commit 68b7934ba62e0888c91aa46c2f850a2572e6e4e2 Author: jordan Date: Mon May 26 12:43:41 2025 -0400 Add stock(mix recovered) files diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..14e2748 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.tar.gz filter=lfs diff=lfs merge=lfs -text +*.g3 filter=lfs diff=lfs merge=lfs -text +*.wav filter=lfs diff=lfs merge=lfs -text +*.sfk filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b54500f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +game +sources.tar.gz +linux/tmp/*.o + diff --git a/dond/core/cab.c b/dond/core/cab.c new file mode 100755 index 0000000..55fdcaa --- /dev/null +++ b/dond/core/cab.c @@ -0,0 +1,242 @@ +// cab.c +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// MTM 20 Jan 05 +// JFL 17 Feb 05; moved into core, cleanup + +#include "pm.h" +#include "mem.h" +#include "str.h" +#include "cab.h" +#include "aud.h" +#include "gun.h" +#include "sys.h" +#include "snd.h" +#include "inp.h" + +#include + +CabGlobal CabG; // cabinet structure + +// +// CabInit +// called once at game power-up +// +// in: +// out: +// global: +// +// MTM 20 Jan 05 +int CabInit(void) +{ + int i; + CabGun *gun; + + MEMZ(CabG); + + for(i=0;igunnum=i; + gun->gunSpeed=1; + } // for + + return 0; +} // CabInit + +// MTM 20 Jan 05 +void CabReset(void) +{ +} // CabReset + +// MTM 20 Jan 05 +void CabFinal(void) +{ +} // CabFinal + +// MTM 20 Jan 05 +// JFL 17 Feb 05 +CabPl* CabGetPl(int n) +{ + if(n>=COUNT(CabG.pl)) + {BP(BP_CABGETPL);n=0;} + return &CabG.pl[n]; +} // CabGetPl + +// JFL 17 Feb 05 +CabGun* CabGetGun(int n) +{ + if((n>=COUNT(CabG.gun))||(n<0)) + {BP(BP_CABGETGUN);n=0;} + return &CabG.gun[n]; +} // CabGetGun + +// JFL 17 Feb 05 +int CabPlAttach(int cabnum,void *pl) +{ + CabPl* cabpl; + cabpl=CabGetPl(cabnum); + cabpl->pl=pl; + return 0; +} // CabPlAttach() + +// JFL 17 Feb 05 +void* CabPlDetach(int cabnum) +{ + CabPl* cabpl; + void *d; + + cabpl=CabGetPl(cabnum); + d=cabpl->pl; + cabpl->pl=NUL; + return d; +} // CabPlDetach() + +// JFL 17 Feb 05 +int CabChangeState(int state) +{ + CabG.state=state; + return 0; +} // CabChangeState() + +// JFL 17 Feb 05 +int CabOp(int op,int n,void *d,void *d2) +{ + BP(BP_CABOP); + return 0; +} // CabOp() + +int CabPlaying(int cNum) +{ + int ec; + CabPl* cabpl; + + if(cNum > CAB_PLAYERS) + berr(-1); + + cabpl=CabGetPl(cNum); + if( cabpl->flags & M_CABPLFLAGS_PLAYING) + ec = 1; + else + ec = 0; + +BAIL: + return ec; +} + +// JFL 17 Feb 05 +// JFL 25 Mar 05 +int CabLoop(void) +{ + int i,j,k,guni; + int m; + CabGun *gun; + InpRec *ir; + + if(!(ir=InpGet(0))) + goto BAIL; + for(guni=0;guniflags&M_CABGUN_ON)) // make sure it's on + continue; + + // + // handle input + // + + if(!guni) + j=INPSW_G0_TRIGGER0; + else if(guni==1) + j=INPSW_G1_TRIGGER0; + else + {BP(BP_CABLOOP);continue;} + + for(i=0;itriggers[i]==ir->count[i+j]) + continue; + gun->triggers[i]=ir->count[i+j]; + m=0; + if(gun->triggers[i]&1) + m|=M_GUNFUNC_TRIGDOWN; + + // jjj -- once we have a real gun attached, review this + if(!(gun->flags&M_CABGUN_POSSET)) + { + // position gun from input record + k=INPGUNTRIG_POS(guni,i); + gun->pos[0]=ir->gunpos[k]; + gun->pos[1]=ir->gunpos[k+1]; + gun->pos[2]=ir->gunpos[k+2]; + } + gun->flags&=~M_CABGUN_POSSET; + + + if(gun->gunfunc) + (*gun->gunfunc)(m|(GUNFUNC_TRIG0+i),gun,NUL,NUL); + + } // for + } // for + +BAIL: + return 0; +} // CabLoop() + + +// +// CabCreditsToCurrencyText +// +// +// in: +// out: +// global: +// +// MTM 23 Jul 01 +// +float CabCreditsToCurrencyText(int32 credits) +{ + float currency; + + currency = (float)credits / 4.0; +// currency = (float)credits /(float)(Adj.coinsPerBill.val * Adj.unitsPerCredit.val); + + return currency; + +//DONE("CabCreditsToCurrencyText") +} // CabCreditsToCurrencyText + + +// +// CabUnusedStarts +// +// +// in: +// out: +// global: +// +// MTM 11 Apr 05 +// +int CabUnusedStarts(void) +{ + int rVal; + + if(Coin.credits >= 4) + rVal=1; + else + rVal=0; + + return rVal; + +//DONE("CabUnusedStarts") +} // CabUnusedStarts + + +void CabDeductCoins(int coinVal) +{ + AudSetCredits(Coin.credits - coinVal); +} + +// EOF diff --git a/dond/core/cab.h b/dond/core/cab.h new file mode 100755 index 0000000..768710c --- /dev/null +++ b/dond/core/cab.h @@ -0,0 +1,82 @@ +#ifndef CAB_H +#define CAB_H +// cab.h +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// MTM 20 Jan 05 +// JFL 17 Feb 05 + +#define CAB_PLAYERS 2 // number of player control sets on cabinet +#define CAB_GUNS 2 // number of guns on the cabinet +#define CAB_TRIGGERS 3 // number of triggers per gun + +#define CAB_NAME_SIZE 16 + +#define M_CABGUN_ON 0x0001 +#define M_CABGUN_POSSET 0x0002 + +typedef struct { + uns8 flags; + uns8 gunnum; + uns8 xx2; + uns triggers[CAB_TRIGGERS]; + int guntype; + void *gundata; // data field + ftype4 *gunfunc; // gun function + crd pos[3]; + float gunSpeed; // world units per millisecond +} CabGun; + +#define M_CABPLFLAGS_ALREADYIN 0x01 //already in, continue is possible +#define M_CABPLFLAGS_PLAYING 0x02 //player is currently playing + +typedef struct { + uns8 pnum; + uns8 flags; + uns16 xx1; + void *pl; +} CabPl; + +enum { + CABSTATE_NONE, + CABSTATE_ATTRACT, + CABSTATE_SELECT_CHARGE, + CABSTATE_CONTINUE, + CABSTATE_GAME, +}; + +typedef struct { + CabPl pl[CAB_PLAYERS]; + CabGun gun[CAB_GUNS]; + uns flags; + uns8 state; + uns8 xx1; + uns16 xx2; +} CabGlobal; + +enum { + CABOP_NONE, +}; +#define M_CABOP 0xff + +// extern routines +extern int CabInit(void); +extern void CabFinal(void); +extern void CabReset(void); +extern CabPl* CabGetPl(int cabnum); +extern CabGun* CabGetGun(int gunnum); +extern int CabPlAttach(int cabnum,void *pl); +extern void* CabPlDetach(int cabnum); +extern int CabChangeState(int state); +extern int CabOp(int op,int n,void *d,void *d2); +extern int CabLoop(void); +extern int CabUnusedStarts(); +extern float CabCreditsToCurrencyText(int32 credits); +extern void CabDeductCoins(int coinVal); +extern int CabPlaying(int cNum); + +extern CabGlobal CabG; // does this need to be global?? + +#endif // ndef CAB_H +// EOF diff --git a/dond/core/cam.c b/dond/core/cam.c new file mode 100755 index 0000000..86dcacb --- /dev/null +++ b/dond/core/cam.c @@ -0,0 +1,68 @@ +// cam.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 19 Oct 04 + +#include "pm.h" +#include "vec.h" +#include "obj.h" +#include "cam.h" + +// JFL 26 May 05 +void CamBuildLookM3(crd *dstm,ObjCam *cam) +{ + crd m1[M3_SIZE],m2[M3_SIZE]; + + M3BuildRot(m1,cam->rot[0],0); + M3BuildRot(m2,cam->rot[1],1); + M3Mul(m1,m1,m2); + M3BuildRot(m2,cam->rot[2],2); + M3Mul(dstm,m1,m2); + +} // CamBuildLookM3() + +// JFL 26 May 05 +// JFL 08 Jun 05 +// JFL 28 Jul 05; shake +void CamBuildVM(crd *dstm,ObjCam *cam) +{ + crd m1[M3_SIZE],m2[M3_SIZE],v[3]; + + M3BuildRot(m1,-cam->rot[0],0); + M3BuildRot(m2,-cam->rot[1],1); + M3Mul(m1,m1,m2); + M3BuildRot(m2,-cam->rot[2],2); + M3Mul(dstm+VM_11,m1,m2); + + if(cam->shake[0]||cam->shake[1]||cam->shake[2]) + { + MathNrmToRot(&cam->nrmkFrust[4*CLIP_NEAR],v); // to get to camera's rotation + M3BuildObj(m1,v); // build matrix + V3RotM3(v,cam->shake,m1); // rotate shake vector to match camera rots + V3Add(v,v,cam->trans); + V3RotM3(dstm+VM_X,v,dstm+VM_11); + } // shake + else + V3RotM3(dstm+VM_X,cam->trans,dstm+VM_11); + + dstm[VM_X]=-dstm[VM_X]; + dstm[VM_Y]=-dstm[VM_Y]; + dstm[VM_Z]=-dstm[VM_Z]; +} // CamBuildVM() + +// JFL 09 Jun 05 +void CamInvM3(crd *dstm,ObjCam *cam) +{ + crd m1[M3_SIZE],m2[M3_SIZE]; + + M3BuildRot(m1,cam->rot[2],0); + M3BuildRot(m2,cam->rot[1],1); + M3Mul(m1,m1,m2); + M3BuildRot(m2,cam->rot[0],2); + M3Mul(dstm,m1,m2); + +} // CamInvM3() + +// EOF + diff --git a/dond/core/cam.h b/dond/core/cam.h new file mode 100755 index 0000000..8b50bcd --- /dev/null +++ b/dond/core/cam.h @@ -0,0 +1,12 @@ +#ifndef CAM_H +#define CAM_H +// cam.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 19 Oct 04 + +extern void CamBuildLookM3(crd *dstm,ObjCam *cam); +extern void CamBuildVM(crd *dstm,ObjCam *cam); +extern void CamInvM3(crd *dstm,ObjCam *cam); + +#endif // ndef CAM_H diff --git a/dond/core/draw.h b/dond/core/draw.h new file mode 100755 index 0000000..6d77edf --- /dev/null +++ b/dond/core/draw.h @@ -0,0 +1,128 @@ +#ifndef DRAW_H +#define DRAW_H +// draw.h +// Copyright 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 25 Feb 05 + +#ifndef RES_H +#include "res.h" +#endif + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +//----------------------------------------------------------------------------- +// SYS_GL +#if SYS_GL + +#define M_SRFRAMEFLAGS_AMBIENT 0x0001 +#define M_SRFRAMEFLAGS_DBG_GCOL 0x0002 +#define M_SRFRAMEFLAGS_GOTMATRICES 0x0004 +#define M_SRFRAMEFLAGS_HASLIGHTS 0x0008 +#define M_SRFRAMEFLAGS_SHADOWDIR 0x0010 +#define M_SRFRAMEFLAGS_SHADOWPOS 0x0020 +#define M_SRFRAMEFLAGS_CULLPLANES 0x0040 +#define M_SRFRAMEFLAGS_ORTHOPROJ 0x0080 //current projection is orthographic + +typedef struct { + uns32 tex; + uns16 mode; + uns16 frameflags; + uns16 camNum; + ObjCam *ocam; + ObjStartSortBuf *sort; + uns lightMask; + int matDepth; + float shadowLight[3]; + N2 afterShadList; + crd *cullPlaneEqs; // only if M_SRFRAMEFLAGS_CULLPLANES, nrmk * CLIP_NUM + crd cullPlaneXYZ[3*CLIP_NUM]; // only if M_SRFRAMEFLAGS_CULLPLANES, xyz * CLIP_NUM + uns culled; + uns32 bBlend; + uns32 bColorMaterial; + uns32 curTex; + uns32 bTex2D; + uns32 bAlphaTest; + uns32 bLighting; + uns32 glShadeModel; + uns32 glTexEnv; + uns32 glAlphaFunc; + uns8 colorR; + uns8 colorG; + uns8 colorB; + uns8 colorA; + uns32 bLights[VID_MAXLIGHTS]; + uns32 draw1; + uns32 draw2; + uns32 draw3; + uns32 draw2Tris; + uns32 draw2Quads; + uns32 draw2Basic; + uns32 draw2Lists; + uns32 draw2Matrix; + uns32 draw2MaxTris; + uns32 draw2MinTris; + uns32 draw2MaxQuads; + uns32 draw2MinQuads; + uns32 draw3Tris; + uns32 draw3Quads; + uns32 draw3Basic; + uns32 draw3Lists; + uns32 draw3MaxTris; + uns32 draw3MinTris; + uns32 draw3MaxQuads; + uns32 draw3MinQuads; + uns32 draw3Mixed; +} StateRec; + +#define M_DRAWDISP_DEFAULT 0x00 +#define M_DRAWDISP_NOMAT 0x01 +#define M_DRAWDISP_NOSORT 0x02 +#define M_DRAWDISP_BLENDPASS 0x04 +#define M_DRAWDISP_ONEQUAD 0x08 +#define M_DRAWDISP_ONETRI 0x10 +#define M_DRAWDISP_ONEPASS 0x20 +#define M_DRAWDISP_AFTERSHADOWS 0x40 +#define M_DRAWDISP_DRAWSORTONCE 0x80 +#define M_DRAWDISP_INDEX 0xfffff000 +#define S_DRAWDISP_INDEX 12 + +#define M_DRAWPOS_DST 0x000f +#define M_DRAWPOS_DSTVM 0x0001 +#define M_DRAWPOS_DSTRTS 0x0002 +#define M_DRAWPOS_DSTRTSP 0x0003 +#define M_DRAWPOS_DSTM3 0x0004 + +#endif // SYS_GL +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +// extern routines +extern int DrawInit(void); +extern int DrawReset(uns reset); +extern void DrawDisp1(StateRec *sr,ResDataDisp1 *disp1); +extern void DrawDisp2(StateRec *sr,Obj *o,ResDataDisp2 *disp2,uns flags); +extern void DrawDisp3(StateRec *sr,Obj *o,ResDataDisp3 *disp3,uns flags); +extern void DrawCol(StateRec *sr,ObjColRes *ocr,ResDataCol *col); +extern void DrawShadows(StateRec *sr,ObjTmpLink *otl); +extern void DrawAfterShadows(StateRec *sr,ObjTmpLink *otl); +extern void DrawStr(StateRec *sr,ObjStr *ostr,uns flags); +extern void DrawSortBuf(StateRec *sr); +extern void DrawFreeSortBuf(ObjStartSortBuf *sort); +extern int DrawAllocSortBuf(StateRec *sr,ObjStartSortBuf *sort); +extern void DrawResetFrame(StateRec *sr); +extern void DrawResetObj(void); +extern int DrawPos(void *dst,crd *scale,ObjDispRes *odr,uns flags); +extern int DrawEmitParticles(StateRec *sr, void *oepv); +extern void DrawInitSortOnce(void); +extern void DrawAccountDisp2SortOnce(Res *r, ResDataDisp2 *d2); +extern void DrawAllocateSortOnce(void); +extern void DrawHideSortOnce(void); +extern void DrawUnhideSortOnce(void); + +// extern vars and mem + +#endif // ndef DRAW_H diff --git a/dond/core/fb.h b/dond/core/fb.h new file mode 100755 index 0000000..8c4ad7b --- /dev/null +++ b/dond/core/fb.h @@ -0,0 +1,112 @@ +#ifndef FB_H +#define FB_H +// fb.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04 + +enum +{ + FB_RESOLUTION_320x240, + FB_RESOLUTION_400x256, + FB_RESOLUTION_512x384, + FB_RESOLUTION_640x480, + FB_RESOLUTION_1366x768, + FB_RESOLUTION_Dev, // development resolution only + FB_NUM_RESOLUTION, +}; + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +//----------------------------------------------------------------------------- +// SYS_JP5500 +#if SYS_JP5500 + +// frame buffer support +#define NUM_FRAMEBUFFERS 2 +#define MAX_FRAMEBUFFER_STRIDE 1024 // 1024 for vga development mode, else 512 +#define MAX_FRAMEBUFFER_HEIGHT 512 + +// +// screen resolution info +// +typedef struct +{ + uns16 bytesPerPixel; + uns16 strideInPixels; + uns16 screenW; + uns16 screenH; + float dispMulX; + float dispMulY; + uns32 crtcReg0; + uns32 crtcReg1; + uns32 gfxSetupReg; + uns32 *modeTable100; + uns32 *modeTable120; +} FbResInfo; + +#define FB_ORIGINAL_WIDTH 640 +#define FB_ORIGINAL_HEIGHT 480 +#define MapDX(x) (((x) * FbRes->screenW) / FB_ORIGINAL_WIDTH) +#define MapDY(y) (((y) * FbRes->screenH) / FB_ORIGINAL_HEIGHT) + +#define M_DISP_INTFLASH_REQUEST 0x01 +#define M_DISP_INTFLASH_WHITEGUNS 0x02 +#define M_DISP_INTFLASH_SCREENWASWHITE 0x04 +#define M_DISP_INTFLASH_ONESHOT_FAKEFLASH 0x08 + +extern void FbIntHandler(void); + +extern FbResInfo *FbRes; +extern volatile uns8* FbDrawBuf; +extern volatile uns FbIntFlipReq; // request flip from Vblank Int +extern volatile int DispIntFlash; + +#endif // SYS_JP5500 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// SYS_PC +#if SYS_PC|SYS_BB + +#define NUM_FRAMEBUFFERS 2 + +// +// screen resolution info +// +typedef struct +{ + uns16 bytesPerPixel; + uns16 strideInPixels; + uns16 screenW; + uns16 screenH; + float dispMulX; + float dispMulY; +} FbResInfo; + +#define FB_ORIGINAL_WIDTH 640 +#define FB_ORIGINAL_HEIGHT 480 +#define MapDX(x) (((x) * FbRes->screenW) / FB_ORIGINAL_WIDTH) +#define MapDY(y) (((y) * FbRes->screenH) / FB_ORIGINAL_HEIGHT) + +extern int FbSetMode(int res); +extern void FbWriteDbgInfo(void); + +extern volatile uns FbIntFlipReq; // request flip from Vblank Int + +#endif // SYS_PC|SYS_BB +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +extern int FbInit(void); +extern void FbFinal(void); +extern int FbReset(uns reset); + +extern void FbWriteDbgInfo(void); + +extern FbResInfo *FbRes; + +#endif // ndef FB_H diff --git a/dond/core/fc.c b/dond/core/fc.c new file mode 100755 index 0000000..fa7e5fd --- /dev/null +++ b/dond/core/fc.c @@ -0,0 +1,216 @@ +// fc.c +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 17 Jan 05 + +#include "pm.h" +#include "res.h" + +extern int GConFCJoe(); +extern int AtFCAtStart(); +extern int FCCounterSet(); +extern int FCCounterDecr(); +extern int FCScale(); +extern int fcScaleAxis(); +extern int fcRot(); +extern int fcBlend(); +extern int fcRandVel(); +extern int fcSmoke(); +extern int fcCredits(); +extern int fcDiag(); +extern int fc3DText(); +extern int fcRandSnd(); +extern int fcRandSndVol(); +extern int fcRandNum(); +extern int fcText3dCircleInit(); +extern int fcText3dCircle(); +extern int fcText3dResolve(); +extern int fcCamShake(); +extern int fcKillSecondaries(); +extern int fcTextAdd(); +extern int fcTextSet(); +extern int fcTextFlashOn(); +extern int fcTextFlashOff(); +extern int fcAniWait(); +extern int fcAniRand(); +extern int fcTapOutReset(); +extern int fcTapOut(); +extern int fcPrompt(); +extern int fcPromptInit(); +extern int fcCreditShow(); +extern int fcCreditRoll(); +extern int fcCreditKill(); +extern int fcCredDone(); + +extern int fcDondFirstCaseDone(); +extern int fcDondFadeOut(); +extern int fcDondCaseRevealDone(); +extern int fcDondRedrawValues(); +extern int fcDondFinalCaseDraw(); +extern int fcDondOnTitleDone(); +extern int fcDondDrawCaseValue(); +extern int fcDondSend(); +extern int fcDondListObjects(); +extern int fcDondUpdateCasesLeftText(); +extern int fcDondAskChoicesLeft(); +extern int fcDondUpdateBankerText(); +extern int fcDondDoGameOver(); +extern int fcDondTestBanker(); +extern int fcDondAskCredits(); +extern int fcDondStartTimer(); +extern int fcDondPlayGradedReveal(); +extern int fcDondAskGradedReveal(); +extern int fcDondAskVideoFrame(); +extern int fcDondFadeKillReveal(); +extern int fcDondPlayGradedAudio(); +extern int fcDondPlayGradedCrowdAudio(); +extern int fcDondUnloadVideos(); +extern int fcDondOnDiagStart(); +extern int fcDondShowPrevOffers(); +extern int fcDondAskPrevOffers(); +extern int fcDondShowTicketsWon(); +extern int fcDondPlayCaseOpenVocal(); +extern int fcDondShowContinueText(); +extern int fcDondDoContinue(); +extern int fcDondAskToContinue(); +extern int fcDondInput(); +extern int fcDondSetGameState(); +extern int fcDondAskWRGirl(); +extern int fcDondAskAtrMode(); +extern int fcDondPlayPCaseRV(); +extern int fcDondAttractText(); +extern int fcDondAskCoupOrTick(); +extern int fcDondClearGameText(); +extern int fcDondPlayNDWR(); +extern int fcDondAnimLED(); +extern int fcDondSetLamp(); +extern int fcDondAskSwitchCount(); +extern int fcDondSetCorrectVol(); +extern int fcDondAskAtrSound(); +extern int fcDondAskGoodGame(); +extern int fcDondSetTapFlag(); +extern int fcDondAskTapFlag(); +extern int fcDondAskBufferedInput(); +extern int fcDondAskNumCredits(); +extern int fcDondAskCollectWait(); +extern int fcDondSetLampWrite(); +extern int fcDondAskForFun(); +extern int fcDondShCan(); +extern int fcDondAskSkillGame(); +extern int fcDondIncShCaseAnim(); +extern int fcDondAskShCaseAnim(); +extern int fcDondAskNJS(); +extern int fcDondAskHFA(); + +ResDataFTOne resFTSysList[] = +{ + {"fcgeorge",NUL,}, + {"fcjoe",GConFCJoe,FTYPE_3,}, + {"fcAtStart",AtFCAtStart,FTYPE_3,}, + {"fcCounterSet",FCCounterSet,FTYPE_3,}, + {"fcCounterDecr",FCCounterDecr,FTYPE_3,}, + {"fcScale",FCScale,FTYPE_3,}, + {"fcScaleAxis",fcScaleAxis,FTYPE_3,}, + {"fcRot",fcRot,FTYPE_3,}, + {"fcBlend",fcBlend,FTYPE_3,}, + {"fcRandVel",fcRandVel,FTYPE_3,}, + {"fcSmoke",fcSmoke,FTYPE_3,}, + {"fcCredits",fcCredits,FTYPE_3,}, + {"fcDiag",fcDiag,FTYPE_3,}, + {"fc3DText",fc3DText,FTYPE_3,}, + {"fcRandSnd",fcRandSnd,FTYPE_3,}, + {"fcRandSndVol",fcRandSndVol,FTYPE_3,}, + {"fcRandNum",fcRandNum,FTYPE_3,}, + {"fcText3dCircleInit",fcText3dCircleInit,FTYPE_3,}, + {"fcText3dCircle",fcText3dCircle,FTYPE_3,}, + {"fcText3dResolve",fcText3dResolve,FTYPE_3,}, + {"fcCamShake",fcCamShake,FTYPE_3,}, + {"fcKillSecondaries",fcKillSecondaries,FTYPE_3,}, + {"fcTextAdd",fcTextAdd,FTYPE_3,}, + {"fcTextSet",fcTextSet,FTYPE_3,}, + {"fcTextFlashOn",fcTextFlashOn,FTYPE_3,}, + {"fcTextFlashOff",fcTextFlashOff,FTYPE_3,}, + {"fcAniWait",fcAniWait,FTYPE_3,}, + {"fcAniRand",fcAniRand,FTYPE_3,}, + {"fcTapOutReset",fcTapOutReset,FTYPE_3,}, + {"fcTapOut",fcTapOut,FTYPE_3,}, + {"fcPrompt",fcPrompt,FTYPE_3,}, + {"fcPromptInit",fcPromptInit,FTYPE_3,}, + {"fcCreditShow",fcCreditShow,FTYPE_3,}, + {"fcCreditRoll",fcCreditRoll,FTYPE_3,}, + {"fcCreditKill",fcCreditKill,FTYPE_3,}, + {"fcCredDone",fcCredDone,FTYPE_3,}, + + {"fcDondFirstCaseDone", fcDondFirstCaseDone, FTYPE_3,}, + {"fcDondFadeOut", fcDondFadeOut, FTYPE_3,}, + {"fcDondCaseRevealDone", fcDondCaseRevealDone, FTYPE_3,}, + {"fcDondRedrawValues", fcDondRedrawValues, FTYPE_3,}, + {"fcDondFinalCaseDraw", fcDondFinalCaseDraw, FTYPE_3,}, + {"fcDondOnTitleDone", fcDondOnTitleDone, FTYPE_3,}, + {"fcDondDrawCaseValue", fcDondDrawCaseValue, FTYPE_3,}, + {"fcDondSend", fcDondSend, FTYPE_3,}, + {"fcDondListObjects", fcDondListObjects, FTYPE_3,}, + {"fcDondUpdateCasesLeftText", fcDondUpdateCasesLeftText, FTYPE_3,}, + {"fcDondAskChoicesLeft", fcDondAskChoicesLeft, FTYPE_3,}, + {"fcDondUpdateBankerText", fcDondUpdateBankerText, FTYPE_3,}, + {"fcDondDoGameOver", fcDondDoGameOver, FTYPE_3,}, + {"fcDondTestBanker", fcDondTestBanker, FTYPE_3,}, + {"fcDondAskCredits", fcDondAskCredits, FTYPE_3,}, + {"fcDondStartTimer", fcDondStartTimer, FTYPE_3,}, + {"fcDondPlayGradedReveal", fcDondPlayGradedReveal, FTYPE_3,}, + {"fcDondPlayGradedAudio", fcDondPlayGradedAudio, FTYPE_3,}, + {"fcDondAskGradedReveal", fcDondAskGradedReveal, FTYPE_3,}, + {"fcDondAskVideoFrame", fcDondAskVideoFrame, FTYPE_3,}, + {"fcDondFadeKillReveal", fcDondFadeKillReveal, FTYPE_3,}, + {"fcDondPlayGradedCrowdAudio", fcDondPlayGradedCrowdAudio, FTYPE_3,}, + {"fcDondUnloadVideos", fcDondUnloadVideos, FTYPE_3,}, + {"fcDondOnDiagStart", fcDondOnDiagStart, FTYPE_3,}, + {"fcDondShowPrevOffers", fcDondShowPrevOffers, FTYPE_3,}, + {"fcDondAskPrevOffers", fcDondAskPrevOffers, FTYPE_3,}, + {"fcDondShowTicketsWon", fcDondShowTicketsWon, FTYPE_3,}, + {"fcDondPlayCaseOpenVocal", fcDondPlayCaseOpenVocal, FTYPE_3,}, + {"fcDondShowContinueText", fcDondShowContinueText, FTYPE_3,}, + {"fcDondDoContinue", fcDondDoContinue, FTYPE_3,}, + {"fcDondAskToContinue", fcDondAskToContinue, FTYPE_3,}, + {"fcDondInput", fcDondInput, FTYPE_3,}, + {"fcDondSetGameState", fcDondSetGameState, FTYPE_3,}, + {"fcDondAskWRGirl", fcDondAskWRGirl, FTYPE_3,}, + {"fcDondAskAtrMode", fcDondAskAtrMode, FTYPE_3,}, + {"fcDondPlayPCaseRV", fcDondPlayPCaseRV, FTYPE_3,}, + {"fcDondAttractText", fcDondAttractText, FTYPE_3,}, + {"fcDondAskCoupOrTick", fcDondAskCoupOrTick, FTYPE_3,}, + {"fcDondClearGameText", fcDondClearGameText, FTYPE_3,}, + {"fcDondPlayNDWR", fcDondPlayNDWR, FTYPE_3,}, + {"fcDondAnimLED", fcDondAnimLED, FTYPE_3,}, + {"fcDondSetLamp", fcDondSetLamp, FTYPE_3,}, + {"fcDondAskSwitchCount", fcDondAskSwitchCount, FTYPE_3,}, + {"fcDondSetCorrectVol", fcDondSetCorrectVol, FTYPE_3,}, + {"fcDondAskAtrSound", fcDondAskAtrSound, FTYPE_3,}, + {"fcDondAskGoodGame", fcDondAskGoodGame, FTYPE_3,}, + {"fcDondSetTapFlag", fcDondSetTapFlag, FTYPE_3,}, + {"fcDondAskTapFlag", fcDondAskTapFlag, FTYPE_3,}, + {"fcDondAskBufferedInput", fcDondAskBufferedInput, FTYPE_3,}, + {"fcDondAskNumCredits", fcDondAskNumCredits, FTYPE_3,}, + {"fcDondAskCollectWait", fcDondAskCollectWait, FTYPE_3,}, + {"fcDondSetLampWrite", fcDondSetLampWrite, FTYPE_3,}, + {"fcDondAskForFun", fcDondAskForFun, FTYPE_3,}, + {"fcDondShCan", fcDondShCan, FTYPE_3,}, + {"fcDondAskSkillGame", fcDondAskSkillGame, FTYPE_3,}, + {"fcDondIncShCaseAnim", fcDondIncShCaseAnim, FTYPE_3,}, + {"fcDondAskShCaseAnim", fcDondAskShCaseAnim, FTYPE_3,}, + {"fcDondAskNJS", fcDondAskNJS, FTYPE_3,}, + {"fcDondAskHFA", fcDondAskHFA, FTYPE_3,}, +}; + +struct { + ResDataFType ftype; + ResDataFTOne list; +} ResFTypeSysList = +{ + COUNT(resFTSysList), + 0, // xx1 + resFTSysList // ftypes +}; + +// EOF diff --git a/dond/core/font.h b/dond/core/font.h new file mode 100755 index 0000000..2e37945 --- /dev/null +++ b/dond/core/font.h @@ -0,0 +1,167 @@ +#ifndef FONT_H +#define FONT_H +// font.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 11 Oct 04 + + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +//----------------------------------------------------------------------------- +// SYS_JP5500 +#if SYS_JP5500 + +#endif // SYS_JP5500 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// SYS_PC +#if SYS_PC|SYS_BB + +// jjj -- check this out.. + +#define TB_SCROLL 0x000100 +#define TB_TITLEBAR 0x000200 +#define TB_KILLABLE 0x000400 +#define TB_MOVING 0x000800 +#define TB_TEXT 0x001000 +#define TB_RESIZING 0x002000 +#define TB_RESIZING_L 0x004000 +#define TB_RESIZING_T 0x008000 +#define TB_RESIZING_R 0x010000 +#define TB_RESIZING_B 0x020000 +#define TB_MPICK_ACTIVE 0x040000 +#define TB_DIALOG 0x080000 + + +#define ANI_LOOP 0x000100 +#define ANI_SYNC 0x000200 +#define ANI_SNAP 0x000400 +#define ANI_BRIDGE 0x000800 +#define ANI_LOOP_OFF 0x001000 + +typedef struct { + void *text1; + uns16 flags; + int isDown; + int hiliteLine; + char anchor[32]; + char mString[32]; + void *drawFunc; +} Menu; + +typedef struct { + void *realObj; + char selected; + void *selObj; + void *selFuncObj; +} OTxtTab; + +typedef struct _EditTextBox{ + + void *text1; + uns32 flags; + int objn; + int objtop; + int objbot; + int xOff; + int yOff; + void *selTB; //point to the EditTextBox struct we're selecting obj's from + void (*tbFunc)(struct _EditTextBox *tb); + OTxtTab winTab[512]; + Menu *menu1; + Menu *menu2; + Menu *menu3; +} EditTextBox; + +typedef struct { + char aniName[32]; + int startFrame; + int aniFrame; + uns aniFlags; + float aniSpeed; +} aniPt; + +#if SYS_BB +// drawing bitmap on linux side needs more space -- not sure why +#define FONT_SYSSPACE 2 +#else // !SYS_BB +#define FONT_SYSSPACE 0 +#endif // !SYS_BB + +#endif // SYS_PC|SYS_BB +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +extern int FontInit(void); +extern void FontFinal(void); +extern int FontReset(uns reset); + +extern int FontColor(uns32 rgb); +extern int FontSet(char *s1,char *s2); + +#define M_FONTGAMESTR_CREATE 0x01 +#define M_FONTGAMESTR_NUMC 0x02 // pass in numc +#define M_FONTGAMESTR_HJUST0 0x04 +#define M_FONTGAMESTR_HJUST1 0x08 +#define M_FONTGAMESTR_VJUST0 0x10 +#define M_FONTGAMESTR_VJUST1 0x20 +#define M_FONTGAMESTR_HLEFT (M_FONTGAMESTR_HJUST0) +#define M_FONTGAMESTR_HCENTER (M_FONTGAMESTR_HJUST1) +#define M_FONTGAMESTR_HRIGHT (M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1) +#define M_FONTGAMESTR_VTOP (M_FONTGAMESTR_VJUST0) +#define M_FONTGAMESTR_VCENTER (M_FONTGAMESTR_VJUST1) +#define M_FONTGAMESTR_VBOTTOM (M_FONTGAMESTR_VJUST0|M_FONTGAMESTR_VJUST1) +#define S_FONTGAMESTR_N 8 + +// +// M_FONTSYSFLAG_ +// flags for usage in FontSys() +// +#define M_FONTSYSFLAG_NOBLEND 0x01 + +extern int FontGameStr(char *s1,char *s2,uns flags,float xs, float ys, void *ostr); +extern int FontSys(char *str,int x,int y,int w,int h,uns flags,void *colobj); +#define FontSysSimple(str,x,y) FontSys((str),(x),(y),VidDisp.screenW,VidDisp.screenH,0,NUL) +#define FontSysSimpleFlags(str,x,y,flags) FontSys((str),(x),(y),VidDisp.screenW,VidDisp.screenH,(flags),NUL) +extern int FontObjText(void *objtext); +extern void* FontXYStr(float x,float y,char *str); +// pass in 'l'=left-justify 'r'=right-justify 'h'=horiz-center +// pass in 't'=top-justify 'b'=bottom-justify 'v'=vert-center +// pass in 0x00RRGGBB +extern void* FontXYJCStr(float x,float y,char hjust,char vjust,uns32 rgb,char *str); + +enum { + FONTINFO_NONE, + FONTINFO_CHAR_WIDTH_HEIGHT, // int size[2]; +}; + +//extern int FontObjInfo(void *objtext,int info,void *res); +extern int FontObjInfo(); + +/////////////////////////////////////////////////////////////////////////////// +// TEXT BOX + +//extern int TBDrawTextBox(void *objtext, void *tb, uns32 flags); +//extern int TBDrawMenu(void *objtext, void *m); +//extern void DrawSelBox(void *text, int n, char *namebuf); +//extern void TBDrawSliderBar(void *text, void *tb); +//extern int TBDrawMousePickBox(void *text, uns32 flags); + +extern void FontOutlineBox(char *buf, crd *s, int boxHalfWid, int col); +extern int TBDrawTextBox(); +extern int TBDrawMenu(); +extern void DrawSelBox(); +extern void TBDrawSliderBar(); +extern int TBDrawMousePickBox(); +extern int TBDrawDeerAnimBox(void *vtext, uns flags, void* vpap, int numAniPts, + float splspeed); + +extern void FontConOutputStart(void); +extern void FontConOutputFinish(void); + +#endif // ndef FONT_H diff --git a/dond/core/fs.c b/dond/core/fs.c new file mode 100755 index 0000000..128f7f1 --- /dev/null +++ b/dond/core/fs.c @@ -0,0 +1,140 @@ +// fs.c +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 20 Apr 05 + +#include "pm.h" +#include "sys.h" +#include "str.h" +#include "fs.h" + +char *ext_adj=".adj"; +char *ext_aud=".aud"; +char *ext_cf=".cf"; +char *ext_trn=".trn"; +char *ext_plr=".plr"; +char *ext_lbd=".lbd"; + +// JFL 21 Apr 05 +int FsOp(FsH *fh,char *name,uns type,uns op,void *buf,uns bufSize) +{ + int ec; + FsH fhmem; + char *ext,*path,*s2; + char namebuf[PM_NAME_SIZE+8]; + char pathbuf[PM_FILEPATH_MAX]; + uns8 fisopen=0; + uns f; + + namebuf[0]=0; + switch(type) + { + case FSOPTYPE_ADJ: + ext=ext_adj; + path=SysG.adjpath; + break; + case FSOPTYPE_AUD: + ext=ext_aud; + path=SysG.audpath; + break; + case FSOPTYPE_CF: + ext=ext_cf; + path=SysG.cfpath; + break; + case FSOPTYPE_TRNY: + ext=ext_trn; + path=SysG.trnpath; + break; + case FSOPTYPE_PLAYER: + ext=ext_plr; + path=SysG.plrpath; + break; + case FSOPTYPE_LBOARD: + ext=ext_lbd; + path=SysG.lbdpath; + break; + } // switch + szncat2(namebuf,name,ext,sizeof(namebuf)); + + switch(op&M_FSOP) + { + case FSOP_OPENREADCLOSE: + fh=&fhmem; + + case FSOP_OPEN: + if(!fh) + { + BP(BP_FSOP); + break; + } + + // build path & open + if((ec=FsFindOpen(fh,path,namebuf,0,NUL,0))<0) + goto BAIL; + + if((op&M_FSOP)==FSOP_OPEN) + err(0); + fisopen=1; + + if((ec=FsRead(fh,buf,bufSize))<0) + goto BAIL; + + break; + case FSOP_CREATEWRITECLOSE: + fh=&fhmem; + case FSOP_CREATE: + if(!fh) + { + BP(BP_FSOP2); + break; + } + // if multiple paths, use first + if((s2=szskipto(path,";,"))) + sz2ncpy(pathbuf,path,s2,sizeof(pathbuf)); + else + szncpy(pathbuf,path,sizeof(pathbuf)); + + if(1 + && ((ec=szlen(pathbuf))>0) + && (eclnk.type = N2TYPE_UNK; + N2LinkAfter(&bufList,nb); + } // for + + return 0; +} // FTPReset() + +// JFL 01 Oct 04 +int ftpBufGet(NetBuf **bufp) +{ + NetBuf *nb; + + if(!(nb=bufList.next) || !(nb->lnk.type)) + { + LOCKUP(BP_FTPBUFGET); // out of bufs + return -1; + } + + N2Unlink(nb); + MemZero(nb,sizeof(NetBuf)); + *bufp=nb; + + ftpG.bufCount++; + return 0; +} // ftpBufGet() + +// JFL 01 Oct 04 +void ftpBufFree(NetBuf *nb) +{ + if(nb->uflags&M_NETBUF_UFLAGS_ALLOC) + MemDFree(MEMPOOL_NET,nb->buf); + ftpG.bufCount--; + N2LinkAfter(&bufList,nb); +} // ftpBufFree() + +typedef struct { + uns16 portB; + uns8 ipB[4]; +} phFTPCTL; + +#define M_PH_ALLOC 0x0100 +#define M_PH_LISTENING 0x0200 +#define M_PH_SENDING 0x0400 + +// JFL 02 Oct 04 +void phFree(NetPH *ph) +{ + if(ph->p1 && ph->flags&M_PH_ALLOC) + { + MemDFree(MEMPOOL_NET,ph->p1); + ph->flags&=~M_PH_ALLOC; + ph->p1=NUL; + } + + if(ph->flags&(M_PH_LISTENING|M_PH_SENDING)) + { + NetPortRem(ph); + ph->flags&=~(M_PH_LISTENING|M_PH_SENDING); + } + +} // phFree() + +// JFL 01 Oct 04 +int FTPOpen(int open) +{ + int ec; + NetPH *ph; + + if(open) + { + ph=&ftpG.ftpctl; + + ph->flags=0; + ph->p1=NUL; + ph->port=NETPORT_FTPCTL; + + if((ec=MemDAlloc(MEMPOOL_NET,sizeof(phFTPCTL),&ph->p1))<0) + goto BAIL; + ph->flags|=M_PH_ALLOC; + + if((ec=NetPortAddListener(ph,NETPORT_FTPCTL,M_NETPORTADD_SENDBACK))<0) + goto BAIL; + ph->flags|=M_PH_LISTENING; + } + else + { + ph=&ftpG.ftpctl; + phFree(ph); + } + + ec=0; +BAIL: + return ec; +} // FTPOpen() + +/////////////////////////////////////////////////////////////////////////////// +// + +// strings -- keep all even lengths +char *ftp200FTP="200 FTP ready.\r\n"; +#define FTP200FTP_LEN 16 + +char *ftp200PORT="200 Port OK.\r\n"; +#define FTP200PORT_LEN 14 + +char *ftp200TYPEA="200 Ascii OK..\r\n"; +char *ftp200TYPEB="200 Binary OK.\r\n"; +#define FTP200TYPE_LEN 16 + +char *ftp200CWD="200 Cwd OK..\r\n"; +#define FTP200CWD_LEN 14 + +const char *ftp150="150 Ready.\r\n"; +#define FTP150_LEN 12 + +const char *ftp215="215 UNIX\r\n"; +#define FTP215_LEN 10 + +const char *ftp221="221 Bye.\r\n"; +#define FTP221_LEN 10 + +const char *ftp226="226 Complete..\r\n"; +#define FTP226_LEN 16 + +const char *ftp231="231 User OK.\r\n"; +#define FTP231_LEN 14 + +const char *ftp500="500 Syntax unrecognized.\r\n"; +#define FTP500_LEN 26 + +const char *ftp501="501 Syntax invalid..\r\n"; +#define FTP501_LEN 22 + +const char *ftp550="550 Error.\r\n"; +#define FTP550_LEN 12 + +// JFL 03 Oct 04 +int ftpPWD(NetPH *ph) +{ + int ec; + NetBuf *nb; + char *buf; + int buflen; + + if((ec=ftpBufGet(&nb))<0) + goto BAIL; + + nb->bufSize=512; + if((ec=MemDAlloc(MEMPOOL_NET,nb->bufSize,&nb->buf))<0) + { + nb->bufSize=0; + goto BAIL; + } + else + nb->uflags|=M_NETBUF_UFLAGS_ALLOC; + + buf=nb->buf; + buflen=nb->bufSize-4-4; + + buf[0]='2'; + buf[1]='3'; + buf[2]='1'; + buf[3]=' '; + buf+=4; + + if((ec=FsCurDir(0,0,buf,buflen))<0) + { + MemDFree(MEMPOOL_NET,nb->buf); + nb->uflags&=~M_NETBUF_UFLAGS_ALLOC; + goto BAIL; + } + + if(ec&1) buf[ec++]=' '; + buf[ec++]='\r'; + buf[ec++]='\n'; + nb->bufLen=4+ec; + + if((ec=NetPortAddSdBuf(ph,nb,0))<0) + goto BAIL; + + ec=0; +BAIL: + return ec; +} // ftpPWD() + +// JFL 03 Oct 04 +void szlinefill(char *buf,int buflen,int linelen,char *eols,int zeroterm) +{ + int i,k,numeols; + char c; + + for(numeols=0;eols[numeols];numeols++) + /* skip till end */ ; + + c='a'; + for(i=0;i0) + { + buf[i++]='X'; + buf[i++]='Y'; + buf[i++]='Z'; + for(k=0;kp1)) + { + LOCKUP(BP_FTPLIST); + err(-2); + } + ph2=&ftpG.ftpdat; + if(ph2->port) + err(1); + ph2->port=NETPORT_FTPDAT; + ph2->flags=0; + ph2->p1=NUL; + + if((ec=NetPortInfo(NUL,NETPORTINFO_OFF_THEIRMAC))<0) + goto BAIL; + mac=(void*)(ec+(memu)phc); + if((ec=NetPortInfo(NUL,NETPORTINFO_OFF_THEIRIP))<0) + goto BAIL; + ip=(void*)(ec+(memu)phc); + + if((ec=NetPortAddSender(ph2,NETPORT_FTPDAT,0,mac,ip,phfc->portB))<0) + goto BAIL; + phc->phOther=ph2; + ph2->phOther=phc; + + // + // + // + + if((ec=ftpBufGet(&nb))<0) + goto BAIL; + + buflen=1024*2; + if((ec=MemDAlloc(MEMPOOL_NET,buflen,&buf))<0) + goto BAIL; + + szlinefill(buf,buflen,20,"\r\n",0); + + nb->buf=buf; + nb->bufLen=nb->bufSize=buflen; + nb->uflags|=M_NETBUF_UFLAGS_ALLOC|M_NETBUF_UFLAGS_FUNC; + nb->uval=NETBUF_UVAL_FTPLIST; + + if((ec=NetPortAddSdBuf(ph2,nb,M_NETPORTADD_FIN))<0) + goto BAIL; + nb=NUL; + buf=NUL; + + ec=0; +BAIL: + if(nb) + ftpBufFree(nb); + if(buf) + MemDFree(MEMPOOL_NET,buf); + return ec; +} // ftpLIST() + +// JFL 01 Oct 04 +int ftpRvCTL(NetPH *ph,NetBuf *nbr) +{ + int ec; + NetBuf *nb=NUL; + char c,*str; + uns8 *buf; + int buflen; + uns8 *sd=NUL; + uns16 sdlen; + phFTPCTL *phfc=ph->p1; + uns flags=0; + + if((ec=ftpBufGet(&nb))<0) + { + LOCKUP(BP_FTPRVCTL); + goto BAIL; + } + + buf=nbr->buf; + buflen=nbr->bufLen; + + c = *buf++;if(c>='a'&&c<='z') c=c-'a'+'A'; + str=szskiptowhite(buf); + str=szskipwhite(str); + + if(c=='C') goto cwd; + if(c=='L') goto list; + if(c=='P') + { + c = *buf++;if(c>='a'&&c<='z') c=c-'a'+'A'; + if(c=='O') goto port; + else goto pwd; + } // P + if(c=='Q') goto quit; + if(c=='S') + { + c = *buf++;if(c>='a'&&c<='z') c=c-'a'+'A'; + if(c=='T') goto stor; + else goto syst; + } // S + if(c=='T') goto type; + if(c=='U') goto user; + if(c=='X') + { + c = *buf++;if(c>='a'&&c<='z') c=c-'a'+'A'; + if(c=='C') goto cwd; + else goto pwd; + } // X + + // not handled.. + BP(BP_FTPRVCTL3); + goto syntax; + +user: + sd=(void*)ftp231; + sdlen=FTP231_LEN; + goto send; + +quit: + sd=(void*)ftp221; + sdlen=FTP221_LEN; + flags|=M_NETPORTADD_FIN; + goto send; + +port: + if(!phfc) + goto error; + + str=szto( str,NUL,'c',10,(void*)(0+(memu)&phfc->ipB)); // bytes + str=szto(1+str,NUL,'c',10,(void*)(1+(memu)&phfc->ipB)); + str=szto(1+str,NUL,'c',10,(void*)(2+(memu)&phfc->ipB)); + str=szto(1+str,NUL,'c',10,(void*)(3+(memu)&phfc->ipB)); + str=szto(1+str,NUL,'c',10,(void*)(1+(memu)&phfc->portB)); // port + str=szto(1+str,NUL,'c',10,(void*)&phfc->portB); + + sd=(void*)ftp200PORT; + sdlen=FTP200PORT_LEN; + goto send; + +list: + + ec=ftpLIST(ph); + + if(ec>=0) + { + sd=(void*)ftp150; // Ready.. + sdlen=FTP150_LEN; + goto send; + } + goto BAIL; + +type: + c = *str++;if(c>='a'&&c<='z') c=c-'a'+'A'; + if(c=='A') + sd=(void*)ftp200TYPEA; + else + sd=(void*)ftp200TYPEB; + sdlen=FTP200TYPE_LEN; + goto send; + +syst: + // not done + sd=(void*)ftp215; + sdlen=FTP215_LEN; + goto send; + +stor: + goto send; + +pwd: + + ec=ftpPWD(ph); + goto BAIL; + +cwd: + + buf = str; + buflen = nbr->bufLen; + buflen -= (memu)buf-(memu)nbr->buf; + + if((ec=FsCurDir(0,1,buf,buflen))<0) + goto error; + + sd=(void*)ftp200CWD; + sdlen=FTP200CWD_LEN; + goto send; + + if(0) + { +error: +syntax: + sd=(void*)ftp500; + sdlen=FTP500_LEN; +send: + nb->buf=sd; + nb->bufLen=sdlen; + if((ec=NetPortAddSdBuf(ph,nb,flags))<0) + LOCKUP(BP_FTPRVCTL2); + nb=NUL; + } // send + + ec=0; +BAIL: + if(nb) + ftpBufFree(nb); + return ec; +} // ftpRvCTL() + +// JFL 04 Oct 04 +int ftpNetBufFunc(NetPH *ph,uns cmd) +{ + int ec; + NetPH *ph2; + NetBuf *nb2; + + switch(cmd) + { + case NETPORTSTACK_SENT_AND_UNLINKED: + + // NETBUF_UVAL_FTPLIST + if(!(ph2=ph->phOther)) + { + LOCKUP(BP_FTPNETBUFFUNC1); // missing other + break; + } + + if(ph2->port!=NETPORT_FTPCTL) + { + LOCKUP(BP_FTPNETBUFFUNC2); // must be control port + break; + } + + if((ec=ftpBufGet(&nb2))<0) + { + LOCKUP(BP_FTPNETBUFFUNC3); + goto BAIL; + } + + nb2->buf=(void*)ftp226; + nb2->bufLen=FTP226_LEN; + if((ec=NetPortAddSdBuf(ph2,nb2,0))<0) + LOCKUP(BP_FTPNETBUFFUNC4); + + break; + } // switch + ec=0; +BAIL: + return ec; +} // ftpNetBufFunc() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 01 Oct 04 +int FTPLoop(void) +{ + int ec; + sto args[NETPORTSTACK_ARGBUF_NUM]; + NetPH *ph; + NetBuf *nb; + + while((ec=NetPortPop(&ph,&args[0]))>0) + { + switch(ec) + { + + case NETPORTSTACK_REMOTE_TRYING_TO_OPEN: + + // respond + + // create a receive buffer + if((ec=ftpBufGet(&nb))<0) + goto BAIL; + + nb->bufSize=128; + if((ec=MemDAlloc(MEMPOOL_NET,nb->bufSize,&nb->buf))<0) + { + nb->bufSize=0; + LOCKUP(BP_FTPLOOP1); + } + else + nb->uflags|=M_NETBUF_UFLAGS_ALLOC; + + NetPortAddRvBuf(ph,nb); + + if(ph->port==NETPORT_FTPCTL) + { + if((ec=ftpBufGet(&nb))<0) + goto BAIL; + nb->buf=ftp200FTP; + nb->bufLen=FTP200FTP_LEN; + if((ec=NetPortAddSdBuf(ph,nb,0))<0) + LOCKUP(BP_FTPLOOP2); + } // ftpctl + + break;// NETPORTSTACK_REMOTE_TRYING_TO_OPEN + + case NETPORTSTACK_CLOSING: + if((ec=ftpBufGet(&nb))<0) + goto BAIL; + if((ec=NetPortAddSdBuf(ph,nb,0))<0) + LOCKUP(BP_FTPLOOP3); + break; // NETPORTSTACK_CLOSING + + case NETPORTSTACK_UNLINKED: + nb=(void*)args[0]; // buf is unlinked + + ftpBufFree(nb); // add it back into free list + break; // NETPORTSTACK_CLOSED_AND_UNLINKED + + case NETPORTSTACK_RECEIVED_AND_UNLINKED: + nb=(void*)args[0]; // buf is unlinked + + // buf of received data + + if(ph->port==NETPORT_FTPCTL) + ftpRvCTL(ph,nb); + + NetPortAddRvBuf(ph,nb); // pass it back to net system + break; // NETPORTSTACK_FILLED_AND_UNLINKED + + case NETPORTSTACK_SENT_AND_UNLINKED: + nb=(void*)args[0]; // buf is unlinked + + // buf has been sent + if(nb->uflags & M_NETBUF_UFLAGS_FUNC) + { + ftpNetBufFunc(ph,NETPORTSTACK_SENT_AND_UNLINKED); + ftpBufFree(nb); // add it back into free list + NetPortRem(ph); + ph->port=0; + } + else + { + ftpBufFree(nb); // add it back into free list + } + + break; // NETPORTSTACK_SENT_AND_UNLINKED + + case NETPORTSTACK_ERROR: + break; // NETPORTSTACK_ERROR + + } // switch + } // while + + ec=0; +BAIL: + return ec; +} // FTPLoop() + +// EOF diff --git a/dond/core/ftp.h b/dond/core/ftp.h new file mode 100755 index 0000000..dc5b9d3 --- /dev/null +++ b/dond/core/ftp.h @@ -0,0 +1,18 @@ +#ifndef FTP_H +#define FTP_H +// net.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 08 Sep 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +extern int FTPInit(void); +extern void FTPFinal(void); +extern int FTPReset(uns reset); +extern int FTPOpen(int open); + +extern int FTPLoop(void); + +#endif // ndef FTP_H diff --git a/dond/core/gun.c b/dond/core/gun.c new file mode 100755 index 0000000..8841ea3 --- /dev/null +++ b/dond/core/gun.c @@ -0,0 +1,146 @@ +// gun.c +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 24 Mar 05 + +#include "pm.h" +#include "mem.h" +#include "inp.h" +#include "cab.h" +#include "gun.h" + +#include + +typedef struct { + int dummy; +} gunGlobals; + +gunGlobals gunG; + +// JFL 24 Mar 05 +int GunInit(void) +{ + return 0; +} // GunInit() + +// JFL 24 Mar 05 +int GunReset(uns reset) +{ + MEMZ(gunG); + return 0; +} // GunReset() + +// JFL 24 Mar 05 +void GunFinal(void) +{ +} // GunFinal() + +// JFL 24 Mar 05 +int GunSetXY(int guni,int x,int y) +{ + CabGun *gun; + + if(!(gun=CabGetGun(guni))) // get the gun + {BP(BP_GUNSETXY);return -1;} + + gun->pos[0]=x; + gun->pos[1]=y; + gun->pos[2]=0; + gun->flags|=M_CABGUN_POSSET; + + return 0; +} // GunSetXY() + +// JFL 17 Feb 05 +int GunOp(int op,int n,void *d,void *d2) +{ + int ec; + int i,j; + CabGun *gun; + InpRec *ir; + + switch(op&M_CABOP) + { + case GUNOP_SETGUNFUNCDATA: + gun=CabGetGun(n); + gun->gunfunc=d; + gun->gundata=d2; + break; + case GUNOP_SETGUNDATA: + gun=CabGetGun(n); + gun->gundata=d; + break; + case GUNOP_GUN_ON: + gun=CabGetGun(n); + gun->flags|=M_CABGUN_ON; + JammaOp(JAMMAOP_GUNONOFF,n,1); + + if(!(ir=InpGet(0))) + break; + + if(!n) + j=INPSW_G0_TRIGGER0; + else if(n==1) + j=INPSW_G1_TRIGGER0; + else + { + BP(BP_GUNOP1); + break; + } + + // copy current trigger counts + for(i=0;itriggers[i]=ir->count[i+j]; + + break; + case GUNOP_GUN_OFF: + gun=CabGetGun(n); + gun->flags&=~M_CABGUN_ON; + JammaOp(JAMMAOP_GUNONOFF,n,0); + break; + case GUNOP_ALLGUNS_ON: + for(n=0;nflags|=M_CABGUN_ON; + JammaOp(JAMMAOP_GUNONOFF,n,1); + + if(!(ir=InpGet(0))) + break; + if(!n) + j=INPSW_G0_TRIGGER0; + else if(n==1) + j=INPSW_G1_TRIGGER0; + else + { + BP(BP_GUNOP2); + continue; + } + + // copy current trigger counts + for(i=0;itriggers[i]=ir->count[i+j]; + + } // for + break; + case GUNOP_ALLGUNS_OFF: + for(n=0;nflags&=~M_CABGUN_ON; + JammaOp(JAMMAOP_GUNONOFF,n,0); + } // for + break; + default: + BP(BP_GUNOP3); + err(-1); + } // switch + + ec=0; +BAIL: + return ec; +} // GunOp() + + +// EOF diff --git a/dond/core/gun.h b/dond/core/gun.h new file mode 100755 index 0000000..69c20f1 --- /dev/null +++ b/dond/core/gun.h @@ -0,0 +1,43 @@ +#ifndef GUN_H +#define GUN_H +// gun.h +// Copyright 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 24 Mar 05 + +/////////////////////////////////////////////////////////////////////////////// +// + +// +// GUN -- this will be split into its own file soon.. +// + +enum { + GUNFUNC_NONE, + GUNFUNC_TRIG0, // (..,CabGun*,NUL,NUL) + GUNFUNC_TRIG1, + GUNFUNC_TRIG2, +}; +#define M_GUNFUNC 0xff +#define M_GUNFUNC_TRIGDOWN 0x100 + +enum { + GUNOP_NONE, + GUNOP_SETGUNFUNCDATA, + GUNOP_SETGUNDATA, + GUNOP_GUN_ON, + GUNOP_GUN_OFF, + GUNOP_ALLGUNS_ON, + GUNOP_ALLGUNS_OFF, +}; +#define M_GUNOP 0xff + +// gun routines +extern int GunOp(int op,int n,void *d,void *d2); + +extern int GunInit(void); +extern void GunFinal(void); +extern int GunReset(uns reset); +extern int GunTrigger(void *gun,uns n); + +#endif // ndef GUN_H diff --git a/dond/core/inp.c b/dond/core/inp.c new file mode 100755 index 0000000..501b033 --- /dev/null +++ b/dond/core/inp.c @@ -0,0 +1,1022 @@ +// inp.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 18 Oct 04 +// JFL 21 Jun 05; serial jamma +// JFL 22 Jul 05; + +#include "pm.h" +#include "mem.h" +#include "str.h" +#include "inp.h" +#include "wnd.h" +#include "donglecheck.h" + +extern void AudWatchdog(void); // from aud.h -- create GameCallback() +extern void AudTixError(int); + +#include +#include + +typedef struct { + InpRec inprec0; + uns jammaSwitchCount[JAMMASW_NUM]; + uns8 jammaSwitchCountInit; + uns8 jammaWatchdogCheck; + uns8 unused1; + uns8 unused2; + uns64 jammaDipTime; +} inpGlobals; + +inpGlobals inpG; + +int inpJammaCallback(int op,...); + +#define INP_JAMMADIPCHECK_TIME 5000 // check in milliseconds + +// JFL 18 Oct 04 +int InpInit(void) +{ + int ec; + + MEMZ(inpG); + + if((ec=JammaInit())<0) + SysLog("JammaInit() failed %d\n",ec); + if((ec=JammaOp(JAMMAOP_SETCALLBACK,inpJammaCallback))<0) + SysLog("JammaOp(JAMMAOP_SETCALLBACK) failed %d\n",ec); + JammaOp(JAMMAOP_SETSCRWH,640,480); + SysG.projammasn=JammaOp(JAMMAOP_GETSN,0); + + // some debugging mode +// JammaOp(JAMMAOP_WATCHLIGHTSONOFF,1); // start buttons reflect gun state + //JammaOp(JAMMAOP_WHITEFLASH_VFB_HFB,33,514,42,654); + + inpG.jammaDipTime=INP_JAMMADIPCHECK_TIME; + + ec=0; +//BAIL: + return 0; +} // InpInit() + +// JFL 18 Oct 04 +int InpReset(uns reset) +{ + if(!reset) + MEMZ(inpG); + return 0; +} // InpReset() + +// JFL 18 Oct 04 +void InpFinal(void) +{ + JammaFinal(); +} // InpFinal() + +// JFL 18 Oct 04 +InpRec* InpGet(uns id) +{ + return &inpG.inprec0; +} // InpGet() + +#define M_INPSWFLAG_FLUSH 0x01 + +// inpSwFlag[] +// general info about each switch +uns8 inpSwFlag[INPSW_NUM] = +{ +/* INPSW_NONE, */ 0, +/* INPSW_P0_L, */ M_INPSWFLAG_FLUSH, +/* INPSW_P0_R, */ M_INPSWFLAG_FLUSH, +/* INPSW_P0_U, */ M_INPSWFLAG_FLUSH, +/* INPSW_P0_D, */ M_INPSWFLAG_FLUSH, +/* INPSW_P0_U2, */ M_INPSWFLAG_FLUSH, +/* INPSW_P0_D2, */ M_INPSWFLAG_FLUSH, +/* INPSW_P0_START, */ M_INPSWFLAG_FLUSH, +/* INPSW_P1_START, */ M_INPSWFLAG_FLUSH, +/* INPSW_MOUSE_LB, */ M_INPSWFLAG_FLUSH, +/* INPSW_MOUSE_CB, */ M_INPSWFLAG_FLUSH, +/* INPSW_MOUSE_RB, */ M_INPSWFLAG_FLUSH, +/* INPSW_MOUSE2_LB, */ M_INPSWFLAG_FLUSH, +/* INPSW_MOUSE2_RB, */ M_INPSWFLAG_FLUSH, +/* INPSW_MODE, */ M_INPSWFLAG_FLUSH, +/* INPSW_ESC, */ M_INPSWFLAG_FLUSH, +/* INPSW_G0_TRIGGER0, */ M_INPSWFLAG_FLUSH, +/* INPSW_G0_TRIGGER1, */ M_INPSWFLAG_FLUSH, +/* INPSW_G0_TRIGGER2, */ M_INPSWFLAG_FLUSH, +/* INPSW_G1_TRIGGER0, */ M_INPSWFLAG_FLUSH, +/* INPSW_G1_TRIGGER1, */ M_INPSWFLAG_FLUSH, +/* INPSW_G1_TRIGGER2, */ M_INPSWFLAG_FLUSH, +/* INPSW_G0_RAW0, */ M_INPSWFLAG_FLUSH, +/* INPSW_G1_RAW0, */ M_INPSWFLAG_FLUSH, +/* INPSW_COIN1, */ 0, +/* INPSW_COIN2, */ 0, +/* INPSW_DIAG, */ M_INPSWFLAG_FLUSH, +/* INPSW_VOLUP, */ M_INPSWFLAG_FLUSH, +/* INPSW_VOLDOWN, */ M_INPSWFLAG_FLUSH, +/* INPSW_BILL, */ 0, +/* INPSW_SERVICE, */ M_INPSWFLAG_FLUSH, +}; // inpSwFlags; + +typedef struct { + char *name; + uns jammamask; + uns jammasw; + uns inp; + uns inpsw; +} inpJammaMapRec; + +inpJammaMapRec inpJammaSwMap[] = +{ + // UP is assumed to be DOWN+1 + // INPLOWEVENT_G0_RAW0_DOWN is used b/c trigger event is sent through + // inpJammaCallback() + {"g11",M_JAMMASW_GUN1_TRIG1,JAMMASW_GUN1_TRIG1,INPLOWEVENT_G0_RAW0_DOWN, + INPSW_G0_TRIGGER0}, + {"g21",M_JAMMASW_GUN2_TRIG1,JAMMASW_GUN2_TRIG1,INPLOWEVENT_G1_RAW0_DOWN, + INPSW_G1_TRIGGER0}, + {"g12",M_JAMMASW_GUN1_TRIG2,JAMMASW_GUN1_TRIG2,INPLOWEVENT_P0_TRIG1_DOWN, + INPSW_G0_TRIGGER1}, + {"g22",M_JAMMASW_GUN2_TRIG2,JAMMASW_GUN2_TRIG2,INPLOWEVENT_P1_TRIG1_DOWN, + INPSW_G1_TRIGGER1}, + {"st1",M_JAMMASW_P1_START,JAMMASW_P1_START,INPLOWEVENT_P0_START_DOWN, + INPSW_P0_START}, + {"st2",M_JAMMASW_P2_START,JAMMASW_P2_START,INPLOWEVENT_P1_START_DOWN, + INPSW_P1_START}, + {"cn1",M_JAMMASW_COIN1,JAMMASW_COIN1,INPLOWEVENT_COIN1_DOWN, + INPSW_COIN1}, + {"cn2",M_JAMMASW_COIN2,JAMMASW_COIN2,INPLOWEVENT_COIN2_DOWN, + INPSW_COIN2}, + {"bil",M_JAMMASW_BILL,JAMMASW_BILL,INPLOWEVENT_BILL_DOWN, + INPSW_BILL}, + {"srv",M_JAMMASW_SERVICE,JAMMASW_SERVICE,INPLOWEVENT_SERVICE_DOWN, + INPSW_SERVICE}, + {"tst",M_JAMMASW_TEST,JAMMASW_TEST,INPLOWEVENT_DIAG_DOWN, + INPSW_DIAG}, + {"vup",M_JAMMASW_VOLUP,JAMMASW_VOLUP,INPLOWEVENT_VOLUP_DOWN, + INPSW_VOLUP}, + {"vdn",M_JAMMASW_VOLDOWN,JAMMASW_VOLDOWN,INPLOWEVENT_VOLDOWN_DOWN, + INPSW_VOLDOWN}, + {"",0,} // term +}; // inpJammaMapRec[] + + +// JFL 18 Oct 04 +// JFL 10 Aug 05; read dips +// JFL 18 Aug 05; +int InpLoop(void) +{ + // once per loop + + int i; + uns j,m; + InpRec *ir; + uns *swcount; + inpJammaMapRec *jmr; + + if(!(ir=InpGet(0))) + return -1; + + // these bits are dropped at the start of the loop + // and or'd in anytime they are read (i.e. they don't set the change bits) + ir->state&=~(M_INP_SHF|M_INP_ALT|M_INP_CTL); + xInpLowScan(); // re-set any of the flag bits cleared but still valid + + // + // process jamma board + // + + if((i=JammaLoop())<0) // every-loop processing for Jamma + { + if (i != -2) // for some reason, this error will happen + SysLog("JammaLoop() failed %d, resetting jamma\n",i); + if((i=JammaOp(JAMMAOP_RESET))<0) + SysLog("JammaOp(JAMMAOP_RESET) failed %d\n",i); + } + #if PRODUCTION + if(i>0) + SysG.proflags|=M_SYSG_PROFLAGS_JAMMALIVES2; + #endif // PRODUCTION + + if(!inpG.jammaSwitchCountInit) + { + if(JammaOp(JAMMAOP_GETSWCOUNT|M_JAMMAOP_CLEAR|M_JAMMAOP_IGNORECHANGED,NUL,&swcount)>=0) + { + inpG.jammaSwitchCountInit=1; + for(jmr=inpJammaSwMap;jmr->jammamask;jmr++) + inpG.jammaSwitchCount[jmr->jammasw]=swcount[jmr->jammasw]; + } + } // inpG.jammaSwitchCountInit + + // get change change + if(inpG.jammaSwitchCountInit && + (JammaOp(JAMMAOP_GETSWCOUNT|M_JAMMAOP_CLEAR,&m,&swcount)>=0) + &&m) + { + m=0; + // m has bit set for every switch changed + for(jmr=inpJammaSwMap;jmr->jammamask;jmr++) + { + if(jmr->jammaswjammasw] + jammasw]) + { + j=inpG.jammaSwitchCount[jmr->jammasw]; + if(j&1) + InpLowEvent(1+jmr->inp,NUL); // up event + else + InpLowEvent(jmr->inp,NUL); // down event + j++; + inpG.jammaSwitchCount[jmr->jammasw]=j; + #if PRODUCTION + SysG.proflags|=M_SYSG_PROFLAGS_JAMMALIVES1; + #endif // PRODUCTION + } // while + } + } // for + } // counts & change + + // check dip switches + if(inpG.jammaDipTime=0) + { + if(i&M_JAMMADIP_VALID) + { + ir->flags|=M_INPREC_DIPSTATEVALID; + ir->dipState=i&M_JAMMADIP_DIP; + } + if(!inpG.jammaWatchdogCheck) + { + if(i&M_JAMMADIP_SPECIAL_VALID) + { + inpG.jammaWatchdogCheck=1; + if(i&M_JAMMADIP_SPECIAL_WATCHDOG) + AudWatchdog(); +// j=JAMMAWATCHDOG_CLICKS_PER_MINUTE; + j=JAMMAWATCHDOG_CLICKS_GAME_OPERATION; + if(j<=1) j=1; // reserve 0 + if(j>=254) j=254; // reserve 255 + JammaOp(JAMMAOP_WATCHDOGBONE_SETCLICKPERIOD,j); + } + else + { + // haven't gotten config yet -- request + JammaOp(JAMMAOP_REQUESTCONFIG); + } + } + } // get dip switches + } // dip check + + // call any switch functions + for(i=1;iswfuncs[i].func + && (ir->swfuncs[i].count!=ir->count[i])) + { + (*(ir->swfuncs[i].func))(i,ir); + ir->swfuncs[i].count=ir->count[i]; + } + } // for + + return 0; +} // InpLoop() + +// JFL 18 Oct 04 +int InpLoopEnd(void) +{ + // reset at the end of every loop + + InpRec *ir; + + if(!(ir=InpGet(0))) + return -1; + + ir->change=0; + + if(!(ir->flags&M_INPREC_DONTCLEARKEYS)) + InpOp(ir,M_INPOP_CLEARKEYS,NUL,0); + + if(ir->count[INPSW_ESC] && !SysG.quit) + { + SysG.quit=1; +#if SYS_BB +#if DEBUG + exit(0); +#endif //DEBUG +#endif //SYS_BB + } + + return 0; +} // InpLoopEnd() + +// +// InpForceDipswitchRead +// force a dipswitch read during the next input loop +// +// in: +// out: +// global: +// +// GNP 13 Jan 06 +// +void InpForceDipswitchRead(void) +{ + inpG.jammaDipTime=0; +//DONE("InpForceDipswitchRead") +} // InpForceDipswitchRead + +// JFL 16 Feb 05 +int InpOp(InpRec *ir,uns op,char *buf,int bufsize) +{ + int ec; + uns *swcount; + inpJammaMapRec *jmr; + int i; + uns j; + + if(!ir) + ir=InpGet(0); + if(!ir) + err(-1); + + switch(op&M_INPOP) + { + case INPOP_KEYBOARD_ON: + ir->flags|=M_INPREC_KEYBOARD; + break; + case INPOP_KEYBOARD_OFF: + ir->flags&=~M_INPREC_KEYBOARD; + break; + case INPOP_MOUSE_ON: + ir->flags|=M_INPREC_MOUSE; + break; + case INPOP_MOUSE_OFF: + ir->flags&=~M_INPREC_MOUSE; + break; + case INPOP_GETKEYS: + + if(buf) + { + bufsize--; // leave room for term + for(ec=0;(eckeyi) && (eckeys[ec]; + if(bufsize>=0) + buf[ec]=0; + } + else + ec=0; + + goto BAIL; + case INPOP_SETSWITCHFUNC: + ec=bufsize; + if((ec<=0)||(ec>=COUNT(ir->swfuncs))) + berr(-1); // must be INPSW_ + ir->swfuncs[ec].count=ir->count[ec]; + ir->swfuncs[ec].func=(void*)buf; + break; + case INPOP_FLUSH: + // flush most pending events + + WndInpLoop(); + + // jamma + ec=JammaOp(JAMMAOP_GETSWCOUNT|M_JAMMAOP_CLEAR,NUL,&swcount); + if((ec>=0) && inpG.jammaSwitchCountInit) + { + for(jmr=inpJammaSwMap;jmr->jammamask;jmr++) + { + i=jmr->jammasw; + if(!(inpSwFlag[i]&M_INPSWFLAG_FLUSH)) + continue; + + if(jmr->jammaswjammasw] + jammasw]) + { + j=inpG.jammaSwitchCount[jmr->jammasw]; + if(j&1) + InpLowEvent(1+jmr->inp,NUL); // up event + else + InpLowEvent(jmr->inp,NUL); // down event + j++; + inpG.jammaSwitchCount[jmr->jammasw]=j; + } // while + } + + inpG.jammaSwitchCount[jmr->jammasw]=swcount[jmr->jammasw]; + } // for + } // inpG.jammaSwitchCountInit + else if(ec>=0) + { + inpG.jammaSwitchCountInit=1; + for(jmr=inpJammaSwMap;jmr->jammamask;jmr++) + inpG.jammaSwitchCount[jmr->jammasw]=swcount[jmr->jammasw]; + } // inpG.jammaSwitchCountInit + + // switch functions + for(i=1;iswfuncs[i].count=ir->count[i]; + } // for + + break; + } // switch + + ec=0; +BAIL: + + if(ir && (op&M_INPOP_CLEARKEYS)) + ir->keyi=0; + + return ec; +} // InpOp() + +// JFL 18 Oct 04 +// JFL 12 Nov 04 +int InpLowEvent(uns event,void* info) +{ + // may be called from another thread (so protect critical sections) + + InpRec *ir; + char *p; + int i,j,m; + + if(!(ir=InpGet(0))) + return -1; + + // handle shifts -- these are cleared every loop + // and ORd in here if any event between the clearing passes them in + if(event&(M_INPLOWEVENT_SHF|M_INPLOWEVENT_ALT|M_INPLOWEVENT_CTL)) + { + // works with INPLOWEVENT_FLAGS (see code) + if(event&M_INPLOWEVENT_SHF) + ir->state|=M_INP_SHF; + if(event&M_INPLOWEVENT_ALT) + ir->state|=M_INP_ALT; + if(event&M_INPLOWEVENT_CTL) + ir->state|=M_INP_CTL; + } // shift + + switch(event&M_INPLOWEVENT) + { + case INPLOWEVENT_FLAGS: + // works with OR code above (see code) + // to turn off the flags not set + if(!(event&M_INPLOWEVENT_SHF)) + ir->state&=~M_INP_SHF; + if(!(event&M_INPLOWEVENT_ALT)) + ir->state&=~M_INP_ALT; + if(!(event&M_INPLOWEVENT_CTL)) + ir->state&=~M_INP_CTL; + break; + case INPLOWEVENT_NOP: + break; + case INPLOWEVENT_P0_TRIG0_DOWN: + m=0;//M_INP_P0_TRIG0; + i=INPSW_G0_TRIGGER0; + goto swdown; + case INPLOWEVENT_P0_TRIG0_UP: + m=0;//M_INP_P0_TRIG0; + i=INPSW_G0_TRIGGER0; + goto swup; + case INPLOWEVENT_P0_TRIG1_DOWN: + m=0;//M_INP_P0_TRIG1; + i=INPSW_G0_TRIGGER1; + goto swdown; + case INPLOWEVENT_P0_TRIG1_UP: + m=0;//M_INP_P0_TRIG1; + i=INPSW_G0_TRIGGER1; + goto swup; + case INPLOWEVENT_G0_RAW0_DOWN: + m=0; // no mask + i=INPSW_G0_RAW0; + goto swdown; + case INPLOWEVENT_G0_RAW0_UP: + m=0; // no mask + i=INPSW_G0_RAW0; + goto swup; + case INPLOWEVENT_G1_RAW0_DOWN: + m=0; // no mask + i=INPSW_G1_RAW0; + goto swdown; + case INPLOWEVENT_G1_RAW0_UP: + m=0; // no mask + i=INPSW_G1_RAW0; + goto swup; + case INPLOWEVENT_P1_TRIG0_DOWN: + m=0;//M_INP_P1_TRIG0; + i=INPSW_G1_TRIGGER0; + goto swdown; + case INPLOWEVENT_P1_TRIG0_UP: + m=0;//M_INP_P1_TRIG0; + i=INPSW_G1_TRIGGER0; + goto swup; + case INPLOWEVENT_P1_TRIG1_DOWN: + m=0;//M_INP_P1_TRIG1; + i=INPSW_G1_TRIGGER1; + goto swdown; + case INPLOWEVENT_P1_TRIG1_UP: + m=0;//M_INP_P1_TRIG1; + i=INPSW_G1_TRIGGER1; + goto swup; + case INPLOWEVENT_MOUSE_LB_DOWN: + m=M_INP_MOUSE_LB; + i=INPSW_MOUSE_LB; + goto swdown; + case INPLOWEVENT_MOUSE2_LB_DOWN: + i=INPSW_MOUSE2_LB; + m=0; + goto swdown; + case INPLOWEVENT_MOUSE2_RB_DOWN: + i=INPSW_MOUSE2_RB; + m=0; +swdown: + ir->change|=m; + ir->state|=m; + ir->count[i]+=1; + ir->count[i]|=1; + + // emulate gun + if(!(ir->flags&M_INPREC_MOUSE)) + { + switch(i) + { + case INPSW_MOUSE_LB: + j=INPGUNTRIG_POS(INP_GUN0,INP_GUNTRIG0); + i=INPSW_G0_TRIGGER0; + m=0; + goto sw2down; + case INPSW_MOUSE2_LB: + j=INPGUNTRIG_POS(INP_GUN1,INP_GUNTRIG0); + i=INPSW_G1_TRIGGER0; + m=0; +sw2down: + ir->change|=m; + ir->state|=m; + ir->count[i]+=1; + ir->count[i]|=1; + + // trigger 0 has two counters + if(i==INPSW_G0_TRIGGER0) + i=INPSW_G0_RAW0; + else if(i==INPSW_G1_TRIGGER0) + i=INPSW_G1_RAW0; + else + i=0; + if(i) + { + ir->count[i]+=1; + ir->count[i]|=1; + } + + ir->gunpos[j]=ir->mx; + ir->gunpos[j+1]=ir->my; + ir->gunpos[j+2]=ir->mz; + break; + case INPSW_MOUSE_RB: + j=INPGUNTRIG_POS(INP_GUN0,INP_GUNTRIG1); + i=INPSW_G0_TRIGGER1; + m=0; + goto sw2down; + case INPSW_MOUSE2_RB: + j=INPGUNTRIG_POS(INP_GUN1,INP_GUNTRIG1); + i=INPSW_G1_TRIGGER1; + m=0; + goto sw2down; + case INPSW_MOUSE_CB: + j=INPGUNTRIG_POS(INP_GUN0,INP_GUNTRIG2); + i=INPSW_G0_TRIGGER2; + m=0; + goto sw2down; + } // switch + } // !mouse + + break; + case INPLOWEVENT_MOUSE_LB_UP: + m=M_INP_MOUSE_LB; + i=INPSW_MOUSE_LB; + goto swup; + case INPLOWEVENT_MOUSE2_LB_UP: + i=INPSW_MOUSE2_LB; + m=0; + goto swup; + case INPLOWEVENT_MOUSE2_RB_UP: + i=INPSW_MOUSE2_RB; + m=0; +swup: + ir->change|=m; + ir->state&=~m; + ir->count[i]+=2; + ir->count[i]&=~1; + + // emulate gun (when the mouse is not a mouse, but a gun) + if(!(ir->flags&M_INPREC_MOUSE)) + { + switch(i) + { + case INPSW_MOUSE_LB: + j=INPGUNTRIG_POS(INP_GUN0,INP_GUNTRIG0); + i=INPSW_G0_TRIGGER0; + m=0; + goto sw2up; + case INPSW_MOUSE2_LB: + j=INPGUNTRIG_POS(INP_GUN1,INP_GUNTRIG0); + i=INPSW_G1_TRIGGER0; + m=0; + +sw2up: + ir->change|=m; + ir->state&=~m; + ir->count[i]+=2; + ir->count[i]&=~1; + + // trigger 0 has two counters + if(i==INPSW_G0_TRIGGER0) + i=INPSW_G0_RAW0; + else if(i==INPSW_G1_TRIGGER0) + i=INPSW_G1_RAW0; + else + i=0; + if(i) + { + ir->count[i]+=2; + ir->count[i]&=~1; + } + + ir->gunpos[j]=ir->mx; + ir->gunpos[j+1]=ir->my; + ir->gunpos[j+2]=ir->mz; + break; + case INPSW_MOUSE_RB: + j=INPGUNTRIG_POS(INP_GUN0,INP_GUNTRIG1); + i=INPSW_G0_TRIGGER1; + m=0; + goto sw2up; + case INPSW_MOUSE2_RB: + j=INPGUNTRIG_POS(INP_GUN1,INP_GUNTRIG1); + i=INPSW_G1_TRIGGER1; + m=0; + goto sw2up; + case INPSW_MOUSE_CB: + j=INPGUNTRIG_POS(INP_GUN0,INP_GUNTRIG2); + i=INPSW_G0_TRIGGER2; + m=0; + goto sw2up; + } // switch + } // !mouse + + break; + case INPLOWEVENT_MOUSE_CB_DOWN: + m=M_INP_MOUSE_CB; + i=INPSW_MOUSE_CB; + goto swdown; + case INPLOWEVENT_MOUSE_CB_UP: + m=M_INP_MOUSE_CB; + i=INPSW_MOUSE_CB; + goto swup; + case INPLOWEVENT_MOUSE_RB_DOWN: + m=M_INP_MOUSE_RB; + i=INPSW_MOUSE_RB; + goto swdown; + case INPLOWEVENT_MOUSE_RB_UP: + m=M_INP_MOUSE_RB; + i=INPSW_MOUSE_RB; + goto swup; + case INPLOWEVENT_P0_L_DOWN: + m=M_INP_P0_L; + i=INPSW_P0_L; + goto swdown; + case INPLOWEVENT_P0_L_UP: + m=M_INP_P0_L; + i=INPSW_P0_L; + goto swup; + case INPLOWEVENT_P0_R_DOWN: + m=M_INP_P0_R; + i=INPSW_P0_R; + goto swdown; + case INPLOWEVENT_P0_R_UP: + m=M_INP_P0_R; + i=INPSW_P0_R; + goto swup; + case INPLOWEVENT_P0_U_DOWN: + m=M_INP_P0_U; + i=INPSW_P0_U; + goto swdown; + case INPLOWEVENT_P0_U_UP: + m=M_INP_P0_U; + i=INPSW_P0_U; + goto swup; + case INPLOWEVENT_P0_D_DOWN: + m=M_INP_P0_D; + i=INPSW_P0_D; + goto swdown; + case INPLOWEVENT_P0_D_UP: + m=M_INP_P0_D; + i=INPSW_P0_D; + goto swup; + case INPLOWEVENT_P0_U2_DOWN: + m=M_INP_P0_U2; + i=INPSW_P0_U2; + goto swdown; + case INPLOWEVENT_P0_U2_UP: + m=M_INP_P0_U2; + i=INPSW_P0_U2; + goto swup; + case INPLOWEVENT_P0_D2_DOWN: + m=M_INP_P0_D2; + i=INPSW_P0_D2; + goto swdown; + case INPLOWEVENT_P0_D2_UP: + m=M_INP_P0_D2; + i=INPSW_P0_D2; + goto swup; + case INPLOWEVENT_P0_START_DOWN: + m=0;//M_INP_P0_START; + i=INPSW_P0_START; + goto swdown; + case INPLOWEVENT_P0_START_UP: + m=0;//M_INP_P0_START; + i=INPSW_P0_START; + goto swup; + case INPLOWEVENT_P1_START_DOWN: + m=0;//M_INP_P1_START; + i=INPSW_P1_START; + goto swdown; + case INPLOWEVENT_P1_START_UP: + m=0;//M_INP_P1_START; + i=INPSW_P1_START; + goto swup; + case INPLOWEVENT_COIN1_DOWN: + m=0;//M_INP_COIN1; + i=INPSW_COIN1; + goto swdown; + case INPLOWEVENT_COIN1_UP: + m=0;//M_INP_COIN1; + i=INPSW_COIN1; + goto swup; + case INPLOWEVENT_COIN2_DOWN: + m=0;//M_INP_COIN2; + i=INPSW_COIN2; + goto swdown; + case INPLOWEVENT_COIN2_UP: + m=0;//M_INP_COIN2; + i=INPSW_COIN2; + goto swup; + case INPLOWEVENT_DIAG_DOWN: + m=0;//M_INP_DIAG; + i=INPSW_DIAG; + goto swdown; + case INPLOWEVENT_DIAG_UP: + m=0;//M_INP_DIAG; + i=INPSW_DIAG; + goto swup; + case INPLOWEVENT_VOLUP_DOWN: + m=0; + i=INPSW_VOLUP; + goto swdown; + case INPLOWEVENT_VOLUP_UP: + m=0; + i=INPSW_VOLUP; + goto swup; + case INPLOWEVENT_VOLDOWN_DOWN: + m=0; + i=INPSW_VOLDOWN; + goto swdown; + case INPLOWEVENT_VOLDOWN_UP: + m=0; + i=INPSW_VOLDOWN; + goto swup; + case INPLOWEVENT_BILL_DOWN: + m=0; + i=INPSW_BILL; + goto swdown; + case INPLOWEVENT_BILL_UP: + m=0; + i=INPSW_BILL; + goto swup; + case INPLOWEVENT_SERVICE_DOWN: + m=0; + i=INPSW_SERVICE; + goto swdown; + case INPLOWEVENT_SERVICE_UP: + m=0; + i=INPSW_SERVICE; + goto swup; + case INPLOWEVENT_SYS_ESC_DOWN: + m=M_INP_ESC; + i=INPSW_ESC; + goto swdown; + case INPLOWEVENT_SYS_ESC_UP: + m=M_INP_ESC; + i=INPSW_ESC; + goto swup; + case INPLOWEVENT_SYS_MODE_DOWN: // the alt key + m=M_INP_MODE; + i=INPSW_MODE; + goto swdown; + case INPLOWEVENT_SYS_MODE_UP: + m=M_INP_MODE; + i=INPSW_MODE; + goto swup; + case INPLOWEVENT_MOUSE_MOVE_XY: + ir->mx=((crd*)info)[0]; + ir->my=((crd*)info)[1]; + ir->change|=M_INP_MOUSE_MOVE_XY; + break; + case INPLOWEVENT_MOUSE_DELTA_Z: + ir->mz+=((crd*)info)[0]; + ir->change|=M_INP_MOUSE_MOVE_Z; + break; + case INPLOWEVENT_SYS_KEYS_DOWN: + ir->change|=M_INP_KEYS; + ir->state|=M_INP_KEYS; + szncpy(ir->keys,info,sizeof(ir->keys)); + if(!(p=info)) + break; + for(;*p;p++) + { + // if not in cmode, the keyboard acts as buttons + // match w/key up + if(!(ir->flags&M_INPREC_KEYBOARD)) + { + if((*p=='s')||(*p=='S')) + InpLowEvent(INPLOWEVENT_P0_START_DOWN,NUL); + if((*p==';')||(*p==':')) + InpLowEvent(INPLOWEVENT_P1_START_DOWN,NUL); + else if(*p=='1') + InpLowEvent(INPLOWEVENT_COIN1_DOWN,NUL); + else if(*p=='2') + InpLowEvent(INPLOWEVENT_COIN2_DOWN,NUL); + else if(*p=='3') + InpLowEvent(INPLOWEVENT_BILL_DOWN,NUL); + else if(*p=='6') + InpLowEvent(INPLOWEVENT_SERVICE_DOWN,NUL); + else if(*p=='D') + InpLowEvent(INPLOWEVENT_DIAG_DOWN,NUL); + else if(*p=='v') + InpLowEvent(INPLOWEVENT_VOLDOWN_DOWN,NUL); + else if(*p=='V') + InpLowEvent(INPLOWEVENT_VOLUP_DOWN,NUL); + else if((*p=='q')||(*p=='Q')) + InpLowEvent(INPLOWEVENT_MOUSE2_LB_DOWN,NUL); + else if((*p=='w')||(*p=='W')) + InpLowEvent(INPLOWEVENT_MOUSE2_RB_DOWN,NUL); + } // keyboard acts as buttons + + // add char to cbuf + if(ir->keyikeys)) + ir->keys[ir->keyi++]=*p; + + } // for + break; + case INPLOWEVENT_SYS_KEYS_UP: + ir->change|=M_INP_KEYS; + ir->state&=~M_INP_KEYS; + szncpy(ir->keys,info,sizeof(ir->keys)); + if(!(p=info)) + break; + for(;*p;p++) + { + // if not in cmode, the keyboard acts as buttons + // match w/key down + if(!(ir->flags&M_INPREC_KEYBOARD)) + { + if((*p=='s')||(*p=='S')) + InpLowEvent(INPLOWEVENT_P0_START_UP,NUL); + if((*p==';')||(*p==':')) + InpLowEvent(INPLOWEVENT_P1_START_UP,NUL); + else if(*p=='1') + InpLowEvent(INPLOWEVENT_COIN1_UP,NUL); + else if(*p=='2') + InpLowEvent(INPLOWEVENT_COIN2_UP,NUL); + else if(*p=='3') + InpLowEvent(INPLOWEVENT_BILL_UP,NUL); + else if(*p=='6') + InpLowEvent(INPLOWEVENT_SERVICE_UP,NUL); + else if(*p=='D') + InpLowEvent(INPLOWEVENT_DIAG_UP,NUL); + else if(*p=='v') + InpLowEvent(INPLOWEVENT_VOLDOWN_UP,NUL); + else if(*p=='V') + InpLowEvent(INPLOWEVENT_VOLUP_UP,NUL); + else if((*p=='q')||(*p=='Q')) + InpLowEvent(INPLOWEVENT_MOUSE2_LB_UP,NUL); + else if((*p=='w')||(*p=='W')) + InpLowEvent(INPLOWEVENT_MOUSE2_RB_UP,NUL); + } // keyboard acts as buttons + + } // for + + break; + case INPLOWEVENT_GUNPOS: + i=((int*)info)[0]; // trig.4:gun.4 + m=(i>>4)&0xf; // trig + i&=0xf; + if((i>=INP_GUNS)||(m>=INP_GUNTRIGS)) + break; + j=INPGUNTRIG_POS(i,m); // gun,trig + + ir->gunpos[j]=((int*)info)[1]; + ir->gunpos[j+1]=((int*)info)[2]; + ir->gunpos[j+2]=0; + + break; + } // switch() + return 0; +} // InpLowEvent() + +static int inpPlTrigTable[] = +{ + INPLOWEVENT_P0_TRIG0_DOWN, + INPLOWEVENT_P0_TRIG1_DOWN, + INPLOWEVENT_P1_TRIG0_DOWN, + INPLOWEVENT_P1_TRIG1_DOWN +}; // inpPlTrigTable[] + +// JFL 10 May 05 +// JFL 18 Jun 05 +int inpJammaCallback(int op,...) +{ + va_list args; + int pl,tr,x,y; + int info[8]; + + va_start(args,op); + + // may be called from another thread (so protect critical sections) + switch(op&M_JAMMACALLBACK) + { + case JAMMACALLBACK_WATCHDOGCOMING: + //SysLog("Watchdog warning received...\n"); + BankerOfferDeinitialize(); + break; + case JAMMACALLBACK_GUNXY: + x=va_arg(args,int); + y=va_arg(args,int); + pl=(op>>S_JAMMACALLBACK_PL)&M_JAMMACALLBACK_PL; + tr=(op>>S_JAMMACALLBACK_TR)&M_JAMMACALLBACK_TR; + + // gun pos + info[0]=pl; // // trig.4:gun.4 + info[1]=x; + info[2]=y; + InpLowEvent(INPLOWEVENT_GUNPOS,info); + + // gun trigger + // note, need only down, don't need to send up event + #if SAFE + if(pl>1 || tr>1) BP(BP_INPJAMMACALLBACK); + #endif // SAFE + pl&=1; // 0 or 1 in table + tr&=1; // 0 or 1 in table + pl<<=1; + pl+=tr; + pl=inpPlTrigTable[pl]; + InpLowEvent(pl,NUL); + + break; + + case JAMMACALLBACK_TICKET: + + x = va_arg(args, int); + y = va_arg(args, int); + + if (y) + { + // - decrease tickets owed + + AudIncTicketsOwed(y * -1); + AudIncrementTixCounter(1); + } + + if (x == JAMMATICKET_ERROR) + { + // - flag ticket error + + AudTixError(1); + } + else + { + // - clear ticket error + + AudTixError(0); + } + + break; + + } // switch + + va_end(args); + return 0; +} // inpJammaCallback() + +// EOF diff --git a/dond/core/inp.h b/dond/core/inp.h new file mode 100755 index 0000000..efb8e44 --- /dev/null +++ b/dond/core/inp.h @@ -0,0 +1,233 @@ +#ifndef INP_H +#define INP_H +// inp.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 18 Oct 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +enum { + INP_GUN0, + INP_GUN1, + INP_GUNS, +}; + +enum { + INP_GUNTRIG0, + INP_GUNTRIG1, + INP_GUNTRIG2, + INP_GUNTRIGS, +}; + +enum { + INPLOWEVENT_NONE, + INPLOWEVENT_NOP, + INPLOWEVENT_MOUSE_LB_DOWN, + INPLOWEVENT_MOUSE_LB_UP, + INPLOWEVENT_MOUSE_CB_DOWN, + INPLOWEVENT_MOUSE_CB_UP, + INPLOWEVENT_MOUSE_RB_DOWN, + INPLOWEVENT_MOUSE_RB_UP, + INPLOWEVENT_MOUSE2_LB_DOWN, + INPLOWEVENT_MOUSE2_LB_UP, + INPLOWEVENT_MOUSE2_RB_DOWN, + INPLOWEVENT_MOUSE2_RB_UP, + INPLOWEVENT_MOUSE_MOVE_XY, + INPLOWEVENT_MOUSE_DELTA_Z, + INPLOWEVENT_P0_TRIG0_DOWN, // down + INPLOWEVENT_P0_TRIG0_UP, // before up assumed.. + INPLOWEVENT_P0_TRIG1_DOWN, + INPLOWEVENT_P0_TRIG1_UP, + INPLOWEVENT_G0_RAW0_DOWN, + INPLOWEVENT_G0_RAW0_UP, + INPLOWEVENT_G1_RAW0_DOWN, + INPLOWEVENT_G1_RAW0_UP, + INPLOWEVENT_P0_L_DOWN, + INPLOWEVENT_P0_L_UP, + INPLOWEVENT_P0_R_DOWN, + INPLOWEVENT_P0_R_UP, + INPLOWEVENT_P0_U_DOWN, + INPLOWEVENT_P0_U_UP, + INPLOWEVENT_P0_D_DOWN, + INPLOWEVENT_P0_D_UP, + INPLOWEVENT_P0_U2_DOWN, + INPLOWEVENT_P0_U2_UP, + INPLOWEVENT_P0_D2_DOWN, + INPLOWEVENT_P0_D2_UP, + INPLOWEVENT_P0_START_DOWN, + INPLOWEVENT_P0_START_UP, + INPLOWEVENT_P1_TRIG0_DOWN, + INPLOWEVENT_P1_TRIG0_UP, + INPLOWEVENT_P1_TRIG1_DOWN, + INPLOWEVENT_P1_TRIG1_UP, + INPLOWEVENT_P1_START_DOWN, + INPLOWEVENT_P1_START_UP, + INPLOWEVENT_COIN1_DOWN, + INPLOWEVENT_COIN1_UP, + INPLOWEVENT_COIN2_DOWN, + INPLOWEVENT_COIN2_UP, + INPLOWEVENT_DIAG_DOWN, + INPLOWEVENT_DIAG_UP, + INPLOWEVENT_VOLUP_DOWN, + INPLOWEVENT_VOLUP_UP, + INPLOWEVENT_VOLDOWN_DOWN, + INPLOWEVENT_VOLDOWN_UP, + INPLOWEVENT_BILL_DOWN, + INPLOWEVENT_BILL_UP, + INPLOWEVENT_SERVICE_DOWN, + INPLOWEVENT_SERVICE_UP, + INPLOWEVENT_SYS_ESC_DOWN, + INPLOWEVENT_SYS_ESC_UP, + INPLOWEVENT_SYS_MODE_DOWN, + INPLOWEVENT_SYS_MODE_UP, + INPLOWEVENT_SYS_KEYS_DOWN, + INPLOWEVENT_SYS_KEYS_UP, + INPLOWEVENT_FLAGS, + INPLOWEVENT_GUNPOS, +}; + +#define M_INPLOWEVENT 0x00ff +#define M_INPLOWEVENT_SHF 0x0100 +#define M_INPLOWEVENT_CTL 0x0200 +#define M_INPLOWEVENT_ALT 0x0400 + +#define M_INP_MOUSE_LB 0x00000001 +#define M_INP_MOUSE_CB 0x00000002 +#define M_INP_MOUSE_RB 0x00000004 +#define M_INP_MOUSE_MOVE_XY 0x00000008 +#define M_INP_MOUSE_MOVE_Z 0x00000010 +#define M_INP_P0_L 0x00000020 +#define M_INP_P0_R 0x00000040 +#define M_INP_P0_U 0x00000080 +#define M_INP_P0_D 0x00000100 +#define M_INP_P0_U2 0x00000200 +#define M_INP_P0_D2 0x00000400 +#define M_INP_ESC 0x00000800 +#define M_INP_MODE 0x00001000 +#define M_INP_KEYS 0x00002000 +#define M_INP_SHF 0x00004000 +#define M_INP_ALT 0x00008000 +#define M_INP_CTL 0x00010000 + +#define M_INPREC_MOUSE 0x0001 +#define M_INPREC_KEYBOARD 0x0002 +#define M_INPREC_DONTCLEARKEYS 0x0004 +#define M_INPREC_DIPSTATEVALID 0x0008 + +enum { + INPSW_NONE, + INPSW_P0_L, + INPSW_P0_R, + INPSW_P0_U, + INPSW_P0_D, + INPSW_P0_U2, + INPSW_P0_D2, + INPSW_P0_START, + INPSW_P1_START, + INPSW_MOUSE_LB, + INPSW_MOUSE_CB, + INPSW_MOUSE_RB, + INPSW_MOUSE2_LB, + INPSW_MOUSE2_RB, + INPSW_MODE, + INPSW_ESC, + INPSW_G0_TRIGGER0, // CabLoop() -- assumes order -- primary trigger + INPSW_G0_TRIGGER1, // CabLoop() -- reload + INPSW_G0_TRIGGER2, // CabLoop() -- rocket launcher (if ever) + INPSW_G1_TRIGGER0, // CabLoop() -- + INPSW_G1_TRIGGER1, // CabLoop() -- + INPSW_G1_TRIGGER2, // CabLoop() -- + INPSW_G0_RAW0, + INPSW_G1_RAW0, + INPSW_COIN1, + INPSW_COIN2, + INPSW_DIAG, // aka 'test' + INPSW_VOLUP, + INPSW_VOLDOWN, + INPSW_BILL, + INPSW_SERVICE, + INPSW_NUM, +}; + +typedef struct { + uns count; + ftype6 *func; // int (ftype6)(int,void*); +} inpswFunc; + +typedef struct { + N2 lnk; + uns16 flags; + uns8 keyi; + uns8 xx1; + crd mx; + crd my; + crd mz; + uns32 state; + uns32 change; + uns8 keys[32]; + uns count[INPSW_NUM]; + inpswFunc swfuncs[INPSW_NUM]; + crd gunpos[3*INP_GUNTRIGS*INP_GUNS]; // xyz for each gun trigger + uns16 dipState; // only if M_INPREC_DIPSTATEVALID +} InpRec; + +enum { + INPREC_NONE, + INPREC_GAME, + INPREC_DEBUG, +}; + +enum { + INPKEY_F1=0xf0, + INPKEY_F2, + INPKEY_F3, + INPKEY_F4, + INPKEY_F5, + INPKEY_F6, + INPKEY_F7, + INPKEY_F8, + INPKEY_F9, + INPKEY_F10, + INPKEY_F11, + INPKEY_F12, + INPKEY_FMAX, +}; + +#define INPKEY_IS_FKEY(c) (((uns8)(c))>=INPKEY_F1 && ((uns8)(c))>= S_DIPS1_RESOLUTION; + u++; + if(u>=FB_NUM_RESOLUTION) + { + LOCKUP(); + u=FB_RESOLUTION_320x240; + } + if((ec=FbSetMode(u,i))<0) + goto BAIL; + if((ec=VidStart())<0) + goto BAIL; + + // + // ENABLE INTERRUPTS + // + + IntEnable(M_INT_SERIAL0|M_INT_VBLANK|M_INT_IDE|M_INT_RENDER|M_INT_ETHERNET,1); + xSysIntEnable(); + + // + // + // + + GameLoop(); + + // + // + // + +BAIL: + IntEnable(~0,0); + GameFinal(); + FTPFinal(); + NetFinal(); + VidMovieFinal(); + VidFinal(); + FbFinal(); + FsFinal(); + MemFinal(); + IntFinal(); + SysFinal(); + return ec; +} // main() + +// EOF diff --git a/dond/core/mem.c b/dond/core/mem.c new file mode 100755 index 0000000..c69e065 --- /dev/null +++ b/dond/core/mem.c @@ -0,0 +1,956 @@ +// mem.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 26 Aug 04 + +#include "pm.h" +#include "str.h" +#include "mem.h" + +MemSysInfoRec MemSysInfo; +extern unsigned char *MemHeap; + +#define ALIGN_MEM_4BYTE (3) //make sure memory is aligned on M_ALIGN_MEM+1 byte boundry + +#define ALIGN4BYTE(ADR) ((((long) ADR) + ALIGN_MEM_4BYTE) & ~ALIGN_MEM_4BYTE) + +///// DOC BLOCK /////////////////////////////////////////////////////////////// +// +// all sizes are in bytes +// allocations must align & pad memory their own memory +// +// this system handles all types of memory +// and presents a common interface to the game +// +// there are different conceptual types of memory +// the type of memory may be physically different or may just be a concept +// in any case, the memory type is the functional descriptor used +// heap memory +// this is a block of CPU memory for general use +// this is always present +// video image memory +// video palette memory +// sound buffer memory +// +// a memory pool is a block of continuous memory +// pools are defined depending on the target system and game requirements +// this system supports management of any number of pools +// +// ability of each pool to reset its memory +// +// MemTotal[] is an aligned array of bytes +// +/////////////////////////////////////////////////////////////////////////////// + +struct { + uns reset; + uns map; +} memG; + +// +// STACK +// + +// +// memS +// stack memory +// +// GNP 25 May 00 +// JFL 22 Sep 04 +typedef struct +{ + memu low; + memu high; + memu levelBot[MEM_SAVEPOINTS]; + memu levelTop[MEM_SAVEPOINTS]; +} memS; + +// +// FIFO +// + +// MemF +// +// JFL 22 Sep 04 +typedef struct { + memu low; + memu high; + memu oldest; + memu next; +} memF; + +// +// DYNAMIC +// + +// +// MN_ +// dynamic memory node +// +// GNP 01 Jun 00 +// +typedef struct +{ + uns32 link; // link is very specialized +} MN; + +typedef uns32 MN_WORD; + +#define S_MNLINK_NEG 16 +#define M_MNLINK_POS 0x7fff +#define M_MNLINK_USED 0x8000 +#define M_MNLINK_UPOS 0xffff + +#define MN_SIZE sizeof(MN)/sizeof(MN_WORD) +#define MN_MINSIZE MN_SIZE*2 +#define MN_MINSPLIT 3+MN_SIZE*2 + +// +// MemD +// dynamic memory pool structure +// +// GNP 25 May 00 +// JFL 26 Aug 04 +typedef struct +{ + memu low; + memu high; + memu startp; + memu startn; +} memD; + +/////////////////////////////////////////////////////////////////////////////// +// MEM MAPS + +enum { + MEMKIND_STACK, + MEMKIND_FIFO, + MEMKIND_DYN, + MEMKIND_MAX +}; + +typedef struct { + struct { + memu mem; + uns size; + } pool[MEMPOOL_MAX]; +} memMap; + +/////////////////////////////////////////////////////////////////////////////// +// MEMMAP_STARTUP + +// the idea behind this memory map +// MEMPOOL_HEAP +// MEMPOOL_VID +// MEMPOOL_NET +// MEMPOOL_PERM +// MEMPOOL_WAVE +// MEMPOOL_SUBW + +// memMap[] defines the memory pool structure +// the following defines define how much each pool gets +// MEMHEAP_SIZE is in mem.h & defines total memory grabbed by system +// N1_HEAP gets everything left over +#define N1_TOT MEMHEAP_SIZE // in mem.h +#define N1_HEAP (N1_TOT-N1_VID-N1_NET-N1_PERM-N1_WAVE-N1_SUBW) +#define N1_VID (1024+256)*KBYTES +#define N1_NET 1*KBYTES +#define N1_PERM 4*MBYTES +#define N1_WAVE 12*MBYTES +#define N1_SUBW 1*MBYTES + +memMap memMaps[MEMMAP_MAX]; + +// - memMapsDim contains the offset and size of each memory pool + +int memMapsDim[MEMPOOL_MAX * 2] = { + 0x000000, N1_HEAP, + N1_HEAP, N1_VID, + N1_HEAP+N1_VID, N1_NET, + N1_HEAP+N1_VID+N1_NET, N1_PERM, + N1_HEAP+N1_VID+N1_NET+N1_PERM, N1_WAVE, + N1_HEAP+N1_VID+N1_NET+N1_PERM+N1_WAVE, N1_SUBW +}; + +// +// memory pool names as character strings for info +// +char memPoolNames[MEMPOOL_MAX][4] = +{ + "HP ", + "VID", + "NET", + "PRM", + "WAV", + "SWV", +}; + +/////////////////////////////////////////////////////////////////////////////// +// + +uns8 memPoolMap[MEMPOOL_MAXMAP-MEMPOOL_MAP]; + +/////////////////////////////////////////////////////////////////////////////// + +// forwards +int memDPoolFirstNode(memD* mempoolp,memu low,memu high); +int memDynPAlloc(memD* mempoolp,uns32 size, void **memp); +int memDynFree(memD* mempoolp,MN_WORD *mem); +int memDynCheck(memD* mempoolp,uns32 *availp,uns32 *usedp,uns32 *countp); + +static memS memSPool[MEMPOOL_MAX]; +static memF memFPool[MEMPOOL_MAX]; +static memD memDPool[MEMPOOL_MAX]; + +// JFL 26 Aug 04 +int MemInit(void) +{ + int i; + + MemHeap = malloc(sizeof(unsigned char) * MEMHEAP_SIZE); + + // - read the offset and size data for each memory pool + + for (i = 0; i < MEMPOOL_MAX; i++) + { + memMaps[MEMMAP_STARTUP].pool[i].mem = (memu)(MemHeap + memMapsDim[(i * 2) + 0]); + memMaps[MEMMAP_STARTUP].pool[i].size = memMapsDim[(i * 2) + 1]; + } + + MEMZ(memG); + MEMZ(memSPool); + MEMZ(memFPool); + MEMZ(memDPool); + MEMZ(memPoolMap); + MEMZ(MemSysInfo); + return 0; +} // MemInit() + +// JFL 26 Aug 04 +void MemFinal(void) +{ + free(MemHeap); +} // MemFinal() + +// JFL 22 Sep 04 +// JFL 30 Dec 04; level +int MemPoolReset(uns pool,uns reset) +{ + uns stack; + memu memu; + memMap *mm; + int k; + + mm=&memMaps[0]; + + // free/reset all memory + + // find start & end of pool + memu = mm->pool[pool].mem; + stack = mm->pool[pool].size; + + // setup for stack + memSPool[pool].low=memu; + memu+=stack; + memSPool[pool].high=memu; + for(k=0;k=MEM_SAVEPOINTS)) + {BP(BP_MEMSTACKRESTORE);return -1;} + + // the idea is to reset the stack memory for this pool + // to the top of the lower level (i.e. reset at this level) + for(pool=0;pool=MEM_SAVEPOINTS)) + {BP(BP_MEMSTACKSAVE);return -1;} + + // save at this level + for(pool=0;pool=MEMPOOL_MAXMAP) + return -1; + if(mapto>=MEMPOOL_MAX) + return -2; + memPoolMap[pool-MEMPOOL_MAP]=mapto; + return 0; +} // MemPoolMap() + +// JFL 02 Feb 05 +int MemInfo(char *buf,int bufSize) +{ + int ec,pool; + uns32 s,avail,count,used,total; + + if(!buf || !bufSize) + return 1; + buf[0]=0; + + total=0; + for(pool=0;pool%s %x %x\n",memPoolNames[pool], + memSPool[pool].low,memSPool[pool].high); + } + else + { + szbuild(buf,bufSize,"<-cat>%s (empty) %x\n",memPoolNames[pool], + memSPool[pool].low); + } + + } // for + szbuild(buf,bufSize,"<-cat>stack: avail=%x\n",total); + + total=0; + for(pool=0;pool%s (empty) %x\n",memPoolNames[pool], + memDPool[pool].low); + } + else + { + szbuild(buf,bufSize,"<-cat>%s %x %x %x\n",memPoolNames[pool], + avail,used,count); + total+=avail; + } + } // for + szbuild(buf,bufSize,"<-cat>dynamic: avail=%x\n",total); + szbuild(buf,bufSize,"<-cat>jps: o=%x c=%d l=%x\n", + MemSysInfo.jpsOutstanding,MemSysInfo.jpsCount,MemSysInfo.jpsLargest); + + return 0; +} // MemInfo() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 26 Aug 04 +void MemZero(void *mem,uns size) +{ + while(size--) + ((char*)mem)[size]=0; +} // MemZero() + +// JFL 28 Oct 04 +void MemCopy(void *dst,void *src,uns size) +{ + while(size--) + ((uns8*)dst)[size]=((uns8*)src)[size]; +} // MemCopy() + +/////////////////////////////////////////////////////////////////////////////// +// STACK ALLOCATOR + +// +// MemSLow +// allocate static memory from the bottom of the stack +// +// in: +// pool = memory pool from which to allocate +// size = size of allocation in bytes +// *memp = ptr for return +// out: +// global: +// +// JFL 26 Aug 04 +// GNP 30 Nov 05; always align size to 4 bytes +// +int MemSLow(uns pool,uns size,void *memp) +{ + memu mem; + // stack based alloc from low end + + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + size = ALIGN4BYTE(size); + mem=memSPool[pool].low; + if(mem+size>memSPool[pool].high) + return ERR_MEM_ALLOC; + memSPool[pool].low+=size; + *((void**)memp)=(void*)mem; + return 0; +//DONE("MemSLow") +} // MemSLow + +// +// MemSHigh +// allocate static memory from the top of the stack +// +// in: +// pool = memory pool from which to allocate +// size = size of allocation in bytes +// *memp = ptr for return +// out: +// global: +// +// JFL 26 Aug 04 +// GNP 30 Nov 05; always align size to 4 bytes +// +int MemSHigh(uns pool,uns size,void *memp) +{ + memu mem; + // stack based alloc from high end + + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + size = ALIGN4BYTE(size); + + mem=memSPool[pool].high-size; + if(memMEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + // get stack low pointer + + return (void*)memSPool[pool].low; +} // MemSLowGet() + +// JFL 26 Aug 04 +void MemSLowSet(uns pool,void *mem) +{ + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + // set stack low pointer + + memSPool[pool].low = (memu)mem; +} // MemSLowSet() + +// JFL 26 Aug 04 +void* MemSHighGet(uns pool) +{ + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + // get stack high pointer + + return (void*)memSPool[pool].high; +} // MemSHighGet() + +// JFL 26 Aug 04 +void MemSHighSet(uns pool,void *mem) +{ + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + // set stack high pointer + + memSPool[pool].high = (memu)mem; +} // MemSHighSet() + +// JFL 22 Sep 04 +uns MemSAvail(uns pool) +{ + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + + return memSPool[pool].high-memSPool[pool].low; +} // MemSAvail() + +/////////////////////////////////////////////////////////////////////////////// +// DYNAMIC ALLOCATOR + +// JFL 22 Sep 04 +int MemDSetup(uns pool,void *mem,uns size) +{ + if(pool>MEMPOOL_MAP) + { + LOCKUP(BP_MEMDSETUP); // don't use mapped pools here.. + pool=memPoolMap[pool-MEMPOOL_MAP]; + } + + return memDPoolFirstNode(&memDPool[pool],(memu)mem,(memu)&((uns8*)mem)[size]); +} // MemDSetup() + +// JFL 22 Sep 04 +int MemDAlloc(uns pool,uns size,void *memp) +{ + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + return memDynPAlloc(&memDPool[pool],size,memp); +} // MemDAlloc() + +// JFL 22 Sep 04 +int MemDAlloz(uns pool,uns size,void *memp) +{ + int ec; + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + if((ec=memDynPAlloc(&memDPool[pool],size,memp))>=0) + { + MemZero(*((void**)memp),size); + } + return ec; +} // MemDAlloz() + +// JFL 22 Sep 04 +int MemDFree(uns pool,void *mem) +{ + if(pool>MEMPOOL_MAP) + pool=memPoolMap[pool-MEMPOOL_MAP]; + return memDynFree(&memDPool[pool],mem); +} // MemDFree() + +// +// memDPoolFirstNode +// all necessary setup for the dynamic system for the given pool +// does not link the node into the list of 'user' pools +// +// in: +// low = low address of pool +// high = high address of pool +// mempoolp = ptr to dynamic memory pool +// out: +// <0 error +// ~ +// +// GNP 01 Jun 00 +// JFL 22 Sep 04 +int memDPoolFirstNode(memD* mempoolp,memu low,memu high) +{ + int16 ec; + MN* mnp; + uns32 size; + uns32 len; + uns32 prev; + MN_WORD* memt; + + // initialize boundries + + // force alignment + low+=3; + low&=~3; + high&=~3; + + mempoolp->low = low; + mempoolp->startp = low; + mempoolp->high = high; + mnp = (MN*)mempoolp->high; + mnp--; + mempoolp->startn = (memu)mnp; + + // setup 1st node + size = mempoolp->high - mempoolp->low; + size >>= 2; // size in MN_WORDSIZE words + if (size < MN_MINSIZE) + { + LOCKUP(BP_MEMDPOOLFIRSTNODE); + err(ERR_MEM_POOL_EMPTY); + } + + size -= MN_SIZE; // room for first node + memt = (void*)mempoolp->low; + prev = 0; + + for (;size>0;size -= len) + { + size -= MN_SIZE; // room for next node + len=size; + if (len > M_MNLINK_POS) + len = M_MNLINK_POS; + + mnp = (MN*)memt; + mnp->link = len|prev; // (neg:pos) + memt += (len + MN_SIZE); + prev = len<link = prev; // (neg:0) + + ec=0; +BAIL: + return ec; +} // memDPoolFirstNode() + +// +// memDynPAlloc +// system call, use memd_alloc +// allocate a block of memory of given size +// +// in: +// size = bytes (must be MN_WORDSIZE aligned) +// memp = handle to memory ptr +// mempoolp = ptr to dynamic memory pool +// out: +// <0 = fail +// global: +// +// GNP 04 Jun 00 +// JFL 22 Sep 04 +int memDynPAlloc(memD* mempoolp,uns32 size,void **memp) +{ + int16 ec; + uns32 mnlink; + uns32 mnlinkc; + MN_WORD* memt; + + if (!mempoolp->startp) + err(ERR_MEM_POOL_NOT_INITIALIZED); + + size+=3;size>>=2; // size into MN_WORDSIZE + + if (size > M_MNLINK_POS) + err(ERR_MEM_ALLOC); // bigger than max size of block + + memt = (void*) mempoolp->startp; + + for (mnlink=((MN*)memt)->link;; + memt += (mnlink + MN_SIZE),mnlink=((MN*)memt)->link) + { + mnlinkc = mnlink; + mnlink &= M_MNLINK_POS; // size of block + if (!mnlink) + break; // end of list + if (mnlinkc & M_MNLINK_USED) + continue; // block currently in use + if (mnlink > size) + goto MDPA_PROCESS_NODE_LEFT; // block large enough + } // for + + // end of list in positive direction reached + // no node found, try other direction from where we started + + memt = (void*)mempoolp->startp; + + for (mnlinkc=((MN*)memt)->link;mnlinkc;) + { + mnlinkc >>= S_MNLINK_NEG; + if (!mnlinkc) + break; // end of list + memt -= (mnlinkc + MN_SIZE); // back-up to previous node + mnlink = mnlinkc = ((MN*)memt)->link; + if (mnlink & M_MNLINK_USED) + continue; // block currently in use + mnlink &= M_MNLINK_POS; + if (mnlink > size) + goto MDPA_PROCESS_NODE_RIGHT; // block big enough + } // for + + // error, no node found + + *memp = NUL; + err(ERR_MEM_ALLOC); // no memory of requested size found + + // we have node, determine what to do + // mnlink = size of found node +MDPA_PROCESS_NODE_RIGHT: + + mnlink -= (size+MN_SIZE); // size of remaining space + if (mnlink < MN_MINSPLIT) + goto MDPA_SUCCESS_RIGHT; // too small to split, possible little hole here + + // left node is unused part + mnlinkc = ((MN*)memt)->link; + mnlinkc &= ~M_MNLINK_UPOS; + ((MN*)memt)->link = mnlinkc | mnlink; + + // middle node, returned + memt += mnlink+MN_SIZE; + mnlinkc = (mnlink<link = mnlinkc; + + *memp = memt + MN_SIZE; // return memory ptr + + // next starting is middle + mempoolp->startn = (memu)memt; // next start + + // right node + memt += size+MN_SIZE; + mnlinkc = size<link & M_MNLINK_UPOS); + ((MN*)memt)->link = mnlinkc; + goto MDPA_SUCCESS; + +MDPA_SUCCESS_RIGHT: + *memp = memt + MN_SIZE; // return memory ptr + ((MN*)memt)->link |= M_MNLINK_USED; // set block in-use + goto MDPA_SUCCESS; + + // node found while travelling in a positive direction + // return pointer to memory. split block by adding + // and MNLINK after size of memory requested. update + // n field of MNLINK for block after. + // if block is too small to split (i.e. there is no + // room for adding an MNLINK, then do not split. + // + // mnlink = size of found node + // memt = ptr to block +MDPA_PROCESS_NODE_LEFT: + *memp = memt + MN_SIZE; // return memory ptr + ((MN*)memt)->link |= M_MNLINK_USED; // set block in-use + + mnlink -= (size+MN_SIZE); // remaining size of block + if (mnlink < MN_MINSPLIT) + goto MDPA_SUCCESS; // too small to split, possible little hole here + + // left node + mnlinkc = ((MN*)memt)->link; // current n:p + mnlinkc &= ~M_MNLINK_POS; // n:0 + mnlinkc |= (size|M_MNLINK_USED); // n:p and in-use + ((MN*)memt)->link = mnlinkc; + + // find address of new node + memt += (size + MN_SIZE); + + // next starting is middle + mempoolp->startp = (memu)memt; // next start + + // middle node, currently free + mnlinkc = size << S_MNLINK_NEG; // n:0 + mnlinkc |= mnlink; // n:p + ((MN*)memt)->link = mnlinkc; + + // right node + memt += mnlink+MN_SIZE; // next node + mnlink <<= S_MNLINK_NEG; // n:0 + mnlinkc = ((MN*)memt)->link; + mnlinkc &= M_MNLINK_UPOS; // 0:p + ((MN*)memt)->link = mnlinkc | mnlink; // n:p + + // we are done +MDPA_SUCCESS: + ec=0; +BAIL: + return ec; +} // memDynPAlloc + +// +// memDynFree +// +// +// in: +// mem = memory to be free'd +// mempoolp = ptr to dynamic memory pool +// out: +// <0 = fail +// global: +// +// GNP 05 Jun 00 +// JFL 22 Sep 04 +int memDynFree(memD* mempoolp,MN_WORD *memt) +{ + MN_WORD* nodesave; + MN_WORD* nodelow; + MN_WORD* nodehigh; + uns32 mnlink; + uns32 size; + uns32 nsize; + + memt -= MN_SIZE; + nodesave = nodehigh = nodelow = memt; + + // clear in-use bit + mnlink = ((MN*)memt)->link; + ((MN*)memt)->link = mnlink & ~M_MNLINK_USED; + + // try to join free node with next (right) + size = mnlink & M_MNLINK_POS; + memt += (size + MN_SIZE); + + mnlink = ((MN*)memt)->link; + + // if next node is not in-use + if (!(mnlink & M_MNLINK_USED)) + { + // join two nodes if new node will not be too large + nsize = mnlink & M_MNLINK_POS; + if ( nsize && ((size + nsize + MN_SIZE) <= M_MNLINK_POS)) + { + // link free + nsize += size+MN_SIZE; + mnlink = ((MN*)nodesave)->link & ~M_MNLINK_POS; + ((MN*)nodesave)->link = mnlink | nsize; + + // link right + memt = nodesave + nsize + MN_SIZE; + nsize <<= S_MNLINK_NEG; + mnlink = ((MN*)memt)->link & M_MNLINK_UPOS; + ((MN*)memt)->link = mnlink | nsize; + nodehigh = memt; + } + } // if + + // try to join free node with previous (left) + mnlink = ((MN*)nodesave)->link; // re-load in case size changed + size = mnlink & M_MNLINK_POS; + + // if end of list not reached + if ((mnlink >>= S_MNLINK_NEG)) + { + memt = nodesave - mnlink - MN_SIZE; // previous node + nsize = ((MN*)memt)->link; + if (!(nsize & M_MNLINK_USED)) + { + nsize &= M_MNLINK_POS; + nsize += size+MN_SIZE; + + // if new node is not too large for system + if (nsize < M_MNLINK_POS) + { + // link left + nodelow = memt; + mnlink = ((MN*)memt)->link & ~M_MNLINK_UPOS; //n:0 + ((MN*)memt)->link = mnlink | nsize; //n:p + + // link free + memt += nsize + MN_SIZE; // next node + nsize <<= S_MNLINK_NEG; + mnlink = ((MN*)memt)->link & M_MNLINK_UPOS; + ((MN*)memt)->link = mnlink | nsize; + nodehigh = memt; + } + } + } // if + + if (mempoolp->startn < (memu)nodehigh) + mempoolp->startn = (memu)nodehigh; + if (mempoolp->startp > (memu)nodelow) + mempoolp->startp = (memu)nodelow; + + return 0; +} // memDynFree + +// +// memDynCheck +// scan dynamic pool +// +// in: +// mempoolp = ptr to dynamic memory pool +// out: +// <0 = fail +// global: +// +// JFL 02 Feb 05 +int memDynCheck(memD* mempoolp,uns32 *availp,uns32 *usedp,uns32 *countp) +{ + int16 ec; + uns32 avail,used,count; + uns32 mnlink; + uns32 mnlinkc; + MN_WORD* memt; + + if (!mempoolp->startp) + err(ERR_MEM_POOL_NOT_INITIALIZED); + + avail=used=count=0; + + memt = (void*) mempoolp->startp; + + for (mnlink=((MN*)memt)->link;; + memt += (mnlink + MN_SIZE),mnlink=((MN*)memt)->link) + { + mnlinkc = mnlink; + mnlink &= M_MNLINK_POS; // size of block + count++; + if (!mnlink) + break; // end of list + if (mnlinkc & M_MNLINK_USED) + used+=mnlink; + else + avail+=mnlink; + } // for + + if(availp) + *availp=avail; + if(usedp) + *usedp=used; + if(countp) + *countp=count; + ec=0; +BAIL: + return ec; +} // memDynCheck + +// EOF diff --git a/dond/core/mem.h b/dond/core/mem.h new file mode 100755 index 0000000..6adeda5 --- /dev/null +++ b/dond/core/mem.h @@ -0,0 +1,89 @@ +#ifndef MEM_H +#define MEM_H +// mem.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// GNP 05 May 00 +// JFL 26 Aug 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +#ifndef SYS_H +#include "sys.h" +#endif // ndef SYS_H + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +// memory sizes in bytes (1MB=0x100000) +#define KBYTES 1024 +#define MBYTES 1024*1024 +#define MEMHEAP_SIZE 64*MBYTES + +enum { + // pools of memory + MEMPOOL_HEAP, + MEMPOOL_VID, + MEMPOOL_NET, + MEMPOOL_PERM, + MEMPOOL_WAVE, + MEMPOOL_SUBW, + MEMPOOL_MAX, + + // remapped pools + MEMPOOL_MAP=0x80, + MEMPOOL_RES, + MEMPOOL_OBJ, + MEMPOOL_MAXMAP +}; + +enum { + // memory maps for different requirements + MEMMAP_STARTUP, + MEMMAP_GAME, + MEMMAP_MAX +}; + +#define MEM_SAVEPOINTS 16 + +extern int MemInit(void); +extern void MemFinal(void); +extern int MemReset(uns reset); +extern int MemInfo(char *buf,int bufSize); +extern int MemStackRestore(int savepoint); +extern int MemStackSave(int savepoint); +extern int MemPoolMap(uns pool,uns mapto); + +#define MemCpy MemCopy +extern void MemCopy(void *dst,void *src,uns size); +extern void MemZero(void *mem,uns size); +#define MEMZ(_mem_) MemZero(&(_mem_),sizeof(_mem_)) + +extern int MemPoolReset(uns pool,uns reset); + +// stack allocator +extern int MemSLow(uns pool,uns size,void *memp); +extern int MemSHigh(uns pool,uns size,void *memp); +extern void* MemSLowGet(uns pool); +extern void MemSLowSet(uns pool,void *mem); +extern void* MemSHighGet(uns pool); +extern void MemSHighSet(uns pool,void *mem); +extern uns MemSAvail(uns pool); + +// dynamic allocator +extern int MemDAlloc(uns pool,uns size,void *memp); +extern int MemDAlloz(uns pool,uns size,void *memp); +extern int MemDFree(uns pool,void *mem); +extern int MemDSetup(uns pool,void *mem,uns size); + +typedef struct +{ + int jpsOutstanding; + int jpsCount; + int jpsLargest; +} MemSysInfoRec; + +extern MemSysInfoRec MemSysInfo; + +#endif // ndef MEM_H diff --git a/dond/core/mem_data.c b/dond/core/mem_data.c new file mode 100755 index 0000000..057fb84 --- /dev/null +++ b/dond/core/mem_data.c @@ -0,0 +1,12 @@ +// mem_data.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 22 Sep 04 + +#include "pm.h" +#include "mem.h" + +unsigned char *MemHeap; + +// EOF diff --git a/dond/core/msg.h b/dond/core/msg.h new file mode 100755 index 0000000..256c328 --- /dev/null +++ b/dond/core/msg.h @@ -0,0 +1,36 @@ +#ifndef MSG_H +#define MSG_H +// msg.h +// Copyright 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 09 Feb 05 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +enum { + MSGSUB_NONE, + MSGSUB_COL, + MSGSUB_MAX +}; + +typedef struct { + N2 lnk; +} Msg; + +enum { + MSGCOLFUNC_NONE, + MSGCOLFUNC_CI, // (-,ObjColAct*,ObjColInfo*,NUL) +}; + +typedef struct { + N2 lnk; + uns8 flags; + uns8 xx1; + uns16 xx2; + void *cola; // ObjColAct + void *block; // ResDataCBXZMM + void *poly; // ResDataCBPoly +} MsgColInfo; + +#endif // MSG_H diff --git a/dond/core/net.h b/dond/core/net.h new file mode 100755 index 0000000..314cf30 --- /dev/null +++ b/dond/core/net.h @@ -0,0 +1,112 @@ +#ifndef NET_H +#define NET_H +// net.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 08 Sep 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +// ---------------------------------------------------------------------------- +// SYS_JP5500 +#if SYS_JP5500 + +typedef struct { + uns8 sys[256]; // must start with system memory + uns16 port; + uns16 flags; + void *p1; + void *phOther; +} NetPH; + +extern int net_intenable(int enable); +extern int net_inthandler(void); + +#endif // SYS_JP5500 +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// SYS_PC SYS_BB +#if SYS_PC|SYS_BB + +typedef struct { + uns8 sys[256]; // must start with system memory + uns16 port; + uns16 flags; + void *p1; + void *phOther; +} NetPH; + +#endif // SYS_PC|SYS_BB +// ---------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +// rfc 1700 "Port Assignments" +#define NETPORT_FTPDAT 20 +#define NETPORT_FTPCTL 21 + +#define NETPORTSTACK_ARGBUF_NUM 8 + +enum { + NETPORTSTACK_EMPTY, + NETPORTSTACK_ERROR, + NETPORTSTACK_REMOTE_TRYING_TO_OPEN, + NETPORTSTACK_CLOSING, + NETPORTSTACK_RECEIVED_AND_UNLINKED, + NETPORTSTACK_SENT_AND_UNLINKED, + NETPORTSTACK_UNLINKED, +}; + +enum { + NETPORTINFO_NONE, + NETPORTINFO_OFF_THEIRIP, + NETPORTINFO_OFF_THEIRMAC, +}; + +enum { + NETBUFSTATE_NONE, + NETBUFSTATE_READYTOREAD, + NETBUFSTATE_READYTOSEND, + NETBUFSTATE_SENDING, + NETBUFSTATE_WAITINGFORACK, + NETBUFSTATE_FILLING, + NETBUFSTATE_FILLED, + NETBUFSTATE_DONESENDING, +}; + +#define M_NETPORTADD_FIN 0x01 + +typedef struct { + N2 lnk; + uns8 state; // state + uns8 sflags; // system flags + uns8 uflags; // user flags + uns8 uval; // user value + uns8 *buf; // buffer + uns bufLen; // len of data in buffer + uns bufSize; // size of buffer + mtime stateTime; + uns32 seqLo; // seq start if sending + uns32 seqHi; // seq end if sending, ack needed if receiving +} NetBuf; + +#define M_NETPORTADD_SENDBACK 0x0001 + +extern int NetInit(void); +extern void NetFinal(void); +extern int NetReset(uns reset); +extern int NetLoop(void); + +extern int NetPortAddListener(NetPH *ph,uns port,uns flags); +extern int NetPortAddSender(NetPH *ph,uns port,uns flags,uns8 *dmac,uns8 *dip,uns16 dport); +extern int NetPortRem(NetPH *ph); +extern int NetPortAddRvBuf(NetPH *ph,NetBuf *nb); +extern int NetPortAddSdBuf(NetPH *ph,NetBuf *nb,uns flags); +extern int NetPortRemBuf(NetPH *ph,NetBuf *nb); +extern int NetPortPop(NetPH **php,sto *argbuf); +extern int NetPortInfo(NetPH *ph,uns info); + +#endif // ndef NET_H diff --git a/dond/core/obj.c b/dond/core/obj.c new file mode 100755 index 0000000..e8a4a7d --- /dev/null +++ b/dond/core/obj.c @@ -0,0 +1,2729 @@ +// obj.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Objerved +// +// JFL 08 Oct 04 + +#include "pm.h" +#include "mem.h" +#include "obj.h" +#include "vec.h" +#include "res.h" +#include "str.h" +#include "vid.h" +#include "sys.h" +#include "msg.h" +#include "game.h" + +typedef struct { + uns8 flags; + uns8 dead; + N2 activeList; + N2 colList; + N2 deadList; + N2 l2List[OBJL2_NUM]; // secondary list link + void *link; +} objGlobals; + +objGlobals objG; + +// forwards +void objFreeAll(void); + +// JFL 08 Oct 04 +int ObjInit(void) +{ + MEMZ(objG); + return 0; +} // ObjInit() + +// JFL 08 Oct 04 +void ObjFinal(void) +{ + if(objG.flags) + { + objG.flags=0; + objFreeAll(); + } +} // ObjFinal() + +// JFL 08 Oct 04 +int ObjReset(uns reset) +{ + int i; + if(objG.flags) + { + objG.flags=0; + objFreeAll(); + } + + N2Head(&objG.activeList); + N2Head(&objG.colList); + N2Head(&objG.deadList); + for(i=0;i=OBJL2_NUM) + return NUL; + return objG.l2List[n].next; +} // ObjL2First() + +// JFL 25 Mar 05 +void ObjL2Link(uns n,void *o) +{ + N2 *l2=N2L2(o); + + n&=M_OBJL2; + if(nflags|=M_N2_L2LINKED; // signal L2 structure & linked + l2->type=N2TYPE_L2; + l2->sub=n; + N2LinkBefore(&objG.l2List[n],l2); + } +} // ObjL2Link() + +// JFL 11 Aug 05 +void ObjL2Reset(uns n) +{ + n&=M_OBJL2; + if(nnext) && n->type) + { + if(n->flags&M_N2_KIDLIST) + objFreeList(n-1); + + N2Unlink(n); + + // free + if(n->flags&M_N2_KIDLIST) + n--; // kid, backup + MemDFree(MEMPOOL_OBJ,n); + } // while +} // objFreeList() + +// JFL 14 Oct 04 +void objFreeAll(void) +{ + objFreeList(&objG.activeList); + objFreeList(&objG.colList); + objFreeList(&objG.deadList); +} // objFreeAll() + +// JFL 14 Oct 04 +// JFL 30 Dec 04; levels +// JFL 05 Jan 04; default to zero all +int ObjNew(void *objp,uns sub,uns size,uns flags) +{ + int ec; + int len; + N2 *n; + Obj *o2; + + len=sizeof(Obj); + if(flags&M_OBJNEW_KIDS) + { + len += sizeof(N2); + size += sizeof(N2); + } + + // create an object node + if((ec=MemDAlloc(MEMPOOL_OBJ,size,&n))<0) + {BP(BP_OBJNEW);goto BAIL;} // couldn't alloc + + // clear the obj memory -- default is to clear all, optimize w/DONTCLEAR + if(flags&M_OBJNEW_DONTCLEAR) + size=len; // override default, and only clear small node + MemZero(n,size); + + if(flags&M_OBJNEW_KIDS) + { + N2Head(n); // kid is list head + n++; + n->flags=M_N2_KIDLIST; + } + + n->type=N2TYPE_OBJ; // type is object + n->sub=sub; + n->flags|=SysG.n2FlagsOr; + + if(flags&M_OBJNEW_KIDFIRST) + n->flags|=M_N2_KIDFIRST; + + switch(flags&M_OBJNEW_LINKLIST) + { + + case M_OBJNEW_LINKACTIVE: +linkactive: + N2LinkBefore(&objG.activeList,n); + break; + case M_OBJNEW_LINKAFTER: + if(!(o2=objG.link)) + goto linkactive; + N2LinkAfter(o2,n); + break; + case M_OBJNEW_LINKBEFORE: + if(!(o2=objG.link)) + goto linkactive; + N2LinkBefore(o2,n); + break; + case M_OBJNEW_LINKCOL: + N2LinkBefore(&objG.colList,n); + break; + } // switch + + switch(sub) + { + case OBJSUB_DISPRES: + ((ObjDispRes*)n)->tag=SysG.tag; + break; + } // switch + + *((void**)objp)=(Obj*)n; + + ec=0; +BAIL: + return ec; +} // ObjNew() + +// JFL 11 Nov 04 +// JFL 01 Feb 05 +// JFL 31 May 05 +int ObjCamResStart(ObjCam *cam,void *vr,uns flags) +{ + int ec; + void *d; + float a; + Res *r; + Res *r2; + Obj *o2; + uns8 hasani=0; + Res resparse,*rp=&resparse; + + if(!cam) + err(1); + cam->res=NUL; + if(!(r=vr)) + err(1); + if((r->lnk.sub==RESSUB_CAM) && (d=r->data)) + { + cam->res=r; + + cam->flags=flags; + cam->flags&=~M_OBJCAM_ORTHO; + if(((ResDataCam*)d)->mode & M_RESDATACAM_ORTHO) + cam->flags|=M_OBJCAM_ORTHO; + + cam->orthoWidth=(float)0.5*((ResDataCam*)d)->orthoWidth; + a=(float)VidDisp.screenH/(float)VidDisp.screenW; + cam->orthoHeight=a*cam->orthoWidth; + + cam->rot[0]=((ResDataCam*)d)->rot[0]; + cam->rot[1]=((ResDataCam*)d)->rot[1]; + cam->rot[2]=((ResDataCam*)d)->rot[2]; + cam->trans[0]=((ResDataCam*)d)->trans[0]; + cam->trans[1]=((ResDataCam*)d)->trans[1]; + cam->trans[2]=((ResDataCam*)d)->trans[2]; + szncpy(cam->name,r->name,sizeof(cam->name)); + + cam->fov=((ResDataCam*)d)->fov; + cam->clipNear=((ResDataCam*)d)->clipNear; + cam->clipFar=((ResDataCam*)d)->clipFar; + } + else + err(-1); + + // + // CAMERA SEQUENCE + // + + if((d=r->data) && ((ResDataCam*)d)->atSize) + { + MEMZ(resparse); + rp->flags|=M_RES_PARSE1; + ResParse(rp,((ResDataCam*)d)->atBuf,NUL); + } + + // + // CAMERA ANIMATION + // + + // check if cam already has anim node + for(o2=(void*)N2KIDLIST(cam)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_ANIRES) + { + ((ObjAniRes*)o2)->skipAdj=0; // jjj -- bogus, think through this + + hasani=1; + break; + } // already has ani + } // for + + if(r->flags&M_RES_LOOP) + flags|=M_OBJANIRES_LOOP; + + if(cam->flags&M_OBJCAM_OFFSPLINE) + goto offspline; + + // look for a matching animation + if((r2=ResFindSubNth(NUL,r->name,RESSUB_KAN,0))) + { + // check if cam already has anim node + if(!hasani) + { + // doesn't have ani, create + if((ec=ObjNew(&o2,OBJSUB_ANIRES,sizeof(ObjAniRes), + M_OBJNEW_DONTLINK))<0) + goto BAIL; + szncpy(((ObjAniRes*)o2)->name,"cam",sizeof(((ObjAniRes*)o2)->name)); + N2LevelCpy((void*)o2,(void*)cam); // these go together + N2LinkBefore(N2KIDLIST(cam),o2); + } + ((ObjAniRes*)o2)->flags=flags; + ObjAniResSwitch((ObjAniRes*)o2,r2); + } + else + { +offspline: + // no matching ani res + if(hasani) + ((ObjAniRes*)o2)->res=NUL; + } + + ec=0; +BAIL: + return ec; +} // ObjCamResStart() + +// JFL 22 Nov 04 +ObjCam* ObjCamCur(void) +{ + Obj *o; + + for(o=ObjActiveFirst();o->lnk.type;o=o->lnk.next) + { + if(o->lnk.sub==OBJSUB_CAM) + return (void*)o; + } // for + + return NUL; +} // ObjCamCur() + +// +// ObjSkelInvertIfNeeded +// temporary routine to invert the skeleton bind pose matrices +// jjj -- until DC does this +// +// in: +// skel = skeleton resource data +// out: +// global: +// +// GNP 21 Dec 05 +// +void ObjSkelInvertIfNeeded(ResDataSkel *skel) +{ + int i; + ResDataJoint *jt; + + // jjj -- until DC does this + if(!(skel->flags&M_RESDATASKEL_JJJBINDINVERTED)) + { + skel->flags|=M_RESDATASKEL_JJJBINDINVERTED; + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + VMInv(jt->bps,jt->bps); + } // jjj +//DONE("ObjSkelInvertIfNeeded") +} // ObjSkelInvertIfNeeded + +// JFL 17 Nov 04; start +int ObjSkelAddAnims(ObjSkelRes *osr,void *vr) +{ + int ec; + int i; + ResDataSkel *skel; + ObjAniRes *oar; + Obj *olink; + ResDataJoint *jt; + Res *r=vr; + + if((r->lnk.sub==RESSUB_SKEL) && (skel=r->data)) + { + osr->res=r; + + // jjj -- until DC does this + ObjSkelInvertIfNeeded(skel); + + olink=(void*)osr; + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + { + + if((ec=ObjNew(&oar,OBJSUB_ANIRES,sizeof(ObjAniRes), + M_OBJNEW_DONTLINK))<0) + break; + szncpy(oar->name,jt->name,sizeof(oar->name)); + N2LevelCpy((void*)oar,(void*)osr); // these go together + N2LinkAfter(olink,oar); + olink=(void*)oar; + + // this is a special case + // before an animation has been attached, set key1 to joint name + oar->res=NUL; + oar->key1=jt->name; + oar->flags|=M_OBJANIRES_SKEL; + } // for + } + else + err(-1); + + ec=0; +BAIL: + return ec; +} // ObjSkelAddAnims() + +// JFL 01 Dec 04 +void* ObjFindDispRes(char *name) +{ + Obj *o; + Res *r; + + for(o=ObjActiveFirst();o->lnk.type;o=o->lnk.next) + { + if((o->lnk.sub==OBJSUB_DISPRES) + && (r=((ObjDispRes*)o)->res)) + { + if(!szcmp(name,r->name)) + return o; + } + + } // for + + return NUL; +} // ObjFindDispRes() + +// +// ObjFindSub +// find sub-object of this object +// +// in: +// obj = obj start +// subtype = OBJSUB_ +// out: +// NULL=fail, otherwise object +// global: +// +// GNP 20 Dec 05 +// +void *ObjFindSub(Obj *obj, uns subtype) +{ + Obj *o; + + for(o=N2KIDLIST(obj)->next;o->lnk.type;o=o->lnk.next) + { + if(o->lnk.sub==subtype) + { + return(o); + } + } // for + +//DONE("ObjFindSub") + return(NULL); +} // ObjFindSub + +// JFL 01 Dec 04 +// JFL 04 Mar 05 +int ObjAniBody(void *vo,void *vr,uns cmd,float f1) +{ + int ec; + Obj *o=vo; + ObjAniRes *oar; + N2 *k; + char *oldname; + Res *r,*newanis,*r2; + Res *br; + uns flags; + + if((br=vr) // body-anim-res + && (br->lnk.flags&M_N2_KIDLIST) // has kids + && (k=N2KIDLIST(br)->next)) // first in kidlist + newanis=(void*)k; + else + newanis=NUL; + + flags=0; + if(cmd&M_OBJANICMD_LOOP) + flags|=M_OBJANIRES_LOOP; + if(cmd&M_OBJANICMD_SNAP) + flags|=M_OBJANIRES_SNAPONCE; + if(cmd&M_OBJANICMD_BRIDGE) + flags|=M_OBJANIRES_BRIDGE; + if(cmd&M_OBJANICMD_SYNC) + flags|=M_OBJANIRES_SYNC; + + // this only handles start now.. + switch(cmd&M_OBJANICMD) + { + case OBJANICMD_START: + case OBJANICMD_SETNEXT: + case OBJANICMD_SETBLENDADD: + if(!newanis) + berr(-1); // need body-anim-res + break; // OBJANICMD_START + case OBJANICMD_FLAGS: + break; // OBJANICMD_FLAGS + default: + berr(-4); // not handled + } // switch + + // scan obj + if(o->lnk.sub!=OBJSUB_DISPRES) + err(-1); + if(!o->lnk.flags&M_N2_KIDLIST) + err(-2); + if(!(k=N2KIDLIST(o)->next) || !k->type) + err(-3); + for(;k->type;k=k->next) + { + if(k->sub!=OBJSUB_ANIRES) + continue; + oar=(void*)k; + + // only process if skel ani nodes + if(!(oar->flags&M_OBJANIRES_SKEL)) + continue; + + // if blending, this overrides default blend time + if(cmd&M_OBJANICMD_ATIME) + oar->aTime=f1; + if(cmd&M_OBJANICMD_BTIME) + oar->bTime=f1; + + // if blendadd + if(cmd&M_OBJANICMD_RAMP) + oar->aRamp=f1; + + if(cmd&M_OBJANICMD_REMOVELOOP) + { + oar->flags&=~M_OBJANIRES_LOOP; + oar->flags|=M_OBJANIRES_DONTLOOP; + } + oar->flags |= flags; + + switch(cmd&M_OBJANICMD) + { + case OBJANICMD_START: + case OBJANICMD_SETNEXT: + case OBJANICMD_SETBLENDADD: + + // after anim has been attached, oar->res is set to attached anim + if((r=oar->res)) // set to res when anim is attached + { + if(r->lnk.sub==RESSUB_KAN) + oldname=r->name; + else + {BP(BP_OBJANIBODY);continue;} // res is wrong type + } + else + { + // this is a special case + // before an animation has been attached, key1=joint-name + if(!(oldname=oar->key1)) + continue; + } + + // run through the newanis resource list to find a match + // for this skel/joint name + for(r2=newanis;r2->lnk.type;r2=r2->lnk.next) + { + if(!szcmp(oldname,r2->name)) + { + if((cmd&M_OBJANICMD)==OBJANICMD_START) + ObjAniResSwitch(oar,r2); + else if((cmd&M_OBJANICMD)==OBJANICMD_SETNEXT) + oar->nextKan=r2->data; + else if((cmd&M_OBJANICMD)==OBJANICMD_SETBLENDADD) + { + // signal to blend once and do it now + oar->flags|=M_OBJANIRES_BLENDONCE|M_OBJANIRES_CHANGE + |M_OBJANIRES_BLEND2ADD; + ObjAniResSwitch(oar,r2); + } + break; + } // match + } // for + + break; // OBJANICMD_START OBJANICMD_SETNEXT OBJANICMD_SETBLEND + + case OBJANICMD_FLAGS: + // nothing to do + break; // OBJANICMD_FLAGS + } // switch + + } // for + + ec=0; +BAIL: + return ec; +} // ObjAniBody() + +// JFL 02 Dec 04 +// JFL 31 Mar 05 +// JFL 07 Apr 05; cam, non-skel +int ObjAniRoot(void *vo,void *vr,uns cmd,float f1,void *oarp) +{ + int ec; + Obj *o=vo; + ObjSkelRes *osr; + ObjAniRes *oar; + N2 *k; + Res *newani,*br=vr; + uns flags; + N2ScanRec nsr; + + if(br && (br->lnk.sub!=RESSUB_KAN)) + berr(-1); + newani=(void*)br; + + // scan obj + oar=NUL; + if(o->lnk.sub==OBJSUB_ANIRES) + { + oar=(void*)o; + goto gotoar; + } + if(o->lnk.sub!=OBJSUB_DISPRES) + { + oar=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_KIDSONLY + |M_N2SCAN_SUB|OBJSUB_ANIRES,o); + if(oar) + goto gotoar; + + berr(-4); + } + if(!o->lnk.flags&M_N2_KIDLIST) + err(-2); + if(!(k=N2KIDLIST(o)->next) || !k->type) + err(-3); + + flags=0; + + // find skel + for(;k->type;k=k->next) + { + if(k->sub==OBJSUB_SKELRES) + { + osr=(void*)k; + goto gotskel; + } + if((k->sub==OBJSUB_ANIRES)&&!oar) + oar=(void*)k; + + } // for + + // no skel + + if(oar) + goto gotani; + + err(-4); +gotskel: + + // find oar for skel + k=N2KIDLIST(o)->next; + for(;k->type;k=k->next) + { + if((osr->rootDriver==k) && (k->sub==OBJSUB_ANIRES)) + { + oar=(void*)k; + goto gotani; + } + } // for + err(-5); +gotani: + + if(oar) + oar->flags|=M_OBJANIRES_ROOT; + +gotoar: + if(oarp) + *((void**)oarp)=oar; + + switch(cmd&M_OBJANICMD) + { + case OBJANICMD_START: + case OBJANICMD_DETACH: + if(cmd&M_OBJANICMD_LOOP) + oar->flags|=M_OBJANIRES_LOOP; + ObjAniResSwitch(oar,newani); + break; + case OBJANICMD_SETNEXT: + if((newani->lnk.type!=N2TYPE_RES) + ||(newani->lnk.sub!=RESSUB_KAN)) + {BP(BP_OBJANIROOT);break;} + oar->nextKan=newani->data; + break; + case OBJANICMD_STEP: + oar->flags&=~M_OBJANIRES_FROZEN; + oar->flags|=M_OBJANIRES_FREEZENEXT; + break; + case OBJANICMD_HOLD: + oar->flags|=M_OBJANIRES_FROZEN; + break; + case OBJANICMD_RUN: + oar->flags&=~(M_OBJANIRES_FROZEN|M_OBJANIRES_FREEZENEXT); + break; + case OBJANICMD_SKIPTO: + // skip to time 'f1' + oar->flags&=~(M_OBJANIRES_FROZEN|M_OBJANIRES_FREEZENEXT); + if(f1frameCount) + break; // only allow skip forward + oar->flags|=M_OBJANIRES_SKIPTO; + oar->skipAdj=f1; + break; + case OBJANICMD_SKIP: + // skip 'f1' + oar->flags&=~(M_OBJANIRES_FROZEN|M_OBJANIRES_FREEZENEXT); + if(f1<0) + break; // only allow skip forward + oar->flags|=M_OBJANIRES_SKIPTO; + oar->skipAdj=f1+oar->frameCount; + break;; + } // switch + + ec=0; +BAIL: + return ec; +} // ObjAniRoot() + +// JFL 11 Nov 04 +// JFL 15 Nov 04; start +// JFL 12 Jan 05; simplified flags +int ObjAniResSwitch(ObjAniRes *oar,void *vr) +{ + int ec; + void *d; + Res *r; + + // take away flags based on current animation + oar->flags&=~(M_OBJANIRES_FROZEN|M_OBJANIRES_DONE|M_OBJANIRES_FREEZENEXT); + + // get ResDataKan + if((r=oar->res=vr) + &&(r->lnk.sub==RESSUB_KAN) + && (d=r->data)) + { + // + // overrides + // + + if(!(oar->flags&M_OBJANIRES_DONTLOOP)) + { + // if dontloop isn't set by user, copy res loop flag out + if(((ResDataKan*)d)->flags&M_RESDATAKAN_LOOP) + oar->flags|=M_OBJANIRES_LOOP; + } + + // if the oar had a name, here's where we'd set it + // szncpy(oar->name,r->name,sizeof(oar->name)); + + // change now or next obj-loop + if(oar->flags&M_OBJANIRES_CHANGE) + ObjAniChange(oar,d,-1); // -1 signals to get current wave time + else + oar->flags|=M_OBJANIRES_CHANGE; + } + else + berr(-1); + + ec=0; +BAIL: + return ec; +} // ObjAniResSwitch() + +// JFL 09 Dec 04 +int ObjAniSeq(ObjSeqRes *osr,void *vr,uns cmd) +{ + int ec; + void *d; + memu *var; + Res *r=vr; + + if(!r) + { + osr->res=r; + osr->key0=0; // force reset + osr->hold=0; + } + else if((r->lnk.sub==RESSUB_SEQ) && (d=r->data)) + { + osr->res=r; + osr->key0=0; // force reset + osr->hold=0; + + osr->flags&=~(M_OBJANIRES_FROZEN|M_OBJANIRES_LOOP); + osr->flags|=M_OBJANIRES_ENDKILL; + if(cmd&M_OBJANICMD_LOOP) + osr->flags|=M_OBJANIRES_LOOP; + + if(((ResDataSeq*)d)->allocSize) + { + var=(void*)&osr[1]; + if(cmd&M_OBJANICMD_ZERO) + MemZero(var,((ResDataSeq*)d)->allocSize); + var[BINBUF_SIZE]=(((ResDataSeq*)d)->allocSize)/sizeof(memu); + } + + ObjOnce((void*)osr); + } + else + err(-1); + + ec=0; +BAIL: + return ec; +} // ObjAniSeq() + +// JFL 17 Jan 05 +int ObjSeqStart(N2 *nlink,void *vr,void *objp) +{ + int ec; + char *s1; + ObjSeqRes *osr=NUL; + memu tmpbin[8],tmpvar[8]; + uns flags; + ResDataSeq *rds; + Res *r=vr; + + if(r->lnk.sub!=RESSUB_SEQ) + err(-1); + rds=(void*)&r[1]; + + // + // BEFORE FUNC + // + + if(rds->beforeOff) + { + s1=(void*)&rds[1]; + s1+=rds->beforeOff; + + // setup to call before func code + MEMZ(tmpbin); + MEMZ(tmpvar); + tmpbin[BINBUF_SIZE]=COUNT(tmpbin); + tmpbin[BINBUF_NEXT]=BINBUF_FIRST; + tmpvar[BINBUF_SIZE]=COUNT(tmpvar); + tmpvar[BINBUF_NEXT]=BINBUF_FIRST; + if((ec=ResParseText(NUL,tmpbin,tmpvar,s1,NUL))<0) + goto BAIL; + } // before func + + // + // CREATE OSR + // + + flags=M_OBJNEW_LINKACTIVE; + if(nlink) + flags=M_OBJNEW_DONTLINK; + + if((ec=ObjNew(&osr,OBJSUB_SEQRES,sizeof(ObjSeqRes)+rds->allocSize,flags))<0) + goto BAIL; + szncpy(osr->name,r->name,sizeof(osr->name)); + if(nlink) + N2LinkBefore(nlink,osr); + + if(rds->cleanupOff) + osr->cleanupSeq = (void*)((memu)&rds[1] + rds->cleanupOff); + + ObjAniSeq(osr,r,OBJANICMD_START|M_OBJANICMD_ZERO); + + if(objp) + *((void**)objp)=osr; + + ec=0; +BAIL: + return ec; +} // ObjSeqStart() + +// JFL 03 Apr 05 +int ObjSeqGetVars(ObjSeqRes *osr,memu **varsp) +{ + int ec; + memu *var; + + ResDataSeq *rds; + if(!(rds=osr->res)) + berr(-1); + if(!rds->allocSize) + err(0); + + var=(void*)&osr[1]; + ec=var[BINBUF_SIZE]-BINBUF_FIRST; + *varsp=(void*)&var[BINBUF_FIRST]; + +BAIL: + return ec; +} // ObjSeqGetVars() + +// JFL 17 Jan 05 +int ObjSeqBranch(ObjSeqRes *osr,void *adr) +{ + osr->key0=adr; // set branch adr + osr->hold=0; // remove any hold + return 0; +} // ObjSeqBranch() + +// JFL 06 Dec 04 +int ObjAddCol(ObjColDef *cold) +{ + N2LinkBefore(&objG.colList,cold); + return 0; +} // ObjAddCol() + +// JFL 06 Dec 04 +void* ObjGetCol(uns size,uns flags,void *colp) +{ + ObjColDef *cold; + ObjColDefBase *ocb; + uns8 type=flags&M_OBJCOLDEFTYPE; + + // find col record + if(!(cold=objG.colList.next) || !cold->lnk.type) + return NUL; + + // make sure there's room + if((cold->next+size)>cold->size) + return NUL; + + // allocate a collision entry + ocb=(void*)((memu) &cold[1] + cold->next); + cold->next+=size; + + ocb->type=type; + ocb->flags=0; + ocb->len=size; + + // pass back + if(colp) + *((void**)colp)=cold; + + return ocb; +} // ObjGetCol() + +// JFL 06 Dec 04 +void* ObjColScanXY(int x,int y) +{ + ObjColDef *col; + ObjColDefBase *ocb; + int x1,y1,x2,y2; + uns sofar; + + for(col=objG.colList.next;col->lnk.type;col=col->lnk.next) + { + for(sofar=0;sofarnext;) + { + ocb=(void*)((memu)&col[1] + sofar); + sofar+=ocb->len; + switch(ocb->type) + { + case OBJCOLDEFTYPE_BASE: + break; + case OBJCOLDEFTYPE_TEXT: + + // check for inside the big box + x1=((ObjColDefText*)ocb)->boxBig[BOX_L]; + y1=((ObjColDefText*)ocb)->boxBig[BOX_T]; + x2=((ObjColDefText*)ocb)->boxBig[BOX_R]; + y2=((ObjColDefText*)ocb)->boxBig[BOX_B]; + if(xx2 || yy2) + break; + + // check if between the top & bottom box (i.e. in the body of the text) + x1=((ObjColDefText*)ocb)->boxBig[BOX_L]; + y1=((ObjColDefText*)ocb)->boxTop[BOX_B]; + x2=((ObjColDefText*)ocb)->boxBig[BOX_R]; + y2=((ObjColDefText*)ocb)->boxBot[BOX_T]; + if(x>=x1 && x<=x2 && y>=y1 && y<=y2) + goto inside; + + // check if in the top + x1=((ObjColDefText*)ocb)->boxTop[BOX_L]; + y1=((ObjColDefText*)ocb)->boxTop[BOX_T]; + x2=((ObjColDefText*)ocb)->boxTop[BOX_R]; + y2=((ObjColDefText*)ocb)->boxTop[BOX_B]; + if(x>=x1 && x<=x2 && y>=y1 && y<=y2) + goto inside; + + // check if in the bot + x1=((ObjColDefText*)ocb)->boxBot[BOX_L]; + y1=((ObjColDefText*)ocb)->boxBot[BOX_T]; + x2=((ObjColDefText*)ocb)->boxBot[BOX_R]; + y2=((ObjColDefText*)ocb)->boxBot[BOX_B]; + if(x>=x1 && x<=x2 && y>=y1 && y<=y2) + goto inside; + + break; +inside: + return ocb; + break; + } // switch + } // for + } // for + + return NUL; +} // ObjColScanXY() + +#define COLEPSILON 0.00001 +#define COLEPSILON0G 0 +#define COLEPSILON1L 1 + +// JFL 07 Feb 05 +// JFL 08 Feb 05; +int ObjColScanGnd(ObjColAct *cola) +{ + int i; + ObjColDef *cold; + ObjColDefBase *ocb; + uns sofar; + ResDataCol *rdc; + ResDataCBVN *vn; + ResDataCBXZMM *mm; + ResDataCBPoly *poly; + int *polylist; + crd x,z,vta[3],pos[3]; + uns8 k; + float t,len,b,d,vtb[3]; + + x=pos[0]=cola->pos[0]+cola->xyzr[0]; // add cola->xyzr in + pos[1]=cola->pos[1]+cola->xyzr[1]; // this allows for offset from + z=pos[2]=cola->pos[2]+cola->xyzr[2]; // the root + t=cola->len+cola->xyzr[3]; + + // backup a small amount + b=cola->len/8; + pos[0]-=b*cola->dir[0]; + pos[1]-=b*cola->dir[1]; + pos[2]-=b*cola->dir[2]; + t+=b; + + for(cold=objG.colList.next;cold->lnk.type;cold=cold->lnk.next) + { + for(sofar=0;sofarnext;) + { + ocb=(void*)((memu)&cold[1] + sofar); + sofar+=ocb->len; + switch(ocb->type) + { + case OBJCOLDEFTYPE_GND: + if(!(rdc=((ObjColDefGnd*)ocb)->d)) + break; + if(!(mm=rdc->blocks) || !rdc->polys) + break; + for(;mm->blk.type==RESDATACOLBLOCK_XZMM;mm++) + { + // check for overlap + if(!cola->dir[0]&&!cola->dir[2]) + { + if(0 + ||(xminx) + ||(x>mm->maxx) + ||(zminz) + ||(z>mm->maxz) + ) + continue; + + } + else + { + len=V3DistFast(pos,mm->xyzr); // quick distance check + len-=t; // ray length + len-=mm->xyzr[3]; // sub out blocks radius + if(len>0) + continue; + } + + // + + polylist = (void*)(((uns8*)rdc->polys) + mm->off); + for(i=0;*polylist;polylist++,i++) + { + poly = (void*)(((uns8*)rdc->polys) + *polylist); + + // + // find ray v plane intersection point + // + vn=poly->v; + b=V3Dot(poly->nrmk,cola->dir); + if((b-COLEPSILON)) + goto polynocol; // orthogonal + d=V3Dot(poly->nrmk,vn->vrt); + len = (poly->nrmk[3]-V3Dot(poly->nrmk,pos))/b; + if((len<0) || (len>t)) + goto polynocol; // behind or too far + + // intersection point of ray and plane + vta[0]=len*cola->dir[0]; + vta[0]+=pos[0]; + vta[1]=len*cola->dir[1]; + vta[1]+=pos[1]; + vta[2]=len*cola->dir[2]; + vta[2]+=pos[2]; + + for(k=poly->numv+2;k>=0;k--,vn++) + { + V3Sub(vtb,vn->vrt,vta); // ray -- colpoint to vert + b=V3Dot(vtb,vn->nrm); + if(k) + { + if(b>0) + goto outside; + } + else + { + if(b<=0) + goto inside; + } + + } // for + +outside: + if(0) + { +inside: + if(!cola->clen || (cola->clen>len)) + { + cola->flags&=~M_OBJCOLACT_HITFLAGS; + cola->flags|=M_OBJCOLACT_HIT|M_OBJCOLACT_HITGNDCOL; + cola->clen=len; + cola->cpos[0]=vta[0]; + cola->cpos[1]=vta[1]; + cola->cpos[2]=vta[2]; + cola->cnrm[0]=poly->nrmk[0]; + cola->cnrm[1]=poly->nrmk[1]; + cola->cnrm[2]=poly->nrmk[2]; + cola->cobj=NUL; // signal no object + cola->ctype="type(gnd)"; + } + } + else + { +polynocol: + k=0; // no collision, parsing dummy + } + } // for + + // break; // jjjj + + } // for + + break; // only 1 set of ground collision info for now + } // switch + } // for + } // for + +//BAIL: + return 0; +} // ObjColScanGnd() + +// JFL 06 Dec 04 +void ObjColLoop(void) +{ + ObjColDef *cold; + + for(cold=objG.colList.next;cold->lnk.type;cold=cold->lnk.next) + { + if(cold->flags&M_OBJCOLDEF_DONTRESET) + continue; + cold->next=0; // reset + } // for + +} // ObjColFrame() + +// JFL 08 Dec 04 +// JFL 24 Aug 05 +int ObjIsSub(void *vo,uns8 subtype) +{ + int ec; + N2 *n; + Obj *o=vo; + + if(!o || (o->lnk.type!=N2TYPE_OBJ)) + berr(-1); + if(subtype && (o->lnk.sub!=subtype)) + berr(-2); + if(!(n=o->lnk.next) || (n->prev!=o)) + berr(-3); + if(n->type && (n->type!=N2TYPE_OBJ)) + berr(-4); + if(!(n=o->lnk.prev) || (n->next!=o)) + berr(-5); + if(n->type && (n->type!=N2TYPE_OBJ)) + berr(-6); + + ec=0; +BAIL: + return ec; +} // ObjIsSub() + +// JFL 09 Dec 04 +// JFL 25 Aug 05; already dead doesnt fail +int ObjKill(void *vo) +{ + // one-time kill functions + int ec; + Obj *o=vo,*o2,*o3; + Res *r; + void *d; + memu *var; + memu bin[8]; + + if(!o || (o->lnk.type!=N2TYPE_OBJ)) + { + #ifndef DEBUG + berr(-1); + #endif + } + + if(o->lnk.flags&M_N2_DEAD) + err(ERC_ALREADY_DEAD); // already dead + o->lnk.flags|=M_N2_SKIP|M_N2_DEAD; + objG.dead=1; // signal dead are waiting to be unlinked + + // process kill + switch(o->lnk.sub) + { + case OBJSUB_SEQRES: + if(((ObjSeqRes*)o)->cleanupSeq) + { + var=NUL; + if((r=((ObjSeqRes*)o)->res) + && (d=r->data) + && ((ResDataSeq*)d)->allocSize) + var=(void*)&((ResDataSeq*)d)[1]; + bin[BINBUF_SIZE]=COUNT(bin); + bin[BINBUF_NEXT]=BINBUF_FIRST; + ResParseText(NUL,bin,var,((ObjSeqRes*)o)->cleanupSeq,NUL); + } + break; + case OBJSUB_DISPRES: + if((r=((ObjDispRes*)o)->res) + && r->lnk.sub==RESSUB_DISP3) + { + // if disp3, must check for hanging disp2 objects + if((o->lnk.flags&M_N2_KIDLIST)) + { + // search first level of kids + for(o2=(void*)N2KIDLIST(o)->next;o2->lnk.type;o2=o2->lnk.next) + { + switch(o2->lnk.sub) + { + // velocity extensions can have display objects + case OBJSUB_VEL: + if((o2->lnk.flags&M_N2_KIDLIST)) + { + for(o3=N2KIDLIST(o2)->next;o3->lnk.type;o3=o3->lnk.next) + { + switch(o3->lnk.sub) + { + case OBJSUB_DISPRES: + ObjKillDisp((ObjDispRes*)o3); + break; // + } // switch + } // for + } + break; + } + } // for + } // kidlist + } //RESSUB_DISP3 + ObjKillDisp((ObjDispRes*)o); + break; + case OBJSUB_GROUP: + if(szcmp(((ObjGroup*)o)->name,"hidden")==0) + { + // hidden group object, must grope charm braclet for display objects + for(o2=N2KIDLIST(o)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_DISPRES) + { + ObjKillDisp((ObjDispRes*)o2); + } + } // for + } + break; + } // switch + + ec=0; +BAIL: + return ec; +} // ObjKill() + +// JFL 26 Jun 05; only kills at top level +int ObjKillBetween(void *v0,void *v1) +{ + N2 *n; + for(n=((N2*)v0)->next;n->type && (n!=v1);n=n->next) + ObjKill(n); + return 0; +} // ObjKillBetween() + +// JFL 26 Jun 05; only works at top level +int ObjHideBetween(void *hideobjp,void *v0,void *v1) +{ + int ec; + N2 *n,*n2,*k; + ObjGroup *o; + + // first obj to hide + n=((N2*)v0)->next; + + // 3d object markers + if((ec=ObjNew(&o,OBJSUB_GROUP,sizeof(ObjGroup), + M_OBJNEW_KIDS|M_OBJNEW_DONTLINK))<0) + goto BAIL; + szncpy(((ObjGroup*)o)->name,"hidden",sizeof(((ObjGroup*)o)->name)); + N2LinkBefore(n,o); // link group where first obj to hide is + ((N2*)o)->flags|=M_N2_SKIP; // don't process + k=(void*)N2KIDLIST(o); // link all here + + // unlink from their list & link into hidden node + for(;n->type && (n!=v1);n=n2) + { + n2=n->next; + N2Unlink(n); + N2LinkAfter(k,n); + } // for + + if(hideobjp) + *((N2**)hideobjp)=(void*)o; + + ec=0; +BAIL: + return ec; +} // ObjHideBetween() + +// JFL 26 Jun 05; only works at top level +int ObjUnhideAfter(void *hideobj,void *unhideafter) +{ + N2 *n; + + while((n=(N2KIDLIST(hideobj)->next)) && n->type) + { + N2Unlink(n); + N2LinkAfter(unhideafter,n); + } // while + + ObjKill(hideobj); + + return 0; +} // ObjUnhideAfter() + +// JFL 06 Jul 05; only works at top level +int ObjCull(uns op) +{ + int ec; + N2 *n; + + switch(op&M_OBJCULL) + { + case OBJCULL_SKIPON: + for(n=ObjActiveFirst();n->type;n=n->next) + { + // only work on disp res objects + if((n->sub!=OBJSUB_DISPRES)||(n->type!=N2TYPE_OBJ)) + continue; + + // only if the cull flag is set + if(!(((ObjDispRes*)n)->flags&M_OBJDISPRES_FRUSTOUT)) + continue; + + // skip + n->flags|=M_N2_SKIP; + } // for + + break; + case OBJCULL_SKIPOFF: + for(n=ObjActiveFirst();n->type;n=n->next) + { + // only work on disp res objects + if((n->sub!=OBJSUB_DISPRES)||(n->type!=N2TYPE_OBJ)) + continue; + + // only if the cull flag is set + if(!(((ObjDispRes*)n)->flags&M_OBJDISPRES_FRUSTOUT)) + continue; + + // don't skip + n->flags&=~M_N2_SKIP; + } // for + + break; + } // switch + + ec=0; +//BAIL: + return ec; +} // ObjCull() + +// JFL 30 Dec 04 +int ObjLevelKill(int level) +{ + N2 *n,*next; + + if(level>=0) + { + level<<=S_N2_LEVEL; + level&=M_N2_LEVEL; + + for(n=objG.colList.next;n->type;n=next) + { + next=n->next; + if((n->flags&M_N2_LEVEL)==level) + ObjKill((void*)n); + } // for + + for(n=objG.activeList.next;n->type;n=next) + { + next=n->next; + if(1 + && ((n->flags&M_N2_LEVEL)==level) + && !(n->flags&M_N2_STRONG) + ) + ObjKill((void*)n); + } // for + } + else if(level==-1) + { + for(n=objG.colList.next;n->type;n=next) + { + next=n->next; + if(n->flags&M_N2_LEVEL) + ObjKill((void*)n); + } // for + + for(n=objG.activeList.next;n->type;n=next) + { + next=n->next; + if(1 + && (n->flags&M_N2_LEVEL) + && !(n->flags&M_N2_STRONG) + ) + ObjKill((void*)n); + } // for + } + + return 0; +} // ObjLevelKill() + +// JFL 17 Jan 05 +int ObjTagKill(int tag) +{ + N2 *n,*next; + + for(n=objG.activeList.next;n->type;n=next) + { + next=n->next; + if((n->type==N2TYPE_OBJ)&&(n->sub==OBJSUB_DISPRES)) + { + if(1 + && (((ObjDispRes*)n)->tag==tag) + && !(n->flags&M_N2_STRONG) + ) + ObjKill((void*)n); + } + } // for + + return 0; +} // ObjTagKill() + +// JFL 09 Dec 04 +int ObjLoopEnd(void) +{ + if(objG.dead) + { + // move dead to the dead list + objG.dead=0; + N2MoveDead(objG.activeList.next,&objG.deadList); + N2MoveDead(objG.colList.next,&objG.deadList); + } + + if(N2MoveDead(objG.activeList.next,&objG.deadList)) + BP(BP_OBJLOOPEND1); + if(N2MoveDead(objG.colList.next,&objG.deadList)) + BP(BP_OBJLOOPEND2); + + // if there are any on the dead list, free them + if(((N2*)objG.deadList.next)->type) + objFreeList(&objG.deadList); + return 0; +} // ObjLoopEnd() + +// JFL 14 Dec 04 +// JFL 13 Apr 05 +void* ObjFindLinkName(char *name) +{ + Obj *o; + + if(!name) + return NUL; + + // look for markers + for(o=objG.activeList.next;o->lnk.type;o=o->lnk.next) + { + if((o->lnk.sub==OBJSUB_MARKER)&&!szcmp(name,((ObjMarker*)o)->name)) + return o; + if((o->lnk.sub==OBJSUB_CAM)&&!szcmp(name,((ObjCam*)o)->name)) + return o; + } // for + return NUL; +} // ObjFindLinkName() + +// JFL 14 Dec 04 +int ObjSetLinkName(char *name) +{ + Obj *o; + if((o=ObjFindLinkName(name))) + { + objG.link=o; + return 0; + } + return -1; +} // ObjSetLinkName() + +// JFL 14 Dec 04 +int ObjSetLinkObj(void *o) +{ + objG.link=o; + return 0; +} // ObjSetLinkObj() + +// JFL 08 Feb 05 +void* ObjGetLinkObj(void) +{ + return objG.link; +} // ObjGetLinkObj() + +// JFL 17 Jan 05 +int ObjSignal(void *vo,int msig,void *a) +{ + int ec; + Obj *o=vo; + N2 *n; + Res *r; + ResDataSeq *rds; + void *adr; + int nsig; + + // run through looking for a node to accept the signal + if(!(o->lnk.flags&M_N2_KIDLIST)) + err(1); // no kidlist -- won't accept signals + + n=N2KIDLIST(o); + n=n->next; + + // - check to see if this n object is invalid! + + if (!n) + { + SysLog("obj.c:ObjSignal error. sending signal %i to bad object. bad n.\n", msig); + err(1); + } + + if ((n->type == N2TYPE_NONE) || (n->type >= N2TYPE_MAX)) + { + SysLog("obj.c:ObjSignal error. sending signal %i to bad object. bad n->type.\n", msig); + err(1); + } + + for(;n->type;n=n->next) + { + if(n->type!=N2TYPE_OBJ) + continue; // not our type + if(n->sub!=OBJSUB_SEQRES) + continue; // not our subtype + if(!(r=((ObjSeqRes*)n)->res) || !(rds=r->data)) + continue; // no res data + if(!rds->nSig) + continue; // doesn't handle signals + + // jjj -- problem when sigdata is used more than once before cleared + ((ObjSeqRes*)n)->sigdata=a; + + nsig=msig&M_OBJSIGNAL; + + // + // before func + // + + // get the signal address -- before func + // return ec==0 if valid + if((ec=ResRDSSigAdr(rds,nsig,'b',&adr))<0) + continue; + if(!ec && (ec=ResRDSCall(n,rds,adr))<0) + err(1); // before func failed, don't start + + // + // abort the current signal-state + // + + if((adr=((ObjSeqRes*)n)->signalAbort)) + ResRDSCall(n,rds,adr); + + // setup signal-state abort adr for next time + adr=NUL; + if(ResRDSSigAdr(rds,nsig,'a',&adr)>=0) + adr=adr; + ((ObjSeqRes*)n)->signalAbort=adr; + + // + // start + // + + // get the signal address -- start func + if((ec=ResRDSSigAdr(rds,nsig,'s',&adr))<0) + continue; + if(!ec) + { + if(msig&M_OBJSIGNAL_IMMEDIATE) + { + if((ec=ResRDSCall(n,rds,adr))<0) + goto BAIL; + } + else + { + ObjSeqBranch((void*)n,adr); + } + } + break; + } // for + + ec=0; +BAIL: + return ec; +} // ObjSignal() + +// JFL 18 Jan 05 +int ObjTagSignal(int tag,int sig,void *a) +{ + N2 *n,*next; + + for(n=objG.activeList.next;n->type;n=next) + { + next=n->next; + if((n->type==N2TYPE_OBJ)&&(n->sub==OBJSUB_DISPRES)) + { + if(((ObjDispRes*)n)->tag==tag) + ObjSignal((void*)n,sig,a); + } + } // for + + return 0; +} // ObjTagSignal() + +// JFL 25 Mar 05 +void ObjColaVel(void *vcola,void *vvel) +{ + ObjColAct *cola=vcola; + ObjVel *ov; + float a,t; + + // this must match velAdd() + // this is assumed to execute before the vel adder + // idea is to collide the same distance & dir as the vel adder + + if(vvel) + { + cola->ov=vvel; + ov=vvel; + + cola->pos[0]=cola->vpos[0]=ov->trans[0]; + cola->pos[1]=cola->vpos[1]=ov->trans[1]; + cola->pos[2]=cola->vpos[2]=ov->trans[2]; + cola->len=0; + return; + } + + if(!(ov=cola->ov)) + return; + + // the goal is to never skip any space + // the projectile display object is attached and moved based on ov + // the collisions happen using cola + // this routine is called when the cola is created + // and at the start of every loop + // the idea is to copy the last drawn position into cola->pos + // then find where the projectile display object will be drawn this frame + // and setup the cola->dir & cola->len to point to where it will be drawn + + // get time in milliseconds + t=GameWaveTime-ov->velTime0; + + cola->pos[0]=cola->vpos[0]; + cola->pos[1]=cola->vpos[1]; + cola->pos[2]=cola->vpos[2]; + + a=t*ov->tacc[0]*0.5; + a+=t*ov->tvel[0]; + cola->vpos[0]=ov->trans[0]+a; + + a=t*ov->tacc[1]*0.5; + a+=t*ov->tvel[1]; + cola->vpos[1]=ov->trans[1]+a; + + a=t*ov->tacc[2]*0.5; + a+=t*ov->tvel[2]; + cola->vpos[2]=ov->trans[2]+a; + + V3Sub(cola->dir,cola->vpos,cola->pos); + cola->len=V3UnitizeFast(cola->dir,1); + +} // ObjColaVel() + +// JFL 12 May 05 +void* objFindPosExt(void *o) +{ + void *bestoar; + Obj *o2; + + if(!o || (((Obj*)o)->lnk.type!=N2TYPE_OBJ)) + return NUL; + + switch(((Obj*)o)->lnk.sub) + { + case OBJSUB_VEL: + case OBJSUB_ANIRES: + goto BAIL; + case OBJSUB_DISPRES: + + // scan first level of kids for extension w/info in it + bestoar=NUL; + if(o && (((Obj*)o)->lnk.flags&M_N2_KIDLIST)) + { + for(o2=(void*)N2KIDLIST(o)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_ANIRES) + { + if(((ObjAniRes*)o2)->flags&M_OBJANIRES_ROOT) + {o=o2;goto BAIL;} + else if(!bestoar) // first + bestoar=o2; + } + else if(o2->lnk.sub==OBJSUB_VEL) + {o=o2;goto BAIL;} + } // for + if(bestoar) + {o=bestoar;goto BAIL;} + } // kidlist + + break; + } // switch + + o=NUL; +BAIL: + return o; +} // objFindPosExt() + +// JFL 12 May 05 +int ObjGetRTS(void *o,crd *rot,crd *trans,crd *scale) +{ + o=objFindPosExt(o); + if(!o || (((Obj*)o)->lnk.type!=N2TYPE_OBJ)) + return -1; + + switch(((Obj*)o)->lnk.sub) + { + case OBJSUB_VEL: + if(rot) + { + rot[0]=((ObjVel*)o)->rot[0]; + rot[1]=((ObjVel*)o)->rot[1]; + rot[2]=((ObjVel*)o)->rot[2]; + } // rot + if(trans) + { + trans[0]=((ObjVel*)o)->trans[0]; + trans[1]=((ObjVel*)o)->trans[1]; + trans[2]=((ObjVel*)o)->trans[2]; + } // trans + if(scale) + { + scale[0]=((ObjVel*)o)->scale[0]; + scale[1]=((ObjVel*)o)->scale[1]; + scale[2]=((ObjVel*)o)->scale[2]; + } // scale + break; + case OBJSUB_ANIRES: + if(rot) + { + rot[0]=((ObjAniRes*)o)->cur[OAR_CH_RX]; + rot[1]=((ObjAniRes*)o)->cur[OAR_CH_RY]; + rot[2]=((ObjAniRes*)o)->cur[OAR_CH_RZ]; + } // rot + if(trans) + { + trans[0]=((ObjAniRes*)o)->cur[OAR_CH_TX]; + trans[1]=((ObjAniRes*)o)->cur[OAR_CH_TY]; + trans[2]=((ObjAniRes*)o)->cur[OAR_CH_TZ]; + } // trans + if(scale) + { + scale[0]=((ObjAniRes*)o)->cur[OAR_CH_SX]; + scale[1]=((ObjAniRes*)o)->cur[OAR_CH_SY]; + scale[2]=((ObjAniRes*)o)->cur[OAR_CH_SZ]; + } // scale + break; + default: + return -2; + } // switch + + return 0; +} // ObjGetRTS() + +// JFL 12 May 05 +int ObjGetRTVels(void *o,crd *rvel,crd *tvel) +{ + int ec; + crd rot[3],trans[3]; + + o=objFindPosExt(o); + if(!o || (((Obj*)o)->lnk.type!=N2TYPE_OBJ)) + return -1; + + switch(((Obj*)o)->lnk.sub) + { + case OBJSUB_VEL: + + if(rvel) + { + rvel[0]=((ObjVel*)o)->rvel[0]; + rvel[1]=((ObjVel*)o)->rvel[1]; + rvel[2]=((ObjVel*)o)->rvel[2]; + } // rvel + + if(tvel) + { + tvel[0]=((ObjVel*)o)->tvel[0]; + tvel[1]=((ObjVel*)o)->tvel[1]; + tvel[2]=((ObjVel*)o)->tvel[2]; + } // rot + + break; + case OBJSUB_ANIRES: + + // project the animation forward in time 1 unit + if((ec=ObjAniKanProject(o,GameWaveTimef+1,rot,trans,NUL))<0) + goto BAIL; + + // vel is change in position + + if(rvel) + { + rvel[0]=rot[0]-((ObjAniRes*)o)->cur[OAR_CH_RX]; + rvel[1]=rot[1]-((ObjAniRes*)o)->cur[OAR_CH_RY]; + rvel[2]=rot[2]-((ObjAniRes*)o)->cur[OAR_CH_RZ]; + } + + if(tvel) + { + tvel[0]=trans[0]-((ObjAniRes*)o)->cur[OAR_CH_TX]; + tvel[1]=trans[1]-((ObjAniRes*)o)->cur[OAR_CH_TY]; + tvel[2]=trans[2]-((ObjAniRes*)o)->cur[OAR_CH_TZ]; + } + + break; + + default: + err(-2); + } // switch + + ec=0; +BAIL: + return ec; +} // ObjGetRTVels() + +// ObjSkelSplineToVel() +// return +// < 0 -- fail +// == 0 -- success, vel obj returned in *ovp +// > 0 -- success, vel obj not returned +// +// JFL 12 May 05 +int ObjSkelSplineToVel(void *prime,uns flags,ObjVel **ovp) +{ + int ec; + Obj *o; + ObjSkelRes *osr; + ObjVel *ov; + + if(!prime || (((Obj*)prime)->lnk.type!=N2TYPE_OBJ)) + return -1; + + // scan kids to find objs we need to make the change + osr=NUL; + if(prime && (((Obj*)prime)->lnk.flags&M_N2_KIDLIST)) + { + for(o=(void*)N2KIDLIST(prime)->next;o->lnk.type;o=o->lnk.next) + { + if(o->lnk.sub==OBJSUB_SKELRES) + {osr=(void*)o;break;} + } // for + } // kidlist + if(!osr) + err(-1); + + // + // create vel & swap it with ani + // + + // swap root driver from animation to vel + if(!(o=osr->rootDriver) || o->lnk.type!=N2TYPE_OBJ) + err(1); + if(o->lnk.sub!=OBJSUB_ANIRES) + err(1); // already swapped out + + // create & link vel extension + if((ec=ObjNew(&ov,OBJSUB_VEL,sizeof(ObjVel),M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkBefore(N2KIDLIST(prime),ov); // link into end of kidlist + + // o->lnk.flags|=M_N2_SKIP; // done with this node + osr->rootDriver=ov; + ov->flags|=M_OBJVEL_IGNORE; // signal disp routine to ignore (skel uses) + ov->velTime0=GameWaveTime; + + // copy position and vels from ani to vel + if((ec=ObjGetRTS(o,ov->rot,ov->trans,ov->scale))<0) + goto BAIL; + if((ec=ObjGetRTVels(o,ov->rvel,ov->tvel))<0) + goto BAIL; + + if(ovp) + { + *ovp=ov; + err(0); // signal vel obj returned + } + + ec=2; +BAIL: + return ec; +} // ObjSkelSplineToVel() + +float LODDistanceTab[NUM_LOD] = +{ + LOD_DIST0, + LOD_DIST1, + LOD_DIST2, +}; + +// +// ObjAddLOD +// add given resource as LOD for this object +// +// in: +// out: +// global: +// +// GNP 20 Dec 05 +// +int ObjAddLOD(ObjDispRes *pObj, void *vLodRes, int lodLevel) +{ + Res *lodRes=vLodRes,*r; + ResDataSkel *skel; + ObjLOD *olod; + ObjSkelRes *oSkel; + LOD *lod; + int ec=0; + + olod = ObjFindLOD(pObj); + + // + // if there exists no LOD node, then create one and initialize + // + if (!olod) + { + // create LOD node + if((ec=ObjNew(&olod,OBJSUB_LOD,sizeof(ObjLOD),M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkBefore(N2KIDLIST(pObj),olod); // link into end of kidlist + + olod->cur=0; + olod->curDispRes = ((Res*)(pObj->res))->data; + // since this is new, initialize + lod = &olod->lod[0]; + lod->dist = LODDistanceTab[0]; + lod->dispRes = ((Res*)(pObj->res))->data; + + // look for skeleton + if(oSkel = ObjFindSkelRes(pObj)) + { + lod->skelRes = oSkel->res; + olod->curSkelRes = oSkel->res; + olod->baseNumJoints = oSkel->numJoints; + } + } + + // + // now set the LOD + // + if (lodLevellod[lodLevel]; + lod->dist = LODDistanceTab[lodLevel]; + lod->dispRes = ((Res*)vLodRes)->data; + + // + // need to try to locate the texture for this LOD + // + rTmp = pObj->res; + dListTmp = pObj->dList; + pObj->res = vLodRes; + pObj->dList = 0; + ObjResolveTex(pObj,0); + pObj->res = rTmp; + pObj->dList = dListTmp; + + // + // find the skeleton associated + // it has the correct weight information + // + if((r=ResFindSubNth(NUL,((Res*)vLodRes)->name,RESSUB_SKEL,NUL))) + { + if((skel=r->data)) + { + // jjj -- until DC does this + // LOD skeletons are not used as regular objects, which + // is when the invert hack is normally applied, so we + // need to do it here for LOD skeletons + ObjSkelInvertIfNeeded(skel); + // only add skeletons that fit + if (skel->numJoints <= olod->baseNumJoints) + lod->skelRes = r; + else + { + SysLog("ObjAddLOD: level %d skeleton: %s too many joints\n",lodLevel,r->name); + BP(BP_UNASSIGNED); //LOD skeleton has too many joints + // do not assign this LOD + lod->dist=0.0; + lod->dispRes=NULL; + } + } + + } + } + + pObj->flags |= M_OBJDISPRES_HASLOD; // make sure people know + +DONE("ObjAddLOD") + return ec; +} // ObjAddLOD + +#define OBJJOINTCOL_LEN 20 +// +// objColJoint +// one time collision of joint and cola +// +// in: +// out: +// global: +// +// JFL 20 Jul 05 +// GNP 03 Jan 06; retrieves bind pose matrix from skeleton resource +// +int objColJoint(ResDataCol *rdc,ObjSkelRes *osr, + ResDataCBXYZR *xyzr,ObjColAct *cola) +{ + int i; + ResDataCBTri *poly; + crd *vrt,vt0[3],vt1[3],vt2[3],vta[3],vtb[3],nrm[3],nre[3]; + float b,d,len; + VMType *vm2; + Res *r; + ResDataSkel *skel; + ResDataJoint *jt; + + if(!(r=osr->res) || (RESSUB_SKEL!=r->lnk.sub) || !(skel=r->data) + || !skel->joints) + return 0; + + vm2=NULL; + + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + { + if (i == xyzr->jointNum) + { + vm2=(void*)jt->bps; + break; + } + } + + if (vm2==NULL) + return(0); + + // find matrix for this block +// vm2=(void*)osr->bindMats; +// vm2+=xyzr->jointNum; + + poly = (void*)(((uns8*)rdc->polys) + xyzr->off); + for(i=0;*((int*)poly->v[0].vrt)!=FLOAT_NAN;poly++,i++) + { + // + // vert weighting & transform + // + + vrt=poly->v[0].vrt; + VMVecMul(vt0,vrt,vm2->a); + + vrt=poly->v[1].vrt; + VMVecMul(vt1,vrt,vm2->a); + + vrt=poly->v[2].vrt; + VMVecMul(vt2,vrt,vm2->a); + + // + // normal & plane k + // + + V3Sub(vta,vt0,vt1); + V3Sub(vtb,vt1,vt2); + V3Cross(nrm,vta,vtb); + V3UnitizeFast(nrm,1); + + // compute intersection with plane + b=V3Dot(nrm,cola->dir); // plane constant + if((b-COLEPSILON)) + continue; // orthogonal + d=V3Dot(nrm,vt0); // plane constant + len=(d-V3Dot(nrm,cola->pos))/b; + if((len<0) || (len>cola->len)) + continue; // behind or too far + + // intersection point of ray and plane + vta[0]=len*cola->dir[0]; + vta[0]+=cola->pos[0]; + vta[1]=len*cola->dir[1]; + vta[1]+=cola->pos[1]; + vta[2]=len*cola->dir[2]; + vta[2]+=cola->pos[2]; + + // + // find & test against edge's normal + // + + // edge + V3Sub(vtb,vt0,vt1); + V3Cross(nre,vtb,nrm); + V3Sub(vtb,vt0,vta); // ray -- colpoint to vert + if((b=V3Dot(vtb,nre))>0) + goto outside; + + // edge + V3Sub(vtb,vt1,vt2); + V3Cross(nre,vtb,nrm); + V3Sub(vtb,vt1,vta); // ray -- colpoint to vert + if((b=V3Dot(vtb,nre))>0) + goto outside; + + // edge + V3Sub(vtb,vt2,vt0); + V3Cross(nre,vtb,nrm); + V3Sub(vtb,vt2,vta); // ray -- colpoint to vert + if(V3Dot(vtb,nre)<=0) + goto inside; + +outside:; + if(0) + { +inside: + // collision -- check if it's first or better + if(!cola->clen || (cola->clen>len)) + { + cola->clen=len; + cola->flags&=~M_OBJCOLACT_HITFLAGS; + cola->flags|=M_OBJCOLACT_HIT|M_OBJCOLACT_HITSKELCOL; + cola->cpos[0]=vta[0]; + cola->cpos[1]=vta[1]; + cola->cpos[2]=vta[2]; + cola->cnrm[0]=nrm[0]; + cola->cnrm[1]=nrm[1]; + cola->cnrm[2]=nrm[2]; + cola->cdata=xyzr->colName; + cola->cnum=xyzr->colNum; + cola->cjointnum=xyzr->jointNum; + V3Cpy(cola->cjointoff,vta); + } // setcol + } // inside + } // for + +//DONE("objColJoint") + return 0; +} // objColJoint + +#if DEBUG +// JFL 19 Jul 05 +int DbgObjJointNames(void *odr) +{ + int ec,i; + ResDataJoint *jt; + ResDataSkel *skel; + ObjSkelRes *osr; + Res *r; + Obj *o2; + + // scan kids for skel + osr=NUL; + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_SKELRES) + { // skel + + // create/animate the mats + osr=(void*)o2; + break; + } // skel + } // for + + if(!osr) + err(-2); + + if(!(r=osr->res) || (RESSUB_SKEL!=r->lnk.sub) || !(skel=r->data) + || !skel->joints) + err(-3); + + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + SysLog("%s\n",jt->name); + + ec=0; +BAIL: + return ec; +} // DbgObjJointNames() +#endif // DEBUG + +// JFL 19 Jul 05 +int ObjJointMirror(void *odr,ObjJointMirrorRec *ojm, + int showonleft,int *np,crd *off) +{ + int ec,i,jointnum; + ResDataJoint *jt; + ResDataSkel *skel; + ObjSkelRes *osr; + Res *r; + Obj *o2; + ResDataCol *rdc; + ResDataCBXYZR *xyzr; + ObjColAct colmem,*cola; + crd vm[3]; + crd m33[M3_SIZE]; + + // skip to ojm + i=*np; + while(i>0) + { + if(!ojm->jname1) + err(-1); + ojm++; + i--; + } // while + + // scan kids for skel + osr=NUL; + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_SKELRES) + { // skel + + // create/animate the mats + osr=(void*)o2; + break; + } // skel + } // for + + if(!osr) + err(-2); + + if(!(r=osr->res) || (RESSUB_SKEL!=r->lnk.sub) || !(skel=r->data) + || !skel->joints) + err(-3); + + #if 0 // dump skel joint names + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + { + SysLog("%s\n",jt->name); + } + #endif // dump skel joint names + + // find original joint + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + { + if(!szcmp(jt->name,ojm->jname1)) + goto gotjoint; + } // for + err(-4); +gotjoint: + + if(!ojm->jname2 // no mirroring joint + ||(showonleft&&(ojm->flags&M_OBJJOINTMIRROR_ISLEFT)) + ||(!showonleft&&!(ojm->flags&M_OBJJOINTMIRROR_ISLEFT))) + goto gotflip; + + // find joint to mirror + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + { + if(!szcmp(jt->name,ojm->jname2)) + goto gotflip; + } // for + err(-5); +gotflip: + jointnum=i; + + // get res data for collision + rdc=NULL; + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_COLRES) + { // skel + + // find res data + + if(!(r=((ObjColRes*)o2)->res)||!(rdc=r->data)) + break; + if(rdc->type!=RESDATACOLTYPE_SKEL) + rdc=NUL; + break; + } // skel + } // for + + if(!rdc) + err(-6); + + // got xyzr + MEMZ(colmem); + cola=&colmem; + + if (!showonleft) + { + //rotate the vector 90 around Y + M3BuildRot(m33,PI,XYZ_Y); + M3VecMul(vm,m33,ojm->dir); + + cola->dir[0]=vm[0]; + cola->dir[1]=vm[1]; + cola->dir[2]=vm[2]; + } + else + { + cola->dir[0]=ojm->dir[0]; + cola->dir[1]=ojm->dir[1]; + cola->dir[2]=ojm->dir[2]; + } + +// cola->dir[0]=0; +// cola->dir[1]=0; +// cola->dir[2]=showonleft?ojm->dir:-ojm->dir; + +// cola->pos[0]=off[0]; +// cola->pos[1]=off[1]; + cola->pos[0]=off[0]-cola->dir[0]*(OBJJOINTCOL_LEN>>1); + cola->pos[1]=off[1]-cola->dir[1]*(OBJJOINTCOL_LEN>>1); + cola->pos[2]=off[2]-cola->dir[2]*(OBJJOINTCOL_LEN>>1); + + cola->len=OBJJOINTCOL_LEN; + + // run through all the blocks (these are geo sets) + for(xyzr=rdc->blocks;xyzr->blk.type;xyzr++) + { + // collide against any collision geometry for the numbered joint + if(xyzr->jointNum==jointnum) + objColJoint(rdc,osr,xyzr,cola); + } // for + + if(cola->flags&M_OBJCOLACT_HIT) + { + *np=jointnum; + off[0]=cola->cpos[0]; + off[1]=cola->cpos[1]; + off[2]=cola->cpos[2]; + } // hit + + ec=0; +BAIL: + return ec; +} // ObjJointMirror() + +// JFL 27 Jul 05 +int ObjJointLR(void *odr,ObjJointMirrorRec *ojm,int n,crd *off) +{ + int ec,i; + ResDataJoint *jt; + ResDataSkel *skel; + ObjSkelRes *osr; + Res *r; + Obj *o2; + + // skip to ojm + i=n; + while(i>0) + { + if(!ojm->jname1) + err(-1); + ojm++; + i--; + } // while + + // scan kids for skel + osr=NUL; + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_SKELRES) + { // skel + + // create/animate the mats + osr=(void*)o2; + break; + } // skel + } // for + + if(!osr) + err(-2); + + if(!(r=osr->res) || (RESSUB_SKEL!=r->lnk.sub) || !(skel=r->data) + || !skel->joints) + err(-3); + + // find original joint + for(i=0,jt=skel->joints;inumJoints;i++,jt++) + { + if(!szcmp(jt->name,ojm->jname1)) + goto gotjoint; + } // for + err(-4); +gotjoint: + + ec=0; // right by default + if(!ojm->jname2) + { + // means this joint does not have a mirroring joint + if(ojm->dir[2]<0) + { + if(off[2]>=0) + ec=1; // left + } + else + { + if(off[2]<0) + ec=1; // left + } + } + else + { + if(ojm->flags&M_OBJJOINTMIRROR_ISLEFT) + ec=1; // left + } + +BAIL: + return ec; +} // ObjJointLR() + +// get type string from object +// JFL 02 Aug 05 +char *ObjColTypeStr(void *objv,char **s2p) +{ + Res *r; + ResDataCol *rdc; + char *s1,*s2; + + if(objv + &&(((Obj*)objv)->lnk.sub==OBJSUB_COLRES) + &&(r=((ObjColRes*)objv)->res) + &&(rdc=r->data) + &&(s1=rdc->atBuf)) + { + if(!(s1=szmid("type",s1))) + goto BAIL; + if(!(s1=szchr(s1,NUL,'('))) + goto BAIL; + s1++; + if(s2p) + { + if((s2=szchr(s1,NUL,')'))) + *s2p=s2; + else + {*s2p=s1;BP(BP_OBJCOLTYPESTR);} // error + } + return s1; + } + +BAIL: + return NUL; +} // ObjColTypeStr() + +// get type string from object +// JFL 03 Aug 05 +char *ObjNameStr(void *objv,char **s2p) +{ + Res *r=NUL; + char *s1; + + if(!objv) + goto BAIL; + + switch( ((Obj*)objv)->lnk.sub) + { + case OBJSUB_COLRES: + r=((ObjColRes*)objv)->res; + break; + case OBJSUB_DISPRES: + r=((ObjDispRes*)objv)->res; + break; + } // switch + + if(r) + { + s1=r->name; + if(s2p) + *s2p=NUL; + return s1; + } +BAIL: + return NUL; +} // ObjNameStr() + +// JFL 10 Aug 05 +int ObjAniGetFrame(void *o,float *f1p,uns flags) +{ + int ec; + ObjAniRes *oar; + ObjSkelRes *osr; + N2 *k,*best; + + // + // if oar is passed in, use it + // else search for first skel node + // else use first oar found + // + + oar=NUL; + best=NUL; + if(((Obj*)o)->lnk.sub==OBJSUB_ANIRES) + { + oar=o; + goto gotoar; + } + + if(!(k=N2KIDLIST(o)->next) || !k->type) + err(-3); + if(flags&M_OBJANIGET_BODY) + { + for(;k->type;k=k->next) + { + if(k->sub!=OBJSUB_ANIRES) + continue; + if(!best) + best=k; + oar=(void*)k; + if(oar->flags&M_OBJANIRES_SKEL) + goto gotoar; + } // for + } // body + else if(flags&M_OBJANIGET_ROOT) + { + // find skel + for(;k->type;k=k->next) + { + if(k->sub==OBJSUB_SKELRES) + { + osr=(void*)k; + goto gotskel; + } + if(k->sub!=OBJSUB_ANIRES) + continue; + if(!best) + best=k; + } // for + + // couldn't find skel, use first oar, or err + if((oar=(void*)best)) + goto gotoar; + err(-4); + +gotskel: + // find oar for skel + k=N2KIDLIST(o)->next; + for(;k->type;k=k->next) + { + if((osr->rootDriver==k) && (k->sub==OBJSUB_ANIRES)) + { + oar=(void*)k; + goto gotoar; + } + } // for + + } // root + + if((oar=(void*)best)) + goto gotoar; + err(-1); +gotoar: + + // + // + // + + if(f1p) + { + *f1p=oar->fcLoopCount; + *f1p/=RES_FRAME_TIME; + } + + ec=0; +BAIL: + return ec; +} // ObjAniGetFrame() + +// JFL 11 Aug 05 +char* ObjAniGetName(void *o,uns flags) +{ + int ec; + ObjAniRes *oar; + ObjSkelRes *osr; + N2 *k,*best; + char *s1=NUL; + + // + // if oar is passed in, use it + // else search for first skel node + // else use first oar found + // + + oar=NUL; + best=NUL; + if(((Obj*)o)->lnk.sub==OBJSUB_ANIRES) + { + oar=o; + goto gotoar; + } + + if(!(k=N2KIDLIST(o)->next) || !k->type) + err(-3); + if(flags&M_OBJANIGET_BODY) + { + for(;k->type;k=k->next) + { + if(k->sub!=OBJSUB_ANIRES) + continue; + if(!best) + best=k; + oar=(void*)k; + if(oar->flags&M_OBJANIRES_SKEL) + goto gotoargroup; + } // for + } // body + else if(flags&M_OBJANIGET_ROOT) + { + // find skel + for(;k->type;k=k->next) + { + if(k->sub==OBJSUB_SKELRES) + { + osr=(void*)k; + goto gotskel; + } + if(k->sub!=OBJSUB_ANIRES) + continue; + if(!best) + best=k; + } // for + + // couldn't find skel, use first oar, or err + if((oar=(void*)best)) + goto gotoar; + err(-4); + +gotskel: + // find oar for skel + k=N2KIDLIST(o)->next; + for(;k->type;k=k->next) + { + if((osr->rootDriver==k) && (k->sub==OBJSUB_ANIRES)) + { + oar=(void*)k; + goto gotoar; + } + } // for + + } // root + + if((oar=(void*)best)) + goto gotoar; + err(-1); + +gotoar: + + k=oar->res; + goto gotres; + +gotoargroup: + + // + // + // + + // find the parent (which is the group that contains resDataKan) + for(k=oar->res;k->type && k!=(void*)oar;k=k->next) + ; /* find list head */ + k=N2PARENT(k); + +gotres: + if(k->type==N2TYPE_RES) + s1=((Res*)k)->name; + else + s1=NUL; + +BAIL: + return s1; +} // ObjAniGetName() + +// EOF diff --git a/dond/core/obj.h b/dond/core/obj.h new file mode 100755 index 0000000..ed49fd5 --- /dev/null +++ b/dond/core/obj.h @@ -0,0 +1,774 @@ +#ifndef OBJ_H +#define OBJ_H +// obj.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 08 Oct 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +// see ADDING NEW OBJ TYPES + +enum { + // must match resObjSubTable[], resObjSubSizes[] + OBJSUB_NONE, + OBJSUB_FRAMESTART, + OBJSUB_FORCEFRAMEEND, + OBJSUB_CAM, + OBJSUB_STR, + OBJSUB_TEXT, + OBJSUB_FUNC, + OBJSUB_DISPRES, + OBJSUB_IMGRES, + OBJSUB_VIDRES, + OBJSUB_STARTSORTBUF, + OBJSUB_DRAWSORTBUF, + OBJSUB_ANIRES, + OBJSUB_COLDEF, + OBJSUB_SKELRES, + OBJSUB_COLRES, + OBJSUB_BUF, + OBJSUB_SEQRES, + OBJSUB_LIGHTRES, // 0x10 + OBJSUB_MARKER, + OBJSUB_VEL, + OBJSUB_COLACT, + OBJSUB_GROUP, + OBJSUB_DISPSAVE, + OBJSUB_DRAWSHADOWS, + OBJSUB_UNKNOWN, + OBJSUB_EMIT, + OBJSUB_PARTICLES, + OBJSUB_LOD, + OBJSUB_MAX + // must match resObjSubTable[], resObjSubSizes[] +}; + +#define OBJSUB_TMPLINK OBJSUB_UNKNOWN + +enum { + OBJL2_PROJECTILE, // collision + OBJL2_BOUNCER, // collision + OBJL2_EMIT, // emitter + OBJL2_PARTICLES, // update & draw particles + OBJL2_NUM +}; +#define M_OBJL2 0xff +#define OBJL2_FIRST_COLLISION OBJL2_PROJECTILE +#define OBJL2_LAST_COLLISION OBJL2_BOUNCER + +// careful about using M_N2 fields +#if M_N2_TYPE != 0x0f00 +#error -- type uses 4 bits of flags + these are flags the type can share with the N2 structure + o->lnk.flags + you must be careful when using these flags to only use those + flags set in the M_N2_TYPE define + search on M_N2 to find all uses +#endif // M_N2_TYPE + +#define OBJ_LIST_DEPTH 4 + +#define M_N2OBJ_RESOLVED 0x0100 // shared using M_N2_TYPE +#define M_N2OBJ_PUSHPOPMAT 0x0400 // shared using M_N2_TYPE + +typedef struct { + N2 lnk; +} Obj; + +typedef struct { + N2 lnk; + char name[PM_SHORTNAME_SIZE]; +} ObjGroup; + +#define M_OBJFRAMESTART_CLEAR 0x01 +#define M_OBJFRAMESTART_DONTEND 0x02 +typedef struct { + N2 lnk; + uns16 flags; + uns8 r,g,b,a; + float depth; +} ObjFrameStart; + +typedef struct { + N2 lnk; + uns16 sortNum; + uns16 xx1; + uns32 sortBufSize; + uns32 sortBufLow; + uns32 sortBufHigh; + uns8 *sortBufStart; + void *sortBufSave; +} ObjStartSortBuf; + +#define M_OBJCAM_OFFSPLINE 0x0001 +#define M_OBJCAM_ORTHO 0x0002 +#define M_OBJCAM_NOZ 0x0004 +#define M_OBJCAM_ADDED 0x0008 +#define M_OBJCAM_SIMPLE 0x0010 +#define M_OBJCAM_CLEARZ 0x0020 +#define M_OBJCAM_GHOSTCAM 0x0040 +#define M_OBJCAM_GHOSTSAVED 0x0080 +#define M_OBJCAM_USEVM 0x0100 +#define M_OBJCAM_DONTFRUST 0x0200 +#define M_OBJCAM_FRUSTVALID 0x0400 + +typedef struct { + N2 lnk; + void *res; // if based on res + char name[PM_SHORTNAME_SIZE]; + + // set by user + uns16 flags; + uns16 xx2; + + float fov; + float orthoWidth; + float orthoHeight; + float clipNear; + float clipFar; + + crd rot[3]; + crd trans[3]; + crd vm[VM_SIZE]; + crd shake[3]; + + crd vertFrust[3*FRUSTVERT_NUM]; + crd nrmkFrust[4*CLIP_NUM]; // nrmk +} ObjCam; + +#define M_OBJSTR_HASALPHA 0x01 +typedef struct { + N2 lnk; + char name[PM_SHORTNAME_SIZE]; + uns8 flags; + uns8 xx1; + uns16 xx2; + uns32 texGen; + float user[4]; + float xyadj[2]; + float wh[2]; // width & height of string in camera coords + float scale[2]; + uns16 numc; + uns16 maxc; + // followed by ObjStrChar +} ObjStr; + +typedef struct { + uns32 rgb; + float user[2]; + float xyadj[2]; + float uvbox[BOX_SIZE]; // top left right bottom + float verts[3*2]; // x0,y0,z0 .. x1,y1,z1 (topleft bottomright) +} ObjStrChar; + +#define M_OBJLIGHTRES_SHADPOS 0x0001 +#define M_OBJLIGHTRES_NOLIGHT 0x0002 +#define M_OBJLIGHTRES_SHADDIR 0x0004 + +typedef struct { + N2 lnk; + void *res; // if based on res + uns flags; +} ObjLightRes; + +typedef struct { + N2 lnk; + char name[PM_SHORTNAME_SIZE]; + char *str; + int16 box[4]; + uns16 flags; + uns16 n; + uns16 size; +} ObjText; + +typedef struct { + N2 lnk; + char name[PM_SHORTNAME_SIZE]; + void *func; // pointer to function + uns8 ftype; // type of function -- see pm.h ftype + uns8 k; + uns16 n; + void *d; +} ObjFunc; + +#define M_OBJDISPRES_MIPMAP 0x00001 +#define M_OBJDISPRES_DONTLIGHT 0x00002 // dont light +#define M_OBJDISPRES_DISPCOL 0x00004 // collide against display geometry +#define M_OBJDISPRES_SKELCOL 0x00008 // collide against skelcol geometry +#define M_OBJDISPRES_PROPCOL 0x00010 // collide against propcol geometry +#define M_OBJDISPRES_NOAUTOANI 0x00020 // dont automatically attach anim +#define M_OBJDISPRES_NOAUTOCOL 0x00040 // dont automatically attach col +#define M_OBJDISPRES_LIGHT 0x00080 // light normals & flag set by artist +#define M_OBJDISPRES_FLASHRGB 0x00100 // flash solid color +#define M_OBJDISPRES_FLASHNOLIGHT 0x00200 // flash w/o light +#define M_OBJDISPRES_SAVE 0x00400 // save disp info +#define M_OBJDISPRES_HASTMPLINK 0x00800 // has ObjTmpLink imm following +#define M_OBJDISPRES_AFTERSHADOWS 0x01000 // draw this after the shadows +#define M_OBJDISPRES_FRUSTOUT 0x02000 // outside of camera frustrum +#define M_OBJDISPRES_BLEND 0x04000 // use alpha in rgba +#define M_OBJDISPRES_NOFOG 0x08000 // dont fog +#define M_OBJDISPRES_SORTEDONCE 0x10000 // "sort once" object has been sorted +#define M_OBJDISPRES_HASLOD 0x20000 // has LODs +#define M_OBJDISPRES_ZALWAYS 0x40000 // set Z buffer to always draw (currenty limited to Draw2 attached to Draw3) + +typedef struct { + N2 lnk; + void *res; + uns32 flags; + uns8 tag; + uns8 rgba[4]; + uns8 curBlend; + uns32 dList; // display list index +} ObjDispRes; + +typedef struct { + N2 tmpLnk; // not a permanent link -- changes every frame, not initialized + void *data; +} ObjTmpLink; + +#define M_OBJDISPSAVE_SET 0x0001 // stuffed with valid data +#define M_OBJDISPSAVE_BIND 0x0002 // concatenate bind matrix +#define M_OBJDISPSAVE_SINGLE 0x0004 // single mat + +typedef struct { + N2 lnk; + + // used to save info about draw state + // currently only used for saving skeleton joint matrices + // but can be expanded to save any info about the draw + + uns16 flags; + uns16 numJoints; + float *bindMats; + float *jointMats; + +} ObjDispSave; + +typedef struct { + N2 lnk; + void *res; +} ObjImgRes; + +typedef struct { + N2 lnk; + void *res; +} ObjVidRes; + +#define M_OBJANIRES_LOOP 0x00000001 +#define M_OBJANIRES_DONTLOOP 0x00000002 +#define M_OBJANIRES_FREEZENEXT 0x00000004 +#define M_OBJANIRES_FROZEN 0x00000008 +#define M_OBJANIRES_DONE 0x00000010 +#define M_OBJANIRES_ENDKILL 0x00000020 +#define M_OBJANIRES_KILLPRIME 0x00000040 // kill prime obj (parent) on exit +#define M_OBJANIRES_ROOT 0x00000080 +#define M_OBJANIRES_SKEL 0x00000100 +#define M_OBJANIRES_GCOL 0x00000200 +#define M_OBJANIRES_NOSCALE 0x00000800 +#define M_OBJANIRES_NOPITCH 0x00001000 +#define M_OBJANIRES_SNAPONCE 0x00002000 +#define M_OBJANIRES_BLENDONCE 0x00004000 +#define M_OBJANIRES_SYNC 0x00008000 +#define M_OBJANIRES_BRIDGE 0x00010000 +#define M_OBJANIRES_MOVED 0x00020000 // not a user flag +#define M_OBJANIRES_BLEND2ADD 0x00040000 // not a user flag +#define M_OBJANIRES_CHANGE 0x00080000 // not a user flag +#define M_OBJANIRES_HITEND 0x00100000 // anim looped, cleared when changing +#define M_OBJANIRES_FROZENTIME 0x00200000 +#define M_OBJANIRES_SKIPTO 0x00400000 +#define M_OBJANIRES_BLENDING 0x00800000 +#define M_OBJANIRES_BLEND2 0x01000000 +#define M_OBJANIRES_SLEEPCB 0x02000000 +#define M_OBJANIRES_JUMP 0x04000000 + +enum { + OAR_CH_RX, // assumed 1st for now + OAR_CH_RY, + OAR_CH_RZ, + OAR_CH_TX, + OAR_CH_TY, + OAR_CH_TZ, + OAR_CH_SX, + OAR_CH_SY, + OAR_CH_SZ, + OAR_CH_N +}; + +#define M_OAR_CH_R ((1<target + ERR_HOST_LAST=-9999, + ERR_HOST_TIMEOUT, + ERR_HOST_FIRST=-9900, + + ERR_PARSE_SYNTAX=-10999, + ERR_PARSE_INCOMPLETE, + ERR_PARSE_SETUP, + ERR_PARSE_RANGE, + ERR_PARSE_FAIL, + ERR_PARSE_STOP, + ERR_PARSE_EOF, + + ERR_PROC_STACKOVERFLOW=-11999, + ERR_PROC_NOTHANDLED, + ERR_PROC_SYNTAX, + +}; // ERR_ + + +enum { + BP_UNASSIGNED=1000, + BP_FTPBUFGET, + BP_FTPLIST, + BP_FTPRVCTL, + BP_FTPRVCTL2, + BP_FTPNETBUFFUNC1, + BP_FTPNETBUFFUNC2, + BP_FTPNETBUFFUNC3, + BP_FTPNETBUFFUNC4, + BP_FTPLOOP1, + BP_FTPLOOP2, + BP_FTPLOOP3, + BP_MAIN, + BP_MEMDSETUP, + BP_MEMDPOOLFIRSTNODE, + BP_MEMDPOOLFIRSTNODE2, + BP_RESLINK, + BP_FBSETMODE, + BP_FSINIT1, + BP_FSINIT2, + BP_NETRESET1, + BP_NETRESET2, + BP_NETPORTINFO, + BP_IMGLOAD1, + BP_IMGLOAD2, + BP_XRESLOADDISP, + BP_XRESLOADIMG, + BP_VIDINIT, + BP_AUDGAMENUMPL, + BP_GAMEGETPL, + BP_REPORTCALCSCORE, //1030 + BP_CABINIT, + BP_CABGETPL, + BP_CABGETGUN, + BP_CABOP, + BP_CABLOOP, + BP_FSOP, + BP_FSOP2, + BP_FTPRVCTL3, + BP_GUNSETXY, + BP_GUNOP1, + BP_GUNOP2, + BP_GUNOP3, + BP_INPJAMMACALLBACK, + BP_MEMSTACKRESTORE, + BP_MEMSTACKSAVE, + BP_OBJNEW, + BP_OBJANIBODY, + BP_OBJANIROOT, + BP_OBJLOOPEND1, + BP_OBJLOOPEND2, + BP_OBJCOLTYPESTR, + BP_ANICHANGE, + BP_SEQCALLBACK, + BP_ADDLIGHT, + BP_ADDLIGHT2, + BP_OBJLOOP, + BP_OBJLOOP2, + BP_PROCLOOP, + BP_RESINIT1, + BP_RESINIT2, + BP_RESINIT3, + BP_RESINIT4, + BP_RESNEW, + BP_RESREAD, + BP_RESREAD2, + BP_RESPTOK, + BP_RESPARSEVARADR, + BP_RESPDEER, + BP_RESPBAN, + BP_RESPBAN2, + BP_RESPBAN3, + BP_RESPRAN, + BP_RESSETCAT, + BP_RESSETCAT2, + BP_RESSETCAT3, + BP_RESSETCAT4, + BP_RESSETCAT5, + BP_RESPKILL, + BP_RESPSEQ, + BP_RESPSEQ2, + BP_RESPBIN, + BP_RESPCREATE, + BP_RESPCREATE2, + BP_RESPCREATE3, + BP_RESPCREATE4, + BP_RESPCREATE5, + BP_RESPCREATE6, + BP_RESPCREATE7, + BP_RESPCREATE8, + BP_RESPCREATE9, + BP_RESPBR, + BP_RESPBR2, + BP_RESPFIND, + BP_RESPFIND2, + BP_RESPFIND3, + BP_RESPFIND4, + BP_RESPFIND5, + BP_RESPFIND6, + BP_RESPFIND7, + BP_RESPFIND8, + BP_RESPFIND9, + BP_RESPFIND10, + BP_RESPFIND11, + BP_RESPFLAG, + BP_RESPOBJ, + BP_RESPOBJ2, + BP_RESPOBJ3, + BP_RESPOBJ4, + BP_RESPOBJ5, + BP_RESPOBJ6, + BP_RESPOBJ7, + BP_RESPOBJ8, + BP_RESPOBJ9, + BP_RESPOBJ10, + BP_RESPMEM, + BP_RESPLIGHT, + BP_RESPLIGHT2, + BP_RESPLIGHT3, + BP_RESPARSEONE, + BP_RESPARSEONE2, + BP_SZTO, + BP_N2LINKAFTER, + BP_N2LINKBEFORE, + BP_N2NAME, + BP_N2SCAN, + BP_INTDEVICEENABLE, + BP_INTDEVICEENABLE2, + BP_INTDEVICEENABLE3, + BP_INTDETACH, + BP_MAIN2, //1130 + BP_PROPCOL, + BP_DRAWPOS, + BP_DRAWPOS2, + BP_DRAWPOS3, + BP_DRAWPOS4, + BP_DRAWPOS5, + BP_DISPDRAW2, + BP_COLDISP3, + BP_SKELCOL, + BP_DRAWSKELCOLDISPDBG, + BP_DISPDRAW3, + BP_DISPDRAW4SKELDBG, + BP_DISPDRAW4SKELDBG2, + BP_DISPDRAW4SKELDBG3, + BP_DISPDRAW4SKELDBG4, + BP_DISPDRAW4SKEL, + BP_DISPDRAW4SKEL2, + BP_DISPDRAW4SKEL3, + BP_DISPDRAW4SKEL4, + BP_DRAWINITSORTONCE, + BP_DRAWACCOUNTDISP2SORTONCE, + BP_DRAWALLOCATESORTONCE, + BP_DRAWADDDISP2SORTONCE, + BP_DRAWADDDISP2SORTONCE2, + BP_DRAWADDDISP2SORTONCE3, + BP_OBJANICHANGE, + BP_OBJANIKAN, + BP_SEQCALLBACK2, + BP_SEQFWD, + BP_ADDLIGHT3, + BP_ADDLIGHT4, + BP_ADDLIGHT5, + BP_OBJONCE, + BP_OBJLOOP3, + BP_OBJLOOP4, + BP_OBJLOOP5, + BP_OBJLOOP6, + BP_OBJLOOP7, + BP_OBJLOOP8, + BP_IMGLOAD3, + BP_IMGLOAD4, + BP_IMGLOAD5, + BP_VIDSTART, + BP_JPSAPPHOOKMSG, + BP_ATSETUPDEMO, + BP_ATSETUPDEMO2, + BP_ATSETUPDEMO3, + BP_ATSETUPDEMO4, + BP_ATSETUPDEMO5, + BP_AUDSETCREDITS, //1180 + BP_FCCREATEBOAR, + BP_BOARKILLSECONDARIES, + BP_FCINITCRIT, + BP_FCCRITFALLSTART, + BP_FCCRITDIEANIM, + BP_DEERCOLSKEL, + BP_DEERSETFLAG, + BP_DEERCLRFLAG, + BP_DEERFREEZESPLINE, + BP_DEERFREEZESPLINE2, + BP_DEERFREEZESPLINE3, + BP_DEERUNFREEZESPLINE, + BP_DEERUNFREEZESPLINE2, + BP_DEERUNFREEZESPLINE3, + BP_DEERGETRUNSTART, + BP_DEERGETRUNSTART2, + BP_DEERGETRUNSTART3, + BP_DEERKILLSECONDARIES, + BP_DEERFALLSTART, + BP_FCINITDEER, + BP_FCINITREPLAYDEER, + BP_FCDEERDIEANIM, + BP_FCDEERDIEANIM2, + BP_FCDEERDIEANIM3, + BP_FCCREATEDOVE, + BP_FCCREATEDUCK, + BP_FINDDEERPRIMEOBJ, + BP_FINDDEERORCRITPRIMEOBJ, + BP_EDITADDNAME, + BP_EDITADDLIGHT, + BP_EDITRESPARSEONE, + BP_FCSETADV, + BP_FCSETADV2, + BP_FCSETADV3, + BP_FCSETADV4, + BP_FCSETADV5, + BP_FCKILLSECONDARIES, + BP_GAMEPROCCB, + BP_FCCREATEGEAR, + BP_MFREEZESPLINE, + BP_MFREEZESPLINE2, + BP_MFREEZESPLINE3, + BP_MFREEZESPLINEOBJ, + BP_MFREEZESPLINEOBJ2, + BP_MFREEZESPLINEOBJ3, + BP_PARTWEATHER, + BP_PARTWEATHER2, + BP_PARTWEATHER3, + BP_FCCREATEPHEASANT, + BP_PROJSHOTDATA, + BP_PROJSHOTDATA2, + BP_PROJSHOTDATA3, + BP_FCCREATEQUAIL, + BP_SHOTREPORTPROC, + BP_SHOTREPORTPROC2, + BP_SHOTREPORTPROC3, + BP_SHOTREPORT2PPROC, + BP_SHOTREPORT2PPROC2, + BP_SHOTREPORT2PPROC3, + BP_SELTIMERPROC, + BP_FCCREATEMUG, + BP_FCWINDCREATEBLADES, + BP_FCWINDSETCUR, + BP_AUDLOADALLDATA, +}; + +enum { // int16 + ERC_ALREADY_DEAD=9000, +}; // ERC_ + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION TYPES + +enum { + FTYPE_NONE, + FTYPE_1, + FTYPE_2, + FTYPE_3, + FTYPE_4, + FTYPE_5, + FTYPE_6, + FTYPE_7, +}; + +typedef void (ftype1)(void); +typedef int (ftype2)(void*); +typedef int (ftype3)(void*,void*); +typedef int (ftype4)(int,void*,void*,void*); +typedef int (ftype5)(int); +typedef int (ftype6)(int,void*); +typedef int (ftype7)(void*,int); + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +typedef struct { + void *next; +} N1; + +enum { + N2TYPE_NONE, + N2TYPE_UNK, // valid node, but not typed yet + N2TYPE_RES, // resource type + N2TYPE_OBJ, // object type + N2TYPE_PROC, // proc type + N2TYPE_MSG, // msg type + N2TYPE_L2, // l2 link + N2TYPE_MAX +}; +#define M_N2TYPE 0x1f // flags will be in the top + +enum { + N2SUB_NONE, + N2SUB_KID=0xf2, // can be used to verify that this is a kid (not needed) +}; + +// keep this whole section up to date in DC + +#define M_N2_KIDLIST 0x0001 // has kid list +#define M_N2_KIDFIRST 0x0002 // process kid list first +#define M_N2_SKIP 0x0004 // don't process this node or any kids +#define M_N2_DEAD 0x0008 // node is dead (unlinked, aborted) +#define M_N2_LEVEL0 0x0010 // 0,1,2,3 +#define M_N2_LEVEL1 0x0020 // 0,1,2,3 +#define M_N2_LEVEL 0x0030 // 0,1,2,3 +#define S_N2_LEVEL 4 +#define M_N2_STRONG 0x0080 // strong node (don't normally kill) +#define M_N2_TYPE 0x0f00 // type can use 4 bits +#define M_N2_OPEN 0x1000 // node is open (for debugging) +#define M_N2_L2LINKED 0x2000 // linked into L2 list + +typedef struct { + // order is assumed by compiled (res_pc.c) and loaded data + void *next; + void *prev; + uns8 type; // type + uns8 sub; // subtype info + uns16 flags; // top 8 bits of flags are reserved for type +} N2; + +#define N2KIDLIST(n) (((N2*)n)-1) +#define N2PARENT(n) (((N2*)n)+1) +#define N2L2(n) (((N2*)n)+1) // n2 to l2 +#define L2N2(n) (((N2*)n)-1) // l2 to n2 + +#define N2_DEPTH_MAX 8 +#define N2_DEPTH_DEFAULT 8 + +/////////////////////////////////////////////////////////////////////////////// +// + +enum { + MATORDER_XYZ, + MATORDER_ZYX +}; + +#define M_MATORDER_ROTS 0x0f +#define M_MATORDER_SCALEFIRST 0x10 +#define M_MATORDER_TRANSLATEFIRST 0x10 + +// VEC_ +enum { + VEC_X, + VEC_Y, + VEC_Z, + VEC_SIZE, +}; + +enum { + V3_X, + V3_Y, + V3_Z, + V3_SIZE, +}; + +enum { + XYZ_X, + XYZ_Y, + XYZ_Z, + XYZ_SIZE, +}; + +// PLANEQ_ +enum { + PLANEQ_NX, + PLANEQ_NY, + PLANEQ_NZ, + PLANEQ_D, + PLANEQ_SIZE, +}; + +// Q_ +enum { + Q_X, + Q_Y, + Q_Z, + Q_W, + Q_SIZE, +}; + +// M3_ +enum { + M3_11, + M3_21, + M3_31, + M3_12, + M3_22, + M3_32, + M3_13, + M3_23, + M3_33, + M3_SIZE +}; + +// VM_ +enum { + VM_X, + VM_Y, + VM_Z, + VM_11, + VM_21, + VM_31, + VM_12, + VM_22, + VM_32, + VM_13, + VM_23, + VM_33, + VM_SIZE +}; + +// VM_ +enum { + VM_TX, + VM_TY, + VM_TZ, + VM_RX, + VM_RY, + VM_RZ, + VM_SX, + VM_SY, + VM_SZ, +}; + +// M4_ +enum { + M4_11, + M4_21, + M4_31, + M4_41, + M4_12, + M4_22, + M4_32, + M4_42, + M4_13, + M4_23, + M4_33, + M4_43, + M4_14, // x + M4_24, // y + M4_34, // z + M4_44, + M4_SIZE +}; +#define M4_X M4_14 +#define M4_Y M4_24 +#define M4_Z M4_34 + +enum { + M4OGL_11, + M4OGL_21, + M4OGL_31, + M4OGL_41, + M4OGL_12, + M4OGL_22, + M4OGL_32, + M4OGL_42, + M4OGL_13, + M4OGL_23, + M4OGL_33, + M4OGL_43, + M4OGL_14, // x + M4OGL_24, // y + M4OGL_34, // z + M4OGL_44, + M4OGL_SIZE +}; + +#define M4OGL_X 12 +#define M4OGL_Y 13 +#define M4OGL_Z 14 + +// notes on boxes +// choose your own box style, but follow conventions +// x,y,w,h +// l,t,r,b +// l=x,t=y,r=l+w-1,b=y+h-1 + +enum { + BOX_LEFT, + BOX_TOP, + BOX_RIGHT, + BOX_BOTTOM, + BOX_SIZE +}; + +enum { + BOX_L, + BOX_T, + BOX_R, + BOX_B +}; + +enum { + BOX_X, + BOX_Y, + BOX_W, + BOX_H +}; + +enum { + CLIP_LEFT, + CLIP_TOP, + CLIP_RIGHT, + CLIP_BOTTOM, + CLIP_NEAR, // assumed to be after LTRB & before far + CLIP_FAR, + CLIP_NUM +}; + +#define FRUSTVERT_NUM 8 // numv for near & far plane + +#define BOX_WIDTH BOX_W +#define BOX_HEIGHT BOX_H + +enum { + BINBUF_SIZE, + BINBUF_NEXT, + BINBUF_FIRST, +}; + +#define BINBUFSET(f,i,v) {if((f)->binBuf&&((i+BINBUF_FIRST)<(int)(f)->binBuf[BINBUF_SIZE])) \ + (f)->binBuf[(i+BINBUF_FIRST)]=(memu)v;} + +/////////////////////////////////////////////////////////////////////////////// +// + +#define M_RESET_ALL 0x0000 +#define M_RESET_HARDWARE 0x0001 +#define M_RESET_MEMORY 0x0002 +#define M_RESET_REBUILD 0x0004 +#define M_RESET_LEVEL 0x0008 + +enum { + LEVEL_PERM, + LEVEL_WAVE, + LEVEL_SUBW, + LEVEL_GAME, + LEVEL_NUM +}; + +/////////////////////////////////////////////////////////////////////////////// +// + +extern void errlog(char *msg); + +#endif // ndef PM_H diff --git a/dond/core/proc.c b/dond/core/proc.c new file mode 100755 index 0000000..194bb08 --- /dev/null +++ b/dond/core/proc.c @@ -0,0 +1,373 @@ +// proc.c +// Play Mechanix - Video Game Proctem +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 19 Jan 05; from JoeCo's lightweight proc system +// JFL 08 Jul 05; callbacks added based on Paul's tapout idea + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "proc.h" +#include "str.h" + +#include + +typedef struct { + N2 activeList; + N2 deadList; + uns32 *gwt; + uns32 loop; +} procGlobals; + +procGlobals procG; + +typedef struct { + N2 lnk; + char name[16]; + uns state; + uns id; + uns time; + void *func; + void *killFunc; + ftype7 *cbFunc; + uns stackSize; + uns stackBegin; + uns stackUsed; + uns allocSize; + jmp_buf envSys; + jmp_buf envRun; + //char stackSave[]; +} procRec; + +#if SYS_BB +// see http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html +// asm ( "statements" : output_registers : input_registers : clobbered_registers); +#define GET_STACK(x) asm("mov %%esp,%0" :"=r"(x)) +#define GROW_STACK(x) asm("sub %0,%%esp"::"r"(x)) +#else // SYS_PC -- MSVC6.0 +#define GET_STACK(x) __asm {mov x,ESP} +#define GROW_STACK(x) __asm {sub ESP,x} +#endif + +// JFL 19 Jan 05 +int ProcInit(void) +{ + MEMZ(procG); + N2Head(&procG.activeList); + N2Head(&procG.deadList); + return 0; +} // ProcInit() + +// JFL 19 Jan 05 +void procFree(procRec *proc) +{ + N2Unlink(proc); + MemDFree(MEMPOOL_OBJ,proc); +} // procFree() + +// JFL 19 Jan 05 +void procFreeDead(void) +{ + procRec *proc; + int (*func)(void *pr); + + while((proc=procG.deadList.next) && proc->lnk.type) + { + if((func=proc->killFunc)) + (*func)(proc); + procFree(proc); + } // for +} // procFreeDead() + +// JFL 19 Jan 05 +void ProcFinal(void) +{ + procFreeDead(); +} // ProcFinal() + +// JFL 19 Jan 05 +int ProcReset(uns reset) +{ + return 0; +} // ProcReset() + +// JFL 19 Jan 05 +int ProcLoop(void) +{ + int ec; + procRec *proc,*pnext; + int (*func)(void *pr); + volatile uns stack; + uns8 dead=0; + + for(proc=procG.activeList.next;proc->lnk.type;proc=proc->lnk.next) + { +top: + if(proc->state & M_PROC_STATE_DEAD) + { + dead=1; + continue; + } + if(!(proc->state & M_PROC_STATE_RUN)) + continue; + if(!(func=proc->func)) + continue; + + if(procG.gwt && !(proc->state&M_PROC_STATE_SLOOP)) + { + if(*procG.gwttime) + { + if(proc->cbFunc && (proc->state&M_PROC_STATE_SLEEPCB)) + { + if((*proc->cbFunc)(proc,PROCCB_SLEEPING)<0) + goto sleepd; + } + continue; + } + } + else + { + if((int)proc->time>0) + { + proc->time--; + continue; + } + } +sleepd: + + GET_STACK(stack); + proc->stackBegin=stack; + + // flags + proc->state&=~M_PROC_STATE_SLEEPCB; + + ec=setjmp(proc->envSys); + // -- control returns here -- + + proc->state &= ~M_PROC_STATE_CURRENT; + SysG.curProc=NUL; + + if(!ec) + { + // direct call -- either start or continue proc + if(!(proc->state & M_PROC_STATE_RUNNING)) + { + // start proc + SysG.curProc=proc->name; + proc->state |= M_PROC_STATE_RUNNING|M_PROC_STATE_CURRENT; + (*func)(proc); + SysG.curProc=NUL; + proc->state &= ~(M_PROC_STATE_RUNNING|M_PROC_STATE_CURRENT); + + // kill procs if they return + dead=1; + proc->state|=M_PROC_STATE_DEAD; + } + else + { + // continue proc + stack = proc->stackUsed; + GROW_STACK(stack); + GET_STACK(stack); + MemCopy((char*)stack,&proc[1],proc->stackUsed); + SysG.curProc=proc->name; + proc->state |= M_PROC_STATE_CURRENT; + longjmp(proc->envRun,1); // jump back to routine + BP(BP_PROCLOOP); // never gets here + } + } // setjmp direct + else if(ec==2) + { + // handle a JUMP + proc->state &= ~M_PROC_STATE_RUNNING; + goto top; + } + + } // for + + // free dead + + if(dead) + { + for(proc=procG.activeList.next;proc->lnk.type;proc=pnext) + { + pnext=proc->lnk.next; + + if(!(proc->state & M_PROC_STATE_DEAD)) + continue; + if((func=proc->killFunc)) + { + (*func)(proc); + proc->killFunc=NUL; + } + + N2Unlink(proc); + N2LinkBefore(&procG.deadList,proc); + } // for + } + + if((proc=procG.deadList.next) && proc->lnk.type) + procFreeDead(); + + procG.loop++; + return 0; +} // ProcLoop() + +// JFL 19 Jan 05 +int ProcNew(void *procp,char *name,uns stackSize,uns allocSize,uns id,void *func) +{ + int ec; + uns len; + procRec *proc; + + len=sizeof(procRec)+stackSize+allocSize; + + // create an object node + if((ec=MemDAlloc(MEMPOOL_OBJ,len,&proc))<0) + goto BAIL; + MemZero(proc,sizeof(procRec)); + + proc->lnk.type=N2TYPE_PROC; + proc->lnk.sub=PROCSUB_LIGHT; + proc->func=func; + proc->id=id; + proc->stackSize=stackSize; + proc->allocSize=allocSize; + proc->state=M_PROC_STATE_RUN; + szncpy(proc->name,name,sizeof(proc->name)); + + N2LinkBefore(&procG.activeList,proc); + + if(procp) + *((void**)procp)=proc; + + ec=0; +BAIL: + return ec; +} // ProcNew() + +// JFL 29 Jan 04 +// JFL 19 Jan 05 +int ProcOp(void *vproc,int op,memu p) +{ + // keep this frame small, it's saved w/proc + int ec; + volatile memu stack; + procRec *proc=vproc; + memu *memubuf; + + // dispatch the op + switch(op) + { + case PROCOP_SLOOP: + // sloop(1) will wakeup next loop + // sloop(0) is not defined yet, but will wakeup next loop too + proc->time=(uns)p; + proc->state|=M_PROC_STATE_SLOOP; + goto sleeptimed; + + case PROCOP_SLEEPCB: + // set sleep cb func to run when sleeping + // this will be cleared every time the proc wakes up + proc->state|=M_PROC_STATE_SLEEPCB; + case PROCOP_SLEEP: + if(procG.gwt) + proc->time=*procG.gwt+(uns)p*PROC_FRAME_TIME; + else + proc->time=(uns)p*PROC_FRAME_TIME; + proc->state&=~M_PROC_STATE_SLOOP; + + if(proc->cbFunc && (proc->state&M_PROC_STATE_SLEEPCB)) + (*proc->cbFunc)(proc,PROCCB_SLEEPINIT); + +sleeptimed: + if(!setjmp(proc->envRun)) + { + // direct call -- going to sleep + GET_STACK(stack); + proc->stackUsed = proc->stackBegin - stack; + if(proc->stackUsed >= proc->stackSize) + berr(ERR_PROC_STACKOVERFLOW); // increase stack size on create + MemCopy(&proc[1],(char*)stack,proc->stackUsed); + longjmp(proc->envSys,1); // jump back to loop + + // should pop this frame off instead of saving it.. + + } // setjmp direct + break; + case PROCOP_JUMP: + proc->func=(void*)p; + longjmp(proc->envSys,2); // jump back to loop + break; + case PROCOP_KILL: + // kill proc + proc->state &= ~M_PROC_STATE_RUN; + proc->state |= M_PROC_STATE_DEAD; + break; + case PROCOP_SET_KILLFUNC: + proc->killFunc=(void*)p; + break; + case PROCOP_SET_CBFUNC: + proc->cbFunc=(void*)p; + break; + case PROCOP_SET_GAMEWAVETIMEPTR: + procG.gwt=(void*)p; + break; + case PROCOP_GET_ALLOCBUF: + if(proc->allocSize) + *((void**)p)=(((uns8*)&proc[1])+proc->stackSize); + else + *((void**)p)=NUL; + err(proc->allocSize); + case PROCOP_GET_NAMEBUF: + *((void**)p)=proc->name; + err(sizeof(proc->name)); + case PROCOP_GET_WAKETIME: + err(proc->time); + case PROCOP_RESET_SLEEPS: + for(proc=procG.activeList.next;proc->lnk.type;proc=proc->lnk.next) + { + if(!(proc->state&M_PROC_STATE_SLOOP)) + proc->time=0; + } // for + break; + case PROCOP_KILL_MASK_MATCH: + if(!(memubuf=(memu*)p)) + break; + for(proc=procG.activeList.next;proc->lnk.type;proc=proc->lnk.next) + { + if(((proc->id&memubuf[0])==memubuf[1]) + && !(proc->state&M_PROC_STATE_CURRENT)) + { + // kill proc + proc->state &= ~M_PROC_STATE_RUN; + proc->state |= M_PROC_STATE_DEAD; + } + } // for + break; // PROCOP_KILL_MASK_MATCH + case PROCOP_GET_ID: + err(proc->id); + case PROCOP_FINDID: + for(proc=procG.activeList.next;proc->lnk.type;proc=proc->lnk.next) + { + if(proc->id==(uns)p) + err(1); + } + break; // PROCOP_FINDID + default: + err(ERR_PROC_NOTHANDLED); + } // switch + + ec=0; +BAIL: + return ec; +} // ProcOp() + +// JFL 19 Jan 05 +void* ProcActiveFirst(void) +{ + return procG.activeList.next; +} // ProcActiveFirst() + +// EOF diff --git a/dond/core/proc.h b/dond/core/proc.h new file mode 100755 index 0000000..f359512 --- /dev/null +++ b/dond/core/proc.h @@ -0,0 +1,84 @@ +#ifndef PROC_H +#define PROC_H +// proc.h +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 19 Jan 05 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM SPECIFIC + +//----------------------------------------------------------------------------- +// SYS_JP5500 +#if SYS_JP5500 + +#define PROC_STACK_SIZE 512 + +#endif // SYS_JP5500 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// SYS_PC|SYS_BB +#if SYS_PC|SYS_BB + +#define PROC_STACK_SIZE 512 + +#endif // SYS_PC|SYS_BB +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +#define PROC_FRAME_TIME PM_FRAME_TIME // 16 milliseconds per frame == approx 60 frames-per-second + +enum { + PROCSUB_NONE, + PROCSUB_LIGHT, +}; + +#define M_PROC_STATE_RUN 0x00000100 // run +#define M_PROC_STATE_CURRENT 0x00100000 // proc is current proc (running & active) +#define M_PROC_STATE_DEAD 0x00200000 // proc is dead +#define M_PROC_STATE_RUNNING 0x00400000 // proc is running (maybe sliced out) +#define M_PROC_STATE_SLOOP 0x00800000 // proc is sleeping on loops +#define M_PROC_STATE_SLEEPCB 0x01000000 // run cb func when sleeping + +#define M_PROCID_DONTKILL 0x00010000 // perm proc + +extern int ProcInit(void); +extern void ProcFinal(void); +extern int ProcReset(uns reset); +extern int ProcLoop(void); +extern int ProcNew(void *procp,char *name,uns stackSize,uns allocSize,uns id,void *func); + +enum { + PROCOP_NONE, + PROCOP_SLEEP, // (uns)time + PROCOP_SLOOP, // (uns)time + PROCOP_KILL, // kills proc + PROCOP_SLEEPCB, // (uns)time + PROCOP_SET_FUNC, // (void*)func + PROCOP_SET_KILLFUNC, // (void*)func + PROCOP_SET_CBFUNC, // (void*)func -- int func(void*,int) + PROCOP_SET_GAMEWAVETIMEPTR, // (uns32*)&GameWaveTime + PROCOP_JUMP, // return code (for now) + PROCOP_GET_ALLOCBUF, // (void*)&buf -- returns size + PROCOP_GET_NAMEBUF, // (char*)&buf -- returns size + PROCOP_GET_WAKETIME, // returns wake time + PROCOP_RESET_SLEEPS, + PROCOP_KILL_MASK_MATCH, // &memubuf[2]; if((proc->id&mask)==match) kill + PROCOP_GET_ID, // returns id + PROCOP_FINDID, // returns if found +}; + +extern int ProcOp(void *proc,int op,memu p); +extern void* ProcActiveFirst(void); + +enum { + PROCCB_NONE, + PROCCB_SLEEPINIT, + PROCCB_SLEEPING, +}; +#define M_PROCCB 0xff + +#endif // ndef PROC_H diff --git a/dond/core/res.c b/dond/core/res.c new file mode 100755 index 0000000..ca5aa68 --- /dev/null +++ b/dond/core/res.c @@ -0,0 +1,7879 @@ +// res.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 08 Oct 04 + +#include "pm.h" +#include "mem.h" +#include "str.h" +#include "fs.h" +#include "res.h" +#include "obj.h" +#include "vec.h" +#include "vid.h" +#include "sys.h" +#include "game.h" +#include "proc.h" +#include "font.h" +#include "cab.h" +#include "msg.h" +#include "inp.h" +#include "snd.h" + +#include "theorafunc.h" + +#define C2(a,b) (int)((a<<8)|b) +#define C3(a,b,c) (int)((a<<16)|(b<<8)|c) + +enum { + RESFUNC_NONE, + RESFUNC_LOAD, +}; + +char *ResResSubTable[] = +{ + // must match RESSUB_ + "", // RESSUB_NONE, + "g", // RESSUB_GROUP, + "f1", // RESSUB_FUNC1, + "d1", // RESSUB_DISP1, + "d2", // RESSUB_DISP2, + "i1", // RESSUB_IMG1, + "cam", // RESSUB_CAM, + "kan", // RESSUB_KAN, + "sk", // RESSUB_SKEL, + "d3", // RESSUB_DISP3, + "p", // RESSUB_PARSE, + "seq", // RESSUB_SEQ, + "lit", // RESSUB_LIGHT, + "ft", // RESSUB_FTYPE, + "col", // RESSUB_COL, + "f2", // RESSUB_FUNC2, + "f3", // RESSUB_FUNC3, + "fnt", // RESSUB_FONT, + "d4", // RESSUB_DISP4, + "jmp", // RESSUB_JUMP, + "vid", + NUL, + // must match RESSUB_ +}; + +char *ResObjSubTable[] = { + // must match OBJSUB_ + "", // OBJSUB_NONE, + "fs", // OBJSUB_FRAMESTART, + "fe", // OBJSUB_FORCEFRAMEEND, + "cam", // OBJSUB_CAM3D, + "str", // OBJSUB_STR, + "txt", // OBJSUB_TEXT, + "func", // OBJSUB_FUNC, + "disp", // OBJSUB_DISPRES, + "img", // OBJSUB_IMGRES, + "vid", // OBJSUB_VIDRES, + "ssb", // OBJSUB_STARTSORTBUF, + "dsb", // OBJSUB_DRAWSORTBUF, + "ani", // OBJSUB_ANIRES, + "cold", // OBJSUB_COLDEF, + "sk", // OBJSUB_SKELRES, + "colr", // OBJSUB_COLRES, + "buf", // OBJSUB_BUF, + "seq", // OBJSUB_SEQRES, + "lit", // OBJSUB_LIGHTRES, + "mrk", // OBJSUB_MARKER, + "vel", // OBJSUB_VEL + "cola", // OBJSUB_COLACT + "grp", // OBJSUB_GROUP + "dsav", // OBJSUB_DISPSAVE + "dsh", // OBJSUB_DRAWSHADOWS + "unk", // OBJSUB_UNKNOWN + "emit", // OBJSUB_EMIT + "part", // OBJSUB_PARTICLES + "lod", // OBJSUB_LOD + NUL, + // must match OBJSUB_ +}; + +char *ResN2TypeTable[] = { + // must match N2TYPE_ + "", // N2TYPE_NONE, + "unk", // N2TYPE_UNK, // valid node, but not typed yet + "res", // N2TYPE_RES, // resource type + "obj", // N2TYPE_OBJ, // object type + "proc", // N2TYPE_PROC, // proc type + "msg", // N2TYPE_MSG, // msg type + "l2", // N2TYPE_L2, // l2 link + NUL, + // must match N2TYPE_ +}; + +int resObjCreateSizes[] = { + // must match OBJSUB_ + 0, // OBJSUB_NONE, + sizeof(ObjFrameStart), // OBJSUB_FRAMESTART, + sizeof(Obj), // OBJSUB_FORCEFRAMEEND, + sizeof(ObjCam), // OBJSUB_CAM3D, + sizeof(ObjStr), // OBJSUB_STR, + sizeof(ObjText), // OBJSUB_TEXT, + sizeof(ObjFunc), // OBJSUB_FUNC, + sizeof(ObjDispRes), // OBJSUB_DISPRES, + sizeof(ObjImgRes), // OBJSUB_IMGRES, + sizeof(ObjVidRes), // OBJSUB_VIDRES, + sizeof(ObjStartSortBuf), // OBJSUB_STARTSORTBUF, + sizeof(Obj), // OBJSUB_DRAWSORTBUF, + sizeof(ObjAniRes), // OBJSUB_ANIRES, + sizeof(ObjColDef), // OBJSUB_COLDEF, + sizeof(ObjSkelRes), // OBJSUB_SKELRES, + sizeof(ObjColRes), // OBJSUB_COLRES + sizeof(ObjBuf), // OBJSUB_BUF, + sizeof(ObjSeqRes), // OBJSUB_SEQRES, + sizeof(ObjLightRes)+sizeof(Res)+sizeof(ResDataLight), // OBJSUB_LIGHTRES, + sizeof(ObjMarker), // OBJSUB_MARKER, + sizeof(ObjVel), // OBJSUB_VEL, + sizeof(ObjColAct), // OBJSUB_COLACT, + sizeof(ObjGroup), // OBJSUB_GROUP, + sizeof(ObjDispSave), // OBJSUB_DISPSAVE, + sizeof(Obj), // OBJSUB_DRAWSHADOWS, + sizeof(Obj), // OBJSUB_UNKNOWN, // this size is unknown & this is probably wrong + sizeof(ObjEmit), // OBJSUB_EMIT, + sizeof(ObjParticles), // OBJSUB_PARTICLES, + sizeof(ObjLOD), // OBJSUB_LOD + // must match OBJSUB_ +}; + +char *respwords[] = { + "", + + // keywords + "geo", // RESPARSE_GEO + "gnd", // RESPARSE_GND + "loop", // RESPARSE_LOOP + "dontloop", // RESPARSE_DONTLOOP + "fog", // RESPARSE_FOG + "dc", // RESPARSE_DC + "help", // RESPARSE_HELP + "blend", // RESPARSE_BLEND + "min", // RESPARSE_MIN + "mag", // RESPARSE_MAG + "mip", // RESPARSE_MIP + "lights", // RESPARSE_LIGHTS + "light", // RESPARSE_LIGHT + "anis", // RESPARSE_ANIS + "q", // RESPARSE_Q + "disp", // RESPARSE_DISP + "cam", // RESPARSE_CAM + "grid", // RESPARSE_GRID + "joints", // RESPARSE_JOINTS + "pause", // RESPARSE_PAUSE + "step", // RESPARSE_STEP + "deer", // RESPARSE_DEER + "ban", // RESPARSE_BAN + "ran", // RESPARSE_RAN + "nul", // RESPARSE_NUL + "hold", // RESPARSE_HOLD + "run", // RESPARSE_RUN + "set", // RESPARSE_SET + "cat", // RESPARSE_CAT + "cfg", // RESPARSE_CFG + "flags", // RESPARSE_FLAGS + "kill", // RESPARSE_KILL + "seq", // RESPARSE_SEQ + "ani", // RESPARSE_ANI + "frame", // RESPARSE_FRAME + "alloc", // RESPARSE_ALLOC + "size", // RESPARSE_SIZE + "bin", // RESPARSE_BIN + "load", // RESPARSE_LOAD + "add", // RESPARSE_ADD + "wire", // RESPARSE_WIRE + "time", // RESPARSE_TIME + "wave", // RESPARSE_WAVE + "off", // RESPARSE_OFF + "if", // RESPARSE_IF + "level", // RESPARSE_LEVEL + "vers", // RESPARSE_VERS + "info", // RESPARSE_INFO + "log", // RESPARSE_LOG + "before", // RESPARSE_BEFORE + "cleanup", // RESPARSE_CLEANUP + "start", // RESPARSE_START + "print", // RESPARSE_PRINT + "fc", // RESPARSE_FC + "br", // RESPARSE_BR + "sleep", // RESPARSE_SLEEP + "sloop", // RESPARSE_SLOOP + "find", // RESPARSE_FIND + "signal", // RESPARSE_SIGNAL + "signals", // RESPARSE_SIGNALS + "return", // RESPARSE_RETURN + "swatch", // RESPARSE_SWATCH + "fail", // RESPARSE_FAIL + "flag", // RESPARSE_FLAG + "create", // RESPARSE_CREATE + "tag", // RESPARSE_TAG + "send", // RESPARSE_SEND + "obj", // RESPARSE_OBJ + "mark", // RESPARSE_MARK + "mem", // RESPARSE_MEM + "nop", // RESPARSE_NOP + "tool", // RESPARSE_TOOL + "keymacro", // RESPARSE_KEYMACRO + "dbg", // RESPARSE_DBG + "game", // RESPARSE_GAME + "sub", // RESPARSE_SUB + "elf", // RESPARSE_ELF + "col", // RESPARSE_COL + "str", // RESPARSE_STR + "sound", // RESPARSE_SOUND + "shad", // RESPARSE_SHAD + "sortbuf", // RESPARSE_SORTBUFSIZE + "dontcull", // RESPARSE_DONTCULL + "curs", // RESPARSE_CURS + "gunspeed", // RESPARSE_GUNSPEED + "op", // RESPARSE_OP + "mintri", // RESPARSE_MINTRI + "minquad", // RESPARSE_MINTRI + "findname", // RESPARSE_FINDNAME + "bozoret", // RESPARSE_BOZORET + "vsync", // RESPARSE_VSYNC + "vidplay", // RESPARSE_VIDPLAY + "vidstop", // RESPARSE_VIDSTOP + "vidready",// RESPARSE_VIDREADY + "viddone", // RESPARSE_VIDDONE + "vidalink",// RESPARSE_VIDALINK + + // tokens + "(", // RESPARSE_PARENOPEN + ")", // RESPARSE_PARENCLOSE + "?", // RESPARSE_QUESTIONMARK + ".", // RESPARSE_DOT + "-", // RESPARSE_DASH + + NUL, // DT_X -- end of parsable tokens -- +}; + +// === 2 tables must match here === +// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +uns resObjOARFlagv[] = { + 0, // none + M_OBJANIRES_LOOP, + M_OBJANIRES_DONTLOOP, + M_OBJANIRES_FREEZENEXT, + M_OBJANIRES_FROZEN, + M_OBJANIRES_DONE, + M_OBJANIRES_ENDKILL, + M_OBJANIRES_KILLPRIME, + M_OBJANIRES_ROOT, + M_OBJANIRES_SKEL, + M_OBJANIRES_GCOL, + M_OBJANIRES_NOSCALE, + M_OBJANIRES_NOPITCH, + M_OBJANIRES_SNAPONCE, + M_OBJANIRES_SYNC, + M_OBJANIRES_SYNC, +}; + +char *resObjOARFlags[] = { + "", // none + "loop", + "dontloop", + "freeze", + "frozen", + "done", + "endkill", + "primekill", + "root", + "skel", + "gcol", + "noscale", + "nopitch", + "snap", + "syncan", // defunct + "sync", + NUL +}; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// === 2 tables must match here === + +// === 2 tables must match here === +// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +uns resObjOVFlagv[] = { + 0, // none + M_OBJVEL_SCALE, + M_OBJVEL_GCOL, +}; +char *resObjOVFlags[] = { + "", // none + "scale", + "gcol", + NUL +}; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// === 2 tables must match here === + + +// === 2 tables must match here === +// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +uns resObjODRFlagv[] = { + 0, // none + M_OBJDISPRES_DONTLIGHT, + M_OBJDISPRES_DISPCOL, + M_OBJDISPRES_SKELCOL, + M_OBJDISPRES_PROPCOL, + M_OBJDISPRES_NOAUTOANI, + M_OBJDISPRES_NOAUTOCOL, + M_OBJDISPRES_LIGHT, + M_OBJDISPRES_FLASHRGB, + M_OBJDISPRES_FLASHNOLIGHT, + M_OBJDISPRES_BLEND, + M_OBJDISPRES_NOFOG, +}; +char *resObjODRFlags[] = { + "", // none + "nolight", + "dcol", + "scol", + "pcol", + "naani", + "nacol", + "lit", + "flash", + "flashnl", + "blend", + "nofog", + NUL +}; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// === 2 tables must match here === + +// === 2 tables must match here === +// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +uns resAniCmdFlagv[] = { + 0, // none + M_OBJANICMD_LOOP, + M_OBJANICMD_SNAP, + M_OBJANICMD_BRIDGE, + M_OBJANICMD_BRIDGE, + M_OBJANICMD_SYNC, + M_OBJANICMD_SYNC, + M_OBJANICMD_REMOVELOOP, + M_OBJANICMD_CHKDEAD, +}; +char *resAniCmdFlags[] = { + "", // none + "loop", + "snap", + "bridge", + "bridges", + "syncan", // defunct + "sync", + "-loop", + "chk", + NUL +}; + +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// === 2 tables must match here === + +// === 2 tables must match here === +// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +uns resObjLightResFlagv[] = { + 0, // none + M_OBJLIGHTRES_NOLIGHT, + M_OBJLIGHTRES_SHADPOS, + M_OBJLIGHTRES_SHADDIR, +}; +char *resObjLightResFlags[] = { + "", // none + "nol", + "shadpos", + "shaddir", + NUL +}; + +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// === 2 tables must match here === + +char *resat_help="commands: (see doc)"; + +char *resTokTerm=" )\t\n\r"; + +// forwards +void resFreeAll(void); +int resParseOne(int ec,ResParseH *fhb,Res *res); + +typedef struct { + uns8 flags; + uns8 dead; + N2 loadedList; + N2 deadList; + memu memubuf[1]; +} resGlobals; + +resGlobals resG; + +// JFL 08 Oct 04 +int ResInit(void) +{ + int ec; + + #if SAFE + if(COUNT(ResObjSubTable)!=OBJSUB_MAX+1) + BP(BP_RESINIT1); + if(COUNT(resObjCreateSizes)!=OBJSUB_MAX) + BP(BP_RESINIT2); + if(COUNT(ResResSubTable)!=RESSUB_MAX+1) + BP(BP_RESINIT3); + if(COUNT(ResN2TypeTable)!=N2TYPE_MAX+1) + BP(BP_RESINIT4); + #endif // SAFE + + MEMZ(resG); + ec=xResInit(); + return ec; +} // ResInit() + +// JFL 08 Oct 04 +void ResFinal(void) +{ + xResFinal(); + if(resG.flags) + { + resG.flags=0; + resFreeAll(); + } +} // ResFinal() + +// JFL 08 Oct 04 +int ResReset(uns reset) +{ + if(resG.flags) + { + resG.flags=0; + resFreeAll(); + } + + resG.flags=1; + N2Head(&resG.loadedList); + N2Head(&resG.deadList); + + return 0; +} // ResReset() + +// JFL 15 Oct 04 +void resFreeList(N2 *list) +{ + N2 *n; + + while((n=list->next) && n->type) + { + if(n->flags&M_N2_KIDLIST) + resFreeList(n-1); + N2Unlink(n); + + // free + // ways the node could be setup + // the data could be allocated together with the node + // or the data could be allocated in a different pool + // or any combination + // this allows you to free the data independently of the node + // the default (i.e. no flags set) is that the data & node + // are allocated together and thus freed by freeing the node + + xResRelease(n); + + if(((Res*)n)->flags&M_RES_FREEDATA) + { + MemDFree(MEMPOOL_RES,((Res*)n)->data); + ((Res*)n)->data=NUL; + } + + if(!(((Res*)n)->flags&M_RES_DONTFREE)) + { + if(n->flags&M_N2_KIDLIST) // if kid, backup + n--; + MemDFree(MEMPOOL_RES,n); + } // free + } // while +} // resFreeList() + +// JFL 12 Oct 04 +void resFreeAll(void) +{ + resFreeList(&resG.loadedList); + resFreeList(&resG.deadList); +} // resFreeAll() + +// JFL 12 Oct 04 +int ResCmp(char *ngame,char *ndata) +{ + int ec; + int i,j; + char c,d; + + if(!ngame) + return 0; // match + if(!ndata) + return 1; // no-match + + i=0; + j=0; +loop: + c=ngame[i]; + d=ndata[j]; + if(c>='A'&&c<='Z') c=c-'A'+'a'; + if(d>='A'&&d<='Z') d=d-'A'+'a'; + if(c=='*') + err(0); // match b/c of wildcard + if(d=='*') + err(0); // match b/c of wildcard + if(c!=d) + err(1); // no match + if(!c) + err(0); // match eos + i++; + j++; + goto loop; + + ec=0; +BAIL: + return ec; +} // ResCmp() + +// JFL 12 Oct 04 +// JFL 06 Jan 05 +int ResCmp2(char *ng1,char *ng2,char *ndata) +{ + int ec; + int i,j; + char c,d; + + if(!ng1) + return 0; // match + if(!ndata) + return 1; // no-match + + i=0; + j=0; +loop: + c=ng1[i]; + d=ndata[j]; + if(c>='A'&&c<='Z') c=c-'A'+'a'; + if(d>='A'&&d<='Z') d=d-'A'+'a'; + if(c=='*') + err(0); // match b/c of wildcard + if(d=='*') + err(0); // match b/c of wildcard + if(!d && (ng2 && ((memu)&ng1[i]==(memu)ng2))) + err(0); // match eos + if(ng2 && ((memu)&ng1[i]>(memu)ng2)) + err(1); // no match b/c eos (other) + if(!d) + err(1); // no match b/c eos + if(c!=d) + err(1); // no match + i++; + j++; + goto loop; + + ec=0; +BAIL: + return ec; +} // ResCmp2() + +// JFL 12 Oct 04 +// JFL 15 Oct 04; from JoeCo +// JFL 09 Nov 04; stack +void* ResFindNth(N2 *n,char *name,int *nth,int level) +{ + N2 *k,*stack[RES_LIST_DEPTH]; + int depth; + + if(!n) + n=resG.loadedList.next; + + stack[0]=n; + depth=1; + + while(depth-->0) + { + for(n=stack[depth];n->type;n=n->next) + { + // compare node + if(!ResCmp(name,((Res*)n)->name)) + { + if(!nth || !(*nth)--) + return n; + } + + if((depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) && k->type) + { + stack[depth++]=n->next; // push next in cur list + n=k->prev; // switch current to first kid + } + + } // for + } // while + + return NUL; +} // ResFindNth() + +// JFL 15 Oct 04; from JoeCo +// JFL 28 Oct 04 +// JFL 09 Nov 04; stack +void* ResFindSubNth(N2 *n,char *name,uns subtype,int *nth) +{ + N2 *k,*stack[RES_LIST_DEPTH]; + int depth; + + if(!n) + n=resG.loadedList.next; + + stack[0]=n; + depth=1; + + while(depth-->0) + { + for(n=stack[depth];n->type;n=n->next) + { + // compare node + if((subtype==((Res*)n)->lnk.sub) + && (!name || !ResCmp(name,((Res*)n)->name))) + { + if(!nth || !(*nth)--) + return n; + } + + if((depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) && k->type) + { + stack[depth++]=n->next; // push next in cur list + n=k->prev; // switch current to first kid + } + + } // for + } // while + + return NUL; +} // ResFindSubNth() + +// JFL 09 Nov 04; stack +// JFL 06 Jan 05; from ResFindSubNth +void* ResFindFT(N2 *n,char *n1,char *n2) +{ + int i; + N2 *k,*stack[RES_LIST_DEPTH]; + int depth; + void *d; + ResDataFTOne *ft; + + if(!n1) + return NUL; + if(!n) + n=resG.loadedList.next; + + stack[0]=n; + depth=1; + + while(depth-->0) + { + for(n=stack[depth];n->type;n=n->next) + { + // compare node + if(RESSUB_FTYPE==((Res*)n)->lnk.sub + && (d=((Res*)n)->data) + && (ft=((ResDataFType*)d)->ftypes)) + { + for(i=0;i<((ResDataFType*)d)->nFTypes;i++,ft++) + if(!ResCmp2(n1,n2,ft->name)) + return ft; + } + + if((depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) && k->type) + { + stack[depth++]=n->next; // push next in cur list + n=k->prev; // switch current to first kid + } + + } // for + } // while + + return NUL; +} // ResFindFT() + +// JFL 12 Oct 04 +// JFL 05 Jan 05; default to zero all +int ResNew(void *resp,uns sub,uns size,uns flags,char *name) +{ + int ec; + int len; + N2 *n; + + len=sizeof(Res); // len is size of mem to zero + if(flags&M_RESNEW_KID) + { + size+=sizeof(N2); + len+=sizeof(N2); + } + + if((ec=MemDAlloc(MEMPOOL_RES,size,&n))<0) + {BP(BP_RESNEW);goto BAIL;} // couldn't alloc + + if(flags&M_RESNEW_DONTCLEAR) + size=len; + MemZero(n,size); + + if(flags&M_RESNEW_KID) + { + N2Head(n); // kid is a list head + n++; // skip to node + n->flags = M_N2_KIDLIST; + } + + n->type=N2TYPE_RES; + n->sub=sub; + n->flags|=SysG.n2FlagsOr; + + if(!(flags&M_RESNEW_DONTLINK)) + N2LinkBefore(&resG.loadedList,n); + + szncpy(((Res*)n)->name,name,sizeof(((Res*)n)->name)); + + *((void**)resp)=(Res*)n; + + ec=0; +BAIL: + return ec; +} // ResNew() + +// JFL 09 Dec 04 +// JFL 25 Aug 05; already dead doesnt fail +int ResKill(void *vr) +{ + Res *r; + if(!(r=vr) || (r->lnk.type!=N2TYPE_RES)) + return -1; + if(r->lnk.flags&M_N2_DEAD) + return ERC_ALREADY_DEAD; // already dead + r->lnk.flags|=M_N2_DEAD; + resG.dead=1; + return 0; +} // ResKill() + +// JFL 30 Dec 04 +int ResLevelKill(int level) +{ + N2 *n,*next; + + if(level>=0) + { + + level<<=S_N2_LEVEL; + level&=M_N2_LEVEL; + + for(n=resG.loadedList.next;n->type;n=next) + { + next=n->next; + if(1 + && ((n->flags&M_N2_LEVEL)==level) + && !(n->flags&M_N2_STRONG) + ) + ResKill((void*)n); + + } // for + } + else if(level==-1) + { + for(n=resG.loadedList.next;n->type;n=next) + { + next=n->next; + if(1 + && (n->flags&M_N2_LEVEL) + && !(n->flags&M_N2_STRONG) + ) + ResKill((void*)n); + } // for + } + + return 0; +} // ResLevelKill() + +// JFL 29 Dec 04 +int ResIsSub(void *vr,uns8 subtype) +{ + N2 *n; + Res *r; + + if(!(r=vr) || (r->lnk.type!=N2TYPE_RES)) + return -1; + if(subtype && (r->lnk.sub!=subtype)) + return -2; + if(!(n=r->lnk.next) || n->prev!=r) + return -3; + if(!(n=r->lnk.prev) || n->next!=r) + return -4; + + return 0; +} // ResIsSub() + +// JFL 09 Dec 04 +void ResLoopEnd(void) +{ + if(resG.dead) + { + resG.dead=0; + N2MoveDead(resG.loadedList.next,&resG.deadList); + } // dead + + if(((N2*)resG.deadList.next)->type) + resFreeList(&resG.deadList); +} // ResLoopEnd() + +#define G_MAGIC 0xAE136457 + +#define LBHEAD_POOL_SIZE 8 +typedef struct { + // must match DC + uns32 magic; + char pool[LBHEAD_POOL_SIZE]; + uns16 flags; + uns16 rhSize; + uns32 size; +} G_LBHead; + +typedef struct { + uns32 magic; +} G_LBTail; + +// JFL 22 Oct 04 +// JFL 29 Nov 04; link kid lists +int resLink(Res *rc,N2 *list,Res *rch) +{ + int ec; + int size; + N2 *n,*kidlist=NUL; + memu kidlist0,kidlistx; + void *rhdata; + + // + // SCAN & LINK IN THE LOADED RESOURCES + // + + kidlist0=kidlistx=0; + for(;;rc++) + { + if(!rc->lnk.type) + { + // terminate unless this is a child + n=(void*)rc; + if((n->sub==N2SUB_KID) && (n[1].type==N2TYPE_RES && n[1].sub==RESSUB_GROUP)) + { + kidlist=n; + kidlistx=(memu)kidlist+(memu)kidlist->next; + N2Head(kidlist); + rc=(void*)&n[1]; + kidlist0=(memu)&rc[1]; + } + else + break; + } + + if(rc->lnk.type!=N2TYPE_RES) + { + LOCKUP(BP_RESLINK); // should be res data +loaderr: + continue; + } + + // patch adr of data if not compiled + if(!(rc->flags&M_RES_COMPILED)) + rc->data = (void*) ((memu)rc->data + (memu)&rc->data); + + size=0; + rhdata=NUL; + if(rch) + rhdata=&rch[1]; + + switch(rc->lnk.sub) + { + + case RESSUB_VID: + if((ec=xResLoadVid(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + + case RESSUB_DISP1: + case RESSUB_DISP2: + case RESSUB_DISP3: + case RESSUB_DISP4: + if((ec=xResLoadDisp(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_IMG1: + if((ec=xResLoadImg(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_CAM: + if((ec=xResLoadCam(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_LIGHT: + if((ec=xResLoadLight(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_SKEL: + if((ec=xResLoadSkel(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_COL: + if((ec=xResLoadCol(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_FONT: + if((ec=xResLoadFont(rc,rhdata))<0) + goto loaderr; + size=ec; + break; + case RESSUB_JUMP: + if(!(rc->flags&M_RES_COMPILED)) + break; + if(rc->data) + (*((ftype2*)rc->data))(rc); + size=ec; + break; + } // switch + + if(rch && rhdata) + { + // copy from the tmp memory to rc header mem + + // copy Res + *rch=*rc; + rch->data=rhdata; // point to local data + + if(kidlist && ((memu)rch>=kidlist0) && ((memu)rch=kidlist0 && (memu)rcmagic) + berr(ERR_RES_FILESYNTAX); + + splitbuf=0; + size = sizeof(Res); + if(!szcmp("tmp",head->pool)) + { + splitbuf=1; + splitpool=MEMPOOL_HEAP; + splitfree=1; + size += head->rhSize; + } + else if(!szcmp("wave",head->pool)) + { + splitbuf=1; + splitpool=MEMPOOL_WAVE; + size += head->rhSize; + } + else + { + size += head->size; + } + + // alloc dynamic node + if((ec=ResNew(&res,RESSUB_GROUP,size,M_RESNEW_KID,name))<0) + goto BAIL; + + kidlist=N2KIDLIST(res); + + rhMem=NUL; + if(splitbuf) + { + // split + memsave=MemSLowGet(splitpool); + if((ec=MemSLow(splitpool,head->size,&rc))<0) + {BP(BP_RESREAD2);goto BAIL;} // couldn't alloc mem + + if(splitfree) + rhMem=&res[1]; + } + else + { + // one-block (not split) + // ptr & adr of start of data block + rc=(void*)&res[1]; + } + + // read in the data + if((ec=FsRead(fh,rc,head->size))<0) + goto BAIL; + + // read in and check LBTail + if((ec=FsRead(fh,buf,sizeof(G_LBTail)))<0) + goto BAIL; + tail=(void*)buf; + if(G_MAGIC !=tail->magic) + berr(ERR_RES_FILESYNTAX); + + if((ec=resLink(rc,kidlist,rhMem))<0) + goto BAIL; + + if(memsave && splitfree) + MemSLowSet(splitpool,memsave); + memsave=NUL; + splitfree=0; + + blocks++; + goto lb_loop; + + ec=0; +BAIL: + if(memsave) + MemSLowSet(MEMPOOL_HEAP,memsave); + + return ec; +} // resRead() + +char *res_compiled_name="compiled"; + +// JFL 12 Oct 04 +int ResLoad(void *resp,char *name) +{ + int ec; + Res *res=NUL; + N2 *kid; + FsH fsmem; + uns8 fsopen=0; + char buf[64]; + + if(!name) + err(1); + + if(!ResCmp(res_compiled_name,name)) + { + if((ec=ResNew(&res,RESSUB_GROUP,sizeof(Res),M_RESNEW_KID,name))<0) + goto BAIL; + + kid=(void*)res; + kid--; + if((ec=resLink(&resCompiled[0],kid,NUL))<0) + goto BAIL; + + if(resp) + *((void**)resp)=(Res*)res; + err(0); + } // load compiled resources + + // + // LOAD -- try a few paths + // + + buf[0]=0; + szncat2(buf,name,".g3",sizeof(buf)); + + if((ec=FsFindOpen(&fsmem,SysG.path,buf,0,NUL,0))<0) + { + char ebuf[256]; + szbuild(ebuf,sizeof(ebuf),"Couldn't open %s",buf); + errlog(ebuf); + goto BAIL; + } // couldn't find file + fsopen=1; + if((ec=resRead(&fsmem,name))<0) + goto BAIL; + + if(resp) + *((void**)resp)=(Res*)res; + + ec=0; +BAIL: + if(fsopen) + FsClose(&fsmem); + return ec; +} // ResLoad() + +// JFL 11 Nov 04 +void* ResLoadedFirst(void) +{ + return resG.loadedList.next; +} // ResLoadedFirst() + +// JFL 11 Nov 04 +int ResLoadedCount(void) +{ + return N2Count(resG.loadedList.next); +} // ResLoadedCount() + +// JFL 29 Mar 05 +int ResKanOp(int op,ResDataKan *kan,void *a) +{ + int ec; + ResDataKanKey *keya,*keyx,*key1,*key2; + float t; + + switch(op&M_RESKANOP) + { + case RESKANOP_NUMKEYS: + err(kan->numk); + case RESKANOP_FIRSTFRAME: + if(!a) + berr(-1); + *((float*)a)=kan->firstFrame; + break; + case RESKANOP_MOVEDELTA: + if(!a) + berr(-1); + keya=(void*)&kan[1]; + keyx=keya+kan->numk; + key1=keya; + + for(t=0;;) + { + key2=1+key1; + if(key2>=keyx) + goto sett; + if(0 + ||(key1->rts[OAR_CH_TX]!=key2->rts[OAR_CH_TX]) + ||(key1->rts[OAR_CH_TY]!=key2->rts[OAR_CH_TY]) + ||(key1->rts[OAR_CH_TZ]!=key2->rts[OAR_CH_TZ])) + goto sett; + t+=key1->time; + key1=key2; + } // for + +sett: + *((float*)a)=t; + break; + default: + berr(-1); + } // switch + + ec=0; +BAIL: + return ec; +} // ResKanOp() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 09 Dec 04 +int ResParseSet(ResParseH *fhb,Res *res,char *str,char *outBuf,uns outBufSize) +{ + fhb->res=res; + fhb->str=str; + fhb->outBuf=outBuf; + fhb->outBufSize=outBufSize; + return 0; +} // ResParseSet() + +// JFL 05 Nov 04 +int ResParseTok(ResParseH *fhb,char **s1p,char **s2p,char *terms) +{ + int ec; + char *s1,*s2; + +loop: + s1=szskipwhite(fhb->str); + s2=szATTok(s1,0,terms); + + if(!s1 || !s2 || !*s1) + err(ERR_PARSE_EOF); + + if(s2==s1 && *s2) + s2++; + + fhb->str=s2; + + if(s1[0]=='/' && s1[1]=='/') + { + s1=szskipto(s1,"\r\n"); + if(!s1) + err(ERR_PARSE_EOF); + + if((s1[1]=='\r' || s1[1]=='\n') && s1[1]!=s1[0]) + s1++; + s1++; + + fhb->str=s1; + + goto loop; + } + + if(*s1=='\"' && s2[-1]=='\"') + { + s1++; + s2--; + ec=RESPARSE_STRING; + } + else if(s2[0]==':') + { + s2++; + fhb->str=s2; + ec=RESPARSE_LABEL; + } + else + ec=sz2map(respwords,s1,s2); + + if(s1p) + *s1p=s1; + if(s2p) + *s2p=s2; + +BAIL: + return ec; +} // ResParseTok() + +// JFL 06 Jan 05 +int ResParseRaw(ResParseH *fhb,char **s1p,char **s2p,char *terms) +{ + int ec; + char *s1,*s2; + +loop: + s1=szskipwhite(fhb->str); + s2=szATTok(s1,0,terms); + + if(!s1 || !s2 || !*s1) + err(ERR_PARSE_EOF); + + if(s2==s1 && *s2) + s2++; + + fhb->str=s2; + + if(s1[0]=='/' && s1[1]=='/') + { + s1=szskipto(s1,"\r\n"); + if(!s1) + err(ERR_PARSE_EOF); + + if((s1[1]=='\r' || s1[1]=='\n') && s1[1]!=s1[0]) + s1++; + s1++; + + fhb->str=s1; + + goto loop; + } + + if(*s1=='\"' && s2[-1]=='\"') + { + s1++; + s2--; + ec=RESPARSE_STRING; + } + else if(s2[0]==':') + { + s2++; + fhb->str=s2; + ec=RESPARSE_LABEL; + } + else + ec=0; + + if(s1p) + *s1p=s1; + if(s2p) + *s2p=s2; + +BAIL: + return ec; +} // ResParseRaw() + +// JFL 22 Nov 04 +int respAdvTok(ResParseH *fhb,char *s1) +{ + fhb->str=s1; + return 0; +} // respAdvTok() + +/////////////////////////////////////////////////////////////////////////////// +// RECURSIVE DESCENT PARSER + +// JFL 13 Aug 04 +int respTOK(ResParseH *fhb,int tok) +{ + int ec; + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=tok) + { + ec=ERR_PARSE_SYNTAX; + BP(BP_RESPTOK); + } + return ec; +} // respTOK() + +// JFL 09 Feb 05 +memu *ResParseVarAdr(ResParseH *fhb,char *s1,char *s2) +{ + int ec; + static memu bogusvar; + + if((s1[1]=='x')&&(s1[0]=='0')) + { + szto(s1,s2,'u',0,&resG.memubuf[0]); + return &resG.memubuf[0]; + } + + if(s1[0]=='$') + s1++; + if(s1[0]=='s'&&s1[1]=='t'&&s1[2]=='r') + { + szto(3+s1,s2,'i',0,&ec); + if((ec<0)||(ec>=COUNT(SysG.str))) + {BP(BP_RESPARSEVARADR);goto BAIL;} // strN out of range + + // this is a little string, it returns the address of the str buf + bogusvar=(memu)SysG.str[ec]; + return &bogusvar; // jjj -- bogus -- can't write + } + szto(s1,s2,'i',0,&ec); + if(ec<0) + { + ec=-ec-1; + if(ec>=COUNT(SysG.var)) + return NUL; + return &(SysG.var[ec]); + } + else if(fhb->varBuf) + { + ec+=BINBUF_FIRST; + if((ec(int)fhb->varBuf[BINBUF_SIZE])) + return NUL; + return &(fhb->varBuf[ec]); + } +BAIL: + return NUL; +} // ResParseVarAdr() + +// JFL 15 Nov 04 +int respDC(ResParseH *fhb) +{ + int ec; + char *s1,*s2; + int count=0; + + while(1) + { + ec=ResParseRaw(fhb,&s1,&s2,NUL); + switch(ec) + { + case RESPARSE_PARENOPEN: + count++; + break; + case RESPARSE_PARENCLOSE: + count--; + break; + case ERR_PARSE_EOF: + goto BAIL; + } // switch + + if(!count) + break; + } // while + + ec=0; +BAIL: + return ec; +} // respDC() + +// JFL 24 Aug 05 +int respGAME(ResParseH *fhb) +{ + int ec; + char *s1,*s2; + int count=0; + + while(1) + { + ec=ResParseRaw(fhb,&s1,&s2,NUL); + switch(ec) + { + case RESPARSE_PARENOPEN: + count++; + break; + case RESPARSE_PARENCLOSE: + count--; + break; + case ERR_PARSE_EOF: + goto BAIL; + } // switch + + if(!count) + break; + } // while + + ec=0; +BAIL: + return ec; +} // respGAME() + +// JFL 15 Nov 04 +int respFOG(ResParseH *fhb) +{ + int ec; + char *s1,*s2; + float a,b,c,rr,gg,bb; + + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec==RESPARSE_QUESTIONMARK) + { + if(fhb->outBuf) + { + szbuild(fhb->outBuf,fhb->outBufSize,"fog(%f %f %f %f %f %f)", + VidDisp.fogNear,VidDisp.fogFar,VidDisp.fogDensity, + VidDisp.fogRGBA[0],VidDisp.fogRGBA[1],VidDisp.fogRGBA[2]); + } + err(1); + } + else if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&a); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&b); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&c); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&rr); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&gg); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&bb); + + if((ec=respTOK(fhb,RESPARSE_PARENCLOSE))<0) + goto BAIL; + + VidDisp.fogNear=a; + VidDisp.fogFar=b; + VidDisp.fogDensity=c; + + VidDisp.fogRGBA[0]=rr; + VidDisp.fogRGBA[1]=gg; + VidDisp.fogRGBA[2]=bb; + + VidDisp.flags|=M_VIDDISP_FOG|M_VIDDISP_FOG_C; + + ec=0; +BAIL: + return ec; +} // respFOG() + +// JFL 22 Nov 04 +int respMIP(ResParseH *fhb) +{ + int ec; + char *s1,*s2; + float a,b; + + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec==RESPARSE_QUESTIONMARK) + { + if(fhb->outBuf) + { + szbuild(fhb->outBuf,fhb->outBufSize,"mip(%f %f)", + VidDisp.mipMin,VidDisp.mipMax); + } + err(1); + } + else if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&a); + + ec=ResParseTok(fhb,&s1,&s2,str_digit); + szto(s1,NUL,'f',0,&b); + + if((ec=respTOK(fhb,RESPARSE_PARENCLOSE))<0) + goto BAIL; + + VidDisp.mipMin=a; + VidDisp.mipMax=b; + + ec=0; +BAIL: + return ec; +} // respMIP() + +// JFL 22 Nov 04 +int respDISP(ResParseH *fhb) +{ + int ec; + char *s1,*s2; + int blend,min,mag,fog,mip,q,grid,joints,lights,wire,shad,vsync; + + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec==RESPARSE_QUESTIONMARK) + { + if(fhb->outBuf) + { + if(VidDisp.flags&M_VIDDISP_FOG) + fog=1; else fog=0; + + if(VidDisp.flags&M_VIDDISP_MINFILTER) + min=1; else min=0; + + if(VidDisp.flags&M_VIDDISP_MAGFILTER) + mag=1; else mag=0; + + if(VidDisp.flags&M_VIDDISP_QUALITY) + q=1; else q=0; + + if(!(VidDisp.flags&M_VIDDISP_MIPMAP)) + mip=0; + else if(VidDisp.flags&M_VIDDISP_MINFILTER) + mip=2; + else + mip=1; + + if(!(VidDisp.flags&M_VIDDISP_BLEND)) + blend=0; + else if(VidDisp.flags&M_VIDDISP_ONEPASSBLEND) + blend=1; + else + blend=2; + + if(VidDisp.flags&M_VIDDISP_GRID) + grid=1; else grid=0; + + if(VidDisp.flags&M_VIDDISP_JOINTS) + joints=1; else joints=0; + + if(VidDisp.flags&M_VIDDISP_LIGHTS) + lights=1; else lights=0; + + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + wire=1; else wire=0; + + if(VidDisp.flags&M_VIDDISP_SHADOWS) + shad=1; else shad=0; + + if(VidDisp.flags&M_VIDDISP_SYNC_VBLANK) + vsync=1; else vsync=0; + + szbuild(fhb->outBuf,fhb->outBufSize, + "disp(blend=%d mag=%d min=%d fog=%d mip=%d q=%d grid=%d lights=%d wire=%d shad=%d vsync=%d)", + blend,mag,min,fog,mip,q,grid,lights,wire,shad,vsync); + } + err(1); + } + else if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + while(1) + { + ec=ResParseTok(fhb,&s1,&s2,NUL); + switch(ec) + { + case ERR_PARSE_EOF: + goto BAIL; + case RESPARSE_PARENCLOSE: + err(2); + case RESPARSE_BLEND: + VidDisp.flags&=~(M_VIDDISP_ONEPASSBLEND|M_VIDDISP_BLEND); + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + { + VidDisp.flags|=M_VIDDISP_BLEND; + if(q==1) + VidDisp.flags|=M_VIDDISP_ONEPASSBLEND; + } + respAdvTok(fhb,s1); + break; + case RESPARSE_MAG: + VidDisp.flags&=~M_VIDDISP_MAGFILTER; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_MAGFILTER; + respAdvTok(fhb,s1); + break; + case RESPARSE_MIN: + VidDisp.flags&=~M_VIDDISP_MINFILTER; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_MINFILTER; + respAdvTok(fhb,s1); + break; + case RESPARSE_FOG: + VidDisp.flags&=~M_VIDDISP_FOG; + VidDisp.flags|=M_VIDDISP_FOG_C; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_FOG; + respAdvTok(fhb,s1); + break; + case RESPARSE_MIP: + VidDisp.flags&=~(M_VIDDISP_MIPMAP|M_VIDDISP_MINFILTER); + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + { + VidDisp.flags|=M_VIDDISP_MIPMAP; + if(q==2) + VidDisp.flags|=M_VIDDISP_MINFILTER; + } + break; + case RESPARSE_Q: // jjj for Will + VidDisp.flags&=~(M_VIDDISP_QUALITY); + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_QUALITY; + respAdvTok(fhb,s1); + break; + case RESPARSE_GRID: + VidDisp.flags&=~M_VIDDISP_GRID; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_GRID; + respAdvTok(fhb,s1); + break; + case RESPARSE_LIGHTS: + VidDisp.flags&=~M_VIDDISP_LIGHTS; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_LIGHTS; + respAdvTok(fhb,s1); + break; + case RESPARSE_JOINTS: + VidDisp.flags&=~M_VIDDISP_JOINTS; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_JOINTS; + respAdvTok(fhb,s1); + break; + case RESPARSE_WIRE: + VidDisp.flags&=~M_VIDDISP_WIREFRAME; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_WIREFRAME; + respAdvTok(fhb,s1); + break; + case RESPARSE_SHAD: + VidDisp.flags&=~M_VIDDISP_SHADOWS; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_SHADOWS; + respAdvTok(fhb,s1); + break; + case RESPARSE_CURS: + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + VidDisp.showCursor=q; + respAdvTok(fhb,s1); + break; + case RESPARSE_MINTRI: + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + VidDisp.minTri=q; + respAdvTok(fhb,s1); + break; + case RESPARSE_MINQUAD: + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + VidDisp.minQuad=q; + respAdvTok(fhb,s1); + break; + case RESPARSE_FINDNAME: + s1=szskipover(s2,str_equal); + s2=szskipto(s1,") \r\n"); + if(s2!=NUL) + szncpy(VidDisp.findResName,s1,s2-s1+1); + respAdvTok(fhb,s2); + break; + case RESPARSE_VSYNC: + VidDisp.flags&=~M_VIDDISP_SYNC_VBLANK; + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'i',10,&q); + if(q) + VidDisp.flags|=M_VIDDISP_SYNC_VBLANK; + respAdvTok(fhb,s1); + break; + } // switch + } // while + ec=0; +BAIL: + return ec; +} // respDISP() + +// JFL 22 Nov 04 +// JFL 31 May 05 +int respCAM(ResParseH *fhb) +{ + int ec; + char *s1,*s2; + Res *r; + int n; + char buf[PM_NAME_SIZE]; + ObjCam *cam; + uns8 add=0,hold=0,camz=0; + int usemark=0; + uns f,flags; + Obj *o; + N2ScanRec nsr; + char posbuf[256]; + + flags=0; + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec==RESPARSE_QUESTIONMARK) + { + + if(!(cam=ObjCamCur())) + s1=""; + else + s1=cam->name; + if(fhb->outBuf) + { + if(!(cam->flags&M_OBJCAM_OFFSPLINE)||!(cam->flags&M_OBJCAM_USEVM)) + szbuild(posbuf,sizeof(posbuf),"r=%f %f %f t=%f %f %f", + cam->rot[0],cam->rot[1],cam->rot[2], + cam->trans[0],cam->trans[1],cam->trans[2]); + else + szbuild(posbuf,sizeof(posbuf),"t=%f %f %f", + cam->vm[VM_X],cam->vm[VM_Y],cam->vm[VM_Z]); + + } + szbuild(fhb->outBuf,fhb->outBufSize,"cam:%s %s",s1,posbuf); + err(1); + } + else if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + r=0; + while(1) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(s1[0]=='.') + { + switch(s1[1]) + { + case 'a': + add=1; + break; + case 'l': + if(s1[2]=='b') + usemark=-1; + else + usemark=1; + break; + case 'z': + if(s1[2]=='0') + camz=1; // no Z buffer + else if(s1[2]=='1') + camz=0; // use existing Z buffer + else if(s1[2]=='2') + camz=2; // clear Z buffer & use + break; + case 'h': + hold=1; + break; + } // switch + } + else + { + ec=sz2map(respwords,s1,s2); + switch(ec) + { + case RESPARSE_PARENCLOSE: + goto parend; + default: + if(s1 && C_IS_DIGIT(*s1)) + { + s1=szto(s1,NUL,'i',10,&n); + r=ResFindSubNth(NUL,NUL,RESSUB_CAM,&n); + } + else + { + szncpy2(buf,s1,s2,sizeof(buf)); + r=ResFindSubNth(NUL,buf,RESSUB_CAM,NUL); + } + break; + } // switch + } // else + } // while +parend: + + // + // + // + + if(camz==1) + flags|=M_OBJCAM_NOZ; + else if(camz==2) + flags|=M_OBJCAM_CLEARZ; + + if(r) + { + if(!add) + { + if((cam=ObjCamCur())) + ObjCamResStart(cam,r,flags); + } + else + { + f=M_OBJNEW_KIDS|M_OBJNEW_KIDSFIRST; + if(!usemark) + { + f|=M_OBJNEW_LINKBEFORE; + ObjSetLinkName("cam2"); // camera2 + } + else if(usemark<0) + f|=M_OBJNEW_LINKBEFORE; + else + f|=M_OBJNEW_LINKAFTER; + + if((ec=ObjNew(&cam,OBJSUB_CAM,sizeof(ObjCam),f))<0) + goto BAIL; + + flags|=M_OBJCAM_ADDED; + ObjCamResStart(cam,r,flags); + } + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"%s %d",r->name,ec); + } + else if(hold) + { + if((cam=ObjCamCur())) + { + if((o=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_SUB + |OBJSUB_ANIRES|M_N2SCAN_KIDSONLY,cam))) + { + ((ObjAniRes*)o)->flags^=M_OBJANIRES_FROZEN; + } + } + + } + else + { + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"cam not found"); + } + + ec=0; +BAIL: + return ec; +} // respCAM() + +// JFL 28 Nov 04 +int ResParsePAREN(ResParseH *fhb) +{ + int ec; + int depth=1; + char *s1,*s2; + + for(;;) + { + if((ec=ResParseTok(fhb,&s1,&s2,NUL))<0) + return ec; + if(ec==RESPARSE_PARENOPEN) + depth++; + if(ec==RESPARSE_PARENCLOSE) + if(!(--depth)) + break; + } // for + + return 0; +} // ResParsePAREN() + +// JFL 28 Nov 04 +int respDEER(ResParseH *fhb,Res *res) +{ + BP(BP_RESPDEER); // use CREATE() + return -1; +} // respDEER() + + +#define FLAGWORD 5 //must match DEERDATA_FLAGS +#define DEADFLAG 0x2 //must match M_DEERFLAG_FALL + + +// JFL 28 Nov 04 +// JFL 04 Mar 05; snap +// JFL 29 Jul 05; blending hit reactions +int respBAN(ResParseH *fhb,Res *res) +{ + int ec; + char buf[128]; + char *s1,*s2; + void *d; + Res *ban=NUL,*nban=NUL,*bban=NUL; + ObjDispRes *odr; + memu *vad; + uns cmd; + int max; + char **map; + uns *val; + float f1=0,f2=0; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + odr=NUL; + ban=NUL; + + for(;;) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + if(s1[0]==')') + break; + if((s1[0]=='f') + &&(s1[1]=='l') + &&(s1[2]=='=')) + { + + map=resAniCmdFlags; + val=resAniCmdFlagv; + max=COUNT(resAniCmdFlagv); + cmd=OBJANICMD_FLAGS; + + // + // BUILD FLAGS FROM LIST + // + + fhb->str=s1+3; + + for(;;) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + if(s1[0]==')') + break; + ec=sz2map(map,s1,s2); + if((ec<1) || (ec>=max)) + {BP(BP_RESPBAN);} // unk flag + else + cmd|=val[ec]; + + // check for continue -- must be imm after flag + if(s2[0]!=',') + break; + fhb->str=1+s2; + } // for + + if((cmd&M_OBJANICMD_CHKDEAD)==M_OBJANICMD_CHKDEAD) + { + goto BAIL; + } + + if(odr) + { + if((ec=ObjAniBody(odr,NUL,cmd,0))<0) + goto BAIL; + } + else + BP(BP_RESPBAN2); // set odr first + + } // opt + else if((s1[0]=='t') + &&(s1[1]=='=')) + { + fhb->str=s1+2; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + fhb->str=szto(s1,s2,'f',0,&f1); + f1*=RES_FRAME_TIME; + } + else if((s1[0]=='r') + &&(s1[1]=='=')) + { + fhb->str=s1+2; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + fhb->str=szto(s1,s2,'f',0,&f2); + } + else if((s1[1]=='=') + &&((s1[0]=='n')||(s1[0]=='b'))) + { + // for this block only + d=NUL; + cmd=s1[0]; + + fhb->str=s1+2; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + szncpy2(buf,s1,s2,sizeof(buf)); + if(s1[2]=='$') + { + if((vad=ResParseVarAdr(fhb,1+s1,s2))) + d=(void*)*vad; + } + else if(STR_IS_HEX(buf)) + { + szto(s1,NUL,'p',0,&d); + } + else if(!(d=ResFindSubNth(NUL,buf,RESSUB_GROUP,NUL))) + berr(ERR_PARSE_INCOMPLETE); + + // + if(cmd=='b') + bban=d; + else if(cmd=='n') + nban=d; + else + BP(BP_RESPBAN3); + } + else if(!odr) + { + szncpy2(buf,s1,s2,sizeof(buf)); + if(s1[0]=='$') + { + if((vad=ResParseVarAdr(fhb,1+s1,s2))) + odr=(void*)*vad; + } + else if(STR_IS_HEX(buf)) + { + szto(s1,NUL,'p',0,&odr); + } + else if(!(odr=ObjFindDispRes(buf))) + berr(ERR_PARSE_INCOMPLETE); + } // odr + else if(!ban) + { + if(s1[0]=='$') + { + if((vad=ResParseVarAdr(fhb,1+s1,s2))) + { + s1=(void*)*vad; + s2=szATTok(s1,0,NUL); // find scan to end of normal token + szncpy2(buf,s1,s2,sizeof(buf)); + } + } + else + szncpy2(buf,s1,s2,sizeof(buf)); + if(!(ban=ResFindSubNth(NUL,buf,RESSUB_GROUP,NUL))) + berr(ERR_PARSE_INCOMPLETE); + } + else + berr(ERR_PARSE_INCOMPLETE); // too many names + } // for + + // + // + // + + if(!odr || (ec=ObjIsSub(odr,OBJSUB_DISPRES))<0) + err(1); + + if(ban) + { + cmd=OBJANICMD_START; + if(f1) + cmd|=M_OBJANICMD_ATIME; + if((ec=ObjAniBody(odr,ban,cmd,f1))<0) + goto BAIL; + } + if(nban) + { + cmd=OBJANICMD_SETNEXT; + if((ec=ObjAniBody(odr,nban,cmd,0))<0) + goto BAIL; + } + if(bban) + { + if(f1) + { + cmd=OBJANICMD_FLAGS|M_OBJANICMD_BTIME; + if((ec=ObjAniBody(odr,NUL,cmd,f1))<0) + goto BAIL; + } + cmd=OBJANICMD_SETBLENDADD; + if(f2) + cmd|=M_OBJANICMD_RAMP; + if((ec=ObjAniBody(odr,bban,cmd,f2))<0) + goto BAIL; + } + + ec=0; +BAIL: + return ec; +} // respBAN() + +enum { + RANOP_NONE, + RANOP_NUL, + RANOP_DASH, + RANOP_STEP, + RANOP_HOLD, + RANOP_RUN, + RANOP_SKIPTO, + RANOP_SKIP, +}; + +char *ranOps[] = +{ + // must match RANOP_ + "", // RANOP_NONE + "nul", // RANOP_NUL + "-", // RANOP_DASH + "step", // RANOP_STEP + "hold", // RANOP_HOLD + "run", // RANOP_RUN + "skipto", // RANOP_SKIPTO + "skip", // RANOP_SKIP + NUL, +}; + +// JFL 02 Dec 04 +int respRAN(ResParseH *fhb,Res *res) +{ + int ec; + //int n; + char buf[128]; + char *s1,*s2; + Res *ran; + Obj *o; + memu *vad; + uns cmd=0; + ObjAniRes *oar; + uns8 paren=0; + float f1; + + // clear binbuf + BINBUFSET(fhb,0,0); + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + paren=1; + + o=NUL; + + // diplay geometry -- for now this is the dispres name + ec=ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + if(s1[0]=='$') + { + if((vad=ResParseVarAdr(fhb,s1,s2))) + o=(void*)*vad; + } + else if(STR_IS_HEX(buf)) + { + szto(s1,NUL,'p',0,&o); + } + else + berr(ERR_PARSE_INCOMPLETE); + + if(!o) + berr(-1); + + // root-anim -- all the joint anims are in a group + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + + f1=0; + if(s1[0]!='-') + { + cmd=OBJANICMD_START|M_OBJANICMD_LOOP; + + // get name of animation + if(s1[0]=='$') + { + if((vad=ResParseVarAdr(fhb,1+s1,s2))) + { + s1=(void*)*vad; + s2=szATTok(s1,0,NUL); // find scan to end of normal token + szncpy2(buf,s1,s2,sizeof(buf)); + } + } + else + szncpy2(buf,s1,s2,sizeof(buf)); + + if(!(ran=ResFindSubNth(NUL,buf,RESSUB_KAN,NUL))) + berr(ERR_PARSE_INCOMPLETE); + + oar=NUL; + if((ec=ObjAniRoot(o,ran,cmd,f1,&oar))<0) + goto BAIL; + + } // start + else + { + s1++; + ec=sz2map(ranOps,s1,s2); + switch(ec) + { + case RANOP_NUL: + case RANOP_DASH: + cmd=OBJANICMD_DETACH; + ran=NUL; + break; + case RANOP_STEP: + cmd=OBJANICMD_STEP; + ran=NUL; + break; + case RANOP_HOLD: + cmd=OBJANICMD_HOLD; + ran=NUL; + break; + case RANOP_RUN: + cmd=OBJANICMD_RUN; + ran=NUL; + break; + case RANOP_SKIP: + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + szto(s1,s2,'f',0,&f1); + f1*=RES_FRAME_TIME; + cmd=OBJANICMD_SKIP; + ran=NUL; + break; + case RANOP_SKIPTO: + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + szto(s1,s2,'f',0,&f1); + f1*=RES_FRAME_TIME; + cmd=OBJANICMD_SKIPTO; + ran=NUL; + break; + default: + BP(BP_RESPRAN); + } // switch + + oar=NUL; + if((ec=ObjAniRoot(o,ran,cmd,f1,&oar))<0) + goto BAIL; + + } // option + + // + // + // + + BINBUFSET(fhb,0,oar); + + ec=0; +BAIL: + if(paren) + { + ResParsePAREN(fhb); + ec=1; + } + return ec; +} // respRAN() + +// JFL 05 Apr 05 +int ResNFSFlag(void *vnsr,N2 *n) +{ + N2ScanRec *nsr=vnsr; + if(n->type==N2TYPE_OBJ) + { + if(n->sub==OBJSUB_ANIRES) + { + if(((ObjAniRes*)n)->flags&nsr->fdata) + return N2SCANFUNC_MATCH_AND_RETURN; + } + } + return N2SCANFUNC_CONTINUE; +} // ResNFSFlag() + +// JFL 29 Mar 05 +int ResNFSZeroTime(void *vnsr,N2 *n) +{ + N2ScanRec *nsr=vnsr; + if(n->type==N2TYPE_OBJ) + { + if(n->sub==OBJSUB_SEQRES) + { + ((ObjSeqRes*)n)->time0=GameWaveTime; + ((ObjSeqRes*)n)->hold=0; + } + if(n->sub==OBJSUB_ANIRES) + { + ((ObjAniRes*)n)->aniTime0=GameWaveTime; + ((ObjAniRes*)n)->skipAdj=0; + } + } + return N2SCANFUNC_CONTINUE; +} // ResNFSZeroTime() + +// JFL 07 Apr 05 +int ResNFSImg(void *vnsr,N2 *n) +{ + void *d; + N2ScanRec *nsr=vnsr; + + if((n->sub==RESSUB_IMG1) + &&(n->type==N2TYPE_RES) + &&(d=((Res*)n)->data) + &&(((ResDataImg1*)d)->texHash==nsr->fdata)) + return N2SCANFUNC_MATCH_AND_RETURN; + return N2SCANFUNC_CONTINUE; +} // ResNFSImg() + +// JFL 07 Dec 04 +// JFL 05 Jul 05 +int respSETCAT(ResParseH *fhb,Res *res,int cat) +{ + int ec,v,i; + uns8 gotparen=0; + char *s1,*s2,*v1,*v2,*n1,*n2; + Obj *o; + Res *r; + void *d; + float f1; + uns u; + N2ScanRec nsr; + + v1=n1=NUL; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // var name + v=ResParseTok(fhb,&n1,&n2,NUL); + + // value + ResParseRaw(fhb,&v1,&v2,NUL); + + // + // + // + + switch(v) + { + case RESPARSE_CFG: + if(!cat) + sz2ncpy(SysG.cfg,v1,v2,sizeof(SysG.cfg)); + else + sz2ncat2(SysG.cfg,v1,v2,NUL,NUL,sizeof(SysG.cfg)); + break; + case RESPARSE_FLAGS: + if(!cat) + sz2ncpy(SysG.flags,v1,v2,sizeof(SysG.flags)); + else + sz2ncat2(SysG.flags,v1,v2,NUL,NUL,sizeof(SysG.flags)); + break; + case RESPARSE_LEVEL: + + szto(v1,NUL,'i',0,&ec); + SysLevelSet(ec); + break; +str: + szto(3+n1,NUL,'i',0,&ec); + if((ec<0) || (ec>=COUNT(SysG.str))) + break; + + i=sz2map(respwords,v1,v2); + if((i==RESPARSE_NUL) || (i==RESPARSE_DASH)) + SysG.str[ec][0]=0; + else + sz2ncpy(SysG.str[ec],v1,v2,sizeof(SysG.str[0])); + break; +var: + szto(1+n1,NUL,'i',0,&ec); + if((ec<0) || (ec>=COUNT(SysG.var))) + break; + i=sz2map(respwords,v1,v2); + if((i==RESPARSE_NUL) || (i==RESPARSE_DASH)) + SysG.var[ec]=0; + else + { + szto(v1,v2,'i',0,&i); + SysG.var[ec]=i; + } + break; + case RESPARSE_KEYMACRO: + + // search for keymacro-already-set or empty slot + i=-1; + for(ec=0;ec=COUNT(SysG.keymacros))) + {BP(BP_RESSETCAT);break;} // couldn't find usable slot + ec=sz2map(respwords,v1,v2); + if((ec==RESPARSE_NUL) || (ec==RESPARSE_DASH)) + SysG.keymacros[i][0]=0; + else + { + SysG.keymacros[i][0]=*v1; + SysG.keymacros[i][1]=' '; + ResParseRaw(fhb,&s1,&s2,NUL); + sz2ncpy(&SysG.keymacros[i][2],s1,s2,sizeof(SysG.keymacros[0])-2); + } + break; + case RESPARSE_TAG: + szto(v1,NUL,'i',0,&ec); + SysG.tag=ec; + break; + case RESPARSE_GAME: + ec=sz2map(respwords,v1,v2); + switch(ec) + { + case RESPARSE_PAUSE: + GameLp.flags|=M_GAMELP_PAUSE; + break; + case RESPARSE_RUN: + GameLp.flags&=~M_GAMELP_PAUSE; + break; + case RESPARSE_STEP: + GameLp.flags|=M_GAMELP_STEPF|M_GAMELP_PAUSE; + break; + } // switch + break; + + case RESPARSE_ELF: + if(!(o=fhb->root) + ||(o->lnk.type!=N2TYPE_OBJ) + ||(o->lnk.sub!=OBJSUB_SEQRES) + ||!(r=((ObjSeqRes*)o)->res) + ||!(d=r->data)) + {BP(BP_RESSETCAT2);break;} + if((v1[0]=='-')||!sznicmp("nul",0,v1,v2,1+sizeof("nul"))) + ((ObjSeqRes*)o)->everyLoop=NUL; + else if((ec=ResRDSLabAdr(d,v1,v2,&((ObjSeqRes*)o)->everyLoop))<0) + {BP(BP_RESSETCAT3);break;} // label not found + break; // elf + + case RESPARSE_BR: + if(!(o=fhb->root) + ||(o->lnk.type!=N2TYPE_OBJ) + ||(o->lnk.sub!=OBJSUB_SEQRES) + ||!(r=((ObjSeqRes*)o)->res) + ||!(d=r->data)) + {BP(BP_RESSETCAT4);break;} + if((ec=ResRDSLabAdr(d,v1,v2,&s1))<0) + {BP(BP_RESSETCAT5);break;} // label not found + ((ObjSeqRes*)o)->key0=s1; + ((ObjSeqRes*)o)->hold=0; + break; // elf + + case RESPARSE_TIME: + szto(v1,v2,'f',0,&f1); + f1*=RES_FRAME_TIME; + u=f1; + GameCallback(GAMECALLBACK_SET_WAVE_TIME,(void*)u,NUL); + if(!u) + { + ProcOp(NUL,PROCOP_RESET_SLEEPS,0); + nsr.func3=(void*)ResNFSZeroTime; + N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_FUNC,ObjActiveFirst()); + } + break; // time + + case RESPARSE_SORTBUFSIZE: + szto(v1,v2,'i',0,&ec); + + o=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_NODEEPER + |M_N2SCAN_SUB|OBJSUB_STARTSORTBUF,ObjActiveFirst()); + if(o) + ((ObjStartSortBuf*)o)->sortBufSize=ec; + + break; + + case RESPARSE_GUNSPEED: + + szto(v1,v2,'f',0,&f1); + f1/=(float)RES_FRAME_TIME; + + for(i=0;igunSpeed=f1; + } // for + + break; + + case RESPARSE_SHAD: + for(;;) + { + switch(*v1) + { + case ')': + gotparen=1; + default: + if((VidDisp.flags&M_VIDDISP_GSHADOW) + &&(VidDisp.flags&M_VIDDISP_GSHADOW_DIR)) + { + V3Normalize(VidDisp.shadowPos); + } + err(1); + + case 'c': + // get color AARRGGBB + ResParseRaw(fhb,&n1,&n2,NUL); + szto(n1,n2,'u',0,&u); // 0xAARRGGBB + VidDisp.shadowRGBA[0]=(u>>16)&0xff; + VidDisp.shadowRGBA[1]=(u>>8)&0xff; + VidDisp.shadowRGBA[2]=(u>>0)&0xff; + VidDisp.shadowRGBA[3]=(u>>24)&0xff; + break; + + case 's': // size (of skirt distance) + ResParseRaw(fhb,&n1,&n2,NUL); + szto(n1,n2,'f',0,&f1); + VidDisp.shadowDist=f1; + break; + + case 'v': // vector + ResParseRaw(fhb,&n1,&n2,NUL); + szto(n1,n2,'f',0,&f1); + VidDisp.shadowPos[0]=f1; + + ResParseRaw(fhb,&n1,&n2,NUL); + szto(n1,n2,'f',0,&f1); + VidDisp.shadowPos[1]=f1; + + ResParseRaw(fhb,&n1,&n2,NUL); + szto(n1,n2,'f',0,&f1); + VidDisp.shadowPos[2]=f1; + break; + + case 'p': // positional + VidDisp.flags|=M_VIDDISP_GSHADOW; + VidDisp.flags&=~M_VIDDISP_GSHADOW_DIR; + break; + + case 'd': // directional + VidDisp.flags|=M_VIDDISP_GSHADOW|M_VIDDISP_GSHADOW_DIR; + break; + + case 'l': // use local/light's shadow info + VidDisp.flags&=~M_VIDDISP_GSHADOW; + break; + + } // switch + ResParseRaw(fhb,&v1,&v2,NUL); + } // for + break; + + default: + if(n1[0]=='s' && n1[1]=='t' && n1[2]=='r') + goto str; + if(n1[0]=='v') + goto var; + + berr(ERR_PARSE_SYNTAX); + } + + ec=0; +BAIL: + if(!gotparen) + ResParsePAREN(fhb); + return ec; +} // respSETCAT() + +// ------------------------------------------------------------------- +// MAN 15 DEC 06 + +int respVIDPLAY(ResParseH *fhb, Res *res) +{ + int ec, ignoreVal; + char *s1,*s2; + char buf[128]; + char buf2[8]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + ignoreVal = 0; + + ec = ResParseTok(fhb, &s1, &s2, NUL); + if (ec != RESPARSE_PARENCLOSE) + { + szncpy2(buf2, s1, s2, sizeof(buf2)); + ignoreVal = atoi(buf2); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + } + + theorafunc_loadVideo(buf); + + if (getVideoFromObject(buf)) + { + ((theorafunc_data_t *)getVideoFromObject(buf))->isPlaying = 1; + ((theorafunc_data_t *)getVideoFromObject(buf))->ignoreTime = ignoreVal; + } + + ec = 0; +BAIL: + return ec; +} + +// ------------------------------------------------------------------- +// MAN 15 DEC 06 + +int respVIDSTOP(ResParseH *fhb, Res *res) +{ + int ec; + char *s1,*s2; + char buf[128]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + if (getVideoFromObject(buf)) + { + ((theorafunc_data_t *)getVideoFromObject(buf))->isPlaying = 0; + } + + ec = 0; +BAIL: + return ec; +} + +// ------------------------------------------------------------------- +// MAN 04 JAN 07 + +int respVIDREADY(ResParseH *fhb, Res *res) +{ + int ec; + char *s1,*s2; + char buf[128]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + if (getVideoFromObject(buf)) + { + ((theorafunc_data_t *)getVideoFromObject(buf))->isPlaying = -1; + theorafunc_restart( ((theorafunc_data_t *)getVideoFromObject(buf)) ); + ((theorafunc_data_t *)getVideoFromObject(buf))->vidStartTicks = -1; + theorafunc_readyVideo( ((theorafunc_data_t *)getVideoFromObject(buf)) ); + } + + ec = 0; +BAIL: + return ec; +} + +// ------------------------------------------------------------------- +// MAN 21 DEC 06 + +int respVIDDONE(ResParseH *fhb, Res *res) +{ + int ec; + char *s1,*s2; + char buf[128], buf2[128]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf2,s1,s2,sizeof(buf2)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + if (getVideoFromObject(buf)) + sprintf(((theorafunc_data_t *)getVideoFromObject(buf))->linkedObject, buf2); + + ec = 0; +BAIL: + return ec; +} + +// ------------------------------------------------------------------- + +int respVIDALINK(ResParseH *fhb, Res *res) +{ + int ec; + char *s1,*s2; + char buf[128], buf2[128]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf2,s1,s2,sizeof(buf2)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + theorafunc_vidalink(buf, buf2); + + ec = 0; +BAIL: + return ec; +} + +// JFL 09 Dec 04 +// JFL 29 Dec 04 +// JFL 30 Mar 05 +int respKILL(ResParseH *fhb,Res *res) +{ + int ec; + int n; + char *s1,*s2; + N2 *o,*ostrong=NUL; + char buf[PM_NAME_SIZE]; + memu *bin=fhb->binBuf; + memu *var=fhb->varBuf; + uns8 strong=0; + int8 paren=0; + uns8 sub,typ; + N2ScanRec nsr; + + // set strong bit so we don't kill our own sequence + if((ostrong=fhb->root)) + { + if(ostrong->flags&M_N2_STRONG) + strong=1; + ostrong->flags|=M_N2_STRONG; + } + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + sub=OBJSUB_DISPRES; // default + typ=N2TYPE_OBJ; // default + o=NUL; + buf[0]=0; + for(;;) + { + ec=ResParseRaw(fhb,&s1,&s2,NUL); + if(*s1==')') + {paren=1;break;} + switch(*s1) + { + case '$': // variable + if(!var) + berr(ERR_PARSE_SETUP); + szto(1+s1,NUL,'i',0,&n); + n+=BINBUF_FIRST; + if((n(int)var[BINBUF_SIZE])) + berr(ERR_PARSE_RANGE); + o=(void*)var[n]; + + break; + case '*': // wildcard + if(s1[1]!='=') + goto gotname; + switch(s1[1]) + { + case '=': + // all res & obj equal to this level + szto(2+s1,NUL,'i',0,&n); + + // mark nodes as dead + ObjLevelKill(n); + ResLevelKill(n); + + // unlink & free nodes + // must be very careful about what's going on with other nodes + ObjLoopEnd(); + ResLoopEnd(); + + break; + } // switch + + break; + case '^': // tag + switch(s1[1]) + { + case '=': + // all res & obj equal to this level + szto(2+s1,NUL,'i',0,&n); + ObjTagKill(n); + break; + } // switch + + break; + case '-': // self + o=fhb->root; + break; + case '.': // options + switch(s1[1]) + { + case 'T': // type + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + ResParseRaw(fhb,&s1,&s2,NUL); // get name + typ=sz2map(ResN2TypeTable,s1,s2); + break; + case 't': // subtype + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + ResParseRaw(fhb,&s1,&s2,NUL); // get name + switch(typ) + { + case N2TYPE_OBJ: + sub=sz2map(ResObjSubTable,s1,s2); + break; + case N2TYPE_RES: + sub=sz2map(ResResSubTable,s1,s2); + break; + default: + BP(BP_RESPKILL); + } // switch + break; + } // switch + break; + case '!': // prime + goto killprime; + default: + if(STR_IS_HEX(s1)) + { + szto(s1,s2,'p',0,&o); + break; + } + if(!sznicmp("prime",NUL,s1,s2,-1)) + { +killprime: + o=N2Parent(fhb->root); + break; + } +gotname: + // get name + szncpy2(buf,s1,s2,sizeof(buf)); + + } // switch + + } // for + + // + // + // + + if(o) + typ=sub=0; + + + switch(typ) + { + case 0: + if(!o) + err(1); + goto killloop; + case N2TYPE_OBJ: + o=ObjActiveFirst(); + break; + case N2TYPE_RES: + o=ResLoadedFirst(); + break; + default: + berr(-1); + } // switch + + nsr.s1=buf; + nsr.s2=NUL; + o=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_NODEEPER + |M_N2SCAN_NAME|M_N2SCAN_SUB|sub,o); + +killloop: + while(o) + { + switch(o->type) + { + case N2TYPE_RES: + if((ec=ResIsSub(o,o->sub))<0) + goto BAIL; + if((ec=ResKill(o))<0) + goto BAIL; + break; + case N2TYPE_OBJ: + if((ec=ObjIsSub(o,o->sub))<0) + goto BAIL; + if((ec=ObjKill(o))<0) + goto BAIL; + break; + } // switch + + if(!typ) + break; + + o=N2Scan(&nsr,M_N2SCAN_NODEEPER + |M_N2SCAN_NAME|M_N2SCAN_SUB|sub,o); + + } // o + + ec=0; +BAIL: + if(!strong && ostrong && !(ostrong->flags&M_N2_DEAD)) + ostrong->flags&=~M_N2_STRONG; + + if(!paren) + ResParsePAREN(fhb); + return ec; +} // respKILL() + +// JFL 11 Jan 05 +int ResLabAdr(ResRDSLab *lab,int nlab,char *s1,char *s2,void *labp) +{ + int i; + + if((s1[0]=='-') && (s1+1==s2)) + return -2; + + for(i=0;iname,NUL,sizeof(lab->name))) + { + *((void**)labp)=(void*) ((memu)&lab->off+lab->off); + return 0; + } + } // for + + return -1; +} // ResLabAdr() + +// JFL 11 Jan 05 +int ResRDSLabAdr(ResDataSeq *rds,char *s1,char *s2,void *adrp) +{ + void *lab; + + lab=(void*)((uns8*)&rds[1]+rds->dataSize); + + return ResLabAdr(lab,rds->nLab,s1,s2,adrp); + +} // ResRDSLabAdr() + +// JFL 11 Jan 05 +int ResRDSSigAdr(ResDataSeq *rds,int n,char type,void *adrp) +{ + // return <0 on err, ==0 on success + + ResRDSSig *sig; + + if((n<0) || (n>rds->nSig)) + return -1; + + sig=(void*)((uns8*)&rds[1]+rds->dataSize+rds->nLab*sizeof(ResRDSLab)); + sig+=n; + + switch(type) + { + default: + case 'b': // before + if(!sig->offBefore) + return 1; + *((void**)adrp)=(void*)((memi)&sig->offBefore+sig->offBefore); + break; + case 'c': // cleanup + case 'a': // abort + if(!sig->offCleanup) + return 1; + *((void**)adrp)=(void*)((memi)&sig->offCleanup+sig->offCleanup); + break; + case 's': // start + if(!sig->offStart) + return 1; + *((void**)adrp)=(void*)((memi)&sig->offStart+sig->offStart); + break; + } // switch + return 0; +} // ResRDSSigAdr() + +// JFL 18 Jan 05 +int ResRDSVars(void *vosr,ResDataSeq *rds,memu **varp) +{ // return number of vars + ObjSeqRes *osr=vosr; + + if(!rds->allocSize) + return 0; + + if(varp) + *varp=(memu*)&osr[1]+BINBUF_FIRST; + + return (rds->allocSize/sizeof(memu))-BINBUF_FIRST; + +} // ResRDSVars() + +// JFL 18 Jan 05 +int ResRDSCall(void *vosr,ResDataSeq *rds,void *adr) +{ + int ec; + ResDataParse rdpmem,*rdp=&rdpmem; + ObjSeqRes *osr=vosr; + + MEMZ(rdpmem); + + // setup rdp for call + rdp->cmd=adr; + if(rds->allocSize) + rdp->varBuf=(memu*)&osr[1]; + if(rds->nLab) + { + rdp->nLab=rds->nLab; + rdp->lab=(void*)((uns8*)&rds[1]+rds->dataSize); + } + rdp->root=osr; + + if((ec=ResParseBlock(rdp,NUL))<0 && (ec!=ERR_PARSE_EOF)) + goto BAIL; + + ec=0; +BAIL: + return ec; +} // ResRDSCall() + +// JFL 12 Jul 05 +int ResSeqCB(uns op,void *vosr) +{ + int ec,i; + ObjSeqRes *osr=vosr; + InpRec *ir=InpGet(0); + int cb[OBJSEQRES_CB_NUM]={INPSW_P0_START,INPSW_P1_START,INPSW_G0_TRIGGER0,INPSW_G0_TRIGGER2,INPSW_G1_TRIGGER0,INPSW_G1_TRIGGER2}; + + #if OBJSEQRES_CB_NUM<6 + #error -- need 6 + #endif // OBJSEQRES_CB_NUM + + switch(op&M_RESSEQCB) + { + case RESSEQCB_SLEEPINIT: + + for (i = 0; i < 24; i++) + osr->lptSwitchCount[i] = dond_lptGetSwitchCount(i); + + if(!ir) + break; +/* osr->cb[0]=1+ir->count[INPSW_P0_START]; + osr->cb[0]|=1; + osr->flags &= ~M_OBJANIRES_JUMP; +*/ + for (i=0;icb[i]=1+ir->count[cb[i]]; + osr->cb[i]|=1; + osr->flags &= ~M_OBJANIRES_JUMP; + } + break; + case RESSEQCB_SLEEPING: + + for (i = 0; i < 24; i++) + { + if (dond_lptGetSwitchCount(i) > osr->lptSwitchCount[i]) + { + osr->flags |= M_OBJANIRES_JUMP; + err(-1); + } + } + + /* + if (dond_lptCountSwitches()) + { + if (dond_lptCountSwitches() > osr->lptSwitchCount) + { + osr->flags |= M_OBJANIRES_JUMP; + err(-1); + } + } + */ + + if(!ir) + break; +/* if(ir->count[INPSW_P0_START]>=osr->cb[0]) + { + osr->flags |= M_OBJANIRES_JUMP; + err(-1); // tapout + } +*/ + for (i=0;icount[cb[i]]>=osr->cb[i]) + { + osr->flags |= M_OBJANIRES_JUMP; + err(-1); // tapout + } + + } + + break; + } // switch + ec=0; +BAIL: + return ec; +} // ResSeqCB() + +// JFL 09 Dec 04 +// JFL 17 Nov 04 +int respSEQ(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2,*q1,*top=NUL,*bot,*tip; + char *first=NUL,*cleanup=NUL,*before=NUL; + Res *r; + ResDataSeq *rds; + int size=0; + int alloc=0; + int nsig=0; + int nlab=0; + char buf[128]; + int i,u; + ResRDSLab *lab; + ResRDSSig *sig; + ResParseH tmpfhmem,*tfhb=&tmpfhmem; + + // name + if((ec=ResParseTok(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + tip=fhb->str; + + // check for 'header' functions + for(;;) + { + q1=fhb->str; + ec=ResParseTok(fhb,&s1,&s2,NUL); + switch(ec) + { + // + // HEADER FUNCTIONS -- not copied into the resource + // + + case RESPARSE_ALLOC: + + // header function -- not copied + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + ec=ResParseTok(fhb,&s1,&s2,NUL); + + szto(s1,s2,'i',10,&alloc); + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + break; + case RESPARSE_SIGNALS: + + // header function -- not copied + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + ec=ResParseTok(fhb,&s1,&s2,NUL); + + szto(s1,s2,'i',10,&nsig); + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + break; + case RESPARSE_SIGNAL: + + // header function -- not copied + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + + break; + case RESPARSE_SIZE: + + // header function -- not copied + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + ec=ResParseTok(fhb,&s1,&s2,NUL); + + szto(s1,s2,'i',10,&size); + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + break; + case ERR_PARSE_EOF: + BP(BP_RESPSEQ); // jjj watch this + goto BAIL; + case RESPARSE_PARENCLOSE: + goto scand; + + // + // BODY + // + + default: + BP(BP_RESPSEQ2); // start script body with: frame(-) or start() + if(!top) + top=q1; + if((ec=resParseOne(ec,fhb,res))<0) + goto BAIL; + break; + case RESPARSE_BEFORE: + if(!top) + top=q1; + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + before=fhb->str; + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + break; + case RESPARSE_CLEANUP: + if(!top) + top=q1; + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + cleanup=fhb->str; + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + break; + case RESPARSE_START: + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + q1=fhb->str; + + // drop through + + case RESPARSE_FRAME: + q1=szskipwhite(q1); + if(!top) + top=q1; + first=q1; + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + goto scand; + } // switch + } // for + +scand: + if(!top) + top=q1; + bot=fhb->str; + + if(!top || !bot) + err(-1); + + u = (memu)bot-(memu)top; + if(sizestr=top;(memu)tfhb->str<(memu)bot;) + { + if((ec=ResParseRaw(tfhb,&s1,&s2,NUL))<0) + break; + if(s2&&s2[-1]==':') + nlab++; + } // for + + // + // + // + + // r Res (rds=r->data) + // rds ResDataSeq + // size (contains all the text) + // nlab*sizeof(ResRDSLab) + // nsig*sizeof(ResRDSSig) + + + // create a resource with the text + if((ec=ResNew(&r,RESSUB_SEQ,sizeof(Res) // careful w/sizes + +sizeof(ResDataSeq)+size+nlab*sizeof(ResRDSLab) + +nsig*sizeof(ResRDSSig),0,buf))<0) + goto BAIL; + rds=(void*)&r[1]; + r->data=rds; + rds->dataSize=size; + if(alloc) + { + alloc+=BINBUF_FIRST; + alloc*=sizeof(memu); // alloc in memu units + } + rds->allocSize=alloc; // size in bytes -- allocation in ani start + rds->flags|=M_RESDATASEQ_TEXT; + szncpy((void*)&rds[1],top,size); + + if(first) + rds->firstOff=(memu)first-(memu)top; + if(before) + rds->beforeOff=(memu)before-(memu)top; + if(cleanup) + rds->cleanupOff=(memu)cleanup-(memu)top; + rds->nLab=nlab; + rds->nSig=nsig; + + // + // build label table + // + + if(nlab) + { + top=(void*)&rds[1]; + bot=top+rds->dataSize; + lab=(void*)((uns8*)&rds[1]+rds->dataSize); + for(i=0,tfhb->str=top;(istr<(memu)bot);) + { + if((ec=ResParseRaw(tfhb,&s1,&s2,NUL))<0) + break; + if(s2&&s2[-1]==':') + { + s2--; + szncpy2(lab->name,s1,s2,sizeof(lab->name)); + s2=szskipwhite(1+s2); + lab->off=(memi)s2-(memi)&lab->off; + i++; + lab++; + } + } // for + } // lab + + // + // build signal table + // + + if(nsig) + { + lab=(void*)((uns8*)&rds[1]+rds->dataSize); + + for(i=0,tfhb->str=tip;(istr<(memu)top);) + { + if((ec=ResParseTok(tfhb,NUL,NUL,NUL))<0) + break; + if(ec==RESPARSE_SIGNAL) + { + if((ec=ResParseTok(tfhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // get signal number + if((ec=ResParseRaw(tfhb,&s1,&s2,NUL))<0) + break; + szto(s1,s2,'i',10,&u); + + if((u<0) || (u>=nsig)) + continue; + + sig=(void*)((uns8*)&rds[1]+rds->dataSize+nlab*sizeof(ResRDSLab)); + sig+=u; + + // get before label + if((ec=ResParseRaw(tfhb,&s1,&s2,NUL))<0) + break; + if(!ResLabAdr(lab,nlab,s1,s2,&q1)) + sig->offBefore=(memi)q1-(memi)&sig->offBefore; + + // get start label + if((ec=ResParseRaw(tfhb,&s1,&s2,NUL))<0) + break; + if(!ResLabAdr(lab,nlab,s1,s2,&q1)) + sig->offStart=(memi)q1-(memi)&sig->offStart; + + // get cleanup label + if((ec=ResParseRaw(tfhb,&s1,&s2,NUL))<0) + break; + if(!ResLabAdr(lab,nlab,s1,s2,&q1)) + sig->offCleanup=(memi)q1-(memi)&sig->offCleanup; + + if((ec=ResParseTok(tfhb,&s1,&s2,NUL))!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + } + else if(ec!=RESPARSE_LABEL) + { + if((ec=ResParseTok(tfhb,&s1,&s2,NUL))==RESPARSE_PARENOPEN) + ResParsePAREN(tfhb); + } + } // for + } // for + + // + // OUTPUT + // + + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>0x%x ",rds); + + if(fhb->binBuf + && ((u=fhb->binBuf[BINBUF_NEXT])<(int)fhb->binBuf[BINBUF_SIZE])) + { + fhb->binBuf[u]=(memu)rds; + fhb->binBuf[BINBUF_NEXT]++; + } + + ec=0; +BAIL: + return ec; +} // respSEQ() + +// JFL 09 Dec 04 +// JFL 17 Nov 04 +// JFL 05 Jan 05 +int respANI(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + Obj *o; + Res *r; + char buf[128]; + N2 *nlink; + //uns flags; + //memu *bin=fhb->binBuf; + memu *var=fhb->varBuf; + int n; + + // clear binbuf + BINBUFSET(fhb,0,0); + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // obj to link after + ec=ResParseTok(fhb,&s1,&s2,NUL); + if((ec==RESPARSE_NUL)||(ec==RESPARSE_DASH)) + { + nlink=NUL; + } + else if(s1[0]=='$') + { + if(s1[1]=='s'&&s1[2]=='t'&&s1[3]=='r') + { + szto(4+s1,NUL,'i',0,&ec); + if((ec>=0) || (ec(int)var[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + nlink=(void*)var[n]; + if((ec=ObjIsSub(nlink,0))<0) + goto BAIL; + if(!(nlink->flags&M_N2_KIDLIST)) + berr(ERR_PARSE_SYNTAX); + nlink=N2KIDLIST(nlink); + + } + } + else if(STR_IS_HEX(s1)) + { + szto(s1,s2,'p',0,&nlink); + if((ec=ObjIsSub(nlink,0))<0) + goto BAIL; + } + else + { +find: + szncpy2(buf,s1,s2,sizeof(buf)); + if(!(nlink=ObjFindDispRes(buf))) + err(1); + } + + // + ec=ResParseTok(fhb,&s1,&s2,NUL); + + if(s1[0]=='$') + { + if(s1[1]=='s'&&s1[2]=='t'&&s1[3]=='r') + { + szto(4+s1,NUL,'i',0,&ec); + if((ec>=0) || (ec=0) || (eclab; + nlab=fhb->nLab; + if((s1=szchr(b1,b2,'.'))) + { + // a different seq -- find it + szncpy2(buf,b1,s1,sizeof(buf)); + b1=1+s1; + if(!(r=ResFindSubNth(NUL,buf,RESSUB_SEQ,NUL))) + berr(1); // couldn't find the seq in buf + if(!(rds=r->data)) + berr(1); // no rds data + nlab=rds->nLab; + s1=(void*)&rds[1]; + s1+=rds->dataSize; + lab=(void*)s1; + } // different sequence + + // + // + // + + if(!lab || !nlab) + berr(-1); // no lables + + ResParsePAREN(fhb); + parend=1; + + if(!b1) // branch label + berr(1); + + if((ec=ResLabAdr(lab,nlab,b1,b2,&s1))<0) + berr(1); + + if(fhb->radepthrastack)) + { + fhb->rastack[fhb->radepth++]=fhb->str; + fhb->str=s1; + err(0); // success + } + else + berr(1); // stack full + + ec=1; // no branch +BAIL: + if(!parend) + ResParsePAREN(fhb); + + return ec; +} // respSUB() + +// JFL 15 Dec 04 +int respBIN(ResParseH *fhb,Res *res) +{ + int ec; + int a,b; + char *s1,*s2; + uns cmd; + memu *bin=fhb->binBuf; + memu *vad,*vad2; + memu m; + float f1; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + if(!bin) + { + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + err(1); + } + + for(;;) + { + // quick way to form a command + s1=szskipwhite(fhb->str); + if(s1[0]==')') + { + fhb->str=szskipwhite(s1+1); + break; + } + cmd=s1[0]<<8; + cmd|=s1[1]; + fhb->str=szskipwhite(s1+2); + + switch(cmd) + { + case C2('m','v'): // move to var from bin + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&b); + + b+=BINBUF_FIRST; + if((b(int)bin[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + m=bin[b]; + + if(!vad) + berr(ERR_PARSE_SYNTAX); + *vad=m; + + break; + case C2('c','p'): // copy from var to var + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + vad2=ResParseVarAdr(fhb,s1,s2); + + if(!vad||!vad2) + berr(ERR_PARSE_SYNTAX); + *vad=*vad2; + + break; + + case C2('c','l'): // clear var + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + *vad=0; + + break; + case C2('s','i'): // set var with integer + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&b); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + *vad=b; + + break; + case C2('a','i'): // add var with integer + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&b); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + b+=(int)*vad; + *vad=b; + + break; + + case C2('s','f'): // set var with float + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'f',0,&f1); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + *((float*)vad)=f1; + + break; + + case C2('a','f'): // add float to float var + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'f',0,&f1); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + f1+=*((float*)vad); + *((float*)vad)=f1; + + + break; + + case C2('s','s'): // set var with adr of string + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + *((char**)vad)=s1; + + break; + + case C2('s','2'): // set 2 conseq vars with adr of string s1 & s2 + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + + if(!vad) + berr(ERR_PARSE_SYNTAX); + *((char**)vad)=s1; + + b=fhb->varBuf[BINBUF_SIZE]; + + if(++vad>=&fhb->varBuf[b]) + {BP(BP_RESPBIN);break;} // 2d var didn't fit + + *((char**)vad)=s2; + + break; + + + case C2('r','b'): // reset bin + bin[BINBUF_NEXT]=BINBUF_FIRST; + break; + case C2('r','p'): // pop one return + if(fhb->radepth) + fhb->radepth--; + break; + case C2('r','P'): // pop all returns + fhb->radepth=0; + break; + case C2('r','i'): // rand int -- bin(ri ) + ResParseRaw(fhb,&s1,&s2,NUL); + vad=ResParseVarAdr(fhb,s1,s2); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&a); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&b); + + b-=a; + b++; + + b=RandU(b); + a+=b; + + *vad=a; + + break; + } // switch + } // for + + ec=0; +BAIL: + return ec; +} // respBIN() + +// JFL 16 Dec 04 +int respLOAD(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + char buf[128],msg[256]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + if(buf[0]=='$') + { + if(buf[1]=='s' && buf[2]=='t' && buf[3]=='r') + { + szto(4+buf,NUL,'i',0,&ec); + if((ec<0) || (ec>=COUNT(SysG.str))) + berr(1); + + szncpy(buf,SysG.str[ec],sizeof(buf)); + } + else + berr(2); + } // var + + if((ec=ResLoad(NUL,buf))<0) + { + szbuild(msg,sizeof(msg),"Couldn't load %s",buf); + errlog(msg); + } + + ec=0; +BAIL: + return ec; +} // respLOAD() + +// JFL 16 Dec 04 +int respADD(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + char buf[128],msg[256]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseRaw(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + if(buf[0]=='$') + { + if(buf[1]=='s' && buf[2]=='t' && buf[3]=='r') + { + szto(4+buf,NUL,'i',0,&ec); + if((ec<0) || (ec>=COUNT(SysG.str))) + berr(1); + + szncpy(buf,SysG.str[ec],sizeof(buf)); + } + else + berr(2); + } + + if((ec=GameCallback(GAMECALLBACK_ADD_RES,buf,NUL))<0) + { + szbuild(msg,sizeof(msg),"Couldn't add %s",buf); + errlog(msg); + } + ec=0; +BAIL: + return ec; +} // respADD() + +// JFL 08 Feb 05 +int resColFunc(int t,void *vp1,void *vp2,void* vp3) +{ + ObjColAct *cola; + MsgColInfo *mci; + Obj *o; + int sig; + + if(t!=OBJCOLFUNC_MCI) + return -1; + + if(!(cola=vp1) || !(mci=vp2)) + return -2; + + sig=0; + + // find parent + if((o=N2Parent(cola))) + ObjSignal(o,sig|M_OBJSIGNAL_IMMEDIATE,mci); + + return 0; +} // resColFunc() + +// JFL 17 Jan 05 +// JFL 08 Feb 05 +// JFL 07 Apr 05; props & prop col +// JFL 25 May 05; shadows for skeletons +int respCREATE(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2,*n1,*n2,*a1,*a2,*p1,*p2,*nn1,*nn2,*sk1,*sk2,*sh1,*sh2; + char *k1,*k2,*c1,*c2,*lod1,*lod1end,*lod2,*lod2end; + char buf[PM_NAME_SIZE]; + Res *r1,*r2; + void *d; + int n; + uns u; + Obj *o,*o2,*o3; + uns8 *p; + N2 *nlink; + uns8 addvel=0,addcol=0,addseq=0,pushpop=0,kidflag=0,setn=0,addsh=0; + uns8 setmat=0,newname=0,addsk=0,findres=0,addkan=0,addsav=0,addotl=0; + uns8 aftersh=0,addLod1=0,addLod2=0; + int8 usemark=0; + uns flgs,sub=0,size,minor,numjoints; + memu *vad; + ResDataCol *col; + N2ScanRec nsr; + + // clear binbuf + BINBUFSET(fhb,0,0); // obj + BINBUFSET(fhb,1,0); // seq + BINBUFSET(fhb,2,0); // vel + BINBUFSET(fhb,3,0); // col + BINBUFSET(fhb,4,0); // root-kan + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name & ani + ResParseRaw(fhb,&n1,&n2,NUL); + + // default obj create flags + flgs=M_OBJNEW_KIDS|M_OBJNEW_KIDFIRST|M_OBJNEW_DONTLINK; + nlink=NUL; // set to obj to link to or NUL + size=0; + + for(;;) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + if(s1[0]==')') + break; + if(s1[0]=='.') + { + switch(s1[1]) + { + case 'a': // keyframe anim + k1=NUL; + addkan=1; + if(s1[2]=='=') + { + fhb->str=s1+3; + ResParseRaw(fhb,&k1,&k2,NUL); // get name + } + break; + case 'c': // col + if(s1[2]=='2') + { + addcol=2; + break; + } + addcol=1; + c1=NUL; + if(s1[2]=='=') + { + fhb->str=s1+3; + ResParseRaw(fhb,&c1,&c2,NUL); // get name + } + break; + case 'd': + if((s1[2]=='s') && (s1[3]=='a') && (s1[4]=='v')) + { + fhb->str=s1+5; + addsav=1; + } + else + berr(ERR_PARSE_SYNTAX); // unrecognized + break; + case 'f': // find + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + ResParseRaw(fhb,&s1,&s2,NUL); // get name + if(!(findres=sz2map(ResResSubTable,s1,s2))) + berr(ERR_PARSE_SYNTAX); // unrecognized type + break; + case 'k': // kidfirst/kidlast + if(s1[2]=='f') + flgs|=M_OBJNEW_KIDFIRST; + else if(s1[2]=='l') + flgs&=~M_OBJNEW_KIDFIRST; + break; + case 'l': // link + // .lb -- link before mark + // .la -- link after mark + // .l -- link after mark (depricated) + // .lb= -- link before node + // .la= -- link after node + // .lbk= -- link before node 's kid list + // .lak= -- link after node 's kid list + if(s1[2]=='b') + s1++,usemark=-1; + else if(s1[2]=='a') + s1++,usemark=1; + kidflag=0; + if(s1[2]=='k') + s1++,kidflag=1; + if(s1[2]=='=') + { + fhb->str=3+s1; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + + if((vad=ResParseVarAdr(fhb,s1,s2))) + nlink=(void*)*vad; + if(kidflag) + { + if(nlink->flags&M_N2_KIDLIST) + nlink=N2KIDLIST(nlink); + } + } + + if((s1[1]=='l') && (s1[2]=='o') && (s1[3]=='d')) + { + if(s1[4]=='1') + { + addLod1=1; + fhb->str=s1+6; + ResParseRaw(fhb,&lod1,&lod1end,NUL); // get name + } + if(s1[4]=='2') + { + addLod2=1; + fhb->str=s1+6; + ResParseRaw(fhb,&lod2,&lod2end,NUL); // get name + } + } + break; + + case 'm': // mat + if(s1[2]=='s') + setmat=1; + break; + case 'n': // new name + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + newname=1; + ResParseRaw(fhb,&nn1,&nn2,NUL); // get name + break; + case 'p': + if(s1[2]=='p') // push&pop mat + pushpop=1; + else if((s1[2]=='n') && (s1[3]=='=')) // parameter-n + { + setn=1; + fhb->str=s1+4; + ResParseRaw(fhb,&p1,&p2,NUL); // n (parameter) + } + break; + case 's': // seq + if(s1[2]=='=') + { + fhb->str=s1+3; + addseq=1; + ResParseRaw(fhb,&a1,&a2,NUL); // get name + } + else if((s1[2]=='k') && (s1[3]=='=')) + { + fhb->str=s1+4; + addsk=1; + ResParseRaw(fhb,&sk1,&sk2,NUL); + } + else if((s1[2]=='h') && (s1[3]=='=')) + { + fhb->str=s1+4; + addsh=addsav=1; + addotl=1; // add tmp link field + aftersh=1; // draw obj after shadows + ResParseRaw(fhb,&sh1,&sh2,NUL); + } + else + berr(ERR_PARSE_SYNTAX); + break; + case 't': // type + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + ResParseRaw(fhb,&s1,&s2,NUL); // get name + sub=sz2map(ResObjSubTable,s1,s2); + + #if SAFE + if(!sub) + BP(BP_RESPCREATE); // unrecognized type + if(sub==OBJSUB_SEQRES) + BP(BP_RESPCREATE2); // dont do this, use ani(- xx) + #endif // SAFE + + break; + case 'v': // vel + addvel=1; + break; + } // switch + } + } // for + + // + // OBJ + // + + o=o2=NUL; + r1=NUL; + d=NUL; + + if(sub) + { + if(sub>=COUNT(resObjCreateSizes)) + berr(-1); + size=resObjCreateSizes[sub]; + goto gotrd; + } + + if(!(s2=szchr(n1,n2,'.'))) + { + // jjj -- joe, make sure this snippet fits into your worldview + // look for res 'name' + if(n1[0]=='$' && n1[1]=='s'&&n1[2]=='t'&&n1[3]=='r') + { + szto(4+n1,NUL,'i',0,&ec); + if((ec>=0) || (eclnk.sub) + { + case RESSUB_LIGHT: + sub=OBJSUB_LIGHTRES; + size=sizeof(ObjLightRes); + break; + case RESSUB_DISP1: + case RESSUB_DISP2: + case RESSUB_DISP3: + if(!(d=r1->data)) + goto ocreated; + sub=OBJSUB_DISPRES; + size=sizeof(ObjDispRes); + break; + case RESSUB_FUNC1: + minor=FTYPE_1; + goto func_data; + case RESSUB_FUNC2: + minor=FTYPE_2; + goto func_data; + case RESSUB_FUNC3: + minor=FTYPE_3; +func_data: + if(!(d=r1->data)) + goto ocreated; + sub=OBJSUB_FUNC; + size=sizeof(ObjFunc); + break; + + } // switch +gotrd: + // + // create obj + // + + if(!size) + berr(-1); // something's wrong.. missed the size + + if(!usemark) + ObjSetLinkName("3dz"); + + // otl is tmp link field immediately after the object + // only setup in OBJSUB_DISPRES + if(addotl) + size+=sizeof(ObjTmpLink); + + if((ec=ObjNew(&o,sub,size,flgs))<0) + goto BAIL; + + // flags + if(pushpop) + o->lnk.flags|=M_N2OBJ_PUSHPOPMAT; + + if(!nlink) + nlink=ObjGetLinkObj(); + if(nlink) + { + if(usemark<=0) + N2LinkBefore(nlink,o); + else + N2LinkAfter(nlink,o); + } + + // + // setup + // + + // buf will be filled with the name + if(!newname) + szncpy2(buf,n1,n2,sizeof(buf)); + else + szncpy2(buf,nn1,nn2,sizeof(buf)); + + switch(sub) + { + case OBJSUB_STR: + szncpy(((ObjStr*)o)->name,buf,sizeof(((ObjStr*)o)->name)); + break; + case OBJSUB_DISPRES: + ((ObjDispRes*)o)->res=r1; + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_NOAUTOCOL; + if(addkan) + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_NOAUTOANI; + if(addotl) + { + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_HASTMPLINK; + + d=1+((ObjDispRes*)o); + ((ObjTmpLink*)d)->tmpLnk.type=N2TYPE_OBJ; + ((ObjTmpLink*)d)->tmpLnk.sub=OBJSUB_TMPLINK; + ((ObjTmpLink*)d)->data=o; // tmp link data points to display object + } // tmp link + if(aftersh) + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_AFTERSHADOWS; + ObjResolveDisp((void*)o); + break; + case OBJSUB_FUNC: + szncpy(((ObjFunc*)o)->name,buf,sizeof(((ObjFunc*)o)->name)); + ((ObjFunc*)o)->func=d; + ((ObjFunc*)o)->ftype=minor; + + // set parameter-n + if(setn && p1) + { + szto(p1,p2,'i',0,&ec); + ((ObjFunc*)o)->n=ec; + } // setn + + break; + case OBJSUB_GROUP: + szncpy(((ObjGroup*)o)->name,buf,sizeof(((ObjGroup*)o)->name)); + break; + case OBJSUB_VEL: + // flags + if(setmat) + ((ObjVel*)o)->flags|=M_OBJVEL_SETMAT; + break; + case OBJSUB_COLACT: + ((ObjColAct*)o)->flags|=M_OBJCOLACT_COLFUNC; + ((ObjColAct*)o)->colfunc=resColFunc; + break; + case OBJSUB_MARKER: + szncpy(((ObjMarker*)o)->name,buf,sizeof(((ObjMarker*)o)->name)); + break; + case OBJSUB_LIGHTRES: + + if(r1) + { + ((ObjLightRes*)o)->res=r1; + break; + } + + // jjj -- code not tested yet.. + + // this allocs the obj, a dummy res, and res data in one alloc + // the dummy res is not linked anywhere + #if SAFE + if(size!=(sizeof(ObjLightRes)+sizeof(Res)+sizeof(ResDataLight))) + {BP(BP_RESPCREATE3);break;} + #endif // SAFE + r1=(void*)&((ObjLightRes*)o)[1]; + d=(void*)&r1[1]; + ((ObjLightRes*)o)->res=r1; + szncpy(r1->name,buf,sizeof(r1->name)); + r1->data=d; + break; + } // switch + + // set binbuf + BINBUFSET(fhb,0,o); + + } // add one from group +ocreated: + + // only add extension objects if the primary object was created + if(!o) + err(1); + + // + // CREATE FLAGGED CHILDREN + // + + // get obj to link to + nlink=NUL; + if(o->lnk.flags&M_N2_KIDLIST) + nlink=N2KIDLIST(o); + + // + // SKEL + // + + if(addsk) + { + + if(sk1[0]=='-') + sk1=n1,sk2=n2; // same name + + if(!(s2=szchr(sk1,sk2,'.'))) + { + // skel + szncpy2(buf,sk1,sk2,sizeof(buf)); + if(!(r1=ResFindSubNth(NUL,buf,RESSUB_SKEL,NUL))) + berr(-1); // couldn't find skeleton res + } + else + { + szncpy2(buf,sk1,s2,sizeof(buf)); + if(!(r2=ResFindSubNth(NUL,buf,RESSUB_GROUP,NUL))) + berr(-2); + s2++; + szncpy2(buf,s2,sk2,sizeof(buf)); + + // skel -- same name as geo + if(!(r1=ResFindSubNth((void*)r2,buf,RESSUB_SKEL,NUL))) + berr(-1); // couldn't find skeleton res + } + + if(!(d=r1->data)) + berr(-2); // skel data invalid + + // + // SKELETON + // + + n=((ResDataSkel*)d)->numJoints; + numjoints=n; + u =n*sizeof(float)*VM_SIZE; // alloc a vm for joint position + u+=n*sizeof(float)*VM_SIZE; // alloc for bindMats + u+=sizeof(ObjSkelRes); + if((ec=ObjNew(&o2,OBJSUB_SKELRES,u,M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkBefore(N2KIDLIST(o),o2); + + ((ObjSkelRes*)o2)->numJoints=n; + + p=(void*)&((ObjSkelRes*)o2)[1]; + ((ObjSkelRes*)o2)->jointMats=(void*)p; + + p+=n*sizeof(float)*VM_SIZE; + ((ObjSkelRes*)o2)->bindMats=(void*)p; + + // add animations to the skeleton bones + ObjSkelAddAnims((void*)o2,r1); + + o3=o2; + + // + // SKELCOL + // + + if(!(r1=ResFindSubNth(NUL,buf,RESSUB_COL,NUL))) + goto skelcold; // no skelcol + + if(!(col=r1->data)) + berr(-2); // data invalid + if(col->type!=RESDATACOLTYPE_SKEL) + berr(-3); // wrong col type -- need skelcol + + if((ec=ObjNew(&o2,OBJSUB_COLRES,sizeof(ObjColRes), + M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkAfter(N2KIDLIST(o),o2); + ((ObjColRes*)o2)->res=r1; + + if((o->lnk.type==N2TYPE_OBJ)&&(o->lnk.sub==OBJSUB_DISPRES)) + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_SKELCOL; +skelcold: + + // + // ROOT-ANIM + // + + if((ec=ObjNew(&o2,OBJSUB_ANIRES,sizeof(ObjAniRes), + M_OBJNEW_DONTLINK))<0) + goto BAIL; + szncpy(((ObjAniRes*)o2)->name,"root",sizeof(((ObjAniRes*)o2)->name)); + N2LinkBefore(N2KIDLIST(o),o2); + + // result + BINBUFSET(fhb,4,o2); // root-kan + + // set the skeleton's root kan + ((ObjSkelRes*)o3)->rootDriver=o2; + + // + // DISP SAVE + // + if(!addsav) + goto skelsavd; + + if(o->lnk.sub==OBJSUB_DISPRES) + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_SAVE; + + u=sizeof(ObjDispSave); + u+=2*numjoints*sizeof(float)*VM_SIZE; // alloc a vm for joint position + if((ec=ObjNew(&o2,OBJSUB_DISPSAVE,u,M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkBefore(N2KIDLIST(o),o2); + ((ObjDispSave*)o2)->flags|=M_OBJDISPSAVE_BIND; // need to set bindMats + ((ObjDispSave*)o2)->numJoints=numjoints; + s1=(void*) (1+((ObjDispSave*)o2)); + ((ObjDispSave*)o2)->jointMats=(void*)s1; + s1+=numjoints*sizeof(float)*VM_SIZE; + ((ObjDispSave*)o2)->bindMats=(void*)s1; + +skelsavd: + + // + // SHADOW + // + +addshadow: // jjj -- tmp for testing if skel has same shadow code + + if(!addsh) + goto skelshd; + + if(sh1[0]=='-') + sh1=n1,sh2=n2; // same name + + // find shadow resource + if(!(s2=szchr(sh1,sh2,'.'))) + { + // shadow + szncpy2(buf,sh1,sh2,sizeof(buf)); + if(!(r1=ResFindSubNth(NUL,buf,RESSUB_DISP4,NUL))) + berr(-1); // couldn't find shadow res + } + else + { + szncpy2(buf,sh1,s2,sizeof(buf)); + if(!(r2=ResFindSubNth(NUL,buf,RESSUB_GROUP,NUL))) + berr(-2); + s2++; + szncpy2(buf,s2,sh2,sizeof(buf)); + + // shad -- same name as geo + if(!(r1=ResFindSubNth((void*)r2,buf,RESSUB_DISP4,NUL))) + berr(-1); // couldn't find shadow res + } + + if(!(d=r1->data)) + berr(-2); // skel data invalid + + // create shadow display object + u =sizeof(ObjDispRes); + u+=sizeof(ObjTmpLink); + if((ec=ObjNew(&o2,OBJSUB_DISPRES,u,M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkBefore(N2KIDLIST(o),o2); + ((ObjDispRes*)o2)->res=r1; + ((ObjDispRes*)o2)->flags|=M_OBJDISPRES_NOAUTOCOL|M_OBJDISPRES_HASTMPLINK; + d=1+((ObjDispRes*)o2); + ((ObjTmpLink*)d)->tmpLnk.type=N2TYPE_OBJ; + ((ObjTmpLink*)d)->tmpLnk.sub=OBJSUB_TMPLINK; + ((ObjTmpLink*)d)->data=o2; // tmp link data points to display object +skelshd:; + } // add skel + else + { + // not skel + + if(addsh) + { + + if(!addsav) + goto propsavd; + + // + // create DISPSAVE node + // + + if(o->lnk.sub==OBJSUB_DISPRES) + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_SAVE; + u=sizeof(ObjDispSave); + u+=sizeof(float)*VM_SIZE; // alloc a vm for joint position + if((ec=ObjNew(&o2,OBJSUB_DISPSAVE,u,M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LinkBefore(N2KIDLIST(o),o2); + ((ObjDispSave*)o2)->flags|=M_OBJDISPSAVE_SINGLE; + s1=(void*) (1+((ObjDispSave*)o2)); + ((ObjDispSave*)o2)->jointMats=(void*)s1; // use jointMats for vmat +propsavd: + + goto addshadow; // jjj -- tmp to test if same code works.. + } + } // not skel + + // + // VEL + // + + if(addvel) + { + // create vel obj before sequence so sequence can use it + + if(nlink) + flgs=M_OBJNEW_DONTLINK; + else + flgs=M_OBJNEW_LINKBEFORE; + + if((ec=ObjNew(&o2,OBJSUB_VEL,sizeof(ObjVel),flgs))<0) + goto BAIL; + + if(nlink) + N2LinkBefore(nlink,o2); + + // copy initial position + if(o + && (o->lnk.type==N2TYPE_OBJ) + && (o->lnk.sub==OBJSUB_DISPRES) + && (r1=((ObjDispRes*)o)->res) + && (d=r1->data) + && !(((ResDataDisp0*)d)->mode&M_RESDISPMODE_VMAT) + ) + { + s1=NUL; + switch(r1->lnk.sub) + { + case RESSUB_DISP2: + s1=(void*)((ResDataDisp2*)d)->vmat; + break; + case RESSUB_DISP3: + s1=(void*)((ResDataDisp3*)d)->vmat; + break; + } // switch + if(s1) + { + ((ObjVel*)o2)->rot[0]=((VMType*)s1)->a[VM_RX]; + ((ObjVel*)o2)->rot[1]=((VMType*)s1)->a[VM_RY]; + ((ObjVel*)o2)->rot[2]=((VMType*)s1)->a[VM_RZ]; + ((ObjVel*)o2)->trans[0]=((VMType*)s1)->a[VM_TX]; + ((ObjVel*)o2)->trans[1]=((VMType*)s1)->a[VM_TY]; + ((ObjVel*)o2)->trans[2]=((VMType*)s1)->a[VM_TZ]; + ((ObjVel*)o2)->scale[0]=((VMType*)s1)->a[VM_SX]; + ((ObjVel*)o2)->scale[1]=((VMType*)s1)->a[VM_SY]; + ((ObjVel*)o2)->scale[2]=((VMType*)s1)->a[VM_SZ]; + } + } // initial position + + // flags + if(setmat) + ((ObjVel*)o2)->flags|=M_OBJVEL_SETMAT; + + // result + BINBUFSET(fhb,2,o2); + } // vel + + // + // COL + // + + if(addcol) + { + if(!c1) + {BP(BP_RESPCREATE4);goto cold;} + nsr.s1=c1; + nsr.s2=c2; + r1=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_NAME|M_N2SCAN_SUB|RESSUB_COL,ResLoadedFirst()); + if(!r1) + {BP(BP_RESPCREATE5);goto kand;} + + if(!(d=r1->data)) + berr(-2); // data invalid + + if(o && (o->lnk.type==N2TYPE_OBJ) && (o->lnk.sub==OBJSUB_DISPRES)) + ((ObjDispRes*)o)->flags|=M_OBJDISPRES_PROPCOL; + + // + // create col obj before sequence so sequence can use it + // + + if(nlink) + flgs=M_OBJNEW_DONTLINK; + else + flgs=M_OBJNEW_LINKBEFORE; + + if((ec=ObjNew(&o2,OBJSUB_COLRES,sizeof(ObjColRes),flgs))<0) + goto BAIL; + + if(nlink) + N2LinkBefore(nlink,o2); + + ((ObjColRes*)o2)->res=r1; + + // result + BINBUFSET(fhb,3,o2); + + // + // + // + + } // col +cold: + + // + // ANI + // + + if(addseq) + { + szncpy2(buf,a1,a2,sizeof(buf)); + if((r1=ResFindSubNth(NUL,buf,RESSUB_SEQ,NUL))) + { + if((ec=ObjSeqStart(nlink,r1,&o2))<0) + goto seqd; + } + else + { + BP(BP_RESPCREATE6); + goto seqd; + } + + // result + BINBUFSET(fhb,1,o2); + } // seq +seqd: + + if(addkan) + { + if((ec=ObjNew(&o2,OBJSUB_ANIRES,sizeof(ObjAniRes), + M_OBJNEW_DONTLINK))<0) + goto BAIL; + N2LevelCpy((void*)o2,(void*)o); // these go together + // jjj -- do another pass on ObjNew & levels + szncpy(((ObjAniRes*)o2)->name,"root",sizeof(((ObjAniRes*)o2)->name)); + N2LinkBefore(N2KIDLIST(o),o2); + + // result + BINBUFSET(fhb,4,o2); // root-kan + + if(k1) + { + nsr.s1=k1; + nsr.s2=k2; + r1=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_NAME|M_N2SCAN_SUB|RESSUB_KAN,ResLoadedFirst()); + if(!r1) + {BP(BP_RESPCREATE7);goto kand;} + ObjAniResSwitch((void*)o2,r1); + + } // k1 + } // kan +kand: + + // + // LOD + // + + if(addLod1||addLod2) + { + //LOD level 1 + if(addLod1) + { + if(lod1[0]=='$' && lod1[1]=='s' && lod1[2]=='t' && lod1[3]=='r') + { + szto(4+lod1,NUL,'i',0,&ec); + if((ec>=0) || (ec=0) || (ecroot; + t=1; // signal this obj + } + else if(n1[0]=='$') + { + if(!fhb->varBuf) + err(ERR_PARSE_SETUP); + szto(1+n1,NUL,'i',0,&n); + n+=BINBUF_FIRST; + if((n(int)fhb->varBuf[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + o=(void*)fhb->varBuf[n]; + t=1; // signal this obj + } + else if(n1[0]=='^') + { + if(n1[1]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=szto(2+n1,NUL,'i',0,&m); + t=2; // signal tag + } + else + err(-1); + + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,NUL,'i',0,&n); + + if(t==1) + { + if(!o) + err(1); + + if((ec=ObjSignal(o,n,NUL))<0) + goto BAIL; + + } + else if(t==2) + { + if((ec=ObjTagSignal(m,n,NUL))<0) + goto BAIL; + } + else + err(-2); + + ec=0; +BAIL: + ResParsePAREN(fhb); + return ec; +} // respSEND() + +// JFL 03 Jan 04 +int respRUN(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + char buf[128];//,msg[256]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseTok(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + ResRunCommandFile(buf); + + ec=0; +BAIL: + return ec; +} // respRUN() + +// JFL 16 Dec 04 +int respTIME(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + uns u; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + while(1) + { + ec=ResParseTok(fhb,&s1,&s2,NUL); + switch(ec) + { + case ERR_PARSE_EOF: + goto BAIL; + case RESPARSE_PARENCLOSE: + err(2); + case RESPARSE_WAVE: + s1=szskipover(s2,str_equal); + s1=szto(s1,NUL,'u',10,&u); + respAdvTok(fhb,s1); + GameCallback(GAMECALLBACK_SET_WAVE_TIME,(void*)u,NUL); + break; + } // switch + } // while + + ec=0; +BAIL: + return ec; +} // respTIME() + +// JFL 29 Dec 04 +int respIF(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + int n; + uns u; + memu *var=fhb->varBuf; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + ec=ResParseTok(fhb,&s1,&s2,NUL); + u=0; + if(s1[0]=='$') + { + if(!var) + err(ERR_PARSE_SETUP); + szto(1+s1,NUL,'i',0,&n); + n+=BINBUF_FIRST; + if((n(int)var[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + u=var[n]; + } + else if(C_IS_DIGIT(*s1)) + szto(s1,NUL,'u',0,&u); + + if(!u) + { + // skip to matching paren + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + } + else + { + // don't skip, parse + fhb->depth++; // not currently used.. + } + + ec=0; +BAIL: + return ec; +} // respIF() + +// JFL 03 Jan 04 +int respVERS(ResParseH *fhb,Res *res) +{ + int ec; + + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>%d.%d.%d", + MAJOR_VERSION,MINOR_VERSION,SUB_MINOR_VERSION); + + ec=0; +//BAIL: + return ec; +} // respVERS() + +// JFL 04 Jan 04 +// JFL 06 Apr 05 +int respINFO(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + int var; + void *d; + char buf[128]; + memu *vad; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + var=ResParseTok(fhb,&s1,&s2,NUL); + + switch(var) + { + case RESPARSE_DISP: + if(fhb->outBuf) + { + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>texAllocs=%d\n", + VidDisp.texAllocs); + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>texMem=%d\n", + VidDisp.texMem); + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>oDList=%d\n", + VidDisp.objDListCount); + } + break; + case RESPARSE_LOG: + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>%s",SysG.log); + break; + case RESPARSE_SEQ: + if(ResParseTok(fhb,&s1,&s2,NUL)<0) + break; + szncpy2(buf,s1,s2,sizeof(buf)); + if(ResGen(RESGEN_GET_NAMED_RESDATASEQ,buf,&d)<0) + break; + if(ResGen(RESGEN_RESDATASEQ_TO_BUF,d,&s1)<0) + break; + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>%s",s1); + break; + case RESPARSE_MEM: + if(fhb->outBuf) + { + ec=szlen(fhb->outBuf); + MemInfo(fhb->outBuf+ec,fhb->outBufSize-ec); + } + break; + case RESPARSE_SOUND: + if(fhb->outBuf) + { + ec=szlen(fhb->outBuf); + SndInfo(fhb->outBuf+ec,fhb->outBufSize-ec); + } + break; + case RESPARSE_COL: + if(ResParseTok(fhb,&s1,&s2,NUL)<0) + break; + szncpy2(buf,s1,s2,sizeof(buf)); + if(ResGen(RESGEN_GET_NAMED_RESDATACOL,buf,&d)<0) + break; + + ec=szlen(fhb->outBuf); + s1=fhb->outBuf; + s1+=ec; + ec=fhb->outBufSize-ec; + if(ResGen(RESGEN_RESDATACOL_TO_BUF|(ec<type==N2TYPE_RES && ((N2*)d)->sub==RESSUB_KAN) + { + ec=szlen(fhb->outBuf); + s1=fhb->outBuf; + s1+=ec; + ec=fhb->outBufSize-ec; + if(ResGen(RESGEN_RESDATAKAN_TO_BUF|(ec<type==N2TYPE_RES && ((N2*)d)->sub==RESSUB_GROUP) + { + ec=szlen(fhb->outBuf); + s1=fhb->outBuf; + s1+=ec; + ec=fhb->outBufSize-ec; + if(ResGen(RESGEN_RESANIGROUP_TO_BUF|(ec<outBuf); + s1=fhb->outBuf; + s1+=ec; + ec=fhb->outBufSize-ec; + if(ResGen(RESGEN_RESDATALIGHT_TO_BUF|(ec<outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>%S",fmt1,fmt2); + + ec=0; +BAIL: + // skip to matching paren + ResParsePAREN(fhb); + + return ec; +} // respPRINT() + +typedef struct { + ResParseH *fhb; +} ResFCPar; + +// JFL 06 Jan 04 +int respFC(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2,*n1,*n2; + ResDataFTOne *ft; + void *d,*root; + ResFCPar fcpmem,*fcp=&fcpmem; + char *finished=NUL; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + if((ec=ResParseRaw(fhb,&n1,&n2,NUL))<0) + goto BAIL; + + // find where we need to end in case function grabs too many parameters + s1=fhb->str; + ResParsePAREN(fhb); + finished=fhb->str; + fhb->str=s1; + + if((ft=ResFindFT(NUL,n1,n2))) + { + if(!ft->adr) + err(1); + switch(ft->ftype) + { + case FTYPE_1: + (*((ftype1*)ft->adr))(); + break; + case FTYPE_2: + root=NUL; + + if((res->lnk.sub==RESSUB_PARSE) && (d=res->data)) + root=((ResDataParse*)d)->root; + + (*((ftype2*)ft->adr))(root); + break; + + case FTYPE_3: + root=NUL; + + if((res->lnk.sub==RESSUB_PARSE) && (d=res->data)) + root=((ResDataParse*)d)->root; + + fcp->fhb=fhb; + + if((ec=(*((ftype3*)ft->adr))(root,fcp))<0) + fhb->fail=1; + break; + + } // switch + } + + ec=0; +BAIL: + // jump to matching paren + if(finished) + fhb->str=finished; + else + ResParsePAREN(fhb); + return ec; +} // respFC() + +// JFL 06 Jan 05 +int ResFCPNext(void *vfcp,char type,int n,void *dst) +{ + int ec; + char *s1,*s2; + ResFCPar *fcp=vfcp; + + if((ec=ResParseRaw(fcp->fhb,&s1,&s2,resTokTerm))<0) + goto BAIL; + + switch(type) + { + case 's': + szncpy2(dst,s1,s2,n); + break; + case 'S': + *((char**)dst)=s1; + break; + default: + szto(s1,s2,type,n,dst); + } // switch + + ec=0; +BAIL: + return ec; +} // ResFCPNext() + +// JFL 17 Jan 05 +int ResFCPCmd(void *vfcp,int cmd,void *a,void *b) +{ + int ec,n; + memu *m; + char *s1,*s2; + ResParseH *fhb; + ResFCPar *fcp=vfcp; + Obj *o; + + switch(cmd&M_RESFCP_CMD) + { + case RESFCP_GETVARS: + // (memu**)varptr -- returns number of vars + if(!fcp->fhb) + err(ERR_INTERNAL); + if(!(m=fcp->fhb->varBuf)) + { + if(a) + *((int*)a)=0; + break; + } + if(a) + *((memu**)a)=&m[BINBUF_FIRST]; + ec=m[BINBUF_SIZE]-BINBUF_FIRST; + goto BAIL; + break; + case RESFCP_PARSE_VAR: + + if(!(fhb=fcp->fhb)) + err(-1); + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(!s1||(*s1!='$')) + err(-2); + + if(!fhb->varBuf) + err(ERR_PARSE_SETUP); + szto(1+s1,NUL,'i',0,&n); + n+=BINBUF_FIRST; + if((n(int)fhb->varBuf[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + if(a) + *((memu*)a)=fhb->varBuf[n]; + break; + case RESFCP_PARSE_VAD: + + if(!(fhb=fcp->fhb)) + err(-1); + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(!s1||(*s1!='$')) + err(-2); + + if(!fhb->varBuf) + err(ERR_PARSE_SETUP); + szto(1+s1,NUL,'i',0,&n); + n+=BINBUF_FIRST; + if((n(int)fhb->varBuf[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + if(a) + *((memu**)a)=&fhb->varBuf[n]; + break; + case RESFCP_GETANDCLEAR_SIGNALDATA: + case RESFCP_GET_SIGNALDATA: + if(!(fhb=fcp->fhb)) + berr(-1); + if(!(o=fhb->root)) + berr(-2); + if((o->lnk.type!=N2TYPE_OBJ)||(o->lnk.sub!=OBJSUB_SEQRES)) + berr(-3); + if(a) + *((void**)a)=((ObjSeqRes*)o)->sigdata; + if((cmd&M_RESFCP_CMD)==RESFCP_GETANDCLEAR_SIGNALDATA) + ((ObjSeqRes*)o)->sigdata=NUL; + break; + default: + err(-1); + } // switch + + ec=0; +BAIL: + return ec; +} // ResFCPCmd() + +// JFL 08 Jan 05 +// JFL 17 Jan 05; conditions & table +int respBR(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2,*b1,*b2,*opt; + ResRDSLab *lab; + int i,n; + uns u; + memu *var=fhb->varBuf; + Obj *o; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + if(!(lab=fhb->lab) || !fhb->nLab) + err(-1); + + // name + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + + // check for conditional + + b1=NUL; // no branch label + opt=NUL; // no options + + u=0; // need var + opt=NUL; + if(s1[0]=='.') + { + opt=s1; + switch(opt[1]) + { + case 't': // table + case 'z': // zero + case 'n': // non-zero + case 'l': // less + case 'g': // greater + u=1; // need var + break; + } // switch + } // option + else + { + b1=s1;b2=s2; // branch label + } + + // get var + if(u) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(s1[0]=='$') + { + if(!var) + err(ERR_PARSE_SETUP); + fhb->str=szto(1+s1,NUL,'i',0,&n); + if(n<0) + { + n=-n-1; + if(n>=COUNT(SysG.var)) + err(ERR_PARSE_RANGE); + u=SysG.var[n]; + } + else + { + n+=BINBUF_FIRST; + if((n(int)var[BINBUF_SIZE])) + err(ERR_PARSE_RANGE); + u=var[n]; + } + } + else + berr(ERR_PARSE_SYNTAX); + } // get var + + // test var & branch + + if(opt) + { + switch(opt[1]) + { + case 't': // table br(.t $3 zero one two) + u++; + if(u>0xfffff) + { + BP(BP_RESPBR); // seems kind of big.. + u=0; + } + while(u) + { + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) + break; + b1=s1;b2=s2; // set branch label + u--; + } // while + break; + case 'z': // on-zero br(.z $3 on-zero) + if(u) // not-zero + break; // dont branch + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) + break; + b1=s1;b2=s2; // set branch label + break; + case 'n': // on-notzero br(.nz $3 on-notzero) + if(!u) // zero + break; // dont branch + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) + break; + b1=s1;b2=s2; // set branch label + break; + case 'l': + if(opt[2]=='e') + { + // on-less br(.le $3 on-lessthanorequal) + if(!(((int)u)<=0)) // zero + break; // dont branch + } + else + { + // on-less br(.lt $3 on-lessthan) + if(!(((int)u)<0)) // zero + break; // dont branch + } + + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) + break; + b1=s1;b2=s2; // set branch label + break; + case 'g': + if(opt[2]=='e') + { + // on-less br(.ge $3 on-greaterthanorequal) + if(!(((int)u)>=0)) // zero + break; // dont branch + } + else + { + // on-less br(.gt $3 on-lessthan) + if(!(((int)u)>0)) // zero + break; // dont branch + } + + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) + break; + b1=s1;b2=s2; // set branch label + break; + case 'f': // flag based + if(opt[2]=='j') // M_OBJANIRES_JUMP + { + if((o=fhb->root)&&(o->lnk.sub==OBJSUB_SEQRES)) + if(((ObjSeqRes*)o)->flags&M_OBJANIRES_JUMP) + { + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) + break; + b1=s1,b2=s2; // branch + } + } + break; // flag + + } // switch + } // branch condition/type + + // + // BRANCH + // + + if(b1) // branch label + { + for(i=0;inLab;i++,lab++) + { + if(!sznicmp(b1,b2,lab->name,NUL,sizeof(lab->name))) + { + fhb->str=(void*)((memu)&lab->off+lab->off); + err(0); // success + } + } // for + } // branch + + if(b1) + BP(BP_RESPBR2); //couldn't find branch in b1 (mispelled?) + + ec=1; // branch not taken +BAIL: + if(ec) + { + // skip to matching paren only if we didn't take the branch + ResParsePAREN(fhb); + } + return ec; +} // respBR() + +// JFL 11 Jan 05 +int respFIND(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2,*t1,*t2,*n1,*n2; + N2 *o; + N2 *n; + uns u,f; + int t; + char buf[128]; + int8 paren=0; + N2ScanRec nsr; + memu *vad; + + BINBUFSET(fhb,0,0); + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + o=NUL; + for(;;) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(*s1==')') + {paren=1;goto done;} + switch(*s1) + { + case 'r': // res + ec=ResParseRaw(fhb,&t1,&t2,NUL); + ec=ResParseRaw(fhb,&n1,&n2,NUL); + szncpy2(buf,n1,n2,sizeof(buf)); + if((t=sz2map(ResResSubTable,t1,t2))) + o=ResFindSubNth(NUL,buf,t,NUL); + break; + case 'o': // obj + if(s1[1]=='b') + goto ob; + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) // subtype + {BP(BP_RESPFIND);break;} + if(!(t=sz2map(ResObjSubTable,s1,s2))) + {BP(BP_RESPFIND2);break;} // subtype not found + s1=szskipwhite(fhb->str); + s2=szskipto(s1,resTokTerm); + fhb->str=s2; + nsr.s1=s1; + nsr.s2=s2; + o=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_NODEEPER|M_N2SCAN_NAME + |M_N2SCAN_SUB|t,ObjActiveFirst()); + break; + case 'x': // ob= + break; +ob: + if(s1[2]!='=') + {BP(BP_RESPFIND3);break;} + fhb->str=3+s1; + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) // subtype + {BP(BP_RESPFIND4);break;} + if(!(vad=ResParseVarAdr(fhb,s1,s2))) + {BP(BP_RESPFIND5);break;} + if(!(o=(void*)*vad)) + {BP(BP_RESPFIND6);break;} + break; + case 's': + if(!o) + { + BP(BP_RESPFIND7); + break; + } + if(s1[1]=='k') + { + f=M_N2SCAN_KIDSONLY; + } + else + { + f=M_N2SCAN_WRAP|M_N2SCAN_NODEEPER; + } + if(ResParseRaw(fhb,&s1,&s2,NUL)<0) // subtype + {BP(BP_RESPFIND8);break;} + if(o->type==N2TYPE_OBJ) + { + if(!(t=sz2map(ResObjSubTable,s1,s2))) + {BP(BP_RESPFIND9);break;} // subtype not found + } + else if(o->type==N2TYPE_RES) + { + if(!(t=sz2map(ResResSubTable,s1,s2))) + {BP(BP_RESPFIND10);break;} // subtype not found + } + else + { + BP(BP_RESPFIND11); // type not handed + break; + } + s1=szskipwhite(fhb->str); + s2=szskipto(s1,resTokTerm); + fhb->str=s2; + nsr.s1=s1; + nsr.s2=s2; + o=N2Scan(&nsr,f|M_N2SCAN_INIT|M_N2SCAN_NAME + |M_N2SCAN_SUB|t,o); + break; + case 'l': // link + ec=ResParseRaw(fhb,&t1,&t2,NUL); + ec=ResParseRaw(fhb,&n1,&n2,NUL); + szncpy2(buf,n1,n2,sizeof(buf)); + u=0; + if(!sznicmp(t1,t2,"ran",NUL,-1)) + u=1; // root anim + else if(!sznicmp(t1,t2,"prime",NUL,-1)) + u=2; // parent + + if((n=fhb->root)) + { + for(n=n->next;n && (n!=fhb->root);n=n->next) + { + if(!n->type) + { + if(u==2) + { + n++; // to parent + if(!ObjIsSub(n,0)) + o=n; + goto done; // or fail + } + continue; // not looking for the parent + } + + if((u==1) + && (n->sub==OBJSUB_ANIRES) + && (((ObjAniRes*)n)->flags&M_OBJANIRES_ROOT)) + { + o=n; + goto done; + } // root anim + } // for + } + break; + } // switch + } // for + +done: + + // + // + // + + if(fhb->outBuf) + szbuild(fhb->outBuf,fhb->outBufSize,"<-cat>0x%x ",o); + + BINBUFSET(fhb,0,o); + + ec=0; +BAIL: + if(!paren) + ResParsePAREN(fhb); + return ec; +} // respFIND() + +// JFL 11 Jan 05 +int respRETURN(ResParseH *fhb,Res *res) +{ + int ec; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // parenclose + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + if(fhb->radepth) + { + fhb->str=fhb->rastack[--fhb->radepth]; + err(0); + } + + + fhb->depth--; + + ec=0; +BAIL: + return ec; +} // respRETURN() + + +extern bgendBozoChk(); + +int respBOZORET(ResParseH *fhb,Res *res) +{ + int ec=0; + + ec = respRETURN(fhb,res); + +//BAIL: + return ec; +} // respRETURN() + +// JFL 11 Jan 05 +int respFAIL(ResParseH *fhb,Res *res) +{ + int ec; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // parenclose + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + fhb->fail=1; + + ec=0; +BAIL: + return ec; +} // respFAIL() + +// JFL 11 Jan 05 +int respFLAG(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + N2 *o; + int max; + uns maska=0,masko=0; + char **map=NUL; + uns *val=NUL; + uns8 neg; + memu *vad; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + ec=ResParseRaw(fhb,&s1,&s2,NUL); + o=NUL; + if(s1[0]=='$') + { + if((vad=ResParseVarAdr(fhb,s1,s2))) + o=(void*)*vad; + } + + if(!o) + err(1); + + map=NUL; + switch(o->type) + { + case N2TYPE_OBJ: + if((ec=ObjIsSub(o,o->sub))<0) + goto BAIL; + switch(o->sub) + { + case OBJSUB_ANIRES: + map=resObjOARFlags; + val=resObjOARFlagv; + max=COUNT(resObjOARFlagv); + break; + case OBJSUB_VEL: + map=resObjOVFlags; + val=resObjOVFlagv; + max=COUNT(resObjOVFlagv); + break; + } // switch + break; + } // switch + if(!map) + err(2); + + for(;;) + { + neg=0; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + if(*s1=='-') + { + s1++; + neg=1; + } + if(s1[0]==')') + break; + ec=sz2map(map,s1,s2); + if((ec<1) || (ec>=max)) + {BP(BP_RESPFLAG);break;} + if(neg) + maska|=val[ec]; + else + masko|=val[ec]; + } // for + + // flip + maska=~maska; + + // + // + // + + switch(o->type) + { + case N2TYPE_OBJ: + switch(o->sub) + { + case OBJSUB_ANIRES: + ((ObjAniRes*)o)->flags&=maska; + ((ObjAniRes*)o)->flags|=masko; + break; + case OBJSUB_VEL: + ((ObjVel*)o)->flags&=maska; + ((ObjVel*)o)->flags|=masko; + break; + } // switch + break; + } // switch + + ec=0; +BAIL: + return ec; +} // respFLAG() + +// JFL 17 Jan 05 +// JFL 03 Mar 05; scale flag for ov +// JFL 17 May 05; flash color +// JFL 30 May 05; light res flags +int respOBJ(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + N2 *o,*k,*o2; + ObjVel *ov; + ObjSeqRes *os; + uns u; + uns16 cmd; + float f1; + memu *vad; + int rel,max; + uns maska,masko; + char **map=NUL; + uns *val=NUL; + uns8 neg; + Res *r; + char buf[PM_NAME_SIZE]; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // o & ov are kind of independent + // if o is reset, ov is also reset + // but ov can be changed on its own + o=NUL; + ov=NUL; + + for(;;) + { +loop: + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(s1[0]==')') + break; + + // load up if there is an assignment + cmd=(s1[0]<<8)|s1[1]; + + rel=0; + if((s1[2]=='+')&&(s1[3]=='=')) + { + rel=1; + fhb->str=s1+4; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + } + else if((s1[2]=='-')&&(s1[3]=='=')) + { + rel=-1; + fhb->str=s1+4; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + } + else if(s1[2]=='=') + { + fhb->str=s1+3; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + } + else + fhb->str=s1+2; + + // SPECIAL COMMANDS + + if((cmd==C2('o','b'))||!o) + { + if(cmd==C2('o','b')) + { + // switch objects + o=NUL; + ov=NUL; + os=NUL; + if(s1[0]=='$') + { + if(!(vad=ResParseVarAdr(fhb,1+s1,s2))) + { +oberr: + o=NUL; + goto loop; + } + + if(!(o=(void*)*vad)) + goto oberr; + } + else if(C_IS_DIGIT(s1[0])) + { + szto(s1,s2,'p',0,&o); + } + else if(s1[0]=='-') + o=fhb->root; + else + goto oberr; + cmd=0; + } + else + o=fhb->root; + + // + // try this o + // + + if(!o || (o->type!=N2TYPE_OBJ)) + goto oberr; + + k=NUL; + switch(o->sub) + { + case OBJSUB_VEL: + ov=(void*)o; + o2=o; + break; + case OBJSUB_SEQRES: + os=(void*)o; + o2=o; + break; + default: + if(o->flags&M_N2_KIDLIST) + o2=N2KIDLIST(o); + else + o2=o; + break; + } // switch + + // scan for first ov in kidlist + for(k=o2->next;k!=o2;k=k->next) + { + if(ov && os) + break; + if(k->sub==OBJSUB_VEL) + ov=(void*)k; + if(k->sub==OBJSUB_SEQRES) + os=(void*)k; + } // for + + if(ov) + ov->accTime=0; // reset time since last 'hit' + + } // ob + + // NORMAL COMMANDS + + switch(cmd) + { + case 0: + case C2('o','b'): // ob + break; + case C2('l','v'): // level + if(!o) goto oerr; + szto(s1,s2,'i',0,&ec); + N2LevelSet(o,ec); + break; + case C2('v','0'): // reset vel-time base + if(!ov) goto oerr; + GameCallback(GAMECALLBACK_GET_WAVE_TIME,(void*)&u,NUL); + ov->velTime0=u; + break; + case C2('v','1'): // vel timer max + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->maxTime=f1*RES_FRAME_TIME; + break; + case C2('s','t'): // stop + if(!ov) goto oerr; + ov->tacc[0]=ov->tacc[1]=ov->tacc[2]= + ov->tvel[0]=ov->tvel[1]=ov->tvel[2]=0; + ov->racc[0]=ov->racc[1]=ov->racc[2]= + ov->rvel[0]=ov->rvel[1]=ov->rvel[2]=0; + break; + case C2('o','f'): // off + if(!ov) goto oerr; + ov->flags|=M_OBJVEL_OFF; + break; + case C2('o','n'): // on + if(!ov) goto oerr; + ov->flags&=~M_OBJVEL_OFF; + break; + case C2('o','t'): // on/off toggle + if(!ov) goto oerr; + ov->flags^=M_OBJVEL_OFF; + break; + case C2('c','l'): // color + if(!o || (o->sub!=OBJSUB_DISPRES)) + {BP(BP_RESPOBJ);goto oerr;} // need o + szto(s1,s2,'u',0,&u); // aarrggbb + ((ObjDispRes*)o)->rgba[3]=(u>>24)&0xff; // a + ((ObjDispRes*)o)->rgba[0]=(u>>16)&0xff; // r + ((ObjDispRes*)o)->rgba[1]=(u>>8)&0xff; // g + ((ObjDispRes*)o)->rgba[2]=(u>>0)&0xff; // b + break; + case C2('d','s'): // res + if(!o || (o->sub!=OBJSUB_DISPRES)) + {BP(BP_RESPOBJ2);goto oerr;} // need o + if(!(r=((ObjDispRes*)o)->res)) + {BP(BP_RESPOBJ3);goto oerr;} // need r + ec=r->lnk.sub; + if((ec!=RESSUB_DISP2)&&(ec!=RESSUB_DISP3)) + {BP(BP_RESPOBJ4);goto oerr;} // wrong type + szncpy2(buf,s1,s2,sizeof(buf)); + if(!(r=ResFindSubNth(NUL,buf,ec,NUL))) + {BP(BP_RESPOBJ5);goto oerr;} // couldnt find res + ((ObjDispRes*)o)->res=r; + ObjResolveTex((void*)o,0); + break; + case C2('s','h'): // res + if(!o || (o->sub!=OBJSUB_CAM)) + {BP(BP_RESPOBJ6);goto oerr;} // need o + + szto(s1,s2,'f',0,&f1); + fhb->str++; + ((ObjCam*)o)->shake[0]=f1; + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'f',0,&f1); + fhb->str++; + ((ObjCam*)o)->shake[1]=f1; + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'f',0,&f1); + ((ObjCam*)o)->shake[2]=f1; + + break; + case C2('x','v'): // xvel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->tvel[0]=f1; + else if(rel>0) ov->tvel[0]+=f1; + else ov->tvel[0]-=f1; + break; + case C2('y','v'): // yvel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->tvel[1]=f1; + else if(rel>0) ov->tvel[1]+=f1; + else ov->tvel[1]-=f1; + break; + case C2('z','v'): // zvel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->tvel[2]=f1; + else if(rel>0) ov->tvel[2]+=f1; + else ov->tvel[2]-=f1; + break; + case C2('x','a'): // xacc + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->tacc[0]=f1; + else if(rel>0) ov->tacc[0]+=f1; + else ov->tacc[0]-=f1; + break; + case C2('y','a'): // yacc + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->tacc[1]=f1; + else if(rel>0) ov->tacc[1]+=f1; + else ov->tacc[1]-=f1; + break; + case C2('z','a'): // zacc + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->tacc[2]=f1; + else if(rel>0) ov->tacc[2]+=f1; + else ov->tacc[2]-=f1; + break; + + case C2('x','p'): // xpos + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->trans[0]=f1; + else if(rel>0) ov->trans[0]+=f1; + else ov->trans[0]-=f1; + break; + case C2('y','p'): // ypos + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->trans[1]=f1; + else if(rel>0) ov->trans[1]+=f1; + else ov->trans[1]-=f1; + break; + case C2('z','p'): // zpos + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->trans[2]=f1; + else if(rel>0) ov->trans[2]+=f1; + else ov->trans[2]-=f1; + break; + + case C2('x','r'): // xrot + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->rot[0]=f1; + else if(rel>0) ov->rot[0]+=f1; + else ov->rot[0]-=f1; + break; + case C2('y','r'): // yrot + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->rot[1]=f1; + else if(rel>0) ov->rot[1]+=f1; + else ov->rot[1]-=f1; + break; + case C2('z','r'): // zrot + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->rot[2]=f1; + else if(rel>0) ov->rot[2]+=f1; + else ov->rot[2]-=f1; + break; + + case C2('x','q'): // xpos relative + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->trans[0]+=f1; + break; + case C2('y','q'): // ypos relative + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->trans[1]+=f1; + break; + case C2('z','q'): // zpos relative + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->trans[2]+=f1; + break; + + case C2('x','t'): // xrot-vel (twist) + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->rvel[0]=f1; + else if(rel>0) ov->rvel[0]+=f1; + else ov->rvel[0]-=f1; + break; + case C2('y','t'): // yrot-vel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->rvel[1]=f1; + else if(rel>0) ov->rvel[1]+=f1; + else ov->rvel[1]-=f1; + break; + case C2('z','t'): // zrot-vel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + if(!rel) ov->rvel[2]=f1; + else if(rel>0) ov->rvel[2]+=f1; + else ov->rvel[2]-=f1; + break; + case C2('x','c'): // xrot-rel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->rot[0]+=f1; + break; + case C2('y','c'): // yrot-rel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->rot[1]+=f1; + break; + case C2('z','c'): // zrot-rel + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + ov->rot[2]+=f1; + break; + + case C2('x','s'): // xscale + szto(s1,s2,'f',0,&f1); + if(ov) + { + if(!rel) ov->scale[0]=f1; + else if(rel>0) ov->scale[0]+=f1; + else ov->scale[0]-=f1; + ov->flags|=M_OBJVEL_SCALE; + } + break; + case C2('y','s'): // yscale + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->scale[1]=f1; + else if(rel>0) ov->scale[1]+=f1; + else ov->scale[1]-=f1; + ov->flags|=M_OBJVEL_SCALE; + break; + case C2('z','s'): // zscale + if(!ov) goto oerr; + szto(s1,s2,'f',0,&f1); + if(!rel) ov->scale[2]=f1; + else if(rel>0) ov->scale[2]+=f1; + else ov->scale[2]-=f1; + ov->flags|=M_OBJVEL_SCALE; + break; + case C2('r','h'): // root hold + if(!o || (o->sub!=OBJSUB_DISPRES)) + goto oerr; + if((ec=ObjAniRoot(o,NUL,OBJANICMD_HOLD,0,NUL))<0) + goto BAIL; + break; + case C2('r','m'): // rot max + if(!o || (o->sub!=OBJSUB_ANIRES)) + {BP(BP_RESPOBJ7);goto oerr;} // need oar + szto(s1,s2,'f',0,&f1); + f1/=RES_FRAME_TIME; + ((ObjAniRes*)o)->rmax=f1; + break; + case C2('s','p'): // speed + if(!o) + {BP(BP_RESPOBJ8);goto oerr;} // need o + szto(s1,s2,'f',0,&f1); + if(f1) f1=1/f1; + if(o->sub==OBJSUB_ANIRES) + ((ObjAniRes*)o)->speed=f1; + else if(o->sub==OBJSUB_DISPRES) + { + // scan for skel oars in kidlist + o2=N2KIDLIST(o); + for(k=o2->next;k->type;k=k->next) + { + if((k->sub==OBJSUB_ANIRES) + &&(((ObjAniRes*)k)->flags&M_OBJANIRES_SKEL)) + ((ObjAniRes*)k)->speed=f1; + } // for + } + else + { + // scan for any oars in kidlist + o2=N2KIDLIST(o); + if(o2->next) + { + for(k=o2->next;k->type;k=k->next) + { + if(k->sub==OBJSUB_ANIRES) + ((ObjAniRes*)k)->speed=f1; + } // for + } + } + break; + + case C2('f','l'): // flags + if(!o) goto oerr; + + // + // CHOOSE MAP + // + + map=NUL; + switch(o->sub) + { + case OBJSUB_ANIRES: + map=resObjOARFlags; + val=resObjOARFlagv; + max=COUNT(resObjOARFlagv); + break; + case OBJSUB_DISPRES: + map=resObjODRFlags; + val=resObjODRFlagv; + max=COUNT(resObjODRFlagv); + break; + case OBJSUB_VEL: + map=resObjOVFlags; + val=resObjOVFlagv; + max=COUNT(resObjOVFlagv); + break; + case OBJSUB_LIGHTRES: + map=resObjLightResFlags; + val=resObjLightResFlagv; + max=COUNT(resObjLightResFlagv); + break; + default: + goto oerr; + } // switch + + if(!map) + break; + + // + // BUILD FLAGS FROM LIST + // + + maska=masko=0; + + for(;;) + { + neg=0; + if(!s1 && (ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + break; + + if(*s1=='-') + { + s1++; + neg=1; + } + if(s1[0]==')') + break; + ec=sz2map(map,s1,s2); + if((ec<1) || (ec>=max)) + {BP(BP_RESPOBJ9);} // unk flag + else if(neg) + maska|=val[ec]; + else + masko|=val[ec]; + + // check for continue -- must be imm after flag + if(s2[0]!=',') + break; + s1=NUL; // parse more + fhb->str=1+s2; + } // for + + // flip + maska=~maska; + + // + // SET FLAGS + // + + switch(o->sub) + { + case OBJSUB_ANIRES: + ((ObjAniRes*)o)->flags&=maska; + ((ObjAniRes*)o)->flags|=masko; + break; + case OBJSUB_DISPRES: + ((ObjDispRes*)o)->flags&=maska; + ((ObjDispRes*)o)->flags|=masko; + break; + case OBJSUB_VEL: + ((ObjVel*)o)->flags&=maska; + ((ObjVel*)o)->flags|=masko; + break; + case OBJSUB_LIGHTRES: + ((ObjLightRes*)o)->flags&=maska; + ((ObjLightRes*)o)->flags|=masko; + break; + } // switch + + break; + default: +oerr: + BP(BP_RESPOBJ10); // look at cmd & s1 to figure where error is + break; + } // switch + } // for + + ec=0; +BAIL: + return ec; +} // respOBJ() + +// JFL 02 Feb 05 +int respMARK(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + char buf[64]; + + // parenopen + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + // name + ResParseRaw(fhb,&s1,&s2,NUL); + szncpy2(buf,s1,s2,sizeof(buf)); + + // parenclose + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(ec!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX); + + ObjSetLinkName(buf); + + ec=0; +BAIL: + return ec; +} // respMARK() + +#if DEBUG // ------------------------------------------------------------------ +// JFL 08 Feb 05 +int respDBG(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + uns16 cmd; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + for(;;) + { + // quick way to form a command + s1=szskipwhite(fhb->str); + if(s1[0]==')') + break; + cmd=s1[0]<<8; + cmd|=s1[1]; + fhb->str=szskipwhite(s1+2); + + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&ec); + + switch(cmd) + { + case C2('g','c'): // ground col + case C2('d','c'): // disp col + VidDisp.dbgcol=ec; + break; + case C2('d','s'): // disp shadows + VidDisp.dbgshad=ec; + break; + case C2('d','d'): // disp + VidDisp.dbgdisp=ec; + break; + case C2('d','b'): // bench + VidDisp.dbgbench=ec; + break; + } // switch + } // for + + ec=0; +BAIL: + ResParsePAREN(fhb); + return ec; +} // respDBG() +#endif // DEBUG --------------------------------------------------------------- + +// JFL 06 Jul 05 +int respOP(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + uns16 cmd; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + for(;;) + { + // quick way to form a command + s1=szskipwhite(fhb->str); + if(s1[0]==')') + break; + cmd=s1[0]<<8; + cmd|=s1[1]; + fhb->str=szskipwhite(s1+2); + + switch(cmd) + { + case C2('o','c'): // obj cull + if(s1[2]!='=') + berr(ERR_PARSE_SYNTAX); + fhb->str=s1+3; + ResParseRaw(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',0,&ec); + ObjCull(ec); + break; + } // switch + } // for + + ec=0; +BAIL: + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + return ec; +} // respOP() + +// JFL 25 Feb 05 +int respNOP(ResParseH *fhb,Res *res) +{ + int ec; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + + ec=0; +BAIL: + return ec; +} // respNOP() + +// JFL 22 Mar 05 +int respMEM(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2,*t1,*t2; + int n; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if((ec=ResParseRaw(fhb,&t1,&t2,NUL))<0) + goto BAIL; + szto(t1,t2,'i',0,&n); + + if(s1[0]=='s') // save memory marks + { + MemStackSave(n); + } + else if(s1[0]=='r') // restore memory marks + { + MemStackRestore(n); + } + else + BP(BP_RESPMEM); + + + ec=0; +BAIL: + ResParsePAREN(fhb); + return ec; +} // respMEM() + +// JFL 06 Apr 05 +int respLIGHT(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + int8 paren=0; + uns8 k; + uns32 cmd; + memu *vad; + N2 *o; + Res *r; + ResDataLight *rdl; + float f1; + crd v[3]; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + o=NUL; + if((vad=ResParseVarAdr(fhb,1+s1,s2))) + o=(void*)*vad; + + if(!o || (o->type!=N2TYPE_OBJ) || (o->sub!=OBJSUB_LIGHTRES) + || !(r=((ObjLightRes*)o)->res) || !(rdl=r->data)) + berr(-2); + + #if SAFE + // we should only stuff dummy resources -- not ones that have been loaded + // in -- this will preserve the option of placing resources in ROM + if(r->lnk.type) + BP(BP_RESPLIGHT); + #endif // SAFE + + for(;;) + { + // quick way to form a command + s1=szskipwhite(fhb->str); + if(s1[0]==')') + break; + cmd =s1[0]<<16; + cmd|=s1[1]<<8; + cmd|=s1[2]<<0; + fhb->str=szskipwhite(s1+3); + if(fhb->str[0]=='=') + fhb->str++; + + // create(light3 .t=lit) bin(mv 3 0) + // light($3 amb pos=1 2.0 3.0 dir=0 0 -1 rgb=1 1 1 par=30) + + switch(cmd) + { + case C3('a','m','t'): // ambient + rdl->type=RESDATALIGHT_AMBIENT; + break; + case C3('p','s','t'): // pst + rdl->type=RESDATALIGHT_POSITIONAL; + break; + case C3('d','r','t'): // drt + rdl->type=RESDATALIGHT_DIRECTIONAL; + break; + case C3('s','p','t'): // spt + rdl->type=RESDATALIGHT_SPOT; + break; + case C3('n','o','l'): // nol + ((ObjLightRes*)o)->flags|=M_OBJLIGHTRES_NOLIGHT; + break; + case C3('x','y','z'): // xyz + for(k=0;k<3;k++) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'f',0,&f1); + rdl->pos[k]=f1; + } // for + break; + + case C3('d','i','r'): + + for(k=0;k<3;k++) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'f',0,&f1); + v[k]=f1; + } // for + + V3Normalize(v); + + for(k=0;k<3;k++) + rdl->dir[k]=v[k]; + + break; + + case C3('r','g','b'): // rgb + + for(k=0;k<3;k++) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'f',0,&f1); + rdl->rgb[k]=f1; + } // for + + break; + + case C3('p','a','0'): // pa0 + case C3('p','a','1'): // pa1 + case C3('p','a','2'): // pa2 + case C3('p','a','3'): // pa3 + k=cmd&0xff; + k-='0'; + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'f',0,&f1); + if(k>=COUNT(rdl->parameters)) + {BP(BP_RESPLIGHT2);break;} + rdl->parameters[k]=f1; + break; + + case C3('s','h','a'): + if(s1[3]=='d'&&s1[4]=='d'&&s1[5]=='i'&&s1[6]=='r') + ((ObjLightRes*)o)->flags|=M_OBJLIGHTRES_SHADDIR; + else if(s1[3]=='d'&&s1[4]=='p'&&s1[5]=='o'&&s1[6]=='s') + ((ObjLightRes*)o)->flags|=M_OBJLIGHTRES_SHADPOS; + fhb->str=szskipwhite(s1+7); + break; + + default: + BP(BP_RESPLIGHT3); // unknown command + break; + } // switch + } // for + + + ec=0; +BAIL: + if(!paren) + ResParsePAREN(fhb); + return ec; +} // respLIGHT() + +// JFL 13 Apr 05 +int respSTR(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + int8 paren=0; + Obj *o,*olnk; + memu *vad; + int8 link=0; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + olnk=NUL; + if(s1[0]=='$') + { + if((vad=ResParseVarAdr(fhb,1+s1,s2))) + olnk=(void*)*vad; + if(olnk) + olnk=(void*)N2KIDLIST(olnk); + link=-1; + } + else if(*s1=='-') + { + s1++; + if(*s1=='m') + { + s1++; + olnk=ObjGetLinkObj(); + } + else + { + olnk=ObjFindLinkName("cam2d"); + } + if(*s1=='a') + { + s1++; + link=1; + } + else if(*s1=='b') + { + s1++; + link=-1; + } + } + + if(!olnk) + berr(-1); // no linking obj + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + + if((ec=FontGameStr(s1,s2,M_FONTGAMESTR_CREATE,1.0,1.0,&o))<0) + goto BAIL; + if(!o) + berr(-1); + + if(link<0) + N2LinkBefore(olnk,o); + else + N2LinkAfter(olnk,o); + + ec=0; +BAIL: + if(!paren) + ResParsePAREN(fhb); + return ec; +} // respSTR() + +// JFL 26 Apr 05 +int respSOUND(ResParseH *fhb,Res *res) +{ + int ec; + char *s1,*s2; + int8 paren=0; + int8 link=0; + char c; + int vol; + int8 setvol=0; + int8 playedsounds=0; + + // parenopen + ec=ResParseTok(fhb,NUL,NUL,NUL); + if(ec!=RESPARSE_PARENOPEN) + berr(ERR_PARSE_SYNTAX); + + for(;;) + { + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + + if(s1[0]==')') + { + paren=1; + break; + } + else if(s1[0]=='-') + { + s1++; + c=*s1++; + switch(c) + { + case 'l': + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + SndLoad(s1,s2); + break; + case 'u': + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + SndUnload(s1,s2); + break; + case 'v': + // get volume (don't set anything here) + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + goto BAIL; + szto(s1,s2,'i',0,&vol); + setvol=1; + break; + + } // switch + } + else + { + // play + szto(s1,s2,'i',0,&ec); + + if(!setvol) + SndPlay(ec); + else + SndPlayVol(ec,vol); + + playedsounds=1; + } + } // for + + // if volume was specified and we didn't play any sounds, set system volume + if(setvol && !playedsounds) + SndVol(vol); + + ec=0; +BAIL: + if(!paren) + ResParsePAREN(fhb); + return ec; +} // respSOUND() + +// JFL 29 Dec 04 +int resParseOne(int ec,ResParseH *fhb,Res *res) +{ + void *d; + + if(fhb->brk) + { + if(fhb->brk==2) + { + GameLp.flags|=M_GAMELP_PAUSE; + } + else + { + fhb->brk=0; + BP(BP_RESPARSEONE); + } + } + + switch(ec) + { + case RESPARSE_PARENOPEN: + fhb->depth++; + break; + case RESPARSE_PARENCLOSE: + --fhb->depth; + break; + case RESPARSE_HELP: + if((res->lnk.sub==RESSUB_PARSE) && (d=res->data) + && ((ResDataParse*)d)->msg) + { + szbuild(((ResDataParse*)d)->msg,((ResDataParse*)d)->msgSize,resat_help); + } + break; + case RESPARSE_GEO: + break; + case RESPARSE_GND: + if((res->lnk.sub==RESSUB_DISP2) && (d=res->data)) + ((ResDataDisp2*)d)->mode|=M_RESDISPMODE_GND; + break; + case RESPARSE_DONTCULL: + if((res->lnk.sub==RESSUB_DISP2) && (d=res->data)) + ((ResDataDisp2*)d)->mode|=M_RESDISPMODE_NOCULL; + break; + case RESPARSE_DONTLOOP: + res->flags&=~M_RES_LOOP; + break; + case RESPARSE_LOOP: + res->flags|=M_RES_LOOP; + break; + case RESPARSE_DC: + if((ec=respDC(fhb))<0) + goto BAIL; + break; + case RESPARSE_GAME: + if((ec=respGAME(fhb))<0) + goto BAIL; + break; + case RESPARSE_MIP: + if((ec=respMIP(fhb))<0) + goto BAIL; + break; + case RESPARSE_FOG: + if((ec=respFOG(fhb))<0) + goto BAIL; + break; + case RESPARSE_DISP: + if((ec=respDISP(fhb))<0) + goto BAIL; + break; + case RESPARSE_CAM: + if((ec=respCAM(fhb))<0) + goto BAIL; + break; + case RESPARSE_DEER: + if((ec=respDEER(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_BAN: + if((ec=respBAN(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_RAN: + if((ec=respRAN(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_SET: + if((ec=respSETCAT(fhb,res,0))<0) + goto BAIL; + break; + case RESPARSE_CAT: + if((ec=respSETCAT(fhb,res,1))<0) + goto BAIL; + break; + case RESPARSE_KILL: + if((ec=respKILL(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_VIDPLAY: + if((ec=respVIDPLAY(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_VIDSTOP: + if((ec=respVIDSTOP(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_VIDREADY: + if((ec=respVIDREADY(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_VIDDONE: + if((ec=respVIDDONE(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_VIDALINK: + if((ec=respVIDALINK(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_SEQ: + if((ec=respSEQ(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_ANI: + if((ec=respANI(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_BIN: + if((ec=respBIN(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_LOAD: + if((ec=respLOAD(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_ADD: + if((ec=respADD(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_TIME: + if((ec=respTIME(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_IF: + if((ec=respIF(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_VERS: + if((ec=respVERS(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_RUN: + if((ec=respRUN(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_INFO: + if((ec=respINFO(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_PRINT: + if((ec=respPRINT(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_FC: + if((ec=respFC(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_LABEL: + // do nothing + break; + case RESPARSE_BR: + if((ec=respBR(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_FIND: + if((ec=respFIND(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_RETURN: + if((ec=respRETURN(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_FAIL: + if((ec=respFAIL(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_FLAG: + if((ec=respFLAG(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_CREATE: + if((ec=respCREATE(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_SEND: + if((ec=respSEND(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_OBJ: + if((ec=respOBJ(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_MARK: + if((ec=respMARK(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_TOOL: + case RESPARSE_NOP: + if((ec=respNOP(fhb,res))<0) + goto BAIL; + break; + #if DEBUG // -------------------------------------------------------------- + case RESPARSE_DBG: + if((ec=respDBG(fhb,res))<0) + goto BAIL; + break; + #endif // DEBUG ----------------------------------------------------------- + case RESPARSE_SUB: + if((ec=respSUB(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_MEM: + if((ec=respMEM(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_LIGHT: + if((ec=respLIGHT(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_STR: + if((ec=respSTR(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_SOUND: + if((ec=respSOUND(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_OP: + if((ec=respOP(fhb,res))<0) + goto BAIL; + break; + case RESPARSE_BOZORET: + if((ec=respBOZORET(fhb,res))<0) + goto BAIL; + break; + + case ERR_PARSE_EOF: + default: + + if((res->lnk.sub==RESSUB_PARSE) + && (d=res->data) + && ((ResDataParse*)d)->callbackFunc) + { + ec=(((ResDataParse*)d)->callbackFunc)(ec,fhb,res, + ((ResDataParse*)d)->callbackData); + } + else + { + ec=ERR_PARSE_SYNTAX; + BP(BP_RESPARSEONE2); + } + + if(ec==ERR_PARSE_EOF) + goto BAIL; + + if(ec<0) + goto BAIL; + } // switch + + ec=0; +BAIL: + return ec; +} // ResParseOne() + +// JFL 05 Nov 04 +int ResParse(Res *res,char *buf,char **nextp) +{ + int ec; + ResParseH fhbuf,*fhb=&fhbuf; + char *s1,*s2; + void *d; + + MEMZ(fhbuf); + + fhb->str=buf; + fhb->res=res; + + fhb->outBuf=NUL; + if((res->lnk.sub==RESSUB_PARSE) && (d=res->data)) + { + if((fhb->outBuf=((ResDataParse*)d)->msg)) + fhb->outBuf[0]=0; + fhb->outBufSize=((ResDataParse*)d)->msgSize; // jjj get rid of this + fhb->binBuf=((ResDataParse*)d)->binBuf; + fhb->varBuf=((ResDataParse*)d)->varBuf; + fhb->nLab=((ResDataParse*)d)->nLab; + fhb->lab=((ResDataParse*)d)->lab; + fhb->root=((ResDataParse*)d)->root; + + if(((ResDataParse*)d)->flags&M_RESDATAPARSE_SINGLE) + fhb->depth--; // force bail-out after first pass + } + + // + // commands that begin with a . are level0 commnds + // without a . at the beginning, the command is a leve1 command + // generally level0 commands are used for flags & this code is executed at load time + // level1 commands are executed when objects are activated + // + + for(;;) + { + fhb->revert=fhb->str; + + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + { + //if(ec==ERR_PARSE_EOF) + // goto done; + //else + goto BAIL; + } + if(s1[0]=='*') + { + fhb->brk=1; + s1++; + if(s1==s2) // * by itself + continue; + if(s1[1]=='*') + { + switch(s1[0]) + { + case 'p': + fhb->brk=2; + break; + default: + fhb->brk=1; + } // switch + s1+=2; + if(s1==s2) + continue; + } + } +loop: + // + // FILTER COMMANDS BASED ON LEVEL + // + + if(res->flags&M_RES_PARSE1) + { + // execution level1 + if(s1[0]=='.') + { + // command starts with . + // get command & ignore it + // get next token, if its not paren loop + // otherwise, the paren belongs to the command, ignore it, continue + + ResParseRaw(fhb,&s1,&s2,NUL); // get next token, ignore + if((ec=ResParseTok(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(ec!=RESPARSE_PARENOPEN) + goto loop; + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + continue; + } + else + { + if((ec!=RESPARSE_STRING) && (ec!=RESPARSE_LABEL)) + ec=sz2map(respwords,s1,s2); + } + } + else + { + // parsing level0 + if(s1[0]=='.') + { + // ignore the dot, get the next token, drop through to process + ec=sz2map(respwords,1+s1,s2); + //ec=ResParseTok(fhb,&s1,&s2,NUL); // get next token to process + } + else + { + // not a dot, ignore the token we have and + if((ec=ResParseTok(fhb,&s1,&s2,NUL))<0) + goto BAIL; + if(ec!=RESPARSE_PARENOPEN) + goto loop; + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + continue; // skip + } + } + + // + // PROCESS THE COMMAND + // + + if(ec==RESPARSE_LABEL) + ec=ec; // dummy + else + ec=resParseOne(ec,fhb,res); + if(ec<0) + { + if(ec==ERR_PARSE_SYNTAX) + { + if((res->lnk.sub==RESSUB_PARSE) && (d=res->data) + && ((ResDataParse*)d)->msg) + { + szbuild(((ResDataParse*)d)->msg,((ResDataParse*)d)->msgSize,"syntax '%S'",s1,s2); + } + } + + goto BAIL; + } + // terminate when an extra close paren is hit + if(fhb->depth<0) + break; + } // for + +//done: + if(fhb->fail) + err(ERR_PARSE_FAIL); + + ec=0; +BAIL: + if(nextp) + *nextp=fhb->str; + + #if DEBUG + if((ec<0)&&(ec!=ERR_PARSE_STOP)&&(ec!=ERR_PARSE_EOF)) + { + char buferr[32]; + static int errcnt=0; + if(++errcnt<1024) + { + szncpy(buferr,fhb->revert,sizeof(buferr)); + SysLog("ResParse:%s %d [%s]\n",res->name,ec,buferr); + } + } + #endif // DEBUG + + return ec; +} // ResParse() + +// JFL 09 Dec 04 +// JFL 03 Jan 05; no alloc +int ResParseText(void *root,memu *bin,memu *var,char *s1,char *s2) +{ + int ec; + ResDataParse rdpmem,*rdp=&rdpmem; + + MemZero(rdp,sizeof(ResDataParse)); + + rdp->root=root; + rdp->binBuf=bin; + rdp->varBuf=var; + rdp->cmd=s1; + + if((ec=ResParseBlock(rdp,NUL))<0 && (ec!=ERR_PARSE_EOF)) + goto BAIL; + + ec=0; +BAIL: + return ec; +} // ResParseText() + +// JFL 14 Apr 05 +int ResScript(char *s1) +{ + int ec; + ResDataParse rdpmem,*rdp=&rdpmem; + + MemZero(rdp,sizeof(ResDataParse)); + rdp->cmd=s1; + if((ec = ResParseBlock(rdp,NUL))<0 && (ec!=ERR_PARSE_EOF)) + goto BAIL; + ec=0; +BAIL: + return ec; +} // ResScript() + +// JFL 08 Jan 05 +int ResParseBlock(ResDataParse *rdp,char **nextp) +{ + int ec; + Res resmem,*res=&resmem; + + MemZero(res,sizeof(Res)); + + res->lnk.type=N2TYPE_RES; + res->lnk.sub=RESSUB_PARSE; + res->flags|=M_RES_PARSE1; + res->data=rdp; + #if DEBUG + if(rdp->nameptr) + szncpy(res->name,rdp->nameptr,sizeof(res->name)); + #endif // DEBUG + + ec=ResParse(res,rdp->cmd,nextp); + + return ec; +} // ResParseBlock() + +// JFL 18 Feb 05 +int ResParseSeq(char *seq) +{ + int ec; + char buf[64]; + ResDataParse rdpmem,*rdp=&rdpmem; + + szbuild(buf,sizeof(buf),"ani(- %s)",seq); + + MemZero(rdp,sizeof(ResDataParse)); + rdp->cmd=buf; + + if((ec=ResParseBlock(rdp,NUL))<0 && (ec!=ERR_PARSE_EOF)) + goto BAIL; + ec=0; +BAIL: + return ec; +} // ResParseSeq() + +// JFL 11 Nov 04 +int ResSelect(Res *r) +{ + int ec; + ObjCam *cam; + + switch(r->lnk.sub) + { + case RESSUB_CAM: + if(!(cam=ObjCamCur())) + break; + ObjCamResStart(cam,r,0); + break; + } // select + + ec=0; +// BAIL: + return ec; +} // ResSelect() + +// link back to the real world +extern int ResAppHookValidateFileCF(char *fname, uns8 *buf, uns size); + +// JFL 07 Dec 04 +int resReadCF(FsH *fh,char *name, char *fname) +{ + int ec; + uns size,j; + uns8 *mem=MemSLowGet(MEMPOOL_HEAP),*p; + Res *res; + ResDataParse *rdp; + + // + // + // + + size=FsSize(fh); + if((ec=MemSLow(MEMPOOL_HEAP,1+size,&p))<0) + goto BAIL; + if((ec=FsRead(fh,p,size))<0) + goto BAIL; + p[size]=0; + + if(szcmpx("// CF?? - Copyright (C) ????, PlayMechanix, Inc.",p)) + berr(ERR_RES_FILESYNTAX); + + // see if there is a callback to validate file + if(ResAppHookValidateFileCF(fname,p,size) < 0) + { + SysLog("resReadCF(): file validation failed for %s\n",fname); +#if PRODUCTION + berr(ERR_RES_CRC); // no load corrupt file in production +#endif //PRODUCTION + } + // + // + // + + j=sizeof(Res)+sizeof(ResDataParse); + if((ec=ResNew(&res,RESSUB_PARSE,j,0,name))<0) + goto BAIL; + res->flags|=M_RES_PARSE1; + res->data=&res[1]; + + rdp=(void*)&res[1]; + MemZero(rdp,sizeof(ResDataParse)); + rdp=(void*)&res[1]; + rdp->cmd=p; + rdp->msg=NUL; + rdp->msgSize=0; + + if((ec=ResParse(res,p,NUL))<0 && (ec!=ERR_PARSE_EOF)) + goto BAIL; + + ec=0; +BAIL: + if(mem) + MemSLowSet(MEMPOOL_HEAP,mem); + return ec; +} // resReadCF() + +// JFL 07 Dec 04 +int ResRunCommandFile(char *name) +{ + int ec; + FsH fsmem; + char buf[64]; + uns8 fsopen=0; + + buf[0]=0; + szncat2(buf,name,".cf",sizeof(buf)); + + if((ec=FsFindOpen(&fsmem,SysG.path,buf,0,NUL,0))<0) + berr(1); // couldn't find file + fsopen=1; + if((ec=resReadCF(&fsmem,name,buf))<0) + goto BAIL; + + ec=0; +BAIL: + if(fsopen) + FsClose(&fsmem); + return ec; +} // ResRunCommandFile() + +// JFL 17 Dec 04 +int ResGen(uns cmd,void *src,void *dst) +{ + int ec; + Res *r,*r2; + void *d; + ResDataCol *col; + ResDataKanKey *key,*keyx; + int n,t; + char *s1; + + switch(cmd&M_RESGEN) + { + case RESGEN_GET_NAMED_RESDATASEQ: + if(!(r=ResFindSubNth(NUL,src,RESSUB_SEQ,NUL))) + err(-1); + if(!(d=r->data)) + err(-2); + *((void**)dst)=d; + break; + case RESGEN_GET_NAMED_RESDATACOL: + if(!(r=ResFindSubNth(NUL,src,RESSUB_COL,NUL))) + err(-1); + if(!(d=r->data)) + err(-2); + *((void**)dst)=d; + break; + case RESGEN_GET_NAMED_RESDATALIGHT: + if(!(r=ResFindSubNth(NUL,src,RESSUB_LIGHT,NUL))) + err(-1); + if(!(d=r->data)) + err(-2); + *((void**)dst)=d; + break; + case RESGEN_RESDATALIGHT_TO_BUF: + if(!(d=src)) + break; + n=((int)cmd)>>S_RESGEN_N; + + switch(((ResDataLight*)d)->type) + { + case RESDATALIGHT_AMBIENT: + s1="abt"; + break; + case RESDATALIGHT_DIRECTIONAL: + s1="drt"; + break; + case RESDATALIGHT_POSITIONAL: + s1="pst"; + break; + case RESDATALIGHT_SPOT: + s1="spt"; + break; + default: + s1="???"; + break; + } // switch +// +// float pos[3]; +// float dir[3]; +// float rgb[3]; // intensity 'baked' in +// float parameters[4]; // parameters + + szbuild(dst,n,"%s xyz=%f %f %f dir=%f %f %f rgb=%f %f %f paX=%f %f %f", + s1, + ((ResDataLight*)d)->pos[0], + ((ResDataLight*)d)->pos[1], + ((ResDataLight*)d)->pos[2], + ((ResDataLight*)d)->dir[0], + ((ResDataLight*)d)->dir[1], + ((ResDataLight*)d)->dir[2], + ((ResDataLight*)d)->rgb[0], + ((ResDataLight*)d)->rgb[1], + ((ResDataLight*)d)->rgb[2], + ((ResDataLight*)d)->parameters[0], + ((ResDataLight*)d)->parameters[1], + ((ResDataLight*)d)->parameters[2] + ); + break; + case RESGEN_RESDATASEQ_TO_BUF: + *((void**)dst)=&((ResDataSeq*)src)[1]; + break; + case RESGEN_RESDATAKAN_TO_BUF: + if(!(r=src) || (r->lnk.type!=N2TYPE_RES) + || (r->lnk.sub!=RESSUB_KAN) || !(d=r->data)) + break; + n=((int)cmd)>>S_RESGEN_N; + + ec=((ResDataKan*)d)->numk; + szbuild(dst,n,"%s numk=%d f=%x",r->name,ec,((ResDataKan*)d)->flags); + key=keyx=(void*)&((ResDataKan*)d)[1]; + keyx=key+ec; + t=0; + while(keytime; + szbuild(dst,n,"<-cat> [%d] %x",t,key->flags); + key++; + } // while + + break; + case RESGEN_GET_NAMED_RESANIGROUP: + + if(!(r=ResFindSubNth(NUL,src,RESSUB_GROUP,NUL))) + berr(-1); + + *((void**)dst)=r; + + break; + case RESGEN_RESANIGROUP_TO_BUF: + + if(!(r=src) || (r->lnk.type!=N2TYPE_RES) + || (r->lnk.sub!=RESSUB_GROUP)) + break; + n=((int)cmd)>>S_RESGEN_N; + + if((r->lnk.flags&M_N2_KIDLIST) + &&(r2=N2KIDLIST(r)->next)) + { + for(;r2->lnk.type;r2=r2->lnk.next) + { + if(r2->lnk.sub!=RESSUB_KAN) + continue; + if(!(d=r2->data)) + continue; + + ec=((ResDataKan*)d)->numk; + + key=keyx=(void*)&((ResDataKan*)d)[1]; + keyx=key+ec; + t=0; + while(keytime; + key++; + } // while + + szbuild(dst,n,"<-cat> %d",t); + + + } // for + } + + break; + + case RESGEN_RESDATACOL_TO_BUF: + if(!(col=src)) + break; + + n=((int)cmd)>>S_RESGEN_N; + + switch(col->type) + { + case 0: + case RESDATACOLTYPE_SINGLE: + szbuild(dst,n,"coltype=%d ",col->type); + break; + case RESDATACOLTYPE_SKEL: + szbuild(dst,n,"skc:"); + break; + case RESDATACOLTYPE_PROP: + szbuild(dst,n,"prc:"); + break; + } // switch + + d=col->blocks; + for(;;) + { + if(!((ResDataColBlock*)d)->type) + break; + switch(((ResDataColBlock*)d)->type) + { + case RESDATACOLBLOCK_XZMM: + szbuild(dst,n,"<-cat>mm "); + d=&((ResDataCBXZMM*)d)[1]; + break; + case RESDATACOLBLOCK_XYZR: + szbuild(dst,n,"<-cat>%s ",((ResDataCBXYZR*)d)->colName); + d=&((ResDataCBXYZR*)d)[1]; + break; + } // switch + } // for + break; + + } // switch + + ec=0; +BAIL: + return ec; +} // ResGen() + +// EOF diff --git a/dond/core/res.h b/dond/core/res.h new file mode 100755 index 0000000..337c415 --- /dev/null +++ b/dond/core/res.h @@ -0,0 +1,762 @@ +#ifndef RES_H +#define RES_H +// res.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 08 Oct 04 + +// note: keep DC up-to-date with these defs + +#define M_RES_LOADED 0x0001 +#define M_RES_COMPILED 0x0002 +#define M_RES_DONTFREE 0x0004 +#define M_RES_FREEDATA 0x0008 +#define M_RES_PARSE1 0x0080 +#define M_RES_LOOP 0x0100 +#define M_RES_ANIM 0x0200 +#define M_RES_SHARED 0xf000 // these flags are shared (OK to use locally) + +enum { + // -- see a-doc.h for notes on adding types + // must match DC & resResSubTable[] + RESSUB_NONE, + RESSUB_GROUP, + RESSUB_FUNC1, + RESSUB_DISP1, + RESSUB_DISP2, + RESSUB_IMG1, + RESSUB_CAM, + RESSUB_KAN, + RESSUB_SKEL, + RESSUB_DISP3, + RESSUB_PARSE, + RESSUB_SEQ, + RESSUB_LIGHT, + RESSUB_FTYPE, + RESSUB_COL, + RESSUB_FUNC2, + RESSUB_FUNC3, + RESSUB_FONT, + RESSUB_DISP4, + RESSUB_JUMP, + RESSUB_VID, + RESSUB_MAX + // must match DC & & resResSubTable[] +}; + +#define M_RESNEW_KID 0x0001 +#define M_RESNEW_DONTLINK 0x0002 +#define M_RESNEW_DONTCLEAR 0x0004 + +#define RES_NAME_SIZE 16 +typedef struct { + // must match DC + N2 lnk; + uns16 flags; + int16 useCount; + char name[RES_NAME_SIZE]; + void *data; +} Res; + +#define RES_LIST_DEPTH 4 + +/////////////////////////////////////////////////////////////////////////////// +// SYS_PC|SYS_BB +#if SYS_PC|SYS_BB + +extern Res resCompiled[]; + +// +// Res -- subtype flags +// + +enum { + // enumerate the bottom bits + RESDISPMODE_NONE, + RESDISPMODE_WIREFRAME, + RESDISPMODE_TEX, +}; + +// flags +#define M_RESDISPMODE 0x000f +#define M_RESDISPMODE_VBO 0x0040 // vertex buffer object +#define M_RESDISPMODE_SORTONCE 0x0080 +#define M_RESDISPMODE_HASALPHA 0x0100 +#define M_RESDISPMODE_GND 0x0200 +#define M_RESDISPMODE_MIPMAP 0x0400 +#define M_RESDISPMODE_FACESORT 0x0800 +#define M_RESDISPMODE_LIGHT 0x1000 +#define M_RESDISPMODE_NOCULL 0x2000 +#define M_RESDISPMODE_VMAT 0x4000 // vmat field is vmat (not rts) +#define M_RESDISPMODE_DONTFOG 0x8000 + +#define M_RESDISPFACE_TRI 0x0001 +#define M_RESDISPFACE_QUAD 0x0002 + +#define RESFLOATSPER_VERT 3 // number of floats stored per vertex +#define RESFLOATSPER_COLOR 4 // number of floats stored per vertex color +#define RESFLOATSPER_TEXCOORD 2 // number of floats stored per texture coordinate +#define RESFLOATSPER_NORMAL 3 // number of floats stored per normal + +// +// DATA +// + +// only used for common fields among all ResDataDisp* +typedef struct { + uns16 mode; // all ResDataDisp* start with uns16 mode +} ResDataDisp0; + +typedef struct { + // this is a simple display structure + // used to compile in test objects (res_pc.c) + // must match DC + uns16 mode; // all ResDataDisp* start with uns16 mode + uns16 nTris; + float xyzrCull[4]; + void *tVerts; + void *tTexCoords; + void *tVertColors; + uns32 tex; +} ResDataDisp1; + +typedef struct { + float xyz[3]; + uns32 index; +} ResDataFaceSort; + +typedef struct { + // must match DC + uns16 mode; + uns16 atSize; + float vmat[12]; + uns16 nTris; + uns16 nQuads; + float xyzrCull[4]; + void *tVerts; + void *tVertColors; + void *tTexCoords; + void *tFaceSort; + void *tNormals; + void *qVerts; + void *qVertColors; + void *qTexCoords; + void *qFaceSort; + void *qNormals; + char *atBuf; + uns32 texHash; + uns32 texGen; + uns32 tVertsVBO; + uns32 tVertColorsVBO; + uns32 tTexCoordsVBO; + uns32 tNormalsVBO; + uns32 qVertsVBO; + uns32 qVertColorsVBO; + uns32 qTexCoordsVBO; + uns32 qNormalsVBO; + uns32 texGen2; +} ResDataDisp2; + +typedef struct { + // must match DC + uns16 mode; // all ResDataDisp* start with uns16 mode + uns16 atSize; + float vmat[12]; // not used now + uns16 nFaces; + uns16 nVerts; + float xyzrCull[4]; + void *verts; + void *normals; + void *faces; + char *atBuf; + uns32 texHash; + uns32 texGen; +} ResDataDisp3; + +#define M_RESDATADISP4_WEIGHTS 0x0001 +typedef struct { + // must match DC + // this is for displaying shadows + uns16 mode; // all ResDataDisp* start with uns16 mode + uns16 atSize; + uns16 flags; + uns16 nJoints; + uns16 maxFaces; + uns16 nVerts; + float xyzrCull[4]; + void *verts; + void *faces; + void *joints; + void *weights; + char *atBuf; +} ResDataDisp4; + +typedef struct { + uns16 nFaces; + uns16 jointNum; + uns32 faceoff; // first ResD4Face +} ResD4Joint; + +typedef struct { + uns32 vertoff[4]; + float nrmk[4]; + int16 neighbor[4]; +} ResD4Face; + +typedef struct { + float w0; // weight for joint j0 + float w1; // weight for joint j1 + uns16 j0; + uns16 j1; +} ResD4Weight; + +enum { + RES_TEX_NONE, + RES_TEX_RGB8, + RES_TEX_RGBA8, + RES_TEX_RGB332, + RES_TEX_RGB555, +}; + +#define M_RESDATAIMG1_MIPMAP 0x0001 +#define M_RESDATAIMG1_HASALPHA 0x0002 + +typedef struct { + // must match DC + uns16 type; + uns16 flags; + uns16 w; + uns16 h; + uns32 texHash; + uns32 texGen; + void *tex; +} ResDataImg1; + +typedef struct { + uns32 fileSize; + void *data; + void *theora; + uns32 texGen; +} ResDataVid; + +#define M_RESDATACAM_ORTHO 0x0001 + +typedef struct { + // must match DC + uns16 mode; + uns16 atSize; + float rot[3]; + float trans[3]; + float scale[3]; + float fov; + float orthoWidth; + float clipNear; + float clipFar; + char *atBuf; +} ResDataCam; + +#define M_RESDATAKAN_LOOP 0x0001 +#define M_RESDATAKAN_SPLINE 0x0002 +#define M_RESDATAKAN_GROUP 0x0004 + +typedef struct { + uns16 flags; + uns16 numk; + float firstFrame; // as keyed by animator + float length; // total length + // followed by ResDataKanKey +} ResDataKan; + +#define M_RESDATAKANKEY_RX 0x0001 +#define M_RESDATAKANKEY_RY 0x0002 +#define M_RESDATAKANKEY_RZ 0x0004 +#define M_RESDATAKANKEY_TX 0x0008 +#define M_RESDATAKANKEY_TY 0x0010 +#define M_RESDATAKANKEY_TZ 0x0020 +#define M_RESDATAKANKEY_SX 0x0040 +#define M_RESDATAKANKEY_SY 0x0080 +#define M_RESDATAKANKEY_SZ 0x0100 +#define M_RESDATAKANKEY_LINEAR 0x0200 +#define M_RESDATAKANKEY_ANGULAR 0x0400 + +#define RESDATAKANKEY_CH_NUM 3 +typedef struct { + float time; // duration + uns16 flags; + uns16 keynum; + float rts[3*RESDATAKANKEY_CH_NUM]; // rx,ry,rz,tx,ty,tz,sx,sy,sz +} ResDataKanKey; + +typedef struct { + float orient[3]; + float vm[12]; + float bps[12]; + char name[PM_NAME_SIZE]; + char parent[PM_NAME_SIZE]; +} ResDataJoint; + +// every vert has a weight for every joint +// this is how they are stored in the res: +// v0.j0 v0.j1 v0.j2 .. v1.j0 v1.j1 v1.j2 .. v2.j0 v2.j1 v2.j2 + +#define M_RESDATASKEL_JJJBINDINVERTED 0x0001 +typedef struct { + uns16 flags; + uns16 numJoints; + char geoName[PM_NAME_SIZE]; + ResDataJoint *joints; + float *weights; +} ResDataSkel; + +#define M_RESDATAPARSE_SINGLE 0x0001 + +typedef struct { + uns16 flags; + uns16 msgSize; + uns16 nLab; + uns16 xx1; + char *cmd; + char *msg; + void *root; + memu *binBuf; + memu *varBuf; + void *lab; + char *nameptr; + ftype4 *callbackFunc; + void *callbackData; +} ResDataParse; + +#define M_RESDATASEQ_TEXT 0x0001 + +typedef struct { + char name[16]; + int32 off; // offset from this adr +} ResRDSLab; + +typedef struct { + int32 offBefore; // offset from this adr (0=empty) + int32 offCleanup; // offset from this adr (0=empty) + int32 offStart; // offset from this adr (0=empty) +} ResRDSSig; + +// rds +// char text[rds->dataSize] +// ResRDSLab labels[rds->nLab] +// ResRDSSig signals[rds->nSig] + +typedef struct { + uns16 flags; + uns16 allocSize; + uns16 dataSize; + uns16 beforeOff; + uns16 cleanupOff; + uns16 firstOff; + uns16 nLab; + uns16 nSig; +} ResDataSeq; + +enum { + RESDATALIGHT_NONE, + RESDATALIGHT_AMBIENT, + RESDATALIGHT_DIRECTIONAL, + RESDATALIGHT_POSITIONAL, + RESDATALIGHT_SPOT, +}; + +enum { + RESDATALIGHTP_SPOT_CONE, +}; + +#define M_RESDATALIGHT_SHADDIR 0x01 +#define M_RESDATALIGHT_SHADPOS 0x02 +#define M_RESDATALIGHT_NOLIGHT 0x04 +typedef struct { + uns8 type; + uns8 flags; + uns16 atSize; + float pos[3]; + float dir[3]; + float rgb[3]; // intensity 'baked' in + float parameters[4]; // parameters + char *atBuf; +} ResDataLight; + +enum { + RESDATACOLTYPE_NONE, + RESDATACOLTYPE_SINGLE, + RESDATACOLTYPE_SKEL, + RESDATACOLTYPE_PROP, +}; + +#define M_RESDATACOL_RTS 0x01 // has ResDataColRTS imm following + +typedef struct { + uns8 flags; + uns8 type; + uns16 atSize; + char *atBuf; + void *blocks; + void *polys; +} ResDataCol; + +typedef struct { + float rts[12]; +} ResDataColRTS; + +enum { + RESDATACOLBLOCK_NONE, + RESDATACOLBLOCK_XZMM, + RESDATACOLBLOCK_XYZR, +}; + +typedef struct { + uns8 type; // must be in 1st int + uns8 flags; + uns16 xx1; +} ResDataColBlock; + +typedef struct { + ResDataColBlock blk; + float minx; + float miny; + float minz; + float maxx; + float maxy; + float maxz; + float xyzr[4]; + int32 off; // offset to list of offsets to G_ResDataGBPoly +} ResDataCBXZMM; + +typedef struct { + ResDataColBlock blk; + char colName[PM_NAME_SIZE]; + uns16 jointNum; + uns16 colNum; + float xyzr[4]; // xyz of center and r*r + int32 off; // offset to list of offsets to G_ResDataGBPoly +} ResDataCBXYZR; + +#define RESDATACBPOLY_NUMV_END 0xff + +typedef struct { + float vrt[3]; + float nrm[3]; +} ResDataCBVN; + +typedef struct { + uns8 numv; + uns8 xx1; + uns16 xx2; + float nrmk[4]; // normal & plane constant + ResDataCBVN v[3]; + // followed by other ResDataCBVN needed +} ResDataCBPoly; + +typedef struct { + struct { + float vrt[3]; + } v[3]; +} ResDataCBTri; + +typedef struct { + uns8 ascii; + uns8 xx1; + uns16 xx2; + float uvbox[BOX_SIZE]; // ltrb + float camsize[2]; // xy + float campivot[2]; // xy +} ResDataFChar; + +#define M_RESDATAFONT_HASALPHA 0x0001 + +typedef struct { + uns16 flags; + uns16 xx1; + uns16 asciiFirst; + uns16 numfcs; + uns32 texHash; + uns32 texGen; + void *fcs; // ResDataFChar +} ResDataFont; + +#define RES_FRAME_TIME PM_FRAME_TIME // 16 milliseconds per frame == approx 60 frames-per-second + +#define RES_CAM2D_W 136.6//64 +#define RES_CAM2D_H 76.8//48 +#define RES_CAM2D_Z 100 + +extern int xResInit(void); +extern void xResFinal(void); +extern int xResStart(void); +extern int xResRelease(); + +extern int xResLoadDisp(Res *res,void *rhdata); +extern int xResLoadVid(Res *res,void *rhdata); +extern int xResLoadImg(Res *res,void *rhdata); +extern int xResLoadCam(Res *res,void *rhdata); +extern int xResLoadLight(Res *res,void *rhdata); +extern int xResLoadSkel(Res *res,void *rhdata); +extern int xResLoadGroup(Res *res,void *rhdata); +extern int xResLoadCol(Res *res,void *rhdata); +extern int xResLoadFont(Res *res,void *rhdata); + +#endif // SYS_PC|SYS_BB +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +enum { + RESPARSE_NONE, + + RESPARSE_GEO, + RESPARSE_GND, + RESPARSE_LOOP, + RESPARSE_DONTLOOP, + RESPARSE_FOG, + RESPARSE_DC, + RESPARSE_HELP, + RESPARSE_BLEND, + RESPARSE_MIN, + RESPARSE_MAG, + RESPARSE_MIP, + RESPARSE_LIGHTS, + RESPARSE_LIGHT, + RESPARSE_ANIS, + RESPARSE_Q, + RESPARSE_DISP, + RESPARSE_CAM, + RESPARSE_GRID, + RESPARSE_JOINTS, + RESPARSE_PAUSE, + RESPARSE_STEP, + RESPARSE_DEER, + RESPARSE_BAN, + RESPARSE_RAN, + RESPARSE_NUL, + RESPARSE_HOLD, + RESPARSE_RUN, + RESPARSE_SET, + RESPARSE_CAT, + RESPARSE_CFG, + RESPARSE_FLAGS, + RESPARSE_KILL, + RESPARSE_SEQ, + RESPARSE_ANI, + RESPARSE_FRAME, + RESPARSE_ALLOC, + RESPARSE_SIZE, + RESPARSE_BIN, + RESPARSE_LOAD, + RESPARSE_ADD, + RESPARSE_WIRE, + RESPARSE_TIME, + RESPARSE_WAVE, + RESPARSE_OFF, + RESPARSE_IF, + RESPARSE_LEVEL, + RESPARSE_VERS, + RESPARSE_INFO, + RESPARSE_LOG, + RESPARSE_BEFORE, + RESPARSE_CLEANUP, + RESPARSE_START, + RESPARSE_PRINT, + RESPARSE_FC, + RESPARSE_BR, + RESPARSE_SLEEP, + RESPARSE_SLOOP, + RESPARSE_FIND, + RESPARSE_SIGNAL, + RESPARSE_SIGNALS, + RESPARSE_RETURN, + RESPARSE_SWATCH, + RESPARSE_FAIL, + RESPARSE_FLAG, + RESPARSE_CREATE, + RESPARSE_TAG, + RESPARSE_SEND, + RESPARSE_OBJ, + RESPARSE_MARK, + RESPARSE_MEM, + RESPARSE_NOP, + RESPARSE_TOOL, + RESPARSE_KEYMACRO, + RESPARSE_DBG, + RESPARSE_GAME, + RESPARSE_SUB, + RESPARSE_ELF, + RESPARSE_COL, + RESPARSE_STR, + RESPARSE_SOUND, + RESPARSE_SHAD, + RESPARSE_SORTBUFSIZE, + RESPARSE_DONTCULL, + RESPARSE_CURS, + RESPARSE_GUNSPEED, + RESPARSE_OP, + RESPARSE_MINTRI, + RESPARSE_MINQUAD, + RESPARSE_FINDNAME, + RESPARSE_BOZORET, + RESPARSE_VSYNC, + RESPARSE_VIDPLAY, + RESPARSE_VIDSTOP, + RESPARSE_VIDREADY, + RESPARSE_VIDDONE, + RESPARSE_VIDALINK, + + RESPARSE_PARENOPEN, + RESPARSE_PARENCLOSE, + RESPARSE_QUESTIONMARK, + RESPARSE_DOT, + RESPARSE_DASH, + + RESPARSE_X, // -- end of parsable tokens + + RESPARSE_STRING, + RESPARSE_LABEL, + RESPARSE_REVERT=-100, +}; + +typedef struct { + void *root; + char *str; + char *revert; + Res *res; + char *outBuf; + uns outBufSize; + memu *binBuf; // binbuf + memu *varBuf; // binbuf + int depth; + int8 fail; + uns8 brk; + uns16 nLab; + void *lab; + uns16 nSig; + void *sig; + void *rastack[8]; + uns16 radepth; +} ResParseH; + +typedef struct { + char name[PM_NAME_SIZE]; + void* adr; + uns8 ftype; + uns8 flags; + uns16 xx1; +} ResDataFTOne; + +typedef struct { + uns16 nFTypes; + uns16 xx1; + void *ftypes; +} ResDataFType; + +extern int ResInit(void); +extern void ResFinal(void); +extern int ResReset(uns reset); + +extern int ResNew(void *resp,uns sub,uns size,uns flags,char *name); +extern int ResKill(void *r); +extern int ResLevelKill(int level); +extern void ResLoopEnd(void); +extern int ResIsSub(void *r,uns8 subtype); + +extern void* ResFindNth(N2 *list,char *name,int *nth,int level); +extern void* ResFindSubNth(N2 *list,char *name,uns subtype,int *nth); +extern int ResLoad(void *resp,char *name); +extern int ResCmp(char *ngame,char *ndata); + +extern int ResRDSLabAdr(ResDataSeq *rds,char *s1,char *s2,void *adrp); +extern int ResRDSSigAdr(ResDataSeq *rds,int n,char type,void *adrp); +extern int ResRDSVars(void *osr,ResDataSeq *rds,memu **adrp); +extern int ResRDSCall(void *osr,ResDataSeq *rds,void *adr); + +extern int ResParseBlock(ResDataParse *rdp,char **nextp); +extern int ResParseText(void *root,memu *bin,memu *var,char *s1,char *s2); +extern int ResParse(Res *res,char *buf,char **nextp); +extern int ResParseSeq(char *seq); +extern int ResScript(char *script); + +extern void* ResLoadedFirst(void); +extern int ResLoadedCount(void); + +extern int ResInfoExpand(char *buf,int size,Res *r,uns flags); +extern int ResSelect(Res *r); + +extern int ResRunCommandFile(char *name); +extern int ResParseSet(ResParseH *fhb,Res *res,char *str,char *outBuf,uns outBufSize); +extern int ResParseTok(ResParseH *fhb,char **s1p,char **s2p,char *terms); +extern int ResParseRaw(ResParseH *fhb,char **s1p,char **s2p,char *terms); +extern int ResParsePAREN(ResParseH *fhb); +extern memu *ResParseVarAdr(ResParseH *fhb,char *s1,char *s2); + +enum { + RESGEN_NONE, + RESGEN_GET_NAMED_RESDATASEQ, // (char *name,ResDataSeq**rdsp) + RESGEN_RESDATASEQ_TO_BUF, // (ResDataSeq *rds,char **bufp) + RESGEN_RESDATAKAN_TO_BUF, // (ResDataKan *rdk,char **bufp) + RESGEN_GET_NAMED_RESANIGROUP, // (char *name,Res **rp) + RESGEN_RESANIGROUP_TO_BUF, // (Res *r,char **bufp) + RESGEN_GET_NAMED_RESDATACOL, // (char *name,ResDataCol**rdcp) + RESGEN_RESDATACOL_TO_BUF, // (ResDataCol *rdc,char **bufp) + RESGEN_GET_NAMED_RESDATALIGHT, // (char *name,ResDataLight**rdlp) + RESGEN_RESDATALIGHT_TO_BUF, // (ResDataLight *rdl,char **bufp) +}; +#define M_RESGEN 0xff +#define S_RESGEN_N 8 + +extern int ResGen(uns cmd,void *src,void *dst); + +// -- move into new file +enum { + GAMECALLBACK_NONE, + GAMECALLBACK_ADD_RES, // (char *name) + GAMECALLBACK_SET_WAVE_TIME, // (uns time) + GAMECALLBACK_GET_WAVE_TIME, // (uns*)&time +}; +#define M_GAMECALLBACK 0xff +extern int GameCallback(uns cmd,void *src,void *dst); + +int ResFCPNext(void *fcp,char type,int n,void *dst); + +enum { + RESFCP_NONE, + RESFCP_GETVARS, // (memu**)varptr -- returns number of vars + RESFCP_PARSE_VAR, // (memu*)&var + RESFCP_PARSE_VAD, // (memu*)&vad + RESFCP_GETANDCLEAR_SIGNALDATA, // (memu*)&ptr + RESFCP_GET_SIGNALDATA, // (memu*)&ptr +}; +#define M_RESFCP_CMD 0xff + +int ResFCPCmd(void *fcp,int cmd,void *a,void *b); + +extern char *ResResSubTable[]; +extern char *ResObjSubTable[]; + +enum { + RESKANOP_NONE, + RESKANOP_NUMKEYS, + RESKANOP_FIRSTFRAME, // *(float*)=time + RESKANOP_MOVEDELTA, // *(float*)=time +}; + +#define M_RESKANOP 0xff + +extern int ResKanOp(int op,ResDataKan *kan,void *a); + +extern int ResNFSZeroTime(void *nsr,N2 *n); +extern int ResNFSFlag(void *nsr,N2 *n); +extern int ResNFSImg(void *nsr,N2 *n); + +enum { + RESSEQCB_NONE, + RESSEQCB_SLEEPINIT, + RESSEQCB_SLEEPING, +}; +#define M_RESSEQCB 0xff +extern int ResSeqCB(uns op,void *osr); + +#endif // ndef RES_H diff --git a/dond/core/snd.c b/dond/core/snd.c new file mode 100755 index 0000000..64cee6f --- /dev/null +++ b/dond/core/snd.c @@ -0,0 +1,268 @@ +// snd.c +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 25 Apr 05 + +#include "pm.h" +#include "snd.h" +#include "fs.h" +#include "str.h" +#include "mem.h" + +#include +#include + +typedef struct { + uns8 mute; + int vol; + int minVol; + int maxVol; + uns32 jpsvers[3]; +} sndGlobals; + +sndGlobals sndG; + +// JFL 25 Apr 05 +int SndInit(void) +{ + MEMZ(sndG); + sndG.minVol=0; + sndG.maxVol=255; + jps_init(); + + jps_version(&sndG.jpsvers[0],&sndG.jpsvers[1],&sndG.jpsvers[2]); + + return 0; +} // SndInit() + +// JFL 25 Apr 05 +int SndReset(uns reset) +{ + MEMZ(sndG); + return 0; +} // SndReset() + +// JFL 25 Apr 05 +void SndFinal(void) +{ + jps_shutdown(); +} // SndFinal() + +// JFL 26 Apr 05 +void* sndBankFindName(char *s1,char *s2) +{ + int i; + jps_bank *b; + + for(i=0;inameStr,NUL)) + return b; + } // for + return NUL; +} // sndBankFindName() + +// JFL 26 Apr 05 +int SndLoad(char *s1,char *s2) +{ + int ec; + char pathbuf[PM_FILEPATH_MAX]; + jps_bank *b; + + if(sndBankFindName(s1,s2)) + err(1); // already + + szncpy(pathbuf,SysG.sndpath,sizeof(pathbuf)); + + if(1 + && ((ec=szlen(pathbuf))>0) + && (ecnameStr,s1,s2,sizeof(b->nameStr)); + + ec=0; +BAIL: + return ec; +} // SndLoad() + +// JFL 26 Apr 05 +int SndUnload(char *s1,char *s2) +{ + int ec; + jps_bank *b; + + if(!(b=sndBankFindName(s1,s2))) + err(1); + + jps_bank_free(b); + + ec=0; +BAIL: + return ec; +} // SndUnload() + +//MTM +void SndStopAll(void) +{ + SndPlay(0); +} + +// JFL 26 Apr 05 +int SndPlay(uns n) +{ + jps_play(NUL,n,255); // play at 100% of master volume + return 0; +} // SndPlay() + +// JFL 11 May 05 +// JFL 27 Jul 05; vol as percent +int SndPlayVol(uns n,int vol) +{ + // this vol is a % of sndG.vol + // eg -- 255=100% 128=50% 64=25% + + if(vol<0) vol=0; + if(vol>255) vol=255; + jps_play(NUL,n,vol); + return vol; +} // SndPlayVol() + +// JFL 26 Apr 05 +// JFL 27 Jul 05 +int SndVol(int vol) +{ + if(volsndG.maxVol) + vol=sndG.maxVol; + sndG.vol=vol; + jps_master_volume(vol); + return vol; +} // SndVol() + + +//ignores minVol - lets you turn off sound +void SndVolOff() +{ + sndG.vol=0; + jps_master_volume(0); + +} // SndVolOff() + + + +// MTM -- --- 05 +int SndGetVol(void) +{ + return sndG.vol; +} // SndGetVol() + +// JFL 13 May 05 +int SndVolMinMax(int *minp,int *maxp,uns flags) +{ + if(flags) + { + if(minp) + sndG.minVol=*minp; + if(maxp) + sndG.maxVol=*maxp; + } + else + { + if(minp) + *minp=sndG.minVol; + if(maxp) + *maxp=sndG.maxVol; + } + + if(sndG.minVol<0) + sndG.minVol=0; + if(sndG.maxVol>255) + sndG.maxVol=255; + + return 0; +} // SndVolMinMax() + +// JFL 18 Jul 05 +int SndOp(uns op,...) +{ + int ec; + va_list args; + char *buf; + int n; + + va_start(args,op); + + switch(op&M_SNDOP) + { + case SNDOP_GETVERS: + buf=va_arg(args,char*); + n=va_arg(args,int); + szbuild(buf,n,"%d.%d.%d",sndG.jpsvers[0],sndG.jpsvers[1],sndG.jpsvers[2]); + break; + default: + err(-1); + } // switch + + ec=0; +BAIL: + va_end(args); + return ec; +} // SndOp() + +// +// SndInfo +// print sound system information into output buffer +// used for debug information +// +// in: +// buf = string buffer +// bufSize = size of string buffer +// +// out: +// +// GNP 27 Feb 06; from MemInfo +// +int SndInfo(char *buf,int bufSize) +{ + int i; + jps_bank *b; + + if(!buf || !bufSize) + return 1; + buf[0]=0; + + szbuild(buf,bufSize,"<-cat>sound banks loaded:\n"); + // print loaded banks + for(i=0;i%s\n",b->nameStr); + } // for + + // print memory usage info + szbuild(buf,bufSize,"<-cat>\njps memory usage:\n"); + szbuild(buf,bufSize,"<-cat>inuse=%x\n",MemSysInfo.jpsOutstanding); + szbuild(buf,bufSize,"<-cat>allocs=%d\n",MemSysInfo.jpsCount); + szbuild(buf,bufSize,"<-cat>largest=%x\n",MemSysInfo.jpsLargest); + + + return 0; +} // SndInfo() + +// EOF diff --git a/dond/core/snd.h b/dond/core/snd.h new file mode 100755 index 0000000..8c9a98e --- /dev/null +++ b/dond/core/snd.h @@ -0,0 +1,38 @@ +#ifndef SND_H +#define SND_H +// snd.h +// Copyright 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 25 Apr 05 + +/////////////////////////////////////////////////////////////////////////////// +// JPS + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +/////////////////////////////////////////////////////////////////////////////// +// + +extern int SndInit(void); +extern void SndFinal(void); +extern int SndReset(uns reset); +extern int SndLoad(char *s1,char *s2); +extern int SndUnload(char *s1,char *s2); +extern int SndPlay(uns n); +extern int SndPlayVol(uns n,int vol); +extern void SndStopAll(void); +extern int SndVol(int n); +extern int SndGetVol(void); +extern int SndVolMinMax(int *minp,int *maxp,uns flags); +extern void SndVolOff(); +extern int SndInfo(char *buf,int bufSize); + +enum { + SNDOP_NONE, + SNDOP_GETVERS, // char *buf,int bufsize +}; +#define M_SNDOP 0xff +extern int SndOp(uns op,...); + +#endif // ndef SND_H diff --git a/dond/core/str.c b/dond/core/str.c new file mode 100755 index 0000000..62610c5 --- /dev/null +++ b/dond/core/str.c @@ -0,0 +1,1194 @@ +// str.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04 + +#include +#include "pm.h" +#include "str.h" + +/////////////////////////////////////////////////////////////////////////////// +// STRINGS + +char *str_digit="+01234567890-.+"; +char *str_equal="="; + +// JFL 05 Dec 99 +// copy till n-1 or eos / copy till eos if n==0 / guaranteed eos, return len +int szncpy(char *dst,char *src,int n) +{ + int len=0; + + if(!dst || !src) + return 0; + + if(!n) + { + while((*dst++=*src++)) + len++; + } + else + { + n--; + while(len>=4);shift++) + ; + + n--; + while(len>(4*shift); + c=rval&0xf; + if(c>9) + c+='A'-10; + else + c+='0'; + + *dst++=c; + len++; + + if(shift--<=0) + break; + } // while + *dst=0; + + return len; +} // sznfmt() + +// JFL 28 Jan 04 +int szncpy2(char *dst,char *s1,char *s2,int n) +{ + int len=0; + + if(!n) + return 0; + + while(*s1 && n) + { + if(s2 && (memu)s1>=(memu)s2) + break; + *dst++=*s1++; + len++; + n--; + } // while + + if(n) + *dst=0; + else + dst[-1]=0; + + return len; +} // szncpy2() + +// JFL 28 Jan 04 +int szncat2(char *dst,char *s1,char *s2,int n) +{ + int len=0; + + if(!n) + return 0; + + while(*dst && n) + { + dst++; + len++; + n--; + } // while + + if(s1) + { + while(*s1 && n) + { + *dst++=*s1++; + len++; + n--; + } // while + } + + if(s2) + { + while(*s2 && n) + { + *dst++=*s2++; + len++; + n--; + } // while + } + + if(n) + *dst=0; + else + dst[-1]=0; + + return len; +} // szncat2() + +// JFL 28 Jan 04 +// JFL 12 Aug 04 +int sz2ncat2(char *dst,char *s1,char *s1x,char *s2,char *s2x,int n) +{ + int len=0; + + if(!n) + return 0; + + while(*dst && n) + { + dst++; + len++; + n--; + } // while + + if(s1) + { + while(n && *s1 && (!s1x || s1='A'&&c<='Z') c = c - 'A' + 'a'; + if(d>='A'&&d<='Z') d = d - 'A' + 'a'; + if(c!=d) + return 1; + if(!c) + return 0; + goto lp; +} // szcmp() + +// JFL 15 Aug 04 +char* szchr(char *s1,char *s2,char c) +{ + if(!s1) + return NUL; + for(;!s2 || s1=s1;s2--) + { + if(c==*s2) + return s2; + } // for + } + else + { + ret=NUL; + for(;!s2 || s1m) + n=m; + } + + // if no length, match + if(!n) + return 0; + + for(;;) + { + // get & compare + s=*s1; + t=*t1; + if(s>='A'&&s<='Z') s=s-'A'+'a'; + if(t>='A'&&t<='Z') t=t-'A'+'a'; + + // check for either ending + if(s2&&((memu)s1>=(memu)s2)) + s=0; + if(t2&&((memu)t1>=(memu)t2)) + t=0; + if(!s || !t) + { + if(!s&&!t) + return 0; // match + return 1; // mismatch + } + s1++; + t1++; + + if(s!=t) // mismatch + return 1; + if(!--n) // length done, match + return 0; + } // for +} // sznicmp() + +// JFL 28 Mar 05 +int sz2cmpx(char *s1,char *s2,char *t1,char *t2) +{ + char s,t; + + // if either doesn't start, fail + if(!s1 || !t1) + return 1; + + for(;;) + { + // get & compare + s=*s1++; + if(s=='*') return 0; + t=*t1++; + if(s>='A'&&s<='Z') s=s-'A'+'a'; + if(t>='A'&&t<='Z') t=t-'A'+'a'; + if(!s && !t) return 0; + if(!s || !t || (t2&&(t1>t2)) || (s2&&(s1>s2))) return 1; + + if(s!=t) + { + if(s!='?') return 1; + } + + if(s2&&(s1==s2)) + { + if(t2&&(t1!=t2)) + return 1; + return 0; + } + + } // for +} // sz2cmpx() + +// JFL 20 Oct 04 +int szcmpx(char *s1,char *s2) +{ + int c,d; + +lp: + c=*s1++;d=*s2++; + if(!c) + return 0; + if(!d) + return 1; + if(c=='?') // match anything + goto lp; + if(c>='A'&&c<='Z') c = c - 'A' + 'a'; + if(d>='A'&&d<='Z') d = d - 'A' + 'a'; + if(c!=d) + return 1; + goto lp; +} // szcmpx() + +// JFL 16 Sep 04 +// JFL 07 Dec 04; base & floats +char *szto(char *s1,char *s2,char type,int base,void *dst) +{ + int64 ival; + uns64 uval; + double fval,decimal; + char i,n; + uns8 c; + + if(!dst || !s1) + return s1; + + if(!base) + base=10; + + if(s1[0]=='0' && (s1[1]=='x'||s1[1]=='X')) + { + base=16; + s1+=2; + } + + switch(type) + { + case 'i': + case 'c': + case 'p': + case 'u': + ival=0; + uval=0; + break; + case 'f': + case 'd': + fval=0; + decimal=0; + break; + default: + BP(BP_SZTO); + type='i'; + ival=0; + } // switch + + if(!s1) + goto done; + + i=0; + n=0; +loop: + if(s2 && (s1>=s2)) + goto done; + if(!(c=*s1)) + goto done; + switch(type) + { + case 'i': + case 'c': + case 'p': + case 'u': + if(!i && c=='-') + n=1; + else + { + if(c>='0'&&c<='9') + c-='0'; + else if(c>='a'&&c<='z') + c=c-'a'+10; + else if(c>='A'&&c<='Z') + c=c-'A'+10; + else + goto done; + if(c>=base) + goto done; + + ival*=base; + ival+=c; + + uval*=base; + uval+=c; + + } // numerical + break; + case 'f': + case 'd': + if(!i && c=='-') + n=1; + else + { + if(c>='0'&&c<='9') + c-='0'; + else if(c>='a'&&c<='z') + c=c-'a'+10; + else if(c>='A'&&c<='Z') + c=c-'A'+10; + else if(c=='.') + { + decimal=1; + break; + } + else + goto done; + if(c>=base) + goto done; + + fval*=base; + fval+=c; + + decimal*=base; + } // numerical + break; + } // switch + +//next: + i++; + s1++; + goto loop; + +done: + + if(n) + { + ival=-ival; + fval=-fval; + } + + switch(type) + { + case 'i': + *((int*)dst)=(int)ival; + break; + case 'u': + *((uns*)dst)=(int)uval; + break; + case 'p': + *((void**)dst)=(void*)((memu)ival); + break; + case 'c': + *((char*)dst)=(char)ival; + break; + case 'f': + if(decimal) + fval/=decimal; + *((float*)dst)=(float)fval; + break; + case 'd': + if(decimal) + fval/=decimal; + *((double*)dst)=fval; + break; + } // switch + + return s1; +} // szto() + +// JFL 08 Jan 04 +char* szmatok(char *src,char till) +{ + char c; + + if(!src) + return NUL; +top: + if(!(c = *src)) + return src; + if(c=='\\') + { + src++; + goto escaped; + } + if(till) + { + if(c==till) + return src; + } + else + { + if(C_IS_WHITE(c)) + return src; + if(c==';') + return src; + if(c=='\"') + src=szmatok(src+1,'\"'); + } +escaped: + src++; + goto top; +} // szmatok() + +// JFL 28 Jan 04 +// JFL 12 Aug 04 +int sz2map(char *table[],char *str,char *strx) +{ + int i,c,d; + char *s,*t; + + if(!str) + return 0; + + for(i=0;;i++) + { + if(!(t=table[i])) + return 0; + s=str; +lp: + c=*s; + d=*t; + + // check for end of either string + if(strx&&((memu)s>=(memu)strx)) + c=0; + if(!c || !d) + { + if(!c&&!d) + return i; // match + continue; // no match + } // end + + s++; + t++; + + if(c>='A'&&c<='Z') c = c - 'A' + 'a'; + if(d>='A'&&d<='Z') d = d - 'A' + 'a'; + + if(c!=d) // no match + continue; + + goto lp; + } // for +} // sz2map() + +// JFL 08 Jan 04 +// JFL 12 Aug 04; DT +// JFL 05 Nov 04; AT +char* szATTok(char *src,char till,char *terms) +{ + char c,*t; + + if(!src) + return NUL; +top: + if(!(c = *src)) + return src; + if(c=='\\') + { + src++; + goto escaped; + } + if(till) + { + if(c==till) + return src; + } + else + { + if(c=='\"') + src=szATTok(src+1,'\"',NUL); + else if(!terms) + { + if(!C_IS_TOKEN(c)) + return src; + } + else + { + t=terms; + if(*t=='+') + { + for(t++;*t;t++) + if(*t==c) + goto keepit; + return src; + } + else + { + for(;*t;t++) + if(*t==c) + return src; + } + } + } +keepit: +escaped: + src++; + goto top; +} // szATTok() + +// JFL 11 Nov 04 +int fmtInt(char *dst,int n,int ival,int base) +{ + // this routine does not terminate the string + + int len=0; + int val,i,j,x; + uns mul,uval; + uns64 mm,uu; + char neg=0; + char digits[100]; + + if(!ival) + { + *dst='0'; + return 1; + } + + if(ival==1) + { + *dst='1'; + return 1; + } + + if(ival<0 && (base==10)) + { + neg=1; + val=(int)-ival; + *dst++='-'; + len++; + if(n && len>=n) + goto BAIL; + } + else + val=(int)ival; + + // -- this routine needs work.. + + uval=val; + if(uval>0xfffffff) + { + uu=uval; + + i=0; + mm=1; + for(i=0,mm=1;uu >= mm;i++,mm*=base) + /* */ ; + + if(i>=COUNT(digits)) + i=COUNT(digits)-1; + + j=i; + mm/=base; + for(;i&&mm;i--,mm/=base) + { + x=(int)(uu/mm); + if(x<10) + digits[i-1]=x+'0'; + else + digits[i-1]=x-10+'A'; + uu-=x*mm; + } // for + + + } + else + { + i=0; + mul=1; + for(i=0,mul=1;uval >= mul;i++,mul*=base) + /* */ ; + + if(i>=COUNT(digits)) + i=COUNT(digits)-1; + + j=i; + mul/=base; + for(;i&&mul;i--,mul/=base) + { + x=uval/mul; + if(x<10) + digits[i-1]=x+'0'; + else + digits[i-1]=x-10+'A'; + uval-=x*mul; + } // for + } + + while(j--) + { + *dst++=digits[j]; + len++; + if(n && len>=n) + break; + } // while + +BAIL: + return len; +} // fmtInt() + +// JFL 24 May 05 +int fmtExpand(char *dst,int n,int cur,int growto,char padc) +{ + int i,j; + if(growto>n) + growto=n; + if(cur>=growto) + return cur; + for(j=growto-1,i=cur-1;i>=0;i--,j--) + dst[j]=dst[i]; + for(i=0;i=n) + goto BAIL; + break; + case 'x': + ival=va_arg(ap,int); + i=fmtInt(dst,n-len,ival,16); + + if(i=n) + goto BAIL; + break; + case 'd': + case 'i': + ival=va_arg(ap,int); + i=fmtInt(dst,n-len,ival,10); + + if(i=n) + goto BAIL; + break; + case 'g': + case 'f': + dval=va_arg(ap,double); + ival=(int)dval; + + i=fmtInt(dst,n-len,ival,10); + + if(i=n) + goto BAIL; + + fltmul=10; + i=fltwidth; + while(--i>0) + fltmul*=10; + + dval-=ival; + ival=(int)(dval*fltmul); + if(ival<0) + ival=-ival; + + if(ival || fltwidthset) + { + *dst++='.'; + len++; + if(n && len>=n) + goto BAIL; + + i=fmtInt(dst,n-len,ival,10); + + if(i=n) + goto BAIL; + } + break; + case 's': + if(!(sval=va_arg(ap,char*))) + break; + for(;(c=*sval++);) + { + *dst++=c; + len++; + if(n && len>=n) + goto BAIL; + } // for + + break; + case 'S': + if(!(sval=va_arg(ap,char*))) + break; + if(!(s2=va_arg(ap,char*))) + break; + for(;(c=*sval);sval++) + { + if(s2 && ((memu)sval>=(memu)s2)) + break; + *dst++=c; + len++; + if(n && len>=n) + goto BAIL; + } // for + + break; + default: + + if((c=='0')&&(p[-2]=='%')) + { + leadc='0'; + goto fmtlp; + } + else if((c>='0')&&(c<='9')) + { + p--; + if(p[-1]=='.') + { + fltwidthset=1; + p=szto(p,NUL,'i',10,&fltwidth); // get precision request + } + else + p=szto(p,NUL,'i',10,&fmtwidth); // get width request + goto fmtlp; + } + break; + } // switch + } // % + else + { +setdst: + *dst++=c; + len++; + if(n && len>=n) + goto BAIL; + } + + goto loop; + +BAIL: + *dst=0; + return len; +} // szbuild_ap + +// JFL 11 Nov 04 +// JFL 06 Dec 04 +int szbuild(char *dst,int n,char *fmt,...) +{ + int len; + va_list ap; + va_start(ap,fmt); + len=szbuild_ap(dst,n,fmt,ap); + va_end(ap); + return len; +} // szbuild() + +// JFL 26 Nov 04 +char* szmid(char *mid,char *src) +{ + int k; + char *s,c,d; + + if(!src) + return NUL; +top: + if(!(c = *src)) + return NUL; + + for(s=mid,k=0;;k++) + { + if(!(c=s[k])) + return src; + d=src[k]; + + if(c>='A'&&c<='Z') c = c - 'A' + 'z'; + if(d>='A'&&d<='Z') d = d - 'A' + 'z'; + + if(c!=d) + break; + } // for + + src++; + goto top; +} // szmid() + +// EOF diff --git a/dond/core/str.h b/dond/core/str.h new file mode 100755 index 0000000..b7889f1 --- /dev/null +++ b/dond/core/str.h @@ -0,0 +1,51 @@ +#ifndef STR_H +#define STR_H +// str.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04 + +/////////////////////////////////////////////////////////////////////////////// +// STRINGS + +#define SZ_IS_HEX STR_IS_HEX +#define STR_IS_HEX(_s_) (((_s_)[0]=='0')&&(((_s_)[1]=='x')||((_s_)[1]=='X'))) + +extern char *str_digit; +extern char *str_equal; +#define C_IS_TOKEN(c) ((c>='0'&&c<='9')||(c>='a'&&c<='z')||(c>='A'&&c<='Z')||(c=='_')||(c=='$')||(c=='.')||(c=='-')||(c=='*')||(c=='?')) +#define C_IS_LABEL(c) ((c>='0'&&c<='9')||(c>='a'&&c<='z')||(c>='A'&&c<='Z')||(c=='_')) +#define C_IS_WHITE(c) (c==' '||c=='\t'||c=='\n'||c=='\r') +#define C_IS_DIGIT(c) (c>='0'&&c<='9') +#define C_IS_NUMBER(c) ((c>='0'&&c<='9')||(c=='-')||(c=='.') +#define C_IS_QUOTE(c) (c=='\"'||c=='\'') +#define C_TO_LOWER(_c_) ((_c_>='A'&&_c_<='Z')?_c_-'A'+'a':_c_) +extern int szlen(char *s1); +extern char* szend(char *s1); +extern int szncpy(char *dst,char *src,int n); +extern int szncpy2(char *dst,char *s1,char *s2,int n); +extern int szncat2(char *dst,char *s1,char *s2,int n); +extern int sz2ncat2(char *dst,char *s1,char *s1x,char *s2,char *s2x,int n); +extern int sz2ncpy(char *dst,char *s1,char *s2,int n); +extern char* szskip(char *src,char *skip); +extern char* szskipto(char *src,char *skipto); +extern char* szskipover(char *src,char *skip); +extern char* szskipwhite(char *src); +extern char* szskiptowhite(char *src); +extern int szcmp(char *s1,char *s2); +extern char* szmid(char *s1,char *s2); +extern char* szchr(char *s1,char *s2,char c); +extern char* szrchr(char *s1,char *s2,char c); +extern int sznicmp(char *s1,char *s2,char *t1,char *t2,int n); +extern int sznfmt(char *dst,int n,char fmt,uns8 *dat); +extern char *szto(char *s1,char *s2,char type,int base,void *dst); +extern int szcmpx(char *s1,char *s2); +extern int sz2cmpx(char *s1,char *s2,char *t1,char *t2); +extern char* szATTok(char *src,char till,char *terms); +extern int sz2map(char *table[],char *str,char *strx); +extern char* szmatok(char *src,char till); +extern int szbuild(char *dst,int n,char *fmt,...); +extern int szbuild_ap(char *dst,int n,char *fmt,void *ap); + + +#endif // ndef STR_H diff --git a/dond/core/sys.c b/dond/core/sys.c new file mode 100755 index 0000000..de9802f --- /dev/null +++ b/dond/core/sys.c @@ -0,0 +1,1001 @@ +// sys.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 26 Aug 04 +// JFL 17 May 05 + +#include +#include + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "wnd.h" +#include "str.h" +#include "fs.h" +#include "res.h" +#include "obj.h" + +#define SYSLOG_MAX_SIZE 1024*1024*20 // maximum size of system log file (20MB) + +SysGlobals SysG; +uns8 SysPMBreakpointBehavior; +SysTimer SysuTimers[NUM_UTIMERS] = +{ + {0,0,"Frame"}, + {0,0,"System"}, + {0,0,"Network"}, + {0,0,"Cab"}, + {0,0,"Wind"}, + {0,0,"WindInp"}, + {0,0,"Input"}, + {0,0,"Proc"}, + {0,0,"Obj"}, + {0,0," Init"}, + {0,0," DrawDisp1"}, + {0,0," DrawDisp2"}, + {0,0," Matrix"}, + {0,0," Cull"}, + {0,0," Sort"}, + {0,0," SetupGL1"}, + {0,0," SetupGL2"}, + {0,0," Col"}, + {0,0," DrawDisp3"}, + {0,0," Matrix"}, + {0,0," Weight"}, + {0,0," SetupGL1"}, + {0,0," SetupGL2"}, + {0,0," Col"}, + {0,0," EmitPart"}, + {0,0," Flip"}, + {0,0," Sort"}, + {0,0," Shad"}, + {0,0," Cam"}, + {0,0," Text"}, + {0,0," Func"}, + {0,0," Ani"}, + {0,0," Seq"}, + {0,0," Vel"}, + {0,0," Col"}, + {0,0," Resolve"}, + {0,0,"GLUT"}, +}; + +// JFL 26 Aug 04 +int SysInit(void) +{ + int sn=SysG.projammasn; + MEMZ(SysG); + SysG.projammasn=sn; + + // + // init + // + + SysPMBreakpointBehavior=0; + + return xSysInit(); +} // SysInit() + +// JFL 26 Aug 04 +void SysFinal(void) +{ + xSysFinal(); +} // SysFinal() + +// JFL 26 Aug 04 +int SysReset(uns reset) +{ + return xSysReset(reset); +} // SysReset() + +// JFL 07 Oct 04 +int SysLoop(void) +{ + SysG.loop++; + SysG.loopTime+=SysG.forceFrameTime; + + if(SysG.restart) + return -1; + return 0; +} // SysLoop() + +// JFL 21 Mar 05 +int SysLog(char *fmt,...) +{ + va_list ap; + char buf[1024]; + char path[1024]; + FsH fsmem; + int n; + + va_start(ap,fmt); + n=szbuild_ap(buf,sizeof(buf),fmt,ap); + va_end(ap); + + path[0]=0; + sz2ncat2(path,SysG.logpath,NUL,"syslog_bb3.txt",NUL,sizeof(path)); + if((n>0)&&FsOpen(&fsmem,path,M_FSOPEN_APPEND + |M_FSOPEN_CREATEIFNOTFOUND|M_FSOPEN_WRITABLE)>=0) + { + FsWrite(&fsmem,buf,n); + FsClose(&fsmem); + } + + return 0; +} // SysLog() + +// +// SysLogCheck +// check the size of the system log +// if too big, then empty it +// +// GNP 18JAN06 +// +int SysLogCheck(void) +{ + char path[1024]; + FsH fsmem; + uns32 size; + + path[0]=0; + sz2ncat2(path,SysG.logpath,NUL,"syslog_bb3.txt",NUL,sizeof(path)); + if(FsOpen(&fsmem,path,0)>=0) + { + size = FsSize(&fsmem); + if (size > SYSLOG_MAX_SIZE) + { + // delete current syslog + FsClose(&fsmem); + if(FsOpen(&fsmem,path,M_FSOPEN_CREATEIFNOTFOUND|M_FSOPEN_WRITABLE|M_FSOPEN_DELETEDATA)>=0) + { + FsClose(&fsmem); + } + } + else + { + FsClose(&fsmem); + } + } + + return 0; +} // SysLogCheck() + +// +// SysLoadVersionInfo +// load version information from file version.txt +// +// GNP 01FEB06 +// +void SysLoadVersionInfo(void) +{ + char path[32]; + FsH fsmem; + int i; + + szncpy(path,"version.txt",sizeof(path)); + + if(FsOpen(&fsmem,path,0)>=0) + { + // version file is open + FsRead(&fsmem,SysG.versionstr,sizeof(SysG.versionstr)); + FsClose(&fsmem); + for(i=0;i>S_N2_LEVEL; // complex clamp + SysG.n2FlagsOr&=~M_N2_LEVEL; + SysG.n2FlagsOr|=lev<sec=tm->tm_sec; + dt->min=tm->tm_min; + dt->hour=tm->tm_hour; + dt->mday=tm->tm_mday; + dt->mon=tm->tm_mon; + dt->year=tm->tm_year; + dt->wday=tm->tm_wday; + dt->yday=tm->tm_yday; + dt->isdst=tm->tm_isdst; + + return 0; +} // SysDateTime() + +// JFL 17 May 05 +int SysDateTimeStr(SysDate *dt,char *buf,int bufsize,char *fmt) +{ + struct tm tmmem,*tm=&tmmem; + + if(!dt||!buf||!fmt||!bufsize) + return -1; + + tm->tm_sec=dt->sec; + tm->tm_min=dt->min; + tm->tm_hour=dt->hour; + tm->tm_mday=dt->mday; + tm->tm_mon=dt->mon; + tm->tm_year=dt->year; + tm->tm_wday=dt->wday; + tm->tm_yday=dt->yday; + tm->tm_isdst=dt->isdst; + + strftime(buf,bufsize-1,fmt,tm); + buf[bufsize-1]=0; + + return 0; +} // SysDateTimeStr() + +// +// SysDateTimeInSeconds +// return the system date and time in seconds +// this is stupid because of JFL's time functions above +// +// GNP 18JAN06 +// +uns32 SysDateTimeInSeconds(void) +{ + SysDate sd; + uns32 seconds; + + SysDateTime(&sd,0); + seconds = sd.year * 31556926 + sd.yday * 86400 + sd.hour * 3600 + sd.min * 60 + sd.sec; + + return(seconds); +} //SysDateTimeInSeconds + +// JFL 26 May 05 +// JFL 03 Jun 05 +// JFL 20 Jul 05; drive sn +int SysBuildInfo(uns op,char *buf,int bufsize,uns *idp) +{ + int ec; + + switch(op&M_SYSBUILDINFO) + { + case SYSBUILDINFO_GAMESN: + if(buf) + buf[0]=0; + if(idp) + *idp=0; + break; + case SYSBUILDINFO_HARDWARESN: + if(!buf) + err(-1); + ec=SysGetHardwareInfo(SYSGETHARDWAREINFO_SN,buf,bufsize); + if(idp) + *idp=ec; + szbuild(buf,bufsize,"%x",ec); + break; + case SYSBUILDINFO_HARDWARECP: + break; + case SYSBUILDINFO_HARDWARESTRING: + if(buf) + szncpy(buf,"0.1",bufsize); + if(idp) + *idp=0; + break; + case SYSBUILDINFO_SOFTWARESTRING: + if(buf) + szncpy(buf,"0.1",bufsize); + if(idp) + *idp=0; + break; + default: + if(buf) + buf[0]=0; + if(idp) + *idp=0; + } // switch + ec=0; +BAIL: + return ec; +} // SysBuildInfo() + +// +// SysMicroTimerStart +// start a micro-second timer +// +// in: +// out: +// global: +// +// GNP 12 Oct 05 +// +void SysMicroTimerStart(uns32 timerNum) +{ + if (timerNum >= NUM_UTIMERS) + return; + SysuTimers[timerNum].timer = SysMicroSec(); + + if ((SysuTimers[timerNum].count < 0) || (SysuTimers[timerNum].count > 10)) + SysuTimers[timerNum].count = 0; + +//DONE("SysMicroTimerStart") +} // SysMicroTimerStart + +// +// SysMicroTimerStop +// stop a micro-second timer that has previously +// been started with SysMicroTimerStart() +// +// in: +// out: +// global: +// +// GNP 12 Oct 05 +// +void SysMicroTimerStop(uns32 timerNum) +{ + uns64 curTime, elapsedTime; + + if (timerNum >= NUM_UTIMERS) + return; + curTime=SysMicroSec(); + if (curTime < SysuTimers[timerNum].timer) + { // counter wrapped + elapsedTime = curTime + 0xffffffffffffffff - SysuTimers[timerNum].timer; + } + else + { + elapsedTime = curTime - SysuTimers[timerNum].timer; + } + + SysuTimers[timerNum].timeacc += elapsedTime; + + SysuTimers[timerNum].count++; + +//DONE("SysMicroTimerStop") +} // SysMicroTimerStop + +// +// SysMicroTimerClear +// clear system micro-second timer +// +// in: +// timerNum = UTIMER_ +// out: +// global: +// +// GNP 13 Oct 05 +// +void SysMicroTimerClear(uns32 timerNum) +{ + SysuTimers[timerNum].timer=0; + // SysuTimers[timerNum].timeacc=0; + + if (SysuTimers[timerNum].count >= 10) + { + SysuTimers[timerNum].timeacc = 0; + SysuTimers[timerNum].count = 0; + } + +//DONE("SysMicroTimerClear") +} // SysMicroTimerClear + +// +// SysMicroTimerClearAll +// clear all system micro-second timers +// +// in: +// out: +// global: +// +// GNP 13 Oct 05 +// +void SysMicroTimerClearAll(void) +{ + int i; + + for (i=0;i>= (SHIFT_BITS-SHIFT_NUM); + u |= x; + u ^= a; + u &= 0xfffffff; + *dstp = u; + + return 1; +} + +uns32 sysChk1(uns32 opseed, uns32 actcode) +{ + uns32 v = sysDecode1(opseed,actcode); + + if (v == 0) + return 1; + else + return 0; +} + +uns32 sysDecode1(uns32 u,uns32 a) +{ + uns32 x = a; + + a >>= SHIFT_NUM; + x <<= (SHIFT_BITS-SHIFT_NUM); + a |= x; + a ^= u; + a &= 0xfffffff; + + return a; +} +/////////////////////////////////////////////////////////////////////////////// +// NODES + +// +// N1Link +// link given node into given list. +// node is linked on the end. +// +// in: +// headp = handle to head of list +// node = node to link +// out: +// global: +// +// GNP 09 Jun 00 +// JFL 06 Sep 04 +void N1LinkTail(void *headp,void *node) +{ + N1 *n; + + ((N1*)node)->next = (N1*)0; + + n = *((N1**)headp); + if(!n) + { + *((N1**)headp) = node; + } + else + { + while(n->next) + n = n->next; + n->next = node; + } + +//DONE("N1LinkTail") +} // N1LinkTail + +// +// N1LinkHead +// link given node into given list. +// node is linked on the head. +// +// in: +// headp = handle to head of list +// node = node to link +// out: +// global: +// +// GNP 09 Jun 00 +// +void N1LinkHead(void *headp,void *node) +{ + ((N1*)node)->next = *((void**)headp); + *((void**)headp) = node; +} // N1LinkHead + +// +// N1Unlink +// un-link node from given list +// +// in: +// headp = handle to head of list +// node = node to un-link +// out: +// <0 = fail +// global: +// +// GNP 09 Jun 00 +// JFL 04 Sep 04 +int N1Unlink(void *headp,void *node) +{ + N1 *n; + + n = *((N1**)headp); + if(!n) + return -1; + + if(n==node) + { + *((N1**)headp) = ((N1*)node)->next; + return 0; + } + else + { + while(n->next && n->next != node) + n = n->next; + + if(n->next == node) + { + n->next = ((N1*)node)->next; + return 0; + } + } + return -1; +} // N1Unlink + +// N2Head() +// JFL 10 Aug 04; from JoeCo +void N2Head(void *head) +{ + ((N2*)head)->next=((N2*)head)->prev=head; + ((N2*)head)->type=0; +} // N2Head() + +void N2DontLink(void *head) +{ + ((N2*)head)->next=((N2*)head)->prev=head; + ((N2*)head)->type=0; +} // N2Head() + +// N2LinkAfter() +// JFL 10 Aug 04; from JoeCo +void N2LinkAfter(void *head,void *node) +{ + N2 *n=node,*h=head; + n->next=h->next; + n->prev=head; + h->next=node; + ((N2*)(n->next))->prev=node; + + if(!n->type) + { + BP(BP_N2LINKAFTER); + n->type=1; + } +} // N2LinkAfter() + +// N2LinkBefore() +// JFL 10 Aug 04; from JoeCo +void N2LinkBefore(void *head,void *node) +{ + N2 *n=node,*h=head; + n->prev=h->prev; + n->next=head; + h->prev=node; + ((N2*)(n->prev))->next=node; + + if(!n->type) + { + BP(BP_N2LINKBEFORE); + n->type=1; + } +} // N2LinkBefore() + +// N2Unlink() +// JFL 10 Aug 04; from JoeCo +void N2Unlink(void *node) +{ + N2 *n=node; + + // unlink + ((N2*)n->next)->prev=n->prev; + ((N2*)n->prev)->next=n->next; + + // the following makes the node safe from multiple unlinking + n->next=n->prev=node; +} // N2Unlink() + +// JFL 12 Jan 05 +void* N2Parent(void *vn) +{ + N2 *n=vn; + while(n && n->type) + n=n->next; + if(n && !n->type) + { + n++; + if(n->next + && (((N2*)n->next)->prev==n) + && (((N2*)n->prev)->next==n)) + return n; + } + return NUL; +} // N2Parent() + +// JFL 29 Mar 05 +int n2sfMDL2(N2ScanRec *nsr,N2 *n) +{ /// scan function to move dead off their L2 list + N2 *k; + if(n->flags&M_N2_L2LINKED) + { + n->flags&=~M_N2_L2LINKED; + k=N2L2(n); + N2Unlink(k); + } // L2 linked + return N2SCANFUNC_CONTINUE; +} // n2sfMDL2() + +// JFL 12 Jan 05 +int N2MoveDead(void *vn,void *deadlist) +{ + int depth; + N2 *k,*stack[N2_DEPTH_MAX]; + N2 *onext; + N2 *n=vn; + int moved=0; + N2ScanRec nsr; + + stack[0]=n; + depth=1; + while(depth-->0) + { + for(n=stack[depth];n->type;n=onext) + { + onext=n->next; + + if(n->flags&M_N2_DEAD) + { + moved++; + N2Unlink(n); + N2LinkBefore(deadlist,n); + + nsr.func3=(void*)n2sfMDL2; + N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_FUNC,n); + } + else if((depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) + && k->type) + { + stack[depth++]=onext; // push next in cur list + onext=k; // switch current to first kid + } + } // for + } // while + + return moved; +} // N2MoveDead() + +// JFL 11 Nov 04 +int N2Count(void *vn) +{ + N2 *k,*stack[N2_DEPTH_MAX]; + int depth,count; + N2 *n=vn; + + count=0; + stack[0]=n; + depth=1; + + while(depth-->0) + { + for(n=stack[depth];n->type;n=n->next) + { + count++; + if(depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) && k->type) + { + stack[depth++]=n->next; // push next in cur list + n=k->prev; // switch current to first kid + } + } // for + } // while + + return count; +} // N2Count() + +// JFL 18 Feb 05 +int N2LevelSet(N2 *n,int lev) +{ + int oldlev; + + oldlev=n->flags&M_N2_LEVEL; + oldlev>>=S_N2_LEVEL; + + lev = (M_N2_LEVEL & (lev<>S_N2_LEVEL; // complex clamp + n->flags&=~M_N2_LEVEL; + n->flags|=lev<flags&M_N2_LEVEL; + oldlev>>=S_N2_LEVEL; + + return oldlev; +} // N2LevelGet() + +// JFL 24 Feb 05 +int N2LevelCpy(N2 *dst,N2 *src) +{ + int oldlev,newlev; + + newlev=src->flags&M_N2_LEVEL; + + oldlev=dst->flags&M_N2_LEVEL; + dst->flags&=~M_N2_LEVEL; + dst->flags|=newlev; + oldlev>>=S_N2_LEVEL; + + return oldlev; +} // N2LevelCpy() + +// JFL 29 Mar 05 +char *N2Name(N2 *n,char **s2p) +{ + char *s1=NUL,*s2; + Res *r; + + switch(n->type) + { + case N2TYPE_OBJ: + switch(n->sub) + { + case OBJSUB_DISPRES: + if(!(r=((ObjDispRes*)n)->res)) + break; + s1=r->name; + break; + case OBJSUB_ANIRES: + s1=((ObjAniRes*)n)->name; + break; + case OBJSUB_SEQRES: + s1=((ObjSeqRes*)n)->name; + break; + case OBJSUB_CAM: + s1=((ObjCam*)n)->name; + break; + case OBJSUB_LIGHTRES: + if(!(r=((ObjLightRes*)n)->res)) + break; + s1=r->name; + break; + case OBJSUB_SKELRES: + if(!(r=((ObjSkelRes*)n)->res)) + break; + s1=r->name; + break; + case OBJSUB_TEXT: + s1=((ObjText*)n)->name; + break; + case OBJSUB_FUNC: + s1=((ObjFunc*)n)->name; + break; + case OBJSUB_VEL: + s1=((ObjVel*)n)->name; + break; + case OBJSUB_EMIT: + s1=((ObjEmit*)n)->name; + break; + case OBJSUB_NONE: + case OBJSUB_STARTSORTBUF: + case OBJSUB_DRAWSORTBUF: + case OBJSUB_FRAMESTART: + case OBJSUB_FORCEFRAMEEND: + case OBJSUB_COLACT: + case OBJSUB_COLRES: + break; // no name + case OBJSUB_BUF: + s1=((ObjBuf*)n)->name; + break; + case OBJSUB_IMGRES: + if(!(r=((ObjImgRes*)n)->res)) + break; + s1=r->name; + break; + case OBJSUB_COLDEF: + s1=((ObjColDef*)n)->name; + break; + case OBJSUB_MARKER: + s1=((ObjMarker*)n)->name; + break; + case OBJSUB_GROUP: + s1=((ObjGroup*)n)->name; + break; + case OBJSUB_PARTICLES: + s1=((ObjParticles*)n)->name; + break; + default: + BP(BP_N2NAME); + break; // not handled + } // switch + break; // N2TYPE_OBJ + case N2TYPE_RES: + s1=((Res*)n)->name; + break; // N2TYPE_RES + default: + break; // not handled + } // switch + + if(s1 && s2p) + { + s2=s1; + while(*s2) + s2++; + *s2p=s2; + } + + return s1; +} // N2Name() + +// JFL 21 Feb 05 +void* N2Scan(N2ScanRec *n2sr,uns find,void *node) +{ + N2 *n=node,*k; + char *s1; + + if(find&M_N2SCAN_PRIME) + { + // this is an easy case, just find the prime obj + for(;n->type;n=n->next) + ; // scan forward + return n+1; + } // search for prime + + // + // init + // + + if(find&M_N2SCAN_INIT) + { + if(find&M_N2SCAN_KIDSONLY) + { + // if we are scanning only the children nodes, + // start at the first child node + if(0 + || !(n->flags&M_N2_KIDLIST) + || !(k=(N2KIDLIST(n)->next)) + || !k->type + ) + goto BAIL; + n=k; // kid + } // kids only + + n2sr->stack[0]=n; + n2sr->stacki=1; + + if(find&M_N2SCAN_WRAP) + n2sr->wrapper=n; + else + n2sr->wrapper=NUL; + } // init + else + goto cont; + + if(find&M_N2SCAN_DONTSCAN) + goto BAIL; + + // + // scan loop + // + + while(n2sr->stacki-->0) + { + for(n=n2sr->stack[n2sr->stacki];n;n=n->next) + { +loop: + if(n==n2sr->wrapper) + { + if(find&M_N2SCAN_INIT) + find&=~M_N2SCAN_INIT; + else + break; + } + + if(!n->type) + { + // hit end of list + // if wrap-around & this is at the top level, skip + if(n2sr->wrapper && !n2sr->stacki) + goto nomatch; + else + break; + } + + // + // handle a node + // + + // sub + if(find&M_N2SCAN_SUB) + { + if(n->sub!=(find&M_N2SCAN_VAL)) + goto nomatch; + } + + // name + if(find&M_N2SCAN_NAME) + { + s1=N2Name(n,NUL); + if(sz2cmpx(n2sr->s1,n2sr->s2,s1,NUL)) + goto nomatch; + } // name + + // function + if((find&M_N2SCAN_FUNC)&&(n2sr->func3)) + { + // functions that return 0 match, else dont match + if((*n2sr->func3)(n2sr,n)!=N2SCANFUNC_MATCH_AND_RETURN) + goto nomatch; + } + + // match + return n; + +nomatch: +cont: + if(1 + && !(find&M_N2SCAN_NODEEPER) + && (n2sr->stackistack)) + && (n->flags&M_N2_KIDLIST) + && (k=(N2KIDLIST(n)->next)) + && k->type) + { + n2sr->stack[n2sr->stacki++]=(void*)n->next; // push next in cur list + n=k; + goto loop; + } + } // for + } // while +BAIL: + return NUL; +} // N2Scan() + +// EOF diff --git a/dond/core/sys.h b/dond/core/sys.h new file mode 100755 index 0000000..1347ee9 --- /dev/null +++ b/dond/core/sys.h @@ -0,0 +1,363 @@ +#ifndef SYS_H +#define SYS_H +// sys.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// GNP 05 May 00 +// JFL 26 Aug 04 +// JFL 20 Jul 05; simple protection + +#define SYS_HARDWARESN1 0x100901CF // twins - sent to RAW THRILLS +#define SYS_HARDWARESN2 0x7CAF9417 // bears -- Test Cabinet +#define SYS_HARDWARESN3 0x58AAA47F // sox -- RawThrills Cabinet +#define SYS_HARDWARESN4 0x246C9FA4 // JAMMA 1 -- JAPAN +#define SYS_HARDWARESN5 0xA44E612F // JAMMA 2 -- JAPAN +#define SYS_HARDWARESN6 0xC458C6BD // AMOA 1 -- VEGAS BABY +#define SYS_HARDWARESN7 0x78D5224D // AMOA 2 -- VEGAS BABY +#define SYS_HARDWARESN8 0x9086987A // AMOA 3 -- VEGAS BABY +#define SYS_HARDWARESN9 0xE88AD32F // AMOA 4 -- VEGAS BABY +#define SYS_HARDWARESN10 0x303C3C68 // AMOA 5 -- VEGAS BABY --THESE 5 DOWN FOR AMOA +#define SYS_HARDWARESN11 0x80DEA837 // AMOA 6 -- VEGAS BABY +#define SYS_HARDWARESN12 0xF8575B4B // AMOA 7 -- VEGAS BABY +#define SYS_HARDWARESN13 0x708A365E // AMOA 8 -- VEGAS BABY +#define SYS_HARDWARESN14 0x748349A1 // AMOA 9 -- VEGAS BABY +#define SYS_HARDWARESN15 0xFC547341 // PM TEST +#define SYS_HARDWARESN16 0xF476FC22 // PM TEST 2 + +#define SYS_JAMMAXOR 0xAAAAAAAA // jamma sn is just xor'd + +#define SYS_HARDSN(x) (((x)==SYS_HARDWARESN1) \ + ||(((x)==SYS_HARDWARESN2)) \ + ||(((x)==SYS_HARDWARESN3)) \ + ||(((x)==SYS_HARDWARESN4)) \ + ||(((x)==SYS_HARDWARESN5)) \ + ||(((x)==SYS_HARDWARESN6)) \ + ||(((x)==SYS_HARDWARESN7)) \ + ||(((x)==SYS_HARDWARESN8)) \ + ||(((x)==SYS_HARDWARESN9)) \ + ||(((x)==SYS_HARDWARESN10)) \ + ||(((x)==SYS_HARDWARESN11)) \ + ||(((x)==SYS_HARDWARESN12)) \ + ||(((x)==SYS_HARDWARESN13)) \ + ||(((x)==SYS_HARDWARESN14)) \ + ||(((x)==SYS_HARDWARESN15)) \ + ||(((x)==SYS_HARDWARESN16))) + +#define SYS_JAMMASN(x) (((x)==(SYS_JAMMAXOR^SYS_HARDWARESN1)) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN2))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN3))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN4))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN5))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN6))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN7))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN8))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN9))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN10))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN11))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN12))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN13))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN14))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN15))) \ + ||(((x)==(SYS_JAMMAXOR^SYS_HARDWARESN16)))) + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM SPECIFIC + +//----------------------------------------------------------------------------- +// SYS_JP5500 +#if SYS_JP5500 + +// +// GENERAL +// + +#define iprintf +#define sprintf + +// +// SYSTEM-SPECIFIC +// + +extern int xSysInit(void); +extern void xSysFinal(void); +extern int xSysReset(uns reset); + +extern uns32 xSysHdwRev(void); +extern uns32 xSysGfxRev(void); +extern void xSysMilliSec(uns n); +extern uns64 xSysMicroSec(void); +extern void xSysNanoSec(uns n); +extern void xSysWatchdogDisable(void); +extern uns xSysIsDebuggerRunning(void); +extern void xSerPort1_init(char baud); +extern int xSerPort1_status(void); +extern char xSerPort1_in(void); +extern void xSerPort1_out(char c); +extern void xSerPort2_init(char baud); +extern int xSerPort2_status(void); +extern char xSerPort2_in(void); +extern void xSerPort2_out(char c); +extern void xSysRTClockStart(void); +extern void xSysRTClockStop(void); +extern uns32 xSysRTClockSec(void); +extern void xSysSetExcVector(void* vec); + +extern int xSysSR(void); +extern void xSysSRSet(int x); +extern int xSysCause(void); +extern uns xSysCPUTimer(void); + +extern int xSysWait(int *sem); +extern void xSysSignal(int *sem); +extern int xSysSRAndOr(int and,int or); +extern int xSysIntDisable(void); +extern int xSysIntEnable(void); + +extern int xSysLock(volatile int *lock,int value); + +extern void xSysCacheHWBInvalidate(void *adrlo,void *adrhi); + +#define REGSAVE_NUM 40 +extern void reg_save(uns64 regs[REGSAVE_NUM]); +extern void reg_restore(uns64 regs[REGSAVE_NUM]); + +#endif // SYS_JP5500 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// SYS_PC|SYS_BB +#if SYS_PC|SYS_BB + +extern int xSysInit(void); +extern void xSysFinal(void); +extern int xSysReset(uns reset); +extern uns64 xSysMicroSec(void); + +#endif // SYS_PC|SYS_BB +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +#if PRODUCTION +#define M_SYSG_PROFLAGS_JAMMALIVES1 0x01 +#define M_SYSG_PROFLAGS_JAMMALIVES2 0x02 +#define M_SYSG_PROFLAGS_DONTFLIP 0x04 +#define M_SYSG_PROFLAGS_CFFILEERROR 0x08 +#endif // PRODUCTION + +#define SYSG_VERSTR_SIZE 64 + +typedef struct { + uns mode; + uns8 restart; + uns8 proflags; // PRODUCTION + uns8 profailrgb[3]; // PRODUCTION + int projammasn; // PRODUCTION + uns8 cfg[32]; + uns8 flags[32]; + uns8 info[128]; + char str[8][16]; // 8 16 character strings + uns16 n2FlagsOr; + uns8 quit; + int gunCalValidated; + int level; + int tag; + char *scriptStartS1; + char *scriptStartS2; + char log[1024]; + uns forceFrameTime; + uns loop; + uns64 loopTime; + memu var[32]; + char path[1024]; // for all data + char adjpath[256]; // for adjustments + char audpath[256]; // for audits + char cfpath[256]; // for parsed sequences + char plrpath[256]; // for player info + char trnpath[256]; // for tournament info + char lbdpath[256]; // for tournament info + char sndpath[256]; // for sound path + char logpath[256]; // for log path + char keymacros[8][16]; // 8 16 character strings + char *curSeq; + char *curProc; + char versionstr[SYSG_VERSTR_SIZE]; +} SysGlobals; + +typedef struct { + int sec; // 0..61(?) + int min; // 0..59 + int hour; // 0..23 + int mday; // 1..31 + int mon; // 0..11 + int year; // eg 2005 + int wday; // 0..6 Sunday==0 + int yday; // since jan 1 0..365 + int isdst; // is daylight savings time +} SysDate; + +enum uTimers { + UTIMER_FRAME, + UTIMER_SYS, + UTIMER_NET, + UTIMER_CAB, + UTIMER_WND, + UTIMER_WNDINP, + UTIMER_INP, + UTIMER_PROC, + UTIMER_OBJ, + UTIMER_DRAWINIT, + UTIMER_DRAWDISP1, + UTIMER_DRAWDISP2, + UTIMER_DRAWDISP2MATRIX, + UTIMER_DRAWDISP2CULL, + UTIMER_DRAWDISP2SORT, + UTIMER_DRAWDISP2SETUP1, + UTIMER_DRAWDISP2SETUP2, + UTIMER_DRAWDISP2COL, + UTIMER_DRAWDISP3, + UTIMER_DRAWDISP3MATRIX, + UTIMER_DRAWDISP3WEIGHT, + UTIMER_DRAWDISP3SETUP1, + UTIMER_DRAWDISP3SETUP2, + UTIMER_DRAWDISP3COL, + UTIMER_DRAWEMITPARTICLES, + UTIMER_DRAWFLIP, + UTIMER_DRAWSORT, + UTIMER_DRAWSHAD, + UTIMER_DRAWCAM, + UTIMER_DRAWTEXT, + UTIMER_OBJFUNC, + UTIMER_OBJANI, + UTIMER_OBJSEQ, + UTIMER_OBJVEL, + UTIMER_OBJCOL, + UTIMER_OBJRESOLVE, + UTIMER_GLUT, + NUM_UTIMERS +}; + +// +// SysTimer +// use for any type of system timer used in debugging +// +typedef struct _systimer { + uns64 timer; // the actual timer + uns64 timeacc; // time accumulator for starts and stops + char name[64]; // timer name + uns8 count; // number of timing measurements we have taken +} SysTimer; + +extern void N1LinkTail(void *headp,void *node); +extern void N1LinkHead(void *headp,void *node); +extern int N1Unlink(void *headp,void *node); + +extern void N2Head(void *head); +extern void N2DontLink(void *node); +extern void N2LinkAfter(void *head,void *node); +extern void N2LinkBefore(void *head,void *node); +extern void N2Unlink(void *node); +extern int N2Count(void *node); +extern void* N2Parent(void *node); +extern int N2MoveDead(void *n,void *deadlist); +extern char *N2Name(N2 *n,char **s2p); + +enum { + // return codes for the scan func + N2SCANFUNC_MATCH_AND_RETURN, + N2SCANFUNC_CONTINUE +}; + +typedef struct { + N2 *stack[8]; + int stacki; + N2 *wrapper; + ftype3 *func3; // int func(N2ScanRec *nsr,N2 *n) return N2SCANFUNC_ + memu fdata; // function data + char *s1; // match string s1 + char *s2; // match string s2 +} N2ScanRec; + +#define M_N2SCAN_VAL 0x0000ffff // used to pass values in +#define M_N2SCAN_SUB 0x00010000 // look for subtype +#define M_N2SCAN_FUNC 0x00020000 // function call +#define M_N2SCAN_NAME 0x00040000 // match the name +#define M_N2SCAN_PRIME 0x00100000 // find prime obj +#define M_N2SCAN_INIT 0x00200000 // this is the first call w/n2sr -- init +#define M_N2SCAN_DONTSCAN 0x00400000 // first and don't search (init only) +#define M_N2SCAN_NODEEPER 0x00800000 // dont scan deeper +#define M_N2SCAN_NOKIDS M_N2SCAN_NODEEPER // -- depricated +#define M_N2SCAN_WRAP 0x01000000 // wrap until start instead of till list end +#define M_N2SCAN_KIDSONLY 0x02000000 // kids only +extern void* N2Scan(N2ScanRec *n2sr,uns find,void *node); + +extern int N2LevelSet(N2 *n,int lev); +extern int N2LevelGet(N2 *n); +extern int N2LevelCpy(N2 *dst,N2 *src); + +extern int SysInit(void); +extern void SysFinal(void); +extern int SysReset(uns reset); +extern int SysLoop(void); + +extern int SysLevelSet(int lev); +extern int SysLevelGet(void); + +#define SysMilliSec xSysMilliSec +#define SysMicroSec xSysMicroSec +#define SysNanoSec xSysNanoSec + +extern void SysWatchdogEnable(void); +extern void SysWatchdogDisable(void); +extern void SysWatchdogBone(void); + +extern uns64 SysClockMilliSec(void); +extern void SysMicroTimerStart(uns32 timerNum); +extern void SysMicroTimerStop(uns32 timerNum); +extern void SysMicroTimerClear(uns32 timerNum); +extern void SysMicroTimerClearAll(void); +extern SysGlobals SysG; +extern SysTimer SysuTimers[]; + +extern SysLog(char *fmt,...); +extern int SysLogCheck(void); + +#define MAIN_RESTART_ARGC_MAX 32 +extern int MainRestartArgc; +extern char *MainRestartArgv[MAIN_RESTART_ARGC_MAX]; + +#define M_SYSTIMEDATE_GMT 0x0001 +extern int SysDateTime(SysDate *dt,uns flags); +extern int SysDateTimeStr(SysDate *dt,char *buf,int bufsize,char *fmt); +extern uns32 SysDateTimeInSeconds(void); + +#define SHIFT_NUM 5 +#define SHIFT_BITS 28 + +extern uns32 sysEnc1(uns32 *dstp,uns32 a); +extern uns32 sysChk1(uns32 opseed, uns32 actcode); +extern uns32 sysDecode1(uns32 u,uns32 a); + +enum { + SYSBUILDINFO_NONE, + SYSBUILDINFO_HARDWARESTRING, + SYSBUILDINFO_SOFTWARESTRING, + SYSBUILDINFO_HARDWARESN, + SYSBUILDINFO_HARDWARECP, + SYSBUILDINFO_GAMESN, +}; +#define M_SYSBUILDINFO 0xff + +extern int SysBuildInfo(uns op,char *buf,int bufsize,uns *idp); + +enum { + SYSGETHARDWAREINFO_NONE, + SYSGETHARDWAREINFO_SN, +}; + +extern int SysGetHardwareInfo(uns op,char *buf,int bufsize); +extern void SysLoadVersionInfo(void); +extern void SysRestart(void); + +#endif // ndef SYS_H diff --git a/dond/core/test.c b/dond/core/test.c new file mode 100755 index 0000000..ea78af9 --- /dev/null +++ b/dond/core/test.c @@ -0,0 +1,28 @@ +#include +#include + +main() +{ + int i; + int n=1024*64; + char *p; + FILE *fh; + + if(!(p=malloc(n))) + goto BAIL; + + for(i=0;i +#include +#include "theorafunc.h" + +//#include + +int theorafunc_bytesAlloced = 0; + +// ------------------------------------------------------------------- + +int mGetMin(int a, int b) +{ + return a>b ? b : a; +} + +int mGetMax(int a, int b) +{ + return a>b ? a : b; +} + +int mClamp(int val, int low, int high) +{ + return mGetMax(mGetMin(val, high), low); +} + +// ------------------------------------------------------------------- +// theorafunc_findImageGlTex +// +// - given a name, find the matching image resource and return the +// value of its gl texture id. + +int theorafunc_findImageGlTex(char *name) +{ + N2ScanRec nsr; + Res *searchObj, *nextObj; + + ResDataImg1 *resImg; + + nsr.s1 = name; + nsr.s2 = NUL; + + searchObj = NULL; + searchObj = N2Scan(&nsr, M_N2SCAN_INIT | M_N2SCAN_SUB | M_N2SCAN_NAME | RESSUB_IMG1, ResLoadedFirst()); + + while (searchObj) + { + resImg = (ResDataImg1*)(searchObj->data); + //resImg->flags ^= M_RESDATAIMG1_MIPMAP; + + return resImg->texGen; + + nextObj = N2Scan(&nsr, M_N2SCAN_NAME + | M_N2SCAN_SUB | RESSUB_IMG1, searchObj); + + searchObj = nextObj; + } + + return -1; +} + +// ------------------------------------------------------------------- +// theorafunc_getFrame + +int theorafunc_getFrame(char *name) +{ + N2ScanRec nsr; + Res *testRes, *nextRes; + ResDataVid *vid; + theorafunc_data_t *td; + char chText[128]; + + nsr.s1 = name; + nsr.s2 = NUL; + + testRes = NUL; + testRes = N2Scan(&nsr, M_N2SCAN_INIT | M_N2SCAN_SUB + | M_N2SCAN_NAME | RESSUB_VID, ResLoadedFirst()); + + while (testRes) + { + vid = (ResDataVid*)testRes->data; + + if (vid->theora) + { + td = (theorafunc_data_t*)vid->theora; + if (td->isPlaying) + return theora_granule_frame(&td->theoraState, td->theoraState.granulepos); + } + + nextRes = N2Scan(&nsr, M_N2SCAN_SUB | M_N2SCAN_NAME | RESSUB_VID, testRes); + testRes = nextRes; + } + + return -1; +} + +// ------------------------------------------------------------------- +// theorafunc_loadVideo + +void theorafunc_loadVideo(char *name) +{ + N2ScanRec nsrObj, nsrRes; + Obj *searchObj, *nextObj, *foundObj; + Res *searchRes, *nextRes, *r; + ResDataVid *vid; + ResDataImg1 *resImg; + char imgName[64]; + + int texGen; + theorafunc_data_t *td; + + nsrObj.s1 = name; + nsrObj.s2 = NUL; + + foundObj = NUL; + searchObj = NUL; + searchObj = N2Scan(&nsrObj, M_N2SCAN_INIT | M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, ObjActiveFirst()); + + while (searchObj) + { + r = ((ObjDispRes*)searchObj)->res; + if (strcmp(r->name, name) == 0) + foundObj = searchObj; + + nextObj = N2Scan(&nsrObj, M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, searchObj); + searchObj = nextObj; + } + + // - if we didn't find a matching object name, do nothing + + if (!foundObj) + return NULL; + + r = ((ObjDispRes*)foundObj)->res; + if (r->lnk.sub != RESSUB_DISP2) + return NULL; + + // - save the texture id of the object we found. + + texGen = ((ResDataDisp2*)r->data)->texGen; + + sprintf(imgName, ""); + + nsrRes.s1 = "*"; + nsrRes.s2 = NUL; + + searchRes = NULL; + searchRes = N2Scan(&nsrRes, M_N2SCAN_INIT | M_N2SCAN_SUB | M_N2SCAN_NAME | RESSUB_IMG1, ResLoadedFirst()); + + while (searchRes) + { + resImg = (ResDataImg1*)(searchRes->data); + + if (resImg->texGen == texGen) + sprintf(imgName, "%s", searchRes->name); + + nextRes = N2Scan(&nsrRes, M_N2SCAN_NAME + | M_N2SCAN_SUB | RESSUB_IMG1, searchRes); + + searchRes = nextRes; + } + + // - now, look for the video resource with the correct name + + nsrRes.s1 = imgName; + nsrRes.s2 = NUL; + + searchRes = NUL; + searchRes = N2Scan(&nsrRes, M_N2SCAN_INIT | M_N2SCAN_SUB + | M_N2SCAN_NAME | RESSUB_VID, ResLoadedFirst()); + + if (searchRes) + { + vid = (ResDataVid*)searchRes->data; + + if (!vid->theora) + { + theorafunc_buildTables(); + vid->theora = theorafunc_allocate(); + + theorafunc_init(vid->theora, vid->data, vid->fileSize, theorafunc_findImageGlTex(searchRes->name)); + td = (theorafunc_data_t*)vid->theora; + + td->vidStartTicks = -1; // <- grab the start time once you start playing! + td->isPlaying = -1; // <- signifies to play the first frame, then stop + + // - turn off mip mapping for any and all display objects that + // will use the same texture page. we cannot be expected to + // generate mip maps in real time. + + disableMipMapping(searchRes->name); + } + } +} + +// ------------------------------------------------------------------- +// theorafunc_unloadVideo + +void theorafunc_unloadVideo(char *name) +{ + N2ScanRec nsrObj, nsrRes; + Obj *searchObj, *nextObj, *foundObj; + Res *searchRes, *nextRes, *r; + ResDataVid *vid; + ResDataImg1 *resImg; + char imgName[64]; + + int texGen; + theorafunc_data_t *td; + + nsrObj.s1 = name; + nsrObj.s2 = NUL; + + foundObj = NUL; + searchObj = NUL; + searchObj = N2Scan(&nsrObj, M_N2SCAN_INIT | M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, ObjActiveFirst()); + + while (searchObj) + { + r = ((ObjDispRes*)searchObj)->res; + if (strcmp(r->name, name) == 0) + foundObj = searchObj; + + nextObj = N2Scan(&nsrObj, M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, searchObj); + searchObj = nextObj; + } + + // - if we didn't find a matching object name, do nothing + + if (!foundObj) + return NULL; + + r = ((ObjDispRes*)foundObj)->res; + if (r->lnk.sub != RESSUB_DISP2) + return NULL; + + // - save the texture id of the object we found. + + texGen = ((ResDataDisp2*)r->data)->texGen; + + sprintf(imgName, ""); + + nsrRes.s1 = "*"; + nsrRes.s2 = NUL; + + searchRes = NULL; + searchRes = N2Scan(&nsrRes, M_N2SCAN_INIT | M_N2SCAN_SUB | M_N2SCAN_NAME | RESSUB_IMG1, ResLoadedFirst()); + + while (searchRes) + { + resImg = (ResDataImg1*)(searchRes->data); + + if (resImg->texGen == texGen) + sprintf(imgName, "%s", searchRes->name); + + nextRes = N2Scan(&nsrRes, M_N2SCAN_NAME + | M_N2SCAN_SUB | RESSUB_IMG1, searchRes); + + searchRes = nextRes; + } + + // - now, look for the video resource with the correct name + + nsrRes.s1 = imgName; + nsrRes.s2 = NUL; + + searchRes = NUL; + searchRes = N2Scan(&nsrRes, M_N2SCAN_INIT | M_N2SCAN_SUB + | M_N2SCAN_NAME | RESSUB_VID, ResLoadedFirst()); + + if (searchRes) + { + vid = (ResDataVid*)searchRes->data; + + if (vid->theora) + theorafunc_unload(vid->theora); + } +} + +// ------------------------------------------------------------------- +// theorafunc_animateG3 +// +// - searches through the resource list for any videos and: +// 1. allocates & loads up videos that haven't been loaded +// 2. animates loaded videos + +void theorafunc_animateG3(void) +{ + N2ScanRec nsr; + Res *testRes, *nextRes; + ResDataVid *vid; + theorafunc_data_t *td; + char chText[128]; + + nsr.s1 = "*"; + nsr.s2 = NUL; + + testRes = NUL; + testRes = N2Scan(&nsr, M_N2SCAN_INIT | M_N2SCAN_SUB + | M_N2SCAN_NAME | RESSUB_VID, ResLoadedFirst()); + + while (testRes) + { + vid = (ResDataVid*)testRes->data; + + if (!vid->theora) + { + /* + theorafunc_buildTables(); + vid->theora = theorafunc_allocate(); + + theorafunc_init(vid->theora, vid->data, vid->fileSize, theorafunc_findImageGlTex(testRes->name)); + td = (theorafunc_data_t*)vid->theora; + + td->vidStartTicks = -1; // <- grab the start time once you start playing! + td->isPlaying = -1; // <- signifies to play the first frame, then stop + + // - turn off mip mapping for any and all display objects that + // will use the same texture page. we cannot be expected to + // generate mip maps in real time. + + disableMipMapping(testRes->name); + */ + } + else + { + td = (theorafunc_data_t*)vid->theora; + + if ((td->isPlaying > 0) || (td->isPlaying == -1)) + { + if ((td->vidStartTicks < 0) && (td->isPlaying > 0)) + td->vidStartTicks = theorafunc_getTime(); + + switch (theorafunc_readyVideo(td)) + { + case 0: // - the video has reached the end + + theorafunc_restart(td); + + if (strlen(td->linkedObject)) + { + sprintf(chText, "ani(- %s)", td->linkedObject); + ResScript(chText); + } + else if (td->onDoneCallback) { + (*(td->onDoneCallback))(); + } + + break; + + case 1: // - we found a good frame + + theorafunc_videoWrite(td); + if (td->isPlaying == -1) + td->isPlaying = 0; + break; + + case 2: // - we have a frame, but it's too early to play + break; + } + + dond_lptSwitchCheck(0); + } + } + + nextRes = N2Scan(&nsr, M_N2SCAN_SUB | M_N2SCAN_NAME | RESSUB_VID, testRes); + testRes = nextRes; + } +} + +// ------------------------------------------------------------------- +// getVideoFromObject + +theorafunc_data_t *getVideoFromObject(char *name) +{ + N2ScanRec nsrObj, nsrRes; + Obj *searchObj, *nextObj, *foundObj; + Res *searchRes, *nextRes, *r; + ResDataVid *vid; + + int texGen; + theorafunc_data_t *td; + + nsrObj.s1 = name; + nsrObj.s2 = NUL; + + foundObj = NUL; + searchObj = NUL; + searchObj = N2Scan(&nsrObj, M_N2SCAN_INIT | M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, ObjActiveFirst()); + + while (searchObj) + { + r = ((ObjDispRes*)searchObj)->res; + if (strcmp(r->name, name) == 0) + foundObj = searchObj; + + nextObj = N2Scan(&nsrObj, M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, searchObj); + searchObj = nextObj; + } + + // - if we didn't find a matching object name, do nothing + + if (!foundObj) + return NULL; + + r = ((ObjDispRes*)foundObj)->res; + if (r->lnk.sub != RESSUB_DISP2) + return NULL; + + // - save the texture id of the object we found. + + texGen = ((ResDataDisp2*)r->data)->texGen; + + // - search for a video resource with the same texture id + + nsrRes.s1 = "*"; + nsrRes.s2 = NUL; + + searchRes = NUL; + searchRes = N2Scan(&nsrRes, M_N2SCAN_INIT | M_N2SCAN_SUB + | M_N2SCAN_NAME | RESSUB_VID, ResLoadedFirst()); + + while (searchRes) + { + vid = searchRes->data; + + if (vid->theora) { + td = vid->theora; + if (texGen == (int)td->glTex) + return td; + } + + nextRes = N2Scan(&nsrRes, M_N2SCAN_SUB | M_N2SCAN_NAME | RESSUB_VID, searchRes); + searchRes = nextRes; + } + + return NULL; +} + +// ------------------------------------------------------------------- +// disableMipMapping +// +// - turns of mip mapping for any objects that are using the image +// resource with the given name. +// +// also returns the number of objects using the image resource. + +int disableMipMapping(char *name) +{ + N2ScanRec nsr, nsr2; + Res *searchObj, *nextObj; + Obj *searchObj2, *nextObj2; + + Res *r, *r2; + ResDataImg1 *resImg; + ResDataDisp2 *d2; + + int numObjects = 0; + + nsr.s1 = name; + nsr.s2 = NUL; + + searchObj = NULL; + searchObj = N2Scan(&nsr, M_N2SCAN_INIT | M_N2SCAN_SUB + | M_N2SCAN_NAME | RESSUB_IMG1, ResLoadedFirst()); + + while (searchObj) + { + resImg = (ResDataImg1*)(searchObj->data); + + // - for this image resource, search for any dispres objects + // with a matching texture page. + + nsr2.s1 = "*"; + nsr2.s2 = NUL; + + searchObj2 = NULL; + searchObj2 = N2Scan(&nsr2, M_N2SCAN_INIT | M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, ObjActiveFirst()); + + while (searchObj2) + { + if (searchObj2->lnk.sub & OBJSUB_DISPRES) + { + r2 = ((ObjDispRes*)searchObj2)->res; + d2 = (ResDataDisp2*)(r2->data); + + // - if this dispres object uses the same texture page, we + // will turn off mip mapping + + if (d2->texGen == resImg->texGen) + if (d2->mode & M_RESDISPMODE_MIPMAP) + d2->mode ^= M_RESDISPMODE_MIPMAP; + + if (d2->texGen == resImg->texGen) + numObjects++; + } + + nextObj2 = N2Scan(&nsr2, M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, searchObj2); + + searchObj2 = nextObj2; + } + + nextObj = N2Scan(&nsr, M_N2SCAN_NAME + | M_N2SCAN_SUB | RESSUB_IMG1, searchObj); + + searchObj = nextObj; + } + + return numObjects; +} + +// ------------------------------------------------------------------- +// theorafunc_buildTables +// +// - creates the lookup tables used to speed up the YUV->RGB +// color conversion. + +void theorafunc_buildTables(void) +{ + int i; + + for (i = 0; i < 256; i++) + { + sAdjCrr[i] = (409 * (i - 128) + 128) >> 8; + sAdjCrg[i] = (208 * (i - 128) + 128) >> 8; + sAdjCbg[i] = (100 * (i - 128) + 128) >> 8; + sAdjCbb[i] = (516 * (i - 128) + 128) >> 8; + sAdjY[i] = (298 * (i - 16)) >> 8; + } + + for (i = -384; i < 640; i++) + { + sClamp[i] = mClamp(i, 0, 0xFF); + } +} + +// ------------------------------------------------------------------- +// theorafunc_allocate + +theorafunc_data_t *theorafunc_allocate(void) +{ + theorafunc_data_t *td; + + td = (theorafunc_data_t *)malloc(sizeof(theorafunc_data_t)); + theorafunc_bytesAlloced += sizeof(td); + + if (td == NULL) + { + printf("could not allocate data\n"); + exit(1); + } + + td->theora_p = 0; + td->vidStartTicks = 0; + td->x = td->y = td->w = td->h = 0; + td->glTex = 0; + + td->alpha = 0; + + td->data = NULL; + td->dataPos = 0; + td->dataSize = 0; + + td->pixelBuff = NULL; + + td->lastFrame = -2; + + // - the movie is turned off by default, and allowed to loop + + td->isPlaying = 0; + + // - by default, this movie keep track of time. + + td->ignoreTime = 0; + + td->onDoneCallback = (void*)0; + + // - the linked object string is intended to pair video objects + // with display objects. + + sprintf(td->linkedObject, ""); + + return td; +} + +// ------------------------------------------------------------------- + +void theorafunc_vidalink(char *vidname, char *objname) +{ + N2ScanRec nsrObj; + Obj *searchObj; + theorafunc_data_t *td; + Res *searchRes, *nextRes, *r; + ResDataImg1 *resImg; + int texGen, w, h; + + // - find our source video object + + td = NULL; + td = getVideoFromObject(vidname); + + if (!td) + return; + + // - look for a disp2 object with our target name + + nsrObj.s1 = objname; + nsrObj.s2 = NUL; + + searchObj = NUL; + searchObj = N2Scan(&nsrObj, M_N2SCAN_INIT | M_N2SCAN_NOKIDS | M_N2SCAN_NAME + | M_N2SCAN_SUB | OBJSUB_DISPRES, ObjActiveFirst()); + + if (!searchObj) + return; + + r = ((ObjDispRes*)searchObj)->res; + ((ResDataDisp2*)r->data)->texGen2 = td->glTex; +} + +// ------------------------------------------------------------------- +// theorafunc_bufferData +// +// - reads in a chunk of data to the ogg buffer. returns the number +// of bytes read. + +int theorafunc_bufferData(theorafunc_data_t *td) +{ + #define BUFFER_SIZE 4096 + int bytesToRead; + + char *buffer = ogg_sync_buffer(&td->oggSyncState, BUFFER_SIZE); + + // - check to see if we can buffer the entire chunk, and + // revise the size if we are too close to the end of the data. + + bytesToRead = BUFFER_SIZE; + if ((td->dataPos + bytesToRead) >= td->dataSize) + bytesToRead = td->dataSize - td->dataPos; + + // - copy the data into our buffer and keep track of our + // positition in the data + + memcpy(buffer, td->data + td->dataPos, bytesToRead); + td->dataPos += bytesToRead; + + ogg_sync_wrote(&td->oggSyncState, bytesToRead); + + /* + if (bytesToRead == 0) + { + //printf("eod: w:%i h:%i dp:%i\n", td->w, td->h, td->dataPos); + printf("!"); + } + */ + + return(bytesToRead); +} + +// ------------------------------------------------------------------- +// theorafunc_queuePage + +static int theorafunc_queuePage(theorafunc_data_t *td) +{ + if (td->theora_p) + ogg_stream_pagein(&td->oggStreamState, &td->oggPage); + + return 0; +} + +// ------------------------------------------------------------------- +// theorafunc_init + +void theorafunc_init(theorafunc_data_t *td, unsigned char *data, int dataSize, int glTex) +{ + ogg_packet op; + int stateflag = 0; + int ret; + + td->data = data; + td->dataPos = 0; + td->dataSize = dataSize; + + // - start up Ogg stream synchronization layer + + ogg_sync_init(&td->oggSyncState); + + // - init supporting Theora structures needed in header parsing + + theora_comment_init(&td->theoraComment); + theora_info_init(&td->theoraInfo); + + // - Ogg file open; parse the headers + + /* Vorbis and Theora both depend on some initial header packets + for decoder setup and initialization. We retrieve these first + before entering the main decode loop. */ + + // - Only interested in Theora streams + + while(!stateflag) + { + ret = theorafunc_bufferData(td); + + if (!ret) + break; + + while (ogg_sync_pageout(&td->oggSyncState, &td->oggPage) > 0) + { + ogg_stream_state test; + + // - is this a mandated initial header? If not, stop parsing + + if (!ogg_page_bos(&td->oggPage)) + { + // - don't leak the page; get it into the appropriate stream + + theorafunc_queuePage(td); + + stateflag = 1; + + break; + } + + ogg_stream_init(&test, ogg_page_serialno(&td->oggPage)); + ogg_stream_pagein(&test, &td->oggPage); + ogg_stream_packetout(&test, &op); + + // - identify the codec: try theora + + if (!td->theora_p && theora_decode_header(&td->theoraInfo, &td->theoraComment, &op) >= 0) + { + // - it is theora -- save this stream state + + memcpy(&td->oggStreamState, &test, sizeof(test)); + td->theora_p = 1; + } + else + { + // - whatever it is, we don't care about it + + ogg_stream_clear(&test); + } + } + + // - fall through to non-initial page parsing + } + + // - we're expecting more header packets. + + while (td->theora_p && (td->theora_p < 3)) + { + // - look for further theora headers + + while (td->theora_p && (td->theora_p < 3) && (ret = ogg_stream_packetout(&td->oggStreamState, &op))) + { + if (ret < 0) + { + fprintf(stderr,"Error parsing Theora stream headers; corrupt stream?\n"); + exit(1); + } + + if (theora_decode_header(&td->theoraInfo, &td->theoraComment, &op)) + { + printf("Error parsing Theora stream headers; corrupt stream?\n"); + exit(1); + } + + td->theora_p++; + + if (td->theora_p == 3) + break; + } + + + // - The header pages/packets will arrive before anything else we + // care about, or the stream is not obeying spec + + if (ogg_sync_pageout(&td->oggSyncState, &td->oggPage) > 0) + { + /* demux into the stream state */ + + theorafunc_queuePage(td); + } + else + { + ret = theorafunc_bufferData(td); /* need more data */ + + if (!ret) + { + fprintf(stderr,"End of file while searching for codec headers.\n"); + exit(1); + } + } + } + + // - Now we have all the required headers. initialize the decoder. + + if (td->theora_p) + { + // - horrible, terrible DOND-specific hack: we want the wide idle animations to + // play at 15fps. instead of doing the smart thing and allowing the tga2ogg tool + // to encode variable fps, we will force-set the fps here! THIS IS STUPID! + + if ((td->theoraInfo.width == 128) && (td->theoraInfo.height == 512)) + { + td->theoraInfo.fps_numerator = 15; + td->theoraInfo.fps_denominator = 1; + } + + theora_decode_init(&td->theoraState, &td->theoraInfo); + + /* + fprintf(stderr, "Ogg logical stream %x is Theora %dx%d %.02f fps video\nEncoded frame content is %dx%d with %dx%d offset\n", + (unsigned int)td->oggStreamState.serialno, td->theoraInfo.width, td->theoraInfo.height, + (double)td->theoraInfo.fps_numerator / td->theoraInfo.fps_denominator, + td->theoraInfo.frame_width, td->theoraInfo.frame_height, td->theoraInfo.offset_x, td->theoraInfo.offset_y); + */ + + td->x = td->theoraInfo.offset_x; + td->y = td->theoraInfo.offset_y; + td->w = td->theoraInfo.width; + td->h = td->theoraInfo.height; + } + else + { + // - tear down the partial theora setup + + theora_info_clear(&td->theoraInfo); + theora_comment_clear(&td->theoraComment); + } + + // - queue any remaining pages from data we buffered but that did not + // contain headers + + while (ogg_sync_pageout(&td->oggSyncState, &td->oggPage) > 0) + { + theorafunc_queuePage(td); + } + + // - search the comments for an "alpha_stacked" tag. + + td->alpha = THEORAFUNC_NOALPHA; + + if (theora_comment_query(&td->theoraComment, "alpha_stacked", 0)) { + if (strcmp("yes", theora_comment_query(&td->theoraComment, "alpha_stacked", 0)) == 0) { + //printf("alpha stacked video\n"); + td->alpha = THEORAFUNC_ALPHA_STACKED; + } + } + + if (td->alpha == THEORAFUNC_NOALPHA) + if (theora_comment_query(&td->theoraComment, "alpha_color", 0)) { + if (strcmp("yes", theora_comment_query(&td->theoraComment, "alpha_color", 0)) == 0) { + td->alpha = THEORAFUNC_ALPHA; + } + } + + // - this fixes a debug error with theora_granule_frame + + td->theoraState.internal_encode = 0; + + //printf("theora_comment_query: %s\n", theora_comment_query(&td->theoraComment, "alpha_stacked", 0)); + + td->glTex = glTex; + theorafunc_openVideo(td); +} + +// ------------------------------------------------------------------- + +void theorafunc_openVideo(theorafunc_data_t *td) +{ + int w = td->theoraInfo.width; + int h = td->theoraInfo.height; + int bpp; + int pixelSize; + + switch (td->alpha) + { + case THEORAFUNC_NOALPHA: + bpp = 3; + pixelSize = w * h * bpp; + break; + + case THEORAFUNC_ALPHA: + bpp = 4; + pixelSize = w * h * bpp; + break; + + case THEORAFUNC_ALPHA_STACKED: + + bpp = 4; + h = h / 2; + pixelSize = w * h * bpp; + + td->w = w; + td->h = h; + + break; + } + + // - allocate our pixel buffer that we will use to store + // uncompressed video frames. + + td->pixelBuff = (unsigned char*)malloc(pixelSize); + td->pixelSize = pixelSize; + theorafunc_bytesAlloced += td->pixelSize; + + memset(td->pixelBuff, 0, pixelSize); + + glBindTexture(GL_TEXTURE_2D, td->glTex); + + if ((td->alpha == THEORAFUNC_ALPHA) || (td->alpha == THEORAFUNC_ALPHA_STACKED)) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, td->pixelBuff); + else + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, td->pixelBuff); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); +} + +// ------------------------------------------------------------------- +// theorafunc_getTime + +int64 theorafunc_getTime(void) +{ + // return SDL_GetTicks(); + return (int64)SysClockMilliSec(); + + //return clock(); +} + +// ------------------------------------------------------------------- +// theorafunc_readyVideo + +int theorafunc_readyVideo(theorafunc_data_t *td) +{ + ogg_packet op; + int gotFrame; + float frameTime, currTime; + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3MATRIX); + #endif + + gotFrame = 0; + + // - check to see if we need to load a new frame. if our current + // frame time is past our current time, we will exit out. + + if (THEORAFUNC_SYNCTIME && !td->ignoreTime) + { + frameTime = theora_granule_time(&td->theoraState, td->theoraState.granulepos); + currTime = (float)(theorafunc_getTime() - td->vidStartTicks) / 1000.0; + + if ((frameTime - currTime) >= 0) + return 2; + } + + // - otherwise, our current frame is older than the current time, so + // we need to grab another frame. + + while (!gotFrame) + { + // - extract a packet from the stream + + if (ogg_stream_packetout(&td->oggStreamState, &op) > 0) + { + // - input the packet into the encoder + // and exit out; our video is ready to + // decode. + + theora_decode_packetin(&td->theoraState, &op); + + if (THEORAFUNC_CATCHUP) // <- do we want to "catch up" to the current frame? + { + // - check to see how "old" this current frame is. + // if it is older than our current time, we need + // grab the next available frame until we get one + // that is current. + + frameTime = theora_granule_time(&td->theoraState, td->theoraState.granulepos); + currTime = (float)(theorafunc_getTime() - td->vidStartTicks) / 1000.0; + + // - if the frame is too old, we don't have a good frame yet. + + if (frameTime < currTime) + gotFrame = 0; + else + gotFrame = 1; + + gotFrame = 1; + } + else + { + // - if we aren't making any effort to catch up to the + // current frame, we will just happily grab frames + // without doing any checking, hoping that the frame + // timer code at the start of this function works. + + gotFrame = 1; + } + } + else + { + // - if we were not able to get a full + // packet from the stream, buffer some more + // data from the file. + + if ( ! theorafunc_bufferData(td) ) + return 0; + + // - take data from our sync state buffer and + // place it into an ogg page. + + while (ogg_sync_pageout(&td->oggSyncState, &td->oggPage) > 0) + { + theorafunc_queuePage(td); + } + } + + // - do not give out a duplicate frame! this can happen if the file + // pointer is reset back to the start. + + gotFrame = gotFrame; + + // - BUG! In debug mode, calling theora_granule_frame with a granulepos of 0 + // cases the game to die! (unless we set the encode_state to NULL) + + if ((td->lastFrame == theora_granule_frame(&td->theoraState, td->theoraState.granulepos)) && gotFrame) + gotFrame = 0; + } + + // - keep track of our last grabbed frame + + td->lastFrame = theora_granule_frame(&td->theoraState, td->theoraState.granulepos); + + //printf("%i, ", td->lastFrame); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3MATRIX); + #endif + + return 1; +} + +// ------------------------------------------------------------------- +// theorafunc_videoWrite + +void theorafunc_videoWrite(theorafunc_data_t *td) +{ + if (td->alpha == THEORAFUNC_ALPHA) { + theorafunc_videoWriteRGBA(td); + } else if (td->alpha == THEORAFUNC_ALPHA_STACKED) { + theorafunc_videoWriteStackedRGBA(td); + } else { + theorafunc_videoWriteRGB(td); + } +} + +// ------------------------------------------------------------------- +// theorafunc_videoWriteRGB + +void theorafunc_videoWriteRGB(theorafunc_data_t *td) +{ + yuv_buffer yuv; + int pictOffset, x, y, G; + unsigned char *pY0, *pY1, *pU, *pV; + unsigned char *dst0, *dst1; + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3WEIGHT); + #endif + + // - decode the current frame into our YUV buffer + + theora_decode_YUVout(&td->theoraState, &yuv); + + // - determine the pixel offset + + pictOffset = yuv.y_stride * td->theoraInfo.offset_y + td->theoraInfo.offset_x; + + dst0 = (unsigned char *)td->pixelBuff; + dst1 = dst0 + td->w * 3; + + for (y = 0; y < yuv.y_height; y += 2) + { + pY0 = yuv.y + pictOffset + y * (yuv.y_stride); + pY1 = yuv.y + pictOffset + (y | 1) * (yuv.y_stride); + pU = yuv.u + ((pictOffset + y * (yuv.uv_stride)) >> 1); + pV = yuv.v + ((pictOffset + y * (yuv.uv_stride)) >> 1); + + for (x = 0; x < yuv.y_width; x += 2) + { + G = sAdjCrg[*pV] + sAdjCbg[*pU]; + + // - [0,0] + + *dst0++ = sClamp[sAdjY[*pY0] + sAdjCrr[*pV]]; // R + *dst0++ = sClamp[sAdjY[*pY0] - G]; // G + *dst0++ = sClamp[sAdjY[*pY0++] + sAdjCbb[*pU]]; // B + + // - [1,0]; + + *dst0++ = sClamp[sAdjY[*pY0] + sAdjCrr[*pV]]; // R + *dst0++ = sClamp[sAdjY[*pY0] - G]; // G + *dst0++ = sClamp[sAdjY[*pY0++] + sAdjCbb[*pU]]; // B + + // - [0,1]; + + *dst1++ = sClamp[sAdjY[*pY1] + sAdjCrr[*pV]]; // R + *dst1++ = sClamp[sAdjY[*pY1] - G]; // G + *dst1++ = sClamp[sAdjY[*pY1++] + sAdjCbb[*pU]]; // B + + // - [1,1]; + + *dst1++ = sClamp[sAdjY[*pY1] + sAdjCrr[*pV++]]; // R + *dst1++ = sClamp[sAdjY[*pY1] - G]; // G + *dst1++ = sClamp[sAdjY[*pY1++] + sAdjCbb[*pU++]]; // B + } + + dst0 = dst1; + dst1 += td->w * 3; + } + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3WEIGHT); + #endif + + // - copy the surface data into our opengl texture space + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3SETUP1); + #endif + + glBindTexture(GL_TEXTURE_2D, td->glTex); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, td->w, td->h, GL_RGB, GL_UNSIGNED_BYTE, td->pixelBuff); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3SETUP1); + #endif +} + +// ------------------------------------------------------------------- +// theorafunc_videoWriteRGBA + +void theorafunc_videoWriteRGBA(theorafunc_data_t *td) +{ + yuv_buffer yuv; + int pictOffset, x, y, G; + int c[3]; + unsigned char *pY0, *pY1, *pU, *pV; + unsigned char *dst0, *dst1; + + // - decode the current frame into our YUV buffer + + theora_decode_YUVout(&td->theoraState, &yuv); + + // - determine the pixel offset + + pictOffset = yuv.y_stride * td->theoraInfo.offset_y + td->theoraInfo.offset_x; + + dst0 = (unsigned char *)td->pixelBuff; + dst1 = dst0 + td->w * 4; + + for (y = 0; y < yuv.y_height; y += 2) + { + pY0 = yuv.y + pictOffset + y * (yuv.y_stride); + pY1 = yuv.y + pictOffset + (y | 1) * (yuv.y_stride); + pU = yuv.u + ((pictOffset + y * (yuv.uv_stride)) >> 1); + pV = yuv.v + ((pictOffset + y * (yuv.uv_stride)) >> 1); + + for (x = 0; x < yuv.y_width; x += 2) + { + G = sAdjCrg[*pV] + sAdjCbg[*pU]; + + // - [0,0] + + c[0] = *dst0++ = sClamp[sAdjY[*pY0] + sAdjCrr[*pV]]; // R + c[1] = *dst0++ = sClamp[sAdjY[*pY0] - G]; // G + c[2] = *dst0++ = sClamp[sAdjY[*pY0++] + sAdjCbb[*pU]]; // B + *dst0++ = (c[0] + c[1] + c[2]) / 3; + + // - [1,0]; + + c[0] = *dst0++ = sClamp[sAdjY[*pY0] + sAdjCrr[*pV]]; // R + c[1] = *dst0++ = sClamp[sAdjY[*pY0] - G]; // G + c[2] = *dst0++ = sClamp[sAdjY[*pY0++] + sAdjCbb[*pU]]; // B + *dst0++ = (c[0] + c[1] + c[2]) / 3; + + // - [0,1]; + + c[0] = *dst1++ = sClamp[sAdjY[*pY1] + sAdjCrr[*pV]]; // R + c[1] = *dst1++ = sClamp[sAdjY[*pY1] - G]; // G + c[2] = *dst1++ = sClamp[sAdjY[*pY1++] + sAdjCbb[*pU]]; // B + *dst1++ = (c[0] + c[1] + c[2]) / 3; + + // - [1,1]; + + c[0] = *dst1++ = sClamp[sAdjY[*pY1] + sAdjCrr[*pV++]]; // R + c[1] = *dst1++ = sClamp[sAdjY[*pY1] - G]; // G + c[2] = *dst1++ = sClamp[sAdjY[*pY1++] + sAdjCbb[*pU++]]; // B + *dst1++ = (c[0] + c[1] + c[2]) / 3; + } + + dst0 = dst1; + dst1 += td->w * 4; + } + + // - copy the surface data into our opengl texture space + + glBindTexture(GL_TEXTURE_2D, td->glTex); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, td->w, td->h, GL_RGBA, GL_UNSIGNED_BYTE, td->pixelBuff); +} + +// ------------------------------------------------------------------- + +void theorafunc_videoWriteStackedRGBA(theorafunc_data_t *td) +{ + yuv_buffer yuv; + int pictOffset, x, y, G; + unsigned char *pY0, *pY1, *pU, *pV; + unsigned char *dst0, *dst1; + unsigned char *pYA0, *pYA1; + + // - decode the current frame into our YUV buffer + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3WEIGHT); + #endif + + theora_decode_YUVout(&td->theoraState, &yuv); + + // - determine the pixel offset + + pictOffset = yuv.y_stride * td->theoraInfo.offset_y + td->theoraInfo.offset_x; + + dst0 = (unsigned char *)td->pixelBuff; + dst1 = dst0 + td->w * 4; + + for (y = 0; y < yuv.y_height / 2; y += 2) + { + pY0 = yuv.y + pictOffset + y * (yuv.y_stride); + pY1 = yuv.y + pictOffset + (y | 1) * (yuv.y_stride); + + pU = yuv.u + ((pictOffset + y * (yuv.uv_stride)) >> 1); + pV = yuv.v + ((pictOffset + y * (yuv.uv_stride)) >> 1); + + pYA0 = yuv.y + pictOffset + (y + (yuv.y_height >> 1)) * (yuv.y_stride); + pYA1 = yuv.y + pictOffset + ((y + (yuv.y_height >> 1)) | 1) * (yuv.y_stride); + + for (x = 0; x < yuv.y_width; x += 2) + { + G = sAdjCrg[*pV] + sAdjCbg[*pU]; + + // - [0,0] + + *dst0++ = sClamp[sAdjY[*pY0] + sAdjCrr[*pV]]; // R + *dst0++ = sClamp[sAdjY[*pY0] - G]; // G + *dst0++ = sClamp[sAdjY[*pY0++] + sAdjCbb[*pU]]; // B + *dst0++ = *pYA0++; + + // - [1,0]; + + *dst0++ = sClamp[sAdjY[*pY0] + sAdjCrr[*pV]]; // R + *dst0++ = sClamp[sAdjY[*pY0] - G]; // G + *dst0++ = sClamp[sAdjY[*pY0++] + sAdjCbb[*pU]]; // B + *dst0++ = *pYA0++; + + // - [0,1]; + + *dst1++ = sClamp[sAdjY[*pY1] + sAdjCrr[*pV]]; // R + *dst1++ = sClamp[sAdjY[*pY1] - G]; // G + *dst1++ = sClamp[sAdjY[*pY1++] + sAdjCbb[*pU]]; // B + *dst1++ = *pYA1++; + + // - [1,1]; + + *dst1++ = sClamp[sAdjY[*pY1] + sAdjCrr[*pV++]]; // R + *dst1++ = sClamp[sAdjY[*pY1] - G]; // G + *dst1++ = sClamp[sAdjY[*pY1++] + sAdjCbb[*pU++]]; // B + *dst1++ = *pYA1++; + } + + dst0 = dst1; + dst1 += td->w << 2; + } + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3WEIGHT); + #endif + + // - copy the surface data into our opengl texture space + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3SETUP1); + #endif + + glBindTexture(GL_TEXTURE_2D, td->glTex); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, td->w, td->h, GL_RGBA, GL_UNSIGNED_BYTE, td->pixelBuff); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3SETUP1); + #endif +} + +// ------------------------------------------------------------------- +// theorafunc_restart + +void theorafunc_restart(theorafunc_data_t *td) +{ + // - reset the file pointer back to the beginning + + td->dataPos = 0; + + // - keep track of the new time at which we are starting + // playback + + td->vidStartTicks = theorafunc_getTime(); + + // - this needs to be reset to zero when the video is + // restarted! not so obvious! + + td->theoraState.granulepos = 0; +} + +// ------------------------------------------------------------------- +// theorafunc_unload + +void theorafunc_unload(theorafunc_data_t *td) +{ + if (1) + { + if (td->theora_p) + ogg_stream_clear(&td->oggStreamState); + + theora_comment_clear(&td->theoraComment); + theora_info_clear(&td->theoraInfo); + + // - this function craps out in a debug build!!! WHY??? + + if (td->theora_p) + theora_clear(&td->theoraState); + + ogg_sync_clear(&td->oggSyncState); + } + + // - should we do this on g3? + // + // no. it causes certain wierd "white texture" artifacts in certain + // scenes. if it helps manage memory, these artifacts can be worked + // around. + + if (0) + { + //printf("theorafunc_unload : deleting texture %i\n", td->glTex); + // glDeleteTextures(1, &td->glTex); + + glBindTexture(GL_TEXTURE_2D, td->glTex); + + if ((td->alpha == THEORAFUNC_ALPHA) || (td->alpha == THEORAFUNC_ALPHA_STACKED)) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, td->pixelBuff); + else + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, td->pixelBuff); + } + + // - get rid of the pixel buffer + + theorafunc_bytesAlloced -= td->pixelSize; + free(td->pixelBuff); + + // - finally, get rid of our object + + theorafunc_bytesAlloced -= sizeof(td); + free(td); + td = NULL; + + //printf("theorafunc_bytesAlloced = %i\n", theorafunc_bytesAlloced); +} + +// ------------------------------------------------------------------- + +int theorafunc_getBytesAlloced(void) +{ + return theorafunc_bytesAlloced; +} + +// ------------------------------------------------------------------- +// encode_unload + +void encode_unload(theorafunc_encode_data_t *td) +{ + ogg_stream_clear(&td->to); + theora_clear(&td->td); + + free(td->yuvFrame); + free(td->screen); + free(td->bScreen); + + fclose(td->outfile); +} + +// ------------------------------------------------------------------- +// encode_init +// +// - bit_rate (45000 - 2000000) +// quality (0 - 63) + +void encode_init(theorafunc_encode_data_t *td, char *filename + , int w, int h, int bit_rate, int quality, int alphaStack) +{ + char chText[128]; + + // - clamp our settings to valid values + + if (quality < 0) quality = 0; + if (quality > 63) quality = 63; + if (bit_rate < 45000) bit_rate = 45000; + if (bit_rate > 2000000) bit_rate = 2000000; + + td->outfile = fopen(filename, "wb"); + + // - give the ogg stream a random serial number + + srand(time(NULL)); + ogg_stream_init(&td->to, rand() % 1024); + + theora_info_init(&td->ti); + + td->w = w; + td->h = h; + td->alphaStack = alphaStack; + if (td->alphaStack) + h *= 2; + + td->ti.width = w; + td->ti.height = h; + td->ti.frame_width = w; + td->ti.frame_height = h; + + td->ti.offset_x = 0; + td->ti.offset_y = 0; + + td->ti.fps_numerator = 30; + td->ti.fps_denominator = 1; + + td->ti.aspect_numerator = 2; + td->ti.aspect_denominator = 3; + + td->ti.colorspace = OC_CS_UNSPECIFIED; + td->ti.pixelformat = OC_PF_420; + td->ti.target_bitrate = bit_rate; + td->ti.quality = quality; + + td->ti.dropframes_p = 0; + td->ti.quick_p = 0; + td->ti.keyframe_auto_p = 1; + td->ti.keyframe_frequency = 64; + td->ti.keyframe_frequency_force = 64; + td->ti.keyframe_data_target_bitrate = bit_rate * 1.5; + td->ti.keyframe_auto_threshold = 80; + td->ti.keyframe_mindistance = 8; + td->ti.noise_sensitivity = 1; // 0 - 3, 0 = most sensitive? + td->ti.sharpness = 0; // 0 - 1, 0 = sharpest + + theora_encode_init(&td->td, &td->ti); + theora_info_clear(&td->ti); + + // - write the first ogg page + + theora_encode_header(&td->td, &td->op); + ogg_stream_packetin(&td->to, &td->op); + + ogg_stream_pageout(&td->to, &td->og); + + fwrite(td->og.header, 1, td->og.header_len, td->outfile); + fwrite(td->og.body, 1, td->og.body_len, td->outfile); + + // + + theora_comment_init(&td->tc); + + sprintf(chText, "width=%i\0", w); + theora_comment_add(&td->tc, chText); + + sprintf(chText, "height=%i\0", h); + theora_comment_add(&td->tc, chText); + + sprintf(chText, "bit_rate=%i\0", bit_rate); + theora_comment_add(&td->tc, chText); + + sprintf(chText, "quality=%i\0", quality); + theora_comment_add(&td->tc, chText); + + if (td->alphaStack) + theora_comment_add(&td->tc, "alpha_stacked=yes\0"); + else + theora_comment_add(&td->tc, "alpha_stacked=no\0"); + // + + theora_encode_comment(&td->tc, &td->op); + ogg_stream_packetin(&td->to, &td->op); + + theora_encode_tables(&td->td, &td->op); + ogg_stream_packetin(&td->to, &td->op); + + // - flush out the rest of the stream + + while (1) + { + int result = ogg_stream_flush(&td->to, &td->og); + + if (result < 0) + { + printf("internal ogg error\n"); + exit(1); + } + + if (result == 0) + break; + + fwrite(td->og.header, 1, td->og.header_len, td->outfile); + fwrite(td->og.body, 1, td->og.body_len, td->outfile); + } + + td->numEncodedFrames = 0; + td->numEncodedBytes = 0; + + w = td->w; + h = td->h; + + if (td->alphaStack) { + td->yuvFrame = (unsigned char*)malloc(w * h * 2 * 3); + td->screen = (unsigned char*)malloc(w * h * 4); + td->bScreen = (unsigned char*)malloc(w * h * 2 * 4); + } else { + td->yuvFrame = (unsigned char*)malloc(w * h * 3); + td->screen = (unsigned char*)malloc(w * h * 4); + td->bScreen = (unsigned char*)malloc(w * h * 4); + } +} + +// ------------------------------------------------------------------- +// encode_buildTables + +void encode_buildTables(void) +{ + int i; + + for (i = 0; i < 256; i++) + { + tableRy[i] = i * 0.299; + tableGy[i] = i * 0.587; + tableBy[i] = i * 0.114; + + tableRu[i] = i * -0.169; + tableGu[i] = i * -0.332; + tableBu[i] = i * 0.500; + + tableRv[i] = i * 0.500; + tableGv[i] = i * -0.419; + tableBv[i] = i * -0.0813; + } + +} + +// ------------------------------------------------------------------- +// encode_frame + +void encode_frame(theorafunc_encode_data_t *td, int bpp, int final) +{ + unsigned char *yFrame, *uFrame, *vFrame, *dstPtr, *srcPtr, *srcPtr2; + unsigned char *yPtr, *uPtr, *vPtr; + + int x, y, i; + int u, v; + int r, g, b; + int bytesWritten; + int w, h; + + yuv_buffer yuv; + + w = td->w; + h = td->h; + if (td->alphaStack) + h *= 2; + + yFrame = (unsigned char*)malloc(w * h); + uFrame = (unsigned char*)malloc(w * h / 4); + vFrame = (unsigned char*)malloc(w * h / 4); + + yuv.y_width = w; + yuv.y_height = h; + yuv.y_stride = w; + + yuv.uv_width = w / 2; + yuv.uv_height = h / 2; + yuv.uv_stride = w / 2; + + yuv.y = yFrame; + yuv.u = uFrame; + yuv.v = vFrame; + + // - fill the initial YUV buffer with converted RGB values + + srcPtr = td->bScreen;//pixels; + dstPtr = td->yuvFrame; + + for (i = 0; i < h * w * bpp; i += 4) { + + r = *srcPtr++; + g = *srcPtr++; + b = *srcPtr++; + *srcPtr++; + + *dstPtr++ = tableRy[r] + tableGy[g] + tableBy[b]; + *dstPtr++ = tableRu[r] + tableGu[g] + tableBu[b] + 128; + *dstPtr++ = tableRv[r] + tableGv[g] + tableBv[b] + 128; + } + + // - grab the Y plane from the YUV buffer + + srcPtr = td->yuvFrame; + yPtr = yFrame; + + for (i = 0; i < w * h; i++) { + *yPtr++ = *srcPtr++; + *srcPtr++; + *srcPtr++; + } + + // - grab the UV planes + + uPtr = uFrame; + vPtr = vFrame; + + for (y = 0; y < h; y += 2) { + + srcPtr = td->yuvFrame + (y * w * 3); + srcPtr2 = td->yuvFrame + ((y + 1) * w * 3); + + for (x = 0; x < w; x += 2) { + + // - [0,0] + + *srcPtr++; // Y + u = *srcPtr++; // U + v = *srcPtr++; // V + + // - [1,0] + + *srcPtr++; // Y + u += *srcPtr++; // U + v += *srcPtr++; // V + + // - [0,1] + + *srcPtr2++; // Y + u += *srcPtr2++; // U + v += *srcPtr2++; // V + + // - [1,1] + + *srcPtr2++; // Y + u += *srcPtr2++; // U + v += *srcPtr2++; // V + + // - the U and V values are averaged out over + // the four-pixel block. + + *uPtr++ = u / 4; + *vPtr++ = v / 4; + } + } + + theora_encode_YUVin(&td->td, &yuv); + + // - take packets from the encoder and place them in + // the ogg stream + + while (theora_encode_packetout(&td->td, final, &td->op)) { + ogg_stream_packetin(&td->to, &td->op); + } + + // - write any available ogg pages to our file + + bytesWritten = 0; + while (ogg_stream_pageout(&td->to, &td->og)) { + fwrite(td->og.header, 1, td->og.header_len, td->outfile); + fwrite(td->og.body, 1, td->og.body_len, td->outfile); + + bytesWritten += td->og.header_len + td->og.body_len; + } + + free(yFrame); + free(uFrame); + free(vFrame); + + td->numEncodedFrames++; + td->numEncodedBytes += bytesWritten; +} + +// ------------------------------------------------------------------- +// copyFlippedScreen + +void copyFlippedScreen(unsigned char *src, unsigned char *dst + , int w, int h, int bpp, int alphaStack) +{ + int i, y; + int alpha; + unsigned char *srcPtr, *dstPtr; + + // - copy the source buffer to the dest buffer while flipping + // the image vertically. glReadPixels had created an inverted + // image. + + y = 0; + for (i = h - 1; i >= 0; i--) + { + srcPtr = src + (w * bpp * i); + dstPtr = dst + (w * bpp * y); + + memcpy(dstPtr, srcPtr, w * bpp); + y++; + } + + if (alphaStack) + { + // - fill the remainder of the dest buffer with a greyscale + // image of the source buffer's alpha channel + + srcPtr = dst; + dstPtr = dst + (w * bpp * h); + + for (i = 0; i < h * w * bpp; i += 4) + { + // - skip the RGB values and grab the alpha + + *srcPtr++; *srcPtr++; *srcPtr++; + alpha = *srcPtr++; + + // - the alpha value is stored as a greyscale image + + *dstPtr++ = alpha; + *dstPtr++ = alpha; + *dstPtr++ = alpha; + + // - the alpha value has to be 100% in order for it + // to be copied by SDL correctly + + *dstPtr++ = 0xFF; + } + } +} + diff --git a/dond/core/theorafunc.h b/dond/core/theorafunc.h new file mode 100755 index 0000000..18bbf6f --- /dev/null +++ b/dond/core/theorafunc.h @@ -0,0 +1,190 @@ +// ------------------------------------------------------------------- +// theorafunc.h - manny najera (11.28.06) + +#ifndef _THEORAFUNC_H_ +#define _THEORAFUNC_H_ + +// ------------------------------------------------------------------- + +#include +#include + +#ifndef WIN32 + #ifdef SYS_BB + #include + #else + #include + #endif +#endif + +#ifdef WIN32 + #include + #include "gl\glut.h" + #include + #include +#endif + +#include + +// ------------------------------------------------------------------- + +#define THEORAFUNC_SYNCTIME 1 +#define THEORAFUNC_CATCHUP 1 + +// ------------------------------------------------------------------- + +enum { + + THEORAFUNC_NOALPHA = 0, + THEORAFUNC_ALPHA, + THEORAFUNC_ALPHA_STACKED, +}; + +enum { + TF_ENCODE_NOALPHA = 0, + TF_ENCODE_ALPHA, +}; + +typedef void (td_callback)(void); + +// ------------------------------------------------------------------- +// - lookup tables for YUV->RGB conversion + +static int sAdjCrr[256]; +static int sAdjCrg[256]; +static int sAdjCbg[256]; +static int sAdjCbb[256]; +static int sAdjY[256]; +static unsigned char sClampBuff[1024]; +static unsigned char *sClamp = sClampBuff + 384; + +// ------------------------------------------------------------------- +// - lookup tables for RGB->YUV conversion + +static int tableRy[256]; +static int tableGy[256]; +static int tableBy[256]; + +static int tableRu[256]; +static int tableGu[256]; +static int tableBu[256]; + +static int tableRv[256]; +static int tableGv[256]; +static int tableBv[256]; + +// ------------------------------------------------------------------- +// - video data type + +typedef struct { + + ogg_sync_state oggSyncState; + ogg_page oggPage; + ogg_stream_state oggStreamState; + theora_info theoraInfo; + theora_comment theoraComment; + theora_state theoraState; + + int theora_p; + int64 vidStartTicks; + int x, y, w, h; + unsigned int glTex; + int alpha; + + int lastFrame; + + int pixelSize; + + int isPlaying; + int ignoreTime; + + td_callback *onDoneCallback; + + unsigned char *data; + int dataPos, dataSize; + + char *linkedObject[128]; + + unsigned char *pixelBuff; + +} theorafunc_data_t; + +// ------------------------------------------------------------------- +// - encoding data type + +typedef struct { + + ogg_stream_state to; + ogg_stream_state vo; + ogg_page og; + ogg_packet op; + + theora_state td; + theora_info ti; + theora_comment tc; + + FILE *outfile; + + unsigned char *yuvFrame; + unsigned char *screen, *bScreen; + + int numEncodedFrames; + int numEncodedBytes; + + int w, h; + int alphaStack; + +} theorafunc_encode_data_t; + +// ------------------------------------------------------------------- + +GLuint textureArray[32]; + +// ------------------------------------------------------------------- + +extern void theorafunc_buildTables(void); +extern theorafunc_data_t *theorafunc_allocate(void); + +//extern void theorafunc_init(theorafunc_data_t *td, char *filename, int glTex); +extern void theorafunc_init(theorafunc_data_t *td, unsigned char *data, int dataSize, int glTex); + +extern void theorafunc_openVideo(theorafunc_data_t *td); +extern int theorafunc_readyVideo(theorafunc_data_t *td); + +//extern int theorafunc_bufferData(FILE *in, ogg_sync_state *oy); +extern int theorafunc_bufferData(theorafunc_data_t *td); +extern int theorafunc_queuePage(theorafunc_data_t *td); + +extern void theorafunc_videoWrite(theorafunc_data_t *td); +extern void theorafunc_videoWriteRGB(theorafunc_data_t *td); +extern void theorafunc_videoWriteRGBA(theorafunc_data_t *td); +extern void theorafunc_videoWriteStackedRGBA(theorafunc_data_t *td); + +extern void theorafunc_restart(theorafunc_data_t *td); +extern void theorafunc_unload(theorafunc_data_t *td); + +extern int64 theorafunc_getTime(void); + +extern void encode_unload(theorafunc_encode_data_t *td); +extern void encode_init(theorafunc_encode_data_t *td, char *filename + , int w, int h, int bit_rate, int quality, int alphaStack); +extern void encode_buildTables(void); +extern void encode_frame(theorafunc_encode_data_t *td, int bpp, int final); +extern void copyFlippedScreen(unsigned char *src, unsigned char *dst + , int w, int h, int bpp, int alphaStack); + +extern void theorafunc_animateG3(void); +extern int theorafunc_getFrame(char *name); +extern int disableMipMapping(char *name); +extern theorafunc_data_t *getVideoFromObject(char *name); + +extern void theorafunc_loadVideo(char *name); +extern void theorafunc_unloadVideo(char *name); + +extern int theorafunc_getBytesAlloced(void); + +extern void theorafunc_vidalink(char *vidname, char *objname); + +// ------------------------------------------------------------------- + +#endif \ No newline at end of file diff --git a/dond/core/vec.c b/dond/core/vec.c new file mode 100755 index 0000000..f68cc40 --- /dev/null +++ b/dond/core/vec.c @@ -0,0 +1,1435 @@ +// vec.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 18 Oct 04 +// JFL 26 May 05; crd must be float + +#include "pm.h" +#include "vec.h" +#include "mem.h" + +#include // rand -- jjj +#include // sqrt, cos, sin + +// turn 3x3 row and column into linear offset +#define M3i(r,c) (r*3+c) + +// JFL 18 Oct 04 +float MathSqrt(float a) +{ + return (float)sqrt(a); +} // MathSqrt() + +// DispFastSqrt() -- from Tricks of the.. LaMothe, p1597 +// JFL 14 Apr 04 +float MathFastSqrt(float a) +{ + int n; + n =*((int*)(&a)); + n-=0x3f800000; + n>>=1; + n+=0x3f800000; + return *((float*)(&n)); +} // MathFastSqrt() + +crd MathACos(crd a) +{ + return (crd)acos(a); +} // MathACos() + +crd MathASin(crd a) +{ + return (crd)asin(a); +} // MathASin() + +crd MathATan(crd a) +{ + return (crd)atan(a); +} // MathATan() + +crd MathTan(crd a) +{ + return (crd)tan(a); +} // MathTan() + +// JFL 10 Feb 05 +double MathCosSind(double a,double *sinp) +{ + if(sinp) + *sinp=sin(a); + return cos(a); +} // MathCosSind() + +// JFL 10 Feb 05 +crd MathCosSin(crd a,crd *sinp) +{ + if(sinp) + *sinp=(crd)sin(a); + return (crd)cos(a); +} // MathCosSin() + +// +// QuatToM3 +// turn quaternion into a 3x3 matrix +// +// algorithm from Advanced Animation And Rendering Techniques by Alan & Mark Watt p363 +// +// in: +// q = quaternion +// mat = result matrix +// out: +// global: +// +// GNP 06 Jul 00 +// +void QuatToM3(crd* q, crd* mat) +{ + double s,xs,ys,zs,wx,wy,wz,xx,xy,xz,yy,yz,zz; + + s = 2.0/(q[Q_X]*q[Q_X]+q[Q_Y]*q[Q_Y]+q[Q_Z]*q[Q_Z]+q[Q_W]*q[Q_W]); + + xs = q[Q_X]*s; + ys = q[Q_Y]*s; + zs = q[Q_Z]*s; + + wx = q[Q_W]*xs; + wy = q[Q_W]*ys; + wz = q[Q_W]*zs; + + xx = q[Q_X]*xs; + xy = q[Q_X]*ys; + xz = q[Q_X]*zs; + + yy = q[Q_Y]*ys; + yz = q[Q_Y]*zs; + zz = q[Q_Z]*zs; + + mat[M3i(0,0)] = (crd)(1.0 - (yy + zz)); + mat[M3i(0,1)] = (crd)(xy + wz); + mat[M3i(0,2)] = (crd)(xz - wy); + + mat[M3i(1,0)] = (crd)(xy - wz); + mat[M3i(1,1)] = (crd)(1.0 - (xx + zz)); + mat[M3i(1,2)] = (crd)(yz + wx); + + mat[M3i(2,0)] = (crd)(xz + wy); + mat[M3i(2,1)] = (crd)(yz - wx); + mat[M3i(2,2)] = (crd)(1.0 - (xx + yy)); + +} // QuatToM3() + +// +// M3ToQuat +// turn 3x3 matrix into a quaternion +// +// algorithm from Advanced Animation And Rendering Techniques by Alan & Mark Watt p363 +// +// in: +// q = quaternion +// mat = result matrix +// out: +// global: +// +// MTM 27 Mar 01 +// +void M3ToQuat(crd* mat, crd* q) +{ + double tr,s; + int i,j,k; + int nxt[3] = {Q_Y,Q_Z,Q_X}; + + tr = mat[M3i(0,0)] + mat[M3i(1,1)] + mat[M3i(2,2)]; + if(tr > 0.0) + { + s = sqrt(tr + 1.0); + q[Q_W] = (crd)(s*0.5); + s = 0.5/s; + + q[Q_X] = (crd)((mat[M3i(1,2)] - mat[M3i(2,1)])*s); + q[Q_Y] = (crd)((mat[M3i(2,0)] - mat[M3i(0,2)])*s); + q[Q_Z] = (crd)((mat[M3i(0,1)] - mat[M3i(1,0)])*s); + } + + else + { + i = Q_X; + if(mat[M3i(Q_Y,Q_Y)] > mat[M3i(Q_X,Q_X)]) i = Q_Y; + if(mat[M3i(Q_Z,Q_Z)] > mat[M3i(i,i)]) i = Q_Z; + j = nxt[i]; k = nxt[j]; + + s = MathSqrt( (crd)((mat[M3i(i,i)] - (mat[M3i(j,j)]+mat[M3i(k,k)])) + 1.0)); + q[i] = (crd)(s*0.5); + s = 0.5/s; + q[Q_W] = (crd)((mat[M3i(j,k)] - mat[M3i(k,j)])*s); + q[j] = (crd)((mat[M3i(i,j)] + mat[M3i(j,i)])*s); + q[k] = (crd)((mat[M3i(i,k)] + mat[M3i(k,i)])*s); + } +} // M3ToQuat + +// JFL 11 Apr 04 +void QuatNormalize(crd *q) +{ + double s; + s=1.0/(q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]); + q[0] = (crd)(s*q[0]); + q[1] = (crd)(s*q[1]); + q[2] = (crd)(s*q[2]); + q[3] = (crd)(s*q[3]); +} // QuatNormalize() + +// JFL 11 Apr 04 +// JFL 18 Oct 04; from JoeCo +void QuatMul(crd *d,crd *a,crd *b) +{ + d[3] = a[3]*b[3] - a[0]*b[0] - a[1]*b[1] - a[2]*b[2]; + d[0] = a[3]*b[0] + a[0]*b[3] + a[1]*b[2] - a[2]*b[1]; + d[1] = a[3]*b[1] + a[1]*b[3] + a[2]*b[0] - a[0]*b[2]; + d[2] = a[3]*b[2] + a[2]*b[3] + a[0]*b[1] - a[1]*b[0]; +} // QuatMul() + +// JFL 11 Apr 04 +// JFL 18 Oct 04; from JoeCo +void QuatAxisToAxis(crd *qdst,crd *a,crd *b) +{ + crd va[V3_SIZE],vb[V3_SIZE],vh[V3_SIZE]; + + V3Cpy(va,a); + V3Cpy(vb,b); + V3Normalize(va); + V3Normalize(vb); + V3Add(vh,va,vb); + V3Normalize(vh); + V3Cross(qdst,va,vh); + qdst[Q_W]=V3Dot(va,vh); +} // QuatAxisToAxis() + +// JFL 13 Jul 05 +float V3DistFast(crd *v0,crd *v1) +{ + int n; + float a,b; + + a=v0[0]-v1[0]; + a*=a; + b=v0[1]-v1[1]; + b*=b; + a+=b; + b=v0[2]-v1[2]; + b*=b; + a+=b; + + n=*((int*)(&a)); + n-=0x3f800000; + n>>=1; + n+=0x3f800000; + return *((float*)(&n)); +} // V3DistFast() + +// +// V3Normalize +// normalize 3-space vector +// +// in: +// v = vector +// out: +// 1/length +// global: +// +// GNP 29 Jun 00 +// JFL 17 Aug 00 +// JFL 13 Jul 05 +crd V3Normalize(crd* v) +{ + double len,a,b; + + a=v[VEC_X]; + a*=a; + b=v[VEC_Y]; + b*=b; + a+=b; + b=v[VEC_Z]; + b*=b; + a+=b; + len=MathSqrt((crd)a); + if(len) a=1.0f/len; + else return 0; + v[VEC_X]=(crd)(a*v[VEC_X]); + v[VEC_Y]=(crd)(a*v[VEC_Y]); + v[VEC_Z]=(crd)(a*v[VEC_Z]); + return (crd)len; +} // V3Normalize + +// JFL 05 Jul 05 +crd V3Unitize(crd* v,crd len) +{ + crd a,b; + + a=v[VEC_X]; + a*=a; + b=v[VEC_Y]; + b*=b; + a+=b; + b=v[VEC_Z]; + b*=b; + a+=b; + + b=MathSqrt((crd)a); + if(!b) + return 0; + + a=len/b; + v[VEC_X]=(crd)(a*v[VEC_X]); + v[VEC_Y]=(crd)(a*v[VEC_Y]); + v[VEC_Z]=(crd)(a*v[VEC_Z]); + + return (crd)b; +} // V3Unitize() + +// JFL 13 Jul 05 +crd V3UnitizeFast(crd* v,crd len) +{ + int n; + float a,b; + + a=v[VEC_X]; + a*=a; + b=v[VEC_Y]; + b*=b; + a+=b; + b=v[VEC_Z]; + b*=b; + a+=b; + + // fast sqrt + n=*((int*)(&a)); + n-=0x3f800000; + n>>=1; + n+=0x3f800000; + b=*((float*)(&n)); + + if(!b) + return 0; + + a=len/b; + + v[VEC_X]=(crd)(a*v[VEC_X]); + v[VEC_Y]=(crd)(a*v[VEC_Y]); + v[VEC_Z]=(crd)(a*v[VEC_Z]); + + return (crd)b; +} // V3UnitizeFast() + +// +// V3Len +// JFL 30 Oct 04 +// +crd V3Len(crd* v) +{ + double a,b; + + a=v[VEC_X]; + a*=a; + b=v[VEC_Y]; + b*=b; + a+=b; + b=v[VEC_Z]; + b*=b; + a+=b; + a=MathSqrt((crd)a); + return (crd)a; +} // V3Len() + +// JFL 03 Feb 05 +int V3NormalCW(crd *normal,crd *v0,crd *v1,crd *v2) +{ + crd a[3],b[3]; + V3Sub(a,v2,v1); + V3Sub(b,v1,v0); + V3Cross(normal,b,a); + V3Normalize(normal); + return 0; +} // V3NormalCW() + +// JFL 23 Nov 04; match OpenGL +void M3Mul(crd *dst,crd *cur, crd *add) +{ + int i,j; + crd tmp[M3_SIZE],*c=NUL; + + if(dst==add || dst==cur) + { + c=dst; + dst=tmp; + } + + for(i=0;i<3;i++) + for(j=0;j<3;j++) + dst[i*3+j]= add[i*3+0]*cur[0*3+j] + +add[i*3+1]*cur[1*3+j] + +add[i*3+2]*cur[2*3+j]; + + if(c) + M3Cpy(c,tmp); +} // M3Mul() + +// JFL 19 Mar 04 +void M4Mul(crd *dst,crd *cur,crd *add) +{ + int i,j; + crd tmp[M4_SIZE],*c=NUL; + + if(dst==add || dst==cur) + { + c=dst; + dst=tmp; + } + + for(i=0;i<4;i++) + for(j=0;j<4;j++) + dst[i*4+j]= add[i*4+0]*cur[0*4+j] + +add[i*4+1]*cur[1*4+j] + +add[i*4+2]*cur[2*4+j] + +add[i*4+3]*cur[3*4+j]; + + if(c) + M4Cpy(c,tmp); +} // M4Mul() + +// JFL 13 May 04 +// JFL 18 Jun 04; handles dst==src +// JFL 18 Nov 04; into game +// JFL 19 Nov 04; tested v OpenGL +void VMMpy(crd *dst,crd *cur,crd *add) +{ + crd tmp[VM_SIZE],*x; + + // note -- need to clean this up -- jjj -- diff than VMCat() + + x=NUL; + if(dst==add || dst==cur) + { + x=dst; + dst=tmp; + } + + dst[VM_X]=add[VM_X]+ + cur[VM_X]*(add)[VM_11]+cur[VM_Y]*(add)[VM_12]+cur[VM_Z]*(add)[VM_13]; + dst[VM_Y]=add[VM_Y]+ + cur[VM_X]*(add)[VM_21]+cur[VM_Y]*(add)[VM_22]+cur[VM_Z]*(add)[VM_23]; + dst[VM_Z]=add[VM_Z]+ + cur[VM_X]*(add)[VM_31]+cur[VM_Y]*(add)[VM_32]+cur[VM_Z]*(add)[VM_33]; + + dst+=VM_11; + add+=VM_11; + cur+=VM_11; + + M3Mul(dst,cur,add); + + if(x) + VMCpy(x,tmp); + +} // VMMpy() + +// JFL 13 May 04 +// JFL 18 Jun 04; handles dst==src +// JFL 18 Nov 04; into game +// JFL 19 Nov 04; tested v OpenGL +void VMCat(crd *dst,crd *cur,crd *add) +{ + crd tmp[VM_SIZE],*x; + + // note -- need to clean this up -- jjj -- diff than VMMpy() + + x=NUL; + if(dst==add || dst==cur) + { + x=dst; + dst=tmp; + } + + dst[VM_X]=cur[VM_X]+ + add[VM_X]*(cur)[VM_11]+add[VM_Y]*(cur)[VM_12]+add[VM_Z]*(cur)[VM_13]; + dst[VM_Y]=cur[VM_Y]+ + add[VM_X]*(cur)[VM_21]+add[VM_Y]*(cur)[VM_22]+add[VM_Z]*(cur)[VM_23]; + dst[VM_Z]=cur[VM_Z]+ + add[VM_X]*(cur)[VM_31]+add[VM_Y]*(cur)[VM_32]+add[VM_Z]*(cur)[VM_33]; + + dst+=VM_11; + add+=VM_11; + cur+=VM_11; + + M3Mul(dst,cur,add); + + if(x) + VMCpy(x,tmp); + +} // VMCat() + +// JFL 19 Mar 04 +// JFL 18 May 04 +// JFL 19 Nov 04; // tested v OpenGL +void M3BuildRot(crd *a,crd rad,int xyz) +{ + crd s,c; + s=(crd)sin(rad);c=(crd)cos(rad); + +/* + | 1 0 0 | + X = | 0 A -B | + | 0 B A | + + | C 0 D | + Y = | 0 1 0 | + | -D 0 C | + + | E -F 0 | + Z = | F E 0 | + | 0 0 1 | +*/ + + if(xyz==XYZ_X) + { + a[M3_11]=1; + a[M3_12]=0; + a[M3_13]=0; + a[M3_21]=0; + a[M3_22]=c; + a[M3_23]=-s; + a[M3_31]=0; + a[M3_32]=s; + a[M3_33]=c; + } + else if(xyz==XYZ_Y) + { + a[M3_11]=c; + a[M3_12]=0; + a[M3_13]=s; + a[M3_21]=0; + a[M3_22]=1; + a[M3_23]=0; + a[M3_31]=-s; + a[M3_32]=0; + a[M3_33]=c; + } + else + { + a[M3_11]=c; + a[M3_12]=-s; + a[M3_13]=0; + a[M3_21]=s; + a[M3_22]=c; + a[M3_23]=0; + a[M3_31]=0; + a[M3_32]=0; + a[M3_33]=1; + } +} // M3BuildRot() + +// JFL 09 Jun 05 +void M3BuildObj(crd *dstm,crd *rots) +{ + crd m1[M3_SIZE],m2[M3_SIZE]; + + M3BuildRot(m1,rots[2],2); + M3BuildRot(m2,rots[1],1); + M3Mul(m1,m2,m1); + M3BuildRot(m2,rots[0],0); + M3Mul(dstm,m2,m1); + +} // M3BuildObj() + +// JFL 03 Aug 05 +void MathM3ToScale(crd *m,crd *scale) +{ + crd *mm; + + mm=m; + scale[0] =*mm * *mm;mm++; + scale[0]+=*mm * *mm;mm++; + scale[0]+=*mm * *mm;mm++; + scale[0]=MathSqrt(scale[0]); + + scale[1] =*mm * *mm;mm++; + scale[1]+=*mm * *mm;mm++; + scale[1]+=*mm * *mm;mm++; + scale[1]=MathSqrt(scale[1]); + + scale[2] =*mm * *mm;mm++; + scale[2]+=*mm * *mm;mm++; + scale[2]+=*mm * *mm; + scale[2]=MathSqrt(scale[2]); + +} // MathM3ToScale() + +// JFL 03 Aug 05 +void MathM3Unscale(crd *m,crd *scale) +{ + crd *mm=m; + *mm++/=scale[0]; + *mm++/=scale[0]; + *mm++/=scale[0]; + *mm++/=scale[1]; + *mm++/=scale[1]; + *mm++/=scale[1]; + *mm++/=scale[2]; + *mm++/=scale[2]; + *mm++/=scale[2]; +} // MathM3Unscale() + +// JFL 09 Jun 05 +void VMBuildObj(crd *dst,crd *rot,crd *trans,crd *scale) +{ + crd m1[VM_SIZE],m2[VM_SIZE]; + + if(rot) + { + M3BuildRot(m1,rot[2],2); + M3BuildRot(m2,rot[1],1); + M3Mul(m1,m1,m2); + M3BuildRot(m2,rot[0],0); + M3Mul(dst+VM_11,m1,m2); + } + else + M3Id(dst+VM_11); + + if(trans) + V3Cpy(dst,trans); + else + dst[0]=dst[1]=dst[2]=0; + + // zero scales are not allowed -- used signal no scale + if(scale&&scale[0]&&scale[1]&&scale[2]) + { + M3BuildScaleXYZ(m1,scale[0],scale[1],scale[2]); + M3Mul(dst+VM_11,dst+VM_11,m1); + } +} // VMBuildObj() + +// JFL 18 May 04 +void VMInv(crd *dst,crd *src) +{ + double scale; + crd tmp[VM_SIZE],*x; + + x=NUL; + if(dst==src) + { + x=dst; + dst=tmp; + } + + /* + * ANSI C code from the article + * "Fast Inversion of Length- and Angle-Preserving Matrices" + * by Kevin Wu, Kevin.Wu@eng.sun.com + * in "Graphics Gems IV", Academic Press, 1994 + */ + + /* + * + * angle_preserving_matrix4_inverse + * + * Computes the inverse of a 3-D angle-preserving matrix. + * + * This procedure treats the 4 by 4 angle-preserving matrix as a block + * matrix and calculates the inverse of one submatrix for a significant + * performance improvement over a general procedure that can invert any + * nonsingular matrix: + * + * ------ ------ + * | A C| -1 = | | + * | 0 1| | | + * ------ ------ + * + * where M is a 4 by 4 angle-preserving matrix, + * A is the 3 by 3 upper-left submatrix of M, + * C is the 3 by 1 upper-right submatrix of M. + * + */ + + /* Calculate the square of the isotropic scale factor */ + scale = src[VM_11]*src[VM_11] + +src[VM_12]*src[VM_12]+src[VM_13]*src[VM_13]; + if(!scale) + scale=1; + else + scale=1/scale; + + /* Transpose and scale the 3 by 3 upper-left submatrix */ + dst[VM_11] = (crd) (scale * src[VM_11]); + dst[VM_12] = (crd) (scale * src[VM_21]); + dst[VM_13] = (crd) (scale * src[VM_31]); + dst[VM_21] = (crd) (scale * src[VM_12]); + dst[VM_22] = (crd) (scale * src[VM_22]); + dst[VM_23] = (crd) (scale * src[VM_32]); + dst[VM_31] = (crd) (scale * src[VM_13]); + dst[VM_32] = (crd) (scale * src[VM_23]); + dst[VM_33] = (crd) (scale * src[VM_33]); + + /* Calculate -(transpose(A) / s*s) C */ + dst[VM_X] = -(dst[VM_11]*src[VM_X] + +dst[VM_12]*src[VM_Y] + +dst[VM_13]*src[VM_Z]); + dst[VM_Y] = -(dst[VM_21]*src[VM_X] + +dst[VM_22]*src[VM_Y] + +dst[VM_23]*src[VM_Z]); + dst[VM_Z] = -(dst[VM_31]*src[VM_X] + +dst[VM_32]*src[VM_Y] + +dst[VM_33]*src[VM_Z]); + + if(x) + VMCpy(x,tmp); + +} // VMInv() + +#define CLEAN_EPSILON_XYZ 0.00001 +#define CLEAN_EPSILON_ANG 0.0000001 + +// JFL 21 May 04 +void VMClean(crd *dst) +{ + crd s; + uns8 k,pass=0; + +loop: + s = dst[VM_11]*dst[VM_11] + + dst[VM_12]*dst[VM_12] + dst[VM_13]*dst[VM_13]; + if(!s) s = 1; + s = (crd)(1/sqrt(s)); + dst[VM_11] *= s; + dst[VM_12] *= s; + dst[VM_13] *= s; + + s = dst[VM_21]*dst[VM_21] + + dst[VM_22]*dst[VM_22] + dst[VM_23]*dst[VM_23]; + if(!s) s = 1; + s = (crd)(1/sqrt(s)); + dst[VM_21] *= s; + dst[VM_22] *= s; + dst[VM_23] *= s; + + s = dst[VM_31]*dst[VM_31] + + dst[VM_32]*dst[VM_32] + dst[VM_33]*dst[VM_33]; + if(!s) s = 1; + s = (crd)(1/sqrt(s)); + dst[VM_31] *= s; + dst[VM_32] *= s; + dst[VM_33] *= s; + + if(pass) + return; + + for(k=0;k0 && dst[k]-CLEAN_EPSILON_XYZ)) + { + dst[k]=0; + } + } // for + + for(k=VM_11;k0 && dst[k]-CLEAN_EPSILON_ANG)) + { + dst[k]=0; + pass=1; + } + } // for + + if(pass) + goto loop; + +} // VMClean() + +// JFL 08 Nov 04 +// JFL 27 Jan 05; wrap fix +float MathBlendRot(float rot0,float rot1,float blend0,float blend1) +{ + float d; + + d=rot1-rot0; + if((d>3*PI/2) || (d<3*-PI/2)) + { + if(d<0) + { + while(d<0) + d+=2*PI; + while(d>2*PI) + d-=2*PI; + } + else + { + while(d>0) + d-=2*PI; + while(d<-2*PI) + d+=2*PI; + } + } // if + d*=blend1; + return rot0+d; +} // MathBlendRot() + +// JFL 11 Jul 05 +// JFL 26 Jul 05 +void MathNrmToRot(crd *nrm,crd *rot) +{ + crd r; + crd v[3],w[3],vm[VM_SIZE],rots[3],n[3]; + + // rot nrm to 0,0,-1 + + n[0]=-nrm[0]; + n[1]=-nrm[1]; + n[2]=-nrm[2]; + + r=atan2(-n[0],n[2]); + rot[1]=-r; + + rots[0]=0; + rots[1]=r; + rots[2]=0; + VMBuildObj(vm,rots,NUL,NUL); + V3RotVM(v,n,vm); + + r=atan2(v[1],v[2]); + rot[0]=-r; + + rots[0]=r; + rots[1]=0; + rots[2]=0; + VMBuildObj(vm,rots,NUL,NUL); + V3RotVM(w,v,vm); + + rot[2]=0; + +} // MathNrmToRot() + +// JFL 29 Jul 05 +void MathM3ToRot(crd *mat,crd *rot) +{ + crd x,y,z,c; + + y=asin(mat[M3_13]); // y angle + c=cos(y); + if((c<-0.004)||(c>0.004)) // no gimbal problem + { + x = atan2(-mat[M3_23]/c,mat[M3_33]/c); + z = atan2(-mat[M3_12]/c,mat[M3_11]/c); + } + else // gimbal lock + { + x=0; // no x angles + z=atan2(mat[M3_21],mat[M3_22]); + } + + rot[0]=x; + rot[1]=y; + rot[2]=z; +} // MathM3ToRot() + +// JFL 17 Mar 04 +// JFL 19 Oct 04; from JoeCo +int MathPDUToCamM4(crd *m4,crd *pos,crd *dir,crd *up) +{ + //float dist; + crd n[3],v[3],u[3],m2[16]; + + #if 0 // code to test + #include + #include + #include + #include + + float ogl[16],tgt[3]; + tgt[0]=pos[0]+dir[0]; + tgt[1]=pos[1]+dir[1]; + tgt[2]=pos[2]+dir[2]; + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(pos[0],pos[1],pos[2], + tgt[0],tgt[1],tgt[2], + up[0],up[1],up[2]); + glGetFloatv(GL_MODELVIEW_MATRIX,ogl); + glLoadIdentity(); // don't cheat + #endif // code to test + + // this builds a matrix for OpenGL + + // create camera matrix from position, direction and up vectors + // started from Foley p.261 + + // find dir + n[0]=-dir[0]; + n[1]=-dir[1]; + n[2]=-dir[2]; + V3Normalize(n); + + // find right + V3Cross(u,up,n); + if(!V3Normalize(u)) + { + if(n[1]) + V3SetXYZ(u,1,0,0); + else if(n[2]) + V3SetXYZ(u,0,1,0); + else + V3SetXYZ(u,0,0,1); + } + + // find up + V3Cross(v,n,u); + V3Normalize(v); + + //dist =pos[0]*pos[0]; + //dist+=pos[1]*pos[1]; + //dist+=pos[2]*pos[2]; + //dist=MathSqrt(dist); + + M4Id(m2); + M4SetXYZ(m2,-pos[0],-pos[1],-pos[2]); + + // build matrix + M4Id(m4); + M4Set3x3(m4, + u[0],u[1],u[2], + v[0],v[1],v[2], + n[0],n[1],n[2]); + M4Mul(m4,m4,m2); + +// M4Cpy(m2,m4); // jjj -- fix this +// M4Cpy(m4,ogl); + return 0; +} // MathPDUToCamM4() + +// JFL 19 Oct 04; from JoeCo +int MathCamToPDUM4(crd *m4,crd *pos,crd *dir,crd *up) +{ + crd va[3],mat[M3_SIZE],inv[M3_SIZE]; + + M3SetM4(mat,m4); + M3Inv(inv,mat); + + va[0]=-m4[M4_X]; + va[1]=-m4[M4_Y]; + va[2]=-m4[M4_Z]; + V3RotM3(pos,va,inv); + + va[0]=0; + va[1]=0; + va[2]=-1; + V3RotM3(dir,va,inv); + + va[0]=0; + va[1]=1; + va[2]=0; + V3RotM3(up,va,inv); + + return 0; +} // MathCamToPDUM4() + +// +// M3Inv +// calculate the inverse of a 3x3 matrix +// +// in: +// src = source matrix +// dst = result matrix +// out: +// <0 = no inverse, dst is identity matrix +// global: +// +// GNP 28 Jun 00 +// JFL 01 Nov 04 +// +int M3Inv(crd *dst,crd *src) +{ + int ec; + int i; + crd det; + float tmp[M3_SIZE],*c=NUL; + + if(src==dst) + { + c=dst; + dst=tmp; + } + + // compute adjugate matrix as transpose of cofactors + dst[M3_11] = src[M3_22] * src[M3_33] - src[M3_23] * src[M3_32]; + dst[M3_21] = src[M3_23] * src[M3_31] - src[M3_21] * src[M3_33]; + dst[M3_31] = src[M3_21] * src[M3_32] - src[M3_22] * src[M3_31]; + + dst[M3_12] = src[M3_13] * src[M3_32] - src[M3_12] * src[M3_33]; + dst[M3_22] = src[M3_11] * src[M3_33] - src[M3_13] * src[M3_31]; + dst[M3_32] = src[M3_12] * src[M3_31] - src[M3_11] * src[M3_32]; + + dst[M3_13] = src[M3_12] * src[M3_23] - src[M3_13] * src[M3_22]; + dst[M3_23] = src[M3_13] * src[M3_21] - src[M3_11] * src[M3_23]; + dst[M3_33] = src[M3_11] * src[M3_22] - src[M3_12] * src[M3_21]; + + // calculate determinate + det = src[M3_11] * dst[M3_11] + src[M3_21] * dst[M3_12] + + src[M3_31] * dst[M3_13]; + + // if determinate is 0, + // the matrix is singular (i.e. has no inverse). + // return identity matrix + if (!det) + { + M3Id(dst); + err(-1); + } + + det = 1.0f/det; + + // calculate inverse of matrix by multiplying + // adjugate matrix by the inverse of the determinate + for (i=0;i 0); \ + } while (0) + +/* Discontinue quicksort algorithm when partition gets below this size. + This particular magic number was chosen to work best on a Sun 4/260. */ +#define MAX_THRESH 4 + +/* Stack node declarations used to store unfulfilled partition obligations. */ +typedef struct + { + char *lo; + char *hi; + } stack_node; + +/* The next 4 #defines implement a very fast in-line stack abstraction. */ +#define STACK_SIZE (8 * sizeof(unsigned long int)) +#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) +#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) +#define STACK_NOT_EMPTY (stack < top) + + +/* Order size using quicksort. This implementation incorporates + four optimizations discussed in Sedgewick: + + 1. Non-recursive, using an explicit stack of pointer that store the + next array partition to sort. To save time, this maximum amount + of space required to store an array of MAX_INT is allocated on the + stack. Assuming a 32-bit integer, this needs only 32 * + sizeof(stack_node) == 136 bits. Pretty cheap, actually. + + 2. Chose the pivot element using a median-of-three decision tree. + This reduces the probability of selecting a bad pivot value and + eliminates certain extraneous comparisons. + + 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving + insertion sort to order the MAX_THRESH items within each partition. + This is a big win, since insertion sort is faster for small, mostly + sorted array segments. + + 4. The larger of the two sub-partitions is always pushed onto the + stack first, with the algorithm then concentrating on the + smaller partition. This *guarantees* no more than log (n) + stack size is needed (actually O(1) in this case)! */ + +void MathQSort(void *pbase,int total_elems,int size,int (*cmp)(void*,void*)) +{ + register char *base_ptr = (char *) pbase; + + /* Allocating SIZE bytes for a pivot buffer facilitates a better + algorithm below since we can do comparisons directly on the pivot. */ + char *pivot_buffer,*memsave=NUL; + const int max_thresh = MAX_THRESH * size; + + if (total_elems == 0) + /* Avoid lossage with unsigned arithmetic below. */ + return; + + memsave=MemSLowGet(MEMPOOL_HEAP); + if(MemSLow(MEMPOOL_HEAP,size,&pivot_buffer)<0) + goto BAIL; + + if (total_elems > MAX_THRESH) + { + char *lo = base_ptr; + char *hi = &lo[size * (total_elems - 1)]; + /* Largest size needed for 32-bit int!!! */ + stack_node stack[STACK_SIZE]; + stack_node *top = stack + 1; + + while (STACK_NOT_EMPTY) + { + char *left_ptr; + char *right_ptr; + + char *pivot = pivot_buffer; + + /* Select median value from among LO, MID, and HI. Rearrange + LO and HI so the three values are sorted. This lowers the + probability of picking a pathological pivot value and + skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ + + char *mid = lo + size * ((hi - lo) / size >> 1); + + if ((*cmp) ((void *) mid, (void *) lo) < 0) + SWAP (mid, lo, size); + if ((*cmp) ((void *) hi, (void *) mid) < 0) + SWAP (mid, hi, size); + else + goto jump_over; + if ((*cmp) ((void *) mid, (void *) lo) < 0) + SWAP (mid, lo, size); + jump_over:; + + MemCpy(pivot, mid, size); + pivot = pivot_buffer; + + left_ptr = lo + size; + right_ptr = hi - size; + + /* Here's the famous ``collapse the walls'' section of quicksort. + Gotta like those tight inner loops! They are the main reason + that this algorithm runs much faster than others. */ + do + { + while ((*cmp) ((void *) left_ptr, (void *) pivot) < 0) + left_ptr += size; + + while ((*cmp) ((void *) pivot, (void *) right_ptr) < 0) + right_ptr -= size; + + if (left_ptr < right_ptr) + { + SWAP (left_ptr, right_ptr, size); + left_ptr += size; + right_ptr -= size; + } + else if (left_ptr == right_ptr) + { + left_ptr += size; + right_ptr -= size; + break; + } + } + while (left_ptr <= right_ptr); + + /* Set up pointers for next iteration. First determine whether + left and right partitions are below the threshold size. If so, + ignore one or both. Otherwise, push the larger partition's + bounds on the stack and continue sorting the smaller one. */ + + if ((int) (right_ptr - lo) <= max_thresh) + { + if ((int) (hi - left_ptr) <= max_thresh) + /* Ignore both small partitions. */ + POP (lo, hi); + else + /* Ignore small left partition. */ + lo = left_ptr; + } + else if ((int) (hi - left_ptr) <= max_thresh) + /* Ignore small right partition. */ + hi = right_ptr; + else if ((right_ptr - lo) > (hi - left_ptr)) + { + /* Push larger left partition indices. */ + PUSH (lo, right_ptr); + lo = left_ptr; + } + else + { + /* Push larger right partition indices. */ + PUSH (left_ptr, hi); + hi = right_ptr; + } + } + } + + /* Once the BASE_PTR array is partially sorted by quicksort the rest + is completely sorted using insertion sort, since this is efficient + for partitions below MAX_THRESH size. BASE_PTR points to the beginning + of the array to sort, and END_PTR points at the very last element in + the array (*not* one beyond it!). */ + +#undef min +#define min(x, y) ((x) < (y) ? (x) : (y)) + + { + char *const end_ptr = &base_ptr[size * (total_elems - 1)]; + char *tmp_ptr = base_ptr; + char *thresh = min(end_ptr, base_ptr + max_thresh); + register char *run_ptr; + + /* Find smallest element in first threshold and place it at the + array's beginning. This is the smallest array element, + and the operation speeds up insertion sort's inner loop. */ + + for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) + if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0) + tmp_ptr = run_ptr; + + if (tmp_ptr != base_ptr) + SWAP (tmp_ptr, base_ptr, size); + + /* Insertion sort, running from left-hand-side up to right-hand-side. */ + + run_ptr = base_ptr + size; + while ((run_ptr += size) <= end_ptr) + { + tmp_ptr = run_ptr - size; + while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0) + tmp_ptr -= size; + + tmp_ptr += size; + if (tmp_ptr != run_ptr) + { + char *trav; + + trav = run_ptr + size; + while (--trav >= run_ptr) + { + char c = *trav; + char *hi, *lo; + + for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) + *hi = *lo; + *hi = c; + } + } + } + } + +BAIL: + if(memsave) + MemSLowSet(MEMPOOL_HEAP,memsave); + return; +} // MathQSort() + +/** + * References an element of 4x4 matrix. + * + * \param m matrix array. + * \param c column of the desired element. + * \param r row of the desired element. + * + * \return value of the desired element. + * + * Calculate the linear storage index of the element and references it. + */ +#define MAT(m,r,c) (m)[(c)*4+(r)] + + +/**********************************************************************/ +/** \name Matrix inversion */ +/*@{*/ + +/** + * Swaps the values of two floating pointer variables. + * + * Used by invert_matrix_general() to swap the row pointers. + */ +#define SWAP_ROWS(a, b) { crd *_tmp = a; (a)=(b); (b)=_tmp; } + +/** + * Compute inverse of 4x4 transformation matrix. + * + * \param mat pointer to a GLmatrix structure. The matrix inverse will be + * stored in the GLmatrix::inv attribute. + * + * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix). + * + * \author + * Code contributed by Jacques Leroy jle@star.be + * + * Calculates the inverse matrix by performing the gaussian matrix reduction + * with partial pivoting followed by back/substitution with the loops manually + * unrolled. + */ +int M4InvGeneral(crd *inv,crd *mat) +{ + crd *m = mat; + crd *out = inv; + crd wtmp[4][8]; + crd m0, m1, m2, m3, s; + crd *r0, *r1, *r2, *r3; + + r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; + + r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1), + r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3), + r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, + + r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1), + r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3), + r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, + + r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1), + r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3), + r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, + + r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1), + r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3), + r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; + + /* choose pivot - or die */ + if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2); + if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1); + if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0); + if (0.0 == r0[0]) return -1; + + /* eliminate first variable */ + m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0]; + s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; + s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; + s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; + s = r0[4]; + if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } + s = r0[5]; + if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } + s = r0[6]; + if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } + s = r0[7]; + if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } + + /* choose pivot - or die */ + if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2); + if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1); + if (0.0 == r1[1]) return -1; + + /* eliminate second variable */ + m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1]; + r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; + r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; + s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } + s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } + s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } + s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } + + /* choose pivot - or die */ + if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2); + if (0.0 == r2[2]) return -1; + + /* eliminate third variable */ + m3 = r3[2]/r2[2]; + r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], + r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], + r3[7] -= m3 * r2[7]; + + /* last check */ + if (0.0 == r3[3]) return -1; + + s = 1.0F/r3[3]; /* now back substitute row 3 */ + r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; + + m2 = r2[3]; /* now back substitute row 2 */ + s = 1.0F/r2[2]; + r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), + r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); + m1 = r1[3]; + r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1, + r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1; + m0 = r0[3]; + r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, + r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; + + m1 = r1[2]; /* now back substitute row 1 */ + s = 1.0F/r1[1]; + r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), + r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); + m0 = r0[2]; + r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, + r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; + + m0 = r0[1]; /* now back substitute row 0 */ + s = 1.0F/r0[0]; + r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), + r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); + + MAT(out,0,0) = r0[4]; MAT(out,0,1) = r0[5], + MAT(out,0,2) = r0[6]; MAT(out,0,3) = r0[7], + MAT(out,1,0) = r1[4]; MAT(out,1,1) = r1[5], + MAT(out,1,2) = r1[6]; MAT(out,1,3) = r1[7], + MAT(out,2,0) = r2[4]; MAT(out,2,1) = r2[5], + MAT(out,2,2) = r2[6]; MAT(out,2,3) = r2[7], + MAT(out,3,0) = r3[4]; MAT(out,3,1) = r3[5], + MAT(out,3,2) = r3[6]; MAT(out,3,3) = r3[7]; + + return 0; +} +#undef SWAP_ROWS + +// JFL 28 Feb 05 +void RandUSeed(uns seed) +{ + srand(seed); +} // RandUSeed() + +// JFL 28 Feb 05 +uns RandU(uns top) +{ + int r; + + r = rand(); + return r%top; +} // RandU() + +// JFL 23 Aug 05 +float RandFOne(void) +{ + float r = rand(); // 0..RAND_MAX +// r*=1.0/32767.0; + r*=1.0/(float)(RAND_MAX); + return r; +} // RandFOne() + +// JFL 23 Aug 05 +float RandFRange(float low,float high) +{ + float t=RandFOne(); + t*=(high-low); + t+=low; + return t; +} // RandFRange() + +// EOF diff --git a/dond/core/vec.h b/dond/core/vec.h new file mode 100755 index 0000000..edd7df6 --- /dev/null +++ b/dond/core/vec.h @@ -0,0 +1,327 @@ +#ifndef VEC_H +#define VEC_H +// vec.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 18 Oct 04 + + +#define BOX_REL_W 640 +#define BOX_REL_H 480 + +#define BOX_ABS_W 640 +#define BOX_ABS_H 480 + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef struct { crd a[Q_SIZE]; } QuatType; +typedef struct { crd a[V3_SIZE]; } V3Type; +typedef struct { crd a[M3_SIZE]; } M3Type; +typedef struct { float a[M3_SIZE]; } M3Typef; +typedef struct { crd a[M4_SIZE]; } M4Type; +typedef struct { crd a[VM_SIZE]; } VMType; + +// +// V3 +// + +#define V3Zero(a) \ + (a)[V3_X]=(a)[V3_Y]=(a)[V3_Z]=0 + +#define V3SetXYZ(a,x,y,z) \ + (a)[V3_X]=x,(a)[V3_Y]=y,(a)[V3_Z]=z + +#define V3SetVM(a,b) \ + (a)[V3_X]=(b)[VM_X],(a)[V3_Y]=(b)[VM_Y],(a)[V3_Z]=(b)[VM_Z] + +#define V3SetM4(a,b) \ + (a)[V3_X]=(b)[M4_X],(a)[V3_Y]=(b)[M4_Y],(a)[V3_Z]=(b)[M4_Z] + +#define V3AddV3(a,b) \ + (a)[V3_X]+=(b)[V3_X],(a)[V3_Y]+=(b)[V3_Y],(a)[V3_Z]+=(b)[V3_Z] + +#define V3Cpy(a,b) \ + *((V3Type*)a)=*((V3Type*)b) + +#define V3Add(dst,a,b) \ + (dst)[V3_X]=(a)[V3_X]+(b)[V3_X], \ + (dst)[V3_Y]=(a)[V3_Y]+(b)[V3_Y], \ + (dst)[V3_Z]=(a)[V3_Z]+(b)[V3_Z] + +#define V3Sub(dst,a,b) \ + (dst)[V3_X]=(a)[V3_X]-(b)[V3_X], \ + (dst)[V3_Y]=(a)[V3_Y]-(b)[V3_Y], \ + (dst)[V3_Z]=(a)[V3_Z]-(b)[V3_Z] + +#define V3MulM3(r,v,mat) \ + (r)[0]=(v)[0]*(mat)[M3_11]+(v)[1]*(mat)[M3_12]+(v)[2]*(mat)[M3_13],\ + (r)[1]=(v)[0]*(mat)[M3_21]+(v)[1]*(mat)[M3_22]+(v)[2]*(mat)[M3_23],\ + (r)[2]=(v)[0]*(mat)[M3_31]+(v)[1]*(mat)[M3_32]+(v)[2]*(mat)[M3_33] + +#define V3RotM3 V3MulM3 + +#define V3MulVM(r,v,vm) \ + (r)[0]=(v)[0]*(vm)[VM_11]+(v)[1]*(vm)[VM_12]+(v)[2]*(vm)[VM_13]+(vm)[VM_X],\ + (r)[1]=(v)[0]*(vm)[VM_21]+(v)[1]*(vm)[VM_22]+(v)[2]*(vm)[VM_23]+(vm)[VM_Y],\ + (r)[2]=(v)[0]*(vm)[VM_31]+(v)[1]*(vm)[VM_32]+(v)[2]*(vm)[VM_33]+(vm)[VM_Z] + +#define V3RotVM(r,v,vm) \ + (r)[0]=(v)[0]*(vm)[VM_11]+(v)[1]*(vm)[VM_12]+(v)[2]*(vm)[VM_13],\ + (r)[1]=(v)[0]*(vm)[VM_21]+(v)[1]*(vm)[VM_22]+(v)[2]*(vm)[VM_23],\ + (r)[2]=(v)[0]*(vm)[VM_31]+(v)[1]*(vm)[VM_32]+(v)[2]*(vm)[VM_33] + +#define V3MulM4(r,v,mat) \ + (r)[0]=(v)[0]*(mat)[M4_11]+(v)[1]*(mat)[M4_12]+(v)[2]*(mat)[M4_13]+(mat)[M4_14],\ + (r)[1]=(v)[0]*(mat)[M4_21]+(v)[1]*(mat)[M4_22]+(v)[2]*(mat)[M4_23]+(mat)[M4_24],\ + (r)[2]=(v)[0]*(mat)[M4_31]+(v)[1]*(mat)[M4_32]+(v)[2]*(mat)[M4_33]+(mat)[M4_34] + +#define V3RotM4(r,v,mat) \ + (r)[0]=(v)[0]*(mat)[M4_11]+(v)[1]*(mat)[M4_12]+(v)[2]*(mat)[M4_13],\ + (r)[1]=(v)[0]*(mat)[M4_21]+(v)[1]*(mat)[M4_22]+(v)[2]*(mat)[M4_23],\ + (r)[2]=(v)[0]*(mat)[M4_31]+(v)[1]*(mat)[M4_32]+(v)[2]*(mat)[M4_33] + +#define V3Cross(r,p,q) \ + (r)[0] = (p)[1]*(q)[2] - (p)[2]*(q)[1],\ + (r)[1] = (p)[2]*(q)[0] - (p)[0]*(q)[2],\ + (r)[2] = (p)[0]*(q)[1] - (p)[1]*(q)[0] + +#define V3Dot(p,q) \ + (((p)[0])*((q)[0])+((p)[1])*((q)[1])+((p)[2])*((q)[2])) + +#define V3DotXZ(p,q) \ + (((p)[0])*((q)[0])+((p)[2])*((q)[2])) + +extern crd V3Normalize(crd* v); +extern crd V3Unitize(crd* v,crd len); +extern crd V3Len(crd* v); +extern int V3NormalCW(crd *normal,crd *v0,crd *v1,crd *v2); +extern crd V3DistFast(crd *v0,crd *v1); +extern crd V3UnitizeFast(crd* v,crd len); + +// +// M3 +// + +#define M3Cpy(a,b) \ + *((M3Type*)(a))=*((M3Type*)(b)) +#define M3Cpyf(a,b) \ + *((M3Typef*)(a))=*((M3Typef*)(b)) + +#define M3Id(a) \ + (a)[M3_11]=(a)[M3_22]=(a)[M3_33]=1, \ + (a)[M3_12]=(a)[M3_13]=(a)[M3_21]= \ + (a)[M3_23]=(a)[M3_31]=(a)[M3_32]=0 + +#define M3BuildScaleXYZ(a,x,y,z) \ + (a)[M3_11]=(x),(a)[M3_22]=(y),(a)[M3_33]=(z), \ + (a)[M3_12]=(a)[M3_13]=(a)[M3_21]= \ + (a)[M3_23]=(a)[M3_31]=(a)[M3_32]=0 + +#define M3SetM4(a,b) \ + (a)[M3_11]=(b)[M4_11],(a)[M3_12]=(b)[M4_12],(a)[M3_13]=(b)[M4_13], \ + (a)[M3_21]=(b)[M4_21],(a)[M3_22]=(b)[M4_22],(a)[M3_23]=(b)[M4_23], \ + (a)[M3_31]=(b)[M4_31],(a)[M3_32]=(b)[M4_32],(a)[M3_33]=(b)[M4_33] + +#define M3VecMul(r,mat,v) \ + (r)[0]=(v)[0]*(mat)[M3_11]+(v)[1]*(mat)[M3_12]+(v)[2]*(mat)[M3_13],\ + (r)[1]=(v)[0]*(mat)[M3_21]+(v)[1]*(mat)[M3_22]+(v)[2]*(mat)[M3_23],\ + (r)[2]=(v)[0]*(mat)[M3_31]+(v)[1]*(mat)[M3_32]+(v)[2]*(mat)[M3_33] + +#define M3Mpy M3Mul + +extern void M3FromQuat(crd *m,crd *q); +extern void M3Mul(crd *dst,crd *a,crd *b); +extern void M3ToQuat(crd* mat, crd* q); +extern int M3Inv(crd *dst,crd *src); +extern void M3BuildRot(crd *a,crd rad,int xyz); +extern void M3BuildObj(crd *dstm,crd *rots); + +// +// M4 +// + +#define M4Cpy(a,b) \ + *((M4Type*)a)=*((M4Type*)b) + +#define M4Id(a) \ + (a)[M4_11]=(a)[M4_22]=(a)[M4_33]=(a)[M4_44]=1,\ + (a)[M4_12]=(a)[M4_13]=(a)[M4_14]=(a)[M4_21]=\ + (a)[M4_23]=(a)[M4_24]=(a)[M4_31]=(a)[M4_32]=\ + (a)[M4_34]=(a)[M4_41]=(a)[M4_42]=(a)[M4_43]=0 + +#define M4ClrVec(a) \ + (a)[M4_44]=1,(a)[M4_X]=(a)[M4_Y]=(a)[M4_Z]=0 + +#define M4ClrCol(a) \ + (a)[M4_41]=(a)[M4_42]=(a)[M4_43]=0 + +#define M4SetV3(a,b) \ + (a)[M4_X]=(b)[V3_X],(a)[M4_Y]=(b)[V3_Y],(a)[M4_Z]=(b)[V3_Z] + +#define M4AddV3(a,b) \ + (a)[M4_X]+=(b)[V3_X],(a)[M4_Y]+=(b)[V3_Y],(a)[M4_Z]+=(b)[V3_Z] + +#define M4SetXYZ(a,x,y,z) \ + (a)[M4_X]=x,(a)[M4_Y]=y,(a)[M4_Z]=z + +#define M4AddXYZ(a,x,y,z) \ + (a)[M4_X]+=x,(a)[M4_Y]+=y,(a)[M4_Z]+=z + +#define M4SetM3(a,b) \ + (a)[M4_11]=(b)[M3_11],(a)[M4_12]=(b)[M3_12],(a)[M4_13]=(b)[M3_13], \ + (a)[M4_21]=(b)[M3_21],(a)[M4_22]=(b)[M3_22],(a)[M4_23]=(b)[M3_23], \ + (a)[M4_31]=(b)[M3_31],(a)[M4_32]=(b)[M3_32],(a)[M4_33]=(b)[M3_33] + +#define M4Set3x3(a,r1,r2,r3,s1,s2,s3,t1,t2,t3) \ + (a)[M4_11]=r1,(a)[M4_12]=r2,(a)[M4_13]=r3, \ + (a)[M4_21]=s1,(a)[M4_22]=s2,(a)[M4_23]=s3, \ + (a)[M4_31]=t1,(a)[M4_32]=t2,(a)[M4_33]=t3 + +#define M4SetVM(a,b) \ + (a)[M4_11]=(b)[VM_11],(a)[M4_12]=(b)[VM_12],(a)[M4_13]=(b)[VM_13], \ + (a)[M4_21]=(b)[VM_21],(a)[M4_22]=(b)[VM_22],(a)[M4_23]=(b)[VM_23], \ + (a)[M4_31]=(b)[VM_31],(a)[M4_32]=(b)[VM_32],(a)[M4_33]=(b)[VM_33], \ + (a)[M4_X]=(b)[VM_X],(a)[M4_Y]=(b)[VM_Y],(a)[M4_Z]=(b)[VM_Z], \ + (a)[M4_41]=(a)[M4_42]=(a)[M4_43]=0,(a)[M4_44]=1 + +#define M4SetM4(a,b) \ + (a)[M4_11]=(b)[M4_11],(a)[M4_12]=(b)[M4_12],(a)[M4_13]=(b)[M4_13], \ + (a)[M4_21]=(b)[M4_21],(a)[M4_22]=(b)[M4_22],(a)[M4_23]=(b)[M4_23], \ + (a)[M4_31]=(b)[M4_31],(a)[M4_32]=(b)[M4_32],(a)[M4_33]=(b)[M4_33], \ + (a)[M4_X]=(b)[M4_X],(a)[M4_Y]=(b)[M4_Y],(a)[M4_Z]=(b)[M4_Z], \ + (a)[M4_41]=(a)[M4_42]=(a)[M4_43]=0,(a)[M4_44]=1 + +#define M4VecMpy(r,v,mat) \ + (r)[0]=(v)[0]*(mat)[M4_11]+(v)[1]*(mat)[M4_12]+(v)[2]*(mat)[M4_13]+(mat)[M4_14],\ + (r)[1]=(v)[0]*(mat)[M4_21]+(v)[1]*(mat)[M4_22]+(v)[2]*(mat)[M4_23]+(mat)[M4_24],\ + (r)[2]=(v)[0]*(mat)[M4_31]+(v)[1]*(mat)[M4_32]+(v)[2]*(mat)[M4_33]+(mat)[M4_34] + +#define VMSetM4OGL(a,b) \ + (a)[VM_11]=(b)[M4OGL_11],(a)[VM_12]=(b)[M4OGL_12],(a)[VM_13]=(b)[M4OGL_13], \ + (a)[VM_21]=(b)[M4OGL_21],(a)[VM_22]=(b)[M4OGL_22],(a)[VM_23]=(b)[M4OGL_23], \ + (a)[VM_31]=(b)[M4OGL_31],(a)[VM_32]=(b)[M4OGL_32],(a)[VM_33]=(b)[M4OGL_33], \ + (a)[VM_X]=(b)[M4OGL_X],(a)[VM_Y]=(b)[M4OGL_Y],(a)[VM_Z]=(b)[M4OGL_Z] + +#define M4OGLSetVM(a,b) \ + (a)[M4OGL_11]=(b)[VM_11],(a)[M4OGL_12]=(b)[VM_12],(a)[M4OGL_13]=(b)[VM_13], \ + (a)[M4OGL_21]=(b)[VM_21],(a)[M4OGL_22]=(b)[VM_22],(a)[M4OGL_23]=(b)[VM_23], \ + (a)[M4OGL_31]=(b)[VM_31],(a)[M4OGL_32]=(b)[VM_32],(a)[M4OGL_33]=(b)[VM_33], \ + (a)[M4OGL_X]=(b)[VM_X],(a)[M4OGL_Y]=(b)[VM_Y],(a)[M4OGL_Z]=(b)[VM_Z], \ + (a)[M4OGL_41]=(a)[M4OGL_42]=(a)[M4OGL_43]=0,(a)[M4OGL_44]=1 + +extern void M4Mul(crd *dst,crd *a,crd *b); +extern int M4InvGeneral(crd *inv,crd *mat); + +// +// VM +// + +#define VMCpy(a,b) \ + *((VMType*)a)=*((VMType*)b) + +#define VMId(a) \ + (a)[VM_11]=(a)[VM_22]=(a)[VM_33]=1, \ + (a)[VM_12]=(a)[VM_13]=(a)[VM_21]= \ + (a)[VM_23]=(a)[VM_31]=(a)[VM_32]=0, \ + (a)[VM_X]=(a)[VM_Y]=(a)[VM_Z]=0 + +#define VMVecMul(r,v,vm) \ + (r)[0]=(v)[0]*(vm)[VM_11]+(v)[1]*(vm)[VM_12]+(v)[2]*(vm)[VM_13]+(vm)[VM_X],\ + (r)[1]=(v)[0]*(vm)[VM_21]+(v)[1]*(vm)[VM_22]+(v)[2]*(vm)[VM_23]+(vm)[VM_Y],\ + (r)[2]=(v)[0]*(vm)[VM_31]+(v)[1]*(vm)[VM_32]+(v)[2]*(vm)[VM_33]+(vm)[VM_Z] + +#define VMVecRot(r,v,vm) \ + (r)[0]=(v)[0]*(vm)[VM_11]+(v)[1]*(vm)[VM_12]+(v)[2]*(vm)[VM_13],\ + (r)[1]=(v)[0]*(vm)[VM_21]+(v)[1]*(vm)[VM_22]+(v)[2]*(vm)[VM_23],\ + (r)[2]=(v)[0]*(vm)[VM_31]+(v)[1]*(vm)[VM_32]+(v)[2]*(vm)[VM_33] + +#define VMSetM4(a,b) \ + (a)[VM_11]=(b)[M4_11],(a)[VM_12]=(b)[M4_12],(a)[VM_13]=(b)[M4_13], \ + (a)[VM_21]=(b)[M4_21],(a)[VM_22]=(b)[M4_22],(a)[VM_23]=(b)[M4_23], \ + (a)[VM_31]=(b)[M4_31],(a)[VM_32]=(b)[M4_32],(a)[VM_33]=(b)[M4_33], \ + (a)[VM_X]=(b)[M4_X],(a)[VM_Y]=(b)[M4_Y],(a)[VM_Z]=(b)[M4_Z] + +#define VMSetXYZ(a,x,y,z) \ + (a)[VM_X]=(x),(a)[VM_Y]=(y),(a)[VM_Z]=(z) + +#define VMAddXYZ(a,x,y,z) \ + (a)[VM_X]+=x,(a)[VM_Y]+=y,(a)[VM_Z]+=z + +#define VMSetV3(a,b) \ + (a)[VM_X]=(b)[V3_X],(a)[VM_Y]=(b)[V3_Y],(a)[VM_Z]=(b)[V3_Z] + +#define VMAddV3(a,b) \ + (a)[VM_X]+=(b)[V3_X],(a)[VM_Y]+=(b)[V3_Y],(a)[VM_Z]+=(b)[V3_Z] + +#define VMSubV3(a,b) \ + (a)[VM_X]-=(b)[V3_X],(a)[VM_Y]-=(b)[V3_Y],(a)[VM_Z]-=(b)[V3_Z] + +#define VMBuildRot(a,rad,xyz) \ + (a)[VM_X]=(a)[VM_Y]=(a)[VM_Z]=0,M3BuildRot(&((crd*)(a))[3],rad,xyz) + +#define VMMul VMMpy + +extern void VMInv(crd *dst,crd *a); +extern void VMMpy(crd *dst,crd *a,crd *b); +extern void VMCat(crd *dst,crd *a,crd *b); +extern void VMMlt(crd *dst,crd *cur,crd *add); +extern void VMClean(crd *dst); +extern void VMBuildObj(crd *dst,crd *rots,crd *trans,crd *scale); + +// +// QUAT +// + +#define QuatId(a) \ + (a)[Q_X]=(a)[Q_Y]=(a)[Q_Z]=0,(a)[Q_W]=1 + +#define QuatCpy(a,b) \ + *((QuatType*)a)=*((QuatType*)b) + +extern void QuatToM3(crd* q, crd* mat); +extern void QuatNormalize(crd *q); +extern void QuatMul(crd *d,crd *a,crd *b); +extern void QuatAxisToAxis(crd *qdst,crd *a,crd *b); + +// +// BOX +// + +#define BOXSetXY(a,x,y) \ + (a)[BOX_X]=x,(a)[BOX_Y]=y + +#define BOXRelXY(a,x,y) \ + (a)[BOX_X]=(x*BOX_REL_W/BOX_ABS_W),(a)[BOX_Y]=y*BOX_REL_H/BOX_ABS_H + +#define BOXSetWH(a,w,h) \ + (a)[BOX_W]=w,(a)[BOX_H]=h + +// +// OTHER +// + +extern float MathBlendRot(float rot0,float rot1,float blend0,float blend1); +extern float MathSqrt(float a); +extern float MathFastSqrt(float a); +extern double MathCosSind(double a,double *sinp); +extern crd MathCosSin(crd a,crd *sinp); +extern int MathPDUToCamM4(crd *m4,crd *pos,crd *dir,crd *up); +extern int MathCamToPDUM4(crd *m4,crd *pos,crd *dir,crd *up); +extern void MathQSort(void *pbase,int total_elems,int size, + int (*cmp)(void*,void*)); +extern void MathNrmToRot(crd *nrm,crd *rot); +extern void MathM3ToRot(crd *m3,crd *rot); +extern void MathM3ToScale(crd *m,crd *scale); +extern void MathM3Unscale(crd *m,crd *scale); +extern crd MathACos(crd a); +extern crd MathASin(crd a); +extern crd MathATan(crd a); +extern crd MathTan(crd a); + +extern void RandUSeed(uns seed); +extern uns RandU(uns top); +extern float RandFOne(void); +extern float RandFRange(float low,float high); + +#endif // ndef VEC_H diff --git a/dond/core/vid.h b/dond/core/vid.h new file mode 100755 index 0000000..3a75d04 --- /dev/null +++ b/dond/core/vid.h @@ -0,0 +1,193 @@ +#ifndef VID_H +#define VID_H +// vid.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +//----------------------------------------------------------------------------- +// SYS_JP5500 +#if SYS_JP5500 + +enum +{ + VID_FOG_TABLE_LINEAR, + VID_FOG_TABLE_EXP, + VID_FOG_TABLE_EXP2, +}; + +typedef struct +{ + uns16 screenW; + uns16 screenH; + uns16 centerX; + uns16 centerY; + uns32 flags; +} VidDispInfo; + +extern void VidGenerateAndLoadFogTable(int type, float val1, float val2,float min,float max); +extern void VidSysVBLRender(void); +extern void VidSysRenderInterrupt(void); + +#define VidIsPlayingMovie() (VidMovieState>1) +extern void VidMovieFrame(void *vid); +extern int VidMovieState; + +#endif // SYS_JP5500 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// SYS_PC|SYS_BB +#if SYS_PC|SYS_BB + +#define M_VIDDISP_DBGDISP_NODISP3B 0x01 +#define M_VIDDISP_DBGDISP_NODISP3 0x02 +#define M_VIDDISP_DBGDISP_FRUST 0x04 +#define M_VIDDISP_DBGDISP_FRUST2 0x08 +#define M_VIDDISP_DBGDISP_DONTCULL 0x10 +#define M_VIDDISP_DBGDISP_NODISP2 0x20 +#define M_VIDDISP_DBGDISP_TEX2X2 0x40 +#define M_VIDDISP_DBGDISP_LOD 0x80 + +#define M_VIDDISP_DBGCOL_WIRE 0x01 +#define M_VIDDISP_DBGCOL_SKELCOL 0x02 +#define M_VIDDISP_DBGCOL_FULL 0x04 +#define M_VIDDISP_DBGCOL_GNDBOXES 0x08 + +#define M_VIDDISP_DBGBENCH_TIMERS 0x01 +#define M_VIDDISP_DBGBENCH_DRAWSTATISTICS 0x02 +#define M_VIDDISP_DBGBENCH_APIINFO 0x04 +#define M_VIDDISP_DBGBENCH_LOGTIMERS 0x08 + +typedef struct +{ + // must be supported by all implementations + uns16 screenW; + uns16 screenH; + uns16 centerX; + uns16 centerY; + uns32 flags; + + int fogMode; + float fogDensity; + float fogNear; + float fogFar; + float fogRGBA[4]; + float mipMin; + float mipMax; + float anisotropic; + uns8 shadowRGBA[4]; // always used for color + float shadowDist; // always used for dist + float shadowPos[3]; // only if M_VIDDISP_GSHADOW (else use light + int maxLights; + int maxTexWidthHeight; + int texAllocs; + int texMem; + + float gridSize; + int gridDim; + uns8 dbgcol; + uns8 dbgshad; + uns8 dbgdisp; + uns8 dbgbench; + int8 dontFlip; + uns8 showCursor; + uns8 bSupportVBO; + uns8 bSoftwareVSync; //limited software VSync support available + uns32 bHardwareVSync; //hardware is handling VSync + int vSyncStart; + uns32 normalFrames; + uns32 droppedFrames; + uns32 vsyncTimeouts; + uns64 VSyncTimerStart; //micro second time stamp since last known vsync + + char dbgbb[4][256]; + uns64 dbgTime0; + uns64 dbgTime1; + uns64 dbgTime2; + uns dbg2x2; + char *apiVendor; + char *apiVersion; + char *apiRenderer; + char *apiExtensions; + uns32 minTri; //less than, do not draw + uns32 minQuad; //less than, do not draw + char findResName[64]; //use to BP on a given display resource + int32 objDListCount; //count of current object display lists +} VidDispInfo; + +#define VID_MAXLIGHTS 8 + +// OpenGL doesn't seem to have these.. +// http://www.opengl.org/documentation/specs/version1.2/1.2specs/texture_lod.txt +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + +enum { + VIDDRAW_NONE, + VIDDRAW_JOINT, + VIDDRAW_AXIS, + VIDDRAW_GRID, + VIDDRAW_NUB, + VIDDRAW_SPHERE, + VIDDRAW_001, + VIDDRAW_PROJECTILE, +}; + +extern void xVidDraw(uns shape,float scale); // in res_pc.c + +#endif // SYS_PC|SYS_BB +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +extern int VidInit(void); +extern void VidFinal(void); +extern int VidReset(uns reset); + +#define M_VIDDISP_MINFILTER 0x00000001 +#define M_VIDDISP_MAGFILTER 0x00000002 +#define M_VIDDISP_WIREFRAME 0x00000004 +#define M_VIDDISP_MIPMAP 0x00000008 +#define M_VIDDISP_BACKFACE 0x00000010 +#define M_VIDDISP_QUALITY 0x00000020 +#define M_VIDDISP_BLEND 0x00000040 +#define M_VIDDISP_ONEPASSBLEND 0x00000080 +#define M_VIDDISP_FOG 0x00000100 +#define M_VIDDISP_FOG_C 0x00000200 +#define M_VIDDISP_GRID 0x00000400 +#define M_VIDDISP_JOINTS 0x00000800 +#define M_VIDDISP_NUBS 0x00001000 +#define M_VIDDISP_LIGHTS 0x00002000 +#define M_VIDDISP_CPFAILURE 0x00004000 +#define M_VIDDISP_DONTFLIP 0x00010000 +#define M_VIDDISP_SHADOWS 0x00020000 +#define M_VIDDISP_PROCHECK 0x00040000 // PRODUCTION +#define M_VIDDISP_PROFAIL 0x00100000 // PRODUCTION +#define M_VIDDISP_GSHADOW 0x00200000 // use VidDisp.shadow (global shadow) +#define M_VIDDISP_GSHADOW_DIR 0x00400000 // directional shadow (else positional) +#define M_VIDDISP_SYNC_VBLANK 0x00800000 // sync to vblank when set + +extern VidDispInfo VidDisp; + +extern int VidStart(void); + +extern void* VidFrameStart(void); +extern void VidFrameEnd(void *vid); +extern void VidDrawSetRenderDest(void *vid,uns32 flags); + +extern void VidGrabViewingMatrices(void); +extern int VidWorldPos(crd *screenxyz,crd *pos); +extern int VidScreenPos(crd *worldxyz,crd *pos); + +extern int VidMovieInit(void); +extern void VidMovieFinal(void); +extern int VidMovieReset(void); + +#endif // ndef VID_H diff --git a/dond/core/wnd.h b/dond/core/wnd.h new file mode 100755 index 0000000..a4d7e9b --- /dev/null +++ b/dond/core/wnd.h @@ -0,0 +1,65 @@ +#ifndef WND_H +#define WND_H +// wnd.h +// Copyright 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 11 Oct 04 + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM DEPENDENT + +//----------------------------------------------------------------------------- +// SYS_PC +#if SYS_PC + +#ifndef _WINDOWS_ +#include +#endif + +typedef struct { + HINSTANCE hinst; + HWND hwnd; + HDC hdc; + HGLRC hrc; + uns8 ready; + uns8 quit; + uns8 fullScreen; + int w,h; +} WndRec; + +extern int WndOpen(memu hinst,uns w,uns h,uns flags); +extern void WndClose(void); + +#endif // SYS_PC +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// SYS_BB +#if SYS_BB + +typedef struct { + void *priv; + uns8 ready; + uns8 quit; + uns8 fullScreen; + int w,h; +} WndRec; + +extern int WndOpen(uns w,uns h,uns flags); +extern void WndClose(void); + +#endif // SYS_BB +//----------------------------------------------------------------------------- + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INDEPENDENT + +extern int WndInit(void); +extern void WndFinal(void); +extern int WndReset(uns reset); +extern int WndLoop(void); +extern int WndInpLoop(void); +extern void* WndCur(void); +extern void WndSwap(WndRec *wnd); + +#endif // ndef WND_H diff --git a/dond/corebb/int_bb.c b/dond/corebb/int_bb.c new file mode 100755 index 0000000..a5379db --- /dev/null +++ b/dond/corebb/int_bb.c @@ -0,0 +1,175 @@ +#if SYS_BB +// int_bb.c +// Play Mechanix - Video Game System +// Copyright (c) 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// GNP 01 Sep 00 +// JFL 26 Aug 04 +// JFL 07 Oct 04 + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "int.h" + +enum { + INT_DEVICE_SW0, + INT_DEVICE_SW1, + INT_DEVICE_IP2, + INT_DEVICE_IP3, + INT_DEVICE_IP4, + INT_DEVICE_IP5, + INT_DEVICE_IP6, + INT_DEVICE_TIMER, + INT_DEVICE_RTC, + INT_DEVICE_IDE1, // first FPGA + INT_DEVICE_IDE2, + INT_DEVICE_SERIAL0, + INT_DEVICE_ETHERNET, + INT_DEVICE_RENDER, + INT_DEVICE_SOUNDDMA, + INT_DEVICE_DISPLAY, + INT_DEVICE_SERIAL1, + INT_DEVICE_GUN0, + INT_DEVICE_GUN1, + INT_DEVICE_COUNT +}; + +typedef struct { + int enabled; +} IntDeviceRec; + +IntDeviceRec intDevices[INT_DEVICE_COUNT]; + +// +// IntInit +// one time initialization at power-up +// +// in: +// out: +// global: +// +// GNP 01 Sep 00 +// JFL 07 Oct 04 +// +int IntInit(void) +{ + // + // RESET VARS + // + + MEMZ(intDevices); + + return 0; +} // IntInit + +// +// IntReset +// called every time system is reset +// +// in: +// out: +// global: +// +// GNP 01 Sep 00 +// JFL 07 Oct 04 +// +int IntReset(uns reset) +{ + return 0; +} // IntReset + +// +// IntFinal +// called once upon system shutdown +// +// in: +// out: +// global: +// +// GNP 01 Sep 00 +// +void IntFinal(void) +{ +} // IntFinal + +// JFL 31 Aug 04 +int intDeviceEnable(int dev,int enable) +{ + int ec; + + if(dev>=INT_DEVICE_COUNT) + { + BP(BP_INTDEVICEENABLE); + return -1; + } + + intDevices[dev].enabled=enable; + + switch(dev) + { + case INT_DEVICE_SW0: + case INT_DEVICE_SW1: + case INT_DEVICE_IP2: + case INT_DEVICE_IP3: + case INT_DEVICE_IP4: + case INT_DEVICE_IP5: + case INT_DEVICE_IP6: + case INT_DEVICE_TIMER: + case INT_DEVICE_IDE1: + case INT_DEVICE_IDE2: + case INT_DEVICE_SERIAL0: + case INT_DEVICE_SERIAL1: + case INT_DEVICE_RTC: + case INT_DEVICE_ETHERNET: + case INT_DEVICE_SOUNDDMA: + case INT_DEVICE_RENDER: + case INT_DEVICE_DISPLAY: + case INT_DEVICE_GUN0: + case INT_DEVICE_GUN1: + BP(BP_INTDEVICEENABLE2); + err(-2); + } // switch + + ec=0; +BAIL: + if(ec<0) + BP(BP_INTDEVICEENABLE3); + return ec; +} // intDeviceEnable() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 31 Aug 04 +int IntAttach(void) +{ + // + // INSTALL LOW LEVEL EXCEPTION HANDLERS + // + + return 0; +} // IntAttach() + +// JFL 31 Aug 04 +void IntDetach(void) +{ + BP(BP_INTDETACH); // unlink our node..?? +} // IntDetach() + +// +// IntEnable +// +// in: +// out: +// global: +// +// GNP 24 Mar 03 +// JFL 31 Aug 04 +void IntEnable(uns intMask,int enable) +{ + +} // IntEnable() + +#endif // SYS_BB +//EOF diff --git a/dond/corebb/main_bb.c b/dond/corebb/main_bb.c new file mode 100755 index 0000000..9b1abfc --- /dev/null +++ b/dond/corebb/main_bb.c @@ -0,0 +1,455 @@ +#if SYS_BB +// main_bb.c +// Play Mechanix - Video Game System +// Copyright 1998-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 26 Aug 04 +// JFL 07 Oct 04 +// JFL 21 Jan 05; linux black box version started + +// #include +// WIN32,_DEBUG,_WINDOWS,_MBCS,SYS_BB +// user32.lib gdi32.lib comdlg32.lib shell32.lib uuid.lib opengl32.lib core.lib + +// freeglut demo: _DEBUG,WIN32,_CONSOLE,_MBCS,FREEGLUT_STATIC +#include + +#include "pm.h" +#include "sys.h" +#include "int.h" +#include "mem.h" +#include "fb.h" +#include "fs.h" +#include "vid.h" +#include "net.h" +#include "res.h" +#include "obj.h" +#include "font.h" +#include "inp.h" +#include "cab.h" +#include "gun.h" +#include "game.h" +#include "str.h" +#include "proc.h" +#include "wnd.h" +#include "snd.h" + +#include // also need rt lib +#include +#include + +// strings for time and date stamp of build +#define BUILD_TIME __TIME__ +#define BUILD_DATE __DATE__ + +// to create a soft link: ln -s ~/donddata data +#define SCRIPT_START "set(str1 atstart) run(perm)" +#define PATH_START "donddata/hd_pc;donddata/cf;donddata/snd" +#define AUDIT_PATH "/donduser/aud" +#define ADJUST_PATH "/donduser/adj" +#define CF_PATH "donddata/cf" +#define PLR_PATH "/donduser/players" +#define TRN_PATH "/donduser/tourneys" +#define LBD_PATH "/donduser/lboards" +#define SND_PATH "donddata/snd" +#define LOG_PATH "/donduser/log/" + +void* jps_memdebug_ptr[2048]; +uns jps_memdebug_size[2048]; + +int MainRestartArgc=0; +char *MainRestartArgv[MAIN_RESTART_ARGC_MAX]; + +// JFL 26 Aug 04 +// JFL 07 Oct 04 +// JFL 21 Jan 05 +int main(int argc0,char **argv0) +{ + int ec; + char *s1,*s2; + uns wndopenflags; + int argc; + char **argv; + SysDate dt; + int swidth, sheight, sresType; + + argc=argc0; + argv=argv0; +restart: + wndopenflags=1; // default to full screen + + // + // GUARANTEED INITS + // + + SysWatchdogDisable(); + + // + // INIT ALL SYSTEMS + // + + for(ec=0;ec +#include +#include +#include +#include +#include +#include +#include + +#include "pm.h" +#include "str.h" +#include "sys.h" +#include "mem.h" +#include "aud.h" +#include "obj.h" +#include "game.h" + +uns64 sysTimeBase; +float sysPTimerResolution; // Performance timer millions of ticks per second + +char sigBuf[256]; // buffer for building signal log strings + +// forward +uns64 xSysMilliSec(void); +float xSysGetPTimerResolution(void); + +// +// fSignalHandler +// handle fatal signal trap +// +void fSignalHandler (int sigNo, void *p) +{ + struct sigcontext *context = (struct sigcontext *) &p; + char *s1; + + AudException(); + + switch(sigNo) + { + case SIGABRT: + s1 = "SIGABRT"; + break; + case SIGSEGV: + s1 = "SIGSEGV"; + break; + case SIGBUS: + s1 = "SIGBUS"; + break; + case SIGFPE: + s1 = "SIGFPE"; + break; + case SIGQUIT: + s1 = "SIGQUIT"; + break; + case SIGILL: + s1 = "SIGILL"; + break; + case SIGSYS: + s1 = "SIGSYS"; + break; + default: + s1 = ""; + break; + } + + SysLog("********************************\n"); + SysLog(" Received FATAL signal %s (%d)\n", s1,sigNo); + SysLog("********************************\n"); + + sprintf(sigBuf,"gs: %04X fs: %04X es: %04X ds: %04X\n",context->gs, context->fs, context->es, context->ds); + SysLog(sigBuf); + sprintf(sigBuf, "edi: %08X esi: %08X ebp: %04X esp: %04X\n",context->edi, context->esi, context->ebp, context->esp); + SysLog(sigBuf); + sprintf(sigBuf, "ebx: %08X edx: %08X ecx: %08X eax: %08X\n", context->ebx, context->edx, context->ecx, context->eax); + SysLog(sigBuf); + sprintf(sigBuf, "trap: %d err: %d eip: %08X cs: %04X\n",context->trapno, context->err, context->eip, context->cs); + SysLog(sigBuf); + sprintf(sigBuf, "flag: %08X SP: %08X ss: %04X cr2: %08X\n",context->eflags, context->esp_at_signal, context->ss, context->cr2); + SysLog(sigBuf); + + SysLog("Program exiting...\n"); + + // fatal, exit hopefully with no core dump + exit(-1); +} + +// +// fTrapHandler +// handle debug trap +// +void fTrapHandler (int sigNo, void *p) +{ + struct sigcontext *context = (struct sigcontext *) &p; + + AudBadTrap(); + + SysLog("*******************************\n"); + SysLog(" Received TRAP signal SIGTRAP (%d) ***\n", sigNo); + SysLog("*******************************\n"); + + sprintf(sigBuf,"gs: %04X fs: %04X es: %04X ds: %04X\n",context->gs, context->fs, context->es, context->ds); + SysLog(sigBuf); + sprintf(sigBuf, "edi: %08X esi: %08X ebp: %04X esp: %04X\n",context->edi, context->esi, context->ebp, context->esp); + SysLog(sigBuf); + sprintf(sigBuf, "ebx: %08X edx: %08X ecx: %08X eax: %08X\n", context->ebx, context->edx, context->ecx, context->eax); + SysLog(sigBuf); + sprintf(sigBuf, "trap: %d err: %d eip: %08X cs: %04X\n",context->trapno, context->err, context->eip, context->cs); + SysLog(sigBuf); + sprintf(sigBuf, "flag: %08X SP: %08X ss: %04X cr2: %08X\n",context->eflags, context->esp_at_signal, context->ss, context->cr2); + SysLog(sigBuf); + SysLog("Program continuing...\n"); + + // let's try to return + return; +} + +// JFL 07 Oct 04 +int xSysInit(void) +{ + struct sigaction sSegvHdl; + + sysPTimerResolution = xSysGetPTimerResolution(); + +// sysTimeBase=glutGet(GLUT_ELAPSED_TIME); + sysTimeBase=xSysMilliSec(); + + // install signal handlers + + sSegvHdl.sa_flags = SA_ONESHOT; + sSegvHdl.sa_handler = (void(*)(int))fSignalHandler; + sigemptyset (&sSegvHdl.sa_mask); + + // segmentation fault + if (sigaction (SIGSEGV, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGSEGV handler\n"); + + // floating point error + if (sigaction (SIGFPE, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGFPE handler\n"); + + // illegal instruction + if (sigaction (SIGILL, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGILL handler\n"); + + // bus fault + if (sigaction (SIGBUS, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGBUS handler\n"); + + // abort() + if (sigaction (SIGABRT, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGABRT handler\n"); + + // non-existant system call + if (sigaction (SIGSYS, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGSYS handler\n"); + + // quit + if (sigaction (SIGQUIT, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGQUIT handler\n"); + + sSegvHdl.sa_handler = (void(*)(int))fTrapHandler; + + // trap + if (sigaction (SIGTRAP, &sSegvHdl, NULL) != 0) + SysLog("xSysInit(): cannot install SIGTRAP handler\n"); + + return 0; +} // xSysInit() + +// JFL 07 Oct 04 +void xSysFinal(void) +{ +} // xSysFinal() + +// JFL 07 Oct 04 +int xSysReset(uns reset) +{ + return 0; +} // xSysReset() + +// GNP 17 Jun 03 + +void SysWatchdogEnable(void) +{ +} // SysWatchdogEnable() + +// GNP 17 Jun 03 +void SysWatchdogDisable(void) +{ +} // SysWatchdogDisable() + +// GNP 17 Jun 03 +void SysWatchdogBone(void) +{ +} // SysWatchdogBone + +// JFL 07 Oct 04 +void* SysAdr(void) +{ + return NUL; +} // SysAdr() + +// JFL 07 Oct 04 +void SysLockup(int id) +{ +// SysLog("LOCKUP: %x\n",adr); + SysLog("LOCKUP: %d\n",(int)id); + GameSysLog(GAMESYSLOG_STATE); +} // SysLockup() + +// +// SysClockMilliSec +// +// +// in: +// out: +// global: +// +// JFL 08 Nov 04 +// GNP 11 Jan 06; changed to use high resolution proc timer (more accurate) +// +uns64 SysClockMilliSec(void) +{ + uns64 newTime; + + if(SysG.forceFrameTime) + return SysG.loopTime; + else + { + newTime = xSysMilliSec(); + if (newTime < sysTimeBase) + { + newTime = newTime + (uns64)0xffffffffffffffff - sysTimeBase; + } + else + { + newTime = newTime - sysTimeBase; + } +// return glutGet(GLUT_ELAPSED_TIME)-sysTimeBase; + return(newTime); + } +//DONE("SysClockMilliSec") +} // SysClockMilliSec + +// +// xSysMilliSec +// return current system timer in milli-seconds +// +// in: +// out: +// global: +// +// GNP 10 Jan 06 +// +uns64 xSysMilliSec(void) +{ + uns64 retval; + double fTime; + + uns32 time_low, time_high; + + rdtsc(time_low, time_high); + retval = ((uns64)time_high << 32) + (uns64)time_low; + + fTime = (double)retval; + fTime = fTime/(double)(sysPTimerResolution * 1000.0); + retval = (uns64)fTime; + return(retval); +//DONE("xSysMilliSec") +} // xSysMilliSec + +// +// xSysMicroSec +// return current system micro-second counter +// +// in: +// out: +// global: +// +// GNP 12 Oct 05 +// +uns64 xSysMicroSec(void) +{ + uns64 retval; + double fTime; + + uns32 time_low, time_high; + + rdtsc(time_low, time_high); + retval = ((uns64)time_high << 32) + (uns64)time_low; + + fTime = (double)retval; + fTime = fTime/(double)sysPTimerResolution; + retval = (uns64)fTime; + return(retval); +//DONE("xSysMicroSec") +} // xSysMicroSec + +// +// xSysGetPTimerResolution +// get system performance timer resolution +// in millions of ticks per second +float xSysGetPTimerResolution(void) +{ + char path_to_procfile[32]; + char cpuinfo_buffer[256]; + int procfile = 0; + int index; + char *ptr = NULL; + float cpuspeed_inMhz = 0.0f; + + // read cpu speed from /proc/cpuinfo + sprintf(path_to_procfile, "/proc/cpuinfo"); + procfile = open(path_to_procfile, O_RDONLY); + index = read(procfile, cpuinfo_buffer, sizeof(cpuinfo_buffer)-1); + cpuinfo_buffer[index] = '\0'; + close(procfile); + ptr = strstr(cpuinfo_buffer, "MHz"); + ptr = strstr(ptr, ":"); + + // search for first non-whitespace character, or just... + ptr += 2; + + // got the cpuspeed! + sscanf(ptr, "%f", &cpuspeed_inMhz); + return(cpuspeed_inMhz); +} +// JFL 20 Jul 05 +int SysGetHardwareInfo(uns op,char *buf,int bufsize) +{ + int ec; + + ec=0; + return ec; +} // SysGetHardwareInfo() + +/////////////////////////////////////////////////////////////////////////////// +// + +#endif // SYS_BB +// EOF diff --git a/dond/corebb/wnd_bb.c b/dond/corebb/wnd_bb.c new file mode 100755 index 0000000..3907d88 --- /dev/null +++ b/dond/corebb/wnd_bb.c @@ -0,0 +1,882 @@ +#if SYS_BB +// wnd_bb.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04; from ah/fb.c +// JFL 26 Jan 05; Xwindow version + +#include +#include +#include +#include + +//#define GLX_SGIX_fbconfig 1 + +#include + +#include "pm.h" +#include "mem.h" +#include "obj.h" +#include "vec.h" +#include "vid.h" +#include "inp.h" +#include "sys.h" +#include "wnd.h" +#include "font.h" + +extern void GameInputFunction(int numPressed); + +WndRec wndlist; + +typedef struct { + Display *disp; + int scr; + Window rootWin; + int con; + Atom delWin; + Window h; + GLXContext ctxt; + Cursor curs; +} WndX11Rec; + +typedef struct { + int window; +} WndGLRec; + +typedef struct { + uns keyFlags; +} WndPrivates; + +WndX11Rec syswnd; +WndGLRec syswndGL; +WndPrivates wndG; + +// JFL 07 Oct 04 +int WndInit(void) +{ + MEMZ(wndlist); + MEMZ(syswnd); + MEMZ(syswndGL); + MEMZ(wndG); + return 0; +} // WndInit() + +// JFL 07 Oct 04 +void WndFinal(void) +{ +} // WndFinal() + +// JFL 07 Oct 04 +int WndReset(uns reset) +{ + MEMZ(wndG); + return 0; +} // WndReset() + +void* WndCur(void) +{ + return &wndlist; +} // WndCur() + +// JFL 12 Nov 04 +int xInpLowScan(void) +{ + if(wndG.keyFlags) + InpLowEvent(INPLOWEVENT_NOP|wndG.keyFlags,NUL); + return 0; +} // xInpLowScan() + +// +// WaitForVSync +// wait until vsync count is one greater than just after the last swap +// +// in: +// out: +// global: +// +// GNP 11 Jan 06 +// +void WaitForVSync (void) +{ + if (!VidDisp.bHardwareVSync + && VidDisp.bSoftwareVSync && (VidDisp.flags&M_VIDDISP_SYNC_VBLANK)) + { + unsigned int count, newCount; + uns64 sanityTime; + + glXGetVideoSyncSGI(&count); + + // if we have sync'd, just continue, no waiting +// if (count != VidDisp.vSyncStart) +// { +// if(count - VidDisp.vSyncStart < 5) +// VidDisp.droppedFrames += count - VidDisp.vSyncStart; +// VidDisp.vSyncStart=count; +// return; +// } + + sanityTime = SysMilliSec() + 6; // max 1/3 frame wait + + while(sanityTime > SysMilliSec()) + { +// glXGetVideoSyncSGI(&count); + glXGetVideoSyncSGI(&newCount); +// if (count != VidDisp.vSyncStart) + if (count != newCount) + { + VidDisp.VSyncTimerStart = SysMicroSec(); + VidDisp.normalFrames++; + VidDisp.vSyncStart=count; + return; + } + } + VidDisp.vsyncTimeouts++; + } +//DONE("WaitForVSync") +} // WaitForVSync + +void WndSwap(WndRec *wnd) +{ + WaitForVSync(); + // swap the buffers + glutSwapBuffers(); + + // grab starting vsync number +// if (VidDisp.bSoftwareVSync) +// glXGetVideoSyncSGI(&VidDisp.vSyncStart); +} + +// JFL 07 Oct 04 +void wndCloseGL(WndRec *wnd) +{ +} // wndCloseGL + +void renderScene(void) { + glClear(GL_COLOR_BUFFER_BIT); + glBegin(GL_TRIANGLES); + glVertex3f(-0.5,-0.5,0.0); + glVertex3f(0.5,0.0,0.0); + glVertex3f(0.0,0.5,0.0); + glEnd(); + glFlush(); + glutSwapBuffers(); +} + +void reshape(int w, int h) +{ + int err; + int i; + + glViewport(0, 0, w, h); /* Establish viewing area to cover entire window. */ +} + +#if 0 // from Sam +void osmousebtn(int button, int state,int x,int y) +{ + int m; + m = glutGetModifiers(); + if (m & GLUT_ACTIVE_ALT) + osio.alt = 1; + else + osio.alt = 0; + + osio.newdata = 1; + osio.newx = x; + osio.newy = y; + +//GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON +//GLUT_UP or GLUT_DOWN + if (button == GLUT_LEFT_BUTTON) + { + if (state == GLUT_DOWN) + { + osio.left = 1; + } + else + osio.left = 0; + } + + if (button == GLUT_MIDDLE_BUTTON) + { + if (state == GLUT_DOWN) + { + osio.center = 1; + } + else + osio.center = 0; + } + + if (button == GLUT_RIGHT_BUTTON) + { + if (state == GLUT_DOWN) + { + osio.right = 1; + } + else + osio.right = 0; + } + +} + +void osmouse(int x,int y) +{ + int m; + m = glutGetModifiers(); + osio.newdata = 1; + osio.newx = x; + osio.newy = y; +} +#endif + +// +// wndKeys +// all key processing ultimately comes through here +// this function should only be called by key functions registerd with +// GLUT. this function is not meant to be registered. +// only for keys that map to ASCII characters +// +// in: +// key = key code +// x = mouse x pos +// y = mouse y pos +// down = if true, key is down +// out: +// global: +// +// GNP 29 Dec 05 +// +void wndKeys(unsigned char key, int x, int y, int down) +{ + int m; + char keys[32]; + uns32 flags=0; + + m = glutGetModifiers(); + + // check key + if (m & GLUT_ACTIVE_ALT) + { + flags|=M_INPLOWEVENT_ALT; + } + + // check key + if (m & GLUT_ACTIVE_SHIFT) + { + flags|=M_INPLOWEVENT_SHF; + } + + // check key + if (m & GLUT_ACTIVE_CTRL) + { + flags|=M_INPLOWEVENT_CTL; + } + + keys[0]=(char)key; + keys[1]=0; + + switch (key) + { + case 27: //ESC + if (down) + InpLowEvent(INPLOWEVENT_SYS_ESC_DOWN,keys); + else + InpLowEvent(INPLOWEVENT_SYS_ESC_UP,keys); + break; + default: + if (down) + InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN|flags,keys); + else + InpLowEvent(INPLOWEVENT_SYS_KEYS_UP|flags,keys); + break; + } + +//DONE("wndKeys") +} // wndKeys + +// +// wndSpecialKeys +// all special key processing ultimately comes through here +// this function should only be called by key functions registerd with +// GLUT. this function is not meant to be registered. +// only for keys have special mappings (i.e. F1-F12, up, down, etc) +// +// in: +// key = key code +// x = mouse x pos +// y = mouse y pos +// down = if true, key is down +// out: +// global: +// +// GNP 29 Dec 05 +// +void wndSpecialKeys(unsigned char key, int x, int y, int down) +{ + int m; + char keys[32]; + uns32 flags=0; + + m = glutGetModifiers(); + + // check key + if (m & GLUT_ACTIVE_ALT) + { + flags|=M_INPLOWEVENT_ALT; + } + + // check key + if (m & GLUT_ACTIVE_SHIFT) + { + flags|=M_INPLOWEVENT_SHF; + } + + // check key + if (m & GLUT_ACTIVE_CTRL) + { + flags|=M_INPLOWEVENT_CTL; + } + + keys[0]=(char)key; + keys[1]=0; + + switch (key) + { + case GLUT_KEY_LEFT: + if (down) + InpLowEvent(INPLOWEVENT_P0_L_DOWN|flags,NUL); + else + InpLowEvent(INPLOWEVENT_P0_L_UP|flags,NUL); + break; + case GLUT_KEY_RIGHT: + if (down) + InpLowEvent(INPLOWEVENT_P0_R_DOWN|flags,NUL); + else + InpLowEvent(INPLOWEVENT_P0_R_UP|flags,NUL); + break; + case GLUT_KEY_UP: + if (down) + InpLowEvent(INPLOWEVENT_P0_U_DOWN|flags,NUL); + else + InpLowEvent(INPLOWEVENT_P0_U_UP|flags,NUL); + break; + case GLUT_KEY_DOWN: + if (down) + InpLowEvent(INPLOWEVENT_P0_D_DOWN|flags,NUL); + else + InpLowEvent(INPLOWEVENT_P0_D_UP|flags,NUL); + break; + case GLUT_KEY_F1: + case GLUT_KEY_F2: + case GLUT_KEY_F3: + case GLUT_KEY_F4: + case GLUT_KEY_F5: + case GLUT_KEY_F6: + case GLUT_KEY_F7: + case GLUT_KEY_F8: + case GLUT_KEY_F9: + case GLUT_KEY_F10: + case GLUT_KEY_F11: + case GLUT_KEY_F12: + keys[0]=(char)(key-GLUT_KEY_F1+INPKEY_F1); + keys[1]=0; + if (down) + InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN|flags,keys); + else + InpLowEvent(INPLOWEVENT_SYS_KEYS_UP|flags,keys); + break; + default: + ; + break; + } + +//DONE("wndSpecialKeys") +} // wndSpecialKeys + +// +// wndKeysDown +// function to process keyboard presses +// GLUT version +// +// in: +// out: +// global: +// +// GNP 06 Nov 05 +// +void wndKeysDown(unsigned char key,int x,int y) +{ + switch (key) + { + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + GameInputFunction(key - 48); + break; + } + wndKeys(key,x,y,1); +} // wndKeysDown + +// +// wndKeysUp +// function to process keyboard releases +// GLUT function +// +// in: +// out: +// global: +// +// GNP 29 Dec 05 +// +void wndKeysUp(unsigned char key,int x,int y) +{ + switch (key) + { + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + GameInputFunction(-1 * (key - 48)); + break; + } + wndKeys(key,x,y,0); +//DONE("wndKeysUp") +} // wndKeysUp + +// +// wndSpecialKeysDown +// function to process keyboard special presses +// GLUT version +// +// in: +// out: +// global: +// +// GNP 06 Nov 05 +// +void wndSpecialKeysDown(int key,int x,int y) +{ + wndSpecialKeys(key,x,y,1); +//DONE("wndSpecialKeysDown") +} // wndSpecialKeysDown + +// +// wndSpecialKeysUp +// function to process keyboard special releases +// GLUT version +// +// in: +// out: +// global: +// +// GNP 29 Dec 05 +// +void wndSpecialKeysUp(int key,int x,int y) +{ + wndSpecialKeys(key,x,y,0); +//DONE("wndSpecialKeysUp") +} // wndSpecialKeysUp + + +// function to handle mouse clicks +// GTR 10Aug2006 +void wndMouseClick(int button, int state, int x, int y) +{ + int whichButton; // remembers which mouse button + int downUp; // remembers the mouse button state + + switch(button) + { + case GLUT_LEFT_BUTTON: + whichButton = 0; // left + break; + case GLUT_RIGHT_BUTTON: + whichButton = 1; // right + break; + } + + switch(state) + { + case GLUT_DOWN: + downUp = 0; // down + break; + case GLUT_UP: + downUp = 10; // up + break; + } + + switch(whichButton + downUp) + { + case 0: + InpLowEvent(INPLOWEVENT_MOUSE_LB_DOWN, NUL); + break; + case 1: + InpLowEvent(INPLOWEVENT_MOUSE_RB_DOWN, NUL); + break; + case 10: + InpLowEvent(INPLOWEVENT_MOUSE_LB_UP, NUL); + break; + case 11: + InpLowEvent(INPLOWEVENT_MOUSE_RB_UP, NUL); + break; + } +} + + +// function to handle mouse motion +// GTR 10Aug2006 +void wndMouseMotion(int x, int y) +{ + crd buf[4]; + buf[0] = x; + buf[1] = y; + InpLowEvent(INPLOWEVENT_MOUSE_MOVE_XY,buf); +} + +const char *wtitle="PlayMechanix"; + +int InitGLWindow(WndRec *wnd,int x,int y,int w,int h) +{ + int ret = 0; + + int argc=3; + char argv1[64]="dondcontext"; + char argv2[64]="-display"; + char argv3[64]=":0.0"; + char *pargv[] = {argv1, argv2, argv3}; + char modestr[64]; + + //init glut and the OpenGL window + //set the mode to RGBA, with Alpha and depth, double buffered + glutInit(&argc, (char **)&pargv); + glutInitDisplayMode (GLUT_RGBA|GLUT_DOUBLE|GLUT_ALPHA|GLUT_DEPTH|GLUT_STENCIL ); + glutInitWindowSize((int)w, (int)h); + glutInitWindowPosition(x,y); + + if(wnd->fullScreen) + { + // Sam's way of full screening + sprintf(modestr,"%dx%d:32@60",w,h); + glutGameModeString(modestr); + syswndGL.window = glutEnterGameMode(); + // other way +// glutFullScreen(); + + } + else + syswndGL.window = glutCreateWindow(wtitle); + + wnd->w=w; + wnd->h=h; + + // not really necessary + glutSetWindow(syswndGL.window); + + // need this for both Win and Lin + glutSetCursor(GLUT_CURSOR_NONE); + + // no keyboard in production mode +#if !PRODUCTION + // keyboard and mouse input handlers + glutKeyboardFunc(wndKeysDown); + glutKeyboardUpFunc(wndKeysUp); + glutSpecialFunc(wndSpecialKeysDown); + glutSpecialUpFunc(wndSpecialKeysUp); + // Mouse input handlers + if(!VidDisp.showCursor) + { + VidDisp.showCursor=2; // dont-change + glutSetCursor(GLUT_CURSOR_NONE); + } + else if(VidDisp.showCursor==1) + { + VidDisp.showCursor=2; // dont-change + glutSetCursor(GLUT_CURSOR_CROSSHAIR); + glutMouseFunc(wndMouseClick); + glutMotionFunc(wndMouseMotion); + glutPassiveMotionFunc(wndMouseMotion); + } + + + // make GLUT ingnore key repeats + glutIgnoreKeyRepeat(1); +#endif //!PRODUCTION + + glutReshapeFunc(reshape); + + return(0); +} + +// JFL 07 Oct 04 +int WndOpen(uns w,uns h,uns flags) +{ + int ec; + WndRec *wnd=&wndlist; + + if(flags&1) + wnd->fullScreen=1; + else + wnd->fullScreen=0; + + if((ec=InitGLWindow(wnd,0,0,w,h))<0) + goto BAIL; + + wnd->ready=1; + + ec=0; +BAIL: + return ec; +} // WndOpen() + +// JFL 07 Oct 04 +void WndClose(void) +{ + WndRec *wnd=&wndlist; + if(wnd->ready) + wndCloseGL(wnd); + wnd->ready=0; +} // WndClose + +int WndInpLoop(void) +{ + return WndLoop(); +} + +// JFL 07 Oct 04 +int WndLoop(void) +{ + int ec; + WndRec *wnd=&wndlist; +#if 0 + WndX11Rec *wndx; + XEvent event; + int x,y; + KeySym key; + char keys[32]; + uns flags; + + if(!wnd || !(wndx=wnd->priv) || !wnd->ready) + err(1); + + wndx=wnd->priv=&syswnd; + XSync(wndx->disp,0); + while(XEventsQueued(wndx->disp,QueuedAfterFlush)) + { + XNextEvent( wndx->disp, &event ); + switch(event.type) + { + case Expose: + while (XCheckTypedEvent(wndx->disp, Expose, &event)) + ; + break; + case ClientMessage: + // Destroy the window when the WM_DELETE_WINDOW message arrives + if( (Atom) event.xclient.data.l[ 0 ] == wndx->delWin ) + { + wnd->quit=1; + + } + break; + case CreateNotify: + case ConfigureNotify: + x = event.xconfigure.width; + y = event.xconfigure.height; + glXMakeCurrent(wndx->disp,wndx->h,wndx->ctxt); + glViewport(0,0,x,y); + // callback to change aspect + break; + case ButtonPress: + // position: event.xbutton.x,y; + x=INPLOWEVENT_MOUSE_LB_DOWN; + if(event.xbutton.button==Button2) + x=INPLOWEVENT_MOUSE_CB_DOWN; + else if(event.xbutton.button==Button3) + x=INPLOWEVENT_MOUSE_RB_DOWN; + InpLowEvent(x,NUL); + break; + case ButtonRelease: + x=INPLOWEVENT_MOUSE_LB_UP; + if(event.xbutton.button==Button2) + x=INPLOWEVENT_MOUSE_CB_UP; + else if(event.xbutton.button==Button3) + x=INPLOWEVENT_MOUSE_RB_UP; + InpLowEvent(x,NUL); + break; + case MotionNotify: + buf[0] = event.xmotion.x; + buf[1] = event.xmotion.y; + InpLowEvent(INPLOWEVENT_MOUSE_MOVE_XY,buf); + break; + case KeyPress: + flags=0; + keys[0]=0; + //XLookupString((XKeyEvent *)&event, keys,sizeof(keys), &key, NULL); + key=XLookupKeysym((XKeyEvent *)&event,0); + keys[0]=key; + keys[1]=0; + switch (key) + { + case XK_KP_4: + case XK_KP_Left: + case XK_Left: + InpLowEvent(INPLOWEVENT_P0_L_DOWN,NUL); + break; + case XK_KP_6: + case XK_KP_Right: + case XK_Right: + InpLowEvent(INPLOWEVENT_P0_R_DOWN,NUL); + break; + case XK_KP_8: + case XK_KP_Up: + case XK_Up: + InpLowEvent(INPLOWEVENT_P0_U_DOWN,NUL); + break; + case XK_KP_2: + case XK_KP_Down: + case XK_Down: + InpLowEvent(INPLOWEVENT_P0_D_DOWN,NUL); + break; + case XK_Next: + InpLowEvent(INPLOWEVENT_P0_D2_DOWN,NUL); + break; + case XK_Prior: + InpLowEvent(INPLOWEVENT_P0_U2_DOWN,NUL); + break; + case XK_Escape: + InpLowEvent(INPLOWEVENT_SYS_ESC_DOWN,NUL); + break; + case XK_F1: + case XK_F2: + case XK_F3: + case XK_F4: + case XK_F5: + case XK_F6: + case XK_F7: + case XK_F8: + case XK_F9: + case XK_F10: + case XK_F11: + case XK_F12: + keys[0]=key-XK_F1+INPKEY_F1; + keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN|flags,keys); + break; + case XK_Shift_L: + case XK_Shift_R: + wndG.keyFlags|=M_INPLOWEVENT_SHF; + InpLowEvent(INPLOWEVENT_FLAGS|wndG.keyFlags,NUL); + break; + case XK_Control_L: + case XK_Control_R: + wndG.keyFlags|=M_INPLOWEVENT_CTL; + InpLowEvent(INPLOWEVENT_FLAGS|wndG.keyFlags,NUL); + break; + case XK_Alt_L: + case XK_Alt_R: + wndG.keyFlags|=M_INPLOWEVENT_ALT; + InpLowEvent(INPLOWEVENT_FLAGS|wndG.keyFlags,NUL); + break; + default: + //keys[0]=key&0xff; + //keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN|flags,keys); + break; + } // switch + break; // KeyPress + case KeyRelease: + flags=0; + keys[0]=0; + XLookupString((XKeyEvent *)&event, keys,sizeof(keys), &key, NULL); + switch (key) + { + case XK_Left: + InpLowEvent(INPLOWEVENT_P0_L_UP,NUL); + break; + case XK_Right: + InpLowEvent(INPLOWEVENT_P0_R_UP,NUL); + break; + case XK_Up: + InpLowEvent(INPLOWEVENT_P0_U_UP,NUL); + break; + case XK_Down: + InpLowEvent(INPLOWEVENT_P0_D_UP,NUL); + break; + case XK_Next: + InpLowEvent(INPLOWEVENT_P0_D2_UP,NUL); + break; + case XK_Prior: + InpLowEvent(INPLOWEVENT_P0_U2_UP,NUL); + break; + case XK_Escape: + InpLowEvent(INPLOWEVENT_SYS_ESC_UP,NUL); + break; + case XK_F1: + case XK_F2: + case XK_F3: + case XK_F4: + case XK_F5: + case XK_F6: + case XK_F7: + case XK_F8: + case XK_F9: + case XK_F10: + case XK_F11: + case XK_F12: + keys[0]=key-XK_F1+INPKEY_F1; + keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_UP|flags,keys); + break; + case XK_Shift_L: + case XK_Shift_R: + wndG.keyFlags&=~M_INPLOWEVENT_SHF; + InpLowEvent(INPLOWEVENT_FLAGS|wndG.keyFlags,NUL); + break; + case XK_Control_L: + case XK_Control_R: + wndG.keyFlags&=~M_INPLOWEVENT_CTL; + InpLowEvent(INPLOWEVENT_FLAGS|wndG.keyFlags,NUL); + break; + case XK_Alt_L: + case XK_Alt_R: + wndG.keyFlags&=~M_INPLOWEVENT_ALT; + InpLowEvent(INPLOWEVENT_FLAGS|wndG.keyFlags,NUL); + break; + default: + //keys[0]=key&0xff; + //keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_UP|flags,keys); + break; + } // switch + break; // KeyRelease + } // switch + } // while +#endif + ec=0; +BAIL: + if(wnd->quit) + ec=-1; + return ec; +} // WndLoop() + +// JFL 28 Oct 04 +void errlog(char *msg) +{ + #if PRODUCTION + SysLog("ERRLOG: %s\n",msg); + #else // !PRODUCTION + WndRec *wnd=&wndlist; + static dontshow=0; + + if(!dontshow) + { + } + #endif // !PRODUCTION +} // errlog() + +#endif // SYS_BB +// EOF diff --git a/dond/coregl/diag_gl.c b/dond/coregl/diag_gl.c new file mode 100755 index 0000000..7bfdc18 --- /dev/null +++ b/dond/coregl/diag_gl.c @@ -0,0 +1,455 @@ +#if SYS_GL +// diag_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// PRF 20 JUN 05 + +#include + +#include "pm.h" +#include "sys.h" +#ifdef SYS_BB +#include +#else +#include +#endif +#include "mem.h" +#include "int.h" +#include "diag.h" +#include "str.h" +#include "obj.h" +#include "fb.h" +#include "res.h" +#include // sqrt, cos, sin + +#define S_X 640 +#define S_Y 480 +#define XY_MULT 10 + +crd x[3] = {4.0, 59.0, 32.0}; +crd y[3] = {43.0, 4.0, 24.0}; + +int glDiagDrawDot(void *objv) +{ + Extra_Tab_t * Extra_Tab = (void*)&((ObjFunc*)objv)[1]; + float xx,yy,d; + + switch(Extra_Tab->n) + { + case 0: + case 1: + xx = x[Extra_Tab->n]; //put bullet in cent er of target + yy = y[Extra_Tab->n]; + break; + case 2: + xx=Extra_Tab->x/XY_MULT; //convert to font coords + yy=(S_Y - Extra_Tab->y)/XY_MULT; + break; + } + + d=.5; + + glPolygonMode(GL_FRONT,GL_FILL); + + if (Extra_Tab->gnum) glColor3ub(255, 175, 0); //green + else glColor3ub(0, 255, 0); //orange + glBegin(GL_QUADS); + glVertex2f(xx-d,yy-d); + glVertex2f(xx+d,yy-d); + glVertex2f(xx+d,yy+d); + glVertex2f(xx-d,yy+d); + glEnd(); + + return 0; +} + +int glDiagDrawScreen(void *objv) +{ +/* int x,y; + + glPolygonMode(GL_FRONT,GL_FILL); + + glColor3ub(255, 255, 255); //gray big + glBegin(GL_QUADS); + glVertex2f(0,0); + glVertex2f(64,0); + glVertex2f(64,48); + glVertex2f(0,48); + glEnd(); + + x = 32.0; + y = 24.0; + + glLineWidth( 2.0f ); + glColor3ub(255, 0, 0); //red + glBegin(GL_LINES); + glVertex2f(x-1.5,y); + glVertex2f(x+1.5,y); + glEnd(); + + glBegin(GL_LINES); + glVertex2f(x,y-1.5); + glVertex2f(x,y+1.5); + glEnd(); +*/ + return 0; +} + +int glDiagDrawTarget(void *objv) +{ + int n = ((ObjFunc*)objv)->n; + + glLineWidth( 2.0f ); + glColor3ub(255, 0, 0); //red + glBegin(GL_LINES); + glVertex2f(x[n]-1.5,y[n]); + glVertex2f(x[n]+1.5,y[n]); + glEnd(); + + glBegin(GL_LINES); + glVertex2f(x[n],y[n]-1.5); + glVertex2f(x[n],y[n]+1.5); + glEnd(); + + return 0; +} + +// ------------------------------------------------------------------- + +int glDiagDrawGrid(void * objv) +{ + float x,y,xd,yd,r,c; + glPolygonMode(GL_FRONT,GL_LINE); + glLineWidth( 1.0f ); + glColor3ub(255, 255, 255); + + x = 0.5; + y = 0.5; + yd = 9.45;//5.85; + xd = 16.925;//7.85; + + for (r = 0; r < 8; r++) + { + for (c = 0; c < 8; c++) + { + glBegin(GL_QUADS); + glVertex2f(x,y); + glVertex2f(x+xd,y); + glVertex2f(x+xd,y+yd); + glVertex2f(x,y+yd); + glEnd(); + + x += xd; + } + + y += yd; + x = 0.5; + } + + return 0; +} + +// ------------------------------------------------------------------- + +/* +int glDiagDrawGrid(void * objv) +{ + float x,y,xd,yd,r,c; + glPolygonMode(GL_FRONT,GL_LINE); + glLineWidth( 10.0f ); + glColor3ub(255, 255, 255); //white square + + x = 0.5; + y = 0.5; + yd = 18.9;//11.7; + xd = 33.85;//15.7; + + for (r=0;r<4;r++) + { + for (c=0;c<4;c++) + { + glBegin(GL_QUADS); + glVertex2f(x,y); + glVertex2f(x+xd,y); + glVertex2f(x+xd,y+yd); + glVertex2f(x,y+yd); + glEnd(); + + x+=xd; + } + y+=yd; + x=.5; + } + + return 0; +} +*/ + +int glDiagDrawColorScreen(void * objv) +{ + Extra_Tab_t * Extra_Tab = (void*)&((ObjFunc*)objv)[1]; + float xd = 136.6, y2 = 76.8; + int x=0,y1=0; + int n = ((ObjFunc*)objv)->n; + + glPolygonMode(GL_FRONT,GL_FILL); + + //tall bars on top + switch(Extra_Tab->n) + { + case 0: glColor3ub(0, 0, 0); break; + case 1: glColor3ub(255, 255, 255); break; + case 2: glColor3ub(255, 0, 0); break; + case 3: glColor3ub(0, 255, 0); break; + case 4: glColor3ub(0, 0, 255); break; + } + + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + return 0; +} + +int glDiagDrawColorBar(void * objv) +{ + float x,y1,xd,y2; + float xs = 1366.0 / 640.0; + + glPolygonMode(GL_FRONT,GL_FILL); + + xd = 19.5;//9; + y1 = 27.2;//17; + y2 = 76.8;//48; + x = 0; + + +//tall bars on top + glColor3ub(204, 204, 204); //gray big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=19.5;//9; + + glColor3ub(255, 255, 0); //yellow big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=39.0;//18; + glColor3ub(0, 255, 255); //cyan big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd+1,y1); + glVertex2f(x+xd+1,y2); + glVertex2f(x,y2); + glEnd(); + + x=58.5;//28; + glColor3ub(0, 255, 0); //green big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=78.0;//37; + glColor3ub(255, 0, 255); //magenta big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=97.5;//46; + glColor3ub(255, 0, 0); //red big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=117;//55; + glColor3ub(0, 0, 255); //blue big + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + +//small middle bars + + xd = 19.5;//9; + y1 = 20.8;//13; + y2 = 27.2;//17; + x = 0; + + glColor3ub(0, 0, 255); //blue small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=19.5;//9; + + glColor3ub(19, 19, 19); //dk gray small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=39.0;//18; + glColor3ub(255, 0, 255); //magenta small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd+1,y1); + glVertex2f(x+xd+1,y2); + glVertex2f(x,y2); + glEnd(); + + x=58.5;//28; + glColor3ub(19, 19, 19); //dk gray small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=78.0;//37; + glColor3ub(0, 255, 255); //cyan small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=97.5;//46; + glColor3ub(19, 19, 19); //dr gray small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=117.0;//55; + glColor3ub(204, 204, 204); //gray small + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + + +//bottom bars + xd = 22.8;//11; + y1 = 0; + y2 = 20.8;//13; + x = 0; + + + + glColor3ub(8, 64, 89); //teal medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=22.8;//11; + + glColor3ub(255, 255, 255); //white medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=45.6;//22; + glColor3ub(58, 0, 126); //purple medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd+1,y1); + glVertex2f(x+xd+1,y2); + glVertex2f(x,y2); + glEnd(); + + x=68.4;//34; + xd++; + glColor3ub(19, 19, 19); //dk gray medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=91.2; + xd=7.6;//3; + glColor3ub(0, 0, 0); //black medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=98.8;//49; + + glColor3ub(19, 19, 19); //dk gray medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=106.4;//52; + glColor3ub(38, 38, 38); //lighter gray medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + x=114.0;//55; + xd=22.8;//9; + glColor3ub(19, 19, 19); //dk gray medium + glBegin(GL_QUADS); + glVertex2f(x,y1); + glVertex2f(x+xd,y1); + glVertex2f(x+xd,y2); + glVertex2f(x,y2); + glEnd(); + + return 0; +} + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/draw_gl.c b/dond/coregl/draw_gl.c new file mode 100755 index 0000000..da044a3 --- /dev/null +++ b/dond/coregl/draw_gl.c @@ -0,0 +1,6683 @@ +#if SYS_GL +// draw_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 25 Feb 05 +// JFL 19 Apr 05 +// JFL 11 Jul 05; col xx1==25 fix + +#include "pm.h" +#include "sys.h" +#ifdef SYS_BB +#include +#else +#include +#include +#endif +#include "res.h" +#include "mem.h" +#include "vec.h" +#include "str.h" +#include "obj.h" +#include "vid.h" +#include "inp.h" +#include "msg.h" +#include "draw.h" +#include "game.h" + +#define COLEPSILON 0.00001 +#define COLEPSILON0G 0 +#define COLEPSILON1L 1 + +#if DEBUG // ------------------------------------------------------------------ +int DrawColDefDbg(void); +int DrawSkelColDisp(Obj *prime,ResDataDisp3 *disp3,ObjSkelRes *osr, + ObjColRes *ocr); +int DrawPropColDisp(Obj *prime,ResDataDisp2 *disp2,ObjColRes *ocr); +#endif // DEBUG --------------------------------------------------------------- + +// +// DrawSOStruct +// structure defining values used to +// handle the "sort once" objects in Disp2 +// +// GNP 30 Nov 05 +// +typedef struct { + void *d2Buf; //static buffer allocated at GameAddRes + uns32 d2BufSize; + uns32 d2BufQuads; + void *d2BufCur; + uns32 d2BufCurSize; + void *d2TriBuf; + void *d2TriBufCur; + uns32 flags; + uns32 nObjs; + uns32 nTris; + uns32 nQuads; + uns32 qStride; + uns32 nVerts; + uns32 nVColors; + uns32 nTexCoords; + uns32 nNormals; + ObjDispRes odr; + Res r; + ResDataDisp2 d2; + float minZ; // minimum Z value of "sort once" object + float maxZ; // maximum Z value of "sort once" object +} DrawSOStruct; + +DrawSOStruct drawSO; + +// +// M_DSO_ +// draw sort once flags +// +#define M_DSO_READY 0x00000001 // sort object ready to draw +#define M_DSO_RECALC 0x00000002 // need to recalc sort once object +#define M_DSO_LOCKED 0x00000004 // no more adding of "sort once" objects +#define M_DSO_NODISPLAY 0x00000008 // do not display the "sort once" object + +// forward +void DrawAddDisp2SortOnce(ObjDispRes *odr, ResDataDisp2 *d2, crd *vm); +void DrawSortOnceBuf(StateRec *sr); + +//#define NUM_DLIST_ENTRIES 2048 + +//struct { +// uns32 listId; +// char resname[RES_NAME_SIZE]; +//} DList[NUM_DLIST_ENTRIES]; + +// +// drawAddDisplayList +// call this function when adding a gl display list, for accounting +// +// in: +// odr = object deleting the display list +// +// GNP 28FEB06 +// +void drawAddDisplayList(ObjDispRes *odr) +{ +// int i; + +// for (i=0;idList; +// szncpy(DList[i].resname,((Res*)((ObjDispRes*)odr)->res)->name,sizeof(DList[i].resname)); +// break; +// } +// } + + VidDisp.objDListCount++; +} //drawAddDisplayList + +// +// drawSubDisplayList +// call this function when deleting a gl display list, for accounting +// +// in: +// odr = object deleting the display list +// +// GNP 28FEB06 +// +void drawSubDisplayList(ObjDispRes *odr) +{ +// int i; + +// for (i=0;idList) +// { +// DList[i].listId = 0; +// DList[i].resname[0] = 0; +// break; +// } +// } + + VidDisp.objDListCount--; +} //drawSubDisplayList + +// +// DrawInit +// called once at system power-up +// +// in: +// out: +// global: +// +// GNP 02 Dec 05 +// +int DrawInit(void) +{ + MEMZ(drawSO); +// MEMZ(DList); + return 0; +//DONE("DrawInit") +} // DrawInit + +// +// DrawReset +// called at every GameWipeout +// +// in: +// reset = reset level +// out: +// global: +// +// GNP 30 Nov 05 +// +int DrawReset(uns reset) +{ + // delete current display list if there was one + if (drawSO.odr.dList) + { + glDeleteLists(drawSO.odr.dList,1); + drawSubDisplayList(&drawSO.odr); + drawSO.odr.dList=0; + } + + MEMZ(drawSO); + drawSO.flags |= M_DSO_RECALC; +//DONE("DrawReset") + return 0; +} // DrawReset + +// +// DrawResetFrame +// called once per frame at the top of the object draw loop +// sets OpenGL into a known state +// +// in: +// out: +// global: +// +// GNP 21 Nov 05 +// +void DrawResetFrame(StateRec *sr) +{ + int i; + crd v4[4]; + + sr->colorR=sr->colorG=sr->colorB=sr->colorA=255; + glColor4ub(255,255,255,255); + + sr->bColorMaterial=FALSE; + glDisable(GL_COLOR_MATERIAL); + + sr->curTex = 0; + glBindTexture(GL_TEXTURE_2D,0); + + sr->bTex2D = FALSE; + glDisable(GL_TEXTURE_2D); + + sr->glShadeModel = GL_FLAT; + glShadeModel(GL_FLAT); + + sr->glTexEnv = GL_DECAL; + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); + + sr->bAlphaTest = FALSE; + glDisable(GL_ALPHA_TEST); + + sr->glAlphaFunc = GL_ALWAYS; + glAlphaFunc(GL_ALWAYS,1); + + sr->bBlend = FALSE; + glDisable(GL_BLEND); + + sr->bLighting = FALSE; + glDisable(GL_LIGHTING); + + for(i=0;ibLights[i] = 0; + } // for + + v4[0]=v4[1]=v4[2]=v4[3]=1; + glColorMaterial(GL_FRONT,GL_AMBIENT); + glMaterialfv(GL_FRONT,GL_DIFFUSE,v4); + glMaterialfv(GL_FRONT,GL_AMBIENT,v4); + glMaterialfv(GL_FRONT,GL_SPECULAR,v4); + glMateriali(GL_FRONT,GL_SHININESS,128); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); + +//DONE("DrawResetFrame") +} // DrawResetFrame + +// +// DrawResetObj +// called once at the start of each object. +// this is some Joe code that I wish to go away +// +// in: +// out: +// global: +// +// GNP 30 Nov 05 +// +void DrawResetObj(void) +{ + return; +// glColor4ub(255,255,255,255); +// glDisable(GL_COLOR_MATERIAL); +// glBindTexture(GL_TEXTURE_2D,0); +// glDisable(GL_TEXTURE_2D); +//// glPolygonMode(GL_FRONT,GL_LINE); +//// glPolygonMode(GL_BACK,GL_LINE); +// glShadeModel(GL_FLAT); +// glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); +// glDisable(GL_ALPHA_TEST); +// glAlphaFunc(GL_ALWAYS,1); +// glDisable(GL_BLEND); +// glDisable(GL_LIGHTING); +//DONE("DrawResetObj") +} // DrawResetObj + +// JFL 28 Oct 04 +void DrawDisp1(StateRec *sr,ResDataDisp1 *disp1) +{ + // + // SETUP ARRAYS + // + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP1); + #endif // DEBUG + + if(disp1->tVertColors) + { + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4,GL_FLOAT,0,disp1->tVertColors); + } + else + { + glDisableClientState(GL_COLOR_ARRAY); + } + + if(disp1->tTexCoords) + { + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2,GL_FLOAT,0,disp1->tTexCoords); + } + else + { + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3,GL_FLOAT,0,disp1->tVerts); + + // + // MODE + // + + if(sr->mode!=(disp1->mode&M_RESDISPMODE)) + { + switch(disp1->mode&M_RESDISPMODE) + { + case RESDISPMODE_WIREFRAME: + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + break; + case RESDISPMODE_TEX: + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); + glPolygonMode(GL_FRONT,GL_FILL); + break; + } // switch + sr->mode=disp1->mode&M_RESDISPMODE; + } + + // + // DRAW + // + + glDrawArrays(GL_TRIANGLES,0,disp1->nTris); + + // + // CLEAN UP + // + + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP1); + #endif // DEBUG + +} // DrawDisp1() + +typedef struct { + // this is whats sorted + float z; + void *p; +} objSortHead; + +typedef struct { + crd vm[VM_SIZE]; // object view matrix or total matrix +// crd vmo[VM_SIZE]; // object matrix + uns32 flags; + void *odr; + uns32 face; +} objSortBody; + +// +// M_OSB_ +// object sort flags +// +#define M_OSB_DRAWN 0x00000001 // sorted object has been drawn + + +// JFL 01 Apr 05 +// JFL 15 Apr 05; projection fix for cols +int colDisp2(Obj *prime,ResDataDisp2 *disp2) +{ + int ec; + int i,ii,k,npoly; + ObjColAct *cola; + N2 *l2; + float m4[16],vt0[3],vt1[3],vt2[3],vt3[3],vta[3],vtb[3],nrm[3],*v; + uns8 i0,i1,i2; + float a,b,c,d,e,f,len,denom; + float t; + + // check if there are any objects to collide + l2=ObjL2First(OBJL2_PROJECTILE); + if(!l2->type) + err(0); // no + +err(1); // jjj -- disable until we want to use this + glGetFloatv(GL_MODELVIEW_MATRIX,m4); + + // run through all projectiles + for(l2=ObjL2First(OBJL2_PROJECTILE);l2->type;l2=l2->next) + { + cola=(void*)L2N2(l2); + if((t=cola->len)<=0) + continue; + + ii=0; +polylp: + if(!ii) + npoly=disp2->nTris,v=disp2->tVerts; + else + npoly=disp2->nQuads,v=disp2->qVerts; + + for(i=0;idir); + if((b-COLEPSILON)) + continue; // orthogonal + len = -(d+V3Dot(nrm,cola->pos)); + len /= b; + + if((len<0) || (len>t)) + continue; + + // intersection point of ray and plane + vta[0]=len*cola->dir[0]; + vta[0]+=cola->pos[0]; + vta[1]=len*cola->dir[1]; + vta[1]+=cola->pos[1]; + vta[2]=len*cola->dir[2]; + vta[2]+=cola->pos[2]; + + // point in poly based on Badouel + + // find dominant axis + a=nrm[0];if(a<0) a=-a; + i0=0,i1=1,i2=2; + b=nrm[1];if(b<0) b=-b; + if(a=COLEPSILON0G)&&(b<=COLEPSILON1L) + &&(d>=COLEPSILON0G)&&(d<=COLEPSILON1L)) + goto inside; + } + + if(k) + { + k=0; + V3Cpy(vt0,vt1); + V3Cpy(vt1,vt2); + V3Cpy(vt2,vt3); + goto trilp; + } + + if(0) + { +inside: + // collision -- check if it's first or better + if(!cola->clen || (cola->clen>len)) + { + cola->flags&=~M_OBJCOLACT_HITFLAGS; + cola->flags|=M_OBJCOLACT_HIT|M_OBJCOLACT_HITPROPCOL; + cola->cpos[0]=vta[0]; + cola->cpos[1]=vta[1]; + cola->cpos[2]=vta[2]; + cola->cnrm[0]=nrm[0]; + cola->cnrm[1]=nrm[1]; + cola->cnrm[2]=nrm[2]; + cola->clen=len; + cola->cobj=prime; + cola->cdata=NUL; + cola->cnum=0; + } // setcol + } // inside + + } // for polys + + if(!ii++) + goto polylp; + + } // for + + ec=0; +BAIL: + return 0; +} // colDisp2() + +// JFL 07 Apr 05 +// JFL 15 Apr 05; projection fix for cols +// JFL 13 Jul 05; re-worked w/plane eqs +// JFL 03 Aug 05; scales +int propCol(Obj *prime,ObjColRes *ocr,crd *vmat,crd *scale) +{ + int ec; + ObjColAct *cola; + N2 *l2; + crd pos[3]; + crd vt0[3],vt1[3],vt2[3],vta[3],vtb[3],nrm[3],nre[3]; + crd bigscale; + crd b,d,len; + crd t; + Res *r; + ResDataCol *rdc; + ResDataCBXYZR *xyzr; + ResDataCBPoly *poly,*pnext; + ResDataCBVN *vn; + uns8 objl2; + + if(!(r=ocr->res)||!(rdc=r->data)) + berr(-1); + if(rdc->type!=RESDATACOLTYPE_PROP) + berr(-2); + + objl2=OBJL2_FIRST_COLLISION; + + if(0) + { +objl2_lp: + if(++objl2>OBJL2_LAST_COLLISION) + err(0); // done + } + + // check if there are any objects to collide + l2=ObjL2First(objl2); + if(!l2->type) + goto objl2_lp; + + // + // find scaled & unscaled matrices + // + + if(!scale) + bigscale=1; + else + { + // scale block's rabigscaleius + bigscale=scale[0]; + if(bigscaletype;l2=l2->next) + { + cola=(void*)L2N2(l2); + if((t=cola->len)<=0) + continue; + + // run through all the blocks (these are geo sets) + for(xyzr=rdc->blocks;xyzr->blk.type;xyzr++) + { + // radius check with block + VMVecMul(vt0,xyzr->xyzr,vmat); // transform block center into world + pos[0]=cola->pos[0]+cola->xyzr[0]; // add cola->xyzr in + pos[1]=cola->pos[1]+cola->xyzr[1]; // this allows for offset from + pos[2]=cola->pos[2]+cola->xyzr[2]; // the root + len=V3DistFast(pos,vt0); // quick distance check + len-=t; // ray length + len-=cola->xyzr[3]; // cola radius + b=bigscale*xyzr->xyzr[3]; // block's radius + len-=b; // sub out block's radius + if(len>0) + continue; + + poly = (void*)(((uns8*)rdc->polys) + xyzr->off); + for(;poly->numv!=RESDATACBPOLY_NUMV_END;poly=pnext) + { + vn=&poly->v[0]; + pnext=(void*)&vn[3+poly->numv]; // adr of next poly + + // transform 3 verts into world + VMVecMul(vt0,vn->vrt,vmat); + VMVecMul(vt1,vn[1].vrt,vmat); + VMVecMul(vt2,vn[2].vrt,vmat); + + // compute plane normal + V3Sub(vta,vt2,vt1); + V3Sub(vtb,vt1,vt0); + V3Cross(nrm,vtb,vta); + V3Unitize(nrm,1); + + // test for + b=V3Dot(nrm,cola->dir); + if((b-COLEPSILON)) + continue; // orthogonal + d=V3Dot(nrm,vt0); // plane constant + len=(d-V3Dot(nrm,pos))/b; + if((len<0)||(len>t)) + continue; // behind or too far + + // + // find point of intersection w/plane + // + + // intersection point of ray and plane + vta[0]=len*cola->dir[0]; + vta[0]+=pos[0]; + vta[1]=len*cola->dir[1]; + vta[1]+=pos[1]; + vta[2]=len*cola->dir[2]; + vta[2]+=pos[2]; + + // edge 0-1 + V3Sub(vtb,vt0,vt1); + V3Cross(nre,vtb,nrm); + V3Unitize(nre,1); + V3Sub(vtb,vt0,vta); // ray -- colpoint to vert + if(V3Dot(vtb,nre)>0) + goto outside; + + // edge 1-2 + V3Sub(vtb,vt1,vt2); + V3Cross(nre,vtb,nrm); + V3Unitize(nre,1); + V3Sub(vtb,vt1,vta); // ray -- colpoint to vert + if(V3Dot(vtb,nre)>0) + goto outside; + + if(poly->numv) + BP(BP_PROPCOL); // only does tris now + + // edge 2-0 + V3Sub(vtb,vt2,vt0); + V3Cross(nre,vtb,nrm); + V3Unitize(nre,1); + V3Sub(vtb,vt2,vta); // ray -- colpoint to vert + if(V3Dot(vtb,nre)<=0) + goto inside; + +outside: + if(0) + { +inside: + // + // collision + // + + // collision -- check if it's first or better + if(!cola->clen || (cola->clen>len)) + { + cola->flags&=~M_OBJCOLACT_HITFLAGS; + cola->flags|=M_OBJCOLACT_HIT|M_OBJCOLACT_HITPROPCOL; + cola->clen=len; + cola->cpos[0]=vta[0]; + cola->cpos[1]=vta[1]; + cola->cpos[2]=vta[2]; + cola->cnrm[0]=nrm[0]; + cola->cnrm[1]=nrm[1]; + cola->cnrm[2]=nrm[2]; + cola->cobj=prime; + cola->cdata=xyzr->colName; + cola->cnum=xyzr->colNum; + } // setcol + } // inside + } // for poly + } // for xyzr + } // for cola + + goto objl2_lp; + + ec=0; +BAIL: + return 0; +} // propCol() + +#if DEBUG // ------------------------------------------------------------------ +// JFL 07 Apr 05 +// JFL 13 Jul 05 +// JFL 03 Aug 05; scaled +int DrawPropColDispDbg(ObjColRes *ocr,crd *scale) +{ + int ec; + ResDataCol *rdc; + ResDataCBXYZR *xyzr; + ResDataCBVN *vn; + ResDataCBPoly *poly,*pnext; + Res *r; + uns8 k; + float f1,nrm[3],vta[3]; + float bigscale=1; + + DrawResetObj(); + + if(!(r=ocr->res)||!(rdc=r->data)) + berr(-1); + if(rdc->type!=RESDATACOLTYPE_PROP) + berr(-2); + + if(VidDisp.dbgcol&M_VIDDISP_DBGCOL_WIRE) + glPolygonMode(GL_FRONT,GL_LINE); + else + glPolygonMode(GL_FRONT,GL_FILL); + + glColor3ub(255,255,0); + + // draw collision info in local coords + + if(scale) + { + bigscale=scale[0]; + if(bigscaleblocks;xyzr->blk.type;xyzr++) + { + glColor3ub(255,255,255); + + glTranslatef(xyzr->xyzr[0],xyzr->xyzr[1],xyzr->xyzr[2]); + xVidDraw(VIDDRAW_SPHERE,bigscale*xyzr->xyzr[3]); + + glTranslatef(-xyzr->xyzr[0],-xyzr->xyzr[1],-xyzr->xyzr[2]); + + poly = (void*)(((uns8*)rdc->polys) + xyzr->off); + for(;poly->numv!=RESDATACBPOLY_NUMV_END;poly=pnext) + { + vn=&poly->v[0]; + pnext=(void*)&vn[3+poly->numv]; + + glColor3ub(255,255,0); + + glBegin(GL_POLYGON); + glVertex3f(vn->vrt[0],vn->vrt[1],vn->vrt[2]),vn++; + glVertex3f(vn->vrt[0],vn->vrt[1],vn->vrt[2]),vn++; + glVertex3f(vn->vrt[0],vn->vrt[1],vn->vrt[2]),vn++; + for(k=0;knumv;k++) + glVertex3f(vn->vrt[0],vn->vrt[1],vn->vrt[2]),vn++; + glEnd(); + + continue; // skip the rest + + // find center point + V3SetXYZ(vta,0,0,0); + for(k=0;k<(3+poly->numv);k++) + { + vta[0]+=poly->v[k].vrt[0]; + vta[1]+=poly->v[k].vrt[1]; + vta[2]+=poly->v[k].vrt[2]; + } // for + + f1=1.0/(float)(3+poly->numv); + vta[0]*=f1; + vta[1]*=f1; + vta[2]*=f1; + + V3Cpy(nrm,poly->nrmk); + + glBegin(GL_LINE_STRIP); + glVertex3f(vta[0],vta[1],vta[2]); + glVertex3f(vta[0]+nrm[0],vta[1]+nrm[1],vta[2]+nrm[2]); + glEnd(); + + // draw edge normals + for(k=0;k<(3+poly->numv);k++) + { + if(!k) glColor3ub(255,0,0); + else if(k==1) glColor3ub(0,255,0); + else if(k==2) glColor3ub(0,0,255); + else glColor3ub(255,255,255); + + V3Cpy(nrm,poly->v[k].nrm); + nrm[0]*=0.3; + nrm[1]*=0.3; + nrm[2]*=0.3; + + V3Cpy(vta,poly->v[k].vrt); + + glBegin(GL_LINE_STRIP); + glVertex3f(vta[0],vta[1],vta[2]); + glVertex3f(vta[0]+nrm[0],vta[1]+nrm[1],vta[2]+nrm[2]); + glEnd(); + } // for + } // for + } // for + + ec=0; +BAIL: + return ec; +} // DrawPropColDispDbg() +#endif // DEBUG --------------------------------------------------------------- + +// JFL 08 Jul 05 +void DrawCol(StateRec *sr,ObjColRes *ocr,ResDataCol *col) +{ + ResDataColRTS *rts=NUL; + crd *scale=NUL; + float vm[12]; + #if DEBUG + float m[16]; + #endif // DEBUG + + if(col->flags&M_RESDATACOL_RTS) + { + rts=(void*)&col[1]; + if(rts->rts[6]&&rts->rts[7]&&rts->rts[8]) + scale=&rts->rts[6]; + VMBuildObj(vm,&rts->rts[0],&rts->rts[3],scale); + } + else + VMId(vm); + + propCol((void*)ocr,ocr,vm,scale); + + #if DEBUG + // draw col geo + if(VidDisp.dbgcol) + { + if(rts) + { + glPushMatrix(); + M4SetVM(m,vm); + glMultMatrixf(m); + } + DrawPropColDispDbg(ocr,scale); + if(rts) + glPopMatrix(); + } // dbgcol + #endif // DEBUG +} // DrawCol() + +// JFL 10 Jun 05 +// JFL 12 Aug 05; disp3 +int DrawPos(void *dst,crd *scale,ObjDispRes *odr,uns flags) +{ + int ec; + Res *r; + void *d; + char *name; + crd *rtsp[3]; + Obj *o2; + ObjVel *ov; + ObjAniRes *oar; + ObjSkelRes *osr; + ResDataDisp2 *disp2=NUL; + ResDataDisp3 *disp3=NUL; + + if(!odr || !(r=odr->res)||!(d=r->data)) + err(-1); + name=r->name; + + rtsp[0]=rtsp[1]=rtsp[1]=NUL; + + // + // DISP2 + // + + if(RESSUB_DISP2==r->lnk.sub) + disp2=d; + else if(RESSUB_DISP3==r->lnk.sub) + disp3=d; + else + berr(-1); + + // + // MATRIX + // + + rtsp[0]=rtsp[1]=rtsp[2]=NUL; + + // disp2 objs + // are driven by the first oar or first ov + // disp3 objs + // if the skel res is present are driven by that + // else they are driven by the first oar/ov + // check for animation + if(odr && (odr->lnk.flags&M_N2_KIDLIST)) + { + for(o2=(void*)N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_ANIRES) + { + // found animation, combine animation's mat + oar=(void*)o2; +driveroar: + rtsp[0]=&oar->cur[OAR_CH_RX]; + rtsp[1]=&oar->cur[OAR_CH_TX]; + if(!(oar->flags&M_OBJANIRES_NOSCALE)) + rtsp[2]=&oar->cur[OAR_CH_SX]; + goto dispd; + } // anires + else if(o2->lnk.sub==OBJSUB_VEL) + { + ov=(void*)o2; + if(ov->flags&M_OBJVEL_IGNORE) + continue; + if(ov->flags&M_OBJVEL_OFF) + err(-99); // obj is off, don't draw +driverov: + rtsp[0]=ov->rot; + rtsp[1]=ov->trans; + if(ov->flags&M_OBJVEL_SCALE) + rtsp[2]=ov->scale; + goto dispd; + } // vel + else if(o2->lnk.sub==OBJSUB_SKELRES) + { // skel + osr=(void*)o2; + + if(((Obj*)osr->rootDriver)->lnk.sub==OBJSUB_ANIRES) + { + oar=osr->rootDriver; + goto driveroar; + } + else if(((Obj*)osr->rootDriver)->lnk.sub==OBJSUB_VEL) + { + ov=osr->rootDriver; + goto driverov; + } + else + BP(BP_DRAWPOS); + } // skel + } // for + } // o + + // vm has already been converted into VM_ + if((flags&M_DRAWPOS_DST)==M_DRAWPOS_DSTVM) + { + if(disp2) + { + // if the vmat is already built, use it + // otherwise we can't overwrite the data b/c it contains + // the rts starting position for an animation + if(disp2->mode&M_RESDISPMODE_VMAT) + { + if(dst==disp2->vmat) + BP(BP_DRAWPOS2); + + VMCpy(dst,disp2->vmat); + if(scale) + MathM3ToScale(disp2->vmat+VM_11,scale); + err(0); + } + + rtsp[0]=&disp2->vmat[VM_RX]; + rtsp[1]=&disp2->vmat[VM_TX]; + rtsp[2]=&disp2->vmat[VM_SX]; + VMBuildObj(dst,rtsp[0],rtsp[1],rtsp[2]); + + // scale values + if(scale) + { + if(rtsp[2]) + V3Cpy(scale,rtsp[2]); + else + V3SetXYZ(scale,1,1,1); + } + + err(0); + } // disp2 + else if(disp3) + { + // if the vmat is already built, use it + // otherwise we can't overwrite the data b/c it contains + // the rts starting position for an animation + if(disp3->mode&M_RESDISPMODE_VMAT) + { + if(dst==disp3->vmat) + BP(BP_DRAWPOS3); + + VMCpy(dst,disp3->vmat); + + if(scale) + MathM3ToScale(disp3->vmat+VM_11,scale); + + err(0); + } + + rtsp[0]=&disp3->vmat[VM_RX]; + rtsp[1]=&disp3->vmat[VM_TX]; + rtsp[2]=&disp3->vmat[VM_SX]; + VMBuildObj(dst,rtsp[0],rtsp[1],rtsp[2]); + + // scale values + if(scale) + { + if(rtsp[2]) + V3Cpy(scale,rtsp[2]); + else + V3SetXYZ(scale,1,1,1); + } + + err(0); + + } // disp3 + else + berr(-4); + + } + + BP(BP_DRAWPOS4); // can't convert + err(-2); + +dispd: + + // scale values + if(scale) + { + if(rtsp[2]) + V3Cpy(scale,rtsp[2]); + else + V3SetXYZ(scale,1,1,1); + } + + if((flags&M_DRAWPOS_DST)==M_DRAWPOS_DSTRTSP) + { + ((crd**)dst)[0]=rtsp[0]; + ((crd**)dst)[1]=rtsp[1]; + ((crd**)dst)[2]=rtsp[2]; + err(0); + } + else if((flags&M_DRAWPOS_DST)==M_DRAWPOS_DSTRTS) + { + ((crd*)dst)[0]=(rtsp[0])[0]; + ((crd*)dst)[1]=(rtsp[0])[1]; + ((crd*)dst)[2]=(rtsp[0])[2]; + ((crd*)dst)[3]=(rtsp[1])[0]; + ((crd*)dst)[4]=(rtsp[1])[1]; + ((crd*)dst)[5]=(rtsp[1])[2]; + ((crd*)dst)[6]=(rtsp[2])[0]; + ((crd*)dst)[7]=(rtsp[2])[1]; + ((crd*)dst)[8]=(rtsp[2])[2]; + err(0); + } + else if((flags&M_DRAWPOS_DST)==M_DRAWPOS_DSTVM) + { + VMBuildObj(dst,rtsp[0],rtsp[1],rtsp[2]); + err(0); + } + BP(BP_DRAWPOS5); // can't convert + err(-1); + + ec=0; +BAIL: + return ec; +} // DrawPos() + +#if DEBUG +void dbgDrawCull(crd *xyzr,crd r,crd *scale,uns odrflags) +{ + glShadeModel(GL_FLAT); + glDisable(GL_BLEND); + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + + // draw line from 0,0,0 -- local root to projected culling root + glColor4ub(90,90,90,255); + glBegin(GL_LINES); + glVertex3f(0,0,0); + glVertex3f(xyzr[0],xyzr[1],xyzr[2]); + glEnd(); + + if(odrflags&M_OBJDISPRES_FRUSTOUT) + glColor4ub(255,255,255,128); + + // draw radius-sphere + glPushMatrix(); + glTranslatef(xyzr[0],xyzr[1],xyzr[2]); + glPolygonMode(GL_FRONT,GL_LINE); + xVidDraw(VIDDRAW_SPHERE,r); + glPopMatrix(); +} // dbgDrawCull() +#endif // DEBUG + +// JFL 10 Jun 05 +int DrawCull(StateRec *sr,crd *xyzr,crd *vmat,crd *scale) +{ + +// return 0 = not culled +// 1 = culled +// <0 = error (probably don't cull) + + int ec; + int i; + crd v1[3],vw[3],*nrmk,*v; + crd b,push[3]; + + // rotate scale + b=scale[0]; + if(bcullPlaneXYZ; // verts + for(i=0,nrmk=sr->cullPlaneEqs;iculled++; + err(1); // cull + } + } // for + + ec=0; +BAIL: + return ec; +} // DrawCull() + +extern uns32 noTex; + +// JFL 28 Oct 04 +// JFL 28 Dec 04; face sorting +// JFL 16 May 05; lighting +// JFL 08 Jun 05; culling +// JFL 10 Jun 05; got rid of rtsptrs +// JFL 03 Aug 05; prop col scaling +// JFL 18 Aug 05; blend & sorting +void DrawDisp2(StateRec *sr,Obj *odr,ResDataDisp2 *disp2,uns flags) +{ + int ec; + crd m[16],v[3],vm[VM_SIZE],*vmscale,scale[3]; + int i,n,j,k,ii; + uns msk; + objSortHead *osh; + objSortBody *osb; + uns8 hasvcolors; + Obj *o2; + float a; + ResDataFaceSort *fs; + uns lightson,odrflags,dispmode; + char *name; + void *tmpbuf=NUL; + uns8 *p, bBuildList; + float f1; + float *qcolors=NUL,*tcolors=NUL; + ObjDispRes *curodr; + + #if !CRD_IS_FLOAT + #error -- crd type assumed float in this routine + #endif + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2); + #endif // DEBUG + + name=NUL; + curodr = (ObjDispRes*)odr; + if(odr && ((ObjDispRes*)odr)->res) + name=((Res*)((ObjDispRes*)odr)->res)->name; + + #if DEBUG + if (VidDisp.findResName[0] != 0) + { + if(!szcmp(VidDisp.findResName,name)) + { + BP(BP_DISPDRAW2); + } + } + #endif + + if(!disp2->nQuads && !disp2->nTris) + goto BAILQUICK; + + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_NODISP2) + goto BAILQUICK; + #endif // DEBUG + + // load up + lightson=0; // bits on signal that light has been enabled + if(odr) + odrflags=((ObjDispRes*)odr)->flags; + else + odrflags=0; + dispmode=disp2->mode; + + // if object has been added to the sort once list, no more processing + if(odrflags & M_OBJDISPRES_SORTEDONCE) + goto BAILQUICK; + + // if there are no lights yet, drop the dispmode bit + if(!(sr->frameflags&M_SRFRAMEFLAGS_HASLIGHTS)) + dispmode&=~M_RESDISPMODE_LIGHT; + + // copy texture if there is one + sr->tex=disp2->texGen; + + if((VidDisp.dbgcol)&&(dispmode&M_RESDISPMODE_GND)) + { + if(sr->frameflags&M_SRFRAMEFLAGS_DBG_GCOL) + sr->frameflags|=M_SRFRAMEFLAGS_DBG_GCOL; + #if DEBUG + DrawColDefDbg(); + #endif // DEBUG + goto BAILQUICK; + } // ground + + // -- no more easy returns -- + + // + // GET TRANSFORM MATRIX + // + + if(!(flags&M_DRAWDISP_NOMAT)) + { + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2MATRIX); + #endif // DEBUG + + sr->draw2Matrix++; + glPushMatrix(); + if(DrawPos(vm,scale,(void*)odr,M_DRAWPOS_DSTVM)<0) + { + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2MATRIX); + #endif // DEBUG + goto BAIL; // don't draw + } + M4SetVM(m,vm); + glMultMatrixf(m); + if((scale[0]!=1)||(scale[1]!=1)||(scale[2]!=1)) + vmscale=scale; + else + vmscale=NUL; + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2MATRIX); + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2CULL); + #endif // DEBUG + + if((sr->frameflags&M_SRFRAMEFLAGS_CULLPLANES) + &&!(dispmode&M_RESDISPMODE_NOCULL)) + { + if(!(dispmode & M_RESDISPMODE_SORTONCE) && (DrawCull(sr,disp2->xyzrCull,vm,scale)==1)) + { + odrflags|=M_OBJDISPRES_FRUSTOUT; + ((ObjDispRes*)odr)->flags|=M_OBJDISPRES_FRUSTOUT; + } + else + ((ObjDispRes*)odr)->flags&=~M_OBJDISPRES_FRUSTOUT; + } + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2CULL); + #endif // DEBUG + + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_FRUST2) + dbgDrawCull(disp2->xyzrCull,disp2->xyzrCull[3],scale,odrflags); + #endif // DEBUG + + } // set matrix + else + VMId(vm),vmscale=NUL; + + if(odrflags&M_OBJDISPRES_AFTERSHADOWS) // wait to draw till after shadows + { + if(!(flags&M_DRAWDISP_AFTERSHADOWS)) // not after shadows + { + if(odrflags&M_OBJDISPRES_SAVE) + { + VMType *vmd; + + // find save node + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_DISPSAVE) + { + ((ObjDispSave*)o2)->flags|=M_OBJDISPSAVE_SET; + if(!(((ObjDispSave*)o2)->flags&M_OBJDISPSAVE_SINGLE)) + continue; // don't use unless single flag is set + vmd=(void*)((ObjDispSave*)o2)->jointMats; + VMCpy(vmd->a,vm); + break; // use first only + } // dispsave + } // for + } // save + + if(((ObjDispRes*)odr)->flags&M_OBJDISPRES_HASTMPLINK) + { + o2=(void*) (1+((ObjDispRes*)odr)); // ObjTmpLink + if((o2->lnk.type==N2TYPE_OBJ)&&(o2->lnk.sub==OBJSUB_TMPLINK)) + N2LinkBefore(&sr->afterShadList,o2); + } + goto BAIL; + } // not after shadows + } // wait to draw till after shadows + + // + // CULLING + // + + #if DEBUG + if((VidDisp.dbgdisp&M_VIDDISP_DBGDISP_FRUST) + &&(odrflags&M_OBJDISPRES_FRUSTOUT)) + { + odrflags|=M_OBJDISPRES_FLASHRGB; + odrflags&=~M_OBJDISPRES_FRUSTOUT; + ((ObjDispRes*)odr)->rgba[0]= + ((ObjDispRes*)odr)->rgba[1]= + ((ObjDispRes*)odr)->rgba[2]=130; + } // culled objs are gray + + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_DONTCULL) + odrflags&=~M_OBJDISPRES_FRUSTOUT; + #endif // DEBUG + + // dont draw if outside frustrum + if(odrflags & M_OBJDISPRES_FRUSTOUT) + { +// if (dispmode & M_RESDISPMODE_SORTONCE && odrflags & M_OBJDISPRES_SORTEDONCE) +// { + // "sort once" object was in and now out, re-calc +// curodr->flags &= ~M_OBJDISPRES_SORTEDONCE; // obj is out of view, if it comes back +// drawSO.flags |= M_DSO_RECALC; +// } + goto BAIL; + } + + // object has passed cull test and is being redrawn + if (dispmode&M_RESDISPMODE_SORTONCE && !(odrflags & M_OBJDISPRES_SORTEDONCE)) + { + // "sort once" object has come on screen that is not in the big object + drawSO.flags |= M_DSO_RECALC; + } + + #if DEBUG + if (disp2->nTris && disp2->nTris/3 < (uns16)VidDisp.minTri) + goto BAIL; + if (disp2->nQuads && disp2->nQuads/4 < (uns16)VidDisp.minQuad) + goto BAIL; + #endif // DEBUG + + // + // ALPHA + // + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2SORT); + #endif // DEBUG + + if(((dispmode&M_RESDISPMODE_HASALPHA)||(odrflags&M_OBJDISPRES_BLEND)) // has alpha + && !(flags&M_DRAWDISP_NOSORT) // no-sort isn't set + && sr->sort // sort buf + && (VidDisp.flags&M_VIDDISP_BLEND)) // blend is on + { + // grab the whole modelview matrix + glGetFloatv(GL_MODELVIEW_MATRIX,m); + + if(!(dispmode&M_RESDISPMODE_FACESORT)) + { + // Normal Sort Buffer + // check if there is enough room for the sort head & body + n = sr->sort->sortBufHigh; + n-= sr->sort->sortBufLow; + if(n<(sizeof(objSortHead)+sizeof(objSortBody))) + { + errlog("drawDisp2() sort buf"); + goto sortd; + } + + // alloc room for sort head & body + osh=(void*)&sr->sort->sortBufStart[sr->sort->sortBufLow]; + sr->sort->sortBufLow+=sizeof(objSortHead); + sr->sort->sortBufHigh-=sizeof(objSortBody); + osb=(void*)&sr->sort->sortBufStart[sr->sort->sortBufHigh]; + sr->sort->sortNum++; + + // head + osh->p = osb; + osh->z = m[M4_Z]; // sort by Z of matrix + + // body + + if (dispmode&M_RESDISPMODE_SORTONCE) + // total object matrix (i.e. r,t,s) + VMCpy(osb->vm,vm); + else + // just model view matrix + VMSetM4(osb->vm,m); // save modelview matrix + osb->odr=odr; + osb->face=0; + osb->flags=0; + + } // object sort + else + { + // -- add all faces -- + + for(k=0;k<2;k++) + { + if(!k) + fs=disp2->qFaceSort,j=disp2->nQuads,ii=4,msk=M_DRAWDISP_ONEQUAD; + else + fs=disp2->tFaceSort,j=disp2->nTris,ii=3,msk=M_DRAWDISP_ONETRI; + + if(!fs || !j) + continue; + + for(i=0;isort->sortBufHigh; + n-= sr->sort->sortBufLow; + if(n<(sizeof(objSortHead)+sizeof(objSortBody))) + { + errlog("drawDisp2() sort buf"); + goto sortd; + } + + // alloc room for sort head & body + osh=(void*)&sr->sort->sortBufStart[sr->sort->sortBufLow]; + sr->sort->sortBufLow+=sizeof(objSortHead); + sr->sort->sortBufHigh-=sizeof(objSortBody); + osb=(void*)&sr->sort->sortBufStart[sr->sort->sortBufHigh]; + sr->sort->sortNum++; + + // body + VMSetM4(osb->vm,m); + osb->odr=odr; + osb->face=msk|(i<xyz,osb->vm); + + // find a value to add into z to push things back if they + // are off center y + if(v[2]) + { + // find + a=v[1]/v[2]; + if(a<0) + a=-a; + } + else + a=0; + + // head + osh->p = osb; + osh->z = v[2]+a; // add b/c smaller draw first + } // for + } // for + } // face sort + + // do blend in one pass -- later + if(VidDisp.flags&M_VIDDISP_ONEPASSBLEND) + { + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2SORT); + #endif // DEBUG + goto BAIL; + } + } // pass1 +sortd: + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2SORT); + #endif // DEBUG + + // + // PREP TO SET COLOR, LIGHTS, TEXTURE + // + + if(disp2->tVertColors || disp2->qVertColors) + hasvcolors=1; + else + hasvcolors=0; + + #if DEBUG + // At this point, we know this object is going + // to be drawn so this is a great place to do some + // accounting. + sr->draw2++; + + if (sr->draw2MinQuads == 0) + sr->draw2MinQuads = 1000000; + + if (sr->draw2MinTris == 0) + sr->draw2MinTris = 1000000; + + if(!(flags&M_DRAWDISP_ONETRI)) + { + i = disp2->nTris/3; + sr->draw2Tris+=i; + if ((uns32)i > sr->draw2MaxTris) + sr->draw2MaxTris = i; + if (i > 0 && (uns32)i < sr->draw2MinTris) + sr->draw2MinTris = i; + } + else + sr->draw2Tris++; + + if(!(flags&M_DRAWDISP_ONEQUAD)) + { + i = disp2->nQuads/4; + sr->draw2Quads+=i; + if ((uns32)i > sr->draw2MaxQuads) + sr->draw2MaxQuads = i; + if (i > 0 && (uns32)i < sr->draw2MinQuads) + sr->draw2MinQuads = i; + } + else + sr->draw2Quads++; + #endif // DEBUG + + DrawResetObj(); +#if 1 + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2SETUP1); + #endif // DEBUG + // + // FLASH COLOR + // + + if(odrflags&M_OBJDISPRES_FLASHRGB) + { + // set color + glColor3ub(curodr->rgba[0],curodr->rgba[1],curodr->rgba[2]); + sr->tex=sr->curTex=0; // drop texture + if(odrflags&M_OBJDISPRES_FLASHNOLIGHT) + dispmode&=~M_RESDISPMODE_LIGHT; + glShadeModel(GL_SMOOTH); + } // flash rgb + else + { + glColor3ub(255,255,255); + } + + // + // LIGHTS + // + + if(dispmode&M_RESDISPMODE_LIGHT) + { + for(i=0,j=1;ilightMask) + { + glEnable(i+GL_LIGHT0); + lightson|=j; + } + } // for + + glEnable(GL_COLOR_MATERIAL); + +//moved this into one-time draw loop initialization +// m[0]=m[1]=m[2]=m[3]=1; +// glColorMaterial(GL_FRONT,GL_AMBIENT); +// glMaterialfv(GL_FRONT,GL_DIFFUSE,m); +// glMaterialfv(GL_FRONT,GL_AMBIENT,m); +// glMaterialfv(GL_FRONT,GL_SPECULAR,m); +// glMateriali(GL_FRONT,GL_SHININESS,128); +// glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); + + glShadeModel(GL_SMOOTH); + glEnable(GL_LIGHTING); + } // light + else + { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + } // no light + + // + // BLEND + // + + if(dispmode&M_RESDISPMODE_HASALPHA) + { + if(flags&M_DRAWDISP_ONEPASS) + goto onepass; + + if(!(VidDisp.flags&M_VIDDISP_BLEND)) + { + // fast -- drop out + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER,0.75); // one-pass + } + else if(!(flags&M_DRAWDISP_BLENDPASS)) + { + // blend -- first pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_EQUAL,1); + } + else + { + if(VidDisp.flags&M_VIDDISP_ONEPASSBLEND) + { +onepass: + // blend -- blend pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + else + { + // blend -- blend pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_LESS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + } + } // has alpha + + // + // OBJECT MODE OVERRIDES + // + + // fog off for this object + if(((dispmode&M_RESDISPMODE_DONTFOG)||(odrflags&M_OBJDISPRES_NOFOG)) + &&(VidDisp.flags&M_VIDDISP_FOG)) + glDisable(GL_FOG); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2SETUP1); + #endif // DEBUG +#endif + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2COL); + #endif // DEBUG + + // + // COLLISIONS + // + + // propcol -- uses propcol geometry -- recommended + if(odrflags&M_OBJDISPRES_PROPCOL) + { + // find propcol + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + if(o2->lnk.sub==OBJSUB_COLRES) + { + propCol(odr,(void*)o2,vm,vmscale); + + #if DEBUG + if(VidDisp.dbgcol) + { + DrawPropColDispDbg((void*)o2,vmscale); + goto drawd; // dont draw + } + #endif // DEBUG + + break; + } + } // propcol + + // dispcol -- uses display geometry + if(odrflags&M_OBJDISPRES_DISPCOL) + colDisp2(odr,disp2); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2COL); + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP2SETUP2); + #endif // DEBUG + + if (odr && curodr->dList) + { + #if DEBUG + sr->draw2Lists++; + #endif // DEBUG + sr->curTex=sr->tex; + glCallList(curodr->dList); + } + else + { + #if DEBUG + sr->draw2Basic++; + #endif // DEBUG + + bBuildList=0; + + // + // Check if we should build a new display list for this object + // We do not build display lists for the following: + // - single faces coming through from face sort + // - objects drawn with orthographic projection + // - objects that use the blend field to change transparency + // + // We have discovered that excessive deleting of display lists can + // have a negative impact the system's speed. + // + if (odr && curodr->dList == 0 + && !((flags&M_DRAWDISP_ONEQUAD) || (flags&M_DRAWDISP_ONETRI)) + && !(sr->frameflags & M_SRFRAMEFLAGS_ORTHOPROJ) + && !(odrflags&M_OBJDISPRES_BLEND)) + { + if ((curodr->dList = glGenLists(1)) != 0) + { + bBuildList=1; + glNewList(curodr->dList,GL_COMPILE_AND_EXECUTE); + drawAddDisplayList(curodr); + } + } + + // if we have a texture, set it up +// if(sr->tex && noTex) + if(sr->tex) + { + noTex=0; + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_TEX2X2) + sr->tex=VidDisp.dbg2x2; + #endif // DEBUG + + // + // Note, if we are building a display list, it is best to always + // bind the texture. This is in case we end up + + if(sr->tex != sr->curTex || bBuildList) + { + sr->curTex=sr->tex; + glBindTexture(GL_TEXTURE_2D, sr->tex); + glEnable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_FILL); + + // - if we have a 2nd texture, enable it here + + if (disp2->texGen2) + { + glActiveTexture(GL_TEXTURE1); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, disp2->texGen2); + glActiveTexture(GL_TEXTURE0); + } + + if(hasvcolors || lightson) + { + glShadeModel(GL_SMOOTH); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); + } + else + { + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); + glShadeModel(GL_FLAT); + } + + // + // FILTER / MIPMAP + // + + // mag + if(!(VidDisp.flags&M_VIDDISP_MAGFILTER)) + { + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + } + else + { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + } + + // min + if(!(VidDisp.flags&(M_VIDDISP_MINFILTER|M_VIDDISP_MIPMAP))) + { + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + } + else if((VidDisp.flags&M_VIDDISP_MIPMAP) + &&(dispmode&M_RESDISPMODE_MIPMAP)) + { + if(!(VidDisp.flags&M_VIDDISP_MINFILTER)) + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_NEAREST); + else + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + } + } + + } + else if((dispmode&M_RESDISPMODE)==RESDISPMODE_WIREFRAME) + { + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + } + else + { + glPolygonMode(GL_FRONT,GL_FILL); +// glDisable(GL_TEXTURE_2D); + } + + // wireframe override + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + { + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + } // wireframe override + +#if 0 + // + // FLASH COLOR + // + + if(odrflags&M_OBJDISPRES_FLASHRGB) + { + // set color + glColor3ub(((ObjDispRes*)odr)->rgba[0], + ((ObjDispRes*)odr)->rgba[1],((ObjDispRes*)odr)->rgba[2]); + sr->tex=sr->curTex=0; // drop texture + if(odrflags&M_OBJDISPRES_FLASHNOLIGHT) + dispmode&=~M_RESDISPMODE_LIGHT; + glShadeModel(GL_SMOOTH); + } // flash rgb + + // + // LIGHTS + // + + if(dispmode&M_RESDISPMODE_LIGHT) + { + for(i=0,j=1;ilightMask) + glEnable(i+GL_LIGHT0),lightson|=j; + } // for + + glEnable(GL_COLOR_MATERIAL); + + m[0]=m[1]=m[2]=m[3]=1; + glColorMaterial(GL_FRONT,GL_AMBIENT); + glMaterialfv(GL_FRONT,GL_DIFFUSE,m); + glMaterialfv(GL_FRONT,GL_AMBIENT,m); + glMaterialfv(GL_FRONT,GL_SPECULAR,m); + glMateriali(GL_FRONT,GL_SHININESS,128); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); + + glEnable(GL_LIGHTING); + } // light + else + { + glDisable(GL_COLOR_MATERIAL); + } // no light + + // + // BLEND + // + + if(dispmode&M_RESDISPMODE_HASALPHA) + { + if(flags&M_DRAWDISP_ONEPASS) + goto onepass; + + if(!(VidDisp.flags&M_VIDDISP_BLEND)) + { + // fast -- drop out + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER,0.75); // one-pass + } + else if(!(flags&M_DRAWDISP_BLENDPASS)) + { + // blend -- first pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_EQUAL,1); + } + else + { + if(VidDisp.flags&M_VIDDISP_ONEPASSBLEND) + { + onepass: + // blend -- blend pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + else + { + // blend -- blend pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_LESS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + } + } // has alpha +#endif + // + // OBJECT MODE OVERRIDES + // + + // object blending & tinting + if((odrflags&M_OBJDISPRES_BLEND) + && odr) + { + if(!curodr->rgba[3]) // blended out completely, invisible + goto BAIL; + + curodr->curBlend = curodr->rgba[3]; + glDepthMask(0);// dont write to depth buffer + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); + + if(disp2->qVertColors || disp2->tVertColors) + { + f1=((ObjDispRes*)odr)->rgba[3]/255.0; // alpha value to blend in + + if(tmpbuf) + { + BP(BP_DISPDRAW2); // already in use, not expected. + goto objblendd; + } + i=disp2->nQuads*4*sizeof(float); + i+=disp2->nTris*4*sizeof(float); + if((ec=MemSLow(MEMPOOL_VID,i,&tmpbuf))<0) + goto BAIL; + p=tmpbuf; + if(disp2->nQuads && disp2->qVertColors) + { + qcolors=(void*)p; + p+=disp2->nQuads*4*sizeof(float); + + // copy & blend the alpha + for(i=0,j=0;inQuads;i++) + { + qcolors[j]=((float*)disp2->qVertColors)[j]; + qcolors[j+1]=((float*)disp2->qVertColors)[j+1]; + qcolors[j+2]=((float*)disp2->qVertColors)[j+2]; + qcolors[j+3]=f1*((float*)disp2->qVertColors)[j+3]; + j+=4; + } // for + } // quads + + if(disp2->nTris && disp2->tVertColors) + { + tcolors=(void*)p; + p+=disp2->nTris*4*sizeof(float); + + // copy & blend the alpha + for(i=0,j=0;inQuads;i++) + { + tcolors[j]=((float*)disp2->tVertColors)[j]; + tcolors[j+1]=((float*)disp2->tVertColors)[j+1]; + tcolors[j+2]=((float*)disp2->tVertColors)[j+2]; + tcolors[j+3]=f1*((float*)disp2->tVertColors)[j+3]; + j+=4; + } // for + } // tris + } + else + { // verts aren't colored + + glColor4ub(255,255,255,curodr->rgba[3]); // not tinting, max out colors + } // verts aren't colored + + } // obj blend + else + odrflags&=~M_OBJDISPRES_BLEND; +objblendd: + + if (flags&M_DRAWDISP_DRAWSORTONCE) + { + // special case for big "sort once" object + if(disp2->qTexCoords) + { + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2,GL_FLOAT,drawSO.qStride,disp2->qTexCoords); + } + else + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + if(disp2->qVertColors) + { + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(3,GL_FLOAT,drawSO.qStride,disp2->qVertColors); + } + else + glDisableClientState(GL_COLOR_ARRAY); + + if((dispmode&M_RESDISPMODE_LIGHT)&&disp2->qNormals) + { + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_FLOAT,drawSO.qStride,disp2->qNormals); + } + else + glDisableClientState(GL_NORMAL_ARRAY); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3,GL_FLOAT,drawSO.qStride,disp2->qVerts); + + glDrawArrays(GL_QUADS,0,drawSO.d2BufQuads); + } + else + { + + // + // DRAW QUADS + // + + if(disp2->nQuads || (flags&M_DRAWDISP_ONEQUAD) + && !(flags&M_DRAWDISP_ONETRI)) + { + if(disp2->qTexCoords) + { + //glClientActiveTexture(GL_TEXTURE0); + //glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2,GL_FLOAT,0,disp2->qTexCoords); + + if (disp2->texGen2) + { + glClientActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE1); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2,GL_FLOAT,0,disp2->qTexCoords); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + + glClientActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); + } + } + else + { + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + if(qcolors) + { + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4,GL_FLOAT,0,qcolors); + } + else if(disp2->qVertColors) + { + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4,GL_FLOAT,0,disp2->qVertColors); + } + else + { + glDisableClientState(GL_COLOR_ARRAY); + } + + if((dispmode&M_RESDISPMODE_LIGHT)&&disp2->qNormals) + { + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_FLOAT,0,disp2->qNormals); + } + else + { + glDisableClientState(GL_NORMAL_ARRAY); + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3,GL_FLOAT,0,disp2->qVerts); + + if(!(flags&M_DRAWDISP_ONEQUAD)) + { + glDrawArrays(GL_QUADS,0,disp2->nQuads); + } + else + { + i=flags>>S_DRAWDISP_INDEX; + glDrawArrays(GL_QUADS,i,4); + } + + } // quads + + // + // DRAW TRIS + // + + if((disp2->nTris || (flags&M_DRAWDISP_ONETRI)) + && !(flags&M_DRAWDISP_ONEQUAD)) + { + if(disp2->tTexCoords) + { + //glClientActiveTexture(GL_TEXTURE0); + //glActiveTexture(GL_TEXTURE0); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2,GL_FLOAT,0,disp2->tTexCoords); + + if (disp2->texGen2) + { + glClientActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2,GL_FLOAT,0,disp2->tTexCoords); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + + glClientActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); + } + } + else + { + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + if(tcolors) + { + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4,GL_FLOAT,0,tcolors); + } + else if(disp2->tVertColors) + { + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4,GL_FLOAT,0,disp2->tVertColors); + } + else + { + glDisableClientState(GL_COLOR_ARRAY); + } + + if((dispmode&M_RESDISPMODE_LIGHT)&&disp2->tNormals) + { + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_FLOAT,0,disp2->tNormals); + } + else + { + glDisableClientState(GL_NORMAL_ARRAY); + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3,GL_FLOAT,0,disp2->tVerts); + + if(!(flags&M_DRAWDISP_ONETRI)) + { + glDrawArrays(GL_TRIANGLES,0,disp2->nTris); + } + else + { + i=flags>>S_DRAWDISP_INDEX; + glDrawArrays(GL_TRIANGLES,i,3); + } + + } // tris + + // - if we were using a 2nd texture, disable it now + + if (disp2->texGen2) + { + glActiveTexture(GL_TEXTURE1); + glDisable(GL_TEXTURE_2D); + glActiveTexture(GL_TEXTURE0); + } + } + if (bBuildList) + glEndList(); + + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + } //endif display list + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2SETUP2); + #endif // DEBUG + + glDepthMask(1); + + +#if DEBUG +drawd: +#endif // DEBUG + + // + // CLEAN UP + // + +BAIL: + + if(tmpbuf) + MemSLowSet(MEMPOOL_VID,tmpbuf); + +// glBindTexture(GL_TEXTURE_2D, 0); + + if(dispmode & M_RESDISPMODE_HASALPHA) + glDisable(GL_ALPHA_TEST); + + // undo fog off for this object + if(((dispmode&M_RESDISPMODE_DONTFOG)||(odrflags&M_OBJDISPRES_NOFOG)) + &&(VidDisp.flags&M_VIDDISP_FOG)) + glEnable(GL_FOG); + + if(lightson) + { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + for(i=0;lightson&&(i>=1) + { + if(lightson&1) + glDisable(i+GL_LIGHT0); + } // for + } // has lights + + if(!(flags&M_DRAWDISP_NOMAT)) + glPopMatrix(); + +BAILQUICK: + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP2); + #endif // DEBUG + + return; +} // DrawDisp2() + +// +// skelMats +// create the skeleton matrices for this object. +// applies current animation data to joints. +// +// in: +// out: +// global: +// +// JFL 17 Nov 04 +// JFL 03 Dec 04; cleanup +// GNP 20 Dec 05; combined joint matrix and bind matrix into one +// +int skelMats(ResDataDisp3 *disp3,ObjSkelRes *osr) +{ + int ec,i,j; + Res *r,*r2; + ResDataJoint *jt,*pt; + ResDataSkel *skel; + VMType *dst,*vm; + ObjAniRes *oar,*roar; + ObjVel *rov; + crd m2[VM_SIZE],*mtmp=NUL; + #if SAFE + float aniTime0=0; + #endif // SAFE + + if(!(r=osr->res) || (RESSUB_SKEL!=r->lnk.sub) || !(skel=r->data) + || !skel->joints) + return 0; + + roar=NUL; + rov=NUL; + if(osr->rootDriver) + { // if driver isn't present, identity matrix is used + if(((Obj*)osr->rootDriver)->lnk.sub==OBJSUB_ANIRES) + roar=osr->rootDriver; + else if(((Obj*)osr->rootDriver)->lnk.sub==OBJSUB_VEL) + rov=osr->rootDriver; + } // rootDriver + + #if SAFE + if((oar=osr->lnk.next)) + aniTime0=oar->aniTime0; + #endif // SAFE + + i=skel->numJoints*sizeof(float)*VM_SIZE; + if((ec=MemSLow(MEMPOOL_VID,i,&mtmp))<0) + goto BAIL; + + dst=(void*)osr->jointMats; + for(i=0,jt=skel->joints;inumJoints;i++,jt++,dst++) + { + // + // PARENT + // + + if(!jt->parent[0]) + { + if(roar) + { + // translate + VMSetV3(dst->a,&roar->cur[OAR_CH_TX]); + + // zyx + M3BuildRot(3+dst->a,roar->cur[OAR_CH_RZ],XYZ_Z); + M3BuildRot(m2,roar->cur[OAR_CH_RY],XYZ_Y); + M3Mpy(3+dst->a,3+dst->a,m2); + M3BuildRot(m2,roar->cur[OAR_CH_RX],XYZ_X); + M3Mpy(3+dst->a,3+dst->a,m2); + } // roar + else if(rov) + { + // translate + VMSetV3(dst->a,&rov->trans[0]); + + // zyx + M3BuildRot(3+dst->a,rov->rot[2],XYZ_Z); + M3BuildRot(m2,rov->rot[1],XYZ_Y); + M3Mpy(3+dst->a,3+dst->a,m2); + M3BuildRot(m2,rov->rot[0],XYZ_X); + M3Mpy(3+dst->a,3+dst->a,m2); + } // rov + else + VMId(dst->a); + + } // root + else + { + // find parent + vm=(void*)osr->jointMats; + for(j=0,pt=skel->joints;jnumJoints;j++,pt++,vm++) + { + if(!szcmp(jt->parent,pt->name)) + { + // start this round with parent + VMCpy((crd*)dst,(crd*)vm); + goto parentd; + } + } // for + VMId((crd*)dst); // error case + } +parentd: + + // + // ANIMATION OR JOINT + // + + for(oar=osr->lnk.next;oar->lnk.type;oar=oar->lnk.next) + { + if((oar->lnk.sub!=OBJSUB_ANIRES)||!(r2=oar->res)||szcmp(jt->name,r2->name)) + continue; + goto gotanim; + } // for + oar=NUL; +gotanim: + + if(oar) + { + // translate + VMId(m2);VMSetV3(m2,&oar->cur[OAR_CH_TX]); + VMMpy(dst->a,m2,dst->a); + + // orient + M3BuildRot(m2,jt->orient[2],XYZ_Z); + M3Mpy(3+dst->a,3+dst->a,m2); + M3BuildRot(m2,jt->orient[1],XYZ_Y); + M3Mpy(3+dst->a,3+dst->a,m2); + M3BuildRot(m2,jt->orient[0],XYZ_X); + M3Mpy(3+dst->a,3+dst->a,m2); + + // rotate + M3BuildRot(m2,oar->cur[OAR_CH_RZ],XYZ_Z); + M3Mpy(3+dst->a,3+dst->a,m2); + M3BuildRot(m2,oar->cur[OAR_CH_RY],XYZ_Y); + M3Mpy(3+dst->a,3+dst->a,m2); + M3BuildRot(m2,oar->cur[OAR_CH_RX],XYZ_X); + M3Mpy(3+dst->a,3+dst->a,m2); + } + else + { + VMMpy(dst->a,dst->a,jt->vm); + } + + } // for + + // + // old code: + // copies skeleton bind pose into object bind matrix for each joint + // +// dst=(void*)osr->bindMats; +// for(i=0,jt=skel->joints;inumJoints;i++,dst++,jt++) +// VMCpy(dst->a,jt->bps); + + // + // new code: + // concatenates skeleton bind pose with current joint matrix and stores + // into object bind matrix for each joint + // + dst=(void*)osr->bindMats; + vm=(void*)osr->jointMats; + for(i=0,jt=skel->joints;inumJoints;i++,dst++,jt++,vm++) + VMCat(dst->a,vm->a,jt->bps); + + ec=0; +BAIL: + if(mtmp) + MemSLowSet(MEMPOOL_VID,mtmp); + + return ec; +} // skelMats() + +// JFL 17 Nov 04 +int skelVerts(ResDataDisp3 *disp3,ObjSkelRes *osr, float *fpbuf,float *npbuf) +{ + int i,j,k,i3; + float *verts=disp3->verts; + float *normals=disp3->normals; + float *wp; + float w,x,y,z,nx,ny,nz; +// crd dst[3],vec[3]; + crd dst[3]; + Res *r; + ResDataSkel *skel; + VMType *vm,*vm2; + ResDataJoint *jt; + + // + // + // + + if(!(r=osr->res) || (RESSUB_SKEL!=r->lnk.sub) || !(skel=r->data) + || !skel->joints || !skel->weights) + return 0; + + i3=0; // used for adder to float* for verts + wp=skel->weights; + for(i=0;inVerts;i++) + { + x=y=z=0; + nx=ny=nz=0; + + // run through all the joints + vm=(void*)osr->jointMats; + vm2=(void*)osr->bindMats; + + k=0; + jt=skel->joints; + for(j=0;jnumJoints;j++,vm++,vm2++,jt++) + { + k++; + if(!(w=*wp++)) + continue; + + // + // old code: + // two matrices + // +// VMVecMul(vec,verts+i3,vm2->a); +// VMVecMul(dst,vec,vm->a); + + // + // new code: + // concatenated matrices + // + VMVecMul(dst,verts+i3,vm2->a); + + x+=w*dst[0]; + y+=w*dst[1]; + z+=w*dst[2]; + + if(npbuf && normals) + { + // + // old code: + // two matrices + // +// VMVecRot(vec,normals+i3,vm2->a); +// VMVecRot(dst,vec,vm->a); + + // + // new code: + // concatenated matrices + // + VMVecRot(dst,normals+i3,vm2->a); + + nx+=w*dst[0]; + ny+=w*dst[1]; + nz+=w*dst[2]; + } + } // for + + // store + fpbuf[0+i3]=x; + fpbuf[1+i3]=y; + fpbuf[2+i3]=z; + + if(npbuf) + { + // jjj -- need to normalize.. or compute each time.. or cheat.. + npbuf[0+i3]=nx; + npbuf[1+i3]=ny; + npbuf[2+i3]=nz; + } + + i3+=3; + + } // for + + return 0; +} // skelVerts() + +// JFL 25 Mar 05 +// JFL 15 Apr 05; projection fix for cols +int colDisp3(Obj *prime,ResDataDisp3 *disp3,int *ip,float *fp,float *np, + crd *rtsptrs[3]) +{ + int ec; + int ff,i,j; + float t,*vt0,*vt1,*vt2,*vt3,vta[3],vtb[3],nrm[3]; + uns8 i0,i1,i2; + float a,b,d,len,u0,v0,u1,v1,u2,v2; + int8 k; + ObjColAct *cola; + N2 *l2; + + // check if there are any objects to collide + l2=ObjL2First(OBJL2_PROJECTILE); + if(!l2->type) + err(0); // no + + if(!np) + { + BP(BP_COLDISP3); // need precalculated normals + return -1; + } + + for(i=0;inFaces;i++) + { + if(!(ff=*ip++)) + break; + + j=ip[0]*3; + vt0=fp+j; + + j=ip[3]*3; + vt1=fp+j; + + j=ip[6]*3; + vt2=fp+j; + + vta[0]=vt0[0]+vt1[0]+vt2[0]; + vta[1]=vt0[1]+vt1[1]+vt2[1]; + vta[2]=vt0[2]+vt1[2]+vt2[2]; + + if(!(ff&M_RESDISPFACE_QUAD)) + { + ip+=9; + vta[0]/=3;vta[1]/=3;vta[2]/=3; + } + else + { + j=ip[9]*3; + vt3=fp+j; + vta[0]+=vt3[0]; + vta[1]+=vt3[1]; + vta[2]+=vt3[2]; + ip+=12; + vta[0]/=4;vta[1]/=4;vta[2]/=4; + } + + for(l2=ObjL2First(OBJL2_PROJECTILE);l2->type;l2=l2->next) + { + cola=(void*)L2N2(l2); + if((t=cola->len)<=0) + continue; + + // test radius + + V3Sub(vta,vt0,vt1); + V3Sub(vtb,vt1,vt2); + V3Cross(nrm,vtb,vta); + V3Normalize(nrm); + d=-V3Dot(nrm,vt0); // plane constant + + b=V3Dot(nrm,cola->dir); + if((b-COLEPSILON)) + continue; // orthogonal + len = -(d+V3Dot(nrm,cola->pos)); + len /= b; + + if((len<0) || (len>t)) + continue; + + // intersection point of ray and plane + vta[0]=len*cola->dir[0]; + vta[0]+=cola->pos[0]; + vta[1]=len*cola->dir[1]; + vta[1]+=cola->pos[1]; + vta[2]=len*cola->dir[2]; + vta[2]+=cola->pos[2]; + + // point in poly based on Badouel + + // find dominant axis + a=nrm[0];if(a<0) a=-a; + i0=0,i1=1,i2=2; + b=nrm[1];if(b<0) b=-b; + if(a=0) && (b<=1)) + { + a=(v0-b*v2)/v1; + if((a>=0)&&((a+b)<=1)) + goto inside; + } + } + else + { + b=(v0*u1-u0*v1)/(v2*u1-u2*v1); + if((b>=0)&&(b<=1)) + { + a=(u0-b*u2)/u1; + if((a>=0)&&((a+b)<=1)) + goto inside; + } + + } + + if(k) + { + k=0; + vt1=vt2; + vt2=vt3; + goto trilp; + } + + + } // for -- cola + } // for -- faces + + if(0) + { +inside: + if(!cola->clen || (cola->clen>len)) + { + cola->flags&=~M_OBJCOLACT_HITFLAGS; + cola->flags|=M_OBJCOLACT_HIT|M_OBJCOLACT_HITCRITCOL; + cola->cpos[0]=vta[0]; + cola->cpos[1]=vta[1]; + cola->cpos[2]=vta[2]; + cola->cnrm[0]=nrm[0]; + cola->cnrm[1]=nrm[1]; + cola->cnrm[2]=nrm[2]; + cola->clen=len; + cola->cobj=prime; + cola->cnum=0; + cola->cdata=disp3->atBuf; // jjj -- check this out -- watch + cola->cjointnum=0; + } + } // inside + + ec=0; +BAIL: + return ec; +} // colDisp3() + +// JFL 31 Mar 05 +// JFL 15 Apr 05; projection fix for cols +// JFL 14 Jul 05 +int skelCol(Obj *prime,ResDataDisp3 *disp3,ObjSkelRes *osr, + ObjColRes *ocr,crd *rtsptrs[3]) +{ + int i,ec; + ResDataCol *rdc; + ResDataCBXYZR *xyzr; + VMType *vm,*vm2; + VMType vmi, vmrts; +// crd *vrt,vt0[3],vt1[3],vt2[3],vec[3],vta[3],vtb[3],nrm[3],nre[3]; + crd *vrt,vt0[3],vt1[3],vt2[3],vec[3],vta[3],vtb[3],nrm[3],nre[3]; + ObjColAct *cola; + N2 *l2; + float t; + float a,b,d,len; + ResDataCBTri *poly; + Res *r; + uns bRTS; + + + if(!(r=ocr->res)||!(rdc=r->data)) + berr(-1); + if(rdc->type!=RESDATACOLTYPE_SKEL) + berr(-2); + + // check if there are any objects to collide + l2=ObjL2First(OBJL2_PROJECTILE); + if(!l2->type) + err(0); // no + + // check if there are valid RTS pointers. + // this means there is added RTS likely from + // the velocity node. we must use it if + // it exists. + if (rtsptrs[0] || rtsptrs[1] || rtsptrs[2]) + { + VMBuildObj(vmrts.a,rtsptrs[0],rtsptrs[1],rtsptrs[2]); + bRTS=1; + } + else + bRTS=0; + + // run through all projectiles + for(l2=ObjL2First(OBJL2_PROJECTILE);l2->type;l2=l2->next) + { + cola=(void*)L2N2(l2); + if((t=cola->len)<0) + continue; + + // run through all the blocks (these are geo sets) + for(xyzr=rdc->blocks;xyzr->blk.type;xyzr++) + { + // find matrix for this block + vm2=(void*)osr->bindMats; + + if(xyzr->jointNum>=osr->numJoints) + { + BP(BP_SKELCOL); + break; + } + vm2+=xyzr->jointNum; + + // jjj -- use rtsptrs[] + + // translate collision sphere + if (bRTS) + { + VMVecMul(vec,xyzr->xyzr,vm2->a); + VMVecMul(vt0,vec,vmrts.a); + } + else + VMVecMul(vt0,xyzr->xyzr,vm2->a); + + // d = distance between + d=cola->pos[0]-vt0[0]; + d*=d; + a=cola->pos[1]-vt0[1]; + a*=a; + d+=a; + a=cola->pos[2]-vt0[2]; + a*=a; + d+=a; + d=MathFastSqrt(d); + if(d>(t+xyzr->xyzr[3])) + continue; + + poly = (void*)(((uns8*)rdc->polys) + xyzr->off); + for(i=0;*((int*)poly->v[0].vrt)!=FLOAT_NAN;poly++,i++) + { + // + // vert weighting & transform + // + + vrt=poly->v[0].vrt; + if (bRTS) + { + VMVecMul(vec,vrt,vm2->a); + VMVecMul(vt0,vec,vmrts.a); + } + else + VMVecMul(vt0,vrt,vm2->a); + + vrt=poly->v[1].vrt; + if (bRTS) + { + VMVecMul(vec,vrt,vm2->a); + VMVecMul(vt1,vec,vmrts.a); + } + else + VMVecMul(vt1,vrt,vm2->a); + + vrt=poly->v[2].vrt; + if (bRTS) + { + VMVecMul(vec,vrt,vm2->a); + VMVecMul(vt2,vec,vmrts.a); + } + else + VMVecMul(vt2,vrt,vm2->a); + + // + // normal & plane k + // + + V3Sub(vta,vt0,vt1); + V3Sub(vtb,vt1,vt2); + V3Cross(nrm,vta,vtb); + V3UnitizeFast(nrm,1); + + // compute intersection with plane + b=V3Dot(nrm,cola->dir); // plane constant + if((b-COLEPSILON)) + continue; // orthogonal + d=V3Dot(nrm,vt0); // plane constant + len=(d-V3Dot(nrm,cola->pos))/b; + if((len<0)||(len>t)) + continue; // behind or too far + + // intersection point of ray and plane + vta[0]=len*cola->dir[0]; + vta[0]+=cola->pos[0]; + vta[1]=len*cola->dir[1]; + vta[1]+=cola->pos[1]; + vta[2]=len*cola->dir[2]; + vta[2]+=cola->pos[2]; + + // + // find & test against edge's normal + // + + // edge + V3Sub(vtb,vt0,vt1); + V3Cross(nre,vtb,nrm); + V3Sub(vtb,vt0,vta); // ray -- colpoint to vert + if((b=V3Dot(vtb,nre))>0) + goto outside; + + // edge + V3Sub(vtb,vt1,vt2); + V3Cross(nre,vtb,nrm); + V3Sub(vtb,vt1,vta); // ray -- colpoint to vert + if((b=V3Dot(vtb,nre))>0) + goto outside; + + // edge + V3Sub(vtb,vt2,vt0); + V3Cross(nre,vtb,nrm); + V3Sub(vtb,vt2,vta); // ray -- colpoint to vert + if(V3Dot(vtb,nre)<=0) + goto inside; + +outside: + if(0) + { +inside: + // collision -- check if it's first or better + if(!cola->clen || (cola->clen>len)) + { + cola->clen=len; + cola->flags&=~M_OBJCOLACT_HITFLAGS; + cola->flags|=M_OBJCOLACT_HIT|M_OBJCOLACT_HITSKELCOL; + cola->cpos[0]=vta[0]; + cola->cpos[1]=vta[1]; + cola->cpos[2]=vta[2]; + cola->cnrm[0]=nrm[0]; + cola->cnrm[1]=nrm[1]; + cola->cnrm[2]=nrm[2]; + cola->cobj=prime; + cola->cdata=xyzr->colName; + cola->cnum=xyzr->colNum; + cola->cjointnum=xyzr->jointNum; + + // find joint matrix of part hit + vm=(void*)osr->jointMats; + vm+=cola->cjointnum; + + // invert mat & find col point in model space + VMInv(vmi.a,vm->a); + VMVecMul(cola->cjointoff,cola->cpos,vmi.a); // col point + + + } // setcol + } // inside + } // for polys + } // for blocks + } // for projectiles + + ec=0; +BAIL: + return ec; +} // skelCol() + +#if DEBUG // ------------------------------------------------------------------ + +void DrawPosDirDbg(crd *pos,crd *dir) +{ +#define A 0.2 + glColor3ub(0,0,255); + glBegin(GL_LINE_STRIP); + glVertex3f(pos[0]-A,pos[1],pos[2]); + glVertex3f(pos[0]+A,pos[1],pos[2]); + glEnd(); + + glColor3ub(255,255,255); + glBegin(GL_LINE_STRIP); + glVertex3f(pos[0],pos[1],pos[2]); + glVertex3f(pos[0]+dir[0],pos[1]+dir[1],pos[2]+dir[2]); + glEnd(); + +} // DrawPosDirDbg() + +// JFL 31 Mar 05 +int DrawSkelColDispDbg(Obj *prime,ResDataDisp3 *disp3,ObjSkelRes *osr, + ObjColRes *ocr) +{ + int ec; + int i; + ResDataCol *rdc; + ResDataCBXYZR *xyzr; + VMType *vm,*vm2; +// crd *vrt,dst[3],vec[3],vt0[3],vt1[3],vt2[3]; + crd *vrt,dst[3],vt0[3],vt1[3],vt2[3]; + crd vta[3],vtb[3],nrm[3],*v0,*v1; + ResDataCBTri *poly; + Res *r; + + if(!(r=ocr->res)||!(rdc=r->data)) + berr(-1); + if(rdc->type!=RESDATACOLTYPE_SKEL) + berr(-2); + + if(!(VidDisp.dbgcol&M_VIDDISP_DBGCOL_SKELCOL)) + err(1); + if(VidDisp.dbgcol&M_VIDDISP_DBGCOL_WIRE) + glPolygonMode(GL_FRONT,GL_LINE); + else + glPolygonMode(GL_FRONT,GL_FILL); + + // run through all the blocks (these are geo sets) + for(xyzr=rdc->blocks;xyzr->blk.type;xyzr++) + { + // find matrix for this block + vm=(void*)osr->jointMats; + vm2=(void*)osr->bindMats; + + if(xyzr->jointNum>=osr->numJoints) + { + BP(BP_DRAWSKELCOLDISPDBG); + break; + } + vm+=xyzr->jointNum; + vm2+=xyzr->jointNum; + + // + // old code: + // two matrices + // +// VMVecMul(vec,xyzr->xyzr,vm2->a); +// VMVecMul(dst,vec,vm->a); + + // + // new code: + // concatenated matrices + // + VMVecMul(dst,xyzr->xyzr,vm2->a); + + poly = (void*)(((uns8*)rdc->polys) + xyzr->off); + for(i=0;*((int*)poly->v[0].vrt)!=FLOAT_NAN;poly++,i++) + { + // vert weighted transform + vrt=poly->v[0].vrt; + //old +// VMVecMul(vec,vrt,vm2->a); +// VMVecMul(vt0,vec,vm->a); + //new + VMVecMul(vt0,vrt,vm2->a); + + vrt=poly->v[1].vrt; + //old +// VMVecMul(vec,vrt,vm2->a); +// VMVecMul(vt1,vec,vm->a); + //new + VMVecMul(vt1,vrt,vm2->a); + + vrt=poly->v[2].vrt; + //old +// VMVecMul(vec,vrt,vm2->a); +// VMVecMul(vt2,vec,vm->a); + //new + VMVecMul(vt2,vrt,vm2->a); + + if(0) + { + glColor3ub(0,255,0); + glPolygonMode(GL_FRONT,GL_FILL); + } + else + { + glColor3ub(255,255,255); + glPolygonMode(GL_FRONT,GL_LINE); + } + + glBegin(GL_TRIANGLES); + glVertex3f(vt0[0],vt0[1],vt0[2]); + glVertex3f(vt1[0],vt1[1],vt1[2]); + glVertex3f(vt2[0],vt2[1],vt2[2]); + glEnd(); + + if(!(VidDisp.dbgcol&M_VIDDISP_DBGCOL_FULL)) + continue; + + // calc normal + V3Sub(vta,vt0,vt1); + V3Sub(vtb,vt1,vt2); + V3Cross(nrm,vta,vtb); + V3Unitize(nrm,0.3); + + vta[0]=(vt0[0]+vt1[0]+vt2[0])/3.0f; + vta[1]=(vt0[1]+vt1[1]+vt2[1])/3.0f; + vta[2]=(vt0[2]+vt1[2]+vt2[2])/3.0f; + + glColor3ub(128,128,128); + glBegin(GL_LINE_STRIP); + glVertex3f(vta[0],vta[1],vta[2]); + glVertex3f(vta[0]+nrm[0],vta[1]+nrm[1],vta[2]+nrm[2]); + glEnd(); + + // edges + + v0=vt0; + v1=vt1; + V3Sub(vtb,v0,v1); + V3Cross(vta,vtb,nrm); + V3UnitizeFast(vta,0.3); + glColor3ub(255,0,0); + glBegin(GL_LINE_STRIP); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(v0[0]+vta[0],v0[1]+vta[1],v0[2]+vta[2]); + glEnd(); + + v0=vt1; + v1=vt2; + V3Sub(vtb,v0,v1); + V3Cross(vta,vtb,nrm); + V3UnitizeFast(vta,0.3); + glColor3ub(0,255,0); + glBegin(GL_LINE_STRIP); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(v0[0]+vta[0],v0[1]+vta[1],v0[2]+vta[2]); + glEnd(); + + v0=vt2; + v1=vt0; + V3Sub(vtb,v0,v1); + V3Cross(vta,vtb,nrm); + V3UnitizeFast(vta,0.3); + glColor3ub(0,0,255); + glBegin(GL_LINE_STRIP); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(v0[0]+vta[0],v0[1]+vta[1],v0[2]+vta[2]); + glEnd(); + + } // for + } // for + + ec=0; +BAIL: + return ec; +} // DrawSkelColDispDbg() +#endif // DEBUG --------------------------------------------------------------- + +// JFL 17 Nov 04 +// JFL 17 May 05; flash +// GNP 20 Dec 05; optimizations - skeleton matrix ops, LODs, drawarrays +void DrawDisp3(StateRec *sr,Obj *odr,ResDataDisp3 *disp3,uns flags) +{ + int ec; + crd m[16],vma[VM_SIZE],vmb[VM_SIZE]; + uns8 quads=0,tris=0,pushmat=0; + float *fp,*fpbuf=NUL; + float *np,*npbuf=NUL; + float *dArray=NUL, *dap; + uns bStride; + int *ip,f,i,j; +// float u,v,x,y,z; + float z; + VMType *vm; + Obj *o2,*o3; + ObjSkelRes *osr=NUL; + ObjVel *ov; + ObjLOD *olod; + float a; + crd *rtsptrs[3]; + uns lightson,odrflags,dispmode; + void *d; + Res *r; + char *name; + ObjDispRes *curodr; +#if DEBUG + uns32 nTris,nQuads; +#endif //DEBUG + + #if !CRD_IS_FLOAT + #error -- crd type assumed float in this routine + #endif + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3); + #endif // DEBUG + + name=NUL; + curodr = (ObjDispRes*)odr; + if(odr && ((ObjDispRes*)odr)->res) + name=((Res*)((ObjDispRes*)odr)->res)->name; + + if(!disp3->nVerts || !disp3->nFaces) + goto BAILQUICK; + if(!disp3->verts || !disp3->faces) + goto BAILQUICK; + + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_NODISP3) + goto BAILQUICK; + #endif // DEBUG + + // -- no more easy returns -- + + // load up + lightson=0; // bits on signal that light has been enabled + if(odr) + odrflags=((ObjDispRes*)odr)->flags; + else + odrflags=0; + + // + // get LOD record, if it exists + // + if (curodr->flags & M_OBJDISPRES_HASLOD) + olod=ObjFindLOD(curodr); + else + olod=NUL; + + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_LOD) + { + if(olod) + disp3 = olod->curDispRes; + } + #endif // DEBUG + + dispmode=disp3->mode; + + // if there are no lights yet, drop the dispmode bit + dispmode|=M_RESDISPMODE_LIGHT; // all disp3's have lights by default + if(!(sr->frameflags&M_SRFRAMEFLAGS_HASLIGHTS) + ||(odrflags&M_OBJDISPRES_DONTLIGHT)) + dispmode&=~M_RESDISPMODE_LIGHT; + + // copy texture if there is one + sr->tex=disp3->texGen; + + // + // Special case for shadowed objects- + // their matrices must be calculated and saved for the shadow draw + // routine. after calculating matrices the object will be added + // to a list and drawn later, after the shadows + // + if(odrflags&M_OBJDISPRES_AFTERSHADOWS) // wait to draw till after shadows + { + osr=NUL; + if(!(flags&M_DRAWDISP_AFTERSHADOWS)) // not after shadows + { + // scan kids for skel + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_SKELRES) + { // skel + + // if this object has LODs then we are going to force a swap + // of the skeleton here + if(olod) + ((ObjSkelRes*)o2)->res = olod->curSkelRes; + + // create/animate the mats + osr=(void*)o2; + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3MATRIX); + #endif // DEBUG + ec=skelMats(disp3,osr); + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3MATRIX); + #endif // DEBUG + if(ec<0) + goto BAIL; + break; + } // skel + } // for + + if(osr && (odrflags&M_OBJDISPRES_SAVE)) + { + VMType *vmb,*vmd; + + // find save node + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_DISPSAVE) + { + i=osr->numJoints; + if(i>((ObjDispSave*)o2)->numJoints) + i=((ObjDispSave*)o2)->numJoints; + if(i && ((ObjDispSave*)o2)->jointMats) + { + ((ObjDispSave*)o2)->flags|=M_OBJDISPSAVE_SET; + + // the bindMats points to the current total object matrices for this frame + vmb=(void*)osr->bindMats; + vmd=(void*)((ObjDispSave*)o2)->jointMats; + while(i-->0) + { + VMCpy(vmd->a,vmb->a); + vmb++; + vmd++; + } // while + } + break; // use first only + } // dispsave + } // for + } // save + + if(((ObjDispRes*)odr)->flags&M_OBJDISPRES_HASTMPLINK) + { + o2=(void*) (1+((ObjDispRes*)odr)); // ObjTmpLink + if((o2->lnk.type==N2TYPE_OBJ)&&(o2->lnk.sub==OBJSUB_TMPLINK)) + N2LinkBefore(&sr->afterShadList,o2); + } + goto BAIL; + } // not after shadows + } // after shadows + + // expand matrix + glPushMatrix(); + pushmat=1; + + // + // VEL OBJECT + // + + rtsptrs[0]=rtsptrs[1]=rtsptrs[2]=NUL; + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_VEL) + { + ov=(void*)o2; + if(ov->flags&M_OBJVEL_IGNORE) + continue; // driving something else, ignore it + + if(ov->flags&M_OBJVEL_OFF) + goto BAIL; // don't draw + rtsptrs[0]=ov->rot; + rtsptrs[1]=ov->trans; + + glTranslatef(ov->trans[0],ov->trans[1],ov->trans[2]); + if(ov->rot[2]) + a=RAD2DEG(ov->rot[2]),glRotatef(a,0,0,1); + if(ov->rot[1]) + a=RAD2DEG(ov->rot[1]),glRotatef(a,0,1,0); + if(ov->rot[0]) + a=RAD2DEG(ov->rot[0]),glRotatef(a,1,0,0); + if(ov->flags&M_OBJVEL_SCALE) + { + if(!ov->scale[0]&&!ov->scale[1]&&!ov->scale[2]) + goto BAIL; // dont draw + rtsptrs[2]=ov->scale; + glScalef(ov->scale[0],ov->scale[1],ov->scale[2]); + } + break; + } // vel + } // for + + // + // SKEL OBJECT + // + + // scan kids for skel + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_SKELRES) + { // skel + + // if this object has LODs then we are going to force a swap + // of the mesh and skeleton here + if(olod) + { + ((ObjSkelRes*)o2)->res = olod->curSkelRes; + disp3 = olod->curDispRes; + } + + // alloc tmp buf + i=3*sizeof(float)*disp3->nVerts; + if(disp3->normals) + i*=2; + if((ec=MemSLow(MEMPOOL_VID,i,&fpbuf))<0) + goto BAIL; + if(disp3->normals) + npbuf=&fpbuf[3*disp3->nVerts]; + + // + // if this object is an AFTERSHADOWS object and this is the + // AFTERSHADOWS pass, then we do NOT need to re-calculate the + // skeleton matrices. They have already been done. + // + if(!(odrflags&M_OBJDISPRES_AFTERSHADOWS) + || !(flags&M_DRAWDISP_AFTERSHADOWS)) + { + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3MATRIX); + #endif // DEBUG + ec=skelMats(disp3,(ObjSkelRes*)o2); + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3MATRIX); + #endif // DEBUG + // create/animate the mats + if(ec<0) + goto BAIL; + } + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3WEIGHT); + #endif // DEBUG + + ec=skelVerts(disp3,(ObjSkelRes*)o2,fpbuf,npbuf); + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3WEIGHT); + #endif // DEBUG + // run through + if(ec<0) + goto BAIL; + + // check if there is a collision + if(odrflags&M_OBJDISPRES_SKELCOL) + { + // find skelcol + for(o3=N2KIDLIST(odr)->next;o3->lnk.type;o3=o3->lnk.next) + if(o3->lnk.sub==OBJSUB_COLRES) + { + #if DEBUG + if(VidDisp.dbgcol) + DrawSkelColDispDbg(odr,disp3,(ObjSkelRes*)o2, + (ObjColRes*)o3); + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3COL); + #endif // DEBUG + skelCol(odr,disp3,(ObjSkelRes*)o2,(ObjColRes*)o3,rtsptrs); + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3COL); + #endif // DEBUG + break; + } + + } // skelcol + + osr=(void*)o2; + + break; + } // skel + } // for + + // + // SAVE DISP INFO + // if this is an AFTERSHADOWS object, it's info is already saved + // + if(!(odrflags&M_OBJDISPRES_AFTERSHADOWS)) // check that it is not AFTERSHADOWS object + { + if(odrflags&M_OBJDISPRES_SAVE) + { + // find save node + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_DISPSAVE) + { + VMType *vmb,*vmd; + i=osr->numJoints; + if(i>((ObjDispSave*)o2)->numJoints) + i=((ObjDispSave*)o2)->numJoints; + if(i && ((ObjDispSave*)o2)->jointMats) + { + ((ObjDispSave*)o2)->flags|=M_OBJDISPSAVE_SET; + + // new code: + // concatenated joint and bind matrices + vmb=(void*)osr->bindMats; + vmd=(void*)((ObjDispSave*)o2)->jointMats; + while(i-->0) + { + VMCpy(vmd->a,vmb->a); + vmb++; + vmd++; + } // while + } + break; + } // dispsave + } // for + } // save + } //!AFTERSHADOWS + + // + // DRAW JOINTS + // +#if 0 + if(osr) + { + VMType *vm2; + + vm2=(void*)osr->bindMats; + for(i=0,vm=(void*)osr->jointMats;inumJoints;i++,vm++,vm2++) + { + if(VidDisp.flags&M_VIDDISP_JOINTS) + { + glPushMatrix(); + + M4SetVM(m,(crd*)vm); + glMultMatrixf(m); + + xVidDraw(VIDDRAW_JOINT,0.5); + + glPopMatrix(); + } + + if(0 && (VidDisp.flags&M_VIDDISP_NUBS)) + { + glPushMatrix(); + + M4SetVM(m,(crd*)vm2); + glMultMatrixf(m); + + xVidDraw(VIDDRAW_NUB,0.5); + + glPopMatrix(); + } + } // for + } // osr +#endif + + // + // PREP COLOR, LIGHTS, TEXTURE + // + + #if DEBUG + // At this point, we know this object is going + // to be drawn so this is a great place to do some + // accounting. + sr->draw3++; + nTris=nQuads=0; + #endif // DEBUG + + DrawResetObj(); + + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_NODISP3B) + goto BAIL; + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3SETUP1); + #endif // DEBUG + + // + // FLASH COLOR + // + + if(odrflags&M_OBJDISPRES_FLASHRGB) + { + glColor3ub(curodr->rgba[0],curodr->rgba[1],curodr->rgba[2]); + sr->tex=sr->curTex=0; // drop texture + if(odrflags&M_OBJDISPRES_FLASHNOLIGHT) + dispmode&=~M_RESDISPMODE_LIGHT; + glShadeModel(GL_SMOOTH); + } // flash rgb + else + { + glColor3ub(255,255,255); + } + + // + // LIGHTS + // + + if(dispmode&M_RESDISPMODE_LIGHT) + { + for(i=0,j=1;ilightMask) + { + glEnable(i+GL_LIGHT0); + lightson|=j; + } + } // for + + glEnable(GL_COLOR_MATERIAL); + +//moved this into one-time draw loop initialization +// m[0]=m[1]=m[2]=m[3]=1; +// glColorMaterial(GL_FRONT,GL_AMBIENT); +// glMaterialfv(GL_FRONT,GL_DIFFUSE,m); +// glMaterialfv(GL_FRONT,GL_AMBIENT,m); +// glMaterialfv(GL_FRONT,GL_SPECULAR,m); +// glMateriali(GL_FRONT,GL_SHININESS,128); +// glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); + + glShadeModel(GL_SMOOTH); + glEnable(GL_LIGHTING); + } // light + else + { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + glShadeModel(GL_FLAT); + } // no light + + // + // TEXTURE + // + + if(sr->tex) + { + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_TEX2X2) + sr->tex=VidDisp.dbg2x2; + #endif // DEBUG + + if (sr->tex != sr->curTex) + { + sr->curTex = sr->tex; + glBindTexture(GL_TEXTURE_2D, sr->tex); + glEnable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_FILL); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); + + // + // FILTER / MIPMAP + // + + // mag + if(!(VidDisp.flags&M_VIDDISP_MAGFILTER)) + { + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + } + else + { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + } + + // min + if(!(VidDisp.flags&(M_VIDDISP_MINFILTER|M_VIDDISP_MIPMAP))) + { + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + } + else if((VidDisp.flags&M_VIDDISP_MIPMAP) + &&(dispmode&M_RESDISPMODE_MIPMAP)) + { + // these all + if(!(VidDisp.flags&M_VIDDISP_MINFILTER)) + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_NEAREST); + else + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + } + } + } + else if((dispmode&M_RESDISPMODE)==RESDISPMODE_WIREFRAME) + { + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + } + else + { + glPolygonMode(GL_FRONT,GL_FILL); + glDisable(GL_TEXTURE_2D); + } + + // + // BLEND + // + + if(dispmode&M_RESDISPMODE_HASALPHA) + { + if(!(VidDisp.flags&M_VIDDISP_BLEND)) + { + // fast -- drop out + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER,0.75); // one-pass + } + else if(!(flags&M_DRAWDISP_BLENDPASS)) + { + // blend -- first pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_EQUAL,1); + } + else + { + if(VidDisp.flags&M_VIDDISP_ONEPASSBLEND) + { + // blend -- blend pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + else + { + // blend -- blend pass + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_LESS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + } + } // has alpha + + // + // OBJECT MODE OVERRIDES + // + + // object blending & tinting + if((odrflags&M_OBJDISPRES_BLEND) + && odr + && (((ObjDispRes*)odr)->rgba[3]!=255)) + { + if(!((ObjDispRes*)odr)->rgba[3]) // blended out completely, invisible + goto BAIL; + + glDepthMask(0);// dont write to depth buffer + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4ub(255,255,255,((ObjDispRes*)odr)->rgba[3]); // not tinting, max out colors + + // the next step is to copy & adjust vert color buf as in draw disp2 + + } // obj blend + + // fog off for this object + if(((dispmode&M_RESDISPMODE_DONTFOG)||(odrflags&M_OBJDISPRES_NOFOG)) + &&(VidDisp.flags&M_VIDDISP_FOG)) + glDisable(GL_FOG); + + // wireframe override + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + { + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + } // wireframe override + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3SETUP1); + #endif // DEBUG + + // + // + // + + ip=disp3->faces; // (int)vert-index, (float)u, (float)v + fp=disp3->verts; + np=disp3->normals; + if(fpbuf) + fp=fpbuf; + if(npbuf) + np=npbuf; + + // it's more efficient to use M_OBJDISPRES_DISPCOL + if(!(odrflags&M_OBJDISPRES_SKELCOL)) + colDisp3(odr,disp3,ip,fp,np,rtsptrs); + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3SETUP2); + #endif // DEBUG + + #if DEBUG + if(VidDisp.dbgcol && (odrflags&M_OBJDISPRES_SKELCOL)) + goto drawattached; + #endif // DEBUG + +#if 1 + // create and fill draw array + // object should be either all tris or all quads + if(*ip&M_RESDISPFACE_TRI) + { + // set-up for tris + tris=1; + i=3; + } + else + { + // set-up for quads + quads=1; + i=4; + } + + // calculate size for buffer + bStride=RESFLOATSPER_VERT+RESFLOATSPER_TEXCOORD; + if (np) + bStride += RESFLOATSPER_NORMAL; + bStride *= sizeof(float); + j = disp3->nFaces * i * bStride; + + // allocate buffer + if(MemSLow(MEMPOOL_VID,j,&dArray)>=0) + { + int k; + uns nVerts=0; + dap=dArray; + if (tris) + { + // build array of triangles + for(i=0;inFaces;i++) + { + if(!(f=*ip++)) + break; + if(f&M_RESDISPFACE_QUAD) + { + BP(BP_UNASSIGNED); + ip+=3*4; + continue; + } + #if DEBUG + nTris++; + #endif + nVerts+=3; + if (np) + { + // with normals + for (k=0;k<3;k++) + { + j=ip[0]*3; + #if 0 // try this using registers + //uv + u=((float*)ip)[1]; + v=((float*)ip)[2]; + //normal + n0=np[j+0]; + n1=np[j+1]; + n2=np[j+2]; + //vert + x=fp[j+0]; + y=fp[j+1]; + z=fp[j+2]; + *dap++=u; + *dap++=v; + //normal + *dap++=n0; + *dap++=n1; + *dap++=n2; + //vert + *dap++=x; + *dap++=y; + *dap++=z; + #else + //uv + *dap++=((float*)ip)[1]; + *dap++=((float*)ip)[2]; + //normal + *dap++=np[j+0]; + *dap++=np[j+1]; + *dap++=np[j+2]; + //vert + *dap++=fp[j+0]; + *dap++=fp[j+1]; + *dap++=fp[j+2]; + #endif + ip+=3; + } + } + else + { + // without normals + for (k=0;k<3;k++) + { + j=ip[0]*3; + #if 0 //try this using registers + //uv + u=((float*)ip)[1]; + v=((float*)ip)[2]; + //vert + x=fp[j+0]; + y=fp[j+1]; + z=fp[j+2]; + //uv + *dap++=u; + *dap++=v; + //vert + *dap++=x; + *dap++=y; + *dap++=z; + #else + //uv + *dap++=((float*)ip)[1]; + *dap++=((float*)ip)[2]; + //normal + *dap++=np[j+0]; + *dap++=np[j+1]; + *dap++=np[j+2]; + //vert + *dap++=fp[j+0]; + *dap++=fp[j+1]; + *dap++=fp[j+2]; + #endif + ip+=3; + } + } + } //for + } //tris + else + { + // build array of quads + for(i=0;inFaces;i++) + { + if(!(f=*ip++)) + break; + if(f&M_RESDISPFACE_TRI) + { + BP(BP_UNASSIGNED); // tri in the midst of quads + ip+=3*3; + continue; + } + #if DEBUG + nQuads++; + #endif + nVerts+=4; + if (np) + { + // with normals + for (k=0;k<4;k++) + { + j=ip[0]*3; + //uv + *dap++=((float*)ip)[1]; + *dap++=((float*)ip)[2]; + //normal + *dap++=np[j+0]; + *dap++=np[j+1]; + *dap++=np[j+2]; + //vert + *dap++=fp[j+0]; + *dap++=fp[j+1]; + *dap++=fp[j+2]; + ip+=3; + } + } + else + { + // without normals + for (k=0;k<4;k++) + { + j=ip[0]*3; + //uv + *dap++=((float*)ip)[1]; + *dap++=((float*)ip)[2]; + //vert + *dap++=fp[j+0]; + *dap++=fp[j+1]; + *dap++=fp[j+2]; + ip+=3; + } + } + } //for + } //quads + + // draw the dang thing + dap=dArray; + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(RESFLOATSPER_TEXCOORD,GL_FLOAT,bStride,dap); + dap += RESFLOATSPER_TEXCOORD; + if(np) + { + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_FLOAT,bStride,dap); + dap += RESFLOATSPER_NORMAL; + } + else + glDisableClientState(GL_NORMAL_ARRAY); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(RESFLOATSPER_VERT,GL_FLOAT,bStride,dap); + + if(tris) + glDrawArrays(GL_TRIANGLES,0,nVerts); + else + glDrawArrays(GL_QUADS,0,nVerts); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + if(np) + glDisableClientState(GL_NORMAL_ARRAY); + + MemSLowSet(MEMPOOL_VID,dArray); + } //dArray + else + { + BP(BP_UNASSIGNED); + SysLog("DrawDisp3: could not allocate vert array of size %d\n",j); + } +#else + for(i=0;inFaces;i++) + { + if(!(f=*ip++)) + break; + if(f&M_RESDISPFACE_TRI) + { + #if DEBUG + nTris++; + #endif // DEBUG + if(!tris) + { + if(quads) + glEnd(); + quads=0; + glBegin(GL_TRIANGLES); + tris=1; + } + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; // vert-index, u, v + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; + } + else if(f&M_RESDISPFACE_QUAD) + { + #if DEBUG + nQuads++; + #endif // DEBUG + + if(!quads) + { + if(tris) + glEnd(); + tris=0; + glBegin(GL_QUADS); + quads=1; + } + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; + + j=ip[0]*3; + if(np) + { + x=np[j+0],y=np[j+1],z=np[j+2]; + glNormal3f(x,y,z); + } + x=fp[j+0];y=fp[j+1];z=fp[j+2]; + u=((float*)ip)[1]; + v=((float*)ip)[2]; + glTexCoord2f(u,v); + glVertex3f(x,y,z); + ip+=3; + + } + else + { + BP(BP_DISPDRAW3); + break; + } + } // for + + if(quads||tris) + glEnd(); +#endif + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3SETUP2); + #endif // DEBUG + +#if DEBUG + //Accounting + sr->draw3Tris+=nTris; + if (nTris > sr->draw3MaxTris) + sr->draw3MaxTris = nTris; + if (nTris > 0 && (nTris < sr->draw3MinTris || sr->draw3MinTris==0)) + sr->draw3MinTris = nTris; + + sr->draw3Quads+=nQuads; + if (nQuads > sr->draw3MaxQuads) + sr->draw3MaxQuads = nQuads; + if (nQuads > 0 && (nQuads < sr->draw3MinQuads || sr->draw3MinQuads == 0)) + sr->draw3MinQuads = nQuads; + + if (nTris && nQuads) + sr->draw3Mixed++; +#endif //DEBUG + + // + // DRAW ATTACHED + // +#if DEBUG +drawattached: +#endif // DEBUG + for(o2=N2KIDLIST(odr)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_VEL) + { + ov=(void*)o2; + + if(ov->flags&M_OBJVEL_OFF) + goto BAIL; // don't draw + if(!(ov->flags&M_OBJVEL_JOINTATTACH)) + continue; // driving something else, ignore it + + DrawResetObj(); + glPushMatrix(); // --- push mat --- + + // + // add in joint matrix + // + + vm=(void*)osr->jointMats; + vm+=ov->attachNum; + + M4SetVM(m,(crd*)vm); + glMultMatrixf(m); + + glTranslatef(ov->trans[0],ov->trans[1],ov->trans[2]); + if(ov->rot[2]) + a=RAD2DEG(ov->rot[2]),glRotatef(a,0,0,1); + if(ov->rot[1]) + a=RAD2DEG(ov->rot[1]),glRotatef(a,0,1,0); + if(ov->rot[0]) + a=RAD2DEG(ov->rot[0]),glRotatef(a,1,0,0); + if(ov->flags&M_OBJVEL_SCALE) + glScalef(ov->scale[0],ov->scale[1],ov->scale[2]); + + // this loop determines what can be drawn + // and needs to be expanded when disp2 or disp3 objs + // are attached + for(o3=N2KIDLIST(ov)->next;o3->lnk.type;o3=o3->lnk.next) + { + switch(o3->lnk.sub) + { + case OBJSUB_DISPRES: + if(!(r=((ObjDispRes*)o3)->res)) + break; + if(!(d=r->data)) + break; + if(RESSUB_DISP2==r->lnk.sub) + { + if(((ObjDispRes*)o3)->flags & M_OBJDISPRES_ZALWAYS) + glDepthFunc(GL_ALWAYS); // always passes z test + DrawDisp2(sr,o3,d,M_DRAWDISP_DEFAULT|flags); + if(((ObjDispRes*)o3)->flags & M_OBJDISPRES_ZALWAYS) + glDepthFunc(GL_LEQUAL); // back to normal z test + } + + break; // + case OBJSUB_FUNC: + if(!(d=((ObjFunc*)o3)->func)) + break; + switch(((ObjFunc*)o3)->ftype) + { + case FTYPE_1: + (*((ftype1*)d))(); + break; + case FTYPE_2: + (*((ftype2*)d))(o3); + break; + case FTYPE_3: + (*((ftype3*)d))(o3,sr); + break; + } // switch + + break; + case OBJSUB_EMIT: + if(((ObjEmit*)o3)->flags&M_OBJEMIT_CAPTURENEXT) + { + ((ObjEmit*)o3)->flags|=M_OBJEMIT_CAPTUREVALID; + VMBuildObj(vma,rtsptrs[0],rtsptrs[1],rtsptrs[2]); + VMMpy(vmb,vm->a,vma); + if(ov->flags&M_OBJVEL_SCALE) + d=ov->scale; + else + d=NUL; + VMBuildObj(vma,ov->rot,ov->trans,d); + VMMpy(((ObjEmit*)o3)->vm,vma,vmb); + } // capture + break; + } // switch + } // for + + glPopMatrix(); // --- pop mat --- + } // vel + } // for + + + // + // if this object has LODs, then check distance and flip LOD for next frame + // + if (olod) + { +#if 0 + i=olod->cur+1; + if((i>=NUM_LOD) || (olod->lod[i].dist == 0)) + i=0; + olod->cur = i; + olod->curDispRes = olod->lod[i].dispRes; + olod->curSkelRes = olod->lod[i].skelRes; +#else + // get translation of animation driver + if (!rtsptrs[1]) + DrawPos(rtsptrs,NULL,(void*)odr,M_DRAWPOS_DSTRTSP); + + if (rtsptrs[1] && sr->ocam) + { + z=V3DistFast(sr->ocam->trans,rtsptrs[1]); + + for (i=0;ilod[i].dist == 0) + { + // no LOD at this level, backup + i-=1; + break; + } + if (z <= olod->lod[i].dist) + { + // this is the correct LOD level + break; + } + } + if (i!=-1) + { + if (i>=NUM_LOD) + i=NUM_LOD; + if (i!=olod->cur) + { + // switch to new LOD level + olod->cur = i; + olod->curDispRes = olod->lod[i].dispRes; + olod->curSkelRes = olod->lod[i].skelRes; + } + } + } +#endif + } + +BAIL: + // + // CLEAN UP + // + + if(fpbuf) + MemSLowSet(MEMPOOL_VID,fpbuf); + +// glBindTexture(GL_TEXTURE_2D, 0); + glDepthMask(1); + + if(dispmode&M_RESDISPMODE_HASALPHA) + glDisable(GL_ALPHA_TEST); + + // undo fog off for this object + if(((dispmode&M_RESDISPMODE_DONTFOG)||(odrflags&M_OBJDISPRES_NOFOG)) + &&(VidDisp.flags&M_VIDDISP_FOG)) + glEnable(GL_FOG); + + if(pushmat) + glPopMatrix(); + + if(sr->frameflags&M_SRFRAMEFLAGS_HASLIGHTS) + { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + for(i=0;lightson&&(i>=1) + { + if(lightson&1) + glDisable(i+GL_LIGHT0); + } // for + } // has lights +BAILQUICK: + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3); + #endif // DEBUG + return; +} // DrawDisp3() + +// JFL 05 Nov 04 +void DrawFreeSortBuf(ObjStartSortBuf *sort) +{ + if(!sort->sortBufStart) + return; + + // MEMPOOL_VID is assumed only to be used for sorting + // during the game loop + + if(sort->sortBufSave != MemSLowGet(MEMPOOL_VID)) + { + errlog("freeSortBuf()"); + return; + } + + MemSLowSet(MEMPOOL_VID,sort->sortBufStart); + + sort->sortBufStart=NUL; + +} // DrawFreeSortBuf() + +// JFL 05 Nov 04 +int DrawAllocSortBuf(StateRec *sr,ObjStartSortBuf *sort) +{ + int ec; + + if(sr->sort) + DrawFreeSortBuf(sr->sort); + sr->sort=NUL; + + // MEMPOOL_VID is assumed only to be used for sorting + // during the game loop + + // alloc into sortBufStart + // save into sortBufSave + // to free -- + // check to make sure sortBufSave matches + // set to sortBufStart + + if((ec=MemSLow(MEMPOOL_VID,sort->sortBufSize,&sort->sortBufStart))<0) + { + errlog("DrawAllocSortBuf() couldn't alloc"); + goto BAIL; + } + sort->sortBufSave=MemSLowGet(MEMPOOL_VID); + + sort->sortBufLow=0; + sort->sortBufHigh=sort->sortBufSize; + sort->sortNum=0; + + sr->sort=sort; + + ec=0; +BAIL: + return ec; +} // DrawAllocSortBuf() + +// JFL 05 Nov 04 +int drawSortCmp(void *osh1,void *osh2) +{ + if(((objSortHead*)osh1)->z<((objSortHead*)osh2)->z) + return -1; + else if(((objSortHead*)osh1)->z>((objSortHead*)osh2)->z) + return 1; + return 0; +} // drawSortCmp() + +// JFL 05 Nov 04 +// JFL 18 Aug 05; odr +void DrawSortBuf(StateRec *sr) +{ + uns n,bNothingToSort=1; + objSortHead *osh; + objSortBody *osb; + crd m[16]; + ObjDispRes *odr; + Res *r; + + if(!sr->sort || !sr->sort->sortBufStart) + goto CHECKSO; + if(!sr->sort->sortNum) + goto CHECKSO; + // + // sort the headers + // + + bNothingToSort=0; + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWSORT); + #endif // DEBUG + + MathQSort(sr->sort->sortBufStart,sr->sort->sortNum, + sizeof(objSortHead),drawSortCmp); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWSORT); + #endif // DEBUG + + // if we need to recalculate the "sort once" object, then do it +// if (0) + if (drawSO.flags & M_DSO_RECALC) + { + ResDataDisp2 *r2; + uns32 bOff; + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWSORT); + #endif // DEBUG + + drawSO.d2BufCur = drawSO.d2Buf; // reset draw buffer + drawSO.d2BufCurSize = 0; + drawSO.d2BufQuads = 0; + drawSO.maxZ = drawSO.minZ = (1e17); + + if (drawSO.odr.dList) + { + glDeleteLists(drawSO.odr.dList,1); + drawSubDisplayList(&drawSO.odr); + drawSO.odr.dList=0; + } + + for(osh=(void*)sr->sort->sortBufStart,n=0;nsort->sortNum;n++,osh++) + { + osb=osh->p; // objSortBody + odr=osb->odr; //ObjDispRes + r=odr->res; + r2 = (ResDataDisp2*)(r->data); //ResDataDisp2 + + // if not a "sort once" object, skip this pass + if (!(r2->mode & M_RESDISPMODE_SORTONCE)) + continue; + DrawAddDisp2SortOnce(odr,r2,osb->vm); + + // keep track of the z span of this object + if(osh->z < drawSO.minZ) + drawSO.minZ=osh->z; + else + drawSO.maxZ=osh->z; + + odr->flags |= M_OBJDISPRES_SORTEDONCE; + } // for + + // setup disp2 header for big object + r2 = &drawSO.d2; + r2->nQuads = drawSO.d2BufQuads; + bOff=0; + if (drawSO.nTexCoords) + { + r2->qTexCoords = drawSO.d2Buf; + bOff += RESFLOATSPER_TEXCOORD; + } + if (drawSO.nVColors) + { + r2->qVertColors = ((float*)(drawSO.d2Buf))+bOff; + bOff += RESFLOATSPER_COLOR-1; + } + if (drawSO.nNormals) + { + r2->qNormals = ((float*)(drawSO.d2Buf))+bOff; + bOff += RESFLOATSPER_NORMAL; + } + r2->qVerts = ((float*)(drawSO.d2Buf))+bOff; + + drawSO.flags &= ~M_DSO_RECALC; + drawSO.flags |= M_DSO_READY; + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWSORT); + #endif // DEBUG + } + + // + // draw + // + + // draw all sorted objects before the first "sort once" object + for(osh=(void*)sr->sort->sortBufStart,n=0;nsort->sortNum;n++,osh++) + { + osb=osh->p; + odr=osb->odr; + r=odr->res; + + // if we are already "in front" of the sort once minZ, then bail + if(osh->z >= drawSO.minZ) + break; + + // if "sort once" object, done on this pass + if (((ResDataDisp2*)(r->data))->mode & M_RESDISPMODE_SORTONCE) + continue; + + osb->flags |= M_OSB_DRAWN; + // expand matrix + glPushMatrix(); + + M4SetVM(m,osb->vm); + glLoadMatrixf(m); + + DrawDisp2(sr,(void*)odr,r->data, + M_DRAWDISP_NOMAT|M_DRAWDISP_NOSORT|M_DRAWDISP_BLENDPASS + |osb->face); + + glPopMatrix(); + } // for + +CHECKSO: + // draw "sort once" object if ready + if ((drawSO.flags & M_DSO_READY) && !(drawSO.flags & M_DSO_NODISPLAY)) + { + // this object's matrix is the identity matrix + // just use the camera to transform + DrawDisp2(sr,(Obj*)&drawSO.odr,&drawSO.d2, + M_DRAWDISP_NOMAT|M_DRAWDISP_NOSORT|M_DRAWDISP_BLENDPASS|M_DRAWDISP_DRAWSORTONCE); + } + + if (bNothingToSort) + return; // just needed to check the "sort once" object + + // draw all objects after the "sort once" object + for(osh=(void*)sr->sort->sortBufStart,n=0;nsort->sortNum;n++,osh++) + { + osb=osh->p; + odr=osb->odr; + r=odr->res; + + // if "sort once" object, skip this pass + if ((((ResDataDisp2*)(r->data))->mode & M_RESDISPMODE_SORTONCE) + || (osb->flags & M_OSB_DRAWN)) + continue; + osb->flags |= M_OSB_DRAWN; + // expand matrix + glPushMatrix(); + + M4SetVM(m,osb->vm); + glLoadMatrixf(m); + + DrawDisp2(sr,(void*)odr,r->data, + M_DRAWDISP_NOMAT|M_DRAWDISP_NOSORT|M_DRAWDISP_BLENDPASS + |osb->face); + + glPopMatrix(); + } // for + +} // DrawSortBuf() + +#if DEBUG // ------------------------------------------------------------------ +// JFL 25 Feb 05 +int DrawColDefDbg(void) +{ + ObjColDef *cold; + ObjColDefBase *ocb; + uns sofar; + ResDataCol *rdc; + ResDataCBPoly *poly; + float x,y,z; + int8 k; + ResDataCBXZMM *mm; + ResDataCBVN *vn; + + if(VidDisp.dbgcol&M_VIDDISP_DBGCOL_WIRE) + glPolygonMode(GL_FRONT,GL_LINE); + else + glPolygonMode(GL_FRONT,GL_FILL); + + for(cold=ObjColFirst();cold->lnk.type;cold=cold->lnk.next) + { + for(sofar=0;sofarnext;) + { + ocb=(void*)((memu)&cold[1] + sofar); + sofar+=ocb->len; + switch(ocb->type) + { + case OBJCOLDEFTYPE_GND: + + if(!(rdc=((ObjColDefGnd*)ocb)->d)) + break; + + if((VidDisp.dbgcol&M_VIDDISP_DBGCOL_GNDBOXES) && (mm=rdc->blocks)) + { + for(;mm->blk.type==RESDATACOLBLOCK_XZMM;mm++) + { + glColor3ub(0,255,0); + glTranslatef(mm->xyzr[0],mm->xyzr[1],mm->xyzr[2]); + xVidDraw(VIDDRAW_SPHERE,0.2); + xVidDraw(VIDDRAW_SPHERE,mm->xyzr[3]); + glTranslatef(-mm->xyzr[0],-mm->xyzr[1],-mm->xyzr[2]); + } // for + } // blocks + + poly = (void*)(((uns8*)rdc->polys) + 4); // 4 bytes 0 + for(;;poly++) + { + if(poly->numv==RESDATACBPOLY_NUMV_END) + break; + + //if(poly->xx2!=100) + // continue; // jjj + + glColor3ub(128,128,0); + + if(!poly->numv) + { + glBegin(GL_TRIANGLES); + glVertex3f(poly->v[0].vrt[0], + poly->v[0].vrt[1],poly->v[0].vrt[2]); + glVertex3f(poly->v[1].vrt[0], + poly->v[1].vrt[1],poly->v[1].vrt[2]); + glVertex3f(poly->v[2].vrt[0], + poly->v[2].vrt[1],poly->v[2].vrt[2]); + x=(poly->v[0].vrt[0]+poly->v[1].vrt[0]+poly->v[2].vrt[0])/3.0; + y=(poly->v[0].vrt[1]+poly->v[1].vrt[1]+poly->v[2].vrt[1])/3.0; + z=(poly->v[0].vrt[2]+poly->v[1].vrt[2]+poly->v[2].vrt[2])/3.0; + glEnd(); + } + else + { + glBegin(GL_QUADS); + glVertex3f(poly->v[0].vrt[0], + poly->v[0].vrt[1],poly->v[0].vrt[2]); + glVertex3f(poly->v[1].vrt[0], + poly->v[1].vrt[1],poly->v[1].vrt[2]); + glVertex3f(poly->v[2].vrt[0], + poly->v[2].vrt[1],poly->v[2].vrt[2]); + glVertex3f(poly->v[3].vrt[0], + poly->v[3].vrt[1],poly->v[3].vrt[2]); + x=(poly->v[0].vrt[0]+poly->v[1].vrt[0] + +poly->v[2].vrt[0]+poly->v[3].vrt[0])/4.0; + y=(poly->v[0].vrt[1]+poly->v[1].vrt[1] + +poly->v[2].vrt[1]+poly->v[3].vrt[1])/4.0; + z=(poly->v[0].vrt[2]+poly->v[1].vrt[2] + +poly->v[2].vrt[2]+poly->v[3].vrt[2])/4.0; + glEnd(); + } + + glBegin(GL_LINE_STRIP); + glVertex3f(x,y,z); + glVertex3f(x+poly->nrmk[0],y+poly->nrmk[1],z+poly->nrmk[2]); + glEnd(); + + if(VidDisp.dbgcol&M_VIDDISP_DBGCOL_FULL) + { + vn=poly->v; + for(k=0;k<(3+poly->numv);k++,vn++) + { + if(!k) glColor3ub(255,0,0); + else if(k==1) glColor3ub(0,255,0); + else if(k==2) glColor3ub(0,0,255); + else glColor3ub(255,255,255); + glBegin(GL_LINE_STRIP); + glVertex3f(vn->vrt[0],vn->vrt[1],vn->vrt[2]); + glVertex3f(vn->vrt[0]+vn->nrm[0],vn->vrt[1]+vn->nrm[1],vn->vrt[2]+vn->nrm[2]); + glEnd(); + } // for + + } // full + + + //break; // jjjj + + } // for + break; // OBJCOLDEFTYPE_GND + } // switch + } // for + } // for + + return 0; +} // DrawColDefDbg() +#endif // DEBUG --------------------------------------------------------------- + +// JFL 12 Apr 05 +void DrawStr(StateRec *sr,ObjStr *ostr,uns flags) +{ + int i; + ObjStrChar *osc; + float u0,v0,x0,y0,z; + float u1,v1,x1,y1; + uns32 incolor; + uns8 r,g,b; + + // + // TEXTURE + // + + glDisable(GL_BLEND); + glColor4ub(255,255,255,255); + + glDisable(GL_COLOR_MATERIAL); + glShadeModel(GL_FLAT); + + if((sr->tex=ostr->texGen)) + { + #if DEBUG + if(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_TEX2X2) + sr->tex=VidDisp.dbg2x2; + #endif // DEBUG + + if (sr->tex != sr->curTex) + { + sr->curTex = sr->tex; + glBindTexture(GL_TEXTURE_2D,sr->tex); + } + glEnable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_FILL); + + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); + + // + // FILTER / MIPMAP + // + + // mag + if(!(VidDisp.flags&M_VIDDISP_MAGFILTER)) + { + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + } + else + { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + } + + // min + if(!(VidDisp.flags&(M_VIDDISP_MINFILTER|M_VIDDISP_MIPMAP))) + { + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + } + else + { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + } + + } + else + { + glPolygonMode(GL_FRONT,GL_FILL); + glDisable(GL_TEXTURE_2D); + } + + // + // BLEND + // + + if(ostr->flags & M_OBJSTR_HASALPHA) + { + if(!(VidDisp.flags&M_VIDDISP_BLEND)) + { + // drop out + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER,0.75); // one-pass + } + else + { + // one pass blend + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } + } + + // + // OBJECT MODE OVERRIDES + // + + // wireframe override + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + { + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + } // wireframe override + + // + // + // + + glBegin(GL_QUADS); + + incolor=0; + glColor4ub(255,255,255,255); + + for(i=0,osc=(void*)&ostr[1];inumc;i++,osc++) + { + + if(incolor!=osc->rgb) + { + if((incolor=osc->rgb)) + { + + // 00RRGGBB + r=(osc->rgb>>16)&0xff; + g=(osc->rgb>>8)&0xff; + b=(osc->rgb>>0)&0xff; + glColor3ub(r,g,b); + } + else + glColor3ub(255,255,255); + } // color change + + u0=osc->uvbox[BOX_L]; + v0=osc->uvbox[BOX_T]; + x0=osc->verts[0*3+0]; + y0=osc->verts[0*3+1]; + z =osc->verts[0*3+2]; + + u1=osc->uvbox[BOX_R]; + v1=osc->uvbox[BOX_B]; + x1=osc->verts[1*3+0]; + y1=osc->verts[1*3+1]; + + x0+=ostr->xyadj[0]; + x0+=osc->xyadj[0]; + x1+=ostr->xyadj[0]; + x1+=osc->xyadj[0]; + y0+=ostr->xyadj[1]; + y0+=osc->xyadj[1]; + y1+=ostr->xyadj[1]; + y1+=osc->xyadj[1]; + + glTexCoord2f(u0,v0); + glVertex3f(x0,y0,z); + + glTexCoord2f(u0,v1); + glVertex3f(x0,y1,z); + + glTexCoord2f(u1,v1); + glVertex3f(x1,y1,z); + + glTexCoord2f(u1,v0); + glVertex3f(x1,y0,z); + + } // for + + glEnd(); + + // + // CLEAN UP + // + +// glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_ALPHA_TEST); + +} // DrawStr() + +// JFL 25 May 05 +// JFL 07 Jul 05; prop shadows +void DrawD4PropDbg(StateRec *sr,Obj *odr,ResDataDisp4 *disp4,uns flags) +{ + Obj *o; + ObjDispSave *ods; + float vlit[3],va[3],vb[3],*v0,*v1,*v2,f1,f2,nrmk[4]; + int j,n; + ResD4Face *face; + int8 k,tri; + float dist; + uns8 *memsave=NUL; + uns8 *p,*pbuf; + float *vertx; + + // find the position of the light in object-space + + // find disp-save + ods=NUL; + for(o=odr->lnk.next;o!=odr;o=o->lnk.next) + { + if(!o->lnk.type) + continue; + if(o->lnk.sub==OBJSUB_DISPSAVE) + { + ods=(void*)o; + break; + } + } // for + + // get obj disp save + if(!ods||!(ods->flags&M_OBJDISPSAVE_SINGLE)) + goto BAIL; + + // alloc tmp mem for hit-by-light flag & vert pool + n=disp4->maxFaces; + n+=3*sizeof(float)*disp4->nVerts; + if(MemSLow(MEMPOOL_VID,n,&memsave)<0) + goto BAIL; + pbuf=memsave; + vertx=(void*)(pbuf+disp4->maxFaces); + + V3Cpy(vlit,sr->shadowLight); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + // the first joint mat saved is the root rot trans scale + // invert it & move world-space light into object-space + // use rootdriver mat instead -- jjj + + // draw light + glPushMatrix(); + glColor4ub(255,255,0,255); + glTranslatef(vlit[0],vlit[1],vlit[2]); + glColor3ub(255,255,0); + xVidDraw(VIDDRAW_SPHERE,0.2); + glPopMatrix(); + } // M_SRFRAMEFLAGS_SHADOWPOS + + // transform verts into world space + v2=(void*)ods->jointMats; + v0=disp4->verts; + v1=vertx; + for(j=0;jnVerts;j++,v0+=3,v1+=3) + V3MulVM(v1,v0,v2); + + // poly mode + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + glPolygonMode(GL_FRONT,GL_LINE); + else + glPolygonMode(GL_FRONT,GL_FILL); + + // + // DRAW FRONT SKIRT & OBJECT + // + + dist=VidDisp.shadowDist; + if(VidDisp.dbgshad&0x1f) + { + + glPushMatrix(); + + // + // does the light hit this face + // + + p=pbuf; // hit by light flags + face=(void*)disp4->faces; + for(j=0;jmaxFaces;j++,p++,face++) + { + // plane normal + v0=(void*)((memu)vertx+face->vertoff[0]); + v1=(void*)((memu)vertx+face->vertoff[1]); + v2=(void*)((memu)vertx+face->vertoff[2]); + V3NormalCW(nrmk,v0,v1,v2); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + f1=V3Dot(vlit,nrmk); + else if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + V3Sub(vb,v0,vlit); // light->vert + f1=V3Dot(vb,nrmk); + } + else + f1=0; + + if(f1>0) + *p=0; + else + *p=1; + } // for + + // + // build skirt + // + + p=pbuf; // hit by light flags + face=(void*)disp4->faces; + for(j=0;jmaxFaces;j++,p++,face++) + { + if(VidDisp.dbgshad&0x01) + { + glBegin(GL_TRIANGLE_FAN); + + if(*p) + glColor4ub(190,190,190,255); + else + glColor4ub(70,70,70,255); + + v0=(void*)((memu)vertx+face->vertoff[0]); + glVertex3f(v0[0],v0[1],v0[2]); + v0=(void*)((memu)vertx+face->vertoff[1]); + glVertex3f(v0[0],v0[1],v0[2]); + v0=(void*)((memu)vertx+face->vertoff[2]); + glVertex3f(v0[0],v0[1],v0[2]); + + if(face->vertoff[2]!=face->vertoff[3]) + { + v0=(void*)((memu)vertx+face->vertoff[3]); + glVertex3f(v0[0],v0[1],v0[2]); + } + + glEnd(); + + } // hit-by-light faces + + if(!*p) + continue; // face not hit by light + + // find edges + tri=face->vertoff[2]==face->vertoff[3]?1:0; + for(k=0;k<4;k++) + { + if(k==3 && tri) + continue; + + // if edge has neighbor face & neighbor face is visible + if((n=face->neighbor[k])>=0 && pbuf[n]) + continue; + + v0=(void*)((memu)vertx+face->vertoff[k]); + if((k<2)||(k==2&&!tri)) + v1=(void*)((memu)vertx+face->vertoff[1+k]); + else + v1=(void*)((memu)vertx+face->vertoff[0]); + + // + // from light to + // + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + { + // skirt vert 0 + V3Cpy(va,vlit); + va[0]*=dist; + va[0]+=v0[0]; // add in vert + va[1]*=dist; + va[1]+=v0[1]; + va[2]*=dist; + va[2]+=v0[2]; + + // skirt vert 1 + V3Cpy(vb,vlit); + vb[0]*=dist; + vb[0]+=v1[0]; + vb[1]*=dist; + vb[1]+=v1[1]; + vb[2]*=dist; + vb[2]+=v1[2]; + + } // dir + else + { + // skirt vert 0 + V3Sub(va,v0,vlit); // distance from vert to light + f1=va[0]*va[0]; // quick normalization + f2=va[1]*va[1]; + f1+=f2; + f2=va[2]*va[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; // set distance + va[0]*=f1; + va[0]+=v0[0]; // add in vert + va[1]*=f1; + va[1]+=v0[1]; + va[2]*=f1; + va[2]+=v0[2]; + + // skirt vert 1 + V3Sub(vb,v1,vlit); // distance from vert to light + f1=vb[0]*vb[0]; + f2=vb[1]*vb[1]; + f1+=f2; + f2=vb[2]*vb[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; + vb[0]*=f1; + vb[0]+=v1[0]; + vb[1]*=f1; + vb[1]+=v1[1]; + vb[2]*=f1; + vb[2]+=v1[2]; + } // pos + + if(VidDisp.dbgshad&0x04) + { + // draw edge + glColor4ub(255,0,0,255); + glLineWidth(2); + glBegin(GL_LINE_STRIP); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glEnd(); + glLineWidth(1); + } + + if(VidDisp.dbgshad&0x08) + { + // draw skirt + // use vert0, vert1, and projected verta, vertb for skirt + glColor4ub(0,255,0,255); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(va[0],va[1],va[2]); + glVertex3f(vb[0],vb[1],vb[2]); + glEnd(); + } + + if(VidDisp.dbgshad&0x10) + { + // draw skirt -- backfaces + glFrontFace(GL_CW); + + // use vert0, vert1, and projected verta, vertb for skirt + glColor4ub(0,128,0,255); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(va[0],va[1],va[2]); + glVertex3f(vb[0],vb[1],vb[2]); + glEnd(); + + glFrontFace(GL_CCW); + } + + + } // for + } // for + glPopMatrix(); + + } // draw shadow skirt + +BAIL: + if(memsave) + MemSLowSet(MEMPOOL_VID,memsave); + + return; +} // DrawD4PropDbg() + +// JFL 25 May 05 +// JFL 07 Jul 05; prop shadows +void DrawD4Prop(StateRec *sr,Obj *odr,ResDataDisp4 *disp4,uns flags) +{ + Obj *o; + ObjDispSave *ods; + float vlit[3],va[3],vb[3],*v0,*v1,*v2,f1,f2,nrmk[4]; + int j,n,loop; + ResD4Face *face; + int8 k,tri; + float dist; + uns8 *memsave=NUL; + uns8 *p,*pbuf; + float *vertx; + + // find the position of the light in object-space + + // find disp-save + ods=NUL; + for(o=odr->lnk.next;o!=odr;o=o->lnk.next) + { + if(!o->lnk.type) + continue; + if(o->lnk.sub==OBJSUB_DISPSAVE) + { + ods=(void*)o; + break; + } + } // for + + // get obj disp save + if(!ods||!(ods->flags&M_OBJDISPSAVE_SINGLE)) + goto BAIL; + + // alloc tmp mem for hit-by-light flag & vert pool + n=disp4->maxFaces; + n+=3*sizeof(float)*disp4->nVerts; + if(MemSLow(MEMPOOL_VID,n,&memsave)<0) + goto BAIL; + pbuf=memsave; + vertx=(void*)(pbuf+disp4->maxFaces); + + V3Cpy(vlit,sr->shadowLight); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + // the first joint mat saved is the root rot trans scale + // invert it & move world-space light into object-space + // use rootdriver mat instead -- jjj + + // draw light + glPushMatrix(); + glColor4ub(255,255,0,255); + glTranslatef(vlit[0],vlit[1],vlit[2]); + glColor3ub(255,255,0); + xVidDraw(VIDDRAW_SPHERE,0.2); + glPopMatrix(); + } // M_SRFRAMEFLAGS_SHADOWPOS + + // transform verts into world space + v2=(void*)ods->jointMats; + v0=disp4->verts; + v1=vertx; + for(j=0;jnVerts;j++,v0+=3,v1+=3) + V3MulVM(v1,v0,v2); + + // poly mode + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + glPolygonMode(GL_FRONT,GL_LINE); + else + glPolygonMode(GL_FRONT,GL_FILL); + + // + // DRAW FRONT SKIRT & OBJECT + // + + loop=0; + dist=VidDisp.shadowDist; +lp: + if(!loop) + { + glFrontFace(GL_CCW); + glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // fails keep sb, pass incs + } + else + { + glFrontFace(GL_CW); + glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); // fails keep sb, pass incs + } + + + glPushMatrix(); + + // + // does the light hit this face + // + + p=pbuf; // hit by light flags + face=(void*)disp4->faces; + for(j=0;jmaxFaces;j++,p++,face++) + { + // plane normal + v0=(void*)((memu)vertx+face->vertoff[0]); + v1=(void*)((memu)vertx+face->vertoff[1]); + v2=(void*)((memu)vertx+face->vertoff[2]); + V3NormalCW(nrmk,v0,v1,v2); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + f1=V3Dot(vlit,nrmk); + else if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + V3Sub(vb,v0,vlit); // light->vert + f1=V3Dot(vb,nrmk); + } + else + f1=0; + + if(f1>0) + *p=0; + else + *p=1; + } // for + + // + // build skirt + // + + p=pbuf; // hit by light flags + face=(void*)disp4->faces; + for(j=0;jmaxFaces;j++,p++,face++) + { + if(!*p) + continue; // face not hit by light + + // find edges + tri=face->vertoff[2]==face->vertoff[3]?1:0; + for(k=0;k<4;k++) + { + if(k==3 && tri) + continue; + + // if edge has neighbor face & neighbor face is visible + if((n=face->neighbor[k])>=0 && pbuf[n]) + continue; + + v0=(void*)((memu)vertx+face->vertoff[k]); + if((k<2)||(k==2&&!tri)) + v1=(void*)((memu)vertx+face->vertoff[1+k]); + else + v1=(void*)((memu)vertx+face->vertoff[0]); + + // + // from light to + // + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + { + // skirt vert 0 + V3Cpy(va,vlit); + va[0]*=dist; + va[0]+=v0[0]; // add in vert + va[1]*=dist; + va[1]+=v0[1]; + va[2]*=dist; + va[2]+=v0[2]; + + // skirt vert 1 + V3Cpy(vb,vlit); + vb[0]*=dist; + vb[0]+=v1[0]; + vb[1]*=dist; + vb[1]+=v1[1]; + vb[2]*=dist; + vb[2]+=v1[2]; + + } // dir + else + { + // skirt vert 0 + V3Sub(va,v0,vlit); // distance from vert to light + f1=va[0]*va[0]; // quick normalization + f2=va[1]*va[1]; + f1+=f2; + f2=va[2]*va[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; // set distance + va[0]*=f1; + va[0]+=v0[0]; // add in vert + va[1]*=f1; + va[1]+=v0[1]; + va[2]*=f1; + va[2]+=v0[2]; + + // skirt vert 1 + V3Sub(vb,v1,vlit); // distance from vert to light + f1=vb[0]*vb[0]; + f2=vb[1]*vb[1]; + f1+=f2; + f2=vb[2]*vb[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; + vb[0]*=f1; + vb[0]+=v1[0]; + vb[1]*=f1; + vb[1]+=v1[1]; + vb[2]*=f1; + vb[2]+=v1[2]; + } // pos + + // draw skirt + // use vert0, vert1, and projected verta, vertb for skirt + glBegin(GL_TRIANGLE_FAN); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(va[0],va[1],va[2]); + glVertex3f(vb[0],vb[1],vb[2]); + glEnd(); + + } // for + } // for + glPopMatrix(); + + if(!loop++) + goto lp; + + +BAIL: + if(memsave) + MemSLowSet(MEMPOOL_VID,memsave); + glFrontFace(GL_CCW); + return; +} // DrawD4Prop() + +// JFL 25 May 05 +// JFL 07 Jul 05; prop shadows +void DrawD4SkelDbg(StateRec *sr,Obj *odr,ResDataDisp4 *disp4,uns flags) +{ + Obj *o; + ObjDispSave *ods; + VMType *vma,*vmb; + float vlit[3],va[3],vb[3],*v0,*v1,*v2,f1,f2,nrmk[4]; + float *v1x; + int i,j,n; + ResD4Joint *joint; + ResD4Face *face; + ResD4Weight *weight; + int8 k,tri; + float dist; + uns8 *memsave=NUL; + uns8 *p,*pbuf; + float *vertx; + + // find the position of the light in object-space + + // find disp-save if this is a skeleton object + ods=NUL; + for(o=odr->lnk.next;o!=odr;o=o->lnk.next) + { + if(!o->lnk.type) + continue; + if(o->lnk.sub==OBJSUB_DISPSAVE) + { + ods=(void*)o; + break; + } + } // for + + // get obj disp save and the joint mats + if(!ods||!ods->numJoints||!ods->jointMats) + goto BAIL; + + // alloc tmp mem for hit-by-light flag & vert pool + n=disp4->maxFaces; + if(disp4->flags&M_RESDATADISP4_WEIGHTS) + n+=3*sizeof(float)*disp4->nVerts; + if(MemSLow(MEMPOOL_VID,n,&memsave)<0) + goto BAIL; + pbuf=memsave; + if(disp4->flags&M_RESDATADISP4_WEIGHTS) + vertx=(void*) (pbuf+disp4->maxFaces); // transformed vert pool + else + vertx=disp4->verts; + + v1x=vertx; + v1x+=3*disp4->nVerts; + + V3Cpy(vlit,sr->shadowLight); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + // the first joint mat saved is the root rot trans scale + // invert it & move world-space light into object-space + // use rootdriver mat instead -- jjj + + // draw light + glPushMatrix(); + glColor4ub(255,255,0,255); + glTranslatef(vlit[0],vlit[1],vlit[2]); + glColor3ub(255,255,0); + xVidDraw(VIDDRAW_SPHERE,0.2); + glPopMatrix(); + } // M_SRFRAMEFLAGS_SHADOWPOS + + // build transformed vert pool + if(disp4->flags&M_RESDATADISP4_WEIGHTS) + { + v0=disp4->verts; + v1=vertx; + weight=disp4->weights; + for(i=0;inVerts;i++,v0+=3,v1+=3,weight++) + { + #if SAFE +// if(weight->j0<0 || weight->j0>=ods->numJoints) + if(weight->j0>=ods->numJoints) + BP(BP_DISPDRAW4SKELDBG); +// if(weight->j1<0 || weight->j1>=ods->numJoints) + if(weight->j1>=ods->numJoints) + BP(BP_DISPDRAW4SKELDBG2); + #endif // SAFE + + // joint0 + vma=(void*)ods->jointMats; + vma+=weight->j0; + + // joint1 + vmb=(void*)ods->jointMats; + vmb+=weight->j1; + + V3MulVM(v1,v0,vma->a); + v1[0]*=weight->w0; + v1[1]*=weight->w0; + v1[2]*=weight->w0; + + if(weight->w1) + { + V3MulVM(va,v0,vmb->a); + v1[0]+=va[0]*weight->w1; + v1[1]+=va[1]*weight->w1; + v1[2]+=va[2]*weight->w1; + } + } // for + + if(v1!=v1x) + BP(BP_DISPDRAW4SKELDBG3); + } // transform verts + else + { + BP(BP_DISPDRAW4SKELDBG4); + } + + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + glPolygonMode(GL_FRONT,GL_LINE); + else + glPolygonMode(GL_FRONT,GL_FILL); + + // + // DRAW FRONT SKIRT & OBJECT + // + + dist=VidDisp.shadowDist; + if(VidDisp.dbgshad&0x1f) + { + // joint object + for(i=0,joint=disp4->joints;inJoints;i++,joint++) + { + if(joint->jointNum&0x8000) + continue; + + glPushMatrix(); + + // + // does the light hit this face + // + + p=pbuf; // hit by light flags + face=(void*)((memu)disp4->faces+joint->faceoff); + for(j=0;jnFaces;j++,p++,face++) + { + // plane normal + v0=(void*)((memu)vertx+face->vertoff[0]); + v1=(void*)((memu)vertx+face->vertoff[1]); + v2=(void*)((memu)vertx+face->vertoff[2]); + V3NormalCW(nrmk,v0,v1,v2); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + f1=V3Dot(vlit,nrmk); + else if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + V3Sub(vb,v0,vlit); // light->vert + f1=V3Dot(vb,nrmk); + } + else + f1=0; + + if(f1>0) + *p=0; + else + *p=1; + } // for + + // + // build skirt + // + + p=pbuf; // hit by light flags + face=(void*)((memu)disp4->faces+joint->faceoff); + for(j=0;jnFaces;j++,p++,face++) + { + if(VidDisp.dbgshad&0x01) + { + glBegin(GL_TRIANGLE_FAN); + + if(*p) + glColor4ub(190,190,190,255); + else + glColor4ub(70,70,70,255); + + v0=(void*)((memu)vertx+face->vertoff[0]); + glVertex3f(v0[0],v0[1],v0[2]); + v0=(void*)((memu)vertx+face->vertoff[1]); + glVertex3f(v0[0],v0[1],v0[2]); + v0=(void*)((memu)vertx+face->vertoff[2]); + glVertex3f(v0[0],v0[1],v0[2]); + + if(face->vertoff[2]!=face->vertoff[3]) + { + v0=(void*)((memu)vertx+face->vertoff[3]); + glVertex3f(v0[0],v0[1],v0[2]); + } + + glEnd(); + + } // hit-by-light faces + + if(!*p) + continue; // face not hit by light + + // find edges + tri=face->vertoff[2]==face->vertoff[3]?1:0; + for(k=0;k<4;k++) + { + if(k==3 && tri) + continue; + + // if edge has neighbor face & neighbor face is visible + if((n=face->neighbor[k])>=0 && pbuf[n]) + continue; + + v0=(void*)((memu)vertx+face->vertoff[k]); + if((k<2)||(k==2&&!tri)) + v1=(void*)((memu)vertx+face->vertoff[1+k]); + else + v1=(void*)((memu)vertx+face->vertoff[0]); + + // + // from light to + // + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + { + // skirt vert 0 + V3Cpy(va,vlit); + va[0]*=dist; + va[0]+=v0[0]; // add in vert + va[1]*=dist; + va[1]+=v0[1]; + va[2]*=dist; + va[2]+=v0[2]; + + // skirt vert 1 + V3Cpy(vb,vlit); + vb[0]*=dist; + vb[0]+=v1[0]; + vb[1]*=dist; + vb[1]+=v1[1]; + vb[2]*=dist; + vb[2]+=v1[2]; + + } // dir + else + { + // skirt vert 0 + V3Sub(va,v0,vlit); // distance from vert to light + f1=va[0]*va[0]; // quick normalization + f2=va[1]*va[1]; + f1+=f2; + f2=va[2]*va[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; // set distance + va[0]*=f1; + va[0]+=v0[0]; // add in vert + va[1]*=f1; + va[1]+=v0[1]; + va[2]*=f1; + va[2]+=v0[2]; + + // skirt vert 1 + V3Sub(vb,v1,vlit); // distance from vert to light + f1=vb[0]*vb[0]; + f2=vb[1]*vb[1]; + f1+=f2; + f2=vb[2]*vb[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; + vb[0]*=f1; + vb[0]+=v1[0]; + vb[1]*=f1; + vb[1]+=v1[1]; + vb[2]*=f1; + vb[2]+=v1[2]; + } // pos + + if(VidDisp.dbgshad&0x04) + { + // draw edge + glColor4ub(255,0,0,255); + glLineWidth(2); + glBegin(GL_LINE_STRIP); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glEnd(); + glLineWidth(1); + } + + if(VidDisp.dbgshad&0x08) + { + // draw skirt + // use vert0, vert1, and projected verta, vertb for skirt + glColor4ub(0,255,0,255); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(va[0],va[1],va[2]); + glVertex3f(vb[0],vb[1],vb[2]); + glEnd(); + } + + if(VidDisp.dbgshad&0x10) + { + // draw skirt -- backfaces + glFrontFace(GL_CW); + + // use vert0, vert1, and projected verta, vertb for skirt + glColor4ub(0,128,0,255); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(va[0],va[1],va[2]); + glVertex3f(vb[0],vb[1],vb[2]); + glEnd(); + + glFrontFace(GL_CCW); + } + + + } // for + } // for + glPopMatrix(); + } // for + } // draw shadow skirt + +BAIL: + if(memsave) + MemSLowSet(MEMPOOL_VID,memsave); + return; +} // DrawD4SkelDbg() + +// JFL 25 May 05 +void DrawD4Skel(StateRec *sr,Obj *odr,ResDataDisp4 *disp4,uns flags) +{ + Obj *o; + ObjDispSave *ods; + VMType *vma,*vmb; + float vlit[3],va[3],vb[3],*v0,*v1,*v2,f1,f2,nrmk[4]; + float *v1x; + int i,j,n; + ResD4Joint *joint; + ResD4Face *face; + ResD4Weight *weight; + int8 k,tri; + float dist; + uns8 *memsave=NUL; + uns8 *p,*pbuf; + float *vertx; + int loop; + + // find the position of the light in object-space + + // find disp-save if this is a skeleton object (all are right now) + ods=NUL; + for(o=odr->lnk.next;o!=odr;o=o->lnk.next) + { + if(!o->lnk.type) + continue; + if(o->lnk.sub==OBJSUB_DISPSAVE) + { + ods=(void*)o; + break; + } + } // for + + // get obj disp save and the joint mats + if(!ods||!ods->numJoints||!ods->jointMats) + goto BAIL; + + // alloc tmp mem for hit-by-light flag & vert pool + n=disp4->maxFaces; + if(disp4->flags&M_RESDATADISP4_WEIGHTS) + n+=3*sizeof(float)*disp4->nVerts; + if(MemSLow(MEMPOOL_VID,n,&memsave)<0) + goto BAIL; + pbuf=memsave; + if(disp4->flags&M_RESDATADISP4_WEIGHTS) + vertx=(void*) (pbuf+disp4->maxFaces); // transformed vert pool + else + vertx=disp4->verts; + + v1x=vertx; + v1x+=3*disp4->nVerts; + + V3Cpy(vlit,sr->shadowLight); + + // build transformed vert pool + if(disp4->flags&M_RESDATADISP4_WEIGHTS) + { + v0=disp4->verts; + v1=vertx; + weight=disp4->weights; + for(i=0;inVerts;i++,v0+=3,v1+=3,weight++) + { + #if SAFE +// if(weight->j0<0 || weight->j0>=ods->numJoints) + if(weight->j0>=ods->numJoints) + BP(BP_DISPDRAW4SKEL); +// if(weight->j1<0 || weight->j1>=ods->numJoints) + if(weight->j1>=ods->numJoints) + BP(BP_DISPDRAW4SKEL2); + #endif // SAFE + + // joint0 + vma=(void*)ods->jointMats; + vma+=weight->j0; + + // joint1 + vmb=(void*)ods->jointMats; + vmb+=weight->j1; + + V3MulVM(v1,v0,vma->a); + v1[0]*=weight->w0; + v1[1]*=weight->w0; + v1[2]*=weight->w0; + + if(weight->w1) + { + V3MulVM(va,v0,vmb->a); + v1[0]+=va[0]*weight->w1; + v1[1]+=va[1]*weight->w1; + v1[2]+=va[2]*weight->w1; + } + } // for + + if(v1!=v1x) + BP(BP_DISPDRAW4SKEL3); + } // transform verts + else + { + BP(BP_DISPDRAW4SKEL4); + } + + // + // DRAW FRONT SKIRT & OBJECT + // + + loop=0; + dist=VidDisp.shadowDist; +lp: + if(!loop) + { + glFrontFace(GL_CCW); + glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); // fails keep sb, pass incs + } + else + { + glFrontFace(GL_CW); + glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); // fails keep sb, pass incs + } + + // joint object + for(i=0,joint=disp4->joints;inJoints;i++,joint++) + { + if(joint->jointNum&0x8000) // skip this joint + continue; + + glPushMatrix(); + + // + // does the light hit this face + // + + p=pbuf; // hit by light flags + face=(void*)((memu)disp4->faces+joint->faceoff); + for(j=0;jnFaces;j++,p++,face++) + { + // plane normal + v0=(void*)((memu)vertx+face->vertoff[0]); + v1=(void*)((memu)vertx+face->vertoff[1]); + v2=(void*)((memu)vertx+face->vertoff[2]); + V3NormalCW(nrmk,v0,v1,v2); + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + f1=V3Dot(vlit,nrmk); + else if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWPOS) + { + V3Sub(vb,v0,vlit); // light->vert + f1=V3Dot(vb,nrmk); + } + else + f1=0; + + if(f1>0) + *p=0; + else + *p=1; + } // for + + // + // build skirt + // + + p=pbuf; // hit by light flags + face=(void*)((memu)disp4->faces+joint->faceoff); + for(j=0;jnFaces;j++,p++,face++) + { + + if(!*p) + continue; // face not hit by light + + // find edges + tri=face->vertoff[2]==face->vertoff[3]?1:0; + for(k=0;k<4;k++) + { + if(k==3 && tri) + continue; + + // if edge has neighbor face & neighbor face is visible + if((n=face->neighbor[k])>=0 && pbuf[n]) + continue; + + v0=(void*)((memu)vertx+face->vertoff[k]); + if((k<2)||(k==2&&!tri)) + v1=(void*)((memu)vertx+face->vertoff[1+k]); + else + v1=(void*)((memu)vertx+face->vertoff[0]); + + // + // from light to + // + + if(sr->frameflags&M_SRFRAMEFLAGS_SHADOWDIR) + { + // skirt vert 0 + V3Cpy(va,vlit); + va[0]*=dist; + va[0]+=v0[0]; // add in vert + va[1]*=dist; + va[1]+=v0[1]; + va[2]*=dist; + va[2]+=v0[2]; + + // skirt vert 1 + V3Cpy(vb,vlit); + vb[0]*=dist; + vb[0]+=v1[0]; + vb[1]*=dist; + vb[1]+=v1[1]; + vb[2]*=dist; + vb[2]+=v1[2]; + + } // dir + else + { + // skirt vert 0 + V3Sub(va,v0,vlit); // distance from vert to light + f1=va[0]*va[0]; // quick normalization + f2=va[1]*va[1]; + f1+=f2; + f2=va[2]*va[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; // set distance + va[0]*=f1; + va[0]+=v0[0]; // add in vert + va[1]*=f1; + va[1]+=v0[1]; + va[2]*=f1; + va[2]+=v0[2]; + + // skirt vert 1 + V3Sub(vb,v1,vlit); // distance from vert to light + f1=vb[0]*vb[0]; + f2=vb[1]*vb[1]; + f1+=f2; + f2=vb[2]*vb[2]; + f1+=f2; + if((f1=MathFastSqrt(f1))) + f1=1.0/f1; + f1*=dist; + vb[0]*=f1; + vb[0]+=v1[0]; + vb[1]*=f1; + vb[1]+=v1[1]; + vb[2]*=f1; + vb[2]+=v1[2]; + } // pos + + + // draw skirt + // use vert0, vert1, and projected verta, vertb for skirt + glBegin(GL_TRIANGLE_FAN); + glVertex3f(v1[0],v1[1],v1[2]); + glVertex3f(v0[0],v0[1],v0[2]); + glVertex3f(va[0],va[1],va[2]); + glVertex3f(vb[0],vb[1],vb[2]); + glEnd(); + + } // for + } // for + glPopMatrix(); + } // for + + if(!loop++) + goto lp; + +BAIL: + if(memsave) + MemSLowSet(MEMPOOL_VID,memsave); + glFrontFace(GL_CCW); + return; +} // DrawD4Skel() + +// JFL 25 May 05 +void DrawShadows(StateRec *sr,ObjTmpLink *otl) +{ + Obj *o; + Res *r; + void *d; + + // must have shadow dir or pos set for this frame + if(!(sr->frameflags&(M_SRFRAMEFLAGS_SHADOWDIR|M_SRFRAMEFLAGS_SHADOWDIR))) + return; + if(!(VidDisp.flags&M_VIDDISP_SHADOWS)) + return; + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWSHAD); + #endif // DEBUG + + DrawResetObj(); + + glDepthFunc(GL_LEQUAL); // but we still test against the depth buffer + glDisable(GL_LIGHTING);// no lighting + glPolygonMode(GL_FRONT,GL_FILL); + glShadeModel(GL_FLAT); + + if(!VidDisp.dbgshad) + { + // not debugging + glDepthMask(0);// dont write to depth buffer + glColorMask(0,0,0,0);// dont write to color buffer + glEnable(GL_STENCIL_TEST);// test against the stencil buffer + glStencilFunc(GL_ALWAYS,1,~0); // always pass + } + + for(;otl->tmpLnk.type;otl=otl->tmpLnk.next) + { + if(!(o=otl->data)||(o->lnk.type!=N2TYPE_OBJ)) + continue; + switch(o->lnk.sub) + { + case OBJSUB_DISPRES: + if(!(r=((ObjDispRes*)o)->res)||!(d=r->data)) + break; + if(RESSUB_DISP4==r->lnk.sub) + { + // draw either using skel or prop shadow routines + if(((ResDataDisp4*)d)->nJoints) + { + // skel shadows + if(!VidDisp.dbgshad) + DrawD4Skel(sr,o,d,0); + else + DrawD4SkelDbg(sr,o,d,0); + } + else + { + // prop shadows + if(!VidDisp.dbgshad) + DrawD4Prop(sr,o,d,0); + else + DrawD4PropDbg(sr,o,d,0); + } + } + break; // OBJSUB_DISPRES + } // switch + } // for + + // + // DRAW SHADOW POLYGON OVER THE WHOLE SCREEN + // it will only stick where it needs to + // + + if(!VidDisp.dbgshad) + { + glFrontFace(GL_CCW); + + glColorMask(1,1,1,1);// draw into color buffer + + glColor4ub(VidDisp.shadowRGBA[0],VidDisp.shadowRGBA[1], + VidDisp.shadowRGBA[2],VidDisp.shadowRGBA[3]); + + // get rid of texture because shadows are solid color + sr->curTex=0; + glBindTexture(GL_TEXTURE_2D,0); + glDisable(GL_TEXTURE_2D); + + glEnable(GL_STENCIL_TEST);// test against the stencil buffer + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // dont change the sb + glStencilFunc(GL_NOTEQUAL,0,~0); // stick where sb is non-zero (8 bits now) + glDepthFunc(GL_ALWAYS); + + glEnable(GL_BLEND); // looks better if shadow is blended + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0,1,0,1,-1,1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glBegin(GL_POLYGON); + glVertex3f(0,0,0); + glVertex3f(1,0,0); + glVertex3f(1,1,0); + glVertex3f(0,1,0); + glEnd(); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + } // 1 + + // restore global states + glDisable(GL_STENCIL_TEST); + glDepthMask(1); + glDepthFunc(GL_LEQUAL); + glFrontFace(GL_CCW); + glDisable(GL_BLEND); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWSHAD); + #endif // DEBUG + +} // DrawShadows() + +// JFL 01 Jun 05 +void DrawAfterShadows(StateRec *sr,ObjTmpLink *otl) +{ + Obj *o; + Res *r; + void *d; + uns dispflags=M_DRAWDISP_AFTERSHADOWS; + + for(;otl->tmpLnk.type;otl=otl->tmpLnk.next) + { + if(!(o=otl->data)||(o->lnk.type!=N2TYPE_OBJ)) + continue; + switch(o->lnk.sub) + { + case OBJSUB_DISPRES: + if(!(r=((ObjDispRes*)o)->res)||!(d=r->data)) + break; + if(RESSUB_DISP2==r->lnk.sub) + DrawDisp2(sr,o,d,M_DRAWDISP_DEFAULT|dispflags); + else if(RESSUB_DISP3==r->lnk.sub) + DrawDisp3(sr,o,d,M_DRAWDISP_DEFAULT|dispflags); + else if(RESSUB_DISP1==r->lnk.sub) + DrawDisp1(sr,d); + break; // OBJSUB_DISPRES + } // switch + } // for + +} // DrawAfterShadows() + +// JFL 19 Aug 05 +// JFL 07 Sep 05; scaling +int DrawEmitParticles(StateRec *sr, void *opartv) +{ + int ec,i,ii; + ObjParticles *opart=opartv; + ObjPartDisp *pd; + ObjPartEachPart *pp; + int8 k; + ObjCam *cam=ObjCamCur(); + uns8 pushed=0; + crd m1[M3_SIZE],v1[3],v2[3]; + ResDataDisp2 *disp2; + uns dispmode; + float *ptex,*pcol,*pnor,*pver; + uns tex=0; + + if(!opart->nPart) + err(1); // nothing to draw + if(!cam) + berr(-2); // no cam + + // + // load up disp & flags + // + + // set mode based on first particle disp record + if(!(pd=opart->disps)) + berr(-3); + if(!(disp2=pd->disp)) + berr(-3); + dispmode=disp2->mode; + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWEMITPARTICLES); + #endif // DEBUG + + // + // open gl mode + // + + DrawResetObj(); + + // textured + glEnable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_FILL); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); + + tex=disp2->texGen; + if(tex != sr->curTex) + { + sr->curTex = tex; + glBindTexture(GL_TEXTURE_2D,tex); + } + + // not lit + glDisable(GL_COLOR_MATERIAL); + glShadeModel(GL_FLAT); + + // fastest + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + + // blend & tint + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glDepthMask(0);// dont write to depth buffer + + if(dispmode&M_RESDISPMODE_HASALPHA) + { + // blend + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + } // alpha + else + { + glDisable(GL_ALPHA_TEST); + } + + // override + if(VidDisp.flags&M_VIDDISP_WIREFRAME) + { + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + glDisable(GL_CULL_FACE); + } // wireframe + + // get inv camera rot matrix + M3Inv(m1,cam->vm+VM_11); + + for(ii=0,pp=opart->parts;iinPart;ii++,pp++) + { + if(!pp->flags) + continue; // empty + + glColor4ub(pp->rgba[0],pp->rgba[1],pp->rgba[2],pp->rgba[3]); + + if(!(disp2=pp->disp)) + continue; + if(tex!=disp2->texGen) + { + tex=disp2->texGen; + sr->curTex=tex; + glBindTexture(GL_TEXTURE_2D,tex); + } + + // + // quads + // + + if(!disp2->nQuads) + goto quadd; + + ptex=disp2->qTexCoords; + pcol=disp2->qVertColors; + pnor=disp2->qNormals; + pver=disp2->qVerts; + + glBegin(GL_QUADS); + + for(i=0;inQuads;i+=4) + { + for(k=0;k<4;k++) + { + if(ptex) + { + glTexCoord2f(ptex[0],ptex[1]); + ptex+=2; + } + + if(pcol) + { + glColor4f(pcol[0],pcol[1],pcol[2],pcol[3]); + pcol+=4; + } + + if(pnor) + { + glNormal3f(pnor[0],pnor[1],pnor[2]); + pnor+=3; + } + + if(!pp->scale) + { + V3RotM3(v1,pver,m1); + } + else + { + v2[0]=pp->scale*pver[0]; + v2[1]=pp->scale*pver[1]; + v2[2]=pp->scale*pver[2]; + V3RotM3(v1,v2,m1); + } + + V3Add(v1,v1,pp->trans); + glVertex3f(v1[0],v1[1],v1[2]); + pver+=3; + + } // for + } // quads + + glEnd(); +quadd: + + // + // tris + // + + if(!disp2->nTris) + goto trid; + + ptex=disp2->tTexCoords; + pcol=disp2->tVertColors; + pnor=disp2->tNormals; + pver=disp2->tVerts; + + glBegin(GL_TRIANGLES); + + for(i=0;inTris;i++) + { + for(k=0;k<3;k++) + { + if(ptex) + { + glTexCoord2f(ptex[0],ptex[1]); + ptex+=2; + } + + if(pcol) + { + glColor4f(pcol[0],pcol[1],pcol[2],pcol[3]); + pcol+=4; + } + + if(pnor) + { + glNormal3f(pnor[0],pnor[1],pnor[2]); + pnor+=3; + } + + if(!pp->scale) + { + V3RotM3(v1,pver,m1); + } + else + { + v2[0]=pp->scale*pver[0]; + v2[1]=pp->scale*pver[1]; + v2[2]=pp->scale*pver[2]; + V3RotM3(v1,v2,m1); + } + + glVertex3f(v1[0],v1[1],v1[2]); + pver+=3; + + } // for + } // tris + + glEnd(); +trid:; + + } // for + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWEMITPARTICLES); + #endif // DEBUG + + ec=0; +BAIL: + glDisable(GL_BLEND); +// glBindTexture(GL_TEXTURE_2D,0); + + return ec; +} // DrawEmitParticles() + +// +// DrawInitSortOnce +// +// +// in: +// out: +// global: +// +// GNP 30 Nov 05 +// +void DrawInitSortOnce(void) +{ + + // if buffer is locked, then we cannot initialize it + if (drawSO.flags & M_DSO_LOCKED) + return; + + drawSO.nVerts=drawSO.nVColors=drawSO.nTexCoords=drawSO.nNormals=0; + drawSO.nQuads=drawSO.nTris=0; + + if (drawSO.odr.dList) + { + glDeleteLists(drawSO.odr.dList,1); + drawSubDisplayList(&drawSO.odr); + drawSO.odr.dList=0; + } + + MEMZ(drawSO.r); + MEMZ(drawSO.d2); + MEMZ(drawSO.odr); + + szbuild(drawSO.r.name,RES_NAME_SIZE,"sobject"); + drawSO.r.data = &drawSO.d2; + + drawSO.odr.res = &drawSO.r; + +//DONE("DrawInitSortOnce") +} // DrawInitSortOnce + +// +// DrawAccountDisp2SortOnce +// account for this disp2 sort once resource +// +// in: +// r = resource header +// d2 = display resource +// out: +// global: +// +// GNP 30 Nov 05 +// +void DrawAccountDisp2SortOnce(Res *r, ResDataDisp2 *d2) +{ + if (drawSO.flags & M_DSO_LOCKED) + return; + + // need to count verts for space necessary sort once memory + if (d2->nTris && d2->nQuads) + { + SysLog("DrawAccountDisp2SortOnce: sort once resource '%s' has mix of quads and tris, removed from sort\n",r->name); + // do not allow to sort + d2->mode &= ~M_RESDISPMODE_SORTONCE; + BP(BP_DRAWACCOUNTDISP2SORTONCE); + } + else if (d2->nTris) + { + // triangles + drawSO.nObjs++; + drawSO.nTris += d2->nTris/3; + drawSO.nVerts += d2->nTris; + if (d2->tVertColors) + drawSO.nVColors += d2->nTris; + if (d2->tTexCoords) + drawSO.nTexCoords += d2->nTris; + if (d2->tNormals) + drawSO.nNormals += d2->nTris; + } + else if (d2->nQuads) + { + // quads + drawSO.nObjs++; + drawSO.nQuads += d2->nQuads/4; + drawSO.nVerts += d2->nQuads; + if (d2->qVertColors) + drawSO.nVColors += d2->nQuads; + if (d2->qTexCoords) + drawSO.nTexCoords += d2->nQuads; + if (d2->qNormals) + drawSO.nNormals += d2->nQuads; + } + + // do stuff common to both tris and quads + if (d2->nTris || d2->nQuads) + { + if (!drawSO.d2.texHash) + { + // have not yet set-up texture, set-up display parameters + drawSO.d2.texHash = d2->texHash; + } + else if(drawSO.d2.texHash != d2->texHash) + { + // will not group objects with different textures + SysLog("DrawAccountDisp2SortOnce: resource '%s' has a different texture than sort group (bg=r%ds%d)\n",r->name,1,1); + d2->mode &= ~M_RESDISPMODE_SORTONCE; +// BP(); + goto BAIL; + } + } + +DONE("DrawAccountDisp2SortOnce") + return; +} // DrawAccountDisp2SortOnce + +// +// DrawAllocateSortOnce +// +// +// in: +// out: +// global: +// +// GNP 30 Nov 05 +// +void DrawAllocateSortOnce(void) +{ + if (drawSO.flags & M_DSO_LOCKED) + return; + + drawSO.qStride = drawSO.d2BufSize = 0; + + if (drawSO.nVerts) + { + drawSO.d2BufSize += drawSO.nVerts * RESFLOATSPER_VERT*sizeof(float); + drawSO.qStride += RESFLOATSPER_VERT*sizeof(float); + } + if (drawSO.nVColors) + { + drawSO.d2BufSize += drawSO.nVColors * RESFLOATSPER_COLOR*sizeof(float); + drawSO.qStride += (RESFLOATSPER_COLOR-1)*sizeof(float); + } + if (drawSO.nTexCoords) + { + drawSO.d2BufSize += drawSO.nTexCoords * RESFLOATSPER_TEXCOORD*sizeof(float); + drawSO.qStride += RESFLOATSPER_TEXCOORD*sizeof(float); + } + if (drawSO.nNormals) + { + drawSO.d2BufSize += drawSO.nNormals * RESFLOATSPER_NORMAL*sizeof(float); + drawSO.qStride += RESFLOATSPER_NORMAL*sizeof(float); + } + + if(drawSO.d2BufSize) + { + if(MemSLow(MEMPOOL_WAVE,drawSO.d2BufSize,&drawSO.d2Buf)>=0) + { + drawSO.flags |= M_DSO_LOCKED; + } + else + { + SysLog("DrawAllocateSortOnce: could not allocate 'sort once' buffer of size %d\n",drawSO.d2BufSize); + BP(BP_DRAWALLOCATESORTONCE); + } + } +//DONE("DrawAllocateSortOnce") +} // DrawAllocateSortOnce + +// +// DrawAddDisp2SortOnce +// add this resource to the "sort once" object +// +// in: +// out: +// global: +// +// GNP 30 Nov 05 +// +void DrawAddDisp2SortOnce(ObjDispRes *odr, ResDataDisp2 *d2, crd *vm) +{ + int i; + uns32 size; + + if (d2->nTris) + { + BP(BP_DRAWADDDISP2SORTONCE); // not supporting triangles in "sort once" yet + return; + } + + // insert all quads associated data into the "sort once" object + if (d2->nQuads) + { + float *qVerts; + float *qVertColors; + float *qTexCoords; + float *qNormals; + float *pF; + + size=0; + if(qVerts = (float*)(d2->qVerts)) + size += d2->nQuads * RESFLOATSPER_VERT; + if(qVertColors = (float*)(d2->qVertColors)) + size += d2->nQuads * (RESFLOATSPER_COLOR-1); // no baked alpha color for verts + if(qTexCoords = (float*)(d2->qTexCoords)) + size += d2->nQuads * RESFLOATSPER_TEXCOORD; + if(qNormals = (float*)(d2->qNormals)) + size += d2->nQuads * RESFLOATSPER_NORMAL; + + if (drawSO.d2BufCurSize + size > drawSO.d2BufSize) + { + SysLog("DrawAddDisp2SortOnce: sort obj buffer full\n"); + BP(BP_DRAWADDDISP2SORTONCE2); + goto BAIL; + } + + drawSO.d2BufQuads += d2->nQuads; + drawSO.d2BufCurSize += size; + pF = (float*)(drawSO.d2BufCur); + + for (i=0;inQuads;i++) + { + // copy texture coordinates + if (drawSO.nTexCoords) + { + if (d2->qTexCoords) + { + *pF++ = *qTexCoords++; + *pF++ = *qTexCoords++; + } + else + { + *pF++ = 0.0f; + *pF++ = 0.0f; + } + } + // copy vert colors (no alpha) + if (drawSO.nVColors) + { + if (d2->qVertColors) + { + *pF++ = *qVertColors++; + *pF++ = *qVertColors++; + *pF++ = *qVertColors++; + qVertColors++;; // skip alpha + } + else + { + *pF++ = 1.0f; + *pF++ = 1.0f; + *pF++ = 1.0f; + } + } + // copy lighting normals, if they exist + if (drawSO.nNormals) + { + BP(BP_DRAWADDDISP2SORTONCE3); //currently lights are not enabled for "sort once" + //objects. so normals are ignored + if (d2->qNormals) + { + *pF++ = *qNormals++; + *pF++ = *qNormals++; + *pF++ = *qNormals++; + } + else + { + *pF++ = 0.0f; + *pF++ = 0.0f; + *pF++ = 1.0f; + } + } + // now transform and copy verts + VMVecMul(pF,qVerts,vm); + pF += RESFLOATSPER_VERT; + qVerts += RESFLOATSPER_VERT; + } //for + + drawSO.d2BufCur=(void*)pF; + + } //quads + + if (!drawSO.d2.texGen) + { + // have not yet set-up texture, set-up display parameters + drawSO.d2.texGen = d2->texGen; + drawSO.d2.mode = d2->mode & ~M_RESDISPMODE_SORTONCE; + drawSO.odr.flags = odr->flags; + } + +DONE("DrawAddDisp2SortOnce") + return; +} // DrawAddDisp2SortOnce + +// +// DrawHideSortOnce +// disable drawing of the 'sort once' object +// +// in: +// out: +// global: +// +// GNP 12 Jan 06 +// +void DrawHideSortOnce(void) +{ + drawSO.flags |= M_DSO_NODISPLAY; + +//DONE("DrawHideSortOnce") +} // DrawHideSortOnce + +// +// DrawUnhideSortOnce +// allow the 'sort once' object to be drawn +// +// in: +// out: +// global: +// +// GNP 12 Jan 06 +// +void DrawUnhideSortOnce(void) +{ + drawSO.flags &= ~M_DSO_NODISPLAY; +//DONE("DrawUnhideSortOnce") +} // DrawUnhideSortOnce + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/fb_gl.c b/dond/coregl/fb_gl.c new file mode 100755 index 0000000..2ca2bf4 --- /dev/null +++ b/dond/coregl/fb_gl.c @@ -0,0 +1,129 @@ +#if SYS_GL +// fb_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04; from ah/fb.c + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "int.h" +#include "fb.h" +#include "wnd.h" + +FbResInfo *FbRes; // pointer to current resolution info + +FbResInfo resTab[FB_NUM_RESOLUTION] = +{ + // 320x240 + { + 8, + 512, // must be next power of 2 from width + 320, + 240, + 1,1, // dispMulX,dispMulY + }, + // 400x256 + { + 8, + 512, // must be next power of 2 from width + 400, + 256, + 1,1, // dispMulX,dispMulY + }, + // 512x384 + { + 8, // bytes per pixel + 512, // pixel stride -- must be next power of 2 from width + 512, // pixel width + 384, // pixel height + 1,1, // dispMulX,dispMulY + }, + // 640X480 + { + 8, + 1024, // must be next power of 2 from width + 640, + 480, + 1,1, // dispMulX,dispMulY + }, + // 1366X768 + { + 8, + 2048, // must be next power of 2 from width + 1366, + 768, + 1,1, // dispMulX,dispMulY + }, + // DevInVGA -- 512x384 in 640X480 -- development resolution only + { + 8, + 1024, // must be next power of 2 from width + 512, + 384, + 1,1, // dispMulX,dispMulY + }, +}; + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 29 Aug 04 +int FbInit(void) +{ + FbRes=NUL; + return 0; +} // FbInit() + +// JFL 29 Aug 04 +void FbFinal(void) +{ +} // FbFinal() + +// JFL 29 Aug 04 +int FbReset(uns reset) +{ + return 0; +} // FbReset() + +/////////////////////////////////////////////////////////////////////////////// +// + +// GNP 24 Mar 03 +// JFL 12 Sep 03 +// JFL 29 Aug 04 +// JFL 07 Oct 04; pc version +int FbSetMode(int res) +{ + int ec; + + if (res >= FB_NUM_RESOLUTION) + { + // unsupported resolution + LOCKUP(BP_FBSETMODE); + err(-1); + } + + FbRes = &resTab[res]; + + ec=0; +BAIL: + return ec; +} // FbSetMode() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 06 Sep 04 +void FbIntHandler(void) +{ +} // FbIntHandler() + +// JFL 06 Sep 04 +void FbWriteDbgInfo(void) +{ +} // FbWriteDbgInfo() + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/font_gl.c b/dond/coregl/font_gl.c new file mode 100755 index 0000000..1feca7b --- /dev/null +++ b/dond/coregl/font_gl.c @@ -0,0 +1,1761 @@ +#if SYS_GL +// font_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 11 Oct 04 +// JFL 12 Apr 05; fonts + +//#include +#include + +#include "pm.h" +#include "sys.h" +#ifdef SYS_BB +#include +#else +#include +#endif +#include "mem.h" +#include "int.h" +#include "font.h" +#include "str.h" +#include "obj.h" +#include "fb.h" +#include "res.h" +#include "vid.h" +#include "wnd.h" + +uns8 font10System[][10] = { +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28}, +{0x00, 0x00, 0x50, 0x28, 0x7C, 0x28, 0x28, 0x7C, 0x28, 0x14}, +{0x00, 0x00, 0x20, 0x20, 0x70, 0x08, 0x30, 0x40, 0x38, 0x10}, +{0x00, 0x00, 0x00, 0x10, 0x28, 0x10, 0x78, 0x20, 0x50, 0x20}, +{0x00, 0x00, 0x00, 0x3C, 0x48, 0x58, 0x20, 0x20, 0x18, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10}, +{0x00, 0x00, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08}, +{0x00, 0x00, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x10, 0x7C, 0x10}, +{0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08}, +{0x00, 0x00, 0x20, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x64, 0x54, 0x4C, 0x38}, +{0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x70, 0x10}, +{0x00, 0x00, 0x00, 0x7C, 0x40, 0x20, 0x10, 0x08, 0x04, 0x38}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x04, 0x18, 0x04, 0x38}, +{0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7C, 0x48, 0x48, 0x08}, +{0x00, 0x00, 0x00, 0x78, 0x04, 0x04, 0x04, 0x78, 0x40, 0x7C}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x78, 0x20, 0x18}, +{0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x7C}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x30, 0x08, 0x04, 0x3C, 0x44, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00}, +{0x00, 0x00, 0x20, 0x30, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x04, 0x18, 0x60, 0x18, 0x04, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x7C, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x40, 0x30, 0x0C, 0x30, 0x40, 0x00}, +{0x00, 0x00, 0x00, 0x30, 0x00, 0x10, 0x10, 0x08, 0x48, 0x30}, +{0x00, 0x00, 0x3C, 0x40, 0x4C, 0x54, 0x54, 0x4C, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x78, 0x44, 0x78}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x44, 0x44, 0x78}, +{0x00, 0x00, 0x00, 0x7C, 0x40, 0x40, 0x40, 0x78, 0x40, 0x7C}, +{0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x78, 0x40, 0x7C}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x4C, 0x40, 0x40, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x7C, 0x44, 0x44}, +{0x00, 0x00, 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x04, 0x04, 0x04, 0x04}, +{0x00, 0x00, 0x00, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44}, +{0x00, 0x00, 0x00, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x54, 0x6C, 0x44}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x4C, 0x54, 0x64, 0x44}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x78, 0x44, 0x44, 0x78}, +{0x00, 0x00, 0x00, 0x34, 0x48, 0x54, 0x44, 0x44, 0x44, 0x38}, +{0x00, 0x00, 0x00, 0x44, 0x48, 0x50, 0x78, 0x44, 0x44, 0x78}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x04, 0x38, 0x40, 0x38}, +{0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7C}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44}, +{0x00, 0x00, 0x00, 0x10, 0x28, 0x44, 0x44, 0x44, 0x44, 0x44}, +{0x00, 0x00, 0x00, 0x28, 0x54, 0x54, 0x54, 0x54, 0x54, 0x44}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44}, +{0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x28, 0x44}, +{0x00, 0x00, 0x00, 0x7C, 0x40, 0x20, 0x10, 0x10, 0x08, 0x7C}, +{0x00, 0x00, 0x18, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x18}, +{0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40}, +{0x00, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x30}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x28, 0x10}, +{0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40}, +{0x00, 0x00, 0x00, 0x68, 0x98, 0x88, 0x78, 0x08, 0x70, 0x00}, +{0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x64, 0x58, 0x40, 0x40}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x44, 0x38, 0x00}, +{0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x4C, 0x34, 0x04, 0x04}, +{0x00, 0x00, 0x00, 0x3C, 0x40, 0x40, 0x7C, 0x44, 0x38, 0x00}, +{0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x38, 0x10, 0x10, 0x0C}, +{0x00, 0x38, 0x04, 0x3C, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x64, 0x58, 0x40}, +{0x00, 0x00, 0x00, 0x30, 0x20, 0x20, 0x20, 0x60, 0x00, 0x20}, +{0x00, 0x60, 0x90, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10}, +{0x00, 0x00, 0x00, 0x48, 0x50, 0x60, 0x50, 0x48, 0x40, 0x40}, +{0x00, 0x00, 0x00, 0x18, 0x10, 0x10, 0x10, 0x10, 0x10, 0x30}, +{0x00, 0x00, 0x00, 0x54, 0x54, 0x54, 0x54, 0x54, 0x68, 0x00}, +{0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x64, 0x58, 0x00}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00}, +{0x00, 0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x64, 0x58, 0x00}, +{0x00, 0x04, 0x04, 0x3C, 0x44, 0x44, 0x44, 0x4C, 0x34, 0x00}, +{0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x32, 0x2C, 0x00}, +{0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x38, 0x40, 0x38, 0x00}, +{0x00, 0x00, 0x00, 0x30, 0x48, 0x40, 0x40, 0x40, 0xF0, 0x40}, +{0x00, 0x00, 0x00, 0x34, 0x4C, 0x44, 0x44, 0x44, 0x44, 0x00}, +{0x00, 0x00, 0x00, 0x10, 0x28, 0x44, 0x44, 0x44, 0x44, 0x00}, +{0x00, 0x00, 0x00, 0x28, 0x54, 0x54, 0x54, 0x44, 0x44, 0x00}, +{0x00, 0x00, 0x00, 0x88, 0x50, 0x20, 0x20, 0x50, 0x88, 0x00}, +{0x00, 0x38, 0x04, 0x34, 0x4C, 0x44, 0x44, 0x44, 0x44, 0x00}, +{0x00, 0x00, 0x00, 0x7C, 0x40, 0x20, 0x10, 0x08, 0x7C, 0x00}, +{0x00, 0x08, 0x10, 0x10, 0x10, 0x30, 0x10, 0x10, 0x10, 0x08}, +{0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, +{0x00, 0x20, 0x10, 0x10, 0x10, 0x18, 0x10, 0x10, 0x10, 0x20}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x34, 0x00, 0x00, 0x00}, +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +}; // font10System + +float clut[][3] = { + 0.0, 0.0, 0.0, //BLACK + 0.5, 0.5, 0.5, //GREY + 1.0, 1.0, 1.0, //WHITE + 1.0, 1.0, 0.0, //YELLOW + 1.0, 0.8, 0.8, //RED + 0.8, 1.0, 0.8, //GREEN + 0.0, 0.0, 1.0, //BLUE + 1.0, 0.0, 1.0, //PURPLE + 0.8, 1.0, 1.0, //CYAN + 0.8, 0.8, 1.0, //LTBLUE + 1.0, 1.0, 0.8, //LTYELLOW +}; + +float defPixelMap [2] = { 0.0, 1.0 }; + +/////////////////////////////////////////////////////////////////////////////// +// + +typedef struct { + uns dummy; + char fontName[PM_NAME_SIZE]; + uns32 fontColor; +} fontGlobals; + +fontGlobals fontG; + +// JFL 29 Aug 04 +int FontInit(void) +{ + MEMZ(fontG); + return 0; +} // FontInit() + +// JFL 29 Aug 04 +void FontFinal(void) +{ +} // FontFinal() + +// JFL 29 Aug 04 +int FontReset(uns reset) +{ + fontG.fontName[0]=0; + fontG.fontColor=0; + glPixelMapfv(GL_PIXEL_MAP_I_TO_R,sizeof(defPixelMap),defPixelMap); + glPixelMapfv(GL_PIXEL_MAP_I_TO_G,sizeof(defPixelMap),defPixelMap); + glPixelMapfv(GL_PIXEL_MAP_I_TO_B,sizeof(defPixelMap),defPixelMap); + glPixelMapfv(GL_PIXEL_MAP_I_TO_A,sizeof(defPixelMap),defPixelMap); + return 0; +} // FontReset() + +// JFL 14 Apr 05 +void* FontXYStr(float x,float y,char *str) +{ + int ec; + ObjStr *ostr=NUL; + + if((ec=FontGameStr(str,NUL,M_FONTGAMESTR_CREATE,1.0,1.0,&ostr))<0) + goto BAIL; + ostr->xyadj[0]=x; + ostr->xyadj[1]=y; + +BAIL: + return ostr; +} // FontXYStr() + +// JFL 14 Apr 05 +extern void* FontXYJCStr(float x,float y,char hjust,char vjust,uns32 rgb,char *str) +{ + int ec; + ObjStr *ostr=NUL; + uns f=0; + + if(hjust=='r') + f|=M_FONTGAMESTR_HRIGHT; + else if(hjust=='h') + f|=M_FONTGAMESTR_HCENTER; + if(vjust=='b') + f|=M_FONTGAMESTR_VBOTTOM; + else if(vjust=='v') + f|=M_FONTGAMESTR_VCENTER; + + fontG.fontColor=rgb; + + if((ec=FontGameStr(str,NUL,f|M_FONTGAMESTR_CREATE,1.0,1.0,&ostr))<0) + goto BAIL; + + ostr->xyadj[0]=x; + ostr->xyadj[1]=y; + +BAIL: + return ostr; +} // FontXYJCStr() + +// JFL 14 Apr 05 +int FontColor(uns32 rgb) +{ + fontG.fontColor=rgb; + return 0; +} // FontColor() + +// JFL 12 Apr 05 +int FontSet(char *s1,char *s2) +{ + int ec; + N2ScanRec nsr; + Res *r,*r2; + ResDataFont *font; + ResDataImg1 *img; + + sz2ncpy(fontG.fontName,s1,s2,sizeof(fontG.fontName)); + + // find font res + nsr.s1=fontG.fontName; + nsr.s2=NUL; + r=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_SUB|M_N2SCAN_NAME|RESSUB_FONT,ResLoadedFirst()); + if(!r || !(font=r->data) ) + berr(-1); + + // resolve font img if not yet resolved + if(!font->texGen) + { + nsr.fdata=font->texHash; + + nsr.func3=(void*)ResNFSImg; + r2=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_FUNC|M_N2SCAN_SUB|RESSUB_IMG1,ResLoadedFirst()); + if(!r2 || !(img=r2->data)) + berr(-4); + font->texGen=img->texGen; + if(img->flags&M_RESDATAIMG1_HASALPHA) + font->flags|=M_RESDATAFONT_HASALPHA; + } // ! tex gen + + ec=0; +BAIL: + return ec; +} // FontSet() + +// JFL 14 Apr 05 +int fontHJust(ObjStrChar *osc0,ObjStrChar *osc1,float w,uns flags) +{ + int ec; + + if(!osc0||!osc1) + err(-1); + + if((flags&(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1)) + ==M_FONTGAMESTR_HCENTER) + { + w/=2; + } + else if((flags&(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1)) + ==M_FONTGAMESTR_HRIGHT) + { + } + else + err(0); // nothing to do + + for(;(memu)osc0<(memu)osc1;osc0++) + osc0->xyadj[0]+=w; + + ec=0; +BAIL: + return ec; +} // fontHJust() + +// JFL 12 Apr 05 +// JFL 06 Jun 05; fixed oscline bug +int FontGameStr(char *s1,char *s2,uns flags,float xs, float ys, void *vptr) +{ + int ec; + char c,*s3; + Res *r; + ResDataFont *font; + ResDataFChar *fc; + N2ScanRec nsr; + float x,y,fontheight,spacewidth,hspace; + float x0,y0,x1,y1,f1; + int numc; + uns size,u; + ObjStr *ostr; + ObjStrChar *osc,*osc2,*oscline; + float scrw,scrh,scrz; + + if(!s1) + err(1); + + scrw=RES_CAM2D_W; + scrh=RES_CAM2D_H; + scrz=-RES_CAM2D_Z; + + font=NUL; + x=y=0; + + // + // count the number of characters + // + + if(flags&M_FONTGAMESTR_NUMC) + numc=flags>>S_FONTGAMESTR_N; + else + { + for(numc=0,s3=s1;(c=*s3) && (!s2||(s3'); + if(!s3) + break; + s3++; + } + else if((c=='\n')||(c==' ')) + { + // skip + } + else + numc++; + } // for + } // numc + + // + // alloc + // + + if(flags&M_FONTGAMESTR_CREATE) + { + size=sizeof(ObjStr); + size+=numc*sizeof(ObjStrChar); + if((ec=ObjNew(&ostr,OBJSUB_STR,size,M_OBJNEW_DONTLINK))<0) + goto BAIL; + ostr->numc=ostr->maxc=numc; + } + else + { + if(!vptr || !(ostr=*((ObjStr**)vptr))) + berr(-4); + if(numc>ostr->maxc) + numc=ostr->maxc; + } + + if(ostr) + { + ostr->scale[0] = xs; + ostr->scale[1] = ys; + } + + if(numc) + { + osc=(void*)&ostr[1]; + oscline=osc; + } + else + { + osc=oscline=NUL; + } + + // reset for new string + ostr->numc=0; + ostr->flags&=~M_OBJSTR_HASALPHA; + + // + // set/change to a new font + // + +changefont: + if(fontG.fontName[0]) + { + // find font res + nsr.s1=fontG.fontName; + nsr.s2=NUL; + r=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_SUB|M_N2SCAN_NAME|RESSUB_FONT,ResLoadedFirst()); + if(!r || !(font=r->data) || !(fc=font->fcs)) + berr(-1); + fontheight=fc->camsize[1]*ostr->scale[1]; + + spacewidth=fc->camsize[0]*ostr->scale[0]; + if (fc->campivot[0] > 0) + spacewidth *= fc->campivot[0]; + + hspace=0; + + ostr->texGen=font->texGen; + + if(font->flags&M_RESDATAFONT_HASALPHA) + ostr->flags|=M_OBJSTR_HASALPHA; + + } // font + + // + // run through all the characters + // + + +charlp: + if(!(c=*s1) || (s2&&(s1>=s2))) + goto done; + s1++; + if(c=='<') + { + // note: leave s2 alone -- it's the end of the string + switch(*s1) + { + case 'f': + s3=2+s1; + s1=szchr(s3,NUL,'>'); + FontSet(s3,s1); + s1++; + goto changefont; + case 'j': + // example: + // drop all flags + flags&=~(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1 + |M_FONTGAMESTR_VJUST0|M_FONTGAMESTR_VJUST1); + s1+=2; + for(;;) + { + if(*s1=='>') + { + s1++; + break; + } + switch(*s1) + { + case 0: + berr(-1); // premature end -- no closing '>' + break; + case 'r': + flags|=M_FONTGAMESTR_HRIGHT; + break; + case 'h': + flags|=M_FONTGAMESTR_HCENTER; + break; + case 'b': + flags|=M_FONTGAMESTR_VBOTTOM; + break; + case 'v': + flags|=M_FONTGAMESTR_VCENTER; + break; + } // switch + s1++; + } // for + break; + case 'x': // + s3=szskipwhite(s1+3); + s1=szskiptowhite(1+s3); + s1=szto(s3,s1,'f',0,&f1); + ostr->xyadj[0]=f1; + + s3=szskipwhite(s1+1); + s1=szskiptowhite(1+s3); + s1=szto(s3,s1,'f',0,&f1); + ostr->xyadj[1]=f1; + + s1=szchr(s1,NUL,'>'); + s1++; + break; + case 'c': // + s1+=2; + s1=szto(s1,s2,'u',0,&u); + fontG.fontColor=u; + s1=szchr(s1,NUL,'>'); + s1++; + break; + } // switch + } // angle + else if(c=='\\') + { + switch(*s1++) + { + case 'n': + goto newline; + } // switch + } + else + { + if(!font) + berr(-4); + if(ostr->numc>=ostr->maxc) + goto done; + switch(c) + { + case '\n': +newline: + // if this line is wider than widest so far, remember + if(ostr->wh[0]wh[0]=x; + + if(flags&(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1)) + { + oscline->user[0]=1; // signal start of new line + oscline->xyadj[0]=x; // width of this line + } + oscline=osc; // first char on new line + y-=fontheight; + x=0; + break; + case ' ': + x+=spacewidth; + break; + default: + for(ec=0,fc=font->fcs;ecnumfcs;ec++,fc++) + { + if(c==fc->ascii) + goto gotascii; + } // for + fc=font->fcs; // use first +gotascii: + osc->uvbox[BOX_L]=fc->uvbox[BOX_L]; + osc->uvbox[BOX_T]=fc->uvbox[BOX_T]; + osc->uvbox[BOX_R]=fc->uvbox[BOX_R]; + osc->uvbox[BOX_B]=fc->uvbox[BOX_B]; + + x0=x; + // x0-=fc->campivot[0]; // -- xpivot not set correctly yet.. + x1=x0+fc->camsize[0]*ostr->scale[0]; + + y1=y; + y1-=((fc->camsize[1]*ostr->scale[1])-(fc->campivot[1]*ostr->scale[1])); + y0=y1+(fc->camsize[1]*ostr->scale[1]); + + osc->verts[0*3+0]=x0; + osc->verts[0*3+1]=y0; + osc->verts[0*3+2]=scrz; + + osc->verts[1*3+0]=x1; + osc->verts[1*3+1]=y1; + osc->verts[1*3+2]=scrz; + + osc->rgb=fontG.fontColor; + + // setup tmp name + if(ostr->numc<(sizeof(ostr->name)-1)) + {ostr->name[ostr->numc]=c;ostr->name[ostr->numc+1]=0;} + + // next char + ostr->numc++; + osc++; + + // - the campivot value is used here as the "correction factor" between the + // the old and new way of determining font spacing in the dc compiler. + if (fc->campivot[0] > 0) + x+=(fc->camsize[0]*ostr->scale[0] * fc->campivot[0])+hspace; + else + x+=(fc->camsize[0]*ostr->scale[0])+hspace; + + } // switch + } // normal char + + goto charlp; +done: + + if(x) // if we didn't end on a blank line (newline) + y-=fontheight; // move y down (for vjust) + + // string width & height + if(ostr->wh[0]wh[0]=x; // grow width + ostr->wh[1]=-y; // set height (positive) + + if((flags&(M_FONTGAMESTR_VJUST0|M_FONTGAMESTR_VJUST1))&&numc) + { + if((flags&(M_FONTGAMESTR_VJUST0|M_FONTGAMESTR_VJUST1)) + ==M_FONTGAMESTR_VCENTER) + y=-y/2; // adj so line's center x is at 0 + else if((flags&(M_FONTGAMESTR_VJUST0|M_FONTGAMESTR_VJUST1)) + ==M_FONTGAMESTR_VBOTTOM) + y=-y; + else + y=0; + + // adjust each char + for(osc2=(void*)&ostr[1];(memu)osc2<(memu)osc;osc2++) + osc2->xyadj[1]=y; + + } // vjust + + if((flags&(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1))&&numc) + { + oscline->user[0]=1; // signal start of new line + oscline->xyadj[0]=x; // width of this line + + // adjust each line + for(osc2=(void*)&ostr[1];(memu)osc2<(memu)osc;osc2++) + { + if(osc2->user[0]) // start of a new line + { + osc2->user[0]=0; + + x=0; + if((flags&(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1)) + ==M_FONTGAMESTR_HCENTER) + x=-osc2->xyadj[0]/2; // adj so line's center x is at 0 + else if((flags&(M_FONTGAMESTR_HJUST0|M_FONTGAMESTR_HJUST1)) + ==M_FONTGAMESTR_HRIGHT) + x=-osc2->xyadj[0]; // adj so line's right is at 0 + } + osc2->xyadj[0]=x; + } // for + + } // hjust + + if(flags&M_FONTGAMESTR_CREATE) + { + if(vptr) + *((ObjStr**)vptr)=ostr; + } + + ec=0; +BAIL: + return ec; +} // FontGame() + +typedef struct { + int left,right,top,bottom; +} LRTB; + +// +// FontSys +// print string on screen using system font +// +// in: +// str = ptr to string +// x = screen x +// y = screen y +// w = max width of string +// h = max height of string +// flags = print flags +// colobj = ptr to text collision box (NUL=none) +// out: +// global: +// +// JFL 11 Oct 04 +// JFL 12 Apr 05 +// +int FontSys(char *str,int x,int y,int w,int h,uns flags,void *colobj) +{ + int ec; + int i,n,inangle=0,ending; + int colorstack[4],colordepth=0; + uns8 c,d; + int x0,y0,x1,y1,xx,yy,yt,yb,xl,xr; + int cw,ch; + ObjColDefText *ctext=NUL; + char *s1; + + if(!str) + err(0); + + x0=x; + y0=y; + x1=x+w-1; + y1=y+h-1; + xx=x; + yy=y; + + // defaults + i=2; + colorstack[colordepth++]=i; +// if (flags&M_FONTSYSFLAG_NOBLEND) + glDisable(GL_BLEND); +// else +// glEnable(GL_BLEND); + + glDisable(GL_TEXTURE_2D); + + glPixelStorei (GL_UNPACK_ALIGNMENT,1); + glColor3f(clut[i][0], clut[i][1], clut[i][2]); + cw=8; + ch=10; + + // + // scan string + // look for commands & special chars + // + + n=0; + for(;;) + { + if(!(c=*str++)) + break; + if(c=='\n') + goto newline; + else if(inangle || (c=='<')) + { + // + // HANDLE ANGLE BRACKETS + // + + // bold + // color 1color 0color off + // underline + //

style h1

+ // anchor + // fontname + if(c=='<') + { + inangle++; + ending=0; + c=*str++; + } + d=*str; // look-ahead + switch(c) + { + case 'a': + if(!C_IS_LABEL(d)) + { + if(ending) + { + // anchor-off + ctext=NUL; + } + else + { + // anchor-on + if(!(ctext=ObjGetCol(sizeof(ObjColDefText),OBJCOLDEFTYPE_TEXT,NUL))) + break; + + // big box is the whole area + ctext->boxBig[BOX_L]=x0; + ctext->boxBig[BOX_T]=y0-ch; + ctext->boxBig[BOX_R]=ctext->boxBig[BOX_L]+w-1; + ctext->boxBig[BOX_B]=ctext->boxBig[BOX_T]+h-1; + + // top box and bot box are set to swapped coords + // so as they can be stretched during the build + ctext->boxTop[BOX_L]=ctext->boxBig[BOX_R]; + ctext->boxTop[BOX_T]=ctext->boxBig[BOX_B]; + ctext->boxTop[BOX_R]=ctext->boxBig[BOX_L]; + ctext->boxTop[BOX_B]=ctext->boxBig[BOX_T]; + + // bot box + ctext->boxBot[BOX_L]=ctext->boxBig[BOX_R]; + ctext->boxBot[BOX_T]=ctext->boxBig[BOX_B]; + ctext->boxBot[BOX_R]=ctext->boxBig[BOX_L]; + ctext->boxBot[BOX_B]=ctext->boxBig[BOX_T]; + + ctext->p=colobj; + ctext->d=1+str; + } + } + break; + case 'b': + if(!C_IS_LABEL(d)) + { + if(ending) + i=0; // bold-off + else + i=1; // bold-on + } + break; + case 'c': + + if(ending) + { + // color-off + if(colordepth>1) + colordepth--; + i=colorstack[colordepth-1]; + glColor3f(clut[i][0], clut[i][1], clut[i][2]); + } + else if(C_IS_DIGIT(d)) + { + str=szto(str,NUL,'i',10,&i); + // i=strtol(str,&str,10); + if(i'); + FontSet(s1,str); + break; // f + case 'u': + if(!C_IS_LABEL(d)) + { + if(ending) + i=0; // underline-off + else + i=1; // underline-on + } + break; + case '>': + inangle--; + break; + case '/': + ending=1; + break; + } // switch + continue; + } // angle + + // + // DRAW CHARACTER + // + + // text collision box + if(ctext) + { + xl=xx; // left + xr=xl+cw-1; // right + yt=yy-ch+2; // top + yb=yt+ch-1; // bot + + // + // top left + // + + // check if this grows the top box + if(ctext->boxTop[BOX_T]>=yt) + { + if(ctext->boxTop[BOX_T]>yt) + { + ctext->boxTop[BOX_L]=xl; + ctext->boxTop[BOX_R]=xr; + } + else + { + if(ctext->boxTop[BOX_L]>xl) + ctext->boxTop[BOX_L]=xl; + if(ctext->boxTop[BOX_R]boxTop[BOX_R]=xr; + } + ctext->boxTop[BOX_T]=yt; + ctext->boxTop[BOX_B]=yb; + } + + // + // bottom right + // + + // check if this grows the bot box + if(ctext->boxBot[BOX_B]<=yb) + { + if(ctext->boxBot[BOX_B]boxBot[BOX_L]=xl; + ctext->boxBot[BOX_R]=xr; + } + else + { + if(ctext->boxBot[BOX_L]>xl) + ctext->boxBot[BOX_L]=xl; + if(ctext->boxBot[BOX_R]boxBot[BOX_R]=xr; + } + ctext->boxBot[BOX_T]=yt; + ctext->boxBot[BOX_B]=yb; + } + + } // ctext + + c-=' '; + glRasterPos2i(xx,yy); + glBitmap(cw,ch,0,2,8,0,font10System[c]); +// glRasterPos2i(xx,yy+3); +// glDrawPixels(cw,ch,GL_COLOR_INDEX,GL_BITMAP,font10System[c]); + glRasterPos2i(xx+8,yy); + xx+=cw+FONT_SYSSPACE; + + if(xx+cw>x1) + { +newline: + yy+=ch+FONT_SYSSPACE; + if(yy+ch>y1) + break; + xx=x; + glRasterPos2i(xx,yy); + } + + } // for + + ec=0; +BAIL: + return ec; +} // FontSys() + +#define FONT_HEIGHT 12 +#define FONT_WIDTH 8 +#define MENUBAR_HT 10 + +// JFL 11 Nov 04 +int FontObjText(void *objtext) +{ + float x,y,xx,yy; + ObjText *text=objtext; + + glDisable(GL_TEXTURE_2D); + + // draw translucent backing + glColor4ub(0,0,0,64); + glEnable(GL_BLEND); // looks better if shadow is blended + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glPolygonMode(GL_FRONT,GL_FILL); + glShadeModel(GL_FLAT); + x=text->box[BOX_X]; + y=text->box[BOX_Y]; + xx=x+text->box[BOX_W]; + yy=y+text->box[BOX_H]; + glBegin(GL_QUADS); + glVertex2f(x,y); + glVertex2f(x,yy); + glVertex2f(xx,yy); + glVertex2f(xx,y); + glEnd(); + + // draw text +// glDisable(GL_BLEND); // looks better if shadow is blended + glColor3ub(255,255,255); // white + FontSys(text->str,text->box[BOX_X]+FONT_WIDTH, + text->box[BOX_Y]+FONT_HEIGHT, + text->box[BOX_W],text->box[BOX_H],0,text); + + return 0; +} // FontObjText() + +// JFL 01 Dec 04 +int FontObjInfo(void *objtext,int info,void *res) +{ + switch(info) + { + case FONTINFO_CHAR_WIDTH_HEIGHT: + ((int*)res)[0]=8; + ((int*)res)[1]=10; + break; + default: + return -1; + } + return 0; +} // FontObjInfo() + +#define EDGESIZE 4 +#define SCROLLBAR_W 12 +#define SCROLL_BTTN_H 12 +#define SCROLL_THUMB_H2 6 +#define FONTHEIGHT 10 +#define FONTWIDTH 8 + +void TBDrawScrollBar(ObjText *text, EditTextBox *tb,uns32 flags) +{ + LRTB scrollBox; + LRTB sBArrowUpBox; + LRTB sBArrowDnBox; + LRTB sBThumbBox; + float sBY,thumbY; + int yOff; + + + if(flags & TB_KILLABLE) + yOff = SCROLLBAR_W; + else + yOff = 0; + + scrollBox.left = text->box[BOX_X]+text->box[BOX_W]-EDGESIZE-SCROLLBAR_W; + scrollBox.top = text->box[BOX_Y]+EDGESIZE+1+yOff; + scrollBox.right = text->box[BOX_X]+text->box[BOX_W]-EDGESIZE-1; + scrollBox.bottom = text->box[BOX_Y]+text->box[BOX_H]-EDGESIZE-1; + + sBArrowUpBox.left = scrollBox.left; + sBArrowUpBox.top = scrollBox.top; + sBArrowUpBox.right = scrollBox.right; + sBArrowUpBox.bottom = scrollBox.top + SCROLL_BTTN_H; + + sBArrowDnBox.left = scrollBox.left; + sBArrowDnBox.top = scrollBox.bottom - SCROLL_BTTN_H; + sBArrowDnBox.right = scrollBox.right; + sBArrowDnBox.bottom = scrollBox.bottom; + + sBY = (float)(text->box[BOX_H] - (2*(EDGESIZE+1) - (2*SCROLL_BTTN_H))); + if(tb->objn) + { + float n; + + n = (float)((float)tb->objtop/(float)tb->objn); + + thumbY = n * sBY; + } + else + thumbY = 0; + + sBThumbBox.left = scrollBox.left; + sBThumbBox.top = (int)(text->box[BOX_Y]+EDGESIZE+SCROLL_BTTN_H+1+SCROLL_THUMB_H2 + thumbY - (SCROLL_THUMB_H2)); + sBThumbBox.right = scrollBox.right; + sBThumbBox.bottom = (int)(text->box[BOX_Y]+EDGESIZE+SCROLL_BTTN_H+1+SCROLL_THUMB_H2 + thumbY + (SCROLL_THUMB_H2)); + + + + + //---- BAR ---------- + glColor3ub(128,128,128); + + glBegin(GL_POLYGON); + + glVertex2i(scrollBox.left,scrollBox.top); + glVertex2i(scrollBox.left,scrollBox.bottom); + glVertex2i(scrollBox.right,scrollBox.bottom); + glVertex2i(scrollBox.right,scrollBox.top); + + glEnd(); + + //----- Up Arrow -------- + glColor3ub(96,96,96); + glBegin(GL_POLYGON); + glVertex2i(sBArrowUpBox.left,sBArrowUpBox.top); + glVertex2i(sBArrowUpBox.left,sBArrowUpBox.bottom); + glVertex2i(sBArrowUpBox.right,sBArrowUpBox.bottom); + glVertex2i(sBArrowUpBox.right,sBArrowUpBox.top); + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + glVertex2i(sBArrowUpBox.left,sBArrowUpBox.top); + glVertex2i(sBArrowUpBox.left,sBArrowUpBox.bottom); + glVertex2i(sBArrowUpBox.right,sBArrowUpBox.bottom); + glVertex2i(sBArrowUpBox.right,sBArrowUpBox.top); + glEnd(); + + + //----- Dn Arrow ----------- + glColor3ub(96,96,96); + glBegin(GL_POLYGON); + glVertex2i(sBArrowDnBox.left,sBArrowDnBox.top); + glVertex2i(sBArrowDnBox.left,sBArrowDnBox.bottom); + glVertex2i(sBArrowDnBox.right,sBArrowDnBox.bottom); + glVertex2i(sBArrowDnBox.right,sBArrowDnBox.top); + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + glVertex2i(sBArrowDnBox.left,sBArrowDnBox.top); + glVertex2i(sBArrowDnBox.left,sBArrowDnBox.bottom); + glVertex2i(sBArrowDnBox.right,sBArrowDnBox.bottom); + glVertex2i(sBArrowDnBox.right,sBArrowDnBox.top); + glEnd(); + + + + //----- Thumb ----------- + glColor3ub(96,96,96); + glBegin(GL_POLYGON); + glVertex2i(sBThumbBox.left,sBThumbBox.top); + glVertex2i(sBThumbBox.left,sBThumbBox.bottom); + glVertex2i(sBThumbBox.right,sBThumbBox.bottom); + glVertex2i(sBThumbBox.right,sBThumbBox.top); + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + glVertex2i(sBThumbBox.left,sBThumbBox.top); + glVertex2i(sBThumbBox.left,sBThumbBox.bottom); + glVertex2i(sBThumbBox.right,sBThumbBox.bottom); + glVertex2i(sBThumbBox.right,sBThumbBox.top); + glEnd(); + + + + //----- border (last) -------- + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + + glVertex2i(scrollBox.left,scrollBox.top); + glVertex2i(scrollBox.left,scrollBox.bottom); + glVertex2i(scrollBox.right,scrollBox.bottom); + glVertex2i(scrollBox.right,scrollBox.top); + + glEnd(); + +} + +#define ICONBAR_HT 30 +#define ICON_HT 16 + +int TBDrawIconBar(ObjText *text, EditTextBox *tb) +{ + + float iBox[4]; + + iBox[0] = (float)(text->box[BOX_X]); + iBox[1] = (float)(text->box[BOX_Y]+text->box[BOX_H]); + iBox[2] = (float)(text->box[BOX_X]+text->box[BOX_W]); + iBox[3] = (float)(text->box[BOX_Y]+text->box[BOX_H]+ICONBAR_HT); + + //--- window bg ------- + glColor3ub(144,144,144); + glBegin(GL_POLYGON); + glVertex2f(iBox[0],iBox[1]); + glVertex2f(iBox[0],iBox[3]); + glVertex2f(iBox[2],iBox[3]); + glVertex2f(iBox[2],iBox[1]); + glEnd(); + +// FontSys("Add Deer"); + + if(tb->menu1) + FontSys((char *)tb->menu1->mString, (int)iBox[0]+FONTWIDTH,(int)iBox[1]+FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + if(tb->menu2) + FontSys((char *)tb->menu2->mString, (int)iBox[0]+FONTWIDTH,(int)iBox[1]+FONTHEIGHT*2, + text->box[BOX_W],ICONBAR_HT,0,text); + + + return 0; +} // TBDrawIconBar() + + +int TBDrawTextBox(ObjText *text, EditTextBox *tb,uns32 flags) +{ + //--- window bg ------- + if(flags&TB_TEXT) + glColor3ub(0,0,0); + else + glColor3ub(160,160,160); + + glBegin(GL_POLYGON); + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + glEnd(); + + //--- Right edge ------- + glColor3ub(128,128,128); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+text->box[BOX_H]-EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + glEnd(); + + //--- bottom edge ------- + glColor3ub(96,96,96); + glBegin(GL_POLYGON); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+text->box[BOX_H]-EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+text->box[BOX_H]-EDGESIZE)); + glEnd(); + + //--- left edge ------- + glColor3ub(192,192,192); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X]),(float)(text->box[BOX_Y])); + glVertex2f((float)(text->box[BOX_X]),(float)text->box[BOX_Y]+text->box[BOX_H]); + glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+text->box[BOX_H]-EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glEnd(); + + + //--- Top edge ------- + glColor3ub(224,224,224); + glBegin(GL_POLYGON); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y])); + glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y])); + glEnd(); + + if(flags & TB_TITLEBAR) + { + glColor3ub(160,160,224); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+FONTHEIGHT)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+FONTHEIGHT)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glEnd(); + } + + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + + glEnd(); + + + if(flags & TB_SCROLL) + TBDrawScrollBar(text,tb,flags); + if ( !(flags & TB_DIALOG)) + { + if(tb->menu1||tb->menu2||tb->menu3) + TBDrawIconBar(text,tb); + } + + if(flags & TB_KILLABLE) + { + glColor3ub(224,0,0); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+SCROLLBAR_W)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(0*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+SCROLLBAR_W)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(0*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glEnd(); + glColor3ub(255,224,224); + glBegin(GL_LINE_LOOP); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+SCROLLBAR_W)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(0*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+SCROLLBAR_W)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(0*SCROLLBAR_W)-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + glEnd(); + FontSys("X",(text->box[BOX_X]+text->box[BOX_W]-((int)(0.7*SCROLLBAR_W))-EDGESIZE), + (text->box[BOX_Y]+EDGESIZE+((int)(0.8*SCROLLBAR_W))), + text->box[BOX_W],text->box[BOX_H],0,text); + } + + if(flags & TB_DIALOG) + { + glColor3ub(0,0,0); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X]+(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(2.7*FONTHEIGHT))); + glVertex2f((float)(text->box[BOX_X]+(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(4.3*FONTHEIGHT))); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(4.3*FONTHEIGHT))); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(2.7*FONTHEIGHT))); + glEnd(); + glColor3ub(255,255,255); + glBegin(GL_LINE_LOOP); + glVertex2f((float)(text->box[BOX_X]+(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(2.7*FONTHEIGHT))); + glVertex2f((float)(text->box[BOX_X]+(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(4.3*FONTHEIGHT))); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(4.3*FONTHEIGHT))); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-(1*SCROLLBAR_W)-(EDGESIZE*2)),(float)(text->box[BOX_Y]+EDGESIZE+(2.7*FONTHEIGHT))); + glEnd(); + } + + + + + return 0; +} // TBDrawTextBox() + + +int TBDrawMousePickBox(ObjText *text, uns32 flags) +{ + + if(flags & TB_MPICK_ACTIVE) + { + glColor3ub(128,128,128); + + glBegin(GL_POLYGON); + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + glEnd(); + } + + //--- window bg ------- + glColor3ub(255,255,255); + + glBegin(GL_LINE_LOOP); + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + glEnd(); + + return 0; +} // TBDrawMousePickBox() + + + +#define HALF_THUMB_WIDTH 6 +#define INFO_AREA_W 80 + +void TBDrawSliderBar(ObjText *text, EditTextBox *tb) +{ + + float barRect[4]; + float thumbRect[4]; + float thumbX,pixPerFrame; +// char buf[80]; + + barRect[BOX_X]= (float)text->box[BOX_X] + EDGESIZE*4 + INFO_AREA_W; + barRect[BOX_Y]= (float)text->box[BOX_Y] + (float)(EDGESIZE*3.5); + barRect[BOX_W]= (float)text->box[BOX_W] - INFO_AREA_W - EDGESIZE*4*2; + barRect[BOX_H]= (float)EDGESIZE; + + //play triangle + glColor3ub(144,144,144); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*2.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*5.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/4+INFO_AREA_W/5)),(float)(text->box[BOX_Y] + EDGESIZE*4)); + glEnd(); + + glColor3ub(96,96,96); + glBegin(GL_LINE_LOOP); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*2.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*5.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/4+INFO_AREA_W/5)),(float)(text->box[BOX_Y] + EDGESIZE*4)); + glEnd(); + + //stop box + glColor3ub(144,144,144); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2+INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2+INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glEnd(); + + glColor3ub(96,96,96); + glBegin(GL_LINE_LOOP); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2+INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (INFO_AREA_W/2+INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glEnd(); + + + //restart icon + glColor3ub(144,144,144); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (7*INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*5.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (7*INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*2.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (7*INFO_AREA_W/8-INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*4)); + glEnd(); + + glColor3ub(96,96,96); + glBegin(GL_LINE_LOOP); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (7*INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*5.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (7*INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*2.5)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (7*INFO_AREA_W/8-INFO_AREA_W/8)),(float)(text->box[BOX_Y] + EDGESIZE*4)); + glEnd(); + + glColor3ub(144,144,144); + glBegin(GL_POLYGON); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4-EDGESIZE)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4-EDGESIZE)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glEnd(); + + glColor3ub(96,96,96); + glBegin(GL_LINE_LOOP); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4-EDGESIZE)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4-EDGESIZE)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*5.2)); + glVertex2f((float)(text->box[BOX_X] + EDGESIZE*4 + (3*INFO_AREA_W/4)),(float)(text->box[BOX_Y] + EDGESIZE*2.8)); + glEnd(); + + + + glColor3ub(80,80,80); + glBegin(GL_POLYGON); + glVertex2f(barRect[BOX_X],barRect[BOX_Y]); + glVertex2f(barRect[BOX_X],barRect[BOX_Y]+barRect[BOX_H]); + glVertex2f(barRect[BOX_X]+barRect[BOX_W],barRect[BOX_Y]+barRect[BOX_H]); + glVertex2f(barRect[BOX_X]+barRect[BOX_W],barRect[BOX_Y]); + glEnd(); + + + glColor3ub(224,224,224); + glBegin(GL_LINE_LOOP); + glVertex2f(barRect[BOX_X],barRect[BOX_Y]+barRect[BOX_H]); + glVertex2f(barRect[BOX_X]+barRect[BOX_W],barRect[BOX_Y]+barRect[BOX_H]); +// glVertex2f(barRect[BOX_X]+barRect[BOX_W],barRect[BOX_Y]+barRect[BOX_H]+1); +// glVertex2f(barRect[BOX_X],barRect[BOX_Y]+barRect[BOX_H]+1); + glEnd(); + + pixPerFrame = barRect[BOX_W]/800; + if(tb->objn < 800) + thumbX = barRect[BOX_X] + tb->objn * pixPerFrame; + + thumbRect[BOX_X] = thumbX - HALF_THUMB_WIDTH; + thumbRect[BOX_Y] = (float)text->box[BOX_Y]+EDGESIZE*2; + thumbRect[BOX_W] = HALF_THUMB_WIDTH*2; + thumbRect[BOX_H] = (float)(text->box[BOX_H]-(EDGESIZE*4)); + + //----- Thumb ----------- + glColor3ub(192,192,192); + glBegin(GL_POLYGON); + glVertex2f(thumbRect[BOX_X],thumbRect[BOX_Y]); + glVertex2f(thumbRect[BOX_X],thumbRect[BOX_Y]+thumbRect[BOX_H]); + glVertex2f(thumbRect[BOX_X]+thumbRect[BOX_W],thumbRect[BOX_Y]+thumbRect[BOX_H]); + glVertex2f(thumbRect[BOX_X]+thumbRect[BOX_W],thumbRect[BOX_Y]); + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + glVertex2f(thumbRect[BOX_X],thumbRect[BOX_Y]); + glVertex2f(thumbRect[BOX_X],thumbRect[BOX_Y]+thumbRect[BOX_H]); + glVertex2f(thumbRect[BOX_X]+thumbRect[BOX_W],thumbRect[BOX_Y]+thumbRect[BOX_H]); + glVertex2f(thumbRect[BOX_X]+thumbRect[BOX_W],thumbRect[BOX_Y]); + glEnd(); + +#if 0 + //draw frame num + szbuild(buf,sizeof(buf),"GameWaveTime: %d\n",GameWaveTime); + FontSys(buf, text->box[BOX_X],text->box[BOX_Y]-7*FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + + szbuild(buf,sizeof(buf),"GameWaveStart: %d\n",GameWaveStart); + FontSys(buf, text->box[BOX_X],text->box[BOX_Y]-6*FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + + + szbuild(buf,sizeof(buf),"GameLp.pauseTime: %d\n",GameLp.pauseTime); + FontSys(buf, text->box[BOX_X],text->box[BOX_Y]-5*FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + + szbuild(buf,sizeof(buf),"currFrame: %d\n",pESB->scene.currFrame); + FontSys(buf, text->box[BOX_X],text->box[BOX_Y]-4*FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + + szbuild(buf,sizeof(buf),"startFrame: %d\n",pESB->scene.startFrame); + FontSys(buf, text->box[BOX_X],text->box[BOX_Y]-3*FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + + szbuild(buf,sizeof(buf),"endFrame: %d\n",pESB->scene.endFrame); + FontSys(buf, text->box[BOX_X],text->box[BOX_Y]-2*FONTHEIGHT, + text->box[BOX_W],ICONBAR_HT,0,text); + +#endif + +} + + + +void DrawSelBox(ObjText *text, int n, char *nameBuf) +{ + glColor3ub(255,255,0); + glBegin(GL_LINE_LOOP); + + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_POLYGON); + + glVertex2f((float)text->box[BOX_X]+2,(float)text->box[BOX_Y]+2); + glVertex2f((float)text->box[BOX_X]+2,(float)(text->box[BOX_Y]+FONTHEIGHT+8)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-2),(float)(text->box[BOX_Y]+FONTHEIGHT+8)); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-2),(float)text->box[BOX_Y]+2); + + glEnd(); + + + FontSys(nameBuf,text->box[BOX_X]+FONT_WIDTH,text->box[BOX_Y]+FONT_HEIGHT, + text->box[BOX_W],text->box[BOX_H],0,text); + +} + +#define ANIBARHT 25 +#define ANIBARHT_2 15 +#define FR_OFF 0 +#define FR_SIZE 4*FONT_WIDTH +#define NAME_OFF 30 +#define NAME_SIZE 18*FONT_WIDTH +#define FL1_OFF 140 +#define FL_SIZE 2*FONT_WIDTH +#define FL2_OFF 154 +#define FL3_OFF 168 +#define FL4_OFF 182 +#define MULT_OFF 200 +#define MULT_SIZE 5*FONT_WIDTH + +int TBDrawDeerAnimBox(void *vtext, uns flags, void* vpap, int numAniPts, float splspeed) +{ + ObjText *text=vtext; + aniPt* pAP=vpap; + int i,aFrame; + char aniBuf[256]; + float speed = splspeed; + + //draw title bar + //glColor3ub(160,160,224); + //glBegin(GL_POLYGON); + //glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + //glVertex2f((float)(text->box[BOX_X]+EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+FONTHEIGHT)); + //glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE+FONTHEIGHT)); + //glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]-EDGESIZE),(float)(text->box[BOX_Y]+EDGESIZE)); + //glEnd(); + + float aBox[4]; + aBox[BOX_X]=(float)(text->box[BOX_X] + EDGESIZE); + aBox[BOX_Y]=(float)(text->box[BOX_Y] + EDGESIZE + 2+ FONTHEIGHT); + aBox[BOX_W]=(float)(text->box[BOX_W] - 2*EDGESIZE - 2); + aBox[BOX_H]=(float)(ANIBARHT); + + + szbuild(aniBuf,sizeof(aniBuf),"%f",splspeed); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FL1_OFF-4),(int)(aBox[BOX_Y]-3), + MULT_SIZE*5,(int)(aBox[BOX_H]),0,text); + + FontSys("KILL",(int)(aBox[BOX_X]+MULT_OFF),(int)(aBox[BOX_Y]-3), + MULT_SIZE,(int)(FONTHEIGHT*1.5),0,text); + + for(i=0;ibox[BOX_X] + EDGESIZE); + aBox[BOX_Y]=(float)(text->box[BOX_Y] + EDGESIZE + 2+ FONTHEIGHT + i*ANIBARHT); + aBox[BOX_W]=(float)(text->box[BOX_W] - 2*EDGESIZE - 2); + aBox[BOX_H]=(float)(ANIBARHT); + + glColor3ub(140,60,60); + glBegin(GL_POLYGON); + glVertex2f(aBox[BOX_X], aBox[BOX_Y]); + glVertex2f(aBox[BOX_X], aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+aBox[BOX_W], aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+aBox[BOX_W], aBox[BOX_Y]); + glEnd(); + + glColor3ub(100,40,40); + glBegin(GL_POLYGON); + glVertex2f(aBox[BOX_X]+NAME_OFF, aBox[BOX_Y]); + glVertex2f(aBox[BOX_X]+NAME_OFF, aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+NAME_SIZE, aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+NAME_SIZE, aBox[BOX_Y]); + glEnd(); + + glColor3ub(100,40,40); + glBegin(GL_POLYGON); + glVertex2f(aBox[BOX_X]+MULT_OFF, aBox[BOX_Y]); + glVertex2f(aBox[BOX_X]+MULT_OFF, aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+MULT_OFF+MULT_SIZE, aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+MULT_OFF+MULT_SIZE, aBox[BOX_Y]); + glEnd(); + + glColor3ub(240,140,140); + glBegin(GL_LINE_LOOP); + glVertex2f(aBox[BOX_X], aBox[BOX_Y]); + glVertex2f(aBox[BOX_X], aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+aBox[BOX_W], aBox[BOX_Y]+aBox[BOX_H]); + glVertex2f(aBox[BOX_X]+aBox[BOX_W], aBox[BOX_Y]); + glEnd(); + + aFrame = pAP[i].aniFrame + pAP[i].startFrame; + + szbuild(aniBuf,sizeof(aniBuf),"%d",aFrame); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FR_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + FR_SIZE,(int)(aBox[BOX_H]),0,text); + + szbuild(aniBuf,sizeof(aniBuf),"%s",pAP[i].aniName); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+NAME_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + NAME_SIZE,(int)(aBox[BOX_H]),0,text); + + if(pAP[i].aniFlags & ANI_SNAP) + { + szbuild(aniBuf,sizeof(aniBuf),"%c",'*'); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FL1_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + FL_SIZE,(int)(aBox[BOX_H]),0,text); + } + + if(pAP[i].aniFlags & ANI_LOOP) + { + szbuild(aniBuf,sizeof(aniBuf),"%c",'L'); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FL2_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + FL_SIZE,(int)(aBox[BOX_H]),0,text); + } + + if(pAP[i].aniFlags & ANI_LOOP_OFF) + { + szbuild(aniBuf,sizeof(aniBuf),"%c",'-'); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FL2_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + FL_SIZE,(int)(aBox[BOX_H]),0,text); + } + + if(pAP[i].aniFlags & ANI_SYNC) + { + szbuild(aniBuf,sizeof(aniBuf),"%c",'S'); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FL3_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + FL_SIZE,(int)(aBox[BOX_H]),0,text); + } + + if(pAP[i].aniFlags & ANI_BRIDGE) + { + szbuild(aniBuf,sizeof(aniBuf),"%c",'B'); + FontSys(aniBuf,(int)(aBox[BOX_X]+FONT_WIDTH+FL4_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + FL_SIZE,(int)(aBox[BOX_H]),0,text); + } + + szbuild(aniBuf,sizeof(aniBuf),"%f",pAP[i].aniSpeed); + FontSys(aniBuf,(int)(aBox[BOX_X]+EDGESIZE+MULT_OFF),(int)(aBox[BOX_Y]+ANIBARHT_2), + MULT_SIZE*5,(int)(aBox[BOX_H]),0,text); + + szbuild(aniBuf,sizeof(aniBuf),"%c",'X'); + FontSys(aniBuf,(int)(aBox[BOX_X]+aBox[BOX_W]-(1*FONT_WIDTH)),(int)(aBox[BOX_Y]+ANIBARHT_2), + FL_SIZE,(int)(aBox[BOX_H]),0,text); + } + return 0; + +} // TBDrawDeerAnimBox() + + + + + +int TBDrawMenu(ObjText *text, Menu *m) +{ + float hiliteBox[4]; + + //--- window bg ------- + glColor3ub(255,255,255); + glBegin(GL_POLYGON); + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_POLYGON); + hiliteBox[0]=(float)text->box[BOX_X]; + hiliteBox[1]=(float)(text->box[BOX_Y]+(m->hiliteLine*MENUBAR_HT)+2); + hiliteBox[2]=(float)(text->box[BOX_X]+text->box[BOX_W]); + hiliteBox[3]=(float)(text->box[BOX_Y]+((m->hiliteLine+1)*MENUBAR_HT)+3); + + glVertex2f(hiliteBox[0],hiliteBox[1]); + glVertex2f(hiliteBox[0],hiliteBox[3]); + glVertex2f(hiliteBox[2],hiliteBox[3]); + glVertex2f(hiliteBox[2],hiliteBox[1]); + +// glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]+(m->hiliteLine*FONTHEIGHT)); +// glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H]+((m->hiliteLine+1)*FONTHEIGHT))); +// glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H]+((m->hiliteLine+1)*FONTHEIGHT))); +// glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]+(m->hiliteLine*FONTHEIGHT)); + glEnd(); + + glColor3ub(0,0,0); + glBegin(GL_LINE_LOOP); + + glVertex2f((float)text->box[BOX_X],(float)text->box[BOX_Y]); + glVertex2f((float)text->box[BOX_X],(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)(text->box[BOX_Y]+text->box[BOX_H])); + glVertex2f((float)(text->box[BOX_X]+text->box[BOX_W]),(float)text->box[BOX_Y]); + + glEnd(); + + + return 0; +} // TBDrawMenu() + +void FontOutlineBox(char *buf, crd *s, int boxHalfWid, int col) +{ + LRTB sBox; + char nameBuf[80]; + + sBox.left = s[0] - boxHalfWid; + sBox.top = s[1] + boxHalfWid; + sBox.right = s[0] + boxHalfWid; + sBox.bottom = s[1] - boxHalfWid; + + + //---- BOX ---------- + glColor3f(clut[col][0],clut[col][1],clut[col][2]); + + glBegin(GL_LINE_LOOP); + glVertex2i(sBox.left,sBox.top); + glVertex2i(sBox.left,sBox.bottom); + glVertex2i(sBox.right,sBox.bottom); + glVertex2i(sBox.right,sBox.top); + glEnd(); + + szbuild(nameBuf,sizeof(nameBuf),"%s",col,buf); + FontSys(nameBuf,sBox.left,sBox.top+FONTHEIGHT, 16*FONTWIDTH, FONTHEIGHT,0,0); + +} + +// +// FontConOutputStart +// set up OpenGL to draw the console output for game start +// +// in: +// out: +// global: +// +// GNP 08 Mar 06 +// +void FontConOutputStart(void) +{ + // this is the nice way out of a copy protection problem + float w,h; + glClearColor(0.3,0.3,0.3,0); + glClear(GL_COLOR_BUFFER_BIT); + + glDisable(GL_COLOR_MATERIAL); + glBindTexture(GL_TEXTURE_2D,0); + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + glShadeModel(GL_FLAT); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); + glDisable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + glDisable(GL_BLEND); + glDisable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + w=VidDisp.screenW; + h=VidDisp.screenH; + glOrtho(0,w,h,0,0,1000); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + +//DONE("FontConOutputStart") +} // FontConOutputStart + +// +// FontConOutputFinish +// finish draw of console output for game start +// +// in: +// out: +// global: +// +// GNP 08 Mar 06 +// +void FontConOutputFinish(void) +{ + glFlush(); + WndSwap(NUL); +//DONE("FontConOutputFinish") +} // FontConOutputFinish + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/fs_gl.c b/dond/coregl/fs_gl.c new file mode 100755 index 0000000..0b6b528 --- /dev/null +++ b/dond/coregl/fs_gl.c @@ -0,0 +1,404 @@ +#if SYS_GL +// fs_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 1998-2005 Play Mechanix Inc. All Rights Reserved +// +// note that is not really a _gl file, but since this code depends on +// it really isn't generic and has to go into some non-generic core area +// +// JFL 26 Aug 04 +// JFL 19 Sep 04; dir +// JFL 08 Oct 04 + +#include + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "str.h" +#include "fs.h" + +#define M_FR_VALID 0x0001 +#define M_FR_DIRFIRST 0x0002 +#define M_FR_DIRNEXT 0x0004 +#define M_FR_DIRSAME 0x0008 +#define M_FR_DIREMPTY 0x0010 +#define M_FR_WRITABLE 0x0020 +#define M_FR_LASTSEC 0x0040 +#define M_FR_DIRTY 0x0080 // dir needs update +#define M_FR_ERR 0x0100 // dir needs update + +typedef struct { + + // this must fit into FsH declared in fs.h + uns16 flags; + FILE *fh; +} FileRec; + +#define M_FF_VALID 0x01 +typedef struct { + + // this must fit into FfH declared in fs.h + uns8 flags; + FILE *fh; +} FastFile; + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 26 Aug 04 +// JFL 08 Oct 04 +int FsInit(void) +{ + int ec=0; + +#if SAFE + if(sizeof(FsH)flags=0; + + if(!(flags&M_FSOPEN_WRITABLE)) + { + // take away flags for things you can't do if not writable + flags&=~(M_FSOPEN_CREATEIFNOTFOUND + |M_FSOPEN_DELETEDATA + |M_FSOPEN_APPEND + |M_FSOPEN_ATOMIC); + } + + // + // FIND OR CREATE FILE IN DIRECTORY + // + + mode="rb"; + if(flags&M_FSOPEN_WRITABLE) + { + if(flags&M_FSOPEN_APPEND) + mode="a+b"; // open for read/write, writing at end + else if(flags&M_FSOPEN_DELETEDATA) + mode="w+b"; // create for read/write, discard + } + + if(!(((FileRec*)fh)->fh=fopen(path,mode))) + err(ERR_FILE_OPEN); + + // + // + // + + if(flags&M_FSOPEN_WRITABLE) + ((FileRec*)fh)->flags|=M_FR_WRITABLE; + + ((FileRec*)fh)->flags|=M_FR_VALID; + + ec=0; +BAIL: + return ec; +} // FsOpen() + +// JFL 15 Feb 05 +int FsFindOpen(FsH *fh,char *pathlist,char *name,uns flags, + char *openpath,int openpathsize) +{ + int ec; + char buf[PM_FILEPATH_MAX]; + char *s2; + + if(!pathlist || !name || !fh) + err(ERR_FILE_NOTVALID); + + for(;pathlist && pathlist[0];) + { + if(!(s2=szskipto(pathlist,";,"))) + { + szncpy(buf,pathlist,sizeof(buf)); + pathlist=NUL; + } + else + { + sz2ncpy(buf,pathlist,s2,sizeof(buf)); + pathlist=1+s2; + } + + if(1 + && ((ec=szlen(buf))>0) + && (ec=0) + { + if(openpath) + szncpy(openpath,buf,openpathsize); + goto BAIL; + } + + } // for + + ec=ERR_FILE_OPEN; +BAIL: + return ec; +} // FsFindOpen() + +// JFL 28 Sep 04 +int FsFlush(FsH *fh) +{ + int ec; + + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + err(ERR_FILE_NOTVALID); + + if(!(((FileRec*)fh)->flags&M_FR_WRITABLE)) + goto done; + + fflush(((FileRec*)fh)->fh); + +done: + ec=0; +BAIL: + return ec; +} // FsFlush() + +// JFL 27 Aug 04 +// JFL 28 Sep 04 +int FsClose(FsH *fh) +{ + int ec; + + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + err(ERR_FILE_NOTVALID); + if((((FileRec*)fh)->flags&M_FR_WRITABLE)) + FsFlush(fh); + ((FileRec*)fh)->flags&=~M_FR_VALID; + fclose(((FileRec*)fh)->fh); + ec=0; +BAIL: + return ec; +} // FsClose() + +// JFL 21 Sep 04 +int FsDelete(char *path) +{ + int ec; + + if(remove(path)) + err(ERR_FILE_DELETE); + + ec=0; +BAIL: + return ec; +} // FsDelete() + +// JFL 27 Jul 05 +int FsRename(char *oldpath,char *newpath) +{ + int ec; + + if(rename(oldpath,newpath)) + err(ERR_FILE_RENAME); + + ec=0; +BAIL: + return ec; +} // FsRename() + +// JFL 28 Aug 04 +int FsRead(FsH *fh,void *buf,uns32 size) +{ + int ec; + uns32 n,s; + + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + err(ERR_FILE_NOTVALID); + s = sizeof(buf); + n=fread(buf,1,size,((FileRec*)fh)->fh); + if(n !=size) + err(ERR_FILE_READ); + + ec=0; +BAIL: + return ec; +} // FsRead() + +// JFL 20 Sep 04 +int FsWrite(FsH *fh,void *buf,uns32 size) +{ + int ec; + + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + err(ERR_FILE_NOTVALID); + if(!(((FileRec*)fh)->flags&M_FR_WRITABLE)) + err(ERR_FILE_NOTWRITABLE); + + if(fwrite(buf,1,size,((FileRec*)fh)->fh)!=size) + err(ERR_FILE_WRITE); + + ec=0; +BAIL: + return ec; +} // FsWrite() + +// JFL 21 Sep 04 +uns FsSize(FsH *fh) +{ + long mark,size; + + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + return 0; + + mark=ftell(((FileRec*)fh)->fh); + + if(fseek(((FileRec*)fh)->fh,0,SEEK_END)) + return 0; + + size=ftell(((FileRec*)fh)->fh); + + if(fseek(((FileRec*)fh)->fh,mark,SEEK_SET)) + return 0; + + return size; +} // FsSize() + +// JFL 21 Sep 04 +int FsDiskSize(FsH *fh,int set,uns *sizep) +{ + int ec; + + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + err(ERR_FILE_NOTVALID); + + if(!set) + { + *sizep=FsSize(fh); + err(0); + } + + ec=0; +BAIL: + return ec; +} // FsDiskSize() + +// JFL 03 Sep 04 +int FsSeek(FsH *fh,uns32 off) +{ + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + return ERR_FILE_NOTVALID; + + if(fseek(((FileRec*)fh)->fh,off,SEEK_SET)) + return ERR_FILE_SEEK; + + return 0; +} // FsSeek() + +// JFL 01 Sep 04 +int FfPrep(FfH *ff,FsH *fh) +{ + if(!(((FileRec*)fh)->flags&M_FR_VALID)) + return ERR_FILE_NOTVALID; + + ((FastFile*)ff)->flags&=~M_FF_VALID; + ((FastFile*)ff)->fh = ((FileRec*)ff)->fh; + ((FastFile*)ff)->flags|=M_FF_VALID; + + return 0; +} // FfPrep() + +// JFL 07 Sep 04 +int FfSeek(FfH *ff,uns32 off) +{ + return FsSeek((void*)ff,off); +} // FfSeek() + +// JFL 01 Sep 04 +int FfRead(FfH *ff,void *buf,uns32 size) +{ + return FsRead((void*)ff,buf,size); +} // FfRead() + +// JFL 02 Sep 04 +// JFL 28 Sep 04 +int FfWrite(FfH *ff,void *abuf,uns32 size) +{ + return FsWrite((void*)ff,abuf,size); +} // FfWrite() + +// JFL 02 Sep 04 +int FsDefrag(FsH *fh,int set) +{ + return 0; +} // FsDefrag() + +// JFL 18 Sep 04 +int FsDir(FsH *fh,uns dirmask,char *buf,uns bufsize) +{ + return ERR_FILE_INTERNAL; +} // FsDir() + +// JFL 17 Sep 04 +int FsCurDir(int num,int set,char *buf,uns bufsize) +{ + return ERR_FILE_INTERNAL; +} // FsCurDir() + +#endif // SYS_GL +//EOF diff --git a/dond/coregl/net_gl.c b/dond/coregl/net_gl.c new file mode 100755 index 0000000..01b122a --- /dev/null +++ b/dond/coregl/net_gl.c @@ -0,0 +1,136 @@ +#if SYS_GL +// net_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 08 Sep 04 +// JFL 27 Sep 04 + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "fs.h" +#include "str.h" +#include "net.h" + +typedef struct { + int dummy; +} netPort; + +/////////////////////////////////////////////////////////////////////////////// +// SYSTEM INIT + +// JFL 08 Sep 04 +int NetInit(void) +{ + int ec; + NetPH *ph=NUL; + if(sizeof(ph->sys)sys[0]>0)) + err(ERR_NET_INTERNAL); + ec=0; +BAIL: + return ec; +} // NetInit() + +// JFL 08 Sep 04 +void NetFinal(void) +{ +} // NetFinal() + +// JFL 22 Sep 04 +int NetReset(uns reset) +{ + int i; + void *mem; + + // reset the pool + MemPoolReset(MEMPOOL_NET,reset); // puts all mem in stack mode + i = MemSAvail(MEMPOOL_NET); // find total size + if(MemSLow(MEMPOOL_NET,i,&mem)<0) // alloc it all from the stack + { + LOCKUP(BP_NETRESET1); + } + else + { + if(MemDSetup(MEMPOOL_NET,mem,i)<0) // put it all into dynamic mode + LOCKUP(BP_NETRESET2); + } + + return 0; +} // NetReset() + +/////////////////////////////////////////////////////////////////////////////// +// FOREGROUND + +// JFL 04 Oct 04 +int NetPortInfo(NetPH *ph,uns info) +{ + switch(info) + { + case NETPORTINFO_OFF_THEIRMAC: + return 0; + case NETPORTINFO_OFF_THEIRIP: + return 0; + } // switch + + LOCKUP(BP_NETPORTINFO); + return 0; +} // NetPortInfo() + +// JFL 01 Oct 04 +int NetPortAddListener(NetPH *ph,uns port,uns flags) +{ + return ERR_NET_INTERNAL; +} // NetPortAddListener() + +// JFL 04 Oct 04 +int NetPortAddSender(NetPH *ph,uns port,uns flags,uns8 *dstmac,uns8 *dstip,uns16 dstport) +{ + return ERR_NET_INTERNAL; +} // NetPortAddSender() + +// JFL 01 Oct 04 +int NetPortRem(NetPH *ph) +{ + return ERR_NET_INTERNAL; +} // NetPortRem() + +// JFL 01 Oct 04 +int NetPortAddRvBuf(NetPH *ph,NetBuf *nb) +{ + return ERR_NET_INTERNAL; +} // NetPortAddRvBuf() + +// JFL 01 Oct 04 +int NetPortAddSdBuf(NetPH *ph,NetBuf *nb,uns flags) +{ + return ERR_NET_INTERNAL; +} // NetPortAddSdBuf() + +// JFL 01 Oct 04 +int NetPortRemBuf(NetPH *ph,NetBuf *nb) +{ + return ERR_NET_INTERNAL; +} // NetPortRemBuf() + +// JFL 01 Oct 04 +// JFL 04 Oct 04 +int NetPortPop(NetPH **php,sto *argbuf) +{ + return ERR_NET_INTERNAL; +} // NetPortPop() + +// JFL 01 Oct 04 +int NetBufSignalFIN(NetBuf *nb) +{ + return ERR_NET_INTERNAL; +} // NetBufSignalFIN() + +// JFL 01 Oct 04 +int NetLoop(void) +{ + return 0; +} // NetLoop() + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/obj_gl.c b/dond/coregl/obj_gl.c new file mode 100755 index 0000000..6c48af2 --- /dev/null +++ b/dond/coregl/obj_gl.c @@ -0,0 +1,3087 @@ +#if SYS_GL +// obj_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 14 Oct 04 +// JFL 02 Feb 05 + +//#include + +#include + +#include "pm.h" +#include "sys.h" +#ifdef SYS_BB +#include +#else +#include +#endif +#include "mem.h" +#include "wnd.h" +#include "font.h" +#include "res.h" +#include "vec.h" +#include "str.h" +#include "obj.h" +#include "vid.h" +#include "inp.h" +#include "game.h" +#include "draw.h" +#include "cam.h" +#include "fb.h" +#include "msg.h" + +extern void drawSubDisplayList(ObjDispRes *odr); + +// +// ObjDeleteDList +// delete the object's display list if it has one +// +// in: +// out: +// global: +// +// GNP 16 Dec 05 +// +void ObjDeleteDList(ObjDispRes *odr) +{ + // kill the display list, if it has one + if (odr->dList) + { + glDeleteLists(odr->dList,1); + drawSubDisplayList(odr); + odr->dList=0; + } +//DONE("ObjDeleteDList") +} // ObjDeleteDList + +// +// ObjKillDisp +// called from ObjKill() when killing a display resource object +// +// in: +// out: +// global: +// +// GNP 31 Oct 05 +// +int ObjKillDisp(ObjDispRes *odr) +{ + ObjDeleteDList(odr); +//DONE("ObjKillDisp") + return(0); +} // ObjKillDisp + +// JFL 04 Nov 04 +// JFL 06 Jun 05 +int ObjResolveTex(ObjDispRes *odr,uns flags) +{ + Res *r,*r2; + ResDataImg1 *img; + ResDataDisp0 *disp0; + ResDataDisp2 *disp2; + ResDataDisp3 *disp3; + uns32 hash; + N2ScanRec nsr; + uns gen; + + // note: RESSUB_DISP4 doesnt need to be resolved b/c no image + + if(!(r=odr->res)) + goto BAIL; + if(!(disp0=r->data)) + goto BAIL; + + gen=0; + switch(r->lnk.sub) + { + case RESSUB_DISP2: + disp2=(void*)disp0; + hash=disp2->texHash; + gen=disp2->texGen; + ObjDeleteDList(odr); // force a re-load of the display list + break; + case RESSUB_DISP3: + disp3=(void*)disp0; + hash=disp3->texHash; + gen=disp3->texGen; + ObjDeleteDList(odr); // for a re-load of the display list + break; + default: + goto BAIL; + } // switch + + if(gen) // already done -- clear if you want it re-loaded + goto imgd; + + // do this somewhere else.. should be resolved by the loader + + nsr.fdata=hash; + nsr.func3=(void*)ResNFSImg; + r2=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_FUNC|M_N2SCAN_SUB|RESSUB_IMG1,ResLoadedFirst()); + if(!r2 || !(img=r2->data)) + goto imgd; + + // shouldn't write to res + // but till now, there has been no link from the image + // to the disp record.. + + if(img->type==RES_TEX_RGBA8) + disp0->mode|=M_RESDISPMODE_HASALPHA; + if(img->flags&M_RESDATAIMG1_MIPMAP) + disp0->mode|=M_RESDISPMODE_MIPMAP; + + switch(r->lnk.sub) + { + case RESSUB_DISP2: + disp2->texGen=img->texGen; + break; + case RESSUB_DISP3: + disp3->texGen=img->texGen; + break; + default: + goto BAIL; + } // switch +imgd: + +BAIL: + return 0; +} // ObjResolveTex() + +// JFL 04 Nov 04 +int ObjResolveDisp(ObjDispRes *odr) +{ + int i; + Obj *o2; + Res *r,*r2; + ResDataImg1 *img; + ResDataDisp0 *disp0; + ResDataDisp2 *disp2; + ResDataDisp3 *disp3; + ObjColDefGnd *coldgnd; + uns32 hash; + N2ScanRec nsr; + uns gen; + + // note: RESSUB_DISP4 doesnt need to be resolved b/c no image + + if(!(r=odr->res)) + goto BAIL; + if(!(disp0=r->data)) + goto BAIL; + + // look for a matching animation + // link up display objects with keyframe animations of same name + if(odr->flags&M_OBJDISPRES_NOAUTOANI) + goto animd; + + nsr.s1=r->name; + nsr.s2=NUL; + r2=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_NAME|M_N2SCAN_SUB|RESSUB_KAN,ResLoadedFirst()); + + //if((r2=ResFindSubNth(NUL,r->name,RESSUB_KAN,0))) + if(r2) + { + if((i=ObjNew(&o2,OBJSUB_ANIRES,sizeof(ObjAniRes), + M_OBJNEW_DONTLINK))<0) + goto animd; + N2LevelCpy((void*)o2,(void*)odr); // these go together + N2LinkBefore(N2KIDLIST(odr),o2); + ObjAniResSwitch((void*)o2,r2); + } // kan +animd: + + // look for a matching collision + if(odr->flags&M_OBJDISPRES_NOAUTOCOL) + goto cold; + + // jjj -- this was written when all collisions + // were ground collisions, this needs to be re-worked + + nsr.s1=r->name; + nsr.s2=NUL; + r2=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_NAME|M_N2SCAN_SUB|RESSUB_COL,ResLoadedFirst()); + if(r2) + { + if((i=ObjNew(&o2,OBJSUB_COLDEF,sizeof(ObjColDef)+sizeof(ObjColDefGnd), + M_OBJNEW_LINKCOL))<0) + goto cold; + N2LevelCpy((void*)o2,(void*)odr); // these go together + ((ObjColDef*)o2)->flags|=M_OBJCOLDEF_DONTRESET; + ((ObjColDef*)o2)->next= + ((ObjColDef*)o2)->size=sizeof(ObjColDefGnd); + coldgnd=(void*)(&((ObjColDef*)o2)[1]); + coldgnd->type=OBJCOLDEFTYPE_GND; + coldgnd->flags=0; + coldgnd->len=sizeof(ObjColDefGnd); + coldgnd->d=r2->data; + } // col +cold: + + switch(r->lnk.sub) + { + case RESSUB_DISP2: + disp2=(void*)disp0; + hash=disp2->texHash; + gen=disp2->texGen; + break; + case RESSUB_DISP3: + disp3=(void*)disp0; + hash=disp3->texHash; + gen=disp3->texGen; + break; + default: + goto BAIL; + } // switch + + if(gen) // already resolved, clear if you want it re-resolved + goto imgd; + + // do this somewhere else.. should be resolved by the loader + nsr.fdata=hash; + nsr.func3=(void*)ResNFSImg; + r2=N2Scan(&nsr,M_N2SCAN_INIT + |M_N2SCAN_FUNC|M_N2SCAN_SUB|RESSUB_IMG1,ResLoadedFirst()); + if(!r2 || !(img=r2->data)) + goto imgd; + + // + // + // + + // shouldn't write to res + // but till now, there has been no link from the image + // to the disp record.. + + if(img->type==RES_TEX_RGBA8) + disp0->mode|=M_RESDISPMODE_HASALPHA; + if(img->flags&M_RESDATAIMG1_MIPMAP) + disp0->mode|=M_RESDISPMODE_MIPMAP; + + switch(r->lnk.sub) + { + case RESSUB_DISP2: + disp2->texGen=img->texGen; + ObjDeleteDList(odr); + break; + case RESSUB_DISP3: + disp3->texGen=img->texGen; + ObjDeleteDList(odr); + break; + default: + goto BAIL; + } // switch +imgd: + +BAIL: + return 0; +} // ObjResolveDisp() + +/////////////////////////////////////////////////////////////////////////////// +// ani + +// -f16 -c -v0 -ws "-sset(str1 testbg) run(joe)" +// -f16 -c -v0 -ws "-sset(str1 testgun) run(joe)" +// -v0 -c -ws "-sdbg(db=3 dd=4) set(str1 atstart) run(perm)" +// -v0 -c -ws "-sdbg(db=3 dd=12) set(str1 windmill) run(joe)" +// -f16 -c -v0 -ws "-sset(str1 testpcol) dbg(dc=1 dd=32) run(joe)" +// -v0 -c -f16 -ws "-sdbg(dc=1) set(str1 testbg) run(joe)" + +int aniScan(ResDataKan *kan,float time, + ResDataKanKey **key0p, + float *time0p,crd *ch9) +{ + ResDataKanKey *key,*keya,*keyx,*key1; + float t,tt,b0,b1; + int8 ch; + uns j; + + keya=(void*)&kan[1]; // first valid key + keyx=keya+kan->numk; // first invalid key + key=keya; + + j=time; + j/=kan->length; // how many anim loops + t=j*kan->length; // how long the loops take + if(t<0) t=0; + if(time0p) *time0p=0; + tt=time-t; // this is how far + + // time is how far into the anim + + t=0; + while(1) + { + // if playing this key from the new animation pushes us past + // where were are now in the old animation, this is the key we want + if((t+key->time)>tt) + break; + if(time0p) *time0p+=key->time; + t+=key->time; + if(++key>=keyx) + {key=keya;break;} + } // while + + *key0p=key; + + if(ch9) + { + key1=1+key; + if(key1>=keyx) + key1=keya; + + b1=time-*time0p; + b1/=(float)key->time; + if(b1<0) b1=0; + else if(b1>1) b1=1; + b0=1-b1; + for(ch=0;ch<3;ch++) + ch9[ch]=MathBlendRot(key->rts[ch],key1->rts[ch],b0,b1); + for(;ch<9;ch++) + ch9[ch]=(b0*key->rts[ch]+b1*key1->rts[ch]); + } + + return 0; +} // aniScan() + +#define OBJ_DEFUALT_BRIDGE_TIME 12 + +// JFL 02 Dec 04 +// JFL 09 Mar 05 +// JFL 12 Mar 05 +int ObjAniChange(ObjAniRes *oar,void *vkan,float wavetime) +{ + ResDataKan *kan=vkan; + ResDataKanKey *key,*keya,*keyx; + float t,tt; + + if(wavetime<0) + wavetime=GameWaveTimef; + + key=keya=(void*)&kan[1]; // first valid key + keyx=keya+kan->numk; // first invalid key + + // + // change to new animation + // + + if(!oar->flags&M_OBJANIRES_CHANGE) + {BP(BP_OBJANICHANGE);goto BAIL;} // only get here if we are changing anims + oar->flags&=~(M_OBJANIRES_CHANGE|M_OBJANIRES_HITEND|M_OBJANIRES_BLENDING); + + // + // from + // + + // we always want to set the 'from' values for all the channels + // if we're bridging, use where we are currently at + // if we're snapping, reset to the first keyframe + + // snapping + if((oar->flags&M_OBJANIRES_SNAPONCE) + ||!(oar->flags&(M_OBJANIRES_SYNC|M_OBJANIRES_BRIDGE|M_OBJANIRES_BLENDONCE))) + { + // keyframe-start + oar->kan=kan; + oar->key0=key; + + // animation starts here + oar->aniTime0=wavetime; + + // changing animations resets the frame counters + // this counter keeps track of how many originally animated frames + // the oar has run through so far since the start of the animation + oar->frameCount=0; + oar->fcAnimAcc=0; + oar->fcLoopAcc=0; + oar->fcGameAcc=0; + + // when snapping or not syncing start with the first keyframe + + // timing from the first key + oar->fcAnimLen=oar->fcGameLen=key->time; // original unmultiplied duration + if(oar->speed) + oar->fcGameLen*=oar->speed; // adjusted duration + if(oar->fcGameLen) oar->fcGameInv=1/oar->fcGameLen; + else oar->fcGameInv=0; // happens w/single frame animations -- OK + + // 'to' -- target next key + if(++key>=keyx) + key=keya; + oar->key1=key; + + } // keyframe-start + else if(!(oar->flags&M_OBJANIRES_BLENDONCE)) + { + oar->flags|=M_OBJANIRES_BLENDING; // enable blending + + // sync or bridge + // both of these setup the animation blending vars -- ab + // blending runs two animations and blends between the two + // the current animation is 'moved' into the blend vars + // and new animation is setup in the primary vars + + // + // copy current animation into blending vars + // + + oar->abKan=oar->kan; + oar->abKey0=oar->key0; + oar->abKey1=oar->key1; + oar->abTime0=oar->aniTime0; + oar->abGameAcc=oar->fcGameAcc; + oar->abGameLen=oar->fcGameLen; + oar->abGameInv=oar->fcGameInv; + + // + // setup blend time + // + + // time to blend + oar->abBlendTime0=wavetime; + if(!oar->aTime) + oar->abBlendInv=RES_FRAME_TIME*OBJ_DEFUALT_BRIDGE_TIME; + else + oar->abBlendInv=oar->aTime; + if(oar->speed) + oar->abBlendInv*=oar->speed; + oar->abBlendInv=1.0/oar->abBlendInv; + + // + // find target keyframe + // + + if(oar->flags&M_OBJANIRES_SYNC) + { + // find the key and time-into-the-key + // use animator time + if(!(tt=oar->fcGameInv)) + tt=1; + t=wavetime-oar->aniTime0; + // t-=oar->fcAnimAcc; // we started + t+=oar->skipAdj/tt; // skip adjustment (in game time) + aniScan(kan,t,&key,&tt,NUL); + // key is key at time t, tt is time accumulated in anim + } // sync + else // bridge + { + t=tt=0; + key=keya; + oar->aniTime0=wavetime; + } // bridge + + oar->kan=kan; + oar->key0=key; + oar->fcAnimAcc=oar->fcGameAcc=tt; + if(oar->speed) + oar->fcGameAcc*=oar->speed; + oar->fcAnimLen=oar->fcGameLen=key->time; // original unmultiplied duration + if(++key>=keyx) + key=keya; + oar->key1=key; + + if(oar->speed) + oar->fcGameLen*=oar->speed; // adjusted duration + if(oar->fcGameLen) oar->fcGameInv=1/oar->fcGameLen; + else oar->fcGameInv=0; // happens w/single frame animations -- OK + + } // synchronized + else + { + // blend once + + // only blend if this joint is set to blend + if(oar->flags&M_OBJANIRES_BLEND2ADD) + { + // Will needs to signal for joints that don't blend here + } // blend add + + // this leaves the primary animation alone + // and replaces the blending animation + + oar->flags|=M_OBJANIRES_BLEND2; // enable blending + + // + // setup blend time + // + + // time to blend + oar->b2BlendTime0=wavetime; + if(!oar->bTime) + oar->b2BlendInv=RES_FRAME_TIME*OBJ_DEFUALT_BRIDGE_TIME; + else + oar->b2BlendInv=oar->bTime; + if(oar->speed) + oar->b2BlendInv*=oar->speed; + oar->b2BlendInv=1.0/oar->b2BlendInv; + + // + // find target keyframe + // + + t=tt=0; + key=keya; + oar->b2Time0=wavetime; + + oar->b2Kan=kan; + oar->b2Key0=key; + oar->b2GameAcc=tt; + if(oar->speed) + oar->b2GameAcc*=oar->speed; + oar->b2GameLen=key->time; // original unmultiplied duration + if(++key>=keyx) + key=keya; + oar->b2Key1=key; + + if(oar->speed) + oar->b2GameLen*=oar->speed; // adjusted duration + if(oar->b2GameLen) oar->b2GameInv=1/oar->b2GameLen; + else oar->b2GameInv=0; // happens w/single frame animations -- OK + + } // blend once + +BAIL: + return 0; +} // ObjAniChange() + +// JFL 08 Nov 04 +// JFL 16 Nov 04 +// JFL 12 Jan 05; kill at end +// JFL 06 Apr 05; blending revisited +// JFL 03 Jul 05; second blend channel +int ObjAniKan(ObjAniRes *oar,ResDataKan *kan,float wavetime) +{ + int ec; + float b0,b1; + float a,b; + crd m1[M3_SIZE],m2[M3_SIZE],m3[M3_SIZE]; + ResDataKanKey *key,*keya,*keyx; + N2 *n; + int8 k; + crd chb[9]; + + // + // PRE-ANIMATION STATES + // + + if(oar->flags&M_OBJANIRES_FROZEN) + { + if(!(oar->flags&M_OBJANIRES_FROZENTIME)) + { + // save frozen time + oar->flags|=M_OBJANIRES_FROZENTIME; + oar->abTime0=wavetime-oar->aniTime0; // save delta time at freeze + } + return 0; + } // frozen + if(oar->flags&M_OBJANIRES_FREEZENEXT) + { + oar->flags&=~M_OBJANIRES_FREEZENEXT; + oar->flags|=M_OBJANIRES_FROZEN; + } // freezenext + + // restore frozen time + if(oar->flags&M_OBJANIRES_FROZENTIME) + { + oar->flags&=~M_OBJANIRES_FROZENTIME; + oar->aniTime0=wavetime-oar->abTime0; // restore delta time + } // retore frozen time + + if(oar->flags&M_OBJANIRES_DONE) + { +done: + if(oar->flags&M_OBJANIRES_KILLPRIME) + { + oar->flags&=~M_OBJANIRES_KILLPRIME; // only do this once + if((n=N2Parent(oar))) + ObjKill(n); + else + ObjKill(oar); + } + else if(oar->flags&M_OBJANIRES_ENDKILL) + ObjKill(oar); + else + oar->flags|=M_OBJANIRES_FROZEN; + + // always exit + err(0); + } // done + + // + // CHANGES TO ANIMATION + // + + // switching animations + if(oar->flags&M_OBJANIRES_CHANGE) + ObjAniChange(oar,kan,wavetime); + + // reset most flags here to avoid path dependencies + oar->flags&=~(M_OBJANIRES_SNAPONCE|M_OBJANIRES_BLENDONCE + |M_OBJANIRES_BRIDGE|M_OBJANIRES_SYNC); + + // catch any done flags set during the change + if(oar->flags&M_OBJANIRES_DONE) + goto done; + + if(oar->flags&M_OBJANIRES_SKIPTO) + { + oar->flags&=~M_OBJANIRES_SKIPTO; + + // calculate skipAdj + b1=oar->skipAdj-oar->fcAnimAcc; + b1/=oar->fcGameInv*oar->fcAnimLen; + b1-=wavetime-oar->aniTime0; + b1+=oar->fcGameAcc; + oar->skipAdj=b1; + } // skip to + + // + // handle primary animation + // + +keyloop: + // find how long since this oar was started + // if it goes beyond the speed-adjusted length, move to the next frame + b1=wavetime-oar->aniTime0; // this is the time since anim start + b1-=oar->fcGameAcc; // we started + b1+=oar->skipAdj; // skip adjustment + if((b1>=oar->fcGameLen)) + { + // past original length, move to next keyframe + + // load up our kan & key info + kan=oar->kan; + keya=(void*)&kan[1]; // first valid key + keyx=keya+kan->numk; // first invalid key + + // move to next key + // we've hit the target key (may have passed it) + + // 'to' key becomes 'from' key + if(!(key=oar->key1)) // target key + berr(-1); + oar->key0=key; // becomes source + + // accumulate the just-finished length & load up new key + oar->fcGameAcc+=oar->fcGameLen; + oar->fcAnimAcc+=oar->fcAnimLen; // keep track in original segment lengths + oar->fcLoopAcc+=oar->fcAnimLen; // keep track in original segment lengths + oar->fcAnimLen=oar->fcGameLen=key->time; // unmultiplied duration + if(oar->speed) + oar->fcGameLen*=oar->speed; // adjusted duration + if(oar->fcGameLen) oar->fcGameInv=1/oar->fcGameLen; + else {oar->fcGameInv=0;} + + // move to next target + if(++key>=keyx) + { + if(oar->nextKan) + { + BP(BP_OBJANIKAN); + // this code should work but doesn't + // there is a problem with the different joints rolling + // over at different times -- I'm not sure if this is a + // problem with the animation keyframes or the code here + // instead of setting nextKan, use bridge for now.. + oar->kan=oar->nextKan; + oar->nextKan=NUL; + + kan=oar->kan; + keya=(void*)&kan[1]; // first valid key + keyx=keya+kan->numk; // first invalid key + + key=keya; + oar->aniTime0=GameWaveTimef; + oar->fcAnimLen=oar->fcGameLen=key->time; // unmultiplied duration + if(oar->speed) + oar->fcGameLen*=oar->speed; // adjusted duration + if(oar->fcGameLen) oar->fcGameInv=1/oar->fcGameLen; + else {oar->fcGameInv=0;} + + goto keyd; + } + oar->flags|=M_OBJANIRES_HITEND; // must be cleared by user + if((oar->flags&M_OBJANIRES_LOOP)) + { + key=keya; // loop + oar->fcLoopAcc=0; + } + else + { + // dont loop + key--; // backup + oar->key1=key; + oar->flags|=M_OBJANIRES_DONE; + goto done; + } // dont loop + } // move to next target +keyd: + oar->key1=key; + if(oar->key0!=oar->key1) + goto keyloop; // loop back up in case we missed more than one keyframe + } // past original length + + // find fraction between 'from' and 'to' + if(b1<=0) + b1=0; + else + { + b1*=oar->fcGameInv; + if(b1>1) b1=1; + } + b0=1-b1; + + // keep track of where we are at in the animation + // this counter is in original (not speed-adjusted) frame units + // this counter is meant to be watched by outside processes to + // key off progress + oar->frameCount=oar->fcAnimAcc+b1*oar->fcAnimLen; + // oar->fcLoopCount=oar->frameCount-oar->fcLoopAcc; + oar->fcLoopCount=oar->fcLoopAcc+b1*oar->fcAnimLen; + + // + // set the channels + // + + keya=oar->key0; + keyx=oar->key1; + for(k=0;k<3;k++) + oar->cur[k]=MathBlendRot(keya->rts[k],keyx->rts[k],b0,b1); + for(;k<9;k++) + oar->cur[k]=(b0*keya->rts[k]+b1*keyx->rts[k]); + + // + // handle blend animation + // + + if(oar->flags&M_OBJANIRES_BLENDING) + { +abkeyloop: + b1=wavetime-oar->abTime0; // this is the time since anim start + b1-=oar->abGameAcc; // we started + if(b1>=oar->abGameLen) + { + // past original length, move to next keyframe + + // load up first & last key pointers + kan=oar->abKan; + keya=(void*)&kan[1]; // first valid key + keyx=keya+kan->numk; // first invalid key + + // move to next key + // we've hit the target key (may have passed it) + + key=oar->abKey1; // 'to' target key + oar->abKey0=key; // becomes 'from' source + + // accumulate the just-finished length & load up new key + oar->abGameAcc+=oar->abGameLen; + oar->abGameLen=key->time; // unmultiplied duration + if(oar->speed) + oar->abGameLen*=oar->speed; // adjusted duration + if(oar->abGameLen) oar->abGameInv=1/oar->abGameLen; + else {oar->abGameInv=0;} + + // move to next target + if(++key>=keyx) + { + if((oar->flags&M_OBJANIRES_LOOP)) + key=keya; // loop + else + key--; // backup + } // move to next target + + oar->abKey1=key; + if(oar->abKey0!=oar->abKey1) + goto abkeyloop; // loop back up in case we missed more than one keyframe + } // past original length + + // find fraction between 'from' and 'to' + if(b1<=0) + b1=0; + else + { + b1*=oar->abGameInv; + if(b1>1) b1=1; + } + b0=1-b1; + + // get second anim's channel values + keya=oar->abKey0; + keyx=oar->abKey1; + for(k=0;k<3;k++) + chb[k]=MathBlendRot(keya->rts[k],keyx->rts[k],b0,b1); + for(;k<9;k++) + chb[k]=(b0*keya->rts[k]+b1*keyx->rts[k]); + + // blend the two channels + b1=wavetime-oar->abBlendTime0; + b1*=oar->abBlendInv; + if(b1<=0) b1=0; + else if(b1>=1) + { + // blend time has passed, signal to stop blending after this + b1=1; + oar->flags&=~M_OBJANIRES_BLENDING; + } + b0=1-b1; + + for(k=0;k<3;k++) + oar->cur[k]=MathBlendRot(chb[k],oar->cur[k],b0,b1); + for(;k<9;k++) + oar->cur[k]=(b0*chb[k]+b1*oar->cur[k]); + + } // blend animations + + // + // handle second blend + // + + if(oar->flags&M_OBJANIRES_BLEND2) + { +b2keyloop: + b1=wavetime-oar->b2Time0; // this is the time since anim start + b1-=oar->b2GameAcc; // we started + if(b1>=oar->b2GameLen) + { + // past original length, move to next keyframe + + // load up first & last key pointers + kan=oar->b2Kan; + keya=(void*)&kan[1]; // first valid key + keyx=keya+kan->numk; // first invalid key + + // move to next key + // we've hit the target key (may have passed it) + + key=oar->b2Key1; // 'to' target key + oar->b2Key0=key; // becomes 'from' source + + // accumulate the just-finished length & load up new key + oar->b2GameAcc+=oar->b2GameLen; + oar->b2GameLen=key->time; // unmultiplied duration + if(oar->speed) + oar->b2GameLen*=oar->speed; // adjusted duration + if(oar->b2GameLen) oar->b2GameInv=1/oar->b2GameLen; + else {oar->b2GameInv=0;} + + // move to next target + if(++key>=keyx) + { + if((oar->flags&M_OBJANIRES_LOOP)) + key=keya; // loop + else + key--; // backup + } // move to next target + + oar->b2Key1=key; + if(oar->b2Key0!=oar->b2Key1) + goto b2keyloop; // loop back up in case we missed more than one keyframe + } // past original length + + // find fraction between 'from' and 'to' + if(b1<=0) + b1=0; + else + { + b1*=oar->b2GameInv; + if(b1>1) b1=1; + } + b0=1-b1; + + // get second anim's channel values + keya=oar->b2Key0; + keyx=oar->b2Key1; + for(k=0;k<3;k++) + chb[k]=MathBlendRot(keya->rts[k],keyx->rts[k],b0,b1); + for(;k<9;k++) + chb[k]=(b0*keya->rts[k]+b1*keyx->rts[k]); + + // blend the two channels + b1=wavetime-oar->b2BlendTime0; + b1*=oar->b2BlendInv; + if(b1<=0) b1=0; + else if(b1>=1) + { + // blend time has passed, signal to stop blending after this + b1=1; + oar->flags&=~(M_OBJANIRES_BLENDING|M_OBJANIRES_BLEND2ADD); + oar->flags&=~(M_OBJANIRES_BLEND2); + } + b0=1-b1; + + if(!(oar->flags&M_OBJANIRES_BLEND2ADD)) + { + for(k=0;k<3;k++) + oar->cur[k]=MathBlendRot(chb[k],oar->cur[k],b0,b1); + for(;k<9;k++) + oar->cur[k]=(b0*chb[k]+b1*oar->cur[k]); + } // always blend + else + { + M3BuildObj(m1,oar->cur); + M3BuildObj(m2,chb); + M3Mpy(m3,m2,m1); + MathM3ToRot(m3,chb); + + // b1 starts at 0 and grows to 1 when done + // a is going to be the blend for the added anim + if(oar->aRamp<0) + { + // snap to and ramp toward + a=1-b1; + a*=-oar->aRamp; // amplitude + } + else + { + // 0.. 0.5 .. 0 + if(b0aRamp) + a*=(2*oar->aRamp); + else + a*=2; + } + + if(a<0) a=0; + else if(a>1) a=1; + b=1-a; + for(k=0;k<3;k++) + oar->cur[k]=MathBlendRot(chb[k],oar->cur[k],a,b); + } // blend nz + + } // second blend + + oar->flags|=M_OBJANIRES_MOVED; // signal new rts + + ec=0; +BAIL: + return ec; +} // ObjAniKan() + +// JFL 12 May 05 +int ObjAniKanProject(ObjAniRes *oar,float wavetime, + crd *rot,crd *trans,crd *scale) +{ + int ec; + ObjAniRes oarsave; + + if(!oar || !oar->kan) + err(-1); + + oarsave=*oar; // save + + if((ec=ObjAniKan(oar,oar->kan,wavetime))<0) + goto BAIL; + + if(rot) + { + rot[0]=oar->cur[OAR_CH_RX]; + rot[1]=oar->cur[OAR_CH_RY]; + rot[2]=oar->cur[OAR_CH_RZ]; + } + + if(trans) + { + trans[0]=oar->cur[OAR_CH_TX]; + trans[1]=oar->cur[OAR_CH_TY]; + trans[2]=oar->cur[OAR_CH_TZ]; + } + + ec=0; +BAIL: + *oar=oarsave; // restore + return ec; +} // ObjAniKanProject() + +#define COL_YSLOP 40 +#define COL_LEN 100 +#define GCOL_RMAX_DEFAULT (0.01/RES_FRAME_TIME) + +// JFL 10 Feb 05 +int aniGColPitch(ObjAniRes *oar) +{ + int ec=0; + ObjColAct colamem,*cola=&colamem; + float v[3],tt,max; + crd s; + + if(!(oar->flags&M_OBJANIRES_GCOL)) + berr(1); + MEMZ(colamem); + + // + // ground collision + // + + oar->cur[OAR_CH_RX]= + oar->cur[OAR_CH_RZ]=0; + + // setup for collision w/root + cola->pos[0]=oar->cur[OAR_CH_TX]; + cola->pos[1]=oar->cur[OAR_CH_TY]+COL_YSLOP; + cola->pos[2]=oar->cur[OAR_CH_TZ]; + cola->dir[0]=0; + cola->dir[1]=-1; + cola->dir[2]=0; + cola->len=COL_LEN; + ObjColScanGnd(cola); + + if(cola->flags&M_OBJCOLACT_HIT) + { + // set root-y + oar->cur[OAR_CH_TY]=cola->cpos[1]; + + if(!(oar->flags&M_OBJANIRES_NOPITCH)) + { + // rotate the modeled 'x' + v[2]=MathCosSin(oar->cur[OAR_CH_RY],&s); + v[0]=s; + + // rotate around x axis b/c that's how the models are made + tt=V3DotXZ(v,cola->cnrm); + tt-=oar->pitch; // delta + + // clamp delta -- zero=default, negative=noclamp + if(!(max=oar->rmax)) + max=GCOL_RMAX_DEFAULT; + if(max>0) + { + if(GameLastLoopDelta) // prevent zero + max*=GameLastLoopDelta; // scale max + else + tt=0; // no time, no adjustment + + if(tt<0) + { + if(tt<-max) + tt=-max; + else + tt*=0.5; // prevent snap + } + else + { + if(tt>max) + tt=max; + else + tt*=0.5; + } + } // rmax + + // add in + tt=oar->pitch+tt; + oar->pitch=tt; + oar->cur[OAR_CH_RX]=tt; + + } // pitch + } // hit + + ec=0; +BAIL: + return ec; +} // aniGColPitch() + +// JFL 10 Feb 05 +// JFL 04 Aug 05; from aniGCol +int velGColPitch(ObjVel *ov) +{ + int ec=0; + ObjColAct colamem,*cola=&colamem; + float v[3],tt,max; + crd s; + + MEMZ(colamem); + + // + // ground collision + // + + ov->rot[0]= + ov->rot[2]=0; + + // setup for collision w/root + cola->pos[0]=ov->trans[0]; + cola->pos[1]=ov->trans[1]+COL_YSLOP; + cola->pos[2]=ov->trans[2]; + cola->dir[0]=0; + cola->dir[1]=-1; + cola->dir[2]=0; + cola->len=COL_LEN; +// cola->d=ov; + ObjColScanGnd(cola); + + if(cola->flags&M_OBJCOLACT_HIT) + { + // set root-y + ov->trans[1]=cola->cpos[1]; + + if(!(ov->flags&M_OBJVEL_NOPITCH)) + { + // rotate the modeled 'x' + v[2]=MathCosSin(ov->rot[1],&s); + v[0]=s; + + // rotate around x axis b/c that's how the models are made + tt=V3DotXZ(v,cola->cnrm); + tt-=ov->pitch; // delta + + // clamp delta -- zero=default, negative=noclamp + if(!(max=ov->rmax)) + max=GCOL_RMAX_DEFAULT; + if(max>0) + { + if(GameLastLoopDelta) // prevent zero + max*=GameLastLoopDelta; // scale max + else + tt=0; // no time, no adjustment + + if(tt<0) + { + if(tt<-max) + tt=-max; + else + tt*=0.5; // prevent snap + } + else + { + if(tt>max) + tt=max; + else + tt*=0.5; + } + } // rmax + + // add in + tt=ov->pitch+tt; + ov->pitch=tt; + ov->rot[0]=tt; + + } // pitch + } // hit + + ec=0; +//BAIL: + return ec; +} // velGColPitch() + +typedef struct { + ObjSeqRes *osr; + uns32 time; +} seqCallbackRec; + +// JFL 10 Jan 05 +int seqCallback(int ec,ResParseH *fhb,Res *res,seqCallbackRec *cr) +{ + ObjSeqRes *osr; + uns u; + char *s1,*s2; + N2 *o; + float f1; + memu *vad; + int i; + N2ScanRec nsr; + + if(!cr || !(osr=cr->osr)) + goto BAIL; + + switch(ec) + { + case ERR_PARSE_EOF: + osr->flags|=M_OBJANIRES_DONE; + break; + case RESPARSE_FRAME: + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + err(ERR_PARSE_SYNTAX) + + // get frame number + ec=ResParseTok(fhb,&s1,&s2,NUL); + if(s1 && s1[0]!='-') + { + szto(s1,s2,'u',10,&u); + + u*=RES_FRAME_TIME; // turn into milliseconds + if(u>cr->time) // skip if not time yet + { + fhb->str=fhb->revert; + ec=ERR_PARSE_STOP; + break; + } + } + + ec=0; + + break; // RESPARSE_FRAME + + case RESPARSE_HOLD: + case RESPARSE_SLEEP: + case RESPARSE_SLOOP: + i=ec; + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + err(ERR_PARSE_SYNTAX) + + if(osr->hold) + { + if(i==RESPARSE_SLOOP) + osr->hold--; + else if((osr->hold>cr->time) || (osr->hold==~0)) + { + // handle sleep callback -- used for tapouts + if(osr->flags&M_OBJANIRES_SLEEPCB) + if(ResSeqCB(RESSEQCB_SLEEPING,osr)<0) + goto holdoff; + + fhb->str=fhb->revert; + ec=ERR_PARSE_STOP; + break; + } + else + { +holdoff: + osr->hold=0; // hold-off + } + } + else + { + // get delay + ec=ResParseRaw(fhb,&s1,&s2,NUL); + osr->flags&=~M_OBJANIRES_SLEEPCB; // remove sleepcb + if(s1[0]=='-') // options + { + + if(s1[1]=='t') // callback (used for tapouts) + { + osr->flags|=M_OBJANIRES_SLEEPCB; + if(*s2=='=') + { + fhb->str=1+s2; + ec=ResParseTok(fhb,&s1,&s2,NUL); + szto(s1,s2,'i',10,&ec); + osr->cb[0]=(memu)ec; + } + } // t + + ec=ResParseTok(fhb,&s1,&s2,NUL); + } + + if(s1[0]=='$') + { + if(!(vad=ResParseVarAdr(fhb,s1,s2))) + berr(ERR_PARSE_SYNTAX); + u=*vad; + } + else + szto(s1,s2,'u',10,&u); + + if(!u) + osr->hold=~0; + else if(i==RESPARSE_SLEEP) + { + u*=RES_FRAME_TIME; // turn into milliseconds + u+=cr->time; + } + else if(i==RESPARSE_SLOOP) + { + // nothing + } + + // hold-on + osr->hold=u; + + fhb->str=fhb->revert; + + // callback here so sleepcb can change time.. + if(osr->flags&M_OBJANIRES_SLEEPCB) + ResSeqCB(RESSEQCB_SLEEPINIT,osr); + + ec=ERR_PARSE_STOP; + break; + } + + // released -- run + + + if((ec=ResParsePAREN(fhb))<0) + goto BAIL; + ec=0; + break; + + case RESPARSE_SWATCH: + + if((ec=ResParseTok(fhb,&s1,&s2,NUL))!=RESPARSE_PARENOPEN) + err(ERR_PARSE_SYNTAX) + + ec=ResParseRaw(fhb,&s1,&s2,NUL); + + // variable + if(s1[0]!='$') + berr(ERR_PARSE_SYNTAX); + if(!(vad=ResParseVarAdr(fhb,s1,s2))) + berr(ERR_PARSE_SYNTAX); + if(!(o=(void*)*vad)) + berr(ERR_PARSE_SYNTAX); + + // time + if((ec=ResParseRaw(fhb,&s1,&s2,NUL))<0) + berr(ERR_PARSE_SYNTAX); + if((ec=ResParseTok(fhb,NUL,NUL,NUL))!=RESPARSE_PARENCLOSE) + berr(ERR_PARSE_SYNTAX) + + // test + if(!o) + break; + if(o->sub!=OBJSUB_ANIRES) + { + o=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_KIDSONLY|M_N2SCAN_NODEEPER + |M_N2SCAN_SUB|OBJSUB_ANIRES,o); + } + if(!o||(o->sub!=OBJSUB_ANIRES)) + {BP(BP_SEQCALLBACK2);break;} + + szto(s1,s2,'f',0,&f1); + if(f1) f1*=RES_FRAME_TIME; // turn into milliseconds + if(!f1||(((ObjAniRes*)o)->frameCountstr=fhb->revert; + ec=ERR_PARSE_STOP; + break; + } + + ec=0; + break; + } // switch + +BAIL: + return ec; +} // seqCallback() + +// JFL 09 Dec 04 +// JFL 10 Jan 05 +int seqFwd(ObjSeqRes *osr,ResDataSeq *rds,uns32 time) +{ + int ec; + ResParseH resparse,*rph=&resparse; + memu bin[32],*var; + ResDataParse rdpmem,*rdp=&rdpmem; + seqCallbackRec crmem,*cr=&crmem; + + MEMZ(bin); + bin[BINBUF_SIZE]=COUNT(bin); + bin[BINBUF_NEXT]=BINBUF_FIRST; + + var=NUL; + if(rds->allocSize) + var=(void*)&osr[1]; + + MEMZ(crmem); + cr->osr=osr; + cr->time=time; + + MEMZ(rdpmem); + rdp->root=osr; + rdp->binBuf=bin; + rdp->varBuf=var; + if(rds->nLab) + { + rdp->lab=(void*) ((memu)&rds[1]+rds->dataSize); + rdp->nLab=rds->nLab; + } + rdp->callbackFunc=(void*)seqCallback; + rdp->callbackData=cr; + rdp->nameptr=osr->name; + + if(osr->everyLoop) + { + rdp->cmd=osr->everyLoop; + if((ec=ResParseBlock(rdp,NUL))<0 && (ec!=ERR_PARSE_EOF)) + { + BP(BP_SEQFWD); // what should be done? clear osr->everyLoop? need a case + osr->everyLoop=NUL; + } + } + + for(;;) + { + rdp->cmd=osr->key0; + if((ec=ResParseBlock(rdp,(void*)&(osr->key0)))<0) + { + if(ec==ERR_PARSE_EOF) + osr->flags|=M_OBJANIRES_DONE; + goto BAIL; + } + if(osr->flags&M_OBJANIRES_DONE) + break; + } // for + + ec=0; +BAIL: + if((ec==ERR_PARSE_STOP) || (ec==ERR_PARSE_EOF)) + ec=3; + return ec; +} // seqFwd() + +// JFL 09 Dec 04 +int aniSeq(ObjSeqRes *osr,ResDataSeq *rds) +{ + int ec; + char *key0; + int32 time; + N2 *n; + + if(osr->flags&M_OBJANIRES_FROZEN) + err(0); + if(osr->flags&M_OBJANIRES_DONE) + { +done: + if(osr->flags&M_OBJANIRES_KILLPRIME) + { + osr->flags|=M_OBJANIRES_KILLPRIME; // only do this once + if((n=N2Parent(osr))) + ObjKill(n); + } + + if(osr->flags&M_OBJANIRES_ENDKILL) + ObjKill(osr); + else + osr->flags|=M_OBJANIRES_FROZEN; + err(0); + } + + // first time -- setup + if(!(key0=osr->key0)) + { + key0=(void*)&rds[1]; + key0+=rds->firstOff; + osr->key0=key0; + osr->time0=GameWaveTime; + osr->hold=0; + } // first time -- setup + + if(rds->flags&M_RESDATASEQ_TEXT) + { + time=GameWaveTime-osr->time0; + if((ec=seqFwd(osr,rds,time))<0) + goto BAIL; + if(osr->flags&M_OBJANIRES_DONE) + goto done; + } // text + + ec=0; +BAIL: + return ec; +} // aniSeq() + +// JFL 18 Jan 05 +int velAdd(ObjVel *ov,StateRec *sr) +{ + float t,a; + + // this routine must match ObjColaVel() + + // get time in milliseconds + if(!(t=GameWaveTime-ov->velTime0)) + goto done; + ov->velTime0=GameWaveTime; + + if(ov->maxTime>0) + { + if((t+ov->accTime)>ov->maxTime) + if((t=ov->maxTime-ov->accTime)<0) + t=0; + } + + if(!t) + goto done; + + ov->t=t; + ov->accTime+=t; + + // trans + + // acc + a=t*ov->tacc[0]*0.5; + a+=t*ov->tvel[0]; + ov->trans[0]+=a; + + a=t*ov->tacc[1]*0.5; + a+=t*ov->tvel[1]; + ov->trans[1]+=a; + + a=t*ov->tacc[2]*0.5; + a+=t*ov->tvel[2]; + ov->trans[2]+=a; + + // vel + ov->tvel[0]+=t*ov->tacc[0]; + ov->tvel[1]+=t*ov->tacc[1]; + ov->tvel[2]+=t*ov->tacc[2]; + + // rots + + // acc + a=t*ov->racc[0]*0.5; + a+=t*ov->rvel[0]; + ov->rot[0]+=a; + + a=t*ov->racc[1]*0.5; + a+=t*ov->rvel[1]; + ov->rot[1]+=a; + + a=t*ov->racc[2]*0.5; + a+=t*ov->rvel[2]; + ov->rot[2]+=a; + + // vel + ov->rvel[0]+=t*ov->racc[0]; + ov->rvel[1]+=t*ov->racc[1]; + ov->rvel[2]+=t*ov->racc[2]; + +done: + if(ov->flags&M_OBJVEL_SETMAT) + { + // restore the matrix + if(sr->matDepth) + { + glPopMatrix(); + glPushMatrix(); + } + + glTranslatef(ov->trans[0],ov->trans[1],ov->trans[2]); + if(ov->rot[2]) + a=RAD2DEG(ov->rot[2]),glRotatef(a,0,0,1); + if(ov->rot[1]) + a=RAD2DEG(ov->rot[1]),glRotatef(a,0,1,0); + if(ov->rot[0]) + a=RAD2DEG(ov->rot[0]),glRotatef(a,1,0,0); + if(ov->flags&M_OBJVEL_SCALE) + glScalef(ov->scale[0],ov->scale[1],ov->scale[2]); + } + + return 0; +} // velAdd() + +// JFL 08 Feb 05 +// JFL 14 Jul 05 +int colAct(ObjColAct *cola) +{ + Obj *o; + + // + // check if cola has expired (kill the obj) + // + + if(cola->maxTime && (cola->maxTimevsflags&M_OBJCOLACTVS_GND) + ObjColScanGnd(cola); + + return 0; +} // colAct() + +// JFL 11 Nov 04 +int camPos(ObjCam *cam,ObjAniRes *oar) +{ + float m1[16]; + + if(oar) + { + cam->rot[0]=oar->cur[OAR_CH_RX]; + cam->rot[1]=oar->cur[OAR_CH_RY]; + cam->rot[2]=oar->cur[OAR_CH_RZ]; + + cam->trans[0]=oar->cur[OAR_CH_TX]; + cam->trans[1]=oar->cur[OAR_CH_TY]; + cam->trans[2]=oar->cur[OAR_CH_TZ]; + } + + if(!(cam->flags&M_OBJCAM_USEVM)) + CamBuildVM(cam->vm,cam); + + M4SetVM(m1,cam->vm); + glMultMatrixf(m1); + + return 0; +} // camPos() + +// 4....5 far +// ...... +// ...... +// 7....6 +// +// 0..1 near +// .... +// 3..2 + +uns camFrustVertOffsets[4*CLIP_NUM] = +{ + 0*3,4*3,7*3,3*3, // CLIP_LEFT + 3*3,7*3,6*3,2*3, // CLIP_TOP + 2*3,6*3,5*3,1*3, // CLIP_RIGHT + 1*3,5*3,4*3,0*3, // CLIP_BOTTOM + 1*3,0*3,3*3,2*3, // CLIP_NEAR + 4*3,5*3,6*3,7*3, // CLIP_FAR +}; + +// JFL 08 Jun 06 +void camFrustInWorld(ObjCam *cam,double fovy,double aspect, + double znear,double zfar) +{ + int i; + double f,h,v,hh,vv; + crd vm[VM_SIZE],*vdst,va[3]; + + // if(znear<1) + znear=1; // if znear is too small, z buffer fails + + f=fovy/2; + v=znear/(cos(f)/sin(f)); + h=v*aspect; + + CamBuildLookM3(vm+VM_11,cam); + V3SetXYZ(vm,cam->trans[0],cam->trans[1],cam->trans[2]); + + vdst=cam->vertFrust; + + va[2]=-znear; + hh=h*znear; + vv=v*znear; + for(i=0;i<2;i++) + { + va[0]=-hh; + va[1]=-vv; + VMVecMul(vdst,va,vm); + vdst+=3; + + va[0]=hh; + va[1]=-vv; + VMVecMul(vdst,va,vm); + vdst+=3; + + va[0]=hh; + va[1]=vv; + VMVecMul(vdst,va,vm); + vdst+=3; + + va[0]=-hh; + va[1]=vv; + VMVecMul(vdst,va,vm); + vdst+=3; + + va[2]=-zfar; + hh=h*zfar; + vv=v*zfar; + + } // for +} // camFrustInWorld() + +// JFL 08 Jun 06 +void camClipPlanes(ObjCam *cam) +{ + int i; + crd *v0,*v1,*v2; + for(i=0;ivertFrust[camFrustVertOffsets[0+i]]; + v1=&cam->vertFrust[camFrustVertOffsets[1+i]]; + v2=&cam->vertFrust[camFrustVertOffsets[2+i]]; + V3NormalCW(&cam->nrmkFrust[i],v0,v1,v2); + cam->nrmkFrust[3+i]=V3Dot(&cam->nrmkFrust[i],v0); // plane constant + } // for +} // camClipPlanes() + +#if DEBUG +uns8 dbgDrawColors[]={255,128,64,0,64,128}; +// JFL 08 Jun 05 +void frustDraw(crd *vertFrust,crd *nrmkFrust) +{ + int i; + crd *v0,*v1,*v2,*v3; + crd *nrmk; + crd vb[3],vc[3]; + uns8 c; + static uns8 ci=0; + static uns16 stipple=0xaaaa; + static uns timer=0; + + glEnable(GL_LINE_STIPPLE); + glLineStipple(1,stipple); + c=dbgDrawColors[ci]; + glColor4ub(c,c,c,255); + + ci++; + if(ci>COUNT(dbgDrawColors)) ci=0; + + + if(timer++>16) + { + timer=0; + stipple<<=1; + if(stipple&4) + stipple|=1; + } + + // near plane + glBegin(GL_LINE_LOOP); + glVertex3f(vertFrust[0*3+0],vertFrust[0*3+1],vertFrust[0*3+2]); + glVertex3f(vertFrust[1*3+0],vertFrust[1*3+1],vertFrust[1*3+2]); + glVertex3f(vertFrust[2*3+0],vertFrust[2*3+1],vertFrust[2*3+2]); + glVertex3f(vertFrust[3*3+0],vertFrust[3*3+1],vertFrust[3*3+2]); + glEnd(); + + // far plane + glBegin(GL_LINE_LOOP); + glVertex3f(vertFrust[4*3+0],vertFrust[4*3+1],vertFrust[4*3+2]); + glVertex3f(vertFrust[5*3+0],vertFrust[5*3+1],vertFrust[5*3+2]); + glVertex3f(vertFrust[6*3+0],vertFrust[6*3+1],vertFrust[6*3+2]); + glVertex3f(vertFrust[7*3+0],vertFrust[7*3+1],vertFrust[7*3+2]); + glEnd(); + + // connecting volume + glBegin(GL_LINES); + glVertex3f(vertFrust[0*3+0],vertFrust[0*3+1],vertFrust[0*3+2]); + glVertex3f(vertFrust[4*3+0],vertFrust[4*3+1],vertFrust[4*3+2]); + + glVertex3f(vertFrust[1*3+0],vertFrust[1*3+1],vertFrust[1*3+2]); + glVertex3f(vertFrust[5*3+0],vertFrust[5*3+1],vertFrust[5*3+2]); + + glVertex3f(vertFrust[2*3+0],vertFrust[2*3+1],vertFrust[2*3+2]); + glVertex3f(vertFrust[6*3+0],vertFrust[6*3+1],vertFrust[6*3+2]); + + glVertex3f(vertFrust[3*3+0],vertFrust[3*3+1],vertFrust[3*3+2]); + glVertex3f(vertFrust[7*3+0],vertFrust[7*3+1],vertFrust[7*3+2]); + glEnd(); + + // DRAW NORMALS + for(i=0,nrmk=nrmkFrust;iframeflags&(M_SRFRAMEFLAGS_SHADOWDIR|M_SRFRAMEFLAGS_SHADOWPOS))) + { + // set from vid disp + if(VidDisp.flags&M_VIDDISP_GSHADOW) // use global shadow info + { + if(VidDisp.flags&M_VIDDISP_GSHADOW_DIR) + sr->frameflags|=M_SRFRAMEFLAGS_SHADOWDIR; + else + sr->frameflags|=M_SRFRAMEFLAGS_SHADOWPOS; + + sr->shadowLight[0]=VidDisp.shadowPos[0]; + sr->shadowLight[1]=VidDisp.shadowPos[1]; + sr->shadowLight[2]=VidDisp.shadowPos[2]; + + } // shadow info from vid disp + else if((olr->flags&M_OBJLIGHTRES_SHADDIR) + ||(rdl->flags&M_RESDATALIGHT_SHADDIR)) + { + sr->shadowLight[0]=rdl->dir[0]; + sr->shadowLight[1]=-rdl->dir[1]; + sr->shadowLight[2]=-rdl->dir[2]; + sr->frameflags|=M_SRFRAMEFLAGS_SHADOWDIR; + } // grab shadow-light position + else if((olr->flags&M_OBJLIGHTRES_SHADPOS) + ||(rdl->flags&M_RESDATALIGHT_SHADPOS)) + { + sr->shadowLight[0]=rdl->pos[0]; + sr->shadowLight[1]=rdl->pos[1]; + sr->shadowLight[2]=rdl->pos[2]; + sr->frameflags|=M_SRFRAMEFLAGS_SHADOWPOS; + } // grab shadow-light position + } // set shadow info + + // dont use for light + if((olr->flags&M_OBJLIGHTRES_NOLIGHT)||(rdl->flags&M_RESDATALIGHT_NOLIGHT)) + goto BAIL; + + // search for empty slot for light + for(glight=0,mlight=1;glightlightMask)) + { + glight+=GL_LIGHT0; + goto foundslot; + } + } // for + glight=0; + BP(BP_ADDLIGHT3); // couldn't find slot for light + goto BAIL; +foundslot: + // for a light to be used, sr->lightMask must get its mlight bit set + + // if any lights are set, signal drawing routine to use lights + sr->frameflags|=M_SRFRAMEFLAGS_HASLIGHTS; + + switch(rdl->type) + { + case RESDATALIGHT_AMBIENT: + // ambient light + + if(0 && !(sr->frameflags&M_SRFRAMEFLAGS_AMBIENT)) + { // dont use global ambient light each cam -- set once at startup + // the first ambient light goes into the global ambient + sr->frameflags|=M_SRFRAMEFLAGS_AMBIENT; + v[0]=rdl->rgb[0]; + v[1]=rdl->rgb[1]; + v[2]=rdl->rgb[2]; + v[3]=1; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT,v); + } + else + { + // colors + v[0]=rdl->rgb[0]; + v[1]=rdl->rgb[1]; + v[2]=rdl->rgb[2]; + v[3]=1; + glLightfv(glight,GL_AMBIENT,v); + v[0]=0,v[1]=0,v[2]=v[3]=0; + glLightfv(glight,GL_SPECULAR,v); + glLightfv(glight,GL_DIFFUSE,v); + glLightf(glight,GL_SPOT_CUTOFF,180.0f); // disable spotlight + sr->lightMask|=mlight; // signal light is active, allocate + } + + break; + case RESDATALIGHT_DIRECTIONAL: + // directional light -- e.g. the sun + + // colors + v[0]=rdl->rgb[0]; + v[1]=rdl->rgb[1]; + v[2]=rdl->rgb[2]; + v[3]=0; + glLightfv(glight,GL_DIFFUSE,v); + v[0]=v[1]=v[2]=v[3]=0; + glLightfv(glight,GL_SPECULAR,v); + glLightfv(glight,GL_AMBIENT,v); + glLightf(glight,GL_SPOT_CUTOFF,180.0f); // disable spotlight + + // direction -- transformed by modelview + // + glPushMatrix(); + glLoadIdentity(); + v[0]=rdl->dir[0],v[1]=rdl->dir[1],v[2]=rdl->dir[2],v[3]=0; // w=0 + glLightfv(glight,GL_POSITION,v); + glPopMatrix(); + + sr->lightMask|=mlight; // signal light is active, allocate + + break; + + case RESDATALIGHT_POSITIONAL: + // positional light -- e.g. a lamp + BP(BP_ADDLIGHT4); // not used yet.. test & remove BP + + // colors + v[0]=rdl->rgb[0],v[1]=rdl->rgb[1],v[2]=rdl->rgb[2],v[3]=1; + glLightfv(glight,GL_DIFFUSE,v); + v[0]=v[1]=v[2]=v[3]=0; + glLightfv(glight,GL_SPECULAR,v); + glLightfv(glight,GL_AMBIENT,v); + glLightf(glight,GL_SPOT_CUTOFF,180.0f); // disable spotlight + + // GL_POSITION when v[3]==1 xyz is position + + // position -- transformed by modelview + v[0]=rdl->pos[0],v[1]=rdl->pos[1],v[2]=rdl->pos[2],v[3]=1; // w=1 + glLightfv(glight,GL_POSITION,v); + + sr->lightMask|=mlight; // signal light is active, allocate + + break; + + case RESDATALIGHT_SPOT: + + // spot light + + // colors + + v[0]=rdl->rgb[0]; + v[1]=rdl->rgb[1]; + v[2]=rdl->rgb[2]; + v[3]=1; + glLightfv(glight,GL_DIFFUSE,v); + v[0]=v[1]=v[2]=v[3]=0; + glLightfv(glight,GL_SPECULAR,v); + glLightfv(glight,GL_AMBIENT,v); + + // attenuation=1/(Kc+Kl*d+Kq*d*d) + glLightf(glight,GL_CONSTANT_ATTENUATION,1); + glLightf(glight,GL_LINEAR_ATTENUATION,0); + glLightf(glight,GL_QUADRATIC_ATTENUATION,0); + glLightf(glight,GL_SPOT_EXPONENT,0); // intensity in center/edges + + // splot light parameters -- 1/2 cone (in degrees) + glLightf(glight,GL_SPOT_CUTOFF,rdl->parameters[RESDATALIGHTP_SPOT_CONE]/2); + + // spot + + // position + v[0]=rdl->pos[0],v[1]=rdl->pos[1],v[2]=rdl->pos[2],v[3]=1; // w=1 + glLightfv(glight,GL_POSITION,v); + + // direction + glPushMatrix(); + glLoadIdentity(); // undo camera + v[0]=-rdl->dir[0],v[1]=-rdl->dir[1],v[2]=-rdl->dir[2];v[3]=1; + glLightfv(glight,GL_SPOT_DIRECTION,v); + glPopMatrix(); + + sr->lightMask|=mlight; // signal light is active, allocate + + break; + + default: + BP(BP_ADDLIGHT5); // unk light tpe + goto BAIL; + } // switch + +BAIL: + return; +} // addLight() + +// JFL 01 Jun 05 +void cpFail(void) +{ + // this is the nice way out of a copy protection problem + float w,h,x,y; + glClearColor(0.3,0.3,0.3,0); + glClear(GL_COLOR_BUFFER_BIT); + + glDisable(GL_COLOR_MATERIAL); + glBindTexture(GL_TEXTURE_2D,0); + glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT,GL_LINE); + glPolygonMode(GL_BACK,GL_LINE); + glShadeModel(GL_FLAT); + glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); + glDisable(GL_ALPHA_TEST); + glAlphaFunc(GL_ALWAYS,1); + glDisable(GL_BLEND); + glDisable(GL_LIGHTING); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + w=VidDisp.screenW; + h=VidDisp.screenH; + glOrtho(0,w,h,0,0,1000); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + x=w/3; + y=h/2; + + FontSys("Contact Playmechanix",x,y,w-x,h-y,0,NUL); + + glFlush(); + WndSwap(NUL); +} // cpFail() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 11 Nov 04 +int ObjOnce(Obj *o) +{ + void *d; + Res *r; + char *name; + Obj *o2; + + switch(o->lnk.sub) + { + case OBJSUB_ANIRES: + + if(!(r=((ObjAniRes*)o)->res)) + break; + name=r->name; + + if(!(d=r->data)) + break; + + if(RESSUB_KAN==r->lnk.sub) + { + ObjAniKan((ObjAniRes*)o,d,GameWaveTimef); + if((((ObjAniRes*)o)->flags&M_OBJANIRES_GCOL) + &&(((ObjAniRes*)o)->flags&M_OBJANIRES_MOVED)) + { + ((ObjAniRes*)o)->flags&=~M_OBJANIRES_MOVED; + aniGColPitch((ObjAniRes*)o); + } + } + break; // OBJSUB_ANIRES + case OBJSUB_SEQRES: + + if(!(r=((ObjSeqRes*)o)->res)) + break; + name=r->name; + + if(!(d=r->data)) + break; + + if(RESSUB_SEQ==r->lnk.sub) + aniSeq((ObjSeqRes*)o,d); + + break; + + case OBJSUB_CAM: + + BP(BP_OBJONCE); // is this hit?? -- take out + + // check if cam has animation + if(o->lnk.flags&M_N2_KIDLIST) + { + for(o2=(void*)N2KIDLIST(o)->next;o2->lnk.type;o2=o2->lnk.next) + { + if(o2->lnk.sub==OBJSUB_ANIRES) + { + camPos((ObjCam*)o,(ObjAniRes*)o2); + break; + } + } // for + } // kidlist + + break; + + } // switch + + return 0; +} // ObjOnce() + +#define M_OBJ_STACK_KIDFIRST 0x0001 +#define M_OBJ_STACK_PUSHPOPMAT 0x0002 + +#if DEBUG +objDbgFrames(int x,int y,int w1,int h1) +{ + int w; + + w=w1/2; + w1-=2; + glColor3ub(255,255,255); + glBegin(GL_LINES); + glVertex2i(x+w,y); + glVertex2i(x+w,y+h1-2); + glVertex2i(x+w1,y); + glVertex2i(x+w1,y+h1-2); + glEnd(); +} // objDbgFrames() + +objDbgChart(float f1,int x,int y,int w1) +{ + int w; + + if(f1<0) f1=0; + if(f1>2) f1=2; + glLineWidth(2); + + w=f1*(w1/2); + glBegin(GL_LINE_STRIP); + glVertex2i(x,y); + glVertex2i(x+w,y); + glColor3ub(128,128,128); + glVertex2i(x+w1,y); + glEnd(); + + glLineWidth(1); +} // objDbgChart() +#endif // DEBUG + +void testTriangle(void) { + glClear(GL_COLOR_BUFFER_BIT); + glBegin(GL_TRIANGLES); + glVertex3f(-0.5,-0.5,2.0); + glVertex3f(0.5,0.0,2.0); + glVertex3f(0.0,0.5,2.0); + glEnd(); +} + +uns32 noTex; +// JFL 07 Oct 04 +int ObjLoop(uns flags) +{ + int ec; + int depth,flgs; + WndRec *wnd=WndCur(); + Obj *o,*o2,*stack[OBJ_LIST_DEPTH],*onext; + N2 *l2; + int stackflgs[OBJ_LIST_DEPTH]; + uns8 forceend=0; + uns8 k; + void *d; + Res *r; + StateRec srmem,*sr=&srmem; + float w,h; + char *name; + uns dispflags; + N2 shadList; + #if DEBUG + uns8 dbgFrust=0; + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_OBJ); + #endif // DEBUG + + MemZero(sr,sizeof(StateRec)); + N2Head(&shadList); + N2Head(&sr->afterShadList); + + if(wnd && wnd->ready) + { + // - for DOND: we need to run the video animation code before the game + // starts issuing opengl commands. this, plus running the code OUTSIDE + // of a game proc helps the video run faster. + + // animateObjectFade takes the place of individual fcBlend calls in the + // token language to fade out and eventually kill any and all objects with + // the blend flag set. this was done for convenience, and should (WILL!) + // be replaced with fcBlend calls for in-game objects that do need it. + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWDISP3); + #endif + + if (!(GameLp.flags & M_GAMELP_PAUSE)) + theorafunc_animateG3(); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWDISP3); + #endif + + if (!(GameLp.flags & M_GAMELP_PAUSE)) + animateObjectFade(); + + // - perform a check of the printer port switches + + if (GameState != GAMESTATE_DIAG) + dond_lptSwitchCheck(0); + + // + // + // + + stack[0]=ObjActiveFirst(); + stackflgs[0]=0; + depth=1; + + while(depth-->0) + { + for(o=stack[depth],flgs=stackflgs[depth];o->lnk.type;o=onext) + { +loop: + onext=o->lnk.next; + + #if SAFE + if(onext==o) + {BP(BP_OBJLOOP3);break;} + if(ObjIsSub(o,0)) + {BP(BP_OBJLOOP4);break;} + if(forceend>2) + BP(BP_OBJLOOP5); + #endif // SAFE + + if(o->lnk.flags&(M_N2_DEAD|M_N2_SKIP)) + continue; + + name=NUL; // used for debugging + + if(!(flgs&M_OBJ_STACK_KIDFIRST)) + { + // drop into kid list if there is one + // process if M_N2_KIDFIRST flag is set + if(1 + && (o->lnk.flags&M_N2_KIDFIRST) // do kids first + && (o->lnk.flags&M_N2_KIDLIST) // has kidlist + && (o2=N2KIDLIST(o)->next) // kid exists + && o2->lnk.type // kid has type + && depthlnk.flags&M_N2OBJ_PUSHPOPMAT) + { + stackflgs[depth]|=M_OBJ_STACK_PUSHPOPMAT; + sr->matDepth++; + glPushMatrix(); + } + stack[depth++]=o; // push cur + o=o2; // switch current to first kid + onext=o->lnk.next; + + // must check this o here + if(o->lnk.flags&(M_N2_DEAD|M_N2_SKIP)) + continue; + } + } // stack KIDFIRST + + flgs&=~M_OBJ_STACK_KIDFIRST; + + switch(o->lnk.sub) + { + case OBJSUB_FRAMESTART: + + // setup initial state + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWINIT); + #endif // DEBUG + + // this is intentionally not under the PRODUCTION compile flag + if((VidDisp.flags&M_VIDDISP_CPFAILURE) + #if 0 + ||(VidDisp.flags&M_VIDDISP_PROFAIL) + #endif // PRODUCTION + ) + { + cpFail(); + goto done; + } // cp failure + + DrawResetFrame(sr); + + dispflags=0; + if(((ObjFrameStart*)o)->flags & M_OBJFRAMESTART_CLEAR) + { + glClearColor( + ((ObjFrameStart*)o)->r/255.0, + ((ObjFrameStart*)o)->g/255.0, + ((ObjFrameStart*)o)->b/255.0,0.0); + +// #if PRODUCTION + #if 0 + if(VidDisp.flags&M_VIDDISP_PROFAIL) + glClearColor( + SysG.profailrgb[0]/255.0, + SysG.profailrgb[1]/255.0, + SysG.profailrgb[2]/255.0,0); + #endif // PRODUCTION + + // setup zdepth + if(!(VidDisp.flags&M_VIDDISP_SHADOWS)) + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + else + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); + } + +#if SYS_BB + // force glut to call us again next frame + glutPostRedisplay(); +#endif + + // set forceend flag unless the dontend object flag is set + if(!(((ObjFrameStart*)o)->flags & M_OBJFRAMESTART_DONTEND)) + forceend=1; + + // reset state record + sr->mode=0; + sr->tex=0; + sr->sort=NUL; + sr->frameflags=0; + sr->lightMask=0; // frees all light slots + sr->camNum=0; + + N2Head(&shadList); + N2Head(&sr->afterShadList); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWINIT); + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_OBJCOL); + #endif // DEBUG + + // update projectile positions once + for(k=OBJL2_FIRST_COLLISION;k<=OBJL2_LAST_COLLISION;k++) + { + for(l2=ObjL2First(k);l2->type;l2=l2->next) + { + o2=(void*)L2N2(l2); + if(o2->lnk.sub!=OBJSUB_COLACT) + continue; + ((ObjColAct*)o2)->flags&=~M_OBJCOLACT_HIT; + ((ObjColAct*)o2)->clen=0; + if(o2->lnk.flags&M_N2_DEAD) + continue; + ObjColaVel(o2,NUL); + } // for + } // for OBJL2_ + + #if DEBUG + SysMicroTimerStop(UTIMER_OBJCOL); + #endif // DEBUG + +// testTriangle(); +// #if PRODUCTION + #if 0 + if(!(VidDisp.flags&M_VIDDISP_PROFAIL)) + // this uses the 'break' below & normally breaks + #endif // PRODUCTION + break; // OBJSUB_FRAMESTART // -- see PRODUCTION note above + case OBJSUB_FORCEFRAMEEND: +frameend: + if(sr->sort) + { + DrawFreeSortBuf(sr->sort); + sr->sort=NUL; + } // sort + + // + // dispatch collisions + // + + // dispatch collisions once + for(k=OBJL2_FIRST_COLLISION;k<=OBJL2_LAST_COLLISION;k++) + { + for(l2=ObjL2First(k);l2->type;l2=l2->next) + { + o2=(void*)L2N2(l2); + if(o2->lnk.sub!=OBJSUB_COLACT) + continue; + if(((ObjColAct*)o2)->flags&M_OBJCOLACT_HIT) + { + ec=0; + if(1 + && (((ObjColAct*)o2)->flags&M_OBJCOLACT_COLFUNC) + && ((ObjColAct*)o2)->colfunc + ) + ec=(*((ObjColAct*)o2)->colfunc)(OBJCOLFUNC_COLA, + o2,NUL,NUL); + + } // collision + } // for + } // for OBJL2_ + + // + // dispatch emissions + // + + for(l2=ObjL2First(OBJL2_EMIT);l2->type;l2=l2->next) + { + o2=(void*)L2N2(l2); + if(o2->lnk.sub!=OBJSUB_EMIT) + continue; + if((((ObjEmit*)o2)->flags&M_OBJEMIT_CALLIFVALID) + &&(((ObjEmit*)o2)->flags&M_OBJEMIT_CAPTUREVALID) + &&(((ObjEmit*)o2)->func)) + { + (*((ftype2*)(((ObjEmit*)o2)->func)))((ObjEmit*)o2); + } + } // for + + #if DEBUG + VidDisp.dbgTime1=SysClockMilliSec(); + SysMicroTimerStop(UTIMER_OBJ); + SysMicroTimerStop(UTIMER_FRAME); + #endif // DEBUG + + #if DEBUG + if((VidDisp.dbgbench & M_VIDDISP_DBGBENCH_TIMERS) + || (VidDisp.dbgbench & M_VIDDISP_DBGBENCH_LOGTIMERS)) + { + // display micro-second timers + int i; + for (i=0;iculled, sr->draw2, sr->draw3); + + // draw frames + objDbgFrames(VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)-1,VidDisp.screenW/4, + VidDisp.screenH/8); + + f1=t0/(float)16; + glColor3ub(0,255,0); + objDbgChart(f1,VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)-1,VidDisp.screenW/4); + + f1=t1/(float)16; + glColor3ub(0,0,255); + objDbgChart(f1,VidDisp.screenW/10, + 2+VidDisp.screenH-(VidDisp.screenH/8)-1,VidDisp.screenW/4); + + FontSys(VidDisp.dbgbb[3],VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)-5, + 3*VidDisp.screenW/4,VidDisp.screenH/8,0,NUL); + + szbuild(VidDisp.dbgbb[3],sizeof(VidDisp.dbgbb[3]),"t2=%d q2=%d do2=%d dl2=%d", + sr->draw2Tris, sr->draw2Quads, sr->draw2Basic, sr->draw2Lists); + + FontSys(VidDisp.dbgbb[3],VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)+12, + 3*VidDisp.screenW/4,VidDisp.screenH/8,0,NUL); + + szbuild(VidDisp.dbgbb[3],sizeof(VidDisp.dbgbb[3]),"tMi=%d tMx=%d qMi=%d qMx=%d", + sr->draw2MinTris, sr->draw2MaxTris,sr->draw2MinQuads, sr->draw2MaxQuads); + + FontSys(VidDisp.dbgbb[3],VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)+24, + 3*VidDisp.screenW/4,VidDisp.screenH/8,0,NUL); + + szbuild(VidDisp.dbgbb[3],sizeof(VidDisp.dbgbb[3]),"t3=%d q3=%d do3=%d dl3=%d dm3=%d", + sr->draw3Tris, sr->draw3Quads, sr->draw3Basic, sr->draw3Lists, sr->draw3Mixed); + + FontSys(VidDisp.dbgbb[3],VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)+36, + 3*VidDisp.screenW/4,VidDisp.screenH/8,0,NUL); + + szbuild(VidDisp.dbgbb[3],sizeof(VidDisp.dbgbb[3]),"t3Mi=%d t3Mx=%d q3Mi=%d q3Mx=%d", + sr->draw3MinTris, sr->draw3MaxTris,sr->draw3MinQuads, sr->draw3MaxQuads); + + FontSys(VidDisp.dbgbb[3],VidDisp.screenW/10, + VidDisp.screenH-(VidDisp.screenH/8)+48, + 3*VidDisp.screenW/4,VidDisp.screenH/8,0,NUL); + + } + + if(VidDisp.dbgbench & M_VIDDISP_DBGBENCH_APIINFO) + { + // display OpenGL version info + FontSysSimpleFlags(VidDisp.apiVendor,VidDisp.screenW/12, + (VidDisp.screenH/8)+0*11,M_FONTSYSFLAG_NOBLEND); + FontSysSimpleFlags(VidDisp.apiVersion,VidDisp.screenW/12, + (VidDisp.screenH/8)+1*11,M_FONTSYSFLAG_NOBLEND); + FontSysSimpleFlags(VidDisp.apiRenderer,VidDisp.screenW/12, + (VidDisp.screenH/8)+2*11,M_FONTSYSFLAG_NOBLEND); + FontSys(VidDisp.apiExtensions,VidDisp.screenW/12, + (VidDisp.screenH/8)+3*11,VidDisp.screenW/2,VidDisp.screenH/2,0,NUL); + } + + SysMicroTimerClearAll(); + #endif // DEBUG + + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWFLIP); + SysMicroTimerStart(UTIMER_FRAME); + #endif // DEBUG + +// glFlush(); + + if(!(VidDisp.flags&M_VIDDISP_DONTFLIP)) + WndSwap(wnd); + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWFLIP); + #endif // DEBUG + + #if DEBUG + VidDisp.dbgTime2=SysClockMilliSec()-VidDisp.dbgTime0; + VidDisp.dbgTime0=SysClockMilliSec(); + #endif // DEBUG + + if(forceend==2) + goto done; + forceend=0; + + break; // OBJSUB_FORCEFRAMEEND + goto BAIL; // to turn warning off + case OBJSUB_LIGHTRES: +#if 1 + if(!(VidDisp.flags&M_VIDDISP_LIGHTS)) + break; + if(!(r=((ObjLightRes*)o)->res)) + break; + if(!(d=r->data)) + break; + addLight(sr,(ObjLightRes*)o,(ResDataLight*)d); +#endif + break; + case OBJSUB_STARTSORTBUF: + +// #if PRODUCTION + #if 0 + // this ends the loop + if(VidDisp.flags&M_VIDDISP_PROFAIL) + err(1); + #endif // PRODUCTION + + DrawAllocSortBuf(sr,(ObjStartSortBuf*)o); + break; // OBJSUB_STARTSORTBUF + case OBJSUB_DRAWSORTBUF: +#if 1 + if(sr->sort) + { + //glDepthMask(0); // disable writes t Z buffer w/blend + DrawSortBuf(sr); + DrawFreeSortBuf(sr->sort); + // glDepthMask(1); // enable writes to Z buffer + sr->sort=NUL; + } // sort + + // + // dispatch particles + // + + for(l2=ObjL2First(OBJL2_PARTICLES);l2->type;l2=l2->next) + { + o2=(void*)L2N2(l2); + if(o2->lnk.sub!=OBJSUB_PARTICLES) + continue; + if(((ObjParticles*)o2)->func) + { + (*((ftype3*)(((ObjParticles*)o2)->func)))(o2,sr); + } + } // for +#endif + break; // OBJSUB_DRAWSORTBUF + case OBJSUB_DRAWSHADOWS: +#if 1 + DrawShadows(sr,shadList.next); + N2Head(&shadList); + + DrawAfterShadows(sr,sr->afterShadList.next); + N2Head(&sr->afterShadList); +#endif + break; // OBJSUB_DRAWSHADOWS + case OBJSUB_CAM: + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWCAM); + #endif // DEBUG + + sr->lightMask=0; // signal all light slots are free + sr->frameflags&= + ~(M_SRFRAMEFLAGS_AMBIENT|M_SRFRAMEFLAGS_HASLIGHTS); + + // disable all lights -- must be turned on + for(ec=0;ecflags&M_OBJCAM_NOZ)) + { + // zdepth buffer + glEnable(GL_DEPTH_TEST); // enable zdepth buffer + glDepthFunc(GL_LEQUAL); // passes if zdepth is ___ + glDepthMask(GL_TRUE); + } + else + { + glDisable(GL_DEPTH_TEST); // disable zdepth buffer + glDepthMask(GL_FALSE); + } + + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + if(((ObjCam*)o)->flags&M_OBJCAM_CLEARZ) + glClear(GL_DEPTH_BUFFER_BIT); + + // first cam -- fog + if(!sr->camNum) + { + if(VidDisp.flags&M_VIDDISP_FOG_C) + { + // fog change + VidDisp.flags&=~M_VIDDISP_FOG_C; + if(VidDisp.flags&M_VIDDISP_FOG) + { + glEnable(GL_FOG); + glFogi(GL_FOG_MODE,VidDisp.fogMode); + glFogfv(GL_FOG_COLOR,VidDisp.fogRGBA); + glFogf(GL_FOG_DENSITY,VidDisp.fogDensity); + glHint(GL_FOG_HINT,GL_DONT_CARE); + glFogf(GL_FOG_START,VidDisp.fogNear); + glFogf(GL_FOG_END,VidDisp.fogFar); + } + else + glDisable(GL_FOG); + } // fog change + else if(VidDisp.flags&M_VIDDISP_FOG) + { + // no change, but it is enabled + glEnable(GL_FOG); + } + } // first cam -- fog + else + glDisable(GL_FOG); + + // + // PROJECTION + // + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + if(!(((ObjCam*)o)->flags&M_OBJCAM_ORTHO)) + { + // not ortho -- normal 3D camera + camPersp(((ObjCam*)o)->fov,(float)wnd->w/(float)wnd->h, + ((ObjCam*)o)->clipNear,((ObjCam*)o)->clipFar); + sr->frameflags &= ~M_SRFRAMEFLAGS_ORTHOPROJ; + } + else if(!(((ObjCam*)o)->flags&M_OBJCAM_SIMPLE)) + { + if(!(w=((ObjCam*)o)->orthoWidth)) + w=wnd->w-1; + if(!(h=((ObjCam*)o)->orthoHeight)) + h=wnd->h-1; + glOrtho(-w,w,-h,h,((ObjCam*)o)->clipNear,((ObjCam*)o)->clipFar); + sr->frameflags |= M_SRFRAMEFLAGS_ORTHOPROJ; + } + else + { + glOrtho(0,wnd->w-1,wnd->h-1,0,0,1); + sr->frameflags |= M_SRFRAMEFLAGS_ORTHOPROJ; + } +#if 1 + + // + // MODELVIEW + // + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + // check if cam has animation + if((o->lnk.flags&M_N2_KIDLIST) + &&!(((ObjCam*)o)->flags&M_OBJCAM_OFFSPLINE)) + { + for(o2=(void*)N2KIDLIST(o)->next;o2->lnk.type;o2=o2->lnk.next) + { + if((o2->lnk.sub==OBJSUB_ANIRES) && (((ObjAniRes*)o2)->res)) + { + camPos((ObjCam*)o,(ObjAniRes*)o2); + goto camanid; + } + } // for + } // kidlist + + // no animation + camPos((ObjCam*)o,NUL); +camanid: + + // + // FRUSTRUM + // + + // create frustrum for cam + if(!(((ObjCam*)o)->flags&M_OBJCAM_DONTFRUST)) + { + ((ObjCam*)o)->flags|=M_OBJCAM_FRUSTVALID; + camFrustInWorld((ObjCam*)o,((ObjCam*)o)->fov, + (float)wnd->w/(float)wnd->h, + ((ObjCam*)o)->clipNear,((ObjCam*)o)->clipFar); + camClipPlanes((ObjCam*)o); + } // ! ghostcam + + // set object culling planes + if(((ObjCam*)o)->flags&M_OBJCAM_FRUSTVALID) + { + sr->frameflags|=M_SRFRAMEFLAGS_CULLPLANES; + sr->cullPlaneEqs=((ObjCam*)o)->nrmkFrust; + { + crd *v; + for(ec=0;ecvertFrust; + v+=camFrustVertOffsets[0+4*ec]; + sr->cullPlaneXYZ[0+3*ec]=v[0]; + sr->cullPlaneXYZ[1+3*ec]=v[1]; + sr->cullPlaneXYZ[2+3*ec]=v[2]; + } // for + } + + #if DEBUG + // only draw first frustrum + if(!dbgFrust&&(VidDisp.dbgdisp&M_VIDDISP_DBGDISP_FRUST)) + dbgFrust=1,frustDraw(((ObjCam*)o)->vertFrust, + sr->cullPlaneEqs); + #endif // DEBUG + + } // set cull planes pointer + else + sr->frameflags&=~M_SRFRAMEFLAGS_CULLPLANES; + + // + // + // + + if((((ObjCam*)o)->flags&M_OBJCAM_ADDED)) + dispflags|=M_DRAWDISP_ONEPASS; + + if(VidDisp.flags&M_VIDDISP_GRID) + { + xVidDraw(VIDDRAW_GRID,VidDisp.gridSize); + xVidDraw(VIDDRAW_AXIS,1); + } + + if(!(sr->frameflags&M_SRFRAMEFLAGS_GOTMATRICES)) + { + // only grab the viewing matrices for the + // primary 3D camera -- currently this is the first + sr->frameflags|=M_SRFRAMEFLAGS_GOTMATRICES; + VidGrabViewingMatrices(); + } + + sr->camNum++; + sr->ocam = (ObjCam*)o; //keep copy for use + + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWCAM); + #endif // DEBUG +#endif + break; // OBJSUB_CAM3D + case OBJSUB_TEXT: + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWTEXT); + #endif // DEBUG + FontObjText(o); + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWTEXT); + #endif // DEBUG + break; // OBJSUB_TEXT + case OBJSUB_FUNC: + #if DEBUG + SysMicroTimerStart(UTIMER_OBJFUNC); + #endif // DEBUG + if(!(d=((ObjFunc*)o)->func)) + break; + switch(((ObjFunc*)o)->ftype) + { + case FTYPE_1: + (*((ftype1*)d))(); + break; + case FTYPE_2: + (*((ftype2*)d))(o); + break; + case FTYPE_3: + (*((ftype3*)d))(o,sr); + break; + } // switch + #if DEBUG + SysMicroTimerStop(UTIMER_OBJFUNC); + #endif // DEBUG + break; // OBJSUB_FUNC + case OBJSUB_DISPRES: +#if 1 + #if PRODUCTION + if(!(VidDisp.flags&M_VIDDISP_PROCHECK)) + break; // dont draw until protection is checked + #endif // PRODUCTION + + if(!(r=((ObjDispRes*)o)->res)) + break; + name=r->name; + + if(!(d=r->data)) + break; + + #if DEBUG + SysMicroTimerStart(UTIMER_OBJRESOLVE); + #endif // DEBUG + // resolve once + // this adds animations (should be done earlier) + if(!(o->lnk.flags&M_N2OBJ_RESOLVED)) + { + o->lnk.flags|=M_N2OBJ_RESOLVED; + ObjResolveDisp((void*)o); + } + #if DEBUG + SysMicroTimerStop(UTIMER_OBJRESOLVE); + #endif // DEBUG + + if(RESSUB_DISP2==r->lnk.sub) + DrawDisp2(sr,o,d,M_DRAWDISP_DEFAULT|dispflags); + else if(RESSUB_DISP3==r->lnk.sub) + DrawDisp3(sr,o,d,M_DRAWDISP_DEFAULT|dispflags); + else if(RESSUB_DISP1==r->lnk.sub) + DrawDisp1(sr,d); + else if(RESSUB_DISP4==r->lnk.sub) + { + // disp4 objects are shadow objects + // link them into the shadow list to draw later + if(((ObjDispRes*)o)->flags&M_OBJDISPRES_HASTMPLINK) + { + d=1+((ObjDispRes*)o); // ObjTmpLink + N2LinkBefore(&shadList,d); + } + else + BP(BP_OBJLOOP6); // all should have this link + } + +#endif + break; // OBJSUB_DISPRES + + case OBJSUB_COLRES: + + // loose colres object + // this may or may not align with displayed geo + // may be col box for a tree + // may be col box for a special target + + if(depth) + break; // this is a child, collisions are handled in draw routine of parent + + if(!(r=((ObjColRes*)o)->res)) + break; + name=r->name; + + if(!(d=r->data)) + break; + + if(((ResDataCol*)d)->type!=RESDATACOLTYPE_PROP) + break; + + // does (and if debug, may draw) collision + DrawCol(sr,(void*)o,d); + + break; + case OBJSUB_STR: + #if DEBUG + SysMicroTimerStart(UTIMER_DRAWTEXT); + #endif // DEBUG + DrawStr(sr,(void*)o,0); + #if DEBUG + SysMicroTimerStop(UTIMER_DRAWTEXT); + #endif // DEBUG + break; // OBJSUB_TEXT + + case OBJSUB_ANIRES: + #if DEBUG + SysMicroTimerStart(UTIMER_OBJANI); + #endif // DEBUG + if(!(r=((ObjAniRes*)o)->res)) + break; + name=r->name; + + if(!(d=r->data)) + break; + if(RESSUB_KAN==r->lnk.sub) + { + ObjAniKan((ObjAniRes*)o,d,GameWaveTimef); + if((((ObjAniRes*)o)->flags&M_OBJANIRES_GCOL) + && (((ObjAniRes*)o)->flags&M_OBJANIRES_MOVED)) + { + aniGColPitch((ObjAniRes*)o); + } + } + #if DEBUG + SysMicroTimerStop(UTIMER_OBJANI); + #endif // DEBUG + break; // OBJSUB_ANIRES + + case OBJSUB_SEQRES: + #if DEBUG + SysMicroTimerStart(UTIMER_OBJSEQ); + #endif // DEBUG + if(!(r=((ObjSeqRes*)o)->res)) + break; + name=r->name; + if(!(d=r->data)) + break; + if(RESSUB_SEQ==r->lnk.sub) + { + SysG.curSeq=name; + aniSeq((ObjSeqRes*)o,d); + SysG.curSeq=NUL; + } + #if DEBUG + SysMicroTimerStop(UTIMER_OBJSEQ); + #endif // DEBUG + break; // OBJSUB_SEQRES + + case OBJSUB_VEL: + #if DEBUG + SysMicroTimerStart(UTIMER_OBJVEL); + #endif // DEBUG + velAdd((ObjVel*)o,sr); + if(((ObjVel*)o)->flags&M_OBJVEL_GCOL) + velGColPitch((ObjVel*)o); + #if DEBUG + SysMicroTimerStop(UTIMER_OBJVEL); + #endif // DEBUG + break; // OBJSUB_VEL + + case OBJSUB_EMIT: + // processed in L2 lists + break; + + case OBJSUB_COLACT: + #if DEBUG + SysMicroTimerStart(UTIMER_OBJCOL); + #endif // DEBUG + + colAct((ObjColAct*)o); + + #if DEBUG + SysMicroTimerStop(UTIMER_OBJCOL); + #endif // DEBUG + + break; // colact + case OBJSUB_GROUP: + name=((ObjGroup*)o)->name; + break; // colgroup + } // switch + + // pop mat after processed + if(flgs&M_OBJ_STACK_PUSHPOPMAT) + sr->matDepth--,glPopMatrix(),flgs&=~M_OBJ_STACK_PUSHPOPMAT; + + // drop into kid list if there is one + // process if M_N2_KIDFIRST flag is clr + if(1 + && !(o->lnk.flags&M_N2_KIDFIRST) // dont do kid first + && (o->lnk.flags&M_N2_KIDLIST) // has kidlist + && depthnext) // valid + && o2->lnk.type // has type + ) + { + stackflgs[depth]=0; + if(o->lnk.flags&M_N2OBJ_PUSHPOPMAT) + { + stackflgs[depth]|=M_OBJ_STACK_PUSHPOPMAT; + glPushMatrix(); + sr->matDepth++; + } + stack[depth++]=onext; // push next in cur list + o=o2; + goto loop; + } + + } // for + } // while + if(forceend) + { + forceend=2; + goto frameend; + } + } // wnd && wnd->hdc +done: + + #if SAFE + if(sr->matDepth) + BP(BP_OBJLOOP7); + #endif // SAFE + + #if DEBUG + // + // check for errors + // + depth=0; + while(((ec=glGetError())!=GL_NO_ERROR)&&(depth++<100)) + { + name=(void*)gluErrorString(ec); + SysLog("glError: %s\n",name); + BP(BP_OBJLOOP8); // look at "name", tell Joe there is an OpenGL error in ObjLoop() + } // while + #endif // DEBUG + + ec=0; +BAIL: + return ec; +} // ObjLoop() + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/res_gl.c b/dond/coregl/res_gl.c new file mode 100755 index 0000000..49717d5 --- /dev/null +++ b/dond/coregl/res_gl.c @@ -0,0 +1,1635 @@ +#if SYS_GL +// res_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2004-2005 Play Mechanix Inc. All Rights Reserved +// +// JFL 14 Oct 04 + +//#include + +#include "pm.h" +#include "sys.h" +#ifdef SYS_BB +#include +#include +#else +#include +#include +#endif +#include "mem.h" +#include "res.h" +#include "obj.h" +#include "str.h" +#include "inp.h" +#include "vid.h" +#include "vec.h" +#include "draw.h" + +#include "wnd.h" + +#ifndef SYS_BB +// VBO Extension Function Pointers +extern PFNGLGENBUFFERSARBPROC glGenBuffersARB; // VBO Name Generation Procedure +extern PFNGLBINDBUFFERARBPROC glBindBufferARB; // VBO Bind Procedure +extern PFNGLBUFFERDATAARBPROC glBufferDataARB; // VBO Data Loading Procedure +extern PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB; // VBO Deletion Procedure +#endif //!SYS_BB + +int resTotalVidAlloced = 0; + +//forward +void xVidDrawInitSphere(void); + +// JFL 22 Oct 04 +int xResInit(void) +{ + xVidDrawInitSphere(); + return 0; +} // xResInit() + +// JFL 22 Oct 04 +void xResFinal(void) +{ +} // xResFinal() + +// forward +void draw_axis(void); +void draw_nub(void *o, StateRec *sr); +void draw_quads(void); + +//////// +// BOX +//////// + +GLfloat box_verts[] = +{ + 0,2,0, + 1,0,1, + -1,0,1 +}; + +GLfloat box_texcoords[] = +{ + 0.5,0, + 1,1, + 0,1, +}; + +GLfloat box_colors[] = +{ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, +}; + +ResDataDisp1 box_disp1 = +{ +/* uns16 mode */ RESDISPMODE_WIREFRAME, +/* uns16 nTris */ sizeof(box_verts)/sizeof(box_verts[0])/3, +/* float xyzrCull[4] */ {0,0,0,1}, +/* void *tVerts */ box_verts, +/* void *tTexCoords */ box_texcoords, +/* void *tVertColors */ NUL +}; + +#define SS 0.5 +float shad_verts[] = +{ + -SS,0,-SS, + SS,0,-SS, + SS,0, SS, + -SS,0, SS +}; + +#define VO(x) x*3*sizeof(float) +ResD4Face shad_faces[] = +{ + {VO(0),VO(1),VO(2),VO(3)}, // uns32 vertoff[4] + {0,1,0,0}, // float nrmk[4] + {0,0,0,0}, // uns16 neighbor[4] +}; + +ResD4Joint shad_joints[] = +{ +1, // uns16 nFaces; +0, // uns16 jointNum; +0, // uns32 faceoff; // first ResD4Face +}; + +ResDataDisp4 shadow_disp4 = +{ +0, // uns16 mode; +0, // uns16 atSize; +0, // uns16 flags; +COUNT(shad_joints), // uns16 nJoints; +COUNT(shad_faces), // uns16 maxFaces; +COUNT(shad_verts), // uns16 nVerts; +{0,0,0,1}, // float xyzrCull[4]; +shad_verts, // void *verts; +shad_faces, // void *faces; +shad_joints, // void *joints; +NUL, // void *weights; +NUL, // char *atBuf; +}; + + +////////// +// IMAGE +////////// + +// rrrgggbb +#define AA 0xe0 +#define C2 0xff +uns8 checker_dots[32*32] = { +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA, +C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA,C2,C2,C2,C2,C2,C2,C2,C2,AA,AA,AA,AA,AA,AA,AA,AA +}; + +ResDataImg1 checker_img1 = +{ + RES_TEX_RGB332,0 /* flags */,32 /* w */,32 /* h */, + 0 /* texHash */ ,0 /* texGen */ ,checker_dots +}; + +ResDataImg1 check2x2_img1 = +{ + RES_TEX_RGB332,0 /* flags */,2 /* w */,2 /* h */, + 0 /* texHash */ ,0 /* texGen */ ,checker_dots +}; + +struct { + ResDataKan kan; + ResDataKanKey keys[2]; +} zero_kan = { +{M_RESDATAKAN_SPLINE,1}, +{ + {0, // time0 + M_RESDATAKANKEY_TX|M_RESDATAKANKEY_TY|M_RESDATAKANKEY_TZ, + 0, // xx1 + {0,0,0, // rot + 0,0,0, // trans + 1,1,1}, // scale + }, // time0 + {1, // time1 + M_RESDATAKANKEY_TX|M_RESDATAKANKEY_TY|M_RESDATAKANKEY_TZ, + 0, // xx1 + {0,0,0, // rot + 0,0,0, // trans + 1,1,1}, // scale + } // time1 +} +}; + +ResDataCam sys2d_cam = { + M_RESDATACAM_ORTHO, //uns16 mode; + 0, //uns16 atSize; + {0,0,0}, // rot[3] + {RES_CAM2D_W/2,RES_CAM2D_H/2,RES_CAM2D_Z}, //float trans[3]; + {1,1,1}, //float scale[3] + 1.0, //0.566833, //float fov; + RES_CAM2D_W, //float orthoWidth; + 1, //float clipNear; + 1000, //float clipFar; + NUL, //char *atBuf; +}; + +int dummyImgLoad(ResDataImg1 *img) +{ + img->type = RES_TEX_RGB332; + img->w = 2; + img->h = 2; + img->tex = checker_dots; + + return imgLoad(img); +} + +// JFL 22 Oct 04 +int imgLoad(ResDataImg1 *img) +{ + int ec; + uns glInternalFormat,glFormat,glType; + uns size,x,y; + GLuint u1; + GLboolean b1; + GLclampf c1; + uns8 *tex,*alloc=NUL,*p,r,g,b,*s; + + // - force the loading of a placeholder image + // + // note: this needs to occur ONLY for images that are + // placeholders for video. maybe a flag similar to + // M_RESDATAIMG1_MIPMAP can be set by the dc compiler. + /* + if ((img->w == 512) && (img->h == 512)) + { + img->type = RES_TEX_RGB332; + img->w = 2; + img->h = 2; + img->tex = checker_dots; + } + */ + + size=0; + tex=img->tex; + switch(img->type) + { + case RES_TEX_RGB8: + glInternalFormat=GL_RGB; + glFormat=GL_RGB; + glType=GL_UNSIGNED_BYTE; + break; + case RES_TEX_RGB332: + glInternalFormat=GL_R3_G3_B2; + glFormat=GL_RGB; + glType=GL_UNSIGNED_BYTE; + size=img->w*img->h*3; + break; + case RES_TEX_RGB555: + glInternalFormat=GL_RGB5; + glFormat=GL_RGB; + glType=GL_UNSIGNED_BYTE; + size=img->w*img->h*3; + break; + case RES_TEX_RGBA8: + glInternalFormat=GL_RGBA; + glFormat=GL_RGBA; + glType=GL_UNSIGNED_BYTE; + break; + default: + LOCKUP(BP_IMGLOAD1); + err(-1); + } // switch + + if(!size) + goto convertd; + + alloc=MemSLowGet(MEMPOOL_HEAP); + if((ec=MemSLow(MEMPOOL_HEAP,size,&tex))<0) + { + char ebuf[256]; + szbuild(ebuf,sizeof(ebuf),"Couldn't alloc img conversion mem"); + errlog(ebuf); + goto BAIL; + } + + switch(img->type) + { + case RES_TEX_RGB332: + for(y=0;yh;y++) + { + p=tex; + p+=y*3*img->w; + s=img->tex; + s+=y*1*img->w; + for(x=0;xw;x++) + { + // rrrgggbb + r=g=b=*s; + r&=0xe0; + g&=0x1c; + g<<=3; + b&=0x03; + b<<=6; + if(r) r|=0x1f; + if(g) g|=0x1f; + if(b) b|=0x3f; + + p[0]=r; + p[1]=g; + p[2]=b; + p+=3; + s+=1; + } // for + } // for + break; + case RES_TEX_RGB555: + for(y=0;yh;y++) + { + p=tex; + p+=y*3*img->w; + s=img->tex; + s+=y*2*img->w; + for(x=0;xw;x++) + { + r=*((uns16*)s)>>7; + r&=0xf8; + g=*((uns16*)s)>>2; + g&=0xf8; + b=*((uns16*)s)<<3; + b&=0xf8; + if(r) r|=0x7; + if(g) g|=0x7; + if(b) b|=0x7; + + p[0]=r; + p[1]=g; + p[2]=b; + p+=3; + s+=2; + } // for + } // for + break; + default: + LOCKUP(BP_IMGLOAD2); // can't convert + } // switch + +convertd: + + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + glGenTextures(1,&u1); + img->texGen=u1; + glBindTexture(GL_TEXTURE_2D,img->texGen); // create tex obj + + // printf("created texture: %i\n", img->texGen); + + // default settings for texture obj + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + if(1) // test proxy + { + glTexImage2D(GL_PROXY_TEXTURE_2D,0, /* level */ + glInternalFormat, + img->w,img->h,0 /* border */, + glFormat,glType,NUL); + + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&x); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&y); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D,0,GL_TEXTURE_INTERNAL_FORMAT,&ec); + if(!x || !y || !ec) + BP(BP_IMGLOAD3); // not enough resources available for texture + } // test proxy + + glTexImage2D(GL_TEXTURE_2D,0, /* level */ + glInternalFormat, + img->w,img->h,0 /* border */, + glFormat,glType,tex); + + VidDisp.texAllocs++; + VidDisp.texMem+=img->w*img->h; + + u1=img->texGen; + c1=1; + // glPrioritizeTextures(1,&u1,&c1); + glAreTexturesResident(1,&u1,&b1); + + // move mipmap creation into DC + + //img->flags|=M_RESDATAIMG1_MIPMAP; // <- manny!!! arrrrgh!! + if(img->flags&M_RESDATAIMG1_MIPMAP) + { + ec=gluBuild2DMipmaps(GL_TEXTURE_2D,glInternalFormat, + img->w,img->h,glFormat,glType,tex); + if(ec) + {errlog("imgLoad() build2d mipmap");BP(BP_IMGLOAD4);} + } // mipmap + + ec=0; +BAIL: + glBindTexture(GL_TEXTURE_2D,0); // create tex obj + if(alloc) + MemSLowSet(MEMPOOL_HEAP,alloc); + + #if DEBUG + { + int i; + + // + // check for errors + // + x=0; + while(((i=glGetError())!=GL_NO_ERROR)&&(x++<100)) + { + s=(void*)gluErrorString(i); + BP(BP_IMGLOAD5); // tell Joe there is an OpenGL error in imgLoad + } // while + + } + #endif // DEBUG + + return ec; +} // imgLoad() + +// JFL 27 Jun 05 +int resCompiledInit(void *rc) +{ + #if DEBUG + Res *r; + void *d; + + // set the + if(!(r=ResFindSubNth(NUL,"2x2-img",RESSUB_IMG1,NUL))) + return -1; + if(!(d=r->data)) + return -2; + VidDisp.dbg2x2=((ResDataImg1*)d)->texGen; + #endif // DEBUG + + return 0; +} // resCompiledInit() + +/////////////////////////////////////////////////////////////////////////////// +// COMPILED + +extern ResDataFType ResFTypeSysList[]; + +Res resCompiled[] = +{ + // compiled resource table + // must have N2TYPE_ and M_RES_COMPILED set + + {{NUL,NUL,N2TYPE_RES,RESSUB_FUNC1,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"axis",draw_axis}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_FUNC3,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"nub",draw_nub}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_FUNC1,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"quads",draw_quads}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_DISP1,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"box",&box_disp1}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_IMG1,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"checker-img",&checker_img1}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_IMG1,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"2x2-img",&check2x2_img1}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_CAM,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"cam2d",&sys2d_cam}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_FTYPE,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"sys",&ResFTypeSysList}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_DISP4,}, + M_RES_COMPILED|M_RES_DONTFREE,0,"shdef",&shadow_disp4}, + + {{NUL,NUL,N2TYPE_RES,RESSUB_JUMP,}, // place an init function in table + M_RES_COMPILED|M_RES_DONTFREE,0,"rcInit",resCompiledInit}, + + {{NUL,NUL,N2TYPE_NONE,}, + 0,0,} // term +}; + +struct { + char *name; + void *data; +} resCompiledData[]= +{ + {"box",&box_disp1}, + {"checker-img",&checker_img1}, + {"check2x2-img",&check2x2_img1}, + {"cam2d",&sys2d_cam}, + {"sys",&ResFTypeSysList}, + {NUL,} +}; // resCompiledData() + +void draw_quads(void) +{ + glBegin(GL_QUADS); + + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(1.0, 0.0); glVertex3f( 0.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f( 0.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, -1.0, 0.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 3.5, -1.0); + glTexCoord2f(0.1, 0.0); glVertex3f( 1.0, 3.5, -1.0); + glTexCoord2f(0.1, 0.1); glVertex3f( 1.0, 1.5, -1.0); + glTexCoord2f(0.0, 0.1); glVertex3f(-1.0, 1.5, -1.0); + + glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0); + glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0); + glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421); + glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0, -1.41421); + + glEnd(); +} // draw_quads() + +#define VIDDRAW_SPHERE_SEGMENTS 8 +// +// SphereDef +// storage for pre-calculated sphere +// note: the "+1" is intentional in the array's second dimensional definition +// +struct +{ + float x; + float y; + float z; + float x2; + float y2; + float z2; +} SphereDef[VIDDRAW_SPHERE_SEGMENTS/2][VIDDRAW_SPHERE_SEGMENTS+1]; + +// +// xVidDrawInitSphere +// initialize the sphere object used by xVidDraw +// +// in: +// out: +// global: +// +// GNP 17 Dec 05 +// +void xVidDrawInitSphere(void) +{ + int i,j,n; + double t1,t2,t3,ca,sa,cb,sb; + + n=VIDDRAW_SPHERE_SEGMENTS; + for(j=0;j=0;i--) + { + t3=i*2*PI/n; + ca=MathCosSind(t2,&sa); + cb=MathCosSind(t3,&sb); + SphereDef[j][i].x=ca*cb; + SphereDef[j][i].y=sa; + SphereDef[j][i].z=ca*sb; + + ca=MathCosSind(t1,&sa); + SphereDef[j][i].x2=ca*cb; + SphereDef[j][i].y2=sa; + SphereDef[j][i].z2=ca*sb; + } // for + } // for + +//DONE("xVidDrawInitSphere") +} // xVidDrawInitSphere + + +// JFL 24 Nov 04 +void xVidDraw(uns shape,float scale) +{ + int i,j,n; + float q4,q3,q1; + float x,y,z,xx,yy,zz; +#if 0 //only needed for formula driven sphere + double t1,t2,t3,ca,sa,cb,sb; +#endif + + glFrontFace(GL_CCW); + //glDisable(GL_BLEND); + + switch(shape&0xff) + { + case VIDDRAW_GRID: + glDisable(GL_TEXTURE_2D); + + glColor3ub(190,190,190); + + q4=scale; + n=VidDisp.gridDim; + + x=(n*q4)*0.5; + z=-(n*q4)*0.5; + for(j=0;j<=n;j++,z+=q4) + { + glBegin(GL_LINE_STRIP); + glVertex3f(-x, 0.0,z); + glVertex3f( x, 0.0,z); + glEnd(); + + glBegin(GL_LINE_STRIP); + glVertex3f( z, 0.0,-x); + glVertex3f( z, 0.0, x); + glEnd(); + + } // for + + glColor3ub(255,255,255); + + glBegin(GL_LINE_STRIP); + glVertex3f( scale/(n*2), 0.0, 0); + glVertex3f( -scale/(n*2), 0.0, 0); + glEnd(); + + glBegin(GL_LINE_STRIP); + glVertex3f( 0, 0.0,-scale/(n*2)); + glVertex3f( 0, 0.0, scale/(n*2)); + glEnd(); + + glBegin(GL_LINE_STRIP); + glVertex3f( 0, -scale/(n*2),0); + glVertex3f( 0, scale/(n*2),0); + glEnd(); + + + break; + case VIDDRAW_AXIS: + + q4=scale; + q3=0.75*scale; + q1=0.25*scale; + + glDisable(GL_TEXTURE_2D); + + glColor3ub(255, 0, 0); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(q4, 0.0, 0.0); + glVertex3f(q3, q1, 0.0); + glVertex3f(q3, -q1, 0.0); + glVertex3f(q4, 0.0, 0.0); + glVertex3f(q3, 0.0, q1); + glVertex3f(q3, 0.0, -q1); + glVertex3f(q4, 0.0, 0.0); + glEnd(); + + glColor3ub(0, 255, 0); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, q4, 0.0); + glVertex3f(0.0, q3, q1); + glVertex3f(0.0, q3, -q1); + glVertex3f(0.0, q4, 0.0); + glVertex3f(q1, q3, 0.0); + glVertex3f(-q1, q3, 0.0); + glVertex3f(0.0, q4, 0.0); + glEnd(); + + glColor3ub(0, 0, 255); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 0.0, q4); + glVertex3f(q1, 0.0, q3); + glVertex3f(-q1, 0.0, q3); + glVertex3f(0.0, 0.0, q4); + glVertex3f(0.0, q1, q3); + glVertex3f(0.0, -q1, q3); + glVertex3f(0.0, 0.0, q4); + glEnd(); + break; + + case VIDDRAW_PROJECTILE: + + glColor3ub(255, 0, 0); + + xVidDraw(VIDDRAW_SPHERE, scale/8); + + q4=scale; + q3=0.75*scale; + q1=0.25*scale; + + glDisable(GL_TEXTURE_2D); + + glColor3ub(0, 0, 255); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 0.0, q4); + glVertex3f(q1, 0.0, q3); + glVertex3f(-q1, 0.0, q3); + glVertex3f(0.0, 0.0, q4); + glVertex3f(0.0, q1, q3); + glVertex3f(0.0, -q1, q3); + glVertex3f(0.0, 0.0, q4); + glEnd(); + break; + + case VIDDRAW_JOINT: + + q4=scale; + q3=0.75*scale; + q1=0.25*scale; + + glDisable(GL_TEXTURE_2D); + + glColor3ub(255, 0, 0); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(q4, 0.0, 0.0); + glEnd(); + + glColor3ub(0, 255, 0); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, q4, 0.0); + glEnd(); + + glColor3ub(0, 0, 255); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 0.0, q4); + glEnd(); + break; + + case VIDDRAW_NUB: + + q4=scale*0.25; + + glDisable(GL_TEXTURE_2D); + + glColor3ub(190, 50, 50); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(q4, 0.0, 0.0); + glEnd(); + + glColor3ub(50, 190, 50); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, q4, 0.0); + glEnd(); + + glColor3ub(50, 50, 190); + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 0.0, q4); + glEnd(); + break; + case VIDDRAW_SPHERE: + // modified to table driven sphere - GNP 17DEC05 + n=VIDDRAW_SPHERE_SEGMENTS; + + for(j=0;j=0;i--) + { + x=SphereDef[j][i].x; + y=SphereDef[j][i].y; + z=SphereDef[j][i].z; + xx=scale*x; + yy=scale*y; + zz=scale*z; + + glNormal3f(x,y,z); + glVertex3f(xx,yy,zz); + + x=SphereDef[j][i].x2; + y=SphereDef[j][i].y2; + z=SphereDef[j][i].z2; + xx=scale*x; + yy=scale*y; + zz=scale*z; + + glNormal3f(x,y,z); + glVertex3f(xx,yy,zz); + + } // for + glEnd(); + } // for + +#if 0 //formula driven + n=VIDDRAW_SPHERE_SEGMENTS; + for(j=0;j=0;i--) + { + t3=i*2*PI/n; + ca=MathCosSind(t2,&sa); + cb=MathCosSind(t3,&sb); + x=ca*cb; + y=sa; + z=ca*sb; + xx=scale*x; + yy=scale*y; + zz=scale*z; + + glNormal3f(x,y,z); + //glTexCoord2f(i/(double)n,2*(j+1)/(double)n); + glVertex3f(xx,yy,zz); + + ca=MathCosSind(t1,&sa); + x=ca*cb; + y=sa; + z=ca*sb; + xx=scale*x; + yy=scale*y; + zz=scale*z; + + glNormal3f(x,y,z); + // glTexCoord2f(i/(double)n,2*j/(double)n); + glVertex3f(xx,yy,zz); + + } // for + glEnd(); + } // for +#endif //comment + break; + + case VIDDRAW_001: + + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0.0, 0.0, scale); + glEnd(); + + break; + + } // switch + + glColor3ub(255, 255, 0); // yellow +} // xVidDraw() + +void draw_axis(void) {xVidDraw(VIDDRAW_AXIS,1);} + +// JFL 24 Feb 05 +// JFL 12 May 05; skel root driver either ani or vel +void draw_nub(void *o, StateRec *sr) +{ + int i; + InpRec *ir=InpGet(INPREC_DEBUG); + Obj *o2,*o3; + N2ScanRec nsr; + float a,rot[3]; + + if(!o || ObjIsSub(o,OBJSUB_FUNC)) + goto draw_default; + + i=((ObjFunc*)o)->n; + switch(i) + { + case 0: + default: +draw_default: + xVidDraw(VIDDRAW_NUB,1); + break; + + case 1: + // special case test code + glPushMatrix(); + + if(ir) + { + // find skelres + if(1 + && (o2=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_SUB + |OBJSUB_SKELRES|M_N2SCAN_NODEEPER|M_N2SCAN_WRAP,o)) + && (o3=((ObjSkelRes*)o2)->rootDriver) // ObjAniRes + ) + { + + if(o3->lnk.sub==OBJSUB_ANIRES) + { + glTranslatef(((ObjAniRes*)o3)->cur[OAR_CH_TX], + ((ObjAniRes*)o3)->cur[OAR_CH_TY], + ((ObjAniRes*)o3)->cur[OAR_CH_TZ]); + if(((ObjAniRes*)o3)->cur[OAR_CH_RZ]) + a=RAD2DEG(((ObjAniRes*)o3)->cur[OAR_CH_RZ]), + glRotatef(a,0,0,1); + if(((ObjAniRes*)o3)->cur[OAR_CH_RY]) + a=RAD2DEG(((ObjAniRes*)o3)->cur[OAR_CH_RY]), + glRotatef(a,0,1,0); + if(((ObjAniRes*)o3)->cur[OAR_CH_RX]) + a=RAD2DEG(((ObjAniRes*)o3)->cur[OAR_CH_RX]), + glRotatef(a,1,0,0); + if(!(((ObjAniRes*)o3)->flags&M_OBJANIRES_NOSCALE)) + glScalef(((ObjAniRes*)o3)->cur[OAR_CH_SX], + ((ObjAniRes*)o3)->cur[OAR_CH_SY], + ((ObjAniRes*)o3)->cur[OAR_CH_SZ]); + } + else if(o3->lnk.sub==OBJSUB_VEL) + { + glTranslatef(((ObjVel*)o3)->trans[0], + ((ObjVel*)o3)->trans[1],((ObjVel*)o3)->trans[2]); + if(((ObjVel*)o3)->rot[2]) + a=RAD2DEG(((ObjVel*)o3)->rot[2]), + glRotatef(a,0,0,1); + if(((ObjVel*)o3)->rot[1]) + a=RAD2DEG(((ObjVel*)o3)->rot[1]), + glRotatef(a,0,1,0); + if(((ObjVel*)o3)->rot[0]) + a=RAD2DEG(((ObjVel*)o3)->rot[0]), + glRotatef(a,1,0,0); + if(((ObjVel*)o3)->flags&M_OBJVEL_SCALE) + { + glScalef(((ObjVel*)o3)->scale[0], + ((ObjVel*)o3)->scale[1],((ObjVel*)o3)->scale[2]); + } + } + } // found skelres + } + + xVidDraw(VIDDRAW_AXIS,1); + glPopMatrix(); + break; + case 2: + // special case test code + glPushMatrix(); + + // find vel extension at same level + if(1 + && (o2=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_SUB + |OBJSUB_VEL|M_N2SCAN_KIDSONLY,o)) + ) + { + glTranslatef(((ObjVel*)o2)->trans[0], + ((ObjVel*)o2)->trans[1],((ObjVel*)o2)->trans[2]); + + if((a=((ObjVel*)o2)->rot[2])) + a=RAD2DEG(a), + glRotatef(a,0,0,1); + if((a=((ObjVel*)o2)->rot[1])) + a=RAD2DEG(a), + glRotatef(a,0,1,0); + if((a=((ObjVel*)o2)->rot[0])) + a=RAD2DEG(a), + glRotatef(a,1,0,0); + + } + + xVidDraw(VIDDRAW_AXIS,1); + glPopMatrix(); + break; + case 3: + xVidDraw(VIDDRAW_AXIS,5); + break; + case 4: + //red ball + sr->curTex = 0; + glDisable(GL_TEXTURE_2D); + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + glColor3ub(255,0,0); + glShadeModel(GL_FLAT); + glPolygonMode(GL_FRONT,GL_FILL); + //glEnable(GL_LIGHTING); + xVidDraw(VIDDRAW_SPHERE,0.2); + + break; + + case 5: + // special case test code + if(!(o2=((ObjFunc*)o)->d)) + break; + if(o2->lnk.sub!=OBJSUB_VEL) + break; + glPushMatrix(); + + glTranslatef(((ObjVel*)o2)->trans[0], + ((ObjVel*)o2)->trans[1],((ObjVel*)o2)->trans[2]); + + // turn normal into rotation + MathNrmToRot(((ObjVel*)o2)->rot,rot); + + if((a=rot[2])) + a=RAD2DEG(a), + glRotatef(a,0,0,1); + if((a=rot[1])) + a=RAD2DEG(a), + glRotatef(a,0,1,0); + if((a=rot[0])) + a=RAD2DEG(a), + glRotatef(a,1,0,0); + + glColor3ub(0,255,255); + xVidDraw(VIDDRAW_001,1); + + glPopMatrix(); + break; + case 6: + //green ball + sr->curTex = 0; + glDisable(GL_TEXTURE_2D); + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + glColor3ub(0,115,28); + glShadeModel(GL_FLAT); + glPolygonMode(GL_FRONT,GL_FILL); + //glEnable(GL_LIGHTING); + xVidDraw(VIDDRAW_SPHERE,0.2); + + break; + case 7: + //orange ball + sr->curTex = 0; + glDisable(GL_TEXTURE_2D); + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + glColor3ub(255,114,0); + glShadeModel(GL_FLAT); + glPolygonMode(GL_FRONT,GL_FILL); + //glEnable(GL_LIGHTING); + xVidDraw(VIDDRAW_SPHERE,0.2); + + break; + case 8: + // special case test code + glPushMatrix(); + + // find vel extension at same level + if(1 + && (o2=N2Scan(&nsr,M_N2SCAN_INIT|M_N2SCAN_SUB + |OBJSUB_VEL|M_N2SCAN_KIDSONLY,o)) + ) + { + glTranslatef(((ObjVel*)o2)->trans[0], + ((ObjVel*)o2)->trans[1],((ObjVel*)o2)->trans[2]); + + if((a=((ObjVel*)o2)->rot[2])) + a=RAD2DEG(a), + glRotatef(a,0,0,1); + if((a=((ObjVel*)o2)->rot[1])) + a=RAD2DEG(a), + glRotatef(a,0,1,0); + if((a=((ObjVel*)o2)->rot[0])) + a=RAD2DEG(a), + glRotatef(a,1,0,0); + + } + + xVidDraw(VIDDRAW_PROJECTILE,1); + glPopMatrix(); + break; + + } // switch + +} // draw_nub() + +// JFL 20 Oct 04 +// JFL 28 Oct 04; disp2 +int xResLoadDisp(Res *res,void *rhdata) +{ + int ec; + ResDataDisp1 *disp1; + ResDataDisp2 *disp2; + ResDataDisp3 *disp3; + ResDataDisp4 *disp4; + int size=0; + + switch(res->lnk.sub) + { + case RESSUB_DISP1: + disp1=res->data; + + if(res->flags&M_RES_COMPILED) + break; // don't patch compiled resources + + // until the linker/loader is fully working, locate individually + if(disp1->tVerts) + disp1->tVerts = (void*)((memu)disp1->tVerts + +(memu)&disp1->tVerts); + if(disp1->tTexCoords) + disp1->tTexCoords = (void*)((memu)disp1->tTexCoords + +(memu)&disp1->tTexCoords); + if(disp1->tVertColors) + disp1->tVertColors = (void*)((memu)disp1->tVertColors + +(memu)&disp1->tVertColors); + + if(rhdata) + { + *((ResDataDisp1*)rhdata)=*disp1; + ((ResDataDisp1*)rhdata)->tVerts=NUL; // this will be freed, zero it + ((ResDataDisp1*)rhdata)->tTexCoords=NUL; // this will be freed, zero it + ((ResDataDisp1*)rhdata)->tVertColors=NUL; // this will be freed, zero it + } + + size=sizeof(ResDataDisp1); + break; // RESSUB_DISP1 + case RESSUB_DISP2: + disp2=res->data; + + if(res->flags&M_RES_COMPILED) + break; // don't patch compiled resources + + // until the linker/loader is fully working, locate individually + + if(disp2->tVerts) + disp2->tVerts = (void*)((memu)disp2->tVerts + +(memu)&disp2->tVerts); + if(disp2->tVertColors) + disp2->tVertColors = (void*)((memu)disp2->tVertColors + +(memu)&disp2->tVertColors); + if(disp2->tTexCoords) + disp2->tTexCoords = (void*)((memu)disp2->tTexCoords + +(memu)&disp2->tTexCoords); + if(disp2->tFaceSort) + disp2->tFaceSort = (void*)((memu)disp2->tFaceSort + +(memu)&disp2->tFaceSort); + if(disp2->tNormals) + disp2->tNormals = (void*)((memu)disp2->tNormals + +(memu)&disp2->tNormals); + + if(disp2->qVerts) + disp2->qVerts = (void*)((memu)disp2->qVerts + +(memu)&disp2->qVerts); + if(disp2->qVertColors) + disp2->qVertColors = (void*)((memu)disp2->qVertColors + +(memu)&disp2->qVertColors); + if(disp2->qTexCoords) + disp2->qTexCoords = (void*)((memu)disp2->qTexCoords + +(memu)&disp2->qTexCoords); + if(disp2->qFaceSort) + disp2->qFaceSort = (void*)((memu)disp2->qFaceSort + +(memu)&disp2->qFaceSort); + if(disp2->qNormals) + disp2->qNormals = (void*)((memu)disp2->qNormals + +(memu)&disp2->qNormals); + + if(disp2->atBuf) + disp2->atBuf = (void*)((memu)disp2->atBuf + +(memu)&disp2->atBuf); + + disp2->texGen2 = 0; + + if(rhdata) + { + *((ResDataDisp2*)rhdata)=*disp2; + // jjj -- geometry isn't freed unless in 'tmp' mem pool -- need to handle this + } + + // set-up VBOs if available + if( 0 ) +// if( VidDisp.bSupportVBO ) + { + if (!disp2->tFaceSort && !disp2->qFaceSort) + { + // only on non-facesorted objects + + // check for triangles + if(disp2->tVerts) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->tVertsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->tVertsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nTris*RESFLOATSPER_VERT*sizeof(float), disp2->tVerts, GL_STATIC_DRAW_ARB ); + } + + if(disp2->tVertColors) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->tVertColorsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->tVertColorsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nTris*RESFLOATSPER_COLOR*sizeof(float), disp2->tVertColors, GL_STATIC_DRAW_ARB ); + } + + if(disp2->tTexCoords) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->tTexCoordsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->tTexCoordsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nTris*RESFLOATSPER_TEXCOORD*sizeof(float), disp2->tTexCoords, GL_STATIC_DRAW_ARB ); + } + + if(disp2->tNormals) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->tNormalsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->tNormalsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nTris*RESFLOATSPER_NORMAL*sizeof(float), disp2->tNormals, GL_STATIC_DRAW_ARB ); + } + + + // check for quads + if(disp2->qVerts) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->qVertsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->qVertsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nQuads*RESFLOATSPER_VERT*sizeof(float), disp2->qVerts, GL_STATIC_DRAW_ARB ); + } + + if(disp2->qVertColors) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->qVertColorsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->qVertColorsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nQuads*RESFLOATSPER_COLOR*sizeof(float), disp2->qVertColors, GL_STATIC_DRAW_ARB ); + } + + if(disp2->qTexCoords) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->qTexCoordsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->qTexCoordsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nQuads*RESFLOATSPER_TEXCOORD*sizeof(float), disp2->qTexCoords, GL_STATIC_DRAW_ARB ); + } + + if(disp2->qNormals) + { + // Generate And Bind The Vertex Buffer + glGenBuffersARB( 1, &(disp2->qNormalsVBO) ); + glBindBufferARB( GL_ARRAY_BUFFER_ARB, disp2->qNormalsVBO ); + // Load The Data + glBufferDataARB( GL_ARRAY_BUFFER_ARB, disp2->nQuads*RESFLOATSPER_NORMAL*sizeof(float), disp2->qNormals, GL_STATIC_DRAW_ARB ); + } + glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); + + } // if not face-sort + } // if support VBO + + // parse the attributes + if(disp2->atSize && disp2->atBuf) + ResParse(res,disp2->atBuf,NUL); + + size=sizeof(ResDataDisp2); + break; // RESSUB_DISP2 + case RESSUB_DISP3: + disp3=res->data; + + if(res->flags&M_RES_COMPILED) + break; // don't patch compiled resources + + // until the linker/loader is fully working, locate individually + + if(disp3->verts) + disp3->verts = (void*)((memu)disp3->verts+(memu)&disp3->verts); + + if(disp3->normals) + disp3->normals = (void*)((memu)disp3->normals+(memu)&disp3->normals); + + if(disp3->faces) + disp3->faces = (void*)((memu)disp3->faces+(memu)&disp3->faces); + + if(disp3->atBuf) + disp3->atBuf = (void*)((memu)disp3->atBuf+(memu)&disp3->atBuf); + + if(rhdata) + { + *((ResDataDisp3*)rhdata)=*disp3; + // jjj -- geometry isn't freed unless in 'tmp' mem pool -- need to handle this + } + + // parse the attributes + if(disp3->atSize && disp3->atBuf) + ResParse(res,disp3->atBuf,NUL); + + size=sizeof(ResDataDisp3); + break; // RESSUB_DISP3 + case RESSUB_DISP4: + disp4=res->data; + + if(res->flags&M_RES_COMPILED) + break; // don't patch compiled resources + + // until the linker/loader is fully working, locate individually + + if(disp4->verts) + disp4->verts = (void*)((memu)disp4->verts+(memu)&disp4->verts); + + if(disp4->faces) + disp4->faces = (void*)((memu)disp4->faces+(memu)&disp4->faces); + + if(disp4->joints) + disp4->joints = (void*)((memu)disp4->joints+(memu)&disp4->joints); + + if(disp4->weights) + disp4->weights = (void*)((memu)disp4->weights+(memu)&disp4->weights); + + if(disp4->atBuf) + disp4->atBuf = (void*)((memu)disp4->atBuf+(memu)&disp4->atBuf); + + if(rhdata) + { + *((ResDataDisp4*)rhdata)=*disp4; + // jjj -- geometry isn't freed unless in 'tmp' mem pool -- need to handle this + } + + // parse the attributes + if(disp4->atSize && disp4->atBuf) + ResParse(res,disp4->atBuf,NUL); + + size=sizeof(ResDataDisp4); + break; // RESSUB_DISP4 + default: + LOCKUP(BP_XRESLOADDISP); // only handles disp1 now + err(-1); + } + + ec=size; // return size of struct +BAIL: + return ec; +} // xResLoadDisp() + +// ------------------------------------------------------------------- +// xResLoadVid - MAN 06 Dec 06 +// +// - loads a video resource object into the system. + +int xResLoadVid(Res *res, void *rhdata) +{ + ResDataVid *vid; + unsigned char *p; + int i, ec; + + if (res->lnk.sub != RESSUB_VID) { + err(-1); + } + + // - get our res object and a pointer to the data + + vid = res->data; + p = (void*)&vid[1]; + + // - alloc and copy over the raw file data + + vid->data = NULL; + vid->data = malloc(vid->fileSize); + + /* + if ((ec = MemDAlloc(MEMPOOL_WAVE, vid->fileSize, vid->data)) < 0) + { + BP(1); + goto BAIL; + } + */ + + if (vid->data) + { + memcpy(vid->data, p, vid->fileSize); + resTotalVidAlloced += vid->fileSize; + /* + printf("xResLoadVid: alloc'ed %2.2f MB. total = %2.2f MB\n" + , (float)vid->fileSize / (1024 * 1024) + , (float)resTotalVidAlloced / (1024 * 1024)); + */ + } + + // - since the theora structure hasn't been allocated yet, it is + // null. + + vid->theora = NULL; + + // - make our data accessible via the resource object + + + if (rhdata) + { + *((ResDataVid*)rhdata) = *vid; + // printf("rhdata = %p : size = %i : vid data = %p\n", rhdata, vid->fileSize, vid->data); + } + + ec = sizeof(ResDataVid); + +BAIL: + return ec; +} + +// ------------------------------------------------------------------- + +// JFL 22 Oct 04 +int xResLoadImg(Res *res,void *rhdata) +{ + int ec; + ResDataImg1 *img; + + if(res->lnk.sub!=RESSUB_IMG1) + { + LOCKUP(BP_XRESLOADIMG); // only handles img1 now + err(-1); + } + + img=res->data; + + if(!(res->flags&M_RES_COMPILED)) + { + if(img->tex) + img->tex = (void*)((memu)img->tex+(memu)&img->tex); + } + + if(!img->texGen) + { + imgLoad(img); + // - if the image is merely a placeholder for video, we want to + // load it with dummy data that doesn't take up too much space. + /* + //if ((strstr(res->name, "frame") || strstr(res->name, ".0"))) + if ((strstr(res->name, "frame.0")) + && !strstr(res->name, "01frame")) + { + //printf("dummy loading %s\n", res->name); + dummyImgLoad(img); + } + else + { + //printf("reg loading %s\n", res->name); + imgLoad(img); + } + */ + } + + if(rhdata) + { +// jjj -- only zero if it's in the 'tmp' mem pool + *((ResDataImg1*)rhdata)=*img; + ((ResDataImg1*)rhdata)->tex=NUL; // this will be freed, zero it + } + + ec=sizeof(ResDataImg1); // return size of struct +BAIL: + return ec; +} // xResLoadImg() + +// JFL 28 Oct 04 +int xResLoadCam(Res *res,void *rhdata) +{ + int ec; + ResDataCam *cam; + + cam=res->data; + + if(!(res->flags&M_RES_COMPILED)) + { + if(cam->atBuf) + cam->atBuf = (void*)((memu)cam->atBuf+(memu)&cam->atBuf); + } + + // parse the attributes + if(cam->atSize && cam->atBuf) + ResParse(res,cam->atBuf,NUL); + + ec=sizeof(ResDataCam); // return size of struct + return ec; +} // xResLoadCam() + +// JFL 14 Dec 04 +int xResLoadLight(Res *res,void *rhdata) +{ + int ec; + ResDataLight *light; + + light=res->data; + + if(!(res->flags&M_RES_COMPILED)) + { + if(light->atBuf) + light->atBuf = (void*)((memu)light->atBuf+(memu)&light->atBuf); + } + + // parse the attributes + if(light->atSize && light->atBuf) + ResParse(res,light->atBuf,NUL); + +// #if PRODUCTION + #if 0 + if(!SYS_JAMMASN(SysG.projammasn)) + { + SysG.profailrgb[1]=255; // yellow + VidDisp.flags|=M_VIDDISP_PROFAIL; + } + #endif // PRODUCTION + + ec=sizeof(ResDataLight); // return size of struct + return ec; +} // xResLoadLight() + +// JFL 17 Nov 04 +int xResLoadSkel(Res *res,void *rhdata) +{ + int ec; + ResDataSkel *hier; + + hier=res->data; + + if(!(res->flags&M_RES_COMPILED)) + { + // not compiled, relocate + if(hier->joints) + hier->joints = (void*)((memu)hier->joints+(memu)&hier->joints); + if(hier->weights) + hier->weights = (void*)((memu)hier->weights+(memu)&hier->weights); + } + + ec=sizeof(ResDataSkel); // return size of struct + return ec; +} // xResLoadSkel() + +// JFL 07 Feb 05 +int xResLoadCol(Res *res,void *rhdata) +{ + int ec; + ResDataCol *col; + + col=res->data; + + if(!(res->flags&M_RES_COMPILED)) + { + // not compiled, relocate + if(col->blocks) + col->blocks = (void*)((memu)col->blocks+(memu)&col->blocks); + if(col->polys) + col->polys = (void*)((memu)col->polys+(memu)&col->polys); + if(col->atBuf) + col->atBuf = (void*)((memu)col->atBuf+(memu)&col->atBuf); + } + + ec=sizeof(ResDataCol); // return size of struct + return ec; +} // xResLoadCol() + +// JFL 12 Apr 05 +int xResLoadFont(Res *res,void *rhdata) +{ + int ec; + ResDataFont *font; + + font=res->data; + + if(!(res->flags&M_RES_COMPILED)) + { + if(font->fcs) + font->fcs = (void*)((memu)font->fcs+(memu)&font->fcs); + } + + ec=sizeof(ResDataFont); // return size of struct + return ec; +} // xResLoadFont() + +// JFL 29 Nov 04 +int xResLoadGroup(Res *res,void *rhdata) +{ + int ec; + ec=0;// sizeof(ResDataGroup); // return size of struct + return ec; +} // xResLoadGroup() + +// JFL 11 Nov 04 +int ResInfoExpand(char *buf,int size,Res *r,uns flags) +{ + return 0; +} // ResInfoExpand() + +// JFL 30 Dec 04 +int xResRelease(Res *res) +{ + int intdat[4]; + void *d; + + if(res->lnk.type!=N2TYPE_RES) + return -1; + switch(res->lnk.sub) + { + case RESSUB_IMG1: + if(!(d=res->data)) + break; + intdat[0]=((ResDataImg1*)d)->texGen; + ((ResDataImg1*)d)->texGen=0; + glDeleteTextures(1,intdat); + VidDisp.texAllocs--; + VidDisp.texMem-=((ResDataImg1*)d)->w*((ResDataImg1*)d)->h; + break; + + case RESSUB_VID: + + if (!(d = res->data)) + break; + + // - if the theora ptr is non-null, it was previously allocated + // and needs to be taken down! + + if (((ResDataVid*)d)->theora) + theorafunc_unload( ((ResDataVid*)d)->theora ); + + if (((ResDataVid*)d)->data) + { + free(((ResDataVid*)d)->data); + + //printf("xResRelease: freed %i bytes.\n", ((ResDataVid*)d)->fileSize); + resTotalVidAlloced -= ((ResDataVid*)d)->fileSize; + } + + break; + } // switch + return 0; +} // xResRelease() + +#endif // SYS_GL +// EOF diff --git a/dond/coregl/vid_gl.c b/dond/coregl/vid_gl.c new file mode 100755 index 0000000..dde35f3 --- /dev/null +++ b/dond/coregl/vid_gl.c @@ -0,0 +1,399 @@ +#if SYS_GL +// vid_gl.c +// +// video graphics interface - pc +// Play Mechanix Platform Independent Video System +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 07 Oct 04; from ah + +///#include + +#include "pm.h" +#include "sys.h" +#ifdef SYS_BB +#include +#include +#else +#include +#include +#endif +#include "mem.h" +#include "fb.h" +#include "str.h" +#include "vid.h" + +VidDispInfo VidDisp; // display info computed + +//#define GL_ARRAY_BUFFER_ARB 0x8892 +//#define GL_STATIC_DRAW_ARB 0x88E4 +//typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +//typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +//typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +//typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage); + +#ifndef SYS_BB +// VBO Extension Function Pointers +PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL; // VBO Name Generation Procedure +PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL; // VBO Bind Procedure +PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL; // VBO Data Loading Procedure +PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL; // VBO Deletion Procedure +#endif //!SYS_BB + +// frame +typedef struct _vp { + struct _vp *next; + uns32 flags; +} Vid; + +void* vidSysMem0=NUL; +/////////////////////////////////////////////////////////////////////////////// +// VID + +// JFL 03 Sep 04 +int VidInit(void) +{ + vidSysMem0=NUL; + MEMZ(VidDisp); + + VidDisp.fogMode=GL_LINEAR; + VidDisp.fogNear=90.0; + VidDisp.fogFar=1000.0; + VidDisp.fogDensity=0.20f; + VidDisp.fogRGBA[0]=0.0f; + VidDisp.fogRGBA[1]=0.8f; + VidDisp.fogRGBA[2]=0.0f; + VidDisp.fogRGBA[3]=0.0f; + + VidDisp.gridSize=10; + VidDisp.gridDim=10; + VidDisp.maxLights=VID_MAXLIGHTS; + + if(sizeof(GLfloat)!=sizeof(float)) + { + // assumptions are made in the data & program + LOCKUP(BP_VIDINIT); + return -2; + } + + return 0; +} // VidInit() + +// JFL 03 Sep 04 +void VidFinal(void) +{ +} // VidFinal() + +// JFL 22 Sep 04 +int VidReset(uns reset) +{ + VidDisp.flags&=~(M_VIDDISP_FOG|M_VIDDISP_GSHADOW|M_VIDDISP_SYNC_VBLANK); + + // always reset global shadow parameters + VidDisp.shadowRGBA[0]=0; + VidDisp.shadowRGBA[1]=0; + VidDisp.shadowRGBA[2]=0; + VidDisp.shadowRGBA[3]=100; + VidDisp.shadowDist=30; // should be a certain height above ground + +// #if PRODUCTION + #if 0 + if(reset) // do this on wipeout + { + int i=SysGetHardwareInfo(SYSGETHARDWAREINFO_SN,NUL,0); + if(!SYS_HARDSN(i)) + VidDisp.flags|=M_VIDDISP_PROFAIL; + } + #endif // PRODUCTION + + return 0; +} // VidReset() + +// +// IsExtensionSupported +// Check to see if OpenGL extension is supported +// from: +// http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=45 +// +// in: +// szTargetExtension = ptr to character string name of extension +// out: +// <>0 = supported +// global: +// +// GNP 25 Nov 05 +// +uns8 IsExtensionSupported( char* szTargetExtension ) +{ + const unsigned char *pszExtensions = NULL; + const unsigned char *pszStart; + unsigned char *pszWhere, *pszTerminator; + + // Extension names should not have spaces + pszWhere = (unsigned char *) strchr( szTargetExtension, ' ' ); + if( pszWhere || *szTargetExtension == '\0' ) + return(0); + + // Get Extensions String + pszExtensions = glGetString( GL_EXTENSIONS ); + + // Search The Extensions String For An Exact Copy + pszStart = pszExtensions; + for(;;) + { + pszWhere = (unsigned char *) strstr( (const char *) pszStart, szTargetExtension ); + if( !pszWhere ) + break; + pszTerminator = pszWhere + strlen( szTargetExtension ); + if( pszWhere == pszStart || *( pszWhere - 1 ) == ' ' ) + if( *pszTerminator == ' ' || *pszTerminator == '\0' ) + return(1); + pszStart = pszTerminator; + } + return(0); +//DONE("IsExtensionSupported") +} // IsExtensionSupported + +// JFL 03 Sep 04 +// JFL 07 Oct 04 +int VidStart(void) +{ + int ec; + char *s1,*s2; + GLint i1; + float v[4]; + char tS[256]; + + if(!FbRes) + err(-1); + + VidDisp.screenW = FbRes->screenW; + VidDisp.screenH = FbRes->screenH; + VidDisp.centerX = FbRes->screenW>>1; + VidDisp.centerY = FbRes->screenH>>1; + + // + // OpenGL settings + // + + VidDisp.apiVendor = (void*)glGetString(GL_VENDOR); + VidDisp.apiVersion = (void*)glGetString(GL_VERSION); + VidDisp.apiRenderer = (void*)glGetString(GL_RENDERER); + VidDisp.apiExtensions = (void*)glGetString(GL_EXTENSIONS); + +#if DEBUG + SysLog("GL Vendor:\n%s\n",VidDisp.apiVendor); + SysLog("GL Version:\n%s\n",VidDisp.apiVersion); + SysLog("GL Renderer:\n%s\n",VidDisp.apiRenderer); + +// prints a list of OpenGL extensions +#if 0 + SysLog("GL Extensions:\n"); + s1=VidDisp.apiExtensions; + while ((s2 = strchr(s1,0x20)) != NULL) + { + int pos; + pos = s2-s1; + strncpy(tS,s1,pos+1); + tS[pos+1]=0; + SysLog("%s\n",tS); + s1=s2+1; + } +#endif + +#endif //DEBUG + + s1=VidDisp.apiExtensions; + + VidDisp.bSupportVBO = IsExtensionSupported( "GL_ARB_vertex_buffer_object" ); + if( VidDisp.bSupportVBO ) + { + // Get Pointers To The GL Functions +#ifndef SYS_BB + glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB"); + glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB"); + glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB"); + glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) wglGetProcAddress("glDeleteBuffersARB"); +#endif //!SYS_BB + } + else + { + SysLog("VidStart: GL_ARB_vertex_buffer_object not supported\n"); + } + +#ifdef SYS_BB + { + int vs,ve; + uns64 sanityTime; + char *e; + + sanityTime = SysMilliSec() + 4*16; + + if (!glXGetVideoSyncSGI(&vs)) + { + while (sanityTime > SysMilliSec()) + { + glXGetVideoSyncSGI(&ve); + if (ve != vs) + { + VidDisp.VSyncTimerStart = SysMicroSec(); + VidDisp.bSoftwareVSync = 1; + break; + } + } + } + if (!VidDisp.bSoftwareVSync) + SysLog("VidStart: glXGetVideoSyncSGI() not working\n"); + + // check if we are letting the hardware handle vsync + e=(char*)getenv("__GL_SYNC_TO_VBLANK"); + if((e!=NULL) & (e[0] != '0')) + { + VidDisp.bHardwareVSync=1; + } +#if DEBUG + if(e==NULL) + SysLog("VidStart: __GL_SYNC_TO_VBLANK not found\n"); + else + SysLog("VidStart: __GL_SYNC_TO_VBLANK = %s\n",e); +#endif //DEBUG + + } +#endif //SYS_BB + // check for expected extensions + //if(!szmid("GL_ARB_imaging",s1)) + // SysLog("GL: imaging extension not available (some blends won't work)\n"); + + // I don't think this works right... + glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_MIN_LOD,&VidDisp.mipMin); + glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_MAX_LOD,&VidDisp.mipMax); + + glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST);//GL_FASTEST);//GL_NICEST); +// glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + // 1=bilinear 2=anisotropic + glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &i1); +#if DEBUG + SysLog("GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = %d\n",i1); +#endif //DEBUG + if(i1>2) + i1=2; // 2 b/c that is the max the NForce2 can do + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, i1 ); + + // glEnable(GL_POLYGON_SMOOTH); + + //Using GL Hints it's not recommended. Performance of Your program will + //get much lower. If You want to make antialiasing of polygons try enabling + //GL_POLYGON_SMOOTH, but remember that You also have to enable GL_BLEND + //with glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). + //Else method of antialiasing is multisample, but You can be sure that + //it will eat many of FPS + + // http://developer.nvidia.com/object/gdc_ogl_multisample.html + // Will's research: + // http://www.opengl.org/resources/tutorials/sig99/advanced99/course_slides/vissim/sld031.htm + // http://www.nvnews.net/previews/geforce_6600_gt/page_3.shtml + // http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt + // http://www.opengl.org/resources/tutorials/advanced/advanced98/notes/node37.html + // http://www.sulaco.co.za/tut4.htm + // http://www.opengl.org/resources/tutorials/sig99/advanced99/notes/node56.html + // http://www.flipcode.com/articles/article_advgltextures.shtml + + // set defaults + // routines must save & restore these settings if changed + + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_FALSE); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE); + glFrontFace(GL_CCW); // front faces counter clock wise + glDisable(GL_SCISSOR_TEST); + glDisable(GL_STENCIL_TEST); + glDisable(GL_COLOR_LOGIC_OP); + glDisable(GL_INDEX_LOGIC_OP); + + glClearDepth(1.0f); + glClearStencil(0); + + // default global ambient light + v[0]=v[1]=v[2]=0;v[3]=1; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT,v); + + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&i1); + VidDisp.maxTexWidthHeight=i1; + + //glewInit(); + + #if SAFE + if(VidDisp.maxTexWidthHeight<1024) + BP(BP_VIDSTART); // game needs at least 1024x1024 texture size + #endif // SAFE + + ec=0; +BAIL: + return ec; +} // VidStart() + +// +// frame +// + +// JFL 19 Nov 03 +void* VidFrameStart() +{ + Vid *vp=NUL; + + if(!vidSysMem0) + return NUL; + + return vp; +} // VidFrameStart() + +// JFL 19 Nov 03 +void VidFrameEnd(void *vid) +{ +} // VidFrameEnd() + +// JFL 04 Dec 03 +void VidDrawSetRenderDest(void *vid,uns32 flags) +{ +} // VidDrawSetRenderDest() + +GLint vglViewport[4]; // 0,0,width,height +GLdouble vglProjection[16]; +GLdouble vglModelView[16]; + +// JFL 24 Mar 05 +void VidGrabViewingMatrices(void) +{ + glGetIntegerv(GL_VIEWPORT,vglViewport); + glGetDoublev(GL_PROJECTION_MATRIX,vglProjection); + glGetDoublev(GL_MODELVIEW_MATRIX,vglModelView); +} // VidGrabViewingMatrices() + +// JFL 24 Mar 05 +int VidWorldPos(crd *scr,crd *pos) +{ + GLdouble x,y,z; + gluUnProject(scr[0],vglViewport[3]-scr[1]-1,scr[2], + vglModelView,vglProjection,vglViewport, + &x,&y,&z); + pos[0]=x; + pos[1]=y; + pos[2]=z; + return 0; +} // VidWorldPos() + +// JFL 29 Mar 05 +int VidScreenPos(crd *world,crd *pos) +{ + GLdouble x,y,z; + gluProject(world[0],world[1],world[2], + vglModelView,vglProjection,vglViewport, + &x,&y,&z); + pos[0]=x; + pos[1]=vglViewport[3]-y-1; + pos[2]=z; + return 0; +} // VidScreenPos() + +#endif // SYS_GL +// EOF diff --git a/dond/corepc/int_pc.c b/dond/corepc/int_pc.c new file mode 100755 index 0000000..0a1ac72 --- /dev/null +++ b/dond/corepc/int_pc.c @@ -0,0 +1,175 @@ +#if SYS_PC +// int_pc.c +// Play Mechanix - Video Game System +// Copyright (c) 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// GNP 01 Sep 00 +// JFL 26 Aug 04 +// JFL 07 Oct 04 + +#include "pm.h" +#include "sys.h" +#include "mem.h" +#include "int.h" + +enum { + INT_DEVICE_SW0, + INT_DEVICE_SW1, + INT_DEVICE_IP2, + INT_DEVICE_IP3, + INT_DEVICE_IP4, + INT_DEVICE_IP5, + INT_DEVICE_IP6, + INT_DEVICE_TIMER, + INT_DEVICE_RTC, + INT_DEVICE_IDE1, // first FPGA + INT_DEVICE_IDE2, + INT_DEVICE_SERIAL0, + INT_DEVICE_ETHERNET, + INT_DEVICE_RENDER, + INT_DEVICE_SOUNDDMA, + INT_DEVICE_DISPLAY, + INT_DEVICE_SERIAL1, + INT_DEVICE_GUN0, + INT_DEVICE_GUN1, + INT_DEVICE_COUNT +}; + +typedef struct { + int enabled; +} IntDeviceRec; + +IntDeviceRec intDevices[INT_DEVICE_COUNT]; + +// +// IntInit +// one time initialization at power-up +// +// in: +// out: +// global: +// +// GNP 01 Sep 00 +// JFL 07 Oct 04 +// +int IntInit(void) +{ + // + // RESET VARS + // + + MEMZ(intDevices); + + return 0; +} // IntInit + +// +// IntReset +// called every time system is reset +// +// in: +// out: +// global: +// +// GNP 01 Sep 00 +// JFL 07 Oct 04 +// +int IntReset(uns reset) +{ + return 0; +} // IntReset + +// +// IntFinal +// called once upon system shutdown +// +// in: +// out: +// global: +// +// GNP 01 Sep 00 +// +void IntFinal(void) +{ +} // IntFinal + +// JFL 31 Aug 04 +int intDeviceEnable(int dev,int enable) +{ + int ec; + + if(dev>=INT_DEVICE_COUNT) + { + BP(BP_INTDEVICEENABLE); + return -1; + } + + intDevices[dev].enabled=enable; + + switch(dev) + { + case INT_DEVICE_SW0: + case INT_DEVICE_SW1: + case INT_DEVICE_IP2: + case INT_DEVICE_IP3: + case INT_DEVICE_IP4: + case INT_DEVICE_IP5: + case INT_DEVICE_IP6: + case INT_DEVICE_TIMER: + case INT_DEVICE_IDE1: + case INT_DEVICE_IDE2: + case INT_DEVICE_SERIAL0: + case INT_DEVICE_SERIAL1: + case INT_DEVICE_RTC: + case INT_DEVICE_ETHERNET: + case INT_DEVICE_SOUNDDMA: + case INT_DEVICE_RENDER: + case INT_DEVICE_DISPLAY: + case INT_DEVICE_GUN0: + case INT_DEVICE_GUN1: + BP(BP_INTDEVICEENABLE2); + err(-2); + } // switch + + ec=0; +BAIL: + if(ec<0) + BP(BP_INTDEVICEENABLE3); + return ec; +} // intDeviceEnable() + +/////////////////////////////////////////////////////////////////////////////// +// + +// JFL 31 Aug 04 +int IntAttach(void) +{ + // + // INSTALL LOW LEVEL EXCEPTION HANDLERS + // + + return 0; +} // IntAttach() + +// JFL 31 Aug 04 +void IntDetach(void) +{ + BP(BP_INTDETACH); // unlink our node..?? +} // IntDetach() + +// +// IntEnable +// +// in: +// out: +// global: +// +// GNP 24 Mar 03 +// JFL 31 Aug 04 +void IntEnable(uns intMask,int enable) +{ + +} // IntEnable() + +#endif // SYS_PC +//EOF diff --git a/dond/corepc/main_pc.c b/dond/corepc/main_pc.c new file mode 100755 index 0000000..5554df2 --- /dev/null +++ b/dond/corepc/main_pc.c @@ -0,0 +1,446 @@ +#if SYS_PC +// main_pc.c +// Play Mechanix - Video Game System +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 26 Aug 04 +// JFL 07 Oct 04 + +#include + +#include "pm.h" +#include "sys.h" +#include "int.h" +#include "mem.h" +#include "fb.h" +#include "fs.h" +#include "vid.h" +#include "net.h" +#include "res.h" +#include "obj.h" +#include "font.h" +#include "inp.h" +#include "cab.h" +#include "gun.h" +#include "game.h" +#include "str.h" +#include "proc.h" +#include "wnd.h" +#include "snd.h" +#include "ftp.h" +#include "draw.h" + +#include +#include +#include // vsprintf +#include + +// strings for time and date stamp of build +#define BUILD_TIME __TIME__ +#define BUILD_DATE __DATE__ + +#define SCRIPT_START "set(str1 atstart) run(perm)" +//#define PATH_START ".;data;/g3/donddata/hd_pc;/g3/donddata/cf" +#define PATH_START "/g3/donddata/hd_pc;/g3/donddata/cf;/g3/donddata/snd" +#define AUDIT_PATH "/g3/donduser/aud" +#define ADJUST_PATH "/g3/donduser/adj" +#define CF_PATH "/g3/donddata/cf" +#define PLR_PATH "/g3/donduser/players" +#define TRN_PATH "/g3/donduser/tourneys" +#define LBD_PATH "/g3/donduser/lboards" +#define SND_PATH "/g3/donddata/snd" +#define LOG_PATH "/g3/donduser/log/" + +void* jps_memdebug_ptr[2048]; +uns jps_memdebug_size[2048]; + +int MainRestartArgc=0; +char *MainRestartArgv[MAIN_RESTART_ARGC_MAX]; +jmp_buf MainJmpBuf; + +// JFL 26 Aug 04 +// JFL 07 Oct 04 +//int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, +// LPSTR lpCmdLine,int nCmdShow) +int main(int argc0,char *argv0[]) +{ + int ec; + char *s1,*s2; + memu hInstance; + uns wndopenflags; + int argc; + char **argv; + SysDate dt; + int swidth, sheight, sresType; + + argc=argc0; + argv=argv0; +restart: + hInstance=0; + wndopenflags=1; // default to full screen + + // + // GUARANTEED INITS + // + + SysWatchdogDisable(); + + // + // INIT ALL SYSTEMS + // + + for(ec=0;ec +#include +#include +#include +#include +#include + +#include "pm.h" +#include "str.h" +#include "sys.h" +#include "mem.h" +#include "aud.h" +#include "obj.h" +#include "game.h" + +uns64 sysTimeBase; +// for micro-second timer +LARGE_INTEGER os_us_freq; +double os_us_freq_d; + +//LPTOP_LEVEL_EXCEPTION_FILTER sysExcHandler(struct _EXCEPTION_POINTERS *exc); +LONG WINAPI sysExcHandler(struct _EXCEPTION_POINTERS *exc); + +typedef struct { + void *excHandler; +} SysPC; + +SysPC sysPC; + +// JFL 07 Oct 04 +int xSysInit(void) +{ + MEMZ(sysPC); + sysTimeBase=glutGet(GLUT_ELAPSED_TIME); + sysPC.excHandler=SetUnhandledExceptionFilter(sysExcHandler); + QueryPerformanceFrequency(&os_us_freq); + os_us_freq_d = (double)(os_us_freq.QuadPart); + os_us_freq_d /= 1000000.0f; // change to us + return 0; +} // xSysInit() + +// JFL 07 Oct 04 +void xSysFinal(void) +{ + if(sysPC.excHandler) + { + SetUnhandledExceptionFilter(sysPC.excHandler); + sysPC.excHandler=NUL; + } +} // xSysFinal() + +// JFL 07 Oct 04 +int xSysReset(uns reset) +{ + return 0; +} // xSysReset() + +// GNP 17 Jun 03 + +void SysWatchdogEnable(void) +{ +} // SysWatchdogEnable() + +// GNP 17 Jun 03 +void SysWatchdogDisable(void) +{ +} // SysWatchdogDisable() + +// GNP 17 Jun 03 +void SysWatchdogBone(void) +{ +} // SysWatchdogBone + +// JFL 07 Oct 04 +void* SysAdr(void) +{ + return NUL; +} // SysAdr() + +// JFL 07 Oct 04 +//void SysLockup(void *adr) +void SysLockup(int id) +{ +// SysLog("LOCKUP: %x\n",adr); + SysLog("LOCKUP: %d\n",(int)id); + GameSysLog(GAMESYSLOG_STATE); + +} // SysLockup() + +// JFL 08 Nov 04 +uns64 SysClockMilliSec(void) +{ + if(SysG.forceFrameTime) + return SysG.loopTime; + else + return glutGet(GLUT_ELAPSED_TIME)-sysTimeBase; +} // SysClockMilliSec() + +// +// xSysMicroSec +// return current system micro-second counter +// +// in: +// out: +// global: +// +// GNP 12 Oct 05 +// +uns64 xSysMicroSec(void) +{ + LARGE_INTEGER li; + double d; + double s; + uns64 retval; + + QueryPerformanceCounter(&li); + d = (double)(li.QuadPart); + s = d/os_us_freq_d; + retval = (uns64)s; + return retval; +//DONE("xSysMicroSec") +} // xSysMicroSec + +// JFL 20 Jul 05 +int SysGetHardwareInfo(uns op,char *buf,int bufsize) +{ + int ec; + DWORD dw; + char buff[8]; + + if(!buf) + buf=buff,bufsize=sizeof(buff),buf[0]='c'; + + ec=0; + switch(op&0xff) + { + case SYSGETHARDWAREINFO_SN: + + // BOOL GetVolumeInformation( + // LPCTSTR lpRootPathName, + // LPTSTR lpVolumeNameBuffer, + // DWORD nVolumeNameSize, + // LPDWORD lpVolumeSerialNumber, + // LPDWORD lpMaximumComponentLength, + // LPDWORD lpFileSystemFlags, + // LPTSTR lpFileSystemNameBuffer, + // DWORD nFileSystemNameSize + // ); + + buf[1]=':'; + buf[2]='\\'; + buf[3]=0; + if(!GetVolumeInformation(buf,NUL,0,&dw,NUL,NUL,NUL,0)) + dw=0; + ec=dw; + break; + } // switch + + return ec; +} // SysGetHardwareInfo() + +extern jmp_buf MainJmpBuf; + +// JFL 22 Jul 05 +void SysRestart(void) +{ + longjmp(MainJmpBuf,1); +} // SysRestart() + +// JFL 22 Jul 05 +LONG WINAPI sysExcHandler(struct _EXCEPTION_POINTERS *exc) +{ + char *s1; + switch(exc->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + s1="ACCESS_VIOLATION"; + break; + case EXCEPTION_DATATYPE_MISALIGNMENT: + s1="DATATYPE_MISALIGNMENT"; + break; + case EXCEPTION_BREAKPOINT: + s1="BREAKPOINT"; + break; + case EXCEPTION_SINGLE_STEP: + s1="SINGLE_STEP"; + break; + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + s1="ARRAY_BOUNDS_EXCEEDED"; + break; + case EXCEPTION_FLT_DENORMAL_OPERAND: + s1="FLT_DENORMAL_OPERAND"; + break; + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + s1="FLT_DIVIDE_BY_ZERO"; + break; + case EXCEPTION_FLT_INEXACT_RESULT: + s1="FLT_INEXACT_RESULT"; + break; + case EXCEPTION_FLT_INVALID_OPERATION: + s1="FLT_INVALID_OPERATION"; + break; + case EXCEPTION_FLT_OVERFLOW: + s1="FLT_OVERFLOW"; + break; + case EXCEPTION_FLT_STACK_CHECK: + s1="FLT_STACK_CHECK"; + break; + case EXCEPTION_FLT_UNDERFLOW: + s1="FLT_UNDERFLOW"; + break; + case EXCEPTION_INT_DIVIDE_BY_ZERO: + s1="INT_DIVIDE_BY_ZERO"; + break; + case EXCEPTION_INT_OVERFLOW: + s1="INT_OVERFLOW"; + break; + case EXCEPTION_PRIV_INSTRUCTION: + s1="PRIV_INSTRUCTION"; + break; + case EXCEPTION_IN_PAGE_ERROR: + s1="IN_PAGE_ERROR"; + break; + case EXCEPTION_ILLEGAL_INSTRUCTION: + s1="ILLEGAL_INSTRUCTION"; + break; + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + s1="NONCONTINUABLE_EXCEPTION"; + break; + case EXCEPTION_STACK_OVERFLOW: + s1="STACK_OVERFLOW"; + break; + case EXCEPTION_INVALID_DISPOSITION: + s1="INVALID_DISPOSITION"; + break; + case EXCEPTION_GUARD_PAGE: + s1="GUARD_PAGE"; + break; + case EXCEPTION_INVALID_HANDLE: + s1="INVALID_HANDLE"; + break; + case CONTROL_C_EXIT: + s1="CONTROL_C_EXIT"; + break; + default: + s1=""; + } // switch + + AudException(); + SysLog("EXCEPTION: %s %x %x\n",s1, + exc->ExceptionRecord->ExceptionAddress,exc->ExceptionRecord->ExceptionFlags); + + GameSysLog(GAMESYSLOG_STATE); + + //if(exc->ExceptionRecord->ExceptionFlags&EXCEPTION_NONCONTINUABLE) + //{ + SysLog("Restarting the game.\n"); + SysRestart(); // doesn't come back.. + //} + return EXCEPTION_CONTINUE_SEARCH; +} // sysExcHandler() + +/////////////////////////////////////////////////////////////////////////////// +// + +#endif // SYS_PC +// EOF \ No newline at end of file diff --git a/dond/corepc/wnd_pc.c b/dond/corepc/wnd_pc.c new file mode 100755 index 0000000..a2717c5 --- /dev/null +++ b/dond/corepc/wnd_pc.c @@ -0,0 +1,584 @@ +#if SYS_PC +// wnd_pc.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 29 Aug 04; from ah/fb.c + +#include +#include +#include + +#include "pm.h" +#include "mem.h" +#include "wnd.h" +#include "font.h" +#include "obj.h" +#include "vec.h" +#include "vid.h" +#include "inp.h" + +WndRec wndlist; + +// WndPrivOGL wndogl; + +// JFL 07 Oct 04 +int WndInit(void) +{ + MEMZ(wndlist); +// MEMZ(wndogl); + return 0; +} // WndInit() + +// JFL 07 Oct 04 +void WndFinal(void) +{ +} // WndFinal() + +// JFL 07 Oct 04 +int WndReset(uns reset) +{ + return 0; +} // WndReset() + +void* WndCur(void) +{ + return &wndlist; +} // WndCur() + +// JFL 12 Nov 04 +int xInpLowScan(void) +{ + uns flags; + + flags=0; + if(GetAsyncKeyState(VK_SHIFT)<0) + flags|=M_INPLOWEVENT_SHF; + if(GetAsyncKeyState(VK_CONTROL)<0) + flags|=M_INPLOWEVENT_CTL; + if(GetAsyncKeyState(VK_MENU)<0) + flags|=M_INPLOWEVENT_ALT; + + InpLowEvent(INPLOWEVENT_NOP|flags,NUL); + + return 0; +} // xInpLowScan() + +LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + crd buf[3]; + uns flags=0; + static HWND hwndCapture=NUL; + static int capture=0; + #if !PRODUCTION + char keys[32]; + #endif // !PRODUCTION + + switch (msg) + { + case WM_CREATE: + break; + case WM_CLOSE: + PostQuitMessage(0); + break; + case WM_DESTROY: + break; + case WM_SYSCOMMAND: + // prevent screensave or powersave mode + if((wp==SC_SCREENSAVE)||(wp==SC_MONITORPOWER)) + return 0; + goto return_default; + + #if !PRODUCTION + case WM_CHAR: + + if(GetKeyState(VK_SHIFT)<0) + flags|=M_INPLOWEVENT_SHF; + if(GetKeyState(VK_CONTROL)<0) + flags|=M_INPLOWEVENT_CTL; + if(GetKeyState(VK_MENU)<0) + flags|=M_INPLOWEVENT_ALT; + + if(0) + { +wm_key: + if(flags&M_INPLOWEVENT_SHF) + { + if(wp>='a'&&wp<='z') + wp=wp-'a'+'A'; + } + else + { + if(wp>='A'&&wp<='Z') + wp=wp-'A'+'a'; + } + } + + // this does generate an extra event (higher level must sort out) + // if((wp=='s')||(wp=='S')) + // InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN|flags,NUL); + + keys[0]=wp; + keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN|flags,keys); + + break; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + + if(GetKeyState(VK_SHIFT)<0) + flags|=M_INPLOWEVENT_SHF; + if(GetKeyState(VK_CONTROL)<0) + flags|=M_INPLOWEVENT_CTL; + if(GetKeyState(VK_MENU)<0) + flags|=M_INPLOWEVENT_ALT; + switch (wp) + { + case ' ': + if(flags&M_INPLOWEVENT_ALT) + goto wm_key; + break; + case VK_CANCEL: + PostQuitMessage(0); + break; + case VK_LEFT: + InpLowEvent(INPLOWEVENT_P0_L_DOWN,NUL); + break; + case VK_RIGHT: + InpLowEvent(INPLOWEVENT_P0_R_DOWN,NUL); + break; + case VK_UP: + InpLowEvent(INPLOWEVENT_P0_U_DOWN,NUL); + break; + case VK_DOWN: + InpLowEvent(INPLOWEVENT_P0_D_DOWN,NUL); + break; + case VK_NEXT: + InpLowEvent(INPLOWEVENT_P0_D2_DOWN,NUL); + break; + case VK_PRIOR: + InpLowEvent(INPLOWEVENT_P0_U2_DOWN,NUL); + break; + case VK_ESCAPE: + InpLowEvent(INPLOWEVENT_SYS_ESC_DOWN,NUL); + break; + case VK_F1: + case VK_F2: + case VK_F3: + case VK_F4: + case VK_F5: + case VK_F6: + case VK_F7: + case VK_F8: + case VK_F9: + case VK_F10: + case VK_F11: + case VK_F12: + keys[0]=wp-VK_F1+INPKEY_F1; + keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_DOWN,keys); + break; + case VK_SHIFT: + case VK_CONTROL: + case VK_MENU: + // don't generate an inp event + break; + default: + + if(flags&M_INPLOWEVENT_ALT) // otherwise this doesn't generate WM_CHAR + goto wm_key; + + break; + } // switch + break; + case WM_KEYUP: + case WM_SYSKEYUP: + switch (wp) + { + case VK_LEFT: + InpLowEvent(INPLOWEVENT_P0_L_UP,NUL); + break; + case VK_RIGHT: + InpLowEvent(INPLOWEVENT_P0_R_UP,NUL); + break; + case VK_UP: + InpLowEvent(INPLOWEVENT_P0_U_UP,NUL); + break; + case VK_DOWN: + InpLowEvent(INPLOWEVENT_P0_D_UP,NUL); + break; + case VK_NEXT: + InpLowEvent(INPLOWEVENT_P0_D2_UP,NUL); + break; + case VK_PRIOR: + InpLowEvent(INPLOWEVENT_P0_U2_UP,NUL); + break; + case VK_ESCAPE: + InpLowEvent(INPLOWEVENT_SYS_ESC_UP,NUL); + break; + case VK_F1: + case VK_F2: + case VK_F3: + case VK_F4: + case VK_F5: + case VK_F6: + case VK_F7: + case VK_F8: + case VK_F9: + case VK_F10: + case VK_F11: + case VK_F12: + keys[0]=wp-VK_F1+INPKEY_F1; + keys[1]=0; + InpLowEvent(INPLOWEVENT_SYS_KEYS_UP,keys); + break; + case VK_SHIFT: + case VK_CONTROL: + case VK_MENU: + // don't generate an inp event + break; + default: + + if(GetKeyState(VK_SHIFT)<0) + flags|=M_INPLOWEVENT_SHF; + if(GetKeyState(VK_CONTROL)<0) + flags|=M_INPLOWEVENT_CTL; + if(GetKeyState(VK_MENU)<0) + flags|=M_INPLOWEVENT_ALT; + + if(wp>127) + wp-=128; + + if(!(flags&M_INPLOWEVENT_SHF)) + { + if((wp>='A')&&(wp<='Z')) + wp=wp-'A'+'a'; + } + else + { + if((wp>='a')&&(wp<='z')) + wp=wp-'a'+'A'; + } + + + + keys[0]=wp; + keys[1]=0; + + // this does generate an extra event (higher level must sort out) + //if((wp=='s')||(wp=='S')) + + InpLowEvent(INPLOWEVENT_SYS_KEYS_UP|flags,keys); + + break; + } // switch + break; + #endif // !PRODUCTION + + case WM_CAPTURECHANGED: + hwndCapture=NUL; + break; + case WM_LBUTTONDOWN: + InpLowEvent(INPLOWEVENT_MOUSE_LB_DOWN,NUL); + if(!capture++) SetCapture(hwnd),hwndCapture=hwnd; + break; + case WM_LBUTTONUP: + InpLowEvent(INPLOWEVENT_MOUSE_LB_UP,NUL); + if(!--capture) ReleaseCapture(),hwndCapture=NUL; + break; + case WM_RBUTTONDOWN: + InpLowEvent(INPLOWEVENT_MOUSE_RB_DOWN,NUL); + if(!capture++) SetCapture(hwnd),hwndCapture=hwnd; + break; + case WM_RBUTTONUP: + InpLowEvent(INPLOWEVENT_MOUSE_RB_UP,NUL); + if(!--capture) ReleaseCapture(),hwndCapture=NUL; + break; + case WM_MBUTTONDOWN: + InpLowEvent(INPLOWEVENT_MOUSE_CB_DOWN,NUL); + if(!capture++) SetCapture(hwnd),hwndCapture=hwnd; + break; + case WM_MBUTTONUP: + InpLowEvent(INPLOWEVENT_MOUSE_CB_UP,NUL); + if(!--capture) ReleaseCapture(),hwndCapture=NUL; + break; + case WM_MOUSEMOVE: + buf[0] = LOWORD(lp); // client x + buf[1] = HIWORD(lp); // client y + InpLowEvent(INPLOWEVENT_MOUSE_MOVE_XY,buf); + break; + case 0x020A: // WM_MOUSEWHEEL: + buf[0] = HIWORD(wp); // wheel-delta + InpLowEvent(INPLOWEVENT_MOUSE_DELTA_Z,buf); + break; + default: +return_default: + return DefWindowProc(hwnd,msg,wp,lp); + } + return 0; +} // wndProc() + +// JFL 07 Oct 04 +int wndOpenGL(WndRec *wnd,int x,int y,int w,int h) +{ + int ec; + PIXELFORMATDESCRIPTOR pfd; + int format; + + // get the device context (DC) + if(!(wnd->hdc = GetDC(wnd->hwnd))) + err(-1); + + // set the pixel format for the DC + MEMZ(pfd); + pfd.nSize = sizeof( pfd ); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 24; + pfd.cAlphaBits = 8; + pfd.cDepthBits = 24; + pfd.cStencilBits = 8; + pfd.iLayerType = PFD_MAIN_PLANE; + format = ChoosePixelFormat(wnd->hdc, &pfd); + SetPixelFormat(wnd->hdc, format, &pfd); + + // create render context + if(!(wnd->hrc = wglCreateContext(wnd->hdc))) + { + errlog("Couldn't create OpenGL context"); + err(-2); + } + wglMakeCurrent(wnd->hdc,wnd->hrc); + + // + // + // + + wnd->w = w; + wnd->h = h; + glViewport(x,y,w,h); + + // + // DEFAULT STATE VARS + // + + ec=0; +BAIL: + return ec; +} // wndOpenGL() + +// JFL 07 Oct 04 +void wndCloseGL(WndRec *wnd) +{ + wglMakeCurrent( NULL, NULL ); + if(wnd->hrc) + wglDeleteContext( wnd->hrc ); + wnd->hrc=NUL; + if(wnd->hwnd && wnd->hdc) + ReleaseDC(wnd->hwnd,wnd->hdc); + wnd->hdc=NUL; +} // wndCloseGL + +// JFL 23 Mar 05 +int wndFullScreen(uns w,uns h) +{ + DEVMODE dm; + + MEMZ(dm); + dm.dmSize=sizeof(dm); + dm.dmPelsWidth= w; + dm.dmPelsHeight= h; + dm.dmBitsPerPel= 32; + dm.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; + + if(ChangeDisplaySettings(&dm,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) + return -1; + + return 0; +} // wndFullScreen() + +// JFL 23 Mar 05 +int wndCloseScreen(void) +{ + ChangeDisplaySettings(NUL,0); + + return 0; +} // wndCloseScreen() + +// JFL 07 Oct 04 +int WndOpen(memu hinst,uns w,uns h,uns flags) +{ + int ec; + WNDCLASS wc; + WndRec *wnd=&wndlist; + int winl,winr,wint,winb; // windows uses left,right,top,bottom + uns drawStyle; + + // extra menubar etc + winl=0; // jjj -- get these from the system metrics + winr=6; + wint=32; + winb=0; + + drawStyle=WS_OVERLAPPEDWINDOW; + if(flags&1) + { + if((ec=wndFullScreen(w,h))>=0) + { + wnd->fullScreen=1; + drawStyle=WS_POPUP; + winl=0; + winr=0; + wint=0; + winb=0; + } + } + + drawStyle|=WS_CLIPSIBLINGS|WS_CLIPCHILDREN; + + if(!wnd->hinst) + { + wnd->hinst=(void*)hinst; + + // register + wc.style = CS_OWNDC; + wc.lpfnWndProc = wndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = (void*)hinst; + wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); + wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); + wc.lpszMenuName = NUL; + wc.lpszClassName = "CoreClass"; + RegisterClass( &wc ); + + } // hinst + + if(!wnd->hwnd) + { + if(!(wnd->hwnd = CreateWindow("CoreClass", "PlayMechanix", + drawStyle | WS_VISIBLE, + 0,0,w+winl+winr,h+wint+winb, + NULL, NULL, wnd->hinst, NULL ))) + err(ERR_WND_SETUP); + } // hwnd + + // start w/cursor off + ShowCursor(0); + + if((ec=wndOpenGL(wnd,winl,winb,w,h))<0) + goto BAIL; + + FontReset(M_RESET_REBUILD); + wnd->ready=1; + + ec=0; +BAIL: + return ec; +} // WndOpen() + +// JFL 07 Oct 04 +void WndClose(void) +{ + WndRec *wnd=&wndlist; + + wndCloseGL(wnd); + if(wnd->hwnd) + DestroyWindow(wnd->hwnd); + wnd->hwnd=NUL; + wnd->ready=0; + + if(wnd->fullScreen) + { + wndCloseScreen(); + } +} // WndClose + +// JFL 07 Oct 04 +// JFL 25 Jul 05 +int WndInpLoop(void) +{ + MSG msg; + WndRec *wnd=&wndlist; + int ec=0; + + // check for messages + while(PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) + { + // handle or dispatch messages + if ( msg.message == WM_QUIT ) + { + wnd->quit = 1; + ec=-1; + } + else + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + } // while + + return ec; +} // WndInpLoop() + +// JFL 07 Oct 04 +int WndLoop(void) +{ + int ec=0; + WndRec *wnd=&wndlist; + + if(!wnd->ready) + return 1; + + if(SysG.quit) + PostQuitMessage(0); + + if(!VidDisp.showCursor) + { + VidDisp.showCursor=2; // dont-change + ShowCursor(0); + } + else if(VidDisp.showCursor==1) + { + VidDisp.showCursor=2; // dont-change + ShowCursor(1); + } + + return ec; +} // WndLoop() + +// JFL 29 Jan 05 +void WndSwap(WndRec *wnd) +{ + if(!wnd) + wnd=&wndlist; + if(!wnd || !wnd->ready) + return; + #if PRODUCTION + if(SysG.proflags&M_SYSG_PROFLAGS_DONTFLIP) + return; + #endif // PRODUCTION + SwapBuffers(wnd->hdc); +} // WndSwap() + +// JFL 28 Oct 04 +void errlog(char *msg) +{ + #if PRODUCTION + SysLog("ERRLOG: %s\n",msg); + #else // !PRODUCTION + WndRec *wnd=&wndlist; + static dontshow=0; + + if(!dontshow) + { + if(IDCANCEL==MessageBox(wnd->hwnd,msg,"ErrLog",MB_OKCANCEL)) + dontshow=1; + } + #endif // !PRODUCTION +} // errlog() + +#endif // SYS_PC +// EOF \ No newline at end of file diff --git a/dond/linux/makefile b/dond/linux/makefile new file mode 100755 index 0000000..d9b2ebf --- /dev/null +++ b/dond/linux/makefile @@ -0,0 +1,86 @@ +# makefile -- gnu make +# JFL 25 Jan 05 +# JFL 15 Apr 05 +# JFL 31 May 05 + +# idea is to build from the PC directory structure into D1 + +H1=. +D1=./linux/tmp + +S1=./bbh3/core +OBJ1=$(D1)/cab.o $(D1)/cam.o $(D1)/fc.o $(D1)/fs.o $(D1)/ftp.o $(D1)/gun.o \ + $(D1)/inp.o $(D1)/mem.o $(D1)/mem_data.o $(D1)/obj.o $(D1)/proc.o \ + $(D1)/res.o \ + $(D1)/snd.o $(D1)/str.o $(D1)/sys.o $(D1)/vec.o + +S2=./bbh3/corebb +OBJ2=$(D1)/int_bb.o $(D1)/main_bb.o $(D1)/sys_bb.o $(D1)/wnd_bb.o + +S3=./bbh3/coregl +OBJ3=$(D1)/diag_gl.o $(D1)/draw_gl.o $(D1)/fb_gl.o $(D1)/font_gl.o $(D1)/fs_gl.o \ + $(D1)/net_gl.o $(D1)/obj_gl.o $(D1)/res_gl.o $(D1)/vid_gl.o + +S4=./bbh3/game +OBJ4=$(D1)/at.o $(D1)/aud.o $(D1)/bgend.o $(D1)/boars.o $(D1)/bonus.o $(D1)/credits.o \ + $(D1)/crit.o $(D1)/currency.o $(D1)/deer.o \ + $(D1)/diag.o $(D1)/dove.o $(D1)/duck.o $(D1)/edit.o \ + $(D1)/fcfunc.o $(D1)/frog.o $(D1)/game.o $(D1)/gcon.o $(D1)/gears.o $(D1)/gopher.o \ + $(D1)/hclub.o $(D1)/hcstat.o \ + $(D1)/hisc.o $(D1)/initials.o \ + $(D1)/lboard.o $(D1)/logyard.o $(D1)/m.o $(D1)/mars.o $(D1)/moon.o $(D1)/part.o \ + $(D1)/pheasant.o $(D1)/piesky.o $(D1)/player.o $(D1)/plgun.o $(D1)/pmnet.o $(D1)/proj.o \ + $(D1)/quail.o $(D1)/report.o $(D1)/report2p.o $(D1)/sel.o \ + $(D1)/shells.o $(D1)/site.o \ + $(D1)/sitesel.o $(D1)/tapper.o $(D1)/text3d.o $(D1)/tip.o $(D1)/trek.o $(D1)/trny.o \ + $(D1)/turkey.o $(D1)/weather.o $(D1)/windmill.o $(D1)/winner.o +# OBJ4B is a list of game files that should not be added to the game library +# as they are intended to be built by outside groups +OBJ4B=$(D1)/prts_interface.o $(D1)/prts_msg.o $(D1)/prts_utils.o +buildall=$(D1)/game + +CFLAGS=-g -DSYS_BB -DSYS_GL -DDEBUG +#CFLAGS=-DSYS_BB -DSYS_GL -DPRODUCTION +CFLAGS+=-O3 +CFLAGS+=-Wno-sign-compare -Wno-conversion -Wno-missing-prototypes +CFLAGS+=-I $(H1)/bbh3/core -I $(H1)/bbh3/game -I $(H1)/lib +CFLAGS+=-I /usr/X11/include -I /usr/local/include +CC=gcc + +LD=gcc --mode=link +LFLAGS=-L/usr/X11/lib -lGL -lGLU -lglut -lpthread -lrt +LIBS=$(H1)/lib/libjps.a $(H1)/lib/libjamma.a + +# library name for game +TARGETLIB = $(D1)/libgame.a + +$(D1)/game: $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ4B) $(LIBS) + $(LD) $(LFLAGS) $^ -o $@ + cp $(D1)/game . + +$(D1)/%.o : $(S1)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(D1)/%.o : $(S2)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(D1)/%.o : $(S3)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(D1)/%.o : $(S4)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +.PHONY: all clean + +all: $(buildall) + +clean: + rm $(D1)/*.o + + +# lib target makes the game objects an archive +lib: $(TARGETLIB) + +$(TARGETLIB) : $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) + ar rs $(TARGETLIB) $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) + cp $(TARGETLIB) ./lib diff --git a/dond/linux/vssver.scc b/dond/linux/vssver.scc new file mode 100755 index 0000000..4fd7d3e Binary files /dev/null and b/dond/linux/vssver.scc differ diff --git a/donddata/cf/at.cf b/donddata/cf/at.cf new file mode 100644 index 0000000..398ab78 --- /dev/null +++ b/donddata/cf/at.cf @@ -0,0 +1,282 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// + + +seq atcoinp1 ( +alloc(8) +start() +// set(level 3) +// load(atcback) +// add(atcback) +// load(cougar) +// load(atcbanim) +// create(cougar .f=d3 .sk=-) bin(mv 0 0 mv 4 4) +// ban($0 atcbacka fl=loop) +// +// cam(courcam) +) + +seq atcoinp2 ( +alloc(10) +start() + set(level 3) + load(atwback) + add(atwback) + load(wolf) + load(atwbanim) + create(wolf .f=d3 .sk=-) bin(mv 0 0 mv 4 4) + create(wolf .f=d3 .sk=-) bin(mv 5 0 mv 9 4) + ban($0 atwback1 fl=loop) + ban($5 atwback2 fl=loop) + + cam(wolfcam) +) + +seq atcoinp3 ( +alloc(8) +start() + +// set(level 3) + load(atbback) + load(bear) + load(atbbanim) + add(atbback) + create(bear .f=d3 .sk=-) bin(mv 0 0 mv 4 4) + ban($0 atbbacka fl=loop) + + cam(bearcam) +) + + +seq atpmlogo ( +alloc(4) +start() + set(tag 1) // set tag + load(pmlogo) + mark(cam3) + create(pmlogo.pmlogo .f=d2 .lb) + cam(atcam) +) // atpmlogo + +seq ath2haction ( +alloc(4) +start() + set(tag 1) // set tag + load(h2haction) + mark(cam2d) + create(h2haction .f=d2 .la) + cam(atcam) +) + +seq ath2haction2 ( +alloc(4) +start() + set(tag 1) // set tag + load(h2haction2) + mark(cam2d) + create(h2haction2 .f=d2 .la) + cam(atcam) +) + + + +seq atrtlogo ( +alloc(4) +start() + set(tag 1) // set tag + load(rawthrills) + mark(cam3) + create(rawthrills.raw .f=d2 .lb) + cam(selcam) +) // rawthrills + + +seq atTitle ( +alloc(4) +start() + set(tag 1) // set tag + load(title) + mark(cam3) + create(title.title .f=d2 .lb) + cam(atcam) +) // atTitle + + +seq credBG( + alloc(8) + start() + load(deerrack) + add(deerrack) + + load(whitetail) + load(whitetailbbuck) + load(whitetaildoe) + load(deeranim) + run(deer) + + create(whitetail .f=d3 .sk=- .sh=-) + bin(mv 0 0 mv 4 4) + ban($0 deerrack1 fl=loop) + obj(ob=$4 fl=gcol,loop,primekill rm=0.01) + + create(whitetailbuck .f=d3 .sk=- .sh=-) + bin(mv 0 0 mv 4 4) + ban($0 dbuckrack fl=loop) + obj(ob=$4 fl=gcol,loop,primekill rm=0.01) + + create(whitetaildoe .f=d3 .sk=- .sh=-) + bin(mv 0 0 mv 4 4) + ban($0 doerack1 fl=loop) + obj(ob=$4 fl=gcol,loop,primekill rm=0.01) + + create(whitetaildoe .f=d3 .sk=- .sh=-) + bin(mv 0 0 mv 4 4) + ban($0 doerack2 fl=loop) + obj(ob=$4 fl=gcol,loop,primekill rm=0.01) + + cam(deerrack) + +) // credBG + + +seq creditSeq ( + alloc(8) + start() + + ani(- credBG) + + mark(cam3) + + ani(- creditRollerSeq) + + fc(fcCreditShow 0 32 0 0) + + sleep(120) + fc(fcCreditShow 1 32 0 0) + + sleep(120) + fc(fcCreditShow 2 32 0 0) + sleep(140) + + // ex prod + fc(fcCreditShow 17 32 0 0) + fc(fcCreditShow 18 32 -6 0) + sleep(150) + + //programmers + fc(fcCreditShow 3 32 0 0) + fc(fcCreditShow 4 32 -6 0) + sleep(300) + + //artists + fc(fcCreditShow 5 32 0 0) + fc(fcCreditShow 6 32 -6 0) + sleep(330) + + //big rob + fc(fcCreditShow 7 32 0 0) + fc(fcCreditShow 8 32 -6 0) + sleep(150) + + //sound + fc(fcCreditShow 9 32 0 0) + fc(fcCreditShow 10 32 -6 0) + sleep(210) + + //prod + fc(fcCreditShow 19 32 0 1) + fc(fcCreditShow 20 32 -6 1) + sleep(180) + + //mechanical design + fc(fcCreditShow 21 32 0 1) + fc(fcCreditShow 22 32 -6 1) + sleep(180) + + fc(fcCreditKill 0) + + //cabinet art + fc(fcCreditShow 23 32 0 1) + fc(fcCreditShow 24 32 -6 1) + sleep(180) + + //engineering + fc(fcCreditShow 25 32 0 1) + fc(fcCreditShow 26 32 -6 1) + sleep(260) + + //promotional art + fc(fcCreditShow 27 32 0 1) + fc(fcCreditShow 28 32 -6 1) + sleep(160) + + //prod/qual + fc(fcCreditShow 29 32 0 1) + fc(fcCreditShow 30 32 -6 1) + sleep(160) + + //testers + fc(fcCreditShow 31 32 0 1) + fc(fcCreditShow 32 32 -6 1) + sleep(119) + fc(fcCreditShow 33 32 -6 1) + sleep(230) + + //bb girls + fc(fcCreditShow 34 32 0 2) + fc(fcCreditShow 35 32 -6 2) + sleep(210) + + //special thanks + fc(fcCreditShow 11 32 0 2) + fc(fcCreditShow 12 32 -6 2) + sleep(80) +// fc(fcCreditShow 13 32 -6 2) + sleep(140) + + fc(fcCreditKill 1) + + //special thanks RT + fc(fcCreditShow 36 32 0 2) + fc(fcCreditShow 37 16 -6 2) + fc(fcCreditShow 40 48 -6 2) + sleep(82) + + fc(fcCreditShow 38 16 -6 2) + fc(fcCreditShow 41 48 -6 2) + sleep(82) + + fc(fcCreditShow 39 16 -6 2) + fc(fcCreditShow 42 48 -6 2) + sleep(210) + + //families + fc(fcCreditShow 14 32 0 2) + fc(fcCreditShow 15 16 -6 2) + fc(fcCreditShow 16 48 -6 2) + sleep(270) + + //made in USA + fc(fcCreditShow 43 32 -6 2) + sleep(80) + fc(fcCreditShow 44 32 -6 2) + + + sleep(500) + fc(fcCredDone) + +) + +seq creditRollerSeq ( + alloc(8) + start() + +credLoop: + sloop(1) + fc(fcCreditRoll) + br(credLoop) + +) + + +// EOF \ No newline at end of file diff --git a/donddata/cf/attract.cf b/donddata/cf/attract.cf new file mode 100644 index 0000000..3074974 --- /dev/null +++ b/donddata/cf/attract.cf @@ -0,0 +1,737 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +// --------------------------------------------- + +seq sAtrLEDAnim ( + + start() + +loop: + fc(fcDondSetLampWrite 15 0) + fc(fcDondSetLampWrite 0 1) + sleep(5) + fc(fcDondSetLampWrite 0 0) + fc(fcDondSetLampWrite 1 1) + sleep(5) + fc(fcDondSetLampWrite 1 0) + fc(fcDondSetLampWrite 2 1) + sleep(5) + fc(fcDondSetLampWrite 2 0) + fc(fcDondSetLampWrite 3 1) + sleep(5) + fc(fcDondSetLampWrite 3 0) + fc(fcDondSetLampWrite 4 1) + sleep(5) + fc(fcDondSetLampWrite 4 0) + fc(fcDondSetLampWrite 5 1) + sleep(5) + fc(fcDondSetLampWrite 5 0) + fc(fcDondSetLampWrite 6 1) + sleep(5) + fc(fcDondSetLampWrite 6 0) + fc(fcDondSetLampWrite 7 1) + sleep(5) + fc(fcDondSetLampWrite 7 0) + fc(fcDondSetLampWrite 8 1) + sleep(5) + fc(fcDondSetLampWrite 8 0) + fc(fcDondSetLampWrite 9 1) + sleep(5) + fc(fcDondSetLampWrite 9 0) + fc(fcDondSetLampWrite 10 1) + sleep(5) + fc(fcDondSetLampWrite 10 0) + fc(fcDondSetLampWrite 11 1) + sleep(5) + fc(fcDondSetLampWrite 11 0) + fc(fcDondSetLampWrite 12 1) + sleep(5) + fc(fcDondSetLampWrite 12 0) + fc(fcDondSetLampWrite 13 1) + sleep(5) + fc(fcDondSetLampWrite 13 0) + fc(fcDondSetLampWrite 14 1) + sleep(5) + fc(fcDondSetLampWrite 14 0) + fc(fcDondSetLampWrite 15 1) + sleep(5) + + fc(fcDondSetLampWrite 14 1) sleep(5) + fc(fcDondSetLampWrite 13 1) sleep(5) + fc(fcDondSetLampWrite 12 1) sleep(5) + fc(fcDondSetLampWrite 11 1) sleep(5) + fc(fcDondSetLampWrite 10 1) sleep(5) + fc(fcDondSetLampWrite 9 1) sleep(5) + fc(fcDondSetLampWrite 8 1) sleep(5) + fc(fcDondSetLampWrite 7 1) sleep(5) + fc(fcDondSetLampWrite 6 1) sleep(5) + fc(fcDondSetLampWrite 5 1) sleep(5) + fc(fcDondSetLampWrite 4 1) sleep(5) + fc(fcDondSetLampWrite 3 1) sleep(5) + fc(fcDondSetLampWrite 2 1) sleep(5) + fc(fcDondSetLampWrite 1 1) sleep(5) + fc(fcDondSetLampWrite 0 1) sleep(5) + + fc(fcDondSetLampWrite 15 0) sleep(5) + fc(fcDondSetLampWrite 14 0) sleep(5) + fc(fcDondSetLampWrite 13 0) sleep(5) + fc(fcDondSetLampWrite 12 0) sleep(5) + fc(fcDondSetLampWrite 11 0) sleep(5) + fc(fcDondSetLampWrite 10 0) sleep(5) + fc(fcDondSetLampWrite 9 0) sleep(5) + fc(fcDondSetLampWrite 8 0) sleep(5) + fc(fcDondSetLampWrite 7 0) sleep(5) + fc(fcDondSetLampWrite 6 0) sleep(5) + fc(fcDondSetLampWrite 5 0) sleep(5) + fc(fcDondSetLampWrite 4 0) sleep(5) + fc(fcDondSetLampWrite 3 0) sleep(5) + fc(fcDondSetLampWrite 2 0) sleep(5) + fc(fcDondSetLampWrite 1 0) sleep(5) + fc(fcDondSetLampWrite 0 0) sleep(5) + + br(loop) +) + +// --------------------------------------------- + +seq sAtrLEDOff ( + + start() + + fc(fcDondSetLamp 15 1) fc(fcDondSetLampWrite 15 0) + fc(fcDondSetLamp 14 1) fc(fcDondSetLampWrite 14 0) + fc(fcDondSetLamp 13 1) fc(fcDondSetLampWrite 13 0) + fc(fcDondSetLamp 12 1) fc(fcDondSetLampWrite 12 0) + fc(fcDondSetLamp 11 1) fc(fcDondSetLampWrite 11 0) + fc(fcDondSetLamp 10 1) fc(fcDondSetLampWrite 10 0) + fc(fcDondSetLamp 9 1) fc(fcDondSetLampWrite 9 0) + fc(fcDondSetLamp 8 1) fc(fcDondSetLampWrite 8 0) + fc(fcDondSetLamp 7 1) fc(fcDondSetLampWrite 7 0) + fc(fcDondSetLamp 6 1) fc(fcDondSetLampWrite 6 0) + fc(fcDondSetLamp 5 1) fc(fcDondSetLampWrite 5 0) + fc(fcDondSetLamp 4 1) fc(fcDondSetLampWrite 4 0) + fc(fcDondSetLamp 3 1) fc(fcDondSetLampWrite 3 0) + fc(fcDondSetLamp 2 1) fc(fcDondSetLampWrite 2 0) + fc(fcDondSetLamp 1 1) fc(fcDondSetLampWrite 1 0) + fc(fcDondSetLamp 0 1) fc(fcDondSetLampWrite 0 0) +) + +// --------------------------------------------- + +seq sAttractStart ( + +alloc(8) + start() + + fc(fcDondAskAtrMode $7) + + mark(fntA) + + //fc(fcDondAnimLED 4) + +restart: + + // - stop any previous music + + sound(99) + + vidstop(bgVideo) + kill(bgVideo) + + br(.t $7 startGirls startVideo startGirls startVideo startGirls startVideo startGirls startVideo) + +startGirls: + + ani(- sAtrLEDAnim) + + create(bgVideo .f=d2 .lb) + vidplay(bgVideo 0) // - 0 = don't ignore clock + + // - turn off the "demo mode" text + + fc(fcDondAttractText 0) + + sloop(1) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound1) + sound(52) +skipSound1: + + mark(fntA) + kill(models_start) + create(models_start .f=d2 .lb .v .s=sPrompt) + bin(mv 4 0) send($4 6) + + mark(fntA) + kill(title_page) + create(title_page .f=d2 .lb .v .s=sPrompt) + bin(mv 5 0) send($5 5) + + sleep(600) + + send($4 2) + send($5 2) + + mark(fntA) + kill(ice_logo) + create(ice_logo .f=d2 .lb .v .s=sPrompt) + bin(mv 4 0) send($4 5) + sleep(1) + + mark(fntA) + kill(pm_logo1) + create(pm_logo1 .f=d2 .lb .v .s=sPrompt) + bin(mv 5 0) send($5 5) + + sleep(300) + + send($4 2) + send($5 2) + + br(end) + + // - play the title video + +startVideo: + + fc(fcDondAnimLED 4) + + vidstop(bgVideo) + vidreset(bgVideo) + + create(titleVideo .f=d2 .lb) + vidplay(titleVideo 0) + viddone(titleVideo sAtrVidDone) + + // - turn on the "demo mode" text + + fc(fcDondAttractText 1) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound2) + sound(2) + sound(373) +skipSound2: + + sleep(290) + + br(.t $7 end startReveal end startBanker end startReveal end startBanker) + + // - show the wide scene + +startReveal: + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound3) + sound(1) +skipSound3: + + vidstop(bgVideo) + kill(bgVideo) + + ani(- fakeMainScene) + fc(fcDondFadeOut titleVideo) + // - "now choose 5 cases" + + sleep(40) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound4) + sound(302) +skipSound4: + + sleep(50) + ani(- startWideAnim) + sleep(210) + + // - play a case reveal scene + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound5) + sound(200) // - polite applause + sound(11) // - case open build-up sound +skipSound5: + + ani(- stopWideAnim) + fc(fcDondPlayGradedReveal) + fc(fcDondAskGradedReveal $0) + + sleep(30) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound8) + fc(fcDondPlayCaseOpenVocal 0) +skipSound8: + +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame * $1 $0) // $1 = video frame of object named "*" + br(.z $1 revealLoop) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound9) + fc(fcDondPlayGradedAudio) +skipSound9: + + bin(si 0 100) // <- $0 = 100 +scaleLoop: + sleep(1) + fc(fcDondDrawCaseValue $0 52.0 18.0) // <- shrinkRate, xpos, ypos + bin(ai 0 -10) // <- $0 = $0 - 10; + br(.n $0 scaleLoop) // <- if ($0 != 0) goto scaleLoop + + // - create the "ticket" label + + fc(fcDondAskForFun $0) + br(.n $0 noLabel) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + create(c_ticket .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) + br(prizeDone) +coupons: + create(c_coupon .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) +prizeDone: + obj(ob=$2 xq=52.0) + obj(ob=$2 yq=17.0) +noLabel: + + sleep(10) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound10) + fc(fcDondPlayGradedCrowdAudio) +skipSound10: + + fc(fcDondRedrawValues) + + sleep(40) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound11) + fc(fcDondPlayCaseOpenVocal 1) +skipSound11: + + sleep(240) + + fc(fcDondFadeKillReveal) + kill($2) + fc(fcDondCaseRevealDone) + fc(fcDondFadeOut bg_tight) + + kill(background) + kill(model_*) + kill(case_*) + kill(shadow_*) + kill(tick*) + kill(coup*) + + br(end) + + // ... + +startBanker: + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound6) + sound(1) +skipSound6: + + vidstop(bgVideo) + vidreset(bgVideo) + kill(bgVideo) + + fc(fcDondFadeOut titleVideo) + + ani(- fakeBankScene) + sleep(700) + + vidstop(bank_anim) vidstop(bank2_anim) + fc(fcDondUpdateBankerText 0) + kill(bank*) + kill(tick*) + kill(coup*) + kill(offer*) + kill(banker*) + kill(bg_*) + kill(back*) + kill(bckgrnd*) + kill(bank_tix) + kill(pr*) + kill(deal) + kill(nodeal) + + // .... + + br(end) + +end: + + //kill(createInitScene .t=seq) + //ani(- createInitScene) + fc(fcDondSetGameState 99) + fc(fcDondAttractText 0) +) + +// --------------------------------------------- + +seq sAtrVidDone ( + start() + vidstop(titleVideo) +) + +// --------------------------------------------- + +seq sAtrGirlDone ( + start() + vidstop(mr_bad_10) +) + +// --------------------------------------------- + +seq sAtrCleanup ( + + start() + + fc(fcDondUnloadVideos) + kill(*) + kill(fakeMainScene .t=seq) + kill(fakeBankScene .t=seq) + kill(sATBankerRv .t=seq) +) + +// --------------------------------------------- +// fakeMainScene + +seq fakeMainScene ( + +alloc(4) + start() + + mark(bgmrk) + + kill(model_*) + + // - we don't want any object duplicates laying + // around, so we delete everything before creating + + kill(background) create(background .f=d2 .lb .v .s=bgAnim) + + // - the models are created in reverse order in order + // to get correct layering. + + kill(model_016) create(model_016 .f=d2 .lb) + kill(case_016) create(case_016 .f=d2 .lb) + + kill(model_015) create(model_015 .f=d2 .lb) + kill(case_015) create(case_015 .f=d2 .lb) + + kill(model_014) create(model_014 .f=d2 .lb) + kill(case_014) create(case_014 .f=d2 .lb) + + kill(model_013) create(model_013 .f=d2 .lb) + kill(case_013) create(case_013 .f=d2 .lb) + + kill(shadow_012) create(shadow_012 .f=d2 .lb) + kill(model_012) create(model_012 .f=d2 .lb) + kill(case_012) create(case_012 .f=d2 .lb) + + kill(shadow_011) create(shadow_011 .f=d2 .lb) + kill(model_011) create(model_011 .f=d2 .lb) + kill(case_011) create(case_011 .f=d2 .lb) + + kill(shadow_010) create(shadow_010 .f=d2 .lb) + kill(model_010) create(model_010 .f=d2 .lb) + kill(case_010) create(case_010 .f=d2 .lb) + + kill(shadow_09) create(shadow_09 .f=d2 .lb) + kill(model_09) create(model_09 .f=d2 .lb) + kill(case_09) create(case_09 .f=d2 .lb) + + kill(shadow_08) create(shadow_08 .f=d2 .lb) + kill(model_08) create(model_08 .f=d2 .lb) + kill(case_08) create(case_08 .f=d2 .lb) + + kill(shadow_07) create(shadow_07 .f=d2 .lb) + kill(model_07) create(model_07 .f=d2 .lb) + kill(case_07) create(case_07 .f=d2 .lb) + + kill(shadow_06) create(shadow_06 .f=d2 .lb) + kill(model_06) create(model_06 .f=d2 .lb) + kill(case_06) create(case_06 .f=d2 .lb) + + kill(shadow_05) create(shadow_05 .f=d2 .lb) + kill(model_05) create(model_05 .f=d2 .lb) + kill(case_05) create(case_05 .f=d2 .lb) + + kill(shadow_04) create(shadow_04 .f=d2 .lb) + kill(model_04) create(model_04 .f=d2 .lb) + kill(case_04) create(case_04 .f=d2 .lb) + + kill(shadow_03) create(shadow_03 .f=d2 .lb) + kill(model_03) create(model_03 .f=d2 .lb) + kill(case_03) create(case_03 .f=d2 .lb) + + kill(shadow_02) create(shadow_02 .f=d2 .lb) + kill(model_02) create(model_02 .f=d2 .lb) + kill(case_02) create(case_02 .f=d2 .lb) + + kill(shadow_01) create(shadow_01 .f=d2 .lb) + kill(model_01) create(model_01 .f=d2 .lb) + kill(case_01) create(case_01 .f=d2 .lb) + + kill(tick_001) create(tick_001 .f=d2 .la .v .s=barAnim) + kill(tick_002) create(tick_002 .f=d2 .la .v .s=barAnim) + kill(tick_003) create(tick_003 .f=d2 .la .v .s=barAnim) + kill(tick_004) create(tick_004 .f=d2 .la .v .s=barAnim) + kill(tick_005) create(tick_005 .f=d2 .la .v .s=barAnim) + kill(tick_006) create(tick_006 .f=d2 .la .v .s=barAnim) + kill(tick_007) create(tick_007 .f=d2 .la .v .s=barAnim) + kill(tick_008) create(tick_008 .f=d2 .la .v .s=barAnim) + kill(tick_009) create(tick_009 .f=d2 .la .v .s=barAnim) + kill(tick_0010) create(tick_0010 .f=d2 .la .v .s=barAnim) + kill(tick_0011) create(tick_0011 .f=d2 .la .v .s=barAnim) + kill(tick_0012) create(tick_0012 .f=d2 .la .v .s=barAnim) + kill(tick_0013) create(tick_0013 .f=d2 .la .v .s=barAnim) + kill(tick_0014) create(tick_0014 .f=d2 .la .v .s=barAnim) + kill(tick_0015) create(tick_0015 .f=d2 .la .v .s=barAnim) + kill(tick_0016) create(tick_0016 .f=d2 .la .v .s=barAnim) + + kill(tick_unlit_001) create(tick_unlit_001 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_002) create(tick_unlit_002 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_003) create(tick_unlit_003 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_004) create(tick_unlit_004 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_005) create(tick_unlit_005 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_006) create(tick_unlit_006 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_007) create(tick_unlit_007 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_008) create(tick_unlit_008 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_009) create(tick_unlit_009 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0010) create(tick_unlit_0010 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0011) create(tick_unlit_0011 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0012) create(tick_unlit_0012 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0013) create(tick_unlit_0013 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0014) create(tick_unlit_0014 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0015) create(tick_unlit_0015 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0016) create(tick_unlit_0016 .f=d2 .la .v .s=barAnim) + + fc(fcDondAskForFun $0) + br(.n $0 prizeDone) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + + kill(ticket_sign*) + create(ticket_signL .f=d2 .la .v .s=barAnim) + create(ticket_signR .f=d2 .la .v .s=barAnim) + br(prizeDone) + +coupons: + + kill(coup_sign*) + create(coup_signL .f=d2 .la .v .s=barAnim) + create(coup_signR .f=d2 .la .v .s=barAnim) + +prizeDone: + + ani(- startWideAnim) + sleep(1) + ani(- stopWideAnim) +) + +// --------------------------------------------- +// fakeBankScene + +seq fakeBankScene ( + +alloc(8) + start() + + //set(level 3) + //load(banker) + //set(level 2) + + mark(bgmrk) + + kill(tick_001) create(tick_001 .f=d2 .la .v .s=barAnim) + kill(tick_002) create(tick_002 .f=d2 .la .v .s=barAnim) + kill(tick_003) create(tick_003 .f=d2 .la .v .s=barAnim) + kill(tick_004) create(tick_004 .f=d2 .la .v .s=barAnim) + kill(tick_005) create(tick_005 .f=d2 .la .v .s=barAnim) + kill(tick_006) create(tick_006 .f=d2 .la .v .s=barAnim) + kill(tick_007) create(tick_007 .f=d2 .la .v .s=barAnim) + kill(tick_008) create(tick_008 .f=d2 .la .v .s=barAnim) + kill(tick_009) create(tick_009 .f=d2 .la .v .s=barAnim) + kill(tick_0010) create(tick_0010 .f=d2 .la .v .s=barAnim) + kill(tick_0011) create(tick_0011 .f=d2 .la .v .s=barAnim) + kill(tick_0012) create(tick_0012 .f=d2 .la .v .s=barAnim) + kill(tick_0013) create(tick_0013 .f=d2 .la .v .s=barAnim) + kill(tick_0014) create(tick_0014 .f=d2 .la .v .s=barAnim) + kill(tick_0015) create(tick_0015 .f=d2 .la .v .s=barAnim) + kill(tick_0016) create(tick_0016 .f=d2 .la .v .s=barAnim) + + kill(tick_unlit_001) create(tick_unlit_001 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_002) create(tick_unlit_002 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_003) create(tick_unlit_003 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_004) create(tick_unlit_004 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_005) create(tick_unlit_005 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_006) create(tick_unlit_006 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_007) create(tick_unlit_007 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_008) create(tick_unlit_008 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_009) create(tick_unlit_009 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0010) create(tick_unlit_0010 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0011) create(tick_unlit_0011 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0012) create(tick_unlit_0012 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0013) create(tick_unlit_0013 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0014) create(tick_unlit_0014 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0015) create(tick_unlit_0015 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0016) create(tick_unlit_0016 .f=d2 .la .v .s=barAnim) + + fc(fcDondAskForFun $0) + br(.n $0 prizeDone) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + + kill(ticket_sign*) + create(ticket_signL .f=d2 .la .v .s=barAnim) + create(ticket_signR .f=d2 .la .v .s=barAnim) + br(prizeDone) + +coupons: + + kill(coup_sign*) + create(coup_signL .f=d2 .la .v .s=barAnim) + create(coup_signR .f=d2 .la .v .s=barAnim) + +prizeDone: + + mark(bgmrk) + + create(bank_anim .f=d2 .la) + create(bank2_anim .f=d2 .la) + + create(offer_frame .f=d2 .la) + create(banker_offer1 .f=d2 .la .v .s=bgAnim) + + create(bg_banker_w1 .f=d2 .la .v .s=sBankerBg) + bin(mv 2 0) send($2 2) + + create(bg_banker_w2 .f=d2 .la .v .s=sBankerBg) + bin(mv 2 0) send($2 2) + + create(bg_banker_drk .f=d2 .la .v .s=sBankerBg) + bin(mv 2 0) send($2 2) // <- turn off the dark red background + + create(background_blue .f=d2 .la .v .s=sBankerBg) + create(bckgrnd_bnk .f=d2 .la) + + vidplay(bank_anim) + viddone(bank_anim onBankVidDone) + + // - phone rings + + sleep(10) + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound1) + sound(14) +skipSound1: + + sleep(50) + fc(fcDondSend background_blue 0) + + // - fade the cabinet lights from blue to red + + fc(fcDondAnimLED 1) // <- fade blue out + fc(fcDondAnimLED 2) // <- fade red in + + // - "that's the banker" + + sleep(-tap 60) + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound2) + sound(350) +skipSound2: + + // - begin strobing the background + + send($2 1) + + // - "hello" + + sleep(-tap 85) + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound3) + sound(351) +skipSound3: + + // - "alright" / "i'll tell them" + + sleep(-tap 90) + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound4) + sound(356) +skipSound4: + + // - "here's the offer" + + sleep(-tap 60) + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound5) + sound(352) +skipSound5: + + kill(offer_frame) + create(offer_rotate .f=d2 .lb) + vidplay(offer_rotate 1) + viddone(offer_rotate sATBankerRv) + + // - offer rotate sound + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound6) + sound(5) +skipSound6: +) + +// --------------------------------------------- +// sBankerRv +// +// - the banker reveals his offer to the player + +seq sATBankerRv ( + +alloc(8) + + start() + + vidstop(offer_rotate) + + fc(fcDondUpdateBankerText 1) + + fc(fcDondAskForFun $0) + br(.n $0 prizeDone) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + create(bank_tix .f=d2 .lb) + br(prizeDone) +coupons: + create(bank_coup .f=d2 .lb) +prizeDone: + + create(press_accept .f=d2 .lb) + create(prss_accpt_l .f=d2 .lb .v .s=sSelectButton) + + create(press_continue .f=d2 .lb) + create(prss_cntn_ .f=d2 .lb .v .s=sSelectButton) + + create(deal .f=d2 .lb) + create(nodeal .f=d2 .lb) + + // - "deal, or no deal?" + + sleep(50) + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound1) + sound(353) +skipSound1: +) + diff --git a/donddata/cf/banker.cf b/donddata/cf/banker.cf new file mode 100644 index 0000000..0a51d0e --- /dev/null +++ b/donddata/cf/banker.cf @@ -0,0 +1,1092 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +// --------------------------------------------- +// sBanker + +seq sBanker ( + +alloc(4) + start() + + fc(fcDondInput 0) + + //set(level 3) + //load(banker) + //set(level 2) + + ani(- stopWideAnim) + fc(fcDondUnloadVideos) + + mark(bgmrk) + +// create(bank_anim .f=d2 .la) +// create(bank2_anim .f=d2 .la) +// +// create(offer_frame .f=d2 .la) +// create(banker_offer1 .f=d2 .la .v .s=bgAnim) +// +// create(bg_banker_w1 .f=d2 .la .v .s=sBankerBg) +// bin(mv 2 0) send($2 2) +// +// create(bg_banker_w2 .f=d2 .la .v .s=sBankerBg) +// bin(mv 2 0) send($2 2) +// +// create(bg_banker_drk .f=d2 .la .v .s=sBankerBg) +// bin(mv 2 0) send($2 2) // <- turn off the dark red background +// +// create(background_blue .f=d2 .la .v .s=sBankerBg) +// create(bckgrnd_bnk .f=d2 .la) + + kill(background_blue) + + create(bckgrnd_bnk .f=d2 .lb) + create(background_blue .f=d2 .lb .v .s=sBankerBg) + create(bg_banker_drk .f=d2 .lb .v .s=sBankerBg) bin(mv 3 0) send($3 2) + create(bg_banker_w2 .f=d2 .lb .v .s=sBankerBg) bin(mv 2 0) send($2 2) + create(bg_banker_w1 .f=d2 .lb .v .s=sBankerBg) bin(mv 2 0) send($2 2) + create(banker_offer1 .f=d2 .lb .v .s=bgAnim) + create(offer_frame .f=d2 .lb) + create(bank2_anim .f=d2 .lb) + create(bank_anim .f=d2 .lb) + + vidplay(bank_anim) + viddone(bank_anim onBankVidDone) + + // - turn on the banker light + + fc(fcDondSetLamp 16 1) + + // - turn off our main background image + + sleep(10) + fc(fcDondSend background 2) + + // - phone rings + + sleep(10) + sound(14) + + sleep(50) + + // - remove the blue background + + fc(fcDondSend background_blue 0) + + // - fade the cabinet lights from blue to red + + fc(fcDondAnimLED 1) // <- fade blue out + fc(fcDondAnimLED 2) // <- fade red in + + // - "that's the banker" + + sleep(-tap 60) + sound(350) + + // - begin strobing the background + + //send($2 1) + send($3 1) + + // - "hello" + + sleep(-tap 85) + sound(351) + + // - "alright" / "i'll tell them" + + sleep(-tap 90) + sound(356) + + // - "here's the offer" + + sleep(-tap 60) + sound(352) + + // - pause a bit before the offer panel begins + // to rotate + + sleep(-tap 50) + + ani(- stopWideAnim) + + kill(offer_frame) + create(offer_rotate .f=d2 .lb) + vidplay(offer_rotate 1) + viddone(offer_rotate sBankerRv) + + // - play the "offer reveal" sound + + sound(5) +) + +// --------------------------------------------- +// sBankerAF - banker sequence after the final +// reveal + +seq sBankerAF ( + +alloc(4) + start() + + ani(- stopWideAnim) + + mark(bgmrk) + + create(offer_frame .f=d2 .la) + + create(bg_banker_w1 .f=d2 .la .v .s=sBankerBg) + bin(mv 2 0) send($2 2) + + create(bg_banker_w2 .f=d2 .la .v .s=sBankerBg) + bin(mv 2 0) send($2 2) + + create(background_blue .f=d2 .la .v .s=sBankerBg) +) + +// --------------------------------------------- + +seq onBankVidDone ( + + start() + vidstop(bank_anim) + //kill(bank_anim) + fc(fcDondFadeOut bank_anim) + vidplay(bank2_anim) +) + +// --------------------------------------------- + +seq sBankerBg ( + +alloc(4) +signals(5) +signal(0 - fadeOut - ) +signal(1 - strobe - ) +signal(2 - turnOff - ) +signal(3 - flash - ) +signal(4 - turnOn - ) + + start() + +wait: + sleep(0) + +// <---- signal 0 +fadeOut: + + bin(si 0 16) + +fadeOutLoop: + sleep(1) + fc(fcBlend -16 1) + bin(ai 0 -1) + br(.n $0 fadeOutLoop) + fc(fcBlend 0 0) + + //find(l prime -) bin(mv 0 0) + //kill($0) + + br(wait) + +// <---- signal 1 +strobe: + + fc(fcBlend 0 0) + bin(si 0 85) + +strobeUpLoop: + sleep(1) + fc(fcBlend 3 1) + bin(ai 0 -1) + br(.n $0 strobeUpLoop) + + fc(fcBlend 255 0) + bin(si 0 85) + +strobeDownLoop: + sleep(1) + fc(fcBlend -3 1) + bin(ai 0 -1) + br(.n $0 strobeDownLoop) + + br(strobe) + +// <---- signal 2 +turnOff: + fc(fcBlend 0 0) + br(wait) + +// <---- signal 3 +flash: + fc(fcBlend 255 0) + + //bin(si 0 60) + bin(si 0 120) +flashLoop: + sleep(2) + obj(on) sleep(2) obj(of) + bin(ai 0 -1) + br(.n $0 flashLoop) + obj(of) + br(wait) + +// <---- signal 4 +turnOn: + obj(on) + fc(fcBlend 255 0) + br(wait) +) + +// --------------------------------------------- +// sBankerRv +// +// - the banker reveals his offer to the player + +seq sBankerRv ( + +alloc(4) + + start() + + vidstop(offer_rotate) + + fc(fcDondUpdateBankerText 1) + sleep(2) + fc(fcDondUpdateBankerText 0) + sleep(2) + fc(fcDondUpdateBankerText 1) + sleep(2) + fc(fcDondUpdateBankerText 0) + sleep(2) + fc(fcDondUpdateBankerText 1) + + fc(fcDondAskForFun $0) + br(.n $0 prizeDone) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + create(bank_tix .f=d2 .lb) + br(prizeDone) +coupons: + create(bank_coup .f=d2 .lb) +prizeDone: + + create(press_accept .f=d2 .lb) + create(prss_accpt_l .f=d2 .lb .v .s=sSelectButton) + + create(press_continue .f=d2 .lb) + create(prss_cntn_ .f=d2 .lb .v .s=sSelectButton) + + create(deal .f=d2 .lb) + create(nodeal .f=d2 .lb) + + ani(- sPOfferReveal) + + ani(- sBankerLED) + + // - "deal, or no deal?" + + sleep(20) + sound(353) + + // - this extra wait time was added to fix the a bug + // in the 1.00.00 release version. it was possible + // to make a "Deal" or "No Deal" input too fast. + // the total sleep time after sPOfferReveal is set + // to 41 because it takes 40 ticks for the previous + // offer animation to stop animating. + + sleep(21) + fc(fcDondInput 1) + + // - the final bit of this sequence is placed in + // it's own part because the user might make an + // input before it would be appropriate for the crowd + // to start reacting. this sequence could then + // be killed off early. + + ani(- sBankerRvF) +) + +// --------------------------------------------- +// - this animation alternately flashes the deal +// and no deal buttons until it is killed + +seq sBankerLED ( + + start() + +begin: + fc(fcDondSetLamp 21 1) + fc(fcDondSetLamp 22 0) + sleep(60) + fc(fcDondSetLamp 21 0) + fc(fcDondSetLamp 22 1) + sleep(60) + br(begin) +) + +// --------------------------------------------- + +seq sChoiceLED ( + +alloc(4) + start() + kill(sBankerLED .t=seq) + + bin(si 0 60) +ledLoop: + sleep(2) + fc(fcDondSetLamp 21 1) + fc(fcDondSetLamp 22 1) + sleep(2) + fc(fcDondSetLamp 21 0) + fc(fcDondSetLamp 22 0) + bin(ai 0 -1) + br(.n $0 ledLoop) +) + +// --------------------------------------------- +// - this sequence flashes the NO DEAL lamp + +seq sNoDealLED ( + +alloc(4) + start() + kill(sBankerLED .t=seq) + + // - turn off the DEAL lamp + + fc(fcDondSetLamp 21 0) + + bin(si 0 60) +ledLoop: + sleep(2) + fc(fcDondSetLamp 22 1) + sleep(2) + fc(fcDondSetLamp 22 0) + bin(ai 0 -1) + br(.n $0 ledLoop) +) + +// --------------------------------------------- +// - this sequence flashes the DEAL lamp + +seq sDealLED ( + +alloc(4) + start() + kill(sBankerLED .t=seq) + + // - turn off the NO DEAL lamp + + fc(fcDondSetLamp 22 0) + + bin(si 0 60) +ledLoop: + sleep(2) + fc(fcDondSetLamp 21 1) + sleep(2) + fc(fcDondSetLamp 21 0) + bin(ai 0 -1) + br(.n $0 ledLoop) +) + +// --------------------------------------------- +// - this sequence flashes the cabinet lights +// blue and red, and ends with blue. + +seq sHooplahLED ( + +alloc(4) + start() + + bin(si 0 60) +ledLoop: + sleep(2) + fc(fcDondSetLamp 17 1) // blue + fc(fcDondSetLamp 19 1) // blue + fc(fcDondSetLamp 18 0) // red + fc(fcDondSetLamp 20 0) // red + sleep(2) + fc(fcDondSetLamp 17 0) // blue + fc(fcDondSetLamp 19 0) // bue + fc(fcDondSetLamp 18 1) // red + fc(fcDondSetLamp 20 1) // red + bin(ai 0 -1) + br(.n $0 ledLoop) + + fc(fcDondSetLamp 17 1) // blue + fc(fcDondSetLamp 19 1) // blue + fc(fcDondSetLamp 18 0) // red + fc(fcDondSetLamp 20 0) // red +) + +// --------------------------------------------- + +seq sBankerRvF ( + + start() + + // - crowd reaction + + sleep(100) + sound(240) + + // - give the player 11 seconds to make a choice + + fc(fcDondStartTimer 11.0) + + ani(- sFamSounds) +) + +// --------------------------------------------- +// sFamSounds + +seq sFamSounds ( + +alloc(4) + + start() + + // - wait for a bit... + + sleep(50) + fc(fcRandNum $1 50) + sleep($1) + +loop: + + // - play a random individual vocal sound + + fc(fcRandSnd 2 400 401) + + // - wait some more + + sleep(200) + fc(fcRandNum $1 150) + sleep($1) + + // - loop until this sequence is killed off! + + br(loop) +) + +// --------------------------------------------- + +seq sPOfferReveal ( + +alloc(6) + + start() + + // $0: 1 - show no offers + // 2 - show 1 offer + // 3 - show 2 offers + // 4 - show 3 offers + + // - create the previous offer bars + + fc(fcDondAskPrevOffers $0) + bin(ai 0 -3) + br(.le $0 skip3rd) + + create(prevoffer_bar .f=d2 .lb .v .s=sPOfferBar) + bin(mv 2 0) send($2 2) + +skip3rd: + + fc(fcDondAskPrevOffers $0) + bin(ai 0 -2) + br(.le $0 skip2nd) + + create(prevoffer_bar .f=d2 .lb .v .s=sPOfferBar) + bin(mv 2 0) send($2 1) + +skip2nd: + + fc(fcDondAskPrevOffers $0) + bin(ai 0 -1) + br(.le $0 skip1st) + + create(prevoffer_bar .f=d2 .lb .v .s=sPOfferBar) + bin(mv 2 0) send($2 0) + + fc(fcDondAskForFun $4) + br(.n $4 noPrizeLabel) + fc(fcDondAskCoupOrTick $4) + br(.z $4 coupons) + create(prev_tix .f=d2 .lb .v .s=sPOfferBar) bin(mv 2 0) + br(prizeDone) +coupons: + create(Prev_coup .f=d2 .lb .v .s=sPOfferBar) bin(mv 2 0) +prizeDone: + + send($2 0) + +noPrizeLabel: + + create(prev_offer .f=d2 .lb) + +skip1st: + +) + +// --------------------------------------------- +// sPOfferBar + +seq sPOfferBar ( +alloc(2) +signals(3) +signal(0 - slideDown1 - ) +signal(1 - slideDown2 - ) +signal(2 - slideDown3 - ) + + start() +wait: + sleep(0) + +// <---- signal 0 +slideDown1: + + fc(fcBlend 0 0) + bin(si 0 15) + +slideDown1Loop: + sleep(1) + obj(yq=-0.2333) + fc(fcBlend 17 1) + bin(ai 0 -1) + br(.n $0 slideDown1Loop) + fc(fcDondShowPrevOffers 1) + br(wait) + +// <---- signal 1 +slideDown2: + + sleep(20) + fc(fcBlend 0 0) + bin(si 0 15) + +slideDown2Loop: + sleep(1) + obj(yq=-0.4666) + fc(fcBlend 17 1) + bin(ai 0 -1) + br(.n $0 slideDown2Loop) + fc(fcDondShowPrevOffers 2) + br(wait) + +// <---- signal 2 +slideDown3: + + sleep(40) + fc(fcBlend 0 0) + bin(si 0 15) + +slideDown3Loop: + sleep(1) + obj(yq=-0.6999) + fc(fcBlend 17 1) + bin(ai 0 -1) + br(.n $0 slideDown3Loop) + fc(fcDondShowPrevOffers 3) + br(wait) +) + +// --------------------------------------------- +// closeBanker + +seq closeBanker ( + + start() + + vidstop(bank_anim) + vidstop(bank2_anim) + + // - turn on our main background image + + fc(fcDondSend background 1) + + fc(fcDondFadeOut bckgrnd_bnk) + fc(fcDondFadeOut background_blue) // + fc(fcDondSend background_blue 0) + + kill(bg_banker_drk) + kill(bg_banker_w1) + kill(bg_banker_w2) + + fc(fcDondFadeOut bank_tix) + fc(fcDondFadeOut bank_coup) + fc(fcDondFadeOut banker_offer1) + fc(fcDondFadeOut deal_rotate1) + fc(fcDondFadeOut offer_rotate) + fc(fcDondFadeOut nodeal_rotate1) + fc(fcDondFadeOut press_accept) + fc(fcDondFadeOut prss_accpt_l) + fc(fcDondFadeOut press_continue) + fc(fcDondFadeOut prss_cntn_) + fc(fcDondFadeOut deal) + fc(fcDondFadeOut nodeal) + fc(fcDondFadeOut bank_anim) + fc(fcDondFadeOut bank2_anim) + + fc(fcDondFadeOut prev_tix) + fc(fcDondFadeOut Prev_coup) + + fc(fcDondFadeOut nodeal_frame) + + sleep(4) + fc(fcDondUpdateBankerText 0) + + // - fade the cabinet from red to blue + + fc(fcDondAnimLED 3) // <- fade out red + fc(fcDondAnimLED 0) // <- fade blue in + + // - turn off the blanker light + + fc(fcDondSetLamp 16 0) + + //ani(- startWideAnim) +) + +// --------------------------------------------- + +seq closeBankerF ( + + start() + + vidstop(bank_anim) + vidstop(bank2_anim) + + fc(fcDondFadeOut bank_tix) + fc(fcDondFadeOut bank_coup) + fc(fcDondFadeOut bckgrnd_bnk) + fc(fcDondFadeOut background_blue) + + kill(bg_banker_drk) + kill(bg_banker_w1) + kill(bg_banker_w2) + + fc(fcDondSend banker_offer1 2) + + kill(deal_rotate1) + kill(offer_rotate) + kill(offer_frame) + kill(nodeal_rotate1) + kill(nodeal_frame) + + //fc(fcDondFadeOut deal_rotate1) + //fc(fcDondFadeOut offer_rotate) + //fc(fcDondFadeOut nodeal_rotate1) + //fc(fcDondFadeOut nodeal_frame) + + fc(fcDondFadeOut bank_anim) + fc(fcDondFadeOut bank2_anim) + + // - fade the cabinet from red to blue + + fc(fcDondAnimLED 3) // <- fade out red + fc(fcDondAnimLED 0) // <- fade blue in + + fc(fcDondSetLamp 16 0) +) + +// --------------------------------------------- + +seq sPCasePrompt ( + +alloc(4) + + start() + + sound(375) // <- kill any announcer sounds + + // - disable inputs + + fc(fcDondInput 0) + + mark(bgmrk) + + // - fade in the black alpha background so the player + // can easily see the prompt + + fc(fcDondSend black_bg 1) + + sound(5) + + // - display the "choose your case" prompt + + create(persnl_prompt1 .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(-tap 10) + create(persnl_prompt1 .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(-tap 50) + sound(300) + + // - fade away the prompt + + sleep(-tap 150) + send($1 4) + fc(fcDondSend black_bg 2) + + sleep(-tap 20) + sound(375) // <- kill any announcer sounds + sound(301) + + // - wait for the prompt to fade away, then begin + // animating the girls + + sleep(-tap 12) + //sleep(32) + ani(- startWideAnim) + + // - re-enable user input + + fc(fcDondInput 1) + + // - start the countdown timer + + fc(fcDondStartTimer 11.0) + + // - kill of the remaining prompt image + + sleep(-tap 30) + kill(persnl_prompt1) +) + +// --------------------------------------------- + +seq sCase5Prompt ( + +alloc(4) + start() + + sound(375) // <- kill any announcer sounds + + fc(fcDondInput 0) + + // - fade in the black alpha background so the player + // can easily see the prompt + + fc(fcDondSend black_bg 1) + + sound(5) + + // - display the "choose your case" prompt + + create(case5_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(-tap 10) + create(case5_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(-tap 50) + sound(302) + + // - fade away the prompt + + sleep(-tap 150) + send($1 4) + fc(fcDondSend black_bg 2) + + // - wait for the prompt to fade away, then begin + // animating the girls + + sleep(-tap 32) + ani(- startWideAnim) + + fc(fcDondInput 1) + + // - start the countdown timer + + fc(fcDondStartTimer 11.0) + + // - kill of the remaining prompt image + + sleep(-tap 30) + kill(case5_prompt) +) + +// --------------------------------------------- + +seq sCase4Prompt ( + +alloc(4) + start() + + sound(375) // <- kill any announcer sounds + + fc(fcDondInput 0) + + // - fade in the black alpha background so the player + // can easily see the prompt + + fc(fcDondSend black_bg 1) + + sound(5) + + // - display the "choose your case" prompt + + create(case4_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(-tap 10) + create(case4_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(-tap 50) + sound(303) + + // - fade away the prompt + + sleep(-tap 150) + send($1 4) + fc(fcDondSend black_bg 2) + + // - wait for the prompt to fade away, then begin + // animating the girls + + sleep(-tap 32) + ani(- startWideAnim) + + fc(fcDondInput 1) + + // - start the countdown timer + + fc(fcDondStartTimer 11.0) + + // - kill of the remaining prompt image + + sleep(-tap 30) + kill(case4_prompt) +) + +// --------------------------------------------- + +seq sCase3Prompt ( + +alloc(4) + start() + + sound(375) // <- kill any announcer sounds + + fc(fcDondInput 0) + + // - fade in the black alpha background so the player + // can easily see the prompt + + fc(fcDondSend black_bg 1) + + sound(5) + + // - display the "choose your case" prompt + + create(case3_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(-tap 10) + create(case3_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(-tap 50) + sound(304) + + // - fade away the prompt + + sleep(-tap 150) + send($1 4) + fc(fcDondSend black_bg 2) + + // - wait for the prompt to fade away, then begin + // animating the girls + + sleep(-tap 32) + ani(- startWideAnim) + + fc(fcDondInput 1) + + // - start the countdown timer + + fc(fcDondStartTimer 11.0) + + // - kill of the remaining prompt image + + sleep(-tap 30) + kill(case3_prompt) +) + +// --------------------------------------------- + +seq sCase2Prompt ( + +alloc(4) + start() + + sound(375) // <- kill any announcer sounds + + fc(fcDondInput 0) + + // - fade in the black alpha background so the player + // can easily see the prompt + + fc(fcDondSend black_bg 1) + + sound(5) + + // - display the "choose your case" prompt + + create(case2_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(-tap 10) + create(case2_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(-tap 50) + sound(305) + + // - fade away the prompt + + sleep(-tap 150) + send($1 4) + fc(fcDondSend black_bg 2) + + // - wait for the prompt to fade away, then begin + // animating the girls + + sleep(-tap 32) + ani(- startWideAnim) + + fc(fcDondInput 1) + + // - start the countdown timer + + fc(fcDondStartTimer 11.0) + + // - kill of the remaining prompt image + + sleep(-tap 30) + kill(case2_prompt) +) + +// --------------------------------------------- + +seq sFinalPrompt ( + +alloc(4) + start() + + sound(375) // <- kill any announcer sounds + + mark(bgmrk) + kill(black_bg) create(black_bg .f=d2 .lb .v .s=sBlackBg) + bin(mv 2 0) send($2 1) + + // - fade in the black alpha background so the player + // can easily see the prompt + + //fc(fcDondSend black_bg 1) + + sound(5) + + create(final_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(10) + create(final_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(50) + + // - fade away the prompt + + sleep(150) + //send($1 4) <- probably causes errors, since that prompt gets killed! + + // - instead, lets look for this object before we send + // it a signal! + + find(o disp final_prompt) bin(mv 1 0) + br(.z $1 dontSend) + send($1 4) +dontSend: + + fc(fcDondSend black_bg 2) + + // - kill of the remaining prompt image + + sleep(30) + kill(final_prompt) +) + +// --------------------------------------------- + +seq sFollowPrompt ( + +alloc(4) + start() + + sound(375) // <- kill any announcer sounds + + //mark(bgmrk) + mark(fntZ) + + kill(black_bg) create(black_bg .f=d2 .lb .v .s=sBlackBg) + bin(mv 2 0) send($2 1) + + // - fade in the black alpha background so the player + // can easily see the prompt + + //fc(fcDondSend black_bg 1) + + sound(5) + + create(follow_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 1 0) send($1 0) + + // - add a special "fade-out-scale-up" image of the prompt + + sleep(10) + create(follow_prompt .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(50) + + // - fade away the prompt + + sleep(150) + //send($1 4) <- probably causes errors, since that prompt gets killed! + + // - instead, lets look for this object before we send + // it a signal! + + find(o disp follow_prompt) bin(mv 1 0) + br(.z $1 dontSend) + send($1 4) +dontSend: + + fc(fcDondSend black_bg 2) + + // - kill of the remaining prompt image + + sleep(30) + kill(final_prompt) +) \ No newline at end of file diff --git a/donddata/cf/diag.cf b/donddata/cf/diag.cf new file mode 100644 index 0000000..bf0b0ca --- /dev/null +++ b/donddata/cf/diag.cf @@ -0,0 +1,8 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// ------------------------------------------------------------------- + +run(perm) +//load(fntsans16) +//load(fntsans20) + +fc(fcDiag 0) \ No newline at end of file diff --git a/donddata/cf/dondinit.cf b/donddata/cf/dondinit.cf new file mode 100644 index 0000000..15dc519 --- /dev/null +++ b/donddata/cf/dondinit.cf @@ -0,0 +1,10 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// copy, make writable, and rename this bbh3init.cf + +//set(cfg proctest) +//set(cfg Mark) +//set(cfg Will) +//set(cfg Warp) +cat(flags a) + +// EOF \ No newline at end of file diff --git a/donddata/cf/fbo_test.cf b/donddata/cf/fbo_test.cf new file mode 100644 index 0000000..c326d49 --- /dev/null +++ b/donddata/cf/fbo_test.cf @@ -0,0 +1,20 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. + +load(fbo_test) + +seq testfbo ( +alloc(4) + start() + + create(swipe .f=d2 .lb .v) bin(mv 1 0) + obj(ob=$1 of) + vidplay(swipe) + + // create(tempobj .f=d2 .lb) + //vidalink(swipe tempobj) + //vidalink(swipe main_logo1) + //vidalink(swipe main_logo2) + //vidalink(swipe doubledeal) +) + +ani(- testfbo) \ No newline at end of file diff --git a/donddata/cf/models.cf b/donddata/cf/models.cf new file mode 100644 index 0000000..318a85d --- /dev/null +++ b/donddata/cf/models.cf @@ -0,0 +1,1474 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +// MODEL 01 ------------------------------------ + +// - bad + +seq sBad_01 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_01 .f=d2 .la) + create(fs_bad_01 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_01) + viddone(mr_bad_01 sBad_01D) +) + +seq sBad_01D ( + start() + vidstop(mr_bad_01) +) + +// - happy + +seq sHappy_01 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_01 .f=d2 .la) + create(fs_happy_01 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_01) + viddone(mr_happy_01 sHappy_01D) +) + +seq sHappy_01D ( + start() + vidstop(mr_happy_01) +) + +// - select + +seq sSelect_01 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_01 .f=d2 .la) + create(fs_select_01 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_01) + viddone(mr_select_01 sSelect_01D) +) + +seq sSelect_01D ( + start() + vidstop(mr_select_01) +) + +// - supper happy + +seq sSHappy_01 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_01 .f=d2 .la) + create(fs_shappy_01 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_01) + viddone(mr_shappy_01 sSHappy_01D) +) + +seq sSHappy_01D ( + start() + vidstop(mr_shappy_01) +) + +// - tight neutral + +seq sTNeutral_01 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_01 .f=d2 .la) + create(fs_tneutral_01 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_01) + viddone(mr_tneutral_01 sTNeutral_01D) +) + +seq sTNeutral_01D ( + start() + vidstop(mr_tneutral_01) +) + +// MODEL 02 ------------------------------------ + +// - bad + +seq sBad_02 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_02 .f=d2 .la) + create(fs_bad_02 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_02) + viddone(mr_bad_02 sBad_02D) +) + +seq sBad_02D ( + start() + vidstop(mr_bad_02) +) + +// - happy + +seq sHappy_02 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_02 .f=d2 .la) + create(fs_happy_02 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_02) + viddone(mr_happy_02 sHappy_02D) +) + +seq sHappy_02D ( + start() + vidstop(mr_happy_02) +) + +// - select + +seq sSelect_02 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_02 .f=d2 .la) + create(fs_select_02 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_02) + viddone(mr_select_02 sSelect_02D) +) + +seq sSelect_02D ( + start() + vidstop(mr_select_02) +) + +// - supper happy + +seq sSHappy_02 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_02 .f=d2 .la) + create(fs_shappy_02 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_02) + viddone(mr_shappy_02 sSHappy_02D) +) + +seq sSHappy_02D ( + start() + vidstop(mr_shappy_02) +) + +// - tight neutral + +seq sTNeutral_02 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_02 .f=d2 .la) + create(fs_tneutral_02 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_02) + viddone(mr_tneutral_02 sTNeutral_02D) +) + +seq sTNeutral_02D ( + start() + vidstop(mr_tneutral_02) +) + +// MODEL 03 ------------------------------------ + +// - bad + +seq sBad_03 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_03 .f=d2 .la) + create(fs_bad_03 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_03) + viddone(mr_bad_03 sBad_03D) +) + +seq sBad_03D ( + start() + vidstop(mr_bad_03) +) + +// - happy + +seq sHappy_03 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_03 .f=d2 .la) + create(fs_happy_03 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_03) + viddone(mr_happy_03 sHappy_03D) +) + +seq sHappy_03D ( + start() + vidstop(mr_happy_03) +) + +// - select + +seq sSelect_03 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_03 .f=d2 .la) + create(fs_select_03 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_03) + viddone(mr_select_03 sSelect_03D) +) + +seq sSelect_03D ( + start() + vidstop(mr_select_03) +) + +// - supper happy + +seq sSHappy_03 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_03 .f=d2 .la) + create(fs_shappy_03 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_03) + viddone(mr_shappy_03 sSHappy_03D) +) + +seq sSHappy_03D ( + start() + vidstop(mr_shappy_03) +) + +// - tight neutral + +seq sTNeutral_03 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_03 .f=d2 .la) + create(fs_tneutral_03 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_03) + viddone(mr_tneutral_03 sTNeutral_03D) +) + +seq sTNeutral_03D ( + start() + vidstop(mr_tneutral_03) +) + +// MODEL 04 ------------------------------------ + +// - bad + +seq sBad_04 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_04 .f=d2 .la) + create(fs_bad_04 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_04) + viddone(mr_bad_04 sBad_04D) +) + +seq sBad_04D ( + start() + vidstop(mr_bad_04) +) + +// - happy + +seq sHappy_04 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_04 .f=d2 .la) + create(fs_happy_04 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_04) + viddone(mr_happy_04 sHappy_04D) +) + +seq sHappy_04D ( + start() + vidstop(mr_happy_04) +) + +// - select + +seq sSelect_04 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_04 .f=d2 .la) + create(fs_select_04 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_04) + viddone(mr_select_04 sSelect_04D) +) + +seq sSelect_04D ( + start() + vidstop(mr_select_04) +) + +// - supper happy + +seq sSHappy_04 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_04 .f=d2 .la) + create(fs_shappy_04 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_04) + viddone(mr_shappy_04 sSHappy_04D) +) + +seq sSHappy_04D ( + start() + vidstop(mr_shappy_04) +) + +// - tight neutral + +seq sTNeutral_04 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_04 .f=d2 .la) + create(fs_tneutral_04 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_04) + viddone(mr_tneutral_04 sTNeutral_04D) +) + +seq sTNeutral_04D ( + start() + vidstop(mr_tneutral_04) +) + +// MODEL 05 ------------------------------------ + +// - bad + +seq sBad_05 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_05 .f=d2 .la) + create(fs_bad_05 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_05) + viddone(mr_bad_05 sBad_05D) +) + +seq sBad_05D ( + start() + vidstop(mr_bad_05) +) + +// - happy + +seq sHappy_05 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_05 .f=d2 .la) + create(fs_happy_05 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_05) + viddone(mr_happy_05 sHappy_05D) +) + +seq sHappy_05D ( + start() + vidstop(mr_happy_05) +) + +// - select + +seq sSelect_05 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_05 .f=d2 .la) + create(fs_select_05 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_05) + viddone(mr_select_05 sSelect_05D) +) + +seq sSelect_05D ( + start() + vidstop(mr_select_05) +) + +// - supper happy + +seq sSHappy_05 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_05 .f=d2 .la) + create(fs_shappy_05 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_05) + viddone(mr_shappy_05 sSHappy_05D) +) + +seq sSHappy_05D ( + start() + vidstop(mr_shappy_05) +) + +// - tight neutral + +seq sTNeutral_05 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_05 .f=d2 .la) + create(fs_tneutral_05 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_05) + viddone(mr_tneutral_05 sTNeutral_05D) +) + +seq sTNeutral_05D ( + start() + vidstop(mr_tneutral_05) +) + +// MODEL 06 ------------------------------------ + +// - bad + +seq sBad_06 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_06 .f=d2 .la) + create(fs_bad_06 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_06) + viddone(mr_bad_06 sBad_06D) +) + +seq sBad_06D ( + start() + vidstop(mr_bad_06) +) + +// - happy + +seq sHappy_06 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_06 .f=d2 .la) + create(fs_happy_06 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_06) + viddone(mr_happy_06 sHappy_06D) +) + +seq sHappy_06D ( + start() + vidstop(mr_happy_06) +) + +// - select + +seq sSelect_06 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_06 .f=d2 .la) + create(fs_select_06 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_06) + viddone(mr_select_06 sSelect_06D) +) + +seq sSelect_06D ( + start() + vidstop(mr_select_06) +) + +// - supper happy + +seq sSHappy_06 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_06 .f=d2 .la) + create(fs_shappy_06 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_06) + viddone(mr_shappy_06 sSHappy_06D) +) + +seq sSHappy_06D ( + start() + vidstop(mr_shappy_06) +) + +// - tight neutral + +seq sTNeutral_06 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_06 .f=d2 .la) + create(fs_tneutral_06 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_06) + viddone(mr_tneutral_06 sTNeutral_06D) +) + +seq sTNeutral_06D ( + start() + vidstop(mr_tneutral_06) +) + +// MODEL 07 ------------------------------------ + +// - bad + +seq sBad_07 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_07 .f=d2 .la) + create(fs_bad_07 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_07) + viddone(mr_bad_07 sBad_07D) +) + +seq sBad_07D ( + start() + vidstop(mr_bad_07) +) + +// - happy + +seq sHappy_07 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_07 .f=d2 .la) + create(fs_happy_07 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_07) + viddone(mr_happy_07 sHappy_07D) +) + +seq sHappy_07D ( + start() + vidstop(mr_happy_07) +) + +// - select + +seq sSelect_07 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_07 .f=d2 .la) + create(fs_select_07 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_07) + viddone(mr_select_07 sSelect_07D) +) + +seq sSelect_07D ( + start() + vidstop(mr_select_07) +) + +// - supper happy + +seq sSHappy_07 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_07 .f=d2 .la) + create(fs_shappy_07 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_07) + viddone(mr_shappy_07 sSHappy_07D) +) + +seq sSHappy_07D ( + start() + vidstop(mr_shappy_07) +) + +// - tight neutral + +seq sTNeutral_07 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_07 .f=d2 .la) + create(fs_tneutral_07 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_07) + viddone(mr_tneutral_07 sTNeutral_07D) +) + +seq sTNeutral_07D ( + start() + vidstop(mr_tneutral_07) +) + +// MODEL 08 ------------------------------------ + +// - bad + +seq sBad_08 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_08 .f=d2 .la) + create(fs_bad_08 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_08) + viddone(mr_bad_08 sBad_08D) +) + +seq sBad_08D ( + start() + vidstop(mr_bad_08) +) + +// - happy + +seq sHappy_08 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_08 .f=d2 .la) + create(fs_happy_08 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_08) + viddone(mr_happy_08 sHappy_08D) +) + +seq sHappy_08D ( + start() + vidstop(mr_happy_08) +) + +// - select + +seq sSelect_08 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_08 .f=d2 .la) + create(fs_select_08 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_08) + viddone(mr_select_08 sSelect_08D) +) + +seq sSelect_08D ( + start() + vidstop(mr_select_08) +) + +// - supper happy + +seq sSHappy_08 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_08 .f=d2 .la) + create(fs_shappy_08 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_08) + viddone(mr_shappy_08 sSHappy_08D) +) + +seq sSHappy_08D ( + start() + vidstop(mr_shappy_08) +) + +// - tight neutral + +seq sTNeutral_08 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_08 .f=d2 .la) + create(fs_tneutral_08 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_08) + viddone(mr_tneutral_08 sTNeutral_08D) +) + +seq sTNeutral_08D ( + start() + vidstop(mr_tneutral_08) +) + +// MODEL 09 ------------------------------------ + +// - bad + +seq sBad_09 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_09 .f=d2 .la) + create(fs_bad_09 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_09) + viddone(mr_bad_09 sBad_09D) +) + +seq sBad_09D ( + start() + vidstop(mr_bad_09) +) + +// - happy + +seq sHappy_09 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_09 .f=d2 .la) + create(fs_happy_09 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_09) + viddone(mr_happy_09 sHappy_09D) +) + +seq sHappy_09D ( + start() + vidstop(mr_happy_09) +) + +// - select + +seq sSelect_09 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_09 .f=d2 .la) + create(fs_select_09 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_09) + viddone(mr_select_09 sSelect_09D) +) + +seq sSelect_09D ( + start() + vidstop(mr_select_09) +) + +// - supper happy + +seq sSHappy_09 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_09 .f=d2 .la) + create(fs_shappy_09 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_09) + viddone(mr_shappy_09 sSHappy_09D) +) + +seq sSHappy_09D ( + start() + vidstop(mr_shappy_09) +) + +// - tight neutral + +seq sTNeutral_09 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_09 .f=d2 .la) + create(fs_tneutral_09 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_09) + viddone(mr_tneutral_09 sTNeutral_09D) +) + +seq sTNeutral_09D ( + start() + vidstop(mr_tneutral_09) +) + +// MODEL 10 ------------------------------------ + +// - bad + +seq sBad_10 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_10 .f=d2 .la) + create(fs_bad_10 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_10) + viddone(mr_bad_10 sBad_10D) +) + +seq sBad_10D ( + start() + vidstop(mr_bad_10) +) + +// - happy + +seq sHappy_10 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_10 .f=d2 .la) + create(fs_happy_10 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_10) + viddone(mr_happy_10 sHappy_10D) +) + +seq sHappy_10D ( + start() + vidstop(mr_happy_10) +) + +// - select + +seq sSelect_10 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_10 .f=d2 .la) + create(fs_select_10 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_10) + viddone(mr_select_10 sSelect_10D) +) + +seq sSelect_10D ( + start() + vidstop(mr_select_10) +) + +// - supper happy + +seq sSHappy_10 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_10 .f=d2 .la) + create(fs_happy_10 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_10) + viddone(mr_happy_10 sSHappy_10D) +) + +seq sSHappy_10D ( + start() + vidstop(mr_happy_10) +) + +// - tight neutral + +seq sTNeutral_10 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_10 .f=d2 .la) + create(fs_tneutral_10 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_10) + viddone(mr_tneutral_10 sTNeutral_10D) +) + +seq sTNeutral_10D ( + start() + vidstop(mr_tneutral_10) +) + +// MODEL 11 ------------------------------------ + +// - bad + +seq sBad_11 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_11 .f=d2 .la) + create(fs_bad_11 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_11) + viddone(mr_bad_11 sBad_11D) +) + +seq sBad_11D ( + start() + vidstop(mr_bad_11) +) + +// - happy + +seq sHappy_11 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_11 .f=d2 .la) + create(fs_happy_11 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_11) + viddone(mr_happy_11 sHappy_11D) +) + +seq sHappy_11D ( + start() + vidstop(mr_happy_11) +) + +// - select + +seq sSelect_11 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_11 .f=d2 .la) + create(fs_select_11 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_11) + viddone(mr_select_11 sSelect_11D) +) + +seq sSelect_11D ( + start() + vidstop(mr_select_11) +) + +// - supper happy + +seq sSHappy_11 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_11 .f=d2 .la) + create(fs_shappy_11 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_11) + viddone(mr_shappy_11 sSHappy_11D) +) + +seq sSHappy_11D ( + start() + vidstop(mr_shappy_11) +) + +// - tight neutral + +seq sTNeutral_11 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_11 .f=d2 .la) + create(fs_tneutral_11 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_11) + viddone(mr_tneutral_11 sTNeutral_11D) +) + +seq sTNeutral_11D ( + start() + vidstop(mr_tneutral_11) +) + +// MODEL 12 ------------------------------------ + +// - bad + +seq sBad_12 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_12 .f=d2 .la) + create(fs_bad_12 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_12) + viddone(mr_bad_12 sBad_12D) +) + +seq sBad_12D ( + start() + vidstop(mr_bad_12) +) + +// - happy + +seq sHappy_12 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_12 .f=d2 .la) + create(fs_happy_12 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_12) + viddone(mr_happy_12 sHappy_12D) +) + +seq sHappy_12D ( + start() + vidstop(mr_happy_12) +) + +// - select + +seq sSelect_12 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_12 .f=d2 .la) + create(fs_select_12 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_12) + viddone(mr_select_12 sSelect_12D) +) + +seq sSelect_12D ( + start() + vidstop(mr_select_12) +) + +// - supper happy + +seq sSHappy_12 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_12 .f=d2 .la) + create(fs_shappy_12 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_12) + viddone(mr_shappy_12 sSHappy_12D) +) + +seq sSHappy_12D ( + start() + vidstop(mr_shappy_12) +) + +// - tight neutral + +seq sTNeutral_12 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_12 .f=d2 .la) + create(fs_tneutral_12 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_12) + viddone(mr_tneutral_12 sTNeutral_12D) +) + +seq sTNeutral_12D ( + start() + vidstop(mr_tneutral_12) +) + +// MODEL 13 ------------------------------------ + +// - bad + +seq sBad_13 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_13 .f=d2 .la) + create(fs_bad_13 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_13) + viddone(mr_bad_13 sBad_13D) +) + +seq sBad_13D ( + start() + vidstop(mr_bad_13) +) + +// - happy + +seq sHappy_13 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_13 .f=d2 .la) + create(fs_happy_13 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_13) + viddone(mr_happy_13 sHappy_13D) +) + +seq sHappy_13D ( + start() + vidstop(mr_happy_13) +) + +// - select + +seq sSelect_13 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_13 .f=d2 .la) + create(fs_select_13 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_13) + viddone(mr_select_13 sSelect_13D) +) + +seq sSelect_13D ( + start() + vidstop(mr_select_13) +) + +// - supper happy + +seq sSHappy_13 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_13 .f=d2 .la) + create(fs_shappy_13 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_13) + viddone(mr_shappy_13 sSHappy_13D) +) + +seq sSHappy_13D ( + start() + vidstop(mr_shappy_13) +) + +// - tight neutral + +seq sTNeutral_13 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_13 .f=d2 .la) + create(fs_tneutral_13 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_13) + viddone(mr_tneutral_13 sTNeutral_13D) +) + +seq sTNeutral_13D ( + start() + vidstop(mr_tneutral_13) +) + +// MODEL 14 ------------------------------------ + +// - bad + +seq sBad_14 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_14 .f=d2 .la) + create(fs_bad_14 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_14) + viddone(mr_bad_14 sBad_14D) +) + +seq sBad_14D ( + start() + vidstop(mr_bad_14) +) + +// - happy + +seq sHappy_14 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_14 .f=d2 .la) + create(fs_happy_14 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_14) + viddone(mr_happy_14 sHappy_14D) +) + +seq sHappy_14D ( + start() + vidstop(mr_happy_14) +) + +// - select + +seq sSelect_14 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_14 .f=d2 .la) + create(fs_select_14 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_14) + viddone(mr_select_14 sSelect_14D) +) + +seq sSelect_14D ( + start() + vidstop(mr_select_14) +) + +// - supper happy + +seq sSHappy_14 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_14 .f=d2 .la) + create(fs_shappy_14 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_14) + viddone(mr_shappy_14 sSHappy_14D) +) + +seq sSHappy_14D ( + start() + vidstop(mr_shappy_14) +) + +// - tight neutral + +seq sTNeutral_14 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_14 .f=d2 .la) + create(fs_tneutral_14 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_14) + viddone(mr_tneutral_14 sTNeutral_14D) +) + +seq sTNeutral_14D ( + start() + vidstop(mr_tneutral_14) +) + +// MODEL 15 ------------------------------------ + +// - bad + +seq sBad_15 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_15 .f=d2 .la) + create(fs_bad_15 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_15) + viddone(mr_bad_15 sBad_15D) +) + +seq sBad_15D ( + start() + vidstop(mr_bad_15) +) + +// - happy + +seq sHappy_15 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_15 .f=d2 .la) + create(fs_happy_15 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_15) + viddone(mr_happy_15 sHappy_15D) +) + +seq sHappy_15D ( + start() + vidstop(mr_happy_15) +) + +// - select + +seq sSelect_15 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_15 .f=d2 .la) + create(fs_select_15 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_15) + viddone(mr_select_15 sSelect_15D) +) + +seq sSelect_15D ( + start() + vidstop(mr_select_15) +) + +// - supper happy + +seq sSHappy_15 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_15 .f=d2 .la) + create(fs_shappy_15 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_15) + viddone(mr_shappy_15 sSHappy_15D) +) + +seq sSHappy_15D ( + start() + vidstop(mr_shappy_15) +) + +// - tight neutral + +seq sTNeutral_15 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_15 .f=d2 .la) + create(fs_tneutral_15 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_15) + viddone(mr_tneutral_15 sTNeutral_15D) +) + +seq sTNeutral_15D ( + start() + vidstop(mr_tneutral_15) +) + +// MODEL 16 ------------------------------------ + +// - bad + +seq sBad_16 ( +alloc(4) + start() + mark(bgmrk) + create(mr_bad_16 .f=d2 .la) + create(fs_bad_16 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_bad_16) + viddone(mr_bad_16 sBad_16D) +) + +seq sBad_16D ( + start() + vidstop(mr_bad_16) +) + +// - happy + +seq sHappy_16 ( +alloc(4) + start() + mark(bgmrk) + create(mr_happy_16 .f=d2 .la) + create(fs_happy_16 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_happy_16) + viddone(mr_happy_16 sHappy_16D) +) + +seq sHappy_16D ( + start() + vidstop(mr_happy_16) +) + +// - select + +seq sSelect_16 ( +alloc(4) + start() + mark(bgmrk) + create(mr_select_16 .f=d2 .la) + create(fs_select_16 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_select_16) + viddone(mr_select_16 sSelect_16D) +) + +seq sSelect_16D ( + start() + vidstop(mr_select_16) +) + +// - supper happy + +seq sSHappy_16 ( +alloc(4) + start() + mark(bgmrk) + create(mr_shappy_16 .f=d2 .la) + create(fs_shappy_16 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_shappy_16) + viddone(mr_shappy_16 sSHappy_16D) +) + +seq sSHappy_16D ( + start() + vidstop(mr_shappy_16) +) + +// - tight neutral + +seq sTNeutral_16 ( +alloc(4) + start() + mark(bgmrk) + create(mr_tneutral_16 .f=d2 .la) + create(fs_tneutral_16 .f=d2 .la .v) bin(mv 2 0) obj(ob=$2 of) + create(bg_tight .f=d2 .la) + vidplay(mr_tneutral_16) + viddone(mr_tneutral_16 sTNeutral_16D) +) + +seq sTNeutral_16D ( + start() + vidstop(mr_tneutral_16) +) diff --git a/donddata/cf/pcase.cf b/donddata/cf/pcase.cf new file mode 100644 index 0000000..5cf27fd --- /dev/null +++ b/donddata/cf/pcase.cf @@ -0,0 +1,1222 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +seq sPCaseTitle ( + +alloc(8) + start() + //mark(bgmrk) + mark(fntA) + + create(personl_title .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 6) + + sound(15) +) + +// --------------------------------------------- +// sPCaseBox - this animation is used for the +// box that contains the personal case + +seq sPCaseBox ( + +alloc(4) +signals(2) +signal(0 - fadeIn - ) +signal(1 - fadeOut - ) + + start() +wait: + sleep(0) + +// <---- signal 0 +fadeIn: + bin(si 0 32) + fc(fcBlend 0 0) +fadeInLoop: + sleep(1) + fc(fcBlend 8 1) + bin(ai 0 -1) + br(.n $0 fadeInLoop) + fc(fcBlend 255 0) + br(wait) + +// <---- signal 1 +fadeOut: + bin(si 0 32) + fc(fcBlend 255 0) +fadeOutLoop: + sleep(1) + fc(fcBlend -8 1) + bin(ai 0 -1) + br(.n $0 fadeOutLoop) + fc(fcBlend 0 0) + br(wait) +) + +// --------------------------------------------- + +seq sPCaseFX ( + +alloc(8) +signals(7) +signal(0 - fadeIn - ) +signal(1 - fadeInScaleUp - ) +signal(2 - fadeOut - ) +signal(3 - fadeOutScaleUp - ) +signal(4 - superZoom - ) +signal(5 - revFade - ) +signal(6 - superZoom2 - ) + + start() +wait: + sleep(0) + +//// <---- signal 0 +//fadeIn: +// fc(fcBlend 64 0) +// obj(xq=32) +// obj(yq=18) +// fc(fcScale 3.0 0) +// bin(si 0 40) +//fadeInLoop: +// sleep(1) +// fc(fcBlend 4.8 1) +// obj(xq=-0.8) +// obj(yq=-0.45) +// fc(fcScale -0.05 1) +// bin(ai 0 -1) +// br(.n $0 fadeInLoop) +// fc(fcBlend 255 0) +// br(wait) + +// - the following is a faster fade-move-zoom for the +// linux version + +// <---- signal 0 +fadeIn: + fc(fcBlend 64 0) + obj(xq=32) + obj(yq=18) + fc(fcScale 3.0 0) + bin(si 0 15) +fadeInLoop: + sleep(1) + fc(fcBlend 6.4 1) + obj(xq=-2.13333) + obj(yq=-1.2) + fc(fcScale -0.1333 1) + bin(ai 0 -1) + br(.n $0 fadeInLoop) + fc(fcBlend 255 0) + br(wait) + +// <---- signal 1 +fadeInScaleUp: + fc(fcBlend 128 0) + fc(fcScale 1.0 0) + bin(si 0 32) +scaleUpLoop: + sleep(1) + fc(fcBlend -4 1) + fc(fcScale 0.01 1) + bin(ai 0 -1) + br(.n $0 scaleUpLoop) + fc(fcBlend 0 0) + + find(l prime -) bin(mv 0 0) // + kill($0) // + + br(wait) + +// <---- signal 2 +fadeOut: + fc(fcBlend 255 0) + bin(si 0 32) +fadeOutLoop: + sleep(1) + fc(fcBlend -8 1) + bin(ai 0 -1) + br(.n $0 fadeOutLoop) + fc(fcBlend 0 0) + + find(l prime -) bin(mv 0 0) + kill($0) + + br(wait) + +// <---- signal 3 +fadeOutScaleUp: + fc(fcBlend 128 0) + fc(fcScale 1.0 0) + bin(si 0 32) +scaleUpLoop2: + sleep(1) + fc(fcBlend -4 1) + fc(fcScale 0.04 1) + bin(ai 0 -1) + br(.n $0 scaleUpLoop2) + fc(fcBlend 0 0) + + find(l prime -) bin(mv 0 0) // + kill($0) // + + br(wait) + +// <---- signal 4 +superZoom: + fc(fcScale 0.0 0) + obj(yq=8) + bin(si 0 16) +superZoomL: + sleep(1) + fc(fcScale 0.0625 1) + bin(ai 0 -1) + br(.n $0 superZoomL) + +zoomMore: + sleep(1) + fc(fcScale 0.00075 1) + // - keep zooming up gently until we die! + br(zoomMore) + + br(wait) + +// <---- signal 6 - just a copy of signal 4 +superZoom2: + fc(fcScale 0.0 0) + obj(yq=8) + bin(si 0 16) +superZoomL2: + sleep(1) + fc(fcScale 0.0625 1) + bin(ai 0 -1) + br(.n $0 superZoomL2) + +zoomMore2: + sleep(1) + fc(fcScale 0.00075 1) + // - keep zooming up gently until we die! + br(zoomMore2) + + br(wait) + +// <---- signal 5 + +revFade: + fc(fcBlend 255 0) + fc(fcScale 1.0 0) + bin(si 0 30) +revFadeLoop: + sleep(1) + fc(fcBlend -8.5 1) + obj(xq=1.06666) + obj(yq=0.50) + fc(fcScale 0.0666 1) + bin(ai 0 -1) + br(.n $0 revFadeLoop) + fc(fcBlend 0 0) + br(wait) +) + +// --------------------------------------------- + +seq sPCase01 ( + +alloc(4) + + start() + sleep(10) + + // - fade-in, shrink-in, and move-in the personal case + + set(tag 4) + mark(fntZ) create(pcase_01 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase01K) + + sleep(60) + sound(16) + + set(tag 4) + mark(fntZ) create(pcase_01 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 4) + mark(fntZ) create(pcase_01 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + set(tag 4) + mark(fntZ) create(pcase_01 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + set(tag 4) + mark(fntZ) create(pcase_01 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase01K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase01 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_01 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase02 ( + +alloc(4) + start() + sleep(10) + + // - fade-in, shrink-in, and move-in the personal case + + set(tag 4) + mark(fntZ) create(pcase_02 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase02K) + + sleep(60) + sound(16) + + set(tag 4) + mark(fntZ) create(pcase_02 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 4) + mark(fntZ) create(pcase_02 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + set(tag 4) + mark(fntZ) create(pcase_02 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + + set(tag 4) + mark(fntZ) create(pcase_02 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase02K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase02 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_02 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase03 ( + +alloc(4) + start() + + sleep(10) + + // - fade-in, shrink-in, and move-in the personal case + + set(tag 4) + mark(fntZ) create(pcase_03 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase03K) + + sleep(60) + sound(16) + + set(tag 4) + mark(fntZ) create(pcase_03 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 4) + mark(fntZ) create(pcase_03 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + set(tag 4) + mark(fntZ) create(pcase_03 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + set(tag 4) + mark(fntZ) create(pcase_03 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase03K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase03 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_03 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase04 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_04 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase04K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_04 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_04 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_04 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_04 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase04K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase04 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_04 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase05 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_05 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase05K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_05 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_05 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_05 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_05 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase05K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase05 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_05 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase06 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_06 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase06K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_06 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_06 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_06 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_06 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase06K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase06 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_06 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase07 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_07 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase07K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_07 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_07 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_07 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_07 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase07K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase07 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_07 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase08 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_08 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase08K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_08 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_08 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_08 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_08 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase08K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase08 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_08 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase09 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_09 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase09K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_09 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_09 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_09 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_09 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase09K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase09 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_09 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase10 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_10 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase10K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_10 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_10 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_10 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_10 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase10K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase10 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_10 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase11 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_11 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase11K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_11 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_11 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_11 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_11 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase11K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase11 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_11 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase12 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_12 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase12K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_12 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_12 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_12 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_12 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase12K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase12 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_12 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase13 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_13 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase13K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_13 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_13 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_13 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_13 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase13K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase13 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_13 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase14 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_14 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase14K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_14 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_14 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_14 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_14 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase14K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase14 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_14 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase15 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_15 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase15K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_15 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_15 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_15 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_15 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase15K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase15 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_15 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase16 ( + +alloc(4) + start() + + sleep(10) + + set(tag 4) + + // - fade-in, shrink-in, and move-in the personal case + + mark(fntZ) create(pcase_16 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 0) + + // - the rest are extra cases that fade out and grow out + + ani(- sPCase16K) + + sleep(60) + sound(16) + + mark(fntZ) create(pcase_16 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + mark(fntZ) create(pcase_16 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 1) + + sleep(10) + mark(fntZ) create(pcase_16 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + sleep(10) + mark(fntZ) create(pcase_16 .f=d2 .lb .v .s=sPCaseFX) + bin(mv 2 0) send($2 3) + + set(tag 0) +) + +seq sPCase16K ( + + start() + sleep(-tap 200) + kill(^=4) + kill(sPCase16 .t=seq) + + set(tag 0) + mark(fntZ) create(pcase_16 .f=d2 .lb) +) + +// --------------------------------------------- + +seq sPCase01Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_01 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase02Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_02 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase03Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_03 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase04Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_04 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase05Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_05 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase06Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_06 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase07Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_07 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase08Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_08 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase09Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_09 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase10Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_10 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase11Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_11 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase12Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_12 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase13Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_13 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase14Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_14 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase15Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_15 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) +// --------------------------------------------- + +seq sPCase16Rv ( + alloc(4) + start() + kill(pcase_*) + mark(fntA) + create(pcase_16 .f=d2 .la .v .s=sPCaseFX) + bin(mv 2 0) send($2 5) + fc(fcDondSend persnl_case 1) +) diff --git a/donddata/cf/perm.cf b/donddata/cf/perm.cf new file mode 100644 index 0000000..d8b05f5 --- /dev/null +++ b/donddata/cf/perm.cf @@ -0,0 +1,2321 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +load(fntsans16) +load(fntsans20) +load(fntsans24) +load(fntsans36) + +load(fntprofr) + +load(fnt_vbar_lit) +load(fnt_tbar_big) +load(fnt_incase) +load(fnt_timer) +load(fnt_tb_big) +load(fnt_tb_small) +load(fnt_cred) +load(fnt_cont) +load(shuffle_fnt) + +// --------------------------------------------- + +load(dondTitle) +load(models_wide) +//load(models_tight_a) +//load(models_tight_b) +load(banker) +load(tight_scene) +load(collect) +load(attract) +load(diag) +load(shuffle) + +// --------------------------------------------- + +run(models) +run(banker) +run(pcase) +run(wreveal) +run(attract) +run(shuffle) + +mark(cam3) + +// --------------------------------------------- + +sound(-l plsdond) +sound(-v 255) + +// --------------------------------------------- +// SCENE ORGANIZATION: +// +// marker: cam3 +// -> background +// -> models +// marker: bgmrk +// -> value bars unlit +// -> value bars lit +// marker: fntA +// -> title page (video) +// marker: fntZ +// -> strings generated by the system + +seq sClear ( + start() + vidstop(bgVideo) + kill(bgVideo) + kill(background) + kill(title_page) + kill(press_start) + kill(models_start) + kill(main_logo1) + kill(credits1) +) + +// --------------------------------------------- +// sDiagStart +// +// - run when the operator enters the diagnostic +// menu. + +seq sDiagStart ( + + start() + + fc(fcDondUnloadVideos) + + kill(*) + kill(* .t=seq) + fc(fcDondClearGameText) + + fc(fcDondSetGameState 0) + + // - tell the code that we are going into diag mode + + fc(fcDondOnDiagStart) +) + +// --------------------------------------------- +// clearPrevScene - called when the DOND game +// process is started. + +seq clearPrevScene ( + + start() +) + +// --------------------------------------------- +// createMainScene + +seq createMainScene ( + +alloc(4) + start() + + mark(bgmrk) + + kill(model_*) + + // - we don't want any object duplicates laying + // around, so we delete everything before creating + + kill(background) create(background .f=d2 .lb .v .s=bgAnim) + + // - the models are created in reverse order in order + // to get correct layering. + + kill(model_016) create(model_016 .f=d2 .lb) + kill(case_016) create(case_016 .f=d2 .lb) + + kill(model_015) create(model_015 .f=d2 .lb) + kill(case_015) create(case_015 .f=d2 .lb) + + kill(model_014) create(model_014 .f=d2 .lb) + kill(case_014) create(case_014 .f=d2 .lb) + + kill(model_013) create(model_013 .f=d2 .lb) + kill(case_013) create(case_013 .f=d2 .lb) + + kill(shadow_012) create(shadow_012 .f=d2 .lb) + kill(model_012) create(model_012 .f=d2 .lb) + kill(case_012) create(case_012 .f=d2 .lb) + + kill(shadow_011) create(shadow_011 .f=d2 .lb) + kill(model_011) create(model_011 .f=d2 .lb) + kill(case_011) create(case_011 .f=d2 .lb) + + kill(shadow_010) create(shadow_010 .f=d2 .lb) + kill(model_010) create(model_010 .f=d2 .lb) + kill(case_010) create(case_010 .f=d2 .lb) + + kill(shadow_09) create(shadow_09 .f=d2 .lb) + kill(model_09) create(model_09 .f=d2 .lb) + kill(case_09) create(case_09 .f=d2 .lb) + + kill(shadow_08) create(shadow_08 .f=d2 .lb) + kill(model_08) create(model_08 .f=d2 .lb) + kill(case_08) create(case_08 .f=d2 .lb) + + kill(shadow_07) create(shadow_07 .f=d2 .lb) + kill(model_07) create(model_07 .f=d2 .lb) + kill(case_07) create(case_07 .f=d2 .lb) + + kill(shadow_06) create(shadow_06 .f=d2 .lb) + kill(model_06) create(model_06 .f=d2 .lb) + kill(case_06) create(case_06 .f=d2 .lb) + + kill(shadow_05) create(shadow_05 .f=d2 .lb) + kill(model_05) create(model_05 .f=d2 .lb) + kill(case_05) create(case_05 .f=d2 .lb) + + kill(shadow_04) create(shadow_04 .f=d2 .lb) + kill(model_04) create(model_04 .f=d2 .lb) + kill(case_04) create(case_04 .f=d2 .lb) + + kill(shadow_03) create(shadow_03 .f=d2 .lb) + kill(model_03) create(model_03 .f=d2 .lb) + kill(case_03) create(case_03 .f=d2 .lb) + + kill(shadow_02) create(shadow_02 .f=d2 .lb) + kill(model_02) create(model_02 .f=d2 .lb) + kill(case_02) create(case_02 .f=d2 .lb) + + kill(shadow_01) create(shadow_01 .f=d2 .lb) + kill(model_01) create(model_01 .f=d2 .lb) + kill(case_01) create(case_01 .f=d2 .lb) + + // - this marker is placed between the models and the + // value bars. when changing scenes, we often want to + // start here because the value bars should always be + // visible to the player and provide framing for the + // other elements. + + // - note: instead of creating a marker, we are simply + // placing our elements at either side with "link before" + // and "link after" options toggled. + + kill(black_bg) create(black_bg .f=d2 .lb .v .s=sBlackBg) + bin(mv 2 0) send($2 0) + + kill(tick_001) create(tick_001 .f=d2 .la .v .s=barAnim) + kill(tick_002) create(tick_002 .f=d2 .la .v .s=barAnim) + kill(tick_003) create(tick_003 .f=d2 .la .v .s=barAnim) + kill(tick_004) create(tick_004 .f=d2 .la .v .s=barAnim) + kill(tick_005) create(tick_005 .f=d2 .la .v .s=barAnim) + kill(tick_006) create(tick_006 .f=d2 .la .v .s=barAnim) + kill(tick_007) create(tick_007 .f=d2 .la .v .s=barAnim) + kill(tick_008) create(tick_008 .f=d2 .la .v .s=barAnim) + kill(tick_009) create(tick_009 .f=d2 .la .v .s=barAnim) + kill(tick_0010) create(tick_0010 .f=d2 .la .v .s=barAnim) + kill(tick_0011) create(tick_0011 .f=d2 .la .v .s=barAnim) + kill(tick_0012) create(tick_0012 .f=d2 .la .v .s=barAnim) + kill(tick_0013) create(tick_0013 .f=d2 .la .v .s=barAnim) + kill(tick_0014) create(tick_0014 .f=d2 .la .v .s=barAnim) + kill(tick_0015) create(tick_0015 .f=d2 .la .v .s=barAnim) + kill(tick_0016) create(tick_0016 .f=d2 .la .v .s=barAnim) + + kill(tick_unlit_001) create(tick_unlit_001 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_002) create(tick_unlit_002 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_003) create(tick_unlit_003 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_004) create(tick_unlit_004 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_005) create(tick_unlit_005 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_006) create(tick_unlit_006 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_007) create(tick_unlit_007 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_008) create(tick_unlit_008 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_009) create(tick_unlit_009 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0010) create(tick_unlit_0010 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0011) create(tick_unlit_0011 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0012) create(tick_unlit_0012 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0013) create(tick_unlit_0013 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0014) create(tick_unlit_0014 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0015) create(tick_unlit_0015 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0016) create(tick_unlit_0016 .f=d2 .la .v .s=barAnim) + + fc(fcDondAskForFun $0) + br(.n $0 prizeDone) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + + kill(ticket_sign*) + create(ticket_signL .f=d2 .la .v .s=barAnim) + create(ticket_signR .f=d2 .la .v .s=barAnim) + br(prizeDone) + +coupons: + + kill(coup_sign*) + create(coup_signL .f=d2 .la .v .s=barAnim) + create(coup_signR .f=d2 .la .v .s=barAnim) + +prizeDone: + + create(textbar .f=d2 .lb) + create(chooseyourcase .f=d2 .lb) + + //ani(- pushBarsOut) + sleep(1) + ani(- startWideAnim) + sleep(1) + ani(- stopWideAnim) +) + +// --------------------------------------------- +// sBlackBg - this signal pertains to the alpha +// black layer that obscures the game screen to +// make player prompts more visible + +seq sBlackBg( + +alloc(4) +signals(4) +signal(0 - turnOff - ) +signal(1 - fadeIn - ) +signal(2 - fadeOut - ) +signal(3 - fadeOutK - ) + + start() +wait: + sleep(0) + +// <---- signal 0 +turnOff: + fc(fcBlend 0 0) + br(wait) + +// <---- signal 1 +fadeIn: + bin(si 0 16) + fc(fcBlend 0 0) +fadeInLoop: + sleep(1) + fc(fcBlend 8 1) + bin(ai 0 -1) + br(.n $0 fadeInLoop) + fc(fcBlend 128 0) + br(wait) + +// <---- signal 2 +fadeOut: + bin(si 0 16) + fc(fcBlend 128 0) +fadeOutLoop: + sleep(1) + fc(fcBlend -8 1) + bin(ai 0 -1) + br(.n $0 fadeOutLoop) + fc(fcBlend 0 0) + br(wait) + +// <---- signal 3 +fadeOutK: + bin(si 0 16) + fc(fcBlend 255 0) +fadeOutKLoop: + sleep(1) + fc(fcBlend -16 1) + bin(ai 0 -1) + br(.n $0 fadeOutKLoop) + fc(fcBlend 0 0) + + // - + find(l prime -) bin(mv 0 0) + kill($0) +) + +// --------------------------------------------- + +seq turnOffBars ( + start() + fc(fcDondSend tick_unlit_001 5) + fc(fcDondSend tick_unlit_002 5) + fc(fcDondSend tick_unlit_003 5) + fc(fcDondSend tick_unlit_004 5) + fc(fcDondSend tick_unlit_005 5) + fc(fcDondSend tick_unlit_006 5) + fc(fcDondSend tick_unlit_007 5) + fc(fcDondSend tick_unlit_008 5) + fc(fcDondSend tick_unlit_009 5) + fc(fcDondSend tick_unlit_0010 5) + fc(fcDondSend tick_unlit_0011 5) + fc(fcDondSend tick_unlit_0012 5) + fc(fcDondSend tick_unlit_0013 5) + fc(fcDondSend tick_unlit_0014 5) + fc(fcDondSend tick_unlit_0015 5) + fc(fcDondSend tick_unlit_0016 5) +) + +// --------------------------------------------- + +seq sAtrCountdown ( + +alloc(4) + start() + + // - if there are credits in the machine, we will + // wait a lot longer before we exit the coin-in + // page and go into the attract mode + + fc(fcDondAskNumCredits $2) + br(.z $2 shortWait) + sleep(1000) +shortWait: + sleep(570) + + // - kill the objects in the initial scene + + vidstop(bgVideo) + kill(bgVideo) + kill(main_logo*) + kill(doubledeal) + kill(dj_logo1) + kill(models_*) + kill(press*) + kill(createInitScene .t=seq) + + kill(frame) + kill(frame2) + + // - set the game into the attract loop + + fc(fcDondSetGameState 11) + ani(- sAttractStart) +) + +// --------------------------------------------- +// createInitScene + +seq createInitScene ( + +alloc(16) + + start() + + sloop(1) + + fc(fcDondClearGameText) + fc(fcDondUnloadVideos) + + kill(*) + kill(* .t=func) + kill(sAtrCountdown .t=seq) + + // - kill any attract-mode light animation + + kill(sAtrLEDAnim .t=seq) + ani(- sAtrLEDOff) + + sloop(1) + + // - are we playing the new jersey shore version? + + fc(fcDondAskNJS $7) + + // - turn off the start button lights + + fc(fcDondSetLamp 23 0) // <- DOUBLE DEAL + fc(fcDondSetLamp 26 0) // <- DEAL / STANDARD START + + // - turn off the cabinet lights + + fc(fcDondSetLamp 16 0) + + fc(fcDondSetLamp 18 0) + fc(fcDondSetLamp 20 0) + + fc(fcDondSetLamp 19 0) fc(fcDondSetLamp 17 0) + fc(fcDondSetLamp 19 1) // <- cabinet lights are always blue! + fc(fcDondSetLamp 17 1) + + fc(fcDondSetCorrectVol) + + // - get rid of any sequences that may still be + // running from the last game + + kill(s* .t=seq) + kill(sAttractStart .t=seq) + + kill(persnl_case) + kill(pCase*) + + kill(model*) + kill(press_*) + + mark(fntA) + + kill(frame) + kill(frame2) + + kill(main_logo1) create(main_logo1 .f=d2 .la .v) bin(mv 10 0) + br(.n $7 NJS_NOTITLE1) + kill(doubledeal) create(doubledeal .f=d2 .la) + kill(main_logo2) create(main_logo2 .f=d2 .la) +NJS_NOTITLE1: + + create(frame .f=d2 .la .v) bin(mv 11 0) + br(.n $7 NJS_NOTITLE2) + create(frame2 .f=d2 .la) +NJS_NOTITLE2: + + // - for the objects we just created, do we need to move them to + // the center of the screen? + + br(.z $7 SKIP_MOVE1) + obj(ob=$10 xq=32.0) + obj(ob=$11 xq=32.0) +SKIP_MOVE1: + + // - create the background video + + kill(bgVideo) create(bgVideo .f=d2 .la) + vidplay(bgVideo 0) // - 0 = don't ignore clock + + // - if there are enough credits in the game to + // play, we will not go back into the attract mode. + // note: if we are NOT asked to continue, that means + // we have enough credits to play! + + fc(fcDondAskToContinue $2) + br(.z $2 noAttract) + + ani(- sAtrCountdown) +noAttract: + + sloop(1) + + // - clear out any playing music + + sound(99) + + fc(fcDondAskAtrSound $6) + br(.z $6 skipSound1) + sound(3) +skipSound1: + + // - this section loops around until there are enough + // credits to display the "press_start" message + + bin(si 1 0) // $1 = press_start + bin(si 2 0) // $2 = press_deal + bin(si 3 0) // $3 = game begun + +checkPStart: + sleep(1) + br(.n $1 checkPDeal) // <- if press_start is visible + // check press_deal + + fc(fcDondAskCredits $0 0) // <- check regular mode pricing + br(.z $0 checkPDeal) + + mark(fntZ) + //create(press_start .f=d2 .lb) + create(main_logoglow1 .f=d2 .lb .v) bin(mv 10 0) + create(main_logo_w .f=d2 .lb .v .s=sPrompt) + bin(mv 5 0) send($5 2) + bin(si 1 1) + fc(fcDondAnimLED 0) // <- fade blue in + fc(fcDondSetLamp 26 1) // <- DEAL / STANDARD START + + // - do we need to move these new glow objects to the center + // of the screen? + + br(.z $7 SKIP_MOVE2) + obj(ob=$5 xq=32.0) + obj(ob=$10 xq=32.0) +SKIP_MOVE2: + +checkPDeal: + sleep(1) + br(.n $2 checkDone) + br(.n $7 checkDone) + + fc(fcDondAskCredits $0 1) // <- check bonus mode pricing + br(.z $0 checkDone) + + mark(fntZ) + //create(press_deal .f=d2 .lb) + kill(doubledeal) + create(main_logoglow2 .f=d2 .lb) + create(main_logo_w2 .f=d2 .lb .v .s=sPrompt) + bin(mv 5 0) send($5 2) + create(doubledeal .f=d2 .lb) + create(main_logo_w4 .f=d2 .lb .v .s=sPrompt) + bin(mv 5 0) send($5 2) + bin(si 2 1) + fc(fcDondAnimLED 0) // <- fade blue in + fc(fcDondSetLamp 23 1) // <- DOUBLE DEAL + +checkDone: + + // - if either of the "press start" or "press deal" + // prompts are off, go back and try to turn them + // off again. + + br(.z $1 checkPStart) + br(.z $2 checkPDeal) + + // ... this sequence will be killed when the game is begun +) + +// --------------------------------------------- +// bgAnim +// +// - this animation sequence simply controls the +// on/off state of the object, so we can +// dynamically add/remove it from the scene +// in order to manage our frame rate. + +seq bgAnim ( + +signals(3) +signal(0 - wait - ) +signal(1 - turnOn - ) +signal(2 - turnOff - ) + + start() + +wait: + sleep(0) + +turnOn: + obj(on) + br(wait) + +turnOff: + obj(of) + br(wait) +) + +// --------------------------------------------- +// sAttractMode +// +// - show the attract mode + +seq sAttractMode ( + + start() + + mark(bgmrk) + create(bgVideo .f=d2 .lb) + vidplay(bgVideo) + + create(title_page .f=d2 .lb) + create(models_start .f=d2 .lb) + create(press_start .f=d2 .lb) +) + +// --------------------------------------------- +// sChooseDeal +// +// - this sequence is played when the user hits +// the "DEAL" button in the banker scene. + +seq sChooseDeal ( + +alloc(4) + + start() + + fc(fcDondInput 0) + + // - remove the random "family" vocals + + kill(sFamSounds .t=seq) + kill(sBankerRvF .t=seq) + ani(- sDealLED) + ani(- sHooplahLED) + + vidready(offer_rotate) + kill(offer_rotate) + + kill(press_continue) + kill(prss_cntn_) + kill(nodeal) + + fc(fcDondFadeOut bank_tix) + fc(fcDondFadeOut bank_coup) + kill(prev_tix) + kill(Prev_coup) + + // - there can be up to three previous offers + + kill(prevoffer_bar) kill(prevoffer_bar) kill(prevoffer_bar) + kill(prev_offer) + + sound(249) // <- end mixed yelling + sound(201) // <- play general applause + + sound(51) // <- play "choose deal" music + + // - play the "DEAL" rotating panel movie + + create(deal_rotate1 .f=d2 .lb) + vidplay(deal_rotate1 1) + + // - this is where we make the choice between displaying + // the wide reveal and simply ending the game! + + //viddone(deal_rotate1 sCDdone) + viddone(deal_rotate1 sCDdoneWR) + + // - get rid of the banker offer text + + fc(fcDondUpdateBankerText 0) + + // - flash the accept button + + fc(fcDondSend prss_accpt_l 0) + + // - animate away the value bars + + // ani(- slideBarsOut) // <- normally removed! + + // - get rid of the player's case + + //kill(pCase_01) kill(pCase_02) kill(pCase_03) kill(pCase_04) + //kill(pCase_05) kill(pCase_06) kill(pCase_07) kill(pCase_08) + //kill(pCase_09) kill(pCase_10) kill(pCase_11) kill(pCase_12) + //kill(pCase_13) kill(pCase_14) kill(pCase_15) kill(pCase_16) + //kill(persnl_case) + + // - so some funky effects with the deal button + + create(deal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + create(deal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(10) + create(deal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + sleep(10) + create(deal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + // - TEST: create the wide reveal scene + + //ani(- createWRS) + + // - turn on the blue background + + fc(fcDondSend background_blue 4) + fc(fcDondSend bg_banker_drk 2) + + fc(fcDondSend bg_banker_w1 3) + sleep(2) + fc(fcDondSend bg_banker_w2 3) + + sleep(100) + // ........... + fc(fcDondFadeOut press_accept) + fc(fcDondFadeOut prss_accpt_l) + fc(fcDondFadeOut press_continue) + fc(fcDondFadeOut prss_cntn_) + fc(fcDondFadeOut deal) + fc(fcDondFadeOut nodeal) + // ........... + sleep(20) + fc(fcDondShowTicketsWon 1) + + sleep(70) + fc(fcDondAskGoodGame $0) + br(.z $0 notGood) + sound(371) // <- "what a great game!" +notGood: +) + +// --------------------------------------------- +// sCDdone +// +// - this is played when the "DEAL" panel movie +// has finished playing in the banker scene. + +seq sCDdone( + + start() + + vidstop(deal_rotate1) + sleep(200) + + fc(fcDondFadeOut ticket_signL) + fc(fcDondFadeOut ticket_signR) + fc(fcDoneFadeOut coup_signL) + fc(fcDondFadeOut coup_signR) + + ani(- slideBarsOut) + ani(- sCollect) + + sleep(40) + + fc(fcDondFadeOut deal_rotate1) + + ani(- closeBanker) +) + +// --------------------------------------------- +// - when the DONE animation is through playing, +// and we are going into the wide reveal scene + +seq sCDdoneWR ( + + start() + vidstop(deal_rotate1) + + sleep(270) + sleep(70) + + // - "let's see what you didn't choose" + + sound(369) + sleep(160) + ani(- createWRS) + + kill(bckgrnd_bnk) + kill(background_blue) + kill(bg_banker_*) + vidstop(bank2_anim) + kill(bank2_anim) + + //fc(fcDondFadeOut banker_offer1) + //fc(fcDondFadeOut deal_rotate1) + kill(banker_offer1) + kill(deal_rotate1) + + // - place the game in DOND_WIDE_REVEAL mode + + fc(fcDondSetGameState 9) + + // - remove the "YOU WON XX TICKETS" text + + fc(fcDondShowTicketsWon 0) + + // - pause a bit, then begin opening the cases + + //sleep(60) + ani(- sWRS) +) + +// --------------------------------------------- +// sCollect +// +// - brings up the "COLLECT" scene, where the +// user collects his/her winnings. + +seq sCollect ( + +alloc(4) + start() + + mark(bgmrk) + create(bgVideo .f=d2 .lb) + vidplay(bgVideo) + + create(game_over .f=d2 .lb) + //create(model_right .f=d2 .lb) + //create(model_right1 .f=d2 .lb) + + sleep(-tap 150) + sound(361) // "Game Over" + + fc(fcDondAskCollectWait $2) + sleep($2) + + fc(fcDondShowTicketsWon 0) + + fc(fcDondInput 1) + fc(fcDondSetGameState 100) +) + +// --------------------------------------------- + +seq sCollectAni ( +alloc(4) +signals(4) +signal(0 - fadeInDwn - ) + + start() +wait: + sleep(0) + +// <---- signal 0 +fadeInDwn: + fc(fcBlend 0 0) + obj(yq=32) + bin(si 0 64) +fadeInDwnL: + sleep(1) + fc(fcBlend 4 1) + obj(yq=-0.5) + bin(ai 0 -1) + br(.n $0 fadeInDwnL) + fc(fcBlend 255 0) + br(wait) +) + +// --------------------------------------------- +// sChooseNoDeal + +seq sChooseNoDeal ( + +alloc(4) + + start() + + fc(fcDondInput 0) + + // - $3 = 0 if the user is not going to be + // prompted to continue. $3 = 1 if the user + // will be prompted. if the user is going to + // be prompted, we will skip any commands that + // concern rotating and hiding away the bankers + // offer. + + fc(fcDondAskToContinue $3) + + br(.n $3 skip1st) + + vidready(offer_rotate) + kill(offer_rotate) + fc(fcDondUpdateBankerText 0) +skip1st: + + // - remove the random "family" vocals + + kill(sFamSounds .t=seq) + kill(sBankerRvF .t=seq) + ani(- sNoDealLED) + + kill(press_accept) + kill(prss_accpt_l) + kill(deal) + + br(.n $3 skip2nd) + + fc(fcDondFadeOut bank_tix) + fc(fcDondFadeOut bank_coup) +skip2nd: + + kill(prev_tix) + kill(Prev_coup) + kill(prevoffer_bar) kill(prevoffer_bar) kill(prevoffer_bar) + kill(prev_offer) + + sound(249) // <- end mixed yelling + sound(201) // <- play general applause + + br(.n $3 skip3rd) + + create(nodeal_rotate1 .f=d2 .lb) + vidplay(nodeal_rotate1 1) + viddone(nodeal_rotate1 sCNDdone) +skip3rd: + + fc(fcDondSend prss_cntn_ 0) + + // - so some funky effects with the no deal button + + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(10) + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + sleep(10) + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + br(.z $3 skip4th) + + sleep(40) + ani(- sCNDdone) + +skip4th: +) + +// --------------------------------------------- +// sCNDdone - when the "no deal" sequence is +// done playing + +seq sCNDdone( + +alloc(4) + + start() + + vidstop(nodeal_rotate1) + + // - fade away the deal/no deal choice + // buttons + + fc(fcDondFadeOut press_accept) + fc(fcDondFadeOut prss_accpt_l) + fc(fcDondFadeOut press_continue) + fc(fcDondFadeOut prss_cntn_) + fc(fcDondFadeOut deal) + fc(fcDondFadeOut nodeal) + + // - at this point, the user is prompted to + // continue the game by pressing the start + // button + // + // $0 = 0 -> player should not be asked to continue + // $0 = 1 -> player is asked to continue + + fc(fcDondAskToContinue $0) + br(.n $0 doContinue) + +noContinue: + + sleep(60) + fc(fcDondDoContinue) + br(end) + +doContinue: + + sleep(50) // !!!! + ani(- sContinue) + +end: + +) + +// --------------------------------------------- + +seq sCNDdone2 ( + +alloc(4) + start() + + fc(fcDondFadeOut continue1) + fc(fcDondFadeOut nodeal_rotate1) + + ani(- closeBanker) + + sleep(30) + ani(- showChoiceLeft) + + // - find out how many choices we have left + + fc(fcDondAskChoicesLeft $0) + bin(ai 0 -4) + br(.lt $0 notFour) + ani(- sCase4Prompt) + br(done) + +notFour: + + fc(fcDondAskChoicesLeft $0) + bin(ai 0 -3) + br(.lt $0 notThree) + ani(- sCase3Prompt) + br(done) + +notThree: + + fc(fcDondAskChoicesLeft $0) + bin(ai 0 -2) + br(.lt $0 notTwo) + ani(- sCase2Prompt) + br(done) + +notTwo: + + + + +done: + + //sleep(10) + //fc(fcDondStartTimer 11.0) + //br(end) +) + +// --------------------------------------------- +// sContinue + +seq sContinue ( + +alloc(1) + + start() + + fc(fcDondShowContinueText) + + // - "would you like to continue?" + + sound(365) + + // - "insert money to continue" + + sleep(100) + + fc(fcDondAskCredits $0) + br(.n $0 skipInsert) + + sound(363) + +skipInsert: + + fc(fcDondStartTimer 11.0) +) + +// --------------------------------------------- +// sChooseNoDealF +// +// - this sequence plays when the user selects +// "no deal" with 1 case left. + +seq sChooseNoDealF ( + +alloc(4) + start() + + vidready(offer_rotate) + kill(offer_rotate) + + // - remove the random "family" vocals + + kill(sFamSounds .t=seq) + kill(sBankerRvF .t=seq) + ani(- sNoDealLED) + + kill(press_accept) + kill(prss_accpt_l) + kill(deal) + + fc(fcDondFadeOut bank_tix) + fc(fcDondFadeOut bank_coup) + kill(prev_tix) + kill(Prev_coup) + + kill(prevoffer_bar) kill(prevoffer_bar) kill(prevoffer_bar) + kill(prev_offer) + + sound(249) // <- end mixed yelling + sound(201) // <- play general applause + + fc(fcDondUpdateBankerText 0) + + create(nodeal_rotate1 .f=d2 .lb) + vidplay(nodeal_rotate1 1) + viddone(nodeal_rotate1 sCNDFdone) + + fc(fcDondSend prss_cntn_ 0) + + // - so some funky effects with the no deal button + + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 1) + + sleep(10) + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + + sleep(10) + create(nodeal .f=d2 .lb .v .s=sPrompt) + bin(mv 2 0) send($2 3) + +) + +// --------------------------------------------- + +seq sCNDFdone ( + + start() + + vidstop(nodeal_rotate1) + + fc(fcDondFadeOut press_accept) + fc(fcDondFadeOut prss_accpt_l) + fc(fcDondFadeOut press_continue) + fc(fcDondFadeOut prss_cntn_) + fc(fcDondFadeOut deal) + fc(fcDondFadeOut nodeal) + + //sleep(40) + sleep(140) + + // - "now... lets open your case" + + ani(- sFinalPrompt) + + sound(374) + + sleep(120) + sleep(40) + + ani(- closeBankerF) + ani(- finalCaseReveal) +) + +// --------------------------------------------- +// sSelectButton +// +// - the animation sequence responsible for the +// "deal" and "no deal" buttons + +seq sSelectButton ( + +alloc(2) +signals(3) +signal(0 - blink - ) +signal(1 - flashOn - ) +signal(2 - flashOff - ) + + start() + obj(ot) + +wait: + sleep(0) + +blink: // <- signal 0 + + br(.n $1 blinkStartOn) + +blinkStartOff: + bin(si 0 24) + br(blinkLoop) + +blinkStartOn: + bin(si 0 23) + br(blinkLoop) + +blinkLoop: + + obj(ot) + sleep(2) + bin(ai 0 -1) + br(.n $0 blinkLoop) + br(wait) + +flashOn: // <- signal 1 + obj(on) + bin(si 1 1) // <- $1 = am i on? + br(wait) + +flashOff: + obj(of) + bin(si 1 0) + br(wait) +) + +// --------------------------------------------- +// pushBarsOut + +seq pushBarsOut ( + + start() + + fc(fcDondSend tick_001 0) fc(fcDondSend tick_unlit_001 0) + fc(fcDondSend tick_002 0) fc(fcDondSend tick_unlit_002 0) + fc(fcDondSend tick_003 0) fc(fcDondSend tick_unlit_003 0) + fc(fcDondSend tick_004 0) fc(fcDondSend tick_unlit_004 0) + fc(fcDondSend tick_005 0) fc(fcDondSend tick_unlit_005 0) + fc(fcDondSend tick_006 0) fc(fcDondSend tick_unlit_006 0) + fc(fcDondSend tick_007 0) fc(fcDondSend tick_unlit_007 0) + fc(fcDondSend tick_008 0) fc(fcDondSend tick_unlit_008 0) + fc(fcDondSend ticket_signL 0) + fc(fcDondSend coup_signL 0) + + fc(fcDondSend tick_009 1) fc(fcDondSend tick_unlit_009 1) + fc(fcDondSend tick_0010 1) fc(fcDondSend tick_unlit_0010 1) + fc(fcDondSend tick_0011 1) fc(fcDondSend tick_unlit_0011 1) + fc(fcDondSend tick_0012 1) fc(fcDondSend tick_unlit_0012 1) + fc(fcDondSend tick_0013 1) fc(fcDondSend tick_unlit_0013 1) + fc(fcDondSend tick_0014 1) fc(fcDondSend tick_unlit_0014 1) + fc(fcDondSend tick_0015 1) fc(fcDondSend tick_unlit_0015 1) + fc(fcDondSend tick_0016 1) fc(fcDondSend tick_unlit_0016 1) + fc(fcDondSend ticket_signR 1) + fc(fcDondSend coup_signR 1) + + return(); +) + +// --------------------------------------------- +// slideBarsOut + +seq slideBarsOut ( + + start() + + fc(fcDondSend ticket_signL 3) fc(fcDondSend coup_signL 3) + fc(fcDondSend ticket_signR 2) fc(fcDondSend coup_signR 2) + sleep(2) + + fc(fcDondSend tick_001 3) fc(fcDondSend tick_unlit_001 3) + fc(fcDondSend tick_009 2) fc(fcDondSend tick_unlit_009 2) + sleep(2) + + fc(fcDondSend tick_002 3) fc(fcDondSend tick_unlit_002 3) + fc(fcDondSend tick_0010 2) fc(fcDondSend tick_unlit_0010 2) + sleep(2) + + fc(fcDondSend tick_003 3) fc(fcDondSend tick_unlit_003 3) + fc(fcDondSend tick_0011 2) fc(fcDondSend tick_unlit_0011 2) + sleep(2) + + fc(fcDondSend tick_004 3) fc(fcDondSend tick_unlit_004 3) + fc(fcDondSend tick_0012 2) fc(fcDondSend tick_unlit_0012 2) + sleep(2) + + fc(fcDondSend tick_005 3) fc(fcDondSend tick_unlit_005 3) + fc(fcDondSend tick_0013 2) fc(fcDondSend tick_unlit_0013 2) + sleep(2) + + fc(fcDondSend tick_006 3) fc(fcDondSend tick_unlit_006 3) + fc(fcDondSend tick_0014 2) fc(fcDondSend tick_unlit_0014 2) + sleep(2) + + fc(fcDondSend tick_007 3) fc(fcDondSend tick_unlit_007 3) + fc(fcDondSend tick_0015 2) fc(fcDondSend tick_unlit_0015 2) + sleep(2) + + fc(fcDondSend tick_008 3) fc(fcDondSend tick_unlit_008 3) + fc(fcDondSend tick_0016 2) fc(fcDondSend tick_unlit_0016 2) + + return(); +) +// --------------------------------------------- + +seq slideBarsIn ( + + start() + + ani(- slideBarsInK) + + fc(fcDondSend ticket_signL 2) fc(fcDondSend coup_signL 2) + fc(fcDondSend ticket_signR 3) fc(fcDondSend coup_signR 3) + sleep(2) + + fc(fcDondSend tick_001 2) fc(fcDondSend tick_unlit_001 2) + fc(fcDondSend tick_009 3) fc(fcDondSend tick_unlit_009 3) + sleep(2) + + fc(fcDondSend tick_002 2) fc(fcDondSend tick_unlit_002 2) + fc(fcDondSend tick_0010 3) fc(fcDondSend tick_unlit_0010 3) + sleep(2) + + fc(fcDondSend tick_003 2) fc(fcDondSend tick_unlit_003 2) + fc(fcDondSend tick_0011 3) fc(fcDondSend tick_unlit_0011 3) + sleep(2) + + fc(fcDondSend tick_004 2) fc(fcDondSend tick_unlit_004 2) + fc(fcDondSend tick_0012 3) fc(fcDondSend tick_unlit_0012 3) + sleep(2) + + fc(fcDondSend tick_005 2) fc(fcDondSend tick_unlit_005 2) + fc(fcDondSend tick_0013 3) fc(fcDondSend tick_unlit_0013 3) + sleep(2) + + fc(fcDondSend tick_006 2) fc(fcDondSend tick_unlit_006 2) + fc(fcDondSend tick_0014 3) fc(fcDondSend tick_unlit_0014 3) + sleep(2) + + fc(fcDondSend tick_007 2) fc(fcDondSend tick_unlit_007 2) + fc(fcDondSend tick_0015 3) fc(fcDondSend tick_unlit_0015 3) + sleep(2) + + fc(fcDondSend tick_008 2) fc(fcDondSend tick_unlit_008 2) + fc(fcDondSend tick_0016 3) fc(fcDondSend tick_unlit_0016 3) + + return(); +) + +seq slideBarsInK ( + +alloc(4) + + start() + sleep(-tap 140) + kill(slideBarsIn .t=seq) + + mark(bgmrk) + + kill(tick_001) create(tick_001 .f=d2 .la .v .s=barAnim) + kill(tick_002) create(tick_002 .f=d2 .la .v .s=barAnim) + kill(tick_003) create(tick_003 .f=d2 .la .v .s=barAnim) + kill(tick_004) create(tick_004 .f=d2 .la .v .s=barAnim) + kill(tick_005) create(tick_005 .f=d2 .la .v .s=barAnim) + kill(tick_006) create(tick_006 .f=d2 .la .v .s=barAnim) + kill(tick_007) create(tick_007 .f=d2 .la .v .s=barAnim) + kill(tick_008) create(tick_008 .f=d2 .la .v .s=barAnim) + kill(tick_009) create(tick_009 .f=d2 .la .v .s=barAnim) + kill(tick_0010) create(tick_0010 .f=d2 .la .v .s=barAnim) + kill(tick_0011) create(tick_0011 .f=d2 .la .v .s=barAnim) + kill(tick_0012) create(tick_0012 .f=d2 .la .v .s=barAnim) + kill(tick_0013) create(tick_0013 .f=d2 .la .v .s=barAnim) + kill(tick_0014) create(tick_0014 .f=d2 .la .v .s=barAnim) + kill(tick_0015) create(tick_0015 .f=d2 .la .v .s=barAnim) + kill(tick_0016) create(tick_0016 .f=d2 .la .v .s=barAnim) + + kill(tick_unlit_001) create(tick_unlit_001 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_002) create(tick_unlit_002 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_003) create(tick_unlit_003 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_004) create(tick_unlit_004 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_005) create(tick_unlit_005 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_006) create(tick_unlit_006 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_007) create(tick_unlit_007 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_008) create(tick_unlit_008 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_009) create(tick_unlit_009 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0010) create(tick_unlit_0010 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0011) create(tick_unlit_0011 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0012) create(tick_unlit_0012 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0013) create(tick_unlit_0013 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0014) create(tick_unlit_0014 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0015) create(tick_unlit_0015 .f=d2 .la .v .s=barAnim) + kill(tick_unlit_0016) create(tick_unlit_0016 .f=d2 .la .v .s=barAnim) + + fc(fcDondAskForFun $0) + br(.n $0 prizeDone) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + + kill(ticket_sign*) + create(ticket_signL .f=d2 .la .v .s=barAnim) + create(ticket_signR .f=d2 .la .v .s=barAnim) + br(prizeDone) + +coupons: + + kill(coup_sign*) + create(coup_signL .f=d2 .la .v .s=barAnim) + create(coup_signR .f=d2 .la .v .s=barAnim) + +prizeDone: + +) + + +// --------------------------------------------- +// barAnim +// +// - this animation sequence is attached to each +// of the "value bars" at the sides of the +// screen. + +seq barAnim ( + +alloc(4) +signals(7) +signal(0 - pushLeft - ) +signal(1 - pushRight - ) +signal(2 - slideRight - ) +signal(3 - slideLeft - ) +signal(4 - flash - ) +signal(5 - turnOff - ) +signal(6 - turnOn - ) + + start() +barAnimStart: + sleep(0) + +// <---- signal 0 +pushLeft: + obj(xq=-30.0) + br(barAnimStart) + +// <---- signal 1 +pushRight: + obj(xq=30.0) + br(barAnimStart) + +// <---- signal 2 +slideRight: + bin(si 0 30) +slideRightLoop: + sleep(1) + obj(xq=1) + bin(ai 0 -1) + br(.n $0 slideRightLoop) + br(barAnimStart) + +// <---- signal 3 +slideLeft: + bin(si 0 30) +slideLeftLoop: + sleep(1) + obj(xq=-1) + bin(ai 0 -1) + br(.n $0 slideLeftLoop) + br(barAnimStart) + +// <---- signal 4 +flash: + + // - flash the object off and on for a bit + + obj(ot) sleep(2) + obj(ot) sleep(2) + obj(ot) sleep(2) + obj(ot) sleep(2) + + // - next, scale up the image. (another process is + // fading this out at the same time) + // note that a bit of correction is done because + // the bars do not have a centered pivot point. + + bin(si 0 40) + obj(v0) +flashLoop: + sleep(1) + // - scale/xq/yr ratio for "correct" scaling: 0.01/0.12/0.03 + + fc(fcScale 0.02 1) + obj(xq=0.24) + obj(yq=0.05) + bin(ai 0 -1) + br(.n $0 flashLoop) + br(barAnimStart) + +// <---- signal 5 +turnOff: + obj(of) + br(barAnimStart) + +// <---- signal 6 +turnOn: + obj(on) + br(barAnimStart) +) + +// --------------------------------------------- +// showIntroVideo + +seq showIntroVideo ( + +alloc(4) + start() + + fc(fcDondSetCorrectVol) + + kill(press_start) + kill(press_deal) + + kill(frame) + kill(frame2) + + //create(textbar .f=d2 .lb) + //create(chooseyourcase .f=d2 .lb) + + // - play the title video, and tell it to call + // onTitleDone when it has finished playing + + mark(fntZ) + create(titleVideo .f=d2 .lb) + + vidplay(titleVideo 0) + + fc(fcDondAskSkillGame $0) + br(.z $0 skipShuffle) + viddone(titleVideo onTitleDoneSH) + br(done) +skipShuffle: + viddone(titleVideo onTitleDone) +done: + + vidstop(bgVideo) + kill(bgVideo) + kill(main_logo*) + kill(doubledeal) + kill(dj_logo1) + kill(models_*) +) + +// --------------------------------------------- +// onTitleDone + +seq onTitleDone ( + +alloc(4) + + start() + + fc(fcDondInput 0) + + // - change the cabinet color to blue + + fc(fcDondAnimLED 0) // <- fade blue in + + // - create the background, models, cases and other + // elements + + //ani(- createMainScene) + + // - stop the video and fade it away + + vidstop(titleVideo) + ani(- createMainScene) + sleep(1) + fc(fcDondFadeOut titleVideo) + + // - tell the code we're done with the title + + fc(fcDondOnTitleDone) + + // - wait for a bit while the tile video fades away, then + // slide in the value bars + + sleep(20) + //ani(- slideBarsIn) + + // - allow a bit of time for the value bars to slide into + // the scene + + sleep(60) + + fc(fcDondInput 1) + + // - check to see if the player is holding down a button. + // if so, we will skip the personal case prompt + + //fc(fcDondAskSwitchCount $0) + //br(.n $0 skipPrompt) + + ani(- sPCasePrompt) + +//skipPrompt: + + // - begin the countdown timer + + //fc(fcDondStartTimer 11.0) + +) + +// --------------------------------------------- + +seq sPrompt ( + +alloc(4) +signals(7) +signal(0 - fadeIn - ) +signal(1 - fadeInScaleUp - ) +signal(2 - fadeOut - ) +signal(3 - fadeOutScaleUp - ) +signal(4 - fadeGentleGrow - ) +signal(5 - fadeInReg - ) +signal(6 - fadeInGirl - ) + + start() +wait: + sleep(0) + +// <---- signal 0 +fadeIn: + fc(fcBlend 0 0) + //fc(fcScale 1.5 0) + bin(si 0 32) +fadeInLoop: + sleep(1) + fc(fcBlend 8 1) + //fc(fcScale -0.015625 1) + bin(ai 0 -1) + br(.n $0 fadeInLoop) + fc(fcBlend 255 0) + +zoomMore: + sleep(1) + fc(fcScale 0.00075 1) + // - keep zooming up gently until we die! + br(zoomMore) + + br(wait) + +// <---- signal 1 +fadeInScaleUp: + fc(fcBlend 128 0) + fc(fcScale 1.0 0) + bin(si 0 32) +scaleUpLoop: + sleep(1) + fc(fcBlend -4 1) + fc(fcScale 0.01 1) + bin(ai 0 -1) + br(.n $0 scaleUpLoop) + fc(fcBlend 0 0) + br(wait) + +// <---- signal 2 +fadeOut: + fc(fcBlend 255 0) + bin(si 0 32) +fadeOutLoop: + sleep(1) + fc(fcBlend -8 1) + bin(ai 0 -1) + br(.n $0 fadeOutLoop) + fc(fcBlend 0 0) + + find(l prime -) bin(mv 0 0) + kill($0) + + br(wait) + +// <---- signal 3 +fadeOutScaleUp: + fc(fcBlend 128 0) + fc(fcScale 1.0 0) + bin(si 0 32) +scaleUpLoop2: + sleep(1) + fc(fcBlend -4 1) + fc(fcScale 0.02 1) + bin(ai 0 -1) + br(.n $0 scaleUpLoop2) + fc(fcBlend 0 0) + br(wait) + +// <---- signal 4 +fadeGentleGrow: + fc(fcBlend 255 0) + //bin(si 0 32) + bin(si 0 16) +fadeOutGGLoop: + sleep(1) + //fc(fcBlend -8 1) + fc(fcBlend -16 1) + //fc(fcScale 0.00075 1) + fc(fcScale 0.00150 1) + bin(ai 0 -1) + br(.n $0 fadeOutGGLoop) + fc(fcBlend 0 0) + + find(l prime -) bin(mv 0 0) + kill($0) + + br(wait) + +// <---- signal 5 +fadeInReg: + fc(fcBlend 0 0) + bin(si 0 32) +fadeInRLoop: + sleep(1) + fc(fcBlend 8 1) + bin(ai 0 -1) + br(.n $0 fadeInRLoop) + fc(fcBlend 255 0) + br(wait) + +// <---- signal 6 +fadeInGirl: + fc(fcBlend 0 0) + //fc(fcScale 1.5 0) + bin(si 0 32) +fadeInGirlLoop: + sleep(1) + fc(fcBlend 8 1) + fc(fcScale 0.0001 1) + bin(ai 0 -1) + br(.n $0 fadeInGirlLoop) + fc(fcBlend 255 0) + +zoomGMore: + sleep(1) + fc(fcScale 0.0001 1) + // - keep zooming up gently until we die! + br(zoomGMore) + + br(wait) +) + +// --------------------------------------------- + +seq startWideAnim ( + +alloc(4) + start() + + // - kill off any objects we don't want to co-exist + // with the animating girls + + kill(persnl_prompt1) + kill(case5_prompt) + kill(case4_prompt) + kill(case3_prompt) + kill(case2_prompt) + kill(case1_prompt) + kill(final_prompt) + + vidplay(model_01) vidplay(model_02) vidplay(model_03) vidplay(model_04) + vidplay(model_05) vidplay(model_06) vidplay(model_07) vidplay(model_08) + vidplay(model_09) vidplay(model_010) vidplay(model_011) vidplay(model_012) + vidplay(model_013) vidplay(model_014) vidplay(model_015) vidplay(model_016) +) + +// --------------------------------------------- + +seq stopWideAnim ( + + start() + + vidstop(model_01) vidstop(model_02) vidstop(model_03) vidstop(model_04) + vidstop(model_05) vidstop(model_06) vidstop(model_07) vidstop(model_08) + vidstop(model_09) vidstop(model_010) vidstop(model_011) vidstop(model_012) + vidstop(model_013) vidstop(model_014) vidstop(model_015) vidstop(model_016) + + vidready(model_01) vidready(model_02) vidready(model_03) vidready(model_04) + vidready(model_05) vidready(model_06) vidready(model_07) vidready(model_08) + vidready(model_09) vidready(model_010) vidready(model_011) vidready(model_012) + vidready(model_013) vidready(model_014) vidready(model_015) vidready(model_016) + + vidplay(model_01) vidplay(model_02) vidplay(model_03) vidplay(model_04) + vidplay(model_05) vidplay(model_06) vidplay(model_07) vidplay(model_08) + vidplay(model_09) vidplay(model_010) vidplay(model_011) vidplay(model_012) + vidplay(model_013) vidplay(model_014) vidplay(model_015) vidplay(model_016) + + vidready(model_01) vidready(model_02) vidready(model_03) vidready(model_04) + vidready(model_05) vidready(model_06) vidready(model_07) vidready(model_08) + vidready(model_09) vidready(model_010) vidready(model_011) vidready(model_012) + vidready(model_013) vidready(model_014) vidready(model_015) vidready(model_016) +) + +// --------------------------------------------- +// showChoiceLeft + +seq showChoiceLeft ( + +alloc(4) + + start() + + mark(bgmrk) + + // - if there is a pending buffered input, don't + // show the number of choices left + + fc(fcDondAskBufferedInput $3) + br(.n $3 dontShow) + //fc(fcDondAskTapFlag $3) + //br(.n $3 dontShow) + + // - if there are no choices left, we don't show + // anything + + fc(fcDondAskChoicesLeft $0) + br(.n $0 showInfo) + br(dontShow) + +showInfo: + set(tag 0) + create(textbar .f=d2 .lb) + + // - if there is only one choice left, use a different + // text message. + + bin(ai 0 -1) + br(.n $0 usePlural) + br(useSingular) + +usePlural: + create(choose_cases .f=d2 .lb) + br(showDone) + +useSingular: + create(choose_1_case .f=d2 .lb) + br(showDone) + +showDone: + fc(fcDondUpdateCasesLeftText 1) + +dontShow: +) + +// --------------------------------------------- +// firstCaseReveal +// +// - show a closeup shot of the girl bringing +// down the case to the user. + +seq firstCaseReveal ( + +alloc(4) + start() + + fc(fcDondInput 0) + + ani(- stopWideAnim) + + // - remove the "choose your case" message from + // the screen + + kill(textbar) + kill(chooseyourcase) + + // - start the animation + + ani(- sPCaseTitle) + + fc(fcDondPlayGradedReveal) + fc(fcDondAskGradedReveal $0) + + ani(- caseRevealKF) + + sound(200) // - polite applause + + // - pause a bit before displaying the + // "this is your case" plaque + +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame * $1 $0) // $1 = video frame of object named "*" + fc(fcDondAskTapFlag $3) + br(.n $3 skipToScaleLoop) + br(.z $1 revealLoop) + +skipToScaleLoop: + fc(fcDondFirstCaseDone) + fc(fcDondAskTapFlag $3) + br(.n $3 skipToFadeOut) + + sound(201) + kill(caseRevealKF .t=seq) + sleep(-tap 200) + +skipToFadeOut: + fc(fcDondSetTapFlag 0) + + fc(fcDondFadeOut textbar_small1) + fc(fcDondFadeOut your_case_is) + fc(fcDondFadeOut bg_tight) + fc(fcDondFadeOut personl_title) + fc(fcDondFadeKillReveal) + + sleep(30) + ani(- showChoiceLeft) + + fc(fcDondInput 0) + + // - display a "choose 5 more cases" prompt + + //fc(fcDondAskSwitchCount $0) + //br(.n $0 skipPrompt) + + ani(- sCase5Prompt) + + //br(end) +//skipPrompt: +// ani(- startWideAnim) +//end: +) + +// --------------------------------------------- + +seq sFirstCaseDone ( + start() + vidstop(mr_select_16) +) + +// --------------------------------------------- + +seq barScale ( + +alloc(4) +signals(4) +signal(0 - scaleUp - ) + + start() +barScaleStart: + sleep(0) + +scaleUp: + bin(si 0 100) +scaleLoop: + sleep(1) + //obj(xs=5 ys=5) + fc(fcScale 0.01 1) + fc(fcRot 0 0 0.1 1) + bin(ai 0 -1) + br(.n $0 scaleLoop) + br(barScaleStart) +) + +// --------------------------------------------- +// caseRevealKF +// +// - called when a case has begun to be revealed. +// it is killed as soon as the value is visible. + +seq caseRevealKF ( + +alloc(4) + + start() + sleep(-tap 1000) + find(o disp fs_*) bin(mv 2 0) + br(.z $2 dontMove) + obj(ob=$2 on) +dontMove: + find(o disp mr_*) bin(mv 1 0) + br(.z $1 dontKill) + kill($1) +dontKill: + br(.z $2 dontTap) + fc(fcDondSetTapFlag 1) +dontTap: +) + +// --------------------------------------------- +// caseReveal +// +// - show a closeup shot of the girl opening up +// the case to reveal the ticket ammount + +seq caseReveal ( + +alloc(4) + + start() + fc(fcDondInput 0) + + ani(- stopWideAnim) + + // - remove the "choose X cases" message + + kill(textbar) + kill(choose_cases) + kill(choose_1_case) + fc(fcDondUpdateCasesLeftText 0) // 0 = remove the text + + sound(200) + + mark(bgmrk) + + fc(fcDondPlayGradedReveal) + fc(fcDondAskGradedReveal $0) // $0 = number of frames to wait + + // - if the KF sequence detects a tapout, we + // will replace the video with a still frame. + + ani(- caseRevealKF) + + // - "open the case" + + sleep(40) + fc(fcDondPlayCaseOpenVocal 0) + +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame * $1 $0) // $1 = video frame of object named "*" + + fc(fcDondAskTapFlag $3) + br(.n $3 skipToScaleLoop) + br(.z $1 revealLoop) + + fc(fcDondPlayGradedAudio) + + // - start at 100% shrink and loop downwards to + // 0% shrink. this causes the displayed value + // to zoom out of the case + +skipToScaleLoop: + bin(si 0 100) // <- $0 = 100 +scaleLoop: + fc(fcDondAskTapFlag $3) + br(.n $3 scaleLoopDone) + sleep(1) + fc(fcDondDrawCaseValue $0 52.0 18.0) // <- shrinkRate, xpos, ypos + bin(ai 0 -10) // <- $0 = $0 - 10; + br(.n $0 scaleLoop) // <- if ($0 != 0) goto scaleLoop + +scaleLoopDone: + bin(si 0 0) + fc(fcDondDrawCaseValue $0 52.0 18.0) + + kill(caseRevealKF .t=seq) + + // - create the "ticket" label + + fc(fcDondAskForFun $0) + br(.n $0 noPrizeLabel) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + create(c_ticket .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) + br(prizeDone) +coupons: + create(c_coupon .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) +prizeDone: + obj(ob=$2 xq=52.0) + obj(ob=$2 yq=17.0) +noPrizeLabel: + + // - pause for a bit, then update the value + // bars + + sleep(10) + + fc(fcDondRedrawValues) + fc(fcDondPlayGradedCrowdAudio) + + ani(- cRevReact) + + // - get rid of the video kill function + + kill(caseRevealKF .t=seq) + + fc(fcDondAskTapFlag $3) + br(.n $3 skipToFadeOut) + + // - pause again, then get out of the scene + + sleep(-tap 190) + +skipToFadeOut: + sleep(10) + + // - if the next girl is ready to play, we will + // not fade out the bg_tight image + + fc(fcDondAskBufferedInput $3) + br(.n $3 buffered) + + fc(fcDondFadeOut bg_tight) +buffered: + + // - replace these fadeouts/kills with a function that + // kills the specific animation we are playing at the time + + fc(fcDondFadeKillReveal) + + // - get rid of the "tickets" label + + kill($2) + + // - tell the code we are done revealing + + fc(fcDondAskBufferedInput $3) + fc(fcDondCaseRevealDone) + + // - if we are doing a buffered input, we will + // skip to the end of the sequence + + //fc(fcDondAskBufferedInput $3) + br(.n $3 noTimer) + + sleep(30) + ani(- showChoiceLeft) + + // - if the user still has a case to choose, + // we will startup the countdown timer + + sleep(10) + fc(fcDondAskChoicesLeft $0) + br(.z $0 noTimer) + + ani(- startWideAnim) + + fc(fcDondInput 1) + fc(fcDondStartTimer 11.0) + br(end) + +noTimer: + + fc(fcDondSetTapFlag 0) + +end: + fc(fcDondSetTapFlag 0) +) + +// --------------------------------------------- + +seq cRevReact ( + start() + sleep(40) + fc(fcDondPlayCaseOpenVocal 1) +) + +// --------------------------------------------- +// finalCaseReveal + +seq finalCaseReveal ( + +alloc(4) + + start() + + ani(- stopWideAnim) + + kill(final_prompt) + + //sound(51) // <- play "choose deal" music + + // - get rid of the player's case + + //kill(pCase_01) kill(pCase_02) kill(pCase_03) kill(pCase_04) + //kill(pCase_05) kill(pCase_06) kill(pCase_07) kill(pCase_08) + //kill(pCase_09) kill(pCase_10) kill(pCase_11) kill(pCase_12) + //kill(pCase_13) kill(pCase_14) kill(pCase_15) kill(pCase_16) + //kill(persnl_case) + + //ani(- slideBarsOut) + + mark(bgmrk) + create(bg_tight .f=d2 .lb) + + // - case opening buildup sound + + sound(11) + + fc(fcDondPlayGradedReveal) + fc(fcDondAskGradedReveal $0) // $0 = number of frames to wait + + ani(- sPCaseTitle) + fc(fcDondPlayPCaseRV) + mark(bgmrk) + +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame * $1 $0) // $1 = video frame of object named "*" + br(.z $1 revealLoop) + + fc(fcDondPlayGradedAudio) + + bin(si 0 100) // <- $0 = 100 +scaleLoop: + sleep(1) + fc(fcDondDrawCaseValue $0 52.0 18.0)// <- shrinkRate, xpos, ypos + bin(ai 0 -5) // <- $0 = $0 - 10; + br(.n $0 scaleLoop) // <- if ($0 != 0) goto scaleLoop + + // - create the "ticket" label + + fc(fcDondAskForFun $0) + br(.n $0 noPrizeLabel) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + create(c_ticket .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) + br(prizeDone) +coupons: + create(c_coupon .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) +prizeDone: + obj(ob=$2 xq=52.0) + obj(ob=$2 yq=17.0) +noPrizeLabel: + + fc(fcDondRedrawValues) + fc(fcDondPlayGradedCrowdAudio) + + sound(53) // <- play "choose deal wr" music + + sleep(100) + sound(201) // <- general applause + + // ..... + + sleep(100) + + // - begin the game over music + + //sound(53) + + fc(fcDondFadeOut personl_title) + + ani(- sBankerAF) + + fc(fcDondFadeKillReveal) + kill($2) // - remove the tickets label + kill(bg_tight) + + fc(fcDondSend bg_banker_w1 3) + sleep(2) + fc(fcDondSend bg_banker_w2 3) + + fc(fcDondDoGameOver) + fc(fcDondShowTicketsWon 1) + ani(- sHooplahLED) + + sleep(80) + fc(fcDondAskGoodGame $0) + br(.z $0 notGood) + sound(371) // <- "what a great game!" +notGood: + + // .... + + sleep(200) + + ani(- createWRS) + + kill(bckgrnd_bnk) + kill(background_blue) + kill(bg_banker_*) + vidstop(bank2_anim) + kill(bank2_anim) + + kill(banker_offer1) + kill(deal_rotate1) + + // - place the game in DOND_WIDE_REVEAL mode + + fc(fcDondSetGameState 9) + + // - remove the "YOU WON XX TICKETS" text + + fc(fcDondShowTicketsWon 0) + + ani(- sWRSnodeal) + +// sleep(200) +// +// fc(fcDondFadeOut ticket_signL) +// fc(fcDondFadeOut ticket_signR) +// fc(fcDondFadeOut coup_signL) +// fc(fcDondFadeOut coup_signR) +// +// //ani(- slideBarsOut) +// ani(- sCollect) +// +// sleep(40) +// +// fc(fcDondFadeOut deal_rotate1) +// kill(tick*) +// kill(coup*) +// +// ani(- closeBanker) +) + +// --------------------------------------------- + +seq atstart ( +start() + fc(fcAtStart) +) + +seq gameFrame ( +start() +mark(cam3) +set(tag 3) +create(gframe.gframe .f=d2 .lb) +set(tag 1) +) + +seq credits ( +alloc(4) +start() +credLoop: + fc(fcCredits) + sleep(1) + br(credLoop) +) + +seq msgSeq( +alloc(2) +start() + sleep(30) + find(l prime -) bin(mv 0 0) + kill($0) +) + + +// ani(- $str1) + + +// EOF \ No newline at end of file diff --git a/donddata/cf/shuffle.cf b/donddata/cf/shuffle.cf new file mode 100644 index 0000000..d1b8402 --- /dev/null +++ b/donddata/cf/shuffle.cf @@ -0,0 +1,1239 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +seq onTitleDoneSH ( + +alloc(8) + start() + + fc(fcDondInput 0) + + sound(99) + sound(54) + + fc(fcDondShCan -4) // hide case values + fc(fcDondShCan -6) // hide case labels + + // - stop and fade out the title video + + vidstop(titleVideo) + + mark(fntA) + create(bgVideo .f=d2 .lb) + vidready(bgVideo) + //vidplay(bgVideo) + + ani(- shMakeCases) + + fc(fcDondFadeOut titleVideo) + + // - place the game in SHUFFLE GAME mode + + fc(fcDondSetGameState 12) + + sleep(50) + + // - display a nice prompt telling the player + // what to do + + ani(- sFollowPrompt) + sleep(250) + + fc(fcDondShCan -2) // reset case positions + +beginTest: + + // - open the case + + bin(si 0 14) + vidplay(shuffle001 0) +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame shc_fwd0 $1 $0) + br(.z $1 revealLoop) + vidstop(shuffle001) + + // - hackey re-use. -3 means: show the case values! + fc(fcDondShCan -3) + sleep(150) + // - -4 means: don't show the values! + fc(fcDondShCan -4) + + // - close the case + + bin(si 0 30) + vidplay(shuffle001 1) + viddone(shuffle001 shvidDone) +revealLoop2: + sleep(1) + fc(fcDondAskVideoFrame shc_fwd0 $1 $0) + br(.z $1 revealLoop2) + vidstop(shuffle001) + + sound(16) + + sleep(30) + + ani(- animShuffle) + +// bin(si 0 15) +// vidplay(shuffle001 1) +//revealLoop3: +// sleep(1) +// fc(fcDondAskVideoFrame * $1 $0) +// br(.z $1 revealLoop3) +// vidstop(shuffle001) +// fc(fcDondShCan -3) + +) + +// --------------------------------------------- + +seq shvidDone( + start() + vidstop(shuffle001) +) + +// --------------------------------------------- + +seq animShuffleDone( + +alloc(4) + start() + + fc(fcDondAskHFA $1) + br(.n $1 doHFA) + + fc(fcDondShCan -5) // show case labels + sleep(150) + + // ///////////////////////////////////////////////////// + // - transition back to the main game + + ani(- createMainScene) + sleep(1) + + mark(fntZ) + create(black_bg .f=d2 .la .v .s=sBlackBg) + bin(mv 2 0) + + vidstop(bgVideo) + fc(fcDondFadeOut bgVideo) + fc(fcDondFadeOut shuffle001) fc(fcDondFadeOut shuffle002) + fc(fcDondFadeOut shuffle003) fc(fcDondFadeOut shuffle004) + fc(fcDondFadeOut shuffle005) fc(fcDondFadeOut shuffle006) + fc(fcDondFadeOut shuffle007) fc(fcDondFadeOut shuffle008) + fc(fcDondFadeOut shuffle009) fc(fcDondFadeOut shuffle0010) + fc(fcDondFadeOut shuffle0011) fc(fcDondFadeOut shuffle0012) + fc(fcDondFadeOut shuffle0013) fc(fcDondFadeOut shuffle0014) + fc(fcDondFadeOut shuffle0015) fc(fcDondFadeOut shuffle0016) + + // - tell the code we're done with the title + + fc(fcDondOnTitleDone) + + // - wait for a bit while the tile video fades away, then + // slide in the value bars + + sleep(20) + + send($2 3) + + // - allow a bit of time for the value bars to slide into + // the scene + + sleep(60) + + fc(fcDondInput 1) + + ani(- sPCasePrompt) + br(done) + +doHFA: + ani(- sHFAmode) +done: +) + +// --------------------------------------------- + +seq sHFAmode( +alloc(4) + start() + + sleep(-tap 1000) + + // - hide the case labels + + fc(fcDondShCan -6) + + bin(si 0 14) + vidready(shuffle001) + vidplay(shuffle001 1) +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame shc_fwd0 $1 $0) + br(.z $1 revealLoop) + vidstop(shuffle001) + + // - show the case values + + fc(fcDondShCan -3) + + sleep(50) + sleep(-tap 1000) + + // - exit back out to the coin in page + fc(fcDondSetGameState 99) +) + +// --------------------------------------------- +// $0 = which shuffle to play +// $1 = how many shuffles to play +// $2 = which shuffle type to play +// 0: standard +// 1: single-swap + +seq animShuffle( + +alloc(4) + start() + + // - let's do some preliminary shuffles to + // "warm the player up" + + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) +prelim_1: + sleep(1) + fc(fcDondAskShCaseAnim $0) + br(.z $0 prelim_1) + sleep(10) + + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) +prelim_2: + sleep(1) + fc(fcDondAskShCaseAnim $0) + br(.z $0 prelim_2) + sleep(10) + + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) +prelim_3: + sleep(1) + fc(fcDondAskShCaseAnim $0) + br(.z $0 prelim_3) + sleep(10) + + // - begin the rest of the shuffles + + bin(si 1 44) + +loop: + bin(ai 1 -1) + br(.z $1 done) + + fc(fcRandNum $2 4) + br(.t $2 reg_swap one_swap hard_swap hard_swap) + + +reg_swap: + fc(fcRandNum $0 14) + br(.t $0 circle circle conveyor conveyor conveyor conveyor swirl swirl swirl scramble scramble overlap1 overlap2 overlap3) + +one_swap: + fc(fcRandNum $0 6) + br(.t $0 swap_01 swap_02 swap_03 swap_04 overlap1 overlap2 overlap3) + +hard_swap: + fc(fcRandNum $0 3) + br(.t $0 overlap1 overlap2 overlap3) + +// SINGLE SWAPS /////////////////////// + +swap_01: + fc(fcDondShCan 3 2 -1 -1 -1 3 2 -1 1 -1 -1 -1 0 -1 3 2) + br(pauseShort) + +swap_02: + fc(fcDondShCan -1 3 2 1 1 -1 -1 0 0 -1 1 -1 -1 -1 0 -1) + br(pauseShort) + +swap_03: + fc(fcDondShCan -1 -1 3 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1) + br(pauseShort) + +swap_04: + fc(fcDondShCan -1 -1 -1 -1 -1 1 1 -1 -1 0 0 -1 -1 -1 -1 -1) + br(pauseShort) + +// REGULAR SWAPS ////////////////////// + +circle: + fc(fcDondShCan 1 2 2 2 1 -1 -1 0 1 -1 -1 0 3 3 3 0) + br(pauseShort) + +conveyor: + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + br(pauseShort) + +swirl: + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + br(pauseShort) + +scramble: + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + br(pauseShort) + +overlap1: + fc(fcDondShCan 3 2 1 2 3 2 1 0 3 2 1 0 3 2 3 0) + br(pauseShort) + +overlap2: + fc(fcDondShCan 1 1 1 1 0 0 0 0 3 2 3 2 3 2 3 2) + br(pauseShort) + +overlap3: + fc(fcDondShCan 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0) + br(pauseShort) + +pauseShort: + sleep(1) + fc(fcDondAskShCaseAnim $0) + br(.z $0 pauseShort) + br(loop) + +done: + + ani(- animShuffleDone) +) + +// --------------------------------------------- + +seq shuffleCases( +alloc(4) + start() + + fc(fcDondShCan -2) + +loop: + + // - conveyor belt + + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(30) + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(30) + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(30) + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(30) + + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(14) + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(14) + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(14) + fc(fcDondShCan 1 2 2 2 3 3 3 0 1 2 2 2 3 3 3 0) + sleep(14) + + // - overlap + + fc(fcDondShCan 3 2 1 2 3 2 1 0 3 2 1 0 3 2 3 0) + sleep(14) + + // - overlap #2 + + fc(fcDondShCan 1 1 1 1 0 0 0 0 3 2 3 2 3 2 3 2) + sleep(14) + + // - overlap #3 + + fc(fcDondShCan 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0) + sleep(14) + + // - swirl around + + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + sleep(14) + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + sleep(14) + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + sleep(14) + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + sleep(14) + + // - overlap #3 + + fc(fcDondShCan 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0) + sleep(14) + + // - overlap #2 + + fc(fcDondShCan 1 1 1 1 0 0 0 0 3 2 3 2 3 2 3 2) + sleep(14) + + // - overlap + + fc(fcDondShCan 3 2 1 2 3 2 1 0 3 2 1 0 3 2 3 0) + sleep(14) + + // - scramble + + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + sleep(14) + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + sleep(14) + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + sleep(14) + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + sleep(14) + + // - overlap + + fc(fcDondShCan 3 2 1 2 3 2 1 0 3 2 1 0 3 2 3 0) + sleep(15) + + // - overlap #3 + + fc(fcDondShCan 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0) + sleep(14) + + // - overlap #2 + + fc(fcDondShCan 1 1 1 1 0 0 0 0 3 2 3 2 3 2 3 2) + sleep(14) + + // - swirl + scramble + + fc(fcDondShCan 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0) + sleep(14) + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + sleep(14) + fc(fcDondShCan 1 1 1 1 0 0 0 0 3 2 3 2 3 2 3 2) + sleep(14) + fc(fcDondShCan 3 2 1 2 3 2 1 0 3 2 1 0 3 2 3 0) + sleep(14) + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + sleep(14) + fc(fcDondShCan 3 3 3 1 0 1 2 1 0 3 0 1 0 2 2 2) + sleep(14) + fc(fcDondShCan 1 1 1 1 0 0 0 0 3 2 3 2 3 2 3 2) + sleep(14) + fc(fcDondShCan 3 2 1 2 3 2 1 0 3 2 1 0 3 2 3 0) + sleep(14) + fc(fcDondShCan 1 2 3 1 3 0 0 2 1 2 1 2 3 0 3 0) + sleep(14) +) + +// --------------------------------------------- + +seq shMakeCases ( + +alloc(4) + start() + + // - row #1 + + create(shuffle001 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=60 xq=30.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle002 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=60 xq=55.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle003 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=60 xq=80.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle004 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=60 xq=105.5) obj(ob=$1 xs=0.85 ys=0.85) + + // - row #2 + + create(shuffle005 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=45 xq=30.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle006 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=45 xq=55.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle007 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=45 xq=80.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle008 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=45 xq=105.5) obj(ob=$1 xs=0.85 ys=0.85) + + // - row #3 + + create(shuffle009 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=30 xq=30.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle0010 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=30 xq=55.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle0011 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=30 xq=80.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle0012 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=30 xq=105.5) obj(ob=$1 xs=0.85 ys=0.85) + + // - row #4 + + create(shuffle0013 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=15 xq=30.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle0014 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=15 xq=55.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle0015 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=15 xq=80.5) obj(ob=$1 xs=0.85 ys=0.85) + + create(shuffle0016 .f=d2 .lb .v .s=sShuffleCase) bin(mv 1 0) + obj(ob=$1 yq=15 xq=105.5) obj(ob=$1 xs=0.85 ys=0.85) + + vidplay(shuffle001) + vidstop(shuffle001) + vidready(shuffle001) +) + +// --------------------------------------------- + +seq sShuffleCase ( + +alloc(8) +signals(56) +// - 140% speed 5, 3, 5 +signal(0 - moveUpN4 - ) +signal(1 - moveDownN4 - ) +signal(2 - moveLeftN4 - ) +signal(3 - moveRightN4 - ) +// - 130% speed 6, 2.5, 4.1666 +signal(4 - moveUpN3 - ) +signal(5 - moveDownN3 - ) +signal(6 - moveLeftN3 - ) +signal(7 - moveRightN3 - ) +// - 120% speed 7, 2.1428, 3.5714 +signal(8 - moveUpN2 - ) +signal(9 - moveDownN2 - ) +signal(10 - moveLeftN2 - ) +signal(11 - moveRightN2 - ) +// - 110% speed 8, 1.875, 3.125 +signal(12 - moveUpN1 - ) +signal(13 - moveDownN1 - ) +signal(14 - moveLeftN1 - ) +signal(15 - moveRightN1 - ) +// - 100% speed 9, 1.666, 2.7777 +signal(16 - moveUp - ) +signal(17 - moveDown - ) +signal(18 - moveLeft - ) +signal(19 - moveRight - ) +// - 90% speed 11, 1.3636, 2.2727 +signal(20 - moveUp2 - ) +signal(21 - moveDown2 - ) +signal(22 - moveLeft2 - ) +signal(23 - moveRight2 - ) +// - 80% speed 13, 1.1538, 1.9230 +signal(24 - moveUp3 - ) +signal(25 - moveDown3 - ) +signal(26 - moveLeft3 - ) +signal(27 - moveRight3 - ) +// - 70% speed 15, 1.0, 1.6666 +signal(28 - moveUp4 - ) +signal(29 - moveDown4 - ) +signal(30 - moveLeft4 - ) +signal(31 - moveRight4 - ) +// - 60% speed 17, 0.8823, 1.4705 +signal(32 - moveUp5 - ) +signal(33 - moveDown5 - ) +signal(34 - moveLeft5 - ) +signal(35 - moveRight5 - ) +// - 50% speed 19, 0.7894, 1.3157 +signal(36 - moveUp6 - ) +signal(37 - moveDown6 - ) +signal(38 - moveLeft6 - ) +signal(39 - moveRight6 - ) +// - 40% speed 21, 0.7142, 1.1904 +signal(40 - moveUp7 - ) +signal(41 - moveDown7 - ) +signal(42 - moveLeft7 - ) +signal(43 - moveRight7 - ) +// - 30% speed 23, 0.6521, 1.0869 +signal(44 - moveUp8 - ) +signal(45 - moveDown8 - ) +signal(46 - moveLeft8 - ) +signal(47 - moveRight8 - ) +// - 20% speed 25, 0.6, 1.0 +signal(48 - moveUp9 - ) +signal(49 - moveDown9 - ) +signal(50 - moveLeft9 - ) +signal(51 - moveRight9 - ) +// - 10% speed 27, 0.5555, 0.9259 +signal(52 - moveUp10 - ) +signal(53 - moveDown10 - ) +signal(54 - moveLeft10 - ) +signal(55 - moveRight10 - ) + + start() +wait: + sleep(0) + +// <---- signal 0 +moveUpN4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 5) +moveUpN4Loop: + sleep(1) + obj(yq=3) + bin(ai 0 -1) + br(.n $0 moveUpN4Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 1 +moveDownN4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 5) +moveDownN4Loop: + sleep(1) + obj(yq=-3) + bin(ai 0 -1) + br(.n $0 moveDownN4Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 2 +moveLeftN4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 5) +moveLeftN4Loop: + sleep(1) + obj(xq=-5) + bin(ai 0 -1) + br(.n $0 moveLeftN4Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 3 +moveRightN4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 5) +moveRightN4Loop: + sleep(1) + obj(xq=5) + bin(ai 0 -1) + br(.n $0 moveRightN4Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 4 +moveUpN3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 6) +moveUpN3Loop: + sleep(1) + obj(yq=2.5) + bin(ai 0 -1) + br(.n $0 moveUpN3Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 5 +moveDownN3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 6) +moveDownN3Loop: + sleep(1) + obj(yq=-2.5) + bin(ai 0 -1) + br(.n $0 moveDownN3Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 6 +moveLeftN3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 6) +moveLeftN3Loop: + sleep(1) + obj(xq=-4.1666) + bin(ai 0 -1) + br(.n $0 moveLeftN3Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 7 +moveRightN3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 6) +moveRightN3Loop: + sleep(1) + obj(xq=4.1666) + bin(ai 0 -1) + br(.n $0 moveRightN3Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 8 +moveUpN2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 7) +moveUpN2Loop: + sleep(1) + obj(yq=2.1428) + bin(ai 0 -1) + br(.n $0 moveUpN2Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 9 +moveDownN2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 7) +moveDownN2Loop: + sleep(1) + obj(yq=-2.1428) + bin(ai 0 -1) + br(.n $0 moveDownN2Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 10 +moveLeftN2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 7) +moveLeftN2Loop: + sleep(1) + obj(xq=-3.5714) + bin(ai 0 -1) + br(.n $0 moveLeftN2Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 11 +moveRightN2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 7) +moveRightN2Loop: + sleep(1) + obj(xq=3.5714) + bin(ai 0 -1) + br(.n $0 moveRightN2Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 12 +moveUpN1: + fc(fcDondIncShCaseAnim 1) + bin(si 0 8) +moveUpN1Loop: + sleep(1) + obj(yq=1.875) + bin(ai 0 -1) + br(.n $0 moveUpN1Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 13 +moveDownN1: + fc(fcDondIncShCaseAnim 1) + bin(si 0 8) +moveDownN1Loop: + sleep(1) + obj(yq=-1.875) + bin(ai 0 -1) + br(.n $0 moveDownN1Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 14 +moveLeftN1: + fc(fcDondIncShCaseAnim 1) + bin(si 0 8) +moveLeftN1Loop: + sleep(1) + obj(xq=-3.125) + bin(ai 0 -1) + br(.n $0 moveLeftN1Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 15 +moveRightN1: + fc(fcDondIncShCaseAnim 1) + bin(si 0 8) +moveRightN1Loop: + sleep(1) + obj(xq=3.125) + bin(ai 0 -1) + br(.n $0 moveRightN1Loop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 0 +moveUp: + fc(fcDondIncShCaseAnim 1) + bin(si 0 9) +moveUpLoop: + sleep(1) + obj(yq=1.666666) + bin(ai 0 -1) + br(.n $0 moveUpLoop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 1 +moveDown: + fc(fcDondIncShCaseAnim 1) + bin(si 0 9) +moveDownLoop: + sleep(1) + obj(yq=-1.666666) + bin(ai 0 -1) + br(.n $0 moveDownLoop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 2 +moveLeft: + fc(fcDondIncShCaseAnim 1) + bin(si 0 9) +moveLeftLoop: + sleep(1) + obj(xq=-2.777777) + bin(ai 0 -1) + br(.n $0 moveLeftLoop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// <---- signal 3 +moveRight: + fc(fcDondIncShCaseAnim 1) + bin(si 0 9) +moveRightLoop: + sleep(1) + obj(xq=2.777777) + bin(ai 0 -1) + br(.n $0 moveRightLoop) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 90% speed 11, 1.3636, 2.2727 + +moveUp2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 11) +moveUpLoop2: + sleep(1) + obj(yq=1.3636) + bin(ai 0 -1) + br(.n $0 moveUpLoop2) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 11) +moveDownLoop2: + sleep(1) + obj(yq=-1.3636) + bin(ai 0 -1) + br(.n $0 moveDownLoop2) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 11) +moveLeftLoop2: + sleep(1) + obj(xq=-2.2727) + bin(ai 0 -1) + br(.n $0 moveLeftLoop2) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight2: + fc(fcDondIncShCaseAnim 1) + bin(si 0 11) +moveRightLoop2: + sleep(1) + obj(xq=2.2727) + bin(ai 0 -1) + br(.n $0 moveRightLoop2) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 80% speed 13, 1.1538, 1.9230 + +moveUp3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 13) +moveUpLoop3: + sleep(1) + obj(yq=1.1538) + bin(ai 0 -1) + br(.n $0 moveUpLoop3) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 13) +moveDownLoop3: + sleep(1) + obj(yq=-1.1538) + bin(ai 0 -1) + br(.n $0 moveDownLoop3) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 13) +moveLeftLoop3: + sleep(1) + obj(xq=-1.9230) + bin(ai 0 -1) + br(.n $0 moveLeftLoop3) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight3: + fc(fcDondIncShCaseAnim 1) + bin(si 0 13) +moveRightLoop3: + sleep(1) + obj(xq=1.9230) + bin(ai 0 -1) + br(.n $0 moveRightLoop3) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 70% speed 15, 1.0, 1.6666 + +moveUp4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 15) +moveUpLoop4: + sleep(1) + obj(yq=1.0) + bin(ai 0 -1) + br(.n $0 moveUpLoop4) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 15) +moveDownLoop4: + sleep(1) + obj(yq=-1.0) + bin(ai 0 -1) + br(.n $0 moveDownLoop4) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 15) +moveLeftLoop4: + sleep(1) + obj(xq=-1.6666) + bin(ai 0 -1) + br(.n $0 moveLeftLoop4) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight4: + fc(fcDondIncShCaseAnim 1) + bin(si 0 15) +moveRightLoop4: + sleep(1) + obj(xq=1.6666) + bin(ai 0 -1) + br(.n $0 moveRightLoop4) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 60% speed 17, 0.8823, 1.4705 + +moveUp5: + fc(fcDondIncShCaseAnim 1) + bin(si 0 17) +moveUpLoop5: + sleep(1) + obj(yq=0.8823) + bin(ai 0 -1) + br(.n $0 moveUpLoop5) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown5: + fc(fcDondIncShCaseAnim 1) + bin(si 0 17) +moveDownLoop5: + sleep(1) + obj(yq=-0.8823) + bin(ai 0 -1) + br(.n $0 moveDownLoop5) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft5: + fc(fcDondIncShCaseAnim 1) + bin(si 0 17) +moveLeftLoop5: + sleep(1) + obj(xq=-1.4705) + bin(ai 0 -1) + br(.n $0 moveLeftLoop5) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight5: + fc(fcDondIncShCaseAnim 1) + bin(si 0 17) +moveRightLoop5: + sleep(1) + obj(xq=1.4705) + bin(ai 0 -1) + br(.n $0 moveRightLoop5) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 50% speed 19, 0.7894, 1.3157 + +moveUp6: + fc(fcDondIncShCaseAnim 1) + bin(si 0 19) +moveUpLoop6: + sleep(1) + obj(yq=0.7894) + bin(ai 0 -1) + br(.n $0 moveUpLoop6) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown6: + fc(fcDondIncShCaseAnim 1) + bin(si 0 19) +moveDownLoop6: + sleep(1) + obj(yq=-0.7894) + bin(ai 0 -1) + br(.n $0 moveDownLoop6) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft6: + fc(fcDondIncShCaseAnim 1) + bin(si 0 19) +moveLeftLoop6: + sleep(1) + obj(xq=-1.3157) + bin(ai 0 -1) + br(.n $0 moveLeftLoop6) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight6: + fc(fcDondIncShCaseAnim 1) + bin(si 0 19) +moveRightLoop6: + sleep(1) + obj(xq=1.3157) + bin(ai 0 -1) + br(.n $0 moveRightLoop6) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 40% speed 21, 0.7142, 1.1904 + +moveUp7: + fc(fcDondIncShCaseAnim 1) + bin(si 0 21) +moveUpLoop7: + sleep(1) + obj(yq=0.7142) + bin(ai 0 -1) + br(.n $0 moveUpLoop7) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown7: + fc(fcDondIncShCaseAnim 1) + bin(si 0 21) +moveDownLoop7: + sleep(1) + obj(yq=-0.7142) + bin(ai 0 -1) + br(.n $0 moveDownLoop7) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft7: + fc(fcDondIncShCaseAnim 1) + bin(si 0 21) +moveLeftLoop7: + sleep(1) + obj(xq=-1.1904) + bin(ai 0 -1) + br(.n $0 moveLeftLoop7) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight7: + fc(fcDondIncShCaseAnim 1) + bin(si 0 21) +moveRightLoop7: + sleep(1) + obj(xq=1.1904) + bin(ai 0 -1) + br(.n $0 moveRightLoop7) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 30% speed 23, 0.6521, 1.0869 + +moveUp8: + fc(fcDondIncShCaseAnim 1) + bin(si 0 23) +moveUpLoop8: + sleep(1) + obj(yq=0.6521) + bin(ai 0 -1) + br(.n $0 moveUpLoop8) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown8: + fc(fcDondIncShCaseAnim 1) + bin(si 0 23) +moveDownLoop8: + sleep(1) + obj(yq=-0.6521) + bin(ai 0 -1) + br(.n $0 moveDownLoop8) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft8: + fc(fcDondIncShCaseAnim 1) + bin(si 0 23) +moveLeftLoop8: + sleep(1) + obj(xq=-1.0869) + bin(ai 0 -1) + br(.n $0 moveLeftLoop8) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight8: + fc(fcDondIncShCaseAnim 1) + bin(si 0 23) +moveRightLoop8: + sleep(1) + obj(xq=1.0869) + bin(ai 0 -1) + br(.n $0 moveRightLoop8) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 20% speed 25, 0.6, 1.0 + +moveUp9: + fc(fcDondIncShCaseAnim 1) + bin(si 0 25) +moveUpLoop9: + sleep(1) + obj(yq=0.6) + bin(ai 0 -1) + br(.n $0 moveUpLoop9) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown9: + fc(fcDondIncShCaseAnim 1) + bin(si 0 25) +moveDownLoop9: + sleep(1) + obj(yq=-0.6) + bin(ai 0 -1) + br(.n $0 moveDownLoop9) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft9: + fc(fcDondIncShCaseAnim 1) + bin(si 0 25) +moveLeftLoop9: + sleep(1) + obj(xq=-1.0) + bin(ai 0 -1) + br(.n $0 moveLeftLoop9) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight9: + fc(fcDondIncShCaseAnim 1) + bin(si 0 25) +moveRightLoop9: + sleep(1) + obj(xq=1.0) + bin(ai 0 -1) + br(.n $0 moveRightLoop9) + fc(fcDondIncShCaseAnim -1) + br(wait) + +// ----------------------------------------------- +// - 10% speed 27, 0.5555, 0.9259 + +moveUp10: + fc(fcDondIncShCaseAnim 1) + bin(si 0 27) +moveUpLoop10: + sleep(1) + obj(yq=0.5555) + bin(ai 0 -1) + br(.n $0 moveUpLoop10) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveDown10: + fc(fcDondIncShCaseAnim 1) + bin(si 0 27) +moveDownLoop10: + sleep(1) + obj(yq=-0.5555) + bin(ai 0 -1) + br(.n $0 moveDownLoop10) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveLeft10: + fc(fcDondIncShCaseAnim 1) + bin(si 0 27) +moveLeftLoop10: + sleep(1) + obj(xq=-0.9259) + bin(ai 0 -1) + br(.n $0 moveLeftLoop10) + fc(fcDondIncShCaseAnim -1) + br(wait) + +moveRight10: + fc(fcDondIncShCaseAnim 1) + bin(si 0 27) +moveRightLoop10: + sleep(1) + obj(xq=0.9259) + bin(ai 0 -1) + br(.n $0 moveRightLoop10) + fc(fcDondIncShCaseAnim -1) + br(wait) + +) diff --git a/donddata/cf/text3d.cf b/donddata/cf/text3d.cf new file mode 100644 index 0000000..beaefd0 --- /dev/null +++ b/donddata/cf/text3d.cf @@ -0,0 +1,459 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. + + +//--- seq for all selGame bttns +seq f3DSeq ( +alloc(10) +signals(15) +signal(0 - idle - ) +signal(1 - spin - ) +signal(2 - slideLeft - ) +signal(3 - slideRight - ) +signal(4 - scale - ) +signal(5 - slideLeftT - ) +signal(6 - slideRightT - ) +signal(7 - circle - ) +signal(8 - unroll - ) +signal(9 - hiscSpin - ) +signal(10 - slam - ) +signal(11 - scaleSR - ) +signal(12 - scaleHH - ) +signal(13 - scrollR - ) +signal(14 - wave - ) +start() + +idle: + sleep(0) + + +//-------- SPIN ----SIGNAL 1 --- + +spin: + sleep($1) //set by create routine + + fc(fcCounterSet $0 20) + obj(v0) + obj(xt=0.29) +spinLoop: + sloop(1) + fc(fcCounterDecr $0 1) + br(.n $0 spinLoop) + obj(xr=0.0) + + obj(st) + + br(x) + +//-------- SLIDE LEFT ----SIGNAL 2 --- + +slideLeft: + fc(fcCounterSet $0 20) + obj(v0) + obj(xq=-60.0) +slideLLoop: + sleep(1) + obj(xq=3.0) + fc(fcCounterDecr $0 1) + br(.n $0 slideLLoop) + + obj(st) + //sound(130) + + br(x) + +//-------- SLIDE RIGHT ----SIGNAL 3 --- + +slideRight: + fc(fcCounterSet $0 20) + obj(v0) + obj(xq=60.0) +slideRLoop: + sleep(1) + obj(xq=-3.0) + fc(fcCounterDecr $0 1) + br(.n $0 slideRLoop) + obj(xr=0.0) + + obj(st) + //sound(130) + + br(x) + +//-------- SCALE DOWN ----SIGNAL 4 --- + +scale: + obj(of) + sleep(60) + obj(on) + fc(fcCounterSet $0 15) + obj(v0) + fc(fcScale 7.0 0) +scaleLoop: + sleep(1) + fc(fcScale -0.4 1) + fc(fcCounterDecr $0 1) + br(.n $0 scaleLoop) + + sound(130) + +scaleLoop2: + sloop(1) + fc(fcScaleAxis 0.2 1 0) + sloop(1) + fc(fcScaleAxis 0.15 1 0) + sloop(1) + fc(fcScaleAxis 0.1 1 0) + sloop(1) + fc(fcScaleAxis 0.05 1 0) + sloop(1) + sloop(1) + fc(fcScaleAxis -0.05 1 0) + sloop(1) + fc(fcScaleAxis -0.1 1 0) + sloop(1) + fc(fcScaleAxis -0.15 1 0) + sloop(1) + fc(fcScaleAxis -0.2 1 0) + + + fc(fcScale 1.0 0) + + + obj(st) + + br(x) + + +//-------- SLIDE LEFT TILT ----SIGNAL 5 --- + +slideLeftT: + fc(fcCounterSet $0 20) + obj(v0) + obj(xq=-60.0) +slideLTLoop: + sleep(1) + obj(xq=3.0) + fc(fcCounterDecr $0 1) + br(.n $0 slideLTLoop) + + obj(st) + + //obj(v0) + + obj(zr=-0.1) + obj(xq=0.5) + sleep(1) + obj(zr=-0.15) + obj(xq=0.5) + sleep(1) + obj(zr=-0.25) + obj(xq=0.5) + sleep(1) + obj(zr=-0.15) + obj(xq=-0.5) + sleep(1) + obj(zr=-0.1) + obj(xq=-0.5) + sleep(1) + obj(zr=0.0) + obj(xq=-0.5) + + obj(st) + br(x) + +//-------- SLIDE RIGHT TILT ----SIGNAL 6 --- + +slideRightT: + fc(fcCounterSet $0 20) + obj(v0) + obj(xq=60.0) +slideRTLoop: + sleep(1) + obj(xq=-3.0) + fc(fcCounterDecr $0 1) + br(.n $0 slideRTLoop) + + obj(st) + + //obj(v0) + + obj(zr=0.1) + obj(xq=-0.5) + sleep(1) + obj(zr=0.15) + obj(xq=-0.5) + sleep(1) + obj(zr=0.25) + obj(xq=-0.5) + sleep(1) + obj(zr=0.15) + obj(xq=0.5) + sleep(1) + obj(zr=0.1) + obj(xq=0.5) + sleep(1) + obj(zr=0.0) + obj(xq=0.5) + + + obj(st) + br(x) + +//-------- CIRCLE ----SIGNAL 7 --- + +circle: + fc(fcText3dCircleInit 7) + fc(fcCounterSet $0 500) + obj(v0) +circleLoop: + sleep(1) + fc(fcText3dCircle) + fc(fcCounterDecr $0 1) + br(.n $0 circleLoop) + + + obj(st) + br(x) + +//-------- UNROLL ----SIGNAL 8 --- + +unroll: + obj(of) + sleep($1) //set by create routine + obj(on) + fc(fcText3dCircleInit 8) + fc(fcCounterSet $0 500) + obj(v0) +unrollLoop: + sleep(1) + fc(fcText3dCircle) + br(.n $0 unrollLoop) + + fc(fcCounterSet $0 10) + fc(fcText3dResolve "var") +unrollRLoop: + sloop(1) + fc(fcText3dResolve "var") + fc(fcCounterDecr $0 1) + br(.n $0 unrollRLoop) + + obj(st) + + br(x) + +//-------- HISC SPIN ----SIGNAL 9 --- + +hiscspin: + obj(v0) + obj(xs=2.5 ys=2.5 zs=2.5 yp=-7.0) + obj(yt=-.1) +hiscspinLoop: + sloop(1) + br(hiscspinLoop) + + obj(st) + br(x) + + +//-------- SLAM ----SIGNAL 10 --- + +slam: + fc(fcCounterSet $0 10) + obj(v0) + obj(zq=-200.0) + //fc(fcScale 0.1 0) +slamLoop: + sleep(1) + //fc(fcScale 0.05 1) + obj(zq=20.0) + fc(fcCounterDecr $0 1) + br(.n $0 slamLoop) + + fc(fcScale 1.0 0) + sound(136) + + obj(of) + sleep(4) + obj(on) + sleep(8) + obj(of) + sleep(4) + obj(on) + sleep(8) + obj(of) + sleep(4) + obj(on) +// sleep(8) +// obj(of) + + +camshake: + //fc(fcCamShake) +// obj(xq=1.5 yq=0.6) +// sleep(3) +// obj(xq=-0.9 yq=-0.9) +// sleep(3) +// obj(xq=0.6 yq=1.2) +// sleep(3) +// obj(xq=-0.9 yq=-0.9) +// sleep(3) +// obj(xq=0.9 yq=1.5) +// sleep(3) +// obj(xq=-0.9 yq=-0.9) +// sleep(3) +// obj(xq=0.6 yq=0.3) +// sleep(3) +// obj(xq=-0.9 yq=-0.9) + + obj(st) + + br(x) + + +//-------- SCALE DOWN SHOTREP----SIGNAL 11 --- + +scaleSR: + fc(fcCounterSet $0 10) + obj(v0) + fc(fcScale 7.0 0) +scaleLoopSR: + sleep(1) + fc(fcScale -0.5 1) + fc(fcCounterDecr $0 1) + br(.n $0 scaleLoopSR) + +// sound(130) + +scaleLoopSR2: + sloop(1) + fc(fcScaleAxis 0.2 1 0) + sloop(1) + fc(fcScaleAxis 0.15 1 0) + sloop(1) + fc(fcScaleAxis 0.1 1 0) + sloop(1) + fc(fcScaleAxis 0.05 1 0) + sloop(1) + sloop(1) + fc(fcScaleAxis -0.05 1 0) + sloop(1) + fc(fcScaleAxis -0.1 1 0) + sloop(1) + fc(fcScaleAxis -0.15 1 0) + sloop(1) + fc(fcScaleAxis -0.2 1 0) + + + fc(fcScale 1.0 0) + + + obj(st) + + br(x) + + +//-------- SCALEDOWN HHERO----SIGNAL 12 --- + +scaleHH: + fc(fcCounterSet $0 7) + obj(v0) + fc(fcScale 8.0 0) +scaleLoopHH: + sleep(1) + fc(fcScale -1.0 1) + fc(fcCounterDecr $0 1) + br(.n $0 scaleLoopHH) + + fc(fcReportScatterHH) +scaleLoopHH2: + sloop(1) + fc(fcScaleAxis 0.2 1 0) + sloop(1) + fc(fcScaleAxis 0.15 1 0) + sloop(1) + fc(fcScaleAxis 0.1 1 0) + sloop(1) + fc(fcScaleAxis 0.05 1 0) + sloop(1) + sloop(1) + fc(fcScaleAxis -0.05 1 0) + sloop(1) + fc(fcScaleAxis -0.1 1 0) + sloop(1) + fc(fcScaleAxis -0.15 1 0) + sloop(1) + fc(fcScaleAxis -0.2 1 0) + + + fc(fcScale 1.0 0) + + + obj(st) + + br(x) + +//-------- SCROLL RIGHT ----SIGNAL 13 --- + +scrollR: + fc(fcCounterSet $0 200) + obj(v0) + obj(xq=25.0) +scrollRLoop: + sleep(1) + obj(xq=-0.30) + fc(fcCounterDecr $0 1) + br(.n $0 scrollRLoop) + + obj(st) + //sound(130) + + br(x) + + +//-------- WAVE ----SIGNAL 14 --- + +wave: + sloop(1) + sleep(15) + sleep($1) //set by create routine + + fc(fcCounterSet $0 10) + obj(v0) +waveUpLoop: + sloop(1) + fc(fcScale 0.1 1) + obj(zq=-0.1) + fc(fcCounterDecr $0 1) + br(.n $0 waveUpLoop) + obj(xr=0.0) + + fc(fcCounterSet $0 10) + obj(v0) +waveDnLoop: + sloop(1) + fc(fcScale -0.1 1) + obj(zq=0.1) + fc(fcCounterDecr $0 1) + br(.n $0 waveDnLoop) + + fc(fcScale 1.0 0) + + + obj(st) + + br(x) + + + +x: + +) + + +seq dblPerf( + start() +// disp(vsync=0) + fc(fc3DText "dbl perf") +) + +// EOF \ No newline at end of file diff --git a/donddata/cf/vssver.scc b/donddata/cf/vssver.scc new file mode 100644 index 0000000..98445a2 Binary files /dev/null and b/donddata/cf/vssver.scc differ diff --git a/donddata/cf/wreveal.cf b/donddata/cf/wreveal.cf new file mode 100644 index 0000000..fe457df --- /dev/null +++ b/donddata/cf/wreveal.cf @@ -0,0 +1,616 @@ +// CF01 - Copyright (C) 2004, PlayMechanix, Inc. +// --------------------------------------------- + +seq createWRScene ( + start() + + ani(- sClear) + + mark(bgmrk) + kill(background) create(background .f=d2 .lb .v .s=bgAnim) + + kill(main_*) + kill(press_*) + kill(doubledeal) + + create(revcase_016 .f=d2 .lb) create(Reveal_016 .f=d2 .lb) + create(revcase_015 .f=d2 .lb) create(Reveal_015 .f=d2 .lb) + create(revcase_014 .f=d2 .lb) create(Reveal_014 .f=d2 .lb) + create(revcase_013 .f=d2 .lb) create(Reveal_013 .f=d2 .lb) + create(revshadow_012 .f=d2 .lb) create(revcase_012 .f=d2 .lb) create(Reveal_012 .f=d2 .lb) + create(revshadow_011 .f=d2 .lb) create(revcase_011 .f=d2 .lb) create(Reveal_011 .f=d2 .lb) + create(revshadow_010 .f=d2 .lb) create(revcase_010 .f=d2 .lb) create(Reveal_010 .f=d2 .lb) + create(revshadow_09 .f=d2 .lb) create(revcase_09 .f=d2 .lb) create(Reveal_09 .f=d2 .lb) + create(revshadow_08 .f=d2 .lb) create(revcase_08 .f=d2 .lb) create(Reveal_08 .f=d2 .lb) + create(revshadow_07 .f=d2 .lb) create(revcase_07 .f=d2 .lb) create(Reveal_07 .f=d2 .lb) + create(revshadow_06 .f=d2 .lb) create(revcase_06 .f=d2 .lb) create(Reveal_06 .f=d2 .lb) + create(revshadow_05 .f=d2 .lb) create(revcase_05 .f=d2 .lb) create(Reveal_05 .f=d2 .lb) + create(revshadow_04 .f=d2 .lb) create(revcase_04 .f=d2 .lb) create(Reveal_04 .f=d2 .lb) + create(revshadow_03 .f=d2 .lb) create(revcase_03 .f=d2 .lb) create(Reveal_03 .f=d2 .lb) + create(revshadow_02 .f=d2 .lb) create(revcase_02 .f=d2 .lb) create(Reveal_02 .f=d2 .lb) + create(revshadow_01 .f=d2 .lb) create(revcase_01 .f=d2 .lb) create(Reveal_01 .f=d2 .lb) + + // - "play" all of the videos in order to load them into memory + + vidplay(Reveal_016) + vidplay(Reveal_015) + vidplay(Reveal_014) + vidplay(Reveal_013) + vidplay(Reveal_012) + vidplay(Reveal_011) + vidplay(Reveal_010) + vidplay(Reveal_09) + vidplay(Reveal_08) + vidplay(Reveal_07) + vidplay(Reveal_06) + vidplay(Reveal_05) + vidplay(Reveal_04) + vidplay(Reveal_03) + vidplay(Reveal_02) + vidplay(Reveal_01) + + sleep(1) + +playAgain: + + vidstop(Reveal_016) vidreset(Reveal_016) + vidstop(Reveal_015) vidreset(Reveal_015) + vidstop(Reveal_014) vidreset(Reveal_014) + vidstop(Reveal_013) vidreset(Reveal_013) + vidstop(Reveal_012) vidreset(Reveal_012) + vidstop(Reveal_011) vidreset(Reveal_011) + vidstop(Reveal_010) vidreset(Reveal_010) + vidstop(Reveal_09) vidreset(Reveal_09) + vidstop(Reveal_08) vidreset(Reveal_08) + vidstop(Reveal_07) vidreset(Reveal_07) + vidstop(Reveal_06) vidreset(Reveal_06) + vidstop(Reveal_05) vidreset(Reveal_05) + vidstop(Reveal_04) vidreset(Reveal_04) + vidstop(Reveal_03) vidreset(Reveal_03) + vidstop(Reveal_02) vidreset(Reveal_02) + vidstop(Reveal_01) vidreset(Reveal_01) + + sleep(1) + +// vidplay(Reveal_016) vidstop(Reveal_016) vidreset(Reveal_016) +// vidplay(Reveal_015) vidstop(Reveal_015) vidreset(Reveal_015) +// vidplay(Reveal_014) vidstop(Reveal_014) vidreset(Reveal_014) +// vidplay(Reveal_013) vidstop(Reveal_013) vidreset(Reveal_013) +// vidplay(Reveal_012) vidstop(Reveal_012) vidreset(Reveal_012) +// vidplay(Reveal_011) vidstop(Reveal_011) vidreset(Reveal_011) +// vidplay(Reveal_010) vidstop(Reveal_010) vidreset(Reveal_010) +// vidplay(Reveal_09) vidstop(Reveal_09) vidreset(Reveal_09) +// vidplay(Reveal_08) vidstop(Reveal_08) vidreset(Reveal_08) +// vidplay(Reveal_07) vidstop(Reveal_07) vidreset(Reveal_07) +// vidplay(Reveal_06) vidstop(Reveal_06) vidreset(Reveal_06) +// vidplay(Reveal_05) vidstop(Reveal_05) vidreset(Reveal_05) +// vidplay(Reveal_04) vidstop(Reveal_04) vidreset(Reveal_04) +// vidplay(Reveal_03) vidstop(Reveal_03) vidreset(Reveal_03) +// vidplay(Reveal_02) vidstop(Reveal_02) vidreset(Reveal_02) +// vidplay(Reveal_01) vidstop(Reveal_01) vidreset(Reveal_01) + + + sleep(50) + + // ... + vidplay(Reveal_09) viddone(Reveal_09 wrDone_09) // 35 + vidplay(Reveal_013) viddone(Reveal_013 wrDone_13) // 21 + + // ... + sleep(35) + vidplay(Reveal_014) viddone(Reveal_014 wrDone_14) // 44 + vidplay(Reveal_010) viddone(Reveal_010 wrDone_10) // 33 + + // ... + sleep(44) + vidplay(Reveal_015) viddone(Reveal_015 wrDone_15) // 42 + vidplay(Reveal_05) viddone(Reveal_05 wrDone_05) // 15 + + // ... + sleep(42) + vidplay(Reveal_011) viddone(Reveal_011 wrDone_11) // 25 + vidplay(Reveal_06) viddone(Reveal_06 wrDone_06) // 24 + + // ... + sleep(25) + vidplay(Reveal_016) viddone(Reveal_016 wrDone_16) // 28 + vidplay(Reveal_01) viddone(Reveal_01 wrDone_01) // 32 + + // ... + sleep(32) + vidplay(Reveal_012) viddone(Reveal_012 wrDone_12) // 46 + + // ... + sleep(46) + vidplay(Reveal_07) viddone(Reveal_07 wrDone_07) // 18 + vidplay(Reveal_02) viddone(Reveal_02 wrDone_02) // 34 + + // ... + sleep(34) + vidplay(Reveal_08) viddone(Reveal_08 wrDone_08) // 21 + vidplay(Reveal_03) viddone(Reveal_03 wrDone_03) // 31 + + // ... + sleep(31) + vidplay(Reveal_04) viddone(Reveal_04 wrDone_04) // 24 + + sleep(100) + br(playAgain) +) + +// --------------------------------------------- + +seq wrDone_01 ( start() vidstop(Reveal_01) ) +seq wrDone_02 ( start() vidstop(Reveal_02) ) +seq wrDone_03 ( start() vidstop(Reveal_03) ) +seq wrDone_04 ( start() vidstop(Reveal_04) ) +seq wrDone_05 ( start() vidstop(Reveal_05) ) +seq wrDone_06 ( start() vidstop(Reveal_06) ) +seq wrDone_07 ( start() vidstop(Reveal_07) ) +seq wrDone_08 ( start() vidstop(Reveal_08) ) +seq wrDone_09 ( start() vidstop(Reveal_09) ) +seq wrDone_10 ( start() vidstop(Reveal_010) ) +seq wrDone_11 ( start() vidstop(Reveal_011) ) +seq wrDone_12 ( start() vidstop(Reveal_012) ) +seq wrDone_13 ( start() vidstop(Reveal_013) ) +seq wrDone_14 ( start() vidstop(Reveal_014) ) +seq wrDone_15 ( start() vidstop(Reveal_015) ) +seq wrDone_16 ( start() vidstop(Reveal_016) ) + +// --------------------------------------------- + +seq createWRS ( + +alloc(4) + + start() + + mark(bgmrk) + + kill(model_*) + kill(case_*) + kill(shadow_*) + kill(background) + kill(black_bg) + + create(background .f=d2 .lb .v .s=bgAnim) + + fc(fcDondAskWRGirl $0 16 0) br(.z $0 skip16) + create(revcase_016 .f=d2 .lb) create(Reveal_016 .f=d2 .lb) +skip16: + + fc(fcDondAskWRGirl $0 15 0) br(.z $0 skip15) + create(revcase_015 .f=d2 .lb) create(Reveal_015 .f=d2 .lb) +skip15: + + fc(fcDondAskWRGirl $0 14 0) br(.z $0 skip14) + create(revcase_014 .f=d2 .lb) create(Reveal_014 .f=d2 .lb) +skip14: + + fc(fcDondAskWRGirl $0 13 0) br(.z $0 skip13) + create(revcase_013 .f=d2 .lb) create(Reveal_013 .f=d2 .lb) +skip13: + + fc(fcDondAskWRGirl $0 12 0) br(.z $0 skip12) + create(revshadow_012 .f=d2 .lb) create(revcase_012 .f=d2 .lb) create(Reveal_012 .f=d2 .lb) +skip12: + + fc(fcDondAskWRGirl $0 11 0) br(.z $0 skip11) + create(revshadow_011 .f=d2 .lb) create(revcase_011 .f=d2 .lb) create(Reveal_011 .f=d2 .lb) +skip11: + + fc(fcDondAskWRGirl $0 10 0) br(.z $0 skip10) + create(revshadow_010 .f=d2 .lb) create(revcase_010 .f=d2 .lb) create(Reveal_010 .f=d2 .lb) +skip10: + + fc(fcDondAskWRGirl $0 9 0) br(.z $0 skip9) + create(revshadow_09 .f=d2 .lb) create(revcase_09 .f=d2 .lb) create(Reveal_09 .f=d2 .lb) +skip9: + + fc(fcDondAskWRGirl $0 8 0) br(.z $0 skip8) + create(revshadow_08 .f=d2 .lb) create(revcase_08 .f=d2 .lb) create(Reveal_08 .f=d2 .lb) +skip8: + + fc(fcDondAskWRGirl $0 7 0) br(.z $0 skip7) + create(revshadow_07 .f=d2 .lb) create(revcase_07 .f=d2 .lb) create(Reveal_07 .f=d2 .lb) +skip7: + + fc(fcDondAskWRGirl $0 6 0) br(.z $0 skip6) + create(revshadow_06 .f=d2 .lb) create(revcase_06 .f=d2 .lb) create(Reveal_06 .f=d2 .lb) +skip6: + + fc(fcDondAskWRGirl $0 5 0) br(.z $0 skip5) + create(revshadow_05 .f=d2 .lb) create(revcase_05 .f=d2 .lb) create(Reveal_05 .f=d2 .lb) +skip5: + + fc(fcDondAskWRGirl $0 4 0) br(.z $0 skip4) + create(revshadow_04 .f=d2 .lb) create(revcase_04 .f=d2 .lb) create(Reveal_04 .f=d2 .lb) +skip4: + + fc(fcDondAskWRGirl $0 3 0) br(.z $0 skip3) + create(revshadow_03 .f=d2 .lb) create(revcase_03 .f=d2 .lb) create(Reveal_03 .f=d2 .lb) +skip3: + + fc(fcDondAskWRGirl $0 2 0) br(.z $0 skip2) + create(revshadow_02 .f=d2 .lb) create(revcase_02 .f=d2 .lb) create(Reveal_02 .f=d2 .lb) +skip2: + + fc(fcDondAskWRGirl $0 1 0) br(.z $0 skip1) + create(revshadow_01 .f=d2 .lb) create(revcase_01 .f=d2 .lb) create(Reveal_01 .f=d2 .lb) +skip1: + + create(black_bg .f=d2 .lb .v .s=sBlackBg) + bin(mv 2 0) send($2 0) + + // - "play" all of the videos in order to load them into memory + + vidplay(Reveal_016) + vidplay(Reveal_015) + vidplay(Reveal_014) + vidplay(Reveal_013) + vidplay(Reveal_012) + vidplay(Reveal_011) + vidplay(Reveal_010) + vidplay(Reveal_09) + vidplay(Reveal_08) + vidplay(Reveal_07) + vidplay(Reveal_06) + vidplay(Reveal_05) + vidplay(Reveal_04) + vidplay(Reveal_03) + vidplay(Reveal_02) + vidplay(Reveal_01) + + sleep(1) + + vidstop(Reveal_016) vidreset(Reveal_016) + vidstop(Reveal_015) vidreset(Reveal_015) + vidstop(Reveal_014) vidreset(Reveal_014) + vidstop(Reveal_013) vidreset(Reveal_013) + vidstop(Reveal_012) vidreset(Reveal_012) + vidstop(Reveal_011) vidreset(Reveal_011) + vidstop(Reveal_010) vidreset(Reveal_010) + vidstop(Reveal_09) vidreset(Reveal_09) + vidstop(Reveal_08) vidreset(Reveal_08) + vidstop(Reveal_07) vidreset(Reveal_07) + vidstop(Reveal_06) vidreset(Reveal_06) + vidstop(Reveal_05) vidreset(Reveal_05) + vidstop(Reveal_04) vidreset(Reveal_04) + vidstop(Reveal_03) vidreset(Reveal_03) + vidstop(Reveal_02) vidreset(Reveal_02) + vidstop(Reveal_01) vidreset(Reveal_01) +) + +// --------------------------------------------- + +seq sWRS ( + +alloc(4) + + start() + + create(textbar .f=d2 .lb) + create(final_reveal .f=d2 .lb) + + // - "ladies, open the cases" + + sound(370) + sound(200) + + sleep(100) + + fc(fcDondAskWRGirl $0 9 13) + br(.z $0 skip1) + + // ... + vidplay(Reveal_09 0) viddone(Reveal_09 wrDone_09) // 35 + vidplay(Reveal_013 0) viddone(Reveal_013 wrDone_13) // 21 + sleep(35) + +skip1: + + fc(fcDondAskWRGirl $0 14 10) + br(.z $0 skip2) + + // ... + vidplay(Reveal_014 0) viddone(Reveal_014 wrDone_14) // 44 + vidplay(Reveal_010 0) viddone(Reveal_010 wrDone_10) // 33 + sleep(44) + +skip2: + + fc(fcDondAskWRGirl $0 15 5) + br(.z $0 skip3) + + // ... + vidplay(Reveal_015 0) viddone(Reveal_015 wrDone_15) // 42 + vidplay(Reveal_05 0) viddone(Reveal_05 wrDone_05) // 15 + sleep(42) + +skip3: + + fc(fcDondAskWRGirl $0 11 6) + br(.z $0 skip4) + + // ... + vidplay(Reveal_011 0) viddone(Reveal_011 wrDone_11) // 25 + vidplay(Reveal_06 0) viddone(Reveal_06 wrDone_06) // 24 + sleep(25) + +skip4: + + fc(fcDondAskWRGirl $0 16 1) + br(.z $0 skip5) + + // ... + vidplay(Reveal_016 0) viddone(Reveal_016 wrDone_16) // 28 + vidplay(Reveal_01 0) viddone(Reveal_01 wrDone_01) // 32 + sleep(32) + +skip5: + + fc(fcDondAskWRGirl $0 12 0) + br(.z $0 skip6) + + // ... + vidplay(Reveal_012 0) viddone(Reveal_012 wrDone_12) // 46 + sleep(46) + +skip6: + + fc(fcDondAskWRGirl $0 7 2) + br(.z $0 skip7) + + // ... + vidplay(Reveal_07 0) viddone(Reveal_07 wrDone_07) // 18 + vidplay(Reveal_02 0) viddone(Reveal_02 wrDone_02) // 34 + sleep(34) + +skip7: + + fc(fcDondAskWRGirl $0 8 3) + br(.z $0 skip8) + + // ... + vidplay(Reveal_08 0) viddone(Reveal_08 wrDone_08) // 21 + vidplay(Reveal_03 0) viddone(Reveal_03 wrDone_03) // 31 + sleep(31) + +skip8: + + fc(fcDondAskWRGirl $0 4 0) + br(.z $0 skip9) + + // ... + vidplay(Reveal_04 0) viddone(Reveal_04 wrDone_04) // 24 + +skip9: + + sleep(160) + + fc(fcDondUnloadVideos) + + // - place the game in DOND_GAMEOVER_REVEAL mode + + fc(fcDondSetGameState 10) + + fc(fcDondFadeOut textbar) + fc(fcDondFadeOut final_reveal) + + ani(- postWRreveal) +) + +// --------------------------------------------- + +seq postWRreveal ( + +alloc(4) + + start() + + mark(bgmrk) + + fc(fcDondPlayGradedReveal) + fc(fcDondAskGradedReveal $0) // $0 = number of frames to wait + + ani(- sPCaseTitle) + fc(fcDondPlayPCaseRV) + mark(bgmrk) + + // - polite applause sound + + sound(200) + + sleep(20) + + // - play the case buildup sound + + sound(372) + + sound(11) + +revealLoop: + sleep(1) + fc(fcDondAskVideoFrame * $1 $0) // $1 = video frame of object named "*" + br(.z $1 revealLoop) + + fc(fcDondPlayGradedAudio) + + // - start at 100% shrink and loop downwards to + // 0% shrink. this causes the displayed value + // to zoom out of the case + + bin(si 0 100) // <- $0 = 100 +scaleLoop: + sleep(1) + fc(fcDondDrawCaseValue $0 52.0 18.0) // <- shrinkRate, xpos, ypos + bin(ai 0 -10) // <- $0 = $0 - 10; + br(.n $0 scaleLoop) // <- if ($0 != 0) goto scaleLoop + + // - create the "ticket" label + + fc(fcDondAskForFun $0) + br(.n $0 noPrizeLabel) + fc(fcDondAskCoupOrTick $0) + br(.z $0 coupons) + create(c_ticket .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) + br(prizeDone) +coupons: + create(c_coupon .f=d2 .lb .v .s=sPrompt) bin(mv 2 0) +prizeDone: + obj(ob=$2 xq=52.0) + obj(ob=$2 yq=17.0) +noPrizeLabel: + + sleep(10) + fc(fcDondPlayGradedCrowdAudio) + fc(fcDondRedrawValues) + + sleep(180) + + fc(fcDondFadeOut personl_title) + + sound(201) + ani(- sCollect) + + kill(background) + kill(Reveal_*) + kill(revcase_*) + kill(revshadow_*) + + fc(fcDondFadeOut bg_tight) + fc(fcDondFadeKillReveal) + + //fc(fcDondFadeOut ticket_signL) + //fc(fcDondFadeOut ticket_signR) + kill(tick*) + kill(coup*) + + //ani(- slideBarsOut) + + // - get rid of the tickets label + + kill($2) + + fc(fcDondDoGameOver 1) +) + +// --------------------------------------------- +// preloadWRS + +seq preloadWRS ( + +alloc(4) + start() + + create(Reveal_016 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_015 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_014 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_013 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_012 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_011 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_010 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_09 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_08 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_07 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_06 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_05 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_04 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_03 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_02 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + create(Reveal_01 .f=d2 .lb .v) bin(mv 1 0) obj(ob=$1 of) + + // - "play" all of the videos in order to load them into memory + + vidplay(Reveal_016) + vidplay(Reveal_015) + vidplay(Reveal_014) + vidplay(Reveal_013) + vidplay(Reveal_012) + vidplay(Reveal_011) + vidplay(Reveal_010) + vidplay(Reveal_09) + vidplay(Reveal_08) + vidplay(Reveal_07) + vidplay(Reveal_06) + vidplay(Reveal_05) + vidplay(Reveal_04) + vidplay(Reveal_03) + vidplay(Reveal_02) + vidplay(Reveal_01) + + sleep(1) + + vidstop(Reveal_016) vidreset(Reveal_016) + vidstop(Reveal_015) vidreset(Reveal_015) + vidstop(Reveal_014) vidreset(Reveal_014) + vidstop(Reveal_013) vidreset(Reveal_013) + vidstop(Reveal_012) vidreset(Reveal_012) + vidstop(Reveal_011) vidreset(Reveal_011) + vidstop(Reveal_010) vidreset(Reveal_010) + vidstop(Reveal_09) vidreset(Reveal_09) + vidstop(Reveal_08) vidreset(Reveal_08) + vidstop(Reveal_07) vidreset(Reveal_07) + vidstop(Reveal_06) vidreset(Reveal_06) + vidstop(Reveal_05) vidreset(Reveal_05) + vidstop(Reveal_04) vidreset(Reveal_04) + vidstop(Reveal_03) vidreset(Reveal_03) + vidstop(Reveal_02) vidreset(Reveal_02) + vidstop(Reveal_01) vidreset(Reveal_01) + + sleep(1) + + kill(Reveal_*) + + sleep(1) +) + +// --------------------------------------------- + +seq sWRSnodeal ( + +alloc(4) + + start() + + kill(offer_rotate) + kill(offer_frame) + + create(textbar .f=d2 .lb) + create(final_reveal .f=d2 .lb) + + // - polite applause + + sound(200) + + //sleep(100) + sleep(50) + + // - play the remaining girl's wide reveal + + fc(fcDondPlayNDWR) + sleep(240) + + fc(fcDondUnloadVideos) + + // - place the game in DOND_GAMEOVER_REVEAL mode + + fc(fcDondSetGameState 10) + + fc(fcDondFadeOut textbar) + fc(fcDondFadeOut final_reveal) + + // ... + + sound(201) + ani(- sCollect) + + kill(background) + kill(Reveal_*) + kill(revcase_*) + + kill(tick*) + kill(coup*) + + fc(fcDondDoGameOver 1) +) diff --git a/donddata/hd_pc/attract.g3 b/donddata/hd_pc/attract.g3 new file mode 100644 index 0000000..9ebc94b --- /dev/null +++ b/donddata/hd_pc/attract.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a17600b6f2a671d3949890c0d9b680747a39dc22e0d6ecbc81579d249379b3d5 +size 11055634 diff --git a/donddata/hd_pc/banker.g3 b/donddata/hd_pc/banker.g3 new file mode 100644 index 0000000..97ce7f1 --- /dev/null +++ b/donddata/hd_pc/banker.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4787d06c63d3d246ea4b128547820bd452163c92dbaf0e4239e66ff0d87b137d +size 19314745 diff --git a/donddata/hd_pc/collect.g3 b/donddata/hd_pc/collect.g3 new file mode 100644 index 0000000..b596a26 --- /dev/null +++ b/donddata/hd_pc/collect.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28a48d68f75a8ba6dcd8be991ae6c9c229abf0a9482964be6cf73d6bcee9bf6b +size 3664048 diff --git a/donddata/hd_pc/diag.g3 b/donddata/hd_pc/diag.g3 new file mode 100644 index 0000000..35fc2fc --- /dev/null +++ b/donddata/hd_pc/diag.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c324b580cf41e6ac0a13e626bbc34c6dd1d1aea6b52f1becbf0b24e93999dafd +size 4196180 diff --git a/donddata/hd_pc/dondTitle.g3 b/donddata/hd_pc/dondTitle.g3 new file mode 100644 index 0000000..be4e895 --- /dev/null +++ b/donddata/hd_pc/dondTitle.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f67c776dd1a01cf3d179588e68f8d0f4fa6801aac4a1fafed89c0f0adccebe33 +size 3801684 diff --git a/donddata/hd_pc/fnt_cont.g3 b/donddata/hd_pc/fnt_cont.g3 new file mode 100644 index 0000000..793c229 --- /dev/null +++ b/donddata/hd_pc/fnt_cont.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48e628601bedaf4aa9d155c3158d58dece159ad676bfee66d9c317a5062e4e6e +size 4197940 diff --git a/donddata/hd_pc/fnt_cred.g3 b/donddata/hd_pc/fnt_cred.g3 new file mode 100644 index 0000000..97dcede --- /dev/null +++ b/donddata/hd_pc/fnt_cred.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b9177c6f4149b69438fe1dc4c50f1288e0fc01dc0dd4f4b18c2739aed83e603 +size 66292 diff --git a/donddata/hd_pc/fnt_incase.g3 b/donddata/hd_pc/fnt_incase.g3 new file mode 100644 index 0000000..1c395ea --- /dev/null +++ b/donddata/hd_pc/fnt_incase.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a9f83d102be59e4656524f65581922752d38e5a35d78b8574505019f809e7b2 +size 262936 diff --git a/donddata/hd_pc/fnt_tb_big.g3 b/donddata/hd_pc/fnt_tb_big.g3 new file mode 100644 index 0000000..da9da7b --- /dev/null +++ b/donddata/hd_pc/fnt_tb_big.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2de267f6cc290a098eb12cb8ffae6c4c405431c6422c52f64209f3728b1baf6a +size 1050232 diff --git a/donddata/hd_pc/fnt_tb_small.g3 b/donddata/hd_pc/fnt_tb_small.g3 new file mode 100644 index 0000000..4f04dd0 --- /dev/null +++ b/donddata/hd_pc/fnt_tb_small.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54c52d35ad8802c463607abb98ff4e14b7dd25574f469c2a78453ef0beb639cd +size 263800 diff --git a/donddata/hd_pc/fnt_tbar_big.g3 b/donddata/hd_pc/fnt_tbar_big.g3 new file mode 100644 index 0000000..821ea8a --- /dev/null +++ b/donddata/hd_pc/fnt_tbar_big.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4dce26cd82969f8e133ed4c6c1a1dcfaf21c334809baaad28e84f5843a42f83e +size 262936 diff --git a/donddata/hd_pc/fnt_timer.g3 b/donddata/hd_pc/fnt_timer.g3 new file mode 100644 index 0000000..b693233 --- /dev/null +++ b/donddata/hd_pc/fnt_timer.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e286f4d2dd3bff5bccca067cada2cb6888afbb2e06201a11d0b0c2d40bfca2b4 +size 262900 diff --git a/donddata/hd_pc/fnt_vbar_lit.g3 b/donddata/hd_pc/fnt_vbar_lit.g3 new file mode 100644 index 0000000..68c60f1 --- /dev/null +++ b/donddata/hd_pc/fnt_vbar_lit.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:beb4b4683f80f266449ae6afb88db446d1892f84aa7d38c747e21750619e9bff +size 262936 diff --git a/donddata/hd_pc/fntarb24.g3 b/donddata/hd_pc/fntarb24.g3 new file mode 100644 index 0000000..e19837f --- /dev/null +++ b/donddata/hd_pc/fntarb24.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba9267be305eacc2f94eb34ea0ef43bd6ee7611cae4d6bbf52f6639704eb8084 +size 265780 diff --git a/donddata/hd_pc/fntarb36.g3 b/donddata/hd_pc/fntarb36.g3 new file mode 100644 index 0000000..90ceb18 --- /dev/null +++ b/donddata/hd_pc/fntarb36.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1feb12eb6db51b24696a2769a8632e8e4f0b54257f8149fdd5cc264e12a49604 +size 1052248 diff --git a/donddata/hd_pc/fntarb48.g3 b/donddata/hd_pc/fntarb48.g3 new file mode 100644 index 0000000..aa5de34 --- /dev/null +++ b/donddata/hd_pc/fntarb48.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e44632c05a472b0abb9f03b62a353d21b8fd6fe97cb1e498f448500c6695c726 +size 1052212 diff --git a/donddata/hd_pc/fntarb72.g3 b/donddata/hd_pc/fntarb72.g3 new file mode 100644 index 0000000..a09cb05 --- /dev/null +++ b/donddata/hd_pc/fntarb72.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8cc6961c08064a0eda40a31ba67d822b76c3ccf3876ac61c2f54acb3a560b808 +size 4197940 diff --git a/donddata/hd_pc/fntprofr.g3 b/donddata/hd_pc/fntprofr.g3 new file mode 100644 index 0000000..8c738d6 --- /dev/null +++ b/donddata/hd_pc/fntprofr.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34143024c62bf419c04235576d2e27b1bbc1bdf478810589333927eb2a402102 +size 66328 diff --git a/donddata/hd_pc/fntsans16.g3 b/donddata/hd_pc/fntsans16.g3 new file mode 100644 index 0000000..920d19b --- /dev/null +++ b/donddata/hd_pc/fntsans16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b01967b34124f281f9a2deb034e8be3517c3fe5a9209db352c8537ab83b2615 +size 265888 diff --git a/donddata/hd_pc/fntsans20.g3 b/donddata/hd_pc/fntsans20.g3 new file mode 100644 index 0000000..8e3982d --- /dev/null +++ b/donddata/hd_pc/fntsans20.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37ec3d5f13151a762acf5ef3c440335880a4370d47addffbe764d059db0b2ae6 +size 265744 diff --git a/donddata/hd_pc/fntsans24.g3 b/donddata/hd_pc/fntsans24.g3 new file mode 100644 index 0000000..a809be8 --- /dev/null +++ b/donddata/hd_pc/fntsans24.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e6adcf1997ab9ea5ff3dfd9a941fe2e83486cd71688555893d0084a156913c7 +size 265780 diff --git a/donddata/hd_pc/fntsans36.g3 b/donddata/hd_pc/fntsans36.g3 new file mode 100644 index 0000000..94352d1 --- /dev/null +++ b/donddata/hd_pc/fntsans36.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c84e3a0774c178db1dc3913c3e5edb80a4e033d3ae8fe2b73e1696f925357092 +size 1052212 diff --git a/donddata/hd_pc/frame_skips_01.g3 b/donddata/hd_pc/frame_skips_01.g3 new file mode 100644 index 0000000..29d6da5 --- /dev/null +++ b/donddata/hd_pc/frame_skips_01.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3dc85028f5081497c80bf583ef521675b395513e1a0fc2f1272fb19ea3ec598e +size 5245084 diff --git a/donddata/hd_pc/frame_skips_02.g3 b/donddata/hd_pc/frame_skips_02.g3 new file mode 100644 index 0000000..f7a5ab5 --- /dev/null +++ b/donddata/hd_pc/frame_skips_02.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d85318a9d49263af3bdda067f73bb4f458a045a55a944331afe3934bbbe7d18 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_03.g3 b/donddata/hd_pc/frame_skips_03.g3 new file mode 100644 index 0000000..d57303b --- /dev/null +++ b/donddata/hd_pc/frame_skips_03.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85a6531f6b0e2190d56cf3e257590ef9fdeb45ef4fec36f68a40a6faa04babf6 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_04.g3 b/donddata/hd_pc/frame_skips_04.g3 new file mode 100644 index 0000000..78530f1 --- /dev/null +++ b/donddata/hd_pc/frame_skips_04.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d11bb7057732138ca485bb69a4ea1aa059f8465a5df2ecf775b86ab869573f7d +size 5245084 diff --git a/donddata/hd_pc/frame_skips_05.g3 b/donddata/hd_pc/frame_skips_05.g3 new file mode 100644 index 0000000..efb2dbf --- /dev/null +++ b/donddata/hd_pc/frame_skips_05.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3beeaa9ddb0e8f0ae5eb57f4c1038077be1d0af5d5fa0c55e60dff53bc13d6b7 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_06.g3 b/donddata/hd_pc/frame_skips_06.g3 new file mode 100644 index 0000000..548e1b0 --- /dev/null +++ b/donddata/hd_pc/frame_skips_06.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e74a51af89c8b516a7d0d46d1907cc1377e6e9a92b134e902dd73db733727f1b +size 5245084 diff --git a/donddata/hd_pc/frame_skips_07.g3 b/donddata/hd_pc/frame_skips_07.g3 new file mode 100644 index 0000000..8e2a052 --- /dev/null +++ b/donddata/hd_pc/frame_skips_07.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f1d1b95e45037a75654e08bde98280445cf93bed95a9b2b1fbe19fc78355667 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_08.g3 b/donddata/hd_pc/frame_skips_08.g3 new file mode 100644 index 0000000..a8dc44e --- /dev/null +++ b/donddata/hd_pc/frame_skips_08.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5a024982c0b4c27bd26df445748c3ea418034fa47a7a03ffdf0a18f669fef1a +size 5245084 diff --git a/donddata/hd_pc/frame_skips_09.g3 b/donddata/hd_pc/frame_skips_09.g3 new file mode 100644 index 0000000..5d25e28 --- /dev/null +++ b/donddata/hd_pc/frame_skips_09.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42ec5e01f921e1696a840e7e8e8854b002594f209a461b783ccf5de8da506d0b +size 5245084 diff --git a/donddata/hd_pc/frame_skips_10.g3 b/donddata/hd_pc/frame_skips_10.g3 new file mode 100644 index 0000000..aafd741 --- /dev/null +++ b/donddata/hd_pc/frame_skips_10.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57bdbcaefac565c8175d308cfd9390dfc42198f0c8f4d81b893a330247244c27 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_11.g3 b/donddata/hd_pc/frame_skips_11.g3 new file mode 100644 index 0000000..c76da4c --- /dev/null +++ b/donddata/hd_pc/frame_skips_11.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbe28e380aea2fbf983c59dc4672d21a62889ef89c1cf24c780a5d3e11e74154 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_12.g3 b/donddata/hd_pc/frame_skips_12.g3 new file mode 100644 index 0000000..9d8bef1 --- /dev/null +++ b/donddata/hd_pc/frame_skips_12.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:487fd4be9473adc49f764a55daf7de75fd555cfcf377c1f7d1a47e6ed0ff7f02 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_13.g3 b/donddata/hd_pc/frame_skips_13.g3 new file mode 100644 index 0000000..eadbc5f --- /dev/null +++ b/donddata/hd_pc/frame_skips_13.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eeee3d0f46915125d52574697d0a0d1ecb4444635659548c75e14e25aa8ad2da +size 5245084 diff --git a/donddata/hd_pc/frame_skips_14.g3 b/donddata/hd_pc/frame_skips_14.g3 new file mode 100644 index 0000000..b9ff4e4 --- /dev/null +++ b/donddata/hd_pc/frame_skips_14.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43b2829e04992e0e164f31e05cf9b10cf90907de50452df83a32ffeffae449d9 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_15.g3 b/donddata/hd_pc/frame_skips_15.g3 new file mode 100644 index 0000000..a6cbfd7 --- /dev/null +++ b/donddata/hd_pc/frame_skips_15.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:909aabfbdbfaa9f0197c1a4e8647cf079ff1aeccd344f72eeeb6d0e37642a155 +size 5245084 diff --git a/donddata/hd_pc/frame_skips_16.g3 b/donddata/hd_pc/frame_skips_16.g3 new file mode 100644 index 0000000..91e0064 --- /dev/null +++ b/donddata/hd_pc/frame_skips_16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdace4ed4ec9d7ca9f543feb4c30182414cfda0a1bc916951bea7e7ecff6ae7a +size 5245084 diff --git a/donddata/hd_pc/frs_bad_01.g3 b/donddata/hd_pc/frs_bad_01.g3 new file mode 100644 index 0000000..895ff23 --- /dev/null +++ b/donddata/hd_pc/frs_bad_01.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa906756b0ae439ba58794d3bc94e13f02fedb56b0c2b11cacda5de2a3549d2d +size 1049120 diff --git a/donddata/hd_pc/frs_bad_02.g3 b/donddata/hd_pc/frs_bad_02.g3 new file mode 100644 index 0000000..19a9975 --- /dev/null +++ b/donddata/hd_pc/frs_bad_02.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3764292cb978b97f7b35b6c605b5dac44b0a2a7150c60e711fd4725e47455ccb +size 1049120 diff --git a/donddata/hd_pc/frs_bad_03.g3 b/donddata/hd_pc/frs_bad_03.g3 new file mode 100644 index 0000000..754225e --- /dev/null +++ b/donddata/hd_pc/frs_bad_03.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0cb465ce7d27c2fe6283499d833372de5b69929b9a430973f9c93b2b3887536 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_04.g3 b/donddata/hd_pc/frs_bad_04.g3 new file mode 100644 index 0000000..5c8d91f --- /dev/null +++ b/donddata/hd_pc/frs_bad_04.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91375bcdaea4556f46b18322bcab2ed0b1183ab0c61f5ddbd6390f44fe9506ee +size 1049120 diff --git a/donddata/hd_pc/frs_bad_05.g3 b/donddata/hd_pc/frs_bad_05.g3 new file mode 100644 index 0000000..4bab0ea --- /dev/null +++ b/donddata/hd_pc/frs_bad_05.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08c4496b045ab97fdac0d6155e4ffc81c0dac29c480eb209257631fed2f9a47f +size 1049120 diff --git a/donddata/hd_pc/frs_bad_06.g3 b/donddata/hd_pc/frs_bad_06.g3 new file mode 100644 index 0000000..0dc67bf --- /dev/null +++ b/donddata/hd_pc/frs_bad_06.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4402206065af156b04264b6f1a939b9342e89b7d3190903811ef8ddebe3a6bb6 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_07.g3 b/donddata/hd_pc/frs_bad_07.g3 new file mode 100644 index 0000000..47b5384 --- /dev/null +++ b/donddata/hd_pc/frs_bad_07.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97cdc92b45186f11d4635846852d5b5fcb89fd88b5af892fdf7d4548104337dd +size 1049120 diff --git a/donddata/hd_pc/frs_bad_08.g3 b/donddata/hd_pc/frs_bad_08.g3 new file mode 100644 index 0000000..c2ed8ed --- /dev/null +++ b/donddata/hd_pc/frs_bad_08.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23f5c51260f4e9c7bcb7c7208735cb53f10b331afb9a6b5d404307489c4a6c69 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_09.g3 b/donddata/hd_pc/frs_bad_09.g3 new file mode 100644 index 0000000..9adf594 --- /dev/null +++ b/donddata/hd_pc/frs_bad_09.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f176973f6972aec9de72a7e110fd3f5971568e061acd608445ad8ef4bd18dd28 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_10.g3 b/donddata/hd_pc/frs_bad_10.g3 new file mode 100644 index 0000000..f83833d --- /dev/null +++ b/donddata/hd_pc/frs_bad_10.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6471b925000e3c2816f6268bcc652d2c5e8e604e6710cd187074666069c34ad6 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_11.g3 b/donddata/hd_pc/frs_bad_11.g3 new file mode 100644 index 0000000..a900800 --- /dev/null +++ b/donddata/hd_pc/frs_bad_11.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e67e48ecc913ad4042fc1ea072d3162f93cddeb3f62e6697a9858219fad290d +size 1049120 diff --git a/donddata/hd_pc/frs_bad_12.g3 b/donddata/hd_pc/frs_bad_12.g3 new file mode 100644 index 0000000..e6faad8 --- /dev/null +++ b/donddata/hd_pc/frs_bad_12.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26e0c77355d45229b17f6a6c8e062a6d8e44a2ad4f8706a8fec0cf680647efe4 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_13.g3 b/donddata/hd_pc/frs_bad_13.g3 new file mode 100644 index 0000000..7eb0c4f --- /dev/null +++ b/donddata/hd_pc/frs_bad_13.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee48d526215277849e3b72d7eba7055b6eb002666f19f4c46d691d1815965dfb +size 1049120 diff --git a/donddata/hd_pc/frs_bad_14.g3 b/donddata/hd_pc/frs_bad_14.g3 new file mode 100644 index 0000000..e5d497f --- /dev/null +++ b/donddata/hd_pc/frs_bad_14.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9009887c7a635eb77523aec597d12d3b6e05e95b9f905243966d0cf942e4829f +size 1049120 diff --git a/donddata/hd_pc/frs_bad_15.g3 b/donddata/hd_pc/frs_bad_15.g3 new file mode 100644 index 0000000..7f32598 --- /dev/null +++ b/donddata/hd_pc/frs_bad_15.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7bf23418797303f9c06630beef56a49631191960701febbc7295ceac48153f25 +size 1049120 diff --git a/donddata/hd_pc/frs_bad_16.g3 b/donddata/hd_pc/frs_bad_16.g3 new file mode 100644 index 0000000..199df51 --- /dev/null +++ b/donddata/hd_pc/frs_bad_16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd7b7c4c66617ebbc1321dd29d7c8d428af8d86c94241a8fffc7dfad9d95dc0e +size 1049120 diff --git a/donddata/hd_pc/frs_happy_01.g3 b/donddata/hd_pc/frs_happy_01.g3 new file mode 100644 index 0000000..1e4a76c --- /dev/null +++ b/donddata/hd_pc/frs_happy_01.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf29abd6ea224a744422bcc4478c4db1e6fcd4000ee202c7fa681829e1ae4494 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_02.g3 b/donddata/hd_pc/frs_happy_02.g3 new file mode 100644 index 0000000..6201e3c --- /dev/null +++ b/donddata/hd_pc/frs_happy_02.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19bef0c040d6b87d352c909d58a411b8477e05027d1e4bf4e6ad5939f6a97c95 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_03.g3 b/donddata/hd_pc/frs_happy_03.g3 new file mode 100644 index 0000000..5774275 --- /dev/null +++ b/donddata/hd_pc/frs_happy_03.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76c191a9a589503a42efd5a2813a4c564600bac6a586cc5f0f902dc795cb62fd +size 1049120 diff --git a/donddata/hd_pc/frs_happy_04.g3 b/donddata/hd_pc/frs_happy_04.g3 new file mode 100644 index 0000000..ff51f89 --- /dev/null +++ b/donddata/hd_pc/frs_happy_04.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5af687b0daf0ca4133728c10a9e298d60a5cba3cd4ff21246dca5679ca2c2e13 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_05.g3 b/donddata/hd_pc/frs_happy_05.g3 new file mode 100644 index 0000000..b828f34 --- /dev/null +++ b/donddata/hd_pc/frs_happy_05.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc5b411c4d794b09bb9e91e2e237b3a57e36f369f34505c5931422340f057548 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_06.g3 b/donddata/hd_pc/frs_happy_06.g3 new file mode 100644 index 0000000..a693b4b --- /dev/null +++ b/donddata/hd_pc/frs_happy_06.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:914001aa543e372dd28ea1f5207a2dfad54aaeaa3f8d19682d212ec30a1c3e8b +size 1049120 diff --git a/donddata/hd_pc/frs_happy_07.g3 b/donddata/hd_pc/frs_happy_07.g3 new file mode 100644 index 0000000..93ac142 --- /dev/null +++ b/donddata/hd_pc/frs_happy_07.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:224104d17984d8bf407b4f91c0b2b8a5b878fc932483f859af9778799abd83ed +size 1049120 diff --git a/donddata/hd_pc/frs_happy_08.g3 b/donddata/hd_pc/frs_happy_08.g3 new file mode 100644 index 0000000..49aef2f --- /dev/null +++ b/donddata/hd_pc/frs_happy_08.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1862f8a8129200a2b32de0fcd42646a0fbb622951c6063cd82188e4f94659961 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_09.g3 b/donddata/hd_pc/frs_happy_09.g3 new file mode 100644 index 0000000..193e010 --- /dev/null +++ b/donddata/hd_pc/frs_happy_09.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:294ebf550e180f634c41f748e48ab2f378b1f7c25ae465416731f558f3526e1f +size 1049120 diff --git a/donddata/hd_pc/frs_happy_10.g3 b/donddata/hd_pc/frs_happy_10.g3 new file mode 100644 index 0000000..9d4e2f6 --- /dev/null +++ b/donddata/hd_pc/frs_happy_10.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f4aef651838eeb7269f5968049c81b6c7518b54ae0f695a586203a53b62d24b +size 1049120 diff --git a/donddata/hd_pc/frs_happy_11.g3 b/donddata/hd_pc/frs_happy_11.g3 new file mode 100644 index 0000000..d23f15e --- /dev/null +++ b/donddata/hd_pc/frs_happy_11.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec4d13a1808b4e06dfe6eb0cc01d2973e90102c017da291760ec36f97ae545d0 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_12.g3 b/donddata/hd_pc/frs_happy_12.g3 new file mode 100644 index 0000000..15f97ba --- /dev/null +++ b/donddata/hd_pc/frs_happy_12.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82c6c4645c84048696f99417e5ac3e666255d98e6146a2033a9e1fc7670007de +size 1049120 diff --git a/donddata/hd_pc/frs_happy_13.g3 b/donddata/hd_pc/frs_happy_13.g3 new file mode 100644 index 0000000..cb5e5a8 --- /dev/null +++ b/donddata/hd_pc/frs_happy_13.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b7e7b6ed516d16291558452199a92a68100bca88f467aa7d3c25497d3d78985c +size 1049120 diff --git a/donddata/hd_pc/frs_happy_14.g3 b/donddata/hd_pc/frs_happy_14.g3 new file mode 100644 index 0000000..1db2d33 --- /dev/null +++ b/donddata/hd_pc/frs_happy_14.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2e5fe3d4109be0e41b3c9e92552d21b086c54630c038fd50235010e221c9ca4 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_15.g3 b/donddata/hd_pc/frs_happy_15.g3 new file mode 100644 index 0000000..656ed26 --- /dev/null +++ b/donddata/hd_pc/frs_happy_15.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e9e9cd53ec2cdb894b4db74c610ae11e1ed0947f1168181123896d59ede21b5 +size 1049120 diff --git a/donddata/hd_pc/frs_happy_16.g3 b/donddata/hd_pc/frs_happy_16.g3 new file mode 100644 index 0000000..2fe2ae0 --- /dev/null +++ b/donddata/hd_pc/frs_happy_16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3003730123464b639cd7ec71aca674bd5e4b16dc97c6453e4daeeb6cec5ec407 +size 1049120 diff --git a/donddata/hd_pc/frs_select_01.g3 b/donddata/hd_pc/frs_select_01.g3 new file mode 100644 index 0000000..653dbff --- /dev/null +++ b/donddata/hd_pc/frs_select_01.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd03ab77fd3d93e34ca18cb01fb84c4669b7a1d7fcf3653bd5ef40b5eeb34bf3 +size 1049120 diff --git a/donddata/hd_pc/frs_select_02.g3 b/donddata/hd_pc/frs_select_02.g3 new file mode 100644 index 0000000..8008b70 --- /dev/null +++ b/donddata/hd_pc/frs_select_02.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ff4ddad5b58e718dbdb99df86436f224ed75d89a028d8e45b91e5e460b332b7 +size 1049120 diff --git a/donddata/hd_pc/frs_select_03.g3 b/donddata/hd_pc/frs_select_03.g3 new file mode 100644 index 0000000..98ba0ce --- /dev/null +++ b/donddata/hd_pc/frs_select_03.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b7aa0988326968ca46bc5b038546ce972af21e437f06a589fe82491d055237a +size 1049120 diff --git a/donddata/hd_pc/frs_select_04.g3 b/donddata/hd_pc/frs_select_04.g3 new file mode 100644 index 0000000..55c5059 --- /dev/null +++ b/donddata/hd_pc/frs_select_04.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b40213cbdff8d42a04268665073bafe06b0108963a8fa63cb95781cf96d6a0b +size 1049120 diff --git a/donddata/hd_pc/frs_select_05.g3 b/donddata/hd_pc/frs_select_05.g3 new file mode 100644 index 0000000..db98eba --- /dev/null +++ b/donddata/hd_pc/frs_select_05.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:45c2802f5d4de1a8392ab440819d622c5432939a74ac6d5266bcb46e139a31bf +size 1049120 diff --git a/donddata/hd_pc/frs_select_06.g3 b/donddata/hd_pc/frs_select_06.g3 new file mode 100644 index 0000000..c633b0b --- /dev/null +++ b/donddata/hd_pc/frs_select_06.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f1df6123e8bbb2b6a76787c507c9901203ba0e946d0a808d6f43da2b1058fd3 +size 1049120 diff --git a/donddata/hd_pc/frs_select_07.g3 b/donddata/hd_pc/frs_select_07.g3 new file mode 100644 index 0000000..4ad3bce --- /dev/null +++ b/donddata/hd_pc/frs_select_07.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5b6a1ac23bf40ada279efff1d5b733cc5078acdc7fd0ac2070a8688ac29640a +size 1049120 diff --git a/donddata/hd_pc/frs_select_08.g3 b/donddata/hd_pc/frs_select_08.g3 new file mode 100644 index 0000000..78da0e8 --- /dev/null +++ b/donddata/hd_pc/frs_select_08.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7dd5a3c59a019b4e56ac779d1a75e2b7f1405cbad3aefb39ab22507618450a51 +size 1049120 diff --git a/donddata/hd_pc/frs_select_09.g3 b/donddata/hd_pc/frs_select_09.g3 new file mode 100644 index 0000000..3f18cf3 --- /dev/null +++ b/donddata/hd_pc/frs_select_09.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66f4c19773120407566ae41f68e7b8230935240615111bc6c3c0563921e7d535 +size 1049120 diff --git a/donddata/hd_pc/frs_select_10.g3 b/donddata/hd_pc/frs_select_10.g3 new file mode 100644 index 0000000..d3fbe8b --- /dev/null +++ b/donddata/hd_pc/frs_select_10.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9182ade2d73a8281eb8bafbffb62b74ea3f8997f985d8738796bb98bb335f90d +size 1049120 diff --git a/donddata/hd_pc/frs_select_11.g3 b/donddata/hd_pc/frs_select_11.g3 new file mode 100644 index 0000000..fb1b40e --- /dev/null +++ b/donddata/hd_pc/frs_select_11.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5012b3dc5afac44b908a0ab1ae33d56a3b6d41703055104bb821065efc04608 +size 1049120 diff --git a/donddata/hd_pc/frs_select_12.g3 b/donddata/hd_pc/frs_select_12.g3 new file mode 100644 index 0000000..7a6acfe --- /dev/null +++ b/donddata/hd_pc/frs_select_12.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb6a46cb35722fed0d0cbbd7cbcaf5d1afa841f8f98ac2a89b9fbc24623237f1 +size 1049120 diff --git a/donddata/hd_pc/frs_select_13.g3 b/donddata/hd_pc/frs_select_13.g3 new file mode 100644 index 0000000..f37138f --- /dev/null +++ b/donddata/hd_pc/frs_select_13.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0da57c0e8a1bafaf3c424f15b80775310ec151f433d6c876d37a27eaf7dccf2e +size 1049120 diff --git a/donddata/hd_pc/frs_select_14.g3 b/donddata/hd_pc/frs_select_14.g3 new file mode 100644 index 0000000..ed7a486 --- /dev/null +++ b/donddata/hd_pc/frs_select_14.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02ce9fbb267b3a7a5be3a4838b2a12d9075f8c2b5c9cc28c41d4abdbab0ed256 +size 1049120 diff --git a/donddata/hd_pc/frs_select_15.g3 b/donddata/hd_pc/frs_select_15.g3 new file mode 100644 index 0000000..423e8c0 --- /dev/null +++ b/donddata/hd_pc/frs_select_15.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d05826765fd5f5f1dd5ee830bfb321c6ee3ba6485157fc50cf40bfeeb81eab5c +size 1049120 diff --git a/donddata/hd_pc/frs_select_16.g3 b/donddata/hd_pc/frs_select_16.g3 new file mode 100644 index 0000000..6540d6f --- /dev/null +++ b/donddata/hd_pc/frs_select_16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:923255d4bfb3b7f3e9196406f192265df92bd1f9955091d1b60a9efe1210f809 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_01.g3 b/donddata/hd_pc/frs_shappy_01.g3 new file mode 100644 index 0000000..72f2c11 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_01.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0211a0af664f02f8bc404b36b28d26f43557a7cecbfc4cbf59aaebc3143f9cfa +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_02.g3 b/donddata/hd_pc/frs_shappy_02.g3 new file mode 100644 index 0000000..584cd97 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_02.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:978f26a903f72f11b491b4c17346f992675edf11fa35601781995e827abf8ee3 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_03.g3 b/donddata/hd_pc/frs_shappy_03.g3 new file mode 100644 index 0000000..965ea6c --- /dev/null +++ b/donddata/hd_pc/frs_shappy_03.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0d9ce1e52b3151fa50c250dcdf8c3ffa17a05a2745034ca2e6775ca2a28012d +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_04.g3 b/donddata/hd_pc/frs_shappy_04.g3 new file mode 100644 index 0000000..e5573d8 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_04.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8d4cb142c8d030ef776650c2de56eec3d4709966d1e74d92e0117cee0d10825 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_05.g3 b/donddata/hd_pc/frs_shappy_05.g3 new file mode 100644 index 0000000..e6ffde5 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_05.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:beed7150cbf460f4e52d5acfab6463d62f1b0eaf3a9863f136d191f457202b6b +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_06.g3 b/donddata/hd_pc/frs_shappy_06.g3 new file mode 100644 index 0000000..93432ed --- /dev/null +++ b/donddata/hd_pc/frs_shappy_06.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b342e3698841ac646ecf1a4fce3ba5ac8bd43165255dbb8a2d9aca281b450957 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_07.g3 b/donddata/hd_pc/frs_shappy_07.g3 new file mode 100644 index 0000000..9df72c3 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_07.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92297b06470d12fcf8d937aa0c808493b5c5689f055b32163e809069f33a9e2f +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_08.g3 b/donddata/hd_pc/frs_shappy_08.g3 new file mode 100644 index 0000000..0cc35dd --- /dev/null +++ b/donddata/hd_pc/frs_shappy_08.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8785ae231baee5a753a7c4ea273d13bd8dcf0ed3c6fab2d52447b3ee4e862eaa +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_09.g3 b/donddata/hd_pc/frs_shappy_09.g3 new file mode 100644 index 0000000..7451821 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_09.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:896c8efec4be66bf161329ae9327305ecb1814f2089bc13db3bdb65f146cd5c4 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_10.g3 b/donddata/hd_pc/frs_shappy_10.g3 new file mode 100644 index 0000000..95ab63a --- /dev/null +++ b/donddata/hd_pc/frs_shappy_10.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c19377b20fdd7f0551da1a041e32fbe9f96580b26339d1e266ecba24ebe6f4cf +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_11.g3 b/donddata/hd_pc/frs_shappy_11.g3 new file mode 100644 index 0000000..742d1ba --- /dev/null +++ b/donddata/hd_pc/frs_shappy_11.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc2124cb144efe74908e4e6732f16d4243f83abbcb61ccbf605373a6fdacdd5d +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_12.g3 b/donddata/hd_pc/frs_shappy_12.g3 new file mode 100644 index 0000000..601a23d --- /dev/null +++ b/donddata/hd_pc/frs_shappy_12.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50fabea9bdbc4da5a42f7add00a8a1c59eb4f996c296bffeeedd5928f915edf7 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_13.g3 b/donddata/hd_pc/frs_shappy_13.g3 new file mode 100644 index 0000000..ad00c5f --- /dev/null +++ b/donddata/hd_pc/frs_shappy_13.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10b00c899d013e88b69349c3dc2b56d8682082d50b2c475e87f4efab540ea389 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_14.g3 b/donddata/hd_pc/frs_shappy_14.g3 new file mode 100644 index 0000000..6a69cf8 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_14.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8229be0b59b2d64e8747f52a6a7690afbeb5660af7eedb7d5c39e3c7d954748f +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_15.g3 b/donddata/hd_pc/frs_shappy_15.g3 new file mode 100644 index 0000000..3c4bf4d --- /dev/null +++ b/donddata/hd_pc/frs_shappy_15.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9c32b558823545fcdc3d98e7c42290a005a553d1a3c1706c26b7f27c3ebbdc1 +size 1049120 diff --git a/donddata/hd_pc/frs_shappy_16.g3 b/donddata/hd_pc/frs_shappy_16.g3 new file mode 100644 index 0000000..d71a865 --- /dev/null +++ b/donddata/hd_pc/frs_shappy_16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df3df3853dfb1c07a356ac85126eebebfd43648adc93c619416be66a03405f0a +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_01.g3 b/donddata/hd_pc/frs_tneutral_01.g3 new file mode 100644 index 0000000..8b1e470 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_01.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b624384fc283c7e29afab255e5944b9578cfe0c70b4005ce4fe36a98a646d15 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_02.g3 b/donddata/hd_pc/frs_tneutral_02.g3 new file mode 100644 index 0000000..460ef91 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_02.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21add1ea830af33cfc9c8d5ca68fd494a63f658794c34152183e4b187f6d2da9 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_03.g3 b/donddata/hd_pc/frs_tneutral_03.g3 new file mode 100644 index 0000000..e24394d --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_03.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33b6108652177c3037decea9c43d361495cce886d9a13f5e9339af59039a2175 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_04.g3 b/donddata/hd_pc/frs_tneutral_04.g3 new file mode 100644 index 0000000..d18e0f7 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_04.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d04847744b4dc2998c2cf6bae4eab70bd6408715cc55bbb545ab2c4d50d9e082 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_05.g3 b/donddata/hd_pc/frs_tneutral_05.g3 new file mode 100644 index 0000000..95a23b3 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_05.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9391b9e0d15119a7a907195d63d411e082644c27c7381d8b9a7b48f71b651a4e +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_06.g3 b/donddata/hd_pc/frs_tneutral_06.g3 new file mode 100644 index 0000000..cc5f85e --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_06.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f25ccf17a1034c6bdb5755c1a53e5f9a4a27dcddb870635a88e7979f3a0757a +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_07.g3 b/donddata/hd_pc/frs_tneutral_07.g3 new file mode 100644 index 0000000..58b1563 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_07.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2029a13ee8ff9a725a719c546a68271c3474f322ca222de543f0ea5be3ac8e2 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_08.g3 b/donddata/hd_pc/frs_tneutral_08.g3 new file mode 100644 index 0000000..d617051 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_08.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a575d853dfc611f442b92c4fe50bf27b618b2fc864d2c801d6b6e02437263c5d +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_09.g3 b/donddata/hd_pc/frs_tneutral_09.g3 new file mode 100644 index 0000000..9f158bc --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_09.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2be204c751fc7f0144669365d98e2fdaeee6db3afa205ffd0c1406aa87215789 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_10.g3 b/donddata/hd_pc/frs_tneutral_10.g3 new file mode 100644 index 0000000..3adf308 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_10.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1bdafcd5be79dd7c8cef5e3115331282c02fe27895a5f92eadae352ae7750fd +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_11.g3 b/donddata/hd_pc/frs_tneutral_11.g3 new file mode 100644 index 0000000..7107c89 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_11.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac1c724eca42f45af880d43d424ebeb2fabc656b48ebb7dc19c5ca5c633787e9 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_12.g3 b/donddata/hd_pc/frs_tneutral_12.g3 new file mode 100644 index 0000000..56c2748 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_12.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8e34162bc302cb17542fa3f43ae58b27c48ae75e07102de7d6494e3dc156215 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_13.g3 b/donddata/hd_pc/frs_tneutral_13.g3 new file mode 100644 index 0000000..4905d89 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_13.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6271871b179a98a25dc1c7f8c67eed911d9df885c0d0f5ee33bc63727c23a5a +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_14.g3 b/donddata/hd_pc/frs_tneutral_14.g3 new file mode 100644 index 0000000..0dc6831 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_14.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bfdef00a14927d6847cf09bba642efc23612ed7745025c45108ad97c9dc0d9c +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_15.g3 b/donddata/hd_pc/frs_tneutral_15.g3 new file mode 100644 index 0000000..8e8100f --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_15.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:955c598fcb0ee5c92505e28f957f89911c3cfae6e0298d5fb3bc0c7732e54404 +size 1049120 diff --git a/donddata/hd_pc/frs_tneutral_16.g3 b/donddata/hd_pc/frs_tneutral_16.g3 new file mode 100644 index 0000000..c30e336 --- /dev/null +++ b/donddata/hd_pc/frs_tneutral_16.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca81d0f787046d32d77bd37d25dc02cfe6f98857bfb0655842ed7d2f32857b98 +size 1049120 diff --git a/donddata/hd_pc/models_wide.g3 b/donddata/hd_pc/models_wide.g3 new file mode 100644 index 0000000..3cd5b0c --- /dev/null +++ b/donddata/hd_pc/models_wide.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d79e94cc3b820a84a3c60795ae584cad16473096df788abeba7321c7e6c574e7 +size 40588617 diff --git a/donddata/hd_pc/mr_01_bad.g3 b/donddata/hd_pc/mr_01_bad.g3 new file mode 100644 index 0000000..d2f0300 --- /dev/null +++ b/donddata/hd_pc/mr_01_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71966d8aa41b7e4e07deac49c37817bc67bff477f984218e226ad460e54c6ada +size 3153762 diff --git a/donddata/hd_pc/mr_01_happy.g3 b/donddata/hd_pc/mr_01_happy.g3 new file mode 100644 index 0000000..252556b --- /dev/null +++ b/donddata/hd_pc/mr_01_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1e9000892cd7201263f300cd1057f99444421caad66e5c4639c9f0e056ce4d4 +size 3154936 diff --git a/donddata/hd_pc/mr_01_select.g3 b/donddata/hd_pc/mr_01_select.g3 new file mode 100644 index 0000000..2aef549 --- /dev/null +++ b/donddata/hd_pc/mr_01_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5a9d1bac1e30975809cd67c6792321402ff73ca6ab40b1ad1b617cd10a5de68 +size 2977652 diff --git a/donddata/hd_pc/mr_01_shappy.g3 b/donddata/hd_pc/mr_01_shappy.g3 new file mode 100644 index 0000000..2d20322 --- /dev/null +++ b/donddata/hd_pc/mr_01_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5155fddb72b86a784c51c075068ca9365459c32c35e6239147d9c57207c06f76 +size 3308799 diff --git a/donddata/hd_pc/mr_01_tneutral.g3 b/donddata/hd_pc/mr_01_tneutral.g3 new file mode 100644 index 0000000..69aa3a9 --- /dev/null +++ b/donddata/hd_pc/mr_01_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd56aafee9abcc622daae180452d5cabff2b6f47fa60e3540a0997e6da683784 +size 2894503 diff --git a/donddata/hd_pc/mr_02_bad.g3 b/donddata/hd_pc/mr_02_bad.g3 new file mode 100644 index 0000000..4d33875 --- /dev/null +++ b/donddata/hd_pc/mr_02_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8c63ce41596ab373f44813492d9c7265f2d52375ad2e71d72a5a43e6105fd17 +size 3212860 diff --git a/donddata/hd_pc/mr_02_happy.g3 b/donddata/hd_pc/mr_02_happy.g3 new file mode 100644 index 0000000..22ef963 --- /dev/null +++ b/donddata/hd_pc/mr_02_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48bb73ee0671f7ad8c38c4f0b5f14b455b124f347e11bc6117d0ad47f449f4ef +size 3336157 diff --git a/donddata/hd_pc/mr_02_select.g3 b/donddata/hd_pc/mr_02_select.g3 new file mode 100644 index 0000000..d9d60d7 --- /dev/null +++ b/donddata/hd_pc/mr_02_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20581b6699a452d9af06eda98d5024ffc7beac6075113283fe5ef73d6d5d7749 +size 3065241 diff --git a/donddata/hd_pc/mr_02_shappy.g3 b/donddata/hd_pc/mr_02_shappy.g3 new file mode 100644 index 0000000..74fb9f5 --- /dev/null +++ b/donddata/hd_pc/mr_02_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a18901279ac233e33446504f645f77cb46e28cdee0b7f93189420bc15d6b4f9 +size 4027976 diff --git a/donddata/hd_pc/mr_02_tneutral.g3 b/donddata/hd_pc/mr_02_tneutral.g3 new file mode 100644 index 0000000..ff654b5 --- /dev/null +++ b/donddata/hd_pc/mr_02_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aefef5a489fc01957e96f3dc1c1cd0c26c012b477f563afefe741844c230ad1b +size 3013460 diff --git a/donddata/hd_pc/mr_03_bad.g3 b/donddata/hd_pc/mr_03_bad.g3 new file mode 100644 index 0000000..9a168e0 --- /dev/null +++ b/donddata/hd_pc/mr_03_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee1fc3c7d9da781012967956ff3dae4a2394d77ae2f97265bdc3cb43100036e9 +size 3447790 diff --git a/donddata/hd_pc/mr_03_happy.g3 b/donddata/hd_pc/mr_03_happy.g3 new file mode 100644 index 0000000..b24bc24 --- /dev/null +++ b/donddata/hd_pc/mr_03_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d58b2300bc5ca345cad9832f6a9cef27382ba6a9fac44ddef67e759110b0724 +size 3135302 diff --git a/donddata/hd_pc/mr_03_select.g3 b/donddata/hd_pc/mr_03_select.g3 new file mode 100644 index 0000000..17269fc --- /dev/null +++ b/donddata/hd_pc/mr_03_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6573f95cb16362401f9d8aadea2d6e575ab2f15ef5edd24d00eed066f16aba00 +size 2919813 diff --git a/donddata/hd_pc/mr_03_shappy.g3 b/donddata/hd_pc/mr_03_shappy.g3 new file mode 100644 index 0000000..5d9fe76 --- /dev/null +++ b/donddata/hd_pc/mr_03_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbb9b9be01739ed137aa2790839bd34c49d8dcf9025e9b8fb7d00dbf79966363 +size 3242387 diff --git a/donddata/hd_pc/mr_03_tneutral.g3 b/donddata/hd_pc/mr_03_tneutral.g3 new file mode 100644 index 0000000..585bf89 --- /dev/null +++ b/donddata/hd_pc/mr_03_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7560d9bca64b0c1332aca7d8d08bcf8a9818281809c0da31bb573b0fd2688da +size 2978885 diff --git a/donddata/hd_pc/mr_04_bad.g3 b/donddata/hd_pc/mr_04_bad.g3 new file mode 100644 index 0000000..7cd0c9a --- /dev/null +++ b/donddata/hd_pc/mr_04_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4108e34e3424c2952de152adc9e30bd6ad0f74be4cbd373af62a9c06d9cb0e0 +size 3422229 diff --git a/donddata/hd_pc/mr_04_happy.g3 b/donddata/hd_pc/mr_04_happy.g3 new file mode 100644 index 0000000..6f7b150 --- /dev/null +++ b/donddata/hd_pc/mr_04_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:220ff5b46df1819fa6bfc852bdf29d0ce3879faa97a0940d67a9972e40183363 +size 3318078 diff --git a/donddata/hd_pc/mr_04_select.g3 b/donddata/hd_pc/mr_04_select.g3 new file mode 100644 index 0000000..73f07c5 --- /dev/null +++ b/donddata/hd_pc/mr_04_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a05f38d6f570bee9a227172bc29d97f6d0e3148ba3576b24101fce1835fc884 +size 3313500 diff --git a/donddata/hd_pc/mr_04_shappy.g3 b/donddata/hd_pc/mr_04_shappy.g3 new file mode 100644 index 0000000..ef31d73 --- /dev/null +++ b/donddata/hd_pc/mr_04_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9b87ae1028382dade5e1f4816865edbb08cacd3e2463e9cb11da74f55e4736b +size 3813534 diff --git a/donddata/hd_pc/mr_04_tneutral.g3 b/donddata/hd_pc/mr_04_tneutral.g3 new file mode 100644 index 0000000..ac17ba2 --- /dev/null +++ b/donddata/hd_pc/mr_04_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21525a8e71ef703a40552e2ded3e8b20df3f164b3761641de58a54f360164841 +size 2957947 diff --git a/donddata/hd_pc/mr_05_bad.g3 b/donddata/hd_pc/mr_05_bad.g3 new file mode 100644 index 0000000..26bec78 --- /dev/null +++ b/donddata/hd_pc/mr_05_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b4f1773173cd9d0ff5b176d11dd3df00eb1d13cc802730bec650c220b88beae +size 3394494 diff --git a/donddata/hd_pc/mr_05_happy.g3 b/donddata/hd_pc/mr_05_happy.g3 new file mode 100644 index 0000000..16e9ec4 --- /dev/null +++ b/donddata/hd_pc/mr_05_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8177d56424c7fac90f578118bf767894044d74235116705ab9b2e5fa29e290c +size 3465102 diff --git a/donddata/hd_pc/mr_05_select.g3 b/donddata/hd_pc/mr_05_select.g3 new file mode 100644 index 0000000..47716a1 --- /dev/null +++ b/donddata/hd_pc/mr_05_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a3b48c09cb574fb1ef74f14f3090220810ec735acb931f534fb264d151f699e5 +size 3005068 diff --git a/donddata/hd_pc/mr_05_shappy.g3 b/donddata/hd_pc/mr_05_shappy.g3 new file mode 100644 index 0000000..dcac8ba --- /dev/null +++ b/donddata/hd_pc/mr_05_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e18444fa26343cd4c0444e11383fb210b33b2843dff25ce18be887292c86251 +size 3298621 diff --git a/donddata/hd_pc/mr_05_tneutral.g3 b/donddata/hd_pc/mr_05_tneutral.g3 new file mode 100644 index 0000000..8955c89 --- /dev/null +++ b/donddata/hd_pc/mr_05_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6b0dd440a75a485d8cb90883fc617525c07a12110964f2abe2f034d5843c147 +size 3095162 diff --git a/donddata/hd_pc/mr_06_bad.g3 b/donddata/hd_pc/mr_06_bad.g3 new file mode 100644 index 0000000..e72bd4f --- /dev/null +++ b/donddata/hd_pc/mr_06_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83bb9545c91d4bc0487672fb993141c076c03ce5ae69cf98bbafc01e6165bd00 +size 2972908 diff --git a/donddata/hd_pc/mr_06_happy.g3 b/donddata/hd_pc/mr_06_happy.g3 new file mode 100644 index 0000000..76e57a8 --- /dev/null +++ b/donddata/hd_pc/mr_06_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18df721d1ce0d3ccc253adc3399ac7bd16d233d98fa72f9df30f1fe40646859b +size 3021910 diff --git a/donddata/hd_pc/mr_06_select.g3 b/donddata/hd_pc/mr_06_select.g3 new file mode 100644 index 0000000..3c2115c --- /dev/null +++ b/donddata/hd_pc/mr_06_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2849d8a2fbc9451103427e84c44c1024eb2605a7e7f191670bb430b95edde3e2 +size 2809566 diff --git a/donddata/hd_pc/mr_06_shappy.g3 b/donddata/hd_pc/mr_06_shappy.g3 new file mode 100644 index 0000000..21ff6a9 --- /dev/null +++ b/donddata/hd_pc/mr_06_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:991d33b5c162c173186534e7cd7824d86143bdaaeb82315293433f8da1aa71a5 +size 3130056 diff --git a/donddata/hd_pc/mr_06_tneutral.g3 b/donddata/hd_pc/mr_06_tneutral.g3 new file mode 100644 index 0000000..f06dbea --- /dev/null +++ b/donddata/hd_pc/mr_06_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78ae75553589c535af2b42d4031e56f8fa53c0d5d05a077c00be1780c952dd87 +size 2955948 diff --git a/donddata/hd_pc/mr_07_bad.g3 b/donddata/hd_pc/mr_07_bad.g3 new file mode 100644 index 0000000..0405a7d --- /dev/null +++ b/donddata/hd_pc/mr_07_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:afc84ca3b0a30701bf7357290a0d146fe326a1a35e05b2aa7bb28f371f3a7534 +size 3187754 diff --git a/donddata/hd_pc/mr_07_happy.g3 b/donddata/hd_pc/mr_07_happy.g3 new file mode 100644 index 0000000..aebcdcd --- /dev/null +++ b/donddata/hd_pc/mr_07_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:463762e5f364274e930ae8e4377a1adaf21be25dec8bb523fdfd1abd26d51f41 +size 3189248 diff --git a/donddata/hd_pc/mr_07_select.g3 b/donddata/hd_pc/mr_07_select.g3 new file mode 100644 index 0000000..9c31cfe --- /dev/null +++ b/donddata/hd_pc/mr_07_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35f18393931385c01979582e24619f1363fd35a70f922ad39e0d2b12d4875ce5 +size 2858499 diff --git a/donddata/hd_pc/mr_07_shappy.g3 b/donddata/hd_pc/mr_07_shappy.g3 new file mode 100644 index 0000000..9eb053e --- /dev/null +++ b/donddata/hd_pc/mr_07_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4468d0065d67be38197c87ac6f50895797941b5e3a526d0a33237d6d30689342 +size 3282774 diff --git a/donddata/hd_pc/mr_07_tneutral.g3 b/donddata/hd_pc/mr_07_tneutral.g3 new file mode 100644 index 0000000..4c58860 --- /dev/null +++ b/donddata/hd_pc/mr_07_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5c1b962aefedd0814bdd3fbcef748101998239fa1802445a8d8ad6b67b647bf +size 2571097 diff --git a/donddata/hd_pc/mr_08_bad.g3 b/donddata/hd_pc/mr_08_bad.g3 new file mode 100644 index 0000000..a231224 --- /dev/null +++ b/donddata/hd_pc/mr_08_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7bb366fc557d579a82c84e1bf8ba1ed45589196fd901b2d867e8b75c210feeb +size 3199480 diff --git a/donddata/hd_pc/mr_08_happy.g3 b/donddata/hd_pc/mr_08_happy.g3 new file mode 100644 index 0000000..68411f8 --- /dev/null +++ b/donddata/hd_pc/mr_08_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2fd319f7f9f5ff9ef706ec5c0c6559b762f32be297f405e6a372580c4565be4 +size 3181201 diff --git a/donddata/hd_pc/mr_08_select.g3 b/donddata/hd_pc/mr_08_select.g3 new file mode 100644 index 0000000..b203a95 --- /dev/null +++ b/donddata/hd_pc/mr_08_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d17f3319bc39b4809df635cdb99b857b4064a57f74f087d3558197224cccb970 +size 2887675 diff --git a/donddata/hd_pc/mr_08_shappy.g3 b/donddata/hd_pc/mr_08_shappy.g3 new file mode 100644 index 0000000..c1718fe --- /dev/null +++ b/donddata/hd_pc/mr_08_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ccd6ee8c75e9415ad008ea4d1ee12ace86aacedb60427dd46048a830680e410 +size 3594840 diff --git a/donddata/hd_pc/mr_08_tneutral.g3 b/donddata/hd_pc/mr_08_tneutral.g3 new file mode 100644 index 0000000..301c3ce --- /dev/null +++ b/donddata/hd_pc/mr_08_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d70aa5ba2c44d8a317bf73f5a1610652cf7bee5e91f081d085865f45d922b0db +size 2938176 diff --git a/donddata/hd_pc/mr_09_bad.g3 b/donddata/hd_pc/mr_09_bad.g3 new file mode 100644 index 0000000..a5485de --- /dev/null +++ b/donddata/hd_pc/mr_09_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae21661f6ecdcb4b4e46d02ddfe6f6b63363267a0187b662e780dfc21240b270 +size 3038966 diff --git a/donddata/hd_pc/mr_09_happy.g3 b/donddata/hd_pc/mr_09_happy.g3 new file mode 100644 index 0000000..352585e --- /dev/null +++ b/donddata/hd_pc/mr_09_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:614c832fbaa744e1a85a9d8b92ef103ff41acc75e5098a04866fc85f74b4f4ca +size 2910374 diff --git a/donddata/hd_pc/mr_09_select.g3 b/donddata/hd_pc/mr_09_select.g3 new file mode 100644 index 0000000..e03be27 --- /dev/null +++ b/donddata/hd_pc/mr_09_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2108af2cd615df3739f960b34c51715f69b49cf8999859f811ea09cc069bdc4d +size 2815921 diff --git a/donddata/hd_pc/mr_09_shappy.g3 b/donddata/hd_pc/mr_09_shappy.g3 new file mode 100644 index 0000000..1f5bb8c --- /dev/null +++ b/donddata/hd_pc/mr_09_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81084cde67cfd907c3ac38607008436af2931747d03f8a198ac321cdb98f3add +size 3079275 diff --git a/donddata/hd_pc/mr_09_tneutral.g3 b/donddata/hd_pc/mr_09_tneutral.g3 new file mode 100644 index 0000000..0c7fda9 --- /dev/null +++ b/donddata/hd_pc/mr_09_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43c3d84fb2dbdabca3785b336e6befcb0f47c64273b5b347c0cd9e738ec20968 +size 2956658 diff --git a/donddata/hd_pc/mr_10_bad.g3 b/donddata/hd_pc/mr_10_bad.g3 new file mode 100644 index 0000000..a2928ea --- /dev/null +++ b/donddata/hd_pc/mr_10_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef32bc29f52cbb19cc1aa6cdf3933ff888cfb1c977900651349d56a078d8d9af +size 3297631 diff --git a/donddata/hd_pc/mr_10_happy.g3 b/donddata/hd_pc/mr_10_happy.g3 new file mode 100644 index 0000000..48d36ad --- /dev/null +++ b/donddata/hd_pc/mr_10_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0925b6d6498ec9a5b144ed756bdbfce8e9ee6270ca28ec4373df86257965edde +size 3181052 diff --git a/donddata/hd_pc/mr_10_select.g3 b/donddata/hd_pc/mr_10_select.g3 new file mode 100644 index 0000000..4ce38a9 --- /dev/null +++ b/donddata/hd_pc/mr_10_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42198ae8a3f5ecd00ccc0f4ee438935cfbcfa37523972ebb6f5db4623fab0417 +size 2960940 diff --git a/donddata/hd_pc/mr_10_shappy.g3 b/donddata/hd_pc/mr_10_shappy.g3 new file mode 100644 index 0000000..9e21c4c --- /dev/null +++ b/donddata/hd_pc/mr_10_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2bd84aa7ff4bdf4d54aa851cdf473d9e7aaeae04828092d7774136023d13366 +size 3424580 diff --git a/donddata/hd_pc/mr_10_tneutral.g3 b/donddata/hd_pc/mr_10_tneutral.g3 new file mode 100644 index 0000000..2bebb03 --- /dev/null +++ b/donddata/hd_pc/mr_10_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:498f9469faf2231d76ab6b4cb4642dc67cd5879010abb5a3b2c083a86d8df0e8 +size 2868412 diff --git a/donddata/hd_pc/mr_11_bad.g3 b/donddata/hd_pc/mr_11_bad.g3 new file mode 100644 index 0000000..caf9989 --- /dev/null +++ b/donddata/hd_pc/mr_11_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15edd637c183d279711371c7b91f52145b9a513951aeb03821658a0b0948b5d6 +size 3197280 diff --git a/donddata/hd_pc/mr_11_happy.g3 b/donddata/hd_pc/mr_11_happy.g3 new file mode 100644 index 0000000..1715bb8 --- /dev/null +++ b/donddata/hd_pc/mr_11_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22510080c3997094ead480339a4abdb4eef5652b1159195a9cb7af44f8542dad +size 3652222 diff --git a/donddata/hd_pc/mr_11_select.g3 b/donddata/hd_pc/mr_11_select.g3 new file mode 100644 index 0000000..0d712c7 --- /dev/null +++ b/donddata/hd_pc/mr_11_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe57b7a6f2ae4c642d547edb1fb07a3b271050612aa382657574e044e8163b1b +size 3112548 diff --git a/donddata/hd_pc/mr_11_shappy.g3 b/donddata/hd_pc/mr_11_shappy.g3 new file mode 100644 index 0000000..8d918e1 --- /dev/null +++ b/donddata/hd_pc/mr_11_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:283095a0194bda8a69208dbb8f0eaae022290afd311dc2b5303b9c4925a3530c +size 3478643 diff --git a/donddata/hd_pc/mr_11_tneutral.g3 b/donddata/hd_pc/mr_11_tneutral.g3 new file mode 100644 index 0000000..17a2568 --- /dev/null +++ b/donddata/hd_pc/mr_11_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82c2a848a11d8d6f0399e2bc0372fc7db4920dd3ce4022ce7ce12009689220f8 +size 3054098 diff --git a/donddata/hd_pc/mr_12_bad.g3 b/donddata/hd_pc/mr_12_bad.g3 new file mode 100644 index 0000000..640adef --- /dev/null +++ b/donddata/hd_pc/mr_12_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c003b8a8707d609701883571fc97bb99dd1597360fa5041a9ef9a20a3e7268dc +size 3272927 diff --git a/donddata/hd_pc/mr_12_happy.g3 b/donddata/hd_pc/mr_12_happy.g3 new file mode 100644 index 0000000..0b99dc5 --- /dev/null +++ b/donddata/hd_pc/mr_12_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0504a16e0f151be26f649a105384fa2ff57f195621398e11e5ee54c6720f0d19 +size 3289329 diff --git a/donddata/hd_pc/mr_12_select.g3 b/donddata/hd_pc/mr_12_select.g3 new file mode 100644 index 0000000..998abe1 --- /dev/null +++ b/donddata/hd_pc/mr_12_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bdcd1b5da674b2ea58bb1a5df923d6ba00ec887b372533b0f2c8a7b163de1463 +size 3008219 diff --git a/donddata/hd_pc/mr_12_shappy.g3 b/donddata/hd_pc/mr_12_shappy.g3 new file mode 100644 index 0000000..feebb2e --- /dev/null +++ b/donddata/hd_pc/mr_12_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35543b336e18c4efe9df99c77a1e1ff76b4e6aeff3d48926b58bb919fa98d691 +size 3620923 diff --git a/donddata/hd_pc/mr_12_tneutral.g3 b/donddata/hd_pc/mr_12_tneutral.g3 new file mode 100644 index 0000000..5ddf4a2 --- /dev/null +++ b/donddata/hd_pc/mr_12_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dda80e6de47980c205b5f5513fa40b0baba6ca6134d66b1909f6940a4a45e1d3 +size 2986680 diff --git a/donddata/hd_pc/mr_13_bad.g3 b/donddata/hd_pc/mr_13_bad.g3 new file mode 100644 index 0000000..630b836 --- /dev/null +++ b/donddata/hd_pc/mr_13_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e15833ab3278513d41547485b72e828f4bc5c7bac37ca7d74a852103bf47726 +size 3597027 diff --git a/donddata/hd_pc/mr_13_happy.g3 b/donddata/hd_pc/mr_13_happy.g3 new file mode 100644 index 0000000..e5130e2 --- /dev/null +++ b/donddata/hd_pc/mr_13_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d00bec300d117ac5ee0b6c6cacae106259e08e09167dfacbcdd9ee2b8ec08caf +size 3182488 diff --git a/donddata/hd_pc/mr_13_select.g3 b/donddata/hd_pc/mr_13_select.g3 new file mode 100644 index 0000000..23a0aac --- /dev/null +++ b/donddata/hd_pc/mr_13_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2d2f86b98abe34334429b36121f416f2685a2a6e01184094f0f103f3dc0e7de +size 3345803 diff --git a/donddata/hd_pc/mr_13_shappy.g3 b/donddata/hd_pc/mr_13_shappy.g3 new file mode 100644 index 0000000..be84d91 --- /dev/null +++ b/donddata/hd_pc/mr_13_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eaf3a27a485793c36e058ddca404dbc372f6b0ced5ac4290359c972ac03f483b +size 3482343 diff --git a/donddata/hd_pc/mr_13_tneutral.g3 b/donddata/hd_pc/mr_13_tneutral.g3 new file mode 100644 index 0000000..ea5e43d --- /dev/null +++ b/donddata/hd_pc/mr_13_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:671f4e9b45862dde1d66ff9e080d6d1665692f4f4aefdc50cd6ecaab8d8d28cf +size 2959249 diff --git a/donddata/hd_pc/mr_14_bad.g3 b/donddata/hd_pc/mr_14_bad.g3 new file mode 100644 index 0000000..cba908f --- /dev/null +++ b/donddata/hd_pc/mr_14_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62618ebafb1cf85920b28a3f1596a82d5605f06c9f1581bb69019b8a8090eda8 +size 3397672 diff --git a/donddata/hd_pc/mr_14_happy.g3 b/donddata/hd_pc/mr_14_happy.g3 new file mode 100644 index 0000000..c37668b --- /dev/null +++ b/donddata/hd_pc/mr_14_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d19851ba14e3892143ab14125fb33e609db66976239150bb8a66a1506f272da +size 3137166 diff --git a/donddata/hd_pc/mr_14_select.g3 b/donddata/hd_pc/mr_14_select.g3 new file mode 100644 index 0000000..f62101c --- /dev/null +++ b/donddata/hd_pc/mr_14_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf5293ef52440aecee647f9d309d4cf57adeed5e513e5e0682fb4882979916e5 +size 2870202 diff --git a/donddata/hd_pc/mr_14_shappy.g3 b/donddata/hd_pc/mr_14_shappy.g3 new file mode 100644 index 0000000..883b0d5 --- /dev/null +++ b/donddata/hd_pc/mr_14_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c949898faa841d3cff2c0e68eff4037e438be6e200b1832686cbe9df7822561 +size 3200792 diff --git a/donddata/hd_pc/mr_14_tneutral.g3 b/donddata/hd_pc/mr_14_tneutral.g3 new file mode 100644 index 0000000..f1de5af --- /dev/null +++ b/donddata/hd_pc/mr_14_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f65f0a140e20c9643ab3018e77050f3657e3249db9816ca72e1d0c622bb72e04 +size 2850146 diff --git a/donddata/hd_pc/mr_15_bad.g3 b/donddata/hd_pc/mr_15_bad.g3 new file mode 100644 index 0000000..6382122 --- /dev/null +++ b/donddata/hd_pc/mr_15_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa81cdc61b06a21ab161efe91e4d624b0e1fcb359d1dfba8642162b592bc7744 +size 3525197 diff --git a/donddata/hd_pc/mr_15_happy.g3 b/donddata/hd_pc/mr_15_happy.g3 new file mode 100644 index 0000000..9661275 --- /dev/null +++ b/donddata/hd_pc/mr_15_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3fd7464e3a01742a896210970f06d5b0bd611ddcf59e4d2cce7f1f22d6d7dbce +size 3149892 diff --git a/donddata/hd_pc/mr_15_select.g3 b/donddata/hd_pc/mr_15_select.g3 new file mode 100644 index 0000000..5f57c68 --- /dev/null +++ b/donddata/hd_pc/mr_15_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ee76c28116f1b208a177a41289400ed2524c40ba6820363ac1ab1b6cb7650bb +size 2820645 diff --git a/donddata/hd_pc/mr_15_shappy.g3 b/donddata/hd_pc/mr_15_shappy.g3 new file mode 100644 index 0000000..9ad9df7 --- /dev/null +++ b/donddata/hd_pc/mr_15_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e82e3c58f1396326c31376686004dd5eaa36e273a4300216b290c967e9102cdd +size 3255192 diff --git a/donddata/hd_pc/mr_15_tneutral.g3 b/donddata/hd_pc/mr_15_tneutral.g3 new file mode 100644 index 0000000..c88d863 --- /dev/null +++ b/donddata/hd_pc/mr_15_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c093d0b16f897a805bdf3164141fc2a77f7a4942c3e02aadc2f64183887fcfde +size 2764278 diff --git a/donddata/hd_pc/mr_16_bad.g3 b/donddata/hd_pc/mr_16_bad.g3 new file mode 100644 index 0000000..ffd958f --- /dev/null +++ b/donddata/hd_pc/mr_16_bad.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1df5d38f5d0b8e77c7936aba8701d7fe9783ab903626fc4f2421e591f33c893d +size 3692406 diff --git a/donddata/hd_pc/mr_16_happy.g3 b/donddata/hd_pc/mr_16_happy.g3 new file mode 100644 index 0000000..1512a53 --- /dev/null +++ b/donddata/hd_pc/mr_16_happy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df45a162e0a94aaac8879c64b2c4327908103dbd9a9bbdad435df453c97a638e +size 3234406 diff --git a/donddata/hd_pc/mr_16_select.g3 b/donddata/hd_pc/mr_16_select.g3 new file mode 100644 index 0000000..128e822 --- /dev/null +++ b/donddata/hd_pc/mr_16_select.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:916cb1410452c6a221e31943430c2f8bf3be90fd5283807a08f751674a0894fe +size 3084302 diff --git a/donddata/hd_pc/mr_16_shappy.g3 b/donddata/hd_pc/mr_16_shappy.g3 new file mode 100644 index 0000000..491afec --- /dev/null +++ b/donddata/hd_pc/mr_16_shappy.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:341537d233b3dd549585a3b7722be72eaa1c4c3a827fa0d8207a6acf8c0364d2 +size 3366243 diff --git a/donddata/hd_pc/mr_16_tneutral.g3 b/donddata/hd_pc/mr_16_tneutral.g3 new file mode 100644 index 0000000..9bf82e7 --- /dev/null +++ b/donddata/hd_pc/mr_16_tneutral.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fb626223b10679427b533dbb1e4615be54c090c5f4c62235b4f27bf1563719e +size 3174149 diff --git a/donddata/hd_pc/shuffle.g3 b/donddata/hd_pc/shuffle.g3 new file mode 100644 index 0000000..e1c1fd0 --- /dev/null +++ b/donddata/hd_pc/shuffle.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e502e40a643f30623ed2894d163014ba1a82e33bccc1a40be4d520759868cc30 +size 693165 diff --git a/donddata/hd_pc/shuffle_fnt.g3 b/donddata/hd_pc/shuffle_fnt.g3 new file mode 100644 index 0000000..5a84153 --- /dev/null +++ b/donddata/hd_pc/shuffle_fnt.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:092bb0056c55e79bb5f7ee51ade598f75782bec8868a8fb335fe69fa755dd731 +size 1049296 diff --git a/donddata/hd_pc/tight_scene.g3 b/donddata/hd_pc/tight_scene.g3 new file mode 100644 index 0000000..14dd62c --- /dev/null +++ b/donddata/hd_pc/tight_scene.g3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d06eb02bd285647ddfb21af68da995f0f326fd1e32bc4e94c9c4b6ec317c4e78 +size 4060820 diff --git a/donddata/hd_pc/vssver.scc b/donddata/hd_pc/vssver.scc new file mode 100644 index 0000000..d059246 Binary files /dev/null and b/donddata/hd_pc/vssver.scc differ diff --git a/donddata/snd/dat/banker/ELECTRONIC_PHONE_RING_02.wav b/donddata/snd/dat/banker/ELECTRONIC_PHONE_RING_02.wav new file mode 100644 index 0000000..df8bf06 --- /dev/null +++ b/donddata/snd/dat/banker/ELECTRONIC_PHONE_RING_02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a6099e6bdabde2f073f0f9752b382bf1f6d3bd46c05875b0ad2e5511eedcb25 +size 96556 diff --git a/donddata/snd/dat/banker/vssver.scc b/donddata/snd/dat/banker/vssver.scc new file mode 100644 index 0000000..f454caf Binary files /dev/null and b/donddata/snd/dat/banker/vssver.scc differ diff --git a/donddata/snd/dat/blank.wav b/donddata/snd/dat/blank.wav new file mode 100644 index 0000000..e4976fa --- /dev/null +++ b/donddata/snd/dat/blank.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab33b9a40b210ecbef1517f24b0081e625e66e2427cb2771c4c17214ba5bc981 +size 44144 diff --git a/donddata/snd/dat/crowd/CrowdBigApplauseCheers01.wav b/donddata/snd/dat/crowd/CrowdBigApplauseCheers01.wav new file mode 100644 index 0000000..ebbe789 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdBigApplauseCheers01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c68ec40673ada6b8b228523e86d9a27fe860d5d618fb5e9d2464d5316754be90 +size 882044 diff --git a/donddata/snd/dat/crowd/CrowdDEALyell03wApplause.wav b/donddata/snd/dat/crowd/CrowdDEALyell03wApplause.wav new file mode 100644 index 0000000..754fbba --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdDEALyell03wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6755f906c073cdddeb4d462fda67a9b1b9e597c42393283100a0f17b5761f529 +size 1764044 diff --git a/donddata/snd/dat/crowd/CrowdDEALyell04wApplause.wav b/donddata/snd/dat/crowd/CrowdDEALyell04wApplause.wav new file mode 100644 index 0000000..7c21097 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdDEALyell04wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef75c47bff78e0b87b8c8f173e472be69c49451179be837a9e0b1702f6164ee2 +size 1409348 diff --git a/donddata/snd/dat/crowd/CrowdMIXyell01wApplause.wav b/donddata/snd/dat/crowd/CrowdMIXyell01wApplause.wav new file mode 100644 index 0000000..a8d07ff --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdMIXyell01wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4bbb4de90caf72baa8a55817f9e6cae766d98cdb2f44d4f95137982c4beba282 +size 1764044 diff --git a/donddata/snd/dat/crowd/CrowdMIXyell02wApplause.wav b/donddata/snd/dat/crowd/CrowdMIXyell02wApplause.wav new file mode 100644 index 0000000..adaae96 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdMIXyell02wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68de38ae1aed0f83328bf20b4855bb7f1a13b683f69a2a9c7e75739d74118462 +size 1764044 diff --git a/donddata/snd/dat/crowd/CrowdMedApplause01.wav b/donddata/snd/dat/crowd/CrowdMedApplause01.wav new file mode 100644 index 0000000..71f4b07 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdMedApplause01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40261d344819939dda0de3e175f628e9336270ea88b962165b6396638b270ab1 +size 882044 diff --git a/donddata/snd/dat/crowd/CrowdNoDealYell01wApplause.wav b/donddata/snd/dat/crowd/CrowdNoDealYell01wApplause.wav new file mode 100644 index 0000000..49e1233 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdNoDealYell01wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3909fc63af0cbe946586060e4a232c558a545ee1b7543a220fc4de0373de1723 +size 1764044 diff --git a/donddata/snd/dat/crowd/CrowdNoDealYell02wApplause.wav b/donddata/snd/dat/crowd/CrowdNoDealYell02wApplause.wav new file mode 100644 index 0000000..1f7ad86 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdNoDealYell02wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f68e12417982d5445cc7c7ddd66af52bd93613bb8a3a04f72f7e61f0cf91915 +size 1447748 diff --git a/donddata/snd/dat/crowd/CrowdNoDealYell02wApplause_bug.wav b/donddata/snd/dat/crowd/CrowdNoDealYell02wApplause_bug.wav new file mode 100644 index 0000000..eed6534 --- /dev/null +++ b/donddata/snd/dat/crowd/CrowdNoDealYell02wApplause_bug.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:088c3128ad84566740e3f62fb23c2dc7737b6569a19370c1ff8af450caca4d5a +size 1764044 diff --git a/donddata/snd/dat/crowd/happy/CrowdWinMed01wApplause.wav b/donddata/snd/dat/crowd/happy/CrowdWinMed01wApplause.wav new file mode 100644 index 0000000..d8fb938 --- /dev/null +++ b/donddata/snd/dat/crowd/happy/CrowdWinMed01wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acb73770731f772d9eefc8e7e4e8a7ceb08a73668d680c3f1c42d89e7b456183 +size 882044 diff --git a/donddata/snd/dat/crowd/happy/CrowdWinMed02wApplause.wav b/donddata/snd/dat/crowd/happy/CrowdWinMed02wApplause.wav new file mode 100644 index 0000000..349e968 --- /dev/null +++ b/donddata/snd/dat/crowd/happy/CrowdWinMed02wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dcfba47dde0535daa819548955541736e4fa20a02b5309de5632eb206e915674 +size 882044 diff --git a/donddata/snd/dat/crowd/happy/CrowdWinMed03wApplause.wav b/donddata/snd/dat/crowd/happy/CrowdWinMed03wApplause.wav new file mode 100644 index 0000000..ab10e8a --- /dev/null +++ b/donddata/snd/dat/crowd/happy/CrowdWinMed03wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f049059cf56a7aa8277019f5869c3d82d093135a11844a12b88af5d9ce3d4af0 +size 882044 diff --git a/donddata/snd/dat/crowd/happy/vssver.scc b/donddata/snd/dat/crowd/happy/vssver.scc new file mode 100644 index 0000000..01a7eba Binary files /dev/null and b/donddata/snd/dat/crowd/happy/vssver.scc differ diff --git a/donddata/snd/dat/crowd/sad/CrowdLoseAhh01.wav b/donddata/snd/dat/crowd/sad/CrowdLoseAhh01.wav new file mode 100644 index 0000000..c9a6ba4 --- /dev/null +++ b/donddata/snd/dat/crowd/sad/CrowdLoseAhh01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9017cc87ca265b813d4a7ad206180e5855f47409a996603793dafe8eaf912c41 +size 882044 diff --git a/donddata/snd/dat/crowd/sad/CrowdLoseAhh02.wav b/donddata/snd/dat/crowd/sad/CrowdLoseAhh02.wav new file mode 100644 index 0000000..f46494e --- /dev/null +++ b/donddata/snd/dat/crowd/sad/CrowdLoseAhh02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c38f5cff525cef75e4c39a9e211491c308d5cd2179cc9799bb190f4d2e90f90b +size 882044 diff --git a/donddata/snd/dat/crowd/sad/CrowdLoseAhh02rev.wav b/donddata/snd/dat/crowd/sad/CrowdLoseAhh02rev.wav new file mode 100644 index 0000000..3021cbf --- /dev/null +++ b/donddata/snd/dat/crowd/sad/CrowdLoseAhh02rev.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7d2c761c5b8ed64c3ff35ab60e2b29aaf76803a89a05b5ece309bdb0f13d0da +size 882044 diff --git a/donddata/snd/dat/crowd/sad/CrowdLoseAhh03.wav b/donddata/snd/dat/crowd/sad/CrowdLoseAhh03.wav new file mode 100644 index 0000000..3a27cce --- /dev/null +++ b/donddata/snd/dat/crowd/sad/CrowdLoseAhh03.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d31ceaaae6e8433b580fcf26fcd1b597f3fe772685d9772b9b30df16bda56840 +size 882044 diff --git a/donddata/snd/dat/crowd/sad/vssver.scc b/donddata/snd/dat/crowd/sad/vssver.scc new file mode 100644 index 0000000..67113ba Binary files /dev/null and b/donddata/snd/dat/crowd/sad/vssver.scc differ diff --git a/donddata/snd/dat/crowd/shappy/CrowdWinBig01wApplause.wav b/donddata/snd/dat/crowd/shappy/CrowdWinBig01wApplause.wav new file mode 100644 index 0000000..8455a71 --- /dev/null +++ b/donddata/snd/dat/crowd/shappy/CrowdWinBig01wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e86606ed976970ad74c30e2743ccf096b28118033509c733b5256291930fa44f +size 882044 diff --git a/donddata/snd/dat/crowd/shappy/CrowdWinBig02wApplause.wav b/donddata/snd/dat/crowd/shappy/CrowdWinBig02wApplause.wav new file mode 100644 index 0000000..65bda3f --- /dev/null +++ b/donddata/snd/dat/crowd/shappy/CrowdWinBig02wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eacf8f54785d460cf99e0fa736cd19332e6b3ccf12554395dd298b5f585261fe +size 882044 diff --git a/donddata/snd/dat/crowd/shappy/CrowdWinBig03wApplause.wav b/donddata/snd/dat/crowd/shappy/CrowdWinBig03wApplause.wav new file mode 100644 index 0000000..b7c4c05 --- /dev/null +++ b/donddata/snd/dat/crowd/shappy/CrowdWinBig03wApplause.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:179f41e75d2b3a433ce1de7951bf01b28341682feb0eef3033b290fdea3100e8 +size 882044 diff --git a/donddata/snd/dat/crowd/shappy/vssver.scc b/donddata/snd/dat/crowd/shappy/vssver.scc new file mode 100644 index 0000000..a9c1af0 Binary files /dev/null and b/donddata/snd/dat/crowd/shappy/vssver.scc differ diff --git a/donddata/snd/dat/crowd/vssver.scc b/donddata/snd/dat/crowd/vssver.scc new file mode 100644 index 0000000..94db744 Binary files /dev/null and b/donddata/snd/dat/crowd/vssver.scc differ diff --git a/donddata/snd/dat/music/bc_bank_offer.wav b/donddata/snd/dat/music/bc_bank_offer.wav new file mode 100644 index 0000000..a629801 --- /dev/null +++ b/donddata/snd/dat/music/bc_bank_offer.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0836dd3016a36827bed28a3f40e7bcc2caca25b8b33e132586d2d0af88502ecc +size 6669592 diff --git a/donddata/snd/dat/music/bc_model_theme_full.wav b/donddata/snd/dat/music/bc_model_theme_full.wav new file mode 100644 index 0000000..1993f31 --- /dev/null +++ b/donddata/snd/dat/music/bc_model_theme_full.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f15c73c21df8c60f990418cb8665d4f2baadcb840685be35883b6bc7913fd8fc +size 6242760 diff --git a/donddata/snd/dat/music/mus_choose_deal.wav b/donddata/snd/dat/music/mus_choose_deal.wav new file mode 100644 index 0000000..9b6934b --- /dev/null +++ b/donddata/snd/dat/music/mus_choose_deal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91c83829aae3a71e9778adfe14a2820afa5eaf77db5d36fe91b95c006ca93922 +size 1764044 diff --git a/donddata/snd/dat/music/mus_choose_deal_wr.wav b/donddata/snd/dat/music/mus_choose_deal_wr.wav new file mode 100644 index 0000000..0d6360f --- /dev/null +++ b/donddata/snd/dat/music/mus_choose_deal_wr.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94b12bd9cd156b950dc69ebc0c52bb2b45a30748b9fd66a7f55230940c972c93 +size 3528044 diff --git a/donddata/snd/dat/music/mus_game_over_wr.wav b/donddata/snd/dat/music/mus_game_over_wr.wav new file mode 100644 index 0000000..16ab451 --- /dev/null +++ b/donddata/snd/dat/music/mus_game_over_wr.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9a79c9f6e967133b4711bf24a1e177610dd099985c1a295f651d15cfebde62e +size 2646044 diff --git a/donddata/snd/dat/music/mus_shuffle.wav b/donddata/snd/dat/music/mus_shuffle.wav new file mode 100644 index 0000000..4cc9d83 --- /dev/null +++ b/donddata/snd/dat/music/mus_shuffle.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4b57073480a4f8238dde292ccedbd0fdd425bae53bef40de295e72410c3aa41 +size 2558068 diff --git a/donddata/snd/dat/music/mus_shuffle2.wav b/donddata/snd/dat/music/mus_shuffle2.wav new file mode 100644 index 0000000..30a1fac --- /dev/null +++ b/donddata/snd/dat/music/mus_shuffle2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7912f8f9fb4c69edfc4ba286a45028deaceecf4add026d2acd54fc5a1a42442c +size 1996060 diff --git a/donddata/snd/dat/music/tp_dond_theme_2.wav b/donddata/snd/dat/music/tp_dond_theme_2.wav new file mode 100644 index 0000000..b141cbb --- /dev/null +++ b/donddata/snd/dat/music/tp_dond_theme_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71a3381c4c778ca4cad0b47a560ae565df476b309dd540dca6c20d259aa2e7a0 +size 5292044 diff --git a/donddata/snd/dat/music/tp_theme_bumper_6.wav b/donddata/snd/dat/music/tp_theme_bumper_6.wav new file mode 100644 index 0000000..c625138 --- /dev/null +++ b/donddata/snd/dat/music/tp_theme_bumper_6.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f7689d6f8295c324e5e7a3577963598488a0d47f9235689c5a515fceeeacd61 +size 1764044 diff --git a/donddata/snd/dat/music/vssver.scc b/donddata/snd/dat/music/vssver.scc new file mode 100644 index 0000000..e5dbfcd Binary files /dev/null and b/donddata/snd/dat/music/vssver.scc differ diff --git a/donddata/snd/dat/sfx/banker_offer.wav b/donddata/snd/dat/sfx/banker_offer.wav new file mode 100644 index 0000000..bafc013 --- /dev/null +++ b/donddata/snd/dat/sfx/banker_offer.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfa8481bb1682824633032c582e790df78bac218b42d577eb3c389209a69d1ec +size 300400 diff --git a/donddata/snd/dat/sfx/case_lock.wav b/donddata/snd/dat/sfx/case_lock.wav new file mode 100644 index 0000000..ac9ee66 --- /dev/null +++ b/donddata/snd/dat/sfx/case_lock.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0cb51288ea42ee46b93ec99462e4af3d10d2ae319424abc29935f8394636722 +size 14098 diff --git a/donddata/snd/dat/sfx/case_open_bad.wav b/donddata/snd/dat/sfx/case_open_bad.wav new file mode 100644 index 0000000..2809255 --- /dev/null +++ b/donddata/snd/dat/sfx/case_open_bad.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4996a372cbf2056ddc8f0ba104f7ce75a8d471d1dd492c832f0b73ae1b98a83c +size 882044 diff --git a/donddata/snd/dat/sfx/case_open_bad_short.wav b/donddata/snd/dat/sfx/case_open_bad_short.wav new file mode 100644 index 0000000..63e7628 --- /dev/null +++ b/donddata/snd/dat/sfx/case_open_bad_short.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43fdaef1190c79d3d6c76cb5b9ebaf307cb617278720e9a8dd6b6141509c9543 +size 392572 diff --git a/donddata/snd/dat/sfx/case_open_build.wav b/donddata/snd/dat/sfx/case_open_build.wav new file mode 100644 index 0000000..54cd343 --- /dev/null +++ b/donddata/snd/dat/sfx/case_open_build.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e04e402b84389ffd61622f8a9a37cde9a37d491f6c49e1c1a2d88a437b757ad3 +size 758088 diff --git a/donddata/snd/dat/sfx/case_open_good.wav b/donddata/snd/dat/sfx/case_open_good.wav new file mode 100644 index 0000000..6112335 --- /dev/null +++ b/donddata/snd/dat/sfx/case_open_good.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50b9f79241c4bc745c7796147152ab2e170c30bead0361efba0bff341375f8fc +size 882044 diff --git a/donddata/snd/dat/sfx/case_open_good_short.wav b/donddata/snd/dat/sfx/case_open_good_short.wav new file mode 100644 index 0000000..ced89c2 --- /dev/null +++ b/donddata/snd/dat/sfx/case_open_good_short.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bed3fd158fb529f44e3dd32fcd150a2b6b6653ee874c8a08907177318c3d34ec +size 155784 diff --git a/donddata/snd/dat/sfx/click.wav b/donddata/snd/dat/sfx/click.wav new file mode 100644 index 0000000..f462a34 --- /dev/null +++ b/donddata/snd/dat/sfx/click.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28de5b02363b800bb5b07ba3c553e5f811cb1e946cbb9508e5a4b726907015fd +size 8836 diff --git a/donddata/snd/dat/sfx/coin_in.wav b/donddata/snd/dat/sfx/coin_in.wav new file mode 100644 index 0000000..f5ef57d --- /dev/null +++ b/donddata/snd/dat/sfx/coin_in.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c468b0783b6886817b15cf637b7969c630ec7b952f41e71dc5f517877853e00 +size 290864 diff --git a/donddata/snd/dat/sfx/money_flip.wav b/donddata/snd/dat/sfx/money_flip.wav new file mode 100644 index 0000000..d7ef8fd --- /dev/null +++ b/donddata/snd/dat/sfx/money_flip.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb25ef8ea024d243771a0704a54a925fe8f08200392fcacbda09cd89e474c4bd +size 102324 diff --git a/donddata/snd/dat/sfx/no_deal.wav b/donddata/snd/dat/sfx/no_deal.wav new file mode 100644 index 0000000..9d18102 --- /dev/null +++ b/donddata/snd/dat/sfx/no_deal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b433fc7f977066780b6c4a9555c601e5a682ce25c97e3724a3c52d16ca71895 +size 273384 diff --git a/donddata/snd/dat/sfx/start_button.wav b/donddata/snd/dat/sfx/start_button.wav new file mode 100644 index 0000000..2cfccdb --- /dev/null +++ b/donddata/snd/dat/sfx/start_button.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3cd499c7db18b89c3e86460f30354d5d0e15d4bed6ceb42febfcd1455b5710e5 +size 279740 diff --git a/donddata/snd/dat/sfx/vssver.scc b/donddata/snd/dat/sfx/vssver.scc new file mode 100644 index 0000000..b68b926 Binary files /dev/null and b/donddata/snd/dat/sfx/vssver.scc differ diff --git a/donddata/snd/dat/sfx/zoom_down.wav b/donddata/snd/dat/sfx/zoom_down.wav new file mode 100644 index 0000000..f9f5d61 --- /dev/null +++ b/donddata/snd/dat/sfx/zoom_down.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:988612be5b9298414035d6c7c1acb4bc220c98b8487673c115eebc0d9f626e41 +size 232064 diff --git a/donddata/snd/dat/sine/sine100.wav b/donddata/snd/dat/sine/sine100.wav new file mode 100644 index 0000000..8af1cf4 --- /dev/null +++ b/donddata/snd/dat/sine/sine100.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8c09b52568ac4da571f3fb847a6e65b4d6232ad3bb5c661af5e1fca097b22bf +size 32756 diff --git a/donddata/snd/dat/sine/sine1k.wav b/donddata/snd/dat/sine/sine1k.wav new file mode 100644 index 0000000..92fc982 --- /dev/null +++ b/donddata/snd/dat/sine/sine1k.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39ae9b1dfae72b4d6d50b8a1eaa72d98a2226ce4135e0ecad969488870b87a55 +size 32854 diff --git a/donddata/snd/dat/sine/vssver.scc b/donddata/snd/dat/sine/vssver.scc new file mode 100644 index 0000000..271e5fa Binary files /dev/null and b/donddata/snd/dat/sine/vssver.scc differ diff --git a/donddata/snd/dat/vocals/01.AreYouReadyToPlayDOND.sfk b/donddata/snd/dat/vocals/01.AreYouReadyToPlayDOND.sfk new file mode 100644 index 0000000..c3b9a54 --- /dev/null +++ b/donddata/snd/dat/vocals/01.AreYouReadyToPlayDOND.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d96c192eca76b8b38b25d8475c466dea2c53175d496156e5204f0616bdbc2fd +size 736 diff --git a/donddata/snd/dat/vocals/01.AreYouReadyToPlayDOND.wav b/donddata/snd/dat/vocals/01.AreYouReadyToPlayDOND.wav new file mode 100644 index 0000000..6c30fc2 --- /dev/null +++ b/donddata/snd/dat/vocals/01.AreYouReadyToPlayDOND.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3564069ed8783d508dd63116fc5728da955f0b41c7ed506fd9d0ccf69ff4ad6b +size 341844 diff --git a/donddata/snd/dat/vocals/05.ChooseYourCase_d.sfk b/donddata/snd/dat/vocals/05.ChooseYourCase_d.sfk new file mode 100644 index 0000000..a2f5146 --- /dev/null +++ b/donddata/snd/dat/vocals/05.ChooseYourCase_d.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aff31c4682fc1ce5240c1da601b5159a0ce67b2148eebacfed06a229c5921916 +size 200 diff --git a/donddata/snd/dat/vocals/05.ChooseYourCase_d.wav b/donddata/snd/dat/vocals/05.ChooseYourCase_d.wav new file mode 100644 index 0000000..87e7db0 --- /dev/null +++ b/donddata/snd/dat/vocals/05.ChooseYourCase_d.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c13ed947cdc7165b046a27b9eb00c9cd504dbe048d1dc7285d565b47e5ee7b46 +size 138460 diff --git a/donddata/snd/dat/vocals/06.ThisWillBePersonalCase_c.sfk b/donddata/snd/dat/vocals/06.ThisWillBePersonalCase_c.sfk new file mode 100644 index 0000000..5b50dcd --- /dev/null +++ b/donddata/snd/dat/vocals/06.ThisWillBePersonalCase_c.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b061cee5c14835682aeb71861a3e90ddfb85d7b0e0ddd63a2c923ee03f64998 +size 248 diff --git a/donddata/snd/dat/vocals/06.ThisWillBePersonalCase_c.wav b/donddata/snd/dat/vocals/06.ThisWillBePersonalCase_c.wav new file mode 100644 index 0000000..d166cd3 --- /dev/null +++ b/donddata/snd/dat/vocals/06.ThisWillBePersonalCase_c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:60b5efe9cda28c5778a07b19ec0fce157a4769c4143e195cb6e718e06aff77b1 +size 188232 diff --git a/donddata/snd/dat/vocals/07.NowOpen5Cases_c.sfk b/donddata/snd/dat/vocals/07.NowOpen5Cases_c.sfk new file mode 100644 index 0000000..771a444 --- /dev/null +++ b/donddata/snd/dat/vocals/07.NowOpen5Cases_c.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86689269805705df97299d966fe2269405f84615a5f69f24fc8fdbc238fc00a4 +size 228 diff --git a/donddata/snd/dat/vocals/07.NowOpen5Cases_c.wav b/donddata/snd/dat/vocals/07.NowOpen5Cases_c.wav new file mode 100644 index 0000000..85fc51c --- /dev/null +++ b/donddata/snd/dat/vocals/07.NowOpen5Cases_c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f094350f3f06abcaf7187e600a680e001415de24334bbafaaab903ea72f1060 +size 165176 diff --git a/donddata/snd/dat/vocals/08.NowOpen4Cases_c.sfk b/donddata/snd/dat/vocals/08.NowOpen4Cases_c.sfk new file mode 100644 index 0000000..b6055d1 --- /dev/null +++ b/donddata/snd/dat/vocals/08.NowOpen4Cases_c.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2aea3a20105103c8a3e50e73bb1c33d1a4a64458bdd2fe001ebafaf74af1b20 +size 252 diff --git a/donddata/snd/dat/vocals/08.NowOpen4Cases_c.wav b/donddata/snd/dat/vocals/08.NowOpen4Cases_c.wav new file mode 100644 index 0000000..86c9e67 --- /dev/null +++ b/donddata/snd/dat/vocals/08.NowOpen4Cases_c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:adac2bb4b93871699d7133b9625882461959288f517cd0d58221bb808b6bf167 +size 189580 diff --git a/donddata/snd/dat/vocals/09.NowOpen3Cases_c.sfk b/donddata/snd/dat/vocals/09.NowOpen3Cases_c.sfk new file mode 100644 index 0000000..b84662d --- /dev/null +++ b/donddata/snd/dat/vocals/09.NowOpen3Cases_c.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2fe109a3773097772734e2f5ec6f4e9434f5d0295cf174b5880378178af8d7ed +size 236 diff --git a/donddata/snd/dat/vocals/09.NowOpen3Cases_c.wav b/donddata/snd/dat/vocals/09.NowOpen3Cases_c.wav new file mode 100644 index 0000000..07b65e4 --- /dev/null +++ b/donddata/snd/dat/vocals/09.NowOpen3Cases_c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72e07aabc8f24b5c38c799dc3d55b5fb8915b7ddcbb196ee9096dbbfdf39ba11 +size 174340 diff --git a/donddata/snd/dat/vocals/1.sfk b/donddata/snd/dat/vocals/1.sfk new file mode 100644 index 0000000..b10e4d8 --- /dev/null +++ b/donddata/snd/dat/vocals/1.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d51ed880e62d3a0409dbaab0f647f241e4f4275007661f3e12cc93048066d1e +size 124 diff --git a/donddata/snd/dat/vocals/1.wav b/donddata/snd/dat/vocals/1.wav new file mode 100644 index 0000000..fedbbfd --- /dev/null +++ b/donddata/snd/dat/vocals/1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bd26667bf1234419dc9acd3ef75081e44086a965797dc507749d345692652be +size 57820 diff --git a/donddata/snd/dat/vocals/10.NowOpen2Cases_d.sfk b/donddata/snd/dat/vocals/10.NowOpen2Cases_d.sfk new file mode 100644 index 0000000..da76a0a --- /dev/null +++ b/donddata/snd/dat/vocals/10.NowOpen2Cases_d.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd77d1f306e2e394b387aca2a0d603466471c67550b5276988ea934446aac46f +size 240 diff --git a/donddata/snd/dat/vocals/10.NowOpen2Cases_d.wav b/donddata/snd/dat/vocals/10.NowOpen2Cases_d.wav new file mode 100644 index 0000000..d983959 --- /dev/null +++ b/donddata/snd/dat/vocals/10.NowOpen2Cases_d.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6fe281245a7f8a614194c9c3fb8a1ffd49d7b902de1d0adfc01ff5df4ac80d4 +size 179936 diff --git a/donddata/snd/dat/vocals/10.sfk b/donddata/snd/dat/vocals/10.sfk new file mode 100644 index 0000000..2f2e189 --- /dev/null +++ b/donddata/snd/dat/vocals/10.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:55e37398579a0bcc97191369c490bb9392b4a8ade47b3be33ae1cce2d6e26091 +size 124 diff --git a/donddata/snd/dat/vocals/10.wav b/donddata/snd/dat/vocals/10.wav new file mode 100644 index 0000000..976d627 --- /dev/null +++ b/donddata/snd/dat/vocals/10.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1966e0e171153465a995716e712a86bb4a02ad0e16f8e36a67484d440a405a5a +size 59848 diff --git a/donddata/snd/dat/vocals/10_a.wav b/donddata/snd/dat/vocals/10_a.wav new file mode 100644 index 0000000..e58f8f0 --- /dev/null +++ b/donddata/snd/dat/vocals/10_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:644d6828b653a093af1dc514059e2615e900839081ee18c4cb99ab2711b4743a +size 441044 diff --git a/donddata/snd/dat/vocals/11.NowOpen1Case_d.sfk b/donddata/snd/dat/vocals/11.NowOpen1Case_d.sfk new file mode 100644 index 0000000..cebd2df --- /dev/null +++ b/donddata/snd/dat/vocals/11.NowOpen1Case_d.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ffb17ce8a8cb0bfa58aa650dfde1dedbb759a423969b4b027fab7d969d9c416 +size 268 diff --git a/donddata/snd/dat/vocals/11.NowOpen1Case_d.wav b/donddata/snd/dat/vocals/11.NowOpen1Case_d.wav new file mode 100644 index 0000000..05e2891 --- /dev/null +++ b/donddata/snd/dat/vocals/11.NowOpen1Case_d.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8fa6cbe1200fc958a918c98552f4cd01bb0ae4c74cec90152e374f4575cfcd3b +size 205400 diff --git a/donddata/snd/dat/vocals/11.sfk b/donddata/snd/dat/vocals/11.sfk new file mode 100644 index 0000000..7c498dd --- /dev/null +++ b/donddata/snd/dat/vocals/11.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbbd8b2fe3afc94bcd71fe66747fb6eea0a6fff196bca9db8a6a557181758c21 +size 128 diff --git a/donddata/snd/dat/vocals/11.wav b/donddata/snd/dat/vocals/11.wav new file mode 100644 index 0000000..3a95316 --- /dev/null +++ b/donddata/snd/dat/vocals/11.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c37f6a05c1485475cbab402bc40e5b975dbacc123b770c3fc4f05fbbd5e866ee +size 63128 diff --git a/donddata/snd/dat/vocals/11_b.wav b/donddata/snd/dat/vocals/11_b.wav new file mode 100644 index 0000000..8222ee1 --- /dev/null +++ b/donddata/snd/dat/vocals/11_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23f8ccd511ad5fa8b827deb69376f76f6c02877be8c8ae545073ca30063a7650 +size 441044 diff --git a/donddata/snd/dat/vocals/12.sfk b/donddata/snd/dat/vocals/12.sfk new file mode 100644 index 0000000..a119c8d --- /dev/null +++ b/donddata/snd/dat/vocals/12.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e69966b3f1b897e73f2a6bf87025d9ed1e28235920b50fea81e07cc2fc0ac59 +size 116 diff --git a/donddata/snd/dat/vocals/12.wav b/donddata/snd/dat/vocals/12.wav new file mode 100644 index 0000000..af486e0 --- /dev/null +++ b/donddata/snd/dat/vocals/12.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5043f2529cd59446031019b9e8088f3f12a698202103aaba8a53021bea75d528 +size 49720 diff --git a/donddata/snd/dat/vocals/12_b.wav b/donddata/snd/dat/vocals/12_b.wav new file mode 100644 index 0000000..f784cca --- /dev/null +++ b/donddata/snd/dat/vocals/12_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d00a57cf7f47530f271f49ab7e85061b87d999d80565a02508d5c17e692c49a5 +size 441044 diff --git a/donddata/snd/dat/vocals/13.sfk b/donddata/snd/dat/vocals/13.sfk new file mode 100644 index 0000000..d108878 --- /dev/null +++ b/donddata/snd/dat/vocals/13.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fbd257ac03a9b413bb1e523247e53eb0347e922c617b8931d7ef03ca229a2bab +size 152 diff --git a/donddata/snd/dat/vocals/13.wav b/donddata/snd/dat/vocals/13.wav new file mode 100644 index 0000000..8d30257 --- /dev/null +++ b/donddata/snd/dat/vocals/13.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db2310a083fccb7a580690c6dfa81377021b30bbfda023dd45c0978cf1edbe6c +size 90040 diff --git a/donddata/snd/dat/vocals/13_b.wav b/donddata/snd/dat/vocals/13_b.wav new file mode 100644 index 0000000..6b4dfc9 --- /dev/null +++ b/donddata/snd/dat/vocals/13_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8783aeafbb83f34876b4339135ce75b3c4a008bb6badca1b6a5dd379cf1b8632 +size 441044 diff --git a/donddata/snd/dat/vocals/14.sfk b/donddata/snd/dat/vocals/14.sfk new file mode 100644 index 0000000..dcd48ee --- /dev/null +++ b/donddata/snd/dat/vocals/14.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70f17a30ea277066d7725437683d926989a202a4fa34631e6ce603e7261b1188 +size 248 diff --git a/donddata/snd/dat/vocals/14.wav b/donddata/snd/dat/vocals/14.wav new file mode 100644 index 0000000..ffd7f1f --- /dev/null +++ b/donddata/snd/dat/vocals/14.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b97477b15c779771b58d3809351e9ddbecb226347bcebdb1b617dc0de7edb9a9 +size 91676 diff --git a/donddata/snd/dat/vocals/14_b.wav b/donddata/snd/dat/vocals/14_b.wav new file mode 100644 index 0000000..346b071 --- /dev/null +++ b/donddata/snd/dat/vocals/14_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c2d8eb357b7d5b81701f4886753ba25d596ae9de68df1c619a7506f40b65bdb +size 441044 diff --git a/donddata/snd/dat/vocals/15.sfk b/donddata/snd/dat/vocals/15.sfk new file mode 100644 index 0000000..39c21e7 --- /dev/null +++ b/donddata/snd/dat/vocals/15.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe48eb6f58e26be8be21467536d87c5d1a90b9c9837fa3d92da06902d1b57363 +size 200 diff --git a/donddata/snd/dat/vocals/15.wav b/donddata/snd/dat/vocals/15.wav new file mode 100644 index 0000000..dc181f1 --- /dev/null +++ b/donddata/snd/dat/vocals/15.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44933c93bd45629d035ddae526970b256ace11196964afba05eff53f8ee2af29 +size 67948 diff --git a/donddata/snd/dat/vocals/15_a.wav b/donddata/snd/dat/vocals/15_a.wav new file mode 100644 index 0000000..5749a62 --- /dev/null +++ b/donddata/snd/dat/vocals/15_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ec1ba4142c7e526c237848cd67a9b7ebb99eed49a39831d4aa296492d9f7114 +size 441044 diff --git a/donddata/snd/dat/vocals/16.sfk b/donddata/snd/dat/vocals/16.sfk new file mode 100644 index 0000000..b8b0015 --- /dev/null +++ b/donddata/snd/dat/vocals/16.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ce99d13f7aed9b52eb41e51d0514e89066408d8c12b5494690a6b31b4567289 +size 152 diff --git a/donddata/snd/dat/vocals/16.wav b/donddata/snd/dat/vocals/16.wav new file mode 100644 index 0000000..58e73b5 --- /dev/null +++ b/donddata/snd/dat/vocals/16.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b942fc3263a8bce3e0203cb203687bb868b0273f5f41c221eb3e6525932a98c +size 87628 diff --git a/donddata/snd/dat/vocals/16_b.wav b/donddata/snd/dat/vocals/16_b.wav new file mode 100644 index 0000000..bf4057f --- /dev/null +++ b/donddata/snd/dat/vocals/16_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d75ee0e2ae99b4ff5bd13c8817f674055c12231c011c8b5e52d8954dcade21b +size 441044 diff --git a/donddata/snd/dat/vocals/18.ThatsTheBanker.sfk b/donddata/snd/dat/vocals/18.ThatsTheBanker.sfk new file mode 100644 index 0000000..2ff1977 --- /dev/null +++ b/donddata/snd/dat/vocals/18.ThatsTheBanker.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec34794e07243152ad66d5205a37f0b190a9108c052f579f7c27f1e637cf76fa +size 156 diff --git a/donddata/snd/dat/vocals/18.ThatsTheBanker.wav b/donddata/snd/dat/vocals/18.ThatsTheBanker.wav new file mode 100644 index 0000000..d44adac --- /dev/null +++ b/donddata/snd/dat/vocals/18.ThatsTheBanker.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e26d11a0ba02fcb74fd61fe164ca92a36d9044abadb69de6ad45469924642fb +size 91432 diff --git a/donddata/snd/dat/vocals/18alt.TheresTheBanker.sfk b/donddata/snd/dat/vocals/18alt.TheresTheBanker.sfk new file mode 100644 index 0000000..58c27bf --- /dev/null +++ b/donddata/snd/dat/vocals/18alt.TheresTheBanker.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc56b59195804b9ceec129787d2f129095e137d5c55b86455a3da48c0aa2e26d +size 148 diff --git a/donddata/snd/dat/vocals/18alt.TheresTheBanker.wav b/donddata/snd/dat/vocals/18alt.TheresTheBanker.wav new file mode 100644 index 0000000..3295f41 --- /dev/null +++ b/donddata/snd/dat/vocals/18alt.TheresTheBanker.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bdf136be199cc10219858fd5eb699e0dc6fc0070e825198da0281875609e1aaf +size 83668 diff --git a/donddata/snd/dat/vocals/19.Hello.wav b/donddata/snd/dat/vocals/19.Hello.wav new file mode 100644 index 0000000..9e7ebc9 --- /dev/null +++ b/donddata/snd/dat/vocals/19.Hello.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a292380e09a8b6c23eb4979dc4c4bc7c1b46efc3ed1efbd18f56cc10da2dbe41 +size 16478 diff --git a/donddata/snd/dat/vocals/1_a.wav b/donddata/snd/dat/vocals/1_a.wav new file mode 100644 index 0000000..cd38a7d --- /dev/null +++ b/donddata/snd/dat/vocals/1_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c53187dfbc74af21901d9b86b34a1180adb06d0138dda27837507b27961ddcf5 +size 441044 diff --git a/donddata/snd/dat/vocals/2.sfk b/donddata/snd/dat/vocals/2.sfk new file mode 100644 index 0000000..cef8dd2 --- /dev/null +++ b/donddata/snd/dat/vocals/2.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de1738196fc5d30cab382fb1378016892a50c7e6a7281bd5c57b25b61db9846b +size 108 diff --git a/donddata/snd/dat/vocals/2.wav b/donddata/snd/dat/vocals/2.wav new file mode 100644 index 0000000..a7b578a --- /dev/null +++ b/donddata/snd/dat/vocals/2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24f78084d2ba88c0891e4cfeec57df813b412588b9bdc659323782abdc119469 +size 44992 diff --git a/donddata/snd/dat/vocals/20.Alright_a.wav b/donddata/snd/dat/vocals/20.Alright_a.wav new file mode 100644 index 0000000..d72349e --- /dev/null +++ b/donddata/snd/dat/vocals/20.Alright_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9868bd870f68918397128190cf663423eb33ebe8a96354587502434da9156631 +size 19372 diff --git a/donddata/snd/dat/vocals/22.HereIsTheOffer.sfk b/donddata/snd/dat/vocals/22.HereIsTheOffer.sfk new file mode 100644 index 0000000..431baec --- /dev/null +++ b/donddata/snd/dat/vocals/22.HereIsTheOffer.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1240dd6b74e24b2e9fbcb56fd7dd0ee8d64b0214f75afac3cfef274cd1ede1ae +size 200 diff --git a/donddata/snd/dat/vocals/22.HereIsTheOffer.wav b/donddata/snd/dat/vocals/22.HereIsTheOffer.wav new file mode 100644 index 0000000..61ebfa3 --- /dev/null +++ b/donddata/snd/dat/vocals/22.HereIsTheOffer.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:685ccdce51f64e75842d7a1bfaa11223d1364ba8cf9e4956abc7e9f902d68b51 +size 138724 diff --git a/donddata/snd/dat/vocals/22.HereIsTheOffer_2.sfk b/donddata/snd/dat/vocals/22.HereIsTheOffer_2.sfk new file mode 100644 index 0000000..45bb3e3 --- /dev/null +++ b/donddata/snd/dat/vocals/22.HereIsTheOffer_2.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad2f4215c1c41dc196742d76e857bb9e9e51aac61152371c2d83de96ee9c619d +size 176 diff --git a/donddata/snd/dat/vocals/22.HereIsTheOffer_2.wav b/donddata/snd/dat/vocals/22.HereIsTheOffer_2.wav new file mode 100644 index 0000000..f4c1e66 --- /dev/null +++ b/donddata/snd/dat/vocals/22.HereIsTheOffer_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1005f38c56390a4c69a3f870121af9ce39648173f6d668568aab28b2675f04bc +size 111256 diff --git a/donddata/snd/dat/vocals/22.HereIsTheOffer_d.sfk b/donddata/snd/dat/vocals/22.HereIsTheOffer_d.sfk new file mode 100644 index 0000000..44f08f5 --- /dev/null +++ b/donddata/snd/dat/vocals/22.HereIsTheOffer_d.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acfca11fb532bbba73bcd3b021b49eebb157cfe730627e7b7e4d692d32deeb41 +size 176 diff --git a/donddata/snd/dat/vocals/22.HereIsTheOffer_d.wav b/donddata/snd/dat/vocals/22.HereIsTheOffer_d.wav new file mode 100644 index 0000000..9f4fc0d --- /dev/null +++ b/donddata/snd/dat/vocals/22.HereIsTheOffer_d.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab781ae682f6d3eaf5c38c0512ba71e3ddea861c4387b1aa6e311018bcd3e72a +size 112512 diff --git a/donddata/snd/dat/vocals/23.DealOrNoDeal.sfk b/donddata/snd/dat/vocals/23.DealOrNoDeal.sfk new file mode 100644 index 0000000..225c3f7 --- /dev/null +++ b/donddata/snd/dat/vocals/23.DealOrNoDeal.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99266f909d71a6e9bbea401895cd444faf0c93ef966db516a04d6c5eb631c2ed +size 268 diff --git a/donddata/snd/dat/vocals/23.DealOrNoDeal.wav b/donddata/snd/dat/vocals/23.DealOrNoDeal.wav new file mode 100644 index 0000000..b201878 --- /dev/null +++ b/donddata/snd/dat/vocals/23.DealOrNoDeal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b10fa7b2cf857e9907f66ede5888ffc98e84ffaee9018c0a1cecac9020ea9b28 +size 206400 diff --git a/donddata/snd/dat/vocals/28.YouWin.sfk b/donddata/snd/dat/vocals/28.YouWin.sfk new file mode 100644 index 0000000..5ca1d48 --- /dev/null +++ b/donddata/snd/dat/vocals/28.YouWin.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:700f6d80687c4b3474f3ab37511e154b9668428039b7bc1fdd2d33ed9a1ec992 +size 148 diff --git a/donddata/snd/dat/vocals/28.YouWin.wav b/donddata/snd/dat/vocals/28.YouWin.wav new file mode 100644 index 0000000..54b5f70 --- /dev/null +++ b/donddata/snd/dat/vocals/28.YouWin.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76f03e81705823e414e754ae674e24762c40a9714ac4589e8be5577dd15249d9 +size 82976 diff --git a/donddata/snd/dat/vocals/29.WouldYouLikeToCont.sfk b/donddata/snd/dat/vocals/29.WouldYouLikeToCont.sfk new file mode 100644 index 0000000..ccb0ad2 --- /dev/null +++ b/donddata/snd/dat/vocals/29.WouldYouLikeToCont.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f5c3546ae12dbc5332c9166a7db97d7248c23ecad526703d4c018e0858c2e68 +size 184 diff --git a/donddata/snd/dat/vocals/29.WouldYouLikeToCont.wav b/donddata/snd/dat/vocals/29.WouldYouLikeToCont.wav new file mode 100644 index 0000000..c18ee65 --- /dev/null +++ b/donddata/snd/dat/vocals/29.WouldYouLikeToCont.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27ea687cb287a611040fa540f3b05cfba41791a3b67d07599366dea60b584562 +size 119152 diff --git a/donddata/snd/dat/vocals/29alt.InsertMoneyToCont.sfk b/donddata/snd/dat/vocals/29alt.InsertMoneyToCont.sfk new file mode 100644 index 0000000..8ea5072 --- /dev/null +++ b/donddata/snd/dat/vocals/29alt.InsertMoneyToCont.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0038c6b952d4981196eeecbb00f41ceb7d1a21ec6a18e26295706b46f55efda +size 220 diff --git a/donddata/snd/dat/vocals/29alt.InsertMoneyToCont.wav b/donddata/snd/dat/vocals/29alt.InsertMoneyToCont.wav new file mode 100644 index 0000000..5b8ef98 --- /dev/null +++ b/donddata/snd/dat/vocals/29alt.InsertMoneyToCont.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15faba3b633331c2b27b02213d2b2c20f28020cbd5f55db303776f28c2f0a3ca +size 156372 diff --git a/donddata/snd/dat/vocals/2_b.wav b/donddata/snd/dat/vocals/2_b.wav new file mode 100644 index 0000000..8be39be --- /dev/null +++ b/donddata/snd/dat/vocals/2_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb5dff44891f05f7ff7eb8c072d3348d60650a4e4b2c0d5f707bfc2cd0d29fad +size 441044 diff --git a/donddata/snd/dat/vocals/3.sfk b/donddata/snd/dat/vocals/3.sfk new file mode 100644 index 0000000..84de220 --- /dev/null +++ b/donddata/snd/dat/vocals/3.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9fd190a786817f28508ef1d5e7b4321dfaff9b9c26541643120a5e73ed111b19 +size 112 diff --git a/donddata/snd/dat/vocals/3.wav b/donddata/snd/dat/vocals/3.wav new file mode 100644 index 0000000..017e5c0 --- /dev/null +++ b/donddata/snd/dat/vocals/3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a68796060e24061001fe6c5831d39930a49fd9d2dc536869df39b68bda6c3bf +size 48684 diff --git a/donddata/snd/dat/vocals/31.PressStartToPlay.sfk b/donddata/snd/dat/vocals/31.PressStartToPlay.sfk new file mode 100644 index 0000000..b3ea3bf --- /dev/null +++ b/donddata/snd/dat/vocals/31.PressStartToPlay.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9c2986e2d56f259f501668f090c2b8eaf2f256bca728cf801022dc1df6074d9 +size 200 diff --git a/donddata/snd/dat/vocals/31.PressStartToPlay.wav b/donddata/snd/dat/vocals/31.PressStartToPlay.wav new file mode 100644 index 0000000..7a4a97a --- /dev/null +++ b/donddata/snd/dat/vocals/31.PressStartToPlay.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffbc0a31c9f88bf41d8da3458821a8a35651ec6fc3e48e926e61d92ad37f353f +size 139244 diff --git a/donddata/snd/dat/vocals/32.GameOver.sfk b/donddata/snd/dat/vocals/32.GameOver.sfk new file mode 100644 index 0000000..79afe63 --- /dev/null +++ b/donddata/snd/dat/vocals/32.GameOver.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99766e65514ed116fed704613c757701b758cb31ebc36073178e76829971d9e9 +size 156 diff --git a/donddata/snd/dat/vocals/32.GameOver.wav b/donddata/snd/dat/vocals/32.GameOver.wav new file mode 100644 index 0000000..86fed47 --- /dev/null +++ b/donddata/snd/dat/vocals/32.GameOver.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ec5af15e28969b249bf9c905057f370fb662f351393fe6034eb4f7aca89f1e6 +size 93028 diff --git a/donddata/snd/dat/vocals/33.LetsOpenTheCase_d.wav b/donddata/snd/dat/vocals/33.LetsOpenTheCase_d.wav new file mode 100644 index 0000000..42db97b --- /dev/null +++ b/donddata/snd/dat/vocals/33.LetsOpenTheCase_d.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:756c3fece867e5233647a90009fddd906eb92d00a738e2da9bcc2d697e0efa28 +size 124588 diff --git a/donddata/snd/dat/vocals/39.WelcomeBack.sfk b/donddata/snd/dat/vocals/39.WelcomeBack.sfk new file mode 100644 index 0000000..dadf17b --- /dev/null +++ b/donddata/snd/dat/vocals/39.WelcomeBack.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa0b25f2eea76cdc993041c3096e5a484f943ecd39add75fd53124bec543f3db +size 148 diff --git a/donddata/snd/dat/vocals/39.WelcomeBack.wav b/donddata/snd/dat/vocals/39.WelcomeBack.wav new file mode 100644 index 0000000..5bb96a8 --- /dev/null +++ b/donddata/snd/dat/vocals/39.WelcomeBack.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ff5d70d3c641d882fd0c8630099934b1e9ab63cc9eca6b09d3a0919d5a3e9a6 +size 85048 diff --git a/donddata/snd/dat/vocals/3_a.wav b/donddata/snd/dat/vocals/3_a.wav new file mode 100644 index 0000000..653c3f0 --- /dev/null +++ b/donddata/snd/dat/vocals/3_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5feee0738e1d7300955ceaa86523526656668bfc2d0a65346e45ec829a44f009 +size 441044 diff --git a/donddata/snd/dat/vocals/4.sfk b/donddata/snd/dat/vocals/4.sfk new file mode 100644 index 0000000..c550a19 --- /dev/null +++ b/donddata/snd/dat/vocals/4.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a320a6c6f7c5bb13379fc6e7a04aff97bf205c3f0c24503bd4e13ac931d26d60 +size 124 diff --git a/donddata/snd/dat/vocals/4.wav b/donddata/snd/dat/vocals/4.wav new file mode 100644 index 0000000..c11a55a --- /dev/null +++ b/donddata/snd/dat/vocals/4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c1b369c95850beab49d482f67f57afeec23da16d43f9d31a33aa6f65df6fc07 +size 60620 diff --git a/donddata/snd/dat/vocals/43.LetsSeeWhatYouDidntChoose.sfk b/donddata/snd/dat/vocals/43.LetsSeeWhatYouDidntChoose.sfk new file mode 100644 index 0000000..1d489d5 --- /dev/null +++ b/donddata/snd/dat/vocals/43.LetsSeeWhatYouDidntChoose.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b70d555d0e6f34de265c56d887f200c6fca66c020bd5773cb01a98129a3df81c +size 248 diff --git a/donddata/snd/dat/vocals/43.LetsSeeWhatYouDidntChoose.wav b/donddata/snd/dat/vocals/43.LetsSeeWhatYouDidntChoose.wav new file mode 100644 index 0000000..4fef0b1 --- /dev/null +++ b/donddata/snd/dat/vocals/43.LetsSeeWhatYouDidntChoose.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:897048e4b94bcd4bded670000db7f27e43ac561349a8909e603c47a8a99a1535 +size 185532 diff --git a/donddata/snd/dat/vocals/44.LadiesOpenTheCases.sfk b/donddata/snd/dat/vocals/44.LadiesOpenTheCases.sfk new file mode 100644 index 0000000..348e34d --- /dev/null +++ b/donddata/snd/dat/vocals/44.LadiesOpenTheCases.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d6d70e09e18e56a8664983a3006a91b95be89df30f8ef7522d3b366284f70fe +size 284 diff --git a/donddata/snd/dat/vocals/44.LadiesOpenTheCases.wav b/donddata/snd/dat/vocals/44.LadiesOpenTheCases.wav new file mode 100644 index 0000000..24955cf --- /dev/null +++ b/donddata/snd/dat/vocals/44.LadiesOpenTheCases.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9471133d216d356db6e995a00724058f0d25579994f83d90db7c8ed3f7d6430b +size 222280 diff --git a/donddata/snd/dat/vocals/46.AndYourCaseIsWorth.sfk b/donddata/snd/dat/vocals/46.AndYourCaseIsWorth.sfk new file mode 100644 index 0000000..d4771db --- /dev/null +++ b/donddata/snd/dat/vocals/46.AndYourCaseIsWorth.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8fea1ae4bc63ac949df1a5d8ffb10856bd7696ea5dc9c6af958fc231a9557db +size 220 diff --git a/donddata/snd/dat/vocals/46.AndYourCaseIsWorth.wav b/donddata/snd/dat/vocals/46.AndYourCaseIsWorth.wav new file mode 100644 index 0000000..0b5d346 --- /dev/null +++ b/donddata/snd/dat/vocals/46.AndYourCaseIsWorth.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:140253d1b1cadba7ecab8dc4f13d418923f09948d442ac7fac11074358162289 +size 157448 diff --git a/donddata/snd/dat/vocals/47.WowWhatAGreatGame_a.sfk b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_a.sfk new file mode 100644 index 0000000..125107c --- /dev/null +++ b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_a.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6521075c1eef53f99792ccaa7e9f10a1e37ad8f468dfffed6b62347682e0b003 +size 208 diff --git a/donddata/snd/dat/vocals/47.WowWhatAGreatGame_a.wav b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_a.wav new file mode 100644 index 0000000..08ee986 --- /dev/null +++ b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac1e570ca23f77bf6b8c78a882600aebdba336a92500c14817acdc3cc2179a46 +size 144804 diff --git a/donddata/snd/dat/vocals/47.WowWhatAGreatGame_b.sfk b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_b.sfk new file mode 100644 index 0000000..34cf56d --- /dev/null +++ b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_b.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23a6c3ed8d46a187aabbae0509c7d33be62f74848d12a0ad03235b6ae8da176f +size 256 diff --git a/donddata/snd/dat/vocals/47.WowWhatAGreatGame_b.wav b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_b.wav new file mode 100644 index 0000000..5ac0113 --- /dev/null +++ b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d09c1b2d6b1eef08e06a7588bcfc18d973d7e0f0ab9a13bafbe644be92b27d50 +size 194924 diff --git a/donddata/snd/dat/vocals/47.WowWhatAGreatGame_c.sfk b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_c.sfk new file mode 100644 index 0000000..6e64664 --- /dev/null +++ b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_c.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fedbcc079b77d4d32ab145c2722eacfd8ec82a333114159d5578cb1d21afad4a +size 264 diff --git a/donddata/snd/dat/vocals/47.WowWhatAGreatGame_c.wav b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_c.wav new file mode 100644 index 0000000..424d811 --- /dev/null +++ b/donddata/snd/dat/vocals/47.WowWhatAGreatGame_c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f5861e4b6d55303da72289a3bb3ea5f20a3246c0a0fb7366829bbe8b5a34c34 +size 201680 diff --git a/donddata/snd/dat/vocals/4_b.wav b/donddata/snd/dat/vocals/4_b.wav new file mode 100644 index 0000000..a13f49d --- /dev/null +++ b/donddata/snd/dat/vocals/4_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f8d01d1c5f28ee6019aab78dcab6ae6bba242d26357b92ca0992c9425230d57 +size 441044 diff --git a/donddata/snd/dat/vocals/5.sfk b/donddata/snd/dat/vocals/5.sfk new file mode 100644 index 0000000..5ffe756 --- /dev/null +++ b/donddata/snd/dat/vocals/5.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c3f5ac79ae64345d45829436197168a38045186b1108dea8d397ace763d6133 +size 144 diff --git a/donddata/snd/dat/vocals/5.wav b/donddata/snd/dat/vocals/5.wav new file mode 100644 index 0000000..da2545c --- /dev/null +++ b/donddata/snd/dat/vocals/5.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:200555cc6e432c058088cbdb432d7c83a32c3c52b2972339e0af7fbd9b1c54c7 +size 78076 diff --git a/donddata/snd/dat/vocals/52.WeWantLowValues.sfk b/donddata/snd/dat/vocals/52.WeWantLowValues.sfk new file mode 100644 index 0000000..0a0df10 --- /dev/null +++ b/donddata/snd/dat/vocals/52.WeWantLowValues.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0193b81cd5328969575d0534f113429fcb1ac8dd73db56f7ba7b6c5fbdd09d75 +size 240 diff --git a/donddata/snd/dat/vocals/52.WeWantLowValues.wav b/donddata/snd/dat/vocals/52.WeWantLowValues.wav new file mode 100644 index 0000000..308e624 --- /dev/null +++ b/donddata/snd/dat/vocals/52.WeWantLowValues.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3a1a7b3bf0ab2a99a7cfb6ff41806fdeed2c5cde3b4293a32fca4c536be8640 +size 179496 diff --git a/donddata/snd/dat/vocals/54.LetsSeeSomeLowValues.sfk b/donddata/snd/dat/vocals/54.LetsSeeSomeLowValues.sfk new file mode 100644 index 0000000..3df603b --- /dev/null +++ b/donddata/snd/dat/vocals/54.LetsSeeSomeLowValues.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a0e5ced5cfdfce18ae6b2117c0e8fdd1f31b1f72370c92afea077eb2c184c9d +size 204 diff --git a/donddata/snd/dat/vocals/54.LetsSeeSomeLowValues.wav b/donddata/snd/dat/vocals/54.LetsSeeSomeLowValues.wav new file mode 100644 index 0000000..9309944 --- /dev/null +++ b/donddata/snd/dat/vocals/54.LetsSeeSomeLowValues.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd7adc5f55311f4c415828812de128f34accafdcd466e42540bd58bac9a4601c +size 139556 diff --git a/donddata/snd/dat/vocals/5_c.wav b/donddata/snd/dat/vocals/5_c.wav new file mode 100644 index 0000000..6db1da9 --- /dev/null +++ b/donddata/snd/dat/vocals/5_c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e848c8f5c60c0511758d49105c83baa5ad7bd72e1c4ba250cab54084987c6e02 +size 441044 diff --git a/donddata/snd/dat/vocals/6.sfk b/donddata/snd/dat/vocals/6.sfk new file mode 100644 index 0000000..9a6fadc --- /dev/null +++ b/donddata/snd/dat/vocals/6.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bdd05a29371a99d6d17f81c0d666d7519739af96068c98760471bf5457e5b32d +size 120 diff --git a/donddata/snd/dat/vocals/6.wav b/donddata/snd/dat/vocals/6.wav new file mode 100644 index 0000000..1424b9b --- /dev/null +++ b/donddata/snd/dat/vocals/6.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c33475b752a4d2fa3a9428dcb67e1012a00b5255d25602388df268035944f6d6 +size 57244 diff --git a/donddata/snd/dat/vocals/6_b.wav b/donddata/snd/dat/vocals/6_b.wav new file mode 100644 index 0000000..a149f1d --- /dev/null +++ b/donddata/snd/dat/vocals/6_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2ef0b7db6a1751ba2674ed740e898f8de04197f53e7e6a851f9bf3379db0372 +size 441044 diff --git a/donddata/snd/dat/vocals/7.sfk b/donddata/snd/dat/vocals/7.sfk new file mode 100644 index 0000000..a02518b --- /dev/null +++ b/donddata/snd/dat/vocals/7.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15a00bf2d6740806597fd26c91b99b43cc8406711f7ea996fe4625daaadb281b +size 112 diff --git a/donddata/snd/dat/vocals/7.wav b/donddata/snd/dat/vocals/7.wav new file mode 100644 index 0000000..4c3709a --- /dev/null +++ b/donddata/snd/dat/vocals/7.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cdb6546afbf486735fcfd87da063245c0df78b4ccc4571dbbcac35b0235dff14 +size 46852 diff --git a/donddata/snd/dat/vocals/7_a.wav b/donddata/snd/dat/vocals/7_a.wav new file mode 100644 index 0000000..0852b09 --- /dev/null +++ b/donddata/snd/dat/vocals/7_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a62282a05433dfeb6a299ec8d716fb48190e9d3d018d4443082c77b66f195ab +size 441044 diff --git a/donddata/snd/dat/vocals/8.sfk b/donddata/snd/dat/vocals/8.sfk new file mode 100644 index 0000000..44f9b0c --- /dev/null +++ b/donddata/snd/dat/vocals/8.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddd31a1982ad0525f6d3c1564caf296f3fe8d450c4fedccd5d6546db34c14d0e +size 104 diff --git a/donddata/snd/dat/vocals/8.wav b/donddata/snd/dat/vocals/8.wav new file mode 100644 index 0000000..aa8dda1 --- /dev/null +++ b/donddata/snd/dat/vocals/8.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebddbc757f52bfeca5b38690515b2e19700afb17ef51c060ad903913b3432c00 +size 39204 diff --git a/donddata/snd/dat/vocals/8_a.wav b/donddata/snd/dat/vocals/8_a.wav new file mode 100644 index 0000000..98284ee --- /dev/null +++ b/donddata/snd/dat/vocals/8_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:360dc2290de644dd623bb0efa21cf9c298450f42cdea35d01ca648ca3130f895 +size 441044 diff --git a/donddata/snd/dat/vocals/9.sfk b/donddata/snd/dat/vocals/9.sfk new file mode 100644 index 0000000..da7fe17 --- /dev/null +++ b/donddata/snd/dat/vocals/9.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bba73ea432723d5369738670d62e8799fcb6fc9c3723ca2866f006e41ce4ae03 +size 128 diff --git a/donddata/snd/dat/vocals/9.wav b/donddata/snd/dat/vocals/9.wav new file mode 100644 index 0000000..258aafd --- /dev/null +++ b/donddata/snd/dat/vocals/9.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7a3fc6f5ccc8ff56c0a9b586f0f114b81294085e704aa04607c2ca9b5dc4d0d +size 65248 diff --git a/donddata/snd/dat/vocals/9_b.wav b/donddata/snd/dat/vocals/9_b.wav new file mode 100644 index 0000000..b32257f --- /dev/null +++ b/donddata/snd/dat/vocals/9_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49fc5c260d679bafccc5234cf768715148603f483d9e3c7d6fc53e3bd9837d87 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase10_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase10_b.wav new file mode 100644 index 0000000..1ad5ea5 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase10_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e14cc6d68744cd4082040e9c546c04be27ebf084836fcc9a72559280fa6e1a62 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase11_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase11_b.wav new file mode 100644 index 0000000..728172f --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase11_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcf9130e483a992d99a8d46b72f43888fcdbfeddf0908e8c950440f300f807e0 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase12_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase12_b.wav new file mode 100644 index 0000000..11285fc --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase12_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d32d068e54a44cfd380e95bce7a3326d9f76352a3ae982c6c5f8b5865994f5f +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase13_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase13_a.wav new file mode 100644 index 0000000..bb102c5 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase13_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ddbd84a465956627dd2ff444882250a3cf2f3ebcac39474975cce2f6d83dc23 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase14_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase14_a.wav new file mode 100644 index 0000000..7eb7cd6 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase14_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:064d2feebfd43289b9ca13ff94d9227410f10bf27358d1df37001a5e772a36b0 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase15_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase15_b.wav new file mode 100644 index 0000000..35a0710 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase15_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e4adb026eac06bf8c22567a2bf0a2cbbaf7ee44f49ba6997c00f0c4f997ae04 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase16_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase16_b.wav new file mode 100644 index 0000000..223ae31 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase16_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58ec85ee16b9a7d0948cb35d3cee5175eaccedf55a4e1cb50c95f418ad0bf521 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase1_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase1_a.wav new file mode 100644 index 0000000..15d661d --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase1_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e3a8e5662b5d9fa3ffc07aed15c84413a8872de2f8a3645cc6c1f432c4731ec +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase2_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase2_a.wav new file mode 100644 index 0000000..e1e9e0d --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase2_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d33664621a33162467c658f4cdd21adec1bfb1e643e3a35d4b15a26b38dbf3f +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase3_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase3_a.wav new file mode 100644 index 0000000..62bb097 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase3_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:059f9586af0447d8851764d6ba89336339a1bbd036d666caf22cacf73b4a3361 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase4_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase4_b.wav new file mode 100644 index 0000000..b31c32c --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase4_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31a302afe69093d09139a06aac75bddca9b364ce21ce33730bdadc579e624447 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase5_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase5_a.wav new file mode 100644 index 0000000..4541d6a --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase5_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bb780c162e5b4c76e34f5199151bd4e9cce2e3997a2a6eeb495ccb7ff35b577 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase6_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase6_b.wav new file mode 100644 index 0000000..8a64a2b --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase6_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee32811edd6a2f7b96f8f8d501b139c3770cc88b848ec1d581e1877cfc8cd689 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase7_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase7_a.wav new file mode 100644 index 0000000..1cce92a --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase7_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56830de033a182cd0dc1bc23fc5d55ce22ac9edce97a24cc69e8076b08bbc7aa +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase8_a.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase8_a.wav new file mode 100644 index 0000000..225cd77 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase8_a.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a80e0c200196a65804e25643897006a38f562649c15e6c1732f74fc820b32126 +size 441044 diff --git a/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase9_b.wav b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase9_b.wav new file mode 100644 index 0000000..63d2f82 --- /dev/null +++ b/donddata/snd/dat/vocals/Copy of pcase/41alt.YouChoseCase9_b.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42a6fffdfa8b1e6fba9b377bf5c64adfae1107c59c12428cf1c4a4e573a3282c +size 441044 diff --git a/donddata/snd/dat/vocals/good_open/53.ThatsGoodKeepItLow.wav b/donddata/snd/dat/vocals/good_open/53.ThatsGoodKeepItLow.wav new file mode 100644 index 0000000..fe031a8 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/53.ThatsGoodKeepItLow.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e46d36fe2f85e3e98298ea1308cd996e222328023c5c9836f1761e9d7e8bdcd +size 184996 diff --git a/donddata/snd/dat/vocals/good_open/53.ThatsGoodKeepItLow_2.wav b/donddata/snd/dat/vocals/good_open/53.ThatsGoodKeepItLow_2.wav new file mode 100644 index 0000000..1d32468 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/53.ThatsGoodKeepItLow_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cb3ced56c488d359dbead0b7ddffc5bd8c0b518e09d026c0eed9f77c420be84 +size 193548 diff --git a/donddata/snd/dat/vocals/good_open/55.ThatsAGoodOne.wav b/donddata/snd/dat/vocals/good_open/55.ThatsAGoodOne.wav new file mode 100644 index 0000000..cbf8100 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/55.ThatsAGoodOne.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:381aeaf545872da6cdfdfd636cf8f55d5968a8da08224cd1fd82f7334723243f +size 102812 diff --git a/donddata/snd/dat/vocals/good_open/56.Yes.wav b/donddata/snd/dat/vocals/good_open/56.Yes.wav new file mode 100644 index 0000000..06ec31d --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/56.Yes.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d481e0f17ca253b860b7b1da190f18516395e8e847a055d1b8f74054bd447ab +size 65124 diff --git a/donddata/snd/dat/vocals/good_open/57.GreatChoice.wav b/donddata/snd/dat/vocals/good_open/57.GreatChoice.wav new file mode 100644 index 0000000..32df677 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/57.GreatChoice.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0d2b3e18eff5a52539ff92cc3a4ddaed04860e87194c64eeb75231846f9d1db +size 101472 diff --git a/donddata/snd/dat/vocals/good_open/58.ThatsGood.wav b/donddata/snd/dat/vocals/good_open/58.ThatsGood.wav new file mode 100644 index 0000000..cf66f54 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/58.ThatsGood.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6cd88549127af6432b01fde82a7c893f93ca87aef1063cee18022d2aa9494cfd +size 75148 diff --git a/donddata/snd/dat/vocals/good_open/58.ThatsGood_2.wav b/donddata/snd/dat/vocals/good_open/58.ThatsGood_2.wav new file mode 100644 index 0000000..5d1714b --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/58.ThatsGood_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ff4ef15a74485e1465211ebf19dcdca079ae0a9fa24689917080ccad60bb624 +size 88644 diff --git a/donddata/snd/dat/vocals/good_open/59.YourDoingGreat.wav b/donddata/snd/dat/vocals/good_open/59.YourDoingGreat.wav new file mode 100644 index 0000000..28231e7 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/59.YourDoingGreat.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28288fb8338fdb0bc64b917d1811ac6801ad3be689a3d2f814b8d6a49e6a1fc6 +size 110160 diff --git a/donddata/snd/dat/vocals/good_open/59.YourDoingGreat_2.wav b/donddata/snd/dat/vocals/good_open/59.YourDoingGreat_2.wav new file mode 100644 index 0000000..4b7e135 --- /dev/null +++ b/donddata/snd/dat/vocals/good_open/59.YourDoingGreat_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e7f0f26463846dca705eb8d9dc9080e11e07c03ff4e05b6acf87e1584e6667d +size 91036 diff --git a/donddata/snd/dat/vocals/good_open/vssver.scc b/donddata/snd/dat/vocals/good_open/vssver.scc new file mode 100644 index 0000000..c196d1a Binary files /dev/null and b/donddata/snd/dat/vocals/good_open/vssver.scc differ diff --git a/donddata/snd/dat/vocals/hello/19.Hello.wav b/donddata/snd/dat/vocals/hello/19.Hello.wav new file mode 100644 index 0000000..3c78fa9 --- /dev/null +++ b/donddata/snd/dat/vocals/hello/19.Hello.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7305b86554511723c5b6c906287f503edd329fb60726629270a83e46c2ed8c7a +size 32912 diff --git a/donddata/snd/dat/vocals/hello/19.Hello_2.wav b/donddata/snd/dat/vocals/hello/19.Hello_2.wav new file mode 100644 index 0000000..accc841 --- /dev/null +++ b/donddata/snd/dat/vocals/hello/19.Hello_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:429e0c7cb0496565a67d2d99b67417acab6d441087db4155cb73f49285c51f6a +size 33144 diff --git a/donddata/snd/dat/vocals/hello/19.Hello_3.wav b/donddata/snd/dat/vocals/hello/19.Hello_3.wav new file mode 100644 index 0000000..131bb3c --- /dev/null +++ b/donddata/snd/dat/vocals/hello/19.Hello_3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0c2e26fa56f331a6d187986878d8b3742912afed696d35057904cb53739f8de +size 37436 diff --git a/donddata/snd/dat/vocals/hello/19.Hello_4.wav b/donddata/snd/dat/vocals/hello/19.Hello_4.wav new file mode 100644 index 0000000..8f3383f --- /dev/null +++ b/donddata/snd/dat/vocals/hello/19.Hello_4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cff979dafb627f073102d60eedb9463cc6301ce6cc4df5e67b74d63dbcbbbf7 +size 36360 diff --git a/donddata/snd/dat/vocals/hello/vssver.scc b/donddata/snd/dat/vocals/hello/vssver.scc new file mode 100644 index 0000000..d8e4046 Binary files /dev/null and b/donddata/snd/dat/vocals/hello/vssver.scc differ diff --git a/donddata/snd/dat/vocals/ind_deal/IndFemA_ISayDeal02.wav b/donddata/snd/dat/vocals/ind_deal/IndFemA_ISayDeal02.wav new file mode 100644 index 0000000..728de3d --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndFemA_ISayDeal02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e307414acc5a8ac9383064890e711a2482b16b77861960186282949ec390b42d +size 147924 diff --git a/donddata/snd/dat/vocals/ind_deal/IndFemB_ISayDeal02.wav b/donddata/snd/dat/vocals/ind_deal/IndFemB_ISayDeal02.wav new file mode 100644 index 0000000..b7565dc --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndFemB_ISayDeal02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c85655949a4c10a39f0a5b8c9ff7faf9ea623a62c05152328b7870f3d108d7a4 +size 157804 diff --git a/donddata/snd/dat/vocals/ind_deal/IndFemB_TakeTheDeal02.wav b/donddata/snd/dat/vocals/ind_deal/IndFemB_TakeTheDeal02.wav new file mode 100644 index 0000000..f4bb6bc --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndFemB_TakeTheDeal02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e96e5030bf7bcd030d0130617d806ee5e2ab722f73726ac256e15072dbd62b3 +size 157708 diff --git a/donddata/snd/dat/vocals/ind_deal/IndFemaleC_ISayDeal01.wav b/donddata/snd/dat/vocals/ind_deal/IndFemaleC_ISayDeal01.wav new file mode 100644 index 0000000..483fb77 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndFemaleC_ISayDeal01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b921db0fc104eaa450ac485bfd02d70c88184f7cc26ac45e43ed93f4c1f8b1b +size 116364 diff --git a/donddata/snd/dat/vocals/ind_deal/IndFemaleC_ItsWhatYouWant01.wav b/donddata/snd/dat/vocals/ind_deal/IndFemaleC_ItsWhatYouWant01.wav new file mode 100644 index 0000000..0ce3b82 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndFemaleC_ItsWhatYouWant01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43829c5d891e8d6082ec0d55a16fe174280cc8d75e0c1432147b7ea0415a087b +size 162240 diff --git a/donddata/snd/dat/vocals/ind_deal/IndMaleB_Deal08.wav b/donddata/snd/dat/vocals/ind_deal/IndMaleB_Deal08.wav new file mode 100644 index 0000000..c511042 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndMaleB_Deal08.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2ae9ef8db530659ef65cbca9f0ede33223eefd9472fc048a5f645e5d7d86a6d +size 138532 diff --git a/donddata/snd/dat/vocals/ind_deal/IndMaleB_ISayDeal01.wav b/donddata/snd/dat/vocals/ind_deal/IndMaleB_ISayDeal01.wav new file mode 100644 index 0000000..de99b73 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndMaleB_ISayDeal01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dae9c240fa8d505b86b0d30059ac9e275f1ca20fa059d8df2d29709be4c4724e +size 115884 diff --git a/donddata/snd/dat/vocals/ind_deal/IndMaleB_TakeTheDeal01.wav b/donddata/snd/dat/vocals/ind_deal/IndMaleB_TakeTheDeal01.wav new file mode 100644 index 0000000..439f6ab --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndMaleB_TakeTheDeal01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7f7bcbc01be7d2a2c391d02d26a36b3c51899e2d5827f3e51fda27c5a5e4af8 +size 149516 diff --git a/donddata/snd/dat/vocals/ind_deal/IndMaleC_ISayDeal01.wav b/donddata/snd/dat/vocals/ind_deal/IndMaleC_ISayDeal01.wav new file mode 100644 index 0000000..cbea20b --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndMaleC_ISayDeal01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e8b8f644b5a6d1f10a2f1a7977a25342f82af044caeb55774776d9836c1f08f +size 145612 diff --git a/donddata/snd/dat/vocals/ind_deal/IndMaleC_TakeTheDeal01.wav b/donddata/snd/dat/vocals/ind_deal/IndMaleC_TakeTheDeal01.wav new file mode 100644 index 0000000..4ea57ae --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndMaleC_TakeTheDeal01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c97015b01ed145119da68fbfcb11f4f0079ed5eceff5408ffd31b99ac9ab5c4 +size 184692 diff --git a/donddata/snd/dat/vocals/ind_deal/IndMaleC_YouGottaTakeIt04.wav b/donddata/snd/dat/vocals/ind_deal/IndMaleC_YouGottaTakeIt04.wav new file mode 100644 index 0000000..ab133d1 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_deal/IndMaleC_YouGottaTakeIt04.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54eadea92d31b8de35f4507e6d80168780fb7392a52d4cbef3b6f310544afe73 +size 142772 diff --git a/donddata/snd/dat/vocals/ind_deal/vssver.scc b/donddata/snd/dat/vocals/ind_deal/vssver.scc new file mode 100644 index 0000000..f9f9852 Binary files /dev/null and b/donddata/snd/dat/vocals/ind_deal/vssver.scc differ diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndFemA_GoForTheBigOne02.wav b/donddata/snd/dat/vocals/ind_nodeal/IndFemA_GoForTheBigOne02.wav new file mode 100644 index 0000000..16cb3ec --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndFemA_GoForTheBigOne02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:863cd646d8215a0c61eea42d00fa3b77b01ef9e7a4d0dac32c0ab6407adeb863 +size 147976 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndFemA_OneMoreOneMore02.wav b/donddata/snd/dat/vocals/ind_nodeal/IndFemA_OneMoreOneMore02.wav new file mode 100644 index 0000000..a25400c --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndFemA_OneMoreOneMore02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7576086fd17779b669ec3b72d542910f76b8847fa0fd923af5c81d795d806877 +size 148360 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndFemB_GoForIt01.wav b/donddata/snd/dat/vocals/ind_nodeal/IndFemB_GoForIt01.wav new file mode 100644 index 0000000..da1d2ff --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndFemB_GoForIt01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b34f86a95037ab8fcf0504f7a98541662155bbfe13f3e1d94bb22a547226e07 +size 128460 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndFemB_NoDeal02.wav b/donddata/snd/dat/vocals/ind_nodeal/IndFemB_NoDeal02.wav new file mode 100644 index 0000000..ec7baa0 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndFemB_NoDeal02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d8fa42865fd1992fd7aff9807c438c2d0404855f3afdfb7003aa40cee3d9330 +size 228156 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndFemaleC_NoWayNoDeal02.wav b/donddata/snd/dat/vocals/ind_nodeal/IndFemaleC_NoWayNoDeal02.wav new file mode 100644 index 0000000..7791220 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndFemaleC_NoWayNoDeal02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:458be26e24b5b64b4653b58d110460aafb19d81628c83146cfb9a28f9bd935e5 +size 251192 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndMaleA_NoWayNoDeal02.wav b/donddata/snd/dat/vocals/ind_nodeal/IndMaleA_NoWayNoDeal02.wav new file mode 100644 index 0000000..231a377 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndMaleA_NoWayNoDeal02.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9adc93ac54027ec7f969d61f442fb6f6c33a9ab2ef4d1af7d7d9fc18aa6c618a +size 207632 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndMaleA_WereNotReadyToGo03.wav b/donddata/snd/dat/vocals/ind_nodeal/IndMaleA_WereNotReadyToGo03.wav new file mode 100644 index 0000000..67093f9 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndMaleA_WereNotReadyToGo03.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54da9ef955ce44672afe15b0bf1d590d1df51b8963e2dae635a5e460801046a6 +size 259768 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndMaleB_NoWay01.wav b/donddata/snd/dat/vocals/ind_nodeal/IndMaleB_NoWay01.wav new file mode 100644 index 0000000..1bd8130 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndMaleB_NoWay01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7e922d17e1d71746df29f9c4de72fa7b3a1e2acb79444270451388e42711507 +size 73960 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndMaleB_NoWayNoDeal03.wav b/donddata/snd/dat/vocals/ind_nodeal/IndMaleB_NoWayNoDeal03.wav new file mode 100644 index 0000000..167a444 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndMaleB_NoWayNoDeal03.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5ac334b475b4844df3611e83cd5195db14eb85087def59b7619bf065e491db5 +size 173032 diff --git a/donddata/snd/dat/vocals/ind_nodeal/IndMaleC_KeepGoin01.wav b/donddata/snd/dat/vocals/ind_nodeal/IndMaleC_KeepGoin01.wav new file mode 100644 index 0000000..724a958 --- /dev/null +++ b/donddata/snd/dat/vocals/ind_nodeal/IndMaleC_KeepGoin01.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f246caa3db561bf6cf7fa17767779b7873accd2c9b6a964f28c876bb876e33a +size 130340 diff --git a/donddata/snd/dat/vocals/ind_nodeal/vssver.scc b/donddata/snd/dat/vocals/ind_nodeal/vssver.scc new file mode 100644 index 0000000..8e86c76 Binary files /dev/null and b/donddata/snd/dat/vocals/ind_nodeal/vssver.scc differ diff --git a/donddata/snd/dat/vocals/open_the_case/voc_open_the_case.wav b/donddata/snd/dat/vocals/open_the_case/voc_open_the_case.wav new file mode 100644 index 0000000..22e2539 --- /dev/null +++ b/donddata/snd/dat/vocals/open_the_case/voc_open_the_case.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edc84423a36a0129816e0fbc69545864ec43c03daad95420ca1ffa45830336f0 +size 84224 diff --git a/donddata/snd/dat/vocals/open_the_case/vssver.scc b/donddata/snd/dat/vocals/open_the_case/vssver.scc new file mode 100644 index 0000000..5fa887c Binary files /dev/null and b/donddata/snd/dat/vocals/open_the_case/vssver.scc differ diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase1.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase1.wav new file mode 100644 index 0000000..197e53f --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f89f6bc999ea507e0bd7f6bbe00a6177bac0cecf39fd229a87aa756078df408 +size 182240 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase10.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase10.wav new file mode 100644 index 0000000..5e003ca --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase10.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d7c3e01f0c394aa591dab2fe708213674cf32c49e6f549248d53fafb4208b49 +size 166712 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase11.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase11.wav new file mode 100644 index 0000000..4859dae --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase11.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8413f48983a5dda71ddc5323bccaefd006730487c911631365b04acb2f5988e9 +size 155324 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase12.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase12.wav new file mode 100644 index 0000000..5a160f1 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase12.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8db01907decf25fc8e7d12d5a5bb1ede89cfc12aba2fd139ccbd630276dff98 +size 185348 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase13.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase13.wav new file mode 100644 index 0000000..3c7d5fd --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase13.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:421d976d7d91465b4d4192a5445abe855c778f73c68a6485e1cc4cd888990ae6 +size 178100 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase14.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase14.wav new file mode 100644 index 0000000..4621484 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase14.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1231a31b54b6c9b9faf163d00697b2cd91626ba39f2cbde4d8c5bf72564f7f0f +size 176028 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase15.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase15.wav new file mode 100644 index 0000000..1e8847a --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase15.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:908dce2ed960f0f9fc6451f2cb144e1ab17a9e733dc981a1ceb0c919a5684675 +size 182240 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase16.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase16.wav new file mode 100644 index 0000000..dd4040f --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase16.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:435f789879c2100be2af58d825115265ccec51b48da4ac756010c6eec5e68eef +size 188452 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase2.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase2.wav new file mode 100644 index 0000000..7b2fea5 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67825c3f574f7a80f52749d014aa514aa70c9740529447440643dfc8ede9b5e0 +size 168784 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase3.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase3.wav new file mode 100644 index 0000000..c5ed021 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8090e74c4a3a94a5e2a7eb4e7423d81391bf9b4beed49efeb624237881607f97 +size 176028 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase4.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase4.wav new file mode 100644 index 0000000..8b86a5f --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c1315be68ef73054062a469c92b4d1cc1e7e36b12a0094e8e53be528596d9c6 +size 164644 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase5.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase5.wav new file mode 100644 index 0000000..1b1a884 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase5.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f65acf32f097cf9e2b68f06bb4c0b0d4603eec1c05b3a59fff2cb791656e97f8 +size 171888 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase6.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase6.wav new file mode 100644 index 0000000..de3aa37 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase6.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a713ac96bbf89fb807272e4023b800670d17b47e725638270babdfa44b7f331b +size 170852 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase7.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase7.wav new file mode 100644 index 0000000..b15cae7 --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase7.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d46d771a45e8993f3fe32ad4e69c3e60d3c91cbf3b56f9e72ac4bb1fd4f48f7 +size 170852 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase8.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase8.wav new file mode 100644 index 0000000..028b3ff --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase8.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b394aca42889f396ca5580af998e7ec8c802575130adc27eb3c2bbc6804921b7 +size 154292 diff --git a/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase9.wav b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase9.wav new file mode 100644 index 0000000..c12c47e --- /dev/null +++ b/donddata/snd/dat/vocals/pcase/41alt.YouChoseCase9.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf0fa8615045195795ab1fd50dc54e5c18ed83d70f76a56153910f6c92558f4a +size 167748 diff --git a/donddata/snd/dat/vocals/pcase/vssver.scc b/donddata/snd/dat/vocals/pcase/vssver.scc new file mode 100644 index 0000000..7d3d8ca Binary files /dev/null and b/donddata/snd/dat/vocals/pcase/vssver.scc differ diff --git a/donddata/snd/dat/vocals/tell_them/20.Alright.wav b/donddata/snd/dat/vocals/tell_them/20.Alright.wav new file mode 100644 index 0000000..56acf81 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20.Alright.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:037ff8a9f4277a0fc0f001ac6a0f96037ec02537e09bb43dc6efa7896ad3dadb +size 38700 diff --git a/donddata/snd/dat/vocals/tell_them/20.Alright_2.wav b/donddata/snd/dat/vocals/tell_them/20.Alright_2.wav new file mode 100644 index 0000000..0feb774 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20.Alright_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98068cf84fb8b88c2315a37dc0588b55c641290b93a545f11182f06841d8382f +size 32040 diff --git a/donddata/snd/dat/vocals/tell_them/20.Alright_3.wav b/donddata/snd/dat/vocals/tell_them/20.Alright_3.wav new file mode 100644 index 0000000..b946c3e --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20.Alright_3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39d2e03323d26a28453cf9d169f683114c072cb6994b998ce7daa6d2209f7c77 +size 43476 diff --git a/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem.wav b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem.wav new file mode 100644 index 0000000..6459448 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24fc85d6c7380e07b2d831af8ab55d530b6974a945ebed511ee2d32cda3e95f1 +size 64176 diff --git a/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_2.wav b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_2.wav new file mode 100644 index 0000000..eec10e0 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e68840a17e7c4c02fecf4b772ea24c8274fb8452419a9527da29a223dce70a5 +size 55088 diff --git a/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_3.wav b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_3.wav new file mode 100644 index 0000000..73926b1 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebabb1f6fc76539beaf1ffe9d81f93962adf767c46209305e08e5e99d50f9bf7 +size 62796 diff --git a/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_4.wav b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_4.wav new file mode 100644 index 0000000..6e7a644 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f623aec215814bf5da91da030c0ec260c5cfe9a2de6d7cccf242d3c5ac96a49 +size 69120 diff --git a/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_5.wav b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_5.wav new file mode 100644 index 0000000..7a96233 --- /dev/null +++ b/donddata/snd/dat/vocals/tell_them/20alt.IllTellThem_5.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9711def05c613ced9b9e00520f7d67f14001a22303094bb6e1c6c0c15df75ea0 +size 86292 diff --git a/donddata/snd/dat/vocals/tell_them/vssver.scc b/donddata/snd/dat/vocals/tell_them/vssver.scc new file mode 100644 index 0000000..793b0f7 Binary files /dev/null and b/donddata/snd/dat/vocals/tell_them/vssver.scc differ diff --git a/donddata/snd/dat/vocals/timeout/49.MakeAChoice.wav b/donddata/snd/dat/vocals/timeout/49.MakeAChoice.wav new file mode 100644 index 0000000..43498ad --- /dev/null +++ b/donddata/snd/dat/vocals/timeout/49.MakeAChoice.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9ef3c6da659ec6891243b16314aedda03feae0ba3f6ac8200e4d665cf161f45 +size 93056 diff --git a/donddata/snd/dat/vocals/timeout/50.TimeIsRunningOut.wav b/donddata/snd/dat/vocals/timeout/50.TimeIsRunningOut.wav new file mode 100644 index 0000000..15962d0 --- /dev/null +++ b/donddata/snd/dat/vocals/timeout/50.TimeIsRunningOut.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b260ce67715ffbace9c20abf899570c8fcef38741517391b1d3262ee3450062a +size 118312 diff --git a/donddata/snd/dat/vocals/timeout/51.HurryUpAndChoose.wav b/donddata/snd/dat/vocals/timeout/51.HurryUpAndChoose.wav new file mode 100644 index 0000000..8d08455 --- /dev/null +++ b/donddata/snd/dat/vocals/timeout/51.HurryUpAndChoose.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4f21c7ff993560aa2c9221e5ae20187455633f32d267f6c9b7ae2052a89bc70 +size 101608 diff --git a/donddata/snd/dat/vocals/timeout/51.HurryUpAndChoose_2.wav b/donddata/snd/dat/vocals/timeout/51.HurryUpAndChoose_2.wav new file mode 100644 index 0000000..0d9b36c --- /dev/null +++ b/donddata/snd/dat/vocals/timeout/51.HurryUpAndChoose_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0bd388c7dadbc35d0b0c783b0fe2ccbb97b1c718d7ac1a92ee5fb38f9c800519 +size 137020 diff --git a/donddata/snd/dat/vocals/timeout/vssver.scc b/donddata/snd/dat/vocals/timeout/vssver.scc new file mode 100644 index 0000000..3168565 Binary files /dev/null and b/donddata/snd/dat/vocals/timeout/vssver.scc differ diff --git a/donddata/snd/dat/vocals/voc_deal.sfk b/donddata/snd/dat/vocals/voc_deal.sfk new file mode 100644 index 0000000..c8a302f --- /dev/null +++ b/donddata/snd/dat/vocals/voc_deal.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91804098991431c8406f939948492646bbf7fc6238be33bd99012ade28764397 +size 136 diff --git a/donddata/snd/dat/vocals/voc_deal.wav b/donddata/snd/dat/vocals/voc_deal.wav new file mode 100644 index 0000000..6774989 --- /dev/null +++ b/donddata/snd/dat/vocals/voc_deal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c9fc3483ed730c2b8cc1b25375664c5dec2e37cdd7c94cbbdd33cc5735c1fb1 +size 73268 diff --git a/donddata/snd/dat/vocals/voc_dealornodeal.sfk b/donddata/snd/dat/vocals/voc_dealornodeal.sfk new file mode 100644 index 0000000..1678f73 --- /dev/null +++ b/donddata/snd/dat/vocals/voc_dealornodeal.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b56bf7fa6d07394e704d614eb840465643301d9e601469ca570e11464bfd1d3e +size 232 diff --git a/donddata/snd/dat/vocals/voc_dealornodeal.wav b/donddata/snd/dat/vocals/voc_dealornodeal.wav new file mode 100644 index 0000000..476b7e1 --- /dev/null +++ b/donddata/snd/dat/vocals/voc_dealornodeal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:240a91434833d9d52dc5e4721c68501bf5dbcef1168a7385d9c0dc12a787b556 +size 171012 diff --git a/donddata/snd/dat/vocals/voc_here_is_the_final_reveal.sfk b/donddata/snd/dat/vocals/voc_here_is_the_final_reveal.sfk new file mode 100644 index 0000000..c60690a --- /dev/null +++ b/donddata/snd/dat/vocals/voc_here_is_the_final_reveal.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d91e9f962c69fa09963bd7969e871a0199c26da3a5b8ab0cd2d6b486867ee311 +size 220 diff --git a/donddata/snd/dat/vocals/voc_here_is_the_final_reveal.wav b/donddata/snd/dat/vocals/voc_here_is_the_final_reveal.wav new file mode 100644 index 0000000..9475cd1 --- /dev/null +++ b/donddata/snd/dat/vocals/voc_here_is_the_final_reveal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab1390c9bef780dd9bf73ae05f3225b921fab3183f7e2a0b54487ca093114948 +size 158692 diff --git a/donddata/snd/dat/vocals/voc_nodeal.sfk b/donddata/snd/dat/vocals/voc_nodeal.sfk new file mode 100644 index 0000000..904238f --- /dev/null +++ b/donddata/snd/dat/vocals/voc_nodeal.sfk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de4a344a545f188b0935ad6d72fd037dd0ffc0ac7499e3543c015fdd36aa7a67 +size 160 diff --git a/donddata/snd/dat/vocals/voc_nodeal.wav b/donddata/snd/dat/vocals/voc_nodeal.wav new file mode 100644 index 0000000..8174d2d --- /dev/null +++ b/donddata/snd/dat/vocals/voc_nodeal.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24ace67889fa7275cb5ca30da563b3982d9c3e13971ceeaa1b019bfc3534ecf1 +size 94344 diff --git a/donddata/snd/dat/vocals/voc_now_letsopen.wav b/donddata/snd/dat/vocals/voc_now_letsopen.wav new file mode 100644 index 0000000..e93d2fa --- /dev/null +++ b/donddata/snd/dat/vocals/voc_now_letsopen.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca89e753aa2c9d992b4a9329124e1b6fc3d20f8e3d4737978786d126b2280a1f +size 213588 diff --git a/donddata/snd/dat/vocals/vssver.scc b/donddata/snd/dat/vocals/vssver.scc new file mode 100644 index 0000000..d1dba37 Binary files /dev/null and b/donddata/snd/dat/vocals/vssver.scc differ diff --git a/donddata/snd/dat/vssver.scc b/donddata/snd/dat/vssver.scc new file mode 100644 index 0000000..3cbb4d4 Binary files /dev/null and b/donddata/snd/dat/vssver.scc differ diff --git a/donddata/snd/plsdond.txt b/donddata/snd/plsdond.txt new file mode 100644 index 0000000..8745a7f --- /dev/null +++ b/donddata/snd/plsdond.txt @@ -0,0 +1,694 @@ +VOL_GAIN + +; MUSIC -------------------------------------------------------------- + +PLAYLIST 1, 'snd_mus_offer', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/bc_bank_offer.wav', 0 + END + +PLAYLIST 2, 'snd_mus_bump', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/tp_theme_bumper_6.wav', 1 + END + +PLAYLIST 3, 'snd_mus_title', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/tp_dond_theme_2.wav', 0 + END + +PLAYLIST 52, 'snd_mus_modeltheme', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/bc_model_theme_full.wav', 0 + END + +PLAYLIST 50, 'snd_mus_choose_deal', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/mus_choose_deal.wav', 1 + END + +PLAYLIST 51, 'snd_mus_choose_deal_wr', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/mus_choose_deal_wr.wav', 1 + END + +PLAYLIST 53, 'snd_mus_game_over_wr', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/mus_game_over_wr.wav', 1 + END + +PLAYLIST 54, 'snd_mus_shuffle', 128, 0x01 + SETVOL 0,200,0 + PLAYS 0, 'dat/music/mus_shuffle2.wav', 0 + END + +; VOCALS ------------------------------------------------------------- +; +; 300 - 309 : prompts for select personal, 5, 4, 3, 2 cases +; 310 - 326 : individual numbers +; 330 - 346 : personal case +; 350 : thats the banker + +GROUP 'grp_thats_the_banker', 1 + SOUND 'dat/vocals/18.ThatsTheBanker.wav', 3 + SOUND 'dat/vocals/18alt.TheresTheBanker.wav', 3 +END + +PLAYLIST 350, 'snd_voc_pcase', 128, 0x04 + SETVOL 0,200,0 + PLAYGROUP 0, 'grp_thats_the_banker', 1 + END + +; ... + +GROUP 'grp_hello', 1 + SOUND 'dat/vocals/hello/19.Hello.wav', 3 + SOUND 'dat/vocals/hello/19.Hello_2.wav', 3 + SOUND 'dat/vocals/hello/19.Hello_3.wav', 3 + SOUND 'dat/vocals/hello/19.Hello_4.wav', 3 +END + +PLAYLIST 351, 'snd_voc_pcase', 128, 0x04 + SETVOL 0,200,0 + PLAYGROUP 0, 'grp_hello', 1 + END + +; ... + +GROUP 'grp_heres_the_offer', 1 + SOUND 'dat/vocals/22.HereIsTheOffer.wav', 1 + SOUND 'dat/vocals/22.HereIsTheOffer_2.wav', 1 +END + +PLAYLIST 352, 'snd_heres_the_offer', 128, 0x04 + SETVOL 0,200,0 + PLAYGROUP 0, 'grp_heres_the_offer', 1 + END + +PLAYLIST 353, 'snd_voc_pcase', 128, 0x04 + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/23.DealOrNoDeal.wav', 1 + END + +PLAYLIST 354, 'snd_voc_pcase', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/voc_deal.wav', 1 + END + +PLAYLIST 355, 'snd_voc_pcase', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/voc_nodeal.wav', 1 + END + +; "alright" / "i'll tell them" + +GROUP 'grp_ill_tell_them', 1 + SOUND 'dat/vocals/tell_them/20.Alright.wav', 7 + SOUND 'dat/vocals/tell_them/20.Alright_2.wav', 7 + SOUND 'dat/vocals/tell_them/20.Alright_3.wav', 7 + SOUND 'dat/vocals/tell_them/20alt.IllTellThem.wav', 7 + SOUND 'dat/vocals/tell_them/20alt.IllTellThem_2.wav', 7 + SOUND 'dat/vocals/tell_them/20alt.IllTellThem_3.wav', 7 + SOUND 'dat/vocals/tell_them/20alt.IllTellThem_4.wav', 7 + SOUND 'dat/vocals/tell_them/20alt.IllTellThem_5.wav', 7 +END + +PLAYLIST 356, 'snd_ill_tell_them', 128, 0x04 + SETVOL 0,200,0 + PLAYGROUP 0, 'grp_ill_tell_them', 1 + END + + +PLAYLIST 357, 'snd_voc_open_the_case', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/open_the_case/voc_open_the_case.wav', 1 + END + +PLAYLIST 358, 'snd_voc_here_is_the_final_reveal', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/voc_here_is_the_final_reveal.wav', 1 + END + +; ... + +GROUP 'grp_low_values', 1 + SOUND 'dat/vocals/52.WeWantLowValues.wav', 1 + SOUND 'dat/vocals/54.LetsSeeSomeLowValues.wav', 1 +END + +PLAYLIST 359, 'snd_voc_here_is_the_final_reveal', 128, 0x04 + SETVOL 0,210,0 + PLAYGROUP 0, 'grp_low_values', 1 + END + +PLAYLIST 360, 'snd_you_win', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/28.YouWin.wav', 1 + END + +PLAYLIST 361, 'snd_game_over', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/32.GameOver.wav', 1 + END + +PLAYLIST 362, 'snd_are_you_ready', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/01.AreYouReadyToPlayDOND.wav', 1 + END + +PLAYLIST 363, 'snd_insert_money_to_cont', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/29alt.InsertMoneyToCont.wav', 1 + END + +PLAYLIST 364, 'snd_insert_money_to_cont', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/31.PressStartToPlay.wav', 1 + END + +PLAYLIST 365, 'snd_would_you_like_to_continue', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/29.WouldYouLikeToCont.wav', 1 + END + +GROUP 'grp_timeout', 1 + SOUND 'dat/vocals/timeout/49.MakeAChoice.wav', 3 + SOUND 'dat/vocals/timeout/51.HurryUpAndChoose.wav', 3 + SOUND 'dat/vocals/timeout/50.TimeIsRunningOut.wav', 3 + SOUND 'dat/vocals/timeout/51.HurryUpAndChoose_2.wav', 3 +END + +PLAYLIST 366, 'snd_hurry_up', 128, 0x04 + SETVOL 0,210,0 + PLAYGROUP 0, 'grp_timeout', 1 + END + +GROUP 'grp_thats_good', 1 + SOUND 'dat/vocals/good_open/56.Yes.wav', 8 + SOUND 'dat/vocals/good_open/58.ThatsGood.wav', 8 + SOUND 'dat/vocals/good_open/58.ThatsGood_2.wav', 8 + SOUND 'dat/vocals/good_open/59.YourDoingGreat_2.wav', 8 + SOUND 'dat/vocals/good_open/57.GreatChoice.wav', 8 + SOUND 'dat/vocals/good_open/55.ThatsAGoodOne.wav', 8 + SOUND 'dat/vocals/good_open/59.YourDoingGreat.wav', 8 + SOUND 'dat/vocals/good_open/53.ThatsGoodKeepItLow.wav', 8 + SOUND 'dat/vocals/good_open/53.ThatsGoodKeepItLow_2.wav', 8 +END + +PLAYLIST 367, 'snd_thats_good', 128, 0x04 + SETVOL 0,210,0 + PLAYGROUP 0, 'grp_thats_good', 1 + END + +PLAYLIST 368, 'snd_welcome_back', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/39.WelcomeBack.wav', 1 + END + +PLAYLIST 369, 'snd_whatyoudidntchoose', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/43.LetsSeeWhatYouDidntChoose.wav', 1 + END + +PLAYLIST 370, 'snd_ladies_open_cases', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/44.LadiesOpenTheCases.wav', 1 + END + +GROUP 'grp_great_game', 1 + SOUND 'dat/vocals/47.WowWhatAGreatGame_a.wav', 2 + SOUND 'dat/vocals/47.WowWhatAGreatGame_b.wav', 2 + SOUND 'dat/vocals/47.WowWhatAGreatGame_c.wav', 2 +END + +PLAYLIST 371, 'snd_great_game', 128, 0x04 + SETVOL 0,210,0 + PLAYGROUP 0, 'grp_great_game', 1 + END + +PLAYLIST 372, 'snd_yourcaseisworth', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/46.AndYourCaseIsWorth.wav', 1 + END + +PLAYLIST 373, 'snd_title_dealornodeal', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/voc_dealornodeal.wav', 1 + END + +PLAYLIST 374, 'snd_open_your_case', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/vocals/voc_now_letsopen.wav', 1 + END + +PLAYLIST 375, 'snd_stop_announcer', 128, 0x04 + SETVOL 0,210,0 + PLAY 0, 'dat/blank.wav', 1 + END + +; ... + +PLAYLIST 300, 'snd_voc_pcase', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/05.ChooseYourCase_d.wav', 1 + END + +PLAYLIST 301, 'snd_voc_pcase2', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/06.ThisWillBePersonalCase_c.wav', 1 + END + +PLAYLIST 302, 'snd_voc_5case', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/07.NowOpen5Cases_c.wav', 1 + END + +PLAYLIST 303, 'snd_voc_4case', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/08.NowOpen4Cases_c.wav', 1 + END + +PLAYLIST 304, 'snd_voc_3case', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/09.NowOpen3Cases_c.wav', 1 + END + +PLAYLIST 305, 'snd_voc_2case', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/10.NowOpen2Cases_d.wav', 1 + END + +PLAYLIST 306, 'snd_voc_1case', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/11.NowOpen1Case_d.wav', 1 + END + +; VOCALS - INDIVIDUAL NUMBERS + +PLAYLIST 310, 'snd_voc_num1', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/1.wav', 1 + END + +PLAYLIST 311, 'snd_voc_num2', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/2.wav', 1 + END + +PLAYLIST 312, 'snd_voc_num3', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/3.wav', 1 + END + +PLAYLIST 313, 'snd_voc_num4', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/4.wav', 1 + END + +PLAYLIST 314, 'snd_voc_num5', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/5.wav', 1 + END + +PLAYLIST 315, 'snd_voc_num6', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/6.wav', 1 + END + +PLAYLIST 316, 'snd_voc_num7', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/7.wav', 1 + END + +PLAYLIST 317, 'snd_voc_num8', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/8.wav', 1 + END + +PLAYLIST 318, 'snd_voc_num9', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/9.wav', 1 + END + +PLAYLIST 319, 'snd_voc_num10', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/10.wav', 1 + END + +PLAYLIST 320, 'snd_voc_num11', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/11.wav', 1 + END + +PLAYLIST 321, 'snd_voc_num12', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/12.wav', 1 + END + +PLAYLIST 322, 'snd_voc_num13', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/13.wav', 1 + END + +PLAYLIST 323, 'snd_voc_num14', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/14.wav', 1 + END + +PLAYLIST 324, 'snd_voc_num15', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/15.wav', 1 + END + +PLAYLIST 325, 'snd_voc_num16', 128, 0xfe + SETVOL 0,200,0 + PLAY 0, 'dat/vocals/16.wav', 1 + END + +; + +PLAYLIST 330, 'snd_voc_pcase01', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase1.wav', 1 + END + +PLAYLIST 331, 'snd_voc_pcase02', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase2.wav', 1 + END + +PLAYLIST 332, 'snd_voc_pcase03', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase3.wav', 1 + END + +PLAYLIST 333, 'snd_voc_pcase04', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase4.wav', 1 + END + +PLAYLIST 334, 'snd_voc_pcase05', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase5.wav', 1 + END + +PLAYLIST 335, 'snd_voc_pcase06', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase6.wav', 1 + END + +PLAYLIST 336, 'snd_voc_pcase07', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase7.wav', 1 + END + +PLAYLIST 337, 'snd_voc_pcase08', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase8.wav', 1 + END + +PLAYLIST 338, 'snd_voc_pcase09', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase9.wav', 1 + END + +PLAYLIST 339, 'snd_voc_pcase10', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase10.wav', 1 + END + +PLAYLIST 340, 'snd_voc_pcase11', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase11.wav', 1 + END + +PLAYLIST 341, 'snd_voc_pcase12', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase12.wav', 1 + END + +PLAYLIST 342, 'snd_voc_pcase13', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase13.wav', 1 + END + +PLAYLIST 343, 'snd_voc_pcase14', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase14.wav', 1 + END + +PLAYLIST 344, 'snd_voc_pcase15', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase15.wav', 1 + END + +PLAYLIST 345, 'snd_voc_pcase16', 128, 0xfe + SETVOL 0,220,0 + PLAY 0, 'dat/vocals/pcase/41alt.YouChoseCase16.wav', 1 + END + +; SOUND EFFECTS ------------------------------------------------------ + +PLAYLIST 4, 'snd_click', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/click.wav', 1 + END + + +PLAYLIST 5, 'snd_offer', 128, 0xf0 + SETVOL 0,210,0 + PLAY 0, 'dat/sfx/banker_offer.wav', 1 + END + + +PLAYLIST 6, 'snd_no_deal', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/no_deal.wav', 1 + END + + +PLAYLIST 7, 'snd_case_open_good', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/case_open_good.wav', 1 + END + + +PLAYLIST 8, 'snd_case_open_bad', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/case_open_bad.wav', 1 + END + + +PLAYLIST 9, 'snd_case_open_good_short', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/case_open_good_short.wav', 1 + END + + +PLAYLIST 10, 'snd_case_open_bad_short', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/case_open_bad_short.wav', 1 + END + + +PLAYLIST 11, 'snd_case_open_build', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/sfx/case_open_build.wav', 1 + END + + +PLAYLIST 12, 'snd_coin_in', 128, 0xf0 + SETVOL 0,180,0 + PLAY 0, 'dat/sfx/coin_in.wav', 1 + END + +PLAYLIST 13, 'snd_start_button', 128, 0xf0 + SETVOL 0,180,0 + PLAY 0, 'dat/sfx/start_button.wav', 1 + END + +PLAYLIST 14, 'snd_phone_ring', 128, 0xf0 + SETVOL 0,210,0 + PLAY 0, 'dat/banker/ELECTRONIC_PHONE_RING_02.wav', 1 + END + +PLAYLIST 15, 'snd_zoom_down', 128, 0xf0 + SETVOL 0,210,0 + PLAY 0, 'dat/sfx/zoom_down.wav', 1 + END + +PLAYLIST 16, 'snd_case_lock', 128, 0xf0 + SETVOL 0,210,0 + PLAY 0, 'dat/sfx/case_lock.wav', 1 + END + +PLAYLIST 17, 'snd_money_flip', 128, 0xf0 + SETVOL 0,210,0 + PLAY 0, 'dat/sfx/money_flip.wav', 1 + END + +PLAYLIST 99, 'snd_safetystop', 128, 0x01 + SETVOL 0,200,0 + PLAY 0, 'dat/blank.wav', 1 + END + +; CROWD NOISE -------------------------------------------------------- +; +; 200 - 209 : general crowd noise (neutral applause) +; 210 - 219 : super happy reactions +; 220 - 229 : happy reactions +; 230 - 239 : sad reactions +; 240 - 249 : deal/no deal mixed crowd yelling + +PLAYLIST 200, 'snd_crowd_med_applause', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/CrowdMedApplause01.wav', 1 + END + +PLAYLIST 201, 'snd_crowd_big_cheers', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/CrowdBigApplauseCheers01.wav', 1 + END + +; SUPER HAPPY REACTIONS ////////////////////////////////////////////// + +PLAYLIST 210, 'snd_crowd_shappy_1', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/shappy/CrowdWinBig01wApplause.wav', 1 + END + +PLAYLIST 211, 'snd_crowd_shappy_2', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/shappy/CrowdWinBig02wApplause.wav', 1 + END + +PLAYLIST 212, 'snd_crowd_shappy_3', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/shappy/CrowdWinBig03wApplause.wav', 1 + END + +; HAPPY REACTIONS //////////////////////////////////////////////////// + +PLAYLIST 220, 'snd_crowd_happy_1', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/happy/CrowdWinMed01wApplause.wav', 1 + END + +PLAYLIST 221, 'snd_crowd_happy_2', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/happy/CrowdWinMed02wApplause.wav', 1 + END + +PLAYLIST 222, 'snd_crowd_happy_3', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/happy/CrowdWinMed03wApplause.wav', 1 + END + +; SAD REACTIONS ////////////////////////////////////////////////////// + +PLAYLIST 230, 'snd_crowd_sad_1', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/sad/CrowdLoseAhh01.wav', 1 + END + +PLAYLIST 231, 'snd_crowd_sad_2', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/sad/CrowdLoseAhh02rev.wav', 1 + END + +PLAYLIST 232, 'snd_crowd_sad_3', 128, 0xf0 + SETVOL 0,200,0 + PLAY 0, 'dat/crowd/sad/CrowdLoseAhh03.wav', 1 + END + +; MIXED CROWD YELLING //////////////////////////////////////////////// + +GROUP 'snd_grp_crowd_mix', 1 + SOUND 'dat/crowd/CrowdMIXyell01wApplause.wav', 1 + SOUND 'dat/crowd/CrowdMIXyell02wApplause.wav', 1 +END + +PLAYLIST 240, 'snd_crowd_mix', 128, 0x02 + SETVOL 0,200,0 + PLAYGROUP 0, 'snd_grp_crowd_mix', 1 + END + +; .... + +GROUP 'snd_grp_crowd_deal', 1 + SOUND 'dat/crowd/CrowdDEALyell03wApplause.wav', 1 + SOUND 'dat/crowd/CrowdDEALyell04wApplause.wav', 1 +END + +PLAYLIST 241, 'snd_crowd_deal', 128, 0x02 + SETVOL 0,200,0 + PLAYGROUP 0, 'snd_grp_crowd_deal', 1 + END + +; .... + +GROUP 'snd_grp_crowd_nodeal', 1 + SOUND 'dat/crowd/CrowdNoDealYell01wApplause.wav', 1 + SOUND 'dat/crowd/CrowdNoDealYell02wApplause.wav', 1 +END + +PLAYLIST 242, 'snd_crowd_nodeal', 128, 0x02 + SETVOL 0,200,0 + PLAYGROUP 0, 'snd_grp_crowd_nodeal', 1 + END + +PLAYLIST 249, 'snd_crowd_mix_stop', 128, 0x02 + SETVOL 0,200,0 + PLAY 0, 'dat/blank.wav', 1 + END + +; INDIVIDUAL VOICES ////////////////////////////////////////////////// + +GROUP 'snd_grp_ind_deal', 1 + SOUND 'dat/vocals/ind_deal/IndMaleB_ISayDeal01.wav', 10 + SOUND 'dat/vocals/ind_deal/IndFemaleC_ISayDeal01.wav', 10 + SOUND 'dat/vocals/ind_deal/IndMaleB_Deal08.wav', 10 + SOUND 'dat/vocals/ind_deal/IndMaleC_YouGottaTakeIt04.wav', 10 + SOUND 'dat/vocals/ind_deal/IndMaleC_ISayDeal01.wav', 10 + SOUND 'dat/vocals/ind_deal/IndFemA_ISayDeal02.wav', 10 + SOUND 'dat/vocals/ind_deal/IndMaleB_TakeTheDeal01.wav', 10 + SOUND 'dat/vocals/ind_deal/IndFemB_TakeTheDeal02.wav', 10 + SOUND 'dat/vocals/ind_deal/IndFemB_ISayDeal02.wav', 10 + SOUND 'dat/vocals/ind_deal/IndFemaleC_ItsWhatYouWant01.wav', 10 + SOUND 'dat/vocals/ind_deal/IndMaleC_TakeTheDeal01.wav', 10 +END + +PLAYLIST 400, 'snd_ind_deal', 128, 0xf0 + SETVOL 0,190,0 + PLAYGROUP 0, 'snd_grp_ind_deal', 1 + END + +GROUP 'snd_grp_ind_nodeal', 1 + SOUND 'dat/vocals/ind_nodeal/IndFemA_GoForTheBigOne02.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndFemA_OneMoreOneMore02.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndFemaleC_NoWayNoDeal02.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndFemB_GoForIt01.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndFemB_NoDeal02.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndMaleA_NoWayNoDeal02.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndMaleA_WereNotReadyToGo03.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndMaleB_NoWay01.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndMaleB_NoWayNoDeal03.wav', 9 + SOUND 'dat/vocals/ind_nodeal/IndMaleC_KeepGoin01.wav', 9 +END + +PLAYLIST 401, 'snd_ind_nodeal', 128, 0xf0 + SETVOL 0,190,0 + PLAYGROUP 0, 'snd_grp_ind_nodeal', 1 + END + +; SOUND TEST ///////////////////////////////////////////////////////// + +PLAYLIST 500, 'snd_sine100', 128, 0x01 + SETVOL 0,255,0 + PLAY 0, 'dat/sine/sine100.wav', 0 + END + +PLAYLIST 501, 'snd_sine1k', 128, 0x01 + SETVOL 0,255,0 + PLAY 0, 'dat/sine/sine1k.wav', 0 + END diff --git a/donddata/snd/vssver.scc b/donddata/snd/vssver.scc new file mode 100644 index 0000000..6744e72 Binary files /dev/null and b/donddata/snd/vssver.scc differ diff --git a/go_nofs b/go_nofs new file mode 100755 index 0000000..73adb7a --- /dev/null +++ b/go_nofs @@ -0,0 +1,12 @@ +#!/bin/sh +echo "Running Deal or no Deal..." + +export __GL_SYNC_TO_VBLANK=0 +export __GL_SINGLE_THREADED=1 +export __GL_LOG_MAX_ANISO=0 +export __GL_FSAA_MODE=0 +printenv |grep GL + +./game -c +#ddd game -display 10.0.1.54:0.0 & + diff --git a/include/GL/glew.h b/include/GL/glew.h new file mode 100755 index 0000000..0bae8c1 --- /dev/null +++ b/include/GL/glew.h @@ -0,0 +1,10716 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2007, Milan Ikits +** Copyright (C) 2002-2007, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#ifndef __glew_h__ +#define __glew_h__ +#define __GLEW_H__ + +#if defined(__gl_h_) || defined(__GL_H__) +#error gl.h included before glew.h +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) +#error glext.h included before glew.h +#endif +#if defined(__gl_ATI_h_) +#error glATI.h included before glew.h +#endif + +#define __gl_h_ +#define __GL_H__ +#define __glext_h_ +#define __GLEXT_H_ +#define __gl_ATI_h_ + +#if defined(_WIN32) + +/* + * GLEW does not include to avoid name space pollution. + * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t + * defined properly. + */ +/* */ +#ifndef APIENTRY +#define GLEW_APIENTRY_DEFINED +# if defined(__MINGW32__) +# define APIENTRY __stdcall +# elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) +# define APIENTRY __stdcall +# else +# define APIENTRY +# endif +#endif +#ifndef GLAPI +# if defined(__MINGW32__) +# define GLAPI extern +# endif +#endif +/* */ +#ifndef CALLBACK +#define GLEW_CALLBACK_DEFINED +# if defined(__MINGW32__) +# define CALLBACK __attribute__ ((__stdcall__)) +# elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) +# define CALLBACK __stdcall +# else +# define CALLBACK +# endif +#endif +/* and */ +#ifndef WINGDIAPI +#define GLEW_WINGDIAPI_DEFINED +#define WINGDIAPI __declspec(dllimport) +#endif +/* */ +#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +#endif +/* */ +#if !defined(_W64) +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif +#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) +# ifdef _WIN64 +typedef __int64 ptrdiff_t; +# else +typedef _W64 int ptrdiff_t; +# endif +# define _PTRDIFF_T_DEFINED +# define _PTRDIFF_T_ +#endif + +#ifndef GLAPI +# if defined(__MINGW32__) +# define GLAPI extern +# else +# define GLAPI WINGDIAPI +# endif +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY APIENTRY +#endif + +/* + * GLEW_STATIC needs to be set when using the static version. + * GLEW_BUILD is set when building the DLL version. + */ +#ifdef GLEW_STATIC +# define GLEWAPI extern +#else +# ifdef GLEW_BUILD +# define GLEWAPI extern __declspec(dllexport) +# else +# define GLEWAPI extern __declspec(dllimport) +# endif +#endif + +#else /* _UNIX */ + +/* + * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO + * C. On my system, this amounts to _3 lines_ of included code, all of + * them pretty much harmless. If you know of a way of detecting 32 vs + * 64 _targets_ at compile time you are free to replace this with + * something that's portable. For now, _this_ is the portable solution. + * (mem, 2004-01-04) + */ + +#include + +#define GLEW_APIENTRY_DEFINED +#define APIENTRY +#define GLEWAPI extern + +/* */ +#ifndef GLAPI +#define GLAPI extern +#endif +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#endif /* _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 + +#if defined(__APPLE__) +typedef unsigned long GLenum; +typedef unsigned long GLbitfield; +typedef unsigned long GLuint; +typedef long GLint; +typedef long GLsizei; +#else +typedef unsigned int GLenum; +typedef unsigned int GLbitfield; +typedef unsigned int GLuint; +typedef int GLint; +typedef int GLsizei; +#endif +typedef unsigned char GLboolean; +typedef signed char GLbyte; +typedef short GLshort; +typedef unsigned char GLubyte; +typedef unsigned short GLushort; +typedef float GLfloat; +typedef float GLclampf; +typedef double GLdouble; +typedef double GLclampd; +typedef void GLvoid; +#if defined(_MSC_VER) && _MSC_VER < 1310 +# ifdef _WIN64 +typedef __int64 GLint64EXT; +typedef unsigned __int64 GLuint64EXT; +# else +typedef _W64 int GLint64EXT; +typedef _W64 unsigned int GLuint64EXT; +# endif +#else +typedef signed long long GLint64EXT; +typedef unsigned long long GLuint64EXT; +#endif + +#define GL_ACCUM 0x0100 +#define GL_LOAD 0x0101 +#define GL_RETURN 0x0102 +#define GL_MULT 0x0103 +#define GL_ADD 0x0104 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000fffff +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_TRUE 1 +#define GL_FALSE 0 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LIST_MODE 0x0B30 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_SHADE_MODEL 0x0B54 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_FOG 0x0B60 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_NORMALIZE 0x0BA1 +#define GL_VIEWPORT 0x0BA2 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_INDEX_MODE 0x0C30 +#define GL_RGBA_MODE 0x0C31 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_RENDER_MODE 0x0C40 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_INDEX_BITS 0x0D51 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_COLOR_INDEX 0x1900 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_BITMAP 0x1A00 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_RENDER 0x1C00 +#define GL_FEEDBACK 0x1C01 +#define GL_SELECT 0x1C02 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_ENV 0x2300 +#define GL_EYE_LINEAR 0x2400 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_SPHERE_MAP 0x2402 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_PLANE 0x2502 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_CLAMP 0x2900 +#define GL_REPEAT 0x2901 +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D +#define GL_LOGIC_OP GL_INDEX_LOGIC_OP +#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 + +GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); +GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); +GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void GLAPIENTRY glArrayElement (GLint i); +GLAPI void GLAPIENTRY glBegin (GLenum mode); +GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); +GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GLAPI void GLAPIENTRY glCallList (GLuint list); +GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); +GLAPI void GLAPIENTRY glClear (GLbitfield mask); +GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); +GLAPI void GLAPIENTRY glClearIndex (GLfloat c); +GLAPI void GLAPIENTRY glClearStencil (GLint s); +GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); +GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); +GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); +GLAPI void GLAPIENTRY glColor3iv (const GLint *v); +GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); +GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); +GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); +GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); +GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); +GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void GLAPIENTRY glColor4iv (const GLint *v); +GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); +GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); +GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); +GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); +GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); +GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); +GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); +GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void GLAPIENTRY glCullFace (GLenum mode); +GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); +GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GLAPI void GLAPIENTRY glDepthFunc (GLenum func); +GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); +GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); +GLAPI void GLAPIENTRY glDisable (GLenum cap); +GLAPI void GLAPIENTRY glDisableClientState (GLenum array); +GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); +GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); +GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); +GLAPI void GLAPIENTRY glEnable (GLenum cap); +GLAPI void GLAPIENTRY glEnableClientState (GLenum array); +GLAPI void GLAPIENTRY glEnd (void); +GLAPI void GLAPIENTRY glEndList (void); +GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); +GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); +GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); +GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); +GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); +GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); +GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); +GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); +GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); +GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); +GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); +GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); +GLAPI void GLAPIENTRY glFinish (void); +GLAPI void GLAPIENTRY glFlush (void); +GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glFrontFace (GLenum mode); +GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); +GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); +GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); +GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); +GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); +GLAPI GLenum GLAPIENTRY glGetError (void); +GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); +GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); +GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); +GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); +GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); +GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); +GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params); +GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); +GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); +GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); +GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); +GLAPI void GLAPIENTRY glIndexMask (GLuint mask); +GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glIndexd (GLdouble c); +GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); +GLAPI void GLAPIENTRY glIndexf (GLfloat c); +GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); +GLAPI void GLAPIENTRY glIndexi (GLint c); +GLAPI void GLAPIENTRY glIndexiv (const GLint *c); +GLAPI void GLAPIENTRY glIndexs (GLshort c); +GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); +GLAPI void GLAPIENTRY glIndexub (GLubyte c); +GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); +GLAPI void GLAPIENTRY glInitNames (void); +GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); +GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); +GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); +GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); +GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); +GLAPI void GLAPIENTRY glLineWidth (GLfloat width); +GLAPI void GLAPIENTRY glListBase (GLuint base); +GLAPI void GLAPIENTRY glLoadIdentity (void); +GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); +GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); +GLAPI void GLAPIENTRY glLoadName (GLuint name); +GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); +GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); +GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); +GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); +GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); +GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); +GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); +GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); +GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); +GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); +GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); +GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); +GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void GLAPIENTRY glPassThrough (GLfloat token); +GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); +GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); +GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); +GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); +GLAPI void GLAPIENTRY glPointSize (GLfloat size); +GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); +GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); +GLAPI void GLAPIENTRY glPopAttrib (void); +GLAPI void GLAPIENTRY glPopClientAttrib (void); +GLAPI void GLAPIENTRY glPopMatrix (void); +GLAPI void GLAPIENTRY glPopName (void); +GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); +GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); +GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); +GLAPI void GLAPIENTRY glPushMatrix (void); +GLAPI void GLAPIENTRY glPushName (GLuint name); +GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); +GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); +GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); +GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); +GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); +GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); +GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); +GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); +GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); +GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); +GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); +GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); +GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); +GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); +GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); +GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); +GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); +GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); +GLAPI void GLAPIENTRY glShadeModel (GLenum mode); +GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GLAPI void GLAPIENTRY glStencilMask (GLuint mask); +GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); +GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); +GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord1i (GLint s); +GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); +GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); +GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); +GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); +GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); +GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); +GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); +GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); +GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); +GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); +GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); +GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) + +#endif /* GL_VERSION_1_1 */ + +/* ---------------------------------- GLU ---------------------------------- */ + +/* this is where we can safely include GLU */ +#if defined(__APPLE__) && defined(__MACH__) +#include +#else +#include +#endif + +/* ----------------------------- GL_VERSION_1_2 ---------------------------- */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 + +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E + +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + +#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) +#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) +#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) +#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) + +#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) + +#endif /* GL_VERSION_1_2 */ + +/* ----------------------------- GL_VERSION_1_3 ---------------------------- */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 + +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_SUBTRACT 0x84E7 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#define GL_MULTISAMPLE_BIT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); + +#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) +#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) +#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) +#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) +#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) +#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) +#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) +#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) +#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) +#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) +#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) +#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) +#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) +#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) +#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) +#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) +#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) +#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) +#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) +#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) +#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) +#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) +#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) +#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) +#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) +#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) +#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) +#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) +#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) +#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) +#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) +#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) +#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) +#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) +#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) +#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) +#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) +#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) +#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) +#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) +#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) +#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) +#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) +#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) +#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) +#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) + +#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) + +#endif /* GL_VERSION_1_3 */ + +/* ----------------------------- GL_VERSION_1_4 ---------------------------- */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 + +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E + +typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); + +#define glBlendColor GLEW_GET_FUN(__glewBlendColor) +#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) +#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) +#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) +#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) +#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) +#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) +#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) +#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) +#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) +#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) +#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) +#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) +#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) +#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) +#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) +#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) +#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) +#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) +#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) +#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) +#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) +#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) +#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) +#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) +#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) +#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) +#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) +#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) +#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) +#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) +#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) +#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) +#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) +#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) +#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) +#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) +#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) +#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) +#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) +#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) +#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) +#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) +#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) +#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) + +#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) + +#endif /* GL_VERSION_1_4 */ + +/* ----------------------------- GL_VERSION_1_5 ---------------------------- */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 + +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 + +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); +typedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); + +#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) +#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) +#define glBufferData GLEW_GET_FUN(__glewBufferData) +#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) +#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) +#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) +#define glEndQuery GLEW_GET_FUN(__glewEndQuery) +#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) +#define glGenQueries GLEW_GET_FUN(__glewGenQueries) +#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) +#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) +#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) +#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) +#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) +#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) +#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) +#define glIsQuery GLEW_GET_FUN(__glewIsQuery) +#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) +#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) + +#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) + +#endif /* GL_VERSION_1_5 */ + +/* ----------------------------- GL_VERSION_2_0 ---------------------------- */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 + +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 + +typedef char GLchar; + +typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); +typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); +typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); +typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); +typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); +typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); +typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); +typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); +typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); + +#define glAttachShader GLEW_GET_FUN(__glewAttachShader) +#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) +#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) +#define glCompileShader GLEW_GET_FUN(__glewCompileShader) +#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) +#define glCreateShader GLEW_GET_FUN(__glewCreateShader) +#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) +#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) +#define glDetachShader GLEW_GET_FUN(__glewDetachShader) +#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) +#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) +#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) +#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) +#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) +#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) +#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) +#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) +#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) +#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) +#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) +#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) +#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) +#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) +#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) +#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) +#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) +#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) +#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) +#define glIsProgram GLEW_GET_FUN(__glewIsProgram) +#define glIsShader GLEW_GET_FUN(__glewIsShader) +#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) +#define glShaderSource GLEW_GET_FUN(__glewShaderSource) +#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) +#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) +#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) +#define glUniform1f GLEW_GET_FUN(__glewUniform1f) +#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) +#define glUniform1i GLEW_GET_FUN(__glewUniform1i) +#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) +#define glUniform2f GLEW_GET_FUN(__glewUniform2f) +#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) +#define glUniform2i GLEW_GET_FUN(__glewUniform2i) +#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) +#define glUniform3f GLEW_GET_FUN(__glewUniform3f) +#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) +#define glUniform3i GLEW_GET_FUN(__glewUniform3i) +#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) +#define glUniform4f GLEW_GET_FUN(__glewUniform4f) +#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) +#define glUniform4i GLEW_GET_FUN(__glewUniform4i) +#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) +#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) +#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) +#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) +#define glUseProgram GLEW_GET_FUN(__glewUseProgram) +#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) +#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) +#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) +#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) +#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) +#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) +#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) +#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) +#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) +#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) +#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) +#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) +#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) +#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) +#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) +#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) +#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) +#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) +#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) +#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) +#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) +#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) +#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) +#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) +#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) +#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) +#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) +#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) +#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) +#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) +#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) +#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) +#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) +#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) +#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) +#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) +#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) +#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) + +#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) + +#endif /* GL_VERSION_2_0 */ + +/* ----------------------------- GL_VERSION_2_1 ---------------------------- */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 + +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B + +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + +#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) +#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) +#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) +#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) +#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) +#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) + +#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) + +#endif /* GL_VERSION_2_1 */ + +/* -------------------------- GL_3DFX_multisample -------------------------- */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 + +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 + +#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) + +#endif /* GL_3DFX_multisample */ + +/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 + +typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); + +#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) + +#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) + +#endif /* GL_3DFX_tbuffer */ + +/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 + +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 + +#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) + +#endif /* GL_3DFX_texture_compression_FXT1 */ + +/* ------------------------ GL_APPLE_client_storage ------------------------ */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 + +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 + +#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) + +#endif /* GL_APPLE_client_storage */ + +/* ------------------------- GL_APPLE_element_array ------------------------ */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 + +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A + +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); + +#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) +#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) +#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) +#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) +#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) + +#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) + +#endif /* GL_APPLE_element_array */ + +/* ----------------------------- GL_APPLE_fence ---------------------------- */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 + +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B + +typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); +typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); +typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); + +#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) +#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) +#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) +#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) +#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) +#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) +#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) +#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) + +#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) + +#endif /* GL_APPLE_fence */ + +/* ------------------------- GL_APPLE_float_pixels ------------------------- */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 + +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F + +#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) + +#endif /* GL_APPLE_float_pixels */ + +/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ + +#ifndef GL_APPLE_pixel_buffer +#define GL_APPLE_pixel_buffer 1 + +#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 + +#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) + +#endif /* GL_APPLE_pixel_buffer */ + +/* ------------------------ GL_APPLE_specular_vector ----------------------- */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 + +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 + +#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) + +#endif /* GL_APPLE_specular_vector */ + +/* ------------------------- GL_APPLE_texture_range ------------------------ */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 + +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); +typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer); + +#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) +#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) + +#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) + +#endif /* GL_APPLE_texture_range */ + +/* ------------------------ GL_APPLE_transform_hint ------------------------ */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 + +#define GL_TRANSFORM_HINT_APPLE 0x85B1 + +#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) + +#endif /* GL_APPLE_transform_hint */ + +/* ---------------------- GL_APPLE_vertex_array_object --------------------- */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 + +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 + +typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); +typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); +typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); + +#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) +#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) +#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) +#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) + +#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) + +#endif /* GL_APPLE_vertex_array_object */ + +/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 + +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + +typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); + +#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) +#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) +#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) + +#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) + +#endif /* GL_APPLE_vertex_array_range */ + +/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 + +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB + +#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) + +#endif /* GL_APPLE_ycbcr_422 */ + +/* ----------------------- GL_ARB_color_buffer_float ----------------------- */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 + +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D + +typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); + +#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) + +#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) + +#endif /* GL_ARB_color_buffer_float */ + +/* -------------------------- GL_ARB_depth_texture ------------------------- */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B + +#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) + +#endif /* GL_ARB_depth_texture */ + +/* -------------------------- GL_ARB_draw_buffers -------------------------- */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 + +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 + +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); + +#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) + +#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) + +#endif /* GL_ARB_draw_buffers */ + +/* ------------------------ GL_ARB_fragment_program ------------------------ */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 + +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 + +#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) + +#endif /* GL_ARB_fragment_program */ + +/* --------------------- GL_ARB_fragment_program_shadow -------------------- */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 + +#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) + +#endif /* GL_ARB_fragment_program_shadow */ + +/* ------------------------- GL_ARB_fragment_shader ------------------------ */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 + +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B + +#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) + +#endif /* GL_ARB_fragment_shader */ + +/* ------------------------ GL_ARB_half_float_pixel ------------------------ */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 + +#define GL_HALF_FLOAT_ARB 0x140B + +#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) + +#endif /* GL_ARB_half_float_pixel */ + +/* ----------------------------- GL_ARB_imaging ---------------------------- */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_IGNORE_BORDER 0x8150 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_WRAP_BORDER 0x8152 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 + +typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + +#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) +#define glColorTable GLEW_GET_FUN(__glewColorTable) +#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) +#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) +#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) +#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) +#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) +#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) +#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) +#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) +#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) +#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) +#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) +#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) +#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) +#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) +#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) +#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) +#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) +#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) +#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) +#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) +#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) +#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) +#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) +#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) +#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) +#define glHistogram GLEW_GET_FUN(__glewHistogram) +#define glMinmax GLEW_GET_FUN(__glewMinmax) +#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) +#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) +#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) + +#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) + +#endif /* GL_ARB_imaging */ + +/* ------------------------- GL_ARB_matrix_palette ------------------------- */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 + +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 + +typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); + +#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) +#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) +#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) +#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) +#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) + +#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) + +#endif /* GL_ARB_matrix_palette */ + +/* --------------------------- GL_ARB_multisample -------------------------- */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 + +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); + +#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) + +#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) + +#endif /* GL_ARB_multisample */ + +/* -------------------------- GL_ARB_multitexture -------------------------- */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) +#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) +#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) +#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) +#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) +#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) +#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) +#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) +#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) +#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) +#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) +#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) +#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) +#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) +#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) +#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) +#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) +#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) +#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) +#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) +#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) +#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) +#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) +#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) +#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) +#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) +#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) +#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) +#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) +#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) +#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) +#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) +#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) +#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) + +#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) + +#endif /* GL_ARB_multitexture */ + +/* ------------------------- GL_ARB_occlusion_query ------------------------ */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 + +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); + +#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) +#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) +#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) +#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) +#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) +#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) +#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) +#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) + +#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) + +#endif /* GL_ARB_occlusion_query */ + +/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 + +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF + +#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) + +#endif /* GL_ARB_pixel_buffer_object */ + +/* ------------------------ GL_ARB_point_parameters ------------------------ */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 + +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, GLfloat* params); + +#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) +#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) + +#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) + +#endif /* GL_ARB_point_parameters */ + +/* -------------------------- GL_ARB_point_sprite -------------------------- */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 + +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 + +#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) + +#endif /* GL_ARB_point_sprite */ + +/* ------------------------- GL_ARB_shader_objects ------------------------- */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 + +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 + +typedef char GLcharARB; +typedef unsigned int GLhandleARB; + +typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); +typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); +typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); +typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); + +#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) +#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) +#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) +#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) +#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) +#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) +#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) +#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) +#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) +#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) +#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) +#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) +#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) +#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) +#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) +#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) +#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) +#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) +#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) +#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) +#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) +#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) +#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) +#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) +#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) +#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) +#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) +#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) +#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) +#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) +#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) +#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) +#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) +#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) +#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) +#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) +#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) +#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) +#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) + +#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) + +#endif /* GL_ARB_shader_objects */ + +/* ---------------------- GL_ARB_shading_language_100 ---------------------- */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 + +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C + +#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) + +#endif /* GL_ARB_shading_language_100 */ + +/* ----------------------------- GL_ARB_shadow ----------------------------- */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 + +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E + +#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) + +#endif /* GL_ARB_shadow */ + +/* ------------------------- GL_ARB_shadow_ambient ------------------------- */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 + +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF + +#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) + +#endif /* GL_ARB_shadow_ambient */ + +/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_ARB 0x812D + +#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) + +#endif /* GL_ARB_texture_border_clamp */ + +/* ----------------------- GL_ARB_texture_compression ---------------------- */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 + +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 + +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img); + +#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) +#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) +#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) +#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) +#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) +#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) +#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) + +#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) + +#endif /* GL_ARB_texture_compression */ + +/* ------------------------ GL_ARB_texture_cube_map ------------------------ */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 + +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C + +#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) + +#endif /* GL_ARB_texture_cube_map */ + +/* ------------------------- GL_ARB_texture_env_add ------------------------ */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 + +#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) + +#endif /* GL_ARB_texture_env_add */ + +/* ----------------------- GL_ARB_texture_env_combine ---------------------- */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 + +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A + +#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) + +#endif /* GL_ARB_texture_env_combine */ + +/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 + +#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) + +#endif /* GL_ARB_texture_env_crossbar */ + +/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 + +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF + +#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) + +#endif /* GL_ARB_texture_env_dot3 */ + +/* -------------------------- GL_ARB_texture_float ------------------------- */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 + +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 + +#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) + +#endif /* GL_ARB_texture_float */ + +/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_ARB 0x8370 + +#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) + +#endif /* GL_ARB_texture_mirrored_repeat */ + +/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 + +#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) + +#endif /* GL_ARB_texture_non_power_of_two */ + +/* ------------------------ GL_ARB_texture_rectangle ----------------------- */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 + +#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) + +#endif /* GL_ARB_texture_rectangle */ + +/* ------------------------ GL_ARB_transpose_matrix ------------------------ */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 + +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 + +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); + +#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) +#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) +#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) +#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) + +#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) + +#endif /* GL_ARB_transpose_matrix */ + +/* -------------------------- GL_ARB_vertex_blend -------------------------- */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 + +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F + +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); +typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); + +#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) +#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) +#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) +#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) +#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) +#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) +#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) +#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) +#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) +#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) + +#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) + +#endif /* GL_ARB_vertex_blend */ + +/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 + +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA + +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; + +typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage); +typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data); +typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); + +#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) +#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) +#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) +#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) +#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) +#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) +#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) +#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) +#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) +#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) +#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) + +#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) + +#endif /* GL_ARB_vertex_buffer_object */ + +/* ------------------------- GL_ARB_vertex_program ------------------------- */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 + +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF + +typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); +typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); + +#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) +#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) +#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) +#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) +#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) +#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) +#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) +#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) +#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) +#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) +#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) +#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) +#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) +#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) +#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) +#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) +#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) +#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) +#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) +#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) +#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) +#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) +#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) +#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) +#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) +#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) +#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) +#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) +#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) +#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) +#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) +#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) +#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) +#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) +#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) +#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) +#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) +#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) +#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) +#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) +#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) +#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) +#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) +#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) +#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) +#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) +#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) +#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) +#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) +#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) +#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) +#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) +#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) +#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) +#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) +#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) +#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) +#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) +#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) +#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) +#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) +#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) + +#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) + +#endif /* GL_ARB_vertex_program */ + +/* -------------------------- GL_ARB_vertex_shader ------------------------- */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 + +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A + +typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); +typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); + +#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) +#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) +#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) + +#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) + +#endif /* GL_ARB_vertex_shader */ + +/* --------------------------- GL_ARB_window_pos --------------------------- */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 + +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); + +#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) +#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) +#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) +#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) +#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) +#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) +#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) +#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) +#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) +#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) +#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) +#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) +#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) +#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) +#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) +#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) + +#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) + +#endif /* GL_ARB_window_pos */ + +/* ------------------------- GL_ATIX_point_sprites ------------------------- */ + +#ifndef GL_ATIX_point_sprites +#define GL_ATIX_point_sprites 1 + +#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 +#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 +#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 +#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 +#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 +#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 + +#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) + +#endif /* GL_ATIX_point_sprites */ + +/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ + +#ifndef GL_ATIX_texture_env_combine3 +#define GL_ATIX_texture_env_combine3 1 + +#define GL_MODULATE_ADD_ATIX 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 +#define GL_MODULATE_SUBTRACT_ATIX 0x8746 + +#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) + +#endif /* GL_ATIX_texture_env_combine3 */ + +/* ----------------------- GL_ATIX_texture_env_route ----------------------- */ + +#ifndef GL_ATIX_texture_env_route +#define GL_ATIX_texture_env_route 1 + +#define GL_SECONDARY_COLOR_ATIX 0x8747 +#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 +#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 + +#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) + +#endif /* GL_ATIX_texture_env_route */ + +/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ + +#ifndef GL_ATIX_vertex_shader_output_point_size +#define GL_ATIX_vertex_shader_output_point_size 1 + +#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E + +#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) + +#endif /* GL_ATIX_vertex_shader_output_point_size */ + +/* -------------------------- GL_ATI_draw_buffers -------------------------- */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 + +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 + +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); + +#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) + +#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) + +#endif /* GL_ATI_draw_buffers */ + +/* -------------------------- GL_ATI_element_array ------------------------- */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 + +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A + +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer); + +#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) +#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) +#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) + +#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) + +#endif /* GL_ATI_element_array */ + +/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 + +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C + +typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); + +#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) +#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) +#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) +#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) + +#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) + +#endif /* GL_ATI_envmap_bumpmap */ + +/* ------------------------- GL_ATI_fragment_shader ------------------------ */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 + +#define GL_RED_BIT_ATI 0x00000001 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B + +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); + +#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) +#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) +#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) +#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) +#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) +#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) +#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) +#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) +#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) +#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) +#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) +#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) +#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) +#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) + +#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) + +#endif /* GL_ATI_fragment_shader */ + +/* ------------------------ GL_ATI_map_object_buffer ----------------------- */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 + +typedef void* (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); + +#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) +#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) + +#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) + +#endif /* GL_ATI_map_object_buffer */ + +/* -------------------------- GL_ATI_pn_triangles -------------------------- */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 + +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 + +typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); + +#define glPNTrianglesfATI GLEW_GET_FUN(__glPNTrianglewesfATI) +#define glPNTrianglesiATI GLEW_GET_FUN(__glPNTrianglewesiATI) + +#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) + +#endif /* GL_ATI_pn_triangles */ + +/* ------------------------ GL_ATI_separate_stencil ------------------------ */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 + +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 + +typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + +#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) +#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) + +#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) + +#endif /* GL_ATI_separate_stencil */ + +/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ + +#ifndef GL_ATI_shader_texture_lod +#define GL_ATI_shader_texture_lod 1 + +#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) + +#endif /* GL_ATI_shader_texture_lod */ + +/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 + +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 + +#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) + +#endif /* GL_ATI_text_fragment_shader */ + +/* --------------------- GL_ATI_texture_compression_3dc -------------------- */ + +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 + +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 + +#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) + +#endif /* GL_ATI_texture_compression_3dc */ + +/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 + +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 + +#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) + +#endif /* GL_ATI_texture_env_combine3 */ + +/* -------------------------- GL_ATI_texture_float ------------------------- */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 + +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F + +#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) + +#endif /* GL_ATI_texture_float */ + +/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 + +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 + +#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) + +#endif /* GL_ATI_texture_mirror_once */ + +/* ----------------------- GL_ATI_vertex_array_object ---------------------- */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 + +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 + +typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage); +typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve); +typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + +#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) +#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) +#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) +#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) +#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) +#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) +#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) +#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) +#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) +#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) +#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) +#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) + +#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) + +#endif /* GL_ATI_vertex_array_object */ + +/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 + +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); + +#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) +#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) +#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) + +#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) + +#endif /* GL_ATI_vertex_attrib_array_object */ + +/* ------------------------- GL_ATI_vertex_streams ------------------------- */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 + +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_SOURCE_ATI 0x876C +#define GL_VERTEX_STREAM0_ATI 0x876D +#define GL_VERTEX_STREAM1_ATI 0x876E +#define GL_VERTEX_STREAM2_ATI 0x876F +#define GL_VERTEX_STREAM3_ATI 0x8770 +#define GL_VERTEX_STREAM4_ATI 0x8771 +#define GL_VERTEX_STREAM5_ATI 0x8772 +#define GL_VERTEX_STREAM6_ATI 0x8773 +#define GL_VERTEX_STREAM7_ATI 0x8774 + +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *v); + +#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) +#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) +#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) +#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) +#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) +#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) +#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) +#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) +#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) +#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) +#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) +#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) +#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) +#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) +#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) +#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) +#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) +#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) +#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) +#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) +#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) +#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) +#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) +#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) +#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) +#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) +#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) +#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) +#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) +#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) +#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) +#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) +#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) +#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) +#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) +#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) +#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) + +#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) + +#endif /* GL_ATI_vertex_streams */ + +/* --------------------------- GL_EXT_422_pixels --------------------------- */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 + +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF + +#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) + +#endif /* GL_EXT_422_pixels */ + +/* ---------------------------- GL_EXT_Cg_shader --------------------------- */ + +#ifndef GL_EXT_Cg_shader +#define GL_EXT_Cg_shader 1 + +#define GL_CG_VERTEX_SHADER_EXT 0x890E +#define GL_CG_FRAGMENT_SHADER_EXT 0x890F + +#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) + +#endif /* GL_EXT_Cg_shader */ + +/* ------------------------------ GL_EXT_abgr ------------------------------ */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 + +#define GL_ABGR_EXT 0x8000 + +#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) + +#endif /* GL_EXT_abgr */ + +/* ------------------------------ GL_EXT_bgra ------------------------------ */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 + +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 + +#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) + +#endif /* GL_EXT_bgra */ + +/* ------------------------ GL_EXT_bindable_uniform ------------------------ */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 + +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF + +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); + +#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) +#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) +#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) + +#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) + +#endif /* GL_EXT_bindable_uniform */ + +/* --------------------------- GL_EXT_blend_color -------------------------- */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 + +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 + +typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + +#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) + +#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) + +#endif /* GL_EXT_blend_color */ + +/* --------------------- GL_EXT_blend_equation_separate -------------------- */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 + +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); + +#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) + +#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) + +#endif /* GL_EXT_blend_equation_separate */ + +/* ----------------------- GL_EXT_blend_func_separate ---------------------- */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 + +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB + +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + +#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) + +#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) + +#endif /* GL_EXT_blend_func_separate */ + +/* ------------------------- GL_EXT_blend_logic_op ------------------------- */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 + +#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) + +#endif /* GL_EXT_blend_logic_op */ + +/* -------------------------- GL_EXT_blend_minmax -------------------------- */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 + +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); + +#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) + +#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) + +#endif /* GL_EXT_blend_minmax */ + +/* ------------------------- GL_EXT_blend_subtract ------------------------- */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 + +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B + +#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) + +#endif /* GL_EXT_blend_subtract */ + +/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 + +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 + +#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) + +#endif /* GL_EXT_clip_volume_hint */ + +/* ------------------------------ GL_EXT_cmyka ----------------------------- */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 + +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F + +#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) + +#endif /* GL_EXT_cmyka */ + +/* ------------------------- GL_EXT_color_subtable ------------------------- */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 + +typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + +#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) +#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) + +#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) + +#endif /* GL_EXT_color_subtable */ + +/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 + +typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); + +#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) +#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) + +#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) + +#endif /* GL_EXT_compiled_vertex_array */ + +/* --------------------------- GL_EXT_convolution -------------------------- */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 + +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 + +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span); +typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column); + +#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) +#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) +#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) +#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) +#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) +#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) +#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) +#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) +#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) +#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) +#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) +#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) +#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) + +#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) + +#endif /* GL_EXT_convolution */ + +/* ------------------------ GL_EXT_coordinate_frame ------------------------ */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 + +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 + +typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); +typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); + +#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) +#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) + +#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) + +#endif /* GL_EXT_coordinate_frame */ + +/* -------------------------- GL_EXT_copy_texture -------------------------- */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 + +typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + +#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) +#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) +#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) +#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) +#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) + +#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) + +#endif /* GL_EXT_copy_texture */ + +/* --------------------------- GL_EXT_cull_vertex -------------------------- */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 + +typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); + +#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) +#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) + +#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) + +#endif /* GL_EXT_cull_vertex */ + +/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 + +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 + +typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); + +#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) + +#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) + +#endif /* GL_EXT_depth_bounds_test */ + +/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 + +typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); + +#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) +#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) +#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) +#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) +#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) +#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) + +#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) + +#endif /* GL_EXT_draw_buffers2 */ + +/* ------------------------- GL_EXT_draw_instanced ------------------------- */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 + +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); + +#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) +#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) + +#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) + +#endif /* GL_EXT_draw_instanced */ + +/* ----------------------- GL_EXT_draw_range_elements ---------------------- */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 + +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 + +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) + +#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) + +#endif /* GL_EXT_draw_range_elements */ + +/* ---------------------------- GL_EXT_fog_coord --------------------------- */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 + +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 + +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); + +#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) +#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) +#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) +#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) +#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) + +#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) + +#endif /* GL_EXT_fog_coord */ + +/* ------------------------ GL_EXT_fragment_lighting ----------------------- */ + +#ifndef GL_EXT_fragment_lighting +#define GL_EXT_fragment_lighting 1 + +#define GL_FRAGMENT_LIGHTING_EXT 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 +#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 +#define GL_LIGHT_ENV_MODE_EXT 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B +#define GL_FRAGMENT_LIGHT0_EXT 0x840C +#define GL_FRAGMENT_LIGHT7_EXT 0x8413 + +typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); + +#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) +#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) +#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) +#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) +#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) +#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) +#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) +#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) +#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) +#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) +#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) +#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) +#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) +#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) +#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) +#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) +#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) +#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) + +#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) + +#endif /* GL_EXT_fragment_lighting */ + +/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 + +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA + +typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + +#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) + +#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) + +#endif /* GL_EXT_framebuffer_blit */ + +/* --------------------- GL_EXT_framebuffer_multisample -------------------- */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 + +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 + +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + +#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) + +#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) + +#endif /* GL_EXT_framebuffer_multisample */ + +/* ----------------------- GL_EXT_framebuffer_object ----------------------- */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 + +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 + +typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); +typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); +typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); +typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + +#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) +#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) +#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) +#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) +#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) +#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) +#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) +#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) +#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) +#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) +#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) +#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) +#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) +#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) +#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) +#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) +#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) + +#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) + +#endif /* GL_EXT_framebuffer_object */ + +/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 + +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA + +#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) + +#endif /* GL_EXT_framebuffer_sRGB */ + +/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 + +#define GL_LINES_ADJACENCY_EXT 0xA +#define GL_LINE_STRIP_ADJACENCY_EXT 0xB +#define GL_TRIANGLES_ADJACENCY_EXT 0xC +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 + +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); + +#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) +#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) +#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) +#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) + +#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) + +#endif /* GL_EXT_geometry_shader4 */ + +/* --------------------- GL_EXT_gpu_program_parameters --------------------- */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 + +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); + +#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) +#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) + +#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) + +#endif /* GL_EXT_gpu_program_parameters */ + +/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 + +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 + +typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); + +#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) +#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) +#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) +#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) +#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) +#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) +#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) +#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) +#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) +#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) +#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) +#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) +#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) +#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) +#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) +#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) +#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) +#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) +#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) +#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) +#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) +#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) +#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) +#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) +#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) +#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) +#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) +#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) +#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) +#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) +#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) +#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) +#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) +#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) + +#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) + +#endif /* GL_EXT_gpu_shader4 */ + +/* ---------------------------- GL_EXT_histogram --------------------------- */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 + +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 + +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); + +#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) +#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) +#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) +#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) +#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) +#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) +#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) +#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) +#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) +#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) + +#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) + +#endif /* GL_EXT_histogram */ + +/* ----------------------- GL_EXT_index_array_formats ---------------------- */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 + +#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) + +#endif /* GL_EXT_index_array_formats */ + +/* --------------------------- GL_EXT_index_func --------------------------- */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 + +typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); + +#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) + +#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) + +#endif /* GL_EXT_index_func */ + +/* ------------------------- GL_EXT_index_material ------------------------- */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 + +typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); + +#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) + +#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) + +#endif /* GL_EXT_index_material */ + +/* -------------------------- GL_EXT_index_texture ------------------------- */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 + +#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) + +#endif /* GL_EXT_index_texture */ + +/* -------------------------- GL_EXT_light_texture ------------------------- */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 + +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 + +typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); + +#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) +#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) +#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) + +#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) + +#endif /* GL_EXT_light_texture */ + +/* ------------------------- GL_EXT_misc_attribute ------------------------- */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 + +#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) + +#endif /* GL_EXT_misc_attribute */ + +/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 + +typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint* first, GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount); + +#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) +#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) + +#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) + +#endif /* GL_EXT_multi_draw_arrays */ + +/* --------------------------- GL_EXT_multisample -------------------------- */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 + +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); + +#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) +#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) + +#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) + +#endif /* GL_EXT_multisample */ + +/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 + +#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) + +#endif /* GL_EXT_packed_depth_stencil */ + +/* -------------------------- GL_EXT_packed_float -------------------------- */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 + +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C + +#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) + +#endif /* GL_EXT_packed_float */ + +/* -------------------------- GL_EXT_packed_pixels ------------------------- */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 + +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 + +#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) + +#endif /* GL_EXT_packed_pixels */ + +/* ------------------------ GL_EXT_paletted_texture ------------------------ */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 + +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 +#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B + +typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); + +#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) +#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) +#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) +#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) + +#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) + +#endif /* GL_EXT_paletted_texture */ + +/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 + +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF + +#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) + +#endif /* GL_EXT_pixel_buffer_object */ + +/* ------------------------- GL_EXT_pixel_transform ------------------------ */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 + +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 + +typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) +#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) +#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) +#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) +#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) +#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) + +#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) + +#endif /* GL_EXT_pixel_transform */ + +/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 + +#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) + +#endif /* GL_EXT_pixel_transform_color_table */ + +/* ------------------------ GL_EXT_point_parameters ------------------------ */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 + +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); + +#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) +#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) + +#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) + +#endif /* GL_EXT_point_parameters */ + +/* ------------------------- GL_EXT_polygon_offset ------------------------- */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 + +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 + +typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); + +#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) + +#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) + +#endif /* GL_EXT_polygon_offset */ + +/* ------------------------- GL_EXT_rescale_normal ------------------------- */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 + +#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) + +#endif /* GL_EXT_rescale_normal */ + +/* -------------------------- GL_EXT_scene_marker -------------------------- */ + +#ifndef GL_EXT_scene_marker +#define GL_EXT_scene_marker 1 + +typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); + +#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) +#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) + +#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) + +#endif /* GL_EXT_scene_marker */ + +/* ------------------------- GL_EXT_secondary_color ------------------------ */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 + +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E + +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); + +#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) +#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) +#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) +#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) +#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) +#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) +#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) +#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) +#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) +#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) +#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) +#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) +#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) +#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) +#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) +#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) +#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) + +#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) + +#endif /* GL_EXT_secondary_color */ + +/* --------------------- GL_EXT_separate_specular_color -------------------- */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 + +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA + +#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) + +#endif /* GL_EXT_separate_specular_color */ + +/* -------------------------- GL_EXT_shadow_funcs -------------------------- */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 + +#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) + +#endif /* GL_EXT_shadow_funcs */ + +/* --------------------- GL_EXT_shared_texture_palette --------------------- */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 + +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB + +#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) + +#endif /* GL_EXT_shared_texture_palette */ + +/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 + +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 + +#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) + +#endif /* GL_EXT_stencil_clear_tag */ + +/* ------------------------ GL_EXT_stencil_two_side ------------------------ */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 + +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 + +typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); + +#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) + +#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) + +#endif /* GL_EXT_stencil_two_side */ + +/* -------------------------- GL_EXT_stencil_wrap -------------------------- */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 + +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 + +#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) + +#endif /* GL_EXT_stencil_wrap */ + +/* --------------------------- GL_EXT_subtexture --------------------------- */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 + +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); + +#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) +#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) +#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) + +#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) + +#endif /* GL_EXT_subtexture */ + +/* ----------------------------- GL_EXT_texture ---------------------------- */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 + +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 + +#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) + +#endif /* GL_EXT_texture */ + +/* ---------------------------- GL_EXT_texture3D --------------------------- */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 + +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 + +typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); + +#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) + +#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) + +#endif /* GL_EXT_texture3D */ + +/* -------------------------- GL_EXT_texture_array ------------------------- */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 + +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D + +#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) + +#endif /* GL_EXT_texture_array */ + +/* ---------------------- GL_EXT_texture_buffer_object --------------------- */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 + +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E + +typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); + +#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) + +#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) + +#endif /* GL_EXT_texture_buffer_object */ + +/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ + +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 + +#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) + +#endif /* GL_EXT_texture_compression_dxt1 */ + +/* -------------------- GL_EXT_texture_compression_latc -------------------- */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 + +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 + +#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) + +#endif /* GL_EXT_texture_compression_latc */ + +/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 + +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE + +#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) + +#endif /* GL_EXT_texture_compression_rgtc */ + +/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 + +#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) + +#endif /* GL_EXT_texture_compression_s3tc */ + +/* ------------------------ GL_EXT_texture_cube_map ------------------------ */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 + +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C + +#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) + +#endif /* GL_EXT_texture_cube_map */ + +/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ + +#ifndef GL_EXT_texture_edge_clamp +#define GL_EXT_texture_edge_clamp 1 + +#define GL_CLAMP_TO_EDGE_EXT 0x812F + +#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) + +#endif /* GL_EXT_texture_edge_clamp */ + +/* --------------------------- GL_EXT_texture_env -------------------------- */ + +#ifndef GL_EXT_texture_env +#define GL_EXT_texture_env 1 + +#define GL_TEXTURE_ENV0_EXT 0 +#define GL_ENV_BLEND_EXT 0 +#define GL_TEXTURE_ENV_SHIFT_EXT 0 +#define GL_ENV_REPLACE_EXT 0 +#define GL_ENV_ADD_EXT 0 +#define GL_ENV_SUBTRACT_EXT 0 +#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0 +#define GL_ENV_REVERSE_SUBTRACT_EXT 0 +#define GL_ENV_REVERSE_BLEND_EXT 0 +#define GL_ENV_COPY_EXT 0 +#define GL_ENV_MODULATE_EXT 0 + +#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) + +#endif /* GL_EXT_texture_env */ + +/* ------------------------- GL_EXT_texture_env_add ------------------------ */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 + +#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) + +#endif /* GL_EXT_texture_env_add */ + +/* ----------------------- GL_EXT_texture_env_combine ---------------------- */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 + +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A + +#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) + +#endif /* GL_EXT_texture_env_combine */ + +/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 + +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 + +#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) + +#endif /* GL_EXT_texture_env_dot3 */ + +/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 + +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + +#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) + +#endif /* GL_EXT_texture_filter_anisotropic */ + +/* ------------------------- GL_EXT_texture_integer ------------------------ */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 + +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E + +typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); + +#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) +#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) +#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) +#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) +#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) +#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) + +#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) + +#endif /* GL_EXT_texture_integer */ + +/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 + +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 + +#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) + +#endif /* GL_EXT_texture_lod_bias */ + +/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 + +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 + +#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) + +#endif /* GL_EXT_texture_mirror_clamp */ + +/* ------------------------- GL_EXT_texture_object ------------------------- */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 + +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A + +typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); +typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); +typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); +typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); + +#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) +#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) +#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) +#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) +#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) +#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) + +#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) + +#endif /* GL_EXT_texture_object */ + +/* --------------------- GL_EXT_texture_perturb_normal --------------------- */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 + +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF + +typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); + +#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) + +#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) + +#endif /* GL_EXT_texture_perturb_normal */ + +/* ------------------------ GL_EXT_texture_rectangle ----------------------- */ + +#ifndef GL_EXT_texture_rectangle +#define GL_EXT_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 + +#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) + +#endif /* GL_EXT_texture_rectangle */ + +/* -------------------------- GL_EXT_texture_sRGB -------------------------- */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 + +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F + +#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) + +#endif /* GL_EXT_texture_sRGB */ + +/* --------------------- GL_EXT_texture_shared_exponent -------------------- */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 + +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F + +#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) + +#endif /* GL_EXT_texture_shared_exponent */ + +/* --------------------------- GL_EXT_timer_query -------------------------- */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 + +#define GL_TIME_ELAPSED_EXT 0x88BF + +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); + +#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) +#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) + +#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) + +#endif /* GL_EXT_timer_query */ + +/* -------------------------- GL_EXT_vertex_array -------------------------- */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 + +#define GL_DOUBLE_EXT 0x140A +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 + +typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); +typedef void (GLAPIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, void** params); +typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); + +#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) +#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) +#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) +#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) +#define glGetPointervEXT GLEW_GET_FUN(__glewGetPointervEXT) +#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) +#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) +#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) +#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) + +#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) + +#endif /* GL_EXT_vertex_array */ + +/* -------------------------- GL_EXT_vertex_shader ------------------------- */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 + +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED + +typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); +typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); +typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); +typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + +#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) +#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) +#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) +#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) +#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) +#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) +#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) +#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) +#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) +#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) +#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) +#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) +#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) +#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) +#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) +#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) +#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) +#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) +#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) +#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) +#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) +#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) +#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) +#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) +#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) +#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) +#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) +#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) +#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) +#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) +#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) +#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) +#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) +#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) +#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) +#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) +#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) +#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) +#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) +#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) +#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) +#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) + +#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) + +#endif /* GL_EXT_vertex_shader */ + +/* ------------------------ GL_EXT_vertex_weighting ------------------------ */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 + +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 + +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); + +#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) +#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) +#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) + +#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) + +#endif /* GL_EXT_vertex_weighting */ + +/* ------------------------ GL_GREMEDY_string_marker ----------------------- */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 + +typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string); + +#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) + +#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) + +#endif /* GL_GREMEDY_string_marker */ + +/* --------------------- GL_HP_convolution_border_modes -------------------- */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 + +#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) + +#endif /* GL_HP_convolution_border_modes */ + +/* ------------------------- GL_HP_image_transform ------------------------- */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 + +typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) +#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) +#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) +#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) +#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) +#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) + +#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) + +#endif /* GL_HP_image_transform */ + +/* -------------------------- GL_HP_occlusion_test ------------------------- */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 + +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 + +#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) + +#endif /* GL_HP_occlusion_test */ + +/* ------------------------- GL_HP_texture_lighting ------------------------ */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 + +#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) + +#endif /* GL_HP_texture_lighting */ + +/* --------------------------- GL_IBM_cull_vertex -------------------------- */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 + +#define GL_CULL_VERTEX_IBM 103050 + +#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) + +#endif /* GL_IBM_cull_vertex */ + +/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 + +typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride); + +#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) +#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) + +#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) + +#endif /* GL_IBM_multimode_draw_arrays */ + +/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 + +#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 + +#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) + +#endif /* GL_IBM_rasterpos_clip */ + +/* --------------------------- GL_IBM_static_data -------------------------- */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 + +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 + +#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) + +#endif /* GL_IBM_static_data */ + +/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_IBM 0x8370 + +#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) + +#endif /* GL_IBM_texture_mirrored_repeat */ + +/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 + +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 + +typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); + +#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) +#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) +#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) +#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) +#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) +#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) +#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) +#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) + +#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) + +#endif /* GL_IBM_vertex_array_lists */ + +/* -------------------------- GL_INGR_color_clamp -------------------------- */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 + +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 + +#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) + +#endif /* GL_INGR_color_clamp */ + +/* ------------------------- GL_INGR_interlace_read ------------------------ */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 + +#define GL_INTERLACE_READ_INGR 0x8568 + +#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) + +#endif /* GL_INGR_interlace_read */ + +/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 + +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 + +typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); + +#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) +#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) +#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) +#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) + +#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) + +#endif /* GL_INTEL_parallel_arrays */ + +/* ------------------------ GL_INTEL_texture_scissor ----------------------- */ + +#ifndef GL_INTEL_texture_scissor +#define GL_INTEL_texture_scissor 1 + +typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); +typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); + +#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) +#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) + +#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) + +#endif /* GL_INTEL_texture_scissor */ + +/* -------------------------- GL_KTX_buffer_region ------------------------- */ + +#ifndef GL_KTX_buffer_region +#define GL_KTX_buffer_region 1 + +#define GL_KTX_FRONT_REGION 0x0 +#define GL_KTX_BACK_REGION 0x1 +#define GL_KTX_Z_REGION 0x2 +#define GL_KTX_STENCIL_REGION 0x3 + +typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDEXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONEXTPROC) (GLenum region); +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); +typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONEXTPROC) (GLenum region); +typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); + +#define glBufferRegionEnabledEXT GLEW_GET_FUN(__glewBufferRegionEnabledEXT) +#define glDeleteBufferRegionEXT GLEW_GET_FUN(__glewDeleteBufferRegionEXT) +#define glDrawBufferRegionEXT GLEW_GET_FUN(__glewDrawBufferRegionEXT) +#define glNewBufferRegionEXT GLEW_GET_FUN(__glewNewBufferRegionEXT) +#define glReadBufferRegionEXT GLEW_GET_FUN(__glewReadBufferRegionEXT) + +#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) + +#endif /* GL_KTX_buffer_region */ + +/* ------------------------- GL_MESAX_texture_stack ------------------------ */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 + +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E + +#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) + +#endif /* GL_MESAX_texture_stack */ + +/* -------------------------- GL_MESA_pack_invert -------------------------- */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 + +#define GL_PACK_INVERT_MESA 0x8758 + +#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) + +#endif /* GL_MESA_pack_invert */ + +/* ------------------------- GL_MESA_resize_buffers ------------------------ */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 + +typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); + +#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) + +#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) + +#endif /* GL_MESA_resize_buffers */ + +/* --------------------------- GL_MESA_window_pos -------------------------- */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 + +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); + +#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) +#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) +#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) +#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) +#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) +#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) +#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) +#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) +#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) +#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) +#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) +#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) +#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) +#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) +#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) +#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) +#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) +#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) +#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) +#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) +#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) +#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) +#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) +#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) + +#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) + +#endif /* GL_MESA_window_pos */ + +/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 + +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 + +#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) + +#endif /* GL_MESA_ycbcr_texture */ + +/* --------------------------- GL_NV_blend_square -------------------------- */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 + +#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) + +#endif /* GL_NV_blend_square */ + +/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 + +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F + +#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) + +#endif /* GL_NV_copy_depth_to_color */ + +/* ------------------------ GL_NV_depth_buffer_float ----------------------- */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 + +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF + +typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); + +#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) +#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) +#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) + +#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) + +#endif /* GL_NV_depth_buffer_float */ + +/* --------------------------- GL_NV_depth_clamp --------------------------- */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 + +#define GL_DEPTH_CLAMP_NV 0x864F + +#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) + +#endif /* GL_NV_depth_clamp */ + +/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ + +#ifndef GL_NV_depth_range_unclamped +#define GL_NV_depth_range_unclamped 1 + +#define GL_SAMPLE_COUNT_BITS_NV 0x8864 +#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 +#define GL_QUERY_RESULT_NV 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 +#define GL_SAMPLE_COUNT_NV 0x8914 + +#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) + +#endif /* GL_NV_depth_range_unclamped */ + +/* ---------------------------- GL_NV_evaluators --------------------------- */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 + +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 + +typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points); +typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points); +typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) +#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) +#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) +#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) +#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) +#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) +#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) +#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) +#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) + +#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) + +#endif /* GL_NV_evaluators */ + +/* ------------------------------ GL_NV_fence ------------------------------ */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 + +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 + +typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); +typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); +typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); + +#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) +#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) +#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) +#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) +#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) +#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) +#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) + +#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) + +#endif /* GL_NV_fence */ + +/* --------------------------- GL_NV_float_buffer -------------------------- */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 + +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E + +#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) + +#endif /* GL_NV_float_buffer */ + +/* --------------------------- GL_NV_fog_distance -------------------------- */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 + +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C + +#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) + +#endif /* GL_NV_fog_distance */ + +/* ------------------------- GL_NV_fragment_program ------------------------ */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 + +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 + +typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); + +#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) +#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) +#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) +#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) +#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) +#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) + +#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) + +#endif /* GL_NV_fragment_program */ + +/* ------------------------ GL_NV_fragment_program2 ------------------------ */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 + +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 + +#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) + +#endif /* GL_NV_fragment_program2 */ + +/* ------------------------ GL_NV_fragment_program4 ------------------------ */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 + +#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) + +#endif /* GL_NV_fragment_program4 */ + +/* --------------------- GL_NV_fragment_program_option --------------------- */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 + +#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) + +#endif /* GL_NV_fragment_program_option */ + +/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 + +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 + +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + +#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) + +#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) + +#endif /* GL_NV_framebuffer_multisample_coverage */ + +/* ------------------------ GL_NV_geometry_program4 ------------------------ */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 + +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 + +typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); + +#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) + +#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) + +#endif /* GL_NV_geometry_program4 */ + +/* ------------------------- GL_NV_geometry_shader4 ------------------------ */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 + +#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) + +#endif /* GL_NV_geometry_shader4 */ + +/* --------------------------- GL_NV_gpu_program4 -------------------------- */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 + +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 + +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); + +#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) +#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) +#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) +#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) +#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) +#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) +#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) +#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) +#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) +#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) +#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) +#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) + +#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) + +#endif /* GL_NV_gpu_program4 */ + +/* ---------------------------- GL_NV_half_float --------------------------- */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 + +#define GL_HALF_FLOAT_NV 0x140B + +typedef unsigned short GLhalf; + +typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); +typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); +typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); +typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); +typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); +typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); +typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); +typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); +typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); +typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); + +#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) +#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) +#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) +#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) +#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) +#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) +#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) +#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) +#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) +#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) +#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) +#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) +#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) +#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) +#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) +#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) +#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) +#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) +#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) +#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) +#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) +#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) +#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) +#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) +#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) +#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) +#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) +#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) +#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) +#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) +#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) +#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) +#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) +#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) +#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) +#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) +#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) +#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) +#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) +#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) +#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) +#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) +#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) +#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) +#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) +#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) + +#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) + +#endif /* GL_NV_half_float */ + +/* ------------------------ GL_NV_light_max_exponent ----------------------- */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 + +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 + +#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) + +#endif /* GL_NV_light_max_exponent */ + +/* --------------------- GL_NV_multisample_filter_hint --------------------- */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 + +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 + +#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) + +#endif /* GL_NV_multisample_filter_hint */ + +/* ------------------------- GL_NV_occlusion_query ------------------------- */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 + +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 + +typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); + +#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) +#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) +#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) +#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) +#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) +#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) +#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) + +#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) + +#endif /* GL_NV_occlusion_query */ + +/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA + +#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) + +#endif /* GL_NV_packed_depth_stencil */ + +/* --------------------- GL_NV_parameter_buffer_object --------------------- */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 + +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 + +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); + +#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) +#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) +#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) + +#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) + +#endif /* GL_NV_parameter_buffer_object */ + +/* ------------------------- GL_NV_pixel_data_range ------------------------ */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 + +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D + +typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer); + +#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) +#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) + +#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) + +#endif /* GL_NV_pixel_data_range */ + +/* --------------------------- GL_NV_point_sprite -------------------------- */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 + +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); + +#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) +#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) + +#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) + +#endif /* GL_NV_point_sprite */ + +/* ------------------------ GL_NV_primitive_restart ------------------------ */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 + +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 + +typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); + +#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) +#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) + +#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) + +#endif /* GL_NV_primitive_restart */ + +/* ------------------------ GL_NV_register_combiners ----------------------- */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 + +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 + +typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); + +#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) +#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) +#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) +#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) +#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) +#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) +#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) +#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) +#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) +#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) +#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) +#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) +#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) + +#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) + +#endif /* GL_NV_register_combiners */ + +/* ----------------------- GL_NV_register_combiners2 ----------------------- */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 + +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 + +typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); + +#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) +#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) + +#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) + +#endif /* GL_NV_register_combiners2 */ + +/* -------------------------- GL_NV_texgen_emboss -------------------------- */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 + +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F + +#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) + +#endif /* GL_NV_texgen_emboss */ + +/* ------------------------ GL_NV_texgen_reflection ------------------------ */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 + +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 + +#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) + +#endif /* GL_NV_texgen_reflection */ + +/* --------------------- GL_NV_texture_compression_vtc --------------------- */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 + +#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) + +#endif /* GL_NV_texture_compression_vtc */ + +/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 + +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B + +#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) + +#endif /* GL_NV_texture_env_combine4 */ + +/* ---------------------- GL_NV_texture_expand_normal ---------------------- */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 + +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F + +#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) + +#endif /* GL_NV_texture_expand_normal */ + +/* ------------------------ GL_NV_texture_rectangle ------------------------ */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 + +#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) + +#endif /* GL_NV_texture_rectangle */ + +/* -------------------------- GL_NV_texture_shader ------------------------- */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 + +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F + +#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) + +#endif /* GL_NV_texture_shader */ + +/* ------------------------- GL_NV_texture_shader2 ------------------------- */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 + +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D + +#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) + +#endif /* GL_NV_texture_shader2 */ + +/* ------------------------- GL_NV_texture_shader3 ------------------------- */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 + +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 + +#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) + +#endif /* GL_NV_texture_shader3 */ + +/* ------------------------ GL_NV_transform_feedback ----------------------- */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 + +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F + +typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); + +#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) +#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) +#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) +#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) +#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) +#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) +#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) +#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) +#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) +#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) +#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) + +#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) + +#endif /* GL_NV_transform_feedback */ + +/* ------------------------ GL_NV_vertex_array_range ----------------------- */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 + +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 + +typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer); + +#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) +#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) + +#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) + +#endif /* GL_NV_vertex_array_range */ + +/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 + +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 + +#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) + +#endif /* GL_NV_vertex_array_range2 */ + +/* -------------------------- GL_NV_vertex_program ------------------------- */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 + +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F + +typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); +typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint num, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint num, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); + +#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) +#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) +#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) +#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) +#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) +#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) +#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) +#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) +#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) +#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) +#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) +#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) +#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) +#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) +#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) +#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) +#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) +#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) +#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) +#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) +#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) +#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) +#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) +#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) +#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) +#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) +#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) +#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) +#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) +#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) +#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) +#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) +#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) +#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) +#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) +#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) +#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) +#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) +#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) +#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) +#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) +#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) +#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) +#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) +#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) +#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) +#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) +#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) +#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) +#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) +#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) +#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) +#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) +#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) +#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) +#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) +#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) +#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) +#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) +#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) +#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) +#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) +#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) +#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) + +#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) + +#endif /* GL_NV_vertex_program */ + +/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 + +#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) + +#endif /* GL_NV_vertex_program1_1 */ + +/* ------------------------- GL_NV_vertex_program2 ------------------------- */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 + +#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) + +#endif /* GL_NV_vertex_program2 */ + +/* ---------------------- GL_NV_vertex_program2_option --------------------- */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 + +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 + +#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) + +#endif /* GL_NV_vertex_program2_option */ + +/* ------------------------- GL_NV_vertex_program3 ------------------------- */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 + +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C + +#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) + +#endif /* GL_NV_vertex_program3 */ + +/* ------------------------- GL_NV_vertex_program4 ------------------------- */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 + +#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) + +#endif /* GL_NV_vertex_program4 */ + +/* ------------------------ GL_OES_byte_coordinates ------------------------ */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 + +#define GL_BYTE 0x1400 + +#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) + +#endif /* GL_OES_byte_coordinates */ + +/* ------------------- GL_OES_compressed_paletted_texture ------------------ */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 + +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 + +#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) + +#endif /* GL_OES_compressed_paletted_texture */ + +/* --------------------------- GL_OES_read_format -------------------------- */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 + +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B + +#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) + +#endif /* GL_OES_read_format */ + +/* ------------------------ GL_OES_single_precision ------------------------ */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 + +typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth); +typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); +typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); +typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); + +#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) +#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) +#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) +#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) +#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) +#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) + +#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) + +#endif /* GL_OES_single_precision */ + +/* ---------------------------- GL_OML_interlace --------------------------- */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 + +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 + +#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) + +#endif /* GL_OML_interlace */ + +/* ---------------------------- GL_OML_resample ---------------------------- */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 + +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 + +#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) + +#endif /* GL_OML_resample */ + +/* ---------------------------- GL_OML_subsample --------------------------- */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 + +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 + +#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) + +#endif /* GL_OML_subsample */ + +/* --------------------------- GL_PGI_misc_hints --------------------------- */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 + +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 +#define GL_CONSERVE_MEMORY_HINT_PGI 107005 +#define GL_RECLAIM_MEMORY_HINT_PGI 107006 +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 +#define GL_ALWAYS_FAST_HINT_PGI 107020 +#define GL_ALWAYS_SOFT_HINT_PGI 107021 +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 +#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 +#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 +#define GL_STRICT_LIGHTING_HINT_PGI 107031 +#define GL_STRICT_SCISSOR_HINT_PGI 107032 +#define GL_FULL_STIPPLE_HINT_PGI 107033 +#define GL_CLIP_NEAR_HINT_PGI 107040 +#define GL_CLIP_FAR_HINT_PGI 107041 +#define GL_WIDE_LINE_HINT_PGI 107042 +#define GL_BACK_NORMALS_HINT_PGI 107043 + +#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) + +#endif /* GL_PGI_misc_hints */ + +/* -------------------------- GL_PGI_vertex_hints -------------------------- */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 + +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_VERTEX_DATA_HINT_PGI 107050 +#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 +#define GL_MATERIAL_SIDE_HINT_PGI 107052 +#define GL_MAX_VERTEX_HINT_PGI 107053 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 + +#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) + +#endif /* GL_PGI_vertex_hints */ + +/* ----------------------- GL_REND_screen_coordinates ---------------------- */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 + +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 + +#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) + +#endif /* GL_REND_screen_coordinates */ + +/* ------------------------------- GL_S3_s3tc ------------------------------ */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 + +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 + +#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) + +#endif /* GL_S3_s3tc */ + +/* -------------------------- GL_SGIS_color_range -------------------------- */ + +#ifndef GL_SGIS_color_range +#define GL_SGIS_color_range 1 + +#define GL_EXTENDED_RANGE_SGIS 0x85A5 +#define GL_MIN_RED_SGIS 0x85A6 +#define GL_MAX_RED_SGIS 0x85A7 +#define GL_MIN_GREEN_SGIS 0x85A8 +#define GL_MAX_GREEN_SGIS 0x85A9 +#define GL_MIN_BLUE_SGIS 0x85AA +#define GL_MAX_BLUE_SGIS 0x85AB +#define GL_MIN_ALPHA_SGIS 0x85AC +#define GL_MAX_ALPHA_SGIS 0x85AD + +#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) + +#endif /* GL_SGIS_color_range */ + +/* ------------------------- GL_SGIS_detail_texture ------------------------ */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 + +typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); +typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); + +#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) +#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) + +#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) + +#endif /* GL_SGIS_detail_texture */ + +/* -------------------------- GL_SGIS_fog_function ------------------------- */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 + +typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); +typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); + +#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) +#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) + +#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) + +#endif /* GL_SGIS_fog_function */ + +/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 + +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 + +#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) + +#endif /* GL_SGIS_generate_mipmap */ + +/* -------------------------- GL_SGIS_multisample -------------------------- */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 + +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); + +#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) +#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) + +#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) + +#endif /* GL_SGIS_multisample */ + +/* ------------------------- GL_SGIS_pixel_texture ------------------------- */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 + +#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) + +#endif /* GL_SGIS_pixel_texture */ + +/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 + +typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); +typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); + +#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) +#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) + +#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) + +#endif /* GL_SGIS_sharpen_texture */ + +/* --------------------------- GL_SGIS_texture4D --------------------------- */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 + +typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels); + +#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) +#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) + +#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) + +#endif /* GL_SGIS_texture4D */ + +/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_SGIS 0x812D + +#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) + +#endif /* GL_SGIS_texture_border_clamp */ + +/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 + +#define GL_CLAMP_TO_EDGE_SGIS 0x812F + +#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) + +#endif /* GL_SGIS_texture_edge_clamp */ + +/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 + +typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); +typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); + +#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) +#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) + +#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) + +#endif /* GL_SGIS_texture_filter4 */ + +/* -------------------------- GL_SGIS_texture_lod -------------------------- */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 + +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D + +#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) + +#endif /* GL_SGIS_texture_lod */ + +/* ------------------------- GL_SGIS_texture_select ------------------------ */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 + +#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) + +#endif /* GL_SGIS_texture_select */ + +/* ----------------------------- GL_SGIX_async ----------------------------- */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 + +#define GL_ASYNC_MARKER_SGIX 0x8329 + +typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); +typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); + +#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) +#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) +#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) +#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) +#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) +#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) + +#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) + +#endif /* GL_SGIX_async */ + +/* ------------------------ GL_SGIX_async_histogram ------------------------ */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 + +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D + +#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) + +#endif /* GL_SGIX_async_histogram */ + +/* -------------------------- GL_SGIX_async_pixel -------------------------- */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 + +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 + +#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) + +#endif /* GL_SGIX_async_pixel */ + +/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 + +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 + +#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) + +#endif /* GL_SGIX_blend_alpha_minmax */ + +/* ---------------------------- GL_SGIX_clipmap ---------------------------- */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 + +#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) + +#endif /* GL_SGIX_clipmap */ + +/* ------------------------- GL_SGIX_depth_texture ------------------------- */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 + +#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) + +#endif /* GL_SGIX_depth_texture */ + +/* -------------------------- GL_SGIX_flush_raster ------------------------- */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 + +typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); + +#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) + +#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) + +#endif /* GL_SGIX_flush_raster */ + +/* --------------------------- GL_SGIX_fog_offset -------------------------- */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 + +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 + +#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) + +#endif /* GL_SGIX_fog_offset */ + +/* -------------------------- GL_SGIX_fog_texture -------------------------- */ + +#ifndef GL_SGIX_fog_texture +#define GL_SGIX_fog_texture 1 + +#define GL_TEXTURE_FOG_SGIX 0 +#define GL_FOG_PATCHY_FACTOR_SGIX 0 +#define GL_FRAGMENT_FOG_SGIX 0 + +typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); + +#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) + +#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) + +#endif /* GL_SGIX_fog_texture */ + +/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ + +#ifndef GL_SGIX_fragment_specular_lighting +#define GL_SGIX_fragment_specular_lighting 1 + +typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); + +#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) +#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) +#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) +#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) +#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) +#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) +#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) +#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) +#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) +#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) +#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) +#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) +#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) +#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) +#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) +#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) +#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) + +#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) + +#endif /* GL_SGIX_fragment_specular_lighting */ + +/* --------------------------- GL_SGIX_framezoom --------------------------- */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 + +typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); + +#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) + +#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) + +#endif /* GL_SGIX_framezoom */ + +/* --------------------------- GL_SGIX_interlace --------------------------- */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 + +#define GL_INTERLACE_SGIX 0x8094 + +#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) + +#endif /* GL_SGIX_interlace */ + +/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 + +#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) + +#endif /* GL_SGIX_ir_instrument1 */ + +/* ------------------------- GL_SGIX_list_priority ------------------------- */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 + +#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) + +#endif /* GL_SGIX_list_priority */ + +/* ------------------------- GL_SGIX_pixel_texture ------------------------- */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 + +typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); + +#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) + +#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) + +#endif /* GL_SGIX_pixel_texture */ + +/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ + +#ifndef GL_SGIX_pixel_texture_bits +#define GL_SGIX_pixel_texture_bits 1 + +#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) + +#endif /* GL_SGIX_pixel_texture_bits */ + +/* ------------------------ GL_SGIX_reference_plane ------------------------ */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 + +typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); + +#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) + +#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) + +#endif /* GL_SGIX_reference_plane */ + +/* ---------------------------- GL_SGIX_resample --------------------------- */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 + +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 + +#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) + +#endif /* GL_SGIX_resample */ + +/* ----------------------------- GL_SGIX_shadow ---------------------------- */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 + +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D + +#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) + +#endif /* GL_SGIX_shadow */ + +/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 + +#define GL_SHADOW_AMBIENT_SGIX 0x80BF + +#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) + +#endif /* GL_SGIX_shadow_ambient */ + +/* ----------------------------- GL_SGIX_sprite ---------------------------- */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 + +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); + +#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) +#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) +#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) +#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) + +#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) + +#endif /* GL_SGIX_sprite */ + +/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 + +typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); + +#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) + +#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) + +#endif /* GL_SGIX_tag_sample_buffer */ + +/* ------------------------ GL_SGIX_texture_add_env ------------------------ */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 + +#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) + +#endif /* GL_SGIX_texture_add_env */ + +/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 + +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B + +#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) + +#endif /* GL_SGIX_texture_coordinate_clamp */ + +/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 + +#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) + +#endif /* GL_SGIX_texture_lod_bias */ + +/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 + +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E + +#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) + +#endif /* GL_SGIX_texture_multi_buffer */ + +/* ------------------------- GL_SGIX_texture_range ------------------------- */ + +#ifndef GL_SGIX_texture_range +#define GL_SGIX_texture_range 1 + +#define GL_RGB_SIGNED_SGIX 0x85E0 +#define GL_RGBA_SIGNED_SGIX 0x85E1 +#define GL_ALPHA_SIGNED_SGIX 0x85E2 +#define GL_LUMINANCE_SIGNED_SGIX 0x85E3 +#define GL_INTENSITY_SIGNED_SGIX 0x85E4 +#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 +#define GL_RGB16_SIGNED_SGIX 0x85E6 +#define GL_RGBA16_SIGNED_SGIX 0x85E7 +#define GL_ALPHA16_SIGNED_SGIX 0x85E8 +#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 +#define GL_INTENSITY16_SIGNED_SGIX 0x85EA +#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB +#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC +#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED +#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE +#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF +#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 +#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 +#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 +#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 +#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 +#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 +#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 +#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 +#define GL_MIN_LUMINANCE_SGIS 0x85F8 +#define GL_MAX_LUMINANCE_SGIS 0x85F9 +#define GL_MIN_INTENSITY_SGIS 0x85FA +#define GL_MAX_INTENSITY_SGIS 0x85FB + +#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) + +#endif /* GL_SGIX_texture_range */ + +/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 + +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C + +#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) + +#endif /* GL_SGIX_texture_scale_bias */ + +/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) + +#endif /* GL_SGIX_vertex_preclip */ + +/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ + +#ifndef GL_SGIX_vertex_preclip_hint +#define GL_SGIX_vertex_preclip_hint 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) + +#endif /* GL_SGIX_vertex_preclip_hint */ + +/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 + +#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) + +#endif /* GL_SGIX_ycrcb */ + +/* -------------------------- GL_SGI_color_matrix -------------------------- */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 + +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB + +#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) + +#endif /* GL_SGI_color_matrix */ + +/* --------------------------- GL_SGI_color_table -------------------------- */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 + +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF + +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table); + +#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) +#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) +#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) +#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) +#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) +#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) +#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) + +#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) + +#endif /* GL_SGI_color_table */ + +/* ----------------------- GL_SGI_texture_color_table ---------------------- */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 + +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD + +#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) + +#endif /* GL_SGI_texture_color_table */ + +/* ------------------------- GL_SUNX_constant_data ------------------------- */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 + +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 + +typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); + +#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) + +#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) + +#endif /* GL_SUNX_constant_data */ + +/* -------------------- GL_SUN_convolution_border_modes -------------------- */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 + +#define GL_WRAP_BORDER_SUN 0x81D4 + +#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) + +#endif /* GL_SUN_convolution_border_modes */ + +/* -------------------------- GL_SUN_global_alpha -------------------------- */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 + +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA + +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); + +#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) +#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) +#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) +#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) +#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) +#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) +#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) +#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) + +#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) + +#endif /* GL_SUN_global_alpha */ + +/* --------------------------- GL_SUN_mesh_array --------------------------- */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 + +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 + +#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) + +#endif /* GL_SUN_mesh_array */ + +/* ------------------------ GL_SUN_read_video_pixels ----------------------- */ + +#ifndef GL_SUN_read_video_pixels +#define GL_SUN_read_video_pixels 1 + +typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); + +#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) + +#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) + +#endif /* GL_SUN_read_video_pixels */ + +/* --------------------------- GL_SUN_slice_accum -------------------------- */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 + +#define GL_SLICE_ACCUM_SUN 0x85CC + +#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) + +#endif /* GL_SUN_slice_accum */ + +/* -------------------------- GL_SUN_triangle_list ------------------------- */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 + +#define GL_RESTART_SUN 0x01 +#define GL_REPLACE_MIDDLE_SUN 0x02 +#define GL_REPLACE_OLDEST_SUN 0x03 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB + +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); + +#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) +#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) +#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) +#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) +#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) +#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) +#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) + +#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) + +#endif /* GL_SUN_triangle_list */ + +/* ----------------------------- GL_SUN_vertex ----------------------------- */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 + +typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); + +#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) +#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) +#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) +#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) +#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) +#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) +#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) +#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) +#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) +#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) +#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) +#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) +#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) +#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) +#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) +#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) +#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) +#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) +#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) +#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) +#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) +#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) +#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) +#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) +#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) +#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) +#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) +#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) +#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) +#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) +#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) +#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) +#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) +#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) + +#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) + +#endif /* GL_SUN_vertex */ + +/* -------------------------- GL_WIN_phong_shading ------------------------- */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 + +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB + +#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) + +#endif /* GL_WIN_phong_shading */ + +/* -------------------------- GL_WIN_specular_fog -------------------------- */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 + +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC + +#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) + +#endif /* GL_WIN_specular_fog */ + +/* ---------------------------- GL_WIN_swap_hint --------------------------- */ + +#ifndef GL_WIN_swap_hint +#define GL_WIN_swap_hint 1 + +typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + +#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) + +#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) + +#endif /* GL_WIN_swap_hint */ + +/* ------------------------------------------------------------------------- */ + +#if defined(GLEW_MX) && defined(_WIN32) +#define GLEW_FUN_EXPORT +#else +#define GLEW_FUN_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#if defined(GLEW_MX) +#define GLEW_VAR_EXPORT +#else +#define GLEW_VAR_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#if defined(GLEW_MX) && defined(_WIN32) +struct GLEWContextStruct +{ +#endif /* GLEW_MX */ + +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; +GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; + +GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; +GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; +GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; +GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; + +GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; +GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; +GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; +GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; +GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; +GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; +GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; +GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; +GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; +GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; +GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; +GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; +GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; +GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; +GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; +GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; +GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; +GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; +GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; +GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; +GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; + +GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; +GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; +GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; +GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; +GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; +GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; +GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; +GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; +GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; +GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; +GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; +GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; +GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; +GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; +GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; +GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; +GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; +GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; +GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; +GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; +GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; +GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; +GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; +GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; +GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; +GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; +GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; +GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; +GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; +GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; +GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; +GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; +GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; +GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; +GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; +GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; +GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; +GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; +GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; +GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; +GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; +GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; +GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; +GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; +GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; + +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; + +GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; + +GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; + +GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; +GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; +GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; +GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; +GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; +GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; +GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; +GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; + +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; +GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; + +GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; +GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; +GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; +GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; + +GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; + +GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; + +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; + +GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; +GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; +GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; +GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; +GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; +GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; +GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; +GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; +GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; +GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; + +GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; + +GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; + +GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; +GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; +GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; +GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; +GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; +GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; +GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; + +GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; +GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; +GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; +GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; +GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; +GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; +GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; +GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; +GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; +GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; +GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; +GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; +GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; +GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; +GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; +GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; + +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; +GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; + +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; + +GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; +GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; +GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; +GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; + +GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; +GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; +GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; +GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; +GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; +GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; +GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; + +GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; +GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; +GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; +GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; +GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; + +GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; +GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; +GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; + +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; + +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; + +GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; +GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; + +GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; +GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; +GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; +GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; + +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; +GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; +GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; +GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; +GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; +GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; + +GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; +GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; + +GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI; +GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI; + +GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; +GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; + +GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; +GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; +GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; +GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; +GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; +GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; +GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; +GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; + +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; + +GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; +GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; +GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; + +GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; +GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; +GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; + +GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; + +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; + +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; + +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; + +GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; +GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; + +GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; +GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; + +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; +GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; + +GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; +GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; + +GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; + +GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; +GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; + +GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; + +GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; +GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; +GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; +GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; +GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; +GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; + +GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; +GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; + +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; + +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; + +GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; +GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; + +GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; + +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; + +GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; +GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; +GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; +GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; +GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; +GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; +GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; +GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; +GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; +GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; + +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; + +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; + +GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; +GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; + +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; +GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; +GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; +GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; +GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; + +GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; + +GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; + +GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; +GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; +GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; + +GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; + +GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; +GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; + +GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; + +GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; + +GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; + +GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; +GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; + +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; + +GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; + +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; + +GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; + +GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; + +GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; +GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; +GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; +GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; + +GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; +GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; +GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; +GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; +GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; + +GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; + +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; + +GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; +GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; +GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; +GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; +GLEW_FUN_EXPORT PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT; +GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; +GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; + +GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; +GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; +GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; +GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; +GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; +GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; +GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; +GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; +GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; +GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; +GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; +GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; +GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; +GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; +GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; +GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; +GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; + +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; + +GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; + +GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; +GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; + +GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; +GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; + +GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; +GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; +GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; +GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; + +GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; +GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; + +GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; +GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; + +GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT; + +GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; + +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; + +GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; +GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; +GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; + +GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; +GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; +GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; +GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; +GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; +GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; +GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; + +GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; +GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; +GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; +GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; +GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; +GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; +GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; + +GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; + +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; + +GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; +GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; +GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; +GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; +GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; +GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; +GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; +GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; +GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; +GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; +GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; + +GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; +GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; +GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; +GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; +GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; +GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; +GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; + +GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; +GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; + +GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; +GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; + +GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; +GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; +GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; +GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; + +GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; + +GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; +GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; +GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; +GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; +GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; +GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; +GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; +GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; + +GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; + +GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; +GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; +GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; +GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; +GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; +GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; +GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; +GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; +GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; + +GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; +GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; +GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; +GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; +GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; +GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; + +GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; +GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; + +GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; +GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; + +GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; +GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; + +GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; +GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; + +GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; + +GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; +GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; + +GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; +GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; +GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; +GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; +GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; +GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; + +GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; + +GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; + +GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; + +GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; + +GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; + +GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; + +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; + +GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; + +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; +GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; +GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; + +GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; + +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; + +GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; + +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; + +GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; + +GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; + +#if defined(GLEW_MX) && !defined(_WIN32) +struct GLEWContextStruct +{ +#endif /* GLEW_MX */ + +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; +GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; +GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; +GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; +GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; +GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; +GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; +GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; +GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; +GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; + +#ifdef GLEW_MX +}; /* GLEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------- */ + +/* error codes */ +#define GLEW_OK 0 +#define GLEW_NO_ERROR 0 +#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ +#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */ +#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */ + +/* string codes */ +#define GLEW_VERSION 1 + +/* API */ +#ifdef GLEW_MX + +typedef struct GLEWContextStruct GLEWContext; +GLEWAPI GLenum glewContextInit (GLEWContext* ctx); +GLEWAPI GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name); + +#define glewInit() glewContextInit(glewGetContext()) +#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) +#define glewIsExtensionSupported(x) glewIsSupported(x) + +#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) +#ifdef _WIN32 +# define GLEW_GET_FUN(x) glewGetContext()->x +#else +# define GLEW_GET_FUN(x) x +#endif + +#else /* GLEW_MX */ + +GLEWAPI GLenum glewInit (); +GLEWAPI GLboolean glewIsSupported (const char* name); +#define glewIsExtensionSupported(x) glewIsSupported(x) + +#define GLEW_GET_VAR(x) (*(const GLboolean*)&x) +#define GLEW_GET_FUN(x) x + +#endif /* GLEW_MX */ + +GLEWAPI GLboolean glewExperimental; +GLEWAPI GLboolean glewGetExtension (const char* name); +GLEWAPI const GLubyte* glewGetErrorString (GLenum error); +GLEWAPI const GLubyte* glewGetString (GLenum name); + +#ifdef __cplusplus +} +#endif + +#ifdef GLEW_APIENTRY_DEFINED +#undef GLEW_APIENTRY_DEFINED +#undef APIENTRY +#undef GLAPIENTRY +#endif + +#ifdef GLEW_CALLBACK_DEFINED +#undef GLEW_CALLBACK_DEFINED +#undef CALLBACK +#endif + +#ifdef GLEW_WINGDIAPI_DEFINED +#undef GLEW_WINGDIAPI_DEFINED +#undef WINGDIAPI +#endif + +#undef GLAPI +/* #undef GLEWAPI */ + +#endif /* __glew_h__ */ diff --git a/include/GL/vssver.scc b/include/GL/vssver.scc new file mode 100755 index 0000000..44f14c5 Binary files /dev/null and b/include/GL/vssver.scc differ diff --git a/include/card.h b/include/card.h new file mode 100755 index 0000000..5bba76e --- /dev/null +++ b/include/card.h @@ -0,0 +1,94 @@ +// +// card.h +// card reader header +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// +#ifndef CARD_H +#define CARD_H + +#define CARD_VER_STRING "3" + +#define CARD_NAME_LENGTH 32 + +// +// sCardData +// card data after it has been deciphered +// +typedef struct { + unsigned int bOperator; + unsigned long id; + unsigned long gameNumber; + unsigned long countryCode; + unsigned long cardId; + char firstName[CARD_NAME_LENGTH]; + char lastName[CARD_NAME_LENGTH]; + char middleName[CARD_NAME_LENGTH]; +} sCardData; + +// +// CARDCALLBACK_ +// callback reasons +// +enum { + CARDCALLBACK_TRACK1DATA=1, // track 1 data received + CARDCALLBACK_TRACK2DATA, // track 2 data received + CARDCALLBACK_DATAERROR, // data not formatted correctly + CARDCALLBACK_CARDIN, // card has been inserted + CARDCALLBACK_CARDOUT, // card has been pulled out + CARDCALLBACK_NODATA, // no data retrieved from card +}; + +// +// CARDREADER_ +// card reader type enumerations +// +enum { + CARDREADER_SINGULAR, // Singular Tech + CARDREADER_XICO, // XICO + NUM_CARDREADERS +}; + +/////////////////////////////////////////////////////////////////////////////// +// ERROR CODES +/////////////////////////////////////////////////////////////////////////////// +// +// ERRORS & EXTENDED RETURN CODES +// +// -1.....-8999 user +// -9000..-9099 system +// +enum // int16 +{ + // system + ERR_CARD_SYS_LAST=-9099, + ERR_CARD_DEVICE_NOTAVAILABLE, + ERR_CARD_MEM, + ERR_CARD_SYS_FIRST=-9000, + +}; // ERR_ + +extern int CardInit(void); +extern int CardBegin(int readerType); +extern void CardEnd(void); +extern void CardFinal(void); +extern int CardChangePortSettings(unsigned int port, unsigned long baud); +extern void CardGetVersionString(char *buf, int bufSize); +extern int CardSetCallback(void *callback); +extern int CardLoop(void); +extern int CardFlushIO(void); +extern int CardSelectMag(void); + +#define msg card_apphook_msg + +// apphook +extern void* card_apphook_malloc(int size); +extern void card_apphook_free(void *m); +extern void card_apphook_msg(char *fmt,...); + +#endif // ndef CARD_H +// EOF diff --git a/include/dongle/dongle.h b/include/dongle/dongle.h new file mode 100755 index 0000000..7e85655 --- /dev/null +++ b/include/dongle/dongle.h @@ -0,0 +1,242 @@ +#ifndef PMRT_DONGLE +#define PMRT_DONGLE + +#include "hasp_hl.h" + +#define ROCKEY_MAX_STORAGE_BYTES 24 +#define ALADDIN_MAX_STORAGE_BYTES 26 + +typedef enum _DongleType +{ + DONGLE_TYPE_FEITIAN, DONGLE_TYPE_ALADDIN, DONGLE_TYPE_UNKNOWN +}DongleType; + +typedef enum _DongleError +{ + DONGLE_OK, // 0 + DONGLE_ERR_ALREADYOPEN, + DONGLE_ERR_OPENFAILED, + DONGLE_ERR_INVALIDHANDLE, + DONGLE_ERR_FINDFAILED, + DONGLE_ERR_LOGINFAILED, // 5 + DONGLE_ERR_VENDOR, + DONGLE_ERR_VENDORSEEK, + DONGLE_ERR_NOTOPEN, + DONGLE_ERR_READFAILED, + DONGLE_ERR_WRITEFAILED, // 10 + DONGLE_ERR_NODATA, + DONGLE_ERR_CLOSEFAILED, + DONGLE_ERR_SESSION, + DONGLE_ERR_BADPARSE, + DONGLE_ERR_RANDFAILED, // 15 + DONGLE_ERR_INVALIDDONGLE, + DONGLE_ERR_ENCRYPTFAILED, + DONGLE_ERR_DECRYPTFAILED, + DONGLE_ERR_FEATURE_UNSUPPORTED, + +}DongleError; + +typedef struct _FeiTianData +{ + // unsigned char rockeyData[ROCKEY_MAX_STORAGE_BYTES]; + unsigned short p1, p2, p3, p4; // Rockey Variable + short handle; + long lp1, lp2; // Rockey Variable + // unsigned char uc; + unsigned int id; +}FeiTianData; + +typedef struct _AladdinData +{ + // unsigned char buffer[ALADDIN_MAX_STORAGE_BYTES]; + unsigned int options; + hasp_handle_t handle; +}AladdinData; + +typedef struct _AladdinInitData +{ + unsigned char *vendorCode; +}AladdinInitData; + +typedef struct _DongleHandle +{ + int type; + int opened; + void *data; + void *initData; + int api_err_code; // error code from underlying api (HASP, Rockey, etc) +}DongleHandle; + + +#ifdef __cplusplus +extern "C" { +#endif +int DongleInit(DongleHandle *handle, DongleType type, unsigned char *key, unsigned int key_len); +int DongleOpen(DongleHandle *handle, unsigned char *key); +int DongleRead(DongleHandle *handle, int startByte, int bytes, char *dest); +int DongleWrite(DongleHandle *handle, int startByte, int bytes, char *src); +int DongleClose(DongleHandle *handle); +int DongleClose(DongleHandle *handle); +int DongleGetRand(DongleHandle *handle, unsigned char *buffer, int numBytes ); +int DongleIsPresent(DongleHandle *handle); +int DongleGetID(DongleHandle *handle, unsigned int *outNum); +int DongleEncrypt(DongleHandle *handle, char *inOutData, unsigned int size); +int DongleDecrypt(DongleHandle *handle, char *inOutData, unsigned int size); + +#ifdef __cplusplus +} +#endif + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleEncrypt(DongleHandle handle, char *inOutData, unsigned int size, int retVal) +//************************************************* +#define DongleEncryptInline(dongle, inOutData, size, retVal) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + \ + if( (retCode = hasp_encrypt(alData->handle, (unsigned char*)inOutData, size)) != HASP_STATUS_OK) \ + retVal = retCode; \ + }break; \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } + +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleDecrypt(DongleHandle handle, char *inOutData, unsigned int size, int retVal) +//************************************************* +#define DongleDecryptInline(dongle, inOutData, size, retVal) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + \ + if( (retCode = hasp_decrypt(alData->handle, (unsigned char*)inOutData, size)) != HASP_STATUS_OK) \ + retVal = retCode; \ + }break; \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } + +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +#endif + + + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleEncryptWithNoiseInline(DongleHandle handle, char *inOutData, unsigned int size, int retVal, int (*RandFunc)( unsigned char *buffer, int numBytes) ) +//************************************************* +/* does not work +#define DongleEncryptWithNoiseInline(dongle, inOutData, size, retVal, RandFunc) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + void *Noise; \ + Noise = malloc(size*2); \ + RandFunc((unsigned char*)Noise, size*2 ); \ + memcpy( &(((unsigned char*)Noise)[size/2]), inOutData, size ); \ + if( (retCode = hasp_encrypt(alData->handle, (unsigned char*)Noise, size * 2)) != HASP_STATUS_OK) \ + retVal = retCode; \ + memcpy( inOutData, &(((unsigned char*)Noise)[size/2]), size ); \ + free(Noise); \ + }break; \ + \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } +*/ +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleDecryptWithNoise(DongleHandle handle, char *inOutData, unsigned int size, int retVal, int (*RandFunc)( unsigned char *buffer, int numBytes)) +//************************************************* +/* +#define DongleDecryptWithNoiseInline(dongle, inOutData, size, retVal, RandFunc) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + void *Noise; \ + Noise = malloc(size*2); \ + RandFunc((unsigned char*)Noise, size*2 ); \ + memcpy( &(((unsigned char*)Noise)[size/2]), inOutData, size ); \ + if( (retCode = hasp_decrypt(alData->handle, (unsigned char*)Noise, size * 2)) != HASP_STATUS_OK) \ + retVal = retCode; \ + memcpy( inOutData, &(((unsigned char*)Noise)[size/2]), size ); \ + free(Noise); \ + }break; \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } +*/ +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +//EOF + + + diff --git a/include/dongle/getopt.h b/include/dongle/getopt.h new file mode 100755 index 0000000..bae04bf --- /dev/null +++ b/include/dongle/getopt.h @@ -0,0 +1,191 @@ + + +/* getopt.h */ +/* Declarations for getopt. + Copyright (C) 1989-1994, 1996-1999, 2001 Free Software + Foundation, Inc. This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute + it and/or modify it under the terms of the GNU Lesser + General Public License as published by the Free Software + Foundation; either version 2.1 of the License, or + (at your option) any later version. + + The GNU C Library 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with the GNU C Library; if not, write + to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA. */ + + + + + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if (defined __STDC__ && __STDC__) || defined __cplusplus +# ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ +extern int getopt (); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif +#else /* not __STDC__ */ +extern int getopt (); +# ifndef __need_getopt +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +# endif +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ + diff --git a/include/dongle/hasp_hl.h b/include/dongle/hasp_hl.h new file mode 100755 index 0000000..8e6a85d --- /dev/null +++ b/include/dongle/hasp_hl.h @@ -0,0 +1,956 @@ +/*! \file hasp_hl.h HASP HL API declarations + * + */ + +/*! + * \mainpage HASP HL High Level API + * Copyright Aladdin Knowledge Systems Ltd. + * + * $Id: hasp_hl.h,v 1.3 2004/05/17 08:52:10 gerhard Exp $ + */ + + +#ifndef __HASP_HL_H__ +#define __HASP_HL_H__ + +#ifndef WITH_AKSTYPES +#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) +typedef unsigned __int64 hasp_u64_t; +typedef signed __int64 hasp_s64_t; +#else +typedef unsigned long long hasp_u64_t; +typedef signed long long hasp_s64_t; +#endif +#if defined(_MSC_VER) +typedef unsigned long hasp_u32_t; +typedef signed long hasp_s32_t; +#else +typedef unsigned int hasp_u32_t; +typedef signed int hasp_s32_t; +#endif +typedef unsigned short hasp_u16_t; +typedef signed short hasp_s16_t; +typedef unsigned char hasp_u8_t; +typedef signed char hasp_s8_t; +#endif + +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) +#define HASP_CALLCONV __stdcall +#else +#define HASP_CALLCONV +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @defgroup hasp_general General declarations + * + * @{ + */ + +typedef hasp_u32_t hasp_status_t; /*!< raw error code */ +typedef hasp_u32_t hasp_size_t; /*!< length */ +typedef hasp_u32_t hasp_handle_t; /*!< connection handle */ +typedef hasp_u32_t hasp_feature_t; /*!< feature id */ +typedef hasp_u32_t hasp_fileid_t; /*!< memory file id */ +typedef hasp_u64_t hasp_time_t; /*!< time, representing seconds since Jan-01-1970 0:00:00 GMT */ + +typedef void *hasp_vendor_code_t; /*!< contains the vendor code */ + +#define HASP_UPDATEINFO "" /*!< hasp_get_sessioninfo() format to get update info (C2V) */ +#define HASP_SESSIONINFO "" /*!< hasp_get_sessioninfo() format to get session info */ +#define HASP_KEYINFO "" /*!< hasp_get_sessioninfo() format to get key/hardware info */ + +/*! @} + */ + + +/*! @defgroup hasp_feature_ids Feature ID defines + * + * See also \ref hasp_features + * + * @{ + */ + +/*! \brief "Featuretype" mask + * + * AND-mask used to identify feature type + */ +#define HASP_FEATURETYPE_MASK 0xffff0000 + + +/*! \brief "PROGRAM NUMBER FEATURE" type + * + * After AND-ing with HASP_FEATURETYPE_MASK feature type contain this value. + */ +#define HASP_PROGNUM_FEATURETYPE 0xffff0000 + + +/*! \brief program number mask + * + * AND-mask used to extract program number from feature id if program number feature. + */ +#define HASP_PROGNUM_MASK 0x000000ff + + +/*! \brief prognum options mask + * + * AND-mask used to identify prognum options: + * - HASP_PROGNUM_OPT_NO_LOCAL + * - HASP_PROGNUM_OPT_NO_REMOTE + * - HASP_PROGNUM_OPT_PROCESS + * - HASP_PROGNUM_OPT_CLASSIC + * - HASP_PROGNUM_OPT_TS + * + * 3 bits of the mask are reserved for future extensions and currently unused. + * Initialize them to zero. + */ +#define HASP_PROGNUM_OPT_MASK 0x0000ff00 + + +/*! \brief "Prognum" option + * + * Disable local license search + */ +#define HASP_PROGNUM_OPT_NO_LOCAL 0x00008000 + + +/*! \brief "Prognum" option + * + * Disable network license search + */ +#define HASP_PROGNUM_OPT_NO_REMOTE 0x00004000 + + +/*! \brief "Prognum" option + * + * Sets session count of network licenses to per-process + */ +#define HASP_PROGNUM_OPT_PROCESS 0x00002000 + + +/*! \brief "Prognum" option + * + * Enables the API to access "classic" (HASP4 or earlier) keys + */ +#define HASP_PROGNUM_OPT_CLASSIC 0x00001000 + + +/*! \brief "Prognum" option + * + * Presence of Terminal Services gets ignored + */ +#define HASP_PROGNUM_OPT_TS 0x00000800 + + +/*! \brief HASP default feature id + * + * Present in every hardware key. + */ +#define HASP_DEFAULT_FID 0 + + +/*! \brief "Prognum" default feature id + * + * Present in every hardware HASP key. + */ +#define HASP_PROGNUM_DEFAULT_FID (HASP_DEFAULT_FID | HASP_PROGNUM_FEATURETYPE) + + +/*! @} + */ + +/*! \brief Minimal block size for hasp_encrypt() and hasp_decrypt() functions. + */ +#define HASP_MIN_BLOCK_SIZE 16 + +/*! \brief Minimal block size for legacy functions hasp_legacy_encrypt() + * and hasp_legacy_decrypt(). + */ +#define HASP_MIN_BLOCK_SIZE_LEGACY 8 + +/*! @defgroup hasp_file_ids Memory file id defines + * + * @{ + */ + +/*! \brief HASP4 memory file + * + * File id for HASP4 compatible memory contents w/o FAS + */ +#define HASP_FILEID_MAIN 0xfff0 + +/*! \brief HASP4 FAS memory file + * + * (Dummy) file id for license data area of memory contents + */ +#define HASP_FILEID_LICENSE 0xfff2 + + +/*! @} + */ + +/*! @defgroup hasp_error_codes Error code defines + * + * @{ + */ + +enum hasp_error_codes +{ + HASP_STATUS_OK = 0, /*!< no error occurred */ + HASP_MEM_RANGE = 1, /*!< invalid memory address */ + HASP_INV_PROGNUM_OPT = 2, /*!< unknown/invalid feature id option */ + HASP_INSUF_MEM = 3, /*!< memory allocation failed */ + HASP_TMOF = 4, /*!< too many open features */ + HASP_ACCESS_DENIED = 5, /*!< feature access denied */ + HASP_INCOMPAT_FEATURE = 6, /*!< incompatible feature */ + HASP_CONTAINER_NOT_FOUND = 7, /*!< license container not found */ + HASP_TOO_SHORT = 8, /*!< en-/decryption length too short */ + HASP_INV_HND = 9, /*!< invalid handle */ + HASP_INV_FILEID = 10, /*!< invalid file id / memory descriptor */ + HASP_OLD_DRIVER = 11, /*!< driver or support daemon version too old */ + HASP_NO_TIME = 12, /*!< real time support not available */ + HASP_SYS_ERR = 13, /*!< generic error from host system call */ + HASP_NO_DRIVER = 14, /*!< hardware key driver not found */ + HASP_INV_FORMAT = 15, /*!< unrecognized info format */ + HASP_REQ_NOT_SUPP = 16, /*!< request not supported */ + HASP_INV_UPDATE_OBJ = 17, /*!< invalid update object */ + HASP_KEYID_NOT_FOUND = 18, /*!< key with requested id was not found */ + HASP_INV_UPDATE_DATA = 19, /*!< update data consistency check failed */ + HASP_INV_UPDATE_NOTSUPP = 20, /*!< update not supported by this key */ + HASP_INV_UPDATE_CNTR = 21, /*!< update counter mismatch */ + HASP_INV_VCODE = 22, /*!< invalid vendor code */ + HASP_ENC_NOT_SUPP = 23, /*!< requested encryption algorithm not supported */ + HASP_INV_TIME = 24, /*!< invalid date / time */ + HASP_NO_BATTERY_POWER = 25, /*!< clock has no power */ + HASP_NO_ACK_SPACE = 26, /*!< update requested acknowledgement, but no area to return it */ + HASP_TS_DETECTED = 27, /*!< terminal services (remote terminal) detected */ + HASP_FEATURE_TYPE_NOT_IMPL = 28, /*!< feature type not implemented */ + HASP_UNKNOWN_ALG = 29, /*!< unknown algorithm */ + HASP_INV_SIG = 30, /*!< signature check failed */ + HASP_FEATURE_NOT_FOUND = 31, /*!< feature not found */ + HASP_NO_LOG = 32, /*!< trace log is not enabled */ + + /* c++ use */ + HASP_INVALID_OBJECT = 500, + HASP_INVALID_PARAMETER, + HASP_ALREADY_LOGGED_IN, + HASP_ALREADY_LOGGED_OUT, + + /* .net use */ + HASP_OPERATION_FAILED = 525, + + /* inside-api use */ + HASP_NO_EXTBLOCK = 600, /*!< no classic memory extension block available */ + /* internal use */ + HASP_INV_PORT_TYPE = 650, /*!< invalid port type */ + HASP_INV_PORT = 651, /*!< invalid port value */ + /* catch-all */ + HASP_NOT_IMPL = 698, /*!< capability isn't available */ + HASP_INT_ERR = 699 /*!< internal API error */ +}; + +/*! @} + */ + + +/*! @defgroup hasp_basic The Basic API + * + * @{ + */ + +/* --------------------------------------------------------------------- */ +/*! \brief Login into a feature. + * + * This function establishes a context (logs into a feature). + * + * \param feature_id - Unique identifier of the feature\n + * With "prognum" features (see \ref HASP_FEATURETYPE_MASK), + * 8 bits are reserved for legacy options (see \ref HASP_PROGNUM_OPT_MASK, + * currently 5 bits are used): + * - only local + * - only remote + * - login is counted per process ID + * - disable terminal server check + * - enable access to old (HASP3/HASP4) keys + * \param vendor_code - pointer to the vendor code + * \param handle - pointer to the resulting session handle + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_FEATURE_NOT_FOUND + * - the requested feature isn't available + * - HASP_CONTAINER_NOT_FOUND + * - no possible feature container found + * - HASP_FEATURE_TYPE_NOT_IMPL + * - the type of feature isn't implemented + * - HASP_INV_PROGNUM_OPT + * - unknown prognum option requested (\ref HASP_PROGNUM_OPT_MASK) + * - HASP_TMOF + * - too many open handles + * - HASP_INSUF_MEM + * - out of memory + * - HASP_INV_VCODE + * - invalid vendor code + * - HASP_NO_DRIVER + * - driver not installed + * - HASP_OLD_DRIVER + * - old driver installed + * - HASP_TS_DETECTED + * - program runs on a remote screen on Terminal Server + * + * \sa hasp_logout() + * + * \remark + * + * For local prognum features, concurrency is not handled and each login performs a decrement + * if it is a counting license. + * + * Network prognum features just use the old HASPLM login logic with all drawbacks. + * There is only support for concurrent usage of \b one server (global server address). + * + */ +hasp_status_t HASP_CALLCONV hasp_login(hasp_feature_t feature_id, + hasp_vendor_code_t vendor_code, + hasp_handle_t *handle); + + +/* --------------------------------------------------------------------- */ +/*! \brief Logout. + * + * Logs out from a session and frees all allocated resources for the session. + * + * \param handle - handle of session to log out from + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * + * \sa hasp_login() + */ +hasp_status_t HASP_CALLCONV hasp_logout(hasp_handle_t handle); + + +/* --------------------------------------------------------------------- */ +/*! \brief Encrypt a buffer. + * + * This function encrypts a buffer. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be encrypted + * \param length - size in bytes of the buffer to be encrypted (16 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be encrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \sa hasp_decrypt() + * + * \remark + * If the encryption fails (e.g. key removed in-between) the data pointed to by buffer is unmodified. + */ +hasp_status_t HASP_CALLCONV hasp_encrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Decrypt a buffer. + * + * This function decrypts a buffer. This is the reverse operation of the + * hasp_encrypt() function. See \ref hasp_encrypt() for more information. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be decrypted + * \param length - size in bytes of the buffer to be decrypted (16 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be decrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \sa hasp_encrypt() + * + * \remark + * If the decryption fails (e.g. key removed in-between) the data pointed to by buffer is unmodified. + */ +hasp_status_t HASP_CALLCONV hasp_decrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Read from key memory. + * + * This function is used to read from the key memory. + * + * \param handle - session handle + * \param fileid - id of the file to read (memory descriptor) + * \param offset - position in the file + * \param length - number of bytes to read + * \param buffer - result of the read operation + * + * \return status code. + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FILEID + * - unknown fileid + * - HASP_MEM_RANGE + * - attempt to read beyond eom + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \remark + * Valid fileids are \ref HASP_FILEID_LICENSE and \ref HASP_FILEID_MAIN. + * + * \sa hasp_write(), hasp_get_size() + */ +hasp_status_t HASP_CALLCONV hasp_read(hasp_handle_t handle, hasp_fileid_t fileid, hasp_size_t offset, hasp_size_t length, void *buffer); + + +/* --------------------------------------------------------------------- */ +/*! \brief Write to key memory. + * + * This function is used to write to the key memory. Depending on the provided + * session handle (either logged into the default feature or any other feature), + * write access to the FAS memory (\ref HASP_FILEID_LICENSE) is not permitted. + * + * \param handle - session handle + * \param fileid - id of the file to write + * \param offset - position in the file + * \param length - number of bytes to write + * \param buffer - what to write + * + * \return status code. + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FILEID + * - unknown fileid + * - HASP_MEM_RANGE + * - attempt to read beyond eom + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \remark + * Valid fileids are \ref HASP_FILEID_LICENSE and \ref HASP_FILEID_MAIN. + * + * \sa hasp_read(), hasp_get_size() + */ +hasp_status_t HASP_CALLCONV hasp_write(hasp_handle_t handle, hasp_fileid_t fileid, hasp_size_t offset, hasp_size_t length, void *buffer); + + +/* --------------------------------------------------------------------- */ +/*! \brief Get memory size. + * + * This function is used to determine the memory size. + * + * \param handle - session handle + * \param fileid - id of the file to query + * \param size - pointer to the resulting file size + * + * \result status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FILEID + * - unknown fileid + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \remark + * Valid fileids are \ref HASP_FILEID_LICENSE and \ref HASP_FILEID_MAIN. + * + * \sa hasp_read(), hasp_write() + */ +hasp_status_t HASP_CALLCONV hasp_get_size(hasp_handle_t handle, hasp_fileid_t fileid, hasp_size_t *size); + + +/* --------------------------------------------------------------------- */ +/*! \brief Read current time from a time key. + * + * This function reads the current time from a time key. + * The time will be returned in seconds since Jan-01-1970 0:00:00 GMT. + * + * \remark The general purpose of this function is not related to + * licensing, but to get reliable timestamps which are independent + * from the system clock. + * \remark This request is only supported on locally accessed keys. Trying to + * get the time from a remotely accessed key will return HASP_NO_TIME. + * + * \param handle - session handle + * \param time - pointer to the actual time + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_NO_TIME + * - RTC not available or remote access + * - HASP_NO_BATTERY_POWER + * - RTC consistency check failed, battery probably dead + * + * \sa hasp_datetime_to_hasptime(), hasp_hasptime_to_datetime() + */ +hasp_status_t HASP_CALLCONV hasp_get_rtc(hasp_handle_t handle, hasp_time_t *time); + + +/* --------------------------------------------------------------------- */ +/*! @} + */ + + +/* --------------------------------------------------------------------- */ +/*! @defgroup hasp_classic Legacy HASP functionality for backward compatibility + * + * @{ + */ + +/*! \brief Legacy HASP4 compatible encryption function. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be encrypted + * \param length - size in bytes of the buffer (8 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be encrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + * + * \sa hasp_legacy_decrypt(), hasp_encrypt(), hasp_decrypt() + * + * \remark + * If the encryption fails (e.g. key removed in-between) the data pointed to by buffer is undefined. + */ +hasp_status_t HASP_CALLCONV hasp_legacy_encrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Legacy HASP4 compatible decryption function. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be decrypted + * \param length - size in bytes of the buffer (8 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be decrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + * + * \sa hasp_legacy_encrypt(), hasp_decrypt(), hasp_encrypt() + * + * \remark + * If the decryption fails (e.g. key removed in-between) the data pointed to by buffer is undefined. + */ +hasp_status_t HASP_CALLCONV hasp_legacy_decrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Write to HASP4 compatible real time clock + * + * \param handle - session handle + * \param new_time - time value to be set + * + * \remark This request is only supported on locally accessed keys. Trying to + * set the time on a remotely accessed key will return HASP_NO_TIME. + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_NO_TIME + * - RTC not available or access remote + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + * + * \sa hasp_get_rtc(), hasp_datetime_to_hasptime(), hasp_hasptime_to_datetime() + */ +hasp_status_t HASP_CALLCONV hasp_legacy_set_rtc(hasp_handle_t handle, hasp_time_t new_time); + + +/* --------------------------------------------------------------------- */ +/*! \brief Set the LM idle time. + * + * \param handle - session handle + * \param idle_time - the idle time in minutes + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_REQ_NOT_SUPP + * - attempt to set the idle time for a local license + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + */ +hasp_status_t HASP_CALLCONV hasp_legacy_set_idletime(hasp_handle_t handle, hasp_u16_t idle_time); + +/*! @} + */ + + +/*! @defgroup hasp_extended Extended HASP HL API + * + * The extended API consists of functions which provide extended functionality. This + * advanced functionality is sometimes necessary, and addresses the "advanced" user. + * + * @{ + */ + +/*! \brief Get information in a session context. + * + * Memory for the information is allocated by this function and has to be freed by the + * \ref hasp_free() function. + * + * \param handle - session handle + * \param format - XML definition of the output data structure + * \param info - pointer to the returned information (XML list) + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FORMAT + * - unrecognized format + * - HASP_INSUF_MEM + * - out of memory + * + * \sa hasp_free() + * \sa HASP_UPDATEINFO, HASP_SESSIONINFO, HASP_KEYINFO + * \sa \ref hasp_query_page + */ +hasp_status_t HASP_CALLCONV hasp_get_sessioninfo (hasp_handle_t handle, const char *format, char **info); + + +/*! \brief Free resources allocated by hasp_get_sessioninfo + * + * This function must be called to free the resources allocated by hasp_get_sessioninfo() + * or to free the acknowledge data optionally returned from hasp_update(). + * + * \param info - pointer to the resources to be freed + * + * \sa hasp_get_sessioninfo(), hasp_update() + */ +void HASP_CALLCONV hasp_free (char *info); + + +/*! \brief Write an update. + * + * This function writes update information. The update blob contains all necessary data + * to perform the update: Where to write (in which "container", e.g. dongle), the necessary + * access data (vendor code) and of course the update itself. + * If the update blob requested it, the function returns in an acknowledge blob, + * which is signed/encrypted by the updated instance and contains a proof that this update + * was successfully installed. Memory for the acknowledge blob is allocated by the API and has to be + * freed by the programmer (see \ref hasp_free()). + * + * \param update_data - pointer to the complete update data. + * \param ack_data - pointer to a buffer to get the acknowledge data. + * + * \return status code + * - HASP_INV_UPDATE_DATA + * - required XML tags not found + * - contents in binary data missing or invalid + * - HASP_INV_UPDATE_OBJ + * - binary data doesn't contain an update blob + * - HASP_NO_ACK_SPACE + * - acknowledge data requested by the update, but ack_data input parameter is NULL + * - HASP_KEYID_NOT_FOUND + * - key to be updated not found + * - HASP_INV_UPDATE_NOTSUPP + * - update not supported by the key + * - HASP_INV_UPDATE_CNTR + * - update counter at the wrong position + * - HASP_INV_SIG + * - signature verification failed + * + * \sa hasp_free() + * + * \remark Update via LM is not supported. + */ +hasp_status_t HASP_CALLCONV hasp_update(char *update_data, char **ack_data); + +/*! @} + */ + + +/* --------------------------------------------------------------------- */ +/*! @defgroup hasp_util Utility functions + * + * @{ + */ + +/* --------------------------------------------------------------------- */ +/*! \brief Convert broken up time into a time type + * + * \param day - input day + * \param month - input month + * \param year - input year + * \param hour - input hour + * \param minute - input minute + * \param second - input second + * \param time - pointer to put result + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_TIME + * - time outside of the supported range + * + * \remark Times are in UTC. + * + * \sa hasp_hasptime_to_datetime() + */ +hasp_status_t HASP_CALLCONV hasp_datetime_to_hasptime(unsigned int day, + unsigned int month, + unsigned int year, + unsigned int hour, + unsigned int minute, + unsigned int second, + hasp_time_t *time); + + +/* --------------------------------------------------------------------- */ +/*! \brief Convert time type into broken up time + * + * \param time - pointer to put result + * \param day - pointer to day + * \param month - pointer to month + * \param year - pointer to year + * \param hour - pointer to hour + * \param minute - pointer to minute + * \param second - pointer to second + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_TIME + * - time outside of the supported range + * + * \remark Times are in UTC. + * + * \sa hasp_datetime_to_hasptime() + */ +hasp_status_t HASP_CALLCONV hasp_hasptime_to_datetime(hasp_time_t time, + unsigned int *day, + unsigned int *month, + unsigned int *year, + unsigned int *hour, + unsigned int *minute, + unsigned int *second); + + +/*! @} + */ + + +/*! \page hasp_features Feature ID convention + +\section FeatIntr Feature ID introduction + +Feature ids are 32bits wide. If the upper 16 bit contain the value indicated by \ref HASP_PROGNUM_FEATURETYPE, +the feature defines a prognum feature.\n +For prognum features there are some options encoded in the feature id. These include + - \ref HASP_PROGNUM_OPT_NO_LOCAL\n + Don't search for a license locally. "Remote-only"\n\n + - \ref HASP_PROGNUM_OPT_NO_REMOTE\n + Don't search for a license on the network. "Local-only"\n\n + - \ref HASP_PROGNUM_OPT_PROCESS\n + In case, a license is found in the network, count license usage per process + instead of per workstation.\n\n + - \ref HASP_PROGNUM_OPT_TS\n + Don't detect whether the program is running on a remote screen on a terminal server.\n\n + - \ref HASP_PROGNUM_OPT_CLASSIC\n + The API by default only searches for HASPHL keys. When this option is set, it also + searches for HASP3/HASP4 keys.\n\n +*/ + + +/*! \page hasp_query_page hasp_get_sessioninfo format and info + +\section QueryPage hasp_get_sessioninfo format and info + +Calling hasp_get_sessioninfo() with \ref HASP_UPDATEINFO format will return something like this: + +\verbatim + + + + YYIBlIADY3R2oQaABEAwulCiCYABaoEBBIIBAKOBxoABAIGBwD2sfFj8UKuDvNWH9 + LhfRKDzUbLCAi6E9mN8ea7EclwOl9VeLMDuLvfsEvkor2igmwxg/wWs6HCuypEFi6 + V/FkI4EUmQNmcKSIY302s9CzHP7aCrG7QKvzArVq25Nc7UxIQJ4kZJm1oWiw3zZJq + UY+G0EleETkPZ8n2uDfMauBpdWhW0R35rHlRM4wiYCZzaelpRtDX36HDh1caqfpaL + mUnwWXRz0+tLs+Dvd+kLmvcQ6jWJJb4r2rxywG2IW1WTjIWBsI+h0/UgaIhG1J+9R + EQ1SrMx3YQ2bpdlK3FluZVDayW9okv7idxKJS4zGG+4UOccpKT4aWJi9cR0vdm4s/ + J6fUNbhK522x/gdvR51a6ll46GpVn2HjD0ZpAgCeu6xAIwHJ7Kc6tjeRfxYX9YksE + aB9JoV/uaPTHnbu2AgQmd0r09p0zmXgD4Kuk8EtTs1GoBbY7WF3qHJsj1Iz1ZeAdA + rdNOYKsOgA/q1tuLLR7O0dag + + +\endverbatim + + +Calling hasp_get_sessioninfo() with \ref HASP_SESSIONINFO format will return something like this: + +\verbatim + + + 4294905856 + 5 + 1 + unlimited + + +\endverbatim + +In case of a expiring license on a time enabled key (prognum <= 8), +instead of the remaining activations the expiration date will be +returned: + +\verbatim + + + 4294905857 + 1052919239 + + +\endverbatim + +For locally accessed keys there is no \p maxlogins and \p currentlogins field. + + +Calling hasp_get_sessioninfo() with \ref HASP_KEYINFO format will return something like +this for a locally accessed key: + +\verbatim + + + + + + + + + + 12345 + 0 + + "Main" + 65520 + 48 + + + "FAS" + 65522 + 80 + + + + "USB" +
1
+
+
+
+\endverbatim + + +Calling hasp_get_sessioninfo() with \ref HASP_KEYINFO format will return something like +this for a remotely accessed key: + +\verbatim + + + + + + + + 782062012 + 5 + + "Main" + 65520 + 432 + + + "FAS" + 65522 + 448 + + + + "IP" +
"10.20.3.10"
+
+
+
+\endverbatim + +\p keycaps flags: + - hasp4 + - support HASP4 compatible encryption + - aes + - support AES encryption + - rtc + - key has real time clock chip + - newintf + - supports new access interface + +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef __HASP_HL_H__ */ diff --git a/include/dongle/hasp_vcode.h b/include/dongle/hasp_vcode.h new file mode 100755 index 0000000..dcfeb0c --- /dev/null +++ b/include/dongle/hasp_vcode.h @@ -0,0 +1,12 @@ +unsigned char vendor_code[] = +"p0AosKZcgvIqHRZwMAK6MqljLvA8fjsYK92+Z4QMib0WKbM/3ljp/RAHjtNwN4wfy1W8oFXWujb" +"bnEppgxd0vulb/ZTuqIvG5hiAuyjLoDYl49KmvXGoXL1yWEwFBIDoVYEbMy1x1Q9k0XxcRioqIG" +"Ks8Q/xX8ZqjvQlQyZi2p27biH4GxKvZew2ctfKKxEK87gHBxEC3Pz40bqUnPUEl5KnjfXwTX674" +"ZG0d8HVNnccAOqdblCHHQN6P5LdRpTOQI6B1W4+cLWOv30i1rsjCv8yWfiqV7k909pVuE8s2YMH" +"GBb14jKOjE4lm1FBQ2j8yr7S/jLFBBy1wbDSpThnwT06uzjGgXRhANPVji7lUYdNNebK/v5daWp" +"ZGN/e1x0H5QhnSOiclsxNRKAS9f4fVv3iLNHYZHi41W5S87teNkEDG/jkMQchv/Ub/VJTgW03ne" +"H44ZzbaAs2Ox+44ZkxdKtDXQM/e0g2qpafrtfPyu07XaEWifw+IBDq2hCoiyB02OZcHVZXAyPO5" +"sk/5pFXr0J2rNT5tf09rqHuemgZnSbEO1XkhrKTo/XS3i9Jw9ST/UgbpSaO5aeiCsWeQ8X5RJ3C" +"IWVDTKC1G2dpadJftEMR2rFS6N9ixxP/1R7pdT1df79/H/dPTVvzuy76dcpxj0UP7/mF/X6GO8O" +"qUOxKG8DoEPGMiZxHHm3ZgLib6uljbQ2ewZYKFp69QSVVMAHumT+wCgWPKg=="; + diff --git a/include/dongle/ryvc32.h b/include/dongle/ryvc32.h new file mode 100755 index 0000000..94189e5 --- /dev/null +++ b/include/dongle/ryvc32.h @@ -0,0 +1,250 @@ +// Function Code +#define RY_FIND 1 // Find Dongle +#define RY_FIND_NEXT 2 // Find Next Dongle +#define RY_OPEN 3 // Open Dongle +#define RY_CLOSE 4 // Close Dongle +#define RY_READ 5 // Read Dongle +#define RY_WRITE 6 // Write Dongle +#define RY_RANDOM 7 // Generate Random Number +#define RY_SEED 8 // Generate Seed Code +#define RY_WRITE_USERID 9 // Write User ID +#define RY_READ_USERID 10 // Read User ID +#define RY_SET_MOUDLE 11 // Set Module +#define RY_CHECK_MOUDLE 12 // Check Module +#define RY_WRITE_ARITHMETIC 13 // Write Arithmetic +#define RY_CALCULATE1 14 // Calculate 1 +#define RY_CALCULATE2 15 // Calculate 2 +#define RY_CALCULATE3 16 // Calculate 3 +#define RY_DECREASE 17 // Decrease Module Unit + +// Error Code +#define ERR_SUCCESS 0 // Success +#define ERR_NO_PARALLEL_PORT 1 // No parallel port on the computer +#define ERR_NO_DRIVER 2 // No install drivers +#define ERR_NO_ROCKEY 3 // No rockey dongle +#define ERR_INVALID_PASSWORD 4 // Found rockey dongle, but base password is wrong +#define ERR_INVALID_PASSWORD_OR_ID 5 // Wrong password or rockey HID +#define ERR_SETID 6 // Set rockey HID wrong +#define ERR_INVALID_ADDR_OR_SIZE 7 // Read/Write address is wrong +#define ERR_UNKNOWN_COMMAND 8 // No such command +#define ERR_NOTBELEVEL3 9 // Inside error +#define ERR_READ 10 // Read error +#define ERR_WRITE 11 // Write error +#define ERR_RANDOM 12 // Random error +#define ERR_SEED 13 // Seed Code error +#define ERR_CALCULATE 14 // Calculate error +#define ERR_NO_OPEN 15 // No open dongle before operate dongle +#define ERR_OPEN_OVERFLOW 16 // Too more open dongle(>16) +#define ERR_NOMORE 17 // No more dongle +#define ERR_NEED_FIND 18 // No Find before FindNext +#define ERR_DECREASE 19 // Decrease error + +#define ERR_AR_BADCOMMAND 20 // Arithmetic instruction error +#define ERR_AR_UNKNOWN_OPCODE 21 // Arithmetic operator error +#define ERR_AR_WRONGBEGIN 22 // Const number can't use on first arithmetic instruction +#define ERR_AR_WRONG_END 23 // Const number can't use on last arithmetic instruction +#define ERR_AR_VALUEOVERFLOW 24 // Const number > 63 +#define ERR_UNKNOWN 0xffff // Unknown error + +#define ERR_RECEIVE_NULL 0x100 // Receive null +#define ERR_PRNPORT_BUSY 0x101 // Parallel busy +#define ERR_UNKNOWN_SYSTEM 0x102 // Unknown operate system + +/* Interface: +(1) Find Dongle + Input: + function = 0 + *p1 = pass1 + *p2 = pass2 + *p3 = pass3 + *p4 = pass4 + Return: + *lp1 = Rockey HID + return 0 = Success, else is error code + +(2) Find Next Dongle + Input: + function = 1 + *p1 = pass1 + *p2 = pass2 + *p3 = pass3 + *p4 = pass4 + Return: + *lp1 = Rockey HID + return 0 = Success, else is error code + +(3) Open Dongle + Input: + function = 2 + *p1 = pass1 + *p2 = pass2 + *p3 = pass3 + *p4 = pass4 + *lp1 = Rockey HID + Return: + *handle = Opened dongle handle + return 0 = Success, else is error code + +(4) Cloase Dongle + Input: + function = 3 + *handle = dongle handle + Return: + return 0 = Success, else is error code + +(5) Read Dongle + Input: + function = 4 + *handle = dongle handle + *p1 = pos + *p2 = length + buffer = pointer of buffer + Return: + Fill buffer with read contents + return 0 = Success, else is error code + +(6) Write Dongle + Input: + function = 5 + *handle = dongle handle + *p1 = pos + *p2 = length + buffer = pointer of buffer + Return: + return 0 = Success, else is error code + +(7) Generate Random Number + Input: + function = 6 + *handle = dongle handle + Return: + *p1 = random number + return 0 = Success, else is error code + +(8) Generate Seed Code + Input: + function = 7 + *handle = dongle handle + *lp2 = seed code + Return: + *p1 = seed return code 1 + *p2 = seed return code 2 + *p3 = seed return code 3 + *p4 = seed return code 4 + return 0 = Success, else is error code + +(9) Write User ID [*] + Input: + function = 8 + *handle = dongle handle + *lp1 = User ID + Return: + return 0 = Success, else is error code + +(10) Read User ID + Input: + function = 9 + *handle = dongle handle + Return: + *lp1 = User ID + return 0 = Success, else is error code + +(11) Set Module [*] + Input: + function = 10 + *handle = dongle handle + *p1 = module number + *p2 = module content + *p3 = set whether allow decrease (1 = allow, 0 = no allow) + Return: + return 0 = Success, else is error code + +(12) Check Module + Input: + function = 11 + *handle = dongle handle + *p1 = module number + Return: + *p2 = 1 means the module is valid, 0 means the module is invalid + *p3 = 1 means the module can't decrease, 0 means the module can decrease + return 0 = Success, else is error code + +(13) Write Arithmetic [*] + Input: + function = 12 + *handle = dongle handle + *p1 = pos + buffer = arithmetic instruction string + Return: + return 0 = Success, else is error code + +(14) Calculate 1 (Hide Unit Init Content = HID high 16bit, HID low 16bit, module content, random number) + Input: + function = 13 + *handle = dongle handle + *lp1 = calculate begin pos + *lp2 = module number + *p1 = input value 1 + *p2 = input value 2 + *p3 = input value 3 + *p4 = input value 4 + Return: + *p1 = return code 1 + *p2 = return code 2 + *p3 = return code 3 + *p4 = return code 4 + return 0 = Success, else is error code + +(15) Calculate 2 (Hide Unit Init Content = seed return code 1, seed return code 2, seed return code 3, seed return code 4) + Input: + function = 14 + *handle = dongle handle + *lp1 = calculate begin pos + *lp2 = seed code + *p1 = input value 1 + *p2 = input value 2 + *p3 = input value 3 + *p4 = input value 4 + Return: + *p1 = return code 1 + *p2 = return code 2 + *p3 = return code 3 + *p4 = return code 4 + return 0 = Success, else is error code + +(16) Calculate 3 (Hide Unit Init Content = module content, module+1 content, module+2 content, module+3 content) + Input: + function = 15 + *handle = dongle handle + *lp1 = calculate begin pos + *lp2 = module begin pos + *p1 = input value 1 + *p2 = input value 2 + *p3 = input value 3 + *p4 = input value 4 + Return: + *p1 = return code 1 + *p2 = return code 2 + *p3 = return code 3 + *p4 = return code 4 + return 0 = Success, else is error code + +(17) Decrease Module Unit + Input: + function = 16 + *handle = dongle handle + *p1 = module number + Return: + return 0 = Success, else is error code +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +WORD Rockey(WORD function, WORD* handle, DWORD* lp1, DWORD* lp2, WORD* p1, WORD* p2, WORD* p3, WORD* p4, BYTE* buffer); + +#ifdef __cplusplus +} +#endif diff --git a/include/gif_lib.h b/include/gif_lib.h new file mode 100755 index 0000000..3515acc --- /dev/null +++ b/include/gif_lib.h @@ -0,0 +1,323 @@ +/****************************************************************************** +* In order to make life a little bit easier when using the GIF file format, * +* this library was written, and which does all the dirty work... * +* * +* Written by Gershon Elber, Jun. 1989 * +* Hacks by Eric S. Raymond, Sep. 1992 * +******************************************************************************* +* History: * +* 14 Jun 89 - Version 1.0 by Gershon Elber. * +* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names) * +* 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp) * +* 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) * +* 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code) * +******************************************************************************/ + +#ifndef _GIF_LIB_H +#define _GIF_LIB_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define GIF_LIB_VERSION " Version 4.0, " + +#define GIF_ERROR 0 +#define GIF_OK 1 + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif /* NULL */ + +#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */ +#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1 +#define GIF_VERSION_POS 3 /* Version first character in stamp. */ +#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */ +#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */ + +#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */ + +typedef int GifBooleanType; +typedef unsigned char GifPixelType; +typedef unsigned char * GifRowType; +typedef unsigned char GifByteType; + +#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg) +#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); } + +#ifdef SYSV +#define VoidPtr char * +#else +#define VoidPtr void * +#endif /* SYSV */ + +typedef struct GifColorType { + GifByteType Red, Green, Blue; +} GifColorType; + +typedef struct ColorMapObject +{ + int ColorCount; + int BitsPerPixel; + GifColorType *Colors; /* on malloc(3) heap */ +} +ColorMapObject; + +typedef struct GifImageDesc { + int Left, Top, Width, Height, /* Current image dimensions. */ + Interlace; /* Sequential/Interlaced lines. */ + ColorMapObject *ColorMap; /* The local color map */ +} GifImageDesc; + +typedef struct GifFileType { + int SWidth, SHeight, /* Screen dimensions. */ + SColorResolution, /* How many colors can we generate? */ + SBackGroundColor; /* I hope you understand this one... */ + ColorMapObject *SColorMap; /* NULL if not exists. */ + int ImageCount; /* Number of current image */ + GifImageDesc Image; /* Block describing current image */ + struct SavedImage *SavedImages; /* Use this to accumulate file state */ + VoidPtr UserData; /* hook to attach user data (TVT) */ + VoidPtr Private; /* Don't mess with this! */ +} GifFileType; + +typedef enum { + UNDEFINED_RECORD_TYPE, + SCREEN_DESC_RECORD_TYPE, + IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */ + EXTENSION_RECORD_TYPE, /* Begin with '!' */ + TERMINATE_RECORD_TYPE /* Begin with ';' */ +} GifRecordType; + +/* DumpScreen2Gif routine constants identify type of window/screen to dump. */ +/* Note all values below 1000 are reserved for the IBMPC different display */ +/* devices (it has many!) and are compatible with the numbering TC2.0 */ +/* (Turbo C 2.0 compiler for IBM PC) gives to these devices. */ +typedef enum { + GIF_DUMP_SGI_WINDOW = 1000, + GIF_DUMP_X_WINDOW = 1001 +} GifScreenDumpType; + +/* func type to read gif data from arbitrary sources (TVT) */ +typedef int (*InputFunc)(GifFileType*,GifByteType*,int); + +/* func type to write gif data ro arbitrary targets. + * Returns count of bytes written. (MRB) + */ +typedef int (*OutputFunc)(GifFileType *, const GifByteType *, int); +/****************************************************************************** +* GIF89 extension function codes * +******************************************************************************/ + +#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */ +#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control */ +#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */ +#define APPLICATION_EXT_FUNC_CODE 0xff /* application block */ + +/****************************************************************************** +* O.K., here are the routines one can access in order to encode GIF file: * +* (GIF_LIB file EGIF_LIB.C). * +******************************************************************************/ + +GifFileType *EGifOpenFileName(const char *GifFileName, int GifTestExistance); +GifFileType *EGifOpenFileHandle(int GifFileHandle); +GifFileType *EgifOpen(void *userPtr, OutputFunc writeFunc); +int EGifSpew(GifFileType *GifFile); +void EGifSetGifVersion(const char *Version); +int EGifPutScreenDesc(GifFileType *GifFile, + int GifWidth, int GifHeight, int GifColorRes, int GifBackGround, + const ColorMapObject *GifColorMap); +int EGifPutImageDesc(GifFileType *GifFile, + int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace, + const ColorMapObject *GifColorMap); +int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); +int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel); +int EGifPutComment(GifFileType *GifFile, const char *GifComment); +int EGifPutExtensionFirst(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutExtensionNext(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutExtensionLast(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutCode(GifFileType *GifFile, int GifCodeSize, + const GifByteType *GifCodeBlock); +int EGifPutCodeNext(GifFileType *GifFile, const GifByteType *GifCodeBlock); +int EGifCloseFile(GifFileType *GifFile); + +#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */ +#define E_GIF_ERR_WRITE_FAILED 2 +#define E_GIF_ERR_HAS_SCRN_DSCR 3 +#define E_GIF_ERR_HAS_IMAG_DSCR 4 +#define E_GIF_ERR_NO_COLOR_MAP 5 +#define E_GIF_ERR_DATA_TOO_BIG 6 +#define E_GIF_ERR_NOT_ENOUGH_MEM 7 +#define E_GIF_ERR_DISK_IS_FULL 8 +#define E_GIF_ERR_CLOSE_FAILED 9 +#define E_GIF_ERR_NOT_WRITEABLE 10 + +/****************************************************************************** +* O.K., here are the routines one can access in order to decode GIF file: * +* (GIF_LIB file DGIF_LIB.C). * +******************************************************************************/ + +GifFileType *DGifOpenFileName(const char *GifFileName); +GifFileType *DGifOpenFileHandle(FILE *FileHandle); +GifFileType *DGifOpen( void* userPtr, InputFunc readFunc ); /* new one (TVT) */ +int DGifSlurp(GifFileType *GifFile); +int DGifGetScreenDesc(GifFileType *GifFile); +int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType); +int DGifGetImageDesc(GifFileType *GifFile); +int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); +int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel); +int DGifGetComment(GifFileType *GifFile, char *GifComment); +int DGifGetExtension(GifFileType *GifFile, int *GifExtCode, + GifByteType **GifExtension); +int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension); +int DGifGetCode(GifFileType *GifFile, int *GifCodeSize, + GifByteType **GifCodeBlock); +int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock); +int DGifGetLZCodes(GifFileType *GifFile, int *GifCode); +int DGifCloseFile(GifFileType *GifFile); + +#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */ +#define D_GIF_ERR_READ_FAILED 102 +#define D_GIF_ERR_NOT_GIF_FILE 103 +#define D_GIF_ERR_NO_SCRN_DSCR 104 +#define D_GIF_ERR_NO_IMAG_DSCR 105 +#define D_GIF_ERR_NO_COLOR_MAP 106 +#define D_GIF_ERR_WRONG_RECORD 107 +#define D_GIF_ERR_DATA_TOO_BIG 108 +#define D_GIF_ERR_NOT_ENOUGH_MEM 109 +#define D_GIF_ERR_CLOSE_FAILED 110 +#define D_GIF_ERR_NOT_READABLE 111 +#define D_GIF_ERR_IMAGE_DEFECT 112 +#define D_GIF_ERR_EOF_TOO_SOON 113 + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file QUANTIZE.C. * +******************************************************************************/ +int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize, + GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput, + GifByteType *OutputBuffer, GifColorType *OutputColorMap); + + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file QPRINTF.C. * +******************************************************************************/ +extern int GifQuietPrint; + +#ifdef HAVE_VARARGS_H +extern void GifQprintf(); +#else +extern void GifQprintf(char *Format, ...); +#endif /* HAVE_VARARGS_H */ + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file GIF_ERR.C. * +******************************************************************************/ +extern void PrintGifError(void); +extern int GifLastError(void); + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file DEV2GIF.C. * +******************************************************************************/ +extern int DumpScreen2Gif(const char *FileName, + int ReqGraphDriver, + int ReqGraphMode1, + int ReqGraphMode2, + int ReqGraphMode3); + +/***************************************************************************** + * + * Everything below this point is new after version 1.2, supporting `slurp + * mode' for doing I/O in two big belts with all the image-bashing in core. + * + *****************************************************************************/ + +/****************************************************************************** +* Color Map handling from ALLOCGIF.C * +******************************************************************************/ + +extern ColorMapObject *MakeMapObject(int ColorCount, const GifColorType *ColorMap); +extern void FreeMapObject(ColorMapObject *Object); +extern ColorMapObject *UnionColorMap( + const ColorMapObject *ColorIn1, + const ColorMapObject *ColorIn2, + GifPixelType ColorTransIn2[]); +extern int BitSize(int n); + +/****************************************************************************** +* Support for the in-core structures allocation (slurp mode). * +******************************************************************************/ + +/* This is the in-core version of an extension record */ +typedef struct { + int ByteCount; + char *Bytes; /* on malloc(3) heap */ + int Function; /* Holds the type of the Extension block. */ +} ExtensionBlock; + +/* This holds an image header, its unpacked raster bits, and extensions */ +typedef struct SavedImage { + GifImageDesc ImageDesc; + + char *RasterBits; /* on malloc(3) heap */ + + int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function + * instead */ + int ExtensionBlockCount; + ExtensionBlock *ExtensionBlocks; /* on malloc(3) heap */ +} SavedImage; + +extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]); + +extern void MakeExtension(SavedImage *New, int Function); +extern int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]); +extern void FreeExtension(SavedImage *Image); + +extern SavedImage *MakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom); +extern void FreeSavedImages(GifFileType *GifFile); + +/****************************************************************************** +* The library's internal utility font * +******************************************************************************/ + +#define GIF_FONT_WIDTH 8 +#define GIF_FONT_HEIGHT 8 +extern unsigned char AsciiTable[][GIF_FONT_WIDTH]; + +extern void DrawText(SavedImage *Image, + const int x, const int y, + const char *legend, + const int color); + +extern void DrawBox(SavedImage *Image, + const int x, const int y, + const int w, const int d, + const int color); + +void DrawRectangle(SavedImage *Image, + const int x, const int y, + const int w, const int d, + const int color); + +extern void DrawBoxedText(SavedImage *Image, + const int x, const int y, + const char *legend, + const int border, + const int bg, + const int fg); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _GIF_LIB_H */ diff --git a/include/hid.h b/include/hid.h new file mode 100755 index 0000000..9f47587 --- /dev/null +++ b/include/hid.h @@ -0,0 +1,197 @@ +#ifndef __INCLUDED_HID_H__ +#define __INCLUDED_HID_H__ + +#include +#include +#include + +/*!@file + * @brief Main libhid API header file + * + * This header file forms the public API for libhid. Functions not prototyped + * here are most likely for internal use only, and may change without notice. + */ + +#ifndef byte + typedef unsigned char byte; +#endif + +#ifdef HAVE_STDBOOL_H +# include +#else +# define bool _Bool +# define true 1 +# define false 0 +#endif + +typedef enum hid_return_t { + HID_RET_SUCCESS = 0, + HID_RET_INVALID_PARAMETER, + HID_RET_NOT_INITIALISED, + HID_RET_ALREADY_INITIALISED, + HID_RET_FAIL_FIND_BUSSES, + HID_RET_FAIL_FIND_DEVICES, + HID_RET_FAIL_OPEN_DEVICE, + HID_RET_DEVICE_NOT_FOUND, + HID_RET_DEVICE_NOT_OPENED, + HID_RET_DEVICE_ALREADY_OPENED, + HID_RET_FAIL_CLOSE_DEVICE, + HID_RET_FAIL_CLAIM_IFACE, + HID_RET_FAIL_DETACH_DRIVER, + HID_RET_NOT_HID_DEVICE, + HID_RET_HID_DESC_SHORT, + HID_RET_REPORT_DESC_SHORT, + HID_RET_REPORT_DESC_LONG, + HID_RET_FAIL_ALLOC, + HID_RET_OUT_OF_SPACE, + HID_RET_FAIL_SET_REPORT, + HID_RET_FAIL_GET_REPORT, + HID_RET_FAIL_INT_READ, + HID_RET_NOT_FOUND, + HID_RET_TIMEOUT +} hid_return; + +struct usb_dev_handle; + +/*!@brief Interface description + * + * This structure contains information associated with a given USB device + * interface. The identification information allows multiple HID-class + * interfaces to be accessed on a single device. + * + * Also available are raw and parsed descriptor information. + */ +typedef struct HIDInterface_t { + struct usb_dev_handle *dev_handle; + struct usb_device *device; + int interface; + char id[32]; + HIDData* hid_data; + HIDParser* hid_parser; +} HIDInterface; + +typedef bool (*matcher_fn_t)(struct usb_dev_handle const* usbdev, + void* custom, unsigned int len); + +typedef struct HIDInterfaceMatcher_t { + unsigned short vendor_id; + unsigned short product_id; +#ifndef SWIG + matcher_fn_t matcher_fn; //!< Only supported in C library (not via SWIG) + void* custom_data; //!< Only used by matcher_fn + unsigned int custom_data_length; //!< Only used by matcher_fn +#endif +} HIDInterfaceMatcher; + +#define HID_ID_MATCH_ANY 0x0000 + +/*!@brief Bitmask for selection of debugging messages + * + * The values of this enumeration can be combined with the bitwise-OR operator + * to select which debug messages should be printed. The selection can be set + * with hid_set_debug(). You can set a file descriptor for error messages with + * hid_set_debug_stream(). + */ +typedef enum HIDDebugLevel_t { + HID_DEBUG_NONE = 0x0, //!< Default + HID_DEBUG_ERRORS = 0x1, //!< Serious conditions + HID_DEBUG_WARNINGS = 0x2, //!< Less serious conditions + HID_DEBUG_NOTICES = 0x4, //!< Informational messages + HID_DEBUG_TRACES = 0x8, //!< Verbose tracing of functions + HID_DEBUG_ASSERTS = 0x10, //!< Assertions for sanity checking + HID_DEBUG_NOTRACES = HID_DEBUG_ERRORS | HID_DEBUG_WARNINGS | HID_DEBUG_NOTICES | HID_DEBUG_ASSERTS, + //!< This is what you probably want to start with while developing with libhid + HID_DEBUG_ALL = HID_DEBUG_ERRORS | HID_DEBUG_WARNINGS | HID_DEBUG_NOTICES | HID_DEBUG_TRACES | HID_DEBUG_ASSERTS +} HIDDebugLevel; + +#ifdef __cplusplus +extern "C" { +#endif + +void hid_set_debug(HIDDebugLevel const level); +void hid_set_debug_stream(FILE* const outstream); +void hid_set_usb_debug(int const level); + +HIDInterface* hid_new_HIDInterface(); + +void hid_delete_HIDInterface(HIDInterface** const hidif); + +void hid_reset_HIDInterface(HIDInterface* const hidif); + +hid_return hid_init(); + +hid_return hid_cleanup(); + +bool hid_is_initialised(); + +hid_return hid_open(HIDInterface* const hidif, int const interface, + HIDInterfaceMatcher const* const matcher); +hid_return hid_force_open(HIDInterface* const hidif, int const interface, + HIDInterfaceMatcher const* const matcher, unsigned short retries); + +hid_return hid_close(HIDInterface* const hidif); + +bool hid_is_opened(HIDInterface const* const hidif); + +const char *hid_strerror(hid_return ret); + +hid_return hid_get_input_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char* const buffer, unsigned int const size); + +hid_return hid_set_output_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char const* const buffer, unsigned int const size); + +hid_return hid_get_feature_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char* const buffer, unsigned int const size); + +hid_return hid_set_feature_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char const* const buffer, unsigned int const size); + +hid_return hid_get_item_value(HIDInterface* const hidif, + int const path[], unsigned int const depth, + double *const value); + +/* +hid_return hid_get_item_string(HIDInterface* const hidif, + int const path[], unsigned int const depth, + char *const value, unsigned int const maxlen); + +hid_return hid_set_item_value(HIDInterface* const hidif, + int const path[], unsigned int const depth, + double const value); +*/ +hid_return hid_write_identification(FILE* const out, + HIDInterface const* const hidif); + +hid_return hid_dump_tree(FILE* const out, HIDInterface* const hidif); + +hid_return hid_interrupt_read(HIDInterface* const hidif, unsigned int const ep, + char* const bytes, unsigned int const size, unsigned int const timeout); + +hid_return hid_interrupt_write(HIDInterface* const hidif, unsigned int const ep, + const char* const bytes, unsigned int const size, unsigned int const timeout); + +hid_return hid_set_idle(HIDInterface * const hidif, + unsigned duration, unsigned report_id); + + +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDED_HID_H__ */ + +/* COPYRIGHT -- + * + * This file is part of libhid, a user-space HID access library. + * libhid is (c) 2003-2006 + * Martin F. Krafft + * Charles Lepple + * Arnaud Quette && + * and distributed under the terms of the GNU General Public License. + * See the file ./COPYING in the source distribution for more information. + * + * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES + * OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ diff --git a/include/hidparser.h b/include/hidparser.h new file mode 100755 index 0000000..612f59f --- /dev/null +++ b/include/hidparser.h @@ -0,0 +1,70 @@ +/*!@file + *@brief HID Parser header file + * + * This file is part of the MGE UPS SYSTEMS HID Parser. + * + * Copyright (C) 1998-2003 MGE UPS SYSTEMS, + * Written by Luc Descotils. + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* -------------------------------------------------------------------------- */ + +#ifndef HIDPARS_H +#define HIDPARS_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hidtypes.h" + +/* + * HIDParse + * -------------------------------------------------------------------------- */ +int HIDParse(HIDParser* pParser, HIDData* pData); + +/* + * ResetParser + * -------------------------------------------------------------------------- */ +void ResetParser(HIDParser* pParser); + +/* + * FindObject + * -------------------------------------------------------------------------- */ +int FindObject(HIDParser* pParser, HIDData* pData); + +/* + * GetValue + * -------------------------------------------------------------------------- */ +void GetValue(const uchar* Buf, HIDData* pData); + +/* + * SetValue + * -------------------------------------------------------------------------- */ +void SetValue(const HIDData* pData, uchar* Buf); + +/* + * GetReportOffset + * -------------------------------------------------------------------------- */ +uchar* GetReportOffset(HIDParser* pParser, const uchar ReportID, + const uchar ReportType); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif diff --git a/include/hidtypes.h b/include/hidtypes.h new file mode 100755 index 0000000..7b3fe77 --- /dev/null +++ b/include/hidtypes.h @@ -0,0 +1,157 @@ +/*!@file + *@brief HID parser type definitions + * + * Header GPL + * @todo Properly tag all files with GPL (as appropriate) + */ + +#ifndef TYPE_H +#define TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +/* + * Types + */ +#if !AIX +typedef unsigned char uchar; +#endif + +#if HPUX || __APPLE__ +typedef unsigned long ulong; +#endif + +typedef short wchar; + +/* + * Constants + */ +#define PATH_SIZE 10 /*!< maximum depth for Path */ +#define USAGE_TAB_SIZE 50 /*!< Size of usage stack */ + +/*! Including FEATURE, INPUT and OUTPUT */ +#define MAX_REPORT 300 + +/*! Size max of Report Descriptor */ +#define REPORT_DSC_SIZE 6144 + +/* + * Items + * -------------------------------------------------------------------------- */ +#define SIZE_0 0x00 +#define SIZE_1 0x01 +#define SIZE_2 0x02 +#define SIZE_4 0x03 +#define SIZE_MASK 0x03 + +#define TYPE_MAIN 0x00 +#define TYPE_GLOBAL 0x04 +#define TYPE_LOCAL 0x08 +#define TYPE_MASK 0x0C + +/* Main items */ +#define ITEM_COLLECTION 0xA0 +#define ITEM_END_COLLECTION 0xC0 +#define ITEM_FEATURE 0xB0 +#define ITEM_INPUT 0x80 +#define ITEM_OUTPUT 0x90 + +/* Global items */ +#define ITEM_UPAGE 0x04 +#define ITEM_LOG_MIN 0x14 +#define ITEM_LOG_MAX 0x24 +#define ITEM_PHY_MIN 0x34 +#define ITEM_PHY_MAX 0x44 +#define ITEM_UNIT_EXP 0x54 +#define ITEM_UNIT 0x64 +#define ITEM_REP_SIZE 0x74 +#define ITEM_REP_ID 0x84 +#define ITEM_REP_COUNT 0x94 + +/* Local items */ +#define ITEM_USAGE 0x08 +#define ITEM_STRING 0x78 + +/* Long item */ +#define ITEM_LONG 0xFC + +#define ITEM_MASK 0xFC + +/* Attribute Flags */ +#define ATTR_DATA_CST 0x01 +#define ATTR_NVOL_VOL 0x80 + +/*! + * Describe a HID Path point + */ +typedef struct +{ + ushort UPage; + ushort Usage; +} HIDNode; + +/*! + * Describe a HID Path + */ +typedef struct +{ + uchar Size; /*!< HID Path size */ + HIDNode Node[PATH_SIZE]; /*!< HID Path */ +} HIDPath; + +/*! + * Describe a HID Data with its location in report + */ +typedef struct +{ + long Value; /*!< HID Object Value */ + HIDPath Path; /*!< HID Path */ + + uchar ReportID; /*!< Report ID, (from incoming report) ??? */ + uchar Offset; /*!< Offset of data in report */ + uchar Size; /*!< Size of data in bit */ + + uchar Type; /*!< Type : FEATURE / INPUT / OUTPUT */ + uchar Attribute; /*!< Report field attribute */ + + ulong Unit; /*!< HID Unit */ + char UnitExp; /*!< Unit exponent */ + + long LogMin; /*!< Logical Min */ + long LogMax; /*!< Logical Max */ + long PhyMin; /*!< Physical Min */ + long PhyMax; /*!< Physical Max */ +} HIDData; + +/* -------------------------------------------------------------------------- */ +typedef struct +{ + uchar ReportDesc[REPORT_DSC_SIZE]; /*!< Store Report Descriptor */ + ushort ReportDescSize; /*!< Size of Report Descriptor */ + ushort Pos; /*!< Store current pos in descriptor */ + uchar Item; /*!< Store current Item */ + long Value; /*!< Store current Value */ + + HIDData Data; /*!< Store current environment */ + + uchar OffsetTab[MAX_REPORT][3]; /*!< Store ID, type & offset of report*/ + uchar ReportCount; /*!< Store Report Count */ + uchar Count; /*!< Store local report count */ + + ushort UPage; /*!< Global UPage */ + HIDNode UsageTab[USAGE_TAB_SIZE]; /*!< Usage stack */ + uchar UsageSize; /*!< Design number of usage used */ + + uchar nObject; /*!< Count objects in Report Descriptor */ + uchar nReport; /*!< Count reports in Report Descriptor */ +} HIDParser; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif diff --git a/include/irtrack.h b/include/irtrack.h new file mode 100755 index 0000000..9e130fe --- /dev/null +++ b/include/irtrack.h @@ -0,0 +1,364 @@ +// ------------------------------------------------------------------- +// irtrack.h +// +// 01.07.09 - (07/02/08) +// +// * removed non-essential messages from the system log +// +// * greater detail displayed for crc errors +// +// 01.07.08 - (06/30/08) +// +// * added code to discriminate between leds from different cabinets. +// +// 01.07.07 - (05/22/08) +// +// * the "danger zone" has been reset to the value before v01.07.05. +// +// * the amount of messages that are written to the system log have +// been reduced. +// +// 01.07.06 - (05/20/08) +// +// * there needs to be a minimum of three points in the camera's view +// for the system to generate a "too close" message. the previous +// limit was one. +// +// 01.07.05 - (05/14/08) +// +// * the "danger zone" has been reduced to zero. +// +// 01.07.03 - (04/28/08) +// +// * a new test has been added to the patternScan function which +// throws out groups that are not oriented in the way that we +// would expect if the gun is held upright. orientations that can +// occur only if the gun is held upside down are ignored. this is +// done to filter out potentially "bad" groups that are created when +// noise is present in the image. +// +// 01.07.02 - (04/23/08) +// +// * the "danger zone" around the edges of the camera's vision have +// been extended back to the previous level, making the system more +// "cautious" about what it looks at. +// +// * in the patternScan function, extra points for history matching +// are only assigned if a group has already scored a minimum of 0.85. +// this is to prevent very skewed trapezoids from passing the test +// if a few points happen to match history. +// +// 01.07.01 - (04/18/08) +// +// * irt_calc_all_boxes no longer includes any interpolated data if +// there is at least one full group of four that consists entirely +// of "real" data. this is done to keep bad interpolation from +// adding noise to an otherwise good gun coordinate +// +// * irt_calc_all_boxes keeps track of the coordinate where the player +// enters interpolated mode, and applies a 115% correction to the +// x coordinate to compensate for the "lag" that occurs when the +// player sweeps across the screen in interpolated mode. +// +// * the anti-lag projection system will now default back to the +// regular un-projected gun coordinate if the projected coordinate +// lands somewhere off-screen. +// +// ------------------------------------------------------------------- + +#ifndef _IRTRACK_H_ +#define _IRTRACK_H_ + +// ------------------------------------------------------------------- + +#define IRT_VERSION_MAJOR 1 +#define IRT_VERSION_MINOR 7 +#define IRT_VERSION_SUB 9 + +#define SERIAL_MAX_PLAYERS 8 + +// ------------------------------------------------------------------- + +#include + +// ------------------------------------------------------------------- + +typedef struct { + + float x, y, s; // x/y coordinates and point size + +} IrCoordType; + +typedef struct { + + IrCoordType crd; + int neighbors; // number of neighbor points + int *nPtr; // index list of each neighbor (index) + float *nDist; // distance to each neighbor + + int friends; // how many friends (close neighbor points) we have + int *fPtr; // index list of each friend + int groupNum; // what group are we in? + + int isNoise; // did this point fail the "history line" test? + float dp[2]; +} IrPointType; + +typedef struct { + + int id; // group id + int friends; // number of friends in the group + //int *fPtr; // index list to each friend + float x, y; // center point for this group + + float id_rx, id_ry; // real-world coordinates for this group + + int faked; // has this group been faked by interpolation? + int near_edge; // is this group near the edge of the screen? + + int rule; // what "rule" were we interpolated by? + +} IrPointGroupType; + +typedef struct { + float x, y; // screen coordinates + int age; // age in frames + int friends; // how many points in this group +} IrGroupTableType; + +typedef struct { + float x, y; + float angle; + clock_t timestamp; +} IrGunCoordType; + +typedef struct { + int id[4]; + float score; + float totalDev; + float minmax; +} IrSPCType; + +typedef struct { + int cx, cy; + float angle; + float dist; +} IrCalibType; + +typedef struct { + IrCoordType A, B; // endpoints of the line + int active; +} IrHistLineType; + +typedef struct { + int targetId; // what group id we are targeting + float x, y; // the offset between us and the target group + float max_x, max_y; + float min_x, min_y; +} IrGroupOffsetType; + +typedef struct { + float x, y; // screen coordinates + float ox, oy; // offset to partner group +} IrOSGridPointType; + +typedef int (slog_callback)(char *fmt, ...); + +// added 7-30-2008 KTU +typedef struct{ + int frames; + int glitches; + int pBlaze_wd; + int pBlaze_pc; + unsigned char stuckbits; + unsigned char version; +} IrGunStatus; + +// ------------------------------------------------------------------- + +#define IR_HIST_TABLE_SIZE 15 + +#define IR_GROUP_LEFT_EDGE 20 +#define IR_GROUP_RIGHT_EDGE 780 +#define IR_GROUP_TOP_EDGE 20 +#define IR_GROUP_BOTTOM_EDGE 580 + +#define IRT_AVG_DIST_THRESHOLD 0.15 +#define IRT_MIN_DIST_THRESHOLD 1.10 +#define IRT_MIN_DIST_LOWEST 20.0 + +// - how many candidates to consider in each run of the pattern +// scan function + +#define IRT_MAX_SP_CANDIDATES 8 + +enum { + IRT_GUN_0 = 0, + IRT_GUN_1, + IRT_GUN_2, + IRT_GUN_3, +}; + +// ------------------------------------------------------------------- +// - these calls should be all that you need to use to get gun data +// into your game + +int irt_systemInit(void); +void irt_systemClose(void); +void irt_systemSetThreadEnable(int state); +void irt_systemLoop(int gindex); +void irt_systemGetCoords(int gindex, float *x, float *y); +void irt_systemGetLatestCoords(int gindex, float *x, float *y); + +void irt_systemGetScaledCoords(int gindex, float *x, float *y); + +//void irt_systemGetProjectedCoords(int gindex, float *x, float *y); +void irt_systemGetProjectedCoords(int gindex, float *x, float *y, int markDirty); + +clock_t irt_systemGetTimeStamp(int gindex); +clock_t irt_systemGetTimeStampDiff(int gindex); + +void irt_systemSetGunCalib(int pnum, int xoffset, int yoffset); +void irt_systemGetGunCalib(int pnum, int *xoffset, int *yoffset); +void irt_systemGunCalib(int gindex); + +void irt_systemSaveCalibration(int gindex, char *filename); +void irt_systemLoadCalibration(int gindex, char *filename); +void irt_systemClearCalibration(int gindex); + +void irt_systemSetYOffset(int gindex, int pindex); +void irt_systemSetYOffsetVal(int gindex, int pindex, float val); +float irt_systemGetYOffset(int gindex, int pindex); + +void irt_systemGetXPM(int gindex, int pindex, float *x, float *y); +float irt_systemGetXPMAngle(int gindex); +float irt_systemGetXPMDist(int gindex); + +// MODIFIED 7-29-2008 KTU +//void irt_systemSetFirmware(int mcuL, int mcuH, int fpgaL, int fpgaH); +//void irt_systemGetFirmware(int *mcuL, int *mcuH, int *fpgaL, int *fpgaH); +void irt_systemSetFirmware(int fpga, int player); +void irt_systemGetFirmware(int *fpga, int player); +void irt_systemGetGunStatus(int gindex, IrGunStatus *gun_stat); +void irt_systemClearGunStatus(int gindex); + +void irt_systemSendUpdateMSG(void); + +void irt_systemSetMarqueeState(int state); + +void irt_systemGetVisibleGroups(int gindex, int *vgroup); + +void irt_systemGetPlayerPosition(int gindex, float *angle, float *dist); + +void irt_systemGetPositionCal(int gindex, int *xoffset, int *yoffset); + +int irt_systemGetTrigger(int gindex); +int irt_systemGetTriggerState(int gindex); +int irt_systemGetPump(int gindex); +int irt_systemGetPumpRelease(int gindex); + +char *irt_systemGetVer(void); + +int irt_dbgGetPointList(int gindex, float *fptr); +int irt_dbgGetGroupList(int gindex, float *fptr); + +void irt_cal_gundisp(int gindex, int type); + +void irt_systemSetSLogCB(slog_callback *func); +void irt_systemSLog(char *fmt,...); + +void _irt_getOffsetTableData(int gindex, int index, float *x, float *y, float *minMax); +void _irt_insertOffsetTableData(int gindex, int gid, int target, float x, float y); + +int irt_systemShouldRestart(void); + +void irt_systemSetRegisterStatus(unsigned char *reg_fpga, unsigned char *reg_cam, int player); + +int irt_systemDetectGWB(void); + +int irt_systemGetGunActive(int gindex); + +//void irt_systemRequestFirmware(void); -- depricated 7-29-2008 KTU + +void irt_systemSetSentCamRegisters(char *buf); +int irt_systemGetCamRegisterState(int gindex); + +float irt_systemGetAvgFriendDistance(int gindex); + +void irt_systemReverseInput(void); + +int irt_systemGetConnectionStatus(int gindex); + +int irt_systemGetSerialErrStatus(void); + +int irt_systemIsPlayerOffscreen(int gindex); + +// ------------------------------------------------------------------- + +void irt_genCoords(int *numCoords, IrCoordType *crdPtr); + +void irt_getPointsFromCoords(int numCoords, IrCoordType *crdPtr, IrPointType *ptPtr, int gindex); + +void irt_destroyPointList(int gindex); + +void irt_getGroupsFromPoints(int gun_index); + +float irt_getDistance(IrCoordType c1, IrCoordType c2); + +int irt_getGroupData(int gindex, int group, float *x, float *y); + +IrPointGroupType *irt_getGroupById(int gindex, int idnum); + +int irt_getNumGroups(int gindex); + +IrPointGroupType* irt_getGroupNum(int gindex, int gnum); + +int irt_groupAssign(int gindex, int oldnum, int newnum); + +void irt_destroyGroupList(int gindex); + +void irt_groupHistoryAssign(int gindex, int markFakes); +void irt_groupHistoryCompensate(int gindex); +void irt_groupTableUpdate(int gindex, IrPointGroupType *g); +void irt_groupTableTick(void); +void irt_groupInterpolateBlanks(int gindex); + +void irt_genCoordsFromImg(int w, int h, int bpp, void *pixels); + +float irt_getAverageDist(void); + +int irt_getNumPoints(int gindex); + +IrPointType *irt_getPointNum(int gindex, int pnum); + +void test_createCoordsFromLeds(int gindex); + +int irt_scanPattern(int gindex, int *psearch, int *pid, int distcheck); +int irt_scan3Pattern(int gindex, int *psearch, int *pid); + +int irt_calcBiggestBox(int gun_index, float cx, float cy, float *x, float *y, int useFake); +int irt_calcBiggestBox2(int gindex, float cx, float cy, float *x, float *y); + +void irt_estimatePlayerPosition(int gindex); + +void irt_cal_gun(int gindex, int *ox, int *oy); + +//void irt_point_transform(CvMat hmat, double *p_in, double *p_out); + +void irt_loop_thread(void *ptr); + +void irt_calc_all_boxes(int gindex, int cx, int cy, float *ftable); + +void irt_discriminateFriends(int gindex); + +void irt_assignHistoryLines(int gindex); +void irt_getHistoryLineData(int gindex, int lindex, int *ax, int *ay, int *bx, int *by); +void irt_discriminatePoints(int gindex); + +void irt_updateGroupOffsetTable(int gindex); +void irt_enforceGroupOffsetTable(int gindex); + +// ------------------------------------------------------------------- + +#endif + diff --git a/include/jamma.h b/include/jamma.h new file mode 100755 index 0000000..7b7fe59 --- /dev/null +++ b/include/jamma.h @@ -0,0 +1,277 @@ +#ifndef JAMMA_H +#define JAMMA_H +// jamma.h + +#define JAMMA_VER_STRING "24" + +#define JAMMA_GUNS 2 // number of supported guns +#define JAMMA_TICKETS 1 // number of supported ticket dispensers + +#define M_JAMMASW_GUN1_TRIG1 0x00000001 // order must match JAMMASW_ +#define M_JAMMASW_GUN2_TRIG1 0x00000002 +#define M_JAMMASW_GUN1_TRIG2 0x00000004 +#define M_JAMMASW_GUN2_TRIG2 0x00000008 +#define M_JAMMASW_P1_START 0x00000010 +#define M_JAMMASW_P2_START 0x00000020 +#define M_JAMMASW_COIN1 0x00000040 +#define M_JAMMASW_COIN2 0x00000080 +#define M_JAMMASW_BILL 0x00000100 +#define M_JAMMASW_SERVICE 0x00000200 +#define M_JAMMASW_TEST 0x00000400 +#define M_JAMMASW_VOLUP 0x00000800 +#define M_JAMMASW_VOLDOWN 0x00001000 +#define M_JAMMASW_USBPOWER 0x00002000 +#define M_JAMMASW_TBALL_X 0x00004000 +#define M_JAMMASW_TBALL_Y 0x00008000 +#define M_JAMMASW_TILT 0x00010000 + +#define M_JAMMADIP_DIP 0x000000ff // dip switch data mask +#define M_JAMMADIP_VALID 0x00010000 // dip switch data valid +#define M_JAMMADIP_SPECIAL_VALID 0x00020000 // special bits are valid +#define M_JAMMADIP_SPECIAL_WATCHDOG 0x00040000 // watchdog detected +#define M_JAMMADIP_SPECIAL_USER 0x00080000 // user bit (jamma resets) + +// Raw switch bits from I/O board +#define M_JAMMASWBIT 0x00ffffff // switch bit data mask +#define M_JAMMASWBIT_GUN2_TRIG1 0x00000001 // gun 2, trigger 1 +#define M_JAMMASWBIT_GUN1_TRIG1 0x00000002 // gun 1, trigger 1 +#define M_JAMMASWBIT_GUN2_SPARE 0x00000004 // gun 2, spare +#define M_JAMMASWBIT_GUN1_SPARE 0x00000008 // gun 1, spare +#define M_JAMMASWBIT_GUN2_TRIG2 0x00000010 // gun 2, trigger 2 (reload) +#define M_JAMMASWBIT_GUN1_TRIG2 0x00000020 // gun 1, trigger 2 (reload) +#define M_JAMMASWBIT_UNUSED1 0x00000040 // currently unused +#define M_JAMMASWBIT_UNUSED2 0x00000080 // currently unused +#define M_JAMMASWBIT_COIN1 0x00000100 // coin switch 1 (left) +#define M_JAMMASWBIT_START1 0x00000200 // player 1 start button +#define M_JAMMASWBIT_COIN2 0x00000400 // coin switch 2 (right) +#define M_JAMMASWBIT_START2 0x00000800 // player 2 start button +#define M_JAMMASWBIT_TILT 0x00001000 // tilt switch +#define M_JAMMASWBIT_SERVICE 0x00002000 // service switch +#define M_JAMMASWBIT_TEST 0x00004000 // test switch +#define M_JAMMASWBIT_CSYNCPOL 0x00008000 // composite sync polarity +#define M_JAMMASWBIT_P2B4 0x00010000 // player 2, button 4 +#define M_JAMMASWBIT_VOLDN 0x00020000 // volume down +#define M_JAMMASWBIT_P2B2 0x00040000 // player 2, button 2 +#define M_JAMMASWBIT_P2B1 0x00080000 // player 2, button 1 +#define M_JAMMASWBIT_BILL 0x00100000 // bill acceptor input +#define M_JAMMASWBIT_VOLUP 0x00200000 // volume up +#define M_JAMMASWBIT_P1B2 0x00400000 // player 1, button 2 +#define M_JAMMASWBIT_P1B1 0x00800000 // player 1, button 1 +#define M_JAMMASWBIT_VALID 0x10000000 // flag, switch register data is valid + + +enum { + JAMMAEVENT_NONE, + JAMMAEVENT_SWITCHES, // unsigned int switches +}; + +#define M_JAMMAEVENT 0xff + +enum { + JAMMASW_NONE, + JAMMASW_GUN1_TRIG1, // order must match M_JAMMASW_ + JAMMASW_GUN2_TRIG1, // order assumed + JAMMASW_GUN1_TRIG2, // order assumed + JAMMASW_GUN2_TRIG2, // order assumed + JAMMASW_P1_START, + JAMMASW_P2_START, + JAMMASW_COIN1, + JAMMASW_COIN2, + JAMMASW_BILL, + JAMMASW_SERVICE, + JAMMASW_TEST, + JAMMASW_VOLUP, + JAMMASW_VOLDOWN, + JAMMASW_USBPOWER, + JAMMASW_TBALL_X, + JAMMASW_TBALL_Y, + JAMMASW_TILT, + // -- beyond physical switches + JAMMASW_GUN1XYTRIG, // order assumed + JAMMASW_GUN2XYTRIG, // order assumed + JAMMASW_NUM +}; + +typedef struct { + unsigned int dipstate; + unsigned int swprev; + unsigned int swstate; + unsigned int swcount[JAMMASW_NUM]; + unsigned char swoff[JAMMASW_NUM]; + unsigned char swlast[JAMMASW_NUM]; + int xy[2*JAMMA_GUNS]; + int snr[2*JAMMA_GUNS]; +} JammaInpRec; + +enum { + JAMMAOP_NONE, + JAMMAOP_GETDIPSWITCHES, // unsigned int dipswitch register M_JAMMADIP_ + JAMMAOP_GETINPREC, // void **jir + JAMMAOP_RESET, + JAMMAOP_RCVBIN, + JAMMAOP_RCVASCII, + JAMMAOP_SETCALLBACK, // int func(int op,...); + JAMMAOP_RECONFIG, + JAMMAOP_SENDBUF, + JAMMAOP_GETVERSTRING, // char *buf,int bufsize + JAMMAOP_GETTICK, // unsigned long *tickp + JAMMAOP_SETCALIBLTRB, // int,int,int,int + JAMMAOP_SETCALIBMODE, // int + JAMMAOP_SETSCRWH, // float,float + JAMMAOP_SETCHARPKTMODE, // int + JAMMAOP_WATCHDOGBONE, + JAMMAOP_GUNONOFF, // int gun,int onoff + JAMMAOP_STARTLIGHTONOFF, // int light, int onoff + JAMMAOP_GETSWCOUNT, // uns *changedmaskp,uns **swcountsp + JAMMAOP_GETSWSTATES, + JAMMAOP_DONTSENDBONE, // int + JAMMAOP_COINMETERINC, // int meter,int num + JAMMAOP_SETCALIBGSXYXYDXYXY, // // int, int,int,int,int, int,int, int,int + JAMMAOP_GETSN, + JAMMAOP_SETCALIBGLTRB, // int,int,int,int,int + JAMMAOP_SETCALIBGMODE, // int,int + JAMMAOP_REQUESTCOUNTS, + JAMMAOP_REQUESTCONFIG, + JAMMAOP_REQUESTVERSION, + JAMMAOP_WATCHLIGHTSONOFF, // int + JAMMAOP_WHITEFLASH_VFB_HFB, // int,int,int,int + JAMMAOP_WATCHDOGBONE_SETCLICKPERIOD, // unsigned -- use JAMMAWATCHDOG_CLICKS_PER_MINUTE + JAMMAOP_WATCHDOGBONE_SETSENDMILLISECONDS, // unsigned + JAMMAOP_GETSTARTLIGHTSTATES, // unsigned char *mask + JAMMAOP_SETIOMODE, // uns + JAMMAOP_TICKETINC, // int ticket dispenser, int count + JAMMAOP_HICURRENTONOFF, // int hi current, int onoff + JAMMAOP_TICKETONOFF, // int hi current, int onoff + JAMMAOP_GETHWVERNUM, // returns Hardware version number + JAMMAOP_GETFWVERNUM, // returns Firmware version number + JAMMAOP_SETTICKETPOLARITY, // uns (0 = lo/hi, !0 = hi/lo) + JAMMAOP_TICKETCLEAR, // clear out ticket logic for given dispenser + JAMMAOP_GUNVERBOSEONOFF, // int onoff, turn verbose data on or off + JAMMAOP_GUNAUTOONOFF, // int gun,int onoff + JAMMAOP_SWBITCALLBACKONOFF, // int + JAMMAOP_TICKETSET, // int ticket dispenser, int count + JAMMAOP_GETERRORF, // returns jdev error flags + JAMMAOP_GETUSBWDVERNUM, // returns USB Watchdog version number + JAMMAOP_ISUSBWDPRESENT, // returns FALSE = no, TRUE = yes + JAMMAOP_ISFIRMWAREUPTODATE, // returns FALSE = no, TRUE = yes +}; + +#define JAMMAWATCHDOG_CLICKS_PER_MINUTE 15 +#define JAMMAWATCHDOG_CLICKS_GAME_OPERATION 3 //clicks for safe game operation + +#define M_JAMMAOP 0xff +#define M_JAMMAOP_CLEAR 0x100 //used with JAMMAOP_GETSWCOUNT to clear swchanged status +#define M_JAMMAOP_IGNORECHANGED 0x200 //used with JAMMAOP_GETSWCOUNT ignore swchanged status + +// +// JAMMAIOMODE_ +// current mode for I/O operation +// +enum +{ + JAMMAIOMODE_BBH, // Big Buck Hunter (default) + JAMMAIOMODE_SBB, // Sponge Bob Bowling + NUM_JAMMAIOMODE +}; + +// ---- ---- cccc cccc +// tttt pppp cccc cccc +// c=callback op +// -- other bits can be overloaded -- +// p=player +// t=trigger +#define M_JAMMACALLBACK 0x00ff +#define M_JAMMACALLBACK_PL 0x0f +#define S_JAMMACALLBACK_PL 8 +#define M_JAMMACALLBACK_TR 0x0f +#define S_JAMMACALLBACK_TR 10 +enum { + JAMMACALLBACK_GUNXY=1, // int x,int y + JAMMACALLBACK_RCVBIN, // unsigned char *buf,int len + JAMMACALLBACK_RCVASCII,// unsigned char *buf,int len + JAMMACALLBACK_RCVCHARPKT,// unsigned char *buf,int len + JAMMACALLBACK_STATUS, // unsigned char *buf,int len + JAMMACALLBACK_MESSAGE, // char *buf, int len + JAMMACALLBACK_USERBIT, // int changedonoff + JAMMACALLBACK_TICKET, // int JAMMATICKET_, int arg + JAMMACALLBACK_GUNXYNOTRIGGER, // int x,int y,float snr + JAMMACALLBACK_SWBIT, // int M_JAMMASWBIT_, int M_JAMMADIP_ (must be enabled by JAMMAOP_SWBITCALLBACKONOFF) + JAMMACALLBACK_WATCHDOGCOMING, // +}; + +// +// JAMMATICKET_ +// passed with JAMMACALLBACK_TICKET +// +enum +{ + JAMMATICKET_DONE, + JAMMATICKET_CONTINUING, + JAMMATICKET_ERROR, +}; + +// +// JAMMAFWID_ +// jamma Firmware identifier +// +#define M_JAMMAFWID 0xf0 // mask for Firmware ID +#define JAMMAFWID_BBH 0x00 // Big Buck Hunter Pro +#define JAMMAFWID_SBB 0x50 // Spongebob Bowling + +// +// JAMMAFWVER_ +// current latest jamma Firmware version +// +#define M_JAMMAFWVER 0x0f // mask for Firmware ID +#define JAMMAFWVER_BBH 0x07 // Big Buck Hunter Pro +#define JAMMAFWVER_SBB 0x09 // Spongebob Bowling + +// +// use this when capturing sample data in app +// +#define JAMMA_MAX_GUN_SAMPLES 64 // max gun samples reported per message + +/////////////////////////////////////////////////////////////////////////////// +// ERROR CODES +/////////////////////////////////////////////////////////////////////////////// +// +// ERRORS & EXTENDED RETURN CODES +// +// -1.....-8999 user +// -9000..-9099 system +// +enum // int16 +{ + // system + ERR_JAMMA_SYS_LAST=-9099, + ERR_JAMMA_DEVICE_NOTAVAILABLE, + ERR_JAMMA_IOPORT_OPEN, + ERR_JAMMA_IOPORT_STATE, + ERR_JAMMA_IOPORT_SETTINGS, + ERR_JAMMA_IOPORT_TIMEOUTS, + ERR_JAMMA_IOPORT_THREAD, + ERR_JAMMA_IOPORT_OVERFLOW, + ERR_JAMMA_MEM, + ERR_JAMMA_SWITCHDATA_NOTVALID, + ERR_JAMMA_SWITCHDATA_UNCHANGED, + ERR_JAMMA_OP_NOTRECOGNIZED, + ERR_JAMMA_SYS_FIRST=-9000, + +}; // ERR_ + + +extern int JammaInit(void); +extern void JammaFinal(void); +extern int JammaLoop(void); +extern int JammaOp(unsigned int op,...); + +// apphook +extern void* jamma_apphook_malloc(int size); +extern void jamma_apphook_free(void *m); +extern void jamma_apphook_msg(char *fmt,...); + +/// FUNCTIONS + +#endif // ndef JAMMA_H + +// EOF diff --git a/include/jconfig.h b/include/jconfig.h new file mode 100755 index 0000000..2f4da14 --- /dev/null +++ b/include/jconfig.h @@ -0,0 +1,45 @@ +/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not int, per Windows custom */ +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ + + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Microsoft has setmode() */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/include/jmorecfg.h b/include/jmorecfg.h new file mode 100755 index 0000000..2a9a345 --- /dev/null +++ b/include/jmorecfg.h @@ -0,0 +1,363 @@ +/* + * jmorecfg.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains additional configuration options that customize the + * JPEG software for special applications or support machine-dependent + * optimizations. Most users will not need to touch this file. + */ + + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 12 for 12-bit sample values + * Only 8 and 12 are legal data precisions for lossy JPEG according to the + * JPEG standard, and the IJG code does not support anything else! + * We do not support run-time selection of data precision, sorry. + */ + +#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ + + +/* + * Maximum number of components (color channels) allowed in JPEG image. + * To meet the letter of the JPEG spec, set this to 255. However, darn + * few applications need more than 4 channels (maybe 5 for CMYK + alpha + * mask). We recommend 10 as a reasonable compromise; use 4 if you are + * really short on memory. (Each allowed component costs a hundred or so + * bytes of storage, whether actually used in an image or not.) + */ + +#define MAX_COMPONENTS 10 /* maximum number of image components */ + + +/* + * Basic data types. + * You may need to change these if you have a machine with unusual data + * type sizes; for example, "char" not 8 bits, "short" not 16 bits, + * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, + * but it had better be at least 16. + */ + +/* Representation of a single sample (pixel element value). + * We frequently allocate large arrays of these, so it's important to keep + * them small. But if you have memory to burn and access to char or short + * arrays is very slow on your hardware, you might want to change these. + */ + +#if BITS_IN_JSAMPLE == 8 +/* JSAMPLE should be the smallest type that will hold the values 0..255. + * You can use a signed char by having GETJSAMPLE mask it with 0xFF. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JSAMPLE; +#ifdef CHAR_IS_UNSIGNED +#define GETJSAMPLE(value) ((int) (value)) +#else +#define GETJSAMPLE(value) ((int) (value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + +#define MAXJSAMPLE 255 +#define CENTERJSAMPLE 128 + +#endif /* BITS_IN_JSAMPLE == 8 */ + + +#if BITS_IN_JSAMPLE == 12 +/* JSAMPLE should be the smallest type that will hold the values 0..4095. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 4095 +#define CENTERJSAMPLE 2048 + +#endif /* BITS_IN_JSAMPLE == 12 */ + + +/* Representation of a DCT frequency coefficient. + * This should be a signed value of at least 16 bits; "short" is usually OK. + * Again, we allocate large arrays of these, but you can change to int + * if you have memory to burn and "short" is really slow. + */ + +typedef short JCOEF; + + +/* Compressed datastreams are represented as arrays of JOCTET. + * These must be EXACTLY 8 bits wide, at least once they are written to + * external storage. Note that when using the stdio data source/destination + * managers, this is also the data type passed to fread/fwrite. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JOCTET; +#define GETJOCTET(value) (value) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JOCTET; +#ifdef CHAR_IS_UNSIGNED +#define GETJOCTET(value) (value) +#else +#define GETJOCTET(value) ((value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + + +/* These typedefs are used for various table entries and so forth. + * They must be at least as wide as specified; but making them too big + * won't cost a huge amount of memory, so we don't provide special + * extraction code like we did for JSAMPLE. (In other words, these + * typedefs live at a different point on the speed/space tradeoff curve.) + */ + +/* UINT8 must hold at least the values 0..255. */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char UINT8; +#else /* not HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char UINT8; +#else /* not CHAR_IS_UNSIGNED */ +typedef short UINT8; +#endif /* CHAR_IS_UNSIGNED */ +#endif /* HAVE_UNSIGNED_CHAR */ + +/* UINT16 must hold at least the values 0..65535. */ + +#ifdef HAVE_UNSIGNED_SHORT +typedef unsigned short UINT16; +#else /* not HAVE_UNSIGNED_SHORT */ +typedef unsigned int UINT16; +#endif /* HAVE_UNSIGNED_SHORT */ + +/* INT16 must hold at least the values -32768..32767. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ +typedef short INT16; +#endif + +/* INT32 must hold at least signed 32-bit values. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +typedef int INT32; +#endif + +/* Datatype used for image dimensions. The JPEG standard only supports + * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + * "unsigned int" is sufficient on all machines. However, if you need to + * handle larger images and you don't mind deviating from the spec, you + * can change this datatype. + */ + +typedef unsigned int JDIMENSION; + +#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ + + +/* These macros are used in all function definitions and extern declarations. + * You could modify them if you need to change function linkage conventions; + * in particular, you'll need to do that to make the library a Windows DLL. + * Another application is to make all functions global for use with debuggers + * or code profilers that require it. + */ + +/* a function called through method pointers: */ +#define METHODDEF(type) static type +/* a function used only in its module: */ +#define LOCAL(type) static type +/* a function referenced thru EXTERNs: */ +#define GLOBAL(type) type +/* a reference to a GLOBAL function: */ +#define EXTERN(type) extern type + + +/* This macro is used to declare a "method", that is, a function pointer. + * We want to supply prototype parameters if the compiler can cope. + * Note that the arglist parameter must be parenthesized! + * Again, you can customize this if you need special linkage keywords. + */ + +#ifdef HAVE_PROTOTYPES +#define JMETHOD(type,methodname,arglist) type (*methodname) arglist +#else +#define JMETHOD(type,methodname,arglist) type (*methodname) () +#endif + + +/* Here is the pseudo-keyword for declaring pointers that must be "far" + * on 80x86 machines. Most of the specialized coding for 80x86 is handled + * by just saying "FAR *" where such a pointer is needed. In a few places + * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. + */ + +#ifdef NEED_FAR_POINTERS +#define FAR far +#else +#define FAR +#endif + + +/* + * On a few systems, type boolean and/or its values FALSE, TRUE may appear + * in standard header files. Or you may have conflicts with application- + * specific header files that you want to include together with these files. + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +#ifndef HAVE_BOOLEAN +typedef int boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif + + +/* + * The remaining options affect code selection within the JPEG library, + * but they don't need to be visible to most applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. + */ + +#ifdef JPEG_INTERNALS +#define JPEG_INTERNAL_OPTIONS +#endif + +#ifdef JPEG_INTERNAL_OPTIONS + + +/* + * These defines indicate whether to include various optional functions. + * Undefining some of these symbols will produce a smaller but less capable + * library. Note that you can leave certain source files out of the + * compilation/linking process if you've #undef'd the corresponding symbols. + * (You may HAVE to do that if your compiler doesn't like null source files.) + */ + +/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ + +/* Capability options common to encoder and decoder: */ + +#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ +#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ +#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ + +/* Encoder capability options: */ + +#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ +/* Note: if you selected 12-bit data precision, it is dangerous to turn off + * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit + * precision, so jchuff.c normally uses entropy optimization to compute + * usable tables for higher precision. If you don't want to do optimization, + * you'll have to supply different default Huffman tables. + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + +/* Decoder capability options: */ + +#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ +#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ +#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + +/* more capability options later, no doubt */ + + +/* + * Ordering of RGB data in scanlines passed to or from the application. + * If your application wants to deal with data in the order B,G,R, just + * change these macros. You can also deal with formats such as R,G,B,X + * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing + * the offsets will also change the order in which colormap data is organized. + * RESTRICTIONS: + * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. + * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not + * useful if you are using JPEG color spaces other than YCbCr or grayscale. + * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE + * is not 3 (they don't understand about dummy color components!). So you + * can't use color quantization if you change that value. + */ + +#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ +#define RGB_GREEN 1 /* Offset of Green */ +#define RGB_BLUE 2 /* Offset of Blue */ +#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ + + +/* Definitions for speed-related optimizations. */ + + +/* If your compiler supports inline functions, define INLINE + * as the inline keyword; otherwise define it as empty. + */ + +#ifndef INLINE +#ifdef __GNUC__ /* for instance, GNU C knows about inline */ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE /* default is to define it as empty */ +#endif +#endif + + +/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying + * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER + * as short on such a machine. MULTIPLIER must be at least 16 bits wide. + */ + +#ifndef MULTIPLIER +#define MULTIPLIER int /* type for fastest integer multiply */ +#endif + + +/* FAST_FLOAT should be either float or double, whichever is done faster + * by your compiler. (Note that this type is only used in the floating point + * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) + * Typically, float is faster in ANSI C compilers, while double is faster in + * pre-ANSI compilers (because they insist on converting to double anyway). + * The code below therefore chooses float if we have ANSI-style prototypes. + */ + +#ifndef FAST_FLOAT +#ifdef HAVE_PROTOTYPES +#define FAST_FLOAT float +#else +#define FAST_FLOAT double +#endif +#endif + +#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/include/jpeglib.h b/include/jpeglib.h new file mode 100755 index 0000000..04cd066 --- /dev/null +++ b/include/jpeglib.h @@ -0,0 +1,1098 @@ +/* + * jpeglib.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the application interface for the JPEG library. + * Most applications using the library need only include this file, + * and perhaps jerror.h if they want to know the exact error codes. + */ + +#ifndef JPEGLIB_H +#define JPEGLIB_H + +/* + * First we include the configuration files that record how this + * installation of the JPEG library is set up. jconfig.h can be + * generated automatically for many systems. jmorecfg.h contains + * manual configuration options that most people need not worry about. + */ + +#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ +#include "jconfig.h" /* widely used configuration options */ +#endif +#include "jmorecfg.h" /* seldom changed options */ + + +/* Version ID for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". + */ + +#define JPEG_LIB_VERSION 62 /* Version 6b */ + + +/* Various constants determining the sizes of things. + * All of these are specified by the JPEG standard, so don't change them + * if you want to be compatible. + */ + +#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ +#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ +#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ +#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ +#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ +#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ +#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ +/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; + * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. + * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU + * to handle it. We even let you do this from the jconfig.h file. However, + * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe + * sometimes emits noncompliant files doesn't mean you should too. + */ +#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ +#ifndef D_MAX_BLOCKS_IN_MCU +#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ +#endif + + +/* Data structures for images (arrays of samples and of DCT coefficients). + * On 80x86 machines, the image arrays are too big for near pointers, + * but the pointer arrays can fit in near memory. + */ + +typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ +typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ + +typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ +typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ +typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ + +typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ + + +/* Types for JPEG compression parameters and working tables. */ + + +/* DCT coefficient quantization tables. */ + +typedef struct { + /* This array gives the coefficient quantizers in natural array order + * (not the zigzag order in which they are stored in a JPEG DQT marker). + * CAUTION: IJG versions prior to v6a kept this array in zigzag order. + */ + UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JQUANT_TBL; + + +/* Huffman coding tables. */ + +typedef struct { + /* These two fields directly represent the contents of a JPEG DHT marker */ + UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ + /* length k bits; bits[0] is unused */ + UINT8 huffval[256]; /* The symbols, in order of incr code length */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JHUFF_TBL; + + +/* Basic info about one component (color channel). */ + +typedef struct { + /* These values are fixed over the whole image. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOF marker. */ + int component_id; /* identifier for this component (0..255) */ + int component_index; /* its index in SOF or cinfo->comp_info[] */ + int h_samp_factor; /* horizontal sampling factor (1..4) */ + int v_samp_factor; /* vertical sampling factor (1..4) */ + int quant_tbl_no; /* quantization table selector (0..3) */ + /* These values may vary between scans. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOS marker. */ + /* The decompressor output side may not use these variables. */ + int dc_tbl_no; /* DC entropy table selector (0..3) */ + int ac_tbl_no; /* AC entropy table selector (0..3) */ + + /* Remaining fields should be treated as private by applications. */ + + /* These values are computed during compression or decompression startup: */ + /* Component's size in DCT blocks. + * Any dummy blocks added to complete an MCU are not counted; therefore + * these values do not depend on whether a scan is interleaved or not. + */ + JDIMENSION width_in_blocks; + JDIMENSION height_in_blocks; + /* Size of a DCT block in samples. Always DCTSIZE for compression. + * For decompression this is the size of the output from one DCT block, + * reflecting any scaling we choose to apply during the IDCT step. + * Values of 1,2,4,8 are likely to be supported. Note that different + * components may receive different IDCT scalings. + */ + int DCT_scaled_size; + /* The downsampled dimensions are the component's actual, unpadded number + * of samples at the main buffer (preprocessing/compression interface), thus + * downsampled_width = ceil(image_width * Hi/Hmax) + * and similarly for height. For decompression, IDCT scaling is included, so + * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) + */ + JDIMENSION downsampled_width; /* actual width in samples */ + JDIMENSION downsampled_height; /* actual height in samples */ + /* This flag is used only for decompression. In cases where some of the + * components will be ignored (eg grayscale output from YCbCr image), + * we can skip most computations for the unused components. + */ + boolean component_needed; /* do we need the value of this component? */ + + /* These values are computed before starting a scan of the component. */ + /* The decompressor output side may not use these variables. */ + int MCU_width; /* number of blocks per MCU, horizontally */ + int MCU_height; /* number of blocks per MCU, vertically */ + int MCU_blocks; /* MCU_width * MCU_height */ + int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ + int last_col_width; /* # of non-dummy blocks across in last MCU */ + int last_row_height; /* # of non-dummy blocks down in last MCU */ + + /* Saved quantization table for component; NULL if none yet saved. + * See jdinput.c comments about the need for this information. + * This field is currently used only for decompression. + */ + JQUANT_TBL * quant_table; + + /* Private per-component storage for DCT or IDCT subsystem. */ + void * dct_table; +} jpeg_component_info; + + +/* The script for encoding a multiple-scan file is an array of these: */ + +typedef struct { + int comps_in_scan; /* number of components encoded in this scan */ + int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ + int Ss, Se; /* progressive JPEG spectral selection parms */ + int Ah, Al; /* progressive JPEG successive approx. parms */ +} jpeg_scan_info; + +/* The decompressor can save APPn and COM markers in a list of these: */ + +typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; + +struct jpeg_marker_struct { + jpeg_saved_marker_ptr next; /* next in list, or NULL */ + UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ + unsigned int original_length; /* # bytes of data in the file */ + unsigned int data_length; /* # bytes of data saved at data[] */ + JOCTET FAR * data; /* the data contained in the marker */ + /* the marker length word is not counted in data_length or original_length */ +}; + +/* Known color spaces. */ + +typedef enum { + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK /* Y/Cb/Cr/K */ +} J_COLOR_SPACE; + +/* DCT/IDCT algorithm options. */ + +typedef enum { + JDCT_ISLOW, /* slow but accurate integer algorithm */ + JDCT_IFAST, /* faster, less accurate integer method */ + JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ +} J_DCT_METHOD; + +#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ +#define JDCT_DEFAULT JDCT_ISLOW +#endif +#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ +#define JDCT_FASTEST JDCT_IFAST +#endif + +/* Dithering options for decompression. */ + +typedef enum { + JDITHER_NONE, /* no dithering */ + JDITHER_ORDERED, /* simple ordered dither */ + JDITHER_FS /* Floyd-Steinberg error diffusion dither */ +} J_DITHER_MODE; + + +/* Common fields between JPEG compression and decompression master structs. */ + +#define jpeg_common_fields \ + struct jpeg_error_mgr * err; /* Error handler module */\ + struct jpeg_memory_mgr * mem; /* Memory manager module */\ + struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ + void * client_data; /* Available for use by application */\ + boolean is_decompressor; /* So common code can tell which is which */\ + int global_state /* For checking call sequence validity */ + +/* Routines that are to be used by both halves of the library are declared + * to receive a pointer to this structure. There are no actual instances of + * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. + */ +struct jpeg_common_struct { + jpeg_common_fields; /* Fields common to both master struct types */ + /* Additional fields follow in an actual jpeg_compress_struct or + * jpeg_decompress_struct. All three structs must agree on these + * initial fields! (This would be a lot cleaner in C++.) + */ +}; + +typedef struct jpeg_common_struct * j_common_ptr; +typedef struct jpeg_compress_struct * j_compress_ptr; +typedef struct jpeg_decompress_struct * j_decompress_ptr; + + +/* Master record for a compression instance */ + +struct jpeg_compress_struct { + jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ + + /* Destination for compressed data */ + struct jpeg_destination_mgr * dest; + + /* Description of source image --- these fields must be filled in by + * outer application before starting compression. in_color_space must + * be correct before you can even call jpeg_set_defaults(). + */ + + JDIMENSION image_width; /* input image width */ + JDIMENSION image_height; /* input image height */ + int input_components; /* # of color components in input image */ + J_COLOR_SPACE in_color_space; /* colorspace of input image */ + + double input_gamma; /* image gamma of input image */ + + /* Compression parameters --- these fields must be set before calling + * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to + * initialize everything to reasonable defaults, then changing anything + * the application specifically wants to change. That way you won't get + * burnt when new parameters are added. Also note that there are several + * helper routines to simplify changing parameters. + */ + + int data_precision; /* bits of precision in image data */ + + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + int num_scans; /* # of entries in scan_info array */ + const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ + /* The default value of scan_info is NULL, which causes a single-scan + * sequential JPEG file to be emitted. To create a multi-scan file, + * set num_scans and scan_info to point to an array of scan definitions. + */ + + boolean raw_data_in; /* TRUE=caller supplies downsampled data */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + int smoothing_factor; /* 1..100, or 0 for no input smoothing */ + J_DCT_METHOD dct_method; /* DCT algorithm selector */ + + /* The restart interval can be specified in absolute MCUs by setting + * restart_interval, or in MCU rows by setting restart_in_rows + * (in which case the correct restart_interval will be figured + * for each scan). + */ + unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ + int restart_in_rows; /* if > 0, MCU rows per restart interval */ + + /* Parameters controlling emission of special markers. */ + + boolean write_JFIF_header; /* should a JFIF marker be written? */ + UINT8 JFIF_major_version; /* What to write for the JFIF version number */ + UINT8 JFIF_minor_version; + /* These three values are not used by the JPEG code, merely copied */ + /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ + /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ + /* ratio is defined by X_density/Y_density even when density_unit=0. */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean write_Adobe_marker; /* should an Adobe marker be written? */ + + /* State variable: index of next scanline to be written to + * jpeg_write_scanlines(). Application may use this to control its + * processing loop, e.g., "while (next_scanline < image_height)". + */ + + JDIMENSION next_scanline; /* 0 .. image_height-1 */ + + /* Remaining fields are known throughout compressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during compression startup + */ + boolean progressive_mode; /* TRUE if scan script uses progressive mode */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ + /* The coefficient controller receives data in units of MCU rows as defined + * for fully interleaved scans (whether the JPEG file is interleaved or not). + * There are v_samp_factor * DCTSIZE sample rows of each component in an + * "iMCU" (interleaved MCU) row. + */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[C_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* + * Links to compression subobjects (methods and private variables of modules) + */ + struct jpeg_comp_master * master; + struct jpeg_c_main_controller * main; + struct jpeg_c_prep_controller * prep; + struct jpeg_c_coef_controller * coef; + struct jpeg_marker_writer * marker; + struct jpeg_color_converter * cconvert; + struct jpeg_downsampler * downsample; + struct jpeg_forward_dct * fdct; + struct jpeg_entropy_encoder * entropy; + jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ + int script_space_size; +}; + + +/* Master record for a decompression instance */ + +struct jpeg_decompress_struct { + jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ + + /* Source of compressed data */ + struct jpeg_source_mgr * src; + + /* Basic description of image --- filled in by jpeg_read_header(). */ + /* Application may inspect these values to decide how to process image. */ + + JDIMENSION image_width; /* nominal image width (from SOF marker) */ + JDIMENSION image_height; /* nominal image height */ + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + /* Decompression processing parameters --- these fields must be set before + * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes + * them to default values. + */ + + J_COLOR_SPACE out_color_space; /* colorspace for output */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + double output_gamma; /* image gamma wanted in output */ + + boolean buffered_image; /* TRUE=multiple output passes */ + boolean raw_data_out; /* TRUE=downsampled data wanted */ + + J_DCT_METHOD dct_method; /* IDCT algorithm selector */ + boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ + boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ + + boolean quantize_colors; /* TRUE=colormapped output wanted */ + /* the following are ignored if not quantize_colors: */ + J_DITHER_MODE dither_mode; /* type of color dithering to use */ + boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ + int desired_number_of_colors; /* max # colors to use in created colormap */ + /* these are significant only in buffered-image mode: */ + boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ + boolean enable_external_quant;/* enable future use of external colormap */ + boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ + + /* Description of actual output image that will be returned to application. + * These fields are computed by jpeg_start_decompress(). + * You can also use jpeg_calc_output_dimensions() to determine these values + * in advance of calling jpeg_start_decompress(). + */ + + JDIMENSION output_width; /* scaled image width */ + JDIMENSION output_height; /* scaled image height */ + int out_color_components; /* # of color components in out_color_space */ + int output_components; /* # of color components returned */ + /* output_components is 1 (a colormap index) when quantizing colors; + * otherwise it equals out_color_components. + */ + int rec_outbuf_height; /* min recommended height of scanline buffer */ + /* If the buffer passed to jpeg_read_scanlines() is less than this many rows + * high, space and time will be wasted due to unnecessary data copying. + * Usually rec_outbuf_height will be 1 or 2, at most 4. + */ + + /* When quantizing colors, the output colormap is described by these fields. + * The application can supply a colormap by setting colormap non-NULL before + * calling jpeg_start_decompress; otherwise a colormap is created during + * jpeg_start_decompress or jpeg_start_output. + * The map has out_color_components rows and actual_number_of_colors columns. + */ + int actual_number_of_colors; /* number of entries in use */ + JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ + + /* State variables: these variables indicate the progress of decompression. + * The application may examine these but must not modify them. + */ + + /* Row index of next scanline to be read from jpeg_read_scanlines(). + * Application may use this to control its processing loop, e.g., + * "while (output_scanline < output_height)". + */ + JDIMENSION output_scanline; /* 0 .. output_height-1 */ + + /* Current input scan number and number of iMCU rows completed in scan. + * These indicate the progress of the decompressor input side. + */ + int input_scan_number; /* Number of SOS markers seen so far */ + JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ + + /* The "output scan number" is the notional scan being displayed by the + * output side. The decompressor will not allow output scan/row number + * to get ahead of input scan/row, but it can fall arbitrarily far behind. + */ + int output_scan_number; /* Nominal scan number being displayed */ + JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ + + /* Current progression status. coef_bits[c][i] indicates the precision + * with which component c's DCT coefficient i (in zigzag order) is known. + * It is -1 when no data has yet been received, otherwise it is the point + * transform (shift) value for the most recent scan of the coefficient + * (thus, 0 at completion of the progression). + * This pointer is NULL when reading a non-progressive file. + */ + int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ + + /* Internal JPEG parameters --- the application usually need not look at + * these fields. Note that the decompressor output side may not use + * any parameters that can change between scans. + */ + + /* Quantization and Huffman tables are carried forward across input + * datastreams when processing abbreviated JPEG datastreams. + */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + /* These parameters are never carried across datastreams, since they + * are given in SOF/SOS markers or defined to be reset by SOI. + */ + + int data_precision; /* bits of precision in image data */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ + + /* These fields record data obtained from optional markers recognized by + * the JPEG library. + */ + boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ + /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ + UINT8 JFIF_major_version; /* JFIF version number */ + UINT8 JFIF_minor_version; + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ + UINT8 Adobe_transform; /* Color transform code from Adobe marker */ + + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + + /* Aside from the specific data retained from APPn markers known to the + * library, the uninterpreted contents of any or all APPn and COM markers + * can be saved in a list for examination by the application. + */ + jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ + + /* Remaining fields are known throughout decompressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during decompression startup + */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ + /* The coefficient controller's input and output progress is measured in + * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows + * in fully interleaved JPEG scans, but are used whether the scan is + * interleaved or not. We define an iMCU row as v_samp_factor DCT block + * rows of each component. Therefore, the IDCT output contains + * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. + */ + + JSAMPLE * sample_range_limit; /* table for fast range-limiting */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + * Note that the decompressor output side must not use these fields. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[D_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* This field is shared between entropy decoder and marker parser. + * It is either zero or the code of a JPEG marker that has been + * read from the data source, but has not yet been processed. + */ + int unread_marker; + + /* + * Links to decompression subobjects (methods, private variables of modules) + */ + struct jpeg_decomp_master * master; + struct jpeg_d_main_controller * main; + struct jpeg_d_coef_controller * coef; + struct jpeg_d_post_controller * post; + struct jpeg_input_controller * inputctl; + struct jpeg_marker_reader * marker; + struct jpeg_entropy_decoder * entropy; + struct jpeg_inverse_dct * idct; + struct jpeg_upsampler * upsample; + struct jpeg_color_deconverter * cconvert; + struct jpeg_color_quantizer * cquantize; +}; + + +/* "Object" declarations for JPEG modules that may be supplied or called + * directly by the surrounding application. + * As with all objects in the JPEG library, these structs only define the + * publicly visible methods and state variables of a module. Additional + * private fields may exist after the public ones. + */ + + +/* Error handler object */ + +struct jpeg_error_mgr { + /* Error exit handler: does not return to caller */ + JMETHOD(void, error_exit, (j_common_ptr cinfo)); + /* Conditionally emit a trace or warning message */ + JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); + /* Routine that actually outputs a trace or error message */ + JMETHOD(void, output_message, (j_common_ptr cinfo)); + /* Format a message string for the most recent JPEG error or message */ + JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); +#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ + /* Reset error state variables at start of a new image */ + JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); + + /* The message ID code and any parameters are saved here. + * A message can have one string parameter or up to 8 int parameters. + */ + int msg_code; +#define JMSG_STR_PARM_MAX 80 + union { + int i[8]; + char s[JMSG_STR_PARM_MAX]; + } msg_parm; + + /* Standard state variables for error facility */ + + int trace_level; /* max msg_level that will be displayed */ + + /* For recoverable corrupt-data errors, we emit a warning message, + * but keep going unless emit_message chooses to abort. emit_message + * should count warnings in num_warnings. The surrounding application + * can check for bad data by seeing if num_warnings is nonzero at the + * end of processing. + */ + long num_warnings; /* number of corrupt-data warnings */ + + /* These fields point to the table(s) of error message strings. + * An application can change the table pointer to switch to a different + * message list (typically, to change the language in which errors are + * reported). Some applications may wish to add additional error codes + * that will be handled by the JPEG library error mechanism; the second + * table pointer is used for this purpose. + * + * First table includes all errors generated by JPEG library itself. + * Error code 0 is reserved for a "no such error string" message. + */ + const char * const * jpeg_message_table; /* Library errors */ + int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ + /* Second table can be added by application (see cjpeg/djpeg for example). + * It contains strings numbered first_addon_message..last_addon_message. + */ + const char * const * addon_message_table; /* Non-library errors */ + int first_addon_message; /* code for first string in addon table */ + int last_addon_message; /* code for last string in addon table */ +}; + + +/* Progress monitor object */ + +struct jpeg_progress_mgr { + JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); + + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +}; + + +/* Data destination object for compression */ + +struct jpeg_destination_mgr { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + + JMETHOD(void, init_destination, (j_compress_ptr cinfo)); + JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); + JMETHOD(void, term_destination, (j_compress_ptr cinfo)); +}; + + +/* Data source object for decompression */ + +struct jpeg_source_mgr { + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + + JMETHOD(void, init_source, (j_decompress_ptr cinfo)); + JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); + JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); + JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); + JMETHOD(void, term_source, (j_decompress_ptr cinfo)); +}; + + +/* Memory manager object. + * Allocates "small" objects (a few K total), "large" objects (tens of K), + * and "really big" objects (virtual arrays with backing store if needed). + * The memory manager does not allow individual objects to be freed; rather, + * each created object is assigned to a pool, and whole pools can be freed + * at once. This is faster and more convenient than remembering exactly what + * to free, especially where malloc()/free() are not too speedy. + * NB: alloc routines never return NULL. They exit to error_exit if not + * successful. + */ + +#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ +#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ +#define JPOOL_NUMPOOLS 2 + +typedef struct jvirt_sarray_control * jvirt_sarray_ptr; +typedef struct jvirt_barray_control * jvirt_barray_ptr; + + +struct jpeg_memory_mgr { + /* Method pointers */ + JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, + JDIMENSION numrows)); + JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, + JDIMENSION numrows)); + JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION samplesperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION blocksperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); + JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, + jvirt_sarray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, + jvirt_barray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); + JMETHOD(void, self_destruct, (j_common_ptr cinfo)); + + /* Limit on memory allocation for this JPEG object. (Note that this is + * merely advisory, not a guaranteed maximum; it only affects the space + * used for virtual-array buffers.) May be changed by outer application + * after creating the JPEG object. + */ + long max_memory_to_use; + + /* Maximum allocation request accepted by alloc_large. */ + long max_alloc_chunk; +}; + + +/* Routine signature for application-supplied marker processing methods. + * Need not pass marker code since it is stored in cinfo->unread_marker. + */ +typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); + + +/* Declarations for routines called by application. + * The JPP macro hides prototype parameters from compilers that can't cope. + * Note JPP requires double parentheses. + */ + +#ifdef HAVE_PROTOTYPES +#define JPP(arglist) arglist +#else +#define JPP(arglist) () +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. + * We shorten external names to be unique in the first six letters, which + * is good enough for all known systems. + * (If your compiler itself needs names to be unique in less than 15 + * characters, you are out of luck. Get a better compiler.) + */ + +#if 0 +//#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_error jStdError +#define jpeg_CreateCompress jCreaCompress +#define jpeg_CreateDecompress jCreaDecompress +#define jpeg_destroy_compress jDestCompress +#define jpeg_destroy_decompress jDestDecompress +#define jpeg_stdio_dest jStdDest +#define jpeg_stdio_src jStdSrc +#define jpeg_set_defaults jSetDefaults +#define jpeg_set_colorspace jSetColorspace +#define jpeg_default_colorspace jDefColorspace +#define jpeg_set_quality jSetQuality +#define jpeg_set_linear_quality jSetLQuality +#define jpeg_add_quant_table jAddQuantTable +#define jpeg_quality_scaling jQualityScaling +#define jpeg_simple_progression jSimProgress +#define jpeg_suppress_tables jSuppressTables +#define jpeg_alloc_quant_table jAlcQTable +#define jpeg_alloc_huff_table jAlcHTable +#define jpeg_start_compress jStrtCompress +#define jpeg_write_scanlines jWrtScanlines +#define jpeg_finish_compress jFinCompress +#define jpeg_write_raw_data jWrtRawData +#define jpeg_write_marker jWrtMarker +#define jpeg_write_m_header jWrtMHeader +#define jpeg_write_m_byte jWrtMByte +#define jpeg_write_tables jWrtTables +#define jpeg_read_header jReadHeader +#define jpeg_start_decompress jStrtDecompress +#define jpeg_read_scanlines jReadScanlines +#define jpeg_finish_decompress jFinDecompress +#define jpeg_read_raw_data jReadRawData +#define jpeg_has_multiple_scans jHasMultScn +#define jpeg_start_output jStrtOutput +#define jpeg_finish_output jFinOutput +#define jpeg_input_complete jInComplete +#define jpeg_new_colormap jNewCMap +#define jpeg_consume_input jConsumeInput +#define jpeg_calc_output_dimensions jCalcDimensions +#define jpeg_save_markers jSaveMarkers +#define jpeg_set_marker_processor jSetMarker +#define jpeg_read_coefficients jReadCoefs +#define jpeg_write_coefficients jWrtCoefs +#define jpeg_copy_critical_parameters jCopyCrit +#define jpeg_abort_compress jAbrtCompress +#define jpeg_abort_decompress jAbrtDecompress +#define jpeg_abort jAbort +#define jpeg_destroy jDestroy +#define jpeg_resync_to_restart jResyncRestart +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Default error-management setup */ +EXTERN(struct jpeg_error_mgr *) jpeg_std_error + JPP((struct jpeg_error_mgr * err)); + +/* Initialization of JPEG compression objects. + * jpeg_create_compress() and jpeg_create_decompress() are the exported + * names that applications should call. These expand to calls on + * jpeg_CreateCompress and jpeg_CreateDecompress with additional information + * passed for version mismatch checking. + * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. + */ +#define jpeg_create_compress(cinfo) \ + jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_compress_struct)) +#define jpeg_create_decompress(cinfo) \ + jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_decompress_struct)) +EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, + int version, size_t structsize)); +EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, + int version, size_t structsize)); +/* Destruction of JPEG compression objects */ +EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); + +EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); + +/* Standard data source and destination managers: stdio streams. */ +/* Caller is responsible for opening the file before and closing after. */ +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* Default parameter setup for compression */ +EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); +/* Compression parameter setup aids */ +EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, + J_COLOR_SPACE colorspace)); +EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, + boolean force_baseline)); +EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, + int scale_factor, + boolean force_baseline)); +EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, + boolean force_baseline)); +EXTERN(int) jpeg_quality_scaling JPP((int quality)); +EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, + boolean suppress)); +EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); + +/* Main entry points for compression */ +EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, + boolean write_all_tables)); +EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION num_lines)); +EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); + +/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION num_lines)); + +/* Write a special marker. See libjpeg.doc concerning safe usage. */ +EXTERN(void) jpeg_write_marker + JPP((j_compress_ptr cinfo, int marker, + const JOCTET * dataptr, unsigned int datalen)); +/* Same, but piecemeal. */ +EXTERN(void) jpeg_write_m_header + JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); +EXTERN(void) jpeg_write_m_byte + JPP((j_compress_ptr cinfo, int val)); + +/* Alternate compression function: just write an abbreviated table file */ +EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); + +/* Decompression startup: read start of JPEG datastream to see what's there */ +EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, + boolean require_image)); +/* Return value is one of: */ +#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ +#define JPEG_HEADER_OK 1 /* Found valid image datastream */ +#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ +/* If you pass require_image = TRUE (normal case), you need not check for + * a TABLES_ONLY return code; an abbreviated file will cause an error exit. + * JPEG_SUSPENDED is only possible if you use a data source module that can + * give a suspension return (the stdio source module doesn't). + */ + +/* Main entry points for decompression */ +EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION max_lines)); +EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); + +/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION max_lines)); + +/* Additional entry points for buffered-image mode. */ +EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, + int scan_number)); +EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); +EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); +/* Return value is one of: */ +/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ +#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ +#define JPEG_REACHED_EOI 2 /* Reached end of image */ +#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ +#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ + +/* Precalculate output dimensions for current decompression parameters. */ +EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); + +/* Control saving of COM and APPn markers into marker_list. */ +EXTERN(void) jpeg_save_markers + JPP((j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit)); + +/* Install a special processing method for COM or APPn markers. */ +EXTERN(void) jpeg_set_marker_processor + JPP((j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine)); + +/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ +EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays)); +EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, + j_compress_ptr dstinfo)); + +/* If you choose to abort compression or decompression before completing + * jpeg_finish_(de)compress, then you need to clean up to release memory, + * temporary files, etc. You can just call jpeg_destroy_(de)compress + * if you're done with the JPEG object, but if you want to clean it up and + * reuse it, call this: + */ +EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); + +/* Generic versions of jpeg_abort and jpeg_destroy that work on either + * flavor of JPEG object. These may be more convenient in some places. + */ +EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); + +/* Default restart-marker-resync procedure for use by data source modules */ +EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, + int desired)); + + +/* These marker codes are exported since applications and data source modules + * are likely to want to use them. + */ + +#define JPEG_RST0 0xD0 /* RST0 marker code */ +#define JPEG_EOI 0xD9 /* EOI marker code */ +#define JPEG_APP0 0xE0 /* APP0 marker code */ +#define JPEG_COM 0xFE /* COM marker code */ + + +/* If we have a brain-damaged compiler that emits warnings (or worse, errors) + * for structure definitions that are never filled in, keep it quiet by + * supplying dummy definitions for the various substructures. + */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +struct jpeg_comp_master { long dummy; }; +struct jpeg_c_main_controller { long dummy; }; +struct jpeg_c_prep_controller { long dummy; }; +struct jpeg_c_coef_controller { long dummy; }; +struct jpeg_marker_writer { long dummy; }; +struct jpeg_color_converter { long dummy; }; +struct jpeg_downsampler { long dummy; }; +struct jpeg_forward_dct { long dummy; }; +struct jpeg_entropy_encoder { long dummy; }; +struct jpeg_decomp_master { long dummy; }; +struct jpeg_d_main_controller { long dummy; }; +struct jpeg_d_coef_controller { long dummy; }; +struct jpeg_d_post_controller { long dummy; }; +struct jpeg_input_controller { long dummy; }; +struct jpeg_marker_reader { long dummy; }; +struct jpeg_entropy_decoder { long dummy; }; +struct jpeg_inverse_dct { long dummy; }; +struct jpeg_upsampler { long dummy; }; +struct jpeg_color_deconverter { long dummy; }; +struct jpeg_color_quantizer { long dummy; }; +#endif /* JPEG_INTERNALS */ +#endif /* INCOMPLETE_TYPES_BROKEN */ + + +/* + * The JPEG library modules define JPEG_INTERNALS before including this file. + * The internal structure declarations are read only when that is true. + * Applications using the library should not include jpegint.h, but may wish + * to include jerror.h. + */ + +#ifdef JPEG_INTERNALS +#include "jpegint.h" /* fetch private declarations */ +#include "jerror.h" /* fetch error codes too */ +#endif + +#endif /* JPEGLIB_H */ diff --git a/include/jpsdefs.h b/include/jpsdefs.h new file mode 100755 index 0000000..b4db27f --- /dev/null +++ b/include/jpsdefs.h @@ -0,0 +1,439 @@ +#ifndef JPSDEFS_H_ +#define JPSDEFS_H_ +/************************************************ +** jpsdefs.h +** +** inteface to the +** +************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef JPS_FILE +// when used in the outside world, this is a void* +#define JPS_FILE void +#endif // ndef JPS_FILE + +#define JPS_NUM_CHANNELS (8) +#define NUM_CHANNELS JPS_NUM_CHANNELS +#define JPS_OK 0 +#define JPS_ERROR -1 +#define JPS_NUM_PLAYERS (JPS_NUM_CHANNELS * 2) +#define ALWAYS_STREAM 0 +#define JPS_MAX_BANKS (32) +#define JPS_TRACK_NOT_ASSIGNED (-1) +#define JPS_TRACK_DYNAMIC (-1) +#define JPS_BUFFER_BYTE_ALIGN 16 // alignment for UDMA usage + +#define JPS_COMMAND_FLAG_ONMARKER 0x0001 + +// for some reason, dlytsk() doesn't wake my procs back up. +// sooo... do this, which might cause deadlock issues + // should the update_thread decide to wake back up +#define JPS_START_PLAYLISTER_MANUALLY 1 + +#define TRACK_0 0 +#define TRACK_1 1 +#define TRACK_2 2 +#define TRACK_3 3 +#define TRACK_4 4 +#define TRACK_5 5 +#define TRACK_6 6 +#define TRACK_7 7 +#define TRACK_8 8 +#define TRACK_9 9 +#define TRACK_10 10 +#define TRACK_11 11 +#define TRACK_12 12 +#define TRACK_13 13 +#define TRACK_14 14 +#define TRACK_15 15 + +#define JPS_VOL_MAX 255 +#define JPS_VOL_MIN 0 + +#if SYS_PC|SYS_BB +#define JPS_AUTOSTREAM 1 +#define STREAM_UPDATE_MIN_SIZE (0x0) +#define STREAM_BUFFER_SIZE (0x10000) +#define STREAM_SIZE_THRESHOLD (0x200000) +#endif +#if SYS_5500 +#define STREAM_UPDATE_MIN_SIZE (0x1000) +#define STREAM_BUFFER_SIZE (0x40000) // must be power of 2 +#define STREAM_SIZE_THRESHOLD (0x40000) +#define JPS_SIMULATE_MONO 0 +#endif + +#define JPS_STREAM_YES 1 +#define JPS_STREAM_NO 0 +#define JPS_STREAM_AUTO 2 + +typedef uns32 jps_name[2]; + +typedef struct transition_s +{ + void *event; + struct jps_sndbuf_s *next_buf; + unsigned long next_buf_position; + void *transition_graph; + struct transition_s *next_trans; +} transition; + +// audio files are parsed into this structure. +typedef struct jps_sndbuf_s +{ + jps_name name; // sound buffer file name + uns32 numbytes; // size IN BYTES of sample data + uns8 looping; // looping + uns8 streaming; // streaming + uns8 playflags; // flags -- cleared each time sound is started + uns8 allocated; // buffer was allocated & needs to be freed + uns16 channel_num; // where are we playing? + uns8 nChannels; // format + uns32 nSamplesPerSec; // format + uns32 nAvgBytesPerSec; // format + uns8 nBlockAlign; // format + uns8 nBitsPerSample;// format + void *data; // actual sample data + + // streaming info + char file_path[256]; + uns32 databufsize; // guaranteed power of 2 if streaming + uns32 dest_offset; // where we last put data in the hdw buf + uns32 finishzeros; // how many zeros have been copied + JPS_FILE *file_pointer; // file pointer (if streaming) + uns32 file_curpos; // where we are in the audio file + uns32 file_hdrpos; // offset in file to where the audio begins + uns32 file_endpos; // one past end of data +} jps_sndbuf; + +#define M_SNDBUF_PLAYING 0x01 // sound buffer is playing +#define M_SNDBUF_HITDATAEND 0x02 // end of buffer +#define M_SNDBUF_FINISHSTOP 0x04 // dont load any more +#define M_SNDBUF_ERR 0x80 // sound buffer is in some kind of error state -- don't play anymore, kill + +// data for the actual audio hardware channels - +// what they should be playing, at what volume, +// the label. +typedef struct jps_channel_s { + jps_name label; // channel label for reference by playlists + jps_sndbuf *curr_buf; // currently-playing buffer + jps_sndbuf *next_buf; // next buffer to play (for seamless transitions) MAY NOT USE + struct jps_player_s *owner; // are we 0WN3D (allocated?) + int volume; // stored as db in linux, index in dx + uns16 pan; + uns16 priority; + uns16 index; // 0-255 + uns16 ducked; + uns16 duckIndex; //original index before duckingzz + uns16 reserved; +} jps_channel; + +#define JPS_ARGS_MAX (64) + +// the commands to be executed by the playlister; +// for example, PLAY, STOP, LOOPSTART +typedef struct jps_command_s { + uns32 opcode; // used to identify command and index into array of fxn ptrs + float time; // the time at which the playlister should execute this command + uns32 flags; // conditional/random/etc modifiers to opcode + uns8 args[JPS_ARGS_MAX]; // plenty of scratch space for arguments +} jps_command; + +// a playlist is a collection of commands to be +// executed by the playlister +typedef struct jps_playlist_s { + jps_name name; + uns32 num; + jps_command *commands; // location of the start of the playlist commands + uns32 num_commands; + uns32 num_tracks; // how many tracks does this playlist require? + uns16 trackmask; // what possible tracks should this playlist land on? + uns16 priority; // what priority level should every sound on this playlist have? +} jps_playlist; + +typedef struct jps_groupsound_s { + jps_sndbuf *buf; + float prob; // probability that it will be selected +} jps_groupsound; + +#define JPS_MAX_HISTORY 10 + +typedef struct jps_group_s { + jps_name name; // the name of the group + jps_groupsound *groupsounds; // pointer to location in the groupsounds array + uns32 num; + uns32 buffer_size; + uns32 buffer[JPS_MAX_HISTORY]; +} jps_group; + +#define JPS_BANK_FLAG_VOL_ATTEN 0x1 +// bank information, parsed from the bank file. +// contains everything necessary to play sounds: +// banks, and playlists consisting of commands +typedef struct jps_bank_s { + jps_name name; // bank file name + char nameStr[32]; // string name + uns32 flags; // any sorts of playlist conventions + jps_sndbuf *sndbufs; // pointer to array of sound buffer information for this bank + void *rawSndbufs; // raw version of above + uns32 num_sndbufs; // number of loaded sound buffers + uns32 max_sndbufs; // maximum number of sound buffer data allocated + jps_playlist *playlists; // pointer to array of playlist information + void *rawPlaylists; // raw version of above + uns32 num_playlists; // number of playlists loaded + uns32 max_playlists; // max number of playlists allocated + jps_command *commands; // pointer to command data for all playlists + void *rawCommands; // raw version of above + uns32 num_commands; // number of commands loaded + uns32 max_commands; // max number of commands loaded + jps_group *groups; + void *rawGroups; // raw version of above + uns32 num_groups; + uns32 max_groups; + jps_groupsound *groupsounds; + void *rawGroupsounds; // raw version of above + uns32 num_groupsounds; + uns32 max_groupsounds; + void *rawBank; // raw ptr to this bank +} jps_bank; + +#define JPS_NUM_RAMPS (10) +#define JPS_RAMP_ARGS_MAX (32) + +typedef enum { + JPS_RAMP_OPCODE_NONE, + JPS_RAMP_OPCODE_REG, +} jps_ramp_opcode; + +typedef enum { + JPS_RAMP_OBJ_VOLUME, + JPS_RAMP_OBJ_PAN, +} jps_ramp_obj; + +typedef struct jps_ramp_args_s { + float start_time; + float finish_time; + int32 start_amount; + int32 final_amount; + uns16 channel; // NOTE: NOT track + uns16 filler; +} jps_ramp_args; + +typedef struct jps_ramp_s { + jps_ramp_opcode opcode; // what type of ramp are we doing? + jps_ramp_obj obj; // what type of obj are we ramping? + uns32 num; // which of those objs are we ramping? + uns8 args[JPS_RAMP_ARGS_MAX]; // plenty of scratch space for arguments +} jps_ramp; + +// this is the max number of loops supported within a playlist. +// 16 should be WAY more than enough +#define JPS_NUM_LOOPS (16) + +typedef struct jps_loop_s { + uns32 start_command; // location of loopstart opcode + uns32 remaining; // how many loops remain? +} jps_loop; + +// the jps_player is used for each instance +// a playlist is played +typedef struct jps_player_s { + jps_playlist *playlist; // currently playing playlist + float start_time; // when did we start? +// float last_time; // we need to HOW MANY commands to execute next + uns32 curr_command; // where are we? + int32 tracks[JPS_NUM_CHANNELS]; // track->channel mapping (-1 if not alloc'ed) + uns16 priority; // how important is this player? + jps_ramp ramps[JPS_NUM_RAMPS]; // different ramp modifiers for playlist channels + jps_loop loops[JPS_NUM_LOOPS]; // loop counters + uns32 track_mask; // what are acceptable values for a start track? + uns32 volume; // what's our default vol? +} jps_player; + +// the opcode-parsing function needs to be able to reference +// the player struct to see on which channel to place +// a sound for playing. it needs the bank stuct so it can +// see where the sound buffers are +#define JPS_OPCODE_FUNC(x) int32 (x) (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) +typedef JPS_OPCODE_FUNC(*jps_opcode_func); +JPS_OPCODE_FUNC(jps_opcode_func_assign); +JPS_OPCODE_FUNC(jps_opcode_func_play); +JPS_OPCODE_FUNC(jps_opcode_func_stop); +JPS_OPCODE_FUNC(jps_opcode_func_end); +JPS_OPCODE_FUNC(jps_opcode_func_setvol); +JPS_OPCODE_FUNC(jps_opcode_func_loopstart); +JPS_OPCODE_FUNC(jps_opcode_func_loopend); +JPS_OPCODE_FUNC(jps_opcode_func_duck); +JPS_OPCODE_FUNC(jps_opcode_func_unduck); +JPS_OPCODE_FUNC(jps_opcode_func_waitfor); +JPS_OPCODE_FUNC(jps_opcode_func_setpan); +JPS_OPCODE_FUNC(jps_opcode_func_setfreq); +JPS_OPCODE_FUNC(jps_opcode_func_signal); +JPS_OPCODE_FUNC(jps_opcode_func_goto); +JPS_OPCODE_FUNC(jps_opcode_func_gosub); +JPS_OPCODE_FUNC(jps_opcode_func_label); +JPS_OPCODE_FUNC(jps_opcode_func_marker); +JPS_OPCODE_FUNC(jps_opcode_func_playgroup); +typedef struct jps_opcode_table_s { + uns32 opcode; + jps_opcode_func func; +} jps_opcode_table; + + +#define JPS_PARSE_FUNC(x) int32 (x) (JPS_FILE *fp, char *currdata, jps_bank *bank, jps_command *cmd, float *time) +typedef JPS_PARSE_FUNC(*jps_parse_func); +JPS_PARSE_FUNC(jps_parse_func_playlist); +JPS_PARSE_FUNC(jps_parse_func_group); +JPS_PARSE_FUNC(jps_parse_func_group_sound); +JPS_PARSE_FUNC(jps_parse_func_group_end); +JPS_PARSE_FUNC(jps_parse_func_end); +JPS_PARSE_FUNC(jps_parse_func_assign); +JPS_PARSE_FUNC(jps_parse_func_play); +JPS_PARSE_FUNC(jps_parse_func_plays); +JPS_PARSE_FUNC(jps_parse_func_stop); +JPS_PARSE_FUNC(jps_parse_func_setvol); +JPS_PARSE_FUNC(jps_parse_func_loopstart); +JPS_PARSE_FUNC(jps_parse_func_loopend); +JPS_PARSE_FUNC(jps_parse_func_duck); +JPS_PARSE_FUNC(jps_parse_func_unduck); +JPS_PARSE_FUNC(jps_parse_func_waitfor); +JPS_PARSE_FUNC(jps_parse_func_setpan); +JPS_PARSE_FUNC(jps_parse_func_setfreq); +JPS_PARSE_FUNC(jps_parse_func_signal); +JPS_PARSE_FUNC(jps_parse_func_goto); +JPS_PARSE_FUNC(jps_parse_func_gosub); +JPS_PARSE_FUNC(jps_parse_func_label); +JPS_PARSE_FUNC(jps_parse_func_marker); +JPS_PARSE_FUNC(jps_parse_func_playgroup); +JPS_PARSE_FUNC(jps_parse_func_vol_atten); +JPS_PARSE_FUNC(jps_parse_func_vol_gain); +JPS_PARSE_FUNC(jps_parse_func_constant); + +typedef struct jps_parse_table_s{ + char command[20]; + uns32 opcode; + jps_parse_func func; +} jps_parse_table; + +// these opcodes need to be synchronized with the list of function pointers +typedef enum jps_opcodes_e { + JPS_NOTACOMMAND=0, + JPS_OPCODE_END, + JPS_OPCODE_PLAY, + JPS_OPCODE_STOP, + JPS_OPCODE_SETVOL, + JPS_OPCODE_LOOPSTART, + JPS_OPCODE_LOOPEND, + JPS_OPCODE_DUCK, + JPS_OPCODE_UNDUCK, + JPS_OPCODE_WAITFOR, + JPS_OPCODE_SETPAN, + JPS_OPCODE_SETFREQ, + JPS_OPCODE_SIGNAL, + JPS_OPCODE_GOTO, + JPS_OPCODE_GOSUB, + JPS_OPCODE_LABEL, + JPS_OPCODE_MARKER, + JPS_OPCODE_PLAYGROUP, +} jps_opcodes; + +extern jps_opcode_table jps_funcs[]; + +typedef struct jps_args_play_s { + jps_group* group; // for groupplay opcode + jps_sndbuf* sndbuf; // for play opcode + uns8 track; + uns32 num_loops; +} jps_args_play; + +typedef struct jps_args_stop_s { + uns8 track; +} jps_args_stop; + +typedef struct jps_args_setvol_s { + uns8 track; + uns16 volume; + float ramp_time; +} jps_args_setvol; + +typedef struct jps_args_setpan_s { + uns8 track; + uns16 pan; + float ramp_time; +} jps_args_setpan; + +typedef struct jps_args_setfreq_s { + uns8 track; + uns16 freq; + float ramp_time; +} jps_args_setfreq; + +typedef struct jps_args_loopstart_s { + uns32 remaining; +} jps_args_loopstart; + +typedef struct jps_args_duck_s { + uns16 channel; + uns16 volume; + float ramp_time; +} jps_args_duck; + +typedef struct jps_args_unduck_s { + uns16 channel; + float ramp_time; +} jps_args_unduck; + +typedef struct jps_args_waitfor_s { + uns8 track; +} jps_args_waitfor; + +typedef struct jps_args_goto_s { + jps_name name; +} jps_args_goto; + +typedef struct jps_args_label_s { + jps_name name; +} jps_args_label; + +typedef struct jps_args_signal_s { + uns16 num; +} jps_args_signal; + +typedef struct jps_args_marker_s { + uns16 num; +} jps_args_marker; + +extern int jps_init(); +extern void jps_master_volume(int volume); +extern uns32 jps_play(jps_bank *bank, uns32 playlist_num, int volume); +extern uns32 jps_bank_play(char *filename, uns32 playlist_num); +extern uns32 jps_bank_play_name(char *filename, char *scallname); +extern uns32 jps_bank_play_vol(char *filename, uns32 playlist_num, int volume); +extern uns32 jps_play_name(char *scallname); +extern void jps_version(uns32 *pMajor, uns32 *pMinor, uns32 *pSubMinor); +extern void jps_update_all(jps_player *player); +extern void jps_player_update(jps_player *player, float curr_time); +extern void *jps_memalloc(void **raw_ptr, uns32 alignbound, uns32 size); +extern void jps_memfree(void *raw_ptr); +extern jps_bank * jps_bank_load(char *filename); + +extern jps_channel jps_channel_data[JPS_NUM_CHANNELS]; +extern jps_player jps_players[JPS_NUM_PLAYERS]; +extern void jps_stop(jps_player *player); +extern jps_bank *jps_banks[JPS_MAX_BANKS]; +extern void jps_parse_channels(char *filename, jps_channel *data); +extern void jps_bank_free(jps_bank *bank); +extern int jps_shutdown(void); +extern void jps_stopall_players(); + +extern int jps_sndmem_alloc_count; +extern int jps_sndmem_alloc_size; + +#ifdef __cplusplus +} +#endif + +#endif // !JPSDEFS_H_ diff --git a/include/libxml/DOCBparser.h b/include/libxml/DOCBparser.h new file mode 100755 index 0000000..57f211a --- /dev/null +++ b/include/libxml/DOCBparser.h @@ -0,0 +1,96 @@ +/* + * Summary: old DocBook SGML parser + * Description: interface for a DocBook SGML non-verifying parser + * This code is DEPRECATED, and should not be used anymore. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DOCB_PARSER_H__ +#define __DOCB_PARSER_H__ +#include + +#ifdef LIBXML_DOCB_ENABLED + +#include +#include + +#ifndef IN_LIBXML +#ifdef __GNUC__ +#warning "The DOCBparser module has been deprecated in libxml2-2.6.0" +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most of the back-end structures from XML and SGML are shared. + */ +typedef xmlParserCtxt docbParserCtxt; +typedef xmlParserCtxtPtr docbParserCtxtPtr; +typedef xmlSAXHandler docbSAXHandler; +typedef xmlSAXHandlerPtr docbSAXHandlerPtr; +typedef xmlParserInput docbParserInput; +typedef xmlParserInputPtr docbParserInputPtr; +typedef xmlDocPtr docbDocPtr; + +/* + * There is only few public functions. + */ +XMLPUBFUN int XMLCALL + docbEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); + +XMLPUBFUN docbDocPtr XMLCALL + docbSAXParseDoc (xmlChar *cur, + const char *encoding, + docbSAXHandlerPtr sax, + void *userData); +XMLPUBFUN docbDocPtr XMLCALL + docbParseDoc (xmlChar *cur, + const char *encoding); +XMLPUBFUN docbDocPtr XMLCALL + docbSAXParseFile (const char *filename, + const char *encoding, + docbSAXHandlerPtr sax, + void *userData); +XMLPUBFUN docbDocPtr XMLCALL + docbParseFile (const char *filename, + const char *encoding); + +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN void XMLCALL + docbFreeParserCtxt (docbParserCtxtPtr ctxt); +XMLPUBFUN docbParserCtxtPtr XMLCALL + docbCreatePushParserCtxt(docbSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + docbParseChunk (docbParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +XMLPUBFUN docbParserCtxtPtr XMLCALL + docbCreateFileParserCtxt(const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + docbParseDocument (docbParserCtxtPtr ctxt); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DOCB_ENABLED */ + +#endif /* __DOCB_PARSER_H__ */ diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h new file mode 100755 index 0000000..706080e --- /dev/null +++ b/include/libxml/HTMLparser.h @@ -0,0 +1,298 @@ +/* + * Summary: interface for an HTML 4.0 non-verifying parser + * Description: this module implements an HTML 4.0 non-verifying parser + * with API compatible with the XML parser ones. It should + * be able to parse "real world" HTML, even if severely + * broken from a specification point of view. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_PARSER_H__ +#define __HTML_PARSER_H__ +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most of the back-end structures from XML and HTML are shared. + */ +typedef xmlParserCtxt htmlParserCtxt; +typedef xmlParserCtxtPtr htmlParserCtxtPtr; +typedef xmlParserNodeInfo htmlParserNodeInfo; +typedef xmlSAXHandler htmlSAXHandler; +typedef xmlSAXHandlerPtr htmlSAXHandlerPtr; +typedef xmlParserInput htmlParserInput; +typedef xmlParserInputPtr htmlParserInputPtr; +typedef xmlDocPtr htmlDocPtr; +typedef xmlNodePtr htmlNodePtr; + +/* + * Internal description of an HTML element, representing HTML 4.01 + * and XHTML 1.0 (which share the same structure). + */ +typedef struct _htmlElemDesc htmlElemDesc; +typedef htmlElemDesc *htmlElemDescPtr; +struct _htmlElemDesc { + const char *name; /* The tag name */ + char startTag; /* Whether the start tag can be implied */ + char endTag; /* Whether the end tag can be implied */ + char saveEndTag; /* Whether the end tag should be saved */ + char empty; /* Is this an empty element ? */ + char depr; /* Is this a deprecated element ? */ + char dtd; /* 1: only in Loose DTD, 2: only Frameset one */ + char isinline; /* is this a block 0 or inline 1 element */ + const char *desc; /* the description */ + +/* NRK Jan.2003 + * New fields encapsulating HTML structure + * + * Bugs: + * This is a very limited representation. It fails to tell us when + * an element *requires* subelements (we only have whether they're + * allowed or not), and it doesn't tell us where CDATA and PCDATA + * are allowed. Some element relationships are not fully represented: + * these are flagged with the word MODIFIER + */ + const char** subelts; /* allowed sub-elements of this element */ + const char* defaultsubelt; /* subelement for suggested auto-repair + if necessary or NULL */ + const char** attrs_opt; /* Optional Attributes */ + const char** attrs_depr; /* Additional deprecated attributes */ + const char** attrs_req; /* Required attributes */ +}; + +/* + * Internal description of an HTML entity. + */ +typedef struct _htmlEntityDesc htmlEntityDesc; +typedef htmlEntityDesc *htmlEntityDescPtr; +struct _htmlEntityDesc { + unsigned int value; /* the UNICODE value for the character */ + const char *name; /* The entity name */ + const char *desc; /* the description */ +}; + +/* + * There is only few public functions. + */ +XMLPUBFUN const htmlElemDesc * XMLCALL + htmlTagLookup (const xmlChar *tag); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlEntityLookup(const xmlChar *name); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlEntityValueLookup(unsigned int value); + +XMLPUBFUN int XMLCALL + htmlIsAutoClosed(htmlDocPtr doc, + htmlNodePtr elem); +XMLPUBFUN int XMLCALL + htmlAutoCloseTag(htmlDocPtr doc, + const xmlChar *name, + htmlNodePtr elem); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlParseEntityRef(htmlParserCtxtPtr ctxt, + const xmlChar **str); +XMLPUBFUN int XMLCALL + htmlParseCharRef(htmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + htmlParseElement(htmlParserCtxtPtr ctxt); + +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlCreateMemoryParserCtxt(const char *buffer, + int size); + +XMLPUBFUN int XMLCALL + htmlParseDocument(htmlParserCtxtPtr ctxt); +XMLPUBFUN htmlDocPtr XMLCALL + htmlSAXParseDoc (xmlChar *cur, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr XMLCALL + htmlParseDoc (xmlChar *cur, + const char *encoding); +XMLPUBFUN htmlDocPtr XMLCALL + htmlSAXParseFile(const char *filename, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr XMLCALL + htmlParseFile (const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + UTF8ToHtml (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +XMLPUBFUN int XMLCALL + htmlEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); +XMLPUBFUN int XMLCALL + htmlIsScriptAttribute(const xmlChar *name); +XMLPUBFUN int XMLCALL + htmlHandleOmittedElem(int val); + +#ifdef LIBXML_PUSH_ENABLED +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + htmlParseChunk (htmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +XMLPUBFUN void XMLCALL + htmlFreeParserCtxt (htmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */ + HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + HTML_PARSE_NONET = 1<<11 /* Forbid network access */ +} htmlParserOption; + +XMLPUBFUN void XMLCALL + htmlCtxtReset (htmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + htmlCtxtUseOptions (htmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/* NRK/Jan2003: further knowledge of HTML structure + */ +typedef enum { + HTML_NA = 0 , /* something we don't check at all */ + HTML_INVALID = 0x1 , + HTML_DEPRECATED = 0x2 , + HTML_VALID = 0x4 , + HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */ +} htmlStatus ; + +/* Using htmlElemDesc rather than name here, to emphasise the fact + that otherwise there's a lookup overhead +*/ +XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ; +XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ; +XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ; +XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ; +/** + * htmlDefaultSubelement: + * @elt: HTML element + * + * Returns the default subelement for this element + */ +#define htmlDefaultSubelement(elt) elt->defaultsubelt +/** + * htmlElementAllowedHereDesc: + * @parent: HTML parent element + * @elt: HTML element + * + * Checks whether an HTML element description may be a + * direct child of the specified element. + * + * Returns 1 if allowed; 0 otherwise. + */ +#define htmlElementAllowedHereDesc(parent,elt) \ + htmlElementAllowedHere((parent), (elt)->name) +/** + * htmlRequiredAttrs: + * @elt: HTML element + * + * Returns the attributes required for the specified element. + */ +#define htmlRequiredAttrs(elt) (elt)->attrs_req + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ +#endif /* __HTML_PARSER_H__ */ diff --git a/include/libxml/HTMLtree.h b/include/libxml/HTMLtree.h new file mode 100755 index 0000000..09d89fe --- /dev/null +++ b/include/libxml/HTMLtree.h @@ -0,0 +1,142 @@ +/* + * Summary: specific APIs to process HTML tree, especially serialization + * Description: this module implements a few function needed to process + * tree in an HTML specific way. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_TREE_H__ +#define __HTML_TREE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * HTML_TEXT_NODE: + * + * Macro. A text node in a HTML document is really implemented + * the same way as a text node in an XML document. + */ +#define HTML_TEXT_NODE XML_TEXT_NODE +/** + * HTML_ENTITY_REF_NODE: + * + * Macro. An entity reference in a HTML document is really implemented + * the same way as an entity reference in an XML document. + */ +#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE +/** + * HTML_COMMENT_NODE: + * + * Macro. A comment in a HTML document is really implemented + * the same way as a comment in an XML document. + */ +#define HTML_COMMENT_NODE XML_COMMENT_NODE +/** + * HTML_PRESERVE_NODE: + * + * Macro. A preserved node in a HTML document is really implemented + * the same way as a CDATA section in an XML document. + */ +#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE +/** + * HTML_PI_NODE: + * + * Macro. A processing instruction in a HTML document is really implemented + * the same way as a processing instruction in an XML document. + */ +#define HTML_PI_NODE XML_PI_NODE + +XMLPUBFUN htmlDocPtr XMLCALL + htmlNewDoc (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN htmlDocPtr XMLCALL + htmlNewDocNoDtD (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN const xmlChar * XMLCALL + htmlGetMetaEncoding (htmlDocPtr doc); +XMLPUBFUN int XMLCALL + htmlSetMetaEncoding (htmlDocPtr doc, + const xmlChar *encoding); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + htmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN int XMLCALL + htmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + htmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + htmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN void XMLCALL + htmlNodeDumpFile (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int XMLCALL + htmlNodeDumpFileFormat (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN int XMLCALL + htmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int XMLCALL + htmlSaveFileFormat (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN void XMLCALL + htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + htmlDocContentDumpOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN void XMLCALL + htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + htmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XMLPUBFUN int XMLCALL + htmlIsBooleanAttr (const xmlChar *name); + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ + +#endif /* __HTML_TREE_H__ */ + diff --git a/include/libxml/SAX.h b/include/libxml/SAX.h new file mode 100755 index 0000000..304ee9f --- /dev/null +++ b/include/libxml/SAX.h @@ -0,0 +1,170 @@ +/* + * Summary: Old SAX version 1 handler, deprecated + * Description: DEPRECATED set of SAX version 1 interfaces used to + * build the DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX_H__ +#define __XML_SAX_H__ + +#include +#include +#include +#include +#include + +#ifdef LIBXML_SAX1_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * XMLCALL + getPublicId (void *ctx); +XMLPUBFUN const xmlChar * XMLCALL + getSystemId (void *ctx); +XMLPUBFUN void XMLCALL + setDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int XMLCALL + getLineNumber (void *ctx); +XMLPUBFUN int XMLCALL + getColumnNumber (void *ctx); + +XMLPUBFUN int XMLCALL + isStandalone (void *ctx); +XMLPUBFUN int XMLCALL + hasInternalSubset (void *ctx); +XMLPUBFUN int XMLCALL + hasExternalSubset (void *ctx); + +XMLPUBFUN void XMLCALL + internalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void XMLCALL + externalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr XMLCALL + getEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + getParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr XMLCALL + resolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void XMLCALL + entityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void XMLCALL + attributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void XMLCALL + elementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + notationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void XMLCALL + unparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void XMLCALL + startDocument (void *ctx); +XMLPUBFUN void XMLCALL + endDocument (void *ctx); +XMLPUBFUN void XMLCALL + attribute (void *ctx, + const xmlChar *fullname, + const xmlChar *value); +XMLPUBFUN void XMLCALL + startElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XMLPUBFUN void XMLCALL + endElement (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + ignorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + processingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void XMLCALL + globalNamespace (void *ctx, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + setNamespace (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlNsPtr XMLCALL + getNamespace (void *ctx); +XMLPUBFUN int XMLCALL + checkNamespace (void *ctx, + xmlChar *nameSpace); +XMLPUBFUN void XMLCALL + namespaceDecl (void *ctx, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void XMLCALL + cdataBlock (void *ctx, + const xmlChar *value, + int len); + +XMLPUBFUN void XMLCALL + initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void XMLCALL + inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); +#endif +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN void XMLCALL + initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); +#endif +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SAX1_ENABLED */ + +#endif /* __XML_SAX_H__ */ diff --git a/include/libxml/SAX2.h b/include/libxml/SAX2.h new file mode 100755 index 0000000..87ebbe2 --- /dev/null +++ b/include/libxml/SAX2.h @@ -0,0 +1,172 @@ +/* + * Summary: SAX2 parser interface used to build the DOM tree + * Description: those are the default SAX2 interfaces used by + * the library when building DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX2_H__ +#define __XML_SAX2_H__ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * XMLCALL + xmlSAX2GetPublicId (void *ctx); +XMLPUBFUN const xmlChar * XMLCALL + xmlSAX2GetSystemId (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2SetDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int XMLCALL + xmlSAX2GetLineNumber (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2GetColumnNumber (void *ctx); + +XMLPUBFUN int XMLCALL + xmlSAX2IsStandalone (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2HasInternalSubset (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2HasExternalSubset (void *ctx); + +XMLPUBFUN void XMLCALL + xmlSAX2InternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void XMLCALL + xmlSAX2ExternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlSAX2GetEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlSAX2GetParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlSAX2ResolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void XMLCALL + xmlSAX2EntityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void XMLCALL + xmlSAX2AttributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void XMLCALL + xmlSAX2ElementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlSAX2NotationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void XMLCALL + xmlSAX2UnparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void XMLCALL + xmlSAX2StartDocument (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2EndDocument (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2StartElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XMLPUBFUN void XMLCALL + xmlSAX2EndElement (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSAX2StartElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); +XMLPUBFUN void XMLCALL + xmlSAX2EndElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); +XMLPUBFUN void XMLCALL + xmlSAX2Reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSAX2Characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + xmlSAX2IgnorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + xmlSAX2ProcessingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void XMLCALL + xmlSAX2Comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlSAX2CDataBlock (void *ctx, + const xmlChar *value, + int len); + +XMLPUBFUN int XMLCALL + xmlSAXDefaultVersion (int version); + +XMLPUBFUN int XMLCALL + xmlSAXVersion (xmlSAXHandler *hdlr, + int version); +XMLPUBFUN void XMLCALL + xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void XMLCALL + xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr); +#endif +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN void XMLCALL + xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr); +#endif +XMLPUBFUN void XMLCALL + xmlDefaultSAXHandlerInit (void); +XMLPUBFUN void XMLCALL + htmlDefaultSAXHandlerInit (void); +XMLPUBFUN void XMLCALL + docbDefaultSAXHandlerInit (void); +#ifdef __cplusplus +} +#endif +#endif /* __XML_SAX2_H__ */ diff --git a/include/libxml/c14n.h b/include/libxml/c14n.h new file mode 100755 index 0000000..8cdb655 --- /dev/null +++ b/include/libxml/c14n.h @@ -0,0 +1,105 @@ +/* + * Summary: Provide Canonical XML and Exclusive XML Canonicalization + * Description: the c14n modules provides a + * + * "Canonical XML" implementation + * http://www.w3.org/TR/xml-c14n + * + * and an + * + * "Exclusive XML Canonicalization" implementation + * http://www.w3.org/TR/xml-exc-c14n + + * Copy: See Copyright for the status of this software. + * + * Author: Aleksey Sanin + */ +#ifndef __XML_C14N_H__ +#define __XML_C14N_H__ +#ifdef LIBXML_C14N_ENABLED +#ifdef LIBXML_OUTPUT_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include +#include + +/* + * XML Canonicazation + * http://www.w3.org/TR/xml-c14n + * + * Exclusive XML Canonicazation + * http://www.w3.org/TR/xml-exc-c14n + * + * Canonical form of an XML document could be created if and only if + * a) default attributes (if any) are added to all nodes + * b) all character and parsed entity references are resolved + * In order to achive this in libxml2 the document MUST be loaded with + * following global setings: + * + * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + * xmlSubstituteEntitiesDefault(1); + * + * or corresponding parser context setting: + * xmlParserCtxtPtr ctxt; + * + * ... + * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + * ctxt->replaceEntities = 1; + * ... + */ + + +XMLPUBFUN int XMLCALL + xmlC14NDocSaveTo (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +XMLPUBFUN int XMLCALL + xmlC14NDocDumpMemory (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlChar **doc_txt_ptr); + +XMLPUBFUN int XMLCALL + xmlC14NDocSave (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + const char* filename, + int compression); + + +/** + * This is the core C14N function + */ +typedef int (*xmlC14NIsVisibleCallback) (void* user_data, + xmlNodePtr node, + xmlNodePtr parent); + +XMLPUBFUN int XMLCALL + xmlC14NExecute (xmlDocPtr doc, + xmlC14NIsVisibleCallback is_visible_callback, + void* user_data, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* LIBXML_C14N_ENABLED */ +#endif /* __XML_C14N_H__ */ + diff --git a/include/libxml/catalog.h b/include/libxml/catalog.h new file mode 100755 index 0000000..e729b1d --- /dev/null +++ b/include/libxml/catalog.h @@ -0,0 +1,181 @@ +/** + * Summary: interfaces to the Catalog handling system + * Description: the catalog module implements the support for + * XML Catalogs and SGML catalogs + * + * SGML Open Technical Resolution TR9401:1997. + * http://www.jclark.com/sp/catalog.htm + * + * XML Catalogs Working Draft 06 August 2001 + * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CATALOG_H__ +#define __XML_CATALOG_H__ + +#include + +#include +#include + +#ifdef LIBXML_CATALOG_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_CATALOGS_NAMESPACE: + * + * The namespace for the XML Catalogs elements. + */ +#define XML_CATALOGS_NAMESPACE \ + (const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog" +/** + * XML_CATALOG_PI: + * + * The specific XML Catalog Processing Instuction name. + */ +#define XML_CATALOG_PI \ + (const xmlChar *) "oasis-xml-catalog" + +/* + * The API is voluntarily limited to general cataloging. + */ +typedef enum { + XML_CATA_PREFER_NONE = 0, + XML_CATA_PREFER_PUBLIC = 1, + XML_CATA_PREFER_SYSTEM +} xmlCatalogPrefer; + +typedef enum { + XML_CATA_ALLOW_NONE = 0, + XML_CATA_ALLOW_GLOBAL = 1, + XML_CATA_ALLOW_DOCUMENT = 2, + XML_CATA_ALLOW_ALL = 3 +} xmlCatalogAllow; + +typedef struct _xmlCatalog xmlCatalog; +typedef xmlCatalog *xmlCatalogPtr; + +/* + * Operations on a given catalog. + */ +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlNewCatalog (int sgml); +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlLoadACatalog (const char *filename); +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlLoadSGMLSuperCatalog (const char *filename); +XMLPUBFUN int XMLCALL + xmlConvertSGMLCatalog (xmlCatalogPtr catal); +XMLPUBFUN int XMLCALL + xmlACatalogAdd (xmlCatalogPtr catal, + const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int XMLCALL + xmlACatalogRemove (xmlCatalogPtr catal, + const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolve (xmlCatalogPtr catal, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolveSystem(xmlCatalogPtr catal, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolvePublic(xmlCatalogPtr catal, + const xmlChar *pubID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolveURI (xmlCatalogPtr catal, + const xmlChar *URI); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlACatalogDump (xmlCatalogPtr catal, + FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeCatalog (xmlCatalogPtr catal); +XMLPUBFUN int XMLCALL + xmlCatalogIsEmpty (xmlCatalogPtr catal); + +/* + * Global operations. + */ +XMLPUBFUN void XMLCALL + xmlInitializeCatalog (void); +XMLPUBFUN int XMLCALL + xmlLoadCatalog (const char *filename); +XMLPUBFUN void XMLCALL + xmlLoadCatalogs (const char *paths); +XMLPUBFUN void XMLCALL + xmlCatalogCleanup (void); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlCatalogDump (FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolve (const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolveSystem (const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolvePublic (const xmlChar *pubID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolveURI (const xmlChar *URI); +XMLPUBFUN int XMLCALL + xmlCatalogAdd (const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int XMLCALL + xmlCatalogRemove (const xmlChar *value); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseCatalogFile (const char *filename); +XMLPUBFUN int XMLCALL + xmlCatalogConvert (void); + +/* + * Strictly minimal interfaces for per-document catalogs used + * by the parser. + */ +XMLPUBFUN void XMLCALL + xmlCatalogFreeLocal (void *catalogs); +XMLPUBFUN void * XMLCALL + xmlCatalogAddLocal (void *catalogs, + const xmlChar *URL); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogLocalResolve (void *catalogs, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogLocalResolveURI(void *catalogs, + const xmlChar *URI); +/* + * Preference settings. + */ +XMLPUBFUN int XMLCALL + xmlCatalogSetDebug (int level); +XMLPUBFUN xmlCatalogPrefer XMLCALL + xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer); +XMLPUBFUN void XMLCALL + xmlCatalogSetDefaults (xmlCatalogAllow allow); +XMLPUBFUN xmlCatalogAllow XMLCALL + xmlCatalogGetDefaults (void); + + +/* DEPRECATED interfaces */ +XMLPUBFUN const xmlChar * XMLCALL + xmlCatalogGetSystem (const xmlChar *sysID); +XMLPUBFUN const xmlChar * XMLCALL + xmlCatalogGetPublic (const xmlChar *pubID); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_CATALOG_ENABLED */ +#endif /* __XML_CATALOG_H__ */ diff --git a/include/libxml/chvalid.h b/include/libxml/chvalid.h new file mode 100755 index 0000000..2700838 --- /dev/null +++ b/include/libxml/chvalid.h @@ -0,0 +1,230 @@ +/* + * Summary: Unicode character range checking + * Description: this module exports interfaces for the character + * range validation APIs + * + * This file is automatically generated from the cvs source + * definition files using the genChRanges.py Python script + * + * Generation date: Tue Nov 18 08:14:21 2003 + * Sources: chvalid.def + * Author: William Brack + */ + +#ifndef __XML_CHVALID_H__ +#define __XML_CHVALID_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define our typedefs and structures + * + */ +typedef struct _xmlChSRange xmlChSRange; +typedef xmlChSRange *xmlChSRangePtr; +struct _xmlChSRange { + unsigned short low; + unsigned short high; +}; + +typedef struct _xmlChLRange xmlChLRange; +typedef xmlChLRange *xmlChLRangePtr; +struct _xmlChLRange { + unsigned int low; + unsigned int high; +}; + +typedef struct _xmlChRangeGroup xmlChRangeGroup; +typedef xmlChRangeGroup *xmlChRangeGroupPtr; +struct _xmlChRangeGroup { + int nbShortRange; + int nbLongRange; + xmlChSRangePtr shortRange; /* points to an array of ranges */ + xmlChLRangePtr longRange; +}; + +/** + * Range checking routine + */ +XMLPUBFUN int XMLCALL + xmlCharInRange(unsigned int val, const xmlChRangeGroupPtr group); + + +/** + * xmlIsBaseChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseChar_ch(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ + ((0x61 <= (c)) && ((c) <= 0x7a)) || \ + ((0xc0 <= (c)) && ((c) <= 0xd6)) || \ + ((0xd8 <= (c)) && ((c) <= 0xf6)) || \ + (0xf8 <= (c))) + +/** + * xmlIsBaseCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseCharQ(c) (((c) < 0x100) ? \ + xmlIsBaseChar_ch((c)) : \ + xmlCharInRange((c), &xmlIsBaseCharGroup)) + +XMLPUBVAR xmlChRangeGroup xmlIsBaseCharGroup; + +/** + * xmlIsBlank_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlank_ch(c) (((c) == 0x20) || \ + ((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd)) + +/** + * xmlIsBlankQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlankQ(c) (((c) < 0x100) ? \ + xmlIsBlank_ch((c)) : 0) + + +/** + * xmlIsChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsChar_ch(c) (((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd) || \ + (0x20 <= (c))) + +/** + * xmlIsCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCharQ(c) (((c) < 0x100) ? \ + xmlIsChar_ch((c)) :\ + (((0x100 <= (c)) && ((c) <= 0xd7ff)) || \ + ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \ + ((0x10000 <= (c)) && ((c) <= 0x10ffff)))) + +XMLPUBVAR xmlChRangeGroup xmlIsCharGroup; + +/** + * xmlIsCombiningQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCombiningQ(c) (((c) < 0x100) ? \ + 0 : \ + xmlCharInRange((c), &xmlIsCombiningGroup)) + +XMLPUBVAR xmlChRangeGroup xmlIsCombiningGroup; + +/** + * xmlIsDigit_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigit_ch(c) (((0x30 <= (c)) && ((c) <= 0x39))) + +/** + * xmlIsDigitQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigitQ(c) (((c) < 0x100) ? \ + xmlIsDigit_ch((c)) : \ + xmlCharInRange((c), &xmlIsDigitGroup)) + +XMLPUBVAR xmlChRangeGroup xmlIsDigitGroup; + +/** + * xmlIsExtender_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtender_ch(c) (((c) == 0xb7)) + +/** + * xmlIsExtenderQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtenderQ(c) (((c) < 0x100) ? \ + xmlIsExtender_ch((c)) : \ + xmlCharInRange((c), &xmlIsExtenderGroup)) + +XMLPUBVAR xmlChRangeGroup xmlIsExtenderGroup; + +/** + * xmlIsIdeographicQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsIdeographicQ(c) (((c) < 0x100) ? \ + 0 :\ + (((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \ + ((c) == 0x3007) || \ + ((0x3021 <= (c)) && ((c) <= 0x3029)))) + +XMLPUBVAR xmlChRangeGroup xmlIsIdeographicGroup; +XMLPUBVAR unsigned char xmlIsPubidChar_tab[256]; + +/** + * xmlIsPubidChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)]) + +/** + * xmlIsPubidCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidCharQ(c) (((c) < 0x100) ? \ + xmlIsPubidChar_ch((c)) : 0) + +XMLPUBFUN int XMLCALL + xmlIsBaseChar(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsBlank(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsChar(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsCombining(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsDigit(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsExtender(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsIdeographic(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsPubidChar(unsigned int ch); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_CHVALID_H__ */ diff --git a/include/libxml/debugXML.h b/include/libxml/debugXML.h new file mode 100755 index 0000000..8e97885 --- /dev/null +++ b/include/libxml/debugXML.h @@ -0,0 +1,196 @@ +/* + * Summary: Tree debugging APIs + * Description: Interfaces to a set of routines used for debugging the tree + * produced by the XML parser. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DEBUG_XML__ +#define __DEBUG_XML__ +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The standard Dump routines. + */ +XMLPUBFUN void XMLCALL + xmlDebugDumpString (FILE *output, + const xmlChar *str); +XMLPUBFUN void XMLCALL + xmlDebugDumpAttr (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpAttrList (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpOneNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpNodeList (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpDocumentHead(FILE *output, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlDebugDumpDocument (FILE *output, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlDebugDumpDTD (FILE *output, + xmlDtdPtr dtd); +XMLPUBFUN void XMLCALL + xmlDebugDumpEntities (FILE *output, + xmlDocPtr doc); + +XMLPUBFUN void XMLCALL + xmlLsOneNode (FILE *output, xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlLsCountNode (xmlNodePtr node); + +XMLPUBFUN const char * XMLCALL + xmlBoolToText (int boolval); + +/**************************************************************** + * * + * The XML shell related structures and functions * + * * + ****************************************************************/ + +/** + * xmlShellReadlineFunc: + * @prompt: a string prompt + * + * This is a generic signature for the XML shell input function. + * + * Returns a string which will be freed by the Shell. + */ +typedef char * (* xmlShellReadlineFunc)(char *prompt); + +/** + * xmlShellCtxt: + * + * A debugging shell context. + * TODO: add the defined function tables. + */ +typedef struct _xmlShellCtxt xmlShellCtxt; +typedef xmlShellCtxt *xmlShellCtxtPtr; +struct _xmlShellCtxt { + char *filename; + xmlDocPtr doc; + xmlNodePtr node; + xmlXPathContextPtr pctxt; + int loaded; + FILE *output; + xmlShellReadlineFunc input; +}; + +/** + * xmlShellCmd: + * @ctxt: a shell context + * @arg: a string argument + * @node: a first node + * @node2: a second node + * + * This is a generic signature for the XML shell functions. + * + * Returns an int, negative returns indicating errors. + */ +typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); + +XMLPUBFUN void XMLCALL + xmlShellPrintXPathError (int errorType, + const char *arg); +XMLPUBFUN void XMLCALL + xmlShellPrintNode (xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlShellPrintXPathResult(xmlXPathObjectPtr list); +XMLPUBFUN int XMLCALL + xmlShellList (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellBase (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellDir (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellCat (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellLoad (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int XMLCALL + xmlShellWrite (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellSave (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN int XMLCALL + xmlShellValidate (xmlShellCtxtPtr ctxt, + char *dtd, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellDu (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr tree, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellPwd (xmlShellCtxtPtr ctxt, + char *buffer, + xmlNodePtr node, + xmlNodePtr node2); + +/* + * The Shell interface. + */ +XMLPUBFUN void XMLCALL + xmlShell (xmlDocPtr doc, + char *filename, + xmlShellReadlineFunc input, + FILE *output); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DEBUG_ENABLED */ +#endif /* __DEBUG_XML__ */ diff --git a/include/libxml/dict.h b/include/libxml/dict.h new file mode 100755 index 0000000..347d4ec --- /dev/null +++ b/include/libxml/dict.h @@ -0,0 +1,58 @@ +/* + * Summary: string dictionnary + * Description: dictionary of reusable strings, just used to avoid allocation + * and freeing operations. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_DICT_H__ +#define __XML_DICT_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The dictionnary. + */ +typedef struct _xmlDict xmlDict; +typedef xmlDict *xmlDictPtr; + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreate (void); +XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreateSub(xmlDictPtr sub); +XMLPUBFUN int XMLCALL + xmlDictReference(xmlDictPtr dict); +XMLPUBFUN void XMLCALL + xmlDictFree (xmlDictPtr dict); + +/* + * Lookup of entry in the dictionnary. + */ +XMLPUBFUN const xmlChar * XMLCALL + xmlDictLookup (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlDictQLookup (xmlDictPtr dict, + const xmlChar *prefix, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlDictOwns (xmlDictPtr dict, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlDictSize (xmlDictPtr dict); +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_DICT_H__ */ diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h new file mode 100755 index 0000000..fe2a697 --- /dev/null +++ b/include/libxml/encoding.h @@ -0,0 +1,224 @@ +/* + * Summary: interface for the encoding conversion functions + * Description: interface for the encoding conversion functions needed for + * XML basic encoding and iconv() support. + * + * Related specs are + * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies + * [ISO-10646] UTF-8 and UTF-16 in Annexes + * [ISO-8859-1] ISO Latin-1 characters codes. + * [UNICODE] The Unicode Consortium, "The Unicode Standard -- + * Worldwide Character Encoding -- Version 1.0", Addison- + * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is + * described in Unicode Technical Report #4. + * [US-ASCII] Coded Character Set--7-bit American Standard Code for + * Information Interchange, ANSI X3.4-1986. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CHAR_ENCODING_H__ +#define __XML_CHAR_ENCODING_H__ + +#include + +#ifdef LIBXML_ICONV_ENABLED +#include +#endif +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlCharEncoding: + * + * Predefined values for some standard encodings. + * Libxml does not do beforehand translation on UTF8 and ISOLatinX. + * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default. + * + * Anything else would have to be translated to UTF8 before being + * given to the parser itself. The BOM for UTF16 and the encoding + * declaration are looked at and a converter is looked for at that + * point. If not found the parser stops here as asked by the XML REC. A + * converter can be registered by the user using xmlRegisterCharEncodingHandler + * but the current form doesn't allow stateful transcoding (a serious + * problem agreed !). If iconv has been found it will be used + * automatically and allow stateful transcoding, the simplest is then + * to be sure to enable iconv and to provide iconv libs for the encoding + * support needed. + * + * Note that the generic "UTF-16" is not a predefined value. Instead, only + * the specific UTF-16LE and UTF-16BE are present. + */ +typedef enum { + XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */ + XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */ + XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */ + XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */ + XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */ + XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */ + XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */ + XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */ + XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */ + XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */ + XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */ + XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */ + XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */ + XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */ + XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */ + XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */ + XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */ + XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */ + XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */ + XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */ + XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */ + XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */ +} xmlCharEncoding; + +/** + * xmlCharEncodingInputFunc: + * @out: a pointer to an array of bytes to store the UTF-8 result + * @outlen: the length of @out + * @in: a pointer to an array of chars in the original encoding + * @inlen: the length of @in + * + * Take a block of chars in the original encoding and try to convert + * it to an UTF-8 block of chars out. + * + * Returns the number of bytes written, -1 if lack of space, or -2 + * if the transcoding failed. + * The value of @inlen after return is the number of octets consumed + * if the return value is positive, else unpredictiable. + * The value of @outlen after return is the number of octets consumed. + */ +typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/** + * xmlCharEncodingOutputFunc: + * @out: a pointer to an array of bytes to store the result + * @outlen: the length of @out + * @in: a pointer to an array of UTF-8 chars + * @inlen: the length of @in + * + * Take a block of UTF-8 chars in and try to convert it to another + * encoding. + * Note: a first call designed to produce heading info is called with + * in = NULL. If stateful this should also initialize the encoder state. + * + * Returns the number of bytes written, -1 if lack of space, or -2 + * if the transcoding failed. + * The value of @inlen after return is the number of octets consumed + * if the return value is positive, else unpredictiable. + * The value of @outlen after return is the number of octets produced. + */ +typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/* + * Block defining the handlers for non UTF-8 encodings. + * If iconv is supported, there are two extra fields. + */ + +typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler; +typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr; +struct _xmlCharEncodingHandler { + char *name; + xmlCharEncodingInputFunc input; + xmlCharEncodingOutputFunc output; +#ifdef LIBXML_ICONV_ENABLED + iconv_t iconv_in; + iconv_t iconv_out; +#endif /* LIBXML_ICONV_ENABLED */ +}; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interfaces for encoding handlers. + */ +XMLPUBFUN void XMLCALL + xmlInitCharEncodingHandlers (void); +XMLPUBFUN void XMLCALL + xmlCleanupCharEncodingHandlers (void); +XMLPUBFUN void XMLCALL + xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlGetCharEncodingHandler (xmlCharEncoding enc); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlFindCharEncodingHandler (const char *name); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlNewCharEncodingHandler (const char *name, + xmlCharEncodingInputFunc input, + xmlCharEncodingOutputFunc output); + +/* + * Interfaces for encoding names and aliases. + */ +XMLPUBFUN int XMLCALL + xmlAddEncodingAlias (const char *name, + const char *alias); +XMLPUBFUN int XMLCALL + xmlDelEncodingAlias (const char *alias); +XMLPUBFUN const char * XMLCALL + xmlGetEncodingAlias (const char *alias); +XMLPUBFUN void XMLCALL + xmlCleanupEncodingAliases (void); +XMLPUBFUN xmlCharEncoding XMLCALL + xmlParseCharEncoding (const char *name); +XMLPUBFUN const char * XMLCALL + xmlGetCharEncodingName (xmlCharEncoding enc); + +/* + * Interfaces directly used by the parsers. + */ +XMLPUBFUN xmlCharEncoding XMLCALL + xmlDetectCharEncoding (const unsigned char *in, + int len); + +XMLPUBFUN int XMLCALL + xmlCharEncOutFunc (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); + +XMLPUBFUN int XMLCALL + xmlCharEncInFunc (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); +XMLPUBFUN int XMLCALL + xmlCharEncFirstLine (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); +XMLPUBFUN int XMLCALL + xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); + +/* + * Export a few useful functions + */ +XMLPUBFUN int XMLCALL + UTF8Toisolat1 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +XMLPUBFUN int XMLCALL + isolat1ToUTF8 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#ifdef __cplusplus +} +#endif + +#endif /* __XML_CHAR_ENCODING_H__ */ diff --git a/include/libxml/entities.h b/include/libxml/entities.h new file mode 100755 index 0000000..5745911 --- /dev/null +++ b/include/libxml/entities.h @@ -0,0 +1,131 @@ +/* + * Summary: interface for the XML entities handling + * Description: this module provides some of the entity API needed + * for the parser and applications. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_ENTITIES_H__ +#define __XML_ENTITIES_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The different valid entity types. + */ +typedef enum { + XML_INTERNAL_GENERAL_ENTITY = 1, + XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, + XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, + XML_INTERNAL_PARAMETER_ENTITY = 4, + XML_EXTERNAL_PARAMETER_ENTITY = 5, + XML_INTERNAL_PREDEFINED_ENTITY = 6 +} xmlEntityType; + +/* + * An unit of storage for an entity, contains the string, the value + * and the linkind data needed for the linking in the hash table. + */ + +struct _xmlEntity { + void *_private; /* application data */ + xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ + const xmlChar *name; /* Entity name */ + struct _xmlNode *children; /* First child link */ + struct _xmlNode *last; /* Last child link */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlChar *orig; /* content without ref substitution */ + xmlChar *content; /* content or ndata if unparsed */ + int length; /* the content length */ + xmlEntityType etype; /* The entity type */ + const xmlChar *ExternalID; /* External identifier for PUBLIC */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ + + struct _xmlEntity *nexte; /* unused */ + const xmlChar *URI; /* the full URI as computed */ + int owner; /* does the entity own the childrens */ +}; + +/* + * All entities are stored in an hash table. + * There is 2 separate hash tables for global and parameter entities. + */ + +typedef struct _xmlHashTable xmlEntitiesTable; +typedef xmlEntitiesTable *xmlEntitiesTablePtr; + +/* + * External functions: + */ + +XMLPUBFUN void XMLCALL + xmlInitializePredefinedEntities (void); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlAddDocEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlAddDtdEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetPredefinedEntity (const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetDocEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetDtdEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetParameterEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN const xmlChar * XMLCALL + xmlEncodeEntities (xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlChar * XMLCALL + xmlEncodeEntitiesReentrant(xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlChar * XMLCALL + xmlEncodeSpecialChars (xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlEntitiesTablePtr XMLCALL + xmlCreateEntitiesTable (void); +XMLPUBFUN xmlEntitiesTablePtr XMLCALL + xmlCopyEntitiesTable (xmlEntitiesTablePtr table); +XMLPUBFUN void XMLCALL + xmlFreeEntitiesTable (xmlEntitiesTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpEntitiesTable (xmlBufferPtr buf, + xmlEntitiesTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpEntityDecl (xmlBufferPtr buf, + xmlEntityPtr ent); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlCleanupPredefinedEntities(void); + + +#ifdef __cplusplus +} +#endif + +# endif /* __XML_ENTITIES_H__ */ diff --git a/include/libxml/globals.h b/include/libxml/globals.h new file mode 100755 index 0000000..afe84f5 --- /dev/null +++ b/include/libxml/globals.h @@ -0,0 +1,455 @@ +/* + * Summary: interface for all global variables of the library + * Description: all the global variables and thread handling for + * those variables is handled by this module. + * + * The bottom of this file is automatically generated by build_glob.py + * based on the description file global.data + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington , Daniel Veillard + */ + +#ifndef __XML_GLOBALS_H +#define __XML_GLOBALS_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL xmlInitGlobals(void); +XMLPUBFUN void XMLCALL xmlCleanupGlobals(void); + +typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc); +typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression); +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc +XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func); +XMLPUBFUN xmlOutputBufferCreateFilenameFunc +XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); + +/* + * Externally global symbols which need to be protected for backwards + * compatibility support. + */ + +#undef docbDefaultSAXHandler +#undef htmlDefaultSAXHandler +#undef oldXMLWDcompatibility +#undef xmlBufferAllocScheme +#undef xmlDefaultBufferSize +#undef xmlDefaultSAXHandler +#undef xmlDefaultSAXLocator +#undef xmlDoValidityCheckingDefaultValue +#undef xmlFree +#undef xmlGenericError +#undef xmlStructuredError +#undef xmlGenericErrorContext +#undef xmlGetWarningsDefaultValue +#undef xmlIndentTreeOutput +#undef xmlTreeIndentString +#undef xmlKeepBlanksDefaultValue +#undef xmlLineNumbersDefaultValue +#undef xmlLoadExtDtdDefaultValue +#undef xmlMalloc +#undef xmlMallocAtomic +#undef xmlMemStrdup +#undef xmlParserDebugEntities +#undef xmlParserVersion +#undef xmlPedanticParserDefaultValue +#undef xmlRealloc +#undef xmlSaveNoEmptyTags +#undef xmlSubstituteEntitiesDefaultValue +#undef xmlRegisterNodeDefaultValue +#undef xmlDeregisterNodeDefaultValue +#undef xmlLastError +#undef xmlParserInputBufferCreateFilenameValue +#undef xmlOutputBufferCreateFilenameValue + +typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node); +typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); + +typedef struct _xmlGlobalState xmlGlobalState; +typedef xmlGlobalState *xmlGlobalStatePtr; +struct _xmlGlobalState +{ + const char *xmlParserVersion; + + xmlSAXLocator xmlDefaultSAXLocator; + xmlSAXHandlerV1 xmlDefaultSAXHandler; + xmlSAXHandlerV1 docbDefaultSAXHandler; + xmlSAXHandlerV1 htmlDefaultSAXHandler; + + xmlFreeFunc xmlFree; + xmlMallocFunc xmlMalloc; + xmlStrdupFunc xmlMemStrdup; + xmlReallocFunc xmlRealloc; + + xmlGenericErrorFunc xmlGenericError; + xmlStructuredErrorFunc xmlStructuredError; + void *xmlGenericErrorContext; + + int oldXMLWDcompatibility; + + xmlBufferAllocationScheme xmlBufferAllocScheme; + int xmlDefaultBufferSize; + + int xmlSubstituteEntitiesDefaultValue; + int xmlDoValidityCheckingDefaultValue; + int xmlGetWarningsDefaultValue; + int xmlKeepBlanksDefaultValue; + int xmlLineNumbersDefaultValue; + int xmlLoadExtDtdDefaultValue; + int xmlParserDebugEntities; + int xmlPedanticParserDefaultValue; + + int xmlSaveNoEmptyTags; + int xmlIndentTreeOutput; + const char *xmlTreeIndentString; + + xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; + xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; + + xmlMallocFunc xmlMallocAtomic; + xmlError xmlLastError; + + xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; + xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; +}; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs); + +XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler); + +XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler); + +XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func); +XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func); +XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func); +XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func); + +XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL + xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func); +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL + xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func); + +/** DOC_DISABLE */ +/* + * In general the memory allocation entry points are not kept + * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED + * - xmlMalloc + * - xmlMallocAtomic + * - xmlRealloc + * - xmlMemStrdup + * - xmlFree + */ + +#ifdef LIBXML_THREAD_ALLOC_ENABLED +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void); +#define xmlMalloc \ +(*(__xmlMalloc())) +#else +XMLPUBVAR xmlMallocFunc xmlMalloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void); +#define xmlMallocAtomic \ +(*(__xmlMallocAtomic())) +#else +XMLPUBVAR xmlMallocFunc xmlMallocAtomic; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void); +#define xmlRealloc \ +(*(__xmlRealloc())) +#else +XMLPUBVAR xmlReallocFunc xmlRealloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void); +#define xmlFree \ +(*(__xmlFree())) +#else +XMLPUBVAR xmlFreeFunc xmlFree; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void); +#define xmlMemStrdup \ +(*(__xmlMemStrdup())) +#else +XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif + +#else /* !LIBXML_THREAD_ALLOC_ENABLED */ +XMLPUBVAR xmlMallocFunc xmlMalloc; +XMLPUBVAR xmlMallocFunc xmlMallocAtomic; +XMLPUBVAR xmlReallocFunc xmlRealloc; +XMLPUBVAR xmlFreeFunc xmlFree; +XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif /* LIBXML_THREAD_ALLOC_ENABLED */ + +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define docbDefaultSAXHandler \ +(*(__docbDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler; +#endif +#endif + +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define htmlDefaultSAXHandler \ +(*(__htmlDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler; +#endif +#endif + +XMLPUBFUN xmlError * XMLCALL __xmlLastError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLastError \ +(*(__xmlLastError())) +#else +XMLPUBVAR xmlError xmlLastError; +#endif + +/* + * Everything starting from the line below is + * Automatically generated by build_glob.py. + * Do not modify the previous line. + */ + + +XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void); +#ifdef LIBXML_THREAD_ENABLED +#define oldXMLWDcompatibility \ +(*(__oldXMLWDcompatibility())) +#else +XMLPUBVAR int oldXMLWDcompatibility; +#endif + +XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlBufferAllocScheme \ +(*(__xmlBufferAllocScheme())) +#else +XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme; +#endif +XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v); + +XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultBufferSize \ +(*(__xmlDefaultBufferSize())) +#else +XMLPUBVAR int xmlDefaultBufferSize; +#endif +XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v); + +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultSAXHandler \ +(*(__xmlDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler; +#endif + +XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultSAXLocator \ +(*(__xmlDefaultSAXLocator())) +#else +XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator; +#endif + +XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDoValidityCheckingDefaultValue \ +(*(__xmlDoValidityCheckingDefaultValue())) +#else +XMLPUBVAR int xmlDoValidityCheckingDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v); + +XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGenericError \ +(*(__xmlGenericError())) +#else +XMLPUBVAR xmlGenericErrorFunc xmlGenericError; +#endif + +XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlStructuredError \ +(*(__xmlStructuredError())) +#else +XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError; +#endif + +XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGenericErrorContext \ +(*(__xmlGenericErrorContext())) +#else +XMLPUBVAR void * xmlGenericErrorContext; +#endif + +XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGetWarningsDefaultValue \ +(*(__xmlGetWarningsDefaultValue())) +#else +XMLPUBVAR int xmlGetWarningsDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlIndentTreeOutput \ +(*(__xmlIndentTreeOutput())) +#else +XMLPUBVAR int xmlIndentTreeOutput; +#endif +XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v); + +XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlTreeIndentString \ +(*(__xmlTreeIndentString())) +#else +XMLPUBVAR const char * xmlTreeIndentString; +#endif +XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v); + +XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlKeepBlanksDefaultValue \ +(*(__xmlKeepBlanksDefaultValue())) +#else +XMLPUBVAR int xmlKeepBlanksDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLineNumbersDefaultValue \ +(*(__xmlLineNumbersDefaultValue())) +#else +XMLPUBVAR int xmlLineNumbersDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLoadExtDtdDefaultValue \ +(*(__xmlLoadExtDtdDefaultValue())) +#else +XMLPUBVAR int xmlLoadExtDtdDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserDebugEntities \ +(*(__xmlParserDebugEntities())) +#else +XMLPUBVAR int xmlParserDebugEntities; +#endif +XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v); + +XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserVersion \ +(*(__xmlParserVersion())) +#else +XMLPUBVAR const char * xmlParserVersion; +#endif + +XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlPedanticParserDefaultValue \ +(*(__xmlPedanticParserDefaultValue())) +#else +XMLPUBVAR int xmlPedanticParserDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlSaveNoEmptyTags \ +(*(__xmlSaveNoEmptyTags())) +#else +XMLPUBVAR int xmlSaveNoEmptyTags; +#endif +XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v); + +XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlSubstituteEntitiesDefaultValue \ +(*(__xmlSubstituteEntitiesDefaultValue())) +#else +XMLPUBVAR int xmlSubstituteEntitiesDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v); + +XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlRegisterNodeDefaultValue \ +(*(__xmlRegisterNodeDefaultValue())) +#else +XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; +#endif + +XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDeregisterNodeDefaultValue \ +(*(__xmlDeregisterNodeDefaultValue())) +#else +XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; +#endif + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserInputBufferCreateFilenameValue \ +(*(__xmlParserInputBufferCreateFilenameValue())) +#else +XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; +#endif + +XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlOutputBufferCreateFilenameValue \ +(*(__xmlOutputBufferCreateFilenameValue())) +#else +XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_GLOBALS_H */ diff --git a/include/libxml/hash.h b/include/libxml/hash.h new file mode 100755 index 0000000..d861e36 --- /dev/null +++ b/include/libxml/hash.h @@ -0,0 +1,206 @@ +/* + * Summary: chained hash tables + * description: this module implement the hash table support used in + * various place in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Bjorn Reese + */ + +#ifndef __XML_HASH_H__ +#define __XML_HASH_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The hash table. + */ +typedef struct _xmlHashTable xmlHashTable; +typedef xmlHashTable *xmlHashTablePtr; + +#ifdef __cplusplus +} +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * function types: + */ +/** + * xmlHashDeallocator: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to free data from a hash. + */ +typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name); +/** + * xmlHashCopier: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to copy data from a hash. + * + * Returns a copy of the data or NULL in case of error. + */ +typedef void *(*xmlHashCopier)(void *payload, xmlChar *name); +/** + * xmlHashScanner: + * @payload: the data in the hash + * @data: extra scannner data + * @name: the name associated + * + * Callback when scanning data in a hash with the simple scanner. + */ +typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name); +/** + * xmlHashScannerFull: + * @payload: the data in the hash + * @data: extra scannner data + * @name: the name associated + * @name2: the second name associated + * @name3: the third name associated + * + * Callback when scanning data in a hash with the full scanner. + */ +typedef void (*xmlHashScannerFull)(void *payload, void *data, + const xmlChar *name, const xmlChar *name2, + const xmlChar *name3); + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCreate (int size); +XMLPUBFUN void XMLCALL + xmlHashFree (xmlHashTablePtr table, + xmlHashDeallocator f); + +/* + * Add a new entry to the hash table. + */ +XMLPUBFUN int XMLCALL + xmlHashAddEntry (xmlHashTablePtr table, + const xmlChar *name, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry(xmlHashTablePtr table, + const xmlChar *name, + void *userdata, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashAddEntry2(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry2(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + void *userdata, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashAddEntry3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata, + xmlHashDeallocator f); + +/* + * Remove an entry from the hash table. + */ +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + xmlHashDeallocator f); + +/* + * Retrieve the userdata. + */ +XMLPUBFUN void * XMLCALL + xmlHashLookup (xmlHashTablePtr table, + const xmlChar *name); +XMLPUBFUN void * XMLCALL + xmlHashLookup2 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2); +XMLPUBFUN void * XMLCALL + xmlHashLookup3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3); +XMLPUBFUN void * XMLCALL + xmlHashQLookup (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN void * XMLCALL + xmlHashQLookup2 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix, + const xmlChar *name2, + const xmlChar *prefix2); +XMLPUBFUN void * XMLCALL + xmlHashQLookup3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix, + const xmlChar *name2, + const xmlChar *prefix2, + const xmlChar *name3, + const xmlChar *prefix3); + +/* + * Helpers. + */ +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCopy (xmlHashTablePtr table, + xmlHashCopier f); +XMLPUBFUN int XMLCALL + xmlHashSize (xmlHashTablePtr table); +XMLPUBFUN void XMLCALL + xmlHashScan (xmlHashTablePtr table, + xmlHashScanner f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScan3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScanner f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScanFull (xmlHashTablePtr table, + xmlHashScannerFull f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScanFull3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScannerFull f, + void *data); +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_HASH_H__ */ diff --git a/include/libxml/list.h b/include/libxml/list.h new file mode 100755 index 0000000..bef39a1 --- /dev/null +++ b/include/libxml/list.h @@ -0,0 +1,137 @@ +/* + * Summary: lists interfaces + * Description: this module implement the list support used in + * various place in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington + */ + +#ifndef __XML_LINK_INCLUDE__ +#define __XML_LINK_INCLUDE__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlLink xmlLink; +typedef xmlLink *xmlLinkPtr; + +typedef struct _xmlList xmlList; +typedef xmlList *xmlListPtr; + +/** + * xmlListDeallocator: + * @lk: the data to deallocate + * + * Callback function used to free data from a list. + */ +typedef void (*xmlListDeallocator) (xmlLinkPtr lk); +/** + * xmlListDataCompare: + * @data0: the first data + * @data1: the second data + * + * Callback function used to compare 2 data. + * + * Returns 0 is equality, -1 or 1 otherwise depending on the ordering. + */ +typedef int (*xmlListDataCompare) (const void *data0, const void *data1); +/** + * xmlListWalker: + * @data: the data found in the list + * @user: extra user provided data to the walker + * + * Callback function used when walking a list with xmlListWalk(). + * + * Returns 0 to stop walking the list, 1 otherwise. + */ +typedef int (*xmlListWalker) (const void *data, const void *user); + +/* Creation/Deletion */ +XMLPUBFUN xmlListPtr XMLCALL + xmlListCreate (xmlListDeallocator deallocator, + xmlListDataCompare compare); +XMLPUBFUN void XMLCALL + xmlListDelete (xmlListPtr l); + +/* Basic Operators */ +XMLPUBFUN void * XMLCALL + xmlListSearch (xmlListPtr l, + void *data); +XMLPUBFUN void * XMLCALL + xmlListReverseSearch (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListInsert (xmlListPtr l, + void *data) ; +XMLPUBFUN int XMLCALL + xmlListAppend (xmlListPtr l, + void *data) ; +XMLPUBFUN int XMLCALL + xmlListRemoveFirst (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListRemoveLast (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListRemoveAll (xmlListPtr l, + void *data); +XMLPUBFUN void XMLCALL + xmlListClear (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListEmpty (xmlListPtr l); +XMLPUBFUN xmlLinkPtr XMLCALL + xmlListFront (xmlListPtr l); +XMLPUBFUN xmlLinkPtr XMLCALL + xmlListEnd (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListSize (xmlListPtr l); + +XMLPUBFUN void XMLCALL + xmlListPopFront (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListPopBack (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListPushFront (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListPushBack (xmlListPtr l, + void *data); + +/* Advanced Operators */ +XMLPUBFUN void XMLCALL + xmlListReverse (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListSort (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListWalk (xmlListPtr l, + xmlListWalker walker, + const void *user); +XMLPUBFUN void XMLCALL + xmlListReverseWalk (xmlListPtr l, + xmlListWalker walker, + const void *user); +XMLPUBFUN void XMLCALL + xmlListMerge (xmlListPtr l1, + xmlListPtr l2); +XMLPUBFUN xmlListPtr XMLCALL + xmlListDup (const xmlListPtr old); +XMLPUBFUN int XMLCALL + xmlListCopy (xmlListPtr cur, + const xmlListPtr old); +/* Link operators */ +XMLPUBFUN void * XMLCALL + xmlLinkGetData (xmlLinkPtr lk); + +/* xmlListUnique() */ +/* xmlListSwap */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_LINK_INCLUDE__ */ diff --git a/include/libxml/nanoftp.h b/include/libxml/nanoftp.h new file mode 100755 index 0000000..ad82f59 --- /dev/null +++ b/include/libxml/nanoftp.h @@ -0,0 +1,143 @@ +/* + * Summary: minimal FTP implementation + * Description: minimal FTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_FTP_H__ +#define __NANO_FTP_H__ + +#include + +#ifdef LIBXML_FTP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * ftpListCallback: + * @userData: user provided data for the callback + * @filename: the file name (including "->" when links are shown) + * @attrib: the attribute string + * @owner: the owner string + * @group: the group string + * @size: the file size + * @links: the link count + * @year: the year + * @month: the month + * @day: the day + * @hour: the hour + * @minute: the minute + * + * A callback for the xmlNanoFTPList command. + * Note that only one of year and day:minute are specified. + */ +typedef void (*ftpListCallback) (void *userData, + const char *filename, const char *attrib, + const char *owner, const char *group, + unsigned long size, int links, int year, + const char *month, int day, int hour, + int minute); +/** + * ftpDataCallback: + * @userData: the user provided context + * @data: the data received + * @len: its size in bytes + * + * A callback for the xmlNanoFTPGet command. + */ +typedef void (*ftpDataCallback) (void *userData, + const char *data, + int len); + +/* + * Init + */ +XMLPUBFUN void XMLCALL + xmlNanoFTPInit (void); +XMLPUBFUN void XMLCALL + xmlNanoFTPCleanup (void); + +/* + * Creating/freeing contexts. + */ +XMLPUBFUN void * XMLCALL + xmlNanoFTPNewCtxt (const char *URL); +XMLPUBFUN void XMLCALL + xmlNanoFTPFreeCtxt (void * ctx); +XMLPUBFUN void * XMLCALL + xmlNanoFTPConnectTo (const char *server, + int port); +/* + * Opening/closing session connections. + */ +XMLPUBFUN void * XMLCALL + xmlNanoFTPOpen (const char *URL); +XMLPUBFUN int XMLCALL + xmlNanoFTPConnect (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPClose (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPQuit (void *ctx); +XMLPUBFUN void XMLCALL + xmlNanoFTPScanProxy (const char *URL); +XMLPUBFUN void XMLCALL + xmlNanoFTPProxy (const char *host, + int port, + const char *user, + const char *passwd, + int type); +XMLPUBFUN int XMLCALL + xmlNanoFTPUpdateURL (void *ctx, + const char *URL); + +/* + * Rather internal commands. + */ +XMLPUBFUN int XMLCALL + xmlNanoFTPGetResponse (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPCheckResponse (void *ctx); + +/* + * CD/DIR/GET handlers. + */ +XMLPUBFUN int XMLCALL + xmlNanoFTPCwd (void *ctx, + char *directory); +XMLPUBFUN int XMLCALL + xmlNanoFTPDele (void *ctx, + char *file); + +XMLPUBFUN int XMLCALL + xmlNanoFTPGetConnection (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPCloseConnection(void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPList (void *ctx, + ftpListCallback callback, + void *userData, + char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPGetSocket (void *ctx, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPGet (void *ctx, + ftpDataCallback callback, + void *userData, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPRead (void *ctx, + void *dest, + int len); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_FTP_ENABLED */ +#endif /* __NANO_FTP_H__ */ diff --git a/include/libxml/nanohttp.h b/include/libxml/nanohttp.h new file mode 100755 index 0000000..0ea4cd4 --- /dev/null +++ b/include/libxml/nanohttp.h @@ -0,0 +1,79 @@ +/* + * Summary: minimal HTTP implementation + * Description: minimal HTTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_HTTP_H__ +#define __NANO_HTTP_H__ + +#include + +#ifdef LIBXML_HTTP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN void XMLCALL + xmlNanoHTTPInit (void); +XMLPUBFUN void XMLCALL + xmlNanoHTTPCleanup (void); +XMLPUBFUN void XMLCALL + xmlNanoHTTPScanProxy (const char *URL); +XMLPUBFUN int XMLCALL + xmlNanoHTTPFetch (const char *URL, + const char *filename, + char **contentType); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPMethod (const char *URL, + const char *method, + const char *input, + char **contentType, + const char *headers, + int ilen); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPMethodRedir (const char *URL, + const char *method, + const char *input, + char **contentType, + char **redir, + const char *headers, + int ilen); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPOpen (const char *URL, + char **contentType); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPOpenRedir (const char *URL, + char **contentType, + char **redir); +XMLPUBFUN int XMLCALL + xmlNanoHTTPReturnCode (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPAuthHeader (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPRedir (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPEncoding (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPMimeType (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoHTTPRead (void *ctx, + void *dest, + int len); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int XMLCALL + xmlNanoHTTPSave (void *ctxt, + const char *filename); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNanoHTTPClose (void *ctx); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTTP_ENABLED */ +#endif /* __NANO_HTTP_H__ */ diff --git a/include/libxml/parser.h b/include/libxml/parser.h new file mode 100755 index 0000000..3bc6d90 --- /dev/null +++ b/include/libxml/parser.h @@ -0,0 +1,1153 @@ +/* + * Summary: the core parser module + * Description: Interfaces, constants and types related to the XML parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_H__ +#define __XML_PARSER_H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_DEFAULT_VERSION: + * + * The default version of XML used: 1.0 + */ +#define XML_DEFAULT_VERSION "1.0" + +/** + * xmlParserInput: + * + * An xmlParserInput is an input flow for the XML processor. + * Each entity parsed is associated an xmlParserInput (except the + * few predefined ones). This is the case both for internal entities + * - in which case the flow is already completely in memory - or + * external entities - in which case we use the buf structure for + * progressive reading and I18N conversions to the internal UTF-8 format. + */ + +/** + * xmlParserInputDeallocate: + * @str: the string to deallocate + * + * Callback for freeing some parser input allocations. + */ +typedef void (* xmlParserInputDeallocate)(xmlChar *str); + +struct _xmlParserInput { + /* Input buffer */ + xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ + + const char *filename; /* The file analyzed, if any */ + const char *directory; /* the directory/base of the file */ + const xmlChar *base; /* Base of the array to parse */ + const xmlChar *cur; /* Current char being parsed */ + const xmlChar *end; /* end of the array to parse */ + int length; /* length if known */ + int line; /* Current line */ + int col; /* Current column */ + /* + * NOTE: consumed is only tested for equality in the parser code, + * so even if there is an overflow this should not give troubles + * for parsing very large instances. + */ + unsigned long consumed; /* How many xmlChars already consumed */ + xmlParserInputDeallocate free; /* function to deallocate the base */ + const xmlChar *encoding; /* the encoding string for entity */ + const xmlChar *version; /* the version string for entity */ + int standalone; /* Was that entity marked standalone */ + int id; /* an unique identifier for the entity */ +}; + +/** + * xmlParserNodeInfo: + * + * The parser can be asked to collect Node informations, i.e. at what + * place in the file they were detected. + * NOTE: This is off by default and not very well tested. + */ +typedef struct _xmlParserNodeInfo xmlParserNodeInfo; +typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; + +struct _xmlParserNodeInfo { + const struct _xmlNode* node; + /* Position & line # that text that created the node begins & ends on */ + unsigned long begin_pos; + unsigned long begin_line; + unsigned long end_pos; + unsigned long end_line; +}; + +typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; +typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; +struct _xmlParserNodeInfoSeq { + unsigned long maximum; + unsigned long length; + xmlParserNodeInfo* buffer; +}; + +/** + * xmlParserInputState: + * + * The parser is now working also as a state based parser. + * The recursive one use the state info for entities processing. + */ +typedef enum { + XML_PARSER_EOF = -1, /* nothing is to be parsed */ + XML_PARSER_START = 0, /* nothing has been parsed */ + XML_PARSER_MISC, /* Misc* before int subset */ + XML_PARSER_PI, /* Within a processing instruction */ + XML_PARSER_DTD, /* within some DTD content */ + XML_PARSER_PROLOG, /* Misc* after internal subset */ + XML_PARSER_COMMENT, /* within a comment */ + XML_PARSER_START_TAG, /* within a start tag */ + XML_PARSER_CONTENT, /* within the content */ + XML_PARSER_CDATA_SECTION, /* within a CDATA section */ + XML_PARSER_END_TAG, /* within a closing tag */ + XML_PARSER_ENTITY_DECL, /* within an entity declaration */ + XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ + XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ + XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ + XML_PARSER_EPILOG, /* the Misc* after the last end tag */ + XML_PARSER_IGNORE, /* within an IGNORED section */ + XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */ +} xmlParserInputState; + +/** + * XML_DETECT_IDS: + * + * Bit in the loadsubset context field to tell to do ID/REFs lookups. + * Use it to initialize xmlLoadExtDtdDefaultValue. + */ +#define XML_DETECT_IDS 2 + +/** + * XML_COMPLETE_ATTRS: + * + * Bit in the loadsubset context field to tell to do complete the + * elements attributes lists with the ones defaulted from the DTDs. + * Use it to initialize xmlLoadExtDtdDefaultValue. + */ +#define XML_COMPLETE_ATTRS 4 + +/** + * XML_SKIP_IDS: + * + * Bit in the loadsubset context field to tell to not do ID/REFs registration. + * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. + */ +#define XML_SKIP_IDS 8 + +/** + * xmlParserMode: + * + * A parser can operate in various modes + */ +typedef enum { + XML_PARSE_UNKNOWN = 0, + XML_PARSE_DOM = 1, + XML_PARSE_SAX = 2, + XML_PARSE_PUSH_DOM = 3, + XML_PARSE_PUSH_SAX = 4, + XML_PARSE_READER = 5 +} xmlParserMode; + +/** + * xmlParserCtxt: + * + * The parser context. + * NOTE This doesn't completely define the parser state, the (current ?) + * design of the parser uses recursive function calls since this allow + * and easy mapping from the production rules of the specification + * to the actual code. The drawback is that the actual function call + * also reflect the parser state. However most of the parsing routines + * takes as the only argument the parser context pointer, so migrating + * to a state based parser for progressive parsing shouldn't be too hard. + */ +struct _xmlParserCtxt { + struct _xmlSAXHandler *sax; /* The SAX handler */ + void *userData; /* For SAX interface only, used by DOM build */ + xmlDocPtr myDoc; /* the document being built */ + int wellFormed; /* is the document well formed */ + int replaceEntities; /* shall we replace entities ? */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* the declared encoding, if any */ + int standalone; /* standalone document */ + int html; /* an HTML(1)/Docbook(2) document */ + + /* Input stream stack */ + xmlParserInputPtr input; /* Current input stream */ + int inputNr; /* Number of current input streams */ + int inputMax; /* Max number of input streams */ + xmlParserInputPtr *inputTab; /* stack of inputs */ + + /* Node analysis stack only used for DOM building */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + int record_info; /* Whether node info should be kept */ + xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ + + int errNo; /* error code */ + + int hasExternalSubset; /* reference and external subset */ + int hasPErefs; /* the internal subset has PE refs */ + int external; /* are we parsing an external entity */ + + int valid; /* is the document valid */ + int validate; /* shall we try to validate ? */ + xmlValidCtxt vctxt; /* The validity context */ + + xmlParserInputState instate; /* current type of input */ + int token; /* next char look-ahead */ + + char *directory; /* the data directory */ + + /* Node name stack */ + const xmlChar *name; /* Current parsed Node */ + int nameNr; /* Depth of the parsing stack */ + int nameMax; /* Max depth of the parsing stack */ + const xmlChar * *nameTab; /* array of nodes */ + + long nbChars; /* number of xmlChar processed */ + long checkIndex; /* used by progressive parsing lookup */ + int keepBlanks; /* ugly but ... */ + int disableSAX; /* SAX callbacks are disabled */ + int inSubset; /* Parsing is in int 1/ext 2 subset */ + const xmlChar * intSubName; /* name of subset */ + xmlChar * extSubURI; /* URI of external subset */ + xmlChar * extSubSystem; /* SYSTEM ID of external subset */ + + /* xml:space values */ + int * space; /* Should the parser preserve spaces */ + int spaceNr; /* Depth of the parsing stack */ + int spaceMax; /* Max depth of the parsing stack */ + int * spaceTab; /* array of space infos */ + + int depth; /* to prevent entity substitution loops */ + xmlParserInputPtr entity; /* used to check entities boundaries */ + int charset; /* encoding of the in-memory content + actually an xmlCharEncoding */ + int nodelen; /* Those two fields are there to */ + int nodemem; /* Speed up large node parsing */ + int pedantic; /* signal pedantic warnings */ + void *_private; /* For user data, libxml won't touch it */ + + int loadsubset; /* should the external subset be loaded */ + int linenumbers; /* set line number in element content */ + void *catalogs; /* document's own catalog */ + int recovery; /* run in recovery mode */ + int progressive; /* is this a progressive parsing */ + xmlDictPtr dict; /* dictionnary for the parser */ + const xmlChar * *atts; /* array for the attributes callbacks */ + int maxatts; /* the size of the array */ + int docdict; /* use strings from dict to build tree */ + + /* + * pre-interned strings + */ + const xmlChar *str_xml; + const xmlChar *str_xmlns; + const xmlChar *str_xml_ns; + + /* + * Everything below is used only by the new SAX mode + */ + int sax2; /* operating in the new SAX mode */ + int nsNr; /* the number of inherited namespaces */ + int nsMax; /* the size of the arrays */ + const xmlChar * *nsTab; /* the array of prefix/namespace name */ + int *attallocs; /* which attribute were allocated */ + void * *pushTab; /* array of data for push */ + xmlHashTablePtr attsDefault; /* defaulted attributes if any */ + xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ + int nsWellFormed; /* is the document XML Nanespace okay */ + int options; /* Extra options */ + + /* + * Those fields are needed only for treaming parsing so far + */ + int dictNames; /* Use dictionary names for the tree */ + int freeElemsNr; /* number of freed element nodes */ + xmlNodePtr freeElems; /* List of freed element nodes */ + int freeAttrsNr; /* number of freed attributes nodes */ + xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ + + /* + * the complete error informations for the last error. + */ + xmlError lastError; + xmlParserMode parseMode; /* the parser mode */ +}; + +/** + * xmlSAXLocator: + * + * A SAX Locator. + */ +struct _xmlSAXLocator { + const xmlChar *(*getPublicId)(void *ctx); + const xmlChar *(*getSystemId)(void *ctx); + int (*getLineNumber)(void *ctx); + int (*getColumnNumber)(void *ctx); +}; + +/** + * xmlSAXHandler: + * + * A SAX handler is bunch of callbacks called by the parser when processing + * of the input generate data or structure informations. + */ + +/** + * resolveEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Callback: + * The entity loader, to control the loading of external entities, + * the application can either: + * - override this resolveEntity() callback in the SAX block + * - or better use the xmlSetExternalEntityLoader() function to + * set up it's own entity resolution routine + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * internalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on internal subset declaration. + */ +typedef void (*internalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * externalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on external subset declaration. + */ +typedef void (*externalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * getEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get an entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * getParameterEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get a parameter entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * entityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed. + */ +typedef void (*entityDeclSAXFunc) (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +/** + * notationDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +typedef void (*notationDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * attributeDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @elem: the name of the element + * @fullname: the attribute name + * @type: the attribute type + * @def: the type of default value + * @defaultValue: the attribute default value + * @tree: the tree of enumerated value set + * + * An attribute definition has been parsed. + */ +typedef void (*attributeDeclSAXFunc)(void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +/** + * elementDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the element name + * @type: the element type + * @content: the element value tree + * + * An element definition has been parsed. + */ +typedef void (*elementDeclSAXFunc)(void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +/** + * unparsedEntityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed. + */ +typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); +/** + * setDocumentLocatorSAXFunc: + * @ctx: the user data (XML parser context) + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator. + * Everything is available on the context, so this is useless in our case. + */ +typedef void (*setDocumentLocatorSAXFunc) (void *ctx, + xmlSAXLocatorPtr loc); +/** + * startDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document start being processed. + */ +typedef void (*startDocumentSAXFunc) (void *ctx); +/** + * endDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document end has been detected. + */ +typedef void (*endDocumentSAXFunc) (void *ctx); +/** + * startElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name, including namespace prefix + * @atts: An array of name/value attributes pairs, NULL terminated + * + * Called when an opening tag has been processed. + */ +typedef void (*startElementSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar **atts); +/** + * endElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name + * + * Called when the end of an element has been detected. + */ +typedef void (*endElementSAXFunc) (void *ctx, + const xmlChar *name); +/** + * attributeSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The attribute name, including namespace prefix + * @value: The attribute value + * + * Handle an attribute that has been read by the parser. + * The default handling is to convert the attribute into an + * DOM subtree and past it in a new xmlAttr element added to + * the element. + */ +typedef void (*attributeSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *value); +/** + * referenceSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Called when an entity reference is detected. + */ +typedef void (*referenceSAXFunc) (void *ctx, + const xmlChar *name); +/** + * charactersSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some chars from the parser. + */ +typedef void (*charactersSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * ignorableWhitespaceSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some ignorable whitespaces from the parser. + * UNUSED: by default the DOM building will use characters. + */ +typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * processingInstructionSAXFunc: + * @ctx: the user data (XML parser context) + * @target: the target name + * @data: the PI data's + * + * A processing instruction has been parsed. + */ +typedef void (*processingInstructionSAXFunc) (void *ctx, + const xmlChar *target, + const xmlChar *data); +/** + * commentSAXFunc: + * @ctx: the user data (XML parser context) + * @value: the comment content + * + * A comment has been parsed. + */ +typedef void (*commentSAXFunc) (void *ctx, + const xmlChar *value); +/** + * cdataBlockSAXFunc: + * @ctx: the user data (XML parser context) + * @value: The pcdata content + * @len: the block length + * + * Called when a pcdata block has been parsed. + */ +typedef void (*cdataBlockSAXFunc) ( + void *ctx, + const xmlChar *value, + int len); +/** + * warningSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a warning messages, callback. + */ +typedef void (*warningSAXFunc) (void *ctx, + const char *msg, ...); +/** + * errorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format an error messages, callback. + */ +typedef void (*errorSAXFunc) (void *ctx, + const char *msg, ...); +/** + * fatalErrorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format fatal error messages, callback. + * Note: so far fatalError() SAX callbacks are not used, error() + * get all the callbacks for errors. + */ +typedef void (*fatalErrorSAXFunc) (void *ctx, + const char *msg, ...); +/** + * isStandaloneSAXFunc: + * @ctx: the user data (XML parser context) + * + * Is this document tagged standalone? + * + * Returns 1 if true + */ +typedef int (*isStandaloneSAXFunc) (void *ctx); +/** + * hasInternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an internal subset. + * + * Returns 1 if true + */ +typedef int (*hasInternalSubsetSAXFunc) (void *ctx); + +/** + * hasExternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an external subset? + * + * Returns 1 if true + */ +typedef int (*hasExternalSubsetSAXFunc) (void *ctx); + +/************************************************************************ + * * + * The SAX version 2 API extensions * + * * + ************************************************************************/ +/** + * XML_SAX2_MAGIC: + * + * Special constant found in SAX2 blocks initialized fields + */ +#define XML_SAX2_MAGIC 0xDEEDBEAF + +/** + * startElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * @nb_namespaces: number of namespace definitions on that node + * @namespaces: pointer to the array of prefix/URI pairs namespace definitions + * @nb_attributes: the number of attributes on that node + * @nb_defaulted: the number of defaulted attributes. The defaulted + * ones are at the end of the array + * @attributes: pointer to the array of (localname/prefix/URI/value/end) + * attribute values. + * + * SAX2 callback when an element start has been detected by the parser. + * It provides the namespace informations for the element, as well as + * the new namespace declarations on the element. + */ + +typedef void (*startElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +/** + * endElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * + * SAX2 callback when an element end has been detected by the parser. + * It provides the namespace informations for the element. + */ + +typedef void (*endElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + + +struct _xmlSAXHandler { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; + /* The following fields are extensions available only on version 2 */ + void *_private; + startElementNsSAX2Func startElementNs; + endElementNsSAX2Func endElementNs; + xmlStructuredErrorFunc serror; +}; + +/* + * SAX Version 1 + */ +typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; +typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; +struct _xmlSAXHandlerV1 { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; +}; + + +/** + * xmlExternalEntityLoader: + * @URL: The System ID of the resource requested + * @ID: The Public ID of the resource requested + * @context: the XML parser context + * + * External entity loaders types. + * + * Returns the entity input parser. + */ +typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, + const char *ID, + xmlParserCtxtPtr context); + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Init/Cleanup + */ +XMLPUBFUN void XMLCALL + xmlInitParser (void); +XMLPUBFUN void XMLCALL + xmlCleanupParser (void); + +/* + * Input functions + */ +XMLPUBFUN int XMLCALL + xmlParserInputRead (xmlParserInputPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputGrow (xmlParserInputPtr in, + int len); + +/* + * Basic parsing Interfaces + */ +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseDoc (xmlChar *cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseMemory (const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseFile (const char *filename); +XMLPUBFUN int XMLCALL + xmlSubstituteEntitiesDefault(int val); +XMLPUBFUN int XMLCALL + xmlKeepBlanksDefault (int val); +XMLPUBFUN void XMLCALL + xmlStopParser (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlPedanticParserDefault(int val); +XMLPUBFUN int XMLCALL + xmlLineNumbersDefault (int val); + +/* + * Recovery mode + */ +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverDoc (xmlChar *cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverMemory (const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverFile (const char *filename); + +/* + * Less common routines and SAX interfaces + */ +XMLPUBFUN int XMLCALL + xmlParseDocument (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseDoc (xmlSAXHandlerPtr sax, + xmlChar *cur, + int recovery); +XMLPUBFUN int XMLCALL + xmlSAXUserParseFile (xmlSAXHandlerPtr sax, + void *user_data, + const char *filename); +XMLPUBFUN int XMLCALL + xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, + void *user_data, + const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseMemory (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery, + void *data); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseFile (xmlSAXHandlerPtr sax, + const char *filename, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, + const char *filename, + int recovery, + void *data); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseEntity (xmlSAXHandlerPtr sax, + const char *filename); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseEntity (const char *filename); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlParseDTD (const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlSAXParseDTD (xmlSAXHandlerPtr sax, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlIOParseDTD (xmlSAXHandlerPtr sax, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlParseBalancedChunkMemory(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst); +XMLPUBFUN xmlParserErrors XMLCALL + xmlParseInNodeContext (xmlNodePtr node, + const char *data, + int datalen, + int options, + xmlNodePtr *lst); +XMLPUBFUN int XMLCALL + xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst, + int recover); +XMLPUBFUN int XMLCALL + xmlParseExternalEntity (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); +XMLPUBFUN int XMLCALL + xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); + +/* + * Parser contexts handling. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlNewParserCtxt (void); +XMLPUBFUN int XMLCALL + xmlInitParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlClearParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, + const xmlChar* buffer, + const char *filename); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateDocParserCtxt (const xmlChar *cur); + +/* + * Reading/setting optional parsing features. + */ + +XMLPUBFUN int XMLCALL + xmlGetFeaturesList (int *len, + const char **result); +XMLPUBFUN int XMLCALL + xmlGetFeature (xmlParserCtxtPtr ctxt, + const char *name, + void *result); +XMLPUBFUN int XMLCALL + xmlSetFeature (xmlParserCtxtPtr ctxt, + const char *name, + void *value); + +#ifdef LIBXML_PUSH_ENABLED +/* + * Interfaces for the Push mode. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename); +XMLPUBFUN int XMLCALL + xmlParseChunk (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +/* + * Special I/O mode. + */ + +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, + void *user_data, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewIOInputStream (xmlParserCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); + +/* + * Node infos. + */ +XMLPUBFUN const xmlParserNodeInfo* XMLCALL + xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, + const xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XMLPUBFUN void XMLCALL + xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XMLPUBFUN unsigned long XMLCALL + xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, + const xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, + const xmlParserNodeInfoPtr info); + +/* + * External entities handling actually implemented in xmlIO. + */ + +XMLPUBFUN void XMLCALL + xmlSetExternalEntityLoader(xmlExternalEntityLoader f); +XMLPUBFUN xmlExternalEntityLoader XMLCALL + xmlGetExternalEntityLoader(void); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlLoadExternalEntity (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +/* + * Index lookup, actually implemented in the encoding module + */ +XMLPUBFUN long XMLCALL + xmlByteConsumed (xmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + XML_PARSE_RECOVER = 1<<0, /* recover on errors */ + XML_PARSE_NOENT = 1<<1, /* substitute entities */ + XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ + XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ + XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ + XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ + XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ + XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */ + XML_PARSE_NONET = 1<<11,/* Forbid network access */ + XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */ + XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ + XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ + XML_PARSE_NOXINCNODE= 1<<15 /* do not generate XINCLUDE START/END nodes */ +} xmlParserOption; + +XMLPUBFUN void XMLCALL + xmlCtxtReset (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlCtxtResetPush (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_H__ */ + diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h new file mode 100755 index 0000000..d052bd9 --- /dev/null +++ b/include/libxml/parserInternals.h @@ -0,0 +1,576 @@ +/* + * Summary: internals routines exported by the parser. + * Description: this module exports a number of internal parsing routines + * they are not really all intended for applications but + * can prove useful doing low level processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_INTERNALS_H__ +#define __XML_PARSER_INTERNALS_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlParserMaxDepth: + * + * arbitrary depth limit for the XML documents that we allow to + * process. This is not a limitation of the parser but a safety + * boundary feature. + */ +XMLPUBVAR unsigned int xmlParserMaxDepth; + + /** + * XML_MAX_NAMELEN: + * + * Identifiers can be longer, but this will be more costly + * at runtime. + */ +#define XML_MAX_NAMELEN 100 + +/** + * INPUT_CHUNK: + * + * The parser tries to always have that amount of input ready. + * One of the point is providing context when reporting errors. + */ +#define INPUT_CHUNK 250 + +/************************************************************************ + * * + * UNICODE version of the macros. * + * * + ************************************************************************/ +/** + * IS_BYTE_CHAR: + * @c: an byte value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20...] + * any byte character in the accepted range + */ +#define IS_BYTE_CHAR(c) xmlIsChar_ch(c) + +/** + * IS_CHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + * | [#x10000-#x10FFFF] + * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. + */ +#define IS_CHAR(c) xmlIsCharQ(c) + +/** + * IS_CHAR_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Behaves like IS_CHAR on single-byte value + */ +#define IS_CHAR_CH(c) xmlIsChar_ch(c) + +/** + * IS_BLANK: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [3] S ::= (#x20 | #x9 | #xD | #xA)+ + */ +#define IS_BLANK(c) xmlIsBlankQ(c) + +/** + * IS_BLANK_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Behaviour same as IS_BLANK + */ +#define IS_BLANK_CH(c) xmlIsBlank_ch(c) + +/** + * IS_BASECHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [85] BaseChar ::= ... long list see REC ... + */ +#define IS_BASECHAR(c) xmlIsBaseCharQ(c) + +/** + * IS_DIGIT: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [88] Digit ::= ... long list see REC ... + */ +#define IS_DIGIT(c) xmlIsDigitQ(c) + +/** + * IS_DIGIT_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_DIGIT but with a single byte argument + */ +#define IS_DIGIT_CH(c) xmlIsDigit_ch(c) + +/** + * IS_COMBINING: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [87] CombiningChar ::= ... long list see REC ... + */ +#define IS_COMBINING(c) xmlIsCombiningQ(c) + +/** + * IS_COMBINING_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Always false (all combining chars > 0xff) + */ +#define IS_COMBINING_CH(c) 0 + +/** + * IS_EXTENDER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | + * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | + * [#x309D-#x309E] | [#x30FC-#x30FE] + */ +#define IS_EXTENDER(c) xmlIsExtenderQ(c) + +/** + * IS_EXTENDER_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_EXTENDER but with a single-byte argument + */ +#define IS_EXTENDER_CH(c) xmlIsExtender_ch(c) + +/** + * IS_IDEOGRAPHIC: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029] + */ +#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c) + +/** + * IS_LETTER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [84] Letter ::= BaseChar | Ideographic + */ +#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c)) + +/** + * IS_LETTER_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Macro behaves like IS_LETTER, but only check base chars + * + */ +#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c) +/** + * IS_PUBIDCHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] + */ +#define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c) + +/** + * IS_PUBIDCHAR_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Same as IS_PUBIDCHAR but for single-byte value + */ +#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c) + +/** + * SKIP_EOL: + * @p: and UTF8 string pointer + * + * Skips the end of line chars. + */ +#define SKIP_EOL(p) \ + if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \ + if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; } + +/** + * MOVETO_ENDTAG: + * @p: and UTF8 string pointer + * + * Skips to the next '>' char. + */ +#define MOVETO_ENDTAG(p) \ + while ((*p) && (*(p) != '>')) (p)++ + +/** + * MOVETO_STARTTAG: + * @p: and UTF8 string pointer + * + * Skips to the next '<' char. + */ +#define MOVETO_STARTTAG(p) \ + while ((*p) && (*(p) != '<')) (p)++ + +/** + * Global variables used for predefined strings. + */ +XMLPUBVAR const xmlChar xmlStringText[]; +XMLPUBVAR const xmlChar xmlStringTextNoenc[]; +XMLPUBVAR const xmlChar xmlStringComment[]; + +/* + * Function to finish the work of the macros where needed. + */ +XMLPUBFUN int XMLCALL xmlIsLetter (int c); + +/** + * Parser context. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateFileParserCtxt (const char *filename); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateURLParserCtxt (const char *filename, + int options); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateMemoryParserCtxt(const char *buffer, + int size); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateEntityParserCtxt(const xmlChar *URL, + const xmlChar *ID, + const xmlChar *base); +XMLPUBFUN int XMLCALL + xmlSwitchEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncodingHandlerPtr handler); +XMLPUBFUN int XMLCALL + xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input, + xmlCharEncodingHandlerPtr handler); + +#ifdef IN_LIBXML +/* internal error reporting */ +XMLPUBFUN void XMLCALL + __xmlErrEncoding (xmlParserCtxtPtr ctxt, + xmlParserErrors xmlerr, + const char *msg, + const xmlChar * str1, + const xmlChar * str2); +#endif +/** + * Entities + */ +XMLPUBFUN void XMLCALL + xmlHandleEntity (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); + +/** + * Input Streams. + */ +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewStringInputStream (xmlParserCtxtPtr ctxt, + const xmlChar *buffer); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); +XMLPUBFUN void XMLCALL + xmlPushInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XMLPUBFUN xmlChar XMLCALL + xmlPopInput (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlFreeInputStream (xmlParserInputPtr input); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewInputFromFile (xmlParserCtxtPtr ctxt, + const char *filename); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewInputStream (xmlParserCtxtPtr ctxt); + +/** + * Namespaces. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlSplitQName (xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlChar **prefix); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseQName (xmlParserCtxtPtr ctxt, + xmlChar **prefix); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseQuotedString (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseNamespace (xmlParserCtxtPtr ctxt); + +/** + * Generic production rules. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlScanName (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseName (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseNmtoken (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseEntityValue (xmlParserCtxtPtr ctxt, + xmlChar **orig); +XMLPUBFUN xmlChar * XMLCALL + xmlParseAttValue (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseSystemLiteral (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParsePubidLiteral (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseCharData (xmlParserCtxtPtr ctxt, + int cdata); +XMLPUBFUN xmlChar * XMLCALL + xmlParseExternalID (xmlParserCtxtPtr ctxt, + xmlChar **publicID, + int strict); +XMLPUBFUN void XMLCALL + xmlParseComment (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParsePITarget (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParsePI (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseNotationDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseEntityDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, + xmlChar **value); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlParseNotationType (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlParseEnumerationType (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XMLPUBFUN int XMLCALL + xmlParseAttributeType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XMLPUBFUN void XMLCALL + xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlParseElementMixedContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlParseElementChildrenContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XMLPUBFUN int XMLCALL + xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlElementContentPtr *result); +XMLPUBFUN int XMLCALL + xmlParseElementDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseMarkupDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseCharRef (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlParseEntityRef (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseReference (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParsePEReference (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseAttribute (xmlParserCtxtPtr ctxt, + xmlChar **value); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseStartTag (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseEndTag (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseCDSect (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseContent (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseElement (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseVersionNum (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseVersionInfo (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseEncName (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseEncodingDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseSDDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseXMLDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseTextDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseMisc (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseExternalSubset (xmlParserCtxtPtr ctxt, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * XML_SUBSTITUTE_NONE: + * + * If no entities need to be substituted. + */ +#define XML_SUBSTITUTE_NONE 0 +/** + * XML_SUBSTITUTE_REF: + * + * Whether general entities need to be substituted. + */ +#define XML_SUBSTITUTE_REF 1 +/** + * XML_SUBSTITUTE_PEREF: + * + * Whether parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_PEREF 2 +/** + * XML_SUBSTITUTE_BOTH: + * + * Both general and parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_BOTH 3 + +XMLPUBFUN xmlChar * XMLCALL + xmlDecodeEntities (xmlParserCtxtPtr ctxt, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XMLPUBFUN xmlChar * XMLCALL + xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XMLPUBFUN xmlChar * XMLCALL + xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); + +/* + * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP. + */ +XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, + xmlNodePtr value); +XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, + xmlParserInputPtr value); +XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL namePop (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, + const xmlChar *value); + +/* + * other commodities shared between parser.c and parserInternals. + */ +XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + int *len); +XMLPUBFUN void XMLCALL xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang); + +/* + * Really core function shared with HTML parser. + */ +XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, + int *len); +XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, + int val); +XMLPUBFUN int XMLCALL xmlCopyChar (int len, + xmlChar *out, + int val); +XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in); + +#ifdef LIBXML_HTML_ENABLED +/* + * Actually comes from the HTML parser but launched from the init stuff. + */ +XMLPUBFUN void XMLCALL htmlInitAutoClose (void); +XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename, + const char *encoding); +#endif + +/* + * Specific function to keep track of entities references + * and used by the XSLT debugger. + */ +/** + * xmlEntityReferenceFunc: + * @ent: the entity + * @firstNode: the fist node in the chunk + * @lastNode: the last nod in the chunk + * + * Callback function used when one needs to be able to track back the + * provenance of a chunk of nodes inherited from an entity replacement. + */ +typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent, + xmlNodePtr firstNode, + xmlNodePtr lastNode); + +XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func); + +#ifdef IN_LIBXML +/* + * internal only + */ +XMLPUBFUN void XMLCALL + xmlErrMemory (xmlParserCtxtPtr ctxt, + const char *extra); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_INTERNALS_H__ */ diff --git a/include/libxml/pattern.h b/include/libxml/pattern.h new file mode 100755 index 0000000..cddab91 --- /dev/null +++ b/include/libxml/pattern.h @@ -0,0 +1,53 @@ +/* + * Summary: pattern expression handling + * Description: allows to compile and test pattern expressions for nodes + * either in a tree or based on a parser state. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PATTERN_H__ +#define __XML_PATTERN_H__ + +#include +#include +#include + +#ifdef LIBXML_PATTERN_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlPattern: + * + * A compiled (XPath based) pattern to select nodes + */ +typedef struct _xmlPattern xmlPattern; +typedef xmlPattern *xmlPatternPtr; + +XMLPUBFUN void XMLCALL + xmlFreePattern (xmlPatternPtr comp); + +XMLPUBFUN void XMLCALL + xmlFreePatternList (xmlPatternPtr comp); + +XMLPUBFUN xmlPatternPtr XMLCALL + xmlPatterncompile (const xmlChar *pattern, + xmlDict *dict, + int flags, + const xmlChar **namespaces); +XMLPUBFUN int XMLCALL + xmlPatternMatch (xmlPatternPtr comp, + xmlNodePtr node); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_PATTERN_ENABLED */ + +#endif /* __XML_PATTERN_H__ */ diff --git a/include/libxml/relaxng.h b/include/libxml/relaxng.h new file mode 100755 index 0000000..83c1735 --- /dev/null +++ b/include/libxml/relaxng.h @@ -0,0 +1,184 @@ +/* + * Summary: implementation of the Relax-NG validation + * Description: implementation of the Relax-NG validation + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_RELAX_NG__ +#define __XML_RELAX_NG__ + +#include +#include +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlRelaxNG xmlRelaxNG; +typedef xmlRelaxNG *xmlRelaxNGPtr; + + +/** + * A schemas validation context + */ +typedef void (*xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...); +typedef void (*xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...); + +typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; +typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; + +typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; +typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; + +/* + * xmlRelaxNGValidErr: + * + * List of possible Relax NG validation errors + */ +typedef enum { + XML_RELAXNG_OK = 0, + XML_RELAXNG_ERR_MEMORY, + XML_RELAXNG_ERR_TYPE, + XML_RELAXNG_ERR_TYPEVAL, + XML_RELAXNG_ERR_DUPID, + XML_RELAXNG_ERR_TYPECMP, + XML_RELAXNG_ERR_NOSTATE, + XML_RELAXNG_ERR_NODEFINE, + XML_RELAXNG_ERR_LISTEXTRA, + XML_RELAXNG_ERR_LISTEMPTY, + XML_RELAXNG_ERR_INTERNODATA, + XML_RELAXNG_ERR_INTERSEQ, + XML_RELAXNG_ERR_INTEREXTRA, + XML_RELAXNG_ERR_ELEMNAME, + XML_RELAXNG_ERR_ATTRNAME, + XML_RELAXNG_ERR_ELEMNONS, + XML_RELAXNG_ERR_ATTRNONS, + XML_RELAXNG_ERR_ELEMWRONGNS, + XML_RELAXNG_ERR_ATTRWRONGNS, + XML_RELAXNG_ERR_ELEMEXTRANS, + XML_RELAXNG_ERR_ATTREXTRANS, + XML_RELAXNG_ERR_ELEMNOTEMPTY, + XML_RELAXNG_ERR_NOELEM, + XML_RELAXNG_ERR_NOTELEM, + XML_RELAXNG_ERR_ATTRVALID, + XML_RELAXNG_ERR_CONTENTVALID, + XML_RELAXNG_ERR_EXTRACONTENT, + XML_RELAXNG_ERR_INVALIDATTR, + XML_RELAXNG_ERR_DATAELEM, + XML_RELAXNG_ERR_VALELEM, + XML_RELAXNG_ERR_LISTELEM, + XML_RELAXNG_ERR_DATATYPE, + XML_RELAXNG_ERR_VALUE, + XML_RELAXNG_ERR_LIST, + XML_RELAXNG_ERR_NOGRAMMAR, + XML_RELAXNG_ERR_EXTRADATA, + XML_RELAXNG_ERR_LACKDATA, + XML_RELAXNG_ERR_INTERNAL, + XML_RELAXNG_ERR_ELEMWRONG, + XML_RELAXNG_ERR_TEXTWRONG +} xmlRelaxNGValidErr; + +/* + * xmlRelaxNGParserFlags: + * + * List of possible Relax NG Parser flags + */ +typedef enum { + XML_RELAXNGP_NONE = 0, + XML_RELAXNGP_FREE_DOC = 1, + XML_RELAXNGP_CRNG = 2 +} xmlRelaxNGParserFlag; +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewParserCtxt (const char *URL); +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); + +XMLPUBFUN int XMLCALL + xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, + int flag); + +XMLPUBFUN void XMLCALL + xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN xmlRelaxNGPtr XMLCALL + xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlRelaxNGFree (xmlRelaxNGPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlRelaxNGDump (FILE *output, + xmlRelaxNGPtr schema); +XMLPUBFUN void XMLCALL + xmlRelaxNGDumpTree (FILE * output, + xmlRelaxNGPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL + xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); +XMLPUBFUN void XMLCALL + xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlRelaxNGCleanupTypes (void); +/* + * Interfaces for progressive validation when possible + */ +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ + +#endif /* __XML_RELAX_NG__ */ diff --git a/include/libxml/schemasInternals.h b/include/libxml/schemasInternals.h new file mode 100755 index 0000000..87daa0a --- /dev/null +++ b/include/libxml/schemasInternals.h @@ -0,0 +1,792 @@ +/* + * Summary: internal interfaces for XML Schemas + * Description: internal interfaces for the XML Schemas handling + * and schema validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_INTERNALS_H__ +#define __XML_SCHEMA_INTERNALS_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMAS_UNKNOWN = 0, + XML_SCHEMAS_STRING, + XML_SCHEMAS_NORMSTRING, + XML_SCHEMAS_DECIMAL, + XML_SCHEMAS_TIME, + XML_SCHEMAS_GDAY, + XML_SCHEMAS_GMONTH, + XML_SCHEMAS_GMONTHDAY, + XML_SCHEMAS_GYEAR, + XML_SCHEMAS_GYEARMONTH, + XML_SCHEMAS_DATE, + XML_SCHEMAS_DATETIME, + XML_SCHEMAS_DURATION, + XML_SCHEMAS_FLOAT, + XML_SCHEMAS_DOUBLE, + XML_SCHEMAS_BOOLEAN, + XML_SCHEMAS_TOKEN, + XML_SCHEMAS_LANGUAGE, + XML_SCHEMAS_NMTOKEN, + XML_SCHEMAS_NMTOKENS, + XML_SCHEMAS_NAME, + XML_SCHEMAS_QNAME, + XML_SCHEMAS_NCNAME, + XML_SCHEMAS_ID, + XML_SCHEMAS_IDREF, + XML_SCHEMAS_IDREFS, + XML_SCHEMAS_ENTITY, + XML_SCHEMAS_ENTITIES, + XML_SCHEMAS_NOTATION, + XML_SCHEMAS_ANYURI, + XML_SCHEMAS_INTEGER, + XML_SCHEMAS_NPINTEGER, + XML_SCHEMAS_NINTEGER, + XML_SCHEMAS_NNINTEGER, + XML_SCHEMAS_PINTEGER, + XML_SCHEMAS_INT, + XML_SCHEMAS_UINT, + XML_SCHEMAS_LONG, + XML_SCHEMAS_ULONG, + XML_SCHEMAS_SHORT, + XML_SCHEMAS_USHORT, + XML_SCHEMAS_BYTE, + XML_SCHEMAS_UBYTE, + XML_SCHEMAS_HEXBINARY, + XML_SCHEMAS_BASE64BINARY, + XML_SCHEMAS_ANYTYPE, + XML_SCHEMAS_ANYSIMPLETYPE +} xmlSchemaValType; + +/* + * XML Schemas defines multiple type of types. + */ +typedef enum { + XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */ + XML_SCHEMA_TYPE_ANY, + XML_SCHEMA_TYPE_FACET, + XML_SCHEMA_TYPE_SIMPLE, + XML_SCHEMA_TYPE_COMPLEX, + XML_SCHEMA_TYPE_SEQUENCE, + XML_SCHEMA_TYPE_CHOICE, + XML_SCHEMA_TYPE_ALL, + XML_SCHEMA_TYPE_SIMPLE_CONTENT, + XML_SCHEMA_TYPE_COMPLEX_CONTENT, + XML_SCHEMA_TYPE_UR, + XML_SCHEMA_TYPE_RESTRICTION, + XML_SCHEMA_TYPE_EXTENSION, + XML_SCHEMA_TYPE_ELEMENT, + XML_SCHEMA_TYPE_ATTRIBUTE, + XML_SCHEMA_TYPE_ATTRIBUTEGROUP, + XML_SCHEMA_TYPE_GROUP, + XML_SCHEMA_TYPE_NOTATION, + XML_SCHEMA_TYPE_LIST, + XML_SCHEMA_TYPE_UNION, + XML_SCHEMA_TYPE_ANY_ATTRIBUTE, + XML_SCHEMA_FACET_MININCLUSIVE = 1000, + XML_SCHEMA_FACET_MINEXCLUSIVE, + XML_SCHEMA_FACET_MAXINCLUSIVE, + XML_SCHEMA_FACET_MAXEXCLUSIVE, + XML_SCHEMA_FACET_TOTALDIGITS, + XML_SCHEMA_FACET_FRACTIONDIGITS, + XML_SCHEMA_FACET_PATTERN, + XML_SCHEMA_FACET_ENUMERATION, + XML_SCHEMA_FACET_WHITESPACE, + XML_SCHEMA_FACET_LENGTH, + XML_SCHEMA_FACET_MAXLENGTH, + XML_SCHEMA_FACET_MINLENGTH +} xmlSchemaTypeType; + +typedef enum { + XML_SCHEMA_CONTENT_UNKNOWN = 0, + XML_SCHEMA_CONTENT_EMPTY = 1, + XML_SCHEMA_CONTENT_ELEMENTS, + XML_SCHEMA_CONTENT_MIXED, + XML_SCHEMA_CONTENT_SIMPLE, + XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* obsolete, not used */ + XML_SCHEMA_CONTENT_BASIC, + XML_SCHEMA_CONTENT_ANY +} xmlSchemaContentType; + +typedef struct _xmlSchemaVal xmlSchemaVal; +typedef xmlSchemaVal *xmlSchemaValPtr; + +typedef struct _xmlSchemaType xmlSchemaType; +typedef xmlSchemaType *xmlSchemaTypePtr; + +typedef struct _xmlSchemaFacet xmlSchemaFacet; +typedef xmlSchemaFacet *xmlSchemaFacetPtr; + +/** + * Annotation + */ +typedef struct _xmlSchemaAnnot xmlSchemaAnnot; +typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; +struct _xmlSchemaAnnot { + struct _xmlSchemaAnnot *next; + xmlNodePtr content; /* the annotation */ +}; + +/** + * XML_SCHEMAS_ANYATTR_SKIP: + * + * Skip unknown attribute from validation + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_SKIP 1 +/** + * XML_SCHEMAS_ANYATTR_LAX: + * + * Ignore validation non definition on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_LAX 2 +/** + * XML_SCHEMAS_ANYATTR_STRICT: + * + * Apply strict validation rules on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_STRICT 3 +/** + * XML_SCHEMAS_ANY_SKIP: + * + * Skip unknown attribute from validation + */ +#define XML_SCHEMAS_ANY_SKIP 1 +/** + * XML_SCHEMAS_ANY_LAX: + * + * Used by wildcards. + * Validate if type found, don't worry if not found + */ +#define XML_SCHEMAS_ANY_LAX 2 +/** + * XML_SCHEMAS_ANY_STRICT: + * + * Used by wildcards. + * Apply strict validation rules + */ +#define XML_SCHEMAS_ANY_STRICT 3 +/** + * XML_SCHEMAS_ATTR_USE_PROHIBITED: + * + * Used by wildcards. + * The attribute is prohibited. + */ +#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0 +/** + * XML_SCHEMAS_ATTR_USE_REQUIRED: + * + * The attribute is required. + */ +#define XML_SCHEMAS_ATTR_USE_REQUIRED 1 +/** + * XML_SCHEMAS_ATTR_USE_OPTIONAL: + * + * The attribute is optional. + */ +#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2 +/** + * XML_SCHEMAS_ATTR_GLOABAL: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0 +/** + * XML_SCHEMAS_ATTR_NSDEFAULT: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ATTR_NSDEFAULT: + * + * this is set when the "type" and "ref" references + * have been resolved. + */ +#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8 +/** + * XML_SCHEMAS_ATTR_FIXED: + * + * the attribute has a fixed value + */ +#define XML_SCHEMAS_ATTR_FIXED 1 << 9 + +/** + * xmlSchemaAttribute: + * An attribute definition. + */ + +typedef struct _xmlSchemaAttribute xmlSchemaAttribute; +typedef xmlSchemaAttribute *xmlSchemaAttributePtr; +struct _xmlSchemaAttribute { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ + const xmlChar *name; /* name of the declaration or empty if particle */ + const xmlChar *id; + const xmlChar *ref; /* the local name of the attribute decl. if a particle */ + const xmlChar *refNs; /* the ns URI of the attribute decl. if a particle */ + const xmlChar *typeName; /* the local name of the type definition */ + const xmlChar *typeNs; /* the ns URI of the type definition */ + xmlSchemaAnnotPtr annot; + + xmlSchemaTypePtr base; /* obsolete, not used */ + int occurs; + const xmlChar *defValue; + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlNodePtr node; + const xmlChar *targetNamespace; + int flags; + const xmlChar *refPrefix; +}; + +/** + * xmlSchemaAttributeLink: + * Used to build a list of attribute uses on complexType definitions. + */ +typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink; +typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr; +struct _xmlSchemaAttributeLink { + struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */ + struct _xmlSchemaAttribute *attr;/* the linked attribute */ +}; + +/** + * XML_SCHEMAS_WILDCARD_COMPLETE: + * + * If the wildcard is complete. + */ +#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0 + +/** + * xmlSchemaCharValueLink: + * Used to build a list of namespaces on wildcards. + */ +typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs; +typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr; +struct _xmlSchemaWildcardNs { + struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */ + const xmlChar *value;/* the value */ +}; + +/** + * xmlSchemaWildcard. + * A wildcard. + */ +typedef struct _xmlSchemaWildcard xmlSchemaWildcard; +typedef xmlSchemaWildcard *xmlSchemaWildcardPtr; +struct _xmlSchemaWildcard { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *id; + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int minOccurs; + int maxOccurs; + int processContents; + int any; /* Indicates if the ns constraint is of ##any */ + xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */ + xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */ + int flags; +}; + +/** + * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED: + * + * The attribute wildcard has been already builded. + */ +#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0 +/** + * XML_SCHEMAS_ATTRGROUP_GLOBAL: + * + * The attribute wildcard has been already builded. + */ +#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1 + +/** + * An attribute group definition. + * + * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures + * must be kept similar + */ +typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; +typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; +struct _xmlSchemaAttributeGroup { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ + const xmlChar *name; + const xmlChar *id; + const xmlChar *ref; + const xmlChar *refNs; + xmlSchemaAnnotPtr annot; + + xmlSchemaAttributePtr attributes; + xmlNodePtr node; + int flags; + xmlSchemaWildcardPtr attributeWildcard; + const xmlChar *refPrefix; +}; + +/** + * xmlSchemaTypeLink: + * Used to build a list of types (e.g. member types of + * simpleType with variety "union"). + */ +typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink; +typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr; +struct _xmlSchemaTypeLink { + struct _xmlSchemaTypeLink *next;/* the next type link ... */ + xmlSchemaTypePtr type;/* the linked type*/ +}; + +/** + * xmlSchemaFacetLink: + * Used to build a list of facets. + */ +typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink; +typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr; +struct _xmlSchemaFacetLink { + struct _xmlSchemaFacetLink *next;/* the next facet link ... */ + xmlSchemaFacetPtr facet;/* the linked facet */ +}; + +/** + * XML_SCHEMAS_TYPE_MIXED: + * + * the element content type is mixed + */ +#define XML_SCHEMAS_TYPE_MIXED 1 << 0 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION: + * + * the simple or complex type has a derivation method of "extension". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION: + * + * the simple or complex type has a derivation method of "restriction". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2 +/** + * XML_SCHEMAS_TYPE_GLOBAL: + * + * the type is global + */ +#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3 +/** + * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD: + * + * the complexType owns an attribute wildcard, i.e. + * it can be freed by the complexType + */ +#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 +/** + * XML_SCHEMAS_TYPE_VARIETY_ABSENT: + * + * the simpleType has a variety of "absent". + */ +#define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5 +/** + * XML_SCHEMAS_TYPE_VARIETY_LIST: + * + * the simpleType has a variety of "list". + */ +#define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6 +/** + * XML_SCHEMAS_TYPE_VARIETY_UNION: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7 +/** + * XML_SCHEMAS_TYPE_VARIETY_ATOMIC: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8 +/** + * XML_SCHEMAS_TYPE_FINAL_EXTENSION: + * + * the complexType has a final of "extension". + */ +#define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9 +/** + * XML_SCHEMAS_TYPE_FINAL_RESTRICTION: + * + * the simpleType/complexType has a final of "restriction". + */ +#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10 +/** + * XML_SCHEMAS_TYPE_FINAL_LIST: + * + * the simpleType has a final of "list". + */ +#define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11 +/** + * XML_SCHEMAS_TYPE_FINAL_UNION: + * + * the simpleType has a final of "union". + */ +#define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12 +/** + * XML_SCHEMAS_TYPE_FINAL_UNION: + * + * the simpleType has a final of "union". + */ +#define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13 +/** + * XML_SCHEMAS_TYPE_FINAL_UNION: + * + * the simpleType has a final of "union". + */ +#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14 + +/** + * _xmlSchemaType: + * + * Schemas type definition. + */ +struct _xmlSchemaType { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next;/* the next type if in a sequence ... */ + const xmlChar *name; + const xmlChar *id; + const xmlChar *ref; + const xmlChar *refNs; + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; + xmlSchemaAttributePtr attributes; + xmlNodePtr node; + int minOccurs; + int maxOccurs; + + int flags; + xmlSchemaContentType contentType; + const xmlChar *base; + const xmlChar *baseNs; + xmlSchemaTypePtr baseType; + xmlSchemaFacetPtr facets; + struct _xmlSchemaType *redef;/* possible redefinitions for the type */ + int recurse; + xmlSchemaAttributeLinkPtr attributeUses; + xmlSchemaWildcardPtr attributeWildcard; + int builtInType; + xmlSchemaTypeLinkPtr memberTypes; + xmlSchemaFacetLinkPtr facetSet; + const xmlChar *refPrefix; + xmlSchemaTypePtr contentTypeDef; +}; + +/* + * xmlSchemaElement: + * An element definition. + * + * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of + * structures must be kept similar + */ +/** + * XML_SCHEMAS_ELEM_NILLABLE: + * + * the element is nillable + */ +#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 +/** + * XML_SCHEMAS_ELEM_GLOBAL: + * + * the element is global + */ +#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ELEM_DEFAULT: + * + * the element has a default value + */ +#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 +/** + * XML_SCHEMAS_ELEM_FIXED: + * + * the element has a fixed value + */ +#define XML_SCHEMAS_ELEM_FIXED 1 << 3 +/** + * XML_SCHEMAS_ELEM_ABSTRACT: + * + * the element is abstract + */ +#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 +/** + * XML_SCHEMAS_ELEM_TOPLEVEL: + * + * the element is top level + * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead + */ +#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 +/** + * XML_SCHEMAS_ELEM_REF: + * + * the element is a reference to a type + */ +#define XML_SCHEMAS_ELEM_REF 1 << 6 +/** + * XML_SCHEMAS_ELEM_NSDEFAULT: + * + * allow elements in no namespace + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED + * + * this is set when "type", "ref", "substitutionGroup" + * references have been resolved. + */ +#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8 + /** + * XML_SCHEMAS_ELEM_CIRCULAR + * + * a helper flag for the search of circular references. + */ +#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9 +/** + * XML_SCHEMAS_ELEM_BLOCK_ABSENT: + * + * the "block" attribute is absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10 +/** + * XML_SCHEMAS_ELEM_BLOCK_EXTENSION: + * + * disallowed substitutions are absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11 +/** + * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: + * + * disallowed substitutions: "restriction" + */ +#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12 +/** + * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION: + * + * disallowed substitutions: "substituion" + */ +#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13 +/** + * XML_SCHEMAS_ELEM_FINAL_ABSENT: + * + * substitution group exclusions are absent + */ +#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14 +/** + * XML_SCHEMAS_ELEM_BLOCK_EXTENSION: + * + * substitution group exclusions: "extension" + */ +#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15 +/** + * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: + * + * substitution group exclusions: "restriction" + */ +#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16 + + +typedef struct _xmlSchemaElement xmlSchemaElement; +typedef xmlSchemaElement *xmlSchemaElementPtr; +struct _xmlSchemaElement { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next;/* the next type if in a sequence ... */ + const xmlChar *name; + const xmlChar *id; + const xmlChar *ref; /* the local name of the element declaration if a particle */ + const xmlChar *refNs; /* the ns URI of the element declaration if a particle */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlSchemaAttributePtr attributes; + xmlNodePtr node; + int minOccurs; + int maxOccurs; + + int flags; + const xmlChar *targetNamespace; + const xmlChar *namedType; + const xmlChar *namedTypeNs; + const xmlChar *substGroup; + const xmlChar *substGroupNs; + const xmlChar *scope; + const xmlChar *value; + struct _xmlSchemaElement *refDecl; /* the element declaration if a particle */ + xmlRegexpPtr contModel; + xmlSchemaContentType contentType; + const xmlChar *refPrefix; +}; + +/* + * XML_SCHEMAS_FACET_UNKNOWN: + * + * unknown facet handling + */ +#define XML_SCHEMAS_FACET_UNKNOWN 0 +/* + * XML_SCHEMAS_FACET_PRESERVE: + * + * preserve the type of the facet + */ +#define XML_SCHEMAS_FACET_PRESERVE 1 +/* + * XML_SCHEMAS_FACET_REPLACE: + * + * replace the type of the facet + */ +#define XML_SCHEMAS_FACET_REPLACE 2 +/* + * XML_SCHEMAS_FACET_COLLAPSE: + * + * collapse the types of the facet + */ +#define XML_SCHEMAS_FACET_COLLAPSE 3 +/** + * A facet definition. + */ +struct _xmlSchemaFacet { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */ + const xmlChar *value; + const xmlChar *id; + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int fixed; + int whitespace; + xmlSchemaValPtr val; + xmlRegexpPtr regexp; +}; + +/** + * A notation definition. + */ +typedef struct _xmlSchemaNotation xmlSchemaNotation; +typedef xmlSchemaNotation *xmlSchemaNotationPtr; +struct _xmlSchemaNotation { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *name; + xmlSchemaAnnotPtr annot; + const xmlChar *identifier; +}; + +/** + * XML_SCHEMAS_QUALIF_ELEM: + * + * the schema requires qualified elements + */ +#define XML_SCHEMAS_QUALIF_ELEM 1 << 0 +/** + * XML_SCHEMAS_QUALIF_ATTR: + * + * the schema requires qualified attributes + */ +#define XML_SCHEMAS_QUALIF_ATTR 1 << 1 +/** + * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2 +/** + * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3 +/** + * XML_SCHEMAS_FINAL_DEFAULT_LIST: + * + * the cshema has "list" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4 +/** + * XML_SCHEMAS_FINAL_DEFAULT_UNION: + * + * the schema has "union" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION: + * + * the schema has "substitution" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8 +/** + * XML_SCHEMAS_INCLUDING_CONVERT_NS: + * + * the schema is currently including an other schema with + * no target namespace. + */ +#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9 +/** + * _xmlSchema: + * + * A Schemas definition + */ +struct _xmlSchema { + const xmlChar *name; /* schema name */ + const xmlChar *targetNamespace; /* the target namespace */ + const xmlChar *version; + const xmlChar *id; + xmlDocPtr doc; + xmlSchemaAnnotPtr annot; + int flags; + + xmlHashTablePtr typeDecl; + xmlHashTablePtr attrDecl; + xmlHashTablePtr attrgrpDecl; + xmlHashTablePtr elemDecl; + xmlHashTablePtr notaDecl; + + xmlHashTablePtr schemasImports; + + void *_private; /* unused by the library for users or bindings */ + xmlHashTablePtr groupDecl; + xmlDictPtr dict; + void *includes; /* the includes, this is opaque for now */ + int preserve; /* whether to free the document */ +}; + +XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type); +XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_INTERNALS_H__ */ + diff --git a/include/libxml/threads.h b/include/libxml/threads.h new file mode 100755 index 0000000..c461375 --- /dev/null +++ b/include/libxml/threads.h @@ -0,0 +1,81 @@ +/** + * Summary: interfaces for thread handling + * Description: set of generic threading related routines + * should work with pthreads, Windows native or TLS threads + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_THREADS_H__ +#define __XML_THREADS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlMutex are a simple mutual exception locks. + */ +typedef struct _xmlMutex xmlMutex; +typedef xmlMutex *xmlMutexPtr; + +/* + * xmlRMutex are reentrant mutual exception locks. + */ +typedef struct _xmlRMutex xmlRMutex; +typedef xmlRMutex *xmlRMutexPtr; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN xmlMutexPtr XMLCALL + xmlNewMutex (void); +XMLPUBFUN void XMLCALL + xmlMutexLock (xmlMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlMutexUnlock (xmlMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlFreeMutex (xmlMutexPtr tok); + +XMLPUBFUN xmlRMutexPtr XMLCALL + xmlNewRMutex (void); +XMLPUBFUN void XMLCALL + xmlRMutexLock (xmlRMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlRMutexUnlock (xmlRMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlFreeRMutex (xmlRMutexPtr tok); + +/* + * Library wide APIs. + */ +XMLPUBFUN void XMLCALL + xmlInitThreads (void); +XMLPUBFUN void XMLCALL + xmlLockLibrary (void); +XMLPUBFUN void XMLCALL + xmlUnlockLibrary(void); +XMLPUBFUN int XMLCALL + xmlGetThreadId (void); +XMLPUBFUN int XMLCALL + xmlIsMainThread (void); +XMLPUBFUN void XMLCALL + xmlCleanupThreads(void); +XMLPUBFUN xmlGlobalStatePtr XMLCALL + xmlGetGlobalState(void); + +#ifdef __cplusplus +} +#endif + + +#endif /* __XML_THREADS_H__ */ diff --git a/include/libxml/tree.h b/include/libxml/tree.h new file mode 100755 index 0000000..414a11a --- /dev/null +++ b/include/libxml/tree.h @@ -0,0 +1,1094 @@ +/* + * Summary: interfaces for tree manipulation + * Description: this module describes the structures found in an tree resulting + * from an XML or HTML parsing, as well as the API provided for + * various processing on that tree + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_TREE_H__ +#define __XML_TREE_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Some of the basic types pointer to structures: + */ +/* xmlIO.h */ +typedef struct _xmlParserInputBuffer xmlParserInputBuffer; +typedef xmlParserInputBuffer *xmlParserInputBufferPtr; + +typedef struct _xmlOutputBuffer xmlOutputBuffer; +typedef xmlOutputBuffer *xmlOutputBufferPtr; + +/* parser.h */ +typedef struct _xmlParserInput xmlParserInput; +typedef xmlParserInput *xmlParserInputPtr; + +typedef struct _xmlParserCtxt xmlParserCtxt; +typedef xmlParserCtxt *xmlParserCtxtPtr; + +typedef struct _xmlSAXLocator xmlSAXLocator; +typedef xmlSAXLocator *xmlSAXLocatorPtr; + +typedef struct _xmlSAXHandler xmlSAXHandler; +typedef xmlSAXHandler *xmlSAXHandlerPtr; + +/* entities.h */ +typedef struct _xmlEntity xmlEntity; +typedef xmlEntity *xmlEntityPtr; + +/** + * BASE_BUFFER_SIZE: + * + * default buffer size 4000. + */ +#define BASE_BUFFER_SIZE 4096 + +/** + * XML_XML_NAMESPACE: + * + * This is the namespace for the special xml: prefix predefined in the + * XML Namespace specification. + */ +#define XML_XML_NAMESPACE \ + (const xmlChar *) "http://www.w3.org/XML/1998/namespace" + +/** + * XML_XML_ID: + * + * This is the name for the special xml:id attribute + */ +#define XML_XML_ID (const xmlChar *) "xml:id" + +/* + * The different element types carried by an XML tree. + * + * NOTE: This is synchronized with DOM Level1 values + * See http://www.w3.org/TR/REC-DOM-Level-1/ + * + * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should + * be deprecated to use an XML_DTD_NODE. + */ +typedef enum { + XML_ELEMENT_NODE= 1, + XML_ATTRIBUTE_NODE= 2, + XML_TEXT_NODE= 3, + XML_CDATA_SECTION_NODE= 4, + XML_ENTITY_REF_NODE= 5, + XML_ENTITY_NODE= 6, + XML_PI_NODE= 7, + XML_COMMENT_NODE= 8, + XML_DOCUMENT_NODE= 9, + XML_DOCUMENT_TYPE_NODE= 10, + XML_DOCUMENT_FRAG_NODE= 11, + XML_NOTATION_NODE= 12, + XML_HTML_DOCUMENT_NODE= 13, + XML_DTD_NODE= 14, + XML_ELEMENT_DECL= 15, + XML_ATTRIBUTE_DECL= 16, + XML_ENTITY_DECL= 17, + XML_NAMESPACE_DECL= 18, + XML_XINCLUDE_START= 19, + XML_XINCLUDE_END= 20 +#ifdef LIBXML_DOCB_ENABLED + ,XML_DOCB_DOCUMENT_NODE= 21 +#endif +} xmlElementType; + + +/** + * xmlNotation: + * + * A DTD Notation definition. + */ + +typedef struct _xmlNotation xmlNotation; +typedef xmlNotation *xmlNotationPtr; +struct _xmlNotation { + const xmlChar *name; /* Notation name */ + const xmlChar *PublicID; /* Public identifier, if any */ + const xmlChar *SystemID; /* System identifier, if any */ +}; + +/** + * xmlAttributeType: + * + * A DTD Attribute type definition. + */ + +typedef enum { + XML_ATTRIBUTE_CDATA = 1, + XML_ATTRIBUTE_ID, + XML_ATTRIBUTE_IDREF , + XML_ATTRIBUTE_IDREFS, + XML_ATTRIBUTE_ENTITY, + XML_ATTRIBUTE_ENTITIES, + XML_ATTRIBUTE_NMTOKEN, + XML_ATTRIBUTE_NMTOKENS, + XML_ATTRIBUTE_ENUMERATION, + XML_ATTRIBUTE_NOTATION +} xmlAttributeType; + +/** + * xmlAttributeDefault: + * + * A DTD Attribute default definition. + */ + +typedef enum { + XML_ATTRIBUTE_NONE = 1, + XML_ATTRIBUTE_REQUIRED, + XML_ATTRIBUTE_IMPLIED, + XML_ATTRIBUTE_FIXED +} xmlAttributeDefault; + +/** + * xmlEnumeration: + * + * List structure used when there is an enumeration in DTDs. + */ + +typedef struct _xmlEnumeration xmlEnumeration; +typedef xmlEnumeration *xmlEnumerationPtr; +struct _xmlEnumeration { + struct _xmlEnumeration *next; /* next one */ + const xmlChar *name; /* Enumeration name */ +}; + +/** + * xmlAttribute: + * + * An Attribute declaration in a DTD. + */ + +typedef struct _xmlAttribute xmlAttribute; +typedef xmlAttribute *xmlAttributePtr; +struct _xmlAttribute { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ + const xmlChar *name; /* Attribute name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + struct _xmlAttribute *nexth; /* next in hash table */ + xmlAttributeType atype; /* The attribute type */ + xmlAttributeDefault def; /* the default */ + const xmlChar *defaultValue; /* or the default value */ + xmlEnumerationPtr tree; /* or the enumeration tree if any */ + const xmlChar *prefix; /* the namespace prefix if any */ + const xmlChar *elem; /* Element holding the attribute */ +}; + +/** + * xmlElementContentType: + * + * Possible definitions of element content types. + */ +typedef enum { + XML_ELEMENT_CONTENT_PCDATA = 1, + XML_ELEMENT_CONTENT_ELEMENT, + XML_ELEMENT_CONTENT_SEQ, + XML_ELEMENT_CONTENT_OR +} xmlElementContentType; + +/** + * xmlElementContentOccur: + * + * Possible definitions of element content occurrences. + */ +typedef enum { + XML_ELEMENT_CONTENT_ONCE = 1, + XML_ELEMENT_CONTENT_OPT, + XML_ELEMENT_CONTENT_MULT, + XML_ELEMENT_CONTENT_PLUS +} xmlElementContentOccur; + +/** + * xmlElementContent: + * + * An XML Element content as stored after parsing an element definition + * in a DTD. + */ + +typedef struct _xmlElementContent xmlElementContent; +typedef xmlElementContent *xmlElementContentPtr; +struct _xmlElementContent { + xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ + xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ + const xmlChar *name; /* Element name */ + struct _xmlElementContent *c1; /* first child */ + struct _xmlElementContent *c2; /* second child */ + struct _xmlElementContent *parent; /* parent */ + const xmlChar *prefix; /* Namespace prefix */ +}; + +/** + * xmlElementTypeVal: + * + * The different possibilities for an element content type. + */ + +typedef enum { + XML_ELEMENT_TYPE_UNDEFINED = 0, + XML_ELEMENT_TYPE_EMPTY = 1, + XML_ELEMENT_TYPE_ANY, + XML_ELEMENT_TYPE_MIXED, + XML_ELEMENT_TYPE_ELEMENT +} xmlElementTypeVal; + + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlElement: + * + * An XML Element declaration from a DTD. + */ + +typedef struct _xmlElement xmlElement; +typedef xmlElement *xmlElementPtr; +struct _xmlElement { + void *_private; /* application data */ + xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ + const xmlChar *name; /* Element name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlElementTypeVal etype; /* The type */ + xmlElementContentPtr content; /* the allowed element content */ + xmlAttributePtr attributes; /* List of the declared attributes */ + const xmlChar *prefix; /* the namespace prefix if any */ +#ifdef LIBXML_REGEXP_ENABLED + xmlRegexpPtr contModel; /* the validating regexp */ +#else + void *contModel; +#endif +}; + + +/** + * XML_LOCAL_NAMESPACE: + * + * A namespace declaration node. + */ +#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL +typedef xmlElementType xmlNsType; + +/** + * xmlNs: + * + * An XML namespace. + * Note that prefix == NULL is valid, it defines the default namespace + * within the subtree (until overridden). + * + * xmlNsType is unified with xmlElementType. + */ + +typedef struct _xmlNs xmlNs; +typedef xmlNs *xmlNsPtr; +struct _xmlNs { + struct _xmlNs *next; /* next Ns link for this node */ + xmlNsType type; /* global or local */ + const xmlChar *href; /* URL for the namespace */ + const xmlChar *prefix; /* prefix for the namespace */ + void *_private; /* application data */ +}; + +/** + * xmlDtd: + * + * An XML DTD, as defined by parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + void *notations; /* Hash table for notations if any */ + void *elements; /* Hash table for elements if any */ + void *attributes; /* Hash table for attributes if any */ + void *entities; /* Hash table for entities if any */ + const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ + void *pentities; /* Hash table for param entities if any */ +}; + +/** + * xmlAttr: + * + * An attribute on an XML node. + */ +typedef struct _xmlAttr xmlAttr; +typedef xmlAttr *xmlAttrPtr; +struct _xmlAttr { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ + const xmlChar *name; /* the name of the property */ + struct _xmlNode *children; /* the value of the property */ + struct _xmlNode *last; /* NULL */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlAttr *next; /* next sibling link */ + struct _xmlAttr *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlAttributeType atype; /* the attribute type if validating */ + void *psvi; /* for type/PSVI informations */ +}; + +/** + * xmlID: + * + * An XML ID instance. + */ + +typedef struct _xmlID xmlID; +typedef xmlID *xmlIDPtr; +struct _xmlID { + struct _xmlID *next; /* next ID */ + const xmlChar *value; /* The ID name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ + struct _xmlDoc *doc; /* The document holding the ID */ +}; + +/** + * xmlRef: + * + * An XML IDREF instance. + */ + +typedef struct _xmlRef xmlRef; +typedef xmlRef *xmlRefPtr; +struct _xmlRef { + struct _xmlRef *next; /* next Ref */ + const xmlChar *value; /* The Ref name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ +}; + +/** + * xmlBufferAllocationScheme: + * + * A buffer allocation scheme can be defined to either match exactly the + * need or double it's allocated size each time it is found too small. + */ + +typedef enum { + XML_BUFFER_ALLOC_DOUBLEIT, + XML_BUFFER_ALLOC_EXACT, + XML_BUFFER_ALLOC_IMMUTABLE +} xmlBufferAllocationScheme; + +/** + * xmlBuffer: + * + * A buffer structure. + */ +typedef struct _xmlBuffer xmlBuffer; +typedef xmlBuffer *xmlBufferPtr; +struct _xmlBuffer { + xmlChar *content; /* The buffer content UTF8 */ + unsigned int use; /* The buffer size used */ + unsigned int size; /* The buffer size */ + xmlBufferAllocationScheme alloc; /* The realloc method */ +}; + +/** + * xmlNode: + * + * A node in an XML tree. + */ +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; +struct _xmlNode { + void *_private; /* application data */ + xmlElementType type; /* type number, must be second ! */ + const xmlChar *name; /* the name of the node, or the entity */ + struct _xmlNode *children; /* parent->childs link */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlChar *content; /* the content */ + struct _xmlAttr *properties;/* properties list */ + xmlNs *nsDef; /* namespace definitions on this node */ + void *psvi; /* for type/PSVI informations */ + unsigned short line; /* line number */ + unsigned short extra; /* extra data for XPath/XSLT */ +}; + +/** + * XML_GET_CONTENT: + * + * Macro to extract the content pointer of a node. + */ +#define XML_GET_CONTENT(n) \ + ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content) + +/** + * XML_GET_LINE: + * + * Macro to extract the line number of an element node. + */ +#define XML_GET_LINE(n) \ + (xmlGetLineNo(n)) + + +/** + * xmlDoc: + * + * An XML document. + */ +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; +struct _xmlDoc { + void *_private; /* application data */ + xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ + char *name; /* name/filename/URI of the document */ + struct _xmlNode *children; /* the document tree */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* autoreference to itself */ + + /* End of common part */ + int compression;/* level of zlib compression */ + int standalone; /* standalone document (no external refs) */ + struct _xmlDtd *intSubset; /* the document internal subset */ + struct _xmlDtd *extSubset; /* the document external subset */ + struct _xmlNs *oldNs; /* Global namespace, the old way */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* external initial encoding, if any */ + void *ids; /* Hash table for ID attributes if any */ + void *refs; /* Hash table for IDREFs attributes if any */ + const xmlChar *URL; /* The URI for that document */ + int charset; /* encoding of the in-memory content + actually an xmlCharEncoding */ + struct _xmlDict *dict; /* dict used to allocate names or NULL */ + void *psvi; /* for type/PSVI informations */ +}; + +/** + * xmlChildrenNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children." + */ +#ifndef xmlChildrenNode +#define xmlChildrenNode children +#endif + +/** + * xmlRootNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children". + */ +#ifndef xmlRootNode +#define xmlRootNode children +#endif + +/* + * Variables. + */ + +/* + * Some helper functions + */ +XMLPUBFUN int XMLCALL + xmlValidateNCName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateQName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateNMToken (const xmlChar *value, + int space); + +XMLPUBFUN xmlChar * XMLCALL + xmlBuildQName (const xmlChar *ncname, + const xmlChar *prefix, + xmlChar *memory, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlSplitQName2 (const xmlChar *name, + xmlChar **prefix); +XMLPUBFUN const xmlChar * XMLCALL + xmlSplitQName3 (const xmlChar *name, + int *len); + +/* + * Handling Buffers. + */ + +XMLPUBFUN void XMLCALL + xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); +XMLPUBFUN xmlBufferAllocationScheme XMLCALL + xmlGetBufferAllocationScheme(void); + +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreate (void); +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreateSize (size_t size); +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreateStatic (void *mem, + size_t size); +XMLPUBFUN int XMLCALL + xmlBufferResize (xmlBufferPtr buf, + unsigned int size); +XMLPUBFUN void XMLCALL + xmlBufferFree (xmlBufferPtr buf); +XMLPUBFUN int XMLCALL + xmlBufferDump (FILE *file, + xmlBufferPtr buf); +XMLPUBFUN int XMLCALL + xmlBufferAdd (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int XMLCALL + xmlBufferAddHead (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int XMLCALL + xmlBufferCat (xmlBufferPtr buf, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlBufferCCat (xmlBufferPtr buf, + const char *str); +XMLPUBFUN int XMLCALL + xmlBufferShrink (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN int XMLCALL + xmlBufferGrow (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN void XMLCALL + xmlBufferEmpty (xmlBufferPtr buf); +XMLPUBFUN const xmlChar* XMLCALL + xmlBufferContent (const xmlBufferPtr buf); +XMLPUBFUN void XMLCALL + xmlBufferSetAllocationScheme(xmlBufferPtr buf, + xmlBufferAllocationScheme scheme); +XMLPUBFUN int XMLCALL + xmlBufferLength (const xmlBufferPtr buf); + +/* + * Creating/freeing new structures. + */ +XMLPUBFUN xmlDtdPtr XMLCALL + xmlCreateIntSubset (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlNewDtd (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlGetIntSubset (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlFreeDtd (xmlDtdPtr cur); +XMLPUBFUN xmlNsPtr XMLCALL + xmlNewGlobalNs (xmlDocPtr doc, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN xmlNsPtr XMLCALL + xmlNewNs (xmlNodePtr node, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + xmlFreeNs (xmlNsPtr cur); +XMLPUBFUN void XMLCALL + xmlFreeNsList (xmlNsPtr cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlNewDoc (const xmlChar *version); +XMLPUBFUN void XMLCALL + xmlFreeDoc (xmlDocPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewDocProp (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewNsPropEatName (xmlNodePtr node, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlFreePropList (xmlAttrPtr cur); +XMLPUBFUN void XMLCALL + xmlFreeProp (xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlCopyProp (xmlNodePtr target, + xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlCopyPropList (xmlNodePtr target, + xmlAttrPtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlDtdPtr XMLCALL + xmlCopyDtd (xmlDtdPtr dtd); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCopyDoc (xmlDocPtr doc, + int recursive); +#endif /* LIBXML_TREE_ENABLED */ + +/* + * Creating new nodes. + */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocNodeEatName (xmlDocPtr doc, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocRawNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewNode (xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewNodeEatName (xmlNsPtr ns, + xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewTextChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocText (xmlDocPtr doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewText (const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewPI (const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocTextLen (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewTextLen (const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocComment (xmlDocPtr doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewComment (const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewCDataBlock (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewCharRef (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewReference (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlCopyNode (const xmlNodePtr node, + int recursive); +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocCopyNode (const xmlNodePtr node, + xmlDocPtr doc, + int recursive); +XMLPUBFUN xmlNodePtr XMLCALL + xmlCopyNodeList (const xmlNodePtr node); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocFragment (xmlDocPtr doc); +#endif /* LIBXML_TREE_ENABLED */ + +/* + * Navigating. + */ +XMLPUBFUN long XMLCALL + xmlGetLineNo (xmlNodePtr node); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlChar * XMLCALL + xmlGetNodePath (xmlNodePtr node); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocGetRootElement (xmlDocPtr doc); +XMLPUBFUN xmlNodePtr XMLCALL + xmlGetLastChild (xmlNodePtr parent); +XMLPUBFUN int XMLCALL + xmlNodeIsText (xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlIsBlankNode (xmlNodePtr node); + +#ifdef LIBXML_TREE_ENABLED +/* + * Changing the structure. + */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +XMLPUBFUN void XMLCALL + xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddChild (xmlNodePtr parent, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddChildList (xmlNodePtr parent, + xmlNodePtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNodePtr XMLCALL + xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN void XMLCALL + xmlUnlinkNode (xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextMerge (xmlNodePtr first, + xmlNodePtr second); +XMLPUBFUN int XMLCALL + xmlTextConcat (xmlNodePtr node, + const xmlChar *content, + int len); +XMLPUBFUN void XMLCALL + xmlFreeNodeList (xmlNodePtr cur); +XMLPUBFUN void XMLCALL + xmlFreeNode (xmlNodePtr cur); +XMLPUBFUN void XMLCALL + xmlSetTreeDoc (xmlNodePtr tree, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSetListDoc (xmlNodePtr list, + xmlDocPtr doc); +/* + * Namespaces. + */ +XMLPUBFUN xmlNsPtr XMLCALL + xmlSearchNs (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *nameSpace); +XMLPUBFUN xmlNsPtr XMLCALL + xmlSearchNsByHref (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *href); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNsPtr * XMLCALL + xmlGetNsList (xmlDocPtr doc, + xmlNodePtr node); +#endif /* LIBXML_TREE_ENABLED */ + +XMLPUBFUN void XMLCALL + xmlSetNs (xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN xmlNsPtr XMLCALL + xmlCopyNamespace (xmlNsPtr cur); +XMLPUBFUN xmlNsPtr XMLCALL + xmlCopyNamespaceList (xmlNsPtr cur); + +/* + * Changing the content. + */ +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlAttrPtr XMLCALL + xmlSetProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlGetNoNsProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN xmlChar * XMLCALL + xmlGetProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlHasProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlHasNsProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *nameSpace); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlAttrPtr XMLCALL + xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlGetNsProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlNodePtr XMLCALL + xmlStringGetNodeList (xmlDocPtr doc, + const xmlChar *value); +XMLPUBFUN xmlNodePtr XMLCALL + xmlStringLenGetNodeList (xmlDocPtr doc, + const xmlChar *value, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeListGetString (xmlDocPtr doc, + xmlNodePtr list, + int inLine); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlChar * XMLCALL + xmlNodeListGetRawString (xmlDocPtr doc, + xmlNodePtr list, + int inLine); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNodeSetContent (xmlNodePtr cur, + const xmlChar *content); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNodeAddContent (xmlNodePtr cur, + const xmlChar *content); +XMLPUBFUN void XMLCALL + xmlNodeAddContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetContent (xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlNodeBufGetContent (xmlBufferPtr buffer, + xmlNodePtr cur); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetLang (xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlNodeGetSpacePreserve (xmlNodePtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetLang (xmlNodePtr cur, + const xmlChar *lang); +XMLPUBFUN void XMLCALL + xmlNodeSetSpacePreserve (xmlNodePtr cur, + int val); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetBase (xmlDocPtr doc, + xmlNodePtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetBase (xmlNodePtr cur, + const xmlChar *uri); + +/* + * Removing content. + */ +XMLPUBFUN int XMLCALL + xmlRemoveProp (xmlAttrPtr cur); +XMLPUBFUN int XMLCALL + xmlUnsetProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlUnsetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name); +#endif /* LIBXML_TREE_ENABLED */ + +/* + * Internal, don't use. + */ +XMLPUBFUN void XMLCALL + xmlBufferWriteCHAR (xmlBufferPtr buf, + const xmlChar *string); +XMLPUBFUN void XMLCALL + xmlBufferWriteChar (xmlBufferPtr buf, + const char *string); +XMLPUBFUN void XMLCALL + xmlBufferWriteQuotedString(xmlBufferPtr buf, + const xmlChar *string); + +XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf, + xmlDocPtr doc, + xmlAttrPtr attr, + const xmlChar *string); + +/* + * Namespace handling. + */ +XMLPUBFUN int XMLCALL + xmlReconciliateNs (xmlDocPtr doc, + xmlNodePtr tree); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Saving. + */ +XMLPUBFUN void XMLCALL + xmlDocDumpFormatMemory (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN void XMLCALL + xmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void XMLCALL + xmlDocDumpMemoryEnc (xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding); +XMLPUBFUN void XMLCALL + xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding, + int format); +XMLPUBFUN int XMLCALL + xmlDocFormatDump (FILE *f, + xmlDocPtr cur, + int format); +XMLPUBFUN int XMLCALL + xmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN void XMLCALL + xmlElemDump (FILE *f, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + xmlSaveFormatFile (const char *filename, + xmlDocPtr cur, + int format); +XMLPUBFUN int XMLCALL + xmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format); + +XMLPUBFUN int XMLCALL + xmlSaveFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int XMLCALL + xmlSaveFormatFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + xmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format, + const char *encoding); + +XMLPUBFUN int XMLCALL + xmlSaveFormatFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN int XMLCALL + xmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * XHTML + */ +XMLPUBFUN int XMLCALL + xmlIsXHTML (const xmlChar *systemID, + const xmlChar *publicID); + +/* + * Compression. + */ +XMLPUBFUN int XMLCALL + xmlGetDocCompressMode (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSetDocCompressMode (xmlDocPtr doc, + int mode); +XMLPUBFUN int XMLCALL + xmlGetCompressMode (void); +XMLPUBFUN void XMLCALL + xmlSetCompressMode (int mode); + +#ifdef __cplusplus +} +#endif +#ifndef __XML_PARSER_H__ +#include +#endif + +#endif /* __XML_TREE_H__ */ + diff --git a/include/libxml/uri.h b/include/libxml/uri.h new file mode 100755 index 0000000..c771648 --- /dev/null +++ b/include/libxml/uri.h @@ -0,0 +1,84 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_URI_H__ +#define __XML_URI_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlURI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + */ +typedef struct _xmlURI xmlURI; +typedef xmlURI *xmlURIPtr; +struct _xmlURI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *query; /* the query string */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ +}; + +/* + * This function is in tree.h: + * xmlChar * xmlNodeGetBase (xmlDocPtr doc, + * xmlNodePtr cur); + */ +XMLPUBFUN xmlURIPtr XMLCALL + xmlCreateURI (void); +XMLPUBFUN xmlChar * XMLCALL + xmlBuildURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlChar * XMLCALL + xmlBuildRelativeURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlURIPtr XMLCALL + xmlParseURI (const char *str); +XMLPUBFUN int XMLCALL + xmlParseURIReference (xmlURIPtr uri, + const char *str); +XMLPUBFUN xmlChar * XMLCALL + xmlSaveUri (xmlURIPtr uri); +XMLPUBFUN void XMLCALL + xmlPrintURI (FILE *stream, + xmlURIPtr uri); +XMLPUBFUN xmlChar * XMLCALL + xmlURIEscapeStr (const xmlChar *str, + const xmlChar *list); +XMLPUBFUN char * XMLCALL + xmlURIUnescapeString (const char *str, + int len, + char *target); +XMLPUBFUN int XMLCALL + xmlNormalizeURIPath (char *path); +XMLPUBFUN xmlChar * XMLCALL + xmlURIEscape (const xmlChar *str); +XMLPUBFUN void XMLCALL + xmlFreeURI (xmlURIPtr uri); +XMLPUBFUN xmlChar* XMLCALL + xmlCanonicPath (const xmlChar *path); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_URI_H__ */ diff --git a/include/libxml/valid.h b/include/libxml/valid.h new file mode 100755 index 0000000..4958e30 --- /dev/null +++ b/include/libxml/valid.h @@ -0,0 +1,418 @@ +/* + * Summary: The DTD validation + * Description: API for the DTD handling and the validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_VALID_H__ +#define __XML_VALID_H__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Validation state added for non-determinist content model. + */ +typedef struct _xmlValidState xmlValidState; +typedef xmlValidState *xmlValidStatePtr; + +/** + * xmlValidityErrorFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity error is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (*xmlValidityErrorFunc) (void *ctx, + const char *msg, + ...); + +/** + * xmlValidityWarningFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity warning is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (*xmlValidityWarningFunc) (void *ctx, + const char *msg, + ...); + +/* + * xmlValidCtxt: + * An xmlValidCtxt is used for error reporting when validating. + */ +typedef struct _xmlValidCtxt xmlValidCtxt; +typedef xmlValidCtxt *xmlValidCtxtPtr; +struct _xmlValidCtxt { + void *userData; /* user specific data block */ + xmlValidityErrorFunc error; /* the callback in case of errors */ + xmlValidityWarningFunc warning; /* the callback in case of warning */ + + /* Node analysis stack used when validating within entities */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + int finishDtd; /* finished validating the Dtd ? */ + xmlDocPtr doc; /* the document */ + int valid; /* temporary validity check result */ + + /* state state used for non-determinist content validation */ + xmlValidState *vstate; /* current state */ + int vstateNr; /* Depth of the validation stack */ + int vstateMax; /* Max depth of the validation stack */ + xmlValidState *vstateTab; /* array of validation states */ + +#ifdef LIBXML_REGEXP_ENABLED + xmlAutomataPtr am; /* the automata */ + xmlAutomataStatePtr state; /* used to build the automata */ +#else + void *am; + void *state; +#endif +}; + +/* + * ALL notation declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlNotationTable; +typedef xmlNotationTable *xmlNotationTablePtr; + +/* + * ALL element declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlElementTable; +typedef xmlElementTable *xmlElementTablePtr; + +/* + * ALL attribute declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlAttributeTable; +typedef xmlAttributeTable *xmlAttributeTablePtr; + +/* + * ALL IDs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlIDTable; +typedef xmlIDTable *xmlIDTablePtr; + +/* + * ALL Refs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlRefTable; +typedef xmlRefTable *xmlRefTablePtr; + +/* Allocate/Release Validation Contexts */ +XMLPUBFUN xmlValidCtxtPtr XMLCALL + xmlNewValidCtxt(void); +XMLPUBFUN void XMLCALL + xmlFreeValidCtxt(xmlValidCtxtPtr); + +/* Notation */ +XMLPUBFUN xmlNotationPtr XMLCALL + xmlAddNotationDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *PublicID, + const xmlChar *SystemID); +XMLPUBFUN xmlNotationTablePtr XMLCALL + xmlCopyNotationTable (xmlNotationTablePtr table); +XMLPUBFUN void XMLCALL + xmlFreeNotationTable (xmlNotationTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpNotationDecl (xmlBufferPtr buf, + xmlNotationPtr nota); +XMLPUBFUN void XMLCALL + xmlDumpNotationTable (xmlBufferPtr buf, + xmlNotationTablePtr table); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Element Content */ +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlNewElementContent (const xmlChar *name, + xmlElementContentType type); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlCopyElementContent (xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlFreeElementContent (xmlElementContentPtr cur); +XMLPUBFUN void XMLCALL + xmlSnprintfElementContent(char *buf, + int size, + xmlElementContentPtr content, + int glob); +/* DEPRECATED */ +XMLPUBFUN void XMLCALL + xmlSprintfElementContent(char *buf, + xmlElementContentPtr content, + int glob); +/* DEPRECATED */ + +/* Element */ +XMLPUBFUN xmlElementPtr XMLCALL + xmlAddElementDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + xmlElementTypeVal type, + xmlElementContentPtr content); +XMLPUBFUN xmlElementTablePtr XMLCALL + xmlCopyElementTable (xmlElementTablePtr table); +XMLPUBFUN void XMLCALL + xmlFreeElementTable (xmlElementTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpElementTable (xmlBufferPtr buf, + xmlElementTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpElementDecl (xmlBufferPtr buf, + xmlElementPtr elem); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Enumeration */ +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlCreateEnumeration (const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlFreeEnumeration (xmlEnumerationPtr cur); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlCopyEnumeration (xmlEnumerationPtr cur); + +/* Attribute */ +XMLPUBFUN xmlAttributePtr XMLCALL + xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *ns, + xmlAttributeType type, + xmlAttributeDefault def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN xmlAttributeTablePtr XMLCALL + xmlCopyAttributeTable (xmlAttributeTablePtr table); +XMLPUBFUN void XMLCALL + xmlFreeAttributeTable (xmlAttributeTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpAttributeTable (xmlBufferPtr buf, + xmlAttributeTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpAttributeDecl (xmlBufferPtr buf, + xmlAttributePtr attr); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* IDs */ +XMLPUBFUN xmlIDPtr XMLCALL + xmlAddID (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void XMLCALL + xmlFreeIDTable (xmlIDTablePtr table); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlGetID (xmlDocPtr doc, + const xmlChar *ID); +XMLPUBFUN int XMLCALL + xmlIsID (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int XMLCALL + xmlRemoveID (xmlDocPtr doc, + xmlAttrPtr attr); + +/* IDREFs */ +XMLPUBFUN xmlRefPtr XMLCALL + xmlAddRef (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void XMLCALL + xmlFreeRefTable (xmlRefTablePtr table); +XMLPUBFUN int XMLCALL + xmlIsRef (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int XMLCALL + xmlRemoveRef (xmlDocPtr doc, + xmlAttrPtr attr); +XMLPUBFUN xmlListPtr XMLCALL + xmlGetRefs (xmlDocPtr doc, + const xmlChar *ID); + +/** + * The public function calls related to validity checking. + */ +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN int XMLCALL + xmlValidateRoot (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateElementDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlElementPtr elem); +XMLPUBFUN xmlChar * XMLCALL + xmlValidNormalizeAttributeValue(xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlAttributePtr attr); +XMLPUBFUN int XMLCALL + xmlValidateAttributeValue(xmlAttributeType type, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNotationPtr nota); +XMLPUBFUN int XMLCALL + xmlValidateDtd (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlDtdPtr dtd); +XMLPUBFUN int XMLCALL + xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateDocument (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlValidateOneElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *prefix, + xmlNsPtr ns, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateNotationUse (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *notationName); +#endif /* LIBXML_VALID_ENABLED */ + +XMLPUBFUN int XMLCALL + xmlIsMixedElement (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr XMLCALL + xmlGetDtdAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr XMLCALL + xmlGetDtdQAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlNotationPtr XMLCALL + xmlGetDtdNotationDesc (xmlDtdPtr dtd, + const xmlChar *name); +XMLPUBFUN xmlElementPtr XMLCALL + xmlGetDtdQElementDesc (xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlElementPtr XMLCALL + xmlGetDtdElementDesc (xmlDtdPtr dtd, + const xmlChar *name); + +XMLPUBFUN int XMLCALL + xmlValidGetValidElements(xmlNode *prev, + xmlNode *next, + const xmlChar **names, + int max); +XMLPUBFUN int XMLCALL + xmlValidGetPotentialChildren(xmlElementContent *ctree, + const xmlChar **list, + int *len, + int max); + +#ifdef LIBXML_VALID_ENABLED + +XMLPUBFUN int XMLCALL + xmlValidateNameValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNamesValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNmtokenValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNmtokensValue(const xmlChar *value); + +#endif /* LIBXML_VALID_ENABLED */ +#ifdef LIBXML_REGEXP_ENABLED +/* + * Validation based on the regexp support + */ +XMLPUBFUN int XMLCALL + xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, + xmlElementPtr elem); + +XMLPUBFUN int XMLCALL + xmlValidatePushElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +XMLPUBFUN int XMLCALL + xmlValidatePushCData (xmlValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int XMLCALL + xmlValidatePopElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +#endif /* LIBXML_REGEXP_ENABLED */ +#ifdef __cplusplus +} +#endif +#endif /* __XML_VALID_H__ */ diff --git a/include/libxml/vssver.scc b/include/libxml/vssver.scc new file mode 100755 index 0000000..4dfd7fc Binary files /dev/null and b/include/libxml/vssver.scc differ diff --git a/include/libxml/xinclude.h b/include/libxml/xinclude.h new file mode 100755 index 0000000..a3ca622 --- /dev/null +++ b/include/libxml/xinclude.h @@ -0,0 +1,121 @@ +/* + * Summary: implementation of XInclude + * Description: API to handle XInclude processing, + * implements the + * World Wide Web Consortium Last Call Working Draft 10 November 2003 + * http://www.w3.org/TR/2003/WD-xinclude-20031110 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XINCLUDE_H__ +#define __XML_XINCLUDE_H__ + +#include +#include + +#ifdef LIBXML_XINCLUDE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XINCLUDE_NS: + * + * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude + */ +#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2003/XInclude" +/** + * XINCLUDE_OLD_NS: + * + * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude + */ +#define XINCLUDE_OLD_NS (const xmlChar *) "http://www.w3.org/2001/XInclude" +/** + * XINCLUDE_NODE: + * + * Macro defining "include" + */ +#define XINCLUDE_NODE (const xmlChar *) "include" +/** + * XINCLUDE_FALLBACK: + * + * Macro defining "fallback" + */ +#define XINCLUDE_FALLBACK (const xmlChar *) "fallback" +/** + * XINCLUDE_HREF: + * + * Macro defining "href" + */ +#define XINCLUDE_HREF (const xmlChar *) "href" +/** + * XINCLUDE_PARSE: + * + * Macro defining "parse" + */ +#define XINCLUDE_PARSE (const xmlChar *) "parse" +/** + * XINCLUDE_PARSE_XML: + * + * Macro defining "xml" + */ +#define XINCLUDE_PARSE_XML (const xmlChar *) "xml" +/** + * XINCLUDE_PARSE_TEXT: + * + * Macro defining "text" + */ +#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" +/** + * XINCLUDE_PARSE_ENCODING: + * + * Macro defining "encoding" + */ +#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding" +/** + * XINCLUDE_PARSE_XPOINTER: + * + * Macro defining "xpointer" + */ +#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) "xpointer" + +typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt; +typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr; + +/* + * standalone processing + */ +XMLPUBFUN int XMLCALL + xmlXIncludeProcess (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessFlags (xmlDocPtr doc, + int flags); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTree (xmlNodePtr tree); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTreeFlags(xmlNodePtr tree, + int flags); +/* + * contextual processing + */ +XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL + xmlXIncludeNewContext (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt, + int flags); +XMLPUBFUN void XMLCALL + xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt, + xmlNodePtr tree); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XINCLUDE_ENABLED */ + +#endif /* __XML_XINCLUDE_H__ */ diff --git a/include/libxml/xlink.h b/include/libxml/xlink.h new file mode 100755 index 0000000..232d1a4 --- /dev/null +++ b/include/libxml/xlink.h @@ -0,0 +1,183 @@ +/* + * Summary: unfinished XLink detection module + * Description: unfinished XLink detection module + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XLINK_H__ +#define __XML_XLINK_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +/** + * Various defines for the various Link properties. + * + * NOTE: the link detection layer will try to resolve QName expansion + * of namespaces. If "foo" is the prefix for "http://foo.com/" + * then the link detection layer will expand role="foo:myrole" + * to "http://foo.com/:myrole". + * NOTE: the link detection layer will expand URI-Refences found on + * href attributes by using the base mechanism if found. + */ +typedef xmlChar *xlinkHRef; +typedef xmlChar *xlinkRole; +typedef xmlChar *xlinkTitle; + +typedef enum { + XLINK_TYPE_NONE = 0, + XLINK_TYPE_SIMPLE, + XLINK_TYPE_EXTENDED, + XLINK_TYPE_EXTENDED_SET +} xlinkType; + +typedef enum { + XLINK_SHOW_NONE = 0, + XLINK_SHOW_NEW, + XLINK_SHOW_EMBED, + XLINK_SHOW_REPLACE +} xlinkShow; + +typedef enum { + XLINK_ACTUATE_NONE = 0, + XLINK_ACTUATE_AUTO, + XLINK_ACTUATE_ONREQUEST +} xlinkActuate; + +/** + * xlinkNodeDetectFunc: + * @ctx: user data pointer + * @node: the node to check + * + * This is the prototype for the link detection routine. + * It calls the default link detection callbacks upon link detection. + */ +typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node); + +/* + * The link detection module interact with the upper layers using + * a set of callback registered at parsing time. + */ + +/** + * xlinkSimpleLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @href: the target of the link + * @role: the role string + * @title: the link title + * + * This is the prototype for a simple link detection callback. + */ +typedef void +(*xlinkSimpleLinkFunk) (void *ctx, + xmlNodePtr node, + const xlinkHRef href, + const xlinkRole role, + const xlinkTitle title); + +/** + * xlinkExtendedLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbArcs: the number of arcs detected on the link + * @from: pointer to the array of source roles found on the arcs + * @to: pointer to the array of target roles found on the arcs + * @show: array of values for the show attributes found on the arcs + * @actuate: array of values for the actuate attributes found on the arcs + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link detection callback. + */ +typedef void +(*xlinkExtendedLinkFunk)(void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbArcs, + const xlinkRole *from, + const xlinkRole *to, + xlinkShow *show, + xlinkActuate *actuate, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * xlinkExtendedLinkSetFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link set detection callback. + */ +typedef void +(*xlinkExtendedLinkSetFunk) (void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * This is the structure containing a set of Links detection callbacks. + * + * There is no default xlink callbacks, if one want to get link + * recognition activated, those call backs must be provided before parsing. + */ +typedef struct _xlinkHandler xlinkHandler; +typedef xlinkHandler *xlinkHandlerPtr; +struct _xlinkHandler { + xlinkSimpleLinkFunk simple; + xlinkExtendedLinkFunk extended; + xlinkExtendedLinkSetFunk set; +}; + +/* + * The default detection routine, can be overridden, they call the default + * detection callbacks. + */ + +XMLPUBFUN xlinkNodeDetectFunc XMLCALL + xlinkGetDefaultDetect (void); +XMLPUBFUN void XMLCALL + xlinkSetDefaultDetect (xlinkNodeDetectFunc func); + +/* + * Routines to set/get the default handlers. + */ +XMLPUBFUN xlinkHandlerPtr XMLCALL + xlinkGetDefaultHandler (void); +XMLPUBFUN void XMLCALL + xlinkSetDefaultHandler (xlinkHandlerPtr handler); + +/* + * Link detection module itself. + */ +XMLPUBFUN xlinkType XMLCALL + xlinkIsLink (xmlDocPtr doc, + xmlNodePtr node); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_XLINK_H__ */ diff --git a/include/libxml/xmlIO.h b/include/libxml/xmlIO.h new file mode 100755 index 0000000..c2cc1d1 --- /dev/null +++ b/include/libxml/xmlIO.h @@ -0,0 +1,352 @@ +/* + * Summary: interface for the I/O interfaces used by the parser + * Description: interface for the I/O interfaces used by the parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_IO_H__ +#define __XML_IO_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Those are the functions and datatypes for the parser input + * I/O structures. + */ + +/** + * xmlInputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to detect if the current handler + * can provide input fonctionnalities for this resource. + * + * Returns 1 if yes and 0 if another Input module should be used + */ +typedef int (*xmlInputMatchCallback) (char const *filename); +/** + * xmlInputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to open the resource + * + * Returns an Input context or NULL in case or error + */ +typedef void * (*xmlInputOpenCallback) (char const *filename); +/** + * xmlInputReadCallback: + * @context: an Input context + * @buffer: the buffer to store data read + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Input API to read the resource + * + * Returns the number of bytes read or -1 in case of error + */ +typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len); +/** + * xmlInputCloseCallback: + * @context: an Input context + * + * Callback used in the I/O Input API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (*xmlInputCloseCallback) (void * context); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Those are the functions and datatypes for the library output + * I/O structures. + */ + +/** + * xmlOutputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to detect if the current handler + * can provide output fonctionnalities for this resource. + * + * Returns 1 if yes and 0 if another Output module should be used + */ +typedef int (*xmlOutputMatchCallback) (char const *filename); +/** + * xmlOutputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to open the resource + * + * Returns an Output context or NULL in case or error + */ +typedef void * (*xmlOutputOpenCallback) (char const *filename); +/** + * xmlOutputWriteCallback: + * @context: an Output context + * @buffer: the buffer of data to write + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Output API to write to the resource + * + * Returns the number of bytes written or -1 in case of error + */ +typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer, + int len); +/** + * xmlOutputCloseCallback: + * @context: an Output context + * + * Callback used in the I/O Output API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (*xmlOutputCloseCallback) (void * context); +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +struct _xmlParserInputBuffer { + void* context; + xmlInputReadCallback readcallback; + xmlInputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */ + xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */ + int compressed; /* -1=unknown, 0=not compressed, 1=compressed */ + int error; + unsigned long rawconsumed;/* amount consumed from raw */ +}; + + +#ifdef LIBXML_OUTPUT_ENABLED +struct _xmlOutputBuffer { + void* context; + xmlOutputWriteCallback writecallback; + xmlOutputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ + xmlBufferPtr conv; /* if encoder != NULL buffer for output */ + int written; /* total number of byte written */ + int error; +}; +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* + * Interfaces for input + */ +XMLPUBFUN void XMLCALL + xmlCleanupInputCallbacks (void); + +XMLPUBFUN int XMLCALL + xmlPopInputCallbacks (void); + +XMLPUBFUN void XMLCALL + xmlRegisterDefaultInputCallbacks (void); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlAllocParserInputBuffer (xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFilename (const char *URI, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFile (FILE *file, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFd (int fd, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateMem (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateStatic (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlParserInputBufferRead (xmlParserInputBufferPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputBufferGrow (xmlParserInputBufferPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputBufferPush (xmlParserInputBufferPtr in, + int len, + const char *buf); +XMLPUBFUN void XMLCALL + xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); +XMLPUBFUN char * XMLCALL + xmlParserGetDirectory (const char *filename); + +XMLPUBFUN int XMLCALL + xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, + xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc); + +xmlParserInputBufferPtr + __xmlParserInputBufferCreateFilename(const char *URI, + xmlCharEncoding enc); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Interfaces for output + */ +XMLPUBFUN void XMLCALL + xmlCleanupOutputCallbacks (void); +XMLPUBFUN void XMLCALL + xmlRegisterDefaultOutputCallbacks(void); +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFilename (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFile (FILE *file, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFd (int fd, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN int XMLCALL + xmlOutputBufferWrite (xmlOutputBufferPtr out, + int len, + const char *buf); +XMLPUBFUN int XMLCALL + xmlOutputBufferWriteString (xmlOutputBufferPtr out, + const char *str); +XMLPUBFUN int XMLCALL + xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, + const xmlChar *str, + xmlCharEncodingOutputFunc escaping); + +XMLPUBFUN int XMLCALL + xmlOutputBufferFlush (xmlOutputBufferPtr out); +XMLPUBFUN int XMLCALL + xmlOutputBufferClose (xmlOutputBufferPtr out); + +XMLPUBFUN int XMLCALL + xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, + xmlOutputOpenCallback openFunc, + xmlOutputWriteCallback writeFunc, + xmlOutputCloseCallback closeFunc); + +xmlOutputBufferPtr + __xmlOutputBufferCreateFilename(const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* This function only exists if HTTP support built into the library */ +#ifdef LIBXML_HTTP_ENABLED +XMLPUBFUN void * XMLCALL + xmlIOHTTPOpenW (const char * post_uri, + int compression ); +XMLPUBFUN void XMLCALL + xmlRegisterHTTPPostCallbacks (void ); +#endif +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr ret); + +/* + * A predefined entity loader disabling network accesses + */ +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNoNetExternalEntityLoader (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +/* + * xmlNormalizeWindowsPath is obsolete, don't use it. + * Check xmlCanonicPath in uri.h for a better alternative. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlNormalizeWindowsPath (const xmlChar *path); + +XMLPUBFUN int XMLCALL + xmlCheckFilename (const char *path); +/** + * Default 'file://' protocol callbacks + */ +XMLPUBFUN int XMLCALL + xmlFileMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlFileOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlFileRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlFileClose (void * context); + +/** + * Default 'http://' protocol callbacks + */ +#ifdef LIBXML_HTTP_ENABLED +XMLPUBFUN int XMLCALL + xmlIOHTTPMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlIOHTTPOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlIOHTTPRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlIOHTTPClose (void * context); +#endif /* LIBXML_HTTP_ENABLED */ + +/** + * Default 'ftp://' protocol callbacks + */ +#ifdef LIBXML_FTP_ENABLED +XMLPUBFUN int XMLCALL + xmlIOFTPMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlIOFTPOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlIOFTPRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlIOFTPClose (void * context); +#endif /* LIBXML_FTP_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_IO_H__ */ diff --git a/include/libxml/xmlautomata.h b/include/libxml/xmlautomata.h new file mode 100755 index 0000000..ee0a0f6 --- /dev/null +++ b/include/libxml/xmlautomata.h @@ -0,0 +1,117 @@ +/* + * Summary: API to build regexp automata + * Description: the API to build regexp automata + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_AUTOMATA_H__ +#define __XML_AUTOMATA_H__ + +#include +#include + +#ifdef LIBXML_AUTOMATA_ENABLED +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlAutomataPtr: + * + * A libxml automata description, It can be compiled into a regexp + */ +typedef struct _xmlAutomata xmlAutomata; +typedef xmlAutomata *xmlAutomataPtr; + +/** + * xmlAutomataStatePtr: + * + * A state int the automata description, + */ +typedef struct _xmlAutomataState xmlAutomataState; +typedef xmlAutomataState *xmlAutomataStatePtr; + +/* + * Building API + */ +XMLPUBFUN xmlAutomataPtr XMLCALL + xmlNewAutomata (void); +XMLPUBFUN void XMLCALL + xmlFreeAutomata (xmlAutomataPtr am); + +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataGetInitState (xmlAutomataPtr am); +XMLPUBFUN int XMLCALL + xmlAutomataSetFinalState (xmlAutomataPtr am, + xmlAutomataStatePtr state); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewState (xmlAutomataPtr am); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewTransition (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewTransition2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewOnceTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewAllTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int lax); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewEpsilon (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountedTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCounterTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XMLPUBFUN int XMLCALL + xmlAutomataNewCounter (xmlAutomataPtr am, + int min, + int max); + +XMLPUBFUN xmlRegexpPtr XMLCALL + xmlAutomataCompile (xmlAutomataPtr am); +XMLPUBFUN int XMLCALL + xmlAutomataIsDeterminist (xmlAutomataPtr am); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_AUTOMATA_ENABLED */ +#endif /* __XML_AUTOMATA_H__ */ diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h new file mode 100755 index 0000000..c86765f --- /dev/null +++ b/include/libxml/xmlerror.h @@ -0,0 +1,845 @@ +/* + * Summary: error handling + * Description: the API used to report errors + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#include + +#ifndef __XML_ERROR_H__ +#define __XML_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlErrorLevel: + * + * Indicates the level of an error + */ +typedef enum { + XML_ERR_NONE = 0, + XML_ERR_WARNING = 1, /* A simple warning */ + XML_ERR_ERROR = 2, /* A recoverable error */ + XML_ERR_FATAL = 3 /* A fatal error */ +} xmlErrorLevel; + +/** + * xmlErrorDomain: + * + * Indicates where an error may have come from + */ +typedef enum { + XML_FROM_NONE = 0, + XML_FROM_PARSER, /* The XML parser */ + XML_FROM_TREE, /* The tree module */ + XML_FROM_NAMESPACE, /* The XML Namespace module */ + XML_FROM_DTD, /* The XML DTD validation with parser context*/ + XML_FROM_HTML, /* The HTML parser */ + XML_FROM_MEMORY, /* The memory allocator */ + XML_FROM_OUTPUT, /* The serialization code */ + XML_FROM_IO, /* The Input/Output stack */ + XML_FROM_FTP, /* The FTP module */ + XML_FROM_HTTP, /* The FTP module */ + XML_FROM_XINCLUDE, /* The XInclude processing */ + XML_FROM_XPATH, /* The XPath module */ + XML_FROM_XPOINTER, /* The XPointer module */ + XML_FROM_REGEXP, /* The regular expressions module */ + XML_FROM_DATATYPE, /* The W3C XML Schemas Datatype module */ + XML_FROM_SCHEMASP, /* The W3C XML Schemas parser module */ + XML_FROM_SCHEMASV, /* The W3C XML Schemas validation module */ + XML_FROM_RELAXNGP, /* The Relax-NG parser module */ + XML_FROM_RELAXNGV, /* The Relax-NG validator module */ + XML_FROM_CATALOG, /* The Catalog module */ + XML_FROM_C14N, /* The Canonicalization module */ + XML_FROM_XSLT, /* The XSLT engine from libxslt */ + XML_FROM_VALID /* The XML DTD validation with valid context */ +} xmlErrorDomain; + +/** + * xmlError: + * + * An XML Error instance. + */ + +typedef struct _xmlError xmlError; +typedef xmlError *xmlErrorPtr; +struct _xmlError { + int domain; /* What part of the library raised this error */ + int code; /* The error code, e.g. an xmlParserError */ + char *message;/* human-readable informative error message */ + xmlErrorLevel level;/* how consequent is the error */ + char *file; /* the filename */ + int line; /* the line number if available */ + char *str1; /* extra string information */ + char *str2; /* extra string information */ + char *str3; /* extra string information */ + int int1; /* extra number information */ + int int2; /* extra number information */ + void *ctxt; /* the parser context if available */ + void *node; /* the node in the tree */ +}; + +/** + * xmlParserError: + * + * This is an error that the XML (or HTML) parser can generate + */ +typedef enum { + XML_ERR_OK = 0, + XML_ERR_INTERNAL_ERROR, /* 1 */ + XML_ERR_NO_MEMORY, /* 2 */ + XML_ERR_DOCUMENT_START, /* 3 */ + XML_ERR_DOCUMENT_EMPTY, /* 4 */ + XML_ERR_DOCUMENT_END, /* 5 */ + XML_ERR_INVALID_HEX_CHARREF, /* 6 */ + XML_ERR_INVALID_DEC_CHARREF, /* 7 */ + XML_ERR_INVALID_CHARREF, /* 8 */ + XML_ERR_INVALID_CHAR, /* 9 */ + XML_ERR_CHARREF_AT_EOF, /* 10 */ + XML_ERR_CHARREF_IN_PROLOG, /* 11 */ + XML_ERR_CHARREF_IN_EPILOG, /* 12 */ + XML_ERR_CHARREF_IN_DTD, /* 13 */ + XML_ERR_ENTITYREF_AT_EOF, /* 14 */ + XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */ + XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */ + XML_ERR_ENTITYREF_IN_DTD, /* 17 */ + XML_ERR_PEREF_AT_EOF, /* 18 */ + XML_ERR_PEREF_IN_PROLOG, /* 19 */ + XML_ERR_PEREF_IN_EPILOG, /* 20 */ + XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */ + XML_ERR_ENTITYREF_NO_NAME, /* 22 */ + XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */ + XML_ERR_PEREF_NO_NAME, /* 24 */ + XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */ + XML_ERR_UNDECLARED_ENTITY, /* 26 */ + XML_WAR_UNDECLARED_ENTITY, /* 27 */ + XML_ERR_UNPARSED_ENTITY, /* 28 */ + XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */ + XML_ERR_ENTITY_IS_PARAMETER, /* 30 */ + XML_ERR_UNKNOWN_ENCODING, /* 31 */ + XML_ERR_UNSUPPORTED_ENCODING, /* 32 */ + XML_ERR_STRING_NOT_STARTED, /* 33 */ + XML_ERR_STRING_NOT_CLOSED, /* 34 */ + XML_ERR_NS_DECL_ERROR, /* 35 */ + XML_ERR_ENTITY_NOT_STARTED, /* 36 */ + XML_ERR_ENTITY_NOT_FINISHED, /* 37 */ + XML_ERR_LT_IN_ATTRIBUTE, /* 38 */ + XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */ + XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */ + XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */ + XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */ + XML_ERR_LITERAL_NOT_STARTED, /* 43 */ + XML_ERR_LITERAL_NOT_FINISHED, /* 44 */ + XML_ERR_COMMENT_NOT_FINISHED, /* 45 */ + XML_ERR_PI_NOT_STARTED, /* 46 */ + XML_ERR_PI_NOT_FINISHED, /* 47 */ + XML_ERR_NOTATION_NOT_STARTED, /* 48 */ + XML_ERR_NOTATION_NOT_FINISHED, /* 49 */ + XML_ERR_ATTLIST_NOT_STARTED, /* 50 */ + XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */ + XML_ERR_MIXED_NOT_STARTED, /* 52 */ + XML_ERR_MIXED_NOT_FINISHED, /* 53 */ + XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */ + XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */ + XML_ERR_XMLDECL_NOT_STARTED, /* 56 */ + XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */ + XML_ERR_CONDSEC_NOT_STARTED, /* 58 */ + XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */ + XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */ + XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */ + XML_ERR_MISPLACED_CDATA_END, /* 62 */ + XML_ERR_CDATA_NOT_FINISHED, /* 63 */ + XML_ERR_RESERVED_XML_NAME, /* 64 */ + XML_ERR_SPACE_REQUIRED, /* 65 */ + XML_ERR_SEPARATOR_REQUIRED, /* 66 */ + XML_ERR_NMTOKEN_REQUIRED, /* 67 */ + XML_ERR_NAME_REQUIRED, /* 68 */ + XML_ERR_PCDATA_REQUIRED, /* 69 */ + XML_ERR_URI_REQUIRED, /* 70 */ + XML_ERR_PUBID_REQUIRED, /* 71 */ + XML_ERR_LT_REQUIRED, /* 72 */ + XML_ERR_GT_REQUIRED, /* 73 */ + XML_ERR_LTSLASH_REQUIRED, /* 74 */ + XML_ERR_EQUAL_REQUIRED, /* 75 */ + XML_ERR_TAG_NAME_MISMATCH, /* 76 */ + XML_ERR_TAG_NOT_FINISHED, /* 77 */ + XML_ERR_STANDALONE_VALUE, /* 78 */ + XML_ERR_ENCODING_NAME, /* 79 */ + XML_ERR_HYPHEN_IN_COMMENT, /* 80 */ + XML_ERR_INVALID_ENCODING, /* 81 */ + XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */ + XML_ERR_CONDSEC_INVALID, /* 83 */ + XML_ERR_VALUE_REQUIRED, /* 84 */ + XML_ERR_NOT_WELL_BALANCED, /* 85 */ + XML_ERR_EXTRA_CONTENT, /* 86 */ + XML_ERR_ENTITY_CHAR_ERROR, /* 87 */ + XML_ERR_ENTITY_PE_INTERNAL, /* 88 */ + XML_ERR_ENTITY_LOOP, /* 89 */ + XML_ERR_ENTITY_BOUNDARY, /* 90 */ + XML_ERR_INVALID_URI, /* 91 */ + XML_ERR_URI_FRAGMENT, /* 92 */ + XML_WAR_CATALOG_PI, /* 93 */ + XML_ERR_NO_DTD, /* 94 */ + XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */ + XML_ERR_VERSION_MISSING, /* 96 */ + XML_WAR_UNKNOWN_VERSION, /* 97 */ + XML_WAR_LANG_VALUE, /* 98 */ + XML_WAR_NS_URI, /* 99 */ + XML_WAR_NS_URI_RELATIVE, /* 100 */ + XML_ERR_MISSING_ENCODING, /* 101 */ + XML_NS_ERR_XML_NAMESPACE = 200, + XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */ + XML_NS_ERR_QNAME, /* 202 */ + XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */ + XML_DTD_ATTRIBUTE_DEFAULT = 500, + XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */ + XML_DTD_ATTRIBUTE_VALUE, /* 502 */ + XML_DTD_CONTENT_ERROR, /* 503 */ + XML_DTD_CONTENT_MODEL, /* 504 */ + XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */ + XML_DTD_DIFFERENT_PREFIX, /* 506 */ + XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */ + XML_DTD_ELEM_NAMESPACE, /* 508 */ + XML_DTD_ELEM_REDEFINED, /* 509 */ + XML_DTD_EMPTY_NOTATION, /* 510 */ + XML_DTD_ENTITY_TYPE, /* 511 */ + XML_DTD_ID_FIXED, /* 512 */ + XML_DTD_ID_REDEFINED, /* 513 */ + XML_DTD_ID_SUBSET, /* 514 */ + XML_DTD_INVALID_CHILD, /* 515 */ + XML_DTD_INVALID_DEFAULT, /* 516 */ + XML_DTD_LOAD_ERROR, /* 517 */ + XML_DTD_MISSING_ATTRIBUTE, /* 518 */ + XML_DTD_MIXED_CORRUPT, /* 519 */ + XML_DTD_MULTIPLE_ID, /* 520 */ + XML_DTD_NO_DOC, /* 521 */ + XML_DTD_NO_DTD, /* 522 */ + XML_DTD_NO_ELEM_NAME, /* 523 */ + XML_DTD_NO_PREFIX, /* 524 */ + XML_DTD_NO_ROOT, /* 525 */ + XML_DTD_NOTATION_REDEFINED, /* 526 */ + XML_DTD_NOTATION_VALUE, /* 527 */ + XML_DTD_NOT_EMPTY, /* 528 */ + XML_DTD_NOT_PCDATA, /* 529 */ + XML_DTD_NOT_STANDALONE, /* 530 */ + XML_DTD_ROOT_NAME, /* 531 */ + XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */ + XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */ + XML_DTD_UNKNOWN_ELEM, /* 534 */ + XML_DTD_UNKNOWN_ENTITY, /* 535 */ + XML_DTD_UNKNOWN_ID, /* 536 */ + XML_DTD_UNKNOWN_NOTATION, /* 537 */ + XML_DTD_STANDALONE_DEFAULTED, /* 538 */ + XML_DTD_XMLID_VALUE, /* 539 */ + XML_DTD_XMLID_TYPE, /* 540 */ + XML_HTML_STRUCURE_ERROR = 800, + XML_HTML_UNKNOWN_TAG, /* 801 */ + XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000, + XML_RNGP_ATTR_CONFLICT, /* 1001 */ + XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */ + XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */ + XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */ + XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */ + XML_RNGP_CHOICE_CONTENT, /* 1006 */ + XML_RNGP_CHOICE_EMPTY, /* 1007 */ + XML_RNGP_CREATE_FAILURE, /* 1008 */ + XML_RNGP_DATA_CONTENT, /* 1009 */ + XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */ + XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */ + XML_RNGP_DEFINE_EMPTY, /* 1012 */ + XML_RNGP_DEFINE_MISSING, /* 1013 */ + XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */ + XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */ + XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */ + XML_RNGP_ELEMENT_EMPTY, /* 1017 */ + XML_RNGP_ELEMENT_CONTENT, /* 1018 */ + XML_RNGP_ELEMENT_NAME, /* 1019 */ + XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */ + XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */ + XML_RNGP_EMPTY, /* 1022 */ + XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */ + XML_RNGP_EMPTY_CONTENT, /* 1024 */ + XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */ + XML_RNGP_ERROR_TYPE_LIB, /* 1026 */ + XML_RNGP_EXCEPT_EMPTY, /* 1027 */ + XML_RNGP_EXCEPT_MISSING, /* 1028 */ + XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */ + XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */ + XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */ + XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */ + XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */ + XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */ + XML_RNGP_FOREIGN_ELEMENT, /* 1035 */ + XML_RNGP_GRAMMAR_CONTENT, /* 1036 */ + XML_RNGP_GRAMMAR_EMPTY, /* 1037 */ + XML_RNGP_GRAMMAR_MISSING, /* 1038 */ + XML_RNGP_GRAMMAR_NO_START, /* 1039 */ + XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */ + XML_RNGP_HREF_ERROR, /* 1041 */ + XML_RNGP_INCLUDE_EMPTY, /* 1042 */ + XML_RNGP_INCLUDE_FAILURE, /* 1043 */ + XML_RNGP_INCLUDE_RECURSE, /* 1044 */ + XML_RNGP_INTERLEAVE_ADD, /* 1045 */ + XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */ + XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */ + XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */ + XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */ + XML_RNGP_INVALID_URI, /* 1050 */ + XML_RNGP_INVALID_VALUE, /* 1051 */ + XML_RNGP_MISSING_HREF, /* 1052 */ + XML_RNGP_NAME_MISSING, /* 1053 */ + XML_RNGP_NEED_COMBINE, /* 1054 */ + XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */ + XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */ + XML_RNGP_NSNAME_NO_NS, /* 1057 */ + XML_RNGP_PARAM_FORBIDDEN, /* 1058 */ + XML_RNGP_PARAM_NAME_MISSING, /* 1059 */ + XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */ + XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */ + XML_RNGP_PARENTREF_NO_NAME, /* 1062 */ + XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */ + XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */ + XML_RNGP_PARSE_ERROR, /* 1065 */ + XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */ + XML_RNGP_PAT_ATTR_ATTR, /* 1067 */ + XML_RNGP_PAT_ATTR_ELEM, /* 1068 */ + XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */ + XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */ + XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */ + XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */ + XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */ + XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */ + XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */ + XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */ + XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */ + XML_RNGP_PAT_LIST_ATTR, /* 1078 */ + XML_RNGP_PAT_LIST_ELEM, /* 1079 */ + XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */ + XML_RNGP_PAT_LIST_LIST, /* 1081 */ + XML_RNGP_PAT_LIST_REF, /* 1082 */ + XML_RNGP_PAT_LIST_TEXT, /* 1083 */ + XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */ + XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */ + XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */ + XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */ + XML_RNGP_PAT_START_ATTR, /* 1088 */ + XML_RNGP_PAT_START_DATA, /* 1089 */ + XML_RNGP_PAT_START_EMPTY, /* 1090 */ + XML_RNGP_PAT_START_GROUP, /* 1091 */ + XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */ + XML_RNGP_PAT_START_LIST, /* 1093 */ + XML_RNGP_PAT_START_ONEMORE, /* 1094 */ + XML_RNGP_PAT_START_TEXT, /* 1095 */ + XML_RNGP_PAT_START_VALUE, /* 1096 */ + XML_RNGP_PREFIX_UNDEFINED, /* 1097 */ + XML_RNGP_REF_CREATE_FAILED, /* 1098 */ + XML_RNGP_REF_CYCLE, /* 1099 */ + XML_RNGP_REF_NAME_INVALID, /* 1100 */ + XML_RNGP_REF_NO_DEF, /* 1101 */ + XML_RNGP_REF_NO_NAME, /* 1102 */ + XML_RNGP_REF_NOT_EMPTY, /* 1103 */ + XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */ + XML_RNGP_START_CONTENT, /* 1105 */ + XML_RNGP_START_EMPTY, /* 1106 */ + XML_RNGP_START_MISSING, /* 1107 */ + XML_RNGP_TEXT_EXPECTED, /* 1108 */ + XML_RNGP_TEXT_HAS_CHILD, /* 1109 */ + XML_RNGP_TYPE_MISSING, /* 1110 */ + XML_RNGP_TYPE_NOT_FOUND, /* 1111 */ + XML_RNGP_TYPE_VALUE, /* 1112 */ + XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */ + XML_RNGP_UNKNOWN_COMBINE, /* 1114 */ + XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */ + XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */ + XML_RNGP_URI_FRAGMENT, /* 1117 */ + XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */ + XML_RNGP_VALUE_EMPTY, /* 1119 */ + XML_RNGP_VALUE_NO_CONTENT, /* 1120 */ + XML_RNGP_XMLNS_NAME, /* 1121 */ + XML_RNGP_XML_NS, /* 1122 */ + XML_XPATH_EXPRESSION_OK = 1200, + XML_XPATH_NUMBER_ERROR, /* 1201 */ + XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */ + XML_XPATH_START_LITERAL_ERROR, /* 1203 */ + XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */ + XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */ + XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */ + XML_XPATH_EXPR_ERROR, /* 1207 */ + XML_XPATH_UNCLOSED_ERROR, /* 1208 */ + XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */ + XML_XPATH_INVALID_OPERAND, /* 1210 */ + XML_XPATH_INVALID_TYPE, /* 1211 */ + XML_XPATH_INVALID_ARITY, /* 1212 */ + XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */ + XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */ + XML_XPATH_MEMORY_ERROR, /* 1215 */ + XML_XPTR_SYNTAX_ERROR, /* 1216 */ + XML_XPTR_RESOURCE_ERROR, /* 1217 */ + XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */ + XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */ + XML_XPATH_ENCODING_ERROR, /* 1220 */ + XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */ + XML_TREE_INVALID_HEX = 1300, + XML_TREE_INVALID_DEC, /* 1301 */ + XML_TREE_UNTERMINATED_ENTITY, /* 1302 */ + XML_SAVE_NOT_UTF8 = 1400, + XML_SAVE_CHAR_INVALID, /* 1401 */ + XML_SAVE_NO_DOCTYPE, /* 1402 */ + XML_SAVE_UNKNOWN_ENCODING, /* 1403 */ + XML_REGEXP_COMPILE_ERROR = 1450, + XML_IO_UNKNOWN = 1500, + XML_IO_EACCES, /* 1501 */ + XML_IO_EAGAIN, /* 1502 */ + XML_IO_EBADF, /* 1503 */ + XML_IO_EBADMSG, /* 1504 */ + XML_IO_EBUSY, /* 1505 */ + XML_IO_ECANCELED, /* 1506 */ + XML_IO_ECHILD, /* 1507 */ + XML_IO_EDEADLK, /* 1508 */ + XML_IO_EDOM, /* 1509 */ + XML_IO_EEXIST, /* 1510 */ + XML_IO_EFAULT, /* 1511 */ + XML_IO_EFBIG, /* 1512 */ + XML_IO_EINPROGRESS, /* 1513 */ + XML_IO_EINTR, /* 1514 */ + XML_IO_EINVAL, /* 1515 */ + XML_IO_EIO, /* 1516 */ + XML_IO_EISDIR, /* 1517 */ + XML_IO_EMFILE, /* 1518 */ + XML_IO_EMLINK, /* 1519 */ + XML_IO_EMSGSIZE, /* 1520 */ + XML_IO_ENAMETOOLONG, /* 1521 */ + XML_IO_ENFILE, /* 1522 */ + XML_IO_ENODEV, /* 1523 */ + XML_IO_ENOENT, /* 1524 */ + XML_IO_ENOEXEC, /* 1525 */ + XML_IO_ENOLCK, /* 1526 */ + XML_IO_ENOMEM, /* 1527 */ + XML_IO_ENOSPC, /* 1528 */ + XML_IO_ENOSYS, /* 1529 */ + XML_IO_ENOTDIR, /* 1530 */ + XML_IO_ENOTEMPTY, /* 1531 */ + XML_IO_ENOTSUP, /* 1532 */ + XML_IO_ENOTTY, /* 1533 */ + XML_IO_ENXIO, /* 1534 */ + XML_IO_EPERM, /* 1535 */ + XML_IO_EPIPE, /* 1536 */ + XML_IO_ERANGE, /* 1537 */ + XML_IO_EROFS, /* 1538 */ + XML_IO_ESPIPE, /* 1539 */ + XML_IO_ESRCH, /* 1540 */ + XML_IO_ETIMEDOUT, /* 1541 */ + XML_IO_EXDEV, /* 1542 */ + XML_IO_NETWORK_ATTEMPT, /* 1543 */ + XML_IO_ENCODER, /* 1544 */ + XML_IO_FLUSH, /* 1545 */ + XML_IO_WRITE, /* 1546 */ + XML_IO_NO_INPUT, /* 1547 */ + XML_IO_BUFFER_FULL, /* 1548 */ + XML_IO_LOAD_ERROR, /* 1549 */ + XML_IO_ENOTSOCK, /* 1550 */ + XML_IO_EISCONN, /* 1551 */ + XML_IO_ECONNREFUSED, /* 1552 */ + XML_IO_ENETUNREACH, /* 1553 */ + XML_IO_EADDRINUSE, /* 1554 */ + XML_IO_EALREADY, /* 1555 */ + XML_IO_EAFNOSUPPORT, /* 1556 */ + XML_XINCLUDE_RECURSION=1600, + XML_XINCLUDE_PARSE_VALUE, /* 1601 */ + XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */ + XML_XINCLUDE_NO_HREF, /* 1603 */ + XML_XINCLUDE_NO_FALLBACK, /* 1604 */ + XML_XINCLUDE_HREF_URI, /* 1605 */ + XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */ + XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */ + XML_XINCLUDE_INVALID_CHAR, /* 1608 */ + XML_XINCLUDE_BUILD_FAILED, /* 1609 */ + XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */ + XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */ + XML_XINCLUDE_XPTR_FAILED, /* 1612 */ + XML_XINCLUDE_XPTR_RESULT, /* 1613 */ + XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */ + XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */ + XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */ + XML_XINCLUDE_DEPRECATED_NS, /* 1617 */ + XML_XINCLUDE_FRAGMENT_ID, /* 1618 */ + XML_CATALOG_MISSING_ATTR = 1650, + XML_CATALOG_ENTRY_BROKEN, /* 1651 */ + XML_CATALOG_PREFER_VALUE, /* 1652 */ + XML_CATALOG_NOT_CATALOG, /* 1653 */ + XML_CATALOG_RECURSION, /* 1654 */ + XML_SCHEMAP_PREFIX_UNDEFINED = 1700, + XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */ + XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */ + XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */ + XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */ + XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */ + XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */ + XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */ + XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */ + XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */ + XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */ + XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */ + XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */ + XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */ + XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */ + XML_SCHEMAP_INVALID_ENUM, /* 1715 */ + XML_SCHEMAP_INVALID_FACET, /* 1716 */ + XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */ + XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */ + XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */ + XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */ + XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */ + XML_SCHEMAP_NOATTR_NOREF, /* 1722 */ + XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */ + XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */ + XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */ + XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */ + XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */ + XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */ + XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */ + XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */ + XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */ + XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */ + XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */ + XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */ + XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */ + XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */ + XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */ + XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */ + XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */ + XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */ + XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */ + XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */ + XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */ + XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */ + XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */ + XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */ + XML_SCHEMAP_UNKNOWN_REF, /* 1747 */ + XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */ + XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */ + XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */ + XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */ + XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */ + XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */ + XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */ + XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */ + XML_SCHEMAP_REGEXP_INVALID, /* 1756 */ + XML_SCHEMAP_FAILED_LOAD, /* 1756 */ + XML_SCHEMAP_NOTHING_TO_PARSE, /* 1757 */ + XML_SCHEMAP_NOROOT, /* 1758 */ + XML_SCHEMAP_REDEFINED_GROUP, /* 1759 */ + XML_SCHEMAP_REDEFINED_TYPE, /* 1760 */ + XML_SCHEMAP_REDEFINED_ELEMENT, /* 1761 */ + XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1762 */ + XML_SCHEMAP_REDEFINED_ATTR, /* 1763 */ + XML_SCHEMAP_REDEFINED_NOTATION, /* 1764 */ + XML_SCHEMAP_FAILED_PARSE, /* 1765 */ + XML_SCHEMAP_UNKNOWN_PREFIX, /* 1766 */ + XML_SCHEMAP_DEF_AND_PREFIX, /* 1767 */ + XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1768 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1769 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1770 */ + XML_SCHEMAP_NOT_SCHEMA, /* 1771 */ + XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1772 */ + XML_SCHEMAP_INVALID_ATTR_USE, /* 1773 */ + XML_SCHEMAP_RECURSIVE, /* 1774 */ + XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1775 */ + XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1776 */ + XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1777 */ + XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1778 */ + XML_SCHEMAP_INVALID_ATTR_NAME, /* 1779 */ + XML_SCHEMAP_REF_AND_CONTENT, /* 1780 */ + XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1781 */ + XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1782 */ + XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1783 */ + XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1784 */ + XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1785 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1786 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1787 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1788 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1789 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1790 */ + XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1791 */ + XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1792 */ + XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1793 */ + XML_SCHEMAP_SRC_IMPORT_3_1, /* 1794 */ + XML_SCHEMAP_SRC_IMPORT_3_2, /* 1795 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1796 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1797 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1798 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1799 */ + XML_SCHEMAV_NOROOT = 1800, + XML_SCHEMAV_UNDECLAREDELEM, /* 1801 */ + XML_SCHEMAV_NOTTOPLEVEL, /* 1802 */ + XML_SCHEMAV_MISSING, /* 1803 */ + XML_SCHEMAV_WRONGELEM, /* 1804 */ + XML_SCHEMAV_NOTYPE, /* 1805 */ + XML_SCHEMAV_NOROLLBACK, /* 1806 */ + XML_SCHEMAV_ISABSTRACT, /* 1807 */ + XML_SCHEMAV_NOTEMPTY, /* 1808 */ + XML_SCHEMAV_ELEMCONT, /* 1809 */ + XML_SCHEMAV_HAVEDEFAULT, /* 1810 */ + XML_SCHEMAV_NOTNILLABLE, /* 1811 */ + XML_SCHEMAV_EXTRACONTENT, /* 1812 */ + XML_SCHEMAV_INVALIDATTR, /* 1813 */ + XML_SCHEMAV_INVALIDELEM, /* 1814 */ + XML_SCHEMAV_NOTDETERMINIST, /* 1815 */ + XML_SCHEMAV_CONSTRUCT, /* 1816 */ + XML_SCHEMAV_INTERNAL, /* 1817 */ + XML_SCHEMAV_NOTSIMPLE, /* 1818 */ + XML_SCHEMAV_ATTRUNKNOWN, /* 1819 */ + XML_SCHEMAV_ATTRINVALID, /* 1820 */ + XML_SCHEMAV_VALUE, /* 1821 */ + XML_SCHEMAV_FACET, /* 1822 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1823 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1824 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1825 */ + XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1826 */ + XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1827 */ + XML_SCHEMAV_CVC_FACET_VALID, /* 1828 */ + XML_SCHEMAV_CVC_LENGTH_VALID, /* 1829 */ + XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1830 */ + XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1831 */ + XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1832 */ + XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1833 */ + XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1834 */ + XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1835 */ + XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1836 */ + XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1837 */ + XML_SCHEMAV_CVC_PATTERN_VALID, /* 1838 */ + XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1839 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1840 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1841 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1842 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1843 */ + XML_SCHEMAV_CVC_ELT_1, /* 1844 */ + XML_SCHEMAV_CVC_ELT_2, /* 1845 */ + XML_SCHEMAV_CVC_ELT_3_1, + XML_SCHEMAV_CVC_ELT_3_2_1, + XML_SCHEMAV_CVC_ELT_3_2_2, + XML_SCHEMAV_CVC_ELT_4_1, + XML_SCHEMAV_CVC_ELT_4_2, + XML_SCHEMAV_CVC_ELT_4_3, + XML_SCHEMAV_CVC_ELT_5_1_1, + XML_SCHEMAV_CVC_ELT_5_1_2, + XML_SCHEMAV_CVC_ELT_5_2_1, + XML_SCHEMAV_CVC_ELT_5_2_2_1, + XML_SCHEMAV_CVC_ELT_5_2_2_2_1, + XML_SCHEMAV_CVC_ELT_5_2_2_2_2, + XML_SCHEMAV_CVC_ELT_6, + XML_SCHEMAV_CVC_ELT_7, + XML_SCHEMAV_CVC_ATTRIBUTE_1, + XML_SCHEMAV_CVC_ATTRIBUTE_2, + XML_SCHEMAV_CVC_ATTRIBUTE_3, + XML_SCHEMAV_CVC_ATTRIBUTE_4, + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, + XML_SCHEMAV_CVC_COMPLEX_TYPE_4, + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, + XML_SCHEMAV_ELEMENT_CONTENT, /* 1846 non-W3C */ + XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* non-W3C */ + XML_XPTR_UNKNOWN_SCHEME = 1900, + XML_XPTR_CHILDSEQ_START, /* 1901 */ + XML_XPTR_EVAL_FAILED, /* 1902 */ + XML_XPTR_EXTRA_OBJECTS, /* 1903 */ + XML_C14N_CREATE_CTXT = 1950, + XML_C14N_REQUIRES_UTF8, /* 1951 */ + XML_C14N_CREATE_STACK, /* 1952 */ + XML_C14N_INVALID_NODE, /* 1953 */ + XML_FTP_PASV_ANSWER = 2000, + XML_FTP_EPSV_ANSWER, /* 2001 */ + XML_FTP_ACCNT, /* 2002 */ + XML_HTTP_URL_SYNTAX = 2020, + XML_HTTP_USE_IP, /* 2021 */ + XML_HTTP_UNKNOWN_HOST, /* 2022 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000, + XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */ + XML_SCHEMAP_SRC_RESOLVE, /* 3004 */ + XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */ + XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */ + XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */ + XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */ + XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */ + XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */ + XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */ + XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */ + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */ + XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */ + XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */ + XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */ + XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */ + XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */ + XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */ + XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */ + XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */ + XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */ + XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */ + XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */ + XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */ + XML_SCHEMAP_SRC_INCLUDE, /* 3050 */ + XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */ + XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */ + XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */ + XML_SCHEMAP_NO_XMLNS, /* 3056 */ + XML_SCHEMAP_NO_XSI, /* 3057 */ + XML_SCHEMAP_COS_VALID_DEFAULT_1, + XML_SCHEMAP_COS_VALID_DEFAULT_2_1, + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, + XML_SCHEMAP_CVC_SIMPLE_TYPE, + XML_SCHEMAP_COS_CT_EXTENDS_1_1, + XML_SCHEMAP_SRC_IMPORT_1_1, + XML_SCHEMAP_SRC_IMPORT_1_2, + XML_SCHEMAP_SRC_IMPORT_2, + XML_SCHEMAP_SRC_IMPORT_2_1, + XML_SCHEMAP_SRC_IMPORT_2_2, + XML_SCHEMAP_INTERNAL, /* non-W3C */ + XML_SCHEMAP_NOT_DETERMINISTIC /* non-W3C */ +} xmlParserErrors; + +/** + * xmlGenericErrorFunc: + * @ctx: a parsing context + * @msg: the message + * @...: the extra arguments of the varags to format the message + * + * Signature of the function to use when there is an error and + * no parsing or validity context available . + */ +typedef void (*xmlGenericErrorFunc) (void *ctx, + const char *msg, + ...); +/** + * xmlStructuredErrorFunc: + * @userData: user provided data for the error callback + * @error: the error being raised. + * + * Signature of the function to use when there is an error and + * the module handles the new error reporting mechanism. + */ +typedef void (*xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error); + +/* + * Use the following function to reset the two global variables + * xmlGenericError and xmlGenericErrorContext. + */ +XMLPUBFUN void XMLCALL + xmlSetGenericErrorFunc (void *ctx, + xmlGenericErrorFunc handler); +XMLPUBFUN void XMLCALL + initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler); + +XMLPUBFUN void XMLCALL + xmlSetStructuredErrorFunc (void *ctx, + xmlStructuredErrorFunc handler); +/* + * Default message routines used by SAX and Valid context for error + * and warning reporting. + */ +XMLPUBFUN void XMLCALL + xmlParserError (void *ctx, + const char *msg, + ...); +XMLPUBFUN void XMLCALL + xmlParserWarning (void *ctx, + const char *msg, + ...); +XMLPUBFUN void XMLCALL + xmlParserValidityError (void *ctx, + const char *msg, + ...); +XMLPUBFUN void XMLCALL + xmlParserValidityWarning (void *ctx, + const char *msg, + ...); +XMLPUBFUN void XMLCALL + xmlParserPrintFileInfo (xmlParserInputPtr input); +XMLPUBFUN void XMLCALL + xmlParserPrintFileContext (xmlParserInputPtr input); + +/* + * Extended error information routines + */ +XMLPUBFUN xmlErrorPtr XMLCALL + xmlGetLastError (void); +XMLPUBFUN void XMLCALL + xmlResetLastError (void); +XMLPUBFUN xmlErrorPtr XMLCALL + xmlCtxtGetLastError (void *ctx); +XMLPUBFUN void XMLCALL + xmlCtxtResetLastError (void *ctx); +XMLPUBFUN void XMLCALL + xmlResetError (xmlErrorPtr err); +XMLPUBFUN int XMLCALL + xmlCopyError (xmlErrorPtr from, + xmlErrorPtr to); + +#ifdef IN_LIBXML +/* + * Internal callback reporting routine + */ +XMLPUBFUN void XMLCALL + __xmlRaiseError (xmlStructuredErrorFunc schannel, + xmlGenericErrorFunc channel, + void *data, + void *ctx, + void *node, + int domain, + int code, + xmlErrorLevel level, + const char *file, + int line, + const char *str1, + const char *str2, + const char *str3, + int int1, + int int2, + const char *msg, + ...); +XMLPUBFUN void XMLCALL + __xmlSimpleError (int domain, + int code, + xmlNodePtr node, + const char *msg, + const char *extra); +#endif +#ifdef __cplusplus +} +#endif +#endif /* __XML_ERROR_H__ */ diff --git a/include/libxml/xmlexports.h b/include/libxml/xmlexports.h new file mode 100755 index 0000000..c83272f --- /dev/null +++ b/include/libxml/xmlexports.h @@ -0,0 +1,138 @@ +/* + * Summary: macros for marking symbols as exportable/importable. + * Description: macros for marking symbols as exportable/importable. + * + * Copy: See Copyright for the status of this software. + * + * Author: Igor Zlatovic + */ + +#ifndef __XML_EXPORTS_H__ +#define __XML_EXPORTS_H__ + +/** + * XMLPUBFUN, XMLPUBVAR, XMLCALL + * + * Macros which declare an exportable function, an exportable variable and + * the calling convention used for functions. + * + * Please use an extra block for every platform/compiler combination when + * modifying this, rather than overlong #ifdef lines. This helps + * readability as well as the fact that different compilers on the same + * platform might need different definitions. + */ + +/** + * XMLPUBFUN: + * + * Macros which declare an exportable function + */ +#define XMLPUBFUN +/** + * XMLPUBVAR: + * + * Macros which declare an exportable variable + */ +#define XMLPUBVAR extern +/** + * XMLCALL: + * + * Macros which declare the called convention for exported functions + */ +#define XMLCALL + +/** DOC_DISABLE */ + +/* Windows platform with MS compiler */ +#if defined(_WIN32) && defined(_MSC_VER) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR extern + #endif + #endif + #define XMLCALL __cdecl + #if !defined _REENTRANT + #define _REENTRANT + #endif +#endif + +/* Windows platform with Borland compiler */ +#if defined(_WIN32) && defined(__BORLANDC__) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) extern + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR extern + #endif + #endif + #define XMLCALL __cdecl + #if !defined _REENTRANT + #define _REENTRANT + #endif +#endif + +/* Windows platform with GNU compiler (Mingw) */ +#if defined(_WIN32) && defined(__MINGW32__) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR extern + #endif + #endif + #define XMLCALL __cdecl + #if !defined _REENTRANT + #define _REENTRANT + #endif +#endif + +/* Cygwin platform, GNU compiler */ +#if defined(_WIN32) && defined(__CYGWIN__) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR + #endif + #endif + #define XMLCALL __cdecl +#endif + +/* Compatibility */ +#if !defined(LIBXML_DLL_IMPORT) +#define LIBXML_DLL_IMPORT XMLPUBVAR +#endif + +#endif /* __XML_EXPORTS_H__ */ + + diff --git a/include/libxml/xmlmemory.h b/include/libxml/xmlmemory.h new file mode 100755 index 0000000..9cad1cd --- /dev/null +++ b/include/libxml/xmlmemory.h @@ -0,0 +1,220 @@ +/* + * Summary: interface for the memory allocator + * Description: provides interfaces for the memory allocator, + * including debugging capabilities. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __DEBUG_MEMORY_ALLOC__ +#define __DEBUG_MEMORY_ALLOC__ + +#include +#include + +/** + * DEBUG_MEMORY: + * + * DEBUG_MEMORY replaces the allocator with a collect and debug + * shell to the libc allocator. + * DEBUG_MEMORY should only be activated when debugging + * libxml i.e. if libxml has been configured with --with-debug-mem too. + */ +/* #define DEBUG_MEMORY_FREED */ +/* #define DEBUG_MEMORY_LOCATION */ + +#ifdef DEBUG +#ifndef DEBUG_MEMORY +#define DEBUG_MEMORY +#endif +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * DEBUG_MEMORY_LOCATION should be activated only when debugging + * libxml i.e. if libxml has been configured with --with-debug-mem too. + */ +#ifdef DEBUG_MEMORY_LOCATION +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The XML memory wrapper support 4 basic overloadable functions. + */ +/** + * xmlFreeFunc: + * @mem: an already allocated block of memory + * + * Signature for a free() implementation. + */ +typedef void (XMLCALL *xmlFreeFunc)(void *mem); +/** + * xmlMallocFunc: + * @size: the size requested in bytes + * + * Signature for a malloc() implementation. + * + * Returns a pointer to the newly allocated block or NULL in case of error. + */ +typedef void *(XMLCALL *xmlMallocFunc)(size_t size); + +/** + * xmlReallocFunc: + * @mem: an already allocated block of memory + * @size: the new size requested in bytes + * + * Signature for a realloc() implementation. + * + * Returns a pointer to the newly reallocated block or NULL in case of error. + */ +typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size); + +/** + * xmlStrdupFunc: + * @str: a zero terminated string + * + * Signature for an strdup() implementation. + * + * Returns the copy of the string or NULL in case of error. + */ +typedef char *(XMLCALL *xmlStrdupFunc)(const char *str); + +/* + * The 4 interfaces used for all memory handling within libxml. +LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree; +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc; +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic; +LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc; +LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup; + */ + +/* + * The way to overload the existing functions. + * The xmlGc function have an extra entry for atomic block + * allocations useful for garbage collected memory allocators + */ +XMLPUBFUN int XMLCALL + xmlMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int XMLCALL + xmlMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); +XMLPUBFUN int XMLCALL + xmlGcMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlMallocFunc mallocAtomicFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int XMLCALL + xmlGcMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlMallocFunc *mallocAtomicFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); + +/* + * Initialization of the memory layer. + */ +XMLPUBFUN int XMLCALL + xmlInitMemory (void); + +/* + * Cleanup of the memory layer. + */ +XMLPUBFUN void XMLCALL + xmlCleanupMemory (void); +/* + * These are specific to the XML debug memory wrapper. + */ +XMLPUBFUN int XMLCALL + xmlMemUsed (void); +XMLPUBFUN void XMLCALL + xmlMemDisplay (FILE *fp); +XMLPUBFUN void XMLCALL + xmlMemShow (FILE *fp, int nr); +XMLPUBFUN void XMLCALL + xmlMemoryDump (void); +XMLPUBFUN void * XMLCALL + xmlMemMalloc (size_t size); +XMLPUBFUN void * XMLCALL + xmlMemRealloc (void *ptr,size_t size); +XMLPUBFUN void XMLCALL + xmlMemFree (void *ptr); +XMLPUBFUN char * XMLCALL + xmlMemoryStrdup (const char *str); +XMLPUBFUN void * XMLCALL + xmlMallocLoc (size_t size, const char *file, int line); +XMLPUBFUN void * XMLCALL + xmlReallocLoc (void *ptr, size_t size, const char *file, int line); +XMLPUBFUN void * XMLCALL + xmlMallocAtomicLoc (size_t size, const char *file, int line); +XMLPUBFUN char * XMLCALL + xmlMemStrdupLoc (const char *str, const char *file, int line); + + +#ifdef DEBUG_MEMORY_LOCATION +/** + * xmlMalloc: + * @size: number of bytes to allocate + * + * Wrapper for the malloc() function used in the XML library. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__) +/** + * xmlMallocAtomic: + * @size: number of bytes to allocate + * + * Wrapper for the malloc() function used in the XML library for allocation + * of block not containing pointers to other areas. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__) +/** + * xmlRealloc: + * @ptr: pointer to the existing allocated area + * @size: number of bytes to allocate + * + * Wrapper for the realloc() function used in the XML library. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__) +/** + * xmlMemStrdup: + * @str: pointer to the existing string + * + * Wrapper for the strdup() function, xmlStrdup() is usually preferred. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__) + +#endif /* DEBUG_MEMORY_LOCATION */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#ifndef __XML_GLOBALS_H +#ifndef __XML_THREADS_H__ +#include +#include +#endif +#endif + +#endif /* __DEBUG_MEMORY_ALLOC__ */ + diff --git a/include/libxml/xmlreader.h b/include/libxml/xmlreader.h new file mode 100755 index 0000000..52ed215 --- /dev/null +++ b/include/libxml/xmlreader.h @@ -0,0 +1,368 @@ +/* + * Summary: the XMLReader implementation + * Description: API of the XML streaming API based on C# interfaces. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLREADER_H__ +#define __XML_XMLREADER_H__ + +#include +#include +#include +#ifdef LIBXML_SCHEMAS_ENABLED +#include +#endif + +#ifdef LIBXML_READER_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlTextReaderMode: + * + * Internal state values for the reader. + */ +typedef enum { + XML_TEXTREADER_MODE_INITIAL = 0, + XML_TEXTREADER_MODE_INTERACTIVE = 1, + XML_TEXTREADER_MODE_ERROR = 2, + XML_TEXTREADER_MODE_EOF =3, + XML_TEXTREADER_MODE_CLOSED = 4, + XML_TEXTREADER_MODE_READING = 5 +} xmlTextReaderMode; + +/** + * xmlParserProperties: + * + * Some common options to use with xmlTextReaderSetParserProp, but it + * is better to use xmlParserOption and the xmlReaderNewxxx and + * xmlReaderForxxx APIs now. + */ +typedef enum { + XML_PARSER_LOADDTD = 1, + XML_PARSER_DEFAULTATTRS = 2, + XML_PARSER_VALIDATE = 3, + XML_PARSER_SUBST_ENTITIES = 4 +} xmlParserProperties; + +/** + * xmlParserSeverities: + * + * How severe an error callback is when the per-reader error callback API + * is used. + */ +typedef enum { + XML_PARSER_SEVERITY_VALIDITY_WARNING = 1, + XML_PARSER_SEVERITY_VALIDITY_ERROR = 2, + XML_PARSER_SEVERITY_WARNING = 3, + XML_PARSER_SEVERITY_ERROR = 4 +} xmlParserSeverities; + +/** + * xmlReaderTypes: + * + * Predefined constants for the different types of nodes. + */ +typedef enum { + XML_READER_TYPE_NONE = 0, + XML_READER_TYPE_ELEMENT = 1, + XML_READER_TYPE_ATTRIBUTE = 2, + XML_READER_TYPE_TEXT = 3, + XML_READER_TYPE_CDATA = 4, + XML_READER_TYPE_ENTITY_REFERENCE = 5, + XML_READER_TYPE_ENTITY = 6, + XML_READER_TYPE_PROCESSING_INSTRUCTION = 7, + XML_READER_TYPE_COMMENT = 8, + XML_READER_TYPE_DOCUMENT = 9, + XML_READER_TYPE_DOCUMENT_TYPE = 10, + XML_READER_TYPE_DOCUMENT_FRAGMENT = 11, + XML_READER_TYPE_NOTATION = 12, + XML_READER_TYPE_WHITESPACE = 13, + XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14, + XML_READER_TYPE_END_ELEMENT = 15, + XML_READER_TYPE_END_ENTITY = 16, + XML_READER_TYPE_XML_DECLARATION = 17 +} xmlReaderTypes; + +/** + * xmlTextReader: + * + * Structure for an xmlReader context. + */ +typedef struct _xmlTextReader xmlTextReader; + +/** + * xmlTextReaderPtr: + * + * Pointer to an xmlReader context. + */ +typedef xmlTextReader *xmlTextReaderPtr; + +/* + * Constructors & Destructor + */ +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlNewTextReader (xmlParserInputBufferPtr input, + const char *URI); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlNewTextReaderFilename(const char *URI); +XMLPUBFUN void XMLCALL + xmlFreeTextReader (xmlTextReaderPtr reader); + +/* + * Iterators + */ +XMLPUBFUN int XMLCALL + xmlTextReaderRead (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadInnerXml (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadOuterXml (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadString (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader); + +/* + * Attributes of the node + */ +XMLPUBFUN int XMLCALL + xmlTextReaderAttributeCount(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderDepth (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderHasAttributes(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderHasValue(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsDefault (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNodeType (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderQuoteChar (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderReadState (xmlTextReaderPtr reader); + +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstLocalName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstPrefix (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstString (xmlTextReaderPtr reader, + const xmlChar *str); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstValue (xmlTextReaderPtr reader); + +/* + * use the Const version of the routine for + * better performance and simpler code + */ +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLocalName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderPrefix (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderValue (xmlTextReaderPtr reader); + +/* + * Methods of the XmlTextReader + */ +XMLPUBFUN int XMLCALL + xmlTextReaderClose (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, + int no); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttribute (xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlTextReaderGetRemainder (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, + const xmlChar *prefix); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, + int no); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToElement (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNormalization (xmlTextReaderPtr reader); + +/* + * Extensions + */ +XMLPUBFUN int XMLCALL + xmlTextReaderSetParserProp (xmlTextReaderPtr reader, + int prop, + int value); +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserProp (xmlTextReaderPtr reader, + int prop); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderCurrentNode (xmlTextReaderPtr reader); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderPreserve (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderPreservePattern(xmlTextReaderPtr reader, + const xmlChar *pattern, + const xmlChar **namespaces); +XMLPUBFUN xmlDocPtr XMLCALL + xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderExpand (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNext (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNextSibling (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsValid (xmlTextReaderPtr reader); +#ifdef LIBXML_SCHEMAS_ENABLED +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, + const char *rng); +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, + xmlRelaxNGPtr schema); +#endif + +/* + * New more complete APIs for simpler creation and reuse of readers + */ +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderWalker (xmlDocPtr doc); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForDoc (const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForFile (const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +XMLPUBFUN int XMLCALL + xmlReaderNewWalker (xmlTextReaderPtr reader, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlReaderNewDoc (xmlTextReaderPtr reader, + const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewFile (xmlTextReaderPtr reader, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewMemory (xmlTextReaderPtr reader, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewFd (xmlTextReaderPtr reader, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewIO (xmlTextReaderPtr reader, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +/* + * Error handling extensions + */ +typedef void * xmlTextReaderLocatorPtr; +typedef void (XMLCALL *xmlTextReaderErrorFunc) (void *arg, + const char *msg, + xmlParserSeverities severity, + xmlTextReaderLocatorPtr locator); +XMLPUBFUN int XMLCALL + xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); +/*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/ +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); +XMLPUBFUN void XMLCALL + xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc f, + void *arg); +XMLPUBFUN void XMLCALL + xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, + xmlStructuredErrorFunc f, + void *arg); +XMLPUBFUN void XMLCALL + xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc *f, + void **arg); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_READER_ENABLED */ + +#endif /* __XML_XMLREADER_H__ */ + diff --git a/include/libxml/xmlregexp.h b/include/libxml/xmlregexp.h new file mode 100755 index 0000000..e40235b --- /dev/null +++ b/include/libxml/xmlregexp.h @@ -0,0 +1,95 @@ +/* + * Summary: regular expressions handling + * Description: basic API for libxml regular expressions handling used + * for XML Schemas and validation. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_REGEXP_H__ +#define __XML_REGEXP_H__ + +#include + +#ifdef LIBXML_REGEXP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlRegexpPtr: + * + * A libxml regular expression, they can actually be far more complex + * thank the POSIX regex expressions. + */ +typedef struct _xmlRegexp xmlRegexp; +typedef xmlRegexp *xmlRegexpPtr; + +/** + * xmlRegExecCtxtPtr: + * + * A libxml progressive regular expression evaluation context + */ +typedef struct _xmlRegExecCtxt xmlRegExecCtxt; +typedef xmlRegExecCtxt *xmlRegExecCtxtPtr; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The POSIX like API + */ +XMLPUBFUN xmlRegexpPtr XMLCALL + xmlRegexpCompile (const xmlChar *regexp); +XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp); +XMLPUBFUN int XMLCALL + xmlRegexpExec (xmlRegexpPtr comp, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlRegexpPrint (FILE *output, + xmlRegexpPtr regexp); +XMLPUBFUN int XMLCALL + xmlRegexpIsDeterminist(xmlRegexpPtr comp); + +/* + * Callback function when doing a transition in the automata + */ +typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec, + const xmlChar *token, + void *transdata, + void *inputdata); + +/* + * The progressive API + */ +XMLPUBFUN xmlRegExecCtxtPtr XMLCALL + xmlRegNewExecCtxt (xmlRegexpPtr comp, + xmlRegExecCallbacks callback, + void *data); +XMLPUBFUN void XMLCALL + xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); +XMLPUBFUN int XMLCALL + xmlRegExecPushString(xmlRegExecCtxtPtr exec, + const xmlChar *value, + void *data); +XMLPUBFUN int XMLCALL + xmlRegExecPushString2(xmlRegExecCtxtPtr exec, + const xmlChar *value, + const xmlChar *value2, + void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /*__XML_REGEXP_H__ */ diff --git a/include/libxml/xmlsave.h b/include/libxml/xmlsave.h new file mode 100755 index 0000000..69f3d4b --- /dev/null +++ b/include/libxml/xmlsave.h @@ -0,0 +1,72 @@ +/* + * Summary: the XML document serializer + * Description: API to save document or subtree of document + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLSAVE_H__ +#define __XML_XMLSAVE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlSaveCtxt xmlSaveCtxt; +typedef xmlSaveCtxt *xmlSaveCtxtPtr; + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToFd (int fd, + const char *encoding, + int options); +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToFilename (const char *filename, + const char *encoding, + int options); +/****** + Not yet implemented. + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToBuffer (xmlBufferPtr buffer, + const char *encoding, + int options); + ******/ +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + const char *encoding, + int options); + +XMLPUBFUN long XMLCALL + xmlSaveDoc (xmlSaveCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN long XMLCALL + xmlSaveTree (xmlSaveCtxtPtr ctxt, + xmlNodePtr node); + +XMLPUBFUN int XMLCALL + xmlSaveFlush (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSaveClose (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSaveSetEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +XMLPUBFUN int XMLCALL + xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* __XML_XMLSAVE_H__ */ + + diff --git a/include/libxml/xmlschemas.h b/include/libxml/xmlschemas.h new file mode 100755 index 0000000..5af4521 --- /dev/null +++ b/include/libxml/xmlschemas.h @@ -0,0 +1,139 @@ +/* + * Summary: incomplete XML Schemas structure implementation + * Description: interface to the XML Schemas handling and schema validity + * checking, it is incomplete right now. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_H__ +#define __XML_SCHEMA_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This error codes are obsolete; not used any more. + */ +typedef enum { + XML_SCHEMAS_ERR_OK = 0, + XML_SCHEMAS_ERR_NOROOT = 1, + XML_SCHEMAS_ERR_UNDECLAREDELEM, + XML_SCHEMAS_ERR_NOTTOPLEVEL, + XML_SCHEMAS_ERR_MISSING, + XML_SCHEMAS_ERR_WRONGELEM, + XML_SCHEMAS_ERR_NOTYPE, + XML_SCHEMAS_ERR_NOROLLBACK, + XML_SCHEMAS_ERR_ISABSTRACT, + XML_SCHEMAS_ERR_NOTEMPTY, + XML_SCHEMAS_ERR_ELEMCONT, + XML_SCHEMAS_ERR_HAVEDEFAULT, + XML_SCHEMAS_ERR_NOTNILLABLE, + XML_SCHEMAS_ERR_EXTRACONTENT, + XML_SCHEMAS_ERR_INVALIDATTR, + XML_SCHEMAS_ERR_INVALIDELEM, + XML_SCHEMAS_ERR_NOTDETERMINIST, + XML_SCHEMAS_ERR_CONSTRUCT, + XML_SCHEMAS_ERR_INTERNAL, + XML_SCHEMAS_ERR_NOTSIMPLE, + XML_SCHEMAS_ERR_ATTRUNKNOWN, + XML_SCHEMAS_ERR_ATTRINVALID, + XML_SCHEMAS_ERR_VALUE, + XML_SCHEMAS_ERR_FACET, + XML_SCHEMAS_ERR_, + XML_SCHEMAS_ERR_XXX +} xmlSchemaValidError; + + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchema xmlSchema; +typedef xmlSchema *xmlSchemaPtr; + +/** + * A schemas validation context + */ +typedef void (*xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...); +typedef void (*xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...); + +typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt; +typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr; + +typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt; +typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr; + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewDocParserCtxt (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchemaGetParserErrors (xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc * err, + xmlSchemaValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN xmlSchemaPtr XMLCALL + xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchemaFree (xmlSchemaPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlSchemaDump (FILE *output, + xmlSchemaPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc *err, + xmlSchemaValidityWarningFunc *warn, + void **ctx); + +XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL + xmlSchemaNewValidCtxt (xmlSchemaPtr schema); +XMLPUBFUN void XMLCALL + xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt, + xmlDocPtr instance); +XMLPUBFUN int XMLCALL + xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc, + xmlSAXHandlerPtr sax, + void *user_data); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_H__ */ diff --git a/include/libxml/xmlschemastypes.h b/include/libxml/xmlschemastypes.h new file mode 100755 index 0000000..812d272 --- /dev/null +++ b/include/libxml/xmlschemastypes.h @@ -0,0 +1,92 @@ +/* + * Summary: implementation of XML Schema Datatypes + * Description: module providing the XML Schema Datatypes implementation + * both definition and validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_TYPES_H__ +#define __XML_SCHEMA_TYPES_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL + xmlSchemaInitTypes (void); +XMLPUBFUN void XMLCALL + xmlSchemaCleanupTypes (void); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetPredefinedType (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val); +XMLPUBFUN int XMLCALL + xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFacet (xmlSchemaTypePtr base, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val); +XMLPUBFUN void XMLCALL + xmlSchemaFreeValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaFacetPtr XMLCALL + xmlSchemaNewFacet (void); +XMLPUBFUN int XMLCALL + xmlSchemaCheckFacet (xmlSchemaFacetPtr facet, + xmlSchemaTypePtr typeDecl, + xmlSchemaParserCtxtPtr ctxt, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSchemaFreeFacet (xmlSchemaFacetPtr facet); +XMLPUBFUN int XMLCALL + xmlSchemaCompareValues (xmlSchemaValPtr x, + xmlSchemaValPtr y); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type); +XMLPUBFUN int XMLCALL +xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet, + const xmlChar *value, + unsigned long actualLen, + unsigned long *expectedLen); +XMLPUBFUN xmlSchemaTypePtr XMLCALL +xmlSchemaGetBuiltInType(xmlSchemaValType type); +XMLPUBFUN int XMLCALL +xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, + int facetType); +XMLPUBFUN xmlChar * XMLCALL +xmlSchemaCollapseString(const xmlChar *value); +XMLPUBFUN unsigned long XMLCALL +xmlSchemaGetFacetValueAsULong(xmlSchemaFacetPtr facet); +XMLPUBFUN int XMLCALL +xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length) ; +XMLPUBFUN int XMLCALL +xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type, const xmlChar *value, + xmlSchemaValPtr *val, xmlNodePtr node); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_TYPES_H__ */ diff --git a/include/libxml/xmlstring.h b/include/libxml/xmlstring.h new file mode 100755 index 0000000..33591cd --- /dev/null +++ b/include/libxml/xmlstring.h @@ -0,0 +1,141 @@ +/* + * Summary: set of routines to process strings + * Description: type and interfaces needed for the internal string handling + * of the library, especially UTF8 processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_STRING_H__ +#define __XML_STRING_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlChar: + * + * This is a basic byte in an UTF-8 encoded string. + * It's unsigned allowing to pinpoint case where char * are assigned + * to xmlChar * (possibly making serialization back impossible). + */ + +typedef unsigned char xmlChar; + +/** + * BAD_CAST: + * + * Macro to cast a string to an xmlChar * when one know its safe. + */ +#define BAD_CAST (xmlChar *) + +/* + * xmlChar handling + */ +XMLPUBFUN xmlChar * XMLCALL + xmlStrdup (const xmlChar *cur); +XMLPUBFUN xmlChar * XMLCALL + xmlStrndup (const xmlChar *cur, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlCharStrndup (const char *cur, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlCharStrdup (const char *cur); +XMLPUBFUN xmlChar * XMLCALL + xmlStrsub (const xmlChar *str, + int start, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrchr (const xmlChar *str, + xmlChar val); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrstr (const xmlChar *str, + const xmlChar *val); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrcasestr (const xmlChar *str, + xmlChar *val); +XMLPUBFUN int XMLCALL + xmlStrcmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrncmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrcasecmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrncasecmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrEqual (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrQEqual (const xmlChar *pref, + const xmlChar *name, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlStrlen (const xmlChar *str); +XMLPUBFUN xmlChar * XMLCALL + xmlStrcat (xmlChar *cur, + const xmlChar *add); +XMLPUBFUN xmlChar * XMLCALL + xmlStrncat (xmlChar *cur, + const xmlChar *add, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlStrncatNew (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrPrintf (xmlChar *buf, + int len, + const xmlChar *msg, + ...); +XMLPUBFUN int XMLCALL + xmlStrVPrintf (xmlChar *buf, + int len, + const xmlChar *msg, + va_list ap); + +XMLPUBFUN int XMLCALL + xmlGetUTF8Char (const unsigned char *utf, + int *len); +XMLPUBFUN int XMLCALL + xmlCheckUTF8 (const unsigned char *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Strsize (const xmlChar *utf, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strndup (const xmlChar *utf, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strpos (const xmlChar *utf, + int pos); +XMLPUBFUN int XMLCALL + xmlUTF8Strloc (const xmlChar *utf, + const xmlChar *utfchar); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strsub (const xmlChar *utf, + int start, + int len); +XMLPUBFUN int XMLCALL + xmlUTF8Strlen (const xmlChar *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Size (const xmlChar *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Charcmp (const xmlChar *utf1, + const xmlChar *utf2); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_STRING_H__ */ diff --git a/include/libxml/xmlunicode.h b/include/libxml/xmlunicode.h new file mode 100755 index 0000000..e471b7b --- /dev/null +++ b/include/libxml/xmlunicode.h @@ -0,0 +1,202 @@ +/* + * Summary: Unicode character APIs + * Description: API for the Unicode character APIs + * + * This file is automatically generated from the + * UCS description files of the Unicode Character Database + * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1d5b.html + * using the genUnicode.py Python script. + * + * Generation date: Mon Nov 10 22:35:10 2003 + * Sources: Blocks-4.0.1d1b.txt UnicodeData-4.0.1d1b.txt + * Author: Daniel Veillard + */ + +#ifndef __XML_UNICODE_H__ +#define __XML_UNICODE_H__ + +#include + +#ifdef LIBXML_UNICODE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN int XMLCALL xmlUCSIsAegeanNumbers (int code); +XMLPUBFUN int XMLCALL xmlUCSIsAlphabeticPresentationForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArmenian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArrows (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBasicLatin (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBengali (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBlockElements (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBopomofo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBopomofoExtended (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBoxDrawing (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBraillePatterns (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBuhid (int code); +XMLPUBFUN int XMLCALL xmlUCSIsByzantineMusicalSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibility (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKRadicalsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKSymbolsandPunctuation (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCherokee (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarks (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarksforSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningHalfMarks (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningMarksforSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsControlPictures (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCurrencySymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCypriotSyllabary (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCyrillic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCyrillicSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDeseret (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDevanagari (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDingbats (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEnclosedAlphanumerics (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEnclosedCJKLettersandMonths (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEthiopic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeneralPunctuation (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeometricShapes (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeorgian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGothic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreek (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreekExtended (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreekandCoptic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGujarati (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGurmukhi (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHalfwidthandFullwidthForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulCompatibilityJamo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulJamo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulSyllables (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHanunoo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHebrew (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHighPrivateUseSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHighSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHiragana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsIPAExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsIdeographicDescriptionCharacters (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKanbun (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKangxiRadicals (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKannada (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKatakana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKatakanaPhoneticExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKhmer (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKhmerSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLao (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatin1Supplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedAdditional (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLetterlikeSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLimbu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLinearBIdeograms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLinearBSyllabary (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLowSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMalayalam (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMathematicalAlphanumericSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMathematicalOperators (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbolsandArrows (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousTechnical (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMongolian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMusicalSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMyanmar (int code); +XMLPUBFUN int XMLCALL xmlUCSIsNumberForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOgham (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOldItalic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOpticalCharacterRecognition (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOriya (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOsmanya (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPhoneticExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPrivateUse (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPrivateUseArea (int code); +XMLPUBFUN int XMLCALL xmlUCSIsRunic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsShavian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSinhala (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSmallFormVariants (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSpacingModifierLetters (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSpecials (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSuperscriptsandSubscripts (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalMathematicalOperators (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSyriac (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTagalog (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTagbanwa (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTags (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTaiLe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTaiXuanJingSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTamil (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTelugu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsThaana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsThai (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTibetan (int code); +XMLPUBFUN int XMLCALL xmlUCSIsUgaritic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsUnifiedCanadianAboriginalSyllabics (int code); +XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectors (int code); +XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectorsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYiRadicals (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYiSyllables (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYijingHexagramSymbols (int code); + +XMLPUBFUN int XMLCALL xmlUCSIsBlock (int code, const char *block); + +XMLPUBFUN int XMLCALL xmlUCSIsCatC (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCf (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatL (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLm (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLt (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatM (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMn (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatN (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNd (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatP (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPd (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPf (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPi (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatS (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSk (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSm (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZ (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZp (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZs (int code); + +XMLPUBFUN int XMLCALL xmlUCSIsCat (int code, const char *cat); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_UNICODE_ENABLED */ + +#endif /* __XML_UNICODE_H__ */ diff --git a/include/libxml/xmlversion.h b/include/libxml/xmlversion.h new file mode 100755 index 0000000..d3a1b77 --- /dev/null +++ b/include/libxml/xmlversion.h @@ -0,0 +1,354 @@ +/* + * Summary: compile-time version informations + * Description: compile-time version informations for the XML library + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_VERSION_H__ +#define __XML_VERSION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * use those to be sure nothing nasty will happen if + * your library and includes mismatch + */ +#ifndef LIBXML2_COMPILING_MSCCDEF +XMLPUBFUN void XMLCALL xmlCheckVersion(int version); +#endif /* LIBXML2_COMPILING_MSCCDEF */ + +/** + * LIBXML_DOTTED_VERSION: + * + * the version string like "1.2.3" + */ +#define LIBXML_DOTTED_VERSION "2.6.13" + +/** + * LIBXML_VERSION: + * + * the version number: 1.2.3 value is 1002003 + */ +#define LIBXML_VERSION 20613 + +/** + * LIBXML_VERSION_STRING: + * + * the version number string, 1.2.3 value is "1002003" + */ +#define LIBXML_VERSION_STRING "20613" + +/** + * LIBXML_VERSION_EXTRA: + * + * extra version information, used to show a CVS compilation + */ +#define LIBXML_VERSION_EXTRA "" + +/** + * LIBXML_TEST_VERSION: + * + * Macro to check that the libxml version in use is compatible with + * the version the software has been compiled against + */ +#define LIBXML_TEST_VERSION xmlCheckVersion(20613); + +#ifndef VMS +#if 0 +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO +#else +/** + * WITHOUT_TRIO: + * + * defined if the trio support should not be configured in + */ +#define WITHOUT_TRIO +#endif +#else /* VMS */ +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO 1 +#endif /* VMS */ + +/** + * LIBXML_THREAD_ENABLED: + * + * Whether the thread support is configured in + */ +#if 1 +#if defined(_REENTRANT) || defined(__MT__) || (_POSIX_C_SOURCE - 0 >= 199506L) +#define LIBXML_THREAD_ENABLED +#endif +#endif + +/** + * LIBXML_TREE_ENABLED: + * + * Whether the DOM like tree manipulation API support is configured in + */ +#if 1 +#define LIBXML_TREE_ENABLED +#endif + +/** + * LIBXML_OUTPUT_ENABLED: + * + * Whether the serialization/saving support is configured in + */ +#if 1 +#define LIBXML_OUTPUT_ENABLED +#endif + +/** + * LIBXML_PUSH_ENABLED: + * + * Whether the push parsing interfaces are configured in + */ +#if 1 +#define LIBXML_PUSH_ENABLED +#endif + +/** + * LIBXML_READER_ENABLED: + * + * Whether the xmlReader parsing interface is configured in + */ +#if 1 +#define LIBXML_READER_ENABLED +#endif + +/** + * LIBXML_PATTERN_ENABLED: + * + * Whether the xmlPattern node selection interface is configured in + */ +#if 1 +#define LIBXML_PATTERN_ENABLED +#endif + +/** + * LIBXML_WRITER_ENABLED: + * + * Whether the xmlWriter saving interface is configured in + */ +#if 1 +#define LIBXML_WRITER_ENABLED +#endif + +/** + * LIBXML_SAX1_ENABLED: + * + * Whether the older SAX1 interface is configured in + */ +#if 1 +#define LIBXML_SAX1_ENABLED +#endif + +/** + * LIBXML_FTP_ENABLED: + * + * Whether the FTP support is configured in + */ +#if 1 +#define LIBXML_FTP_ENABLED +#endif + +/** + * LIBXML_HTTP_ENABLED: + * + * Whether the HTTP support is configured in + */ +#if 1 +#define LIBXML_HTTP_ENABLED +#endif + +/** + * LIBXML_VALID_ENABLED: + * + * Whether the DTD validation support is configured in + */ +#if 1 +#define LIBXML_VALID_ENABLED +#endif + +/** + * LIBXML_HTML_ENABLED: + * + * Whether the HTML support is configured in + */ +#if 1 +#define LIBXML_HTML_ENABLED +#endif + +/** + * LIBXML_LEGACY_ENABLED: + * + * Whether the deprecated APIs are compiled in for compatibility + */ +#if 1 +#define LIBXML_LEGACY_ENABLED +#endif + +/** + * LIBXML_C14N_ENABLED: + * + * Whether the Canonicalization support is configured in + */ +#if 1 +#define LIBXML_C14N_ENABLED +#endif + +/** + * LIBXML_CATALOG_ENABLED: + * + * Whether the Catalog support is configured in + */ +#if 1 +#define LIBXML_CATALOG_ENABLED +#endif + +/** + * LIBXML_DOCB_ENABLED: + * + * Whether the SGML Docbook support is configured in + */ +#if 1 +#define LIBXML_DOCB_ENABLED +#endif + +/** + * LIBXML_XPATH_ENABLED: + * + * Whether XPath is configured in + */ +#if 1 +#define LIBXML_XPATH_ENABLED +#endif + +/** + * LIBXML_XPTR_ENABLED: + * + * Whether XPointer is configured in + */ +#if 1 +#define LIBXML_XPTR_ENABLED +#endif + +/** + * LIBXML_XINCLUDE_ENABLED: + * + * Whether XInclude is configured in + */ +#if 1 +#define LIBXML_XINCLUDE_ENABLED +#endif + +/** + * LIBXML_ICONV_ENABLED: + * + * Whether iconv support is available + */ +#if 1 +#define LIBXML_ICONV_ENABLED +#endif + +/** + * LIBXML_ISO8859X_ENABLED: + * + * Whether ISO-8859-* support is made available in case iconv is not + */ +#if 1 +#define LIBXML_ISO8859X_ENABLED +#endif + +/** + * LIBXML_DEBUG_ENABLED: + * + * Whether Debugging module is configured in + */ +#if 1 +#define LIBXML_DEBUG_ENABLED +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * Whether the memory debugging is configured in + */ +#if 0 +#define DEBUG_MEMORY_LOCATION +#endif + +/** + * LIBXML_UNICODE_ENABLED: + * + * Whether the Unicode related interfaces are compiled in + */ +#if 1 +#define LIBXML_UNICODE_ENABLED +#endif + +/** + * LIBXML_REGEXP_ENABLED: + * + * Whether the regular expressions interfaces are compiled in + */ +#if 1 +#define LIBXML_REGEXP_ENABLED +#endif + +/** + * LIBXML_AUTOMATA_ENABLED: + * + * Whether the automata interfaces are compiled in + */ +#if 1 +#define LIBXML_AUTOMATA_ENABLED +#endif + +/** + * LIBXML_SCHEMAS_ENABLED: + * + * Whether the Schemas validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMAS_ENABLED +#endif + +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ +#ifdef __GNUC__ +#ifdef HAVE_ANSIDECL_H +#include +#endif +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED __attribute__((unused)) +#endif +#else +#define ATTRIBUTE_UNUSED +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif + + diff --git a/include/libxml/xmlwriter.h b/include/libxml/xmlwriter.h new file mode 100755 index 0000000..898850d --- /dev/null +++ b/include/libxml/xmlwriter.h @@ -0,0 +1,459 @@ + +/* + * Summary: text writing API for XML + * Description: text writing API for XML + * + * Copy: See Copyright for the status of this software. + * + * Author: Alfred Mickautsch + */ + +#ifndef __XML_XMLWRITER_H__ +#define __XML_XMLWRITER_H__ + +#include + +#ifdef LIBXML_WRITER_ENABLED + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _xmlTextWriter xmlTextWriter; + typedef xmlTextWriter *xmlTextWriterPtr; + +/* + * Constructors & Destructor + */ + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriter(xmlOutputBufferPtr out); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterFilename(const char *uri, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterMemory(xmlBufferPtr buf, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterDoc(xmlDocPtr * doc, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, + int compression); + XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer); + +/* + * Functions + */ + + +/* + * Document + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDocument(xmlTextWriterPtr writer, + const char *version, + const char *encoding, + const char *standalone); + XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr + writer); + +/* + * Comments + */ + XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr + writer); + XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr + writer, + const xmlChar * + content); + +/* + * Elements + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI); + XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr + writer); + +/* + * Elements conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * Text + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, + const char *format, va_list argptr); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, + const xmlChar * content, int len); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteRaw(xmlTextWriterPtr writer, + const xmlChar * content); + XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr + writer, + const char + *format, ...); + XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr + writer, + const char + *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer, + const xmlChar * + content); + XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer, + const char *data, + int start, int len); + XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, + const char *data, + int start, int len); + +/* + * Attributes + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartAttribute(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI); + XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr + writer); + +/* + * Attributes conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * PI's + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartPI(xmlTextWriterPtr writer, + const xmlChar * target); + XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer); + +/* + * PI conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, va_list argptr); + XMLPUBFUN int XMLCALL + xmlTextWriterWritePI(xmlTextWriterPtr writer, + const xmlChar * target, + const xmlChar * content); + +/** + * xmlTextWriterWriteProcessingInstruction: + * + * This macro maps to xmlTextWriterWritePI + */ +#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI + +/* + * CDATA + */ + XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer); + +/* + * CDATA conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, + const char *format, va_list argptr); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, + const xmlChar * content); + +/* + * DTD + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer); + +/* + * DTD conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, va_list argptr); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * subset); + +/** + * xmlTextWriterWriteDocType: + * + * this macro maps to xmlTextWriterWriteDTD + */ +#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD + +/* + * DTD element definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr + writer); + +/* + * DTD element definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD attribute list definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr + writer); + +/* + * DTD attribute list definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD entity definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, + int pe, const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr + writer); + +/* + * DTD entity definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, ...); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, + va_list argptr); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * ndataid); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr + writer, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * + ndataid); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr + writer, int pe, + const xmlChar * name, + const xmlChar * + pubid, + const xmlChar * + sysid, + const xmlChar * + ndataid, + const xmlChar * + content); + +/* + * DTD notation definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + +/* + * Indentation + */ + XMLPUBFUN int XMLCALL + xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent); + XMLPUBFUN int XMLCALL + xmlTextWriterSetIndentString(xmlTextWriterPtr writer, + const xmlChar * str); + +/* + * misc + */ + XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_WRITER_ENABLED */ + +#endif /* __XML_XMLWRITER_H__ */ diff --git a/include/libxml/xpath.h b/include/libxml/xpath.h new file mode 100755 index 0000000..ede6484 --- /dev/null +++ b/include/libxml/xpath.h @@ -0,0 +1,506 @@ +/* + * Summary: XML Path Language implementation + * Description: API for the XML Path Language implementation + * + * XML Path Language implementation + * XPath is a language for addressing parts of an XML document, + * designed to be used by both XSLT and XPointer + * http://www.w3.org/TR/xpath + * + * Implements + * W3C Recommendation 16 November 1999 + * http://www.w3.org/TR/1999/REC-xpath-19991116 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_H__ +#define __XML_XPATH_H__ + +#include + +#ifdef LIBXML_XPATH_ENABLED + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlXPathContext xmlXPathContext; +typedef xmlXPathContext *xmlXPathContextPtr; +typedef struct _xmlXPathParserContext xmlXPathParserContext; +typedef xmlXPathParserContext *xmlXPathParserContextPtr; + +/** + * The set of XPath error codes. + */ + +typedef enum { + XPATH_EXPRESSION_OK = 0, + XPATH_NUMBER_ERROR, + XPATH_UNFINISHED_LITERAL_ERROR, + XPATH_START_LITERAL_ERROR, + XPATH_VARIABLE_REF_ERROR, + XPATH_UNDEF_VARIABLE_ERROR, + XPATH_INVALID_PREDICATE_ERROR, + XPATH_EXPR_ERROR, + XPATH_UNCLOSED_ERROR, + XPATH_UNKNOWN_FUNC_ERROR, + XPATH_INVALID_OPERAND, + XPATH_INVALID_TYPE, + XPATH_INVALID_ARITY, + XPATH_INVALID_CTXT_SIZE, + XPATH_INVALID_CTXT_POSITION, + XPATH_MEMORY_ERROR, + XPTR_SYNTAX_ERROR, + XPTR_RESOURCE_ERROR, + XPTR_SUB_RESOURCE_ERROR, + XPATH_UNDEF_PREFIX_ERROR, + XPATH_ENCODING_ERROR, + XPATH_INVALID_CHAR_ERROR +} xmlXPathError; + +/* + * A node-set (an unordered collection of nodes without duplicates). + */ +typedef struct _xmlNodeSet xmlNodeSet; +typedef xmlNodeSet *xmlNodeSetPtr; +struct _xmlNodeSet { + int nodeNr; /* number of nodes in the set */ + int nodeMax; /* size of the array as allocated */ + xmlNodePtr *nodeTab; /* array of nodes in no particular order */ + /* @@ with_ns to check wether namespace nodes should be looked at @@ */ +}; + +/* + * An expression is evaluated to yield an object, which + * has one of the following four basic types: + * - node-set + * - boolean + * - number + * - string + * + * @@ XPointer will add more types ! + */ + +typedef enum { + XPATH_UNDEFINED = 0, + XPATH_NODESET = 1, + XPATH_BOOLEAN = 2, + XPATH_NUMBER = 3, + XPATH_STRING = 4, + XPATH_POINT = 5, + XPATH_RANGE = 6, + XPATH_LOCATIONSET = 7, + XPATH_USERS = 8, + XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */ +} xmlXPathObjectType; + +typedef struct _xmlXPathObject xmlXPathObject; +typedef xmlXPathObject *xmlXPathObjectPtr; +struct _xmlXPathObject { + xmlXPathObjectType type; + xmlNodeSetPtr nodesetval; + int boolval; + double floatval; + xmlChar *stringval; + void *user; + int index; + void *user2; + int index2; +}; + +/** + * xmlXPathConvertFunc: + * @obj: an XPath object + * @type: the number of the target type + * + * A conversion function is associated to a type and used to cast + * the new type to primitive values. + * + * Returns -1 in case of error, 0 otherwise + */ +typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type); + +/* + * Extra type: a name and a conversion function. + */ + +typedef struct _xmlXPathType xmlXPathType; +typedef xmlXPathType *xmlXPathTypePtr; +struct _xmlXPathType { + const xmlChar *name; /* the type name */ + xmlXPathConvertFunc func; /* the conversion function */ +}; + +/* + * Extra variable: a name and a value. + */ + +typedef struct _xmlXPathVariable xmlXPathVariable; +typedef xmlXPathVariable *xmlXPathVariablePtr; +struct _xmlXPathVariable { + const xmlChar *name; /* the variable name */ + xmlXPathObjectPtr value; /* the value */ +}; + +/** + * xmlXPathEvalFunc: + * @ctxt: an XPath parser context + * @nargs: the number of arguments passed to the function + * + * An XPath evaluation function, the parameters are on the XPath context stack. + */ + +typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, + int nargs); + +/* + * Extra function: a name and a evaluation function. + */ + +typedef struct _xmlXPathFunct xmlXPathFunct; +typedef xmlXPathFunct *xmlXPathFuncPtr; +struct _xmlXPathFunct { + const xmlChar *name; /* the function name */ + xmlXPathEvalFunc func; /* the evaluation function */ +}; + +/** + * xmlXPathAxisFunc: + * @ctxt: the XPath interpreter context + * @cur: the previous node being explored on that axis + * + * An axis traversal function. To traverse an axis, the engine calls + * the first time with cur == NULL and repeat until the function returns + * NULL indicating the end of the axis traversal. + * + * Returns the next node in that axis or NULL if at the end of the axis. + */ + +typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr cur); + +/* + * Extra axis: a name and an axis function. + */ + +typedef struct _xmlXPathAxis xmlXPathAxis; +typedef xmlXPathAxis *xmlXPathAxisPtr; +struct _xmlXPathAxis { + const xmlChar *name; /* the axis name */ + xmlXPathAxisFunc func; /* the search function */ +}; + +/** + * xmlXPathFunction: + * @ctxt: the XPath interprestation context + * @nargs: the number of arguments + * + * An XPath function. + * The arguments (if any) are popped out from the context stack + * and the result is pushed on the stack. + */ + +typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs); + +/* + * Function and Variable Lookup. + */ + +/** + * xmlXPathVariableLookupFunc: + * @ctxt: an XPath context + * @name: name of the variable + * @ns_uri: the namespace name hosting this variable + * + * Prototype for callbacks used to plug variable lookup in the XPath + * engine. + * + * Returns the XPath object value or NULL if not found. + */ +typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFuncLookupFunc: + * @ctxt: an XPath context + * @name: name of the function + * @ns_uri: the namespace name hosting this function + * + * Prototype for callbacks used to plug function lookup in the XPath + * engine. + * + * Returns the XPath function or NULL if not found. + */ +typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathContext: + * + * Expression evaluation occurs with respect to a context. + * he context consists of: + * - a node (the context node) + * - a node list (the context node list) + * - a set of variable bindings + * - a function library + * - the set of namespace declarations in scope for the expression + * Following the switch to hash tables, this need to be trimmed up at + * the next binary incompatible release. + */ + +struct _xmlXPathContext { + xmlDocPtr doc; /* The current document */ + xmlNodePtr node; /* The current node */ + + int nb_variables_unused; /* unused (hash table) */ + int max_variables_unused; /* unused (hash table) */ + xmlHashTablePtr varHash; /* Hash table of defined variables */ + + int nb_types; /* number of defined types */ + int max_types; /* max number of types */ + xmlXPathTypePtr types; /* Array of defined types */ + + int nb_funcs_unused; /* unused (hash table) */ + int max_funcs_unused; /* unused (hash table) */ + xmlHashTablePtr funcHash; /* Hash table of defined funcs */ + + int nb_axis; /* number of defined axis */ + int max_axis; /* max number of axis */ + xmlXPathAxisPtr axis; /* Array of defined axis */ + + /* the namespace nodes of the context node */ + xmlNsPtr *namespaces; /* Array of namespaces */ + int nsNr; /* number of namespace in scope */ + void *user; /* function to free */ + + /* extra variables */ + int contextSize; /* the context size */ + int proximityPosition; /* the proximity position */ + + /* extra stuff for XPointer */ + int xptr; /* it this an XPointer context */ + xmlNodePtr here; /* for here() */ + xmlNodePtr origin; /* for origin() */ + + /* the set of namespace declarations in scope for the expression */ + xmlHashTablePtr nsHash; /* The namespaces hash table */ + xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */ + void *varLookupData; /* variable lookup data */ + + /* Possibility to link in an extra item */ + void *extra; /* needed for XSLT */ + + /* The function name and URI when calling a function */ + const xmlChar *function; + const xmlChar *functionURI; + + /* function lookup function and data */ + xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */ + void *funcLookupData; /* function lookup data */ + + /* temporary namespace lists kept for walking the namespace axis */ + xmlNsPtr *tmpNsList; /* Array of namespaces */ + int tmpNsNr; /* number of namespace in scope */ + + /* error reporting mechanism */ + void *userData; /* user specific data block */ + xmlStructuredErrorFunc error; /* the callback in case of errors */ + xmlError lastError; /* the last error */ + xmlNodePtr debugNode; /* the source node XSLT */ + + /* dictionnary */ + xmlDictPtr dict; /* dictionnary if any */ +}; + +/* + * The structure of a compiled expression form is not public. + */ + +typedef struct _xmlXPathCompExpr xmlXPathCompExpr; +typedef xmlXPathCompExpr *xmlXPathCompExprPtr; + +/** + * xmlXPathParserContext: + * + * An XPath parser context. It contains pure parsing informations, + * an xmlXPathContext, and the stack of objects. + */ +struct _xmlXPathParserContext { + const xmlChar *cur; /* the current char being parsed */ + const xmlChar *base; /* the full expression */ + + int error; /* error code */ + + xmlXPathContextPtr context; /* the evaluation context */ + xmlXPathObjectPtr value; /* the current value */ + int valueNr; /* number of values stacked */ + int valueMax; /* max number of values stacked */ + xmlXPathObjectPtr *valueTab; /* stack of values */ + + xmlXPathCompExprPtr comp; /* the precompiled expression */ + int xptr; /* it this an XPointer expression */ + xmlNodePtr ancestor; /* used for walking preceding axis */ +}; + +/************************************************************************ + * * + * Public API * + * * + ************************************************************************/ + +/** + * Objects and Nodesets handling + */ + +XMLPUBVAR double xmlXPathNAN; +XMLPUBVAR double xmlXPathPINF; +XMLPUBVAR double xmlXPathNINF; + +XMLPUBFUN int XMLCALL + xmlXPathIsNaN (double val); +XMLPUBFUN int XMLCALL + xmlXPathIsInf (double val); + +/* These macros may later turn into functions */ +/** + * xmlXPathNodeSetGetLength: + * @ns: a node-set + * + * Implement a functionality similar to the DOM NodeList.length. + * + * Returns the number of nodes in the node-set. + */ +#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0) +/** + * xmlXPathNodeSetItem: + * @ns: a node-set + * @index: index of a node in the set + * + * Implements a functionality similar to the DOM NodeList.item(). + * + * Returns the xmlNodePtr at the given @index in @ns or NULL if + * @index is out of range (0 to length-1) + */ +#define xmlXPathNodeSetItem(ns, index) \ + ((((ns) != NULL) && \ + ((index) >= 0) && ((index) < (ns)->nodeNr)) ? \ + (ns)->nodeTab[(index)] \ + : NULL) +/** + * xmlXPathNodeSetIsEmpty: + * @ns: a node-set + * + * Checks whether @ns is empty or not. + * + * Returns %TRUE if @ns is an empty node-set. + */ +#define xmlXPathNodeSetIsEmpty(ns) \ + (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL)) + + +XMLPUBFUN void XMLCALL + xmlXPathFreeObject (xmlXPathObjectPtr obj); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeSetCreate (xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj); +XMLPUBFUN void XMLCALL + xmlXPathFreeNodeSet (xmlNodeSetPtr obj); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathObjectCopy (xmlXPathObjectPtr val); +XMLPUBFUN int XMLCALL + xmlXPathCmpNodes (xmlNodePtr node1, + xmlNodePtr node2); +/** + * Conversion functions to basic types. + */ +XMLPUBFUN int XMLCALL + xmlXPathCastNumberToBoolean (double val); +XMLPUBFUN int XMLCALL + xmlXPathCastStringToBoolean (const xmlChar * val); +XMLPUBFUN int XMLCALL + xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns); +XMLPUBFUN int XMLCALL + xmlXPathCastToBoolean (xmlXPathObjectPtr val); + +XMLPUBFUN double XMLCALL + xmlXPathCastBooleanToNumber (int val); +XMLPUBFUN double XMLCALL + xmlXPathCastStringToNumber (const xmlChar * val); +XMLPUBFUN double XMLCALL + xmlXPathCastNodeToNumber (xmlNodePtr node); +XMLPUBFUN double XMLCALL + xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns); +XMLPUBFUN double XMLCALL + xmlXPathCastToNumber (xmlXPathObjectPtr val); + +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastBooleanToString (int val); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNumberToString (double val); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNodeToString (xmlNodePtr node); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNodeSetToString (xmlNodeSetPtr ns); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastToString (xmlXPathObjectPtr val); + +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertBoolean (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertNumber (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertString (xmlXPathObjectPtr val); + +/** + * Context handling. + */ +XMLPUBFUN void XMLCALL + xmlXPathInit (void); +XMLPUBFUN xmlXPathContextPtr XMLCALL + xmlXPathNewContext (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlXPathFreeContext (xmlXPathContextPtr ctxt); + +/** + * Evaluation functions. + */ +XMLPUBFUN long XMLCALL + xmlXPathOrderDocElems (xmlDocPtr doc); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathEvalExpression (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXPathEvalPredicate (xmlXPathContextPtr ctxt, + xmlXPathObjectPtr res); +/** + * Separate compilation/evaluation entry points. + */ +XMLPUBFUN xmlXPathCompExprPtr XMLCALL + xmlXPathCompile (const xmlChar *str); +XMLPUBFUN xmlXPathCompExprPtr XMLCALL + xmlXPathCtxtCompile (xmlXPathContextPtr ctxt, + const xmlChar *str); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathCompiledEval (xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctx); +XMLPUBFUN void XMLCALL + xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED */ +#endif /* ! __XML_XPATH_H__ */ diff --git a/include/libxml/xpathInternals.h b/include/libxml/xpathInternals.h new file mode 100755 index 0000000..80f6598 --- /dev/null +++ b/include/libxml/xpathInternals.h @@ -0,0 +1,629 @@ +/* + * Summary: internal interfaces for XML Path Language implementation + * Description: internal interfaces for XML Path Language implementation + * used to build new modules on top of XPath like XPointer and + * XSLT + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_INTERNALS_H__ +#define __XML_XPATH_INTERNALS_H__ + +#include +#include + +#ifdef LIBXML_XPATH_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************ + * * + * Helpers * + * * + ************************************************************************/ + +/* + * Many of these macros may later turn into functions. They + * shouldn't be used in #ifdef's preprocessor instructions. + */ +/** + * xmlXPathSetError: + * @ctxt: an XPath parser context + * @err: an xmlXPathError code + * + * Raises an error. + */ +#define xmlXPathSetError(ctxt, err) \ + { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \ + (ctxt)->error = (err); } + +/** + * xmlXPathSetArityError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_ARITY error. + */ +#define xmlXPathSetArityError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_ARITY) + +/** + * xmlXPathSetTypeError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_TYPE error. + */ +#define xmlXPathSetTypeError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_TYPE) + +/** + * xmlXPathGetError: + * @ctxt: an XPath parser context + * + * Get the error code of an XPath context. + * + * Returns the context error. + */ +#define xmlXPathGetError(ctxt) ((ctxt)->error) + +/** + * xmlXPathCheckError: + * @ctxt: an XPath parser context + * + * Check if an XPath error was raised. + * + * Returns true if an error has been raised, false otherwise. + */ +#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK) + +/** + * xmlXPathGetDocument: + * @ctxt: an XPath parser context + * + * Get the document of an XPath context. + * + * Returns the context document. + */ +#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc) + +/** + * xmlXPathGetContextNode: + * @ctxt: an XPath parser context + * + * Get the context node of an XPath context. + * + * Returns the context node. + */ +#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node) + +XMLPUBFUN int XMLCALL + xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt); +XMLPUBFUN double XMLCALL + xmlXPathPopNumber (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathPopString (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void * XMLCALL + xmlXPathPopExternal (xmlXPathParserContextPtr ctxt); + +/** + * xmlXPathReturnBoolean: + * @ctxt: an XPath parser context + * @val: a boolean + * + * Pushes the boolean @val on the context stack. + */ +#define xmlXPathReturnBoolean(ctxt, val) \ + valuePush((ctxt), xmlXPathNewBoolean(val)) + +/** + * xmlXPathReturnTrue: + * @ctxt: an XPath parser context + * + * Pushes true on the context stack. + */ +#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1) + +/** + * xmlXPathReturnFalse: + * @ctxt: an XPath parser context + * + * Pushes false on the context stack. + */ +#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0) + +/** + * xmlXPathReturnNumber: + * @ctxt: an XPath parser context + * @val: a double + * + * Pushes the double @val on the context stack. + */ +#define xmlXPathReturnNumber(ctxt, val) \ + valuePush((ctxt), xmlXPathNewFloat(val)) + +/** + * xmlXPathReturnString: + * @ctxt: an XPath parser context + * @str: a string + * + * Pushes the string @str on the context stack. + */ +#define xmlXPathReturnString(ctxt, str) \ + valuePush((ctxt), xmlXPathWrapString(str)) + +/** + * xmlXPathReturnEmptyString: + * @ctxt: an XPath parser context + * + * Pushes an empty string on the stack. + */ +#define xmlXPathReturnEmptyString(ctxt) \ + valuePush((ctxt), xmlXPathNewCString("")) + +/** + * xmlXPathReturnNodeSet: + * @ctxt: an XPath parser context + * @ns: a node-set + * + * Pushes the node-set @ns on the context stack. + */ +#define xmlXPathReturnNodeSet(ctxt, ns) \ + valuePush((ctxt), xmlXPathWrapNodeSet(ns)) + +/** + * xmlXPathReturnEmptyNodeSet: + * @ctxt: an XPath parser context + * + * Pushes an empty node-set on the context stack. + */ +#define xmlXPathReturnEmptyNodeSet(ctxt) \ + valuePush((ctxt), xmlXPathNewNodeSet(NULL)) + +/** + * xmlXPathReturnExternal: + * @ctxt: an XPath parser context + * @val: user data + * + * Pushes user data on the context stack. + */ +#define xmlXPathReturnExternal(ctxt, val) \ + valuePush((ctxt), xmlXPathWrapExternal(val)) + +/** + * xmlXPathStackIsNodeSet: + * @ctxt: an XPath parser context + * + * Check if the current value on the XPath stack is a node set or + * an XSLT value tree. + * + * Returns true if the current object on the stack is a node-set. + */ +#define xmlXPathStackIsNodeSet(ctxt) \ + (((ctxt)->value != NULL) \ + && (((ctxt)->value->type == XPATH_NODESET) \ + || ((ctxt)->value->type == XPATH_XSLT_TREE))) + +/** + * xmlXPathStackIsExternal: + * @ctxt: an XPath parser context + * + * Checks if the current value on the XPath stack is an external + * object. + * + * Returns true if the current object on the stack is an external + * object. + */ +#define xmlXPathStackIsExternal(ctxt) \ + ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS)) + +/** + * xmlXPathEmptyNodeSet: + * @ns: a node-set + * + * Empties a node-set. + */ +#define xmlXPathEmptyNodeSet(ns) \ + { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; } + +/** + * CHECK_ERROR: + * + * Macro to return from the function if an XPath error was detected. + */ +#define CHECK_ERROR \ + if (ctxt->error != XPATH_EXPRESSION_OK) return + +/** + * CHECK_ERROR0: + * + * Macro to return 0 from the function if an XPath error was detected. + */ +#define CHECK_ERROR0 \ + if (ctxt->error != XPATH_EXPRESSION_OK) return(0) + +/** + * XP_ERROR: + * @X: the error code + * + * Macro to raise an XPath error and return. + */ +#define XP_ERROR(X) \ + { xmlXPathErr(ctxt, X); return; } + +/** + * XP_ERROR0: + * @X: the error code + * + * Macro to raise an XPath error and return 0. + */ +#define XP_ERROR0(X) \ + { xmlXPathErr(ctxt, X); return(0); } + +/** + * CHECK_TYPE: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. + */ +#define CHECK_TYPE(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR(XPATH_INVALID_TYPE) + +/** + * CHECK_TYPE0: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. Return(0) in case of failure + */ +#define CHECK_TYPE0(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR0(XPATH_INVALID_TYPE) + +/** + * CHECK_ARITY: + * @x: the number of expected args + * + * Macro to check that the number of args passed to an XPath function matches. + */ +#define CHECK_ARITY(x) \ + if (nargs != (x)) \ + XP_ERROR(XPATH_INVALID_ARITY); + +/** + * CAST_TO_STRING: + * + * Macro to try to cast the value on the top of the XPath stack to a string. + */ +#define CAST_TO_STRING \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \ + xmlXPathStringFunction(ctxt, 1); + +/** + * CAST_TO_NUMBER: + * + * Macro to try to cast the value on the top of the XPath stack to a number. + */ +#define CAST_TO_NUMBER \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \ + xmlXPathNumberFunction(ctxt, 1); + +/** + * CAST_TO_BOOLEAN: + * + * Macro to try to cast the value on the top of the XPath stack to a boolean. + */ +#define CAST_TO_BOOLEAN \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \ + xmlXPathBooleanFunction(ctxt, 1); + +/* + * Variable Lookup forwarding. + */ + +XMLPUBFUN void XMLCALL + xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt, + xmlXPathVariableLookupFunc f, + void *data); + +/* + * Function Lookup forwarding. + */ + +XMLPUBFUN void XMLCALL + xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt, + xmlXPathFuncLookupFunc f, + void *funcCtxt); + +/* + * Error reporting. + */ +XMLPUBFUN void XMLCALL + xmlXPatherror (xmlXPathParserContextPtr ctxt, + const char *file, + int line, + int no); + +XMLPUBFUN void XMLCALL + xmlXPathErr (xmlXPathParserContextPtr ctxt, + int error); + +#ifdef LIBXML_DEBUG_ENABLED +XMLPUBFUN void XMLCALL + xmlXPathDebugDumpObject (FILE *output, + xmlXPathObjectPtr cur, + int depth); +XMLPUBFUN void XMLCALL + xmlXPathDebugDumpCompExpr(FILE *output, + xmlXPathCompExprPtr comp, + int depth); +#endif +/** + * NodeSet handling. + */ +XMLPUBFUN int XMLCALL + xmlXPathNodeSetContains (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDifference (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathIntersection (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDistinctSorted (xmlNodeSetPtr nodes); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDistinct (xmlNodeSetPtr nodes); + +XMLPUBFUN int XMLCALL + xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeLeading (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathLeading (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeTrailing (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathTrailing (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + + +/** + * Extending a context. + */ + +XMLPUBFUN int XMLCALL + xmlXPathRegisterNs (xmlXPathContextPtr ctxt, + const xmlChar *prefix, + const xmlChar *ns_uri); +XMLPUBFUN const xmlChar * XMLCALL + xmlXPathNsLookup (xmlXPathContextPtr ctxt, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt); + +XMLPUBFUN int XMLCALL + xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathFunction f); +XMLPUBFUN int XMLCALL + xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathFunction f); +XMLPUBFUN int XMLCALL + xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathObjectPtr value); +XMLPUBFUN int XMLCALL + xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathObjectPtr value); +XMLPUBFUN xmlXPathFunction XMLCALL + xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathFunction XMLCALL + xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathVariableLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); + +/** + * Utilities to extend XPath. + */ +XMLPUBFUN xmlXPathParserContextPtr XMLCALL + xmlXPathNewParserContext (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); + +/* TODO: remap to xmlXPathValuePop and Push. */ +XMLPUBFUN xmlXPathObjectPtr XMLCALL + valuePop (xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL + valuePush (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr value); + +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewString (const xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewCString (const char *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapString (xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapCString (char * val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewFloat (double val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewBoolean (int val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewNodeSet (xmlNodePtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewValueTree (xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetAdd (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetAddNs (xmlNodeSetPtr cur, + xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetSort (xmlNodeSetPtr set); + +XMLPUBFUN void XMLCALL + xmlXPathRoot (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathParseName (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathParseNCName (xmlXPathParserContextPtr ctxt); + +/* + * Existing functions. + */ +XMLPUBFUN double XMLCALL + xmlXPathStringEvalNumber (const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr res); +XMLPUBFUN void XMLCALL + xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeSetMerge (xmlNodeSetPtr val1, + xmlNodeSetPtr val2); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetDel (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetRemove (xmlNodeSetPtr cur, + int val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewNodeSetList (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapNodeSet (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapExternal (void *val); + +XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); +XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt); + +XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name); + +/* + * Some of the axis navigation routines. + */ +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +/* + * The official core of XPath functions. + */ +XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs); + +/** + * Really internal functions + */ +XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED */ +#endif /* ! __XML_XPATH_INTERNALS_H__ */ diff --git a/include/libxml/xpointer.h b/include/libxml/xpointer.h new file mode 100755 index 0000000..822843f --- /dev/null +++ b/include/libxml/xpointer.h @@ -0,0 +1,114 @@ +/* + * Summary: API to handle XML Pointers + * Description: API to handle XML Pointers + * Base implementation was made accordingly to + * W3C Candidate Recommendation 7 June 2000 + * http://www.w3.org/TR/2000/CR-xptr-20000607 + * + * Added support for the element() scheme described in: + * W3C Proposed Recommendation 13 November 2002 + * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPTR_H__ +#define __XML_XPTR_H__ + +#include + +#ifdef LIBXML_XPTR_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A Location Set + */ +typedef struct _xmlLocationSet xmlLocationSet; +typedef xmlLocationSet *xmlLocationSetPtr; +struct _xmlLocationSet { + int locNr; /* number of locations in the set */ + int locMax; /* size of the array as allocated */ + xmlXPathObjectPtr *locTab;/* array of locations */ +}; + +/* + * Handling of location sets. + */ + +XMLPUBFUN xmlLocationSetPtr XMLCALL + xmlXPtrLocationSetCreate (xmlXPathObjectPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); +XMLPUBFUN xmlLocationSetPtr XMLCALL + xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, + xmlLocationSetPtr val2); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRange (xmlNodePtr start, + int startindex, + xmlNodePtr end, + int endindex); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangePoints (xmlXPathObjectPtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodePoint (xmlNodePtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangePointNode (xmlXPathObjectPtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodes (xmlNodePtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewLocationSetNodes (xmlNodePtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodeObject (xmlNodePtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewCollapsedRange (xmlNodePtr start); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, + xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrWrapLocationSet (xmlLocationSetPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetDel (xmlLocationSetPtr cur, + xmlXPathObjectPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetRemove (xmlLocationSetPtr cur, + int val); + +/* + * Functions. + */ +XMLPUBFUN xmlXPathContextPtr XMLCALL + xmlXPtrNewContext (xmlDocPtr doc, + xmlNodePtr here, + xmlNodePtr origin); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN void XMLCALL + xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt, + int nargs); +XMLPUBFUN xmlNodePtr XMLCALL + xmlXPtrBuildNodeList (xmlXPathObjectPtr obj); +XMLPUBFUN void XMLCALL + xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ +#endif /* __XML_XPTR_H__ */ diff --git a/include/modem/modem.h b/include/modem/modem.h new file mode 100755 index 0000000..2048004 --- /dev/null +++ b/include/modem/modem.h @@ -0,0 +1,89 @@ +// +// modem.h +// modem header +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 16 Aug 07 +// +#ifndef MODEM_H +#define MODEM_H + +#define MODEM_VER_STRING "1" + +// +// MODEMOP_ +// modem operations +// +enum { + MODEMOP_GETVERSTRING=0, + MODEMOP_SETCALLBACK, + MODEMOP_SENDBUF, + MODEMOP_ISMODEMPRESENT, + MODEMOP_RESET, +}; + +#define M_MODEMOP 0xff + +// +// MODEMCALLBACK_ +// callback reasons +// +enum { + MODEMCALLBACK_ERROR=1, // received ERROR + MODEMCALLBACK_OK, // received OK + MODEMCALLBACK_UNKNOWN, // received but don't recognize string +}; + +// +// MODEM_ +// modem type enumerations +// +enum { + MODEM_AIRCARD875U, // Sierra Wireless Aircard + NUM_MODEMS +}; + +/////////////////////////////////////////////////////////////////////////////// +// ERROR CODES +/////////////////////////////////////////////////////////////////////////////// +// +// ERRORS & EXTENDED RETURN CODES +// +// -1.....-8999 user +// -9000..-9099 system +// +enum // int16 +{ + // system + ERR_MODEM_SYS_LAST=-9099, + ERR_MODEM_DEVICE_NOTAVAILABLE, + ERR_MODEM_MEM, + ERR_MODEM_SENDBUFFER_FULL, + ERR_MODEM_PORT_NOTOPEN, + ERR_MODEM_OP_NOTRECOGNIZED, + ERR_MODEM_SYS_FIRST=-9000, + +}; // ERR_ + +extern int ModemInit(void); +extern void ModemFinal(void); +extern int ModemBegin(void); +extern void ModemEnd(void); +extern int ModemChangePortSettings(unsigned int port, unsigned long baud); +extern void ModemGetVersionString(char *buf, int bufSize); +extern int ModemLoop(void); +extern int ModemOp(unsigned int op,...); +extern int ModemFlushIO(void); + + +// apphook +extern void* modem_apphook_malloc(int size); +extern void modem_apphook_free(void *m); +extern void modem_apphook_msg(char *fmt,...); + +#endif // ndef MODEM_H +// EOF + diff --git a/include/modem/modempriv.h b/include/modem/modempriv.h new file mode 100755 index 0000000..34a5a88 --- /dev/null +++ b/include/modem/modempriv.h @@ -0,0 +1,143 @@ +// +// modempriv.h +// modem header, internal +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Aug 07 +// +#ifndef MODEMPRIV_H +#define MODEMPRIV_H + +#define MODEMPRIV_VER_STRING "a" + +#define MODEM_AT_IOPORT_DEFAULT 2 +#define MODEM_DM_IOPORT_DEFAULT 1 +#define MODEM_BAUD_DEFAULT 115200 + +#define NUM_MODEM_IOPORTS 3 + +#define SEND_BUFFER_SIZE 256 +#define RECEIVE_BUFFER_SIZE 4096 + +// +// M_MODEM_FLAGS_ +// flags set/cleared by modem mid-level routines +// +#define M_MODEM_FLAGS_FLUSHIO 0x00000001 +#define M_MODEM_FLAGS_NODATA_PROCESSED 0x01000000 +#define M_MODEM_FLAGS_DATA_EXPECTED 0x02000000 +#define M_MODEM_FLAGS_DM_PRINT 0x04000000 + +// +// M_MODEM_INTFLAGS_ +// flags set/cleared only by modem reader thread +// +#define M_MODEM_INTFLAGS_FLUSHIO_ACK 0x00000001 +#define M_MODEM_INTFLAGS_RESET 0x00000004 +#define M_MODEM_INTFLAGS_ACK 0x00000008 +#define M_MODEM_INTFLAGS_NODATA 0x00100000 + +// +// M_MODEM_INTERROR_ +// error flags set only by modem reader thread +// +#define M_MODEM_INTERROR_ROVERFLOW 0x00000001 + +#if SYS_PC +#include +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + int avail; // packets available + int (*callback)(int op,...); + unsigned int iComPort[2]; // Open Com Port number + unsigned long iBaudRate; + unsigned int modemType; + + // intFlags, intErrorf and card track data (only written by xxxcardThread, read all you want) + unsigned intFlags; + unsigned intErrorf; // error flags + + char transferBuf[RECEIVE_BUFFER_SIZE+1]; + + // implementation specific + HANDLE thread; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + + char *snd; + unsigned sndsize; + unsigned sndn; // bytes in buf + unsigned sndw; // write index + unsigned sndr; // read index + + int iPd[2]; // port file descriptor + +} sModemDev; +#elif SYS_BB +#include +#define _POSIX_SOURCE 1 // POSIX compliant source +#define FALSE 0 +#define TRUE 1 +#define _XOPEN_SOURCE 500 // makes usleep() get defined properly? +#include +#include +#include +#include //posix threads +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + int avail; // packets available + int (*callback)(int op,...); + unsigned int iComPort[2]; // Open Com Port number + unsigned long iBaudRate; + unsigned int modemType; + + // intFlags, intErrorf and card track data (only written by xxxcardThread, read all you want) + unsigned intFlags; + unsigned intErrorf; // error flags + + char transferBuf[RECEIVE_BUFFER_SIZE+1]; + + // implementation specific + pthread_t thread; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + + char *snd; + unsigned sndsize; + unsigned sndn; // bytes in buf + unsigned sndw; // write index + unsigned sndr; // read index + + int iPd[2]; // port file descriptor + struct termios oldtio[2]; + +} sModemDev; +#else +#error Must define SYS_ in pre-processor +#endif + +extern int modemDrvrInit(sModemDev *mdev); +extern void modemDrvrFinal(sModemDev *mdev); +extern int modemDrvrOpen(sModemDev *mdev); +extern void modemDrvrClose(sModemDev *mdev); +extern int modemDrvrIsPresent(sModemDev *mdev); +extern sModemDev *modemGetDevice(void); +int modemSendLoop(sModemDev *mdev); +int modemSend(sModemDev *mdev,int flags,unsigned char *buf,int bufsize); +int modemReadLoop(sModemDev *mdev); + +#endif // ndef MODEMPRIV_H +// EOF diff --git a/include/ogg/config_types.h b/include/ogg/config_types.h new file mode 100755 index 0000000..880914e --- /dev/null +++ b/include/ogg/config_types.h @@ -0,0 +1,11 @@ +#ifndef __CONFIG_TYPES_H__ +#define __CONFIG_TYPES_H__ + +/* these are filled in by configure */ +typedef int16_t ogg_int16_t; +typedef u_int16_t ogg_uint16_t; +typedef int32_t ogg_int32_t; +typedef u_int32_t ogg_uint32_t; +typedef int64_t ogg_int64_t; + +#endif diff --git a/include/ogg/ogg.h b/include/ogg/ogg.h new file mode 100755 index 0000000..a3040dc --- /dev/null +++ b/include/ogg/ogg.h @@ -0,0 +1,202 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: toplevel libogg include + last mod: $Id: ogg.h 7188 2004-07-20 07:26:04Z xiphmont $ + + ********************************************************************/ +#ifndef _OGG_H +#define _OGG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct { + long endbyte; + int endbit; + + unsigned char *buffer; + unsigned char *ptr; + long storage; +} oggpack_buffer; + +/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ + +typedef struct { + unsigned char *header; + long header_len; + unsigned char *body; + long body_len; +} ogg_page; + +/* ogg_stream_state contains the current encode/decode state of a logical + Ogg bitstream **********************************************************/ + +typedef struct { + unsigned char *body_data; /* bytes from packet bodies */ + long body_storage; /* storage elements allocated */ + long body_fill; /* elements stored; fill mark */ + long body_returned; /* elements of fill returned */ + + + int *lacing_vals; /* The values that will go to the segment table */ + ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact + this way, but it is simple coupled to the + lacing fifo */ + long lacing_storage; + long lacing_fill; + long lacing_packet; + long lacing_returned; + + unsigned char header[282]; /* working space for header encode */ + int header_fill; + + int e_o_s; /* set when we have buffered the last packet in the + logical bitstream */ + int b_o_s; /* set after we've written the initial page + of a logical bitstream */ + long serialno; + long pageno; + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ + ogg_int64_t granulepos; + +} ogg_stream_state; + +/* ogg_packet is used to encapsulate the data and metadata belonging + to a single raw Ogg/Vorbis packet *************************************/ + +typedef struct { + unsigned char *packet; + long bytes; + long b_o_s; + long e_o_s; + + ogg_int64_t granulepos; + + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ +} ogg_packet; + +typedef struct { + unsigned char *data; + int storage; + int fill; + int returned; + + int unsynced; + int headerbytes; + int bodybytes; +} ogg_sync_state; + +/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ + +extern void oggpack_writeinit(oggpack_buffer *b); +extern void oggpack_writetrunc(oggpack_buffer *b,long bits); +extern void oggpack_writealign(oggpack_buffer *b); +extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpack_reset(oggpack_buffer *b); +extern void oggpack_writeclear(oggpack_buffer *b); +extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpack_look(oggpack_buffer *b,int bits); +extern long oggpack_look1(oggpack_buffer *b); +extern void oggpack_adv(oggpack_buffer *b,int bits); +extern void oggpack_adv1(oggpack_buffer *b); +extern long oggpack_read(oggpack_buffer *b,int bits); +extern long oggpack_read1(oggpack_buffer *b); +extern long oggpack_bytes(oggpack_buffer *b); +extern long oggpack_bits(oggpack_buffer *b); +extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); + +extern void oggpackB_writeinit(oggpack_buffer *b); +extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); +extern void oggpackB_writealign(oggpack_buffer *b); +extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpackB_reset(oggpack_buffer *b); +extern void oggpackB_writeclear(oggpack_buffer *b); +extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpackB_look(oggpack_buffer *b,int bits); +extern long oggpackB_look1(oggpack_buffer *b); +extern void oggpackB_adv(oggpack_buffer *b,int bits); +extern void oggpackB_adv1(oggpack_buffer *b); +extern long oggpackB_read(oggpack_buffer *b,int bits); +extern long oggpackB_read1(oggpack_buffer *b); +extern long oggpackB_bytes(oggpack_buffer *b); +extern long oggpackB_bits(oggpack_buffer *b); +extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); + +/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ + +extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); +extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); +extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); + +/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ + +extern int ogg_sync_init(ogg_sync_state *oy); +extern int ogg_sync_clear(ogg_sync_state *oy); +extern int ogg_sync_reset(ogg_sync_state *oy); +extern int ogg_sync_destroy(ogg_sync_state *oy); + +extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); +extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); +extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); +extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); +extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); +extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); +extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); + +/* Ogg BITSTREAM PRIMITIVES: general ***************************/ + +extern int ogg_stream_init(ogg_stream_state *os,int serialno); +extern int ogg_stream_clear(ogg_stream_state *os); +extern int ogg_stream_reset(ogg_stream_state *os); +extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); +extern int ogg_stream_destroy(ogg_stream_state *os); +extern int ogg_stream_eos(ogg_stream_state *os); + +extern void ogg_page_checksum_set(ogg_page *og); + +extern int ogg_page_version(ogg_page *og); +extern int ogg_page_continued(ogg_page *og); +extern int ogg_page_bos(ogg_page *og); +extern int ogg_page_eos(ogg_page *og); +extern ogg_int64_t ogg_page_granulepos(ogg_page *og); +extern int ogg_page_serialno(ogg_page *og); +extern long ogg_page_pageno(ogg_page *og); +extern int ogg_page_packets(ogg_page *og); + +extern void ogg_packet_clear(ogg_packet *op); + + +#ifdef __cplusplus +} +#endif + +#endif /* _OGG_H */ + + + + + + diff --git a/include/ogg/os_types.h b/include/ogg/os_types.h new file mode 100755 index 0000000..0aeae34 --- /dev/null +++ b/include/ogg/os_types.h @@ -0,0 +1,127 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $ + + ********************************************************************/ +#ifndef _OS_TYPES_H +#define _OS_TYPES_H + +/* make it easy on the folks that want to compile the libs with a + different malloc than stdlib */ +#define _ogg_malloc malloc +#define _ogg_calloc calloc +#define _ogg_realloc realloc +#define _ogg_free free + +#if defined(_WIN32) + +# if defined(__CYGWIN__) +# include <_G_config.h> + typedef _G_int64_t ogg_int64_t; + typedef _G_int32_t ogg_int32_t; + typedef _G_uint32_t ogg_uint32_t; + typedef _G_int16_t ogg_int16_t; + typedef _G_uint16_t ogg_uint16_t; +# elif defined(__MINGW32__) + typedef short ogg_int16_t; + typedef unsigned short ogg_uint16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + typedef unsigned long long ogg_uint64_t; +# elif defined(__MWERKS__) + typedef long long ogg_int64_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef short ogg_int16_t; + typedef unsigned short ogg_uint16_t; +# else + /* MSVC/Borland */ + typedef __int64 ogg_int64_t; + typedef __int32 ogg_int32_t; + typedef unsigned __int32 ogg_uint32_t; + typedef __int16 ogg_int16_t; + typedef unsigned __int16 ogg_uint16_t; +# endif + +#elif defined(__MACOS__) + +# include + typedef SInt16 ogg_int16_t; + typedef UInt16 ogg_uint16_t; + typedef SInt32 ogg_int32_t; + typedef UInt32 ogg_uint32_t; + typedef SInt64 ogg_int64_t; + +#elif defined(__MACOSX__) /* MacOS X Framework build */ + +# include + typedef int16_t ogg_int16_t; + typedef u_int16_t ogg_uint16_t; + typedef int32_t ogg_int32_t; + typedef u_int32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + +#elif defined(__BEOS__) + + /* Be */ +# include + typedef int16_t ogg_int16_t; + typedef u_int16_t ogg_uint16_t; + typedef int32_t ogg_int32_t; + typedef u_int32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef short ogg_int16_t; + typedef unsigned short ogg_uint16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + +#elif defined (DJGPP) + + /* DJGPP */ + typedef short ogg_int16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + +#elif defined(R5900) + + /* PS2 EE */ + typedef long ogg_int64_t; + typedef int ogg_int32_t; + typedef unsigned ogg_uint32_t; + typedef short ogg_int16_t; + +#elif defined(__SYMBIAN32__) + + /* Symbian GCC */ + typedef signed short ogg_int16_t; + typedef unsigned short ogg_uint16_t; + typedef signed int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long int ogg_int64_t; + +#else + +# include +# include + +#endif + +#endif /* _OS_TYPES_H */ diff --git a/include/ogg/vssver.scc b/include/ogg/vssver.scc new file mode 100755 index 0000000..8eeac4f Binary files /dev/null and b/include/ogg/vssver.scc differ diff --git a/include/opencv/cv.h b/include/opencv/cv.h new file mode 100755 index 0000000..b35724d --- /dev/null +++ b/include/opencv/cv.h @@ -0,0 +1,1208 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + + +#ifndef _CV_H_ +#define _CV_H_ + +#ifdef __IPL_H__ +#define HAVE_IPL +#endif + +#ifndef SKIP_INCLUDES + #if defined(_CH_) + #pragma package + #include + LOAD_CHDL(cv) + #endif +#endif + +#include "cxcore.h" +#include "cvtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Image Processing * +\****************************************************************************************/ + +/* Copies source 2D array inside of the larger destination array and + makes a border of the specified type (IPL_BORDER_*) around the copied area. */ +CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset, + int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0))); + +#define CV_BLUR_NO_SCALE 0 +#define CV_BLUR 1 +#define CV_GAUSSIAN 2 +#define CV_MEDIAN 3 +#define CV_BILATERAL 4 + +/* Smoothes array (removes noise) */ +CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst, + int smoothtype CV_DEFAULT(CV_GAUSSIAN), + int param1 CV_DEFAULT(3), + int param2 CV_DEFAULT(0), + double param3 CV_DEFAULT(0), + double param4 CV_DEFAULT(0)); + +/* Convolves the image with the kernel */ +CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, + CvPoint anchor CV_DEFAULT(cvPoint(-1,-1))); + +/* Finds integral image: SUM(X,Y) = sum(xnext[(edge + (int)type) & 3]; + return (edge & ~3) + ((edge + ((int)type >> 4)) & 3); +} + + +CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge ) +{ + CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); + return (CvSubdiv2DPoint*)e->pt[edge & 3]; +} + + +CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge ) +{ + CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); + return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3]; +} + + +CV_INLINE double cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c ) +{ + return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); +} + + +/****************************************************************************************\ +* Contour Processing and Shape Analysis * +\****************************************************************************************/ + +#define CV_POLY_APPROX_DP 0 + +/* Approximates a single polygonal curve (contour) or + a tree of polygonal curves (contours) */ +CVAPI(CvSeq*) cvApproxPoly( const void* src_seq, + int header_size, CvMemStorage* storage, + int method, double parameter, + int parameter2 CV_DEFAULT(0)); + +#define CV_DOMINANT_IPAN 1 + +/* Finds high-curvature points of the contour */ +CVAPI(CvSeq*) cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage, + int method CV_DEFAULT(CV_DOMINANT_IPAN), + double parameter1 CV_DEFAULT(0), + double parameter2 CV_DEFAULT(0), + double parameter3 CV_DEFAULT(0), + double parameter4 CV_DEFAULT(0)); + +/* Calculates perimeter of a contour or length of a part of contour */ +CVAPI(double) cvArcLength( const void* curve, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ), + int is_closed CV_DEFAULT(-1)); +#define cvContourPerimeter( contour ) cvArcLength( contour, CV_WHOLE_SEQ, 1 ) + +/* Calculates contour boundning rectangle (update=1) or + just retrieves pre-calculated rectangle (update=0) */ +CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) ); + +/* Calculates area of a contour or contour segment */ +CVAPI(double) cvContourArea( const CvArr* contour, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ)); + +/* Finds minimum area rotated rectangle bounding a set of points */ +CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points, + CvMemStorage* storage CV_DEFAULT(NULL)); + +/* Finds minimum enclosing circle for a set of points */ +CVAPI(int) cvMinEnclosingCircle( const CvArr* points, + CvPoint2D32f* center, float* radius ); + +#define CV_CONTOURS_MATCH_I1 1 +#define CV_CONTOURS_MATCH_I2 2 +#define CV_CONTOURS_MATCH_I3 3 + +/* Compares two contours by matching their moments */ +CVAPI(double) cvMatchShapes( const void* object1, const void* object2, + int method, double parameter CV_DEFAULT(0)); + +/* Builds hierarhical representation of a contour */ +CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour, + CvMemStorage* storage, + double threshold ); + +/* Reconstruct (completelly or partially) contour a from contour tree */ +CVAPI(CvSeq*) cvContourFromContourTree( const CvContourTree* tree, + CvMemStorage* storage, + CvTermCriteria criteria ); + +/* Compares two contour trees */ +#define CV_CONTOUR_TREES_MATCH_I1 1 + +CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1, + const CvContourTree* tree2, + int method, double threshold ); + +/* Calculates histogram of a contour */ +CVAPI(void) cvCalcPGH( const CvSeq* contour, CvHistogram* hist ); + +#define CV_CLOCKWISE 1 +#define CV_COUNTER_CLOCKWISE 2 + +/* Calculates exact convex hull of 2d point set */ +CVAPI(CvSeq*) cvConvexHull2( const CvArr* input, + void* hull_storage CV_DEFAULT(NULL), + int orientation CV_DEFAULT(CV_CLOCKWISE), + int return_points CV_DEFAULT(0)); + +/* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */ +CVAPI(int) cvCheckContourConvexity( const CvArr* contour ); + +/* Finds convexity defects for the contour */ +CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull, + CvMemStorage* storage CV_DEFAULT(NULL)); + +/* Fits ellipse into a set of 2d points */ +CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points ); + +/* Finds minimum rectangle containing two given rectangles */ +CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 ); + +/* Finds coordinates of the box vertices */ +CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] ); + +/* Initializes sequence header for a matrix (column or row vector) of points - + a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */ +CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat, + CvContour* contour_header, + CvSeqBlock* block ); + +/* Checks whether the point is inside polygon, outside, on an edge (at a vertex). + Returns positive, negative or zero value, correspondingly. + Optionally, measures a signed distance between + the point and the nearest polygon edge (measure_dist=1) */ +CVAPI(double) cvPointPolygonTest( const CvArr* contour, + CvPoint2D32f pt, int measure_dist ); + +/****************************************************************************************\ +* Histogram functions * +\****************************************************************************************/ + +/* Creates new histogram */ +CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type, + float** ranges CV_DEFAULT(NULL), + int uniform CV_DEFAULT(1)); + +/* Assignes histogram bin ranges */ +CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges, + int uniform CV_DEFAULT(1)); + +/* Creates histogram header for array */ +CVAPI(CvHistogram*) cvMakeHistHeaderForArray( + int dims, int* sizes, CvHistogram* hist, + float* data, float** ranges CV_DEFAULT(NULL), + int uniform CV_DEFAULT(1)); + +/* Releases histogram */ +CVAPI(void) cvReleaseHist( CvHistogram** hist ); + +/* Clears all the histogram bins */ +CVAPI(void) cvClearHist( CvHistogram* hist ); + +/* Finds indices and values of minimum and maximum histogram bins */ +CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist, + float* min_value, float* max_value, + int* min_idx CV_DEFAULT(NULL), + int* max_idx CV_DEFAULT(NULL)); + + +/* Normalizes histogram by dividing all bins by sum of the bins, multiplied by . + After that sum of histogram bins is equal to */ +CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor ); + + +/* Clear all histogram bins that are below the threshold */ +CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold ); + +#define CV_COMP_CORREL 0 +#define CV_COMP_CHISQR 1 +#define CV_COMP_INTERSECT 2 +#define CV_COMP_BHATTACHARYYA 3 + +/* Compares two histogram */ +CVAPI(double) cvCompareHist( const CvHistogram* hist1, + const CvHistogram* hist2, + int method); + +/* Copies one histogram to another. Destination histogram is created if + the destination pointer is NULL */ +CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst ); + + +/* Calculates bayesian probabilistic histograms + (each or src and dst is an array of histograms */ +CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number, + CvHistogram** dst); + +/* Calculates array histogram */ +CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist, + int accumulate CV_DEFAULT(0), + const CvArr* mask CV_DEFAULT(NULL) ); + +CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist, + int accumulate CV_DEFAULT(0), + const CvArr* mask CV_DEFAULT(NULL) ) +{ + cvCalcArrHist( (CvArr**)image, hist, accumulate, mask ); +} + +/* Calculates back project */ +CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst, + const CvHistogram* hist ); +#define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist) + + +/* Does some sort of template matching but compares histograms of + template and each window location */ +CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range, + CvHistogram* hist, int method, + double factor ); +#define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \ + cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor ) + + +/* calculates probabilistic density (divides one histogram by another) */ +CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2, + CvHistogram* dst_hist, double scale CV_DEFAULT(255) ); + +/* equalizes histogram of 8-bit single-channel image */ +CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst ); + + +#define CV_VALUE 1 +#define CV_ARRAY 2 +/* Updates active contour in order to minimize its cummulative + (internal and external) energy. */ +CVAPI(void) cvSnakeImage( const IplImage* image, CvPoint* points, + int length, float* alpha, + float* beta, float* gamma, + int coeff_usage, CvSize win, + CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1)); + +/* Calculates the cooficients of the homography matrix */ +CVAPI(void) cvCalcImageHomography( float* line, CvPoint3D32f* center, + float* intrinsic, float* homography ); + +#define CV_DIST_MASK_3 3 +#define CV_DIST_MASK_5 5 +#define CV_DIST_MASK_PRECISE 0 + +/* Applies distance transform to binary image */ +CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst, + int distance_type CV_DEFAULT(CV_DIST_L2), + int mask_size CV_DEFAULT(3), + const float* mask CV_DEFAULT(NULL), + CvArr* labels CV_DEFAULT(NULL)); + + +/* Types of thresholding */ +#define CV_THRESH_BINARY 0 /* value = value > threshold ? max_value : 0 */ +#define CV_THRESH_BINARY_INV 1 /* value = value > threshold ? 0 : max_value */ +#define CV_THRESH_TRUNC 2 /* value = value > threshold ? threshold : value */ +#define CV_THRESH_TOZERO 3 /* value = value > threshold ? value : 0 */ +#define CV_THRESH_TOZERO_INV 4 /* value = value > threshold ? 0 : value */ +#define CV_THRESH_MASK 7 + +#define CV_THRESH_OTSU 8 /* use Otsu algorithm to choose the optimal threshold value; + combine the flag with one of the above CV_THRESH_* values */ + +/* Applies fixed-level threshold to grayscale image. + This is a basic operation applied before retrieving contours */ +CVAPI(void) cvThreshold( const CvArr* src, CvArr* dst, + double threshold, double max_value, + int threshold_type ); + +#define CV_ADAPTIVE_THRESH_MEAN_C 0 +#define CV_ADAPTIVE_THRESH_GAUSSIAN_C 1 + +/* Applies adaptive threshold to grayscale image. + The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and + CV_ADAPTIVE_THRESH_GAUSSIAN_C are: + neighborhood size (3, 5, 7 etc.), + and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */ +CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value, + int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C), + int threshold_type CV_DEFAULT(CV_THRESH_BINARY), + int block_size CV_DEFAULT(3), + double param1 CV_DEFAULT(5)); + +#define CV_FLOODFILL_FIXED_RANGE (1 << 16) +#define CV_FLOODFILL_MASK_ONLY (1 << 17) + +/* Fills the connected component until the color difference gets large enough */ +CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point, + CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)), + CvScalar up_diff CV_DEFAULT(cvScalarAll(0)), + CvConnectedComp* comp CV_DEFAULT(NULL), + int flags CV_DEFAULT(4), + CvArr* mask CV_DEFAULT(NULL)); + +/****************************************************************************************\ +* Feature detection * +\****************************************************************************************/ + +#define CV_CANNY_L2_GRADIENT (1 << 31) + +/* Runs canny edge detector */ +CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1, + double threshold2, int aperture_size CV_DEFAULT(3) ); + +/* Calculates constraint image for corner detection + Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. + Applying threshold to the result gives coordinates of corners */ +CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners, + int aperture_size CV_DEFAULT(3) ); + +/* Calculates eigen values and vectors of 2x2 + gradient covariation matrix at every image pixel */ +CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at + every image pixel */ +CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/* Harris corner detector: + Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */ +CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_responce, + int block_size, int aperture_size CV_DEFAULT(3), + double k CV_DEFAULT(0.04) ); + +/* Adjust corner position using some sort of gradient search */ +CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, + int count, CvSize win, CvSize zero_zone, + CvTermCriteria criteria ); + +/* Finds a sparse set of points within the selected region + that seem to be easy to track */ +CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, + CvArr* temp_image, CvPoint2D32f* corners, + int* corner_count, double quality_level, + double min_distance, + const CvArr* mask CV_DEFAULT(NULL), + int block_size CV_DEFAULT(3), + int use_harris CV_DEFAULT(0), + double k CV_DEFAULT(0.04) ); + +#define CV_HOUGH_STANDARD 0 +#define CV_HOUGH_PROBABILISTIC 1 +#define CV_HOUGH_MULTI_SCALE 2 +#define CV_HOUGH_GRADIENT 3 + +/* Finds lines on binary image using one of several methods. + line_storage is either memory storage or 1 x CvMat, its + number of columns is changed by the function. + method is one of CV_HOUGH_*; + rho, theta and threshold are used for each of those methods; + param1 ~ line length, param2 ~ line gap - for probabilistic, + param1 ~ srn, param2 ~ stn - for multi-scale */ +CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method, + double rho, double theta, int threshold, + double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0)); + +/* Finds circles in the image */ +CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage, + int method, double dp, double min_dist, + double param1 CV_DEFAULT(100), + double param2 CV_DEFAULT(100), + int min_radius CV_DEFAULT(0), + int max_radius CV_DEFAULT(0)); + +/* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */ +CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, + double reps, double aeps, float* line ); + +/****************************************************************************************\ +* Haar-like Object Detection functions * +\****************************************************************************************/ + +/* Loads haar classifier cascade from a directory. + It is obsolete: convert your cascade to xml and use cvLoad instead */ +CVAPI(CvHaarClassifierCascade*) cvLoadHaarClassifierCascade( + const char* directory, CvSize orig_window_size); + +CVAPI(void) cvReleaseHaarClassifierCascade( CvHaarClassifierCascade** cascade ); + +#define CV_HAAR_DO_CANNY_PRUNING 1 +#define CV_HAAR_SCALE_IMAGE 2 + +CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image, + CvHaarClassifierCascade* cascade, + CvMemStorage* storage, double scale_factor CV_DEFAULT(1.1), + int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0), + CvSize min_size CV_DEFAULT(cvSize(0,0))); + +/* sets images for haar classifier cascade */ +CVAPI(void) cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade, + const CvArr* sum, const CvArr* sqsum, + const CvArr* tilted_sum, double scale ); + +/* runs the cascade on the specified window */ +CVAPI(int) cvRunHaarClassifierCascade( CvHaarClassifierCascade* cascade, + CvPoint pt, int start_stage CV_DEFAULT(0)); + +/****************************************************************************************\ +* Camera Calibration and Rectification functions * +\****************************************************************************************/ + +/* transforms the input image to compensate lens distortion */ +CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst, + const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs ); + +/* computes transformation map from intrinsic camera parameters + that can used by cvRemap */ +CVAPI(void) cvInitUndistortMap( const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs, + CvArr* mapx, CvArr* mapy ); + +/* converts rotation vector to rotation matrix or vice versa */ +CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst, + CvMat* jacobian CV_DEFAULT(0) ); + +/* finds perspective transformation between the object plane and image (view) plane */ +CVAPI(void) cvFindHomography( const CvMat* src_points, + const CvMat* dst_points, + CvMat* homography ); + +/* projects object points to the view plane using + the specified extrinsic and intrinsic camera parameters */ +CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector, + const CvMat* translation_vector, const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs, CvMat* image_points, + CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL), + CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL), + CvMat* dpddist CV_DEFAULT(NULL) ); + +/* finds extrinsic camera parameters from + a few known corresponding point pairs and intrinsic parameters */ +CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points, + const CvMat* image_points, + const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs, + CvMat* rotation_vector, + CvMat* translation_vector ); + +#define CV_CALIB_USE_INTRINSIC_GUESS 1 +#define CV_CALIB_FIX_ASPECT_RATIO 2 +#define CV_CALIB_FIX_PRINCIPAL_POINT 4 +#define CV_CALIB_ZERO_TANGENT_DIST 8 + +/* finds intrinsic and extrinsic camera parameters + from a few views of known calibration pattern */ +CVAPI(void) cvCalibrateCamera2( const CvMat* object_points, + const CvMat* image_points, + const CvMat* point_counts, + CvSize image_size, + CvMat* intrinsic_matrix, + CvMat* distortion_coeffs, + CvMat* rotation_vectors CV_DEFAULT(NULL), + CvMat* translation_vectors CV_DEFAULT(NULL), + int flags CV_DEFAULT(0) ); + +#define CV_CALIB_CB_ADAPTIVE_THRESH 1 +#define CV_CALIB_CB_NORMALIZE_IMAGE 2 +#define CV_CALIB_CB_FILTER_QUADS 4 + +/* Detects corners on a chessboard calibration pattern */ +CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size, + CvPoint2D32f* corners, + int* corner_count CV_DEFAULT(NULL), + int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH) ); + +/* Draws individual chessboard corners or the whole chessboard detected */ +CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size, + CvPoint2D32f* corners, + int count, int pattern_was_found ); + +typedef struct CvPOSITObject CvPOSITObject; + +/* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */ +CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count ); + + +/* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of + an object given its model and projection in a weak-perspective case */ +CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points, + double focal_length, CvTermCriteria criteria, + CvMatr32f rotation_matrix, CvVect32f translation_vector); + +/* Releases CvPOSITObject structure */ +CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object ); + + +/****************************************************************************************\ +* Epipolar Geometry * +\****************************************************************************************/ + +CVAPI(void) cvConvertPointsHomogenious( const CvMat* src, CvMat* dst ); + +/* Calculates fundamental matrix given a set of corresponding points */ +#define CV_FM_7POINT 1 +#define CV_FM_8POINT 2 +#define CV_FM_LMEDS_ONLY 4 +#define CV_FM_RANSAC_ONLY 8 +#define CV_FM_LMEDS (CV_FM_LMEDS_ONLY + CV_FM_8POINT) +#define CV_FM_RANSAC (CV_FM_RANSAC_ONLY + CV_FM_8POINT) +CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2, + CvMat* fundamental_matrix, + int method CV_DEFAULT(CV_FM_RANSAC), + double param1 CV_DEFAULT(1.), double param2 CV_DEFAULT(0.99), + CvMat* status CV_DEFAULT(NULL) ); + +/* For each input point on one of images + computes parameters of the corresponding + epipolar line on the other image */ +CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points, + int which_image, + const CvMat* fundamental_matrix, + CvMat* correspondent_lines ); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +#include "cv.hpp" +#endif + +/****************************************************************************************\ +* Backward compatibility * +\****************************************************************************************/ + +#ifndef CV_NO_BACKWARD_COMPATIBILITY +#include "cvcompat.h" +#endif + +#endif /*_CV_H_*/ diff --git a/include/opencv/cvaux.h b/include/opencv/cvaux.h new file mode 100755 index 0000000..df430e5 --- /dev/null +++ b/include/opencv/cvaux.h @@ -0,0 +1,1464 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __CVAUX__H__ +#define __CVAUX__H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +CVAPI(CvSeq*) cvSegmentImage( const CvArr* srcarr, CvArr* dstarr, + double canny_threshold, + double ffill_threshold, + CvMemStorage* storage ); + +/****************************************************************************************\ +* Eigen objects * +\****************************************************************************************/ + +typedef int (CV_CDECL * CvCallback)(int index, void* buffer, void* user_data); +typedef union +{ + CvCallback callback; + void* data; +} +CvInput; + +#define CV_EIGOBJ_NO_CALLBACK 0 +#define CV_EIGOBJ_INPUT_CALLBACK 1 +#define CV_EIGOBJ_OUTPUT_CALLBACK 2 +#define CV_EIGOBJ_BOTH_CALLBACK 3 + +/* Calculates covariation matrix of a set of arrays */ +CVAPI(void) cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags, + int ioBufSize, uchar* buffer, void* userData, + IplImage* avg, float* covarMatrix ); + +/* Calculates eigen values and vectors of covariation matrix of a set of + arrays */ +CVAPI(void) cvCalcEigenObjects( int nObjects, void* input, void* output, + int ioFlags, int ioBufSize, void* userData, + CvTermCriteria* calcLimit, IplImage* avg, + float* eigVals ); + +/* Calculates dot product (obj - avg) * eigObj (i.e. projects image to eigen vector) */ +CVAPI(double) cvCalcDecompCoeff( IplImage* obj, IplImage* eigObj, IplImage* avg ); + +/* Projects image to eigen space (finds all decomposion coefficients */ +CVAPI(void) cvEigenDecomposite( IplImage* obj, int nEigObjs, void* eigInput, + int ioFlags, void* userData, IplImage* avg, + float* coeffs ); + +/* Projects original objects used to calculate eigen space basis to that space */ +CVAPI(void) cvEigenProjection( void* eigInput, int nEigObjs, int ioFlags, + void* userData, float* coeffs, IplImage* avg, + IplImage* proj ); + +/****************************************************************************************\ +* 1D/2D HMM * +\****************************************************************************************/ + +typedef struct CvImgObsInfo +{ + int obs_x; + int obs_y; + int obs_size; + float* obs;//consequtive observations + + int* state;/* arr of pairs superstate/state to which observation belong */ + int* mix; /* number of mixture to which observation belong */ + +} +CvImgObsInfo;/*struct for 1 image*/ + +typedef CvImgObsInfo Cv1DObsInfo; + +typedef struct CvEHMMState +{ + int num_mix; /*number of mixtures in this state*/ + float* mu; /*mean vectors corresponding to each mixture*/ + float* inv_var; /* square root of inversed variances corresp. to each mixture*/ + float* log_var_val; /* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n */ + float* weight; /*array of mixture weights. Summ of all weights in state is 1. */ + +} +CvEHMMState; + +typedef struct CvEHMM +{ + int level; /* 0 - lowest(i.e its states are real states), ..... */ + int num_states; /* number of HMM states */ + float* transP;/*transition probab. matrices for states */ + float** obsProb; /* if level == 0 - array of brob matrices corresponding to hmm + if level == 1 - martix of matrices */ + union + { + CvEHMMState* state; /* if level == 0 points to real states array, + if not - points to embedded hmms */ + struct CvEHMM* ehmm; /* pointer to an embedded model or NULL, if it is a leaf */ + } u; + +} +CvEHMM; + +/*CVAPI(int) icvCreate1DHMM( CvEHMM** this_hmm, + int state_number, int* num_mix, int obs_size ); + +CVAPI(int) icvRelease1DHMM( CvEHMM** phmm ); + +CVAPI(int) icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm ); + +CVAPI(int) icvInit1DMixSegm( Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm); + +CVAPI(int) icvEstimate1DHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm); + +CVAPI(int) icvEstimate1DObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm ); + +CVAPI(int) icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array, + int num_seq, + CvEHMM* hmm ); + +CVAPI(float) icvViterbi( Cv1DObsInfo* obs_info, CvEHMM* hmm); + +CVAPI(int) icv1DMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm );*/ + +/*********************************** Embedded HMMs *************************************/ + +/* Creates 2D HMM */ +CVAPI(CvEHMM*) cvCreate2DHMM( int* stateNumber, int* numMix, int obsSize ); + +/* Releases HMM */ +CVAPI(void) cvRelease2DHMM( CvEHMM** hmm ); + +#define CV_COUNT_OBS(roi, win, delta, numObs ) \ +{ \ + (numObs)->width =((roi)->width -(win)->width +(delta)->width)/(delta)->width; \ + (numObs)->height =((roi)->height -(win)->height +(delta)->height)/(delta)->height;\ +} + +/* Creates storage for observation vectors */ +CVAPI(CvImgObsInfo*) cvCreateObsInfo( CvSize numObs, int obsSize ); + +/* Releases storage for observation vectors */ +CVAPI(void) cvReleaseObsInfo( CvImgObsInfo** obs_info ); + + +/* The function takes an image on input and and returns the sequnce of observations + to be used with an embedded HMM; Each observation is top-left block of DCT + coefficient matrix */ +CVAPI(void) cvImgToObs_DCT( const CvArr* arr, float* obs, CvSize dctSize, + CvSize obsSize, CvSize delta ); + + +/* Uniformly segments all observation vectors extracted from image */ +CVAPI(void) cvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* ehmm ); + +/* Does mixture segmentation of the states of embedded HMM */ +CVAPI(void) cvInitMixSegm( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/* Function calculates means, variances, weights of every Gaussian mixture + of every low-level state of embedded HMM */ +CVAPI(void) cvEstimateHMMStateParams( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/* Function computes transition probability matrices of embedded HMM + given observations segmentation */ +CVAPI(void) cvEstimateTransProb( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/* Function computes probabilities of appearing observations at any state + (i.e. computes P(obs|state) for every pair(obs,state)) */ +CVAPI(void) cvEstimateObsProb( CvImgObsInfo* obs_info, + CvEHMM* hmm ); + +/* Runs Viterbi algorithm for embedded HMM */ +CVAPI(float) cvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm ); + + +/* Function clusters observation vectors from several images + given observations segmentation. + Euclidean distance used for clustering vectors. + Centers of clusters are given means of every mixture */ +CVAPI(void) cvMixSegmL2( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/****************************************************************************************\ +* A few functions from old stereo gesture recognition demosions * +\****************************************************************************************/ + +/* Creates hand mask image given several points on the hand */ +CVAPI(void) cvCreateHandMask( CvSeq* hand_points, + IplImage *img_mask, CvRect *roi); + +/* Finds hand region in range image data */ +CVAPI(void) cvFindHandRegion (CvPoint3D32f* points, int count, + CvSeq* indexs, + float* line, CvSize2D32f size, int flag, + CvPoint3D32f* center, + CvMemStorage* storage, CvSeq **numbers); + +/* Finds hand region in range image data (advanced version) */ +CVAPI(void) cvFindHandRegionA( CvPoint3D32f* points, int count, + CvSeq* indexs, + float* line, CvSize2D32f size, int jc, + CvPoint3D32f* center, + CvMemStorage* storage, CvSeq **numbers); + +/****************************************************************************************\ +* Additional operations on Subdivisions * +\****************************************************************************************/ + +// paints voronoi diagram: just demo function +CVAPI(void) icvDrawMosaic( CvSubdiv2D* subdiv, IplImage* src, IplImage* dst ); + +// checks planar subdivision for correctness. It is not an absolute check, +// but it verifies some relations between quad-edges +CVAPI(int) icvSubdiv2DCheck( CvSubdiv2D* subdiv ); + +// returns squared distance between two 2D points with floating-point coordinates. +CV_INLINE double icvSqDist2D32f( CvPoint2D32f pt1, CvPoint2D32f pt2 ) +{ + double dx = pt1.x - pt2.x; + double dy = pt1.y - pt2.y; + + return dx*dx + dy*dy; +} + + +/****************************************************************************************\ +* More operations on sequences * +\****************************************************************************************/ + +/*****************************************************************************************/ + +#define CV_CURRENT_INT( reader ) (*((int *)(reader).ptr)) +#define CV_PREV_INT( reader ) (*((int *)(reader).prev_elem)) + +#define CV_GRAPH_WEIGHTED_VERTEX_FIELDS() CV_GRAPH_VERTEX_FIELDS()\ + float weight; + +#define CV_GRAPH_WEIGHTED_EDGE_FIELDS() CV_GRAPH_EDGE_FIELDS() + +typedef struct CvGraphWeightedVtx +{ + CV_GRAPH_WEIGHTED_VERTEX_FIELDS() +} +CvGraphWeightedVtx; + +typedef struct CvGraphWeightedEdge +{ + CV_GRAPH_WEIGHTED_EDGE_FIELDS() +} +CvGraphWeightedEdge; + +typedef enum CvGraphWeightType +{ + CV_NOT_WEIGHTED, + CV_WEIGHTED_VTX, + CV_WEIGHTED_EDGE, + CV_WEIGHTED_ALL +} CvGraphWeightType; + + +/*****************************************************************************************/ + + +/*******************************Stereo correspondence*************************************/ + +typedef struct CvCliqueFinder +{ + CvGraph* graph; + int** adj_matr; + int N; //graph size + + // stacks, counters etc/ + int k; //stack size + int* current_comp; + int** All; + + int* ne; + int* ce; + int* fixp; //node with minimal disconnections + int* nod; + int* s; //for selected candidate + int status; + int best_score; + int weighted; + int weighted_edges; + float best_weight; + float* edge_weights; + float* vertex_weights; + float* cur_weight; + float* cand_weight; + +} CvCliqueFinder; + +#define CLIQUE_TIME_OFF 2 +#define CLIQUE_FOUND 1 +#define CLIQUE_END 0 + +/*CVAPI(void) cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse, + int weighted CV_DEFAULT(0), int weighted_edges CV_DEFAULT(0)); +CVAPI(int) cvFindNextMaximalClique( CvCliqueFinder* finder, int* clock_rest CV_DEFAULT(0) ); +CVAPI(void) cvEndFindCliques( CvCliqueFinder* finder ); + +CVAPI(void) cvBronKerbosch( CvGraph* graph );*/ + + +/*F/////////////////////////////////////////////////////////////////////////////////////// +// +// Name: cvSubgraphWeight +// Purpose: finds weight of subgraph in a graph +// Context: +// Parameters: +// graph - input graph. +// subgraph - sequence of pairwise different ints. These are indices of vertices of subgraph. +// weight_type - describes the way we measure weight. +// one of the following: +// CV_NOT_WEIGHTED - weight of a clique is simply its size +// CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices +// CV_WEIGHTED_EDGE - the same but edges +// CV_WEIGHTED_ALL - the same but both edges and vertices +// weight_vtx - optional vector of floats, with size = graph->total. +// If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL +// weights of vertices must be provided. If weight_vtx not zero +// these weights considered to be here, otherwise function assumes +// that vertices of graph are inherited from CvGraphWeightedVtx. +// weight_edge - optional matrix of floats, of width and height = graph->total. +// If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL +// weights of edges ought to be supplied. If weight_edge is not zero +// function finds them here, otherwise function expects +// edges of graph to be inherited from CvGraphWeightedEdge. +// If this parameter is not zero structure of the graph is determined from matrix +// rather than from CvGraphEdge's. In particular, elements corresponding to +// absent edges should be zero. +// Returns: +// weight of subgraph. +// Notes: +//F*/ +/*CVAPI(float) cvSubgraphWeight( CvGraph *graph, CvSeq *subgraph, + CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), + CvVect32f weight_vtx CV_DEFAULT(0), + CvMatr32f weight_edge CV_DEFAULT(0) );*/ + + +/*F/////////////////////////////////////////////////////////////////////////////////////// +// +// Name: cvFindCliqueEx +// Purpose: tries to find clique with maximum possible weight in a graph +// Context: +// Parameters: +// graph - input graph. +// storage - memory storage to be used by the result. +// is_complementary - optional flag showing whether function should seek for clique +// in complementary graph. +// weight_type - describes our notion about weight. +// one of the following: +// CV_NOT_WEIGHTED - weight of a clique is simply its size +// CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices +// CV_WEIGHTED_EDGE - the same but edges +// CV_WEIGHTED_ALL - the same but both edges and vertices +// weight_vtx - optional vector of floats, with size = graph->total. +// If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL +// weights of vertices must be provided. If weight_vtx not zero +// these weights considered to be here, otherwise function assumes +// that vertices of graph are inherited from CvGraphWeightedVtx. +// weight_edge - optional matrix of floats, of width and height = graph->total. +// If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL +// weights of edges ought to be supplied. If weight_edge is not zero +// function finds them here, otherwise function expects +// edges of graph to be inherited from CvGraphWeightedEdge. +// Note that in case of CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL +// nonzero is_complementary implies nonzero weight_edge. +// start_clique - optional sequence of pairwise different ints. They are indices of +// vertices that shall be present in the output clique. +// subgraph_of_ban - optional sequence of (maybe equal) ints. They are indices of +// vertices that shall not be present in the output clique. +// clique_weight_ptr - optional output parameter. Weight of found clique stored here. +// num_generations - optional number of generations in evolutionary part of algorithm, +// zero forces to return first found clique. +// quality - optional parameter determining degree of required quality/speed tradeoff. +// Must be in the range from 0 to 9. +// 0 is fast and dirty, 9 is slow but hopefully yields good clique. +// Returns: +// sequence of pairwise different ints. +// These are indices of vertices that form found clique. +// Notes: +// in cases of CV_WEIGHTED_EDGE and CV_WEIGHTED_ALL weights should be nonnegative. +// start_clique has a priority over subgraph_of_ban. +//F*/ +/*CVAPI(CvSeq*) cvFindCliqueEx( CvGraph *graph, CvMemStorage *storage, + int is_complementary CV_DEFAULT(0), + CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), + CvVect32f weight_vtx CV_DEFAULT(0), + CvMatr32f weight_edge CV_DEFAULT(0), + CvSeq *start_clique CV_DEFAULT(0), + CvSeq *subgraph_of_ban CV_DEFAULT(0), + float *clique_weight_ptr CV_DEFAULT(0), + int num_generations CV_DEFAULT(3), + int quality CV_DEFAULT(2) );*/ + + +#define CV_UNDEF_SC_PARAM 12345 //default value of parameters + +#define CV_IDP_BIRCHFIELD_PARAM1 25 +#define CV_IDP_BIRCHFIELD_PARAM2 5 +#define CV_IDP_BIRCHFIELD_PARAM3 12 +#define CV_IDP_BIRCHFIELD_PARAM4 15 +#define CV_IDP_BIRCHFIELD_PARAM5 25 + + +#define CV_DISPARITY_BIRCHFIELD 0 + + +/*F/////////////////////////////////////////////////////////////////////////// +// +// Name: cvFindStereoCorrespondence +// Purpose: find stereo correspondence on stereo-pair +// Context: +// Parameters: +// leftImage - left image of stereo-pair (format 8uC1). +// rightImage - right image of stereo-pair (format 8uC1). +// mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only) +// dispImage - destination disparity image +// maxDisparity - maximal disparity +// param1, param2, param3, param4, param5 - parameters of algorithm +// Returns: +// Notes: +// Images must be rectified. +// All images must have format 8uC1. +//F*/ +CVAPI(void) +cvFindStereoCorrespondence( + const CvArr* leftImage, const CvArr* rightImage, + int mode, + CvArr* dispImage, + int maxDisparity, + double param1 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param2 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param3 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param4 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param5 CV_DEFAULT(CV_UNDEF_SC_PARAM) ); + +/*****************************************************************************************/ +/************ Epiline functions *******************/ + + + +typedef struct CvStereoLineCoeff +{ + double Xcoef; + double XcoefA; + double XcoefB; + double XcoefAB; + + double Ycoef; + double YcoefA; + double YcoefB; + double YcoefAB; + + double Zcoef; + double ZcoefA; + double ZcoefB; + double ZcoefAB; +}CvStereoLineCoeff; + + +typedef struct CvCamera +{ + float imgSize[2]; /* size of the camera view, used during calibration */ + float matrix[9]; /* intinsic camera parameters: [ fx 0 cx; 0 fy cy; 0 0 1 ] */ + float distortion[4]; /* distortion coefficients - two coefficients for radial distortion + and another two for tangential: [ k1 k2 p1 p2 ] */ + float rotMatr[9]; + float transVect[3]; /* rotation matrix and transition vector relatively + to some reference point in the space. */ +} +CvCamera; + +typedef struct CvStereoCamera +{ + CvCamera* camera[2]; /* two individual camera parameters */ + float fundMatr[9]; /* fundamental matrix */ + + /* New part for stereo */ + CvPoint3D32f epipole[2]; + CvPoint2D32f quad[2][4]; /* coordinates of destination quadrangle after + epipolar geometry rectification */ + double coeffs[2][3][3];/* coefficients for transformation */ + CvPoint2D32f border[2][4]; + CvSize warpSize; + CvStereoLineCoeff* lineCoeffs; + int needSwapCameras;/* flag set to 1 if need to swap cameras for good reconstruction */ + float rotMatrix[9]; + float transVector[3]; +} +CvStereoCamera; + + +typedef struct CvContourOrientation +{ + float egvals[2]; + float egvects[4]; + + float max, min; // minimum and maximum projections + int imax, imin; +} CvContourOrientation; + +#define CV_CAMERA_TO_WARP 1 +#define CV_WARP_TO_CAMERA 2 + +CVAPI(int) icvConvertWarpCoordinates(double coeffs[3][3], + CvPoint2D32f* cameraPoint, + CvPoint2D32f* warpPoint, + int direction); + +CVAPI(int) icvGetSymPoint3D( CvPoint3D64d pointCorner, + CvPoint3D64d point1, + CvPoint3D64d point2, + CvPoint3D64d *pointSym2); + +CVAPI(void) icvGetPieceLength3D(CvPoint3D64d point1,CvPoint3D64d point2,double* dist); + +CVAPI(int) icvCompute3DPoint( double alpha,double betta, + CvStereoLineCoeff* coeffs, + CvPoint3D64d* point); + +CVAPI(int) icvCreateConvertMatrVect( CvMatr64d rotMatr1, + CvMatr64d transVect1, + CvMatr64d rotMatr2, + CvMatr64d transVect2, + CvMatr64d convRotMatr, + CvMatr64d convTransVect); + +CVAPI(int) icvConvertPointSystem(CvPoint3D64d M2, + CvPoint3D64d* M1, + CvMatr64d rotMatr, + CvMatr64d transVect + ); + +CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera); + +CVAPI(int) icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross); +CVAPI(int) icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross); +CVAPI(float) icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point); +CVAPI(int) icvStereoCalibration( int numImages, + int* nums, + CvSize imageSize, + CvPoint2D32f* imagePoints1, + CvPoint2D32f* imagePoints2, + CvPoint3D32f* objectPoints, + CvStereoCamera* stereoparams + ); + + +CVAPI(int) icvComputeRestStereoParams(CvStereoCamera *stereoparams); + +CVAPI(void) cvComputePerspectiveMap( const double coeffs[3][3], CvArr* rectMapX, CvArr* rectMapY ); + +CVAPI(int) icvComCoeffForLine( CvPoint2D64d point1, + CvPoint2D64d point2, + CvPoint2D64d point3, + CvPoint2D64d point4, + CvMatr64d camMatr1, + CvMatr64d rotMatr1, + CvMatr64d transVect1, + CvMatr64d camMatr2, + CvMatr64d rotMatr2, + CvMatr64d transVect2, + CvStereoLineCoeff* coeffs, + int* needSwapCameras); + +CVAPI(int) icvGetDirectionForPoint( CvPoint2D64d point, + CvMatr64d camMatr, + CvPoint3D64d* direct); + +CVAPI(int) icvGetCrossLines(CvPoint3D64d point11,CvPoint3D64d point12, + CvPoint3D64d point21,CvPoint3D64d point22, + CvPoint3D64d* midPoint); + +CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64d pointA, + CvPoint3D64d pointB, + CvPoint3D64d pointCam1, + double gamma, + CvStereoLineCoeff* coeffs); + +/*CVAPI(int) icvComputeFundMatrEpipoles ( CvMatr64d camMatr1, + CvMatr64d rotMatr1, + CvVect64d transVect1, + CvMatr64d camMatr2, + CvMatr64d rotMatr2, + CvVect64d transVect2, + CvPoint2D64d* epipole1, + CvPoint2D64d* epipole2, + CvMatr64d fundMatr);*/ + +CVAPI(int) icvGetAngleLine( CvPoint2D64d startPoint, CvSize imageSize,CvPoint2D64d *point1,CvPoint2D64d *point2); + +CVAPI(void) icvGetCoefForPiece( CvPoint2D64d p_start,CvPoint2D64d p_end, + double *a,double *b,double *c, + int* result); + +/*CVAPI(void) icvGetCommonArea( CvSize imageSize, + CvPoint2D64d epipole1,CvPoint2D64d epipole2, + CvMatr64d fundMatr, + CvVect64d coeff11,CvVect64d coeff12, + CvVect64d coeff21,CvVect64d coeff22, + int* result);*/ + +CVAPI(void) icvComputeeInfiniteProject1(CvMatr64d rotMatr, + CvMatr64d camMatr1, + CvMatr64d camMatr2, + CvPoint2D32f point1, + CvPoint2D32f *point2); + +CVAPI(void) icvComputeeInfiniteProject2(CvMatr64d rotMatr, + CvMatr64d camMatr1, + CvMatr64d camMatr2, + CvPoint2D32f* point1, + CvPoint2D32f point2); + +CVAPI(void) icvGetCrossDirectDirect( CvVect64d direct1,CvVect64d direct2, + CvPoint2D64d *cross,int* result); + +CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64d p_start,CvPoint2D64d p_end, + double a,double b,double c, + CvPoint2D64d *cross,int* result); + +CVAPI(void) icvGetCrossPiecePiece( CvPoint2D64d p1_start,CvPoint2D64d p1_end, + CvPoint2D64d p2_start,CvPoint2D64d p2_end, + CvPoint2D64d* cross, + int* result); + +CVAPI(void) icvGetPieceLength(CvPoint2D64d point1,CvPoint2D64d point2,double* dist); + +CVAPI(void) icvGetCrossRectDirect( CvSize imageSize, + double a,double b,double c, + CvPoint2D64d *start,CvPoint2D64d *end, + int* result); + +CVAPI(void) icvProjectPointToImage( CvPoint3D64d point, + CvMatr64d camMatr,CvMatr64d rotMatr,CvVect64d transVect, + CvPoint2D64d* projPoint); + +CVAPI(void) icvGetQuadsTransform( CvSize imageSize, + CvMatr64d camMatr1, + CvMatr64d rotMatr1, + CvVect64d transVect1, + CvMatr64d camMatr2, + CvMatr64d rotMatr2, + CvVect64d transVect2, + CvSize* warpSize, + double quad1[4][2], + double quad2[4][2], + CvMatr64d fundMatr, + CvPoint3D64d* epipole1, + CvPoint3D64d* epipole2 + ); + +CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera); + +CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera); + +CVAPI(void) icvGetCutPiece( CvVect64d areaLineCoef1,CvVect64d areaLineCoef2, + CvPoint2D64d epipole, + CvSize imageSize, + CvPoint2D64d* point11,CvPoint2D64d* point12, + CvPoint2D64d* point21,CvPoint2D64d* point22, + int* result); + +CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64d basePoint, + CvPoint2D64d point1,CvPoint2D64d point2, + CvPoint2D64d* midPoint); + +CVAPI(void) icvGetNormalDirect(CvVect64d direct,CvPoint2D64d point,CvVect64d normDirect); + +CVAPI(double) icvGetVect(CvPoint2D64d basePoint,CvPoint2D64d point1,CvPoint2D64d point2); + +CVAPI(void) icvProjectPointToDirect( CvPoint2D64d point,CvVect64d lineCoeff, + CvPoint2D64d* projectPoint); + +CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64d point,CvVect64d lineCoef,double*dist); + +CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst, + int desired_depth, int desired_num_channels ); + +CVAPI(void) cvDeInterlace( const CvArr* frame, CvArr* fieldEven, CvArr* fieldOdd ); + +/*CVAPI(int) icvSelectBestRt( int numImages, + int* numPoints, + CvSize imageSize, + CvPoint2D32f* imagePoints1, + CvPoint2D32f* imagePoints2, + CvPoint3D32f* objectPoints, + + CvMatr32f cameraMatrix1, + CvVect32f distortion1, + CvMatr32f rotMatrs1, + CvVect32f transVects1, + + CvMatr32f cameraMatrix2, + CvVect32f distortion2, + CvMatr32f rotMatrs2, + CvVect32f transVects2, + + CvMatr32f bestRotMatr, + CvVect32f bestTransVect + );*/ + +/****************************************************************************************\ +* Contour Morphing * +\****************************************************************************************/ + +/* finds correspondence between two contours */ +CvSeq* cvCalcContoursCorrespondence( const CvSeq* contour1, + const CvSeq* contour2, + CvMemStorage* storage); + +/* morphs contours using the pre-calculated correspondence: + alpha=0 ~ contour1, alpha=1 ~ contour2 */ +CvSeq* cvMorphContours( const CvSeq* contour1, const CvSeq* contour2, + CvSeq* corr, double alpha, + CvMemStorage* storage ); + +/****************************************************************************************\ +* Texture Descriptors * +\****************************************************************************************/ + +#define CV_GLCM_OPTIMIZATION_NONE -2 +#define CV_GLCM_OPTIMIZATION_LUT -1 +#define CV_GLCM_OPTIMIZATION_HISTOGRAM 0 + +#define CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST 10 +#define CV_GLCMDESC_OPTIMIZATION_ALLOWTRIPLENEST 11 +#define CV_GLCMDESC_OPTIMIZATION_HISTOGRAM 4 + +#define CV_GLCMDESC_ENTROPY 0 +#define CV_GLCMDESC_ENERGY 1 +#define CV_GLCMDESC_HOMOGENITY 2 +#define CV_GLCMDESC_CONTRAST 3 +#define CV_GLCMDESC_CLUSTERTENDENCY 4 +#define CV_GLCMDESC_CLUSTERSHADE 5 +#define CV_GLCMDESC_CORRELATION 6 +#define CV_GLCMDESC_CORRELATIONINFO1 7 +#define CV_GLCMDESC_CORRELATIONINFO2 8 +#define CV_GLCMDESC_MAXIMUMPROBABILITY 9 + +#define CV_GLCM_ALL 0 +#define CV_GLCM_GLCM 1 +#define CV_GLCM_DESC 2 + +typedef struct CvGLCM CvGLCM; + +CVAPI(CvGLCM*) cvCreateGLCM( const IplImage* srcImage, + int stepMagnitude, + const int* stepDirections CV_DEFAULT(0), + int numStepDirections CV_DEFAULT(0), + int optimizationType CV_DEFAULT(CV_GLCM_OPTIMIZATION_NONE)); + +CVAPI(void) cvReleaseGLCM( CvGLCM** GLCM, int flag CV_DEFAULT(CV_GLCM_ALL)); + +CVAPI(void) cvCreateGLCMDescriptors( CvGLCM* destGLCM, + int descriptorOptimizationType + CV_DEFAULT(CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST)); + +CVAPI(double) cvGetGLCMDescriptor( CvGLCM* GLCM, int step, int descriptor ); + +CVAPI(void) cvGetGLCMDescriptorStatistics( CvGLCM* GLCM, int descriptor, + double* average, double* standardDeviation ); + +CVAPI(IplImage*) cvCreateGLCMImage( CvGLCM* GLCM, int step ); + +/****************************************************************************************\ +* Face eyes&mouth tracking * +\****************************************************************************************/ + + +typedef struct CvFaceTracker CvFaceTracker; + +#define CV_NUM_FACE_ELEMENTS 3 +enum CV_FACE_ELEMENTS +{ + CV_FACE_MOUTH = 0, + CV_FACE_LEFT_EYE = 1, + CV_FACE_RIGHT_EYE = 2 +}; + +CVAPI(CvFaceTracker*) cvInitFaceTracker(CvFaceTracker* pFaceTracking, const IplImage* imgGray, + CvRect* pRects, int nRects); +CVAPI(int) cvTrackFace( CvFaceTracker* pFaceTracker, IplImage* imgGray, + CvRect* pRects, int nRects, + CvPoint* ptRotate, double* dbAngleRotate); +CVAPI(void) cvReleaseFaceTracker(CvFaceTracker** ppFaceTracker); + + +typedef struct CvFace +{ + CvRect MouthRect; + CvRect LeftEyeRect; + CvRect RightEyeRect; +} CvFaceData; + +CvSeq * cvFindFace(IplImage * Image,CvMemStorage* storage); +CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage); + + +/****************************************************************************************\ +* 3D Tracker * +\****************************************************************************************/ + +typedef unsigned char CvBool; + +typedef struct +{ + int id; + CvPoint2D32f p; // pgruebele: So we do not loose precision, this needs to be float +} Cv3dTracker2dTrackedObject; + +CV_INLINE Cv3dTracker2dTrackedObject cv3dTracker2dTrackedObject(int id, CvPoint2D32f p) +{ + Cv3dTracker2dTrackedObject r; + r.id = id; + r.p = p; + return r; +} + +typedef struct +{ + int id; + CvPoint3D32f p; // location of the tracked object +} Cv3dTrackerTrackedObject; + +CV_INLINE Cv3dTrackerTrackedObject cv3dTrackerTrackedObject(int id, CvPoint3D32f p) +{ + Cv3dTrackerTrackedObject r; + r.id = id; + r.p = p; + return r; +} + +typedef struct +{ + CvBool valid; + float mat[4][4]; /* maps camera coordinates to world coordinates */ + CvPoint2D32f principal_point; /* copied from intrinsics so this structure */ + /* has all the info we need */ +} Cv3dTrackerCameraInfo; + +typedef struct +{ + CvPoint2D32f principal_point; + float focal_length[2]; + float distortion[4]; +} Cv3dTrackerCameraIntrinsics; + +CVAPI(CvBool) cv3dTrackerCalibrateCameras(int num_cameras, + const Cv3dTrackerCameraIntrinsics camera_intrinsics[], /* size is num_cameras */ + CvSize etalon_size, + float square_size, + IplImage *samples[], /* size is num_cameras */ + Cv3dTrackerCameraInfo camera_info[]); /* size is num_cameras */ + +CVAPI(int) cv3dTrackerLocateObjects(int num_cameras, int num_objects, + const Cv3dTrackerCameraInfo camera_info[], /* size is num_cameras */ + const Cv3dTracker2dTrackedObject tracking_info[], /* size is num_objects*num_cameras */ + Cv3dTrackerTrackedObject tracked_objects[]); /* size is num_objects */ +/**************************************************************************************** + tracking_info is a rectangular array; one row per camera, num_objects elements per row. + The id field of any unused slots must be -1. Ids need not be ordered or consecutive. On + completion, the return value is the number of objects located; i.e., the number of objects + visible by more than one camera. The id field of any unused slots in tracked objects is + set to -1. +****************************************************************************************/ + + +/****************************************************************************************\ +* Skeletons and Linear-Contour Models * +\****************************************************************************************/ + +typedef enum CvLeeParameters +{ + CV_LEE_INT = 0, + CV_LEE_FLOAT = 1, + CV_LEE_DOUBLE = 2, + CV_LEE_AUTO = -1, + CV_LEE_ERODE = 0, + CV_LEE_ZOOM = 1, + CV_LEE_NON = 2 +} CvLeeParameters; + +#define CV_NEXT_VORONOISITE2D( SITE ) ((SITE)->edge[0]->site[((SITE)->edge[0]->site[0] == (SITE))]) +#define CV_PREV_VORONOISITE2D( SITE ) ((SITE)->edge[1]->site[((SITE)->edge[1]->site[0] == (SITE))]) +#define CV_FIRST_VORONOIEDGE2D( SITE ) ((SITE)->edge[0]) +#define CV_LAST_VORONOIEDGE2D( SITE ) ((SITE)->edge[1]) +#define CV_NEXT_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[(EDGE)->site[0] != (SITE)]) +#define CV_PREV_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[2 + ((EDGE)->site[0] != (SITE))]) +#define CV_VORONOIEDGE2D_BEGINNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] != (SITE))]) +#define CV_VORONOIEDGE2D_ENDNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] == (SITE))]) +#define CV_TWIN_VORONOISITE2D( SITE, EDGE ) ( (EDGE)->site[((EDGE)->site[0] == (SITE))]) + +#define CV_VORONOISITE2D_FIELDS() \ + struct CvVoronoiNode2D *node[2]; \ + struct CvVoronoiEdge2D *edge[2]; + +typedef struct CvVoronoiSite2D +{ + CV_VORONOISITE2D_FIELDS() + struct CvVoronoiSite2D *next[2]; +} CvVoronoiSite2D; + +#define CV_VORONOIEDGE2D_FIELDS() \ + struct CvVoronoiNode2D *node[2]; \ + struct CvVoronoiSite2D *site[2]; \ + struct CvVoronoiEdge2D *next[4]; + +typedef struct CvVoronoiEdge2D +{ + CV_VORONOIEDGE2D_FIELDS() +} CvVoronoiEdge2D; + +#define CV_VORONOINODE2D_FIELDS() \ + CV_SET_ELEM_FIELDS(CvVoronoiNode2D) \ + CvPoint2D32f pt; \ + float radius; + +typedef struct CvVoronoiNode2D +{ + CV_VORONOINODE2D_FIELDS() +} CvVoronoiNode2D; + +#define CV_VORONOIDIAGRAM2D_FIELDS() \ + CV_GRAPH_FIELDS() \ + CvSet *sites; + +typedef struct CvVoronoiDiagram2D +{ + CV_VORONOIDIAGRAM2D_FIELDS() +} CvVoronoiDiagram2D; + +/* Computes Voronoi Diagram for given polygons with holes */ +CVAPI(int) cvVoronoiDiagramFromContour(CvSeq* ContourSeq, + CvVoronoiDiagram2D** VoronoiDiagram, + CvMemStorage* VoronoiStorage, + CvLeeParameters contour_type CV_DEFAULT(CV_LEE_INT), + int contour_orientation CV_DEFAULT(-1), + int attempt_number CV_DEFAULT(10)); + +/* Computes Voronoi Diagram for domains in given image */ +CVAPI(int) cvVoronoiDiagramFromImage(IplImage* pImage, + CvSeq** ContourSeq, + CvVoronoiDiagram2D** VoronoiDiagram, + CvMemStorage* VoronoiStorage, + CvLeeParameters regularization_method CV_DEFAULT(CV_LEE_NON), + float approx_precision CV_DEFAULT(CV_LEE_AUTO)); + +/* Deallocates the storage */ +CVAPI(void) cvReleaseVoronoiStorage(CvVoronoiDiagram2D* VoronoiDiagram, + CvMemStorage** pVoronoiStorage); + +/*********************** Linear-Contour Model ****************************/ + +struct CvLCMEdge; +struct CvLCMNode; + +typedef struct CvLCMEdge +{ + CV_GRAPH_EDGE_FIELDS() + CvSeq* chain; + float width; + int index1; + int index2; +} CvLCMEdge; + +typedef struct CvLCMNode +{ + CV_GRAPH_VERTEX_FIELDS() + CvContour* contour; +} CvLCMNode; + + +/* Computes hybrid model from Voronoi Diagram */ +CVAPI(CvGraph*) cvLinearContorModelFromVoronoiDiagram(CvVoronoiDiagram2D* VoronoiDiagram, + float maxWidth); + +/* Releases hybrid model storage */ +CVAPI(int) cvReleaseLinearContorModelStorage(CvGraph** Graph); + + +/* two stereo-related functions */ + +CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4], double matrix[3][3], + CvArr* rectMap ); + +/*CVAPI(void) cvInitStereoRectification( CvStereoCamera* params, + CvArr* rectMap1, CvArr* rectMap2, + int do_undistortion );*/ + +/*************************** View Morphing Functions ************************/ + +/* The order of the function corresponds to the order they should appear in + the view morphing pipeline */ + +/* Finds ending points of scanlines on left and right images of stereo-pair */ +CVAPI(void) cvMakeScanlines( const CvMatrix3* matrix, CvSize img_size, + int* scanlines1, int* scanlines2, + int* lengths1, int* lengths2, + int* line_count ); + +/* Grab pixel values from scanlines and stores them sequentially + (some sort of perspective image transform) */ +CVAPI(void) cvPreWarpImage( int line_count, + IplImage* img, + uchar* dst, + int* dst_nums, + int* scanlines); + +/* Approximate each grabbed scanline by a sequence of runs + (lossy run-length compression) */ +CVAPI(void) cvFindRuns( int line_count, + uchar* prewarp1, + uchar* prewarp2, + int* line_lengths1, + int* line_lengths2, + int* runs1, + int* runs2, + int* num_runs1, + int* num_runs2); + +/* Compares two sets of compressed scanlines */ +CVAPI(void) cvDynamicCorrespondMulti( int line_count, + int* first, + int* first_runs, + int* second, + int* second_runs, + int* first_corr, + int* second_corr); + +/* Finds scanline ending coordinates for some intermediate "virtual" camera position */ +CVAPI(void) cvMakeAlphaScanlines( int* scanlines1, + int* scanlines2, + int* scanlinesA, + int* lengths, + int line_count, + float alpha); + +/* Blends data of the left and right image scanlines to get + pixel values of "virtual" image scanlines */ +CVAPI(void) cvMorphEpilinesMulti( int line_count, + uchar* first_pix, + int* first_num, + uchar* second_pix, + int* second_num, + uchar* dst_pix, + int* dst_num, + float alpha, + int* first, + int* first_runs, + int* second, + int* second_runs, + int* first_corr, + int* second_corr); + +/* Does reverse warping of the morphing result to make + it fill the destination image rectangle */ +CVAPI(void) cvPostWarpImage( int line_count, + uchar* src, + int* src_nums, + IplImage* img, + int* scanlines); + +/* Deletes Moire (missed pixels that appear due to discretization) */ +CVAPI(void) cvDeleteMoire( IplImage* img ); + + +/****************************************************************************************\ +* Background/foreground segmentation * +\****************************************************************************************/ + +#define CV_BG_MODEL_FGD 0 +#define CV_BG_MODEL_MOG 1 +#define CV_BG_MODEL_FGD_SIMPLE 2 + +struct CvBGStatModel; + +typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model ); +typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model ); + +#define CV_BG_STAT_MODEL_FIELDS() \ + int type; /*type of BG model*/ \ + CvReleaseBGStatModel release; \ + CvUpdateBGStatModel update; \ + IplImage* background; /*8UC3 reference background image*/ \ + IplImage* foreground; /*8UC1 foreground image*/ \ + IplImage** layers; /*8UC3 reference background image, can be null */ \ + int layer_count; /* can be zero */ \ + CvMemStorage* storage; /*storage for “foreground_regions”*/ \ + CvSeq* foreground_regions /*foreground object contours*/ + +typedef struct CvBGStatModel +{ + CV_BG_STAT_MODEL_FIELDS(); +} +CvBGStatModel; + +// + +// Releases memory used by BGStatModel +CV_INLINE void cvReleaseBGStatModel( CvBGStatModel** bg_model ) +{ + if( bg_model && *bg_model && (*bg_model)->release ) + (*bg_model)->release( bg_model ); +} + +// Updates statistical model and returns number of found foreground regions +CV_INLINE int cvUpdateBGStatModel( IplImage* current_frame, CvBGStatModel* bg_model ) +{ + return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model ) : 0; +} + +// Performs FG post-processing using segmentation +// (all pixels of a region will be classified as foreground if majority of pixels of the region are FG). +// parameters: +// segments - pointer to result of segmentation (for example MeanShiftSegmentation) +// bg_model - pointer to CvBGStatModel structure +CVAPI(void) cvRefineForegroundMaskBySegm( CvSeq* segments, CvBGStatModel* bg_model ); + +/* Common use change detection function */ +CVAPI(int) cvChangeDetection( IplImage* prev_frame, + IplImage* curr_frame, + IplImage* change_mask ); + +/* + Interface of ACM MM2003 algorithm + (Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian. + "Foreground Object Detection from Videos Containing Complex Background. ACM MM2003") +*/ + +/* default paremeters of foreground detection algorithm */ +#define CV_BGFG_FGD_LC 128 +#define CV_BGFG_FGD_N1C 15 +#define CV_BGFG_FGD_N2C 25 + +#define CV_BGFG_FGD_LCC 64 +#define CV_BGFG_FGD_N1CC 25 +#define CV_BGFG_FGD_N2CC 40 + +/* BG reference image update parameter */ +#define CV_BGFG_FGD_ALPHA_1 0.1f + +/* stat model update parameter + 0.002f ~ 1K frame(~45sec), 0.005 ~ 18sec (if 25fps and absolutely static BG) */ +#define CV_BGFG_FGD_ALPHA_2 0.005f + +/* start value for alpha parameter (to fast initiate statistic model) */ +#define CV_BGFG_FGD_ALPHA_3 0.1f + +#define CV_BGFG_FGD_DELTA 2 + +#define CV_BGFG_FGD_T 0.9f + +#define CV_BGFG_FGD_MINAREA 15.f + +#define CV_BGFG_FGD_BG_UPDATE_TRESH 0.5f + +typedef struct CvFGDStatModelParams +{ + int Lc, N1c, N2c, Lcc, N1cc, N2cc, is_obj_without_holes, perform_morphing; + float alpha1, alpha2, alpha3, delta, T, minArea; +} +CvFGDStatModelParams; + +typedef struct CvBGPixelCStatTable +{ + float Pv, Pvb; + uchar v[3]; +} +CvBGPixelCStatTable; + +typedef struct CvBGPixelCCStatTable +{ + float Pv, Pvb; + uchar v[6]; +} +CvBGPixelCCStatTable; + +typedef struct CvBGPixelStat +{ + float Pbc; + float Pbcc; + CvBGPixelCStatTable* ctable; + CvBGPixelCCStatTable* cctable; + uchar is_trained_st_model; + uchar is_trained_dyn_model; +} +CvBGPixelStat; + + +typedef struct CvFGDStatModel +{ + CV_BG_STAT_MODEL_FIELDS(); + CvBGPixelStat* pixel_stat; + IplImage* Ftd; + IplImage* Fbd; + IplImage* prev_frame; + CvFGDStatModelParams params; +} +CvFGDStatModel; + +/* Creates FGD model */ +CVAPI(CvBGStatModel*) cvCreateFGDStatModel( IplImage* first_frame, + CvFGDStatModelParams* parameters CV_DEFAULT(NULL)); + +/* + Interface of Gaussian mixture algorithm + (P. KadewTraKuPong and R. Bowden, + "An improved adaptive background mixture model for real-time tracking with shadow detection" + in Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001.") +*/ + +#define CV_BGFG_MOG_MAX_NGAUSSIANS 500 + +/* default parameters of gaussian background detection algorithm */ +#define CV_BGFG_MOG_BACKGROUND_THRESHOLD 0.7 /* threshold sum of weights for background test */ +#define CV_BGFG_MOG_STD_THRESHOLD 2.5 /* lambda=2.5 is 99% */ +#define CV_BGFG_MOG_WINDOW_SIZE 200 /* Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE */ +#define CV_BGFG_MOG_NGAUSSIANS 5 /* = K = number of Gaussians in mixture */ +#define CV_BGFG_MOG_WEIGHT_INIT 0.05 +#define CV_BGFG_MOG_SIGMA_INIT 30 +#define CV_BGFG_MOG_MINAREA 15.f + + +#define CV_BGFG_MOG_NCOLORS 3 + +typedef struct CvGaussBGStatModelParams +{ + int win_size; /* = 1/alpha */ + int n_gauss; + double bg_threshold, std_threshold, minArea; + double weight_init, variance_init; +}CvGaussBGStatModelParams; + +typedef struct CvGaussBGValues +{ + int match_sum; + double weight; + double variance[CV_BGFG_MOG_NCOLORS]; + double mean[CV_BGFG_MOG_NCOLORS]; +} +CvGaussBGValues; + +typedef struct CvGaussBGPoint +{ + CvGaussBGValues* g_values; +} +CvGaussBGPoint; + + +typedef struct CvGaussBGModel +{ + CV_BG_STAT_MODEL_FIELDS(); + CvGaussBGStatModelParams params; + CvGaussBGPoint* g_point; + int countFrames; +} +CvGaussBGModel; + + +/* Creates Gaussian mixture background model */ +CVAPI(CvBGStatModel*) cvCreateGaussianBGModel( IplImage* first_frame, + CvGaussBGStatModelParams* parameters CV_DEFAULT(NULL)); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus + +/****************************************************************************************\ +* Calibration engine * +\****************************************************************************************/ + +typedef enum CvCalibEtalonType +{ + CV_CALIB_ETALON_USER = -1, + CV_CALIB_ETALON_CHESSBOARD = 0, + CV_CALIB_ETALON_CHECKERBOARD = CV_CALIB_ETALON_CHESSBOARD +} +CvCalibEtalonType; + +class CV_EXPORTS CvCalibFilter +{ +public: + /* Constructor & destructor */ + CvCalibFilter(); + virtual ~CvCalibFilter(); + + /* Sets etalon type - one for all cameras. + etalonParams is used in case of pre-defined etalons (such as chessboard). + Number of elements in etalonParams is determined by etalonType. + E.g., if etalon type is CV_ETALON_TYPE_CHESSBOARD then: + etalonParams[0] is number of squares per one side of etalon + etalonParams[1] is number of squares per another side of etalon + etalonParams[2] is linear size of squares in the board in arbitrary units. + pointCount & points are used in case of + CV_CALIB_ETALON_USER (user-defined) etalon. */ + virtual bool + SetEtalon( CvCalibEtalonType etalonType, double* etalonParams, + int pointCount = 0, CvPoint2D32f* points = 0 ); + + /* Retrieves etalon parameters/or and points */ + virtual CvCalibEtalonType + GetEtalon( int* paramCount = 0, const double** etalonParams = 0, + int* pointCount = 0, const CvPoint2D32f** etalonPoints = 0 ) const; + + /* Sets number of cameras calibrated simultaneously. It is equal to 1 initially */ + virtual void SetCameraCount( int cameraCount ); + + /* Retrieves number of cameras */ + int GetCameraCount() const { return cameraCount; } + + /* Starts cameras calibration */ + virtual bool SetFrames( int totalFrames ); + + /* Stops cameras calibration */ + virtual void Stop( bool calibrate = false ); + + /* Retrieves number of cameras */ + bool IsCalibrated() const { return isCalibrated; } + + /* Feeds another serie of snapshots (one per each camera) to filter. + Etalon points on these images are found automatically. + If the function can't locate points, it returns false */ + virtual bool FindEtalon( IplImage** imgs ); + + /* The same but takes matrices */ + virtual bool FindEtalon( CvMat** imgs ); + + /* Lower-level function for feeding filter with already found etalon points. + Array of point arrays for each camera is passed. */ + virtual bool Push( const CvPoint2D32f** points = 0 ); + + /* Returns total number of accepted frames and, optionally, + total number of frames to collect */ + virtual int GetFrameCount( int* framesTotal = 0 ) const; + + /* Retrieves camera parameters for specified camera. + If camera is not calibrated the function returns 0 */ + virtual const CvCamera* GetCameraParams( int idx = 0 ) const; + + virtual const CvStereoCamera* GetStereoParams() const; + + /* Sets camera parameters for all cameras */ + virtual bool SetCameraParams( CvCamera* params ); + + /* Saves all camera parameters to file */ + virtual bool SaveCameraParams( const char* filename ); + + /* Loads all camera parameters from file */ + virtual bool LoadCameraParams( const char* filename ); + + /* Undistorts images using camera parameters. Some of src pointers can be NULL. */ + virtual bool Undistort( IplImage** src, IplImage** dst ); + + /* Undistorts images using camera parameters. Some of src pointers can be NULL. */ + virtual bool Undistort( CvMat** src, CvMat** dst ); + + /* Returns array of etalon points detected/partally detected + on the latest frame for idx-th camera */ + virtual bool GetLatestPoints( int idx, CvPoint2D32f** pts, + int* count, bool* found ); + + /* Draw the latest detected/partially detected etalon */ + virtual void DrawPoints( IplImage** dst ); + + /* Draw the latest detected/partially detected etalon */ + virtual void DrawPoints( CvMat** dst ); + + virtual bool Rectify( IplImage** srcarr, IplImage** dstarr ); + virtual bool Rectify( CvMat** srcarr, CvMat** dstarr ); + +protected: + + enum { MAX_CAMERAS = 3 }; + + /* etalon data */ + CvCalibEtalonType etalonType; + int etalonParamCount; + double* etalonParams; + int etalonPointCount; + CvPoint2D32f* etalonPoints; + CvSize imgSize; + CvMat* grayImg; + CvMat* tempImg; + CvMemStorage* storage; + + /* camera data */ + int cameraCount; + CvCamera cameraParams[MAX_CAMERAS]; + CvStereoCamera stereo; + CvPoint2D32f* points[MAX_CAMERAS]; + CvMat* undistMap[MAX_CAMERAS][2]; + CvMat* undistImg; + int latestCounts[MAX_CAMERAS]; + CvPoint2D32f* latestPoints[MAX_CAMERAS]; + CvMat* rectMap[MAX_CAMERAS][2]; + + /* Added by Valery */ + //CvStereoCamera stereoParams; + + int maxPoints; + int framesTotal; + int framesAccepted; + bool isCalibrated; +}; + +#include "cvaux.hpp" +#include "cvvidsurv.hpp" +/*#include "cvmat.hpp"*/ +#endif + +#endif + +/* End of file. */ diff --git a/include/opencv/cvcompat.h b/include/opencv/cvcompat.h new file mode 100755 index 0000000..03280d8 --- /dev/null +++ b/include/opencv/cvcompat.h @@ -0,0 +1,1081 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright( C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +//(including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort(including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* + A few macros and definitions for backward compatibility + with the previous versions of OpenCV. They are obsolete and + are likely to be removed in future. To check whether your code + uses any of these, define CV_NO_BACKWARD_COMPATIBILITY before + including cv.h. +*/ + +#ifndef _CVCOMPAT_H_ +#define _CVCOMPAT_H_ + +#include + +#ifdef __cplusplus + #define CV_UNREFERENCED(arg) +#else + #define CV_UNREFERENCED(arg) arg +#endif + +#define CvMatType int +#define CvDisMaskType int +#define CvMatArray CvMat + +#define CvThreshType int +#define CvAdaptiveThreshMethod int +#define CvCompareMethod int +#define CvFontFace int +#define CvPolyApproxMethod int +#define CvContoursMatchMethod int +#define CvContourTreesMatchMethod int +#define CvCoeffType int +#define CvRodriguesType int +#define CvElementShape int +#define CvMorphOp int +#define CvTemplMatchMethod int + +#define CvPoint2D64d CvPoint2D64f +#define CvPoint3D64d CvPoint3D64f + +#define CV_MAT32F CV_32FC1 +#define CV_MAT3x1_32F CV_32FC1 +#define CV_MAT4x1_32F CV_32FC1 +#define CV_MAT3x3_32F CV_32FC1 +#define CV_MAT4x4_32F CV_32FC1 + +#define CV_MAT64D CV_64FC1 +#define CV_MAT3x1_64D CV_64FC1 +#define CV_MAT4x1_64D CV_64FC1 +#define CV_MAT3x3_64D CV_64FC1 +#define CV_MAT4x4_64D CV_64FC1 + +#define IPL_GAUSSIAN_5x5 7 +#define CvBox2D32f CvBox2D + +/* allocation/deallocation macros */ +#define cvCreateImageData cvCreateData +#define cvReleaseImageData cvReleaseData +#define cvSetImageData cvSetData +#define cvGetImageRawData cvGetRawData + +#define cvmAlloc cvCreateData +#define cvmFree cvReleaseData +#define cvmAllocArray cvCreateData +#define cvmFreeArray cvReleaseData + +#define cvIntegralImage cvIntegral +#define cvMatchContours cvMatchShapes + +CV_INLINE CvMat cvMatArray( int rows, int cols, int type, + int count, void* data CV_DEFAULT(0)) +{ + return cvMat( rows*count, cols, type, data ); +} + +#define cvUpdateMHIByTime cvUpdateMotionHistory + +#define cvAccMask cvAcc +#define cvSquareAccMask cvSquareAcc +#define cvMultiplyAccMask cvMultiplyAcc +#define cvRunningAvgMask(imgY, imgU, mask, alpha) cvRunningAvg(imgY, imgU, alpha, mask) + +#define cvSetHistThresh cvSetHistBinRanges +#define cvCalcHistMask(img, mask, hist, doNotClear) cvCalcHist(img, hist, doNotClear, mask) + +CV_INLINE double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0)) +{ + CvScalar mean = cvAvg( image, mask ); + return mean.val[0]; +} + + +CV_INLINE double cvSumPixels( const CvArr* image ) +{ + CvScalar scalar = cvSum( image ); + return scalar.val[0]; +} + +CV_INLINE void cvMean_StdDev( const CvArr* image, double* mean, double* sdv, + const CvArr* mask CV_DEFAULT(0)) +{ + CvScalar _mean, _sdv; + cvAvgSdv( image, &_mean, &_sdv, mask ); + + if( mean ) + *mean = _mean.val[0]; + + if( sdv ) + *sdv = _sdv.val[0]; +} + + +CV_INLINE void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst ) +{ + CvMat tsrc, tdst; + + cvReshape( src, &tsrc, 3, 0 ); + cvReshape( dst, &tdst, 3, 0 ); + + cvPerspectiveTransform( &tsrc, &tdst, mat ); +} + + +CV_INLINE void cvFillImage( CvArr* mat, double color ) +{ + cvSet( mat, cvColorToScalar(color, cvGetElemType(mat)), 0 ); +} + + +#define cvCvtPixToPlane cvSplit +#define cvCvtPlaneToPix cvMerge + +typedef struct CvRandState +{ + CvRNG state; /* RNG state (the current seed and carry)*/ + int disttype; /* distribution type */ + CvScalar param[2]; /* parameters of RNG */ +} +CvRandState; + + +/* Changes RNG range while preserving RNG state */ +CV_INLINE void cvRandSetRange( CvRandState* state, double param1, + double param2, int index CV_DEFAULT(-1)) +{ + if( !state ) + { + cvError( CV_StsNullPtr, "cvRandSetRange", "Null pointer to RNG state", "cvcompat.h", 0 ); + return; + } + + if( (unsigned)(index + 1) > 4 ) + { + cvError( CV_StsOutOfRange, "cvRandSetRange", "index is not in -1..3", "cvcompat.h", 0 ); + return; + } + + if( index < 0 ) + { + state->param[0].val[0] = state->param[0].val[1] = + state->param[0].val[2] = state->param[0].val[3] = param1; + state->param[1].val[0] = state->param[1].val[1] = + state->param[1].val[2] = state->param[1].val[3] = param2; + } + else + { + state->param[0].val[index] = param1; + state->param[1].val[index] = param2; + } +} + + +CV_INLINE void cvRandInit( CvRandState* state, double param1, + double param2, int seed, + int disttype CV_DEFAULT(CV_RAND_UNI)) +{ + if( !state ) + { + cvError( CV_StsNullPtr, "cvRandInit", "Null pointer to RNG state", "cvcompat.h", 0 ); + return; + } + + if( disttype != CV_RAND_UNI && disttype != CV_RAND_NORMAL ) + { + cvError( CV_StsBadFlag, "cvRandInit", "Unknown distribution type", "cvcompat.h", 0 ); + return; + } + + state->state = (uint64)(seed ? seed : -1); + state->disttype = disttype; + cvRandSetRange( state, param1, param2, -1 ); +} + + +/* Fills array with random numbers */ +CV_INLINE void cvRand( CvRandState* state, CvArr* arr ) +{ + if( !state ) + { + cvError( CV_StsNullPtr, "cvRand", "Null pointer to RNG state", "cvcompat.h", 0 ); + return; + } + cvRandArr( &state->state, arr, state->disttype, state->param[0], state->param[1] ); +} + +#define cvRandNext( _state ) cvRandInt( &(_state)->state ) + +CV_INLINE void cvbRand( CvRandState* state, float* dst, int len ) +{ + CvMat mat = cvMat( 1, len, CV_32F, (void*)dst ); + cvRand( state, &mat ); +} + + +CV_INLINE void cvbCartToPolar( const float* y, const float* x, + float* magnitude, float* angle, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + CvMat mm = mx; + CvMat ma = mx; + + my.data.fl = (float*)y; + mm.data.fl = (float*)magnitude; + ma.data.fl = (float*)angle; + + cvCartToPolar( &mx, &my, &mm, angle ? &ma : NULL, 1 ); +} + + +CV_INLINE void cvbFastArctan( const float* y, const float* x, + float* angle, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + CvMat ma = mx; + + my.data.fl = (float*)y; + ma.data.fl = (float*)angle; + + cvCartToPolar( &mx, &my, NULL, &ma, 1 ); +} + + +CV_INLINE void cvbSqrt( const float* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + my.data.fl = (float*)y; + + cvPow( &mx, &my, 0.5 ); +} + + +CV_INLINE void cvbInvSqrt( const float* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + my.data.fl = (float*)y; + + cvPow( &mx, &my, -0.5 ); +} + + +CV_INLINE void cvbReciprocal( const float* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + my.data.fl = (float*)y; + + cvPow( &mx, &my, -1 ); +} + + +CV_INLINE void cvbFastExp( const float* x, double* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = cvMat( 1, len, CV_64F, y ); + cvExp( &mx, &my ); +} + + +CV_INLINE void cvbFastLog( const double* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_64F, (void*)x ); + CvMat my = cvMat( 1, len, CV_32F, y ); + cvLog( &mx, &my ); +} + + +CV_INLINE CvRect cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0)) +{ + return cvBoundingRect( point_set, update ); +} + + +CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst ) +{ + return cvInvert( src, dst, CV_SVD ); +} + +#define cvPseudoInv cvPseudoInverse + +#define cvContourMoments( contour, moments ) \ + cvMoments( contour, moments, 0 ) + +#define cvGetPtrAt cvPtr2D +#define cvGetAt cvGet2D +#define cvSetAt(arr,val,y,x) cvSet2D((arr),(y),(x),(val)) + +#define cvMeanMask cvMean +#define cvMean_StdDevMask(img,mask,mean,sdv) cvMean_StdDev(img,mean,sdv,mask) + +#define cvNormMask(imgA,imgB,mask,normType) cvNorm(imgA,imgB,normType,mask) + +#define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \ + cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask) + +#define cvRemoveMemoryManager cvSetMemoryManager + +#define cvmSetZero( mat ) cvSetZero( mat ) +#define cvmSetIdentity( mat ) cvSetIdentity( mat ) +#define cvmAdd( src1, src2, dst ) cvAdd( src1, src2, dst, 0 ) +#define cvmSub( src1, src2, dst ) cvSub( src1, src2, dst, 0 ) +#define cvmCopy( src, dst ) cvCopy( src, dst, 0 ) +#define cvmMul( src1, src2, dst ) cvMatMulAdd( src1, src2, 0, dst ) +#define cvmTranspose( src, dst ) cvT( src, dst ) +#define cvmInvert( src, dst ) cvInv( src, dst ) +#define cvmMahalanobis(vec1, vec2, mat) cvMahalanobis( vec1, vec2, mat ) +#define cvmDotProduct( vec1, vec2 ) cvDotProduct( vec1, vec2 ) +#define cvmCrossProduct(vec1, vec2,dst) cvCrossProduct( vec1, vec2, dst ) +#define cvmTrace( mat ) (cvTrace( mat )).val[0] +#define cvmMulTransposed( src, dst, order ) cvMulTransposed( src, dst, order ) +#define cvmEigenVV( mat, evec, eval, eps) cvEigenVV( mat, evec, eval, eps ) +#define cvmDet( mat ) cvDet( mat ) +#define cvmScale( src, dst, scale ) cvScale( src, dst, scale ) + +#define cvCopyImage( src, dst ) cvCopy( src, dst, 0 ) +#define cvReleaseMatHeader cvReleaseMat + +/* Calculates exact convex hull of 2d point set */ +CV_INLINE void cvConvexHull( CvPoint* points, int num_points, + CvRect* CV_UNREFERENCED(bound_rect), + int orientation, int* hull, int* hullsize ) +{ + CvMat points1 = cvMat( 1, num_points, CV_32SC2, points ); + CvMat hull1 = cvMat( 1, num_points, CV_32SC1, hull ); + + cvConvexHull2( &points1, &hull1, orientation, 0 ); + *hullsize = hull1.cols; +} + +/* Calculates exact convex hull of 2d point set stored in a sequence */ +#define cvContourConvexHull( contour, orientation, storage ) \ + cvConvexHull2( contour, storage, orientation ) + +/* Calculates approximate convex hull of 2d point set */ +#define cvConvexHullApprox( points, num_points, bound_rect, bandwidth, \ + orientation, hull, hullsize ) \ +cvConvexHull( points, num_points, bound_rect, orientation, hull, hullsize ) + +/* Calculates approximate convex hull of 2d point set stored in a sequence */ +#define cvContourConvexHullApprox( contour, bandwidth, orientation, storage ) \ + cvConvexHull2( contour, storage, orientation ) + + +CV_INLINE void cvMinAreaRect( CvPoint* points, int n, + int CV_UNREFERENCED(left), int CV_UNREFERENCED(bottom), + int CV_UNREFERENCED(right), int CV_UNREFERENCED(top), + CvPoint2D32f* anchor, + CvPoint2D32f* vect1, + CvPoint2D32f* vect2 ) +{ + CvMat mat = cvMat( 1, n, CV_32SC2, points ); + CvBox2D box = cvMinAreaRect2( &mat, 0 ); + CvPoint2D32f pt[4]; + + cvBoxPoints( box, pt ); + *anchor = pt[0]; + vect1->x = pt[1].x - pt[0].x; + vect1->y = pt[1].y - pt[0].y; + vect2->x = pt[3].x - pt[0].x; + vect2->y = pt[3].y - pt[0].y; + + CV_UNREFERENCED((void)left); + CV_UNREFERENCED((void)bottom); + CV_UNREFERENCED((void)right); + CV_UNREFERENCED((void)top); +} + +typedef int CvDisType; +typedef int CvChainApproxMethod; +typedef int CvContourRetrievalMode; + +CV_INLINE void cvFitLine3D( CvPoint3D32f* points, int count, int dist, + void *param, float reps, float aeps, float* line ) +{ + CvMat mat = cvMat( 1, count, CV_32FC3, points ); + float _param = param != NULL ? *(float*)param : 0.f; + assert( dist != CV_DIST_USER ); + cvFitLine( &mat, dist, _param, reps, aeps, line ); +} + +/* Fits a line into set of 2d points in a robust way (M-estimator technique) */ +CV_INLINE void cvFitLine2D( CvPoint2D32f* points, int count, int dist, + void *param, float reps, float aeps, float* line ) +{ + CvMat mat = cvMat( 1, count, CV_32FC2, points ); + float _param = param != NULL ? *(float*)param : 0.f; + assert( dist != CV_DIST_USER ); + cvFitLine( &mat, dist, _param, reps, aeps, line ); +} + + +CV_INLINE void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box ) +{ + CvMat mat = cvMat( 1, count, CV_32FC2, (void*)points ); + *box = cvFitEllipse2( &mat ); +} + +/* Projects 2d points to one of standard coordinate planes + (i.e. removes one of coordinates) */ +CV_INLINE void cvProject3D( CvPoint3D32f* points3D, int count, + CvPoint2D32f* points2D, + int xIndx CV_DEFAULT(0), + int yIndx CV_DEFAULT(1)) +{ + CvMat src = cvMat( 1, count, CV_32FC3, points3D ); + CvMat dst = cvMat( 1, count, CV_32FC2, points2D ); + float m[6] = {0,0,0,0,0,0}; + CvMat M = cvMat( 2, 3, CV_32F, m ); + + assert( (unsigned)xIndx < 3 && (unsigned)yIndx < 3 ); + m[xIndx] = m[yIndx+3] = 1.f; + + cvTransform( &src, &dst, &M, NULL ); +} + + +/* Retrieves value of the particular bin + of x-dimensional (x=1,2,3,...) histogram */ +#define cvQueryHistValue_1D( hist, idx0 ) \ + ((float)cvGetReal1D( (hist)->bins, (idx0))) +#define cvQueryHistValue_2D( hist, idx0, idx1 ) \ + ((float)cvGetReal2D( (hist)->bins, (idx0), (idx1))) +#define cvQueryHistValue_3D( hist, idx0, idx1, idx2 ) \ + ((float)cvGetReal3D( (hist)->bins, (idx0), (idx1), (idx2))) +#define cvQueryHistValue_nD( hist, idx ) \ + ((float)cvGetRealND( (hist)->bins, (idx))) + +/* Returns pointer to the particular bin of x-dimesional histogram. + For sparse histogram the bin is created if it didn't exist before */ +#define cvGetHistValue_1D( hist, idx0 ) \ + ((float*)cvPtr1D( (hist)->bins, (idx0), 0)) +#define cvGetHistValue_2D( hist, idx0, idx1 ) \ + ((float*)cvPtr2D( (hist)->bins, (idx0), (idx1), 0)) +#define cvGetHistValue_3D( hist, idx0, idx1, idx2 ) \ + ((float*)cvPtr3D( (hist)->bins, (idx0), (idx1), (idx2), 0)) +#define cvGetHistValue_nD( hist, idx ) \ + ((float*)cvPtrND( (hist)->bins, (idx), 0)) + + +#define CV_IS_SET_ELEM_EXISTS CV_IS_SET_ELEM + + +CV_INLINE int cvHoughLines( CvArr* image, double rho, + double theta, int threshold, + float* lines, int linesNumber ) +{ + CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines ); + cvHoughLines2( image, &linesMat, CV_HOUGH_STANDARD, + rho, theta, threshold, 0, 0 ); + + return linesMat.cols; +} + + +CV_INLINE int cvHoughLinesP( CvArr* image, double rho, + double theta, int threshold, + int lineLength, int lineGap, + int* lines, int linesNumber ) +{ + CvMat linesMat = cvMat( 1, linesNumber, CV_32SC4, lines ); + cvHoughLines2( image, &linesMat, CV_HOUGH_PROBABILISTIC, + rho, theta, threshold, lineLength, lineGap ); + + return linesMat.cols; +} + + +CV_INLINE int cvHoughLinesSDiv( CvArr* image, double rho, int srn, + double theta, int stn, int threshold, + float* lines, int linesNumber ) +{ + CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines ); + cvHoughLines2( image, &linesMat, CV_HOUGH_MULTI_SCALE, + rho, theta, threshold, srn, stn ); + + return linesMat.cols; +} + + +/* Find fundamental matrix */ +CV_INLINE void cvFindFundamentalMatrix( int* points1, int* points2, + int numpoints, int CV_UNREFERENCED(method), float* matrix ) +{ + CvMat* pointsMat1; + CvMat* pointsMat2; + CvMat fundMatr = cvMat(3,3,CV_32F,matrix); + int i, curr = 0; + + pointsMat1 = cvCreateMat(3,numpoints,CV_64F); + pointsMat2 = cvCreateMat(3,numpoints,CV_64F); + + for( i = 0; i < numpoints; i++ ) + { + cvmSet(pointsMat1,0,i,points1[curr]);//x + cvmSet(pointsMat1,1,i,points1[curr+1]);//y + cvmSet(pointsMat1,2,i,1.0); + + cvmSet(pointsMat2,0,i,points2[curr]);//x + cvmSet(pointsMat2,1,i,points2[curr+1]);//y + cvmSet(pointsMat2,2,i,1.0); + curr += 2; + } + + cvFindFundamentalMat(pointsMat1,pointsMat2,&fundMatr,CV_FM_RANSAC,1,0.99,0); + + cvReleaseMat(&pointsMat1); + cvReleaseMat(&pointsMat2); +} + + + +CV_INLINE int +cvFindChessBoardCornerGuesses( const void* arr, void* CV_UNREFERENCED(thresharr), + CvMemStorage * CV_UNREFERENCED(storage), + CvSize pattern_size, CvPoint2D32f * corners, + int *corner_count ) +{ + return cvFindChessboardCorners( arr, pattern_size, corners, + corner_count, CV_CALIB_CB_ADAPTIVE_THRESH ); +} + + +/* Calibrates camera using multiple views of calibration pattern */ +CV_INLINE void cvCalibrateCamera( int image_count, int* _point_counts, + CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points, + float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors, + float* _rotation_matrices, int flags ) +{ + int i, total = 0; + CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts ); + CvMat image_points, object_points; + CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs ); + CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, _camera_matrix ); + CvMat rotation_matrices = cvMat( image_count, 9, CV_32FC1, _rotation_matrices ); + CvMat translation_vectors = cvMat( image_count, 3, CV_32FC1, _translation_vectors ); + + for( i = 0; i < image_count; i++ ) + total += _point_counts[i]; + + image_points = cvMat( total, 1, CV_32FC2, _image_points ); + object_points = cvMat( total, 1, CV_32FC3, _object_points ); + + cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size, + &camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors, + flags ); +} + + +CV_INLINE void cvCalibrateCamera_64d( int image_count, int* _point_counts, + CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points, + double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors, + double* _rotation_matrices, int flags ) +{ + int i, total = 0; + CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts ); + CvMat image_points, object_points; + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs ); + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix ); + CvMat rotation_matrices = cvMat( image_count, 9, CV_64FC1, _rotation_matrices ); + CvMat translation_vectors = cvMat( image_count, 3, CV_64FC1, _translation_vectors ); + + for( i = 0; i < image_count; i++ ) + total += _point_counts[i]; + + image_points = cvMat( total, 1, CV_64FC2, _image_points ); + object_points = cvMat( total, 1, CV_64FC3, _object_points ); + + cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size, + &camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors, + flags ); +} + + + +/* Find 3d position of object given intrinsic camera parameters, + 3d model of the object and projection of the object into view plane */ +CV_INLINE void cvFindExtrinsicCameraParams( int point_count, + CvSize CV_UNREFERENCED(image_size), CvPoint2D32f* _image_points, + CvPoint3D32f* _object_points, float* focal_length, + CvPoint2D32f principal_point, float* _distortion_coeffs, + float* _rotation_vector, float* _translation_vector ) +{ + CvMat image_points = cvMat( point_count, 1, CV_32FC2, _image_points ); + CvMat object_points = cvMat( point_count, 1, CV_32FC3, _object_points ); + CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs ); + float a[9]; + CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, a ); + CvMat rotation_vector = cvMat( 1, 1, CV_32FC3, _rotation_vector ); + CvMat translation_vector = cvMat( 1, 1, CV_32FC3, _translation_vector ); + + a[0] = focal_length[0]; a[4] = focal_length[1]; + a[2] = principal_point.x; a[5] = principal_point.y; + a[1] = a[3] = a[6] = a[7] = 0.f; + a[8] = 1.f; + + cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix, + &dist_coeffs, &rotation_vector, &translation_vector ); +} + + +/* Variant of the previous function that takes double-precision parameters */ +CV_INLINE void cvFindExtrinsicCameraParams_64d( int point_count, + CvSize CV_UNREFERENCED(image_size), CvPoint2D64f* _image_points, + CvPoint3D64f* _object_points, double* focal_length, + CvPoint2D64f principal_point, double* _distortion_coeffs, + double* _rotation_vector, double* _translation_vector ) +{ + CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points ); + CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points ); + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs ); + double a[9]; + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a ); + CvMat rotation_vector = cvMat( 1, 1, CV_64FC3, _rotation_vector ); + CvMat translation_vector = cvMat( 1, 1, CV_64FC3, _translation_vector ); + + a[0] = focal_length[0]; a[4] = focal_length[1]; + a[2] = principal_point.x; a[5] = principal_point.y; + a[1] = a[3] = a[6] = a[7] = 0.; + a[8] = 1.; + + cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix, + &dist_coeffs, &rotation_vector, &translation_vector ); +} + + +/* Rodrigues transform */ +#define CV_RODRIGUES_M2V 0 +#define CV_RODRIGUES_V2M 1 + +/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */ +CV_INLINE void cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector, + CvMat* jacobian, int conv_type ) +{ + if( conv_type == CV_RODRIGUES_V2M ) + cvRodrigues2( rotation_vector, rotation_matrix, jacobian ); + else + cvRodrigues2( rotation_matrix, rotation_vector, jacobian ); +} + + +/* Does reprojection of 3d object points to the view plane */ +CV_INLINE void cvProjectPoints( int point_count, CvPoint3D64f* _object_points, + double* _rotation_vector, double* _translation_vector, + double* focal_length, CvPoint2D64f principal_point, + double* _distortion, CvPoint2D64f* _image_points, + double* _deriv_points_rotation_matrix, + double* _deriv_points_translation_vect, + double* _deriv_points_focal, + double* _deriv_points_principal_point, + double* _deriv_points_distortion_coeffs ) +{ + CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points ); + CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points ); + CvMat rotation_vector = cvMat( 3, 1, CV_64FC1, _rotation_vector ); + CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector ); + double a[9]; + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a ); + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion ); + CvMat dpdr = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_rotation_matrix ); + CvMat dpdt = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_translation_vect ); + CvMat dpdf = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_focal ); + CvMat dpdc = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_principal_point ); + CvMat dpdk = cvMat( 2*point_count, 4, CV_64FC1, _deriv_points_distortion_coeffs ); + + a[0] = focal_length[0]; a[4] = focal_length[1]; + a[2] = principal_point.x; a[5] = principal_point.y; + a[1] = a[3] = a[6] = a[7] = 0.; + a[8] = 1.; + + cvProjectPoints2( &object_points, &rotation_vector, &translation_vector, + &camera_matrix, &dist_coeffs, &image_points, + &dpdr, &dpdt, &dpdf, &dpdc, &dpdk ); +} + + +/* Simpler version of the previous function */ +CV_INLINE void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points, + double* _rotation_matrix, double* _translation_vector, + double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points ) +{ + CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points ); + CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points ); + CvMat rotation_matrix = cvMat( 3, 3, CV_64FC1, _rotation_matrix ); + CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector ); + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix ); + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion ); + + cvProjectPoints2( &object_points, &rotation_matrix, &translation_vector, + &camera_matrix, &dist_coeffs, &image_points, + 0, 0, 0, 0, 0 ); +} + + +CV_INLINE void cvUnDistortOnce( const CvArr* src, CvArr* dst, + const float* intrinsic_matrix, + const float* distortion_coeffs, + int CV_UNREFERENCED(interpolate) ) +{ + CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix ); + CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs ); + cvUndistort2( src, dst, &_a, &_k ); +} + + +/* the two functions below have quite hackerish implementations, use with care + (or, which is better, switch to cvUndistortInitMap and cvRemap instead */ +CV_INLINE void cvUnDistortInit( const CvArr* CV_UNREFERENCED(src), + CvArr* undistortion_map, + const float* A, const float* k, + int CV_UNREFERENCED(interpolate) ) +{ + union { uchar* ptr; float* fl; } data; + CvSize sz; + cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); + assert( sz.width >= 8 ); + /* just save the intrinsic parameters to the map */ + data.fl[0] = A[0]; data.fl[1] = A[4]; + data.fl[2] = A[2]; data.fl[3] = A[5]; + data.fl[4] = k[0]; data.fl[5] = k[1]; + data.fl[6] = k[2]; data.fl[7] = k[3]; +} + +CV_INLINE void cvUnDistort( const CvArr* src, CvArr* dst, + const CvArr* undistortion_map, + int CV_UNREFERENCED(interpolate) ) +{ + union { uchar* ptr; float* fl; } data; + float a[] = {0,0,0,0,0,0,0,0,1}; + CvSize sz; + cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); + assert( sz.width >= 8 ); + a[0] = data.fl[0]; a[4] = data.fl[1]; + a[2] = data.fl[2]; a[5] = data.fl[3]; + cvUnDistortOnce( src, dst, a, data.fl + 4, 1 ); +} + + +CV_INLINE float cvCalcEMD( const float* signature1, int size1, + const float* signature2, int size2, + int dims, int dist_type CV_DEFAULT(CV_DIST_L2), + CvDistanceFunction dist_func CV_DEFAULT(0), + float* lower_bound CV_DEFAULT(0), + void* user_param CV_DEFAULT(0)) +{ + CvMat sign1 = cvMat( size1, dims + 1, CV_32FC1, (void*)signature1 ); + CvMat sign2 = cvMat( size2, dims + 1, CV_32FC1, (void*)signature2 ); + + return cvCalcEMD2( &sign1, &sign2, dist_type, dist_func, 0, 0, lower_bound, user_param ); +} + + +CV_INLINE void cvKMeans( int num_clusters, float** samples, + int num_samples, int vec_size, + CvTermCriteria termcrit, int* cluster_idx ) +{ + CvMat* samples_mat = cvCreateMat( num_samples, vec_size, CV_32FC1 ); + CvMat cluster_idx_mat = cvMat( num_samples, 1, CV_32SC1, cluster_idx ); + int i; + for( i = 0; i < num_samples; i++ ) + memcpy( samples_mat->data.fl + i*vec_size, samples[i], vec_size*sizeof(float)); + cvKMeans2( samples_mat, num_clusters, &cluster_idx_mat, termcrit ); + cvReleaseMat( &samples_mat ); +} + + +CV_INLINE void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner, + CvGraphVtx* vtx CV_DEFAULT(NULL), + int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)) +{ + CvGraphScanner* temp_scanner; + + if( !scanner ) + cvError( CV_StsNullPtr, "cvStartScanGraph", "Null scanner pointer", "cvcompat.h", 0 ); + + temp_scanner = cvCreateGraphScanner( graph, vtx, mask ); + *scanner = *temp_scanner; + cvFree( &temp_scanner ); +} + + +CV_INLINE void cvEndScanGraph( CvGraphScanner* scanner ) +{ + if( !scanner ) + cvError( CV_StsNullPtr, "cvEndScanGraph", "Null scanner pointer", "cvcompat.h", 0 ); + + if( scanner->stack ) + { + CvGraphScanner* temp_scanner = (CvGraphScanner*)cvAlloc( sizeof(*temp_scanner) ); + *temp_scanner = *scanner; + cvReleaseGraphScanner( &temp_scanner ); + memset( scanner, 0, sizeof(*scanner) ); + } +} + + +#define cvKalmanUpdateByTime cvKalmanPredict +#define cvKalmanUpdateByMeasurement cvKalmanCorrect + +/* old drawing functions */ +CV_INLINE void cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2, + double color, int scale CV_DEFAULT(0)) +{ + cvLine( img, pt1, pt2, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale ); +} + +CV_INLINE void cvCircleAA( CvArr* img, CvPoint center, int radius, + double color, int scale CV_DEFAULT(0) ) +{ + cvCircle( img, center, radius, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale ); +} + +CV_INLINE void cvEllipseAA( CvArr* img, CvPoint center, CvSize axes, + double angle, double start_angle, + double end_angle, double color, + int scale CV_DEFAULT(0) ) +{ + cvEllipse( img, center, axes, angle, start_angle, end_angle, + cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale ); +} + +CV_INLINE void cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours, + int is_closed, double color, int scale CV_DEFAULT(0) ) +{ + cvPolyLine( img, pts, npts, contours, is_closed, + cvColorToScalar(color, cvGetElemType(img)), + 1, CV_AA, scale ); +} + + +#define cvMake2DPoints cvConvertPointsHomogenious +#define cvMake3DPoints cvConvertPointsHomogenious + +#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform + +/****************************************************************************************\ +* Pixel Access Macros * +\****************************************************************************************/ + +typedef struct _CvPixelPosition8u +{ + unsigned char* currline; /* pointer to the start of the current pixel line */ + unsigned char* topline; /* pointer to the start of the top pixel line */ + unsigned char* bottomline; /* pointer to the start of the first line */ + /* which is below the image */ + int x; /* current x coordinate ( in pixels ) */ + int width; /* width of the image ( in pixels ) */ + int height; /* height of the image ( in pixels ) */ + int step; /* distance between lines ( in elements of single */ + /* plane ) */ + int step_arr[3]; /* array: ( 0, -step, step ). It is used for */ + /* vertical moving */ +} CvPixelPosition8u; + +/* this structure differs from the above only in data type */ +typedef struct _CvPixelPosition8s +{ + char* currline; + char* topline; + char* bottomline; + int x; + int width; + int height; + int step; + int step_arr[3]; +} CvPixelPosition8s; + +/* this structure differs from the CvPixelPosition8u only in data type */ +typedef struct _CvPixelPosition32f +{ + float* currline; + float* topline; + float* bottomline; + int x; + int width; + int height; + int step; + int step_arr[3]; +} CvPixelPosition32f; + + +/* Initialize one of the CvPixelPosition structures. */ +/* pos - initialized structure */ +/* origin - pointer to the left-top corner of the ROI */ +/* step - width of the whole image in bytes */ +/* roi - width & height of the ROI */ +/* x, y - initial position */ +#define CV_INIT_PIXEL_POS(pos, origin, _step, roi, _x, _y, orientation) \ + ( \ + (pos).step = (_step)/sizeof((pos).currline[0]) * (orientation ? -1 : 1), \ + (pos).width = (roi).width, \ + (pos).height = (roi).height, \ + (pos).bottomline = (origin) + (pos).step*(pos).height, \ + (pos).topline = (origin) - (pos).step, \ + (pos).step_arr[0] = 0, \ + (pos).step_arr[1] = -(pos).step, \ + (pos).step_arr[2] = (pos).step, \ + (pos).x = (_x), \ + (pos).currline = (origin) + (pos).step*(_y) ) + + +/* Move to specified point ( absolute shift ) */ +/* pos - position structure */ +/* x, y - coordinates of the new position */ +/* cs - number of the image channels */ +#define CV_MOVE_TO( pos, _x, _y, cs ) \ +((pos).currline = (_y) >= 0 && (_y) < (pos).height ? (pos).topline + ((_y)+1)*(pos).step : 0, \ + (pos).x = (_x) >= 0 && (_x) < (pos).width ? (_x) : 0, (pos).currline + (_x) * (cs) ) + +/* Get current coordinates */ +/* pos - position structure */ +/* x, y - coordinates of the new position */ +/* cs - number of the image channels */ +#define CV_GET_CURRENT( pos, cs ) ((pos).currline + (pos).x * (cs)) + +/* Move by one pixel relatively to current position */ +/* pos - position structure */ +/* cs - number of the image channels */ + +/* left */ +#define CV_MOVE_LEFT( pos, cs ) \ + ( --(pos).x >= 0 ? (pos).currline + (pos).x*(cs) : 0 ) + +/* right */ +#define CV_MOVE_RIGHT( pos, cs ) \ + ( ++(pos).x < (pos).width ? (pos).currline + (pos).x*(cs) : 0 ) + +/* up */ +#define CV_MOVE_UP( pos, cs ) \ + (((pos).currline -= (pos).step) != (pos).topline ? (pos).currline + (pos).x*(cs) : 0 ) + +/* down */ +#define CV_MOVE_DOWN( pos, cs ) \ + (((pos).currline += (pos).step) != (pos).bottomline ? (pos).currline + (pos).x*(cs) : 0 ) + +/* left up */ +#define CV_MOVE_LU( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_UP(pos, cs)) + +/* right up */ +#define CV_MOVE_RU( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_UP(pos, cs)) + +/* left down */ +#define CV_MOVE_LD( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_DOWN(pos, cs)) + +/* right down */ +#define CV_MOVE_RD( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_DOWN(pos, cs)) + + + +/* Move by one pixel relatively to current position with wrapping when the position */ +/* achieves image boundary */ +/* pos - position structure */ +/* cs - number of the image channels */ + +/* left */ +#define CV_MOVE_LEFT_WRAP( pos, cs ) \ + ((pos).currline + ( --(pos).x >= 0 ? (pos).x : ((pos).x = (pos).width-1))*(cs)) + +/* right */ +#define CV_MOVE_RIGHT_WRAP( pos, cs ) \ + ((pos).currline + ( ++(pos).x < (pos).width ? (pos).x : ((pos).x = 0))*(cs) ) + +/* up */ +#define CV_MOVE_UP_WRAP( pos, cs ) \ + ((((pos).currline -= (pos).step) != (pos).topline ? \ + (pos).currline : ((pos).currline = (pos).bottomline - (pos).step)) + (pos).x*(cs) ) + +/* down */ +#define CV_MOVE_DOWN_WRAP( pos, cs ) \ + ((((pos).currline += (pos).step) != (pos).bottomline ? \ + (pos).currline : ((pos).currline = (pos).topline + (pos).step)) + (pos).x*(cs) ) + +/* left up */ +#define CV_MOVE_LU_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs)) +/* right up */ +#define CV_MOVE_RU_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs)) +/* left down */ +#define CV_MOVE_LD_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs)) +/* right down */ +#define CV_MOVE_RD_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs)) + +/* Numeric constants which used for moving in arbitrary direction */ +#define CV_SHIFT_NONE 2 +#define CV_SHIFT_LEFT 1 +#define CV_SHIFT_RIGHT 3 +#define CV_SHIFT_UP 6 +#define CV_SHIFT_DOWN 10 +#define CV_SHIFT_LU 5 +#define CV_SHIFT_RU 7 +#define CV_SHIFT_LD 9 +#define CV_SHIFT_RD 11 + +/* Move by one pixel in specified direction */ +/* pos - position structure */ +/* shift - direction ( it's value must be one of the CV_SHIFT_… constants ) */ +/* cs - number of the image channels */ +#define CV_MOVE_PARAM( pos, shift, cs ) \ + ( (pos).currline += (pos).step_arr[(shift)>>2], (pos).x += ((shift)&3)-2, \ + ((pos).currline != (pos).topline && (pos).currline != (pos).bottomline && \ + (pos).x >= 0 && (pos).x < (pos).width) ? (pos).currline + (pos).x*(cs) : 0 ) + +/* Move by one pixel in specified direction with wrapping when the */ +/* position achieves image boundary */ +/* pos - position structure */ +/* shift - direction ( it's value must be one of the CV_SHIFT_… constants ) */ +/* cs - number of the image channels */ +#define CV_MOVE_PARAM_WRAP( pos, shift, cs ) \ + ( (pos).currline += (pos).step_arr[(shift)>>2], \ + (pos).currline = ((pos).currline == (pos).topline ? \ + (pos).bottomline - (pos).step : \ + (pos).currline == (pos).bottomline ? \ + (pos).topline + (pos).step : (pos).currline), \ + \ + (pos).x += ((shift)&3)-2, \ + (pos).x = ((pos).x < 0 ? (pos).width-1 : (pos).x >= (pos).width ? 0 : (pos).x), \ + \ + (pos).currline + (pos).x*(cs) ) + +#endif/*_CVCOMPAT_H_*/ diff --git a/include/opencv/cvhaartraining.h b/include/opencv/cvhaartraining.h new file mode 100755 index 0000000..eb533d3 --- /dev/null +++ b/include/opencv/cvhaartraining.h @@ -0,0 +1,191 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* + * cvhaartraining.h + * + * haar training functions + */ + +#ifndef _CVHAARTRAINING_H_ +#define _CVHAARTRAINING_H_ + +/* + * cvCreateTrainingSamples + * + * Create training samples applying random distortions to sample image and + * store them in .vec file + * + * filename - .vec file name + * imgfilename - sample image file name + * bgcolor - background color for sample image + * bgthreshold - background color threshold. Pixels those colors are in range + * [bgcolor-bgthreshold, bgcolor+bgthreshold] are considered as transparent + * bgfilename - background description file name. If not NULL samples + * will be put on arbitrary background + * count - desired number of samples + * invert - if not 0 sample foreground pixels will be inverted + * if invert == CV_RANDOM_INVERT then samples will be inverted randomly + * maxintensitydev - desired max intensity deviation of foreground samples pixels + * maxxangle - max rotation angles + * maxyangle + * maxzangle + * showsamples - if not 0 samples will be shown + * winwidth - desired samples width + * winheight - desired samples height + */ +#define CV_RANDOM_INVERT 0x7FFFFFFF + +void cvCreateTrainingSamples( const char* filename, + const char* imgfilename, int bgcolor, int bgthreshold, + const char* bgfilename, int count, + int invert = 0, int maxintensitydev = 40, + double maxxangle = 1.1, + double maxyangle = 1.1, + double maxzangle = 0.5, + int showsamples = 0, + int winwidth = 24, int winheight = 24 ); + +void cvCreateTestSamples( const char* infoname, + const char* imgfilename, int bgcolor, int bgthreshold, + const char* bgfilename, int count, + int invert, int maxintensitydev, + double maxxangle, double maxyangle, double maxzangle, + int showsamples, + int winwidth, int winheight ); + +/* + * cvCreateTrainingSamplesFromInfo + * + * Create training samples from a set of marked up images and store them into .vec file + * infoname - file in which marked up image descriptions are stored + * num - desired number of samples + * showsamples - if not 0 samples will be shown + * winwidth - sample width + * winheight - sample height + * + * Return number of successfully created samples + */ +int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename, + int num, + int showsamples, + int winwidth, int winheight ); + +/* + * cvShowVecSamples + * + * Shows samples stored in .vec file + * + * filename + * .vec file name + * winwidth + * sample width + * winheight + * sample height + * scale + * the scale each sample is adjusted to + */ +void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale ); + + +/* + * cvCreateCascadeClassifier + * + * Create cascade classifier + * dirname - directory name in which cascade classifier will be created. + * It must exist and contain subdirectories 0, 1, 2, ... (nstages-1). + * vecfilename - name of .vec file with object's images + * bgfilename - name of background description file + * npos - number of positive samples used in training of each stage + * nneg - number of negative samples used in training of each stage + * nstages - number of stages + * numprecalculated - number of features being precalculated. Each precalculated feature + * requires (number_of_samples*(sizeof( float ) + sizeof( short ))) bytes of memory + * numsplits - number of binary splits in each weak classifier + * 1 - stumps, 2 and more - trees. + * minhitrate - desired min hit rate of each stage + * maxfalsealarm - desired max false alarm of each stage + * weightfraction - weight trimming parameter + * mode - 0 - BASIC = Viola + * 1 - CORE = All upright + * 2 - ALL = All features + * symmetric - if not 0 vertical symmetry is assumed + * equalweights - if not 0 initial weights of all samples will be equal + * winwidth - sample width + * winheight - sample height + * boosttype - type of applied boosting algorithm + * 0 - Discrete AdaBoost + * 1 - Real AdaBoost + * 2 - LogitBoost + * 3 - Gentle AdaBoost + * stumperror - type of used error if Discrete AdaBoost algorithm is applied + * 0 - misclassification error + * 1 - gini error + * 2 - entropy error + */ +void cvCreateCascadeClassifier( const char* dirname, + const char* vecfilename, + const char* bgfilename, + int npos, int nneg, int nstages, + int numprecalculated, + int numsplits, + float minhitrate = 0.995F, float maxfalsealarm = 0.5F, + float weightfraction = 0.95F, + int mode = 0, int symmetric = 1, + int equalweights = 1, + int winwidth = 24, int winheight = 24, + int boosttype = 3, int stumperror = 0 ); + +void cvCreateTreeCascadeClassifier( const char* dirname, + const char* vecfilename, + const char* bgfilename, + int npos, int nneg, int nstages, + int numprecalculated, + int numsplits, + float minhitrate, float maxfalsealarm, + float weightfraction, + int mode, int symmetric, + int equalweights, + int winwidth, int winheight, + int boosttype, int stumperror, + int maxtreesplits, int minpos ); + +#endif /* _CVHAARTRAINING_H_ */ diff --git a/include/opencv/cvtypes.h b/include/opencv/cvtypes.h new file mode 100755 index 0000000..fb7aaf9 --- /dev/null +++ b/include/opencv/cvtypes.h @@ -0,0 +1,384 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CVTYPES_H_ +#define _CVTYPES_H_ + +#ifndef SKIP_INCLUDES + #include + #include +#endif + +/* spatial and central moments */ +typedef struct CvMoments +{ + double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */ + double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */ + double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */ +} +CvMoments; + +/* Hu invariants */ +typedef struct CvHuMoments +{ + double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */ +} +CvHuMoments; + +/**************************** Connected Component **************************************/ + +typedef struct CvConnectedComp +{ + double area; /* area of the connected component */ + CvScalar value; /* average color of the connected component */ + CvRect rect; /* ROI of the component */ + CvSeq* contour; /* optional component boundary + (the contour might have child contours corresponding to the holes)*/ +} +CvConnectedComp; + +/* +Internal structure that is used for sequental retrieving contours from the image. +It supports both hierarchical and plane variants of Suzuki algorithm. +*/ +typedef struct _CvContourScanner* CvContourScanner; + +/* contour retrieval mode */ +#define CV_RETR_EXTERNAL 0 +#define CV_RETR_LIST 1 +#define CV_RETR_CCOMP 2 +#define CV_RETR_TREE 3 + +/* contour approximation method */ +#define CV_CHAIN_CODE 0 +#define CV_CHAIN_APPROX_NONE 1 +#define CV_CHAIN_APPROX_SIMPLE 2 +#define CV_CHAIN_APPROX_TC89_L1 3 +#define CV_CHAIN_APPROX_TC89_KCOS 4 +#define CV_LINK_RUNS 5 + +/* Freeman chain reader state */ +typedef struct CvChainPtReader +{ + CV_SEQ_READER_FIELDS() + char code; + CvPoint pt; + char deltas[8][2]; +} +CvChainPtReader; + +/* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */ +#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \ + ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ + (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ + (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ + (deltas)[6] = (step), (deltas)[7] = (step) + (nch)) + +/* Contour tree header */ +typedef struct CvContourTree +{ + CV_SEQUENCE_FIELDS() + CvPoint p1; /* the first point of the binary tree root segment */ + CvPoint p2; /* the last point of the binary tree root segment */ +} +CvContourTree; + +/* Finds a sequence of convexity defects of given contour */ +typedef struct CvConvexityDefect +{ + CvPoint* start; /* point of the contour where the defect begins */ + CvPoint* end; /* point of the contour where the defect ends */ + CvPoint* depth_point; /* the farthest from the convex hull point within the defect */ + float depth; /* distance between the farthest point and the convex hull */ +} +CvConvexityDefect; + +/************ Data structures and related enumerations for Planar Subdivisions ************/ + +typedef size_t CvSubdiv2DEdge; + +#define CV_QUADEDGE2D_FIELDS() \ + int flags; \ + struct CvSubdiv2DPoint* pt[4]; \ + CvSubdiv2DEdge next[4]; + +#define CV_SUBDIV2D_POINT_FIELDS()\ + int flags; \ + CvSubdiv2DEdge first; \ + CvPoint2D32f pt; + +#define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30) + +typedef struct CvQuadEdge2D +{ + CV_QUADEDGE2D_FIELDS() +} +CvQuadEdge2D; + +typedef struct CvSubdiv2DPoint +{ + CV_SUBDIV2D_POINT_FIELDS() +} +CvSubdiv2DPoint; + +#define CV_SUBDIV2D_FIELDS() \ + CV_GRAPH_FIELDS() \ + int quad_edges; \ + int is_geometry_valid; \ + CvSubdiv2DEdge recent_edge; \ + CvPoint2D32f topleft; \ + CvPoint2D32f bottomright; + +typedef struct CvSubdiv2D +{ + CV_SUBDIV2D_FIELDS() +} +CvSubdiv2D; + + +typedef enum CvSubdiv2DPointLocation +{ + CV_PTLOC_ERROR = -2, + CV_PTLOC_OUTSIDE_RECT = -1, + CV_PTLOC_INSIDE = 0, + CV_PTLOC_VERTEX = 1, + CV_PTLOC_ON_EDGE = 2 +} +CvSubdiv2DPointLocation; + +typedef enum CvNextEdgeType +{ + CV_NEXT_AROUND_ORG = 0x00, + CV_NEXT_AROUND_DST = 0x22, + CV_PREV_AROUND_ORG = 0x11, + CV_PREV_AROUND_DST = 0x33, + CV_NEXT_AROUND_LEFT = 0x13, + CV_NEXT_AROUND_RIGHT = 0x31, + CV_PREV_AROUND_LEFT = 0x20, + CV_PREV_AROUND_RIGHT = 0x02 +} +CvNextEdgeType; + +/* get the next edge with the same origin point (counterwise) */ +#define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3]) + + +/* Defines for Distance Transform */ +#define CV_DIST_USER -1 /* User defined distance */ +#define CV_DIST_L1 1 /* distance = |x1-x2| + |y1-y2| */ +#define CV_DIST_L2 2 /* the simple euclidean distance */ +#define CV_DIST_C 3 /* distance = max(|x1-x2|,|y1-y2|) */ +#define CV_DIST_L12 4 /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */ +#define CV_DIST_FAIR 5 /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */ +#define CV_DIST_WELSCH 6 /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */ +#define CV_DIST_HUBER 7 /* distance = |x|data.fl */ + float* PriorState; /* =state_post->data.fl */ + float* DynamMatr; /* =transition_matrix->data.fl */ + float* MeasurementMatr; /* =measurement_matrix->data.fl */ + float* MNCovariance; /* =measurement_noise_cov->data.fl */ + float* PNCovariance; /* =process_noise_cov->data.fl */ + float* KalmGainMatr; /* =gain->data.fl */ + float* PriorErrorCovariance;/* =error_cov_pre->data.fl */ + float* PosterErrorCovariance;/* =error_cov_post->data.fl */ + float* Temp1; /* temp1->data.fl */ + float* Temp2; /* temp2->data.fl */ +#endif + + CvMat* state_pre; /* predicted state (x'(k)): + x(k)=A*x(k-1)+B*u(k) */ + CvMat* state_post; /* corrected state (x(k)): + x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */ + CvMat* transition_matrix; /* state transition matrix (A) */ + CvMat* control_matrix; /* control matrix (B) + (it is not used if there is no control)*/ + CvMat* measurement_matrix; /* measurement matrix (H) */ + CvMat* process_noise_cov; /* process noise covariance matrix (Q) */ + CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */ + CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)): + P'(k)=A*P(k-1)*At + Q)*/ + CvMat* gain; /* Kalman gain matrix (K(k)): + K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/ + CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)): + P(k)=(I-K(k)*H)*P'(k) */ + CvMat* temp1; /* temporary matrices */ + CvMat* temp2; + CvMat* temp3; + CvMat* temp4; + CvMat* temp5; +} +CvKalman; + + +/*********************** Haar-like Object Detection structures **************************/ +#define CV_HAAR_MAGIC_VAL 0x42500000 +#define CV_TYPE_NAME_HAAR "opencv-haar-classifier" + +#define CV_IS_HAAR_CLASSIFIER( haar ) \ + ((haar) != NULL && \ + (((const CvHaarClassifierCascade*)(haar))->flags & CV_MAGIC_MASK)==CV_HAAR_MAGIC_VAL) + +#define CV_HAAR_FEATURE_MAX 3 + +typedef struct CvHaarFeature +{ + int tilted; + struct + { + CvRect r; + float weight; + } rect[CV_HAAR_FEATURE_MAX]; +} +CvHaarFeature; + +typedef struct CvHaarClassifier +{ + int count; + CvHaarFeature* haar_feature; + float* threshold; + int* left; + int* right; + float* alpha; +} +CvHaarClassifier; + +typedef struct CvHaarStageClassifier +{ + int count; + float threshold; + CvHaarClassifier* classifier; + + int next; + int child; + int parent; +} +CvHaarStageClassifier; + +typedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade; + +typedef struct CvHaarClassifierCascade +{ + int flags; + int count; + CvSize orig_window_size; + CvSize real_window_size; + double scale; + CvHaarStageClassifier* stage_classifier; + CvHidHaarClassifierCascade* hid_cascade; +} +CvHaarClassifierCascade; + +typedef struct CvAvgComp +{ + CvRect rect; + int neighbors; +} +CvAvgComp; + +#endif /*_CVTYPES_H_*/ + +/* End of file. */ diff --git a/include/opencv/cvver.h b/include/opencv/cvver.h new file mode 100755 index 0000000..ac89efe --- /dev/null +++ b/include/opencv/cvver.h @@ -0,0 +1,55 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright( C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +//(including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort(including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* + definition of the current version of OpenCV + Usefull to test in user programs +*/ + +#ifndef _CVVERSION_H_ +#define _CVVERSION_H_ + +#define CV_MAJOR_VERSION 1 +#define CV_MINOR_VERSION 0 +#define CV_SUBMINOR_VERSION 0 +#define CV_VERSION "1.0.0" + +#endif /*_CVVERSION_H_*/ diff --git a/include/opencv/cxcore.h b/include/opencv/cxcore.h new file mode 100755 index 0000000..adbb041 --- /dev/null +++ b/include/opencv/cxcore.h @@ -0,0 +1,1750 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + + +#ifndef _CXCORE_H_ +#define _CXCORE_H_ + +#ifdef __IPL_H__ +#define HAVE_IPL +#endif + +#ifndef SKIP_INCLUDES + #if defined HAVE_IPL && !defined __IPL_H__ + #ifndef _INC_WINDOWS + #define CV_PRETEND_WINDOWS + #define _INC_WINDOWS + typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER; + typedef int BOOL; + #endif + #if defined WIN32 || defined WIN64 + #include "ipl.h" + #else + #include "ipl/ipl.h" + #endif + #ifdef CV_PRETEND_WINDOWS + #undef _INC_WINDOWS + #endif + #endif +#endif // SKIP_INCLUDES + +#include "cxtypes.h" +#include "cxerror.h" +#include "cvver.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Array allocation, deallocation, initialization and access to elements * +\****************************************************************************************/ + +/* wrapper. + If there is no enough memory, the function + (as well as other OpenCV functions that call cvAlloc) + raises an error. */ +CVAPI(void*) cvAlloc( size_t size ); + +/* wrapper. + Here and further all the memory releasing functions + (that all call cvFree) take double pointer in order to + to clear pointer to the data after releasing it. + Passing pointer to NULL pointer is Ok: nothing happens in this case +*/ +CVAPI(void) cvFree_( void* ptr ); +#define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0) + +/* Allocates and initializes IplImage header */ +CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); + +/* Inializes IplImage header */ +CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth, + int channels, int origin CV_DEFAULT(0), + int align CV_DEFAULT(4)); + +/* Creates IPL image (header and data) */ +CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); + +/* Releases (i.e. deallocates) IPL image header */ +CVAPI(void) cvReleaseImageHeader( IplImage** image ); + +/* Releases IPL image header and data */ +CVAPI(void) cvReleaseImage( IplImage** image ); + +/* Creates a copy of IPL image (widthStep may differ) */ +CVAPI(IplImage*) cvCloneImage( const IplImage* image ); + +/* Sets a Channel Of Interest (only a few functions support COI) - + use cvCopy to extract the selected channel and/or put it back */ +CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); + +/* Retrieves image Channel Of Interest */ +CVAPI(int) cvGetImageCOI( const IplImage* image ); + +/* Sets image ROI (region of interest) (COI is not changed) */ +CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); + +/* Resets image ROI and COI */ +CVAPI(void) cvResetImageROI( IplImage* image ); + +/* Retrieves image ROI */ +CVAPI(CvRect) cvGetImageROI( const IplImage* image ); + +/* Allocates and initalizes CvMat header */ +CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); + +#define CV_AUTOSTEP 0x7fffffff + +/* Initializes CvMat header */ +CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols, + int type, void* data CV_DEFAULT(NULL), + int step CV_DEFAULT(CV_AUTOSTEP) ); + +/* Allocates and initializes CvMat header and allocates data */ +CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); + +/* Releases CvMat header and deallocates matrix data + (reference counting is used for data) */ +CVAPI(void) cvReleaseMat( CvMat** mat ); + +/* Decrements CvMat data reference counter and deallocates the data if + it reaches 0 */ +CV_INLINE void cvDecRefData( CvArr* arr ) +{ + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } +} + +/* Increments CvMat data reference counter */ +CV_INLINE int cvIncRefData( CvArr* arr ) +{ + int refcount = 0; + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + return refcount; +} + + +/* Creates an exact copy of the input matrix (except, may be, step value) */ +CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); + + +/* Makes a new matrix from subrectangle of input array. + No data is copied */ +CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); +#define cvGetSubArr cvGetSubRect + +/* Selects row span of the input array: arr(start_row:delta_row:end_row,:) + (end_row is not included into the span). */ +CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat, + int start_row, int end_row, + int delta_row CV_DEFAULT(1)); + +CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) +{ + return cvGetRows( arr, submat, row, row + 1, 1 ); +} + + +/* Selects column span of the input array: arr(:,start_col:end_col) + (end_col is not included into the span) */ +CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat, + int start_col, int end_col ); + +CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col ) +{ + return cvGetCols( arr, submat, col, col + 1 ); +} + +/* Select a diagonal of the input array. + (diag = 0 means the main diagonal, >0 means a diagonal above the main one, + <0 - below the main one). + The diagonal will be represented as a column (nx1 matrix). */ +CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat, + int diag CV_DEFAULT(0)); + +/* low-level scalar <-> raw data conversion functions */ +CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, + int extend_to_12 CV_DEFAULT(0) ); + +CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); + +/* Allocates and initializes CvMatND header */ +CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); + +/* Allocates and initializes CvMatND header and allocates data */ +CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); + +/* Initializes preallocated CvMatND header */ +CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, + int type, void* data CV_DEFAULT(NULL) ); + +/* Releases CvMatND */ +CV_INLINE void cvReleaseMatND( CvMatND** mat ) +{ + cvReleaseMat( (CvMat**)mat ); +} + +/* Creates a copy of CvMatND (except, may be, steps) */ +CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); + +/* Allocates and initializes CvSparseMat header and allocates data */ +CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); + +/* Releases CvSparseMat */ +CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); + +/* Creates a copy of CvSparseMat (except, may be, zero items) */ +CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); + +/* Initializes sparse array iterator + (returns the first node or NULL if the array is empty) */ +CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, + CvSparseMatIterator* mat_iterator ); + +// returns next sparse array node (or NULL if there is no more nodes) +CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator ) +{ + if( mat_iterator->node->next ) + return mat_iterator->node = mat_iterator->node->next; + else + { + int idx; + for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ ) + { + CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx]; + if( node ) + { + mat_iterator->curidx = idx; + return mat_iterator->node = node; + } + } + return NULL; + } +} + +/**************** matrix iterator: used for n-ary operations on dense arrays *********/ + +#define CV_MAX_ARR 10 + +typedef struct CvNArrayIterator +{ + int count; /* number of arrays */ + int dims; /* number of dimensions to iterate */ + CvSize size; /* maximal common linear size: { width = size, height = 1 } */ + uchar* ptr[CV_MAX_ARR]; /* pointers to the array slices */ + int stack[CV_MAX_DIM]; /* for internal use */ + CvMatND* hdr[CV_MAX_ARR]; /* pointers to the headers of the + matrices that are processed */ +} +CvNArrayIterator; + +#define CV_NO_DEPTH_CHECK 1 +#define CV_NO_CN_CHECK 2 +#define CV_NO_SIZE_CHECK 4 + +/* initializes iterator that traverses through several arrays simulteneously + (the function together with cvNextArraySlice is used for + N-ari element-wise operations) */ +CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs, + const CvArr* mask, CvMatND* stubs, + CvNArrayIterator* array_iterator, + int flags CV_DEFAULT(0) ); + +/* returns zero value if iteration is finished, non-zero (slice length) otherwise */ +CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); + + +/* Returns type of array elements: + CV_8UC1 ... CV_64FC4 ... */ +CVAPI(int) cvGetElemType( const CvArr* arr ); + +/* Retrieves number of an array dimensions and + optionally sizes of the dimensions */ +CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) ); + + +/* Retrieves size of a particular array dimension. + For 2d arrays cvGetDimSize(arr,0) returns number of rows (image height) + and cvGetDimSize(arr,1) returns number of columns (image width) */ +CVAPI(int) cvGetDimSize( const CvArr* arr, int index ); + + +/* ptr = &arr(idx0,idx1,...). All indexes are zero-based, + the major dimensions go first (e.g. (y,x) for 2D, (z,y,x) for 3D */ +CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL)); +CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) ); +CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, + int* type CV_DEFAULT(NULL)); + +/* For CvMat or IplImage number of indices should be 2 + (row index (y) goes first, column index (x) goes next). + For CvMatND or CvSparseMat number of infices should match number of and + indices order should match the array dimension order. */ +CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL), + int create_node CV_DEFAULT(1), + unsigned* precalc_hashval CV_DEFAULT(NULL)); + +/* value = arr(idx0,idx1,...) */ +CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 ); +CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 ); +CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx ); + +/* for 1-channel arrays */ +CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 ); +CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 ); +CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx ); + +/* arr(idx0,idx1,...) = value */ +CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value ); +CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value ); +CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); +CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value ); + +/* for 1-channel arrays */ +CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value ); +CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value ); +CVAPI(void) cvSetReal3D( CvArr* arr, int idx0, + int idx1, int idx2, double value ); +CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value ); + +/* clears element of ND dense array, + in case of sparse arrays it deletes the specified node */ +CVAPI(void) cvClearND( CvArr* arr, const int* idx ); + +/* Converts CvArr (IplImage or CvMat,...) to CvMat. + If the last parameter is non-zero, function can + convert multi(>2)-dimensional array to CvMat as long as + the last array's dimension is continous. The resultant + matrix will be have appropriate (a huge) number of rows */ +CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header, + int* coi CV_DEFAULT(NULL), + int allowND CV_DEFAULT(0)); + +/* Converts CvArr (IplImage or CvMat) to IplImage */ +CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header ); + + +/* Changes a shape of multi-dimensional array. + new_cn == 0 means that number of channels remains unchanged. + new_dims == 0 means that number and sizes of dimensions remain the same + (unless they need to be changed to set the new number of channels) + if new_dims == 1, there is no need to specify new dimension sizes + The resultant configuration should be achievable w/o data copying. + If the resultant array is sparse, CvSparseMat header should be passed + to the function else if the result is 1 or 2 dimensional, + CvMat header should be passed to the function + else CvMatND header should be passed */ +CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr, + int sizeof_header, CvArr* header, + int new_cn, int new_dims, int* new_sizes ); + +#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \ + cvReshapeMatND( (arr), sizeof(*(header)), (header), \ + (new_cn), (new_dims), (new_sizes)) + +CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header, + int new_cn, int new_rows CV_DEFAULT(0) ); + +/* Repeats source 2d array several times in both horizontal and + vertical direction to fill destination array */ +CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst ); + +/* Allocates array data */ +CVAPI(void) cvCreateData( CvArr* arr ); + +/* Releases array data */ +CVAPI(void) cvReleaseData( CvArr* arr ); + +/* Attaches user data to the array header. The step is reffered to + the pre-last dimension. That is, all the planes of the array + must be joint (w/o gaps) */ +CVAPI(void) cvSetData( CvArr* arr, void* data, int step ); + +/* Retrieves raw data of CvMat, IplImage or CvMatND. + In the latter case the function raises an error if + the array can not be represented as a matrix */ +CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data, + int* step CV_DEFAULT(NULL), + CvSize* roi_size CV_DEFAULT(NULL)); + +/* Returns width and height of array in elements */ +CVAPI(CvSize) cvGetSize( const CvArr* arr ); + +/* Copies source array to destination array */ +CVAPI(void) cvCopy( const CvArr* src, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL) ); + +/* Sets all or "masked" elements of input array + to the same value*/ +CVAPI(void) cvSet( CvArr* arr, CvScalar value, + const CvArr* mask CV_DEFAULT(NULL) ); + +/* Clears all the array elements (sets them to 0) */ +CVAPI(void) cvSetZero( CvArr* arr ); +#define cvZero cvSetZero + + +/* Splits a multi-channel array into the set of single-channel arrays or + extracts particular [color] plane */ +CVAPI(void) cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1, + CvArr* dst2, CvArr* dst3 ); + +/* Merges a set of single-channel arrays into the single multi-channel array + or inserts one particular [color] plane to the array */ +CVAPI(void) cvMerge( const CvArr* src0, const CvArr* src1, + const CvArr* src2, const CvArr* src3, + CvArr* dst ); + +/* Copies several channels from input arrays to + certain channels of output arrays */ +CVAPI(void) cvMixChannels( const CvArr** src, int src_count, + CvArr** dst, int dst_count, + const int* from_to, int pair_count ); + +/* Performs linear transformation on every source array element: + dst(x,y,c) = scale*src(x,y,c)+shift. + Arbitrary combination of input and output array depths are allowed + (number of channels must be the same), thus the function can be used + for type conversion */ +CVAPI(void) cvConvertScale( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScale cvConvertScale +#define cvScale cvConvertScale +#define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 ) + + +/* Performs linear transformation on every source array element, + stores absolute value of the result: + dst(x,y,c) = abs(scale*src(x,y,c)+shift). + destination array must have 8u type. + In other cases one may use cvConvertScale + cvAbsDiffS */ +CVAPI(void) cvConvertScaleAbs( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScaleAbs cvConvertScaleAbs + + +/* checks termination criteria validity and + sets eps to default_eps (if it is not set), + max_iter to default_max_iters (if it is not set) +*/ +CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria, + double default_eps, + int default_max_iters ); + +/****************************************************************************************\ +* Arithmetic, logic and comparison operations * +\****************************************************************************************/ + +/* dst(mask) = src1(mask) + src2(mask) */ +CVAPI(void) cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(mask) = src(mask) + value */ +CVAPI(void) cvAddS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(mask) = src1(mask) - src2(mask) */ +CVAPI(void) cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(mask) = src(mask) - value = src(mask) + (-value) */ +CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)) +{ + cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]), + dst, mask ); +} + +/* dst(mask) = value - src(mask) */ +CVAPI(void) cvSubRS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src1(idx) * src2(idx) * scale + (scaled element-wise multiplication of 2 arrays) */ +CVAPI(void) cvMul( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1) ); + +/* element-wise division/inversion with scaling: + dst(idx) = src1(idx) * scale / src2(idx) + or dst(idx) = scale / src2(idx) if src1 == 0 */ +CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1)); + +/* dst = src1 * scale + src2 */ +CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale, + const CvArr* src2, CvArr* dst ); +#define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C) + +/* dst = src1 * alpha + src2 * beta + gamma */ +CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha, + const CvArr* src2, double beta, + double gamma, CvArr* dst ); + +/* result = sum_i(src1(i) * src2(i)) (results for all channels are accumulated together) */ +CVAPI(double) cvDotProduct( const CvArr* src1, const CvArr* src2 ); + +/* dst(idx) = src1(idx) & src2(idx) */ +CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src(idx) & value */ +CVAPI(void) cvAndS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src1(idx) | src2(idx) */ +CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src(idx) | value */ +CVAPI(void) cvOrS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src1(idx) ^ src2(idx) */ +CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src(idx) ^ value */ +CVAPI(void) cvXorS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = ~src(idx) */ +CVAPI(void) cvNot( const CvArr* src, CvArr* dst ); + +/* dst(idx) = lower(idx) <= src(idx) < upper(idx) */ +CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower, + const CvArr* upper, CvArr* dst ); + +/* dst(idx) = lower <= src(idx) < upper */ +CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower, + CvScalar upper, CvArr* dst ); + +#define CV_CMP_EQ 0 +#define CV_CMP_GT 1 +#define CV_CMP_GE 2 +#define CV_CMP_LT 3 +#define CV_CMP_LE 4 +#define CV_CMP_NE 5 + +/* The comparison operation support single-channel arrays only. + Destination image should be 8uC1 or 8sC1 */ + +/* dst(idx) = src1(idx) _cmp_op_ src2(idx) */ +CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op ); + +/* dst(idx) = src1(idx) _cmp_op_ value */ +CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op ); + +/* dst(idx) = min(src1(idx),src2(idx)) */ +CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* dst(idx) = max(src1(idx),src2(idx)) */ +CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* dst(idx) = min(src(idx),value) */ +CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst ); + +/* dst(idx) = max(src(idx),value) */ +CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst ); + +/* dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */ +CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* dst(x,y,c) = abs(src(x,y,c) - value(c)) */ +CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); +#define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0)) + +/****************************************************************************************\ +* Math operations * +\****************************************************************************************/ + +/* Does cartesian->polar coordinates conversion. + Either of output components (magnitude or angle) is optional */ +CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y, + CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL), + int angle_in_degrees CV_DEFAULT(0)); + +/* Does polar->cartesian coordinates conversion. + Either of output components (magnitude or angle) is optional. + If magnitude is missing it is assumed to be all 1's */ +CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle, + CvArr* x, CvArr* y, + int angle_in_degrees CV_DEFAULT(0)); + +/* Does powering: dst(idx) = src(idx)^power */ +CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power ); + +/* Does exponention: dst(idx) = exp(src(idx)). + Overflow is not handled yet. Underflow is handled. + Maximal relative error is ~7e-6 for single-precision input */ +CVAPI(void) cvExp( const CvArr* src, CvArr* dst ); + +/* Calculates natural logarithms: dst(idx) = log(abs(src(idx))). + Logarithm of 0 gives large negative number(~-700) + Maximal relative error is ~3e-7 for single-precision output +*/ +CVAPI(void) cvLog( const CvArr* src, CvArr* dst ); + +/* Fast arctangent calculation */ +CVAPI(float) cvFastArctan( float y, float x ); + +/* Fast cubic root calculation */ +CVAPI(float) cvCbrt( float value ); + +/* Checks array values for NaNs, Infs or simply for too large numbers + (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set, + no runtime errors is raised (function returns zero value in case of "bad" values). + Otherwise cvError is called */ +#define CV_CHECK_RANGE 1 +#define CV_CHECK_QUIET 2 +CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), + double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0)); +#define cvCheckArray cvCheckArr + +#define CV_RAND_UNI 0 +#define CV_RAND_NORMAL 1 +CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, + CvScalar param1, CvScalar param2 ); + +CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, + double iter_factor CV_DEFAULT(1.)); + +/* Finds real roots of a cubic equation */ +CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots ); + +/****************************************************************************************\ +* Matrix operations * +\****************************************************************************************/ + +/* Calculates cross product of two 3d vectors */ +CVAPI(void) cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* Matrix transform: dst = A*B + C, C is optional */ +#define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 ) +#define cvMatMul( src1, src2, dst ) cvMatMulAdd( (src1), (src2), NULL, (dst)) + +#define CV_GEMM_A_T 1 +#define CV_GEMM_B_T 2 +#define CV_GEMM_C_T 4 +/* Extended matrix transform: + dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */ +CVAPI(void) cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, + const CvArr* src3, double beta, CvArr* dst, + int tABC CV_DEFAULT(0)); +#define cvMatMulAddEx cvGEMM + +/* Transforms each element of source array and stores + resultant vectors in destination array */ +CVAPI(void) cvTransform( const CvArr* src, CvArr* dst, + const CvMat* transmat, + const CvMat* shiftvec CV_DEFAULT(NULL)); +#define cvMatMulAddS cvTransform + +/* Does perspective transform on every element of input array */ +CVAPI(void) cvPerspectiveTransform( const CvArr* src, CvArr* dst, + const CvMat* mat ); + +/* Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */ +CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order, + const CvArr* delta CV_DEFAULT(NULL), + double scale CV_DEFAULT(1.) ); + +/* Tranposes matrix. Square matrices can be transposed in-place */ +CVAPI(void) cvTranspose( const CvArr* src, CvArr* dst ); +#define cvT cvTranspose + + +/* Mirror array data around horizontal (flip=0), + vertical (flip=1) or both(flip=-1) axises: + cvFlip(src) flips images vertically and sequences horizontally (inplace) */ +CVAPI(void) cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), + int flip_mode CV_DEFAULT(0)); +#define cvMirror cvFlip + + +#define CV_SVD_MODIFY_A 1 +#define CV_SVD_U_T 2 +#define CV_SVD_V_T 4 + +/* Performs Singular Value Decomposition of a matrix */ +CVAPI(void) cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL), + CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0)); + +/* Performs Singular Value Back Substitution (solves A*X = B): + flags must be the same as in cvSVD */ +CVAPI(void) cvSVBkSb( const CvArr* W, const CvArr* U, + const CvArr* V, const CvArr* B, + CvArr* X, int flags ); + +#define CV_LU 0 +#define CV_SVD 1 +#define CV_SVD_SYM 2 +/* Inverts matrix */ +CVAPI(double) cvInvert( const CvArr* src, CvArr* dst, + int method CV_DEFAULT(CV_LU)); +#define cvInv cvInvert + +/* Solves linear system (src1)*(dst) = (src2) + (returns 0 if src1 is a singular and CV_LU method is used) */ +CVAPI(int) cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst, + int method CV_DEFAULT(CV_LU)); + +/* Calculates determinant of input matrix */ +CVAPI(double) cvDet( const CvArr* mat ); + +/* Calculates trace of the matrix (sum of elements on the main diagonal) */ +CVAPI(CvScalar) cvTrace( const CvArr* mat ); + +/* Finds eigen values and vectors of a symmetric matrix */ +CVAPI(void) cvEigenVV( CvArr* mat, CvArr* evects, + CvArr* evals, double eps CV_DEFAULT(0)); + +/* Makes an identity matrix (mat_ij = i == j) */ +CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) ); + +/* Fills matrix with given range of numbers */ +CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end ); + +/* Calculates covariation matrix for a set of vectors */ +/* transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */ +#define CV_COVAR_SCRAMBLED 0 + +/* [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */ +#define CV_COVAR_NORMAL 1 + +/* do not calc average (i.e. mean vector) - use the input vector instead + (useful for calculating covariance matrix by parts) */ +#define CV_COVAR_USE_AVG 2 + +/* scale the covariance matrix coefficients by number of the vectors */ +#define CV_COVAR_SCALE 4 + +/* all the input vectors are stored in a single matrix, as its rows */ +#define CV_COVAR_ROWS 8 + +/* all the input vectors are stored in a single matrix, as its columns */ +#define CV_COVAR_COLS 16 + +CVAPI(void) cvCalcCovarMatrix( const CvArr** vects, int count, + CvArr* cov_mat, CvArr* avg, int flags ); + +#define CV_PCA_DATA_AS_ROW 0 +#define CV_PCA_DATA_AS_COL 1 +#define CV_PCA_USE_AVG 2 +CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean, + CvArr* eigenvals, CvArr* eigenvects, int flags ); + +CVAPI(void) cvProjectPCA( const CvArr* data, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +CVAPI(void) cvBackProjectPCA( const CvArr* proj, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +/* Calculates Mahalanobis(weighted) distance */ +CVAPI(double) cvMahalanobis( const CvArr* vec1, const CvArr* vec2, CvArr* mat ); +#define cvMahalonobis cvMahalanobis + +/****************************************************************************************\ +* Array Statistics * +\****************************************************************************************/ + +/* Finds sum of array elements */ +CVAPI(CvScalar) cvSum( const CvArr* arr ); + +/* Calculates number of non-zero pixels */ +CVAPI(int) cvCountNonZero( const CvArr* arr ); + +/* Calculates mean value of array elements */ +CVAPI(CvScalar) cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) ); + +/* Calculates mean and standard deviation of pixel values */ +CVAPI(void) cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev, + const CvArr* mask CV_DEFAULT(NULL) ); + +/* Finds global minimum, maximum and their positions */ +CVAPI(void) cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val, + CvPoint* min_loc CV_DEFAULT(NULL), + CvPoint* max_loc CV_DEFAULT(NULL), + const CvArr* mask CV_DEFAULT(NULL) ); + +/* types of array norm */ +#define CV_C 1 +#define CV_L1 2 +#define CV_L2 4 +#define CV_NORM_MASK 7 +#define CV_RELATIVE 8 +#define CV_DIFF 16 +#define CV_MINMAX 32 + +#define CV_DIFF_C (CV_DIFF | CV_C) +#define CV_DIFF_L1 (CV_DIFF | CV_L1) +#define CV_DIFF_L2 (CV_DIFF | CV_L2) +#define CV_RELATIVE_C (CV_RELATIVE | CV_C) +#define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1) +#define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2) + +/* Finds norm, difference norm or relative difference norm for an array (or two arrays) */ +CVAPI(double) cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + +CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst, + double a CV_DEFAULT(1.), double b CV_DEFAULT(0.), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + + +#define CV_REDUCE_SUM 0 +#define CV_REDUCE_AVG 1 +#define CV_REDUCE_MAX 2 +#define CV_REDUCE_MIN 3 + +CVAPI(void) cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1), + int op CV_DEFAULT(CV_REDUCE_SUM) ); + +/****************************************************************************************\ +* Discrete Linear Transforms and Related Functions * +\****************************************************************************************/ + +#define CV_DXT_FORWARD 0 +#define CV_DXT_INVERSE 1 +#define CV_DXT_SCALE 2 /* divide result by size of array */ +#define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE) +#define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE +#define CV_DXT_ROWS 4 /* transform each row individually */ +#define CV_DXT_MUL_CONJ 8 /* conjugate the second argument of cvMulSpectrums */ + +/* Discrete Fourier Transform: + complex->complex, + real->ccs (forward), + ccs->real (inverse) */ +CVAPI(void) cvDFT( const CvArr* src, CvArr* dst, int flags, + int nonzero_rows CV_DEFAULT(0) ); +#define cvFFT cvDFT + +/* Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) */ +CVAPI(void) cvMulSpectrums( const CvArr* src1, const CvArr* src2, + CvArr* dst, int flags ); + +/* Finds optimal DFT vector size >= size0 */ +CVAPI(int) cvGetOptimalDFTSize( int size0 ); + +/* Discrete Cosine Transform */ +CVAPI(void) cvDCT( const CvArr* src, CvArr* dst, int flags ); + +/****************************************************************************************\ +* Dynamic data structures * +\****************************************************************************************/ + +/* Calculates length of sequence slice (with support of negative indices). */ +CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq ); + + +/* Creates new memory storage. + block_size == 0 means that default, + somewhat optimal size, is used (currently, it is 64K) */ +CVAPI(CvMemStorage*) cvCreateMemStorage( int block_size CV_DEFAULT(0)); + + +/* Creates a memory storage that will borrow memory blocks from parent storage */ +CVAPI(CvMemStorage*) cvCreateChildMemStorage( CvMemStorage* parent ); + + +/* Releases memory storage. All the children of a parent must be released before + the parent. A child storage returns all the blocks to parent when it is released */ +CVAPI(void) cvReleaseMemStorage( CvMemStorage** storage ); + + +/* Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) + to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... + do not free any memory. + A child storage returns all the blocks to the parent when it is cleared */ +CVAPI(void) cvClearMemStorage( CvMemStorage* storage ); + +/* Remember a storage "free memory" position */ +CVAPI(void) cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos ); + +/* Restore a storage "free memory" position */ +CVAPI(void) cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos ); + +/* Allocates continuous buffer of the specified size in the storage */ +CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); + +/* Allocates string in memory storage */ +CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, + int len CV_DEFAULT(-1) ); + +/* Creates new empty sequence that will reside in the specified storage */ +CVAPI(CvSeq*) cvCreateSeq( int seq_flags, int header_size, + int elem_size, CvMemStorage* storage ); + +/* Changes default size (granularity) of sequence blocks. + The default size is ~1Kbyte */ +CVAPI(void) cvSetSeqBlockSize( CvSeq* seq, int delta_elems ); + + +/* Adds new element to the end of sequence. Returns pointer to the element */ +CVAPI(char*) cvSeqPush( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/* Adds new element to the beginning of sequence. Returns pointer to it */ +CVAPI(char*) cvSeqPushFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/* Removes the last element from sequence and optionally saves it */ +CVAPI(void) cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/* Removes the first element from sequence and optioanally saves it */ +CVAPI(void) cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +#define CV_FRONT 1 +#define CV_BACK 0 +/* Adds several new elements to the end of sequence */ +CVAPI(void) cvSeqPushMulti( CvSeq* seq, void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/* Removes several elements from the end of sequence and optionally saves them */ +CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/* Inserts a new element in the middle of sequence. + cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */ +CVAPI(char*) cvSeqInsert( CvSeq* seq, int before_index, + void* element CV_DEFAULT(NULL)); + +/* Removes specified sequence element */ +CVAPI(void) cvSeqRemove( CvSeq* seq, int index ); + + +/* Removes all the elements from the sequence. The freed memory + can be reused later only by the same sequence unless cvClearMemStorage + or cvRestoreMemStoragePos is called */ +CVAPI(void) cvClearSeq( CvSeq* seq ); + + +/* Retrives pointer to specified sequence element. + Negative indices are supported and mean counting from the end + (e.g -1 means the last sequence element) */ +CVAPI(char*) cvGetSeqElem( const CvSeq* seq, int index ); + +/* Calculates index of the specified sequence element. + Returns -1 if element does not belong to the sequence */ +CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element, + CvSeqBlock** block CV_DEFAULT(NULL) ); + +/* Initializes sequence writer. The new elements will be added to the end of sequence */ +CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer ); + + +/* Combination of cvCreateSeq and cvStartAppendToSeq */ +CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size, + int elem_size, CvMemStorage* storage, + CvSeqWriter* writer ); + +/* Closes sequence writer, updates sequence header and returns pointer + to the resultant sequence + (which may be useful if the sequence was created using cvStartWriteSeq)) +*/ +CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer ); + + +/* Updates sequence header. May be useful to get access to some of previously + written elements via cvGetSeqElem or sequence reader */ +CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer ); + + +/* Initializes sequence reader. + The sequence can be read in forward or backward direction */ +CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, + int reverse CV_DEFAULT(0) ); + + +/* Returns current sequence reader position (currently observed sequence element) */ +CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader ); + + +/* Changes sequence reader position. It may seek to an absolute or + to relative to the current position */ +CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index, + int is_relative CV_DEFAULT(0)); + +/* Copies sequence content to a continuous piece of memory */ +CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) ); + +/* Creates sequence header for array. + After that all the operations on sequences that do not alter the content + can be applied to the resultant sequence */ +CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size, + int elem_size, void* elements, int total, + CvSeq* seq, CvSeqBlock* block ); + +/* Extracts sequence slice (with or without copying sequence elements) */ +CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice, + CvMemStorage* storage CV_DEFAULT(NULL), + int copy_data CV_DEFAULT(0)); + +CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL)) +{ + return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 ); +} + +/* Removes sequence slice */ +CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ); + +/* Inserts a sequence or array into another sequence */ +CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); + +/* a < b ? -1 : a > b ? 1 : 0 */ +typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata ); + +/* Sorts sequence in-place given element comparison function */ +CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) ); + +/* Finds element in a [sorted] sequence */ +CVAPI(char*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func, + int is_sorted, int* elem_idx, + void* userdata CV_DEFAULT(NULL) ); + +/* Reverses order of sequence elements in-place */ +CVAPI(void) cvSeqInvert( CvSeq* seq ); + +/* Splits sequence into one or more equivalence classes using the specified criteria */ +CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, + CvSeq** labels, CvCmpFunc is_equal, void* userdata ); + +/************ Internal sequence functions ************/ +CVAPI(void) cvChangeSeqBlock( void* reader, int direction ); +CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer ); + + +/* Creates a new set */ +CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size, + int elem_size, CvMemStorage* storage ); + +/* Adds new element to the set and returns pointer to it */ +CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL), + CvSetElem** inserted_elem CV_DEFAULT(NULL) ); + +/* Fast variant of cvSetAdd */ +CV_INLINE CvSetElem* cvSetNew( CvSet* set_header ) +{ + CvSetElem* elem = set_header->free_elems; + if( elem ) + { + set_header->free_elems = elem->next_free; + elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK; + set_header->active_count++; + } + else + cvSetAdd( set_header, NULL, (CvSetElem**)&elem ); + return elem; +} + +/* Removes set element given its pointer */ +CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem ) +{ + CvSetElem* _elem = (CvSetElem*)elem; + assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ ); + _elem->next_free = set_header->free_elems; + _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG; + set_header->free_elems = _elem; + set_header->active_count--; +} + +/* Removes element from the set by its index */ +CVAPI(void) cvSetRemove( CvSet* set_header, int index ); + +/* Returns a set element by index. If the element doesn't belong to the set, + NULL is returned */ +CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int index ) +{ + CvSetElem* elem = (CvSetElem*)cvGetSeqElem( (CvSeq*)set_header, index ); + return elem && CV_IS_SET_ELEM( elem ) ? elem : 0; +} + +/* Removes all the elements from the set */ +CVAPI(void) cvClearSet( CvSet* set_header ); + +/* Creates new graph */ +CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size, + int vtx_size, int edge_size, + CvMemStorage* storage ); + +/* Adds new vertex to the graph */ +CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL), + CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) ); + + +/* Removes vertex from the graph together with all incident edges */ +CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index ); +CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx ); + + +/* Link two vertices specifed by indices or pointers if they + are not connected or return pointer to already existing edge + connecting the vertices. + Functions return 1 if a new edge was created, 0 otherwise */ +CVAPI(int) cvGraphAddEdge( CvGraph* graph, + int start_idx, int end_idx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph, + CvGraphVtx* start_vtx, CvGraphVtx* end_vtx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +/* Remove edge connecting two vertices */ +CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx ); +CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, + CvGraphVtx* end_vtx ); + +/* Find edge connecting two vertices */ +CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx ); +CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph, + const CvGraphVtx* start_vtx, + const CvGraphVtx* end_vtx ); +#define cvGraphFindEdge cvFindGraphEdge +#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr + +/* Remove all vertices and edges from the graph */ +CVAPI(void) cvClearGraph( CvGraph* graph ); + + +/* Count number of edges incident to the vertex */ +CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx ); +CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx ); + + +/* Retrieves graph vertex by given index */ +#define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx)) + +/* Retrieves index of a graph vertex given its pointer */ +#define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK) + +/* Retrieves index of a graph edge given its pointer */ +#define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK) + +#define cvGraphGetVtxCount( graph ) ((graph)->active_count) +#define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count) + +#define CV_GRAPH_VERTEX 1 +#define CV_GRAPH_TREE_EDGE 2 +#define CV_GRAPH_BACK_EDGE 4 +#define CV_GRAPH_FORWARD_EDGE 8 +#define CV_GRAPH_CROSS_EDGE 16 +#define CV_GRAPH_ANY_EDGE 30 +#define CV_GRAPH_NEW_TREE 32 +#define CV_GRAPH_BACKTRACKING 64 +#define CV_GRAPH_OVER -1 + +#define CV_GRAPH_ALL_ITEMS -1 + +/* flags for graph vertices and edges */ +#define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30) +#define CV_IS_GRAPH_VERTEX_VISITED(vtx) \ + (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_IS_GRAPH_EDGE_VISITED(edge) \ + (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29) +#define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28) + +typedef struct CvGraphScanner +{ + CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */ + CvGraphVtx* dst; /* current graph edge destination vertex */ + CvGraphEdge* edge; /* current edge */ + + CvGraph* graph; /* the graph */ + CvSeq* stack; /* the graph vertex stack */ + int index; /* the lower bound of certainly visited vertices */ + int mask; /* event mask */ +} +CvGraphScanner; + +/* Creates new graph scanner. */ +CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph, + CvGraphVtx* vtx CV_DEFAULT(NULL), + int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)); + +/* Releases graph scanner. */ +CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner ); + +/* Get next graph element */ +CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner ); + +/* Creates a copy of graph */ +CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ); + +/****************************************************************************************\ +* Drawing * +\****************************************************************************************/ + +/****************************************************************************************\ +* Drawing functions work with images/matrices of arbitrary type. * +* For color images the channel order is BGR[A] * +* Antialiasing is supported only for 8-bit image now. * +* All the functions include parameter color that means rgb value (that may be * +* constructed with CV_RGB macro) for color images and brightness * +* for grayscale images. * +* If a drawn figure is partially or completely outside of the image, it is clipped.* +\****************************************************************************************/ + +#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 ) +#define CV_FILLED -1 + +#define CV_AA 16 + +/* Draws 4-connected, 8-connected or antialiased line segment connecting two points */ +CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/* Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2), + if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn */ +CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + int shift CV_DEFAULT(0)); + +/* Draws a circle with specified center and radius. + Thickness works in the same way as with cvRectangle */ +CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/* Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector, + depending on , and parameters. The resultant figure + is rotated by . All the angles are in degrees */ +CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, + double angle, double start_angle, double end_angle, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color, + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ) +{ + CvSize axes; + axes.width = cvRound(box.size.height*0.5); + axes.height = cvRound(box.size.width*0.5); + + cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle, + 0, 360, color, thickness, line_type, shift ); +} + +/* Fills convex or monotonous polygon. */ +CVAPI(void) cvFillConvexPoly( CvArr* img, CvPoint* pts, int npts, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/* Fills an area bounded by one or more arbitrary polygons */ +CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, int* npts, int contours, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/* Draws one or more polygonal curves */ +CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours, + int is_closed, CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +#define cvDrawRect cvRectangle +#define cvDrawLine cvLine +#define cvDrawCircle cvCircle +#define cvDrawEllipse cvEllipse +#define cvDrawPolyLine cvPolyLine + +/* Clips the line segment connecting *pt1 and *pt2 + by the rectangular window + (0<=xptr will point + to pt1 (or pt2, see left_to_right description) location in the image. + Returns the number of pixels on the line between the ending points. */ +CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2, + CvLineIterator* line_iterator, + int connectivity CV_DEFAULT(8), + int left_to_right CV_DEFAULT(0)); + +/* Moves iterator to the next line point */ +#define CV_NEXT_LINE_POINT( line_iterator ) \ +{ \ + int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \ + (line_iterator).err += (line_iterator).minus_delta + \ + ((line_iterator).plus_delta & _line_iterator_mask); \ + (line_iterator).ptr += (line_iterator).minus_step + \ + ((line_iterator).plus_step & _line_iterator_mask); \ +} + + +/* basic font types */ +#define CV_FONT_HERSHEY_SIMPLEX 0 +#define CV_FONT_HERSHEY_PLAIN 1 +#define CV_FONT_HERSHEY_DUPLEX 2 +#define CV_FONT_HERSHEY_COMPLEX 3 +#define CV_FONT_HERSHEY_TRIPLEX 4 +#define CV_FONT_HERSHEY_COMPLEX_SMALL 5 +#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6 +#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7 + +/* font flags */ +#define CV_FONT_ITALIC 16 + +#define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX + +/* Font structure */ +typedef struct CvFont +{ + int font_face; /* =CV_FONT_* */ + const int* ascii; /* font data and metrics */ + const int* greek; + const int* cyrillic; + float hscale, vscale; + float shear; /* slope coefficient: 0 - normal, >0 - italic */ + int thickness; /* letters thickness */ + float dx; /* horizontal interval between letters */ + int line_type; +} +CvFont; + +/* Initializes font structure used further in cvPutText */ +CVAPI(void) cvInitFont( CvFont* font, int font_face, + double hscale, double vscale, + double shear CV_DEFAULT(0), + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8)); + +CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) ) +{ + CvFont font; + cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA ); + return font; +} + +/* Renders text stroke with specified font and color at specified location. + CvFont should be initialized with cvInitFont */ +CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org, + const CvFont* font, CvScalar color ); + +/* Calculates bounding box of text stroke (useful for alignment) */ +CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font, + CvSize* text_size, int* baseline ); + +/* Unpacks color value, if arrtype is CV_8UC?, is treated as + packed color value, otherwise the first channels (depending on arrtype) + of destination scalar are set to the same value = */ +CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype ); + +/* Returns the polygon points which make up the given ellipse. The ellipse is define by + the box of size 'axes' rotated 'angle' around the 'center'. A partial sweep + of the ellipse arc can be done by spcifying arc_start and arc_end to be something + other than 0 and 360, respectively. The input array 'pts' must be large enough to + hold the result. The total number of points stored into 'pts' is returned by this + function. */ +CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes, + int angle, int arc_start, int arc_end, CvPoint * pts, int delta ); + +/* Draws contour outlines or filled interiors on the image */ +CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, + CvScalar external_color, CvScalar hole_color, + int max_level, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + CvPoint offset CV_DEFAULT(cvPoint(0,0))); + +/* Does look-up transformation. Elements of the source array + (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */ +CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut ); + + +/******************* Iteration through the sequence tree *****************/ +typedef struct CvTreeNodeIterator +{ + const void* node; + int level; + int max_level; +} +CvTreeNodeIterator; + +CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, + const void* first, int max_level ); +CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator ); +CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator ); + +/* Inserts sequence into tree with specified "parent" sequence. + If parent is equal to frame (e.g. the most external contour), + then added contour will have null pointer to parent. */ +CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame ); + +/* Removes contour from tree (together with the contour children). */ +CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame ); + +/* Gathers pointers to all the sequences, + accessible from the , to the single sequence */ +CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, + CvMemStorage* storage ); + +/* The function implements the K-means algorithm for clustering an array of sample + vectors in a specified number of classes */ +CVAPI(void) cvKMeans2( const CvArr* samples, int cluster_count, + CvArr* labels, CvTermCriteria termcrit ); + +/****************************************************************************************\ +* System functions * +\****************************************************************************************/ + +/* Add the function pointers table with associated information to the IPP primitives list */ +CVAPI(int) cvRegisterModule( const CvModuleInfo* module_info ); + +/* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ +CVAPI(int) cvUseOptimized( int on_off ); + +/* Retrieves information about the registered modules and loaded optimized plugins */ +CVAPI(void) cvGetModuleInfo( const char* module_name, + const char** version, + const char** loaded_addon_plugins ); + +/* Get current OpenCV error status */ +CVAPI(int) cvGetErrStatus( void ); + +/* Sets error status silently */ +CVAPI(void) cvSetErrStatus( int status ); + +#define CV_ErrModeLeaf 0 /* Print error and exit program */ +#define CV_ErrModeParent 1 /* Print error and continue */ +#define CV_ErrModeSilent 2 /* Don't print and continue */ + +/* Retrives current error processing mode */ +CVAPI(int) cvGetErrMode( void ); + +/* Sets error processing mode, returns previously used mode */ +CVAPI(int) cvSetErrMode( int mode ); + +/* Sets error status and performs some additonal actions (displaying message box, + writing message to stderr, terminating application etc.) + depending on the current error mode */ +CVAPI(void) cvError( int status, const char* func_name, + const char* err_msg, const char* file_name, int line ); + +/* Retrieves textual description of the error given its code */ +CVAPI(const char*) cvErrorStr( int status ); + +/* Retrieves detailed information about the last error occured */ +CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, + const char** filename, int* line ); + +/* Maps IPP error codes to the counterparts from OpenCV */ +CVAPI(int) cvErrorFromIppStatus( int ipp_status ); + +typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, int line, void* userdata ); + +/* Assigns a new error-handling function */ +CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, + void* userdata CV_DEFAULT(NULL), + void** prev_userdata CV_DEFAULT(NULL) ); + +/* + Output to: + cvNulDevReport - nothing + cvStdErrReport - console(fprintf(stderr,...)) + cvGuiBoxReport - MessageBox(WIN32) +*/ +CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +typedef void* (CV_CDECL *CvAllocFunc)(size_t size, void* userdata); +typedef int (CV_CDECL *CvFreeFunc)(void* pptr, void* userdata); + +/* Set user-defined memory managment functions (substitutors for malloc and free) that + will be called by cvAlloc, cvFree and higher-level functions (e.g. cvCreateImage) */ +CVAPI(void) cvSetMemoryManager( CvAllocFunc alloc_func CV_DEFAULT(NULL), + CvFreeFunc free_func CV_DEFAULT(NULL), + void* userdata CV_DEFAULT(NULL)); + + +typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) + (int,int,int,char*,char*,int,int,int,int,int, + IplROI*,IplImage*,void*,IplTileInfo*); +typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int); +typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int); +typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int); +typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*); + +/* Makes OpenCV use IPL functions for IplImage allocation/deallocation */ +CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, + Cv_iplAllocateImageData allocate_data, + Cv_iplDeallocate deallocate, + Cv_iplCreateROI create_roi, + Cv_iplCloneImage clone_image ); + +#define CV_TURN_ON_IPL_COMPATIBILITY() \ + cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ + iplDeallocate, iplCreateROI, iplCloneImage ) + +/****************************************************************************************\ +* Data Persistence * +\****************************************************************************************/ + +/********************************** High-level functions ********************************/ + +/* opens existing or creates new file storage */ +CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, + CvMemStorage* memstorage, + int flags ); + +/* closes file storage and deallocates buffers */ +CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs ); + +/* returns attribute value or 0 (NULL) if there is no such attribute */ +CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name ); + +/* starts writing compound structure (map or sequence) */ +CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name, + int struct_flags, const char* type_name CV_DEFAULT(NULL), + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/* finishes writing compound structure */ +CVAPI(void) cvEndWriteStruct( CvFileStorage* fs ); + +/* writes an integer */ +CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value ); + +/* writes a floating-point number */ +CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value ); + +/* writes a string */ +CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name, + const char* str, int quote CV_DEFAULT(0) ); + +/* writes a comment */ +CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment, + int eol_comment ); + +/* writes instance of a standard type (matrix, image, sequence, graph etc.) + or user-defined type */ +CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr, + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/* starts the next stream */ +CVAPI(void) cvStartNextStream( CvFileStorage* fs ); + +/* helper function: writes multiple integer or floating-point numbers */ +CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src, + int len, const char* dt ); + +/* returns the hash entry corresponding to the specified literal key string or 0 + if there is no such a key in the storage */ +CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name, + int len CV_DEFAULT(-1), + int create_missing CV_DEFAULT(0)); + +/* returns file node with the specified key within the specified map + (collection of named nodes) */ +CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs, + int stream_index CV_DEFAULT(0) ); + +/* returns file node with the specified key within the specified map + (collection of named nodes) */ +CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map, + const CvStringHashNode* key, + int create_missing CV_DEFAULT(0) ); + +/* this is a slower version of cvGetFileNode that takes the key as a literal string */ +CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs, + const CvFileNode* map, + const char* name ); + +CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? node->data.i : + CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff; +} + + +CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, int default_value CV_DEFAULT(0) ) +{ + return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? (double)node->data.i : + CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300; +} + + +CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, double default_value CV_DEFAULT(0.) ) +{ + return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +CV_INLINE const char* cvReadString( const CvFileNode* node, + const char* default_value CV_DEFAULT(NULL) ) +{ + return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0; +} + + +CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, const char* default_value CV_DEFAULT(NULL) ) +{ + return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +/* decodes standard or user-defined object and returns it */ +CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node, + CvAttrList* attributes CV_DEFAULT(NULL)); + +/* decodes standard or user-defined object and returns it */ +CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map, + const char* name, CvAttrList* attributes CV_DEFAULT(NULL) ) +{ + return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes ); +} + + +/* starts reading data from sequence or scalar numeric node */ +CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, + CvSeqReader* reader ); + +/* reads multiple numbers and stores them to array */ +CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, + int count, void* dst, const char* dt ); + +/* combination of two previous functions for easier reading of whole sequences */ +CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, + void* dst, const char* dt ); + +/* writes a copy of file node to file storage */ +CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, + const CvFileNode* node, int embed ); + +/* returns name of file node */ +CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node ); + +/*********************************** Adding own types ***********************************/ + +CVAPI(void) cvRegisterType( const CvTypeInfo* info ); +CVAPI(void) cvUnregisterType( const char* type_name ); +CVAPI(CvTypeInfo*) cvFirstType(void); +CVAPI(CvTypeInfo*) cvFindType( const char* type_name ); +CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr ); + +/* universal functions */ +CVAPI(void) cvRelease( void** struct_ptr ); +CVAPI(void*) cvClone( const void* struct_ptr ); + +/* simple API for reading/writing data */ +CVAPI(void) cvSave( const char* filename, const void* struct_ptr, + const char* name CV_DEFAULT(NULL), + const char* comment CV_DEFAULT(NULL), + CvAttrList attributes CV_DEFAULT(cvAttrList())); +CVAPI(void*) cvLoad( const char* filename, + CvMemStorage* memstorage CV_DEFAULT(NULL), + const char* name CV_DEFAULT(NULL), + const char** real_name CV_DEFAULT(NULL) ); + +/*********************************** Measuring Execution Time ***************************/ + +/* helper functions for RNG initialization and accurate time measurement: + uses internal clock counter on x86 */ +CVAPI(int64) cvGetTickCount( void ); +CVAPI(double) cvGetTickFrequency( void ); + +/*********************************** Multi-Threading ************************************/ + +/* retrieve/set the number of threads used in OpenMP implementations */ +CVAPI(int) cvGetNumThreads( void ); +CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) ); +/* get index of the thread being executed */ +CVAPI(int) cvGetThreadNum( void ); + +#ifdef __cplusplus +} + +#include "cxcore.hpp" +#endif + +#endif /*_CXCORE_H_*/ diff --git a/include/opencv/cxerror.h b/include/opencv/cxerror.h new file mode 100755 index 0000000..e7540bc --- /dev/null +++ b/include/opencv/cxerror.h @@ -0,0 +1,189 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CXCORE_ERROR_H_ +#define _CXCORE_ERROR_H_ + +/************Below is declaration of error handling stuff in PLSuite manner**/ + +typedef int CVStatus; + +/* this part of CVStatus is compatible with IPLStatus + Some of below symbols are not [yet] used in OpenCV +*/ +#define CV_StsOk 0 /* everithing is ok */ +#define CV_StsBackTrace -1 /* pseudo error for back trace */ +#define CV_StsError -2 /* unknown /unspecified error */ +#define CV_StsInternal -3 /* internal error (bad state) */ +#define CV_StsNoMem -4 /* insufficient memory */ +#define CV_StsBadArg -5 /* function arg/param is bad */ +#define CV_StsBadFunc -6 /* unsupported function */ +#define CV_StsNoConv -7 /* iter. didn't converge */ +#define CV_StsAutoTrace -8 /* tracing */ + +#define CV_HeaderIsNull -9 /* image header is NULL */ +#define CV_BadImageSize -10 /* image size is invalid */ +#define CV_BadOffset -11 /* offset is invalid */ +#define CV_BadDataPtr -12 /**/ +#define CV_BadStep -13 /**/ +#define CV_BadModelOrChSeq -14 /**/ +#define CV_BadNumChannels -15 /**/ +#define CV_BadNumChannel1U -16 /**/ +#define CV_BadDepth -17 /**/ +#define CV_BadAlphaChannel -18 /**/ +#define CV_BadOrder -19 /**/ +#define CV_BadOrigin -20 /**/ +#define CV_BadAlign -21 /**/ +#define CV_BadCallBack -22 /**/ +#define CV_BadTileSize -23 /**/ +#define CV_BadCOI -24 /**/ +#define CV_BadROISize -25 /**/ + +#define CV_MaskIsTiled -26 /**/ + +#define CV_StsNullPtr -27 /* null pointer */ +#define CV_StsVecLengthErr -28 /* incorrect vector length */ +#define CV_StsFilterStructContentErr -29 /* incorr. filter structure content */ +#define CV_StsKernelStructContentErr -30 /* incorr. transform kernel content */ +#define CV_StsFilterOffsetErr -31 /* incorrect filter ofset value */ + +/*extra for CV */ +#define CV_StsBadSize -201 /* the input/output structure size is incorrect */ +#define CV_StsDivByZero -202 /* division by zero */ +#define CV_StsInplaceNotSupported -203 /* in-place operation is not supported */ +#define CV_StsObjectNotFound -204 /* request can't be completed */ +#define CV_StsUnmatchedFormats -205 /* formats of input/output arrays differ */ +#define CV_StsBadFlag -206 /* flag is wrong or not supported */ +#define CV_StsBadPoint -207 /* bad CvPoint */ +#define CV_StsBadMask -208 /* bad format of mask (neither 8uC1 nor 8sC1)*/ +#define CV_StsUnmatchedSizes -209 /* sizes of input/output structures do not match */ +#define CV_StsUnsupportedFormat -210 /* the data format/type is not supported by the function*/ +#define CV_StsOutOfRange -211 /* some of parameters are out of range */ +#define CV_StsParseError -212 /* invalid syntax/structure of the parsed file */ +#define CV_StsNotImplemented -213 /* the requested function/feature is not implemented */ +#define CV_StsBadMemBlock -214 /* an allocated block has been corrupted */ + +/********************************* Error handling Macros ********************************/ + +#define OPENCV_ERROR(status,func,context) \ + cvError((status),(func),(context),__FILE__,__LINE__) + +#define OPENCV_ERRCHK(func,context) \ + {if (cvGetErrStatus() >= 0) \ + {OPENCV_ERROR(CV_StsBackTrace,(func),(context));}} + +#define OPENCV_ASSERT(expr,func,context) \ + {if (! (expr)) \ + {OPENCV_ERROR(CV_StsInternal,(func),(context));}} + +#define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk)) + +#define OPENCV_CALL( Func ) \ +{ \ + Func; \ +} + + +/**************************** OpenCV-style error handling *******************************/ + +/* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */ +#ifdef CV_NO_FUNC_NAMES + #define CV_FUNCNAME( Name ) + #define cvFuncName "" +#else + #define CV_FUNCNAME( Name ) \ + static char cvFuncName[] = Name +#endif + + +/* + CV_ERROR macro unconditionally raises error with passed code and message. + After raising error, control will be transferred to the exit label. +*/ +#define CV_ERROR( Code, Msg ) \ +{ \ + cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \ + EXIT; \ +} + +/* Simplified form of CV_ERROR */ +#define CV_ERROR_FROM_CODE( code ) \ + CV_ERROR( code, "" ) + +/* + CV_CHECK macro checks error status after CV (or IPL) + function call. If error detected, control will be transferred to the exit + label. +*/ +#define CV_CHECK() \ +{ \ + if( cvGetErrStatus() < 0 ) \ + CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ +} + + +/* + CV_CALL macro calls CV (or IPL) function, checks error status and + signals a error if the function failed. Useful in "parent node" + error procesing mode +*/ +#define CV_CALL( Func ) \ +{ \ + Func; \ + CV_CHECK(); \ +} + + +/* Runtime assertion macro */ +#define CV_ASSERT( Condition ) \ +{ \ + if( !(Condition) ) \ + CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \ +} + +#define __BEGIN__ { +#define __END__ goto exit; exit: ; } +#define __CLEANUP__ +#define EXIT goto exit + +#endif /* _CXCORE_ERROR_H_ */ + +/* End of file. */ diff --git a/include/opencv/cxmisc.h b/include/opencv/cxmisc.h new file mode 100755 index 0000000..b97878f --- /dev/null +++ b/include/opencv/cxmisc.h @@ -0,0 +1,922 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* The header is mostly for internal use and it is likely to change. + It contains some macro definitions that are used in cxcore, cv, cvaux + and, probably, other libraries. If you need some of this functionality, + the safe way is to copy it into your code and rename the macros. +*/ +#ifndef _CXCORE_MISC_H_ +#define _CXCORE_MISC_H_ + +#ifdef HAVE_CONFIG_H + #include "cvconfig.h" +#endif + +#include +#ifdef _OPENMP +#include "omp.h" +#endif + +/****************************************************************************************\ +* Compile-time tuning parameters * +\****************************************************************************************/ + +/* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */ +#define CV_MAX_INLINE_MAT_OP_SIZE 10 + +/* maximal linear size of matrix to allocate it on stack. */ +#define CV_MAX_LOCAL_MAT_SIZE 32 + +/* maximal size of local memory storage */ +#define CV_MAX_LOCAL_SIZE \ + (CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double)) + +/* default image row align (in bytes) */ +#define CV_DEFAULT_IMAGE_ROW_ALIGN 4 + +/* matrices are continuous by default */ +#define CV_DEFAULT_MAT_ROW_ALIGN 1 + +/* maximum size of dynamic memory buffer. + cvAlloc reports an error if a larger block is requested. */ +#define CV_MAX_ALLOC_SIZE (((size_t)1 << (sizeof(size_t)*8-2))) + +/* the alignment of all the allocated buffers */ +#define CV_MALLOC_ALIGN 32 + +/* default alignment for dynamic data strucutures, resided in storages. */ +#define CV_STRUCT_ALIGN ((int)sizeof(double)) + +/* default storage block size */ +#define CV_STORAGE_BLOCK_SIZE ((1<<16) - 128) + +/* default memory block for sparse array elements */ +#define CV_SPARSE_MAT_BLOCK (1<<12) + +/* initial hash table size */ +#define CV_SPARSE_HASH_SIZE0 (1<<10) + +/* maximal average node_count/hash_size ratio beyond which hash table is resized */ +#define CV_SPARSE_HASH_RATIO 3 + +/* max length of strings */ +#define CV_MAX_STRLEN 1024 + +/* maximum possible number of threads in parallel implementations */ +#ifdef _OPENMP +#define CV_MAX_THREADS 128 +#else +#define CV_MAX_THREADS 1 +#endif + +#if 0 /*def CV_CHECK_FOR_NANS*/ + #define CV_CHECK_NANS( arr ) cvCheckArray((arr)) +#else + #define CV_CHECK_NANS( arr ) +#endif + +/****************************************************************************************\ +* Common declarations * +\****************************************************************************************/ + +/* get alloca declaration */ +#ifdef __GNUC__ + #undef alloca + #define alloca __builtin_alloca +#elif defined WIN32 || defined WIN64 + #if defined _MSC_VER || defined __BORLANDC__ + #include + #endif +#elif defined HAVE_ALLOCA_H + #include +#elif defined HAVE_ALLOCA + #include +#elif + #error +#endif + +/* ! DO NOT make it an inline function */ +#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN ) + +#if defined _MSC_VER || defined __BORLANDC__ + #define CV_BIG_INT(n) n##I64 + #define CV_BIG_UINT(n) n##UI64 +#else + #define CV_BIG_INT(n) n##LL + #define CV_BIG_UINT(n) n##ULL +#endif + +#define CV_IMPL CV_EXTERN_C + +#if defined WIN32 && !defined WIN64 && (_MSC_VER >= 1200 || defined CV_ICC) + #define CV_DBG_BREAK() __asm int 3 +#else + #define CV_DBG_BREAK() assert(0); +#endif + +/* default step, set in case of continuous data + to work around checks for valid step in some ipp functions */ +#define CV_STUB_STEP (1 << 30) + +#define CV_SIZEOF_FLOAT ((int)sizeof(float)) +#define CV_SIZEOF_SHORT ((int)sizeof(short)) + +#define CV_ORIGIN_TL 0 +#define CV_ORIGIN_BL 1 + +/* IEEE754 constants and macros */ +#define CV_POS_INF 0x7f800000 +#define CV_NEG_INF 0x807fffff /* CV_TOGGLE_FLT(0xff800000) */ +#define CV_1F 0x3f800000 +#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0)) +#define CV_TOGGLE_DBL(x) \ + ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0)) + +#define CV_NOP(a) (a) +#define CV_ADD(a, b) ((a) + (b)) +#define CV_SUB(a, b) ((a) - (b)) +#define CV_MUL(a, b) ((a) * (b)) +#define CV_AND(a, b) ((a) & (b)) +#define CV_OR(a, b) ((a) | (b)) +#define CV_XOR(a, b) ((a) ^ (b)) +#define CV_ANDN(a, b) (~(a) & (b)) +#define CV_ORN(a, b) (~(a) | (b)) +#define CV_SQR(a) ((a) * (a)) + +#define CV_LT(a, b) ((a) < (b)) +#define CV_LE(a, b) ((a) <= (b)) +#define CV_EQ(a, b) ((a) == (b)) +#define CV_NE(a, b) ((a) != (b)) +#define CV_GT(a, b) ((a) > (b)) +#define CV_GE(a, b) ((a) >= (b)) + +#define CV_NONZERO(a) ((a) != 0) +#define CV_NONZERO_FLT(a) (((a)+(a)) != 0) + +/* general-purpose saturation macros */ +#define CV_CAST_8U(t) (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0) +#define CV_CAST_8S(t) (char)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128) +#define CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0) +#define CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768) +#define CV_CAST_32S(t) (int)(t) +#define CV_CAST_64S(t) (int64)(t) +#define CV_CAST_32F(t) (float)(t) +#define CV_CAST_64F(t) (double)(t) + +#define CV_PASTE2(a,b) a##b +#define CV_PASTE(a,b) CV_PASTE2(a,b) + +#define CV_EMPTY +#define CV_MAKE_STR(a) #a + +#define CV_DEFINE_MASK \ + float maskTab[2]; maskTab[0] = 0.f; maskTab[1] = 1.f; +#define CV_ANDMASK( m, x ) ((x) & (((m) == 0) - 1)) + +/* (x) * ((m) == 1 ? 1.f : (m) == 0 ? 0.f : */ +#define CV_MULMASK( m, x ) (maskTab[(m) != 0]*(x)) + +/* (x) * ((m) == -1 ? 1.f : (m) == 0 ? 0.f : */ +#define CV_MULMASK1( m, x ) (maskTab[(m)+1]*(x)) + +#define CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x))) + +#define CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0]))) + +#define CV_UN_ENTRY_C1(worktype) \ + worktype s0 = scalar[0] + +#define CV_UN_ENTRY_C2(worktype) \ + worktype s0 = scalar[0], s1 = scalar[1] + +#define CV_UN_ENTRY_C3(worktype) \ + worktype s0 = scalar[0], s1 = scalar[1], s2 = scalar[2] + +#define CV_UN_ENTRY_C4(worktype) \ + worktype s0 = scalar[0], s1 = scalar[1], s2 = scalar[2], s3 = scalar[3] + +#define cvUnsupportedFormat "Unsupported format" + +CV_INLINE void* cvAlignPtr( const void* ptr, int align=32 ) +{ + assert( (align & (align-1)) == 0 ); + return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) ); +} + +CV_INLINE int cvAlign( int size, int align ) +{ + assert( (align & (align-1)) == 0 && size < INT_MAX ); + return (size + align - 1) & -align; +} + +CV_INLINE CvSize cvGetMatSize( const CvMat* mat ) +{ + CvSize size = { mat->width, mat->height }; + return size; +} + +#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n)) +#define CV_FLT_TO_FIX(x,n) cvRound((x)*(1<<(n))) + +#if 0 +/* This is a small engine for performing fast division of multiple numbers + by the same constant. Most compilers do it too if they know the divisor value + at compile-time. The algorithm was taken from Agner Fog's optimization guide + at http://www.agner.org/assem */ +typedef struct CvFastDiv +{ + unsigned delta, scale, divisor; +} +CvFastDiv; + +#define CV_FAST_DIV_SHIFT 32 + +CV_INLINE CvFastDiv cvFastDiv( int divisor ) +{ + CvFastDiv fastdiv; + + assert( divisor >= 1 ); + uint64 temp = ((uint64)1 << CV_FAST_DIV_SHIFT)/divisor; + + fastdiv.divisor = divisor; + fastdiv.delta = (unsigned)(((temp & 1) ^ 1) + divisor - 1); + fastdiv.scale = (unsigned)((temp + 1) >> 1); + + return fastdiv; +} + +#define CV_FAST_DIV( x, fastdiv ) \ + ((int)(((int64)((x)*2 + (int)(fastdiv).delta))*(int)(fastdiv).scale>>CV_FAST_DIV_SHIFT)) + +#define CV_FAST_UDIV( x, fastdiv ) \ + ((int)(((uint64)((x)*2 + (fastdiv).delta))*(fastdiv).scale>>CV_FAST_DIV_SHIFT)) +#endif + +#define CV_MEMCPY_CHAR( dst, src, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + char* _icv_memcpy_dst_ = (char*)(dst); \ + const char* _icv_memcpy_src_ = (const char*)(src); \ + \ + for( _icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; _icv_memcpy_i_++ ) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = _icv_memcpy_src_[_icv_memcpy_i_]; \ +} + + +#define CV_MEMCPY_INT( dst, src, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + int* _icv_memcpy_dst_ = (int*)(dst); \ + const int* _icv_memcpy_src_ = (const int*)(src); \ + assert( ((size_t)_icv_memcpy_src_&(sizeof(int)-1)) == 0 && \ + ((size_t)_icv_memcpy_dst_&(sizeof(int)-1)) == 0 ); \ + \ + for(_icv_memcpy_i_=0;_icv_memcpy_i_<_icv_memcpy_len_;_icv_memcpy_i_++) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = _icv_memcpy_src_[_icv_memcpy_i_]; \ +} + + +#define CV_MEMCPY_AUTO( dst, src, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + char* _icv_memcpy_dst_ = (char*)(dst); \ + const char* _icv_memcpy_src_ = (const char*)(src); \ + if( (_icv_memcpy_len_ & (sizeof(int)-1)) == 0 ) \ + { \ + assert( ((size_t)_icv_memcpy_src_&(sizeof(int)-1)) == 0 && \ + ((size_t)_icv_memcpy_dst_&(sizeof(int)-1)) == 0 ); \ + for( _icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; \ + _icv_memcpy_i_+=sizeof(int) ) \ + { \ + *(int*)(_icv_memcpy_dst_+_icv_memcpy_i_) = \ + *(const int*)(_icv_memcpy_src_+_icv_memcpy_i_); \ + } \ + } \ + else \ + { \ + for(_icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; _icv_memcpy_i_++)\ + _icv_memcpy_dst_[_icv_memcpy_i_] = _icv_memcpy_src_[_icv_memcpy_i_]; \ + } \ +} + + +#define CV_ZERO_CHAR( dst, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + char* _icv_memcpy_dst_ = (char*)(dst); \ + \ + for( _icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; _icv_memcpy_i_++ ) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = '\0'; \ +} + + +#define CV_ZERO_INT( dst, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + int* _icv_memcpy_dst_ = (int*)(dst); \ + assert( ((size_t)_icv_memcpy_dst_&(sizeof(int)-1)) == 0 ); \ + \ + for(_icv_memcpy_i_=0;_icv_memcpy_i_<_icv_memcpy_len_;_icv_memcpy_i_++) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = 0; \ +} + + +/****************************************************************************************\ + + Generic implementation of QuickSort algorithm. + ---------------------------------------------- + Using this macro user can declare customized sort function that can be much faster + than built-in qsort function because of lower overhead on elements + comparison and exchange. The macro takes less_than (or LT) argument - a macro or function + that takes 2 arguments returns non-zero if the first argument should be before the second + one in the sorted sequence and zero otherwise. + + Example: + + Suppose that the task is to sort points by ascending of y coordinates and if + y's are equal x's should ascend. + + The code is: + ------------------------------------------------------------------------------ + #define cmp_pts( pt1, pt2 ) \ + ((pt1).y < (pt2).y || ((pt1).y < (pt2).y && (pt1).x < (pt2).x)) + + [static] CV_IMPLEMENT_QSORT( icvSortPoints, CvPoint, cmp_pts ) + ------------------------------------------------------------------------------ + + After that the function "void icvSortPoints( CvPoint* array, size_t total, int aux );" + is available to user. + + aux is an additional parameter, which can be used when comparing elements. + The current implementation was derived from *BSD system qsort(): + + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + +\****************************************************************************************/ + +#define CV_IMPLEMENT_QSORT_EX( func_name, T, LT, user_data_type ) \ +void func_name( T *array, size_t total, user_data_type aux ) \ +{ \ + int isort_thresh = 7; \ + T t; \ + int sp = 0; \ + \ + struct \ + { \ + T *lb; \ + T *ub; \ + } \ + stack[48]; \ + \ + aux = aux; \ + \ + if( total <= 1 ) \ + return; \ + \ + stack[0].lb = array; \ + stack[0].ub = array + (total - 1); \ + \ + while( sp >= 0 ) \ + { \ + T* left = stack[sp].lb; \ + T* right = stack[sp--].ub; \ + \ + for(;;) \ + { \ + int i, n = (int)(right - left) + 1, m; \ + T* ptr; \ + T* ptr2; \ + \ + if( n <= isort_thresh ) \ + { \ + insert_sort: \ + for( ptr = left + 1; ptr <= right; ptr++ ) \ + { \ + for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--) \ + CV_SWAP( ptr2[0], ptr2[-1], t ); \ + } \ + break; \ + } \ + else \ + { \ + T* left0; \ + T* left1; \ + T* right0; \ + T* right1; \ + T* pivot; \ + T* a; \ + T* b; \ + T* c; \ + int swap_cnt = 0; \ + \ + left0 = left; \ + right0 = right; \ + pivot = left + (n/2); \ + \ + if( n > 40 ) \ + { \ + int d = n / 8; \ + a = left, b = left + d, c = left + 2*d; \ + left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + \ + a = pivot - d, b = pivot, c = pivot + d; \ + pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + \ + a = right - 2*d, b = right - d, c = right; \ + right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + } \ + \ + a = left, b = pivot, c = right; \ + pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + if( pivot != left0 ) \ + { \ + CV_SWAP( *pivot, *left0, t ); \ + pivot = left0; \ + } \ + left = left1 = left0 + 1; \ + right = right1 = right0; \ + \ + for(;;) \ + { \ + while( left <= right && !LT(*pivot, *left) ) \ + { \ + if( !LT(*left, *pivot) ) \ + { \ + if( left > left1 ) \ + CV_SWAP( *left1, *left, t ); \ + swap_cnt = 1; \ + left1++; \ + } \ + left++; \ + } \ + \ + while( left <= right && !LT(*right, *pivot) ) \ + { \ + if( !LT(*pivot, *right) ) \ + { \ + if( right < right1 ) \ + CV_SWAP( *right1, *right, t ); \ + swap_cnt = 1; \ + right1--; \ + } \ + right--; \ + } \ + \ + if( left > right ) \ + break; \ + CV_SWAP( *left, *right, t ); \ + swap_cnt = 1; \ + left++; \ + right--; \ + } \ + \ + if( swap_cnt == 0 ) \ + { \ + left = left0, right = right0; \ + goto insert_sort; \ + } \ + \ + n = MIN( (int)(left1 - left0), (int)(left - left1) ); \ + for( i = 0; i < n; i++ ) \ + CV_SWAP( left0[i], left[i-n], t ); \ + \ + n = MIN( (int)(right0 - right1), (int)(right1 - right) ); \ + for( i = 0; i < n; i++ ) \ + CV_SWAP( left[i], right0[i-n+1], t ); \ + n = (int)(left - left1); \ + m = (int)(right1 - right); \ + if( n > 1 ) \ + { \ + if( m > 1 ) \ + { \ + if( n > m ) \ + { \ + stack[++sp].lb = left0; \ + stack[sp].ub = left0 + n - 1; \ + left = right0 - m + 1, right = right0; \ + } \ + else \ + { \ + stack[++sp].lb = right0 - m + 1; \ + stack[sp].ub = right0; \ + left = left0, right = left0 + n - 1; \ + } \ + } \ + else \ + left = left0, right = left0 + n - 1; \ + } \ + else if( m > 1 ) \ + left = right0 - m + 1, right = right0; \ + else \ + break; \ + } \ + } \ + } \ +} + +#define CV_IMPLEMENT_QSORT( func_name, T, cmp ) \ + CV_IMPLEMENT_QSORT_EX( func_name, T, cmp, int ) + +/****************************************************************************************\ +* Structures and macros for integration with IPP * +\****************************************************************************************/ + +/* IPP-compatible return codes */ +typedef enum CvStatus +{ + CV_BADMEMBLOCK_ERR = -113, + CV_INPLACE_NOT_SUPPORTED_ERR= -112, + CV_UNMATCHED_ROI_ERR = -111, + CV_NOTFOUND_ERR = -110, + CV_BADCONVERGENCE_ERR = -109, + + CV_BADDEPTH_ERR = -107, + CV_BADROI_ERR = -106, + CV_BADHEADER_ERR = -105, + CV_UNMATCHED_FORMATS_ERR = -104, + CV_UNSUPPORTED_COI_ERR = -103, + CV_UNSUPPORTED_CHANNELS_ERR = -102, + CV_UNSUPPORTED_DEPTH_ERR = -101, + CV_UNSUPPORTED_FORMAT_ERR = -100, + + CV_BADARG_ERR = -49, //ipp comp + CV_NOTDEFINED_ERR = -48, //ipp comp + + CV_BADCHANNELS_ERR = -47, //ipp comp + CV_BADRANGE_ERR = -44, //ipp comp + CV_BADSTEP_ERR = -29, //ipp comp + + CV_BADFLAG_ERR = -12, + CV_DIV_BY_ZERO_ERR = -11, //ipp comp + CV_BADCOEF_ERR = -10, + + CV_BADFACTOR_ERR = -7, + CV_BADPOINT_ERR = -6, + CV_BADSCALE_ERR = -4, + CV_OUTOFMEM_ERR = -3, + CV_NULLPTR_ERR = -2, + CV_BADSIZE_ERR = -1, + CV_NO_ERR = 0, + CV_OK = CV_NO_ERR +} +CvStatus; + +#define CV_ERROR_FROM_STATUS( result ) \ + CV_ERROR( cvErrorFromIppStatus( result ), "OpenCV function failed" ) + +#define IPPI_CALL( Func ) \ +{ \ + CvStatus ippi_call_result; \ + ippi_call_result = Func; \ + \ + if( ippi_call_result < 0 ) \ + CV_ERROR_FROM_STATUS( (ippi_call_result)); \ +} + +#define CV_PLUGIN_NONE 0 +#define CV_PLUGIN_OPTCV 1 /* custom "emerged" ippopencv library */ +#define CV_PLUGIN_IPPCV 2 /* IPP: computer vision */ +#define CV_PLUGIN_IPPI 3 /* IPP: image processing */ +#define CV_PLUGIN_IPPS 4 /* IPP: signal processing */ +#define CV_PLUGIN_IPPVM 5 /* IPP: vector math functions */ +#define CV_PLUGIN_IPPCC 6 /* IPP: color space conversion */ +#define CV_PLUGIN_MKL 8 /* Intel Math Kernel Library */ + +#define CV_PLUGIN_MAX 16 + +#define CV_PLUGINS1(lib1) ((lib1)&15) +#define CV_PLUGINS2(lib1,lib2) (((lib1)&15)|(((lib2)&15)<<4)) +#define CV_PLUGINS3(lib1,lib2,lib3) (((lib1)&15)|(((lib2)&15)<<4)|(((lib2)&15)<<8)) + +#define CV_NOTHROW throw() + +#ifndef IPCVAPI +#define IPCVAPI(type,declspec,name,args) \ + /* function pointer */ \ + typedef type (declspec* name##_t) args; \ + extern name##_t name##_p; \ + type declspec name args; +#endif + +#define IPCVAPI_EX(type,name,ipp_name,ipp_search_modules,args) \ + IPCVAPI(type,CV_STDCALL,name,args) + +#define IPCVAPI_C_EX(type,name,ipp_name,ipp_search_modules,args)\ + IPCVAPI(type,CV_CDECL,name,args) + +#ifndef IPCVAPI_IMPL +#define IPCVAPI_IMPL(type,name,args,arg_names) \ + static type CV_STDCALL name##_f args; \ + name##_t name##_p = name##_f; \ + type CV_STDCALL name args { return name##_p arg_names; } \ + static type CV_STDCALL name##_f args +#endif + +/* IPP types' enumeration */ +typedef enum CvDataType { + cv1u, + cv8u, cv8s, + cv16u, cv16s, cv16sc, + cv32u, cv32s, cv32sc, + cv32f, cv32fc, + cv64u, cv64s, cv64sc, + cv64f, cv64fc +} CvDataType; + +typedef enum CvHintAlgorithm { + cvAlgHintNone, + cvAlgHintFast, + cvAlgHintAccurate +} CvHintAlgorithm; + +typedef enum CvCmpOp { + cvCmpLess, + cvCmpLessEq, + cvCmpEq, + cvCmpGreaterEq, + cvCmpGreater +} CvCmpOp; + +typedef struct CvFuncTable +{ + void* fn_2d[CV_DEPTH_MAX]; +} +CvFuncTable; + +typedef struct CvBigFuncTable +{ + void* fn_2d[CV_DEPTH_MAX*CV_CN_MAX]; +} +CvBigFuncTable; + + +typedef struct CvBtFuncTable +{ + void* fn_2d[33]; +} +CvBtFuncTable; + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A)(void* arr, int step, CvSize size); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A1P)(void* arr, int step, CvSize size, void* param); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A1P1I)(void* arr, int step, CvSize size, + void* param, int flag); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A1P)( void* arr, int step, CvSize size, + int cn, int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A1P)( void* arr, int step, CvSize size, + int cn, int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A2P)( void* arr, int step, CvSize size, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A2P)( void* arr, int step, + CvSize size, int cn, int coi, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A4P)( void* arr, int step, CvSize size, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A4P)( void* arr, int step, + CvSize size, int cn, int coi, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A)( void* arr0, int step0, + void* arr1, int step1, CvSize size ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A1P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A1P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, int cn, + int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A1P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, int cn, + int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A2P)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A2P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, int cn, int coi, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A1P1I)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + void* param, int flag ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A4P)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A4P)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + int cn, int coi, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_3A)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, CvSize size ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_3A1P)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + CvSize size, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_3A1I)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + CvSize size, int flag ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_3A1P)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + CvSize size, int cn, + int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_4A)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + void* arr3, int step3, + CvSize size ); + +typedef CvStatus (CV_STDCALL *CvFunc0D)( const void* src, void* dst, int param ); + +#define CV_DEF_INIT_FUNC_TAB_2D( FUNCNAME, FLAG ) \ +static void icvInit##FUNCNAME##FLAG##Table( CvFuncTable* tab ) \ +{ \ + assert( tab ); \ + \ + tab->fn_2d[CV_8U] = (void*)icv##FUNCNAME##_8u_##FLAG; \ + tab->fn_2d[CV_8S] = (void*)icv##FUNCNAME##_8s_##FLAG; \ + tab->fn_2d[CV_16U] = (void*)icv##FUNCNAME##_16u_##FLAG; \ + tab->fn_2d[CV_16S] = (void*)icv##FUNCNAME##_16s_##FLAG; \ + tab->fn_2d[CV_32S] = (void*)icv##FUNCNAME##_32s_##FLAG; \ + tab->fn_2d[CV_32F] = (void*)icv##FUNCNAME##_32f_##FLAG; \ + tab->fn_2d[CV_64F] = (void*)icv##FUNCNAME##_64f_##FLAG; \ +} + + +#define CV_DEF_INIT_BIG_FUNC_TAB_2D( FUNCNAME, FLAG ) \ +static void icvInit##FUNCNAME##FLAG##Table( CvBigFuncTable* tab ) \ +{ \ + assert( tab ); \ + \ + tab->fn_2d[CV_8UC1] = (void*)icv##FUNCNAME##_8u_C1##FLAG; \ + tab->fn_2d[CV_8UC2] = (void*)icv##FUNCNAME##_8u_C2##FLAG; \ + tab->fn_2d[CV_8UC3] = (void*)icv##FUNCNAME##_8u_C3##FLAG; \ + tab->fn_2d[CV_8UC4] = (void*)icv##FUNCNAME##_8u_C4##FLAG; \ + \ + tab->fn_2d[CV_8SC1] = (void*)icv##FUNCNAME##_8s_C1##FLAG; \ + tab->fn_2d[CV_8SC2] = (void*)icv##FUNCNAME##_8s_C2##FLAG; \ + tab->fn_2d[CV_8SC3] = (void*)icv##FUNCNAME##_8s_C3##FLAG; \ + tab->fn_2d[CV_8SC4] = (void*)icv##FUNCNAME##_8s_C4##FLAG; \ + \ + tab->fn_2d[CV_16UC1] = (void*)icv##FUNCNAME##_16u_C1##FLAG; \ + tab->fn_2d[CV_16UC2] = (void*)icv##FUNCNAME##_16u_C2##FLAG; \ + tab->fn_2d[CV_16UC3] = (void*)icv##FUNCNAME##_16u_C3##FLAG; \ + tab->fn_2d[CV_16UC4] = (void*)icv##FUNCNAME##_16u_C4##FLAG; \ + \ + tab->fn_2d[CV_16SC1] = (void*)icv##FUNCNAME##_16s_C1##FLAG; \ + tab->fn_2d[CV_16SC2] = (void*)icv##FUNCNAME##_16s_C2##FLAG; \ + tab->fn_2d[CV_16SC3] = (void*)icv##FUNCNAME##_16s_C3##FLAG; \ + tab->fn_2d[CV_16SC4] = (void*)icv##FUNCNAME##_16s_C4##FLAG; \ + \ + tab->fn_2d[CV_32SC1] = (void*)icv##FUNCNAME##_32s_C1##FLAG; \ + tab->fn_2d[CV_32SC2] = (void*)icv##FUNCNAME##_32s_C2##FLAG; \ + tab->fn_2d[CV_32SC3] = (void*)icv##FUNCNAME##_32s_C3##FLAG; \ + tab->fn_2d[CV_32SC4] = (void*)icv##FUNCNAME##_32s_C4##FLAG; \ + \ + tab->fn_2d[CV_32FC1] = (void*)icv##FUNCNAME##_32f_C1##FLAG; \ + tab->fn_2d[CV_32FC2] = (void*)icv##FUNCNAME##_32f_C2##FLAG; \ + tab->fn_2d[CV_32FC3] = (void*)icv##FUNCNAME##_32f_C3##FLAG; \ + tab->fn_2d[CV_32FC4] = (void*)icv##FUNCNAME##_32f_C4##FLAG; \ + \ + tab->fn_2d[CV_64FC1] = (void*)icv##FUNCNAME##_64f_C1##FLAG; \ + tab->fn_2d[CV_64FC2] = (void*)icv##FUNCNAME##_64f_C2##FLAG; \ + tab->fn_2d[CV_64FC3] = (void*)icv##FUNCNAME##_64f_C3##FLAG; \ + tab->fn_2d[CV_64FC4] = (void*)icv##FUNCNAME##_64f_C4##FLAG; \ +} + +#define CV_DEF_INIT_FUNC_TAB_0D( FUNCNAME ) \ +static void icvInit##FUNCNAME##Table( CvFuncTable* tab ) \ +{ \ + tab->fn_2d[CV_8U] = (void*)icv##FUNCNAME##_8u; \ + tab->fn_2d[CV_8S] = (void*)icv##FUNCNAME##_8s; \ + tab->fn_2d[CV_16U] = (void*)icv##FUNCNAME##_16u; \ + tab->fn_2d[CV_16S] = (void*)icv##FUNCNAME##_16s; \ + tab->fn_2d[CV_32S] = (void*)icv##FUNCNAME##_32s; \ + tab->fn_2d[CV_32F] = (void*)icv##FUNCNAME##_32f; \ + tab->fn_2d[CV_64F] = (void*)icv##FUNCNAME##_64f; \ +} + +#define CV_DEF_INIT_FUNC_TAB_1D CV_DEF_INIT_FUNC_TAB_0D + + +#define CV_DEF_INIT_PIXSIZE_TAB_2D( FUNCNAME, FLAG ) \ +static void icvInit##FUNCNAME##FLAG##Table( CvBtFuncTable* table ) \ +{ \ + table->fn_2d[1] = (void*)icv##FUNCNAME##_8u_C1##FLAG; \ + table->fn_2d[2] = (void*)icv##FUNCNAME##_8u_C2##FLAG; \ + table->fn_2d[3] = (void*)icv##FUNCNAME##_8u_C3##FLAG; \ + table->fn_2d[4] = (void*)icv##FUNCNAME##_16u_C2##FLAG; \ + table->fn_2d[6] = (void*)icv##FUNCNAME##_16u_C3##FLAG; \ + table->fn_2d[8] = (void*)icv##FUNCNAME##_32s_C2##FLAG; \ + table->fn_2d[12] = (void*)icv##FUNCNAME##_32s_C3##FLAG; \ + table->fn_2d[16] = (void*)icv##FUNCNAME##_64s_C2##FLAG; \ + table->fn_2d[24] = (void*)icv##FUNCNAME##_64s_C3##FLAG; \ + table->fn_2d[32] = (void*)icv##FUNCNAME##_64s_C4##FLAG; \ +} + +#define CV_GET_FUNC_PTR( func, table_entry ) \ + func = (table_entry); \ + \ + if( !func ) \ + CV_ERROR( CV_StsUnsupportedFormat, "" ) + + +#endif /*_CXCORE_MISC_H_*/ diff --git a/include/opencv/cxtypes.h b/include/opencv/cxtypes.h new file mode 100755 index 0000000..94f88ed --- /dev/null +++ b/include/opencv/cxtypes.h @@ -0,0 +1,1771 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CXCORE_TYPES_H_ +#define _CXCORE_TYPES_H_ + +#if !defined _CRT_SECURE_NO_DEPRECATE && _MSC_VER > 1300 +#define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */ +#endif + +#ifndef SKIP_INCLUDES + #include + #include + #include + #include + + #if defined __ICL + #define CV_ICC __ICL + #elif defined __ICC + #define CV_ICC __ICC + #elif defined __ECL + #define CV_ICC __ECL + #elif defined __ECC + #define CV_ICC __ECC + #endif + + #if defined WIN64 && defined EM64T && (defined _MSC_VER || defined CV_ICC) \ + || defined __SSE2__ || defined _MM_SHUFFLE2 || defined __x86_64__ + #include + #define CV_SSE2 1 + #else + #define CV_SSE2 0 + #endif + + #if defined __BORLANDC__ + #include + #elif defined WIN64 && !defined EM64T && defined CV_ICC + #include + #else + #include + #endif + + #ifdef HAVE_IPL + #ifndef __IPL_H__ + #if defined WIN32 || defined WIN64 + #include + #else + #include + #endif + #endif + #elif defined __IPL_H__ + #define HAVE_IPL + #endif +#endif // SKIP_INCLUDES + +#if defined WIN32 || defined WIN64 + #define CV_CDECL __cdecl + #define CV_STDCALL __stdcall +#else + #define CV_CDECL + #define CV_STDCALL +#endif + +#ifndef CV_EXTERN_C + #ifdef __cplusplus + #define CV_EXTERN_C extern "C" + #define CV_DEFAULT(val) = val + #else + #define CV_EXTERN_C + #define CV_DEFAULT(val) + #endif +#endif + +#ifndef CV_EXTERN_C_FUNCPTR + #ifdef __cplusplus + #define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } + #else + #define CV_EXTERN_C_FUNCPTR(x) typedef x + #endif +#endif + +#ifndef CV_INLINE +#if defined __cplusplus + #define CV_INLINE inline +#elif (defined WIN32 || defined WIN64) && !defined __GNUC__ + #define CV_INLINE __inline +#else + #define CV_INLINE static inline +#endif +#endif /* CV_INLINE */ + +#if (defined WIN32 || defined WIN64) && defined CVAPI_EXPORTS + #define CV_EXPORTS __declspec(dllexport) +#else + #define CV_EXPORTS +#endif + +#ifndef CVAPI + #define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL +#endif + +#if defined _MSC_VER || defined __BORLANDC__ +typedef __int64 int64; +typedef unsigned __int64 uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif + +#ifndef HAVE_IPL +typedef unsigned char uchar; +typedef unsigned short ushort; +#endif + +/* CvArr* is used to pass arbitrary array-like data structures + into the functions where the particular + array type is recognized at runtime */ +typedef void CvArr; + +typedef union Cv32suf +{ + int i; + unsigned u; + float f; +} +Cv32suf; + +typedef union Cv64suf +{ + int64 i; + uint64 u; + double f; +} +Cv64suf; + +/****************************************************************************************\ +* Common macros and inline functions * +\****************************************************************************************/ + +#define CV_PI 3.1415926535897932384626433832795 +#define CV_LOG2 0.69314718055994530941723212145818 + +#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t)) + +#ifndef MIN +#define MIN(a,b) ((a) > (b) ? (b) : (a)) +#endif + +#ifndef MAX +#define MAX(a,b) ((a) < (b) ? (b) : (a)) +#endif + +/* min & max without jumps */ +#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1))) + +#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1))) + +/* absolute value without jumps */ +#ifndef __cplusplus +#define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0)) +#else +#define CV_IABS(a) abs(a) +#endif +#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b))) +#define CV_SIGN(a) CV_CMP((a),0) + +CV_INLINE int cvRound( double value ) +{ +#if CV_SSE2 + __m128d t = _mm_load_sd( &value ); + return _mm_cvtsd_si32(t); +#elif defined WIN32 && !defined WIN64 && defined _MSC_VER + int t; + __asm + { + fld value; + fistp t; + } + return t; +#elif (defined HAVE_LRINT) || (defined WIN64 && !defined EM64T && defined CV_ICC) + return (int)lrint(value); +#else + /* + the algorithm was taken from Agner Fog's optimization guide + at http://www.agner.org/assem + */ + Cv64suf temp; + temp.f = value + 6755399441055744.0; + return (int)temp.u; +#endif +} + + +CV_INLINE int cvFloor( double value ) +{ +#if CV_SSE2 + __m128d t = _mm_load_sd( &value ); + int i = _mm_cvtsd_si32(t); + return i - _mm_movemask_pd(_mm_cmplt_sd(t,_mm_cvtsi32_sd(t,i))); +#else + int temp = cvRound(value); + Cv32suf diff; + diff.f = (float)(value - temp); + return temp - (diff.i < 0); +#endif +} + + +CV_INLINE int cvCeil( double value ) +{ +#if CV_SSE2 + __m128d t = _mm_load_sd( &value ); + int i = _mm_cvtsd_si32(t); + return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i),t)); +#else + int temp = cvRound(value); + Cv32suf diff; + diff.f = (float)(temp - value); + return temp + (diff.i < 0); +#endif +} + +#define cvInvSqrt(value) ((float)(1./sqrt(value))) +#define cvSqrt(value) ((float)sqrt(value)) + +CV_INLINE int cvIsNaN( double value ) +{ +#if 1/*defined _MSC_VER || defined __BORLANDC__ + return _isnan(value); +#elif defined __GNUC__ + return isnan(value); +#else*/ + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) + + ((unsigned)ieee754.u != 0) > 0x7ff00000; +#endif +} + + +CV_INLINE int cvIsInf( double value ) +{ +#if 1/*defined _MSC_VER || defined __BORLANDC__ + return !_finite(value); +#elif defined __GNUC__ + return isinf(value); +#else*/ + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && + (unsigned)ieee754.u == 0; +#endif +} + + +/*************** Random number generation *******************/ + +typedef uint64 CvRNG; + +CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1)) +{ + CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1; + return rng; +} + +/* returns random 32-bit unsigned integer */ +CV_INLINE unsigned cvRandInt( CvRNG* rng ) +{ + uint64 temp = *rng; + temp = (uint64)(unsigned)temp*1554115554 + (temp >> 32); + *rng = temp; + return (unsigned)temp; +} + +/* returns random floating-point number between 0 and 1 */ +CV_INLINE double cvRandReal( CvRNG* rng ) +{ + return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */; +} + +/****************************************************************************************\ +* Image type (IplImage) * +\****************************************************************************************/ + +#ifndef HAVE_IPL + +/* + * The following definitions (until #endif) + * is an extract from IPL headers. + * Copyright (c) 1995 Intel Corporation. + */ +#define IPL_DEPTH_SIGN 0x80000000 + +#define IPL_DEPTH_1U 1 +#define IPL_DEPTH_8U 8 +#define IPL_DEPTH_16U 16 +#define IPL_DEPTH_32F 32 + +#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8) +#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16) +#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32) + +#define IPL_DATA_ORDER_PIXEL 0 +#define IPL_DATA_ORDER_PLANE 1 + +#define IPL_ORIGIN_TL 0 +#define IPL_ORIGIN_BL 1 + +#define IPL_ALIGN_4BYTES 4 +#define IPL_ALIGN_8BYTES 8 +#define IPL_ALIGN_16BYTES 16 +#define IPL_ALIGN_32BYTES 32 + +#define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES +#define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES + +#define IPL_BORDER_CONSTANT 0 +#define IPL_BORDER_REPLICATE 1 +#define IPL_BORDER_REFLECT 2 +#define IPL_BORDER_WRAP 3 + +typedef struct _IplImage +{ + int nSize; /* sizeof(IplImage) */ + int ID; /* version (=0)*/ + int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */ + int alphaChannel; /* ignored by OpenCV */ + int depth; /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, + IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */ + char colorModel[4]; /* ignored by OpenCV */ + char channelSeq[4]; /* ditto */ + int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels. + cvCreateImage can only create interleaved images */ + int origin; /* 0 - top-left origin, + 1 - bottom-left origin (Windows bitmaps style) */ + int align; /* Alignment of image rows (4 or 8). + OpenCV ignores it and uses widthStep instead */ + int width; /* image width in pixels */ + int height; /* image height in pixels */ + struct _IplROI *roi;/* image ROI. if NULL, the whole image is selected */ + struct _IplImage *maskROI; /* must be NULL */ + void *imageId; /* ditto */ + struct _IplTileInfo *tileInfo; /* ditto */ + int imageSize; /* image data size in bytes + (==image->height*image->widthStep + in case of interleaved data)*/ + char *imageData; /* pointer to aligned image data */ + int widthStep; /* size of aligned image row in bytes */ + int BorderMode[4]; /* ignored by OpenCV */ + int BorderConst[4]; /* ditto */ + char *imageDataOrigin; /* pointer to very origin of image data + (not necessarily aligned) - + needed for correct deallocation */ +} +IplImage; + +typedef struct _IplTileInfo IplTileInfo; + +typedef struct _IplROI +{ + int coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/ + int xOffset; + int yOffset; + int width; + int height; +} +IplROI; + +typedef struct _IplConvKernel +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + int *values; + int nShiftR; +} +IplConvKernel; + +typedef struct _IplConvKernelFP +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + float *values; +} +IplConvKernelFP; + +#define IPL_IMAGE_HEADER 1 +#define IPL_IMAGE_DATA 2 +#define IPL_IMAGE_ROI 4 + +#endif/*HAVE_IPL*/ + +/* extra border mode */ +#define IPL_BORDER_REFLECT_101 4 + +#define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage)) +#define CV_TYPE_NAME_IMAGE "opencv-image" + +#define CV_IS_IMAGE_HDR(img) \ + ((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage)) + +#define CV_IS_IMAGE(img) \ + (CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->imageData != NULL) + +/* for storing double-precision + floating point data in IplImage's */ +#define IPL_DEPTH_64F 64 + +/* get reference to pixel at (col,row), + for multi-channel images (col) should be multiplied by number of channels */ +#define CV_IMAGE_ELEM( image, elemtype, row, col ) \ + (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)]) + +/****************************************************************************************\ +* Matrix type (CvMat) * +\****************************************************************************************/ + +#define CV_CN_MAX 64 +#define CV_CN_SHIFT 3 +#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) + +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 +#define CV_USRTYPE1 7 + +#define CV_MAKETYPE(depth,cn) ((depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKE_TYPE CV_MAKETYPE + +#define CV_8UC1 CV_MAKETYPE(CV_8U,1) +#define CV_8UC2 CV_MAKETYPE(CV_8U,2) +#define CV_8UC3 CV_MAKETYPE(CV_8U,3) +#define CV_8UC4 CV_MAKETYPE(CV_8U,4) +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) + +#define CV_8SC1 CV_MAKETYPE(CV_8S,1) +#define CV_8SC2 CV_MAKETYPE(CV_8S,2) +#define CV_8SC3 CV_MAKETYPE(CV_8S,3) +#define CV_8SC4 CV_MAKETYPE(CV_8S,4) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) + +#define CV_16UC1 CV_MAKETYPE(CV_16U,1) +#define CV_16UC2 CV_MAKETYPE(CV_16U,2) +#define CV_16UC3 CV_MAKETYPE(CV_16U,3) +#define CV_16UC4 CV_MAKETYPE(CV_16U,4) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) + +#define CV_16SC1 CV_MAKETYPE(CV_16S,1) +#define CV_16SC2 CV_MAKETYPE(CV_16S,2) +#define CV_16SC3 CV_MAKETYPE(CV_16S,3) +#define CV_16SC4 CV_MAKETYPE(CV_16S,4) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_32SC1 CV_MAKETYPE(CV_32S,1) +#define CV_32SC2 CV_MAKETYPE(CV_32S,2) +#define CV_32SC3 CV_MAKETYPE(CV_32S,3) +#define CV_32SC4 CV_MAKETYPE(CV_32S,4) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) + +#define CV_32FC1 CV_MAKETYPE(CV_32F,1) +#define CV_32FC2 CV_MAKETYPE(CV_32F,2) +#define CV_32FC3 CV_MAKETYPE(CV_32F,3) +#define CV_32FC4 CV_MAKETYPE(CV_32F,4) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) + +#define CV_64FC1 CV_MAKETYPE(CV_64F,1) +#define CV_64FC2 CV_MAKETYPE(CV_64F,2) +#define CV_64FC3 CV_MAKETYPE(CV_64F,3) +#define CV_64FC4 CV_MAKETYPE(CV_64F,4) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + +#define CV_AUTO_STEP 0x7fffffff +#define CV_WHOLE_ARR cvSlice( 0, 0x3fffffff ) + +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) +#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) +#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_CONT_FLAG_SHIFT 14 +#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) +#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) +#define CV_IS_CONT_MAT CV_IS_MAT_CONT +#define CV_MAT_TEMP_FLAG_SHIFT 15 +#define CV_MAT_TEMP_FLAG (1 << CV_MAT_TEMP_FLAG_SHIFT) +#define CV_IS_TEMP_MAT(flags) ((flags) & CV_MAT_TEMP_FLAG) + +#define CV_MAGIC_MASK 0xFFFF0000 +#define CV_MAT_MAGIC_VAL 0x42420000 +#define CV_TYPE_NAME_MAT "opencv-matrix" + +typedef struct CvMat +{ + int type; + int step; + + /* for internal use only */ + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + short* s; + int* i; + float* fl; + double* db; + } data; + +#ifdef __cplusplus + union + { + int rows; + int height; + }; + + union + { + int cols; + int width; + }; +#else + int rows; + int cols; +#endif + +} +CvMat; + + +#define CV_IS_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ + ((const CvMat*)(mat))->cols > 0 && ((const CvMat*)(mat))->rows > 0) + +#define CV_IS_MAT(mat) \ + (CV_IS_MAT_HDR(mat) && ((const CvMat*)(mat))->data.ptr != NULL) + +#define CV_IS_MASK_ARR(mat) \ + (((mat)->type & (CV_MAT_TYPE_MASK & ~CV_8SC1)) == 0) + +#define CV_ARE_TYPES_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_TYPE_MASK) == 0) + +#define CV_ARE_CNS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_CN_MASK) == 0) + +#define CV_ARE_DEPTHS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_DEPTH_MASK) == 0) + +#define CV_ARE_SIZES_EQ(mat1, mat2) \ + ((mat1)->height == (mat2)->height && (mat1)->width == (mat2)->width) + +#define CV_IS_MAT_CONST(mat) \ + (((mat)->height|(mat)->width) == 1) + +/* size of each channel item, + 0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ +#define CV_ELEM_SIZE1(type) \ + ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15) + +/* 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */ +#define CV_ELEM_SIZE(type) \ + (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)) + +/* inline constructor. No data is allocated internally!!! + (use together with cvCreateData, or use cvCreateMat instead to + get a matrix with allocated data) */ +CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)) +{ + CvMat m; + + assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); + type = CV_MAT_TYPE(type); + m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; + m.cols = cols; + m.rows = rows; + m.step = rows > 1 ? m.cols*CV_ELEM_SIZE(type) : 0; + m.data.ptr = (uchar*)data; + m.refcount = NULL; + m.hdr_refcount = 0; + + return m; +} + + +#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \ + (assert( (unsigned)(row) < (unsigned)(mat).rows && \ + (unsigned)(col) < (unsigned)(mat).cols ), \ + (mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col)) + +#define CV_MAT_ELEM_PTR( mat, row, col ) \ + CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) ) + +#define CV_MAT_ELEM( mat, elemtype, row, col ) \ + (*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype))) + + +CV_INLINE double cvmGet( const CvMat* mat, int row, int col ) +{ + int type; + + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + return ((float*)(mat->data.ptr + (size_t)mat->step*row))[col]; + else + { + assert( type == CV_64FC1 ); + return ((double*)(mat->data.ptr + (size_t)mat->step*row))[col]; + } +} + + +CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) +{ + int type; + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + ((float*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value; + else + { + assert( type == CV_64FC1 ); + ((double*)(mat->data.ptr + (size_t)mat->step*row))[col] = (double)value; + } +} + + +CV_INLINE int cvCvToIplDepth( int type ) +{ + int depth = CV_MAT_DEPTH(type); + return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || + depth == CV_32S ? IPL_DEPTH_SIGN : 0); +} + + +/****************************************************************************************\ +* Multi-dimensional dense array (CvMatND) * +\****************************************************************************************/ + +#define CV_MATND_MAGIC_VAL 0x42430000 +#define CV_TYPE_NAME_MATND "opencv-nd-matrix" + +#define CV_MAX_DIM 32 +#define CV_MAX_DIM_HEAP (1 << 16) + +typedef struct CvMatND +{ + int type; + int dims; + + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + float* fl; + double* db; + int* i; + short* s; + } data; + + struct + { + int size; + int step; + } + dim[CV_MAX_DIM]; +} +CvMatND; + +#define CV_IS_MATND_HDR(mat) \ + ((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL) + +#define CV_IS_MATND(mat) \ + (CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL) + + +/****************************************************************************************\ +* Multi-dimensional sparse array (CvSparseMat) * +\****************************************************************************************/ + +#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000 +#define CV_TYPE_NAME_SPARSE_MAT "opencv-sparse-matrix" + +struct CvSet; + +typedef struct CvSparseMat +{ + int type; + int dims; + int* refcount; + int hdr_refcount; + + struct CvSet* heap; + void** hashtable; + int hashsize; + int valoffset; + int idxoffset; + int size[CV_MAX_DIM]; +} +CvSparseMat; + +#define CV_IS_SPARSE_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL) + +#define CV_IS_SPARSE_MAT(mat) \ + CV_IS_SPARSE_MAT_HDR(mat) + +/**************** iteration through a sparse array *****************/ + +typedef struct CvSparseNode +{ + unsigned hashval; + struct CvSparseNode* next; +} +CvSparseNode; + +typedef struct CvSparseMatIterator +{ + CvSparseMat* mat; + CvSparseNode* node; + int curidx; +} +CvSparseMatIterator; + +#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset)) +#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset)) + +/****************************************************************************************\ +* Histogram * +\****************************************************************************************/ + +typedef int CvHistType; + +#define CV_HIST_MAGIC_VAL 0x42450000 +#define CV_HIST_UNIFORM_FLAG (1 << 10) + +/* indicates whether bin ranges are set already or not */ +#define CV_HIST_RANGES_FLAG (1 << 11) + +#define CV_HIST_ARRAY 0 +#define CV_HIST_SPARSE 1 +#define CV_HIST_TREE CV_HIST_SPARSE + +/* should be used as a parameter only, + it turns to CV_HIST_UNIFORM_FLAG of hist->type */ +#define CV_HIST_UNIFORM 1 + +typedef struct CvHistogram +{ + int type; + CvArr* bins; + float thresh[CV_MAX_DIM][2]; /* for uniform histograms */ + float** thresh2; /* for non-uniform histograms */ + CvMatND mat; /* embedded matrix header for array histograms */ +} +CvHistogram; + +#define CV_IS_HIST( hist ) \ + ((hist) != NULL && \ + (((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \ + (hist)->bins != NULL) + +#define CV_IS_UNIFORM_HIST( hist ) \ + (((hist)->type & CV_HIST_UNIFORM_FLAG) != 0) + +#define CV_IS_SPARSE_HIST( hist ) \ + CV_IS_SPARSE_MAT((hist)->bins) + +#define CV_HIST_HAS_RANGES( hist ) \ + (((hist)->type & CV_HIST_RANGES_FLAG) != 0) + +/****************************************************************************************\ +* Other supplementary data type definitions * +\****************************************************************************************/ + +/*************************************** CvRect *****************************************/ + +typedef struct CvRect +{ + int x; + int y; + int width; + int height; +} +CvRect; + +CV_INLINE CvRect cvRect( int x, int y, int width, int height ) +{ + CvRect r; + + r.x = x; + r.y = y; + r.width = width; + r.height = height; + + return r; +} + + +CV_INLINE IplROI cvRectToROI( CvRect rect, int coi ) +{ + IplROI roi; + roi.xOffset = rect.x; + roi.yOffset = rect.y; + roi.width = rect.width; + roi.height = rect.height; + roi.coi = coi; + + return roi; +} + + +CV_INLINE CvRect cvROIToRect( IplROI roi ) +{ + return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height ); +} + +/*********************************** CvTermCriteria *************************************/ + +#define CV_TERMCRIT_ITER 1 +#define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER +#define CV_TERMCRIT_EPS 2 + +typedef struct CvTermCriteria +{ + int type; /* may be combination of + CV_TERMCRIT_ITER + CV_TERMCRIT_EPS */ + int max_iter; + double epsilon; +} +CvTermCriteria; + +CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon ) +{ + CvTermCriteria t; + + t.type = type; + t.max_iter = max_iter; + t.epsilon = (float)epsilon; + + return t; +} + + +/******************************* CvPoint and variants ***********************************/ + +typedef struct CvPoint +{ + int x; + int y; +} +CvPoint; + + +CV_INLINE CvPoint cvPoint( int x, int y ) +{ + CvPoint p; + + p.x = x; + p.y = y; + + return p; +} + + +typedef struct CvPoint2D32f +{ + float x; + float y; +} +CvPoint2D32f; + + +CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y ) +{ + CvPoint2D32f p; + + p.x = (float)x; + p.y = (float)y; + + return p; +} + + +CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point ) +{ + return cvPoint2D32f( (float)point.x, (float)point.y ); +} + + +CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point ) +{ + CvPoint ipt; + ipt.x = cvRound(point.x); + ipt.y = cvRound(point.y); + + return ipt; +} + + +typedef struct CvPoint3D32f +{ + float x; + float y; + float z; +} +CvPoint3D32f; + + +CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z ) +{ + CvPoint3D32f p; + + p.x = (float)x; + p.y = (float)y; + p.z = (float)z; + + return p; +} + + +typedef struct CvPoint2D64f +{ + double x; + double y; +} +CvPoint2D64f; + + +CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y ) +{ + CvPoint2D64f p; + + p.x = x; + p.y = y; + + return p; +} + + +typedef struct CvPoint3D64f +{ + double x; + double y; + double z; +} +CvPoint3D64f; + + +CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z ) +{ + CvPoint3D64f p; + + p.x = x; + p.y = y; + p.z = z; + + return p; +} + + +/******************************** CvSize's & CvBox **************************************/ + +typedef struct +{ + int width; + int height; +} +CvSize; + +CV_INLINE CvSize cvSize( int width, int height ) +{ + CvSize s; + + s.width = width; + s.height = height; + + return s; +} + +typedef struct CvSize2D32f +{ + float width; + float height; +} +CvSize2D32f; + + +CV_INLINE CvSize2D32f cvSize2D32f( double width, double height ) +{ + CvSize2D32f s; + + s.width = (float)width; + s.height = (float)height; + + return s; +} + +typedef struct CvBox2D +{ + CvPoint2D32f center; /* center of the box */ + CvSize2D32f size; /* box width and length */ + float angle; /* angle between the horizontal axis + and the first side (i.e. length) in degrees */ +} +CvBox2D; + + +/* Line iterator state */ +typedef struct CvLineIterator +{ + /* pointer to the current point */ + uchar* ptr; + + /* Bresenham algorithm state */ + int err; + int plus_delta; + int minus_delta; + int plus_step; + int minus_step; +} +CvLineIterator; + + + +/************************************* CvSlice ******************************************/ + +typedef struct CvSlice +{ + int start_index, end_index; +} +CvSlice; + +CV_INLINE CvSlice cvSlice( int start, int end ) +{ + CvSlice slice; + slice.start_index = start; + slice.end_index = end; + + return slice; +} + +#define CV_WHOLE_SEQ_END_INDEX 0x3fffffff +#define CV_WHOLE_SEQ cvSlice(0, CV_WHOLE_SEQ_END_INDEX) + + +/************************************* CvScalar *****************************************/ + +typedef struct CvScalar +{ + double val[4]; +} +CvScalar; + +CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0), + double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0)) +{ + CvScalar scalar; + scalar.val[0] = val0; scalar.val[1] = val1; + scalar.val[2] = val2; scalar.val[3] = val3; + return scalar; +} + + +CV_INLINE CvScalar cvRealScalar( double val0 ) +{ + CvScalar scalar; + scalar.val[0] = val0; + scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; + return scalar; +} + +CV_INLINE CvScalar cvScalarAll( double val0123 ) +{ + CvScalar scalar; + scalar.val[0] = val0123; + scalar.val[1] = val0123; + scalar.val[2] = val0123; + scalar.val[3] = val0123; + return scalar; +} + +/****************************************************************************************\ +* Dynamic Data structures * +\****************************************************************************************/ + +/******************************** Memory storage ****************************************/ + +typedef struct CvMemBlock +{ + struct CvMemBlock* prev; + struct CvMemBlock* next; +} +CvMemBlock; + +#define CV_STORAGE_MAGIC_VAL 0x42890000 + +typedef struct CvMemStorage +{ + int signature; + CvMemBlock* bottom;/* first allocated block */ + CvMemBlock* top; /* current memory block - top of the stack */ + struct CvMemStorage* parent; /* borrows new blocks from */ + int block_size; /* block size */ + int free_space; /* free space in the current block */ +} +CvMemStorage; + +#define CV_IS_STORAGE(storage) \ + ((storage) != NULL && \ + (((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) == CV_STORAGE_MAGIC_VAL) + + +typedef struct CvMemStoragePos +{ + CvMemBlock* top; + int free_space; +} +CvMemStoragePos; + + +/*********************************** Sequence *******************************************/ + +typedef struct CvSeqBlock +{ + struct CvSeqBlock* prev; /* previous sequence block */ + struct CvSeqBlock* next; /* next sequence block */ + int start_index; /* index of the first element in the block + + sequence->first->start_index */ + int count; /* number of elements in the block */ + char* data; /* pointer to the first element of the block */ +} +CvSeqBlock; + + +#define CV_TREE_NODE_FIELDS(node_type) \ + int flags; /* micsellaneous flags */ \ + int header_size; /* size of sequence header */ \ + struct node_type* h_prev; /* previous sequence */ \ + struct node_type* h_next; /* next sequence */ \ + struct node_type* v_prev; /* 2nd previous sequence */ \ + struct node_type* v_next /* 2nd next sequence */ + +/* + Read/Write sequence. + Elements can be dynamically inserted to or deleted from the sequence. +*/ +#define CV_SEQUENCE_FIELDS() \ + CV_TREE_NODE_FIELDS(CvSeq); \ + int total; /* total number of elements */ \ + int elem_size; /* size of sequence element in bytes */ \ + char* block_max; /* maximal bound of the last block */ \ + char* ptr; /* current write pointer */ \ + int delta_elems; /* how many elements allocated when the seq grows */ \ + CvMemStorage* storage; /* where the seq is stored */ \ + CvSeqBlock* free_blocks; /* free blocks list */ \ + CvSeqBlock* first; /* pointer to the first sequence block */ + +typedef struct CvSeq +{ + CV_SEQUENCE_FIELDS() +} +CvSeq; + +#define CV_TYPE_NAME_SEQ "opencv-sequence" +#define CV_TYPE_NAME_SEQ_TREE "opencv-sequence-tree" + +/*************************************** Set ********************************************/ +/* + Set. + Order is not preserved. There can be gaps between sequence elements. + After the element has been inserted it stays in the same place all the time. + The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists. +*/ +#define CV_SET_ELEM_FIELDS(elem_type) \ + int flags; \ + struct elem_type* next_free; + +typedef struct CvSetElem +{ + CV_SET_ELEM_FIELDS(CvSetElem) +} +CvSetElem; + +#define CV_SET_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvSetElem* free_elems; \ + int active_count; + +typedef struct CvSet +{ + CV_SET_FIELDS() +} +CvSet; + + +#define CV_SET_ELEM_IDX_MASK ((1 << 26) - 1) +#define CV_SET_ELEM_FREE_FLAG (1 << (sizeof(int)*8-1)) + +/* Checks whether the element pointed by ptr belongs to a set or not */ +#define CV_IS_SET_ELEM( ptr ) (((CvSetElem*)(ptr))->flags >= 0) + +/************************************* Graph ********************************************/ + +/* + Graph is represented as a set of vertices. + Vertices contain their adjacency lists (more exactly, pointers to first incoming or + outcoming edge (or 0 if isolated vertex)). Edges are stored in another set. + There is a single-linked list of incoming/outcoming edges for each vertex. + + Each edge consists of: + two pointers to the starting and the ending vertices (vtx[0] and vtx[1], + respectively). Graph may be oriented or not. In the second case, edges between + vertex i to vertex j are not distingueshed (during the search operations). + + two pointers to next edges for the starting and the ending vertices. + next[0] points to the next edge in the vtx[0] adjacency list and + next[1] points to the next edge in the vtx[1] adjacency list. +*/ +#define CV_GRAPH_EDGE_FIELDS() \ + int flags; \ + float weight; \ + struct CvGraphEdge* next[2]; \ + struct CvGraphVtx* vtx[2]; + + +#define CV_GRAPH_VERTEX_FIELDS() \ + int flags; \ + struct CvGraphEdge* first; + + +typedef struct CvGraphEdge +{ + CV_GRAPH_EDGE_FIELDS() +} +CvGraphEdge; + +typedef struct CvGraphVtx +{ + CV_GRAPH_VERTEX_FIELDS() +} +CvGraphVtx; + +typedef struct CvGraphVtx2D +{ + CV_GRAPH_VERTEX_FIELDS() + CvPoint2D32f* ptr; +} +CvGraphVtx2D; + +/* + Graph is "derived" from the set (this is set a of vertices) + and includes another set (edges) +*/ +#define CV_GRAPH_FIELDS() \ + CV_SET_FIELDS() \ + CvSet* edges; + +typedef struct CvGraph +{ + CV_GRAPH_FIELDS() +} +CvGraph; + +#define CV_TYPE_NAME_GRAPH "opencv-graph" + +/*********************************** Chain/Countour *************************************/ + +typedef struct CvChain +{ + CV_SEQUENCE_FIELDS() + CvPoint origin; +} +CvChain; + +#define CV_CONTOUR_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvRect rect; \ + int color; \ + int reserved[3]; + +typedef struct CvContour +{ + CV_CONTOUR_FIELDS() +} +CvContour; + +typedef CvContour CvPoint2DSeq; + +/****************************************************************************************\ +* Sequence types * +\****************************************************************************************/ + +#define CV_SEQ_MAGIC_VAL 0x42990000 + +#define CV_IS_SEQ(seq) \ + ((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL) + +#define CV_SET_MAGIC_VAL 0x42980000 +#define CV_IS_SET(set) \ + ((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL) + +#define CV_SEQ_ELTYPE_BITS 9 +#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1) + +#define CV_SEQ_ELTYPE_POINT CV_32SC2 /* (x,y) */ +#define CV_SEQ_ELTYPE_CODE CV_8UC1 /* freeman code: 0..7 */ +#define CV_SEQ_ELTYPE_GENERIC 0 +#define CV_SEQ_ELTYPE_PTR CV_USRTYPE1 +#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /* &(x,y) */ +#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /* #(x,y) */ +#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /* &next_o, &next_d, &vtx_o, &vtx_d */ +#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /* first_edge, &(x,y) */ +#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /* vertex of the binary tree */ +#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /* connected component */ +#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /* (x,y,z) */ + +#define CV_SEQ_KIND_BITS 3 +#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<flags & CV_SEQ_ELTYPE_MASK) +#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK ) + +/* flag checking */ +#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC)) + +#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE) +#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0) +#define CV_IS_SEQ_CONVEX( seq ) (((seq)->flags & CV_SEQ_FLAG_CONVEX) != 0) +#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0) +#define CV_IS_SEQ_SIMPLE( seq ) ((((seq)->flags & CV_SEQ_FLAG_SIMPLE) != 0) || \ + CV_IS_SEQ_CONVEX(seq)) + +/* type checking macros */ +#define CV_IS_SEQ_POINT_SET( seq ) \ + ((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2)) + +#define CV_IS_SEQ_POINT_SUBSET( seq ) \ + (CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT) + +#define CV_IS_SEQ_POLYLINE( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq)) + +#define CV_IS_SEQ_POLYGON( seq ) \ + (CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq)) + +#define CV_IS_SEQ_CHAIN( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1) + +#define CV_IS_SEQ_CONTOUR( seq ) \ + (CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq))) + +#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \ + (CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq )) + +#define CV_IS_SEQ_POLYGON_TREE( seq ) \ + (CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \ + CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE ) + +#define CV_IS_GRAPH( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH) + +#define CV_IS_GRAPH_ORIENTED( seq ) \ + (((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0) + +#define CV_IS_SUBDIV2D( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D) + +/****************************************************************************************/ +/* Sequence writer & reader */ +/****************************************************************************************/ + +#define CV_SEQ_WRITER_FIELDS() \ + int header_size; \ + CvSeq* seq; /* the sequence written */ \ + CvSeqBlock* block; /* current block */ \ + char* ptr; /* pointer to free space */ \ + char* block_min; /* pointer to the beginning of block*/\ + char* block_max; /* pointer to the end of block */ + +typedef struct CvSeqWriter +{ + CV_SEQ_WRITER_FIELDS() +} +CvSeqWriter; + + +#define CV_SEQ_READER_FIELDS() \ + int header_size; \ + CvSeq* seq; /* sequence, beign read */ \ + CvSeqBlock* block; /* current block */ \ + char* ptr; /* pointer to element be read next */ \ + char* block_min; /* pointer to the beginning of block */\ + char* block_max; /* pointer to the end of block */ \ + int delta_index;/* = seq->first->start_index */ \ + char* prev_elem; /* pointer to previous element */ + + +typedef struct CvSeqReader +{ + CV_SEQ_READER_FIELDS() +} +CvSeqReader; + +/****************************************************************************************/ +/* Operations on sequences */ +/****************************************************************************************/ + +#define CV_SEQ_ELEM( seq, elem_type, index ) \ +/* assert gives some guarantee that parameter is valid */ \ +( assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && \ + (seq)->elem_size == sizeof(elem_type)), \ + (elem_type*)((seq)->first && (unsigned)index < \ + (unsigned)((seq)->first->count) ? \ + (seq)->first->data + (index) * sizeof(elem_type) : \ + cvGetSeqElem( (CvSeq*)(seq), (index) ))) +#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) ) + +/* macro that adds element to sequence */ +#define CV_WRITE_SEQ_ELEM_VAR( elem_ptr, writer ) \ +{ \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + memcpy((writer).ptr, elem_ptr, (writer).seq->elem_size);\ + (writer).ptr += (writer).seq->elem_size; \ +} + +#define CV_WRITE_SEQ_ELEM( elem, writer ) \ +{ \ + assert( (writer).seq->elem_size == sizeof(elem)); \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + assert( (writer).ptr <= (writer).block_max - sizeof(elem));\ + memcpy((writer).ptr, &(elem), sizeof(elem)); \ + (writer).ptr += sizeof(elem); \ +} + + +/* move reader position forward */ +#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr += (elem_size)) >= (reader).block_max ) \ + { \ + cvChangeSeqBlock( &(reader), 1 ); \ + } \ +} + + +/* move reader position backward */ +#define CV_PREV_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr -= (elem_size)) < (reader).block_min ) \ + { \ + cvChangeSeqBlock( &(reader), -1 ); \ + } \ +} + +/* read element and move read position forward */ +#define CV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy( &(elem), (reader).ptr, sizeof((elem))); \ + CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \ +} + +/* read element and move read position backward */ +#define CV_REV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy(&(elem), (reader).ptr, sizeof((elem))); \ + CV_PREV_SEQ_ELEM( sizeof(elem), reader ) \ +} + + +#define CV_READ_CHAIN_POINT( _pt, reader ) \ +{ \ + (_pt) = (reader).pt; \ + if( (reader).ptr ) \ + { \ + CV_READ_SEQ_ELEM( (reader).code, (reader)); \ + assert( ((reader).code & ~7) == 0 ); \ + (reader).pt.x += (reader).deltas[(int)(reader).code][0]; \ + (reader).pt.y += (reader).deltas[(int)(reader).code][1]; \ + } \ +} + +#define CV_CURRENT_POINT( reader ) (*((CvPoint*)((reader).ptr))) +#define CV_PREV_POINT( reader ) (*((CvPoint*)((reader).prev_elem))) + +#define CV_READ_EDGE( pt1, pt2, reader ) \ +{ \ + assert( sizeof(pt1) == sizeof(CvPoint) && \ + sizeof(pt2) == sizeof(CvPoint) && \ + reader.seq->elem_size == sizeof(CvPoint)); \ + (pt1) = CV_PREV_POINT( reader ); \ + (pt2) = CV_CURRENT_POINT( reader ); \ + (reader).prev_elem = (reader).ptr; \ + CV_NEXT_SEQ_ELEM( sizeof(CvPoint), (reader)); \ +} + +/************ Graph macros ************/ + +/* returns next graph edge for given vertex */ +#define CV_NEXT_GRAPH_EDGE( edge, vertex ) \ + (assert((edge)->vtx[0] == (vertex) || (edge)->vtx[1] == (vertex)), \ + (edge)->next[(edge)->vtx[1] == (vertex)]) + + + +/****************************************************************************************\ +* Data structures for persistence (a.k.a serialization) functionality * +\****************************************************************************************/ + +/* "black box" file storage */ +typedef struct CvFileStorage CvFileStorage; + +/* storage flags */ +#define CV_STORAGE_READ 0 +#define CV_STORAGE_WRITE 1 +#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE +#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE +#define CV_STORAGE_APPEND 2 + +/* list of attributes */ +typedef struct CvAttrList +{ + const char** attr; /* NULL-terminated array of (attribute_name,attribute_value) pairs */ + struct CvAttrList* next; /* pointer to next chunk of the attributes list */ +} +CvAttrList; + +CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL), + CvAttrList* next CV_DEFAULT(NULL) ) +{ + CvAttrList l; + l.attr = attr; + l.next = next; + + return l; +} + +struct CvTypeInfo; + +#define CV_NODE_NONE 0 +#define CV_NODE_INT 1 +#define CV_NODE_INTEGER CV_NODE_INT +#define CV_NODE_REAL 2 +#define CV_NODE_FLOAT CV_NODE_REAL +#define CV_NODE_STR 3 +#define CV_NODE_STRING CV_NODE_STR +#define CV_NODE_REF 4 /* not used */ +#define CV_NODE_SEQ 5 +#define CV_NODE_MAP 6 +#define CV_NODE_TYPE_MASK 7 + +#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK) + +/* file node flags */ +#define CV_NODE_FLOW 8 /* used only for writing structures to YAML format */ +#define CV_NODE_USER 16 +#define CV_NODE_EMPTY 32 +#define CV_NODE_NAMED 64 + +#define CV_NODE_IS_INT(flags) (CV_NODE_TYPE(flags) == CV_NODE_INT) +#define CV_NODE_IS_REAL(flags) (CV_NODE_TYPE(flags) == CV_NODE_REAL) +#define CV_NODE_IS_STRING(flags) (CV_NODE_TYPE(flags) == CV_NODE_STRING) +#define CV_NODE_IS_SEQ(flags) (CV_NODE_TYPE(flags) == CV_NODE_SEQ) +#define CV_NODE_IS_MAP(flags) (CV_NODE_TYPE(flags) == CV_NODE_MAP) +#define CV_NODE_IS_COLLECTION(flags) (CV_NODE_TYPE(flags) >= CV_NODE_SEQ) +#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0) +#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0) +#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0) +#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0) + +#define CV_NODE_SEQ_SIMPLE 256 +#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0) + +typedef struct CvString +{ + int len; + char* ptr; +} +CvString; + +/* all the keys (names) of elements in the readed file storage + are stored in the hash to speed up the lookup operations */ +typedef struct CvStringHashNode +{ + unsigned hashval; + CvString str; + struct CvStringHashNode* next; +} +CvStringHashNode; + +typedef struct CvGenericHash CvFileNodeHash; + +/* basic element of the file storage - scalar or collection */ +typedef struct CvFileNode +{ + int tag; + struct CvTypeInfo* info; /* type information + (only for user-defined object, for others it is 0) */ + union + { + double f; /* scalar floating-point number */ + int i; /* scalar integer number */ + CvString str; /* text string */ + CvSeq* seq; /* sequence (ordered collection of file nodes) */ + CvFileNodeHash* map; /* map (collection of named file nodes) */ + } data; +} +CvFileNode; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr ); +typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr ); +typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); +typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name, + const void* struct_ptr, CvAttrList attributes ); +typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); +#ifdef __cplusplus +} +#endif + +typedef struct CvTypeInfo +{ + int flags; + int header_size; + struct CvTypeInfo* prev; + struct CvTypeInfo* next; + const char* type_name; + CvIsInstanceFunc is_instance; + CvReleaseFunc release; + CvReadFunc read; + CvWriteFunc write; + CvCloneFunc clone; +} +CvTypeInfo; + + +/**** System data types ******/ + +typedef struct CvPluginFuncInfo +{ + void** func_addr; + void* default_func_addr; + const char* func_names; + int search_modules; + int loaded_from; +} +CvPluginFuncInfo; + +typedef struct CvModuleInfo +{ + struct CvModuleInfo* next; + const char* name; + const char* version; + CvPluginFuncInfo* func_tab; +} +CvModuleInfo; + +#endif /*_CXCORE_TYPES_H_*/ + +/* End of file. */ diff --git a/include/opencv/highgui.h b/include/opencv/highgui.h new file mode 100755 index 0000000..aa004e9 --- /dev/null +++ b/include/opencv/highgui.h @@ -0,0 +1,486 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _HIGH_GUI_ +#define _HIGH_GUI_ + +#ifndef SKIP_INCLUDES + + #include "cxcore.h" + #if defined WIN32 || defined WIN64 + #include + #endif + +#else // SKIP_INCLUDES + + #if defined WIN32 || defined WIN64 + #define CV_CDECL __cdecl + #define CV_STDCALL __stdcall + #else + #define CV_CDECL + #define CV_STDCALL + #endif + + #ifndef CV_EXTERN_C + #ifdef __cplusplus + #define CV_EXTERN_C extern "C" + #define CV_DEFAULT(val) = val + #else + #define CV_EXTERN_C + #define CV_DEFAULT(val) + #endif + #endif + + #ifndef CV_EXTERN_C_FUNCPTR + #ifdef __cplusplus + #define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } + #else + #define CV_EXTERN_C_FUNCPTR(x) typedef x + #endif + #endif + + #ifndef CV_INLINE + #if defined __cplusplus + #define CV_INLINE inline + #elif (defined WIN32 || defined WIN64) && !defined __GNUC__ + #define CV_INLINE __inline + #else + #define CV_INLINE static inline + #endif + #endif /* CV_INLINE */ + + #if (defined WIN32 || defined WIN64) && defined CVAPI_EXPORTS + #define CV_EXPORTS __declspec(dllexport) + #else + #define CV_EXPORTS + #endif + + #ifndef CVAPI + #define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL + #endif + +#endif // SKIP_INCLUDES + +#if defined(_CH_) + #pragma package + #include + LOAD_CHDL(highgui) +#endif + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + +/****************************************************************************************\ +* Basic GUI functions * +\****************************************************************************************/ + +/* this function is used to set some external parameters in case of X Window */ +CVAPI(int) cvInitSystem( int argc, char** argv ); + +CVAPI(int) cvStartWindowThread(); + +#define CV_WINDOW_AUTOSIZE 1 +/* create window */ +CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) ); + +/* display image within window (highgui windows remember their content) */ +CVAPI(void) cvShowImage( const char* name, const CvArr* image ); + +/* resize/move window */ +CVAPI(void) cvResizeWindow( const char* name, int width, int height ); +CVAPI(void) cvMoveWindow( const char* name, int x, int y ); + + +/* destroy window and all the trackers associated with it */ +CVAPI(void) cvDestroyWindow( const char* name ); + +CVAPI(void) cvDestroyAllWindows(void); + +/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */ +CVAPI(void*) cvGetWindowHandle( const char* name ); + +/* get name of highgui window given its native handle */ +CVAPI(const char*) cvGetWindowName( void* window_handle ); + + +typedef void (CV_CDECL *CvTrackbarCallback)(int pos); + +/* create trackbar and display it on top of given window, set callback */ +CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name, + int* value, int count, CvTrackbarCallback on_change ); + +/* retrieve or set trackbar position */ +CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name ); +CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos ); + +#define CV_EVENT_MOUSEMOVE 0 +#define CV_EVENT_LBUTTONDOWN 1 +#define CV_EVENT_RBUTTONDOWN 2 +#define CV_EVENT_MBUTTONDOWN 3 +#define CV_EVENT_LBUTTONUP 4 +#define CV_EVENT_RBUTTONUP 5 +#define CV_EVENT_MBUTTONUP 6 +#define CV_EVENT_LBUTTONDBLCLK 7 +#define CV_EVENT_RBUTTONDBLCLK 8 +#define CV_EVENT_MBUTTONDBLCLK 9 + +#define CV_EVENT_FLAG_LBUTTON 1 +#define CV_EVENT_FLAG_RBUTTON 2 +#define CV_EVENT_FLAG_MBUTTON 4 +#define CV_EVENT_FLAG_CTRLKEY 8 +#define CV_EVENT_FLAG_SHIFTKEY 16 +#define CV_EVENT_FLAG_ALTKEY 32 + +typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param); + +/* assign callback for mouse events */ +CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, + void* param CV_DEFAULT(NULL)); + +/* 8bit, color or not */ +#define CV_LOAD_IMAGE_UNCHANGED -1 +/* 8bit, gray */ +#define CV_LOAD_IMAGE_GRAYSCALE 0 +/* ?, color */ +#define CV_LOAD_IMAGE_COLOR 1 +/* any depth, ? */ +#define CV_LOAD_IMAGE_ANYDEPTH 2 +/* ?, any color */ +#define CV_LOAD_IMAGE_ANYCOLOR 4 + +/* load image from file + iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED + overrides the other flags + using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED + unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit +*/ +CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); +CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); + +/* save image to file */ +CVAPI(int) cvSaveImage( const char* filename, const CvArr* image ); + +#define CV_CVTIMG_FLIP 1 +#define CV_CVTIMG_SWAP_RB 2 +/* utility function: convert one image to another with optional vertical flip */ +CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0)); + +/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */ +CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0)); + + +/****************************************************************************************\ +* Working with Video Files and Cameras * +\****************************************************************************************/ + +/* "black box" capture structure */ +typedef struct CvCapture CvCapture; + +/* start capturing frames from video file */ +CVAPI(CvCapture*) cvCreateFileCapture( const char* filename ); + +#define CV_CAP_ANY 0 // autodetect + +#define CV_CAP_MIL 100 // MIL proprietary drivers + +#define CV_CAP_VFW 200 // platform native +#define CV_CAP_V4L 200 +#define CV_CAP_V4L2 200 + +#define CV_CAP_FIREWARE 300 // IEEE 1394 drivers +#define CV_CAP_IEEE1394 300 +#define CV_CAP_DC1394 300 +#define CV_CAP_CMU1394 300 + +#define CV_CAP_STEREO 400 // TYZX proprietary drivers +#define CV_CAP_TYZX 400 +#define CV_TYZX_LEFT 400 +#define CV_TYZX_RIGHT 401 +#define CV_TYZX_COLOR 402 +#define CV_TYZX_Z 403 + +#define CV_CAP_QT 500 // QuickTime + +/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */ +CVAPI(CvCapture*) cvCreateCameraCapture( int index ); + +/* grab a frame, return 1 on success, 0 on fail. + this function is thought to be fast */ +CVAPI(int) cvGrabFrame( CvCapture* capture ); + +/* get the frame grabbed with cvGrabFrame(..) + This function may apply some frame processing like + frame decompression, flipping etc. + !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */ +CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture ); + +/* Just a combination of cvGrabFrame and cvRetrieveFrame + !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */ +CVAPI(IplImage*) cvQueryFrame( CvCapture* capture ); + +/* stop capturing/reading and free resources */ +CVAPI(void) cvReleaseCapture( CvCapture** capture ); + +#define CV_CAP_PROP_POS_MSEC 0 +#define CV_CAP_PROP_POS_FRAMES 1 +#define CV_CAP_PROP_POS_AVI_RATIO 2 +#define CV_CAP_PROP_FRAME_WIDTH 3 +#define CV_CAP_PROP_FRAME_HEIGHT 4 +#define CV_CAP_PROP_FPS 5 +#define CV_CAP_PROP_FOURCC 6 +#define CV_CAP_PROP_FRAME_COUNT 7 +#define CV_CAP_PROP_FORMAT 8 +#define CV_CAP_PROP_MODE 9 +#define CV_CAP_PROP_BRIGHTNESS 10 +#define CV_CAP_PROP_CONTRAST 11 +#define CV_CAP_PROP_SATURATION 12 +#define CV_CAP_PROP_HUE 13 +#define CV_CAP_PROP_GAIN 14 +#define CV_CAP_PROP_CONVERT_RGB 15 + + +/* retrieve or set capture properties */ +CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id ); +CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value ); + +/* "black box" video file writer structure */ +typedef struct CvVideoWriter CvVideoWriter; + +#define CV_FOURCC(c1,c2,c3,c4) \ + (((c1)&255) + (((c2)&255)<<8) + (((c3)&255)<<16) + (((c4)&255)<<24)) + +/* initialize video file writer */ +CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc, + double fps, CvSize frame_size, + int is_color CV_DEFAULT(1)); + +/* write frame to video file */ +CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image ); + +/* close video file writer */ +CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer ); + +/****************************************************************************************\ +* Obsolete functions/synonyms * +\****************************************************************************************/ + +#ifndef HIGHGUI_NO_BACKWARD_COMPATIBILITY + #define HIGHGUI_BACKWARD_COMPATIBILITY +#endif + +#ifdef HIGHGUI_BACKWARD_COMPATIBILITY + +#define cvCaptureFromFile cvCreateFileCapture +#define cvCaptureFromCAM cvCreateCameraCapture +#define cvCaptureFromAVI cvCaptureFromFile +#define cvCreateAVIWriter cvCreateVideoWriter +#define cvWriteToAVI cvWriteFrame +#define cvAddSearchPath(path) +#define cvvInitSystem cvInitSystem +#define cvvNamedWindow cvNamedWindow +#define cvvShowImage cvShowImage +#define cvvResizeWindow cvResizeWindow +#define cvvDestroyWindow cvDestroyWindow +#define cvvCreateTrackbar cvCreateTrackbar +#define cvvLoadImage(name) cvLoadImage((name),1) +#define cvvSaveImage cvSaveImage +#define cvvAddSearchPath cvAddSearchPath +#define cvvWaitKey(name) cvWaitKey(0) +#define cvvWaitKeyEx(name,delay) cvWaitKey(delay) +#define cvvConvertImage cvConvertImage +#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE +#define set_preprocess_func cvSetPreprocessFuncWin32 +#define set_postprocess_func cvSetPostprocessFuncWin32 + +#ifdef WIN32 + +typedef int (CV_CDECL * CvWin32WindowCallback)(HWND, UINT, WPARAM, LPARAM, int*); +CVAPI(void) cvSetPreprocessFuncWin32( CvWin32WindowCallback on_preprocess ); +CVAPI(void) cvSetPostprocessFuncWin32( CvWin32WindowCallback on_postprocess ); + +CV_INLINE int iplWidth( const IplImage* img ); +CV_INLINE int iplWidth( const IplImage* img ) +{ + return !img ? 0 : !img->roi ? img->width : img->roi->width; +} + +CV_INLINE int iplHeight( const IplImage* img ); +CV_INLINE int iplHeight( const IplImage* img ) +{ + return !img ? 0 : !img->roi ? img->height : img->roi->height; +} + +#endif + +#endif /* obsolete functions */ + +/* For use with Win32 */ +#ifdef WIN32 + +CV_INLINE RECT NormalizeRect( RECT r ); +CV_INLINE RECT NormalizeRect( RECT r ) +{ + int t; + + if( r.left > r.right ) + { + t = r.left; + r.left = r.right; + r.right = t; + } + + if( r.top > r.bottom ) + { + t = r.top; + r.top = r.bottom; + r.bottom = t; + } + + return r; +} + +CV_INLINE CvRect RectToCvRect( RECT sr ); +CV_INLINE CvRect RectToCvRect( RECT sr ) +{ + sr = NormalizeRect( sr ); + return cvRect( sr.left, sr.top, sr.right - sr.left, sr.bottom - sr.top ); +} + +CV_INLINE RECT CvRectToRect( CvRect sr ); +CV_INLINE RECT CvRectToRect( CvRect sr ) +{ + RECT dr; + dr.left = sr.x; + dr.top = sr.y; + dr.right = sr.x + sr.width; + dr.bottom = sr.y + sr.height; + + return dr; +} + +CV_INLINE IplROI RectToROI( RECT r ); +CV_INLINE IplROI RectToROI( RECT r ) +{ + IplROI roi; + r = NormalizeRect( r ); + roi.xOffset = r.left; + roi.yOffset = r.top; + roi.width = r.right - r.left; + roi.height = r.bottom - r.top; + roi.coi = 0; + + return roi; +} + +#endif /* WIN32 */ + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif /* __cplusplus */ + + +#if defined __cplusplus && (!defined WIN32 || !defined (__GNUC__)) + +#define CImage CvvImage + +/* CvvImage class definition */ +class CV_EXPORTS CvvImage +{ +public: + CvvImage(); + virtual ~CvvImage(); + + /* Create image (BGR or grayscale) */ + virtual bool Create( int width, int height, int bits_per_pixel, int image_origin = 0 ); + + /* Load image from specified file */ + virtual bool Load( const char* filename, int desired_color = 1 ); + + /* Load rectangle from the file */ + virtual bool LoadRect( const char* filename, + int desired_color, CvRect r ); + +#ifdef WIN32 + virtual bool LoadRect( const char* filename, + int desired_color, RECT r ) + { + return LoadRect( filename, desired_color, + cvRect( r.left, r.top, r.right - r.left, r.bottom - r.top )); + } +#endif + + /* Save entire image to specified file. */ + virtual bool Save( const char* filename ); + + /* Get copy of input image ROI */ + virtual void CopyOf( CvvImage& image, int desired_color = -1 ); + virtual void CopyOf( IplImage* img, int desired_color = -1 ); + + IplImage* GetImage() { return m_img; }; + virtual void Destroy(void); + + /* width and height of ROI */ + int Width() { return !m_img ? 0 : !m_img->roi ? m_img->width : m_img->roi->width; }; + int Height() { return !m_img ? 0 : !m_img->roi ? m_img->height : m_img->roi->height;}; + int Bpp() { return m_img ? (m_img->depth & 255)*m_img->nChannels : 0; }; + + virtual void Fill( int color ); + + /* draw to highgui window */ + virtual void Show( const char* window ); + +#ifdef WIN32 + /* draw part of image to the specified DC */ + virtual void Show( HDC dc, int x, int y, int width, int height, + int from_x = 0, int from_y = 0 ); + /* draw the current image ROI to the specified rectangle of the destination DC */ + virtual void DrawToHDC( HDC hDCDst, RECT* pDstRect ); +#endif + +protected: + + IplImage* m_img; +}; + +#endif /* __cplusplus */ + +#endif /* _HIGH_GUI_ */ diff --git a/include/opencv/ml.h b/include/opencv/ml.h new file mode 100755 index 0000000..fdf6fa6 --- /dev/null +++ b/include/opencv/ml.h @@ -0,0 +1,1476 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __ML_H__ +#define __ML_H__ + +// disable deprecation warning which appears in VisualStudio 8.0 +#if _MSC_VER >= 1400 +#pragma warning( disable : 4996 ) +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Main struct definitions * +\****************************************************************************************/ + +/* log(2*PI) */ +#define CV_LOG2PI (1.8378770664093454835606594728112) + +/* columns of matrix are training samples */ +#define CV_COL_SAMPLE 0 + +/* rows of matrix are training samples */ +#define CV_ROW_SAMPLE 1 + +#define CV_IS_ROW_SAMPLE(flags) ((flags) & CV_ROW_SAMPLE) + +struct CvVectors +{ + int type; + int dims, count; + CvVectors* next; + union + { + uchar** ptr; + float** fl; + double** db; + } data; +}; + +#if 0 +/* A structure, representing the lattice range of statmodel parameters. + It is used for optimizing statmodel parameters by cross-validation method. + The lattice is logarithmic, so must be greater then 1. */ +typedef struct CvParamLattice +{ + double min_val; + double max_val; + double step; +} +CvParamLattice; + +CV_INLINE CvParamLattice cvParamLattice( double min_val, double max_val, + double log_step ) +{ + CvParamLattice pl; + pl.min_val = MIN( min_val, max_val ); + pl.max_val = MAX( min_val, max_val ); + pl.step = MAX( log_step, 1. ); + return pl; +} + +CV_INLINE CvParamLattice cvDefaultParamLattice( void ) +{ + CvParamLattice pl = {0,0,0}; + return pl; +} +#endif + +/* Variable type */ +#define CV_VAR_NUMERICAL 0 +#define CV_VAR_ORDERED 0 +#define CV_VAR_CATEGORICAL 1 + +#define CV_TYPE_NAME_ML_SVM "opencv-ml-svm" +#define CV_TYPE_NAME_ML_KNN "opencv-ml-knn" +#define CV_TYPE_NAME_ML_NBAYES "opencv-ml-bayesian" +#define CV_TYPE_NAME_ML_EM "opencv-ml-em" +#define CV_TYPE_NAME_ML_BOOSTING "opencv-ml-boost-tree" +#define CV_TYPE_NAME_ML_TREE "opencv-ml-tree" +#define CV_TYPE_NAME_ML_ANN_MLP "opencv-ml-ann-mlp" +#define CV_TYPE_NAME_ML_CNN "opencv-ml-cnn" +#define CV_TYPE_NAME_ML_RTREES "opencv-ml-random-trees" + +class CV_EXPORTS CvStatModel +{ +public: + CvStatModel(); + virtual ~CvStatModel(); + + virtual void clear(); + + virtual void save( const char* filename, const char* name=0 ); + virtual void load( const char* filename, const char* name=0 ); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + +protected: + const char* default_model_name; +}; + + +/****************************************************************************************\ +* Normal Bayes Classifier * +\****************************************************************************************/ + +class CV_EXPORTS CvNormalBayesClassifier : public CvStatModel +{ +public: + CvNormalBayesClassifier(); + virtual ~CvNormalBayesClassifier(); + + CvNormalBayesClassifier( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx=0, const CvMat* _sample_idx=0 ); + + virtual bool train( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx = 0, const CvMat* _sample_idx=0, bool update=false ); + + virtual float predict( const CvMat* _samples, CvMat* results=0 ) const; + virtual void clear(); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + +protected: + int var_count, var_all; + CvMat* var_idx; + CvMat* cls_labels; + CvMat** count; + CvMat** sum; + CvMat** productsum; + CvMat** avg; + CvMat** inv_eigen_values; + CvMat** cov_rotate_mats; + CvMat* c; +}; + + +/****************************************************************************************\ +* K-Nearest Neighbour Classifier * +\****************************************************************************************/ + +// k Nearest Neighbors +class CV_EXPORTS CvKNearest : public CvStatModel +{ +public: + + CvKNearest(); + virtual ~CvKNearest(); + + CvKNearest( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _sample_idx=0, bool _is_regression=false, int max_k=32 ); + + virtual bool train( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _sample_idx=0, bool is_regression=false, + int _max_k=32, bool _update_base=false ); + + virtual float find_nearest( const CvMat* _samples, int k, CvMat* results=0, + const float** neighbors=0, CvMat* neighbor_responses=0, CvMat* dist=0 ) const; + + virtual void clear(); + int get_max_k() const; + int get_var_count() const; + int get_sample_count() const; + bool is_regression() const; + +protected: + + virtual float write_results( int k, int k1, int start, int end, + const float* neighbor_responses, const float* dist, CvMat* _results, + CvMat* _neighbor_responses, CvMat* _dist, Cv32suf* sort_buf ) const; + + virtual void find_neighbors_direct( const CvMat* _samples, int k, int start, int end, + float* neighbor_responses, const float** neighbors, float* dist ) const; + + + int max_k, var_count; + int total; + bool regression; + CvVectors* samples; +}; + +/****************************************************************************************\ +* Support Vector Machines * +\****************************************************************************************/ + +// SVM training parameters +struct CV_EXPORTS CvSVMParams +{ + CvSVMParams(); + CvSVMParams( int _svm_type, int _kernel_type, + double _degree, double _gamma, double _coef0, + double _C, double _nu, double _p, + CvMat* _class_weights, CvTermCriteria _term_crit ); + + int svm_type; + int kernel_type; + double degree; // for poly + double gamma; // for poly/rbf/sigmoid + double coef0; // for poly/sigmoid + + double C; // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR + double nu; // for CV_SVM_NU_SVC, CV_SVM_ONE_CLASS, and CV_SVM_NU_SVR + double p; // for CV_SVM_EPS_SVR + CvMat* class_weights; // for CV_SVM_C_SVC + CvTermCriteria term_crit; // termination criteria +}; + + +struct CV_EXPORTS CvSVMKernel +{ + typedef void (CvSVMKernel::*Calc)( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + CvSVMKernel(); + CvSVMKernel( const CvSVMParams* _params, Calc _calc_func ); + virtual bool create( const CvSVMParams* _params, Calc _calc_func ); + virtual ~CvSVMKernel(); + + virtual void clear(); + virtual void calc( int vcount, int n, const float** vecs, const float* another, float* results ); + + const CvSVMParams* params; + Calc calc_func; + + virtual void calc_non_rbf_base( int vec_count, int vec_size, const float** vecs, + const float* another, float* results, + double alpha, double beta ); + + virtual void calc_linear( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + virtual void calc_rbf( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + virtual void calc_poly( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + virtual void calc_sigmoid( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); +}; + + +struct CvSVMKernelRow +{ + CvSVMKernelRow* prev; + CvSVMKernelRow* next; + float* data; +}; + + +struct CvSVMSolutionInfo +{ + double obj; + double rho; + double upper_bound_p; + double upper_bound_n; + double r; // for Solver_NU +}; + +class CV_EXPORTS CvSVMSolver +{ +public: + typedef bool (CvSVMSolver::*SelectWorkingSet)( int& i, int& j ); + typedef float* (CvSVMSolver::*GetRow)( int i, float* row, float* dst, bool existed ); + typedef void (CvSVMSolver::*CalcRho)( double& rho, double& r ); + + CvSVMSolver(); + + CvSVMSolver( int count, int var_count, const float** samples, char* y, + int alpha_count, double* alpha, double Cp, double Cn, + CvMemStorage* storage, CvSVMKernel* kernel, GetRow get_row, + SelectWorkingSet select_working_set, CalcRho calc_rho ); + virtual bool create( int count, int var_count, const float** samples, char* y, + int alpha_count, double* alpha, double Cp, double Cn, + CvMemStorage* storage, CvSVMKernel* kernel, GetRow get_row, + SelectWorkingSet select_working_set, CalcRho calc_rho ); + virtual ~CvSVMSolver(); + + virtual void clear(); + virtual bool solve_generic( CvSVMSolutionInfo& si ); + + virtual bool solve_c_svc( int count, int var_count, const float** samples, char* y, + double Cp, double Cn, CvMemStorage* storage, + CvSVMKernel* kernel, double* alpha, CvSVMSolutionInfo& si ); + virtual bool solve_nu_svc( int count, int var_count, const float** samples, char* y, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + virtual bool solve_one_class( int count, int var_count, const float** samples, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + + virtual bool solve_eps_svr( int count, int var_count, const float** samples, const float* y, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + + virtual bool solve_nu_svr( int count, int var_count, const float** samples, const float* y, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + + virtual float* get_row_base( int i, bool* _existed ); + virtual float* get_row( int i, float* dst ); + + int sample_count; + int var_count; + int cache_size; + int cache_line_size; + const float** samples; + const CvSVMParams* params; + CvMemStorage* storage; + CvSVMKernelRow lru_list; + CvSVMKernelRow* rows; + + int alpha_count; + + double* G; + double* alpha; + + // -1 - lower bound, 0 - free, 1 - upper bound + char* alpha_status; + + char* y; + double* b; + float* buf[2]; + double eps; + int max_iter; + double C[2]; // C[0] == Cn, C[1] == Cp + CvSVMKernel* kernel; + + SelectWorkingSet select_working_set_func; + CalcRho calc_rho_func; + GetRow get_row_func; + + virtual bool select_working_set( int& i, int& j ); + virtual bool select_working_set_nu_svm( int& i, int& j ); + virtual void calc_rho( double& rho, double& r ); + virtual void calc_rho_nu_svm( double& rho, double& r ); + + virtual float* get_row_svc( int i, float* row, float* dst, bool existed ); + virtual float* get_row_one_class( int i, float* row, float* dst, bool existed ); + virtual float* get_row_svr( int i, float* row, float* dst, bool existed ); +}; + + +struct CvSVMDecisionFunc +{ + double rho; + int sv_count; + double* alpha; + int* sv_index; +}; + + +// SVM model +class CV_EXPORTS CvSVM : public CvStatModel +{ +public: + // SVM type + enum { C_SVC=100, NU_SVC=101, ONE_CLASS=102, EPS_SVR=103, NU_SVR=104 }; + + // SVM kernel type + enum { LINEAR=0, POLY=1, RBF=2, SIGMOID=3 }; + + CvSVM(); + virtual ~CvSVM(); + + CvSVM( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx=0, const CvMat* _sample_idx=0, + CvSVMParams _params=CvSVMParams() ); + + virtual bool train( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx=0, const CvMat* _sample_idx=0, + CvSVMParams _params=CvSVMParams() ); + + virtual float predict( const CvMat* _sample ) const; + virtual int get_support_vector_count() const; + virtual const float* get_support_vector(int i) const; + virtual void clear(); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + int get_var_count() const { return var_idx ? var_idx->cols : var_all; } + +protected: + + virtual bool set_params( const CvSVMParams& _params ); + virtual bool train1( int sample_count, int var_count, const float** samples, + const void* _responses, double Cp, double Cn, + CvMemStorage* _storage, double* alpha, double& rho ); + virtual void create_kernel(); + virtual void create_solver(); + + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + CvSVMParams params; + CvMat* class_labels; + int var_all; + float** sv; + int sv_total; + CvMat* var_idx; + CvMat* class_weights; + CvSVMDecisionFunc* decision_func; + CvMemStorage* storage; + + CvSVMSolver* solver; + CvSVMKernel* kernel; +}; + + +/* The function trains SVM model with optimal parameters, obtained by using cross-validation. +The parameters to be estimated should be indicated by setting theirs values to FLT_MAX. +The optimal parameters are saved in */ +/*CVAPI(CvStatModel*) +cvTrainSVM_CrossValidation( const CvMat* train_data, int tflag, + const CvMat* responses, + CvStatModelParams* model_params, + const CvStatModelParams* cross_valid_params, + const CvMat* comp_idx CV_DEFAULT(0), + const CvMat* sample_idx CV_DEFAULT(0), + const CvParamLattice* degree_lattice CV_DEFAULT(0), + const CvParamLattice* gamma_lattice CV_DEFAULT(0), + const CvParamLattice* coef0_lattice CV_DEFAULT(0), + const CvParamLattice* C_lattice CV_DEFAULT(0), + const CvParamLattice* nu_lattice CV_DEFAULT(0), + const CvParamLattice* p_lattice CV_DEFAULT(0) );*/ + +/****************************************************************************************\ +* Expectation - Maximization * +\****************************************************************************************/ + +struct CV_EXPORTS CvEMParams +{ + CvEMParams() : nclusters(10), cov_mat_type(1/*CvEM::COV_MAT_DIAGONAL*/), + start_step(0/*CvEM::START_AUTO_STEP*/), probs(0), weights(0), means(0), covs(0) + { + term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON ); + } + + CvEMParams( int _nclusters, int _cov_mat_type=1/*CvEM::COV_MAT_DIAGONAL*/, + int _start_step=0/*CvEM::START_AUTO_STEP*/, + CvTermCriteria _term_crit=cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON), + const CvMat* _probs=0, const CvMat* _weights=0, const CvMat* _means=0, const CvMat** _covs=0 ) : + nclusters(_nclusters), cov_mat_type(_cov_mat_type), start_step(_start_step), + probs(_probs), weights(_weights), means(_means), covs(_covs), term_crit(_term_crit) + {} + + int nclusters; + int cov_mat_type; + int start_step; + const CvMat* probs; + const CvMat* weights; + const CvMat* means; + const CvMat** covs; + CvTermCriteria term_crit; +}; + + +class CV_EXPORTS CvEM : public CvStatModel +{ +public: + // Type of covariation matrices + enum { COV_MAT_SPHERICAL=0, COV_MAT_DIAGONAL=1, COV_MAT_GENERIC=2 }; + + // The initial step + enum { START_E_STEP=1, START_M_STEP=2, START_AUTO_STEP=0 }; + + CvEM(); + CvEM( const CvMat* samples, const CvMat* sample_idx=0, + CvEMParams params=CvEMParams(), CvMat* labels=0 ); + virtual ~CvEM(); + + virtual bool train( const CvMat* samples, const CvMat* sample_idx=0, + CvEMParams params=CvEMParams(), CvMat* labels=0 ); + + virtual float predict( const CvMat* sample, CvMat* probs ) const; + virtual void clear(); + + int get_nclusters() const; + const CvMat* get_means() const; + const CvMat** get_covs() const; + const CvMat* get_weights() const; + const CvMat* get_probs() const; + +protected: + + virtual void set_params( const CvEMParams& params, + const CvVectors& train_data ); + virtual void init_em( const CvVectors& train_data ); + virtual double run_em( const CvVectors& train_data ); + virtual void init_auto( const CvVectors& samples ); + virtual void kmeans( const CvVectors& train_data, int nclusters, + CvMat* labels, CvTermCriteria criteria, + const CvMat* means ); + CvEMParams params; + double log_likelihood; + + CvMat* means; + CvMat** covs; + CvMat* weights; + CvMat* probs; + + CvMat* log_weight_div_det; + CvMat* inv_eigen_values; + CvMat** cov_rotate_mats; +}; + +/****************************************************************************************\ +* Decision Tree * +\****************************************************************************************/ + +struct CvPair32s32f +{ + int i; + float val; +}; + + +#define CV_DTREE_CAT_DIR(idx,subset) \ + (2*((subset[(idx)>>5]&(1 << ((idx) & 31)))==0)-1) + +struct CvDTreeSplit +{ + int var_idx; + int inversed; + float quality; + CvDTreeSplit* next; + union + { + int subset[2]; + struct + { + float c; + int split_point; + } + ord; + }; +}; + + +struct CvDTreeNode +{ + int class_idx; + int Tn; + double value; + + CvDTreeNode* parent; + CvDTreeNode* left; + CvDTreeNode* right; + + CvDTreeSplit* split; + + int sample_count; + int depth; + int* num_valid; + int offset; + int buf_idx; + double maxlr; + + // global pruning data + int complexity; + double alpha; + double node_risk, tree_risk, tree_error; + + // cross-validation pruning data + int* cv_Tn; + double* cv_node_risk; + double* cv_node_error; + + int get_num_valid(int vi) { return num_valid ? num_valid[vi] : sample_count; } + void set_num_valid(int vi, int n) { if( num_valid ) num_valid[vi] = n; } +}; + + +struct CV_EXPORTS CvDTreeParams +{ + int max_categories; + int max_depth; + int min_sample_count; + int cv_folds; + bool use_surrogates; + bool use_1se_rule; + bool truncate_pruned_tree; + float regression_accuracy; + const float* priors; + + CvDTreeParams() : max_categories(10), max_depth(INT_MAX), min_sample_count(10), + cv_folds(10), use_surrogates(true), use_1se_rule(true), + truncate_pruned_tree(true), regression_accuracy(0.01f), priors(0) + {} + + CvDTreeParams( int _max_depth, int _min_sample_count, + float _regression_accuracy, bool _use_surrogates, + int _max_categories, int _cv_folds, + bool _use_1se_rule, bool _truncate_pruned_tree, + const float* _priors ) : + max_categories(_max_categories), max_depth(_max_depth), + min_sample_count(_min_sample_count), cv_folds (_cv_folds), + use_surrogates(_use_surrogates), use_1se_rule(_use_1se_rule), + truncate_pruned_tree(_truncate_pruned_tree), + regression_accuracy(_regression_accuracy), + priors(_priors) + {} +}; + + +struct CV_EXPORTS CvDTreeTrainData +{ + CvDTreeTrainData(); + CvDTreeTrainData( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + const CvDTreeParams& _params=CvDTreeParams(), + bool _shared=false, bool _add_labels=false ); + virtual ~CvDTreeTrainData(); + + virtual void set_data( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + const CvDTreeParams& _params=CvDTreeParams(), + bool _shared=false, bool _add_labels=false, + bool _update_data=false ); + + virtual void get_vectors( const CvMat* _subsample_idx, + float* values, uchar* missing, float* responses, bool get_class_idx=false ); + + virtual CvDTreeNode* subsample_data( const CvMat* _subsample_idx ); + + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + // release all the data + virtual void clear(); + + int get_num_classes() const; + int get_var_type(int vi) const; + int get_work_var_count() const; + + virtual int* get_class_labels( CvDTreeNode* n ); + virtual float* get_ord_responses( CvDTreeNode* n ); + virtual int* get_labels( CvDTreeNode* n ); + virtual int* get_cat_var_data( CvDTreeNode* n, int vi ); + virtual CvPair32s32f* get_ord_var_data( CvDTreeNode* n, int vi ); + virtual int get_child_buf_idx( CvDTreeNode* n ); + + //////////////////////////////////// + + virtual bool set_params( const CvDTreeParams& params ); + virtual CvDTreeNode* new_node( CvDTreeNode* parent, int count, + int storage_idx, int offset ); + + virtual CvDTreeSplit* new_split_ord( int vi, float cmp_val, + int split_point, int inversed, float quality ); + virtual CvDTreeSplit* new_split_cat( int vi, float quality ); + virtual void free_node_data( CvDTreeNode* node ); + virtual void free_train_data(); + virtual void free_node( CvDTreeNode* node ); + + int sample_count, var_all, var_count, max_c_count; + int ord_var_count, cat_var_count; + bool have_labels, have_priors; + bool is_classifier; + + int buf_count, buf_size; + bool shared; + + CvMat* cat_count; + CvMat* cat_ofs; + CvMat* cat_map; + + CvMat* counts; + CvMat* buf; + CvMat* direction; + CvMat* split_buf; + + CvMat* var_idx; + CvMat* var_type; // i-th element = + // k<0 - ordered + // k>=0 - categorical, see k-th element of cat_* arrays + CvMat* priors; + CvMat* priors_mult; + + CvDTreeParams params; + + CvMemStorage* tree_storage; + CvMemStorage* temp_storage; + + CvDTreeNode* data_root; + + CvSet* node_heap; + CvSet* split_heap; + CvSet* cv_heap; + CvSet* nv_heap; + + CvRNG rng; +}; + + +class CV_EXPORTS CvDTree : public CvStatModel +{ +public: + CvDTree(); + virtual ~CvDTree(); + + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvDTreeParams params=CvDTreeParams() ); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx ); + + virtual CvDTreeNode* predict( const CvMat* _sample, const CvMat* _missing_data_mask=0, + bool preprocessed_input=false ) const; + virtual const CvMat* get_var_importance(); + virtual void clear(); + + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void write( CvFileStorage* fs, const char* name ); + + // special read & write methods for trees in the tree ensembles + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvDTreeTrainData* data ); + virtual void write( CvFileStorage* fs ); + + const CvDTreeNode* get_root() const; + int get_pruned_tree_idx() const; + CvDTreeTrainData* get_data(); + +protected: + + virtual bool do_train( const CvMat* _subsample_idx ); + + virtual void try_split_node( CvDTreeNode* n ); + virtual void split_node_data( CvDTreeNode* n ); + virtual CvDTreeSplit* find_best_split( CvDTreeNode* n ); + virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_surrogate_split_ord( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_surrogate_split_cat( CvDTreeNode* n, int vi ); + virtual double calc_node_dir( CvDTreeNode* node ); + virtual void complete_node_dir( CvDTreeNode* node ); + virtual void cluster_categories( const int* vectors, int vector_count, + int var_count, int* sums, int k, int* cluster_labels ); + + virtual void calc_node_value( CvDTreeNode* node ); + + virtual void prune_cv(); + virtual double update_tree_rnc( int T, int fold ); + virtual int cut_tree( int T, int fold, double min_alpha ); + virtual void free_prune_data(bool cut_tree); + virtual void free_tree(); + + virtual void write_node( CvFileStorage* fs, CvDTreeNode* node ); + virtual void write_split( CvFileStorage* fs, CvDTreeSplit* split ); + virtual CvDTreeNode* read_node( CvFileStorage* fs, CvFileNode* node, CvDTreeNode* parent ); + virtual CvDTreeSplit* read_split( CvFileStorage* fs, CvFileNode* node ); + virtual void write_tree_nodes( CvFileStorage* fs ); + virtual void read_tree_nodes( CvFileStorage* fs, CvFileNode* node ); + + CvDTreeNode* root; + + int pruned_tree_idx; + CvMat* var_importance; + + CvDTreeTrainData* data; +}; + + +/****************************************************************************************\ +* Random Trees Classifier * +\****************************************************************************************/ + +class CvRTrees; + +class CV_EXPORTS CvForestTree: public CvDTree +{ +public: + CvForestTree(); + virtual ~CvForestTree(); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx, CvRTrees* forest ); + + virtual int get_var_count() const {return data ? data->var_count : 0;} + virtual void read( CvFileStorage* fs, CvFileNode* node, CvRTrees* forest, CvDTreeTrainData* _data ); + + /* dummy methods to avoid warnings: BEGIN */ + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvDTreeParams params=CvDTreeParams() ); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx ); + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvDTreeTrainData* data ); + /* dummy methods to avoid warnings: END */ + +protected: + virtual CvDTreeSplit* find_best_split( CvDTreeNode* n ); + CvRTrees* forest; +}; + + +struct CV_EXPORTS CvRTParams : public CvDTreeParams +{ + //Parameters for the forest + bool calc_var_importance; // true <=> RF processes variable importance + int nactive_vars; + CvTermCriteria term_crit; + + CvRTParams() : CvDTreeParams( 5, 10, 0, false, 10, 0, false, false, 0 ), + calc_var_importance(false), nactive_vars(0) + { + term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 50, 0.1 ); + } + + CvRTParams( int _max_depth, int _min_sample_count, + float _regression_accuracy, bool _use_surrogates, + int _max_categories, const float* _priors, bool _calc_var_importance, + int _nactive_vars, int max_num_of_trees_in_the_forest, + float forest_accuracy, int termcrit_type ) : + CvDTreeParams( _max_depth, _min_sample_count, _regression_accuracy, + _use_surrogates, _max_categories, 0, + false, false, _priors ), + calc_var_importance(_calc_var_importance), + nactive_vars(_nactive_vars) + { + term_crit = cvTermCriteria(termcrit_type, + max_num_of_trees_in_the_forest, forest_accuracy); + } +}; + + +class CV_EXPORTS CvRTrees : public CvStatModel +{ +public: + CvRTrees(); + virtual ~CvRTrees(); + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvRTParams params=CvRTParams() ); + virtual float predict( const CvMat* sample, const CvMat* missing = 0 ) const; + virtual void clear(); + + virtual const CvMat* get_var_importance(); + virtual float get_proximity( const CvMat* sample1, const CvMat* sample2, + const CvMat* missing1 = 0, const CvMat* missing2 = 0 ) const; + + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void write( CvFileStorage* fs, const char* name ); + + CvMat* get_active_var_mask(); + CvRNG* get_rng(); + + int get_tree_count() const; + CvForestTree* get_tree(int i) const; + +protected: + + bool grow_forest( const CvTermCriteria term_crit ); + + // array of the trees of the forest + CvForestTree** trees; + CvDTreeTrainData* data; + int ntrees; + int nclasses; + double oob_error; + CvMat* var_importance; + int nsamples; + + CvRNG rng; + CvMat* active_var_mask; +}; + + +/****************************************************************************************\ +* Boosted tree classifier * +\****************************************************************************************/ + +struct CV_EXPORTS CvBoostParams : public CvDTreeParams +{ + int boost_type; + int weak_count; + int split_criteria; + double weight_trim_rate; + + CvBoostParams(); + CvBoostParams( int boost_type, int weak_count, double weight_trim_rate, + int max_depth, bool use_surrogates, const float* priors ); +}; + + +class CvBoost; + +class CV_EXPORTS CvBoostTree: public CvDTree +{ +public: + CvBoostTree(); + virtual ~CvBoostTree(); + + virtual bool train( CvDTreeTrainData* _train_data, + const CvMat* subsample_idx, CvBoost* ensemble ); + + virtual void scale( double s ); + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvBoost* ensemble, CvDTreeTrainData* _data ); + virtual void clear(); + + /* dummy methods to avoid warnings: BEGIN */ + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvDTreeParams params=CvDTreeParams() ); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx ); + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvDTreeTrainData* data ); + /* dummy methods to avoid warnings: END */ + +protected: + + virtual void try_split_node( CvDTreeNode* n ); + virtual CvDTreeSplit* find_surrogate_split_ord( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_surrogate_split_cat( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi ); + virtual void calc_node_value( CvDTreeNode* n ); + virtual double calc_node_dir( CvDTreeNode* n ); + + CvBoost* ensemble; +}; + + +class CV_EXPORTS CvBoost : public CvStatModel +{ +public: + // Boosting type + enum { DISCRETE=0, REAL=1, LOGIT=2, GENTLE=3 }; + + // Splitting criteria + enum { DEFAULT=0, GINI=1, MISCLASS=3, SQERR=4 }; + + CvBoost(); + virtual ~CvBoost(); + + CvBoost( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvBoostParams params=CvBoostParams() ); + + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvBoostParams params=CvBoostParams(), + bool update=false ); + + virtual float predict( const CvMat* _sample, const CvMat* _missing=0, + CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, + bool raw_mode=false ) const; + + virtual void prune( CvSlice slice ); + + virtual void clear(); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + + CvSeq* get_weak_predictors(); + + CvMat* get_weights(); + CvMat* get_subtree_weights(); + CvMat* get_weak_response(); + const CvBoostParams& get_params() const; + +protected: + + virtual bool set_params( const CvBoostParams& _params ); + virtual void update_weights( CvBoostTree* tree ); + virtual void trim_weights(); + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + CvDTreeTrainData* data; + CvBoostParams params; + CvSeq* weak; + + CvMat* orig_response; + CvMat* sum_response; + CvMat* weak_eval; + CvMat* subsample_mask; + CvMat* weights; + CvMat* subtree_weights; + bool have_subsample; +}; + + +/****************************************************************************************\ +* Artificial Neural Networks (ANN) * +\****************************************************************************************/ + +/////////////////////////////////// Multi-Layer Perceptrons ////////////////////////////// + +struct CV_EXPORTS CvANN_MLP_TrainParams +{ + CvANN_MLP_TrainParams(); + CvANN_MLP_TrainParams( CvTermCriteria term_crit, int train_method, + double param1, double param2=0 ); + ~CvANN_MLP_TrainParams(); + + enum { BACKPROP=0, RPROP=1 }; + + CvTermCriteria term_crit; + int train_method; + + // backpropagation parameters + double bp_dw_scale, bp_moment_scale; + + // rprop parameters + double rp_dw0, rp_dw_plus, rp_dw_minus, rp_dw_min, rp_dw_max; +}; + + +class CV_EXPORTS CvANN_MLP : public CvStatModel +{ +public: + CvANN_MLP(); + CvANN_MLP( const CvMat* _layer_sizes, + int _activ_func=SIGMOID_SYM, + double _f_param1=0, double _f_param2=0 ); + + virtual ~CvANN_MLP(); + + virtual void create( const CvMat* _layer_sizes, + int _activ_func=SIGMOID_SYM, + double _f_param1=0, double _f_param2=0 ); + + virtual int train( const CvMat* _inputs, const CvMat* _outputs, + const CvMat* _sample_weights, const CvMat* _sample_idx=0, + CvANN_MLP_TrainParams _params = CvANN_MLP_TrainParams(), + int flags=0 ); + virtual float predict( const CvMat* _inputs, + CvMat* _outputs ) const; + + virtual void clear(); + + // possible activation functions + enum { IDENTITY = 0, SIGMOID_SYM = 1, GAUSSIAN = 2 }; + + // available training flags + enum { UPDATE_WEIGHTS = 1, NO_INPUT_SCALE = 2, NO_OUTPUT_SCALE = 4 }; + + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void write( CvFileStorage* storage, const char* name ); + + int get_layer_count() { return layer_sizes ? layer_sizes->cols : 0; } + const CvMat* get_layer_sizes() { return layer_sizes; } + double* get_weights(int layer) + { + return layer_sizes && weights && + (unsigned)layer <= (unsigned)layer_sizes->cols ? weights[layer] : 0; + } + +protected: + + virtual bool prepare_to_train( const CvMat* _inputs, const CvMat* _outputs, + const CvMat* _sample_weights, const CvMat* _sample_idx, + CvVectors* _ivecs, CvVectors* _ovecs, double** _sw, int _flags ); + + // sequential random backpropagation + virtual int train_backprop( CvVectors _ivecs, CvVectors _ovecs, const double* _sw ); + + // RPROP algorithm + virtual int train_rprop( CvVectors _ivecs, CvVectors _ovecs, const double* _sw ); + + virtual void calc_activ_func( CvMat* xf, const double* bias ) const; + virtual void calc_activ_func_deriv( CvMat* xf, CvMat* deriv, const double* bias ) const; + virtual void set_activ_func( int _activ_func=SIGMOID_SYM, + double _f_param1=0, double _f_param2=0 ); + virtual void init_weights(); + virtual void scale_input( const CvMat* _src, CvMat* _dst ) const; + virtual void scale_output( const CvMat* _src, CvMat* _dst ) const; + virtual void calc_input_scale( const CvVectors* vecs, int flags ); + virtual void calc_output_scale( const CvVectors* vecs, int flags ); + + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + CvMat* layer_sizes; + CvMat* wbuf; + CvMat* sample_weights; + double** weights; + double f_param1, f_param2; + double min_val, max_val, min_val1, max_val1; + int activ_func; + int max_count, max_buf_sz; + CvANN_MLP_TrainParams params; + CvRNG rng; +}; + +#if 0 +/****************************************************************************************\ +* Convolutional Neural Network * +\****************************************************************************************/ +typedef struct CvCNNLayer CvCNNLayer; +typedef struct CvCNNetwork CvCNNetwork; + +#define CV_CNN_LEARN_RATE_DECREASE_HYPERBOLICALLY 1 +#define CV_CNN_LEARN_RATE_DECREASE_SQRT_INV 2 +#define CV_CNN_LEARN_RATE_DECREASE_LOG_INV 3 + +#define CV_CNN_GRAD_ESTIM_RANDOM 0 +#define CV_CNN_GRAD_ESTIM_BY_WORST_IMG 1 + +#define ICV_CNN_LAYER 0x55550000 +#define ICV_CNN_CONVOLUTION_LAYER 0x00001111 +#define ICV_CNN_SUBSAMPLING_LAYER 0x00002222 +#define ICV_CNN_FULLCONNECT_LAYER 0x00003333 + +#define ICV_IS_CNN_LAYER( layer ) \ + ( ((layer) != NULL) && ((((CvCNNLayer*)(layer))->flags & CV_MAGIC_MASK)\ + == ICV_CNN_LAYER )) + +#define ICV_IS_CNN_CONVOLUTION_LAYER( layer ) \ + ( (ICV_IS_CNN_LAYER( layer )) && (((CvCNNLayer*) (layer))->flags \ + & ~CV_MAGIC_MASK) == ICV_CNN_CONVOLUTION_LAYER ) + +#define ICV_IS_CNN_SUBSAMPLING_LAYER( layer ) \ + ( (ICV_IS_CNN_LAYER( layer )) && (((CvCNNLayer*) (layer))->flags \ + & ~CV_MAGIC_MASK) == ICV_CNN_SUBSAMPLING_LAYER ) + +#define ICV_IS_CNN_FULLCONNECT_LAYER( layer ) \ + ( (ICV_IS_CNN_LAYER( layer )) && (((CvCNNLayer*) (layer))->flags \ + & ~CV_MAGIC_MASK) == ICV_CNN_FULLCONNECT_LAYER ) + +typedef void (CV_CDECL *CvCNNLayerForward) + ( CvCNNLayer* layer, const CvMat* input, CvMat* output ); + +typedef void (CV_CDECL *CvCNNLayerBackward) + ( CvCNNLayer* layer, int t, const CvMat* X, const CvMat* dE_dY, CvMat* dE_dX ); + +typedef void (CV_CDECL *CvCNNLayerRelease) + (CvCNNLayer** layer); + +typedef void (CV_CDECL *CvCNNetworkAddLayer) + (CvCNNetwork* network, CvCNNLayer* layer); + +typedef void (CV_CDECL *CvCNNetworkRelease) + (CvCNNetwork** network); + +#define CV_CNN_LAYER_FIELDS() \ + /* Indicator of the layer's type */ \ + int flags; \ + \ + /* Number of input images */ \ + int n_input_planes; \ + /* Height of each input image */ \ + int input_height; \ + /* Width of each input image */ \ + int input_width; \ + \ + /* Number of output images */ \ + int n_output_planes; \ + /* Height of each output image */ \ + int output_height; \ + /* Width of each output image */ \ + int output_width; \ + \ + /* Learning rate at the first iteration */ \ + float init_learn_rate; \ + /* Dynamics of learning rate decreasing */ \ + int learn_rate_decrease_type; \ + /* Trainable weights of the layer (including bias) */ \ + /* i-th row is a set of weights of the i-th output plane */ \ + CvMat* weights; \ + \ + CvCNNLayerForward forward; \ + CvCNNLayerBackward backward; \ + CvCNNLayerRelease release; \ + /* Pointers to the previous and next layers in the network */ \ + CvCNNLayer* prev_layer; \ + CvCNNLayer* next_layer + +typedef struct CvCNNLayer +{ + CV_CNN_LAYER_FIELDS(); +}CvCNNLayer; + +typedef struct CvCNNConvolutionLayer +{ + CV_CNN_LAYER_FIELDS(); + // Kernel size (height and width) for convolution. + int K; + // connections matrix, (i,j)-th element is 1 iff there is a connection between + // i-th plane of the current layer and j-th plane of the previous layer; + // (i,j)-th element is equal to 0 otherwise + CvMat *connect_mask; + // value of the learning rate for updating weights at the first iteration +}CvCNNConvolutionLayer; + +typedef struct CvCNNSubSamplingLayer +{ + CV_CNN_LAYER_FIELDS(); + // ratio between the heights (or widths - ratios are supposed to be equal) + // of the input and output planes + int sub_samp_scale; + // amplitude of sigmoid activation function + float a; + // scale parameter of sigmoid activation function + float s; + // exp2ssumWX = exp(2*(bias+w*(x1+...+x4))), where x1,...x4 are some elements of X + // - is the vector used in computing of the activation function in backward + CvMat* exp2ssumWX; + // (x1+x2+x3+x4), where x1,...x4 are some elements of X + // - is the vector used in computing of the activation function in backward + CvMat* sumX; +}CvCNNSubSamplingLayer; + +// Structure of the last layer. +typedef struct CvCNNFullConnectLayer +{ + CV_CNN_LAYER_FIELDS(); + // amplitude of sigmoid activation function + float a; + // scale parameter of sigmoid activation function + float s; + // exp2ssumWX = exp(2**(W*X)) - is the vector used in computing of the + // activation function and it's derivative by the formulae + // activ.func. =
(exp(2WX)-1)/(exp(2WX)+1) == - 2/( + 1) + // (activ.func.)' = 4exp(2WX)/(exp(2WX)+1)^2 + CvMat* exp2ssumWX; +}CvCNNFullConnectLayer; + +typedef struct CvCNNetwork +{ + int n_layers; + CvCNNLayer* layers; + CvCNNetworkAddLayer add_layer; + CvCNNetworkRelease release; +}CvCNNetwork; + +typedef struct CvCNNStatModel +{ + CV_STAT_MODEL_FIELDS(); + CvCNNetwork* network; + // etalons are allocated as rows, the i-th etalon has label cls_labeles[i] + CvMat* etalons; + // classes labels + CvMat* cls_labels; +}CvCNNStatModel; + +typedef struct CvCNNStatModelParams +{ + CV_STAT_MODEL_PARAM_FIELDS(); + // network must be created by the functions cvCreateCNNetwork and + CvCNNetwork* network; + CvMat* etalons; + // termination criteria + int max_iter; + int start_iter; + int grad_estim_type; +}CvCNNStatModelParams; + +CVAPI(CvCNNLayer*) cvCreateCNNConvolutionLayer( + int n_input_planes, int input_height, int input_width, + int n_output_planes, int K, + float init_learn_rate, int learn_rate_decrease_type, + CvMat* connect_mask CV_DEFAULT(0), CvMat* weights CV_DEFAULT(0) ); + +CVAPI(CvCNNLayer*) cvCreateCNNSubSamplingLayer( + int n_input_planes, int input_height, int input_width, + int sub_samp_scale, float a, float s, + float init_learn_rate, int learn_rate_decrease_type, CvMat* weights CV_DEFAULT(0) ); + +CVAPI(CvCNNLayer*) cvCreateCNNFullConnectLayer( + int n_inputs, int n_outputs, float a, float s, + float init_learn_rate, int learning_type, CvMat* weights CV_DEFAULT(0) ); + +CVAPI(CvCNNetwork*) cvCreateCNNetwork( CvCNNLayer* first_layer ); + +CVAPI(CvStatModel*) cvTrainCNNClassifier( + const CvMat* train_data, int tflag, + const CvMat* responses, + const CvStatModelParams* params, + const CvMat* CV_DEFAULT(0), + const CvMat* sample_idx CV_DEFAULT(0), + const CvMat* CV_DEFAULT(0), const CvMat* CV_DEFAULT(0) ); + +/****************************************************************************************\ +* Estimate classifiers algorithms * +\****************************************************************************************/ +typedef const CvMat* (CV_CDECL *CvStatModelEstimateGetMat) + ( const CvStatModel* estimateModel ); + +typedef int (CV_CDECL *CvStatModelEstimateNextStep) + ( CvStatModel* estimateModel ); + +typedef void (CV_CDECL *CvStatModelEstimateCheckClassifier) + ( CvStatModel* estimateModel, + const CvStatModel* model, + const CvMat* features, + int sample_t_flag, + const CvMat* responses ); + +typedef void (CV_CDECL *CvStatModelEstimateCheckClassifierEasy) + ( CvStatModel* estimateModel, + const CvStatModel* model ); + +typedef float (CV_CDECL *CvStatModelEstimateGetCurrentResult) + ( const CvStatModel* estimateModel, + float* correlation ); + +typedef void (CV_CDECL *CvStatModelEstimateReset) + ( CvStatModel* estimateModel ); + +//-------------------------------- Cross-validation -------------------------------------- +#define CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_PARAM_FIELDS() \ + CV_STAT_MODEL_PARAM_FIELDS(); \ + int k_fold; \ + int is_regression; \ + CvRNG* rng + +typedef struct CvCrossValidationParams +{ + CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_PARAM_FIELDS(); +} CvCrossValidationParams; + +#define CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_FIELDS() \ + CvStatModelEstimateGetMat getTrainIdxMat; \ + CvStatModelEstimateGetMat getCheckIdxMat; \ + CvStatModelEstimateNextStep nextStep; \ + CvStatModelEstimateCheckClassifier check; \ + CvStatModelEstimateGetCurrentResult getResult; \ + CvStatModelEstimateReset reset; \ + int is_regression; \ + int folds_all; \ + int samples_all; \ + int* sampleIdxAll; \ + int* folds; \ + int max_fold_size; \ + int current_fold; \ + int is_checked; \ + CvMat* sampleIdxTrain; \ + CvMat* sampleIdxEval; \ + CvMat* predict_results; \ + int correct_results; \ + int all_results; \ + double sq_error; \ + double sum_correct; \ + double sum_predict; \ + double sum_cc; \ + double sum_pp; \ + double sum_cp + +typedef struct CvCrossValidationModel +{ + CV_STAT_MODEL_FIELDS(); + CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_FIELDS(); +} CvCrossValidationModel; + +CVAPI(CvStatModel*) +cvCreateCrossValidationEstimateModel + ( int samples_all, + const CvStatModelParams* estimateParams CV_DEFAULT(0), + const CvMat* sampleIdx CV_DEFAULT(0) ); + +CVAPI(float) +cvCrossValidation( const CvMat* trueData, + int tflag, + const CvMat* trueClasses, + CvStatModel* (*createClassifier)( const CvMat*, + int, + const CvMat*, + const CvStatModelParams*, + const CvMat*, + const CvMat*, + const CvMat*, + const CvMat* ), + const CvStatModelParams* estimateParams CV_DEFAULT(0), + const CvStatModelParams* trainParams CV_DEFAULT(0), + const CvMat* compIdx CV_DEFAULT(0), + const CvMat* sampleIdx CV_DEFAULT(0), + CvStatModel** pCrValModel CV_DEFAULT(0), + const CvMat* typeMask CV_DEFAULT(0), + const CvMat* missedMeasurementMask CV_DEFAULT(0) ); +#endif + +/****************************************************************************************\ +* Auxilary functions declarations * +\****************************************************************************************/ + +/* Generates from multivariate normal distribution, where - is an + average row vector, - symmetric covariation matrix */ +CVAPI(void) cvRandMVNormal( CvMat* mean, CvMat* cov, CvMat* sample, + CvRNG* rng CV_DEFAULT(0) ); + +/* Generates sample from gaussian mixture distribution */ +CVAPI(void) cvRandGaussMixture( CvMat* means[], + CvMat* covs[], + float weights[], + int clsnum, + CvMat* sample, + CvMat* sampClasses CV_DEFAULT(0) ); + +#define CV_TS_CONCENTRIC_SPHERES 0 + +/* creates test set */ +CVAPI(void) cvCreateTestSet( int type, CvMat** samples, + int num_samples, + int num_features, + CvMat** responses, + int num_classes, ... ); + +/* Aij <- Aji for i > j if lower_to_upper != 0 + for i < j if lower_to_upper = 0 */ +CVAPI(void) cvCompleteSymm( CvMat* matrix, int lower_to_upper ); + +#ifdef __cplusplus +} +#endif + +#endif /*__ML_H__*/ +/* End of file. */ diff --git a/include/openssl/aes.h b/include/openssl/aes.h new file mode 100755 index 0000000..015a1e4 --- /dev/null +++ b/include/openssl/aes.h @@ -0,0 +1,138 @@ +/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + */ + +#ifndef HEADER_AES_H +#define HEADER_AES_H + +#include + +#ifdef OPENSSL_NO_AES +#error AES is disabled. +#endif + +#define AES_ENCRYPT 1 +#define AES_DECRYPT 0 + +/* Because array size can't be a const in C, the following two are macros. + Both sizes are in bytes. */ +#define AES_MAXNR 14 +#define AES_BLOCK_SIZE 16 + +#ifdef __cplusplus +extern "C" { +#endif + +/* This should be a hidden type, but EVP requires that the size be known */ +struct aes_key_st { +#ifdef AES_LONG + unsigned long rd_key[4 *(AES_MAXNR + 1)]; +#else + unsigned int rd_key[4 *(AES_MAXNR + 1)]; +#endif + int rounds; +}; +typedef struct aes_key_st AES_KEY; + +const char *AES_options(void); + +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); + +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); + +void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key, const int enc); +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, + const int nbits,const AES_KEY *key, + unsigned char *ivec,const int enc); +void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num); +void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char ivec[AES_BLOCK_SIZE], + unsigned char ecount_buf[AES_BLOCK_SIZE], + unsigned int *num); + +/* For IGE, see also http://www.links.org/files/openssl-ige.pdf */ +/* NB: the IV is _two_ blocks long */ +void AES_ige_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +/* NB: the IV is _four_ blocks long */ +void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + const AES_KEY *key2, const unsigned char *ivec, + const int enc); + + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_AES_H */ diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h new file mode 100755 index 0000000..8671b80 --- /dev/null +++ b/include/openssl/asn1.h @@ -0,0 +1,1233 @@ +/* crypto/asn1/asn1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_H +#define HEADER_ASN1_H + +#include +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#include + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define V_ASN1_UNIVERSAL 0x00 +#define V_ASN1_APPLICATION 0x40 +#define V_ASN1_CONTEXT_SPECIFIC 0x80 +#define V_ASN1_PRIVATE 0xc0 + +#define V_ASN1_CONSTRUCTED 0x20 +#define V_ASN1_PRIMITIVE_TAG 0x1f +#define V_ASN1_PRIMATIVE_TAG 0x1f + +#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ +#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +#define V_ASN1_ANY -4 /* used in ASN1 template code */ + +#define V_ASN1_NEG 0x100 /* negative flag */ + +#define V_ASN1_UNDEF -1 +#define V_ASN1_EOC 0 +#define V_ASN1_BOOLEAN 1 /**/ +#define V_ASN1_INTEGER 2 +#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) +#define V_ASN1_BIT_STRING 3 +#define V_ASN1_OCTET_STRING 4 +#define V_ASN1_NULL 5 +#define V_ASN1_OBJECT 6 +#define V_ASN1_OBJECT_DESCRIPTOR 7 +#define V_ASN1_EXTERNAL 8 +#define V_ASN1_REAL 9 +#define V_ASN1_ENUMERATED 10 +#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) +#define V_ASN1_UTF8STRING 12 +#define V_ASN1_SEQUENCE 16 +#define V_ASN1_SET 17 +#define V_ASN1_NUMERICSTRING 18 /**/ +#define V_ASN1_PRINTABLESTRING 19 +#define V_ASN1_T61STRING 20 +#define V_ASN1_TELETEXSTRING 20 /* alias */ +#define V_ASN1_VIDEOTEXSTRING 21 /**/ +#define V_ASN1_IA5STRING 22 +#define V_ASN1_UTCTIME 23 +#define V_ASN1_GENERALIZEDTIME 24 /**/ +#define V_ASN1_GRAPHICSTRING 25 /**/ +#define V_ASN1_ISO64STRING 26 /**/ +#define V_ASN1_VISIBLESTRING 26 /* alias */ +#define V_ASN1_GENERALSTRING 27 /**/ +#define V_ASN1_UNIVERSALSTRING 28 /**/ +#define V_ASN1_BMPSTRING 30 + +/* For use with d2i_ASN1_type_bytes() */ +#define B_ASN1_NUMERICSTRING 0x0001 +#define B_ASN1_PRINTABLESTRING 0x0002 +#define B_ASN1_T61STRING 0x0004 +#define B_ASN1_TELETEXSTRING 0x0004 +#define B_ASN1_VIDEOTEXSTRING 0x0008 +#define B_ASN1_IA5STRING 0x0010 +#define B_ASN1_GRAPHICSTRING 0x0020 +#define B_ASN1_ISO64STRING 0x0040 +#define B_ASN1_VISIBLESTRING 0x0040 +#define B_ASN1_GENERALSTRING 0x0080 +#define B_ASN1_UNIVERSALSTRING 0x0100 +#define B_ASN1_OCTET_STRING 0x0200 +#define B_ASN1_BIT_STRING 0x0400 +#define B_ASN1_BMPSTRING 0x0800 +#define B_ASN1_UNKNOWN 0x1000 +#define B_ASN1_UTF8STRING 0x2000 +#define B_ASN1_UTCTIME 0x4000 +#define B_ASN1_GENERALIZEDTIME 0x8000 +#define B_ASN1_SEQUENCE 0x10000 + +/* For use with ASN1_mbstring_copy() */ +#define MBSTRING_FLAG 0x1000 +#define MBSTRING_UTF8 (MBSTRING_FLAG) +#define MBSTRING_ASC (MBSTRING_FLAG|1) +#define MBSTRING_BMP (MBSTRING_FLAG|2) +#define MBSTRING_UNIV (MBSTRING_FLAG|4) + +struct X509_algor_st; + +#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ +#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ + +/* We MUST make sure that, except for constness, asn1_ctx_st and + asn1_const_ctx are exactly the same. Fortunately, as soon as + the old ASN1 parsing macros are gone, we can throw this away + as well... */ +typedef struct asn1_ctx_st + { + unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + unsigned char *max; /* largest value of p allowed */ + unsigned char *q;/* temporary variable */ + unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_CTX; + +typedef struct asn1_const_ctx_st + { + const unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + const unsigned char *max; /* largest value of p allowed */ + const unsigned char *q;/* temporary variable */ + const unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_const_CTX; + +/* These are used internally in the ASN1_OBJECT to keep track of + * whether the names and data need to be free()ed */ +#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ +#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ +#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ +#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ +typedef struct asn1_object_st + { + const char *sn,*ln; + int nid; + int length; + unsigned char *data; + int flags; /* Should we free this one */ + } ASN1_OBJECT; + +#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ +/* This indicates that the ASN1_STRING is not a real value but just a place + * holder for the location where indefinite length constructed data should + * be inserted in the memory buffer + */ +#define ASN1_STRING_FLAG_NDEF 0x010 +/* This is the base type that holds just about everything :-) */ +typedef struct asn1_string_st + { + int length; + int type; + unsigned char *data; + /* The value of the following field depends on the type being + * held. It is mostly being used for BIT_STRING so if the + * input data has a non-zero 'unused bits' value, it will be + * handled correctly */ + long flags; + } ASN1_STRING; + +/* ASN1_ENCODING structure: this is used to save the received + * encoding of an ASN1 type. This is useful to get round + * problems with invalid encodings which can break signatures. + */ + +typedef struct ASN1_ENCODING_st + { + unsigned char *enc; /* DER encoding */ + long len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ + } ASN1_ENCODING; + +/* Used with ASN1 LONG type: if a long is set to this it is omitted */ +#define ASN1_LONG_UNDEF 0x7fffffffL + +#define STABLE_FLAGS_MALLOC 0x01 +#define STABLE_NO_MASK 0x02 +#define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) +#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) + +typedef struct asn1_string_table_st { + int nid; + long minsize; + long maxsize; + unsigned long mask; + unsigned long flags; +} ASN1_STRING_TABLE; + +DECLARE_STACK_OF(ASN1_STRING_TABLE) + +/* size limits: this stuff is taken straight from RFC2459 */ + +#define ub_name 32768 +#define ub_common_name 64 +#define ub_locality_name 128 +#define ub_state_name 128 +#define ub_organization_name 64 +#define ub_organization_unit_name 64 +#define ub_title 64 +#define ub_email_address 128 + +/* Declarations for template structures: for full definitions + * see asn1t.h + */ +typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; +typedef struct ASN1_ITEM_st ASN1_ITEM; +typedef struct ASN1_TLC_st ASN1_TLC; +/* This is just an opaque pointer */ +typedef struct ASN1_VALUE_st ASN1_VALUE; + +/* Declare ASN1 functions: the implement macro in in asn1t.h */ + +#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) + +#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(itname) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(const type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(name) + +#define DECLARE_ASN1_NDEF_FUNCTION(name) \ + int i2d_##name##_NDEF(name *a, unsigned char **out); + +#define DECLARE_ASN1_FUNCTIONS_const(name) \ + name *name##_new(void); \ + void name##_free(name *a); + +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + type *name##_new(void); \ + void name##_free(type *a); + +#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) +#define I2D_OF(type) int (*)(type *,unsigned char **) +#define I2D_OF_const(type) int (*)(const type *,unsigned char **) + +#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) +#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) +#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) + +TYPEDEF_D2I2D_OF(void); + +/* The following macros and typedefs allow an ASN1_ITEM + * to be embedded in a structure and referenced. Since + * the ASN1_ITEM pointers need to be globally accessible + * (possibly from shared libraries) they may exist in + * different forms. On platforms that support it the + * ASN1_ITEM structure itself will be globally exported. + * Other platforms will export a function that returns + * an ASN1_ITEM pointer. + * + * To handle both cases transparently the macros below + * should be used instead of hard coding an ASN1_ITEM + * pointer in a structure. + * + * The structure will look like this: + * + * typedef struct SOMETHING_st { + * ... + * ASN1_ITEM_EXP *iptr; + * ... + * } SOMETHING; + * + * It would be initialised as e.g.: + * + * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; + * + * and the actual pointer extracted with: + * + * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); + * + * Finally an ASN1_ITEM pointer can be extracted from an + * appropriate reference with: ASN1_ITEM_rptr(X509). This + * would be used when a function takes an ASN1_ITEM * argument. + * + */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM ASN1_ITEM_EXP; + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) + +#define ASN1_ITEM_rptr(ref) (&(ref##_it)) + +#define DECLARE_ASN1_ITEM(name) \ + OPENSSL_EXTERN const ASN1_ITEM name##_it; + +#else + +/* Platforms that can't easily handle shared global variables are declared + * as functions returning ASN1_ITEM pointers. + */ + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM * ASN1_ITEM_EXP(void); + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr()) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (iptr##_it) + +#define ASN1_ITEM_rptr(ref) (ref##_it()) + +#define DECLARE_ASN1_ITEM(name) \ + const ASN1_ITEM * name##_it(void); + +#endif + +/* Parameters used by ASN1_STRING_print_ex() */ + +/* These determine which characters to escape: + * RFC2253 special characters, control characters and + * MSB set characters + */ + +#define ASN1_STRFLGS_ESC_2253 1 +#define ASN1_STRFLGS_ESC_CTRL 2 +#define ASN1_STRFLGS_ESC_MSB 4 + + +/* This flag determines how we do escaping: normally + * RC2253 backslash only, set this to use backslash and + * quote. + */ + +#define ASN1_STRFLGS_ESC_QUOTE 8 + + +/* These three flags are internal use only. */ + +/* Character is a valid PrintableString character */ +#define CHARTYPE_PRINTABLESTRING 0x10 +/* Character needs escaping if it is the first character */ +#define CHARTYPE_FIRST_ESC_2253 0x20 +/* Character needs escaping if it is the last character */ +#define CHARTYPE_LAST_ESC_2253 0x40 + +/* NB the internal flags are safely reused below by flags + * handled at the top level. + */ + +/* If this is set we convert all character strings + * to UTF8 first + */ + +#define ASN1_STRFLGS_UTF8_CONVERT 0x10 + +/* If this is set we don't attempt to interpret content: + * just assume all strings are 1 byte per character. This + * will produce some pretty odd looking output! + */ + +#define ASN1_STRFLGS_IGNORE_TYPE 0x20 + +/* If this is set we include the string type in the output */ +#define ASN1_STRFLGS_SHOW_TYPE 0x40 + +/* This determines which strings to display and which to + * 'dump' (hex dump of content octets or DER encoding). We can + * only dump non character strings or everything. If we + * don't dump 'unknown' they are interpreted as character + * strings with 1 octet per character and are subject to + * the usual escaping options. + */ + +#define ASN1_STRFLGS_DUMP_ALL 0x80 +#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 + +/* These determine what 'dumping' does, we can dump the + * content octets or the DER encoding: both use the + * RFC2253 #XXXXX notation. + */ + +#define ASN1_STRFLGS_DUMP_DER 0x200 + +/* All the string flags consistent with RFC2253, + * escaping control characters isn't essential in + * RFC2253 but it is advisable anyway. + */ + +#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER) + +DECLARE_STACK_OF(ASN1_INTEGER) +DECLARE_ASN1_SET_OF(ASN1_INTEGER) + +DECLARE_STACK_OF(ASN1_GENERALSTRING) + +typedef struct asn1_type_st + { + int type; + union { + char *ptr; + ASN1_BOOLEAN boolean; + ASN1_STRING * asn1_string; + ASN1_OBJECT * object; + ASN1_INTEGER * integer; + ASN1_ENUMERATED * enumerated; + ASN1_BIT_STRING * bit_string; + ASN1_OCTET_STRING * octet_string; + ASN1_PRINTABLESTRING * printablestring; + ASN1_T61STRING * t61string; + ASN1_IA5STRING * ia5string; + ASN1_GENERALSTRING * generalstring; + ASN1_BMPSTRING * bmpstring; + ASN1_UNIVERSALSTRING * universalstring; + ASN1_UTCTIME * utctime; + ASN1_GENERALIZEDTIME * generalizedtime; + ASN1_VISIBLESTRING * visiblestring; + ASN1_UTF8STRING * utf8string; + /* set and sequence are left complete and still + * contain the set or sequence bytes */ + ASN1_STRING * set; + ASN1_STRING * sequence; + } value; + } ASN1_TYPE; + +DECLARE_STACK_OF(ASN1_TYPE) +DECLARE_ASN1_SET_OF(ASN1_TYPE) + +typedef struct asn1_method_st + { + i2d_of_void *i2d; + d2i_of_void *d2i; + void *(*create)(void); + void (*destroy)(void *); + } ASN1_METHOD; + +/* This is used when parsing some Netscape objects */ +typedef struct asn1_header_st + { + ASN1_OCTET_STRING *header; + void *data; + ASN1_METHOD *meth; + } ASN1_HEADER; + +/* This is used to contain a list of bit names */ +typedef struct BIT_STRING_BITNAME_st { + int bitnum; + const char *lname; + const char *sname; +} BIT_STRING_BITNAME; + + +#define M_ASN1_STRING_length(x) ((x)->length) +#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) +#define M_ASN1_STRING_type(x) ((x)->type) +#define M_ASN1_STRING_data(x) ((x)->data) + +/* Macros for string operations */ +#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ + ASN1_STRING_type_new(V_ASN1_BIT_STRING) +#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) + +#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ + ASN1_STRING_type_new(V_ASN1_INTEGER) +#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ + ASN1_STRING_type_new(V_ASN1_ENUMERATED) +#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ + ASN1_STRING_type_new(V_ASN1_OCTET_STRING) +#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) +#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) +#define M_i2d_ASN1_OCTET_STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ + V_ASN1_UNIVERSAL) + +#define B_ASN1_TIME \ + B_ASN1_UTCTIME | \ + B_ASN1_GENERALIZEDTIME + +#define B_ASN1_PRINTABLE \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_T61STRING| \ + B_ASN1_IA5STRING| \ + B_ASN1_BIT_STRING| \ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING|\ + B_ASN1_SEQUENCE|\ + B_ASN1_UNKNOWN + +#define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_TELETEXSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_UTF8STRING + +#define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING| \ + B_ASN1_VISIBLESTRING| \ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING + +#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_PRINTABLE) + +#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DIRECTORYSTRING(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DIRECTORYSTRING) + +#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DISPLAYTEXT(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DISPLAYTEXT) + +#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ + (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) + +#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ + ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_T61STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_T61STRING(a,pp,l) \ + (ASN1_T61STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) + +#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ + ASN1_STRING_type_new(V_ASN1_IA5STRING) +#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_IA5STRING_dup(a) \ + (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_i2d_ASN1_IA5STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_IA5STRING(a,pp,l) \ + (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ + B_ASN1_IA5STRING) + +#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ + ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) +#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ + (ASN1_STRING *)a) + +#define M_ASN1_TIME_new() (ASN1_TIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_GENERALSTRING) +#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_GENERALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ + (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) + +#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) +#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ + (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) + +#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ + ASN1_STRING_type_new(V_ASN1_BMPSTRING) +#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_BMPSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_BMPSTRING(a,pp,l) \ + (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) + +#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ + (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) + +#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ + ASN1_STRING_type_new(V_ASN1_UTF8STRING) +#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UTF8STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UTF8STRING(a,pp,l) \ + (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) + + /* for the is_set parameter to i2d_ASN1_SET */ +#define IS_SEQUENCE 0 +#define IS_SET 1 + +DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) + +int ASN1_TYPE_get(ASN1_TYPE *a); +void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); + +ASN1_OBJECT * ASN1_OBJECT_new(void ); +void ASN1_OBJECT_free(ASN1_OBJECT *a); +int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); +ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); +ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); + +DECLARE_ASN1_ITEM(ASN1_OBJECT) + +DECLARE_STACK_OF(ASN1_OBJECT) +DECLARE_ASN1_SET_OF(ASN1_OBJECT) + +ASN1_STRING * ASN1_STRING_new(void); +void ASN1_STRING_free(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_type_new(int type ); +int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); + /* Since this is used to store all sorts of things, via macros, for now, make + its data void * */ +int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); +int ASN1_STRING_length(ASN1_STRING *x); +void ASN1_STRING_length_set(ASN1_STRING *x, int n); +int ASN1_STRING_type(ASN1_STRING *x); +unsigned char * ASN1_STRING_data(ASN1_STRING *x); + +DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) +int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); +ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp, + long length); +int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, + int length ); +int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); +int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); + +#ifndef OPENSSL_NO_BIO +int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, + BIT_STRING_BITNAME *tbl, int indent); +#endif +int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); +int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, + BIT_STRING_BITNAME *tbl); + +int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); +int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) +int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); +ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); +int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); + +DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) + +int ASN1_UTCTIME_check(ASN1_UTCTIME *a); +ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); +int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); +int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); +#if 0 +time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); +#endif + +int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); +int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); + +DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) +ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); +int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); +int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); + +DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_NULL) +DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) + +int UTF8_getc(const unsigned char *str, int len, unsigned long *val); +int UTF8_putc(unsigned char *str, int len, unsigned long value); + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) +DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_TIME) + +DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) + +ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); +int ASN1_TIME_check(ASN1_TIME *t); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); + +int i2d_ASN1_SET(STACK *a, unsigned char **pp, + i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); +STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, + d2i_of_void *d2i, void (*free_func)(void *), + int ex_tag, int ex_class); + +#ifndef OPENSSL_NO_BIO +int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); +int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); +int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); +int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size); +int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); +int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size); +int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); +#endif +int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a); + +int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); +ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, + const char *sn, const char *ln); + +int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); +long ASN1_INTEGER_get(ASN1_INTEGER *a); +ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai); +BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn); + +int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); +long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); +ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); +BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); + +/* General */ +/* given a string, return the correct type, max is the maximum length */ +int ASN1_PRINTABLE_type(const unsigned char *s, int max); + +int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); +ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, + long length, int Ptag, int Pclass); +unsigned long ASN1_tag2bit(int tag); +/* type is one or more of the B_ASN1_ values. */ +ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, + long length,int type); + +/* PARSING */ +int asn1_Finish(ASN1_CTX *c); +int asn1_const_Finish(ASN1_const_CTX *c); + +/* SPECIALS */ +int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax); +int ASN1_check_infinite_end(unsigned char **p,long len); +int ASN1_const_check_infinite_end(const unsigned char **p,long len); +void ASN1_put_object(unsigned char **pp, int constructed, int length, + int tag, int xclass); +int ASN1_put_eoc(unsigned char **pp); +int ASN1_object_size(int constructed, int length, int tag); + +/* Used to implement other functions */ +void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); +#define ASN1_dup_of(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) +#define ASN1_dup_of_const(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) + +void *ASN1_item_dup(const ASN1_ITEM *it, void *x); + +#ifndef OPENSSL_NO_FP_API +void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); +#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x) +void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); +int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); +#define ASN1_i2d_fp_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +#define ASN1_i2d_fp_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); +int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); +#endif + +int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); + +#ifndef OPENSSL_NO_BIO +void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); +#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x) +void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); +int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); +#define ASN1_i2d_bio_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +#define ASN1_i2d_bio_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); +int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); +int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); +int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); +int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); +int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); +int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); +int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); +#endif +const char *ASN1_tag2str(int tag); + +/* Used to load and write netscape format cert/key */ +int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); +ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length); +ASN1_HEADER *ASN1_HEADER_new(void ); +void ASN1_HEADER_free(ASN1_HEADER *a); + +int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); + +/* Not used that much at this point, except for the first two */ +ASN1_METHOD *X509_asn1_meth(void); +ASN1_METHOD *RSAPrivateKey_asn1_meth(void); +ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void); +ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void); + +int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, + unsigned char *data, int len); +int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, + unsigned char *data, int max_len); +int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, + unsigned char *data, int max_len); + +STACK *ASN1_seq_unpack(const unsigned char *buf, int len, + d2i_of_void *d2i, void (*free_func)(void *)); +unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, + unsigned char **buf, int *len ); +void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); +void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); +ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, + ASN1_OCTET_STRING **oct); +#define ASN1_pack_string_of(type,obj,i2d,oct) \ + ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct) +ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); + +void ASN1_STRING_set_default_mask(unsigned long mask); +int ASN1_STRING_set_default_mask_asc(char *p); +unsigned long ASN1_STRING_get_default_mask(void); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask); +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask, + long minsize, long maxsize); + +ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, + const unsigned char *in, int inlen, int inform, int nid); +ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); +int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); +void ASN1_STRING_TABLE_cleanup(void); + +/* ASN1 template functions */ + +/* Old API compatible functions */ +ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); +void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); +ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); +int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); +int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); + +void ASN1_add_oid_module(void); + +ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); +ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ASN1_strings(void); + +/* Error codes for the ASN1 functions. */ + +/* Function codes. */ +#define ASN1_F_A2D_ASN1_OBJECT 100 +#define ASN1_F_A2I_ASN1_ENUMERATED 101 +#define ASN1_F_A2I_ASN1_INTEGER 102 +#define ASN1_F_A2I_ASN1_STRING 103 +#define ASN1_F_APPEND_EXP 176 +#define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 +#define ASN1_F_ASN1_CB 177 +#define ASN1_F_ASN1_CHECK_TLEN 104 +#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 +#define ASN1_F_ASN1_COLLECT 106 +#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 +#define ASN1_F_ASN1_D2I_FP 109 +#define ASN1_F_ASN1_D2I_READ_BIO 107 +#define ASN1_F_ASN1_DIGEST 184 +#define ASN1_F_ASN1_DO_ADB 110 +#define ASN1_F_ASN1_DUP 111 +#define ASN1_F_ASN1_ENUMERATED_SET 112 +#define ASN1_F_ASN1_ENUMERATED_TO_BN 113 +#define ASN1_F_ASN1_EX_C2I 204 +#define ASN1_F_ASN1_FIND_END 190 +#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 +#define ASN1_F_ASN1_GENERATE_V3 178 +#define ASN1_F_ASN1_GET_OBJECT 114 +#define ASN1_F_ASN1_HEADER_NEW 115 +#define ASN1_F_ASN1_I2D_BIO 116 +#define ASN1_F_ASN1_I2D_FP 117 +#define ASN1_F_ASN1_INTEGER_SET 118 +#define ASN1_F_ASN1_INTEGER_TO_BN 119 +#define ASN1_F_ASN1_ITEM_D2I_FP 206 +#define ASN1_F_ASN1_ITEM_DUP 191 +#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 +#define ASN1_F_ASN1_ITEM_EX_D2I 120 +#define ASN1_F_ASN1_ITEM_I2D_BIO 192 +#define ASN1_F_ASN1_ITEM_I2D_FP 193 +#define ASN1_F_ASN1_ITEM_PACK 198 +#define ASN1_F_ASN1_ITEM_SIGN 195 +#define ASN1_F_ASN1_ITEM_UNPACK 199 +#define ASN1_F_ASN1_ITEM_VERIFY 197 +#define ASN1_F_ASN1_MBSTRING_NCOPY 122 +#define ASN1_F_ASN1_OBJECT_NEW 123 +#define ASN1_F_ASN1_PACK_STRING 124 +#define ASN1_F_ASN1_PCTX_NEW 205 +#define ASN1_F_ASN1_PKCS5_PBE_SET 125 +#define ASN1_F_ASN1_SEQ_PACK 126 +#define ASN1_F_ASN1_SEQ_UNPACK 127 +#define ASN1_F_ASN1_SIGN 128 +#define ASN1_F_ASN1_STR2TYPE 179 +#define ASN1_F_ASN1_STRING_SET 186 +#define ASN1_F_ASN1_STRING_TABLE_ADD 129 +#define ASN1_F_ASN1_STRING_TYPE_NEW 130 +#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 +#define ASN1_F_ASN1_TEMPLATE_NEW 133 +#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 +#define ASN1_F_ASN1_TIME_SET 175 +#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 +#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 +#define ASN1_F_ASN1_UNPACK_STRING 136 +#define ASN1_F_ASN1_UTCTIME_SET 187 +#define ASN1_F_ASN1_VERIFY 137 +#define ASN1_F_BITSTR_CB 180 +#define ASN1_F_BN_TO_ASN1_ENUMERATED 138 +#define ASN1_F_BN_TO_ASN1_INTEGER 139 +#define ASN1_F_C2I_ASN1_BIT_STRING 189 +#define ASN1_F_C2I_ASN1_INTEGER 194 +#define ASN1_F_C2I_ASN1_OBJECT 196 +#define ASN1_F_COLLECT_DATA 140 +#define ASN1_F_D2I_ASN1_BIT_STRING 141 +#define ASN1_F_D2I_ASN1_BOOLEAN 142 +#define ASN1_F_D2I_ASN1_BYTES 143 +#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 +#define ASN1_F_D2I_ASN1_HEADER 145 +#define ASN1_F_D2I_ASN1_INTEGER 146 +#define ASN1_F_D2I_ASN1_OBJECT 147 +#define ASN1_F_D2I_ASN1_SET 148 +#define ASN1_F_D2I_ASN1_TYPE_BYTES 149 +#define ASN1_F_D2I_ASN1_UINTEGER 150 +#define ASN1_F_D2I_ASN1_UTCTIME 151 +#define ASN1_F_D2I_NETSCAPE_RSA 152 +#define ASN1_F_D2I_NETSCAPE_RSA_2 153 +#define ASN1_F_D2I_PRIVATEKEY 154 +#define ASN1_F_D2I_PUBLICKEY 155 +#define ASN1_F_D2I_RSA_NET 200 +#define ASN1_F_D2I_RSA_NET_2 201 +#define ASN1_F_D2I_X509 156 +#define ASN1_F_D2I_X509_CINF 157 +#define ASN1_F_D2I_X509_PKEY 159 +#define ASN1_F_I2D_ASN1_SET 188 +#define ASN1_F_I2D_ASN1_TIME 160 +#define ASN1_F_I2D_DSA_PUBKEY 161 +#define ASN1_F_I2D_EC_PUBKEY 181 +#define ASN1_F_I2D_PRIVATEKEY 163 +#define ASN1_F_I2D_PUBLICKEY 164 +#define ASN1_F_I2D_RSA_NET 162 +#define ASN1_F_I2D_RSA_PUBKEY 165 +#define ASN1_F_LONG_C2I 166 +#define ASN1_F_OID_MODULE_INIT 174 +#define ASN1_F_PARSE_TAGGING 182 +#define ASN1_F_PKCS5_PBE2_SET 167 +#define ASN1_F_PKCS5_PBE_SET 202 +#define ASN1_F_X509_CINF_NEW 168 +#define ASN1_F_X509_CRL_ADD0_REVOKED 169 +#define ASN1_F_X509_INFO_NEW 170 +#define ASN1_F_X509_NAME_ENCODE 203 +#define ASN1_F_X509_NAME_EX_D2I 158 +#define ASN1_F_X509_NAME_EX_NEW 171 +#define ASN1_F_X509_NEW 172 +#define ASN1_F_X509_PKEY_NEW 173 + +/* Reason codes. */ +#define ASN1_R_ADDING_OBJECT 171 +#define ASN1_R_AUX_ERROR 100 +#define ASN1_R_BAD_CLASS 101 +#define ASN1_R_BAD_OBJECT_HEADER 102 +#define ASN1_R_BAD_PASSWORD_READ 103 +#define ASN1_R_BAD_TAG 104 +#define ASN1_R_BN_LIB 105 +#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 +#define ASN1_R_BUFFER_TOO_SMALL 107 +#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 +#define ASN1_R_DATA_IS_WRONG 109 +#define ASN1_R_DECODE_ERROR 110 +#define ASN1_R_DECODING_ERROR 111 +#define ASN1_R_DEPTH_EXCEEDED 174 +#define ASN1_R_ENCODE_ERROR 112 +#define ASN1_R_ERROR_GETTING_TIME 173 +#define ASN1_R_ERROR_LOADING_SECTION 172 +#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 +#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 +#define ASN1_R_EXPECTING_AN_INTEGER 115 +#define ASN1_R_EXPECTING_AN_OBJECT 116 +#define ASN1_R_EXPECTING_A_BOOLEAN 117 +#define ASN1_R_EXPECTING_A_TIME 118 +#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 +#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 +#define ASN1_R_FIELD_MISSING 121 +#define ASN1_R_FIRST_NUM_TOO_LARGE 122 +#define ASN1_R_HEADER_TOO_LONG 123 +#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 +#define ASN1_R_ILLEGAL_BOOLEAN 176 +#define ASN1_R_ILLEGAL_CHARACTERS 124 +#define ASN1_R_ILLEGAL_FORMAT 177 +#define ASN1_R_ILLEGAL_HEX 178 +#define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 +#define ASN1_R_ILLEGAL_INTEGER 180 +#define ASN1_R_ILLEGAL_NESTED_TAGGING 181 +#define ASN1_R_ILLEGAL_NULL 125 +#define ASN1_R_ILLEGAL_NULL_VALUE 182 +#define ASN1_R_ILLEGAL_OBJECT 183 +#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 +#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 +#define ASN1_R_ILLEGAL_TAGGED_ANY 127 +#define ASN1_R_ILLEGAL_TIME_VALUE 184 +#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 +#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 +#define ASN1_R_INVALID_BMPSTRING_LENGTH 129 +#define ASN1_R_INVALID_DIGIT 130 +#define ASN1_R_INVALID_MODIFIER 186 +#define ASN1_R_INVALID_NUMBER 187 +#define ASN1_R_INVALID_SEPARATOR 131 +#define ASN1_R_INVALID_TIME_FORMAT 132 +#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 +#define ASN1_R_INVALID_UTF8STRING 134 +#define ASN1_R_IV_TOO_LARGE 135 +#define ASN1_R_LENGTH_ERROR 136 +#define ASN1_R_LIST_ERROR 188 +#define ASN1_R_MISSING_EOC 137 +#define ASN1_R_MISSING_SECOND_NUMBER 138 +#define ASN1_R_MISSING_VALUE 189 +#define ASN1_R_MSTRING_NOT_UNIVERSAL 139 +#define ASN1_R_MSTRING_WRONG_TAG 140 +#define ASN1_R_NESTED_ASN1_STRING 197 +#define ASN1_R_NON_HEX_CHARACTERS 141 +#define ASN1_R_NOT_ASCII_FORMAT 190 +#define ASN1_R_NOT_ENOUGH_DATA 142 +#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 +#define ASN1_R_NULL_IS_WRONG_LENGTH 144 +#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 +#define ASN1_R_ODD_NUMBER_OF_CHARS 145 +#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 +#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 +#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 +#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 +#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 +#define ASN1_R_SHORT_LINE 150 +#define ASN1_R_STRING_TOO_LONG 151 +#define ASN1_R_STRING_TOO_SHORT 152 +#define ASN1_R_TAG_VALUE_TOO_HIGH 153 +#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 +#define ASN1_R_TIME_NOT_ASCII_FORMAT 193 +#define ASN1_R_TOO_LONG 155 +#define ASN1_R_TYPE_NOT_CONSTRUCTED 156 +#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 +#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 +#define ASN1_R_UNEXPECTED_EOC 159 +#define ASN1_R_UNKNOWN_FORMAT 160 +#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 +#define ASN1_R_UNKNOWN_OBJECT_TYPE 162 +#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 +#define ASN1_R_UNKNOWN_TAG 194 +#define ASN1_R_UNKOWN_FORMAT 195 +#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 +#define ASN1_R_UNSUPPORTED_CIPHER 165 +#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 +#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 +#define ASN1_R_UNSUPPORTED_TYPE 196 +#define ASN1_R_WRONG_TAG 168 +#define ASN1_R_WRONG_TYPE 169 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/asn1_mac.h b/include/openssl/asn1_mac.h new file mode 100755 index 0000000..1ac54cf --- /dev/null +++ b/include/openssl/asn1_mac.h @@ -0,0 +1,571 @@ +/* crypto/asn1/asn1_mac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_MAC_H +#define HEADER_ASN1_MAC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASN1_MAC_ERR_LIB +#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1 +#endif + +#define ASN1_MAC_H_err(f,r,line) \ + ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line)) + +#define M_ASN1_D2I_vars(a,type,func) \ + ASN1_const_CTX c; \ + type ret=NULL; \ + \ + c.pp=(const unsigned char **)pp; \ + c.q= *(const unsigned char **)pp; \ + c.error=ERR_R_NESTED_ASN1_ERROR; \ + if ((a == NULL) || ((*a) == NULL)) \ + { if ((ret=(type)func()) == NULL) \ + { c.line=__LINE__; goto err; } } \ + else ret=(*a); + +#define M_ASN1_D2I_Init() \ + c.p= *(const unsigned char **)pp; \ + c.max=(length == 0)?0:(c.p+length); + +#define M_ASN1_D2I_Finish_2(a) \ + if (!asn1_const_Finish(&c)) \ + { c.line=__LINE__; goto err; } \ + *(const unsigned char **)pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); + +#define M_ASN1_D2I_Finish(a,func,e) \ + M_ASN1_D2I_Finish_2(a); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_start_sequence() \ + if (!asn1_GetSequence(&c,&length)) \ + { c.line=__LINE__; goto err; } +/* Begin reading ASN1 without a surrounding sequence */ +#define M_ASN1_D2I_begin() \ + c.slen = length; + +/* End reading ASN1 with no check on length */ +#define M_ASN1_D2I_Finish_nolen(a, func, e) \ + *pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_end_sequence() \ + (((c.inf&1) == 0)?(c.slen <= 0): \ + (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen))) + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get(b, func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get_x(type,b,func) \ + c.q=c.p; \ + if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* use this instead () */ +#define M_ASN1_D2I_get_int(b,func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) < 0) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_opt(b,func,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ + == (V_ASN1_UNIVERSAL|(type)))) \ + { \ + M_ASN1_D2I_get(b,func); \ + } + +#define M_ASN1_D2I_get_imp(b,func, type) \ + M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \ + c.slen-=(c.p-c.q);\ + M_ASN1_next_prev=_tmp; + +#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \ + (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \ + { \ + unsigned char _tmp = M_ASN1_next; \ + M_ASN1_D2I_get_imp(b,func, type);\ + } + +#define M_ASN1_D2I_get_set(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set(r,func,free_func); } + +#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set_type(type,r,func,free_func); } + +#define M_ASN1_I2D_len_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SET(a,f); + +#define M_ASN1_I2D_put_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SET(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE_type(type,a,f); + +#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set(b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_seq(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq(r,func,free_func); } + +#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq_type(type,r,func,free_func); } + +#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\ + (void (*)())free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\ + free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_set_strings(r,func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \ + if ((c.slen != 0L) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (func(&(r),&c.p,Tlen) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \ + (void (*)())free_func, \ + b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \ + free_func,b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +/* New macros */ +#define M_ASN1_New_Malloc(ret,type) \ + if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ + { c.line=__LINE__; goto err2; } + +#define M_ASN1_New(arg,func) \ + if (((arg)=func()) == NULL) return(NULL) + +#define M_ASN1_New_Error(a) \ +/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \ + return(NULL);*/ \ + err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \ + return(NULL) + + +/* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, + some macros that use ASN1_const_CTX still insist on writing in the input + stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. + Please? -- Richard Levitte */ +#define M_ASN1_next (*((unsigned char *)(c.p))) +#define M_ASN1_next_prev (*((unsigned char *)(c.q))) + +/*************************************************/ + +#define M_ASN1_I2D_vars(a) int r=0,ret=0; \ + unsigned char *p; \ + if (a == NULL) return(0) + +/* Length Macros */ +#define M_ASN1_I2D_len(a,f) ret+=f(a,NULL) +#define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f) + +#define M_ASN1_I2D_len_SET(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SET_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \ + V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SEQUENCE(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE(a,f); + +#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE_type(type,a,f); + +#define M_ASN1_I2D_len_IMP_SET(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \ + if (a != NULL)\ + { \ + v=f(a,NULL); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0))\ + { \ + v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \ + V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +/* Put Macros */ +#define M_ASN1_I2D_put(a,f) f(a,&p) + +#define M_ASN1_I2D_put_IMP_opt(a,f,t) \ + if (a != NULL) \ + { \ + unsigned char *q=p; \ + f(a,&p); \ + *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\ + } + +#define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\ + V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_SET_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \ + i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \ + if (a != NULL) \ + { \ + ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \ + f(a,&p); \ + } + +#define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_seq_total() \ + r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ + if (pp == NULL) return(r); \ + p= *pp; \ + ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_I2D_INF_seq_start(tag,ctx) \ + *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \ + *(p++)=0x80 + +#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00 + +#define M_ASN1_I2D_finish() *pp=p; \ + return(r); + +int asn1_GetSequence(ASN1_const_CTX *c, long *length); +void asn1_add_error(const unsigned char *address,int offset); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/asn1t.h b/include/openssl/asn1t.h new file mode 100755 index 0000000..4fd99e3 --- /dev/null +++ b/include/openssl/asn1t.h @@ -0,0 +1,886 @@ +/* asn1t.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ASN1T_H +#define HEADER_ASN1T_H + +#include +#include +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +/* ASN1 template defines, structures and functions */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { + +#define ASN1_ITEM_end(itname) \ + }; + +#else + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + const ASN1_ITEM * itname##_it(void) \ + { \ + static const ASN1_ITEM local_it = { + +#define ASN1_ITEM_end(itname) \ + }; \ + return &local_it; \ + } + +#endif + + +/* Macros to aid ASN1 template writing */ + +#define ASN1_ITEM_TEMPLATE(tname) \ + static const ASN1_TEMPLATE tname##_item_tt + +#define ASN1_ITEM_TEMPLATE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_PRIMITIVE,\ + -1,\ + &tname##_item_tt,\ + 0,\ + NULL,\ + 0,\ + #tname \ + ASN1_ITEM_end(tname) + + +/* This is a ASN1 type which just embeds a template */ + +/* This pair helps declare a SEQUENCE. We can do: + * + * ASN1_SEQUENCE(stname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END(stname) + * + * This will produce an ASN1_ITEM called stname_it + * for a structure called stname. + * + * If you want the same structure but a different + * name then use: + * + * ASN1_SEQUENCE(itname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END_name(stname, itname) + * + * This will create an item called itname_it using + * a structure called stname. + */ + +#define ASN1_SEQUENCE(tname) \ + static const ASN1_TEMPLATE tname##_seq_tt[] + +#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) + +#define ASN1_SEQUENCE_END_name(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_NDEF_SEQUENCE(tname) \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_BROKEN_SEQUENCE(tname) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_ref(tname, cb, lck) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_enc(tname, enc, cb) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_NDEF_SEQUENCE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(tname),\ + #tname \ + ASN1_ITEM_end(tname) + +#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) + +#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_ref(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + + +/* This pair helps declare a CHOICE type. We can do: + * + * ASN1_CHOICE(chname) = { + * ... CHOICE options ... + * ASN1_CHOICE_END(chname) + * + * This will produce an ASN1_ITEM called chname_it + * for a structure called chname. The structure + * definition must look like this: + * typedef struct { + * int type; + * union { + * ASN1_SOMETHING *opt1; + * ASN1_SOMEOTHER *opt2; + * } value; + * } chname; + * + * the name of the selector must be 'type'. + * to use an alternative selector name use the + * ASN1_CHOICE_END_selector() version. + */ + +#define ASN1_CHOICE(tname) \ + static const ASN1_TEMPLATE tname##_ch_tt[] + +#define ASN1_CHOICE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_CHOICE(tname) + +#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) + +#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) + +#define ASN1_CHOICE_END_selector(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_CHOICE_END_cb(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +/* This helps with the template wrapper form of ASN1_ITEM */ + +#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ + (flags), (tag), 0,\ + #name, ASN1_ITEM_ref(type) } + +/* These help with SEQUENCE or CHOICE components */ + +/* used to declare other types */ + +#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ + (flags), (tag), offsetof(stname, field),\ + #field, ASN1_ITEM_ref(type) } + +/* used when the structure is combined with the parent */ + +#define ASN1_EX_COMBINE(flags, tag, type) { \ + (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } + +/* implicit and explicit helper macros */ + +#define ASN1_IMP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) + +#define ASN1_EXP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) + +/* Any defined by macros: the field used is in the table itself */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#else +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } +#endif +/* Plain simple type */ +#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) + +/* OPTIONAL simple type */ +#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* IMPLICIT tagged simple type */ +#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) + +/* IMPLICIT tagged OPTIONAL simple type */ +#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* Same as above but EXPLICIT */ + +#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) +#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* SEQUENCE OF type */ +#define ASN1_SEQUENCE_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) + +/* OPTIONAL SEQUENCE OF */ +#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Same as above but for SET OF */ + +#define ASN1_SET_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) + +#define ASN1_SET_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ + +#define ASN1_IMP_SET_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_EXP_SET_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +/* EXPLICIT OPTIONAL using indefinite length constructed form */ +#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) + +/* Macros for the ASN1_ADB structure */ + +#define ASN1_ADB(name) \ + static const ASN1_ADB_TABLE name##_adbtbl[] + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ADB name##_adb = {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + } + +#else + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ITEM *name##_adb(void) \ + { \ + static const ASN1_ADB internal_adb = \ + {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + }; \ + return (const ASN1_ITEM *) &internal_adb; \ + } \ + void dummy_function(void) + +#endif + +#define ADB_ENTRY(val, template) {val, template} + +#define ASN1_ADB_TEMPLATE(name) \ + static const ASN1_TEMPLATE name##_tt + +/* This is the ASN1 template structure that defines + * a wrapper round the actual type. It determines the + * actual position of the field in the value structure, + * various flags such as OPTIONAL and the field name. + */ + +struct ASN1_TEMPLATE_st { +unsigned long flags; /* Various flags */ +long tag; /* tag, not used if no tagging */ +unsigned long offset; /* Offset of this field in structure */ +#ifndef NO_ASN1_FIELD_NAMES +const char *field_name; /* Field name */ +#endif +ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ +}; + +/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ + +#define ASN1_TEMPLATE_item(t) (t->item_ptr) +#define ASN1_TEMPLATE_adb(t) (t->item_ptr) + +typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; +typedef struct ASN1_ADB_st ASN1_ADB; + +struct ASN1_ADB_st { + unsigned long flags; /* Various flags */ + unsigned long offset; /* Offset of selector field */ + STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ + const ASN1_ADB_TABLE *tbl; /* Table of possible types */ + long tblcount; /* Number of entries in tbl */ + const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ + const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ +}; + +struct ASN1_ADB_TABLE_st { + long value; /* NID for an object or value for an int */ + const ASN1_TEMPLATE tt; /* item for this value */ +}; + +/* template flags */ + +/* Field is optional */ +#define ASN1_TFLG_OPTIONAL (0x1) + +/* Field is a SET OF */ +#define ASN1_TFLG_SET_OF (0x1 << 1) + +/* Field is a SEQUENCE OF */ +#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) + +/* Special case: this refers to a SET OF that + * will be sorted into DER order when encoded *and* + * the corresponding STACK will be modified to match + * the new order. + */ +#define ASN1_TFLG_SET_ORDER (0x3 << 1) + +/* Mask for SET OF or SEQUENCE OF */ +#define ASN1_TFLG_SK_MASK (0x3 << 1) + +/* These flags mean the tag should be taken from the + * tag field. If EXPLICIT then the underlying type + * is used for the inner tag. + */ + +/* IMPLICIT tagging */ +#define ASN1_TFLG_IMPTAG (0x1 << 3) + + +/* EXPLICIT tagging, inner tag from underlying type */ +#define ASN1_TFLG_EXPTAG (0x2 << 3) + +#define ASN1_TFLG_TAG_MASK (0x3 << 3) + +/* context specific IMPLICIT */ +#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT + +/* context specific EXPLICIT */ +#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT + +/* If tagging is in force these determine the + * type of tag to use. Otherwise the tag is + * determined by the underlying type. These + * values reflect the actual octet format. + */ + +/* Universal tag */ +#define ASN1_TFLG_UNIVERSAL (0x0<<6) +/* Application tag */ +#define ASN1_TFLG_APPLICATION (0x1<<6) +/* Context specific tag */ +#define ASN1_TFLG_CONTEXT (0x2<<6) +/* Private tag */ +#define ASN1_TFLG_PRIVATE (0x3<<6) + +#define ASN1_TFLG_TAG_CLASS (0x3<<6) + +/* These are for ANY DEFINED BY type. In this case + * the 'item' field points to an ASN1_ADB structure + * which contains a table of values to decode the + * relevant type + */ + +#define ASN1_TFLG_ADB_MASK (0x3<<8) + +#define ASN1_TFLG_ADB_OID (0x1<<8) + +#define ASN1_TFLG_ADB_INT (0x1<<9) + +/* This flag means a parent structure is passed + * instead of the field: this is useful is a + * SEQUENCE is being combined with a CHOICE for + * example. Since this means the structure and + * item name will differ we need to use the + * ASN1_CHOICE_END_name() macro for example. + */ + +#define ASN1_TFLG_COMBINE (0x1<<10) + +/* This flag when present in a SEQUENCE OF, SET OF + * or EXPLICIT causes indefinite length constructed + * encoding to be used if required. + */ + +#define ASN1_TFLG_NDEF (0x1<<11) + +/* This is the actual ASN1 item itself */ + +struct ASN1_ITEM_st { +char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ +long utype; /* underlying type */ +const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ +long tcount; /* Number of templates if SEQUENCE or CHOICE */ +const void *funcs; /* functions that handle this type */ +long size; /* Structure size (usually)*/ +#ifndef NO_ASN1_FIELD_NAMES +const char *sname; /* Structure name */ +#endif +}; + +/* These are values for the itype field and + * determine how the type is interpreted. + * + * For PRIMITIVE types the underlying type + * determines the behaviour if items is NULL. + * + * Otherwise templates must contain a single + * template and the type is treated in the + * same way as the type specified in the template. + * + * For SEQUENCE types the templates field points + * to the members, the size field is the + * structure size. + * + * For CHOICE types the templates field points + * to each possible member (typically a union) + * and the 'size' field is the offset of the + * selector. + * + * The 'funcs' field is used for application + * specific functions. + * + * For COMPAT types the funcs field gives a + * set of functions that handle this type, this + * supports the old d2i, i2d convention. + * + * The EXTERN type uses a new style d2i/i2d. + * The new style should be used where possible + * because it avoids things like the d2i IMPLICIT + * hack. + * + * MSTRING is a multiple string type, it is used + * for a CHOICE of character strings where the + * actual strings all occupy an ASN1_STRING + * structure. In this case the 'utype' field + * has a special meaning, it is used as a mask + * of acceptable types using the B_ASN1 constants. + * + * NDEF_SEQUENCE is the same as SEQUENCE except + * that it will use indefinite length constructed + * encoding if requested. + * + */ + +#define ASN1_ITYPE_PRIMITIVE 0x0 + +#define ASN1_ITYPE_SEQUENCE 0x1 + +#define ASN1_ITYPE_CHOICE 0x2 + +#define ASN1_ITYPE_COMPAT 0x3 + +#define ASN1_ITYPE_EXTERN 0x4 + +#define ASN1_ITYPE_MSTRING 0x5 + +#define ASN1_ITYPE_NDEF_SEQUENCE 0x6 + +/* Cache for ASN1 tag and length, so we + * don't keep re-reading it for things + * like CHOICE + */ + +struct ASN1_TLC_st{ + char valid; /* Values below are valid */ + int ret; /* return value */ + long plen; /* length */ + int ptag; /* class value */ + int pclass; /* class value */ + int hdrlen; /* header length */ +}; + +/* Typedefs for ASN1 function pointers */ + +typedef ASN1_VALUE * ASN1_new_func(void); +typedef void ASN1_free_func(ASN1_VALUE *a); +typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); +typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); + +typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); +typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); + +typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +typedef struct ASN1_COMPAT_FUNCS_st { + ASN1_new_func *asn1_new; + ASN1_free_func *asn1_free; + ASN1_d2i_func *asn1_d2i; + ASN1_i2d_func *asn1_i2d; +} ASN1_COMPAT_FUNCS; + +typedef struct ASN1_EXTERN_FUNCS_st { + void *app_data; + ASN1_ex_new_func *asn1_ex_new; + ASN1_ex_free_func *asn1_ex_free; + ASN1_ex_free_func *asn1_ex_clear; + ASN1_ex_d2i *asn1_ex_d2i; + ASN1_ex_i2d *asn1_ex_i2d; +} ASN1_EXTERN_FUNCS; + +typedef struct ASN1_PRIMITIVE_FUNCS_st { + void *app_data; + unsigned long flags; + ASN1_ex_new_func *prim_new; + ASN1_ex_free_func *prim_free; + ASN1_ex_free_func *prim_clear; + ASN1_primitive_c2i *prim_c2i; + ASN1_primitive_i2c *prim_i2c; +} ASN1_PRIMITIVE_FUNCS; + +/* This is the ASN1_AUX structure: it handles various + * miscellaneous requirements. For example the use of + * reference counts and an informational callback. + * + * The "informational callback" is called at various + * points during the ASN1 encoding and decoding. It can + * be used to provide minor customisation of the structures + * used. This is most useful where the supplied routines + * *almost* do the right thing but need some extra help + * at a few points. If the callback returns zero then + * it is assumed a fatal error has occurred and the + * main operation should be abandoned. + * + * If major changes in the default behaviour are required + * then an external type is more appropriate. + */ + +typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it); + +typedef struct ASN1_AUX_st { + void *app_data; + int flags; + int ref_offset; /* Offset of reference value */ + int ref_lock; /* Lock type to use */ + ASN1_aux_cb *asn1_cb; + int enc_offset; /* Offset of ASN1_ENCODING structure */ +} ASN1_AUX; + +/* Flags in ASN1_AUX */ + +/* Use a reference count */ +#define ASN1_AFLG_REFCOUNT 1 +/* Save the encoding of structure (useful for signatures) */ +#define ASN1_AFLG_ENCODING 2 +/* The Sequence length is invalid */ +#define ASN1_AFLG_BROKEN 4 + +/* operation values for asn1_cb */ + +#define ASN1_OP_NEW_PRE 0 +#define ASN1_OP_NEW_POST 1 +#define ASN1_OP_FREE_PRE 2 +#define ASN1_OP_FREE_POST 3 +#define ASN1_OP_D2I_PRE 4 +#define ASN1_OP_D2I_POST 5 +#define ASN1_OP_I2D_PRE 6 +#define ASN1_OP_I2D_POST 7 + +/* Macro to implement a primitive type */ +#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) +#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement a multi string type */ +#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement an ASN1_ITEM in terms of old style funcs */ + +#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) + +#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ + static const ASN1_COMPAT_FUNCS sname##_ff = { \ + (ASN1_new_func *)sname##_new, \ + (ASN1_free_func *)sname##_free, \ + (ASN1_d2i_func *)d2i_##sname, \ + (ASN1_i2d_func *)i2d_##sname, \ + }; \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_COMPAT, \ + tag, \ + NULL, \ + 0, \ + &sname##_ff, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_EXTERN, \ + tag, \ + NULL, \ + 0, \ + &fptrs, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +/* Macro to implement standard functions in terms of ASN1_ITEM structures */ + +#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ + stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ + int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ + { \ + return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ + } + +/* This includes evil casts to remove const: they will go away when full + * ASN1 constification is done. + */ +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ + stname * stname##_dup(stname *x) \ + { \ + return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ + IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) + +#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +/* external definitions for primitive types */ + +DECLARE_ASN1_ITEM(ASN1_BOOLEAN) +DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_SEQUENCE) +DECLARE_ASN1_ITEM(CBIGNUM) +DECLARE_ASN1_ITEM(BIGNUM) +DECLARE_ASN1_ITEM(LONG) +DECLARE_ASN1_ITEM(ZLONG) + +DECLARE_STACK_OF(ASN1_VALUE) + +/* Functions used internally by the ASN1 code */ + +int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); + +void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); +void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); + +int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); + +ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + +const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr); + +int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); + +void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); +void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/bio.h b/include/openssl/bio.h new file mode 100755 index 0000000..385ec12 --- /dev/null +++ b/include/openssl/bio.h @@ -0,0 +1,775 @@ +/* crypto/bio/bio.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BIO_H +#define HEADER_BIO_H + +#include + +#ifndef OPENSSL_NO_FP_API +# include +#endif +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These are the 'types' of BIOs */ +#define BIO_TYPE_NONE 0 +#define BIO_TYPE_MEM (1|0x0400) +#define BIO_TYPE_FILE (2|0x0400) + +#define BIO_TYPE_FD (4|0x0400|0x0100) +#define BIO_TYPE_SOCKET (5|0x0400|0x0100) +#define BIO_TYPE_NULL (6|0x0400) +#define BIO_TYPE_SSL (7|0x0200) +#define BIO_TYPE_MD (8|0x0200) /* passive filter */ +#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ +#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ +#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ +#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */ +#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */ +#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */ +#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NULL_FILTER (17|0x0200) +#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ +#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ +#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ +#define BIO_TYPE_DGRAM (21|0x0400|0x0100) + +#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ +#define BIO_TYPE_FILTER 0x0200 +#define BIO_TYPE_SOURCE_SINK 0x0400 + +/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. + * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ +#define BIO_NOCLOSE 0x00 +#define BIO_CLOSE 0x01 + +/* These are used in the following macros and are passed to + * BIO_ctrl() */ +#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ +#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ +#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ +#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ +#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ +#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ +#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ +#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ +#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ +#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ +#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ +#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ +#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ +/* callback is int cb(BIO *bio,state,ret); */ +#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ +#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ + +#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ + +/* dgram BIO stuff */ +#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ +#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally + * connected socket to be + * passed in */ +#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ +#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ + +#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ + +/* #ifdef IP_MTU_DISCOVER */ +#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ +/* #endif */ + +#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ +#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ +#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for + * MTU. want to use this + * if asking the kernel + * fails */ + +#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU + * was exceed in the + * previous write + * operation */ + +#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ + + +/* modifiers */ +#define BIO_FP_READ 0x02 +#define BIO_FP_WRITE 0x04 +#define BIO_FP_APPEND 0x08 +#define BIO_FP_TEXT 0x10 + +#define BIO_FLAGS_READ 0x01 +#define BIO_FLAGS_WRITE 0x02 +#define BIO_FLAGS_IO_SPECIAL 0x04 +#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) +#define BIO_FLAGS_SHOULD_RETRY 0x08 +#ifndef BIO_FLAGS_UPLINK +/* "UPLINK" flag denotes file descriptors provided by application. + It defaults to 0, as most platforms don't require UPLINK interface. */ +#define BIO_FLAGS_UPLINK 0 +#endif + +/* Used in BIO_gethostbyname() */ +#define BIO_GHBN_CTRL_HITS 1 +#define BIO_GHBN_CTRL_MISSES 2 +#define BIO_GHBN_CTRL_CACHE_SIZE 3 +#define BIO_GHBN_CTRL_GET_ENTRY 4 +#define BIO_GHBN_CTRL_FLUSH 5 + +/* Mostly used in the SSL BIO */ +/* Not used anymore + * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 + * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 + * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 + */ + +#define BIO_FLAGS_BASE64_NO_NL 0x100 + +/* This is used with memory BIOs: it means we shouldn't free up or change the + * data in any way. + */ +#define BIO_FLAGS_MEM_RDONLY 0x200 + +typedef struct bio_st BIO; + +void BIO_set_flags(BIO *b, int flags); +int BIO_test_flags(const BIO *b, int flags); +void BIO_clear_flags(BIO *b, int flags); + +#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) +#define BIO_set_retry_special(b) \ + BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_read(b) \ + BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_write(b) \ + BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) + +/* These are normally used internally in BIOs */ +#define BIO_clear_retry_flags(b) \ + BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_get_retry_flags(b) \ + BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) + +/* These should be used by the application to tell why we should retry */ +#define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) +#define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) +#define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) +#define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) +#define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) + +/* The next three are used in conjunction with the + * BIO_should_io_special() condition. After this returns true, + * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO + * stack and return the 'reason' for the special and the offending BIO. + * Given a BIO, BIO_get_retry_reason(bio) will return the code. */ +/* Returned from the SSL bio when the certificate retrieval code had an error */ +#define BIO_RR_SSL_X509_LOOKUP 0x01 +/* Returned from the connect BIO when a connect would have blocked */ +#define BIO_RR_CONNECT 0x02 +/* Returned from the accept BIO when an accept would have blocked */ +#define BIO_RR_ACCEPT 0x03 + +/* These are passed by the BIO callback */ +#define BIO_CB_FREE 0x01 +#define BIO_CB_READ 0x02 +#define BIO_CB_WRITE 0x03 +#define BIO_CB_PUTS 0x04 +#define BIO_CB_GETS 0x05 +#define BIO_CB_CTRL 0x06 + +/* The callback is called before and after the underling operation, + * The BIO_CB_RETURN flag indicates if it is after the call */ +#define BIO_CB_RETURN 0x80 +#define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) +#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) +#define BIO_cb_post(a) ((a)&BIO_CB_RETURN) + +long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long); +void BIO_set_callback(BIO *b, + long (*callback)(struct bio_st *,int,const char *,int, long,long)); +char *BIO_get_callback_arg(const BIO *b); +void BIO_set_callback_arg(BIO *b, char *arg); + +const char * BIO_method_name(const BIO *b); +int BIO_method_type(const BIO *b); + +typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); + +#ifndef OPENSSL_SYS_WIN16 +typedef struct bio_method_st + { + int type; + const char *name; + int (*bwrite)(BIO *, const char *, int); + int (*bread)(BIO *, char *, int); + int (*bputs)(BIO *, const char *); + int (*bgets)(BIO *, char *, int); + long (*ctrl)(BIO *, int, long, void *); + int (*create)(BIO *); + int (*destroy)(BIO *); + long (*callback_ctrl)(BIO *, int, bio_info_cb *); + } BIO_METHOD; +#else +typedef struct bio_method_st + { + int type; + const char *name; + int (_far *bwrite)(); + int (_far *bread)(); + int (_far *bputs)(); + int (_far *bgets)(); + long (_far *ctrl)(); + int (_far *create)(); + int (_far *destroy)(); + long (_far *callback_ctrl)(); + } BIO_METHOD; +#endif + +struct bio_st + { + BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + long (*callback)(struct bio_st *,int,const char *,int, long,long); + char *cb_arg; /* first argument for the callback */ + + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + int references; + unsigned long num_read; + unsigned long num_write; + + CRYPTO_EX_DATA ex_data; + }; + +DECLARE_STACK_OF(BIO) + +typedef struct bio_f_buffer_ctx_struct + { + /* BIO *bio; */ /* this is now in the BIO struct */ + int ibuf_size; /* how big is the input buffer */ + int obuf_size; /* how big is the output buffer */ + + char *ibuf; /* the char array */ + int ibuf_len; /* how many bytes are in it */ + int ibuf_off; /* write/read offset */ + + char *obuf; /* the char array */ + int obuf_len; /* how many bytes are in it */ + int obuf_off; /* write/read offset */ + } BIO_F_BUFFER_CTX; + +/* connect BIO stuff */ +#define BIO_CONN_S_BEFORE 1 +#define BIO_CONN_S_GET_IP 2 +#define BIO_CONN_S_GET_PORT 3 +#define BIO_CONN_S_CREATE_SOCKET 4 +#define BIO_CONN_S_CONNECT 5 +#define BIO_CONN_S_OK 6 +#define BIO_CONN_S_BLOCKED_CONNECT 7 +#define BIO_CONN_S_NBIO 8 +/*#define BIO_CONN_get_param_hostname BIO_ctrl */ + +#define BIO_C_SET_CONNECT 100 +#define BIO_C_DO_STATE_MACHINE 101 +#define BIO_C_SET_NBIO 102 +#define BIO_C_SET_PROXY_PARAM 103 +#define BIO_C_SET_FD 104 +#define BIO_C_GET_FD 105 +#define BIO_C_SET_FILE_PTR 106 +#define BIO_C_GET_FILE_PTR 107 +#define BIO_C_SET_FILENAME 108 +#define BIO_C_SET_SSL 109 +#define BIO_C_GET_SSL 110 +#define BIO_C_SET_MD 111 +#define BIO_C_GET_MD 112 +#define BIO_C_GET_CIPHER_STATUS 113 +#define BIO_C_SET_BUF_MEM 114 +#define BIO_C_GET_BUF_MEM_PTR 115 +#define BIO_C_GET_BUFF_NUM_LINES 116 +#define BIO_C_SET_BUFF_SIZE 117 +#define BIO_C_SET_ACCEPT 118 +#define BIO_C_SSL_MODE 119 +#define BIO_C_GET_MD_CTX 120 +#define BIO_C_GET_PROXY_PARAM 121 +#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */ +#define BIO_C_GET_CONNECT 123 +#define BIO_C_GET_ACCEPT 124 +#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 +#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 +#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 +#define BIO_C_FILE_SEEK 128 +#define BIO_C_GET_CIPHER_CTX 129 +#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ +#define BIO_C_SET_BIND_MODE 131 +#define BIO_C_GET_BIND_MODE 132 +#define BIO_C_FILE_TELL 133 +#define BIO_C_GET_SOCKS 134 +#define BIO_C_SET_SOCKS 135 + +#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ +#define BIO_C_GET_WRITE_BUF_SIZE 137 +#define BIO_C_MAKE_BIO_PAIR 138 +#define BIO_C_DESTROY_BIO_PAIR 139 +#define BIO_C_GET_WRITE_GUARANTEE 140 +#define BIO_C_GET_READ_REQUEST 141 +#define BIO_C_SHUTDOWN_WR 142 +#define BIO_C_NREAD0 143 +#define BIO_C_NREAD 144 +#define BIO_C_NWRITE0 145 +#define BIO_C_NWRITE 146 +#define BIO_C_RESET_READ_REQUEST 147 +#define BIO_C_SET_MD_CTX 148 + + +#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) +#define BIO_get_app_data(s) BIO_get_ex_data(s,0) + +/* BIO_s_connect() and BIO_s_socks4a_connect() */ +#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) +#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) +#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) +#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) +#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) +#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) +#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) +#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3) + + +#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) + +/* BIO_s_accept_socket() */ +#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) +#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) +/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ +#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) +#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) + +#define BIO_BIND_NORMAL 0 +#define BIO_BIND_REUSEADDR_IF_UNUSED 1 +#define BIO_BIND_REUSEADDR 2 +#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) +#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) + +#define BIO_do_connect(b) BIO_do_handshake(b) +#define BIO_do_accept(b) BIO_do_handshake(b) +#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) + +/* BIO_s_proxy_client() */ +#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) +#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) +/* BIO_set_nbio(b,n) */ +#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) +/* BIO *BIO_get_filter_bio(BIO *bio); */ +#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) +#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) +#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) + +#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) +#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) +#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) +#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) + +#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) +#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) + +#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) +#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) + +#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) +#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) + +/* name is cast to lose const, but might be better to route through a function + so we can do it safely */ +#ifdef CONST_STRICT +/* If you are wondering why this isn't defined, its because CONST_STRICT is + * purely a compile-time kludge to allow const to be checked. + */ +int BIO_read_filename(BIO *b,const char *name); +#else +#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ,(char *)name) +#endif +#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_WRITE,name) +#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_APPEND,name) +#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) + +/* WARNING WARNING, this ups the reference count on the read bio of the + * SSL structure. This is because the ssl read BIO is now pointed to by + * the next_bio field in the bio. So when you free the BIO, make sure + * you are doing a BIO_free_all() to catch the underlying BIO. */ +#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) +#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) +#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) +#define BIO_set_ssl_renegotiate_bytes(b,num) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); +#define BIO_get_num_renegotiates(b) \ + BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); +#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); + +/* defined in evp.h */ +/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ + +#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) +#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) +#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) +#define BIO_set_mem_eof_return(b,v) \ + BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) + +/* For the BIO_f_buffer() type */ +#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) +#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) +#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) +#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) +#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) + +/* Don't use the next one unless you know what you are doing :-) */ +#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) + +#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) +#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) +#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) +#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) +#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) +#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) +/* ...pending macros have inappropriate return type */ +size_t BIO_ctrl_pending(BIO *b); +size_t BIO_ctrl_wpending(BIO *b); +#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) +#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ + cbp) +#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) + +/* For the BIO_f_buffer() type */ +#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) + +/* For BIO_s_bio() */ +#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) +#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) +#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) +#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) +#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) +/* macros with inappropriate type -- but ...pending macros use int too: */ +#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) +#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) +size_t BIO_ctrl_get_write_guarantee(BIO *b); +size_t BIO_ctrl_get_read_request(BIO *b); +int BIO_ctrl_reset_read_request(BIO *b); + +/* ctrl macros for dgram */ +#define BIO_ctrl_dgram_connect(b,peer) \ + (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) +#define BIO_ctrl_set_connected(b, state, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) +#define BIO_dgram_recv_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) +#define BIO_dgram_send_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) +#define BIO_dgram_set_peer(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) + +/* These two aren't currently implemented */ +/* int BIO_get_ex_num(BIO *bio); */ +/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ +int BIO_set_ex_data(BIO *bio,int idx,void *data); +void *BIO_get_ex_data(BIO *bio,int idx); +int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +unsigned long BIO_number_read(BIO *bio); +unsigned long BIO_number_written(BIO *bio); + +# ifndef OPENSSL_NO_FP_API +# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL) +BIO_METHOD *BIO_s_file_internal(void); +BIO *BIO_new_file_internal(char *filename, char *mode); +BIO *BIO_new_fp_internal(FILE *stream, int close_flag); +# define BIO_s_file BIO_s_file_internal +# define BIO_new_file BIO_new_file_internal +# define BIO_new_fp BIO_new_fp_internal +# else /* FP_API */ +BIO_METHOD *BIO_s_file(void ); +BIO *BIO_new_file(const char *filename, const char *mode); +BIO *BIO_new_fp(FILE *stream, int close_flag); +# define BIO_s_file_internal BIO_s_file +# define BIO_new_file_internal BIO_new_file +# define BIO_new_fp_internal BIO_s_file +# endif /* FP_API */ +# endif +BIO * BIO_new(BIO_METHOD *type); +int BIO_set(BIO *a,BIO_METHOD *type); +int BIO_free(BIO *a); +void BIO_vfree(BIO *a); +int BIO_read(BIO *b, void *data, int len); +int BIO_gets(BIO *bp,char *buf, int size); +int BIO_write(BIO *b, const void *data, int len); +int BIO_puts(BIO *bp,const char *buf); +int BIO_indent(BIO *b,int indent,int max); +long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); +long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); +char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); +long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); +BIO * BIO_push(BIO *b,BIO *append); +BIO * BIO_pop(BIO *b); +void BIO_free_all(BIO *a); +BIO * BIO_find_type(BIO *b,int bio_type); +BIO * BIO_next(BIO *b); +BIO * BIO_get_retry_BIO(BIO *bio, int *reason); +int BIO_get_retry_reason(BIO *bio); +BIO * BIO_dup_chain(BIO *in); + +int BIO_nread0(BIO *bio, char **buf); +int BIO_nread(BIO *bio, char **buf, int num); +int BIO_nwrite0(BIO *bio, char **buf); +int BIO_nwrite(BIO *bio, char **buf, int num); + +#ifndef OPENSSL_SYS_WIN16 +long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#else +long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#endif + +BIO_METHOD *BIO_s_mem(void); +BIO *BIO_new_mem_buf(void *buf, int len); +BIO_METHOD *BIO_s_socket(void); +BIO_METHOD *BIO_s_connect(void); +BIO_METHOD *BIO_s_accept(void); +BIO_METHOD *BIO_s_fd(void); +#ifndef OPENSSL_SYS_OS2 +BIO_METHOD *BIO_s_log(void); +#endif +BIO_METHOD *BIO_s_bio(void); +BIO_METHOD *BIO_s_null(void); +BIO_METHOD *BIO_f_null(void); +BIO_METHOD *BIO_f_buffer(void); +#ifdef OPENSSL_SYS_VMS +BIO_METHOD *BIO_f_linebuffer(void); +#endif +BIO_METHOD *BIO_f_nbio_test(void); +#ifndef OPENSSL_NO_DGRAM +BIO_METHOD *BIO_s_datagram(void); +#endif + +/* BIO_METHOD *BIO_f_ber(void); */ + +int BIO_sock_should_retry(int i); +int BIO_sock_non_fatal_error(int error); +int BIO_dgram_non_fatal_error(int error); + +int BIO_fd_should_retry(int i); +int BIO_fd_non_fatal_error(int error); +int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len); +int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len, int indent); +int BIO_dump(BIO *b,const char *bytes,int len); +int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); +#ifndef OPENSSL_NO_FP_API +int BIO_dump_fp(FILE *fp, const char *s, int len); +int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); +#endif +struct hostent *BIO_gethostbyname(const char *name); +/* We might want a thread-safe interface too: + * struct hostent *BIO_gethostbyname_r(const char *name, + * struct hostent *result, void *buffer, size_t buflen); + * or something similar (caller allocates a struct hostent, + * pointed to by "result", and additional buffer space for the various + * substructures; if the buffer does not suffice, NULL is returned + * and an appropriate error code is set). + */ +int BIO_sock_error(int sock); +int BIO_socket_ioctl(int fd, long type, void *arg); +int BIO_socket_nbio(int fd,int mode); +int BIO_get_port(const char *str, unsigned short *port_ptr); +int BIO_get_host_ip(const char *str, unsigned char *ip); +int BIO_get_accept_socket(char *host_port,int mode); +int BIO_accept(int sock,char **ip_port); +int BIO_sock_init(void ); +void BIO_sock_cleanup(void); +int BIO_set_tcp_ndelay(int sock,int turn_on); + +BIO *BIO_new_socket(int sock, int close_flag); +BIO *BIO_new_dgram(int fd, int close_flag); +BIO *BIO_new_fd(int fd, int close_flag); +BIO *BIO_new_connect(char *host_port); +BIO *BIO_new_accept(char *host_port); + +int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, + BIO **bio2, size_t writebuf2); +/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. + * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. + * Size 0 uses default value. + */ + +void BIO_copy_next_retry(BIO *b); + +/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ + +#ifdef __GNUC__ +# define __bio_h__attr__ __attribute__ +#else +# define __bio_h__attr__(x) +#endif +int BIO_printf(BIO *bio, const char *format, ...) + __bio_h__attr__((__format__(__printf__,2,3))); +int BIO_vprintf(BIO *bio, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,2,0))); +int BIO_snprintf(char *buf, size_t n, const char *format, ...) + __bio_h__attr__((__format__(__printf__,3,4))); +int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,3,0))); +#undef __bio_h__attr__ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BIO_strings(void); + +/* Error codes for the BIO functions. */ + +/* Function codes. */ +#define BIO_F_ACPT_STATE 100 +#define BIO_F_BIO_ACCEPT 101 +#define BIO_F_BIO_BER_GET_HEADER 102 +#define BIO_F_BIO_CALLBACK_CTRL 131 +#define BIO_F_BIO_CTRL 103 +#define BIO_F_BIO_GETHOSTBYNAME 120 +#define BIO_F_BIO_GETS 104 +#define BIO_F_BIO_GET_ACCEPT_SOCKET 105 +#define BIO_F_BIO_GET_HOST_IP 106 +#define BIO_F_BIO_GET_PORT 107 +#define BIO_F_BIO_MAKE_PAIR 121 +#define BIO_F_BIO_NEW 108 +#define BIO_F_BIO_NEW_FILE 109 +#define BIO_F_BIO_NEW_MEM_BUF 126 +#define BIO_F_BIO_NREAD 123 +#define BIO_F_BIO_NREAD0 124 +#define BIO_F_BIO_NWRITE 125 +#define BIO_F_BIO_NWRITE0 122 +#define BIO_F_BIO_PUTS 110 +#define BIO_F_BIO_READ 111 +#define BIO_F_BIO_SOCK_INIT 112 +#define BIO_F_BIO_WRITE 113 +#define BIO_F_BUFFER_CTRL 114 +#define BIO_F_CONN_CTRL 127 +#define BIO_F_CONN_STATE 115 +#define BIO_F_FILE_CTRL 116 +#define BIO_F_FILE_READ 130 +#define BIO_F_LINEBUFFER_CTRL 129 +#define BIO_F_MEM_READ 128 +#define BIO_F_MEM_WRITE 117 +#define BIO_F_SSL_NEW 118 +#define BIO_F_WSASTARTUP 119 + +/* Reason codes. */ +#define BIO_R_ACCEPT_ERROR 100 +#define BIO_R_BAD_FOPEN_MODE 101 +#define BIO_R_BAD_HOSTNAME_LOOKUP 102 +#define BIO_R_BROKEN_PIPE 124 +#define BIO_R_CONNECT_ERROR 103 +#define BIO_R_EOF_ON_MEMORY_BIO 127 +#define BIO_R_ERROR_SETTING_NBIO 104 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 +#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +#define BIO_R_INVALID_ARGUMENT 125 +#define BIO_R_INVALID_IP_ADDRESS 108 +#define BIO_R_IN_USE 123 +#define BIO_R_KEEPALIVE 109 +#define BIO_R_NBIO_CONNECT_ERROR 110 +#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 +#define BIO_R_NO_HOSTNAME_SPECIFIED 112 +#define BIO_R_NO_PORT_DEFINED 113 +#define BIO_R_NO_PORT_SPECIFIED 114 +#define BIO_R_NO_SUCH_FILE 128 +#define BIO_R_NULL_PARAMETER 115 +#define BIO_R_TAG_MISMATCH 116 +#define BIO_R_UNABLE_TO_BIND_SOCKET 117 +#define BIO_R_UNABLE_TO_CREATE_SOCKET 118 +#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 +#define BIO_R_UNINITIALIZED 120 +#define BIO_R_UNSUPPORTED_METHOD 121 +#define BIO_R_WRITE_TO_READ_ONLY_BIO 126 +#define BIO_R_WSASTARTUP 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/blowfish.h b/include/openssl/blowfish.h new file mode 100755 index 0000000..ec7b869 --- /dev/null +++ b/include/openssl/blowfish.h @@ -0,0 +1,127 @@ +/* crypto/bf/blowfish.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BLOWFISH_H +#define HEADER_BLOWFISH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_BF +#error BF is disabled. +#endif + +#define BF_ENCRYPT 1 +#define BF_DECRYPT 0 + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! BF_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define BF_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define BF_LONG unsigned long +#define BF_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define BF_LONG unsigned int +#endif + +#define BF_ROUNDS 16 +#define BF_BLOCK 8 + +typedef struct bf_key_st + { + BF_LONG P[BF_ROUNDS+2]; + BF_LONG S[4*256]; + } BF_KEY; + + +void BF_set_key(BF_KEY *key, int len, const unsigned char *data); + +void BF_encrypt(BF_LONG *data,const BF_KEY *key); +void BF_decrypt(BF_LONG *data,const BF_KEY *key); + +void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int enc); +void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int enc); +void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); +void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num); +const char *BF_options(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/bn.h b/include/openssl/bn.h new file mode 100755 index 0000000..8c800ee --- /dev/null +++ b/include/openssl/bn.h @@ -0,0 +1,827 @@ +/* crypto/bn/bn.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the Eric Young open source + * license provided above. + * + * The binary polynomial arithmetic software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_BN_H +#define HEADER_BN_H + +#include +#ifndef OPENSSL_NO_FP_API +#include /* FILE */ +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These preprocessor symbols control various aspects of the bignum headers and + * library code. They're not defined by any "normal" configuration, as they are + * intended for development and testing purposes. NB: defining all three can be + * useful for debugging application code as well as openssl itself. + * + * BN_DEBUG - turn on various debugging alterations to the bignum code + * BN_DEBUG_RAND - uses random poisoning of unused words to trip up + * mismanagement of bignum internals. You must also define BN_DEBUG. + */ +/* #define BN_DEBUG */ +/* #define BN_DEBUG_RAND */ + +#define BN_MUL_COMBA +#define BN_SQR_COMBA +#define BN_RECURSION + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using normal cc. This would + * be a common occurrence because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assembler code. */ +#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ + defined(OPENSSL_SYS_WIN32) || defined(linux) +# ifndef BN_DIV2W +# define BN_DIV2W +# endif +#endif + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits :-(, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000UL) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +/* This is where the long long data type is 64 bits, but long is 32. + * For machines where there are 64bit registers, this is the mode to use. + * IRIX, on R4000 and above should use this mode, along with the relevant + * assembler code :-). Do NOT define BN_LLONG. + */ +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG +#undef BN_ULLONG +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000ULL) +#define BN_DEC_FMT1 "%llu" +#define BN_DEC_FMT2 "%019llu" +#define BN_DEC_NUM 19 +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef BN_LLONG +# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) +# define BN_ULLONG unsigned __int64 +# else +# define BN_ULLONG unsigned long long +# endif +#endif +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +#ifdef OPENSSL_SYS_WIN32 +/* VC++ doesn't like the LL suffix */ +#define BN_MASK (0xffffffffffffffffL) +#else +#define BN_MASK (0xffffffffffffffffLL) +#endif +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK (0xffffffff) +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (100000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%05u" +#define BN_DEC_NUM 5 +#endif + +#ifdef EIGHT_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK (0xffff) +#define BN_MASK2 (0xff) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#endif + +#define BN_DEFAULT_BITS 1280 + +#define BN_FLG_MALLOCED 0x01 +#define BN_FLG_STATIC_DATA 0x02 +#define BN_FLG_EXP_CONSTTIME 0x04 /* avoid leaking exponent information through timings + * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ +#ifndef OPENSSL_NO_DEPRECATED +#define BN_FLG_FREE 0x8000 /* used for debuging */ +#endif +#define BN_set_flags(b,n) ((b)->flags|=(n)) +#define BN_get_flags(b,n) ((b)->flags&(n)) + +/* get a clone of a BIGNUM with changed flags, for *temporary* use only + * (the two BIGNUMs cannot not be used in parallel!) */ +#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ + (dest)->top=(b)->top, \ + (dest)->dmax=(b)->dmax, \ + (dest)->neg=(b)->neg, \ + (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ + | ((b)->flags & ~BN_FLG_MALLOCED) \ + | BN_FLG_STATIC_DATA \ + | (n))) + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct bignum_st BIGNUM; +/* Used for temp variables (declaration hidden in bn_lcl.h) */ +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; +#endif + +struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int dmax; /* Size of the d array. */ + int neg; /* one if the number is negative */ + int flags; + }; + +/* Used for montgomery multiplication */ +struct bn_mont_ctx_st + { + int ri; /* number of bits in R */ + BIGNUM RR; /* used to convert to montgomery form */ + BIGNUM N; /* The modulus */ + BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 + * (Ni is only stored for bignum algorithm) */ + BN_ULONG n0; /* least significant word of Ni */ + int flags; + }; + +/* Used for reciprocal division/mod functions + * It cannot be shared between threads + */ +struct bn_recp_ctx_st + { + BIGNUM N; /* the divisor */ + BIGNUM Nr; /* the reciprocal */ + int num_bits; + int shift; + int flags; + }; + +/* Used for slow "generation" functions. */ +struct bn_gencb_st + { + unsigned int ver; /* To handle binary (in)compatibility */ + void *arg; /* callback-specific data */ + union + { + /* if(ver==1) - handles old style callbacks */ + void (*cb_1)(int, int, void *); + /* if(ver==2) - new callback style */ + int (*cb_2)(int, int, BN_GENCB *); + } cb; + }; +/* Wrapper function to make using BN_GENCB easier, */ +int BN_GENCB_call(BN_GENCB *cb, int a, int b); +/* Macro to populate a BN_GENCB structure with an "old"-style callback */ +#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 1; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_1 = (callback); } +/* Macro to populate a BN_GENCB structure with a "new"-style callback */ +#define BN_GENCB_set(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 2; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_2 = (callback); } + +#define BN_prime_checks 0 /* default: select number of iterations + based on the size of the number */ + +/* number of Miller-Rabin iterations for an error rate of less than 2^-80 + * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook + * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; + * original paper: Damgaard, Landrock, Pomerance: Average case error estimates + * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ +#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ + (b) >= 850 ? 3 : \ + (b) >= 650 ? 4 : \ + (b) >= 550 ? 5 : \ + (b) >= 450 ? 6 : \ + (b) >= 400 ? 7 : \ + (b) >= 350 ? 8 : \ + (b) >= 300 ? 9 : \ + (b) >= 250 ? 12 : \ + (b) >= 200 ? 15 : \ + (b) >= 150 ? 18 : \ + /* b >= 100 */ 27) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) + +/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ +#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ + (((w) == 0) && ((a)->top == 0))) +#define BN_is_zero(a) ((a)->top == 0) +#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) +#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) +#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) + +#define BN_one(a) (BN_set_word((a),1)) +#define BN_zero_ex(a) \ + do { \ + BIGNUM *_tmp_bn = (a); \ + _tmp_bn->top = 0; \ + _tmp_bn->neg = 0; \ + } while(0) +#ifdef OPENSSL_NO_DEPRECATED +#define BN_zero(a) BN_zero_ex(a) +#else +#define BN_zero(a) (BN_set_word((a),0)) +#endif + +const BIGNUM *BN_value_one(void); +char * BN_options(void); +BN_CTX *BN_CTX_new(void); +#ifndef OPENSSL_NO_DEPRECATED +void BN_CTX_init(BN_CTX *c); +#endif +void BN_CTX_free(BN_CTX *c); +void BN_CTX_start(BN_CTX *ctx); +BIGNUM *BN_CTX_get(BN_CTX *ctx); +void BN_CTX_end(BN_CTX *ctx); +int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_num_bits(const BIGNUM *a); +int BN_num_bits_word(BN_ULONG); +BIGNUM *BN_new(void); +void BN_init(BIGNUM *); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); +void BN_swap(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(const BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(const BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); +/** BN_set_negative sets sign of a BIGNUM + * \param b pointer to the BIGNUM object + * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise + */ +void BN_set_negative(BIGNUM *b, int n); +/** BN_is_negative returns 1 if the BIGNUM is negative + * \param a pointer to the BIGNUM object + * \return 1 if a < 0 and 0 otherwise + */ +#define BN_is_negative(a) ((a)->neg != 0) + +int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); +#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) +int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); +int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); + +BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); +int BN_mul_word(BIGNUM *a, BN_ULONG w); +int BN_add_word(BIGNUM *a, BN_ULONG w); +int BN_sub_word(BIGNUM *a, BN_ULONG w); +int BN_set_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_get_word(const BIGNUM *a); + +int BN_cmp(const BIGNUM *a, const BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(const BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, const BIGNUM *a); +int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); + +int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); +int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, + BN_CTX *ctx,BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); + +int BN_mask_bits(BIGNUM *a,int n); +#ifndef OPENSSL_NO_FP_API +int BN_print_fp(FILE *fp, const BIGNUM *a); +#endif +#ifdef HEADER_BIO_H +int BN_print(BIO *fp, const BIGNUM *a); +#else +int BN_print(void *fp, const BIGNUM *a); +#endif +int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, const BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *BN_dup(const BIGNUM *a); +int BN_ucmp(const BIGNUM *a, const BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(const BIGNUM *a); +char * BN_bn2dec(const BIGNUM *a); +int BN_hex2bn(BIGNUM **a, const char *str); +int BN_dec2bn(BIGNUM **a, const char *str); +int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); +int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ +BIGNUM *BN_mod_inverse(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); +BIGNUM *BN_mod_sqrt(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); + +/* Deprecated versions */ +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, + const BIGNUM *add, const BIGNUM *rem, + void (*callback)(int,int,void *),void *cb_arg); +int BN_is_prime(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *), + BN_CTX *ctx,void *cb_arg); +int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, + int do_trial_division); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* Newer versions */ +int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); +int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); +int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, + int do_trial_division, BN_GENCB *cb); + +BN_MONT_CTX *BN_MONT_CTX_new(void ); +void BN_MONT_CTX_init(BN_MONT_CTX *ctx); +int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + (r),(a),&((mont)->RR),(mont),(ctx)) +int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, + BN_MONT_CTX *mont, BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); +BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); +BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, + const BIGNUM *mod, BN_CTX *ctx); + +/* BN_BLINDING flags */ +#define BN_BLINDING_NO_UPDATE 0x00000001 +#define BN_BLINDING_NO_RECREATE 0x00000002 + +BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); +int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); +unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); +void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); +unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); +void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); +BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, + const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); + +#ifndef OPENSSL_NO_DEPRECATED +void BN_set_params(int mul,int high,int low,int mont); +int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ +#endif + +void BN_RECP_CTX_init(BN_RECP_CTX *recp); +BN_RECP_CTX *BN_RECP_CTX_new(void); +void BN_RECP_CTX_free(BN_RECP_CTX *recp); +int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); +int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, + BN_RECP_CTX *recp,BN_CTX *ctx); +int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, + BN_RECP_CTX *recp, BN_CTX *ctx); + +/* Functions for arithmetic over binary polynomials represented by BIGNUMs. + * + * The BIGNUM::neg property of BIGNUMs representing binary polynomials is + * ignored. + * + * Note that input arguments are not const so that their bit arrays can + * be expanded to the appropriate size if needed. + */ + +int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/ +#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) +int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/ +int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r^2 + r = a mod p */ +#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) +/* Some functions allow for representation of the irreducible polynomials + * as an unsigned int[], say p. The irreducible f(t) is then of the form: + * t^p[0] + t^p[1] + ... + t^p[k] + * where m = p[0] > p[1] > ... > p[k] = 0. + */ +int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); + /* r = a mod p */ +int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ +int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); +int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); + +/* faster mod functions for the 'NIST primes' + * 0 <= a < p^2 */ +int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); + +const BIGNUM *BN_get0_nist_prime_192(void); +const BIGNUM *BN_get0_nist_prime_224(void); +const BIGNUM *BN_get0_nist_prime_256(void); +const BIGNUM *BN_get0_nist_prime_384(void); +const BIGNUM *BN_get0_nist_prime_521(void); + +/* library internal functions */ + +#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ + (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) +#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) +BIGNUM *bn_expand2(BIGNUM *a, int words); +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ +#endif + +/* Bignum consistency macros + * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from + * bignum data after direct manipulations on the data. There is also an + * "internal" macro, bn_check_top(), for verifying that there are no leading + * zeroes. Unfortunately, some auditing is required due to the fact that + * bn_fix_top() has become an overabused duct-tape because bignum data is + * occasionally passed around in an inconsistent state. So the following + * changes have been made to sort this out; + * - bn_fix_top()s implementation has been moved to bn_correct_top() + * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and + * bn_check_top() is as before. + * - if BN_DEBUG *is* defined; + * - bn_check_top() tries to pollute unused words even if the bignum 'top' is + * consistent. (ed: only if BN_DEBUG_RAND is defined) + * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. + * The idea is to have debug builds flag up inconsistent bignums when they + * occur. If that occurs in a bn_fix_top(), we examine the code in question; if + * the use of bn_fix_top() was appropriate (ie. it follows directly after code + * that manipulates the bignum) it is converted to bn_correct_top(), and if it + * was not appropriate, we convert it permanently to bn_check_top() and track + * down the cause of the bug. Eventually, no internal code should be using the + * bn_fix_top() macro. External applications and libraries should try this with + * their own code too, both in terms of building against the openssl headers + * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it + * defined. This not only improves external code, it provides more test + * coverage for openssl's own code. + */ + +#ifdef BN_DEBUG + +/* We only need assert() when debugging */ +#include + +#ifdef BN_DEBUG_RAND +/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */ +#ifndef RAND_pseudo_bytes +int RAND_pseudo_bytes(unsigned char *buf,int num); +#define BN_DEBUG_TRIX +#endif +#define bn_pollute(a) \ + do { \ + const BIGNUM *_bnum1 = (a); \ + if(_bnum1->top < _bnum1->dmax) { \ + unsigned char _tmp_char; \ + /* We cast away const without the compiler knowing, any \ + * *genuinely* constant variables that aren't mutable \ + * wouldn't be constructed with top!=dmax. */ \ + BN_ULONG *_not_const; \ + memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ + RAND_pseudo_bytes(&_tmp_char, 1); \ + memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ + (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ + } \ + } while(0) +#ifdef BN_DEBUG_TRIX +#undef RAND_pseudo_bytes +#endif +#else +#define bn_pollute(a) +#endif +#define bn_check_top(a) \ + do { \ + const BIGNUM *_bnum2 = (a); \ + if (_bnum2 != NULL) { \ + assert((_bnum2->top == 0) || \ + (_bnum2->d[_bnum2->top - 1] != 0)); \ + bn_pollute(_bnum2); \ + } \ + } while(0) + +#define bn_fix_top(a) bn_check_top(a) + +#else /* !BN_DEBUG */ + +#define bn_pollute(a) +#define bn_check_top(a) +#define bn_fix_top(a) bn_correct_top(a) + +#endif + +#define bn_correct_top(a) \ + { \ + BN_ULONG *ftl; \ + if ((a)->top > 0) \ + { \ + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(ftl--)) break; \ + } \ + bn_pollute(a); \ + } + +BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); +BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); +BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); +BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); + +/* Primes from RFC 2409 */ +BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); +BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); + +/* Primes from RFC 3526 */ +BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); + +int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BN_strings(void); + +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BNRAND 127 +#define BN_F_BN_BLINDING_CONVERT_EX 100 +#define BN_F_BN_BLINDING_CREATE_PARAM 128 +#define BN_F_BN_BLINDING_INVERT_EX 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_GET 116 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_CTX_START 129 +#define BN_F_BN_DIV 107 +#define BN_F_BN_DIV_RECP 130 +#define BN_F_BN_EXP 123 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_EXPAND_INTERNAL 120 +#define BN_F_BN_GF2M_MOD 131 +#define BN_F_BN_GF2M_MOD_EXP 132 +#define BN_F_BN_GF2M_MOD_MUL 133 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 +#define BN_F_BN_GF2M_MOD_SQR 136 +#define BN_F_BN_GF2M_MOD_SQRT 137 +#define BN_F_BN_MOD_EXP2_MONT 118 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 +#define BN_F_BN_MOD_EXP_MONT_WORD 117 +#define BN_F_BN_MOD_EXP_RECP 125 +#define BN_F_BN_MOD_EXP_SIMPLE 126 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_LSHIFT_QUICK 119 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MOD_SQRT 121 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 +#define BN_F_BN_RAND_RANGE 122 +#define BN_F_BN_USUB 115 + +/* Reason codes. */ +#define BN_R_ARG2_LT_ARG3 100 +#define BN_R_BAD_RECIPROCAL 101 +#define BN_R_BIGNUM_TOO_LONG 114 +#define BN_R_CALLED_WITH_EVEN_MODULUS 102 +#define BN_R_DIV_BY_ZERO 103 +#define BN_R_ENCODING_ERROR 104 +#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 +#define BN_R_INPUT_NOT_REDUCED 110 +#define BN_R_INVALID_LENGTH 106 +#define BN_R_INVALID_RANGE 115 +#define BN_R_NOT_A_SQUARE 111 +#define BN_R_NOT_INITIALIZED 107 +#define BN_R_NO_INVERSE 108 +#define BN_R_NO_SOLUTION 116 +#define BN_R_P_IS_NOT_PRIME 112 +#define BN_R_TOO_MANY_ITERATIONS 113 +#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/buffer.h b/include/openssl/buffer.h new file mode 100755 index 0000000..e3f394c --- /dev/null +++ b/include/openssl/buffer.h @@ -0,0 +1,118 @@ +/* crypto/buffer/buffer.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BUFFER_H +#define HEADER_BUFFER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if !defined(NO_SYS_TYPES_H) +#include +#endif + +/* Already declared in ossl_typ.h */ +/* typedef struct buf_mem_st BUF_MEM; */ + +struct buf_mem_st + { + int length; /* current number of bytes */ + char *data; + int max; /* size of buffer */ + }; + +BUF_MEM *BUF_MEM_new(void); +void BUF_MEM_free(BUF_MEM *a); +int BUF_MEM_grow(BUF_MEM *str, int len); +int BUF_MEM_grow_clean(BUF_MEM *str, int len); +char * BUF_strdup(const char *str); +char * BUF_strndup(const char *str, size_t siz); +void * BUF_memdup(const void *data, size_t siz); + +/* safe string functions */ +size_t BUF_strlcpy(char *dst,const char *src,size_t siz); +size_t BUF_strlcat(char *dst,const char *src,size_t siz); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BUF_strings(void); + +/* Error codes for the BUF functions. */ + +/* Function codes. */ +#define BUF_F_BUF_MEMDUP 103 +#define BUF_F_BUF_MEM_GROW 100 +#define BUF_F_BUF_MEM_GROW_CLEAN 105 +#define BUF_F_BUF_MEM_NEW 101 +#define BUF_F_BUF_STRDUP 102 +#define BUF_F_BUF_STRNDUP 104 + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/cast.h b/include/openssl/cast.h new file mode 100755 index 0000000..6948e64 --- /dev/null +++ b/include/openssl/cast.h @@ -0,0 +1,105 @@ +/* crypto/cast/cast.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CAST_H +#define HEADER_CAST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef OPENSSL_NO_CAST +#error CAST is disabled. +#endif + +#define CAST_ENCRYPT 1 +#define CAST_DECRYPT 0 + +#define CAST_LONG unsigned long + +#define CAST_BLOCK 8 +#define CAST_KEY_LENGTH 16 + +typedef struct cast_key_st + { + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ + } CAST_KEY; + + +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); +void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, + int enc); +void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + CAST_KEY *ks, unsigned char *iv, int enc); +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/comp.h b/include/openssl/comp.h new file mode 100755 index 0000000..9e77ebc --- /dev/null +++ b/include/openssl/comp.h @@ -0,0 +1,66 @@ + +#ifndef HEADER_COMP_H +#define HEADER_COMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct comp_ctx_st COMP_CTX; + +typedef struct comp_method_st + { + int type; /* NID for compression library */ + const char *name; /* A text string to identify the library */ + int (*init)(COMP_CTX *ctx); + void (*finish)(COMP_CTX *ctx); + int (*compress)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + int (*expand)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + /* The following two do NOTHING, but are kept for backward compatibility */ + long (*ctrl)(void); + long (*callback_ctrl)(void); + } COMP_METHOD; + +struct comp_ctx_st + { + COMP_METHOD *meth; + unsigned long compress_in; + unsigned long compress_out; + unsigned long expand_in; + unsigned long expand_out; + + CRYPTO_EX_DATA ex_data; + }; + + +COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); +void COMP_CTX_free(COMP_CTX *ctx); +int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +COMP_METHOD *COMP_rle(void ); +COMP_METHOD *COMP_zlib(void ); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_COMP_strings(void); + +/* Error codes for the COMP functions. */ + +/* Function codes. */ + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/conf.h b/include/openssl/conf.h new file mode 100755 index 0000000..bc8f95d --- /dev/null +++ b/include/openssl/conf.h @@ -0,0 +1,253 @@ +/* crypto/conf/conf.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_H +#define HEADER_CONF_H + +#include +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct + { + char *section; + char *name; + char *value; + } CONF_VALUE; + +DECLARE_STACK_OF(CONF_VALUE) +DECLARE_STACK_OF(CONF_MODULE) +DECLARE_STACK_OF(CONF_IMODULE) + +struct conf_st; +struct conf_method_st; +typedef struct conf_method_st CONF_METHOD; + +struct conf_method_st + { + const char *name; + CONF *(*create)(CONF_METHOD *meth); + int (*init)(CONF *conf); + int (*destroy)(CONF *conf); + int (*destroy_data)(CONF *conf); + int (*load_bio)(CONF *conf, BIO *bp, long *eline); + int (*dump)(const CONF *conf, BIO *bp); + int (*is_number)(const CONF *conf, char c); + int (*to_int)(const CONF *conf, char c); + int (*load)(CONF *conf, const char *name, long *eline); + }; + +/* Module definitions */ + +typedef struct conf_imodule_st CONF_IMODULE; +typedef struct conf_module_st CONF_MODULE; + +/* DSO module function typedefs */ +typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); +typedef void conf_finish_func(CONF_IMODULE *md); + +#define CONF_MFLAGS_IGNORE_ERRORS 0x1 +#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 +#define CONF_MFLAGS_SILENT 0x4 +#define CONF_MFLAGS_NO_DSO 0x8 +#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 + +int CONF_set_default_method(CONF_METHOD *meth); +void CONF_set_nconf(CONF *conf,LHASH *hash); +LHASH *CONF_load(LHASH *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); +#endif +LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); +char *CONF_get_string(LHASH *conf,const char *group,const char *name); +long CONF_get_number(LHASH *conf,const char *group,const char *name); +void CONF_free(LHASH *conf); +int CONF_dump_fp(LHASH *conf, FILE *out); +int CONF_dump_bio(LHASH *conf, BIO *out); + +void OPENSSL_config(const char *config_name); +void OPENSSL_no_config(void); + +/* New conf code. The semantics are different from the functions above. + If that wasn't the case, the above functions would have been replaced */ + +struct conf_st + { + CONF_METHOD *meth; + void *meth_data; + LHASH *data; + }; + +CONF *NCONF_new(CONF_METHOD *meth); +CONF_METHOD *NCONF_default(void); +CONF_METHOD *NCONF_WIN32(void); +#if 0 /* Just to give you an idea of what I have in mind */ +CONF_METHOD *NCONF_XML(void); +#endif +void NCONF_free(CONF *conf); +void NCONF_free_data(CONF *conf); + +int NCONF_load(CONF *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); +#endif +int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); +char *NCONF_get_string(const CONF *conf,const char *group,const char *name); +int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, + long *result); +int NCONF_dump_fp(const CONF *conf, FILE *out); +int NCONF_dump_bio(const CONF *conf, BIO *out); + +#if 0 /* The following function has no error checking, + and should therefore be avoided */ +long NCONF_get_number(CONF *conf,char *group,char *name); +#else +#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) +#endif + +/* Module functions */ + +int CONF_modules_load(const CONF *cnf, const char *appname, + unsigned long flags); +int CONF_modules_load_file(const char *filename, const char *appname, + unsigned long flags); +void CONF_modules_unload(int all); +void CONF_modules_finish(void); +void CONF_modules_free(void); +int CONF_module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); + +const char *CONF_imodule_get_name(const CONF_IMODULE *md); +const char *CONF_imodule_get_value(const CONF_IMODULE *md); +void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); +void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); +CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); +unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); +void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); +void *CONF_module_get_usr_data(CONF_MODULE *pmod); +void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); + +char *CONF_get1_default_config_file(void); + +int CONF_parse_list(const char *list, int sep, int nospc, + int (*list_cb)(const char *elem, int len, void *usr), void *arg); + +void OPENSSL_load_builtin_modules(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CONF_strings(void); + +/* Error codes for the CONF functions. */ + +/* Function codes. */ +#define CONF_F_CONF_DUMP_FP 104 +#define CONF_F_CONF_LOAD 100 +#define CONF_F_CONF_LOAD_BIO 102 +#define CONF_F_CONF_LOAD_FP 103 +#define CONF_F_CONF_MODULES_LOAD 116 +#define CONF_F_DEF_LOAD 120 +#define CONF_F_DEF_LOAD_BIO 121 +#define CONF_F_MODULE_INIT 115 +#define CONF_F_MODULE_LOAD_DSO 117 +#define CONF_F_MODULE_RUN 118 +#define CONF_F_NCONF_DUMP_BIO 105 +#define CONF_F_NCONF_DUMP_FP 106 +#define CONF_F_NCONF_GET_NUMBER 107 +#define CONF_F_NCONF_GET_NUMBER_E 112 +#define CONF_F_NCONF_GET_SECTION 108 +#define CONF_F_NCONF_GET_STRING 109 +#define CONF_F_NCONF_LOAD 113 +#define CONF_F_NCONF_LOAD_BIO 110 +#define CONF_F_NCONF_LOAD_FP 114 +#define CONF_F_NCONF_NEW 111 +#define CONF_F_STR_COPY 101 + +/* Reason codes. */ +#define CONF_R_ERROR_LOADING_DSO 110 +#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +#define CONF_R_MISSING_EQUAL_SIGN 101 +#define CONF_R_MISSING_FINISH_FUNCTION 111 +#define CONF_R_MISSING_INIT_FUNCTION 112 +#define CONF_R_MODULE_INITIALIZATION_ERROR 109 +#define CONF_R_NO_CLOSE_BRACE 102 +#define CONF_R_NO_CONF 105 +#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 +#define CONF_R_NO_SECTION 107 +#define CONF_R_NO_SUCH_FILE 114 +#define CONF_R_NO_VALUE 108 +#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +#define CONF_R_UNKNOWN_MODULE_NAME 113 +#define CONF_R_VARIABLE_HAS_NO_VALUE 104 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/conf_api.h b/include/openssl/conf_api.h new file mode 100755 index 0000000..8e7d5d5 --- /dev/null +++ b/include/openssl/conf_api.h @@ -0,0 +1,89 @@ +/* conf_api.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_API_H +#define HEADER_CONF_API_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Up until OpenSSL 0.9.5a, this was new_section */ +CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was get_section */ +CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ +STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, + const char *section); + +int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); +char *_CONF_get_string(const CONF *conf, const char *section, + const char *name); +long _CONF_get_number(const CONF *conf, const char *section, const char *name); + +int _CONF_new_data(CONF *conf); +void _CONF_free_data(CONF *conf); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h new file mode 100755 index 0000000..fcba789 --- /dev/null +++ b/include/openssl/crypto.h @@ -0,0 +1,550 @@ +/* crypto/crypto.h */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_CRYPTO_H +#define HEADER_CRYPTO_H + +#include + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#include +#include +#include +#include + +#ifdef CHARSET_EBCDIC +#include +#endif + +/* Resolve problems on some operating systems with symbol names that clash + one way or another */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Backward compatibility to SSLeay */ +/* This is more to be used to check the correct DLL is being used + * in the MS world. */ +#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER +#define SSLEAY_VERSION 0 +/* #define SSLEAY_OPTIONS 1 no longer supported */ +#define SSLEAY_CFLAGS 2 +#define SSLEAY_BUILT_ON 3 +#define SSLEAY_PLATFORM 4 +#define SSLEAY_DIR 5 + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Called when a new object is created */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when an object is free()ed */ +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when we need to dup an object */ +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); +#endif + +/* A generic structure to pass assorted data in a expandable way */ +typedef struct openssl_item_st + { + int code; + void *value; /* Not used for flag attributes */ + size_t value_size; /* Max size of value for output, length for input */ + size_t *value_length; /* Returned length of value for output */ + } OPENSSL_ITEM; + + +/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock + * names in cryptlib.c + */ + +#define CRYPTO_LOCK_ERR 1 +#define CRYPTO_LOCK_EX_DATA 2 +#define CRYPTO_LOCK_X509 3 +#define CRYPTO_LOCK_X509_INFO 4 +#define CRYPTO_LOCK_X509_PKEY 5 +#define CRYPTO_LOCK_X509_CRL 6 +#define CRYPTO_LOCK_X509_REQ 7 +#define CRYPTO_LOCK_DSA 8 +#define CRYPTO_LOCK_RSA 9 +#define CRYPTO_LOCK_EVP_PKEY 10 +#define CRYPTO_LOCK_X509_STORE 11 +#define CRYPTO_LOCK_SSL_CTX 12 +#define CRYPTO_LOCK_SSL_CERT 13 +#define CRYPTO_LOCK_SSL_SESSION 14 +#define CRYPTO_LOCK_SSL_SESS_CERT 15 +#define CRYPTO_LOCK_SSL 16 +#define CRYPTO_LOCK_SSL_METHOD 17 +#define CRYPTO_LOCK_RAND 18 +#define CRYPTO_LOCK_RAND2 19 +#define CRYPTO_LOCK_MALLOC 20 +#define CRYPTO_LOCK_BIO 21 +#define CRYPTO_LOCK_GETHOSTBYNAME 22 +#define CRYPTO_LOCK_GETSERVBYNAME 23 +#define CRYPTO_LOCK_READDIR 24 +#define CRYPTO_LOCK_RSA_BLINDING 25 +#define CRYPTO_LOCK_DH 26 +#define CRYPTO_LOCK_MALLOC2 27 +#define CRYPTO_LOCK_DSO 28 +#define CRYPTO_LOCK_DYNLOCK 29 +#define CRYPTO_LOCK_ENGINE 30 +#define CRYPTO_LOCK_UI 31 +#define CRYPTO_LOCK_ECDSA 32 +#define CRYPTO_LOCK_EC 33 +#define CRYPTO_LOCK_ECDH 34 +#define CRYPTO_LOCK_BN 35 +#define CRYPTO_LOCK_EC_PRE_COMP 36 +#define CRYPTO_LOCK_STORE 37 +#define CRYPTO_LOCK_COMP 38 +#define CRYPTO_NUM_LOCKS 39 + +#define CRYPTO_LOCK 1 +#define CRYPTO_UNLOCK 2 +#define CRYPTO_READ 4 +#define CRYPTO_WRITE 8 + +#ifndef OPENSSL_NO_LOCKING +#ifndef CRYPTO_w_lock +#define CRYPTO_w_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_w_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_r_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_r_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_add(addr,amount,type) \ + CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) +#endif +#else +#define CRYPTO_w_lock(a) +#define CRYPTO_w_unlock(a) +#define CRYPTO_r_lock(a) +#define CRYPTO_r_unlock(a) +#define CRYPTO_add(a,b,c) ((*(a))+=(b)) +#endif + +/* Some applications as well as some parts of OpenSSL need to allocate + and deallocate locks in a dynamic fashion. The following typedef + makes this possible in a type-safe manner. */ +/* struct CRYPTO_dynlock_value has to be defined by the application. */ +typedef struct + { + int references; + struct CRYPTO_dynlock_value *data; + } CRYPTO_dynlock; + + +/* The following can be used to detect memory leaks in the SSLeay library. + * It used, it turns on malloc checking */ + +#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ +#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ +#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ +#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ + +/* The following are bit values to turn on or off options connected to the + * malloc checking functionality */ + +/* Adds time to the memory checking information */ +#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ +/* Adds thread number to the memory checking information */ +#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ + +#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) + + +/* predec of the BIO type */ +typedef struct bio_st BIO_dummy; + +struct crypto_ex_data_st + { + STACK *sk; + int dummy; /* gcc is screwing up this data structure :-( */ + }; + +/* This stuff is basically class callback functions + * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ + +typedef struct crypto_ex_data_func_st + { + long argl; /* Arbitary long */ + void *argp; /* Arbitary void * */ + CRYPTO_EX_new *new_func; + CRYPTO_EX_free *free_func; + CRYPTO_EX_dup *dup_func; + } CRYPTO_EX_DATA_FUNCS; + +DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) + +/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA + * entry. + */ + +#define CRYPTO_EX_INDEX_BIO 0 +#define CRYPTO_EX_INDEX_SSL 1 +#define CRYPTO_EX_INDEX_SSL_CTX 2 +#define CRYPTO_EX_INDEX_SSL_SESSION 3 +#define CRYPTO_EX_INDEX_X509_STORE 4 +#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 +#define CRYPTO_EX_INDEX_RSA 6 +#define CRYPTO_EX_INDEX_DSA 7 +#define CRYPTO_EX_INDEX_DH 8 +#define CRYPTO_EX_INDEX_ENGINE 9 +#define CRYPTO_EX_INDEX_X509 10 +#define CRYPTO_EX_INDEX_UI 11 +#define CRYPTO_EX_INDEX_ECDSA 12 +#define CRYPTO_EX_INDEX_ECDH 13 +#define CRYPTO_EX_INDEX_COMP 14 +#define CRYPTO_EX_INDEX_STORE 15 + +/* Dynamically assigned indexes start from this value (don't use directly, use + * via CRYPTO_ex_data_new_class). */ +#define CRYPTO_EX_INDEX_USER 100 + + +/* This is the default callbacks, but we can have others as well: + * this is needed in Win32 where the application malloc and the + * library malloc may not be the same. + */ +#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ + malloc, realloc, free) + +#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD +# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ +# define CRYPTO_MDEBUG +# endif +#endif + +/* Set standard debugging functions (not done by default + * unless CRYPTO_MDEBUG is defined) */ +#define CRYPTO_malloc_debug_init() do {\ + CRYPTO_set_mem_debug_functions(\ + CRYPTO_dbg_malloc,\ + CRYPTO_dbg_realloc,\ + CRYPTO_dbg_free,\ + CRYPTO_dbg_set_options,\ + CRYPTO_dbg_get_options);\ + } while(0) + +int CRYPTO_mem_ctrl(int mode); +int CRYPTO_is_mem_check_on(void); + +/* for applications */ +#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) +#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) + +/* for library-internal use */ +#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) +#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) +#define is_MemCheck_on() CRYPTO_is_mem_check_on() + +#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) +#define OPENSSL_realloc(addr,num) \ + CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_realloc_clean(addr,old_num,num) \ + CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) +#define OPENSSL_remalloc(addr,num) \ + CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_freeFunc CRYPTO_free +#define OPENSSL_free(addr) CRYPTO_free(addr) + +#define OPENSSL_malloc_locked(num) \ + CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) +#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) + + +const char *SSLeay_version(int type); +unsigned long SSLeay(void); + +int OPENSSL_issetugid(void); + +/* An opaque type representing an implementation of "ex_data" support */ +typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; +/* Return an opaque pointer to the current "ex_data" implementation */ +const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); +/* Sets the "ex_data" implementation to be used (if it's not too late) */ +int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); +/* Get a new "ex_data" class, and return the corresponding "class_index" */ +int CRYPTO_ex_data_new_class(void); +/* Within a given class, get/register a new index */ +int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, + CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func); +/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given + * class (invokes whatever per-class callbacks are applicable) */ +int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, + CRYPTO_EX_DATA *from); +void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index + * (relative to the class type involved) */ +int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); +void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); +/* This function cleans up all "ex_data" state. It mustn't be called under + * potential race-conditions. */ +void CRYPTO_cleanup_all_ex_data(void); + +int CRYPTO_get_new_lockid(char *name); + +int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ +void CRYPTO_lock(int mode, int type,const char *file,int line); +void CRYPTO_set_locking_callback(void (*func)(int mode,int type, + const char *file,int line)); +void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, + int line); +void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, + const char *file, int line)); +int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, + const char *file,int line); +void CRYPTO_set_id_callback(unsigned long (*func)(void)); +unsigned long (*CRYPTO_get_id_callback(void))(void); +unsigned long CRYPTO_thread_id(void); +const char *CRYPTO_get_lock_name(int type); +int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, + int line); + +int CRYPTO_get_new_dynlockid(void); +void CRYPTO_destroy_dynlockid(int i); +struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); +void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); +void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); +void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); +struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); +void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); +void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); + +/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- + * call the latter last if you need different functions */ +int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); +int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); +int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), + void *(*r)(void *,size_t,const char *,int), + void (*f)(void *)); +int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), + void (*free_func)(void *)); +int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), + void (*r)(void *,void *,int,const char *,int,int), + void (*f)(void *,int), + void (*so)(long), + long (*go)(void)); +void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); +void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); +void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), + void *(**r)(void *, size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), + void (**r)(void *,void *,int,const char *,int,int), + void (**f)(void *,int), + void (**so)(long), + long (**go)(void)); + +void *CRYPTO_malloc_locked(int num, const char *file, int line); +void CRYPTO_free_locked(void *); +void *CRYPTO_malloc(int num, const char *file, int line); +void CRYPTO_free(void *); +void *CRYPTO_realloc(void *addr,int num, const char *file, int line); +void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, + int line); +void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); + +void OPENSSL_cleanse(void *ptr, size_t len); + +void CRYPTO_set_mem_debug_options(long bits); +long CRYPTO_get_mem_debug_options(void); + +#define CRYPTO_push_info(info) \ + CRYPTO_push_info_(info, __FILE__, __LINE__); +int CRYPTO_push_info_(const char *info, const char *file, int line); +int CRYPTO_pop_info(void); +int CRYPTO_remove_all_info(void); + + +/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; + * used as default in CRYPTO_MDEBUG compilations): */ +/* The last argument has the following significance: + * + * 0: called before the actual memory allocation has taken place + * 1: called after the actual memory allocation has taken place + */ +void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_free(void *addr,int before_p); +/* Tell the debugging code about options. By default, the following values + * apply: + * + * 0: Clear all options. + * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. + * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. + * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 + */ +void CRYPTO_dbg_set_options(long bits); +long CRYPTO_dbg_get_options(void); + + +#ifndef OPENSSL_NO_FP_API +void CRYPTO_mem_leaks_fp(FILE *); +#endif +void CRYPTO_mem_leaks(struct bio_st *bio); +/* unsigned long order, char *file, int line, int num_bytes, char *addr */ +typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); +void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); + +/* die if we have to */ +void OpenSSLDie(const char *file,int line,const char *assertion); +#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) + +unsigned long *OPENSSL_ia32cap_loc(void); +#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CRYPTO_strings(void); + +/* Error codes for the CRYPTO functions. */ + +/* Function codes. */ +#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 +#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 +#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 +#define CRYPTO_F_DEF_ADD_INDEX 104 +#define CRYPTO_F_DEF_GET_CLASS 105 +#define CRYPTO_F_INT_DUP_EX_DATA 106 +#define CRYPTO_F_INT_FREE_EX_DATA 107 +#define CRYPTO_F_INT_NEW_EX_DATA 108 + +/* Reason codes. */ +#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/des.h b/include/openssl/des.h new file mode 100755 index 0000000..5ed8747 --- /dev/null +++ b/include/openssl/des.h @@ -0,0 +1,244 @@ +/* crypto/des/des.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_NEW_DES_H +#define HEADER_NEW_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, + DES_LONG (via openssl/opensslconf.h */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char DES_cblock[8]; +typedef /* const */ unsigned char const_DES_cblock[8]; +/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * + * and const_DES_cblock * are incompatible pointer types. */ + +typedef struct DES_ks + { + union + { + DES_cblock cblock; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG deslong[2]; + } ks[16]; + } DES_key_schedule; + +#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT +# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT +# define OPENSSL_ENABLE_OLD_DES_SUPPORT +# endif +#endif + +#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT +# include +#endif + +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define DES_ecb2_encrypt(i,o,k1,k2,e) \ + DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ +#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) +OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ +#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) + +const char *DES_options(void); +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); +DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, + long length,DES_key_schedule *schedule, + const_DES_cblock *ivec); +/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ +void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + const_DES_cblock *inw,const_DES_cblock *outw,int enc); +void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, + DES_key_schedule *ks,int enc); + +/* This is the DES encryption function that gets called by just about + every other DES routine in the library. You should not use this + function except to implement 'modes' of DES. I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. The characters are loaded 'little endian'. + Data is a pointer to 2 unsigned long's and ks is the + DES_key_schedule to use. enc, is non zero specifies encryption, + zero if decryption. */ +void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); + +/* This functions is the same as DES_encrypt1() except that the DES + initial permutation (IP) and final permutation (FP) have been left + out. As for DES_encrypt1(), you should not use this function. + It is used by the routines in the library that implement triple DES. + IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same + as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ +void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); + +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3,DES_cblock *ivec,int enc); +void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, + DES_cblock *ivec1,DES_cblock *ivec2, + int enc); +void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num,int enc); +void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, + int numbits,long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int enc); +void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num); + +void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, + DES_cblock *out_white); + +int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +char *DES_fcrypt(const char *buf,const char *salt, char *ret); +char *DES_crypt(const char *buf,const char *salt); +void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec); +void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], + long length,int out_count,DES_cblock *seed); +int DES_random_key(DES_cblock *ret); +void DES_set_odd_parity(DES_cblock *key); +int DES_check_key_parity(const_DES_cblock *key); +int DES_is_weak_key(const_DES_cblock *key); +/* DES_set_key (= set_key = DES_key_sched = key_sched) calls + * DES_set_key_checked if global variable DES_check_key is set, + * DES_set_key_unchecked otherwise. */ +int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_string_to_key(const char *str,DES_cblock *key); +void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); +void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num, + int enc); +void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num); + +int DES_read_password(DES_cblock *key, const char *prompt, int verify); +int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, + int verify); + +#define DES_fixup_key_parity DES_set_odd_parity + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/des_old.h b/include/openssl/des_old.h new file mode 100755 index 0000000..caaa1da --- /dev/null +++ b/include/openssl/des_old.h @@ -0,0 +1,445 @@ +/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * The function names in here are deprecated and are only present to + * provide an interface compatible with openssl 0.9.6 and older as + * well as libdes. OpenSSL now provides functions where "des_" has + * been replaced with "DES_" in the names, to make it possible to + * make incompatible changes that are needed for C type security and + * other stuff. + * + * This include files has two compatibility modes: + * + * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API + * that is compatible with libdes and SSLeay. + * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an + * API that is compatible with OpenSSL 0.9.5x to 0.9.6x. + * + * Note that these modes break earlier snapshots of OpenSSL, where + * libdes compatibility was the only available mode or (later on) the + * prefered compatibility mode. However, after much consideration + * (and more or less violent discussions with external parties), it + * was concluded that OpenSSL should be compatible with earlier versions + * of itself before anything else. Also, in all honesty, libdes is + * an old beast that shouldn't really be used any more. + * + * Please consider starting to use the DES_ functions rather than the + * des_ ones. The des_ functions will disappear completely before + * OpenSSL 1.0! + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DES_H +#define HEADER_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifndef HEADER_NEW_DES_H +#error You must include des.h, not des_old.h directly. +#endif + +#ifdef _KERBEROS_DES_H +#error replaces . +#endif + +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _ +#undef _ +#endif + +typedef unsigned char _ossl_old_des_cblock[8]; +typedef struct _ossl_old_des_ks_struct + { + union { + _ossl_old_des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; + } _ossl_old_des_key_schedule[16]; + +#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY +#define des_cblock DES_cblock +#define const_des_cblock const_DES_cblock +#define des_key_schedule DES_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e)) +#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\ + DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n)) +#define des_options()\ + DES_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + DES_cbc_cksum((i),(o),(l),&(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + DES_ecb_encrypt((i),(o),&(k),(e)) +#define des_encrypt1(d,k,e)\ + DES_encrypt1((d),&(k),(e)) +#define des_encrypt2(d,k,e)\ + DES_encrypt2((d),&(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + DES_encrypt3((d),&(k1),&(k2),&(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + DES_decrypt3((d),&(k1),&(k2),&(k3)) +#define des_xwhite_in2out(k,i,o)\ + DES_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + DES_enc_read((f),(b),(l),&(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + DES_enc_write((f),(b),(l),&(k),(iv)) +#define des_fcrypt(b,s,r)\ + DES_fcrypt((b),(s),(r)) +#if 0 +#define des_crypt(b,s)\ + DES_crypt((b),(s)) +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) +#define crypt(b,s)\ + DES_crypt((b),(s)) +#endif +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + DES_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_096_des_random_seed((k)) +#define des_random_key(r)\ + DES_random_key((r)) +#define des_read_password(k,p,v) \ + DES_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + DES_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + DES_set_odd_parity((k)) +#define des_check_key_parity(k)\ + DES_check_key_parity((k)) +#define des_is_weak_key(k)\ + DES_is_weak_key((k)) +#define des_set_key(k,ks)\ + DES_set_key((k),&(ks)) +#define des_key_sched(k,ks)\ + DES_key_sched((k),&(ks)) +#define des_set_key_checked(k,ks)\ + DES_set_key_checked((k),&(ks)) +#define des_set_key_unchecked(k,ks)\ + DES_set_key_unchecked((k),&(ks)) +#define des_string_to_key(s,k)\ + DES_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + DES_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#else /* libdes compatibility */ +/* Map all symbol names to _ossl_old_des_* form, so we avoid all + clashes with libdes */ +#define des_cblock _ossl_old_des_cblock +#define des_key_schedule _ossl_old_des_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n)) +#define des_options()\ + _ossl_old_des_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + _ossl_old_des_ecb_encrypt((i),(o),(k),(e)) +#define des_encrypt(d,k,e)\ + _ossl_old_des_encrypt((d),(k),(e)) +#define des_encrypt2(d,k,e)\ + _ossl_old_des_encrypt2((d),(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + _ossl_old_des_encrypt3((d),(k1),(k2),(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + _ossl_old_des_decrypt3((d),(k1),(k2),(k3)) +#define des_xwhite_in2out(k,i,o)\ + _ossl_old_des_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + _ossl_old_des_enc_read((f),(b),(l),(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + _ossl_old_des_enc_write((f),(b),(l),(k),(iv)) +#define des_fcrypt(b,s,r)\ + _ossl_old_des_fcrypt((b),(s),(r)) +#define des_crypt(b,s)\ + _ossl_old_des_crypt((b),(s)) +#if 0 +#define crypt(b,s)\ + _ossl_old_crypt((b),(s)) +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + _ossl_old_des_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_old_des_random_seed((k)) +#define des_random_key(r)\ + _ossl_old_des_random_key((r)) +#define des_read_password(k,p,v) \ + _ossl_old_des_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + _ossl_old_des_set_odd_parity((k)) +#define des_is_weak_key(k)\ + _ossl_old_des_is_weak_key((k)) +#define des_set_key(k,ks)\ + _ossl_old_des_set_key((k),(ks)) +#define des_key_sched(k,ks)\ + _ossl_old_des_key_sched((k),(ks)) +#define des_string_to_key(s,k)\ + _ossl_old_des_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + _ossl_old_des_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#endif + +const char *_ossl_old_des_options(void); +void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, int enc); +DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec, + _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc); +void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks,int enc); +void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc); +void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), + _ossl_old_des_cblock (*out_white)); + +int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret); +char *_ossl_old_des_crypt(const char *buf,const char *salt); +#if !defined(PERL5) && !defined(NeXT) +char *_ossl_old_crypt(const char *buf,const char *salt); +#endif +void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,int out_count,_ossl_old_des_cblock *seed); +void _ossl_old_des_random_seed(_ossl_old_des_cblock key); +void _ossl_old_des_random_key(_ossl_old_des_cblock ret); +int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify); +int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2, + const char *prompt,int verify); +void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key); +int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key); +int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key); +void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2); +void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_096_des_random_seed(des_cblock *key); + +/* The following definitions provide compatibility with the MIT Kerberos + * library. The _ossl_old_des_key_schedule structure is not binary compatible. */ + +#define _KERBEROS_DES_H + +#define KRBDES_ENCRYPT DES_ENCRYPT +#define KRBDES_DECRYPT DES_DECRYPT + +#ifdef KERBEROS +# define ENCRYPT DES_ENCRYPT +# define DECRYPT DES_DECRYPT +#endif + +#ifndef NCOMPAT +# define C_Block des_cblock +# define Key_schedule des_key_schedule +# define KEY_SZ DES_KEY_SZ +# define string_to_key des_string_to_key +# define read_pw_string des_read_pw_string +# define random_key des_random_key +# define pcbc_encrypt des_pcbc_encrypt +# define set_key des_set_key +# define key_sched des_key_sched +# define ecb_encrypt des_ecb_encrypt +# define cbc_encrypt des_cbc_encrypt +# define ncbc_encrypt des_ncbc_encrypt +# define xcbc_encrypt des_xcbc_encrypt +# define cbc_cksum des_cbc_cksum +# define quad_cksum des_quad_cksum +# define check_parity des_check_key_parity +#endif + +#define des_fixup_key_parity DES_fixup_key_parity + +#ifdef __cplusplus +} +#endif + +/* for DES_read_pw_string et al */ +#include + +#endif diff --git a/include/openssl/dh.h b/include/openssl/dh.h new file mode 100755 index 0000000..44158f8 --- /dev/null +++ b/include/openssl/dh.h @@ -0,0 +1,234 @@ +/* crypto/dh/dh.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_DH_H +#define HEADER_DH_H + +#include + +#ifdef OPENSSL_NO_DH +#error DH is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifndef OPENSSL_DH_MAX_MODULUS_BITS +# define OPENSSL_DH_MAX_MODULUS_BITS 10000 +#endif + +#define DH_FLAG_CACHE_MONT_P 0x01 +#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dh_st DH; */ +/* typedef struct dh_method DH_METHOD; */ + +struct dh_method + { + const char *name; + /* Methods here */ + int (*generate_key)(DH *dh); + int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh); + int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a, + const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + + int (*init)(DH *dh); + int (*finish)(DH *dh); + int flags; + char *app_data; + /* If this is non-NULL, it will be used to generate parameters */ + int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb); + }; + +struct dh_st + { + /* This first argument is used to pick up errors when + * a DH is passed instead of a EVP_PKEY */ + int pad; + int version; + BIGNUM *p; + BIGNUM *g; + long length; /* optional */ + BIGNUM *pub_key; /* g^x */ + BIGNUM *priv_key; /* x */ + + int flags; + BN_MONT_CTX *method_mont_p; + /* Place holders if we want to do X9.42 DH */ + BIGNUM *q; + BIGNUM *j; + unsigned char *seed; + int seedlen; + BIGNUM *counter; + + int references; + CRYPTO_EX_DATA ex_data; + const DH_METHOD *meth; + ENGINE *engine; + }; + +#define DH_GENERATOR_2 2 +/* #define DH_GENERATOR_3 3 */ +#define DH_GENERATOR_5 5 + +/* DH_check error codes */ +#define DH_CHECK_P_NOT_PRIME 0x01 +#define DH_CHECK_P_NOT_SAFE_PRIME 0x02 +#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 +#define DH_NOT_SUITABLE_GENERATOR 0x08 + +/* DH_check_pub_key error codes */ +#define DH_CHECK_PUBKEY_TOO_SMALL 0x01 +#define DH_CHECK_PUBKEY_TOO_LARGE 0x02 + +/* primes p where (p-1)/2 is prime too are called "safe"; we define + this for backward compatibility: */ +#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME + +#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x) +#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ + (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) +#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) +#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) + +const DH_METHOD *DH_OpenSSL(void); + +void DH_set_default_method(const DH_METHOD *meth); +const DH_METHOD *DH_get_default_method(void); +int DH_set_method(DH *dh, const DH_METHOD *meth); +DH *DH_new_method(ENGINE *engine); + +DH * DH_new(void); +void DH_free(DH *dh); +int DH_up_ref(DH *dh); +int DH_size(const DH *dh); +int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DH_set_ex_data(DH *d, int idx, void *arg); +void *DH_get_ex_data(DH *d, int idx); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DH * DH_generate_parameters(int prime_len,int generator, + void (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); + +int DH_check(const DH *dh,int *codes); +int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes); +int DH_generate_key(DH *dh); +int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh); +DH * d2i_DHparams(DH **a,const unsigned char **pp, long length); +int i2d_DHparams(const DH *a,unsigned char **pp); +#ifndef OPENSSL_NO_FP_API +int DHparams_print_fp(FILE *fp, const DH *x); +#endif +#ifndef OPENSSL_NO_BIO +int DHparams_print(BIO *bp, const DH *x); +#else +int DHparams_print(char *bp, const DH *x); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DH_strings(void); + +/* Error codes for the DH functions. */ + +/* Function codes. */ +#define DH_F_COMPUTE_KEY 102 +#define DH_F_DHPARAMS_PRINT 100 +#define DH_F_DHPARAMS_PRINT_FP 101 +#define DH_F_DH_BUILTIN_GENPARAMS 106 +#define DH_F_DH_NEW_METHOD 105 +#define DH_F_GENERATE_KEY 103 +#define DH_F_GENERATE_PARAMETERS 104 + +/* Reason codes. */ +#define DH_R_BAD_GENERATOR 101 +#define DH_R_INVALID_PUBKEY 102 +#define DH_R_MODULUS_TOO_LARGE 103 +#define DH_R_NO_PRIVATE_VALUE 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h new file mode 100755 index 0000000..fa58369 --- /dev/null +++ b/include/openssl/dsa.h @@ -0,0 +1,285 @@ +/* crypto/dsa/dsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* + * The DSS routines are based on patches supplied by + * Steven Schoch . He basically did the + * work and I have just tweaked them a little to fit into my + * stylistic vision for SSLeay :-) */ + +#ifndef HEADER_DSA_H +#define HEADER_DSA_H + +#include + +#ifdef OPENSSL_NO_DSA +#error DSA is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_DH +# include +#endif +#endif + +#ifndef OPENSSL_DSA_MAX_MODULUS_BITS +# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 +#endif + +#define DSA_FLAG_CACHE_MONT_P 0x01 +#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dsa_st DSA; */ +/* typedef struct dsa_method DSA_METHOD; */ + +typedef struct DSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } DSA_SIG; + +struct dsa_method + { + const char *name; + DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa); + int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); + int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); + int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, + BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); + int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(DSA *dsa); + int (*finish)(DSA *dsa); + int flags; + char *app_data; + /* If this is non-NULL, it is used to generate DSA parameters */ + int (*dsa_paramgen)(DSA *dsa, int bits, + unsigned char *seed, int seed_len, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); + /* If this is non-NULL, it is used to generate DSA keys */ + int (*dsa_keygen)(DSA *dsa); + }; + +struct dsa_st + { + /* This first variable is used to pick up errors where + * a DSA is passed instead of of a EVP_PKEY */ + int pad; + long version; + int write_params; + BIGNUM *p; + BIGNUM *q; /* == 20 */ + BIGNUM *g; + + BIGNUM *pub_key; /* y public key */ + BIGNUM *priv_key; /* x private key */ + + BIGNUM *kinv; /* Signing pre-calc */ + BIGNUM *r; /* Signing pre-calc */ + + int flags; + /* Normally used to cache montgomery values */ + BN_MONT_CTX *method_mont_p; + int references; + CRYPTO_EX_DATA ex_data; + const DSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + }; + +#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x) +#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ + (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) +#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) +#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) + + +DSA_SIG * DSA_SIG_new(void); +void DSA_SIG_free(DSA_SIG *a); +int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); +DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); + +DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); +int DSA_do_verify(const unsigned char *dgst,int dgst_len, + DSA_SIG *sig,DSA *dsa); + +const DSA_METHOD *DSA_OpenSSL(void); + +void DSA_set_default_method(const DSA_METHOD *); +const DSA_METHOD *DSA_get_default_method(void); +int DSA_set_method(DSA *dsa, const DSA_METHOD *); + +DSA * DSA_new(void); +DSA * DSA_new_method(ENGINE *engine); +void DSA_free (DSA *r); +/* "up" the DSA object's reference count */ +int DSA_up_ref(DSA *r); +int DSA_size(const DSA *); + /* next 4 return -1 on error */ +int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); +int DSA_sign(int type,const unsigned char *dgst,int dlen, + unsigned char *sig, unsigned int *siglen, DSA *dsa); +int DSA_verify(int type,const unsigned char *dgst,int dgst_len, + const unsigned char *sigbuf, int siglen, DSA *dsa); +int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DSA_set_ex_data(DSA *d, int idx, void *arg); +void *DSA_get_ex_data(DSA *d, int idx); + +DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DSA * DSA_generate_parameters(int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret,void + (*callback)(int, int, void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DSA_generate_parameters_ex(DSA *dsa, int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); + +int DSA_generate_key(DSA *a); +int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); +int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); +int i2d_DSAparams(const DSA *a,unsigned char **pp); + +#ifndef OPENSSL_NO_BIO +int DSAparams_print(BIO *bp, const DSA *x); +int DSA_print(BIO *bp, const DSA *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int DSAparams_print_fp(FILE *fp, const DSA *x); +int DSA_print_fp(FILE *bp, const DSA *x, int off); +#endif + +#define DSS_prime_checks 50 +/* Primality test according to FIPS PUB 186[-1], Appendix 2.1: + * 50 rounds of Rabin-Miller */ +#define DSA_is_prime(n, callback, cb_arg) \ + BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) + +#ifndef OPENSSL_NO_DH +/* Convert DSA structure (key or just parameters) into DH structure + * (be careful to avoid small subgroup attacks when using this!) */ +DH *DSA_dup_DH(const DSA *r); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSA_strings(void); + +/* Error codes for the DSA functions. */ + +/* Function codes. */ +#define DSA_F_D2I_DSA_SIG 110 +#define DSA_F_DSAPARAMS_PRINT 100 +#define DSA_F_DSAPARAMS_PRINT_FP 101 +#define DSA_F_DSA_DO_SIGN 112 +#define DSA_F_DSA_DO_VERIFY 113 +#define DSA_F_DSA_NEW_METHOD 103 +#define DSA_F_DSA_PRINT 104 +#define DSA_F_DSA_PRINT_FP 105 +#define DSA_F_DSA_SIGN 106 +#define DSA_F_DSA_SIGN_SETUP 107 +#define DSA_F_DSA_SIG_NEW 109 +#define DSA_F_DSA_VERIFY 108 +#define DSA_F_I2D_DSA_SIG 111 +#define DSA_F_SIG_CB 114 + +/* Reason codes. */ +#define DSA_R_BAD_Q_VALUE 102 +#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 +#define DSA_R_MISSING_PARAMETERS 101 +#define DSA_R_MODULUS_TOO_LARGE 103 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/dso.h b/include/openssl/dso.h new file mode 100755 index 0000000..1836231 --- /dev/null +++ b/include/openssl/dso.h @@ -0,0 +1,368 @@ +/* dso.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DSO_H +#define HEADER_DSO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These values are used as commands to DSO_ctrl() */ +#define DSO_CTRL_GET_FLAGS 1 +#define DSO_CTRL_SET_FLAGS 2 +#define DSO_CTRL_OR_FLAGS 3 + +/* By default, DSO_load() will translate the provided filename into a form + * typical for the platform (more specifically the DSO_METHOD) using the + * dso_name_converter function of the method. Eg. win32 will transform "blah" + * into "blah.dll", and dlfcn will transform it into "libblah.so". The + * behaviour can be overriden by setting the name_converter callback in the DSO + * object (using DSO_set_name_converter()). This callback could even utilise + * the DSO_METHOD's converter too if it only wants to override behaviour for + * one or two possible DSO methods. However, the following flag can be set in a + * DSO to prevent *any* native name-translation at all - eg. if the caller has + * prompted the user for a path to a driver library so the filename should be + * interpreted as-is. */ +#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 +/* An extra flag to give if only the extension should be added as + * translation. This is obviously only of importance on Unix and + * other operating systems where the translation also may prefix + * the name with something, like 'lib', and ignored everywhere else. + * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used + * at the same time. */ +#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 + +/* The following flag controls the translation of symbol names to upper + * case. This is currently only being implemented for OpenVMS. + */ +#define DSO_FLAG_UPCASE_SYMBOL 0x10 + +/* This flag loads the library with public symbols. + * Meaning: The exported symbols of this library are public + * to all libraries loaded after this library. + * At the moment only implemented in unix. + */ +#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 + + +typedef void (*DSO_FUNC_TYPE)(void); + +typedef struct dso_st DSO; + +/* The function prototype used for method functions (or caller-provided + * callbacks) that transform filenames. They are passed a DSO structure pointer + * (or NULL if they are to be used independantly of a DSO object) and a + * filename to transform. They should either return NULL (if there is an error + * condition) or a newly allocated string containing the transformed form that + * the caller will need to free with OPENSSL_free() when done. */ +typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); +/* The function prototype used for method functions (or caller-provided + * callbacks) that merge two file specifications. They are passed a + * DSO structure pointer (or NULL if they are to be used independantly of + * a DSO object) and two file specifications to merge. They should + * either return NULL (if there is an error condition) or a newly allocated + * string containing the result of merging that the caller will need + * to free with OPENSSL_free() when done. + * Here, merging means that bits and pieces are taken from each of the + * file specifications and added together in whatever fashion that is + * sensible for the DSO method in question. The only rule that really + * applies is that if the two specification contain pieces of the same + * type, the copy from the first string takes priority. One could see + * it as the first specification is the one given by the user and the + * second being a bunch of defaults to add on if they're missing in the + * first. */ +typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); + +typedef struct dso_meth_st + { + const char *name; + /* Loads a shared library, NB: new DSO_METHODs must ensure that a + * successful load populates the loaded_filename field, and likewise a + * successful unload OPENSSL_frees and NULLs it out. */ + int (*dso_load)(DSO *dso); + /* Unloads a shared library */ + int (*dso_unload)(DSO *dso); + /* Binds a variable */ + void *(*dso_bind_var)(DSO *dso, const char *symname); + /* Binds a function - assumes a return type of DSO_FUNC_TYPE. + * This should be cast to the real function prototype by the + * caller. Platforms that don't have compatible representations + * for different prototypes (this is possible within ANSI C) + * are highly unlikely to have shared libraries at all, let + * alone a DSO_METHOD implemented for them. */ + DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); + +/* I don't think this would actually be used in any circumstances. */ +#if 0 + /* Unbinds a variable */ + int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr); + /* Unbinds a function */ + int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); +#endif + /* The generic (yuck) "ctrl()" function. NB: Negative return + * values (rather than zero) indicate errors. */ + long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_NAME_CONVERTER_FUNC dso_name_converter; + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_MERGER_FUNC dso_merger; + + /* [De]Initialisation handlers. */ + int (*init)(DSO *dso); + int (*finish)(DSO *dso); + } DSO_METHOD; + +/**********************************************************************/ +/* The low-level handle type used to refer to a loaded shared library */ + +struct dso_st + { + DSO_METHOD *meth; + /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS + * doesn't use anything but will need to cache the filename + * for use in the dso_bind handler. All in all, let each + * method control its own destiny. "Handles" and such go in + * a STACK. */ + STACK *meth_data; + int references; + int flags; + /* For use by applications etc ... use this for your bits'n'pieces, + * don't touch meth_data! */ + CRYPTO_EX_DATA ex_data; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_name_converter. NB: This + * should normally set using DSO_set_name_converter(). */ + DSO_NAME_CONVERTER_FUNC name_converter; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_merger. NB: This + * should normally set using DSO_set_merger(). */ + DSO_MERGER_FUNC merger; + /* This is populated with (a copy of) the platform-independant + * filename used for this DSO. */ + char *filename; + /* This is populated with (a copy of) the translated filename by which + * the DSO was actually loaded. It is NULL iff the DSO is not currently + * loaded. NB: This is here because the filename translation process + * may involve a callback being invoked more than once not only to + * convert to a platform-specific form, but also to try different + * filenames in the process of trying to perform a load. As such, this + * variable can be used to indicate (a) whether this DSO structure + * corresponds to a loaded library or not, and (b) the filename with + * which it was actually loaded. */ + char *loaded_filename; + }; + + +DSO * DSO_new(void); +DSO * DSO_new_method(DSO_METHOD *method); +int DSO_free(DSO *dso); +int DSO_flags(DSO *dso); +int DSO_up_ref(DSO *dso); +long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); + +/* This function sets the DSO's name_converter callback. If it is non-NULL, + * then it will be used instead of the associated DSO_METHOD's function. If + * oldcb is non-NULL then it is set to the function pointer value being + * replaced. Return value is non-zero for success. */ +int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, + DSO_NAME_CONVERTER_FUNC *oldcb); +/* These functions can be used to get/set the platform-independant filename + * used for a DSO. NB: set will fail if the DSO is already loaded. */ +const char *DSO_get_filename(DSO *dso); +int DSO_set_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's name_converter callback to translate a + * filename, or if the callback isn't set it will instead use the DSO_METHOD's + * converter. If "filename" is NULL, the "filename" in the DSO itself will be + * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is + * simply duplicated. NB: This function is usually called from within a + * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that + * caller-created DSO_METHODs can do the same thing. A non-NULL return value + * will need to be OPENSSL_free()'d. */ +char *DSO_convert_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's merger callback to merge two file + * specifications, or if the callback isn't set it will instead use the + * DSO_METHOD's merger. A non-NULL return value will need to be + * OPENSSL_free()'d. */ +char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); +/* If the DSO is currently loaded, this returns the filename that it was loaded + * under, otherwise it returns NULL. So it is also useful as a test as to + * whether the DSO is currently loaded. NB: This will not necessarily return + * the same value as DSO_convert_filename(dso, dso->filename), because the + * DSO_METHOD's load function may have tried a variety of filenames (with + * and/or without the aid of the converters) before settling on the one it + * actually loaded. */ +const char *DSO_get_loaded_filename(DSO *dso); + +void DSO_set_default_method(DSO_METHOD *meth); +DSO_METHOD *DSO_get_default_method(void); +DSO_METHOD *DSO_get_method(DSO *dso); +DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); + +/* The all-singing all-dancing load function, you normally pass NULL + * for the first and third parameters. Use DSO_up and DSO_free for + * subsequent reference count handling. Any flags passed in will be set + * in the constructed DSO after its init() function but before the + * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ +DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); + +/* This function binds to a variable inside a shared library. */ +void *DSO_bind_var(DSO *dso, const char *symname); + +/* This function binds to a function inside a shared library. */ +DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); + +/* This method is the default, but will beg, borrow, or steal whatever + * method should be the default on any particular platform (including + * DSO_METH_null() if necessary). */ +DSO_METHOD *DSO_METHOD_openssl(void); + +/* This method is defined for all platforms - if a platform has no + * DSO support then this will be the only method! */ +DSO_METHOD *DSO_METHOD_null(void); + +/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions + * (dlopen, dlclose, dlsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dlfcn(void); + +/* If DSO_DL is defined, the standard dl.h-style functions (shl_load, + * shl_unload, shl_findsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dl(void); + +/* If WIN32 is defined, use DLLs. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_win32(void); + +/* If VMS is defined, use shared images. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_vms(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSO_strings(void); + +/* Error codes for the DSO functions. */ + +/* Function codes. */ +#define DSO_F_DLFCN_BIND_FUNC 100 +#define DSO_F_DLFCN_BIND_VAR 101 +#define DSO_F_DLFCN_LOAD 102 +#define DSO_F_DLFCN_MERGER 130 +#define DSO_F_DLFCN_NAME_CONVERTER 123 +#define DSO_F_DLFCN_UNLOAD 103 +#define DSO_F_DL_BIND_FUNC 104 +#define DSO_F_DL_BIND_VAR 105 +#define DSO_F_DL_LOAD 106 +#define DSO_F_DL_MERGER 131 +#define DSO_F_DL_NAME_CONVERTER 124 +#define DSO_F_DL_UNLOAD 107 +#define DSO_F_DSO_BIND_FUNC 108 +#define DSO_F_DSO_BIND_VAR 109 +#define DSO_F_DSO_CONVERT_FILENAME 126 +#define DSO_F_DSO_CTRL 110 +#define DSO_F_DSO_FREE 111 +#define DSO_F_DSO_GET_FILENAME 127 +#define DSO_F_DSO_GET_LOADED_FILENAME 128 +#define DSO_F_DSO_LOAD 112 +#define DSO_F_DSO_MERGE 132 +#define DSO_F_DSO_NEW_METHOD 113 +#define DSO_F_DSO_SET_FILENAME 129 +#define DSO_F_DSO_SET_NAME_CONVERTER 122 +#define DSO_F_DSO_UP_REF 114 +#define DSO_F_VMS_BIND_SYM 115 +#define DSO_F_VMS_LOAD 116 +#define DSO_F_VMS_MERGER 133 +#define DSO_F_VMS_UNLOAD 117 +#define DSO_F_WIN32_BIND_FUNC 118 +#define DSO_F_WIN32_BIND_VAR 119 +#define DSO_F_WIN32_JOINER 135 +#define DSO_F_WIN32_LOAD 120 +#define DSO_F_WIN32_MERGER 134 +#define DSO_F_WIN32_NAME_CONVERTER 125 +#define DSO_F_WIN32_SPLITTER 136 +#define DSO_F_WIN32_UNLOAD 121 + +/* Reason codes. */ +#define DSO_R_CTRL_FAILED 100 +#define DSO_R_DSO_ALREADY_LOADED 110 +#define DSO_R_EMPTY_FILE_STRUCTURE 113 +#define DSO_R_FAILURE 114 +#define DSO_R_FILENAME_TOO_BIG 101 +#define DSO_R_FINISH_FAILED 102 +#define DSO_R_INCORRECT_FILE_SYNTAX 115 +#define DSO_R_LOAD_FAILED 103 +#define DSO_R_NAME_TRANSLATION_FAILED 109 +#define DSO_R_NO_FILENAME 111 +#define DSO_R_NO_FILE_SPECIFICATION 116 +#define DSO_R_NULL_HANDLE 104 +#define DSO_R_SET_FILENAME_FAILED 112 +#define DSO_R_STACK_ERROR 105 +#define DSO_R_SYM_FAILURE 106 +#define DSO_R_UNLOAD_FAILED 107 +#define DSO_R_UNSUPPORTED 108 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/dtls1.h b/include/openssl/dtls1.h new file mode 100755 index 0000000..8093a8f --- /dev/null +++ b/include/openssl/dtls1.h @@ -0,0 +1,212 @@ +/* ssl/dtls1.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DTLS1_H +#define HEADER_DTLS1_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DTLS1_VERSION 0x0100 +#define DTLS1_VERSION_MAJOR 0x01 +#define DTLS1_VERSION_MINOR 0x00 + +#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 + +/* lengths of messages */ +#define DTLS1_COOKIE_LENGTH 32 + +#define DTLS1_RT_HEADER_LENGTH 13 + +#define DTLS1_HM_HEADER_LENGTH 12 + +#define DTLS1_HM_BAD_FRAGMENT -2 +#define DTLS1_HM_FRAGMENT_RETRY -3 + +#define DTLS1_CCS_HEADER_LENGTH 3 + +#define DTLS1_AL_HEADER_LENGTH 7 + + +typedef struct dtls1_bitmap_st + { + PQ_64BIT map; + unsigned long length; /* sizeof the bitmap in bits */ + PQ_64BIT max_seq_num; /* max record number seen so far */ + } DTLS1_BITMAP; + +struct hm_header_st + { + unsigned char type; + unsigned long msg_len; + unsigned short seq; + unsigned long frag_off; + unsigned long frag_len; + unsigned int is_ccs; + }; + +struct ccs_header_st + { + unsigned char type; + unsigned short seq; + }; + +struct dtls1_timeout_st + { + /* Number of read timeouts so far */ + unsigned int read_timeouts; + + /* Number of write timeouts so far */ + unsigned int write_timeouts; + + /* Number of alerts received so far */ + unsigned int num_alerts; + }; + +typedef struct record_pqueue_st + { + unsigned short epoch; + pqueue q; + } record_pqueue; + +typedef struct hm_fragment_st + { + struct hm_header_st msg_header; + unsigned char *fragment; + } hm_fragment; + +typedef struct dtls1_state_st + { + unsigned int send_cookie; + unsigned char cookie[DTLS1_COOKIE_LENGTH]; + unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; + unsigned int cookie_len; + + /* + * The current data and handshake epoch. This is initially + * undefined, and starts at zero once the initial handshake is + * completed + */ + unsigned short r_epoch; + unsigned short w_epoch; + + /* records being received in the current epoch */ + DTLS1_BITMAP bitmap; + + /* renegotiation starts a new set of sequence numbers */ + DTLS1_BITMAP next_bitmap; + + /* handshake message numbers */ + unsigned short handshake_write_seq; + unsigned short next_handshake_write_seq; + + unsigned short handshake_read_seq; + + /* Received handshake records (processed and unprocessed) */ + record_pqueue unprocessed_rcds; + record_pqueue processed_rcds; + + /* Buffered handshake messages */ + pqueue buffered_messages; + + /* Buffered (sent) handshake records */ + pqueue sent_messages; + + unsigned int mtu; /* max wire packet size */ + + struct hm_header_st w_msg_hdr; + struct hm_header_st r_msg_hdr; + + struct dtls1_timeout_st timeout; + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; + unsigned int handshake_fragment_len; + + unsigned int retransmitting; + + } DTLS1_STATE; + +typedef struct dtls1_record_data_st + { + unsigned char *packet; + unsigned int packet_length; + SSL3_BUFFER rbuf; + SSL3_RECORD rrec; + } DTLS1_RECORD_DATA; + + +/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ +#define DTLS1_TMO_READ_COUNT 2 +#define DTLS1_TMO_WRITE_COUNT 2 + +#define DTLS1_TMO_ALERT_COUNT 12 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h new file mode 100755 index 0000000..79bfe24 --- /dev/null +++ b/include/openssl/e_os2.h @@ -0,0 +1,279 @@ +/* e_os2.h */ +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#ifndef HEADER_E_OS2_H +#define HEADER_E_OS2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + * Detect operating systems. This probably needs completing. + * The result is that at least one OPENSSL_SYS_os macro should be defined. + * However, if none is defined, Unix is assumed. + **/ + +#define OPENSSL_SYS_UNIX + +/* ----------------------- Macintosh, before MacOS X ----------------------- */ +#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MACINTOSH_CLASSIC +#endif + +/* ----------------------- NetWare ----------------------------------------- */ +#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_NETWARE +#endif + +/* ---------------------- Microsoft operating systems ---------------------- */ + +/* Note that MSDOS actually denotes 32-bit environments running on top of + MS-DOS, such as DJGPP one. */ +#if defined(OPENSSL_SYSNAME_MSDOS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MSDOS +#endif + +/* For 32 bit environment, there seems to be the CygWin environment and then + all the others that try to do the same thing Microsoft does... */ +#if defined(OPENSSL_SYSNAME_UWIN) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_UWIN +#else +# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_CYGWIN +# else +# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32 +# endif +# if defined(OPENSSL_SYSNAME_WINNT) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINNT +# endif +# if defined(OPENSSL_SYSNAME_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINCE +# endif +# endif +#endif + +/* Anything that tries to look like Microsoft is "Windows" */ +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_SYS_MSDOS +# define OPENSSL_SYS_MSDOS +# endif +#endif + +/* DLL settings. This part is a bit tough, because it's up to the application + implementor how he or she will link the application, so it requires some + macro to be used. */ +#ifdef OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_OPT_WINDLL +# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that + DLL linkage should be used */ +# define OPENSSL_OPT_WINDLL +# endif +# endif +#endif + +/* -------------------------------- OpenVMS -------------------------------- */ +#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_VMS +# if defined(__DECC) +# define OPENSSL_SYS_VMS_DECC +# elif defined(__DECCXX) +# define OPENSSL_SYS_VMS_DECC +# define OPENSSL_SYS_VMS_DECCXX +# else +# define OPENSSL_SYS_VMS_NODECC +# endif +#endif + +/* --------------------------------- OS/2 ---------------------------------- */ +#if defined(__EMX__) || defined(__OS2__) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_OS2 +#endif + +/* --------------------------------- Unix ---------------------------------- */ +#ifdef OPENSSL_SYS_UNIX +# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) +# define OPENSSL_SYS_LINUX +# endif +# ifdef OPENSSL_SYSNAME_MPE +# define OPENSSL_SYS_MPE +# endif +# ifdef OPENSSL_SYSNAME_SNI +# define OPENSSL_SYS_SNI +# endif +# ifdef OPENSSL_SYSNAME_ULTRASPARC +# define OPENSSL_SYS_ULTRASPARC +# endif +# ifdef OPENSSL_SYSNAME_NEWS4 +# define OPENSSL_SYS_NEWS4 +# endif +# ifdef OPENSSL_SYSNAME_MACOSX +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_SUNOS +# define OPENSSL_SYS_SUNOS +#endif +# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) +# define OPENSSL_SYS_CRAY +# endif +# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) +# define OPENSSL_SYS_AIX +# endif +#endif + +/* --------------------------------- VOS ----------------------------------- */ +#ifdef OPENSSL_SYSNAME_VOS +# define OPENSSL_SYS_VOS +#endif + +/* ------------------------------- VxWorks --------------------------------- */ +#ifdef OPENSSL_SYSNAME_VXWORKS +# define OPENSSL_SYS_VXWORKS +#endif + +/** + * That's it for OS-specific stuff + *****************************************************************************/ + + +/* Specials for I/O an exit */ +#ifdef OPENSSL_SYS_MSDOS +# define OPENSSL_UNISTD_IO +# define OPENSSL_DECLARE_EXIT extern void exit(int); +#else +# define OPENSSL_UNISTD_IO OPENSSL_UNISTD +# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ +#endif + +/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare + certain global symbols that, with some compilers under VMS, have to be + defined and declared explicitely with globaldef and globalref. + Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare + DLL exports and imports for compilers under Win32. These are a little + more complicated to use. Basically, for any library that exports some + global variables, the following code must be present in the header file + that declares them, before OPENSSL_EXTERN is used: + + #ifdef SOME_BUILD_FLAG_MACRO + # undef OPENSSL_EXTERN + # define OPENSSL_EXTERN OPENSSL_EXPORT + #endif + + The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL + have some generally sensible values, and for OPENSSL_EXTERN to have the + value OPENSSL_IMPORT. +*/ + +#if defined(OPENSSL_SYS_VMS_NODECC) +# define OPENSSL_EXPORT globalref +# define OPENSSL_IMPORT globalref +# define OPENSSL_GLOBAL globaldef +#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) +# define OPENSSL_EXPORT extern __declspec(dllexport) +# define OPENSSL_IMPORT extern __declspec(dllimport) +# define OPENSSL_GLOBAL +#else +# define OPENSSL_EXPORT extern +# define OPENSSL_IMPORT extern +# define OPENSSL_GLOBAL +#endif +#define OPENSSL_EXTERN OPENSSL_IMPORT + +/* Macros to allow global variables to be reached through function calls when + required (if a shared library version requvres it, for example. + The way it's done allows definitions like this: + + // in foobar.c + OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; + // in foobar.h + OPENSSL_DECLARE_GLOBAL(int,foobar); + #define foobar OPENSSL_GLOBAL_REF(foobar) +*/ +#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ + extern type _hide_##name; \ + type *_shadow_##name(void) { return &_hide_##name; } \ + static type _hide_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) +# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) +#else +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name +# define OPENSSL_GLOBAL_REF(name) _shadow_##name +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/ebcdic.h b/include/openssl/ebcdic.h new file mode 100755 index 0000000..0941c8b --- /dev/null +++ b/include/openssl/ebcdic.h @@ -0,0 +1,19 @@ +/* crypto/ebcdic.h */ + +#ifndef HEADER_EBCDIC_H +#define HEADER_EBCDIC_H + +#include + +/* Avoid name clashes with other applications */ +#define os_toascii _openssl_os_toascii +#define os_toebcdic _openssl_os_toebcdic +#define ebcdic2ascii _openssl_ebcdic2ascii +#define ascii2ebcdic _openssl_ascii2ebcdic + +extern const unsigned char os_toascii[256]; +extern const unsigned char os_toebcdic[256]; +void *ebcdic2ascii(void *dest, const void *srce, size_t count); +void *ascii2ebcdic(void *dest, const void *srce, size_t count); + +#endif diff --git a/include/openssl/ec.h b/include/openssl/ec.h new file mode 100755 index 0000000..51304f7 --- /dev/null +++ b/include/openssl/ec.h @@ -0,0 +1,525 @@ +/* crypto/ec/ec.h */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_EC_H +#define HEADER_EC_H + +#include + +#ifdef OPENSSL_NO_EC +#error EC is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#elif defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + + +#ifndef OPENSSL_ECC_MAX_FIELD_BITS +# define OPENSSL_ECC_MAX_FIELD_BITS 661 +#endif + +typedef enum { + /* values as defined in X9.62 (ECDSA) and elsewhere */ + POINT_CONVERSION_COMPRESSED = 2, + POINT_CONVERSION_UNCOMPRESSED = 4, + POINT_CONVERSION_HYBRID = 6 +} point_conversion_form_t; + + +typedef struct ec_method_st EC_METHOD; + +typedef struct ec_group_st + /* + EC_METHOD *meth; + -- field definition + -- curve coefficients + -- optional generator with associated information (order, cofactor) + -- optional extra data (precomputed table for fast computation of multiples of generator) + -- ASN1 stuff + */ + EC_GROUP; + +typedef struct ec_point_st EC_POINT; + + +/* EC_METHODs for curves over GF(p). + * EC_GFp_simple_method provides the basis for the optimized methods. + */ +const EC_METHOD *EC_GFp_simple_method(void); +const EC_METHOD *EC_GFp_mont_method(void); +const EC_METHOD *EC_GFp_nist_method(void); + +/* EC_METHOD for curves over GF(2^m). + */ +const EC_METHOD *EC_GF2m_simple_method(void); + + +EC_GROUP *EC_GROUP_new(const EC_METHOD *); +void EC_GROUP_free(EC_GROUP *); +void EC_GROUP_clear_free(EC_GROUP *); +int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); +EC_GROUP *EC_GROUP_dup(const EC_GROUP *); + +const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); +int EC_METHOD_get_field_type(const EC_METHOD *); + +int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); +int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); +int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); + +void EC_GROUP_set_curve_name(EC_GROUP *, int nid); +int EC_GROUP_get_curve_name(const EC_GROUP *); + +void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); +int EC_GROUP_get_asn1_flag(const EC_GROUP *); + +void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); +size_t EC_GROUP_get_seed_len(const EC_GROUP *); +size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); + +int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); +int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); + +/* returns the number of bits needed to represent a field element */ +int EC_GROUP_get_degree(const EC_GROUP *); + +/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); +/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the + * elliptic curve is not zero, 0 otherwise */ +int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ +int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() + * after choosing an appropriate EC_METHOD */ +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + +/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure + * specified by a curve name (in form of a NID) */ +EC_GROUP *EC_GROUP_new_by_curve_name(int nid); +/* handling of internal curves */ +typedef struct { + int nid; + const char *comment; + } EC_builtin_curve; +/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number + * of all available curves or zero if a error occurred. + * In case r ist not zero nitems EC_builtin_curve structures + * are filled with the data of the first nitems internal groups */ +size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); + + +/* EC_POINT functions */ + +EC_POINT *EC_POINT_new(const EC_GROUP *); +void EC_POINT_free(EC_POINT *); +void EC_POINT_clear_free(EC_POINT *); +int EC_POINT_copy(EC_POINT *, const EC_POINT *); +EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); + +const EC_METHOD *EC_POINT_method_of(const EC_POINT *); + +int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); +int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); +int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); + +/* other interfaces to point2oct/oct2point: */ +BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BIGNUM *, BN_CTX *); +EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, + EC_POINT *, BN_CTX *); +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, + EC_POINT *, BN_CTX *); + +int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); +int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); + +int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + +int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); + + +int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); +int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); + +/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ +int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); +/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ +int EC_GROUP_have_precompute_mult(const EC_GROUP *); + + + +/* ASN1 stuff */ + +/* EC_GROUP_get_basis_type() returns the NID of the basis type + * used to represent the field elements */ +int EC_GROUP_get_basis_type(const EC_GROUP *); +int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); + +#define OPENSSL_EC_NAMED_CURVE 0x001 + +typedef struct ecpk_parameters_st ECPKPARAMETERS; + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); +int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); + +#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) +#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) +#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ + (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) +#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ + (unsigned char *)(x)) + +#ifndef OPENSSL_NO_BIO +int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); +#endif + +/* the EC_KEY stuff */ +typedef struct ec_key_st EC_KEY; + +/* some values for the encoding_flag */ +#define EC_PKEY_NO_PARAMETERS 0x001 +#define EC_PKEY_NO_PUBKEY 0x002 + +EC_KEY *EC_KEY_new(void); +EC_KEY *EC_KEY_new_by_curve_name(int nid); +void EC_KEY_free(EC_KEY *); +EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); +EC_KEY *EC_KEY_dup(const EC_KEY *); + +int EC_KEY_up_ref(EC_KEY *); + +const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); +int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); +const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); +int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); +const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); +int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); +unsigned EC_KEY_get_enc_flags(const EC_KEY *); +void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); +void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); +/* functions to set/get method specific data */ +void *EC_KEY_get_key_method_data(EC_KEY *, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_KEY_insert_key_method_data(EC_KEY *, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +/* wrapper functions for the underlying EC_GROUP object */ +void EC_KEY_set_asn1_flag(EC_KEY *, int); +int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); + +/* EC_KEY_generate_key() creates a ec private (public) key */ +int EC_KEY_generate_key(EC_KEY *); +/* EC_KEY_check_key() */ +int EC_KEY_check_key(const EC_KEY *); + +/* de- and encoding functions for SEC1 ECPrivateKey */ +EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC parameters */ +EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECParameters(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC public key + * (octet string, not DER -- hence 'o2i' and 'i2o') */ +EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); +int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); + +#ifndef OPENSSL_NO_BIO +int ECParameters_print(BIO *bp, const EC_KEY *x); +int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECParameters_print_fp(FILE *fp, const EC_KEY *x); +int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); +#endif + +#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) + +#ifndef __cplusplus +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +# endif +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EC_strings(void); + +/* Error codes for the EC functions. */ + +/* Function codes. */ +#define EC_F_COMPUTE_WNAF 143 +#define EC_F_D2I_ECPARAMETERS 144 +#define EC_F_D2I_ECPKPARAMETERS 145 +#define EC_F_D2I_ECPRIVATEKEY 146 +#define EC_F_ECPARAMETERS_PRINT 147 +#define EC_F_ECPARAMETERS_PRINT_FP 148 +#define EC_F_ECPKPARAMETERS_PRINT 149 +#define EC_F_ECPKPARAMETERS_PRINT_FP 150 +#define EC_F_ECP_NIST_MOD_192 203 +#define EC_F_ECP_NIST_MOD_224 204 +#define EC_F_ECP_NIST_MOD_256 205 +#define EC_F_ECP_NIST_MOD_521 206 +#define EC_F_EC_ASN1_GROUP2CURVE 153 +#define EC_F_EC_ASN1_GROUP2FIELDID 154 +#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 +#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 +#define EC_F_EC_ASN1_PARAMETERS2GROUP 157 +#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 +#define EC_F_EC_EX_DATA_SET_DATA 211 +#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 +#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 +#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 +#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 +#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 +#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 +#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 +#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 +#define EC_F_EC_GFP_MONT_FIELD_DECODE 133 +#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 +#define EC_F_EC_GFP_MONT_FIELD_MUL 131 +#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 +#define EC_F_EC_GFP_MONT_FIELD_SQR 132 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 +#define EC_F_EC_GFP_NIST_FIELD_MUL 200 +#define EC_F_EC_GFP_NIST_FIELD_SQR 201 +#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 +#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 +#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 +#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 +#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 +#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 +#define EC_F_EC_GROUP_CHECK 170 +#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 +#define EC_F_EC_GROUP_COPY 106 +#define EC_F_EC_GROUP_GET0_GENERATOR 139 +#define EC_F_EC_GROUP_GET_COFACTOR 140 +#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 +#define EC_F_EC_GROUP_GET_CURVE_GFP 130 +#define EC_F_EC_GROUP_GET_DEGREE 173 +#define EC_F_EC_GROUP_GET_ORDER 141 +#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 +#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 +#define EC_F_EC_GROUP_NEW 108 +#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 +#define EC_F_EC_GROUP_NEW_FROM_DATA 175 +#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 +#define EC_F_EC_GROUP_SET_CURVE_GF2M 176 +#define EC_F_EC_GROUP_SET_CURVE_GFP 109 +#define EC_F_EC_GROUP_SET_EXTRA_DATA 110 +#define EC_F_EC_GROUP_SET_GENERATOR 111 +#define EC_F_EC_KEY_CHECK_KEY 177 +#define EC_F_EC_KEY_COPY 178 +#define EC_F_EC_KEY_GENERATE_KEY 179 +#define EC_F_EC_KEY_NEW 182 +#define EC_F_EC_KEY_PRINT 180 +#define EC_F_EC_KEY_PRINT_FP 181 +#define EC_F_EC_POINTS_MAKE_AFFINE 136 +#define EC_F_EC_POINTS_MUL 138 +#define EC_F_EC_POINT_ADD 112 +#define EC_F_EC_POINT_CMP 113 +#define EC_F_EC_POINT_COPY 114 +#define EC_F_EC_POINT_DBL 115 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 +#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 +#define EC_F_EC_POINT_INVERT 210 +#define EC_F_EC_POINT_IS_AT_INFINITY 118 +#define EC_F_EC_POINT_IS_ON_CURVE 119 +#define EC_F_EC_POINT_MAKE_AFFINE 120 +#define EC_F_EC_POINT_MUL 184 +#define EC_F_EC_POINT_NEW 121 +#define EC_F_EC_POINT_OCT2POINT 122 +#define EC_F_EC_POINT_POINT2OCT 123 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 +#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 +#define EC_F_EC_POINT_SET_TO_INFINITY 127 +#define EC_F_EC_PRE_COMP_DUP 207 +#define EC_F_EC_WNAF_MUL 187 +#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 +#define EC_F_I2D_ECPARAMETERS 190 +#define EC_F_I2D_ECPKPARAMETERS 191 +#define EC_F_I2D_ECPRIVATEKEY 192 +#define EC_F_I2O_ECPUBLICKEY 151 +#define EC_F_O2I_ECPUBLICKEY 152 + +/* Reason codes. */ +#define EC_R_ASN1_ERROR 115 +#define EC_R_ASN1_UNKNOWN_FIELD 116 +#define EC_R_BUFFER_TOO_SMALL 100 +#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 +#define EC_R_DISCRIMINANT_IS_ZERO 118 +#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +#define EC_R_FIELD_TOO_LARGE 138 +#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +#define EC_R_INCOMPATIBLE_OBJECTS 101 +#define EC_R_INVALID_ARGUMENT 112 +#define EC_R_INVALID_COMPRESSED_POINT 110 +#define EC_R_INVALID_COMPRESSION_BIT 109 +#define EC_R_INVALID_ENCODING 102 +#define EC_R_INVALID_FIELD 103 +#define EC_R_INVALID_FORM 104 +#define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_PENTANOMIAL_BASIS 132 +#define EC_R_INVALID_PRIVATE_KEY 123 +#define EC_R_INVALID_TRINOMIAL_BASIS 137 +#define EC_R_MISSING_PARAMETERS 124 +#define EC_R_MISSING_PRIVATE_KEY 125 +#define EC_R_NOT_A_NIST_PRIME 135 +#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 +#define EC_R_NOT_IMPLEMENTED 126 +#define EC_R_NOT_INITIALIZED 111 +#define EC_R_NO_FIELD_MOD 133 +#define EC_R_PASSED_NULL_PARAMETER 134 +#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 +#define EC_R_POINT_AT_INFINITY 106 +#define EC_R_POINT_IS_NOT_ON_CURVE 107 +#define EC_R_SLOT_FULL 108 +#define EC_R_UNDEFINED_GENERATOR 113 +#define EC_R_UNDEFINED_ORDER 128 +#define EC_R_UNKNOWN_GROUP 129 +#define EC_R_UNKNOWN_ORDER 114 +#define EC_R_UNSUPPORTED_FIELD 131 +#define EC_R_WRONG_ORDER 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/ecdh.h b/include/openssl/ecdh.h new file mode 100755 index 0000000..c2c00b8 --- /dev/null +++ b/include/openssl/ecdh.h @@ -0,0 +1,123 @@ +/* crypto/ecdh/ecdh.h */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDH_H +#define HEADER_ECDH_H + +#include + +#ifdef OPENSSL_NO_ECDH +#error ECDH is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +const ECDH_METHOD *ECDH_OpenSSL(void); + +void ECDH_set_default_method(const ECDH_METHOD *); +const ECDH_METHOD *ECDH_get_default_method(void); +int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); + +int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); + +int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDH_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDH_strings(void); + +/* Error codes for the ECDH functions. */ + +/* Function codes. */ +#define ECDH_F_ECDH_COMPUTE_KEY 100 +#define ECDH_F_ECDH_DATA_NEW_METHOD 101 + +/* Reason codes. */ +#define ECDH_R_KDF_FAILED 102 +#define ECDH_R_NO_PRIVATE_VALUE 100 +#define ECDH_R_POINT_ARITHMETIC_FAILURE 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/ecdsa.h b/include/openssl/ecdsa.h new file mode 100755 index 0000000..294e2ba --- /dev/null +++ b/include/openssl/ecdsa.h @@ -0,0 +1,271 @@ +/* crypto/ecdsa/ecdsa.h */ +/** + * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions + * \author Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDSA_H +#define HEADER_ECDSA_H + +#include + +#ifdef OPENSSL_NO_ECDSA +#error ECDSA is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ECDSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } ECDSA_SIG; + +/** ECDSA_SIG *ECDSA_SIG_new(void) + * allocates and initialize a ECDSA_SIG structure + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_SIG_new(void); + +/** ECDSA_SIG_free + * frees a ECDSA_SIG structure + * \param a pointer to the ECDSA_SIG structure + */ +void ECDSA_SIG_free(ECDSA_SIG *a); + +/** i2d_ECDSA_SIG + * DER encode content of ECDSA_SIG object (note: this function modifies *pp + * (*pp += length of the DER encoded signature)). + * \param a pointer to the ECDSA_SIG object + * \param pp pointer to a unsigned char pointer for the output or NULL + * \return the length of the DER encoded ECDSA_SIG object or 0 + */ +int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp); + +/** d2i_ECDSA_SIG + * decodes a DER encoded ECDSA signature (note: this function changes *pp + * (*pp += len)). + * \param v pointer to ECDSA_SIG pointer (may be NULL) + * \param pp buffer with the DER encoded signature + * \param len bufferlength + * \return pointer to the decoded ECDSA_SIG structure (or NULL) + */ +ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len); + +/** ECDSA_do_sign + * computes the ECDSA signature of the given hash value using + * the supplied private key and returns the created signature. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); + +/** ECDSA_do_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, + const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_do_verify + * verifies that the supplied signature is a valid ECDSA + * signature of the supplied hash value using the supplied public key. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param sig pointer to the ECDSA_SIG structure + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY* eckey); + +const ECDSA_METHOD *ECDSA_OpenSSL(void); + +/** ECDSA_set_default_method + * sets the default ECDSA method + * \param meth the new default ECDSA_METHOD + */ +void ECDSA_set_default_method(const ECDSA_METHOD *meth); + +/** ECDSA_get_default_method + * returns the default ECDSA method + * \return pointer to ECDSA_METHOD structure containing the default method + */ +const ECDSA_METHOD *ECDSA_get_default_method(void); + +/** ECDSA_set_method + * sets method to be used for the ECDSA operations + * \param eckey pointer to the EC_KEY object + * \param meth pointer to the new method + * \return 1 on success and 0 otherwise + */ +int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); + +/** ECDSA_size + * returns the maximum length of the DER encoded signature + * \param eckey pointer to a EC_KEY object + * \return numbers of bytes required for the DER encoded signature + */ +int ECDSA_size(const EC_KEY *eckey); + +/** ECDSA_sign_setup + * precompute parts of the signing operation. + * \param eckey pointer to the EC_KEY object containing a private EC key + * \param ctx pointer to a BN_CTX object (may be NULL) + * \param kinv pointer to a BIGNUM pointer for the inverse of k + * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, + BIGNUM **rp); + +/** ECDSA_sign + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); + + +/** ECDSA_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_verify + * verifies that the given signature is valid ECDSA signature + * of the supplied hash value using the specified public key. + * \param type this parameter is ignored + * \param dgst pointer to the hash value + * \param dgstlen length of the hash value + * \param sig pointer to the DER encoded signature + * \param siglen length of the DER encoded signature + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int siglen, EC_KEY *eckey); + +/* the standard ex_data functions */ +int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDSA_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDSA_strings(void); + +/* Error codes for the ECDSA functions. */ + +/* Function codes. */ +#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 +#define ECDSA_F_ECDSA_DO_SIGN 101 +#define ECDSA_F_ECDSA_DO_VERIFY 102 +#define ECDSA_F_ECDSA_SIGN_SETUP 103 + +/* Reason codes. */ +#define ECDSA_R_BAD_SIGNATURE 100 +#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101 +#define ECDSA_R_ERR_EC_LIB 102 +#define ECDSA_R_MISSING_PARAMETERS 103 +#define ECDSA_R_NEED_NEW_SETUP_VALUES 106 +#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 +#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/engine.h b/include/openssl/engine.h new file mode 100755 index 0000000..4fd0f09 --- /dev/null +++ b/include/openssl/engine.h @@ -0,0 +1,785 @@ +/* openssl/engine.h */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_ENGINE_H +#define HEADER_ENGINE_H + +#include + +#ifdef OPENSSL_NO_ENGINE +#error ENGINE is disabled. +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#ifndef OPENSSL_NO_ECDH +#include +#endif +#ifndef OPENSSL_NO_ECDSA +#include +#endif +#include +#include +#include +#include +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These flags are used to control combinations of algorithm (methods) + * by bitwise "OR"ing. */ +#define ENGINE_METHOD_RSA (unsigned int)0x0001 +#define ENGINE_METHOD_DSA (unsigned int)0x0002 +#define ENGINE_METHOD_DH (unsigned int)0x0004 +#define ENGINE_METHOD_RAND (unsigned int)0x0008 +#define ENGINE_METHOD_ECDH (unsigned int)0x0010 +#define ENGINE_METHOD_ECDSA (unsigned int)0x0020 +#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 +#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 +#define ENGINE_METHOD_STORE (unsigned int)0x0100 +/* Obvious all-or-nothing cases. */ +#define ENGINE_METHOD_ALL (unsigned int)0xFFFF +#define ENGINE_METHOD_NONE (unsigned int)0x0000 + +/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used + * internally to control registration of ENGINE implementations, and can be set + * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to + * initialise registered ENGINEs if they are not already initialised. */ +#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 + +/* ENGINE flags that can be set by ENGINE_set_flags(). */ +/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */ + +/* This flag is for ENGINEs that wish to handle the various 'CMD'-related + * control commands on their own. Without this flag, ENGINE_ctrl() handles these + * control commands on behalf of the ENGINE using their "cmd_defns" data. */ +#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 + +/* This flag is for ENGINEs who return new duplicate structures when found via + * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl() + * commands are called in sequence as part of some stateful process like + * key-generation setup and execution), it can set this flag - then each attempt + * to obtain the ENGINE will result in it being copied into a new structure. + * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments + * the existing ENGINE's structural reference count. */ +#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 + +/* ENGINEs can support their own command types, and these flags are used in + * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each + * command expects. Currently only numeric and string input is supported. If a + * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options, + * then it is regarded as an "internal" control command - and not for use in + * config setting situations. As such, they're not available to the + * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to + * this list of 'command types' should be reflected carefully in + * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */ + +/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 +/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to + * ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 +/* Indicates that the control command takes *no* input. Ie. the control command + * is unparameterised. */ +#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 +/* Indicates that the control command is internal. This control command won't + * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() + * function. */ +#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 + +/* NB: These 3 control commands are deprecated and should not be used. ENGINEs + * relying on these commands should compile conditional support for + * compatibility (eg. if these symbols are defined) but should also migrate the + * same functionality to their own ENGINE-specific control functions that can be + * "discovered" by calling applications. The fact these control commands + * wouldn't be "executable" (ie. usable by text-based config) doesn't change the + * fact that application code can find and use them without requiring per-ENGINE + * hacking. */ + +/* These flags are used to tell the ctrl function what should be done. + * All command numbers are shared between all engines, even if some don't + * make sense to some engines. In such a case, they do nothing but return + * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ +#define ENGINE_CTRL_SET_LOGSTREAM 1 +#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 +#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any + handles/connections etc. */ +#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ +#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used + when calling the password + callback and the user + interface */ +#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given + a string that represents a + file name or so */ +#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given + section in the already loaded + configuration */ + +/* These control commands allow an application to deal with an arbitrary engine + * in a dynamic way. Warn: Negative return values indicate errors FOR THESE + * COMMANDS because zero is used to indicate 'end-of-list'. Other commands, + * including ENGINE-specific command types, return zero for an error. + * + * An ENGINE can choose to implement these ctrl functions, and can internally + * manage things however it chooses - it does so by setting the + * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the + * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns + * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl() + * handler need only implement its own commands - the above "meta" commands will + * be taken care of. */ + +/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then + * all the remaining control commands will return failure, so it is worth + * checking this first if the caller is trying to "discover" the engine's + * capabilities and doesn't want errors generated unnecessarily. */ +#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 +/* Returns a positive command number for the first command supported by the + * engine. Returns zero if no ctrl commands are supported. */ +#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 +/* The 'long' argument specifies a command implemented by the engine, and the + * return value is the next command supported, or zero if there are no more. */ +#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 +/* The 'void*' argument is a command name (cast from 'const char *'), and the + * return value is the command that corresponds to it. */ +#define ENGINE_CTRL_GET_CMD_FROM_NAME 13 +/* The next two allow a command to be converted into its corresponding string + * form. In each case, the 'long' argument supplies the command. In the NAME_LEN + * case, the return value is the length of the command name (not counting a + * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer + * large enough, and it will be populated with the name of the command (WITH a + * trailing EOL). */ +#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 +#define ENGINE_CTRL_GET_NAME_FROM_CMD 15 +/* The next two are similar but give a "short description" of a command. */ +#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 +#define ENGINE_CTRL_GET_DESC_FROM_CMD 17 +/* With this command, the return value is the OR'd combination of + * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given + * engine-specific ctrl command expects. */ +#define ENGINE_CTRL_GET_CMD_FLAGS 18 + +/* ENGINE implementations should start the numbering of their own control + * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ +#define ENGINE_CMD_BASE 200 + +/* NB: These 2 nCipher "chil" control commands are deprecated, and their + * functionality is now available through ENGINE-specific control commands + * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 + * commands should be migrated to the more general command handling before these + * are removed. */ + +/* Flags specific to the nCipher "chil" engine */ +#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 + /* Depending on the value of the (long)i argument, this sets or + * unsets the SimpleForkCheck flag in the CHIL API to enable or + * disable checking and workarounds for applications that fork(). + */ +#define ENGINE_CTRL_CHIL_NO_LOCKING 101 + /* This prevents the initialisation function from providing mutex + * callbacks to the nCipher library. */ + +/* If an ENGINE supports its own specific control commands and wishes the + * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its + * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries + * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that + * supports the stated commands (ie. the "cmd_num" entries as described by the + * array). NB: The array must be ordered in increasing order of cmd_num. + * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set + * to zero and/or cmd_name set to NULL. */ +typedef struct ENGINE_CMD_DEFN_st + { + unsigned int cmd_num; /* The command number */ + const char *cmd_name; /* The command name itself */ + const char *cmd_desc; /* A short description of the command */ + unsigned int cmd_flags; /* The input the command expects */ + } ENGINE_CMD_DEFN; + +/* Generic function pointer */ +typedef int (*ENGINE_GEN_FUNC_PTR)(void); +/* Generic function pointer taking no arguments */ +typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); +/* Generic load_key function pointer */ +typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, + UI_METHOD *ui_method, void *callback_data); +/* These callback types are for an ENGINE's handler for cipher and digest logic. + * These handlers have these prototypes; + * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); + * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); + * Looking at how to implement these handlers in the case of cipher support, if + * the framework wants the EVP_CIPHER for 'nid', it will call; + * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) + * If the framework wants a list of supported 'nid's, it will call; + * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) + */ +/* Returns to a pointer to the array of supported cipher 'nid's. If the second + * parameter is non-NULL it is set to the size of the returned array. */ +typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); +typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); + +/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE + * structures where the pointers have a "structural reference". This means that + * their reference is to allowed access to the structure but it does not imply + * that the structure is functional. To simply increment or decrement the + * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not + * required when iterating using ENGINE_get_next as it will automatically + * decrement the structural reference count of the "current" ENGINE and + * increment the structural reference count of the ENGINE it returns (unless it + * is NULL). */ + +/* Get the first/last "ENGINE" type available. */ +ENGINE *ENGINE_get_first(void); +ENGINE *ENGINE_get_last(void); +/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ +ENGINE *ENGINE_get_next(ENGINE *e); +ENGINE *ENGINE_get_prev(ENGINE *e); +/* Add another "ENGINE" type into the array. */ +int ENGINE_add(ENGINE *e); +/* Remove an existing "ENGINE" type from the array. */ +int ENGINE_remove(ENGINE *e); +/* Retrieve an engine from the list by its unique "id" value. */ +ENGINE *ENGINE_by_id(const char *id); +/* Add all the built-in engines. */ +void ENGINE_load_openssl(void); +void ENGINE_load_dynamic(void); +#ifndef OPENSSL_NO_STATIC_ENGINE +void ENGINE_load_4758cca(void); +void ENGINE_load_aep(void); +void ENGINE_load_atalla(void); +void ENGINE_load_chil(void); +void ENGINE_load_cswift(void); +#ifndef OPENSSL_NO_GMP +void ENGINE_load_gmp(void); +#endif +void ENGINE_load_nuron(void); +void ENGINE_load_sureware(void); +void ENGINE_load_ubsec(void); +#endif +void ENGINE_load_cryptodev(void); +void ENGINE_load_padlock(void); +void ENGINE_load_builtin_engines(void); + +/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation + * "registry" handling. */ +unsigned int ENGINE_get_table_flags(void); +void ENGINE_set_table_flags(unsigned int flags); + +/* Manage registration of ENGINEs per "table". For each type, there are 3 + * functions; + * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) + * ENGINE_unregister_***(e) - unregister the implementation from 'e' + * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list + * Cleanup is automatically registered from each table when required, so + * ENGINE_cleanup() will reverse any "register" operations. */ + +int ENGINE_register_RSA(ENGINE *e); +void ENGINE_unregister_RSA(ENGINE *e); +void ENGINE_register_all_RSA(void); + +int ENGINE_register_DSA(ENGINE *e); +void ENGINE_unregister_DSA(ENGINE *e); +void ENGINE_register_all_DSA(void); + +int ENGINE_register_ECDH(ENGINE *e); +void ENGINE_unregister_ECDH(ENGINE *e); +void ENGINE_register_all_ECDH(void); + +int ENGINE_register_ECDSA(ENGINE *e); +void ENGINE_unregister_ECDSA(ENGINE *e); +void ENGINE_register_all_ECDSA(void); + +int ENGINE_register_DH(ENGINE *e); +void ENGINE_unregister_DH(ENGINE *e); +void ENGINE_register_all_DH(void); + +int ENGINE_register_RAND(ENGINE *e); +void ENGINE_unregister_RAND(ENGINE *e); +void ENGINE_register_all_RAND(void); + +int ENGINE_register_STORE(ENGINE *e); +void ENGINE_unregister_STORE(ENGINE *e); +void ENGINE_register_all_STORE(void); + +int ENGINE_register_ciphers(ENGINE *e); +void ENGINE_unregister_ciphers(ENGINE *e); +void ENGINE_register_all_ciphers(void); + +int ENGINE_register_digests(ENGINE *e); +void ENGINE_unregister_digests(ENGINE *e); +void ENGINE_register_all_digests(void); + +/* These functions register all support from the above categories. Note, use of + * these functions can result in static linkage of code your application may not + * need. If you only need a subset of functionality, consider using more + * selective initialisation. */ +int ENGINE_register_complete(ENGINE *e); +int ENGINE_register_all_complete(void); + +/* Send parametrised control commands to the engine. The possibilities to send + * down an integer, a pointer to data or a function pointer are provided. Any of + * the parameters may or may not be NULL, depending on the command number. In + * actuality, this function only requires a structural (rather than functional) + * reference to an engine, but many control commands may require the engine be + * functional. The caller should be aware of trying commands that require an + * operational ENGINE, and only use functional references in such situations. */ +int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); + +/* This function tests if an ENGINE-specific command is usable as a "setting". + * Eg. in an application's config file that gets processed through + * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to + * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */ +int ENGINE_cmd_is_executable(ENGINE *e, int cmd); + +/* This function works like ENGINE_ctrl() with the exception of taking a + * command name instead of a command number, and can handle optional commands. + * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to + * use the cmd_name and cmd_optional. */ +int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, + long i, void *p, void (*f)(void), int cmd_optional); + +/* This function passes a command-name and argument to an ENGINE. The cmd_name + * is converted to a command number and the control command is called using + * 'arg' as an argument (unless the ENGINE doesn't support such a command, in + * which case no control command is called). The command is checked for input + * flags, and if necessary the argument will be converted to a numeric value. If + * cmd_optional is non-zero, then if the ENGINE doesn't support the given + * cmd_name the return value will be success anyway. This function is intended + * for applications to use so that users (or config files) can supply + * engine-specific config data to the ENGINE at run-time to control behaviour of + * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl() + * functions that return data, deal with binary data, or that are otherwise + * supposed to be used directly through ENGINE_ctrl() in application code. Any + * "return" data from an ENGINE_ctrl() operation in this function will be lost - + * the return value is interpreted as failure if the return value is zero, + * success otherwise, and this function returns a boolean value as a result. In + * other words, vendors of 'ENGINE'-enabled devices should write ENGINE + * implementations with parameterisations that work in this scheme, so that + * compliant ENGINE-based applications can work consistently with the same + * configuration for the same ENGINE-enabled devices, across applications. */ +int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, + int cmd_optional); + +/* These functions are useful for manufacturing new ENGINE structures. They + * don't address reference counting at all - one uses them to populate an ENGINE + * structure with personalised implementations of things prior to using it + * directly or adding it to the builtin ENGINE list in OpenSSL. These are also + * here so that the ENGINE structure doesn't have to be exposed and break binary + * compatibility! */ +ENGINE *ENGINE_new(void); +int ENGINE_free(ENGINE *e); +int ENGINE_up_ref(ENGINE *e); +int ENGINE_set_id(ENGINE *e, const char *id); +int ENGINE_set_name(ENGINE *e, const char *name); +int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); +int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); +int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); +int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); +int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); +int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); +int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); +int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); +int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); +int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); +int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); +int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); +int ENGINE_set_flags(ENGINE *e, int flags); +int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); +/* These functions allow control over any per-structure ENGINE data. */ +int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); +void *ENGINE_get_ex_data(const ENGINE *e, int idx); + +/* This function cleans up anything that needs it. Eg. the ENGINE_add() function + * automatically ensures the list cleanup function is registered to be called + * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure + * ENGINE_cleanup() will clean up after them. */ +void ENGINE_cleanup(void); + +/* These return values from within the ENGINE structure. These can be useful + * with functional references as well as structural references - it depends + * which you obtained. Using the result for functional purposes if you only + * obtained a structural reference may be problematic! */ +const char *ENGINE_get_id(const ENGINE *e); +const char *ENGINE_get_name(const ENGINE *e); +const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); +const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); +const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); +const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); +const DH_METHOD *ENGINE_get_DH(const ENGINE *e); +const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); +const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); +ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); +ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); +const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); +const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); +const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); +int ENGINE_get_flags(const ENGINE *e); + +/* FUNCTIONAL functions. These functions deal with ENGINE structures + * that have (or will) be initialised for use. Broadly speaking, the + * structural functions are useful for iterating the list of available + * engine types, creating new engine types, and other "list" operations. + * These functions actually deal with ENGINEs that are to be used. As + * such these functions can fail (if applicable) when particular + * engines are unavailable - eg. if a hardware accelerator is not + * attached or not functioning correctly. Each ENGINE has 2 reference + * counts; structural and functional. Every time a functional reference + * is obtained or released, a corresponding structural reference is + * automatically obtained or released too. */ + +/* Initialise a engine type for use (or up its reference count if it's + * already in use). This will fail if the engine is not currently + * operational and cannot initialise. */ +int ENGINE_init(ENGINE *e); +/* Free a functional reference to a engine type. This does not require + * a corresponding call to ENGINE_free as it also releases a structural + * reference. */ +int ENGINE_finish(ENGINE *e); + +/* The following functions handle keys that are stored in some secondary + * location, handled by the engine. The storage may be on a card or + * whatever. */ +EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); + +/* This returns a pointer for the current ENGINE structure that + * is (by default) performing any RSA operations. The value returned + * is an incremented reference, so it should be free'd (ENGINE_finish) + * before it is discarded. */ +ENGINE *ENGINE_get_default_RSA(void); +/* Same for the other "methods" */ +ENGINE *ENGINE_get_default_DSA(void); +ENGINE *ENGINE_get_default_ECDH(void); +ENGINE *ENGINE_get_default_ECDSA(void); +ENGINE *ENGINE_get_default_DH(void); +ENGINE *ENGINE_get_default_RAND(void); +/* These functions can be used to get a functional reference to perform + * ciphering or digesting corresponding to "nid". */ +ENGINE *ENGINE_get_cipher_engine(int nid); +ENGINE *ENGINE_get_digest_engine(int nid); + +/* This sets a new default ENGINE structure for performing RSA + * operations. If the result is non-zero (success) then the ENGINE + * structure will have had its reference count up'd so the caller + * should still free their own reference 'e'. */ +int ENGINE_set_default_RSA(ENGINE *e); +int ENGINE_set_default_string(ENGINE *e, const char *def_list); +/* Same for the other "methods" */ +int ENGINE_set_default_DSA(ENGINE *e); +int ENGINE_set_default_ECDH(ENGINE *e); +int ENGINE_set_default_ECDSA(ENGINE *e); +int ENGINE_set_default_DH(ENGINE *e); +int ENGINE_set_default_RAND(ENGINE *e); +int ENGINE_set_default_ciphers(ENGINE *e); +int ENGINE_set_default_digests(ENGINE *e); + +/* The combination "set" - the flags are bitwise "OR"d from the + * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" + * function, this function can result in unnecessary static linkage. If your + * application requires only specific functionality, consider using more + * selective functions. */ +int ENGINE_set_default(ENGINE *e, unsigned int flags); + +void ENGINE_add_conf_module(void); + +/* Deprecated functions ... */ +/* int ENGINE_clear_defaults(void); */ + +/**************************/ +/* DYNAMIC ENGINE SUPPORT */ +/**************************/ + +/* Binary/behaviour compatibility levels */ +#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000 +/* Binary versions older than this are too old for us (whether we're a loader or + * a loadee) */ +#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000 + +/* When compiling an ENGINE entirely as an external shared library, loadable by + * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure + * type provides the calling application's (or library's) error functionality + * and memory management function pointers to the loaded library. These should + * be used/set in the loaded library code so that the loading application's + * 'state' will be used/changed in all operations. The 'static_state' pointer + * allows the loaded library to know if it shares the same static data as the + * calling application (or library), and thus whether these callbacks need to be + * set or not. */ +typedef void *(*dyn_MEM_malloc_cb)(size_t); +typedef void *(*dyn_MEM_realloc_cb)(void *, size_t); +typedef void (*dyn_MEM_free_cb)(void *); +typedef struct st_dynamic_MEM_fns { + dyn_MEM_malloc_cb malloc_cb; + dyn_MEM_realloc_cb realloc_cb; + dyn_MEM_free_cb free_cb; + } dynamic_MEM_fns; +/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use + * these types so we (and any other dependant code) can simplify a bit?? */ +typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); +typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); +typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( + const char *,int); +typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, + const char *,int); +typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, + const char *,int); +typedef struct st_dynamic_LOCK_fns { + dyn_lock_locking_cb lock_locking_cb; + dyn_lock_add_lock_cb lock_add_lock_cb; + dyn_dynlock_create_cb dynlock_create_cb; + dyn_dynlock_lock_cb dynlock_lock_cb; + dyn_dynlock_destroy_cb dynlock_destroy_cb; + } dynamic_LOCK_fns; +/* The top-level structure */ +typedef struct st_dynamic_fns { + void *static_state; + const ERR_FNS *err_fns; + const CRYPTO_EX_DATA_IMPL *ex_data_fns; + dynamic_MEM_fns mem_fns; + dynamic_LOCK_fns lock_fns; + } dynamic_fns; + +/* The version checking function should be of this prototype. NB: The + * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. + * If this function returns zero, it indicates a (potential) version + * incompatibility and the loaded library doesn't believe it can proceed. + * Otherwise, the returned value is the (latest) version supported by the + * loading library. The loader may still decide that the loaded code's version + * is unsatisfactory and could veto the load. The function is expected to + * be implemented with the symbol name "v_check", and a default implementation + * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ +typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); +#define IMPLEMENT_DYNAMIC_CHECK_FN() \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ + if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ + return 0; } + +/* This function is passed the ENGINE structure to initialise with its own + * function and command settings. It should not adjust the structural or + * functional reference counts. If this function returns zero, (a) the load will + * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the + * structure, and (c) the shared library will be unloaded. So implementations + * should do their own internal cleanup in failure circumstances otherwise they + * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that + * the loader is looking for. If this is NULL, the shared library can choose to + * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared + * library must initialise only an ENGINE matching the passed 'id'. The function + * is expected to be implemented with the symbol name "bind_engine". A standard + * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where + * the parameter 'fn' is a callback function that populates the ENGINE structure + * and returns an int value (zero for failure). 'fn' should have prototype; + * [static] int fn(ENGINE *e, const char *id); */ +typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, + const dynamic_fns *fns); +#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ + if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ + if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ + fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \ + return 0; \ + CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \ + CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \ + CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \ + CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \ + CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \ + if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \ + return 0; \ + if(!ERR_set_implementation(fns->err_fns)) return 0; \ + skip_cbs: \ + if(!fn(e,id)) return 0; \ + return 1; } + +/* If the loading application (or library) and the loaded ENGINE library share + * the same static data (eg. they're both dynamically linked to the same + * libcrypto.so) we need a way to avoid trying to set system callbacks - this + * would fail, and for the same reason that it's unnecessary to try. If the + * loaded ENGINE has (or gets from through the loader) its own copy of the + * libcrypto static data, we will need to set the callbacks. The easiest way to + * detect this is to have a function that returns a pointer to some static data + * and let the loading application and loaded ENGINE compare their respective + * values. */ +void *ENGINE_get_static_state(void); + +#if defined(__OpenBSD__) || defined(__FreeBSD__) +void ENGINE_setup_bsd_cryptodev(void); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ENGINE_strings(void); + +/* Error codes for the ENGINE functions. */ + +/* Function codes. */ +#define ENGINE_F_DYNAMIC_CTRL 180 +#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 +#define ENGINE_F_DYNAMIC_LOAD 182 +#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 +#define ENGINE_F_ENGINE_ADD 105 +#define ENGINE_F_ENGINE_BY_ID 106 +#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 +#define ENGINE_F_ENGINE_CTRL 142 +#define ENGINE_F_ENGINE_CTRL_CMD 178 +#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 +#define ENGINE_F_ENGINE_FINISH 107 +#define ENGINE_F_ENGINE_FREE_UTIL 108 +#define ENGINE_F_ENGINE_GET_CIPHER 185 +#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 +#define ENGINE_F_ENGINE_GET_DIGEST 186 +#define ENGINE_F_ENGINE_GET_NEXT 115 +#define ENGINE_F_ENGINE_GET_PREV 116 +#define ENGINE_F_ENGINE_INIT 119 +#define ENGINE_F_ENGINE_LIST_ADD 120 +#define ENGINE_F_ENGINE_LIST_REMOVE 121 +#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 +#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 +#define ENGINE_F_ENGINE_NEW 122 +#define ENGINE_F_ENGINE_REMOVE 123 +#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 +#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 +#define ENGINE_F_ENGINE_SET_ID 129 +#define ENGINE_F_ENGINE_SET_NAME 130 +#define ENGINE_F_ENGINE_TABLE_REGISTER 184 +#define ENGINE_F_ENGINE_UNLOAD_KEY 152 +#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 +#define ENGINE_F_ENGINE_UP_REF 190 +#define ENGINE_F_INT_CTRL_HELPER 172 +#define ENGINE_F_INT_ENGINE_CONFIGURE 188 +#define ENGINE_F_INT_ENGINE_MODULE_INIT 187 +#define ENGINE_F_LOG_MESSAGE 141 + +/* Reason codes. */ +#define ENGINE_R_ALREADY_LOADED 100 +#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 +#define ENGINE_R_CMD_NOT_EXECUTABLE 134 +#define ENGINE_R_COMMAND_TAKES_INPUT 135 +#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 +#define ENGINE_R_CONFLICTING_ENGINE_ID 103 +#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 +#define ENGINE_R_DH_NOT_IMPLEMENTED 139 +#define ENGINE_R_DSA_NOT_IMPLEMENTED 140 +#define ENGINE_R_DSO_FAILURE 104 +#define ENGINE_R_DSO_NOT_FOUND 132 +#define ENGINE_R_ENGINES_SECTION_ERROR 148 +#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 +#define ENGINE_R_ENGINE_SECTION_ERROR 149 +#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 +#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 +#define ENGINE_R_FINISH_FAILED 106 +#define ENGINE_R_GET_HANDLE_FAILED 107 +#define ENGINE_R_ID_OR_NAME_MISSING 108 +#define ENGINE_R_INIT_FAILED 109 +#define ENGINE_R_INTERNAL_LIST_ERROR 110 +#define ENGINE_R_INVALID_ARGUMENT 143 +#define ENGINE_R_INVALID_CMD_NAME 137 +#define ENGINE_R_INVALID_CMD_NUMBER 138 +#define ENGINE_R_INVALID_INIT_VALUE 151 +#define ENGINE_R_INVALID_STRING 150 +#define ENGINE_R_NOT_INITIALISED 117 +#define ENGINE_R_NOT_LOADED 112 +#define ENGINE_R_NO_CONTROL_FUNCTION 120 +#define ENGINE_R_NO_INDEX 144 +#define ENGINE_R_NO_LOAD_FUNCTION 125 +#define ENGINE_R_NO_REFERENCE 130 +#define ENGINE_R_NO_SUCH_ENGINE 116 +#define ENGINE_R_NO_UNLOAD_FUNCTION 126 +#define ENGINE_R_PROVIDE_PARAMETERS 113 +#define ENGINE_R_RSA_NOT_IMPLEMENTED 141 +#define ENGINE_R_UNIMPLEMENTED_CIPHER 146 +#define ENGINE_R_UNIMPLEMENTED_DIGEST 147 +#define ENGINE_R_VERSION_INCOMPATIBILITY 145 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/err.h b/include/openssl/err.h new file mode 100755 index 0000000..ed38141 --- /dev/null +++ b/include/openssl/err.h @@ -0,0 +1,318 @@ +/* crypto/err/err.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ERR_H +#define HEADER_ERR_H + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#include +#endif + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_LHASH +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef OPENSSL_NO_ERR +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) +#else +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) +#endif + +#include + +#define ERR_TXT_MALLOCED 0x01 +#define ERR_TXT_STRING 0x02 + +#define ERR_FLAG_MARK 0x01 + +#define ERR_NUM_ERRORS 16 +typedef struct err_state_st + { + unsigned long pid; + int err_flags[ERR_NUM_ERRORS]; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_data[ERR_NUM_ERRORS]; + int err_data_flags[ERR_NUM_ERRORS]; + const char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + int top,bottom; + } ERR_STATE; + +/* library */ +#define ERR_LIB_NONE 1 +#define ERR_LIB_SYS 2 +#define ERR_LIB_BN 3 +#define ERR_LIB_RSA 4 +#define ERR_LIB_DH 5 +#define ERR_LIB_EVP 6 +#define ERR_LIB_BUF 7 +#define ERR_LIB_OBJ 8 +#define ERR_LIB_PEM 9 +#define ERR_LIB_DSA 10 +#define ERR_LIB_X509 11 +/* #define ERR_LIB_METH 12 */ +#define ERR_LIB_ASN1 13 +#define ERR_LIB_CONF 14 +#define ERR_LIB_CRYPTO 15 +#define ERR_LIB_EC 16 +#define ERR_LIB_SSL 20 +/* #define ERR_LIB_SSL23 21 */ +/* #define ERR_LIB_SSL2 22 */ +/* #define ERR_LIB_SSL3 23 */ +/* #define ERR_LIB_RSAREF 30 */ +/* #define ERR_LIB_PROXY 31 */ +#define ERR_LIB_BIO 32 +#define ERR_LIB_PKCS7 33 +#define ERR_LIB_X509V3 34 +#define ERR_LIB_PKCS12 35 +#define ERR_LIB_RAND 36 +#define ERR_LIB_DSO 37 +#define ERR_LIB_ENGINE 38 +#define ERR_LIB_OCSP 39 +#define ERR_LIB_UI 40 +#define ERR_LIB_COMP 41 +#define ERR_LIB_ECDSA 42 +#define ERR_LIB_ECDH 43 +#define ERR_LIB_STORE 44 + +#define ERR_LIB_USER 128 + +#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__) +#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__) +#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__) +#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__) +#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__) +#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__) +#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__) +#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__) +#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__) +#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__) +#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__) +#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__) +#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__) +#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__) +#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__) +#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__) +#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__) +#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__) +#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__) +#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__) +#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__) +#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__) +#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) +#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) +#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) +#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__) +#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__) +#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) + +/* Borland C seems too stupid to be able to shift and do longs in + * the pre-processor :-( */ +#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \ + ((((unsigned long)f)&0xfffL)*0x1000)| \ + ((((unsigned long)r)&0xfffL))) +#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) +#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) +#define ERR_GET_REASON(l) (int)((l)&0xfffL) +#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) + + +/* OS functions */ +#define SYS_F_FOPEN 1 +#define SYS_F_CONNECT 2 +#define SYS_F_GETSERVBYNAME 3 +#define SYS_F_SOCKET 4 +#define SYS_F_IOCTLSOCKET 5 +#define SYS_F_BIND 6 +#define SYS_F_LISTEN 7 +#define SYS_F_ACCEPT 8 +#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ +#define SYS_F_OPENDIR 10 +#define SYS_F_FREAD 11 + + +/* reasons */ +#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */ +#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */ +#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */ +#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */ +#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */ +#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */ +#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */ +#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */ +#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */ +#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */ +#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */ +#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */ +#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */ +#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */ +#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */ +#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */ +#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */ +#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */ +#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */ +#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */ +#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */ +#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */ +#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */ +#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */ +#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */ +#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */ +#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */ +#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */ + +#define ERR_R_NESTED_ASN1_ERROR 58 +#define ERR_R_BAD_ASN1_OBJECT_HEADER 59 +#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60 +#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61 +#define ERR_R_ASN1_LENGTH_MISMATCH 62 +#define ERR_R_MISSING_ASN1_EOS 63 + +/* fatal error */ +#define ERR_R_FATAL 64 +#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) +#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) +#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) +#define ERR_R_DISABLED (5|ERR_R_FATAL) + +/* 99 is the maximum possible ERR_R_... code, higher values + * are reserved for the individual libraries */ + + +typedef struct ERR_string_data_st + { + unsigned long error; + const char *string; + } ERR_STRING_DATA; + +void ERR_put_error(int lib, int func,int reason,const char *file,int line); +void ERR_set_error_data(char *data,int flags); + +unsigned long ERR_get_error(void); +unsigned long ERR_get_error_line(const char **file,int *line); +unsigned long ERR_get_error_line_data(const char **file,int *line, + const char **data, int *flags); +unsigned long ERR_peek_error(void); +unsigned long ERR_peek_error_line(const char **file,int *line); +unsigned long ERR_peek_error_line_data(const char **file,int *line, + const char **data,int *flags); +unsigned long ERR_peek_last_error(void); +unsigned long ERR_peek_last_error_line(const char **file,int *line); +unsigned long ERR_peek_last_error_line_data(const char **file,int *line, + const char **data,int *flags); +void ERR_clear_error(void ); +char *ERR_error_string(unsigned long e,char *buf); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +const char *ERR_lib_error_string(unsigned long e); +const char *ERR_func_error_string(unsigned long e); +const char *ERR_reason_error_string(unsigned long e); +void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); +#ifndef OPENSSL_NO_FP_API +void ERR_print_errors_fp(FILE *fp); +#endif +#ifndef OPENSSL_NO_BIO +void ERR_print_errors(BIO *bp); +void ERR_add_error_data(int num, ...); +#endif +void ERR_load_strings(int lib,ERR_STRING_DATA str[]); +void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); +void ERR_load_ERR_strings(void); +void ERR_load_crypto_strings(void); +void ERR_free_strings(void); + +void ERR_remove_state(unsigned long pid); /* if zero we look it up */ +ERR_STATE *ERR_get_state(void); + +#ifndef OPENSSL_NO_LHASH +LHASH *ERR_get_string_table(void); +LHASH *ERR_get_err_state_table(void); +void ERR_release_err_state_table(LHASH **hash); +#endif + +int ERR_get_next_error_library(void); + +int ERR_set_mark(void); +int ERR_pop_to_mark(void); + +/* Already defined in ossl_typ.h */ +/* typedef struct st_ERR_FNS ERR_FNS; */ +/* An application can use this function and provide the return value to loaded + * modules that should use the application's ERR state/functionality */ +const ERR_FNS *ERR_get_implementation(void); +/* A loaded module should call this function prior to any ERR operations using + * the application's "ERR_FNS". */ +int ERR_set_implementation(const ERR_FNS *fns); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/evp.h b/include/openssl/evp.h new file mode 100755 index 0000000..7b13fd7 --- /dev/null +++ b/include/openssl/evp.h @@ -0,0 +1,970 @@ +/* crypto/evp/evp.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ENVELOPE_H +#define HEADER_ENVELOPE_H + +#ifdef OPENSSL_ALGORITHM_DEFINES +# include +#else +# define OPENSSL_ALGORITHM_DEFINES +# include +# undef OPENSSL_ALGORITHM_DEFINES +#endif + +#include + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif + +/* +#define EVP_RC2_KEY_SIZE 16 +#define EVP_RC4_KEY_SIZE 16 +#define EVP_BLOWFISH_KEY_SIZE 16 +#define EVP_CAST5_KEY_SIZE 16 +#define EVP_RC5_32_12_16_KEY_SIZE 16 +*/ +#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ +#define EVP_MAX_KEY_LENGTH 32 +#define EVP_MAX_IV_LENGTH 16 +#define EVP_MAX_BLOCK_LENGTH 32 + +#define PKCS5_SALT_LEN 8 +/* Default PKCS#5 iteration count */ +#define PKCS5_DEFAULT_ITER 2048 + +#include + +#define EVP_PK_RSA 0x0001 +#define EVP_PK_DSA 0x0002 +#define EVP_PK_DH 0x0004 +#define EVP_PK_EC 0x0008 +#define EVP_PKT_SIGN 0x0010 +#define EVP_PKT_ENC 0x0020 +#define EVP_PKT_EXCH 0x0040 +#define EVP_PKS_RSA 0x0100 +#define EVP_PKS_DSA 0x0200 +#define EVP_PKS_EC 0x0400 +#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ + +#define EVP_PKEY_NONE NID_undef +#define EVP_PKEY_RSA NID_rsaEncryption +#define EVP_PKEY_RSA2 NID_rsa +#define EVP_PKEY_DSA NID_dsa +#define EVP_PKEY_DSA1 NID_dsa_2 +#define EVP_PKEY_DSA2 NID_dsaWithSHA +#define EVP_PKEY_DSA3 NID_dsaWithSHA1 +#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 +#define EVP_PKEY_DH NID_dhKeyAgreement +#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type needs to be a bit field + * Sub-type needs to be for variations on the method, as in, can it do + * arbitrary encryption.... */ +struct evp_pkey_st + { + int type; + int save_type; + int references; + union { + char *ptr; +#ifndef OPENSSL_NO_RSA + struct rsa_st *rsa; /* RSA */ +#endif +#ifndef OPENSSL_NO_DSA + struct dsa_st *dsa; /* DSA */ +#endif +#ifndef OPENSSL_NO_DH + struct dh_st *dh; /* DH */ +#endif +#ifndef OPENSSL_NO_EC + struct ec_key_st *ec; /* ECC */ +#endif + } pkey; + int save_parameters; + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } /* EVP_PKEY */; + +#define EVP_PKEY_MO_SIGN 0x0001 +#define EVP_PKEY_MO_VERIFY 0x0002 +#define EVP_PKEY_MO_ENCRYPT 0x0004 +#define EVP_PKEY_MO_DECRYPT 0x0008 + +#if 0 +/* This structure is required to tie the message digest and signing together. + * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or + * oid, md and pkey. + * This is required because for various smart-card perform the digest and + * signing/verification on-board. To handle this case, the specific + * EVP_MD and EVP_PKEY_METHODs need to be closely associated. + * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. + * This can either be software or a token to provide the required low level + * routines. + */ +typedef struct evp_pkey_md_st + { + int oid; + EVP_MD *md; + EVP_PKEY_METHOD *pkey; + } EVP_PKEY_MD; + +#define EVP_rsa_md2() \ + EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md2()) +#define EVP_rsa_md5() \ + EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md5()) +#define EVP_rsa_sha0() \ + EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha()) +#define EVP_rsa_sha1() \ + EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha1()) +#define EVP_rsa_ripemd160() \ + EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ + EVP_rsa_pkcs1(),EVP_ripemd160()) +#define EVP_rsa_mdc2() \ + EVP_PKEY_MD_add(NID_mdc2WithRSA,\ + EVP_rsa_octet_string(),EVP_mdc2()) +#define EVP_dsa_sha() \ + EVP_PKEY_MD_add(NID_dsaWithSHA,\ + EVP_dsa(),EVP_sha()) +#define EVP_dsa_sha1() \ + EVP_PKEY_MD_add(NID_dsaWithSHA1,\ + EVP_dsa(),EVP_sha1()) + +typedef struct evp_pkey_method_st + { + char *name; + int flags; + int type; /* RSA, DSA, an SSLeay specific constant */ + int oid; /* For the pub-key type */ + int encrypt_oid; /* pub/priv key encryption */ + + int (*sign)(); + int (*verify)(); + struct { + int (*set)(); /* get and/or set the underlying type */ + int (*get)(); + int (*encrypt)(); + int (*decrypt)(); + int (*i2d)(); + int (*d2i)(); + int (*dup)(); + } pub,priv; + int (*set_asn1_parameters)(); + int (*get_asn1_parameters)(); + } EVP_PKEY_METHOD; +#endif + +#ifndef EVP_MD +struct env_md_st + { + int type; + int pkey_type; + int md_size; + unsigned long flags; + int (*init)(EVP_MD_CTX *ctx); + int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count); + int (*final)(EVP_MD_CTX *ctx,unsigned char *md); + int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); + int (*cleanup)(EVP_MD_CTX *ctx); + + /* FIXME: prototype these some day */ + int (*sign)(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, void *key); + int (*verify)(int type, const unsigned char *m, unsigned int m_length, + const unsigned char *sigbuf, unsigned int siglen, + void *key); + int required_pkey_type[5]; /*EVP_PKEY_xxx */ + int block_size; + int ctx_size; /* how big does the ctx->md_data need to be */ + } /* EVP_MD */; + +typedef int evp_sign_method(int type,const unsigned char *m, + unsigned int m_length,unsigned char *sigret, + unsigned int *siglen, void *key); +typedef int evp_verify_method(int type,const unsigned char *m, + unsigned int m_length,const unsigned char *sigbuf, + unsigned int siglen, void *key); + +#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single + * block */ + +#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \ + (evp_verify_method *)DSA_verify, \ + {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ + EVP_PKEY_DSA4,0} +#else +#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_ECDSA +#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \ + (evp_verify_method *)ECDSA_verify, \ + {EVP_PKEY_EC,0,0,0} +#else +#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \ + (evp_verify_method *)RSA_verify, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ + (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \ + (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#else +#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method +#endif + +#endif /* !EVP_MD */ + +struct env_md_ctx_st + { + const EVP_MD *digest; + ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ + unsigned long flags; + void *md_data; + } /* EVP_MD_CTX */; + +/* values for EVP_MD_CTX flags */ + +#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called + * once only */ +#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been + * cleaned */ +#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data + * in EVP_MD_CTX_cleanup */ + +struct evp_cipher_st + { + int nid; + int block_size; + int key_len; /* Default value for variable length ciphers */ + int iv_len; + unsigned long flags; /* Various flags */ + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc); /* init key */ + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ + int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ + int ctx_size; /* how big ctx->cipher_data needs to be */ + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ + void *app_data; /* Application data */ + } /* EVP_CIPHER */; + +/* Values for cipher flags */ + +/* Modes for ciphers */ + +#define EVP_CIPH_STREAM_CIPHER 0x0 +#define EVP_CIPH_ECB_MODE 0x1 +#define EVP_CIPH_CBC_MODE 0x2 +#define EVP_CIPH_CFB_MODE 0x3 +#define EVP_CIPH_OFB_MODE 0x4 +#define EVP_CIPH_MODE 0x7 +/* Set if variable length cipher */ +#define EVP_CIPH_VARIABLE_LENGTH 0x8 +/* Set if the iv handling should be done by the cipher itself */ +#define EVP_CIPH_CUSTOM_IV 0x10 +/* Set if the cipher's init() function should be called if key is NULL */ +#define EVP_CIPH_ALWAYS_CALL_INIT 0x20 +/* Call ctrl() to init cipher parameters */ +#define EVP_CIPH_CTRL_INIT 0x40 +/* Don't use standard key length function */ +#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 +/* Don't use standard block padding */ +#define EVP_CIPH_NO_PADDING 0x100 +/* cipher handles random key generation */ +#define EVP_CIPH_RAND_KEY 0x200 + +/* ctrl() values */ + +#define EVP_CTRL_INIT 0x0 +#define EVP_CTRL_SET_KEY_LENGTH 0x1 +#define EVP_CTRL_GET_RC2_KEY_BITS 0x2 +#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 +#define EVP_CTRL_GET_RC5_ROUNDS 0x4 +#define EVP_CTRL_SET_RC5_ROUNDS 0x5 +#define EVP_CTRL_RAND_KEY 0x6 + +typedef struct evp_cipher_info_st + { + const EVP_CIPHER *cipher; + unsigned char iv[EVP_MAX_IV_LENGTH]; + } EVP_CIPHER_INFO; + +struct evp_cipher_ctx_st + { + const EVP_CIPHER *cipher; + ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ + int encrypt; /* encrypt or decrypt */ + int buf_len; /* number we have left */ + + unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ + unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ + unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ + int num; /* used by cfb/ofb mode */ + + void *app_data; /* application stuff */ + int key_len; /* May change for variable length cipher */ + unsigned long flags; /* Various flags */ + void *cipher_data; /* per EVP data */ + int final_used; + int block_mask; + unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ + } /* EVP_CIPHER_CTX */; + +typedef struct evp_Encode_Ctx_st + { + int num; /* number saved in a partial encode/decode */ + int length; /* The length is either the output line length + * (in input bytes) or the shortest input line + * length that is ok. Once decoding begins, + * the length is adjusted up each time a longer + * line is decoded */ + unsigned char enc_data[80]; /* data to encode */ + int line_num; /* number read on current line */ + int expect_nl; + } EVP_ENCODE_CTX; + +/* Password based encryption function */ +typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ + (char *)(rsa)) +#endif + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ + (char *)(dsa)) +#endif + +#ifndef OPENSSL_NO_DH +#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ + (char *)(dh)) +#endif + +#ifndef OPENSSL_NO_EC +#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ + (char *)(eckey)) +#endif + +/* Add some extra combinations */ +#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) +#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) +#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) +#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) + +int EVP_MD_type(const EVP_MD *md); +#define EVP_MD_nid(e) EVP_MD_type(e) +#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) +int EVP_MD_pkey_type(const EVP_MD *md); +int EVP_MD_size(const EVP_MD *md); +int EVP_MD_block_size(const EVP_MD *md); + +const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx); +#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) +#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e)) +#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e)) + +int EVP_CIPHER_nid(const EVP_CIPHER *cipher); +#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) +int EVP_CIPHER_block_size(const EVP_CIPHER *cipher); +int EVP_CIPHER_key_length(const EVP_CIPHER *cipher); +int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher); +unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher); +#define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE) + +const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); +void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); +void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); +#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) +unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx); +#define EVP_CIPHER_CTX_mode(e) (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE) + +#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) +#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) + +#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_SignInit(a,b) EVP_DigestInit(a,b) +#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) +#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) +#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) + +#ifdef CONST_STRICT +void BIO_set_md(BIO *,const EVP_MD *md); +#else +# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) +#endif +#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) +#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) +#define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp) +#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) +#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) + +int EVP_Cipher(EVP_CIPHER_CTX *c, + unsigned char *out, + const unsigned char *in, + unsigned int inl); + +#define EVP_add_cipher_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_add_digest_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_delete_cipher_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); +#define EVP_delete_digest_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); + +void EVP_MD_CTX_init(EVP_MD_CTX *ctx); +int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); +EVP_MD_CTX *EVP_MD_CTX_create(void); +void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); +int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); +void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); +void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); +int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags); +int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); +int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, + size_t cnt); +int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); +int EVP_Digest(const void *data, size_t count, + unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); + +int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); +int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); +int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); + +int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); +void EVP_set_pw_prompt(const char *prompt); +char * EVP_get_pw_prompt(void); + +int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, + const unsigned char *salt, const unsigned char *data, + int datal, int count, unsigned char *key,unsigned char *iv); + +int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); +int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, + EVP_PKEY *pkey); + +int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf, + unsigned int siglen,EVP_PKEY *pkey); + +int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, + const unsigned char *ek, int ekl, const unsigned char *iv, + EVP_PKEY *priv); +int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); +int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); + +void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); +void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in,int inl); +void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); +int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in, int inl); +int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned + char *out, int *outl); +int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); +EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); +void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); +int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); +int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); +int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_md(void); +BIO_METHOD *BIO_f_base64(void); +BIO_METHOD *BIO_f_cipher(void); +BIO_METHOD *BIO_f_reliable(void); +void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k, + const unsigned char *i, int enc); +#endif + +const EVP_MD *EVP_md_null(void); +#ifndef OPENSSL_NO_MD2 +const EVP_MD *EVP_md2(void); +#endif +#ifndef OPENSSL_NO_MD4 +const EVP_MD *EVP_md4(void); +#endif +#ifndef OPENSSL_NO_MD5 +const EVP_MD *EVP_md5(void); +#endif +#ifndef OPENSSL_NO_SHA +const EVP_MD *EVP_sha(void); +const EVP_MD *EVP_sha1(void); +const EVP_MD *EVP_dss(void); +const EVP_MD *EVP_dss1(void); +const EVP_MD *EVP_ecdsa(void); +#endif +#ifndef OPENSSL_NO_SHA256 +const EVP_MD *EVP_sha224(void); +const EVP_MD *EVP_sha256(void); +#endif +#ifndef OPENSSL_NO_SHA512 +const EVP_MD *EVP_sha384(void); +const EVP_MD *EVP_sha512(void); +#endif +#ifndef OPENSSL_NO_MDC2 +const EVP_MD *EVP_mdc2(void); +#endif +#ifndef OPENSSL_NO_RIPEMD +const EVP_MD *EVP_ripemd160(void); +#endif +const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ +#ifndef OPENSSL_NO_DES +const EVP_CIPHER *EVP_des_ecb(void); +const EVP_CIPHER *EVP_des_ede(void); +const EVP_CIPHER *EVP_des_ede3(void); +const EVP_CIPHER *EVP_des_ede_ecb(void); +const EVP_CIPHER *EVP_des_ede3_ecb(void); +const EVP_CIPHER *EVP_des_cfb64(void); +# define EVP_des_cfb EVP_des_cfb64 +const EVP_CIPHER *EVP_des_cfb1(void); +const EVP_CIPHER *EVP_des_cfb8(void); +const EVP_CIPHER *EVP_des_ede_cfb64(void); +# define EVP_des_ede_cfb EVP_des_ede_cfb64 +#if 0 +const EVP_CIPHER *EVP_des_ede_cfb1(void); +const EVP_CIPHER *EVP_des_ede_cfb8(void); +#endif +const EVP_CIPHER *EVP_des_ede3_cfb64(void); +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb1(void); +const EVP_CIPHER *EVP_des_ede3_cfb8(void); +const EVP_CIPHER *EVP_des_ofb(void); +const EVP_CIPHER *EVP_des_ede_ofb(void); +const EVP_CIPHER *EVP_des_ede3_ofb(void); +const EVP_CIPHER *EVP_des_cbc(void); +const EVP_CIPHER *EVP_des_ede_cbc(void); +const EVP_CIPHER *EVP_des_ede3_cbc(void); +const EVP_CIPHER *EVP_desx_cbc(void); +/* This should now be supported through the dev_crypto ENGINE. But also, why are + * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ +#if 0 +# ifdef OPENSSL_OPENBSD_DEV_CRYPTO +const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); +const EVP_CIPHER *EVP_dev_crypto_rc4(void); +const EVP_MD *EVP_dev_crypto_md5(void); +# endif +#endif +#endif +#ifndef OPENSSL_NO_RC4 +const EVP_CIPHER *EVP_rc4(void); +const EVP_CIPHER *EVP_rc4_40(void); +#endif +#ifndef OPENSSL_NO_IDEA +const EVP_CIPHER *EVP_idea_ecb(void); +const EVP_CIPHER *EVP_idea_cfb64(void); +# define EVP_idea_cfb EVP_idea_cfb64 +const EVP_CIPHER *EVP_idea_ofb(void); +const EVP_CIPHER *EVP_idea_cbc(void); +#endif +#ifndef OPENSSL_NO_RC2 +const EVP_CIPHER *EVP_rc2_ecb(void); +const EVP_CIPHER *EVP_rc2_cbc(void); +const EVP_CIPHER *EVP_rc2_40_cbc(void); +const EVP_CIPHER *EVP_rc2_64_cbc(void); +const EVP_CIPHER *EVP_rc2_cfb64(void); +# define EVP_rc2_cfb EVP_rc2_cfb64 +const EVP_CIPHER *EVP_rc2_ofb(void); +#endif +#ifndef OPENSSL_NO_BF +const EVP_CIPHER *EVP_bf_ecb(void); +const EVP_CIPHER *EVP_bf_cbc(void); +const EVP_CIPHER *EVP_bf_cfb64(void); +# define EVP_bf_cfb EVP_bf_cfb64 +const EVP_CIPHER *EVP_bf_ofb(void); +#endif +#ifndef OPENSSL_NO_CAST +const EVP_CIPHER *EVP_cast5_ecb(void); +const EVP_CIPHER *EVP_cast5_cbc(void); +const EVP_CIPHER *EVP_cast5_cfb64(void); +# define EVP_cast5_cfb EVP_cast5_cfb64 +const EVP_CIPHER *EVP_cast5_ofb(void); +#endif +#ifndef OPENSSL_NO_RC5 +const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); +const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); +const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 +const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); +#endif +#ifndef OPENSSL_NO_AES +const EVP_CIPHER *EVP_aes_128_ecb(void); +const EVP_CIPHER *EVP_aes_128_cbc(void); +const EVP_CIPHER *EVP_aes_128_cfb1(void); +const EVP_CIPHER *EVP_aes_128_cfb8(void); +const EVP_CIPHER *EVP_aes_128_cfb128(void); +# define EVP_aes_128_cfb EVP_aes_128_cfb128 +const EVP_CIPHER *EVP_aes_128_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_128_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_192_ecb(void); +const EVP_CIPHER *EVP_aes_192_cbc(void); +const EVP_CIPHER *EVP_aes_192_cfb1(void); +const EVP_CIPHER *EVP_aes_192_cfb8(void); +const EVP_CIPHER *EVP_aes_192_cfb128(void); +# define EVP_aes_192_cfb EVP_aes_192_cfb128 +const EVP_CIPHER *EVP_aes_192_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_192_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_256_ecb(void); +const EVP_CIPHER *EVP_aes_256_cbc(void); +const EVP_CIPHER *EVP_aes_256_cfb1(void); +const EVP_CIPHER *EVP_aes_256_cfb8(void); +const EVP_CIPHER *EVP_aes_256_cfb128(void); +# define EVP_aes_256_cfb EVP_aes_256_cfb128 +const EVP_CIPHER *EVP_aes_256_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_256_ctr(void); +#endif +#endif +#ifndef OPENSSL_NO_CAMELLIA +const EVP_CIPHER *EVP_camellia_128_ecb(void); +const EVP_CIPHER *EVP_camellia_128_cbc(void); +const EVP_CIPHER *EVP_camellia_128_cfb1(void); +const EVP_CIPHER *EVP_camellia_128_cfb8(void); +const EVP_CIPHER *EVP_camellia_128_cfb128(void); +# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 +const EVP_CIPHER *EVP_camellia_128_ofb(void); +const EVP_CIPHER *EVP_camellia_192_ecb(void); +const EVP_CIPHER *EVP_camellia_192_cbc(void); +const EVP_CIPHER *EVP_camellia_192_cfb1(void); +const EVP_CIPHER *EVP_camellia_192_cfb8(void); +const EVP_CIPHER *EVP_camellia_192_cfb128(void); +# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 +const EVP_CIPHER *EVP_camellia_192_ofb(void); +const EVP_CIPHER *EVP_camellia_256_ecb(void); +const EVP_CIPHER *EVP_camellia_256_cbc(void); +const EVP_CIPHER *EVP_camellia_256_cfb1(void); +const EVP_CIPHER *EVP_camellia_256_cfb8(void); +const EVP_CIPHER *EVP_camellia_256_cfb128(void); +# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 +const EVP_CIPHER *EVP_camellia_256_ofb(void); +#endif + +void OPENSSL_add_all_algorithms_noconf(void); +void OPENSSL_add_all_algorithms_conf(void); + +#ifdef OPENSSL_LOAD_CONF +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_conf() +#else +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_noconf() +#endif + +void OpenSSL_add_all_ciphers(void); +void OpenSSL_add_all_digests(void); +#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() +#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() +#define SSLeay_add_all_digests() OpenSSL_add_all_digests() + +int EVP_add_cipher(const EVP_CIPHER *cipher); +int EVP_add_digest(const EVP_MD *digest); + +const EVP_CIPHER *EVP_get_cipherbyname(const char *name); +const EVP_MD *EVP_get_digestbyname(const char *name); +void EVP_cleanup(void); + +int EVP_PKEY_decrypt(unsigned char *dec_key, + const unsigned char *enc_key,int enc_key_len, + EVP_PKEY *private_key); +int EVP_PKEY_encrypt(unsigned char *enc_key, + const unsigned char *key,int key_len, + EVP_PKEY *pub_key); +int EVP_PKEY_type(int type); +int EVP_PKEY_bits(EVP_PKEY *pkey); +int EVP_PKEY_size(EVP_PKEY *pkey); +int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); + +#ifndef OPENSSL_NO_RSA +struct rsa_st; +int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key); +struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DSA +struct dsa_st; +int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key); +struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DH +struct dh_st; +int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); +struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_EC +struct ec_key_st; +int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key); +struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); +#endif + +EVP_PKEY * EVP_PKEY_new(void); +void EVP_PKEY_free(EVP_PKEY *pkey); + +EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); + +EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); + +int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); +int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); +int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); +int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_CIPHER_type(const EVP_CIPHER *ctx); + +/* calls methods */ +int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); + +/* These are used by EVP_CIPHER methods */ +int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); +int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); + +/* PKCS5 password based encryption */ +int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); +int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + int keylen, unsigned char *out); +int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); + +void PKCS5_PBE_add(void); + +int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); +int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, + EVP_PBE_KEYGEN *keygen); +void EVP_PBE_cleanup(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EVP_strings(void); + +/* Error codes for the EVP functions. */ + +/* Function codes. */ +#define EVP_F_AES_INIT_KEY 133 +#define EVP_F_CAMELLIA_INIT_KEY 159 +#define EVP_F_D2I_PKEY 100 +#define EVP_F_DSAPKEY2PKCS8 134 +#define EVP_F_DSA_PKEY2PKCS8 135 +#define EVP_F_ECDSA_PKEY2PKCS8 129 +#define EVP_F_ECKEY_PKEY2PKCS8 132 +#define EVP_F_EVP_CIPHERINIT_EX 123 +#define EVP_F_EVP_CIPHER_CTX_CTRL 124 +#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 +#define EVP_F_EVP_DECRYPTFINAL_EX 101 +#define EVP_F_EVP_DIGESTINIT_EX 128 +#define EVP_F_EVP_ENCRYPTFINAL_EX 127 +#define EVP_F_EVP_MD_CTX_COPY_EX 110 +#define EVP_F_EVP_OPENINIT 102 +#define EVP_F_EVP_PBE_ALG_ADD 115 +#define EVP_F_EVP_PBE_CIPHERINIT 116 +#define EVP_F_EVP_PKCS82PKEY 111 +#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113 +#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 +#define EVP_F_EVP_PKEY_DECRYPT 104 +#define EVP_F_EVP_PKEY_ENCRYPT 105 +#define EVP_F_EVP_PKEY_GET1_DH 119 +#define EVP_F_EVP_PKEY_GET1_DSA 120 +#define EVP_F_EVP_PKEY_GET1_ECDSA 130 +#define EVP_F_EVP_PKEY_GET1_EC_KEY 131 +#define EVP_F_EVP_PKEY_GET1_RSA 121 +#define EVP_F_EVP_PKEY_NEW 106 +#define EVP_F_EVP_RIJNDAEL 126 +#define EVP_F_EVP_SIGNFINAL 107 +#define EVP_F_EVP_VERIFYFINAL 108 +#define EVP_F_PKCS5_PBE_KEYIVGEN 117 +#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 +#define EVP_F_PKCS8_SET_BROKEN 112 +#define EVP_F_RC2_MAGIC_TO_METH 109 +#define EVP_F_RC5_CTRL 125 + +/* Reason codes. */ +#define EVP_R_AES_KEY_SETUP_FAILED 143 +#define EVP_R_ASN1_LIB 140 +#define EVP_R_BAD_BLOCK_LENGTH 136 +#define EVP_R_BAD_DECRYPT 100 +#define EVP_R_BAD_KEY_LENGTH 137 +#define EVP_R_BN_DECODE_ERROR 112 +#define EVP_R_BN_PUBKEY_ERROR 113 +#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 +#define EVP_R_CIPHER_PARAMETER_ERROR 122 +#define EVP_R_CTRL_NOT_IMPLEMENTED 132 +#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 +#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 +#define EVP_R_DECODE_ERROR 114 +#define EVP_R_DIFFERENT_KEY_TYPES 101 +#define EVP_R_ENCODE_ERROR 115 +#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 +#define EVP_R_EXPECTING_AN_RSA_KEY 127 +#define EVP_R_EXPECTING_A_DH_KEY 128 +#define EVP_R_EXPECTING_A_DSA_KEY 129 +#define EVP_R_EXPECTING_A_ECDSA_KEY 141 +#define EVP_R_EXPECTING_A_EC_KEY 142 +#define EVP_R_INITIALIZATION_ERROR 134 +#define EVP_R_INPUT_NOT_INITIALIZED 111 +#define EVP_R_INVALID_KEY_LENGTH 130 +#define EVP_R_IV_TOO_LARGE 102 +#define EVP_R_KEYGEN_FAILURE 120 +#define EVP_R_MISSING_PARAMETERS 103 +#define EVP_R_NO_CIPHER_SET 131 +#define EVP_R_NO_DIGEST_SET 139 +#define EVP_R_NO_DSA_PARAMETERS 116 +#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 +#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 +#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 +#define EVP_R_UNSUPPORTED_CIPHER 107 +#define EVP_R_UNSUPPORTED_KEYLENGTH 123 +#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 +#define EVP_R_UNSUPPORTED_KEY_SIZE 108 +#define EVP_R_UNSUPPORTED_PRF 125 +#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 +#define EVP_R_UNSUPPORTED_SALT_TYPE 126 +#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 +#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h new file mode 100755 index 0000000..943869a --- /dev/null +++ b/include/openssl/hmac.h @@ -0,0 +1,108 @@ +/* crypto/hmac/hmac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#ifndef HEADER_HMAC_H +#define HEADER_HMAC_H + +#include + +#ifdef OPENSSL_NO_HMAC +#error HMAC is disabled. +#endif + +#include + +#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct hmac_ctx_st + { + const EVP_MD *md; + EVP_MD_CTX md_ctx; + EVP_MD_CTX i_ctx; + EVP_MD_CTX o_ctx; + unsigned int key_length; + unsigned char key[HMAC_MAX_MD_CBLOCK]; + } HMAC_CTX; + +#define HMAC_size(e) (EVP_MD_size((e)->md)) + + +void HMAC_CTX_init(HMAC_CTX *ctx); +void HMAC_CTX_cleanup(HMAC_CTX *ctx); + +#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ + +void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md); /* deprecated */ +void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md, ENGINE *impl); +void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); +void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); +unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, + const unsigned char *d, size_t n, unsigned char *md, + unsigned int *md_len); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/idea.h b/include/openssl/idea.h new file mode 100755 index 0000000..d96154a --- /dev/null +++ b/include/openssl/idea.h @@ -0,0 +1,100 @@ +/* crypto/idea/idea.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_IDEA_H +#define HEADER_IDEA_H + +#include /* IDEA_INT, OPENSSL_NO_IDEA */ + +#ifdef OPENSSL_NO_IDEA +#error IDEA is disabled. +#endif + +#define IDEA_ENCRYPT 1 +#define IDEA_DECRYPT 0 + +#define IDEA_BLOCK 8 +#define IDEA_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct idea_key_st + { + IDEA_INT data[9][6]; + } IDEA_KEY_SCHEDULE; + +const char *idea_options(void); +void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, + IDEA_KEY_SCHEDULE *ks); +void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); +void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); +void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc); +void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, + int *num,int enc); +void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num); +void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/krb5_asn.h b/include/openssl/krb5_asn.h new file mode 100755 index 0000000..fa08967 --- /dev/null +++ b/include/openssl/krb5_asn.h @@ -0,0 +1,256 @@ +/* krb5_asn.h */ +/* Written by Vern Staats for the OpenSSL project, +** using ocsp/{*.h,*asn*.c} as a starting point +*/ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_KRB5_ASN_H +#define HEADER_KRB5_ASN_H + +/* +#include +*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ASN.1 from Kerberos RFC 1510 +*/ + +/* EncryptedData ::= SEQUENCE { +** etype[0] INTEGER, -- EncryptionType +** kvno[1] INTEGER OPTIONAL, +** cipher[2] OCTET STRING -- ciphertext +** } +*/ +typedef struct krb5_encdata_st + { + ASN1_INTEGER *etype; + ASN1_INTEGER *kvno; + ASN1_OCTET_STRING *cipher; + } KRB5_ENCDATA; + +DECLARE_STACK_OF(KRB5_ENCDATA) + +/* PrincipalName ::= SEQUENCE { +** name-type[0] INTEGER, +** name-string[1] SEQUENCE OF GeneralString +** } +*/ +typedef struct krb5_princname_st + { + ASN1_INTEGER *nametype; + STACK_OF(ASN1_GENERALSTRING) *namestring; + } KRB5_PRINCNAME; + +DECLARE_STACK_OF(KRB5_PRINCNAME) + + +/* Ticket ::= [APPLICATION 1] SEQUENCE { +** tkt-vno[0] INTEGER, +** realm[1] Realm, +** sname[2] PrincipalName, +** enc-part[3] EncryptedData +** } +*/ +typedef struct krb5_tktbody_st + { + ASN1_INTEGER *tktvno; + ASN1_GENERALSTRING *realm; + KRB5_PRINCNAME *sname; + KRB5_ENCDATA *encdata; + } KRB5_TKTBODY; + +typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET; +DECLARE_STACK_OF(KRB5_TKTBODY) + + +/* AP-REQ ::= [APPLICATION 14] SEQUENCE { +** pvno[0] INTEGER, +** msg-type[1] INTEGER, +** ap-options[2] APOptions, +** ticket[3] Ticket, +** authenticator[4] EncryptedData +** } +** +** APOptions ::= BIT STRING { +** reserved(0), use-session-key(1), mutual-required(2) } +*/ +typedef struct krb5_ap_req_st + { + ASN1_INTEGER *pvno; + ASN1_INTEGER *msgtype; + ASN1_BIT_STRING *apoptions; + KRB5_TICKET *ticket; + KRB5_ENCDATA *authenticator; + } KRB5_APREQBODY; + +typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ; +DECLARE_STACK_OF(KRB5_APREQBODY) + + +/* Authenticator Stuff */ + + +/* Checksum ::= SEQUENCE { +** cksumtype[0] INTEGER, +** checksum[1] OCTET STRING +** } +*/ +typedef struct krb5_checksum_st + { + ASN1_INTEGER *ctype; + ASN1_OCTET_STRING *checksum; + } KRB5_CHECKSUM; + +DECLARE_STACK_OF(KRB5_CHECKSUM) + + +/* EncryptionKey ::= SEQUENCE { +** keytype[0] INTEGER, +** keyvalue[1] OCTET STRING +** } +*/ +typedef struct krb5_encryptionkey_st + { + ASN1_INTEGER *ktype; + ASN1_OCTET_STRING *keyvalue; + } KRB5_ENCKEY; + +DECLARE_STACK_OF(KRB5_ENCKEY) + + +/* AuthorizationData ::= SEQUENCE OF SEQUENCE { +** ad-type[0] INTEGER, +** ad-data[1] OCTET STRING +** } +*/ +typedef struct krb5_authorization_st + { + ASN1_INTEGER *adtype; + ASN1_OCTET_STRING *addata; + } KRB5_AUTHDATA; + +DECLARE_STACK_OF(KRB5_AUTHDATA) + + +/* -- Unencrypted authenticator +** Authenticator ::= [APPLICATION 2] SEQUENCE { +** authenticator-vno[0] INTEGER, +** crealm[1] Realm, +** cname[2] PrincipalName, +** cksum[3] Checksum OPTIONAL, +** cusec[4] INTEGER, +** ctime[5] KerberosTime, +** subkey[6] EncryptionKey OPTIONAL, +** seq-number[7] INTEGER OPTIONAL, +** authorization-data[8] AuthorizationData OPTIONAL +** } +*/ +typedef struct krb5_authenticator_st + { + ASN1_INTEGER *avno; + ASN1_GENERALSTRING *crealm; + KRB5_PRINCNAME *cname; + KRB5_CHECKSUM *cksum; + ASN1_INTEGER *cusec; + ASN1_GENERALIZEDTIME *ctime; + KRB5_ENCKEY *subkey; + ASN1_INTEGER *seqnum; + KRB5_AUTHDATA *authorization; + } KRB5_AUTHENTBODY; + +typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT; +DECLARE_STACK_OF(KRB5_AUTHENTBODY) + + +/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) = +** type *name##_new(void); +** void name##_free(type *a); +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) = +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) = +** type *d2i_##name(type **a, const unsigned char **in, long len); +** int i2d_##name(type *a, unsigned char **out); +** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it +*/ + +DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME) +DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_TICKET) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQ) + +DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM) +DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT) + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/kssl.h b/include/openssl/kssl.h new file mode 100755 index 0000000..c84820f --- /dev/null +++ b/include/openssl/kssl.h @@ -0,0 +1,179 @@ +/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */ +/* Written by Vern Staats for the OpenSSL project 2000. + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* +** 19990701 VRS Started. +*/ + +#ifndef KSSL_H +#define KSSL_H + +#include + +#ifndef OPENSSL_NO_KRB5 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Depending on which KRB5 implementation used, some types from +** the other may be missing. Resolve that here and now +*/ +#ifdef KRB5_HEIMDAL +typedef unsigned char krb5_octet; +#define FAR +#else + +#ifndef FAR +#define FAR +#endif + +#endif + +/* Uncomment this to debug kssl problems or +** to trace usage of the Kerberos session key +** +** #define KSSL_DEBUG +*/ + +#ifndef KRB5SVC +#define KRB5SVC "host" +#endif + +#ifndef KRB5KEYTAB +#define KRB5KEYTAB "/etc/krb5.keytab" +#endif + +#ifndef KRB5SENDAUTH +#define KRB5SENDAUTH 1 +#endif + +#ifndef KRB5CHECKAUTH +#define KRB5CHECKAUTH 1 +#endif + +#ifndef KSSL_CLOCKSKEW +#define KSSL_CLOCKSKEW 300; +#endif + +#define KSSL_ERR_MAX 255 +typedef struct kssl_err_st { + int reason; + char text[KSSL_ERR_MAX+1]; + } KSSL_ERR; + + +/* Context for passing +** (1) Kerberos session key to SSL, and +** (2) Config data between application and SSL lib +*/ +typedef struct kssl_ctx_st + { + /* used by: disposition: */ + char *service_name; /* C,S default ok (kssl) */ + char *service_host; /* C input, REQUIRED */ + char *client_princ; /* S output from krb5 ticket */ + char *keytab_file; /* S NULL (/etc/krb5.keytab) */ + char *cred_cache; /* C NULL (default) */ + krb5_enctype enctype; + int length; + krb5_octet FAR *key; + } KSSL_CTX; + +#define KSSL_CLIENT 1 +#define KSSL_SERVER 2 +#define KSSL_SERVICE 3 +#define KSSL_KEYTAB 4 + +#define KSSL_CTX_OK 0 +#define KSSL_CTX_ERR 1 +#define KSSL_NOMEM 2 + +/* Public (for use by applications that use OpenSSL with Kerberos 5 support */ +krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text); +KSSL_CTX *kssl_ctx_new(void); +KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx); +void kssl_ctx_show(KSSL_CTX *kssl_ctx); +krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, + krb5_data *realm, krb5_data *entity, int nentities); +krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp, + krb5_data *authenp, KSSL_ERR *kssl_err); +krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata, + krb5_ticket_times *ttimes, KSSL_ERR *kssl_err); +krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session); +void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text); +void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data); +krb5_error_code kssl_build_principal_2(krb5_context context, + krb5_principal *princ, int rlen, const char *realm, + int slen, const char *svc, int hlen, const char *host); +krb5_error_code kssl_validate_times(krb5_timestamp atime, + krb5_ticket_times *ttimes); +krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp, + krb5_timestamp *atimep, KSSL_ERR *kssl_err); +unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn); + +#ifdef __cplusplus +} +#endif +#endif /* OPENSSL_NO_KRB5 */ +#endif /* KSSL_H */ diff --git a/include/openssl/lhash.h b/include/openssl/lhash.h new file mode 100755 index 0000000..d0b1daf --- /dev/null +++ b/include/openssl/lhash.h @@ -0,0 +1,200 @@ +/* crypto/lhash/lhash.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ + +#ifndef HEADER_LHASH_H +#define HEADER_LHASH_H + +#include +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct lhash_node_st + { + void *data; + struct lhash_node_st *next; +#ifndef OPENSSL_NO_HASH_COMP + unsigned long hash; +#endif + } LHASH_NODE; + +typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); +typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); +typedef void (*LHASH_DOALL_FN_TYPE)(void *); +typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); + +/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. + * This way, callbacks can be provided to LHASH structures without function + * pointer casting and the macro-defined callbacks provide per-variable casting + * before deferring to the underlying type-specific callbacks. NB: It is + * possible to place a "static" in front of both the DECLARE and IMPLEMENT + * macros if the functions are strictly internal. */ + +/* First: "hash" functions */ +#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *); +#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *arg) { \ + o_type a = (o_type)arg; \ + return f_name(a); } +#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH + +/* Second: "compare" functions */ +#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *, const void *); +#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ + o_type a = (o_type)arg1; \ + o_type b = (o_type)arg2; \ + return f_name(a,b); } +#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP + +/* Third: "doall" functions */ +#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *); +#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *arg) { \ + o_type a = (o_type)arg; \ + f_name(a); } +#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL + +/* Fourth: "doall_arg" functions */ +#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *, void *); +#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ + o_type a = (o_type)arg1; \ + a_type b = (a_type)arg2; \ + f_name(a,b); } +#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG + +typedef struct lhash_st + { + LHASH_NODE **b; + LHASH_COMP_FN_TYPE comp; + LHASH_HASH_FN_TYPE hash; + unsigned int num_nodes; + unsigned int num_alloc_nodes; + unsigned int p; + unsigned int pmax; + unsigned long up_load; /* load times 256 */ + unsigned long down_load; /* load times 256 */ + unsigned long num_items; + + unsigned long num_expands; + unsigned long num_expand_reallocs; + unsigned long num_contracts; + unsigned long num_contract_reallocs; + unsigned long num_hash_calls; + unsigned long num_comp_calls; + unsigned long num_insert; + unsigned long num_replace; + unsigned long num_delete; + unsigned long num_no_delete; + unsigned long num_retrieve; + unsigned long num_retrieve_miss; + unsigned long num_hash_comps; + + int error; + } LHASH; + +#define LH_LOAD_MULT 256 + +/* Indicates a malloc() error in the last call, this is only bad + * in lh_insert(). */ +#define lh_error(lh) ((lh)->error) + +LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); +void lh_free(LHASH *lh); +void *lh_insert(LHASH *lh, void *data); +void *lh_delete(LHASH *lh, const void *data); +void *lh_retrieve(LHASH *lh, const void *data); +void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); +unsigned long lh_strhash(const char *c); +unsigned long lh_num_items(const LHASH *lh); + +#ifndef OPENSSL_NO_FP_API +void lh_stats(const LHASH *lh, FILE *out); +void lh_node_stats(const LHASH *lh, FILE *out); +void lh_node_usage_stats(const LHASH *lh, FILE *out); +#endif + +#ifndef OPENSSL_NO_BIO +void lh_stats_bio(const LHASH *lh, BIO *out); +void lh_node_stats_bio(const LHASH *lh, BIO *out); +void lh_node_usage_stats_bio(const LHASH *lh, BIO *out); +#endif +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/openssl/md2.h b/include/openssl/md2.h new file mode 100755 index 0000000..442fc5a --- /dev/null +++ b/include/openssl/md2.h @@ -0,0 +1,92 @@ +/* crypto/md/md2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD2_H +#define HEADER_MD2_H + +#include /* OPENSSL_NO_MD2, MD2_INT */ +#ifdef OPENSSL_NO_MD2 +#error MD2 is disabled. +#endif +#include + +#define MD2_DIGEST_LENGTH 16 +#define MD2_BLOCK 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct MD2state_st + { + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; + } MD2_CTX; + +const char *MD2_options(void); +int MD2_Init(MD2_CTX *c); +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); +int MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/md4.h b/include/openssl/md4.h new file mode 100755 index 0000000..8315d5c --- /dev/null +++ b/include/openssl/md4.h @@ -0,0 +1,117 @@ +/* crypto/md4/md4.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD4_H +#define HEADER_MD4_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD4 +#error MD4 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD4_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD4_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD4_LONG unsigned long +#define MD4_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD4_LONG unsigned int +#endif + +#define MD4_CBLOCK 64 +#define MD4_LBLOCK (MD4_CBLOCK/4) +#define MD4_DIGEST_LENGTH 16 + +typedef struct MD4state_st + { + MD4_LONG A,B,C,D; + MD4_LONG Nl,Nh; + MD4_LONG data[MD4_LBLOCK]; + unsigned int num; + } MD4_CTX; + +int MD4_Init(MD4_CTX *c); +int MD4_Update(MD4_CTX *c, const void *data, size_t len); +int MD4_Final(unsigned char *md, MD4_CTX *c); +unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); +void MD4_Transform(MD4_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/md5.h b/include/openssl/md5.h new file mode 100755 index 0000000..d09e099 --- /dev/null +++ b/include/openssl/md5.h @@ -0,0 +1,117 @@ +/* crypto/md5/md5.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD5_H +#define HEADER_MD5_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD5 +#error MD5 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD5_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD5_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD5_LONG unsigned long +#define MD5_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD5_LONG unsigned int +#endif + +#define MD5_CBLOCK 64 +#define MD5_LBLOCK (MD5_CBLOCK/4) +#define MD5_DIGEST_LENGTH 16 + +typedef struct MD5state_st + { + MD5_LONG A,B,C,D; + MD5_LONG Nl,Nh; + MD5_LONG data[MD5_LBLOCK]; + unsigned int num; + } MD5_CTX; + +int MD5_Init(MD5_CTX *c); +int MD5_Update(MD5_CTX *c, const void *data, size_t len); +int MD5_Final(unsigned char *md, MD5_CTX *c); +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); +void MD5_Transform(MD5_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/obj_mac.h b/include/openssl/obj_mac.h new file mode 100755 index 0000000..d53e809 --- /dev/null +++ b/include/openssl/obj_mac.h @@ -0,0 +1,3408 @@ +/* crypto/objects/obj_mac.h */ + +/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the + * following command: + * perl objects.pl objects.txt obj_mac.num obj_mac.h + */ + +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_itu_t "ITU-T" +#define LN_itu_t "itu-t" +#define NID_itu_t 645 +#define OBJ_itu_t 0L + +#define NID_ccitt 404 +#define OBJ_ccitt OBJ_itu_t + +#define SN_iso "ISO" +#define LN_iso "iso" +#define NID_iso 181 +#define OBJ_iso 1L + +#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" +#define LN_joint_iso_itu_t "joint-iso-itu-t" +#define NID_joint_iso_itu_t 646 +#define OBJ_joint_iso_itu_t 2L + +#define NID_joint_iso_ccitt 393 +#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t + +#define SN_member_body "member-body" +#define LN_member_body "ISO Member Body" +#define NID_member_body 182 +#define OBJ_member_body OBJ_iso,2L + +#define SN_identified_organization "identified-organization" +#define NID_identified_organization 676 +#define OBJ_identified_organization OBJ_iso,3L + +#define SN_certicom_arc "certicom-arc" +#define NID_certicom_arc 677 +#define OBJ_certicom_arc OBJ_identified_organization,132L + +#define SN_international_organizations "international-organizations" +#define LN_international_organizations "International Organizations" +#define NID_international_organizations 647 +#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L + +#define SN_wap "wap" +#define NID_wap 678 +#define OBJ_wap OBJ_international_organizations,43L + +#define SN_wap_wsg "wap-wsg" +#define NID_wap_wsg 679 +#define OBJ_wap_wsg OBJ_wap,13L + +#define SN_selected_attribute_types "selected-attribute-types" +#define LN_selected_attribute_types "Selected Attribute Types" +#define NID_selected_attribute_types 394 +#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L + +#define SN_clearance "clearance" +#define NID_clearance 395 +#define OBJ_clearance OBJ_selected_attribute_types,55L + +#define SN_ISO_US "ISO-US" +#define LN_ISO_US "ISO US Member Body" +#define NID_ISO_US 183 +#define OBJ_ISO_US OBJ_member_body,840L + +#define SN_X9_57 "X9-57" +#define LN_X9_57 "X9.57" +#define NID_X9_57 184 +#define OBJ_X9_57 OBJ_ISO_US,10040L + +#define SN_X9cm "X9cm" +#define LN_X9cm "X9.57 CM ?" +#define NID_X9cm 185 +#define OBJ_X9cm OBJ_X9_57,4L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa OBJ_X9cm,1L + +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 OBJ_X9cm,3L + +#define SN_ansi_X9_62 "ansi-X9-62" +#define LN_ansi_X9_62 "ANSI X9.62" +#define NID_ansi_X9_62 405 +#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L + +#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L + +#define SN_X9_62_prime_field "prime-field" +#define NID_X9_62_prime_field 406 +#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L + +#define SN_X9_62_characteristic_two_field "characteristic-two-field" +#define NID_X9_62_characteristic_two_field 407 +#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L + +#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" +#define NID_X9_62_id_characteristic_two_basis 680 +#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L + +#define SN_X9_62_onBasis "onBasis" +#define NID_X9_62_onBasis 681 +#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L + +#define SN_X9_62_tpBasis "tpBasis" +#define NID_X9_62_tpBasis 682 +#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L + +#define SN_X9_62_ppBasis "ppBasis" +#define NID_X9_62_ppBasis 683 +#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L + +#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L + +#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" +#define NID_X9_62_id_ecPublicKey 408 +#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L + +#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L + +#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L + +#define SN_X9_62_c2pnb163v1 "c2pnb163v1" +#define NID_X9_62_c2pnb163v1 684 +#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L + +#define SN_X9_62_c2pnb163v2 "c2pnb163v2" +#define NID_X9_62_c2pnb163v2 685 +#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L + +#define SN_X9_62_c2pnb163v3 "c2pnb163v3" +#define NID_X9_62_c2pnb163v3 686 +#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L + +#define SN_X9_62_c2pnb176v1 "c2pnb176v1" +#define NID_X9_62_c2pnb176v1 687 +#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L + +#define SN_X9_62_c2tnb191v1 "c2tnb191v1" +#define NID_X9_62_c2tnb191v1 688 +#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L + +#define SN_X9_62_c2tnb191v2 "c2tnb191v2" +#define NID_X9_62_c2tnb191v2 689 +#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L + +#define SN_X9_62_c2tnb191v3 "c2tnb191v3" +#define NID_X9_62_c2tnb191v3 690 +#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L + +#define SN_X9_62_c2onb191v4 "c2onb191v4" +#define NID_X9_62_c2onb191v4 691 +#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L + +#define SN_X9_62_c2onb191v5 "c2onb191v5" +#define NID_X9_62_c2onb191v5 692 +#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L + +#define SN_X9_62_c2pnb208w1 "c2pnb208w1" +#define NID_X9_62_c2pnb208w1 693 +#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L + +#define SN_X9_62_c2tnb239v1 "c2tnb239v1" +#define NID_X9_62_c2tnb239v1 694 +#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L + +#define SN_X9_62_c2tnb239v2 "c2tnb239v2" +#define NID_X9_62_c2tnb239v2 695 +#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L + +#define SN_X9_62_c2tnb239v3 "c2tnb239v3" +#define NID_X9_62_c2tnb239v3 696 +#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L + +#define SN_X9_62_c2onb239v4 "c2onb239v4" +#define NID_X9_62_c2onb239v4 697 +#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L + +#define SN_X9_62_c2onb239v5 "c2onb239v5" +#define NID_X9_62_c2onb239v5 698 +#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L + +#define SN_X9_62_c2pnb272w1 "c2pnb272w1" +#define NID_X9_62_c2pnb272w1 699 +#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L + +#define SN_X9_62_c2pnb304w1 "c2pnb304w1" +#define NID_X9_62_c2pnb304w1 700 +#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L + +#define SN_X9_62_c2tnb359v1 "c2tnb359v1" +#define NID_X9_62_c2tnb359v1 701 +#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L + +#define SN_X9_62_c2pnb368w1 "c2pnb368w1" +#define NID_X9_62_c2pnb368w1 702 +#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L + +#define SN_X9_62_c2tnb431r1 "c2tnb431r1" +#define NID_X9_62_c2tnb431r1 703 +#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L + +#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L + +#define SN_X9_62_prime192v1 "prime192v1" +#define NID_X9_62_prime192v1 409 +#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L + +#define SN_X9_62_prime192v2 "prime192v2" +#define NID_X9_62_prime192v2 410 +#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L + +#define SN_X9_62_prime192v3 "prime192v3" +#define NID_X9_62_prime192v3 411 +#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L + +#define SN_X9_62_prime239v1 "prime239v1" +#define NID_X9_62_prime239v1 412 +#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L + +#define SN_X9_62_prime239v2 "prime239v2" +#define NID_X9_62_prime239v2 413 +#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L + +#define SN_X9_62_prime239v3 "prime239v3" +#define NID_X9_62_prime239v3 414 +#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L + +#define SN_X9_62_prime256v1 "prime256v1" +#define NID_X9_62_prime256v1 415 +#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L + +#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L + +#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" +#define NID_ecdsa_with_SHA1 416 +#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L + +#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L + +#define SN_secp112r1 "secp112r1" +#define NID_secp112r1 704 +#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L + +#define SN_secp112r2 "secp112r2" +#define NID_secp112r2 705 +#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L + +#define SN_secp128r1 "secp128r1" +#define NID_secp128r1 706 +#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L + +#define SN_secp128r2 "secp128r2" +#define NID_secp128r2 707 +#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L + +#define SN_secp160k1 "secp160k1" +#define NID_secp160k1 708 +#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L + +#define SN_secp160r1 "secp160r1" +#define NID_secp160r1 709 +#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L + +#define SN_secp160r2 "secp160r2" +#define NID_secp160r2 710 +#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L + +#define SN_secp192k1 "secp192k1" +#define NID_secp192k1 711 +#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L + +#define SN_secp224k1 "secp224k1" +#define NID_secp224k1 712 +#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L + +#define SN_secp224r1 "secp224r1" +#define NID_secp224r1 713 +#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L + +#define SN_secp256k1 "secp256k1" +#define NID_secp256k1 714 +#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L + +#define SN_secp384r1 "secp384r1" +#define NID_secp384r1 715 +#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L + +#define SN_secp521r1 "secp521r1" +#define NID_secp521r1 716 +#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L + +#define SN_sect113r1 "sect113r1" +#define NID_sect113r1 717 +#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L + +#define SN_sect113r2 "sect113r2" +#define NID_sect113r2 718 +#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L + +#define SN_sect131r1 "sect131r1" +#define NID_sect131r1 719 +#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L + +#define SN_sect131r2 "sect131r2" +#define NID_sect131r2 720 +#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L + +#define SN_sect163k1 "sect163k1" +#define NID_sect163k1 721 +#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L + +#define SN_sect163r1 "sect163r1" +#define NID_sect163r1 722 +#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L + +#define SN_sect163r2 "sect163r2" +#define NID_sect163r2 723 +#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L + +#define SN_sect193r1 "sect193r1" +#define NID_sect193r1 724 +#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L + +#define SN_sect193r2 "sect193r2" +#define NID_sect193r2 725 +#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L + +#define SN_sect233k1 "sect233k1" +#define NID_sect233k1 726 +#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L + +#define SN_sect233r1 "sect233r1" +#define NID_sect233r1 727 +#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L + +#define SN_sect239k1 "sect239k1" +#define NID_sect239k1 728 +#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L + +#define SN_sect283k1 "sect283k1" +#define NID_sect283k1 729 +#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L + +#define SN_sect283r1 "sect283r1" +#define NID_sect283r1 730 +#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L + +#define SN_sect409k1 "sect409k1" +#define NID_sect409k1 731 +#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L + +#define SN_sect409r1 "sect409r1" +#define NID_sect409r1 732 +#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L + +#define SN_sect571k1 "sect571k1" +#define NID_sect571k1 733 +#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L + +#define SN_sect571r1 "sect571r1" +#define NID_sect571r1 734 +#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L + +#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L + +#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" +#define NID_wap_wsg_idm_ecid_wtls1 735 +#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L + +#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" +#define NID_wap_wsg_idm_ecid_wtls3 736 +#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L + +#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" +#define NID_wap_wsg_idm_ecid_wtls4 737 +#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L + +#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" +#define NID_wap_wsg_idm_ecid_wtls5 738 +#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L + +#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" +#define NID_wap_wsg_idm_ecid_wtls6 739 +#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L + +#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" +#define NID_wap_wsg_idm_ecid_wtls7 740 +#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L + +#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" +#define NID_wap_wsg_idm_ecid_wtls8 741 +#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L + +#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" +#define NID_wap_wsg_idm_ecid_wtls9 742 +#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L + +#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" +#define NID_wap_wsg_idm_ecid_wtls10 743 +#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L + +#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" +#define NID_wap_wsg_idm_ecid_wtls11 744 +#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L + +#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" +#define NID_wap_wsg_idm_ecid_wtls12 745 +#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L + +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L + +#define SN_rsadsi "rsadsi" +#define LN_rsadsi "RSA Data Security, Inc." +#define NID_rsadsi 1 +#define OBJ_rsadsi OBJ_ISO_US,113549L + +#define SN_pkcs "pkcs" +#define LN_pkcs "RSA Data Security, Inc. PKCS" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_pkcs1 "pkcs1" +#define NID_pkcs1 186 +#define OBJ_pkcs1 OBJ_pkcs,1L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs1,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L + +#define SN_md4WithRSAEncryption "RSA-MD4" +#define LN_md4WithRSAEncryption "md4WithRSAEncryption" +#define NID_md4WithRSAEncryption 396 +#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L + +#define SN_sha256WithRSAEncryption "RSA-SHA256" +#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" +#define NID_sha256WithRSAEncryption 668 +#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L + +#define SN_sha384WithRSAEncryption "RSA-SHA384" +#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" +#define NID_sha384WithRSAEncryption 669 +#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L + +#define SN_sha512WithRSAEncryption "RSA-SHA512" +#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" +#define NID_sha512WithRSAEncryption 670 +#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L + +#define SN_sha224WithRSAEncryption "RSA-SHA224" +#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" +#define NID_sha224WithRSAEncryption 671 +#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L + +#define SN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_pkcs5 "pkcs5" +#define NID_pkcs5 187 +#define OBJ_pkcs5 OBJ_pkcs,5L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L + +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L + +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs5,12L + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs5,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs5,14L + +#define SN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define SN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_ext_req "extReq" +#define LN_ext_req "Extension Request" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_SMIME "SMIME" +#define LN_SMIME "S/MIME" +#define NID_SMIME 188 +#define OBJ_SMIME OBJ_pkcs9,16L + +#define SN_id_smime_mod "id-smime-mod" +#define NID_id_smime_mod 189 +#define OBJ_id_smime_mod OBJ_SMIME,0L + +#define SN_id_smime_ct "id-smime-ct" +#define NID_id_smime_ct 190 +#define OBJ_id_smime_ct OBJ_SMIME,1L + +#define SN_id_smime_aa "id-smime-aa" +#define NID_id_smime_aa 191 +#define OBJ_id_smime_aa OBJ_SMIME,2L + +#define SN_id_smime_alg "id-smime-alg" +#define NID_id_smime_alg 192 +#define OBJ_id_smime_alg OBJ_SMIME,3L + +#define SN_id_smime_cd "id-smime-cd" +#define NID_id_smime_cd 193 +#define OBJ_id_smime_cd OBJ_SMIME,4L + +#define SN_id_smime_spq "id-smime-spq" +#define NID_id_smime_spq 194 +#define OBJ_id_smime_spq OBJ_SMIME,5L + +#define SN_id_smime_cti "id-smime-cti" +#define NID_id_smime_cti 195 +#define OBJ_id_smime_cti OBJ_SMIME,6L + +#define SN_id_smime_mod_cms "id-smime-mod-cms" +#define NID_id_smime_mod_cms 196 +#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L + +#define SN_id_smime_mod_ess "id-smime-mod-ess" +#define NID_id_smime_mod_ess 197 +#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L + +#define SN_id_smime_mod_oid "id-smime-mod-oid" +#define NID_id_smime_mod_oid 198 +#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L + +#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" +#define NID_id_smime_mod_msg_v3 199 +#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L + +#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" +#define NID_id_smime_mod_ets_eSignature_88 200 +#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L + +#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" +#define NID_id_smime_mod_ets_eSignature_97 201 +#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L + +#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" +#define NID_id_smime_mod_ets_eSigPolicy_88 202 +#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L + +#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" +#define NID_id_smime_mod_ets_eSigPolicy_97 203 +#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L + +#define SN_id_smime_ct_receipt "id-smime-ct-receipt" +#define NID_id_smime_ct_receipt 204 +#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L + +#define SN_id_smime_ct_authData "id-smime-ct-authData" +#define NID_id_smime_ct_authData 205 +#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L + +#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" +#define NID_id_smime_ct_publishCert 206 +#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L + +#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" +#define NID_id_smime_ct_TSTInfo 207 +#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L + +#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" +#define NID_id_smime_ct_TDTInfo 208 +#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L + +#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" +#define NID_id_smime_ct_contentInfo 209 +#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L + +#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" +#define NID_id_smime_ct_DVCSRequestData 210 +#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L + +#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" +#define NID_id_smime_ct_DVCSResponseData 211 +#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L + +#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" +#define NID_id_smime_aa_receiptRequest 212 +#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L + +#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" +#define NID_id_smime_aa_securityLabel 213 +#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L + +#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" +#define NID_id_smime_aa_mlExpandHistory 214 +#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L + +#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" +#define NID_id_smime_aa_contentHint 215 +#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L + +#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" +#define NID_id_smime_aa_msgSigDigest 216 +#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L + +#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" +#define NID_id_smime_aa_encapContentType 217 +#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L + +#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" +#define NID_id_smime_aa_contentIdentifier 218 +#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L + +#define SN_id_smime_aa_macValue "id-smime-aa-macValue" +#define NID_id_smime_aa_macValue 219 +#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L + +#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" +#define NID_id_smime_aa_equivalentLabels 220 +#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L + +#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" +#define NID_id_smime_aa_contentReference 221 +#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L + +#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" +#define NID_id_smime_aa_encrypKeyPref 222 +#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L + +#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" +#define NID_id_smime_aa_signingCertificate 223 +#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L + +#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" +#define NID_id_smime_aa_smimeEncryptCerts 224 +#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L + +#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" +#define NID_id_smime_aa_timeStampToken 225 +#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L + +#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" +#define NID_id_smime_aa_ets_sigPolicyId 226 +#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L + +#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" +#define NID_id_smime_aa_ets_commitmentType 227 +#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L + +#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" +#define NID_id_smime_aa_ets_signerLocation 228 +#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L + +#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" +#define NID_id_smime_aa_ets_signerAttr 229 +#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L + +#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" +#define NID_id_smime_aa_ets_otherSigCert 230 +#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L + +#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" +#define NID_id_smime_aa_ets_contentTimestamp 231 +#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L + +#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" +#define NID_id_smime_aa_ets_CertificateRefs 232 +#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L + +#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" +#define NID_id_smime_aa_ets_RevocationRefs 233 +#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L + +#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" +#define NID_id_smime_aa_ets_certValues 234 +#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L + +#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" +#define NID_id_smime_aa_ets_revocationValues 235 +#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L + +#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" +#define NID_id_smime_aa_ets_escTimeStamp 236 +#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L + +#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" +#define NID_id_smime_aa_ets_certCRLTimestamp 237 +#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L + +#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" +#define NID_id_smime_aa_ets_archiveTimeStamp 238 +#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L + +#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" +#define NID_id_smime_aa_signatureType 239 +#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L + +#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" +#define NID_id_smime_aa_dvcs_dvc 240 +#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L + +#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" +#define NID_id_smime_alg_ESDHwith3DES 241 +#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L + +#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" +#define NID_id_smime_alg_ESDHwithRC2 242 +#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L + +#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" +#define NID_id_smime_alg_3DESwrap 243 +#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L + +#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" +#define NID_id_smime_alg_RC2wrap 244 +#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L + +#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" +#define NID_id_smime_alg_ESDH 245 +#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L + +#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" +#define NID_id_smime_alg_CMS3DESwrap 246 +#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L + +#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" +#define NID_id_smime_alg_CMSRC2wrap 247 +#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L + +#define SN_id_smime_cd_ldap "id-smime-cd-ldap" +#define NID_id_smime_cd_ldap 248 +#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L + +#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" +#define NID_id_smime_spq_ets_sqt_uri 249 +#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L + +#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" +#define NID_id_smime_spq_ets_sqt_unotice 250 +#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L + +#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" +#define NID_id_smime_cti_ets_proofOfOrigin 251 +#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L + +#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" +#define NID_id_smime_cti_ets_proofOfReceipt 252 +#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L + +#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" +#define NID_id_smime_cti_ets_proofOfDelivery 253 +#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L + +#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" +#define NID_id_smime_cti_ets_proofOfSender 254 +#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L + +#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" +#define NID_id_smime_cti_ets_proofOfApproval 255 +#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L + +#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" +#define NID_id_smime_cti_ets_proofOfCreation 256 +#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9,20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9,21L + +#define SN_ms_csp_name "CSPName" +#define LN_ms_csp_name "Microsoft CSP Name" +#define NID_ms_csp_name 417 +#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L + +#define OBJ_certTypes OBJ_pkcs9,22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes,1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes,2L + +#define OBJ_crlTypes OBJ_pkcs9,23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes,1L + +#define OBJ_pkcs12 OBJ_pkcs,12L + +#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds,1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds,3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds,4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds,5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md4 "MD4" +#define LN_md4 "md4" +#define NID_md4 257 +#define OBJ_md4 OBJ_rsadsi,2L,4L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" +#define NID_md5_sha1 114 + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_ms_ext_req "msExtReq" +#define LN_ms_ext_req "Microsoft Extension Request" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +#define SN_ms_smartcard_login "msSmartcardLogin" +#define LN_ms_smartcard_login "Microsoft Smartcardlogin" +#define NID_ms_smartcard_login 648 +#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L + +#define SN_ms_upn "msUPN" +#define LN_ms_upn "Microsoft Universal Principal Name" +#define NID_ms_upn 649 +#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_pkix_mod "id-pkix-mod" +#define NID_id_pkix_mod 258 +#define OBJ_id_pkix_mod OBJ_id_pkix,0L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_qt "id-qt" +#define NID_id_qt 259 +#define OBJ_id_qt OBJ_id_pkix,2L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +#define SN_id_it "id-it" +#define NID_id_it 260 +#define OBJ_id_it OBJ_id_pkix,4L + +#define SN_id_pkip "id-pkip" +#define NID_id_pkip 261 +#define OBJ_id_pkip OBJ_id_pkix,5L + +#define SN_id_alg "id-alg" +#define NID_id_alg 262 +#define OBJ_id_alg OBJ_id_pkix,6L + +#define SN_id_cmc "id-cmc" +#define NID_id_cmc 263 +#define OBJ_id_cmc OBJ_id_pkix,7L + +#define SN_id_on "id-on" +#define NID_id_on 264 +#define OBJ_id_on OBJ_id_pkix,8L + +#define SN_id_pda "id-pda" +#define NID_id_pda 265 +#define OBJ_id_pda OBJ_id_pkix,9L + +#define SN_id_aca "id-aca" +#define NID_id_aca 266 +#define OBJ_id_aca OBJ_id_pkix,10L + +#define SN_id_qcs "id-qcs" +#define NID_id_qcs 267 +#define OBJ_id_qcs OBJ_id_pkix,11L + +#define SN_id_cct "id-cct" +#define NID_id_cct 268 +#define OBJ_id_cct OBJ_id_pkix,12L + +#define SN_id_ppl "id-ppl" +#define NID_id_ppl 662 +#define OBJ_id_ppl OBJ_id_pkix,21L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" +#define NID_id_pkix1_explicit_88 269 +#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L + +#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" +#define NID_id_pkix1_implicit_88 270 +#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L + +#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" +#define NID_id_pkix1_explicit_93 271 +#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L + +#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" +#define NID_id_pkix1_implicit_93 272 +#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L + +#define SN_id_mod_crmf "id-mod-crmf" +#define NID_id_mod_crmf 273 +#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L + +#define SN_id_mod_cmc "id-mod-cmc" +#define NID_id_mod_cmc 274 +#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L + +#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" +#define NID_id_mod_kea_profile_88 275 +#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L + +#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" +#define NID_id_mod_kea_profile_93 276 +#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L + +#define SN_id_mod_cmp "id-mod-cmp" +#define NID_id_mod_cmp 277 +#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L + +#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" +#define NID_id_mod_qualified_cert_88 278 +#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L + +#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" +#define NID_id_mod_qualified_cert_93 279 +#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L + +#define SN_id_mod_attribute_cert "id-mod-attribute-cert" +#define NID_id_mod_attribute_cert 280 +#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L + +#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" +#define NID_id_mod_timestamp_protocol 281 +#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L + +#define SN_id_mod_ocsp "id-mod-ocsp" +#define NID_id_mod_ocsp 282 +#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L + +#define SN_id_mod_dvcs "id-mod-dvcs" +#define NID_id_mod_dvcs 283 +#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L + +#define SN_id_mod_cmp2000 "id-mod-cmp2000" +#define NID_id_mod_cmp2000 284 +#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_biometricInfo "biometricInfo" +#define LN_biometricInfo "Biometric Info" +#define NID_biometricInfo 285 +#define OBJ_biometricInfo OBJ_id_pe,2L + +#define SN_qcStatements "qcStatements" +#define NID_qcStatements 286 +#define OBJ_qcStatements OBJ_id_pe,3L + +#define SN_ac_auditEntity "ac-auditEntity" +#define NID_ac_auditEntity 287 +#define OBJ_ac_auditEntity OBJ_id_pe,4L + +#define SN_ac_targeting "ac-targeting" +#define NID_ac_targeting 288 +#define OBJ_ac_targeting OBJ_id_pe,5L + +#define SN_aaControls "aaControls" +#define NID_aaControls 289 +#define OBJ_aaControls OBJ_id_pe,6L + +#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" +#define NID_sbgp_ipAddrBlock 290 +#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L + +#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" +#define NID_sbgp_autonomousSysNum 291 +#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L + +#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" +#define NID_sbgp_routerIdentifier 292 +#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L + +#define SN_ac_proxying "ac-proxying" +#define NID_ac_proxying 397 +#define OBJ_ac_proxying OBJ_id_pe,10L + +#define SN_sinfo_access "subjectInfoAccess" +#define LN_sinfo_access "Subject Information Access" +#define NID_sinfo_access 398 +#define OBJ_sinfo_access OBJ_id_pe,11L + +#define SN_proxyCertInfo "proxyCertInfo" +#define LN_proxyCertInfo "Proxy Certificate Information" +#define NID_proxyCertInfo 663 +#define OBJ_proxyCertInfo OBJ_id_pe,14L + +#define SN_id_qt_cps "id-qt-cps" +#define LN_id_qt_cps "Policy Qualifier CPS" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_qt,1L + +#define SN_id_qt_unotice "id-qt-unotice" +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_qt,2L + +#define SN_textNotice "textNotice" +#define NID_textNotice 293 +#define OBJ_textNotice OBJ_id_qt,3L + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_ipsecEndSystem "ipsecEndSystem" +#define LN_ipsecEndSystem "IPSec End System" +#define NID_ipsecEndSystem 294 +#define OBJ_ipsecEndSystem OBJ_id_kp,5L + +#define SN_ipsecTunnel "ipsecTunnel" +#define LN_ipsecTunnel "IPSec Tunnel" +#define NID_ipsecTunnel 295 +#define OBJ_ipsecTunnel OBJ_id_kp,6L + +#define SN_ipsecUser "ipsecUser" +#define LN_ipsecUser "IPSec User" +#define NID_ipsecUser 296 +#define OBJ_ipsecUser OBJ_id_kp,7L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L + +#define SN_dvcs "DVCS" +#define LN_dvcs "dvcs" +#define NID_dvcs 297 +#define OBJ_dvcs OBJ_id_kp,10L + +#define SN_id_it_caProtEncCert "id-it-caProtEncCert" +#define NID_id_it_caProtEncCert 298 +#define OBJ_id_it_caProtEncCert OBJ_id_it,1L + +#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" +#define NID_id_it_signKeyPairTypes 299 +#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L + +#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" +#define NID_id_it_encKeyPairTypes 300 +#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L + +#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" +#define NID_id_it_preferredSymmAlg 301 +#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L + +#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" +#define NID_id_it_caKeyUpdateInfo 302 +#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L + +#define SN_id_it_currentCRL "id-it-currentCRL" +#define NID_id_it_currentCRL 303 +#define OBJ_id_it_currentCRL OBJ_id_it,6L + +#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" +#define NID_id_it_unsupportedOIDs 304 +#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L + +#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" +#define NID_id_it_subscriptionRequest 305 +#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L + +#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" +#define NID_id_it_subscriptionResponse 306 +#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L + +#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" +#define NID_id_it_keyPairParamReq 307 +#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L + +#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" +#define NID_id_it_keyPairParamRep 308 +#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L + +#define SN_id_it_revPassphrase "id-it-revPassphrase" +#define NID_id_it_revPassphrase 309 +#define OBJ_id_it_revPassphrase OBJ_id_it,12L + +#define SN_id_it_implicitConfirm "id-it-implicitConfirm" +#define NID_id_it_implicitConfirm 310 +#define OBJ_id_it_implicitConfirm OBJ_id_it,13L + +#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" +#define NID_id_it_confirmWaitTime 311 +#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L + +#define SN_id_it_origPKIMessage "id-it-origPKIMessage" +#define NID_id_it_origPKIMessage 312 +#define OBJ_id_it_origPKIMessage OBJ_id_it,15L + +#define SN_id_regCtrl "id-regCtrl" +#define NID_id_regCtrl 313 +#define OBJ_id_regCtrl OBJ_id_pkip,1L + +#define SN_id_regInfo "id-regInfo" +#define NID_id_regInfo 314 +#define OBJ_id_regInfo OBJ_id_pkip,2L + +#define SN_id_regCtrl_regToken "id-regCtrl-regToken" +#define NID_id_regCtrl_regToken 315 +#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L + +#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" +#define NID_id_regCtrl_authenticator 316 +#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L + +#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" +#define NID_id_regCtrl_pkiPublicationInfo 317 +#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L + +#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" +#define NID_id_regCtrl_pkiArchiveOptions 318 +#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L + +#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" +#define NID_id_regCtrl_oldCertID 319 +#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L + +#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" +#define NID_id_regCtrl_protocolEncrKey 320 +#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L + +#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" +#define NID_id_regInfo_utf8Pairs 321 +#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L + +#define SN_id_regInfo_certReq "id-regInfo-certReq" +#define NID_id_regInfo_certReq 322 +#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L + +#define SN_id_alg_des40 "id-alg-des40" +#define NID_id_alg_des40 323 +#define OBJ_id_alg_des40 OBJ_id_alg,1L + +#define SN_id_alg_noSignature "id-alg-noSignature" +#define NID_id_alg_noSignature 324 +#define OBJ_id_alg_noSignature OBJ_id_alg,2L + +#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" +#define NID_id_alg_dh_sig_hmac_sha1 325 +#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L + +#define SN_id_alg_dh_pop "id-alg-dh-pop" +#define NID_id_alg_dh_pop 326 +#define OBJ_id_alg_dh_pop OBJ_id_alg,4L + +#define SN_id_cmc_statusInfo "id-cmc-statusInfo" +#define NID_id_cmc_statusInfo 327 +#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L + +#define SN_id_cmc_identification "id-cmc-identification" +#define NID_id_cmc_identification 328 +#define OBJ_id_cmc_identification OBJ_id_cmc,2L + +#define SN_id_cmc_identityProof "id-cmc-identityProof" +#define NID_id_cmc_identityProof 329 +#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L + +#define SN_id_cmc_dataReturn "id-cmc-dataReturn" +#define NID_id_cmc_dataReturn 330 +#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L + +#define SN_id_cmc_transactionId "id-cmc-transactionId" +#define NID_id_cmc_transactionId 331 +#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L + +#define SN_id_cmc_senderNonce "id-cmc-senderNonce" +#define NID_id_cmc_senderNonce 332 +#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L + +#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" +#define NID_id_cmc_recipientNonce 333 +#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L + +#define SN_id_cmc_addExtensions "id-cmc-addExtensions" +#define NID_id_cmc_addExtensions 334 +#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L + +#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" +#define NID_id_cmc_encryptedPOP 335 +#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L + +#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" +#define NID_id_cmc_decryptedPOP 336 +#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L + +#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" +#define NID_id_cmc_lraPOPWitness 337 +#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L + +#define SN_id_cmc_getCert "id-cmc-getCert" +#define NID_id_cmc_getCert 338 +#define OBJ_id_cmc_getCert OBJ_id_cmc,15L + +#define SN_id_cmc_getCRL "id-cmc-getCRL" +#define NID_id_cmc_getCRL 339 +#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L + +#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" +#define NID_id_cmc_revokeRequest 340 +#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L + +#define SN_id_cmc_regInfo "id-cmc-regInfo" +#define NID_id_cmc_regInfo 341 +#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L + +#define SN_id_cmc_responseInfo "id-cmc-responseInfo" +#define NID_id_cmc_responseInfo 342 +#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L + +#define SN_id_cmc_queryPending "id-cmc-queryPending" +#define NID_id_cmc_queryPending 343 +#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L + +#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" +#define NID_id_cmc_popLinkRandom 344 +#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L + +#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" +#define NID_id_cmc_popLinkWitness 345 +#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L + +#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" +#define NID_id_cmc_confirmCertAcceptance 346 +#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L + +#define SN_id_on_personalData "id-on-personalData" +#define NID_id_on_personalData 347 +#define OBJ_id_on_personalData OBJ_id_on,1L + +#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" +#define NID_id_pda_dateOfBirth 348 +#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L + +#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" +#define NID_id_pda_placeOfBirth 349 +#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L + +#define SN_id_pda_gender "id-pda-gender" +#define NID_id_pda_gender 351 +#define OBJ_id_pda_gender OBJ_id_pda,3L + +#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" +#define NID_id_pda_countryOfCitizenship 352 +#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L + +#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" +#define NID_id_pda_countryOfResidence 353 +#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L + +#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" +#define NID_id_aca_authenticationInfo 354 +#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L + +#define SN_id_aca_accessIdentity "id-aca-accessIdentity" +#define NID_id_aca_accessIdentity 355 +#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L + +#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" +#define NID_id_aca_chargingIdentity 356 +#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L + +#define SN_id_aca_group "id-aca-group" +#define NID_id_aca_group 357 +#define OBJ_id_aca_group OBJ_id_aca,4L + +#define SN_id_aca_role "id-aca-role" +#define NID_id_aca_role 358 +#define OBJ_id_aca_role OBJ_id_aca,5L + +#define SN_id_aca_encAttrs "id-aca-encAttrs" +#define NID_id_aca_encAttrs 399 +#define OBJ_id_aca_encAttrs OBJ_id_aca,6L + +#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" +#define NID_id_qcs_pkixQCSyntax_v1 359 +#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L + +#define SN_id_cct_crs "id-cct-crs" +#define NID_id_cct_crs 360 +#define OBJ_id_cct_crs OBJ_id_cct,1L + +#define SN_id_cct_PKIData "id-cct-PKIData" +#define NID_id_cct_PKIData 361 +#define OBJ_id_cct_PKIData OBJ_id_cct,2L + +#define SN_id_cct_PKIResponse "id-cct-PKIResponse" +#define NID_id_cct_PKIResponse 362 +#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L + +#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" +#define LN_id_ppl_anyLanguage "Any language" +#define NID_id_ppl_anyLanguage 664 +#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L + +#define SN_id_ppl_inheritAll "id-ppl-inheritAll" +#define LN_id_ppl_inheritAll "Inherit all" +#define NID_id_ppl_inheritAll 665 +#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L + +#define SN_Independent "id-ppl-independent" +#define LN_Independent "Independent" +#define NID_Independent 667 +#define OBJ_Independent OBJ_id_ppl,2L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_ad_timeStamping "ad_timestamping" +#define LN_ad_timeStamping "AD Time Stamping" +#define NID_ad_timeStamping 363 +#define OBJ_ad_timeStamping OBJ_id_ad,3L + +#define SN_ad_dvcs "AD_DVCS" +#define LN_ad_dvcs "ad dvcs" +#define NID_ad_dvcs 364 +#define OBJ_ad_dvcs OBJ_id_ad,4L + +#define OBJ_id_pkix_OCSP OBJ_ad_OCSP + +#define SN_id_pkix_OCSP_basic "basicOCSPResponse" +#define LN_id_pkix_OCSP_basic "Basic OCSP Response" +#define NID_id_pkix_OCSP_basic 365 +#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L + +#define SN_id_pkix_OCSP_Nonce "Nonce" +#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" +#define NID_id_pkix_OCSP_Nonce 366 +#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L + +#define SN_id_pkix_OCSP_CrlID "CrlID" +#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" +#define NID_id_pkix_OCSP_CrlID 367 +#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L + +#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" +#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" +#define NID_id_pkix_OCSP_acceptableResponses 368 +#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L + +#define SN_id_pkix_OCSP_noCheck "noCheck" +#define LN_id_pkix_OCSP_noCheck "OCSP No Check" +#define NID_id_pkix_OCSP_noCheck 369 +#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L + +#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" +#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" +#define NID_id_pkix_OCSP_archiveCutoff 370 +#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L + +#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" +#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" +#define NID_id_pkix_OCSP_serviceLocator 371 +#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L + +#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" +#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" +#define NID_id_pkix_OCSP_extendedStatus 372 +#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L + +#define SN_id_pkix_OCSP_valid "valid" +#define NID_id_pkix_OCSP_valid 373 +#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L + +#define SN_id_pkix_OCSP_path "path" +#define NID_id_pkix_OCSP_path 374 +#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L + +#define SN_id_pkix_OCSP_trustRoot "trustRoot" +#define LN_id_pkix_OCSP_trustRoot "Trust Root" +#define NID_id_pkix_OCSP_trustRoot 375 +#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L + +#define SN_algorithm "algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 376 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_rsaSignature "rsaSignature" +#define NID_rsaSignature 377 +#define OBJ_rsaSignature OBJ_algorithm,11L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_ecb "DES-EDE" +#define LN_des_ede_ecb "des-ede" +#define NID_des_ede_ecb 32 +#define OBJ_des_ede_ecb OBJ_algorithm,17L + +#define SN_des_ede3_ecb "DES-EDE3" +#define LN_des_ede3_ecb "des-ede3" +#define NID_des_ede3_ecb 33 + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +#define SN_X500 "X500" +#define LN_X500 "directory services (X.500)" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define SN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_surname "SN" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define LN_streetAddress "streetAddress" +#define NID_streetAddress 660 +#define OBJ_streetAddress OBJ_X509,9L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +#define LN_postalCode "postalCode" +#define NID_postalCode 661 +#define OBJ_postalCode OBJ_X509,17L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_givenName "GN" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define LN_generationQualifier "generationQualifier" +#define NID_generationQualifier 509 +#define OBJ_generationQualifier OBJ_X509,44L + +#define LN_x500UniqueIdentifier "x500UniqueIdentifier" +#define NID_x500UniqueIdentifier 503 +#define OBJ_x500UniqueIdentifier OBJ_X509,45L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define LN_pseudonym "pseudonym" +#define NID_pseudonym 510 +#define OBJ_pseudonym OBJ_X509,65L + +#define SN_role "role" +#define LN_role "role" +#define NID_role 400 +#define OBJ_role OBJ_X509,72L + +#define SN_X500algorithms "X500algorithms" +#define LN_X500algorithms "directory services - algorithms" +#define NID_X500algorithms 378 +#define OBJ_X500algorithms OBJ_X500,8L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500algorithms,1L,1L + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2WithRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 OBJ_X500algorithms,3L,101L + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce OBJ_X500,29L + +#define SN_subject_directory_attributes "subjectDirectoryAttributes" +#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" +#define NID_subject_directory_attributes 769 +#define OBJ_subject_directory_attributes OBJ_id_ce,9L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "X509v3 CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_issuing_distribution_point "issuingDistributionPoint" +#define LN_issuing_distribution_point "X509v3 Issuing Distrubution Point" +#define NID_issuing_distribution_point 770 +#define OBJ_issuing_distribution_point OBJ_id_ce,28L + +#define SN_certificate_issuer "certificateIssuer" +#define LN_certificate_issuer "X509v3 Certificate Issuer" +#define NID_certificate_issuer 771 +#define OBJ_certificate_issuer OBJ_id_ce,29L + +#define SN_name_constraints "nameConstraints" +#define LN_name_constraints "X509v3 Name Constraints" +#define NID_name_constraints 666 +#define OBJ_name_constraints OBJ_id_ce,30L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_any_policy "anyPolicy" +#define LN_any_policy "X509v3 Any Policy" +#define NID_any_policy 746 +#define OBJ_any_policy OBJ_certificate_policies,0L + +#define SN_policy_mappings "policyMappings" +#define LN_policy_mappings "X509v3 Policy Mappings" +#define NID_policy_mappings 747 +#define OBJ_policy_mappings OBJ_id_ce,33L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_policy_constraints "policyConstraints" +#define LN_policy_constraints "X509v3 Policy Constraints" +#define NID_policy_constraints 401 +#define OBJ_policy_constraints OBJ_id_ce,36L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37L + +#define SN_inhibit_any_policy "inhibitAnyPolicy" +#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" +#define NID_inhibit_any_policy 748 +#define OBJ_inhibit_any_policy OBJ_id_ce,54L + +#define SN_target_information "targetInformation" +#define LN_target_information "X509v3 AC Targeting" +#define NID_target_information 402 +#define OBJ_target_information OBJ_id_ce,55L + +#define SN_no_rev_avail "noRevAvail" +#define LN_no_rev_avail "X509v3 No Revocation Available" +#define NID_no_rev_avail 403 +#define OBJ_no_rev_avail OBJ_id_ce,56L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_org "ORG" +#define LN_org "org" +#define NID_org 379 +#define OBJ_org OBJ_iso,3L + +#define SN_dod "DOD" +#define LN_dod "dod" +#define NID_dod 380 +#define OBJ_dod OBJ_org,6L + +#define SN_iana "IANA" +#define LN_iana "iana" +#define NID_iana 381 +#define OBJ_iana OBJ_dod,1L + +#define OBJ_internet OBJ_iana + +#define SN_Directory "directory" +#define LN_Directory "Directory" +#define NID_Directory 382 +#define OBJ_Directory OBJ_internet,1L + +#define SN_Management "mgmt" +#define LN_Management "Management" +#define NID_Management 383 +#define OBJ_Management OBJ_internet,2L + +#define SN_Experimental "experimental" +#define LN_Experimental "Experimental" +#define NID_Experimental 384 +#define OBJ_Experimental OBJ_internet,3L + +#define SN_Private "private" +#define LN_Private "Private" +#define NID_Private 385 +#define OBJ_Private OBJ_internet,4L + +#define SN_Security "security" +#define LN_Security "Security" +#define NID_Security 386 +#define OBJ_Security OBJ_internet,5L + +#define SN_SNMPv2 "snmpv2" +#define LN_SNMPv2 "SNMPv2" +#define NID_SNMPv2 387 +#define OBJ_SNMPv2 OBJ_internet,6L + +#define LN_Mail "Mail" +#define NID_Mail 388 +#define OBJ_Mail OBJ_internet,7L + +#define SN_Enterprises "enterprises" +#define LN_Enterprises "Enterprises" +#define NID_Enterprises 389 +#define OBJ_Enterprises OBJ_Private,1L + +#define SN_dcObject "dcobject" +#define LN_dcObject "dcObject" +#define NID_dcObject 390 +#define OBJ_dcObject OBJ_Enterprises,1466L,344L + +#define SN_mime_mhs "mime-mhs" +#define LN_mime_mhs "MIME MHS" +#define NID_mime_mhs 504 +#define OBJ_mime_mhs OBJ_Mail,1L + +#define SN_mime_mhs_headings "mime-mhs-headings" +#define LN_mime_mhs_headings "mime-mhs-headings" +#define NID_mime_mhs_headings 505 +#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L + +#define SN_mime_mhs_bodies "mime-mhs-bodies" +#define LN_mime_mhs_bodies "mime-mhs-bodies" +#define NID_mime_mhs_bodies 506 +#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L + +#define SN_id_hex_partial_message "id-hex-partial-message" +#define LN_id_hex_partial_message "id-hex-partial-message" +#define NID_id_hex_partial_message 507 +#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L + +#define SN_id_hex_multipart_message "id-hex-multipart-message" +#define LN_id_hex_multipart_message "id-hex-multipart-message" +#define NID_id_hex_multipart_message 508 +#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define OBJ_csor 2L,16L,840L,1L,101L,3L + +#define OBJ_nistAlgorithms OBJ_csor,4L + +#define OBJ_aes OBJ_nistAlgorithms,1L + +#define SN_aes_128_ecb "AES-128-ECB" +#define LN_aes_128_ecb "aes-128-ecb" +#define NID_aes_128_ecb 418 +#define OBJ_aes_128_ecb OBJ_aes,1L + +#define SN_aes_128_cbc "AES-128-CBC" +#define LN_aes_128_cbc "aes-128-cbc" +#define NID_aes_128_cbc 419 +#define OBJ_aes_128_cbc OBJ_aes,2L + +#define SN_aes_128_ofb128 "AES-128-OFB" +#define LN_aes_128_ofb128 "aes-128-ofb" +#define NID_aes_128_ofb128 420 +#define OBJ_aes_128_ofb128 OBJ_aes,3L + +#define SN_aes_128_cfb128 "AES-128-CFB" +#define LN_aes_128_cfb128 "aes-128-cfb" +#define NID_aes_128_cfb128 421 +#define OBJ_aes_128_cfb128 OBJ_aes,4L + +#define SN_aes_192_ecb "AES-192-ECB" +#define LN_aes_192_ecb "aes-192-ecb" +#define NID_aes_192_ecb 422 +#define OBJ_aes_192_ecb OBJ_aes,21L + +#define SN_aes_192_cbc "AES-192-CBC" +#define LN_aes_192_cbc "aes-192-cbc" +#define NID_aes_192_cbc 423 +#define OBJ_aes_192_cbc OBJ_aes,22L + +#define SN_aes_192_ofb128 "AES-192-OFB" +#define LN_aes_192_ofb128 "aes-192-ofb" +#define NID_aes_192_ofb128 424 +#define OBJ_aes_192_ofb128 OBJ_aes,23L + +#define SN_aes_192_cfb128 "AES-192-CFB" +#define LN_aes_192_cfb128 "aes-192-cfb" +#define NID_aes_192_cfb128 425 +#define OBJ_aes_192_cfb128 OBJ_aes,24L + +#define SN_aes_256_ecb "AES-256-ECB" +#define LN_aes_256_ecb "aes-256-ecb" +#define NID_aes_256_ecb 426 +#define OBJ_aes_256_ecb OBJ_aes,41L + +#define SN_aes_256_cbc "AES-256-CBC" +#define LN_aes_256_cbc "aes-256-cbc" +#define NID_aes_256_cbc 427 +#define OBJ_aes_256_cbc OBJ_aes,42L + +#define SN_aes_256_ofb128 "AES-256-OFB" +#define LN_aes_256_ofb128 "aes-256-ofb" +#define NID_aes_256_ofb128 428 +#define OBJ_aes_256_ofb128 OBJ_aes,43L + +#define SN_aes_256_cfb128 "AES-256-CFB" +#define LN_aes_256_cfb128 "aes-256-cfb" +#define NID_aes_256_cfb128 429 +#define OBJ_aes_256_cfb128 OBJ_aes,44L + +#define SN_aes_128_cfb1 "AES-128-CFB1" +#define LN_aes_128_cfb1 "aes-128-cfb1" +#define NID_aes_128_cfb1 650 + +#define SN_aes_192_cfb1 "AES-192-CFB1" +#define LN_aes_192_cfb1 "aes-192-cfb1" +#define NID_aes_192_cfb1 651 + +#define SN_aes_256_cfb1 "AES-256-CFB1" +#define LN_aes_256_cfb1 "aes-256-cfb1" +#define NID_aes_256_cfb1 652 + +#define SN_aes_128_cfb8 "AES-128-CFB8" +#define LN_aes_128_cfb8 "aes-128-cfb8" +#define NID_aes_128_cfb8 653 + +#define SN_aes_192_cfb8 "AES-192-CFB8" +#define LN_aes_192_cfb8 "aes-192-cfb8" +#define NID_aes_192_cfb8 654 + +#define SN_aes_256_cfb8 "AES-256-CFB8" +#define LN_aes_256_cfb8 "aes-256-cfb8" +#define NID_aes_256_cfb8 655 + +#define SN_des_cfb1 "DES-CFB1" +#define LN_des_cfb1 "des-cfb1" +#define NID_des_cfb1 656 + +#define SN_des_cfb8 "DES-CFB8" +#define LN_des_cfb8 "des-cfb8" +#define NID_des_cfb8 657 + +#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" +#define LN_des_ede3_cfb1 "des-ede3-cfb1" +#define NID_des_ede3_cfb1 658 + +#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" +#define LN_des_ede3_cfb8 "des-ede3-cfb8" +#define NID_des_ede3_cfb8 659 + +#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L + +#define SN_sha256 "SHA256" +#define LN_sha256 "sha256" +#define NID_sha256 672 +#define OBJ_sha256 OBJ_nist_hashalgs,1L + +#define SN_sha384 "SHA384" +#define LN_sha384 "sha384" +#define NID_sha384 673 +#define OBJ_sha384 OBJ_nist_hashalgs,2L + +#define SN_sha512 "SHA512" +#define LN_sha512 "sha512" +#define NID_sha512 674 +#define OBJ_sha512 OBJ_nist_hashalgs,3L + +#define SN_sha224 "SHA224" +#define LN_sha224 "sha224" +#define NID_sha224 675 +#define OBJ_sha224 OBJ_nist_hashalgs,4L + +#define SN_hold_instruction_code "holdInstructionCode" +#define LN_hold_instruction_code "Hold Instruction Code" +#define NID_hold_instruction_code 430 +#define OBJ_hold_instruction_code OBJ_id_ce,23L + +#define OBJ_holdInstruction OBJ_X9_57,2L + +#define SN_hold_instruction_none "holdInstructionNone" +#define LN_hold_instruction_none "Hold Instruction None" +#define NID_hold_instruction_none 431 +#define OBJ_hold_instruction_none OBJ_holdInstruction,1L + +#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" +#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" +#define NID_hold_instruction_call_issuer 432 +#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L + +#define SN_hold_instruction_reject "holdInstructionReject" +#define LN_hold_instruction_reject "Hold Instruction Reject" +#define NID_hold_instruction_reject 433 +#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L + +#define SN_data "data" +#define NID_data 434 +#define OBJ_data OBJ_itu_t,9L + +#define SN_pss "pss" +#define NID_pss 435 +#define OBJ_pss OBJ_data,2342L + +#define SN_ucl "ucl" +#define NID_ucl 436 +#define OBJ_ucl OBJ_pss,19200300L + +#define SN_pilot "pilot" +#define NID_pilot 437 +#define OBJ_pilot OBJ_ucl,100L + +#define LN_pilotAttributeType "pilotAttributeType" +#define NID_pilotAttributeType 438 +#define OBJ_pilotAttributeType OBJ_pilot,1L + +#define LN_pilotAttributeSyntax "pilotAttributeSyntax" +#define NID_pilotAttributeSyntax 439 +#define OBJ_pilotAttributeSyntax OBJ_pilot,3L + +#define LN_pilotObjectClass "pilotObjectClass" +#define NID_pilotObjectClass 440 +#define OBJ_pilotObjectClass OBJ_pilot,4L + +#define LN_pilotGroups "pilotGroups" +#define NID_pilotGroups 441 +#define OBJ_pilotGroups OBJ_pilot,10L + +#define LN_iA5StringSyntax "iA5StringSyntax" +#define NID_iA5StringSyntax 442 +#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L + +#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" +#define NID_caseIgnoreIA5StringSyntax 443 +#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L + +#define LN_pilotObject "pilotObject" +#define NID_pilotObject 444 +#define OBJ_pilotObject OBJ_pilotObjectClass,3L + +#define LN_pilotPerson "pilotPerson" +#define NID_pilotPerson 445 +#define OBJ_pilotPerson OBJ_pilotObjectClass,4L + +#define SN_account "account" +#define NID_account 446 +#define OBJ_account OBJ_pilotObjectClass,5L + +#define SN_document "document" +#define NID_document 447 +#define OBJ_document OBJ_pilotObjectClass,6L + +#define SN_room "room" +#define NID_room 448 +#define OBJ_room OBJ_pilotObjectClass,7L + +#define LN_documentSeries "documentSeries" +#define NID_documentSeries 449 +#define OBJ_documentSeries OBJ_pilotObjectClass,9L + +#define SN_Domain "domain" +#define LN_Domain "Domain" +#define NID_Domain 392 +#define OBJ_Domain OBJ_pilotObjectClass,13L + +#define LN_rFC822localPart "rFC822localPart" +#define NID_rFC822localPart 450 +#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L + +#define LN_dNSDomain "dNSDomain" +#define NID_dNSDomain 451 +#define OBJ_dNSDomain OBJ_pilotObjectClass,15L + +#define LN_domainRelatedObject "domainRelatedObject" +#define NID_domainRelatedObject 452 +#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L + +#define LN_friendlyCountry "friendlyCountry" +#define NID_friendlyCountry 453 +#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L + +#define LN_simpleSecurityObject "simpleSecurityObject" +#define NID_simpleSecurityObject 454 +#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L + +#define LN_pilotOrganization "pilotOrganization" +#define NID_pilotOrganization 455 +#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L + +#define LN_pilotDSA "pilotDSA" +#define NID_pilotDSA 456 +#define OBJ_pilotDSA OBJ_pilotObjectClass,21L + +#define LN_qualityLabelledData "qualityLabelledData" +#define NID_qualityLabelledData 457 +#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L + +#define SN_userId "UID" +#define LN_userId "userId" +#define NID_userId 458 +#define OBJ_userId OBJ_pilotAttributeType,1L + +#define LN_textEncodedORAddress "textEncodedORAddress" +#define NID_textEncodedORAddress 459 +#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L + +#define SN_rfc822Mailbox "mail" +#define LN_rfc822Mailbox "rfc822Mailbox" +#define NID_rfc822Mailbox 460 +#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L + +#define SN_info "info" +#define NID_info 461 +#define OBJ_info OBJ_pilotAttributeType,4L + +#define LN_favouriteDrink "favouriteDrink" +#define NID_favouriteDrink 462 +#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L + +#define LN_roomNumber "roomNumber" +#define NID_roomNumber 463 +#define OBJ_roomNumber OBJ_pilotAttributeType,6L + +#define SN_photo "photo" +#define NID_photo 464 +#define OBJ_photo OBJ_pilotAttributeType,7L + +#define LN_userClass "userClass" +#define NID_userClass 465 +#define OBJ_userClass OBJ_pilotAttributeType,8L + +#define SN_host "host" +#define NID_host 466 +#define OBJ_host OBJ_pilotAttributeType,9L + +#define SN_manager "manager" +#define NID_manager 467 +#define OBJ_manager OBJ_pilotAttributeType,10L + +#define LN_documentIdentifier "documentIdentifier" +#define NID_documentIdentifier 468 +#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L + +#define LN_documentTitle "documentTitle" +#define NID_documentTitle 469 +#define OBJ_documentTitle OBJ_pilotAttributeType,12L + +#define LN_documentVersion "documentVersion" +#define NID_documentVersion 470 +#define OBJ_documentVersion OBJ_pilotAttributeType,13L + +#define LN_documentAuthor "documentAuthor" +#define NID_documentAuthor 471 +#define OBJ_documentAuthor OBJ_pilotAttributeType,14L + +#define LN_documentLocation "documentLocation" +#define NID_documentLocation 472 +#define OBJ_documentLocation OBJ_pilotAttributeType,15L + +#define LN_homeTelephoneNumber "homeTelephoneNumber" +#define NID_homeTelephoneNumber 473 +#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L + +#define SN_secretary "secretary" +#define NID_secretary 474 +#define OBJ_secretary OBJ_pilotAttributeType,21L + +#define LN_otherMailbox "otherMailbox" +#define NID_otherMailbox 475 +#define OBJ_otherMailbox OBJ_pilotAttributeType,22L + +#define LN_lastModifiedTime "lastModifiedTime" +#define NID_lastModifiedTime 476 +#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L + +#define LN_lastModifiedBy "lastModifiedBy" +#define NID_lastModifiedBy 477 +#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L + +#define SN_domainComponent "DC" +#define LN_domainComponent "domainComponent" +#define NID_domainComponent 391 +#define OBJ_domainComponent OBJ_pilotAttributeType,25L + +#define LN_aRecord "aRecord" +#define NID_aRecord 478 +#define OBJ_aRecord OBJ_pilotAttributeType,26L + +#define LN_pilotAttributeType27 "pilotAttributeType27" +#define NID_pilotAttributeType27 479 +#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L + +#define LN_mXRecord "mXRecord" +#define NID_mXRecord 480 +#define OBJ_mXRecord OBJ_pilotAttributeType,28L + +#define LN_nSRecord "nSRecord" +#define NID_nSRecord 481 +#define OBJ_nSRecord OBJ_pilotAttributeType,29L + +#define LN_sOARecord "sOARecord" +#define NID_sOARecord 482 +#define OBJ_sOARecord OBJ_pilotAttributeType,30L + +#define LN_cNAMERecord "cNAMERecord" +#define NID_cNAMERecord 483 +#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L + +#define LN_associatedDomain "associatedDomain" +#define NID_associatedDomain 484 +#define OBJ_associatedDomain OBJ_pilotAttributeType,37L + +#define LN_associatedName "associatedName" +#define NID_associatedName 485 +#define OBJ_associatedName OBJ_pilotAttributeType,38L + +#define LN_homePostalAddress "homePostalAddress" +#define NID_homePostalAddress 486 +#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L + +#define LN_personalTitle "personalTitle" +#define NID_personalTitle 487 +#define OBJ_personalTitle OBJ_pilotAttributeType,40L + +#define LN_mobileTelephoneNumber "mobileTelephoneNumber" +#define NID_mobileTelephoneNumber 488 +#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L + +#define LN_pagerTelephoneNumber "pagerTelephoneNumber" +#define NID_pagerTelephoneNumber 489 +#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L + +#define LN_friendlyCountryName "friendlyCountryName" +#define NID_friendlyCountryName 490 +#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L + +#define LN_organizationalStatus "organizationalStatus" +#define NID_organizationalStatus 491 +#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L + +#define LN_janetMailbox "janetMailbox" +#define NID_janetMailbox 492 +#define OBJ_janetMailbox OBJ_pilotAttributeType,46L + +#define LN_mailPreferenceOption "mailPreferenceOption" +#define NID_mailPreferenceOption 493 +#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L + +#define LN_buildingName "buildingName" +#define NID_buildingName 494 +#define OBJ_buildingName OBJ_pilotAttributeType,48L + +#define LN_dSAQuality "dSAQuality" +#define NID_dSAQuality 495 +#define OBJ_dSAQuality OBJ_pilotAttributeType,49L + +#define LN_singleLevelQuality "singleLevelQuality" +#define NID_singleLevelQuality 496 +#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L + +#define LN_subtreeMinimumQuality "subtreeMinimumQuality" +#define NID_subtreeMinimumQuality 497 +#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L + +#define LN_subtreeMaximumQuality "subtreeMaximumQuality" +#define NID_subtreeMaximumQuality 498 +#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L + +#define LN_personalSignature "personalSignature" +#define NID_personalSignature 499 +#define OBJ_personalSignature OBJ_pilotAttributeType,53L + +#define LN_dITRedirect "dITRedirect" +#define NID_dITRedirect 500 +#define OBJ_dITRedirect OBJ_pilotAttributeType,54L + +#define SN_audio "audio" +#define NID_audio 501 +#define OBJ_audio OBJ_pilotAttributeType,55L + +#define LN_documentPublisher "documentPublisher" +#define NID_documentPublisher 502 +#define OBJ_documentPublisher OBJ_pilotAttributeType,56L + +#define SN_id_set "id-set" +#define LN_id_set "Secure Electronic Transactions" +#define NID_id_set 512 +#define OBJ_id_set OBJ_international_organizations,42L + +#define SN_set_ctype "set-ctype" +#define LN_set_ctype "content types" +#define NID_set_ctype 513 +#define OBJ_set_ctype OBJ_id_set,0L + +#define SN_set_msgExt "set-msgExt" +#define LN_set_msgExt "message extensions" +#define NID_set_msgExt 514 +#define OBJ_set_msgExt OBJ_id_set,1L + +#define SN_set_attr "set-attr" +#define NID_set_attr 515 +#define OBJ_set_attr OBJ_id_set,3L + +#define SN_set_policy "set-policy" +#define NID_set_policy 516 +#define OBJ_set_policy OBJ_id_set,5L + +#define SN_set_certExt "set-certExt" +#define LN_set_certExt "certificate extensions" +#define NID_set_certExt 517 +#define OBJ_set_certExt OBJ_id_set,7L + +#define SN_set_brand "set-brand" +#define NID_set_brand 518 +#define OBJ_set_brand OBJ_id_set,8L + +#define SN_setct_PANData "setct-PANData" +#define NID_setct_PANData 519 +#define OBJ_setct_PANData OBJ_set_ctype,0L + +#define SN_setct_PANToken "setct-PANToken" +#define NID_setct_PANToken 520 +#define OBJ_setct_PANToken OBJ_set_ctype,1L + +#define SN_setct_PANOnly "setct-PANOnly" +#define NID_setct_PANOnly 521 +#define OBJ_setct_PANOnly OBJ_set_ctype,2L + +#define SN_setct_OIData "setct-OIData" +#define NID_setct_OIData 522 +#define OBJ_setct_OIData OBJ_set_ctype,3L + +#define SN_setct_PI "setct-PI" +#define NID_setct_PI 523 +#define OBJ_setct_PI OBJ_set_ctype,4L + +#define SN_setct_PIData "setct-PIData" +#define NID_setct_PIData 524 +#define OBJ_setct_PIData OBJ_set_ctype,5L + +#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" +#define NID_setct_PIDataUnsigned 525 +#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L + +#define SN_setct_HODInput "setct-HODInput" +#define NID_setct_HODInput 526 +#define OBJ_setct_HODInput OBJ_set_ctype,7L + +#define SN_setct_AuthResBaggage "setct-AuthResBaggage" +#define NID_setct_AuthResBaggage 527 +#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L + +#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" +#define NID_setct_AuthRevReqBaggage 528 +#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L + +#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" +#define NID_setct_AuthRevResBaggage 529 +#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L + +#define SN_setct_CapTokenSeq "setct-CapTokenSeq" +#define NID_setct_CapTokenSeq 530 +#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L + +#define SN_setct_PInitResData "setct-PInitResData" +#define NID_setct_PInitResData 531 +#define OBJ_setct_PInitResData OBJ_set_ctype,12L + +#define SN_setct_PI_TBS "setct-PI-TBS" +#define NID_setct_PI_TBS 532 +#define OBJ_setct_PI_TBS OBJ_set_ctype,13L + +#define SN_setct_PResData "setct-PResData" +#define NID_setct_PResData 533 +#define OBJ_setct_PResData OBJ_set_ctype,14L + +#define SN_setct_AuthReqTBS "setct-AuthReqTBS" +#define NID_setct_AuthReqTBS 534 +#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L + +#define SN_setct_AuthResTBS "setct-AuthResTBS" +#define NID_setct_AuthResTBS 535 +#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L + +#define SN_setct_AuthResTBSX "setct-AuthResTBSX" +#define NID_setct_AuthResTBSX 536 +#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L + +#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" +#define NID_setct_AuthTokenTBS 537 +#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L + +#define SN_setct_CapTokenData "setct-CapTokenData" +#define NID_setct_CapTokenData 538 +#define OBJ_setct_CapTokenData OBJ_set_ctype,20L + +#define SN_setct_CapTokenTBS "setct-CapTokenTBS" +#define NID_setct_CapTokenTBS 539 +#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L + +#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" +#define NID_setct_AcqCardCodeMsg 540 +#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L + +#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" +#define NID_setct_AuthRevReqTBS 541 +#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L + +#define SN_setct_AuthRevResData "setct-AuthRevResData" +#define NID_setct_AuthRevResData 542 +#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L + +#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" +#define NID_setct_AuthRevResTBS 543 +#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L + +#define SN_setct_CapReqTBS "setct-CapReqTBS" +#define NID_setct_CapReqTBS 544 +#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L + +#define SN_setct_CapReqTBSX "setct-CapReqTBSX" +#define NID_setct_CapReqTBSX 545 +#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L + +#define SN_setct_CapResData "setct-CapResData" +#define NID_setct_CapResData 546 +#define OBJ_setct_CapResData OBJ_set_ctype,28L + +#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" +#define NID_setct_CapRevReqTBS 547 +#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L + +#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" +#define NID_setct_CapRevReqTBSX 548 +#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L + +#define SN_setct_CapRevResData "setct-CapRevResData" +#define NID_setct_CapRevResData 549 +#define OBJ_setct_CapRevResData OBJ_set_ctype,31L + +#define SN_setct_CredReqTBS "setct-CredReqTBS" +#define NID_setct_CredReqTBS 550 +#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L + +#define SN_setct_CredReqTBSX "setct-CredReqTBSX" +#define NID_setct_CredReqTBSX 551 +#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L + +#define SN_setct_CredResData "setct-CredResData" +#define NID_setct_CredResData 552 +#define OBJ_setct_CredResData OBJ_set_ctype,34L + +#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" +#define NID_setct_CredRevReqTBS 553 +#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L + +#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" +#define NID_setct_CredRevReqTBSX 554 +#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L + +#define SN_setct_CredRevResData "setct-CredRevResData" +#define NID_setct_CredRevResData 555 +#define OBJ_setct_CredRevResData OBJ_set_ctype,37L + +#define SN_setct_PCertReqData "setct-PCertReqData" +#define NID_setct_PCertReqData 556 +#define OBJ_setct_PCertReqData OBJ_set_ctype,38L + +#define SN_setct_PCertResTBS "setct-PCertResTBS" +#define NID_setct_PCertResTBS 557 +#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L + +#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" +#define NID_setct_BatchAdminReqData 558 +#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L + +#define SN_setct_BatchAdminResData "setct-BatchAdminResData" +#define NID_setct_BatchAdminResData 559 +#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L + +#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" +#define NID_setct_CardCInitResTBS 560 +#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L + +#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" +#define NID_setct_MeAqCInitResTBS 561 +#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L + +#define SN_setct_RegFormResTBS "setct-RegFormResTBS" +#define NID_setct_RegFormResTBS 562 +#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L + +#define SN_setct_CertReqData "setct-CertReqData" +#define NID_setct_CertReqData 563 +#define OBJ_setct_CertReqData OBJ_set_ctype,45L + +#define SN_setct_CertReqTBS "setct-CertReqTBS" +#define NID_setct_CertReqTBS 564 +#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L + +#define SN_setct_CertResData "setct-CertResData" +#define NID_setct_CertResData 565 +#define OBJ_setct_CertResData OBJ_set_ctype,47L + +#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" +#define NID_setct_CertInqReqTBS 566 +#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L + +#define SN_setct_ErrorTBS "setct-ErrorTBS" +#define NID_setct_ErrorTBS 567 +#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L + +#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" +#define NID_setct_PIDualSignedTBE 568 +#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L + +#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" +#define NID_setct_PIUnsignedTBE 569 +#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L + +#define SN_setct_AuthReqTBE "setct-AuthReqTBE" +#define NID_setct_AuthReqTBE 570 +#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L + +#define SN_setct_AuthResTBE "setct-AuthResTBE" +#define NID_setct_AuthResTBE 571 +#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L + +#define SN_setct_AuthResTBEX "setct-AuthResTBEX" +#define NID_setct_AuthResTBEX 572 +#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L + +#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" +#define NID_setct_AuthTokenTBE 573 +#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L + +#define SN_setct_CapTokenTBE "setct-CapTokenTBE" +#define NID_setct_CapTokenTBE 574 +#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L + +#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" +#define NID_setct_CapTokenTBEX 575 +#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L + +#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" +#define NID_setct_AcqCardCodeMsgTBE 576 +#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L + +#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" +#define NID_setct_AuthRevReqTBE 577 +#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L + +#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" +#define NID_setct_AuthRevResTBE 578 +#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L + +#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" +#define NID_setct_AuthRevResTBEB 579 +#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L + +#define SN_setct_CapReqTBE "setct-CapReqTBE" +#define NID_setct_CapReqTBE 580 +#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L + +#define SN_setct_CapReqTBEX "setct-CapReqTBEX" +#define NID_setct_CapReqTBEX 581 +#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L + +#define SN_setct_CapResTBE "setct-CapResTBE" +#define NID_setct_CapResTBE 582 +#define OBJ_setct_CapResTBE OBJ_set_ctype,64L + +#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" +#define NID_setct_CapRevReqTBE 583 +#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L + +#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" +#define NID_setct_CapRevReqTBEX 584 +#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L + +#define SN_setct_CapRevResTBE "setct-CapRevResTBE" +#define NID_setct_CapRevResTBE 585 +#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L + +#define SN_setct_CredReqTBE "setct-CredReqTBE" +#define NID_setct_CredReqTBE 586 +#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L + +#define SN_setct_CredReqTBEX "setct-CredReqTBEX" +#define NID_setct_CredReqTBEX 587 +#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L + +#define SN_setct_CredResTBE "setct-CredResTBE" +#define NID_setct_CredResTBE 588 +#define OBJ_setct_CredResTBE OBJ_set_ctype,70L + +#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" +#define NID_setct_CredRevReqTBE 589 +#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L + +#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" +#define NID_setct_CredRevReqTBEX 590 +#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L + +#define SN_setct_CredRevResTBE "setct-CredRevResTBE" +#define NID_setct_CredRevResTBE 591 +#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L + +#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" +#define NID_setct_BatchAdminReqTBE 592 +#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L + +#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" +#define NID_setct_BatchAdminResTBE 593 +#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L + +#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" +#define NID_setct_RegFormReqTBE 594 +#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L + +#define SN_setct_CertReqTBE "setct-CertReqTBE" +#define NID_setct_CertReqTBE 595 +#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L + +#define SN_setct_CertReqTBEX "setct-CertReqTBEX" +#define NID_setct_CertReqTBEX 596 +#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L + +#define SN_setct_CertResTBE "setct-CertResTBE" +#define NID_setct_CertResTBE 597 +#define OBJ_setct_CertResTBE OBJ_set_ctype,79L + +#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" +#define NID_setct_CRLNotificationTBS 598 +#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L + +#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" +#define NID_setct_CRLNotificationResTBS 599 +#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L + +#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" +#define NID_setct_BCIDistributionTBS 600 +#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L + +#define SN_setext_genCrypt "setext-genCrypt" +#define LN_setext_genCrypt "generic cryptogram" +#define NID_setext_genCrypt 601 +#define OBJ_setext_genCrypt OBJ_set_msgExt,1L + +#define SN_setext_miAuth "setext-miAuth" +#define LN_setext_miAuth "merchant initiated auth" +#define NID_setext_miAuth 602 +#define OBJ_setext_miAuth OBJ_set_msgExt,3L + +#define SN_setext_pinSecure "setext-pinSecure" +#define NID_setext_pinSecure 603 +#define OBJ_setext_pinSecure OBJ_set_msgExt,4L + +#define SN_setext_pinAny "setext-pinAny" +#define NID_setext_pinAny 604 +#define OBJ_setext_pinAny OBJ_set_msgExt,5L + +#define SN_setext_track2 "setext-track2" +#define NID_setext_track2 605 +#define OBJ_setext_track2 OBJ_set_msgExt,7L + +#define SN_setext_cv "setext-cv" +#define LN_setext_cv "additional verification" +#define NID_setext_cv 606 +#define OBJ_setext_cv OBJ_set_msgExt,8L + +#define SN_set_policy_root "set-policy-root" +#define NID_set_policy_root 607 +#define OBJ_set_policy_root OBJ_set_policy,0L + +#define SN_setCext_hashedRoot "setCext-hashedRoot" +#define NID_setCext_hashedRoot 608 +#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L + +#define SN_setCext_certType "setCext-certType" +#define NID_setCext_certType 609 +#define OBJ_setCext_certType OBJ_set_certExt,1L + +#define SN_setCext_merchData "setCext-merchData" +#define NID_setCext_merchData 610 +#define OBJ_setCext_merchData OBJ_set_certExt,2L + +#define SN_setCext_cCertRequired "setCext-cCertRequired" +#define NID_setCext_cCertRequired 611 +#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L + +#define SN_setCext_tunneling "setCext-tunneling" +#define NID_setCext_tunneling 612 +#define OBJ_setCext_tunneling OBJ_set_certExt,4L + +#define SN_setCext_setExt "setCext-setExt" +#define NID_setCext_setExt 613 +#define OBJ_setCext_setExt OBJ_set_certExt,5L + +#define SN_setCext_setQualf "setCext-setQualf" +#define NID_setCext_setQualf 614 +#define OBJ_setCext_setQualf OBJ_set_certExt,6L + +#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" +#define NID_setCext_PGWYcapabilities 615 +#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L + +#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" +#define NID_setCext_TokenIdentifier 616 +#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L + +#define SN_setCext_Track2Data "setCext-Track2Data" +#define NID_setCext_Track2Data 617 +#define OBJ_setCext_Track2Data OBJ_set_certExt,9L + +#define SN_setCext_TokenType "setCext-TokenType" +#define NID_setCext_TokenType 618 +#define OBJ_setCext_TokenType OBJ_set_certExt,10L + +#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" +#define NID_setCext_IssuerCapabilities 619 +#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L + +#define SN_setAttr_Cert "setAttr-Cert" +#define NID_setAttr_Cert 620 +#define OBJ_setAttr_Cert OBJ_set_attr,0L + +#define SN_setAttr_PGWYcap "setAttr-PGWYcap" +#define LN_setAttr_PGWYcap "payment gateway capabilities" +#define NID_setAttr_PGWYcap 621 +#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L + +#define SN_setAttr_TokenType "setAttr-TokenType" +#define NID_setAttr_TokenType 622 +#define OBJ_setAttr_TokenType OBJ_set_attr,2L + +#define SN_setAttr_IssCap "setAttr-IssCap" +#define LN_setAttr_IssCap "issuer capabilities" +#define NID_setAttr_IssCap 623 +#define OBJ_setAttr_IssCap OBJ_set_attr,3L + +#define SN_set_rootKeyThumb "set-rootKeyThumb" +#define NID_set_rootKeyThumb 624 +#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L + +#define SN_set_addPolicy "set-addPolicy" +#define NID_set_addPolicy 625 +#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L + +#define SN_setAttr_Token_EMV "setAttr-Token-EMV" +#define NID_setAttr_Token_EMV 626 +#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L + +#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" +#define NID_setAttr_Token_B0Prime 627 +#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L + +#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" +#define NID_setAttr_IssCap_CVM 628 +#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L + +#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" +#define NID_setAttr_IssCap_T2 629 +#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L + +#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" +#define NID_setAttr_IssCap_Sig 630 +#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L + +#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" +#define LN_setAttr_GenCryptgrm "generate cryptogram" +#define NID_setAttr_GenCryptgrm 631 +#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L + +#define SN_setAttr_T2Enc "setAttr-T2Enc" +#define LN_setAttr_T2Enc "encrypted track 2" +#define NID_setAttr_T2Enc 632 +#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L + +#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" +#define LN_setAttr_T2cleartxt "cleartext track 2" +#define NID_setAttr_T2cleartxt 633 +#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L + +#define SN_setAttr_TokICCsig "setAttr-TokICCsig" +#define LN_setAttr_TokICCsig "ICC or token signature" +#define NID_setAttr_TokICCsig 634 +#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L + +#define SN_setAttr_SecDevSig "setAttr-SecDevSig" +#define LN_setAttr_SecDevSig "secure device signature" +#define NID_setAttr_SecDevSig 635 +#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L + +#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" +#define NID_set_brand_IATA_ATA 636 +#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L + +#define SN_set_brand_Diners "set-brand-Diners" +#define NID_set_brand_Diners 637 +#define OBJ_set_brand_Diners OBJ_set_brand,30L + +#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" +#define NID_set_brand_AmericanExpress 638 +#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L + +#define SN_set_brand_JCB "set-brand-JCB" +#define NID_set_brand_JCB 639 +#define OBJ_set_brand_JCB OBJ_set_brand,35L + +#define SN_set_brand_Visa "set-brand-Visa" +#define NID_set_brand_Visa 640 +#define OBJ_set_brand_Visa OBJ_set_brand,4L + +#define SN_set_brand_MasterCard "set-brand-MasterCard" +#define NID_set_brand_MasterCard 641 +#define OBJ_set_brand_MasterCard OBJ_set_brand,5L + +#define SN_set_brand_Novus "set-brand-Novus" +#define NID_set_brand_Novus 642 +#define OBJ_set_brand_Novus OBJ_set_brand,6011L + +#define SN_des_cdmf "DES-CDMF" +#define LN_des_cdmf "des-cdmf" +#define NID_des_cdmf 643 +#define OBJ_des_cdmf OBJ_rsadsi,3L,10L + +#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" +#define NID_rsaOAEPEncryptionSET 644 +#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L + +#define SN_ipsec3 "Oakley-EC2N-3" +#define LN_ipsec3 "ipsec3" +#define NID_ipsec3 749 + +#define SN_ipsec4 "Oakley-EC2N-4" +#define LN_ipsec4 "ipsec4" +#define NID_ipsec4 750 + +#define SN_camellia_128_cbc "CAMELLIA-128-CBC" +#define LN_camellia_128_cbc "camellia-128-cbc" +#define NID_camellia_128_cbc 751 +#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L + +#define SN_camellia_192_cbc "CAMELLIA-192-CBC" +#define LN_camellia_192_cbc "camellia-192-cbc" +#define NID_camellia_192_cbc 752 +#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L + +#define SN_camellia_256_cbc "CAMELLIA-256-CBC" +#define LN_camellia_256_cbc "camellia-256-cbc" +#define NID_camellia_256_cbc 753 +#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L + +#define OBJ_ntt_ds 0L,3L,4401L,5L + +#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L + +#define SN_camellia_128_ecb "CAMELLIA-128-ECB" +#define LN_camellia_128_ecb "camellia-128-ecb" +#define NID_camellia_128_ecb 754 +#define OBJ_camellia_128_ecb OBJ_camellia,1L + +#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" +#define LN_camellia_128_ofb128 "camellia-128-ofb" +#define NID_camellia_128_ofb128 766 +#define OBJ_camellia_128_ofb128 OBJ_camellia,3L + +#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" +#define LN_camellia_128_cfb128 "camellia-128-cfb" +#define NID_camellia_128_cfb128 757 +#define OBJ_camellia_128_cfb128 OBJ_camellia,4L + +#define SN_camellia_192_ecb "CAMELLIA-192-ECB" +#define LN_camellia_192_ecb "camellia-192-ecb" +#define NID_camellia_192_ecb 755 +#define OBJ_camellia_192_ecb OBJ_camellia,21L + +#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" +#define LN_camellia_192_ofb128 "camellia-192-ofb" +#define NID_camellia_192_ofb128 767 +#define OBJ_camellia_192_ofb128 OBJ_camellia,23L + +#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" +#define LN_camellia_192_cfb128 "camellia-192-cfb" +#define NID_camellia_192_cfb128 758 +#define OBJ_camellia_192_cfb128 OBJ_camellia,24L + +#define SN_camellia_256_ecb "CAMELLIA-256-ECB" +#define LN_camellia_256_ecb "camellia-256-ecb" +#define NID_camellia_256_ecb 756 +#define OBJ_camellia_256_ecb OBJ_camellia,41L + +#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" +#define LN_camellia_256_ofb128 "camellia-256-ofb" +#define NID_camellia_256_ofb128 768 +#define OBJ_camellia_256_ofb128 OBJ_camellia,43L + +#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" +#define LN_camellia_256_cfb128 "camellia-256-cfb" +#define NID_camellia_256_cfb128 759 +#define OBJ_camellia_256_cfb128 OBJ_camellia,44L + +#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" +#define LN_camellia_128_cfb1 "camellia-128-cfb1" +#define NID_camellia_128_cfb1 760 + +#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" +#define LN_camellia_192_cfb1 "camellia-192-cfb1" +#define NID_camellia_192_cfb1 761 + +#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" +#define LN_camellia_256_cfb1 "camellia-256-cfb1" +#define NID_camellia_256_cfb1 762 + +#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" +#define LN_camellia_128_cfb8 "camellia-128-cfb8" +#define NID_camellia_128_cfb8 763 + +#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" +#define LN_camellia_192_cfb8 "camellia-192-cfb8" +#define NID_camellia_192_cfb8 764 + +#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" +#define LN_camellia_256_cfb8 "camellia-256-cfb8" +#define NID_camellia_256_cfb8 765 + diff --git a/include/openssl/objects.h b/include/openssl/objects.h new file mode 100755 index 0000000..7700894 --- /dev/null +++ b/include/openssl/objects.h @@ -0,0 +1,1049 @@ +/* crypto/objects/objects.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_OBJECTS_H +#define HEADER_OBJECTS_H + +#define USE_OBJ_MAC + +#ifdef USE_OBJ_MAC +#include +#else +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_Algorithm "Algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 38 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define LN_rsadsi "rsadsi" +#define NID_rsadsi 1 +#define OBJ_rsadsi 1L,2L,840L,113549L + +#define LN_pkcs "pkcs" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs,1L,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L + +#define LN_X500 "X500" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define LN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +/* Postal Address? PA */ + +/* should be "ST" (rfc1327) but MS uses 'S' */ +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500,8L,1L,1L + +#define LN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define LN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +/* IV + num */ +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +/* IV */ +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ede "DES-EDE" +#define LN_des_ede "des-ede" +#define NID_des_ede 32 +/* ?? */ +#define OBJ_des_ede OBJ_algorithm,17L + +#define SN_des_ede3 "DES-EDE3" +#define LN_des_ede3 "des-ede3" +#define NID_des_ede3 33 + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define LN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define SN_pkcs9_emailAddress "Email" +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +/* I'm not sure about the object ID */ +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L +/* 28 Jun 1996 - eay */ +/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +/* proposed by microsoft to RSA */ +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L + +/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now + * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something + * completely different. + */ +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce 2L,5L,29L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 2L,5L,8L,3L,101L +/* An alternative? 1L,3L,14L,3L,2L,19L */ + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2withRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_givenName "G" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define SN_surname "S" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define SN_initials "I" +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define SN_uniqueIdentifier "UID" +#define LN_uniqueIdentifier "uniqueIdentifier" +#define NID_uniqueIdentifier 102 +#define OBJ_uniqueIdentifier OBJ_X509,45L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_serialNumber "SN" +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_title "T" +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define SN_description "D" +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +/* CAST5 is CAST-128, I'm just sticking with the documentation */ +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L + +/* This is one sun will soon be using :-( + * id-dsa-with-sha1 ID ::= { + * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } + */ +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L + +#define NID_md5_sha1 114 +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa 1L,2L,840L,10040L,4L,1L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +/* The name should actually be rsaSignatureWithripemd160, but I'm going + * to continue using the convention I'm using with the other ciphers */ +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +/* Taken from rfc2040 + * RC5_CBC_Parameters ::= SEQUENCE { + * version INTEGER (v1_0(16)), + * rounds INTEGER (8..127), + * blockSizeInBits INTEGER (64, 128), + * iv OCTET STRING OPTIONAL + * } + */ +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +/* PKIX extended key usage OIDs */ + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +/* Additional extended key usage OIDs: Microsoft */ + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +/* Additional usage: Netscape */ + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +/* PKCS12 and related OBJECT IDENTIFIERS */ + +#define OBJ_pkcs12 OBJ_pkcs,12L +#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds, 3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9, 20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9, 21L + +#define OBJ_certTypes OBJ_pkcs9, 22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes, 1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes, 2L + +#define OBJ_crlTypes OBJ_pkcs9, 23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes, 1L + +/* PKCS#5 v2 OIDs */ + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs,5L,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs,5L,14L + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +/* Policy Qualifier Ids */ + +#define LN_id_qt_cps "Policy Qualifier CPS" +#define SN_id_qt_cps "id-qt-cps" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L + +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define SN_id_qt_unotice "id-qt-unotice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L + +/* Extension request OIDs */ + +#define LN_ms_ext_req "Microsoft Extension Request" +#define SN_ms_ext_req "msExtReq" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define LN_ext_req "Extension Request" +#define SN_ext_req "extReq" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L +#endif /* USE_OBJ_MAC */ + +#include +#include + +#define OBJ_NAME_TYPE_UNDEF 0x00 +#define OBJ_NAME_TYPE_MD_METH 0x01 +#define OBJ_NAME_TYPE_CIPHER_METH 0x02 +#define OBJ_NAME_TYPE_PKEY_METH 0x03 +#define OBJ_NAME_TYPE_COMP_METH 0x04 +#define OBJ_NAME_TYPE_NUM 0x05 + +#define OBJ_NAME_ALIAS 0x8000 + +#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 +#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct obj_name_st + { + int type; + int alias; + const char *name; + const char *data; + } OBJ_NAME; + +#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) + + +int OBJ_NAME_init(void); +int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), + int (*cmp_func)(const char *, const char *), + void (*free_func)(const char *, int, const char *)); +const char *OBJ_NAME_get(const char *name,int type); +int OBJ_NAME_add(const char *name,int type,const char *data); +int OBJ_NAME_remove(const char *name,int type); +void OBJ_NAME_cleanup(int type); /* -1 for everything */ +void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); +void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); + +ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_nid2obj(int n); +const char * OBJ_nid2ln(int n); +const char * OBJ_nid2sn(int n); +int OBJ_obj2nid(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); +int OBJ_txt2nid(const char *s); +int OBJ_ln2nid(const char *s); +int OBJ_sn2nid(const char *s); +int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); +const char * OBJ_bsearch(const char *key,const char *base,int num,int size, + int (*cmp)(const void *, const void *)); +const char * OBJ_bsearch_ex(const char *key,const char *base,int num, + int size, int (*cmp)(const void *, const void *), int flags); + +int OBJ_new_nid(int num); +int OBJ_add_object(const ASN1_OBJECT *obj); +int OBJ_create(const char *oid,const char *sn,const char *ln); +void OBJ_cleanup(void ); +int OBJ_create_objects(BIO *in); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OBJ_strings(void); + +/* Error codes for the OBJ functions. */ + +/* Function codes. */ +#define OBJ_F_OBJ_ADD_OBJECT 105 +#define OBJ_F_OBJ_CREATE 100 +#define OBJ_F_OBJ_DUP 101 +#define OBJ_F_OBJ_NAME_NEW_INDEX 106 +#define OBJ_F_OBJ_NID2LN 102 +#define OBJ_F_OBJ_NID2OBJ 103 +#define OBJ_F_OBJ_NID2SN 104 + +/* Reason codes. */ +#define OBJ_R_MALLOC_FAILURE 100 +#define OBJ_R_UNKNOWN_NID 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/ocsp.h b/include/openssl/ocsp.h new file mode 100755 index 0000000..830d428 --- /dev/null +++ b/include/openssl/ocsp.h @@ -0,0 +1,614 @@ +/* ocsp.h */ +/* Written by Tom Titchener for the OpenSSL + * project. */ + +/* History: + This file was transfered to Richard Levitte from CertCo by Kathy + Weinhold in mid-spring 2000 to be included in OpenSSL or released + as a patch kit. */ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OCSP_H +#define HEADER_OCSP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Various flags and values */ + +#define OCSP_DEFAULT_NONCE_LENGTH 16 + +#define OCSP_NOCERTS 0x1 +#define OCSP_NOINTERN 0x2 +#define OCSP_NOSIGS 0x4 +#define OCSP_NOCHAIN 0x8 +#define OCSP_NOVERIFY 0x10 +#define OCSP_NOEXPLICIT 0x20 +#define OCSP_NOCASIGN 0x40 +#define OCSP_NODELEGATED 0x80 +#define OCSP_NOCHECKS 0x100 +#define OCSP_TRUSTOTHER 0x200 +#define OCSP_RESPID_KEY 0x400 +#define OCSP_NOTIME 0x800 + +/* CertID ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier, + * issuerNameHash OCTET STRING, -- Hash of Issuer's DN + * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) + * serialNumber CertificateSerialNumber } + */ +typedef struct ocsp_cert_id_st + { + X509_ALGOR *hashAlgorithm; + ASN1_OCTET_STRING *issuerNameHash; + ASN1_OCTET_STRING *issuerKeyHash; + ASN1_INTEGER *serialNumber; + } OCSP_CERTID; + +DECLARE_STACK_OF(OCSP_CERTID) + +/* Request ::= SEQUENCE { + * reqCert CertID, + * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_one_request_st + { + OCSP_CERTID *reqCert; + STACK_OF(X509_EXTENSION) *singleRequestExtensions; + } OCSP_ONEREQ; + +DECLARE_STACK_OF(OCSP_ONEREQ) +DECLARE_ASN1_SET_OF(OCSP_ONEREQ) + + +/* TBSRequest ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * requestorName [1] EXPLICIT GeneralName OPTIONAL, + * requestList SEQUENCE OF Request, + * requestExtensions [2] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_req_info_st + { + ASN1_INTEGER *version; + GENERAL_NAME *requestorName; + STACK_OF(OCSP_ONEREQ) *requestList; + STACK_OF(X509_EXTENSION) *requestExtensions; + } OCSP_REQINFO; + +/* Signature ::= SEQUENCE { + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ +typedef struct ocsp_signature_st + { + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_SIGNATURE; + +/* OCSPRequest ::= SEQUENCE { + * tbsRequest TBSRequest, + * optionalSignature [0] EXPLICIT Signature OPTIONAL } + */ +typedef struct ocsp_request_st + { + OCSP_REQINFO *tbsRequest; + OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ + } OCSP_REQUEST; + +/* OCSPResponseStatus ::= ENUMERATED { + * successful (0), --Response has valid confirmations + * malformedRequest (1), --Illegal confirmation request + * internalError (2), --Internal error in issuer + * tryLater (3), --Try again later + * --(4) is not used + * sigRequired (5), --Must sign the request + * unauthorized (6) --Request unauthorized + * } + */ +#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 +#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 +#define OCSP_RESPONSE_STATUS_INTERNALERROR 2 +#define OCSP_RESPONSE_STATUS_TRYLATER 3 +#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 +#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 + +/* ResponseBytes ::= SEQUENCE { + * responseType OBJECT IDENTIFIER, + * response OCTET STRING } + */ +typedef struct ocsp_resp_bytes_st + { + ASN1_OBJECT *responseType; + ASN1_OCTET_STRING *response; + } OCSP_RESPBYTES; + +/* OCSPResponse ::= SEQUENCE { + * responseStatus OCSPResponseStatus, + * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } + */ +typedef struct ocsp_response_st + { + ASN1_ENUMERATED *responseStatus; + OCSP_RESPBYTES *responseBytes; + } OCSP_RESPONSE; + +/* ResponderID ::= CHOICE { + * byName [1] Name, + * byKey [2] KeyHash } + */ +#define V_OCSP_RESPID_NAME 0 +#define V_OCSP_RESPID_KEY 1 +typedef struct ocsp_responder_id_st + { + int type; + union { + X509_NAME* byName; + ASN1_OCTET_STRING *byKey; + } value; + } OCSP_RESPID; +/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key + * --(excluding the tag and length fields) + */ + +/* RevokedInfo ::= SEQUENCE { + * revocationTime GeneralizedTime, + * revocationReason [0] EXPLICIT CRLReason OPTIONAL } + */ +typedef struct ocsp_revoked_info_st + { + ASN1_GENERALIZEDTIME *revocationTime; + ASN1_ENUMERATED *revocationReason; + } OCSP_REVOKEDINFO; + +/* CertStatus ::= CHOICE { + * good [0] IMPLICIT NULL, + * revoked [1] IMPLICIT RevokedInfo, + * unknown [2] IMPLICIT UnknownInfo } + */ +#define V_OCSP_CERTSTATUS_GOOD 0 +#define V_OCSP_CERTSTATUS_REVOKED 1 +#define V_OCSP_CERTSTATUS_UNKNOWN 2 +typedef struct ocsp_cert_status_st + { + int type; + union { + ASN1_NULL *good; + OCSP_REVOKEDINFO *revoked; + ASN1_NULL *unknown; + } value; + } OCSP_CERTSTATUS; + +/* SingleResponse ::= SEQUENCE { + * certID CertID, + * certStatus CertStatus, + * thisUpdate GeneralizedTime, + * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, + * singleExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_single_response_st + { + OCSP_CERTID *certId; + OCSP_CERTSTATUS *certStatus; + ASN1_GENERALIZEDTIME *thisUpdate; + ASN1_GENERALIZEDTIME *nextUpdate; + STACK_OF(X509_EXTENSION) *singleExtensions; + } OCSP_SINGLERESP; + +DECLARE_STACK_OF(OCSP_SINGLERESP) +DECLARE_ASN1_SET_OF(OCSP_SINGLERESP) + +/* ResponseData ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * responderID ResponderID, + * producedAt GeneralizedTime, + * responses SEQUENCE OF SingleResponse, + * responseExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_response_data_st + { + ASN1_INTEGER *version; + OCSP_RESPID *responderId; + ASN1_GENERALIZEDTIME *producedAt; + STACK_OF(OCSP_SINGLERESP) *responses; + STACK_OF(X509_EXTENSION) *responseExtensions; + } OCSP_RESPDATA; + +/* BasicOCSPResponse ::= SEQUENCE { + * tbsResponseData ResponseData, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ + /* Note 1: + The value for "signature" is specified in the OCSP rfc2560 as follows: + "The value for the signature SHALL be computed on the hash of the DER + encoding ResponseData." This means that you must hash the DER-encoded + tbsResponseData, and then run it through a crypto-signing function, which + will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems + a bit odd, but that's the spec. Also note that the data structures do not + leave anywhere to independently specify the algorithm used for the initial + hash. So, we look at the signature-specification algorithm, and try to do + something intelligent. -- Kathy Weinhold, CertCo */ + /* Note 2: + It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open + for interpretation. I've done tests against another responder, and found + that it doesn't do the double hashing that the RFC seems to say one + should. Therefore, all relevant functions take a flag saying which + variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */ +typedef struct ocsp_basic_response_st + { + OCSP_RESPDATA *tbsResponseData; + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_BASICRESP; + +/* + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * removeFromCRL (8) } + */ +#define OCSP_REVOKED_STATUS_NOSTATUS -1 +#define OCSP_REVOKED_STATUS_UNSPECIFIED 0 +#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 +#define OCSP_REVOKED_STATUS_CACOMPROMISE 2 +#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 +#define OCSP_REVOKED_STATUS_SUPERSEDED 4 +#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 +#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 +#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 + +/* CrlID ::= SEQUENCE { + * crlUrl [0] EXPLICIT IA5String OPTIONAL, + * crlNum [1] EXPLICIT INTEGER OPTIONAL, + * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } + */ +typedef struct ocsp_crl_id_st + { + ASN1_IA5STRING *crlUrl; + ASN1_INTEGER *crlNum; + ASN1_GENERALIZEDTIME *crlTime; + } OCSP_CRLID; + +/* ServiceLocator ::= SEQUENCE { + * issuer Name, + * locator AuthorityInfoAccessSyntax OPTIONAL } + */ +typedef struct ocsp_service_locator_st + { + X509_NAME* issuer; + STACK_OF(ACCESS_DESCRIPTION) *locator; + } OCSP_SERVICELOC; + +#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" +#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" + +#define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) + +#define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) + +#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL) + +#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ + (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL) + +#define PEM_write_bio_OCSP_REQUEST(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_OCSP_RESPONSE(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) + +#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) + +#define OCSP_REQUEST_sign(o,pkey,md) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ + o->optionalSignature->signatureAlgorithm,NULL,\ + o->optionalSignature->signature,o->tbsRequest,pkey,md) + +#define OCSP_BASICRESP_sign(o,pkey,md,d) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\ + o->signature,o->tbsResponseData,pkey,md) + +#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ + a->optionalSignature->signatureAlgorithm,\ + a->optionalSignature->signature,a->tbsRequest,r) + +#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ + a->signatureAlgorithm,a->signature,a->tbsResponseData,r) + +#define ASN1_BIT_STRING_digest(data,type,md,len) \ + ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) + +#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid) + +#define OCSP_CERTSTATUS_dup(cs)\ + (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ + (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) + +OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); + +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); + +OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, + X509_NAME *issuerName, + ASN1_BIT_STRING* issuerKey, + ASN1_INTEGER *serialNumber); + +OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); + +int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); +int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); +int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); +int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); + +int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); +int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); + +int OCSP_request_sign(OCSP_REQUEST *req, + X509 *signer, + EVP_PKEY *key, + const EVP_MD *dgst, + STACK_OF(X509) *certs, + unsigned long flags); + +int OCSP_response_status(OCSP_RESPONSE *resp); +OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); + +int OCSP_resp_count(OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); +int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); +int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, + int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, + ASN1_GENERALIZEDTIME *nextupd, + long sec, long maxsec); + +int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags); + +int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl); + +int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); +int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); + +int OCSP_request_onereq_count(OCSP_REQUEST *req); +OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); +OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); +int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, + ASN1_OCTET_STRING **pikeyHash, + ASN1_INTEGER **pserial, OCSP_CERTID *cid); +int OCSP_request_is_signed(OCSP_REQUEST *req); +OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, + OCSP_CERTID *cid, + int status, int reason, + ASN1_TIME *revtime, + ASN1_TIME *thisupd, ASN1_TIME *nextupd); +int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); +int OCSP_basic_sign(OCSP_BASICRESP *brsp, + X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, + STACK_OF(X509) *certs, unsigned long flags); + +ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, + void *data, STACK_OF(ASN1_OBJECT) *sk); +#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \ +((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk) + +X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); + +X509_EXTENSION *OCSP_accept_responses_new(char **oids); + +X509_EXTENSION *OCSP_archive_cutoff_new(char* tim); + +X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls); + +int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); +int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); +X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); +X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); +void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx); +int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); + +int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); +int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); +X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); +X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); +void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); +int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); + +int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); +int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); +X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); +void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx); +int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); + +int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); +int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); +X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); +void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx); +int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); + +DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) +DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) +DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) +DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) +DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) +DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) +DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) + +char *OCSP_response_status_str(long s); +char *OCSP_cert_status_str(long s); +char *OCSP_crl_reason_str(long s); + +int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags); +int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags); + +int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, + X509_STORE *st, unsigned long flags); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OCSP_strings(void); + +/* Error codes for the OCSP functions. */ + +/* Function codes. */ +#define OCSP_F_ASN1_STRING_ENCODE 100 +#define OCSP_F_D2I_OCSP_NONCE 102 +#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 +#define OCSP_F_OCSP_BASIC_SIGN 104 +#define OCSP_F_OCSP_BASIC_VERIFY 105 +#define OCSP_F_OCSP_CERT_ID_NEW 101 +#define OCSP_F_OCSP_CHECK_DELEGATED 106 +#define OCSP_F_OCSP_CHECK_IDS 107 +#define OCSP_F_OCSP_CHECK_ISSUER 108 +#define OCSP_F_OCSP_CHECK_VALIDITY 115 +#define OCSP_F_OCSP_MATCH_ISSUERID 109 +#define OCSP_F_OCSP_PARSE_URL 114 +#define OCSP_F_OCSP_REQUEST_SIGN 110 +#define OCSP_F_OCSP_REQUEST_VERIFY 116 +#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 +#define OCSP_F_OCSP_SENDREQ_BIO 112 +#define OCSP_F_REQUEST_VERIFY 113 + +/* Reason codes. */ +#define OCSP_R_BAD_DATA 100 +#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 +#define OCSP_R_DIGEST_ERR 102 +#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 +#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 +#define OCSP_R_ERROR_PARSING_URL 121 +#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 +#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 +#define OCSP_R_NOT_BASIC_RESPONSE 104 +#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 +#define OCSP_R_NO_CONTENT 106 +#define OCSP_R_NO_PUBLIC_KEY 107 +#define OCSP_R_NO_RESPONSE_DATA 108 +#define OCSP_R_NO_REVOKED_TIME 109 +#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 +#define OCSP_R_REQUEST_NOT_SIGNED 128 +#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 +#define OCSP_R_ROOT_CA_NOT_TRUSTED 112 +#define OCSP_R_SERVER_READ_ERROR 113 +#define OCSP_R_SERVER_RESPONSE_ERROR 114 +#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 +#define OCSP_R_SERVER_WRITE_ERROR 116 +#define OCSP_R_SIGNATURE_FAILURE 117 +#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 +#define OCSP_R_STATUS_EXPIRED 125 +#define OCSP_R_STATUS_NOT_YET_VALID 126 +#define OCSP_R_STATUS_TOO_OLD 127 +#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 +#define OCSP_R_UNKNOWN_NID 120 +#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/opensslconf.h b/include/openssl/opensslconf.h new file mode 100755 index 0000000..3942a69 --- /dev/null +++ b/include/openssl/opensslconf.h @@ -0,0 +1,219 @@ +/* opensslconf.h */ +/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ + +/* OpenSSL was configured with the following options: */ +#ifndef OPENSSL_DOING_MAKEDEPEND + +#ifndef OPENSSL_NO_CAMELLIA +# define OPENSSL_NO_CAMELLIA +#endif +#ifndef OPENSSL_NO_GMP +# define OPENSSL_NO_GMP +#endif +#ifndef OPENSSL_NO_KRB5 +# define OPENSSL_NO_KRB5 +#endif +#ifndef OPENSSL_NO_MDC2 +# define OPENSSL_NO_MDC2 +#endif +#ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +#endif +#ifndef OPENSSL_NO_RFC3779 +# define OPENSSL_NO_RFC3779 +#endif + +#endif /* OPENSSL_DOING_MAKEDEPEND */ +#ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +#endif +#ifndef OPENSSL_NO_DYNAMIC_ENGINE +# define OPENSSL_NO_DYNAMIC_ENGINE +#endif + +/* The OPENSSL_NO_* macros are also defined as NO_* if the application + asks for it. This is a transient feature that is provided for those + who haven't had the time to do the appropriate changes in their + applications. */ +#ifdef OPENSSL_ALGORITHM_DEFINES +# if defined(OPENSSL_NO_CAMELLIA) && !defined(NO_CAMELLIA) +# define NO_CAMELLIA +# endif +# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) +# define NO_GMP +# endif +# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) +# define NO_KRB5 +# endif +# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2) +# define NO_MDC2 +# endif +# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) +# define NO_RC5 +# endif +# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779) +# define NO_RFC3779 +# endif +#endif + +#define OPENSSL_CPUID_OBJ + +/* crypto/opensslconf.h.in */ + +/* Generate 80386 code? */ +#undef I386_ONLY + +#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define ENGINESDIR "/g3/openssl/linux/lib/engines" +#define OPENSSLDIR "/g3/openssl/linux/ssl" +#endif +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#define DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#define DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/openssl/opensslv.h b/include/openssl/opensslv.h new file mode 100755 index 0000000..c801bdb --- /dev/null +++ b/include/openssl/opensslv.h @@ -0,0 +1,89 @@ +#ifndef HEADER_OPENSSLV_H +#define HEADER_OPENSSLV_H + +/* Numeric release version identifier: + * MNNFFPPS: major minor fix patch status + * The status nibble has one of the values 0 for development, 1 to e for betas + * 1 to 14, and f for release. The patch level is exactly that. + * For example: + * 0.9.3-dev 0x00903000 + * 0.9.3-beta1 0x00903001 + * 0.9.3-beta2-dev 0x00903002 + * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) + * 0.9.3 0x0090300f + * 0.9.3a 0x0090301f + * 0.9.4 0x0090400f + * 1.2.3z 0x102031af + * + * For continuity reasons (because 0.9.5 is already out, and is coded + * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level + * part is slightly different, by setting the highest bit. This means + * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start + * with 0x0090600S... + * + * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) + * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for + * major minor fix final patch/beta) + */ +#define OPENSSL_VERSION_NUMBER 0x0090805fL +#ifdef OPENSSL_FIPS +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8e-fips 23 Feb 2007" +#else +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8e 23 Feb 2007" +#endif +#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT + + +/* The macros below are to be used for shared library (.so, .dll, ...) + * versioning. That kind of versioning works a bit differently between + * operating systems. The most usual scheme is to set a major and a minor + * number, and have the runtime loader check that the major number is equal + * to what it was at application link time, while the minor number has to + * be greater or equal to what it was at application link time. With this + * scheme, the version number is usually part of the file name, like this: + * + * libcrypto.so.0.9 + * + * Some unixen also make a softlink with the major verson number only: + * + * libcrypto.so.0 + * + * On Tru64 and IRIX 6.x it works a little bit differently. There, the + * shared library version is stored in the file, and is actually a series + * of versions, separated by colons. The rightmost version present in the + * library when linking an application is stored in the application to be + * matched at run time. When the application is run, a check is done to + * see if the library version stored in the application matches any of the + * versions in the version string of the library itself. + * This version string can be constructed in any way, depending on what + * kind of matching is desired. However, to implement the same scheme as + * the one used in the other unixen, all compatible versions, from lowest + * to highest, should be part of the string. Consecutive builds would + * give the following versions strings: + * + * 3.0 + * 3.0:3.1 + * 3.0:3.1:3.2 + * 4.0 + * 4.0:4.1 + * + * Notice how version 4 is completely incompatible with version, and + * therefore give the breach you can see. + * + * There may be other schemes as well that I haven't yet discovered. + * + * So, here's the way it works here: first of all, the library version + * number doesn't need at all to match the overall OpenSSL version. + * However, it's nice and more understandable if it actually does. + * The current library version is stored in the macro SHLIB_VERSION_NUMBER, + * which is just a piece of text in the format "M.m.e" (Major, minor, edit). + * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, + * we need to keep a history of version numbers, which is done in the + * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and + * should only keep the versions that are binary compatible with the current. + */ +#define SHLIB_VERSION_HISTORY "" +#define SHLIB_VERSION_NUMBER "0.9.8" + + +#endif /* HEADER_OPENSSLV_H */ diff --git a/include/openssl/ossl_typ.h b/include/openssl/ossl_typ.h new file mode 100755 index 0000000..9115bcc --- /dev/null +++ b/include/openssl/ossl_typ.h @@ -0,0 +1,174 @@ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OPENSSL_TYPES_H +#define HEADER_OPENSSL_TYPES_H + +#include + +#ifdef NO_ASN1_TYPEDEFS +#define ASN1_INTEGER ASN1_STRING +#define ASN1_ENUMERATED ASN1_STRING +#define ASN1_BIT_STRING ASN1_STRING +#define ASN1_OCTET_STRING ASN1_STRING +#define ASN1_PRINTABLESTRING ASN1_STRING +#define ASN1_T61STRING ASN1_STRING +#define ASN1_IA5STRING ASN1_STRING +#define ASN1_UTCTIME ASN1_STRING +#define ASN1_GENERALIZEDTIME ASN1_STRING +#define ASN1_TIME ASN1_STRING +#define ASN1_GENERALSTRING ASN1_STRING +#define ASN1_UNIVERSALSTRING ASN1_STRING +#define ASN1_BMPSTRING ASN1_STRING +#define ASN1_VISIBLESTRING ASN1_STRING +#define ASN1_UTF8STRING ASN1_STRING +#define ASN1_BOOLEAN int +#define ASN1_NULL int +#else +typedef struct asn1_string_st ASN1_INTEGER; +typedef struct asn1_string_st ASN1_ENUMERATED; +typedef struct asn1_string_st ASN1_BIT_STRING; +typedef struct asn1_string_st ASN1_OCTET_STRING; +typedef struct asn1_string_st ASN1_PRINTABLESTRING; +typedef struct asn1_string_st ASN1_T61STRING; +typedef struct asn1_string_st ASN1_IA5STRING; +typedef struct asn1_string_st ASN1_GENERALSTRING; +typedef struct asn1_string_st ASN1_UNIVERSALSTRING; +typedef struct asn1_string_st ASN1_BMPSTRING; +typedef struct asn1_string_st ASN1_UTCTIME; +typedef struct asn1_string_st ASN1_TIME; +typedef struct asn1_string_st ASN1_GENERALIZEDTIME; +typedef struct asn1_string_st ASN1_VISIBLESTRING; +typedef struct asn1_string_st ASN1_UTF8STRING; +typedef int ASN1_BOOLEAN; +typedef int ASN1_NULL; +#endif + +#ifdef OPENSSL_SYS_WIN32 +#undef X509_NAME +#undef X509_CERT_PAIR +#undef PKCS7_ISSUER_AND_SERIAL +#endif + +#ifdef BIGNUM +#undef BIGNUM +#endif +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; + +typedef struct buf_mem_st BUF_MEM; + +typedef struct evp_cipher_st EVP_CIPHER; +typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; +typedef struct env_md_st EVP_MD; +typedef struct env_md_ctx_st EVP_MD_CTX; +typedef struct evp_pkey_st EVP_PKEY; + +typedef struct dh_st DH; +typedef struct dh_method DH_METHOD; + +typedef struct dsa_st DSA; +typedef struct dsa_method DSA_METHOD; + +typedef struct rsa_st RSA; +typedef struct rsa_meth_st RSA_METHOD; + +typedef struct rand_meth_st RAND_METHOD; + +typedef struct ecdh_method ECDH_METHOD; +typedef struct ecdsa_method ECDSA_METHOD; + +typedef struct x509_st X509; +typedef struct X509_algor_st X509_ALGOR; +typedef struct X509_crl_st X509_CRL; +typedef struct X509_name_st X509_NAME; +typedef struct x509_store_st X509_STORE; +typedef struct x509_store_ctx_st X509_STORE_CTX; + +typedef struct v3_ext_ctx X509V3_CTX; +typedef struct conf_st CONF; + +typedef struct store_st STORE; +typedef struct store_method_st STORE_METHOD; + +typedef struct ui_st UI; +typedef struct ui_method_st UI_METHOD; + +typedef struct st_ERR_FNS ERR_FNS; + +typedef struct engine_st ENGINE; + +typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; +typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; +typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; +typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; + + /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ +#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ +#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ + +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Callback types for crypto.h */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); + +#endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/include/openssl/pem.h b/include/openssl/pem.h new file mode 100755 index 0000000..c003eec --- /dev/null +++ b/include/openssl/pem.h @@ -0,0 +1,737 @@ +/* crypto/pem/pem.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PEM_H +#define HEADER_PEM_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_STACK +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PEM_BUFSIZE 1024 + +#define PEM_OBJ_UNDEF 0 +#define PEM_OBJ_X509 1 +#define PEM_OBJ_X509_REQ 2 +#define PEM_OBJ_CRL 3 +#define PEM_OBJ_SSL_SESSION 4 +#define PEM_OBJ_PRIV_KEY 10 +#define PEM_OBJ_PRIV_RSA 11 +#define PEM_OBJ_PRIV_DSA 12 +#define PEM_OBJ_PRIV_DH 13 +#define PEM_OBJ_PUB_RSA 14 +#define PEM_OBJ_PUB_DSA 15 +#define PEM_OBJ_PUB_DH 16 +#define PEM_OBJ_DHPARAMS 17 +#define PEM_OBJ_DSAPARAMS 18 +#define PEM_OBJ_PRIV_RSA_PUBLIC 19 +#define PEM_OBJ_PRIV_ECDSA 20 +#define PEM_OBJ_PUB_ECDSA 21 +#define PEM_OBJ_ECPARAMETERS 22 + +#define PEM_ERROR 30 +#define PEM_DEK_DES_CBC 40 +#define PEM_DEK_IDEA_CBC 45 +#define PEM_DEK_DES_EDE 50 +#define PEM_DEK_DES_ECB 60 +#define PEM_DEK_RSA 70 +#define PEM_DEK_RSA_MD2 80 +#define PEM_DEK_RSA_MD5 90 + +#define PEM_MD_MD2 NID_md2 +#define PEM_MD_MD5 NID_md5 +#define PEM_MD_SHA NID_sha +#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption +#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption +#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption + +#define PEM_STRING_X509_OLD "X509 CERTIFICATE" +#define PEM_STRING_X509 "CERTIFICATE" +#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" +#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" +#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +#define PEM_STRING_X509_CRL "X509 CRL" +#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" +#define PEM_STRING_PUBLIC "PUBLIC KEY" +#define PEM_STRING_RSA "RSA PRIVATE KEY" +#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +#define PEM_STRING_DSA "DSA PRIVATE KEY" +#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" +#define PEM_STRING_PKCS7 "PKCS7" +#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" +#define PEM_STRING_PKCS8INF "PRIVATE KEY" +#define PEM_STRING_DHPARAMS "DH PARAMETERS" +#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" +#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" +#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" +#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" + + /* Note that this structure is initialised by PEM_SealInit and cleaned up + by PEM_SealFinal (at least for now) */ +typedef struct PEM_Encode_Seal_st + { + EVP_ENCODE_CTX encode; + EVP_MD_CTX md; + EVP_CIPHER_CTX cipher; + } PEM_ENCODE_SEAL_CTX; + +/* enc_type is one off */ +#define PEM_TYPE_ENCRYPTED 10 +#define PEM_TYPE_MIC_ONLY 20 +#define PEM_TYPE_MIC_CLEAR 30 +#define PEM_TYPE_CLEAR 40 + +typedef struct pem_recip_st + { + char *name; + X509_NAME *dn; + + int cipher; + int key_enc; + /* char iv[8]; unused and wrong size */ + } PEM_USER; + +typedef struct pem_ctx_st + { + int type; /* what type of object */ + + struct { + int version; + int mode; + } proc_type; + + char *domain; + + struct { + int cipher; + /* unused, and wrong size + unsigned char iv[8]; */ + } DEK_info; + + PEM_USER *originator; + + int num_recipient; + PEM_USER **recipient; + +#ifndef OPENSSL_NO_STACK + STACK *x509_chain; /* certificate chain */ +#else + char *x509_chain; /* certificate chain */ +#endif + EVP_MD *md; /* signature type */ + + int md_enc; /* is the md encrypted or not? */ + int md_len; /* length of md_data */ + char *md_data; /* message digest, could be pkey encrypted */ + + EVP_CIPHER *dec; /* date encryption cipher */ + int key_len; /* key length */ + unsigned char *key; /* key */ + /* unused, and wrong size + unsigned char iv[8]; */ + + + int data_enc; /* is the data encrypted */ + int data_len; + unsigned char *data; + } PEM_CTX; + +/* These macros make the PEM_read/PEM_write functions easier to maintain and + * write. Now they are all implemented with either: + * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) + */ + +#ifdef OPENSSL_NO_FP_API + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ + +#else + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ +type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#endif + +#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ +type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_read_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb(name, type, str, asn1) + +/* These are the same except they are for the declarations */ + +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) + +#define DECLARE_PEM_read_fp(name, type) /**/ +#define DECLARE_PEM_write_fp(name, type) /**/ +#define DECLARE_PEM_write_cb_fp(name, type) /**/ + +#else + +#define DECLARE_PEM_read_fp(name, type) \ + type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x); + +#define DECLARE_PEM_write_fp_const(name, type) \ + int PEM_write_##name(FILE *fp, const type *x); + +#define DECLARE_PEM_write_cb_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#endif + +#ifndef OPENSSL_NO_BIO +#define DECLARE_PEM_read_bio(name, type) \ + type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x); + +#define DECLARE_PEM_write_bio_const(name, type) \ + int PEM_write_bio_##name(BIO *bp, const type *x); + +#define DECLARE_PEM_write_cb_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#else + +#define DECLARE_PEM_read_bio(name, type) /**/ +#define DECLARE_PEM_write_bio(name, type) /**/ +#define DECLARE_PEM_write_cb_bio(name, type) /**/ + +#endif + +#define DECLARE_PEM_write(name, type) \ + DECLARE_PEM_write_bio(name, type) \ + DECLARE_PEM_write_fp(name, type) + +#define DECLARE_PEM_write_const(name, type) \ + DECLARE_PEM_write_bio_const(name, type) \ + DECLARE_PEM_write_fp_const(name, type) + +#define DECLARE_PEM_write_cb(name, type) \ + DECLARE_PEM_write_cb_bio(name, type) \ + DECLARE_PEM_write_cb_fp(name, type) + +#define DECLARE_PEM_read(name, type) \ + DECLARE_PEM_read_bio(name, type) \ + DECLARE_PEM_read_fp(name, type) + +#define DECLARE_PEM_rw(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write(name, type) + +#define DECLARE_PEM_rw_const(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_const(name, type) + +#define DECLARE_PEM_rw_cb(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_cb(name, type) + +#ifdef SSLEAY_MACROS + +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_CRL(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ + fp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_RSAPublicKey(fp,x) \ + PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ + PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PKCS7(fp,x) \ + PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_DHparams(fp,x) \ + PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ + (char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ + PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \ + (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u) +#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u) +#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u) +#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u) +#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u) +#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u) +#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u) +#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u) +#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u) + +#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ + (char **)x,cb,u) + +#define PEM_write_bio_X509(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_CRL(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ + bp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_RSAPublicKey(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ + PEM_STRING_RSA_PUBLIC,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PKCS7(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DHparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ + PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u) +#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u) + +#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u) +#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u) + +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ + (char **)x,cb,u) + +#endif + +#if 1 +/* "userdata": new with OpenSSL 0.9.4 */ +typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); +#else +/* OpenSSL 0.9.3, 0.9.3a */ +typedef int pem_password_cb(char *buf, int size, int rwflag); +#endif + +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + pem_password_cb *callback,void *u); + +#ifndef OPENSSL_NO_BIO +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, + long len); +int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, + pem_password_cb *cb, void *u); +void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, + void **x, pem_password_cb *cb, void *u); +#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ +((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u) +int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, + const EVP_CIPHER *enc,unsigned char *kstr,int klen, + pem_password_cb *cb, void *u); +#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ + ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u) + +STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); +int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, + unsigned char *kstr, int klen, pem_password_cb *cd, void *u); +#endif + +#ifndef OPENSSL_SYS_WIN16 +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); +void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, + char *x,const EVP_CIPHER *enc,unsigned char *kstr, + int klen,pem_password_cb *callback, void *u); +STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u); +#endif + +int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, + EVP_MD *md_type, unsigned char **ek, int *ekl, + unsigned char *iv, EVP_PKEY **pubk, int npubk); +void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, + unsigned char *in, int inl); +int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, + unsigned char *out, int *outl, EVP_PKEY *priv); + +void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +int PEM_def_callback(char *buf, int num, int w, void *key); +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, const char *type, int len, char *str); + +#ifndef SSLEAY_MACROS + +#include + +DECLARE_PEM_rw(X509, X509) + +DECLARE_PEM_rw(X509_AUX, X509) + +DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) + +DECLARE_PEM_rw(X509_REQ, X509_REQ) +DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) + +DECLARE_PEM_rw(X509_CRL, X509_CRL) + +DECLARE_PEM_rw(PKCS7, PKCS7) + +DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) + +DECLARE_PEM_rw(PKCS8, X509_SIG) + +DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) + +#ifndef OPENSSL_NO_RSA + +DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) + +DECLARE_PEM_rw_const(RSAPublicKey, RSA) +DECLARE_PEM_rw(RSA_PUBKEY, RSA) + +#endif + +#ifndef OPENSSL_NO_DSA + +DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) + +DECLARE_PEM_rw(DSA_PUBKEY, DSA) + +DECLARE_PEM_rw_const(DSAparams, DSA) + +#endif + +#ifndef OPENSSL_NO_EC +DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) +DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) +DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) +#endif + +#ifndef OPENSSL_NO_DH + +DECLARE_PEM_rw_const(DHparams, DH) + +#endif + +DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) + +DECLARE_PEM_rw(PUBKEY, EVP_PKEY) + +int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, + char *, int, pem_password_cb *, void *); +int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); + +EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, + char *kstr,int klen, pem_password_cb *cd, void *u); + +#endif /* SSLEAY_MACROS */ + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PEM_strings(void); + +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 +#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 +#define PEM_F_DO_PK8PKEY 126 +#define PEM_F_DO_PK8PKEY_FP 125 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DEF_CALLBACK 100 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_PK8PKEY 119 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 +#define PEM_F_PEM_READ_PRIVATEKEY 124 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/pem2.h b/include/openssl/pem2.h new file mode 100755 index 0000000..97ba68a --- /dev/null +++ b/include/openssl/pem2.h @@ -0,0 +1,70 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* + * This header only exists to break a circular dependency between pem and err + * Ben 30 Jan 1999. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HEADER_PEM_H +void ERR_load_PEM_strings(void); +#endif + +#ifdef __cplusplus +} +#endif diff --git a/include/openssl/pkcs12.h b/include/openssl/pkcs12.h new file mode 100755 index 0000000..46d8dad --- /dev/null +++ b/include/openssl/pkcs12.h @@ -0,0 +1,333 @@ +/* pkcs12.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PKCS12_H +#define HEADER_PKCS12_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PKCS12_KEY_ID 1 +#define PKCS12_IV_ID 2 +#define PKCS12_MAC_ID 3 + +/* Default iteration count */ +#ifndef PKCS12_DEFAULT_ITER +#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER +#endif + +#define PKCS12_MAC_KEY_LENGTH 20 + +#define PKCS12_SALT_LEN 8 + +/* Uncomment out next line for unicode password and names, otherwise ASCII */ + +/*#define PBE_UNICODE*/ + +#ifdef PBE_UNICODE +#define PKCS12_key_gen PKCS12_key_gen_uni +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni +#else +#define PKCS12_key_gen PKCS12_key_gen_asc +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc +#endif + +/* MS key usage constants */ + +#define KEY_EX 0x10 +#define KEY_SIG 0x80 + +typedef struct { +X509_SIG *dinfo; +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; /* defaults to 1 */ +} PKCS12_MAC_DATA; + +typedef struct { +ASN1_INTEGER *version; +PKCS12_MAC_DATA *mac; +PKCS7 *authsafes; +} PKCS12; + +PREDECLARE_STACK_OF(PKCS12_SAFEBAG) + +typedef struct { +ASN1_OBJECT *type; +union { + struct pkcs12_bag_st *bag; /* secret, crl and certbag */ + struct pkcs8_priv_key_info_st *keybag; /* keybag */ + X509_SIG *shkeybag; /* shrouded key bag */ + STACK_OF(PKCS12_SAFEBAG) *safes; + ASN1_TYPE *other; +}value; +STACK_OF(X509_ATTRIBUTE) *attrib; +} PKCS12_SAFEBAG; + +DECLARE_STACK_OF(PKCS12_SAFEBAG) +DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG) +DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG) + +typedef struct pkcs12_bag_st { +ASN1_OBJECT *type; +union { + ASN1_OCTET_STRING *x509cert; + ASN1_OCTET_STRING *x509crl; + ASN1_OCTET_STRING *octet; + ASN1_IA5STRING *sdsicert; + ASN1_TYPE *other; /* Secret or other bag */ +}value; +} PKCS12_BAGS; + +#define PKCS12_ERROR 0 +#define PKCS12_OK 1 + +/* Compatibility macros */ + +#define M_PKCS12_x5092certbag PKCS12_x5092certbag +#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag + +#define M_PKCS12_certbag2x509 PKCS12_certbag2x509 +#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl + +#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data +#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes +#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes +#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata + +#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey +#define M_PKCS8_decrypt PKCS8_decrypt + +#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type) +#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type) +#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type + +#define PKCS12_get_attr(bag, attr_nid) \ + PKCS12_get_attr_gen(bag->attrib, attr_nid) + +#define PKCS8_get_attr(p8, attr_nid) \ + PKCS12_get_attr_gen(p8->attributes, attr_nid) + +#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) + + +PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509); +PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl); +X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag); +X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); + +PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, + int nid2); +PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, + int passlen); +X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, + int passlen, unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); +PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) *bags); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); + +int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); +STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); + +int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); +int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, + int namelen); +int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); +ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); +char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); +unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, + int passlen, unsigned char *in, int inlen, + unsigned char **data, int *datalen, int en_de); +void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf); +PKCS12 *PKCS12_init(int mode); +int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); +int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type, + int en_de); +int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *mac, unsigned int *maclen); +int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); +int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type); +int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, + int saltlen, const EVP_MD *md_type); +unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); +char *uni2asc(unsigned char *uni, int unilen); + +DECLARE_ASN1_FUNCTIONS(PKCS12) +DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) +DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) +DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) + +DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) +DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) + +void PKCS12_PBE_add(void); +int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, + STACK_OF(X509) **ca); +PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, + STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, + int mac_iter, int keytype); + +PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); +PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, + int key_usage, int iter, + int key_nid, char *pass); +int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, + int safe_nid, int iter, char *pass); +PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); + +int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); +int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); +PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); +PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); +int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS12_strings(void); + +/* Error codes for the PKCS12 functions. */ + +/* Function codes. */ +#define PKCS12_F_PARSE_BAG 129 +#define PKCS12_F_PARSE_BAGS 103 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102 +#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104 +#define PKCS12_F_PKCS12_CREATE 105 +#define PKCS12_F_PKCS12_GEN_MAC 107 +#define PKCS12_F_PKCS12_INIT 109 +#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 +#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 +#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 +#define PKCS12_F_PKCS12_KEY_GEN_ASC 110 +#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 +#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 +#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 +#define PKCS12_F_PKCS12_NEWPASS 128 +#define PKCS12_F_PKCS12_PACK_P7DATA 114 +#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 +#define PKCS12_F_PKCS12_PARSE 118 +#define PKCS12_F_PKCS12_PBE_CRYPT 119 +#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 +#define PKCS12_F_PKCS12_SETUP_MAC 122 +#define PKCS12_F_PKCS12_SET_MAC 123 +#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 +#define PKCS12_F_PKCS12_UNPACK_P7DATA 131 +#define PKCS12_F_PKCS12_VERIFY_MAC 126 +#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124 +#define PKCS12_F_PKCS8_ENCRYPT 125 + +/* Reason codes. */ +#define PKCS12_R_CANT_PACK_STRUCTURE 100 +#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 +#define PKCS12_R_DECODE_ERROR 101 +#define PKCS12_R_ENCODE_ERROR 102 +#define PKCS12_R_ENCRYPT_ERROR 103 +#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 +#define PKCS12_R_INVALID_NULL_ARGUMENT 104 +#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 +#define PKCS12_R_IV_GEN_ERROR 106 +#define PKCS12_R_KEY_GEN_ERROR 107 +#define PKCS12_R_MAC_ABSENT 108 +#define PKCS12_R_MAC_GENERATION_ERROR 109 +#define PKCS12_R_MAC_SETUP_ERROR 110 +#define PKCS12_R_MAC_STRING_SET_ERROR 111 +#define PKCS12_R_MAC_VERIFY_ERROR 112 +#define PKCS12_R_MAC_VERIFY_FAILURE 113 +#define PKCS12_R_PARSE_ERROR 114 +#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 +#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 +#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 +#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 +#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/pkcs7.h b/include/openssl/pkcs7.h new file mode 100755 index 0000000..eeb0532 --- /dev/null +++ b/include/openssl/pkcs7.h @@ -0,0 +1,464 @@ +/* crypto/pkcs7/pkcs7.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PKCS7_H +#define HEADER_PKCS7_H + +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 thes are defined in wincrypt.h */ +#undef PKCS7_ISSUER_AND_SERIAL +#undef PKCS7_SIGNER_INFO +#endif + +/* +Encryption_ID DES-CBC +Digest_ID MD5 +Digest_Encryption_ID rsaEncryption +Key_Encryption_ID rsaEncryption +*/ + +typedef struct pkcs7_issuer_and_serial_st + { + X509_NAME *issuer; + ASN1_INTEGER *serial; + } PKCS7_ISSUER_AND_SERIAL; + +typedef struct pkcs7_signer_info_st + { + ASN1_INTEGER *version; /* version 1 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *digest_alg; + STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ + X509_ALGOR *digest_enc_alg; + ASN1_OCTET_STRING *enc_digest; + STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ + + /* The private key to sign with */ + EVP_PKEY *pkey; + } PKCS7_SIGNER_INFO; + +DECLARE_STACK_OF(PKCS7_SIGNER_INFO) +DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) + +typedef struct pkcs7_recip_info_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *key_enc_algor; + ASN1_OCTET_STRING *enc_key; + X509 *cert; /* get the pub-key from this */ + } PKCS7_RECIP_INFO; + +DECLARE_STACK_OF(PKCS7_RECIP_INFO) +DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) + +typedef struct pkcs7_signed_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + struct pkcs7_st *contents; + } PKCS7_SIGNED; +/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE. + * How about merging the two */ + +typedef struct pkcs7_enc_content_st + { + ASN1_OBJECT *content_type; + X509_ALGOR *algorithm; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + const EVP_CIPHER *cipher; + } PKCS7_ENC_CONTENT; + +typedef struct pkcs7_enveloped_st + { + ASN1_INTEGER *version; /* version 0 */ + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENVELOPE; + +typedef struct pkcs7_signedandenveloped_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + PKCS7_ENC_CONTENT *enc_data; + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + } PKCS7_SIGN_ENVELOPE; + +typedef struct pkcs7_digest_st + { + ASN1_INTEGER *version; /* version 0 */ + X509_ALGOR *md; /* md used */ + struct pkcs7_st *contents; + ASN1_OCTET_STRING *digest; + } PKCS7_DIGEST; + +typedef struct pkcs7_encrypted_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENCRYPT; + +typedef struct pkcs7_st + { + /* The following is non NULL if it contains ASN1 encoding of + * this structure */ + unsigned char *asn1; + long length; + +#define PKCS7_S_HEADER 0 +#define PKCS7_S_BODY 1 +#define PKCS7_S_TAIL 2 + int state; /* used during processing */ + + int detached; + + ASN1_OBJECT *type; + /* content as defined by the type */ + /* all encryption/message digests are applied to the 'contents', + * leaving out the 'type' field. */ + union { + char *ptr; + + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + + /* NID_pkcs7_signed */ + PKCS7_SIGNED *sign; + + /* NID_pkcs7_enveloped */ + PKCS7_ENVELOPE *enveloped; + + /* NID_pkcs7_signedAndEnveloped */ + PKCS7_SIGN_ENVELOPE *signed_and_enveloped; + + /* NID_pkcs7_digest */ + PKCS7_DIGEST *digest; + + /* NID_pkcs7_encrypted */ + PKCS7_ENCRYPT *encrypted; + + /* Anything else */ + ASN1_TYPE *other; + } d; + } PKCS7; + +DECLARE_STACK_OF(PKCS7) +DECLARE_ASN1_SET_OF(PKCS7) +DECLARE_PKCS12_STACK_OF(PKCS7) + +#define PKCS7_OP_SET_DETACHED_SIGNATURE 1 +#define PKCS7_OP_GET_DETACHED_SIGNATURE 2 + +#define PKCS7_get_signed_attributes(si) ((si)->auth_attr) +#define PKCS7_get_attributes(si) ((si)->unauth_attr) + +#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) +#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) +#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +#define PKCS7_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) + +#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) + +#define PKCS7_set_detached(p,v) \ + PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) +#define PKCS7_get_detached(p) \ + PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) + +#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) + +#ifdef SSLEAY_MACROS +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +/* S/MIME related flags */ + +#define PKCS7_TEXT 0x1 +#define PKCS7_NOCERTS 0x2 +#define PKCS7_NOSIGS 0x4 +#define PKCS7_NOCHAIN 0x8 +#define PKCS7_NOINTERN 0x10 +#define PKCS7_NOVERIFY 0x20 +#define PKCS7_DETACHED 0x40 +#define PKCS7_BINARY 0x80 +#define PKCS7_NOATTR 0x100 +#define PKCS7_NOSMIMECAP 0x200 +#define PKCS7_NOOLDMIMETYPE 0x400 +#define PKCS7_CRLFEOL 0x800 +#define PKCS7_STREAM 0x1000 +#define PKCS7_NOCRL 0x2000 + +/* Flags: for compatibility with older code */ + +#define SMIME_TEXT PKCS7_TEXT +#define SMIME_NOCERTS PKCS7_NOCERTS +#define SMIME_NOSIGS PKCS7_NOSIGS +#define SMIME_NOCHAIN PKCS7_NOCHAIN +#define SMIME_NOINTERN PKCS7_NOINTERN +#define SMIME_NOVERIFY PKCS7_NOVERIFY +#define SMIME_DETACHED PKCS7_DETACHED +#define SMIME_BINARY PKCS7_BINARY +#define SMIME_NOATTR PKCS7_NOATTR + +DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) + +#ifndef SSLEAY_MACROS +int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, + unsigned char *md,unsigned int *len); +#ifndef OPENSSL_NO_FP_API +PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); +int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7); +#endif +PKCS7 *PKCS7_dup(PKCS7 *p7); +PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7); +int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); +#endif + +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) +DECLARE_ASN1_FUNCTIONS(PKCS7) + +DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) +DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) + +DECLARE_ASN1_NDEF_FUNCTION(PKCS7) + +long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); + +int PKCS7_set_type(PKCS7 *p7, int type); +int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); +int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); +int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); +int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); +int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); +int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); +int PKCS7_content_new(PKCS7 *p7, int nid); +int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, + BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, + X509 *x509); + +BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); +int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); +BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); + + +PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, + EVP_PKEY *pkey, const EVP_MD *dgst); +X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); +STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); + +PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); +int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); +int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); +int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); + +PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); +ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type, + void *data); +int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, + void *value); +ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); +ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); +int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); + + +PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, + BIO *data, int flags); +int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, + BIO *indata, BIO *out, int flags); +STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); +PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, + int flags); +int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); + +int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, + STACK_OF(X509_ALGOR) *cap); +STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); +int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); + +int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); +PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); +int SMIME_crlf_copy(BIO *in, BIO *out, int flags); +int SMIME_text(BIO *in, BIO *out); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS7_strings(void); + +/* Error codes for the PKCS7 functions. */ + +/* Function codes. */ +#define PKCS7_F_B64_READ_PKCS7 120 +#define PKCS7_F_B64_WRITE_PKCS7 121 +#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 +#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 +#define PKCS7_F_PKCS7_ADD_CRL 101 +#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 +#define PKCS7_F_PKCS7_ADD_SIGNER 103 +#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 +#define PKCS7_F_PKCS7_CTRL 104 +#define PKCS7_F_PKCS7_DATADECODE 112 +#define PKCS7_F_PKCS7_DATAFINAL 128 +#define PKCS7_F_PKCS7_DATAINIT 105 +#define PKCS7_F_PKCS7_DATASIGN 106 +#define PKCS7_F_PKCS7_DATAVERIFY 107 +#define PKCS7_F_PKCS7_DECRYPT 114 +#define PKCS7_F_PKCS7_ENCRYPT 115 +#define PKCS7_F_PKCS7_FIND_DIGEST 127 +#define PKCS7_F_PKCS7_GET0_SIGNERS 124 +#define PKCS7_F_PKCS7_SET_CIPHER 108 +#define PKCS7_F_PKCS7_SET_CONTENT 109 +#define PKCS7_F_PKCS7_SET_DIGEST 126 +#define PKCS7_F_PKCS7_SET_TYPE 110 +#define PKCS7_F_PKCS7_SIGN 116 +#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 +#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 +#define PKCS7_F_PKCS7_VERIFY 117 +#define PKCS7_F_SMIME_READ_PKCS7 122 +#define PKCS7_F_SMIME_TEXT 123 + +/* Reason codes. */ +#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 +#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 +#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 +#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 +#define PKCS7_R_DECODE_ERROR 130 +#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 +#define PKCS7_R_DECRYPT_ERROR 119 +#define PKCS7_R_DIGEST_FAILURE 101 +#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 +#define PKCS7_R_ERROR_SETTING_CIPHER 121 +#define PKCS7_R_INVALID_MIME_TYPE 131 +#define PKCS7_R_INVALID_NULL_POINTER 143 +#define PKCS7_R_MIME_NO_CONTENT_TYPE 132 +#define PKCS7_R_MIME_PARSE_ERROR 133 +#define PKCS7_R_MIME_SIG_PARSE_ERROR 134 +#define PKCS7_R_MISSING_CERIPEND_INFO 103 +#define PKCS7_R_NO_CONTENT 122 +#define PKCS7_R_NO_CONTENT_TYPE 135 +#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136 +#define PKCS7_R_NO_MULTIPART_BOUNDARY 137 +#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 +#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY 146 +#define PKCS7_R_NO_SIGNATURES_ON_DATA 123 +#define PKCS7_R_NO_SIGNERS 142 +#define PKCS7_R_NO_SIG_CONTENT_TYPE 138 +#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 +#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 +#define PKCS7_R_PKCS7_DATAFINAL 126 +#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125 +#define PKCS7_R_PKCS7_DATASIGN 145 +#define PKCS7_R_PKCS7_PARSE_ERROR 139 +#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140 +#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 +#define PKCS7_R_SIGNATURE_FAILURE 105 +#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 +#define PKCS7_R_SIG_INVALID_MIME_TYPE 141 +#define PKCS7_R_SMIME_TEXT_ERROR 129 +#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 +#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 +#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 +#define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 +#define PKCS7_R_UNKNOWN_OPERATION 110 +#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 +#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 +#define PKCS7_R_WRONG_CONTENT_TYPE 113 +#define PKCS7_R_WRONG_PKCS7_TYPE 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/pq_compat.h b/include/openssl/pq_compat.h new file mode 100755 index 0000000..2075042 --- /dev/null +++ b/include/openssl/pq_compat.h @@ -0,0 +1,147 @@ +/* crypto/pqueue/pqueue_compat.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "opensslconf.h" +#include + +/* + * The purpose of this header file is for supporting 64-bit integer + * manipulation on 32-bit (and lower) machines. Currently the only + * such environment is VMS, Utrix and those with smaller default integer + * sizes than 32 bits. For all such environment, we fall back to using + * BIGNUM. We may need to fine tune the conditions for systems that + * are incorrectly configured. + * + * The only clients of this code are (1) pqueue for priority, and + * (2) DTLS, for sequence number manipulation. + */ + +#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT) + +#define PQ_64BIT_IS_INTEGER 0 +#define PQ_64BIT_IS_BIGNUM 1 + +#define PQ_64BIT BIGNUM +#define PQ_64BIT_CTX BN_CTX + +#define pq_64bit_init(x) BN_init(x) +#define pq_64bit_free(x) BN_free(x) + +#define pq_64bit_ctx_new(ctx) BN_CTX_new() +#define pq_64bit_ctx_free(x) BN_CTX_free(x) + +#define pq_64bit_assign(x, y) BN_copy(x, y) +#define pq_64bit_assign_word(x, y) BN_set_word(x, y) +#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0 +#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0 +#define pq_64bit_add_word(x, w) BN_add_word(x, w) +#define pq_64bit_sub(r, x, y) BN_sub(r, x, y) +#define pq_64bit_sub_word(x, w) BN_sub_word(x, w) +#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn) +#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes) +#define pq_64bit_get_word(x) BN_get_word(x) +#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset) +#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift) +#define pq_64bit_set_bit(x, num) BN_set_bit(x, num) +#define pq_64bit_get_length(x) BN_num_bits((x)) + +#else + +#define PQ_64BIT_IS_INTEGER 1 +#define PQ_64BIT_IS_BIGNUM 0 + +#if defined(SIXTY_FOUR_BIT) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%lld" +#elif defined(SIXTY_FOUR_BIT_LONG) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%ld" +#elif defined(THIRTY_TWO_BIT) +#define PQ_64BIT BN_ULLONG +#define PQ_64BIT_PRINT "%lld" +#endif + +#define PQ_64BIT_CTX void + +#define pq_64bit_init(x) +#define pq_64bit_free(x) +#define pq_64bit_ctx_new(ctx) (ctx) +#define pq_64bit_ctx_free(x) + +#define pq_64bit_assign(x, y) (*(x) = *(y)) +#define pq_64bit_assign_word(x, y) (*(x) = y) +#define pq_64bit_gt(x, y) (*(x) > *(y)) +#define pq_64bit_eq(x, y) (*(x) == *(y)) +#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w))) +#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y))) +#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w))) +#define pq_64bit_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num) +#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes) +#define pq_64bit_get_word(x) *(x) +#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift))) +#define pq_64bit_set_bit(x, num) do { \ + PQ_64BIT mask = 1; \ + mask = mask << (num); \ + *(x) |= mask; \ + } while(0) +#endif /* OPENSSL_SYS_VMS */ diff --git a/include/openssl/pqueue.h b/include/openssl/pqueue.h new file mode 100755 index 0000000..699095f --- /dev/null +++ b/include/openssl/pqueue.h @@ -0,0 +1,95 @@ +/* crypto/pqueue/pqueue.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PQUEUE_H +#define HEADER_PQUEUE_H + +#include +#include +#include + +#include + +typedef struct _pqueue *pqueue; + +typedef struct _pitem + { + PQ_64BIT priority; + void *data; + struct _pitem *next; + } pitem; + +typedef struct _pitem *piterator; + +pitem *pitem_new(PQ_64BIT priority, void *data); +void pitem_free(pitem *item); + +pqueue pqueue_new(void); +void pqueue_free(pqueue pq); + +pitem *pqueue_insert(pqueue pq, pitem *item); +pitem *pqueue_peek(pqueue pq); +pitem *pqueue_pop(pqueue pq); +pitem *pqueue_find(pqueue pq, PQ_64BIT priority); +pitem *pqueue_iterator(pqueue pq); +pitem *pqueue_next(piterator *iter); + +void pqueue_print(pqueue pq); + +#endif /* ! HEADER_PQUEUE_H */ diff --git a/include/openssl/rand.h b/include/openssl/rand.h new file mode 100755 index 0000000..e2f9f82 --- /dev/null +++ b/include/openssl/rand.h @@ -0,0 +1,140 @@ +/* crypto/rand/rand.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RAND_H +#define HEADER_RAND_H + +#include +#include +#include + +#if defined(OPENSSL_SYS_WINDOWS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_RAND_SIZE_T size_t +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct rand_meth_st RAND_METHOD; */ + +struct rand_meth_st + { + void (*seed)(const void *buf, int num); + int (*bytes)(unsigned char *buf, int num); + void (*cleanup)(void); + void (*add)(const void *buf, int num, double entropy); + int (*pseudorand)(unsigned char *buf, int num); + int (*status)(void); + }; + +#ifdef BN_DEBUG +extern int rand_predictable; +#endif + +int RAND_set_rand_method(const RAND_METHOD *meth); +const RAND_METHOD *RAND_get_rand_method(void); +#ifndef OPENSSL_NO_ENGINE +int RAND_set_rand_engine(ENGINE *engine); +#endif +RAND_METHOD *RAND_SSLeay(void); +void RAND_cleanup(void ); +int RAND_bytes(unsigned char *buf,int num); +int RAND_pseudo_bytes(unsigned char *buf,int num); +void RAND_seed(const void *buf,int num); +void RAND_add(const void *buf,int num,double entropy); +int RAND_load_file(const char *file,long max_bytes); +int RAND_write_file(const char *file); +const char *RAND_file_name(char *file,size_t num); +int RAND_status(void); +int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); +int RAND_egd(const char *path); +int RAND_egd_bytes(const char *path,int bytes); +int RAND_poll(void); + +#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) + +void RAND_screen(void); +int RAND_event(UINT, WPARAM, LPARAM); + +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RAND_strings(void); + +/* Error codes for the RAND functions. */ + +/* Function codes. */ +#define RAND_F_RAND_GET_RAND_METHOD 101 +#define RAND_F_SSLEAY_RAND_BYTES 100 + +/* Reason codes. */ +#define RAND_R_PRNG_NOT_SEEDED 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/rc2.h b/include/openssl/rc2.h new file mode 100755 index 0000000..13edfaf --- /dev/null +++ b/include/openssl/rc2.h @@ -0,0 +1,101 @@ +/* crypto/rc2/rc2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC2_H +#define HEADER_RC2_H + +#include /* OPENSSL_NO_RC2, RC2_INT */ +#ifdef OPENSSL_NO_RC2 +#error RC2 is disabled. +#endif + +#define RC2_ENCRYPT 1 +#define RC2_DECRYPT 0 + +#define RC2_BLOCK 8 +#define RC2_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc2_key_st + { + RC2_INT data[64]; + } RC2_KEY; + + +void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); +void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, + int enc); +void RC2_encrypt(unsigned long *data,RC2_KEY *key); +void RC2_decrypt(unsigned long *data,RC2_KEY *key); +void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, int enc); +void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/rc4.h b/include/openssl/rc4.h new file mode 100755 index 0000000..676ffdb --- /dev/null +++ b/include/openssl/rc4.h @@ -0,0 +1,87 @@ +/* crypto/rc4/rc4.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC4_H +#define HEADER_RC4_H + +#include /* OPENSSL_NO_RC4, RC4_INT */ +#ifdef OPENSSL_NO_RC4 +#error RC4 is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc4_key_st + { + RC4_INT x,y; + RC4_INT data[256]; + } RC4_KEY; + + +const char *RC4_options(void); +void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); +void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, + unsigned char *outdata); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/ripemd.h b/include/openssl/ripemd.h new file mode 100755 index 0000000..e0474f0 --- /dev/null +++ b/include/openssl/ripemd.h @@ -0,0 +1,104 @@ +/* crypto/ripemd/ripemd.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RIPEMD_H +#define HEADER_RIPEMD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_RIPEMD +#error RIPEMD is disabled. +#endif + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define RIPEMD160_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define RIPEMD160_LONG unsigned long +#define RIPEMD160_LONG_LOG2 3 +#else +#define RIPEMD160_LONG unsigned int +#endif + +#define RIPEMD160_CBLOCK 64 +#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) +#define RIPEMD160_DIGEST_LENGTH 20 + +typedef struct RIPEMD160state_st + { + RIPEMD160_LONG A,B,C,D,E; + RIPEMD160_LONG Nl,Nh; + RIPEMD160_LONG data[RIPEMD160_LBLOCK]; + unsigned int num; + } RIPEMD160_CTX; + +int RIPEMD160_Init(RIPEMD160_CTX *c); +int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); +int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); +unsigned char *RIPEMD160(const unsigned char *d, size_t n, + unsigned char *md); +void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h new file mode 100755 index 0000000..f650681 --- /dev/null +++ b/include/openssl/rsa.h @@ -0,0 +1,441 @@ +/* crypto/rsa/rsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RSA_H +#define HEADER_RSA_H + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_NO_RSA +#error RSA is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct rsa_st RSA; */ +/* typedef struct rsa_meth_st RSA_METHOD; */ + +struct rsa_meth_st + { + const char *name; + int (*rsa_pub_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_pub_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */ + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(RSA *rsa); /* called at new */ + int (*finish)(RSA *rsa); /* called at free */ + int flags; /* RSA_METHOD_FLAG_* things */ + char *app_data; /* may be needed! */ +/* New sign and verify functions: some libraries don't allow arbitrary data + * to be signed/verified: this allows them to be used. Note: for this to work + * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used + * RSA_sign(), RSA_verify() should be used instead. Note: for backwards + * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER + * option is set in 'flags'. + */ + int (*rsa_sign)(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, const RSA *rsa); + int (*rsa_verify)(int dtype, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); +/* If this callback is NULL, the builtin software RSA key-gen will be used. This + * is for behavioural compatibility whilst the code gets rewired, but one day + * it would be nice to assume there are no such things as "builtin software" + * implementations. */ + int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + }; + +struct rsa_st + { + /* The first parameter is used to pickup errors where + * this is passed instead of aEVP_PKEY, it is set to 0 */ + int pad; + long version; + const RSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + BIGNUM *n; + BIGNUM *e; + BIGNUM *d; + BIGNUM *p; + BIGNUM *q; + BIGNUM *dmp1; + BIGNUM *dmq1; + BIGNUM *iqmp; + /* be careful using this if the RSA structure is shared */ + CRYPTO_EX_DATA ex_data; + int references; + int flags; + + /* Used to cache montgomery values */ + BN_MONT_CTX *_method_mod_n; + BN_MONT_CTX *_method_mod_p; + BN_MONT_CTX *_method_mod_q; + + /* all BIGNUM values are actually in the following data, if it is not + * NULL */ + char *bignum_data; + BN_BLINDING *blinding; + BN_BLINDING *mt_blinding; + }; + +#ifndef OPENSSL_RSA_MAX_MODULUS_BITS +# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 +#endif + +#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS +# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 +#endif +#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS +# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "large" modulus only */ +#endif + +#define RSA_3 0x3L +#define RSA_F4 0x10001L + +#define RSA_METHOD_FLAG_NO_CHECK 0x0001 /* don't check pub/private match */ + +#define RSA_FLAG_CACHE_PUBLIC 0x0002 +#define RSA_FLAG_CACHE_PRIVATE 0x0004 +#define RSA_FLAG_BLINDING 0x0008 +#define RSA_FLAG_THREAD_SAFE 0x0010 +/* This flag means the private key operations will be handled by rsa_mod_exp + * and that they do not depend on the private key components being present: + * for example a key stored in external hardware. Without this flag bn_mod_exp + * gets called when private key components are absent. + */ +#define RSA_FLAG_EXT_PKEY 0x0020 + +/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions. + */ +#define RSA_FLAG_SIGN_VER 0x0040 + +#define RSA_FLAG_NO_BLINDING 0x0080 /* new with 0.9.6j and 0.9.7b; the built-in + * RSA implementation now uses blinding by + * default (ignoring RSA_FLAG_BLINDING), + * but other engines might not need it + */ +#define RSA_FLAG_NO_EXP_CONSTTIME 0x0100 /* new with 0.9.7h; the built-in RSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#define RSA_PKCS1_PADDING 1 +#define RSA_SSLV23_PADDING 2 +#define RSA_NO_PADDING 3 +#define RSA_PKCS1_OAEP_PADDING 4 +#define RSA_X931_PADDING 5 + +#define RSA_PKCS1_PADDING_SIZE 11 + +#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) +#define RSA_get_app_data(s) RSA_get_ex_data(s,0) + +RSA * RSA_new(void); +RSA * RSA_new_method(ENGINE *engine); +int RSA_size(const RSA *); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +RSA * RSA_generate_key(int bits, unsigned long e,void + (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + +int RSA_check_key(const RSA *); + /* next 4 return -1 on error */ +int RSA_public_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_public_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +void RSA_free (RSA *r); +/* "up" the RSA object's reference count */ +int RSA_up_ref(RSA *r); + +int RSA_flags(const RSA *r); + +void RSA_set_default_method(const RSA_METHOD *meth); +const RSA_METHOD *RSA_get_default_method(void); +const RSA_METHOD *RSA_get_method(const RSA *rsa); +int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); + +/* This function needs the memory locking malloc callbacks to be installed */ +int RSA_memory_lock(RSA *r); + +/* these are the actual SSLeay RSA functions */ +const RSA_METHOD *RSA_PKCS1_SSLeay(void); + +const RSA_METHOD *RSA_null_method(void); + +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) + +#ifndef OPENSSL_NO_FP_API +int RSA_print_fp(FILE *fp, const RSA *r,int offset); +#endif + +#ifndef OPENSSL_NO_BIO +int RSA_print(BIO *bp, const RSA *r,int offset); +#endif + +int i2d_RSA_NET(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); +RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); + +int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); +RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); + +/* The following 2 functions sign and verify a X509_SIG ASN1 object + * inside PKCS#1 padded RSA encryption */ +int RSA_sign(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +/* The following 2 function sign and verify a ASN1_OCTET_STRING + * object inside PKCS#1 padded RSA encryption */ +int RSA_sign_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); +void RSA_blinding_off(RSA *rsa); +BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); + +int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int PKCS1_MGF1(unsigned char *mask, long len, + const unsigned char *seed, long seedlen, const EVP_MD *dgst); +int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl, + const unsigned char *p,int pl); +int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len, + const unsigned char *p,int pl); +int RSA_padding_add_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_none(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_none(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_X931_hash_id(int nid); + +int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const unsigned char *EM, int sLen); +int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, int sLen); + +int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int RSA_set_ex_data(RSA *r,int idx,void *arg); +void *RSA_get_ex_data(const RSA *r, int idx); + +RSA *RSAPublicKey_dup(RSA *rsa); +RSA *RSAPrivateKey_dup(RSA *rsa); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RSA_strings(void); + +/* Error codes for the RSA functions. */ + +/* Function codes. */ +#define RSA_F_MEMORY_LOCK 100 +#define RSA_F_RSA_BUILTIN_KEYGEN 129 +#define RSA_F_RSA_CHECK_KEY 123 +#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 +#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 +#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 +#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 +#define RSA_F_RSA_GENERATE_KEY 105 +#define RSA_F_RSA_MEMORY_LOCK 130 +#define RSA_F_RSA_NEW_METHOD 106 +#define RSA_F_RSA_NULL 124 +#define RSA_F_RSA_NULL_MOD_EXP 131 +#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 +#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 +#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 +#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 +#define RSA_F_RSA_PADDING_ADD_NONE 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 +#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 +#define RSA_F_RSA_PADDING_ADD_SSLV23 110 +#define RSA_F_RSA_PADDING_ADD_X931 127 +#define RSA_F_RSA_PADDING_CHECK_NONE 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 114 +#define RSA_F_RSA_PADDING_CHECK_X931 128 +#define RSA_F_RSA_PRINT 115 +#define RSA_F_RSA_PRINT_FP 116 +#define RSA_F_RSA_SETUP_BLINDING 136 +#define RSA_F_RSA_SIGN 117 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 +#define RSA_F_RSA_VERIFY 119 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 +#define RSA_F_RSA_VERIFY_PKCS1_PSS 126 + +/* Reason codes. */ +#define RSA_R_ALGORITHM_MISMATCH 100 +#define RSA_R_BAD_E_VALUE 101 +#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +#define RSA_R_BAD_PAD_BYTE_COUNT 103 +#define RSA_R_BAD_SIGNATURE 104 +#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +#define RSA_R_DATA_TOO_LARGE 109 +#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 +#define RSA_R_DATA_TOO_SMALL 111 +#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 +#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 +#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 +#define RSA_R_FIRST_OCTET_INVALID 133 +#define RSA_R_INVALID_HEADER 137 +#define RSA_R_INVALID_MESSAGE_LENGTH 131 +#define RSA_R_INVALID_PADDING 138 +#define RSA_R_INVALID_TRAILER 139 +#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 +#define RSA_R_KEY_SIZE_TOO_SMALL 120 +#define RSA_R_LAST_OCTET_INVALID 134 +#define RSA_R_MODULUS_TOO_LARGE 105 +#define RSA_R_NO_PUBLIC_EXPONENT 140 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 +#define RSA_R_OAEP_DECODING_ERROR 121 +#define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_P_NOT_PRIME 128 +#define RSA_R_Q_NOT_PRIME 129 +#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 +#define RSA_R_SLEN_CHECK_FAILED 136 +#define RSA_R_SLEN_RECOVERY_FAILED 135 +#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +#define RSA_R_UNKNOWN_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/safestack.h b/include/openssl/safestack.h new file mode 100755 index 0000000..8515019 --- /dev/null +++ b/include/openssl/safestack.h @@ -0,0 +1,1850 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SAFESTACK_H +#define HEADER_SAFESTACK_H + +#include + +typedef void (*openssl_fptr)(void); +#define openssl_fcast(f) ((openssl_fptr)f) + +#ifdef DEBUG_SAFESTACK + +#define STACK_OF(type) struct stack_st_##type +#define PREDECLARE_STACK_OF(type) STACK_OF(type); + +#define DECLARE_STACK_OF(type) \ +STACK_OF(type) \ + { \ + STACK stack; \ + }; + +#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ + +/* SKM_sk_... stack macros are internal to safestack.h: + * never use them directly, use sk__... instead */ +#define SKM_sk_new(type, cmp) \ + ((STACK_OF(type) * (*)(int (*)(const type * const *, const type * const *)))openssl_fcast(sk_new))(cmp) +#define SKM_sk_new_null(type) \ + ((STACK_OF(type) * (*)(void))openssl_fcast(sk_new_null))() +#define SKM_sk_free(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_free))(st) +#define SKM_sk_num(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_num))(st) +#define SKM_sk_value(type, st,i) \ + ((type * (*)(const STACK_OF(type) *, int))openssl_fcast(sk_value))(st, i) +#define SKM_sk_set(type, st,i,val) \ + ((type * (*)(STACK_OF(type) *, int, type *))openssl_fcast(sk_set))(st, i, val) +#define SKM_sk_zero(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_zero))(st) +#define SKM_sk_push(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_push))(st, val) +#define SKM_sk_unshift(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_unshift))(st, val) +#define SKM_sk_find(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_find))(st, val) +#define SKM_sk_delete(type, st,i) \ + ((type * (*)(STACK_OF(type) *, int))openssl_fcast(sk_delete))(st, i) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type * (*)(STACK_OF(type) *, type *))openssl_fcast(sk_delete_ptr))(st, ptr) +#define SKM_sk_insert(type, st,val,i) \ + ((int (*)(STACK_OF(type) *, type *, int))openssl_fcast(sk_insert))(st, val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*(*)(STACK_OF(type) *, int (*)(const type * const *, const type * const *))) \ + (const type * const *, const type * const *))openssl_fcast(sk_set_cmp_func))\ + (st, cmp) +#define SKM_sk_dup(type, st) \ + ((STACK_OF(type) *(*)(STACK_OF(type) *))openssl_fcast(sk_dup))(st) +#define SKM_sk_pop_free(type, st,free_func) \ + ((void (*)(STACK_OF(type) *, void (*)(type *)))openssl_fcast(sk_pop_free))\ + (st, free_func) +#define SKM_sk_shift(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_shift))(st) +#define SKM_sk_pop(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_pop))(st) +#define SKM_sk_sort(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_sort))(st) +#define SKM_sk_is_sorted(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_is_sorted))(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ +((STACK_OF(type) * (*) (STACK_OF(type) **,const unsigned char **, long , \ + type *(*)(type **, const unsigned char **,long), \ + void (*)(type *), int ,int )) openssl_fcast(d2i_ASN1_SET)) \ + (st,pp,length, d2i_func, free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + ((int (*)(STACK_OF(type) *,unsigned char **, \ + int (*)(type *,unsigned char **), int , int , int)) openssl_fcast(i2d_ASN1_SET)) \ + (st,pp,i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ((unsigned char *(*)(STACK_OF(type) *, \ + int (*)(type *,unsigned char **), unsigned char **,int *)) openssl_fcast(ASN1_seq_pack)) \ + (st, i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ((STACK_OF(type) * (*)(const unsigned char *,int, \ + type *(*)(type **,const unsigned char **, long), \ + void (*)(type *)))openssl_fcast(ASN1_seq_unpack)) \ + (buf,len,d2i_func, free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK_OF(type) * (*)(X509_ALGOR *, \ + type *(*)(type **, const unsigned char **, long), \ + void (*)(type *), \ + const char *, int, \ + ASN1_STRING *, int))PKCS12_decrypt_d2i) \ + (algor,d2i_func,free_func,pass,passlen,oct,seq) + +#else + +#define STACK_OF(type) STACK +#define PREDECLARE_STACK_OF(type) /* nada */ +#define DECLARE_STACK_OF(type) /* nada */ +#define IMPLEMENT_STACK_OF(type) /* nada */ + +#define SKM_sk_new(type, cmp) \ + sk_new((int (*)(const char * const *, const char * const *))(cmp)) +#define SKM_sk_new_null(type) \ + sk_new_null() +#define SKM_sk_free(type, st) \ + sk_free(st) +#define SKM_sk_num(type, st) \ + sk_num(st) +#define SKM_sk_value(type, st,i) \ + ((type *)sk_value(st, i)) +#define SKM_sk_set(type, st,i,val) \ + ((type *)sk_set(st, i,(char *)val)) +#define SKM_sk_zero(type, st) \ + sk_zero(st) +#define SKM_sk_push(type, st,val) \ + sk_push(st, (char *)val) +#define SKM_sk_unshift(type, st,val) \ + sk_unshift(st, val) +#define SKM_sk_find(type, st,val) \ + sk_find(st, (char *)val) +#define SKM_sk_delete(type, st,i) \ + ((type *)sk_delete(st, i)) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type *)sk_delete_ptr(st,(char *)ptr)) +#define SKM_sk_insert(type, st,val,i) \ + sk_insert(st, (char *)val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*)(const type * const *,const type * const *)) \ + sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp))) +#define SKM_sk_dup(type, st) \ + sk_dup(st) +#define SKM_sk_pop_free(type, st,free_func) \ + sk_pop_free(st, (void (*)(void *))free_func) +#define SKM_sk_shift(type, st) \ + ((type *)sk_shift(st)) +#define SKM_sk_pop(type, st) \ + ((type *)sk_pop(st)) +#define SKM_sk_sort(type, st) \ + sk_sort(st) +#define SKM_sk_is_sorted(type, st) \ + sk_is_sorted(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq)) + +#endif + +/* This block of defines is updated by util/mkstack.pl, please do not touch! */ +#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION) +#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val)) +#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr)) +#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i)) +#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp)) +#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st) +#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func)) +#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st)) + +#define sk_ASIdOrRange_new(st) SKM_sk_new(ASIdOrRange, (st)) +#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange) +#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st)) +#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st)) +#define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i)) +#define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val)) +#define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st)) +#define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i)) +#define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr)) +#define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i)) +#define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp)) +#define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st) +#define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func)) +#define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st)) +#define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st)) +#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st)) +#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st)) + +#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING) +#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val)) +#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr)) +#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i)) +#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp)) +#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st) +#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func)) +#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st)) + +#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) +#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val)) +#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr)) +#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i)) +#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp)) +#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st) +#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func)) +#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st)) + +#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT) +#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val)) +#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr)) +#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i)) +#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp)) +#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st) +#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func)) +#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st)) + +#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE) +#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val)) +#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr)) +#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i)) +#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp)) +#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st) +#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func)) +#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st)) + +#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE) +#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val)) +#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr)) +#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i)) +#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp)) +#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st) +#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func)) +#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st)) + +#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE) +#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val)) +#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr)) +#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i)) +#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp)) +#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st) +#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func)) +#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st)) + +#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) +#define sk_BIO_new_null() SKM_sk_new_null(BIO) +#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) +#define sk_BIO_num(st) SKM_sk_num(BIO, (st)) +#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i)) +#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val)) +#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st)) +#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val)) +#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val)) +#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val)) +#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val)) +#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i)) +#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr)) +#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i)) +#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp)) +#define sk_BIO_dup(st) SKM_sk_dup(BIO, st) +#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func)) +#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st)) +#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st)) +#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) +#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st)) + +#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE) +#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val)) +#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr)) +#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i)) +#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp)) +#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st) +#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func)) +#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st)) + +#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st)) +#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE) +#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st)) +#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st)) +#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val)) +#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st)) +#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr)) +#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i)) +#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp)) +#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st) +#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func)) +#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st)) +#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st)) +#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st)) +#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st)) + +#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) +#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) +#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) +#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st)) +#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val)) +#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st)) +#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr)) +#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i)) +#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp)) +#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st) +#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func)) +#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st)) +#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st)) +#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st)) +#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st)) + +#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS) +#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr)) +#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp)) +#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st) +#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func)) +#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st)) + +#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock) +#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val)) +#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr)) +#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i)) +#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp)) +#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st) +#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func)) +#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st)) + +#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st)) +#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT) +#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st)) +#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st)) +#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val)) +#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st)) +#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr)) +#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i)) +#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp)) +#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st) +#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func)) +#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st)) +#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st)) +#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) +#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st)) + +#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st)) +#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE) +#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st)) +#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st)) +#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i)) +#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val)) +#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st)) +#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val)) +#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val)) +#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val)) +#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val)) +#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i)) +#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr)) +#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i)) +#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp)) +#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st) +#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func)) +#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st)) +#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st)) +#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st)) +#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st)) + +#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM) +#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val)) +#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr)) +#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp)) +#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st) +#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func)) +#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st)) + +#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) +#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val)) +#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr)) +#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i)) +#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp)) +#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st) +#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func)) +#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st)) + +#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE) +#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val)) +#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr)) +#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i)) +#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp)) +#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st) +#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func)) +#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st)) + +#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st)) +#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily) +#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st)) +#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st)) +#define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i)) +#define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val)) +#define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st)) +#define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i)) +#define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr)) +#define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i)) +#define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp)) +#define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st) +#define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func)) +#define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st)) +#define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st)) +#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st)) +#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st)) + +#define sk_IPAddressOrRange_new(st) SKM_sk_new(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange) +#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i)) +#define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val)) +#define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i)) +#define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr)) +#define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i)) +#define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp)) +#define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st) +#define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func)) +#define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st)) + +#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY) +#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val)) +#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr)) +#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i)) +#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp)) +#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st) +#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func)) +#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st)) + +#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA) +#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val)) +#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr)) +#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i)) +#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp)) +#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st) +#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func)) +#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st)) + +#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY) +#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val)) +#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr)) +#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i)) +#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp)) +#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st) +#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func)) +#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st)) + +#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM) +#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val)) +#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr)) +#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i)) +#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp)) +#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st) +#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func)) +#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st)) + +#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA) +#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val)) +#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr)) +#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i)) +#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp)) +#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st) +#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func)) +#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st)) + +#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY) +#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val)) +#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr)) +#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i)) +#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp)) +#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st) +#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func)) +#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st)) + +#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME) +#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val)) +#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr)) +#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i)) +#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp)) +#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st) +#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func)) +#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st)) + +#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY) +#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val)) +#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr)) +#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i)) +#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp)) +#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st) +#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func)) +#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st)) + +#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) +#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) +#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) +#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st)) +#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val)) +#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st)) +#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr)) +#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i)) +#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp)) +#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st) +#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func)) +#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st)) +#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st)) +#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st)) +#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st)) + +#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st)) +#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM) +#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st)) +#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st)) +#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val)) +#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st)) +#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr)) +#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i)) +#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp)) +#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st) +#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func)) +#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st)) +#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st)) +#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st)) +#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st)) + +#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS) +#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val)) +#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr)) +#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i)) +#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp)) +#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st) +#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func)) +#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st)) + +#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID) +#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val)) +#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr)) +#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i)) +#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp)) +#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st) +#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func)) +#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st)) + +#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ) +#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val)) +#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr)) +#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i)) +#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp)) +#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st) +#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func)) +#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st)) + +#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP) +#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val)) +#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr)) +#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i)) +#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp)) +#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st) +#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func)) +#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st)) + +#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) +#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val)) +#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr)) +#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i)) +#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp)) +#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st) +#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func)) +#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st)) + +#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st)) +#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7) +#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st)) +#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st)) +#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i)) +#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val)) +#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st)) +#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val)) +#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val)) +#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val)) +#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val)) +#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i)) +#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr)) +#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i)) +#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp)) +#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st) +#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func)) +#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st)) +#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st)) +#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st)) +#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st)) + +#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO) +#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val)) +#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr)) +#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i)) +#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp)) +#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st) +#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func)) +#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st)) + +#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO) +#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val)) +#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr)) +#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i)) +#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp)) +#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st) +#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func)) +#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st)) + +#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st)) +#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO) +#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st)) +#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st)) +#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val)) +#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st)) +#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr)) +#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i)) +#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp)) +#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st) +#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func)) +#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st)) +#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st)) +#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st)) +#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st)) + +#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO) +#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val)) +#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr)) +#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i)) +#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp)) +#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st) +#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func)) +#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st)) + +#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING) +#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val)) +#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr)) +#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i)) +#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp)) +#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st) +#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func)) +#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st)) + +#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER) +#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val)) +#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr)) +#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i)) +#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp)) +#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st) +#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func)) +#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st)) + +#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st)) +#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP) +#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st)) +#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st)) +#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val)) +#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st)) +#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr)) +#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i)) +#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp)) +#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st) +#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func)) +#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st)) +#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st)) +#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st)) +#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st)) + +#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT) +#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val)) +#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr)) +#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i)) +#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp)) +#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st) +#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func)) +#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st)) + +#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st)) +#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID) +#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st)) +#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st)) +#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i)) +#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val)) +#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st)) +#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val)) +#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val)) +#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val)) +#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val)) +#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i)) +#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr)) +#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i)) +#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp)) +#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st) +#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func)) +#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st)) +#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st)) +#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) +#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st)) + +#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st)) +#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING) +#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st)) +#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st)) +#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i)) +#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val)) +#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st)) +#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val)) +#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val)) +#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val)) +#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val)) +#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i)) +#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr)) +#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i)) +#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp)) +#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st) +#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func)) +#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st)) +#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st)) +#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st)) +#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st)) + +#define sk_X509_new(st) SKM_sk_new(X509, (st)) +#define sk_X509_new_null() SKM_sk_new_null(X509) +#define sk_X509_free(st) SKM_sk_free(X509, (st)) +#define sk_X509_num(st) SKM_sk_num(X509, (st)) +#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i)) +#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val)) +#define sk_X509_zero(st) SKM_sk_zero(X509, (st)) +#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val)) +#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val)) +#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val)) +#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val)) +#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i)) +#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr)) +#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i)) +#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp)) +#define sk_X509_dup(st) SKM_sk_dup(X509, st) +#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func)) +#define sk_X509_shift(st) SKM_sk_shift(X509, (st)) +#define sk_X509_pop(st) SKM_sk_pop(X509, (st)) +#define sk_X509_sort(st) SKM_sk_sort(X509, (st)) +#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st)) + +#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD) +#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val)) +#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr)) +#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i)) +#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp)) +#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st) +#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func)) +#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st)) + +#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st)) +#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR) +#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st)) +#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st)) +#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val)) +#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st)) +#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr)) +#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i)) +#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp)) +#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st) +#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func)) +#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st)) +#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st)) +#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st)) +#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st)) + +#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE) +#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val)) +#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr)) +#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i)) +#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp)) +#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st) +#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func)) +#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st)) + +#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st)) +#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL) +#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st)) +#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st)) +#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i)) +#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val)) +#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st)) +#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val)) +#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val)) +#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val)) +#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val)) +#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i)) +#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr)) +#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i)) +#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp)) +#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st) +#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func)) +#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st)) +#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st)) +#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st)) +#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st)) + +#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION) +#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val)) +#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr)) +#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i)) +#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp)) +#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st) +#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func)) +#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st)) + +#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st)) +#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO) +#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st)) +#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st)) +#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i)) +#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val)) +#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st)) +#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val)) +#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val)) +#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val)) +#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val)) +#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i)) +#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr)) +#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i)) +#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp)) +#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st) +#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func)) +#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st)) +#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st)) +#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st)) +#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st)) + +#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP) +#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val)) +#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr)) +#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i)) +#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp)) +#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st) +#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func)) +#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st)) + +#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st)) +#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME) +#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st)) +#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st)) +#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i)) +#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val)) +#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st)) +#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val)) +#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val)) +#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val)) +#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val)) +#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i)) +#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr)) +#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i)) +#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp)) +#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st) +#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func)) +#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st)) +#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st)) +#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st)) +#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st)) + +#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY) +#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val)) +#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr)) +#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i)) +#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp)) +#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st) +#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func)) +#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st)) + +#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st)) +#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT) +#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st)) +#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st)) +#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val)) +#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st)) +#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr)) +#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i)) +#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp)) +#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st) +#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func)) +#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st)) +#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st)) +#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st)) +#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st)) + +#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA) +#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val)) +#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr)) +#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i)) +#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp)) +#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st) +#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func)) +#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st)) + +#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE) +#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val)) +#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr)) +#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i)) +#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp)) +#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st) +#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func)) +#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st)) + +#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF) +#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val)) +#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr)) +#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i)) +#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp)) +#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st) +#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func)) +#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st)) + +#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE) +#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val)) +#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr)) +#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i)) +#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp)) +#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st) +#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func)) +#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st)) + +#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st)) +#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED) +#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st)) +#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st)) +#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val)) +#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st)) +#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr)) +#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i)) +#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp)) +#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st) +#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func)) +#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st)) +#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st)) +#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st)) +#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st)) + +#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st)) +#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST) +#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st)) +#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st)) +#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val)) +#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st)) +#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr)) +#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i)) +#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp)) +#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st) +#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func)) +#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st)) +#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st)) +#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st)) +#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st)) + +#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM) +#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val)) +#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr)) +#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i)) +#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp)) +#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st) +#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func)) +#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st)) + +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func)) + +#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) + +#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) +/* End of util/mkstack.pl block, you may now edit :-) */ + +#endif /* !defined HEADER_SAFESTACK_H */ diff --git a/include/openssl/sha.h b/include/openssl/sha.h new file mode 100755 index 0000000..5064482 --- /dev/null +++ b/include/openssl/sha.h @@ -0,0 +1,200 @@ +/* crypto/sha/sha.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SHA_H +#define HEADER_SHA_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) +#error SHA is disabled. +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_SHA_SIZE_T size_t +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! SHA_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define SHA_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define SHA_LONG unsigned long +#define SHA_LONG_LOG2 3 +#else +#define SHA_LONG unsigned int +#endif + +#define SHA_LBLOCK 16 +#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA_LAST_BLOCK (SHA_CBLOCK-8) +#define SHA_DIGEST_LENGTH 20 + +typedef struct SHAstate_st + { + SHA_LONG h0,h1,h2,h3,h4; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num; + } SHA_CTX; + +#ifndef OPENSSL_NO_SHA0 +int SHA_Init(SHA_CTX *c); +int SHA_Update(SHA_CTX *c, const void *data, size_t len); +int SHA_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); +void SHA_Transform(SHA_CTX *c, const unsigned char *data); +#endif +#ifndef OPENSSL_NO_SHA1 +int SHA1_Init(SHA_CTX *c); +int SHA1_Update(SHA_CTX *c, const void *data, size_t len); +int SHA1_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); +void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +#endif + +#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA224_DIGEST_LENGTH 28 +#define SHA256_DIGEST_LENGTH 32 + +typedef struct SHA256state_st + { + SHA_LONG h[8]; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num,md_len; + } SHA256_CTX; + +#ifndef OPENSSL_NO_SHA256 +int SHA224_Init(SHA256_CTX *c); +int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA224_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md); +int SHA256_Init(SHA256_CTX *c); +int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA256_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md); +void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); +#endif + +#define SHA384_DIGEST_LENGTH 48 +#define SHA512_DIGEST_LENGTH 64 + +#ifndef OPENSSL_NO_SHA512 +/* + * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 + * being exactly 64-bit wide. See Implementation Notes in sha512.c + * for further details. + */ +#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a + * contiguous array of 64 bit + * wide big-endian values. */ +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +#define SHA_LONG64 unsigned __int64 +#define U64(C) C##UI64 +#elif defined(__arch64__) +#define SHA_LONG64 unsigned long +#define U64(C) C##UL +#else +#define SHA_LONG64 unsigned long long +#define U64(C) C##ULL +#endif + +typedef struct SHA512state_st + { + SHA_LONG64 h[8]; + SHA_LONG64 Nl,Nh; + union { + SHA_LONG64 d[SHA_LBLOCK]; + unsigned char p[SHA512_CBLOCK]; + } u; + unsigned int num,md_len; + } SHA512_CTX; +#endif + +#ifndef OPENSSL_NO_SHA512 +int SHA384_Init(SHA512_CTX *c); +int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA384_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); +int SHA512_Init(SHA512_CTX *c); +int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA512_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); +void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h new file mode 100755 index 0000000..36e347b --- /dev/null +++ b/include/openssl/ssl.h @@ -0,0 +1,1960 @@ +/* ssl/ssl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL_H +#define HEADER_SSL_H + +#include + +#ifndef OPENSSL_NO_COMP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_X509 +#include +#endif +#include +#include +#include +#endif +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* SSLeay version number for ASN.1 encoding of the session information */ +/* Version 0 - initial version + * Version 1 - added the optional peer certificate + */ +#define SSL_SESSION_ASN1_VERSION 0x0001 + +/* text strings for the ciphers */ +#define SSL_TXT_NULL_WITH_MD5 SSL2_TXT_NULL_WITH_MD5 +#define SSL_TXT_RC4_128_WITH_MD5 SSL2_TXT_RC4_128_WITH_MD5 +#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_WITH_MD5 SSL2_TXT_RC2_128_CBC_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 +#define SSL_TXT_IDEA_128_CBC_WITH_MD5 SSL2_TXT_IDEA_128_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_MD5 SSL2_TXT_DES_64_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_SHA SSL2_TXT_DES_64_CBC_WITH_SHA +#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 +#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA + +/* VRS Additional Kerberos5 entries + */ +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA +#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5 +#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA +#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5 +#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256 + +#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 +#define SSL_MAX_SID_CTX_LENGTH 32 + +#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) +#define SSL_MAX_KEY_ARG_LENGTH 8 +#define SSL_MAX_MASTER_KEY_LENGTH 48 + +/* These are used to specify which ciphers to use and not to use */ +#define SSL_TXT_LOW "LOW" +#define SSL_TXT_MEDIUM "MEDIUM" +#define SSL_TXT_HIGH "HIGH" +#define SSL_TXT_kFZA "kFZA" +#define SSL_TXT_aFZA "aFZA" +#define SSL_TXT_eFZA "eFZA" +#define SSL_TXT_FZA "FZA" + +#define SSL_TXT_aNULL "aNULL" +#define SSL_TXT_eNULL "eNULL" +#define SSL_TXT_NULL "NULL" + +#define SSL_TXT_kKRB5 "kKRB5" +#define SSL_TXT_aKRB5 "aKRB5" +#define SSL_TXT_KRB5 "KRB5" + +#define SSL_TXT_kRSA "kRSA" +#define SSL_TXT_kDHr "kDHr" +#define SSL_TXT_kDHd "kDHd" +#define SSL_TXT_kEDH "kEDH" +#define SSL_TXT_aRSA "aRSA" +#define SSL_TXT_aDSS "aDSS" +#define SSL_TXT_aDH "aDH" +#define SSL_TXT_DSS "DSS" +#define SSL_TXT_DH "DH" +#define SSL_TXT_EDH "EDH" +#define SSL_TXT_ADH "ADH" +#define SSL_TXT_RSA "RSA" +#define SSL_TXT_DES "DES" +#define SSL_TXT_3DES "3DES" +#define SSL_TXT_RC4 "RC4" +#define SSL_TXT_RC2 "RC2" +#define SSL_TXT_IDEA "IDEA" +#define SSL_TXT_AES "AES" +#define SSL_TXT_CAMELLIA "CAMELLIA" +#define SSL_TXT_MD5 "MD5" +#define SSL_TXT_SHA1 "SHA1" +#define SSL_TXT_SHA "SHA" +#define SSL_TXT_EXP "EXP" +#define SSL_TXT_EXPORT "EXPORT" +#define SSL_TXT_EXP40 "EXPORT40" +#define SSL_TXT_EXP56 "EXPORT56" +#define SSL_TXT_SSLV2 "SSLv2" +#define SSL_TXT_SSLV3 "SSLv3" +#define SSL_TXT_TLSV1 "TLSv1" +#define SSL_TXT_ALL "ALL" +#define SSL_TXT_ECC "ECCdraft" /* ECC ciphersuites are not yet official */ + +/* + * COMPLEMENTOF* definitions. These identifiers are used to (de-select) + * ciphers normally not being used. + * Example: "RC4" will activate all ciphers using RC4 including ciphers + * without authentication, which would normally disabled by DEFAULT (due + * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" + * will make sure that it is also disabled in the specific selection. + * COMPLEMENTOF* identifiers are portable between version, as adjustments + * to the default cipher setup will also be included here. + * + * COMPLEMENTOFDEFAULT does not experience the same special treatment that + * DEFAULT gets, as only selection is being done and no sorting as needed + * for DEFAULT. + */ +#define SSL_TXT_CMPALL "COMPLEMENTOFALL" +#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" + +/* The following cipher list is used by default. + * It also is substituted when an application-defined cipher list string + * starts with 'DEFAULT'. */ +#ifdef OPENSSL_NO_CAMELLIA +# define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ +#else +# define SSL_DEFAULT_CIPHER_LIST "AES:CAMELLIA:ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ +#endif + +/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ +#define SSL_SENT_SHUTDOWN 1 +#define SSL_RECEIVED_SHUTDOWN 2 + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) +#define OPENSSL_NO_SSL2 +#endif + +#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 +#define SSL_FILETYPE_PEM X509_FILETYPE_PEM + +/* This is needed to stop compilers complaining about the + * 'struct ssl_st *' function parameters used to prototype callbacks + * in SSL_CTX. */ +typedef struct ssl_st *ssl_crock_st; + +/* used to hold info on the particular ciphers used */ +typedef struct ssl_cipher_st + { + int valid; + const char *name; /* text name */ + unsigned long id; /* id, 4 bytes, first is version */ + unsigned long algorithms; /* what ciphers are used */ + unsigned long algo_strength; /* strength and export flags */ + unsigned long algorithm2; /* Extra flags */ + int strength_bits; /* Number of bits really used */ + int alg_bits; /* Number of bits for algorithm */ + unsigned long mask; /* used for matching */ + unsigned long mask_strength; /* also used for matching */ + } SSL_CIPHER; + +DECLARE_STACK_OF(SSL_CIPHER) + +typedef struct ssl_st SSL; +typedef struct ssl_ctx_st SSL_CTX; + +/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ +typedef struct ssl_method_st + { + int version; + int (*ssl_new)(SSL *s); + void (*ssl_clear)(SSL *s); + void (*ssl_free)(SSL *s); + int (*ssl_accept)(SSL *s); + int (*ssl_connect)(SSL *s); + int (*ssl_read)(SSL *s,void *buf,int len); + int (*ssl_peek)(SSL *s,void *buf,int len); + int (*ssl_write)(SSL *s,const void *buf,int len); + int (*ssl_shutdown)(SSL *s); + int (*ssl_renegotiate)(SSL *s); + int (*ssl_renegotiate_check)(SSL *s); + long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long + max, int *ok); + int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len, + int peek); + int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); + int (*ssl_dispatch_alert)(SSL *s); + long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg); + long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg); + SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); + int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); + int (*ssl_pending)(const SSL *s); + int (*num_ciphers)(void); + SSL_CIPHER *(*get_cipher)(unsigned ncipher); + struct ssl_method_st *(*get_ssl_method)(int version); + long (*get_timeout)(void); + struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ + int (*ssl_version)(void); + long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void)); + long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void)); + } SSL_METHOD; + +/* Lets make this into an ASN.1 type structure as follows + * SSL_SESSION_ID ::= SEQUENCE { + * version INTEGER, -- structure version number + * SSLversion INTEGER, -- SSL version number + * Cipher OCTET_STRING, -- the 3 byte cipher ID + * Session_ID OCTET_STRING, -- the Session ID + * Master_key OCTET_STRING, -- the master key + * KRB5_principal OCTET_STRING -- optional Kerberos principal + * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument + * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time + * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds + * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate + * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context + * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer' + * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX + * } + * Look in ssl/ssl_asn1.c for more details + * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). + */ +typedef struct ssl_session_st + { + int ssl_version; /* what ssl version session info is + * being kept in here? */ + + /* only really used in SSLv2 */ + unsigned int key_arg_length; + unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH]; + int master_key_length; + unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH]; + /* session_id - valid? */ + unsigned int session_id_length; + unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + /* this is used to determine whether the session is being reused in + * the appropriate context. It is up to the application to set this, + * via SSL_new */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + +#ifndef OPENSSL_NO_KRB5 + unsigned int krb5_client_princ_len; + unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH]; +#endif /* OPENSSL_NO_KRB5 */ + + int not_resumable; + + /* The cert is the certificate used to establish this connection */ + struct sess_cert_st /* SESS_CERT */ *sess_cert; + + /* This is the cert for the other end. + * On clients, it will be the same as sess_cert->peer_key->x509 + * (the latter is not enough as sess_cert is not retained + * in the external representation of sessions, see ssl_asn1.c). */ + X509 *peer; + /* when app_verify_callback accepts a session where the peer's certificate + * is not ok, we must remember the error for session reuse: */ + long verify_result; /* only for servers */ + + int references; + long timeout; + long time; + + int compress_meth; /* Need to lookup the method */ + + SSL_CIPHER *cipher; + unsigned long cipher_id; /* when ASN.1 loaded, this + * needs to be used to load + * the 'cipher' structure */ + + STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */ + + CRYPTO_EX_DATA ex_data; /* application specific data */ + + /* These are used to make removal of session-ids more + * efficient and to implement a maximum cache size. */ + struct ssl_session_st *prev,*next; + } SSL_SESSION; + + +#define SSL_OP_MICROSOFT_SESS_ID_BUG 0x00000001L +#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x00000002L +#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L +#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L +#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L +#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */ +#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L +#define SSL_OP_TLS_D5_BUG 0x00000100L +#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L + +/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added + * in OpenSSL 0.9.6d. Usually (depending on the application protocol) + * the workaround is not needed. Unfortunately some broken SSL/TLS + * implementations cannot handle it at all, which is why we include + * it in SSL_OP_ALL. */ +#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L /* added in 0.9.6e */ + +/* SSL_OP_ALL: various bug workarounds that should be rather harmless. + * This used to be 0x000FFFFFL before 0.9.7. */ +#define SSL_OP_ALL 0x00000FFFL + +/* DTLS options */ +#define SSL_OP_NO_QUERY_MTU 0x00001000L +/* Turn on Cookie Exchange (on relevant for servers) */ +#define SSL_OP_COOKIE_EXCHANGE 0x00002000L + +/* As server, disallow session resumption on renegotiation */ +#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000L +/* If set, always create a new key when using tmp_ecdh parameters */ +#define SSL_OP_SINGLE_ECDH_USE 0x00080000L +/* If set, always create a new key when using tmp_dh parameters */ +#define SSL_OP_SINGLE_DH_USE 0x00100000L +/* Set to always use the tmp_rsa key when doing RSA operations, + * even when this violates protocol specs */ +#define SSL_OP_EPHEMERAL_RSA 0x00200000L +/* Set on servers to choose the cipher according to the server's + * preferences */ +#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L +/* If set, a server will allow a client to issue a SSLv3.0 version number + * as latest version supported in the premaster secret, even when TLSv1.0 + * (version 3.1) was announced in the client hello. Normally this is + * forbidden to prevent version rollback attacks. */ +#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L + +#define SSL_OP_NO_SSLv2 0x01000000L +#define SSL_OP_NO_SSLv3 0x02000000L +#define SSL_OP_NO_TLSv1 0x04000000L + +/* The next flag deliberately changes the ciphertest, this is a check + * for the PKCS#1 attack */ +#define SSL_OP_PKCS1_CHECK_1 0x08000000L +#define SSL_OP_PKCS1_CHECK_2 0x10000000L +#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L +#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L + + +/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success + * when just a single record has been written): */ +#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L +/* Make it possible to retry SSL_write() with changed buffer location + * (buffer contents must stay the same!); this is not the default to avoid + * the misconception that non-blocking SSL_write() behaves like + * non-blocking write(): */ +#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L +/* Never bother the application with retries if the transport + * is blocking: */ +#define SSL_MODE_AUTO_RETRY 0x00000004L +/* Don't attempt to automatically build certificate chain */ +#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L + + +/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, + * they cannot be used to clear bits. */ + +#define SSL_CTX_set_options(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_CTX_get_options(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL) +#define SSL_set_options(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_get_options(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL) + +#define SSL_CTX_set_mode(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) +#define SSL_CTX_get_mode(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mode(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) +#define SSL_get_mode(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mtu(ssl, mtu) \ + SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) + + +void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) +#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) + + + +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) +#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */ +#else +#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ +#endif + +#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) + +/* This callback type is used inside SSL_CTX, SSL, and in the functions that set + * them. It is used to override the generation of SSL/TLS session IDs in a + * server. Return value should be zero on an error, non-zero to proceed. Also, + * callbacks should themselves check if the id they generate is unique otherwise + * the SSL handshake will fail with an error - callbacks can do this using the + * 'ssl' value they're passed by; + * SSL_has_matching_session_id(ssl, id, *id_len) + * The length value passed in is set at the maximum size the session ID can be. + * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback + * can alter this length to be less if desired, but under SSLv2 session IDs are + * supposed to be fixed at 16 bytes so the id will be padded after the callback + * returns in this case. It is also an error for the callback to set the size to + * zero. */ +typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, + unsigned int *id_len); + +typedef struct ssl_comp_st + { + int id; + const char *name; +#ifndef OPENSSL_NO_COMP + COMP_METHOD *method; +#else + char *method; +#endif + } SSL_COMP; + +DECLARE_STACK_OF(SSL_COMP) + +struct ssl_ctx_st + { + SSL_METHOD *method; + + STACK_OF(SSL_CIPHER) *cipher_list; + /* same as above but sorted for lookup */ + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + struct x509_store_st /* X509_STORE */ *cert_store; + struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */ + /* Most session-ids that will be cached, default is + * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ + unsigned long session_cache_size; + struct ssl_session_st *session_cache_head; + struct ssl_session_st *session_cache_tail; + + /* This can have one of 2 values, ored together, + * SSL_SESS_CACHE_CLIENT, + * SSL_SESS_CACHE_SERVER, + * Default is SSL_SESSION_CACHE_SERVER, which means only + * SSL_accept which cache SSL_SESSIONS. */ + int session_cache_mode; + + /* If timeout is not 0, it is the default timeout value set + * when SSL_new() is called. This has been put in to make + * life easier to set things up */ + long session_timeout; + + /* If this callback is not null, it will be called each + * time a session id is added to the cache. If this function + * returns 1, it means that the callback will do a + * SSL_SESSION_free() when it has finished using it. Otherwise, + * on 0, it means the callback has finished with it. + * If remove_session_cb is not null, it will be called when + * a session-id is removed from the cache. After the call, + * OpenSSL will SSL_SESSION_free() it. */ + int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); + void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); + SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, + unsigned char *data,int len,int *copy); + + struct + { + int sess_connect; /* SSL new conn - started */ + int sess_connect_renegotiate;/* SSL reneg - requested */ + int sess_connect_good; /* SSL new conne/reneg - finished */ + int sess_accept; /* SSL new accept - started */ + int sess_accept_renegotiate;/* SSL reneg - requested */ + int sess_accept_good; /* SSL accept/reneg - finished */ + int sess_miss; /* session lookup misses */ + int sess_timeout; /* reuse attempt on timeouted session */ + int sess_cache_full; /* session removed due to full cache */ + int sess_hit; /* session reuse actually done */ + int sess_cb_hit; /* session-id that was not + * in the cache was + * passed back via the callback. This + * indicates that the application is + * supplying session-id's from other + * processes - spooky :-) */ + } stats; + + int references; + + /* if defined, these override the X509_verify_cert() calls */ + int (*app_verify_callback)(X509_STORE_CTX *, void *); + void *app_verify_arg; + /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored + * ('app_verify_callback' was called with just one argument) */ + + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + + /* get client cert callback */ + int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); + + /* cookie generate callback */ + int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len); + + /* verify cookie callback */ + int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int cookie_len); + + CRYPTO_EX_DATA ex_data; + + const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ + const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ + const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ + + STACK_OF(X509) *extra_certs; + STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ + + + /* Default values used when no per-SSL value is defined follow */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ + + /* what we put in client cert requests */ + STACK_OF(X509_NAME) *client_CA; + + + /* Default values to use in SSL structures follow (these are copied by SSL_new) */ + + unsigned long options; + unsigned long mode; + long max_cert_list; + + struct cert_st /* CERT */ *cert; + int read_ahead; + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int verify_mode; + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + int quiet_shutdown; + }; + +#define SSL_SESS_CACHE_OFF 0x0000 +#define SSL_SESS_CACHE_CLIENT 0x0001 +#define SSL_SESS_CACHE_SERVER 0x0002 +#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) +#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 +/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ +#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 +#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 +#define SSL_SESS_CACHE_NO_INTERNAL \ + (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) + + struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); +#define SSL_CTX_sess_number(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) +#define SSL_CTX_sess_connect(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) +#define SSL_CTX_sess_connect_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) +#define SSL_CTX_sess_connect_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) +#define SSL_CTX_sess_accept_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) +#define SSL_CTX_sess_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) +#define SSL_CTX_sess_cb_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) +#define SSL_CTX_sess_misses(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) +#define SSL_CTX_sess_timeouts(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) +#define SSL_CTX_sess_cache_full(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) + +void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess)); +int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess); +void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess)); +void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess); +void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,int len,int *copy)); +SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *Data, int len, int *copy); +void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl,int type,int val); +void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); +int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey); +void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len)); +void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len)); + +#define SSL_NOTHING 1 +#define SSL_WRITING 2 +#define SSL_READING 3 +#define SSL_X509_LOOKUP 4 + +/* These will only be used when doing non-blocking IO */ +#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) +#define SSL_want_read(s) (SSL_want(s) == SSL_READING) +#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) +#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) + +struct ssl_st + { + /* protocol version + * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) + */ + int version; + int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ + + SSL_METHOD *method; /* SSLv3 */ + + /* There are 2 BIO's even though they are normally both the + * same. This is so data can be read and written to different + * handlers */ + +#ifndef OPENSSL_NO_BIO + BIO *rbio; /* used by SSL_read */ + BIO *wbio; /* used by SSL_write */ + BIO *bbio; /* used during session-id reuse to concatenate + * messages */ +#else + char *rbio; /* used by SSL_read */ + char *wbio; /* used by SSL_write */ + char *bbio; +#endif + /* This holds a variable that indicates what we were doing + * when a 0 or -1 is returned. This is needed for + * non-blocking IO so we know what request needs re-doing when + * in SSL_accept or SSL_connect */ + int rwstate; + + /* true when we are actually in SSL_accept() or SSL_connect() */ + int in_handshake; + int (*handshake_func)(SSL *); + + /* Imagine that here's a boolean member "init" that is + * switched as soon as SSL_set_{accept/connect}_state + * is called for the first time, so that "state" and + * "handshake_func" are properly initialized. But as + * handshake_func is == 0 until then, we use this + * test instead of an "init" member. + */ + + int server; /* are we the server side? - mostly used by SSL_clear*/ + + int new_session;/* 1 if we are to use a new session. + * 2 if we are a server and are inside a handshake + * (i.e. not just sending a HelloRequest) + * NB: For servers, the 'new' session may actually be a previously + * cached session or even the previous session unless + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ + int quiet_shutdown;/* don't send shutdown packets */ + int shutdown; /* we have shut things down, 0x01 sent, 0x02 + * for received */ + int state; /* where we are */ + int rstate; /* where we are when reading */ + + BUF_MEM *init_buf; /* buffer used during init */ + void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */ + int init_num; /* amount read/written */ + int init_off; /* amount read/written */ + + /* used internally to point at a raw packet */ + unsigned char *packet; + unsigned int packet_length; + + struct ssl2_state_st *s2; /* SSLv2 variables */ + struct ssl3_state_st *s3; /* SSLv3 variables */ + struct dtls1_state_st *d1; /* DTLSv1 variables */ + + int read_ahead; /* Read as many input bytes as possible + * (for non-blocking reads) */ + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int hit; /* reusing a previous session */ + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + /* crypto */ + STACK_OF(SSL_CIPHER) *cipher_list; + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + /* These are the ones being used, the ones in SSL_SESSION are + * the ones to be 'copied' into these ones */ + + EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ + const EVP_MD *read_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *expand; /* uncompress */ +#else + char *expand; +#endif + + EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ + const EVP_MD *write_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *compress; /* compression */ +#else + char *compress; +#endif + + /* session info */ + + /* client cert? */ + /* This is used to hold the server certificate used */ + struct cert_st /* CERT */ *cert; + + /* the session_id_context is used to ensure sessions are only reused + * in the appropriate context */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + + /* This can also be in the session once a session is established */ + SSL_SESSION *session; + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + /* Used in SSL2 and SSL3 */ + int verify_mode; /* 0 don't care about verify failure. + * 1 fail if verify fails */ + int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */ + + int error; /* error bytes to be written */ + int error_code; /* actual code */ + +#ifndef OPENSSL_NO_KRB5 + KSSL_CTX *kssl_ctx; /* Kerberos 5 context */ +#endif /* OPENSSL_NO_KRB5 */ + + SSL_CTX *ctx; + /* set this flag to 1 and a sleep(1) is put into all SSL_read() + * and SSL_write() calls, good for nbio debuging :-) */ + int debug; + + /* extra application data */ + long verify_result; + CRYPTO_EX_DATA ex_data; + + /* for server side, keep the list of CA_dn we can use */ + STACK_OF(X509_NAME) *client_CA; + + int references; + unsigned long options; /* protocol behaviour */ + unsigned long mode; /* API behaviour */ + long max_cert_list; + int first_packet; + int client_version; /* what was passed, used for + * SSLv3/TLS rollback check */ + }; + +#ifdef __cplusplus +} +#endif + +#include +#include +#include /* This is mostly sslv3 with a few tweaks */ +#include /* Datagram TLS */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* compatibility */ +#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) +#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) +#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) +#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) +#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) +#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) + +/* The following are the possible values for ssl->state are are + * used to indicate where we are up to in the SSL connection establishment. + * The macros that follow are about the only things you should need to use + * and even then, only when using non-blocking IO. + * It can also be useful to work out where you were when the connection + * failed */ + +#define SSL_ST_CONNECT 0x1000 +#define SSL_ST_ACCEPT 0x2000 +#define SSL_ST_MASK 0x0FFF +#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT) +#define SSL_ST_BEFORE 0x4000 +#define SSL_ST_OK 0x03 +#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT) + +#define SSL_CB_LOOP 0x01 +#define SSL_CB_EXIT 0x02 +#define SSL_CB_READ 0x04 +#define SSL_CB_WRITE 0x08 +#define SSL_CB_ALERT 0x4000 /* used in callback */ +#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) +#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) +#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) +#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) +#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) +#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) +#define SSL_CB_HANDSHAKE_START 0x10 +#define SSL_CB_HANDSHAKE_DONE 0x20 + +/* Is the SSL_connection established? */ +#define SSL_get_state(a) SSL_state(a) +#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) +#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT) +#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE) +#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT) +#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT) + +/* The following 2 states are kept in ssl->rstate when reads fail, + * you should not need these */ +#define SSL_ST_READ_HEADER 0xF0 +#define SSL_ST_READ_BODY 0xF1 +#define SSL_ST_READ_DONE 0xF2 + +/* Obtain latest Finished message + * -- that we sent (SSL_get_finished) + * -- that we expected from peer (SSL_get_peer_finished). + * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ +size_t SSL_get_finished(const SSL *s, void *buf, size_t count); +size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); + +/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options + * are 'ored' with SSL_VERIFY_PEER if they are desired */ +#define SSL_VERIFY_NONE 0x00 +#define SSL_VERIFY_PEER 0x01 +#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 +#define SSL_VERIFY_CLIENT_ONCE 0x04 + +#define OpenSSL_add_ssl_algorithms() SSL_library_init() +#define SSLeay_add_ssl_algorithms() SSL_library_init() + +/* this is for backward compatibility */ +#if 0 /* NEW_SSLEAY */ +#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) +#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) +#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b)) +#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) +#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) +#endif +/* More backward compatibility */ +#define SSL_get_cipher(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_cipher_bits(s,np) \ + SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) +#define SSL_get_cipher_version(s) \ + SSL_CIPHER_get_version(SSL_get_current_cipher(s)) +#define SSL_get_cipher_name(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_time(a) SSL_SESSION_get_time(a) +#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) +#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) +#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) + +#if 1 /*SSLEAY_MACROS*/ +#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) +#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u) +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_SSL_SESSION(bp,x) \ + PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL) +#endif + +#define SSL_AD_REASON_OFFSET 1000 +/* These alert types are for SSLv3 and TLSv1 */ +#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY +#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ +#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */ +#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED +#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW +#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */ +#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */ +#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */ +#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE +#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE +#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED +#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED +#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN +#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */ +#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */ +#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ +#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ +#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR +#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */ +#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ +#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ +#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ +#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED +#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION + +#define SSL_ERROR_NONE 0 +#define SSL_ERROR_SSL 1 +#define SSL_ERROR_WANT_READ 2 +#define SSL_ERROR_WANT_WRITE 3 +#define SSL_ERROR_WANT_X509_LOOKUP 4 +#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ +#define SSL_ERROR_ZERO_RETURN 6 +#define SSL_ERROR_WANT_CONNECT 7 +#define SSL_ERROR_WANT_ACCEPT 8 + +#define SSL_CTRL_NEED_TMP_RSA 1 +#define SSL_CTRL_SET_TMP_RSA 2 +#define SSL_CTRL_SET_TMP_DH 3 +#define SSL_CTRL_SET_TMP_ECDH 4 +#define SSL_CTRL_SET_TMP_RSA_CB 5 +#define SSL_CTRL_SET_TMP_DH_CB 6 +#define SSL_CTRL_SET_TMP_ECDH_CB 7 + +#define SSL_CTRL_GET_SESSION_REUSED 8 +#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 +#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 +#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 +#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 +#define SSL_CTRL_GET_FLAGS 13 +#define SSL_CTRL_EXTRA_CHAIN_CERT 14 + +#define SSL_CTRL_SET_MSG_CALLBACK 15 +#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 + +/* only applies to datagram connections */ +#define SSL_CTRL_SET_MTU 17 +/* Stats */ +#define SSL_CTRL_SESS_NUMBER 20 +#define SSL_CTRL_SESS_CONNECT 21 +#define SSL_CTRL_SESS_CONNECT_GOOD 22 +#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 +#define SSL_CTRL_SESS_ACCEPT 24 +#define SSL_CTRL_SESS_ACCEPT_GOOD 25 +#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 +#define SSL_CTRL_SESS_HIT 27 +#define SSL_CTRL_SESS_CB_HIT 28 +#define SSL_CTRL_SESS_MISSES 29 +#define SSL_CTRL_SESS_TIMEOUTS 30 +#define SSL_CTRL_SESS_CACHE_FULL 31 +#define SSL_CTRL_OPTIONS 32 +#define SSL_CTRL_MODE 33 + +#define SSL_CTRL_GET_READ_AHEAD 40 +#define SSL_CTRL_SET_READ_AHEAD 41 +#define SSL_CTRL_SET_SESS_CACHE_SIZE 42 +#define SSL_CTRL_GET_SESS_CACHE_SIZE 43 +#define SSL_CTRL_SET_SESS_CACHE_MODE 44 +#define SSL_CTRL_GET_SESS_CACHE_MODE 45 + +#define SSL_CTRL_GET_MAX_CERT_LIST 50 +#define SSL_CTRL_SET_MAX_CERT_LIST 51 + +#define SSL_session_reused(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) +#define SSL_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_clear_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_total_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) + +#define SSL_CTX_need_tmp_RSA(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_CTX_set_tmp_rsa(ctx,rsa) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_CTX_set_tmp_dh(ctx,dh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_need_tmp_RSA(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_set_tmp_rsa(ssl,rsa) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_set_tmp_dh(ssl,dh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_set_tmp_ecdh(ssl,ecdh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_ssl(void); +BIO *BIO_new_ssl(SSL_CTX *ctx,int client); +BIO *BIO_new_ssl_connect(SSL_CTX *ctx); +BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); +int BIO_ssl_copy_session_id(BIO *to,BIO *from); +void BIO_ssl_shutdown(BIO *ssl_bio); + +#endif + +int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str); +SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); +void SSL_CTX_free(SSL_CTX *); +long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); +long SSL_CTX_get_timeout(const SSL_CTX *ctx); +X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); +void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); +int SSL_want(const SSL *s); +int SSL_clear(SSL *s); + +void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); + +SSL_CIPHER *SSL_get_current_cipher(const SSL *s); +int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits); +char * SSL_CIPHER_get_version(const SSL_CIPHER *c); +const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); + +int SSL_get_fd(const SSL *s); +int SSL_get_rfd(const SSL *s); +int SSL_get_wfd(const SSL *s); +const char * SSL_get_cipher_list(const SSL *s,int n); +char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len); +int SSL_get_read_ahead(const SSL * s); +int SSL_pending(const SSL *s); +#ifndef OPENSSL_NO_SOCK +int SSL_set_fd(SSL *s, int fd); +int SSL_set_rfd(SSL *s, int fd); +int SSL_set_wfd(SSL *s, int fd); +#endif +#ifndef OPENSSL_NO_BIO +void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); +BIO * SSL_get_rbio(const SSL *s); +BIO * SSL_get_wbio(const SSL *s); +#endif +int SSL_set_cipher_list(SSL *s, const char *str); +void SSL_set_read_ahead(SSL *s, int yes); +int SSL_get_verify_mode(const SSL *s); +int SSL_get_verify_depth(const SSL *s); +int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *); +void SSL_set_verify(SSL *s, int mode, + int (*callback)(int ok,X509_STORE_CTX *ctx)); +void SSL_set_verify_depth(SSL *s, int depth); +#ifndef OPENSSL_NO_RSA +int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); +#endif +int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); +int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); +int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len); +int SSL_use_certificate(SSL *ssl, X509 *x); +int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); + +#ifndef OPENSSL_NO_STDIO +int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_certificate_file(SSL *ssl, const char *file, int type); +int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */ +STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); +int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *file); +#ifndef OPENSSL_SYS_VMS +#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *dir); +#endif +#endif + +#endif + +void SSL_load_error_strings(void ); +const char *SSL_state_string(const SSL *s); +const char *SSL_rstate_string(const SSL *s); +const char *SSL_state_string_long(const SSL *s); +const char *SSL_rstate_string_long(const SSL *s); +long SSL_SESSION_get_time(const SSL_SESSION *s); +long SSL_SESSION_set_time(SSL_SESSION *s, long t); +long SSL_SESSION_get_timeout(const SSL_SESSION *s); +long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); +void SSL_copy_session_id(SSL *to,const SSL *from); + +SSL_SESSION *SSL_SESSION_new(void); +unsigned long SSL_SESSION_hash(const SSL_SESSION *a); +int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b); +const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); +#ifndef OPENSSL_NO_FP_API +int SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses); +#endif +#ifndef OPENSSL_NO_BIO +int SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses); +#endif +void SSL_SESSION_free(SSL_SESSION *ses); +int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); +int SSL_set_session(SSL *to, SSL_SESSION *session); +int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); +int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); +int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); +int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); +int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, + unsigned int id_len); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,const unsigned char **pp, + long length); + +#ifdef HEADER_X509_H +X509 * SSL_get_peer_certificate(const SSL *s); +#endif + +STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); + +int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); +int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); +int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *); +void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, + int (*callback)(int, X509_STORE_CTX *)); +void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); +void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg); +#ifndef OPENSSL_NO_RSA +int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); +#endif +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); +int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); +int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, + const unsigned char *d, long len); +int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); +int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d); + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); + +int SSL_CTX_check_private_key(const SSL_CTX *ctx); +int SSL_check_private_key(const SSL *ctx); + +int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +SSL * SSL_new(SSL_CTX *ctx); +int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); +int SSL_set_purpose(SSL *s, int purpose); +int SSL_CTX_set_trust(SSL_CTX *s, int trust); +int SSL_set_trust(SSL *s, int trust); + +void SSL_free(SSL *ssl); +int SSL_accept(SSL *ssl); +int SSL_connect(SSL *ssl); +int SSL_read(SSL *ssl,void *buf,int num); +int SSL_peek(SSL *ssl,void *buf,int num); +int SSL_write(SSL *ssl,const void *buf,int num); +long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg); +long SSL_callback_ctrl(SSL *, int, void (*)(void)); +long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg); +long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); + +int SSL_get_error(const SSL *s,int ret_code); +const char *SSL_get_version(const SSL *s); + +/* This sets the 'default' SSL version that SSL_new() will create */ +int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); + +SSL_METHOD *SSLv2_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */ + +SSL_METHOD *SSLv3_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */ + +SSL_METHOD *SSLv23_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_server_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_client_method(void); /* SSLv3 but can rollback to v2 */ + +SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ + +SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */ + +STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); + +int SSL_do_handshake(SSL *s); +int SSL_renegotiate(SSL *s); +int SSL_renegotiate_pending(SSL *s); +int SSL_shutdown(SSL *s); + +SSL_METHOD *SSL_get_ssl_method(SSL *s); +int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); +const char *SSL_alert_type_string_long(int value); +const char *SSL_alert_type_string(int value); +const char *SSL_alert_desc_string_long(int value); +const char *SSL_alert_desc_string(int value); + +void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); +void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); +STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); +STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); +int SSL_add_client_CA(SSL *ssl,X509 *x); +int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); + +void SSL_set_connect_state(SSL *s); +void SSL_set_accept_state(SSL *s); + +long SSL_get_default_timeout(const SSL *s); + +int SSL_library_init(void ); + +char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); +STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); + +SSL *SSL_dup(SSL *ssl); + +X509 *SSL_get_certificate(const SSL *ssl); +/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl); + +void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode); +int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); +void SSL_set_quiet_shutdown(SSL *ssl,int mode); +int SSL_get_quiet_shutdown(const SSL *ssl); +void SSL_set_shutdown(SSL *ssl,int mode); +int SSL_get_shutdown(const SSL *ssl); +int SSL_version(const SSL *ssl); +int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); +int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, + const char *CApath); +#define SSL_get0_session SSL_get_session /* just peek at pointer */ +SSL_SESSION *SSL_get_session(const SSL *ssl); +SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ +SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); +void SSL_set_info_callback(SSL *ssl, + void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val); +int SSL_state(const SSL *ssl); + +void SSL_set_verify_result(SSL *ssl,long v); +long SSL_get_verify_result(const SSL *ssl); + +int SSL_set_ex_data(SSL *ssl,int idx,void *data); +void *SSL_get_ex_data(const SSL *ssl,int idx); +int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); +void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss,int idx); +int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); +void *SSL_CTX_get_ex_data(const SSL_CTX *ssl,int idx); +int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_get_ex_data_X509_STORE_CTX_idx(void ); + +#define SSL_CTX_sess_set_cache_size(ctx,t) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) +#define SSL_CTX_sess_get_cache_size(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) +#define SSL_CTX_set_session_cache_mode(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) +#define SSL_CTX_get_session_cache_mode(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) + +#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) +#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) +#define SSL_CTX_get_read_ahead(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) +#define SSL_CTX_set_read_ahead(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) +#define SSL_CTX_get_max_cert_list(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_CTX_set_max_cert_list(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) +#define SSL_get_max_cert_list(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_set_max_cert_list(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) + + /* NB: the keylength is only applicable when is_export is true */ +#ifndef OPENSSL_NO_RSA +void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); + +void SSL_set_tmp_rsa_callback(SSL *ssl, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_DH +void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_dh_callback(SSL *ssl, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_ECDH +void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_ecdh_callback(SSL *ssl, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +#endif + +#ifndef OPENSSL_NO_COMP +const COMP_METHOD *SSL_get_current_compression(SSL *s); +const COMP_METHOD *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const COMP_METHOD *comp); +STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); +#else +const void *SSL_get_current_compression(SSL *s); +const void *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const void *comp); +void *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,void *cm); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_SSL_strings(void); + +/* Error codes for the SSL functions. */ + +/* Function codes. */ +#define SSL_F_CLIENT_CERTIFICATE 100 +#define SSL_F_CLIENT_FINISHED 167 +#define SSL_F_CLIENT_HELLO 101 +#define SSL_F_CLIENT_MASTER_KEY 102 +#define SSL_F_D2I_SSL_SESSION 103 +#define SSL_F_DO_DTLS1_WRITE 245 +#define SSL_F_DO_SSL3_WRITE 104 +#define SSL_F_DTLS1_ACCEPT 246 +#define SSL_F_DTLS1_BUFFER_RECORD 247 +#define SSL_F_DTLS1_CLIENT_HELLO 248 +#define SSL_F_DTLS1_CONNECT 249 +#define SSL_F_DTLS1_ENC 250 +#define SSL_F_DTLS1_GET_HELLO_VERIFY 251 +#define SSL_F_DTLS1_GET_MESSAGE 252 +#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT 253 +#define SSL_F_DTLS1_GET_RECORD 254 +#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN 255 +#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE 256 +#define SSL_F_DTLS1_PROCESS_RECORD 257 +#define SSL_F_DTLS1_READ_BYTES 258 +#define SSL_F_DTLS1_READ_FAILED 259 +#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST 260 +#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE 261 +#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE 262 +#define SSL_F_DTLS1_SEND_CLIENT_VERIFY 263 +#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST 264 +#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE 265 +#define SSL_F_DTLS1_SEND_SERVER_HELLO 266 +#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267 +#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 +#define SSL_F_GET_CLIENT_FINISHED 105 +#define SSL_F_GET_CLIENT_HELLO 106 +#define SSL_F_GET_CLIENT_MASTER_KEY 107 +#define SSL_F_GET_SERVER_FINISHED 108 +#define SSL_F_GET_SERVER_HELLO 109 +#define SSL_F_GET_SERVER_VERIFY 110 +#define SSL_F_I2D_SSL_SESSION 111 +#define SSL_F_READ_N 112 +#define SSL_F_REQUEST_CERTIFICATE 113 +#define SSL_F_SERVER_FINISH 239 +#define SSL_F_SERVER_HELLO 114 +#define SSL_F_SERVER_VERIFY 240 +#define SSL_F_SSL23_ACCEPT 115 +#define SSL_F_SSL23_CLIENT_HELLO 116 +#define SSL_F_SSL23_CONNECT 117 +#define SSL_F_SSL23_GET_CLIENT_HELLO 118 +#define SSL_F_SSL23_GET_SERVER_HELLO 119 +#define SSL_F_SSL23_PEEK 237 +#define SSL_F_SSL23_READ 120 +#define SSL_F_SSL23_WRITE 121 +#define SSL_F_SSL2_ACCEPT 122 +#define SSL_F_SSL2_CONNECT 123 +#define SSL_F_SSL2_ENC_INIT 124 +#define SSL_F_SSL2_GENERATE_KEY_MATERIAL 241 +#define SSL_F_SSL2_PEEK 234 +#define SSL_F_SSL2_READ 125 +#define SSL_F_SSL2_READ_INTERNAL 236 +#define SSL_F_SSL2_SET_CERTIFICATE 126 +#define SSL_F_SSL2_WRITE 127 +#define SSL_F_SSL3_ACCEPT 128 +#define SSL_F_SSL3_CALLBACK_CTRL 233 +#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 +#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CLIENT_HELLO 131 +#define SSL_F_SSL3_CONNECT 132 +#define SSL_F_SSL3_CTRL 213 +#define SSL_F_SSL3_CTX_CTRL 133 +#define SSL_F_SSL3_ENC 134 +#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 +#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 +#define SSL_F_SSL3_GET_CERT_VERIFY 136 +#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 +#define SSL_F_SSL3_GET_CLIENT_HELLO 138 +#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139 +#define SSL_F_SSL3_GET_FINISHED 140 +#define SSL_F_SSL3_GET_KEY_EXCHANGE 141 +#define SSL_F_SSL3_GET_MESSAGE 142 +#define SSL_F_SSL3_GET_RECORD 143 +#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144 +#define SSL_F_SSL3_GET_SERVER_DONE 145 +#define SSL_F_SSL3_GET_SERVER_HELLO 146 +#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 +#define SSL_F_SSL3_PEEK 235 +#define SSL_F_SSL3_READ_BYTES 148 +#define SSL_F_SSL3_READ_N 149 +#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 +#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151 +#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152 +#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153 +#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154 +#define SSL_F_SSL3_SEND_SERVER_HELLO 242 +#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155 +#define SSL_F_SSL3_SETUP_BUFFERS 156 +#define SSL_F_SSL3_SETUP_KEY_BLOCK 157 +#define SSL_F_SSL3_WRITE_BYTES 158 +#define SSL_F_SSL3_WRITE_PENDING 159 +#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 +#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 +#define SSL_F_SSL_BAD_METHOD 160 +#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 +#define SSL_F_SSL_CERT_DUP 221 +#define SSL_F_SSL_CERT_INST 222 +#define SSL_F_SSL_CERT_INSTANTIATE 214 +#define SSL_F_SSL_CERT_NEW 162 +#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 +#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 +#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 +#define SSL_F_SSL_CLEAR 164 +#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 +#define SSL_F_SSL_CREATE_CIPHER_LIST 166 +#define SSL_F_SSL_CTRL 232 +#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 +#define SSL_F_SSL_CTX_NEW 169 +#define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 +#define SSL_F_SSL_CTX_SET_PURPOSE 226 +#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 +#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 +#define SSL_F_SSL_CTX_SET_TRUST 229 +#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 +#define SSL_F_SSL_DO_HANDSHAKE 180 +#define SSL_F_SSL_GET_NEW_SESSION 181 +#define SSL_F_SSL_GET_PREV_SESSION 217 +#define SSL_F_SSL_GET_SERVER_SEND_CERT 182 +#define SSL_F_SSL_GET_SIGN_PKEY 183 +#define SSL_F_SSL_INIT_WBIO_BUFFER 184 +#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 +#define SSL_F_SSL_NEW 186 +#define SSL_F_SSL_PEEK 270 +#define SSL_F_SSL_READ 223 +#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187 +#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188 +#define SSL_F_SSL_SESSION_NEW 189 +#define SSL_F_SSL_SESSION_PRINT_FP 190 +#define SSL_F_SSL_SESS_CERT_NEW 225 +#define SSL_F_SSL_SET_CERT 191 +#define SSL_F_SSL_SET_CIPHER_LIST 271 +#define SSL_F_SSL_SET_FD 192 +#define SSL_F_SSL_SET_PKEY 193 +#define SSL_F_SSL_SET_PURPOSE 227 +#define SSL_F_SSL_SET_RFD 194 +#define SSL_F_SSL_SET_SESSION 195 +#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 +#define SSL_F_SSL_SET_TRUST 228 +#define SSL_F_SSL_SET_WFD 196 +#define SSL_F_SSL_SHUTDOWN 224 +#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION 243 +#define SSL_F_SSL_UNDEFINED_FUNCTION 197 +#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 +#define SSL_F_SSL_USE_CERTIFICATE 198 +#define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 +#define SSL_F_SSL_USE_CERTIFICATE_FILE 200 +#define SSL_F_SSL_USE_PRIVATEKEY 201 +#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 +#define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 +#define SSL_F_SSL_USE_RSAPRIVATEKEY 204 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 +#define SSL_F_SSL_VERIFY_CERT_CHAIN 207 +#define SSL_F_SSL_WRITE 208 +#define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 +#define SSL_F_TLS1_ENC 210 +#define SSL_F_TLS1_SETUP_KEY_BLOCK 211 +#define SSL_F_WRITE_PENDING 212 + +/* Reason codes. */ +#define SSL_R_APP_DATA_IN_HANDSHAKE 100 +#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 +#define SSL_R_BAD_ALERT_RECORD 101 +#define SSL_R_BAD_AUTHENTICATION_TYPE 102 +#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 +#define SSL_R_BAD_CHECKSUM 104 +#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 +#define SSL_R_BAD_DECOMPRESSION 107 +#define SSL_R_BAD_DH_G_LENGTH 108 +#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 +#define SSL_R_BAD_DH_P_LENGTH 110 +#define SSL_R_BAD_DIGEST_LENGTH 111 +#define SSL_R_BAD_DSA_SIGNATURE 112 +#define SSL_R_BAD_ECC_CERT 304 +#define SSL_R_BAD_ECDSA_SIGNATURE 305 +#define SSL_R_BAD_ECPOINT 306 +#define SSL_R_BAD_HELLO_REQUEST 105 +#define SSL_R_BAD_LENGTH 271 +#define SSL_R_BAD_MAC_DECODE 113 +#define SSL_R_BAD_MESSAGE_TYPE 114 +#define SSL_R_BAD_PACKET_LENGTH 115 +#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 +#define SSL_R_BAD_RESPONSE_ARGUMENT 117 +#define SSL_R_BAD_RSA_DECRYPT 118 +#define SSL_R_BAD_RSA_ENCRYPT 119 +#define SSL_R_BAD_RSA_E_LENGTH 120 +#define SSL_R_BAD_RSA_MODULUS_LENGTH 121 +#define SSL_R_BAD_RSA_SIGNATURE 122 +#define SSL_R_BAD_SIGNATURE 123 +#define SSL_R_BAD_SSL_FILETYPE 124 +#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125 +#define SSL_R_BAD_STATE 126 +#define SSL_R_BAD_WRITE_RETRY 127 +#define SSL_R_BIO_NOT_SET 128 +#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 +#define SSL_R_BN_LIB 130 +#define SSL_R_CA_DN_LENGTH_MISMATCH 131 +#define SSL_R_CA_DN_TOO_LONG 132 +#define SSL_R_CCS_RECEIVED_EARLY 133 +#define SSL_R_CERTIFICATE_VERIFY_FAILED 134 +#define SSL_R_CERT_LENGTH_MISMATCH 135 +#define SSL_R_CHALLENGE_IS_DIFFERENT 136 +#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 +#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 +#define SSL_R_CIPHER_TABLE_SRC_ERROR 139 +#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 +#define SSL_R_COMPRESSION_FAILURE 141 +#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 +#define SSL_R_COMPRESSION_LIBRARY_ERROR 142 +#define SSL_R_CONNECTION_ID_IS_DIFFERENT 143 +#define SSL_R_CONNECTION_TYPE_NOT_SET 144 +#define SSL_R_COOKIE_MISMATCH 308 +#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 +#define SSL_R_DATA_LENGTH_TOO_LONG 146 +#define SSL_R_DECRYPTION_FAILED 147 +#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 +#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 +#define SSL_R_DIGEST_CHECK_FAILED 149 +#define SSL_R_DUPLICATE_COMPRESSION_ID 309 +#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER 310 +#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 +#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 282 +#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 +#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 +#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 +#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 +#define SSL_R_HTTPS_PROXY_REQUEST 155 +#define SSL_R_HTTP_REQUEST 156 +#define SSL_R_ILLEGAL_PADDING 283 +#define SSL_R_INVALID_CHALLENGE_LENGTH 158 +#define SSL_R_INVALID_COMMAND 280 +#define SSL_R_INVALID_PURPOSE 278 +#define SSL_R_INVALID_TRUST 279 +#define SSL_R_KEY_ARG_TOO_LONG 284 +#define SSL_R_KRB5 285 +#define SSL_R_KRB5_C_CC_PRINC 286 +#define SSL_R_KRB5_C_GET_CRED 287 +#define SSL_R_KRB5_C_INIT 288 +#define SSL_R_KRB5_C_MK_REQ 289 +#define SSL_R_KRB5_S_BAD_TICKET 290 +#define SSL_R_KRB5_S_INIT 291 +#define SSL_R_KRB5_S_RD_REQ 292 +#define SSL_R_KRB5_S_TKT_EXPIRED 293 +#define SSL_R_KRB5_S_TKT_NYV 294 +#define SSL_R_KRB5_S_TKT_SKEW 295 +#define SSL_R_LENGTH_MISMATCH 159 +#define SSL_R_LENGTH_TOO_SHORT 160 +#define SSL_R_LIBRARY_BUG 274 +#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 +#define SSL_R_MESSAGE_TOO_LONG 296 +#define SSL_R_MISSING_DH_DSA_CERT 162 +#define SSL_R_MISSING_DH_KEY 163 +#define SSL_R_MISSING_DH_RSA_CERT 164 +#define SSL_R_MISSING_DSA_SIGNING_CERT 165 +#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166 +#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167 +#define SSL_R_MISSING_RSA_CERTIFICATE 168 +#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 +#define SSL_R_MISSING_RSA_SIGNING_CERT 170 +#define SSL_R_MISSING_TMP_DH_KEY 171 +#define SSL_R_MISSING_TMP_ECDH_KEY 311 +#define SSL_R_MISSING_TMP_RSA_KEY 172 +#define SSL_R_MISSING_TMP_RSA_PKEY 173 +#define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_NON_SSLV2_INITIAL_PACKET 175 +#define SSL_R_NO_CERTIFICATES_RETURNED 176 +#define SSL_R_NO_CERTIFICATE_ASSIGNED 177 +#define SSL_R_NO_CERTIFICATE_RETURNED 178 +#define SSL_R_NO_CERTIFICATE_SET 179 +#define SSL_R_NO_CERTIFICATE_SPECIFIED 180 +#define SSL_R_NO_CIPHERS_AVAILABLE 181 +#define SSL_R_NO_CIPHERS_PASSED 182 +#define SSL_R_NO_CIPHERS_SPECIFIED 183 +#define SSL_R_NO_CIPHER_LIST 184 +#define SSL_R_NO_CIPHER_MATCH 185 +#define SSL_R_NO_CLIENT_CERT_RECEIVED 186 +#define SSL_R_NO_COMPRESSION_SPECIFIED 187 +#define SSL_R_NO_METHOD_SPECIFIED 188 +#define SSL_R_NO_PRIVATEKEY 189 +#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 +#define SSL_R_NO_PROTOCOLS_AVAILABLE 191 +#define SSL_R_NO_PUBLICKEY 192 +#define SSL_R_NO_SHARED_CIPHER 193 +#define SSL_R_NO_VERIFY_CALLBACK 194 +#define SSL_R_NULL_SSL_CTX 195 +#define SSL_R_NULL_SSL_METHOD_PASSED 196 +#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 +#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE 297 +#define SSL_R_PACKET_LENGTH_TOO_LONG 198 +#define SSL_R_PATH_TOO_LONG 270 +#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 +#define SSL_R_PEER_ERROR 200 +#define SSL_R_PEER_ERROR_CERTIFICATE 201 +#define SSL_R_PEER_ERROR_NO_CERTIFICATE 202 +#define SSL_R_PEER_ERROR_NO_CIPHER 203 +#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204 +#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205 +#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206 +#define SSL_R_PROTOCOL_IS_SHUTDOWN 207 +#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208 +#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209 +#define SSL_R_PUBLIC_KEY_NOT_RSA 210 +#define SSL_R_READ_BIO_NOT_SET 211 +#define SSL_R_READ_TIMEOUT_EXPIRED 312 +#define SSL_R_READ_WRONG_PACKET_TYPE 212 +#define SSL_R_RECORD_LENGTH_MISMATCH 213 +#define SSL_R_RECORD_TOO_LARGE 214 +#define SSL_R_RECORD_TOO_SMALL 298 +#define SSL_R_REQUIRED_CIPHER_MISSING 215 +#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216 +#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217 +#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218 +#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 +#define SSL_R_SHORT_READ 219 +#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 +#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221 +#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG 299 +#define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 +#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222 +#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 +#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 +#define SSL_R_SSL_HANDSHAKE_FAILURE 229 +#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 +#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 +#define SSL_R_SSL_SESSION_ID_CONFLICT 302 +#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 +#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 +#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 +#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 +#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 +#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 +#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 +#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 +#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 +#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 +#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 +#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 +#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 +#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 +#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 +#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 +#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 +#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 +#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235 +#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236 +#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS 313 +#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237 +#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238 +#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 +#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 +#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240 +#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241 +#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 +#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 +#define SSL_R_UNEXPECTED_MESSAGE 244 +#define SSL_R_UNEXPECTED_RECORD 245 +#define SSL_R_UNINITIALIZED 276 +#define SSL_R_UNKNOWN_ALERT_TYPE 246 +#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 +#define SSL_R_UNKNOWN_CIPHER_RETURNED 248 +#define SSL_R_UNKNOWN_CIPHER_TYPE 249 +#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 +#define SSL_R_UNKNOWN_PKEY_TYPE 251 +#define SSL_R_UNKNOWN_PROTOCOL 252 +#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253 +#define SSL_R_UNKNOWN_SSL_VERSION 254 +#define SSL_R_UNKNOWN_STATE 255 +#define SSL_R_UNSUPPORTED_CIPHER 256 +#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 +#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 +#define SSL_R_UNSUPPORTED_PROTOCOL 258 +#define SSL_R_UNSUPPORTED_SSL_VERSION 259 +#define SSL_R_WRITE_BIO_NOT_SET 260 +#define SSL_R_WRONG_CIPHER_RETURNED 261 +#define SSL_R_WRONG_MESSAGE_TYPE 262 +#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263 +#define SSL_R_WRONG_SIGNATURE_LENGTH 264 +#define SSL_R_WRONG_SIGNATURE_SIZE 265 +#define SSL_R_WRONG_SSL_VERSION 266 +#define SSL_R_WRONG_VERSION_NUMBER 267 +#define SSL_R_X509_LIB 268 +#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/ssl2.h b/include/openssl/ssl2.h new file mode 100755 index 0000000..c871efe --- /dev/null +++ b/include/openssl/ssl2.h @@ -0,0 +1,268 @@ +/* ssl/ssl2.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL2_H +#define HEADER_SSL2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Protocol Version Codes */ +#define SSL2_VERSION 0x0002 +#define SSL2_VERSION_MAJOR 0x00 +#define SSL2_VERSION_MINOR 0x02 +/* #define SSL2_CLIENT_VERSION 0x0002 */ +/* #define SSL2_SERVER_VERSION 0x0002 */ + +/* Protocol Message Codes */ +#define SSL2_MT_ERROR 0 +#define SSL2_MT_CLIENT_HELLO 1 +#define SSL2_MT_CLIENT_MASTER_KEY 2 +#define SSL2_MT_CLIENT_FINISHED 3 +#define SSL2_MT_SERVER_HELLO 4 +#define SSL2_MT_SERVER_VERIFY 5 +#define SSL2_MT_SERVER_FINISHED 6 +#define SSL2_MT_REQUEST_CERTIFICATE 7 +#define SSL2_MT_CLIENT_CERTIFICATE 8 + +/* Error Message Codes */ +#define SSL2_PE_UNDEFINED_ERROR 0x0000 +#define SSL2_PE_NO_CIPHER 0x0001 +#define SSL2_PE_NO_CERTIFICATE 0x0002 +#define SSL2_PE_BAD_CERTIFICATE 0x0004 +#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 + +/* Cipher Kind Values */ +#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */ +#define SSL2_CK_RC4_128_WITH_MD5 0x02010080 +#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080 +#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080 +#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080 +#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080 +#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040 +#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */ +#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0 +#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */ +#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */ + +#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */ +#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */ + +#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1" +#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5" +#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5" +#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5" +#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5" +#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5" +#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA" +#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5" + +#define SSL2_TXT_NULL "NULL" + +/* Flags for the SSL_CIPHER.algorithm2 field */ +#define SSL2_CF_5_BYTE_ENC 0x01 +#define SSL2_CF_8_BYTE_ENC 0x02 + +/* Certificate Type Codes */ +#define SSL2_CT_X509_CERTIFICATE 0x01 + +/* Authentication Type Code */ +#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01 + +#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32 + +/* Upper/Lower Bounds */ +#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 +#ifdef OPENSSL_SYS_MPE +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u +#else +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ +#endif +#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ + +#define SSL2_CHALLENGE_LENGTH 16 +/*#define SSL2_CHALLENGE_LENGTH 32 */ +#define SSL2_MIN_CHALLENGE_LENGTH 16 +#define SSL2_MAX_CHALLENGE_LENGTH 32 +#define SSL2_CONNECTION_ID_LENGTH 16 +#define SSL2_MAX_CONNECTION_ID_LENGTH 16 +#define SSL2_SSL_SESSION_ID_LENGTH 16 +#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32 +#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16 +#define SSL2_MAX_KEY_MATERIAL_LENGTH 24 + +#ifndef HEADER_SSL_LOCL_H +#define CERT char +#endif + +typedef struct ssl2_state_st + { + int three_byte_header; + int clear_text; /* clear text */ + int escape; /* not used in SSLv2 */ + int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */ + + /* non-blocking io info, used to make sure the same + * args were passwd */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; + const unsigned char *wpend_buf; + + int wpend_off; /* offset to data to write */ + int wpend_len; /* number of bytes passwd to write */ + int wpend_ret; /* number of bytes to return to caller */ + + /* buffer raw data */ + int rbuf_left; + int rbuf_offs; + unsigned char *rbuf; + unsigned char *wbuf; + + unsigned char *write_ptr;/* used to point to the start due to + * 2/3 byte header. */ + + unsigned int padding; + unsigned int rlength; /* passed to ssl2_enc */ + int ract_data_length; /* Set when things are encrypted. */ + unsigned int wlength; /* passed to ssl2_enc */ + int wact_data_length; /* Set when things are decrypted. */ + unsigned char *ract_data; + unsigned char *wact_data; + unsigned char *mac_data; + + unsigned char *read_key; + unsigned char *write_key; + + /* Stuff specifically to do with this SSL session */ + unsigned int challenge_length; + unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH]; + unsigned int conn_id_length; + unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH]; + unsigned int key_material_length; + unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2]; + + unsigned long read_sequence; + unsigned long write_sequence; + + struct { + unsigned int conn_id_length; + unsigned int cert_type; + unsigned int cert_length; + unsigned int csl; + unsigned int clear; + unsigned int enc; + unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; + unsigned int cipher_spec_length; + unsigned int session_id_length; + unsigned int clen; + unsigned int rlen; + } tmp; + } SSL2_STATE; + +/* SSLv2 */ +/* client */ +#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT) +#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT) +#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT) +/* server */ +#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT) +#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT) +#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/ssl23.h b/include/openssl/ssl23.h new file mode 100755 index 0000000..1a87d8c --- /dev/null +++ b/include/openssl/ssl23.h @@ -0,0 +1,83 @@ +/* ssl/ssl23.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL23_H +#define HEADER_SSL23_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*client */ +/* write to server */ +#define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) +#define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) +/* read from server */ +#define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) +#define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) + +/* server */ +/* read from client */ +#define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) +#define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/ssl3.h b/include/openssl/ssl3.h new file mode 100755 index 0000000..45e7c99 --- /dev/null +++ b/include/openssl/ssl3.h @@ -0,0 +1,555 @@ +/* ssl/ssl3.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL3_H +#define HEADER_SSL3_H + +#ifndef OPENSSL_NO_COMP +#include +#endif +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SSL3_CK_RSA_NULL_MD5 0x03000001 +#define SSL3_CK_RSA_NULL_SHA 0x03000002 +#define SSL3_CK_RSA_RC4_40_MD5 0x03000003 +#define SSL3_CK_RSA_RC4_128_MD5 0x03000004 +#define SSL3_CK_RSA_RC4_128_SHA 0x03000005 +#define SSL3_CK_RSA_RC2_40_MD5 0x03000006 +#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 +#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 +#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 +#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A + +#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B +#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C +#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D +#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E +#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F +#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 + +#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 +#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 +#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 +#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 +#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 +#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 + +#define SSL3_CK_ADH_RC4_40_MD5 0x03000017 +#define SSL3_CK_ADH_RC4_128_MD5 0x03000018 +#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 +#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A +#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B + +#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C +#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D +#if 0 /* Because it clashes with KRB5, is never used any more, and is safe + to remove according to David Hopwood + of the ietf-tls list */ +#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E +#endif + +/* VRS Additional Kerberos5 entries + */ +#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E +#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F +#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 +#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 +#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 +#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 +#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 +#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 + +#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 +#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 +#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 +#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 +#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A +#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B + +#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" +#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" +#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" +#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" +#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" +#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" + +#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" +#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" +#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" + +#define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA" +#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" +#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" + +#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" +#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" +#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" +#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" +#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" + +#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" +#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" +#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" + +#define SSL3_SSL_SESSION_ID_LENGTH 32 +#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 + +#define SSL3_MASTER_SECRET_SIZE 48 +#define SSL3_RANDOM_SIZE 32 +#define SSL3_SESSION_ID_SIZE 32 +#define SSL3_RT_HEADER_LENGTH 5 + +/* Due to MS stuffing up, this can change.... */ +#if defined(OPENSSL_SYS_WIN16) || \ + (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) +#define SSL3_RT_MAX_EXTRA (14000) +#else +#define SSL3_RT_MAX_EXTRA (16384) +#endif + +#define SSL3_RT_MAX_PLAIN_LENGTH 16384 +#ifdef OPENSSL_NO_COMP +#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH +#else +#define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH) +#endif +#define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH) +#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) +#define SSL3_RT_MAX_DATA_SIZE (1024*1024) + +#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" +#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" + +#define SSL3_VERSION 0x0300 +#define SSL3_VERSION_MAJOR 0x03 +#define SSL3_VERSION_MINOR 0x00 + +#define SSL3_RT_CHANGE_CIPHER_SPEC 20 +#define SSL3_RT_ALERT 21 +#define SSL3_RT_HANDSHAKE 22 +#define SSL3_RT_APPLICATION_DATA 23 + +#define SSL3_AL_WARNING 1 +#define SSL3_AL_FATAL 2 + +#define SSL3_AD_CLOSE_NOTIFY 0 +#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ +#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ +#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ +#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ +#define SSL3_AD_NO_CERTIFICATE 41 +#define SSL3_AD_BAD_CERTIFICATE 42 +#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 +#define SSL3_AD_CERTIFICATE_REVOKED 44 +#define SSL3_AD_CERTIFICATE_EXPIRED 45 +#define SSL3_AD_CERTIFICATE_UNKNOWN 46 +#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ + +typedef struct ssl3_record_st + { +/*r */ int type; /* type of record */ +/*rw*/ unsigned int length; /* How many bytes available */ +/*r */ unsigned int off; /* read/write offset into 'buf' */ +/*rw*/ unsigned char *data; /* pointer to the record data */ +/*rw*/ unsigned char *input; /* where the decode bytes are */ +/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ +/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */ +/*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */ + } SSL3_RECORD; + +typedef struct ssl3_buffer_st + { + unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, + * see ssl3_setup_buffers() */ + size_t len; /* buffer size */ + int offset; /* where to 'copy from' */ + int left; /* how many bytes left */ + } SSL3_BUFFER; + +#define SSL3_CT_RSA_SIGN 1 +#define SSL3_CT_DSS_SIGN 2 +#define SSL3_CT_RSA_FIXED_DH 3 +#define SSL3_CT_DSS_FIXED_DH 4 +#define SSL3_CT_RSA_EPHEMERAL_DH 5 +#define SSL3_CT_DSS_EPHEMERAL_DH 6 +#define SSL3_CT_FORTEZZA_DMS 20 +/* SSL3_CT_NUMBER is used to size arrays and it must be large + * enough to contain all of the cert types defined either for + * SSLv3 and TLSv1. + */ +#define SSL3_CT_NUMBER 7 + + +#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 +#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 +#define SSL3_FLAGS_POP_BUFFER 0x0004 +#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +typedef struct ssl3_state_st + { + long flags; + int delay_buf_pop_ret; + + unsigned char read_sequence[8]; + unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; + unsigned char write_sequence[8]; + unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; + + unsigned char server_random[SSL3_RANDOM_SIZE]; + unsigned char client_random[SSL3_RANDOM_SIZE]; + + /* flags for countermeasure against known-IV weakness */ + int need_empty_fragments; + int empty_fragment_done; + + SSL3_BUFFER rbuf; /* read IO goes into here */ + SSL3_BUFFER wbuf; /* write IO goes into here */ + + SSL3_RECORD rrec; /* each decoded record goes in here */ + SSL3_RECORD wrec; /* goes out from here */ + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[2]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[4]; + unsigned int handshake_fragment_len; + + /* partial write - check the numbers match */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; /* number bytes written */ + int wpend_type; + int wpend_ret; /* number of bytes submitted */ + const unsigned char *wpend_buf; + + /* used during startup, digest all incoming/outgoing packets */ + EVP_MD_CTX finish_dgst1; + EVP_MD_CTX finish_dgst2; + + /* this is set whenerver we see a change_cipher_spec message + * come in when we are not looking for one */ + int change_cipher_spec; + + int warn_alert; + int fatal_alert; + /* we allow one fatal and one warning alert to be outstanding, + * send close alert via the warning alert */ + int alert_dispatch; + unsigned char send_alert[2]; + + /* This flag is set when we should renegotiate ASAP, basically when + * there is no more data in the read or write buffers */ + int renegotiate; + int total_renegotiations; + int num_renegotiations; + + int in_read_app_data; + + struct { + /* actually only needs to be 16+20 */ + unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; + + /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ + unsigned char finish_md[EVP_MAX_MD_SIZE*2]; + int finish_md_len; + unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; + int peer_finish_md_len; + + unsigned long message_size; + int message_type; + + /* used to hold the new cipher we are going to use */ + SSL_CIPHER *new_cipher; +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + +#ifndef OPENSSL_NO_ECDH + EC_KEY *ecdh; /* holds short lived ECDH key */ +#endif + + /* used when SSL_ST_FLUSH_DATA is entered */ + int next_state; + + int reuse_message; + + /* used for certificate requests */ + int cert_req; + int ctype_num; + char ctype[SSL3_CT_NUMBER]; + STACK_OF(X509_NAME) *ca_names; + + int use_rsa_tmp; + + int key_block_length; + unsigned char *key_block; + + const EVP_CIPHER *new_sym_enc; + const EVP_MD *new_hash; +#ifndef OPENSSL_NO_COMP + const SSL_COMP *new_compression; +#else + char *new_compression; +#endif + int cert_request; + } tmp; + + } SSL3_STATE; + + +/* SSLv3 */ +/*client */ +/* extra state */ +#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) +#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) +#define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) + +/* server */ +/* extra state */ +#define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) +/* read from client */ +/* Do not change the number values, they do matter */ +#define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) +/* write to client */ +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT) +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) +/* read from client */ +#define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) +/* write to client */ +#define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) + +#define SSL3_MT_HELLO_REQUEST 0 +#define SSL3_MT_CLIENT_HELLO 1 +#define SSL3_MT_SERVER_HELLO 2 +#define SSL3_MT_CERTIFICATE 11 +#define SSL3_MT_SERVER_KEY_EXCHANGE 12 +#define SSL3_MT_CERTIFICATE_REQUEST 13 +#define SSL3_MT_SERVER_DONE 14 +#define SSL3_MT_CERTIFICATE_VERIFY 15 +#define SSL3_MT_CLIENT_KEY_EXCHANGE 16 +#define SSL3_MT_FINISHED 20 +#define DTLS1_MT_HELLO_VERIFY_REQUEST 3 + + +#define SSL3_MT_CCS 1 + +/* These are used when changing over to a new cipher */ +#define SSL3_CC_READ 0x01 +#define SSL3_CC_WRITE 0x02 +#define SSL3_CC_CLIENT 0x10 +#define SSL3_CC_SERVER 0x20 +#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) +#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/stack.h b/include/openssl/stack.h new file mode 100755 index 0000000..7f3b13d --- /dev/null +++ b/include/openssl/stack.h @@ -0,0 +1,109 @@ +/* crypto/stack/stack.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_STACK_H +#define HEADER_STACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stack_st + { + int num; + char **data; + int sorted; + + int num_alloc; + int (*comp)(const char * const *, const char * const *); + } STACK; + +#define M_sk_num(sk) ((sk) ? (sk)->num:-1) +#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) + +int sk_num(const STACK *); +char *sk_value(const STACK *, int); + +char *sk_set(STACK *, int, char *); + +STACK *sk_new(int (*cmp)(const char * const *, const char * const *)); +STACK *sk_new_null(void); +void sk_free(STACK *); +void sk_pop_free(STACK *st, void (*func)(void *)); +int sk_insert(STACK *sk,char *data,int where); +char *sk_delete(STACK *st,int loc); +char *sk_delete_ptr(STACK *st, char *p); +int sk_find(STACK *st,char *data); +int sk_find_ex(STACK *st,char *data); +int sk_push(STACK *st,char *data); +int sk_unshift(STACK *st,char *data); +char *sk_shift(STACK *st); +char *sk_pop(STACK *st); +void sk_zero(STACK *st); +int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, + const char * const *))) + (const char * const *, const char * const *); +STACK *sk_dup(STACK *st); +void sk_sort(STACK *st); +int sk_is_sorted(const STACK *st); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/store.h b/include/openssl/store.h new file mode 100755 index 0000000..9665d0d --- /dev/null +++ b/include/openssl/store.h @@ -0,0 +1,554 @@ +/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2003. + */ +/* ==================================================================== + * Copyright (c) 2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_STORE_H +#define HEADER_STORE_H + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct store_st STORE; */ +/* typedef struct store_method_st STORE_METHOD; */ + + +/* All the following functions return 0, a negative number or NULL on error. + When everything is fine, they return a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +STORE *STORE_new_method(const STORE_METHOD *method); +STORE *STORE_new_engine(ENGINE *engine); +void STORE_free(STORE *ui); + + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a STORE. */ +int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); + +/* A control to set the directory with keys and certificates. Used by the + built-in directory level method. */ +#define STORE_CTRL_SET_DIRECTORY 0x0001 +/* A control to set a file to load. Used by the built-in file level method. */ +#define STORE_CTRL_SET_FILE 0x0002 +/* A control to set a configuration file to load. Can be used by any method + that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_FILE 0x0003 +/* A control to set a the section of the loaded configuration file. Can be + used by any method that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_SECTION 0x0004 + + +/* Some methods may use extra data */ +#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) +#define STORE_get_app_data(s) STORE_get_ex_data(s,0) +int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int STORE_set_ex_data(STORE *r,int idx,void *arg); +void *STORE_get_ex_data(STORE *r, int idx); + +/* Use specific methods instead of the built-in one */ +const STORE_METHOD *STORE_get_method(STORE *store); +const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); + +/* The standard OpenSSL methods. */ +/* This is the in-memory method. It does everything except revoking and updating, + and is of course volatile. It's used by other methods that have an in-memory + cache. */ +const STORE_METHOD *STORE_Memory(void); +#if 0 /* Not yet implemented */ +/* This is the directory store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. */ +const STORE_METHOD *STORE_Directory(void); +/* This is the file store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. Certificates are added + to it with the store operation, and it will only get cached certificates. */ +const STORE_METHOD *STORE_File(void); +#endif + +/* Store functions take a type code for the type of data they should store + or fetch */ +typedef enum STORE_object_types + { + STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ + STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ + STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ + STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ + STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known + object types */ + } STORE_OBJECT_TYPES; +/* List of text strings corresponding to the object types. */ +extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; + +/* Some store functions take a parameter list. Those parameters come with + one of the following codes. The comments following the codes below indicate + what type the value should be a pointer to. */ +typedef enum STORE_params + { + STORE_PARAM_EVP_TYPE= 0x01, /* int */ + STORE_PARAM_BITS= 0x02, /* size_t */ + STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ + STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ + STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ + STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ + STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known + parameter types */ + } STORE_PARAM_TYPES; +/* Parameter value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; + +/* Store functions take attribute lists. Those attributes come with codes. + The comments following the codes below indicate what type the value should + be a pointer to. */ +typedef enum STORE_attribs + { + STORE_ATTR_END= 0x00, + STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ + STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ + STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ + STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ + STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ + STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ + STORE_ATTR_EMAIL= 0x0a, /* C string */ + STORE_ATTR_FILENAME= 0x0b, /* C string */ + STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known + attribute types */ + STORE_ATTR_OR= 0xff /* This is a special + separator, which + expresses the OR + operation. */ + } STORE_ATTR_TYPES; +/* Attribute value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; + +typedef enum STORE_certificate_status + { + STORE_X509_VALID= 0x00, + STORE_X509_EXPIRED= 0x01, + STORE_X509_SUSPENDED= 0x02, + STORE_X509_REVOKED= 0x03 + } STORE_CERTIFICATE_STATUS; + +/* Engine store functions will return a structure that contains all the necessary + * information, including revokation status for certificates. This is really not + * needed for application authors, as the ENGINE framework functions will extract + * the OpenSSL-specific information when at all possible. However, for engine + * authors, it's crucial to know this structure. */ +typedef struct STORE_OBJECT_st + { + STORE_OBJECT_TYPES type; + union + { + struct + { + STORE_CERTIFICATE_STATUS status; + X509 *certificate; + } x509; + X509_CRL *crl; + EVP_PKEY *key; + BIGNUM *number; + BUF_MEM *arbitrary; + } data; + } STORE_OBJECT; +DECLARE_STACK_OF(STORE_OBJECT) +STORE_OBJECT *STORE_OBJECT_new(void); +void STORE_OBJECT_free(STORE_OBJECT *data); + + + +/* The following functions handle the storage. They return 0, a negative number + or NULL on error, anything else on success. */ +X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509 *STORE_list_certificate_next(STORE *e, void *handle); +int STORE_list_certificate_end(STORE *e, void *handle); +int STORE_list_certificate_endp(STORE *e, void *handle); +EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_private_key(STORE *e, EVP_PKEY *data, + OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); +int STORE_list_private_key_end(STORE *e, void *handle); +int STORE_list_private_key_endp(STORE *e, void *handle); +EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); +int STORE_list_public_key_end(STORE *e, void *handle); +int STORE_list_public_key_endp(STORE *e, void *handle); +X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_list_crl_next(STORE *e, void *handle); +int STORE_list_crl_end(STORE *e, void *handle); +int STORE_list_crl_endp(STORE *e, void *handle); +int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); + + +/* Create and manipulate methods */ +STORE_METHOD *STORE_create_method(char *name); +void STORE_destroy_method(STORE_METHOD *store_method); + +/* These callback types are use for store handlers */ +typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); +typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); +typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); + +int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); +int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); +int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); +int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); +int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); +int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); +int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); +int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); +int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); +int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); +int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); +int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); + +STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); +STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); +STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); +STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); +STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); +STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); +STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); +STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); +STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); +STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); + +/* Method helper structures and functions. */ + +/* This structure is the result of parsing through the information in a list + of OPENSSL_ITEMs. It stores all the necessary information in a structured + way.*/ +typedef struct STORE_attr_info_st STORE_ATTR_INFO; + +/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. + Note that we do this in the list form, since the list of OPENSSL_ITEMs can + come in blocks separated with STORE_ATTR_OR. Note that the value returned + by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ +void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); +STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); +int STORE_parse_attrs_end(void *handle); +int STORE_parse_attrs_endp(void *handle); + +/* Creator and destructor */ +STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); +int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); + +/* Manipulators */ +char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, + STORE_ATTR_TYPES code); +X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); +int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); + +/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values + in each contained attribute. */ +int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a is within the range of attributes + set in b. */ +int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a are also set in b. */ +int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ +int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_STORE_strings(void); + +/* Error codes for the STORE functions. */ + +/* Function codes. */ +#define STORE_F_MEM_DELETE 134 +#define STORE_F_MEM_GENERATE 135 +#define STORE_F_MEM_LIST_END 168 +#define STORE_F_MEM_LIST_NEXT 136 +#define STORE_F_MEM_LIST_START 137 +#define STORE_F_MEM_MODIFY 169 +#define STORE_F_MEM_STORE 138 +#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 +#define STORE_F_STORE_ATTR_INFO_GET0_DN 140 +#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 +#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 +#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 +#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 +#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 +#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 +#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 +#define STORE_F_STORE_ATTR_INFO_SET_DN 148 +#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 +#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 +#define STORE_F_STORE_CERTIFICATE 170 +#define STORE_F_STORE_CTRL 161 +#define STORE_F_STORE_DELETE_ARBITRARY 158 +#define STORE_F_STORE_DELETE_CERTIFICATE 102 +#define STORE_F_STORE_DELETE_CRL 103 +#define STORE_F_STORE_DELETE_NUMBER 104 +#define STORE_F_STORE_DELETE_PRIVATE_KEY 105 +#define STORE_F_STORE_DELETE_PUBLIC_KEY 106 +#define STORE_F_STORE_GENERATE_CRL 107 +#define STORE_F_STORE_GENERATE_KEY 108 +#define STORE_F_STORE_GET_ARBITRARY 159 +#define STORE_F_STORE_GET_CERTIFICATE 109 +#define STORE_F_STORE_GET_CRL 110 +#define STORE_F_STORE_GET_NUMBER 111 +#define STORE_F_STORE_GET_PRIVATE_KEY 112 +#define STORE_F_STORE_GET_PUBLIC_KEY 113 +#define STORE_F_STORE_LIST_CERTIFICATE_END 114 +#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 +#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 +#define STORE_F_STORE_LIST_CERTIFICATE_START 116 +#define STORE_F_STORE_LIST_CRL_END 117 +#define STORE_F_STORE_LIST_CRL_ENDP 154 +#define STORE_F_STORE_LIST_CRL_NEXT 118 +#define STORE_F_STORE_LIST_CRL_START 119 +#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 +#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 +#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 +#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 +#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 +#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 +#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 +#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 +#define STORE_F_STORE_MODIFY_ARBITRARY 162 +#define STORE_F_STORE_MODIFY_CERTIFICATE 163 +#define STORE_F_STORE_MODIFY_CRL 164 +#define STORE_F_STORE_MODIFY_NUMBER 165 +#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 +#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 +#define STORE_F_STORE_NEW_ENGINE 133 +#define STORE_F_STORE_NEW_METHOD 132 +#define STORE_F_STORE_PARSE_ATTRS_END 151 +#define STORE_F_STORE_PARSE_ATTRS_ENDP 172 +#define STORE_F_STORE_PARSE_ATTRS_NEXT 152 +#define STORE_F_STORE_PARSE_ATTRS_START 171 +#define STORE_F_STORE_REVOKE_CERTIFICATE 129 +#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 +#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 +#define STORE_F_STORE_STORE_ARBITRARY 157 +#define STORE_F_STORE_STORE_CERTIFICATE 100 +#define STORE_F_STORE_STORE_CRL 101 +#define STORE_F_STORE_STORE_NUMBER 126 +#define STORE_F_STORE_STORE_PRIVATE_KEY 127 +#define STORE_F_STORE_STORE_PUBLIC_KEY 128 + +/* Reason codes. */ +#define STORE_R_ALREADY_HAS_A_VALUE 127 +#define STORE_R_FAILED_DELETING_ARBITRARY 132 +#define STORE_R_FAILED_DELETING_CERTIFICATE 100 +#define STORE_R_FAILED_DELETING_KEY 101 +#define STORE_R_FAILED_DELETING_NUMBER 102 +#define STORE_R_FAILED_GENERATING_CRL 103 +#define STORE_R_FAILED_GENERATING_KEY 104 +#define STORE_R_FAILED_GETTING_ARBITRARY 133 +#define STORE_R_FAILED_GETTING_CERTIFICATE 105 +#define STORE_R_FAILED_GETTING_KEY 106 +#define STORE_R_FAILED_GETTING_NUMBER 107 +#define STORE_R_FAILED_LISTING_CERTIFICATES 108 +#define STORE_R_FAILED_LISTING_KEYS 109 +#define STORE_R_FAILED_MODIFYING_ARBITRARY 138 +#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 +#define STORE_R_FAILED_MODIFYING_CRL 140 +#define STORE_R_FAILED_MODIFYING_NUMBER 141 +#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 +#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 +#define STORE_R_FAILED_REVOKING_CERTIFICATE 110 +#define STORE_R_FAILED_REVOKING_KEY 111 +#define STORE_R_FAILED_STORING_ARBITRARY 134 +#define STORE_R_FAILED_STORING_CERTIFICATE 112 +#define STORE_R_FAILED_STORING_KEY 113 +#define STORE_R_FAILED_STORING_NUMBER 114 +#define STORE_R_NOT_IMPLEMENTED 128 +#define STORE_R_NO_CONTROL_FUNCTION 144 +#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 +#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 +#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 +#define STORE_R_NO_GENERATE_CRL_FUNCTION 117 +#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 +#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 +#define STORE_R_NO_GET_OBJECT_FUNCTION 119 +#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 +#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 +#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 +#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 +#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 +#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 +#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 +#define STORE_R_NO_STORE 129 +#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 +#define STORE_R_NO_STORE_OBJECT_FUNCTION 125 +#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 +#define STORE_R_NO_VALUE 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/symhacks.h b/include/openssl/symhacks.h new file mode 100755 index 0000000..16df42d --- /dev/null +++ b/include/openssl/symhacks.h @@ -0,0 +1,383 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SYMHACKS_H +#define HEADER_SYMHACKS_H + +#include + +/* Hacks to solve the problem with linkers incapable of handling very long + symbol names. In the case of VMS, the limit is 31 characters on VMS for + VAX. */ +#ifdef OPENSSL_SYS_VMS + +/* Hack a long name in crypto/ex_data.c */ +#undef CRYPTO_get_ex_data_implementation +#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl +#undef CRYPTO_set_ex_data_implementation +#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl + +/* Hack a long name in crypto/asn1/a_mbstr.c */ +#undef ASN1_STRING_set_default_mask_asc +#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF +#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF +#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */ +#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC +#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC +#endif + +/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ +#undef PEM_read_NETSCAPE_CERT_SEQUENCE +#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ +#undef PEM_write_NETSCAPE_CERT_SEQUENCE +#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ +#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ +#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ +#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ + +/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */ +#undef PEM_read_PKCS8_PRIV_KEY_INFO +#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO +#undef PEM_write_PKCS8_PRIV_KEY_INFO +#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO +#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO +#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO +#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO +#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO + +/* Hack other PEM names */ +#undef PEM_write_bio_PKCS8PrivateKey_nid +#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid + +/* Hack some long X509 names */ +#undef X509_REVOKED_get_ext_by_critical +#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic +#undef X509_policy_tree_get0_user_policies +#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies +#undef X509_policy_node_get0_qualifiers +#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers +#undef X509_STORE_CTX_get_explicit_policy +#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy + +/* Hack some long CRYPTO names */ +#undef CRYPTO_set_dynlock_destroy_callback +#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb +#undef CRYPTO_set_dynlock_create_callback +#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb +#undef CRYPTO_set_dynlock_lock_callback +#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb +#undef CRYPTO_get_dynlock_lock_callback +#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb +#undef CRYPTO_get_dynlock_destroy_callback +#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb +#undef CRYPTO_get_dynlock_create_callback +#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb +#undef CRYPTO_set_locked_mem_ex_functions +#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs +#undef CRYPTO_get_locked_mem_ex_functions +#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs + +/* Hack some long SSL names */ +#undef SSL_CTX_set_default_verify_paths +#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths +#undef SSL_get_ex_data_X509_STORE_CTX_idx +#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx +#undef SSL_add_file_cert_subjects_to_stack +#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk +#undef SSL_add_dir_cert_subjects_to_stack +#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk +#undef SSL_CTX_use_certificate_chain_file +#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file +#undef SSL_CTX_set_cert_verify_callback +#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb +#undef SSL_CTX_set_default_passwd_cb_userdata +#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud +#undef SSL_COMP_get_compression_methods +#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods + +/* Hack some long ENGINE names */ +#undef ENGINE_get_default_BN_mod_exp_crt +#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt +#undef ENGINE_set_default_BN_mod_exp_crt +#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt +#undef ENGINE_set_load_privkey_function +#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn +#undef ENGINE_get_load_privkey_function +#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn + +/* Hack some long OCSP names */ +#undef OCSP_REQUEST_get_ext_by_critical +#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit +#undef OCSP_BASICRESP_get_ext_by_critical +#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit +#undef OCSP_SINGLERESP_get_ext_by_critical +#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit + +/* Hack some long DES names */ +#undef _ossl_old_des_ede3_cfb64_encrypt +#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt +#undef _ossl_old_des_ede3_ofb64_encrypt +#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt + +/* Hack some long EVP names */ +#undef OPENSSL_add_all_algorithms_noconf +#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf +#undef OPENSSL_add_all_algorithms_conf +#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf + +/* Hack some long EC names */ +#undef EC_GROUP_set_point_conversion_form +#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form +#undef EC_GROUP_get_point_conversion_form +#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form +#undef EC_GROUP_clear_free_all_extra_data +#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data +#undef EC_POINT_set_Jprojective_coordinates_GFp +#define EC_POINT_set_Jprojective_coordinates_GFp \ + EC_POINT_set_Jproj_coords_GFp +#undef EC_POINT_get_Jprojective_coordinates_GFp +#define EC_POINT_get_Jprojective_coordinates_GFp \ + EC_POINT_get_Jproj_coords_GFp +#undef EC_POINT_set_affine_coordinates_GFp +#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp +#undef EC_POINT_get_affine_coordinates_GFp +#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp +#undef EC_POINT_set_compressed_coordinates_GFp +#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp +#undef EC_POINT_set_affine_coordinates_GF2m +#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m +#undef EC_POINT_get_affine_coordinates_GF2m +#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m +#undef EC_POINT_set_compressed_coordinates_GF2m +#define EC_POINT_set_compressed_coordinates_GF2m \ + EC_POINT_set_compr_coords_GF2m +#undef ec_GF2m_simple_group_clear_finish +#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish +#undef ec_GF2m_simple_group_check_discriminant +#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim +#undef ec_GF2m_simple_point_clear_finish +#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish +#undef ec_GF2m_simple_point_set_to_infinity +#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf +#undef ec_GF2m_simple_points_make_affine +#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine +#undef ec_GF2m_simple_point_set_affine_coordinates +#define ec_GF2m_simple_point_set_affine_coordinates \ + ec_GF2m_smp_pt_set_af_coords +#undef ec_GF2m_simple_point_get_affine_coordinates +#define ec_GF2m_simple_point_get_affine_coordinates \ + ec_GF2m_smp_pt_get_af_coords +#undef ec_GF2m_simple_set_compressed_coordinates +#define ec_GF2m_simple_set_compressed_coordinates \ + ec_GF2m_smp_set_compr_coords +#undef ec_GFp_simple_group_set_curve_GFp +#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_group_clear_finish +#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish +#undef ec_GFp_simple_group_set_generator +#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator +#undef ec_GFp_simple_group_get0_generator +#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator +#undef ec_GFp_simple_group_get_cofactor +#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor +#undef ec_GFp_simple_point_clear_finish +#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish +#undef ec_GFp_simple_point_set_to_infinity +#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf +#undef ec_GFp_simple_points_make_affine +#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_set_Jprojective_coordinates_GFp +#define ec_GFp_simple_set_Jprojective_coordinates_GFp \ + ec_GFp_smp_set_Jproj_coords_GFp +#undef ec_GFp_simple_get_Jprojective_coordinates_GFp +#define ec_GFp_simple_get_Jprojective_coordinates_GFp \ + ec_GFp_smp_get_Jproj_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates_GFp +#define ec_GFp_simple_point_set_affine_coordinates_GFp \ + ec_GFp_smp_pt_set_af_coords_GFp +#undef ec_GFp_simple_point_get_affine_coordinates_GFp +#define ec_GFp_simple_point_get_affine_coordinates_GFp \ + ec_GFp_smp_pt_get_af_coords_GFp +#undef ec_GFp_simple_set_compressed_coordinates_GFp +#define ec_GFp_simple_set_compressed_coordinates_GFp \ + ec_GFp_smp_set_compr_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates +#define ec_GFp_simple_point_set_affine_coordinates \ + ec_GFp_smp_pt_set_af_coords +#undef ec_GFp_simple_point_get_affine_coordinates +#define ec_GFp_simple_point_get_affine_coordinates \ + ec_GFp_smp_pt_get_af_coords +#undef ec_GFp_simple_set_compressed_coordinates +#define ec_GFp_simple_set_compressed_coordinates \ + ec_GFp_smp_set_compr_coords +#undef ec_GFp_simple_group_check_discriminant +#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim + +/* Hack som long STORE names */ +#undef STORE_method_set_initialise_function +#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn +#undef STORE_method_set_cleanup_function +#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn +#undef STORE_method_set_generate_function +#define STORE_method_set_generate_function STORE_meth_set_generate_fn +#undef STORE_method_set_modify_function +#define STORE_method_set_modify_function STORE_meth_set_modify_fn +#undef STORE_method_set_revoke_function +#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn +#undef STORE_method_set_delete_function +#define STORE_method_set_delete_function STORE_meth_set_delete_fn +#undef STORE_method_set_list_start_function +#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn +#undef STORE_method_set_list_next_function +#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn +#undef STORE_method_set_list_end_function +#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn +#undef STORE_method_set_update_store_function +#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn +#undef STORE_method_set_lock_store_function +#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn +#undef STORE_method_set_unlock_store_function +#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn +#undef STORE_method_get_initialise_function +#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn +#undef STORE_method_get_cleanup_function +#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn +#undef STORE_method_get_generate_function +#define STORE_method_get_generate_function STORE_meth_get_generate_fn +#undef STORE_method_get_modify_function +#define STORE_method_get_modify_function STORE_meth_get_modify_fn +#undef STORE_method_get_revoke_function +#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn +#undef STORE_method_get_delete_function +#define STORE_method_get_delete_function STORE_meth_get_delete_fn +#undef STORE_method_get_list_start_function +#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn +#undef STORE_method_get_list_next_function +#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn +#undef STORE_method_get_list_end_function +#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn +#undef STORE_method_get_update_store_function +#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn +#undef STORE_method_get_lock_store_function +#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn +#undef STORE_method_get_unlock_store_function +#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn + +#endif /* defined OPENSSL_SYS_VMS */ + + +/* Case insensiteve linking causes problems.... */ +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) +#undef ERR_load_CRYPTO_strings +#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings +#undef OCSP_crlID_new +#define OCSP_crlID_new OCSP_crlID2_new + +#undef d2i_ECPARAMETERS +#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS +#undef i2d_ECPARAMETERS +#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS +#undef d2i_ECPKPARAMETERS +#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS +#undef i2d_ECPKPARAMETERS +#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS + +/* These functions do not seem to exist! However, I'm paranoid... + Original command in x509v3.h: + These functions are being redefined in another directory, + and clash when the linker is case-insensitive, so let's + hide them a little, by giving them an extra 'o' at the + beginning of the name... */ +#undef X509v3_cleanup_extensions +#define X509v3_cleanup_extensions oX509v3_cleanup_extensions +#undef X509v3_add_extension +#define X509v3_add_extension oX509v3_add_extension +#undef X509v3_add_netscape_extensions +#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions +#undef X509v3_add_standard_extensions +#define X509v3_add_standard_extensions oX509v3_add_standard_extensions + + +#endif + + +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/include/openssl/tls1.h b/include/openssl/tls1.h new file mode 100755 index 0000000..1fabd50 --- /dev/null +++ b/include/openssl/tls1.h @@ -0,0 +1,305 @@ +/* ssl/tls1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * ECC cipher suite support in OpenSSL originally written by + * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_TLS1_H +#define HEADER_TLS1_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 + +#define TLS1_VERSION 0x0301 +#define TLS1_VERSION_MAJOR 0x03 +#define TLS1_VERSION_MINOR 0x01 + +#define TLS1_AD_DECRYPTION_FAILED 21 +#define TLS1_AD_RECORD_OVERFLOW 22 +#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ +#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ +#define TLS1_AD_DECODE_ERROR 50 /* fatal */ +#define TLS1_AD_DECRYPT_ERROR 51 +#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ +#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ +#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ +#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ +#define TLS1_AD_USER_CANCELLED 90 +#define TLS1_AD_NO_RENEGOTIATION 100 + +/* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt + * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see + * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably + * shouldn't. */ +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 +#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 +#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 + +/* AES ciphersuites from RFC3268 */ + +#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F +#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 +#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 +#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 +#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 +#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 + +#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 +#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 +#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 +#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 +#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 +#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A + +/* Camellia ciphersuites from RFC4132 */ +#define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 +#define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 +#define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 +#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 +#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 +#define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 + +#define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 +#define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 +#define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 +#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 +#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 +#define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 + +/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */ +#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 +#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 +#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 + +#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 +#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 +#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A + +#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B +#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C +#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D +#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E +#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F + +#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 +#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 +#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 +#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 +#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 + +#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 +#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 +#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 +#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 +#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 + +/* XXX + * Inconsistency alert: + * The OpenSSL names of ciphers with ephemeral DH here include the string + * "DHE", while elsewhere it has always been "EDH". + * (The alias for the list of all such ciphers also is "EDH".) + * The specifications speak of "EDH"; maybe we should allow both forms + * for everything. */ +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" +#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" + +/* AES ciphersuites from RFC3268 */ +#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" +#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" + +#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" +#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" + +/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" + +#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" +#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" +#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" + +/* Camellia ciphersuites form RFC4132 */ +#define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" +#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" +#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" +#define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" + +#define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" +#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" +#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" +#define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" + + +#define TLS_CT_RSA_SIGN 1 +#define TLS_CT_DSS_SIGN 2 +#define TLS_CT_RSA_FIXED_DH 3 +#define TLS_CT_DSS_FIXED_DH 4 +#define TLS_CT_ECDSA_SIGN 64 +#define TLS_CT_RSA_FIXED_ECDH 65 +#define TLS_CT_ECDSA_FIXED_ECDH 66 +#define TLS_CT_NUMBER 7 + +#define TLS1_FINISH_MAC_LENGTH 12 + +#define TLS_MD_MAX_CONST_SIZE 20 +#define TLS_MD_CLIENT_FINISH_CONST "client finished" +#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_FINISH_CONST "server finished" +#define TLS_MD_SERVER_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_KEY_EXPANSION_CONST "key expansion" +#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 +#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" +#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_IV_BLOCK_CONST "IV block" +#define TLS_MD_IV_BLOCK_CONST_SIZE 8 +#define TLS_MD_MASTER_SECRET_CONST "master secret" +#define TLS_MD_MASTER_SECRET_CONST_SIZE 13 + +#ifdef CHARSET_EBCDIC +#undef TLS_MD_CLIENT_FINISH_CONST +#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/ +#undef TLS_MD_SERVER_FINISH_CONST +#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_KEY_EXPANSION_CONST +#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/ +#undef TLS_MD_CLIENT_WRITE_KEY_CONST +#define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_IV_BLOCK_CONST +#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/ +#undef TLS_MD_MASTER_SECRET_CONST +#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ +#endif + +#ifdef __cplusplus +} +#endif +#endif + + + diff --git a/include/openssl/tmdiff.h b/include/openssl/tmdiff.h new file mode 100755 index 0000000..6ed309e --- /dev/null +++ b/include/openssl/tmdiff.h @@ -0,0 +1,93 @@ +/* crypto/tmdiff.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ +/* ... erm yeah, "dynamic hash tables" you say? + * + * And what would dynamic hash tables have to do with any of this code *now*? + * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused + * file that I doubt compiles any more. speed.c is the only thing that could + * use this (and it has nothing to do with hash tables), yet it instead has its + * own duplication of all this stuff and looks, if anything, more complete. See + * the corresponding note in apps/speed.c. + * The Bemused - Geoff + */ + +#ifndef HEADER_TMDIFF_H +#define HEADER_TMDIFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ms_tm MS_TM; + +MS_TM *ms_time_new(void ); +void ms_time_free(MS_TM *a); +void ms_time_get(MS_TM *a); +double ms_time_diff(MS_TM *start, MS_TM *end); +int ms_time_cmp(const MS_TM *ap, const MS_TM *bp); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/openssl/txt_db.h b/include/openssl/txt_db.h new file mode 100755 index 0000000..a767e45 --- /dev/null +++ b/include/openssl/txt_db.h @@ -0,0 +1,109 @@ +/* crypto/txt_db/txt_db.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_TXT_DB_H +#define HEADER_TXT_DB_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#define DB_ERROR_OK 0 +#define DB_ERROR_MALLOC 1 +#define DB_ERROR_INDEX_CLASH 2 +#define DB_ERROR_INDEX_OUT_OF_RANGE 3 +#define DB_ERROR_NO_INDEX 4 +#define DB_ERROR_INSERT_INDEX_CLASH 5 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct txt_db_st + { + int num_fields; + STACK /* char ** */ *data; + LHASH **index; + int (**qual)(char **); + long error; + long arg1; + long arg2; + char **arg_row; + } TXT_DB; + +#ifndef OPENSSL_NO_BIO +TXT_DB *TXT_DB_read(BIO *in, int num); +long TXT_DB_write(BIO *out, TXT_DB *db); +#else +TXT_DB *TXT_DB_read(char *in, int num); +long TXT_DB_write(char *out, TXT_DB *db); +#endif +int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **), + LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp); +void TXT_DB_free(TXT_DB *db); +char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); +int TXT_DB_insert(TXT_DB *db,char **value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/openssl/ui.h b/include/openssl/ui.h new file mode 100755 index 0000000..5570e0d --- /dev/null +++ b/include/openssl/ui.h @@ -0,0 +1,381 @@ +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_H +#define HEADER_UI_H + +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct ui_st UI; */ +/* typedef struct ui_method_st UI_METHOD; */ + + +/* All the following functions return -1 or NULL on error and in some cases + (UI_process()) -2 if interrupted or in some other way cancelled. + When everything is fine, they return 0, a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +UI *UI_new(void); +UI *UI_new_method(const UI_METHOD *method); +void UI_free(UI *ui); + +/* The following functions are used to add strings to be printed and prompt + strings to prompt for data. The names are UI_{add,dup}__string + and UI_{add,dup}_input_boolean. + + UI_{add,dup}__string have the following meanings: + add add a text or prompt string. The pointers given to these + functions are used verbatim, no copying is done. + dup make a copy of the text or prompt string, then add the copy + to the collection of strings in the user interface. + + The function is a name for the functionality that the given + string shall be used for. It can be one of: + input use the string as data prompt. + verify use the string as verification prompt. This + is used to verify a previous input. + info use the string for informational output. + error use the string for error output. + Honestly, there's currently no difference between info and error for the + moment. + + UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", + and are typically used when one wants to prompt for a yes/no response. + + + All of the functions in this group take a UI and a prompt string. + The string input and verify addition functions also take a flag argument, + a buffer for the result to end up with, a minimum input size and a maximum + input size (the result buffer MUST be large enough to be able to contain + the maximum number of characters). Additionally, the verify addition + functions takes another buffer to compare the result against. + The boolean input functions take an action description string (which should + be safe to ignore if the expected user action is obvious, for example with + a dialog box with an OK button and a Cancel button), a string of acceptable + characters to mean OK and to mean Cancel. The two last strings are checked + to make sure they don't have common characters. Additionally, the same + flag argument as for the string input is taken, as well as a result buffer. + The result buffer is required to be at least one byte long. Depending on + the answer, the first character from the OK or the Cancel character strings + will be stored in the first byte of the result buffer. No NUL will be + added, so the result is *not* a string. + + On success, the all return an index of the added information. That index + is usefull when retrieving results with UI_get0_result(). */ +int UI_add_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_dup_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_add_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_dup_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_add_info_string(UI *ui, const char *text); +int UI_dup_info_string(UI *ui, const char *text); +int UI_add_error_string(UI *ui, const char *text); +int UI_dup_error_string(UI *ui, const char *text); + +/* These are the possible flags. They can be or'ed together. */ +/* Use to have echoing of input */ +#define UI_INPUT_FLAG_ECHO 0x01 +/* Use a default password. Where that password is found is completely + up to the application, it might for example be in the user data set + with UI_add_user_data(). It is not recommended to have more than + one input in each UI being marked with this flag, or the application + might get confused. */ +#define UI_INPUT_FLAG_DEFAULT_PWD 0x02 + +/* The user of these routines may want to define flags of their own. The core + UI won't look at those, but will pass them on to the method routines. They + must use higher bits so they don't get confused with the UI bits above. + UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good + example of use is this: + + #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) + +*/ +#define UI_INPUT_FLAG_USER_BASE 16 + + +/* The following function helps construct a prompt. object_desc is a + textual short description of the object, for example "pass phrase", + and object_name is the name of the object (might be a card name or + a file name. + The returned string shall always be allocated on the heap with + OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). + + If the ui_method doesn't contain a pointer to a user-defined prompt + constructor, a default string is built, looking like this: + + "Enter {object_desc} for {object_name}:" + + So, if object_desc has the value "pass phrase" and object_name has + the value "foo.key", the resulting string is: + + "Enter pass phrase for foo.key:" +*/ +char *UI_construct_prompt(UI *ui_method, + const char *object_desc, const char *object_name); + + +/* The following function is used to store a pointer to user-specific data. + Any previous such pointer will be returned and replaced. + + For callback purposes, this function makes a lot more sense than using + ex_data, since the latter requires that different parts of OpenSSL or + applications share the same ex_data index. + + Note that the UI_OpenSSL() method completely ignores the user data. + Other methods may not, however. */ +void *UI_add_user_data(UI *ui, void *user_data); +/* We need a user data retrieving function as well. */ +void *UI_get0_user_data(UI *ui); + +/* Return the result associated with a prompt given with the index i. */ +const char *UI_get0_result(UI *ui, int i); + +/* When all strings have been added, process the whole thing. */ +int UI_process(UI *ui); + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a UI. */ +int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); + +/* The commands */ +/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the + OpenSSL error stack before printing any info or added error messages and + before any prompting. */ +#define UI_CTRL_PRINT_ERRORS 1 +/* Check if a UI_process() is possible to do again with the same instance of + a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 + if not. */ +#define UI_CTRL_IS_REDOABLE 2 + + +/* Some methods may use extra data */ +#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) +#define UI_get_app_data(s) UI_get_ex_data(s,0) +int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int UI_set_ex_data(UI *r,int idx,void *arg); +void *UI_get_ex_data(UI *r, int idx); + +/* Use specific methods instead of the built-in one */ +void UI_set_default_method(const UI_METHOD *meth); +const UI_METHOD *UI_get_default_method(void); +const UI_METHOD *UI_get_method(UI *ui); +const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); + +/* The method with all the built-in thingies */ +UI_METHOD *UI_OpenSSL(void); + + +/* ---------- For method writers ---------- */ +/* A method contains a number of functions that implement the low level + of the User Interface. The functions are: + + an opener This function starts a session, maybe by opening + a channel to a tty, or by opening a window. + a writer This function is called to write a given string, + maybe to the tty, maybe as a field label in a + window. + a flusher This function is called to flush everything that + has been output so far. It can be used to actually + display a dialog box after it has been built. + a reader This function is called to read a given prompt, + maybe from the tty, maybe from a field in a + window. Note that it's called wth all string + structures, not only the prompt ones, so it must + check such things itself. + a closer This function closes the session, maybe by closing + the channel to the tty, or closing the window. + + All these functions are expected to return: + + 0 on error. + 1 on success. + -1 on out-of-band events, for example if some prompting has + been canceled (by pressing Ctrl-C, for example). This is + only checked when returned by the flusher or the reader. + + The way this is used, the opener is first called, then the writer for all + strings, then the flusher, then the reader for all strings and finally the + closer. Note that if you want to prompt from a terminal or other command + line interface, the best is to have the reader also write the prompts + instead of having the writer do it. If you want to prompt from a dialog + box, the writer can be used to build up the contents of the box, and the + flusher to actually display the box and run the event loop until all data + has been given, after which the reader only grabs the given data and puts + them back into the UI strings. + + All method functions take a UI as argument. Additionally, the writer and + the reader take a UI_STRING. +*/ + +/* The UI_STRING type is the data structure that contains all the needed info + about a string or a prompt, including test data for a verification prompt. +*/ +DECLARE_STACK_OF(UI_STRING) +typedef struct ui_string_st UI_STRING; + +/* The different types of strings that are currently supported. + This is only needed by method authors. */ +enum UI_string_types + { + UIT_NONE=0, + UIT_PROMPT, /* Prompt for a string */ + UIT_VERIFY, /* Prompt for a string and verify */ + UIT_BOOLEAN, /* Prompt for a yes/no response */ + UIT_INFO, /* Send info to the user */ + UIT_ERROR /* Send an error message to the user */ + }; + +/* Create and manipulate methods */ +UI_METHOD *UI_create_method(char *name); +void UI_destroy_method(UI_METHOD *ui_method); +int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); +int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); +int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); +int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); +int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); +int (*UI_method_get_opener(UI_METHOD *method))(UI*); +int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_flusher(UI_METHOD *method))(UI*); +int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_closer(UI_METHOD *method))(UI*); + +/* The following functions are helpers for method writers to access relevant + data from a UI_STRING. */ + +/* Return type of the UI_STRING */ +enum UI_string_types UI_get_string_type(UI_STRING *uis); +/* Return input flags of the UI_STRING */ +int UI_get_input_flags(UI_STRING *uis); +/* Return the actual string to output (the prompt, info or error) */ +const char *UI_get0_output_string(UI_STRING *uis); +/* Return the optional action string to output (the boolean promtp instruction) */ +const char *UI_get0_action_string(UI_STRING *uis); +/* Return the result of a prompt */ +const char *UI_get0_result_string(UI_STRING *uis); +/* Return the string to test the result against. Only useful with verifies. */ +const char *UI_get0_test_string(UI_STRING *uis); +/* Return the required minimum size of the result */ +int UI_get_result_minsize(UI_STRING *uis); +/* Return the required maximum size of the result */ +int UI_get_result_maxsize(UI_STRING *uis); +/* Set the result of a UI_STRING. */ +int UI_set_result(UI *ui, UI_STRING *uis, const char *result); + + +/* A couple of popular utility functions */ +int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); +int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_UI_strings(void); + +/* Error codes for the UI functions. */ + +/* Function codes. */ +#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 +#define UI_F_GENERAL_ALLOCATE_PROMPT 109 +#define UI_F_GENERAL_ALLOCATE_STRING 100 +#define UI_F_UI_CTRL 111 +#define UI_F_UI_DUP_ERROR_STRING 101 +#define UI_F_UI_DUP_INFO_STRING 102 +#define UI_F_UI_DUP_INPUT_BOOLEAN 110 +#define UI_F_UI_DUP_INPUT_STRING 103 +#define UI_F_UI_DUP_VERIFY_STRING 106 +#define UI_F_UI_GET0_RESULT 107 +#define UI_F_UI_NEW_METHOD 104 +#define UI_F_UI_SET_RESULT 105 + +/* Reason codes. */ +#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 +#define UI_R_INDEX_TOO_LARGE 102 +#define UI_R_INDEX_TOO_SMALL 103 +#define UI_R_NO_RESULT_BUFFER 105 +#define UI_R_RESULT_TOO_LARGE 100 +#define UI_R_RESULT_TOO_SMALL 101 +#define UI_R_UNKNOWN_CONTROL_COMMAND 106 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/ui_compat.h b/include/openssl/ui_compat.h new file mode 100755 index 0000000..0209438 --- /dev/null +++ b/include/openssl/ui_compat.h @@ -0,0 +1,83 @@ +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_COMPAT_H +#define HEADER_UI_COMPAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following functions were previously part of the DES section, + and are provided here for backward compatibility reasons. */ + +#define des_read_pw_string(b,l,p,v) \ + _ossl_old_des_read_pw_string((b),(l),(p),(v)) +#define des_read_pw(b,bf,s,p,v) \ + _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) + +int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); +int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/vssver.scc b/include/openssl/vssver.scc new file mode 100755 index 0000000..5a05a5f Binary files /dev/null and b/include/openssl/vssver.scc differ diff --git a/include/openssl/x509.h b/include/openssl/x509.h new file mode 100755 index 0000000..5e36aca --- /dev/null +++ b/include/openssl/x509.h @@ -0,0 +1,1344 @@ +/* crypto/x509/x509.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_X509_H +#define HEADER_X509_H + +#include +#include +#ifndef OPENSSL_NO_BUFFER +#include +#endif +#ifndef OPENSSL_NO_EVP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#include + +#ifndef OPENSSL_NO_EC +#include +#endif + +#ifndef OPENSSL_NO_ECDSA +#include +#endif + +#ifndef OPENSSL_NO_ECDH +#include +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#endif + +#ifndef OPENSSL_NO_SHA +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 these are defined in wincrypt.h */ +#undef X509_NAME +#undef X509_CERT_PAIR +#endif + +#define X509_FILETYPE_PEM 1 +#define X509_FILETYPE_ASN1 2 +#define X509_FILETYPE_DEFAULT 3 + +#define X509v3_KU_DIGITAL_SIGNATURE 0x0080 +#define X509v3_KU_NON_REPUDIATION 0x0040 +#define X509v3_KU_KEY_ENCIPHERMENT 0x0020 +#define X509v3_KU_DATA_ENCIPHERMENT 0x0010 +#define X509v3_KU_KEY_AGREEMENT 0x0008 +#define X509v3_KU_KEY_CERT_SIGN 0x0004 +#define X509v3_KU_CRL_SIGN 0x0002 +#define X509v3_KU_ENCIPHER_ONLY 0x0001 +#define X509v3_KU_DECIPHER_ONLY 0x8000 +#define X509v3_KU_UNDEF 0xffff + +typedef struct X509_objects_st + { + int nid; + int (*a2i)(void); + int (*i2a)(void); + } X509_OBJECTS; + +struct X509_algor_st + { + ASN1_OBJECT *algorithm; + ASN1_TYPE *parameter; + } /* X509_ALGOR */; + +DECLARE_STACK_OF(X509_ALGOR) +DECLARE_ASN1_SET_OF(X509_ALGOR) + +typedef struct X509_val_st + { + ASN1_TIME *notBefore; + ASN1_TIME *notAfter; + } X509_VAL; + +typedef struct X509_pubkey_st + { + X509_ALGOR *algor; + ASN1_BIT_STRING *public_key; + EVP_PKEY *pkey; + } X509_PUBKEY; + +typedef struct X509_sig_st + { + X509_ALGOR *algor; + ASN1_OCTET_STRING *digest; + } X509_SIG; + +typedef struct X509_name_entry_st + { + ASN1_OBJECT *object; + ASN1_STRING *value; + int set; + int size; /* temp variable */ + } X509_NAME_ENTRY; + +DECLARE_STACK_OF(X509_NAME_ENTRY) +DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) + +/* we always keep X509_NAMEs in 2 forms. */ +struct X509_name_st + { + STACK_OF(X509_NAME_ENTRY) *entries; + int modified; /* true if 'bytes' needs to be built */ +#ifndef OPENSSL_NO_BUFFER + BUF_MEM *bytes; +#else + char *bytes; +#endif + unsigned long hash; /* Keep the hash around for lookups */ + } /* X509_NAME */; + +DECLARE_STACK_OF(X509_NAME) + +#define X509_EX_V_NETSCAPE_HACK 0x8000 +#define X509_EX_V_INIT 0x0001 +typedef struct X509_extension_st + { + ASN1_OBJECT *object; + ASN1_BOOLEAN critical; + ASN1_OCTET_STRING *value; + } X509_EXTENSION; + +DECLARE_STACK_OF(X509_EXTENSION) +DECLARE_ASN1_SET_OF(X509_EXTENSION) + +/* a sequence of these are used */ +typedef struct x509_attributes_st + { + ASN1_OBJECT *object; + int single; /* 0 for a set, 1 for a single item (which is wrong) */ + union { + char *ptr; +/* 0 */ STACK_OF(ASN1_TYPE) *set; +/* 1 */ ASN1_TYPE *single; + } value; + } X509_ATTRIBUTE; + +DECLARE_STACK_OF(X509_ATTRIBUTE) +DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) + + +typedef struct X509_req_info_st + { + ASN1_ENCODING enc; + ASN1_INTEGER *version; + X509_NAME *subject; + X509_PUBKEY *pubkey; + /* d=2 hl=2 l= 0 cons: cont: 00 */ + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } X509_REQ_INFO; + +typedef struct X509_req_st + { + X509_REQ_INFO *req_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } X509_REQ; + +typedef struct x509_cinf_st + { + ASN1_INTEGER *version; /* [ 0 ] default of v1 */ + ASN1_INTEGER *serialNumber; + X509_ALGOR *signature; + X509_NAME *issuer; + X509_VAL *validity; + X509_NAME *subject; + X509_PUBKEY *key; + ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ + ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ + STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ + } X509_CINF; + +/* This stuff is certificate "auxiliary info" + * it contains details which are useful in certificate + * stores and databases. When used this is tagged onto + * the end of the certificate itself + */ + +typedef struct x509_cert_aux_st + { + STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ + STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ + ASN1_UTF8STRING *alias; /* "friendly name" */ + ASN1_OCTET_STRING *keyid; /* key id of private key */ + STACK_OF(X509_ALGOR) *other; /* other unspecified info */ + } X509_CERT_AUX; + +struct x509_st + { + X509_CINF *cert_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int valid; + int references; + char *name; + CRYPTO_EX_DATA ex_data; + /* These contain copies of various extension values */ + long ex_pathlen; + long ex_pcpathlen; + unsigned long ex_flags; + unsigned long ex_kusage; + unsigned long ex_xkusage; + unsigned long ex_nscert; + ASN1_OCTET_STRING *skid; + struct AUTHORITY_KEYID_st *akid; + X509_POLICY_CACHE *policy_cache; +#ifndef OPENSSL_NO_RFC3779 + STACK_OF(IPAddressFamily) *rfc3779_addr; + struct ASIdentifiers_st *rfc3779_asid; +#endif +#ifndef OPENSSL_NO_SHA + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; +#endif + X509_CERT_AUX *aux; + } /* X509 */; + +DECLARE_STACK_OF(X509) +DECLARE_ASN1_SET_OF(X509) + +/* This is used for a table of trust checking functions */ + +typedef struct x509_trust_st { + int trust; + int flags; + int (*check_trust)(struct x509_trust_st *, X509 *, int); + char *name; + int arg1; + void *arg2; +} X509_TRUST; + +DECLARE_STACK_OF(X509_TRUST) + +typedef struct x509_cert_pair_st { + X509 *forward; + X509 *reverse; +} X509_CERT_PAIR; + +/* standard trust ids */ + +#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */ + +#define X509_TRUST_COMPAT 1 +#define X509_TRUST_SSL_CLIENT 2 +#define X509_TRUST_SSL_SERVER 3 +#define X509_TRUST_EMAIL 4 +#define X509_TRUST_OBJECT_SIGN 5 +#define X509_TRUST_OCSP_SIGN 6 +#define X509_TRUST_OCSP_REQUEST 7 + +/* Keep these up to date! */ +#define X509_TRUST_MIN 1 +#define X509_TRUST_MAX 7 + + +/* trust_flags values */ +#define X509_TRUST_DYNAMIC 1 +#define X509_TRUST_DYNAMIC_NAME 2 + +/* check_trust return codes */ + +#define X509_TRUST_TRUSTED 1 +#define X509_TRUST_REJECTED 2 +#define X509_TRUST_UNTRUSTED 3 + +/* Flags for X509_print_ex() */ + +#define X509_FLAG_COMPAT 0 +#define X509_FLAG_NO_HEADER 1L +#define X509_FLAG_NO_VERSION (1L << 1) +#define X509_FLAG_NO_SERIAL (1L << 2) +#define X509_FLAG_NO_SIGNAME (1L << 3) +#define X509_FLAG_NO_ISSUER (1L << 4) +#define X509_FLAG_NO_VALIDITY (1L << 5) +#define X509_FLAG_NO_SUBJECT (1L << 6) +#define X509_FLAG_NO_PUBKEY (1L << 7) +#define X509_FLAG_NO_EXTENSIONS (1L << 8) +#define X509_FLAG_NO_SIGDUMP (1L << 9) +#define X509_FLAG_NO_AUX (1L << 10) +#define X509_FLAG_NO_ATTRIBUTES (1L << 11) + +/* Flags specific to X509_NAME_print_ex() */ + +/* The field separator information */ + +#define XN_FLAG_SEP_MASK (0xf << 16) + +#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */ +#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ +#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ +#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ +#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ + +#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ + +/* How the field name is shown */ + +#define XN_FLAG_FN_MASK (0x3 << 21) + +#define XN_FLAG_FN_SN 0 /* Object short name */ +#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ +#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ +#define XN_FLAG_FN_NONE (3 << 21) /* No field names */ + +#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ + +/* This determines if we dump fields we don't recognise: + * RFC2253 requires this. + */ + +#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) + +#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */ + +/* Complete set of RFC2253 flags */ + +#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ + XN_FLAG_SEP_COMMA_PLUS | \ + XN_FLAG_DN_REV | \ + XN_FLAG_FN_SN | \ + XN_FLAG_DUMP_UNKNOWN_FIELDS) + +/* readable oneline form */ + +#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ + ASN1_STRFLGS_ESC_QUOTE | \ + XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_SN) + +/* readable multiline form */ + +#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + XN_FLAG_SEP_MULTILINE | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_LN | \ + XN_FLAG_FN_ALIGN) + +typedef struct X509_revoked_st + { + ASN1_INTEGER *serialNumber; + ASN1_TIME *revocationDate; + STACK_OF(X509_EXTENSION) /* optional */ *extensions; + int sequence; /* load sequence */ + } X509_REVOKED; + +DECLARE_STACK_OF(X509_REVOKED) +DECLARE_ASN1_SET_OF(X509_REVOKED) + +typedef struct X509_crl_info_st + { + ASN1_INTEGER *version; + X509_ALGOR *sig_alg; + X509_NAME *issuer; + ASN1_TIME *lastUpdate; + ASN1_TIME *nextUpdate; + STACK_OF(X509_REVOKED) *revoked; + STACK_OF(X509_EXTENSION) /* [0] */ *extensions; + ASN1_ENCODING enc; + } X509_CRL_INFO; + +struct X509_crl_st + { + /* actual signature */ + X509_CRL_INFO *crl; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } /* X509_CRL */; + +DECLARE_STACK_OF(X509_CRL) +DECLARE_ASN1_SET_OF(X509_CRL) + +typedef struct private_key_st + { + int version; + /* The PKCS#8 data types */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + + /* When decrypted, the following will not be NULL */ + EVP_PKEY *dec_pkey; + + /* used to encrypt and decrypt */ + int key_length; + char *key_data; + int key_free; /* true if we should auto free key_data */ + + /* expanded version of 'enc_algor' */ + EVP_CIPHER_INFO cipher; + + int references; + } X509_PKEY; + +#ifndef OPENSSL_NO_EVP +typedef struct X509_info_st + { + X509 *x509; + X509_CRL *crl; + X509_PKEY *x_pkey; + + EVP_CIPHER_INFO enc_cipher; + int enc_len; + char *enc_data; + + int references; + } X509_INFO; + +DECLARE_STACK_OF(X509_INFO) +#endif + +/* The next 2 structures and their 8 routines were sent to me by + * Pat Richard and are used to manipulate + * Netscapes spki structures - useful if you are writing a CA web page + */ +typedef struct Netscape_spkac_st + { + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ + } NETSCAPE_SPKAC; + +typedef struct Netscape_spki_st + { + NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ + X509_ALGOR *sig_algor; + ASN1_BIT_STRING *signature; + } NETSCAPE_SPKI; + +/* Netscape certificate sequence structure */ +typedef struct Netscape_certificate_sequence + { + ASN1_OBJECT *type; + STACK_OF(X509) *certs; + } NETSCAPE_CERT_SEQUENCE; + +/* Unused (and iv length is wrong) +typedef struct CBCParameter_st + { + unsigned char iv[8]; + } CBC_PARAM; +*/ + +/* Password based encryption structure */ + +typedef struct PBEPARAM_st { +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; +} PBEPARAM; + +/* Password based encryption V2 structures */ + +typedef struct PBE2PARAM_st { +X509_ALGOR *keyfunc; +X509_ALGOR *encryption; +} PBE2PARAM; + +typedef struct PBKDF2PARAM_st { +ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ +ASN1_INTEGER *iter; +ASN1_INTEGER *keylength; +X509_ALGOR *prf; +} PBKDF2PARAM; + + +/* PKCS#8 private key info structure */ + +typedef struct pkcs8_priv_key_info_st + { + int broken; /* Flag for various broken formats */ +#define PKCS8_OK 0 +#define PKCS8_NO_OCTET 1 +#define PKCS8_EMBEDDED_PARAM 2 +#define PKCS8_NS_DB 3 + ASN1_INTEGER *version; + X509_ALGOR *pkeyalg; + ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ + STACK_OF(X509_ATTRIBUTE) *attributes; + } PKCS8_PRIV_KEY_INFO; + +#ifdef __cplusplus +} +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SSLEAY_MACROS +#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\ + a->signature,(char *)a->cert_info,r) +#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \ + a->sig_alg,a->signature,(char *)a->req_info,r) +#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \ + a->sig_alg, a->signature,(char *)a->crl,r) + +#define X509_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \ + x->sig_alg, x->signature, (char *)x->cert_info,pkey,md) +#define X509_REQ_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \ + x->signature, (char *)x->req_info,pkey,md) +#define X509_CRL_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \ + x->signature, (char *)x->crl,pkey,md) +#define NETSCAPE_SPKI_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \ + x->signature, (char *)x->spkac,pkey,md) + +#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \ + (char *(*)())d2i_X509,(char *)x509) +#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\ + (int (*)())i2d_X509_ATTRIBUTE, \ + (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa) +#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \ + (int (*)())i2d_X509_EXTENSION, \ + (char *(*)())d2i_X509_EXTENSION,(char *)ex) +#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)) +#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509) +#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) +#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) + +#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \ + (char *(*)())d2i_X509_CRL,(char *)crl) +#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\ + (unsigned char *)crl) +#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\ + (unsigned char *)crl) + +#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \ + (char *(*)())d2i_PKCS7,(char *)p7) +#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\ + (unsigned char *)p7) +#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\ + (unsigned char *)p7) + +#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \ + (char *(*)())d2i_X509_REQ,(char *)req) +#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\ + (unsigned char *)req) +#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\ + (unsigned char *)req) + +#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \ + (char *(*)())d2i_RSAPublicKey,(char *)rsa) +#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \ + (char *(*)())d2i_RSAPrivateKey,(char *)rsa) + +#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \ + (unsigned char *)rsa) + +#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \ + (unsigned char *)rsa) + +#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \ + (unsigned char *)dsa) +#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \ + (unsigned char *)dsa) + +#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \ + (unsigned char *)ecdsa) +#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \ + (unsigned char *)ecdsa) + +#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\ + (char *(*)())d2i_X509_ALGOR,(char *)xn) + +#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \ + (char *(*)())d2i_X509_NAME,(char *)xn) +#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \ + (int (*)())i2d_X509_NAME_ENTRY, \ + (char *(*)())d2i_X509_NAME_ENTRY,\ + (char *)ne) + +#define X509_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len) +#define X509_NAME_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len) +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +#define X509_EXT_PACK_UNKNOWN 1 +#define X509_EXT_PACK_STRING 2 + +#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) +/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ +#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) +#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) +#define X509_extract_key(x) X509_get_pubkey(x) /*****/ +#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) +#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) +#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) +#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) +#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) + +#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) +#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) +#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) +#define X509_CRL_get_issuer(x) ((x)->crl->issuer) +#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) + +/* This one is only used so that a binary form can output, as in + * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ +#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) + + +const char *X509_verify_cert_error_string(long n); + +#ifndef SSLEAY_MACROS +#ifndef OPENSSL_NO_EVP +int X509_verify(X509 *a, EVP_PKEY *r); + +int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); +int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); +int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); + +NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); +char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); +EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); +int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); + +int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); + +int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); + +int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); +int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); + +int X509_pubkey_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +#endif + +#ifndef OPENSSL_NO_FP_API +X509 *d2i_X509_fp(FILE *fp, X509 **x509); +int i2d_X509_fp(FILE *fp,X509 *x509); +X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); +int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); +int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); +int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); +int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); +DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); +int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); +int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); +int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); +int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); +int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); +int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); +#endif + +#ifndef OPENSSL_NO_BIO +X509 *d2i_X509_bio(BIO *bp,X509 **x509); +int i2d_X509_bio(BIO *bp,X509 *x509); +X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); +int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); +int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); +int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); +int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); +DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); +int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); +int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); +int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); +int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); +int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); +int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); +#endif + +X509 *X509_dup(X509 *x509); +X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); +X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); +X509_CRL *X509_CRL_dup(X509_CRL *crl); +X509_REQ *X509_REQ_dup(X509_REQ *req); +X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); +X509_NAME *X509_NAME_dup(X509_NAME *xn); +X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); + +#endif /* !SSLEAY_MACROS */ + +int X509_cmp_time(ASN1_TIME *s, time_t *t); +int X509_cmp_current_time(ASN1_TIME *s); +ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); +ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); + +const char * X509_get_default_cert_area(void ); +const char * X509_get_default_cert_dir(void ); +const char * X509_get_default_cert_file(void ); +const char * X509_get_default_cert_dir_env(void ); +const char * X509_get_default_cert_file_env(void ); +const char * X509_get_default_private_dir(void ); + +X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); + +DECLARE_ASN1_FUNCTIONS(X509_ALGOR) +DECLARE_ASN1_FUNCTIONS(X509_VAL) + +DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) + +int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); +EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); +int X509_get_pubkey_parameters(EVP_PKEY *pkey, + STACK_OF(X509) *chain); +int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp); +EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp, + long length); +#ifndef OPENSSL_NO_RSA +int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp); +RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_DSA +int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp); +DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_EC +int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); +EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, + long length); +#endif + +DECLARE_ASN1_FUNCTIONS(X509_SIG) +DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) +DECLARE_ASN1_FUNCTIONS(X509_REQ) + +DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) +X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); + +DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) + +DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) + +DECLARE_ASN1_FUNCTIONS(X509_NAME) + +int X509_NAME_set(X509_NAME **xn, X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(X509_CINF) + +DECLARE_ASN1_FUNCTIONS(X509) +DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) + +DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR) + +int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_set_ex_data(X509 *r, int idx, void *arg); +void *X509_get_ex_data(X509 *r, int idx); +int i2d_X509_AUX(X509 *a,unsigned char **pp); +X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); + +int X509_alias_set1(X509 *x, unsigned char *name, int len); +int X509_keyid_set1(X509 *x, unsigned char *id, int len); +unsigned char * X509_alias_get0(X509 *x, int *len); +unsigned char * X509_keyid_get0(X509 *x, int *len); +int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); +int X509_TRUST_set(int *t, int trust); +int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); +int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); +void X509_trust_clear(X509 *x); +void X509_reject_clear(X509 *x); + +DECLARE_ASN1_FUNCTIONS(X509_REVOKED) +DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) +DECLARE_ASN1_FUNCTIONS(X509_CRL) + +int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); + +X509_PKEY * X509_PKEY_new(void ); +void X509_PKEY_free(X509_PKEY *a); +int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); +X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) + +#ifndef OPENSSL_NO_EVP +X509_INFO * X509_INFO_new(void); +void X509_INFO_free(X509_INFO *a); +char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); + +int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); + +int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data, + unsigned char *md,unsigned int *len); + +int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + char *data,EVP_PKEY *pkey, const EVP_MD *type); + +int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, + unsigned char *md,unsigned int *len); + +int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey); + +int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, + void *data, EVP_PKEY *pkey, const EVP_MD *type); +#endif + +int X509_set_version(X509 *x,long version); +int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); +ASN1_INTEGER * X509_get_serialNumber(X509 *x); +int X509_set_issuer_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_issuer_name(X509 *a); +int X509_set_subject_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_subject_name(X509 *a); +int X509_set_notBefore(X509 *x, ASN1_TIME *tm); +int X509_set_notAfter(X509 *x, ASN1_TIME *tm); +int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); +EVP_PKEY * X509_get_pubkey(X509 *x); +ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); +int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); + +int X509_REQ_set_version(X509_REQ *x,long version); +int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); +int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); +EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); +int X509_REQ_extension_nid(int nid); +int * X509_REQ_get_extension_nids(void); +void X509_REQ_set_extension_nids(int *nids); +STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); +int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, + int nid); +int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); +int X509_REQ_get_attr_count(const X509_REQ *req); +int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, + int lastpos); +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); +X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); +int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); +int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_NID(X509_REQ *req, + int nid, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_txt(X509_REQ *req, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_CRL_set_version(X509_CRL *x, long version); +int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); +int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_sort(X509_CRL *crl); + +int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); +int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); + +int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); + +int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); + +int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_and_serial_hash(X509 *a); + +int X509_issuer_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_name_hash(X509 *a); + +int X509_subject_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_subject_name_hash(X509 *x); + +int X509_cmp(const X509 *a, const X509 *b); +int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); +unsigned long X509_NAME_hash(X509_NAME *x); + +int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); +#ifndef OPENSSL_NO_FP_API +int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print_fp(FILE *bp,X509 *x); +int X509_CRL_print_fp(FILE *bp,X509_CRL *x); +int X509_REQ_print_fp(FILE *bp,X509_REQ *req); +int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); +#endif + +#ifndef OPENSSL_NO_BIO +int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); +int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); +int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print(BIO *bp,X509 *x); +int X509_ocspid_print(BIO *bp,X509 *x); +int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); +int X509_CRL_print(BIO *bp,X509_CRL *x); +int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); +int X509_REQ_print(BIO *bp,X509_REQ *req); +#endif + +int X509_NAME_entry_count(X509_NAME *name); +int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, + char *buf,int len); +int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, + char *buf,int len); + +/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use + * lastpos, search after that position on. */ +int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); +int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, + int lastpos); +X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); +X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); +int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, + int loc, int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, + unsigned char *bytes, int len, int loc, int set); +int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, + unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, + const char *field, int type, const unsigned char *bytes, int len); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, + int type,unsigned char *bytes, int len); +int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, + const unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, + ASN1_OBJECT *obj, int type,const unsigned char *bytes, + int len); +int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, + ASN1_OBJECT *obj); +int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, + const unsigned char *bytes, int len); +ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); +ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); + +int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); +int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, + int nid, int lastpos); +int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, + ASN1_OBJECT *obj,int lastpos); +int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, + int crit, int lastpos); +X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); +X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); +STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, + X509_EXTENSION *ex, int loc); + +int X509_get_ext_count(X509 *x); +int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); +int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); +int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); +X509_EXTENSION *X509_get_ext(X509 *x, int loc); +X509_EXTENSION *X509_delete_ext(X509 *x, int loc); +int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); +void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); +int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_CRL_get_ext_count(X509_CRL *x); +int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); +int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); +int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); +X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); +X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); +int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); +void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_REVOKED_get_ext_count(X509_REVOKED *x); +int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); +int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); +int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); +X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); +X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); +int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); +void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, + unsigned long flags); + +X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, + int nid, int crit, ASN1_OCTET_STRING *data); +X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, + ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); +int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); +int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); +int X509_EXTENSION_set_data(X509_EXTENSION *ex, + ASN1_OCTET_STRING *data); +ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); +ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); +int X509_EXTENSION_get_critical(X509_EXTENSION *ex); + +int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); +int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, + int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); +X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, + X509_ATTRIBUTE *attr); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, + int nid, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, + const char *attrname, int type, + const unsigned char *bytes, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, + int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, + const ASN1_OBJECT *obj, int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, + const char *atrname, int type, const unsigned char *bytes, int len); +int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); +int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); +void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, + int atrtype, void *data); +int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); +ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); +ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); + +int EVP_PKEY_get_attr_count(const EVP_PKEY *key); +int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, + int lastpos); +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); +X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); +int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); +int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, + int nid, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_verify_cert(X509_STORE_CTX *ctx); + +/* lookup a cert from a X509 STACK */ +X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, + ASN1_INTEGER *serial); +X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(PBEPARAM) +DECLARE_ASN1_FUNCTIONS(PBE2PARAM) +DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) + +X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen); + +/* PKCS#8 utilities */ + +DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) + +EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); +PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); + +int X509_check_trust(X509 *x, int id, int flags); +int X509_TRUST_get_count(void); +X509_TRUST * X509_TRUST_get0(int idx); +int X509_TRUST_get_by_id(int id); +int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), + char *name, int arg1, void *arg2); +void X509_TRUST_cleanup(void); +int X509_TRUST_get_flags(X509_TRUST *xp); +char *X509_TRUST_get0_name(X509_TRUST *xp); +int X509_TRUST_get_trust(X509_TRUST *xp); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509_strings(void); + +/* Error codes for the X509 functions. */ + +/* Function codes. */ +#define X509_F_ADD_CERT_DIR 100 +#define X509_F_BY_FILE_CTRL 101 +#define X509_F_CHECK_POLICY 145 +#define X509_F_DIR_CTRL 102 +#define X509_F_GET_CERT_BY_SUBJECT 103 +#define X509_F_NETSCAPE_SPKI_B64_DECODE 129 +#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 +#define X509_F_X509AT_ADD1_ATTR 135 +#define X509_F_X509V3_ADD_EXT 104 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 +#define X509_F_X509_ATTRIBUTE_GET0_DATA 139 +#define X509_F_X509_ATTRIBUTE_SET1_DATA 138 +#define X509_F_X509_CHECK_PRIVATE_KEY 128 +#define X509_F_X509_CRL_PRINT_FP 147 +#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 +#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 +#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 +#define X509_F_X509_LOAD_CERT_CRL_FILE 132 +#define X509_F_X509_LOAD_CERT_FILE 111 +#define X509_F_X509_LOAD_CRL_FILE 112 +#define X509_F_X509_NAME_ADD_ENTRY 113 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 +#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 +#define X509_F_X509_NAME_ONELINE 116 +#define X509_F_X509_NAME_PRINT 117 +#define X509_F_X509_PRINT_EX_FP 118 +#define X509_F_X509_PUBKEY_GET 119 +#define X509_F_X509_PUBKEY_SET 120 +#define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 +#define X509_F_X509_REQ_PRINT_EX 121 +#define X509_F_X509_REQ_PRINT_FP 122 +#define X509_F_X509_REQ_TO_X509 123 +#define X509_F_X509_STORE_ADD_CERT 124 +#define X509_F_X509_STORE_ADD_CRL 125 +#define X509_F_X509_STORE_CTX_GET1_ISSUER 146 +#define X509_F_X509_STORE_CTX_INIT 143 +#define X509_F_X509_STORE_CTX_NEW 142 +#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 +#define X509_F_X509_TO_X509_REQ 126 +#define X509_F_X509_TRUST_ADD 133 +#define X509_F_X509_TRUST_SET 141 +#define X509_F_X509_VERIFY_CERT 127 + +/* Reason codes. */ +#define X509_R_BAD_X509_FILETYPE 100 +#define X509_R_BASE64_DECODE_ERROR 118 +#define X509_R_CANT_CHECK_DH_KEY 114 +#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +#define X509_R_ERR_ASN1_LIB 102 +#define X509_R_INVALID_DIRECTORY 113 +#define X509_R_INVALID_FIELD_NAME 119 +#define X509_R_INVALID_TRUST 123 +#define X509_R_KEY_TYPE_MISMATCH 115 +#define X509_R_KEY_VALUES_MISMATCH 116 +#define X509_R_LOADING_CERT_DIR 103 +#define X509_R_LOADING_DEFAULTS 104 +#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +#define X509_R_SHOULD_RETRY 106 +#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +#define X509_R_UNKNOWN_KEY_TYPE 117 +#define X509_R_UNKNOWN_NID 109 +#define X509_R_UNKNOWN_PURPOSE_ID 121 +#define X509_R_UNKNOWN_TRUST_ID 120 +#define X509_R_UNSUPPORTED_ALGORITHM 111 +#define X509_R_WRONG_LOOKUP_TYPE 112 +#define X509_R_WRONG_TYPE 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/openssl/x509_vfy.h b/include/openssl/x509_vfy.h new file mode 100755 index 0000000..09c3191 --- /dev/null +++ b/include/openssl/x509_vfy.h @@ -0,0 +1,531 @@ +/* crypto/x509/x509_vfy.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_X509_H +#include +/* openssl/x509.h ends up #include-ing this file at about the only + * appropriate moment. */ +#endif + +#ifndef HEADER_X509_VFY_H +#define HEADER_X509_VFY_H + +#include +#ifndef OPENSSL_NO_LHASH +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Outer object */ +typedef struct x509_hash_dir_st + { + int num_dirs; + char **dirs; + int *dirs_type; + int num_dirs_alloced; + } X509_HASH_DIR_CTX; + +typedef struct x509_file_st + { + int num_paths; /* number of paths to files or directories */ + int num_alloced; + char **paths; /* the list of paths or directories */ + int *path_type; + } X509_CERT_FILE_CTX; + +/*******************************/ +/* +SSL_CTX -> X509_STORE + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + +SSL -> X509_STORE_CTX + ->X509_STORE + +The X509_STORE holds the tables etc for verification stuff. +A X509_STORE_CTX is used while validating a single certificate. +The X509_STORE has X509_LOOKUPs for looking up certs. +The X509_STORE then calls a function to actually verify the +certificate chain. +*/ + +#define X509_LU_RETRY -1 +#define X509_LU_FAIL 0 +#define X509_LU_X509 1 +#define X509_LU_CRL 2 +#define X509_LU_PKEY 3 + +typedef struct x509_object_st + { + /* one of the above types */ + int type; + union { + char *ptr; + X509 *x509; + X509_CRL *crl; + EVP_PKEY *pkey; + } data; + } X509_OBJECT; + +typedef struct x509_lookup_st X509_LOOKUP; + +DECLARE_STACK_OF(X509_LOOKUP) +DECLARE_STACK_OF(X509_OBJECT) + +/* This is a static that defines the function interface */ +typedef struct x509_lookup_method_st + { + const char *name; + int (*new_item)(X509_LOOKUP *ctx); + void (*free)(X509_LOOKUP *ctx); + int (*init)(X509_LOOKUP *ctx); + int (*shutdown)(X509_LOOKUP *ctx); + int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, + char **ret); + int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, + X509_OBJECT *ret); + int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, + ASN1_INTEGER *serial,X509_OBJECT *ret); + int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, + unsigned char *bytes,int len, + X509_OBJECT *ret); + int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, + X509_OBJECT *ret); + } X509_LOOKUP_METHOD; + +/* This structure hold all parameters associated with a verify operation + * by including an X509_VERIFY_PARAM structure in related structures the + * parameters used can be customized + */ + +typedef struct X509_VERIFY_PARAM_st + { + char *name; + time_t check_time; /* Time to use */ + unsigned long inh_flags; /* Inheritance flags */ + unsigned long flags; /* Various verify flags */ + int purpose; /* purpose to check untrusted certificates */ + int trust; /* trust setting to check */ + int depth; /* Verify depth */ + STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ + } X509_VERIFY_PARAM; + +DECLARE_STACK_OF(X509_VERIFY_PARAM) + +/* This is used to hold everything. It is used for all certificate + * validation. Once we have a certificate chain, the 'verify' + * function is then called to actually check the cert chain. */ +struct x509_store_st + { + /* The following is a cache of trusted certs */ + int cache; /* if true, stash any hits */ + STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ + + /* These are external lookup methods */ + STACK_OF(X509_LOOKUP) *get_cert_methods; + + X509_VERIFY_PARAM *param; + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*cleanup)(X509_STORE_CTX *ctx); + + CRYPTO_EX_DATA ex_data; + int references; + } /* X509_STORE */; + +int X509_STORE_set_depth(X509_STORE *store, int depth); + +#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) +#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) + +/* This is the functions plus an instance of the local variables. */ +struct x509_lookup_st + { + int init; /* have we been started */ + int skip; /* don't use us. */ + X509_LOOKUP_METHOD *method; /* the functions */ + char *method_data; /* method data */ + + X509_STORE *store_ctx; /* who owns us */ + } /* X509_LOOKUP */; + +/* This is a used when verifying cert chains. Since the + * gathering of the cert chain can take some time (and have to be + * 'retried', this needs to be kept and passed around. */ +struct x509_store_ctx_st /* X509_STORE_CTX */ + { + X509_STORE *ctx; + int current_method; /* used when looking up certs */ + + /* The following are set by the caller */ + X509 *cert; /* The cert to check */ + STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ + STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ + + X509_VERIFY_PARAM *param; + void *other_ctx; /* Other info for use with get_issuer() */ + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*check_policy)(X509_STORE_CTX *ctx); + int (*cleanup)(X509_STORE_CTX *ctx); + + /* The following is built up */ + int valid; /* if 0, rebuild chain */ + int last_untrusted; /* index of last untrusted cert */ + STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ + X509_POLICY_TREE *tree; /* Valid policy tree */ + + int explicit_policy; /* Require explicit policy value */ + + /* When something goes wrong, this is why */ + int error_depth; + int error; + X509 *current_cert; + X509 *current_issuer; /* cert currently being tested as valid issuer */ + X509_CRL *current_crl; /* current CRL */ + + CRYPTO_EX_DATA ex_data; + } /* X509_STORE_CTX */; + +void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); + +#define X509_STORE_CTX_set_app_data(ctx,data) \ + X509_STORE_CTX_set_ex_data(ctx,0,data) +#define X509_STORE_CTX_get_app_data(ctx) \ + X509_STORE_CTX_get_ex_data(ctx,0) + +#define X509_L_FILE_LOAD 1 +#define X509_L_ADD_DIR 2 + +#define X509_LOOKUP_load_file(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) + +#define X509_LOOKUP_add_dir(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) + +#define X509_V_OK 0 +/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ + +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 +#define X509_V_ERR_UNABLE_TO_GET_CRL 3 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 +#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 +#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 +#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 +#define X509_V_ERR_CERT_NOT_YET_VALID 9 +#define X509_V_ERR_CERT_HAS_EXPIRED 10 +#define X509_V_ERR_CRL_NOT_YET_VALID 11 +#define X509_V_ERR_CRL_HAS_EXPIRED 12 +#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 +#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 +#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 +#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 +#define X509_V_ERR_OUT_OF_MEM 17 +#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 +#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 +#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 +#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 +#define X509_V_ERR_CERT_REVOKED 23 +#define X509_V_ERR_INVALID_CA 24 +#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 +#define X509_V_ERR_INVALID_PURPOSE 26 +#define X509_V_ERR_CERT_UNTRUSTED 27 +#define X509_V_ERR_CERT_REJECTED 28 +/* These are 'informational' when looking for issuer cert */ +#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 +#define X509_V_ERR_AKID_SKID_MISMATCH 30 +#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 +#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 + +#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 +#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 +#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 +#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 +#define X509_V_ERR_INVALID_NON_CA 37 +#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 +#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 +#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 + +#define X509_V_ERR_INVALID_EXTENSION 41 +#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 +#define X509_V_ERR_NO_EXPLICIT_POLICY 43 + +#define X509_V_ERR_UNNESTED_RESOURCE 44 + +/* The application is not happy */ +#define X509_V_ERR_APPLICATION_VERIFICATION 50 + +/* Certificate verify flags */ + +/* Send issuer+subject checks to verify_cb */ +#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 +/* Use check time instead of current time */ +#define X509_V_FLAG_USE_CHECK_TIME 0x2 +/* Lookup CRLs */ +#define X509_V_FLAG_CRL_CHECK 0x4 +/* Lookup CRLs for whole chain */ +#define X509_V_FLAG_CRL_CHECK_ALL 0x8 +/* Ignore unhandled critical extensions */ +#define X509_V_FLAG_IGNORE_CRITICAL 0x10 +/* Disable workarounds for broken certificates */ +#define X509_V_FLAG_X509_STRICT 0x20 +/* Enable proxy certificate validation */ +#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 +/* Enable policy checking */ +#define X509_V_FLAG_POLICY_CHECK 0x80 +/* Policy variable require-explicit-policy */ +#define X509_V_FLAG_EXPLICIT_POLICY 0x100 +/* Policy variable inhibit-any-policy */ +#define X509_V_FLAG_INHIBIT_ANY 0x200 +/* Policy variable inhibit-policy-mapping */ +#define X509_V_FLAG_INHIBIT_MAP 0x400 +/* Notify callback that policy is OK */ +#define X509_V_FLAG_NOTIFY_POLICY 0x800 + +#define X509_VP_FLAG_DEFAULT 0x1 +#define X509_VP_FLAG_OVERWRITE 0x2 +#define X509_VP_FLAG_RESET_FLAGS 0x4 +#define X509_VP_FLAG_LOCKED 0x8 +#define X509_VP_FLAG_ONCE 0x10 + +/* Internal use: mask of policy related options */ +#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ + | X509_V_FLAG_EXPLICIT_POLICY \ + | X509_V_FLAG_INHIBIT_ANY \ + | X509_V_FLAG_INHIBIT_MAP) + +int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, + X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); +void X509_OBJECT_up_ref_count(X509_OBJECT *a); +void X509_OBJECT_free_contents(X509_OBJECT *a); +X509_STORE *X509_STORE_new(void ); +void X509_STORE_free(X509_STORE *v); + +int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); +int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); +int X509_STORE_set_trust(X509_STORE *ctx, int trust); +int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); + +X509_STORE_CTX *X509_STORE_CTX_new(void); + +int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + +void X509_STORE_CTX_free(X509_STORE_CTX *ctx); +int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, + X509 *x509, STACK_OF(X509) *chain); +void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); +void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); + +X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); + +X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); +X509_LOOKUP_METHOD *X509_LOOKUP_file(void); + +int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); +int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); + +int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name, + X509_OBJECT *ret); + +int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); + +#ifndef OPENSSL_NO_STDIO +int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); +#endif + + +X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); +void X509_LOOKUP_free(X509_LOOKUP *ctx); +int X509_LOOKUP_init(X509_LOOKUP *ctx); +int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, + X509_OBJECT *ret); +int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, + ASN1_INTEGER *serial, X509_OBJECT *ret); +int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, + unsigned char *bytes, int len, X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, + int len, X509_OBJECT *ret); +int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); + +#ifndef OPENSSL_NO_STDIO +int X509_STORE_load_locations (X509_STORE *ctx, + const char *file, const char *dir); +int X509_STORE_set_default_paths(X509_STORE *ctx); +#endif + +int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); +void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); +int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); +int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); +X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); +void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); +void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); +int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); +int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); +int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, + int purpose, int trust); +void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); +void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, + time_t t); +void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, + int (*verify_cb)(int, X509_STORE_CTX *)); + +X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); +int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); + +X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); +int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); + +/* X509_VERIFY_PARAM functions */ + +X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); +void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); +int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); +int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, + unsigned long flags); +unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); +int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); +void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); +void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); +int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, + ASN1_OBJECT *policy); +int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, + STACK_OF(ASN1_OBJECT) *policies); +int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); + +int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); +const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); +void X509_VERIFY_PARAM_table_cleanup(void); + +int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, + STACK_OF(X509) *certs, + STACK_OF(ASN1_OBJECT) *policy_oids, + unsigned int flags); + +void X509_policy_tree_free(X509_POLICY_TREE *tree); + +int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); +X509_POLICY_LEVEL * + X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); + +int X509_policy_level_node_count(X509_POLICY_LEVEL *level); + +X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); + +const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); + +STACK_OF(POLICYQUALINFO) * + X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); +const X509_POLICY_NODE * + X509_policy_node_get0_parent(const X509_POLICY_NODE *node); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/include/openssl/x509v3.h b/include/openssl/x509v3.h new file mode 100755 index 0000000..0a84264 --- /dev/null +++ b/include/openssl/x509v3.h @@ -0,0 +1,919 @@ +/* x509v3.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_X509V3_H +#define HEADER_X509V3_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward reference */ +struct v3_ext_method; +struct v3_ext_ctx; + +/* Useful typedefs */ + +typedef void * (*X509V3_EXT_NEW)(void); +typedef void (*X509V3_EXT_FREE)(void *); +typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); +typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); +typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); +typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); +typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); +typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); +typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); +typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); + +/* V3 extension structure */ + +struct v3_ext_method { +int ext_nid; +int ext_flags; +/* If this is set the following four fields are ignored */ +ASN1_ITEM_EXP *it; +/* Old style ASN1 calls */ +X509V3_EXT_NEW ext_new; +X509V3_EXT_FREE ext_free; +X509V3_EXT_D2I d2i; +X509V3_EXT_I2D i2d; + +/* The following pair is used for string extensions */ +X509V3_EXT_I2S i2s; +X509V3_EXT_S2I s2i; + +/* The following pair is used for multi-valued extensions */ +X509V3_EXT_I2V i2v; +X509V3_EXT_V2I v2i; + +/* The following are used for raw extensions */ +X509V3_EXT_I2R i2r; +X509V3_EXT_R2I r2i; + +void *usr_data; /* Any extension specific data */ +}; + +typedef struct X509V3_CONF_METHOD_st { +char * (*get_string)(void *db, char *section, char *value); +STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); +void (*free_string)(void *db, char * string); +void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); +} X509V3_CONF_METHOD; + +/* Context specific info */ +struct v3_ext_ctx { +#define CTX_TEST 0x1 +int flags; +X509 *issuer_cert; +X509 *subject_cert; +X509_REQ *subject_req; +X509_CRL *crl; +X509V3_CONF_METHOD *db_meth; +void *db; +/* Maybe more here */ +}; + +typedef struct v3_ext_method X509V3_EXT_METHOD; + +DECLARE_STACK_OF(X509V3_EXT_METHOD) + +/* ext_flags values */ +#define X509V3_EXT_DYNAMIC 0x1 +#define X509V3_EXT_CTX_DEP 0x2 +#define X509V3_EXT_MULTILINE 0x4 + +typedef BIT_STRING_BITNAME ENUMERATED_NAMES; + +typedef struct BASIC_CONSTRAINTS_st { +int ca; +ASN1_INTEGER *pathlen; +} BASIC_CONSTRAINTS; + + +typedef struct PKEY_USAGE_PERIOD_st { +ASN1_GENERALIZEDTIME *notBefore; +ASN1_GENERALIZEDTIME *notAfter; +} PKEY_USAGE_PERIOD; + +typedef struct otherName_st { +ASN1_OBJECT *type_id; +ASN1_TYPE *value; +} OTHERNAME; + +typedef struct EDIPartyName_st { + ASN1_STRING *nameAssigner; + ASN1_STRING *partyName; +} EDIPARTYNAME; + +typedef struct GENERAL_NAME_st { + +#define GEN_OTHERNAME 0 +#define GEN_EMAIL 1 +#define GEN_DNS 2 +#define GEN_X400 3 +#define GEN_DIRNAME 4 +#define GEN_EDIPARTY 5 +#define GEN_URI 6 +#define GEN_IPADD 7 +#define GEN_RID 8 + +int type; +union { + char *ptr; + OTHERNAME *otherName; /* otherName */ + ASN1_IA5STRING *rfc822Name; + ASN1_IA5STRING *dNSName; + ASN1_TYPE *x400Address; + X509_NAME *directoryName; + EDIPARTYNAME *ediPartyName; + ASN1_IA5STRING *uniformResourceIdentifier; + ASN1_OCTET_STRING *iPAddress; + ASN1_OBJECT *registeredID; + + /* Old names */ + ASN1_OCTET_STRING *ip; /* iPAddress */ + X509_NAME *dirn; /* dirn */ + ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ + ASN1_OBJECT *rid; /* registeredID */ + ASN1_TYPE *other; /* x400Address */ +} d; +} GENERAL_NAME; + +typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; + +typedef struct ACCESS_DESCRIPTION_st { + ASN1_OBJECT *method; + GENERAL_NAME *location; +} ACCESS_DESCRIPTION; + +typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; + +typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; + +DECLARE_STACK_OF(GENERAL_NAME) +DECLARE_ASN1_SET_OF(GENERAL_NAME) + +DECLARE_STACK_OF(ACCESS_DESCRIPTION) +DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) + +typedef struct DIST_POINT_NAME_st { +int type; +union { + GENERAL_NAMES *fullname; + STACK_OF(X509_NAME_ENTRY) *relativename; +} name; +} DIST_POINT_NAME; + +typedef struct DIST_POINT_st { +DIST_POINT_NAME *distpoint; +ASN1_BIT_STRING *reasons; +GENERAL_NAMES *CRLissuer; +} DIST_POINT; + +typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; + +DECLARE_STACK_OF(DIST_POINT) +DECLARE_ASN1_SET_OF(DIST_POINT) + +typedef struct AUTHORITY_KEYID_st { +ASN1_OCTET_STRING *keyid; +GENERAL_NAMES *issuer; +ASN1_INTEGER *serial; +} AUTHORITY_KEYID; + +/* Strong extranet structures */ + +typedef struct SXNET_ID_st { + ASN1_INTEGER *zone; + ASN1_OCTET_STRING *user; +} SXNETID; + +DECLARE_STACK_OF(SXNETID) +DECLARE_ASN1_SET_OF(SXNETID) + +typedef struct SXNET_st { + ASN1_INTEGER *version; + STACK_OF(SXNETID) *ids; +} SXNET; + +typedef struct NOTICEREF_st { + ASN1_STRING *organization; + STACK_OF(ASN1_INTEGER) *noticenos; +} NOTICEREF; + +typedef struct USERNOTICE_st { + NOTICEREF *noticeref; + ASN1_STRING *exptext; +} USERNOTICE; + +typedef struct POLICYQUALINFO_st { + ASN1_OBJECT *pqualid; + union { + ASN1_IA5STRING *cpsuri; + USERNOTICE *usernotice; + ASN1_TYPE *other; + } d; +} POLICYQUALINFO; + +DECLARE_STACK_OF(POLICYQUALINFO) +DECLARE_ASN1_SET_OF(POLICYQUALINFO) + +typedef struct POLICYINFO_st { + ASN1_OBJECT *policyid; + STACK_OF(POLICYQUALINFO) *qualifiers; +} POLICYINFO; + +typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; + +DECLARE_STACK_OF(POLICYINFO) +DECLARE_ASN1_SET_OF(POLICYINFO) + +typedef struct POLICY_MAPPING_st { + ASN1_OBJECT *issuerDomainPolicy; + ASN1_OBJECT *subjectDomainPolicy; +} POLICY_MAPPING; + +DECLARE_STACK_OF(POLICY_MAPPING) + +typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; + +typedef struct GENERAL_SUBTREE_st { + GENERAL_NAME *base; + ASN1_INTEGER *minimum; + ASN1_INTEGER *maximum; +} GENERAL_SUBTREE; + +DECLARE_STACK_OF(GENERAL_SUBTREE) + +typedef struct NAME_CONSTRAINTS_st { + STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; + STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; +} NAME_CONSTRAINTS; + +typedef struct POLICY_CONSTRAINTS_st { + ASN1_INTEGER *requireExplicitPolicy; + ASN1_INTEGER *inhibitPolicyMapping; +} POLICY_CONSTRAINTS; + +/* Proxy certificate structures, see RFC 3820 */ +typedef struct PROXY_POLICY_st + { + ASN1_OBJECT *policyLanguage; + ASN1_OCTET_STRING *policy; + } PROXY_POLICY; + +typedef struct PROXY_CERT_INFO_EXTENSION_st + { + ASN1_INTEGER *pcPathLengthConstraint; + PROXY_POLICY *proxyPolicy; + } PROXY_CERT_INFO_EXTENSION; + +DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) +DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) + + +#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ +",name:", val->name, ",value:", val->value); + +#define X509V3_set_ctx_test(ctx) \ + X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) +#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; + +#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ + 0,0,0,0, \ + 0,0, \ + (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ + (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ + NULL, NULL, \ + table} + +#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ + 0,0,0,0, \ + (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ + 0,0,0,0, \ + NULL} + +#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + + +/* X509_PURPOSE stuff */ + +#define EXFLAG_BCONS 0x1 +#define EXFLAG_KUSAGE 0x2 +#define EXFLAG_XKUSAGE 0x4 +#define EXFLAG_NSCERT 0x8 + +#define EXFLAG_CA 0x10 +#define EXFLAG_SS 0x20 +#define EXFLAG_V1 0x40 +#define EXFLAG_INVALID 0x80 +#define EXFLAG_SET 0x100 +#define EXFLAG_CRITICAL 0x200 +#define EXFLAG_PROXY 0x400 + +#define EXFLAG_INVALID_POLICY 0x400 + +#define KU_DIGITAL_SIGNATURE 0x0080 +#define KU_NON_REPUDIATION 0x0040 +#define KU_KEY_ENCIPHERMENT 0x0020 +#define KU_DATA_ENCIPHERMENT 0x0010 +#define KU_KEY_AGREEMENT 0x0008 +#define KU_KEY_CERT_SIGN 0x0004 +#define KU_CRL_SIGN 0x0002 +#define KU_ENCIPHER_ONLY 0x0001 +#define KU_DECIPHER_ONLY 0x8000 + +#define NS_SSL_CLIENT 0x80 +#define NS_SSL_SERVER 0x40 +#define NS_SMIME 0x20 +#define NS_OBJSIGN 0x10 +#define NS_SSL_CA 0x04 +#define NS_SMIME_CA 0x02 +#define NS_OBJSIGN_CA 0x01 +#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) + +#define XKU_SSL_SERVER 0x1 +#define XKU_SSL_CLIENT 0x2 +#define XKU_SMIME 0x4 +#define XKU_CODE_SIGN 0x8 +#define XKU_SGC 0x10 +#define XKU_OCSP_SIGN 0x20 +#define XKU_TIMESTAMP 0x40 +#define XKU_DVCS 0x80 + +#define X509_PURPOSE_DYNAMIC 0x1 +#define X509_PURPOSE_DYNAMIC_NAME 0x2 + +typedef struct x509_purpose_st { + int purpose; + int trust; /* Default trust ID */ + int flags; + int (*check_purpose)(const struct x509_purpose_st *, + const X509 *, int); + char *name; + char *sname; + void *usr_data; +} X509_PURPOSE; + +#define X509_PURPOSE_SSL_CLIENT 1 +#define X509_PURPOSE_SSL_SERVER 2 +#define X509_PURPOSE_NS_SSL_SERVER 3 +#define X509_PURPOSE_SMIME_SIGN 4 +#define X509_PURPOSE_SMIME_ENCRYPT 5 +#define X509_PURPOSE_CRL_SIGN 6 +#define X509_PURPOSE_ANY 7 +#define X509_PURPOSE_OCSP_HELPER 8 + +#define X509_PURPOSE_MIN 1 +#define X509_PURPOSE_MAX 8 + +/* Flags for X509V3_EXT_print() */ + +#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) +/* Return error for unknown extensions */ +#define X509V3_EXT_DEFAULT 0 +/* Print error for unknown extensions */ +#define X509V3_EXT_ERROR_UNKNOWN (1L << 16) +/* ASN1 parse unknown extensions */ +#define X509V3_EXT_PARSE_UNKNOWN (2L << 16) +/* BIO_dump unknown extensions */ +#define X509V3_EXT_DUMP_UNKNOWN (3L << 16) + +/* Flags for X509V3_add1_i2d */ + +#define X509V3_ADD_OP_MASK 0xfL +#define X509V3_ADD_DEFAULT 0L +#define X509V3_ADD_APPEND 1L +#define X509V3_ADD_REPLACE 2L +#define X509V3_ADD_REPLACE_EXISTING 3L +#define X509V3_ADD_KEEP_EXISTING 4L +#define X509V3_ADD_DELETE 5L +#define X509V3_ADD_SILENT 0x10 + +DECLARE_STACK_OF(X509_PURPOSE) + +DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) + +DECLARE_ASN1_FUNCTIONS(SXNET) +DECLARE_ASN1_FUNCTIONS(SXNETID) + +int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); + +ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); +ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); +ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); + +DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) + +DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) + + +ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); +STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + ASN1_BIT_STRING *bits, + STACK_OF(CONF_VALUE) *extlist); + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); +int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, + GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); +GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); + +DECLARE_ASN1_FUNCTIONS(OTHERNAME) +DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) + +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); + +DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) +int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); + +DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) +DECLARE_ASN1_FUNCTIONS(POLICYINFO) +DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) +DECLARE_ASN1_FUNCTIONS(USERNOTICE) +DECLARE_ASN1_FUNCTIONS(NOTICEREF) + +DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) +DECLARE_ASN1_FUNCTIONS(DIST_POINT) +DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) + +DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) +DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) + +DECLARE_ASN1_ITEM(POLICY_MAPPING) +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) +DECLARE_ASN1_ITEM(POLICY_MAPPINGS) + +DECLARE_ASN1_ITEM(GENERAL_SUBTREE) +DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) + +DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) +DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) +DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) + +#ifdef HEADER_CONF_H +GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + CONF_VALUE *cnf); +GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); +void X509V3_conf_free(CONF_VALUE *val); + +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +int X509V3_add_value_bool_nf(char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); +int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); +void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); +void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); +#endif + +char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); +STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); +void X509V3_string_free(X509V3_CTX *ctx, char *str); +void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); +void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, + X509_REQ *req, X509_CRL *crl, int flags); + +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_uchar(const char *name, const unsigned char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_bool(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, + STACK_OF(CONF_VALUE) **extlist); +char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); +ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); +char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +int X509V3_EXT_add(X509V3_EXT_METHOD *ext); +int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); +int X509V3_EXT_add_alias(int nid_to, int nid_from); +void X509V3_EXT_cleanup(void); + +X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); +X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); +int X509V3_add_standard_extensions(void); +STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); +void *X509V3_EXT_d2i(X509_EXTENSION *ext); +void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); + + +X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); +int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); + +char *hex_to_string(unsigned char *buffer, long len); +unsigned char *string_to_hex(char *str, long *len); +int name_cmp(const char *name, const char *cmp); + +void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, + int ml); +int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); +int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); + +int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); + +int X509_check_ca(X509 *x); +int X509_check_purpose(X509 *x, int id, int ca); +int X509_supported_extension(X509_EXTENSION *ex); +int X509_PURPOSE_set(int *p, int purpose); +int X509_check_issued(X509 *issuer, X509 *subject); +int X509_PURPOSE_get_count(void); +X509_PURPOSE * X509_PURPOSE_get0(int idx); +int X509_PURPOSE_get_by_sname(char *sname); +int X509_PURPOSE_get_by_id(int id); +int X509_PURPOSE_add(int id, int trust, int flags, + int (*ck)(const X509_PURPOSE *, const X509 *, int), + char *name, char *sname, void *arg); +char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); +char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); +int X509_PURPOSE_get_trust(X509_PURPOSE *xp); +void X509_PURPOSE_cleanup(void); +int X509_PURPOSE_get_id(X509_PURPOSE *); + +STACK *X509_get1_email(X509 *x); +STACK *X509_REQ_get1_email(X509_REQ *x); +void X509_email_free(STACK *sk); + +ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); +ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); +int a2i_ipadd(unsigned char *ipout, const char *ipasc); +int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, + unsigned long chtype); + +void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); + +#ifndef OPENSSL_NO_RFC3779 + +typedef struct ASRange_st { + ASN1_INTEGER *min, *max; +} ASRange; + +#define ASIdOrRange_id 0 +#define ASIdOrRange_range 1 + +typedef struct ASIdOrRange_st { + int type; + union { + ASN1_INTEGER *id; + ASRange *range; + } u; +} ASIdOrRange; + +typedef STACK_OF(ASIdOrRange) ASIdOrRanges; +DECLARE_STACK_OF(ASIdOrRange) + +#define ASIdentifierChoice_inherit 0 +#define ASIdentifierChoice_asIdsOrRanges 1 + +typedef struct ASIdentifierChoice_st { + int type; + union { + ASN1_NULL *inherit; + ASIdOrRanges *asIdsOrRanges; + } u; +} ASIdentifierChoice; + +typedef struct ASIdentifiers_st { + ASIdentifierChoice *asnum, *rdi; +} ASIdentifiers; + +DECLARE_ASN1_FUNCTIONS(ASRange) +DECLARE_ASN1_FUNCTIONS(ASIdOrRange) +DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) +DECLARE_ASN1_FUNCTIONS(ASIdentifiers) + + +typedef struct IPAddressRange_st { + ASN1_BIT_STRING *min, *max; +} IPAddressRange; + +#define IPAddressOrRange_addressPrefix 0 +#define IPAddressOrRange_addressRange 1 + +typedef struct IPAddressOrRange_st { + int type; + union { + ASN1_BIT_STRING *addressPrefix; + IPAddressRange *addressRange; + } u; +} IPAddressOrRange; + +typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; +DECLARE_STACK_OF(IPAddressOrRange) + +#define IPAddressChoice_inherit 0 +#define IPAddressChoice_addressesOrRanges 1 + +typedef struct IPAddressChoice_st { + int type; + union { + ASN1_NULL *inherit; + IPAddressOrRanges *addressesOrRanges; + } u; +} IPAddressChoice; + +typedef struct IPAddressFamily_st { + ASN1_OCTET_STRING *addressFamily; + IPAddressChoice *ipAddressChoice; +} IPAddressFamily; + +typedef STACK_OF(IPAddressFamily) IPAddrBlocks; +DECLARE_STACK_OF(IPAddressFamily) + +DECLARE_ASN1_FUNCTIONS(IPAddressRange) +DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) +DECLARE_ASN1_FUNCTIONS(IPAddressChoice) +DECLARE_ASN1_FUNCTIONS(IPAddressFamily) + +/* + * API tag for elements of the ASIdentifer SEQUENCE. + */ +#define V3_ASID_ASNUM 0 +#define V3_ASID_RDI 1 + +/* + * AFI values, assigned by IANA. It'd be nice to make the AFI + * handling code totally generic, but there are too many little things + * that would need to be defined for other address families for it to + * be worth the trouble. + */ +#define IANA_AFI_IPV4 1 +#define IANA_AFI_IPV6 2 + +/* + * Utilities to construct and extract values from RFC3779 extensions, + * since some of the encodings (particularly for IP address prefixes + * and ranges) are a bit tedious to work with directly. + */ +int v3_asid_add_inherit(ASIdentifiers *asid, int which); +int v3_asid_add_id_or_range(ASIdentifiers *asid, int which, + ASN1_INTEGER *min, ASN1_INTEGER *max); +int v3_addr_add_inherit(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi); +int v3_addr_add_prefix(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *a, const int prefixlen); +int v3_addr_add_range(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *min, unsigned char *max); +unsigned v3_addr_get_afi(const IPAddressFamily *f); +int v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, + unsigned char *min, unsigned char *max, + const int length); + +/* + * Canonical forms. + */ +int v3_asid_is_canonical(ASIdentifiers *asid); +int v3_addr_is_canonical(IPAddrBlocks *addr); +int v3_asid_canonize(ASIdentifiers *asid); +int v3_addr_canonize(IPAddrBlocks *addr); + +/* + * Tests for inheritance and containment. + */ +int v3_asid_inherits(ASIdentifiers *asid); +int v3_addr_inherits(IPAddrBlocks *addr); +int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); +int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); + +/* + * Check whether RFC 3779 extensions nest properly in chains. + */ +int v3_asid_validate_path(X509_STORE_CTX *); +int v3_addr_validate_path(X509_STORE_CTX *); +int v3_asid_validate_resource_set(STACK_OF(X509) *chain, + ASIdentifiers *ext, + int allow_inheritance); +int v3_addr_validate_resource_set(STACK_OF(X509) *chain, + IPAddrBlocks *ext, + int allow_inheritance); + +#endif /* OPENSSL_NO_RFC3779 */ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509V3_strings(void); + +/* Error codes for the X509V3 functions. */ + +/* Function codes. */ +#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 156 +#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 157 +#define X509V3_F_COPY_EMAIL 122 +#define X509V3_F_COPY_ISSUER 123 +#define X509V3_F_DO_DIRNAME 144 +#define X509V3_F_DO_EXT_CONF 124 +#define X509V3_F_DO_EXT_I2D 135 +#define X509V3_F_DO_EXT_NCONF 151 +#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148 +#define X509V3_F_HEX_TO_STRING 111 +#define X509V3_F_I2S_ASN1_ENUMERATED 121 +#define X509V3_F_I2S_ASN1_IA5STRING 149 +#define X509V3_F_I2S_ASN1_INTEGER 120 +#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 +#define X509V3_F_NOTICE_SECTION 132 +#define X509V3_F_NREF_NOS 133 +#define X509V3_F_POLICY_SECTION 131 +#define X509V3_F_PROCESS_PCI_VALUE 150 +#define X509V3_F_R2I_CERTPOL 130 +#define X509V3_F_R2I_PCI 155 +#define X509V3_F_S2I_ASN1_IA5STRING 100 +#define X509V3_F_S2I_ASN1_INTEGER 108 +#define X509V3_F_S2I_ASN1_OCTET_STRING 112 +#define X509V3_F_S2I_ASN1_SKEY_ID 114 +#define X509V3_F_S2I_SKEY_ID 115 +#define X509V3_F_STRING_TO_HEX 113 +#define X509V3_F_SXNET_ADD_ID_ASC 125 +#define X509V3_F_SXNET_ADD_ID_INTEGER 126 +#define X509V3_F_SXNET_ADD_ID_ULONG 127 +#define X509V3_F_SXNET_GET_ID_ASC 128 +#define X509V3_F_SXNET_GET_ID_ULONG 129 +#define X509V3_F_V2I_ASIDENTIFIERS 158 +#define X509V3_F_V2I_ASN1_BIT_STRING 101 +#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 +#define X509V3_F_V2I_AUTHORITY_KEYID 119 +#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 +#define X509V3_F_V2I_CRLD 134 +#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 +#define X509V3_F_V2I_GENERAL_NAMES 118 +#define X509V3_F_V2I_GENERAL_NAME_EX 117 +#define X509V3_F_V2I_IPADDRBLOCKS 159 +#define X509V3_F_V2I_ISSUER_ALT 153 +#define X509V3_F_V2I_NAME_CONSTRAINTS 147 +#define X509V3_F_V2I_POLICY_CONSTRAINTS 146 +#define X509V3_F_V2I_POLICY_MAPPINGS 145 +#define X509V3_F_V2I_SUBJECT_ALT 154 +#define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL 160 +#define X509V3_F_V3_GENERIC_EXTENSION 116 +#define X509V3_F_X509V3_ADD1_I2D 140 +#define X509V3_F_X509V3_ADD_VALUE 105 +#define X509V3_F_X509V3_EXT_ADD 104 +#define X509V3_F_X509V3_EXT_ADD_ALIAS 106 +#define X509V3_F_X509V3_EXT_CONF 107 +#define X509V3_F_X509V3_EXT_I2D 136 +#define X509V3_F_X509V3_EXT_NCONF 152 +#define X509V3_F_X509V3_GET_SECTION 142 +#define X509V3_F_X509V3_GET_STRING 143 +#define X509V3_F_X509V3_GET_VALUE_BOOL 110 +#define X509V3_F_X509V3_PARSE_LIST 109 +#define X509V3_F_X509_PURPOSE_ADD 137 +#define X509V3_F_X509_PURPOSE_SET 141 + +/* Reason codes. */ +#define X509V3_R_BAD_IP_ADDRESS 118 +#define X509V3_R_BAD_OBJECT 119 +#define X509V3_R_BN_DEC2BN_ERROR 100 +#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 +#define X509V3_R_DIRNAME_ERROR 149 +#define X509V3_R_DUPLICATE_ZONE_ID 133 +#define X509V3_R_ERROR_CONVERTING_ZONE 131 +#define X509V3_R_ERROR_CREATING_EXTENSION 144 +#define X509V3_R_ERROR_IN_EXTENSION 128 +#define X509V3_R_EXPECTED_A_SECTION_NAME 137 +#define X509V3_R_EXTENSION_EXISTS 145 +#define X509V3_R_EXTENSION_NAME_ERROR 115 +#define X509V3_R_EXTENSION_NOT_FOUND 102 +#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 +#define X509V3_R_EXTENSION_VALUE_ERROR 116 +#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 +#define X509V3_R_ILLEGAL_HEX_DIGIT 113 +#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 +#define X509V3_R_INVALID_ASNUMBER 160 +#define X509V3_R_INVALID_ASRANGE 161 +#define X509V3_R_INVALID_BOOLEAN_STRING 104 +#define X509V3_R_INVALID_EXTENSION_STRING 105 +#define X509V3_R_INVALID_INHERITANCE 162 +#define X509V3_R_INVALID_IPADDRESS 163 +#define X509V3_R_INVALID_NAME 106 +#define X509V3_R_INVALID_NULL_ARGUMENT 107 +#define X509V3_R_INVALID_NULL_NAME 108 +#define X509V3_R_INVALID_NULL_VALUE 109 +#define X509V3_R_INVALID_NUMBER 140 +#define X509V3_R_INVALID_NUMBERS 141 +#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 +#define X509V3_R_INVALID_OPTION 138 +#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 +#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 +#define X509V3_R_INVALID_PURPOSE 146 +#define X509V3_R_INVALID_SAFI 164 +#define X509V3_R_INVALID_SECTION 135 +#define X509V3_R_INVALID_SYNTAX 143 +#define X509V3_R_ISSUER_DECODE_ERROR 126 +#define X509V3_R_MISSING_VALUE 124 +#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 +#define X509V3_R_NO_CONFIG_DATABASE 136 +#define X509V3_R_NO_ISSUER_CERTIFICATE 121 +#define X509V3_R_NO_ISSUER_DETAILS 127 +#define X509V3_R_NO_POLICY_IDENTIFIER 139 +#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 +#define X509V3_R_NO_PUBLIC_KEY 114 +#define X509V3_R_NO_SUBJECT_DETAILS 125 +#define X509V3_R_ODD_NUMBER_OF_DIGITS 112 +#define X509V3_R_OPERATION_NOT_DEFINED 148 +#define X509V3_R_OTHERNAME_ERROR 147 +#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155 +#define X509V3_R_POLICY_PATH_LENGTH 156 +#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157 +#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158 +#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 +#define X509V3_R_SECTION_NOT_FOUND 150 +#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 +#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 +#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 +#define X509V3_R_UNKNOWN_EXTENSION 129 +#define X509V3_R_UNKNOWN_EXTENSION_NAME 130 +#define X509V3_R_UNKNOWN_OPTION 120 +#define X509V3_R_UNSUPPORTED_OPTION 117 +#define X509V3_R_USER_TOO_LONG 132 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/pmrt_compression/pmrt_compression.h b/include/pmrt_compression/pmrt_compression.h new file mode 100755 index 0000000..ea54446 --- /dev/null +++ b/include/pmrt_compression/pmrt_compression.h @@ -0,0 +1,59 @@ +// pmrt_compression.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_COMPRESSION_H +#define PMRT_COMPRESSION_H + +#include + +#include + +enum GZERRS +{ + GZ_FAILED_TO_OPEN_SRCFILE = -99, + GZ_FAILED_TO_OPEN_DESTFILE, + GZ_WRITE_FAILED, + GZ_READ_FAILED, + + GZ_SUCCESS = 0, +}; + + + + +int gunzipfile( char *srcfile, char *destfile ); +int gzipfile( char *srcfile, char *destfile ); + +//will uncompress a file that was compressed using the compress function in zlib +//outBuffer will be filled in. Buffer size will be filled in with the size of the buffer +//NOTE: User is expected to free the buffer after use! +int UncompressFile(const char *fileName, char *outBuffer, unsigned int *bufferSize); + + +/* these funcs moved to pmrt_ssl lib, consider implementing sans crypto here +typedef enum _ZEnum +{ + ZENUM_READ, ZENUM_UNKNOWN +}ZEnum; + +typedef struct _ZStreamHandle +{ + z_stream stream; + CryptoFileHandle crypFile; + char *inBuffer; + char *origBuffer; + int inBufSize; +}ZStreamHandle; + + +int ZStreamCryptoInit(ZStreamHandle *handle, ZEnum type, const char *fileName, const char *fileKey, + int keySize, const char *iv, int ivSize, char *inBuffer, int inSize); +int ZStreamRead(ZStreamHandle *zhandle, void *outData, unsigned int outSize); +void ZStreamClose(ZStreamHandle *zhandle); + +*/ + +#endif +//EOF + diff --git a/include/pmrt_messages/dbquery.h b/include/pmrt_messages/dbquery.h new file mode 100755 index 0000000..dfc470f --- /dev/null +++ b/include/pmrt_messages/dbquery.h @@ -0,0 +1,296 @@ +// dbquery.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef DBQUERY_H +#define DBQUERY_H + +#include "messages.h" + +//#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +//#include "node.h" +//#endif + +#include +#include + + + + +#include + + +#define MAX_NUM_DBQUERY_TYPES 512 +#define MAX_DBQUERY_ORPHAN_CALLBACKS MAX_NUM_DBQUERY_TYPES + +#define DBQUERY_WAIT_CONNECT_TIMEOUT 10 +#define DBQUERY_SEND_TIMEOUT 10 +#define DBQUERY_RECV_TIMEOUT 30 // DB queries can take some time to execute +#define DBQUERY_BASE_BACKOFF_TIMEOUT 2 +#define DBQUERY_MAX_BACKOFF_TIMEOUT 128 // don't ever back off for more than 2 minutes + +#define DBQUERY_DISABLE_PERSISTENT_CONNECTIONS 0 +#define DBQUERY_CONNECTION_PERSIST_TIME 900 // how long to hold connections open while waiting for new queries to queue + +// Enumerate basic dbquery types here +// should match DBQueryTypeInfo defined in dbquery.c +// use AddNewDBQueryTypes() to add additional query types form game code +enum +{ + DBQUERY_TYPE_PLAIN_TEXT = 0, +// administrative queries (not actual queries, instead instruct DBQuery Thread to do something) + DBQUERY_TYPE_PURGE_CACHE, + DBQUERY_TYPE_RESET_BACKEDOFF_CLIENTS, + NUM_BASE_DBQUERY_TYPES, +}; + + +// used by open/load routines +#define CRYPTO_IV_LEN 16 + + + +typedef struct DBQueryTypeInfoStruct +{ + int query_type; + int query_struct_type; + int result_struct_type; + char name[256]; + +} DBQueryTypeInfoStruct; + +extern DBQueryTypeInfoStruct DBQueryTypeInfo[MAX_NUM_DBQUERY_TYPES]; + +typedef struct +{ + int type; + void (*callback)(struct Message*); +} DBQueryOrphanCallbackStruct; + +extern DBQueryOrphanCallbackStruct DBQueryOrphanCallbacks[MAX_DBQUERY_ORPHAN_CALLBACKS]; + +enum DBQueryResultErrorCodes +{ + DBQUERY_RESULT_SUCCESS, + DBQUERY_RESULT_CACHE_MISS, + DBQUERY_RESULT_SERVER_UNREACHABLE, + DBQUERY_RESULT_TRANSMIT_ERR, + DBQUERY_RESULT_SERVER_RETURNED_ERR, + DBQUERY_RESULT_SERVER_COULD_NOT_CONTACT_DATABASE, + DBQUERY_RESULT_ERROR_PARSING_RESULTS, +}; + + + +enum DBQueryFileOperationErrorCodes +{ + DBQUERY_FILE_RESULT_SUCCESS, + DBQUERY_FILE_RESULT_INVALID_PARAMS, + DBQUERY_FILE_RESULT_INVALID_FD, + DBQUERY_FILE_RESULT_WRITE_ERR, + DBQUERY_FILE_RESULT_READ_ERR, + DBQUERY_FILE_RESULT_MALLOC_ERR, + DBQUERY_FILE_RESULT_FOPEN_ERR, + DBQUERY_FILE_RESULT_FCLOSE_ERR, + DBQUERY_FILE_RESULT_MKDIR_ERR, + DBQUERY_FILE_RESULT_EOF, +}; + +typedef struct +{ + int type; + int maxage; + int max_result_rows; + int query_data_size; + uns32 query_data_crc; + void *query_data; + +} DBQuery; + +typedef struct +{ + DBQuery query; + int timestamp; + int error_code; + int result_rows; + int result_row_size; + int saved; + uns32 result_data_crc; + void *result_data; + +} DBQueryResult; + + +struct DBQuerySystemStats +{ + int start_timestamp; + int TotalMsgs; + int ActiveMsgs; + int ActiveMsgsByType[NUM_MESSAGE_TYPES]; + int ActivePersistentMsgs; + + int DBQueryInQueueSize; + int DBQueryOutQueueSize; + + int ActiveDBClientSessions; + + // err counts and timestamps + int DBClientConnectAttemps; + int DBClientNoConnectErrs; + int DBClientTransmitErrs; + int DBClientServerErrs; + int DBClientSuccessfulConnections; + int DBClientLastSuccessfulServerConnect; + int DBClientLastFailedServerConnect; + int DBClientLastSuccessfulQuery; + int DBClientLastFailedQuery; + int DBClientSuccessfulConnectionsByType[MAX_NUM_DBQUERY_TYPES]; + + + int DBClientConnectionsOpen; + int DBClientConnectionsOpened; + int DBClientConnectionsClosed; + + + // backoff stats + int DBQueryBackOffTime; + int DBQueryNextFreeClient; + int DBQueryNextFreePersistentClient; + + // byte counters + // (note these are raw bytes sent/recvd before SSL and/or encryption) + unsigned int DBClientTotalBytesSent; + unsigned int DBClientTotalBytesRecieved; + + unsigned int DBClientBytesSentByType[MAX_NUM_DBQUERY_TYPES]; + unsigned int DBClientBytesRecievedByType[MAX_NUM_DBQUERY_TYPES]; + + // cache stats + int DBQueryMemCacheSize; + int DBQueryMemCacheSizeBytes; + + int DBQueryDiskCacheSize; + int DBQueryDiskCacheSizeBytes; + + int DBQueryMemCacheHits; + int DBQueryDiskCacheHits; + + // microsecond timers + uns64 DBClientTotalConnectTime; + uns64 DBClientTotalSendTime; + uns64 DBClientTotalRecvTime; + uns64 DBClientTotalCloseTime; + uns64 DBClientTotalCompleteQueryTime; + + uns64 DBClientAvgConnectTime; + uns64 DBClientAvgSendTime; + uns64 DBClientAvgRecvTime; + uns64 DBClientAvgCloseTime; + uns64 DBClientAvgCompleteQueryTime; + + uns64 DBClientTotalCompleteQueryTimeByType[MAX_NUM_DBQUERY_TYPES]; + uns64 DBClientAvgCompleteQueryTimeByType[MAX_NUM_DBQUERY_TYPES]; + + // general stat tracking + // note these are all tracked on a 'by type' so the two + // queries of the same type but w/ different inputs are treated + // the same as far as these stats are concerned + // also as a note, all these stats are actually tracked in messages.c + // that's b/c only the message loop really knows what the final + // answer passed to the game is (dbquery only knows what it tried to send) + // but keep in mind, messages.c runs in a different thread than + // dbquery.c, so should never edit these fields in dbqeury.c + int DBQueryCountByType[MAX_NUM_DBQUERY_TYPES]; // raw count of queries answered + int DBQueryResultTimestampsByType[MAX_NUM_DBQUERY_TYPES]; // timestamp on must recent result given to game + int DBQueryTotalAgeTimesByType[MAX_NUM_DBQUERY_TYPES]; // // sum of age of results for each query answered + int DBQueryAvgAgeTimesByType[MAX_NUM_DBQUERY_TYPES]; // QueryTotalAgeTimes / QueryCounts; +}; + +struct DBQuerySystemStats gDBQuerySystemStats; + +char gDBQueryPublicCert[2048]; // text copy of public cert, good for displaying the public key + + + +void FreeDBQuery( DBQuery *query, int free_query_data ); +void FreeDBQueryResult( DBQueryResult *result, int free_query_data, int free_result_data ); + + +int CreateDBQuery( DBQuery **ppQuery, int type, int maxage, int max_result_rows, int query_data_size, void *query_data, int copy_query_data ); +int CloneDBQuery( DBQuery **ppDst, DBQuery *Src, int copy_query_data ); +int CopyDBQuery( DBQuery *src, DBQuery *dst, int copy_query_data ); +int CreateDBQueryResult( DBQueryResult **ppQueryResult, DBQuery *Query, int copy_query_data, int timestamp, int error_code, int result_row_size, int result_rows, void *result_data, int copy_result_data ); +int CloneDBQueryResult(DBQueryResult **ppDst, DBQueryResult *Src, int copy_query_data, int copy_result_data ); + + +DBQueryResult *SearchDBQueryResultCache( DBQuery *query ); +DBQueryResult *SearchDBQueryResultCacheFiles( DBQuery *query ); + +int DBQueryCompare( DBQuery *q1, DBQuery *q2 ); + + +void PrintDBQuery( DBQuery *query, char *lead ); +void PrintDBQueryResult( DBQueryResult *result, char *lead ); + +int WriteDBQueryToFile( FILE *fd, DBQuery *query ); +int WriteDBQueryResultToFile( FILE *fd, DBQueryResult *result ); +int LoadDBQueryFromFile( FILE *fd, DBQuery *query ); +int LoadDBQueryResultFromFile( FILE *fd, DBQueryResult *result ); + +int SaveDBQuery( char *filename, DBQuery *query ); +int LoadDBQuery( char *filename, DBQuery *query ); +int GenerateFileIV( char *filename, unsigned char *iv, int iv_len ); + +int SaveDBQueryResult( char *filename, DBQueryResult *result ); +int LoadDBQueryResult( char *filename, DBQueryResult *result ); + + +int DBQuerySystemInit(char *CacheDir, char *AuditsDir, + char *ServerIP, int ServerPort, char *ServerCertFile, + int (*pCheckIfOKToUseDiskFunc)(), + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize ); + +void DBQuerySystemSetServer( char *ServerIP, int ServerPort ); + +void DBQueryThread( int arg ); + +int AddNewDBQueryTypes(int count, DBQueryTypeInfoStruct *NewQueryTypeInfo); +int AddNewDBQueryOrphanCallbacks( int count, DBQueryOrphanCallbackStruct *NewOrphanCallbacks ); + +void DoDBQueryOrphanCallback(Message *msg); + + +int AssignMessageToClientSession(Message *msg,int session_num); +void ProcessClientSessionResults(int session_num); +int UpdateClientSessions(); + +// write passed data to passed file handle +// appending CRC after data +int WriteDataWithCRCToFile( void *data, int len, int count, FILE *fd ); + + +// reads data from file handle into passed buffer +// then reads next 32 bytes from filehandle, +// assumes it is a CRC for the data +// (as would be the case if data was written with WriteDataWithCRCToFile()) +// and compares it to the calc'd CRC for the loaded data +int ReadDataWithCRCFromFile( void *data, int len, int count, FILE *fd ); + + +int LoadDataWithCRC( void *data, int size, char *filename ); +int SaveDataWithCRC( void *data, int size, char *filename ); + + +// crypto versions of above read/write functions +int WriteDataWithCRCToCryptoFile( void *data, int len, int count, CryptoFileHandle *cfh ); +int ReadDataWithCRCFromCryptoFile( void *data, int len, int count, CryptoFileHandle *cfh ); +int WriteDBQueryToCryptoFile( CryptoFileHandle *cfh, DBQuery *query ); +int WriteDBQueryResultToCryptoFile( CryptoFileHandle *cfh, DBQueryResult *result ); +int LoadDBQueryFromCryptoFile( CryptoFileHandle *cfh, DBQuery *query ); +int LoadDBQueryResultFromCryptoFile( CryptoFileHandle *cfh, DBQueryResult *result ); + + +#endif + diff --git a/include/pmrt_messages/filetransfer.h b/include/pmrt_messages/filetransfer.h new file mode 100755 index 0000000..ffee926 --- /dev/null +++ b/include/pmrt_messages/filetransfer.h @@ -0,0 +1,146 @@ +// filetransfer.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef FILEXFR_H +#define FILEXFR_H + + + + +#include + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +// #include "node.h" +#endif + +#include +#include + + + +enum FileTranferErrCodes +{ + FILETRANSFER_RESULT_SUCCESS, + FILETRANSFER_RESULT_SERVER_UNREACHABLE, + FILETRANSFER_RESULT_SERVER_RETURNED_ERR, + FILETRANSFER_RESULT_FAILURE, +}; + + +#define MAX_FILEXFR_STRING_LENGTH 256 +// file transfer structs +typedef struct +{ + unsigned int id; + char Filepath[MAX_FILEXFR_STRING_LENGTH]; + char Filename[MAX_FILEXFR_STRING_LENGTH]; + unsigned int Filesize; + unsigned int FileCRC; + char Filetype[MAX_FILEXFR_STRING_LENGTH]; + char FTPaddress[MAX_FILEXFR_STRING_LENGTH]; +} FileTransferInfo_t; + +typedef struct +{ + unsigned int id; + char FileType[MAX_FILEXFR_STRING_LENGTH]; +} FileTransferGetByType_t; + + +typedef struct +{ + int game; + int type; + int id; +} FileTransferRequest_t; + +enum FileTransferRequestTypes +{ + FILETRANSFER_TYPE_TEST_CONNECTION, + FILETRANSFER_TYPE_TRNY_FILES, + FILETRANSFER_TYPE_AD_FILES, + NUM_FILETRANSFER_TYPES, +}; + +enum FileTransferGameTypes +{ + FILETRANSFER_GAME_BBHT, + FILETRANSFER_GAME_BBST, +}; + +char gFileTransferPublicCert[2048]; + +typedef struct +{ + char Filename[MAX_FILEXFR_STRING_LENGTH]; + char SrcPath[MAX_FILEXFR_STRING_LENGTH]; + char DestPath[MAX_FILEXFR_STRING_LENGTH]; + int Filesize; + unsigned int FileCRC; + char FileDigest[3*DATADIGEST_MAX_DIGEST_LEN]; + +} FileInfoStruct_t; + + +struct FileTransferSystemStats +{ + int start_timestamp; + int TotalMsgs; + int ActiveMsgs; + + // err counts and timestamps + unsigned int ConnectAttemps; + unsigned int NoConnectErrs; + unsigned int ClientErrs; + unsigned int HTTPErrs; + unsigned int FileNotFoundErrs; + unsigned int SuccessfulConnections; + + int LastSuccessfulServerConnect; + int LastFailedServerConnect; + int LastSuccessfulXFR; + int LastFailedXFR; + + unsigned int FailedValidations; + int LastFailedValidation; + + unsigned int FailedGunzips; + int LastFailedGunzip; + + unsigned int FailedRenames; + int LastFailedRename; + + // byte counters + // (note these are raw bytes sent/recvd before SSL and/or encryption) + unsigned int TotalBytesSent; + unsigned int TotalBytesRecieved; + + // unsigned int BytesSentByType[NUM_FILETRANSFER_TYPES]; + // unsigned int BytesRecievedByType[NUM_FILETRANSFER_TYPES]; + +}; + +struct FileTransferSystemStats gFileTransferSystemStats; + + +int FileTransferSystemInit( char *ServerIP, int ServerPort, char *ServerCertFile, + char *DownloadPath, char *AuditsDir, + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize, + int (*pCheckIfOKToUseDiskFunc)()); + +void FileTransferSetServer( char *ServerIP, int ServerPort ); + +void FileTransferThread( int arg ); + +void FreeFileTransferRequest( FileTransferRequest_t *request ); +void FreeFileTransferReply( int *reply ); +int CloneFileTransferRequest( FileTransferRequest_t **ppDst, FileTransferRequest_t *Src ); +int CloneFileTransferReply( int **ppDst, int *Src ); + +extern char RequestTypeDirs[][64]; +extern char RequestGameDirs[][64]; +#endif + diff --git a/include/pmrt_messages/messages.h b/include/pmrt_messages/messages.h new file mode 100755 index 0000000..cfe3686 --- /dev/null +++ b/include/pmrt_messages/messages.h @@ -0,0 +1,198 @@ +#ifndef MESSAGES_H +#define MESSAGES_H + +// messages.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#include + +#include "filetransfer.h" + +enum MessageStatus +{ + MESSAGE_OPEN, // new + MESSAGE_QUEUE, // waiting to be queued + MESSAGE_QUEUED, // queued + MESSAGE_RETRY, // retrying + MESSAGE_ANSWERED_TENTATIVE, // answered w/ err or from old/stale data + MESSAGE_ANSWERED, // answered definitively + MESSAGE_DROP, // message has been marked for removal (can happen if we are at limit of active messages and msg gets bumped to let a higher priority msg in) +}; + +enum MessageTypes +{ + MESSAGE_TYPE_PLAIN_TEXT, + MESSAGE_TYPE_DB_QUERY, + MESSAGE_TYPE_FILE_TRANSFER_REQUEST, + NUM_MESSAGE_TYPES, +}; + +enum SendMessageErrorCodes +{ + SEND_MESSAGE_SUCCESS, + SEND_MESSAGE_INVALID_PARAMS, + SEND_MESSAGE_MALLOC_ERR, +}; + +enum MessageFileOperationErrorCodes +{ + MESSAGE_FILE_RESULT_SUCCESS, + MESSAGE_FILE_RESULT_INVALID_PARAMS, + MESSAGE_FILE_RESULT_INVALID_FD, + MESSAGE_FILE_RESULT_WRITE_ERR, + MESSAGE_FILE_RESULT_READ_ERR, + MESSAGE_FILE_RESULT_MALLOC_ERR, + MESSAGE_FILE_RESULT_FOPEN_ERR, + MESSAGE_FILE_RESULT_FCLOSE_ERR, + MESSAGE_FILE_RESULT_MKDIR_ERR, + MESSAGE_FILE_RESULT_EOF, +}; + + + + + +typedef struct Message +{ + unsigned int id; + int type; + int timestamp; + int waittime; + int priority; + int persist; + int waitstatus; + int closed; + int saved; + int orphaned; + void *msg_data; + void *reply_data; + void (*replyCB)(struct Message*); + void (*killCB)(struct Message*); +}Message; + + +struct MessageSystemStats +{ + int TotalMsgs; + int ActiveMsgs; + int ActiveMsgsByType[NUM_MESSAGE_TYPES]; + int ActivePersistentMsgs; + + int StoredMsgs; + +}; + +void TestOrphanCallbackFunc(Message *msg); + +struct MessageSystemStats gMessageSystemStats; + + + +// +// Public Message Functions +// (see messages.c for all message functions) +// +// + +// Message Init and Loop funcs +// +int MessageSystemInit(char *MessageStoreDir, int (*pCheckIfOKToUseDiskFunc)(), unsigned char *CryptoSeed, int CryptoSeedSize); +int MessageLoop(); + + +// +// Print Message funcs +// for debug printing of messages to stdout +// +int PrintMessage( Message *msg ); +void PrintMessageStats(); + +// +// Message Send Funtions +// These create new messages and link them onto the actice Message List +// +int SendNewMessage( unsigned int *id, int type, + int waittime, int priority, int persist, + void *msg_data, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + + +int SendNewDBQueryMessage( unsigned int *id, + int query_type, + int maxage, int max_result_rows, + int query_data_size, void *query_data, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int SendNewDBQueryCacheUpdateMessage( unsigned int *id, + int query_type, + int query_data_size, void *query_data, + int result_row_size, int result_rows, void *result_data, + int waittime, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int SendNewFileTransferMessage( unsigned int *id, + FileTransferRequest_t *FileInfo, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + + +// +// Message Create/Delete/Copy/Clone Funtions +// 'nuff said +// +int CloneMessage( Message **ppDst, Message *Src, int copy_msg_data, int copy_reply_data ); +void FreeMessageData( Message *message, int free_msg_data, int free_reply_data ); +void FreeMessage( Message *message, int free_msg_data, int free_reply_data ); + + +// +// Message Flush Funtions +// func to flush out current message list (call before entering Diag) +// +void FlushMessages(); + +// +// Message Search Funtion +// +Message *FindMessageByID( unsigned int id ); + +// +// Message Introspection Funtions +// Wrapper functions for the game to use when +// interacting with messages (eg. closing them or pull information out of them) +// +int CheckMessageStatus( Message *message ); +int CloseOutMessage( Message *message ); +int CheckDBQueryMsgErrorCode( Message *message ); +int CheckDBQueryMsgResultCount( Message *message ); +int CopyDBQueryMsgResultsData( Message *message, void *dest, int size ); +void *GetDBQueryMsgResultsData( Message *message ); +void *GetDBQueryMsgQueryData( Message *message ); +int GetDBQueryMsgResultsTimestamp( Message *message ); + + + +int CheckMessageStatusByID( unsigned int id ); +int CloseOutMessageByID( unsigned int id ); +int CheckDBQueryMsgErrorCodeByID( unsigned int id ); +int CheckDBQueryMsgResultCountByID( unsigned int id ); +int CopyDBQueryMsgResultsDataByID( unsigned int id, void *dest, int size ); +void *GetDBQueryMsgResultsDataByID( unsigned int id ); +void *GetDBQueryMsgQueryDataByID( unsigned int id ); +int GetDBQueryMsgResultsTimestampByID( unsigned int id ); + +int CheckFileTransferMsgErrorCode( Message *message ); +int CheckFileTransferMsgErrorCodeByID( unsigned int id ); + + + +#endif + + + diff --git a/include/pmrt_messages/node.h b/include/pmrt_messages/node.h new file mode 100755 index 0000000..57f0730 --- /dev/null +++ b/include/pmrt_messages/node.h @@ -0,0 +1,286 @@ +#ifndef NODE_H +#define NODE_H +// node.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// + +//#include "" + +#include +#include + + +// Play Mechanix base types & system +typedef signed char int8; +typedef unsigned char uns8; +typedef signed short int16; +typedef unsigned short uns16; +typedef signed long int32; +typedef unsigned long uns32; + +#if SYS_PC +typedef __int64 int64; +typedef unsigned __int64 uns64; +#endif +#if SYS_BB +typedef long long int64; +typedef unsigned long long uns64; +#endif + +typedef int8 int2; +typedef uns8* ptr; +typedef float f32; +typedef unsigned int uns; +typedef uns sto; // unsigned, big enough for void*,float,int +typedef uns memu; +typedef int memi; + +#if SYS_PC +#define SYSBREAK() __asm {int 3} +#endif // SYS_PC + +#if SYS_BB +#define SYSBREAK() __asm__ ("int $3") +#endif // SYS_BB + + +#define BP(x) { SYSBREAK();} + + + +#define NUL ((void*)0) + +#define COUNT(array) (sizeof(array) / sizeof(array[0])) + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION TYPES + +enum { + FTYPE_NONE, + FTYPE_1, + FTYPE_2, + FTYPE_3, + FTYPE_4, + FTYPE_5, + FTYPE_6, + FTYPE_7, +}; + +typedef void (ftype1)(void); +typedef int (ftype2)(void*); +typedef int (ftype3)(void*,void*); +typedef int (ftype4)(int,void*,void*,void*); +typedef int (ftype5)(int); +typedef int (ftype6)(int,void*); +typedef int (ftype7)(void*,int); + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +typedef struct { + void *next; +} N1; + +enum { + N2TYPE_NONE, + N2TYPE_UNK, // valid node, but not typed yet + N2TYPE_RES, // resource type + N2TYPE_OBJ, // object type + N2TYPE_PROC, // proc type + N2TYPE_MSG, // msg type + N2TYPE_L2, // l2 link + N2TYPE_MAX +}; +#define M_N2TYPE 0x1f // flags will be in the top + +enum { + N2SUB_NONE, + N2SUB_KID=0xf2, // can be used to verify that this is a kid (not needed) +}; + +// keep this whole section up to date in DC + +#define M_N2_KIDLIST 0x0001 // has kid list +#define M_N2_KIDFIRST 0x0002 // process kid list first +#define M_N2_SKIP 0x0004 // don't process this node or any kids +#define M_N2_DEAD 0x0008 // node is dead (unlinked, aborted) +#define M_N2_LEVEL0 0x0010 // 0,1,2,3 +#define M_N2_LEVEL1 0x0020 // 0,1,2,3 +#define M_N2_LEVEL 0x0030 // 0,1,2,3 +#define S_N2_LEVEL 4 +#define M_N2_STRONG 0x0080 // strong node (don't normally kill) +#define M_N2_TYPE 0x0f00 // type can use 4 bits +#define M_N2_OPEN 0x1000 // node is open (for debugging) +#define M_N2_L2LINKED 0x2000 // linked into L2 list + + + +typedef struct { + // order is assumed by compiled (res_pc.c) and loaded data + void *next; + void *prev; + uns8 type; // type + uns8 sub; // subtype info + uns16 flags; // top 8 bits of flags are reserved for type +} N2; + + +#define N2KIDLIST(n) (((N2*)n)-1) +#define N2PARENT(n) (((N2*)n)+1) +#define N2L2(n) (((N2*)n)+1) // n2 to l2 +#define L2N2(n) (((N2*)n)-1) // l2 to n2 + +#define N2_DEPTH_MAX 8 +#define N2_DEPTH_DEFAULT 8 + + +void N1LinkTail(void *headp,void *node); +void N1LinkHead(void *headp,void *node); +int N1Unlink(void *headp,void *node); + +void N2Head(void *head); +void N2DontLink(void *node); +void N2LinkAfter(void *head,void *node); +void N2LinkBefore(void *head,void *node); +void N2Unlink(void *node); +int N2Count(void *node); +void* N2Parent(void *node); +char *N2Name(N2 *n,char **s2p); + +enum { + // return codes for the scan func + N2SCANFUNC_MATCH_AND_RETURN, + N2SCANFUNC_CONTINUE +}; + +typedef struct { + N2 *stack[8]; + int stacki; + N2 *wrapper; + ftype3 *func3; // int func(N2ScanRec *nsr,N2 *n) return N2SCANFUNC_ + memu fdata; // function data + char *s1; // match string s1 + char *s2; // match string s2 +} N2ScanRec; + +#define M_N2SCAN_VAL 0x0000ffff // used to pass values in +#define M_N2SCAN_SUB 0x00010000 // look for subtype +#define M_N2SCAN_FUNC 0x00020000 // function call +#define M_N2SCAN_NAME 0x00040000 // match the name +#define M_N2SCAN_PRIME 0x00100000 // find prime obj +#define M_N2SCAN_INIT 0x00200000 // this is the first call w/n2sr -- init +#define M_N2SCAN_DONTSCAN 0x00400000 // first and don't search (init only) +#define M_N2SCAN_NODEEPER 0x00800000 // dont scan deeper +#define M_N2SCAN_NOKIDS M_N2SCAN_NODEEPER // -- depricated +#define M_N2SCAN_WRAP 0x01000000 // wrap until start instead of till list end +#define M_N2SCAN_KIDSONLY 0x02000000 // kids only +void* N2Scan(N2ScanRec *n2sr,uns find,void *node); + +// generic search func for N2 list +void *N2Search( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *) ); +// generic operation func for N2 list +void N2Walk( void *StartNode, void *OperationParam, int (*OperationFunc)(void *, void *) ); +// Combo func, searches list for matching items and performs operation on them +void N2SearchAndOperate( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *), void *OperationParam, int (*OperationFunc)(void *, void *) ); + +// funcs for popping items off list +void *N2PopNode( void *Node ); +void *N2PopNext( void *Node ); +void *N2PopPrev( void *Node ); + + +int N2LevelSet(N2 *n,int lev); +int N2LevelGet(N2 *n); +int N2LevelCpy(N2 *dst,N2 *src); + +int N2AddDataNode( N2 *List , void *(*malloc_func)(size_t), void *data, int link_after); +int N2CountDataNodes( N2 *List ); + + +enum { + // must match resObjSubTable[], resObjSubSizes[] + OBJSUB_NONE, + OBJSUB_DATA, +}; + +typedef struct { + N2 lnk; + void *data; +} ObjData; + + +void prts_debug(char* format,...); + + +/* +uns32 AudCRC(uns8 *data, int len); + +typedef struct +{ + unsigned int count; + uns32 crc; +} RollingCRCHandle; + +int AudInitRollingCRC( RollingCRCHandle *rcrc ); +int AudAddToRollingCRC( RollingCRCHandle *rcrc, uns8 *data, int len); +uns32 AudCalcRollingCRC( RollingCRCHandle *rcrc ); + +uns32 AudCRCFile(char *filename ); +*/ + +int FsDirCheck(char* dirName); + + +#include + + + +// int CheckIfGameSubSystemsOkToUseDisk(); + + + +//----------------------------------------------------------------------------- +// Directory walking structures +#define FS_MAX_FILENAME_LEN 256 + +// SYS_PC +#if SYS_PC +#include +#include +typedef struct { + struct _finddata_t file; + long hFile; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir + int done; +} FsDH; +#endif // SYS_PC + +#if SYS_BB +#include +#include +#include +typedef struct { + DIR *dir; + struct dirent *ent; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir +} FsDH; +#endif // SYS_BB + +int FsOpenDir(FsDH *fdh, char *dirname ); +int FsCloseDir(FsDH *fdh); +char *FsReadDir(FsDH *fdh); +int FsMkDir( char *dirname, int make_parent_dirs ); + +int FsFileSize( char *filename ); + +int FsDirSize( char *dirname, int recurse ); +int FsDirWalk( char *dirname, int recurse, int (*OperationFunc)(char *, void *), void *data); + + +//----------------------------------------------------------------------------- + + +#endif // ndef NODE_H + + diff --git a/include/pmrt_messages/pmrt_messages.h b/include/pmrt_messages/pmrt_messages.h new file mode 100755 index 0000000..f009bc9 --- /dev/null +++ b/include/pmrt_messages/pmrt_messages.h @@ -0,0 +1,32 @@ +// pmrt_messages.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_MESSAGES_H +#define PMRT_MESSAGES_H + + +#include "messages.h" +#include "dbquery.h" +#include "filetransfer.h" +#include "tokens.h" + +#define PMRT_MESSAGES_MAJOR_VERSION 1 +#define PMRT_MESSAGES_MINOR_VERSION 6 +#define PMRT_MESSAGES_SUB_MINOR_VERSION 0x01 + + +int PMRT_MessagesSystemInit( char *MessageStoreDir, + char *DBQueryCacheDir, char *AuditsDir, + char *DBQueryServerIP, int DBQueryServerPort, char *DBQueryServerCert, + char *FileServerIP, int FileServerPort, char *FileServerCert, + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize, + char *FTPDownloadPath, + int (*pCheckIfOKToUseDiskFunc)(), + int NumGameQueryTypes, DBQueryTypeInfoStruct *GameDBQueryTypes, + int NumGameStructForms, int *GameStructForms, + int NumGameQueryOrphanCallbacks, DBQueryOrphanCallbackStruct *GameDBQueryOrphanCallbacks ); + +#endif + diff --git a/include/pmrt_messages/tokens.h b/include/pmrt_messages/tokens.h new file mode 100755 index 0000000..c3662c9 --- /dev/null +++ b/include/pmrt_messages/tokens.h @@ -0,0 +1,62 @@ +// tokens.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef TOKENS_H +#define TOKENS_H + + +#define MAX_STRUCT_FORMS 256 +#define MAX_STRUCT_MEMBERS 256 + + +// Enumerate token primitives here +// should match definition of StructForms in tokens.h +// use AddTokenStructForms() to add additional structure forms from game code +typedef enum +{ + // primitives + VOID_FORM = 0, + BYTE_PAD_FORM, + CHAR_FORM, + SHORT_FORM, + INT_FORM, + UNSINT_FORM, + LONG_FORM, + FLOAT_FORM, + TOKENS_NUM_BASE_FORMS, +} e_BaseStructForms; + + +typedef struct +{ + int rows; + int fields; + int min_fields; // fields in the longest row + int max_fields; // fields in the shortest row + int current_token; +} token_data; + +// Parses string source and puts into struct pointed to by +// the pointer that is pointed to by pDest +int ParseStruct(int dataType, int memberCount, void **ppDest, char *source); +// reverse of ParseStruct +// converts structure of type dataType into a text string +// of space seperated values enclosed in single quotes +// (ie. "'val1' 'val2' ...") +// puts new string in dest +int UnParseStruct(int dataType, void *pData, char *dest, int dest_size ); +// Compares two structures of type dataType +// returns 0 if all members hold the same values +// returns 1 if any members hold different values +// returns -1 on error +int StructCmp(int dataType, void *pData1, void *pData2 ); + +extern int StructForms[MAX_STRUCT_FORMS][MAX_STRUCT_MEMBERS]; + +int AddTokenStructForms(int count,int *NewForms); + +int TokenSystemInit(); + +#endif + diff --git a/include/pmrt_ssl/filecrypto.h b/include/pmrt_ssl/filecrypto.h new file mode 100755 index 0000000..60ba2cb --- /dev/null +++ b/include/pmrt_ssl/filecrypto.h @@ -0,0 +1,114 @@ +// filecrypto.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef FILECRYPTO_H +#define FILECRYPTO_H + +#include + + +#include +#include +#include +#include + +#include + + +enum +{ + CRYPTOFILE_RESULT_SUCCESS, + CRYPTOFILE_RESULT_INVALID_HANDLE, + CRYPTOFILE_RESULT_INVALID_PARAMS, + CRYPTOFILE_RESULT_FAILURE, + CRYPTOFILE_RESULT_DECRYPT_FAILURE, + CRYPTOFILE_RESULT_EOF, + CRYPTOFILE_RESULT_ZLIB_ERR, + CRYPTOFILE_RESULT_WRITE_FAILURE, + +}; + +enum +{ + CRYPTO_BLOWFISH, + CRYPTO_AES256, + CRYPTO_AES256_CBC = CRYPTO_AES256, + CRYPTO_AES256_OFB, + CRYPTO_AES256_CFB, +} CryptoAlgs; + +enum +{ + CRYPTO_ENCRYPT, + CRYPTO_DECRYPT, +} CryptoModes; + + +typedef struct +{ + BIO *file_bio; + BIO *crypto_bio; + + int writing; + int eof; +} CryptoFileHandle; + + + +int OpenCryptoFile( CryptoFileHandle *cfh, const char *filename, const char *mode, int CryptoMode, int CryptoAlg, + const unsigned char *key, int key_len, const unsigned char *iv, int iv_len ); + +int ReadFromCryptoFile( CryptoFileHandle *cfh, void *data, int *size ); +int WriteToCryptoFile( CryptoFileHandle *cfh, void *data, int *size ); + +int CloseCryptoFile( CryptoFileHandle *cfh ); + +int CheckCryptoFileEOF( CryptoFileHandle *cfh ); + + +int CryptoFileOp( const char *srcfile, const char *dstfile, int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len ); + + + +// funcs for reading/writing files that are zlib compressed and then encrypted + +typedef struct _CryptoZFileHandle +{ + z_stream stream; + CryptoFileHandle crypFile; + char *inBuffer; + char *outBuffer; + char origBuffer[128*128]; + int inBufSize; + int outBufSize; + int err; + int zlib_err; + int mode; + int eof; + int closed; +} CryptoZFileHandle; + +enum +{ + CRYPTO_COMPRESS_ENCRYPT, + CRYPTO_DECRYPT_DECOMPRESS, +} CryptoZModes; + + + +int CryptoZFileInit(CryptoZFileHandle *handle, int CryptoZMode, int CryptoAlg, + const char *filename, const unsigned char *key, int key_len, + const unsigned char *iv, int iv_len ); +int CryptoZFileRead(CryptoZFileHandle *zhandle, void *outData, unsigned int *outSize); +int CryptoZFileWrite(CryptoZFileHandle *zhandle, void *inData, unsigned int *inSize); +int CryptoZFileClose(CryptoZFileHandle *zhandle); +int CheckCryptoZFileEOF( CryptoZFileHandle *zhandle ); + +int CryptoZFileOp( const char *srcfile, const char *dstfile, + int CryptoZMode, int CryptoAlg, int PrependUncompressedSize, + const unsigned char *key, int key_len, const unsigned char *iv, int iv_len ); + +#endif + diff --git a/include/pmrt_ssl/keygenerate.h b/include/pmrt_ssl/keygenerate.h new file mode 100755 index 0000000..75c8693 --- /dev/null +++ b/include/pmrt_ssl/keygenerate.h @@ -0,0 +1,76 @@ +// keygenerate.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef KEYGENERATE_H +#define KEYGENERATE_H + +#include + +#include +#include +#include +#include +#include +#include + +#include "datadigest.h" + +// how big to make the private/public keys, 2048 is considered safe for immediate future +// from the RSA folks: (http://www.rsa.com/rsalabs/node.asp?id=2218) +/* +RSA Laboratories currently recommends key sizes of 1024 bits for corporate use and +2048 bits for extremely valuable keys like the root key pair used by a certifying +authority (see Question 4.1.3.12). Several recent standards specify a 1024-bit minimum +for corporate use. +*/ +// found some articles recommending 2048 bit keys, so consider using them if speed allows +#define KEYGEN_RSA_KEY_LEN 1024 +// keys will expire on Jan 1 of this year +#define KEYGEN_KEY_EXPIRE_YEAR 2025 // <- due to 32 bit time counter, can't go higher than this! + +enum +{ + KEYGEN_RESULT_SUCCESS, + KEYGEN_RESULT_INVALID_HANDLE, + KEYGEN_RESULT_INVALID_PARAMS, + KEYGEN_RESULT_FAILURE, +}; + +typedef struct +{ + X509 *cert; + EVP_PKEY *key; +} KeyGenHandle; + +RSA *GenerateRSAKey( unsigned char *seed, int seed_len ); + + +#ifdef __cplusplus +extern "C" { +#endif + +int MakeSSLCert( X509 **ppX509Cert, EVP_PKEY **ppPrivateKey, RSA *rsa, char *text ); + +int InitKeyHandleFromSeed( KeyGenHandle *kgh, unsigned char *seed, int seed_len, char *CertText ); +int SaveKeyHandleCert( KeyGenHandle *kgh, char *filename ); +int SaveKeyHandlePrivateKey( KeyGenHandle *kgh, char *filename ); +int ExportKeyHandleCert( KeyGenHandle *kgh, char *buf, int len ); + +int CloseKeyHandle( KeyGenHandle *kgh ); + +int GenerateCryptoKey( unsigned char *seed, int seed_len, + unsigned char *key, int key_len ); + +int GenerateCryptoKeyFast( const unsigned char *seed1, int seed1_len, + const unsigned char *seed2, int seed2_len, + unsigned char *key, int key_len ); + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/include/pmrt_ssl/memcrypto.h b/include/pmrt_ssl/memcrypto.h new file mode 100755 index 0000000..c314ec5 --- /dev/null +++ b/include/pmrt_ssl/memcrypto.h @@ -0,0 +1,53 @@ +// memcrypto.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef MEMCRYPTO_H +#define MEMCRYPTO_H + +#include "filecrypto.h" + +#include +#include +#include +#include + +enum +{ + CRYPTOMEM_RESULT_SUCCESS, + CRYPTOMEM_RESULT_INVALID_HANDLE, + CRYPTOMEM_RESULT_INVALID_PARAMS, + CRYPTOMEM_RESULT_FAILURE, + CRYPTOMEM_RESULT_DECRYPT_FAILURE, + CRYPTOMEM_RESULT_EOF, + +}; + + + +typedef struct +{ + BIO *mem_bio; + BIO *crypto_bio; + +} CryptoMemHandle; + + + +int InitCryptoMemHandle( CryptoMemHandle *cmh, int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len ); + +int ReadFromCryptoMemHandle( CryptoMemHandle *cmh, void *data, int *size ); +int WriteToCryptoMemHandle( CryptoMemHandle *cmh, void *data, int *size ); + +int ResetCryptoMemHandle( CryptoMemHandle *cfh ); + +int CloseCryptoMemHandle( CryptoMemHandle *cfh ); + + +int CryptoMemOp( int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len, + void *src, int src_len, void *dst, int *dst_len ); + + +#endif + diff --git a/include/pmrt_ssl/netssl.h b/include/pmrt_ssl/netssl.h new file mode 100755 index 0000000..8461bdf --- /dev/null +++ b/include/pmrt_ssl/netssl.h @@ -0,0 +1,98 @@ +// netssl.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + + +#ifndef NETSSL_H +#define NETSSL_H + +#include +#include +#include + +#include "keygenerate.h" + +enum +{ + NETSSL_RESULT_SUCCESS, + NETSSL_RESULT_PENDING, + NETSSL_RESULT_INVALID_HANDLE, + NETSSL_RESULT_INVALID_PARAMS, + NETSSL_RESULT_FAILED_TO_INIT_SSL_CONTEXT, + NETSSL_RESULT_FAILED_TO_SET_CLIENT_CERT, + NETSSL_RESULT_FAILED_TO_SET_CLIENT_KEY, + NETSSL_RESULT_CLIENT_CERT_NO_MATCH_KEY, + + NETSSL_RESULT_FAILED_TO_SET_SERVER_CERT_FILE, + NETSSL_RESULT_FAILED_TO_SET_VERIFY_CALLBACK, + NETSSL_RESULT_FAILED_TO_SET_CIPHER_LIST, + NETSSL_RESULT_FAILED_TO_INIT_BIO_OBJECT, + NETSSL_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION, + NETSSL_RESULT_CONNECT_FAILED, + NETSSL_RESULT_CONNECTION_NOT_READY, + NETSSL_RESULT_CONNECTION_CLOSED, + NETSSL_RESULT_FAILURE, +}; + +enum +{ + NETSSL_STATUS_READY_SEND, + NETSSL_STATUS_READY_RECV, + NETSSL_STATUS_READY_SEND_AND_RECV, + NETSSL_STATUS_NOT_READY, + NETSSL_STATUS_CONNECT_PENDING, + NETSSL_STATUS_HANDSHAKE_PENDING, + NETSSL_STATUS_INVALID_HANDLE, + NETSSL_STATUS_SELECT_FAILED, + NETSSL_STATUS_CONNECT_FAILED, + NETSSL_STATUS_CLOSED, +}; + + +#define NETSSL_MAX_IP_LEN 64 +#define NETSSL_MAX_ERR_LEN 256 + +typedef struct +{ + int type; + BIO *bio; + SSL_CTX *ctx; + SSL_METHOD *ssl_method; + SSL *ssl; + SSL_SESSION *ssl_session; + char ip[NETSSL_MAX_IP_LEN]; + int port; + char error[NETSSL_MAX_ERR_LEN]; + int connected; + int session_reused; + int session_renegotiate_bytes; + int session_renegotiate_time; + int ignore_dates_on_server_cert; + +} NetSSLHandle; + + +int NetSSLInitClientSession( NetSSLHandle *handle, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + int session_renegotiate_bytes, int session_renegotiate_time, + int ignore_dates_on_server_cert ); +int NetSSLOpenClientSession( NetSSLHandle *handle, char *remote_ip, int remote_port ); +int NetSSLCheckClientSessionStatus(NetSSLHandle *handle); +int NetSSLCloseClientSession( NetSSLHandle *handle ); +int NetSSLSendOutClientSession( NetSSLHandle *handle, void *data, int *size ); +int NetSSLRecvFromClientSession( NetSSLHandle *handle, void *data, int *size ); +int NetSSLRestoreClientSession( NetSSLHandle *handle ); +int NetSSLFreeClientSession( NetSSLHandle *handle ); +char *NetSSLCheckClientSessionError(NetSSLHandle *handle); + + + + + + +#endif + + diff --git a/include/pmrt_ssl/pmrt_ssl.h b/include/pmrt_ssl/pmrt_ssl.h new file mode 100755 index 0000000..a387b5b --- /dev/null +++ b/include/pmrt_ssl/pmrt_ssl.h @@ -0,0 +1,31 @@ +// filecrypto.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef PMRTSSL_H +#define PMRTSSL_H + +// openssl includes windows.h so for PC systems, +// need to go lean and mean, otherwise run afowl of a whole lot of stuff +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include "keygenerate.h" +#include "datadigest.h" +#include "filecrypto.h" +#include "netssl.h" +#include "sslclient.h" +#include "sslhttpclient.h" +#include "randomnumbers.h" +#include "memcrypto.h" +#include "aescrypt.h" + +#define PMRT_SSL_MAJOR_VERSION 1 +#define PMRT_SSL_MINOR_VERSION 1 +#define PMRT_SSL_SUB_MINOR_VERSION 0x01 + + +#endif + diff --git a/include/pmrt_ssl/randomnumbers.h b/include/pmrt_ssl/randomnumbers.h new file mode 100755 index 0000000..da810e7 --- /dev/null +++ b/include/pmrt_ssl/randomnumbers.h @@ -0,0 +1,42 @@ +// randomnumbers.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// funcs for generating random numbers + +#ifndef RANDOMNUMBERS_H +#define RANDOMNUMBERS_H + +#include "keygenerate.h" + + +typedef struct +{ + unsigned char state[1023]; + unsigned char md[DATADIGEST_MAX_DIGEST_LEN]; + unsigned int count; + unsigned int spot; + DataDigestHandle ddh; +} RandState; + +enum { + RANDNUM_SUCCESS, + RANDNUM_INVALID_PARAMS, + +} RandomNumbersErrCodes; + +// generate random number using OpenSSL's random number generator +// uses /dev/rand, system uptime, passed in bytes, etc. etc. +// to try to be really random +int SSLRand(unsigned char *buffer, int numBytes); + +// functions for generating deterministic series of random numbers +int RandStateInit( RandState *rs ); +int RandStateDeinit( RandState *rs ); +int RandStatePsuedoRand( RandState *rs, unsigned char *buf, int num); +int RandStateSeed( RandState *rs, const void *buf, int num); + + + +#endif + diff --git a/include/pmrt_ssl/sslclient.h b/include/pmrt_ssl/sslclient.h new file mode 100755 index 0000000..3391297 --- /dev/null +++ b/include/pmrt_ssl/sslclient.h @@ -0,0 +1,127 @@ +// sslclient.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#ifndef SSLCLIENT_H +#define SSLCLIENT_H + +#include +#include "netssl.h" +#include "keygenerate.h" + +typedef struct SSLClientStateStruct +{ + char server_ip[32]; + int server_port; + int state; + int start_time; + int curr_state_start; + int retries; + int curr_state_retries; + int connected; + int error_code; + + NetSSLHandle nsh; + + int (*eod_check)(struct SSLClientStateStruct*); + + char *send_buf; + int send_buf_size; + int send_count; + char *recv_buf; + int recv_buf_size; + int recv_count; + int last_recv_time; + + int null_terminate_recv_data; + int close_connection_after_recv_data; + + int connect_timeout; + int send_timeout; + int recv_timeout; + int backoff_timeout; + + uns64 connect_start_time; + uns64 connect_time; + uns64 send_start_time; + uns64 send_time; + uns64 recv_start_time; + uns64 recv_time; + uns64 close_start_time; + uns64 close_time; + uns64 complete_time; + +} SSLClientStateStruct; + +enum SSLClientStates +{ + SSL_CLIENT_STATE_AVAILABLE, + SSL_CLIENT_STATE_OPEN_CONNECTION, + SSL_CLIENT_STATE_WAIT_FOR_CONNECTION, + SSL_CLIENT_STATE_SEND_DATA, + SSL_CLIENT_STATE_RECV_DATA, + SSL_CLIENT_STATE_RECV_COMPLETE, + SSL_CLIENT_STATE_CLOSE_CONNECTION, + SSL_CLIENT_STATE_FREE_SESSION, + SSL_CLIENT_STATE_DONE, + SSL_CLIENT_STATE_ERROR, + SSL_CLIENT_STATE_BACKOFF, + +}; + + +enum SSLClientStateErrorCodes +{ + SSL_CLIENT_ERR_NONE, + SSL_CLIENT_ERR_CONNECT_FAILED, + SSL_CLIENT_ERR_SEND_FAILED, + SSL_CLIENT_ERR_RECV_FAILED, + SSL_CLIENT_ERR_CONNECT_TIMEDOUT, + SSL_CLIENT_ERR_SEND_TIMEDOUT, + SSL_CLIENT_ERR_RECV_TIMEDOUT, + SSL_CLIENT_ERR_RECV_BUFFER_FULL, +}; + + + + +int InitSSLClientStateStruct(SSLClientStateStruct *clientstate, + char *server_ip, int server_port, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + char *send_buf, int send_buf_size, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int (*eod_check)(struct SSLClientStateStruct*), + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout, + int ssl_renegotiate_bytes, int ssl_renegotiate_seconds, + int ignore_dates_on_server_cert ); + + +int UpdateSSLClientState(SSLClientStateStruct *clientstate); + +int ResetSSLClientStateStruct(SSLClientStateStruct *clientstate ); + +int ResetSSLClientStateStructRecvBuf(SSLClientStateStruct *clientstate ); + +int SetSSLClientStateStructSendBuf(SSLClientStateStruct *clientstate, char *send_buf, int send_buf_size ); +int SetSSLClientStateStructRecvBuf(SSLClientStateStruct *clientstate, char *recv_buf, int recv_buf_size ); + +int SetSSLClientStateStructTimeOuts(SSLClientStateStruct *clientstate, int connect_timeout, int send_timeout, + int recv_timeout, int backoff_timeout ); + +int SetSSLClientStateStructServer(SSLClientStateStruct *clientstate, char *server_ip, int server_port ); + +int FreeSSLClientStateStruct(SSLClientStateStruct *clientstate); + +int CloseSSLClientConnection(SSLClientStateStruct *clientstate); + +#endif + + diff --git a/include/pmrt_ssl/sslhttpclient.h b/include/pmrt_ssl/sslhttpclient.h new file mode 100755 index 0000000..0bac3d7 --- /dev/null +++ b/include/pmrt_ssl/sslhttpclient.h @@ -0,0 +1,171 @@ +// sslclient.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#ifndef SSLHTTPCLIENT_H +#define SSLHTTPCLIENT_H + +#include +#include + +#include +#include "netssl.h" +#include "sslclient.h" +#include "keygenerate.h" + +#define MAX_HTTP_REQUEST_LEN 1024 +#define MAX_HTTP_HEADER_LEN 2048 +#define MAX_HTTP_RECV_FILENAME_LEN 1024 + +// use a 256k buffer when reading http get data +// this buffer can go as large or small as you like +// smaller sizes maybe a little bit slower do to more +// frequent 'process data' calls +#define HTTP_GET_BUFFER_SIZE 256000 + +typedef struct HTTPGetParserStruct +{ + int state; + char server_ip[32]; + int server_port; + + char request_document[MAX_HTTP_REQUEST_LEN]; + int request_start_byte; + char request[MAX_HTTP_REQUEST_LEN]; + + char header[MAX_HTTP_HEADER_LEN]; + int header_len; + + char data_file[MAX_HTTP_RECV_FILENAME_LEN]; + FILE *fd; + char *data_buf; + int data_buf_size; + int data_len; + + int chunk_encoded; + char chunk_header[MAX_HTTP_HEADER_LEN]; + int chunk_header_len; + int chunk_len; + int chunk_pos; + + int content_len; + int content_pos; + + char footer[MAX_HTTP_HEADER_LEN]; + int footer_len; + + int close_connection_after_recv_data; + int null_terminate_data; + + int error_code; + int http_error_code; + +} HTTPGetParserStruct; + + +enum HTTPGetStates +{ + HTTP_GET_STATE_START, + HTTP_GET_STATE_PARSING_HEADER, + HTTP_GET_STATE_PARSING_DATA, + HTTP_GET_STATE_PARSE_FOOTER, + HTTP_GET_STATE_DONE, + HTTP_GET_STATE_ERR, +}; + +enum HTTPGetErrCodes +{ + HTTP_GET_ERR_NONE, + HTTP_GET_ERR_PARSE_ERR, + HTTP_GET_ERR_HTTP_ERR, + HTTP_GET_ERR_HEADER_BUFFER_FULL, + HTTP_GET_ERR_FOOTER_BUFFER_FULL, + HTTP_GET_ERR_DATA_BUFFER_FULL, + HTTP_GET_ERR_DATA_FILE_OPEN_FAILED, + HTTP_GET_ERR_DATA_FILE_WRITE_FAILED, +}; + + +int HTTPGetParserInit( HTTPGetParserStruct *parser, + char *server_ip, int server_port, + char *request_document, int request_start_byte, + char *dest_filename, + char *dest_buf, int dest_buf_size, + int close_connection_after_recv_data, + int null_terminate_data + ); + +char *HTTPGetParserGetRequestString( HTTPGetParserStruct *parser ); +int HTTPGetParserParseRecvdData( HTTPGetParserStruct *parser, char *data, int len ); + +int ResetHTTPGetParser( HTTPGetParserStruct *parser ); + + + +typedef struct HTTPGetClientStruct +{ + + SSLClientStateStruct clientstate; + HTTPGetParserStruct parser; + char recv_buf[HTTP_GET_BUFFER_SIZE]; + int state; + int parser_error; + int http_error; + int client_error; + +} HTTPGetClientStruct; + + +enum HTTPGetClientStates +{ + HTTP_GET_CLIENT_STATE_NORMAL, + HTTP_GET_CLIENT_STATE_DONE, + HTTP_GET_CLIENT_STATE_ERR, +}; + + +int InitHTTPGetClientStruct(HTTPGetClientStruct *client, + char *server_ip, int server_port, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + char *request_document, + int request_document_start_byte, + char *recv_filename, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout, + int ssl_renegotiate_bytes, int ssl_renegotiate_seconds, + int ignore_dates_on_server_cert ); + + +int UpdateHTTPGetClientStruct(HTTPGetClientStruct *client ); + +int ResetHTTPGetClientStruct(HTTPGetClientStruct *client ); + +int ResetHTTPGetClientStructRecvBuf(HTTPGetClientStruct *client ); + +int SetHTTPGetClientStructRequestDoc(HTTPGetClientStruct *client, char *request_document, int request_start_byte ); +int SetHTTPGetClientStructDest(HTTPGetClientStruct *client, char *dest_filename, char *dest_buf, int dest_buf_size ); + +int SetHTTPGetClientStructTimeOuts(HTTPGetClientStruct *client, int connect_timeout, int send_timeout, + int recv_timeout, int backoff_timeout ); + +int FreeHTTPGetClientStateStruct(HTTPGetClientStruct *client); + +int CloseHTTPGetClientConnection(HTTPGetClientStruct *client); + +/* +int FreeSSLhttpClientStateStruct(SSLhttpClientStateStruct *clientstate); + +int CloseSSLhttpClientConnection(SSLhttpClientStateStruct *clientstate); +*/ + +#endif + + diff --git a/include/pmrt_utils/audcrc.h b/include/pmrt_utils/audcrc.h new file mode 100755 index 0000000..b4499aa --- /dev/null +++ b/include/pmrt_utils/audcrc.h @@ -0,0 +1,47 @@ +// +// audcrc.h +// PM crc generator header +// +// Play Mechanix - Video Game System +// +// Copyright (c) 1998-2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 21 Mar 07 +// +#ifndef AUDCRC_H +#define AUDCRC_H + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned long AudCRC32(unsigned char *data, int len); + +#ifdef __cplusplus +} +#endif + +typedef struct +{ + unsigned int count; + unsigned long crc; +} RollingCRC32Handle; + +// these functions operate on a RollingCRCHandle +// general idea is mimic results of AudCRC but allow +// one to incrementally CRC data instead of having +// to CRC all the data at once, useful for calculating +// CRC of large files since you don't have to load the +// entire file int memory, instead you can just load n bytes at a time +// see AudCRCFile() for example of this... + +int AudInitRollingCRC32( RollingCRC32Handle *rcrc ); +int AudAddToRollingCRC32( RollingCRC32Handle *rcrc, unsigned char *data, int len); +unsigned long AudCalcRollingCRC32( RollingCRC32Handle *rcrc ); +unsigned long AudCRC32File(char *filename ); + + + +#endif // ndef AUDCRC_H +//EOF + diff --git a/include/pmrt_utils/cguardian.h b/include/pmrt_utils/cguardian.h new file mode 100755 index 0000000..264344a --- /dev/null +++ b/include/pmrt_utils/cguardian.h @@ -0,0 +1,67 @@ +// cguardian.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for guarding code against attackers +#ifndef CGUARD_H +#define CGUARD_H + + +// this bit of magic removes dbg strings from production code +// if you call prts_debug() to print them +#if SYS_BB + #if PRODUCTION + // replace calls to prts_dbg with null op, eating string along the way + #define prts_debug(...) + #else + #define prts_debug PrintDebug + #endif // PRODUCTION +#endif // SYS_BB +#if SYS_PC // VisStudio < VisStudio 2005 does not support variodic macros + #define prts_debug PrintDebug +#endif +void PrintDebug(char* format,...); + + +// Debugger Guard + +int CheckForDebugger(); + +int StartDebugGuard(); +int CheckDebugGuard(); + + +int DisableCoreDump(); + + +int CheckSharedLibs( int (*CheckCallback)(char *) ); + + +#define CGUARD_DECLARE_CODE_BLOCK(label) extern void CG_Code_Block_##label(); extern void _CG_Code_Block_##label(); +#define CGUARD_START_CODE_BLOCK(label) void CG_Code_Block_##label() {} +#define CGUARD_END_CODE_BLOCK(label) void _CG_Code_Block_##label() {} +#define CGUARD_CODE_BLOCK_LEN(label) (int) _CG_Code_Block_##label - (int) CG_Code_Block_##label +#define CGUARD_CODE_BLOCK_ADDR(label) (unsigned char *) CG_Code_Block_##label +#define CGUARD_CODE_BLOCK_OFFSET(label) (long) CG_Code_Block_##label - (long)_start + +#define CGUARD_DATA_BLOCK_ADDR &__data_start +#define CGUARD_DATA_BLOCK_OFFSET (long) &__data_start - (long)_start +#define CGUARD_DATA_BLOCK_LEN (long)&__bss_start - (long) &__data_start + +#define CGUARD_GLOBAL_VAR_ADDR(global_variable) &##global_variable +#define CGUARD_GLOBAL_VAR_LEN(global_variable) sizeof(##global_variable) +#define CGUARD_GLOBAL_VAR_OFFSET(global_variable) (long) ##global_variable - (long)_start + + +extern void _start(void); // true starting point of program +extern unsigned char *__data_start; +extern unsigned char *__bss_start; +extern unsigned char *_end; + + +void *GetCodeEntryPoint(char *filename); + +#endif + + + diff --git a/include/pmrt_utils/containerCommon.h b/include/pmrt_utils/containerCommon.h new file mode 100755 index 0000000..1c0593b --- /dev/null +++ b/include/pmrt_utils/containerCommon.h @@ -0,0 +1,24 @@ +// containerCommon.h +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +#ifndef _COMMON +#define _COMMON + +int CopyStrings(char **dest, const char *source); +void DebugOutput(const char *string); + +//will enlarge the destination buffer and copy source over +void StringConcat(char **dest, const char *src1, const char *src2); + +extern void* (*CustomMalloc)(size_t); +extern void (*CustomFree) (void *); + +#endif + + + + + diff --git a/include/pmrt_utils/containers.h b/include/pmrt_utils/containers.h new file mode 100755 index 0000000..5b3948a --- /dev/null +++ b/include/pmrt_utils/containers.h @@ -0,0 +1,99 @@ +// containers.h +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +#ifndef _TREE +#define _TREE + +#include + +#define _NULL 0 + +typedef enum _ContainerCommands +{ + TREE_ADD_NODE, TREE_ADD_NODE_AND_GO_DOWN +}ContainerCommands; + +typedef struct _ListNode +{ + struct _ListNode *next; + struct _ListNode *prev; + void *data; + size_t dataSize; +}ListNode; + +typedef struct _List +{ + ListNode *head; + ListNode *tail; + size_t numNodes; +}List; + +typedef struct _TreeNode +{ + int depth; + size_t dataSize; + void *data; + List childList; + struct _TreeNode *parent; +}TreeNode; + +typedef struct _BinaryTreeNode +{ + int depth; + size_t dataSize; + unsigned int key; + void *data; + struct _BinaryTreeNode *parent; + struct _BinaryTreeNode *left; + struct _BinaryTreeNode *right; +}BinaryTreeNode; + +typedef struct _Tree +{ + TreeNode *head; + TreeNode *currNode; + int numNodes; +}Tree; + +typedef struct _BinaryTree +{ + BinaryTreeNode *head; + int numNodes; +}BinaryTree; + +void ContainersSetMemoryFuncs( void* (*CustomMallocFunc)(size_t size), void (*CustomFreeFunc)(void *) ); + +void ListCreate(List *list); +ListNode *ListPushBack(List *list, void *data, size_t dataSize); +ListNode *ListPushFront(List *list, void *data, size_t dataSize); +ListNode *ListPopFront(List *list); +ListNode *ListPopBack(List *list); +ListNode *ListRemove(List *list, void *data); +void ListInsertBefore(List *list, ListNode *node, ListNode *nextNode); +void ListPop(List *list, ListNode *node); +void ListFree(List *list); +void ListFreeNode(ListNode *node); +int ListWalk(List *list, int (*OpFunc)(ListNode *, void *), void *data ); +ListNode *ListSearch(List *list, int (*SearchFunc)(ListNode *, void *), void *data, int match_number ); +ListNode *ListGetNthNode(List *list, int n ); +int ListCopy(List *src, List *dst); + + +void TreeCreate(Tree *tree); +void TreeDeleteNode(Tree *tree, TreeNode *removeNode); +void TreeFree(Tree *tree); +TreeNode *TreeAddNode(Tree *tree, void *data, size_t size, ContainerCommands behavior); +TreeNode *TreeGoUp(Tree *tree); +TreeNode *TreeGoDown(Tree *tree); + +void BinaryTreeCreate(BinaryTree *tree); +BinaryTreeNode *BinaryTreeAddNode(BinaryTree *tree, unsigned int dataSize, void *data, void *dataKey); +BinaryTreeNode *BinaryTreeFindNode(BinaryTree *tree, void* dataKey); + +#endif + + + diff --git a/include/pmrt_utils/dnslookup.h b/include/pmrt_utils/dnslookup.h new file mode 100755 index 0000000..ba3f8c2 --- /dev/null +++ b/include/pmrt_utils/dnslookup.h @@ -0,0 +1,18 @@ +// dnslookup.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + + +enum +{ + DNSLOOKUP_SUCCESS = 0, + DNSLOOKUP_INVALID_PARAMS, + DNSLOOKUP_BUSY, + DNSLOOKUP_DNS_ERROR, + DNSLOOKUP_THREAD_ERROR, + +} DNSQueryResults; + + +int DNSLookup(char *hostname, char *result, int result_len); diff --git a/include/pmrt_utils/filesys.h b/include/pmrt_utils/filesys.h new file mode 100755 index 0000000..fc20f4d --- /dev/null +++ b/include/pmrt_utils/filesys.h @@ -0,0 +1,215 @@ +// filesys.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#ifndef FILESYS_H +#define FILESYS_H + +#include "netsock.h" // gives us select on the PC + +#include + +#include + +#if SYS_BB +#include +#include +#include +#endif + +#if SYS_PC +#include +#endif + +// Directory walking structures +#define FS_MAX_FILENAME_LEN 256 + +#if SYS_PC +typedef struct { + struct _finddata_t file; + long hFile; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir + int done; +} FsDH; +#endif // SYS_PC + +#if SYS_BB +typedef struct { + DIR *dir; + struct dirent *ent; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir +} FsDH; +#endif // SYS_BB + +int FsOpenDir(FsDH *fdh, char *dirname ); +int FsCloseDir(FsDH *fdh); +char *FsReadDir(FsDH *fdh); + +int FsDirSize( char *dirname, int recurse ); +int FsDirWalk( char *dirname, int recurse, int actOnDirs, int (*OperationFunc)(char *, void *), void *data); + +int FsDirCountFiles(char *dirname, int recursive); // counts files in directory + +int FsMkDir( char *dirname, int make_parent_dirs ); +int FsRecursiveRmdir(char *dirname); + +// file info functions +int FsFileSize( const char *filename ); + + +unsigned int UtilGetFileSize(FILE *openFile); +int UtilReadFromFile(const char *fileName, const char *fopenFlags, char **buffer, unsigned int *bufferSize); + + +// wrappers for the usual fopen, fread/fwrite, fclose business +int FsLoadFile( char *filename, void **dest, int *dest_len, void *(*malloc_func)(size_t), void (*free_func)(void *) ); +int FsSaveFile( char *filename, void *data, int data_len ); + + +int FsFileCopy( char *srcfile, char *destfile ); +int FsFileMove( char *srcfile, char *destfile ); + + + +// returns FS_ERR_NONE if the file exists and is readable, FS_ERR_INVALID_FILE otherwise +int FsCheckIfFileExists( char *filename ); + +// wrappers for FsLoadFile/FsSaveFile that deal only with ints +// who knows that this is useful for but... +int FsSaveInt( char *filename, int val ); +int FsLoadInt( char *filename, int *val ); + + +enum { + FS_ERR_NONE, + FS_ERR_INVALID_PARAMS, + FS_ERR_INVALID_FILE, + FS_ERR_MALLOC_FAILED, + FS_ERR_WRITE_FAILED, + FS_ERR_READ_FAILED, + +} FS_ERR_CODES; + + + +// Threaded loading stuff +typedef struct { + int status; + char filename[FS_MAX_FILENAME_LEN]; + char mode[8]; + void *data; + int data_len; + void *(*malloc_func)(size_t); + void (*free_func)(void *); + int writing; + int mallocd; + int error; + FILE *fp; + int bytes_readorwrote; + int ERRNO; +} ThreadedFileIOHandle; + +enum { + THREADEDIO_STATUS_BUSY, + THREADEDIO_STATUS_COMPLETE, + THREADEDIO_STATUS_ERROR, +} ThreadedIO_Stati; + +enum { + THREADEDIO_ERR_NONE, + THREADEDIO_ERR_INVALID_PARAMS, + THREADEDIO_ERR_INVALID_HANDLE, + THREADEDIO_ERR_FAILED_TO_START_THREAD, + THREADEDIO_ERR_INVALID_FILE, + THREADEDIO_ERR_MALLOC_FAILED, + THREADEDIO_ERR_OPEN_FAILED, + THREADEDIO_ERR_READ_FAILED, + THREADEDIO_ERR_WRITE_FAILED, + THREADEDIO_ERR_UNKNOWN, + +} ThreadedIO_Error_Codes; + +// an all in one function, will open file and read/write entire contents to/from the passed buffer +// alternately a malloc and free func can be passed and a buffer will be created for read data +// use ThreadedFileIOHandle_GetData to get a ptr to resultant buffer +int ThreadedFileIOHandle_OpenSimple( ThreadedFileIOHandle *tfioh, char *filename, char *mode, + void *data, int data_len, + void *(*malloc_func)(size_t), void (*free_func)(void *) ); + +// opens manual threaded io file handle +// use ThreadedFileIOHandle_Read(), ThreadedFileIOHandle_Write() and ThreadedFileIOHandle_Close() +// to perform read/write/close operations +// use ThreadedFileIOHandle_CheckStatus() to spin while waiting for an operation to complete +int ThreadedFileIOHandle_Open( ThreadedFileIOHandle *tfioh, char *filename, char *mode ); + +// analogs for fread/fwrite +// use ThreadedFileIOHandle_CheckReadWriteBytes() to recover the actual number of +// bytes read/written from/to file (useful in event of an error) +int ThreadedFileIOHandle_Read( ThreadedFileIOHandle *tfioh, void *data, int len ); +int ThreadedFileIOHandle_Write( ThreadedFileIOHandle *tfioh, void *data, int len ); + +int ThreadedFileIOHandle_CheckReadWriteBytes( ThreadedFileIOHandle *tfioh ); + + +int ThreadedFileIOHandle_CheckStatus( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_CheckError( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_CheckErrorno( ThreadedFileIOHandle *tfioh ); + +void *ThreadedFileIOHandle_GetData( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_GetDataLen( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_Close( ThreadedFileIOHandle *tfioh ); + + + +// Non-blocking reading/writing +// note that reads/writes may block +// during the actual read/write +// just not before + +typedef struct { + int status; + char filename[FS_MAX_FILENAME_LEN]; + char mode[8]; + int fd; + + void *data; + int data_len; + int data_pos; + + //void *(*malloc_func)(size_t); + //void (*free_func)(void *); + int writing; + //int mallocd; + int error; + int ERRNO; +} NonBlockingIOHandle; + +enum { + NONBLOCKINGIO_STATUS_BUSY, + NONBLOCKINGIO_STATUS_COMPLETE, + NONBLOCKINGIO_STATUS_ERROR, +} NONBLOCKINGIO_Stati; + +enum { + NONBLOCKINGIO_ERR_NONE, + NONBLOCKINGIO_ERR_INVALID_PARAMS, + NONBLOCKINGIO_ERR_INVALID_HANDLE, + NONBLOCKINGIO_ERR_INVALID_FILE, + NONBLOCKINGIO_ERR_OPEN_FAILED, + NONBLOCKINGIO_ERR_SELECT_FAILED, + NONBLOCKINGIO_ERR_READ_FAILED, + NONBLOCKINGIO_ERR_WRITE_FAILED, + NONBLOCKINGIO_ERR_CLOSE_FAILED, + NONBLOCKINGIO_ERR_EOF, + NONBLOCKINGIO_ERR_UNKNOWN, + +} NONBLOCKINGIO_Error_Codes; + +int NonBlockingIO_OpenFile( NonBlockingIOHandle *nbioh, char *filename, char *mode ); +int NonBlockingIO_SetData( NonBlockingIOHandle *nbioh, void *data, int len ); +int NonBlockingIO_GetData( NonBlockingIOHandle *nbioh, void **data, int *len, int *pos ); +int NonBlockingIO_Update( NonBlockingIOHandle *nbioh ); +int NonBlockingIO_Close( NonBlockingIOHandle *nbioh ); + + +#endif diff --git a/include/pmrt_utils/icmpSock.h b/include/pmrt_utils/icmpSock.h new file mode 100755 index 0000000..2f512b6 --- /dev/null +++ b/include/pmrt_utils/icmpSock.h @@ -0,0 +1,23 @@ +#ifndef PRTS_ICMP_H +#define PRTS_ICMP_H + +#define PING_COMPLETE 0 +#define PING_NOHOST -2 +#define PING_MALLOC_FAIL -3 +#define PING_SOCKET_FAIL -4 +#define PING_SEND_FAIL -5 +#define PING_INVALID_SELECT -6 +#define PING_INVALID_RESULT -7 +#define PING_RECV_FAIL -8 +#define PING_ACTIVE -9 +#define PING_THREAD_FAILED -10 + +#ifdef SYS_PC +#include "icmpSock_pc.h" +#endif +#ifdef SYS_BB +#include "icmpSock_bb.h" +#endif + +#endif + diff --git a/include/pmrt_utils/icmpSock_bb.h b/include/pmrt_utils/icmpSock_bb.h new file mode 100755 index 0000000..be05100 --- /dev/null +++ b/include/pmrt_utils/icmpSock_bb.h @@ -0,0 +1,54 @@ +// icmpSock_bb.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef ICMPSOCK_H +#define ICMPSOCK_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define DEFDATALEN (64-ICMP_MINLEN) // default data length */ +#define MAXPACKET (ICMP_MINLEN) // max packet size +#define MAXIPLEN 60 +#define MAXICMPLEN 76 + +typedef struct timeval TimeVal; +typedef struct ip Ip; +typedef struct icmp Icmp; +typedef struct sockaddr_in SockAddr_In; +typedef struct hostent HostEnt; + +typedef struct _IcmpData +{ + HostEnt *host; + SockAddr_In to; + Icmp *icp; + Ip *ip; + TimeVal tv, start, end; + fd_set rfds; + u_char *packet, outpack[MAXPACKET]; + char hostNameBuf[MAXHOSTNAMELEN], hostName[255]; + int fromLength, retVal, time, packLength; + int sock; + +}IcmpData; + +int IcmpPing(IcmpData *icmpData); +int IcmpPingInitialize(IcmpData *outData, const char *target, unsigned int timeout); + +int PingQueryTime(); + +#endif + + diff --git a/include/pmrt_utils/icmpSock_pc.h b/include/pmrt_utils/icmpSock_pc.h new file mode 100755 index 0000000..7098617 --- /dev/null +++ b/include/pmrt_utils/icmpSock_pc.h @@ -0,0 +1,7 @@ +#ifndef ICMP_PC +#define ICMP_PC + +int IcmpPing(const char *target); +int PingQueryTime(); + +#endif \ No newline at end of file diff --git a/include/pmrt_utils/interfaceInfo.h b/include/pmrt_utils/interfaceInfo.h new file mode 100755 index 0000000..d63de1d --- /dev/null +++ b/include/pmrt_utils/interfaceInfo.h @@ -0,0 +1,20 @@ +#ifndef PMRT_NET_INTERFACE +#define PMRT_NET_INTERFACE + + +int NetGetHostName(char *name,unsigned int size); +int EthToolCableStatus(const char *interfaceName); +int GetDefaultGateway(char *gw_addr, int gw_addr_len, char *interfaceName, int interfaceName_len ); +int GetMacAddress(const char *interfaceName, char *outMacAddress); + +#ifdef SYS_PC + #include "interfaceInfo_pc.h" +#endif + +#ifdef SYS_BB + #include "interfaceInfo_bb.h" +#endif + + +#endif //PRMT_NET_INTERFACE + diff --git a/include/pmrt_utils/interfaceInfo_bb.h b/include/pmrt_utils/interfaceInfo_bb.h new file mode 100755 index 0000000..6c52536 --- /dev/null +++ b/include/pmrt_utils/interfaceInfo_bb.h @@ -0,0 +1,16 @@ +// interfaceInfo_bb.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef INTERFACE_INFO_H +#define INTERFACE_INFO_H + +#include + +int GetInterfaceIpAddress(const char *interfaceName, unsigned int *ipaddr, unsigned int *netmask); + +#endif + + + diff --git a/include/pmrt_utils/interfaceInfo_pc.h b/include/pmrt_utils/interfaceInfo_pc.h new file mode 100755 index 0000000..cd54f8f --- /dev/null +++ b/include/pmrt_utils/interfaceInfo_pc.h @@ -0,0 +1,14 @@ +// interfaceInfo_pc.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef INTERFACE_INFO_H +#define INTERFACE_INFO_H + +#include + +int GetInterfaceIpAddress(const char *interfaceName, unsigned int *ipaddr, unsigned int *netmask); + +#endif + diff --git a/include/pmrt_utils/memallochist.h b/include/pmrt_utils/memallochist.h new file mode 100755 index 0000000..16c23d6 --- /dev/null +++ b/include/pmrt_utils/memallochist.h @@ -0,0 +1,29 @@ +#ifndef MEMALLOCHIST_H +#define MEMALLOCHIST_H +// memallochist.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + + +#define MALLOC_HIST_SIZE 8000 + +struct malloc_rec +{ + void *addr; + int size; +}; + + +struct malloc_rec gMemAllocHistory[MALLOC_HIST_SIZE]; + +int InitMemAllocHistory(); +void AddToMemAllocHistory( void *addr, int size ); +void DelFromMemAllocHistory( void *addr ); +void PrintMemAllocHistory(); + + +#endif + + + diff --git a/include/pmrt_utils/microtime.h b/include/pmrt_utils/microtime.h new file mode 100755 index 0000000..b3703ad --- /dev/null +++ b/include/pmrt_utils/microtime.h @@ -0,0 +1,73 @@ +// microtime.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for obtaining time in micro second + +#ifndef MICROTIME_H +#define MICROTIME_H + +#include +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + + +#ifdef USE_INTERNAL_RDTSC +#define rdtsc(low,high) \ +__asm__ __volatile__(".byte 0x0f, 0x31" : "=a" (low), "=d" (high)) +#endif + +// returns time since system boot in micro seconds +uns64 GetSysElapsedMicroseconds(); + +// returns time since system boot in milli seconds +uns32 GetSysElapsedMilliseconds(); + +typedef struct PMRT_Timer +{ + uns64 start_time; + uns64 accumulated_time; + int running; +} PMRT_Timer; + +void PMRT_Timer_Start( PMRT_Timer *timer ); +void PMRT_Timer_Stop( PMRT_Timer *timer ); +void PMRT_Timer_Reset( PMRT_Timer *timer ); + +uns64 PMRT_Timer_GetElapsedMicroseconds( PMRT_Timer *timer ); +uns32 PMRT_Timer_GetElapsedMilliseconds( PMRT_Timer *timer ); + + + +int DateChangesBetweenDates(time_t firstTime_t, time_t secondTime_t, int noSign); + +#ifndef SYS_UTILS +#define SYS_UTILS +#define M_SYSTIMEDATE_GMT 0x0001 + +typedef struct { + int sec; // 0..61(?) + int min; // 0..59 + int hour; // 0..23 + int mday; // 1..31 + int mon; // 0..11 + int year; // eg 2005 + int wday; // 0..6 Sunday==0 + int yday; // since jan 1 0..365 + int isdst; // is daylight savings time +} SysDate_Utils; + +long SysDateTime_Utils(SysDate_Utils *dt,uns flags); +void SysCopytmToSysDate_Utils(void *tmv,SysDate_Utils *dt); + +#endif + + + + + + + +#endif // define MICROTIME_H + diff --git a/include/pmrt_utils/netclient.h b/include/pmrt_utils/netclient.h new file mode 100755 index 0000000..1740739 --- /dev/null +++ b/include/pmrt_utils/netclient.h @@ -0,0 +1,120 @@ +// netclient.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#ifndef NETCLIENT_H +#define NETCLIENT_H + +#include "netsock.h" +#include "microtime.h" + + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + + +/* +#define CLIENT_WAIT_CONNECT_TIMEOUT 5 +#define CLIENT_SEND_TIMEOUT 5 +#define CLIENT_RECV_TIMEOUT 5 +// how long to pause for after a failed connection/transmit err +#define CLIENT_BACKOFF_TIMEOUT 3 +*/ + +typedef struct ClientStateStruct +{ + char server_ip[32]; + int server_port; + int state; + int start_time; + int curr_state_start; + int retries; + int curr_state_retries; + NetSockHandle nsh; + int connected; + int error_code; + + int (*eod_check)(struct ClientStateStruct*); + + char *send_buf; + int send_buf_size; + char *recv_buf; + int recv_buf_size; + int recv_count; + + int null_terminate_recv_data; + int close_connection_after_recv_data; + + int connect_timeout; + int send_timeout; + int recv_timeout; + int backoff_timeout; + + + uns64 connect_start_time; + uns64 connect_time; + uns64 send_start_time; + uns64 send_time; + uns64 recv_start_time; + uns64 recv_time; + uns64 close_start_time; + uns64 close_time; + uns64 complete_time; + +} ClientStateStruct; + +enum ClientStates +{ + CLIENT_STATE_AVAILABLE, + CLIENT_STATE_OPEN_CONNECTION, + CLIENT_STATE_WAIT_FOR_CONNECTION, + CLIENT_STATE_SEND_DATA, + CLIENT_STATE_RECV_DATA, + CLIENT_STATE_RECV_COMPLETE, + CLIENT_STATE_CLOSE_CONNECTION, + CLIENT_STATE_DONE, + CLIENT_STATE_ERROR, + CLIENT_STATE_BACKOFF, +}; + + +enum ClientStateErrorCodes +{ + CLIENT_ERR_NONE, + CLIENT_ERR_CONNECT_FAILED, + CLIENT_ERR_SEND_FAILED, + CLIENT_ERR_RECV_FAILED, + CLIENT_ERR_CONNECT_TIMEDOUT, + CLIENT_ERR_SEND_TIMEDOUT, + CLIENT_ERR_RECV_TIMEDOUT, + CLIENT_ERR_RECV_BUFFER_FULL, +}; + + + + +int InitClientStateStruct(ClientStateStruct *clientstate, + char *server_ip, int server_port, + char *send_buf, int send_buf_size, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int (*eod_check)(struct ClientStateStruct*), + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout ); + + +int UpdateClientState(ClientStateStruct *clientstate); + +int ResetClientStateStructRecvBuf(ClientStateStruct *clientstate ); + +int SetClientStateStructSendBuf(ClientStateStruct *clientstate, char *send_buf, int send_buf_size ); +int SetClientStateStructRecvBuf(ClientStateStruct *clientstate, char *recv_buf, int recv_buf_size ); + +int CloseClientConnection(ClientStateStruct *clientstate); + +#endif + diff --git a/include/pmrt_utils/netsock.h b/include/pmrt_utils/netsock.h new file mode 100755 index 0000000..f195482 --- /dev/null +++ b/include/pmrt_utils/netsock.h @@ -0,0 +1,65 @@ +#ifndef NETSOCK_H +#define NETSOCK_H + + +// these guy pull in system include files and define the NetSockHandle struct +#ifdef SYS_PC +#include "netsock_pc.h" +#endif +#ifdef SYS_BB +#include "netsock_bb.h" +#endif + + + +enum +{ + NETSOCK_RESULT_SUCCESS, + NETSOCK_RESULT_PENDING, + NETSOCK_RESULT_INVALID_HANDLE, + NETSOCK_RESULT_INVALID_PARAMS, + NETSOCK_RESULT_WIN32_SOCK_INIT_FAILED, + NETSOCK_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION, + NETSOCK_RESULT_BIND_FAILED, + NETSOCK_RESULT_CONNECT_FAILED, + NETSOCK_RESULT_SOCKET_NOT_READY, + NETSOCK_RESULT_SOCKET_CLOSED, + NETSOCK_RESULT_EAGAIN, + NETSOCK_RESULT_FAILURE, +}; + +enum +{ + NETSOCK_STATUS_READY_SEND, + NETSOCK_STATUS_READY_RECV, + NETSOCK_STATUS_READY_SEND_AND_RECV, + NETSOCK_STATUS_NOT_READY, + NETSOCK_STATUS_CONNECT_PENDING, + NETSOCK_STATUS_INVALID_HANDLE, + NETSOCK_STATUS_SELECT_FAILED, + NETSOCK_STATUS_CONNECT_FAILED, + NETSOCK_STATUS_CLOSED, + +}; + + + + +int NetSockCheckConnectionStatus(NetSockHandle *handle); +int NetSockCloseConnection( NetSockHandle *handle ); + +int NetSockOpenClientTCPConnection( NetSockHandle *handle, char *remote_ip, int remote_port ); +int NetSockSendOutTCPConnection( NetSockHandle *handle, void *data, int *size ); +int NetSockRecvFromTCPConnection( NetSockHandle *handle, void *data, int *size ); + + +int NetSockSetBroadcast( NetSockHandle *handle, int enable ); + + +int NetSockOpenUDPSocket( NetSockHandle *handle, char *local_ip, int local_port ); + +int NetSockSendOutUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int remote_port ); +int NetSockRecvFromUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int *remote_port ); + + +#endif diff --git a/include/pmrt_utils/netsock_bb.h b/include/pmrt_utils/netsock_bb.h new file mode 100755 index 0000000..f7033f9 --- /dev/null +++ b/include/pmrt_utils/netsock_bb.h @@ -0,0 +1,45 @@ +#ifdef SYS_BB +// netsock.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef NETSOCKBB_H +#define NETSOCKBB_H + +// includes req for datatypes and err codes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +typedef struct +{ + int type; + int sd; + struct sockaddr_in src_addr; + struct sockaddr_in dst_addr; + int connected; + +} NetSockHandle; + + + + + +#endif + + +#endif + + diff --git a/include/pmrt_utils/netsock_pc.h b/include/pmrt_utils/netsock_pc.h new file mode 100755 index 0000000..e5c2964 --- /dev/null +++ b/include/pmrt_utils/netsock_pc.h @@ -0,0 +1,39 @@ +#ifdef SYS_PC +// netsock.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef NETSOCKPC_H +#define NETSOCKPC_H + +// includes req for datatypes and err codes +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include + + + + +typedef struct +{ + int type; + SOCKET sd; + struct sockaddr_in src_addr; + struct sockaddr_in dst_addr; + int connected; +} NetSockHandle; + + + + +#endif + + +#endif + + diff --git a/include/pmrt_utils/node.h b/include/pmrt_utils/node.h new file mode 100755 index 0000000..092b398 --- /dev/null +++ b/include/pmrt_utils/node.h @@ -0,0 +1,220 @@ +#ifndef NODE_H +#define NODE_H +// node.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// + +//#include "memallochist.h" + +#include +#include + +// Play Mechanix base types & system +typedef signed char int8; +typedef unsigned char uns8; +typedef signed short int16; +typedef unsigned short uns16; +typedef signed long int32; +typedef unsigned long uns32; + +#if SYS_PC +typedef __int64 int64; +typedef unsigned __int64 uns64; +#endif +#if SYS_BB +typedef long long int64; +typedef unsigned long long uns64; +#endif + +typedef int8 int2; +typedef uns8* ptr; +typedef float f32; +typedef unsigned int uns; +typedef uns sto; // unsigned, big enough for void*,float,int +typedef uns memu; +typedef int memi; + +#if SYS_PC +#define SYSBREAK() __asm {int 3} +#endif // SYS_PC + +#if SYS_BB +#define SYSBREAK() __asm__ ("int $3") +#endif // SYS_BB + + +#define BP(x) { SYSBREAK();} + + + +#define NUL ((void*)0) + +#define COUNT(array) (sizeof(array) / sizeof(array[0])) + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION TYPES + +enum { + FTYPE_NONE, + FTYPE_1, + FTYPE_2, + FTYPE_3, + FTYPE_4, + FTYPE_5, + FTYPE_6, + FTYPE_7, +}; + +typedef void (ftype1)(void); +typedef int (ftype2)(void*); +typedef int (ftype3)(void*,void*); +typedef int (ftype4)(int,void*,void*,void*); +typedef int (ftype5)(int); +typedef int (ftype6)(int,void*); +typedef int (ftype7)(void*,int); + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +typedef struct { + void *next; +} N1; + +enum { + N2TYPE_NONE, + N2TYPE_UNK, // valid node, but not typed yet + N2TYPE_RES, // resource type + N2TYPE_OBJ, // object type + N2TYPE_PROC, // proc type + N2TYPE_MSG, // msg type + N2TYPE_L2, // l2 link + N2TYPE_MAX +}; +#define M_N2TYPE 0x1f // flags will be in the top + +enum { + N2SUB_NONE, + N2SUB_KID=0xf2, // can be used to verify that this is a kid (not needed) +}; + +// keep this whole section up to date in DC + +#define M_N2_KIDLIST 0x0001 // has kid list +#define M_N2_KIDFIRST 0x0002 // process kid list first +#define M_N2_SKIP 0x0004 // don't process this node or any kids +#define M_N2_DEAD 0x0008 // node is dead (unlinked, aborted) +#define M_N2_LEVEL0 0x0010 // 0,1,2,3 +#define M_N2_LEVEL1 0x0020 // 0,1,2,3 +#define M_N2_LEVEL 0x0030 // 0,1,2,3 +#define S_N2_LEVEL 4 +#define M_N2_STRONG 0x0080 // strong node (don't normally kill) +#define M_N2_TYPE 0x0f00 // type can use 4 bits +#define M_N2_OPEN 0x1000 // node is open (for debugging) +#define M_N2_L2LINKED 0x2000 // linked into L2 list + + + +typedef struct { + // order is assumed by compiled (res_pc.c) and loaded data + void *next; + void *prev; + uns8 type; // type + uns8 sub; // subtype info + uns16 flags; // top 8 bits of flags are reserved for type +} N2; + + +#define N2KIDLIST(n) (((N2*)n)-1) +#define N2PARENT(n) (((N2*)n)+1) +#define N2L2(n) (((N2*)n)+1) // n2 to l2 +#define L2N2(n) (((N2*)n)-1) // l2 to n2 + +#define N2_DEPTH_MAX 8 +#define N2_DEPTH_DEFAULT 8 + + +void N1LinkTail(void *headp,void *node); +void N1LinkHead(void *headp,void *node); +int N1Unlink(void *headp,void *node); + +void N2Head(void *head); +void N2DontLink(void *node); +void N2LinkAfter(void *head,void *node); +void N2LinkBefore(void *head,void *node); +void N2Unlink(void *node); +int N2Count(void *node); +void* N2Parent(void *node); +char *N2Name(N2 *n,char **s2p); + +enum { + // return codes for the scan func + N2SCANFUNC_MATCH_AND_RETURN, + N2SCANFUNC_CONTINUE +}; + +typedef struct { + N2 *stack[8]; + int stacki; + N2 *wrapper; + ftype3 *func3; // int func(N2ScanRec *nsr,N2 *n) return N2SCANFUNC_ + memu fdata; // function data + char *s1; // match string s1 + char *s2; // match string s2 +} N2ScanRec; + +#define M_N2SCAN_VAL 0x0000ffff // used to pass values in +#define M_N2SCAN_SUB 0x00010000 // look for subtype +#define M_N2SCAN_FUNC 0x00020000 // function call +#define M_N2SCAN_NAME 0x00040000 // match the name +#define M_N2SCAN_PRIME 0x00100000 // find prime obj +#define M_N2SCAN_INIT 0x00200000 // this is the first call w/n2sr -- init +#define M_N2SCAN_DONTSCAN 0x00400000 // first and don't search (init only) +#define M_N2SCAN_NODEEPER 0x00800000 // dont scan deeper +#define M_N2SCAN_NOKIDS M_N2SCAN_NODEEPER // -- depricated +#define M_N2SCAN_WRAP 0x01000000 // wrap until start instead of till list end +#define M_N2SCAN_KIDSONLY 0x02000000 // kids only +void* N2Scan(N2ScanRec *n2sr,uns find,void *node); + +// generic search func for N2 list +void *N2Search( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *) ); +// generic operation func for N2 list +void N2Walk( void *StartNode, void *OperationParam, int (*OperationFunc)(void *, void *) ); +// Combo func, searches list for matching items and performs operation on them +void N2SearchAndOperate( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *), void *OperationParam, int (*OperationFunc)(void *, void *) ); + +// funcs for popping items off list +void *N2PopNode( void *Node ); +void *N2PopNext( void *Node ); +void *N2PopPrev( void *Node ); + + +int N2LevelSet(N2 *n,int lev); +int N2LevelGet(N2 *n); +int N2LevelCpy(N2 *dst,N2 *src); + +int N2AddDataNode( N2 *List , void *(*malloc_func)(size_t), void *data, int link_after); +int N2CountDataNodes( N2 *List ); + + +enum { + // must match resObjSubTable[], resObjSubSizes[] + OBJSUB_NONE, + OBJSUB_DATA, +}; + +// this one needs to match the same definition in core/obj.h +typedef struct { + N2 lnk; + uns32 oid; + void *data; +} ObjData; + +int N2CountDataNodes( N2 *List ); + + + +#endif // ndef NODE_H + + + diff --git a/include/pmrt_utils/pmrt_strings.h b/include/pmrt_utils/pmrt_strings.h new file mode 100755 index 0000000..5325fcd --- /dev/null +++ b/include/pmrt_utils/pmrt_strings.h @@ -0,0 +1,82 @@ +#ifndef PMRT_STRINGS +#define PMRT_STRINGS + + +#if SYS_PC // required to use snprintf on win32 (why MS? why?) +#define snprintf _snprintf +#endif + +//fill in destString with sourceString as many times as possible +void StringFill(char *destString, const char *sourceString, unsigned int destSize, unsigned int sourceSize); + +// strips new line and or carriage returns from string +void StringChomp(char *string); + +int StringInsertChar(char *dst, int len, char c, int frequency, int origin ); + +//get the name of a file from the path. Example c:\g3\main.c will put main.c in dest +//src is assumed to be null terminated +//outLen will be filled in with the length of the name. Set to NULL if not wanted +void StringGetNameFromPath(const char *src, char *dest, int destLen, int *outLen); + +//get the starting index of the file name from the path. Example c:\g3\main.c will return 6 +//src is assumed to be null terminated +//outLen will be filled in with the length of the name. Set to NULL if not wanted +int StringGetNameIndexFromPath(const char *src, int *outLen); + +//get the path from a path+fileName. Examplee c:\g3\main.c will put c:\g3\ into dest +//outLen will be filled in with the length of the path. Set to NULL if not wanted +void StringGetPath(const char *src, char *dest, int destLen, int *outLen); + +//get the ending index of the path. Example c:\g3\main.c will return 5 +//outLen will be filled in with the length of the path. Set to NULL if not wanted +int StringGetPathIndex(const char *src, int *outLen); + +// Copies text up to the first instance of 'c' from src to dest (useful for parsing comma seperated lists, etc) +int StringCopyUntilChar(const char *src, int start_index, int src_len, char *dest, int dest_len, char c ); + +// gets the index of the next instance of 'c' +int StringIndexOfNextChar(const char *src, int startIndex, int srcLen, char c); + +// gets the end index of the next word in a string not including white space or newline +// returns 0 on success, -1 on fail +int StringGetWordEndIndex(const char *const src, int startIndex, int *outEndIndex); + +//convert a hexidecimal string into an integer. Ex: 0xffffffff returns 4294967295 as does ffffffff +unsigned int StringHexToDecimal(const char *const src); + + +// similar to FindLineInTextFileByStartString but operates on passed string instead of a file +int FindLineInTextStringByStartString(const char *string, int string_len, int start_index, char *dst, int dst_len, const char *start_string, + int skip_start_string, int skip_whitespace ); + + +// returns 1 if c is whitespace (space, tab, newline, carriage return), 0 otherwise +int StringIsWhiteSpace(char c ); + +// returns index of first non-whitespace char in string +int StringFindFirstNonWhiteSpaceIndex(char *string ); + +// returns index of first whitespace char in string +int StringFindFirstWhiteSpaceIndex(char *string ); + + +// Copies text up to the first whitespace char from src to dest (useful for parsing comma seperated lists, etc) +int StringCopyUntilWhitespace( const char *src, int start_index, int src_len, char *dest, int dest_len ); + +unsigned int StringHash(char *string); + +unsigned int StringNHash(char *string, int len ); + + +// Changes the case of src and puts results in dest. +// - nonzero 'upperOrLower' is uppercase, 0 is lowercase. +// - src and dest may point to the same string. +// - returns 0 if no error, -1 if either pointer is null. +int StringChangeCase( char *src, char *dest, int upperOrLower ); + +#endif + +//EOF + + diff --git a/include/pmrt_utils/pmrt_utils.h b/include/pmrt_utils/pmrt_utils.h new file mode 100755 index 0000000..4e32945 --- /dev/null +++ b/include/pmrt_utils/pmrt_utils.h @@ -0,0 +1,38 @@ +// pmrt_utils.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef PMRT_UTLILITIES_H +#define PMRT_UTLILITIES_H + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + +#include "memallochist.h" +#include "netsock.h" +#include "netclient.h" +#include "thread.h" +#include "tsqueue.h" +#include "cguardian.h" +#include "microtime.h" +#include "containerCommon.h" +#include "containers.h" +#include "audcrc.h" +#include "icmpSock.h" +#include "dnslookup.h" +#include "interfaceInfo.h" +#include "textfile.h" +#include "filesys.h" +#include "pmrt_strings.h" +#include "rtdatatypes.h" + + +#define PMRT_UTILS_MAJOR_VERSION 1 +#define PMRT_UTILS_MINOR_VERSION 4 +#define PMRT_UTILS_SUB_MINOR_VERSION 0x01 + + +#endif + diff --git a/include/pmrt_utils/rtdatatypes.h b/include/pmrt_utils/rtdatatypes.h new file mode 100755 index 0000000..5eadd41 --- /dev/null +++ b/include/pmrt_utils/rtdatatypes.h @@ -0,0 +1,110 @@ +// rtdatatypes.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for parsing datatypes at runtime + +#ifndef RTDATATYPES_H +#define RTDATATYPES_H + +#include + +#define RTDT_MAX_FORM_NAME_LEN 32 + + +enum +{ + RTDT_RESULT_SUCCESS, + RTDT_RESULT_INVALID_PARAMS, + RTDT_RESULT_MALLOC_FAILED, + RTDT_RESULT_PARSE_FAILED, + RTDT_RESULT_DATATYPE_CREATION_FAILED, + RTDT_RESULT_UNKNOWN_DATATYPE, + RTDT_RESULT_MEMBER_NOT_FOUND, + RTDT_RESULT_LOAD_FAILED, + +}; + +// RTDataSmallString +// example of a type defined at compile time +// see top of rtdatatypes.c for rest of example +typedef struct RTDataSmallString +{ + char string[RTDT_MAX_FORM_NAME_LEN]; +} RTDataSmallString; + +typedef struct RTDataTwoSmallStrings +{ + RTDataSmallString strings[2]; +} RTDataTwoSmallStrings; + +typedef struct RTDataLongString +{ + char string[4*RTDT_MAX_FORM_NAME_LEN]; +} RTDataLongString; + + + +typedef struct RTDataTypeMemberForm +{ + char type[RTDT_MAX_FORM_NAME_LEN]; + unsigned int type_hash; + + char name[RTDT_MAX_FORM_NAME_LEN]; + unsigned int name_hash; + + int count; + size_t byte_aligned_size; // useful for walking form (may differ from size of the type) + +} RTDataTypeMemberForm; + + +typedef struct RTDataTypeForm +{ + char type[RTDT_MAX_FORM_NAME_LEN]; + unsigned int type_hash; + + size_t size; + + int member_count; + + RTDataTypeMemberForm *members; + +} RTDataTypeForm; + + +typedef struct RTDataTypeParser +{ + RTDataTypeForm **Forms; + int form_count; + int max_form_count; + int byte_alignment; + +} RTDataTypeParser; + + + + + +int RTDataTypeParser_Init( RTDataTypeParser *prtdtp, int byte_alignment ); + +int RTDataTypeParser_AddNewDataType( RTDataTypeParser *prtdtp, RTDataTypeForm *Form ); + +int RTDataTypeParser_AddNewDataTypeFromCStruct( RTDataTypeParser *prtdtp, char *c_def ); +int RTDataTypeParser_AddNewDataTypesFromCDefFile( RTDataTypeParser *prtdtp, char *filename ); + +RTDataTypeForm *RTDataTypeParser_GetType( RTDataTypeParser *prtdtp, char *type ); + +int RTDataTypeParser_SizeOf( RTDataTypeParser *prtdtp, char *type ); + + +void *RTDataTypeParser_GetMember( RTDataTypeParser *prtdtp, char *type, char *member, void *data, RTDataTypeForm **type_form, RTDataTypeMemberForm **member_form ); +int RTDataTypeParser_SetMember( RTDataTypeParser *prtdtp, char *type, char *member, void *data, void *value ); +int RTDataTypeParser_SetByString( RTDataTypeParser *prtdtp, char *type, char *member, void *data, char *value ); +int RTDataTypeParser_GetByString( RTDataTypeParser *prtdtp, char *type, char *member, void *data, char *value, int value_len ); + +int RTDataTypeParser_Tokenize( RTDataTypeParser *prtdtp, char *type, void *data, char *dest, int dest_len, char *seperator, char *wrapper ); +int RTDataTypeParser_DeTokenize( RTDataTypeParser *prtdtp, char *type, void *data, char *src, char *seperator, char *wrapper ); + + +#endif diff --git a/include/pmrt_utils/textfile.h b/include/pmrt_utils/textfile.h new file mode 100755 index 0000000..af71f53 --- /dev/null +++ b/include/pmrt_utils/textfile.h @@ -0,0 +1,72 @@ +// textfile.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for dealing with plain text files + +#ifndef TEXTFILE_H +#define TEXTFILE_H +#include + +// ReadLineFromTextFile() +// copies line number line_number in filename into dst +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// usefule for reading a specfic line from a file +// line numbers start counting from 1 +int ReadLineFromTextFile(const char *filename, char *dst, int dst_len, int line_number, int skip_whitespace ); + + +// ReadLinesFromTextFile() +// copies lines from start_line to end_line (inclusive) from filename into dst +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// line numbers start counting from 1 +// returns number of lines copied (maybe less than end_line - start_line, if reach +// int ReadLinesFromTextFile( char *filename, char *dst, int dst_len, int start_line, int end_line, int skip_whitespace ); + + +// FindLineInTextFileByStartString() +// copies first line in filename that starts with the string 'start_string' int dst +// if skip_start_string == 1, then copying starts after 'start_string' +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// usefule for reading files for format "Name: value" +int FindLineInTextFileByStartString(const char *filename, char *dst, int dst_len, const char *start_string, int skip_start_string, int skip_whitespace ); + + + + +/*! + \brief Get the number of lines in a file. Can either pass in a handle to an open file handle, or the name + of the file to open. One one is needed, so set the other to NULL + \param inFile handle to an open file + \param fileName name of the file to open + \return int number of lines read in +*/ +int FileGetNumLines(FILE *inFile, const char *fileName); + + +/*! + \brief Gets the starting positions of lines in a file. User can then use fseek(file, position, SEEK_SET) to + reach the starting points of the lines. If a file is passed in, its position will be unchanged + after the function returns. If a fileName is passed in, a file handle will be opened and closed. + \param inFile open file handle. Set to NULL if the name of the file is passed in + \param fileName name of the file to open. Set to NULL if a valid file handle is passed in + \param outBuffer buffer containing line positions + \param bufSize number of elements outBuffer can cold + \param lineSkipAmount number of lines to skip + \return int 0 on sucess, -1 on fail +*/ +int FileGetLinePositions(FILE *inFile, const char *fileName, int *outBuffer, int bufSize, int lineSkipAmount); + + + +// Writes passed string to file (if append set, then will append to end of file) +int WriteStringToFile(char *filename,char *string, int append); + + +#endif + +//EOF + diff --git a/include/pmrt_utils/thread.h b/include/pmrt_utils/thread.h new file mode 100755 index 0000000..9697a56 --- /dev/null +++ b/include/pmrt_utils/thread.h @@ -0,0 +1,56 @@ +// thread.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#ifndef THREAD_H +#define THREAD_H + +// system specific definitions +#ifdef SYS_PC +#include "thread_pc.h" +#endif +#ifdef SYS_BB +#include "thread_bb.h" +#endif + + +typedef void (*ThreadFunc)(int); + +typedef struct +{ + ThreadFunc Func; + int Arg; + +} ThreadStartInfo; + +enum +{ + THREAD_RESULT_SUCCESS, + THREAD_RESULT_INVALID_PARAMS, + THREAD_RESULT_MALLOC_FAILED, + THREAD_RESULT_THREAD_CREATION_FAILED, +}; + +int StartThread( ThreadHandle *handle, ThreadStartInfo *info); +void ThreadSleep( int millisec ); + + +enum { + MUTEX_RESULT_SUCCESS, + MUTEX_RESULT_UNKNOWN_ERROR, + MUTEX_RESULT_MUTEX_ALREADY_EXISTS, + MUTEX_RESULT_NO_SUCH_MUTEX, + MUTEX_RESULT_INVALID_HANDLE, + MUTEX_RESULT_MUTEX_ABANDONED, + MUTEX_RESULT_MUTEX_BUSY, +}; + +int InitMutex( MutexHandle *handle ); +int GetMutex( MutexHandle *handle ); +int FreeMutex( MutexHandle *handle ); +int DestroyMutex( MutexHandle *handle ); + + +#endif + diff --git a/include/pmrt_utils/thread_bb.h b/include/pmrt_utils/thread_bb.h new file mode 100755 index 0000000..cbd0c7c --- /dev/null +++ b/include/pmrt_utils/thread_bb.h @@ -0,0 +1,29 @@ +#ifdef SYS_BB + +#ifndef THREADBB_H +#define THREADBB_H + +// thread.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + + +#include +typedef struct _ThreadHandle +{ + pthread_t threadp; +} ThreadHandle; + +typedef struct +{ + pthread_mutex_t lock; +} MutexHandle; + + + +#endif + + +#endif + diff --git a/include/pmrt_utils/thread_pc.h b/include/pmrt_utils/thread_pc.h new file mode 100755 index 0000000..80801b1 --- /dev/null +++ b/include/pmrt_utils/thread_pc.h @@ -0,0 +1,35 @@ +#ifdef SYS_PC + +#ifndef THREADPC_H +#define THREADPC_H + +// thread.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + + + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +typedef struct _ThreadHandle +{ + HANDLE handle; + DWORD id; +} ThreadHandle; + + +typedef struct +{ + HANDLE handle; +} MutexHandle; + + +#endif + + +#endif + + diff --git a/include/pmrt_utils/tsqueue.h b/include/pmrt_utils/tsqueue.h new file mode 100644 index 0000000..a61011a --- /dev/null +++ b/include/pmrt_utils/tsqueue.h @@ -0,0 +1,50 @@ +#ifndef TSQUEUE_H +#define TSQUEUE_H + +// tsqueue.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +// Thread Safe Queue Structs/Funcs +#include "thread.h" + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + +typedef struct +{ + N2 Queue; + MutexHandle Mutex; + void *(*malloc_func)(size_t); + void (*free_func)(void *); + int size; + int max_size; // use 0 for infite size queue + +} ThreadSafeQueue; + + +enum +{ + TSQ_RESULT_SUCCESS, + TSQ_RESULT_INVALID_QUEUE, + TSQ_RESULT_INVALID_MALLOC_FUNC, + TSQ_RESULT_INVALID_FREE_FUNC, + TSQ_RESULT_INVALID_PARAMS, + TSQ_RESULT_MUTEX_CREATION_FAILED, + TSQ_RESULT_MUTEX_GET_FAILED, + TSQ_RESULT_QUEUE_BUSY, + TSQ_RESULT_QUEUE_EMPTY, + TSQ_RESULT_QUEUE_FULL, + TSQ_RESULT_MALLOC_FAILED, +}; + +int ThreadSafeQueueInit( ThreadSafeQueue *Queue, int max_size, void *(*malloc_func)(size_t), void (*free_func)(void *) ); +int ThreadSafeQueuePush( ThreadSafeQueue *Queue, void *data ); +int ThreadSafeQueuePop( ThreadSafeQueue *Queue, void **ppdata ); +int ThreadSafeQueueDeInit( ThreadSafeQueue *Queue ); +int ThreadSafeQueueGetCurrSize( ThreadSafeQueue *Queue ); + + +#endif + diff --git a/include/psm_engine/psm_engine.h b/include/psm_engine/psm_engine.h new file mode 100755 index 0000000..9d3cd07 --- /dev/null +++ b/include/psm_engine/psm_engine.h @@ -0,0 +1,287 @@ +// psm_engine.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for building/using programmable state machines + +#ifndef PSM_ENGINE_H +#define PSM_ENGINE_H + +#include + +#define PSM_MAX_NAME_LEN 32 + +#define PSM_PLAINTEXT_EVENTACTION "EVENTACTION" +#define PSM_PLAINTEXT_STATEMACHINEPARAM "SMPARAM" +#define PSM_PLAINTEXT_STATEMACHINENAME "STATEMACHINE" + + +struct PSM_ExeContext; // forward dec + +typedef struct PSM_State +{ + int number; + char name[PSM_MAX_NAME_LEN]; + char params_type[RTDT_MAX_FORM_NAME_LEN]; + int params_size; + + unsigned int flags; + int (*StateFunc)(struct PSM_ExeContext *, void *, void *, uns32 * ); + +} PSM_State; + + +typedef struct PSM_StateRecord +{ + uns32 elapsed_time; + + unsigned int updates; + + PSM_State *state; + void *params; + int params_size; + +} PSM_StateRecord; + + +typedef struct PSM_ProgramInstruction +{ + char state_name[PSM_MAX_NAME_LEN]; + int state_number; + void *params; + int params_size; +} PSM_ProgramInstruction; + + +typedef struct PSM_ProgramEventAction +{ + char event_name[PSM_MAX_NAME_LEN]; + PSM_ProgramInstruction instruction; + +} PSM_ProgramEventAction; + +typedef struct PSM_ProgramStateMachineParam +{ + char param_name[RTDT_MAX_FORM_NAME_LEN*4]; // give a little extra room to allow for array and sub-member setting + char value[PSM_MAX_NAME_LEN]; +} PSM_ProgramStateMachineParam; + +typedef struct PSM_Program +{ + char name[PSM_MAX_NAME_LEN]; + char statemachine_name[PSM_MAX_NAME_LEN]; + + List instructions; + + List eventactions; + + List statemachineparams; + + + RTDataTypeParser *prtdtp; + +} PSM_Program; + + + + + + +typedef struct PSM_StateMachine +{ + char name[PSM_MAX_NAME_LEN]; + char params_type[RTDT_MAX_FORM_NAME_LEN]; + int params_size; + + List states; + + RTDataTypeParser *prtdtp; + +} PSM_StateMachine; + + + + + +typedef struct PSM_ExeContext +{ + + + PSM_StateMachine *statemachine; + + void *statemachine_params; + + PSM_Program *program; + + int curr_instruction_number; + + + // StateFunc's are allowed to modify the passed in params and these changes are held over + // until the ExeContext advances to the next instruction + // hence we have two buffers that we copy the initial state params from our program into + // before executing each instruction + void *state_params_buf; // buffer into which we put a copy of the state params for each instruction before it's executed + void *eaction_state_params_buf; // same, but used when we are executing an event action + + + unsigned int elapsed_time; + +// unsigned int last_update; +// unsigned int update_elapsed_time; + + unsigned int updates; + + // data for most recent event + void *event_data; + + RTDataTypeParser *prtdtp; + + + + + // b/c the event actions may change + // as the program runs, we need to maintain + // a seperate list for each ExeContext + // list is copied from program on init + List eventactions; + + // put all the mem bufs we malloc for on a list + // makes it easier to clean up + List membufs; + + + // list of instruction numbers to return to + List return_stack; + + // current state data stored in here + PSM_StateRecord state_rec; + + // use this guy for keeping time if no time supplied + PMRT_Timer timer; + + +} PSM_ExeContext; + + +enum +{ + PSM_SUCCESS, + PSM_INVALID_HANDLE, + PSM_INVALID_PARAMS, + PSM_MALLOC_FAILURE, + PSM_LIST_FAILURE, + PSM_FILE_FAILURE, + PSM_FAILURE, + PSM_PROGRAM_HALTED, + PSM_PROGRAM_COMPLETED, + PSM_INVALID_STATE, + +} PSM_ERROR_CODES; + + +enum +{ +// timing + PSM_BUILTIN_STATE_MSLEEP, + PSM_BUILTIN_STATE_SLOOP, + +// flow control + PSM_BUILTIN_STATE_LABEL, + PSM_BUILTIN_STATE_GOTO, + PSM_BUILTIN_STATE_GOSUB, + PSM_BUILTIN_STATE_RETURN, + PSM_BUILTIN_STATE_INTERRUPT, + PSM_BUILTIN_STATE_EXIT, + +// variables + PSM_BUILTIN_STATE_SET_PARAM, + +// debug + PSM_BUILTIN_STATE_PRINT, + PSM_BUILTIN_STATE_SINGLECOMMENT, + PSM_BUILTIN_STATE_STARTCOMMENT, + PSM_BUILTIN_STATE_COMMENTLINE, + PSM_BUILTIN_STATE_ENDCOMMENT, + + NUM_PSM_BUILTIN_STATES, +} PSM_BUILTIN_STATES; + + +enum +{ + PSM_RETURN_WAIT, // wait for next update call + PSM_RETURN_CONTINUE, // continue w/o waiting for next update call + PSM_RETURN_NEXT_INSTRUCTION, // proceed to next instuction w/o waiting for next update call + PSM_RETURN_QUIT, // stop program execution +} PSM_STATE_RETURN_CODES; + + +int PSM_Engine_Init( RTDataTypeParser *prtdtp ); + + +int PSM_State_Init( PSM_State *state, int number, char *name, char *params_type, int params_size, int (*StateFunc)(PSM_ExeContext *,void *,void *, uns32 * ) ); + + +int PSM_StateMachine_Init( PSM_StateMachine *statemachine, char *name, char *params_type, RTDataTypeParser *prtdtp ); +int PSM_StateMachine_AddBuiltInStates( PSM_StateMachine *statemachine ); +int PSM_StateMachine_AddStates( PSM_StateMachine *statemachine, PSM_State *states, int count ); + +PSM_State *PSM_StateMachine_FindStateByName( PSM_StateMachine *statemachine, char *name ); +int PSM_StateMachine_FindLargestParamSize( PSM_StateMachine *statemachine ); + +int PSM_StateMachine_DeInit( PSM_StateMachine *statemachine ); +int PSM_StateMachine_Document( PSM_StateMachine *statemachine, char *filename, int show_types ); + +int PSM_Program_Init( PSM_Program *program, char *name, char *statemachine_name ); +int PSM_Program_AddInstructions( PSM_Program *program, PSM_ProgramInstruction *instructions, int count, int start_pos ); +int PSM_Program_DropInstructions( PSM_Program *program, int count, int start_pos ); +PSM_ProgramInstruction *PSM_Program_GetInstruction( PSM_Program *program, int pos ); +int PSM_Program_FindLabel( PSM_Program *program, char *label ); + + +int PSM_Program_AddEventActions( PSM_Program *program, PSM_ProgramEventAction *eventactions, int count ); +int PSM_Program_DropEventAction( PSM_Program *program, char *event_name ); +PSM_ProgramEventAction *PSM_Program_GetEventAction( PSM_Program *program, char *event_name ); + +int PSM_Program_AddStateMachineParams( PSM_Program *program, PSM_ProgramStateMachineParam *statemachineparams, int count ); +int PSM_Program_DropStateMachineParam( PSM_Program *program, char *param_name ); +int PSM_Program_SetStateMachineParam( PSM_Program *program, char *param_name, char *value ); +PSM_ProgramStateMachineParam *PSM_Program_GetStateMachineParam( PSM_Program *program, char *param_name ); + + +int PSM_Program_DeInit( PSM_Program *program ); + +int PSM_Program_LoadFromPlainTextFile( PSM_Program *program, PSM_StateMachine *statemachine, char *filename ); +int PSM_Program_SaveToPlainTextFile( PSM_Program *program, PSM_StateMachine *statemachine, char *filename ); + +int PSM_Program_CompileForStateMachine( PSM_Program *program, PSM_StateMachine *statemachine ); + + +int PSM_ExeContext_Init( PSM_ExeContext *context, PSM_StateMachine *statemachine, void *statemachine_params, PSM_Program *program ); +int PSM_ExeContext_Update( PSM_ExeContext *context, uns32 *elapsed_time ); +int PSM_ExeContext_DoEvent( PSM_ExeContext *context, char *event_name, void *event_data ); +int PSM_ExeContext_DeInit( PSM_ExeContext *context ); +int PSM_ExeContext_AddEventActions( PSM_ExeContext *context, PSM_ProgramEventAction *eventactions, int count ); +int PSM_ExeContext_DropEventAction( PSM_ExeContext *context, char *event_name ); +PSM_ProgramEventAction *PSM_ExeContext_GetEventAction( PSM_ExeContext *context, char *event_name ); +int PSM_ExeContext_SetActiveInstruction( PSM_ExeContext *context, PSM_ProgramInstruction *instruction ); + + +int PSM_BuiltInStateFunc_MSleep( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Sloop( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time); + +int PSM_BuiltInStateFunc_SingleComment( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_StartComment( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_EndComment( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Print( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); + +int PSM_BuiltInStateFunc_Goto( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_GoSub( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Return( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Interrupt( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_SetParam( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Exit( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); + + + +#endif // PSM_ENGINE_H diff --git a/include/rockey.h b/include/rockey.h new file mode 100755 index 0000000..ab80356 --- /dev/null +++ b/include/rockey.h @@ -0,0 +1,59 @@ +#ifndef __ROCKEY__H +#define __ROCKEY__H +#define RY_FIND 1 +#define RY_FIND_NEXT 2 +#define RY_OPEN 3 +#define RY_CLOSE 4 +#define RY_READ 5 +#define RY_WRITE 6 +#define RY_RANDOM 7 +#define RY_SEED 8 +#define RY_WRITE_USERID 9 +#define RY_READ_USERID 10 +#define RY_SET_MODULE 11 +#define RY_CHECK_MODULE 12 +#define RY_WRITE_ARITHMETIC 13 +#define RY_CALCULATE1 14 +#define RY_CALCULATE2 15 +#define RY_CALCULATE3 16 +#define RY_DECREASE 17 + +/*return code*/ +#define ERR_SUCCESS 0 +#define ERR_NO_PARALLEL_PORT 1 +#define ERR_NO_DRIVER -1 +#define ERR_NO_ROCKEY 3 +#define ERR_INVALID_PASSWORD 4 +#define ERR_INVALID_PASSWORD_OR_ID 5 +#define ERR_SETID 6 +#define ERR_INVALID_ADDR_OR_SIZE 7 +#define ERR_UNKNOWN_COMMAND 8 +#define ERR_NOTBELEVEL3 9 +#define ERR_READ 10 +#define ERR_WRITE 11 +#define ERR_RANDOM 12 +#define ERR_SEED 13 +#define ERR_CALCULATE 14 +#define ERR_NO_OPEN 15 +#define ERR_NOMORE 17 +#define ERR_NEED_FIND 18 +#define ERR_DECREASE 19 +#define ERR_AR_BADCOMMAND 20 +#define ERR_AR_UNKNOWN_OPCODE 21 +#define ERR_AR_WRONGBEGIN 22 +#define ERR_AR_WRONG_END 23 +#define ERR_AR_VALUEOVERFLOW 24 +#define ERR_UNKNOWN 0xffff +#define ERR_RECEIVE_NULL 0x100 +#define ERR_PRNPORT_BUSY 0x101 + +#ifdef __cplusplus +extern "C" { +#endif + +short rockey(unsigned short function,unsigned short *handle,unsigned long *lp1,unsigned long *lp2,unsigned short *p1,unsigned short *p2,unsigned short *p3,unsigned short *p4,unsigned char *buffer); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/telemetry/bitbyte.h b/include/telemetry/bitbyte.h new file mode 100755 index 0000000..ccb8586 --- /dev/null +++ b/include/telemetry/bitbyte.h @@ -0,0 +1,63 @@ +#ifndef _BIT_BYTE_ +#define _BIT_BYTE_ +#include + +typedef struct _BitBytePacket +{ + unsigned int recv; + unsigned int sent; +}BitBytePacket; + +typedef struct _BitByteDataInfo //where interface is eth0, ppp, ... +{ + int size; //number of elements allocated + int count; //number of elements used +}BitByteDataInfo; + +typedef struct _BitByteTimer +{ + char name[80]; + int timeInterval; //time period in which the timer works in in hours (1 day, 7 days, 30 days...) +}BitByteTimer; + +typedef struct _BitByteData +{ + char name[20]; //name of the interface + BitBytePacket prevCount; //previous eth data read from machine + BitByteDataInfo info; + BitBytePacket *data; //collected data +}BitByteData; + +typedef struct _BitByteSaveData //used for saving/loading data +{ + BitByteData bitByteData; + time_t prevCollectTime; //time data was previously collected +}BitByteSaveData; + +typedef struct _BitByteInterface +{ + BitByteData *bitByteData; + BitByteTimer *timers; //timer data - same for all interfaces + BitBytePacket *copyBuf; //used for shifting interface data + time_t prevCollectTime; //time data was previously collected + int interval; //interval in hours which the data will be collected + int numTimers; //number of BitByteTimers + int numInterfaces; //number of elements in bitByteData +}BitByteInterfaces; + +int BitByteInitialize(const char *xmlData, int xmlDataSize); +int BitByteFill(const BitByteSaveData *inData); +int BitByteUpdate(void); +int BitByteGetTimerData(BitByteTimer *outTimer, BitBytePacket *outData, int timer, const char *interfaceName); +int BitByteGetNumTimers(void); +int BitByteGetCurrData(const char *interfaceName, BitBytePacket *outData); +int BitByteGetAllData(const char *interfaceName, int timer, BitBytePacket *outData); +int BitByteGetNumValidIntervals(const char *interfaceName, int timer); +int BitByteGetMaxValue(const char *interfaceName, int timer, BitBytePacket *outPacket); + +const BitByteInterfaces* BitByteGetInterfaces(void); + +#endif + +//EOF + diff --git a/include/telemetry/telemetry.h b/include/telemetry/telemetry.h new file mode 100755 index 0000000..2d84b88 --- /dev/null +++ b/include/telemetry/telemetry.h @@ -0,0 +1,72 @@ + // telemetry.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_TELEMETRY +#define PMRT_TELEMETRY + +#include "telemetryXml.h" +#include +#include +#include + +typedef struct _QueryData +{ + int dataId; + float data; + char misc[256]; + char *postFix; + char *name; +}QueryData; + +typedef struct _NetByteData +{ + uns64 bytesSentEth0; + uns64 bytesRecievedEth0; + uns64 bytesSentPpp0; + uns64 bytesRecievedPpp0; +}NetByteData; + +typedef struct _SystemNetNode +{ + SysDate_Utils recordTime; //when it was recorded + uns32 dataCount; + uns32 dataSize; + uns32 timeInterval; + char *title; + NetByteData *data; + NetByteData *dataCopyBuf; + +}SystemNetNode; + +int TelemetryInitialize(const char *telemLookUpTable, const char *telemFields, int lutSize, int fieldSize); + +unsigned int TelemetryCollectData(); + +//need to call when game shut downs inorder to avoid memleaks +void TelemetryShutDown(); + +//needs to be called continuously +int TelemetryUpdateNetTimers(); + +int TelemetryGetNumNetTimers(); + +int TelemetryGetNetData(int timerIndex, NetByteData *outData); + +int TelemetryFillNetData(NetByteData *data, uns32 *dataCount, uns32 *dataSize, uns32 numTimers, time_t recordTime); + +int TelemetryGetNextNetUpdate(); + +int TelemetryGetNetInterval(int timer); //returns in days + +extern QueryData *telemetryData; +extern SystemNetNode *systemNetNodes; +extern NetByteData currNetData; + +#define MAX_NET_TIMERS 5 + +#endif + + + + diff --git a/include/telemetry/telemetryXml.h b/include/telemetry/telemetryXml.h new file mode 100755 index 0000000..2668b4e --- /dev/null +++ b/include/telemetry/telemetryXml.h @@ -0,0 +1,58 @@ +// telemetryXml.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_TELEMETRY_XML +#define PMRT_TELEMETRY_XML +#include + +typedef enum _TelemetryEnum +{ + TELEMETRY_ERRUNKNOWN, + TELEMETRY_INVALID_FILE, + TELEMETRY_SUCCESS +}TelemetryEnum; + +typedef struct _TelemetryQueryDef +{ + float version; + unsigned int numAttributes; + unsigned int numElements; +}TelemetryQueryDef; + +typedef struct _TelemetryQueryNode +{ + unsigned char *name; + unsigned char *value; +}TelemetryQueryNode; + +typedef struct _TelemetryQuery +{ + List attributes; //list + List elements; //list +}TelemetryQuery; + +typedef struct _NetNodeTimeTrigger +{ + char *title; + uns32 days; + uns32 weeks; + uns32 months; +}NetNodeTrigger; + +int TelemXMLInitializeFromXML (const char *lutData, int lutSize, const char *fieldData, int fieldSize, + List *queryList, List *names, List *netNodes, + int *netCollectionInterval); + +List* TelemXMLFindQuery(List *telemQueries, const char *nodeName, const char *valueName); + +void TelemXMLFreeTelemetryQueries(List *queryList); +TelemetryQueryNode *TelemXMLFindQueryNode (const char *name, List *queryNodes); + +#endif + +//EOF + + + + diff --git a/include/theora/theora.h b/include/theora/theora.h new file mode 100755 index 0000000..20849db --- /dev/null +++ b/include/theora/theora.h @@ -0,0 +1,474 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: + last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $ + + ********************************************************************/ + +#ifndef _O_THEORA_H_ +#define _O_THEORA_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifndef LIBOGG2 +#include +#else +#include +/* This is temporary until libogg2 is more complete */ +ogg_buffer_state *ogg_buffer_create(void); +#endif + +/** \mainpage + * + * \section intro Introduction + * + * This is the documentation for the libtheora C API. + * libtheora is the reference implementation for + * Theora, a free video codec. + * Theora is derived from On2's VP3 codec with improved integration for + * Ogg multimedia formats by Xiph.Org. + */ + +/** \file + * The libtheora C API. + */ + +/** + * A YUV buffer for passing uncompressed frames to and from the codec. + * This holds a Y'CbCr frame in planar format. The CbCr planes can be + * subsampled and have their own separate dimensions and row stride + * offsets. Note that the strides may be negative in some + * configurations. For theora the width and height of the largest plane + * must be a multiple of 16. The actual meaningful picture size and + * offset are stored in the theora_info structure; frames returned by + * the decoder may need to be cropped for display. + * All samples are 8 bits. + */ +typedef struct { + int y_width; /**< width of the Y' luminance plane */ + int y_height; /**< height of the luminance plane */ + int y_stride; /**< offset in bytes between successive rows */ + + int uv_width; /**< height of the Cb and Cr chroma planes */ + int uv_height; /**< width of the chroma planes */ + int uv_stride; /**< offset between successive chroma rows */ + unsigned char *y; /**< pointer to start of luminance data */ + unsigned char *u; /**< pointer to start of Cb data */ + unsigned char *v; /**< pointer to start of Cr data */ + +} yuv_buffer; + +/** + * A Colorspace. + */ +typedef enum { + OC_CS_UNSPECIFIED, /**< the colorspace is unknown or unspecified */ + OC_CS_ITU_REC_470M, /**< best option for 'NTSC' content */ + OC_CS_ITU_REC_470BG, /**< best option for 'PAL' content */ + OC_CS_NSPACES /* mark the end of the defined colorspaces */ +} theora_colorspace; + +/** + * A Chroma subsampling + * + * These enumerate the available chroma subsampling options supported + * by the theora format. See Section 4.4 of the specification for + * exact definitions. + */ +typedef enum { + OC_PF_420, /**< Chroma subsampling by 2 in each direction (4:2:0) */ + OC_PF_RSVD, /**< reserved value */ + OC_PF_422, /**< Horizonatal chroma subsampling by 2 (4:2:2) */ + OC_PF_444, /**< No chroma subsampling at all (4:4:4) */ +} theora_pixelformat; + +/** + * Theora bitstream info. + * Contains the basic playback parameters for a stream, + * corresponds to the initial 'info' header packet. + * + * Encoded theora frames must be a multiple of 16 is size; + * this is what the width and height members represent. To + * handle other sizes, a crop rectangle is specified in + * frame_height and frame_width, offset_x and offset_y. The + * offset and size should still be a power of 2 to avoid + * chroma sampling shifts. + * + * Frame rate, in frames per second is stored as a rational + * fraction. So is the aspect ratio. Note that this refers + * to the aspect ratio of the frame pixels, not of the + * overall frame itself. + * + * see the example code for use of the other parameters and + * good default settings for the encoder parameters. + */ +typedef struct { + ogg_uint32_t width; + ogg_uint32_t height; + ogg_uint32_t frame_width; + ogg_uint32_t frame_height; + ogg_uint32_t offset_x; + ogg_uint32_t offset_y; + ogg_uint32_t fps_numerator; + ogg_uint32_t fps_denominator; + ogg_uint32_t aspect_numerator; + ogg_uint32_t aspect_denominator; + theora_colorspace colorspace; + int target_bitrate; + int quality; /**< nominal quality setting, 0-63 */ + int quick_p; /**< quick encode/decode */ + + /* decode only */ + unsigned char version_major; + unsigned char version_minor; + unsigned char version_subminor; + + void *codec_setup; + + /* encode only */ + int dropframes_p; + int keyframe_auto_p; + ogg_uint32_t keyframe_frequency; + ogg_uint32_t keyframe_frequency_force; /* also used for decode init to + get granpos shift correct */ + ogg_uint32_t keyframe_data_target_bitrate; + ogg_int32_t keyframe_auto_threshold; + ogg_uint32_t keyframe_mindistance; + ogg_int32_t noise_sensitivity; + ogg_int32_t sharpness; + + theora_pixelformat pixelformat; + +} theora_info; + +/** Codec internal state and context. + */ +typedef struct{ + theora_info *i; + ogg_int64_t granulepos; + + void *internal_encode; + void *internal_decode; + +} theora_state; + +/** + * Comment header metadata. + * + * This structure holds the in-stream metadata corresponding to + * the 'comment' header packet. + * + * Meta data is stored as a series of (tag, value) pairs, in + * length-encoded string vectors. The first occurence of the + * '=' character delimits the tag and value. A particular tag + * may occur more than once. The character set encoding for + * the strings is always utf-8, but the tag names are limited + * to case-insensitive ascii. See the spec for details. + * + * In filling in this structure, theora_decode_header() will + * null-terminate the user_comment strings for safety. However, + * the bitstream format itself treats them as 8-bit clean, + * and so the length array should be treated as authoritative + * for their length. + */ +typedef struct theora_comment{ + char **user_comments; /**< an array of comment string vectors */ + int *comment_lengths; /**< an array of corresponding string vector lengths in bytes */ + int comments; /**< the total number of comment string vectors */ + char *vendor; /**< the vendor string identifying the encoder, null terminated */ + +} theora_comment; + +#define OC_FAULT -1 /**< general failure */ +#define OC_EINVAL -10 /**< library encountered invalid internal data */ +#define OC_DISABLED -11 /**< requested action is disabled */ +#define OC_BADHEADER -20 /**< header packet was corrupt/invalid */ +#define OC_NOTFORMAT -21 /**< packet is not a theora packet */ +#define OC_VERSION -22 /**< bitstream version is not handled */ +#define OC_IMPL -23 /**< feature or action not implemented */ +#define OC_BADPACKET -24 /**< packet is corrupt */ +#define OC_NEWPACKET -25 /**< packet is an (ignorable) unhandled extension */ + +/** + * Retrieve a human-readable string to identify the encoder vendor and version. + * \returns a version string. + */ +extern const char *theora_version_string(void); + +/** + * Retrieve a 32-bit version number. + * This number is composed of a 16-bit major version, 8-bit minor version + * and 8 bit sub-version, composed as follows: +
+   (VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)
+
+* \returns the version number. +*/ +extern ogg_uint32_t theora_version_number(void); + +/** + * Initialize the theora encoder. + * \param th The theora_state handle to initialize for encoding. + * \param ti A theora_info struct filled with the desired encoding parameters. + * \returns 0 Success + */ +extern int theora_encode_init(theora_state *th, theora_info *c); + +/** + * Submit a YUV buffer to the theora encoder. + * \param t A theora_state handle previously initialized for encoding. + * \param yuv A buffer of YUV data to encode. + * \retval OC_EINVAL Encoder is not ready, or is finished. + * \retval -1 The size of the given frame differs from those previously input + * \retval 0 Success + */ +extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv); + +/** + * Request the next packet of encoded video. + * The encoded data is placed in a user-provided ogg_packet structure. + * \param t A theora_state handle previously initialized for encoding. + * \param last_p whether this is the last packet the encoder should produce. + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to encoded + * data. The memory for the encoded data is owned by libtheora. + * \retval 0 No internal storage exists OR no packet is ready + * \retval -1 The encoding process has completed + * \retval 1 Success + */ +extern int theora_encode_packetout( theora_state *t, int last_p, + ogg_packet *op); + +/** + * Request a packet containing the initial header. + * A pointer to the header data is placed in a user-provided ogg_packet + * structure. + * \param t A theora_state handle previously initialized for encoding. + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to the header + * data. The memory for the header data is owned by libtheora. + * \retval 0 Success + */ +extern int theora_encode_header(theora_state *t, ogg_packet *op); + +/** + * Request a comment header packet from provided metadata. + * A pointer to the comment data is placed in a user-provided ogg_packet + * structure. + * \param tc A theora_comment structure filled with the desired metadata + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to the encoded + * comment data. The memory for the comment data is owned by + * libtheora. + * \retval 0 Success + */ +extern int theora_encode_comment(theora_comment *tc, ogg_packet *op); + +/** + * Request a packet containing the codebook tables for the stream. + * A pointer to the codebook data is placed in a user-provided ogg_packet + * structure. + * \param t A theora_state handle previously initialized for encoding. + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to the codebook + * data. The memory for the header data is owned by libtheora. + * \retval 0 Success + */ +extern int theora_encode_tables(theora_state *t, ogg_packet *op); + +/** + * Decode an Ogg packet, with the expectation that the packet contains + * an initial header, comment data or codebook tables. + * + * \param ci A theora_info structure to fill. This must have been previously + * initialized with theora_info_init(). If \a op contains an initial + * header, theora_decode_header() will fill \a ci with the + * parsed header values. If \a op contains codebook tables, + * theora_decode_header() will parse these and attach an internal + * representation to \a ci->codec_setup. + * \param cc A theora_comment structure to fill. If \a op contains comment + * data, theora_decode_header() will fill \a cc with the parsed + * comments. + * \param op An ogg_packet structure which you expect contains an initial + * header, comment data or codebook tables. + * + * \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet + * has the signature of an initial packet, but op is + * not a b_o_s packet; OR this packet has the signature + * of an initial header packet, but an initial header + * packet has already been seen; OR this packet has the + * signature of a comment packet, but the initial header + * has not yet been seen; OR this packet has the signature + * of a comment packet, but contains invalid data; OR + * this packet has the signature of codebook tables, + * but the initial header or comments have not yet + * been seen; OR this packet has the signature of codebook + * tables, but contains invalid data; + * OR the stream being decoded has a compatible version + * but this packet does not have the signature of a + * theora initial header, comments, or codebook packet + * \retval OC_VERSION The packet data of \a op is an initial header with + * a version which is incompatible with this version of + * libtheora. + * \retval OC_NEWPACKET the stream being decoded has an incompatible (future) + * version and contains an unknown signature. + * \retval 0 Success + * + * \note The normal usage is that theora_decode_header() be called on the + * first three packets of a theora logical bitstream in succession. + */ +extern int theora_decode_header(theora_info *ci, theora_comment *cc, + ogg_packet *op); + +/** + * Initialize a theora_state handle for decoding. + * \param th The theora_state handle to initialize. + * \param c A theora_info struct filled with the desired decoding parameters. + * This is of course usually obtained from a previous call to + * theora_decode_header(). + * \returns 0 Success + */ +extern int theora_decode_init(theora_state *th, theora_info *c); + +/** + * Input a packet containing encoded data into the theora decoder. + * \param th A theora_state handle previously initialized for decoding. + * \param op An ogg_packet containing encoded theora data. + * \retval OC_BADPACKET \a op does not contain encoded video data + */ +extern int theora_decode_packetin(theora_state *th,ogg_packet *op); + +/** + * Output the next available frame of decoded YUV data. + * \param th A theora_state handle previously initialized for decoding. + * \param yuv A yuv_buffer in which libtheora should place the decoded data. + * \retval 0 Success + */ +extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv); + +/** + * Report whether a theora packet is a header or not + * This function does no verification beyond checking the header + * flag bit so it should not be used for bitstream identification; + * use theora_decode_header() for that. + * + * \param op An ogg_packet containing encoded theora data. + * \retval 1 The packet is a header packet + * \retval 0 The packet is not a header packet (and so contains frame data) + * + * Thus function was added in the 1.0alpha4 release. + */ +extern int theora_packet_isheader(ogg_packet *op); + +/** + * Report whether a theora packet is a keyframe or not + * + * \param op An ogg_packet containing encoded theora data. + * \retval 1 The packet contains a keyframe image + * \retval 0 The packet is contains an interframe delta + * \retval -1 the packet is not an image data packet at all + * + * Thus function was added in the 1.0alpha4 release. + */ +extern int theora_packet_iskeyframe(ogg_packet *op); + +/** + * Convert a granulepos to an absolute frame number. The granulepos is + * interpreted in the context of a given theora_state handle. + * + * \param th A previously initialized theora_state handle (encode or decode) + * \param granulepos The granulepos to convert. + * \returns The frame number corresponding to \a granulepos. + * \retval -1 The given granulepos is invalid (ie. negative) + * + * Thus function was added in the 1.0alpha4 release. + */ +extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos); + +/** + * Convert a granulepos to absolute time in seconds. The granulepos is + * interpreted in the context of a given theora_state handle. + * \param th A previously initialized theora_state handle (encode or decode) + * \param granulepos The granulepos to convert. + * \returns The absolute time in seconds corresponding to \a granulepos. + * \retval -1 The given granulepos is invalid (ie. negative) + */ +extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos); + +/** + * Initialize a theora_info structure. All values within the given theora_info + * structure are initialized, and space is allocated within libtheora for + * internal codec setup data. + * \param c A theora_info struct to initialize. + */ +extern void theora_info_init(theora_info *c); + +/** + * Clear a theora_info structure. All values within the given theora_info + * structure are cleared, and associated internal codec setup data is freed. + * \param c A theora_info struct to initialize. + */ +extern void theora_info_clear(theora_info *c); + +/** + * Free all internal data associated with a theora_state handle. + * \param t A theora_state handle. + */ +extern void theora_clear(theora_state *t); + +/** Initialize an allocated theora_comment structure */ +extern void theora_comment_init(theora_comment *tc); +/** Add a comment to an initialized theora_comment structure + \param comment must be a null-terminated string encoding + the comment in "TAG=the value" form */ +extern void theora_comment_add(theora_comment *tc, char *comment); +/** Add a comment to an initialized theora_comment structure + \param tag a null-terminated string containing the tag + associated with the comment. + \param value the corresponding value as a null-terminated string + Neither theora_comment_add() nor theora_comment_add_tag() support + comments containing null values, although the bitstream format + supports this. To add such comments you will need to manipulate + the theora_comment structure directly */ +extern void theora_comment_add_tag(theora_comment *tc, + char *tag, char *value); +/** look up a comment value by tag + \param tc an initialized theora_comment structure + \param tag the tag to look up + \param count the instance of the tag. The same tag can appear + multiple times, each with a distinct and ordered value, so + an index is required to retrieve them all. + Use theora_comment_query_count() to get the legal range for the + count parameter + \returns a pointer to the queried tag's value + \retval NULL if no matching tag is found */ +extern char *theora_comment_query(theora_comment *tc, char *tag, int count); +/** look up the number of instances of a tag + \param tc an initialized theora_comment structure + \param tag the tag to look up + \returns the number on instances of a particular tag. + Call this first when querying for a specific tag and then interate + over the number of instances with separate calls to + theora_comment_query() to retrieve all instances in order. */ +extern int theora_comment_query_count(theora_comment *tc, char *tag); +/** clears an allocated theora_comment struct so that it can be freed. */ +extern void theora_comment_clear(theora_comment *tc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _O_THEORA_H_ */ diff --git a/include/theora/vssver.scc b/include/theora/vssver.scc new file mode 100755 index 0000000..12d18d6 Binary files /dev/null and b/include/theora/vssver.scc differ diff --git a/include/usb.h b/include/usb.h new file mode 100755 index 0000000..02d1244 --- /dev/null +++ b/include/usb.h @@ -0,0 +1,337 @@ +/* + * Prototypes, structure definitions and macros. + * + * Copyright (c) 2000-2003 Johannes Erdfelt + * + * This library is covered by the LGPL, read LICENSE for details. + * + * This file (and only this file) may alternatively be licensed under the + * BSD license as well, read LICENSE for details. + */ +#ifndef __USB_H__ +#define __USB_H__ + +#include +#include +#include + +#include + +/* + * USB spec information + * + * This is all stuff grabbed from various USB specs and is pretty much + * not subject to change + */ + +/* + * Device and/or Interface Class codes + */ +#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ +#define USB_CLASS_AUDIO 1 +#define USB_CLASS_COMM 2 +#define USB_CLASS_HID 3 +#define USB_CLASS_PRINTER 7 +#define USB_CLASS_PTP 6 +#define USB_CLASS_MASS_STORAGE 8 +#define USB_CLASS_HUB 9 +#define USB_CLASS_DATA 10 +#define USB_CLASS_VENDOR_SPEC 0xff + +/* + * Descriptor types + */ +#define USB_DT_DEVICE 0x01 +#define USB_DT_CONFIG 0x02 +#define USB_DT_STRING 0x03 +#define USB_DT_INTERFACE 0x04 +#define USB_DT_ENDPOINT 0x05 + +#define USB_DT_HID 0x21 +#define USB_DT_REPORT 0x22 +#define USB_DT_PHYSICAL 0x23 +#define USB_DT_HUB 0x29 + +/* + * Descriptor sizes per descriptor type + */ +#define USB_DT_DEVICE_SIZE 18 +#define USB_DT_CONFIG_SIZE 9 +#define USB_DT_INTERFACE_SIZE 9 +#define USB_DT_ENDPOINT_SIZE 7 +#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ +#define USB_DT_HUB_NONVAR_SIZE 7 + +/* All standard descriptors have these 2 fields in common */ +struct usb_descriptor_header { + u_int8_t bLength; + u_int8_t bDescriptorType; +}; + +/* String descriptor */ +struct usb_string_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t wData[1]; +}; + +/* HID descriptor */ +struct usb_hid_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t bcdHID; + u_int8_t bCountryCode; + u_int8_t bNumDescriptors; + /* u_int8_t bReportDescriptorType; */ + /* u_int16_t wDescriptorLength; */ + /* ... */ +}; + +/* Endpoint descriptor */ +#define USB_MAXENDPOINTS 32 +struct usb_endpoint_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int8_t bEndpointAddress; + u_int8_t bmAttributes; + u_int16_t wMaxPacketSize; + u_int8_t bInterval; + u_int8_t bRefresh; + u_int8_t bSynchAddress; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +}; + +#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ +#define USB_ENDPOINT_DIR_MASK 0x80 + +#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ +#define USB_ENDPOINT_TYPE_CONTROL 0 +#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 +#define USB_ENDPOINT_TYPE_BULK 2 +#define USB_ENDPOINT_TYPE_INTERRUPT 3 + +/* Interface descriptor */ +#define USB_MAXINTERFACES 32 +struct usb_interface_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int8_t bInterfaceNumber; + u_int8_t bAlternateSetting; + u_int8_t bNumEndpoints; + u_int8_t bInterfaceClass; + u_int8_t bInterfaceSubClass; + u_int8_t bInterfaceProtocol; + u_int8_t iInterface; + + struct usb_endpoint_descriptor *endpoint; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +}; + +#define USB_MAXALTSETTING 128 /* Hard limit */ +struct usb_interface { + struct usb_interface_descriptor *altsetting; + + int num_altsetting; +}; + +/* Configuration descriptor information.. */ +#define USB_MAXCONFIG 8 +struct usb_config_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t wTotalLength; + u_int8_t bNumInterfaces; + u_int8_t bConfigurationValue; + u_int8_t iConfiguration; + u_int8_t bmAttributes; + u_int8_t MaxPower; + + struct usb_interface *interface; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +}; + +/* Device descriptor */ +struct usb_device_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t bcdUSB; + u_int8_t bDeviceClass; + u_int8_t bDeviceSubClass; + u_int8_t bDeviceProtocol; + u_int8_t bMaxPacketSize0; + u_int16_t idVendor; + u_int16_t idProduct; + u_int16_t bcdDevice; + u_int8_t iManufacturer; + u_int8_t iProduct; + u_int8_t iSerialNumber; + u_int8_t bNumConfigurations; +}; + +struct usb_ctrl_setup { + u_int8_t bRequestType; + u_int8_t bRequest; + u_int16_t wValue; + u_int16_t wIndex; + u_int16_t wLength; +}; + +/* + * Standard requests + */ +#define USB_REQ_GET_STATUS 0x00 +#define USB_REQ_CLEAR_FEATURE 0x01 +/* 0x02 is reserved */ +#define USB_REQ_SET_FEATURE 0x03 +/* 0x04 is reserved */ +#define USB_REQ_SET_ADDRESS 0x05 +#define USB_REQ_GET_DESCRIPTOR 0x06 +#define USB_REQ_SET_DESCRIPTOR 0x07 +#define USB_REQ_GET_CONFIGURATION 0x08 +#define USB_REQ_SET_CONFIGURATION 0x09 +#define USB_REQ_GET_INTERFACE 0x0A +#define USB_REQ_SET_INTERFACE 0x0B +#define USB_REQ_SYNCH_FRAME 0x0C + +#define USB_TYPE_STANDARD (0x00 << 5) +#define USB_TYPE_CLASS (0x01 << 5) +#define USB_TYPE_VENDOR (0x02 << 5) +#define USB_TYPE_RESERVED (0x03 << 5) + +#define USB_RECIP_DEVICE 0x00 +#define USB_RECIP_INTERFACE 0x01 +#define USB_RECIP_ENDPOINT 0x02 +#define USB_RECIP_OTHER 0x03 + +/* + * Various libusb API related stuff + */ + +#define USB_ENDPOINT_IN 0x80 +#define USB_ENDPOINT_OUT 0x00 + +/* Error codes */ +#define USB_ERROR_BEGIN 500000 + +/* + * This is supposed to look weird. This file is generated from autoconf + * and I didn't want to make this too complicated. + */ +#if 0 +#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0) +#else +#define USB_LE16_TO_CPU(x) +#endif + +/* Data types */ +struct usb_device; +struct usb_bus; + +/* + * To maintain compatibility with applications already built with libusb, + * we must only add entries to the end of this structure. NEVER delete or + * move members and only change types if you really know what you're doing. + */ +struct usb_device { + struct usb_device *next, *prev; + + char filename[PATH_MAX + 1]; + + struct usb_bus *bus; + + struct usb_device_descriptor descriptor; + struct usb_config_descriptor *config; + + void *dev; /* Darwin support */ + + u_int8_t devnum; + + unsigned char num_children; + struct usb_device **children; +}; + +struct usb_bus { + struct usb_bus *next, *prev; + + char dirname[PATH_MAX + 1]; + + struct usb_device *devices; + u_int32_t location; + + struct usb_device *root_dev; +}; + +struct usb_dev_handle; +typedef struct usb_dev_handle usb_dev_handle; + +/* Variables */ +extern struct usb_bus *usb_busses; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/* usb.c */ +usb_dev_handle *usb_open(struct usb_device *dev); +int usb_close(usb_dev_handle *dev); +int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, + size_t buflen); +int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, + size_t buflen); + +/* descriptors.c */ +int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, + unsigned char type, unsigned char index, void *buf, int size); +int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, + unsigned char index, void *buf, int size); + +/* .c */ +int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, + int value, int index, char *bytes, int size, int timeout); +int usb_set_configuration(usb_dev_handle *dev, int configuration); +int usb_claim_interface(usb_dev_handle *dev, int interface); +int usb_release_interface(usb_dev_handle *dev, int interface); +int usb_set_altinterface(usb_dev_handle *dev, int alternate); +int usb_resetep(usb_dev_handle *dev, unsigned int ep); +int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); +int usb_reset(usb_dev_handle *dev); + +#if 1 +#define LIBUSB_HAS_GET_DRIVER_NP 1 +int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name, + unsigned int namelen); +#define LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 1 +int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface); +#endif + +char *usb_strerror(void); + +void usb_init(void); +void usb_set_debug(int level); +int usb_find_busses(void); +int usb_find_devices(void); +struct usb_device *usb_device(usb_dev_handle *dev); +struct usb_bus *usb_get_busses(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_H__ */ + diff --git a/include/usbpp.h b/include/usbpp.h new file mode 100755 index 0000000..525e217 --- /dev/null +++ b/include/usbpp.h @@ -0,0 +1,855 @@ +// -*- C++;indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- +#ifndef __USBPP_HEADER__ +#define __USBPP_HEADER__ + +#include +#include + +#include + +/* + * The following usb.h function is not wrapped yet: + * char *usb_strerror(void); + */ + + +/** + * \brief Classes to access Universal Serial Bus devices + * + * The USB Namespace provides a number of classes to work + * with Universal Serial Bus (USB) devices attached to the + * system. + * + * \author Brad Hards + */ +namespace USB { + + class Device; + + /** + * \brief Class representing a device endpoint + * + * This class represents a device endpoint. You need this class to + * perform bulk reads and writes. + * + */ + class Endpoint { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + Endpoint() {}; + +#ifdef USE_UNTESTED_LIBUSBPP_METHODS + /** + * \brief Bulk write + * + * This method performs a bulk transfer to the endpoint. + * + * \param message is the message to be sent. + * \param timeout is the USB transaction timeout in milliseconds + * + * \returns the number of bytes sent, or a negative value on + * failure + */ + int bulkWrite(QByteArray message, int timeout = 100); + + /** + * \brief Bulk read + * + * This method performs a bulk transfer from the endpoint. + * + * \param length is the maximum data transfer required. + * \param message is the message that was received. + * \param timeout is the USB transaction timeout in milliseconds + * + * \returns the number of bytes received, or a negative value on + * failure + */ + int bulkRead(int length, unsigned char *message, int timeout = 100); + + /** + * \brief Reset endpoint + * + * This method resets the endpoint. + */ + int reset(void); + + /** + * \brief Clear halt + * + * This method clears a halt (stall) on the endpoint. + */ + int clearHalt(void); + +#endif /* USE_UNTESTED_LIBUSBPP_METHODS */ + + /** + * \brief Endpoint descriptor information output + * + * This method dumps out the various characteristics + * of the endpoint to standard output. + * + * It is mostly useful for debugging. + */ + void dumpDescriptor(void); + + private: + void setDescriptor(struct usb_endpoint_descriptor); + void setParent(Device *parent); + u_int8_t m_Length; + u_int8_t m_DescriptorType; + u_int8_t m_EndpointAddress; + u_int8_t m_Attributes; + u_int16_t m_MaxPacketSize; + u_int8_t m_Interval; + u_int8_t m_Refresh; + u_int8_t m_SynchAddress; + Device *m_parent; + }; + + class AltSetting : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + AltSetting() {}; + u_int8_t numEndpoints(void); + + /** + * \brief AltSetting descriptor information output + * + * This method dumps out the various characteristics + * of the alternate setting to standard output. + * + * It is mostly useful for debugging. + */ + void dumpDescriptor(void); + + Endpoint *firstEndpoint(void); + Endpoint *nextEndpoint(void); + Endpoint *lastEndpoint(void); + + private: + std::list::const_iterator iter; + + void setDescriptor(struct usb_interface_descriptor); + /* we don't use a normal usb_interface_descriptor */ + /* because that would bring in the endpoint list */ + u_int8_t m_Length; + u_int8_t m_DescriptorType; + u_int8_t m_InterfaceNumber; + u_int8_t m_AlternateSetting; + u_int8_t m_NumEndpoints; + u_int8_t m_InterfaceClass; + u_int8_t m_InterfaceSubClass; + u_int8_t m_InterfaceProtocol; + u_int8_t m_Interface; + }; + + /** + * \brief Class representing an interface of a Device + * + * The Interface class represents a USB interface + * for a device attached to a Universal Serial Bus. + * + * Interfaces are the main element of the USB class + * structure. + * + * \author Brad Hards + */ + class Interface : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + Interface() {}; + +#ifdef LIBUSB_HAS_GET_DRIVER_NP + /** + * \brief get the current driver for an interface + * + * \param driver a string containing the name of the current + * driver for the interface. You can typically pass in an empty + * string for this. + * + * \return length of string, or 0 on error. + */ + int driverName(std::string &driver); +#endif + +#ifdef USE_UNTESTED_LIBUSBPP_METHODS + /** + * \brief Claim this interface + * + * This method claims the interface. You have to claim the + * interface before performing any operations on the interface (or + * on endpoints that are part of the interface). + * + * \return 0 on success or negative number on error. + */ + int claim(void); + + /** + * \brief Release this interface + * + * This method releases the interface. You should release the + * interface after all operations on it (and any lower level + * endpoints) are completed. + * + * \return 0 on success or negative number on error. + */ + int release(void); + + /** + * \brief Set interface alternate setting + * + * This method sets the interface to a particular AltSetting. + * + * \param altSettingNumber the AltSetting that the interface + * should be changed to. + * + * \return 0 on success, or a negative number in case of error. + */ + int setAltSetting(int altSettingNumber); +#endif /* USE_UNTESTED_LIBUSBPP_METHODS */ + + /** + * \brief Number of Alternative Settings that this interface has + * + * This is a simple accessor method that specifies the number + * alternative settings that this device interface has. + */ + u_int8_t numAltSettings(void); + + /** + * \brief First AltSetting for the Interface + * + * This method returns a pointer to the first AltSetting + * for the Interface. + * + * See nextAltSetting() for an example of how it might be + * used. + * + * \see nextAltSetting(), lastAltSetting(), numAltSettings() + */ + AltSetting *firstAltSetting(void); + + /** + * \brief Next AltSetting for the Interface + * + * This method returns a pointer to the next AltSetting + * for the Interface. + * + * If you want to iterate through each AltSetting on + * a device, you can use something like the following: + * \code + * USB::Configuration *this_Configuration; + * this_Configuration = device->firstConfiguration(); + * for (i=0; i < device->numConfigurations(); i++) { + * this_Configuration->dumpDescriptor(); + * USB::Interface *this_Interface; + * this_Interface = this_Configuration->firstInterface(); + * for (j=0; j < this_Configuration->numInterfaces(); j++) { + * USB::AltSetting *this_AltSetting; + * this_AltSetting = this_Interface->firstAltSetting(); + * for (k=0; k < this_Interface->numAltSettings(); k++) { + * // do something with this_AltSetting + * this_AltSetting = this_Interface->nextAltSetting(); + * } + * this_Interface = this_Configuration->nextInterface(); + * } + * this_Configuration = device->nextConfiguration(); + * } + * \endcode + * + * \see firstAltSetting(), lastAltSetting(), numAltSettings() + */ + AltSetting *nextAltSetting(void); + + /** + * \brief Last AltSetting for the Interface + * + * This method returns a pointer to the last AltSetting + * for the Interface. + * + * \see firstAltSetting(), nextAltSetting(), numAltSettings() + */ + + AltSetting *lastAltSetting(void); + + private: + std::list::const_iterator iter; + + void setNumAltSettings(u_int8_t); + void setParent(Device *parent); + u_int8_t m_numAltSettings; + Device *m_parent; + + /* index representing the interface, in this configuration */ + int m_interfaceNumber; + void setInterfaceNumber(int interfaceNumber); + }; + + /** + * \brief Class representing a configuration of a Device + * + * The Configuration class represents a single configuration + * of a device attached to a Universal Serial Bus. + * + * \author Brad Hards + */ + class Configuration : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + Configuration() {}; + + /** + * \brief Configuration descriptor information output + * + * This method dumps out the various characteristics + * of the configuration to standard output. + * + * It is mostly useful for debugging. + */ + void dumpDescriptor(void); + + /** + * \brief Number of Interfaces that this device has + * + * This is a simple accessor method that specifies the number + * Interfaces that this device configuration has. + */ + u_int8_t numInterfaces(void); + + /** + * \brief First Interface for the Configuration + * + * This method returns a pointer to the first Interface + * for the Configuration. + * + * See nextInterface() for an example of how it might be + * used. + * + * \see nextInterface(), lastInterface(), numInterfaces() + */ + Interface *firstInterface(void); + + /** + * \brief Next Interface for the Configuration + * + * This method returns a pointer to the next Interface + * for the Configuration. + * + * If you want to iterate through each Interface on + * a device, you can use something like the following: + * \code + * USB::Configuration *this_Configuration; + * this_Configuration = device->firstConfiguration(); + * for (i=0; i < device->numConfigurations(); i++) { + * this_Interface = this_Configuration->firstInterface(); + * for (j=0; j < this_Configuration->numInterfaces(); j++) { + * // do something with this_Interface + * this_Interface = this_Configuration->nextInterface(); + * } + * this_Configuration->nextConfiguration(); + * } + * \endcode + * + * \see firstInterface(), lastInterface(), numInterfaces() + */ + Interface *nextInterface(void); + + /** + * \brief Last Interface for the Configuration + * + * This method returns a pointer to the last Interface + * for the Configuration. + * + * \see firstInterface(), nextInterface(), numInterfaces() + */ + Interface *lastInterface(void); + + private: + std::list::const_iterator iter; + + void setDescriptor(struct usb_config_descriptor); + /* we don't use a normal usb_config_descriptor */ + /* because that would bring in the interface list */ + u_int8_t m_Length; + u_int8_t m_DescriptorType; + u_int16_t m_TotalLength; + u_int8_t m_NumInterfaces; + u_int8_t m_ConfigurationValue; + u_int8_t m_Configuration; + u_int8_t m_Attributes; + u_int8_t m_MaxPower; + }; + + /** + * \brief Class representing a Device on the Bus + * + * The Device class represents a single device + * attached to a Universal Serial Bus. + * + * \author Brad Hards + */ + class Device : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + /** + * Interface is a friend because it needs the handle() function to + * perform claim(), release(). + */ + friend class Interface; + /** + * Endpoint is a friend because it needs the handle() function to + * perform reads, writes, and other transactions. + */ + friend class Endpoint; + + public: + Device() {}; + ~Device(); + + /** + * \brief OS representation of filename for this device + * + * libusb++ provides a uniform way of accessing USB + * devices irrespective of the underlying Operation System + * representation. If you want to map the libusb++ representation + * to the Operating System representation, you can do this + * with filename(). + * + * On Linux, the filename is usually something like 002, which + * represents the second device (usually the first real device, + * after the root hub pseudo-device) on the bus. + * + * \see Bus::directoryName() + */ + std::string fileName(void); + + /** + * \brief The vendor ID number, as provided by the device. + * + * This method returns a number containing the vendor + * (manufacturer) identification number. These are allocated + * by the USB Implementers Forum, and you can construct a + * lookup based on the number to get the manufacturer's name, + * even if the device does not contain a vendor string. + * + * \see Vendor() + */ + u_int16_t idVendor(void); + + /** + * \brief The product ID number, as provided by the device. + * + * This method returns a number containing the product + * identification number. These are allocated + * by the manufacturer, and should be different on each device. + * + * \see Product() + */ + u_int16_t idProduct(void); + + /** + * \brief The product's revision ID, as provided by the device. + * + * This method returns a number containing the product's revision. + * This revision level is nominally binary coded decimal, but + * hexadecimal revision levels are not uncommon. The binary coded + * decimal version nominally has a major version in the high byte, + * and a minor version in the low byte. + */ + u_int16_t idRevision(void); + + /** + * \brief The device's USB class, as provided by the device. + * + * This method returns a number containing the device's class. + * These are defined by the USB Implementer's Forum. + * + * A code of Zero is special (and common) - it means that the + * class is found in the Interface descriptor, rather than in the + * Device descriptor. + * + * A code of 0xFF is also special (and far too common) - it means + * that the manufacturer didn't conform to one of the defined + * class specifications, and chose to implement a vendor specified + * protocol. + * + */ + u_int8_t devClass(void); + + /** + * \brief The device's USB subclass, as provided by the device. + * + * This method returns a number containing the device's subclass. + * These subclasses are defined by the USB Implementer's Forum, + * and only have meaning in the context of a specified class. + */ + u_int8_t devSubClass(void); + + /** + * \brief The device's USB protocol, as provided by the device. + * + * This method returns a number containing the device's protocol. + * These protocols are defined by the USB Implementer's Forum, and + * only have meaning in the context of a specified class and + * subclass. + */ + u_int8_t devProtocol(void); + + + /** + * \brief The vendor name string, as provided by the device. + * + * This method returns a string containing the name of the + * device's vendor (manufacturer), as encoded into the device. + * + * Note that not all devices contain a vendor name, and also + * that under some operating systems you may not be able to + * read the vendor name without elevated privledges (typically + * root privledges). + * + * \see idVendor() + **/ + std::string Vendor(void); + + /** + * \brief The product name string, as provided by the device. + * + * This method returns a string containing the name of the + * device's product name, as encoded into the device. + * + * Note that not all devices contain a product name, and also + * that under some operating systems you may not be able to + * read the vendor name without elevated privledges (typically + * root privledges). + * + * \see idProduct() + **/ + std::string Product(void); + + /** + * \brief The serial number string, as provided by the device. + * + * This method returns a string containing a serial number for + * the device, as encoded into the device. + * + * Note that few devices contain a serial number string, and also + * that under some operating systems you may not be able to + * read the serial number without elevated privledges (typically + * root privledges). The USB specification requires that serial + * numbers are unique if they are provided, but adherence to this + * requirement by manufacturers is not universal. + **/ + std::string SerialNumber(void); + + /** + * \brief Number of Configurations that this device has + * + * This is a simple accessor method that specifies the number + * configurations that this device has. + */ + u_int8_t numConfigurations(void); + + /** + * \brief fetch an arbitrary string from the device + * + * \param string the string from the device. You can typically + * pass in an empty string for this. + * \param index the index of the string required + * \param lang the language ID to use. Defaults to using the + * first language ID. + * + * \return length of string, or 0 on error. + */ + int string(std::string &buf, int index, u_int16_t lang=0); + + /** + * \brief First Configuration for the Device + * + * This method returns a pointer to the first Configuration + * for the Device. + * + * See nextConfiguration() for an example of how it might be + * used. + */ + Configuration *firstConfiguration(void); + + /** + * \brief Next Configuration for the Device + * + * This method returns a pointer to the next Configuration + * for the Device. + * + * If you want to iterate through each Configuration on + * a device, you can use something like the following: + * \code + * USB::Configuration *this_Configuration; + * this_Configuration = device->firstConfiguration(); + * for (i=0; i < device->numConfigurations(); i++) { + * // do something with this_Configuration + * this_Configuration->nextConfiguration(); + * } + * \endcode + */ + Configuration *nextConfiguration(void); + + /** + * \brief Last Configuration for the Device + * + * This method returns a pointer to the last Configuration + * for the Device. + * + */ + Configuration *lastConfiguration(void); + + /** + * \brief USB control transfer + * + * This method performs a standard control transfer to the default + * endpoint. See the USB specification for more details on this. + * + * \param requestType corresponds to the bmRequestType field + * in the transfer + * \param request corresponds to the bRequest field in the + * transfer + * \param value corresponds to the wValue field in the transfer + * \param index corresponds to the wIndex field in the transfer + * \param length corresponds to the wLength field in the transfer + * \param payload corresponds to the data phase of a control + * transfer + * \param timeout is the timeout period for the control transfer, + * in milliseconds + * + * \return number of bytes sent or received, or a negative number + * in case of error. + */ + int controlTransfer(u_int8_t requestType, u_int8_t request, + u_int16_t value, u_int16_t index, u_int16_t length, + unsigned char *payload, + int timeout = 100); + +#ifdef USE_UNTESTED_LIBUSBPP_METHODS + /** + * \brief USB device reset + * + * This method performs a device reset - see USB Specification + * 9.1 for how this changes the device state to the Default state. + * + * \return 0 on success, or a negative number in case of error. + */ + int reset(void); + + /** + * \brief Set device configuration + * + * This method sets the device to a particular Configuration. + * + * \param configurationNumber the configuration that the device + * should be changed to. + * + * \return 0 on success, or a negative number in case of error. + */ + int setConfiguration(int configurationNumber); +#endif /* USE_UNTESTED_LIBUSBPP_METHODS */ + + private: + std::list::const_iterator iter; + + struct usb_dev_handle *handle(); + void setFileName(std::string); + void setDescriptor(struct usb_device_descriptor); + void setVendor(std::string); + void setProduct(std::string); + void setSerialNumber(std::string); + void setDevHandle(struct usb_dev_handle *); + std::string m_fileName; + std::string m_Vendor; + std::string m_Product; + std::string m_SerialNumber; + struct usb_device *m_dev; + struct usb_dev_handle *m_handle; + struct usb_device_descriptor m_descriptor; + }; + + /** + * \brief Class representing a single bus on the machine + * + * This class is essentially a list of Device class instances + */ + class Bus : public std::list { + /** + * Busses is a friend because it fills in the directory name + * information on initialisation and rescan. + */ + friend class Busses; + public: + Bus() {}; + /** + * \brief OS representation of directory name for this Bus + * + * libusb++ provides a uniform way of accessing USB + * busses irrespective of the underlying Operation System + * representation. If you want to map the libusb++ representation + * to the Operating System representation, you can do this + * with directory name(). + * + * On Linux, the directoryname is usually something like 003, which + * represents the third bus on the host. + * + * \see Directory::filename() + */ + std::string directoryName(void); + private: + std::list::const_iterator iter; + + void setDirectoryName(std::string); + std::string m_directoryName; + }; + + /** + * \brief A vendor/product ID pair + * + * DeviceID provides a list of (vendor, product) identification + * pairs. It is intended for use in a list of device numbers to + * search for, but there is no reason why it couldn't be used for a + * general purpose (vendor,product) tuple if you had some reason for + * this. + * + * The description for Busses::match() provides an example of how + * this class might be used. + * + * \see DeviceIDList, Busses::match() + */ + class DeviceID { + public: + DeviceID() {}; + /** + * \brief Standard constructor + * + * This constructor takes (vendor, product) tuple, which are + * stored away. + * + * \param vendor the 16 bit vendor number for the device + * \param product the 16 bit product number for the device + */ + DeviceID(u_int16_t vendor, u_int16_t product); + + /** + * \brief vendor number for the device + * + * This method returns the 16 bit vendor number. + */ + u_int16_t vendor(void); + + /** + * \brief product number for the device + * + * This method returns the 16 bit product number. + */ + u_int16_t product(void); + + private: + u_int16_t m_vendor; + u_int16_t m_product; + }; + + /** + * \brief A list of vendor/product pairs + * + * DeviceIDList provides a list of DeviceID classes, which is + * essentially a list of (vendor, product) identification pairs. + * + * \see DeviceID + */ + typedef std::list DeviceIDList; + + /** + * \brief Class representing all the busses on the machine + * + * This class is essentially a list of Bus class instances + */ + class Busses : public std::list { + public: + Busses(); + + /** + * \brief Update method + * + * This method can be called to rescan the various devices + * attached to the various busses. You should use it to + * update if things change. Unfortunately there is no + * way to automatically detect this change in a portable way, + * so worst case is that you need to call this using some + * kind of timer in the background. + */ + void rescan(void); + + /** + * \brief find all devices with matching device class designator + * + * This method searches every device on every bus, and returns a + * list of pointers to the devices that have a matching device + * class code + */ + std::list match(u_int8_t Class); + + /** + * \brief find all devices with matching device IDs + * + * This method searches every device on every bus, and returns a + * list of pointers to the devices that have a matching device + * ID. That is, if the (vendor, product) tuple of a device matches + * one of the tuples on the list, then the device will be added to + * the list of matches. + * + * An example of usage is shown below: + * \code + * USB::Busses buslist; + * USB::Device *device; + * std::list miceFound; + * USB::DeviceIDList mouseList; + * + * mouseList.append(USB::DeviceID(VENDOR_LOGITECH, 0xC00E)); // Wheel Mouse Optical + * mouseList.append(USB::DeviceID(VENDOR_LOGITECH, 0xC012)); // MouseMan Dual Optical + * mouseList.append(USB::DeviceID(VENDOR_LOGITECH, 0xC506)); // MX700 Optical Mouse + * + * miceFound = buslist.match(mouseList); + * + * for ( device = miceFound.first(); device; device = miceFound.next() ) { + * // do something with each mouse that matched + * } + * FIXME: This is incorrect now + * \endcode + */ + std::list match(DeviceIDList); + + private: + std::list::const_iterator iter; + }; + + class Error { + public: + private: + }; + +} +#endif /* __USBPP_HEADER__ */ + diff --git a/include/vorbis/codec.h b/include/vorbis/codec.h new file mode 100755 index 0000000..14f44b0 --- /dev/null +++ b/include/vorbis/codec.h @@ -0,0 +1,240 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + + ******************************************************************** + + function: libvorbis codec headers + last mod: $Id: codec.h 7485 2004-08-05 14:54:23Z thomasvs $ + + ********************************************************************/ + +#ifndef _vorbis_codec_h_ +#define _vorbis_codec_h_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include + +typedef struct vorbis_info{ + int version; + int channels; + long rate; + + /* The below bitrate declarations are *hints*. + Combinations of the three values carry the following implications: + + all three set to the same value: + implies a fixed rate bitstream + only nominal set: + implies a VBR stream that averages the nominal bitrate. No hard + upper/lower limit + upper and or lower set: + implies a VBR bitstream that obeys the bitrate limits. nominal + may also be set to give a nominal rate. + none set: + the coder does not care to speculate. + */ + + long bitrate_upper; + long bitrate_nominal; + long bitrate_lower; + long bitrate_window; + + void *codec_setup; +} vorbis_info; + +/* vorbis_dsp_state buffers the current vorbis audio + analysis/synthesis state. The DSP state belongs to a specific + logical bitstream ****************************************************/ +typedef struct vorbis_dsp_state{ + int analysisp; + vorbis_info *vi; + + float **pcm; + float **pcmret; + int pcm_storage; + int pcm_current; + int pcm_returned; + + int preextrapolate; + int eofflag; + + long lW; + long W; + long nW; + long centerW; + + ogg_int64_t granulepos; + ogg_int64_t sequence; + + ogg_int64_t glue_bits; + ogg_int64_t time_bits; + ogg_int64_t floor_bits; + ogg_int64_t res_bits; + + void *backend_state; +} vorbis_dsp_state; + +typedef struct vorbis_block{ + /* necessary stream state for linking to the framing abstraction */ + float **pcm; /* this is a pointer into local storage */ + oggpack_buffer opb; + + long lW; + long W; + long nW; + int pcmend; + int mode; + + int eofflag; + ogg_int64_t granulepos; + ogg_int64_t sequence; + vorbis_dsp_state *vd; /* For read-only access of configuration */ + + /* local storage to avoid remallocing; it's up to the mapping to + structure it */ + void *localstore; + long localtop; + long localalloc; + long totaluse; + struct alloc_chain *reap; + + /* bitmetrics for the frame */ + long glue_bits; + long time_bits; + long floor_bits; + long res_bits; + + void *internal; + +} vorbis_block; + +/* vorbis_block is a single block of data to be processed as part of +the analysis/synthesis stream; it belongs to a specific logical +bitstream, but is independant from other vorbis_blocks belonging to +that logical bitstream. *************************************************/ + +struct alloc_chain{ + void *ptr; + struct alloc_chain *next; +}; + +/* vorbis_info contains all the setup information specific to the + specific compression/decompression mode in progress (eg, + psychoacoustic settings, channel setup, options, codebook + etc). vorbis_info and substructures are in backends.h. +*********************************************************************/ + +/* the comments are not part of vorbis_info so that vorbis_info can be + static storage */ +typedef struct vorbis_comment{ + /* unlimited user comment fields. libvorbis writes 'libvorbis' + whatever vendor is set to in encode */ + char **user_comments; + int *comment_lengths; + int comments; + char *vendor; + +} vorbis_comment; + + +/* libvorbis encodes in two abstraction layers; first we perform DSP + and produce a packet (see docs/analysis.txt). The packet is then + coded into a framed OggSquish bitstream by the second layer (see + docs/framing.txt). Decode is the reverse process; we sync/frame + the bitstream and extract individual packets, then decode the + packet back into PCM audio. + + The extra framing/packetizing is used in streaming formats, such as + files. Over the net (such as with UDP), the framing and + packetization aren't necessary as they're provided by the transport + and the streaming layer is not used */ + +/* Vorbis PRIMITIVES: general ***************************************/ + +extern void vorbis_info_init(vorbis_info *vi); +extern void vorbis_info_clear(vorbis_info *vi); +extern int vorbis_info_blocksize(vorbis_info *vi,int zo); +extern void vorbis_comment_init(vorbis_comment *vc); +extern void vorbis_comment_add(vorbis_comment *vc, char *comment); +extern void vorbis_comment_add_tag(vorbis_comment *vc, + char *tag, char *contents); +extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); +extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); +extern void vorbis_comment_clear(vorbis_comment *vc); + +extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); +extern int vorbis_block_clear(vorbis_block *vb); +extern void vorbis_dsp_clear(vorbis_dsp_state *v); +extern double vorbis_granule_time(vorbis_dsp_state *v, + ogg_int64_t granulepos); + +/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ + +extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); +extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); +extern int vorbis_analysis_headerout(vorbis_dsp_state *v, + vorbis_comment *vc, + ogg_packet *op, + ogg_packet *op_comm, + ogg_packet *op_code); +extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); +extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); +extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); +extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); + +extern int vorbis_bitrate_addblock(vorbis_block *vb); +extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, + ogg_packet *op); + +/* Vorbis PRIMITIVES: synthesis layer *******************************/ +extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, + ogg_packet *op); + +extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); +extern int vorbis_synthesis_restart(vorbis_dsp_state *v); +extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); +extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); +extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); +extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); +extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); +extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); +extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); + +extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); +extern int vorbis_synthesis_halfrate_p(vorbis_info *v); + +/* Vorbis ERRORS and return codes ***********************************/ + +#define OV_FALSE -1 +#define OV_EOF -2 +#define OV_HOLE -3 + +#define OV_EREAD -128 +#define OV_EFAULT -129 +#define OV_EIMPL -130 +#define OV_EINVAL -131 +#define OV_ENOTVORBIS -132 +#define OV_EBADHEADER -133 +#define OV_EVERSION -134 +#define OV_ENOTAUDIO -135 +#define OV_EBADPACKET -136 +#define OV_EBADLINK -137 +#define OV_ENOSEEK -138 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/include/vorbis/vorbisenc.h b/include/vorbis/vorbisenc.h new file mode 100755 index 0000000..0c78a3b --- /dev/null +++ b/include/vorbis/vorbisenc.h @@ -0,0 +1,112 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: vorbis encode-engine setup + last mod: $Id: vorbisenc.h 7485 2004-08-05 14:54:23Z thomasvs $ + + ********************************************************************/ + +#ifndef _OV_ENC_H_ +#define _OV_ENC_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "codec.h" + +extern int vorbis_encode_init(vorbis_info *vi, + long channels, + long rate, + + long max_bitrate, + long nominal_bitrate, + long min_bitrate); + +extern int vorbis_encode_setup_managed(vorbis_info *vi, + long channels, + long rate, + + long max_bitrate, + long nominal_bitrate, + long min_bitrate); + +extern int vorbis_encode_setup_vbr(vorbis_info *vi, + long channels, + long rate, + + float quality /* quality level from 0. (lo) to 1. (hi) */ + ); + +extern int vorbis_encode_init_vbr(vorbis_info *vi, + long channels, + long rate, + + float base_quality /* quality level from 0. (lo) to 1. (hi) */ + ); + +extern int vorbis_encode_setup_init(vorbis_info *vi); + +extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); + + /* deprecated rate management supported only for compatability */ +#define OV_ECTL_RATEMANAGE_GET 0x10 +#define OV_ECTL_RATEMANAGE_SET 0x11 +#define OV_ECTL_RATEMANAGE_AVG 0x12 +#define OV_ECTL_RATEMANAGE_HARD 0x13 + +struct ovectl_ratemanage_arg { + int management_active; + + long bitrate_hard_min; + long bitrate_hard_max; + double bitrate_hard_window; + + long bitrate_av_lo; + long bitrate_av_hi; + double bitrate_av_window; + double bitrate_av_window_center; +}; + + + /* new rate setup */ +#define OV_ECTL_RATEMANAGE2_GET 0x14 +#define OV_ECTL_RATEMANAGE2_SET 0x15 + +struct ovectl_ratemanage2_arg { + int management_active; + + long bitrate_limit_min_kbps; + long bitrate_limit_max_kbps; + long bitrate_limit_reservoir_bits; + double bitrate_limit_reservoir_bias; + + long bitrate_average_kbps; + double bitrate_average_damping; +}; + + + +#define OV_ECTL_LOWPASS_GET 0x20 +#define OV_ECTL_LOWPASS_SET 0x21 + +#define OV_ECTL_IBLOCK_GET 0x30 +#define OV_ECTL_IBLOCK_SET 0x31 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + + diff --git a/include/vorbis/vorbisfile.h b/include/vorbis/vorbisfile.h new file mode 100755 index 0000000..6481eb4 --- /dev/null +++ b/include/vorbis/vorbisfile.h @@ -0,0 +1,143 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + last mod: $Id: vorbisfile.h 7485 2004-08-05 14:54:23Z thomasvs $ + + ********************************************************************/ + +#ifndef _OV_FILE_H_ +#define _OV_FILE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include +#include "codec.h" + +/* The function prototypes for the callbacks are basically the same as for + * the stdio functions fread, fseek, fclose, ftell. + * The one difference is that the FILE * arguments have been replaced with + * a void * - this is to be used as a pointer to whatever internal data these + * functions might need. In the stdio case, it's just a FILE * cast to a void * + * + * If you use other functions, check the docs for these functions and return + * the right values. For seek_func(), you *MUST* return -1 if the stream is + * unseekable + */ +typedef struct { + size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); + int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); + int (*close_func) (void *datasource); + long (*tell_func) (void *datasource); +} ov_callbacks; + +#define NOTOPEN 0 +#define PARTOPEN 1 +#define OPENED 2 +#define STREAMSET 3 +#define INITSET 4 + +typedef struct OggVorbis_File { + void *datasource; /* Pointer to a FILE *, etc. */ + int seekable; + ogg_int64_t offset; + ogg_int64_t end; + ogg_sync_state oy; + + /* If the FILE handle isn't seekable (eg, a pipe), only the current + stream appears */ + int links; + ogg_int64_t *offsets; + ogg_int64_t *dataoffsets; + long *serialnos; + ogg_int64_t *pcmlengths; /* overloaded to maintain binary + compatability; x2 size, stores both + beginning and end values */ + vorbis_info *vi; + vorbis_comment *vc; + + /* Decoding working state local storage */ + ogg_int64_t pcm_offset; + int ready_state; + long current_serialno; + int current_link; + + double bittrack; + double samptrack; + + ogg_stream_state os; /* take physical pages, weld into a logical + stream of packets */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ + + ov_callbacks callbacks; + +} OggVorbis_File; + +extern int ov_clear(OggVorbis_File *vf); +extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); + +extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); +extern int ov_test_open(OggVorbis_File *vf); + +extern long ov_bitrate(OggVorbis_File *vf,int i); +extern long ov_bitrate_instant(OggVorbis_File *vf); +extern long ov_streams(OggVorbis_File *vf); +extern long ov_seekable(OggVorbis_File *vf); +extern long ov_serialnumber(OggVorbis_File *vf,int i); + +extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); +extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); +extern double ov_time_total(OggVorbis_File *vf,int i); + +extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek(OggVorbis_File *vf,double pos); +extern int ov_time_seek_page(OggVorbis_File *vf,double pos); + +extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); +extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); + +extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); +extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); +extern double ov_time_tell(OggVorbis_File *vf); + +extern vorbis_info *ov_info(OggVorbis_File *vf,int link); +extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); + +extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, + int *bitstream); +extern long ov_read(OggVorbis_File *vf,char *buffer,int length, + int bigendianp,int word,int sgned,int *bitstream); +extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); + +extern int ov_halfrate(OggVorbis_File *vf,int flag); +extern int ov_halfrate_p(OggVorbis_File *vf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + + diff --git a/include/vorbis/vssver.scc b/include/vorbis/vssver.scc new file mode 100755 index 0000000..efef2e4 Binary files /dev/null and b/include/vorbis/vssver.scc differ diff --git a/include/vssver.scc b/include/vssver.scc new file mode 100755 index 0000000..fa7235d Binary files /dev/null and b/include/vssver.scc differ diff --git a/include/xmlWrapper/xmlWrapper.h b/include/xmlWrapper/xmlWrapper.h new file mode 100755 index 0000000..09ddefc --- /dev/null +++ b/include/xmlWrapper/xmlWrapper.h @@ -0,0 +1,114 @@ +#ifndef XML_WRAPPER +#define XML_WRAPPER + +#include +#include +#include +#include +#include +#include + +typedef xmlTextReaderPtr XmlFile; +typedef enum +{ + XML_SEARCH_FORWARD, XML_SEARCH_BACKWARDS +}XmlEnum; + +typedef struct _XmlTextNode +{ + struct _XmlTextNode *next; + xmlChar *string; +}XmlTextNode; + +typedef struct _XmlDataList +{ + struct _XmlDataList *root; + struct _XmlDataList *tail; + struct _XmlDataList *next; + struct _XmlDataList *prev; + xmlChar *text; + int type; + +}XmlDataList; + +typedef struct _XmlAttrib +{ + int index; + xmlChar *name; + xmlChar *value; +}XmlAttrib; + +typedef struct _XmlElement +{ + List attribs; + xmlReaderTypes type; + xmlChar *name; + xmlChar *value; +}XmlElement; + +typedef struct _XmlParser +{ + XmlFile file; + XmlDataList parsedData; + + void (*HandleAttributes)(const xmlChar *inName, int inCount, struct _XmlParser *inParser); + void (*HandleTextValue)(const xmlChar *inName, xmlChar *inValue, struct _XmlParser *inParser); + void (*HandleEndElement)(const xmlChar *inName, struct _XmlParser *inParser); + void (*HandleBeginElement)(const xmlChar *inName, struct _XmlParser *inParser); + +}XmlParser; + +typedef struct _XmlFileTree +{ + Tree tree; + List delAttribs; //attribute pointers are added here to be freed at the end +}XmlFileTree; + +//Note: Remember to call XmlFreeParser after done with the parser +int XmlCreateParser(XmlParser *parser, const char *fileName, + void *HandleAttribute, void *HandleTextValue, void *HandleEndElement, + void *HandleBeginElement); + +int XmlCreateParserFromMem(XmlParser *parser, const char *buffer, int size, + void *HandleAttribute, void *HandleTextValue, void *HandleEndElement, + void *HandleBeginElement); + +//gets the number of attributes assuming file reader is currently at an element with attributes +int XmlGetNumAttributes(XmlFile file); + +//gets the attribute assuming file reader is currently at an element with attributes +//outAttribName is the address to an xmlChar which will point to the name of the attribute +//if name of the attribtue is not wanted, set outAttribName to 0 +//Note: User is expected to free the strings returned +xmlChar *XmlGetAttributeByIndex(XmlFile file, int index, xmlChar **outAttribName); + +//gets the attribute assuming file reader is currently at an element with attributes +//Note: User is expected to free the string returned +xmlChar *XmlGetAttributeByName(XmlFile file, const char *name); + +const xmlChar *XmlGetElementValue(XmlParser *parser, const xmlChar *elementName); + +//gets the name of the element to which this node belongs +const xmlChar *XmlGetElementName(XmlDataList *currNode); + +//get the strings within an element block associated to a certain tag +//Note: User is expected to free XmlTextNode +int XmlGetStringsInElementBlock(XmlDataList *currNode, const xmlChar *name, const xmlChar *elementName, + XmlTextNode **head, XmlEnum direction); + +int XmlBuildFileTree(const char *xmlFile, XmlFileTree *fileTree); //parse file into a big tree +int XmlBuildFileTreeFromMem(const char *buffer, int bufSize, XmlFileTree *fileTree); //parse file into a big tree +void XmlParseFile(XmlParser *reader); //run parser +void XmlFreeFileTree(XmlFileTree *fileTree); +void XmlFreeString(xmlChar *s); +void XmlFreeParser(XmlParser *parser); +void XmlFreeTextNodes(XmlTextNode *head); + +int XmlFileTreeGetElement(const TreeNode *treeHead, const char *name, XmlElement **outElement); +int XmlFileTreeGetElements(const TreeNode *treeHead, const char *parentName, List *addList, int valuesOnly); +int XmlFileTreeGetNodes(const TreeNode *treeHead, const char *parentName, List *addList); + +#endif + +//EOF + diff --git a/include/zconf.h b/include/zconf.h new file mode 100755 index 0000000..4919b35 --- /dev/null +++ b/include/zconf.h @@ -0,0 +1,332 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/include/zlib.h b/include/zlib.h new file mode 100755 index 0000000..62d0e46 --- /dev/null +++ b/include/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/lib/irtrack.a b/lib/irtrack.a new file mode 100644 index 0000000..da0f93b Binary files /dev/null and b/lib/irtrack.a differ diff --git a/lib/jpeglib.a b/lib/jpeglib.a new file mode 100644 index 0000000..cbf7b7a Binary files /dev/null and b/lib/jpeglib.a differ diff --git a/lib/libDongle.a b/lib/libDongle.a new file mode 100644 index 0000000..a82ebcc Binary files /dev/null and b/lib/libDongle.a differ diff --git a/lib/libGLEW.a b/lib/libGLEW.a new file mode 100755 index 0000000..9fb2cef Binary files /dev/null and b/lib/libGLEW.a differ diff --git a/lib/libHASP.a b/lib/libHASP.a new file mode 100755 index 0000000..0c8de7f Binary files /dev/null and b/lib/libHASP.a differ diff --git a/lib/libModem.a b/lib/libModem.a new file mode 100644 index 0000000..ee0874d Binary files /dev/null and b/lib/libModem.a differ diff --git a/lib/libTelemetry.a b/lib/libTelemetry.a new file mode 100644 index 0000000..a7988a6 Binary files /dev/null and b/lib/libTelemetry.a differ diff --git a/lib/libXmlWrapper.a b/lib/libXmlWrapper.a new file mode 100644 index 0000000..cd38069 Binary files /dev/null and b/lib/libXmlWrapper.a differ diff --git a/lib/libcard.a b/lib/libcard.a new file mode 100644 index 0000000..fb2fd74 Binary files /dev/null and b/lib/libcard.a differ diff --git a/lib/libcrypto.a b/lib/libcrypto.a new file mode 100755 index 0000000..21c6742 Binary files /dev/null and b/lib/libcrypto.a differ diff --git a/lib/libcv.a b/lib/libcv.a new file mode 100755 index 0000000..dda1f62 Binary files /dev/null and b/lib/libcv.a differ diff --git a/lib/libcxcore.a b/lib/libcxcore.a new file mode 100755 index 0000000..dd91a91 Binary files /dev/null and b/lib/libcxcore.a differ diff --git a/lib/libhid.a b/lib/libhid.a new file mode 100755 index 0000000..4ac95ec Binary files /dev/null and b/lib/libhid.a differ diff --git a/lib/libhid.la b/lib/libhid.la new file mode 100755 index 0000000..2242634 --- /dev/null +++ b/lib/libhid.la @@ -0,0 +1,35 @@ +# libhid.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libhid.a' + +# Libraries that this one depends upon. +dependency_libs=' -L/g3/libusb/lib /g3/libusb/lib/libusb.la' + +# Version information for libhid. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libhid/lib' diff --git a/lib/libjamma.a b/lib/libjamma.a new file mode 100644 index 0000000..e8c06fc Binary files /dev/null and b/lib/libjamma.a differ diff --git a/lib/libjps.a b/lib/libjps.a new file mode 100644 index 0000000..cc45f59 Binary files /dev/null and b/lib/libjps.a differ diff --git a/lib/libpmrt_compression.a b/lib/libpmrt_compression.a new file mode 100644 index 0000000..5329bae Binary files /dev/null and b/lib/libpmrt_compression.a differ diff --git a/lib/libpmrt_messages.a b/lib/libpmrt_messages.a new file mode 100644 index 0000000..f2dfbdf Binary files /dev/null and b/lib/libpmrt_messages.a differ diff --git a/lib/libpmrt_ssl.a b/lib/libpmrt_ssl.a new file mode 100644 index 0000000..62794f3 Binary files /dev/null and b/lib/libpmrt_ssl.a differ diff --git a/lib/libpmrt_utils.a b/lib/libpmrt_utils.a new file mode 100644 index 0000000..6de64d3 Binary files /dev/null and b/lib/libpmrt_utils.a differ diff --git a/lib/libpsm_engine.a b/lib/libpsm_engine.a new file mode 100644 index 0000000..c29fb14 Binary files /dev/null and b/lib/libpsm_engine.a differ diff --git a/lib/librockeyapi.a b/lib/librockeyapi.a new file mode 100755 index 0000000..f2afd84 Binary files /dev/null and b/lib/librockeyapi.a differ diff --git a/lib/libssl.a b/lib/libssl.a new file mode 100755 index 0000000..2c8cf64 Binary files /dev/null and b/lib/libssl.a differ diff --git a/lib/libusb-0.1.so.4 b/lib/libusb-0.1.so.4 new file mode 100755 index 0000000..a0d84bc Binary files /dev/null and b/lib/libusb-0.1.so.4 differ diff --git a/lib/libusb-0.1.so.4.4.4 b/lib/libusb-0.1.so.4.4.4 new file mode 100755 index 0000000..a0d84bc Binary files /dev/null and b/lib/libusb-0.1.so.4.4.4 differ diff --git a/lib/libusb.a b/lib/libusb.a new file mode 100755 index 0000000..a75e6e4 Binary files /dev/null and b/lib/libusb.a differ diff --git a/lib/libusb.la b/lib/libusb.la new file mode 100755 index 0000000..9708651 --- /dev/null +++ b/lib/libusb.la @@ -0,0 +1,35 @@ +# libusb.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.6 (1.1220.2.95 2004/04/11 05:50:42) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libusb-0.1.so.4' + +# Names of this library. +library_names='libusb-0.1.so.4.4.4 libusb-0.1.so.4 libusb.so' + +# The name of the static archive. +old_library='libusb.a' + +# Libraries that this one depends upon. +dependency_libs='' + +# Version information for libusb. +current=8 +age=4 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libusb/lib' diff --git a/lib/libusb.so b/lib/libusb.so new file mode 100755 index 0000000..a0d84bc Binary files /dev/null and b/lib/libusb.so differ diff --git a/lib/libusbpp-0.1.so.4 b/lib/libusbpp-0.1.so.4 new file mode 100755 index 0000000..7e7a6ad Binary files /dev/null and b/lib/libusbpp-0.1.so.4 differ diff --git a/lib/libusbpp-0.1.so.4.4.4 b/lib/libusbpp-0.1.so.4.4.4 new file mode 100755 index 0000000..7e7a6ad Binary files /dev/null and b/lib/libusbpp-0.1.so.4.4.4 differ diff --git a/lib/libusbpp.a b/lib/libusbpp.a new file mode 100755 index 0000000..96cfc9e Binary files /dev/null and b/lib/libusbpp.a differ diff --git a/lib/libusbpp.la b/lib/libusbpp.la new file mode 100755 index 0000000..999c2b6 --- /dev/null +++ b/lib/libusbpp.la @@ -0,0 +1,35 @@ +# libusbpp.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.6 (1.1220.2.95 2004/04/11 05:50:42) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libusbpp-0.1.so.4' + +# Names of this library. +library_names='libusbpp-0.1.so.4.4.4 libusbpp-0.1.so.4 libusbpp.so' + +# The name of the static archive. +old_library='libusbpp.a' + +# Libraries that this one depends upon. +dependency_libs=' /g3/libusb/lib/libusb.la /usr/lib/./libstdc++.la -L/usr/i486-slackware-linux/bin -L/usr/i486-slackware-linux/lib' + +# Version information for libusbpp. +current=8 +age=4 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libusb/lib' diff --git a/lib/libusbpp.so b/lib/libusbpp.so new file mode 100755 index 0000000..7e7a6ad Binary files /dev/null and b/lib/libusbpp.so differ diff --git a/lib/libxml2.la b/lib/libxml2.la new file mode 100755 index 0000000..b2f48fc --- /dev/null +++ b/lib/libxml2.la @@ -0,0 +1,35 @@ +# libxml2.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5 (1.1220.2.1 2003/04/14 22:48:00) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libxml2.so.2' + +# Names of this library. +library_names='libxml2.so.2.6.13 libxml2.so.2 libxml2.so' + +# The name of the static archive. +old_library='libxml2.a' + +# Libraries that this one depends upon. +dependency_libs=' -lpthread -lz -lm' + +# Version information for libxml2. +current=8 +age=6 +revision=13 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libxml/lib' diff --git a/lib/libxml2.so b/lib/libxml2.so new file mode 100755 index 0000000..df2fce9 Binary files /dev/null and b/lib/libxml2.so differ diff --git a/lib/libxml2.so.2 b/lib/libxml2.so.2 new file mode 100755 index 0000000..df2fce9 Binary files /dev/null and b/lib/libxml2.so.2 differ diff --git a/lib/libxml2.so.2.6.13 b/lib/libxml2.so.2.6.13 new file mode 100755 index 0000000..df2fce9 Binary files /dev/null and b/lib/libxml2.so.2.6.13 differ diff --git a/lib/libz.a b/lib/libz.a new file mode 100755 index 0000000..1fd5364 Binary files /dev/null and b/lib/libz.a differ diff --git a/lib/lungif.a b/lib/lungif.a new file mode 100644 index 0000000..b78049a Binary files /dev/null and b/lib/lungif.a differ diff --git a/lib/vssver.scc b/lib/vssver.scc new file mode 100755 index 0000000..b1b6bf5 Binary files /dev/null and b/lib/vssver.scc differ diff --git a/lib/xml2Conf.sh b/lib/xml2Conf.sh new file mode 100755 index 0000000..554f53c --- /dev/null +++ b/lib/xml2Conf.sh @@ -0,0 +1,8 @@ +# +# Configuration file for using the XML library in GNOME applications +# +XML2_LIBDIR="-L/g3/libxml/lib" +XML2_LIBS="-lxml2 -lz -lpthread -lm " +XML2_INCLUDEDIR="-I/g3/libxml/include/libxml2" +MODULE_VERSION="xml2-2.6.13" + diff --git a/libraries/dnslookup.c b/libraries/dnslookup.c new file mode 100755 index 0000000..e69de29 diff --git a/libraries/external/dsound/lib/dsound.lib b/libraries/external/dsound/lib/dsound.lib new file mode 100755 index 0000000..6e9604d Binary files /dev/null and b/libraries/external/dsound/lib/dsound.lib differ diff --git a/libraries/external/dsound/lib/vssver.scc b/libraries/external/dsound/lib/vssver.scc new file mode 100755 index 0000000..b193c0e Binary files /dev/null and b/libraries/external/dsound/lib/vssver.scc differ diff --git a/libraries/external/eldos/pc/include/ElAES.cpp b/libraries/external/eldos/pc/include/ElAES.cpp new file mode 100755 index 0000000..7dab899 --- /dev/null +++ b/libraries/external/eldos/pc/include/ElAES.cpp @@ -0,0 +1,1749 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "ElAES.h" + +unsigned long Rcon[31] = { 0, + 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, + 0x00000040, 0x00000080, 0x0000001B, 0x00000036, 0x0000006C, 0x000000D8, + 0x000000AB, 0x0000004D, 0x0000009A, 0x0000002F, 0x0000005E, 0x000000BC, + 0x00000063, 0x000000C6, 0x00000097, 0x00000035, 0x0000006A, 0x000000D4, + 0x000000B3, 0x0000007D, 0x000000FA, 0x000000EF, 0x000000C5, 0x00000091 +}; + +unsigned long ForwardTable[256] = { + 0xA56363C6, 0x847C7CF8, 0x997777EE, 0x8D7B7BF6, 0x0DF2F2FF, 0xBD6B6BD6, 0xB16F6FDE, 0x54C5C591, + 0x50303060, 0x03010102, 0xA96767CE, 0x7D2B2B56, 0x19FEFEE7, 0x62D7D7B5, 0xE6ABAB4D, 0x9A7676EC, + 0x45CACA8F, 0x9D82821F, 0x40C9C989, 0x877D7DFA, 0x15FAFAEF, 0xEB5959B2, 0xC947478E, 0x0BF0F0FB, + 0xECADAD41, 0x67D4D4B3, 0xFDA2A25F, 0xEAAFAF45, 0xBF9C9C23, 0xF7A4A453, 0x967272E4, 0x5BC0C09B, + 0xC2B7B775, 0x1CFDFDE1, 0xAE93933D, 0x6A26264C, 0x5A36366C, 0x413F3F7E, 0x02F7F7F5, 0x4FCCCC83, + 0x5C343468, 0xF4A5A551, 0x34E5E5D1, 0x08F1F1F9, 0x937171E2, 0x73D8D8AB, 0x53313162, 0x3F15152A, + 0x0C040408, 0x52C7C795, 0x65232346, 0x5EC3C39D, 0x28181830, 0xA1969637, 0x0F05050A, 0xB59A9A2F, + 0x0907070E, 0x36121224, 0x9B80801B, 0x3DE2E2DF, 0x26EBEBCD, 0x6927274E, 0xCDB2B27F, 0x9F7575EA, + 0x1B090912, 0x9E83831D, 0x742C2C58, 0x2E1A1A34, 0x2D1B1B36, 0xB26E6EDC, 0xEE5A5AB4, 0xFBA0A05B, + 0xF65252A4, 0x4D3B3B76, 0x61D6D6B7, 0xCEB3B37D, 0x7B292952, 0x3EE3E3DD, 0x712F2F5E, 0x97848413, + 0xF55353A6, 0x68D1D1B9, 0x00000000, 0x2CEDEDC1, 0x60202040, 0x1FFCFCE3, 0xC8B1B179, 0xED5B5BB6, + 0xBE6A6AD4, 0x46CBCB8D, 0xD9BEBE67, 0x4B393972, 0xDE4A4A94, 0xD44C4C98, 0xE85858B0, 0x4ACFCF85, + 0x6BD0D0BB, 0x2AEFEFC5, 0xE5AAAA4F, 0x16FBFBED, 0xC5434386, 0xD74D4D9A, 0x55333366, 0x94858511, + 0xCF45458A, 0x10F9F9E9, 0x06020204, 0x817F7FFE, 0xF05050A0, 0x443C3C78, 0xBA9F9F25, 0xE3A8A84B, + 0xF35151A2, 0xFEA3A35D, 0xC0404080, 0x8A8F8F05, 0xAD92923F, 0xBC9D9D21, 0x48383870, 0x04F5F5F1, + 0xDFBCBC63, 0xC1B6B677, 0x75DADAAF, 0x63212142, 0x30101020, 0x1AFFFFE5, 0x0EF3F3FD, 0x6DD2D2BF, + 0x4CCDCD81, 0x140C0C18, 0x35131326, 0x2FECECC3, 0xE15F5FBE, 0xA2979735, 0xCC444488, 0x3917172E, + 0x57C4C493, 0xF2A7A755, 0x827E7EFC, 0x473D3D7A, 0xAC6464C8, 0xE75D5DBA, 0x2B191932, 0x957373E6, + 0xA06060C0, 0x98818119, 0xD14F4F9E, 0x7FDCDCA3, 0x66222244, 0x7E2A2A54, 0xAB90903B, 0x8388880B, + 0xCA46468C, 0x29EEEEC7, 0xD3B8B86B, 0x3C141428, 0x79DEDEA7, 0xE25E5EBC, 0x1D0B0B16, 0x76DBDBAD, + 0x3BE0E0DB, 0x56323264, 0x4E3A3A74, 0x1E0A0A14, 0xDB494992, 0x0A06060C, 0x6C242448, 0xE45C5CB8, + 0x5DC2C29F, 0x6ED3D3BD, 0xEFACAC43, 0xA66262C4, 0xA8919139, 0xA4959531, 0x37E4E4D3, 0x8B7979F2, + 0x32E7E7D5, 0x43C8C88B, 0x5937376E, 0xB76D6DDA, 0x8C8D8D01, 0x64D5D5B1, 0xD24E4E9C, 0xE0A9A949, + 0xB46C6CD8, 0xFA5656AC, 0x07F4F4F3, 0x25EAEACF, 0xAF6565CA, 0x8E7A7AF4, 0xE9AEAE47, 0x18080810, + 0xD5BABA6F, 0x887878F0, 0x6F25254A, 0x722E2E5C, 0x241C1C38, 0xF1A6A657, 0xC7B4B473, 0x51C6C697, + 0x23E8E8CB, 0x7CDDDDA1, 0x9C7474E8, 0x211F1F3E, 0xDD4B4B96, 0xDCBDBD61, 0x868B8B0D, 0x858A8A0F, + 0x907070E0, 0x423E3E7C, 0xC4B5B571, 0xAA6666CC, 0xD8484890, 0x05030306, 0x01F6F6F7, 0x120E0E1C, + 0xA36161C2, 0x5F35356A, 0xF95757AE, 0xD0B9B969, 0x91868617, 0x58C1C199, 0x271D1D3A, 0xB99E9E27, + 0x38E1E1D9, 0x13F8F8EB, 0xB398982B, 0x33111122, 0xBB6969D2, 0x70D9D9A9, 0x898E8E07, 0xA7949433, + 0xB69B9B2D, 0x221E1E3C, 0x92878715, 0x20E9E9C9, 0x49CECE87, 0xFF5555AA, 0x78282850, 0x7ADFDFA5, + 0x8F8C8C03, 0xF8A1A159, 0x80898909, 0x170D0D1A, 0xDABFBF65, 0x31E6E6D7, 0xC6424284, 0xB86868D0, + 0xC3414182, 0xB0999929, 0x772D2D5A, 0x110F0F1E, 0xCBB0B07B, 0xFC5454A8, 0xD6BBBB6D, 0x3A16162C +}; + +unsigned long LastForwardTable[256] = { + 0x00000063, 0x0000007C, 0x00000077, 0x0000007B, 0x000000F2, 0x0000006B, 0x0000006F, 0x000000C5, + 0x00000030, 0x00000001, 0x00000067, 0x0000002B, 0x000000FE, 0x000000D7, 0x000000AB, 0x00000076, + 0x000000CA, 0x00000082, 0x000000C9, 0x0000007D, 0x000000FA, 0x00000059, 0x00000047, 0x000000F0, + 0x000000AD, 0x000000D4, 0x000000A2, 0x000000AF, 0x0000009C, 0x000000A4, 0x00000072, 0x000000C0, + 0x000000B7, 0x000000FD, 0x00000093, 0x00000026, 0x00000036, 0x0000003F, 0x000000F7, 0x000000CC, + 0x00000034, 0x000000A5, 0x000000E5, 0x000000F1, 0x00000071, 0x000000D8, 0x00000031, 0x00000015, + 0x00000004, 0x000000C7, 0x00000023, 0x000000C3, 0x00000018, 0x00000096, 0x00000005, 0x0000009A, + 0x00000007, 0x00000012, 0x00000080, 0x000000E2, 0x000000EB, 0x00000027, 0x000000B2, 0x00000075, + 0x00000009, 0x00000083, 0x0000002C, 0x0000001A, 0x0000001B, 0x0000006E, 0x0000005A, 0x000000A0, + 0x00000052, 0x0000003B, 0x000000D6, 0x000000B3, 0x00000029, 0x000000E3, 0x0000002F, 0x00000084, + 0x00000053, 0x000000D1, 0x00000000, 0x000000ED, 0x00000020, 0x000000FC, 0x000000B1, 0x0000005B, + 0x0000006A, 0x000000CB, 0x000000BE, 0x00000039, 0x0000004A, 0x0000004C, 0x00000058, 0x000000CF, + 0x000000D0, 0x000000EF, 0x000000AA, 0x000000FB, 0x00000043, 0x0000004D, 0x00000033, 0x00000085, + 0x00000045, 0x000000F9, 0x00000002, 0x0000007F, 0x00000050, 0x0000003C, 0x0000009F, 0x000000A8, + 0x00000051, 0x000000A3, 0x00000040, 0x0000008F, 0x00000092, 0x0000009D, 0x00000038, 0x000000F5, + 0x000000BC, 0x000000B6, 0x000000DA, 0x00000021, 0x00000010, 0x000000FF, 0x000000F3, 0x000000D2, + 0x000000CD, 0x0000000C, 0x00000013, 0x000000EC, 0x0000005F, 0x00000097, 0x00000044, 0x00000017, + 0x000000C4, 0x000000A7, 0x0000007E, 0x0000003D, 0x00000064, 0x0000005D, 0x00000019, 0x00000073, + 0x00000060, 0x00000081, 0x0000004F, 0x000000DC, 0x00000022, 0x0000002A, 0x00000090, 0x00000088, + 0x00000046, 0x000000EE, 0x000000B8, 0x00000014, 0x000000DE, 0x0000005E, 0x0000000B, 0x000000DB, + 0x000000E0, 0x00000032, 0x0000003A, 0x0000000A, 0x00000049, 0x00000006, 0x00000024, 0x0000005C, + 0x000000C2, 0x000000D3, 0x000000AC, 0x00000062, 0x00000091, 0x00000095, 0x000000E4, 0x00000079, + 0x000000E7, 0x000000C8, 0x00000037, 0x0000006D, 0x0000008D, 0x000000D5, 0x0000004E, 0x000000A9, + 0x0000006C, 0x00000056, 0x000000F4, 0x000000EA, 0x00000065, 0x0000007A, 0x000000AE, 0x00000008, + 0x000000BA, 0x00000078, 0x00000025, 0x0000002E, 0x0000001C, 0x000000A6, 0x000000B4, 0x000000C6, + 0x000000E8, 0x000000DD, 0x00000074, 0x0000001F, 0x0000004B, 0x000000BD, 0x0000008B, 0x0000008A, + 0x00000070, 0x0000003E, 0x000000B5, 0x00000066, 0x00000048, 0x00000003, 0x000000F6, 0x0000000E, + 0x00000061, 0x00000035, 0x00000057, 0x000000B9, 0x00000086, 0x000000C1, 0x0000001D, 0x0000009E, + 0x000000E1, 0x000000F8, 0x00000098, 0x00000011, 0x00000069, 0x000000D9, 0x0000008E, 0x00000094, + 0x0000009B, 0x0000001E, 0x00000087, 0x000000E9, 0x000000CE, 0x00000055, 0x00000028, 0x000000DF, + 0x0000008C, 0x000000A1, 0x00000089, 0x0000000D, 0x000000BF, 0x000000E6, 0x00000042, 0x00000068, + 0x00000041, 0x00000099, 0x0000002D, 0x0000000F, 0x000000B0, 0x00000054, 0x000000BB, 0x00000016 +}; + +unsigned long InverseTable[256] = { + 0x50A7F451, 0x5365417E, 0xC3A4171A, 0x965E273A, 0xCB6BAB3B, 0xF1459D1F, 0xAB58FAAC, 0x9303E34B, + 0x55FA3020, 0xF66D76AD, 0x9176CC88, 0x254C02F5, 0xFCD7E54F, 0xD7CB2AC5, 0x80443526, 0x8FA362B5, + 0x495AB1DE, 0x671BBA25, 0x980EEA45, 0xE1C0FE5D, 0x02752FC3, 0x12F04C81, 0xA397468D, 0xC6F9D36B, + 0xE75F8F03, 0x959C9215, 0xEB7A6DBF, 0xDA595295, 0x2D83BED4, 0xD3217458, 0x2969E049, 0x44C8C98E, + 0x6A89C275, 0x78798EF4, 0x6B3E5899, 0xDD71B927, 0xB64FE1BE, 0x17AD88F0, 0x66AC20C9, 0xB43ACE7D, + 0x184ADF63, 0x82311AE5, 0x60335197, 0x457F5362, 0xE07764B1, 0x84AE6BBB, 0x1CA081FE, 0x942B08F9, + 0x58684870, 0x19FD458F, 0x876CDE94, 0xB7F87B52, 0x23D373AB, 0xE2024B72, 0x578F1FE3, 0x2AAB5566, + 0x0728EBB2, 0x03C2B52F, 0x9A7BC586, 0xA50837D3, 0xF2872830, 0xB2A5BF23, 0xBA6A0302, 0x5C8216ED, + 0x2B1CCF8A, 0x92B479A7, 0xF0F207F3, 0xA1E2694E, 0xCDF4DA65, 0xD5BE0506, 0x1F6234D1, 0x8AFEA6C4, + 0x9D532E34, 0xA055F3A2, 0x32E18A05, 0x75EBF6A4, 0x39EC830B, 0xAAEF6040, 0x069F715E, 0x51106EBD, + 0xF98A213E, 0x3D06DD96, 0xAE053EDD, 0x46BDE64D, 0xB58D5491, 0x055DC471, 0x6FD40604, 0xFF155060, + 0x24FB9819, 0x97E9BDD6, 0xCC434089, 0x779ED967, 0xBD42E8B0, 0x888B8907, 0x385B19E7, 0xDBEEC879, + 0x470A7CA1, 0xE90F427C, 0xC91E84F8, 0x00000000, 0x83868009, 0x48ED2B32, 0xAC70111E, 0x4E725A6C, + 0xFBFF0EFD, 0x5638850F, 0x1ED5AE3D, 0x27392D36, 0x64D90F0A, 0x21A65C68, 0xD1545B9B, 0x3A2E3624, + 0xB1670A0C, 0x0FE75793, 0xD296EEB4, 0x9E919B1B, 0x4FC5C080, 0xA220DC61, 0x694B775A, 0x161A121C, + 0x0ABA93E2, 0xE52AA0C0, 0x43E0223C, 0x1D171B12, 0x0B0D090E, 0xADC78BF2, 0xB9A8B62D, 0xC8A91E14, + 0x8519F157, 0x4C0775AF, 0xBBDD99EE, 0xFD607FA3, 0x9F2601F7, 0xBCF5725C, 0xC53B6644, 0x347EFB5B, + 0x7629438B, 0xDCC623CB, 0x68FCEDB6, 0x63F1E4B8, 0xCADC31D7, 0x10856342, 0x40229713, 0x2011C684, + 0x7D244A85, 0xF83DBBD2, 0x1132F9AE, 0x6DA129C7, 0x4B2F9E1D, 0xF330B2DC, 0xEC52860D, 0xD0E3C177, + 0x6C16B32B, 0x99B970A9, 0xFA489411, 0x2264E947, 0xC48CFCA8, 0x1A3FF0A0, 0xD82C7D56, 0xEF903322, + 0xC74E4987, 0xC1D138D9, 0xFEA2CA8C, 0x360BD498, 0xCF81F5A6, 0x28DE7AA5, 0x268EB7DA, 0xA4BFAD3F, + 0xE49D3A2C, 0x0D927850, 0x9BCC5F6A, 0x62467E54, 0xC2138DF6, 0xE8B8D890, 0x5EF7392E, 0xF5AFC382, + 0xBE805D9F, 0x7C93D069, 0xA92DD56F, 0xB31225CF, 0x3B99ACC8, 0xA77D1810, 0x6E639CE8, 0x7BBB3BDB, + 0x097826CD, 0xF418596E, 0x01B79AEC, 0xA89A4F83, 0x656E95E6, 0x7EE6FFAA, 0x08CFBC21, 0xE6E815EF, + 0xD99BE7BA, 0xCE366F4A, 0xD4099FEA, 0xD67CB029, 0xAFB2A431, 0x31233F2A, 0x3094A5C6, 0xC066A235, + 0x37BC4E74, 0xA6CA82FC, 0xB0D090E0, 0x15D8A733, 0x4A9804F1, 0xF7DAEC41, 0x0E50CD7F, 0x2FF69117, + 0x8DD64D76, 0x4DB0EF43, 0x544DAACC, 0xDF0496E4, 0xE3B5D19E, 0x1B886A4C, 0xB81F2CC1, 0x7F516546, + 0x04EA5E9D, 0x5D358C01, 0x737487FA, 0x2E410BFB, 0x5A1D67B3, 0x52D2DB92, 0x335610E9, 0x1347D66D, + 0x8C61D79A, 0x7A0CA137, 0x8E14F859, 0x893C13EB, 0xEE27A9CE, 0x35C961B7, 0xEDE51CE1, 0x3CB1477A, + 0x59DFD29C, 0x3F73F255, 0x79CE1418, 0xBF37C773, 0xEACDF753, 0x5BAAFD5F, 0x146F3DDF, 0x86DB4478, + 0x81F3AFCA, 0x3EC468B9, 0x2C342438, 0x5F40A3C2, 0x72C31D16, 0x0C25E2BC, 0x8B493C28, 0x41950DFF, + 0x7101A839, 0xDEB30C08, 0x9CE4B4D8, 0x90C15664, 0x6184CB7B, 0x70B632D5, 0x745C6C48, 0x4257B8D0 +}; + +unsigned long LastInverseTable[256] = { + 0x00000052, 0x00000009, 0x0000006A, 0x000000D5, 0x00000030, 0x00000036, 0x000000A5, 0x00000038, + 0x000000BF, 0x00000040, 0x000000A3, 0x0000009E, 0x00000081, 0x000000F3, 0x000000D7, 0x000000FB, + 0x0000007C, 0x000000E3, 0x00000039, 0x00000082, 0x0000009B, 0x0000002F, 0x000000FF, 0x00000087, + 0x00000034, 0x0000008E, 0x00000043, 0x00000044, 0x000000C4, 0x000000DE, 0x000000E9, 0x000000CB, + 0x00000054, 0x0000007B, 0x00000094, 0x00000032, 0x000000A6, 0x000000C2, 0x00000023, 0x0000003D, + 0x000000EE, 0x0000004C, 0x00000095, 0x0000000B, 0x00000042, 0x000000FA, 0x000000C3, 0x0000004E, + 0x00000008, 0x0000002E, 0x000000A1, 0x00000066, 0x00000028, 0x000000D9, 0x00000024, 0x000000B2, + 0x00000076, 0x0000005B, 0x000000A2, 0x00000049, 0x0000006D, 0x0000008B, 0x000000D1, 0x00000025, + 0x00000072, 0x000000F8, 0x000000F6, 0x00000064, 0x00000086, 0x00000068, 0x00000098, 0x00000016, + 0x000000D4, 0x000000A4, 0x0000005C, 0x000000CC, 0x0000005D, 0x00000065, 0x000000B6, 0x00000092, + 0x0000006C, 0x00000070, 0x00000048, 0x00000050, 0x000000FD, 0x000000ED, 0x000000B9, 0x000000DA, + 0x0000005E, 0x00000015, 0x00000046, 0x00000057, 0x000000A7, 0x0000008D, 0x0000009D, 0x00000084, + 0x00000090, 0x000000D8, 0x000000AB, 0x00000000, 0x0000008C, 0x000000BC, 0x000000D3, 0x0000000A, + 0x000000F7, 0x000000E4, 0x00000058, 0x00000005, 0x000000B8, 0x000000B3, 0x00000045, 0x00000006, + 0x000000D0, 0x0000002C, 0x0000001E, 0x0000008F, 0x000000CA, 0x0000003F, 0x0000000F, 0x00000002, + 0x000000C1, 0x000000AF, 0x000000BD, 0x00000003, 0x00000001, 0x00000013, 0x0000008A, 0x0000006B, + 0x0000003A, 0x00000091, 0x00000011, 0x00000041, 0x0000004F, 0x00000067, 0x000000DC, 0x000000EA, + 0x00000097, 0x000000F2, 0x000000CF, 0x000000CE, 0x000000F0, 0x000000B4, 0x000000E6, 0x00000073, + 0x00000096, 0x000000AC, 0x00000074, 0x00000022, 0x000000E7, 0x000000AD, 0x00000035, 0x00000085, + 0x000000E2, 0x000000F9, 0x00000037, 0x000000E8, 0x0000001C, 0x00000075, 0x000000DF, 0x0000006E, + 0x00000047, 0x000000F1, 0x0000001A, 0x00000071, 0x0000001D, 0x00000029, 0x000000C5, 0x00000089, + 0x0000006F, 0x000000B7, 0x00000062, 0x0000000E, 0x000000AA, 0x00000018, 0x000000BE, 0x0000001B, + 0x000000FC, 0x00000056, 0x0000003E, 0x0000004B, 0x000000C6, 0x000000D2, 0x00000079, 0x00000020, + 0x0000009A, 0x000000DB, 0x000000C0, 0x000000FE, 0x00000078, 0x000000CD, 0x0000005A, 0x000000F4, + 0x0000001F, 0x000000DD, 0x000000A8, 0x00000033, 0x00000088, 0x00000007, 0x000000C7, 0x00000031, + 0x000000B1, 0x00000012, 0x00000010, 0x00000059, 0x00000027, 0x00000080, 0x000000EC, 0x0000005F, + 0x00000060, 0x00000051, 0x0000007F, 0x000000A9, 0x00000019, 0x000000B5, 0x0000004A, 0x0000000D, + 0x0000002D, 0x000000E5, 0x0000007A, 0x0000009F, 0x00000093, 0x000000C9, 0x0000009C, 0x000000EF, + 0x000000A0, 0x000000E0, 0x0000003B, 0x0000004D, 0x000000AE, 0x0000002A, 0x000000F5, 0x000000B0, + 0x000000C8, 0x000000EB, 0x000000BB, 0x0000003C, 0x00000083, 0x00000053, 0x00000099, 0x00000061, + 0x00000017, 0x0000002B, 0x00000004, 0x0000007E, 0x000000BA, 0x00000077, 0x000000D6, 0x00000026, + 0x000000E1, 0x00000069, 0x00000014, 0x00000063, 0x00000055, 0x00000021, 0x0000000C, 0x0000007D +}; + +void ExpandAESKeyForEncryption128(byte* Key, unsigned long* ExpandedKey) +{ + unsigned long I = 0, J = 1; + unsigned long T; + unsigned long W0, W1, W2, W3; + + ExpandedKey[0] = *(unsigned long*)&Key[0]; + ExpandedKey[1] = *(unsigned long*)&Key[4]; + ExpandedKey[2] = *(unsigned long*)&Key[8]; + ExpandedKey[3] = *(unsigned long*)&Key[12]; + do { + T = (ExpandedKey[I + 3] << 24) | (ExpandedKey[I + 3] >> 8); + W0 = LastForwardTable[(byte)T]; W1 = LastForwardTable[(byte)(T >> 8)]; + W2 = LastForwardTable[(byte)(T >> 16)]; W3 = LastForwardTable[(byte)(T >> 24)]; + ExpandedKey[I + 4] = ExpandedKey[I] ^ + (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ + ((W2 << 16) | (W2 >> 16)) ^ ((W3 << 24) | (W3 >> 8))) ^ Rcon[J]; + J++; + ExpandedKey[I + 5] = ExpandedKey[I + 1] ^ ExpandedKey[I + 4]; + ExpandedKey[I + 6] = ExpandedKey[I + 2] ^ ExpandedKey[I + 5]; + ExpandedKey[I + 7] = ExpandedKey[I + 3] ^ ExpandedKey[I + 6]; + I += 4; + } while (I < 40); +} + +void ExpandAESKeyForEncryption192(byte* Key, unsigned long* ExpandedKey) +{ + unsigned long I = 0, J = 1; + unsigned long T; + unsigned long W0, W1, W2, W3; + + ExpandedKey[0] = *(unsigned long*)&Key[0]; + ExpandedKey[1] = *(unsigned long*)&Key[4]; + ExpandedKey[2] = *(unsigned long*)&Key[8]; + ExpandedKey[3] = *(unsigned long*)&Key[12]; + ExpandedKey[4] = *(unsigned long*)&Key[16]; + ExpandedKey[5] = *(unsigned long*)&Key[20]; + do { + T = (ExpandedKey[I + 5] << 24) | (ExpandedKey[I + 5] >> 8); + W0 = LastForwardTable[(byte)T]; W1 = LastForwardTable[(byte)(T >> 8)]; + W2 = LastForwardTable[(byte)(T >> 16)]; W3 = LastForwardTable[(byte)(T >> 24)]; + ExpandedKey[I + 6] = ExpandedKey[I] ^ + (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ + ((W2 << 16) | (W2 >> 16)) ^ ((W3 << 24) | (W3 >> 8))) ^ Rcon[J]; + J++; + ExpandedKey[I + 7] = ExpandedKey[I + 1] ^ ExpandedKey[I + 6]; + ExpandedKey[I + 8] = ExpandedKey[I + 2] ^ ExpandedKey[I + 7]; + ExpandedKey[I + 9] = ExpandedKey[I + 3] ^ ExpandedKey[I + 8]; + ExpandedKey[I + 10] = ExpandedKey[I + 4] ^ ExpandedKey[I + 9]; + ExpandedKey[I + 11] = ExpandedKey[I + 5] ^ ExpandedKey[I + 10]; + I += 6; + } while (I < 46); +} + +void ExpandAESKeyForEncryption256(byte* Key, unsigned long* ExpandedKey) +{ + unsigned long I = 0, J = 1; + unsigned long T; + unsigned long W0, W1, W2, W3; + + ExpandedKey[0] = *(unsigned long*)&Key[0]; + ExpandedKey[1] = *(unsigned long*)&Key[4]; + ExpandedKey[2] = *(unsigned long*)&Key[8]; + ExpandedKey[3] = *(unsigned long*)&Key[12]; + ExpandedKey[4] = *(unsigned long*)&Key[16]; + ExpandedKey[5] = *(unsigned long*)&Key[20]; + ExpandedKey[6] = *(unsigned long*)&Key[24]; + ExpandedKey[7] = *(unsigned long*)&Key[28]; + do { + T = (ExpandedKey[I + 7] << 24) | (ExpandedKey[I + 7] >> 8); + W0 = LastForwardTable[(byte)T]; W1 = LastForwardTable[(byte)(T >> 8)]; + W2 = LastForwardTable[(byte)(T >> 16)]; W3 = LastForwardTable[(byte)(T >> 24)]; + ExpandedKey[I + 8] = ExpandedKey[I] ^ + (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ + ((W2 << 16) | (W2 >> 16)) ^ ((W3 << 24) | (W3 >> 8))) ^ Rcon[J]; + J++; + ExpandedKey[I + 9] = ExpandedKey[I + 1] ^ ExpandedKey[I + 8]; + ExpandedKey[I + 10] = ExpandedKey[I + 2] ^ ExpandedKey[I + 9]; + ExpandedKey[I + 11] = ExpandedKey[I + 3] ^ ExpandedKey[I + 10]; + W0 = LastForwardTable[(byte)(ExpandedKey[I + 11])]; + W1 = LastForwardTable[(byte)(ExpandedKey[I + 11] >> 8)]; + W2 = LastForwardTable[(byte)(ExpandedKey[I + 11] >> 16)]; + W3 = LastForwardTable[(byte)(ExpandedKey[I + 11] >> 24)]; + ExpandedKey[I + 12] = ExpandedKey[I + 4] ^ + (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ + ((W2 << 16) | (W2 >> 16)) ^ ((W3 << 24) | (W3 >> 8))); + ExpandedKey[I + 13] = ExpandedKey[I + 5] ^ ExpandedKey[I + 12]; + ExpandedKey[I + 14] = ExpandedKey[I + 6] ^ ExpandedKey[I + 13]; + ExpandedKey[I + 15] = ExpandedKey[I + 7] ^ ExpandedKey[I + 14]; + I += 8; + } while (I < 52); +} + +void ExpandAESKeyForDecryption128(unsigned long* ExpandedKey) +{ + unsigned long I; + unsigned long U, F2, F4, F8, F9; + + for(I = 1;I <= 9;I++) + { + F9 = ExpandedKey[I * 4]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 1]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 1] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 2]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 2] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 3]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 3] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + } +} + +void ExpandAESKeyForDecryption128(byte* Key, unsigned long* ExpandedKey) +{ + ExpandAESKeyForEncryption128(Key, ExpandedKey); + ExpandAESKeyForDecryption128(ExpandedKey); +} + +void ExpandAESKeyForDecryption192(unsigned long* ExpandedKey) +{ + unsigned long I; + unsigned long U, F2, F4, F8, F9; + + for(I = 1;I <= 11;I++) + { + F9 = ExpandedKey[I * 4]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 1]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 1] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 2]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 2] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 3]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 3] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + } +} + +void ExpandAESKeyForDecryption192(byte* Key, unsigned long* ExpandedKey) +{ + ExpandAESKeyForEncryption192(Key, ExpandedKey); + ExpandAESKeyForDecryption192(ExpandedKey); +} + +void ExpandAESKeyForDecryption256(unsigned long* ExpandedKey) +{ + unsigned long I; + unsigned long U, F2, F4, F8, F9; + + for(I = 1;I <= 13;I++) + { + F9 = ExpandedKey[I * 4]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 1]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 1] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 2]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 2] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + F9 = ExpandedKey[I * 4 + 3]; + U = F9 & 0x80808080; + F2 = ((F9 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F2 & 0x80808080; + F4 = ((F2 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + U = F4 & 0x80808080; + F8 = ((F4 & 0x7F7F7F7F) << 1) ^ ((U - (U >> 7)) & 0x1B1B1B1B); + F9 = F9 ^ F8; + ExpandedKey[I * 4 + 3] = F2 ^ F4 ^ F8 ^ + (((F2 ^ F9) << 24) | ((F2 ^ F9) >> 8)) ^ + (((F4 ^ F9) << 16) | ((F4 ^ F9) >> 16)) ^ ((F9 << 8) | (F9 >> 24)); + } +} + +void ExpandAESKeyForDecryption256(byte* Key, unsigned long* ExpandedKey) +{ + ExpandAESKeyForEncryption256(Key, ExpandedKey); + ExpandAESKeyForDecryption256(ExpandedKey); +} + +void EncryptAES128(byte* InBuf, const unsigned long* Key, byte* OutBuf) +{ + unsigned long T0[4], T1[4]; + unsigned long W0, W1, W2, W3; + + // initializing + T0[0] = *(unsigned long*)&InBuf[0] ^ Key[0]; + T0[1] = *(unsigned long*)&InBuf[4] ^ Key[1]; + T0[2] = *(unsigned long*)&InBuf[8] ^ Key[2]; + T0[3] = *(unsigned long*)&InBuf[12] ^ Key[3]; + // performing transformation 9 times + // round 1 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[4]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[5]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[6]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[7]; + // round 2 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[8]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[9]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[10]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[11]; + // round 3 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[12]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[13]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[14]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[15]; + // round 4 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[16]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[17]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[18]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[19]; + // round 5 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[20]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[21]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[22]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[23]; + // round 6 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[24]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[25]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[26]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[27]; + // round 7 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[28]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[29]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[30]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[31]; + // round 8 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[32]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[33]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[34]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[35]; + // round 9 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[36]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[37]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[38]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[39]; + // last round of transformations + W0 = LastForwardTable[(byte)T1[0]]; W1 = LastForwardTable[(byte)(T1[1] >> 8)]; + W2 = LastForwardTable[(byte)(T1[2] >> 16)]; W3 = LastForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[40]; + W0 = LastForwardTable[(byte)T1[1]]; W1 = LastForwardTable[(byte)(T1[2] >> 8)]; + W2 = LastForwardTable[(byte)(T1[3] >> 16)]; W3 = LastForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[41]; + W0 = LastForwardTable[(byte)T1[2]]; W1 = LastForwardTable[(byte)(T1[3] >> 8)]; + W2 = LastForwardTable[(byte)(T1[0] >> 16)]; W3 = LastForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[42]; + W0 = LastForwardTable[(byte)T1[3]]; W1 = LastForwardTable[(byte)(T1[0] >> 8)]; + W2 = LastForwardTable[(byte)(T1[1] >> 16)]; W3 = LastForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[43]; + // finalizing + *(unsigned long*)&OutBuf[0] = T0[0]; *(unsigned long*)&OutBuf[4] = T0[1]; + *(unsigned long*)&OutBuf[8] = T0[2]; *(unsigned long*)&OutBuf[12] = T0[3]; +} + +void EncryptAES192(byte* InBuf, const unsigned long* Key, byte* OutBuf) +{ + unsigned long T0[4], T1[4]; + unsigned long W0, W1, W2, W3; + + // initializing + T0[0] = *(unsigned long*)&InBuf[0] ^ Key[0]; + T0[1] = *(unsigned long*)&InBuf[4] ^ Key[1]; + T0[2] = *(unsigned long*)&InBuf[8] ^ Key[2]; + T0[3] = *(unsigned long*)&InBuf[12] ^ Key[3]; + // performing transformation 11 times + // round 1 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[4]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[5]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[6]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[7]; + // round 2 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[8]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[9]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[10]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[11]; + // round 3 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[12]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[13]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[14]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[15]; + // round 4 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[16]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[17]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[18]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[19]; + // round 5 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[20]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[21]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[22]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[23]; + // round 6 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[24]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[25]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[26]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[27]; + // round 7 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[28]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[29]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[30]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[31]; + // round 8 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[32]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[33]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[34]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[35]; + // round 9 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[36]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[37]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[38]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[39]; + // round 10 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[40]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[41]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[42]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[43]; + // round 11 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[44]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[45]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[46]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[47]; + // last round of transformations + W0 = LastForwardTable[(byte)T1[0]]; W1 = LastForwardTable[(byte)(T1[1] >> 8)]; + W2 = LastForwardTable[(byte)(T1[2] >> 16)]; W3 = LastForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[48]; + W0 = LastForwardTable[(byte)T1[1]]; W1 = LastForwardTable[(byte)(T1[2] >> 8)]; + W2 = LastForwardTable[(byte)(T1[3] >> 16)]; W3 = LastForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[49]; + W0 = LastForwardTable[(byte)T1[2]]; W1 = LastForwardTable[(byte)(T1[3] >> 8)]; + W2 = LastForwardTable[(byte)(T1[0] >> 16)]; W3 = LastForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[50]; + W0 = LastForwardTable[(byte)T1[3]]; W1 = LastForwardTable[(byte)(T1[0] >> 8)]; + W2 = LastForwardTable[(byte)(T1[1] >> 16)]; W3 = LastForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[51]; + // finalizing + *(unsigned long*)&OutBuf[0] = T0[0]; *(unsigned long*)&OutBuf[4] = T0[1]; + *(unsigned long*)&OutBuf[8] = T0[2]; *(unsigned long*)&OutBuf[12] = T0[3]; +} + +void EncryptAES256(byte* InBuf, const unsigned long* Key, byte* OutBuf) +{ + unsigned long T0[4], T1[4]; + unsigned long W0, W1, W2, W3; + + // initializing + T0[0] = *(unsigned long*)&InBuf[0] ^ Key[0]; + T0[1] = *(unsigned long*)&InBuf[4] ^ Key[1]; + T0[2] = *(unsigned long*)&InBuf[8] ^ Key[2]; + T0[3] = *(unsigned long*)&InBuf[12] ^ Key[3]; + // performing transformation 13 times + // round 1 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[4]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[5]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[6]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[7]; + // round 2 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[8]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[9]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[10]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[11]; + // round 3 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[12]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[13]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[14]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[15]; + // round 4 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[16]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[17]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[18]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[19]; + // round 5 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[20]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[21]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[22]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[23]; + // round 6 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[24]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[25]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[26]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[27]; + // round 7 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[28]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[29]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[30]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[31]; + // round 8 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[32]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[33]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[34]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[35]; + // round 9 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[36]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[37]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[38]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[39]; + // round 10 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[40]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[41]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[42]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[43]; + // round 11 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[44]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[45]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[46]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[47]; + // round 12 + W0 = ForwardTable[(byte)T1[0]]; W1 = ForwardTable[(byte)(T1[1] >> 8)]; + W2 = ForwardTable[(byte)(T1[2] >> 16)]; W3 = ForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[48]; + W0 = ForwardTable[(byte)T1[1]]; W1 = ForwardTable[(byte)(T1[2] >> 8)]; + W2 = ForwardTable[(byte)(T1[3] >> 16)]; W3 = ForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[49]; + W0 = ForwardTable[(byte)T1[2]]; W1 = ForwardTable[(byte)(T1[3] >> 8)]; + W2 = ForwardTable[(byte)(T1[0] >> 16)]; W3 = ForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[50]; + W0 = ForwardTable[(byte)T1[3]]; W1 = ForwardTable[(byte)(T1[0] >> 8)]; + W2 = ForwardTable[(byte)(T1[1] >> 16)]; W3 = ForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[51]; + // round 13 + W0 = ForwardTable[(byte)T0[0]]; W1 = ForwardTable[(byte)(T0[1] >> 8)]; + W2 = ForwardTable[(byte)(T0[2] >> 16)]; W3 = ForwardTable[(byte)(T0[3] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[52]; + W0 = ForwardTable[(byte)T0[1]]; W1 = ForwardTable[(byte)(T0[2] >> 8)]; + W2 = ForwardTable[(byte)(T0[3] >> 16)]; W3 = ForwardTable[(byte)(T0[0] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[53]; + W0 = ForwardTable[(byte)T0[2]]; W1 = ForwardTable[(byte)(T0[3] >> 8)]; + W2 = ForwardTable[(byte)(T0[0] >> 16)]; W3 = ForwardTable[(byte)(T0[1] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[54]; + W0 = ForwardTable[(byte)T0[3]]; W1 = ForwardTable[(byte)(T0[0] >> 8)]; + W2 = ForwardTable[(byte)(T0[1] >> 16)]; W3 = ForwardTable[(byte)(T0[2] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[55]; + // last round of transformations + W0 = LastForwardTable[(byte)T1[0]]; W1 = LastForwardTable[(byte)(T1[1] >> 8)]; + W2 = LastForwardTable[(byte)(T1[2] >> 16)]; W3 = LastForwardTable[(byte)(T1[3] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[56]; + W0 = LastForwardTable[(byte)T1[1]]; W1 = LastForwardTable[(byte)(T1[2] >> 8)]; + W2 = LastForwardTable[(byte)(T1[3] >> 16)]; W3 = LastForwardTable[(byte)(T1[0] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[57]; + W0 = LastForwardTable[(byte)T1[2]]; W1 = LastForwardTable[(byte)(T1[3] >> 8)]; + W2 = LastForwardTable[(byte)(T1[0] >> 16)]; W3 = LastForwardTable[(byte)(T1[1] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[58]; + W0 = LastForwardTable[(byte)T1[3]]; W1 = LastForwardTable[(byte)(T1[0] >> 8)]; + W2 = LastForwardTable[(byte)(T1[1] >> 16)]; W3 = LastForwardTable[(byte)(T1[2] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[59]; + // finalizing + *(unsigned long*)&OutBuf[0] = T0[0]; *(unsigned long*)&OutBuf[4] = T0[1]; + *(unsigned long*)&OutBuf[8] = T0[2]; *(unsigned long*)&OutBuf[12] = T0[3]; +} + +void DecryptAES128(byte* InBuf, const unsigned long* Key, byte* OutBuf) +{ + unsigned long T0[4], T1[4]; + unsigned long W0, W1, W2, W3; + + // initializing + T0[0] = *(unsigned long*)&InBuf[0] ^ Key[40]; + T0[1] = *(unsigned long*)&InBuf[4] ^ Key[41]; + T0[2] = *(unsigned long*)&InBuf[8] ^ Key[42]; + T0[3] = *(unsigned long*)&InBuf[12] ^ Key[43]; + // performing transformations 9 times + // round 1 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[36]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[37]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[38]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[39]; + // round 2 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[32]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[33]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[34]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[35]; + // round 3 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[28]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[29]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[30]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[31]; + // round 4 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[24]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[25]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[26]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[27]; + // round 5 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[20]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[21]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[22]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[23]; + // round 6 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[16]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[17]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[18]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[19]; + // round 7 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[12]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[13]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[14]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[15]; + // round 8 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[8]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[9]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[10]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[11]; + // round 9 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[4]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[5]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[6]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[7]; + // last round of transformations + W0 = LastInverseTable[(byte)(T1[0])]; W1 = LastInverseTable[(byte)(T1[3] >> 8)]; + W2 = LastInverseTable[(byte)(T1[2] >> 16)]; W3 = LastInverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[0]; + W0 = LastInverseTable[(byte)(T1[1])]; W1 = LastInverseTable[(byte)(T1[0] >> 8)]; + W2 = LastInverseTable[(byte)(T1[3] >> 16)]; W3 = LastInverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[1]; + W0 = LastInverseTable[(byte)(T1[2])]; W1 = LastInverseTable[(byte)(T1[1] >> 8)]; + W2 = LastInverseTable[(byte)(T1[0] >> 16)]; W3 = LastInverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[2]; + W0 = LastInverseTable[(byte)(T1[3])]; W1 = LastInverseTable[(byte)(T1[2] >> 8)]; + W2 = LastInverseTable[(byte)(T1[1] >> 16)]; W3 = LastInverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[3]; + // finalizing + *(unsigned long*)&OutBuf[0] = T0[0]; *(unsigned long*)&OutBuf[4] = T0[1]; + *(unsigned long*)&OutBuf[8] = T0[2]; *(unsigned long*)&OutBuf[12] = T0[3]; +} + +void DecryptAES192(byte* InBuf, const unsigned long* Key, byte* OutBuf) +{ + unsigned long T0[4], T1[4]; + unsigned long W0, W1, W2, W3; + + // initializing + T0[0] = *(unsigned long*)&InBuf[0] ^ Key[48]; + T0[1] = *(unsigned long*)&InBuf[4] ^ Key[49]; + T0[2] = *(unsigned long*)&InBuf[8] ^ Key[50]; + T0[3] = *(unsigned long*)&InBuf[12] ^ Key[51]; + // performing transformations 11 times + // round 1 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[44]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[45]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[46]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[47]; + // round 2 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[40]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[41]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[42]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[43]; + // round 3 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[36]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[37]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[38]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[39]; + // round 4 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[32]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[33]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[34]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[35]; + // round 5 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[28]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[29]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[30]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[31]; + // round 6 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[24]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[25]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[26]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[27]; + // round 7 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[20]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[21]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[22]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[23]; + // round 8 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[16]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[17]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[18]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[19]; + // round 9 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[12]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[13]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[14]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[15]; + // round 10 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[8]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[9]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[10]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[11]; + // round 11 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[4]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[5]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[6]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[7]; + // last round of transformations + W0 = LastInverseTable[(byte)(T1[0])]; W1 = LastInverseTable[(byte)(T1[3] >> 8)]; + W2 = LastInverseTable[(byte)(T1[2] >> 16)]; W3 = LastInverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[0]; + W0 = LastInverseTable[(byte)(T1[1])]; W1 = LastInverseTable[(byte)(T1[0] >> 8)]; + W2 = LastInverseTable[(byte)(T1[3] >> 16)]; W3 = LastInverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[1]; + W0 = LastInverseTable[(byte)(T1[2])]; W1 = LastInverseTable[(byte)(T1[1] >> 8)]; + W2 = LastInverseTable[(byte)(T1[0] >> 16)]; W3 = LastInverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[2]; + W0 = LastInverseTable[(byte)(T1[3])]; W1 = LastInverseTable[(byte)(T1[2] >> 8)]; + W2 = LastInverseTable[(byte)(T1[1] >> 16)]; W3 = LastInverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[3]; + // finalizing + *(unsigned long*)&OutBuf[0] = T0[0]; *(unsigned long*)&OutBuf[4] = T0[1]; + *(unsigned long*)&OutBuf[8] = T0[2]; *(unsigned long*)&OutBuf[12] = T0[3]; +} + +void DecryptAES256(byte* InBuf, const unsigned long* Key, byte* OutBuf) +{ + unsigned long T0[4], T1[4]; + unsigned long W0, W1, W2, W3; + + // initializing + T0[0] = *(unsigned long*)&InBuf[0] ^ Key[56]; + T0[1] = *(unsigned long*)&InBuf[4] ^ Key[57]; + T0[2] = *(unsigned long*)&InBuf[8] ^ Key[58]; + T0[3] = *(unsigned long*)&InBuf[12] ^ Key[59]; + // performing transformations 13 times + // round 1 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[52]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[53]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[54]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[55]; + // round 2 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[48]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[49]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[50]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[51]; + // round 3 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[44]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[45]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[46]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[47]; + // round 4 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[40]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[41]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[42]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[43]; + // round 5 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[36]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[37]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[38]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[39]; + // round 6 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[32]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[33]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[34]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[35]; + // round 7 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[28]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[29]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[30]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[31]; + // round 8 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[24]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[25]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[26]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[27]; + // round 9 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[20]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[21]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[22]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[23]; + // round 10 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[16]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[17]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[18]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[19]; + // round 11 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[12]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[13]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[14]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[15]; + // round 12 + W0 = InverseTable[(byte)(T1[0])]; W1 = InverseTable[(byte)(T1[3] >> 8)]; + W2 = InverseTable[(byte)(T1[2] >> 16)]; W3 = InverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[8]; + W0 = InverseTable[(byte)(T1[1])]; W1 = InverseTable[(byte)(T1[0] >> 8)]; + W2 = InverseTable[(byte)(T1[3] >> 16)]; W3 = InverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[9]; + W0 = InverseTable[(byte)(T1[2])]; W1 = InverseTable[(byte)(T1[1] >> 8)]; + W2 = InverseTable[(byte)(T1[0] >> 16)]; W3 = InverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[10]; + W0 = InverseTable[(byte)(T1[3])]; W1 = InverseTable[(byte)(T1[2] >> 8)]; + W2 = InverseTable[(byte)(T1[1] >> 16)]; W3 = InverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[11]; + // round 13 + W0 = InverseTable[(byte)(T0[0])]; W1 = InverseTable[(byte)(T0[3] >> 8)]; + W2 = InverseTable[(byte)(T0[2] >> 16)]; W3 = InverseTable[(byte)(T0[1] >> 24)]; + T1[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[4]; + W0 = InverseTable[(byte)(T0[1])]; W1 = InverseTable[(byte)(T0[0] >> 8)]; + W2 = InverseTable[(byte)(T0[3] >> 16)]; W3 = InverseTable[(byte)(T0[2] >> 24)]; + T1[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[5]; + W0 = InverseTable[(byte)(T0[2])]; W1 = InverseTable[(byte)(T0[1] >> 8)]; + W2 = InverseTable[(byte)(T0[0] >> 16)]; W3 = InverseTable[(byte)(T0[3] >> 24)]; + T1[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[6]; + W0 = InverseTable[(byte)(T0[3])]; W1 = InverseTable[(byte)(T0[2] >> 8)]; + W2 = InverseTable[(byte)(T0[1] >> 16)]; W3 = InverseTable[(byte)(T0[0] >> 24)]; + T1[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[7]; + // last round of transformations + W0 = LastInverseTable[(byte)(T1[0])]; W1 = LastInverseTable[(byte)(T1[3] >> 8)]; + W2 = LastInverseTable[(byte)(T1[2] >> 16)]; W3 = LastInverseTable[(byte)(T1[1] >> 24)]; + T0[0] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[0]; + W0 = LastInverseTable[(byte)(T1[1])]; W1 = LastInverseTable[(byte)(T1[0] >> 8)]; + W2 = LastInverseTable[(byte)(T1[3] >> 16)]; W3 = LastInverseTable[(byte)(T1[2] >> 24)]; + T0[1] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[1]; + W0 = LastInverseTable[(byte)(T1[2])]; W1 = LastInverseTable[(byte)(T1[1] >> 8)]; + W2 = LastInverseTable[(byte)(T1[0] >> 16)]; W3 = LastInverseTable[(byte)(T1[3] >> 24)]; + T0[2] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[2]; + W0 = LastInverseTable[(byte)(T1[3])]; W1 = LastInverseTable[(byte)(T1[2] >> 8)]; + W2 = LastInverseTable[(byte)(T1[1] >> 16)]; W3 = LastInverseTable[(byte)(T1[0] >> 24)]; + T0[3] = (W0 ^ ((W1 << 8) | (W1 >> 24)) ^ ((W2 << 16) | (W2 >> 16)) + ^ ((W3 << 24) | (W3 >> 8))) ^ Key[3]; + // finalizing + *(unsigned long*)&OutBuf[0] = T0[0]; *(unsigned long*)&OutBuf[4] = T0[1]; + *(unsigned long*)&OutBuf[8] = T0[2]; *(unsigned long*)&OutBuf[12] = T0[3]; +} diff --git a/libraries/external/eldos/pc/include/ElAES.h b/libraries/external/eldos/pc/include/ElAES.h new file mode 100755 index 0000000..ea81ca3 --- /dev/null +++ b/libraries/external/eldos/pc/include/ElAES.h @@ -0,0 +1,38 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +typedef unsigned char byte; +#define TAESBuffer(n) byte n[16] +const long sTAESBuffer = sizeof(byte[16]); +#define TAESKey128(n) byte n[16] +const long sTAESKey128 = sizeof(byte[16]); +#define TAESKey192(n) byte n[24] +const long sTAESKey192 = sizeof(byte[24]); +#define TAESKey256(n) byte n[32] +const long sTAESKey256 = sizeof(byte[32]); +#define TAESExpandedKey128(n) unsigned long n[44] +const long sTAESExpandedKey128 = sizeof(unsigned long[44]); +#define TAESExpandedKey192(n) unsigned long n[54] +const long sTAESExpandedKey192 = sizeof(unsigned long[54]); +#define TAESExpandedKey256(n) unsigned long n[64] +const long sTAESExpandedKey256 = sizeof(unsigned long[64]); + +void ExpandAESKeyForEncryption128(byte* Key, unsigned long* ExpandedKey); +void ExpandAESKeyForEncryption192(byte* Key, unsigned long* ExpandedKey); +void ExpandAESKeyForEncryption256(byte* Key, unsigned long* ExpandedKey); + +void ExpandAESKeyForDecryption128(byte* Key, unsigned long* ExpandedKey); +void ExpandAESKeyForDecryption192(byte* Key, unsigned long* ExpandedKey); +void ExpandAESKeyForDecryption256(byte* Key, unsigned long* ExpandedKey); + +void EncryptAES128(byte* InBuf, const unsigned long* Key, byte* OutBuf); +void EncryptAES192(byte* InBuf, const unsigned long* Key, byte* OutBuf); +void EncryptAES256(byte* InBuf, const unsigned long* Key, byte* OutBuf); + +void DecryptAES128(byte* InBuf, const unsigned long* Key, byte* OutBuf); +void DecryptAES192(byte* InBuf, const unsigned long* Key, byte* OutBuf); +void DecryptAES256(byte* InBuf, const unsigned long* Key, byte* OutBuf); diff --git a/libraries/external/eldos/pc/include/MC.h b/libraries/external/eldos/pc/include/MC.h new file mode 100755 index 0000000..bfa22f6 --- /dev/null +++ b/libraries/external/eldos/pc/include/MC.h @@ -0,0 +1,221 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#ifndef __MC__ +#define __MC__ + +#ifndef __BORLANDC__ +# define USE_NAMESPACE +#else +# undef USE_NAMESPACE +#endif + +#ifdef __BORLANDC__ +# ifndef WIN32 +# define WIN32 +# endif +#endif + +#if defined(WIN32) && !defined(_WIN32_WCE) +#if(_WIN32_WINNT < 0x0400) +#define _WIN32_WINNT 0x0400 +#endif +//#if (_MSC_VER >= 1300) +//# include +//#endif +# include +# include +//# include +#endif + +#ifdef _WIN32_WCE +# include +# include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +#if defined(_WIN32_WCE) || defined(UNICODE) +# include +# include + wchar_t* s2w(const char* s); // use operator delete to release memory after string using +#endif + + +#ifndef SD_BOTH +const int SD_BOTH = 2; +#endif + +/* +#if defined(_WIN32) && defined(_WIN32_WCE) +# if _WIN32_WCE >= 400 +# define USE_CPPEXCEPTIONS +# else +# undef USE_CPPEXCEPTIONS +# endif +#else +# define USE_CPPEXCEPTIONS +#endif +*/ + +#if defined(__GNUC__) +# define USE_CPPEXCEPTIONS +#endif + +#if defined(_WIN32) && defined(_WIN32_WCE) +# ifdef _WIN32_WCE +# undef USE_CPPEXCEPTIONS +# else +# define USE_CPPEXCEPTIONS +# endif +#else +# define USE_CPPEXCEPTIONS +#endif + +//#define USE_CPPEXCEPTIONS +#define NO_CHECK_DISPATCHTHREAD + +//define some macros for handling SEH & C++ exceptions in one way +#ifndef ELDOS_CPP_EXCEPTIONS +# ifndef USE_CPPEXCEPTIONS //use the SEH instead +# define MCERRORCODEBASE 1000 +# define MCRETURNCODE MCERRORCODEBASE+1 +# define MCRETURN MCERRORCODEBASE+2 +//# define FINALLY(z) __finally { z } +# define try __try +# define TRY_BLOCK __try +# define CATCH_EVERY __except(1) +# define RETURN_EXCEPT RaiseException(MCRETURNCODE, 0, 0, NULL) +# define RETURN RaiseException(MCRETURN, 0, 0, NULL); +# define CATCH_RETURN } __except(((long)((_EXCEPTION_POINTERS*)GetExceptionInformation())->ExceptionRecord->ExceptionInformation) != 1) {} +//# undef FINALLY +# define FINALLY(z) __finally{z} +# define THROW_ERROR(x) RaiseException(MCERRORCODEBASE+x+2, 0, 0, NULL) +# define CATCH_MCERROR __except( ((GetExceptionCode() >= MCERRORCODEBASE+2) && (GetExceptionCode() <= MCERRORCODEBASE+2+1000)) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) +# else +# define TRY_BLOCK try +# define CATCH_EVERY catch(...) +# define RETURN_EXCEPT throw 1 +# define RETURN throw((int)1); +# define CATCH_RETURN } catch(int) {} +# define FINALLY(z) catch(...) { z throw; } z +# define THROW_ERROR(x) throw EMCError(x) +# define CATCH_MCERROR catch(EMCError&/* x*/) +# endif +# define ELDOS_CPP_EXCEPTIONS +#endif +#define TRY_RETURN try { + +#ifdef _WIN32_WCE +# define try __try +# define stricmp _stricmp +# define strncmpi _strnicmp +# include +# include +//int __cdecl _stricmp(const char *, const char *); +//int __cdecl _strnicmp(const char *, const char *, size_t); + +# define assert(p) if(!p) exit(1); +# include + void DebugWrite(LPSTR s); + char* strdup(const char*); +# define snprintf _snprintf +#else +# include +typedef unsigned char byte; +#endif + +extern unsigned long MCMainThreadID; + +#ifndef _WIN32 +typedef unsigned long DWORD; +#endif + +typedef unsigned long Cardinal; + +#ifdef __GNUC__ +#ifndef __USE_UNIX98 +# define __USE_UNIX98 +#endif + + + typedef long long __int64; + typedef unsigned char byte; + const unsigned long INFINITE = 0xFFFFFFFFul; // Infinite timeout + const unsigned long INVALID_SOCKET = (unsigned long)-1; + const unsigned long SOCKET_ERROR = (unsigned long)-1; + unsigned long GetTickCount(void); + +# define UNALIGNED +# define TCHAR char +# define __T(x) x +# define _T(x) __T(x) +# define TEXT(x) __T(x) +# define _TEXT(x) __T(x) +# define LPTSTR char * +# define LPCTSTR const char * + +# define Sleep(s) usleep((long)s*1000) +# define Random random +# define closesocket(s) close(s) +# define GetCurrentThreadId IntGetCurrentThreadID +# define GetCurrentThread IntGetCurrentThreadID +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# define __stdcall +#else +# include +#endif + +#if defined(_MSC_VER) && !defined(_WIN32_WCE) +# define snprintf _snprintf +# define strncmpi _strnicmp +#endif + +#ifdef _WIN32 +# define LAST_ERROR WSAGetLastError() +#else +# define LAST_ERROR errno +#endif + + +//Socket section +#define SOCKETBUF_INITIAL_SIZE 512 + + +//#ifndef _WIN32_WCE +# include +# include +# include +# include +# include +//#endif + +#ifndef _WIN32_WCE +# define MCASSERT(x) assert(x) +#else +# define MCASSERT(x) +#endif + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCAES.cpp b/libraries/external/eldos/pc/include/MCAES.cpp new file mode 100755 index 0000000..1517997 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCAES.cpp @@ -0,0 +1,280 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCAES.h" +#include "ElAES.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +void NewDynArray(DynArray* arr, long asize) +{ + arr->size = asize; + arr->data = (unsigned char*)MCMemAlloc(arr->size); +} + +void DelDynArray(DynArray* arr) +{ + if(arr->data && (arr->size > 0)) + MCMemFree(arr->data); + arr->data = NULL; + arr->size = 0; +} + +MCAESEncryption::MCAESEncryption(void):MCCBaseEncryption() +{ + InitKeyRecord(&FDefaultKeys); + FKeys = new MCList(); + FKeys->DeleteItem = MCAESEncryption::KeyDelete; +} + +MCAESEncryption::~MCAESEncryption() +{ + ClearKeys(); + delete FKeys; +} + +void MCAESEncryption::KeyDelete(void* /*sender*/, void* v) +{ + MCAESKeyRecord* k = (MCAESKeyRecord*)v; + if(k->Remote) + MCMemFree(k->Remote); + DelDynArray(&k->EncKey); + DelDynArray(&k->DecKey); + delete k; +} + +void MCAESEncryption::ClearKeys(void) +{ + FKeys->DeleteAll(); + DelDynArray(&FDefaultKeys.DecKey); + DelDynArray(&FDefaultKeys.EncKey); +} + +MCAESKeyRecord* MCAESEncryption::FindKeyRecord(char* Remote) +{ + //unsigned long i; + for(int i = 1; i <= FKeys->Length(); i++) + { + if(strcmp(((MCAESKeyRecord*)(*FKeys)[i-1])->Remote, Remote) == 0) + return((MCAESKeyRecord*)(*FKeys)[i-1]); + } + return(NULL); +} + +long MCAESEncryption::GetID(void) +{ + return(1); +} + +void MCAESEncryption::InitKeyRecord(MCAESKeyRecord* Keys) +{ + Keys->Remote = NULL; + Keys->EncKey.size = 0; + Keys->EncKey.data = NULL; + Keys->DecKey.size = 0; + Keys->DecKey.data = NULL; +} + +void MCAESEncryption::SetKey(char* Remote, DynArray* Value) +{ +/* TAESKey128(ASKey128); + TAESKey192(ASKey192); + TAESKey256(ASKey256);*/ + MCAESKeyRecord* ARecord; + bool b = false; + + bool emptyRemote = Remote ? (strlen(Remote) == 0) : true; + if(!emptyRemote) + { + ARecord = FindKeyRecord(Remote); + if(!ARecord) + { + b = true; + ARecord = new MCAESKeyRecord; + InitKeyRecord(ARecord); + ARecord->Remote = strdup(Remote); + FKeys->Add(ARecord); + } + } + else + ARecord = &FDefaultKeys; + + DelDynArray(&ARecord->EncKey); + DelDynArray(&ARecord->DecKey); + switch(Value->size) { + case sTAESKey128: + NewDynArray(&ARecord->EncKey, sTAESExpandedKey128); + NewDynArray(&ARecord->DecKey, sTAESExpandedKey128); + ExpandAESKeyForEncryption128(Value->data, (unsigned long*)ARecord->EncKey.data); + ExpandAESKeyForDecryption128(Value->data, (unsigned long*)ARecord->DecKey.data); + break; + case sTAESKey192: + NewDynArray(&ARecord->EncKey, sTAESExpandedKey192); + NewDynArray(&ARecord->DecKey, sTAESExpandedKey192); + ExpandAESKeyForEncryption192(Value->data, (unsigned long*)ARecord->EncKey.data); + ExpandAESKeyForDecryption192(Value->data, (unsigned long*)ARecord->DecKey.data); + break; + case sTAESKey256: + NewDynArray(&ARecord->EncKey, sTAESExpandedKey256); + NewDynArray(&ARecord->DecKey, sTAESExpandedKey256); + ExpandAESKeyForEncryption256(Value->data, (unsigned long*)ARecord->EncKey.data); + ExpandAESKeyForDecryption256(Value->data, (unsigned long*)ARecord->DecKey.data); + break; + default: + if(b) + MCAESEncryption::KeyDelete(NULL, ARecord); + THROW_ERROR(MCError_InvalidEncryptionKey); + } + DelDynArray(Value); +} + +void MCAESEncryption::Encrypt(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success) +{ + MCAESKeyRecord* KeyRecord; + TAESBuffer(InBuffer); + TAESBuffer(OutBuffer); + long i,j,k; + char *p,*p1; + + if(!InDataSize||!InData) + { + OutData = InData; + OutDataSize = InDataSize; + Success = false; + return; + } + Success = true; + + KeyRecord = FindKeyRecord(Remote); + if(!KeyRecord) + KeyRecord = &FDefaultKeys; + + // allocate buffer for new data + OutDataSize = InDataSize & (~(unsigned long)(sTAESBuffer - 1)); + if((InDataSize & (sTAESBuffer - 1)) != 0) + OutDataSize += sTAESBuffer; + OutDataSize += sizeof(long) * 2; + OutData = MCMemAlloc(OutDataSize); + if(!OutData) + THROW_ERROR(MCError_NotEnoughMemory); + p = (char*)InData; + p1 = (char*)OutData; + // write the size of the encoded and original data to the buffer + *(long*)p1 = OutDataSize; + p1 += sizeof(long); + *(long*)p1 = InDataSize; + p1 += sizeof(long); + + // encode the buffer + j = OutDataSize / sTAESBuffer - 1; + for(i = 0;i <= j;i++) + { + // copy the data to InBuffer + if(i == j) + { + memset(InBuffer, 0, sizeof(InBuffer)); + k = InDataSize & (sTAESBuffer - 1); + if(!k) + k = sTAESBuffer; + memmove(InBuffer, p, k); + } + else + memmove(InBuffer, p, sTAESBuffer); + + switch(KeyRecord->EncKey.size) { + case sTAESExpandedKey128: + EncryptAES128(InBuffer, (unsigned long*)KeyRecord->EncKey.data, OutBuffer); + break; + case sTAESExpandedKey192: + EncryptAES192(InBuffer, (unsigned long*)KeyRecord->EncKey.data, OutBuffer); + break; + case sTAESExpandedKey256: + EncryptAES256(InBuffer, (unsigned long*)KeyRecord->EncKey.data, OutBuffer); + break; + } + memmove(p1, OutBuffer, sTAESBuffer); + p += sTAESBuffer; + p1 += sTAESBuffer; + } + MCMemFree(InData); +} + +void MCAESEncryption::Decrypt(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long /*TransformID*/, + bool& Success) +{ + MCAESKeyRecord* KeyRecord; + TAESBuffer(OutBuffer); + long i,j,k; + char *p,*p1; + + if((InDataSize % 16 != 8) || !InData) + { + Success = false; + return; + } + + KeyRecord = FindKeyRecord(Remote); + if(!KeyRecord) + KeyRecord = &FDefaultKeys; + + p = (char*)InData; + if(*(long*)p != InDataSize) + { + Success = false; + return; + } + p += sizeof(long); + OutDataSize = *(long*)p; + p += sizeof(long); + + OutData = MCMemAlloc(OutDataSize); + if(!OutData) + THROW_ERROR(MCError_NotEnoughMemory); + + p1 = (char*)OutData; + + // decode the buffer + j = InDataSize / sTAESBuffer - 1; + for(i = 0;i <= j;i++) + { + switch(KeyRecord->EncKey.size) { + case sTAESExpandedKey128: + DecryptAES128((byte*)p, (unsigned long*)KeyRecord->DecKey.data, OutBuffer); + break; + case sTAESExpandedKey192: + DecryptAES192((byte*)p, (unsigned long*)KeyRecord->DecKey.data, OutBuffer); + break; + case sTAESExpandedKey256: + DecryptAES256((byte*)p, (unsigned long*)KeyRecord->DecKey.data, OutBuffer); + break; + } + if(i == j) + { + k = (OutDataSize & (sTAESBuffer - 1)); + if(!k) + k = sTAESBuffer; + memmove(p1, &OutBuffer, k); + } + else + memmove(p1, &OutBuffer, sTAESBuffer); + + p += sTAESBuffer; + p1 += sTAESBuffer; + } + MCMemFree(InData); +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCAES.h b/libraries/external/eldos/pc/include/MCAES.h new file mode 100755 index 0000000..0ce28b6 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCAES.h @@ -0,0 +1,65 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCAES__ +#define __MCAES__ + +#include "MC.h" +#include "MCBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +const long AESTransformID = 0x46428432ul; + +typedef struct { + unsigned long size; + byte* data; +} DynArray; + +typedef struct { + char* Remote; + DynArray EncKey; + DynArray DecKey; +} MCAESKeyRecord; + +class MCAESEncryption:public MCCBaseEncryption { +protected: + MCAESKeyRecord FDefaultKeys; + MCList* FKeys; + + static void KeyDelete(void* sender, void* v); + +public: + virtual void Encrypt(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success); + + virtual void Decrypt(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success); + + void InitKeyRecord(MCAESKeyRecord* Keys); +public: + MCAESEncryption(void); + ~MCAESEncryption(); + void ClearKeys(void); + MCAESKeyRecord* FindKeyRecord(char* Remote); + virtual long GetID(void); + void SetKey(char* Remote, DynArray* Value); +}; + +void NewDynArray(DynArray* arr, long asize); +void DelDynArray(DynArray* arr); + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCAdler.cpp b/libraries/external/eldos/pc/include/MCAdler.cpp new file mode 100755 index 0000000..7ad93c2 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCAdler.cpp @@ -0,0 +1,94 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +//#include "MC.h" +#include "MCUtils.h" +#include "MCAdler.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +const int ADLER_PRIME = 65521; + +long Adler(long c, byte b) +{ + long i1 = ((c & 0xffff) + b) % ADLER_PRIME; + long i2 = (((c >> 16) & 0xffff) + i1) % ADLER_PRIME; + return((i2 << 16) + i1); +} + +long AdlerBuffer(long InitialAdler, void* Buffer, long BufLen) +{ + long c = InitialAdler; + byte* p = (byte*)Buffer; + for(long i = 0;i < BufLen;i++) + { + c = Adler(c, *p); + p++; + } + return(c); +} + +long MCAdlerSealing::GetID(void) +{ + return(1); +} + +void MCAdlerSealing::Seal(char* /* Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success) +{ + long i; + + if((InDataSize == 0) || (!InData)) + { + OutData = InData; + OutDataSize = InDataSize; + Success = false; + } + else + { + OutDataSize = InDataSize + sizeof(long); + OutData = MCMemAlloc(OutDataSize); +// i = AdlerBuffer(1, (void*)((char*)InData + sizeof(long)), InDataSize - sizeof(long)); + i = AdlerBuffer(1, InData, InDataSize); + memmove(OutData, &i, sizeof(i)); + memmove((char*)((long)OutData + sizeof(long)), InData, InDataSize); + MCMemFree(InData); + Success = true; + } +} + +void MCAdlerSealing::UnSeal(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long /*TransformID*/, bool& Success) +{ + long i; + + if((InDataSize == 0) || (!InData)) + { + OutData = InData; + OutDataSize = InDataSize; + Success = false; + } + else + { + OutDataSize = InDataSize - sizeof(long); + OutData = MCMemAlloc(OutDataSize); +// i = AdlerBuffer(1, InData, InDataSize); + i = AdlerBuffer(1, (void*)((char*)InData + sizeof(long)), InDataSize - sizeof(long)); + Success = *((long*)InData) == i; + memmove(OutData, (char*)((long)InData + sizeof(long)), OutDataSize); + MCMemFree(InData); + } +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCAdler.h b/libraries/external/eldos/pc/include/MCAdler.h new file mode 100755 index 0000000..f7eaf45 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCAdler.h @@ -0,0 +1,36 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCADLER__ +#define __MCADLER__ + +#include "MC.h" +#include "MCBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCAdlerSealing:public MCBaseSealing { +protected: +public: + virtual void Seal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success); + virtual void UnSeal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success); +public: + virtual long GetID(void); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCBase.cpp b/libraries/external/eldos/pc/include/MCBase.cpp new file mode 100755 index 0000000..6790de3 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCBase.cpp @@ -0,0 +1,3538 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#include "MC.h" +#include "MCUtils.h" +#include "MCBase.h" +#include "MCThreads.h" +#include +#include +#ifndef USE_CPPEXCEPTIONS +# include +#endif + + +//#define MC_FORCE_EVAL + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +long GlobalSeed; + +static MCList* DirectTransports = NULL; +static bool DirectTransportForeign = false; +static MCCriticalSection* DirectTransportCS = NULL; + + +//$ifndef LINUX +#ifdef _WIN32_WCE +# define strnicmp _strnicmp +#endif +//$endif + +//thanks to Claudio Fiorani for replacing wrong #define +#if defined(_UNICODE) || defined(UNICODE) +wchar_t* s2w(const char* s) +{ + if(s) + { + long l = strlen(s) + 1; + wchar_t* w=new wchar_t[l]; + mbstowcs(w,s,l); + return(w); + } + else + return(NULL); +} +#endif + +#ifdef __GNUC__ +unsigned long GetTickCount(void) +{ + char buf[1024]; + int n, fd = -1; + double up, idle; + fd = open("/proc/uptime", O_RDONLY); + if (fd == -1) + return(0); + + lseek(fd, 0L, SEEK_SET); + if ((n = read(fd, buf, sizeof buf - 1)) < 0) + { + close(fd); + fd = -1; + return(0); + } + close(fd); + + buf[n] = '\0'; + if (sscanf(buf, "%lf %lf", &up, &idle) < 2) + return 0; + return (long)(up*1000); +} +#endif + + +void DefineOS(void) +{ +//$ifndef LINUX +#ifdef _WIN32 + OSVERSIONINFO VerInfo; + + VerInfo.dwOSVersionInfoSize = sizeof(VerInfo); + GetVersionEx(&VerInfo); + IsWinNT = VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT; + + IsWin2000 = (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && + (VerInfo.dwMajorVersion >= 5); + IsWinNTUp = IsWinNT || IsWin2000Up; + + IsWin98 = (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && + (VerInfo.dwMinorVersion > 0); + IsWin98Up = IsWin98; + + IsWinME = (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && + (VerInfo.dwMinorVersion >= 90); + + IsWinXP = (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && + (VerInfo.dwMajorVersion == 5) && (VerInfo.dwMinorVersion == 1); + IsWinXPUp = (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) && + (VerInfo.dwMajorVersion >= 5) & (VerInfo.dwMinorVersion >= 1); + IsWin2000Up = IsWin2000 || IsWinXP; +#endif +//$endif +#ifdef __GNUC__ + IsLinux = true; +#endif +} + +char* sstr2pchar(int l,char*s) +{ + static char z[256]; + strncpy(z, s, l); + return(&z[0]); +} +/* + +//$ifndef LINUX +#ifdef _WIN32 +bool SupportsTSNames(void) +{ + return IsWin2000Up; +} +#endif +//$endif + +void* MCMemAlloc(long Size) +{ + if(Size > 0) + { + void* result = (void*)malloc(Size); + if (NULL == result) + THROW_ERROR(MCError_NotEnoughMemory); + return result; + } + else + return NULL; +} + +void MCMemFree(void* Block) +{ + if (NULL != Block) + free(Block); +} + +void MCFreeNull(void*& Block) +{ + MCMemFree(Block); + Block = NULL; +} + +*/ + +#ifdef _WIN32_WCE +#ifndef strdup +char* strdup(const char* s) +{ + if(!s) return(NULL); + char* p = (char*)MCMemAlloc(strlen(s)+1); + strcpy(p, s); + return p; +} +#endif +#endif + +bool IsLeapYear(long Year) +{ + return((Year % 4 == 0) && ((Year % 100 != 0) || (Year % 400 == 0))); +} + +const long MSecsPerDay = 24 * 60 * 60 * 1000; + +double EncodeTime(long Hour, long Min, long Sec, long MSec) +{ + double r = 0.0; + + if((Hour < 24) && (Min < 60) && (Sec < 60) && (MSec < 1000)) + r = ((double)Hour * 3600000 + (double)Min * 60000 + (double)Sec * 1000 + MSec) / MSecsPerDay; + return(r); +} + +double EncodeDate(long Year, long Month, long Day) +{ + byte days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + days[1] = 28 + IsLeapYear(Year); + double r = 0.0; + if((Year >= 1) && (Year <= 9999) && (Month >= 1) && (Month <= 12) && + (Day >= 1) && (Day <= days[Month-1])) + { + long i; + for(i = 1;i < Month;i++) + Day+=days[i-1]; + i = Year - 1; + r = i * 365 + i / 4 - i / 100 + i / 400 + Day - 693594; // DateDelta + } + return r; +} + +double Now(void) +{ + double r; +#ifndef __GNUC__ +//$ifndef LINUX + SYSTEMTIME sst; + LPSYSTEMTIME st = &sst; + + GetSystemTime(st); + r = EncodeDate(st->wYear, st->wMonth, st->wDay) + + EncodeTime(st->wHour, st->wMinute, st->wSecond, st->wMilliseconds); +//$endif +#else + time_t t; + struct timeval tv; + struct tm ut; + + gettimeofday(&tv, NULL); + t = tv.tv_sec; + gmtime_r(&t, &ut); + //systemtime_r(&t, &ut); + r = EncodeDate(ut.tm_year + 1900, ut.tm_mon + 1, ut.tm_mday) + + EncodeTime(ut.tm_hour, ut.tm_min, ut.tm_sec, tv.tv_usec / 1000); +#endif + return r; +} + +double Time(void) +{ + double r; +#ifndef __GNUC__ +//$ifndef LINUX + SYSTEMTIME st; + + GetLocalTime(&st); + r = EncodeTime(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); +//$endif +#else + time_t t; + struct timeval tv; + struct tm ut; + + gettimeofday(&tv, NULL); + t = tv.tv_sec; + localtime_r(&t, &ut); + r = EncodeTime(ut.tm_hour, ut.tm_min, ut.tm_sec, tv.tv_usec / 1000); +#endif + return r; +} + +const long PSTR_MAX = 255; + +void equPstr(char* p, char* s, int max) +{ + long l = strlen(s); + if(l > max) + l = max; + if(l > PSTR_MAX) + l = PSTR_MAX; + p[0] = (char)l; + strncpy(&p[1], s, l); +} + +char* Pstr2c(char* p) +{ + char* t = (char*)MCMemAlloc(p[0]+1); + strncpy(t, &p[1], p[0]); + t[p[0]] = 0; + return t; +} + +char* strCopy(const char* s, long f, long l) +{ + long ll = l; + long sl = strlen(s); + if(!s) + return(NULL); + if(f < 0) + return(NULL); + if(ll < 0) + ll = sl - f; + if(ll < 0) + return(NULL); + if(f >= sl) + return(NULL); + if(f + ll > sl) + ll = sl - f; + char* t = (char*)MCMemAlloc(ll+1); + strncpy(t, &s[f], ll); + t[ll] = 0; + return t; +} + +long strPos(char c, const char* s) +{ + char* t = strchr((char*) s, c); + if(!t) + return -1; + return t - s; +} + +// ******************************* MCMessageInfo ******************************* + +MCMessageInfo::MCMessageInfo(MCMessage* Msg) +: Time(0), OrigID(0), IsSendMsg(0), MCError(0), State(imsQueued), ReplyFlag(NULL), + Transport(NULL), UserData(0), NotifyProc(NULL), TimeoutProc(NULL), ErrorProc(NULL), + SMessenger(NULL), DMessenger(NULL), Sent(false), + URL(NULL), StartTime(0), Timeout(0), Track(NULL), ConnID(0), ClientID(0), OldState(imsNone) +//$ifdef MC_COMMERCIAL + , RouteTo(NULL), RecvPath(NULL), EncodedMsg(NULL), Intermed(false), TransactCmd(itcNormal) + , EncodedLen(0), EncryptID(0) , CompressID(0), SealID(0) +//$endif +{ + memset(DQueue, 0, sizeof(DQueue)); + memset(&Credentials, 0, sizeof(Credentials)); + memset(&Message, 0, sizeof(Message)); + + MCMessenger::SetMessageID(this); + + Time = Now(); + Msg->MsgID = Message.MsgID; + memmove(&Message, Msg, sizeof(MCMessage)); + Message.Data = NULL; + if(Message.DataSize > 0) + { + Message.Data = MCMemAlloc(Message.DataSize); + memmove(Message.Data, Msg->Data, Message.DataSize); + } +} + +MCMessageInfo::~MCMessageInfo() +{ + if(Message.Data) + MCFreeNull(Message.Data); +//$ifdef MC_COMMERCIAL + if (RouteTo) + MCMemFree(RouteTo); + if (RecvPath) + MCMemFree(RecvPath); + if (EncodedMsg) + MCMemFree(EncodedMsg); +//$endif MC_COMMERCIAL + delete ReplyFlag; ReplyFlag = NULL; + if (SMessenger) + MCMemFree(SMessenger); SMessenger = NULL; + if (DMessenger) + MCMemFree(DMessenger); DMessenger = NULL; + MCMemFree(URL); URL = NULL; + //if (this->State == imsEmpty) + // OutputDebugString("~MCMessageInfo\n"); +} + +void MCMessageInfo::WriteToStream(MCStream* Stream) +{ + Stream->Write(&Time, sizeof(Time)); + Stream->Write(&OrigID, sizeof(OrigID)); + Stream->Write(&IsSendMsg, sizeof(IsSendMsg)); + Stream->Write(DQueue, sizeof(DQueue)); + Stream->Write(&Credentials, sizeof(Credentials)); + Stream->Write(&MCError, sizeof(MCError)); + unsigned int stub = (unsigned int)State; + Stream->Write(&stub, sizeof(stub)); + //Stream->Write(&stub, sizeof(stub)); + signed char flag = (signed char) Message.TransCmd; + Stream->Write(&flag, sizeof(flag)); + Stream->Write(&Message.TransID, sizeof(Message.TransID)); + Stream->Write(&Message.Priority, sizeof(Message.Priority)); + + Stream->Write(&Message.MsgID, sizeof(Message.MsgID)); + Stream->Write(&Message.MsgCode, sizeof(Message.MsgCode)); + Stream->Write(&Message.Result, sizeof(Message.Result)); + Stream->Write(&Message.Param1, sizeof(Message.Param1)); + Stream->Write(&Message.Param2, sizeof(Message.Param2)); + stub = Message.DataType; + Stream->Write(&stub, sizeof(stub)); + Stream->Write(&Message.DataSize, sizeof(Message.DataSize)); +} + +void MCMessageInfo::LoadFromStream(MCStream* Stream) +{ + Stream->Read(&Time, sizeof(Time)); + Stream->Read(&OrigID, sizeof(OrigID)); + Stream->Read(&IsSendMsg, sizeof(IsSendMsg)); + Stream->Read(DQueue, sizeof(DQueue)); + Stream->Read(&Credentials, sizeof(Credentials)); + Stream->Read(&MCError, sizeof(MCError)); + unsigned int stub = 0; + Stream->Read(&stub, sizeof(stub)); + State = (MCMessageState)stub; + // Stream->Read(&stub, sizeof(stub)); //read fake value for compatibility with earlier versions + signed char flag; + Stream->Read(&flag, sizeof(flag)); + Message.TransCmd = (MCTransactCmd) flag; + Stream->Read(&Message.TransID, sizeof(Message.TransID)); + Stream->Read(&Message.Priority, sizeof(Message.Priority)); + + Stream->Read(&Message.MsgID, sizeof(Message.MsgID)); + Stream->Read(&Message.MsgCode, sizeof(Message.MsgCode)); + Stream->Read(&Message.Result, sizeof(Message.Result)); + Stream->Read(&Message.Param1, sizeof(Message.Param1)); + Stream->Read(&Message.Param2, sizeof(Message.Param2)); + Stream->Read(&stub, sizeof(stub)); + Message.DataType = MCBinDataType(stub); + Stream->Read(&Message.DataSize, sizeof(Message.DataSize)); +} + +void MCMessageInfo::setSMessenger(char* SMsg) +{ + MCMemFree(SMessenger); SMessenger = NULL; + if (NULL != SMsg) + SMessenger = strdup(SMsg); + else + SMessenger = NULL; +} + +void MCMessageInfo::setDMessenger(char* DMsg) +{ + MCMemFree(DMessenger); DMessenger = NULL; + if (NULL != DMsg) + DMessenger = strdup(DMsg); + else + DMessenger = NULL; +} + +void MCMessageInfo::setURL(char* URLStr) +{ + MCMemFree(URL); URL = NULL; + if (NULL != URLStr) + URL = strdup(URLStr); + else + URL = NULL; +} + +//$ifdef MC_COMMERCIAL +void MCMessageInfo::setRecvPath(char* value) +{ + MCMemFree(RecvPath); RecvPath = NULL; + if (NULL != value) + RecvPath = strdup(value); + else + RecvPath = NULL; +} + +void MCMessageInfo::setRouteTo(char* value) +{ + MCMemFree(RouteTo); RouteTo = NULL; + if (NULL != value) + RouteTo = strdup(value); + else + RouteTo = NULL; +} + +void MCMessageInfo::setEncodedMsg(void* value, long len) +{ + MCMemFree(EncodedMsg); EncodedMsg = NULL; + if (NULL != value) + { + EncodedMsg = MCMemAlloc(len); + memmove(EncodedMsg, value, len); + } +} +//$endif MC_COMMERCIAL + +void MCMessageInfo::CopyMessage(MCMessageInfo *Dest) +{ + memmove(&Dest->Message.MsgID, &Message.MsgID, sizeof(MCMessage)); +} + +// ******************************* MCMessenger ******************************* + +MCMessenger::MCMessenger() +{ + FThreadID = IntGetCurrentThreadID(); + FIncomingCriticalSection = new MCCriticalSection(); + FCompleteCriticalSection = new MCCriticalSection(); + FForwardCriticalSection = new MCCriticalSection(); + + FQueues = new MCList(); + FForwardQueue = new MCList(); + FIncomingQueue = new MCList(); + FCompleteQueue = new MCList(); + FIncomingEvent = new MCEvent(NULL, false, false, NULL); + FCompleteEvent = new MCEvent(NULL, false, false, NULL); + FMaxTimeout = INFINITE; + FLastCleanup = 0; + FCleanupInterval = 0;//10000; + +//$ifdef MC_COMMERCIAL + FRouter = NULL; +//$endif MC_COMMERCIAL + + FTransportList = new MCList(); + + FOnValidateCredentials = NULL; + FOnValidateCredentialsData = NULL; +} + +MCMessenger::~MCMessenger() +{ + MCMessageInfo* Info; + + FIncomingCriticalSection->Enter(); + while(FIncomingQueue->Length() > 0) + { + Info = (MCMessageInfo*)(*FIncomingQueue)[0]; + + // remove the message from the queue of pending messages + FIncomingQueue->Del((long)0); + + // adjust message state + Info->State = imsFailed; + if(Info->IsSendMsg && (FTransportList->Find(Info->Transport) > -1)) + Info->Transport->MessageProcessed(Info); + else + { + delete Info; + Info = NULL; + } + } + FIncomingCriticalSection->Leave(); + DispatchCompleteMessages(); + + // Cleanup ForwardQueue + FForwardCriticalSection->Enter(); + while (FForwardQueue->Length() > 0) + { + Info = (MCMessageInfo*)(*FForwardQueue)[0]; + + // remove the message from the queue of pending messages + FForwardQueue->Del((long)0); + delete Info; Info = NULL; + } + FForwardCriticalSection->Leave(); + + + delete FCompleteCriticalSection; FCompleteCriticalSection = NULL; + delete FIncomingCriticalSection; FIncomingCriticalSection = NULL; + delete FForwardCriticalSection; FForwardCriticalSection = NULL; + delete FForwardQueue; FForwardQueue = NULL; + delete FIncomingQueue; FIncomingQueue = NULL; + delete FIncomingEvent; FIncomingEvent = NULL; + delete FCompleteQueue; FCompleteQueue = NULL; + delete FCompleteEvent; FCompleteEvent = NULL; + // FTransportList->DeleteItem = TransportDelete; + delete FTransportList; FTransportList = NULL; + delete FQueues; FQueues = NULL; +} + +unsigned long MCMessenger::getThreadID(void) +{ + return FThreadID; +} + +void MCMessenger::setThreadID(unsigned long Thr) +{ + FThreadID = Thr; +} + +unsigned long MCMessenger::getMaxTimeout(void) +{ + return FMaxTimeout; +} + +unsigned long MCMessenger::getCleanupInterval(void) +{ + return FCleanupInterval; +} + + +MCValidateCredentialsEvent MCMessenger::getOnValidateCredentials(void* *UserData) +{ + if (UserData) + *UserData = FOnValidateCredentialsData; + + return FOnValidateCredentials; +} + +void MCMessenger::setOnValidateCredentials(MCValidateCredentialsEvent Value, void* UserData) +{ + FOnValidateCredentialsData = UserData; + FOnValidateCredentials = Value; +} + +void MCMessenger::AddQueue(MCQueue* AQueue) +{ + if(FQueues->Find(AQueue) <= -1) + FQueues->Add(AQueue); +} + +void MCMessenger::AddTransport(MCBaseTransport* ATransport) +{ + if(FTransportList->Find(ATransport) <= -1) + FTransportList->Add(ATransport); +} + +void MCMessenger::CleanupForwardQueue() +{ + int i; + MCMessageInfo* Info; + unsigned int TC; + bool me; + + FForwardCriticalSection->Enter(); + + TRY_BLOCK + { + i = 0; + TC = GetTickCount(); + while (i < FForwardQueue->Length()) + { + Info = (MCMessageInfo*)((*FForwardQueue)[i]); + + if (Info->Timeout == 0) + { + i++; + continue; + } + + if (TC < Info->StartTime) + { + me = 0xFFFFFFFF - Info->StartTime + TC >= Info->Timeout; + } + else + { + me = TC - Info->StartTime >= Info->Timeout; + } + if (me) + FForwardQueue->Del(Info); + else + i++; + } + } + FINALLY ( + FForwardCriticalSection->Leave(); + ) + +} + +void MCMessenger::CleanupQueues() +{ + unsigned long TC; + bool dc; + int i; + + TC = GetTickCount(); + if (TC < FLastCleanup) + { + dc = 0xFFFFFFFF - FLastCleanup + TC >= FCleanupInterval; + } + else + { + dc = TC - FLastCleanup >= FCleanupInterval; + } + if (dc) + { + FLastCleanup = TC; + for (i = 0; i < FTransportList->Length(); i++) + { + ((MCBaseTransport*)((*FTransportList)[i]))->CleanupMessages(); + } + + CleanupForwardQueue(); + } + +} + +bool MCMessenger::CancelMessage(__int64 MsgID) +{ + int i; + for (i = 0; i < FTransportList->Length(); i++) + { + if (((MCBaseTransport*)((*FTransportList)[i]))->CancelMessageByID(MsgID, true)) + return true; + } + return false; +} + + +bool MCMessenger::CancelMessageEx(__int64 MsgID, bool CancelComplete) +{ + int i; + for (i = 0; i < FTransportList->Length(); i++) + { + if (((MCBaseTransport*)((*FTransportList)[i]))->CancelMessageByID(MsgID, true)) + { + return true; + } + } + if (CancelComplete) + { + bool res = false; + + FCompleteCriticalSection->Enter(); + + MCMessageInfo* Info = NULL; + + for (i = 0; i < FCompleteQueue->Length(); i++) + { + Info = ((MCMessageInfo*)(*FCompleteQueue)[i]); + if (Info->Message.MsgID == MsgID) + { + FCompleteQueue->Del(i); + delete Info; Info = NULL; + res = true; + break; + } + } + FCompleteCriticalSection->Leave(); + return res; + } + else + return false; +} + +void MCMessenger::DispatchCompleteMessages(void) +{ + MCMessageInfo* Info; + MCMessageInfo* LocalInfo; + long i = 0, i2 = 0; + bool ProcessInfo; + + if (FCleanupInterval > 0) + CleanupQueues(); + + FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + while(i < FCompleteQueue->Length()) + { + Info = (MCMessageInfo*)(*FCompleteQueue)[i]; + ProcessInfo = false; + + FCompleteQueue->Del(i); + + if(!Info->ReplyFlag) + ProcessInfo = true; + + LocalInfo = NULL; + + FForwardCriticalSection->Enter(); + + i2 = FindMessageInQueue(Info->OrigID, FForwardQueue); + if (i2 != -1) + LocalInfo = (MCMessageInfo *)((*FForwardQueue)[i2]); + + if (LocalInfo != NULL) + { + FForwardQueue->Del(LocalInfo); + FForwardCriticalSection->Leave(); + + LocalInfo->MCError = Info->MCError; + + Info->CopyMessage(LocalInfo); + Info->Message.DataSize = 0; + Info->Message.Data = NULL; + + DoMessageProcessed(LocalInfo); + } + else + { + FForwardCriticalSection->Leave(); + + // only notify about complete (not abandoned) events + if(Info->State == imsComplete) + { + if(Info->NotifyProc) + { + FCompleteCriticalSection->Leave(); + Info->NotifyProc(Info->UserData, Info->Message); + FCompleteCriticalSection->Enter(); + } + } + else + if (Info->State == imsExpired) + { + if(Info->TimeoutProc) + { + FCompleteCriticalSection->Leave(); + Info->TimeoutProc(Info->UserData, Info->Message); + FCompleteCriticalSection->Enter(); + } + } + else + if (Info->State == imsFailed) + { + if(Info->ErrorProc) + { + FCompleteCriticalSection->Leave(); + Info->ErrorProc(Info->UserData, Info->Message, Info->MCError); + FCompleteCriticalSection->Enter(); + } + } + } + + if (ProcessInfo) + { + delete Info; Info = NULL; + } + } + } + FINALLY + ( + FCompleteEvent->resetEvent(); + FCompleteCriticalSection->Leave(); + ) +} + +void MCMessenger::MCDispatchMessages(void) +{ + MCQueue* AQueue; + MCMessageInfo* Info; + long i; + +/* if(FThreadID != IntGetCurrentThreadID()) + THROW_ERROR(MCError_WrongReceiverThread); +*/ + + DispatchCompleteMessages(); + if(NULL == FIncomingCriticalSection) + return; + FIncomingCriticalSection->Enter(); + TRY_BLOCK + { + i = 0; + while(i < FIncomingQueue->Length()) + { + Info = (MCMessageInfo*)(*FIncomingQueue)[i]; + if(Info->State == imsProcessing) + { + /* + char tmp[128]; + sprintf(tmp, "Missing message number %d due to its imsProcessing state\n", Info->Message.Param1); + OutputDebugString(tmp); + */ + i++; + continue; + } + char* q = strdup(Info->DQueue); + AQueue = FindQueue(q); + MCMemFree(q); + + //long Len = FIncomingQueue->Length(); + if(AQueue) + { + FIncomingCriticalSection->Leave(); + AQueue->ProcessMessage(Info); + FIncomingCriticalSection->Enter(); + } + else + { + Info->MCError = MCError_BadDestinationName; + MessageProcessed(&Info->Message); + } + /* + if(FIncomingQueue->Find(Info) != -1) + i++; + */ + + } + } FINALLY ( + FIncomingCriticalSection->Leave(); + ) +} + +void MCMessenger::DoSendMessage(const char* Destination, MCMessageInfo* Info) +{ + bool b = false; + char* destCopy = strCopy(Destination, 0, strlen(Destination)); + +//$ifdef MC_COMMERCIAL + char* RouteTo; + + if (FRouter != NULL) + { + char* pos = strchr(destCopy, '|'); + if (pos) + { + int i = pos - destCopy; + char* tmpAddr = strCopy(destCopy, 0, i); + RouteTo = FRouter->TranslateAddress(tmpAddr); + MCMemFree(tmpAddr); + if (RouteTo != NULL) + { + MCMemFree(destCopy); + destCopy = (char*) MCMemAlloc(strlen(RouteTo) + 1 + strlen(Destination) + 1); + destCopy[0] = 0; + strcat(destCopy, RouteTo); + strcat(destCopy, "|"); + strcat(destCopy, Destination); + MCMemFree(RouteTo); + } + } + } +//$endif MC_COMMERCIAL + + MCBaseTransport* Transport = NULL; + + for(long i = 0; i < FTransportList->Length();i++) + { + Transport = (MCBaseTransport*)((*FTransportList)[i]); + + if (Transport->AddressValid(destCopy, false)) + { + if(!Transport->getActive()) + { + THROW_ERROR(MCError_TransportInactive); + } + else + if (Transport->DeliverMessage(destCopy, Info)) + { + b = true; + break; + } + } + } + MCMemFree(destCopy); + if(!b) + THROW_ERROR(MCError_BadTransport); +} + +long MCMessenger::FindMessageInQueue(__int64 MessageID, MCList* Queue) +{ + MCMessageInfo* Info = NULL; + + for(long i = 0; i < Queue->Length(); i++) + { + Info = (MCMessageInfo*)(*Queue)[i]; + if(Info->Message.MsgID == MessageID) + return i ; + } + return -1; +} + +MCQueue* MCMessenger::FindQueue(char* QueueName) +{ +// QueueName := Uppercase(QueueName); + for(long i = 0;i <= FQueues->Length() - 1;i++) + { + if (((MCQueue*)(*FQueues)[i])->getQueueName() != NULL) +#if !defined( __GNUC__) || defined(QNX) + if(stricmp(((MCQueue*)(*FQueues)[i])->getQueueName(), QueueName)==0) +#else + if(strcasecmp(((MCQueue*)(*FQueues)[i])->getQueueName(), QueueName)==0) +#endif + return((MCQueue*)(*FQueues)[i]); + } + return NULL; +} + +/* +Gets new message from the message queue. Doesn't return until any message +is available. +*/ +void MCMessenger::MCGetMessage(MCMessage* Message) +{ + long i = -1; + bool cq = false; + MCHandle HandleArray[2]; +/* if(FThreadID != IntGetCurrentThreadID()) + THROW_ERROR(MCError_WrongReceiverThread); +*/ + DispatchCompleteMessages(); + FIncomingCriticalSection->Enter(); + i = HasPendingMessages(FIncomingQueue); + if(i == -1) + { + FIncomingCriticalSection->Leave(); + do { +#ifdef __GNUC__ + if(FIncomingEvent->WaitFor(0) == wrSignaled) + cq = true; + if(FCompleteEvent->WaitFor(0) == wrSignaled) + DispatchCompleteMessages(); + Sleep(10); +#else +//$ifndef LINUX + HandleArray[0] = FIncomingEvent->getHandle(); + HandleArray[1] = FCompleteEvent->getHandle(); + switch (WaitForMultipleObjects(2, (void**)&HandleArray, false, INFINITE)) { + case WAIT_OBJECT_0: + cq = true; + break; + case WAIT_OBJECT_0 + 1: + DispatchCompleteMessages(); + break; + default: + break; + } +//$endif +#endif + } while(!cq); + } + else + FIncomingCriticalSection->Leave(); + + MCMessageInfo* Info; + + DispatchCompleteMessages(); + FIncomingCriticalSection->Enter(); + if (i == -1) + i = HasPendingMessages(FIncomingQueue); + + if(i != -1) + { + Info = (MCMessageInfo*)((*FIncomingQueue)[i]); + Info->State = imsDispatching; + Info->Message.copyTo(Message); + FIncomingEvent->WaitFor(0); + } + FIncomingCriticalSection->Leave(); +} + +long MCMessenger::HasPendingMessages(MCList* Queue) +{ + MCMessageInfo* Info = NULL; + + for(long i = 0;i <= Queue->Length() - 1;i++) + { + Info = (MCMessageInfo*)(*Queue)[i]; + if(Info->State == imsWaiting) + return i; + } + return -1; +} + +void MCMessenger::MessageProcessed(MCMessage* Message) +{ + long i; + MCMessageInfo* Info; +/* if(FThreadID != IntGetCurrentThreadID()) + THROW_ERROR(MCError_WrongReceiverThread); +*/ + FIncomingCriticalSection->Enter(); + i = FindMessageInQueue(Message->MsgID, FIncomingQueue); + if(i != -1) + { + Info = (MCMessageInfo*)(*FIncomingQueue)[i]; + + //copy the 'fresh' message :) + Message->copyTo(&Info->Message); + + // remove the message from the queue of pending messages + + FIncomingQueue->Del(i); + FIncomingCriticalSection->Leave(); + + DoMessageProcessed(Info); + } + else + FIncomingCriticalSection->Leave(); +} + + +unsigned long MCMessenger::MsgWaitForMultipleObjects(unsigned long nCount,void* pHandles, + bool fWaitAll, unsigned long dwMilliseconds) +{ + MCHandle* Handles = NULL; + unsigned long i = 0, r = 0; +#ifndef NO_CHECK_DISPATCHTHREAD + if(FThreadID != IntGetCurrentThreadID()) + THROW_ERROR(MCError_WrongReceiverThread); +#endif + + long ToWait = (long) dwMilliseconds; + unsigned long StTime = 0; + unsigned long Elapsed = 0; + + DispatchCompleteMessages(); + FIncomingCriticalSection->Enter(); + if(HasPendingMessages(FIncomingQueue) == -1) + { + FIncomingCriticalSection->Leave(); +#ifdef __GNUC__ +//error No Linux support yet +#else +//$ifndef LINUX + Handles = (MCHandle*)MCMemAlloc(sizeof(MCHandle) * (nCount + 2)); + TRY_BLOCK + { + Handles[0] = FIncomingEvent->getHandle(); + Handles[1] = FCompleteEvent->getHandle(); + if (NULL != pHandles) + memcpy((char*)Handles + sizeof(MCHandle) * 2, pHandles, sizeof(MCHandle) * nCount); + + while (true) + { + StTime = GetTickCount(); + i = WaitForMultipleObjects(nCount + 2, (void**)Handles, fWaitAll, (unsigned long) ToWait); + if(i == WAIT_OBJECT_0) // our internal handle has been isgnaled + r = WAIT_OBJECT_0 + nCount; + else + if(i == WAIT_OBJECT_0 + 1) // completed message has been posted + { + + DispatchCompleteMessages(); + + Elapsed = GetTickCount(); + if(StTime > Elapsed) + Elapsed = Elapsed + ((unsigned long)-1) - StTime; + else + Elapsed = Elapsed - StTime; + ToWait = ToWait - ((long)Elapsed); + + if (dwMilliseconds == INFINITE) + { + ToWait = dwMilliseconds; + continue; + } + + if (ToWait < 0) + { + r = WAIT_TIMEOUT; + break; + } + else + continue; + } + else + if((i > WAIT_OBJECT_0 + 1) && (i <= WAIT_OBJECT_0 + nCount + 1)) // some handle has signaled + r = i - 2; + else + if(i == WAIT_ABANDONED_0) // our internal handle has been killed??? + r = WAIT_FAILED; + else + if(i == WAIT_ABANDONED_0 + 1) // our internal handle has been killed??? + r = WAIT_FAILED; + else + if((i > WAIT_ABANDONED_0 + 1) && (i < WAIT_ABANDONED_0 + nCount + 1)) // some handle has been killed + r = i - 2; + else + if(i == WAIT_TIMEOUT) // timeout + r = WAIT_TIMEOUT; + else // unknown event (most likely a failure) + r = WAIT_FAILED; + break; + } + } + FINALLY + ( + MCMemFree(Handles); + Handles = NULL; + ) +//$endif LINUX +#endif + } + else + { + FIncomingCriticalSection->Leave(); +#ifdef __GNUC__ +//error No Linux support yet +#else + r = WAIT_OBJECT_0 + nCount; +#endif + } + return r; +} + +/* +Gets new message from the message queue. Return immediately even when no +message is available. +Returns true if the message has been picked and false otherwise. +*/ + +bool MCMessenger::MCPeekMessage(MCMessage* Message) +{ + long i; + bool r = true; + //if(FThreadID != IntGetCurrentThreadID()) + // THROW_ERROR(MCError_WrongReceiverThread); + + MCMessageInfo * Info; + + DispatchCompleteMessages(); + FIncomingCriticalSection->Enter(); + try { + i = HasPendingMessages(FIncomingQueue); + if(i != -1) + { + Info = (MCMessageInfo*)(*FIncomingQueue)[i]; + Info->Message.copyTo(Message); + FIncomingEvent->WaitFor(0); + } + else + r = false; + } FINALLY ( + FIncomingCriticalSection->Leave(); + ) + return r; +} + +void MCMessenger::MCPostMessage(const char* Destination, MCMessage* Message, + MCMessageCredentials* Credentials) +{ + SendMessageTimeoutCallback(Destination, Message, FMaxTimeout, NULL, NULL, NULL, 0, Credentials); +} + +void MCMessenger::RemoveQueue(MCQueue* AQueue) +{ + long i = FQueues->Find(AQueue); + if(i != -1) + FQueues->Del(i); +} + +void MCMessenger::RemoveTransport(MCBaseTransport* ATransport) +{ + long i = FTransportList->Find(ATransport); + if(i != -1) + FTransportList->Del(i); +} + +/* +Gets new message from the message queue. Doesn't return until any message +is available. +*/ +long MCMessenger::MCSendMessage(const char* Destination, MCMessage* Message, + MCMessageCredentials* Credentials) +{ + long r; + if (MCSendMessageTimeout(Destination, Message, FMaxTimeout, false, Credentials, r)) + return r; + else + THROW_ERROR(MCError_TransportTimeout); + return 0; //stupid compiler... +} + +void MCMessenger::MCSendMessageCallback(const char* Destination, MCMessage* Message, + MCNotifyProc CompletionProc, unsigned long UserData, MCMessageCredentials* Credentials) +{ + SendMessageTimeoutCallback(Destination, Message, FMaxTimeout, CompletionProc, NULL, NULL, UserData, Credentials); +} + +void MCMessenger::SendMessageTimeoutCallback(const char* Destination, MCMessage* Message, + DWORD Timeout, MCNotifyProc CompletionProc, + MCNotifyProc TimeoutProc, MCErrorProc ErrorProc, + DWORD UserData, MCMessageCredentials* Credentials) +{ + +#ifndef MC_FORCE_EVAL + if (false) + { +#endif +#ifndef MC_FORCE_EVAL + } +#endif + + MCMessageInfo* Info; + Info = new MCMessageInfo(Message); + + // set OrigID + MCMessenger::SetOrigID(Info); + + Info->Timeout = Timeout; + Info->StartTime = GetTickCount(); + Info->NotifyProc = CompletionProc; + Info->TimeoutProc = TimeoutProc; + Info->ErrorProc = ErrorProc; + Info->UserData = UserData; + Info->ReplyFlag = NULL; + Info->IsSendMsg = CompletionProc != NULL; + if(Credentials) + memmove(&Info->Credentials, Credentials, sizeof(*Credentials)); + else + memset(&Info->Credentials, 0, sizeof(Info->Credentials)); + + int MCErrorCode = 0; + TRY_BLOCK + { + DoSendMessage(Destination, Info); + } + CATCH_MCERROR + { + delete Info; Info = NULL; + THROW_ERROR(MCErrorCode); + } +} + +bool MCMessenger::MCSendMessageTimeout(const char* Destination, MCMessage* Message, + unsigned long Timeout, bool Block, MCMessageCredentials* Credentials, + long& MsgResult) +{ + MCMessageInfo* Info; + long ToWait; +#ifdef __GNUC__ + long wtime; +#endif + unsigned long StTime; + unsigned long Elapsed; + bool b,r; + MCHandle HandleArray[3]; + +#ifndef MC_FORCE_EVAL + if (false) + { +#endif +#ifndef MC_FORCE_EVAL + } +#endif + + r = false; + Info = new MCMessageInfo(Message); + // set OrigID + MCMessenger::SetOrigID(Info); + + Info->ReplyFlag = new MCEvent(NULL, false, false, NULL); + Info->IsSendMsg = true; + if(Credentials) + memmove(&Info->Credentials, Credentials, sizeof(*Credentials)); + else + memset(&Info->Credentials, 0, sizeof(*Credentials)); + int errorCode = 0; + TRY_BLOCK + { + DoSendMessage(Destination, Info); + } + CATCH_EVERY + { + delete Info; Info = NULL; +#ifdef USE_CPPEXCEPTIONS + throw; +#else + RaiseException(GetExceptionCode(), 0, 0, NULL); +#endif + } + + ToWait = (long)Timeout; + b = Timeout == INFINITE; + do { + StTime = GetTickCount(); + +#ifdef __GNUC__ + long l_wait = ToWait * 100; + while(l_wait > 0) + { + if(Info->ReplyFlag->WaitFor(0) == wrSignaled) + { + r = true; + break; + } + if(FThreadID != IntGetCurrentThreadID()) + { + if(FIncomingEvent->WaitFor(0) == wrSignaled) + break; + } + Sleep(10); + l_wait--; + } + if(r) + break; +#else +//$ifndef LINUX + DWORD WaitRes; + if(FThreadID == IntGetCurrentThreadID()) + { + HandleArray[0] = Info->ReplyFlag->getHandle(); + HandleArray[1] = FIncomingEvent->getHandle(); + HandleArray[2] = FCompleteEvent->getHandle(); + WaitRes = WaitForMultipleObjects(3, (void**)&HandleArray, false, (unsigned long)ToWait); + } + else + WaitRes = WaitForSingleObject(Info->ReplyFlag->getHandle(), (unsigned long)ToWait); + + if(WaitRes == WAIT_OBJECT_0) + { + r = true; + break; + } +//$endif LINUX +#endif + // if timeout elapsed, break the loop + if (!r && (FThreadID != IntGetCurrentThreadID())) + break; + + Elapsed = GetTickCount(); + if(StTime > Elapsed) + Elapsed = Elapsed + ((unsigned long)-1) - StTime; + else + Elapsed = Elapsed - StTime; + ToWait = ToWait - ((long)Elapsed); + + StTime = GetTickCount(); + DispatchCompleteMessages(); + + if(!Block) + { + DispatchMessages(); + } + + Elapsed = GetTickCount(); + if(StTime > Elapsed) + Elapsed = Elapsed + ((unsigned long)-1) - StTime; + else + Elapsed = Elapsed - StTime; + ToWait = ToWait - ((long)Elapsed); + } while (b || (ToWait > 0)); + // if it was, set result + if(r) + { + FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + if(Info->State == imsFailed) + { + THROW_ERROR(Info->MCError); + } + else + { + MsgResult = Info->Message.Result; + Message->Result = MsgResult; + if (bdtVar == Message->DataType) + {//copy the fresh message value + Message->DataSize = Info->Message.DataSize; + MCFreeNull(Message->Data); + if (Message->DataSize) + { + Message->Data = MCMemAlloc(Message->DataSize); + memmove(Message->Data, Info->Message.Data, Message->DataSize); + } + else + Message->Data = NULL; + } + } + } FINALLY ( + FCompleteQueue->Del(Info); + delete Info; Info = NULL; + FCompleteCriticalSection->Leave(); + ) + } + else + { + Info->Transport->CancelMessage(Info); + delete Info; Info = NULL; + } + return r; +} + +void MCMessenger::setMaxTimeout(unsigned long Value) +{ + if(FMaxTimeout != Value) + { + FMaxTimeout = Value; + for (int i = 0; i < FTransportList->Length(); i++) + ((MCBaseTransport*)((*FTransportList)[i]))->CleanupMessages(); + } +} + +void MCMessenger::setCleanupInterval(unsigned long Value) +{ + if (FCleanupInterval != Value) + { + if (FCleanupInterval == 0 && Value > 0) + FLastCleanup = GetTickCount(); + FCleanupInterval = Value; + } +} + +void MCMessenger::SetMessageID(MCMessageInfo* MessageInfo) +{ + // create unique ID + long i = long(floor(Time() * 86400000)); + memmove(&MessageInfo->Message.MsgID, &i, sizeof(i)); + i = GetTickCount() +#ifndef __GNUC__ +//$ifndef LINUX + + InterlockedIncrement(&GlobalSeed) +//$endif LINUX +#else + + GlobalSeed++; +#endif + ; + memmove((((char*)(&MessageInfo->Message.MsgID)) + sizeof(i)), &i, sizeof(i)); +} + +void MCMessenger::SetOrigID(MCMessageInfo* MessageInfo) +{ + // create unique ID + long i = long(floor(Time() * 86400000)); + memmove(&MessageInfo->OrigID, &i, sizeof(i)); + i = GetTickCount() +#ifndef __GNUC__ +//$ifndef LINUX + + InterlockedIncrement(&GlobalSeed) +//$endif LINUX +#else + + GlobalSeed++; +#endif + ; + memmove((((char*)(&MessageInfo->OrigID)) + sizeof(i)), &i, sizeof(i)); +} + +bool MCMessenger::ValidateCredentials(MCMessageInfo* Info) +{ + bool r = false; + + void* UserData; + + if(getOnValidateCredentials(&UserData)) + FOnValidateCredentials(UserData, this, &Info->Message, &Info->Credentials, r); + else + r = true; + + return(r); +} + +/* +Waits for any message to appear in the message queue. +Returns only when any message appears. +*/ +void MCMessenger::MCWaitMessage(void) +{ + MCWaitMessageEx(INFINITE); +/* THandle HandleArray[2]; + bool cq = false; + long i; + +// if(FThreadID != IntGetCurrentThreadID()) +// THROW_ERROR(MCError_WrongReceiverThread); + + DispatchCompleteMessages(); + FIncomingCriticalSection->Enter(); + i = HasPendingMessages(FIncomingQueue); + if(i == -1) + { + FIncomingCriticalSection->Leave(); + do { +#ifdef __GNUC__ + if(FIncomingEvent->WaitFor(0) == wrSignaled) + cq = true; + if(FCompleteEvent->WaitFor(0) == wrSignaled) + DispatchCompleteMessages(); + Sleep(10); +#else +//$ifndef LINUX + HandleArray[0] = FIncomingEvent->getHandle(); + HandleArray[1] = FCompleteEvent->getHandle(); + switch (WaitForMultipleObjects(2, (void**)&HandleArray, false, INFINITE)) { + case WAIT_OBJECT_0: + cq = true; + break; + case WAIT_OBJECT_0 + 1: + DispatchCompleteMessages(); + break; + default: + break; + } +//$endif +#endif + } while(!cq); + } + else + FIncomingCriticalSection->Leave(); + DispatchCompleteMessages(); + */ +} + +//Timeout pointed in milliseconds +bool MCMessenger::MCWaitMessageEx(DWORD Timeout) +{ + MCHandle HandleArray[2]; + bool cq = false; + long i; + + double startTime = Now(); + + DispatchCompleteMessages(); + FIncomingCriticalSection->Enter(); + i = HasPendingMessages(FIncomingQueue); + if(i == -1) + { + FIncomingCriticalSection->Leave(); + do { + double currentTime = Now(); + //to consider possible floating-point errors... + DWORD elapsedTime = (currentTime > startTime + 0.0000001) ? (DWORD)((currentTime - startTime) * 86400000 + 0.5) : 0; + //timeout expired? + if (elapsedTime > Timeout && INFINITE != Timeout) + return false; + +#ifdef __GNUC__ + + if(FIncomingEvent->WaitFor(0) == wrSignaled) + cq = true; + if(FCompleteEvent->WaitFor(0) == wrSignaled) + DispatchCompleteMessages(); + Sleep(10); +#else +//$ifndef LINUX + HandleArray[0] = FIncomingEvent->getHandle(); + HandleArray[1] = FCompleteEvent->getHandle(); + + DWORD remainingTime = Timeout != INFINITE ? Timeout - elapsedTime : INFINITE; + + switch (WaitForMultipleObjects(2, (void**)&HandleArray, false, remainingTime)) { + case WAIT_OBJECT_0: + cq = true; + break; + + case WAIT_OBJECT_0 + 1: + DispatchCompleteMessages(); + break; + + case WAIT_TIMEOUT: + return false; + + default: + break; + } +//$endif +#endif + } while(!cq); + } + else + FIncomingCriticalSection->Leave(); + /* + if (cq || i != -1) + { + //walk through FIncomingQueue + FIncomingCriticalSection->Enter(); + for (long j=0; jLength(); j++) + { + MCMessageInfo* pInfo = (MCMessageInfo*)FIncomingQueue->At(j); + if (imsWaiting == pInfo->State) + { + char tmp[128]; + sprintf(tmp, "Message number %d arrived\n", pInfo->Message.Param1); + OutputDebugString(tmp); + } + } + FIncomingCriticalSection->Leave(); + } + */ + DispatchCompleteMessages(); + return true; +} + +void MCMessenger::GetMessageSource(const MCMessage* Message, char* Buffer, int* BufferSize) +{ +// if (IntGetCurrentThreadID() != FThreadID) +// THROW_ERROR(MCError_WrongReceiverThread); + + FIncomingCriticalSection->Enter(); + int i = FindMessageInQueue(Message->MsgID, FIncomingQueue); + if (-1 != i) + { + MCMessageInfo* Info = (MCMessageInfo*)(*FIncomingQueue)[i]; + FIncomingCriticalSection->Leave(); + if ((NULL != Info) && (FTransportList->Find(Info->Transport) != -1)) + { + TRY_BLOCK + { + Info->Transport->GetMessageSource(Info, Buffer, BufferSize); + } + CATCH_EVERY + { + ; + } + } + else + { + if (NULL != Buffer) + Buffer[0] = 0; + if (NULL != BufferSize) + *BufferSize = 0; + } + } + else + { + FIncomingCriticalSection->Leave(); + if (NULL != Buffer) + Buffer[0] = 0; + if (NULL != BufferSize) + *BufferSize = 0; + } +} + +//$ifdef MC_COMMERCIAL +void MCMessenger::setRouter(MCBaseRouter* Value) +{ + FRouter = Value; +} + +MCBaseRouter* MCMessenger::getRouter() +{ + return FRouter; +} +//$endif MC_COMMERCIAL + +void MCMessenger::DoMessageProcessed(MCMessageInfo* Info) +{ + // adjust message state + if(Info->MCError == 0) + Info->State = imsComplete; + else + Info->State = imsFailed; + + strncpy(Info->DQueue, "intREPLY\0", sizeof(Info->DQueue) - 1); + + if(Info->Message.DataType == bdtConst) + { + if((Info->Message.DataSize != 0) && Info->Message.Data) + MCFreeNull(Info->Message.Data); + else + if (Info->Message.Data) + { + Info->Message.Data = NULL; + } + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + + // if the message was posted, no need to return it back + if(Info->IsSendMsg && (FTransportList->Find(Info->Transport) != -1)) + { + TRY_BLOCK + { +//$IFDEF MC_COMMERCIAL + if (Info->RouteTo) + { + MCMemFree(Info->RouteTo); + } + Info->RouteTo = Info->RecvPath; + Info->RecvPath = NULL; +//$ENDIF MC_COMMERCIAL + + Info->Transport->MessageProcessed(Info); + } + CATCH_EVERY + { + + } + } + else + { + delete Info; Info = NULL;//DestroyMessageInfo(Info); + } +} + +bool MCMessenger::ForwardMessage(const char* Destination, MCMessage* Message, + DWORD Timeout, MCMessageCredentials* Credentials) +{ + bool res = false; + FIncomingCriticalSection->Enter(); + TRY_BLOCK + { + MCMessageInfo* Info = NULL; + int i = FindMessageInQueue(Message->MsgID, FForwardQueue); + if (i != -1) + Info = (MCMessageInfo *) ((*FForwardQueue)[i]); + + // only forward the message that has not been forwarded yet + if (Info == NULL) + { + Info = NULL; + i = FindMessageInQueue(Message->MsgID, FIncomingQueue); + if (i != -1) + Info = (MCMessageInfo *) ((*FIncomingQueue)[i]); + + if (Info != NULL) + { + MCMessageInfo* NewInfo = new MCMessageInfo(Message); + NewInfo->OrigID = Message->MsgID; + + NewInfo->Message.MsgID = Message->MsgID; + + /* + if (Message->Data != NULL) + { + NewInfo->Message.Data = MCMemAlloc(Message->DataSize); + NewInfo->Message.DataSize = Message->DataSize; + memmove(NewInfo->Message.Data, Message->Data, Message->DataSize); + } + */ + + NewInfo->Timeout = Timeout; + NewInfo->StartTime = GetTickCount(); + NewInfo->NotifyProc = NULL; + NewInfo->TimeoutProc = NULL; + NewInfo->ErrorProc = NULL; + NewInfo->UserData = 0; + NewInfo->ReplyFlag = NULL; + NewInfo->IsSendMsg = true; + if(Credentials) + memmove(&NewInfo->Credentials, Credentials, sizeof(*Credentials)); + else + memset(&NewInfo->Credentials, 0, sizeof(Info->Credentials)); + + int MCErrorCode = 0; + TRY_BLOCK + { + DoSendMessage(Destination, NewInfo); + + FIncomingQueue->Del(Info); + FForwardCriticalSection->Enter(); + FForwardQueue->Add(Info); + FForwardCriticalSection->Leave(); + + res = true; + } + CATCH_MCERROR + { + delete NewInfo; NewInfo = NULL; +#ifndef USE_CPPEXCEPTIONS + THROW_ERROR(MCErrorCode); +#else + throw; +#endif + } + } + } + } + FINALLY + ( + FIncomingCriticalSection->Leave(); + ) + return res; +} + +void MCMessenger::GetQueueStatus(const char* QueueName, long MsgCodeLow, long MsgCodeHigh, + long &MsgCount, long &MsgTotalSize, long &MsgMaxSize) +{ + long i; + MCMessageInfo* Info; + long MS; + + MsgCount = 0; + MsgMaxSize = 0; + MsgTotalSize = 0; + + char* q = (char *) QueueName; + if (q != NULL && strlen(q) == 0) + q = NULL; + + + FIncomingCriticalSection->Enter(); + TRY_BLOCK + { + for (i = 0; i < FIncomingQueue->Length(); i++) + { + Info = (MCMessageInfo *) ((*FIncomingQueue)[i]); + if (q) + { +#if !defined( __GNUC__) || defined(QNX) + if(stricmp(Info->DQueue, q)==0) +#else + if(strcasecmp(Info->DQueue, q)==0) +#endif + continue; + } + + if (((MsgCodeLow != 0) || (MsgCodeHigh != 0)) && + ((Info->Message.MsgCode < MsgCodeLow) || (Info->Message.MsgCode > MsgCodeHigh))) + continue; + + MS = sizeof(MCMessage) - sizeof(Info->Message.Data) + Info->Message.DataSize; + MsgTotalSize += MS; + if (MS > MsgMaxSize) + MsgMaxSize = MS; + MsgCount++; + } + } + FINALLY + ( + FIncomingCriticalSection->Leave(); + ); +} + +bool MCMessenger::GetMessageSent(__int64 MsgID) +{ + MCMessageInfo *Info; + + bool res = true; + + for (int i = 0; i < FTransportList->Length(); i++) + { + Info = ((MCBaseTransport*)((*FTransportList)[i]))->GetMessageByID(MsgID); + if (Info) + { + res = Info->State == imsWaiting; + break; + } + else + res = true; + } + return res; +} + +void MCMessenger::CreateMessageSimple(long MsgCode, long Param1, long Param2, MCMessage& Message) +{ + memset(&Message, 0, sizeof(MCMessage)); + Message.MsgCode = MsgCode; + Message.Param1 = Param1; + Message.Param2 = Param2; +} + +void MCMessenger::CreateMessageFromBinary(long MsgCode, long Param1, long Param2, void* Binary, long BinarySize, bool IsVarData, MCMessage& Message) +{ + memset(&Message, 0, sizeof(MCMessage)); + Message.MsgCode = MsgCode; + Message.Param1 = Param1; + Message.Param2 = Param2; + + Message.DataSize = BinarySize; + + if (BinarySize > 0) + { + Message.Data = MCMemAlloc(BinarySize); + memmove(Message.Data, Binary, BinarySize); + } + else + Message.Data = NULL; + + Message.DataType = IsVarData ? bdtVar : bdtConst; +} + +void MCMessenger::CreateMessageFromText(long MsgCode, long Param1, long Param2, const char* Text, bool IsVarData, MCMessage& Message) +{ + memset(&Message, 0, sizeof(MCMessage)); + Message.MsgCode = MsgCode; + Message.Param1 = Param1; + Message.Param2 = Param2; + + if (Text == NULL) + { + Message.DataSize = 0; + Message.Data = NULL; + } + else + { + Message.DataSize = strlen(Text) + 1; + Message.Data = MCMemAlloc(Message.DataSize); + memmove(Message.Data, Text, Message.DataSize); + } + + Message.DataType = IsVarData ? bdtVar : bdtConst; +} + +void* MCMessenger::getDirectTransportList() +{ + if (DirectTransportCS == NULL) + DirectTransportCS = new MCCriticalSection(); + + void* result; + + DirectTransportCS->Enter(); + TRY_BLOCK + { + if (DirectTransports == NULL) + { + DirectTransports = new MCList(); + } + result = DirectTransports; + } + FINALLY ( + DirectTransportCS->Leave(); + ) + return result; +} + +void MCMessenger::setDirectTransportList(void* value) +{ + if (DirectTransports != value) + { + if (DirectTransportCS == NULL) + DirectTransportCS = new MCCriticalSection(); + + DirectTransportCS->Enter(); + if (DirectTransports != NULL) + { + delete DirectTransports; + } + DirectTransports = (MCList *) value; + DirectTransportForeign = true; + DirectTransportCS->Leave(); + } +} + + +/*const char* MCMessenger::GetMessageDestQueue(__int64 MsgID) +{ + MCMessageInfo *Info = NULL; + + for (int i = 0; i < FTransportList->Length(); i++) + { + Info = ((MCBaseTransport*)((*FTransportList)[i]))->GetMessageByID(MsgID); + if (Info) + return Info->DQueue; + } + return NULL; +}*/ + +// **************************** TMCMessageHandler ***************************** + +MCMessageHandler::MCMessageHandler(MCMessageHandlers* Collection) +{ + FCollection = Collection; + FEnabled = true; + FMsgCodeHigh = ULONG_MAX; + FMsgCodeLow = 0; + FOnMessage = NULL; + FOnMessageData = NULL; +} + +void MCMessageHandler::Assign(MCMessageHandler& Source) +{ + FEnabled = Source.getEnabled(); + FMsgCodeHigh = Source.getMsgCodeHigh(); + FMsgCodeLow = Source.getMsgCodeLow(); + FOnMessage = Source.getOnMessage(); + FOnMessageData = Source.FOnMessageData; +} + +bool MCMessageHandler::getEnabled(void) +{ + return(FEnabled); +} + +void MCMessageHandler::setEnabled(bool v) +{ + FEnabled = v; +} + +long MCMessageHandler::getMsgCodeHigh(void) +{ + return(FMsgCodeHigh); +} + +void MCMessageHandler::setMsgCodeHigh(long v) +{ + FMsgCodeHigh = v; +} + +long MCMessageHandler::getMsgCodeLow(void) +{ + return(FMsgCodeLow); +} + +void MCMessageHandler::setMsgCodeLow(long v) +{ + FMsgCodeLow = v; +} + +MCHandleMessageEvent MCMessageHandler::getOnMessage(void**UserData) +{ + if (UserData) + *UserData = FOnMessageData; + + return(FOnMessage); +} + +void MCMessageHandler::setOnMessage(MCHandleMessageEvent v, void* UserData) +{ + FOnMessageData = UserData; + FOnMessage = v; +} + +// **************************** TMCMessageHandlers **************************** + +void MCMessageHandlers::MCMessageHandlerDelete(void* /*sender*/, void* v) +{ + delete (MCMessageHandler*)v; +} + +MCMessageHandlers::MCMessageHandlers(MCQueue* Queue) +{ + FOwner = Queue; + DeleteItem = MCMessageHandlers::MCMessageHandlerDelete; +} + +/* +Adds a message handler to the list and returns the reference to this +handler. +*/ +MCMessageHandler* MCMessageHandlers::Add(void) +{ + MCMessageHandler* mh = new MCMessageHandler(this); + MCList::Add(mh); + return mh; +} + +MCMessageHandler* MCMessageHandlers::getItems(long Index) +{ + return((MCMessageHandler*)((*this)[Index])); +} + +MCQueue* MCMessageHandlers::GetOwner(void) +{ + return FOwner; +} + +void MCMessageHandlers::setItems(long Index, const MCMessageHandler* Value) +{ + this->Data[Index] = (void*)Value; +} + +// ********************************* TMCQueue ********************************* + +MCQueue::MCQueue() +{ + FHandlers = new MCMessageHandlers(this); + FMessenger = NULL; + FOnUnhandledMessage = NULL; + FOnUnhandledMessageData = NULL; + FQueueName = NULL; +} + +MCQueue::~MCQueue() +{ + FMessenger = NULL; + delete FHandlers; FHandlers = NULL; + if (NULL != FQueueName) + free(FQueueName); + FQueueName = NULL; +} + +void MCQueue::ProcessMessage(MCMessageInfo* Info) +{ + long i; + bool Handled = false; + + if(!FMessenger) return; + i = 0; + Info->State = imsProcessing; + while(i < FHandlers->Length()) + { + Handled = false; + void* UserData; + if(FHandlers->getItems(i)->getOnMessage(&UserData)) + { + if((FHandlers->getItems(i)->getMsgCodeHigh() >= Info->Message.MsgCode) + && (FHandlers->getItems(i)->getMsgCodeLow() <= Info->Message.MsgCode) + && (FHandlers->getItems(i)->getEnabled())) + { + FHandlers->getItems(i)->getOnMessage()(UserData, this, Info->Message, Handled); + } + } + if(Handled) + break; + i++; + } + if(!Handled) + { + void* UserData; + if(getOnUnhandledMessage(&UserData)) + getOnUnhandledMessage()(UserData, this, Info->Message, Handled); + if(!Handled) + Info->Message.Result = 0; + } + FMessenger->MessageProcessed(&Info->Message); +} + +MCMessageHandlers* MCQueue::getHandlers(void) +{ + return(FHandlers); +} + +void MCQueue::setHandlers(MCMessageHandlers* Value) +{ +// FHandlers->copyof(Value); + FHandlers = Value; +} + +MCMessenger* MCQueue::getMessenger(void) +{ + return(FMessenger); +} + +void MCQueue::setMessenger(MCMessenger* Value) +{ + if(FMessenger != Value) + { + if(FMessenger) + { + FMessenger->RemoveQueue(this); + } + FMessenger = Value; + if(FMessenger) + { + FMessenger->AddQueue(this); + } + } +} + +MCHandleMessageEvent MCQueue::getOnUnhandledMessage(void**UserData) +{ + if (UserData) + *UserData = FOnUnhandledMessageData; + + return(FOnUnhandledMessage); +} + +void MCQueue::setOnUnhandledMessage(MCHandleMessageEvent Value, void* UserData) +{ + FOnUnhandledMessageData = UserData; + FOnUnhandledMessage = Value; +} + +char* MCQueue::getQueueName(void) +{ + return FQueueName; +} + +void MCQueue::setQueueName(char* Value) +{ + FQueueName = strdup(Value); +} + +// ***************************** TMCBaseTransport ***************************** + +MCBaseTransport::MCBaseTransport() +{ + FLinkCriticalSection = new MCCriticalSection(); + FCriticalSection = new MCCriticalSection(); + + FMaxTimeout = INFINITE; + FMaxMsgSize = 0x7FFFDFFF; + FThreadID = GetCurrentThreadId(); + FActive = false; + FCompressor = NULL; + FEncryptor = NULL; + FMessenger = NULL; + FSealer = NULL; + FName = NULL; + FDefaultTransportName = NULL; + FIgnoreIncomingPriorities = false; + FDiscardUnsentMessages = false; +} + +MCBaseTransport::~MCBaseTransport() +{ + setActive(false); + FLinkCriticalSection->Enter(); + try { + setMessenger(NULL); + setCompressor(NULL); + setEncryptor(NULL); + setSealer(NULL); + } FINALLY ( + FLinkCriticalSection->Leave(); + delete FLinkCriticalSection; + FLinkCriticalSection = NULL; + ) + delete FCriticalSection; + FCriticalSection = NULL; + MCMemFree(FName); +} + + +void MCBaseTransport::InsertInfoIntoQueueWithPriorities(MCList* Queue, MCMessageInfo* Info, bool IgnoreMode) +{ + int Cnt, j; + MCMessageInfo* TmpInfo; + Cnt = Queue->Length(); + j = Cnt - 1; + while (j >= -1) + { + if (j == -1) + { + Queue->Insert(0, Info); + if (Cnt > 1) + { + TmpInfo = (MCMessageInfo *)((*Queue)[1]); + } + } + else + { + TmpInfo = (MCMessageInfo *)((*Queue)[j]); + if ((TmpInfo->IsSendMsg && (!Info->IsSendMsg)) || + ((TmpInfo->IsSendMsg == Info->IsSendMsg) && (IgnoreMode || + (TmpInfo->Message.Priority >= Info->Message.Priority))) ) + { + Queue->Insert(j + 1, Info); + break; + } + } + j--; + } +} + +bool MCBaseTransport::getActive(void) +{ + return(FActive); +} + +MCBaseCompression* MCBaseTransport::getCompressor(void) +{ + return(FCompressor); +} + +MCCBaseEncryption* MCBaseTransport::getEncryptor(void) +{ + return FEncryptor; +} + +long MCBaseTransport::getMaxMsgSize(void) +{ + return FMaxMsgSize; +} + +void MCBaseTransport::setMaxMsgSize(long v) +{ + FMaxMsgSize = v; +} + +unsigned long MCBaseTransport::getMaxTimeout(void) +{ + return FMaxTimeout; +} + +void MCBaseTransport::setMaxTimeout(unsigned long v) +{ + FMaxTimeout = v; +} + +MCMessenger* MCBaseTransport::getMessenger(void) +{ + return FMessenger; +} + +MCBaseSealing* MCBaseTransport::getSealer(void) +{ + return FSealer; +} + +bool MCBaseTransport::AddressValid(char* Address, bool ChangeAddress) +{ + char* S = NULL; + long l = 0; + bool r = false; + + if(!FName) + { + l = strlen(FDefaultTransportName) + 2; + S = (char*)MCMemAlloc(l); + strcpy(S, FDefaultTransportName); + } + else + { + l = strlen(FName) + 2; + S = (char*)MCMemAlloc(l); + strcpy(S,FName); + } + S[l - 2] = ':'; + S[l - 1] = 0; +#if !defined(__GNUC__) || defined(QNX) + r = strnicmp(Address, S, l - 1) == 0; +#else + r = strncasecmp(Address, S, l - 1) == 0; +#endif + MCMemFree(S); S = NULL; + if(true == r && true == ChangeAddress) + { + memmove(Address, &Address[l - 1], strlen(Address) - l + 1); + Address[strlen(Address) - l + 1] = 0; + } + return r; +} + +void MCBaseTransport::DoSetActive(void) +{ + // intentionally left blank +} + +void MCBaseTransport::Loaded(void) +{ + if(FActive) + { + FActive = false; + setActive(true); + } +} + +/* + PrepareDataBlock takes some buffer and prepares it for delivery. After the + call to this method the Data block is considered to be invalid ( + PrepareDataBlock most likely will dispose of it). +*/ + +void MCBaseTransport::PrepareDataBlock(char* Remote,void* Data, long DataSize, void*& OutputData, + long& OutputSize, long& EncryptID, long& CompressID, long& SealID) +{ + bool b; + + FLinkCriticalSection->Enter(); + try { + OutputData = Data; + OutputSize = DataSize; + + // compress + if(CompressID > 0) + { + if(FCompressor && (FCompressor->GetID() == CompressID)) + { + b = true; + FCompressor->Compress(Remote, Data, DataSize, OutputData, OutputSize, b); + if(b) + { + Data = OutputData; + DataSize = OutputSize; + } + else + CompressID = 0; + } + else + CompressID = 0; + } + else + CompressID = 0; + + // seal + if(SealID != 0) + { + if(FSealer && (FSealer->GetID() == SealID)) + { + b = true; + FSealer->Seal(Remote, Data, DataSize, OutputData, OutputSize, b); + if(b) + { + Data = OutputData; + DataSize = OutputSize; + } + else + SealID = 0; + } + else + SealID = 0; + } + else + SealID = 0; + + // encrypt + if(EncryptID != 0) + { + if(FEncryptor && (FEncryptor->GetID() == EncryptID)) + { + b = true; + FEncryptor->Encrypt(Remote, Data, DataSize, OutputData, OutputSize, b); + if(b) + { + /*Data = OutputData;*/ + /*DataSize = OutputSize;*/ + } + else + EncryptID = 0; + } + else + EncryptID = 0; + } + else + EncryptID = 0; + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCBaseTransport::setActive(bool Value) +{ + if(FActive != Value) + { + FActive = Value; + try { + if (FMessenger) + DoSetActive(); +#ifdef USE_CPPEXCEPTIONS + } catch(...) { +#else + } __except(1) { +#endif + FActive = false; +#ifdef USE_CPPEXCEPTIONS + throw; +#else + RaiseException(1,0,0,0); +#endif + } + } +} + +void MCBaseTransport::setCompressor(MCBaseCompression* Value) +{ + //bool b; + + if(FCompressor != Value) + { + FLinkCriticalSection->Enter(); + TRY_BLOCK { +// b = getActive(); +// setActive(false); + FCompressor = Value; +// if(FCompressor) +// FCompressor->FreeNotification(this); +// setActive(b); + } FINALLY ( + FLinkCriticalSection->Leave(); + ) + } +} + +void MCBaseTransport::setEncryptor(MCCBaseEncryption* Value) +{ + //bool b; + + if(FEncryptor != Value) + { + FLinkCriticalSection->Enter(); + TRY_BLOCK { +// b = getActive(); +// setActive(false); + FEncryptor = Value; +// if(FEncryptor) +// FEncryptor->FreeNotification(this); +// setActive(b); + } FINALLY ( + FLinkCriticalSection->Leave(); + ) + } +} + +void MCBaseTransport::setMessenger(MCMessenger* Value) +{ + bool b, b1; + + if(FMessenger != Value) + { + b1 = getActive(); + setActive(false); + + FLinkCriticalSection->Enter(); + try { + b = FMessenger != NULL; + if(b) + FMessenger->RemoveTransport(this); + FMessenger = Value; + if(FMessenger) + { + FMessenger->AddTransport(this); +// FMessenger->FreeNotification(this); + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) + setActive(b1); + } +} + +void MCBaseTransport::setSealer(MCBaseSealing* Value) +{ + //bool b; + + if(FSealer != Value) + { + FLinkCriticalSection->Enter(); + TRY_BLOCK { +// b = getActive(); +// setActive(false); + FSealer = Value; +// if(FSealer) +// FSealer->FreeNotification(this); +// setActive(b); + } FINALLY ( + FLinkCriticalSection->Leave(); + ) + } +} + +/* + PrepareDataBlock takes some buffer and prepares it for delivery. After the + call to this method the Data block is considered to be invalid ( + PrepareDataBlock most likely will dispose of it). +*/ + +bool MCBaseTransport::UnprepareDataBlock(char* Remote,void* Data, long DataSize, void*& OutputData, + long& OutputSize, long EncryptID, long CompressID, long SealID) +{ + bool b, b1, b2, b3; + + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + OutputData = Data; + OutputSize = DataSize; + b1 = false; + b2 = false; + b3 = false; + + // compress + if(EncryptID != 0) + { + if(FEncryptor && (FEncryptor->GetID() == EncryptID)) + { + b = true; + FEncryptor->Decrypt(Remote, Data, DataSize, OutputData, OutputSize, EncryptID, b); + if(b) + { + Data = OutputData; + DataSize = OutputSize; + b3 = true; + } + } + } + else + if(EncryptID == 0) + b3 = true; + + // seal + if(b3) + { + if(SealID != 0) + { + if(FSealer && (FSealer->GetID() == SealID)) + { + b = true; + FSealer->UnSeal(Remote, Data, DataSize, OutputData, OutputSize, SealID, b); + if(b) + { + Data = OutputData; + DataSize = OutputSize; + b2 = true; + } + } + } + else + if(SealID == 0) + b2 = true; + } + + // encrypt + if(b2) + { + if(CompressID > 0) + { + if(FCompressor && (FCompressor->GetID() == CompressID)) + { + b = true; + FCompressor->Decompress(Remote, Data, DataSize, OutputData, OutputSize, CompressID, b); + if(b) + { + //Data = OutputData; + //DataSize = OutputSize; + b1 = true; + } + } + } + else + if(CompressID == 0) + b1 = true; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) + return b1; +} + +void MCBaseTransport::GetMessageSource(MCMessageInfo* Info, char* Buffer, int* BufferSize) +{ + bool EmptySource = false; + EmptySource = (NULL == FName) && (NULL == FDefaultTransportName); + if (false == EmptySource) + EmptySource = FName ? (FName[0] == 0) : (FDefaultTransportName[0] == 0); + + if (true == EmptySource) + { + if (NULL != Buffer) + Buffer[0] = 0; + if (NULL != BufferSize) + *BufferSize = 0; + } + else + { + //char temp[16]; sprintf(temp, "%d", Info->ConnID); + if (NULL != BufferSize) + { + if (NULL != FName) + *BufferSize = strlen(FName) + 1 + strlen(Info->SMessenger)/* + 1 + strlen(temp)*/; + else + *BufferSize = strlen(FDefaultTransportName) + 1 + strlen(Info->SMessenger) /*+ 1 + strlen(temp)*/; + } + if (NULL != Buffer) + { + strcpy(Buffer, (NULL != FName) ? FName : FDefaultTransportName); + strcat(Buffer, ":"); + //strcat(Buffer, temp); + //strcat(Buffer, "#"); + strcat(Buffer, Info->SMessenger); + } + } + +} + + +//$ifdef MC_COMMERCIAL +/// Resends a message to new destination +void MCBaseTransport::RouteMessage(MCMessageInfo* Info) +{ + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if (FMessenger != NULL) + { + char* S = Info->RouteTo; + Info->RouteTo = NULL; + char* tmpAddr = (char*) MCMemAlloc(strlen(S) + 1 + strlen(Info->DQueue) + 1); + tmpAddr[0] = 0; + strcat(tmpAddr, S); + strcat(tmpAddr, "|"); + strcat(tmpAddr, Info->DQueue); + MCMemFree(S); + FMessenger->DoSendMessage(tmpAddr, Info); + MCMemFree(tmpAddr); + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} +//$endif MC_COMMERCIAL + +char* MCBaseTransport::RealTransportName() +{ + if (FName) + return FName; + else + return FDefaultTransportName; +} + +char* MCBaseTransport::getName(void) +{ + return FName; +} + +void MCBaseTransport::setName(char* Value) +{ + MCMemFree(FName); + FName = strCopy(Value, 0); +} + +bool MCBaseTransport::CancelMessageByID(__int64 MsgID, DWORD ErrorCode, bool Discard) +{ + bool res = false; + FCriticalSection->Enter(); + TRY_BLOCK + { + MCMessageInfo *Info = GetMessageByID(MsgID); + if (Info) + { + CancelMessage(Info); + Info->State = imsFailed; + Info->MCError = ErrorCode; + + res = true; + + if (Discard == false) + { + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + + FMessenger->FCompleteCriticalSection->Enter(); + //TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if (Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + //} FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + //) + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) + } + else + { + delete Info; + Info = NULL; + } + } + } + FINALLY + ( + FCriticalSection->Leave(); + ) + return res; +} + +MCMessageInfo* MCBaseTransport::GetMessageByID(__int64 MsgID) +{ + return NULL; +} + +bool MCBaseTransport::getIgnoreIncomingPriorities(void) +{ + return FIgnoreIncomingPriorities; +} + +void MCBaseTransport::setIgnoreIncomingPriorities(bool Value) +{ + FIgnoreIncomingPriorities = Value; +} + +void MCBaseTransport::Shutdown(bool DiscardUnsentMessages) +{ + if (getActive()) + { + FDiscardUnsentMessages = DiscardUnsentMessages; + setActive(false); + FDiscardUnsentMessages = false; + } +} + +// **************************** TMCDirectTransport **************************** + +MCDirectTransport* MCDirectTransport::FindTransportByID(char* ID) +{ + MCDirectTransport* Transport = NULL; + if (DirectTransports == NULL) + return NULL; + for (int i = 0; i < DirectTransports->Length(); i++) + { + Transport = ((MCDirectTransport*)(*DirectTransports)[i]); +#if !defined(__GNUC__) || defined(QNX) + if (stricmp(ID, Transport->getTransportID()) == 0) +#else + if (strcasecmp(ID, Transport->getTransportID()) == 0) +#endif + { + return (MCDirectTransport*)(*DirectTransports)[i]; + } + } + return NULL; +} + +MCDirectTransport::MCDirectTransport() +:MCBaseTransport() +{ + FDefaultTransportName = "LOCAL"; + + FTransportID = (char *) MCMemAlloc(11); + sprintf(FTransportID, "%d", (DWORD) this); + + FOutgoingQueue = new MCList(); + + if (DirectTransportCS == NULL) + { + DirectTransportCS = new MCCriticalSection(); + DirectTransports = new MCList(); + } +} + +MCDirectTransport::~MCDirectTransport() +{ + setActive(false); + delete FOutgoingQueue; + + MCMemFree(FTransportID); FTransportID = NULL; + DirectTransportCS->Enter(); + if (DirectTransports != NULL && DirectTransports->Length() == 0) + { + delete DirectTransports; DirectTransports = NULL; + } + DirectTransportCS->Leave(); +} + +long MCDirectTransport::GetOutgoingMessagesCount() +{ + return FOutgoingQueue->Length(); +} + +void MCDirectTransport::DoSetActive(void) +{ + if (getActive()) + { + DirectTransportCS->Enter(); + if (DirectTransports == NULL) + { + DirectTransports = new MCList(); + } + DirectTransports->Add(this); + DirectTransportCS->Leave(); + } + else + { + DirectTransportCS->Enter(); + DirectTransports->Del(this); + DirectTransportCS->Leave(); + + if (FOutgoingQueue != NULL) + { + while (FOutgoingQueue->Length() > 0) + { + CancelMessageByID(((MCMessageInfo*)(*FOutgoingQueue)[0])->Message.MsgID, MCError_Shutdown); + } + } + } +} + +void MCDirectTransport::CancelMessage(MCMessageInfo* Info) +{ + FCriticalSection->Enter(); + TRY_BLOCK + { + FOutgoingQueue->Del(Info); + } FINALLY ( + FCriticalSection->Leave(); + ) +} + +bool MCDirectTransport::DeliverMessage(char* DestAddress, MCMessageInfo* Info) +{ + long p; + char *sep, *dm; + MCDirectTransport* DestTransport = NULL; + + if(DestAddress && AddressValid(DestAddress)) + { + sep = strchr(DestAddress, '|'); + + if (sep != NULL) + { + p = sep - DestAddress; + + dm = (char *) MCMemAlloc(p + 1); + strncpy(dm, DestAddress, p); + dm[p] = 0; + + DestTransport = FindTransportByID(dm); + if (DestTransport == NULL) + { + MCMemFree(dm); + THROW_ERROR(MCError_BadDestinationName); + } + } + else + { + dm = strdup(FTransportID); + DestTransport = this; + } + + __int64 saveID = Info->Message.MsgID; + + MCMessageInfo* NewInfo = new MCMessageInfo(&Info->Message); + Info->Message.MsgID = saveID; + Info->Transport = this; + + NewInfo->OrigID = Info->OrigID; + + NewInfo->setDMessenger(dm); + NewInfo->setSMessenger(FTransportID); + + sep++; + strncpy(NewInfo->DQueue, sep, DQueueMaxLength - 1); + NewInfo->DQueue[DQueueMaxLength - 1] = 0; + + NewInfo->IsSendMsg = Info->IsSendMsg; + + memmove(&NewInfo->Credentials, &Info->Credentials, sizeof(Info->Credentials)); + + /* + if (Info->Message.Data != NULL) + { + NewInfo->Message.Data = MCMemAlloc(Info->Message.DataSize); + memmove(NewInfo->Message.Data, Info->Message.Data, Info->Message.DataSize); + NewInfo->Message.DataSize = Info->Message.DataSize; + } + */ + + if(Info->IsSendMsg) + { + FCriticalSection->Enter(); + try + { + FOutgoingQueue->Add(Info); + DestTransport->MessageReceived(NewInfo); + } + FINALLY + ( + FCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL; + DestTransport->MessageReceived(NewInfo); + } + + MCMemFree(dm); + + return true; + } + else + return false; +} + +void MCDirectTransport::MessageReceived(MCMessageInfo* Info) +{ + Info->Transport = this; + Info->State = imsWaiting; + + FMessenger->FIncomingCriticalSection->Enter(); + try + { + InsertInfoIntoQueueWithPriorities(FMessenger->FIncomingQueue, Info, FIgnoreIncomingPriorities); + FMessenger->FIncomingEvent->setEvent(); + } FINALLY ( + FMessenger->FIncomingCriticalSection->Leave(); + ) +} + +void MCDirectTransport::ReplyReceived(MCMessageInfo* Info) +{ + MCMessageInfo* CurInfo = NULL; + + FCriticalSection->Enter(); + + try + { + for (int i = 0; i < FOutgoingQueue->Length(); i++) + { + if (((MCMessageInfo*)((*FOutgoingQueue)[i]))->OrigID == Info->OrigID) + { + CurInfo = (MCMessageInfo*)((*FOutgoingQueue)[i]); + FOutgoingQueue->Del(i); + break; + } + } + } + FINALLY + ( + FCriticalSection->Leave(); + ) + if (CurInfo != NULL) + { + if (CurInfo->Message.Data != NULL) + { + MCMemFree(CurInfo->Message.Data); + CurInfo->Message.Data = NULL; + } + Info->CopyMessage(CurInfo); + Info->Message.DataSize = 0; + Info->Message.Data = NULL; + + CurInfo->MCError = Info->MCError; + CurInfo->State = Info->State; + + DoMessageProcessed(CurInfo); + } +} + +void MCDirectTransport::DoMessageProcessed(MCMessageInfo* Info) +{ + FMessenger->FCompleteCriticalSection->Enter(); + try { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) +} + +void MCDirectTransport::MessageProcessed(MCMessageInfo* Info) +{ + MCDirectTransport *DestTransport = FindTransportByID(Info->SMessenger); + if (DestTransport != NULL) + { + DestTransport->ReplyReceived(Info); + delete Info; Info = NULL; + } +} + +void MCDirectTransport::CleanupMessages() +{ + int i; + MCMessageInfo* Info; + unsigned int TC; + bool me; + + FCriticalSection->Enter(); + TRY_BLOCK + { + i = 0; + TC = GetTickCount(); + while (i < FOutgoingQueue->Length()) + { + Info = (MCMessageInfo*)((*FOutgoingQueue)[i]); + + if (Info->Timeout == 0) + { + i++; + continue; + } + + if (TC < Info->StartTime) + { + me = 0xFFFFFFFF - Info->StartTime + TC >= Info->Timeout; + } + else + { + me = TC - Info->StartTime >= Info->Timeout; + } + if (me) + { + CancelMessage(Info); + Info->State = imsExpired; + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if (Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) + } + else + i++; + } + } + FINALLY ( + FCriticalSection->Leave(); + ) +} + +MCMessageInfo* MCDirectTransport::GetMessageByID(__int64 MsgID) +{ + int i; + MCMessageInfo* Info; + MCMessageInfo* res = NULL; + + FCriticalSection->Enter(); + TRY_BLOCK + { + i = 0; + while (i < FOutgoingQueue->Length()) + { + Info = (MCMessageInfo*)((*FOutgoingQueue)[i]); + + if (Info->Message.MsgID == MsgID) + { + res = Info; + break; + } + else + i++; + } + } + FINALLY ( + FCriticalSection->Leave(); + ) + return res; +} + +// **************************** TMCSimpleTransport **************************** +MCSimpleTransport::MCSimpleTransport() +{ + FOutgoingQueue = new MCList(); +#ifdef __GNUC__ +#ifndef QNX + FOutgoingCount = new MCSemaphore(0, IPC_PRIVATE, true); +#else + FOutgoingCount = new MCSemaphore(0, NULL, true); +#endif +#else +//$ifndef LINUX + FOutgoingCount = CreateSemaphore(NULL, 0, LONG_MAX - 1, NULL); +//$endif +#endif +} + +MCSimpleTransport::~MCSimpleTransport() +{ + delete FOutgoingQueue; +#ifdef __GNUC__ + delete FOutgoingCount; +#else +//$ifndef LINUX + CloseHandle(FOutgoingCount); +//$endif +#endif +} + +void MCSimpleTransport::CleanupMessages() +{ + int i; + MCMessageInfo* Info; + unsigned int TC; + bool me; + + FCriticalSection->Enter(); + TRY_BLOCK + { + i = 0; + TC = GetTickCount(); + while (i < FOutgoingQueue->Length()) + { + Info = (MCMessageInfo*)((*FOutgoingQueue)[i]); + + if (Info->Timeout == 0) + { + i++; + continue; + } + + if (TC < Info->StartTime) + { + me = 0xFFFFFFFF - Info->StartTime + TC >= Info->Timeout; + } + else + { + me = TC - Info->StartTime >= Info->Timeout; + } + if (me) + { + CancelMessage(Info); + Info->State = imsExpired; + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if (Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) + } + else + i++; + } + } + FINALLY ( + FCriticalSection->Leave(); + ) +} + +MCMessageInfo* MCSimpleTransport::GetMessageByID(__int64 MsgID) +{ + int i; + MCMessageInfo* Info; + MCMessageInfo* res = NULL; + + FCriticalSection->Enter(); + TRY_BLOCK + { + i = 0; + while (i < FOutgoingQueue->Length()) + { + Info = (MCMessageInfo*)((*FOutgoingQueue)[i]); + + if (Info->Message.MsgID == MsgID) + { + res = Info; + break; + } + else + i++; + } + } + FINALLY ( + FCriticalSection->Leave(); + ) + return res; +} + +long MCSimpleTransport::GetOutgoingMessagesCount() +{ + return FOutgoingQueue->Length(); +} + +void MCSimpleTransport::MessageReceived(MCMessageInfo* Info) +{ + // add to incoming queue + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger) + { + // check message credentials + if(!FMessenger->ValidateCredentials(Info)) + { + Info->MCError = MCError_WrongCredentials; + Info->State = imsFailed; + // if the message was posted, no need to return it back + if(Info->IsSendMsg) + { + FLinkCriticalSection->Leave(); + MessageProcessed(Info); + FLinkCriticalSection->Enter(); + } + else + { + delete Info; Info = NULL;//MCMessenger::DestroyMessageInfo(Info); + } + } + else + { + Info->MCError = 0; + Info->Transport = this; + Info->State = imsWaiting; + + FMessenger->FIncomingCriticalSection->Enter(); + TRY_BLOCK + { + InsertInfoIntoQueueWithPriorities(FMessenger->FIncomingQueue, Info, FIgnoreIncomingPriorities); + + FMessenger->FIncomingEvent->setEvent(); + // Begin platform-specific code (Windows) +// PostThreadMessage(FMessenger->getThreadID(), WM_NULL, 0, 0); + // End platform-specific code (Windows) + } FINALLY ( + FMessenger->FIncomingCriticalSection->Leave(); + ) + } + } + else + { + delete Info; Info = NULL;//MCMessenger::DestroyMessageInfo(Info); + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCSimpleTransport::ReplyReceived(MCMessageInfo* Info) +{ + // add to complete queue + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger) + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); +// else +// return; + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL; + //MCMessenger::DestroyMessageInfo(Info); + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCSimpleTransport::DeliveryFailed(MCMessageInfo* Info) +{ + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger && (Info->State == imsDispatching || Info->State == imsWaiting) && Info->IsSendMsg) + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + Info->State = imsFailed; + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCSimpleTransport::MessageProcessed(MCMessageInfo* Info) +{ + // Info->DQueue[0] = 0; + MCMemFree(Info->DMessenger); + Info->DMessenger = strdup(Info->SMessenger); + MCMemFree(Info->SMessenger); + Info->SMessenger = NULL; + SetInfoSMessenger(Info); + FCriticalSection->Enter(); + TRY_BLOCK + { + InsertInfoIntoQueueWithPriorities(FOutgoingQueue, Info, FIgnoreIncomingPriorities); + KickSender(true); + } FINALLY ( + FCriticalSection->Leave(); + ) +} + +void MCSimpleTransport::CancelMessage(MCMessageInfo* Info) +{ + FCriticalSection->Enter(); + TRY_BLOCK + { + CancelMessageInSender(Info); + FOutgoingQueue->Del(Info); + } FINALLY ( + FCriticalSection->Leave(); + ) +} + +void MCSimpleTransport::KickSender(bool MessageFlag) +{ + // default implementation does nothing +} + +void MCSimpleTransport::CancelMessageInSender(MCMessageInfo* Info) +{ + // default implementation does nothing +} + +bool MCSimpleTransport::WasCancelled(MCMessageInfo* Info) +{ + // default implementation does nothing + return false; +} + +void MCSimpleTransport::SetInfoSMessenger(MCMessageInfo* Info) +{ + // default implementation does nothing +} + +//$ifdef MC_COMMERCIAL +// **************************** TMCBaseRouter **************************** + +MCBaseRouter::MCBaseRouter() +{ + FCriticalSection = new MCCriticalSection(); + FMessenger = NULL; + FOnTranslateAddress = NULL; + FOnTranslateAddressData = NULL; +} + +MCBaseRouter::~MCBaseRouter() +{ + delete FCriticalSection; + FCriticalSection = NULL; +} + +MCMessenger* MCBaseRouter::getMessenger(void) +{ + return FMessenger; +} + +void MCBaseRouter::setMessenger(MCMessenger* Value) +{ + if (FMessenger != NULL) + FMessenger->setRouter(NULL); + FMessenger = Value; + if (FMessenger != NULL) + FMessenger->setRouter(this); +} + +MCTranslateAddressEvent MCBaseRouter::getOnTranslateAddress(void**UserData) +{ + if (UserData) + *UserData = FOnTranslateAddressData; + + return FOnTranslateAddress; +} + +void MCBaseRouter::setOnTranslateAddress(MCTranslateAddressEvent Value, void* UserData) +{ + FOnTranslateAddressData = UserData; + FOnTranslateAddress = Value; +} +//$endif + +static volatile int UniqueID = 0; +MCCriticalSection UniqueIDCS; + +int CreateUniqueID(void) +{ + UniqueIDCS.Enter(); + int result = ++UniqueID; + UniqueIDCS.Leave(); + return result; +} + +void MCBaseInitialization(void) +{ + DefineOS(); +#if defined(__GNUC__) || defined(_WIN32_WCE) + GlobalSeed = (unsigned long)(((__int64)0x7FFFFFFFul)*Random()/(RAND_MAX+1)); +#else +#ifndef _MSC_VER + GlobalSeed = random(0x7FFFFFFFul); +#else + GlobalSeed = rand(); +#endif +#endif + InitializeThreads(); + MCMainThreadID = GetCurrentThreadId(); +} + +static class MsgConnectInitializer +{ +public: + MsgConnectInitializer(void) + { + MCBaseInitialization(); + } +} InitMsgConnectObject; + + + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCBase.h b/libraries/external/eldos/pc/include/MCBase.h new file mode 100755 index 0000000..1c1cb60 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCBase.h @@ -0,0 +1,751 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCBASE__ +#define __MCBASE__ + +#include "MC.h" +#include "MCUtils.h" +#include "MCLists.h" +#include "MCSyncs.h" +#include "MCLogger.h" +#include "MCStream.h" + + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +//#define SEH2CPP + +//#undef SendMessageTimeout +#ifdef _WIN32_WCE +# undef MsgWaitForMultipleObjects +#endif + +//#undef SendMessage +//#undef SendMessageTimeout +//#undef SendMessageCallback + +void MCBaseInitialization(void); // !!! CALL THIS BEFORE ANY MC OPERATION !!! +void InitializeThreads(void); + +class MCBaseTransport; +//$ifdef MC_COMMERCIAL +class MCBaseRouter; +//$endif + +typedef enum {bdtConst, bdtVar} MCBinDataType; + +// The sequence of fields must remain the same. New fields can be added before +// DataType field + +/* +#ifdef _WIN32 +bool SupportsTSNames(void); +#endif +void* MCMemAlloc(long Size); +void MCMemFree(void* Block); +void MCFreeNull(void*& Block); +*/ + +#ifdef _WIN32 +extern MCList* DirectTransports; +#endif + +typedef enum { + itcNormal, + itcTransactionPart, + itcTransactionStart, + itcTransactionCommit, + itcTransactionRollback +} MCTransactCmd; + +struct MCMessage { + __int64 MsgID; + MCTransactCmd TransCmd; + short TransID; + signed char Priority; + long MsgCode; + long Result; + long Param1; + long Param2; + MCBinDataType DataType; + long DataSize; + void* Data; + + MCMessage(void) { + Priority = 0; + TransCmd = itcNormal; + Data = NULL; + DataSize = 0; + Result = 0; + DataType = bdtVar; + }; + + /* + ~MCMessage() { + if (Data) + MCMemFree(Data); + Data = NULL; + }; + */ + + void copyTo(MCMessage* msg) + { + memmove(&msg->MsgID, &MsgID, sizeof(MCMessage)); + }; +}; + +typedef struct { + byte UserName[16]; + byte Password[16]; +} MCMessageCredentials; + +typedef enum { + imsQueued, // placed to the queue for delivery 0 + imsDispatching, // in delivery queue 1 + imsWaiting, // waiting for processing 2 + imsProcessing, // currently in ProcessMessage 3 + imsComplete, // complete and waiting for delivery to destination 4 + imsFailed, // declined by transport 5 + imsEmptyRequest,// 6 + imsEmptyReply, // empty messages - used for resuming aborted connections 7 + imsExpired, // the message expired while in delivery queue 8 + imsNone // just none state is not set 9 +} MCMessageState; + +class MCQueue; + +#ifndef __GNUC__ +//$ifndef LINUX +# define STDCALLCONV __stdcall +//$endif +#else +# define STDCALLCONV +#endif + + +const int DQueueMaxLength=32; + +//define handlers +typedef void (STDCALLCONV *MCNotifyProc)(unsigned long UserData, MCMessage& Message); +typedef void (STDCALLCONV *MCErrorProc)(unsigned long UserData, MCMessage& Message, long ErrorCode); +typedef void (STDCALLCONV *MCHandleMessageEvent)(void* UserData, void* Sender, + MCMessage& Message, bool& Handled); +typedef void (STDCALLCONV *MCValidateCredentialsEvent)(void* UserData, void* Sender, + MCMessage* Message, MCMessageCredentials* Credentials, bool& Valid); +//typedef void (STDCALLCONV *MCHandleMessageTimeout)(void* resvd, void* Sender, MCMessage* Message); + +//$ifdef MC_COMMERCIAL +typedef void (STDCALLCONV *MCTranslateAddressEvent)(void* UserData, void* Sender, + char* Address, char** RouteTo, bool* UseDefaultRoutingTable); +//$endif + +// The sequence of fields must remain the same. New fields can be added before +// Message field +#include "MCStream.h" + +class MCMessageInfo +{ +public: + // transferrable fields + double Time; + __int64 OrigID; + long IsSendMsg; + char DQueue[DQueueMaxLength]; + MCMessageCredentials + Credentials; + long MCError; + MCMessageState State; + MCMessage Message; + + // local fields + MCEvent* ReplyFlag; + MCBaseTransport* Transport; + long UserData; + MCNotifyProc NotifyProc; + MCNotifyProc TimeoutProc; + MCErrorProc ErrorProc; + //char SourcePrefix[4]; + long ConnID; + long ClientID; + char* SMessenger; + char* DMessenger; + char* URL; + unsigned int StartTime; + unsigned int Timeout; + void* Track; + MCMessageState OldState; + bool Sent; + +//$ifdef MC_COMMERCIAL + MCTransactCmd TransactCmd; + int TransactID; + char* RecvPath; + char* RouteTo; + bool Intermed; + void* EncodedMsg; + int EncodedLen; + int EncryptID; + int CompressID; + int SealID; +//$endif MC_COMMERCIAL + + MCMessageInfo(MCMessage* Msg); + ~MCMessageInfo(); + void WriteToStream(MCStream* Stream); + void LoadFromStream(MCStream* Stream); + void setSMessenger(char* SMsg); + void setDMessenger(char* DMsg); + void setURL(char* URLStr); +//$ifdef MC_COMMERCIAL + void setRecvPath(char* value); + void setRouteTo(char* value); + void setEncodedMsg(void* value, long len); +//$endif MC_COMMERCIAL + void CopyMessage(MCMessageInfo* Dest); +}; + +class MCBaseTransformer: public MCObject { +public: + virtual long GetID(void)=0; +}; + +class MCBaseCompression:public MCBaseTransformer { +friend class MCBaseTransport; +protected: + virtual void Compress(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success)=0; + virtual void Decompress(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success)=0; +}; + +class MCCBaseEncryption:public MCBaseTransformer { +friend class MCBaseTransport; +protected: + virtual void Encrypt(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success)=0; + virtual void Decrypt(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success)=0; +}; + +class MCBaseSealing:public MCBaseTransformer { +friend class MCBaseTransport; +protected: + virtual void Seal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success)=0; + virtual void UnSeal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success)=0; +}; + +//#define INFINITE 0xFFFFFFFF + +class MCMessenger: public MCObject +{ +private: +friend class MCBaseTransport; +friend class MCSimpleTransport; +friend class MCInetTransport; +friend class MCInetTransportJob; +friend class MCDirectTransport; +friend class MCSocketTransport; +friend class MCSocketTransportJob; +friend class MCMMFTransport; +friend class MCMMFSenderThread; +friend class MCMMFReceiverThread; +friend class MCHttpTransport; +friend class MCHttpTransportJob; +friend class MCMessageInfo; +friend class MCUDPTransport; +friend class MCUDPSenderThread; +friend class MCUDPReceiverThread; +friend class MCOBEXTransport; +friend class MCOBEXThread; +friend class MCQueue; +//$ifdef MC_COMMERCIAL +friend class MCBaseRouter; +//$endif MC_COMMERCIAL + + unsigned long FThreadID; + /* + The list of transports registered for the given messenger + */ + MCList* FTransportList; +protected: + + MCCriticalSection* FCompleteCriticalSection; + /* + MainEvent is set to signaled state when a message appears in Incoming + queue. + */ + MCEvent* FCompleteEvent; + /* + Queue of messages pending for receiving. + These messages are read by PeekMessage/GetMessage. + */ + MCList* FCompleteQueue; + unsigned long FMaxTimeout; + unsigned long FCleanupInterval; + unsigned long FLastCleanup; + MCValidateCredentialsEvent + FOnValidateCredentials; + void* FOnValidateCredentialsData; + MCList* FQueues; + + MCCriticalSection* FForwardCriticalSection; + MCList* FForwardQueue; + + MCCriticalSection* FIncomingCriticalSection; + /* + MainEvent is set to signaled state when a message appears in Incoming + queue. + */ + MCEvent* FIncomingEvent; + /* + Queue of messages pending for receiving. + These messages are read by PeekMessage/GetMessage. + */ + MCList* FIncomingQueue; +//$ifdef MC_COMMERCIAL + MCBaseRouter* FRouter; +//$endif MC_COMMERCIAL + + void AddQueue(MCQueue* AQueue); + void AddTransport(MCBaseTransport* ATransport); + void DispatchCompleteMessages(void); + void DoSendMessage(const char* Destination, MCMessageInfo* Info); + MCQueue* FindQueue(char* QueueName); + long HasPendingMessages(MCList* Queue); + void RemoveQueue(MCQueue* AQueue); + void RemoveTransport(MCBaseTransport* ATransport); + bool ValidateCredentials(MCMessageInfo* Info); + + void DoMessageProcessed(MCMessageInfo* Info); + void CleanupForwardQueue(); + + static long FindMessageInQueue(__int64 MessageID, MCList* Queue); +/* static MCMessageInfo* CreateMessageInfo(MCMessage* Message); + static void DestroyMessageInfo(MCMessageInfo* Info); + static MCMessageInfo* CopyMessageInfo(MCMessageInfo* Info); + static void SetSMessenger(MCMessageInfo* Info, char* SMsg); + static void SetDMessenger(MCMessageInfo* Info, char* DMsg); */ + +//$ifdef MC_COMMERCIAL + void setRouter(MCBaseRouter* Value); + MCBaseRouter* getRouter(); +//$endif MC_COMMERCIAL +public: + MCMessenger(); + virtual ~MCMessenger(); + + static void SetMessageID(MCMessageInfo* MessageInfo); + static void SetOrigID(MCMessageInfo* MessageInfo); + + static void CreateMessageSimple(long MsgCode, long Param1, long Param2, MCMessage& Message); + static void CreateMessageFromBinary(long MsgCode, long Param1, long Param2, void* Binary, long BinarySize, bool IsVarData, MCMessage& Message); + static void CreateMessageFromText(long MsgCode, long Param1, long Param2, const char* Text, bool IsVarData, MCMessage& Message); + + void MCDispatchMessages(void); + void DispatchMessages(void) { MCDispatchMessages(); }; + /* + Gets new message from the message queue. Doesn't return until any message + is available. + */ + void MCGetMessage(MCMessage* Message); + void GetMessage(MCMessage* Message) { MCGetMessage(Message); }; + + void MessageProcessed(MCMessage* Message); + + bool ForwardMessage(const char* Destination, MCMessage* Message, + DWORD Timeout, MCMessageCredentials* Credentials); + + DWORD MsgWaitForMultipleObjects(DWORD nCount,void* pHandles, bool fWaitAll, DWORD dwMilliseconds); + /* + Gets new message from the message queue. Return immediately even when no + message is available. + Returns true if the message has been picked and false otherwise. + */ + bool MCPeekMessage(MCMessage* Message); + bool PeekMessage(MCMessage* Message) + { return MCPeekMessage(Message); }; + + void MCPostMessage(const char* Destination, MCMessage* Message, + MCMessageCredentials* Credentials); + void PostMessage(const char* Destination, MCMessage* Message, + MCMessageCredentials* Credentials) + { MCPostMessage(Destination, Message, Credentials); }; + + /* + Gets new message from the message queue. Doesn't return until any message + is available. + */ + long MCSendMessage(const char* Destination, MCMessage* Message, + MCMessageCredentials* Credentials); + long SendMessage(const char* Destination, MCMessage* Message, + MCMessageCredentials* Credentials) + { return MCSendMessage(Destination, Message, Credentials); }; + + void MCSendMessageCallback(const char* Destination, MCMessage* Message, + MCNotifyProc CompletionProc, DWORD UserData, MCMessageCredentials* Credentials); + void SendMessageCallback(const char* Destination, MCMessage* Message, + MCNotifyProc CompletionProc, DWORD UserData, MCMessageCredentials* Credentials) + { MCSendMessageCallback(Destination, Message, CompletionProc, UserData, Credentials); }; + + bool MCSendMessageTimeout(const char* Destination, MCMessage* Message, + DWORD Timeout, bool Block, MCMessageCredentials* Credentials, + long& MsgResult); + bool SendMessageTimeout(const char* Destination, MCMessage* Message, + DWORD Timeout, bool Block, MCMessageCredentials* Credentials, + long& MsgResult) + { return MCSendMessageTimeout(Destination, Message, Timeout, Block, Credentials, MsgResult); }; + + void SendMessageTimeoutCallback(const char* Destination, MCMessage* Message, + DWORD Timeout, MCNotifyProc CompletionProc, + MCNotifyProc TimeoutProc, MCErrorProc ErrorProc, DWORD UserData, + MCMessageCredentials* Credentials); + + /* + Waits for any message to appear in the message queue. + Returns only when any message appears. + */ + void MCWaitMessage(void); + void WaitMessage(void) { MCWaitMessage(); }; + bool MCWaitMessageEx(DWORD Timeout); + bool WaitMessageEx(DWORD Timeout) { return MCWaitMessageEx(Timeout); }; + void CleanupQueues(); + bool CancelMessage(__int64 MsgID); + bool CancelMessageEx(__int64 MsgID, bool CancelComplete); + bool GetMessageSent(__int64 MsgID); + //const char* GetMessageDestQueue(__int64 MsgID); + void GetMessageSource(const MCMessage* Message, char* Buffer, int* BufferSize); + + void GetQueueStatus(const char* QueueName, long MsgCodeLow, long MsgCodeHigh, + long &MsgCount, long &MsgTotalSize, long &MsgMaxSize); + + void* getDirectTransportList(); + void setDirectTransportList(void* value); + + + unsigned long getThreadID(void); + void setThreadID(unsigned long Thr); //GetCurrentThread() or getpid() result should be used + + unsigned long getMaxTimeout(void); + void setMaxTimeout(unsigned long Value); + unsigned long getCleanupInterval(void); + void setCleanupInterval(unsigned long Value); + MCValidateCredentialsEvent + getOnValidateCredentials(void* *UserData = NULL); + void setOnValidateCredentials(MCValidateCredentialsEvent Value, void* UserData = NULL); +//$ifdef BERND_VERSION + bool IsMessageHere(const char* QueueName); +//$endif + +}; + +class MCMessageHandlers; + +class MCMessageHandler +{ +private: +friend class MCMessageHandlers; + bool FEnabled; + long FMsgCodeHigh; + long FMsgCodeLow; + MCList* FCollection; + MCHandleMessageEvent + FOnMessage; + void* FOnMessageData; +public: + MCMessageHandler(MCMessageHandlers* Collection); + + void Assign(MCMessageHandler& Source); + bool getEnabled(void); + void setEnabled(bool v); + long getMsgCodeHigh(void); + void setMsgCodeHigh(long v); + long getMsgCodeLow(void); + void setMsgCodeLow(long v); + /* + The handler should process the message and set Handled to true if the + message is processed. + There is no need to call MCMessenger.MessageProcessed manually. + */ + MCHandleMessageEvent getOnMessage(void**UserData = NULL); + void setOnMessage(MCHandleMessageEvent v, void* UserData = NULL); +}; + +class MCQueue; + +class MCMessageHandlers: public MCList +{ +friend class MCQueue; +protected: + MCQueue* FOwner; + + + static void MCMessageHandlerDelete(void* sender,void* v); + MCQueue* GetOwner(void); + bool HandleMessage(MCMessageInfo* Info); +public: + MCMessageHandlers(MCQueue* Queue); + /* + Adds a message handler to the list and returns the reference to this + handler. + */ + MCMessageHandler* Add(void); + /* + Use getItems/setItems to access particular handler in the list. + */ + MCMessageHandler* getItems(long Index); + void setItems(long Index, const MCMessageHandler* Value); +}; + +class MCQueue: public MCObject +{ +friend class MCMessenger; +protected: + MCMessageHandlers* FHandlers; + MCMessenger* FMessenger; + MCHandleMessageEvent + FOnUnhandledMessage; + void* FOnUnhandledMessageData; + char* FQueueName; + //MCList* FMessages; + //MCCriticalSection* FGuard; + + void ProcessMessage(MCMessageInfo* Info); + + bool HandleMessage(MCMessageInfo* Info); + void ProcessMessages(void); + void AddIncoming(MCMessageInfo* Info); + +public: + MCQueue(); + virtual ~MCQueue(); + + MCMessageHandlers* getHandlers(void); + void setHandlers(MCMessageHandlers* Value); + MCMessenger* getMessenger(void); + void setMessenger(MCMessenger* Value); + MCHandleMessageEvent getOnUnhandledMessage(void* *UserData = NULL); + void setOnUnhandledMessage(MCHandleMessageEvent Value, void* UserData = NULL); + /* + This is the name of the queue as it will be known to the sender. + */ + char* getQueueName(void); + void setQueueName(char* Value); +}; + + +//$ifdef MC_COMMERCIAL +class MCBaseRouter : public MCObject { +protected: + MCCriticalSection* FCriticalSection; + MCTranslateAddressEvent FOnTranslateAddress; + void* FOnTranslateAddressData; + MCMessenger* FMessenger; + +public: + MCBaseRouter(); + ~MCBaseRouter(); + + virtual char* TranslateAddress(char* Address) = 0; + + //void ClearRoutingRules(); + //void AddRoutingRule(char *Address, char* RouteTo); + + MCMessenger* getMessenger(void); + void setMessenger(MCMessenger* Value); + + MCTranslateAddressEvent getOnTranslateAddress(void* *UserData = NULL); + void setOnTranslateAddress(MCTranslateAddressEvent Value, void* UserData = NULL); + + +}; +//$endif + +class MCBaseTransport: public MCObject +{ +friend class MCMessenger; +friend class MCQueue; +friend class MCInetTransportJob; + +protected: + char* FName; + long FThreadID; + + char* FDefaultTransportName; + bool FActive; + MCBaseCompression* FCompressor; + MCCBaseEncryption* FEncryptor; + /* + LinkCriticalSection is used to secure operations with + compressors/encryptors + and to prevent access to those objects from several threads. + */ + MCCriticalSection* FLinkCriticalSection; + MCCriticalSection* FCriticalSection; + long FMaxMsgSize; + unsigned long FMaxTimeout; + unsigned long FMsgTimeout; + MCMessenger* FMessenger; + MCBaseSealing* FSealer; + bool FIgnoreIncomingPriorities; + bool FDiscardUnsentMessages; + + static void InsertInfoIntoQueueWithPriorities(MCList* Queue, MCMessageInfo* Info, bool IgnoreMode); + virtual bool AddressValid(char* Address, bool ChangeAddress = true); + //$ifdef MC_COMMERCIAL + virtual void RouteMessage(MCMessageInfo* Info); + //$endif + virtual void CancelMessage(MCMessageInfo* Info)=0; + virtual bool DeliverMessage(char* DestAddress, MCMessageInfo* Info)=0; + virtual void DoSetActive(void); + virtual void Loaded(void); + virtual void MessageProcessed(MCMessageInfo* Info)=0; + virtual void CleanupMessages(void) = 0; + virtual bool CancelMessageByID(__int64 MsgID, DWORD ErrorCode = MCError_Cancelled, bool Discard = false); + virtual MCMessageInfo* GetMessageByID(__int64 MsgID); + /* + PrepareDataBlock takes some buffer and prepares it for delivery. After the + call to this method the Data block is considered to be invalid ( + PrepareDataBlock most likely will dispose of it). + */ + void PrepareDataBlock(char* Remote,void* Data, long DataSize, void*& OutputData, + long& OutputSize, long& EncryptID, long& CompressID, long& SealID); + /* + PrepareDataBlock takes some buffer and prepares it for delivery. After the + call to this method the Data block is considered to be invalid ( + PrepareDataBlock most likely will dispose of it). + */ + bool UnprepareDataBlock(char* Remote,void* Data, long DataSize, void*& OutputData, + long& OutputSize, long EncryptID, long CompressID, long SealID); + virtual void GetMessageSource(MCMessageInfo* Info, char* Buffer, int* BufferSize); + + char* RealTransportName(); + +public: + MCBaseTransport(void); + virtual ~MCBaseTransport(void); + + void Shutdown(bool DiscardUnsentMessages); + + virtual long GetOutgoingMessagesCount() = 0; + /* + Specifies whether the transport is active and can be used to deliver + messages. + */ + bool getActive(void); + void setActive(bool Value); + MCBaseCompression* getCompressor(void); + void setCompressor(MCBaseCompression* Value); + MCCBaseEncryption* getEncryptor(void); + void setEncryptor(MCCBaseEncryption* Value); + MCBaseSealing* getSealer(void); + void setSealer(MCBaseSealing* Value); + /* + USe this property to specify how much data can be sent in a single + message. + If the message is larger, than the specified limit, it is declined. + */ + long getMaxMsgSize(void); + void setMaxMsgSize(long v); + char* getName(void); + void setName(char* Value); + + /* + MaxTimeout specifies a timeout for SendMessage method (so that + Sendessage is not blocked forever if the destination is unreachable). + */ + unsigned long getMaxTimeout(void); + void setMaxTimeout(unsigned long v); + MCMessenger* getMessenger(void); + void setMessenger(MCMessenger* Value); + bool getIgnoreIncomingPriorities(void); + void setIgnoreIncomingPriorities(bool Value); + +}; + +class MCDirectTransport:public MCBaseTransport +{ +protected: + + MCList* FOutgoingQueue; + + char* FTransportID; + + virtual void DoSetActive(); + virtual void CancelMessage(MCMessageInfo* Info); + virtual bool DeliverMessage(char* DestAddress, MCMessageInfo* Info); + virtual void MessageProcessed(MCMessageInfo* Info); + virtual void DoMessageProcessed(MCMessageInfo* Info); + virtual void ReplyReceived(MCMessageInfo* Info); + virtual void MessageReceived(MCMessageInfo* Info); + virtual void CleanupMessages(); + virtual MCMessageInfo* GetMessageByID(__int64 MsgID); +public: + MCDirectTransport(); + virtual ~MCDirectTransport(); + virtual long GetOutgoingMessagesCount(); + + static MCDirectTransport* FindTransportByID(char* ID); + char* getTransportID() { return FTransportID; }; +}; + +class MCSimpleTransport: public MCBaseTransport +{ +protected: +#ifdef __GNUC__ + MCSemaphore* FOutgoingCount; +#else +//$ifndef LINUX + MCHandle FOutgoingCount; +//$endif +#endif + MCList* FOutgoingQueue; + + virtual void CleanupMessages(); + virtual MCMessageInfo* GetMessageByID(__int64 MsgID); + void MessageReceived(MCMessageInfo* Info); + void ReplyReceived(MCMessageInfo* Info); + virtual void DeliveryFailed(MCMessageInfo* Info); + virtual void MessageProcessed(MCMessageInfo* Info); + virtual void CancelMessage(MCMessageInfo* Info); + + virtual void KickSender(bool MessageFlag); + virtual void CancelMessageInSender(MCMessageInfo* Info); + virtual bool WasCancelled(MCMessageInfo* Info); + virtual void SetInfoSMessenger(MCMessageInfo* Info); + +public: + MCSimpleTransport(); + virtual ~MCSimpleTransport(); + + virtual long GetOutgoingMessagesCount(); +}; + +// internal service functions + +void equPstr(char* p, char* s, int max); +char* Pstr2c(char* p); +char* strCopy(const char* s, long f, long l = -1); +long strPos(char c, const char* s); + +extern double Now(void); +extern int CreateUniqueID(void); +extern void DefineOS(void); +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCCRC32.cpp b/libraries/external/eldos/pc/include/MCCRC32.cpp new file mode 100755 index 0000000..d430d51 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCCRC32.cpp @@ -0,0 +1,119 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCCRC32.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +const long CRC32_POLYNOMIAL = 0xEDB88320ul; + +long Ccitt32Table[256]; + +bool table_built = false; + +void BuildCRCTable(void) +{ + unsigned long i, j, value; + + if(table_built) + return; + for(i = 0;i <= 255;i++) + { + value = i; + for(j = 8;j >= 1;j--) + { + if((value & 1) != 0) + value = (value >> 1) ^ CRC32_POLYNOMIAL; + else + value = value >> 1; + } + Ccitt32Table[i] = value; + } + table_built = true; +} + +long crc32(long crc, const byte c) +{ + return(((crc >> 8) & 0x00FFFFFFul) ^ (Ccitt32Table[(crc ^ c) & 0xFF])); +} + +long CRCBuffer(long InitialCRC, void* Buffer, long BufLen) +{ + long c, i; + byte* p; + + c = InitialCRC; + p = (byte*)Buffer; + for(i = 0;i < BufLen;i++) + { + c = crc32(c, *p); + p++; + } + return(c); +} + +// ******************************* TMCCRC32Sealing *************************** + +long MCCRC32Sealing::GetID(void) +{ + return(3); +} + +void MCCRC32Sealing::Seal(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success) +{ + long i; + + BuildCRCTable(); + Success = true; + if((InDataSize == 0) || (!InData)) + { + OutData = InData; + OutDataSize = InDataSize; + } + else + { + OutDataSize = InDataSize + sizeof(long); + OutData = MCMemAlloc(OutDataSize); + i = CRCBuffer(1, InData, InDataSize); + memmove(OutData, &i, sizeof(i)); + memmove((void*)((char*)OutData + sizeof(long)), InData, InDataSize); + MCMemFree(InData); + } +} + +void MCCRC32Sealing::UnSeal(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long /*TransformID*/, bool& Success) +{ + long i; + + BuildCRCTable(); + if((InDataSize == 0) || (!InData)) + { + OutData = InData; + OutDataSize = InDataSize; + Success = true; + } + else + { + OutDataSize = InDataSize - sizeof(long); + OutData = MCMemAlloc(OutDataSize); + i = CRCBuffer(1, (void*)((char*)InData + sizeof(long)), InDataSize - sizeof(long)); + Success = *((long*)InData) == i; + memmove(OutData, (void*)((char*)InData + sizeof(long)), OutDataSize); + MCMemFree(InData); + } +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCCRC32.h b/libraries/external/eldos/pc/include/MCCRC32.h new file mode 100755 index 0000000..588e526 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCCRC32.h @@ -0,0 +1,36 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCCRC32__ +#define __MCCRC32__ + +#include "MC.h" +#include "MCBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCCRC32Sealing:public MCBaseSealing { +protected: +public: + virtual void Seal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success); + virtual void UnSeal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success); +public: + virtual long GetID(void); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCDataTree.cpp b/libraries/external/eldos/pc/include/MCDataTree.cpp new file mode 100755 index 0000000..15a0aee --- /dev/null +++ b/libraries/external/eldos/pc/include/MCDataTree.cpp @@ -0,0 +1,2892 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#include "MC.h" +#ifdef _WIN32_WCE +//#include +#endif +#include "MCDataTree.h" +#include "MCPlatforms.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +const char* cUTF8magic = "\xef\xbb\xbf"; + +// ********************************* utf8 ********************************** + +char* EncodeUTF8string(wchar_t* w) +{ + unsigned long c, count; + unsigned char* r; + if(!w) + return(NULL); + long wl = wstrlen(w); + r = (unsigned char*)malloc(wl * 3 + 4); + strcpy((char*)r, cUTF8magic); + count = 3; + for(long i = 0;i < wl;i++) + { + c = w[i]; + if(c <= 0x7f) + { + r[count] = (char)c; + count++; + } + else if(c > 0x7ff) + { + r[count] = (unsigned char)(0xe0 | (c >> 12)); // ? << + r[count+1] = (unsigned char)(0x80 | ((c >> 6) & 0x3f)); + r[count+2] = (unsigned char)(0x80 | (c & 0x3f)); + count += 3; + } + else // 0x7F < w[i] <= 0x7FF + { + r[count] = (unsigned char)(0xc0 | (c >> 6)); + r[count+1] = (unsigned char)(0x80 | (c & 0x3f)); + count += 2; + } + } + r[count] = 0; + return((char*)r); +} + +wchar_t* DecodeUTF8string(char* s) +{ + unsigned long count, wc; + unsigned char c; + wchar_t* r; + + if(strlen(s) < 4) + return(NULL); + if(_strncmp(s, cUTF8magic, strlen(cUTF8magic)) != 0) + return(NULL); + size_t ss = strlen(s); + r = (wchar_t*)malloc(ss * 3 + 2); + count = 0; + unsigned int i = 3; + while(i < ss) + { + wc = (unsigned char)s[i]; + i++; + if(wc & 0x80) + { + wc = wc & 0x3f; + if(i > ss) + break; + if(wc & 0x20) + { + c = (unsigned char)s[i]; + i++; + if((c & 0xc0) != 0x80) + { + free(r); + return(NULL); + } + if(i > ss) + break; + wc = (wc << 6) | (c & 0x3f); + } + c = (unsigned char)s[i]; + i++; + if((c & 0xcc0) != 0x80) + { + free(r); + return(NULL); + } + r[count] = (wchar_t)((wc << 6) | (c & 0x3f)); + } + else + r[count] = (wchar_t)wc; + count++; + } + r[count] = 0; + return(r); +} + +// ******************************************************************* + +void Str2Data(char* Src, void* &B, long &L) +{ + if(NULL == Src) + return; + size_t x = (strlen(Src) - 4) >> 1; + char t[3]; + unsigned char* p = (unsigned char*)malloc(x); + long r; + L = (long)x; + B = p; + Src += 4; + t[2] = 0; + while(*Src) + { + t[0] = Src[0]; + t[1] = Src[1]; + r = strtol(t, NULL, 16); + *p = (unsigned char)r; + Src += 2; + p++; + } + +} + +char* Data2Str(void* B, long L) +{ + if(NULL == B || L < 1) + return NULL; + + char* r = (char*)malloc((L << 1) + 5); + char* p; + unsigned char *s=(unsigned char*)B; + + memset(r, 0, (L << 1) + 5); + strncpy(r, "454C", 4); + p = r + 4; + for(long zl=0; zlEof()) + { + char* s = ReadTextFromStream(F); + L->Add(s); + if(s) + free(s); + } +} +*/ +void LoadListFromStream(MCStringList* L, TStream* F) +{ + if(NULL == L || NULL == F) + return; + long size = F->Size() - F->Pos() + 1; + char* s = (char*)malloc(size); + char* x = s; + char* y; + if(NULL == s) + return; + F->Read(s, size - 1); + s[size - 1] = 0; + L->DeleteAll(); + while(*x) { + y = x; + while(*x && *x != '\n' && *x != '\r') + x++; + char c = *x; + *x = 0; + L->Add(y); + *x = c; + if(*x == '\r') + x++; + if(*x == '\n') + x++; + } + free(s); +} + +// **************************************************************************** + +MCTreeItem::MCTreeItem(void) +{ + FIsKey = false; + FParent = NULL; + FValueData = new MCValueData(); + memset(FValueData, 0, sizeof(*FValueData)); + FValueName = NULL; + FChildren = new MCList(); + FChildren->CompareItems = ItemsCompare; + FChildren->setSorted(true); + FChildren->DeleteItem = &MCTreeItem::OnValueDelete; +} + +MCTreeItem* MCTreeItem::GetParent(void) +{ + return FParent; +} + +bool MCTreeItem::IsKey(void) +{ + return FIsKey; +} + +MCTreeItem::~MCTreeItem(void) +{ + this->Invalidate(); + delete FValueData; + if (NULL != FValueName) + free(FValueName); + delete FChildren; +} + +long MCTreeItem::SubCount(void) +{ + return FChildren->Length(); +} + +MCTreeItem* MCTreeItem::GetValue(char* Name) +{ + long Index; + MCTreeItem Item; + + Item.FValueName = Name; + Index = FChildren->Find(&Item); + Item.FValueName = NULL; + if (Index >= 0) + return (MCTreeItem*)(FChildren->At(Index)); + else + return NULL; + /* + char* n = UpperTrim(Name); + for(long i=1; i <= FChildren->Length(); i++) + { + char* p = UpperTrim(((MCTreeItem*)((*FChildren)[i-1]))->FValueName); + if(strcmp(p,n)==0) + { + free(p); + free(n); + return((MCTreeItem*)((*FChildren)[i-1])); + } + free(p); + } + free(n); + return NULL; + */ +} + +void MCTreeItem::Invalidate(void) +{ + if(evtString == FValueData->ValueType) + { + if(NULL != FValueData->StrValue) + free(FValueData->StrValue); + } + else + if(evtWideString == FValueData->ValueType) + { + if(NULL != FValueData->WideStrValue) + free(FValueData->WideStrValue); + } + else + if(evtMultiString == FValueData->ValueType) + delete FValueData->MStrValue; + else + if(evtMultiWideString == FValueData->ValueType) + delete FValueData->MWideStrValue; + else + if(evtBinary == FValueData->ValueType) + free(FValueData->DATAVALUE); + FValueData->ValueType = evtUnknown; +} + +void MCTreeItem::OnValueDelete(void*, void* Data) +{ + MCTreeItem* Entry = (MCTreeItem*)Data; + Entry->Invalidate(); + delete Entry; +} + +long MCTreeItem::ItemsCompare(void* Sender, void* V1, void* V2) +{ + return UpperTrimCmp(((MCTreeItem*)V1)->FValueName, + ((MCTreeItem*)V2)->FValueName); +/* + char C1, C2; + char* N1 = ((MCTreeItem*)V1)->FValueName; + char* N2 = ((MCTreeItem*)V2)->FValueName; + + while(*N1 && isspace(*N1)) + N1++; + while(*N2 && isspace(*N2)) + N2++; + while (true) + { + C1 = *N1++; + if (isspace(C1)) + C1 = 0; + else if ((C1 >= 'a') || (C1 <= 'z')) + C1 &= (~0x20); + + C2 = *N2++; + if (isspace(C2)) + C2 = 0; + else if ((C2 >= 'a') || (C2 <= 'z')) + C2 &= (~0x20); + + if (C1 > C2) + return +1; + else if (C1 < C2) + return -1; + else if (C1 == 0) + return 0; + } + return 0; +*/ +} + +void MCTreeItem::SetParent(MCTreeItem* Value) +{ + if(NULL != FParent) + FParent->FChildren->Del(this); + FParent = Value; + if(NULL != Value) + FParent->FChildren->Add(this); +} + +bool MCTreeItem::DubFrom(MCTreeItem* Peer, bool CopySubKeys, bool CopyValue) +{ + MCTreeItem* x; + MCTreeItem* z; + bool r = true; + + if(!Peer) + return(false); + FIsKey = Peer->FIsKey; + memset(FValueData, 0, sizeof(*FValueData)); + if(CopyValue) + { + FValueData->ValueType = Peer->FValueData->ValueType; + switch(FValueData->ValueType) { + case evtBoolean: + FValueData->BoolValue = Peer->FValueData->BoolValue; + break; + case evtInt: + FValueData->IntValue = Peer->FValueData->IntValue; + break; + case evtDouble: + FValueData->DoubleValue = Peer->FValueData->DoubleValue; + break; + case evtString: + if(Peer->FValueData->StrValue) + FValueData->StrValue = strdup(Peer->FValueData->StrValue); + break; + case evtMultiString: + FValueData->MStrValue = new MCStringList(); + FValueData->MStrValue->CopyOf(Peer->FValueData->MStrValue); + break; + case evtMultiWideString: + FValueData->MWideStrValue = new MCWideStringList(); + FValueData->MWideStrValue->CopyOf(Peer->FValueData->MWideStrValue); + break; + case evtBinary: +#ifndef M68K + if(Peer->FValueData->DATAVALUE) + { + FValueData->DATALENGTH = Peer->FValueData->DATALENGTH; + FValueData->DATAVALUE = malloc(FValueData->DATALENGTH); + memmove(FValueData->DATAVALUE, Peer->FValueData->DATAVALUE, FValueData->DATALENGTH); +#else + if(Peer->FValueData->DataValue) + { + FValueData->DataLength = Peer->FValueData->DataLength; + FValueData->DataValue = malloc(FValueData->DataLength); + memmove(FValueData->DataValue, Peer->FValueData->DataValue, FValueData->DataLength); +#endif + } + break; + case evtWideString: + if(Peer->FValueData->WideStrValue) + FValueData->WideStrValue = wstrdup(Peer->FValueData->WideStrValue); + break; + } + } + for(long i = 1;i <= Peer->FChildren->Length();i++) + { + z = (MCTreeItem*)((*Peer->FChildren)[i - 1]); + if(!CopySubKeys && z->FIsKey) + continue; + x = new MCTreeItem(); + x->FValueName = strdup(z->FValueName); + x->SetParent(this); + r = r && x->DubFrom(z, CopySubKeys, true); + if(!r) + break; + } + return(r); +} + +// **************************************************************************** + +MCDataTree::MCDataTree(void) +{ + WarningMessage = strdup("Automatically generated file. DO NOT MODIFY!!!"); + FRoot = new MCTreeItem(); + FDelimiter = '\\'; + FCurrentKey = Char2Str(FDelimiter, NULL); + FCurEntry = FRoot; + FLazyWrite = true; + FComment = strdup(";"); + FDivChar = '='; + FSimple = false; + FModified = false; + FBinaryMode = false; + FPath = NULL; + OnBeforeLoad = NULL; + OnAfterSave = NULL; + OnBeforeSave = NULL; + OnAfterLoad = NULL; +} + +MCDataTree::~MCDataTree(void) +{ +#ifdef USE_CPPEXCEPTIONS + try { +#else + __try { +#endif + if(FLazyWrite && FModified) + Save(); + } +#ifdef USE_CPPEXCEPTIONS + catch(...) {} +#else + __except(-1 /*EXCEPTION_CONTINUE_EXECUTION from */) {} +#endif + free(WarningMessage); + free(FComment); + free(FCurrentKey); + free(FPath); + FCurEntry = NULL; + FRoot->FChildren->DeleteAll(); + delete FRoot; +} + +bool MCDataTree::GetBinaryMode(void) +{ + return FBinaryMode; +} + +void MCDataTree::SetBinaryMode(bool Val) +{ + FBinaryMode = Val; +} + +bool MCDataTree::Modified(void) +{ + return FModified; +} + +char* MCDataTree::GetCurrentKey(void) +{ + return FCurrentKey; +} + +void MCDataTree::SetComment(const char* newValue) +{ + if(FComment) + free(FComment); + FComment = strdup(newValue); +} + +char* MCDataTree::GetComment(void) +{ + return FComment; +} + +char MCDataTree::GetDelimiter(void) +{ + return FDelimiter; +} + +void MCDataTree::SetDivChar(char NewValue) +{ + FDivChar = NewValue; +} + +char MCDataTree::GetDivChar(void) +{ + return FDivChar; +} + +bool MCDataTree::GetLazyWrite(void) +{ + return FLazyWrite; +} + +char* MCDataTree::GetPath(void) +{ + return FPath; +} + +bool MCDataTree::GetSimple(void) +{ + return FSimple; +} + +bool MCDataTree::Clear(void) +{ + FRoot->FChildren->DeleteAll(); + FCurrentKey = Char2Str(FDelimiter, FCurrentKey); + FCurEntry = FRoot; + FModified = true; + return true; +} + +bool MCDataTree::ClearKey(char* Key) +{ + MCTreeItem* E = GetValueEntry(Key, NULL); + if((NULL != E) && E->FIsKey) + { + E->FChildren->DeleteAll(); + if(0 == FLazyWrite) + Save(); + FModified=true; + return(true); + } + return false; +} + +MCTreeItem* MCDataTree::CreateValue(char* Key, char* ValueName) +{ + char* S=strdup(FCurrentKey); + MCTreeItem* E; + if(OpenKey(Key,true)) + { + E = GetValueEntry(Key, ValueName); + if(NULL == E) + { + E = new MCTreeItem(); + E->FValueName = strdup(ValueName); + E->SetParent(FCurEntry); + } + else + E->Invalidate(); + FModified=true; + E->FValueData->ValueType=evtUnknown; + free(S); + return(E); + } + OpenKey(S, false); + free(S); + return NULL; +} + +bool MCDataTree::Delete(char* Key, char* ValueName) +{ + MCTreeItem* E = GetValueEntry(Key, ValueName); + if(E && (E != FRoot)) + { + if(FCurEntry==E) + { + FCurEntry=E->GetParent(); + for(long l = (long)strlen(FCurrentKey)-1; l>=0; l--) + if(FCurrentKey[l] == FDelimiter) + { + FCurrentKey[l] = 0; + break; + } + } + E->FParent->FChildren->Del(E); + FModified = true; + return true; + } + else + return false; +} + +bool MCDataTree::EnumSubKeys(char* Key, MCStringList* Strings) +{ + char* S = strdup(FCurrentKey); + + if(OpenKey(Key, true)) + { + for(long i=1; i<=FCurEntry->FChildren->Length(); i++) + if(((MCTreeItem*)((*(FCurEntry->FChildren))[i-1]))->FIsKey) + Strings->Add(((MCTreeItem*)((*(FCurEntry->FChildren))[i-1]))->FValueName); + free(S); + return true; + } + OpenKey(S, false); + free(S); + return false; +} + +bool MCDataTree::EnumValues(char* Key, MCStringList* Strings) +{ + char* S = strdup(FCurrentKey); + if(OpenKey(Key, true)) + { + for(long i=1; i<=FCurEntry->FChildren->Length(); i++) + if(!(((MCTreeItem*)((*(FCurEntry->FChildren))[i-1]))->FIsKey)) + Strings->Add(((MCTreeItem*)((*(FCurEntry->FChildren))[i-1]))->FValueName); + free(S); + return true; + } + OpenKey(S, false); + free(S); + return false; +} + +char* MCDataTree::FullKey(char* Key) +{ + char* z; + size_t t; + if((NULL != Key) || (Key[0] != FDelimiter)) + { + if((FCurrentKey[0] == FDelimiter) && (0 == FCurrentKey[1])) + { + t = strlen(Key)+2; + z = (char*)malloc(t); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(z,t,"%c%s",FDelimiter,Key); +#else + *z = FDelimiter; + strcpy(&z[1],Key); +#endif + } + else + { + t = strlen(FCurrentKey) + strlen(Key) + 2; + z = (char*)malloc(t); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(z,t,"%s%c%s",FCurrentKey,FDelimiter,Key); +#else + strcpy(z,FCurrentKey); + long zl = strlen(z); + z[zl] = FDelimiter; + z[zl+1] = 0; + strcat(z, Key); +#endif + } + } + t = strlen(z); + if(z[t-1] == FDelimiter) + z[t-1] = 0; + return z; +} + +MCTreeItem* MCDataTree::GetValueEntry(char* Key, char* ValueName) +{ + MCTreeItem* r = NULL; + char* S = NULL; + + if ((Key != NULL) && (Key[0] != 0)) + { + S = strdup(FCurrentKey); + if(!OpenKey(Key, false)) + { + free(S); + return NULL; + } + } + if(ValueName) + r = FCurEntry->GetValue(ValueName); + else if (FCurEntry != FRoot) + r = FCurEntry; + if (NULL != S) + { + OpenKey(S,false); + free(S); + } + return r; +} + +MCValueType MCDataTree::GetValueType(char* Key,char* ValueName) +{ + MCTreeItem* E = GetValueEntry(Key, ValueName); + if(E) + return(E->FValueData->ValueType); + else + return(evtUnknown); +} + +bool MCDataTree::KeyExists(char* Key) +{ + char* S = strdup(FCurrentKey); + bool r = OpenKey(Key, false); + OpenKey(S, false); + free(S); + return r; +} + +void MCDataTree::IntLoadBinKey(TStream* F, char* LoadInto) +{ + size_t i/*,lz*/; + MCTreeItem *E, *KE = FRoot; + char* S = NULL; + char* KEN = NULL; + bool b, SkipValues = false; + MCValueType VT; + char* xLoadInto = LoadInto; + + if(!xLoadInto || !*xLoadInto) + xLoadInto = NULL; + else + { + long zl = (long)strlen(LoadInto); + xLoadInto = (char*)malloc(zl + 2); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(xLoadInto, zl + 2, "%s%c", LoadInto, FDelimiter); +#else + strcpy(xLoadInto, FCurrentKey); + xLoadInto[zl] = FDelimiter; + xLoadInto[zl + 1] = 0; +#endif + S = strdup(FCurrentKey); + OpenKey(xLoadInto, false); + KE = FCurEntry; + OpenKey(S, false); + free(S); + S = NULL; + } + + while(F->Pos() < F->Size()) + { + F->Read(&b, sizeof(b)); + if(S) + { + free(S); + S = NULL; + } + S = ReadStringFromStream(F, -1); + if(b) + { + if(S && (S[0] != FDelimiter)) + { + if(xLoadInto) + { + long t = (long)strlen(xLoadInto) + (long)strlen(S) + 1; + char* z = (char*)malloc(t); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(z, t, "%s%s", xLoadInto, S); +#else + strcpy(z, xLoadInto); + strcat(z, S); +#endif + free(S); + S = z; + } + else + S = CharNstr(FDelimiter, S); + } + if(!OpenKey(S, true)) + { + SkipValues = true; + continue; + } + if(KEN) + free(KEN); + KEN = S; + S = NULL; + KE = FCurEntry; + char* z = Char2Str(FDelimiter, NULL); + OpenKey(z, false); + free(z); + } + else + { + E = GetValueEntry(KEN, S); + F->Read(&VT, sizeof(VT)); + F->Read(&i, sizeof(i)); +#ifdef M68K + i = TurnLong(i); +#endif + if(SkipValues) + { + F->Seek((long)(F->Pos()+i)); + continue; + } + if(E) + { + if((evtMultiString == VT)^(evtMultiString == E->FValueData->ValueType)) + { + if(evtMultiString == VT) + { + E->FValueData->ValueType = evtMultiString; + E->FValueData->MStrValue = new MCStringList(); + } + else + E->Invalidate(); + } + if((evtMultiWideString == VT)^(evtMultiWideString == E->FValueData->ValueType)) + { + if(evtMultiWideString == VT) + { + E->FValueData->ValueType = evtMultiWideString; + E->FValueData->MWideStrValue = new MCWideStringList(); + } + else + E->Invalidate(); + } + } + else + { + E = new MCTreeItem(); + E->FValueName = strdup(S); + E->SetParent(KE); + } + E->FValueData->ValueType = VT; + switch(VT) { + case evtBoolean: + F->Read(&E->FValueData->BoolValue, sizeof(E->FValueData->BoolValue)); + break; + case evtDouble: + { + double d; + F->Read(&d, sizeof(d)); +#ifdef M68K + E->FValueData->DoubleValue = TurnDouble(d); +#else + E->FValueData->DoubleValue = d; +#endif + } + break; + case evtInt: + { + long d; + F->Read(&d, sizeof(d)); +#ifdef M68K + E->FValueData->IntValue = TurnLong(d); +#else + E->FValueData->IntValue = d; +#endif + } + break; + case evtString: + E->FValueData->StrValue = ReadStringFromStream(F, i); + break; + case evtMultiString: + if(!E->FValueData->MStrValue) + E->FValueData->MStrValue = new MCStringList(); + if(i > 0) + { + free(S); + while(i > 0) + { + S = ReadStringFromStream(F, -1); + E->FValueData->MStrValue->Add(S); + i -= sizeof(long) + strlen(S); + free(S); + } + S = NULL; + } + break; + case evtMultiWideString: + if(!E->FValueData->MWideStrValue) + E->FValueData->MWideStrValue = new MCWideStringList(); + if(i > 0) + { + while(i > 0) + { + wchar_t* t = ReadWideStringFromStream(F, -1); + E->FValueData->MWideStrValue->Add(t); + i -= sizeof(long) + wstrlen(t) * sizeof(wchar_t); + free(t); + } + } + break; + case evtBinary: +#ifndef M68K + E->FValueData->DATALENGTH = (long)i; +#else + E->FValueData->DataLength = i; +#endif + E->FValueData->DATAVALUE = malloc(E->FValueData->DATALENGTH); + F->Read(E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + break; + case evtWideString: + E->FValueData->WideStrValue = ReadWideStringFromStream(F, i); + break; + } // switch + } // else + } + if(KEN) + free(KEN); + if(S) + free(S); +} + +bool CmpFloatStr(double D, char* S) +{ + char a[50]; +#ifdef _SNPRINTF_ENABLED_ + _snprintf(a, 50, "%f", D); +#else + MakeDoubleAt(a, D, 15, 23); +#endif + return(0 == strcmp(S, a)); +} + +bool CmpIntStr(long L, char* S) +{ + char a[50]; +#ifdef _SNPRINTF_ENABLED_ + _snprintf(a, 50, "%ld", L); +#else + MakeLongAt(a,L,49); +#endif + return(0 == strcmp(S, a)); +} + +char* AddFloatStr(char* S, double D) +{ + char a[50]; +#ifdef _SNPRINTF_ENABLED_ + _snprintf(a, 50, "%f", D); +#else + MakeDoubleAt(a, D, 15, 23); +#endif + return(AddStr(S, a)); +} + +char* AddIntStr(char* s, long l) +{ + char a[50]; +#ifdef _SNPRINTF_ENABLED_ + _snprintf(a, 50, "%ld", l); +#else + MakeLongAt(a, l, 49); +#endif + return(AddStr(s, a)); +} + + +void MCDataTree::IntLoadKey(MCStringList* SL, long CurLine, char* LoadInto) +{ + char* S = NULL; + char* KEN = Char2Str(FDelimiter, NULL); + char* ValueName = NULL; + char* Value = NULL; + MCTreeItem *E, *KE = FRoot; + long i, j = 0, l; + bool b, eos = false, SkipValues = false; + double d; + char* xLoadInto = LoadInto; + if(!xLoadInto || !*xLoadInto) + xLoadInto = NULL; + else + { + xLoadInto = strdup(LoadInto); + long zl = (long)strlen(xLoadInto); + if(xLoadInto[zl - 1] == FDelimiter) + xLoadInto[zl - 1] = 0; + } + + while(!eos) + { + j++; + if(Value) + { + free(Value); + Value = NULL; + } + + if(ValueName) + { + free(ValueName); + ValueName = NULL; + } + + if(S) + { + free(S); + S = NULL; + } + if(SL->Length() <= CurLine) + break; + else + S = strdup((char*)(*SL)[CurLine++]); + + if((NULL == S) || (!*S) || (FComment && _strncmp(S, FComment, strlen(FComment)) == 0)) + continue; + + if('[' == S[0]) + { + SkipValues = false; + if(']' == S[strlen(S)-1]) + { + S[0] = FDelimiter; + S[strlen(S)-1] = 0; + if(xLoadInto) + { + long t = (long)strlen(xLoadInto) + (long)strlen(S) + 1; + char* z = (char*)malloc(t); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(z, t, "%s%s", xLoadInto, S); +#else + strcpy(z, xLoadInto); + strcat(z, S); +#endif + free(S); + S = z; + } + } + else + S[0] = FDelimiter; + if(strcmp(S, FCurrentKey) !=0 && !OpenKey(S,true)) + { + SkipValues = true; + continue; + } + if(KEN) + free(KEN); + KEN = S; + S = NULL; + KE = FCurEntry; + char* z = Char2Str(FDelimiter, NULL); + OpenKey(z, false); + free(z); + } + else + { + if(!SkipValues) + { + ParseLine(S, ValueName, Value, b); + if(!b) + { + if(Value) + free(Value); + Value = ValueName; + ValueName = (char*)malloc(50); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(ValueName, 50, "#%ld", j); +#else + ValueName[0] = '#'; + MakeLongAt(&ValueName[1], j, 49); +#endif + } + i =- 1; + if(']' == ValueName[strlen(ValueName)-1]) + { + l =- 1; + for(long x=0; ValueName[x]; x++) + { + if('[' == ValueName[x]) + { + l = x; + break; + } + } + long l1 =- 1; + for(long x1=l+1; ValueName[x1]; x1++) + { + if(']' == ValueName[x1]) + { + l1 = x1; + break; + } + } + + if(-1 == l || -1 == l1) + { + i =- 1; + free(ValueName); + ValueName = NULL; + } + else + { + char *z; + ValueName[l1] = 0; + i = strtol(&ValueName[l+1], &z, 0); + if(*z) + i =- 1; + ValueName[l] = 0; + } + } + + E = GetValueEntry(KEN,ValueName); + if(E) + { + if(-1 == i) + E->Invalidate(); + if(i >= 0) + { + if(evtMultiString != E->FValueData->ValueType && evtMultiWideString != E->FValueData->ValueType) + { + E->Invalidate(); + E->FValueData->ValueType = evtMultiString; + E->FValueData->MStrValue = new MCStringList(); + } + } + } + else + if(NULL == ValueName) + continue; + else + { + E = new MCTreeItem(); + E->FValueName = ValueName; + ValueName = NULL; + E->SetParent(KE); + } + + if(NULL != ValueName) + { + free(ValueName); + ValueName = NULL; + } + // MultiString + if(-1 != i) + { + bool w = (0 == _strncmp(cUTF8magic, Value, strlen(cUTF8magic))); + bool f = 0 == i; + if(f) { + if(!w && evtMultiString != E->FValueData->ValueType) + { + E->Invalidate(); + E->FValueData->ValueType = evtMultiString; + E->FValueData->MStrValue = new MCStringList(); + } + else + if(w && evtMultiWideString != E->FValueData->ValueType) + { + E->Invalidate(); + E->FValueData->ValueType = evtMultiWideString; + E->FValueData->MWideStrValue = new MCWideStringList(); + } + } + if(evtMultiString == E->FValueData->ValueType) + { + E->FValueData->MStrValue->Add(Value); + } + else + { + if(w) + E->FValueData->MWideStrValue->Add(DecodeUTF8string(Value)); + else + { + wchar_t* t = str2wstr(Value, DefaultCodePage); + E->FValueData->MWideStrValue->Add(t); + free(t); + } + } + continue; + } + // boolean + if(0 == UpperTrimCmp(Value,"FALSE") || 0 == UpperTrimCmp(Value,"TRUE")) + { + E->FValueData->ValueType = evtBoolean; + if(0 == UpperTrimCmp(Value,"TRUE")) + E->FValueData->BoolValue = true; + else + E->FValueData->BoolValue = false; + continue; + } + + // integer + char* zz; + i = strtol(Value, &zz, 0); + if(!*zz && CmpIntStr(i, Value)) + { + E->FValueData->ValueType = evtInt; + E->FValueData->IntValue = i; + continue; + } + + // float + d = strtod(Value, &zz); + if(!*zz && CmpFloatStr(d, Value)) + { + E->FValueData->ValueType = evtDouble; + E->FValueData->DoubleValue = d; + continue; + } + + // binary + if(0 == _strncmp("454C", Value, 4)) + { + E->FValueData->ValueType = evtBinary; + Str2Data(Value, E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + continue; + } + + // wide string + if(0 == _strncmp(cUTF8magic, Value, strlen(cUTF8magic))) + { + E->FValueData->ValueType = evtWideString; + E->FValueData->WideStrValue = DecodeUTF8string(Value); + continue; + } + + // string + E->FValueData->ValueType = evtString; + if(Value) + E->FValueData->StrValue = strdup(Value); + } + } + } + if(Value) + free(Value); + if(ValueName) + free(ValueName); + if(KEN) + free(KEN); + if(S) + free(S); + if(xLoadInto) + free(xLoadInto); +} + + +void MCDataTree::LoadFromStream(TStream* Stream) +{ + MCStringList* SL; + long i; + + TriggerBeforeLoadEvent(); + +#ifdef USE_CPPEXCEPTIONS + try { +#else + __try { +#endif + FRoot->FChildren->DeleteAll(); + FCurrentKey = Char2Str(FDelimiter, FCurrentKey); + FCurEntry = FRoot; + if(FBinaryMode) + IntLoadBinKey(Stream, NULL); + else + { + SL = new MCStringList(); +#ifdef USE_CPPEXCEPTIONS + try + { +#else + __try + { +#endif + LoadListFromStream(SL, Stream); + i = 0; + IntLoadKey(SL, i, NULL); + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + delete SL; + throw; + }; + delete SL; +#else + __finally + { + delete SL; + } +#endif + } + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + TriggerAfterLoadEvent(); + throw; + }; + TriggerAfterLoadEvent(); +#else + __finally + { + TriggerAfterLoadEvent(); + } +#endif +} + + +bool MCDataTree::Load(void) +{ + TStream* F = NULL; + MCStringList* SL = NULL; + bool r = false; + + TriggerBeforeLoadEvent(); +#ifndef WINCE + try + { +#else + __try + { +#endif + FRoot->FChildren->DeleteAll(); + FCurrentKey = Char2Str(FDelimiter, FCurrentKey); + FCurEntry = FRoot; + F = OpenStream(FPath, stRead); + if(F) + { + if(FBinaryMode) + { + IntLoadBinKey(F, NULL); + } + else + { + SL = new MCStringList(); +#ifdef USE_CPPEXCEPTIONS + try + { +#else + __try + { +#endif + LoadListFromStream(SL,F); + IntLoadKey(SL, 0, NULL); + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + delete SL; + throw; + } + delete SL; +#else + __finally + { + delete SL; + } +#endif + } + + } + r = true; + } +#ifndef WINCE + catch(...) + { + if(F) + delete F; + TriggerAfterLoadEvent(); + throw; + } + if(F) + delete F; + TriggerAfterLoadEvent(); +#else + __finally + { + if(F) delete F; + TriggerAfterLoadEvent(); + } +#endif + return r; +} + + +void MCDataTree::Loaded(void) +{ + if(FPath) +#ifdef USE_CPPEXCEPTIONS + try +#else + __try +#endif + { + Load(); + } +#ifdef USE_CPPEXCEPTIONS + catch(...) {} +#else + __except(-1 /*EXCEPTION_CONTINUE_EXECUTION from */) {} +#endif +} + +bool MCDataTree::MoveEntry(char* Key, char* ValueName, char* NewKey) +{ + MCTreeItem *E, *E1; + char* S = strdup(FCurrentKey); + + if(OpenKey(Key, false)) + { + E = FCurEntry->GetValue(ValueName); + if(E) + { + E1 = this->GetValueEntry(NewKey, NULL); + E->SetParent(E1); // this will remove the entry from the old parent's children list + // and add it to the new parent's children list + free(S); + return(true); + } + } + OpenKey(S, false); + free(S); + return false; +} + +bool MCDataTree::CopyToDataTree(char* Key, char* ValueName, MCDataTree* NewTree, + char *NewKey, bool CopySubKeys, bool CopyValue) +{ + MCTreeItem* E; + MCTreeItem* E1; + bool r = true; + + if((Key && strlen(Key) == 1 && Key[0] == FDelimiter) && (!ValueName || !(*ValueName))) + E = FRoot; + else + E = GetValueEntry(Key, ValueName); + if(E) + { + E1 = NewTree->CreateValue(NewKey, ValueName); + if(E1) + { + r = r && E1->DubFrom(E, CopySubKeys, CopyValue); + } + } + return(r); +} + +bool MCDataTree::CopyEntry(char* Key, char* ValueName, char *NewKey, bool CopySubKeys, + bool CopyValue) +{ + return(CopyToDataTree(Key, ValueName, this, NewKey, CopySubKeys, CopyValue)); +} + +char* HF1(char* d, char* s, char c) +{ + size_t l = strlen(s) + strlen(d) + 2; + char* x = (char*)malloc(l); x[0] = 0; + if(d) strcat(x, d); + if(s) strcat(x, s); + x[l-2] = c; + x[l-1] = 0; + if(d) + free(d); + return x; +} +#undef NVA +#ifdef PALM_CW +# define NVA +#endif +#ifdef WINCE +# define NVA +#endif +#ifdef WINFULL +# define NVA +#endif + +bool MCDataTree::OpenKey(char* aKey, bool CanCreate) +{ + MCTreeItem *CE; + long i; + char *S; + bool r; + size_t zl = aKey ? strlen(aKey) : 0; +#ifndef NVA + char Key[zl+1]; +#else + char* Key; +#endif + + if(aKey) + { +#ifdef NVA + Key = (char*)malloc(zl+1); +#endif + strcpy(Key,aKey); + //S = UpperTrim(Key); + //S1 = UpperTrim(FCurrentKey); + r = UpperTrimCmp(Key,FCurrentKey) == 0; + //free(S); + //free(S1); + } + else + { + r = true; +#ifndef NVA + strcpy(Key,FCurrentKey); +#else + Key=strdup(FCurrentKey); +#endif + } + if(!aKey || r) +#ifndef NVA + return true; +#else + { + if(Key) + free(Key); + return true; + } +#endif + // In simple mode + if(FSimple) + { + if(!Key) + return(true); + else + { + FCurEntry = FRoot; + FCurrentKey = Char2Str(FDelimiter, FCurrentKey); + if(Key[0] == FDelimiter) + { + size_t z = strlen(Key) - 1; + memmove(Key, &Key[1], z); + Key[z] = 0; + } + CE = FRoot->GetValue(Key); + if(CE) + { + FCurEntry = CE; + FCurrentKey = CharNstr(FDelimiter, Key, FCurrentKey); +#ifdef NVA + free(Key); +#endif + return true; + } + else + if(CanCreate) + { + CE = new MCTreeItem(); + CE->FIsKey = true; + CE->FValueName = strdup(Key); + CE->SetParent(FRoot); + FModified = true; + FCurEntry = CE; + FCurrentKey = CharNstr(FDelimiter, Key, FCurrentKey); +#ifdef NVA + free(Key); +#endif + return true; + } + } +#ifdef NVA + free(Key); +#endif + return false; + } + // in standard mode + if(Key) + { + if(Key[0] == FDelimiter) // starting from root + { + FCurEntry = FRoot; + FCurrentKey = Char2Str(FDelimiter, FCurrentKey); + CE = FRoot; + size_t z = strlen(Key) - 1; + memmove(Key, &Key[1], z); + Key[z] = 0; + } + else + { // starting from current + CE = FCurEntry; + if(('\\' != FCurrentKey[0]) && (0 != FCurrentKey[1])) + FCurrentKey = StrNchar(FCurrentKey, FDelimiter); + } + if(!strlen(Key)) +#ifdef NVA + { + free(Key); +#endif + return true; +#ifdef NVA + } +#endif + if(Key[strlen(Key)-1] == FDelimiter) + Key[strlen(Key)-1] = 0; + while(true) + { + i =- 1; + for(long z=0; Key[z]; z++) + if(Key[z] == FDelimiter) + { + i = z; + break; + } + if(i > -1) + { + S = (char*)malloc(i+1); + strncpy(S, Key, i); + S[i] = 0; + if(!*S) + { + free(S); +#ifdef NVA + free(Key); +#endif + return(false); + } + size_t z = strlen(Key) - i - 1; + memmove(Key, &Key[i+1], z); + Key[z] = 0; + } + else + { + i = strlen(Key); + S = (char*)malloc(i+1); + strncpy(S, Key, i); + S[i] = 0; + //S = strdup(Key); + Key[0] = 0; + } + CE = CE->GetValue(S); + if(!CE) + { + if(!CanCreate) + { + free(S); +#ifdef NVA + free(Key); +#endif + return(false); + } + FCurrentKey = HF1(FCurrentKey, S, FDelimiter); + CE = new MCTreeItem(); + CE->FIsKey = true; + CE->FValueName = S; + CE->SetParent(FCurEntry); + FModified = true; + } + else + { + if(!CE->FIsKey) + { + if(CanCreate) + { + CE->FIsKey = true; + FModified = true; + FCurrentKey = HF1(FCurrentKey, S, FDelimiter); + } + else + { +#ifdef NVA + free(Key); +#endif + free(S); + return false; + } + } + else + FCurrentKey = HF1(FCurrentKey,S,FDelimiter); + free(S); + } + FCurEntry = CE; + if(!*Key) + break; + } + if((strlen(FCurrentKey) > 1) && (FCurrentKey[strlen(FCurrentKey)-2] == FDelimiter)) + FCurrentKey[strlen(FCurrentKey)-2] = 0; + } +#ifdef NVA + if(Key) + free(Key); +#endif + return true; +} + +char* MCDataTree::OwnKey(char* Key) +{ + char* t = FullKey(Key), *t1; + long l = (long)strlen(t), l1 = -1; + for(long z=l-1; z>=0; z--) + if(t[z] == FDelimiter) + { + l1 = z; + break; + } + + if(l1 < 0) + return t; + else + { + t1 = (char*)malloc(l - l1); + strcpy(t1, &t[l1+1]); + free(t); + return(t1); + } +} + +char* MCDataTree::ParentKey(char* Key) +{ + char* t = FullKey(Key), *t1; + long l = (long)strlen(t), l1 = -1; + for(long z=(long)l-1; z>=0; z--) + if(t[z] == FDelimiter) + { + l1 = z; + break; + } + if(l1 < 0) + { + free(t); + return(Char2Str(FDelimiter, NULL)); + } + else + { + t1 = (char*)malloc(l1 + 1); + strcpy(t1, t); + free(t); + return t1; + } +} + +void MCDataTree::ParseLine(char* S, char*& Name, char*& Value, bool& HasName) +{ + bool b = false, iv = false; + size_t z = strlen(S) + 1, vx = 0, nx = 0; + char* n = (char*)malloc(z); + char* v = (char*)malloc(z); + + memset(n, 0, z); + memset(v, 0, z); + for(unsigned long i=0; iFValueData->ValueType) + { + if(BufferLen < E->FValueData->DATALENGTH) + BufferLen = E->FValueData->DATALENGTH; + else + { + memmove(Buffer, E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + BufferLen = E->FValueData->DATALENGTH; + return true; + } + } + return false; +} + +bool MCDataTree::ReadBool(char* Key, char* ValueName, bool DefValue, bool& Value) +{ + MCTreeItem* E; + + Value = DefValue; + E = GetValueEntry(Key, ValueName); + if(E) + { + if(evtBoolean == E->FValueData->ValueType) + { + Value = E->FValueData->BoolValue; + return true; + } + else + if(evtInt == E->FValueData->ValueType) + { + Value = E->FValueData->IntValue != 0; + return true; + } + } + return false; +} + +bool MCDataTree::ReadInteger(char* Key, char* ValueName, long DefValue, long& Value) +{ + MCTreeItem* E; + E = GetValueEntry(Key,ValueName); + if(E) + { + if(evtInt == E->FValueData->ValueType) + { + Value = E->FValueData->IntValue; + return true; + } + else + if(evtString == E->FValueData->ValueType) + { + char* z; + Value = strtol(E->FValueData->StrValue, &z, 0); + if(*z) + Value = DefValue; + } + else + if(evtWideString == E->FValueData->ValueType) + { + wchar_t* z; + Value = wstrtol(E->FValueData->WideStrValue, &z, 0); + if(*z) + Value = DefValue; + } + else + Value = DefValue; + } + else + Value = DefValue; + return false; +} + +bool MCDataTree::ReadMultiString(char* Key, char* ValueName, MCStringList* Strings) +{ + MCTreeItem* E; + + E = GetValueEntry(Key, ValueName); + if(E && (evtMultiString == E->FValueData->ValueType)) + { + Strings->CopyOf(E->FValueData->MStrValue); + return true; + } + return false; +} + +bool MCDataTree::ReadMultiWideString(char* Key, char* ValueName, MCWideStringList* Strings) +{ + MCTreeItem* E; + + E = GetValueEntry(Key, ValueName); + if(E && (evtMultiWideString == E->FValueData->ValueType)) + { + Strings->CopyOf(E->FValueData->MWideStrValue); + return true; + } + return false; +} + +bool MCDataTree::ReadWideString(char* Key, char* ValueName, wchar_t* DefValue, wchar_t*& Value) +{ + MCTreeItem* E; + char* tValue = NULL; + bool r = false; + + E = GetValueEntry(Key, ValueName); + if(E) + { + if(evtMultiString == E->FValueData->ValueType) + { + tValue = E->FValueData->MStrValue->Text(); + r = true; + } + else + if(evtMultiWideString == E->FValueData->ValueType) + { + Value = E->FValueData->MWideStrValue->Text(); + r = true; + } + else + if (evtString == E->FValueData->ValueType) + { + if(E->FValueData->StrValue) + tValue = strdup(E->FValueData->StrValue); + else + tValue = NULL; + r = true; + } + else + if (evtWideString == E->FValueData->ValueType) + { + if(E->FValueData->WideStrValue) + Value = wstrdup(E->FValueData->WideStrValue); + else + Value = NULL; + r = true; + } + else + if(evtInt == E->FValueData->ValueType) + { + tValue = (char*)malloc(50); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(tValue, 50, "%ld", E->FValueData->IntValue); +#else + MakeLongAt(tValue, E->FValueData->IntValue, 49); +#endif + r = true; + } + else + if(evtBoolean == E->FValueData->ValueType) + { + if(E->FValueData->BoolValue) + tValue = strdup("true"); + else + tValue = strdup("false"); + r = true; + } + else + if(evtBinary == E->FValueData->ValueType) + { + tValue = Data2Str(E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + r = true; + } + } + if(!r) { + Value = wstrdup(DefValue); + } + else { + if(tValue) { + Value = str2wstr(tValue, DefaultCodePage); + free(tValue); + } + } + return r; +} + +bool MCDataTree::ReadString(char* Key, char* ValueName, char* DefValue, char*& Value) +{ + MCTreeItem* E; + + E = GetValueEntry(Key, ValueName); + if(E) + { + if(evtMultiString == E->FValueData->ValueType) + { + Value = E->FValueData->MStrValue->Text(); + return true; + } + else + if(evtMultiWideString == E->FValueData->ValueType) + { + wchar_t* w = E->FValueData->MWideStrValue->Text(); + Value = wstr2str(w, DefaultCodePage); + if(NULL != w) + free(w); + return true; + } + else + if (evtString == E->FValueData->ValueType) + { + if(E->FValueData->StrValue) + Value = strdup(E->FValueData->StrValue); + else + Value = NULL; + return true; + } + else + if (evtWideString == E->FValueData->ValueType) + { + if(E->FValueData->WideStrValue) + Value = wstr2str(E->FValueData->WideStrValue, DefaultCodePage); + else + Value = NULL; + return true; + } + else + if(evtInt == E->FValueData->ValueType) + { + Value = (char*)malloc(50); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(Value, 50, "%ld", E->FValueData->IntValue); +#else + MakeLongAt(Value, E->FValueData->IntValue, 49); +#endif + return true; + } + else + if(evtBoolean == E->FValueData->ValueType) + { + if(E->FValueData->BoolValue) + Value = strdup("true"); + else + Value = strdup("false"); + return true; + } + else + if(evtBinary == E->FValueData->ValueType) + { + Value = Data2Str(E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + return true; + } + } + Value = strdup(DefValue); + return false; +} + +bool MCDataTree::RenameKey(char* Key, char* NewName) +{ + MCTreeItem* E = GetValueEntry(Key,NULL), *P; + if(E && (E != FRoot)) + { + if(!strchr(NewName, FDelimiter)) + return false; + + char* s = (char*)malloc(strlen(Key) + strlen(NewName) + 1); + char* z = strrchr(s, FDelimiter) + 1; + strcpy(z, NewName); + bool b = KeyExists(s); + free(s); + if(b) + return false; + P = E->FParent; + E->SetParent(NULL); + free(E->FValueName); + E->FValueName = strdup(NewName); + E->SetParent(P); + FModified = true; + return true; + } + return false; +} + +bool MCDataTree::RenameValue(char* Key,char* ValueName,char* NewName) +{ + MCTreeItem* E = GetValueEntry(Key, ValueName), *P; + if(E && (E != FRoot) && !GetValueEntry(Key, NewName)&& !strchr(NewName, FDelimiter)) + { + P = E->FParent; + E->SetParent(NULL); + free(E->FValueName); + E->FValueName=strdup(NewName); + E->SetParent(P); + FModified=true; + return true; + } + else + return false; +} + +char* BoolValues[] = {"false", "true"}; + +void MCDataTree::IntSaveBinKey(TStream* F, char* KeyName, MCTreeItem* KeyEntry) +{ + bool b = true; + long i, k; + size_t j; + MCTreeItem* E; + + F->Write(&b, sizeof(b)); + WriteStringToStream(F, KeyName, true); + for(i=1; i <= KeyEntry->FChildren->Length(); i++) + { + E = (MCTreeItem*)(*KeyEntry->FChildren)[i-1]; + if(evtUnknown == E->FValueData->ValueType) + continue; + b = false; + F->Write(&b, sizeof(b)); + WriteStringToStream(F, E->FValueName, true); + F->Write(&E->FValueData->ValueType, sizeof(E->FValueData->ValueType)); + switch(E->FValueData->ValueType) + { + case evtBoolean: + j = sizeof(bool); + break; + case evtDouble: + j = sizeof(double); + break; + case evtInt: + j = sizeof(long); + break; + case evtString: + j = E->FValueData->StrValue?strlen(E->FValueData->StrValue):0; + break; + case evtWideString: + j = E->FValueData->WideStrValue?(wstrlen(E->FValueData->WideStrValue)*sizeof(wchar_t)):0; + break; + case evtMultiString: + j = 0; + for(k = 1; k <= E->FValueData->MStrValue->Length(); k++) + { + char* s = (char*)(*E->FValueData->MStrValue)[k-1]; + j += sizeof(long) + (s?strlen(s):0); + } + break; + case evtMultiWideString: + j = 0; + for(k = 1; k <= E->FValueData->MWideStrValue->Length(); k++) + { + wchar_t* s = (wchar_t*)(*E->FValueData->MWideStrValue)[k-1]; + j += sizeof(long) + (s?wstrlen(s)*sizeof(wchar_t):0); + } + break; + case evtBinary: + j = E->FValueData->DATALENGTH; + break; + } + +#ifdef M68K + j = TurnLong(j); +#endif + F->Write(&j, sizeof(j)); + switch(E->FValueData->ValueType) + { + case evtBoolean: + F->Write(&E->FValueData->BoolValue, sizeof(E->FValueData->BoolValue)); + break; + case evtDouble: + { + double d = +#ifdef M68K + TurnDouble( +#endif + E->FValueData->DoubleValue +#ifdef M68K + ) +#endif + ; + F->Write(&d, sizeof(d)); + break; + } + case evtInt: + { +#ifdef M68K + long d = TurnLong(E->FValueData->IntValue); +#else + long d = E->FValueData->IntValue; +#endif + F->Write(&d,sizeof(d)); + break; + } + + case evtString: + WriteStringToStream(F, E->FValueData->StrValue, false); + break; + case evtWideString: + WriteWideStringToStream(F, E->FValueData->WideStrValue, false); + break; + case evtMultiString: + for(k=1; k<=E->FValueData->MStrValue->Length(); k++) + WriteStringToStream(F, (char*)(*E->FValueData->MStrValue)[k-1], true); + break; + case evtMultiWideString: + for(k=1; k<=E->FValueData->MWideStrValue->Length(); k++) + WriteWideStringToStream(F, (wchar_t*)(*E->FValueData->MWideStrValue)[k-1], true); + break; + case evtBinary: + F->Write(E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + break; + } + } // for + for(i=1; i<=KeyEntry->FChildren->Length(); i++) + { + E = (MCTreeItem*)(*KeyEntry->FChildren)[i-1]; + if(E->FIsKey) + if(KeyName) + { + size_t zl=strlen(KeyName)+strlen(E->FValueName)+2; + char* z=(char*)malloc(zl); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(z, zl, "%s%c%s", KeyName, FDelimiter, E->FValueName); +#else + strcpy(z, KeyName); + z[strlen(z)+1] = 0; + z[strlen(z)] = FDelimiter; + strcat(z, E->FValueName); +#endif + IntSaveBinKey(F,z,E); + free(z); + } + else + IntSaveBinKey(F, E->FValueName, E); + } // for +} + +void MCDataTree::IntSaveKey(TStream* F, char* KeyName, MCTreeItem* KeyEntry) +{ + long i, j; + MCTreeItem *E; + char* S; + + if(KeyName) + { + size_t zl = strlen(KeyName) + 7; + S = (char*)malloc(zl); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(S, zl, "\n[%s]\n", KeyName); +#else + strcpy(S, "\r\n["); + strcat(S, KeyName); + strcat(S, "]\r\n"); +#endif + WriteTextToStream(F, S, false); + free(S); + } + for(i=1; i<=KeyEntry->FChildren->Length(); i++) + { + E = (MCTreeItem*)(*KeyEntry->FChildren)[i-1]; + if(E->FValueName && (E->FValueName[0]!='#')) + S = StrNchar(E->FValueName, FDivChar, NULL); + else + S = NULL; + switch(E->FValueData->ValueType) + { + case evtUnknown: + break; + case evtDouble: + S = AddFloatStr(S, E->FValueData->DoubleValue); + WriteTextToStream(F, S); + break; + case evtInt: + S = AddIntStr(S, E->FValueData->IntValue); + WriteTextToStream(F, S); + break; + case evtBoolean: + if(FSimple) + S = AddIntStr(S, E->FValueData->BoolValue); + else + S = AddStr(S, BoolValues[E->FValueData->BoolValue?1:0]); + WriteTextToStream(F, S); + break; + case evtString: + S = AddStr(S, E->FValueData->StrValue); + WriteTextToStream(F, S); + break; + case evtWideString: + { + char* ts = EncodeUTF8string(E->FValueData->WideStrValue); + S = AddStr(S, ts); + if(ts) + free(ts); + WriteTextToStream(F, S); + } + break; + case evtMultiString: + if(S) + free(S); + for(j=1; j<=E->FValueData->MStrValue->Length(); j++) + { + size_t zl = strlen(E->FValueName) + + strlen((char*)(*E->FValueData->MStrValue)[j-1]) + 20; + S = (char*)malloc(zl); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(S, zl, "%s[%d]%c%s", E->FValueName, j-1, FDivChar, + (*E->FValueData->MStrValue)[j-1]); +#else + strcpy(S, E->FValueName); + strcat(S, "["); + MakeLongAt(S, j-1, 17); + strcat(S, "]"); + S[strlen(S)+1] = 0; + S[strlen(S)] = FDivChar; + strcat(S, (const char*)(*E->FValueData->MStrValue)[j-1]); +#endif + WriteTextToStream(F, S); + if(S) + { + free(S); + S = NULL; + } + } + break; + case evtMultiWideString: + if(S) + free(S); + for(j=1; j<=E->FValueData->MWideStrValue->Length(); j++) + { + char* ts = EncodeUTF8string((wchar_t*)(*E->FValueData->MWideStrValue)[j-1]); + size_t zl = strlen(E->FValueName) + + strlen(ts) + 20; + S = (char*)malloc(zl); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(S, zl, "%s[%d]%c%s", E->FValueName, j-1, FDivChar, ts); +#else + strcpy(S, E->FValueName); + strcat(S, "["); + MakeLongAt(S, j-1, 17); + strcat(S, "]"); + S[strlen(S)+1] = 0; + S[strlen(S)] = FDivChar; + strcat(S, ts); +#endif + WriteTextToStream(F, S); + if(S) + { + free(S); + S = NULL; + } + } + break; + case evtBinary: + char* d = Data2Str(E->FValueData->DATAVALUE, E->FValueData->DATALENGTH); + S = AddStr(S, d); + free(d); + WriteTextToStream(F, S); + break; + } // case + if(S) + free(S); + } // for + for(i=1; i<=KeyEntry->FChildren->Length(); i++) + { + E = (MCTreeItem*)(*KeyEntry->FChildren)[i-1]; + if(E->FIsKey) + if(KeyName) + { + size_t zl = strlen(KeyName) + strlen(E->FValueName) + 2; + char* z = (char*)malloc(zl); +#ifdef _SNPRINTF_ENABLED_ + _snprintf(z, zl, "%s%c%s", KeyName, FDelimiter, E->FValueName); +#else + strcpy(z, KeyName); + z[strlen(z)+1] = 0; + z[strlen(z)] = FDelimiter; + strcat(z, E->FValueName); +#endif + IntSaveKey(F,z,E); + free(z); + } + else + IntSaveKey(F, E->FValueName, E); + } // for +} + +void MCDataTree::SaveToStream(TStream* Stream) +{ + TriggerBeforeSaveEvent(); +#ifdef USE_CPPEXCEPTIONS + try +#else + __try +#endif + { + if(FBinaryMode) + IntSaveBinKey(Stream, NULL, FRoot); + else + { + if(WarningMessage) + { + char* s = strdup(FComment); + s = AddStr(s, WarningMessage); + WriteTextToStream(Stream, s); + free(s); + } + IntSaveKey(Stream, NULL, FRoot); + } + FModified = false; + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + TriggerAfterSaveEvent(); + throw; + } + TriggerAfterSaveEvent(); +#else + __finally + { + TriggerAfterSaveEvent(); + } +#endif +} + +bool MCDataTree::Save(void) +{ + TStream *F = NULL; + bool r = false; + + if (!FPath) + return false; + + TriggerBeforeSaveEvent(); +#ifdef USE_CPPEXCEPTIONS + try +#else + __try +#endif + { + F = OpenStream(FPath, stWrite|stCreate); + //if(!FPath) + // FPath = strdup(F->PathName()); // return(false); +#ifdef USE_CPPEXCEPTIONS + try +#else + __try +#endif + { + if(this->FBinaryMode) + IntSaveBinKey(F,NULL,FRoot); + else + { + if(WarningMessage) + { + char* s = strdup(FComment); + s = AddStr(s, WarningMessage); + WriteTextToStream(F, s); + free(s); + } + IntSaveKey(F,NULL,FRoot); + } + FModified = false; + r = true; + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + delete F; + throw; + } + delete F; +#else + __finally + { + delete F; + } +#endif + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + TriggerAfterSaveEvent(); + throw; + } + TriggerAfterSaveEvent(); +#else + __finally + { + TriggerAfterSaveEvent(); + } +#endif + return r; +} + +void MCDataTree::SetCurrentKey(char* NewValue) +{ + if (0 != strcmp(FCurrentKey, NewValue)) + OpenKey(NewValue, true); +} + +void MCDataTree::SetDelimiter(char NewValue) +{ + if(FDelimiter != NewValue) + { + FDelimiter = NewValue; + if(FCurEntry == FRoot) + FCurrentKey = Char2Str(FDelimiter, FCurrentKey); + if(!FLazyWrite) + Save(); + } +} + +void MCDataTree::SetLazyWrite(bool NewValue) +{ + if(FLazyWrite != NewValue) + FLazyWrite = NewValue; +} + +void MCDataTree::SetPath(char* NewValue) +{ + if((FPath && NewValue && 0 != strcmp(FPath, NewValue)) || NewValue) + { + if(FPath) + free(FPath); + FPath = strdup(NewValue); + } +} + +void MCDataTree::SetSimple(bool NewValue) +{ + char* RN; + char TD; + TStream* f; + + if(FSimple != NewValue) + { + RN = FPath; + FPath = NULL; + Save(); + FSimple = NewValue; + if(FSimple) + { + TD = FDelimiter; + FDelimiter = 0; + Load(); + FDelimiter = TD; + } + else + Load(); + f = OpenStream(FPath, stWrite); + f->DeleteFile(); + delete f; + free(FPath); + FPath = RN; + } +} + +void MCDataTree::SetValueType(char* Key, char* ValueName, MCValueType NewType) +{ + MCTreeItem *E = CreateValue(Key, ValueName); + if(E) + { + E->Invalidate(); + E->FValueData->ValueType = NewType; + if(evtMultiString == NewType) + E->FValueData->MStrValue = new MCStringList(); + if(evtMultiWideString == NewType) + E->FValueData->MWideStrValue = new MCWideStringList(); + } + FModified = true; +} + +long MCDataTree::SubKeysCount(char* Key) +{ + long r = -1; + MCStringList *sl = new MCStringList(); + if(EnumSubKeys(Key, sl)) + r = sl->Length(); + delete sl; + return r; +} + +bool MCDataTree::ValueExists(char* Key, char* ValueName) +{ + char* S = strdup(FCurrentKey); + MCTreeItem *E; + bool r = false; + + if(OpenKey(Key, false)) + { + E = FCurEntry->GetValue(ValueName); + if(E && !E->FIsKey) + r = true; + } + OpenKey(S, false); + free(S); + return r; +} + +long MCDataTree::ValuesCount(char* Key) +{ + long r = -1; + MCStringList *sl = new MCStringList(); + if(EnumValues(Key, sl)) + r = sl->Length(); + delete sl; + return r; +} + +bool MCDataTree::WriteBinary(char* Key, char* ValueName, void* Buffer, long BufferLen) +{ + char* S; + MCTreeItem *E; + + if(FSimple) + return false; + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtBinary; + E->FValueData->DATAVALUE = malloc(BufferLen); + memmove(E->FValueData->DATAVALUE, Buffer, BufferLen); + E->FValueData->DATALENGTH = BufferLen; + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +bool MCDataTree::WriteBool(char* Key,char* ValueName,bool Value) +{ + char* S; + MCTreeItem *E; + + if(FSimple) + return false; + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtBoolean; + E->FValueData->BoolValue = Value; + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +bool MCDataTree::WriteInteger(char* Key, char* ValueName, long Value) +{ + char* S; + MCTreeItem *E; + + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtInt; + E->FValueData->IntValue = Value; + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +bool MCDataTree::WriteMultiString(char* Key, char* ValueName, MCStringList* Strings) +{ + char* S; + MCTreeItem *E; + + if(FSimple) + return false; + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtMultiString; + E->FValueData->MStrValue = new MCStringList(); + E->FValueData->MStrValue->CopyOf(Strings); + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +bool MCDataTree::WriteMultiWideString(char* Key, char* ValueName, MCWideStringList* Strings) +{ + char* S; + MCTreeItem *E; + + if(FSimple) + return false; + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtMultiWideString; + E->FValueData->MWideStrValue = new MCWideStringList(); + E->FValueData->MWideStrValue->CopyOf(Strings); + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +bool MCDataTree::WriteString(char* Key, char* ValueName, char* Value) +{ + char* S; + MCTreeItem *E; + + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtString; + E->FValueData->StrValue = Value?strdup(Value):NULL; + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +bool MCDataTree::WriteWideString(char* Key, char* ValueName, wchar_t* Value) +{ + char* S; + MCTreeItem *E; + + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtWideString; + E->FValueData->WideStrValue = Value?wstrdup(Value):NULL; + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +void MCDataTree::TriggerBeforeSaveEvent(void) +// Triggers the OnBeforeSave event. This is a virtual method (descendants +// of this component can override it). +{ + if(OnBeforeSave) + OnBeforeSave(this); +} + +void MCDataTree::TriggerAfterLoadEvent(void) +{ + if(OnAfterLoad) + OnAfterLoad(this); +} + +void MCDataTree::TriggerBeforeLoadEvent(void) +{ + if(OnBeforeLoad) + OnBeforeLoad(this); +} + +void MCDataTree::TriggerAfterSaveEvent(void) +{ + if(OnAfterSave) + OnAfterSave(this); +} + +bool MCDataTree::ReadDouble(char* Key, char* ValueName, double DefValue, double& Value) +{ + MCTreeItem *E = GetValueEntry(Key, ValueName); + + if(E) + { + if(evtDouble == E->FValueData->ValueType) + { + Value = E->FValueData->DoubleValue; + return true; + } + else + if(evtString == E->FValueData->ValueType) + { + char* zz; + if(E->FValueData->StrValue) + { + Value = strtod(E->FValueData->StrValue, &zz); + if(*zz) + Value = DefValue; + } + else + Value = (double)NULL; + } + else + if(evtWideString == E->FValueData->ValueType) + { + if(E->FValueData->WideStrValue) + { + wchar_t* zz; + Value = wstrtod(E->FValueData->WideStrValue, &zz); + if(*zz) + Value = DefValue; + } + else + Value = (double)NULL; + } + else + if(evtInt == E->FValueData->ValueType) + Value = E->FValueData->IntValue; + else + Value = DefValue; + } + else + Value = DefValue; + return false; +} + +bool MCDataTree::WriteDouble(char* Key, char* ValueName, double Value) +{ + char* S; + MCTreeItem *E; + + S = strdup(FCurrentKey); + if(!OpenKey(Key, true)) + { + OpenKey(S, false); + free(S); + return false; + } + E = CreateValue(NULL, ValueName); + E->FValueData->ValueType = evtDouble; + E->FValueData->DoubleValue = Value; + FModified = true; + if(!FLazyWrite) + Save(); + OpenKey(S, false); + free(S); + return true; +} + +void MCDataTree::LoadKeyFromStream(TStream* F, char* KeyName) +{ + MCStringList* SL; + if(FBinaryMode) + IntLoadBinKey(F, KeyName); + else + { + SL = new MCStringList(); +#ifdef USE_CPPEXCEPTIONS + try + { +#else + __try + { +#endif + LoadListFromStream(SL,F); + IntLoadKey(SL, 0, KeyName); + } +#ifdef USE_CPPEXCEPTIONS + catch(...) + { + delete SL; + throw; + } + delete SL; +#else + __finally + { + delete SL; + } +#endif + } +} + +void MCDataTree::SaveKeyToStream(TStream* F, char* KeyName) +{ + char* S = strdup(FCurrentKey); + if(OpenKey(KeyName, false)) + { + if(FBinaryMode) + IntSaveBinKey(F, FCurEntry->FValueName, FCurEntry); + else + IntSaveKey(F, FCurEntry->FValueName, FCurEntry); + } + OpenKey(S, false); +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCDataTree.h b/libraries/external/eldos/pc/include/MCDataTree.h new file mode 100755 index 0000000..d6c4a5d --- /dev/null +++ b/libraries/external/eldos/pc/include/MCDataTree.h @@ -0,0 +1,188 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef MCDATATREE_H +#define MCDATATREE_H + +#include "MC.h" +#include "MCPlatforms.h" +#include "MCStreams.h" +#include "MCLists.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCDataTree; +class MCTreeItem; + +enum {evtUnknown=0, evtBoolean, evtInt, evtString, evtMultiString, + evtBinary, evtDouble, evtWideString, evtMultiWideString}; + +typedef unsigned char MCValueType; + +typedef struct { +public: + MCValueType ValueType; + union { + bool BoolValue; + long IntValue; + char* StrValue; + MCStringList* MStrValue; + double DoubleValue; + wchar_t* WideStrValue; + MCWideStringList* MWideStrValue; +#ifndef PALM + struct { + void* DataValue; + long DataLength; + } DataRec; +#define DATAVALUE DataRec.DataValue +#define DATALENGTH DataRec.DataLength +#else + void* DataValue; +#define DATAVALUE DataValue +#define DATALENGTH DataLength +#endif + }; +#ifdef PALM + long DataLength; +#endif +} MCValueData; + + +class MCTreeItem { +private: +friend class MCDataTree; + MCList* FChildren; + bool FIsKey; + MCTreeItem* FParent; + MCValueData* FValueData; + char* FValueName; + static DEFSECT void OnValueDelete(void* Sender, void* Data); + static DEFSECT long ItemsCompare(void* Sender,void* V1,void* V2); + DEFSECT bool DubFrom(MCTreeItem* Peer, bool CopySubKeys, bool CopyValue); + DEFSECT void SetParent(MCTreeItem* Value); +protected: + DEFSECT MCTreeItem(void); + DEFSECT MCTreeItem* GetValue(char* Name); + DEFSECT MCTreeItem* GetParent(void); +public: + DEFSECT virtual ~MCTreeItem(void); + DEFSECT void Invalidate(void); + DEFSECT bool IsKey(void); + DEFSECT long SubCount(void); +}; + +typedef void (*NotifyEvent)(void* Sender); + +class MCDataTree { +private: + bool FBinaryMode; + char* FComment; + MCTreeItem* FCurEntry; + char* FCurrentKey; + char FDelimiter; + char FDivChar; + bool FLazyWrite; + bool FModified; + char* FPath; + MCTreeItem* FRoot; + bool FSimple; + + DEFSECT void IntLoadKey(MCStringList* SL, long CurLine, char* LoadInto); + DEFSECT void IntLoadBinKey(TStream* F, char* LoadInto); + DEFSECT void IntSaveKey(TStream* F, char* KeyName, MCTreeItem* KeyEntry); + DEFSECT void IntSaveBinKey(TStream* F, char* KeyName, MCTreeItem* KeyEntry); +protected: + DEFSECT virtual MCTreeItem* GetValueEntry(char* Key, char* ValueName); + DEFSECT virtual void ParseLine(char* S, char*& Name, char*& Value, bool& HasName); + DEFSECT virtual void TriggerBeforeSaveEvent(void); + DEFSECT virtual void TriggerAfterLoadEvent(void); + DEFSECT virtual void TriggerBeforeLoadEvent(void); + DEFSECT virtual void TriggerAfterSaveEvent(void); +public: + unsigned int DefaultCodePage; + DEFSECT MCDataTree(void); + DEFSECT virtual ~MCDataTree(void); + DEFSECT bool Clear(void); + DEFSECT virtual bool ClearKey(char* Key); + DEFSECT MCTreeItem* CreateValue(char* Key, char* ValueName); + DEFSECT bool Delete(char* Key, char* ValueName); + DEFSECT bool EnumSubKeys(char* Key, MCStringList* Strings); + DEFSECT bool EnumValues(char* Key, MCStringList* Strings); + DEFSECT char* FullKey(char* Key); + DEFSECT MCValueType GetValueType(char* Key, char* ValueName); + DEFSECT bool KeyExists(char* Key); + DEFSECT void LoadFromStream(TStream* Stream); + DEFSECT void SaveToStream(TStream* Stream); + DEFSECT bool Load(void); + DEFSECT virtual void Loaded(void); + DEFSECT bool MoveEntry(char* Key, char* ValueName, char* NewKey); + DEFSECT bool CopyToDataTree(char* Key, char* ValueName, MCDataTree* NewTree, + char *NewKey, bool CopySubKeys, bool CopyValue); + DEFSECT bool CopyEntry(char* Key, char* ValueName, char *NewKey, bool CopySubKeys, bool CopyValue); + DEFSECT bool OpenKey(char* Key, bool CanCreate); + DEFSECT char* OwnKey(char* Key); + DEFSECT char* ParentKey(char* Key); + DEFSECT bool ReadBinary(char* Key, char* ValueName, void* Buffer, long& Value); + DEFSECT bool ReadBool(char* Key, char* ValueName, bool DefValue, bool& Value); + DEFSECT bool ReadDouble(char* Key, char* ValueName, double DefValue, double& Value); + DEFSECT bool ReadInteger(char* Key, char* ValueName, long DefValue, long& Value); + DEFSECT bool ReadMultiString(char* Key, char* ValueName, MCStringList* Strings); + DEFSECT bool ReadMultiWideString(char* Key, char* ValueName, MCWideStringList* Strings); + DEFSECT bool ReadString(char* Key, char* ValueName, char* DefValue, char*& Value); + DEFSECT bool ReadWideString(char* Key, char* ValueName, wchar_t* DefValue, wchar_t*& Value); + DEFSECT virtual bool RenameKey(char* Key, char* NewName); + DEFSECT virtual bool RenameValue(char* Key, char* ValueName, char* NewName); + DEFSECT bool Save(void); + DEFSECT virtual void SetValueType(char* Key, char* ValueName, MCValueType NewType); + DEFSECT long SubKeysCount(char* Key); + DEFSECT bool ValueExists(char* Key, char* ValueName); + DEFSECT long ValuesCount(char* Key); + DEFSECT bool WriteBinary(char* Key, char* ValueName, void* Buffer, long BufferLen); + DEFSECT bool WriteBool(char* Key, char* ValueName, bool Value); + DEFSECT bool WriteDouble(char* Key, char* ValueName, double Value); + DEFSECT bool WriteInteger(char* Key, char* ValueName, long Value); + DEFSECT bool WriteMultiString(char* Key, char* ValueName, MCStringList* Strings); + DEFSECT bool WriteMultiWideString(char* Key, char* ValueName, MCWideStringList* Strings); + DEFSECT bool WriteString(char* Key, char* ValueName, char* Value); + DEFSECT bool WriteWideString(char* Key, char* ValueName, wchar_t* Value); + DEFSECT void SetCurrentKey(char* NewValue); + DEFSECT char* GetCurrentKey(void); + DEFSECT void SetComment(const char* NewValue); + DEFSECT char* GetComment(void); + DEFSECT bool Modified(void); + DEFSECT bool GetBinaryMode(void); + DEFSECT void SetBinaryMode(bool); + DEFSECT void SetDelimiter(char NewValue); + DEFSECT char GetDelimiter(void); + DEFSECT void SetDivChar(char NewValue); + DEFSECT char GetDivChar(void); + DEFSECT void SetLazyWrite(bool NewValue); + DEFSECT bool GetLazyWrite(void); + DEFSECT void SetPath(LPSTR NewValue); + DEFSECT char* GetPath(void); + DEFSECT void SetSimple(bool NewValue); + DEFSECT bool GetSimple(void); + DEFSECT char* WarningMessage; + DEFSECT NotifyEvent OnBeforeLoad; + DEFSECT NotifyEvent OnAfterSave; + DEFSECT NotifyEvent OnBeforeSave; + DEFSECT NotifyEvent OnAfterLoad; + // ----- + DEFSECT void LoadKeyFromStream(TStream* F, char* KeyName); + DEFSECT void SaveKeyToStream(TStream* F, char* KeyName); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCFile.cpp b/libraries/external/eldos/pc/include/MCFile.cpp new file mode 100755 index 0000000..81a895b --- /dev/null +++ b/libraries/external/eldos/pc/include/MCFile.cpp @@ -0,0 +1,129 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCFile.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +TFile::TFile(char* Fn, int Am) +:TStream() +{ + char m[4]=" b"; + FName = strdup(Fn); + if(!Am) + Am = stRead; + if(Am & stRead) + m[0] = 'r'; + if((Am & stWrite) || (Am & stCreate)) + m[0] = 'w'; + if(Am & stCreate) + m[1] = '+'; + else + { + m[1] = 'b'; + m[2] = 0; + } + IntFile = fopen(Fn, m); + FSize = RSize = 0; +} + +TFile::~TFile(void) +{ + if(!Deleted) + Shutdown(); +} + +long TFile::Read(void* Buf, long Cnt) +{ + return((long)fread(Buf, 1, Cnt, IntFile)); +} + +long TFile::Write(const void* Buf, long Cnt) +{ + RSize = false; + return((long)fwrite(Buf, 1, Cnt, IntFile)); +} + +long TFile::Seek(long Cnt) +{ + fseek(IntFile, Cnt, SEEK_SET); + return this->Pos(); +} + +long TFile::Pos(void) +{ + return(ftell(IntFile)); +} + +long TFile::Size(void) +{ + if(!RSize) + { + long cp = this->Pos(); + fseek(IntFile, 0, SEEK_END); + FSize = this->Pos(); + this->Seek(cp); + RSize = true; + } + return(FSize); +} + +bool TFile::Eof(void) +{ + return(feof(IntFile) != 0); +} + +LPSTR TFile::PathName(void) +{ + return(strdup(FName)); +} + +void TFile::DeleteFile(void) +{ + char* fn = strdup(FName); + TStream::DeleteFile(); +#ifndef _WIN32_WCE + remove(fn); +#else +// !!! troubles to delete file +#endif + free(fn); +} + +void TFile::Shutdown(void) +{ + fclose(IntFile); + free(FName); +} + +TStream* OpenFile(char* File, int m) +{ + if(!File) + return NULL; + TFile* f = new TFile(File, m); + if(!f->IntFile) + { + delete f; + f = NULL; + } + return f; +} + +void InitFileProc(void) +{ + OpenStream = /*&*/OpenFile; +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCFile.h b/libraries/external/eldos/pc/include/MCFile.h new file mode 100755 index 0000000..b6efad1 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCFile.h @@ -0,0 +1,55 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef MCFILE_H +#define MCFILE_H + +#include "MC.h" +#include "MCStreams.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif +class TFile:public TStream { +#ifndef PALM + long FSize; + bool RSize; +#endif +protected: +#ifndef PALM + FILE* IntFile; + char* FName; +#else + long FSize; + long FPos; + char* File; +#endif + DEFSECT virtual void Shutdown(void); + DEFSECT friend TStream* OpenFile(char* File, int m); +public: + TFile(char*, int); + DEFSECT virtual ~TFile(void); + + DEFSECT virtual long Read(void* Buf, long Cnt); + DEFSECT virtual long Write(const void* Buf, long Cnt); + DEFSECT virtual long Seek(long Cnt); + DEFSECT virtual long Pos(void); + DEFSECT virtual long Size(void); + DEFSECT virtual bool Eof(void); + DEFSECT virtual char* PathName(void); + DEFSECT virtual void DeleteFile(void); +}; + +DEFSECT void InitFileProc(void); + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCHTTP.cpp b/libraries/external/eldos/pc/include/MCHTTP.cpp new file mode 100755 index 0000000..253329c --- /dev/null +++ b/libraries/external/eldos/pc/include/MCHTTP.cpp @@ -0,0 +1,1053 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCHTTP.h" +#ifdef _WIN32 +//# include +//# include +#endif +#define USE_HTTP11 + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +#ifdef __GNUC__ +inline unsigned long max(unsigned long a, unsigned long b) +{ + return a > b ? a : b; +} +#endif + +// ***************************** MCHttpTransport **************************** + +MCHttpTransport::MCHttpTransport() +{ + FDefaultTransportName = "HTTP"; + FUseProxy = false; + FProxyAddress = NULL; + FProxyPort = 3128; + FReqTime = 1000; + memset(&FProxyIP, 0, sizeof(FProxyIP)); +} + +MCHttpTransport::~MCHttpTransport() +{ + MCMemFree(FProxyAddress); +} + + +MCInetTransportJob* MCHttpTransport::CreateTransportJob(void) +{ + MCHttpTransportJob* trans = new MCHttpTransportJob(); //memory leak + trans->AdjustBufferSize(FIncomingBufferSize, FOutgoingBufferSize); + trans->AdjustSpeedLimits(FIncomingSpeedLimit, FOutgoingSpeedLimit); + return trans; +} + +MCInetConnectionEntry* MCHttpTransport::CreateConnectionEntry(void) +{ + MCHttpConnectionEntry* Ent = new MCHttpConnectionEntry(); + Ent->setUseProxy(this->getUseProxy()); + Ent->setProxyIP(this->FProxyIP); + return Ent; +} + +void MCHttpTransport::NotifyJob(MCInetTransportJob* Job, bool MessageFlag) +{ + MCHttpTransportJob* Thr = (MCHttpTransportJob*)Job; + if (NULL != Thr) + { + if(!(Thr->getIsSending())) + { + KickEntrySocket(Thr->getEntry(), MessageFlag); + } + } +} + +bool MCHttpTransport::NeedLiveConnectionForDelivery(void) +{ + return false; +} + +#ifndef _WIN32 +# define PROXY_ADDR FProxyIP.sin_addr.s_addr +#else +# define PROXY_ADDR FProxyIP.sin_addr.S_un.S_addr +#endif + +void MCHttpTransport::DoSetActive(void) +{ + if(!FMessenger) + return; + + MCInetTransport::DoSetActive(); + if(getActive()) + { + //configure proxy + if (getUseProxy() == true) + { + memset(&FProxyIP, 0, sizeof(FProxyIP)); + PROXY_ADDR = inet_addr(FProxyAddress); + if (INADDR_NONE == PROXY_ADDR) + { + hostent* host = gethostbyname(FProxyAddress); + if (NULL != host) + PROXY_ADDR = inet_addr(host->h_addr_list[0]); + else + RETURN_EXCEPT; //todo - return the MCError_InvalidAddress + } + FProxyIP.sin_family = AF_INET; + FProxyIP.sin_port = htons(FProxyPort); + /* + for (int i=0; iLength(); i++) + { + FConnections->Length(); + MCHttpConnectionEntry* CEntry = (MCHttpConnectionEntry*)((*FConnections)[i]); + if (CEntry->getSocket()->getDirection() == isdOutgoing) + CEntry->setProxyIP(FProxyIP); + }*/ + } + else + { + memset(&FProxyIP, 0, sizeof(FProxyIP)); + } + } +} + +void MCHttpTransport::setProxyAddress(const char* ProxyAddr) +{ + if (FProxyAddress) + free(FProxyAddress); + FProxyAddress = strdup(ProxyAddr); +} + +const char* MCHttpTransport::getProxyAddress(void) +{ + return FProxyAddress; +} + +void MCHttpTransport::setProxyPort(unsigned short ProxyPort) +{ + FProxyPort = ProxyPort; +} + +unsigned short MCHttpTransport::getProxyPort(void) +{ + return FProxyPort; +} + +void MCHttpTransport::setUseProxy(bool UseProxy) +{ + FUseProxy = UseProxy; +} + +bool MCHttpTransport::getUseProxy(void) +{ + return FUseProxy; +} + +void MCHttpTransport::setRequestTime(int ReqTime) +{ + FReqTime = ReqTime; +} + +int MCHttpTransport::getRequestTime(void) +{ + return FReqTime; +} + +// ************************** MCHttpTransportJob ************************* + +MCHttpTransportJob::MCHttpTransportJob(void) +{ + FAlreadyReceived = -1; + FHeaderRead = 0; + FReadingState = 0; + FWasRead = 0; + FChunked = false; + + FHeaderSize = 0; + FHeaderSent = 0; + FSendingStage = ssHeader; + FServerRequestTime = 1000; + + memset(FIncomingBuffer, 0, FIncomingBufferSize); +} + +MCHttpTransportJob::~MCHttpTransportJob(void) +{ +} + +bool MCHttpTransportJob::IsMessageRead(void) +{ + if (NULL != FEntry) + return ((MCHttpConnectionEntry*)FEntry)->getMessageRead(); + else + return false; +} + +void MCHttpTransportJob::SetTransporterAddress(MCInetConnectionEntry* Ent, MCSocket* Transp) +{ + MCHttpConnectionEntry* FEntry = (MCHttpConnectionEntry*)Ent; + + if (FEntry->getUseProxy() == true) + { + Transp->setRemoteAddress(inet_ntoa(FEntry->getProxyIP().sin_addr)); + Transp->setRemotePort(ntohs(FEntry->getProxyIP().sin_port)); + } + else + { + long ClientID = 0; long ConnID = 0; int Port = 0; char* IP = NULL; + if (ParseRemoteAddr(FEntry->getRemoteAddress(), &ClientID, &ConnID, &IP, &Port) == true) + { + Transp->setRemoteAddress(IP); + Transp->setRemotePort(Port); + } + MCMemFree(IP); IP = NULL; + } + +} + +bool MCHttpTransportJob::InitializeConnection() +{ + if (MCInetTransportJob::InitializeConnection()) + { + FSendingStage = ssHeader; + FLastRequestTime = GetTickCount(); + FServerRequestTime = 1000; + return true; + } + else + return false; +} + +bool MCHttpTransportJob::PostConnectionStep(void) +{ + FAlreadyReceived = -1; + FHeaderRead = 0; + memset(FIncomingBuffer, 0, FIncomingBufferSize); + return true; +} + + +/* +ReceiveData reads the data from the socket and adds them to the incoming +packet (optionally creating this packet). +ReceiveData returns true if the socket can be read or false if the socket +was closed. +*/ + +#ifndef _WIN32 +#include +#ifndef QNX +void _strupr(char* s) +{ + for (int i=0; i HeaderEnd) || (NULL == SpaceP)) + return false; + if (SpaceP - HeaderStart > 126) + return false; + if (HeaderEnd - SpaceP > 126) + return false; + memmove(HeaderName, HeaderStart, SpaceP - HeaderStart); + HeaderName[SpaceP - HeaderStart] = 0; +#if !defined(_WIN32_WCE) && defined(_WIN32) + strupr(HeaderName); +#else + _strupr(HeaderName); +#endif + memmove(HeaderValue, SpaceP + 1, HeaderEnd - SpaceP - 1); + HeaderValue[HeaderEnd - SpaceP - 1] = 0; + TRY_BLOCK + { + if (strcmp(HeaderName, "POST") == 0) + {//get the POST params + char* SpaceP2 = strchr(HeaderValue, ' '); + if (NULL != SpaceP2) + strncpy(URL, HeaderValue, SpaceP2-HeaderValue); + else + URL[0] = 0; + POST = true; + } + else + if (strcmp(HeaderName, "CONTENT-LENGTH:") == 0) + {//get the MsgConnect length + if (0 != HeaderValue[0]) + ContentLength = atoi(HeaderValue); + else + ContentLength = 0; + } + else + if (strcmp(HeaderName, "TRANSFER-ENCODING:") == 0) + { + if (strlen(HeaderValue) >= 7) + { +#if !defined(_WIN32_WCE) && defined(_WIN32) + strupr(HeaderValue); +#else + _strupr(HeaderValue); +#endif + Chunked = strncmp(HeaderValue, "CHUNKED", 7) == 0; + } + } + else + if (strcmp(HeaderName, "HOST:") == 0) + strcpy(Host, HeaderValue); + else + if ((strcmp(HeaderName, "HTTP/1.1") == 0) || + (strcmp(HeaderName, "HTTP/1.0") == 0)) + {//get the HTTP code + strncpy(TempValue, HeaderValue, 3); + HttpCode = atoi(TempValue); + } + else + if (strcmp(HeaderName, "X-REQUEST-TIME:") == 0) + {//get the MsgConnect length + if (0 != HeaderValue[0]) + FServerRequestTime = atoi(HeaderValue); + else + FServerRequestTime = 1000; + } + + HeaderStart = HeaderEnd + 2; + HeaderEnd = strstr(HeaderStart, "\r\n"); + } + CATCH_EVERY + { + return false; + } + } + return true; +} + +static char CRLFCRLF[] = "\r\n\r\n"; +static char CRLF[] = "\r\n"; + +#ifndef USE_HTTP11 +bool MCHttpTransportJob::ReceiveData(bool& tooBigPacket) +{ + long Received; + long ToRecv; + tooBigPacket = false; + + const char* TS1 = NULL; + char Host[128], URL[128]; + int ContentLength = 0, HttpLength = 0, HttpCode = 0; + bool POST = false, Chunked = false; + + bool res = false; + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if(!getIsReceiving()) + { + if (0 == FHeaderRead) + memset(FIncomingBuffer, 0, FIncomingBufferSize); + + if(FTransporter->Receive(&FIncomingBuffer[FHeaderRead], FIncomingBufferSize, Received) == 0) + { + if (Received > 0) + { + TS1 = strstr((const char*)&FIncomingBuffer[0], CRLFCRLF); + if (NULL != TS1) + {//HTTP header is read + //return the unnecessary data + long remains = FHeaderRead + Received - 4 - (TS1 - (char*)&FIncomingBuffer[0]); + if (0 != remains) + ((MCSocket*)FTransporter)->ReturnData((void*)(TS1+4), remains); + FHeaderRead += Received; FHeaderRead -= remains; + + if (false == ParseHeaders((const char*)&FIncomingBuffer[0], TS1 - (char*)FIncomingBuffer + 2, URL, Host, HttpCode, POST, ContentLength, Chunked)) + { + res = false; + FEntry->setMsgSize(0); + memset(FIncomingBuffer, 0, FIncomingBufferSize); + RETURN_EXCEPT; + } + + + if ((false == POST) && (200 != HttpCode)) + {//it is failed reply from HTTP server + res = false; + FAlreadyReceived = -1; FHeaderRead = 0; + memset(FIncomingBuffer, 0, FIncomingBufferSize); + RETURN_EXCEPT; + } + + if (Chunked) + { + //now we do not support this + res = false; + FAlreadyReceived = -1; FHeaderRead = 0; + memset(FIncomingBuffer, 0, FIncomingBufferSize); + RETURN_EXCEPT; + } + else + { + FEntry->setMsgSize(ContentLength); + if (FOwner->getMaxMsgSize() != 0 && ContentLength > FOwner->getMaxMsgSize()) + { + FEntry->setMsgSize(0); + tooBigPacket = true; + //FTransporter->Close(false); + res = false; + } + } + + if (false == tooBigPacket) + { + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + FEntry->setIncomingStream(new MCMemStream()); + setIsReceiving(true); + FHeaderRead = 0; + } + } + else + FHeaderRead += Received; + res = tooBigPacket ? false : true; + } + else + return false; + } + else + { + //OutputDebugString("MCHTTPTransport::ReceiveData:: Socket error occured.\n"); + FHeaderRead = 0; + res = false; + FAlreadyReceived = -1; + return res; + } + } + else + { + FAlreadyReceived = -1; FHeaderRead = 0; + ToRecv = FEntry->getMsgSize() - FEntry->getIncomingStream()->Len(); + if (ToRecv > (long) FIncomingBufferSize) + ToRecv = (long) FIncomingBufferSize; + + if (FTransporter->Receive(FIncomingBuffer, ToRecv, Received) == 0) + { + FEntry->getIncomingStream()->Write(FIncomingBuffer, Received); + res = true; + } + } + } + CATCH_EVERY + {} + FEntry->getCS()->Leave(); + } + CATCH_EVERY + {} + return res; +} + +#else + + +const int ReadingHeader = 0; +const int ReadingChunkHeader = 1; +const int ReadingChunkBody = 2; +const int ReadingChunkLimiter = 3; +const int ReadingBody = 4; +const int ReadingEntityHeaders = 5; + +inline bool isHEX(char x) +{ + if (x >= '0' && x <= '9') + return true; + if (x >= 'a' && x <= 'f') + return true; + if (x >= 'A' && x <= 'F') + return true; + return false; +} + +inline int HEX2Bits(char x) +{ + if (x >= '0' && x <= '9') + return x - (int)'0'; + if (x >= 'a' && x <= 'f') + return x - (int)'a' + 10; + if (x >= 'A' && x <= 'F') + return x - (int)'A' + 10; + RETURN_EXCEPT; + return 0;//for dummy compilers +} + +static int findChunkedSize(const char* s, int maxSize) +{ + if (0 == maxSize) + return 0; + int i = 0; + char buf[32]; + while (isHEX(s[i]) && i < maxSize && i < 31) + i++; + int len = i; + strncpy(buf, s, len); + int res = 0; + for (i=0; igetCS()->Enter(); + TRY_BLOCK + { + do + { + isData = false; + switch (FReadingState) + { + case ReadingHeader: + if (FTransporter->Receive(&FIncomingBuffer[FWasRead], 512, Received) == 0) + { + if (Received > 0) + {//we've got data + + FblInSessionTransferred += Received; + FblInMsgTransferred += Received; + FblInSecTransferred += Received; + + FEntry->setMsgSize(0); setIsReceiving(true); + ((MCHttpConnectionEntry*)FEntry)->setMessageRead(false); + //do we received all header? + TS1 = strstr((char *) &FIncomingBuffer[0], CRLFCRLF); + if (NULL != TS1) + {//yes! HTTP header is here + + //return the unnecessary data to stream + remains = FWasRead + Received - 4 - + (TS1 - (char*)&FIncomingBuffer[0]); + if (0 != remains) + ((MCSocket*)FTransporter)->ReturnData(TS1+4, remains); + FWasRead += Received; FWasRead -= remains; + + //ok, ParseHeaders + if (false == ParseHeaders((const char*)&FIncomingBuffer[0], TS1 - (char*)FIncomingBuffer + 2, URL, Host, HttpCode, POST, ContentLength, Chunked)) + RETURN_EXCEPT; + + if ((false == POST) && (200 != HttpCode)) + RETURN_EXCEPT; + + FChunked = Chunked; + FWasRead = 0; + memset(FIncomingBuffer, 0, FIncomingBufferSize); + + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + FEntry->setIncomingStream(new MCMemStream()); + if (false == FChunked) + { + FEntry->setMsgSize(ContentLength); + FReadingState = ReadingBody; + } + else + { + FReadingState = ReadingChunkHeader; + FReadMsgSize = 0; + } + } + else + {//HTTP header is not read now + FWasRead += Received; + } + memset(FIncomingBuffer+FWasRead, 0, FIncomingBufferSize-FWasRead); + } + else + {//connection was close by remote side + res = false; + } + } + else + res = false; + + break; + + case ReadingChunkHeader: + //read chunk-size, chunk-ext (if any) and CRLF + //maybe we already read this shit? + if (FTransporter->Receive(&FIncomingBuffer[FWasRead], 512, Received) != 0) + res = false; + else + if (0 == Received) + res = false; + + if (res) + {// There is fresh data :) + + //is it full chunk header? + TS1 = strstr((char *)&FIncomingBuffer[0], CRLF); + + if (NULL != TS1) + {//yes! chunk header is here! + + //return the unnecessary data to stream + remains = FWasRead + Received - 2 - (TS1 - (char*)&FIncomingBuffer[0]); + if (0 != remains) + ((MCStdSocket*)FTransporter)->ReturnData(TS1+2, remains); + + Received -= remains; + + //handle chunk size + int chunkSizeLen = (char*)TS1 - (char*)FIncomingBuffer; + FChunkSize = findChunkedSize((const char*)FIncomingBuffer, chunkSizeLen); + FChunkRead = 0; + FReadMsgSize += FChunkSize; + + FWasRead = 0; + + if (0 != FChunkSize) + FReadingState = ReadingChunkBody; + else + FReadingState = ReadingEntityHeaders; + memset(FIncomingBuffer, 0, FIncomingBufferSize); + } + else + { + FWasRead += Received; + } + } + break; + + case ReadingChunkBody: + if (FTransporter->Receive(FIncomingBuffer, FIncomingBufferSize, Received) != 0) + res = false; + else + if (0 == Received) + res = false; + + //read FChunkSize + if (res) + { + long write2Stream = 0; + if (FChunkSize != FChunkRead) + write2Stream = Received > FChunkSize - FChunkRead ? FChunkSize - FChunkRead : Received; + if (0 != write2Stream) + { + FEntry->getIncomingStream()->Write(FIncomingBuffer, write2Stream); + FChunkRead += write2Stream; + if (FChunkRead == FChunkSize) + { + FReadingState = ReadingChunkLimiter; + FWasRead = 0; + FChunkRead = 0; FChunkSize = 0; + } + } + remains = Received - write2Stream; + if (0 != remains) + ((MCStdSocket*)FTransporter)->ReturnData(FIncomingBuffer+write2Stream, remains); + memset(FIncomingBuffer, 0, FIncomingBufferSize); + } + break; + case ReadingChunkLimiter: + if (FTransporter->Receive(&FIncomingBuffer[FWasRead], 512, Received) != 0) + res = false; + else + if (0 == Received) + res = false; + if (Received >= 2) + { + if (FIncomingBuffer[0] == 0xD && FIncomingBuffer[1] == 0xA) + { + FReadingState = ReadingChunkHeader; FWasRead = 0; + ((MCStdSocket*)FTransporter)->ReturnData(FIncomingBuffer+2, Received-2); + } + else + THROW_ERROR(MCError_InvalidHTTP); + } + else + FWasRead += Received; + break; + + + case ReadingEntityHeaders: + if (FTransporter->Receive(&FIncomingBuffer[FWasRead], 512, Received) != 0) + res = false; + else + if (0 == Received) + res = false; + + if (res) + { + TS1 = strstr((char*)&FIncomingBuffer[0], CRLFCRLF); + if (NULL != TS1) + {//entity headers are read. Just ignore them now + ((MCHttpConnectionEntry*)FEntry)->setMessageRead(true); + FEntry->setMsgSize(FReadMsgSize); + FReadingState = ReadingHeader; + remains = FWasRead + Received - 4 - (TS1 - (char*)&FIncomingBuffer[0]); + if (0 != remains) + ((MCStdSocket*)FTransporter)->ReturnData(TS1+4, remains); + } + else + { + //maybe we read empty line? + TS1 = strstr((char*)&FIncomingBuffer[0], CRLF); + if ((char*)TS1 == (char*)FIncomingBuffer) + {//entity headers are read. Just ignore them now + ((MCHttpConnectionEntry*)FEntry)->setMessageRead(true); + FEntry->setMsgSize(FReadMsgSize); + + FReadingState = ReadingHeader; + remains = Received - 2 - (TS1 - (char*)&FIncomingBuffer[0]); + if (0 != remains) + ((MCStdSocket*)FTransporter)->ReturnData(TS1+2, remains); + + } + else + FWasRead += Received; + } + } + break; + + case ReadingBody: + toRead = FEntry->getMsgSize() - FEntry->getIncomingStream()->Pos(); + + if(toRead > (long) FblToRecv) + toRead = FblToRecv; + + if (FTransporter->Receive(FIncomingBuffer, toRead, Received) == 0) + { + if (Received > 0) + { + FblInSessionTransferred += Received; + FblInMsgTransferred += Received; + FblInSecTransferred += Received; + + FEntry->getIncomingStream()->Write(FIncomingBuffer, Received); + if (FEntry->getMsgSize() == FEntry->getIncomingStream()->Pos()) + {//message is read + ((MCHttpConnectionEntry*)FEntry)->setMessageRead(true); + FReadingState = ReadingHeader; + FWasRead = 0; + } + } + else + res = false; + } + else + res = false; + break; + } + } + while(isData); + } + FINALLY + ( + FEntry->getCS()->Leave(); + ) + return res; +} + +#endif + +void MCHttpTransportJob::UpdateConnectionContext(void) +{ + if (getEntry()->getInfo()) + ((MCHttpConnectionEntry*)getEntry())->setURL(getEntry()->getInfo()->URL); +} + +const char HTTPPostFormatString1[] = "POST %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: MsgConnect\r\n"; +const char HTTPPostFormatString2[] = "Content-Length: %d\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nContent-Type: application/octet-stream\r\n\r\n"; + +int MCHttpTransportJob::ClientBuildHTTPHeader(char* Buffer, int MaxBufferLen, int DataLen) +{ + int l = 0; + char URL[256], *IP = NULL; + long ClientID = 0; long ConnID = 0; int Port = 0; + ParseRemoteAddr(FEntry->getRemoteAddress(), &ClientID, &ConnID, &IP, &Port); + MCHttpConnectionEntry* httpEntry = (MCHttpConnectionEntry*)FEntry; + if (httpEntry->getURL() != NULL) + sprintf(URL, "http://%s:%d%s", IP, Port, httpEntry->getURL()); + else + sprintf(URL, "http://%s:%d/", IP, Port); + memset(Buffer, 0, MaxBufferLen); l = 0; + sprintf(Buffer, HTTPPostFormatString1, URL, IP); l = strlen(Buffer); + sprintf(Buffer+l, HTTPPostFormatString2, ((MCHttpConnectionEntry*)FEntry)->getContentLength()); l = strlen(Buffer); + MCMemFree(IP); + return l; +} + +const char HTTPReplyFormatString1[] = "HTTP/1.1 200 OK\r\n"; +const char HTTPReplyFormatString2[] = "Content-Type: application/octet-stream\r\n"; +const char HTTPReplyFormatString5[] = "Content-Length: %d\r\nX-Request-Time: %d\r\n\r\n"; + +int MCHttpTransportJob::ServerBuildHTTPHeader(char* Buffer, int MaxBufferLen, MCHttpConnectionEntry* HttpEnt) +{ + memset(Buffer, 0, MaxBufferLen); int l = 0; + sprintf(Buffer, HTTPReplyFormatString1); l = strlen(Buffer); + sprintf(Buffer+l, HTTPReplyFormatString2); l = strlen(Buffer); + sprintf(Buffer+l, HTTPReplyFormatString5, HttpEnt->getContentLength(), ((MCHttpTransport*)FOwner)->getRequestTime()); + l = strlen(Buffer); + return l; +} + +/* +Writes data to the socket. Returns true if the operation was successful and +false if the socket returned an error. +*/ + +bool MCHttpTransportJob::SendData(void) +{ + long ToSend, Sent; + bool r = false; + + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if(getIsSending()) + { + + TRY_BLOCK + { + if (ssHeader == FSendingStage) + { + if (0 == FHeaderSent) + {//build header + ((MCHttpConnectionEntry*)FEntry)->setContentLength(FEntry->getOutgoingStream()->Len()); + MCMessageInfo* info = FEntry->getInfo(); + if (info->OldState == imsDispatching || + info->OldState == imsEmptyRequest) //is it request? + FHeaderSize = ClientBuildHTTPHeader((char*)&FOutgoingBuffer[0], FOutgoingBufferSize, FEntry->getOutgoingStream()->Len()); + else //else it is reply... + FHeaderSize = ServerBuildHTTPHeader((char*)&FOutgoingBuffer[0], FOutgoingBufferSize, ((MCHttpConnectionEntry*)FEntry)); + } + if (FTransporter->Send(&FOutgoingBuffer[FHeaderSent], FHeaderSize - FHeaderSent, Sent) == 0) + { + FblOutSessionTransferred += Sent; + FblOutMsgTransferred += Sent; + FblOutSecTransferred += Sent; + + FHeaderSent += Sent; + if (FHeaderSent == FHeaderSize) + {//all header is sent + FHeaderSent = 0; FHeaderSize = 0; + FSendingStage = ssBody; + } + r = true; + } + else + { + //OutputDebugString("MCHTTPTransport::SendData:: Socket error occured.\n"); + r = false; + } + } + else + {//send message's body + if(FEntry->getOutgoingStream()->Len() - FEntry->getOutgoingStream()->Pos() < (long)FblToSend) + ToSend = FEntry->getOutgoingStream()->Len() - FEntry->getOutgoingStream()->Pos(); + else + ToSend = FblToSend; + FEntry->getOutgoingStream()->Read(FOutgoingBuffer, ToSend); + long res = FTransporter->Send(FOutgoingBuffer, ToSend, Sent); + if (res == 0) + { + FblOutSessionTransferred += Sent; + FblOutMsgTransferred += Sent; + FblOutSecTransferred += Sent; + + FEntry->getOutgoingStream()->SetPos(FEntry->getOutgoingStream()->Pos() - ToSend + Sent); + if (FEntry->getOutgoingStream()->Pos() == FEntry->getOutgoingStream()->Len()) + FSendingStage = ssHeader; + r = true; + } + else +#ifdef _WIN32 + if (res == WSAEWOULDBLOCK) +#else + if (res == EWOULDBLOCK) +#endif + r = true; + else + r = false; + } + } FINALLY ( + ; + ) + } + } + CATCH_EVERY + { + r = false; + } + FEntry->getCS()->Leave(); + return r; +} + +void MCHttpTransportJob::ChangeLastSendTime(MCMessageState state) +{ + if (state != imsEmptyRequest && state != imsEmptyReply) + { + FActivityTime = GetTickCount(); + FLastMsgSendTime = FActivityTime; + } + else + { + FActivityTime = max(FLastMsgRecvTime, FLastMsgSendTime); + } +} + +void MCHttpTransportJob::ChangeLastRecvTime(MCMessageState state) +{ + if (state != imsEmptyRequest && state != imsEmptyReply) + { + FActivityTime = GetTickCount(); + FLastMsgRecvTime = FActivityTime; + } + else + { + FActivityTime = max(FLastMsgRecvTime, FLastMsgSendTime); + } +} + +bool MCHttpTransportJob::IsRequestNeeded() +{ + unsigned long CurrentTime; + long LR2; + long LastRequest; + + if (FTransporter->getDirection() == isdIncoming /*|| getIsSending()*/) + return false; + + CurrentTime = GetTickCount(); + if (CurrentTime > FLastRequestTime) + LastRequest = CurrentTime - FLastRequestTime; + else + LastRequest = (0xFFFFFFFF - FLastRequestTime) + CurrentTime; + + if (CurrentTime > FLastMsgRecvTime) + LR2 = CurrentTime - FLastMsgRecvTime; + else + LR2 = (0xFFFFFFFF - FLastMsgRecvTime) + CurrentTime; + + if (LR2 < LastRequest) + LastRequest = LR2; + + if (LastRequest > FServerRequestTime) + { + FLastRequestTime = CurrentTime; + return true; + } + else + return false; +} + +// ************************** MCHttpConnectionEntry ************************* + +MCHttpConnectionEntry::MCHttpConnectionEntry(void) +{ + FUseProxy = false; + FURL = NULL; + FMessageRead = false; + memset(&FProxyIP, 0, sizeof(FProxyIP)); +} + +MCHttpConnectionEntry::~MCHttpConnectionEntry(void) +{ +} + +void MCHttpConnectionEntry::Reset(void) +{ + FCS->Enter(); + MCInetConnectionEntry::Reset(); + MCMemFree(FURL); FURL = NULL; + FUseProxy = false; + + memset(&FProxyIP, 0, sizeof(FProxyIP)); + FMessageRead = false; + FCS->Leave(); +} + +void MCHttpConnectionEntry::setUseProxy(bool Value) +{ + FUseProxy = Value; +} + +bool MCHttpConnectionEntry::getUseProxy(void) +{ + return FUseProxy; +} + +void MCHttpConnectionEntry::setProxyIP(sockaddr_in Value) +{ + FProxyIP = Value; +} + +sockaddr_in MCHttpConnectionEntry::getProxyIP(void) +{ + return FProxyIP; +} + +void MCHttpConnectionEntry::setContentLength(int Value) +{ + FContentLength = Value; +} + +int MCHttpConnectionEntry::getContentLength(void) +{ + return FContentLength; +} + +char* MCHttpConnectionEntry::getURL(void) +{ + return FURL; +} + +void MCHttpConnectionEntry::setURL(char* URL) +{ + MCMemFree(FURL); FURL = NULL; + if (URL) + FURL = strCopy(URL, 0, strlen(URL)); +} + +bool MCHttpConnectionEntry::getMessageRead(void) +{ + return FMessageRead; +} + +void MCHttpConnectionEntry::setMessageRead(bool Value) +{ + FMessageRead = Value; +} + + + +//---------------------------------------------------------------------- + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCHTTP.h b/libraries/external/eldos/pc/include/MCHTTP.h new file mode 100755 index 0000000..686ee5a --- /dev/null +++ b/libraries/external/eldos/pc/include/MCHTTP.h @@ -0,0 +1,144 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCHTTP__ +#define __MCHTTP__ + + +#include "MC.h" +#include "MCBase.h" +#include "MCSock.h" +#include "MCSyncs.h" +#include "MCThreads.h" +#include "MCSocket.h" +#include "MCStream.h" +#include "MCSocketBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCHttpConnectionEntry; +class MCHttpTransport: public MCInetTransport +{ +friend class MCHttpTransportJob; +protected: + char* FProxyAddress; + struct sockaddr_in FProxyIP; + unsigned short FProxyPort; + bool FUseProxy; + int FRequestTime; + + + virtual MCInetTransportJob* + CreateTransportJob(void); + virtual void NotifyJob(MCInetTransportJob* Job, bool MessageFlag); + virtual void DoSetActive(void); + virtual MCInetConnectionEntry* + CreateConnectionEntry(void); + virtual bool NeedLiveConnectionForDelivery(void); + virtual unsigned int getDeliveryInterval(void) + { + return FReqTime; + }; + +public: + MCHttpTransport(); + virtual ~MCHttpTransport(); + + void setProxyAddress(const char* ProxyAddr); + const char* getProxyAddress(void); + void setProxyPort(unsigned short ProxyPort); + unsigned short getProxyPort(void); + void setUseProxy(bool UseProxy); + bool getUseProxy(void); + void setRequestTime(int ReqTime); + int getRequestTime(void); +}; + +// TransportJob performs data transfer for the sockets. + +enum HttpSendingStage +{ + ssHeader = 0, + ssBody = 1 +}; + +class MCHttpTransportJob: public MCInetTransportJob { +protected: + int FAlreadyReceived; + int FHeaderRead; + int FReadingState; + int FWasRead; + bool FChunked; + int FChunkSize; + int FChunkRead; + int FReadMsgSize; + int FHeaderSize; + int FHeaderSent; + HttpSendingStage FSendingStage; + unsigned long FLastRequestTime; + + virtual bool IsMessageRead(void); + virtual void UpdateConnectionContext(void); + virtual void SetTransporterAddress(MCInetConnectionEntry* Ent, MCSocket* Transp); + bool ParseHeaders(const char* Headers, unsigned int Len, char* URL, char* Host, int& HttpCode, bool& POST, int& ContentLength, bool& Chunked); + virtual bool PostConnectionStep(void); + virtual bool InitializeConnection(); + + bool ReceiveData(); + + /* + Writes data to the socket. Returns true if the operation was successful and + false if the socket returned an error. + */ + bool SendData(void); + int ServerBuildHTTPHeader(char* Buffer, int MaxBufferLen, MCHttpConnectionEntry* HttpEnt); + int ClientBuildHTTPHeader(char* Buffer, int MaxBufferLen, int DataLen); + virtual bool IsRequestNeeded(); + virtual void ChangeLastSendTime(MCMessageState state); + virtual void ChangeLastRecvTime(MCMessageState state); + + +public: + MCHttpTransportJob(void); + virtual ~MCHttpTransportJob(void); +}; + + +class MCHttpConnectionEntry: public MCInetConnectionEntry { +protected: + bool FUseProxy; + struct sockaddr_in FProxyIP; + int FContentLength; + char* FURL; + bool FMessageRead; + +public: + MCHttpConnectionEntry(void); + virtual ~MCHttpConnectionEntry(void); + + virtual void Reset(void); + void setUseProxy(bool Value); + bool getUseProxy(void); + void setProxyIP(sockaddr_in Value); + sockaddr_in getProxyIP(void); + void setContentLength(int Value); + int getContentLength(void); + char* getURL(void); + void setURL(char* URL); + bool getMessageRead(void); + void setMessageRead(bool Value); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCInetTransport.cpp b/libraries/external/eldos/pc/include/MCInetTransport.cpp new file mode 100755 index 0000000..bb310b6 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCInetTransport.cpp @@ -0,0 +1,4523 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCInetTransport.h" +#include "MCThreads.h" + +#ifndef _WIN32_WCE +# include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +#ifdef __GNUC__ + void OutputDebugString(char *text) +{ + +} + +//#define TEXT(x) x + +#endif + +#ifdef _WIN32 +#include +#include + +void ShowDebugInfo(const char* format,...) +{ +#ifdef _SHOW_DEBUG_INFO + char log[256]; + va_list lst; + va_start(lst, format); + vsprintf(log, format, lst); + va_end(lst); + //OutputDebugString(log); +#endif +} + +#else +void ShowDebugInfo(const char* format,...) +{ +} +#endif +//long MCInetTransport::FConnectionID = 0; + +#ifdef _WIN32_WCE +//suppress C4509 +#pragma warning( disable : 4509) +#endif +#pragma warning( disable : 4355) + +inline long Min(long A, long B) +{ + return A < B ? A : B; +}; + +//yes, I know about warning. But 'this' pointer is not used during construction of MCThreadPool, so I'm able to code such construction +MCInetTransport::MCInetTransport() +:FThreadPool(this, this) +{ + FDefaultSocketFactory = new MCStdSocketFactory(); + FSocketFactory = NULL; + + FDefaultTransportName = ""; + FOutgoingQueue = new MCList(); + FAttemptsToConnect = 0; + FAttemptsInterval = 1; + FConnectionTimeout = 10000; + FConnections = new MCList(); + FActive = false; + + FListenerJob = NULL; + FBandwidthPolicy = bpStrict; + FNoTransformerFallback = false; + //FAttemptsInterval = 0; + FClientThreadLimit = 0; + FFailOnInactive = false; + FInactivityTime = 0; + FIncomingMemoryThreshold = 0; + FMessengerAddress = (char*) MCMemAlloc(strlen("0.0.0.0") + 1); + strcpy(FMessengerAddress, "0.0.0.0"); + FMessengerPort = 0; + FOutgoingMemoryThreshold = 0; + FTempFilesFolder = NULL; + FThreadPoolSize = 0; + FTransportMode = (MCInetTransportMode)0; + FUseTempFilesForIncoming = false; + FUseTempFilesForOutgoing = false; + FReqTime = 5; + FTransformerFailProc = NULL; + FMsgTimeout = 0; + FIncomingBufferSize = 8192; + FOutgoingBufferSize = 8192; + FIncomingSpeedLimit = 0; + FOutgoingSpeedLimit = 0; + +//$ifndef LINUX + FUseSocks = false; + FSocksServer = NULL; + FSocksPort = 1080; + FSocksUserCode = NULL; + FSocksPassword = NULL; + FSocksVersion = mcSocks5; + FSocksAuthentication = saNoAuthentication; + FSocksResolveAddress = false; +//$endif + + // Web tunneling support + FUseWebTunneling = false; + FWebTunnelAddress = NULL; + FWebTunnelPort = 4080; + FWebTunnelAuthentication = wtaNoAuthentication; + FWebTunnelUserId = NULL; + FWebTunnelPassword = NULL; + + FReuseServerPort = true; + +//$ifdef MC_COMMERCIAL + FRoutingEnabled = false; +//$endif MC_COMMERCIAL + this->FOnConnected = NULL; + this->FOnConnectedData = 0; + this->FOnDisconnected = NULL; + this->FOnDisconnectedData = 0; +} + + +MCInetTransport::~MCInetTransport() +{ + setActive(false); + delete FOutgoingQueue; FOutgoingQueue = NULL; + delete FConnections; FConnections = NULL; + delete FDefaultSocketFactory; FDefaultSocketFactory = NULL; + + if (NULL != FMessengerAddress) + { + free(FMessengerAddress); + FMessengerAddress = NULL; + } + if (NULL != FTempFilesFolder) + { + free(FTempFilesFolder); + FTempFilesFolder = NULL; + } +//$ifndef LINUX + if (NULL != FSocksUserCode) + { + free(FSocksUserCode); + FSocksUserCode = NULL; + } + if (NULL != FSocksPassword) + { + free(FSocksPassword); + FSocksPassword = NULL; + } + if (NULL != FSocksServer) + { + free(FSocksServer); + FSocksServer = NULL; + } +//$endif + + // Web tunneling support + if (NULL != FWebTunnelAddress) + { + free(FWebTunnelAddress); + FWebTunnelAddress = NULL; + } + if (NULL != FWebTunnelUserId) + { + free(FWebTunnelUserId); + FWebTunnelUserId = NULL; + } + if (NULL != FWebTunnelPassword) + { + free(FWebTunnelPassword); + FWebTunnelPassword = NULL; + } +} + +class MCSocketThread: public MCWorkerThread +{ +public: + MCSocketThread(MCThreadPool* Pool, int Priority = -1): MCWorkerThread(Pool, Priority) {}; + virtual void Terminate(void); + + virtual void KickThread(bool MessageFlag); +}; + +void MCSocketThread::Terminate() +{ + MCWorkerThread::Terminate(); + KickThread(false); +} + +void MCSocketThread::KickThread(bool MessageFlag) +{ + char c = (char) MessageFlag; + long i = 0; + + MCSocketJob* SocketJob = (MCSocketJob*)FJob; + if (NULL != SocketJob) + { + //printf("Kicking socket...\n"); + SocketJob->getSocket()->SendTo(&c, 1, i, "127.0.0.1", SocketJob->getSocket()->getLocalPort()); + } +} + +MCWorkerThread* MCInetTransport::CreateThread(void) +{ + return new MCSocketThread(&FThreadPool); +} + +#ifdef USE_CPPEXCEPTIONS +void MCInetTransport::HandleError(const EMCError& Error) +{ + +} +#else +void MCInetTransport::HandleError(unsigned int ErrorCode) +{ +} +#endif + + +void MCInetTransport::CancelMessage(MCMessageInfo* Info) +{ + MCInetConnectionEntry* Entry = NULL; + char* SocketName = NULL; + + FCriticalSection->Enter(); + TRY_BLOCK + { + SocketName = Info->DMessenger; + Entry = FindEntry(SocketName, Info); + if(NULL != Entry) + { + Entry->getCS()->Enter(); + if(Entry->getInfo() == Info) + {//this message is sending now + Entry->setInfo(NULL); + delete Entry->getOutgoingStream(); Entry->setOutgoingStream(NULL); + if (NULL != Entry->getProcessingJob()) + Entry->getProcessingJob()->setIsSending(false); + else + ShowDebugInfo("Job for the message being cancelled is not found!"); + + } + if (NULL != Entry->getProcessingJob()) + Entry->getProcessingJob()->getOutgoingQueue()->Del(Info); + Entry->getCS()->Leave(); + } + // remove from outgoing queue + FOutgoingQueue->Del(Info); + } FINALLY ( + FCriticalSection->Leave(); + ) +} + +char* CreateSMessenger(long ClientID, long ConnID, const char* RemAddr, int Port) +{ + char buf[128]; + //char idbuf[64]; + + if (NULL != RemAddr) + sprintf(buf, "%d:%d:%s:%d", ClientID, ConnID, RemAddr, Port); + else + sprintf(buf, "%d:%d", ClientID, ConnID); + + char* result = (char*)MCMemAlloc(strlen(buf)+1); + strcpy(result, buf); + return result; + +} + +MCSocket* MCInetTransport::CreateClientSocket(void) +{ + + MCSocket* s; + if (FSocketFactory != NULL) + s = FSocketFactory->CreateClientSocket(); + else + s = FDefaultSocketFactory->CreateClientSocket(); + + s->Init(istStream); + return s; +} + + +MCSocket* MCInetTransport::CreateServerSocket(void) +{ + + MCSocket* s; + if (FSocketFactory != NULL) + s = FSocketFactory->CreateServerSocket(); + else + s = FDefaultSocketFactory->CreateServerSocket(); + + return s; +} + +MCInetListenerJob* MCInetTransport::CreateListenerJob(void) +{ + MCInetListenerJob* t = new MCInetListenerJob(); + t->setJobName("Listener"); + t->setOwner(this); + t->Initialize(CreateServerSocket()); + return t; +} + +const char* ExtractConnID(const char* SocketName, long* ClientID, long* ConnID) +{ + MCASSERT(NULL != SocketName); + MCASSERT(NULL != ConnID); + MCASSERT(NULL != ClientID); + + int Port = -1; char* IP = NULL; + MCInetTransportJob::ParseRemoteAddr(SocketName, ClientID, ConnID, &IP, &Port); + MCMemFree(IP); IP = NULL; + if (*ClientID != 0 || *ConnID != 0) + { + char* p = strchr((char*) SocketName, ':'); + return p ? p + 1 : NULL; + } + else + { + return SocketName; + } +} + +void MCInetTransport::PutMessageToOutgoing(const char* SocketName, MCMessageInfo* Info) +{ + //FLogger->PutMessage(llTrivial, "PutMessageToOutgoing is started.", 0, "MCInetTransport::PutMessageToOutgoing"); + MCInetConnectionEntry* Entry = NULL; + //int i = 0; + //bool foundEntry = false; + // place the message to the queue + FCriticalSection->Enter(); + + TRY_BLOCK + { + // find out whether we have a connection with this host + // or we need to initiate one + Entry = FindEntry((char*)SocketName, Info); + if (NULL != Entry) + { + Entry->getCS()->Enter(); + Info->ConnID = Entry->getConnID(); + Info->ClientID = Entry->getClientID(); + InsertInfoIntoQueueWithPriorities(Entry->getProcessingJob()->getOutgoingQueue(), Info, false); + NotifyJob(Entry->getProcessingJob(), true); + Entry->getCS()->Leave(); + } + else + { + //OutputDebugString("Client connection initiated for "); + //OutputDebugString(SocketName); + //OutputDebugString("\n"); + InsertInfoIntoQueueWithPriorities(FOutgoingQueue, Info, false); + + if (NeedLiveConnectionForDelivery() == false) + { + if (IsImmediateDelivery(SocketName) == true) + { + if (Info->State == imsDispatching) + InitiateDelivery(NULL, NULL); + } + } + else + InitiateDelivery(NULL, NULL); + } + } FINALLY ( + FCriticalSection->Leave(); + ) +} + +bool MCInetTransport::IsImmediateDelivery(const char* RemAddr) +{ + char* p1 = strchr((char*) RemAddr, ':'); //is there any address component or just ID? + if (p1 != RemAddr) + return p1 != RemAddr + (strlen(RemAddr) - 1); + else + return false; +} + +bool MCInetTransport::DeliverMessage(char* DestAddress, MCMessageInfo* Info) +{ + bool r = false; + + char *p = NULL, *p1 = NULL; + char *SocketName = NULL, *QueueName = NULL, *URLName = NULL; + + if(DestAddress && AddressValid(DestAddress)) + { + Info->Transport = this; + + // extract names + if(!strchr(DestAddress, '|')) + THROW_ERROR(MCError_BadDestinationName); + + p = p1 = DestAddress; + + while((*p != '|') && (*p != '/') && *p) + p++; + if(!*p) + THROW_ERROR(MCError_BadDestinationName); + + // get socket name + if(p - p1 > 0) + SocketName = strCopy(p1, 0, p - p1); + else + THROW_ERROR(MCError_BadDestinationName); + //p++; + + //get URL if such available + p1 = p; + while ((*p != '|') && *p) + p++; + if (!*p) + THROW_ERROR(MCError_BadDestinationName); // there is not queue name + + if (*p == '|') + URLName = strCopy(p1, 0, p - p1); + p++; + + // get queue name + p1 = p; + while(*p) + p++; + if(p - p1 > 0) + QueueName = strCopy(p1, 0, p - p1); + else + THROW_ERROR(MCError_BadDestinationName); + +//$ifdef MC_COMMERCIAL + p1 = QueueName; + p = p1; + p += strlen(QueueName); + while (p != p1) + { + if (*p == '|') + { + if (Info->RouteTo) + MCMemFree(Info->RouteTo); + Info->RouteTo = strCopy(QueueName, 0, p - p1); + p++; + + char* tmpQ = (char*)MCMemAlloc(strlen(p) + 1); + strcpy(tmpQ, p); + MCMemFree(QueueName); + QueueName = tmpQ; + + break; + } + p--; + } +//$endif MC_COMMERCIAL + + // set message info properties + strncpy(Info->DQueue, QueueName, DQueueMaxLength - 1); + Info->DQueue[DQueueMaxLength - 1] = 0; + + // update Info->ConnID from SocketName + const char* realName = ExtractConnID(SocketName, &Info->ClientID, &Info->ConnID); + if (NULL != realName) + { + int len = strlen(realName); + memmove(SocketName, realName, strlen(realName)); + SocketName[len] = 0; + } + + Info->DMessenger = SocketName; + Info->URL = URLName; + + Info->State = imsDispatching; + MCMemFree(QueueName); QueueName = NULL; + //FCriticalSection->Enter(); + //TRY_BLOCK + //{ + PutMessageToOutgoing(SocketName, Info); + //} + //FINALLY( + // FCriticalSection->Leave(); + //) + r = true; + } + else + r = false; + return r; +} + +void MCInetTransport::DeliveryFailed(MCMessageInfo* Info) +{ +/* FCriticalSection->Enter(); + TRY_BLOCK + { + FOutgoingQueue->Del(Info); + } + FINALLY ( + FCriticalSection->Leave(); + ) */ + + + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger && (Info->State == imsDispatching || Info->State == imsWaiting) && Info->IsSendMsg + //$ifdef MC_COMMERCIAL + && (!Info->Intermed) + //$endif + + ) + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + Info->State = imsFailed; + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL; + //MCMessenger::DestroyMessageInfo(Info); + } + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCInetTransport::CleanupMessages() +{ + int i = 0; + MCMessageInfo* Info = NULL; + unsigned int TC = 0; + bool me = false; + + FCriticalSection->Enter(); + TRY_BLOCK + { + TC = GetTickCount(); + + i = 0; + while (i < FOutgoingQueue->Length()) + { + Info = (MCMessageInfo*)((*FOutgoingQueue)[i]); + + if (Info->Timeout == 0) + { + i++; + continue; + } + + if (TC < Info->StartTime) + { + me = 0xFFFFFFFF - Info->StartTime + TC >= Info->Timeout; + } + else + { + me = TC - Info->StartTime >= Info->Timeout; + } + if (me) + { + CancelMessage(Info); + Info->State = imsExpired; + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + + FMessenger->FCompleteCriticalSection->Enter(); + //TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if (Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + //} FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + //) + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) + } + else + i++; + } + + MCInetConnectionEntry* Entry = NULL; + int j; + for(j = 0; j < FConnections->Length(); j++) + { + Entry = (MCInetConnectionEntry*)(*FConnections)[j]; + Entry->getCS()->Enter(); + TRY_BLOCK + { + if (NULL != Entry->getProcessingJob()) + { + MCInetTransportJob *job = Entry->getProcessingJob(); + if (job != NULL) + { + i = 0; + while (i < job->getOutgoingQueue()->Length()) + { + Info = (MCMessageInfo*)((*(job->getOutgoingQueue()))[i]); + + if (Info->Timeout == 0) + { + i++; + continue; + } + + if (TC < Info->StartTime) + me = 0xFFFFFFFF - Info->StartTime + TC >= Info->Timeout; + else + me = TC - Info->StartTime >= Info->Timeout; + if (me) + { + CancelMessage(Info); + Info->State = imsExpired; + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if (Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) + } + else + i++; + } + } + } + } + FINALLY ( + Entry->getCS()->Leave(); + ) + } + } + FINALLY ( + FCriticalSection->Leave(); + ) +} + +MCMessageInfo* MCInetTransport::GetMessageByID(__int64 MsgID) +{ + int i = 0; + MCMessageInfo* Info = NULL; + MCMessageInfo* res = NULL; + + FCriticalSection->Enter(); + TRY_BLOCK + { + i = 0; + while (i < FOutgoingQueue->Length()) + { + Info = (MCMessageInfo*)((*FOutgoingQueue)[i]); + + if (Info->Message.MsgID == MsgID) + { + res = Info; + break; + } + else + i++; + } + + if (res == NULL) + { + + MCInetConnectionEntry* Entry = NULL; + int j; + for(j = 0; j < FConnections->Length(); j++) + { + Entry = (MCInetConnectionEntry*)(*FConnections)[j]; + Entry->getCS()->Enter(); + if (NULL != Entry->getProcessingJob()) + { + MCInetTransportJob *job = Entry->getProcessingJob(); + if (job != NULL) + { + i = 0; + while (i < job->getOutgoingQueue()->Length()) + { + Info = (MCMessageInfo*)((*(job->getOutgoingQueue()))[i]); + + if (Info->Message.MsgID == MsgID) + { + res = Info; + break; + } + else + i++; + } + } + } + Entry->getCS()->Leave(); + } + } + } + FINALLY ( + FCriticalSection->Leave(); + ) + return res; +} + +void MCInetTransport::DoSetActive(void) +{ + if(!FMessenger) + return; + + if(getActive()) + { + FThreadPool.setJobsRan(0); + if((getTransportMode() == stmP2P) || (getTransportMode() == stmServer)) + { + FListenerJob = CreateListenerJob(); + FThreadPool.PostJob(FListenerJob); //run listener + while (FThreadPool.getJobsRan() == 0) + Sleep(1); + } + } + else + { + if (FListenerJob) + FThreadPool.FinalizeJob(FListenerJob); + + FListenerJob = NULL; + FThreadPool.Clear(); //stop all threads/jobs + + if (FOutgoingQueue != NULL) + { + while (FOutgoingQueue->Length() > 0) + { + CancelMessageByID(((MCMessageInfo*)(*FOutgoingQueue)[0])->Message.MsgID, MCError_Shutdown); + } + } + } +} + +#ifndef _WIN32 +#ifndef QNX +# define stricmp strcasecmp +#endif +#endif + +bool MCInetTransport::CompareAddress(const char* Addr1, const char* Addr2, bool Strict) +{ + long ClientID1 = 0, ClientID2 = 0, ConnID1 = 0, ConnID2 = 0; int Port1 = 0, Port2 = 0; + char *IP1 = NULL, *IP2 = NULL; + bool res = false; + + if ((NULL == Addr1) || (NULL == Addr2)) + return false; + if ((0 == Addr1[0]) || (0 == Addr2[0])) + return false; + + MCInetTransportJob::ParseRemoteAddr(Addr1, &ClientID1, &ConnID1, &IP1, &Port1); + MCInetTransportJob::ParseRemoteAddr(Addr2, &ClientID2, &ConnID2, &IP2, &Port2); + if (Strict == false) + res = (Port1 == Port2) && (stricmp(IP1, IP2) == 0); + else + res = (ClientID1 == ClientID2) && (Port1 == Port2) && (stricmp(IP1, IP2) == 0); + + MCMemFree(IP1); MCMemFree(IP2); + return res; +} + +MCInetConnectionEntry* MCInetTransport::FindEntry(char* SocketName, MCMessageInfo* Info) +{ + long i = 0; + MCInetConnectionEntry* Entry = NULL; + + if (NULL != Info) + { + for (i = 0; i < FConnections->Length(); i++) + { + Entry = (MCInetConnectionEntry*)(*FConnections)[i]; + if (Entry) + { + Entry->getCS()->Enter(); + if (Entry->getConnID() == Info->ConnID) + { + Entry->getCS()->Leave(); + return Entry; + } + else + Entry->getCS()->Leave(); + } + } + } + + if (Info->ClientID == 0) + { + //connID is not found so seek by RemoteAddress + for(i = 0;i < FConnections->Length();i++) + { + Entry = (MCInetConnectionEntry*)(*FConnections)[i]; + if (Entry != NULL) + { + Entry->getCS()->Enter(); + if (CompareAddress(Entry->getRemoteAddress(), SocketName, false) + || CompareAddress(Entry->getRemoteSAddress(), SocketName, false)) + { + Entry->getCS()->Leave(); + return Entry; + } + Entry->getCS()->Leave(); + } + } + } + else + { + for(i = 0; i < FConnections->Length();i++) + { + Entry = (MCInetConnectionEntry*)(*FConnections)[i]; + if (Entry != NULL) + { + Entry->getCS()->Enter(); + + if (Entry->getProcessingJob()->getTransporter()->getDirection() == isdIncoming) + { + if (Info->ClientID == Entry->getClientID()) + { + Entry->getCS()->Leave(); + return Entry; + } + } + else + { + + if (Info->ClientID == Entry->getClientID() && + (CompareAddress(Entry->getRemoteAddress(), SocketName, false) || + CompareAddress(Entry->getRemoteSAddress(), SocketName, false))) + { + Entry->getCS()->Leave(); + return Entry; + } + } + + + Entry->getCS()->Leave(); + } + } + } + return NULL; +} + +bool MCInetTransport::InitiateDelivery(MCInetTransportJob* Job, + MCInetConnectionEntry* Entry) +{ + bool r = false; + MCSocket* Socket = NULL; + MCMessageInfo* Info = NULL; + //long i = 0; + MCInetConnectionEntry* NewEntry = NULL; + //lock transport + //FCriticalSection->Enter(); + + bool IsMessage = FOutgoingQueue->Length() > 0; + bool IsClientMode = (getTransportMode() == stmP2P) || (getTransportMode() == stmClient); + bool ShouldCreateJob = true;//(FThreadPool.getBusyCount() < FThreadPool.getMaxSize()) || (FThreadPool.getMaxSize() == 0); + if (IsMessage && IsClientMode && ShouldCreateJob) //can we try to establish client connection? + { + //TRY_BLOCK + // { + //FLogger->PutMessage(llTrivial, "New transport job is creating.", 0, "MCInetTransport::InitiateDelivery"); + MCInetConnectionEntry* NewEntry = this->CreateConnectionEntry(); + if (NULL != FCompressor) + NewEntry->setCompressID(FCompressor->GetID()); + if (NULL != FEncryptor) + NewEntry->setEncryptID(FEncryptor->GetID()); + if (NULL != FSealer) + NewEntry->setSealID(FSealer->GetID()); + + MCInetTransportJob* NewJob = this->CreateTransportJob(); + NewJob->setJobName("Client worker job"); + FConnections->Add(NewEntry); + + Info = (MCMessageInfo*)(*FOutgoingQueue)[0]; + char* S = Info->DMessenger; + //move existing Info's to job's queue + int removedItems = 0; + int i = 0; + while (i < FOutgoingQueue->Length()) + { + MCMessageInfo* CandidateInfo = (MCMessageInfo*)(*FOutgoingQueue)[i]; + if (true == CompareAddress(S, CandidateInfo->DMessenger, false)) + { + CandidateInfo->ConnID = NewEntry->getConnID(); + CandidateInfo->ClientID = NewEntry->getClientID(); + NewJob->getOutgoingQueue()->Add(CandidateInfo); + FOutgoingQueue->Del(CandidateInfo); + } + else + i++; + } + + Socket = CreateClientSocket(); //create new endpoint + NewJob->setOwner(this); + NewJob->Initialize2(Socket, NewEntry); + NewEntry->setProcessingJob(NewJob); + //NewEntry->setSocket(Socket); + MCASSERT(Info->DMessenger); + NewEntry->setRemoteAddress(Info->DMessenger); + + NewEntry->setRemoteSAddress(Info->DMessenger); + FThreadPool.PostJob(NewJob); //run the job + r = true; + //} + //FINALLY ( + // FCriticalSection->Leave(); + //) + } + //else + // FCriticalSection->Leave(); + return r; +} + +void MCInetTransport::KickEntrySocket(MCInetConnectionEntry* Entry, bool MessageFlag) +{ + char c = (char) MessageFlag; + long i = 0; + + Entry->getProcessingJob()->FKickSocket->SendTo(&c, 1, i, "127.0.0.1", + Entry->getProcessingJob()->getSocket()->getLocalPort()); +} + +void MCInetTransport::MessageProcessed(MCMessageInfo* Info) +{ + //FLogger->PutMessage(llTrivial, "MessageProcessed is started.\n", 0, "MCInetTransport::MessageProcessed"); + char* SocketName; + + if (!NeedLiveConnectionForDelivery()) + { + //modify DMessenger/SMessenger + long ClientID = 0; long ConnID = 0; int Port = -1; char* IP = NULL; + MCInetTransportJob::ParseRemoteAddr(Info->DMessenger, &ClientID, &ConnID, &IP, &Port); + MCMemFree(IP); IP = NULL; + SocketName = CreateSMessenger(ClientID, ConnID, NULL, -1); + //char* SMessenger = CreateSMessenger(ClientID, NULL, -1); + //Info->setDMessenger(SMessenger); + //Info->setSMessenger(SMessenger); + //MCMemFree(SMessenger); SMessenger = NULL; + } + else + SocketName = strdup(Info->DMessenger); + + /* Moved to Messenger + Info->DQueue[0] = 0; + if(Info->Message.DataType == bdtConst) + { + if((Info->Message.DataSize != 0) && Info->Message.Data) + MCMemFree(Info->Message.Data); + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + */ + this->PutMessageToOutgoing(SocketName, Info); + MCMemFree(SocketName); +} + + + +void MCInetTransport::MessageReceived(MCMessageInfo* Info) +{ + // Add to incoming queue + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger) + { + // check message credentials + if(!FMessenger->ValidateCredentials(Info)) + { + Info->MCError = MCError_WrongCredentials; + Info->State = imsFailed; + // if the message was posted, no need to return it back + if(Info->IsSendMsg) + { + FLinkCriticalSection->Leave(); + MessageProcessed(Info); + FLinkCriticalSection->Enter(); + } + else + { + delete Info; + Info = NULL; + } + } + else + { + Info->MCError = 0; + Info->Transport = this; + Info->State = imsWaiting; + + FMessenger->FIncomingCriticalSection->Enter(); + TRY_BLOCK + { + InsertInfoIntoQueueWithPriorities(FMessenger->FIncomingQueue, Info, FIgnoreIncomingPriorities); + FMessenger->FIncomingEvent->setEvent(); + } FINALLY ( + FMessenger->FIncomingCriticalSection->Leave(); + ) + } + } + else + { + delete Info; + Info = NULL; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCInetTransport::ReplyReceived(MCMessageInfo* Info) +{ + // Add to complete queue + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger) + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + delete Info; + Info = NULL; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + + + +unsigned long MCInetTransport::getThreadPoolSize(void) +{ + return FThreadPool.getSize() - 1; +} + +unsigned long MCInetTransport::getAttemptsInterval(void) +{ + return FAttemptsInterval; +} + +void MCInetTransport::setAttemptsInterval(unsigned long Value) +{ + FAttemptsInterval = Value; +} + +unsigned long MCInetTransport::getAttemptsToConnect(void) +{ + return FAttemptsToConnect; +} + +void MCInetTransport::setAttemptsToConnect(unsigned long Value) +{ + FAttemptsToConnect = Value; +} + +unsigned long MCInetTransport::getClientThreadLimit(void) +{ + return FThreadPool.getMaxSize(); +} + +void MCInetTransport::setClientThreadLimit(unsigned long Value) +{ + FThreadPool.setMaxSize(Value); +} + +unsigned long MCInetTransport::getConnectionTimeout(void) +{ + return FConnectionTimeout; +} + +void MCInetTransport::setConnectionTimeout(unsigned long Value) +{ + FConnectionTimeout = Value; +} + +void MCInetTransport::setFailOnInactive(bool Value) +{ + if(FFailOnInactive != Value) + FFailOnInactive = Value; +} + +bool MCInetTransport::getFailOnInactive(void) +{ + return FFailOnInactive; +} + +void MCInetTransport::setInactivityTime(unsigned long Value) +{ + FInactivityTime = Value; +} + +unsigned long MCInetTransport::getInactivityTime(void) +{ + return FInactivityTime; +} + +void MCInetTransport::setIncomingMemoryThreshold(unsigned long Value) +{ + if(FIncomingMemoryThreshold != Value) + { + if(getActive()) + FCriticalSection->Enter(); + FIncomingMemoryThreshold = Value; + if(getActive()) + FCriticalSection->Leave(); + } +} + +unsigned long MCInetTransport::getIncomingMemoryThreshold(void) +{ + return FIncomingMemoryThreshold; +} + +void MCInetTransport::setMessengerAddress(char* Value) +{ + bool b = false; + unsigned long i = 0; + + if(!FMessengerAddress && !Value) + return; + if(!FMessengerAddress || !Value || (strcmp(FMessengerAddress, Value) != 0)) + { + if(FMessengerAddress) + MCMemFree(FMessengerAddress); + FMessengerAddress = NULL; + b = getActive(); + setActive(false); + if(Value && strcmp(Value, "255.255.255.255") != 0) + { + i = inet_addr(Value); + if(i == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + } + FMessengerAddress = strdup(Value); + setActive(b); + } +} + +char* MCInetTransport::getMessengerAddress(void) +{ + return FMessengerAddress; +} + +void MCInetTransport::setMessengerPort(unsigned Value) +{ + bool b; + + if(FMessengerPort != Value) + { + b = getActive(); + setActive(false); + FMessengerPort = Value; + setActive(b); + } +} + +unsigned MCInetTransport::getMessengerPortBound(void) +{ + if (getActive() == false || FListenerJob == NULL) + return 0; + else + return FListenerJob->getSocket()->getLocalPort(); +} + +unsigned MCInetTransport::getMessengerPort(void) +{ + return FMessengerPort; +} + +void MCInetTransport::setOutgoingMemoryThreshold(unsigned long Value) +{ + if(FOutgoingMemoryThreshold != Value) + { + if(getActive()) + FCriticalSection->Enter(); + FOutgoingMemoryThreshold = Value; + if(getActive()) + FCriticalSection->Leave(); + } +} + +unsigned long MCInetTransport::getOutgoingMemoryThreshold(void) +{ + return FOutgoingMemoryThreshold; +} + +void MCInetTransport::setTempFilesFolder(char* Value) +{ + if(FTempFilesFolder) + MCMemFree(FTempFilesFolder); + if(Value) + FTempFilesFolder = strdup(Value); + else + FTempFilesFolder = Value; +} + +char* MCInetTransport::getTempFilesFolder(void) +{ + return FTempFilesFolder; +} + +void MCInetTransport::setTransportMode(MCInetTransportMode Value) +{ + FTransportMode = Value; + if(getActive()) + { + setActive(false); + FTransportMode = Value; + setActive(true); + } + else + FTransportMode = Value; +} + +MCInetTransportMode MCInetTransport::getTransportMode(void) +{ + return FTransportMode; +} + +void MCInetTransport::setUseTempFilesForIncoming(bool Value) +{ + if(FUseTempFilesForIncoming != Value) + { + if(getActive()) + FCriticalSection->Enter(); + FUseTempFilesForIncoming = Value; + if(getActive()) + FCriticalSection->Leave(); + } +} + +bool MCInetTransport::getUseTempFilesForIncoming(void) +{ + return FUseTempFilesForIncoming; +} + +void MCInetTransport::setUseTempFilesForOutgoing(bool Value) +{ + if(FUseTempFilesForOutgoing != Value) + { + if(getActive()) + FCriticalSection->Enter(); + FUseTempFilesForOutgoing = Value; + if(getActive()) + FCriticalSection->Leave(); + } +} + +bool MCInetTransport::getUseTempFilesForOutgoing(void) +{ + return FUseTempFilesForOutgoing; +} + +void MCInetTransport::setThreadPoolSize(unsigned long Value) +{ + FThreadPool.setSize(Value+1); +} + +//$ifdef MC_COMMERCIAL +void MCInetTransport::setRoutingAllowed(bool Value) +{ + FRoutingEnabled = Value; +} + +bool MCInetTransport::getRoutingAllowed(void) +{ + return FRoutingEnabled; +} +//$endif MC_COMMERCIAL + +void MCInetTransport::setTransformerFailingHandler(MCTransformerFailProc Handler) +{ + this->FTransformerFailProc = Handler; +} + +MCTransformerFailProc MCInetTransport::getTransformerFailingHandler(void) +{ + return this->FTransformerFailProc; +} + +bool MCInetTransport::getNoTransformerFallback() +{ + return FNoTransformerFallback; +} + +void MCInetTransport::setNoTransformerFallback(bool Value) +{ + FNoTransformerFallback = Value; +} + +void MCInetTransport::setIncomingBufferSize(unsigned long Value) +{ + if (Value != FIncomingBufferSize && Value >= 1024) + { + FIncomingBufferSize = Value; + } +} + +unsigned long MCInetTransport::getIncomingBufferSize() +{ + return FIncomingBufferSize; +} + +void MCInetTransport::setOutgoingBufferSize(unsigned long Value) +{ + if (Value != FOutgoingBufferSize && Value >= 1024) + { + FOutgoingBufferSize = Value; + } +} + +unsigned long MCInetTransport::getOutgoingBufferSize() +{ + return FOutgoingBufferSize; +} + + + +void MCInetTransport::setIncomingSpeedLimit(unsigned long Value) +{ + if (Value != FIncomingSpeedLimit) + { + FIncomingSpeedLimit = Value; + } +} + +unsigned long MCInetTransport::getIncomingSpeedLimit() +{ + return FIncomingSpeedLimit; +} + +void MCInetTransport::setOutgoingSpeedLimit(unsigned long Value) +{ + if (Value != FOutgoingSpeedLimit) + { + FOutgoingSpeedLimit = Value; + } +} + +unsigned long MCInetTransport::getOutgoingSpeedLimit() +{ + return FOutgoingSpeedLimit; +} + +int MCInetTransport::GetIncomingConnectionCount() +{ + int res = 0; + MCInetConnectionEntry* Entry = NULL; + MCInetTransportJob *job = NULL; + + FCriticalSection->Enter(); + TRY_BLOCK + { + int i = 0; + + for (i = 0; i < FConnections->Length(); i++) + { + + Entry = (MCInetConnectionEntry*)(*FConnections)[i]; + Entry->getCS()->Enter(); + TRY_BLOCK + { + if (NULL != Entry->getProcessingJob()) + { + job = Entry->getProcessingJob(); + if (job != NULL && job->getSocket()->getDirection() == isdIncoming) + res ++; + } + } + FINALLY ( + Entry->getCS()->Leave(); + ) + } + } + FINALLY + ( + FCriticalSection->Leave(); + ) + return res; +} + +int MCInetTransport::GetOutgoingConnectionCount() +{ + int res = 0; + MCInetConnectionEntry* Entry = NULL; + MCInetTransportJob *job = NULL; + + FCriticalSection->Enter(); + TRY_BLOCK + { + int i = 0; + + for (i = 0; i < FConnections->Length(); i++) + { + + Entry = (MCInetConnectionEntry*)(*FConnections)[i]; + Entry->getCS()->Enter(); + TRY_BLOCK + { + if (NULL != Entry->getProcessingJob()) + { + job = Entry->getProcessingJob(); + if (job != NULL && job->getSocket()->getDirection() == isdOutgoing) + res ++; + } + } + FINALLY ( + Entry->getCS()->Leave(); + ) + } + } + FINALLY + ( + FCriticalSection->Leave(); + ) + return res; +} + +void MCInetTransport::GetMessageSource(MCMessageInfo* Info, char* Buffer, int* BufferSize) +{ + + //return MCBaseTransport::GetMessageSource(Info, Buffer, BufferSize); + + char* SMessenger; + + MCInetConnectionEntry *entry = FindEntry(Info->DMessenger, Info); + if (entry != NULL) + { + SMessenger = entry->getRemoteAddress(); + } + else + { + SMessenger = Info->SMessenger; + } + + bool EmptySource = false; + EmptySource = (NULL == FName) && (NULL == FDefaultTransportName); + if (false == EmptySource) + EmptySource = FName ? (FName[0] == 0) : (FDefaultTransportName[0] == 0); + + if (true == EmptySource) + { + if (NULL != Buffer && NULL != BufferSize && *BufferSize > 0) + Buffer[0] = 0; + if (NULL != BufferSize) + *BufferSize = 0; + } + else + { + if (NULL != BufferSize) + { + int newsize; + if (NULL != FName) + newsize = strlen(FName) + 1 + strlen(SMessenger); + else + newsize = strlen(FDefaultTransportName) + 1 + strlen(SMessenger); + + if (*BufferSize < newsize) + { + if (*BufferSize > 0) + Buffer[0] = 0; + *BufferSize = newsize; + return; + } + *BufferSize = newsize; + } + if (NULL != Buffer) + { + strcpy(Buffer, (NULL != FName) ? FName : FDefaultTransportName); + strcat(Buffer, ":"); strcat(Buffer, SMessenger); + } + } + + +} + +//$ifdef BERND_VERSION +bool MCInetTransport::IsMessageInTransport( const char* DQueueName ) +{ + bool res = false; + FCriticalSection->Enter(); + TRY_BLOCK + { + for (int i=0; iLength() && !res; i++) + { + MCMessageInfo* pInfo = (MCMessageInfo*)FOutgoingQueue->At(i); + if( strcmp(DQueueName, pInfo->DQueue) == 0 ) + res = true; + } + for (int j=0; jLength() && !res; j++) + { + MCInetConnectionEntry* entry = (MCInetConnectionEntry*)FConnections->At(j); + MCInetTransportJob* job = entry->getProcessingJob(); + entry->getCS()->Enter(); + TRY_BLOCK + { + for (int k=0; kgetOutgoingQueue()->Length() && !res; k++) + { + MCMessageInfo* pInfo = (MCMessageInfo*)job->getOutgoingQueue()->At(k); + if( strcmp(DQueueName, pInfo->DQueue) == 0 ) + res = true; + } + } + FINALLY + ( + entry->getCS()->Leave(); + ) + } + } + FINALLY + ( + FCriticalSection->Leave(); + ) + return res; +} +//$endif + + +void MCInetTransport::setReuseServerPort(bool Value) +{ + FReuseServerPort = Value; +} + +bool MCInetTransport::getReuseServerPort(void) +{ + return FReuseServerPort; +} + +void MCInetTransport::setBandwidthPolicy(MCBandwidthPolicy Value) +{ + FBandwidthPolicy = Value; +} + +MCBandwidthPolicy MCInetTransport::getBandwidthPolicy() +{ + return FBandwidthPolicy; +} + +//$ifndef LINUX +void MCInetTransport::setUseSocks(bool Value) +{ + FUseSocks = Value; + if (Value) + setUseWebTunneling(false); +} + +bool MCInetTransport::getUseSocks(void) +{ + return FUseSocks; +} + +void MCInetTransport::setSocksVersion(MCSocksVersion Value) +{ + FSocksVersion = Value; +} + +MCSocksVersion MCInetTransport::getSocksVersion(void) +{ + return FSocksVersion; +} + +void MCInetTransport::setSocksServer(const char* Value) +{ + if (FSocksServer) + free(FSocksServer); + FSocksServer = strdup(Value); +} + +const char* MCInetTransport::getSocksServer(void) +{ + return FSocksServer; +} + +void MCInetTransport::setSocksPort(unsigned short Value) +{ + FSocksPort = Value; +} + +unsigned short MCInetTransport::getSocksPort(void) +{ + return FSocksPort; +} + +void MCInetTransport::setSocksAuthentication(MCSocksAuthentication Value) +{ + FSocksAuthentication = Value; +} + +MCSocksAuthentication MCInetTransport::getSocksAuthentication(void) +{ + return FSocksAuthentication; +} + +void MCInetTransport::setSocksUserCode(const char* Value) +{ + if (FSocksUserCode) + free(FSocksUserCode); + FSocksUserCode = strdup(Value); +} + +const char* MCInetTransport::getSocksUserCode(void) +{ + return FSocksUserCode; +} + +void MCInetTransport::setSocksPassword(const char* Value) +{ + if (FSocksPassword) + free(FSocksPassword); + FSocksPassword = strdup(Value); +} +const char* MCInetTransport::getSocksPassword(void) +{ + return FSocksPassword; +} +void MCInetTransport::setSocksResolveAddress(bool Value) +{ + FSocksResolveAddress = Value; +} + +bool MCInetTransport::getSocksResolveAddress(void) +{ + return FSocksResolveAddress; +} +//$endif + +// Web tunneling support +void MCInetTransport::setUseWebTunneling(bool Value) +{ + FUseWebTunneling = Value; +//$ifndef LINUX + if (Value) + setUseSocks(false); +//$endif +} + +bool MCInetTransport::getUseWebTunneling() +{ + return FUseWebTunneling; +} + +void MCInetTransport::setWebTunnelAddress(const char *Value) +{ + if (FWebTunnelAddress) + free(FWebTunnelAddress); + FWebTunnelAddress = strdup(Value); +} + +const char* MCInetTransport::getWebTunnelAddress() +{ + return FWebTunnelAddress; +} + +void MCInetTransport::setWebTunnelPort(unsigned short Value) +{ + FWebTunnelPort = Value; +} + +unsigned short MCInetTransport::getWebTunnelPort() +{ + return FWebTunnelPort; +} + +MCWebTunnelAuthentication MCInetTransport::getWebTunnelAuthentication() +{ + return FWebTunnelAuthentication; +} + +void MCInetTransport::setWebTunnelAuthentication(MCWebTunnelAuthentication Value) +{ + FWebTunnelAuthentication = Value; +} + +void MCInetTransport::setWebTunnelUserId(const char *Value) +{ + if (FWebTunnelUserId) + free(FWebTunnelUserId); + FWebTunnelUserId = strdup(Value); +} + +const char* MCInetTransport::getWebTunnelUserId() +{ + return FWebTunnelUserId; +} + +void MCInetTransport::setWebTunnelPassword(const char *Value) +{ + if (FWebTunnelPassword) + free(FWebTunnelPassword); + FWebTunnelPassword = strdup(Value); +} + +const char* MCInetTransport::getWebTunnelPassword() +{ + return FWebTunnelPassword; +} + +void MCInetTransport::setSocketFactory(MCSocketFactory* Value) +{ + FSocketFactory = Value; +} + +MCSocketFactory* MCInetTransport::getSocketFactory() +{ + return FSocketFactory; +} + +MCSocketConnectedEvent MCInetTransport::getOnConnected(void* *UserData) +{ + if (UserData) + *UserData = FOnConnectedData; + return FOnConnected; +} + +void MCInetTransport::setOnConnected(MCSocketConnectedEvent Value, void* UserData) +{ + FOnConnected = Value; + FOnConnectedData = UserData; +} + +MCSocketDisconnectedEvent MCInetTransport::getOnDisconnected(void* *UserData) +{ + if (UserData) + *UserData = FOnDisconnectedData; + return FOnDisconnected; +} + +void MCInetTransport::setOnDisconnected(MCSocketDisconnectedEvent Value, void* UserData) +{ + FOnDisconnected = Value; + FOnDisconnectedData = UserData; +} + +long MCInetTransport::GetOutgoingMessagesCount() +{ + long res = 0; + MCInetConnectionEntry* Entry = NULL; + MCInetTransportJob *job = NULL; + FCriticalSection->Enter(); + TRY_BLOCK + { + res += FOutgoingQueue->Length(); + int i = 0; + for (i = 0; i < FConnections->Length(); i++) + { + Entry = (MCInetConnectionEntry*)(*FConnections)[i]; + Entry->getCS()->Enter(); + TRY_BLOCK + { + if (NULL != Entry->getProcessingJob()) + { + job = Entry->getProcessingJob(); + if (job != NULL) + res += job->getOutgoingQueue()->Length(); + } + } + FINALLY ( + Entry->getCS()->Leave(); + ) + } + } + FINALLY + ( + FCriticalSection->Leave(); + ) + return res; +} + +void MCInetTransport::DebugBreakConnections(void) +{ + FCriticalSection->Enter(); + TRY_BLOCK + { + for (int i=0; iLength(); i++) + { + MCInetConnectionEntry* entry = (MCInetConnectionEntry*)FConnections->At(i); + entry->getCS()->Enter(); + MCInetTransportJob* job = entry->getProcessingJob(); + //closesocket(job->getTransporter()->getSocket()); + job->getTransporter()->Close(true); + entry->getCS()->Leave(); + } + } + CATCH_EVERY + { + } + FCriticalSection->Leave(); +} + +// ************************** MCInetTransportJob ************************* + +MCInetTransportJob::MCInetTransportJob(void) +{ + FEntry = NULL; + FHandshakeWaitingReply = false; + FTransporter = NULL; + FInitialized = false; + FIsReceiving = false; + FIsSending = false; + + FIncomingSpeedLimit = 0; + FOutgoingSpeedLimit = 0; + + FblInSessionStartTime = 0; + FblOutSessionStartTime = 0; + + FblInMsgStartTime = 0; + FblOutMsgStartTime = 0; + + FblInSessionTransferred = 0; + FblOutSessionTransferred = 0; + + FblInMsgTransferred = 0; + FblOutMsgTransferred = 0; + + FblInSecTransferred = 0; + FblOutSecTransferred = 0; + + FblInNextTime = 0; + FblOutNextTime = 0; + + FblToRecv = 0; + FblToSend = 0; + + FIncomingBuffer = NULL; + FOutgoingBuffer = NULL; + + FIncomingBufferSize = 0; + FOutgoingBufferSize = 0; + + AdjustBufferSize(8192, 8192); + + FServerRequestTime = 0; + + FOwner = NULL; +} + +MCInetTransportJob::~MCInetTransportJob(void) +{ + delete FTransporter; + FTransporter = NULL; + if (FIncomingBuffer) + MCMemFree(FIncomingBuffer); + FIncomingBuffer = NULL; + + if (FOutgoingBuffer) + MCMemFree(FOutgoingBuffer); + FOutgoingBuffer = NULL; +} + + + +void MCInetTransportJob::WaitForSignal(unsigned int ms) +{ + fd_set FDRecvSet; + FD_ZERO(&FDRecvSet); + FD_SET((unsigned long)FSocket->getSocket(), &FDRecvSet); + timeval tv; + tv.tv_sec = ms / 1000; + tv.tv_usec = (ms % 1000) * 1000; + //printf("Waiting for signal...\n"); + int resCode = select(FSocket->getSocket(), &FDRecvSet, NULL, NULL, &tv); + + if (resCode > 0) + { + char c; sockaddr_in fromAddr; int fromAddrLen = sizeof(fromAddr); + #ifdef _WIN32 +//$ifndef LINUX + recvfrom(FSocket->getSocket(), &c, 1, 0, (sockaddr*)&fromAddr, &fromAddrLen); +//$endif LINUX + #else + recvfrom(FSocket->getSocket(), &c, 1, 0, (sockaddr*)&fromAddr, (socklen_t*)&fromAddrLen); + #endif + + } + //printf("Waiting for signal finished\n"); +} + +bool MCInetTransportJob::ClientConnect(void) +{ + + bool result = false; + + //ok, trying to connect! + + //set transporter address (maybe proxy in HTTP transport) + SetTransporterAddress(FEntry, FTransporter); + + //wait while connect + TRY_BLOCK + { +//$ifndef LINUX + FTransporter->setUseSocks(FOwner->getUseSocks()); + if (FOwner->getUseSocks()) + { + FTransporter->setSocksAuthentication(FOwner->getSocksAuthentication()); + FTransporter->setSocksPassword(FOwner->getSocksPassword()); + FTransporter->setSocksUserCode(FOwner->getSocksUserCode()); + FTransporter->setSocksPort(FOwner->getSocksPort()); + FTransporter->setSocksResolveAddress(FOwner->getSocksResolveAddress()); + FTransporter->setSocksServer(FOwner->getSocksServer()); + FTransporter->setSocksPort(FOwner->getSocksPort()); + FTransporter->setSocksVersion(FOwner->getSocksVersion()); + } +//$endif + // Web tunneling support + FTransporter->setUseWebTunneling(FOwner->getUseWebTunneling()); + if (FOwner->getUseWebTunneling()) + { + FTransporter->setWebTunnelAddress(FOwner->getWebTunnelAddress()); + FTransporter->setWebTunnelPort(FOwner->getWebTunnelPort()); + FTransporter->setWebTunnelAuthentication(FOwner->getWebTunnelAuthentication()); + FTransporter->setWebTunnelUserId(FOwner->getWebTunnelUserId()); + FTransporter->setWebTunnelPassword(FOwner->getWebTunnelPassword()); + } + + FTransporter->ExtConnect(FSocket, FOwner->getConnectionTimeout()); + + if(FTransporter->getState() == issConnected) + { + if (FTransporter->AfterConnection(FSocket, FOwner->getConnectionTimeout()) != 0) + FTransporter->Close(true); + } + if (FTransporter->getState() == issConnected) + { //yes, we are connected + if (!InitializeConnection()) + FTransporter->Close(true); + else + result = true; + } + + } + CATCH_EVERY + {//cannot connect due to bad host name etc. Just ignore it for now + } + return result; +} + +bool MCInetTransportJob::SetMessageForSending(void) +{ + bool bRet = false; + FEntry->getCS()->Enter(); + TRY_BLOCK + { + + if (FEntry->getInfo() == NULL) + { + MCMessageInfo *Info = GetMessageForDelivery(); + FEntry->setInfo(Info); + if (NULL != Info) + { + Info->OldState = Info->State; + //FEntry->setInfoState(FEntry->getInfo()->State); + Info->State = imsWaiting; //mark message as 'waiting' delivery + } + } + + bRet = FEntry->getInfo() != NULL; + } + FINALLY ( + FEntry->getCS()->Leave(); + ) + + return bRet; +} + +bool MCInetTransportJob::AreRequestsInQueue(void) +{ + for (int i=0; iSent) + return true; + } + return false; +} + +bool MCInetTransportJob::HandleIncomingData(void) +{ + + if ((FEntry->FIncomingStream == NULL) || (FEntry->FIncomingStream->Pos() == 0)) + { + FblInMsgStartTime = GetTickCount(); + FblInMsgTransferred = 0; + } + + if (ReceiveData()) + { + MessageReceivedCompletely2(); + return true; + } + else + return false; +} + +bool MCInetTransportJob::HandleOutgoingData() +{ + + if ((FEntry->FOutgoingStream == NULL) || (FEntry->FOutgoingStream->Pos() == 0)) + { + FblOutMsgStartTime = GetTickCount(); + FblOutMsgTransferred = 0; + } + + if (SendData()) + { + MessageSentCompletely(); + return true; + } + else + return false; +} + +/* +void checkForTimeOut(int select_res, bool failOnInactive, bool& timeout, bool& errorFlag) +{ + if (0 == select_res) + {//timeout! + if (failOnInactive) + timeout = true; + else + errorFlag = true; + } + else + { + errorFlag = true; + } +} +*/ + +bool MCInetTransportJob::PerformRecvSend(bool& errorFlag, bool& closeConnection, bool& timeout) +{ + fd_set FDSendSet, FDRecvSet; + timeval TimeVal, *PTV; + + int TimeoutV; + unsigned long InactTime = 0; + + bool IsBWLimit; + bool SendAllowed, RecvAllowed; + + unsigned long CurTicks; + unsigned long x1; + + CurTicks = GetTickCount(); + FblInMsgStartTime = CurTicks; + FblOutMsgStartTime = CurTicks; + + while ((false == errorFlag) && + (false == closeConnection) && + (false == timeout) && + (false == getTerminated())) + { + TRY_BLOCK + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"IsSending is %d.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, + // GetTickCount(), (int)getIsSending()); + + if (false == getIsSending()) + {//nothing sending now + if (SetMessageForSending()) + { + PrepareMessageForSending(); + } + } + + if (IsRequestNeeded()) + { + FOutgoingQueue.Insert(0, MakeEmptyPacket(imsEmptyRequest)); + continue; + } + + UpdateConnectionContext(); + + /* + if (((MCStdSocket*)FTransporter)->IsCachedData()) + { + if (!HandleIncomingData()) + errorFlag = true; + continue; + } + */ + + // adjust speed limitations and define amount of data to transfer + + AdjustSpeedLimits(FOwner->FIncomingSpeedLimit, FOwner->FOutgoingSpeedLimit); + + IsBWLimit = (FIncomingSpeedLimit > 0) || (FOutgoingSpeedLimit > 0); + + CurTicks = GetTickCount() + 1000; + + RecvAllowed = true; + FblToRecv = FIncomingBufferSize; + if (FIncomingSpeedLimit > 0) + { + + if (FOwner->getBandwidthPolicy() == bpStrict) + { + if (CurTicks > FblInNextTime) + { + FblInNextTime = (CurTicks / 1000 + 1) * 1000; + FblInSecTransferred = 0; + } + if (FblInSecTransferred < FIncomingSpeedLimit) + { + FblToRecv = FIncomingSpeedLimit; + + if (FIncomingBufferSize < FblToRecv) + FblToRecv = FIncomingBufferSize; + + if (FblToRecv == 0) + RecvAllowed = false; + } + else + RecvAllowed = false; + } + else + { + if ((FblInSessionTransferred > ((__int64)(CurTicks - FblInSessionStartTime)) * ((__int64)FIncomingSpeedLimit) / 1000) || + (FblInMsgTransferred > ((__int64)(CurTicks - FblInMsgStartTime)) * ((__int64)FIncomingSpeedLimit) / 1000)) + { + RecvAllowed = false; + } + else + { + FblToRecv = (unsigned long)(((__int64)CurTicks - (__int64)FblInSessionStartTime) * (__int64)FIncomingSpeedLimit / 1000 - FblInSessionTransferred); + x1 = (unsigned long)(((__int64)CurTicks - (__int64)FblInMsgStartTime) * (__int64)FIncomingSpeedLimit / 1000 - FblInMsgTransferred); + + if (x1 < FblToRecv) + FblToRecv = x1; + + if (FIncomingBufferSize < FblToRecv) + FblToRecv = FIncomingBufferSize; + if (FblToRecv > FIncomingSpeedLimit) + FblToRecv = FIncomingSpeedLimit; + + if (FblToRecv == 0) + RecvAllowed = false; + } + } + } + + SendAllowed = true; + FblToSend = FOutgoingBufferSize; + + if (getIsSending() && (FOutgoingSpeedLimit > 0)) + { + if (FOwner->getBandwidthPolicy() == bpStrict) + { + if (CurTicks > FblOutNextTime) + { + FblOutNextTime = (CurTicks / 1000 + 1) * 1000; + FblOutSecTransferred = 0; + } + if (FblOutSecTransferred < FOutgoingSpeedLimit) + { + FblToSend = FOutgoingSpeedLimit; + + if (FOutgoingBufferSize < FblToSend) + FblToSend = FOutgoingBufferSize; + + if (FblToSend == 0) + SendAllowed = false; + } + else + SendAllowed = false; + } + else + { + if ((FblOutSessionTransferred > ((__int64)(CurTicks - FblOutSessionStartTime)) * ((__int64)FOutgoingSpeedLimit) / 1000) || + (FblOutMsgTransferred > ((__int64)(CurTicks - FblOutMsgStartTime)) * ((__int64)FOutgoingSpeedLimit) / 1000)) + { + SendAllowed = false; + } + else + { + FblToSend = (unsigned long)(((__int64)CurTicks - (__int64)FblOutSessionStartTime) * (__int64)FOutgoingSpeedLimit / 1000 - FblOutSessionTransferred); + x1 = (unsigned long)(((__int64)CurTicks - (__int64)FblOutMsgStartTime) * (__int64)FOutgoingSpeedLimit / 1000 - FblOutMsgTransferred); + + if (x1 < FblToSend) + FblToSend = x1; + + if (FOutgoingBufferSize < FblToSend) + FblToSend = FOutgoingBufferSize; + if (FblToSend > FOutgoingSpeedLimit) + FblToSend = FOutgoingSpeedLimit; + + if (FblToSend == 0) + SendAllowed = false; + + } + } + } + + //prepare select's parameters for send/receive/signal + // initialize sets for select + FD_ZERO(&FDSendSet); + FD_ZERO(&FDRecvSet); + + FD_SET((unsigned long)FSocket->getSocket(), &FDRecvSet); + + unsigned int highSocketHandle; + + if (RecvAllowed) + { + FD_SET((unsigned long)FTransporter->getSocket(), &FDRecvSet); + + highSocketHandle = + (FSocket->getSocket() > FTransporter->getSocket() ? FSocket->getSocket() + : FTransporter->getSocket()); + } + else + { + highSocketHandle = FSocket->getSocket(); + } + + + // highSocketHandle++; // moved to select() call + bool b = getIsSending(); + + InactTime = FOwner->getInactivityTime(); + + //determine select's timeout + if (IsBWLimit && ((InactTime == 0) || (InactTime > 1000))) + TimeoutV = 1000; + else + if (FServerRequestTime != 0) + TimeoutV = FServerRequestTime < 1000 ? FServerRequestTime : 1000; + else + TimeoutV = InactTime; + + if(TimeoutV > 0) + { + TimeVal.tv_sec = TimeoutV / 1000; + TimeVal.tv_usec = (TimeoutV % 1000) * 1000; + PTV = &TimeVal; + } + else + PTV = NULL; + + int select_res = 0; + //well, do select + // printf("Select starts...\n"); + + if (RecvAllowed && FTransporter->HasBufferedIncomingData()) + { + if (HandleIncomingData()) + ChangeLastRecvTime(FLastMsgRecvState); + else + errorFlag = true; + } + else + { + if((b || FTransporter->HasBufferedOutgoingData()) && SendAllowed) + { + FD_SET((unsigned long) FTransporter->getSocket(), &FDSendSet); + select_res = select(highSocketHandle + 1, &FDRecvSet, &FDSendSet, NULL, PTV); + } + else + select_res = select(highSocketHandle + 1, &FDRecvSet, NULL, NULL, PTV); + + //FOwner->FLogger->PutMessage(llTrivial, "Select finished\n", 0, "MCInetTransportJob::PerformRecvSend"); + if ((0 != select_res) && (-1 != select_res)) + { + if(FD_ISSET(FSocket->getSocket(), &FDRecvSet)) + {//thread was kicked + if(!getTerminated()) + { + errorFlag = (MCSocket::PopFromCtlSocket(FSocket) == false); + continue; + } + } + + if(FD_ISSET(FTransporter->getSocket(), &FDRecvSet)) + { + if (FTransporter->PreprocessIncomingData()) + { + if (HandleIncomingData()) + ChangeLastRecvTime(FLastMsgRecvState); + else + { + errorFlag = true; + continue; + } + } + } + + if (FD_ISSET(FTransporter->getSocket(), &FDSendSet)) + { + if ((!getIsSending()) || HandleOutgoingData()) + { + if (FTransporter->PostprocessOutgoingData() && getIsSending()) + { + ChangeLastSendTime(FLastMsgSendState); + } + } + else + { + errorFlag = true; + continue; + } + // continue; + } + } + else + if (select_res == 0) + { + if (IsBWLimit || (FServerRequestTime != 0)) + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Bandwidth limit is found.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + + if (FOwner->getInactivityTime() > 0) + timeout = GetTickCount() - FActivityTime > FOwner->getInactivityTime(); + else + timeout = false; + } + else + timeout = true; + /* + if (timeout) + { + / + if (!FOwner->getFailOnInactive()) + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Timeout occured. Connection will not be closed.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + + timeout = false; + errorFlag = true; + } + //else + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Timeout occured. Connection will be closed.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + } + */ + } + else + + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d\"Select returned socket_error.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + errorFlag = true; + /* + int err = LAST_ERROR; + { + char Buffer[100]; + + if (FTransporter->getDirection() == isdOutgoing) + sprintf(Buffer, "select() on outgoing socket (in PerformRecvSend) failed with error %d\n", err); + else + sprintf(Buffer, "select() on incoming socket (in PerformRecvSend) failed with error %d\n", err); + //OutputDebugString(Buffer); + } + */ + } + } + } + CATCH_EVERY + { + errorFlag = true; + } + } + //if (errorFlag) + // ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Select returned socket_error.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + return errorFlag; +} + +MCMessageInfo* MCInetTransportJob::MakeEmptyPacket(MCMessageState state) +{ + MCMessage msg; + memset(&msg, 0, sizeof(msg)); + MCMessageInfo* dstInfo = new MCMessageInfo(&msg); + + //memset(dstInfo, 0, sizeof(*dstInfo)); + MCMessenger::SetOrigID(dstInfo); + + char* SMessenger = CreateSMessenger(FEntry->getClientID(), FEntry->getConnID(), FTransporter->getLocalAddress(), FOwner->getMessengerPort()); + dstInfo->setSMessenger(SMessenger); + MCMemFree(SMessenger); + dstInfo->setDMessenger(FEntry->getRemoteAddress()); + dstInfo->MCError = 0; + dstInfo->State = state; + dstInfo->StartTime = GetTickCount(); + dstInfo->Timeout = FOwner->FMsgTimeout; + + return dstInfo; +} + +void MCInetTransportJob::FinalizeJob(void) +{ + //clean thread + setIsSending(false); + setIsReceiving(false); + + if (NULL != FEntry) + { + delete FEntry->getOutgoingStream(); FEntry->setOutgoingStream(NULL); + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + delete FEntry; + FEntry = NULL; + } + + if (NULL != FTransporter) + { + delete FTransporter; + FTransporter = NULL; + } +} + +bool MCInetTransportJob::FailCurrentMessage(int ErrorCode) +{ + MCMessageInfo* Info = NULL; + FEntry->getCS()->Enter(); + + //check first packet + if (FOutgoingQueue.Length() > 0) + { + Info = (MCMessageInfo*)FOutgoingQueue[0]; + if (Info->State == imsEmptyRequest || Info->OldState == imsEmptyRequest) + { + FOutgoingQueue.Del((long)0); + if (FEntry->getInfo() == Info) + FEntry->setInfo(NULL); + delete Info; + } + } + + + long index = 0; + if (FEntry->getInfo() != NULL) + index = FOutgoingQueue.Find(FEntry->getInfo()); + if (index >= 0 && FOutgoingQueue.Length() > 0) + { + Info = (MCMessageInfo*)FOutgoingQueue[index]; + Info->MCError = ErrorCode; + FOutgoingQueue.Del(index); + if (FEntry->getInfo() == Info) + FEntry->setInfo(NULL); + + FEntry->getCS()->Leave(); + FOwner->DeliveryFailed(Info); + FEntry->getCS()->Enter(); + } + + bool result = FOutgoingQueue.Length() > 0; + FEntry->getCS()->Leave(); + return result; +} + +void MCInetTransportJob::ClientExecute(void) +{ + bool Connected = false; + bool errorFlag = false, closeConnection = false, timeout = false; + MCMessageInfo* Info = NULL; + + while ((false == errorFlag) && (false == closeConnection) && (false == getTerminated()) && (false == timeout) && + ((FOwner->getAttemptsToConnect() == 0) || (FEntry->getAttempt() <= (long)FOwner->getAttemptsToConnect()))) + { + if (false == Connected) + {//trying to connect + + //increase counter of connect's attempts + FEntry->setAttempt(FEntry->getAttempt() + 1); + + if ((FOwner->getAttemptsToConnect() > 0) && (FEntry->getAttempt() > (long)FOwner->getAttemptsToConnect())) + { + if (FailCurrentMessage(MCError_ConnectionLost)) + FEntry->setAttempt(0); + else + errorFlag = true; + continue; + } + if (FEntry->getAttempt() > 1) + Sleep(0); //avoid 100% CPU during frequent reconnections + + if (true == ClientConnect()) + { + //go to PostConnectionStep && look for termination flag + if (PostConnectionStep()) + { + Connected = !getTerminated(); + if (Connected && (FEntry->getClientID() == 0) && (FEntry->getInfo() == NULL)) + FOutgoingQueue.Insert(0, MakeEmptyPacket(imsEmptyRequest)); //get ClientID from server + continue; + } + else + { + FinalizeConnection(); + if (FTransporter != NULL) + FTransporter->Close(true); + } + } + + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Cannot connect.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + + //should we try again? + if (!timeout && ((FOwner->getAttemptsToConnect() >= (unsigned long)FEntry->getAttempt()) || + (FOwner->getAttemptsToConnect() == 0))) + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Reconnecting.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + + //replace transporter by this way due to strange XP behaviour + MCSocket* newTransporter = FOwner->CreateClientSocket(); + delete FTransporter; FTransporter = NULL; + FTransporter = newTransporter; + //MCASSERT(newTransporter->getSocket() != FTransporter->getSocket()); + WaitForSignal(FOwner->getAttemptsInterval()); + continue; + } + else + { + if (FailCurrentMessage(MCError_ConnectionLost)) + FEntry->setAttempt(0); + else + errorFlag = true; + } + } + } + else + { + //DWORD trd = GetCurrentThreadId(); + //ShowDebugInfo("Client %d PerformRecvSend started\n", GetCurrentThreadId()); + PerformRecvSend(errorFlag, closeConnection, timeout); + FinalizeConnection(); + //ShowDebugInfo("Client PerformRecvSend done\n", GetCurrentThreadId()); + + if (errorFlag && !getTerminated() && !timeout) + { + Connected = false; + + bool tryAgain = false; + + FEntry->getCS()->Enter(); + TRY_BLOCK + { + setIsReceiving(false); setIsSending(false); + + //cleanup streams + if (FEntry->getOutgoingStream() != NULL) + { + delete FEntry->getOutgoingStream(); + FEntry->setOutgoingStream(NULL); + } + + if (FEntry->getIncomingStream() != NULL) + { + delete FEntry->getIncomingStream(); + FEntry->setIncomingStream(NULL); + } + } + FINALLY( + FEntry->getCS()->Leave(); + ) + //should try again to deliver remaining messages? + if (!timeout && ((FOwner->getAttemptsToConnect() > (unsigned long)FEntry->getAttempt()) || + (FOwner->getAttemptsToConnect() == 0))) + tryAgain = true; + else + { + if (FailCurrentMessage(MCError_ConnectionFailed)) + { + tryAgain = true; + FEntry->setAttempt(0); + } + } + + if (tryAgain) + { + errorFlag = false; closeConnection = false; + MCSocket* newTransporter = FOwner->CreateClientSocket(); + delete FTransporter; FTransporter = newTransporter; newTransporter = NULL; + WaitForSignal(FOwner->getAttemptsInterval()); + FEntry->getCS()->Enter(); + if (!getTerminated() && (FEntry->getInfo() == NULL) && (!AreRequestsInQueue() || (FEntry->getClientID() == 0))) + FOutgoingQueue.Insert(0, MakeEmptyPacket(imsEmptyRequest)); + FEntry->getCS()->Leave(); + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Connection will be established again.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + + continue; + } + //else + // ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Connection will NOT be established again.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + + } + } + } + +#if defined(__GNUC__) && (!defined(QNX)) + long errorCode = ((MCStdSocket*)FTransporter)->GetInAddr()->sin_addr.s_addr == INADDR_NONE ? MCError_InvalidAddress : MCError_ConnectionLost; +#else + long errorCode = ((MCStdSocket*)FTransporter)->GetInAddr()->sin_addr.S_un.S_addr == INADDR_NONE ? MCError_InvalidAddress : MCError_ConnectionLost; +#endif + + //ok, we are finished exchanging + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + //remove connection from list of connections + FOwner->FConnections->Del(FEntry); + if (FOutgoingQueue.Length() > 0) + { + FinalizeJob(); + + //move remaining messages to transport's main outgoing queue + while (0 < FOutgoingQueue.Length()) + { + MCMessageInfo* Info = (MCMessageInfo*)FOutgoingQueue[0]; + Info->Track = NULL; + if (Info->State == imsWaiting && !Info->Sent) + Info->State = Info->OldState; //restore original state + + FOutgoingQueue.Del(Info); + + if ((Info->State != imsEmptyRequest) && (Info->State != imsEmptyReply)) + { + if (FOwner->FDiscardUnsentMessages && !Info->ReplyFlag) + delete Info; + else + if ((FOwner->FDiscardUnsentMessages && Info->ReplyFlag) || + (getTerminated() && FOwner->getFailOnInactive())) + { + Info->MCError = errorCode; + FOwner->FCriticalSection->Leave(); + TRY_BLOCK + { + FOwner->DeliveryFailed(Info); + } + FINALLY + ( + FOwner->FCriticalSection->Enter(); + ) + } + else + FOwner->FOutgoingQueue->Add(Info); + } + else + { + delete Info; + } + } + //FEntry->getCS()->Leave(); + } + else + FinalizeJob(); + } + FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + + errorFlag = false; + Connected = false; + closeConnection = true; //exit from loop +} + + +void MCInetTransportJob::ServerExecute(void) +{ + MCMessageInfo* InfoCopy = NULL; + bool /*Connected = false, */errorFlag = false, closeConnection = false, timeout = false; + + TRY_BLOCK + { + errorFlag = FTransporter->AfterConnection(FSocket, FOwner->getConnectionTimeout()) != 0; + } + CATCH_EVERY + { + errorFlag = true; + } + + if (!errorFlag) + { + if (!InitializeConnection()) + errorFlag = true; + + + if (false == errorFlag && (false == getTerminated()) && (true == PostConnectionStep()) ) + PerformRecvSend(errorFlag, closeConnection, timeout); + FinalizeConnection(); + } + //ShowDebugInfo("Server %d PerformRecvSend done\n", GetCurrentThreadId()); + + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + FOwner->FConnections->Del(FEntry); + FEntry->setAttempt(0); + if (FOutgoingQueue.Length() > 0) + { + FinalizeJob(); + + //move remaining messages to transport's main outgoing queue + while (0 < FOutgoingQueue.Length()) + { + MCMessageInfo* Info = (MCMessageInfo*)FOutgoingQueue[0]; + Info->Track = NULL; + if (Info->State == imsWaiting && !Info->Sent) + Info->State = Info->OldState; //restore original state + + FOutgoingQueue.Del(Info); + + if ((Info->State != imsEmptyRequest) && (Info->State != imsEmptyReply)) + { + if (FOwner->FDiscardUnsentMessages && !Info->ReplyFlag) + delete Info; + else + if ((FOwner->FDiscardUnsentMessages && Info->ReplyFlag) || + (getTerminated() && FOwner->getFailOnInactive())) + { Info->MCError = MCError_ConnectionLost; + FOwner->FCriticalSection->Leave(); + TRY_BLOCK + { + FOwner->DeliveryFailed(Info); + } + FINALLY + ( + FOwner->FCriticalSection->Enter(); + ) + } + else + FOwner->FOutgoingQueue->Add(Info); + } + else + { + delete Info; + } + } + //FEntry->getCS()->Leave(); + } + else + FinalizeJob(); + } + FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + errorFlag = false; + closeConnection = true; +} + +void MCInetTransportJob::Run(void) +{ + //FOwner->FLogger->PutMessage(llTrivial, "Job is starting.\n", 0, "MCInetTransportJob::Run"); + TRY_BLOCK + { + if (FTransporter->getDirection() == isdOutgoing) + { + //ShowDebugInfo("Client thread %d started\n", GetCurrentThreadId()); + ClientExecute(); + //ShowDebugInfo("Client thread %d finalizing\n", GetCurrentThreadId()); + } + else + { + //ShowDebugInfo("Server %d thread started\n", GetCurrentThreadId()); + ServerExecute(); + //ShowDebugInfo("Server %d thread finalizing\n", GetCurrentThreadId()); + } + } + CATCH_EVERY + { + } + /* + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + FOwner->FConnections->Del(FEntry); + FinalizeJob(); + delete FTransporter; FTransporter = NULL; + } + FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + */ + //FOwner->FLogger->PutMessage(llTrivial, "Job is finishing.\n", 0, "MCInetTransportJob::Run"); +} + +MCMessageInfo* MCInetTransportJob::GetMessageForDelivery(void) +{ + long i; + MCMessageInfo *r = NULL, *r1 = NULL; + + //FEntry->getCS()->Enter(); + //TRY_BLOCK + //{ + for(i = 0; i < FOutgoingQueue.Length(); i++) + { + r = (MCMessageInfo*)FOutgoingQueue[i]; + + //CHANGES + if (FEntry->getClientID() != 0) + { + if (r->State == imsDispatching || r->State == imsComplete || r->State == imsFailed || r->State == imsEmptyRequest || r->State == imsEmptyReply) + { + r1 = r; + break; + } + } + else + { + if (r->State == imsEmptyRequest) + { + r1 = r; + break; + } + } + } + //} FINALLY ( + // FEntry->getCS()->Leave(); + //) + + return r1; +} + +void MCInetTransportJob::Initialize2(MCSocket* Socket, MCInetConnectionEntry* Entry) +{ + MCSocketJob::Initialize(); + FTransporter = Socket; + FEntry = Entry; + FInitialized = true; +} + +bool MCInetTransportJob::IsMessageRead(void) +{ + return false; +} + + +bool MCInetTransportJob::IsMessageFetched(void) +{ + MCStream* inStream = FEntry->getIncomingStream(); + if (NULL != inStream) + return (FEntry->getMsgSize() > 0) && (inStream->Len() == FEntry->getMsgSize()); + else + return false; +} + + +char* ReadStringFromArray(UNALIGNED char* array, char** str) +{ + MCASSERT(NULL != array); + MCASSERT(NULL != str); + + UNALIGNED int* p = (int *) array; + int len = *p; + //memmove(array, &len, sizeof(len)); + + array += sizeof(int); + if (0 != len) + { + *str = (char*)MCMemAlloc(len+1); + memmove(*str, array, len); + (*str)[len] = 0; + array += len; + } + return array; +} + +bool MCInetTransportJob::ParseRoutingStrings(char* s, char* *outS, char* TransactCmd, char** RouteTo, + char** RecvPath, char** DQueue) +{ + MCASSERT(NULL != s); + MCASSERT(NULL != outS); + MCASSERT(NULL != TransactCmd); + MCASSERT(NULL != RouteTo); + MCASSERT(NULL != RecvPath); + MCASSERT(NULL != DQueue); + + //unsigned int i = 0; + char* p = s + strlen(s) + 1; + + //get the right SMessenger + *outS = (char*)MCMemAlloc(strlen(s)+1); + strcpy(*outS, s); + + //read the transact cmd + *TransactCmd = *p++; + + //read the RecvPath + p = ReadStringFromArray(p, RecvPath); + //read the RouteTo + p = ReadStringFromArray(p, RouteTo); + //read the DQueue + p = ReadStringFromArray(p, DQueue); + + return true; +} + +bool MCInetTransportJob::ReadHeader(MCInetHeader* Header, char** s, char* TransactCmd, + char** RouteTo, char** RecvPath, char** DQueue) +{ + MCASSERT(NULL != Header); + MCASSERT(NULL != s); + MCASSERT(NULL != TransactCmd); + MCASSERT(NULL != RouteTo); + MCASSERT(NULL != RecvPath); + MCASSERT(NULL != DQueue); + + MCStream* inStream = FEntry->getIncomingStream(); + + // read the header and smessenger + inStream->Read(Header, sizeof(*Header)); + + unsigned long SMsgLen = 0; + // read the source messenger name + if (inStream->Read(&SMsgLen, sizeof(SMsgLen)) < sizeof(SMsgLen)) + { + MCASSERT(0); + } + + if((SMsgLen > 0) && (long) SMsgLen < (Min(0x7FFFDFFF, FOwner->getMaxMsgSize()) + 8192)) + { + *s = (char*)MCMemAlloc(SMsgLen + 1); + if (inStream->Read(*s, SMsgLen) != (long)SMsgLen) + { + MCASSERT(0); + } + (*s)[SMsgLen] = 0; + + char* newS = NULL; + if (strlen(*s) < SMsgLen) //is there routing/transaction info? + { + if (false == ParseRoutingStrings(*s, &newS, TransactCmd, RouteTo, RecvPath, DQueue)) + return false; + MCASSERT(NULL != newS); + MCMemFree(*s); *s = NULL; + *s = newS; + } + else + ; + } + else + { + MCASSERT(0); + *s = NULL; + } + MCASSERT(*s != NULL); + return true; +} + +bool MCInetTransportJob::UpdateEntry(char* *s, char **OriginalSMsg) +{ + MCASSERT(NULL != OriginalSMsg); + MCASSERT(NULL != s); + MCASSERT(NULL != *s); + + long ClientID = 0, ConnID = 0; + int Port = 0; + char* IP = NULL; + // what's this? + *OriginalSMsg = strdup(*s); //just store original SMessenger + + //ok, let's parse the incoming SMessenger + bool IsRemoteAddr = ParseRemoteAddr(*s, &ClientID, &ConnID, &IP, &Port); + if (ClientID != 0) + { + if (FEntry->getClientID() == 0) + { + FEntry->setClientID(ClientID); + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Last ClientID is uploaded from incoming packet.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + } + /* + else + if (FEntry->getClientID() != ClientID) + THROW_ERROR(MCError_InvalidSignature); + */ + } + else + { + if (FEntry->getClientID() == 0) + { + FEntry->setClientID(CreateUniqueID()); + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"New ClientID is generated .\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, GetTickCount()); + } + else + ; + } + + MCMemFree(*s); *s = NULL; + + //update the RemoteAddress + if (true == IsRemoteAddr) + { + if (strcmp(IP, "0.0.0.0") != 0) + { + *s = CreateSMessenger(FEntry->getClientID(), FEntry->getConnID(), IP, Port); + } + else + {//.NET bug workaround + char* OldIP = NULL; + long OldClientID = 0; + long OldConnID = 0; + int OldPort = 0; + ParseRemoteAddr(FEntry->getRemoteAddress(), &OldClientID, &OldConnID, &OldIP, &OldPort); + + *s = CreateSMessenger(FEntry->getClientID(), FEntry->getConnID(), OldIP, Port); + } + } + else + *s = CreateSMessenger(FEntry->getClientID(), FEntry->getConnID(), NULL, 0); + MCMemFree(IP); IP = NULL; + FEntry->setRemoteAddress(*s); + MCASSERT(*s); + return true; +} + +bool MCInetTransportJob::PrepareRouting(char* s, char* OriginalSMsg, char** RecvPath) +{ + char* tmpPath = NULL; + int npl = 0; + if (*RecvPath != NULL) + { + npl = strlen(FOwner->RealTransportName()) + 1 + strlen(s) + 1 + strlen(*RecvPath) + 1; + tmpPath = (char*)MCMemAlloc(npl); + tmpPath[0] = 0; + strcpy(tmpPath, FOwner->RealTransportName()); strcat(tmpPath, ":"); + strcat(tmpPath, s); strcat(tmpPath, "|"); strcat(tmpPath, *RecvPath); + MCMemFree(*RecvPath); + *RecvPath = tmpPath; + } + else + { + npl = strlen(FOwner->RealTransportName()) + 1 + strlen(s) + 1; + tmpPath = (char*) MCMemAlloc(npl); + tmpPath[0] = 0; + strcpy(tmpPath, FOwner->RealTransportName()); strcat(tmpPath, ":"); + strcat(tmpPath, s); + *RecvPath = tmpPath; + } + +//$ifdef MC_COMMERCIAL + if (!FOwner->FRoutingEnabled) +//$endif MC_COMMERCIAL + { + PutErrorPacket(OriginalSMsg, s, *RecvPath, 0, MCError_RoutingNotAllowed); + return false; + } + return true; + +} + +//don't forget to not free DMessenger and SMessenger +void MCInetTransportJob::PutErrorPacket(char* DMessenger, char* SMessenger, char* RecvPath, __int64 MsgID, long Error) +{ + MCMessage Message; + Message.Data = NULL; + Message.DataType = bdtConst; + Message.Result = 0; + Message.Param1 = 0; + Message.Param2 = 0; + Message.MsgID = 0; + + MCMessageInfo *Info = new MCMessageInfo(&Message); + Info->setDMessenger(DMessenger); + Info->setSMessenger(SMessenger); + MCMessenger::SetMessageID(Info); + Info->MCError = Error; + Info->State = imsFailed; + Info->StartTime = GetTickCount(); + Info->Timeout = FOwner->FMsgTimeout; + Info->OrigID = MsgID; +//$ifdef MC_COMMERCIAL + if (RecvPath) + Info->setRecvPath(RecvPath); + else + Info->setRecvPath(NULL); +//$endif MC_COMMERCIAL + FOutgoingQueue.Add(Info); +} + +MCMessageInfo* MCInetTransportJob::LoadAndUnpackMessage(MCInetHeader* Header, void** DataBuf, + long* DataLen, MCMemStream** AStream, + char* s, char* SMsg, char TransactCmd, + char* RecvPath) +{ + MCASSERT(NULL != Header); + MCASSERT(NULL != DataBuf); + MCASSERT(NULL != DataLen); + MCASSERT(NULL != AStream); + MCASSERT(NULL != s); + MCASSERT(NULL != SMsg); + + *AStream = NULL; *DataBuf = NULL; *DataLen = 0; + + bool res = false; + MCMessageInfo* Info = NULL; + int Port; + char* IP; + char* s1; + long ClientID; + long ConnID; + + MCStream* inStream = FEntry->getIncomingStream(); + + if (inStream->Pos() >= inStream->Len()) + return NULL; //there is no real message + + *DataLen = inStream->Len() - inStream->Pos(); //find message's size + *DataBuf = MCMemAlloc(*DataLen); //alloc mem for message + //if(NULL == DataBuf) + // THROW_ERROR(MCError_NotEnoughMemory); + + TRY_BLOCK + { + // read the data + inStream->Read(*DataBuf, *DataLen); + // decode the message + ParseRemoteAddr(s, &ClientID, &ConnID, &IP, &Port); + s1 = (char*)MCMemAlloc(strlen(IP) + 20); + sprintf(s1, "%s:%d", IP, Port); + MCMemFree(IP); + if(FOwner->UnprepareDataBlock(s1, *DataBuf, *DataLen, *DataBuf, *DataLen, FEntry->getEncryptID(), FEntry->getCompressID(), FEntry->getSealID())) + { + // decoding was successful + + *AStream = new MCMemStream(); + (*AStream)->SetPointer((char*)*DataBuf, *DataLen); + + MCMessage Message; Message.DataSize = 0; + Info = new MCMessageInfo(&Message); + Info->setSMessenger(SMsg); + Info->setDMessenger(s); + Info->Track = FEntry;//this; + Info->Timeout = FOwner->FMsgTimeout; +//$ifdef MC_COMMERCIAL + Info->TransactCmd = (MCTransactCmd) TransactCmd; + if (RecvPath) + Info->setRecvPath(strCopy(RecvPath, 0)); + else + Info->setRecvPath(NULL); +//$endif MC_COMMERCIAL + Info->LoadFromStream(*AStream); + res = true; + } + else + res = false; + MCMemFree(s1); + } + CATCH_EVERY + { + res = false; + } + if (false == res) + { + if (*AStream) + { + delete *AStream; *AStream = NULL; + } + MCMemFree(*DataBuf); *DataBuf = NULL; *DataLen = 0; + delete Info; Info = NULL; + } + return res ? Info : NULL; +} + +bool MCInetTransportJob::HandleEmptyRequest(MCMessageInfo* Info, MCMemStream* AStream) +{ + FEntry->getCS()->Leave(); + FOwner->FCriticalSection->Enter(); + FEntry->getCS()->Enter(); + TRY_BLOCK + { + int i = 0; + while (iFOutgoingQueue->Length()) + { + MCMessageInfo* pInfo = (MCMessageInfo*)(*FOwner->FOutgoingQueue)[i]; + if ((pInfo->ClientID == FEntry->getClientID()) || ((pInfo->ClientID == 0) && FOwner->CompareAddress(pInfo->SMessenger, FEntry->getRemoteAddress(), false))) + { + FOwner->FOutgoingQueue->Del(pInfo); + FOutgoingQueue.Add(pInfo); + } + else + i++; + } + if (FOutgoingQueue.Length() == 0) + FOutgoingQueue.Add(MakeEmptyPacket(imsEmptyReply)); + } + FINALLY + ( + FEntry->getCS()->Leave(); + FOwner->FCriticalSection->Leave(); + FEntry->getCS()->Enter(); + delete Info; Info = NULL; + ) + + return true; +} + +bool MCInetTransportJob::HandleEmptyReply(MCMessageInfo* Info, MCMemStream* AStream) +{ + //find request + // remove the message from the list of pending messages + /* + MCMessageInfo* CurInfo = NULL; + int i = -1; + + for(i = 0;i < FOutgoingQueue.Length();i++) + if(((MCMessageInfo*)FOutgoingQueue[i])->OrigID == Info->OrigID) + { + CurInfo = (MCMessageInfo*)FOutgoingQueue[i]; + FOutgoingQueue.Del(i); + break; + } + + delete CurInfo; CurInfo = NULL; + */ + delete Info; Info = NULL; + + return true; +} + +bool MCInetTransportJob::HandleDispatching(MCMessageInfo* Info, MCMemStream* AStream, char* RecvPath) +{ + MCMessenger::SetMessageID(Info); + + if(AStream->Len() - AStream->Pos() < Info->Message.DataSize) + {//we've got corrupted packet + if(Info->IsSendMsg && (!getTerminated())) + PutErrorPacket(Info->DMessenger, Info->SMessenger, RecvPath, Info->OrigID, MCError_GenTransportFailure); + else + { //just drop this packet + delete Info; + Info = NULL; + } + } + else + { + if(Info->Message.DataSize > 0) + { + Info->Message.Data = MCMemAlloc(Info->Message.DataSize); + AStream->Read(Info->Message.Data, Info->Message.DataSize); + } + else + Info->Message.Data = NULL; + + } + FEntry->getCS()->Leave(); + FOwner->MessageReceived(Info); + FEntry->getCS()->Enter(); + + return true; +} + +bool MCInetTransportJob::HandleReply(MCMessageInfo* Info, MCMemStream* AStream) +{ + // remove the message from the list of pending messages + MCMessageInfo* CurInfo = NULL; + int i = -1; + + for(i = 0;i < FOutgoingQueue.Length();i++) + if(((MCMessageInfo*)FOutgoingQueue[i])->OrigID == Info->OrigID) + { + CurInfo = (MCMessageInfo*)FOutgoingQueue[i]; + FOutgoingQueue.Del(i); + break; + } + + if(NULL == CurInfo) + {// the message was cancelled + } + else + { + // we have to copy result data and signal about reply + if (bdtConst != CurInfo->Message.DataType) + { + if(NULL != CurInfo->Message.Data) + {//free old (request) data + MCMemFree(CurInfo->Message.Data); + CurInfo->Message.Data = NULL; + CurInfo->Message.DataSize = 0; + } + // read the resulting data from the stream + CurInfo->Message.DataSize = Info->Message.DataSize; + if(CurInfo->Message.DataSize > 0) + { + CurInfo->Message.Data = MCMemAlloc(CurInfo->Message.DataSize); + AStream->Read(CurInfo->Message.Data, Info->Message.DataSize); + } + else + CurInfo->Message.Data = NULL; + + // reset fields in Info + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + + CurInfo->Message.Result = Info->Message.Result; + CurInfo->MCError = Info->MCError; + CurInfo->State = Info->State; + FOwner->ReplyReceived(CurInfo); + } + delete Info; Info = NULL; + + return true; +} + +bool MCInetTransportJob::HandleUnknown(MCMessageInfo* Info, MCMemStream* AStream) +{ + delete Info; Info = NULL; + return true; +} + +void MCInetTransportJob::UpdateRemoteSAddress(MCMessageInfo* Info) +{ + if (NULL != Info->SMessenger) + { + long ClientID1 = 0, ConnID1; + int Port1 = 0; + char* IP1 = NULL; + + bool res1 = ParseRemoteAddr(Info->SMessenger, &ClientID1, &ConnID1, &IP1, &Port1); + char buf[128]; + if (res1) + sprintf(buf, "%d:%d:%s:%d", FEntry->getClientID(), FEntry->getConnID(), IP1, Port1); + else + sprintf(buf, "%d:%d", FEntry->getClientID(), FEntry->getConnID()); + FEntry->setRemoteSAddress(buf); + Info->setSMessenger(buf); + MCMemFree(IP1); + } + +} + +bool MCInetTransportJob::MessageReceivedCompletely2(void) +{ + MCInetHeader Header; + char* s = NULL, *RouteTo = NULL, *RecvPath = NULL, *DQueue = NULL, *OriginalSMsg = NULL; + char TransactCmd = 0; + void *DataBuf = NULL; long DataLen = 0; MCMemStream *AStream = NULL; + + bool res = false; + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if (IsMessageFetched()) + { + FEntry->getIncomingStream()->SetPos(0); + if (ReadHeader(&Header, &s, &TransactCmd, &RouteTo, &RecvPath, &DQueue)) + { + UpdateEntry(&s, &OriginalSMsg); + MCASSERT(OriginalSMsg != NULL); + + if (NULL != RouteTo) //should we route this message? + PrepareRouting(s, OriginalSMsg, &RecvPath); + else + { + if (!IsTransformerOK(&Header)) + PutErrorPacket(OriginalSMsg, s, RecvPath, 0, MCError_NoTransformer); + FEntry->setSealID(Header.dwSealID); + FEntry->setCompressID(Header.dwCompressID); + FEntry->setEncryptID(Header.dwEncryptID); + } + + MCMessageInfo* Info = LoadAndUnpackMessage(&Header, &DataBuf, &DataLen, &AStream, s, OriginalSMsg, TransactCmd, RecvPath); + + //update Entry->RemoteSAddress for server connections + + + if (NULL != Info) + { + if (FTransporter->getDirection() == isdIncoming) + UpdateRemoteSAddress(Info); + + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Incoming message with type %d.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, + // GetTickCount(), Info->State); + + MCMessageState State = Info->State; + + TRY_BLOCK + { + Info->ConnID = FEntry->getConnID(); + Info->ClientID = FEntry->getClientID(); + + switch (Info->State) + { + case imsEmptyRequest: + res = HandleEmptyRequest(Info, AStream); + break; + + case imsEmptyReply: + res = HandleEmptyReply(Info, AStream); + break; + + case imsDispatching: + res = HandleDispatching(Info, AStream, RecvPath); + break; + + case imsComplete: + case imsFailed: + res = HandleReply(Info, AStream); + break; + default: + res = HandleUnknown(Info, AStream); + } + } + CATCH_EVERY + { + res = false; + } + if (res) + FLastMsgRecvState = State; + + delete AStream; AStream = NULL; + MCMemFree(DataBuf); DataBuf = NULL; DataLen = 0; + } + } + if (NULL != FEntry) + { + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + FEntry->setMsgSize(0); + } + setIsReceiving(false); + } + } + FINALLY( + FEntry->getCS()->Leave(); + ) + } + CATCH_EVERY + { + res = false; + } + + MCMemFree(s); s = NULL; + MCMemFree(RouteTo); RouteTo = NULL; + MCMemFree(RecvPath); RecvPath = NULL; + MCMemFree(DQueue); DQueue = NULL; + MCMemFree(OriginalSMsg); OriginalSMsg = NULL; + + return res; +} + +void WriteStringToStream(MCStream* stream, char* str) +{ + int len = NULL != str ? strlen(str) : 0; + stream->Write(&len, sizeof(len)); + if (0 != len) + stream->Write(str, len); +} + +bool MCInetTransportJob::PrepareMessageForSending(void) +{ + long i = 0, j = 0; + MCMessageInfo* Info = NULL; + MCMemStream* MemStream = NULL; + void* DataBuf = NULL; + long DataLen = 0; + MCInetHeader Header; + char* s = NULL; + bool r = false, immExit = false, im = false, wrt = false; + int extra = 0; + unsigned char bt = 0; + int Port; + char* IP; + long ClientID, ConnID; + + TRY_BLOCK + { + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if(!FEntry->getInfo()) + { + FEntry->setInfo(GetMessageForDelivery()); + if(!FEntry->getInfo()) + { + r = false; immExit = true; + } + if (false == immExit) + FEntry->getInfo()->OldState = FEntry->getInfo()->State; + //FEntry->setInfoState(FEntry->getInfo()->State); + } + + if (false == immExit) + { + Info = FEntry->getInfo(); + s = CreateSMessenger(FEntry->getClientID(), FEntry->getConnID(), FTransporter->getLocalAddress(), FOwner->getMessengerPort()); + Info->setSMessenger(s); + MCMemFree(s); s = NULL; + + + FEntry->getInfo()->State = FEntry->getInfo()->OldState;//= FEntry->getInfoState(); + // write data for conversion + MemStream = new MCMemStream(); + + im = false; +//$ifdef MC_COMMERCIAL + if (Info->EncodedMsg != NULL) + im = true; + + if (!im) +//$endif + { + Info->WriteToStream(MemStream); + if(Info->Message.DataSize > 0) + MemStream->Write(Info->Message.Data, Info->Message.DataSize); + } + + //FEntry->setInfoState(FEntry->getInfo()->State); + Info->OldState = Info->State; + Info->State = imsWaiting; + +//$ifdef MC_COMMERCIAL + if (im) + { + DataLen = Info->EncodedLen; + DataBuf = Info->EncodedMsg; + Info->EncodedMsg = NULL; + Info->EncodedLen = 0; + } + else +//$endif + { + + DataLen = MemStream->Len(); + DataBuf = MCMemAlloc(DataLen); + MemStream->SetPos(0); + MemStream->Read(DataBuf, DataLen); + MemStream->SetPointer(NULL, 0); + + // prepare data block + IP = NULL; + ParseRemoteAddr(Info->DMessenger, &ClientID, &ConnID, &IP, &Port); + if (IP != NULL) + { + s = (char*)MCMemAlloc(strlen(IP) + 20); + sprintf(s, "%s:%d", IP, Port); + MCMemFree(IP); + } + else + { + s = (char*)MCMemAlloc(1); + s[0] = 0; + } + + FOwner->PrepareDataBlock(s, DataBuf, DataLen, DataBuf, DataLen, FEntry->FEncryptID, FEntry->FCompressID, FEntry->FSealID); + MCMemFree(s); + } + + Header.dwSignature = 0x50444945ul; + + Header.dwDataSize = DataLen + sizeof(Header) + strlen(Info->SMessenger) + sizeof(long); + + // this will be used for routing and transactions + extra = 2 + 4 + 4 + 4; + +//$ifdef MC_COMMERCIAL + if (Info->RecvPath) + extra += strlen(Info->RecvPath); + if (Info->RouteTo) + extra += strlen(Info->RouteTo); + if (Info->DQueue) + extra += strlen(Info->DQueue); + if (im) + { + Header.dwCompressID = Info->CompressID; + Header.dwEncryptID = Info->EncryptID; + Header.dwSealID = Info->SealID; + } + else +//$endif MC_COMMERCIAL + { + Header.dwCompressID = FEntry->FCompressID; + Header.dwEncryptID = FEntry->FEncryptID; + Header.dwSealID = FEntry->FSealID; + } + + // this will be used for routing and transactions + Header.dwDataSize += extra; + + // allocate stream for outgoing data + if(FOwner->getUseTempFilesForOutgoing() && (Header.dwDataSize > (long)FOwner->getOutgoingMemoryThreshold())) + { + delete MemStream; MemStream = NULL; + FEntry->setOutgoingStream(new MCTmpFileStream(FOwner->getTempFilesFolder(), Info->Message.MsgID)); + } + else + FEntry->setOutgoingStream(MemStream); + + MCStream* writer = FEntry->getOutgoingStream(); + + // write outgoing data + // write header + writer->Write(&Header, sizeof(Header)); + + // write source address + i = strlen(Info->SMessenger); + j = i; + + // this will be used for routing and transactions + i += extra; + MCASSERT(i != 0); + writer->Write(&i, sizeof(i)); + if(j > 0) + writer->Write(Info->SMessenger, j); + //write zero - end of string + bt = 0; + writer->Write(&bt, sizeof(bt)); + + wrt = false; +//$ifdef MC_COMMERCIAL + //write transact command + bt = (char) Info->TransactCmd; + writer->Write(&bt, sizeof(bt)); + WriteStringToStream(writer, Info->RecvPath); + WriteStringToStream(writer, Info->RouteTo); + WriteStringToStream(writer, Info->DQueue); + wrt = true; +//$else + if (!wrt) + { + //write empty transact command + bt = (char)0; + writer->Write(&bt, sizeof(bt)); + WriteStringToStream(writer, NULL); + WriteStringToStream(writer, NULL); + WriteStringToStream(writer, NULL); + } +//$endif + // write actual data + writer->Write(DataBuf, DataLen); + writer->SetPos(0); + + setIsSending(true); + } + } + FINALLY ( + FEntry->getCS()->Leave(); + ) + if (false == immExit) + { + MCMemFree(DataBuf); + r = true; + } + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + } + CATCH_EVERY + { + } + return r; +} + +bool MCInetTransportJob::MessageSentCompletely(void) +{ + bool r = false; + + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if (FEntry->getOutgoingStream() != NULL) + r = FEntry->getOutgoingStream()->Len() == FEntry->getOutgoingStream()->Pos(); + else + r = false; + + if(r) + { + //ShowDebugInfo("ThreadID=%d, ConnID=%d, ClientID=%d, Dir=%d, Timestamp=%d, \"Message with type %d is sent.\";\n", + // GetCurrentThreadId(), FEntry->getConnID(), FEntry->getClientID(), FTransporter->getDirection() == isdIncoming, + // GetTickCount(), FEntry->getInfo()->OldState); + + + FEntry->setAttempt(0); + TRY_BLOCK + { + MCMessageInfo* Info = FEntry->getInfo(); + Info->Sent = true; + + FLastMsgSendState = Info->OldState; + + // if the message is to be replied, we do nothing + if((Info->OldState == imsDispatching) && Info->IsSendMsg +//$ifdef MC_COMMERCIAL + && (!Info->Intermed) +//$endif + ) + { + FEntry->setInfo(NULL); + } + else + { + MCMessageInfo* pMCInfo = FEntry->getInfo(); + FEntry->setInfo(NULL); + /* + FOwner->FMessenger->FIncomingCriticalSection->Enter(); + TRY_BLOCK + { + FOwner->FMessenger->FIncomingQueue->Del(pMCInfo); + } FINALLY ( + FOwner->FMessenger->FIncomingCriticalSection->Leave(); + ) + */ + // remove the message from the queue + FOutgoingQueue.Del(pMCInfo); + // destroy message info + delete pMCInfo; pMCInfo = NULL; + } + } FINALLY ( + delete FEntry->getOutgoingStream(); + FEntry->setOutgoingStream(NULL); + setIsSending(false); + ) + } + } FINALLY ( + FEntry->getCS()->Leave(); + ) + } + CATCH_EVERY + { + } + return r; +} + +/* +int MCInetTransportJob::ExtractClientID(const char* S) +{ + int res = 0; + ParseRemoteAddr(S, &res, NULL, NULL); + return res; +} +*/ +/* +char* MCInetTransportJob::UpdateClientID(const char* S, int ID) +{ + int ClientID = 0, Port = 0; + char* IP = NULL; + char* res = (char*)MCMemAlloc(strlen(S) + 20); + if (ParseRemoteAddr(S, &ClientID, &IP, &Port) == true) + sprintf(res, "%d:%s:%d", ID, IP, Port); + else + sprintf(res, "%d", ID); + MCMemFree(IP); + return res; +} +*/ +bool MCInetTransportJob::ParseRemoteAddr(const char* S, long *ClientID, long *ConnID, char** IP, int* Port) +{ + const int BUF_SIZE = 128; + + char cc[BUF_SIZE]; + char pt[8]; + + if (NULL == S) return false; + + if (NULL != ClientID) + *ClientID = 0; + + if (NULL != ConnID) + *ConnID = 0; + + cc[0] = 0; + + char* p2 = NULL; + char* p1 = strchr((char *) S, ':'); + char *p3 = NULL; + bool res = false; + + if (NULL != p1) + { + p2 = strchr(p1+1, ':'); + if (NULL != p2) + { + p3 = strchr(p2 + 1, ':'); + if (p3 == NULL) + { + p3 = p1; + } + else + { + p3 = p2; + p2 = strchr(p2 + 1, ':'); + } + // set cc + memset(cc, 0, sizeof(cc)); + strncpy(cc, S, p3-S); + cc[p3-S] = 0; + + if (NULL != IP) + { + *IP = (char*)MCMemAlloc(p2 - p3); + memset(*IP, 0, p2 - p3); + strncpy(*IP, p3 + 1, p2 - p3 - 1); + //*IP[p2-p1-1] = 0; + } + if (NULL != Port) + { + strcpy(pt, p2+1); + *Port = atoi(pt); + } + res = true; + } + else + { + if (p1 != (S + strlen(S)-1)) + {//extract IP + if (NULL != IP) + { + *IP = (char*)MCMemAlloc(p1 - S + 1); + memset(*IP, 0, p1 - S + 1); + strncpy(*IP, S, p1 - S); + } + if (NULL != Port) + { + strcpy(pt, p1 + 1); + *Port = atoi(pt); + } + res = true; + } + else // extract ClientID + { + memset(cc, 0, sizeof(cc)); + strncpy(cc, S, p1-S); + res = false; + } + } + } + else + { + memset(cc, 0, sizeof(cc)); + strcpy(cc, S); + res = false; + } + if (cc[0] != 0) + { + p1 = strchr((char *) cc, ':'); + p2 = p1 + 1; + if (p1 != NULL) + { + *p1 = 0; + if ((p1 - cc) > 0) + { + + if (ClientID != NULL) + *ClientID = atoi(cc); + } + if (*p2 != 0) + { + if (ConnID != NULL) + *ConnID = atoi(p2); + } + } + else + { + p1 = strchr((char *) cc, '\\'); + p2 = p1 + 1; + if (p1 == NULL) + { + if (ClientID != NULL) + *ClientID = atoi(cc); + } + else + { + *p1 = 0; + if ((p1 - cc) > 0) + { + + if (ClientID != NULL) + *ClientID = atoi(cc); + } + if (*p2 != 0) + { + if (ConnID != NULL) + *ConnID = atoi(p2); + } + } + } + } + return res; +} + +void MCInetTransportJob::ChangeLastSendTime(MCMessageState state) +{ + FActivityTime = GetTickCount(); + FLastMsgSendTime = FActivityTime; +} + +void MCInetTransportJob::ChangeLastRecvTime(MCMessageState state) +{ + FActivityTime = GetTickCount(); + FLastMsgRecvTime = FActivityTime; +} + +bool MCInetTransportJob::IsTransformerOK(MCInetHeader* Header) +{ + if (FTransporter->getDirection() == isdIncoming) + { + FOwner->FLinkCriticalSection->Enter(); + FEntry->setCompressID(0); + FEntry->setSealID(0); + FEntry->setEncryptID(0); + FEntry->setRejectedTransformer(false); + + if (0 != Header->dwCompressID) + { + if (NULL != FOwner->getCompressor()) + { + if (FOwner->getCompressor()->GetID() == Header->dwCompressID) + FEntry->setCompressID(Header->dwCompressID); + else + FEntry->setRejectedTransformer(true); + } else + FEntry->setRejectedTransformer(true); + } + + if (0 != Header->dwEncryptID) + { + if (NULL != FOwner->getEncryptor()) + { + if (FOwner->getEncryptor()->GetID() == Header->dwEncryptID) + FEntry->setEncryptID(Header->dwEncryptID); + else + FEntry->setRejectedTransformer(true); + } else + FEntry->setRejectedTransformer(true); + } + + if (0 != Header->dwSealID) + { + if (NULL != FOwner->getSealer()) + { + if (FOwner->getSealer()->GetID() == Header->dwSealID) + FEntry->setSealID(Header->dwSealID); + else + FEntry->setRejectedTransformer(true); + } else + FEntry->setRejectedTransformer(true); + } + FOwner->FLinkCriticalSection->Leave(); + return !FEntry->getRejectedTransformer(); + } + else + return true; + +} + +bool MCInetTransportJob::getIsReceiving(void) +{ + return FIsReceiving; +} + +void MCInetTransportJob::setIsReceiving(bool Value) +{ + FIsReceiving = Value; + if (Value == false && FEntry != NULL) + FEntry->setMsgSize(0); +} + +bool MCInetTransportJob::getIsSending(void) +{ + return FIsSending; +} + +void MCInetTransportJob::setIsSending(bool Value) +{ + FIsSending = Value; +} + +MCInetConnectionEntry* MCInetTransportJob::getEntry(void) +{ + return FEntry; +} + +void MCInetTransportJob::setEntry(MCInetConnectionEntry* Value) +{ + FEntry = Value; +} + +MCInetTransport* MCInetTransportJob::getOwner(void) +{ + return FOwner; +} + +void MCInetTransportJob::setOwner(MCInetTransport* Value) +{ + FOwner = Value; +} + +MCSocket* MCInetTransportJob::getTransporter(void) +{ + return FTransporter; +} + +void MCInetTransportJob::setTransporter(MCSocket* Value) +{ + if(FTransporter != Value) + { + delete FTransporter; + FTransporter = Value; + } +} + +MCList* MCInetTransportJob::getOutgoingQueue(void) +{ + return &FOutgoingQueue; +} + +void MCInetTransportJob::AdjustSpeedLimits(unsigned long Incoming, unsigned long Outgoing) +{ + FIncomingSpeedLimit = Incoming; + FOutgoingSpeedLimit = Outgoing; +} + +void MCInetTransportJob::AdjustBufferSize(unsigned long Incoming, unsigned long Outgoing) +{ + if (FIncomingBuffer) + MCMemFree(FIncomingBuffer); + FIncomingBuffer = NULL; + FIncomingBufferSize = Incoming; + FIncomingBuffer = (unsigned char *) MCMemAlloc(Incoming); + + if (FOutgoingBuffer) + MCMemFree(FOutgoingBuffer); + FOutgoingBuffer = NULL; + FOutgoingBufferSize = Outgoing; + FOutgoingBuffer = (unsigned char *) MCMemAlloc(Outgoing); + + FblToSend = FOutgoingBufferSize; + FblToRecv = FIncomingBufferSize; +} + +bool MCInetTransportJob::InitializeConnection() +{ + FActivityTime = GetTickCount(); + FLastMsgRecvTime = FActivityTime; + FLastMsgSendTime = FActivityTime; + FblInSessionStartTime = FActivityTime; + FblOutSessionStartTime = FActivityTime; + + FblInSessionTransferred = 0; + FblOutSessionTransferred = 0; + + FblInMsgStartTime = 0; + FblOutMsgStartTime = 0; + FblInMsgTransferred = 0; + FblOutMsgTransferred = 0; + + FServerRequestTime = 0; + + bool result = true; + void* UserData; + if (FOwner->getOnConnected(&UserData) != NULL) + (FOwner->getOnConnected())(UserData, FOwner, FTransporter->getDirection(), FTransporter->getRemoteAddress(), FTransporter->getRemotePort(), result); + return result; +} + +void MCInetTransportJob::FinalizeConnection() +{ + void* UserData; + if (FOwner->getOnDisconnected(&UserData) != NULL) + (FOwner->getOnDisconnected())(UserData, FOwner, FTransporter->getDirection(), FTransporter->getRemoteAddress(), FTransporter->getRemotePort()); +} + + +// ************************** MCInetListenerJob ************************** + +MCInetListenerJob::MCInetListenerJob(void) +{ + FInitialized = false; + FOwner = NULL; + FListener = NULL; + FSocket = NULL; +} + + +MCInetListenerJob::~MCInetListenerJob(void) +{ + if(FListener) + { + FListener->Close(false); + delete FListener; + } + FListener = NULL; + //printf("Listener is destroyed\n"); +} + +bool MCInetListenerJob::AcceptConnection(void) +{ + MCSocket* NewSocket = NULL; + MCInetConnectionEntry* NewEntry = NULL; + MCInetTransportJob* NewJob = NULL; + char* s = NULL; + bool r = false; + + assert(FListener != NULL); + if(FListener->getState() != issListening) + return false; + + NewSocket = FListener->Accept(); + if(NewSocket) + { + // Add objects to owner's list + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + + MCInetTransportJob* NewJob = FOwner->CreateTransportJob(); + NewJob->setJobName("Server worker job"); + NewJob->setOwner(FOwner); + NewJob->Initialize2(NewSocket, FOwner->CreateConnectionEntry()); + NewEntry = NewJob->getEntry(); + //ShowDebugInfo("ThreadID=%d, ConnID=none, ClientID=none, Dir=accepting, Timestamp=%d, \"New connection is accepted.\";\n", + // GetCurrentThreadId(), GetTickCount()); + + + //create remote address + s = (char*)MCMemAlloc(strlen(NewSocket->getRemoteAddress()) + 20); + sprintf(s, "%s:%d", NewSocket->getRemoteAddress(), NewSocket->getRemotePort()); + NewEntry->setRemoteAddress(s); + MCASSERT(s); + + MCMemFree(s); + + + + //NewEntry->setSocket(NewSocket); + NewEntry->setLastActionTime(GetTickCount()); + NewEntry->setProcessingJob(NewJob); + + //NewEntry->getCS()->Enter(); + FOwner->FConnections->Add(NewEntry); + //NewEntry->getCS()->Leave(); + //just for experiment - start +#ifdef _WIN32 + u_long enableNonBlocking = 1; + if (0 != ioctlsocket(NewJob->getTransporter()->getSocket(), FIONBIO, &enableNonBlocking)) + RETURN_EXCEPT; +#endif + //just for experiment - finish + FOwner->FThreadPool.PostJob(NewJob); + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + r = true; + } + else + r = false; + return r; +} + +#define RETURN_MESSAGE(x) +//OutputDebugString(x); return + +void MCInetListenerJob::Run(void) +{ + fd_set FDRecvSet; + long select_res; + + while(!getTerminated()) + { + TRY_BLOCK + { + FD_ZERO(&FDRecvSet); + FD_SET((unsigned long)FSocket->getSocket(), &FDRecvSet); + FD_SET((unsigned long)FListener->getSocket(), &FDRecvSet); + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 500000; +#ifdef __GNUC__ + select_res = select(FD_SETSIZE, &FDRecvSet, NULL, NULL, &tv); +#else + select_res = select(2, &FDRecvSet, NULL, NULL, &tv); +#endif + switch(select_res) + { + case 0: // timeout elapsed? OS error. Something's wrong in the world today... + continue; + default: + if (!getTerminated()) + { + if (FD_ISSET(FListener->getSocket(), &FDRecvSet)) + { + if (false == AcceptConnection()) + { + return; //finish job + } + else + continue; + } + else + return; //finish job + } else + return; //finish job + } + } + CATCH_EVERY + { + } + } +} + +void MCInetListenerJob::Initialize(MCSocket *ASocket) +{ + MCSocketJob::Initialize(); + FListener = ASocket; + FListener->setLocalAddress(FOwner->getMessengerAddress()); + FListener->setLocalPort(FOwner->getMessengerPort()); + WinsockErrorCheck(FListener->Init(istStream)); + if (FOwner->getReuseServerPort()) + WinsockErrorCheck(FListener->ReusePort()); + WinsockErrorCheck(FListener->Bind()); + WinsockErrorCheck(FListener->Listen(SOMAXCONN)); + FInitialized = true; +} + +void MCInetListenerJob::setOwner(MCInetTransport* Value) +{ + FOwner = Value; +} + +// ************************** MCInetConnectionEntry ************************* + +MCInetConnectionEntry::MCInetConnectionEntry(void) +{ + FCS = new MCCriticalSection(); + FEncryptID = -1; + FCompressID = -1; + FSealID = -1; + FAttempt = 0; + FCancelID = 0; + FIncomingStream = NULL; + FInfo = NULL; + //FInfoState = (MCMessageState)0; + FLastActionTime = 0; + FMsgSize = 0; + FOutgoingStream = NULL; + FProcessingThread = NULL; + FRemoteAddress = NULL; + FRemoteSAddress = NULL; + FClientID = 0; + FConnID = CreateUniqueID(); +} + +MCInetConnectionEntry::~MCInetConnectionEntry(void) +{ + //FCS->Enter(); + delete FIncomingStream; + delete FOutgoingStream; + if (FRemoteAddress) + MCMemFree(FRemoteAddress); + FRemoteAddress = NULL; + if (FRemoteSAddress) + MCMemFree(FRemoteSAddress); + FRemoteSAddress = NULL; + delete FCS; FCS = NULL; +} + +void MCInetConnectionEntry::Reset(void) +{ + FCS->Enter(); + delete FIncomingStream; + FIncomingStream = NULL; + delete FOutgoingStream; + FOutgoingStream = NULL; + FAttempt = 0; + FCancelID = 0; + FEncryptID = -1; + FCompressID = -1; + FSealID = -1; + FMsgSize = 0; + FInfo = NULL; + if (NULL != FRemoteAddress) + FRemoteAddress[0] = 0; + if (NULL != FRemoteSAddress) + FRemoteSAddress[0] = 0; + FCS->Leave(); +} + +void MCInetConnectionEntry::setAttempt(long Value) +{ + FAttempt = Value; +} + +long MCInetConnectionEntry::getAttempt(void) +{ + return FAttempt; +} + +void MCInetConnectionEntry::setCancelID(__int64 Value) +{ + FCancelID = Value; +} + +__int64 MCInetConnectionEntry::getCancelID(void) +{ + return FCancelID; +} + +void MCInetConnectionEntry::setCompressID(long Value) +{ + FCompressID = Value; +} + +long MCInetConnectionEntry::getCompressID(void) +{ + return FCompressID; +} + +MCCriticalSection* MCInetConnectionEntry::getCS(void) +{ + return FCS; +} + +void MCInetConnectionEntry::setEncryptID(long Value) +{ + FEncryptID = Value; +} + +long MCInetConnectionEntry::getEncryptID(void) +{ + return FEncryptID; +} + +void MCInetConnectionEntry::setIncomingStream(MCStream* Value) +{ + FIncomingStream = Value; +} + +MCStream* MCInetConnectionEntry::getIncomingStream(void) +{ + return FIncomingStream; +} + +void MCInetConnectionEntry::setInfo(MCMessageInfo* Value) +{ + FInfo = Value; +} + +MCMessageInfo* MCInetConnectionEntry::getInfo(void) +{ + return FInfo; +} + +/* +void MCInetConnectionEntry::setInfoState(MCMessageState Value) +{ + FInfoState = Value; +} + +MCMessageState MCInetConnectionEntry::getInfoState(void) +{ + return FInfoState; +} +*/ + +void MCInetConnectionEntry::setLastActionTime(__int64 Value) +{ + FLastActionTime = Value; +} + +__int64 MCInetConnectionEntry::getLastActionTime(void) +{ + return FLastActionTime; +} + +void MCInetConnectionEntry::setMsgSize(long Value) +{ + FMsgSize = Value; +} + +long MCInetConnectionEntry::getMsgSize(void) +{ + return FMsgSize; +} + +void MCInetConnectionEntry::setOutgoingStream(MCStream* Value) +{ + FOutgoingStream = Value; +} + +MCStream* MCInetConnectionEntry::getOutgoingStream(void) +{ + return FOutgoingStream; +} + +void MCInetConnectionEntry::setProcessingJob(MCInetTransportJob* Value) +{ + FProcessingThread = Value; +} + +MCInetTransportJob* MCInetConnectionEntry::getProcessingJob(void) +{ + return FProcessingThread; +} + +void MCInetConnectionEntry::setRemoteAddress(const char* Value) +{ + if(FRemoteAddress) + MCMemFree(FRemoteAddress); + if(Value) + FRemoteAddress = strdup(Value); + else + FRemoteAddress = NULL; +} + +char* MCInetConnectionEntry::getRemoteAddress(void) +{ + return FRemoteAddress; +} + + +void MCInetConnectionEntry::setRemoteSAddress(const char* Value) +{ + if(FRemoteSAddress) + MCMemFree(FRemoteSAddress); + if(Value) + FRemoteSAddress = strdup(Value); + else + FRemoteSAddress = NULL; +} + +char* MCInetConnectionEntry::getRemoteSAddress(void) +{ + return FRemoteSAddress; +} + +void MCInetConnectionEntry::setSealID(long Value) +{ + FSealID = Value; +} + +long MCInetConnectionEntry::getSealID(void) +{ + return FSealID; +} + +int MCInetConnectionEntry::getClientID(void) +{ + return FClientID; +} + +void MCInetConnectionEntry::setClientID(int Value) +{ + FClientID = Value; +} + +bool MCInetConnectionEntry::getRejectedTransformer(void) +{ + return FRejectedTransformer; +} + +void MCInetConnectionEntry::setRejectedTransformer(bool Value) +{ + FRejectedTransformer = Value; +} + +int MCInetConnectionEntry::getReqTime(void) +{ + return FReqTime; +} + +void MCInetConnectionEntry::setReqTime(int ReqTime) +{ + FReqTime = ReqTime; +} + +long MCInetConnectionEntry::getConnID(void) +{ + return FConnID; +} + +void MCInetConnectionEntry::setConnID(long value) +{ + FConnID = value; +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCInetTransport.h b/libraries/external/eldos/pc/include/MCInetTransport.h new file mode 100755 index 0000000..4aa42c8 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCInetTransport.h @@ -0,0 +1,636 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCINETTRANSPORT__ +#define __MCINETTRANSPORT__ + +#include "MC.h" +#include "MCSock.h" +#include "MCBase.h" +#include "MCSyncs.h" +#include "MCThreads.h" +#include "MCStream.h" +#include "MCSocketBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCInetTransport; +class MCInetConnectionEntry; + +typedef void (STDCALLCONV *MCTransformerFailProc)(MCInetTransport* Transport, MCInetConnectionEntry* Entry); + +typedef void (STDCALLCONV *MCSocketConnectedEvent)(void* UserData, void* Sender, + MCSocketDir Direction, const char* RemoteHost, unsigned short Port, bool& AllowConnection); +typedef void (STDCALLCONV *MCSocketDisconnectedEvent)(void* UserData, void* Sender, + MCSocketDir Direction, const char* RemoteHost, unsigned short Port); + +class MCSocket; +class MCInetTransportJob; +class MCInetListenerJob; +class MCInetConnectionEntry; + + +class MCInetTransport: public MCBaseTransport, MCThreadFactory, MCJobErrorHandler { +friend class MCInetTransportJob; +friend class MCInetListenerJob; +friend class MCSocketTransportJob; +friend class MCHttpTransportJob; + +protected: +// static volatile long FConnectionID; + unsigned long FAttemptsInterval; + unsigned long FConnectionTimeout; + unsigned long FAttemptsToConnect; + unsigned long FClientThreadLimit; + MCList* FConnections; + bool FFailOnInactive; + unsigned long FInactivityTime; + unsigned long FIncomingMemoryThreshold; + char* FMessengerAddress; + unsigned int FMessengerPort; + unsigned long FOutgoingMemoryThreshold; + char* FTempFilesFolder; + + unsigned long FThreadPoolSize; + + MCInetTransportMode FTransportMode; + bool FUseTempFilesForIncoming; + bool FUseTempFilesForOutgoing; + int FReqTime; +//$ifdef MC_COMMERCIAL + bool FRoutingEnabled; +//$endif MC_COMMERCIAL + bool FNoTransformerFallback; + + MCThreadPool FThreadPool; + MCTransformerFailProc FTransformerFailProc; + + MCSocketConnectedEvent FOnConnected; + void* FOnConnectedData; + + MCSocketDisconnectedEvent FOnDisconnected; + void* FOnDisconnectedData; + + /* + This event is used to tell the thread about new messages to be delivered. + Also it is used to wake up the waiting thread when it is time to terminate. + */ +// MCHandle OutgoingCount; + /* + Queue of messages pending for delivery. + These messages are delivered to the + recepient Messenger and after that are + moved to SentQueue (or deleted) + */ + MCList* FOutgoingQueue; + + unsigned long FIncomingBufferSize; + unsigned long FOutgoingBufferSize; + + unsigned long FIncomingSpeedLimit; + unsigned long FOutgoingSpeedLimit; + + bool FReuseServerPort; + +//$ifndef LINUX + bool FUseSocks; + char* FSocksServer; + unsigned short FSocksPort; + char* FSocksUserCode;//: ShortString; + char* FSocksPassword;//: ShortString; + MCSocksVersion FSocksVersion; + MCSocksAuthentication FSocksAuthentication; + bool FSocksResolveAddress; +//$endif +protected: + // Web tunneling support + bool FUseWebTunneling; + char *FWebTunnelAddress; + unsigned short FWebTunnelPort; + MCWebTunnelAuthentication FWebTunnelAuthentication; + char *FWebTunnelUserId; + char *FWebTunnelPassword; + +protected: + MCSocketFactory* FDefaultSocketFactory; + MCSocketFactory* FSocketFactory; + MCBandwidthPolicy FBandwidthPolicy; + MCInetListenerJob* FListenerJob; + + virtual void CancelMessage(MCMessageInfo* Info); + virtual MCSocket* CreateClientSocket(void); + virtual MCSocket* CreateServerSocket(void); + virtual MCInetListenerJob* + CreateListenerJob(void); + virtual bool DeliverMessage(char* DestAddress, MCMessageInfo* Info); + virtual void DeliveryFailed(MCMessageInfo* Info); + virtual void DoSetActive(void); + MCInetConnectionEntry* FindEntry(char* SocketName, MCMessageInfo* Info); + void KickEntrySocket(MCInetConnectionEntry* Entry, bool MessageFlag); + virtual void MessageProcessed(MCMessageInfo* Info); + void MessageReceived(MCMessageInfo* Info); + void ReplyReceived(MCMessageInfo* Info); + static bool CompareAddress(const char* Addr1, const char* Addr2, bool Strict); + + virtual MCInetConnectionEntry* + CreateConnectionEntry(void) = 0; + virtual MCInetTransportJob* + CreateTransportJob(void) = 0; + + virtual void GetMessageSource(MCMessageInfo* Info, char* Buffer, int* BufferSize); + virtual void NotifyJob(MCInetTransportJob* Job, bool MessageFlag) = 0; + //virtual void PutReconnectionPacket(void); + //MCMessageInfo* IsAnyMsgForDelivery(void); + bool IsImmediateDelivery(const char* RemAddr); + void PutMessageToOutgoing(const char* SocketName, MCMessageInfo* Info); + virtual bool NeedLiveConnectionForDelivery(void) = 0; + virtual unsigned int getDeliveryInterval(void) = 0; + virtual void CleanupMessages(); + virtual MCMessageInfo* GetMessageByID(__int64 MsgID); +// long GenConnID(void); + + //MCThreadFactory implementation + virtual MCWorkerThread* CreateThread(void); +#ifdef USE_CPPEXCEPTIONS + virtual void HandleError(const EMCError& Error); +#else + virtual void HandleError(unsigned int ErrorCode); +#endif +public: + MCInetTransport(); + virtual ~MCInetTransport(); + bool InitiateDelivery(MCInetTransportJob* Job, MCInetConnectionEntry* Entry); + + virtual int GetIncomingConnectionCount(); + virtual int GetOutgoingConnectionCount(); + +//$ifdef BERND_VERSION + bool IsMessageInTransport( const char* DQueueName ); +//$endif + + virtual long GetOutgoingMessagesCount(); + + unsigned getMessengerPortBound(void); + + /* + ThreadPoolSize defines the number of threads that are kept pre-initialized. + 0 - thread pool is not used + */ + unsigned long getThreadPoolSize(void); + void setThreadPoolSize(unsigned long Value); + + /* + Use ConnectionTimeout property to specify how much time should be spent + trying to establish connection. + Time is expressed in ms. 0 means do not wait. + */ + unsigned long getConnectionTimeout(void); + void setConnectionTimeout(unsigned long Value); + /* + Use AttemptsInterval property to specify how much time should be spent + between attempts to connect to remote side. + Time is expressed in ms. 0 means do not wait. + */ + unsigned long getAttemptsInterval(void); + void setAttemptsInterval(unsigned long Value); + /* + With AttemptsToConnect you specify how much time the thread will try to + connect to the remote side before giving up and marking the messages with + failed status. + 0 means try until all messages are cancelled. + */ + unsigned long getAttemptsToConnect(void); + void setAttemptsToConnect(unsigned long Value); + /* + Use ClientThreadLimit to limit the number of client threads that can be + started at the same time. + 0 - start as many threads as needed. + */ + void setClientThreadLimit(unsigned long Value); + unsigned long getClientThreadLimit(void); + /* + When FailOnInactive is true and Active property is set to false, any + pending messages are canceled and marked as failed. + When FailOnInactive is false, messages are kept in hope for delivery in + future. + */ + void setFailOnInactive(bool Value); + bool getFailOnInactive(void); + /* + Specifies connection inactivity time in milliseconds - time after which + idle connection is disconnected. + Set 0 to wait until socket is closed by the other side. + */ + void setInactivityTime(unsigned long Value); + unsigned long getInactivityTime(void); + /* + Temporary files for incoming data are used when data size exceeds the value + of this property. + If the amount of data to be received is less than threshold, memory stream + is used. + */ + void setIncomingMemoryThreshold(unsigned long Value); + unsigned long getIncomingMemoryThreshold(void); + /* + This address is used to bind the listening socket to. + Use 0 to bind to any address. Use specific IP to bind only to the interface, + to which the address belongs. + */ + void setMessengerAddress(char* Value); + char* getMessengerAddress(void); + /* + The number of the port that the receiver socket will listen. + Used to receive messages from other computers. + */ + void setMessengerPort(unsigned Value); + unsigned getMessengerPort(void); + /* + Temporary files for outgoing data are used when data size exceeds the value + of this property. + If the amount of data to be sent is less than threshold, memory stream is + used. + */ + void setOutgoingMemoryThreshold(unsigned long Value); + unsigned long getOutgoingMemoryThreshold(void); + /* + Defines the folder where temporary files will be stored. If the folder is + not specified, system default folder is used. + */ + void setTempFilesFolder(char* Value); + char* getTempFilesFolder(void); + /* + TransportMode specifies how the connections are established. + In P2P mode connection can be initiated or accepted. This is optimal for + LANs and when both sides are not behind the proxy/firewall. + In server mode connections are only accepted, but not initiated. This mode + is optimal for servers that are supposed to accept connections from clients + which are behind the proxy/firewall. + In client mode connections are only initiated, but not accepted. This mode + is optimal for clients that might work behind the proxy/firewall. + */ + void setTransportMode(MCInetTransportMode Value); + MCInetTransportMode getTransportMode(void); + /* + Defines whether temporary files are used for incoming data. + When UseTempFiles is true, temporary files are placed in the folder defined + by TempFilesFolder. + When UseTempFiles is false, temporary files are not used and the data is + stored in memory. + */ + void setUseTempFilesForIncoming(bool Value); + bool getUseTempFilesForIncoming(void); + /* + Defines whether temporary files are used for outgoing data. + When UseTempFiles is true, temporary files are placed in the folder defined + by TempFilesFolder. + When UseTempFiles is false, temporary files are not used and the data is + stored in memory. + */ + void setUseTempFilesForOutgoing(bool Value); + bool getUseTempFilesForOutgoing(void); + +//$ifdef MC_COMMERCIAL + void setRoutingAllowed(bool Value); + bool getRoutingAllowed(void); +//$endif MC_COMMERCIAL + + /* + Defines whether unprotected data is sent if the parties couldn't agree + on some transformer + */ + void setNoTransformerFallback(bool Value); + bool getNoTransformerFallback(); + + /* + Defines size of incoming buffer + */ + void setIncomingBufferSize(unsigned long Value); + unsigned long getIncomingBufferSize(); + + /* + Defines size of outgoing buffer + */ + void setOutgoingBufferSize(unsigned long Value); + unsigned long getOutgoingBufferSize(); + + /* + Defines bandwidth limitation for inbound traffic + */ + void setIncomingSpeedLimit(unsigned long Value); + unsigned long getIncomingSpeedLimit(); + + /* + Defines bandwidth limitation for outbound traffic + */ + void setOutgoingSpeedLimit(unsigned long Value); + unsigned long getOutgoingSpeedLimit(); + + void setTransformerFailingHandler(MCTransformerFailProc Handler); + MCTransformerFailProc getTransformerFailingHandler(void); +//$ifndef LINUX + void setUseSocks(bool Value); + bool getUseSocks(void); + void setSocksVersion(MCSocksVersion Value); + MCSocksVersion getSocksVersion(void); + void setSocksServer(const char* Value); + const char* getSocksServer(void); + void setSocksPort(unsigned short Value); + unsigned short getSocksPort(void); + void setSocksAuthentication(MCSocksAuthentication Value); + MCSocksAuthentication getSocksAuthentication(void); + void setSocksUserCode(const char* Value); + const char* getSocksUserCode(void); + void setSocksPassword(const char* Value); + const char* getSocksPassword(void); + void setSocksResolveAddress(bool Value); + bool getSocksResolveAddress(void); +//$endif + // Web tunneling support + void setUseWebTunneling(bool Value); + bool getUseWebTunneling(); + void setWebTunnelAddress(const char *Value); + const char* getWebTunnelAddress(); + void setWebTunnelPort(unsigned short Value); + unsigned short getWebTunnelPort(); + MCWebTunnelAuthentication getWebTunnelAuthentication(); + void setWebTunnelAuthentication(MCWebTunnelAuthentication Value); + void setWebTunnelUserId(const char *Value); + const char* getWebTunnelUserId(); + void setWebTunnelPassword(const char *Value); + const char* getWebTunnelPassword(); + + void setReuseServerPort(bool Value); + bool getReuseServerPort(void); + + void setSocketFactory(MCSocketFactory* Value); + MCSocketFactory* getSocketFactory(); + + void setBandwidthPolicy(MCBandwidthPolicy Value); + MCBandwidthPolicy getBandwidthPolicy(); + + MCSocketConnectedEvent getOnConnected(void* *UserData = NULL); + void setOnConnected(MCSocketConnectedEvent Value, void* UserData = NULL); + + MCSocketDisconnectedEvent getOnDisconnected(void* *UserData = NULL); + void setOnDisconnected(MCSocketDisconnectedEvent Value, void* UserData = NULL); + + void DebugBreakConnections(void); +}; + + +class MCInetTransportJob: public MCSocketJob +{ +protected: + MCInetConnectionEntry* FEntry; + bool FHandshakeWaitingReply; + byte* FIncomingBuffer; + byte* FOutgoingBuffer; + unsigned long FIncomingBufferSize; + unsigned long FOutgoingBufferSize; + + // Bandwidth limitation begin + unsigned long FIncomingSpeedLimit; + unsigned long FOutgoingSpeedLimit; + + unsigned long FblInSessionStartTime; + unsigned long FblOutSessionStartTime; + + unsigned long FblInMsgStartTime; + unsigned long FblOutMsgStartTime; + + __int64 FblInSessionTransferred; + __int64 FblOutSessionTransferred; + + __int64 FblInMsgTransferred; + __int64 FblOutMsgTransferred; + + __int64 FblInSecTransferred; + __int64 FblOutSecTransferred; + + unsigned long FblInNextTime; + unsigned long FblOutNextTime; + + unsigned long FblToRecv; + unsigned long FblToSend; + + unsigned long FActivityTime; + unsigned long FLastMsgRecvTime; + unsigned long FLastMsgSendTime; + MCMessageState FLastMsgRecvState; + MCMessageState FLastMsgSendState; + + // bandwidth limitation end + + MCSocket* FTransporter; + bool FInitialized; + bool FIsReceiving; + bool FIsSending; + MCInetTransport* FOwner; + + MCList FOutgoingQueue; + int FServerRequestTime; + + void DeleteEntry(void); + + void WaitForSignal(unsigned int ms); + bool SetMessageForSending(void); + void MakeAsyncConnect(void); +//$ifndef LINUX + void MakeSocksConnect(void); + bool DoSocksConnect(void); + bool SocksSendReceive(void* sendBuf, long sendBufSize, long& wasSent, + void* readBuf, long readBufSize, long& wasRead); +//$endif + bool ClientConnect(void); + bool FailCurrentMessage(int ErrorCode); + virtual void ClientExecute(void); + virtual void ServerExecute(void); + + int IsMsgPendingForClient(MCMessageInfo* deferredInfo); + bool HandleIncomingData(void); + bool HandleOutgoingData(void); + bool PerformRecvSend(bool& errorFlag, bool& closeConnection, bool& timeout); + virtual void Run(void); + MCMessageInfo* GetMessageForDelivery(void); + /* + This method is called from Execute to transform a message into a data + block. Method returns true if the message was prepared and false if there + was no message. + */ + bool PrepareMessageForSending(void); + /* + ReceiveData reads the data from the socket and adds them to the incoming + packet (optionally creating this packet). + ReceiveData returns true if the socket can be read or false if the socket + was closed. + */ + virtual bool ReceiveData(void) = 0; + virtual void UpdateConnectionContext(void) = 0; + virtual bool SendData(void) = 0; + virtual bool IsMessageRead(void); + //virtual bool MessageReceivedCompletely(void); + void UpdateRemoteSAddress(MCMessageInfo* Info); + + //new receiving logic + virtual bool MessageReceivedCompletely2(void); + virtual bool IsMessageFetched(void); + bool ReadHeader(MCInetHeader* Header, char** s, char* TransactCmd, + char** RouteTo, char** RecvPath, char** DQueue); + bool ParseRoutingStrings(char* s, char* *outS, char* TransactCmd, + char** RouteTo, char** RecvPath, char** DQueue); + bool UpdateEntry(char* *s, char **OriginalSMsg); + void PutErrorPacket(char* DMessenger, char* SMessenger, char* RecvPath, + __int64 MsgID, long Error); + MCMessageInfo* LoadAndUnpackMessage(MCInetHeader* Header, void** DataBuf, + long* DataLen, MCMemStream** AStream, + char* s, char* SMsg, char TransactCmd, + char* RecvPath); + bool PrepareRouting(char* s, char* OriginalSMsg, char** RecvPath); + + bool HandleEmptyRequest(MCMessageInfo* Info, MCMemStream* AStream); + bool HandleEmptyReply(MCMessageInfo* Info, MCMemStream* AStream); + bool HandleDispatching(MCMessageInfo* Info, MCMemStream* AStream, char* RecvPath); + bool HandleReply(MCMessageInfo* Info, MCMemStream* AStream); + bool HandleUnknown(MCMessageInfo* Info, MCMemStream* AStream); + //end of NRL + + virtual bool MessageSentCompletely(void); + + virtual void SetTransporterAddress(MCInetConnectionEntry* Ent, MCSocket* Transp) = 0; + virtual bool PostConnectionStep(void) = 0; + + //char* UpdateClientID(const char* S, int ID); + //int ExtractClientID(const char* S); + bool IsTransformerOK(MCInetHeader* Header); + MCMessageInfo* MakeEmptyPacket(MCMessageState state); + void FinalizeJob(void); + bool AreRequestsInQueue(void); + virtual bool IsRequestNeeded() {return false; }; + virtual void ChangeLastSendTime(MCMessageState state); + virtual void ChangeLastRecvTime(MCMessageState state); + + virtual bool InitializeConnection(); + virtual void FinalizeConnection(); + +public: + MCInetTransportJob(void); + virtual ~MCInetTransportJob(); + + virtual void Initialize2(MCSocket* Socket, MCInetConnectionEntry* Entry); + void AdjustBufferSize(unsigned long Incoming, unsigned long Outgoing); + void AdjustSpeedLimits(unsigned long Incoming, unsigned long Outgoing); + static bool ParseRemoteAddr(const char* S, long *ClientID, long *ConnID, char** IP, int* Port); + + MCInetConnectionEntry* getEntry(void); + void setEntry(MCInetConnectionEntry* Value); + bool getIsReceiving(void); + void setIsReceiving(bool Value); + bool getIsSending(void); + void setIsSending(bool Value); + MCInetTransport* getOwner(void); + void setOwner(MCInetTransport* Value); + MCSocket* getTransporter(void); + void setTransporter(MCSocket* Value); + MCList* getOutgoingQueue(void); +}; + + +class MCInetListenerJob: public MCSocketJob { +private: +protected: + MCInetTransport* FOwner; + MCSocket* FListener; + bool FInitialized; + + virtual bool AcceptConnection(void); +public: + MCInetListenerJob(void); + virtual ~MCInetListenerJob(void); + virtual void Run(void); + virtual void Initialize(MCSocket *ASocket); + MCInetTransport* getOwner(void); + void setOwner(MCInetTransport* Value); +}; + +class MCInetConnectionEntry { +friend class MCInetTransportJob; +protected: + long FAttempt; + __int64 FCancelID; + long FCompressID; + MCCriticalSection* + FCS; + long FEncryptID; + MCStream* FIncomingStream; + MCMessageInfo* FInfo; +// MCMessageState FInfoState; + __int64 FLastActionTime; + long FMsgSize; + MCStream* FOutgoingStream; + MCInetTransportJob* FProcessingThread; + char* FRemoteAddress; + long FSealID; + int FClientID; + bool FRejectedTransformer; + char* FRemoteSAddress; + int FReqTime; + long FConnID; +public: + MCInetConnectionEntry(void); + virtual ~MCInetConnectionEntry(void); + void Reset(void); + long getAttempt(void); + void setAttempt(long Value); + __int64 getCancelID(void); + void setCancelID(__int64 Value); + long getCompressID(void); + void setCompressID(long Value); + MCCriticalSection* getCS(void); + long getEncryptID(void); + void setEncryptID(long Value); + MCStream* getIncomingStream(void); + void setIncomingStream(MCStream* Value); + MCMessageInfo* getInfo(void); + void setInfo(MCMessageInfo* Value); +// MCMessageState getInfoState(void); +// void setInfoState(MCMessageState Value); + __int64 getLastActionTime(void); + void setLastActionTime(__int64 Value); + long getMsgSize(void); + void setMsgSize(long Value); + MCStream* getOutgoingStream(void); + void setOutgoingStream(MCStream* Value); + MCInetTransportJob* getProcessingJob(void); + void setProcessingJob(MCInetTransportJob* Value); + char* getRemoteAddress(void); + void setRemoteAddress(const char* Value); + long getSealID(void); + void setSealID(long Value); + int getClientID(void); + void setClientID(int Value); + bool getRejectedTransformer(void); + void setRejectedTransformer(bool Value); + char* getRemoteSAddress(void); + void setRemoteSAddress(const char* Addr); + int getReqTime(void); + void setReqTime(int value); + long getConnID(void); + void setConnID(long value); +}; + +void ShowDebugInfo(const char* format,...); + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCLists.cpp b/libraries/external/eldos/pc/include/MCLists.cpp new file mode 100755 index 0000000..ed01a39 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCLists.cpp @@ -0,0 +1,373 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCPlatforms.h" +#include "MCLists.h" +#include +#include + +#ifndef _WIN32_WCE +#include +#else + +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +// --------------------- tlist ----------------------- + +MCList::MCList(void) +{ + OnDelete = 0; + DeleteItem = 0; + CompareItems = &DefaultCompare; + Data = 0; + Size = 0; + Len = 0; + DuplicatesAllowed = true; + Sorted = false;//true; +} + +MCList::~MCList(void) +{ + DeleteAll(); + MCMemFree(Data); Data = NULL; +} + +void MCList::setDuplicatesOff(bool DisableDuplicates) +{ + DuplicatesAllowed = !DisableDuplicates; +} + +void MCList::setSorted(bool Sorted) +{ + this->Sorted = Sorted; +} + +long MCList::Length(void) +{ + return Len; +} + +void MCList::DeleteAll(void) +{ + for(long x=Len; x>0; x--) + Del(x-1); + + Len = 0; +} + +void MCList::Del(long N) +{ + if (N < 0 || N > Len-1) + return; + if(0 != OnDelete) + OnDelete(this, Data[N]); + + if(DeleteItem) + DeleteItem(this, Data[N]); + + if(N < Len-1) + memmove(&Data[N], &Data[N+1], (Len-N-1)*sizeof(void*)); + Len--; +} + +bool MCList::Del(void* V) +{ + long index = Find(V); + if(-1 != index) + { + Del(index); + return true; + } + else + return false; +} + +typedef void* PVOID; + +void MCList::Upgrade(long Upg) +{ + long delta = (long)(Size * 1.33 + 0.5); + if (delta < 1) + delta = 32; + + if (Upg < 1) + return; + long x = (delta - Size) < Upg ? Upg : delta; + void** p = (void**)MCMemAlloc(sizeof(PVOID) * (Size + x)); + + memset(p, 0, (Size + x) * sizeof(void*)); + if(0 != Size) + { + memcpy(p, Data, Size*sizeof(void*)); + if(Data) + MCMemFree(Data); + Data = 0; + } + Size += x; + Data = p; +} + +long MCList::Add(void* V) +{ + if (Sorted) + return(Insert(IndexOf(V, NULL), V)); + else + return(Insert(Len, V)); +} + +long MCList::DefaultCompare(void* Sender,void* V1,void* V2) +{ + return ((long)V1 - (long)V2); +} + +long MCList::IndexOf(void* V, bool *Found) +{ + long L, H, I, C; + bool Result; + + L = 0; + Result = false; + if (Sorted) + { + H = Len - 1; + while (L <= H) + { + I = (L + H) >> 1; + C = CompareItems(this, Data[I], V); + if (C < 0) + L = I + 1; + else + { + H = I - 1; + if (C == 0) + { + Result = true; + L = I; + } + } + } + } + if (NULL != Found) + *Found = Result; + return L; +} + +long MCList::Find(void* V) +{ + long x; + + if(!V) + return -1; + + if(0 != CompareItems) + { + if (Sorted) + { + bool Found; + x = IndexOf(V, &Found); + if (Found) + return x; + } + else + { + for(x = 1; x <= Len; x++) + { + if (CompareItems(this, Data[x-1], V) == 0) + return(x-1); + } + } + } + + return -1; +} + +long MCList::Insert(long N, void* V) +{ + if (N < 0 || N > Len || !V) + return -1; + if (false == DuplicatesAllowed) + { + if (this->Find(V) != -1) + { + ;//assert(0); + return 0; + } + } + if (Len+1 > Size) + Upgrade(1); + if (N < Len) + { + memmove(&Data[N+1], &Data[N], (Len-N)*sizeof(void*)); + } + Data[N] = V; + Len++; + return N; +} + +void* MCList::operator[](long N) +{ + if(N < 0 || N >= Len) + return NULL; + return Data[N]; +} + +void* MCList::At(long N) +{ + if(N < 0 || N >= Len) + return NULL; + return Data[N]; +} + +void MCList::CopyOf(MCList* L) +{ + DeleteAll(); + Upgrade(L->Length() - Size); + for(long x=1; x <= L->Length(); x++) + Add((*L)[x-1]); +} + +// ------------------ tstringlist -------------------- + +MCStringList::MCStringList(void) +{ + DeleteItem = &StringDelete; + CompareItems = &StringCompare; +} + +void MCStringList::StringDelete(void* Sender, void* V) +{ + if(V) + MCMemFree(V); +} + +long MCStringList::StringCompare(void* Sender, void* V1,void* V2) +{ + return strcmp((char*)V1, (char*)V2); +} + +char* MCStringList::Text(void) +{ + char* p; + char nl[] = "\n"; + long nll = strlen(nl); + long t = 0; + + for(long x=1; x <= Length(); x++) + t += strlen((char*)(*this)[x-1]) + nll; + + p = (char*)MCMemAlloc(t+1); + *p = 0; + for(long x1=1; x1 <= Length(); x1++) + { + strcat(p, (char*)(*this)[x1-1]); + strcat(p,nl); + } + return(p); +} + +long MCStringList::Add(void* V) +{ + return(MCStringList::Add((char*)V)); +} + +static char* copyString(char* s) +{ + char* r = (char*)MCMemAlloc(strlen(s)+1); + strcpy(r, s); + return r; +} + +long MCStringList::Add(char* V) +{ + if(!V) + return(-1); +#ifndef _WIN32_WCE + return(MCList::Add((void*)copyString(V))); +#else + return(MCList::Add((void*)copyString(V))); +#endif + +} + +void* MCStringList::operator[](long N) +{ + return MCList::operator[](N); +} + +MCWideStringList::MCWideStringList(void):MCList() +{ + DeleteItem = &StringDelete; + //DupItem = &StringDup; + CompareItems = &StringCompare; +} + +void MCWideStringList::StringDelete(void*, void* V) +{ + if(V) + MCMemFree(V); +} + +void* MCWideStringList::StringDup(void*, void* V) +{ + return wstrdup((wchar_t*)V); +} + +long MCWideStringList::StringCompare(void*, void* V1,void* V2) +{ + return strcmp((char*)V1, (char*)V2); +} + +wchar_t* MCWideStringList::Text(void) +{ + wchar_t* p; + wchar_t nl[] = {0xa, 0}; + size_t nll = wstrlen(nl); + size_t t = 0; + + for(long x=1; x <= Length(); x++) + t += wstrlen((wchar_t*)(*this)[x-1]) + nll; + + p = (wchar_t*)MCMemAlloc(t * sizeof(wchar_t) + 1); + *p = 0; + + for(long x1=1; x1 <= Length(); x1++) + { + wstrcat(p, (wchar_t*)(*this)[x1-1]); + wstrcat(p,nl); + } + return p; +} + +long MCWideStringList::Add(void* V) +{ + return(MCWideStringList::Add((wchar_t*)V)); +} + +long MCWideStringList::Add(wchar_t* V) +{ + if(!V) + return(-1); + return(MCList::Add((void*)wstrdup(V))); +} + +void* MCWideStringList::operator[](long N) +{ + return MCList::operator[](N); +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCLists.h b/libraries/external/eldos/pc/include/MCLists.h new file mode 100755 index 0000000..d570c41 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCLists.h @@ -0,0 +1,83 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCLISTS__ +#define __MCLISTS__ + +#include "MC.h" +#include "MCPlatforms.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +class MCList { +protected: + void** Data; + long Len; + long Size; + bool DuplicatesAllowed; + bool Sorted; + + void Upgrade (long Upg=20); + static long DefaultCompare(void* Sender, void* V1,void* V2); + long IndexOf(void* V, bool *Found); +public: + MCList(void); + virtual ~MCList(void); + long Length(void); + virtual long Add(void* V); + long Insert(long N, void* V); + long Find(void* V); + void Del(long N); + bool Del(void* V); + void DeleteAll(void); + virtual void* operator[](long N); + void CopyOf(MCList* L); + void setDuplicatesOff(bool DisableDuplicates); + void setSorted(bool Sorted); + void* At(long N); + void (*OnDelete)(void* Sender, void* V); + void (*DeleteItem)(void* Sender, void* V); + long (*CompareItems)(void* Sender, void* V1, void* V2); +}; + +class MCStringList: public MCList +{ + static long StringCompare(void* Sender,void* V1,void* V2); + static void StringDelete(void* Sender,void* V); +public: + MCStringList(void); + char* Text(void); + long Add(void* V); + virtual long Add(char* V); + virtual void* operator[](long N); +}; + + +class MCWideStringList: public MCList +{ + static long StringCompare(void* Sender, void* V1, void* V2); + static void StringDelete(void* Sender, void* V); + static void* StringDup(void* Sender,void* V); +public: + MCWideStringList(void); + wchar_t* Text(void); + long Add(void* V); + virtual long Add(wchar_t* V); + virtual void* operator[](long N); +}; + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCLogger.cpp b/libraries/external/eldos/pc/include/MCLogger.cpp new file mode 100755 index 0000000..9d444d2 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCLogger.cpp @@ -0,0 +1,112 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCLogger.h" +#ifdef _WIN32 +# include +#else +//# include +//# include +//# include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +MCLogger* MCLogger::FSingletone = NULL; + +MCLogger::MCLogger(void) +:FOnLogMessage(NULL), FLevel(llTrivial), FRefCount(0) +{ +} + +MCLogger::~MCLogger() +{ +} + +MCLogger* MCLogger::Singletone(void) +{ + if (NULL == MCLogger::FSingletone) + FSingletone = new MCLogger(); + FSingletone->FRefCount++; + return FSingletone; +} + +void MCLogger::Release(void) +{ + if (this == FSingletone) + { + FRefCount--; + if (0 == FRefCount) + { + delete this; + MCLogger::FSingletone = NULL; + } + } +} + +void MCLogger::setOnLogMessage(MCLogMessageHandler Handler) +{ + FOnLogMessage = Handler; +} + +MCLogMessageHandler MCLogger::getOnLogMessage(void) +{ + return FOnLogMessage; +} + +void MCLogger::PutMessage(MCLogLevel LogLevel, const char* Msg, unsigned int Code, const char* Location) +{ + FGuard.Enter(); + if (FLevel >= LogLevel) + { + if (NULL != FOnLogMessage) + { + TRY_BLOCK + { + int ThreadID = 0; +#ifndef __GNUC__ +#ifndef _WIN32_WCE +//$ifndef LINUX + ThreadID = CoGetCurrentProcess(); +//$endif +#else +//$ifndef LINUX + ThreadID = GetCurrentThreadId(); +//$endif +#endif +#else + ThreadID = getpid(); +#endif + + FOnLogMessage(this, ThreadID, Msg, Code, Location); + } + CATCH_EVERY + { + } + } + else + { +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(UNICODE) && !defined(_UNICODE) + OutputDebugString(Msg); +#endif +#ifndef _WIN32 +// std::cerr<> 25)) + FB; + FD += ((FA & FB) | (~FA & FC)) + Temp[1] + 0xE8C7B756; + FD = ((FD << 12) | (FD >> 20)) + FA; + FC += ((FD & FA) | (~FD & FB)) + Temp[2] + 0x242070DB; + FC = ((FC << 17) | (FC >> 15)) + FD; + FB += ((FC & FD) | (~FC & FA)) + Temp[3] + 0xC1BDCEEE; + FB = ((FB << 22) | (FB >> 10)) + FC; + FA += ((FB & FC) | (~FB & FD)) + Temp[4] + 0xF57C0FAF; + FA = ((FA << 7) | (FA >> 25)) + FB; + FD += ((FA & FB) | (~FA & FC)) + Temp[5] + 0x4787C62A; + FD = ((FD << 12) | (FD >> 20)) + FA; + FC += ((FD & FA) | (~FD & FB)) + Temp[6] + 0xA8304613; + FC = ((FC << 17) | (FC >> 15)) + FD; + FB += ((FC & FD) | (~FC & FA)) + Temp[7] + 0xFD469501; + FB = ((FB << 22) | (FB >> 10)) + FC; + FA += ((FB & FC) | (~FB & FD)) + Temp[8] + 0x698098D8; + FA = ((FA << 7) | (FA >> 25)) + FB; + FD += ((FA & FB) | (~FA & FC)) + Temp[9] + 0x8B44F7AF; + FD = ((FD << 12) | (FD >> 20)) + FA; + FC += ((FD & FA) | (~FD & FB)) + Temp[10] + 0xFFFF5BB1; + FC = ((FC << 17) | (FC >> 15)) + FD; + FB += ((FC & FD) | (~FC & FA)) + Temp[11] + 0x895CD7BE; + FB = ((FB << 22) | (FB >> 10)) + FC; + FA += ((FB & FC) | (~FB & FD)) + Temp[12] + 0x6B901122; + FA = ((FA << 7) | (FA >> 25)) + FB; + FD += ((FA & FB) | (~FA & FC)) + Temp[13] + 0xFD987193; + FD = ((FD << 12) | (FD >> 20)) + FA; + FC += ((FD & FA) | (~FD & FB)) + Temp[14] + 0xA679438E; + FC = ((FC << 17) | (FC >> 15)) + FD; + FB += ((FC & FD) | (~FC & FA)) + Temp[15] + 0x49B40821; + FB = ((FB << 22) | (FB >> 10)) + FC; + // round 2 + FA += ((FB & FD) | (FC & ~FD)) + Temp[1] + 0xF61E2562; + FA = ((FA << 5) | (FA >> 27)) + FB; + FD += ((FA & FC) | (FB & ~FC)) + Temp [6] + 0xC040B340; + FD = ((FD << 9) | (FD >> 23)) + FA; + FC += ((FD & FB) | (FA & ~FB)) + Temp[11] + 0x265E5A51; + FC = ((FC << 14) | (FC >> 18)) + FD; + FB += ((FC & FA) | (FD & ~FA)) + Temp[0] + 0xE9B6C7AA; + FB = ((FB << 20) | (FB >> 12)) + FC; + FA += ((FB & FD) | (FC & ~FD)) + Temp[5] + 0xD62F105D; + FA = ((FA << 5) | (FA >> 27)) + FB; + FD += ((FA & FC) | (FB & ~FC)) + Temp [10] + 0x2441453; + FD = ((FD << 9) | (FD >> 23)) + FA; + FC += ((FD & FB) | (FA & ~FB)) + Temp[15] + 0xD8A1E681; + FC = ((FC << 14) | (FC >> 18)) + FD; + FB += ((FC & FA) | (FD & ~FA)) + Temp[4] + 0xE7D3FBC8; + FB = ((FB << 20) | (FB >> 12)) + FC; + FA += ((FB & FD) | (FC & ~FD)) + Temp[9] + 0x21E1CDE6; + FA = ((FA << 5) | (FA >> 27)) + FB; + FD += ((FA & FC) | (FB & ~FC)) + Temp [14] + 0xC33707D6; + FD = ((FD << 9) | (FD >> 23)) + FA; + FC += ((FD & FB) | (FA & ~FB)) + Temp[3] + 0xF4D50D87; + FC = ((FC << 14) | (FC >> 18)) + FD; + FB += ((FC & FA) | (FD & ~FA)) + Temp[8] + 0x455A14ED; + FB = ((FB << 20) | (FB >> 12)) + FC; + FA += ((FB & FD) | (FC & ~FD)) + Temp[13] + 0xA9E3E905; + FA = ((FA << 5) | (FA >> 27)) + FB; + FD += ((FA & FC) | (FB & ~FC)) + Temp [2] + 0xFCEFA3F8; + FD = ((FD << 9) | (FD >> 23)) + FA; + FC += ((FD & FB) | (FA & ~FB)) + Temp[7] + 0x676F02D9; + FC = ((FC << 14) | (FC >> 18)) + FD; + FB += ((FC & FA) | (FD & ~FA)) + Temp[12] + 0x8D2A4C8A; + FB = ((FB << 20) | (FB >> 12)) + FC; + // round 3 + FA += (FB ^ FC ^ FD) + Temp[5] + 0xFFFA3942; + FA = FB + ((FA << 4) | (FA >> 28)); + FD += (FA ^ FB ^ FC) + Temp[8] + 0x8771F681; + FD = FA + ((FD << 11) | (FD >> 21)); + FC += (FD ^ FA ^ FB) + Temp[11] + 0x6D9D6122; + FC = FD + ((FC << 16) | (FC >> 16)); + FB += (FC ^ FD ^ FA) + Temp[14] + 0xFDE5380C; + FB = FC + ((FB << 23) | (FB >> 9)); + FA += (FB ^ FC ^ FD) + Temp[1] + 0xA4BEEA44; + FA = FB + ((FA << 4) | (FA >> 28)); + FD += (FA ^ FB ^ FC) + Temp[4] + 0x4BDECFA9; + FD = FA + ((FD << 11) | (FD >> 21)); + FC += (FD ^ FA ^ FB) + Temp[7] + 0xF6BB4B60; + FC = FD + ((FC << 16) | (FC >> 16)); + FB += (FC ^ FD ^ FA) + Temp[10] + 0xBEBFBC70; + FB = FC + ((FB << 23) | (FB >> 9)); + FA += (FB ^ FC ^ FD) + Temp[13] + 0x289B7EC6; + FA = FB + ((FA << 4) | (FA >> 28)); + FD += (FA ^ FB ^ FC) + Temp[0] + 0xEAA127FA; + FD = FA + ((FD << 11) | (FD >> 21)); + FC += (FD ^ FA ^ FB) + Temp[3] + 0xD4EF3085; + FC = FD + ((FC << 16) | (FC >> 16)); + FB += (FC ^ FD ^ FA) + Temp[6] + 0x4881D05; + FB = FC + ((FB << 23) | (FB >> 9)); + FA += (FB ^ FC ^ FD) + Temp[9] + 0xD9D4D039; + FA = FB + ((FA << 4) | (FA >> 28)); + FD += (FA ^ FB ^ FC) + Temp[12] + 0xE6DB99E5; + FD = FA + ((FD << 11) | (FD >> 21)); + FC += (FD ^ FA ^ FB) + Temp[15] + 0x1FA27CF8; + FC = FD + ((FC << 16) | (FC >> 16)); + FB += (FC ^ FD ^ FA) + Temp[2] + 0xC4AC5665; + FB = FC + ((FB << 23) | (FB >> 9)); + // round 4 + FA += (FC ^ (FB | ~FD)) + Temp[0] + 0xF4292244; + FA = FB + ((FA << 6) | (FA >> 26)); + FD += (FB ^ (FA | ~FC)) + Temp[7] + 0x432AFF97; + FD = FA + ((FD << 10) | (FD >> 22)); + FC += (FA ^ (FD | ~FB)) + Temp[14] + 0xAB9423A7; + FC = FD + ((FC << 15) | (FC >> 17)); + FB += (FD ^ (FC | ~FA)) + Temp[5] + 0xFC93A039; + FB = FC + ((FB << 21) | (FB >> 11)); + FA += (FC ^ (FB | ~FD)) + Temp[12] + 0x655B59C3; + FA = FB + ((FA << 6) | (FA >> 26)); + FD += (FB ^ (FA | ~FC)) + Temp[3] + 0x8F0CCC92; + FD = FA + ((FD << 10) | (FD >> 22)); + FC += (FA ^ (FD | ~FB)) + Temp[10] + 0xFFEFF47D; + FC = FD + ((FC << 15) | (FC >> 17)); + FB += (FD ^ (FC | ~FA)) + Temp[1] + 0x85845DD1; + FB = FC + ((FB << 21) | (FB >> 11)); + FA += (FC ^ (FB | ~FD)) + Temp[8] + 0x6FA87E4F; + FA = FB + ((FA << 6) | (FA >> 26)); + FD += (FB ^ (FA | ~FC)) + Temp[15] + 0xFE2CE6E0; + FD = FA + ((FD << 10) | (FD >> 22)); + FC += (FA ^ (FD | ~FB)) + Temp[6] + 0xA3014314; + FC = FD + ((FC << 15) | (FC >> 17)); + FB += (FD ^ (FC | ~FA)) + Temp[13] + 0x4E0811A1; + FB = FC + ((FB << 21) | (FB >> 11)); + FA += (FC ^ (FB | ~FD)) + Temp[4] + 0xF7537E82; + FA = FB + ((FA << 6) | (FA >> 26)); + FD += (FB ^ (FA | ~FC)) + Temp[11] + 0xBD3AF235; + FD = FA + ((FD << 10) | (FD >> 22)); + FC += (FA ^ (FD | ~FB)) + Temp[2] + 0x2AD7D2BB; + FC = FD + ((FC << 15) | (FC >> 17)); + FB += (FD ^ (FC | ~FA)) + Temp[9] + 0xEB86D391; + FB = FC + ((FB << 21) | (FB >> 11)); + + FA += FAA; FB += FBB; FC += FCC; FD += FDD; + I += 64; + } while(I != Read); + } while(!Done); + // finalizing + Result.A = FA; Result.B = FB; Result.C = FC; Result.D = FD; + return(Result); +} + +// ****************************** TMCMD5Sealing ******************************* + +long MCMD5Sealing::GetID(void) +{ + return(2); +} + +void MCMD5Sealing::Seal(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success) +{ + TMessageDigest128 Digest; + + Success = true; + if(!InData || (InDataSize == 0)) + { + OutData = InData; + OutDataSize = InDataSize; + } + else + { + OutDataSize = InDataSize + sizeof(Digest); + OutData = MCMemAlloc(OutDataSize); + Digest = HashMD5(InData, InDataSize); + memmove(OutData, &Digest, sizeof(Digest)); + memmove((char*)OutData + sizeof(Digest), InData, InDataSize); + MCMemFree(InData); + } +} + +void MCMD5Sealing::UnSeal(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long /*TransformID*/, + bool& Success) +{ + TMessageDigest128 Digest; + + if(!InData || (InDataSize == 0)) + { + OutData = InData; + OutDataSize = InDataSize; + Success = true; + } + else + { + OutDataSize = InDataSize - sizeof(Digest); + OutData = MCMemAlloc(OutDataSize); +// Digest = HashMD5((char*)InData + sizeof(long), InDataSize - sizeof(long)); + Digest = HashMD5((char*)InData + sizeof(Digest), InDataSize - sizeof(Digest)); + Success = memcmp(InData, &Digest, sizeof(Digest)) == 0; + memmove(OutData, (char*)InData + sizeof(Digest), OutDataSize); + MCMemFree(InData); + } +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCMD5.h b/libraries/external/eldos/pc/include/MCMD5.h new file mode 100755 index 0000000..145604d --- /dev/null +++ b/libraries/external/eldos/pc/include/MCMD5.h @@ -0,0 +1,36 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCMD5__ +#define __MCMD5__ + +#include "MC.h" +#include "MCBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCMD5Sealing:public MCBaseSealing { +protected: +public: + virtual void Seal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success); + virtual void UnSeal(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success); +public: + virtual long GetID(void); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCMMF.cpp b/libraries/external/eldos/pc/include/MCMMF.cpp new file mode 100755 index 0000000..814b3d8 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCMMF.cpp @@ -0,0 +1,1306 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCMMF.h" +#ifdef _WIN32_WCE +# include +#endif + +#ifdef _WIN32 +# include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +const long MMF_FRAME_SIZE = 4096; +const long MMF_CLEAN_SIZE = 4096 - sizeof(long); + + +// ***************************** TMCMMFTransport ****************************** + +MCMMFTransport::MCMMFTransport(void):MCSimpleTransport() +{ + FDefaultTransportName = "MMF"; + FMessengerName = NULL; + FReceiverThread = NULL; + FSenderThread = NULL; +} + +MCMMFTransport::~MCMMFTransport(void) +{ + setActive(false); + + MCMemFree(FMessengerName); + delete FReceiverThread; + delete FSenderThread; +} + +bool MCMMFTransport::DeliverMessage(char* DestAddress,MCMessageInfo* Info) +{ + bool r; + char *p, *p1; + char *MMFName, *QueueName; + //long i; + + if(DestAddress && AddressValid(DestAddress)) + { + Info->Transport = this; + + if(!strchr(DestAddress, '|')) + { + THROW_ERROR(MCError_BadDestinationName); + } + + p = DestAddress; + p1 = p; + while(*p && (*p != '|')) + p++; + if(!*p) + THROW_ERROR(MCError_BadDestinationName); + + // get MMF name + if(p - p1 > 0) + MMFName = strCopy(p1, 0, (long)(p - p1)); + else + THROW_ERROR(MCError_BadDestinationName); + + p++; + // get queue name + p1 = p; + while(*p) + p++; + if(p - p1 > 0) + QueueName = strCopy(p1, 0, (long)(p - p1)); + else + THROW_ERROR(MCError_BadDestinationName); + + // setup message info properties + + strncpy(Info->DQueue, QueueName, DQueueMaxLength - 1); + MCMemFree(QueueName); QueueName = NULL; + + Info->DQueue[DQueueMaxLength - 1] = 0; + Info->DMessenger = MMFName; + + Info->SMessenger = strdup(FMessengerName); + + Info->State = imsDispatching; + FCriticalSection->Enter(); + + TRY_BLOCK + { + InsertInfoIntoQueueWithPriorities(FOutgoingQueue, Info, false); + + KickSender(true); + } FINALLY ( + FCriticalSection->Leave(); + ) + r = true; + } + else + r = false; + return r; +} + +MCMMFSenderThread* MCMMFTransport::CreateSenderThread(bool x) +{ + return new MCMMFSenderThread(x); +} + +MCMMFReceiverThread* MCMMFTransport::CreateReceiverThread(bool x) +{ + return new MCMMFReceiverThread(x); +} + +void MCMMFTransport::DoSetActive(void) +{ + bool initFailed = false; + MCHandle HandleArray[2]; + + if(!FMessenger) + return; + + if(getActive()) + { + if(!getMessengerName()) + THROW_ERROR(MCError_NoMessengerName); + FSenderThread = NULL; + + // initialize receiver + FReceiverThread = CreateReceiverThread(true);//new MCMMFReceiverThread(true); + TRY_BLOCK + { + FReceiverThread->Initialize(this); + } + CATCH_EVERY + { + delete FReceiverThread; FReceiverThread = NULL; + initFailed = true; + } + + if (true == initFailed) +#ifndef USE_CPPEXCEPTIONS + RaiseException(1, 0, 0, NULL); +#else + throw EMCError(0); +#endif + +// RaiseException(((EXCEPTION_POINTERS*)_exception_info)->ExceptionRecord->ExceptionRecord->ExceptionCode, +// ((EXCEPTION_POINTERS*)_exception_info)->ExceptionRecord->ExceptionFlags, +// ((EXCEPTION_POINTERS*)_exception_info)->ExceptionRecord->NumberParameters, +// ((EXCEPTION_POINTERS*)_exception_info)->ExceptionRecord->ExceptionInformation); + + FReceiverThread->setFreeOnTerminate(false); + + // initialize sender + FSenderThread = CreateSenderThread(true);//new MCMMFSenderThread(true); + TRY_BLOCK + { + FSenderThread->Initialize(this); + } + CATCH_EVERY + { + delete FSenderThread; + FSenderThread = NULL; + delete FReceiverThread; + FReceiverThread = NULL; + initFailed = true; + } + if (true == initFailed) +#ifndef USE_CPPEXCEPTIONS + RaiseException(1, 0, 0, NULL); +#else + throw EMCError(0); +#endif + FSenderThread->setFreeOnTerminate(false); + FReceiverThread->Resume(); + FSenderThread->Resume(); + } + else + { + if (NULL != FSenderThread) + { + FSenderThread->Terminate(); + FSenderThread->FStopEvent->setEvent(); + } + + if (NULL != FReceiverThread) + { + FReceiverThread->Terminate(); + FReceiverThread->FStopEvent->setEvent(); + } + + if ((NULL != FSenderThread) && (NULL != FReceiverThread)) + { +#ifdef __GNUC__ + FSenderThread->WaitFor(); + FReceiverThread->WaitFor(); +#else +//$ifndef LINUX + HandleArray[0] = FSenderThread->getHandle(); + HandleArray[1] = FReceiverThread->getHandle(); + WaitForMultipleObjects(2, HandleArray, true, INFINITE); +//$endif +#endif + } + delete FSenderThread; FSenderThread = NULL; + delete FReceiverThread; FReceiverThread = NULL; + + if (FOutgoingQueue != NULL) + { + while (FOutgoingQueue->Length() > 0) + { + CancelMessageByID(((MCMessageInfo*)(*FOutgoingQueue)[0])->Message.MsgID, MCError_Shutdown); + } + } + } +} + +char* MCMMFTransport::getMessengerName(void) +{ + return(FMessengerName); +} + +void MCMMFTransport::setMessengerName(const char* Value) +{ + bool b; + + if(!FMessengerName && !Value) + return; + if(!FMessengerName || !Value || (strcmp(FMessengerName, Value) != 0)) + { + b = getActive(); + setActive(false); + if(FMessengerName) + MCMemFree(FMessengerName); + FMessengerName = strdup(Value); + setActive(b); + } +} + +void MCMMFTransport::KickSender(bool MessageFlag) +{ +#ifdef __GNUC__ + FOutgoingCount->Release(); +#else +//$ifndef LINUX + ReleaseSemaphore(FOutgoingCount, 1, NULL); +//$endif +#endif +} + +void MCMMFTransport::CancelMessageInSender(MCMessageInfo* Info) +{ + if(FSenderThread) + FSenderThread->FCancelID = Info->Message.MsgID; +} + +bool MCMMFTransport::WasCancelled(MCMessageInfo* Info) +{ + return (FSenderThread && (FSenderThread->FCancelID == Info->Message.MsgID)); +} + +void MCMMFTransport::SetInfoSMessenger(MCMessageInfo* Info) +{ + Info->SMessenger = strdup(FMessengerName); +} + +// **************************** TMCMMFSenderThread **************************** + +MCMMFSenderThread::~MCMMFSenderThread(void) +{ + delete FStopEvent; +} + +void MCMMFSenderThread::Execute(void) +{ + FCancelID = 0; +#ifndef __GNUC__ +//$ifndef LINUX + MCHandle HandleArray[2]; + bool br = false; +//$endif +#endif + + while(!getTerminated()) + { + TRY_BLOCK + { + // wait for messages to be delivered +#ifdef __GNUC__ + if(FOwner->FOutgoingCount->WaitFor(0) == wrSignaled) + SendMessage(); + if(FStopEvent->WaitFor(0) == wrSignaled) + break; + Sleep(10); +#else +//$ifndef LINUX + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = FOwner->FOutgoingCount; + switch(WaitForMultipleObjects(2, HandleArray, false, INFINITE)) { + case WAIT_OBJECT_0: + br = true; + break; + case WAIT_OBJECT_0 + 1: + SendMessage(); + } + if(br) + break; +//$endif +#endif + if(getTerminated()) + return; + } + CATCH_EVERY + { + } + } +} + +void MCMMFSenderThread::Initialize(MCMMFTransport* Owner) +{ + FOwner = Owner; + FStopEvent = new MCEvent(NULL, true , false, NULL); +} + +void MCMMFSenderThread::SendMessage(void) +{ + MCMessageInfo* Info; +#ifdef __GNUC__ + MCEvent *RFreeMutex, *RReplyEvent, *RRequestEvent, *RReceiptEvent; + int RMMF; +#else +//$ifndef LINUX + MCHandle HandleArray[2]; + MCHandle RFreeMutex, RReplyEvent, RRequestEvent, RReceiptEvent; + MCHandle RMMF; +//$endif +#endif + MCMMFHeader* RMMFPtr; + char* DMessenger; + long i; + //char* AQueue; + __int64 StartTime, EndTime; + unsigned long ToWait; + char* p; + __int64 GTC; + MCStream* AStream = NULL; + + Info = NULL; + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + for(i = 0;i <= FOwner->FOutgoingQueue->Length() - 1;i++) + if(((MCMessageInfo*)((*FOwner->FOutgoingQueue)[i]))->State == imsDispatching || + ((MCMessageInfo*)((*FOwner->FOutgoingQueue)[i]))->State == imsComplete || + ((MCMessageInfo*)((*FOwner->FOutgoingQueue)[i]))->State == imsFailed) + { + Info = (MCMessageInfo*)((*FOwner->FOutgoingQueue)[i]); + FOwner->FOutgoingQueue->Del(i); + break; + } + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + + if(!Info) + return; + +// AQueue = Pstr2c(Info->DQueue); +// AQueue = strdup(Info->DQueue); + DMessenger = Info->DMessenger; + // get destination messenger name + if(!DMessenger) + { + Info->MCError = MCError_GenTransportFailure; + FOwner->DeliveryFailed(Info); + return; + } + +#ifdef __GNUC__ + char* ttmpdir = getenv("TEMP"); + char tmpdir[1024]; + if(ttmpdir) + { + strcpy(tmpdir, ttmpdir); + strcat(tmpdir, "/"); + } + else + strcpy(tmpdir, "/tmp/"); + p = (char*)MCMemAlloc(strlen(tmpdir) + strlen(DMessenger) + strlen("_Mapping") + 1); + strcpy(p, tmpdir); + strcat(p, DMessenger); + strcat(p, "_Mapping"); + RMMF = open(p, O_RDWR|O_SYNC, DEFFILEMODE); + MCMemFree(p); + if(RMMF < 0) +#else +//$ifndef LINUX + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_Mapping") + 1); + strcpy(p, DMessenger); + strcat(p, "_Mapping"); +#if defined(_WIN32_WCE) || defined(UNICODE) + wchar_t* w = s2w(p); +#ifndef _WIN32_WCE + RMMF = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, w); + delete w; +#else + RMMF = CreateFileMapping((HANDLE)INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, + strlen(Info->SMessenger) + 4 + sizeof(Info) + Info->Message.DataSize, w); + delete w; + if(GetLastError() != ERROR_ALREADY_EXISTS) + { + CloseHandle(RMMF); + RMMF = 0; + } +#endif +#else + RMMF = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, p); +#endif + MCMemFree(p); + if(RMMF == 0) +//$endif +#endif + { + Info->MCError = MCError_GenTransportFailure; + FOwner->DeliveryFailed(Info); + return; + } + +#ifdef __GNUC__ + RMMFPtr = (MCMMFHeader*)mmap(0, MMF_FRAME_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, RMMF, 0); + if(-1 == (long) RMMFPtr) +#else +//$ifndef LINUX + RMMFPtr = (MCMMFHeader*)MapViewOfFile(RMMF, FILE_MAP_ALL_ACCESS, 0, 0, 0); + if(!RMMFPtr) +//$endif +#endif + { + Info->MCError = MCError_GenTransportFailure; + FOwner->DeliveryFailed(Info); +#ifdef __GNUC__ + close(RMMF); +#else +//$ifndef LINUX + CloseHandle(RMMF); +//$endif +#endif + return; + } + + // create necessary events +#ifndef __GNUC__ +//$ifndef LINUX + RFreeMutex = INVALID_HANDLE_VALUE; + RReceiptEvent = INVALID_HANDLE_VALUE; + RRequestEvent = INVALID_HANDLE_VALUE; + RReplyEvent = INVALID_HANDLE_VALUE; +//$endif +#else + RFreeMutex = NULL; + RReceiptEvent = NULL; + RRequestEvent = NULL; + RReplyEvent = NULL; +#endif + TRY_BLOCK + { + TRY_BLOCK + { +#ifdef __GNUC__ + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_MMFFreeMutex") + 1); + strcpy(p, DMessenger); + strcat(p, "_MMFFreeMutex"); + RFreeMutex = new MCEvent(NULL, false, false, p, true); + MCMemFree(p); + + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_ReceiptEvent") + 1); + strcpy(p, DMessenger); + strcat(p, "_ReceiptEvent"); + RReceiptEvent = new MCEvent(NULL, false, false, p, true); + MCMemFree(p); + + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_RequestEvent") + 1); + strcpy(p, DMessenger); + strcat(p, "_RequestEvent"); + RRequestEvent = new MCEvent(NULL, false, false, p, true); + MCMemFree(p); + + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_ReplyEvent") + 1); + strcpy(p, DMessenger); + strcat(p, "_ReplyEvent"); + RReplyEvent = new MCEvent(NULL, false, false, p, true); + MCMemFree(p); +#else +//$ifndef LINUX + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_MMFFreeMutex") + 1); + strcpy(p, DMessenger); + strcat(p, "_MMFFreeMutex"); +#if defined(_WIN32_WCE) || defined(UNICODE) + LPCTSTR w = s2w(p); + RFreeMutex = CreateMutex(NULL, false, w); + delete (void*)w; +#else + RFreeMutex = OpenMutex(MUTEX_ALL_ACCESS, false, p); +#endif + MCMemFree(p); + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_ReceiptEvent") + 1); + strcpy(p, DMessenger); + strcat(p, "_ReceiptEvent"); +#if defined(_WIN32_WCE) || defined(UNICODE) + w = s2w(p); + RReceiptEvent = CreateEvent(NULL, true, false, w); + delete (void*)w; +#else + RReceiptEvent = OpenEvent(EVENT_ALL_ACCESS, false, p); +#endif + MCMemFree(p); + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_RequestEvent") + 1); + strcpy(p, DMessenger); + strcat(p, "_RequestEvent"); +#if defined(_WIN32_WCE) || defined(UNICODE) + w = s2w(p); + RRequestEvent = CreateEvent(NULL, true, false, w); + delete (void*)w; +#else + RRequestEvent = OpenEvent(EVENT_ALL_ACCESS, false, p); +#endif + MCMemFree(p); + p = (char*)MCMemAlloc(strlen(DMessenger) + strlen("_ReplyEvent") + 1); + strcpy(p, DMessenger); + strcat(p, "_ReplyEvent"); +#if defined(_WIN32_WCE) || defined(UNICODE) + w = s2w(p); + RReplyEvent = CreateEvent(NULL, true, false, w); + delete (void*)w; +#else + RReplyEvent = OpenEvent(EVENT_ALL_ACCESS, false, p); +#endif + MCMemFree(p); +//$endif +#endif + +#ifdef __GNUC__ + if((!RFreeMutex) || + (!RReceiptEvent) || + (!RRequestEvent) || + (!RReplyEvent)) +#else +//$ifndef LINUX + if((RFreeMutex == INVALID_HANDLE_VALUE) || + (RReceiptEvent == INVALID_HANDLE_VALUE) || + (RRequestEvent == INVALID_HANDLE_VALUE) || + (RReplyEvent == INVALID_HANDLE_VALUE)) +//$endif +#endif + THROW_ERROR(MCError_GenTransportFailure); + + // write transferrable data to the buffer + AStream = new MCMemStream(); + i = strlen(Info->SMessenger); + if(i > 0) + AStream->Write(&i, sizeof(i)); + + AStream->Write(Info->SMessenger, i); + Info->WriteToStream(AStream); + if(Info->Message.DataSize > 0) + AStream->Write((char*)(Info->Message.Data), Info->Message.DataSize); + AStream->SetPos(0); + + // initialize time counters + StartTime = GetTickCount(); + ToWait = FOwner->getMaxTimeout(); + EndTime = StartTime + ToWait; + +#ifdef __GNUC__ + long l_wait = ToWait*100; + while(true) + { + if(FStopEvent->WaitFor(0) == wrSignaled) + throw EMCError(MCError_TransportTimeout); + if(RFreeMutex->WaitFor(0) == wrSignaled) + break; + Sleep(10); + l_wait--; + if(l_wait == 0) + { + printf("timeout when waiting for signal\n"); + throw EMCError(MCError_TransportTimeout); + } + } +#else +//$ifndef LINUX + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = RFreeMutex; + i = WaitForMultipleObjects(2, HandleArray, false, ToWait); + if((i == (long)WAIT_OBJECT_0) || (i == (long)WAIT_TIMEOUT)) + THROW_ERROR(MCError_TransportTimeout); +//$endif +#endif + + // begin transfer operation + RMMFPtr->dwDataSize = AStream->Len(); + + while(AStream->Pos() < AStream->Len()) + { + RMMFPtr->bIsFirst = AStream->Pos() == 0; + RMMFPtr->dwErrorCode = 0; + RMMFPtr->dwBlockStart = AStream->Pos(); + if((RMMFPtr->dwMMFSize - sizeof(MCMMFHeader)) < (unsigned long)(AStream->Len() - AStream->Pos())) + RMMFPtr->dwBlockSize = RMMFPtr->dwMMFSize - sizeof(MCMMFHeader); + else + RMMFPtr->dwBlockSize = AStream->Len() - AStream->Pos(); + + p = (char*)&RMMFPtr->dwBlockSize; + p += 4; + AStream->Read(p, RMMFPtr->dwBlockSize); + + // flag the availability of the data +#ifdef __GNUC__ + msync(RMMFPtr, MMF_FRAME_SIZE, MS_SYNC); + RRequestEvent->setEvent(); +#else +//$ifndef LINUX + SetEvent(RRequestEvent); +//$endif +#endif + + GTC = GetTickCount(); + if(GTC < StartTime) +#ifdef __GNUC__ + GTC = GTC + 0x100000000ll; +#else +//$ifndef LINUX + GTC = GTC + 0x100000000l; +//$endif +#endif + if((GTC > EndTime) && (ToWait != INFINITE)) + THROW_ERROR(MCError_TransportTimeout); + + if(ToWait != INFINITE) +#ifndef __GNUC__ +//$ifndef LINUX + ToWait = (unsigned long)(EndTime - (__int64)GTC); +//$endif +#else + ToWait = EndTime - GTC; +#endif + + +#ifdef __GNUC__ + long l_wait = ToWait*100; + while(true) + { + if(FStopEvent->WaitFor(0) == wrSignaled) + throw EMCError(MCError_TransportTimeout); + if(RReplyEvent->WaitFor(0) == wrSignaled) + break; + Sleep(10); + l_wait--; + if(l_wait == 0) + { + printf("timeout when waiting for signal\n"); + throw EMCError(MCError_TransportTimeout); + } + } +#else +//$ifndef LINUX + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = RReplyEvent; + if(WaitForMultipleObjects(2, HandleArray, false, ToWait) != (WAIT_OBJECT_0 + 1)) + THROW_ERROR(MCError_TransportTimeout); + //ResetEvent(RReplyEvent); +//$endif +#endif + if(AStream->Pos() < AStream->Len()) +#ifdef __GNUC__ + RReceiptEvent->setEvent(); +#else +//$ifndef LINUX + SetEvent(RReceiptEvent); +//$endif +#endif + } + + if((Info->State == imsDispatching) && Info->IsSendMsg && (Info->Message.MsgID != FCancelID)) + { + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + Info->State = imsWaiting; + FOwner->FOutgoingQueue->Add(Info); + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + } + else + { + if (Info->Message.MsgID != FCancelID) + { + delete Info; + Info = NULL; //MCMessenger::DestroyMessageInfo(Info); + } + } + +#ifdef __GNUC__ + RReceiptEvent->setEvent(); + RFreeMutex->setEvent(); +#else +//$ifndef LINUX + SetEvent(RReceiptEvent); + ReleaseMutex(RFreeMutex); +//$endif +#endif +#ifdef USE_CPPEXCEPTIONS + } catch(EMCError* E) { +#ifdef __GNUC__ + RFreeMutex->setEvent(); +#else +//$ifndef LINUX + ReleaseMutex(RFreeMutex); +//$endif +#endif + Info->MCError = E->ErrorCode(); + FOwner->DeliveryFailed(Info); +// return; + } +#else + } __except(1) { + ReleaseMutex(RFreeMutex); + Info->MCError = _exception_code(); + FOwner->DeliveryFailed(Info); +// return; + } +#endif + +#ifdef __GNUC__ + } FINALLY ( + delete AStream; + munmap(RMMFPtr, MMF_FRAME_SIZE); + close(RMMF); + delete RFreeMutex; + delete RReceiptEvent; + delete RRequestEvent; + delete RReplyEvent; + ) +#else +//$ifndef LINUX + } FINALLY ( + delete AStream; + UnmapViewOfFile(RMMFPtr); + CloseHandle(RMMF); + CloseHandle(RFreeMutex); + CloseHandle(RReceiptEvent); + CloseHandle(RRequestEvent); + CloseHandle(RReplyEvent); + ) +//$endif +#endif +} + +// *************************** TMCMMFReceiverThread *************************** +MCMMFReceiverThread::MCMMFReceiverThread(bool CreateSuspended) +:MCThread(CreateSuspended), FStopEvent(NULL), FReceiptEvent(NULL), FRequestEvent(NULL), + FReplyEvent(NULL) +{ +#ifdef _WIN32 + FMapping = NULL; + FMMFFreeMutex = NULL; +#endif +} + + +MCMMFReceiverThread::~MCMMFReceiverThread(void) +{ +#ifdef __GNUC__ + close(FMapping); + unlink(FMn); + MCMemFree(FMn); + delete FMMFFreeMutex; +#else +//$ifndef LINUX + CloseHandle(FMapping); + CloseHandle(FMMFFreeMutex); +//$endif +#endif + delete FStopEvent; + delete FReceiptEvent; + delete FRequestEvent; + delete FReplyEvent; +} + +void MCMMFReceiverThread::Execute(void) +{ + MCHandle HandleArray[2]; + + while(!getTerminated()) + { + TRY_BLOCK + { + // wait for messages to be delivered +#ifdef __GNUC__ + if(FRequestEvent->WaitFor(0) == wrSignaled) + { + ReceiveMessage(); + FMMFFreeMutex->setEvent(); + } + else + if(FStopEvent->WaitFor(0) == wrSignaled) + break; + Sleep(10); +#else +//$ifndef LINUX + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = FRequestEvent->getHandle(); + switch(long r = WaitForMultipleObjects(2, HandleArray, false, INFINITE)) { + case WAIT_OBJECT_0: + return; + case WAIT_OBJECT_0 + 1: + ReceiveMessage(); + } +//$endif +#endif + if(getTerminated()) + return; + } + CATCH_EVERY + { + } + } +} + +void MCMMFReceiverThread::Initialize(MCMMFTransport* Owner) +{ +#ifndef __GNUC__ +//$ifndef LINUX +#ifndef _WIN32_WCE + SECURITY_DESCRIPTOR pSD; + SECURITY_ATTRIBUTES SA; +#endif + SECURITY_ATTRIBUTES* pSA; +//$endif +#endif + long i; + MCMMFHeader* MMFPtr; + char* p; + + FOwner = Owner; +#ifndef __GNUC__ +//$ifndef LINUX +#ifndef _WIN32_WCE + if(IsWinNTUp) + { + if(!InitializeSecurityDescriptor(&pSD, SECURITY_DESCRIPTOR_REVISION)) + throw EMCError(MCError_SecurityInitFailed); + if(!SetSecurityDescriptorDacl(&pSD, true, NULL, false)) + throw EMCError(MCError_SecurityInitFailed); + SA.nLength = sizeof(SA); + SA.lpSecurityDescriptor = &pSD; + SA.bInheritHandle = true; + pSA = &SA; + } + else +#endif + pSA = NULL; +//$endif +#else +#define pSA NULL +#endif + + FStopEvent = new MCEvent(NULL, true , false, NULL); +#ifndef __GNUC__ +//$ifndef LINUX + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_MMFFreeMutex") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_MMFFreeMutex"); +#if defined(_WIN32_WCE) || defined(UNICODE) + LPCTSTR w = s2w(p); + FMMFFreeMutex = CreateMutex(pSA, true, w); + WaitForSingleObject(FMMFFreeMutex, 0); + delete (void*)w; +#else + FMMFFreeMutex = CreateMutex(pSA, true, p); + WaitForSingleObject(FMMFFreeMutex, 0); +#endif + MCMemFree(p); + i = GetLastError(); + if((FMMFFreeMutex && (i == ERROR_ALREADY_EXISTS)) || (!FMMFFreeMutex && (i != 0))) + THROW_ERROR(MCError_MutexCreationFailed); +//$endif +#endif + +#ifndef __GNUC__ +//$ifndef LINUX + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_ReceiptEvent") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_ReceiptEvent"); + FReceiptEvent = new MCEvent(pSA, false, false, p); + MCMemFree(p); + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_RequestEvent") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_RequestEvent"); + FRequestEvent = new MCEvent(pSA, false, false, p); + MCMemFree(p); + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_ReplyEvent") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_ReplyEvent"); + FReplyEvent = new MCEvent(pSA, false, false, p); + MCMemFree(p); +//$endif +#endif +#ifdef __GNUC__ + char* ttmpdir = getenv("TEMP"); + char tmpdir[1024]; + if(ttmpdir) + { + strcpy(tmpdir, ttmpdir); + strcat(tmpdir, "/"); + } + else + strcpy(tmpdir, "/tmp/"); + FMn = (char*)MCMemAlloc(strlen(tmpdir) + strlen(Owner->getMessengerName()) + strlen("_Mapping") + 1); + strcpy(FMn, tmpdir); + strcat(FMn, Owner->getMessengerName()); + strcat(FMn, "_Mapping"); + FMapping = open(FMn, O_CREAT|O_EXCL|O_RDWR|O_SYNC, 00666); + if(FMapping < 0) + THROW_ERROR(MCError_MMFCreationFailed); + + void *c; + lseek(FMapping, sizeof(long), SEEK_SET); + c = malloc(MMF_CLEAN_SIZE); + memset(c, 0, MMF_CLEAN_SIZE); + write(FMapping, c, MMF_CLEAN_SIZE); + free(c); + lseek(FMapping, 0, SEEK_SET); + + MMFPtr = (MCMMFHeader*)mmap(0, MMF_FRAME_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, FMapping, 0); + if(MMFPtr == MAP_FAILED) + THROW_ERROR(MCError_MMFCreationFailed); +#else + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_Mapping") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_Mapping"); +#if defined(_WIN32_WCE) || defined(UNICODE) + w = s2w(p); + FMapping = CreateFileMapping((void*)0xfffffffful, pSA, PAGE_READWRITE, 0, MMF_FRAME_SIZE, w); + delete (void*)w; +#else + FMapping = CreateFileMapping((void*)0xfffffffful, pSA, PAGE_READWRITE, 0, MMF_FRAME_SIZE, p); +#endif + MCMemFree(p); + i = GetLastError(); + if(((FMapping != 0) && (i == ERROR_ALREADY_EXISTS)) || ((FMapping == 0) && (i != 0))) + THROW_ERROR(MCError_MMFCreationFailed); + MMFPtr = (MCMMFHeader*)MapViewOfFile(FMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); + if(!MMFPtr) + THROW_ERROR(MCError_MMFCreationFailed); +#endif + + MMFPtr->dwMMFSize = MMF_FRAME_SIZE; + +#ifdef __GNUC__ + + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_MMFFreeMutex") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_MMFFreeMutex"); + FMMFFreeMutex = new MCEvent(NULL, false, false, p); + MCMemFree(p); + + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_ReceiptEvent") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_ReceiptEvent"); + FReceiptEvent = new MCEvent(pSA, false, false, p); + MCMemFree(p); + + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_RequestEvent") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_RequestEvent"); + FRequestEvent = new MCEvent(pSA, false, false, p); + MCMemFree(p); + + p = (char*)MCMemAlloc(strlen(Owner->getMessengerName()) + strlen("_ReplyEvent") + 1); + strcpy(p, Owner->getMessengerName()); + strcat(p, "_ReplyEvent"); + FReplyEvent = new MCEvent(pSA, false, false, p); + MCMemFree(p); + + if(!FMMFFreeMutex) + THROW_ERROR(MCError_MutexCreationFailed); + +#endif + +#ifdef __GNUC__ + munmap(MMFPtr, MMF_FRAME_SIZE); + FMMFFreeMutex->setEvent(); +#else +//$ifndef LINUX + UnmapViewOfFile(MMFPtr); + ReleaseMutex(FMMFFreeMutex); + ReleaseMutex(FMMFFreeMutex); // must be called twice to avoid a bug of CreateMutex (the one with ownership) +//$endif +#endif +} + +#ifdef _WIN32_WCE +//suppress C4509 +#pragma warning( disable : 4509) +#endif + +void MCMMFReceiverThread::ReceiveMessage(void) +{ + MCMMFHeader* MMFPtr; + MCMessageInfo *Info, *CurInfo; + __int64 StartTime, EndTime; + unsigned long ToWait; + MCMemStream* AStream; + long TotalSize; + MCHandle HandleArray[2]; + __int64 GTC; + MCMessage Message; + long i; + char* s; + + TRY_BLOCK + { + AStream = new MCMemStream(); + try { +#ifdef __GNUC__ + MMFPtr = (MCMMFHeader*)mmap(0, MMF_FRAME_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, FMapping, 0); + if (((void*) MAP_FAILED) == MMFPtr) +#else +//$ifndef LINUX + MMFPtr = (MCMMFHeader*)MapViewOfFile(FMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); + if(!MMFPtr) +//$endif +#endif +// return; // what else can we do? + RETURN + + try { +#ifndef __GNUC__ +//$ifndef LINUX + ResetEvent(FReceiptEvent->getHandle()); + ResetEvent(FReplyEvent->getHandle()); +//$endif +#else + FReceiptEvent->resetEvent(); + FReplyEvent->resetEvent(); +#endif + // initialize time counters + StartTime = GetTickCount(); + ToWait = FOwner->getMaxTimeout(); + EndTime = StartTime + ToWait; + + TotalSize = MMFPtr->dwDataSize; + do { + if(MMFPtr->dwBlockStart != AStream->Pos()) + { + AStream->SetPos(MMFPtr->dwBlockStart); + } + AStream->Write((char*)((long)MMFPtr + sizeof(MCMMFHeader)), MMFPtr->dwBlockSize); + + memset(((unsigned char*)MMFPtr + sizeof(unsigned long)), 0, MMF_CLEAN_SIZE); + + FReplyEvent->setEvent(); + + GTC = GetTickCount(); + if(GTC < StartTime) +#ifdef __GNUC__ + GTC = GTC + 0x100000000ll; +#else +//$ifndef LINUX + GTC = GTC + 0x100000000l; +//$endif +#endif + if(GTC > EndTime) + THROW_ERROR(MCError_TransportTimeout); + + if(ToWait != INFINITE) +#ifndef __GNUC__ +//$ifndef LINUX + ToWait = (unsigned long)(EndTime - (__int64)GTC); +//$endif +#else + ToWait = EndTime - GTC; +#endif + + +#ifdef __GNUC__ + long l_wait = ToWait*100; + while(true) + { + if(FStopEvent->WaitFor(0) == wrSignaled) + RETURN + if(FReceiptEvent->WaitFor(0) == wrSignaled) + break; + Sleep(10); + l_wait--; + if(l_wait == 0) + RETURN + } +#else +//$ifndef LINUX + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = FReceiptEvent->getHandle(); + if(WaitForMultipleObjects(2, HandleArray, false, ToWait) != WAIT_OBJECT_0 + 1) + { +// return; + RETURN + } +//$endif +#endif + // ResetEvent(FReplyEvent.Handle); + if(AStream->Len() < TotalSize) + { + GTC = GetTickCount(); + if(GTC < StartTime) +#ifdef __GNUC__ + GTC = GTC + 0x100000000ll; +#else +//$ifndef LINUX + GTC = GTC + 0x100000000l; +//$endif +#endif + if(GTC > EndTime) + THROW_ERROR(MCError_TransportTimeout); + + if(ToWait != INFINITE) +#ifndef __GNUC__ +//$ifndef LINUX + ToWait = (unsigned long)(EndTime - (__int64)GTC); +//$endif +#else + ToWait = EndTime - GTC; +#endif + +#ifdef __GNUC__ + l_wait = ToWait*100; + while(true) + { + if(FStopEvent->WaitFor(0) == wrSignaled) + RETURN + if(FRequestEvent->WaitFor(0) == wrSignaled) + break; + Sleep(10); + l_wait--; + if(l_wait == 0) + RETURN + } +#else +//$ifndef LINUX + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = FRequestEvent->getHandle(); + if(WaitForMultipleObjects(2, HandleArray, false, ToWait) != WAIT_OBJECT_0 + 1) + { +// return; + RETURN + } +//$endif +#endif + } + } while(AStream->Len() < TotalSize); +#ifdef __GNUC__ + } FINALLY ( + munmap(MMFPtr, MMF_FRAME_SIZE); + ) +#else +//$ifndef LINUX + } FINALLY ( + UnmapViewOfFile(MMFPtr); + ) +//$endif +#endif + // message received. Load it + Info = NULL; + AStream->SetPos(0); + if(AStream->Len() < (long)sizeof(long)) +// return; + RETURN + AStream->Read(&i, sizeof(i)); + //if(AStream->Len() < i + ((char*)(&Info->Message.Data) - (char*)(Info))) +// return; + // RETURN + s = NULL; + if(i > 0) + { + s = (char*)MCMemAlloc(i + 1); + AStream->Read(s, i); + s[i] = 0; + } + + Message.DataSize = 0; + Info = new MCMessageInfo(&Message); + Info->SMessenger = s; + Info->LoadFromStream(AStream); //AStream->Read(Info, (long)((char*)(&Info->Message.Data) - (char*)(Info))); + if(Info->State == imsDispatching) // we have received an original message + { + MCMessenger::SetMessageID(Info); + if(AStream->Len() - AStream->Pos() < Info->Message.DataSize) + { + if(Info->IsSendMsg && (!getTerminated())) + { + // decline the message as the data portion is corrupt + Info->MCError = MCError_GenTransportFailure; + Info->State = imsFailed; + FOwner->FCriticalSection->Enter(); + try { + FOwner->FOutgoingQueue->Add(Info); + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL;//MCMessenger::DestroyMessageInfo(Info); + } + RETURN + } + else + if(Info->Message.DataSize > 0) + { + Info->Message.Data = MCMemAlloc(Info->Message.DataSize); + AStream->Read(Info->Message.Data, Info->Message.DataSize); + } + else + Info->Message.Data = NULL; + FOwner->MessageReceived(Info); + } + else // we have received a reply + { + // remove the message from the list of pending messages + FOwner->FCriticalSection->Enter(); + try { + CurInfo = NULL; + for(i = 0;i < FOwner->FOutgoingQueue->Length();i++) + if(((MCMessageInfo*)((*FOwner->FOutgoingQueue)[i]))->OrigID == Info->OrigID) + { + CurInfo = (MCMessageInfo*)(*FOwner->FOutgoingQueue)[i]; + FOwner->FOutgoingQueue->Del(i); + break; + } + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + + if(!CurInfo) // the message was cancelled + { + delete Info; Info = NULL;//MCMessenger::DestroyMessageInfo(Info); + } + else + { + // we have to copy result data and signal about reply + if (bdtConst != CurInfo->Message.DataType) + { + if(NULL != CurInfo->Message.Data) + {//free old (request) data + MCMemFree(CurInfo->Message.Data); + CurInfo->Message.Data = NULL; + CurInfo->Message.DataSize = 0; + } + // read the resulting data from the stream + CurInfo->Message.DataSize = Info->Message.DataSize; + if(CurInfo->Message.DataSize > 0) + { + CurInfo->Message.Data = MCMemAlloc(CurInfo->Message.DataSize); + AStream->Read(CurInfo->Message.Data, Info->Message.DataSize); + } + else + CurInfo->Message.Data = NULL; + + // reset fields in Info + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + + CurInfo->Message.Result = Info->Message.Result; + CurInfo->MCError = Info->MCError; + CurInfo->State = Info->State; + + delete Info; Info = NULL;//MCMessenger::DestroyMessageInfo(Info); + FOwner->ReplyReceived(CurInfo); + } + } + } FINALLY ( + delete AStream; + ) + } + CATCH_EVERY + { + } +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCMMF.h b/libraries/external/eldos/pc/include/MCMMF.h new file mode 100755 index 0000000..b843669 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCMMF.h @@ -0,0 +1,161 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCMMF__ +#define __MCMMF__ + + +#include "MC.h" +#include "MCBase.h" +#include "MCSyncs.h" +#include "MCThreads.h" +#include "MCStream.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +#ifdef __GNUC__ +//$ifdef LINUX +# include +# include +# include +# include +# include +//$endif +#endif + + +typedef struct { + long dwMMFSize; + long dwErrorCode; + long bIsFirst; + long dwDataSize; // total size of the data + long dwBlockStart; // the number of byte on which current block starts + long dwBlockSize; // size of current block + // here goes the data +} MCMMFHeader; + +/* +class EMCMMFError: public EMCError { +protected: + static char* GetMessageFromErrorCode(long ErrorCode); +public: + EMCMMFError(long acode): EMCError(acode) { } +}; +*/ + +class MCMMFSenderThread; +class MCMMFReceiverThread; + +class MCMMFTransport:public MCSimpleTransport { +friend class MCMMFSenderThread; +friend class MCMMFReceiverThread; +protected: + //MCMutex* FCriticalSection; + char* FMessengerName; + MCMMFReceiverThread* FReceiverThread; + MCMMFSenderThread* FSenderThread; + + virtual bool DeliverMessage(char* DestAddress,MCMessageInfo* Info); + virtual void DoSetActive(void); + + virtual void KickSender(bool MessageFlag); + virtual void CancelMessageInSender(MCMessageInfo* Info); + virtual bool WasCancelled(MCMessageInfo* Info); + virtual void SetInfoSMessenger(MCMessageInfo* Info); + + virtual MCMMFSenderThread* CreateSenderThread(bool x); + virtual MCMMFReceiverThread* CreateReceiverThread(bool x); +public: + MCMMFTransport(void); + virtual ~MCMMFTransport(void); + + /* + The name of MMF that is used to transfer the messages + from other processes on the same computer. + Can't be empty. + */ + char* getMessengerName(void); + void setMessengerName(const char* Value); +}; + +class MCMMFSenderThread: public MCThread { +private: +friend class MCMMFTransport; + __int64 FCancelID; + MCEvent* FStopEvent; + MCMMFTransport* FOwner; +protected: + virtual void Execute(void); + void SendMessage(void); +public: + MCMMFSenderThread(bool CreateSuspended): MCThread(CreateSuspended) { } + virtual ~MCMMFSenderThread(void); + void Initialize(MCMMFTransport* Owner); +}; + +class MCMMFReceiverThread:public MCThread { +friend class MCMMFTransport; +private: +#ifdef __GNUC__ + char* FMn; + int FMapping; +#else +//$ifndef LINUX + MCHandle FMapping; +//$endif +#endif + /* + This event is used to signal possibility to send the data. + Once a sender grabs the event, nobody except the received is able to write + to MMF. + */ +#ifdef __GNUC__ + MCEvent* FMMFFreeMutex; + //This event is used to signal that reply has been received by sender + MCEvent* FReceiptEvent; + + //This event is used to signal about reply available in the MMF + MCEvent* FReplyEvent; + + //This event is used to signal about incoming data available in the MMF + MCEvent* FRequestEvent; +#else +//$ifndef LINUX + MCHandle FMMFFreeMutex; + + //This event is used to signal that reply has been received by sender + MCEvent* FReceiptEvent; + + //This event is used to signal about reply available in the MMF + MCEvent* FReplyEvent; + + //This event is used to signal about incoming data available in the MMF + MCEvent* FRequestEvent; +//$endif +#endif + MCEvent* FStopEvent; + MCMMFTransport* FOwner; +protected: + virtual void Execute(void); + void ReceiveMessage(void); + void Initialize(MCMMFTransport* Owner); +public: + MCMMFReceiverThread(bool CreateSuspended); + virtual ~MCMMFReceiverThread(void); +}; + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCOBEX.cpp b/libraries/external/eldos/pc/include/MCOBEX.cpp new file mode 100755 index 0000000..008553a --- /dev/null +++ b/libraries/external/eldos/pc/include/MCOBEX.cpp @@ -0,0 +1,1955 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#include +#ifdef _WIN32_WCE +# include +#endif + +#include "MCOBEX.h" + +#ifdef USE_NAMESPACE + +namespace MsgConnect +{ +#endif + +#define MAX_BUFF_SIZE 0x0400 // 1K = 1024 Bytes +#define MAX_FILE_NAME 0x0100 // 256 Bytes + +// OBEX Operation codes +#define OBEX_PUT (byte)0x02 +#define OBEX_PUT_FINAL (byte)0x82 +#define OBEX_CONNECT (byte)0x80 +#define OBEX_DISCONNECT (byte)0x81 + +// OBEX Header codes +#define OBEX_NAME (byte)0x01 +#define OBEX_LENGTH (byte)0xC3 +#define OBEX_DESCRIPTION (byte)0x05 +#define OBEX_PALM_CREATOR_ID (byte)0xCF +#define OBEX_BODY (byte)0x48 +#define OBEX_END_OF_BODY (byte)0x49 + +// OBEX Response codes +#define OBEX_CONTINUE (byte)0x90 +#define OBEX_SUCCESS (byte)0xA0 + +#define OBEX_VERSION (byte)0x10 +#define OBEX_CONNECT_FLAGS (byte)0x00 + +#define MAX_PKT_SIZE 0x800 +#define MAX_RECV_BUFF_LEN 0x100 +#define MAX_SEND_BUFF_LEN (MAX_BUFF_SIZE + 6) + +// ***************************** TMCOBEXTransport ****************************** + +MCOBEXTransport::MCOBEXTransport(void) +:MCSimpleTransport(), FOutgoingQueue(), FCriticalSection(), FThread(NULL), FListener(NULL), FCounter(0) +{ + FDefaultTransportName = "OBEX"; + FMessengerName = NULL; +//$ifdef MC_COMMERCIAL + FRoutingEnabled = true; +//$endif MC_COMMERCIAL +} + +MCOBEXTransport::~MCOBEXTransport(void) +{ + setActive(false); + FCounter--; + free(FMessengerName); +} + +void MCOBEXTransport::DiscoverIRDARemotes(unsigned int* devices, int& count) +{ + + int cnt = 0; + MCOBEXSocket *lSocket = NULL; + //allocate memory for IRDA list + if (NULL == devices || 0 == count) + return; + + DEVICELIST *cDevice = (PDEVICELIST)MCMemAlloc(sizeof(DEVICELIST) - sizeof(IRDA_DEVICE_INFO) + + (sizeof(IRDA_DEVICE_INFO) * count)); + + FCriticalSection.Enter(); + + TRY_BLOCK + { + lSocket = new MCOBEXSocket(); + lSocket->Init(istStream); + for (cnt=0; cntgetSocket(), SOL_IRLMP, IRLMP_ENUMDEVICES, (char*)cDevice, &numDevices) == SOCKET_ERROR) + { + MCMemFree(cDevice); + THROW_ERROR(MCError_WrongSocketResult); + } + + if (cDevice->numDevice > 0) + {//ok, now we have devices list - append them to result + for (unsigned int j=0; jnumDevice; j++) + memmove(devices+j, &cDevice->Device[j].irdaDeviceID, sizeof(cDevice->Device[j].irdaDeviceID)); + count = cDevice->numDevice; + break; + } + if (0 == cDevice->numDevice) + Sleep(200); + } + } + FINALLY + ( + delete lSocket; lSocket = NULL; + MCMemFree(cDevice); + FCriticalSection.Leave(); + ) +} + + +void MCOBEXTransport::CancelMessage(MCMessageInfo* Info) +{ + FCriticalSection.Enter(); + TRY_BLOCK + { + if(FThread) + FThread->FCancelID = Info->Message.MsgID; + FOutgoingQueue.Del(Info); + } FINALLY ( + FCriticalSection.Leave(); + ) +} + +bool MCOBEXTransport::CancelMessageByID(__int64 MsgID, DWORD ErrorCode, bool Discard) +{ + int i = 0; + MCMessageInfo* Info = NULL; + bool res = false; + + FCriticalSection.Enter(); + TRY_BLOCK + { + i = 0; + while (i < FOutgoingQueue.Length()) + { + Info = (MCMessageInfo*)(FOutgoingQueue[i]); + + if (Info->Message.MsgID == MsgID) + { + CancelMessage(Info); + Info->State = imsFailed; + Info->MCError = ErrorCode; + res = true; + + if (Discard == false) + { + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if (Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + FINALLY ( + FLinkCriticalSection->Leave(); + ) + } + else + { + delete Info; + Info = NULL; + } + break; + } + else + i++; + } + } + FINALLY ( + FCriticalSection.Leave(); + ) + return res; +} + +bool MCOBEXTransport::DeliverMessage(char* DestAddress, MCMessageInfo* Info) +{ + bool r; + char *p, *p1; + char *OBEXName = NULL, *QueueName = NULL, *irdaID = NULL; + long i; + + if(DestAddress && AddressValid(DestAddress)) + { + Info->Transport = this; + + if(!strchr(DestAddress, '|')) + THROW_ERROR(MCError_BadDestinationName); + + p = DestAddress; + p1 = p; + while (*p && (*p != '|') && (*p != ':')) + p++; + if(!*p) + THROW_ERROR(MCError_BadDestinationName); + if (p - p1 > 0) + { + if (*p == ':') + irdaID = strCopy(p1, 0, (long)(p - p1)); + else + OBEXName = strCopy(p1, 0, (long)(p - p1)); + } + else + THROW_ERROR(MCError_BadDestinationName); + + p++; + p1 = p; + + if (NULL == OBEXName) + { + while (*p && (*p != '|')) + p++; + if(!*p) + THROW_ERROR(MCError_BadDestinationName); + if (p - p1 > 0) + OBEXName = strCopy(p1, 0, (long)(p - p1)); + else + THROW_ERROR(MCError_BadDestinationName); + p++; + p1 = p; + } + + + // get queue name + p1 = p; + while(*p) + p++; + if(p - p1 > 0) + QueueName = strCopy(p1, 0, (long)(p - p1)); + else + THROW_ERROR(MCError_BadDestinationName); + +//$ifdef MC_COMMERCIAL + p1 = QueueName; + p = p1; + p += strlen(QueueName); + while (p != p1) + { + if (*p == '|') + { + if (Info->RouteTo) + MCMemFree(Info->RouteTo); + Info->RouteTo = strCopy(QueueName, 0, p - p1); + p++; + + char* tmpQ = (char*)MCMemAlloc(strlen(p) + 1); + strcpy(tmpQ, p); + MCMemFree(QueueName); + QueueName = tmpQ; + + break; + } + p--; + } +//$endif MC_COMMERCIAL + + // setup message info properties +// equPstr(Info->DQueue, QueueName, DQueueMaxLength); + strncpy(Info->DQueue, QueueName, DQueueMaxLength - 1); + Info->DQueue[DQueueMaxLength - 1] = 0; + //prepare dest name + + char* dstName = NULL; + if (NULL != irdaID) + { + dstName = (char*)MCMemAlloc(strlen(OBEXName)+strlen(irdaID)+2); + strcpy(dstName, irdaID); strcat(dstName, ":"); strcat(dstName, OBEXName); + MCMemFree(OBEXName); MCMemFree(irdaID); + } + else + dstName = OBEXName; + + Info->setDMessenger(OBEXName); + Info->setSMessenger(strdup(FMessengerName)); + + Info->State = imsDispatching; + + FCriticalSection.Enter(); + TRY_BLOCK + { + // place the message to the proper place in the queue + if(Info->IsSendMsg) + { + for(i = 0;i <= FOutgoingQueue.Length();i++) + { + if( (i == FOutgoingQueue.Length()) || + (((MCMessageInfo*)FOutgoingQueue[i])->IsSendMsg == false) ) + { + FOutgoingQueue.Insert(i, Info); + break; + } + } + } + else + FOutgoingQueue.Add(Info); + + ReleaseSemaphore(FOutgoingCount, 1, NULL);//.Release(); + } FINALLY ( + FCriticalSection.Leave(); + ) + r = true; + } + else + r = false; + return r; +} + +void MCOBEXTransport::DeliveryFailed(MCMessageInfo* Info) +{ + FCriticalSection.Enter(); + try { + FOutgoingQueue.Del(Info); + } FINALLY ( + FCriticalSection.Leave(); + ) + + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger && (Info->State == imsDispatching) && Info->IsSendMsg +//$ifdef MC_COMMERCIAL + && (!Info->Intermed) +//$endif + && (!FThread || (Info->Message.MsgID != FThread->FCancelID))) + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + Info->State = imsFailed; + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +//$ifdef MC_COMMERCIAL +void MCOBEXTransport::setRoutingAllowed(bool Value) +{ + FRoutingEnabled = Value; +} + +bool MCOBEXTransport::getRoutingAllowed(void) +{ + return FRoutingEnabled; +} +//$endif MC_COMMERCIAL + +void MCOBEXTransport::setSelectRemoteProc(MCSelectRemoteProc Value) +{ + FSelectRemoteProc = Value; +} + +MCSelectRemoteProc MCOBEXTransport::getSelectRemoteProc(void) +{ + return(FSelectRemoteProc); +} + +void MCOBEXTransport::DoSetActive(void) +{ + if(!FMessenger) + return; + if(getActive()) + {//ok, we are turning on + if(!getMessengerName()) + THROW_ERROR(MCError_NoMessengerName); + if(FCounter <= 0) + { + FThread = new MCOBEXThread(true); + FListener = new MCOBEXListener(true); + // initialize thread + int MCErrorCode = 0; + FThread->Initialize(this); + FListener->Initialize(FThread); + FThread->setFreeOnTerminate(false); + FThread->Resume(); + FListener->setFreeOnTerminate(false); + FListener->Resume(); + } + FCounter++; + } + else + {//we are turned off + if(FCounter <= 0) + { + if (NULL != FThread) + { + FThread->Terminate(); + FThread->FStopEvent->setEvent(); + FThread->WaitFor(); + } + delete FThread; FThread = NULL; + if (NULL != FListener) + { + FListener->Terminate(); + FListener->WaitFor(); + } + delete FListener; FListener = NULL; + } + } +} + +/*void MCOBEXTransport::MessageProcessed(MCMessageInfo* Info) +{ + long i = 0; + + Info->DQueue[0] = 0; + MCMemFree(Info->DMessenger); + char* dest = NULL; + if (NULL != Info->URL) + { + dest = (char*)MCMemAlloc(strlen(Info->SMessenger) + strlen(Info->URL) + 2); + strcpy(dest, Info->URL); strcat(dest, ":"); strcat(dest, Info->SMessenger); + } + else + dest = strdup(Info->SMessenger); + Info->setDMessenger(dest); + Info->setSMessenger(FMessengerName); + if(Info->Message.DataType == bdtConst) + { + if((Info->Message.DataSize != 0) && Info->Message.Data) + MCMemFree(Info->Message.Data); + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + FCriticalSection.Enter(); + TRY_BLOCK + { + for(i = 0; i <= FOutgoingQueue.Length(); i++) + { + if( (i == FOutgoingQueue.Length()) || + (((MCMessageInfo*)FOutgoingQueue[i])->IsSendMsg == false)) + { + FOutgoingQueue.Insert(i, Info); + break; + } + } + ReleaseSemaphore(FOutgoingCount, 1, NULL);//.Release(); + } FINALLY ( + FCriticalSection.Leave(); + ) +} + + + +void MCOBEXTransport::MessageReceived(MCMessageInfo* Info) +{ + // add to incoming queue + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger) + { + // check message credentials + if(!FMessenger->ValidateCredentials(Info)) + { + Info->MCError = MCError_WrongCredentials; + Info->State = imsFailed; + // if the message was posted, no need to return it back + if(Info->IsSendMsg) + { + FLinkCriticalSection->Leave(); + MessageProcessed(Info); + FLinkCriticalSection->Enter(); + } + else { + delete Info; Info = NULL; + } + } + else + { + Info->MCError = 0; + Info->Transport = this; + Info->State = imsWaiting; + + FMessenger->FIncomingCriticalSection->Enter(); + TRY_BLOCK { + FMessenger->FIncomingQueue->Add(Info); + FMessenger->FIncomingEvent->setEvent(); + } FINALLY ( + FMessenger->FIncomingCriticalSection->Leave(); + ) + } + } + else + { + delete Info; Info = NULL; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +void MCOBEXTransport::ReplyReceived(MCMessageInfo* Info) +{ + // add to complete queue + FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FMessenger) + { + FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK { + FMessenger->FCompleteQueue->Add(Info); + FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + delete Info; Info = NULL; + } + } FINALLY ( + FLinkCriticalSection->Leave(); + ) +} + +*/ +char* MCOBEXTransport::getMessengerName(void) +{ + return FMessengerName; +} + +void MCOBEXTransport::setMessengerName(const char* Value) +{ + bool b; + if(!FMessengerName && !Value) + return; + if(!FMessengerName || !Value || !strcmp(FMessengerName, Value)) + { + b = getActive(); + setActive(false); + if(FMessengerName) + MCMemFree(FMessengerName); + FMessengerName = strdup(Value); + setActive(b); + } +} + +// ******************************** MCOBEXSocket ******************************* + +MCSocket* MCOBEXSocket::CreateSame(void) +{ + return new MCOBEXSocket(); +} + +MCSocket* MCOBEXSocket::Accept(void) +{ + SOCKADDR_IRDA addr; + int addrSize = sizeof(addr); + + TSocket NewSocket = 0; + MCSocket* r = NULL; + + if(FState != issListening) + THROW_ERROR(MCError_WrongSocketState); + + NewSocket = accept(FSocket, (sockaddr*)&addr, &addrSize); + if(NewSocket != (long)INVALID_SOCKET) + { + r = CreateSame(); + r->FSocket = NewSocket; + r->FDirection = isdIncoming; + r->FState = issConnected; + unsigned int irdaID = 0; + memmove(&irdaID, &addr.irdaDeviceID, sizeof(irdaID)); + ((MCOBEXSocket*)r)->setIrdaID(irdaID); + } + else + return NULL; + return r; +} + +long MCOBEXSocket::Bind(void) +{ + long r = 0; + // buffer for IAS set + byte IASSetBuff[sizeof (IAS_SET) - 3 + IAS_MAX_ATTRIBNAME]; + int IASSetLen = sizeof (IASSetBuff); + PIAS_SET pIASSet = (PIAS_SET) &IASSetBuff; + + memcpy(&pIASSet->irdaClassName[0], "MCOBEX", 7); + // include length of the NULL character in the end + + memcpy(&pIASSet->irdaAttribName[0], "IrDA:TinyTP", 12); + + pIASSet->irdaAttribType = IAS_ATTRIB_STR; + pIASSet->irdaAttribute.irdaAttribUsrStr.Len = 12; + + if (setsockopt(FSocket, SOL_IRLMP, IRLMP_IAS_SET, (const char *) + pIASSet, IASSetLen) == SOCKET_ERROR) + r = LAST_ERROR; + SOCKADDR_IRDA FAddr = {AF_IRDA, 0, 0, 0, 0, "MCOBEX"}; + + if((FSocket == (long)INVALID_SOCKET) && (Init(istStream) != 0)) + THROW_ERROR(MCError_NotASocket); + + r = bind(FSocket, (const struct sockaddr *) &FAddr, sizeof(FAddr)); + if(r == 0) + FState = issBound; + else + r = LAST_ERROR; + return r; +} + +void MCOBEXSocket::Close(bool Forced) +{ + if(FSocket != (long)INVALID_SOCKET) + { + if(!Forced) + shutdown(FSocket, SD_BOTH); + closesocket(FSocket); + FSocket = INVALID_SOCKET; + FState = issNotASocket; + } + else + if(FState == issInitializing) + FCloseRequest = true; +} + +long MCOBEXSocket::Connect(void) +{ + SOCKADDR_IRDA FAddr = {AF_IRDA, 0, 0, 0, 0, "OBEX"}; + long r = 0; + PDEVICELIST pDL = NULL; + + char szServiceName[12]; + char cDevice[0x100]; + int cnt = 0; + + byte IASQueryBuff[sizeof(IAS_QUERY) - 3 + IAS_MAX_ATTRIBNAME]; + int IASQueryLen = sizeof(IASQueryBuff); + PIAS_QUERY pIASQuery = (PIAS_QUERY) &IASQueryBuff; + + MCSocket::Connect(); + if((FSocket == (long)INVALID_SOCKET) && (Init(istStream) != 0)) + THROW_ERROR(MCError_NotASocket); + + if(FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + + memset (cDevice, 0, sizeof (cDevice)); + int nSize = sizeof (cDevice); + unsigned long nDev = 0; + + if (0 == FIrdaID) + {//try to find any device + for (cnt = 0 ; cnt < 10 ; cnt++) + { + if (getsockopt(FSocket, SOL_IRLMP, IRLMP_ENUMDEVICES, cDevice, &nSize) == SOCKET_ERROR) + { + r = LAST_ERROR; + return r; + } + else + pDL = (PDEVICELIST)cDevice; + + if (pDL->numDevice != 0) // Found at least one device + break; + + Sleep(200); + } + + if (cnt == 10) // If there isn't any device in range, exit + return LAST_ERROR; + memmove(&FIrdaID, &pDL->Device[0].irdaDeviceID, sizeof(FIrdaID)); + } + + // Query IAS database + // irdaClassName and irdaAttribName are case sensitive + memcpy(&pIASQuery->irdaDeviceID, pDL->Device[nDev].irdaDeviceID, 4); + memcpy(&pIASQuery->irdaClassName, "MCOBEX", 7); + memcpy(&pIASQuery->irdaAttribName, "IrDA:TinyTP:LsapSel", 20); + + if (getsockopt(FSocket, SOL_IRLMP, IRLMP_IAS_QUERY, (char *)pIASQuery, &IASQueryLen) == SOCKET_ERROR) + return LAST_ERROR; + + sprintf(szServiceName, "LSAP-SEL%d", pIASQuery->irdaAttribute.irdaAttribInt); + + memset (&FAddr, 0, sizeof(FAddr)); + FAddr.irdaAddressFamily = AF_IRDA; + memcpy (FAddr.irdaDeviceID, &FIrdaID, 4); + memcpy (FAddr.irdaServiceName, szServiceName, strlen(szServiceName) + 1); + + r = connect(FSocket, (sockaddr*)&FAddr, sizeof(FAddr)); + + if(r == 0) + FState = issConnected; + else + r = LAST_ERROR; + return r; +} + +long MCOBEXSocket::Init(MCSocketType SocketType) +{ + long r = 0; + + if(FState != issNotASocket) + THROW_ERROR(MCError_WrongSocketState); + + FState = issInitializing; + FSocket = socket(AF_IRDA, SOCK_STREAM, 0); + if(FSocket == (long)INVALID_SOCKET) + r = LAST_ERROR; + else + r = 0; + if(FCloseRequest) + { + FCloseRequest = false; + FState = issNotASocket; + if(r == 0) + closesocket(FSocket); + FSocket = INVALID_SOCKET; + return r; + } + if(r == 0) + FState = issInitialized; + return r; +} + +long MCOBEXSocket::Listen(long BackLog) +{ + long r = 0; + + MCSocket::Listen(BackLog); + if(FSocket == (long)INVALID_SOCKET) + THROW_ERROR(MCError_NotASocket); + + if(FState != issBound) + { + if(FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + r = Bind(); + if(0 != r) + return r; + } + // The backlog parameter is currently limited (silently) to + // 2. (API Reference) + if(BackLog > 2 /*SOMAXCONN*/) + BackLog = 2 /*SOMAXCONN*/; + r = listen(FSocket, BackLog); + if(r == 0) + FState = issListening; + else + r = LAST_ERROR; + return r; +} + +long MCOBEXSocket::Receive(void* Data, long DataLen, long& Received) +{ + long r; + if(FState != issConnected) + THROW_ERROR(MCError_WrongSocketState); + + r = recv(FSocket, (char*)Data, DataLen, 0); + if(r == SOCKET_ERROR) + { + Received = 0; + r = LAST_ERROR; + } + else + { + Received = r; + r = 0; + } + return r; +} + +long MCOBEXSocket::Send(void* Data, long DataLen, long& Sent) +{ + long r; + if(FState != issConnected) + THROW_ERROR(MCError_WrongSocketState); + + r = send(FSocket, (char*)Data, DataLen, 0); + if(r == SOCKET_ERROR) + { + Sent = 0; + r = LAST_ERROR; + } + else + { + Sent = r; + r = 0; + } + return r; +} + +long MCOBEXSocket::ReceiveFrom(void* Data, long DataLen, long& Received, char*& RemoteAddress, + unsigned int& RemotePort) +{ + return Receive(Data, DataLen, Received); +} + +long MCOBEXSocket::SendTo(void* Data, long DataLen, long& Sent, char* RemoteAddress, + unsigned int RemotePort) +{ + return Send(Data, DataLen, Sent); +} + +// ***************************** TMCOBEXThread ****************************** + +MCOBEXThread::MCOBEXThread(bool CreateSuspended):MCThread(CreateSuspended) +{ + FCancelID = 0; + FStopEvent = NULL; + FRecvEvent = NULL; + FOwner = NULL; + //FOwners = new MCList(); + FSocket = NULL; + FOutgoingStream = NULL; +} + +MCOBEXThread::~MCOBEXThread(void) +{ + delete FRecvEvent; + delete FStopEvent; +} + +void MCOBEXThread::Execute(void) +{ +#ifndef __GNUC__ + HANDLE HandleArray[3]; + bool br = false; +#endif + + while(!getTerminated()) + { + TRY_BLOCK + { + // wait for messages to be delivered + +#ifdef __GNUC__ + if (FOutgoingCount.Wait(1)) + SendMessage(); + if(FStopEvent->WaitFor(0) == wrSignaled) + break; + if(FRecvEvent->WaitFor(0) == wrSignaled) + ReceiveMessage(); + Sleep(10); +#else + HandleArray[0] = FStopEvent->getHandle(); + HandleArray[1] = FOwner->FOutgoingCount;//.getHandle(); + HandleArray[2] = FRecvEvent->getHandle(); + switch(WaitForMultipleObjects(3, HandleArray, false, INFINITE)) { + case WAIT_OBJECT_0: + br = true; + break; + case WAIT_OBJECT_0 + 1: + SendMessage(); + break; + case WAIT_OBJECT_0 + 2: + FRecvEvent->resetEvent(); + ReceiveMessage(); + break; + } + if(br) + break; +#endif + if(getTerminated()) + return; + } + CATCH_EVERY + { + } + } +} + +void MCOBEXThread::Initialize(MCOBEXTransport* Owner) +{ + FOwner = Owner; +// FOwners->Add(Owner); + FStopEvent = new MCEvent(NULL, true , false, NULL); + FRecvEvent = new MCEvent(NULL, true , false, NULL); +} + +void MCOBEXThread::setOutgoingStream(MCStream* Value) +{ + FOutgoingStream = Value; +} + +MCStream* MCOBEXThread::getOutgoingStream(void) +{ + return FOutgoingStream; +} + +void MCOBEXThread::setIncomingStream(MCStream* Value) +{ + FIncomingStream = Value; +} + +MCStream* MCOBEXThread::getIncomingStream(void) +{ + return FIncomingStream; +} + +MCMessageInfo* MCOBEXThread::GetMessageForDelivery(void) +{ + long i; + MCMessageInfo *r, *r1 = NULL; + + FOwner->FCriticalSection.Enter(); + TRY_BLOCK + { + for(i = 0; i < FOwner->FOutgoingQueue.Length(); i++) + { + r = (MCMessageInfo*)(FOwner->FOutgoingQueue[i]); + if(r->State == imsDispatching || + r->State == imsComplete || + r->State == imsFailed) + { + r1 = r; + break; + } + } + } FINALLY ( + FOwner->FCriticalSection.Leave(); + ) + return r1; +} + +MCMessageInfo* MCOBEXThread::PrepareMessageForSending(void) +{ + long i,j; + MCMessageInfo* Info; + MCMemStream* MemStream; + void* DataBuf; + long DataLen; + MCOBEXHeader Header; + char* s; + bool r = false, immExit = false; + MCOBEXTransport* FOwner = NULL; + int extra; + bool im = false,wrt; + unsigned char bt = 0; + + TRY_BLOCK + { + Info = GetMessageForDelivery(); + if(!Info) + { + r = false; immExit = true; + } + + if (false == immExit) + { + FOwner = (MCOBEXTransport*)Info->Transport; + Info->setSMessenger(strdup(FOwner->getMessengerName())); + + // write data for conversion + MemStream = new MCMemStream(); + MemStream->Write(Info, (long)((char*)&Info->Message.Data - (char*)Info)); + if(Info->Message.DataSize > 0) + MemStream->Write(Info->Message.Data, Info->Message.DataSize); + + Info->State = imsWaiting; + + DataLen = MemStream->Len(); + DataBuf = MCMemAlloc(DataLen); + MemStream->SetPos(0); + MemStream->Read(DataBuf, DataLen); + MemStream->SetPointer(NULL, 0); + + // prepare data block + Header.dwSignature = 0x50444945ul; + Header.dwDataSize = DataLen + sizeof(Header) + strlen(Info->SMessenger) + sizeof(long); + extra = 2 + 4 + 4 + 4; + +//$ifdef MC_COMMERCIAL +// till palm version will not have routing !!! +// if (Info->RecvPath) +// extra += strlen(Info->RecvPath); +// if (Info->RouteTo) +// extra += strlen(Info->RouteTo); +// if (Info->DQueue) +// extra += strlen(Info->DQueue); + if (im) + { + Header.dwCompressID = Info->CompressID; + Header.dwEncryptID = Info->EncryptID; + Header.dwSealID = Info->SealID; + } + else +//$endif MC_COMMERCIAL + { + Header.dwCompressID = FOwner->getCompressor()?FOwner->getCompressor()->GetID():0; //!!!!!!!!! + Header.dwEncryptID = FOwner->getEncryptor()?FOwner->getEncryptor()->GetID():0; + Header.dwSealID = FOwner->getEncryptor()?FOwner->getEncryptor()->GetID():0; + } + + s = strdup(FOwner->getMessengerName()); + FOwner->PrepareDataBlock(s, DataBuf, DataLen, DataBuf, DataLen, Header.dwEncryptID, Header.dwCompressID, Header.dwSealID); + s = NULL; + Header.dwDataSize = DataLen + sizeof(Header) + strlen(Info->SMessenger) + sizeof(long); + + // this will be used for routing and transactions + Header.dwDataSize += extra; + + // allocate stream for outgoing data + setOutgoingStream(MemStream); + + // write outgoing data + // write header + getOutgoingStream()->Write(&Header, sizeof(Header)); + + // write source address + i = strlen(Info->SMessenger); + + j = i; + + // this will be used for routing and transactions + i += extra; + + getOutgoingStream()->Write(&i, sizeof(i)); + if(j > 0) + getOutgoingStream()->Write(Info->SMessenger, j); + + wrt = false; + //$ifdef MC_COMMERCIAL + bt = 0; + getOutgoingStream()->Write(&bt, sizeof(bt)); + bt = (char) Info->TransactCmd; + getOutgoingStream()->Write(&bt, sizeof(bt)); + + // write RecvPath + if (Info->RecvPath) + i = strlen(Info->RecvPath); + else + i = 0; + getOutgoingStream()->Write(&i, sizeof(i)); + if (i > 0) + getOutgoingStream()->Write(Info->RecvPath, i); + + // write RouteTo + if (Info->RouteTo) + i = strlen(Info->RouteTo); + else + i = 0; + getOutgoingStream()->Write(&i, sizeof(i)); + if (i > 0) + getOutgoingStream()->Write(Info->RouteTo, i); + + // write DQueue +// till palm version will not have routing !!! +// if (Info->DQueue) +// i = strlen(Info->DQueue); +// else + i = 0; + getOutgoingStream()->Write(&i, sizeof(i)); + if (i > 0) + getOutgoingStream()->Write(Info->DQueue, i); + + wrt = true; +//$else + if (!wrt) + { + char buf[14]; + memset(buf, 0, 14); + getOutgoingStream()->Write(buf, sizeof(buf)); + } +//$endif + + // write actual data + getOutgoingStream()->Write(DataBuf, DataLen); + getOutgoingStream()->SetPos(0); + + MCMemFree(DataBuf); + r = true; + } + } + CATCH_EVERY + { + r = false; + } + return r ? Info : NULL; +} + +void MCOBEXThread::SendMessage(void) +{ + MCMessageInfo* Info = NULL; + bool immExit = false; + char irdaID[16]; + + if(Info = PrepareMessageForSending()) + { + MCOBEXTransport* FOwner = (MCOBEXTransport*)Info->Transport; + FOwner->FCriticalSection.Enter(); + TRY_BLOCK + { + FSocket = new MCOBEXSocket(); + FSocket->Init(istStream); + //get the irdaID from DMessenger + char* smc = strchr(Info->DMessenger, ':'); + if ( NULL != smc) + { + int smcPos = smc - Info->DMessenger; + memmove(irdaID, Info->DMessenger, smcPos); + FSocket->setIrdaID(atoi(irdaID)); + int destLen = strlen(Info->DMessenger); + memmove(Info->DMessenger, smc+1, destLen - smcPos); + Info->DMessenger[destLen-smcPos] = 0; + } + + if(FSocket->Connect() == 0) + { + byte dataBuff[MAX_SEND_BUFF_LEN]; + byte recvBuff[MAX_RECV_BUFF_LEN]; + + dataBuff[0] = OBEX_CONNECT; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)7); + dataBuff[3] = OBEX_VERSION; + dataBuff[4] = OBEX_CONNECT_FLAGS; + *((unsigned short *)&dataBuff[5]) = htons((unsigned short)MAX_PKT_SIZE); + + long res; + + if (FSocket->Send(dataBuff, 7, res) == SOCKET_ERROR) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + + if (!immExit) + { + if ((FSocket->Receive((char *)recvBuff, MAX_RECV_BUFF_LEN, res) == SOCKET_ERROR) + || (recvBuff[0] != OBEX_SUCCESS)) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + } + + /* Now convert the unicode file name text from host to network byte order */ + int i = 0; + if (!immExit) + { + char t[256]; + snprintf(t, 255, "%s.mcm", Info->DMessenger); +// snprintf(t, 255, "%s.vcf", Info->DMessenger); + for (i=0; i <= (long)strlen(t); i++) + *((unsigned short *)&dataBuff[6 + 2 * i]) = htons((unsigned short)t[i]); + } + + if (!immExit) + { + dataBuff[0] = OBEX_PUT; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)(i * 2 + 6)); + dataBuff[3] = OBEX_NAME; + *((unsigned short *)&dataBuff[4]) = htons((unsigned short)(i * 2 + 3)); + + if (FSocket->Send(dataBuff, 6 + i * 2, res) == SOCKET_ERROR) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + } + + if (!immExit) + { + if ((FSocket->Receive((char *)recvBuff, MAX_RECV_BUFF_LEN, res) == SOCKET_ERROR) + || (recvBuff[0] != OBEX_CONTINUE)) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + } + + if (!immExit) + { + dataBuff[0] = OBEX_PUT; + dataBuff[3] = OBEX_BODY; + + size_t count = 0; + /* Read and send 1K chunks of data to the device */ + /* + char text[] = "BEGIN:VCARD\r\n" + "VERSION:2.1\r\n" + "N:Doe;John\r\n" + "EMAIL;PREF;INTERNET:john@doe.com\r\n" + "UID:123456789\r\n" + "END:VCARD\r\n"; + + count = strlen(text) + 1; + memcpy(&dataBuff[6], text, count); + */ + while (((count = getOutgoingStream()->Read(&dataBuff[6], MAX_BUFF_SIZE)) != 0) && !immExit) + { + if (count < MAX_BUFF_SIZE) + { + dataBuff[0] = OBEX_PUT_FINAL; + dataBuff[3] = OBEX_END_OF_BODY; + } + + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)(count + 6)); + *((unsigned short *)&dataBuff[4]) = htons((unsigned short)(count + 3)); + + if(FSocket->Send(dataBuff, count + 6, res) == SOCKET_ERROR) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + continue; + } + + if (!immExit) + { + if((FSocket->Receive((char *)recvBuff, MAX_RECV_BUFF_LEN, res) == SOCKET_ERROR) + || ((dataBuff[0] == OBEX_PUT) && (recvBuff[0] != OBEX_CONTINUE)) + || ((dataBuff[0] == OBEX_PUT_FINAL) && (recvBuff[0] != OBEX_SUCCESS))) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + } + } + } + + if (!immExit) + { + dataBuff[0] = OBEX_DISCONNECT; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)3); + + if (FSocket->Send(dataBuff, 3, res) == SOCKET_ERROR) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + } + + if (!immExit) + { + + if ((FSocket->Receive((char *)recvBuff, MAX_RECV_BUFF_LEN, res) == SOCKET_ERROR) + || ((recvBuff[0] != OBEX_CONTINUE) && (recvBuff[0] != OBEX_SUCCESS))) + { + Info->MCError = MCError_ConnectionLost; + FOwner->DeliveryFailed(Info); + immExit = true; + } + } + if (!immExit) + { + delete FSocket; + delete getOutgoingStream(); + setOutgoingStream(NULL); + } + } + } FINALLY ( + FOwner->FCriticalSection.Leave(); + ) + } +} + +void MCOBEXThread::ReceiveMessage(void) +{ + long iRcvd = 0, iSent; + int packetLen = 0; + byte dataBuff[MAX_BUFF_SIZE]; + MCMemStream* MemStream; + unsigned char fname[MAX_FILE_NAME]; + bool immExit = false; + + FOwner->FCriticalSection.Enter(); + TRY_BLOCK + { + if((FServer->Receive(dataBuff, sizeof(dataBuff), iRcvd)) == SOCKET_ERROR + || iRcvd != 7 || dataBuff[0] != OBEX_CONNECT) + immExit = true; + + if (!immExit) + { + dataBuff[0] = OBEX_SUCCESS; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)7); + dataBuff[3] = OBEX_VERSION; + dataBuff[4] = OBEX_CONNECT_FLAGS; + *((unsigned short *)&dataBuff[5]) = htons((unsigned short)MAX_BUFF_SIZE); + packetLen = 7; + if(FServer->Send(dataBuff, packetLen, iSent) == SOCKET_ERROR) + immExit = true; + } + + if (!immExit) + { + if((FServer->Receive(dataBuff, sizeof(dataBuff), iRcvd)) == SOCKET_ERROR || dataBuff[0] != OBEX_PUT || dataBuff[3] != OBEX_NAME) + immExit = true; + } + + if (!immExit) + { + if(iRcvd > (MAX_FILE_NAME + 6)) + iRcvd = MAX_FILE_NAME + 6; + int fn_len = iRcvd - 6; + for (int i=0; i < (fn_len/2); i++) + fname[i] = (unsigned char)(ntohs(*(unsigned short *)&dataBuff[6 + 2*i]) & 0xff); + dataBuff[0] = OBEX_CONTINUE; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)3); + packetLen = 3; + if(FServer->Send(dataBuff, packetLen, iSent) == SOCKET_ERROR) + immExit = true; + } + + if (!immExit) + { + MemStream = new MCMemStream(); + setIncomingStream(MemStream); + while(!immExit) + { + if((FServer->Receive(dataBuff, sizeof(dataBuff), iRcvd)) == SOCKET_ERROR) + { + immExit = true; + continue; + } + unsigned char* buff = (unsigned char*)&dataBuff[0]; + + if (*buff == OBEX_DISCONNECT) + { + dataBuff[0] = OBEX_SUCCESS; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)3); + packetLen = 3; + FServer->Send(dataBuff, packetLen, iSent); + break; + } + + while((*buff != OBEX_BODY) && (*buff != OBEX_END_OF_BODY)) + { + if ((*buff == OBEX_PUT) || (*buff == OBEX_PUT_FINAL)) + { + iRcvd = ntohs(*(unsigned short *)(buff + 1)) - 3; + buff += 3; + } + else if ((*buff == OBEX_NAME) || (*buff == OBEX_DESCRIPTION)) + { + buff += ntohs(*(unsigned short *)(buff + 1)); + iRcvd -= ntohs(*(unsigned short *)(buff + 1)); + } + else if ((*buff == OBEX_LENGTH) || (*buff == OBEX_PALM_CREATOR_ID)) + { + buff += 5; // both occupy 4 bytes... + iRcvd -= 5; + } + + if(iRcvd <= 0) + break; + } + + if ((*buff == OBEX_BODY) || (*buff == OBEX_END_OF_BODY)) + { + int size = ntohs(*(unsigned short *)(buff + 1)); + getIncomingStream()->Write(buff + 3, size - 3); + iRcvd -= size; + + dataBuff[0] = OBEX_CONTINUE; + if(*buff == OBEX_END_OF_BODY) + dataBuff[0] = OBEX_SUCCESS; + *((unsigned short *)&dataBuff[1]) = htons((unsigned short)3); + packetLen = 3; + if(FServer->Send(dataBuff, packetLen, iSent) == SOCKET_ERROR) + { + immExit = true; + continue; + } + } + } + } + + if (!immExit) + { + for(int i1 = strlen((char*)fname); i1 > 0; i1--) + { + if (fname[i1 - 1] == '.') + { + fname[i1 - 1] = 0; + break; + } + } + MessageReceivedCompletely(strdup((char*)fname), FServer->getIrdaID()); + } + } FINALLY ( + delete FServer; FServer = NULL; + FOwner->FCriticalSection.Leave(); + FOwner->FListener->Resume(); + ) +} + +MCOBEXTransport* MCOBEXThread::FindMessenger(char* name) +{ + return FOwner;//->FMessenger; + + /*for(int i = FOwners->Length(); i > 0; i--) + if(strcmp(name, ((MCOBEXTransport*)((*FOwners)[i - 1]))->getMessengerName()) == 0) + return((MCOBEXTransport*)((*FOwners)[i - 1])); + return NULL; */ +} + +bool MCOBEXThread::MessageReceivedCompletely(char* MessengerName, unsigned int irdaID) +{ + MCOBEXHeader Header; + bool r = false; + long i; + char* s = NULL; + char* RemoteMessenger = NULL; + void* DataBuf = NULL; + long DataLen; + char irdaIDBuf[16]; + + MCMessageInfo *Info = NULL, *CurInfo = NULL; + MCMessage* Message = NULL; + MCMemStream* AStream = NULL; + MCOBEXTransport* FOwner = FindMessenger(MessengerName); + +//this is used always, but is related to MC_COMMERCIAL + char* RouteTo = NULL; + char* RecvPath = NULL; + char TransactCmd = 0; + char* DQueue = NULL; + bool immExit = false; + + if(!FOwner) + { + delete getIncomingStream(); + setIncomingStream(NULL); + return(false); + } + TRY_BLOCK + { + Message = new MCMessage(); + FOwner->FCriticalSection.Enter(); + TRY_BLOCK + { + r = getIncomingStream() != NULL; + if(r) + { + TRY_BLOCK + { + getIncomingStream()->SetPos(0); + + // read the header and smessenger + getIncomingStream()->Read(&Header, sizeof(Header)); + + // read the source messenger name + getIncomingStream()->Read(&i, sizeof(i)); + if(i > 0) + { + RemoteMessenger = (char*)MCMemAlloc(i + 1); + getIncomingStream()->Read(RemoteMessenger, i); + RemoteMessenger[i] = 0; + s = RemoteMessenger; + + // here comes information about transacations and routing + if ((long)strlen(s) < i) + { + while (true) + { + char* tmp_p = (char*) MCMemAlloc(strlen(s) + 1); + strcpy(tmp_p, s); + + char* ps = s + strlen(s) + 1; + char* pe = ps + i - strlen(s); + if (pe - ps < 14) + break; + + // read TransactCmd + TransactCmd = *ps; + ps++; + + // read RecvPath + i = *((int*)(ps)); + ps += 4; + + if (pe - ps < i + 4) + break; + + if (i) + { + RecvPath = strCopy(ps, 0, i); + ps += i; + } + + // read RouteTo + i = *((int*)(ps)); + ps += 4; + + if (pe - ps < i + 4) + break; + + if (i) + { + RouteTo = strCopy(ps, 0, i); + ps += i; + } + + // read DQueue + i = *((int*)(ps)); + ps += 4; + if (pe - ps < i) + break; + + if (i) + DQueue = strCopy(ps, 0, i); + + MCMemFree(s); + s = tmp_p; + + r = true; + break; + } + if (!r) + { + MCMemFree(s); + s = NULL; + immExit = true; + } + else + { + r = false; + } + } + } + else + RemoteMessenger = NULL; + + // if we are an intermediate node, we must add sender path to RecvPath + if (!immExit) + { + if (RouteTo != NULL) + { + char* tmpPath; + int npl; + if (RecvPath != NULL) + { + npl = strlen(FOwner->RealTransportName()) + 1 + strlen(s) + 1 + strlen(RecvPath) + 1; + tmpPath = (char*) MCMemAlloc(npl); + tmpPath[0] = 0; + strcpy(tmpPath, FOwner->RealTransportName()); + strcat(tmpPath, ":"); + strcat(tmpPath, s); + strcat(tmpPath, "|"); + strcat(tmpPath, RecvPath); + MCMemFree(RecvPath); + RecvPath = tmpPath; + } + else + { + npl = strlen(FOwner->RealTransportName()) + 1 + strlen(s) + 1; + tmpPath = (char*) MCMemAlloc(npl); + tmpPath[0] = 0; + strcpy(tmpPath, FOwner->RealTransportName()); + strcat(tmpPath, ":"); + strcat(tmpPath, s); + RecvPath = tmpPath; + } + } + + if (RouteTo != NULL + //$ifdef MC_COMMERCIAL + && !FOwner->FRoutingEnabled + //$endif MC_COMMERCIAL + ) + { + Message->Data = NULL; + Message->DataType = bdtConst; + Message->Result = 0; + Message->Param1 = 0; + Message->Param2 = 0; + Message->MsgID = 0; + + Info = new MCMessageInfo(Message); + Info->setDMessenger(MessengerName); + Info->setSMessenger(RemoteMessenger); + MCMessenger::SetMessageID(Info); + Info->MCError = MCError_RoutingNotAllowed; + Info->State = imsFailed; + Info->StartTime = GetTickCount(); + Info->Timeout = FOwner->FMsgTimeout; + //$ifdef MC_COMMERCIAL + if (RecvPath) + Info->setRecvPath(strCopy(RecvPath, 0)); + else + Info->setRecvPath(NULL); + //$endif MC_COMMERCIAL + FOwner->FOutgoingQueue.Add(Info); + r = true; + immExit = true; + } + } + + if (!immExit) + { + // MC_COMMERCIAL. Fixed to not check for intermediate nodes + if (RouteTo == NULL) + { + if (IsTransformerOK(&Header, FOwner) == false) + {//oops! + Message->Data = NULL; + Message->DataType = bdtConst; + Message->Result = 0; + Message->Param1 = 0; + Message->Param2 = 0; + Message->MsgID = 0; + Info = new MCMessageInfo(Message); + //Info->DMessenger = s; + Info->setDMessenger(RemoteMessenger); + Info->setSMessenger(MessengerName); + MCMessenger::SetMessageID(Info); + Info->MCError = MCError_GenTransportFailure; + Info->State = imsFailed; + Info->StartTime = GetTickCount(); + Info->Timeout = FOwner->FMsgTimeout; + //$ifdef MC_COMMERCIAL + if (RecvPath) + Info->setRecvPath(strCopy(RecvPath, 0)); + else + Info->setRecvPath(NULL); + //$endif MC_COMMERCIAL + FOwner->FOutgoingQueue.Add(Info); + r = true; + immExit = true; + } + } + } + + if (!immExit) + { + // read the encoded message + if(getIncomingStream()->Pos() < getIncomingStream()->Len()) + { + // allocate buffer for data + DataLen = getIncomingStream()->Len() - getIncomingStream()->Pos(); + DataBuf = MCMemAlloc(DataLen); // memory leak + if(!DataBuf) + THROW_ERROR(MCError_NotEnoughMemory); + + TRY_BLOCK + { + // read the data + getIncomingStream()->Read(DataBuf, DataLen); + +//$ifdef MC_COMMERCIAL + if (RouteTo != NULL) + { + Info = new MCMessageInfo(Message); + MCMessenger::SetMessageID(Info); + Info->setDMessenger(RemoteMessenger); + Info->setSMessenger(MessengerName); + Info->StartTime = GetTickCount(); + Info->Timeout = FOwner->FMsgTimeout; + if (RouteTo) + Info->setRouteTo(strCopy(RouteTo, 0, strlen(RouteTo))); + else + Info->setRouteTo(NULL); + Info->Intermed = true; + if (RecvPath) + Info->setRecvPath(strCopy(RecvPath, 0)); + else + Info->setRecvPath(NULL); + + Info->EncodedMsg = DataBuf; + Info->EncodedLen = DataLen; + Info->SealID = Header.dwSealID; + Info->EncryptID = Header.dwEncryptID; + Info->CompressID = Header.dwCompressID; + strncpy(Info->DQueue, DQueue, sizeof(Info->DQueue) - 1); + + DataBuf = NULL; + FOwner->RouteMessage(Info); + } + else +//$endif + // decode the message + if(FOwner->UnprepareDataBlock(MessengerName, DataBuf, DataLen, DataBuf, DataLen, Header.dwEncryptID, Header.dwCompressID, Header.dwSealID)) + { + // decoding was successful + AStream = new MCMemStream(); + TRY_BLOCK + { + AStream->SetPointer((char*)DataBuf, DataLen); + + Message->DataSize = 0; + Info = new MCMessageInfo(Message); + Info->Timeout = FOwner->FMsgTimeout; +//$ifdef MC_COMMERCIAL + Info->TransactCmd = (MCTransactCmd) TransactCmd; + if (RecvPath) + Info->setRecvPath(strCopy(RecvPath, 0)); + else + Info->setRecvPath(NULL); +//$endif MC_COMMERCIAL + Info->setSMessenger(MessengerName); + Info->setDMessenger(RemoteMessenger); + AStream->Read(Info, (long)((char*)&Info->Message.Data - (char*)Info)); + + if(Info->State == imsDispatching) // we have received an original message + { + MCMessenger::SetMessageID(Info); + + if(AStream->Len() - AStream->Pos() < Info->Message.DataSize) + { + if(Info->IsSendMsg && (!getTerminated())) + { + // decline the message as the data portion is corrupt + Info->MCError = MCError_GenTransportFailure; + Info->State = imsFailed; + FOwner->FOutgoingQueue.Add(Info); + } + else + { + delete Info; Info = NULL; + } + MCMemFree(DataBuf); DataBuf = NULL; + delete AStream; AStream = NULL; + immExit = true; + } + + if (!immExit) + { + if(Info->Message.DataSize > 0) + { + Info->Message.Data = MCMemAlloc(Info->Message.DataSize); + AStream->Read(Info->Message.Data, Info->Message.DataSize); + } + else + Info->Message.Data = NULL; + MCMemFree(DataBuf); DataBuf = NULL; + delete AStream; AStream = NULL; +/* if (Info->IsSendMsg && (Info->State == imsDispatching))// (FTransporter->getDirection() == isdIncoming)) + { + MCMessageInfo* Reply = MakeEmptyReply(Info); + if (NULL != Reply) + { + //change the Reply->DMessenger + _itoa(irdaID, irdaIDBuf, 10); + char* dest = MCMemAlloc(strlen(Reply->DMessenger) + strlen(irdaIDBuf) + 2); + strcpy(dest, irdaIDBuf); strcat(dest, ":"); strcat(dest, Info->DMessenger); + Info->setDMessenger(dest); + MCOBEXTransport::FCriticalSection->Leave(); + FOwner->DeliverMessage(Reply->DMessenger, Reply); + MCOBEXTransport::FCriticalSection->Enter(); + } + }*/ + _itoa(irdaID, irdaIDBuf, 10); + Info->setURL(strdup(irdaIDBuf)); + FOwner->MessageReceived(Info); + } + } + else // we have received a reply + { + CurInfo = NULL; + for(i = 0;i < FOwner->FOutgoingQueue.Length();i++) + if (((MCMessageInfo*)FOwner->FOutgoingQueue[i])->OrigID == Info->OrigID) + { + CurInfo = (MCMessageInfo*)(FOwner->FOutgoingQueue[i]); + FOwner->FOutgoingQueue.Del(i); + break; + } + + if(!CurInfo) // the message was cancelled + { + delete Info; Info = NULL; + } + else + { + // we have to copy result data and signal about reply + if (CurInfo->Message.DataType != bdtConst) + { + if(CurInfo->Message.Data) + { + MCMemFree(CurInfo->Message.Data); + CurInfo->Message.DataSize = 0; + CurInfo->Message.Data = NULL; + } + + // read the resulting data from the stream + CurInfo->Message.DataSize = Info->Message.DataSize; + if(CurInfo->Message.DataSize > 0) + { + CurInfo->Message.Data = MCMemAlloc(CurInfo->Message.DataSize); + AStream->Read(CurInfo->Message.Data, Info->Message.DataSize); + } + else + CurInfo->Message.Data = NULL; + + // reset fields in Info + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + + CurInfo->Message.Result = Info->Message.Result; + CurInfo->MCError = Info->MCError; + CurInfo->State = Info->State; + delete Info; Info = NULL; + FOwner->ReplyReceived(CurInfo); + } + } + } FINALLY ( + if(AStream) + AStream->SetPointer(NULL, 0); + delete AStream; + ) + } + else + MCMemFree(s); + } FINALLY ( + MCMemFree(DataBuf); DataBuf = NULL; + ) + } + } // with + } FINALLY ( + delete getIncomingStream(); + setIncomingStream(NULL); + ) + } + } FINALLY ( + FOwner->FCriticalSection.Leave(); + if (DQueue) + MCMemFree(DQueue); + if (RouteTo) + MCMemFree(RouteTo); + if (RecvPath) + MCMemFree(RecvPath); + ) + } + CATCH_EVERY + { + } + MCMemFree(DataBuf); DataBuf = NULL; + return r; +} + +bool MCOBEXThread::IsTransformerOK(MCOBEXHeader* Header, MCOBEXTransport* FOwner) +{ + bool r = true; + if (0 != Header->dwCompressID) + { + if (NULL != FOwner->getCompressor()) + { + if (FOwner->getCompressor()->GetID() != Header->dwCompressID) + r = false; + } else + r = false; + } + + if (0 != Header->dwEncryptID) + { + if (NULL != FOwner->getEncryptor()) + { + if (FOwner->getEncryptor()->GetID() != Header->dwEncryptID) + r = false; + } else + r = false; + } + + if (0 != Header->dwSealID) + { + if (NULL != FOwner->getSealer()) + { + if (FOwner->getSealer()->GetID() != Header->dwSealID) + r = false; + } else + r = false; + } + return(r); +} + +MCMessageInfo* MCOBEXThread::MakeEmptyReply(MCMessageInfo* Info) +{ +// MCMessage msg; +// memset(&msg, 0, sizeof(msg)); + MCMessageInfo* dstInfo = new MCMessageInfo(&Info->Message); +// memset(dstInfo, 0, sizeof(*dstInfo)); + dstInfo->setSMessenger(strCopy(Info->SMessenger, 0, strlen(Info->SMessenger))); + dstInfo->setDMessenger(strCopy(Info->DMessenger, 0, strlen(Info->DMessenger))); + dstInfo->Message.Data = NULL; + dstInfo->Message.DataSize = 0; + dstInfo->MCError = MCError_ReplyDeferred; + dstInfo->State = imsComplete; + dstInfo->StartTime = GetTickCount(); + dstInfo->Timeout = Info->Timeout; + + return dstInfo; +} + +// ***************************** TMCOBEXListener ****************************** + +MCOBEXListener::MCOBEXListener(bool CreateSuspended):MCThread(CreateSuspended) +{ + FListener = NULL; +} + +MCOBEXListener::~MCOBEXListener(void) +{ + delete FListener; +} + +void MCOBEXListener::Execute(void) +{ + while(!getTerminated()) + { + TRY_BLOCK + { + if(MainThread->FRecvEvent->WaitFor(0) == wrSignaled) + Sleep(10); + else + if(MainThread->FServer = (MCOBEXSocket*)FListener->Accept()) + MainThread->FRecvEvent->setEvent(); +// if(getTerminated()) +// return; + } + CATCH_EVERY + { + Sleep(10); + } + } +} + +void MCOBEXListener::Initialize(MCOBEXThread* Main) +{ + MainThread = Main; + FListener = new MCOBEXSocket(); + FListener->Init(istStream); + FListener->Bind(); + FListener->Listen(1); +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCOBEX.h b/libraries/external/eldos/pc/include/MCOBEX.h new file mode 100755 index 0000000..560e0d7 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCOBEX.h @@ -0,0 +1,184 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCOBEXTRANSPORT__ +#define __MCOBEXTRANSPORT__ + +#include "MC.h" +#include "MCBase.h" +#include "MCStream.h" +#include "MCSock.h" +#include "MCSyncs.h" + + +#if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS) && !defined(_WIN32_WCE) +# define _WIN32_WINNT +#endif + +#ifdef _WIN32 +# include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +/* + +Some compatibility notes + +http://homepage.ntlworld.com/alanjmcf/comms/infrared/IrDA%20FAQ.html + +If one wants to replace the Wireless Link program with another OBEX application, +the local OBEX 'port' (actually IAS entry) needs to be free. Unlike with the IrCOMM +equivalent "Image Transfer" as discussed in Question 1 and 24, de-selecting the +apparent equivalent "Allow others to send files to your computer using infrared +communications" in the Wireless Link Control Panel does not release the OBEX port. +(an attempt to 'bind' to "OBEX" fails with WSAEADDRINUSE 10048). To free the port +actually the "Infrared Monitor" Service itself needs to be stopped e.g. +"net stop Irmon". + +*/ + +typedef struct { + long dwSignature; // "EIDP", $50444945 + long dwDataSize; // total size of the data + long dwCompressID; + long dwEncryptID; + long dwSealID; +} MCOBEXHeader ; + +class MCOBEXListener; + +typedef unsigned long (STDCALLCONV *MCSelectRemoteProc)(PDEVICELIST devs); + +//It is a maximum number of simultaneous attached devices +const int NMAX_IRDA_DEVICES = 10; +const int NMAX_IRDA_DISCOVERY_ATTEMPTS = 10; + +class MCOBEXTransport: public MCSimpleTransport { +friend class MCOBEXThread; +protected: + char* FMessengerName; + int FCounter; + MCOBEXThread* FThread; + MCOBEXListener* FListener; + MCList FOutgoingQueue; + MCCriticalSection FCriticalSection; +//$ifdef MC_COMMERCIAL + bool FRoutingEnabled; +//$endif MC_COMMERCIAL + + MCSelectRemoteProc FSelectRemoteProc; + virtual void CancelMessage(MCMessageInfo* Info); + virtual bool DeliverMessage(char* DestAddress,MCMessageInfo* Info); + virtual void DeliveryFailed(MCMessageInfo* Info); + virtual void DoSetActive(void); +// virtual void MessageProcessed(MCMessageInfo* Info); +// void MessageReceived(MCMessageInfo* Info); +// void ReplyReceived(MCMessageInfo* Info); + virtual void CleanupMessages(){}; + bool CancelMessageByID(__int64 MsgID, DWORD ErrorCode, bool Discard); +public: + MCOBEXTransport(void); + virtual ~MCOBEXTransport(void); + void DiscoverIRDARemotes(unsigned int* devices, int& count); + /* + The name of OBEX that is used to transfer the messages + from other messenger on the same processes. + Can't be empty. + */ + char* getMessengerName(void); + void setMessengerName(const char* Value); +//$ifdef MC_COMMERCIAL + void setRoutingAllowed(bool Value); + bool getRoutingAllowed(void); +//$endif MC_COMMERCIAL + void setSelectRemoteProc(MCSelectRemoteProc Value); + MCSelectRemoteProc getSelectRemoteProc(void); +}; + +class MCOBEXSocket: public MCStdSocket { +protected: + unsigned int FIrdaID; +public: + MCOBEXSocket(void):MCStdSocket(), FIrdaID(0) {} + virtual ~MCOBEXSocket(void) {} + void setIrdaID(unsigned int id) + { + FIrdaID = id; + } + unsigned int getIrdaID(void) { return FIrdaID; } + virtual MCSocket* CreateSame(void); + virtual MCSocket* Accept(void); + virtual long Bind(void); + virtual void Close(bool Forced); + virtual long Connect(void); + virtual long Init(MCSocketType SocketType); + virtual long Listen(long BackLog); + virtual long Receive(void* Data, long DataLen, long& Received); + virtual long ReceiveFrom(void* Data, long DataLen, long& Received, char*& RemoteAddress, + unsigned int& RemotePort); + virtual long Send(void* Data, long DataLen, long& Sent); + virtual long SendTo(void* Data, long DataLen, long& Sent, char* RemoteAddress, + unsigned int RemotePort); +}; + +class MCOBEXThread: public MCThread { +private: +friend class MCOBEXTransport; +friend class MCOBEXListener; + __int64 FCancelID; + MCEvent* FStopEvent; + MCEvent* FRecvEvent; + MCOBEXTransport* FOwner; + +protected: + MCOBEXSocket* FSocket; + MCOBEXSocket* FServer; + MCStream* FOutgoingStream; + MCStream* FIncomingStream; + + virtual void Execute(void); + void SendMessage(void); + void ReceiveMessage(void); + MCMessageInfo* PrepareMessageForSending(void); + MCMessageInfo* GetMessageForDelivery(void); + bool MessageReceivedCompletely(char* MessengerName, unsigned int irdaID); + MCOBEXTransport* FindMessenger(char* name); + bool IsTransformerOK(MCOBEXHeader* Header, MCOBEXTransport* FOwner); + MCMessageInfo* MakeEmptyReply(MCMessageInfo* Info); +public: + MCOBEXThread(bool CreateSuspended); + virtual ~MCOBEXThread(void); + void Initialize(MCOBEXTransport* Owner); + MCStream* getOutgoingStream(void); + void setOutgoingStream(MCStream* Value); + MCStream* getIncomingStream(void); + void setIncomingStream(MCStream* Value); +}; + +class MCOBEXListener: public MCThread { +private: + MCOBEXSocket* FListener; +protected: + MCOBEXThread* MainThread; + + virtual void Execute(void); +public: + MCOBEXListener(bool CreateSuspended); + virtual ~MCOBEXListener(void); + void Initialize(MCOBEXThread* Main); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCPlatforms.cpp b/libraries/external/eldos/pc/include/MCPlatforms.cpp new file mode 100755 index 0000000..de5b87b --- /dev/null +++ b/libraries/external/eldos/pc/include/MCPlatforms.cpp @@ -0,0 +1,309 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCPlatforms.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +// ----------------------------- unicode support ------------------------------ + +int wstrlen(wchar_t* s) +{ + int r = 0; + if(!s) + return(0); + while(*s++) + r++; + return(r); +} + +wchar_t* wstrcat(wchar_t* dest, wchar_t* src) +{ + if(!src || !dest) + return(dest); + wchar_t* td = dest + wstrlen(dest); + while(*src) + *td++ = *src++; + *td = '\0'; + return(dest); +} + +long wstrtol(wchar_t* s, wchar_t** e, int r) +{ + char* s1 = wstr2str(s, CP_ACP); + char* e1; + long l = strtol(s1, &e1, r); + if(*e1) + *e = s + (e1 - s1); + else + *e = NULL; + return(l); +} + +double wstrtod(wchar_t* s, wchar_t** e) +{ + char* s1 = wstr2str(s, CP_ACP); + char* e1; + double d = strtod(s1, &e1); + if(*e1) + *e = s + (e1 - s1); + else + *e = NULL; + return(d); +} + +wchar_t* wstrdup(wchar_t* s) +{ + long i = (wstrlen(s)+1)*sizeof(wchar_t); + wchar_t* r = (wchar_t*)malloc(i); + memmove(r, s, i); + return(r); +} + +wchar_t* str2wstr(char* s, unsigned int cp) +{ +#ifdef _WIN32 +//$ifndef LINUX + int ws = MultiByteToWideChar(cp, MB_PRECOMPOSED, s, -1, NULL, 0); + wchar_t* w = (wchar_t*)malloc((ws+1) * sizeof(wchar_t)); + int wr = MultiByteToWideChar(cp, MB_PRECOMPOSED, s, -1, w, ws); + if(wr != ws) + { + free(w); + return NULL; + } + w[ws] = 0; + return w; +//$endif +#else + wchar_t* w = (wchar_t*)malloc((strlen(s)+1)*sizeof(wchar_t)); + wchar_t* r = w; + while(*s) + *(w++) = (wchar_t)*(s++); + *w = *s; + return(r); +#endif +} + +char* wstr2str(wchar_t* w, unsigned int cp) +{ +#ifdef _WIN32 +//$ifndef LINUX + int ss = WideCharToMultiByte(cp, WC_COMPOSITECHECK|WC_SEPCHARS|WC_DEFAULTCHAR, w, -1, NULL, 0, NULL, NULL); + char* s = (char*)malloc(ss); + int sr = WideCharToMultiByte(cp, WC_COMPOSITECHECK|WC_SEPCHARS|WC_DEFAULTCHAR, w, -1, s, ss, NULL, NULL); + if(sr != ss) { + free(s); + return(NULL); + } + return(s); +//$endif +#else + char* s = (char*)malloc(wstrlen(w)+1); + char* r = s; + while(*w) + *(s++) = (char)*(w++); + *s = *w; + return(r); +#endif +} + +// ---------------------------------------------------------------------------- + +double TurnDouble(double D) +{ + double t = D; + char* curP = (char*)&D; + char* curD = (char*)&t; + curD += sizeof(D)-1; + + for(long l=0; l < (signed long)sizeof(D); l++) + { + *curD = *curP; + curP++; + curD--; + } + return t; +} + +long TurnLong(long D) +{ + long T = D; + char* curP = (char*)&D; + char* curD = (char*)&T; + + curD += sizeof(D)-1; + + for(long l=0;(unsigned long)l < sizeof(D); l++) + { + *curD = *curP; + curP++; + curD--; + } + return(T); +} + +long UpperTrimCmp(char* S1, char* S2) +{ + char C1, C2, *E1, *E2; + + while(*S1 && isspace(*S1)) + S1++; + E1 = S1; + while(*E1) + E1++; + if (S1 != E1) + { + E1--; + while(isspace(*E1)) + E1--; + E1++; + } + + while(*S2 && isspace(*S2)) + S2++; + E2 = S2; + while(*E2) + E2++; + if (S2 != E2) + { + E2--; + while(isspace(*E2)) + E2--; + E2++; + } + + + while (true) + { + C1 = *S1; + if (S1 == E1) + C1 = 0; + else if ((C1 >= 'a') && (C1 <= 'z')) + C1 &= (~0x20); + S1++; + + C2 = *S2; + if (S2 == E2) + C2 = 0; + else if ((C2 >= 'a') && (C2 <= 'z')) + C2 &= (~0x20); + S2++; + + if (C1 > C2) + return +1; + else if (C1 < C2) + return -1; + else if (C1 == 0) + return 0; + } + return 0; + +/* + unsigned char* S = (unsigned char*)S1; + char* p = (char*)malloc(strlen(S1) + 1); + long x = 0; + while(*S) + { + while(*S && isspace(*S)) + S++; + while(*S && !isspace(*S)) + if(*S >= 'a' || *S <= 'z') + p[x++] = *S++ & (~0x20); + else + p[x++] = *S++; + } + p[x] = 0; + return(p); +*/ +} + +LPSTR CharNstr(char C, char* S) +{ + return (CharNstr(C, S, S)); +} + +LPSTR CharNstr(char C, char* S, char* D) +{ + if(!S) + return(Char2Str(C, S)); + size_t l = strlen(S) + 2; + char* x=(char*)malloc(l); + +#ifdef _WIN32 +//$ifndef LINUX + _snprintf(x, l, "%c%s", C, S); +//$endif +#else + *x = C; + strcpy(&x[1], S); +#endif + + if(D) + free(D); + return(x); +} + +LPSTR StrNchar(char* S, char C) +{ + return(StrNchar(S, C, S)); +} + +LPSTR StrNchar(char* S, char C, char* D) +{ + if(NULL == S) + return(Char2Str(C, S)); + size_t l = strlen(S) + 2; + char* x= (char*)malloc(l); +#ifdef _WIN32 +//$ifndef LINUX + _snprintf(x, l, "%s%c", S, C); +//$endif +#else + strcpy(x, S); + x[strlen(x) + 1] = 0; + x[strlen(x)] = C; +#endif + if(D) + free(D); + return(x); +} + +LPSTR Char2Str(char C, char* S) +{ + if(S) + free(S); + + char* z = (char*)malloc(2); + z[0] = C; + z[1] = 0; + return(z); +} + +LPSTR AddStr(char* S1,char* S2) +{ + if(NULL == S1) + return(strdup(S2)); + if(NULL == S2) + return(S1); + size_t zl = strlen(S1) + strlen(S2) + 1; + char* t = (char*)malloc(zl); + strcpy(t, S1); + strcat(t, S2); + free(S1); + return(t); +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCPlatforms.h b/libraries/external/eldos/pc/include/MCPlatforms.h new file mode 100755 index 0000000..8b17203 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCPlatforms.h @@ -0,0 +1,158 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCPLATFORMS__ +#define __MCPLATFORMS__ + +#include "MC.h" +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +// =----------------- ! user-configurable part begins here ! -----------------= + +//#define LINUX +//#define WINFULL +//#define WINCE +//#define PALM_CW +//#define PALM_GNU + +// =------------------ ! user-configurable part ends here ! ------------------= + +#ifdef _WIN32 +# include +#endif + +#ifdef QNX +#include +#endif + +#if !defined(_WIN32) && defined(__GNUC__) && !defined(QNX) +#if !defined(wchar_t) +# define wchar_t short int +#endif +#endif + +int wstrlen(wchar_t*); +wchar_t* wstrcat(wchar_t*, wchar_t*); +long wstrtol(wchar_t*, wchar_t**, int); +double wstrtod(wchar_t*, wchar_t**); +wchar_t* wstrdup(wchar_t*); +wchar_t* str2wstr(char*, unsigned int); +char* wstr2str(wchar_t*, unsigned int); + +//disable _snprintf +#undef _SNPRINTF_ENABLED_ + +#if defined(PALM_CW) || defined(PALM_GNU) +# define M68K +# define PALM +#endif + +#if defined(_WIN32) || defined(__GNUC__) +# define _SNPRINTF_ENABLED_ +# ifndef _WIN32_WCE +# define WINFULL +# else +# ifndef WINCE +# define WINCE +# endif +# endif +#endif + +#ifdef __GNUC__ +#define _snprintf snprintf +#endif + +#ifdef PALM_CW +# include +# include +# ifndef NULL +# define NULL 0L +# endif +#else +# include +# include +# ifndef PALM_GNU +# include +# include +# endif +#endif + +#ifndef _WIN32 +typedef char* LPSTR; +#endif + +typedef LPSTR* PLPSTR; + +#ifndef CP_ACP +#define CP_ACP 0 +#endif + +#ifdef _WIN32_WCE +# define strdup _strdup +double strtod(char *, char **); +#endif + +#ifdef PALM_GNU +# define DEFSECT __attribute__ ((section ("DEFSECT"))) +#else +# define DEFSECT /**/ +#endif + +DEFSECT double TurnDouble(double d); +DEFSECT long TurnLong(long d); + +#ifdef PALM +DEFSECT char* strdup(const char*); +DEFSECT double strtod(char *, char **); +DEFSECT char* strrchr(const char*,char); +DEFSECT int isspace(char); +DEFSECT void MakeHexByteAt(char* P, char C); +DEFSECT void MakeLongAt(char* P, long L, int N); +DEFSECT void MakeDoubleAt(char* P, double D, int Ni, int Nf); +#endif + +#ifdef PALM_GNU +extern "C" { + void *malloc (size_t __size); + void free (void *__ptr); + void *realloc (void *__ptr, size_t __size); +} +# undef NULL +# define NULL 0L +#endif + +#ifdef PALM_CW +//void* malloc(long); +//void free(void*); +long strtol(char * , char ** , int); +int _strncmp(const char*,const char*,long); +//char* strncpy(char*,const char*,long); +//char* strcat(char*,const char*); +char* strchr(const char*,char); +#else +#define _strncmp strncmp +#endif + +typedef void** PVOIDLIST; + +long DEFSECT UpperTrimCmp(char* S1, char* S2); +LPSTR DEFSECT CharNstr(char C, char* S, char* D); +LPSTR DEFSECT CharNstr(char C, char* S); +LPSTR DEFSECT StrNchar(char* S, char C, char* D); +LPSTR DEFSECT StrNchar(char* S, char C); +LPSTR DEFSECT Char2Str(char C, char* S); +LPSTR DEFSECT AddStr(char* S1, char* S2); + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCRouter.cpp b/libraries/external/eldos/pc/include/MCRouter.cpp new file mode 100755 index 0000000..aedd77f --- /dev/null +++ b/libraries/external/eldos/pc/include/MCRouter.cpp @@ -0,0 +1,168 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCRouter.h" + + +#ifdef USE_NAMESPACE +namespace MsgConnect { +#endif + +#ifndef _WIN32 +#include +#ifndef QNX +void strupr(char* s) +{ + for (int i=0; i +# endif +#endif + +MCRouter::MCRouter() +{ + FRoutingTable = new MCStringList(); +} + +MCRouter::~MCRouter() +{ + delete FRoutingTable; + FRoutingTable = NULL; +} + +int MCRouter::IndexOfKey(char * Key) +{ + int result = -1; + //int keylen = strlen(Key); + int i, j, n; + char* value; + char* xval; + + char* aKey = strCopy(Key, 0); +#ifndef _WIN32_WCE + strupr(aKey); +#else + aKey = _strupr(aKey); +#endif + + FCriticalSection->Enter(); + j = FRoutingTable->Length(); + for (i = 0; i < j; i++) + { + xval = (char*) ((*FRoutingTable)[i]); + value = (char*) MCMemAlloc(strlen(xval) + 1); + strcpy(value, xval); + +#ifndef _WIN32_WCE + strupr(value); +#else + value = _strupr(value); +#endif + n = strchr(value, '=') - value - 1; + if (n != -1) + { + if (strncmp(value, aKey, n) == 0) + { + result = i; + break; + } + } + MCMemFree(value); + } + FCriticalSection->Leave(); + MCMemFree(aKey); + return result; +} + +char* MCRouter::TranslateAddress(char* Address) +{ + char* result = NULL; + bool UseDefTable = true; + + void* UserData; + if(getOnTranslateAddress(&UserData)) + getOnTranslateAddress()(UserData, this, Address, &result, &UseDefTable); + if (UseDefTable) + { + // address = strupr(Address); + //char* FTransportPart = NULL; + //char* FAddressPart = NULL; + int addr_part_len, trans_part_len; + char* ad; + char* ap; + int key_len, tp_len, ap_len; + + int i, j; + j = strchr(Address, ':') - Address; + if (j > 0 && j < (int) strlen(Address) - 1) + { + trans_part_len = j; + addr_part_len = strlen(Address) - j - 1; + + FCriticalSection->Enter(); + + for (i = 0; i < FRoutingTable->Length(); i++) + { + ad = (char*) ((*FRoutingTable)[i]); + + key_len = strchr(ad, '=') - ad; + tp_len = strchr(ad, ':') - ad; + if (tp_len > key_len) + continue; + ap_len = key_len - tp_len - 1; + ap = ad + tp_len + 1; +#ifdef _WIN32_WCE +# define strnicmp _strnicmp +#elif __GNUC__ +# define strnicmp strncasecmp +#endif + if ((tp_len == trans_part_len) && (strnicmp(Address, ad, tp_len) == 0)) + { + if ((ap_len == 1 && *ap == '*') || + ((ap_len == addr_part_len) && (strncmp(Address + trans_part_len + 1, ad + tp_len + 1, ap_len) == 0))) + { + // copy the value to result + result = (char*) MCMemAlloc(strlen(ad) - key_len); + strcpy(result, ad + key_len + 1); + break; + } + } + } + FCriticalSection->Leave(); + } + } + return result; +} + +void MCRouter::ClearRoutingRules() +{ + FRoutingTable->DeleteAll(); +} + +void MCRouter::SetRoutingRule(char *Address, char* RouteTo) +{ + int i = IndexOfKey(Address); + if (i != -1) + FRoutingTable->Del(i); + + if (strlen(RouteTo) == 0) + return; + + char* newval = (char*) MCMemAlloc(strlen(Address)+strlen(RouteTo) + 2); + sprintf(newval, "%s=%s", Address, RouteTo); + FRoutingTable->Add(newval); +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCRouter.h b/libraries/external/eldos/pc/include/MCRouter.h new file mode 100755 index 0000000..030d819 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCRouter.h @@ -0,0 +1,39 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCROUTER__ +#define __MCROUTER__ + +#include "MC.h" +#include "MCBase.h" +#include "MCLists.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect { +#endif + +class MCRouter : public MCBaseRouter{ +protected: + MCStringList* FRoutingTable; + int IndexOfKey(char * Key); + +public: + MCRouter(); + ~MCRouter(); + + virtual char* TranslateAddress(char* Address); + + void ClearRoutingRules(); + void SetRoutingRule(char *Address, char* RouteTo); +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCSock.cpp b/libraries/external/eldos/pc/include/MCSock.cpp new file mode 100755 index 0000000..e3043a7 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSock.cpp @@ -0,0 +1,1892 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCSock.h" +#ifndef QNX +# define socklen_t size_t +#endif + +#ifdef __GNUC__ +# include +# include +# include +# include +#define WSAEWOULDBLOCK EWOULDBLOCK +#endif + +#include "MC.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +const long SocketTypes[2] = {SOCK_STREAM, SOCK_DGRAM}; + +bool WinsockInitialized = false; +long SocketsCreated = 0; + +void WinsockErrorCheck(long ErrorCode) +{ + if(ErrorCode != 0) + THROW_ERROR(ErrorCode); +} + +class MCBase64Codec +{ + +public: + // Encode buffer to Base64 + static char* Encode(const char *pInput, size_t Len); + +}; + +// Encode buffer to Base64 +char* MCBase64Codec::Encode(const char *pInput, size_t Len) +{ + const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + char *pEncoded = (char *)calloc((int) floor(Len + (Len * 0.7) + 1), sizeof(pInput[0])); // Memory consuming version + + char ch, pc = '\0'; + int j = 0, x = 0; + for (size_t i = 0; i < Len; i++) + { + ch = pInput[i]; + switch (j) + { + case 0: + pEncoded[x++] = alphabet[(ch & 0xfc) >> 2]; + break; + case 1: + pEncoded[x++] = alphabet[((pc & 0x03) << 4) ^ ((ch & 0xf0) >> 4)]; + break; + case 2: + pEncoded[x++] = alphabet[((pc & 0x0f) << 2) ^ ((ch & 0xc0) >> 6)]; + pEncoded[x++] = alphabet[ch & 0x3f]; + j = -1; + break; + } + j++; + pc = ch; + } + switch (j) + { + case 1: + pEncoded[x++] = alphabet[((pc & 0x03) << 4)]; + pEncoded[x++] = '='; + pEncoded[x++] = '='; + break; + case 2: + pEncoded[x++] = alphabet[((pc & 0x0f) << 2)]; + pEncoded[x++] = '='; + break; + } + pEncoded[x] = '\0'; + + char *pResult = strdup(pEncoded); + free(pEncoded); + + return pResult; +} + +// ********************************* MCSocket ********************************* + +MCSocket::MCSocket(void) +{ + InitializeWinSock(); + SocketsCreated++; + FSocket = INVALID_SOCKET; + FState = issNotASocket; + FLocalAddress = NULL; + FRemoteAddress = NULL; + FCloseRequest = false; + FDirection = isdOutgoing; + FRemotePort = 0; + FLocalPort = 0; + FIsClient = false; +//$ifndef LINUX + FUseSocks = false; + FSocksServer = NULL; + FSocksPort = 1080; + FSocksUserCode = NULL; + FSocksPassword = NULL; + FSocksVersion = mcSocks5; + FSocksAuthentication = saNoAuthentication; + FSocksResolveAddress = false; +//$endif + + // Web tunneling support + FUseWebTunneling = false; + FWebTunnelAddress = NULL; + FWebTunnelPort = 4080; + FWebTunnelAuthentication = wtaNoAuthentication; + FWebTunnelUserId = NULL; + FWebTunnelPassword = NULL; + + FIncomingBuf.Data = MCMemAlloc(SOCKETBUF_INITIAL_SIZE); + if (NULL == FIncomingBuf.Data) + THROW_ERROR(MCError_NotEnoughMemory); + + FIncomingBuf.Len = 0; + FIncomingBuf.Size = SOCKETBUF_INITIAL_SIZE; +} + +MCSocket::~MCSocket(void) +{ + if (NULL != FRemoteAddress) + { + MCMemFree(FRemoteAddress); + FRemoteAddress = NULL; + } + + if (NULL != FLocalAddress) + { + MCMemFree(FLocalAddress); + FLocalAddress = NULL; + } + if (NULL != FIncomingBuf.Data) + { + MCMemFree(FIncomingBuf.Data); + } +//$ifndef LINUX + if (NULL != FSocksUserCode) + { + free(FSocksUserCode); + FSocksUserCode = NULL; + } + if (NULL != FSocksPassword) + { + free(FSocksPassword); + FSocksPassword = NULL; + } + if (NULL != FSocksServer) + { + free(FSocksServer); + FSocksServer = NULL; + } +//$endif + + // Web tunneling support + if (NULL != FWebTunnelAddress) + { + free(FWebTunnelAddress); + FWebTunnelAddress = NULL; + } + if (NULL != FWebTunnelUserId) + { + free(FWebTunnelUserId); + FWebTunnelUserId = NULL; + } + if (NULL != FWebTunnelPassword) + { + free(FWebTunnelPassword); + FWebTunnelPassword = NULL; + } + + SocketsCreated--; + FinalizeWinSock(); +} + +/* +This method is called by the transport thread after socket is connected. +All communications between connection parties, that are not part of normal +data exchange (SOCKS authentication, SSL connection initiation), +should be implemented inside of this method. +*/ +long MCSocket::AfterConnection(MCSocket* CtlSocket, long Timeout) +{ + // intentionally left blank + return 0; +} + +long MCSocket::AsyncConnect(MCSocket* CtlSocket, long Timeout) +{ + FDirection = isdOutgoing; + return 0; +} + +bool MCSocket::Connect(void) +{ + FDirection = isdOutgoing; + return true; +} + +long MCSocket::ExtConnect(MCSocket* CtlSocket, long Timeout) +{ + FDirection = isdOutgoing; + return 0; +} + +void MCSocket::FinalizeWinSock(void) +{ +#ifndef __GNUC__ +//$ifndef LINUX + if(WinsockInitialized && (SocketsCreated <= 0)) + WSACleanup(); +//$endif +#endif +} + +bool MCSocket::HasBufferedOutgoingData() +{ + return false; +} + +bool MCSocket::HasBufferedIncomingData() +{ + return FIncomingBuf.Len > 0; +} + +TSocket MCSocket::getSocket(void) +{ + return FSocket; +} + +void MCSocket::InitializeWinSock(void) +{ +#ifndef __GNUC__ +//$ifndef LINUX + WSADATA Data; + + if(WSAStartup((MAKEWORD(2,0)), &Data) != 0) +//$endif + THROW_ERROR(MCError_WinsockInitFailed); + WinsockInitialized = true; +#endif +} + +long MCSocket::Listen(long /*BackLog*/) +{ + FDirection = isdIncoming; + return 0; +} + +bool MCSocket::PopFromCtlSocket(MCSocket* CtlSocket) +{ + long i; + char p; + char* RemoteHost; + unsigned int RemotePort; + + CtlSocket->ReceiveFrom(&p, 1, i, RemoteHost, RemotePort); + return p != 0; +} + +bool MCSocket::PostprocessOutgoingData() +{ + return true; +} + +bool MCSocket::PreprocessIncomingData() +{ + return true; +} + +void MCSocket::setLocalAddress(const char* Value) +{ + if(FState != issNotASocket && FState != issInitialized && FState != issConnected) + THROW_ERROR(MCError_WrongSocketState); + if(FLocalAddress) + MCMemFree(FLocalAddress); + if(Value) + FLocalAddress = strdup(Value); + else + FLocalAddress = NULL; +} + +void MCSocket::setLocalPort(unsigned int Value) +{ + if(FState != issNotASocket && FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + FLocalPort = Value; +} + +void MCSocket::setRemoteAddress(const char* Value) +{ + if(FState != issNotASocket && FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + if(FRemoteAddress) + MCMemFree(FRemoteAddress); + if(Value) + FRemoteAddress = strdup(Value); + else + FRemoteAddress = NULL; +} + +long MCSocket::StartAsyncConnect() +{ + FDirection = isdOutgoing; + return 0; +} + +long MCSocket::SyncConnect(void) +{ + FDirection = isdOutgoing; + return 0; +} + +void MCSocket::setRemotePort(unsigned int Value) +{ + if(FState != issNotASocket && FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + FRemotePort = Value; +} + +MCSocketDir MCSocket::getDirection(void) +{ + return FDirection; +} + +MCSocketState MCSocket::getState(void) +{ + return FState; +} + +char* MCSocket::getLocalAddress(void) +{ + return FLocalAddress; +} + +unsigned int MCSocket::getLocalPort(void) +{ + return FLocalPort; +} + +char* MCSocket::getRemoteAddress(void) +{ + return FRemoteAddress; +} + +unsigned int MCSocket::getRemotePort(void) +{ + return FRemotePort; +} + +//$ifndef LINUX +void MCSocket::setUseSocks(bool Value) +{ + FUseSocks = Value; + if (Value) + setUseWebTunneling(false); +} + +bool MCSocket::getUseSocks(void) +{ + return FUseSocks; +} + +void MCSocket::setSocksVersion(MCSocksVersion Value) +{ + FSocksVersion = Value; +} + +MCSocksVersion MCSocket::getSocksVersion(void) +{ + return FSocksVersion; +} + +void MCSocket::setSocksServer(const char* Value) +{ + if (FSocksServer) + free(FSocksServer); + FSocksServer = strdup(Value); +} + +const char* MCSocket::getSocksServer(void) +{ + return FSocksServer; +} + +void MCSocket::setSocksPort(unsigned short Value) +{ + FSocksPort = Value; +} + +unsigned short MCSocket::getSocksPort(void) +{ + return FSocksPort; +} + +void MCSocket::setSocksAuthentication(MCSocksAuthentication Value) +{ + FSocksAuthentication = Value; +} + +MCSocksAuthentication MCSocket::getSocksAuthentication(void) +{ + return FSocksAuthentication; +} + +void MCSocket::setSocksUserCode(const char* Value) +{ + if (FSocksUserCode) + free(FSocksUserCode); + FSocksUserCode = strdup(Value); +} + +const char* MCSocket::getSocksUserCode(void) +{ + return FSocksUserCode; +} + +void MCSocket::setSocksPassword(const char* Value) +{ + if (FSocksPassword) + free(FSocksPassword); + FSocksPassword = strdup(Value); +} +const char* MCSocket::getSocksPassword(void) +{ + return FSocksPassword; +} +void MCSocket::setSocksResolveAddress(bool Value) +{ + FSocksResolveAddress = Value; +} + +bool MCSocket::getSocksResolveAddress(void) +{ + return FSocksResolveAddress; +} +//$endif + +// Web tunneling support +void MCSocket::setUseWebTunneling(bool Value) +{ + FUseWebTunneling = Value; +//$ifndef LINUX + if (Value) + setUseSocks(false); +//$endif +} + +bool MCSocket::getUseWebTunneling() +{ + return FUseWebTunneling; +} + +void MCSocket::setWebTunnelAddress(const char *Value) +{ + if (FWebTunnelAddress) + free(FWebTunnelAddress); + FWebTunnelAddress = strdup(Value); +} + +const char* MCSocket::getWebTunnelAddress() +{ + return FWebTunnelAddress; +} + +void MCSocket::setWebTunnelPort(unsigned short Value) +{ + FWebTunnelPort = Value; +} + +unsigned short MCSocket::getWebTunnelPort() +{ + return FWebTunnelPort; +} + +MCWebTunnelAuthentication MCSocket::getWebTunnelAuthentication() +{ + return FWebTunnelAuthentication; +} + +void MCSocket::setWebTunnelAuthentication(MCWebTunnelAuthentication Value) +{ + FWebTunnelAuthentication = Value; +} + +void MCSocket::setWebTunnelUserId(const char *Value) +{ + if (FWebTunnelUserId) + free(FWebTunnelUserId); + FWebTunnelUserId = strdup(Value); +} + +const char* MCSocket::getWebTunnelUserId() +{ + return FWebTunnelUserId; +} + +void MCSocket::setWebTunnelPassword(const char *Value) +{ + if (FWebTunnelPassword) + free(FWebTunnelPassword); + FWebTunnelPassword = strdup(Value); +} + +const char* MCSocket::getWebTunnelPassword() +{ + return FWebTunnelPassword; +} + +// ******************************** MCStdSocket ******************************* + +MCStdSocket::MCStdSocket() +:MCSocket() +{ +} + +MCStdSocket::~MCStdSocket() +{ + Close(false); +} + +MCSocket* MCStdSocket::Accept(void) +{ + TSocket NewSocket; + struct sockaddr_in FAddr; + int FAddrLen; + char* addr; + MCSocket* r; + + if(FState != issListening) + THROW_ERROR(MCError_WrongSocketState); + FAddrLen = sizeof(FAddr); +#ifdef __GNUC__ + NewSocket = accept(FSocket, (sockaddr*)&FAddr, (socklen_t*)&FAddrLen); +#else +//$ifndef LINUX + NewSocket = accept(FSocket, (sockaddr*)&FAddr, &FAddrLen); +//$endif +#endif + if(NewSocket != (long)INVALID_SOCKET) + { + r = CreateAcceptingSocket(); + r->FSocket = NewSocket; + r->FDirection = isdIncoming; + //OutputDebugString("Incoming socket accepted\n"); + r->setRemotePort(ntohs(FAddr.sin_port)); + addr = inet_ntoa(FAddr.sin_addr); + if(addr) + r->setRemoteAddress(addr); + else + r->setRemoteAddress(NULL); +#ifdef __GNUC__ + if(getsockname(NewSocket, (sockaddr*)&FAddr, (socklen_t*)&FAddrLen) != SOCKET_ERROR) +#else +//$ifndef LINUX + if(getsockname(NewSocket, (sockaddr*)&FAddr, &FAddrLen) != SOCKET_ERROR) +//$endif +#endif + { + r->FLocalPort = ntohs(FAddr.sin_port); + addr = inet_ntoa(FAddr.sin_addr); + if(addr) + r->setLocalAddress(addr); + else + r->setLocalAddress(NULL); + } + else + { + r->setLocalAddress(getLocalAddress()); + r->setLocalPort(getLocalPort()); + } + r->FState = issConnected; + } + else + return NULL; + return r ; +} + +long MCStdSocket::AsyncConnect(MCSocket* CtlSocket, long Timeout) +{ + MCSocket::AsyncConnect(CtlSocket, Timeout); + fd_set FDSendSet, FDRecvSet; + long elapsed = 0; + unsigned int highSocketHandle; + double startTime; + + int select_res; + long result = StartAsyncConnect(); + + while (FState == issConnecting && ((0 == Timeout) || (elapsed <= Timeout))) + { + FD_ZERO(&FDSendSet); + FD_ZERO(&FDRecvSet); + FD_SET(FSocket, &FDSendSet); + if (CtlSocket) + { + highSocketHandle = FSocket > CtlSocket->getSocket() ? FSocket : CtlSocket->getSocket(); + FD_SET(CtlSocket->getSocket(), &FDRecvSet); + } + else + highSocketHandle = FSocket; + + timeval TimeVal; + TimeVal.tv_sec = 0; + TimeVal.tv_usec = (Timeout - elapsed) * 1000; + + timeval* PTV = &TimeVal; + startTime = Now(); + + + if (CtlSocket == NULL) + select_res = select(highSocketHandle+1, NULL, &FDSendSet, NULL, PTV); + else + select_res = select(highSocketHandle+1, &FDRecvSet, &FDSendSet, NULL, PTV); + + if ( select_res > 0) + { + if (CtlSocket != NULL && FD_ISSET(CtlSocket->getSocket(), &FDRecvSet)) + { + if (!PopFromCtlSocket(CtlSocket)) + break; + } + else + if (FD_ISSET(FSocket, &FDSendSet)) + { + FinishAsyncConnect(); + break; + } + } + else + if (select_res == SOCKET_ERROR) + RETURN_EXCEPT; + + elapsed += (unsigned long)((Now() - startTime) * 86400 * 1000 + 0.5); + } + if (getState() != issConnected) + { + Close(true); +#ifndef __GNUC__ + result = WSAETIMEDOUT; +#else + result = ETIMEDOUT; +#endif + } + else + result = true; + return result; +} + +long MCStdSocket::Bind(void) +{ + struct sockaddr_in FAddr; + unsigned long addr; + struct hostent* HostEnt = NULL; + long r = 0; + int i = 0; + struct in_addr TAddr; + + + if((FSocket == (long)INVALID_SOCKET) && (Init(istStream) != 0)) + THROW_ERROR(MCError_NotASocket); + if(FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + + if (NULL != getLocalAddress()) + addr = inet_addr(getLocalAddress()); + else + addr = INADDR_NONE; + + if(addr == INADDR_NONE) + { + HostEnt = gethostbyname(getLocalAddress()); + if(HostEnt) + memmove(&addr, &HostEnt->h_addr[0], sizeof(addr)); + } + if(addr == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + FAddr.sin_addr.s_addr = addr; + FAddr.sin_port = htons(getLocalPort()); + r = bind(FSocket, (sockaddr*)&FAddr, sizeof(FAddr)); + if(r == 0) + { + if((addr == 0) || (getLocalPort() == 0)) + { + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + i = sizeof(FAddr); +#ifdef __GNUC__ + if(getsockname(FSocket, (sockaddr*)&FAddr, (socklen_t*)&i) == 0) +#else + if(getsockname(FSocket, (sockaddr*)&FAddr, &i) == 0) +#endif + { + TAddr.s_addr = FAddr.sin_addr.s_addr; + setLocalPort(ntohs(FAddr.sin_port)); + setLocalAddress(inet_ntoa(TAddr)); + } + } + FState = issBound; + } + else + r = LAST_ERROR; + return r; +} + +void MCStdSocket::Close(bool Forced) +{ + if(FSocket != (long)INVALID_SOCKET) + { + /* + if (FDirection == isdOutgoing) + OutputDebugString("Outgoing socket closed\n"); + else + OutputDebugString("Incoming socket closed\n"); + */ + if(!Forced) + shutdown(FSocket, SD_BOTH); + closesocket(FSocket); + FSocket = INVALID_SOCKET; + FState = issNotASocket; + } + else + if(FState == issInitializing) + FCloseRequest = true; + if (NULL != FIncomingBuf.Data) + free(FIncomingBuf.Data); + FIncomingBuf.Data = NULL; + FIncomingBuf.Len = 0; + FIncomingBuf.Size = 0; +} + +bool MCStdSocket::Connect() +{ +//$ifndef LINUX + if (FUseSocks) + return SocksConnect(NULL, 0x7FFFFFFF) == 0; + else +//$endif + if (FUseWebTunneling) + return HTTPConnect(NULL, 0x7FFFFFFF) == 0; + else + return SyncConnect() == 0; +} + +long MCStdSocket::ExtConnect(MCSocket* CtlSocket, long Timeout) +{ + MCSocket::ExtConnect(CtlSocket, Timeout); +//$ifndef LINUX + if (FUseSocks) + return SocksConnect(CtlSocket, Timeout); + else +//$endif + if (FUseWebTunneling) + return HTTPConnect(CtlSocket, Timeout); + else + return AsyncConnect(CtlSocket, Timeout); +} + +void MCStdSocket::FinishAsyncConnect() +{ + int i = 0; + struct in_addr TAddr; + + FState = issConnected; + { +// OutputDebugString("Outgoing socket connected\n"); + if(!getLocalAddress() || (getLocalPort() == 0)) + { + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + i = sizeof(FAddr); +#ifdef __GNUC__ + if(getsockname(FSocket, (sockaddr*)&FAddr, (socklen_t*)&i) == 0) +#else +//$ifndef LINUX + if(getsockname(FSocket, (sockaddr*)&FAddr, &i) == 0) +//$endif +#endif + { + TAddr.s_addr = FAddr.sin_addr.s_addr; + FLocalPort = ntohs(FAddr.sin_port); + setLocalAddress(inet_ntoa(TAddr)); + } + } + } +} + +bool MCStdSocket::SocksSendReceive(bool &Terminated, MCSocket* CtlSocket, unsigned long Timeout, + void* sendBuf, long sendBufSize, long& wasSent, + void* readBuf, long readBufSize, long& wasRead) +{ + long highestSocketHandle; + if (CtlSocket) + highestSocketHandle = CtlSocket->getSocket() > FSocket ? CtlSocket->getSocket() : FSocket; + else + highestSocketHandle = FSocket; + + unsigned long TimeoutV = 0; + timeval TimeVal, *pTV = NULL; + fd_set FDRecvSet, FDSendSet; + int selectRes; + + wasSent = 0; + wasRead = 0; + + unsigned long started = GetTickCount(); + unsigned long elapsed = 0; + + while (true) + { + elapsed = GetTickCount() - started; + if (elapsed >= Timeout) + return false; + + FD_ZERO(&FDRecvSet); FD_ZERO(&FDSendSet); + + if (Timeout > 0) + TimeoutV = Timeout - elapsed; + else + TimeoutV = 0; + + if (TimeoutV > 0) + { + TimeVal.tv_sec = TimeoutV / 1000; + TimeVal.tv_usec = (TimeoutV % 1000) * 1000; + pTV = &TimeVal; + } + else + pTV = NULL; + + if (CtlSocket) + FD_SET(CtlSocket->getSocket(), &FDRecvSet); + FD_SET(FSocket, &FDSendSet); + + if (CtlSocket) + selectRes = select(highestSocketHandle+1, &FDRecvSet, &FDSendSet, NULL, pTV); + else + selectRes = select(highestSocketHandle+1, NULL, &FDSendSet, NULL, pTV); + + if (0 != selectRes && SOCKET_ERROR != selectRes) + { + if (CtlSocket && FD_ISSET(CtlSocket->getSocket(), &FDRecvSet)) + { + if (!PopFromCtlSocket(CtlSocket)) + { + Terminated = true; + return false; + } + } + if (FD_ISSET(FSocket, &FDSendSet)) + { + if (SOCKET_ERROR == IntSend(sendBuf, sendBufSize, wasSent)) + return false; + else + break; + } + } + else + if (SOCKET_ERROR == selectRes) + { + return false; + } + } + + while (true) + { + elapsed = GetTickCount() - started; + if (elapsed >= Timeout) + return false; + + FD_ZERO(&FDRecvSet); + + if (Timeout > 0) + TimeoutV = Timeout - elapsed; + else + TimeoutV = 0; + + if (TimeoutV > 0) + { + TimeVal.tv_sec = TimeoutV / 1000; + TimeVal.tv_usec = (TimeoutV % 1000) * 1000; + pTV = &TimeVal; + } + else + pTV = NULL; + + if (CtlSocket) + FD_SET(CtlSocket->getSocket(), &FDRecvSet); + FD_SET(FSocket, &FDRecvSet); + + selectRes = select(highestSocketHandle, &FDRecvSet, NULL, NULL, pTV); + + if (0 != selectRes && SOCKET_ERROR != selectRes) + { + if (CtlSocket && FD_ISSET(CtlSocket->getSocket(), &FDRecvSet)) + { + if (!PopFromCtlSocket(CtlSocket)) + { + Terminated = true; + return false; + } + } + if (FD_ISSET(FSocket, &FDRecvSet)) + { + if (SOCKET_ERROR == IntReceive(readBuf, readBufSize, wasRead)) + return false; + else + return true; + } + } + else + if (SOCKET_ERROR == selectRes) + { + return false; + } + } +} + +//$ifndef LINUX +long MCStdSocket::SocksConnect(MCSocket* CtlSocket, long Timeout) +{ +/* rAddr: string; + rPrt: Word; + buf: pointer; + rIP: in_addr; + HostEnt: PHostent; + cnt, len, psize, SelectRes: integer; +*/ + bool res = false; + bool Term = false; + char* rAddr = strdup(FRemoteAddress); + unsigned int rPrt = FRemotePort; + setRemoteAddress(FSocksServer); + setRemotePort(FSocksPort); + AsyncConnect(CtlSocket, Timeout); + + struct in_addr rIP; + long len = 1024, cnt = 0, selectRes = 0; + unsigned char* buf = (unsigned char*)MCMemAlloc(len); + long psize = 0; + + TRY_BLOCK + { + if (FState == issConnected) + { + + if (mcSocks5 == FSocksVersion) + { + psize = 4; + switch (FSocksAuthentication) + { + case saUsercode: + *((unsigned int*)buf) = 0x02000205; + break; + case saNoAuthentication: + *((unsigned int*)buf) = 0x00000105; + psize = 3; + break; + } + + if (!SocksSendReceive(Term, CtlSocket, Timeout, buf, psize, cnt, buf, 1024, cnt)) + THROW_ERROR(0); + if (Term) + THROW_ERROR(-1); + + if (buf[0] == 05 && buf[1] == 0xFF) + THROW_ERROR(MCError_SocksNoAcceptableAuthMethods); + + if (buf[0] == 5 && buf[1] == 2) + { + cnt = strlen(FSocksUserCode); + buf[0] = 1; + buf[1] = (char)cnt; + memmove(buf+2, FSocksUserCode, cnt); + psize = strlen(FSocksPassword); + buf[cnt+2] = (char)psize; + memmove(buf + cnt + 3, FSocksPassword, psize); + + if (!SocksSendReceive(Term, CtlSocket, Timeout, buf, psize, cnt, buf, 1024, cnt)) + THROW_ERROR(0); + if (Term) + THROW_ERROR(-1); + + if (buf[1] != 0) + THROW_ERROR(MCError_SocksAuthFailure); + } + + psize = 8; + + rIP.s_addr = inet_addr(rAddr); + if (INADDR_NONE == rIP.s_addr) + { + if (FSocksResolveAddress) + { + psize = strlen(rAddr); + memmove(buf+5, (void*)rAddr, psize); + *(buf + 4) = (char)psize; + *((unsigned short*)(buf+2)) = 0x0300; // 03 - DOMAINNAME + psize += 5; + } + else + { + hostent* host = gethostbyname(rAddr); + if (NULL != host) + memmove(buf+4, host->h_addr_list[0], sizeof(rIP.s_addr)); + else + THROW_ERROR(MCError_InvalidAddress); + *(unsigned short*)(buf+2) = 0x0100; + // 01 - IP V4 address, 04 - IP V6 address + } + } + else + { + memmove(buf+4, &rIP.s_addr, sizeof(rIP.s_addr)); + *(unsigned short*)(buf+2) = 0x0100; + } + *(unsigned short*)buf = 0x0105; //connect + *(unsigned short*)(buf+psize) = htons(rPrt); + psize += 2; + + if (!SocksSendReceive(Term, CtlSocket, Timeout, buf, psize, cnt, buf, 1024, cnt)) + THROW_ERROR(0); + if (Term) + THROW_ERROR(-1); + + switch (buf[1]) + { + case 0x00: res = true; + break; + case 0x01: selectRes = MCError_SocksGenFailure; + break; + case 0x02: selectRes = MCError_SocksNotallowed; + break; + case 0x03: selectRes = MCError_SocksNetUnreachable; + break; + case 0x04: selectRes = MCError_SocksHostUnreachable; + break; + case 0x05: selectRes = MCError_SocksConnectionRefused; + break; + case 0x06: selectRes = MCError_SocksTTLExpired; + break; + case 0x07: selectRes = MCError_SocksCmdNotSupported; + break; + case 0x08: selectRes = MCError_SocksAddrTypeNotSupported; + break; + default: + selectRes = 0; + res = false; + break; + } + + if (false == res) + THROW_ERROR(selectRes); + + if (cnt < 10) + THROW_ERROR(MCError_SocksGenFailure); + + int realDataLen = 0; + switch (buf[3]) + { + case 0x01: + realDataLen = 4 + 4 + 2; + break; + case 0x03: + realDataLen = 4 + (1 + buf[4]) + 2; + break; + case 0x04: + realDataLen = 4 + 16 + 2; + break; + default: + realDataLen = -1; + } + if (realDataLen == -1) + THROW_ERROR(MCError_SocksGenFailure); + if (realDataLen < cnt) + { + ReturnData(&(buf[realDataLen]), cnt - realDataLen); + } + } + else + { + *(unsigned short*)buf = 0x0104; // 01 = Connect + *(unsigned short*)(buf + 2) = htons(rPrt); + cnt = strlen(FSocksUserCode); + memmove(buf+8, FSocksUserCode, cnt); + psize = cnt + 8 + 1; + *(buf + psize - 1) = 0; + rIP.s_addr = inet_addr(rAddr); + if (INADDR_NONE == rIP.s_addr) + { + if (FSocksResolveAddress) + { + cnt = strlen(rAddr); + *(unsigned int*)(buf+4) = 0xFF000000; + memmove(buf+psize, rAddr, cnt); + psize += cnt + 1; + *(buf + psize - 1) = 0; + } + else + { + hostent *host = gethostbyname(rAddr); + if (NULL != host) + memmove(buf+4, host->h_addr_list[0], sizeof(rIP.s_addr)); + else + THROW_ERROR(MCError_InvalidAddress); + } + } + else + memmove(buf+4, &rIP.s_addr, sizeof(rIP.s_addr)); + + if (!SocksSendReceive(Term, CtlSocket, Timeout, buf, psize, cnt, buf, 1024, cnt)) + THROW_ERROR(0); + if (Term) + THROW_ERROR(-1); + + switch(buf[1]) + { + case 90: + res = true; + break; + + default: + THROW_ERROR(MCError_SocksNotallowed); + } + if (res) + { + if (8 < cnt) + { + ReturnData(&(buf[8]), cnt - 8); + } + } + } + } + } + FINALLY + ( + if (len > 0) + MCMemFree(buf); + if (!res && FState == issConnected) + Close(true); + if (NULL != rAddr) + free(rAddr); + ) + return res; +} +//$endif + +// Web tunneling support +long MCStdSocket::HTTPConnect(MCSocket* CtlSocket, long Timeout) +{ + bool res = false; + long len = 1025; + char* buf = (char*)MCMemAlloc(len); + + char* rAddr = strdup(FRemoteAddress); + unsigned int rPort = FRemotePort; + setRemoteAddress(FWebTunnelAddress); + setRemotePort(FWebTunnelPort); + AsyncConnect(CtlSocket, Timeout); + + TRY_BLOCK + { + if (FState == issConnected) + { + if (wtaRequiresAuthentication == FWebTunnelAuthentication && + FWebTunnelUserId != NULL && FWebTunnelPassword != NULL) + { + char BasicCredentials[512]; + sprintf(BasicCredentials, "%s:%s", FWebTunnelUserId, FWebTunnelPassword); + char *pBasicCredentialsEnc = + MCBase64Codec::Encode(BasicCredentials, strlen(BasicCredentials)); + + sprintf(buf, "CONNECT %s:%d HTTP/1.0\r\nUser-agent: MsgConnect\r\nProxy-Authorization: Basic %s\r\n\r\n", + rAddr, rPort, pBasicCredentialsEnc); + + free(pBasicCredentialsEnc); + } + else + { + sprintf(buf, "CONNECT %s:%d HTTP/1.0\r\nUser-agent: MsgConnect\r\n\r\n", + rAddr, rPort); + } + + long psize = strlen(buf); + long cnt = 0, selectRes = 0, rcvcnt = 0; + bool Term = false; + if (!SocksSendReceive(Term, CtlSocket, Timeout, buf, psize, cnt, buf, 1024, rcvcnt)) + THROW_ERROR(0); + if (Term) + THROW_ERROR(-1); + if (rcvcnt < 12) + THROW_ERROR(MCError_WebTunnelFailure); + + int httpMajor = 0, httpMinor = 0, httpCode = 0; + char headerBuf[13]; + memmove(headerBuf, buf, 12); + headerBuf[12] = 0; + + sscanf(headerBuf, "HTTP/%d.%d %d", &httpMajor, &httpMinor, &httpCode); + + if (1 == httpMajor && (!httpMinor || 1 == httpMinor)) + { + switch (httpCode) + { + case 200: + res = true; + break; + case 407: + THROW_ERROR(MCError_WebTunnelAuthRequired); + break; + default: + THROW_ERROR(MCError_WebTunnelFailure); + break; + } + } + else + THROW_ERROR(MCError_WebTunnelFailure); + + if (res) + { + buf[rcvcnt] = 0; + char* tail = strstr(buf, "\r\n\r\n"); + if (tail) + { + cnt = tail - buf; + ReturnData(&(tail[4]), rcvcnt - (cnt + 4)); + } + } + } + else + THROW_ERROR(MCError_WebTunnelConnectionFailed); + } + FINALLY + ( + if (len > 0) + MCMemFree(buf); + if (!res && FState == issConnected) + Close(true); + if (NULL != rAddr) + free(rAddr); + ) + return res; +} + +long MCStdSocket::StartAsyncConnect(void) +{ + unsigned long addr; + struct hostent* HostEnt; + long r = MCSocket::StartAsyncConnect(); + + if((FSocket == (long)INVALID_SOCKET) && (Init(istStream) != 0)) + THROW_ERROR(MCError_NotASocket); + + if (FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + + if (issInitialized == FState) + { + FAddr.sin_addr.s_addr = INADDR_NONE; + addr = inet_addr(getRemoteAddress()); + + if(addr == INADDR_NONE) + { + HostEnt = gethostbyname(getRemoteAddress()); + if(HostEnt) + memmove(&addr, &HostEnt->h_addr[0], sizeof(addr)); + } + + if(addr == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + FAddr.sin_addr.s_addr = addr; + FAddr.sin_port = htons(getRemotePort()); + u_long arg = 1; +#ifndef __GNUC__ + ioctlsocket(FSocket, FIONBIO, &arg); //set non-blocking IO +#else + ioctl(FSocket, FIONBIO, &arg); //set non-blocking IO +#endif + r = connect(FSocket, (sockaddr*)&FAddr, sizeof(FAddr)); + + if (0 != r) + { + int errorCode = LAST_ERROR; +#ifndef __GNUC__ + if ((errorCode != WSAEWOULDBLOCK) && /*(errorCode != WSAEINVAL) && */(errorCode != WSAEISCONN) && (errorCode != WSAEINPROGRESS)) +#else + if (errorCode != EINPROGRESS) +#endif + { + //DWORD errorCode = LAST_ERROR; + FState = issInitialized; + return errorCode; + } + else +#ifndef __GNUC__ + if (errorCode == WSAEISCONN) + { + FState = issConnected; + //OutputDebugString("Outgoing socket connected\n"); + } + else +#endif + FState = issConnecting; + + } + else + FState = issConnected; + + if (FState == issConnected) + FinishAsyncConnect(); + } + else + THROW_ERROR(MCError_WrongSocketState); + + return r; +} + +long MCStdSocket::SyncConnect(void) +{ + struct sockaddr_in FAddr; + unsigned long addr; + struct hostent* HostEnt; + long r; + int i; + struct in_addr TAddr; + + MCSocket::Connect(); + if((FSocket == (long)INVALID_SOCKET) && (Init(istStream) != 0)) + THROW_ERROR(MCError_NotASocket); + + if(FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + + addr = inet_addr(getRemoteAddress()); + + if(addr == INADDR_NONE) + { + HostEnt = gethostbyname(getRemoteAddress()); + if(HostEnt) + memmove(&addr, &HostEnt->h_addr[0], sizeof(addr)); + } + + if(addr == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + FAddr.sin_addr.s_addr = addr; + FAddr.sin_port = htons(getRemotePort()); + r = connect(FSocket, (sockaddr*)&FAddr, sizeof(FAddr)); + + if(r == 0) + { + //OutputDebugString("Outgoing socket connected\n"); + if(!getLocalAddress() || (getLocalPort() == 0)) + { + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + i = sizeof(FAddr); +#ifdef __GNUC__ + if(getsockname(FSocket, (sockaddr*)&FAddr, (socklen_t*)&i) == 0) +#else +//$ifndef LINUX + if(getsockname(FSocket, (sockaddr*)&FAddr, &i) == 0) +//$endif +#endif + { + TAddr.s_addr = FAddr.sin_addr.s_addr; + FLocalPort = ntohs(FAddr.sin_port); + setLocalAddress(inet_ntoa(TAddr)); + } + } + FState = issConnected; + } + else + r = LAST_ERROR; + return r; +} + +/* +//*nix code +long MCStdSocket::AsyncConnect(void) +{ + unsigned long addr; + struct hostent* HostEnt; + long r; + int i; + struct in_addr TAddr; + if((FSocket == (long)INVALID_SOCKET) && (Init(istStream) != 0)) + THROW_ERROR(MCError_NotASocket); + if (issInitialized != FState) + THROW_ERROR(MCError_WrongSocketState); + + MCSocket::AsyncConnect(); + addr = inet_addr(getRemoteAddress()); + if (INADDR_NONE == addr) + { + HostEnt = gethostbyname(getRemoteAddress()); + if (NULL != HostEnt) + memmove(&addr, &HostEnt->h_addr[0], sizeof(addr)); + } + + if(addr == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + FAddr.sin_addr.s_addr = addr; + FAddr.sin_port = htons(getRemotePort()); + u_long arg = 1; + ioctl(FSocket, FIONBIO, &arg); + r = connect(FSocket, (sockaddr*)&FAddr, sizeof(FAddr)); + + if (0 != r) + { + int errorCode = LAST_ERROR; + if (errorCode != EINPROGRESS) + { + FState = issInitialized; + return errorCode; + } + else + FState = issConnecting; + } + else + FState = issConnected; + + + return 0; +} +*/ + +long MCStdSocket::ReusePort() +{ + long r; + int reuseAddrVal = 1; //int reuseAddrLen = sizeof(reuseAddrVal); + r = setsockopt(FSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuseAddrVal, reuseAddrVal); + + if(FSocket == (long)INVALID_SOCKET) + r = LAST_ERROR; + else + r = 0; + return r; +} + +long MCStdSocket::Init(MCSocketType SocketType) +{ + long r ; + + if(FState != issNotASocket) + THROW_ERROR(MCError_WrongSocketState); + FState = issInitializing; + FSocket = socket(PF_INET, SocketTypes[SocketType], IPPROTO_IP); + + if(FSocket == (long)INVALID_SOCKET) + r = LAST_ERROR; + else + r = 0; + + if(FCloseRequest) + { + FCloseRequest = false; + FState = issNotASocket; + if(r == 0) + closesocket(FSocket); + FSocket = INVALID_SOCKET; + return r; + } + if(r == 0) + FState = issInitialized; + + return r; +} + +long MCStdSocket::Listen(long BackLog) +{ + long r; + + //set REUSE_ADDRESS option + MCSocket::Listen(BackLog); + if(FSocket == (long)INVALID_SOCKET) + THROW_ERROR(MCError_NotASocket); + if(FState != issBound) + { + if(FState != issInitialized) + THROW_ERROR(MCError_WrongSocketState); + //int reuseAddrVal = 1; int reuseAddrLen = sizeof(reuseAddrVal); + //r = setsockopt(FSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuseAddrVal, reuseAddrVal); + r = Bind(); + if(r != 0) + return r; + } + if(BackLog > SOMAXCONN) + BackLog = SOMAXCONN; + r = listen(FSocket, BackLog); + if(r == 0) + FState = issListening; + else + r = LAST_ERROR; + return r; +} + +long MCStdSocket::Receive(void* Data, long DataLen, long& Received) +{ + return IntReceive(Data, DataLen, Received); +} + +long MCStdSocket::IntReceive(void* Data, long DataLen, long& Received) +{ + long r = 0; + if(FState != issConnected) + THROW_ERROR(MCError_WrongSocketState); + + if (NULL == Data || 0 == DataLen) + return 0; + + if (0 != FIncomingBuf.Len) + {//there is some data in cache + r = 0; + Received = DataLen < FIncomingBuf.Len ? DataLen : FIncomingBuf.Len; + memmove(Data, FIncomingBuf.Data, Received); + if (Received != FIncomingBuf.Len) + { + memmove(FIncomingBuf.Data, (char*)FIncomingBuf.Data + Received, FIncomingBuf.Len - Received); + FIncomingBuf.Len -= Received; + } + else + { + FIncomingBuf.Len = 0; + } + + } + else + { + r = recv(FSocket, (char*)Data, DataLen, 0); + if(r == SOCKET_ERROR) + { + Received = 0; + r = LAST_ERROR; + /*char Buffer [150]; + if (FDirection == isdOutgoing) + sprintf(Buffer, "Receive on outgoing socket failed with error %d\n", r); + else + sprintf(Buffer, "Receive on incoming socket failed with error %d\n", r); + OutputDebugString(Buffer); + */ + } + else + { + Received = r; + r = 0; + } + } + return r; +} + +long MCStdSocket::ReceiveFrom(void* Data, long DataLen, long& Received, + char*& RemoteAddress, unsigned int& RemotePort) +{ + struct sockaddr_in FAddr; + long r; + int i; + + if(FState == issConnected) + { + r = Receive(Data, DataLen, Received); + RemoteAddress = getRemoteAddress(); + RemotePort = getRemotePort(); + } + else + if(FState != issBound) + THROW_ERROR(MCError_WrongSocketState); + else + { + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + i = sizeof(FAddr); +#ifdef __GNUC__ + r = recvfrom(FSocket, (char*)Data, DataLen, 0, (sockaddr*)&FAddr, (socklen_t*)&i); +#else +//$ifndef LINUX + r = recvfrom(FSocket, (char*)Data, DataLen, 0, (sockaddr*)&FAddr, &i); +//$endif +#endif + if(r == SOCKET_ERROR) + { + Received = 0; + r = LAST_ERROR; + } + else + { + RemotePort = FAddr.sin_port; + RemoteAddress = inet_ntoa(FAddr.sin_addr); + Received = r; + r = 0; + } + } + return r; +} + +long MCStdSocket::Send(void* Data, long DataLen, long& Sent) +{ + return IntSend(Data, DataLen, Sent); +} + +long MCStdSocket::IntSend(void* Data, long DataLen, long& Sent) +{ + long r; + + if(FState != issConnected) + THROW_ERROR(MCError_WrongSocketState); + r = send(FSocket, (char*)Data, DataLen, 0); + if(r == SOCKET_ERROR) + { + Sent = 0; + r = LAST_ERROR; + /* + char Buffer [150]; + if (FDirection == isdOutgoing) + sprintf(Buffer, "Send on outgoing socket failed with error %d\n", r); + else + sprintf(Buffer, "Send on incoming socket failed with error %d\n", r); + OutputDebugString(Buffer); + */ + } + else + { + Sent = r; + r = 0; + } + return r; +} + +long MCStdSocket::SendTo(void* Data, long DataLen, long& Sent, + char* RemoteAddress, unsigned int RemotePort) +{ + struct sockaddr_in FAddr; + unsigned long addr; + struct hostent* HostEnt; + long r; + int i; + + if(FState == issConnected) + r = Send(Data, DataLen, Sent); + else + //if not (State in [issInitialized, issBound]) then + // raise EMCSockError.CreateCode(MCError_WrongSocketState) + //else + { + // translate destination address + if(!RemoteAddress || (strcmp(RemoteAddress, "255.255.255.255") != 0)) + { + addr = inet_addr(RemoteAddress); + if(addr == INADDR_NONE) + { + HostEnt = gethostbyname(RemoteAddress); + if(HostEnt) + memmove(&addr, &HostEnt->h_addr[0], sizeof(addr)); + } + if(addr == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + } + else + addr = INADDR_NONE; + + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + FAddr.sin_addr.s_addr = addr; + FAddr.sin_port = htons(RemotePort); + // do send + r = sendto(FSocket, (char*)Data, DataLen, 0, (sockaddr*)&FAddr, sizeof(FAddr)); + + if(r == SOCKET_ERROR) + { + Sent = 0; + r = LAST_ERROR; + } + else + { + if(FState == issInitialized) + { + memset(&FAddr, 0, sizeof(FAddr)); + FAddr.sin_family = AF_INET; + i = sizeof(FAddr); +#ifdef __GNUC__ + if(getsockname(FSocket, (sockaddr*)&FAddr, (socklen_t*)&i) == 0) +#else +//$ifndef LINUX + if(getsockname(FSocket, (sockaddr*)&FAddr, &i) == 0) +//$endif +#endif + { + setLocalPort(ntohs(FAddr.sin_port)); + setLocalAddress(inet_ntoa(FAddr.sin_addr)); + FState = issBound; + } + } + Sent = r; + r = 0; + } + } + return r; +} + +void MCStdSocket::ReturnData(void* Data, long DataLen) +{ + if (NULL == Data || 0 == DataLen) + return; + + if (NULL != FIncomingBuf.Data) + { + //look for remaining space + long remaining = FIncomingBuf.Size - FIncomingBuf.Len; + if (remaining < DataLen) + {//expand buffer + void* newBuf = realloc(FIncomingBuf.Data, FIncomingBuf.Size + DataLen - remaining); + if (NULL == newBuf) + THROW_ERROR(MCError_NotEnoughMemory); + FIncomingBuf.Data = newBuf; + FIncomingBuf.Size += DataLen - remaining; + } + + //move the remaining data to the end of buffer + memmove((char*)FIncomingBuf.Data+DataLen, FIncomingBuf.Data, FIncomingBuf.Len); + memmove(FIncomingBuf.Data, Data, DataLen); + FIncomingBuf.Len += DataLen; + } + else + THROW_ERROR(MCError_WrongSocketState); +} + +long MCStdSocket::AddToMulticastSrv(const char* GroupAddress, const char* BindAddress) +{ + if (FState != issBound) + THROW_ERROR(MCError_WrongSocketState); + + long r; + struct ip_mreq imreq; + + //memset(&imreq, 0, sizeof(struct ip_mreq)); + + imreq.imr_multiaddr.s_addr = inet_addr(GroupAddress); + imreq.imr_interface.s_addr = inet_addr(BindAddress); + + r = setsockopt(FSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, + (/*const */char *) &imreq, sizeof(/*struct */ip_mreq)); + + if (r) + return LAST_ERROR; + else + return 0; +} + +long MCStdSocket::AddToMulticastCli(const char* BindAddress, unsigned char TTL, bool Loop) +{ + long r; + struct in_addr iaddr; + + memset(&iaddr, 0, sizeof(struct in_addr)); + + iaddr.s_addr = inet_addr(BindAddress); + + r = setsockopt(FSocket, IPPROTO_IP, IP_MULTICAST_IF, (const char *) &iaddr, sizeof(struct in_addr)); + if (r) + return LAST_ERROR; + + r = setsockopt(FSocket, IPPROTO_IP, IP_MULTICAST_TTL, (const char *) &TTL, sizeof(unsigned char)); + if (r) + return LAST_ERROR; + + setsockopt(FSocket, IPPROTO_IP, IP_MULTICAST_LOOP, (const char *) &Loop, sizeof(unsigned char)); + if (r) + return LAST_ERROR; + + return 0; +} + + +// **************************** MCSocketFactory **************************** + +MCSocketFactory::MCSocketFactory() +{ + FOnSocketCreation = NULL; + FOnSocketCreationData = NULL; +} + +MCSocket* MCSocketFactory::CreateClientSocket() +{ + MCSocket* result = DoCreateClientSocket(); + if (FOnSocketCreation != NULL) + (FOnSocketCreation)(FOnSocketCreationData, this, result, issClient); + return result; +} + +MCSocket* MCSocketFactory::CreateServerSocket() +{ + MCSocket* result = DoCreateServerSocket(); + if (FOnSocketCreation != NULL) + (FOnSocketCreation)(FOnSocketCreationData, this, result, issServer); + return result; +} + +MCSocketCreationEvent MCSocketFactory::getOnSocketCreation(void**UserData) +{ + if (UserData) + *UserData = FOnSocketCreationData; + return FOnSocketCreation; +} + +void MCSocketFactory::setOnSocketCreation(MCSocketCreationEvent v, void* UserData) +{ + FOnSocketCreationData = UserData; + FOnSocketCreation = v; +} + +// *************************** MCStdSocketFactory ************************** +MCSocket* MCStdSocketFactory::DoCreateClientSocket() +{ + return new MCStdSocket(); +} + +MCSocket* MCStdSocketFactory::DoCreateServerSocket() +{ + return new MCStdSocket(); +} + +// ****************************** MCSocketJob ****************************** + +MCSocketJob::MCSocketJob(void) +:FSocket(NULL), FKickSocket(NULL) +{ +} + +MCSocketJob::~MCSocketJob(void) +{ + delete FSocket; + delete FKickSocket; +} + +MCSocket* MCSocketJob::getSocket(void) +{ + return FSocket; +} + +MCSocket* MCSocketJob::CreateSocket(void) +{ + return new MCStdSocket(); +} + +/* +SocketClass parameter specifies the class of socket property value. +*/ +void MCSocketJob::Initialize(void) +{ + FSocket = CreateSocket(); + FSocket->setLocalPort(0); + FSocket->setLocalAddress("0.0.0.0"); + WinsockErrorCheck(FSocket->Init(istDatagram)); + WinsockErrorCheck(FSocket->Bind()); + FKickSocket = new MCStdSocket(); + WinsockErrorCheck(FKickSocket->Init(istDatagram)); +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCSock.h b/libraries/external/eldos/pc/include/MCSock.h new file mode 100755 index 0000000..9083be5 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSock.h @@ -0,0 +1,296 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCSOCK__ +#define __MCSOCK__ + +#include "MC.h" +#include "MCBase.h" +#include "MCSyncs.h" +#include "MCThreads.h" + +#if defined(WIN32) && !defined(_WIN32_WCE) +#if (_MSC_VER < 1300) +# include +#endif +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +typedef enum {issNotASocket = 0, issInitializing, issInitialized, issBound, issConnected, issListening, issConnecting} + MCSocketState; +typedef enum {isdOutgoing, isdIncoming} MCSocketDir; +typedef enum {istStream, istDatagram} MCSocketType; +typedef enum {issClient, issServer} MCSocketSide; + +//$ifdef MC_SOCKS +enum MCSocksVersion { mcSocks4, mcSocks5}; +enum MCSocksAuthentication {saNoAuthentication, saUsercode}; +//$endif + +enum MCWebTunnelAuthentication { wtaNoAuthentication, wtaRequiresAuthentication }; + +/* +class EMCSockError: public EMCError { +protected: + static char* GetMessageFromErrorCode(long AErrorCode); +public: + static void RaiseLastWinsockError(long AErrorCode); + EMCSockError(long l): EMCError(l) { } +}; +*/ + +#ifndef LINUX +typedef long TSocket; // according to WinSock.pas +#else +typedef int TSocket; +#endif + +class MCSocket { +friend class MCStdSocket; +friend class MCOBEXSocket; +friend class MCInetTransportJob; +protected: + bool FCloseRequest; + MCSocketDir FDirection; + char* FLocalAddress; + unsigned int FLocalPort; + char* FRemoteAddress; + unsigned int FRemotePort; + TSocket FSocket; + MCSocketState FState; + bool FIsClient; + +//$ifdef MC_SOCKS + bool FUseSocks; + char* FSocksServer; + unsigned short FSocksPort; + char* FSocksUserCode;//: ShortString; + char* FSocksPassword;//: ShortString; + MCSocksVersion FSocksVersion; + MCSocksAuthentication FSocksAuthentication; + bool FSocksResolveAddress; +//$endif + struct { + void* Data; + long Len; + long Size; + } FIncomingBuf; + +protected: + // Web tunneling support + bool FUseWebTunneling; + char *FWebTunnelAddress; + unsigned short FWebTunnelPort; + MCWebTunnelAuthentication FWebTunnelAuthentication; + char *FWebTunnelUserId; + char *FWebTunnelPassword; + +protected: + virtual MCSocket* CreateAcceptingSocket() = 0; +public: + MCSocket(void); + virtual ~MCSocket(void); + + virtual MCSocket* Accept(void) = 0; + /* + This method is called by the transport thread after socket is connected. + All communications between connection parties, that are not part of normal + data exchange (SOCKS authentication, SSL connection initiation), + should be implemented inside of this method. + */ + virtual long AfterConnection(MCSocket* CtlSocket, long Timeout); + virtual long AsyncConnect(MCSocket* CtlSocket, long Timeout); + virtual long Bind(void) = 0; + virtual void Close(bool Forced) = 0; + virtual bool Connect(void); + + virtual long ExtConnect(MCSocket* CtlSocket, long Timeout); + + static void FinalizeWinSock(void); + virtual void FinishAsyncConnect(void) = 0; + + virtual bool HasBufferedOutgoingData(); + virtual bool HasBufferedIncomingData(); + + virtual long Init(MCSocketType SocketType) = 0; + static void InitializeWinSock(void); + + virtual long IntReceive(void* Data, long DataLen, long& Received) = 0; + virtual long IntSend(void* Data, long DataLen, long& Sent) = 0; + + virtual long Listen(long BackLog); + static bool PopFromCtlSocket(MCSocket* CtlSocket); + virtual bool PostprocessOutgoingData(); + virtual bool PreprocessIncomingData(); + virtual long Receive(void* Data, long DataLen, long& Received) = 0; + virtual long ReceiveFrom(void* Data, long DataLen, long& Received, char*& RemoteAddress, + unsigned int& RemotePort) = 0; + virtual void ReturnData(void* Data, long DataLen) = 0; + virtual long ReusePort() = 0; + virtual long Send(void* Data, long DataLen, long& Sent) = 0; + virtual long SendTo(void* Data, long DataLen, long& Sent, char* RemoteAddress, + unsigned int RemotePort) = 0; + virtual long StartAsyncConnect(); + virtual long SyncConnect(void); + + /* + Direction specifies whether the socket initiated connection (outgoing + socket) or the socket is listening or accepted connection (incoming). + */ + virtual TSocket getSocket(void); + virtual MCSocketDir getDirection(void); + virtual MCSocketState getState(void); + void setLocalAddress(const char* Value); + void setLocalPort(unsigned int Value); + void setRemoteAddress(const char* Value); + void setRemotePort(unsigned int Value); + char* getLocalAddress(void); + unsigned int getLocalPort(void); + char* getRemoteAddress(void); + unsigned int getRemotePort(void); +//$ifdef MC_SOCKS + void setUseSocks(bool Value); + bool getUseSocks(void); + void setSocksVersion(MCSocksVersion Value); + MCSocksVersion getSocksVersion(void); + void setSocksServer(const char* Value); + const char* getSocksServer(void); + void setSocksPort(unsigned short Value); + unsigned short getSocksPort(void); + void setSocksAuthentication(MCSocksAuthentication Value); + MCSocksAuthentication getSocksAuthentication(void); + void setSocksUserCode(const char* Value); + const char* getSocksUserCode(void); + void setSocksPassword(const char* Value); + const char* getSocksPassword(void); + void setSocksResolveAddress(bool Value); + bool getSocksResolveAddress(void); +//$endif + // Web tunneling support + void setUseWebTunneling(bool Value); + bool getUseWebTunneling(); + void setWebTunnelAddress(const char *Value); + const char* getWebTunnelAddress(); + void setWebTunnelPort(unsigned short Value); + unsigned short getWebTunnelPort(); + MCWebTunnelAuthentication getWebTunnelAuthentication(); + void setWebTunnelAuthentication(MCWebTunnelAuthentication Value); + void setWebTunnelUserId(const char *Value); + const char* getWebTunnelUserId(); + void setWebTunnelPassword(const char *Value); + const char* getWebTunnelPassword(); +}; + +class MCStdSocket: public MCSocket { +protected: + struct sockaddr_in FAddr; + virtual MCSocket* CreateAcceptingSocket() { return new MCStdSocket; }; +//$ifndef LINUX + virtual long SocksConnect(MCSocket* CtlSocket, long Timeout); +//$endif + virtual long HTTPConnect(MCSocket* CtlSocket, long Timeout); + bool SocksSendReceive(bool &Terminated, MCSocket* CtlSocket, unsigned long Timeout, + void* sendBuf, long sendBufSize, long& wasSent, + void* readBuf, long readBufSize, long& wasRead); + +public: + MCStdSocket(void); + virtual ~MCStdSocket(); + + virtual MCSocket* Accept(void); + virtual long AddToMulticastSrv(const char* GroupAddress, const char* BindAddress); + virtual long AddToMulticastCli(const char* BindAddress, unsigned char TTL, bool Loop); + virtual long AsyncConnect(MCSocket* CtlSocket, long Timeout); + virtual long Bind(void); + virtual void Close(bool Forced); + virtual bool Connect(void); + virtual long ExtConnect(MCSocket* CtlSocket, long Timeout); + + virtual void FinishAsyncConnect(void); + sockaddr_in* GetInAddr(void) { return &FAddr; } + virtual long Init(MCSocketType SocketType); + virtual long IntReceive(void* Data, long DataLen, long& Received); + virtual long IntSend(void* Data, long DataLen, long& Sent); + + virtual long Listen(long BackLog); + virtual long Receive(void* Data, long DataLen, long& Received); + virtual long ReceiveFrom(void* Data, long DataLen, long& Received, char*& RemoteAddress, + unsigned int& RemotePort); + virtual void ReturnData(void* Data, long DataLen); + virtual long ReusePort(); + virtual long Send(void* Data, long DataLen, long& Sent); + virtual long SendTo(void* Data, long DataLen, long& Sent, char* RemoteAddress, + unsigned int RemotePort); + + virtual long StartAsyncConnect(); + virtual long SyncConnect(void); +}; + +typedef void (STDCALLCONV *MCSocketCreationEvent)(void* UserData, void* Sender, + MCSocket *Socket, MCSocketSide SocketSide); + +class MCSocketFactory +{ +protected: + MCSocketCreationEvent FOnSocketCreation; + void* FOnSocketCreationData; + + virtual MCSocket* DoCreateClientSocket() = 0; + virtual MCSocket* DoCreateServerSocket() = 0; +public: + MCSocketFactory(); + + MCSocket* CreateClientSocket(); + MCSocket* CreateServerSocket(); + + MCSocketCreationEvent getOnSocketCreation(void**UserData = NULL); + void setOnSocketCreation(MCSocketCreationEvent v, void* UserData = NULL); + +}; + +class MCStdSocketFactory : public MCSocketFactory +{ + virtual MCSocket* DoCreateClientSocket(); + virtual MCSocket* DoCreateServerSocket(); +}; + +class MCSocketJob:public MCThreadJob { +protected: +friend class MCInetTransport; +friend class MCSocketTransport; +friend class MCHTTPTransport; + MCStdSocket* FKickSocket; + MCSocket* FSocket; + +public: + MCSocketJob(void); + virtual ~MCSocketJob(); + + virtual MCSocket* CreateSocket(void); + virtual void Initialize(void); + MCStdSocket* getKickSocket(void) { return FKickSocket; }; + MCSocket* getSocket(void); + + //MCThreadJob implementation + virtual void Run(void) = 0; +}; + + +void WinsockErrorCheck(long ErrorCode); + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCSocket.cpp b/libraries/external/eldos/pc/include/MCSocket.cpp new file mode 100755 index 0000000..ebe499d --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSocket.cpp @@ -0,0 +1,824 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCSocket.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +// ***************************** MCInetTransport **************************** + +MCSocketTransport::MCSocketTransport() +{ + FDefaultTransportName = "SOCKET"; +} + + +MCSocketTransport::~MCSocketTransport() +{ + ; +} + +void MCSocketTransport::NotifyJob(MCInetTransportJob* Job, bool MessageFlag) +{ + MCSocketTransportJob* Thr = (MCSocketTransportJob*)Job; + if (NULL != Thr) + { + if(!(Thr->getIsSending() || Thr->getInHandshake())) + { + KickEntrySocket(Job->getEntry(), MessageFlag); + } + } +} + +void MCSocketTransportJob::MakeFetchPacket(void) +{ +} + +bool MCSocketTransportJob::InitializeConnection() +{ + if (MCInetTransportJob::InitializeConnection()) + { + FHandshakeWaitingReply = false; + return true; + } + else + return false; +} + +MCMessageInfo* MCSocketTransportJob::MakeEmptyReply(MCMessageInfo* Info) +{ + return NULL; +} + +MCInetTransportJob* MCSocketTransport::CreateTransportJob(void) +{ + MCInetTransportJob* trans = new MCSocketTransportJob(); + trans->AdjustBufferSize(FIncomingBufferSize, FOutgoingBufferSize); + trans->AdjustSpeedLimits(FIncomingSpeedLimit, FOutgoingSpeedLimit); + return trans; +} + +MCInetConnectionEntry* MCSocketTransport::CreateConnectionEntry(void) +{ + return new MCInetConnectionEntry(); +} + +MCSocketTransportJob::MCSocketTransportJob(void) +{ + FInHandshake = false; +} + +MCSocketTransportJob::~MCSocketTransportJob() +{ +} + +bool MCSocketTransportJob::PostConnectionStep(void) +{ + //if (FTransporter->getDirection() == isdOutgoing) + // ShowDebugInfo("Outgoing %d handshake calling\n", GetCurrentThreadId()); + //else + // ShowDebugInfo("Incoming %d handshake calling\n", GetCurrentThreadId()); + + bool res = PerformHandshake(); + + //if (FTransporter->getDirection() == isdOutgoing) + // ShowDebugInfo("Outgoing %d handshake done\n", GetCurrentThreadId()); + //else + // ShowDebugInfo("Incoming %d handshake done\n", GetCurrentThreadId()); + + FInHandshake = false; + FHandshakeWaitingReply = false; + return res; +} + +void MCSocketTransportJob::SetTransporterAddress(MCInetConnectionEntry* Ent, MCSocket* Transp) +{ + long ClientID = 0, ConnID = 0; + int Port = 0; char* IP = NULL; + if (ParseRemoteAddr(FEntry->getRemoteAddress(), &ClientID, &ConnID, &IP, &Port) == true) + { + Transp->setRemoteAddress(IP); + Transp->setRemotePort(Port); + } + MCMemFree(IP); IP = NULL; +} + +bool MCSocketTransportJob::NeedCloseCompletedExchg(void) +{ + return false; +} + + + +bool MCSocketTransportJob::HSPacketSent(void) +{ + bool r = false; + try { + FEntry->getCS()->Enter(); + try { + r = FEntry->getOutgoingStream() && + (FEntry->getOutgoingStream()->Len() == FEntry->getOutgoingStream()->Pos()); + if(r) + { + setIsSending(false); + delete FEntry->getOutgoingStream(); + FEntry->setOutgoingStream(NULL); + } + } FINALLY ( + FEntry->getCS()->Leave(); + ) +#ifdef USE_CPPEXCEPTIONS + } catch(...) { +#else + } __except(1) { +#endif + } + return r; +} + +bool MCSocketTransportJob::HSReplyReceived(bool& Success) +{ + MCInetHeader Header; + long i; + bool r = false; + + try { + FEntry->getCS()->Enter(); + try { + r = FEntry->getIncomingStream() && + (FEntry->getMsgSize() > 0) && + (FEntry->getIncomingStream()->Len() == FEntry->getMsgSize()); + if(r) + { + FEntry->getIncomingStream()->SetPos(0); + + // read the header + FEntry->getIncomingStream()->Read(&Header, sizeof(Header)); + + // read 0 (source messenger name, as it is supposed to be) + FEntry->getIncomingStream()->Read(&i, sizeof(i)); +// char SMsg[128]; +// FEntry->getIncomingStream()->Read(SMsg, i); + + + Success = ((Header.dwEncryptID != -1) && + (Header.dwCompressID != -1) && + (Header.dwSealID != -1)); + + if (Success) + { + + Success = Success && (((Header.dwEncryptID == 0) && ((!FOwner->FNoTransformerFallback) || (FOwner->FEncryptor == NULL)) || + ((FOwner->FEncryptor != NULL) && (FOwner->FEncryptor->GetID() == Header.dwEncryptID)))); + + Success = Success && (((Header.dwCompressID == 0) && ((!FOwner->FNoTransformerFallback) || (FOwner->FCompressor == NULL)) || + ((FOwner->FCompressor != NULL) && (FOwner->FCompressor->GetID() == Header.dwCompressID)))); + + Success = Success && (((Header.dwSealID == 0) && ((!FOwner->FNoTransformerFallback) || (FOwner->FSealer == NULL)) || + ((FOwner->FSealer != NULL) && (FOwner->FSealer->GetID() == Header.dwSealID)))); + + } + + + if (Success) + { + FEntry->setEncryptID(Header.dwEncryptID); + FEntry->setCompressID(Header.dwCompressID); + FEntry->setSealID(Header.dwSealID); + } + + FEntry->setMsgSize(0); + setIsReceiving(false); + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + + } + } FINALLY ( + FEntry->getCS()->Leave(); + ) +#ifdef USE_CPPEXCEPTIONS + } catch(...) { +#else + } __except(1) { +#endif + } + return r; +} + +bool MCSocketTransportJob::HSRequestReceived(void) +{ + MCInetHeader Header; + long i; + char* SMessenger; + bool r = false; + + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + r = FEntry->getIncomingStream() && + (FEntry->getMsgSize() > 0) && + (FEntry->getIncomingStream()->Len() == FEntry->getMsgSize()); + if(r) + { + FEntry->getIncomingStream()->SetPos(0); + + // read the header + FEntry->getIncomingStream()->Read(&Header, sizeof(Header)); + + // read source messenger name + FEntry->getIncomingStream()->Read(&i, sizeof(i)); + + if(i > 0) + { + SMessenger = (char*)MCMemAlloc(i + 1); + FEntry->getIncomingStream()->Read(SMessenger, i); + SMessenger[i] = 0; + + //FEntry->setRemoteAddress(SMessenger); + MCASSERT(SMessenger); + MCMemFree(SMessenger); + } + + FEntry->setMsgSize(0); + + PrepareReplyForHandshake(&Header); + setIsReceiving(false); + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + } + } FINALLY ( + FEntry->getCS()->Leave(); + ) + } + CATCH_EVERY + { + + } + return r; +} + +bool MCSocketTransportJob::PerformHandshake(void) +{ + timeval TimeVal; + timeval* PTV; + long select_res; + fd_set FDSendSet, FDRecvSet; + long i; + bool r = false; + + while(true) + { + if(!getIsSending()) + { + // if this is client + if(FTransporter->getDirection() == isdOutgoing) + { + // if we are not waiting for reply, then we have just started. + if(!FHandshakeWaitingReply) + { + // create a packet for sending. + if(!PrepareMessageForHandshake()) + { + //if(FTransporter->getDirection() == isdIncoming) + // OutputDebugString("Incoming handshake failed (Prepare failed)\n"); + //else + // OutputDebugString("Outgoing handshake failed (Prepare failed)\n"); + return(r); + } + else + { + setIsSending(true); + continue; + } + } + } + } + + if (FTransporter->HasBufferedIncomingData()) + { + if (ReceiveData()) + { + if(FTransporter->getDirection() == isdIncoming) + { + HSRequestReceived(); + continue; + } + else + if(FTransporter->getDirection() == isdOutgoing) + { + if (HSReplyReceived(r)) + { + break; + } + } + continue; + } + else + break; + } + else + { + + // prepare parameters for select() + + // initialize sets for select + FD_ZERO(&FDSendSet); + FD_ZERO(&FDRecvSet); + + FD_SET((unsigned long)FSocket->getSocket(), &FDRecvSet); + + // decide whether we expect to get something + // We read from socket if (a) we are in receiving state, or + // (b) we are server that is waiting for client's request, or + // (c) we are client which is getting reply + unsigned int highSocketHandle; + if(getIsReceiving() || + ((FTransporter->getDirection() == isdIncoming) && (!getIsSending())) || + ((FTransporter->getDirection() == isdOutgoing) && FHandshakeWaitingReply)) + { + FD_SET((unsigned long)FTransporter->getSocket(), &FDRecvSet); + highSocketHandle = FSocket->getSocket() > FTransporter->getSocket() ? FSocket->getSocket() : FTransporter->getSocket(); + } + else + { + highSocketHandle = FSocket->getSocket(); + } + + i = FOwner->getInactivityTime(); + if(i > 0) + { + TimeVal.tv_sec = i / 1000; + TimeVal.tv_usec = (i % 1000) * 1000; + PTV = &TimeVal; + } + else + PTV = NULL; + + if(getIsSending()) + { + FD_SET((unsigned long)FTransporter->getSocket(), &FDSendSet); +//#ifdef __GNUC__ +// select_res = select(FD_SETSIZE, &FDRecvSet, &FDSendSet, NULL, PTV); +//#else + select_res = select(highSocketHandle + 1, &FDRecvSet, &FDSendSet, NULL, PTV); +//#endif + } + else +//#ifdef __GNUC__ +// select_res = select(FD_SETSIZE, &FDRecvSet, NULL, NULL, PTV); +//#else + select_res = select(highSocketHandle + 1, &FDRecvSet, NULL, NULL, PTV); +//#endif + + switch(select_res) { + case -1: + case 0: // return thread to the pool or wherever it goes ... + return r; + default: + // CtlSocket signaled that we have a message to send + if(FD_ISSET(FSocket->getSocket(), &FDRecvSet)) + { + if(!getTerminated()) + { + if (!MCSocket::PopFromCtlSocket(FSocket)) + return r; + } + } + + // we have something to receive from the remote side + if(FD_ISSET((unsigned long)FTransporter->getSocket(), &FDRecvSet)) + { + if (FTransporter->PreprocessIncomingData()) + { + if(ReceiveData()) + { + if(FTransporter->getDirection() == isdIncoming) + { + HSRequestReceived(); + continue; + } + else + if(FTransporter->getDirection() == isdOutgoing) + { + if (HSReplyReceived(r)) + { + /* + if (r) + OutputDebugString("Outgoing handshake OK\n"); + else + OutputDebugString("Outgoing handshake failed\n"); + */ + return r; // break; + } + } + continue; + } + else + { + // give up due to connection error + /*if(FTransporter->getDirection() == isdIncoming) + OutputDebugString("Incoming handshake failed\n"); + else + OutputDebugString("Outgoing handshake failed\n"); + */ + return(r); // break; + } + } + } + // we can send + if(FD_ISSET(FTransporter->getSocket(), &FDSendSet)) + { + if (FTransporter->HasBufferedOutgoingData() || (getIsSending() && SendData())) + { + if (FTransporter->PostprocessOutgoingData()) + { + if (getIsSending()) + { + if(FTransporter->getDirection() == isdIncoming) + { + if(HSPacketSent() && !FTransporter->HasBufferedOutgoingData()) + { + return true; // break; + } + } + else + if(FTransporter->getDirection() == isdOutgoing) + { + if(HSPacketSent()) + { + FHandshakeWaitingReply = true; + continue; + } + } + } + } + } + else + if (getIsSending()) + { + return false; + } + } + } + } + if(getTerminated()) + break; + } + return(r); +} + + +/* +This method is called from PerformHandshake to create a request data block +for handshake. Method returns true if the block was prepared and false if +there was some error. +*/ + +bool MCSocketTransportJob::PrepareMessageForHandshake(void) +{ + long i; + MCMemStream* MemStream; + MCInetHeader Header; + //char* SMessenger; + bool r = false; + + TRY_BLOCK + { + FOwner->FLinkCriticalSection->Enter(); + try { + if(FOwner->FCompressor) + Header.dwCompressID = FOwner->FCompressor->GetID(); + else + Header.dwCompressID = 0; + if(FOwner->FEncryptor) + Header.dwEncryptID = FOwner->FEncryptor->GetID(); + else + Header.dwEncryptID = 0; + if(FOwner->FSealer) + Header.dwSealID = FOwner->FSealer->GetID(); + else + Header.dwSealID = 0; + } FINALLY ( + FOwner->FLinkCriticalSection->Leave(); + ) + MemStream = new MCMemStream(); + + FEntry->getCS()->Enter(); + try { + // prepare source address + i = 0; + // prepare data block + Header.dwSignature = 0x50444945ul; + Header.dwDataSize = sizeof(Header) + sizeof(i) + i; + + FEntry->setOutgoingStream(MemStream); + // write outgoing data + // write header + MemStream->Write(&Header, sizeof(Header)); + + // write source address + MemStream->Write(&i, sizeof(i)); + + MemStream->SetPos(0); + + setIsSending(true); + } FINALLY ( + FEntry->getCS()->Leave(); + ) + r = true; + } + CATCH_EVERY + { + } + return r; +} + + +/* +This method is called from HSRequestReceived create a reply data block for +handshake. Method returns true if the block was prepared and false if there +was some error. +*/ + +bool MCSocketTransportJob::PrepareReplyForHandshake(MCInetHeader* RqHeader) +{ + long i; + MCMemStream* MemStream; + MCInetHeader Header; + bool r = false; + + TRY_BLOCK + { + FOwner->FLinkCriticalSection->Enter(); + TRY_BLOCK + { + if(FOwner->FCompressor && (FOwner->FCompressor->GetID() == RqHeader->dwCompressID)) + Header.dwCompressID = RqHeader->dwCompressID; + else + if ((FOwner->getNoTransformerFallback()) && + ((FOwner->FCompressor != NULL) && (FOwner->FCompressor->GetID() != RqHeader->dwCompressID))) + Header.dwCompressID = -1; + else + Header.dwCompressID = 0; + + if (FOwner->FEncryptor && (FOwner->FEncryptor->GetID() == RqHeader->dwEncryptID)) + Header.dwEncryptID = RqHeader->dwEncryptID; + else + if ((FOwner->getNoTransformerFallback()) && + ((FOwner->FEncryptor != NULL) && (FOwner->FEncryptor->GetID() != RqHeader->dwEncryptID))) + Header.dwEncryptID = -1; + else + Header.dwEncryptID = 0; + + if(FOwner->FSealer && (FOwner->FSealer->GetID() == RqHeader->dwSealID)) + Header.dwSealID = RqHeader->dwSealID; + else + if ((FOwner->getNoTransformerFallback()) && + ((FOwner->FSealer != NULL) && (FOwner->FSealer->GetID() != RqHeader->dwSealID))) + Header.dwSealID = -1; + else + Header.dwSealID = 0; + + } FINALLY ( + FOwner->FLinkCriticalSection->Leave(); + ) + MemStream = new MCMemStream(); + + FEntry->setCompressID(Header.dwCompressID); + FEntry->setEncryptID(Header.dwEncryptID); + FEntry->setSealID(Header.dwSealID); + + //FEntry->getCS()->Enter(); + //TRY_BLOCK { + + // prepare data block + Header.dwSignature = 0x50444945ul; + Header.dwDataSize = sizeof(Header) + sizeof(long);// + strlen(FEntry->getRemoteAddress()); + FEntry->setOutgoingStream(MemStream); + + // write outgoing data + // write header + FEntry->getOutgoingStream()->Write(&Header, sizeof(Header)); + + // write source address + i = 0;//strlen(FEntry->getRemoteAddress()); + FEntry->getOutgoingStream()->Write(&i, sizeof(i)); + if (i > 0) + FEntry->getOutgoingStream()->Write(FEntry->getRemoteAddress(), i); + + FEntry->getOutgoingStream()->SetPos(0); + + setIsSending(true); + //} FINALLY ( {} + // FEntry->getCS()->Leave(); + //) + r = true; + } + CATCH_EVERY + { + } + return r; +} + +bool MCSocketTransportJob::ReceiveData(void) +{ + long Received; + long MsgSize; + long ToRecv; + bool r = false; + bool tooBigPacket = false; + + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if(!getIsReceiving()) + { + // initiate new message + if(FTransporter->Receive(&FIncomingBuffer[0 - FEntry->getMsgSize()], sizeof(long) * 2, Received) == 0) + { + if(Received > 0) + { + FblInSessionTransferred += Received; + FblInMsgTransferred += Received; + FblInSecTransferred += Received; + + if((Received + (-FEntry->getMsgSize())) < (long)(sizeof(long) * 2)) + { + FEntry->setMsgSize(FEntry->getMsgSize() - Received); + // here we will get negative value. Negative value is used to signal + // that we have not yet allocated an incoming stream and + // -Entry.MsgSize is the amount of data already in incoming buffer + r = true; + // return(r); + RETURN + } + + unsigned long readSignature = *((unsigned long*)FIncomingBuffer); + if (readSignature != 0x50444945ul) + { + FEntry->setMsgSize(0); + r = false; + RETURN + } + + // calculate total size of already received data + Received = -FEntry->getMsgSize() + Received; + + // set message size + MsgSize = *((unsigned long*)&FIncomingBuffer[sizeof(long)]); + + /* + char bubuf[50]; + sprintf(bubuf, "MsgSize: %d \n", MsgSize); + ShowDebugInfo(bubuf); + */ + + FEntry->setMsgSize(MsgSize); + + // check owner's properties, then allocate stream + FEntry->getCS()->Leave(); + FOwner->FCriticalSection->Enter(); + TRY_BLOCK + { + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if(FOwner->getMaxMsgSize() != 0 && FEntry->getMsgSize() > FOwner->getMaxMsgSize()) + { + FEntry->setMsgSize(0); + tooBigPacket = true; + //FTransporter->Close(false); + r = false; + } + else + { + // allocate stream for incoming data + if (FEntry->getIncomingStream() != NULL) + { + delete FEntry->getIncomingStream(); FEntry->setIncomingStream(NULL); + } + if(!getInHandshake() && FOwner->getUseTempFilesForIncoming() && (MsgSize > (long)FOwner->getIncomingMemoryThreshold())) + FEntry->setIncomingStream(new MCTmpFileStream(FOwner->getTempFilesFolder(), MsgSize)); + else + FEntry->setIncomingStream(new MCMemStream()); + MCASSERT(FEntry->getIncomingStream() != NULL); + } + } FINALLY ( + FEntry->getCS()->Leave(); + ) + } FINALLY ( + FOwner->FCriticalSection->Leave(); + ) + + FEntry->getCS()->Enter(); + if (!tooBigPacket) + { + FEntry->getIncomingStream()->Write(FIncomingBuffer, Received); + setIsReceiving(true); + r = true; + } + } + } + else + { + //char Buffer [150]; + //sprintf(Buffer, "ReceiveData failed with error %d\n", err); + //OutputDebugString(Buffer); + } + } + else // already receiving + { + MCASSERT(FTransporter != NULL); + MCASSERT(FEntry->getIncomingStream() != NULL); + + ToRecv = FEntry->getMsgSize() - FEntry->getIncomingStream()->Len(); + + if(ToRecv > (long) FblToRecv) + ToRecv = FblToRecv; + + if(FTransporter->Receive(FIncomingBuffer, ToRecv, Received) == 0) + { + FblInSessionTransferred += Received; + FblInMsgTransferred += Received; + FblInSecTransferred += Received; + + FEntry->getIncomingStream()->Write(FIncomingBuffer, Received); + r = true; + } + } + } FINALLY ( + FEntry->getCS()->Leave(); + ) + } + CATCH_EVERY + { + } + return r; +} + +bool MCSocketTransportJob::SendData(void) +{ + long ToSend, Sent; + bool r = false; + + FEntry->getCS()->Enter(); + TRY_BLOCK + { + if(getIsSending()) + { + TRY_BLOCK + { + if(FEntry->getOutgoingStream()->Len() - FEntry->getOutgoingStream()->Pos() < (long)FblToSend) + ToSend = FEntry->getOutgoingStream()->Len() - FEntry->getOutgoingStream()->Pos(); + else + ToSend = FblToSend; + FEntry->getOutgoingStream()->Read(FOutgoingBuffer, ToSend); + if(FTransporter->Send(FOutgoingBuffer, ToSend, Sent) == 0) + { + FblOutSessionTransferred += Sent; + FblOutMsgTransferred += Sent; + FblOutSecTransferred += Sent; + + FEntry->getOutgoingStream()->SetPos(FEntry->getOutgoingStream()->Pos() - ToSend + Sent); + r = true; + } + } FINALLY ( + ; + ) + } + } + CATCH_EVERY + { + } + FEntry->getCS()->Leave(); + + return r; +} + +bool MCSocketTransportJob::getInHandshake(void) +{ + return FInHandshake; +} + +void MCSocketTransportJob::setInHandshake(bool Value) +{ + FInHandshake = Value; +} + + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCSocket.h b/libraries/external/eldos/pc/include/MCSocket.h new file mode 100755 index 0000000..2c51494 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSocket.h @@ -0,0 +1,81 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCSOCKET__ +#define __MCSOCKET__ + + +#include "MC.h" +#include "MCSocketBase.h" +#include "MCInetTransport.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +class MCSocketTransport: public MCInetTransport +{ +protected: + virtual MCInetConnectionEntry* CreateConnectionEntry(void); + virtual MCInetTransportJob* CreateTransportJob(void); + virtual void NotifyJob(MCInetTransportJob* Job, bool MessageFlag); + virtual bool NeedLiveConnectionForDelivery(void) + { + return true; + }; + + virtual unsigned int getDeliveryInterval(void) + { + return getAttemptsInterval(); + }; + + +public: + MCSocketTransport(void); + virtual ~MCSocketTransport(); +}; + + +class MCSocketTransportJob: public MCInetTransportJob +{ +protected: + bool FInHandshake; + + bool HSPacketSent(void); + bool HSReplyReceived(bool& Success); + bool HSRequestReceived(void); + bool PerformHandshake(void); + bool PrepareMessageForHandshake(void); + bool PrepareReplyForHandshake(MCInetHeader* RqHeader); + virtual bool InitializeConnection(); + + virtual void UpdateConnectionContext(void) {}; + virtual void SetTransporterAddress(MCInetConnectionEntry* Ent, MCSocket* Transp); + virtual bool PostConnectionStep(void); + virtual bool NeedCloseCompletedExchg(void); + virtual bool ReceiveData(void); + virtual bool SendData(void); + virtual void MakeFetchPacket(void); + virtual MCMessageInfo* MakeEmptyReply(MCMessageInfo* Info); + +public: + MCSocketTransportJob(); + virtual ~MCSocketTransportJob(); + + bool getInHandshake(void); + void setInHandshake(bool Value); + +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCSocketBase.h b/libraries/external/eldos/pc/include/MCSocketBase.h new file mode 100755 index 0000000..4893462 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSocketBase.h @@ -0,0 +1,24 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCSOCKETBASE__ +#define __MCSOCKETBASE__ + +typedef struct { + long dwSignature; // "EIDP", $50444945 + long dwDataSize; // total size of the data + long dwCompressID; + long dwEncryptID; + long dwSealID; +} MCInetHeader ; + +typedef enum {stmP2P, stmServer, stmClient} MCInetTransportMode; + +typedef enum {bpFlexible, bpStrict} MCBandwidthPolicy; + +#endif diff --git a/libraries/external/eldos/pc/include/MCStream.cpp b/libraries/external/eldos/pc/include/MCStream.cpp new file mode 100755 index 0000000..0be8e18 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCStream.cpp @@ -0,0 +1,313 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCStream.h" +#include +#include +#include +#include "MCThreads.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +MCStream::MCStream(void) +{ + FLen = 0; + FPos = 0; +} + +long MCStream::Len(void) +{ + return FLen; +} + +long MCStream::Pos(void) +{ + return FPos; +} + +long MCStream::SetPos(long l) +{ + return FPos = l; +} + +MCMemStream::MCMemStream(void):MCStream() +{ + FData = NULL; + FSize = 0; + FExt = false; +} + +long MCMemStream::Grow(long l) +{ + long delta = (long)(FSize * 1.33 + 0.5) - FSize; + if (delta < 32) + delta = 32; + + char* p = NULL; + if(FExt) + return 0; + + if(l < 1) + return 0; + delta = delta < l ? l : delta; + + p = new char[FSize + delta]; + memset(p, 0, (FSize + delta) * sizeof(char)); + if(FSize) + { + memcpy(p, FData, FSize * sizeof(char)); + delete[] FData; FData = NULL; + } + FSize += delta; + FData = p; + return delta; +} + +MCMemStream::~MCMemStream(void) +{ + Free(); +} + +void MCStream::Free(void) +{ + FLen = 0; + FPos = 0; +} + +void MCMemStream::Free(void) +{ + if(!FExt && FData) + delete[] FData; + FData = NULL; + MCStream::Free(); + FSize = 0; + FExt = false; +} + +long MCMemStream::SetPos(long l) +{ + if(l < 0) + return FPos; + if(FExt && (l >= FLen)) + { + MCStream::SetPos(FLen); + return FPos; + } + MCStream::SetPos(l); + if(l > FSize) + Grow(l - FSize); + if(l > FLen) + FLen = l; + return FPos; +} + +long MCMemStream::Read(void* d, long l) +{ + if(l < 1) + return 0; + long x = ((FPos + l) > FLen) ? (FLen - FPos) : l; + memcpy(d, &FData[FPos], x); + FPos += x; + return x; +} + +long MCMemStream::Write(void* d, long l) +{ + if(l < 1) + return(0); + long x = l; + if((FPos + l) > FSize) + if(Grow(FPos + l - FSize) == 0) + x = FSize - FPos; + else + FLen = FPos + l; + memcpy(&FData[FPos], d, x); + FPos += x; + if(FPos > FLen) + FLen = FPos; + return x; +} + +void MCMemStream::SetPointer(char* data, long l) +{ + Free(); + if(l < 0) + return; + if(data) + { + FExt = true; + FData = data; + FSize = FLen = l; + } + else + { + FData = NULL; + FSize = 0; + FExt = false; + } +} + +#ifdef _WIN32 + +#ifdef UNICODE +# include +#endif + +MCTmpFileStream::MCTmpFileStream(char*s, __int64 i) +:FName(NULL) +{ +#ifdef _UNICODE + int reqSize = 0; + MultiByteToWideChar(CP_ACP, 0, s, -1, NULL, reqSize); + TCHAR* sW = (TCHAR*)MCMemAlloc(reqSize+1); + MultiByteToWideChar(CP_ACP, 0, s, -1, sW, reqSize); + TCHAR buf[MAX_PATH]; + GetTempFileName(sW, _T("mc"), 0, buf); + FName = (TCHAR*)MCMemAlloc((_tcslen(buf)+1) * sizeof(TCHAR)); + _tcscpy(FName, buf); + MCMemFree(sW); sW = NULL; +#else + TCHAR buf[MAX_PATH]; + GetTempFileName(s, "mc", 0, buf); + FName = (TCHAR*)MCMemAlloc(strlen(buf)+1); + strcpy(FName, buf); +#endif + + FFile = CreateFile(FName, GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NOT_CONTENT_INDEXED | FILE_ATTRIBUTE_TEMPORARY | + FILE_FLAG_SEQUENTIAL_SCAN, 0); + + if (INVALID_HANDLE_VALUE == FFile) + THROW_ERROR(GetLastError()); +} + +MCTmpFileStream::~MCTmpFileStream() +{ + Free(); +} + +long MCTmpFileStream::Len(void) +{ + unsigned int oldPos = SetFilePointer(FFile, 0, NULL, FILE_CURRENT); + unsigned int len = SetFilePointer(FFile, 0, NULL, FILE_END); + SetFilePointer(FFile, oldPos, NULL, FILE_BEGIN); + return len; +} + +long MCTmpFileStream::Pos(void) +{ + return SetFilePointer(FFile, 0, NULL, FILE_CURRENT); +} + +long MCTmpFileStream::SetPos(long l) +{ + return SetFilePointer(FFile, l, NULL, FILE_BEGIN); +} + +long MCTmpFileStream::Read(void* d, long l) +{ + DWORD wasRead = 0; + ReadFile(FFile, d, l, &wasRead, NULL); + return wasRead; +} + +long MCTmpFileStream::Write(void* d, long l) +{ + DWORD wasWritten = 0; + WriteFile(FFile, d, l, &wasWritten, NULL); + return wasWritten; +} + +void MCTmpFileStream::Free(void) +{ + if (INVALID_HANDLE_VALUE != FFile) + { + CloseHandle(FFile); + FFile = INVALID_HANDLE_VALUE; + } + if (NULL != FName) + { + DeleteFile(FName); + MCMemFree(FName); FName = NULL; + } +} + +#else + + +MCTmpFileStream::MCTmpFileStream(char*s, __int64 i): MCStream() +{ + char buf[1024]; + //build temp file name + sprintf(buf, "mc%ld%d%d.tmp", i, IntGetCurrentThreadID(), GetCurrentThread()); + FName = (char*)malloc(strlen(s)+strlen(buf)+1); + strcpy(FName, s); + strcat(FName, buf); + FFile = fopen(FName, "wb"); + FLen = 0; + FRsize = false; +} + +long MCTmpFileStream::Len(void) +{ + if(!FRsize) + { + long cp = this->Pos(); + fseek(FFile, 0, SEEK_END); + FLen = this->Pos(); + this->SetPos(cp); + FRsize = true; + } + return MCStream::Len(); +} + +long MCTmpFileStream::Pos(void) +{ + return ftell(FFile); +} + +long MCTmpFileStream::SetPos(long l) +{ + FRsize = false; + return fseek(FFile, l, SEEK_SET); +} + +long MCTmpFileStream::Read(void* d, long l) +{ + fread(d, 1, l, FFile); +} + +long MCTmpFileStream::Write(void* d, long l) +{ + FRsize = false; + return fwrite(d, 1, l, FFile); +} + +void MCTmpFileStream::Free(void) +{ + fclose(FFile); +#ifdef _WIN32_WCE + long l = strlen(FName)+1; + wchar_t* w = new wchar_t[l]; + mbstowcs(w, FName, l); + DeleteFile(w); +#else + remove(FName); +#endif + free(FName); +} +#endif + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCStream.h b/libraries/external/eldos/pc/include/MCStream.h new file mode 100755 index 0000000..679aefc --- /dev/null +++ b/libraries/external/eldos/pc/include/MCStream.h @@ -0,0 +1,93 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCSTREAM__ +#define __MCSTREAM__ + +#include "MC.h" +#include + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +class MCStream +{ +protected: + long FLen; + long FPos; +public: + MCStream(void); + virtual ~MCStream(void) {} + virtual long Len(void); + virtual long Pos(void); + virtual long SetPos(long l); + virtual long Read(void* d, long l) = 0; + virtual long Write(void* d, long l) = 0; + virtual void Free(void); +}; + +class MCMemStream:public MCStream { +protected: + char* FData; + long FSize; + bool FExt; + virtual long Grow(long l); +public: + MCMemStream(void); + virtual ~MCMemStream(void); + virtual void Free(void); + virtual long SetPos(long l); + virtual long Read(void* d, long l); + virtual long Write(void* d, long l); + virtual void SetPointer(char* data, long l); +}; + +#ifdef _WIN32 +class MCTmpFileStream: public MCStream +{ +protected: + HANDLE FFile; + TCHAR* FName; +public: + MCTmpFileStream(char* s, __int64 i); + virtual ~MCTmpFileStream(); + virtual long Len(void); + virtual long Pos(void); + virtual long SetPos(long l); + virtual long Read(void* d, long l); + virtual long Write(void* d, long l); + virtual void Free(void); +}; + +#else + +class MCTmpFileStream: public MCStream { +protected: + FILE* FFile; + bool FRsize; + char* FName; +public: + MCTmpFileStream(char* s, __int64 i); + virtual long Len(void); + virtual long Pos(void); + virtual long SetPos(long l); + virtual long Read(void* d, long l); + virtual long Write(void* d, long l); + virtual void Free(void); +}; +#endif + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCStreams.cpp b/libraries/external/eldos/pc/include/MCStreams.cpp new file mode 100755 index 0000000..5ea97d0 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCStreams.cpp @@ -0,0 +1,274 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCStreams.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +TStream::TStream(void) +{ + Deleted = false; +} + +long TStream::Read(void*, long) +{ + return 0; +} + +long TStream::Write(const void*, long) +{ + return 0; +} + +long TStream::Seek(long) +{ + return 0; +} + +long TStream::Pos(void) +{ + return 0; +} + +long TStream::Size(void) +{ + return 0; +} + +bool TStream::Eof(void) +{ + return true; +} + +char* TStream::PathName(void) +{ + return NULL; +} + +void TStream::Shutdown(void) +{ +} + +void TStream::DeleteFile(void) +{ + Shutdown(); + Deleted = true; +} + +TStream::~TStream(void) +{ + if(!Deleted) + Shutdown(); +} + +TStream* DefOpenStream(char*, int) +{ + return NULL; +} + +TStream* (*OpenStream)(char* File, int AMode) = &DefOpenStream; + +void WriteTextToStream(TStream* F, char* S, bool NewLine) +{ + if(!F) + return; + const char* nl = "\r\n"; + if(S) + F->Write(S, (long)strlen(S)); + if(NewLine) + F->Write(nl, (long)strlen(nl)); +} + +char* ReadStringFromStream(TStream* F, long i) +{ + if(!F) + return NULL; + long x = 0; + char* r = NULL; + + if(!F) + return NULL; + if(i >= 0) + x = i; + else + { + if(F->Read(&x, sizeof(x)) < (long)sizeof(x)) + return NULL; +#ifdef M68K + x = TurnLong(x); +#endif + } + if(x < 0) + x = 0; + if(x > 0) + { + r = (char*)malloc(x + sizeof(char)); + if(F->Read(r, x) < x) + return NULL; + r[x] = 0; + } + return r; +} + +void WriteStringToStream(TStream* F,char* S, bool write_len) +{ + if(NULL == F) + return; + long x = (long)(S ? strlen(S) : 0); + if(x < 0) + x = 0; + if(write_len) + { + long x1 = +#ifdef M68K + TurnLong +#endif + (x); + if(F->Write(&x1, sizeof(x1)) < (long)sizeof(x1)) + return; + } + if(x > 0 && S) + F->Write(S, x); +} + +wchar_t* ReadWideStringFromStream(TStream* F, long i) +{ + if(!F) + return NULL; + long x = i; + wchar_t* r = NULL; + + if(!F) + return NULL; + if(i < 0) + { + if(F->Read(&x, sizeof(x)) < (long)sizeof(x)) + return NULL; +#ifdef M68K + x = TurnLong(x); +#endif + } + if(x < 0) + x = 0; + if(x > 0) + { + r = (wchar_t*)malloc(x + sizeof(wchar_t)); + if(F->Read(r, x) < (signed long)x) + return NULL; + r[x / sizeof(wchar_t)] = 0; + } + return r; +} + +void WriteWideStringToStream(TStream* F, wchar_t* S, bool write_len) +{ + if(NULL == F) + return; + long x = S ? (wstrlen(S) * sizeof(wchar_t)) : 0; + if(write_len) + { + long x1 = +#ifdef M68K + TurnLong +#endif + (x); + if(F->Write(&x1, sizeof(x1)) < (long)sizeof(x1)) + return; + } + if(x > 0 && S) + F->Write(S, x); +} + +void* lrealloc(void* V, long N, long +#ifdef PALM_CW +Os +#endif +) +{ +#ifndef PALM_CW + return(realloc(V, N)); +#else + void* t = NULL; + long cl = (Os > N) ? N : Os; + if(N < 1) + { + free(V); + return NULL; + } + t = malloc(N); + if(NULL == V) + return t; + if(Os > 0) + memcpy(t, V, cl); + free(V); + return t; +#endif +} + +char* ReadTextFromStream(TStream* F) +{ +#ifdef PALM +# define BS 128 +#else +# define BS 16384 +#endif + static char nl[] = "\r\n"; + static size_t nll = strlen(nl); + long x = 0, z = -2, lr = BS, ox = 0, olr; + char* r = NULL, *p; + + if(NULL == F) + return NULL; + while(!F->Eof()) + { + x += lr; + r = (char*)lrealloc(r, x, ox); + ox = x; + p = r + x - lr; + olr = lr; + lr = F->Read(p, BS); + if(lr < 1) + { + free(r); + r = NULL; + break; + } + for(signed long l=((x>BS)?-1:0); l<(signed long)(lr+1-nll); l++) + { + if(0 == _strncmp(&p[l], nl, nll)) + { + z = l; + break; + } + } + if(z > -2) + { + x = x - olr + z; + r = (char*)lrealloc(r, x+1, ox); + if(x >= 0) + r[x] = 0; + F->Seek(F->Pos() - lr + z + 1); + break; + } + } + if(r && !r[0]) + { + free(r); + return(NULL); + } + return r; +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCStreams.h b/libraries/external/eldos/pc/include/MCStreams.h new file mode 100755 index 0000000..2f49311 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCStreams.h @@ -0,0 +1,59 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef MCSTREAMS_H +#define MCSTREAMS_H + +#include "MC.h" +#include "MCPlatforms.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +enum { stRead=1,stWrite=2,stCreate=4 }; + +class TStream { +protected: + int Mode; + int Deleted; // set to true by delete_file() + DEFSECT virtual void Shutdown(void); // actual destruction code called by destructor +public: + DEFSECT TStream(void); + DEFSECT virtual long Read(void* Buf, long Cnt); // reading from + DEFSECT virtual long Write(const void* Buf, long Cnt); // writing to + DEFSECT virtual long Seek(long Cnt); // setting stream position + DEFSECT virtual long Pos(void); // querying stream position + DEFSECT virtual long Size(void); // querying stream size + DEFSECT virtual bool Eof(void); // is end of stream + DEFSECT virtual char* PathName(void); // returns open stream name + DEFSECT virtual void DeleteFile(void); // closes file with shutdown() call and then + // deletes it + DEFSECT virtual ~TStream(void); +}; + +extern TStream* (*OpenStream)(char* File, int AMode); // call with file==NULL + // opens temporary file + +DEFSECT char* ReadTextFromStream(TStream* F); +DEFSECT void WriteTextToStream(TStream* F, char* S, bool NewLine = true); + +DEFSECT char* ReadStringFromStream(TStream* F, long i); +DEFSECT void WriteStringToStream(TStream* F, char* S, bool write_len); + +DEFSECT wchar_t* ReadWideStringFromStream(TStream* F, long i); +DEFSECT void WriteWideStringToStream(TStream* F, wchar_t* S, bool write_len); + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCSyncs.cpp b/libraries/external/eldos/pc/include/MCSyncs.cpp new file mode 100755 index 0000000..dabc16e --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSyncs.cpp @@ -0,0 +1,560 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MCBase.h" +#include "MCSyncs.h" +#ifndef _WIN32 +# include +#endif + +#ifdef _WIN32 +# include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +// --------- MCSynchroObject -------------------------------------------------- + +MCSynchroObject::MCSynchroObject() +{ +#ifndef __GNUC__ + FHandle = INVALID_HANDLE_VALUE; +#else + FOrig = false; +#ifndef QNX + FId = 0; + FEvent = -1; + FMaxCount = 1; +#endif +#endif +} + +#ifdef __GNUC__ +#ifndef QNX +//**********************UNIX******************************************* +void MCSynchroObject::Initialize(int InitialState, __key_t Id, bool Orig, unsigned long MaxCount) +{int fd; + FId = Id; + FEvent = -1; + if (Orig) + FEvent = semget(FId, 1, IPC_CREAT | IPC_EXCL | 0666); + if (FEvent < 0) + { + if ((not Orig) || (errno == EEXIST)) + { + FEvent = semget(FId, 1, IPC_CREAT | 0666); + if (Orig && (FEvent >=0)) + errno = EEXIST; + } + } + if (FEvent < 0) + THROW_ERROR(MCError_SynchroObjectFailed); + + FMaxCount = MaxCount; + FOrig = Orig; + + if (FOrig) + { + semctl(FEvent, 0, SETVAL, 0); + if (InitialState > 0) + Release(InitialState); + } +} + +void MCSynchroObject::Release(int Num) +{ + sembuf b0; + sembuf b; + int err; + memset(&b0, 0, sizeof(b0)); + memset(&b, 0, sizeof(b)); + + b0.sem_flg = IPC_NOWAIT; + b.sem_op = 1; + + if (FMaxCount > 1) + { + if (Num > 1) + b.sem_op = Num; + err = semop(FEvent, &b, 1); + } + else + { + if (semop(FEvent, &b0, 1) >= 0) + err = semop(FEvent, &b, 1); + else + err = 0; + }; + if ((err < 0) && (errno != EIDRM)) + THROW_ERROR(MCError_SynchroObjectFailed); +} + +#else +//**********************QNX******************************************* +void MCSynchroObject::Initialize(int InitialState, char *FileName, bool Orig, unsigned long MaxCount) +{ + int fd; + FEvent = -1; + void *addr; + if (FileName) + { + if (Orig) + { + sem = sem_open(FileName, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 0); + } + if (sem == NULL) + { + if ((!Orig) || (errno == EEXIST)) + { + sem = sem_open(FileName, 0, 0); + } + } + else + FEvent = 0; + } + else + { + FEvent = sem_init(sem, false, 0); + } + if (FEvent < 0) + THROW_ERROR(MCError_SynchroObjectFailed); + + FMaxCount = MaxCount; + FOrig = Orig; + + if (FOrig && (FileName != NULL)) + { + FEvent = sem_init(sem, 1, 0); +// if (InitialState > 0) +// Release(InitialState); + } +} + +void MCSynchroObject::Release(int Num) +{ + int err; +// if (FMaxCount > 1) +// err=sem_wait(sem); +// else + err=sem_post(sem); + if ((err < 0) && (errno != EIDRM)) + THROW_ERROR(MCError_SynchroObjectFailed); +} +#endif //QNX +#endif //__GNUC__ + + +MCWaitResult MCSynchroObject::WaitFor(unsigned long Timeout) +{ + MCWaitResult Result; +#ifndef __GNUC__ + +//$ifndef LINUX + switch(WaitForSingleObject(FHandle, Timeout)) { + case WAIT_ABANDONED: Result = wrAbandoned; break; + case WAIT_OBJECT_0: Result = wrSignaled; break; + case WAIT_TIMEOUT: Result = wrTimeout; break; + case WAIT_FAILED: Result = wrError; break; + default: Result = wrError; break; + } +//$endif +#else + + if ((Timeout == 0xFFFFFFFFL) || (Timeout == 0)) + { +#ifndef QNX + sembuf b; + + memset(&b, 0, sizeof(b)); + + if (Timeout == 0) + b.sem_flg = IPC_NOWAIT; + else + b.sem_flg = 0; + + //if num >= 1 then + b.sem_op = -1; + + if (semop(FEvent, &b, 1) >= 0) + Result = wrSignaled; + else if (errno == EIDRM) + Result = wrAbandoned; + else if (errno == EAGAIN) + Result = wrTimeout; + else + THROW_ERROR(MCError_SynchroObjectFailed); + //result := wrError; +#else + if(sem_wait(sem)) + Result = wrSignaled; + else if (errno == EIDRM) + Result = wrAbandoned; + else if (errno == EAGAIN) + Result = wrTimeout; + else + THROW_ERROR(MCError_SynchroObjectFailed); +#endif + } + else + Result = wrError; +#endif + return(Result); +} + + +MCSynchroObject::~MCSynchroObject() +{ +#ifdef __GNUC__ + if (FOrig) +#ifndef QNX + semctl(FEvent, 0, IPC_RMID, 0); +#else + sem_close(sem); +#endif + +#else +//$ifndef LINUX + if (FHandle != INVALID_HANDLE_VALUE) + CloseHandle(FHandle); + FHandle = INVALID_HANDLE_VALUE; +//$endif +#endif +} + +#ifndef __GNUC__ +//$ifndef LINUX +MCHandle MCSynchroObject::getHandle(void) +{ + return(FHandle); +} +//$endif +#endif + +// --------- MCEvent ---------------------------------------------------------- + +#ifdef __GNUC__ +void MCEvent::Initialize(void* EventAttributes, bool ManualReset, bool InitialState, bool InitialOwner, const char* Name) +{ + char *AName; + bool IO; + FManualReset = ManualReset; +#ifndef QNX + key_t token; + if (Name == NULL || *Name == 0) + { + token = IPC_PRIVATE; + FFileName = NULL; + IO = true; + } +#else + if (Name == NULL || *Name == 0) + { + FFileName = "/SEM"; + IO = true; + } +#endif + else + { + IO = InitialOwner; + + char* ttmpdir = getenv("TEMP"); + char tmpdir[1024]; + if(ttmpdir) + { + strcpy(tmpdir, ttmpdir); + strcat(tmpdir, "/"); + } + else + strcpy(tmpdir, "/tmp/"); + + FFileName = (char*) MCMemAlloc(strlen(tmpdir) + strlen(Name) + 1); + strcpy(FFileName, tmpdir); + strcat(FFileName, Name); + + FFileObj = -1; + if (IO) + { + FFileObj = open(FFileName, O_CREAT | O_RDWR | O_EXCL | O_SYNC, DEFFILEMODE); + if (FFileObj < 0) + { + if (errno != EEXIST) + THROW_ERROR(MCError_SynchroObjectFailed); + IO = false; + } + } +#ifndef QNX + token = ftok(FFileName, 'E'); +#endif + } + +#ifndef QNX + MCSynchroObject::Initialize(InitialState ? 1 : 0, token, IO, 1); +#else + MCSynchroObject::Initialize(InitialState ? 1 : 0, FFileName, IO, 1); +#endif + +} + +#endif + +MCEvent::MCEvent(void* EventAttributes, bool ManualReset, bool InitialState, + const char* Name, bool OpenOnly) : MCSynchroObject() +#ifdef __GNUC__ +#ifndef QNX + , FManualReset(false), FFileName(NULL), FFileObj(-1) +#endif +#endif +{ +#ifndef __GNUC__ +//$ifndef LINUX +#if defined(_WIN32_WCE) || defined(UNICODE) + wchar_t* w = s2w(Name); + FHandle = CreateEvent((LPSECURITY_ATTRIBUTES)EventAttributes, ManualReset, InitialState, w); + delete w; +#else + FHandle = CreateEvent((LPSECURITY_ATTRIBUTES)EventAttributes, ManualReset, InitialState, Name); +#endif +//$endif +#else + Initialize(EventAttributes, ManualReset, InitialState, !OpenOnly, Name); +#endif +} + + +MCEvent::~MCEvent() +{ +#ifdef __GNUC__ + if (FFileObj >= 0) + { + close(FFileObj); + remove(FFileName); + } + MCMemFree(FFileName); +#endif +} + +MCWaitResult MCEvent::WaitFor(unsigned long Timeout) +{ + MCWaitResult Result; +#ifndef __GNUC__ +//$ifndef LINUX + switch(WaitForSingleObject(FHandle, Timeout)) { + case WAIT_ABANDONED: Result = wrAbandoned; break; + case WAIT_OBJECT_0: Result = wrSignaled; break; + case WAIT_TIMEOUT: Result = wrTimeout; break; + case WAIT_FAILED: Result = wrError; break; + default: Result = wrError; break; + } +//$endif +#else + Result = MCSynchroObject::WaitFor(Timeout); + if ((FManualReset) && (Result == wrSignaled)) + setEvent(); +#endif + return(Result); +} + +void MCEvent::setEvent(void) +{ +#ifndef __GNUC__ +//$ifndef LINUX + SetEvent(FHandle); +//$endif +#else + MCSynchroObject::Release(1); +#endif +} + +void MCEvent::resetEvent(void) +{ +#ifndef __GNUC__ +//$ifndef LINUX + ResetEvent(FHandle); +//$endif +#else + while (MCSynchroObject::WaitFor(0) != wrTimeout) {}; +#endif +} + +//-------------- MCCriticalSection -------------- +MCCriticalSection::MCCriticalSection(void) +//:startWaiting(0), sumWaiting(0) +{ +#ifdef _WIN32 +//$ifndef LINUX + InitializeCriticalSection(&FSection); + //count = 0; +//$endif +#else + + if (pthread_mutexattr_init(&FMutexAttr) != 0) + THROW_ERROR(MCError_SynchroObjectFailed); + try { + if (pthread_mutexattr_settype(&FMutexAttr, PTHREAD_MUTEX_RECURSIVE)!=0) + THROW_ERROR(MCError_SynchroObjectFailed); + + pthread_mutex_init(&FMutex, &FMutexAttr); + + } + FINALLY( + pthread_mutexattr_destroy(&FMutexAttr); + ) +#endif +} + +MCCriticalSection::~MCCriticalSection() +{ +#ifdef _WIN32 +//$ifndef LINUX + DeleteCriticalSection(&FSection); + //char buf[128]; + //sprintf(buf, "Waiting time is %d\n", sumWaiting); + //OutputDebugString(buf); +//$endif +#else + pthread_mutex_destroy(&FMutex); +#endif +} + +void MCCriticalSection::Enter(void) +{ + +#ifdef _WIN32 +//$ifndef LINUX + //startWaiting = GetTickCount(); + + EnterCriticalSection(&FSection); + //MCASSERT(count == 0); + //count++; + //sumWaiting += GetTickCount() - startWaiting; +//$endif +#else + pthread_mutex_lock(&FMutex); +#endif +} + +void MCCriticalSection::Leave(void) +{ +#ifdef _WIN32 +//$ifndef LINUX + //count--; + //MCASSERT(count == 0); + LeaveCriticalSection(&FSection); +//$endif +#else + pthread_mutex_unlock(&FMutex); +#endif +} + +/* + +//-------------- MCSemaphore - pthread's version ----- +#ifndef _WIN32 +MCSemaphore::MCSemaphore(void) +:FCount(0) +{ + pthread_cond_init(&FCond, NULL); + pthread_mutex_init(&FMutex, NULL); + +} + +MCSemaphore::~MCSemaphore(void) +{ + pthread_cond_destroy(&FCond); + pthread_mutex_destroy(&FMutex); +} + +void MCSemaphore::Release(void) +{ + pthread_mutex_lock(&FMutex); + FCount++; + pthread_mutex_unlock(&FMutex); + pthread_cond_signal(&FCond); +} + +bool MCSemaphore::Wait(unsigned int TimeOut) +{ + timespec abst; + bool res = false; + + pthread_mutex_lock(&FMutex); + if (FCount > 0) + { + FCount--; + } + else + { + abst.tv_sec = time(NULL) + TimeOut / 1000; + abst.tv_nsec = (TimeOut % 1000) * 1000000; + res = pthread_cond_timedwait(&FCond, &FMutex, &abst) == 0; + } + pthread_mutex_unlock(&FMutex); + return res; +} + +void MCSemaphore::Wait(void) +{ + Wait(0); +} + +#else + +//$ifndef LINUX +MCSemaphore::MCSemaphore(void) +{ + FSemaphore = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL); +} + +MCSemaphore::~MCSemaphore() +{ + if (0 != FSemaphore) + CloseHandle(FSemaphore); +} + +void MCSemaphore::Release(void) +{ + ReleaseSemaphore(FSemaphore, 1, NULL); +} + +void MCSemaphore::Wait(void) +{ + Wait(INFINITE); +} + +bool MCSemaphore::Wait(unsigned int TimeOut) +{ + return WaitForSingleObject(FSemaphore, TimeOut) == WAIT_OBJECT_0; +} + +//$endif +#endif + +*/ + +#ifdef __GNUC__ +#ifndef QNX +MCSemaphore::MCSemaphore(int InitialState, __key_t Id, bool Orig, unsigned long MaxCount) +{ + Initialize(InitialState, Id, Orig, MaxCount); +} +#else +MCSemaphore::MCSemaphore(int InitialState, char* FileName, bool Orig, unsigned long MaxCount) +{ + Initialize(InitialState, FileName, Orig, MaxCount); +} + +#endif +#endif + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCSyncs.h b/libraries/external/eldos/pc/include/MCSyncs.h new file mode 100755 index 0000000..3d37448 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCSyncs.h @@ -0,0 +1,160 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCSYNCS__ +#define __MCSYNCS__ + +#include "MC.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +typedef void* MCHandle; + +typedef enum { + wrSignaled, + wrTimeout, + wrAbandoned, + wrError +} MCWaitResult; + +#ifdef __GNUC__ +#ifndef QNX +# include +# include +# include +#else +# include +# include +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif +# include +typedef sem_t TSemaphore; +#endif + + +class MCSynchroObject { +#ifndef __GNUC__ +//$ifndef LINUX +protected: + MCHandle FHandle; +public: + MCHandle getHandle(void); +//$endif +#else +protected: +#ifndef QNX + __key_t FId; +#else + TSemaphore *sem; +#endif + int FEvent; + int FOrig; + unsigned long FMaxCount; +public: +#ifndef QNX + void Initialize(int InitialState, __key_t Id, bool Orig, unsigned long MaxCount); +#else + void Initialize(int InitialState, char* FileName, bool Orig, unsigned long MaxCount); +#endif + void Release(int Num = 1); +#endif +public: + MCSynchroObject(); + virtual MCWaitResult WaitFor(unsigned long Timeout); + virtual ~MCSynchroObject(); +}; + + +class MCEvent: public MCSynchroObject { +#ifdef __GNUC__ +private: + char* FFileName; + int FFileObj; + bool FManualReset; +public: + void Initialize(void* EventAttributes, bool ManualReset, bool InitialState, bool InitialOwner, const char* Name); +#endif +public: + MCEvent(void* EventAttributes, bool ManualReset, bool InitialState, const char* Name, bool OpenOnly = false); + virtual ~MCEvent(); + virtual MCWaitResult WaitFor(unsigned long Timeout); + void setEvent(void); + void resetEvent(void); +}; + + +#ifdef __GNUC__ +//#define __USE_UNIX98 +#ifndef QNX +#include +#endif +#include +#include +#include + +typedef pthread_mutex_t TRTLCriticalSection; + +long InitializeCriticalSection(TRTLCriticalSection* lpCriticalSection); +long EnterCriticalSection(TRTLCriticalSection* lpCriticalSection); +long LeaveCriticalSection(TRTLCriticalSection* lpCriticalSection); +bool TryEnterCriticalSection(TRTLCriticalSection* lpCriticalSection); +long DeleteCriticalSection(TRTLCriticalSection* lpCriticalSection); + +#else +#include +#ifndef _WIN32_WCE +#include +#endif + +typedef CRITICAL_SECTION TRTLCriticalSection; + +#endif + +class MCCriticalSection +{ +protected: +#ifdef _WIN32 +//$ifndef LINUX + CRITICAL_SECTION FSection; + //int count; +//$endif +#else + pthread_mutex_t FMutex; + pthread_mutexattr_t FMutexAttr; +#endif + //unsigned int startWaiting; + //unsigned int sumWaiting; +public: + MCCriticalSection(void); + ~MCCriticalSection(); + void Enter(void); + void Leave(void); +}; + +#ifdef __GNUC__ +class MCSemaphore : public MCSynchroObject +{ +public: +#ifndef QNX + MCSemaphore(int InitialState, __key_t Id, bool Orig, unsigned long MaxCount = 0xFFFFFFFF); +#else + MCSemaphore(int InitialState, char* FileName, bool Orig, unsigned long MaxCount = 0xFFE); +#endif +}; +#endif + + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCThreads.cpp b/libraries/external/eldos/pc/include/MCThreads.cpp new file mode 100755 index 0000000..ca0ab3e --- /dev/null +++ b/libraries/external/eldos/pc/include/MCThreads.cpp @@ -0,0 +1,1058 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCThreads.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +//#define THREADINFO + +#ifdef __GNUC__ +typedef pthread_cond_t* MCCondVar; +# define InitializeCriticalSection(x) pthread_mutex_init(x, NULL) +# define DeleteCriticalSection(x) pthread_mutex_destroy(x) +# define EnterCriticalSection(x) pthread_mutex_lock(x) +# define LeaveCriticalSection(x) pthread_mutex_unlock(x) +#endif + +typedef struct { + MCThread* Thread; +#ifndef __GNUC__ +//$ifndef LINUX + MCHandle Signal; +//$endif +#else + MCCondVar Signal; +#endif +} MCSyncProc; + +bool ProcPosted; +MCList* SyncList = NULL; +//TRTLCriticalSection ThreadLock; +long ThreadCount; + +void InitializeThreads(void) +{ + //InitializeCriticalSection(&ThreadLock); +} + +#ifdef __GNUC__ +unsigned long GetCurrentThreadID(void) +{ + return(pthread_self()); +} + +#endif + +unsigned long IntGetCurrentThreadID(void) +{ +#ifndef __GNUC__ +//$ifndef LINUX + return (unsigned long)GetCurrentThread(); +//$endif +#else + return getpid(); +#endif +} + +MCHandle GetCurrentThreadHandle(void) +{ + MCHandle DstHandle; +#ifndef __GNUC__ +//$ifndef LINUX +#ifdef _WIN32_WCE + DstHandle = GetCurrentThread(); +#else + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), + GetCurrentProcess(), (void**)&DstHandle, 0, false, DUPLICATE_SAME_ACCESS); +#endif +//$endif +#else + DstHandle = (void*)pthread_self(); +#endif + return(DstHandle); +} + +void AddThread(void) +{ +} + +void RemoveThread(void) +{ +} + +#ifdef __GNUC__ +long ThreadProc(void* p) +#else +//$ifndef LINUX +long __stdcall ThreadProc(void* p) +//$endif +#endif +{ + bool FreeThread = false; + long r = 0; + MCThread* Thread = (MCThread*)p; + Thread->FReturnValue = 0; + //suspend if needed +#ifdef __GNUC__ + if(Thread->FSuspended) + sem_wait(&Thread->FCreateSuspendedSem); +#endif + if(!Thread->getTerminated()) + TRY_BLOCK + { + Thread->Execute(); + } + CATCH_EVERY + { + Thread->FFatalException = NULL; + } + FreeThread = Thread->FFreeOnTerminate; + r = Thread->FReturnValue; + Thread->FFinished = true; + //Thread->DoTerminate(); + if(FreeThread) + delete Thread; + return r; +} + +MCThread::MCThread(bool CreateSuspended, int Priority) +{ +#ifdef __GNUC__ + long ErrCode; + FInitialSuspendDone = false; +#endif + FTerminated = false; + //AddThread(); + FSuspended = CreateSuspended; + FCreateSuspended = CreateSuspended; + FFatalException = NULL; + FThreadName = NULL; +#ifndef __GNUC__ +//$ifndef LINUX + FHandle = (void*)BeginThread(NULL, 0, /*&*/ThreadProc, this, CREATE_SUSPENDED, FThreadID); + if (0 == FHandle) + THROW_ERROR(MCError_ThreadCreateError); + if (-1 != Priority) + SetThreadPriority(FHandle, Priority); +//$endif +#else + sem_init(&FCreateSuspendedSem, false, 0); + ErrCode = BeginThread(NULL, &ThreadProc, this, FThreadID); +#endif + //AfterConstruction(); +} + +MCThread::~MCThread() +{ + + Free(); +} + +void MCThread::Free(void) +{ + if (NULL != FThreadName) + free(FThreadName); + + if((FThreadID != 0) && !FFinished) + { + Terminate(); + if(FCreateSuspended) + Resume(); + WaitFor(); + } +#ifndef __GNUC__ +//$ifndef LINUX + if(FHandle != 0) + { + CloseHandle(FHandle); + } +//$endif +#else + // This final check is to ensure that even if the thread was never waited on + // its resources will be freed. + if(FThreadID != 0) + pthread_detach(FThreadID); + sem_destroy(&FCreateSuspendedSem); +#endif + if(FFatalException) + delete FFatalException; + RemoveThread(); +} + +long MCThread::getReturnValue(void) +{ + return FReturnValue; +} + +void MCThread::setReturnValue(long value) +{ + FReturnValue = value; +} + +bool MCThread::getTerminated(void) +{ + return FTerminated; +} + +EMCError* MCThread::getFatalException(void) +{ + return FFatalException; +} + +bool MCThread::getFreeOnTerminate(void) +{ + return FFreeOnTerminate; +} + +void MCThread::setFreeOnTerminate(bool value) +{ + FFreeOnTerminate = value; +} + +MCHandle MCThread::getHandle(void) +{ + return FHandle; +} + +bool MCThread::getSuspended(void) +{ + return FSuspended; +} + +void MCThread::setThreadName(const char* threadName) +{ + if (NULL != FThreadName) + { + free(FThreadName); + FThreadName = NULL; + } + if (NULL != threadName) + { + FThreadName = (char*)malloc(strlen(threadName)+1); + strcpy(FThreadName, threadName); + } +} + +const char* MCThread::getThreadName(void) +{ + return FThreadName; +} + +#ifndef __GNUC__ +//$ifndef LINUX +unsigned +//$endif +#else +unsigned long +#endif +MCThread::getThreadID(void) +{ + return FThreadID; +} + +/* +MCThreadProc MCThread::getOnTerminate(void) +{ + return(FOnTerminate); +} + +void MCThread::setOnTerminate(MCThreadProc value) +{ + FOnTerminate = value; +} +*/ + +void MCThread::AfterConstruction(void) +{ + if(!FCreateSuspended) + Resume(); +} + +void MCThread::CheckThreadError(long ErrCode) +{ + if(ErrCode != 0) + THROW_ERROR(ErrCode); +} + +void MCThread::CheckThreadError(bool Success) +{ + if(!Success) + CheckThreadError((long)MCError_ThreadError); +} + +/* +void MCThread::CallOnTerminate(void) +{ + if(FOnTerminate) + FOnTerminate(NULL,this); +} + +void MCThread::DoTerminate(void) +{ +} +*/ + +#ifndef __GNUC__ +//$ifndef LINUX + +const long Priorities[tpTimeCritical+1] = { THREAD_PRIORITY_IDLE, + THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_BELOW_NORMAL, + THREAD_PRIORITY_NORMAL, THREAD_PRIORITY_ABOVE_NORMAL, + THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL + }; + +MCThreadPriority MCThread::getPriority(void) +{ +// MCThreadPriority i,r; + int i,r; + + long p = GetThreadPriority(FHandle); + CheckThreadError(p != THREAD_PRIORITY_ERROR_RETURN); + r = tpNormal; + for(i = tpIdle;i <= tpTimeCritical; i++) + if(Priorities[i] == p) + r = i; + return((MCThreadPriority)r); +} + +void MCThread::setPriority(MCThreadPriority Value) +{ + CheckThreadError(0 != SetThreadPriority(FHandle, Priorities[Value])); +} +//$endif +#else +long MCThread::getPriority(void) +{ + int p; + sched_param j; + + /* + Linux Priority is based on the Schedule policy. + There are 3 different kinds of policy. See SetPolicy. + + Policy Type Priority + ---------- -------- -------- + SCHED_RR RealTime 0-99 + SCHED_FIFO RealTime 0-99 + SCHED_OTHER Regular 0 + + SCHED_RR and SCHED_FIFO can only be set by root. + */ + CheckThreadError((long)pthread_getschedparam(FThreadID, &p, &j)); + return(j.sched_priority); +} + +/* + Note that to fully utilize Linux Scheduling, see SetPolicy. +*/ + +void MCThread::setPriority(long Value) +{ + sched_param p; + + if(Value != getPriority()) + { + p.sched_priority = Value; + CheckThreadError((long)pthread_setschedparam(FThreadID, getPolicy(), &p)); + } +} + +long MCThread::getPolicy(void) +{ + sched_param j; + int p; + + CheckThreadError((long)pthread_getschedparam(FThreadID, &p, &j)); + return(p); +} + +/* + Note that to fully utilize Linux Scheduling, SetPolicy needs to + be used as well. See SetPriority for the relationship between these + methods. +*/ + +void MCThread::setPolicy(long Value) +{ + sched_param p; + + if(Value != getPolicy()) + { + p.sched_priority = getPriority(); + CheckThreadError((long)pthread_setschedparam(FThreadID, Value, &p)); + } +} +#endif + + +void MCThread::setSuspended(bool Value) +{ + if(Value != FSuspended) + if(Value) + Suspend(); + else + Resume(); +} + +#ifndef __GNUC__ +//$ifndef LINUX +void MCThread::Suspend(void) +{ + FSuspended = true; + DWORD resCode = SuspendThread(FHandle); + resCode = resCode != 0 ? GetLastError() : 0; + CheckThreadError((long)resCode > 0); +} + +void MCThread::Resume(void) +{ + long SuspendCount; + + SuspendCount = ResumeThread(FHandle); + CheckThreadError(SuspendCount >= 0); + if(SuspendCount == 1) + FSuspended = false; +} +//$endif +#else +/* + About Suspend and Resume. POSIX does not support suspending/resuming a thread. + Suspending a thread is considerd dangerous since it is not guaranteed where the + thread would be suspend. It might be holding a lock, mutex or it might be inside + a critical section. In order to simulate it in Linux we've used signals. To + suspend, a thread SIGSTOP is sent and to resume, SIGCONT is sent. Note that this + is Linux only i.e. according to POSIX if a thread receives SIGSTOP then the + entire process is stopped. However Linux doesn't entirely exhibit the POSIX-mandated + behaviour. If and when it fully complies with the POSIX standard then suspend + and resume won't work. +*/ + +void MCThread::Suspend(void) +{ + FSuspended = true; + CheckThreadError((long)pthread_kill(FThreadID, SIGSTOP)); +} + +void MCThread::Resume(void) +{ + if(!FInitialSuspendDone) + { + FInitialSuspendDone = true; + sem_post(&FCreateSuspendedSem); + } else + CheckThreadError((long)pthread_kill(FThreadID, SIGCONT)); + FSuspended = false; +} +#endif + +void MCThread::Terminate(void) +{ + FTerminated = true; +} + +unsigned long MCThread::WaitFor(void) +#ifndef __GNUC__ +//$ifndef LINUX +{ + unsigned long r = 0; + WaitForSingleObject(FHandle, INFINITE); + return r; +} +//$endif +#else +{ + void* x; + unsigned long ID = FThreadID, r = 0; + + if(GetCurrentThreadID() == MCMainThreadID) + while(!FFinished) + { + sleep(10); + //CheckSynchronize(); + } + FThreadID = 0; + x = &r; + if (pthread_join(ID, &x) == 0) + return(r); + else + return 0; +} +#endif + +#ifndef __GNUC__ +//$ifndef LINUX +int BeginThread(void* SecurityAttributes, unsigned StackSize, MCThreadFunc + ThreadFunc, void* Parameter, unsigned CreationFlags, unsigned &ThreadId) +{ + return((int)CreateThread((_SECURITY_ATTRIBUTES*)SecurityAttributes, StackSize, + (LPTHREAD_START_ROUTINE)ThreadFunc, Parameter, CreationFlags, (unsigned long*)&ThreadId)); +} + + +void EndThread(int ExitCode) +{ + ExitThread(ExitCode); +} +//$endif +#else + + +int BeginThread(pthread_attr_t* SecurityAttributes, MCThreadFunc ThreadFunc, + void* Parameter, unsigned long &ThreadId) +{ +// if(BeginThreadProc) +// return(BeginThreadProc(Attribute, ThreadFunc, Parameter, ThreadId)) +// else + return(pthread_create((pthread_t*)&ThreadId, SecurityAttributes, (void *(*) (void *))ThreadFunc, Parameter)); +} + +void EndThread(int ExitCode) +{ +// pthread_detach(GetCurrentThreadID); + pthread_exit((void*)ExitCode); +} +#endif + + +// ----------------MCThreadPool ------------------------------- + +MCThreadJob::MCThreadJob(void) +:FThread(NULL) +, FJobName(NULL) +#ifdef _TESTPOOL +, FJobRunning(NULL) +#endif +{ + +} + +MCThreadJob::~MCThreadJob() +{ + if (NULL != FJobName) + free(FJobName); +} + +bool MCThreadJob::getTerminated(void) +{ + return FThread->getTerminated(); +} + +void MCThreadJob::setJobName(const char* jobName) +{ + if (NULL != FJobName) + { + free(FJobName); + FJobName = NULL; + } + if (NULL != jobName) + { + FJobName = (char*)malloc(strlen(jobName)+1); + strcpy(FJobName, jobName); + } +} + +const char* MCThreadJob::getJobName(void) +{ + return FJobName; +} + +#ifdef _TESTPOOL +void MCThreadJob::setJobRunning(HANDLE handle) +{ + FJobRunning = handle; +} + +HANDLE MCThreadJob::getJobRunning(void) +{ + return FJobRunning; +} +#endif + +//--------------- MCThreadPool ------------ + +MCThreadPool::MCThreadPool(MCThreadFactory* Factory, MCJobErrorHandler* ErrorHandler) +:FSize(0), FFactory(Factory), FErrorHandler(ErrorHandler), +FInactivityIdle(5000), FMaxSize(0), FJobsRan(0), FBusyCount(0) +{ + +#ifndef _WIN32 + pthread_mutex_init(&FGuard, NULL); + pthread_cond_init(&FNonEmpty, NULL); +#else +//$ifndef LINUX +#ifndef _TESTPOOL + InitializeCriticalSection(&FGuard); +#endif + FNonEmpty = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL); +//$endif +#endif +} + +MCThreadPool::~MCThreadPool() +{ + TRY_BLOCK + { + Clear(); + } + CATCH_EVERY + { + } +#ifndef _WIN32 + pthread_cond_destroy(&FNonEmpty); + pthread_mutex_destroy(&FGuard); +#else +//$ifndef LINUX + //OutputDebugString("Closing FNonEmpty handle\n"); + CloseHandle(FNonEmpty); + DeleteCriticalSection(&FGuard); +//$endif +#endif +} + +#ifdef _TESTPOOL + +void MCThreadPool::PostJob(MCThreadJob* Job) +{ + bool assigned = false; HANDLE runningSignal = NULL; + FGuard.Enter(); + while (!assigned) + { + //seek for free thread + bool thrExited = false; + if (FRestThreads.Length() > 0) + { + MCWorkerThread* thr = (MCWorkerThread*)FRestThreads[0]; + FRestThreads.Del((long)0); + thr->FJob = Job; + thr->FThrExit = &thrExited; + runningSignal = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL); + thr->FJob->setJobRunning(runningSignal); + ReleaseSemaphore(thr->FJobAssigned, 1, NULL); + FGuard.Leave(); + + assigned = WaitForSingleObject(runningSignal, 5000) != WAIT_TIMEOUT; + FGuard.Enter(); + assigned = false == thrExited; + } + else + {//create new thread + MCWorkerThread* Thread = FFactory->CreateThread(); + //OutputDebugString(TEXT("New worker thread is created\n")); + Thread->FJob = Job; + Thread->FThrExit = NULL; + Thread->Resume(); + assigned = true; + } + } + FGuard.Leave(); + //LeaveCriticalSection(&FGuard); +} + +#else + +void MCThreadPool::PostJob(MCThreadJob* Job) +{ +#ifndef _WIN32 + pthread_mutex_lock(&FGuard); +#else +//$ifndef LINUX + EnterCriticalSection(&FGuard); +//$endif +#endif + bool notCreate = false; + + //iterate all threads and look for waiting worker thread + + //There is possible free threads + int thrAvail = FThreadList.Length() - FBusyCount - FJobList.Length(); + + if (thrAvail > 0) + notCreate = true; + if (false == notCreate) + { + if ((FMaxSize > (unsigned int)FThreadList.Length()) || (0 == FMaxSize)) + {//there is some slots for new threads + MCWorkerThread* Thread = FFactory->CreateThread(); + FThreadList.Add(Thread); + //OutputDebugString(TEXT("New worker thread is created\n")); + Thread->Resume(); + } + else + notCreate = true; + } +// if (notCreate) +// OutputDebugString(TEXT("There is no need to create yet another thread\n")); + + FJobList.Add(Job); + +#ifndef _WIN32 + pthread_mutex_unlock(&FGuard); + pthread_cond_signal(&FNonEmpty); +#else +//$ifndef LINUX + ReleaseSemaphore(FNonEmpty, 1, NULL); + LeaveCriticalSection(&FGuard); +//$endif +#endif + +} + +#endif + +unsigned int MCThreadPool::getSize(void) +{ + return FSize; +} + +void MCThreadPool::setSize(unsigned int Size) +{ + FSize = Size; +} + +unsigned int MCThreadPool::getMaxSize(void) +{ + return FMaxSize; +} + +void MCThreadPool::setMaxSize(unsigned int size) +{ + FMaxSize = size; +} + +unsigned int MCThreadPool::getInactivityIdle(void) +{ + return FInactivityIdle; +} + +void MCThreadPool::setInactivityIdle(unsigned int Idle) +{ + FInactivityIdle = Idle; +} + +#ifdef _TESTPOOL + +void MCThreadPool::Clear(void) +{ + FGuard.Enter(); + volatile int ThrLen = 0; + ThrLen = FBusyThreads.Length(); + int i = 0; + for (i = 0; iTerminate(); + } + for (i = 0; iKickThread(false); + } + FGuard.Leave(); +} + +#else + + +void MCThreadPool::Clear(void) +{ + volatile unsigned int ThrLen = 0; +#ifdef _WIN32 +//$ifndef LINUX + EnterCriticalSection(&FGuard); +//$endif +#else + pthread_mutex_lock(&FGuard); +#endif + FJobList.DeleteAll(); + unsigned int i = 0; + unsigned int ThrCount = FThreadList.Length(); + + for (i=0; iTerminate(); +#ifdef _WIN32 +//$ifndef LINUX + for (i=0; iFJob == Job) + { + Thread = (MCWorkerThread*)FThreadList[i]; + break; + } + } + if (Thread != NULL) + { + Thread->Terminate(); + Thread->KickThread(false); +#ifdef _WIN32 +//$ifndef LINUX + ReleaseSemaphore(FNonEmpty, 1, NULL); +//$endif +#else + pthread_cond_signal(&FNonEmpty); +#endif + } +#ifdef _WIN32 +//$ifndef LINUX + LeaveCriticalSection(&FGuard); +//$endif +#else + pthread_mutex_unlock(&FGuard); +#endif + if (Thread != NULL) + { + Thread->WaitFor(); + FJobList.Del(Job); + } +} + +unsigned int MCThreadPool::getJobsRan(void) +{ + return FJobsRan; +} + +void MCThreadPool::setJobsRan(unsigned int jobsRan) +{ + FJobsRan = jobsRan; +} + +unsigned int MCThreadPool::getBusyCount(void) +{ + return FBusyCount; +} + +//----------------- MCWorkerThread ------------ +MCWorkerThread::MCWorkerThread(MCThreadPool* Pool, int Priority) +:MCThread(true, Priority), FPool(Pool), FJob(NULL) +{ + FFreeOnTerminate = true; +} + +MCWorkerThread::~MCWorkerThread() +{ + FFreeOnTerminate = true; + ; +} + + +#ifdef _WIN32 + +//$ifndef LINUX + +#ifdef ENABLE_SEH2CPP +#include +void SEHTranslator(unsigned int u, PEXCEPTION_POINTERS pExp) +{ + throw EMCError(MCError_SEHRaised, u, pExp); +} +#endif + +void MCWorkerThread::Execute(void) +{ + bool timeout = false, noJob = false; +#ifdef ENABLE_SEH2CPP +#if _MSC_VER > 600 + _set_se_translator(SEHTranslator); +#endif +#endif + + while (getTerminated() == false) + { + TRY_BLOCK + { + timeout = false; noJob = false; + timeout = WaitForSingleObject(FPool->FNonEmpty, FPool->FInactivityIdle) == WAIT_TIMEOUT; + if (false == timeout) + { + EnterCriticalSection(&FPool->FGuard); + + if ((FPool->FJobList.Length() != 0) && (false == getTerminated())) + {//well, we have a job for thread! + + FPool->FBusyCount++; + FJob = (MCThreadJob*)FPool->FJobList[0]; + FPool->FJobList.Del((long)0); + FPool->FJobsRan++; + LeaveCriticalSection(&FPool->FGuard); +#ifdef THREADINFO + //char buf[128]; +#endif + + TRY_BLOCK + { + FJob->FThread = this; + FJob->Run(); + } +#if defined(USE_CPPEXCEPTIONS) + catch(EMCError& error) + { + if (NULL != FPool->FErrorHandler) + FPool->FErrorHandler->HandleError(error); + } + catch(...) + { + } +#else + __except(1) + { + if (NULL != FPool->FErrorHandler) + FPool->FErrorHandler->HandleError(GetExceptionCode()); + } +#endif + EnterCriticalSection(&FPool->FGuard); + if (FPool->FBusyCount > 0) + FPool->FBusyCount--; + LeaveCriticalSection(&FPool->FGuard); + delete FJob; FJob = NULL; + } + else + { + LeaveCriticalSection(&FPool->FGuard); + noJob = true; + } + } + if (timeout || noJob) + { + EnterCriticalSection(&FPool->FGuard); + //toExit = FPool->FJobList.Length() == 0; + bool toExit = (FPool->FSize < (unsigned int)FPool->FThreadList.Length()) || getTerminated(); + LeaveCriticalSection(&FPool->FGuard); + if (true == toExit) + this->Terminate(); + else + continue; + } + } + CATCH_EVERY + { + + } + } +#ifdef THREADINFO + //OutputDebugString(TEXT("Thread exits\n")); +#endif + delete FJob; FJob = NULL; + EnterCriticalSection(&FPool->FGuard); + FPool->FThreadList.Del(this); + LeaveCriticalSection(&FPool->FGuard); +} + +//$endif +#else + + +void MCWorkerThread::Execute(void) +{ + bool timeout = false; + + while (getTerminated() == false) + { + TRY_BLOCK + { + //FGuard.Enter(); + pthread_mutex_lock(&FPool->FGuard); + if (FPool->FJobList.Length() == 0) + {//wait for the job + timespec abst; + abst.tv_sec = time(NULL) + FPool->FInactivityIdle; + abst.tv_nsec = 0; + pthread_cond_timedwait(&FPool->FNonEmpty, &FPool->FGuard, &abst); + } + //ok, should we add itself to the thread's list? + if (FPool->FThreadList.Find(this) < 0) + FPool->FThreadList.Add(this); + + if ((FPool->FJobList.Length() != 0) && (false == getTerminated())) + {//well, we have a job for thread! + + FJob = (MCThreadJob*)FPool->FJobList[0]; + FPool->FJobList.Del(FJob); + FPool->FBusyCount++; + FPool->FJobsRan++; + pthread_mutex_unlock(&FPool->FGuard); + TRY_BLOCK + { + //FGuard.Leave(); + FJob->FThread = this; + FJob->Run(); + } + CATCH_EVERY + { + + } + + pthread_mutex_lock(&FPool->FGuard); + if (FPool->FBusyCount > 0) + FPool->FBusyCount--; + pthread_mutex_unlock(&FPool->FGuard); + delete FJob; FJob = NULL; + } + else + { + //inactivity idle happens or time to terminate :( + bool toExit = (FPool->FSize < (unsigned int)FPool->FThreadList.Length()) || getTerminated(); + pthread_mutex_unlock(&FPool->FGuard); + if (true == toExit) + this->Terminate(); + else + continue; + } + } + CATCH_EVERY + { + + } + } + delete FJob; FJob = NULL; + pthread_mutex_lock(&FPool->FGuard); + FPool->FThreadList.Del(this); + pthread_mutex_unlock(&FPool->FGuard); + +} + +#endif + +void MCWorkerThread::Terminate(void) +{ + MCThread::Terminate(); +} + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCThreads.h b/libraries/external/eldos/pc/include/MCThreads.h new file mode 100755 index 0000000..b4819d1 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCThreads.h @@ -0,0 +1,256 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCTHREADS__ +#define __MCTHREADS__ + +#include "MC.h" +#include "MCUtils.h" +#include "MCSyncs.h" +#include "MCLists.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + + +DWORD IntGetCurrentThreadID(void); +MCHandle GetCurrentThreadHandle(void); + +class EMCThread: public EMCError { +public: + EMCThread(long l):EMCError(l) {} +}; + +typedef void(*MCThreadMethod)(void* resv); +typedef void(*MCThreadProc)(void *resv, void *sender); + +#ifdef _WIN32 +typedef enum {tpIdle = 0, tpLowest, tpLower, tpNormal, tpHigher, tpHighest, + tpTimeCritical} MCThreadPriority; +#endif + +class MCThread : public MCObject { +private: + MCHandle FHandle; +public: +#ifndef __GNUC__ + unsigned FThreadID; +#else + // ** FThreadID is not TMCHandle in Linux ** + unsigned long FThreadID; + TSemaphore FCreateSuspendedSem; + bool FInitialSuspendDone; +#endif +protected: +//friend long ThreadProc(MCThread* Thread); +//friend int __fastcall ThreadProc(void* p); +#ifdef __GNUC__ +friend long ThreadProc(void* p); +#else +//$ifndef LINUX +friend long __stdcall ThreadProc(void* p); +//$endif +#endif + bool FCreateSuspended; + bool FTerminated; + bool FSuspended; + bool FFreeOnTerminate; + bool FFinished; + long FReturnValue; + MCThreadProc FOnTerminate; + MCThreadMethod FMethod; + EMCError* FSynchronizeException; + EMCError* FFatalException; + char* FThreadName; + + void CheckThreadError(long ErrCode); + void CheckThreadError(bool Success); + +protected: + virtual void Free(void); + virtual void Execute(void) = 0; + long getReturnValue(void); + void setReturnValue(long value); +public: + MCThread(bool CreateSuspended, int Priority = -1); + virtual ~MCThread(); + + virtual void AfterConstruction(void); + bool getTerminated(void); + void Resume(void); + void Suspend(void); + virtual void Terminate(void); + unsigned long WaitFor(void); + EMCError* getFatalException(void); + bool getFreeOnTerminate(void); + void setFreeOnTerminate(bool value); + MCHandle getHandle(void); + void setThreadName(const char* threadName); + const char* getThreadName(void); +#ifndef __GNUC__ +//$ifndef LINUX + MCThreadPriority getPriority(void); + void setPriority(MCThreadPriority Value); + unsigned getThreadID(void); +//$endif +#else + // ** Priority is an Integer value in Linux + long getPriority(void); + void setPriority(long Value); + long getPolicy(void); + void setPolicy(long Value); + unsigned long getThreadID(void); +#endif + bool getSuspended(void); + void setSuspended(bool Value); +}; + +//typedef int __fastcall (*MCThreadFunc)(void* Parameter); +#ifndef __GNUC__ +//$ifndef LINUX +typedef long (__stdcall *MCThreadFunc)(void*); +//$endif +#else +typedef long (*MCThreadFunc)(void*); +#endif + +typedef struct sThreadRec { + MCThreadFunc Func; + void* Parameter; +} ThreadRec; + +#ifndef __GNUC__ +//$ifndef LINUX +int BeginThread(void* SecurityAttributes, unsigned StackSize, MCThreadFunc + ThreadFunc, void* Parameter, unsigned CreationFlags, unsigned &ThreadId); +void EndThread(int ExitCode); +//$endif +#else + +unsigned long GetCurrentThreadID(void); +int BeginThread(pthread_attr_t* SecurityAttributes, MCThreadFunc ThreadFunc, + void* Parameter, unsigned long &ThreadId); +void EndThread(int ExitCode); + +#endif + +void InitializeThreads(void); + +//----------- Thread pool interface declaration ------ +//#define THREADINFO + +class MCWorkerThread; + +class MCThreadFactory +{ +public: + virtual MCWorkerThread* CreateThread(void) = 0; +}; + +class MCJobErrorHandler +{ +public: +#ifdef USE_CPPEXCEPTIONS + virtual void HandleError(const EMCError& Error) = 0; +#else + virtual void HandleError(unsigned int ErrorCode) = 0; +#endif +}; + + +class MCThreadJob +{ +friend class MCWorkerThread; +protected: + MCWorkerThread* FThread; + char* FJobName; + +public: + MCThreadJob(void); + virtual ~MCThreadJob(); + virtual void Run(void) = 0; + bool getTerminated(void); + void setJobName(const char* jobName); + const char* getJobName(void); +}; + + +class MCThreadPool; + +class MCWorkerThread: public MCThread +{ +friend class MCThreadPool; +protected: + MCThreadPool* FPool; + MCCriticalSection FGuard; + MCThreadJob* FJob; + virtual void KickThread(bool MessageFlag) {}; +public: + MCWorkerThread(MCThreadPool* Pool, int Priority = -1); + virtual ~MCWorkerThread(); + virtual void Execute(void); + virtual void Terminate(void); +}; + + +class MCThreadPool +{ +friend class MCWorkerThread; +protected: + unsigned int FSize; + unsigned int FMaxSize; + MCList FThreadList; + MCList FJobList; + unsigned int FJobsRan; + +#ifndef _WIN32 + pthread_mutex_t FGuard; + pthread_cond_t FNonEmpty; +#else +//$ifndef LINUX + CRITICAL_SECTION FGuard; + HANDLE FNonEmpty; +//$endif +#endif + MCThreadFactory* FFactory; + MCJobErrorHandler* FErrorHandler; + unsigned int FBusyCount; + unsigned int FInactivityIdle; +public: + MCThreadPool(MCThreadFactory* Factory, MCJobErrorHandler* ErrorHandler); + virtual ~MCThreadPool(); + + void PostJob(MCThreadJob* Job); + void FinalizeJob(MCThreadJob* Job); + void Clear(void); + + unsigned int + getSize(void); + void setSize(unsigned int size); + unsigned int + getMaxSize(void); + void setMaxSize(unsigned int size); + unsigned int + getInactivityIdle(void); + void setInactivityIdle(unsigned int Idle); + unsigned int + getJobsRan(void); + void setJobsRan(unsigned int jobsRan); + unsigned int + getBusyCount(void); +}; + + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCUDPSocket.cpp b/libraries/external/eldos/pc/include/MCUDPSocket.cpp new file mode 100755 index 0000000..797361e --- /dev/null +++ b/libraries/external/eldos/pc/include/MCUDPSocket.cpp @@ -0,0 +1,1475 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +//#include "MC.h" +#include "MCUtils.h" +#include "MCUDPSocket.h" +#ifndef _WIN32_WCE +#include +#endif + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +static char * mcstrtok(const char *strToken, const char*strDelim) +{ + if (!strDelim || *strDelim == 0) + return NULL; + + char *result = (char *) strToken; + if (strDelim[1] == 0) + { + while ((*result != 0) && (*result != *strDelim)) + { + result ++; + } + if (*result == 0) + return NULL; + else + return result; + } + else + { + while ((*result != 0)) + { + if (strchr(strDelim, *result) != NULL) + break; + else + result++; + } + if (*result == 0) + return NULL; + else + return result; + } +} + +MCUDPTransport::MCUDPTransport(): MCSimpleTransport() +{ + FDefaultTransportName = "UDP"; + FMessengerPort = 1459; + FFailOnInactive = false; + FMessengerAddress = (char*) MCMemAlloc(strlen("0.0.0.0") + 1); + strcpy(FMessengerAddress, "0.0.0.0"); + FTransportMode = (MCInetTransportMode)0; + FReceiverThread = NULL; + FSenderThread = NULL; + FMulticastList = new MCStringList(); +//$ifdef MC_COMMERCIAL + FRoutingAllowed = false; +//$endif MC_COMMERCIAL + FReuseServerPort = true; +} + +MCUDPTransport::~MCUDPTransport() +{ + setActive(false); + + if (NULL != FMulticastList) + delete(FMulticastList); + + if (NULL != FMessengerAddress) + { + free(FMessengerAddress); + FMessengerAddress = NULL; + } +} + +void MCUDPTransport::setFailOnInactive(bool Value) +{ + if(FFailOnInactive != Value) + FFailOnInactive = Value; +} + +bool MCUDPTransport::getFailOnInactive(void) +{ + return FFailOnInactive; +} + +void MCUDPTransport::setMessengerAddress(char* Value) +{ + bool b; + unsigned long i; + + if(!FMessengerAddress && !Value) + return; + if(!FMessengerAddress || !Value || (strcmp(FMessengerAddress, Value) != 0)) + { + if(FMessengerAddress) + MCMemFree(FMessengerAddress); + b = getActive(); + setActive(false); + if(Value && strcmp(Value, "255.255.255.255") != 0) + { + i = inet_addr(Value); + if(i == INADDR_NONE) + THROW_ERROR(MCError_InvalidAddress); + } + FMessengerAddress = Value; + setActive(b); + } +} + +char* MCUDPTransport::getMessengerAddress(void) +{ + return FMessengerAddress; +} + +void MCUDPTransport::setMessengerPort(unsigned Value) +{ + bool b; + + if(FMessengerPort != Value) + { + b = getActive(); + setActive(false); + FMessengerPort = Value; + setActive(b); + } +} + +unsigned MCUDPTransport::getMessengerPort(void) +{ + return FMessengerPort; +} + +unsigned MCUDPTransport::getMessengerPortBound(void) +{ + if (getActive() == false || FReceiverThread == NULL) + return 0; + else + return FReceiverThread->FRecvSocket->getLocalPort(); +} + +void MCUDPTransport::setReuseServerPort(bool Value) +{ + FReuseServerPort = Value; +} + +bool MCUDPTransport::getReuseServerPort(void) +{ + return FReuseServerPort; +} + +void MCUDPTransport::setTransportMode(MCInetTransportMode Value) +{ + FTransportMode = Value; + if(getActive()) + { + setActive(false); + FTransportMode = Value; + setActive(true); + } + else + FTransportMode = Value; +} + +MCInetTransportMode MCUDPTransport::getTransportMode(void) +{ + return(FTransportMode); +} + +//$ifdef MC_COMMERCIAL +void MCUDPTransport::setRoutingAllowed(bool Value) +{ + FRoutingAllowed = Value; +} + +bool MCUDPTransport::getRoutingAllowed(void) +{ + return FRoutingAllowed; +} +//$endif MC_COMMERCIAL + +MCUDPSenderThread* MCUDPTransport::CreateSenderThread(bool x) +{ + return new MCUDPSenderThread(x); +} + +MCUDPReceiverThread* MCUDPTransport::CreateReceiverThread(bool x) +{ + return new MCUDPReceiverThread(x); +} + +bool MCUDPTransport::DeliverMessage(char* DestAddress, MCMessageInfo* Info) +{ + //FLogger->PutMessage(llTrivial, "DeliverMessage is started.\n", 0, "MCInetTransport::DeliverMessage"); + bool r; + + char *p = NULL, *p1 = NULL; + char *SocketName = NULL, *QueueName = NULL, *URLName = NULL; + + if(int(FTransportMode) != stmP2P && int(FTransportMode) != stmClient) + return(false); + + if(DestAddress && AddressValid(DestAddress)) + { + Info->Transport = this; + + // extract names + if(!strchr(DestAddress, '|')) + THROW_ERROR(MCError_BadDestinationName); + p = p1 = DestAddress; + while((*p != '|') && (*p != '/') && *p) + p++; + if(!*p) + THROW_ERROR(MCError_BadDestinationName); + + // get ID/socket name + if(p - p1 > 0) + SocketName = strCopy(p1, 0, p - p1); + else + THROW_ERROR(MCError_BadDestinationName); + + //get URL name + p1 = p; + while ((*p != '|') && *p) + p++; + if (!*p) + THROW_ERROR(MCError_BadDestinationName); // there is no queue name + + if (*p == '|') + URLName = strCopy(p1, 0, p - p1); + else + THROW_ERROR(MCError_BadDestinationName); + p++; + + // get queue name + p1 = p; + while(*p) + p++; + if(p - p1 > 0) + QueueName = strCopy(p1, 0, p - p1); + else + THROW_ERROR(MCError_BadDestinationName); + +//$ifdef MC_COMMERCIAL + p1 = QueueName; + p = p1; + p += strlen(QueueName); + while (p != p1) + { + if (*p == '|') + { + if (Info->RouteTo) + MCMemFree(Info->RouteTo); + Info->RouteTo = strCopy(QueueName, 0, p - p1); + p++; + + char* tmpQ = (char*)MCMemAlloc(strlen(p) + 1); + strcpy(tmpQ, p); + MCMemFree(QueueName); + QueueName = tmpQ; +// QueueName := Copy(DestAddress, Length(DestAddress) - Length(QueueName) + (p - p1 + 1), Length(QueueName)); + break; + } + p--; + } +//$endif MC_COMMERCIAL + // set MessageInfo properties + strncpy(Info->DQueue, QueueName, DQueueMaxLength - 1); + Info->DQueue[DQueueMaxLength - 1] = 0; + Info->DMessenger = SocketName; + Info->URL = URLName; + Info->State = imsDispatching; +// MCMemFree(QueueName); QueueName = NULL; + FCriticalSection->Enter(); + TRY_BLOCK { + InsertInfoIntoQueueWithPriorities(FOutgoingQueue, Info, false); + FSenderThread->KickThread(true); + } FINALLY ( + FCriticalSection->Leave(); + ) + r = true; + } + else + r = false; + MCMemFree(QueueName); QueueName = NULL; + return r; +} + +void MCUDPTransport::DoSetActive(void) +{ + bool initFailed = false; + + if(!FMessenger) + return; + + if(getActive()) + { + FSenderThread = NULL; + + if((getTransportMode() == stmP2P) || (getTransportMode() == stmServer)) + { + FReceiverThread = new MCUDPReceiverThread(true); + TRY_BLOCK + { + FReceiverThread->Initialize(this); + } + CATCH_EVERY + { + delete FReceiverThread; FReceiverThread = NULL; + initFailed = true; + } + if (true == initFailed) +#ifndef USE_CPPEXCEPTIONS + RaiseException(1, 0, 0, NULL); +#else + throw EMCError(0); +#endif + FReceiverThread->setFreeOnTerminate(false); + } + + if((getTransportMode() == stmP2P) || (getTransportMode() == stmClient)) + { + FSenderThread = new MCUDPSenderThread(true); + TRY_BLOCK + { + FSenderThread->Initialize(this); + } + CATCH_EVERY + { + delete FSenderThread; FSenderThread = NULL; + delete FReceiverThread; FReceiverThread = NULL; + initFailed = true; + } + if (true == initFailed) +#ifndef USE_CPPEXCEPTIONS + RaiseException(1, 0, 0, NULL); +#else + throw EMCError(0); +#endif + FSenderThread->setFreeOnTerminate(false); + } + if((getTransportMode() == stmP2P) || (getTransportMode() == stmServer)) + FReceiverThread->Resume(); + if((getTransportMode() == stmP2P) || (getTransportMode() == stmClient)) + FSenderThread->Resume(); + } + else + { + if (NULL != FSenderThread) + { + FSenderThread->Terminate(); + FSenderThread->KickThread(false); +// FSenderThread->FStopEvent->setEvent(); +#ifdef __GNUC__ + FSenderThread->WaitFor(); +#else + WaitForSingleObject(FSenderThread->getHandle(), INFINITE); +#endif + } + if (NULL != FReceiverThread) + { + FReceiverThread->Terminate(); + FReceiverThread->KickThread(false); +// FReceiverThread->FStopEvent->setEvent(); +#ifdef __GNUC__ + FReceiverThread->WaitFor(); +#else + WaitForSingleObject(FReceiverThread->getHandle(), INFINITE); +#endif + } + + delete FSenderThread; FSenderThread = NULL; + delete FReceiverThread; FReceiverThread = NULL; + + if (FOutgoingQueue != NULL) + { + while (FOutgoingQueue->Length() > 0) + { + CancelMessageByID(((MCMessageInfo*)(*FOutgoingQueue)[0])->Message.MsgID, MCError_Shutdown); + } + } + } +} + +void MCUDPTransport::KickSender(bool MessageFlag) +{ + if (FSenderThread != NULL) + FSenderThread->KickThread(MessageFlag); + +} + +void MCUDPTransport::CancelMessageInSender(MCMessageInfo* Info) +{ + if(FSenderThread) + FSenderThread->FCancelID = Info->Message.MsgID; +} + +bool MCUDPTransport::WasCancelled(MCMessageInfo* Info) +{ + return (FSenderThread && (FSenderThread->FCancelID == Info->Message.MsgID)); +} + +void MCUDPTransport::SetInfoSMessenger(MCMessageInfo* Info) +{ + if(FSenderThread) + { + char pt[128]; + sprintf(pt, "%s:%d", FSenderThread->FSendSocket->getLocalAddress(), getMessengerPort()); + Info->setSMessenger(pt); + } + else + Info->SMessenger = NULL; +} + +long MCUDPTransport::FindMulticastAddress(const char* Value) +{ + char *val = NULL; + long result = -1; + for (int i = 0; i < FMulticastList->Length(); i++) + { + val = (char *) ((*FMulticastList)[i]); + if (strncmp(Value, val, strlen(Value)) == 0) + { + result = i; + break; + } + } + return result; +} + +void MCUDPTransport::JoinMulticastGroup(const char* GroupAddress, const char* BindAddress, unsigned char TTL, bool Loop) +{ + if (!GroupAddress) + return; + + long ma = FindMulticastAddress(GroupAddress); + if (ma != -1) + FMulticastList->Del(ma); + bool oa = getActive(); + if (oa) + setActive(false); + + char* ba = "0.0.0.0"; + if (BindAddress && BindAddress[0] != 0) + ba = (char *) BindAddress; + + char *buf = (char *) MCMemAlloc(strlen(GroupAddress) + strlen(ba) + 8); + sprintf(buf, "%s|%s|%i|%i", GroupAddress, ba, TTL, (unsigned char) Loop); + FMulticastList->Add(buf); + MCMemFree(buf); + + if (oa) + setActive(true); +} + +void MCUDPTransport::LeaveMulticastGroup(const char* GroupAddress) +{ + long ma = FindMulticastAddress(GroupAddress); + if (ma != -1) + { + bool oa = getActive(); + if (oa) + setActive(false); + FMulticastList->Del(ma); + if (oa) + setActive(true); + } +} + + +// ================================ + +MCUDPSenderThread::~MCUDPSenderThread(void) +{ + delete FSendSocket; +} + +void MCUDPSenderThread::Execute(void) +{ + fd_set FDSendSet, FDRecvSet; + bool errorFlag = false, b; + long i; + unsigned int highSocketHandle = 0; + + while ((false == errorFlag) && + (false == getTerminated())) + { + TRY_BLOCK + { + FD_ZERO(&FDSendSet); + FD_ZERO(&FDRecvSet); + FD_SET((unsigned long)FSocket->getSocket(), &FDRecvSet); + + Owner->FCriticalSection->Enter(); + TRY_BLOCK + { + b = false; + for(i = 0; i < Owner->FOutgoingQueue->Length(); i++) + { + MCMessageInfo* r = ((MCMessageInfo*)(*Owner->FOutgoingQueue)[i]); + if(r->State == imsDispatching || r->State == imsComplete || r->State == imsFailed) + { + b = true; + break; + } + } + if(b) + { + FD_SET((unsigned long)FSendSocket->getSocket(), &FDSendSet); + highSocketHandle = FSocket->getSocket() > FSendSocket->getSocket() ? FSocket->getSocket() : FSendSocket->getSocket(); + } + else + highSocketHandle = FSocket->getSocket(); + } FINALLY ( + Owner->FCriticalSection->Leave(); + ) + int select_res = select(highSocketHandle + 1, &FDRecvSet, &FDSendSet, NULL, NULL); + + if ((0 != select_res) && (-1 != select_res)) + { + if(FD_ISSET(FSocket->getSocket(), &FDRecvSet)) + { + if(!getTerminated()) + { + if (!MCSocket::PopFromCtlSocket(FSocket)) + { + errorFlag = true; + continue; + } + } + } + + if(FD_ISSET(FSendSocket->getSocket(), &FDSendSet)) + { + if(!SendMessage()) + errorFlag = true; + } + } + else + { + if((select_res == 0 && Owner->getFailOnInactive()) || + (select_res == -1)) + errorFlag = true; + } + } + CATCH_EVERY + { + errorFlag = true; + } + } +} + +MCUDPSenderThread::MCUDPSenderThread(bool CreateSuspended) +:MCUDPThread(CreateSuspended), FSendSocket(NULL) +{ +} + + +void MCUDPSenderThread::Initialize(MCUDPTransport* AOwner) +{ + MCUDPThread::Initialize(AOwner); + FSendSocket = new MCStdSocket(); + FSendSocket->setLocalPort(0); + FSendSocket->setLocalAddress(Owner->getMessengerAddress()); + WinsockErrorCheck(FSendSocket->Init(istDatagram)); + long i = 1; + WinsockErrorCheck(setsockopt(FSendSocket->getSocket(), SOL_SOCKET, SO_BROADCAST, (char*)&i, sizeof(i))); + i = 1; +#ifndef __GNUC__ + WinsockErrorCheck(ioctlsocket(FSendSocket->getSocket(), FIONBIO, (u_long*)&i)); +#else + WinsockErrorCheck(ioctl(FSendSocket->getSocket(), FIONBIO, (u_long*)&i)); +#endif + + for (i = 0; i < Owner->FMulticastList->Length(); i++) + { + char* ml = (char *) ((*Owner->FMulticastList)[i]); + char* mle = ml; + + mle = mcstrtok(ml, "|"); + char GroupAddress[16]; + strncpy(GroupAddress, ml, mle - ml); GroupAddress[mle - ml] = 0; + ml = mle + 1; + + mle = mcstrtok(ml, "|"); + char BindAddress[16]; + strncpy(BindAddress, ml, mle - ml); BindAddress[mle - ml] = 0; + ml = mle + 1; + + mle = mcstrtok(ml, "|"); + char TTLStr[4]; + strncpy(TTLStr, ml, mle - ml); TTLStr[mle - ml] = 0; + ml = mle + 1; + + unsigned char TTL = (unsigned char) atoi(TTLStr); + bool Loop = atoi(ml) != 0; + + WinsockErrorCheck(FSendSocket->AddToMulticastCli(BindAddress, TTL, Loop)); + } +} + +void MCUDPSenderThread::MessageFailed(int reason, MCMessageInfo* Info, MCMessageState InfoState) +{ + if((InfoState == imsDispatching) && (reason != 0) +//$ifdef MC_COMMERCIAL + && !Info->Intermed +//$endif MC_COMMERCIAL + ) + { + Owner->FCriticalSection->Enter(); + + // remove the message from the queue + Owner->FOutgoingQueue->Del(Info); + Owner->FCriticalSection->Leave(); + + Owner->FMessenger->FCompleteCriticalSection->Enter(); + TRY_BLOCK + { + Info->State = imsFailed; + Info->MCError = reason; + Owner->FMessenger->FCompleteQueue->Add(Info); + Owner->FMessenger->FCompleteEvent->setEvent(); + if(Info->ReplyFlag) + Info->ReplyFlag->setEvent(); + } FINALLY ( + Owner->FMessenger->FCompleteCriticalSection->Leave(); + ) + } + else + { + Owner->FCriticalSection->Enter(); + + // remove the message from the queue + Owner->FOutgoingQueue->Del(Info); + Owner->FCriticalSection->Leave(); + + // destroy message info + delete Info; Info = NULL; + } +} + +bool MCUDPSenderThread::SendMessage(void) +{ + char* DataBuf = NULL; + long DataLen = 0; + char* RemoteHost = NULL; + int RemotePort = 0; + + long i = 0, i1 = 0; + MCMessageInfo* Info = NULL; + MCMessageState InfoState = imsNone; + bool result = true; + + if(PrepareMessage(&Info, &DataBuf, &DataLen, &InfoState)) + { + i = CONST_MAX_MSG_SIZE; + if(DataLen <= i) + { + if(ParseRemoteAddr(Info->DMessenger, &RemoteHost, &RemotePort)) + { + i = FSendSocket->SendTo(DataBuf, DataLen, i1, RemoteHost, RemotePort); + if(i != 0) + MessageFailed(MCError_WrongSocketResult, Info, InfoState); + else + { + if(InfoState == imsDispatching && Info->IsSendMsg +//$ifdef MC_COMMERCIAL + && !Info->Intermed +//$endif MC_COMMERCIAL + ) + // if the message is to be replied, we do nothing + ; + else + { + // otherwise we destroy the message + MessageFailed(0, Info, InfoState); + } + } + } + else + MessageFailed(MCError_InvalidAddress, Info, InfoState); + } + else + MessageFailed(MCError_PacketTooLarge, Info, InfoState); + + // FreeAndNil(Info); + } + if( DataBuf != NULL ) + MCMemFree(DataBuf); + + if (NULL != RemoteHost) + free(RemoteHost); + return result; +} + +bool MCUDPSenderThread::PrepareMessage(MCMessageInfo** AInfo, char** DataBuf, + long* DataLen, MCMessageState* InfoState) +{ + long i, j; + MCMemStream* MemStream; + MCInetHeader Header; + bool im, wrt; + bool res = false; + int extra; + unsigned char bt = 0; + //bool result = false; + MCMessageInfo* Info = NULL; + + *DataLen = 0; + *DataBuf = NULL; + *AInfo = NULL; + + Owner->FCriticalSection->Enter(); + TRY_BLOCK + { + for(i = 0;i <= Owner->FOutgoingQueue->Length() - 1;i++) + if(((MCMessageInfo*)((*Owner->FOutgoingQueue)[i]))->State == imsDispatching || + ((MCMessageInfo*)((*Owner->FOutgoingQueue)[i]))->State == imsComplete || + ((MCMessageInfo*)((*Owner->FOutgoingQueue)[i]))->State == imsFailed) + { + Info = (MCMessageInfo*)((*Owner->FOutgoingQueue)[i]); + //Owner->FOutgoingQueue->Del(i); + break; + } + + if(Info) + { + res = true; + //Owner->FCriticalSection->Leave(); + // return(false); + + { + //MCMemFree(Info->SMessenger); + char pt[128]; + sprintf(pt, "%s:%d", FSendSocket->getLocalAddress(), Owner->FMessengerPort); + Info->setSMessenger(pt); + } + + // write data for conversion + MemStream = new MCMemStream(); + TRY_BLOCK + { + im = false; + + //$ifdef MC_COMMERCIAL + if (Info->EncodedMsg != NULL) + im = true; + + if (!im) + //$endif + { + Info->WriteToStream(MemStream);//->Write(Info, (long)((char*)&Info->Message.Data - (char*)Info)); + if(Info->Message.DataSize > 0) + MemStream->Write(Info->Message.Data, Info->Message.DataSize); + } + *InfoState = Info->State; + Info->State = imsWaiting; + + //$ifdef MC_COMMERCIAL + if (im) + { + Header.dwCompressID = Info->CompressID; + Header.dwEncryptID = Info->EncryptID; + Header.dwSealID = Info->SealID; + } + else + //$endif MC_COMMERCIAL + { + if(Owner->getCompressor()) + Header.dwCompressID = Owner->getCompressor()->GetID(); + else + Header.dwCompressID = 0; + + if(Owner->getEncryptor()) + Header.dwEncryptID = Owner->getEncryptor()->GetID(); + else + Header.dwEncryptID = 0; + + if(Owner->getSealer()) + Header.dwSealID = Owner->getSealer()->GetID(); + else + Header.dwSealID = 0; + } + + //$ifdef MC_COMMERCIAL + if(im) + { + *DataLen = Info->EncodedLen; + *DataBuf = (char*)Info->EncodedMsg; + Info->EncodedMsg = NULL; + Info->EncodedLen = 0; + } + else + //$endif + { + *DataLen = MemStream->Len(); + *DataBuf = (char*)MCMemAlloc(*DataLen); + MemStream->SetPos(0); + MemStream->Read(*DataBuf, *DataLen); + MemStream->SetPointer(NULL, 0); + + // prepare data block + char* s = (char*)MCMemAlloc(FSendSocket->getRemoteAddress()?strlen(FSendSocket->getRemoteAddress()):0 + 20); + sprintf(s, "%s:%d", FSendSocket->getRemoteAddress()?FSendSocket->getRemoteAddress():"", + Owner->getMessengerPort()); + Owner->PrepareDataBlock(s, *DataBuf, *DataLen, (void*&)*DataBuf, *DataLen, Header.dwEncryptID, Header.dwCompressID, Header.dwSealID); + MCMemFree(s); s = NULL; + } + + Header.dwSignature = 0x50444945ul; + Header.dwDataSize = *DataLen + sizeof(Header) + strlen(Info->SMessenger) + sizeof(long); + + extra = 2 + 4 + 4 + 4; + + //$ifdef MC_COMMERCIAL + if (Info->RecvPath) + extra += strlen(Info->RecvPath); + if (Info->RouteTo) + extra += strlen(Info->RouteTo); + if (Info->DQueue) + extra += strlen(Info->DQueue); + //$endif + + Header.dwDataSize += extra; // add router info and separator + // write header + MemStream->Write(&Header, sizeof(Header)); + // write source address + i = strlen(Info->SMessenger); + j = i; + // this will be used for routing and transactions + i += extra; + MemStream->Write(&i, sizeof(i)); + if(j > 0) + MemStream->Write(Info->SMessenger, j); + + //$ifdef MC_COMMERCIAL + bt = 0; + MemStream->Write(&bt, sizeof(bt)); + bt = (char) Info->TransactCmd; + MemStream->Write(&bt, sizeof(bt)); + + // write RecvPath + if (Info->RecvPath) + i = strlen(Info->RecvPath); + else + i = 0; + MemStream->Write(&i, sizeof(i)); + if (i > 0) + MemStream->Write(Info->RecvPath, i); + + // write RouteTo + if (Info->RouteTo) + i = strlen(Info->RouteTo); + else + i = 0; + MemStream->Write(&i, sizeof(i)); + if (i > 0) + MemStream->Write(Info->RouteTo, i); + + // write DQueue + if (Info->DQueue) + i = strlen(Info->DQueue); + else + i = 0; + MemStream->Write(&i, sizeof(i)); + if (i > 0) + MemStream->Write(Info->DQueue, i); + wrt = true; + //$else + if (!wrt) + { + char buf[14]; + memset(buf, 0, 14); + MemStream->Write(buf, sizeof(buf)); + } + //$endif + + // write actual data + MemStream->Write(*DataBuf, *DataLen); + MemStream->SetPos(0); + + MCMemFree(*DataBuf); + *DataBuf = NULL; + + *DataLen = MemStream->Len(); + *DataBuf = (char*)MCMemAlloc(*DataLen); + MemStream->SetPos(0); + MemStream->Read(*DataBuf, *DataLen); + } FINALLY ( + delete MemStream; MemStream = NULL; + ) + } + } FINALLY ( + Owner->FCriticalSection->Leave(); + ) + + *AInfo = Info; + return(res); +} + +MCUDPReceiverThread::~MCUDPReceiverThread(void) +{ + delete FRecvSocket; FRecvSocket = NULL; + if(FRecvBuffer) + { + MCMemFree(FRecvBuffer); + FRecvBuffer = NULL; + } +} + +void MCUDPReceiverThread::Execute(void) +{ + fd_set FDRecvSet; + bool errorFlag = false; + + while ((false == errorFlag) && + (false == getTerminated())) + { + TRY_BLOCK + { + FD_ZERO(&FDRecvSet); + FD_SET((unsigned long)FSocket->getSocket(), &FDRecvSet); + FD_SET((unsigned long)FRecvSocket->getSocket(), &FDRecvSet); + + unsigned int highSocketHandle = 0; + highSocketHandle = FSocket->getSocket() > FRecvSocket->getSocket() ? FSocket->getSocket() : FRecvSocket->getSocket(); + int select_res = select(highSocketHandle + 1, &FDRecvSet, NULL, NULL, NULL); + + if (0 == select_res) + continue; + if (-1 != select_res) + { + if(FD_ISSET(FSocket->getSocket(), &FDRecvSet)) + { + if(!getTerminated()) + { + if (!MCSocket::PopFromCtlSocket(FSocket)) + { + errorFlag = true; + continue; + } + } + } + + if(FD_ISSET(FRecvSocket->getSocket(), &FDRecvSet)) + { + if(!ReceiveMessage()) + errorFlag = true; + } + } + else + errorFlag = true; + } + CATCH_EVERY + { + errorFlag = true; + } + } +} + +void MCUDPReceiverThread::Initialize(MCUDPTransport* AOwner) +{ + MCUDPThread::Initialize(AOwner); + FRecvSocket = new MCStdSocket(); + FRecvSocket->setLocalPort(Owner->getMessengerPort()); + FRecvSocket->setLocalAddress(Owner->getMessengerAddress()); + WinsockErrorCheck(FRecvSocket->Init(istDatagram)); + if (Owner->getReuseServerPort()) + WinsockErrorCheck(FRecvSocket->ReusePort()); + WinsockErrorCheck(FRecvSocket->Bind()); + long i = 0; + i = CONST_MAX_MSG_SIZE; + FRecvBuffer = (long*)MCMemAlloc(i); + FRecvBufSize = i; + + for (i = 0; i < Owner->FMulticastList->Length(); i++) + { + char* ml = (char *) ((*Owner->FMulticastList)[i]); + char* mle = ml; + + mle = mcstrtok(ml, "|"); + char GroupAddress[16]; + strncpy(GroupAddress, ml, mle - ml); GroupAddress[mle - ml] = 0; + ml = mle + 1; + + mle = mcstrtok(ml, "|"); + char BindAddress[16]; + strncpy(BindAddress, ml, mle - ml); BindAddress[mle - ml] = 0; + //ml = mle + 1; + + WinsockErrorCheck(FRecvSocket->AddToMulticastSrv(GroupAddress, BindAddress)); + } + +} + +long getLong(void* x) +{ + long temp = 0; + memmove(&temp, x, sizeof(temp)); + return temp; +} + +bool MCUDPReceiverThread::ReceiveMessage(void) +{ + MCInetHeader Header; + MCMessageInfo *Info = NULL, *CurInfo = NULL; + MCMemStream* AStream = NULL; + MCMemStream* Stream = NULL; + MCMessage Message; + long i = 0; + char *s = NULL, *s1 = NULL, *SMsg = NULL; + long Received = 0; + char* RemoteHost = NULL; + unsigned int RemotePort = 0; + long recvres = 0; + long MsgSize = 0; + void* DataBuf = NULL; + long DataLen = 0; + char* RemoteAddr = NULL; + bool parsed = false; + bool noprocess = false; + + //this is used always, but is related to MC_COMMERCIAL + char* RouteTo = NULL; + char* RecvPath = NULL; + char TransactCmd = 0; + char* DQueue = NULL; + + Received = FRecvBufSize; + recvres = FRecvSocket->ReceiveFrom(FRecvBuffer, FRecvBufSize, Received, RemoteHost, RemotePort); + bool Result = true; + if(recvres == 0) + { + MsgSize = FRecvBuffer[1]; + if(MsgSize == Received && Received < Owner->getMaxMsgSize()) + { + Stream = new MCMemStream(); + TRY_BLOCK + { + Stream->Write(FRecvBuffer, Received); + Stream->SetPos(0); + + Stream->Read(&Header, sizeof(Header)); + + // read the source messenger name + Stream->Read(&i, sizeof(i)); + if(i > 0) + { + s = (char*)MCMemAlloc(i + 1); + Stream->Read(s, i); + s[i] = 0; + + //this is used always, but is related to MC_COMMERCIAL + if ((long)strlen(s) < i) + { + while (true) + { + char* tmp_p = (char*) MCMemAlloc(strlen(s) + 1); + strcpy(tmp_p, s); + + char* ps = s + strlen(s) + 1; + char* pe = ps + i - strlen(s); + if (pe - ps < 14) + break; + // read TransactCmd + TransactCmd = *ps; + ps++; + + // read RecvPath + i = getLong(ps);//*((int*)(ps)); + ps += 4; + + if (pe - ps < i + 4) + break; + + if (i) + { + RecvPath = strCopy(ps, 0, i); + ps += i; + } + + // read RouteTo + i = getLong(ps);//*((int*)(ps)); + ps += 4; + + if (pe - ps < i + 4) + break; + + if (i) + { + RouteTo = strCopy(ps, 0, i); + ps += i; + } + + // read DQueue + i = getLong(ps);//*((int*)(ps)); + ps += 4; + if (pe - ps < i) + break; + + if (i) + DQueue = strCopy(ps, 0, i); + + MCMemFree(s); + s = tmp_p; + + parsed = true; + break; + } + if (!parsed) + { + MCMemFree(s); + s = NULL; + } + } + } + else + s = NULL; + // SMsg := RemoteHost + ':' + IntToStr(RemotePort); + + if(ParseRemoteAddr(s, &s1, (int*)&RemotePort)) + { + if(strcmp(s1, "0.0.0.0") == 0) + { + MCMemFree(s1); + s1 = strdup(RemoteHost); + } + char* tmp = (char*)MCMemAlloc(strlen(s1) + 11); + sprintf(tmp, "%s:%d", s1, RemotePort); + RemoteAddr = tmp; + MCMemFree(s); s = NULL; + MCMemFree(s1); s1 = NULL; + } + else + { + RemoteAddr = s; + s = NULL; + } + + SMsg = strdup(RemoteAddr); + + // if we are an intermediate node, we must add sender path to RecvPath + if (RouteTo != NULL) + { + char* tmpPath; + int npl; + if (RecvPath != NULL) + { + npl = strlen(Owner->RealTransportName()) + 1 + strlen(s) + 1 + strlen(RecvPath) + 1; + tmpPath = (char*) MCMemAlloc(npl); + tmpPath[0] = 0; + strcpy(tmpPath, Owner->RealTransportName()); strcat(tmpPath, ":"); + strcat(tmpPath, RemoteAddr); strcat(tmpPath, "|"); strcat(tmpPath, RecvPath); + MCMemFree(RecvPath); + RecvPath = tmpPath; + } + else + { + npl = strlen(Owner->RealTransportName()) + 1 + strlen(s) + 1; + tmpPath = (char*) MCMemAlloc(npl); + tmpPath[0] = 0; + strcpy(tmpPath, Owner->RealTransportName()); strcat(tmpPath, ":"); + strcat(tmpPath, RemoteAddr); + RecvPath = tmpPath; + } + } + + // MC_COMMERCIAL. Fixed to not check for intermediate nodes + if(!RouteTo) + //check for suitable transformers + if(!IsTransformerOK(&Header)) + { + //Owner->FCriticalSection->Leave(); + noprocess = true; + //return(Result); + } + + if (!noprocess) + { + // discard the message if routing is not allowed + if(RouteTo + //$ifdef MC_COMMERCIAL + && !Owner->getRoutingAllowed() + //$endif MC_COMMERCIAL + ) + { + //Owner->FCriticalSection->Leave(); + noprocess = true; + //return(Result); + } + } + + if (!noprocess) + { + if(Stream->Pos() < Stream->Len()) + { + // allocate buffer for data + DataLen = Stream->Len() - Stream->Pos(); + DataBuf = (char*)MCMemAlloc(DataLen); // former memory leak + if(!DataBuf) + THROW_ERROR(MCError_NotEnoughMemory); + + TRY_BLOCK + { + // read the data + Stream->Read(DataBuf, DataLen); + +//$ifdef MC_COMMERCIAL + if (RouteTo != NULL) + { + Info = new MCMessageInfo(&Message); + Info->setSMessenger(SMsg); MCMemFree(SMsg); SMsg = NULL; + Info->setDMessenger(RemoteAddr); MCMemFree(RemoteAddr); RemoteAddr = NULL; + if (RouteTo) + Info->setRouteTo(RouteTo); + else + Info->setRouteTo(NULL); + Info->Intermed = true; + if (RecvPath) + Info->setRecvPath(RecvPath); + else + Info->setRecvPath(NULL); + Info->EncodedMsg = DataBuf; + Info->EncodedLen = DataLen; + Info->SealID = Header.dwSealID; + Info->EncryptID = Header.dwEncryptID; + Info->CompressID = Header.dwCompressID; + Info->Timeout = Owner->FMsgTimeout; + strncpy(Info->DQueue, DQueue, sizeof(Info->DQueue) - 1); + MCMessenger::SetMessageID(Info); + DataBuf = NULL; + Owner->RouteMessage(Info); + } + else +//$endif + // decode the message + if(Owner->UnprepareDataBlock(RemoteAddr, DataBuf, DataLen, DataBuf, DataLen, Header.dwEncryptID, Header.dwCompressID, Header.dwSealID)) + { + // decoding was successful + AStream = new MCMemStream(); + TRY_BLOCK + { + AStream->SetPointer((char*)DataBuf, DataLen); + Message.DataSize = 0; + Info = new MCMessageInfo(&Message); + Info->setSMessenger(SMsg); MCMemFree(SMsg); SMsg = NULL; + Info->setDMessenger(RemoteAddr); MCMemFree(RemoteAddr); RemoteAddr = NULL; + Info->Timeout = Owner->FMsgTimeout; +//$ifdef MC_COMMERCIAL + Info->TransactCmd = (MCTransactCmd) TransactCmd; + if (RecvPath) + Info->setRecvPath(strCopy(RecvPath, 0)); + else + Info->setRecvPath(NULL); +//$endif MC_COMMERCIAL + + Info->LoadFromStream(AStream); + { + if(Info->State == imsDispatching) // we have received an original message + { + MCMessenger::SetMessageID(Info); + if(AStream->Len() - AStream->Pos() < Info->Message.DataSize) + { + // discard the message as the data portion is corrupt + delete Info; Info = NULL; + //Owner->FCriticalSection->Leave(); + noprocess = true; + //return(Result); + } + else + if(Info->Message.DataSize > 0) + { + Info->Message.Data = MCMemAlloc(Info->Message.DataSize); + AStream->Read(Info->Message.Data, Info->Message.DataSize); + } + else + Info->Message.Data = NULL; + Owner->MessageReceived(Info); + } + else // we have received a reply + { + // remove the message from the list of pending messages + + Owner->FCriticalSection->Enter(); + TRY_BLOCK + { + //Entry.ClientID := ExtractClientID(S); + //find original request + CurInfo = NULL; + for(i = 0;i < Owner->FOutgoingQueue->Length();i++) + if(((MCMessageInfo*)(*Owner->FOutgoingQueue)[i])->OrigID == Info->OrigID) + { + CurInfo = (MCMessageInfo*)(*Owner->FOutgoingQueue)[i]; + Owner->FOutgoingQueue->Del(i); + break; + } + } + FINALLY ( + Owner->FCriticalSection->Leave(); + ) + //original request is found? + if(!CurInfo) // the message was cancelled - well, destroy the reply + { + delete Info; + Info = NULL; + } + else + { + // we have to copy result data and signal about reply + if (CurInfo->Message.DataType != bdtConst) + { + if(CurInfo->Message.Data) + { + MCMemFree(CurInfo->Message.Data); + CurInfo->Message.Data = NULL; + CurInfo->Message.DataSize = 0; + } + + // read the resulting data from the stream + CurInfo->Message.DataSize = Info->Message.DataSize; + if(CurInfo->Message.DataSize > 0) + { + CurInfo->Message.Data = MCMemAlloc(CurInfo->Message.DataSize); + AStream->Read(CurInfo->Message.Data, Info->Message.DataSize); + } + else + CurInfo->Message.Data = NULL; + + // reset fields in Info + Info->Message.Data = NULL; + Info->Message.DataSize = 0; + } + + CurInfo->Message.Result = Info->Message.Result; + CurInfo->MCError = Info->MCError; + CurInfo->State = Info->State; + delete Info; Info = NULL; + Owner->ReplyReceived(CurInfo); + } + } + } + } FINALLY ( + if(AStream) + AStream->SetPointer(NULL, 0); + delete AStream; + ) + } + } FINALLY ( + MCMemFree(DataBuf); DataBuf = NULL; + ) + } + } + } FINALLY ( + delete Stream; + if (RecvPath) + MCMemFree(RecvPath); + if (DQueue) + MCMemFree(DQueue); + if (RouteTo) + MCMemFree(RouteTo); + if (SMsg) + MCMemFree(SMsg); + if (RemoteAddr) + MCMemFree(RemoteAddr); + ) + } + } + else +#ifdef _WIN32 + Result = (recvres == WSAEMSGSIZE); +#else + Result = true; +#endif + return(Result); +} + +bool MCUDPReceiverThread::IsTransformerOK(MCInetHeader* Header) +{ + bool r = true; + Owner->FLinkCriticalSection->Enter(); + + if (0 != Header->dwCompressID) + { + if (NULL == Owner->getCompressor() || + Owner->getCompressor()->GetID() != Header->dwCompressID) + { + Header->dwCompressID = 0; + r = false; + } + } + + if (0 != Header->dwEncryptID) + { + if (NULL == Owner->getEncryptor() || + Owner->getEncryptor()->GetID() != Header->dwEncryptID) + { + Header->dwEncryptID = 0; + r = false; + } + } + + if (0 != Header->dwSealID) + { + if (NULL == Owner->getSealer() || + Owner->getSealer()->GetID() != Header->dwSealID) + { + Header->dwSealID = 0; + r = false; + } + } + + Owner->FLinkCriticalSection->Leave(); + return r; +} + +MCUDPThread::MCUDPThread(bool CreateSuspended) +:MCThread(CreateSuspended), FSocket(NULL), FKickSocket(NULL), Owner(NULL) +{ +} + +MCUDPThread::~MCUDPThread() +{ + delete FSocket; FSocket = NULL; + delete FKickSocket; FKickSocket = NULL; +} + +void MCUDPThread::Initialize(MCUDPTransport* AOwner) +{ + Owner = AOwner; + + FSocket = new MCStdSocket(); + FSocket->setLocalPort(0); + FSocket->setLocalAddress("0.0.0.0"); + WinsockErrorCheck(FSocket->Init(istDatagram)); + WinsockErrorCheck(FSocket->Bind()); + FKickSocket = new MCStdSocket(); + WinsockErrorCheck(FKickSocket->Init(istDatagram)); +} + +void MCUDPThread::KickThread(bool MessageFlag) +{ + char c = (char) MessageFlag; + long i; + FKickSocket->SendTo(&c, 1, i, "127.0.0.1", + FSocket->getLocalPort()); +} + +bool MCUDPThread::ParseRemoteAddr(const char* S, char** IP, int* Port) +{ + char *c = strchr((char*) S, ':'); + if(!S || !(c)) + return(false); + long i = c - S + 1; + if (NULL != IP) + { + *IP = (char*)MCMemAlloc(i); + strncpy(*IP, S, i); + (*IP)[i-1] = 0; + } + if (NULL != Port) + *Port = atoi(++c); + return(true); +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCUDPSocket.h b/libraries/external/eldos/pc/include/MCUDPSocket.h new file mode 100755 index 0000000..f7eb9be --- /dev/null +++ b/libraries/external/eldos/pc/include/MCUDPSocket.h @@ -0,0 +1,140 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef MCUDP_H +#define MCUDP_H + +#include "MC.h" +#include "MCBase.h" +#include "MCSyncs.h" +#include "MCThreads.h" +#include "MCStream.h" +#include "MCSock.h" +#include "MCSocketBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +const int CONST_MAX_MSG_SIZE = 512; + +class MCUDPTransport; +class MCUDPSenderThread; +class MCUDPReceiverThread; + +class MCUDPThread : public MCThread { +friend class MCUDPTransport; +friend class MCUDPSenderThread; +friend class MCUDPReceiverThread; +protected: + + MCSocket* FSocket; + MCSocket* FKickSocket; + MCUDPTransport* Owner; + void KickThread(bool MessageFlag); + static bool ParseRemoteAddr(const char* S, char** IP, int* Port); + +public: + MCUDPThread(bool CreateSuspended); + virtual ~MCUDPThread(); + virtual void Initialize(MCUDPTransport* AOwner); +}; + +class MCUDPSenderThread : public MCUDPThread { +friend class MCUDPTransport; +protected: + __int64 FCancelID; + MCStdSocket* FSendSocket; + + + virtual void Execute(void); + bool SendMessage(void); + void MessageFailed(int reason, MCMessageInfo* Info, MCMessageState InfoState); + bool PrepareMessage(MCMessageInfo** Info, char** DataBuf, + long* DataLen, MCMessageState* InfoState); +public: + MCUDPSenderThread(bool CreateSuspended); + virtual ~MCUDPSenderThread(void); + virtual void Initialize(MCUDPTransport* AOwner); +}; + +class MCUDPReceiverThread : public MCUDPThread { +friend class MCUDPTransport; +protected: + + MCStdSocket* FRecvSocket; + long* FRecvBuffer; + long FRecvBufSize; + MCUDPReceiverThread(bool CreateSuspended): MCUDPThread(CreateSuspended), FRecvSocket(NULL), FRecvBuffer(NULL) {}; + + virtual void Execute(void); + bool ReceiveMessage(void); + bool IsTransformerOK(MCInetHeader* Header); +public: + virtual ~MCUDPReceiverThread(void); + virtual void Initialize(MCUDPTransport* AOwner); +}; + +class MCUDPTransport : public MCSimpleTransport { +friend class MCUDPSenderThread; +friend class MCUDPReceiverThread; +protected: + bool FFailOnInactive; + char* FMessengerAddress; + unsigned int FMessengerPort; + MCInetTransportMode FTransportMode; + MCUDPReceiverThread* FReceiverThread; + MCUDPSenderThread* FSenderThread; + MCStringList* FMulticastList; + bool FReuseServerPort; +//$ifdef MC_COMMERCIAL + bool FRoutingAllowed; +//$endif MC_COMMERCIAL + virtual bool DeliverMessage(char* DestAddress, MCMessageInfo* Info); + virtual void DoSetActive(void); + + virtual void KickSender(bool MessageFlag); + virtual void CancelMessageInSender(MCMessageInfo* Info); + virtual bool WasCancelled(MCMessageInfo* Info); + virtual void SetInfoSMessenger(MCMessageInfo* Info); + long FindMulticastAddress(const char* Value); + + virtual MCUDPSenderThread* CreateSenderThread(bool x); + virtual MCUDPReceiverThread* CreateReceiverThread(bool x); +public: + MCUDPTransport(void); + virtual ~MCUDPTransport(); + void JoinMulticastGroup(const char* GroupAddress, const char* BindAddress, unsigned char TTL, bool Loop); + void LeaveMulticastGroup(const char* GroupAddress); + + unsigned getMessengerPortBound(void); + + void setFailOnInactive(bool Value); + bool getFailOnInactive(void); + void setMessengerAddress(char* Value); + char* getMessengerAddress(void); + void setMessengerPort(unsigned Value); + unsigned getMessengerPort(void); + void setTransportMode(MCInetTransportMode Value); + MCInetTransportMode getTransportMode(void); + void setRoutingAllowed(bool Value); + bool getRoutingAllowed(void); + void setReuseServerPort(bool Value); + bool getReuseServerPort(void); + +}; + +class HackMCMessenger : public MCMessenger {}; + +#ifdef USE_NAMESPACE +} +#endif + + +#endif diff --git a/libraries/external/eldos/pc/include/MCUtils.cpp b/libraries/external/eldos/pc/include/MCUtils.cpp new file mode 100755 index 0000000..b1b900b --- /dev/null +++ b/libraries/external/eldos/pc/include/MCUtils.cpp @@ -0,0 +1,199 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#include "MC.h" +#include "MCUtils.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +unsigned long MCMainThreadID; + +bool IsLinux = false; +//$ifndef LINUX +bool IsWin95 = false; +bool IsWinNT = false; +bool IsWin2000 = false; +bool IsWinNTUp = false; +bool IsWin2000Up = false; +bool IsWinXP = false; +bool IsWinXPUp = false; +bool IsWin95OSR2 = false; +bool IsWin98 = false; +bool IsWinME = false; +bool IsWin98Up = false; +//$endif + + +//$ifndef LINUX +#ifdef _WIN32 +bool SupportsTSNames(void) +{ + return IsWin2000Up; +} +#endif +//$endif + +void* MCMemAlloc(long Size) +{ + if(Size > 0) + { + void* result = (void*)malloc(Size); + if (NULL == result) + THROW_ERROR(MCError_NotEnoughMemory); + return result; + } + else + return NULL; +} + +void MCMemFree(void* Block) +{ + if (NULL != Block) + free(Block); +} + +void MCFreeNull(void*& Block) +{ + MCMemFree(Block); + Block = NULL; +} + +// ********************************* MCObject ********************************* +MCObject::MCObject(void) +//:FLogger(NULL) +{ +// FLogger = MCLogger::Singletone(); +} + +MCObject::~MCObject() +{ +/* + if (FLogger == MCLogger::Singletone()) + { + FLogger->Release(); + FLogger->Release(); + } +*/ +} + +/* + +void MCObject::setLogger(MCLogger* Logger) +{ + if (FLogger == MCLogger::Singletone()) + { + FLogger->Release(); + FLogger->Release(); + } + FLogger = Logger; +} +*/ + +// ********************************* EMCError ********************************* + + +EMCError::EMCError(long ErrorCode) +:FErrorCode(ErrorCode) +{ +} + +EMCError::EMCError(long ErrorCode, long SubCode) +:FErrorCode(ErrorCode), FSubCode(SubCode) +{ +} + +#ifdef ENABLE_SEH2CPP +EMCError::EMCError(long ErrorCode, long SubCode, EXCEPTION_POINTERS* ExpPtr) +:FErrorCode(ErrorCode), FSubCode(SubCode), FExPtr(ExpPtr) +{ +} +#endif + +long EMCError::ErrorCode(void) const +{ + return FErrorCode; +} + +long EMCError::SubCode(void) const +{ + return FSubCode; +} + +TCHAR* EMCError::GetErrorMessage(void) const +{ + switch(FErrorCode) { + case MCError_BadTransport: + return TEXT("No suitable transport found"); + case MCError_TransportInactive: + return TEXT("Transport is inactive"); + case MCError_BadDestinationName: + return TEXT("Bad destination address format"); + case MCError_WrongSenderThread: + return TEXT("Use destination messenger's thread context."); + case MCError_WrongReceiverThread: + return TEXT("This method should be called within Messenger creator thread"); + case MCError_NoQueueName: + return TEXT("Messenger Queue name must be specified."); + case MCError_SecurityInitFailed: + return TEXT("Security descriptor initialization failed"); + case MCError_InvalidEncryptionKey: + return TEXT("Invalid key specified for encryption component"); + case MCError_NotEnoughMemory: + return TEXT("Not enough memory to perform operation"); + case MCError_WrongCredentials: + return TEXT("Sender presented invalid credentials"); + case MCError_GenTransportFailure: + return TEXT("Transport failure due to unexpected error"); + case MCError_NoDecryptor: + return TEXT("Decryptor is not found"); + case MCError_NoDecompressor: + return TEXT("Decompressor is not found"); + case MCError_NoSignatureHandler: + return TEXT("Decompressor is not found"); + case MCError_InvalidSignature: + return TEXT("Invalid signature in data stream"); + case MCError_TransportTimeout: + return TEXT("Timeout during message tranferring"); + case MCError_ReplyDeferred: + return TEXT("Reply to message is deferred. It is internal error. Please write us bug report"); + case MCError_SEHRaised: + return TEXT("SEH exception was raised."); + case MCError_MMFCreationFailed: + return TEXT("Creation of memory mapping failed"); + case MCError_MutexCreationFailed: + return TEXT("Creation of memory mapping access mutex failed"); + case MCError_NoMessengerName: + return TEXT("No messenger name specified"); + case MCError_NotASocket: + return TEXT("Operation called on invalid socket"); + case MCError_WrongSocketState: + return TEXT("Socket is in state that is not acceptable for current operation"); + case MCError_WinsockInitFailed: + return TEXT("Failed to initialize Winsock"); + case MCError_InvalidAddress: + return TEXT("Invalid address specified"); + case MCError_ConnectionFailed: + return TEXT("Connection failed"); + case MCError_ConnectionLost: + return TEXT("Connection to remote host was lost"); + + case MCError_InvalidHTTP: + return TEXT("Cannot parse HTTP header - seems it is invalid."); + default: + return TEXT("Unspecified error"); + } +} + + +#ifdef USE_NAMESPACE +} +#endif + diff --git a/libraries/external/eldos/pc/include/MCUtils.h b/libraries/external/eldos/pc/include/MCUtils.h new file mode 100755 index 0000000..8586cb9 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCUtils.h @@ -0,0 +1,145 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCUTILS__ +#define __MCUTILS__ + +#include "MC.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +extern bool IsLinux; +extern bool IsWin95; +extern bool IsWinNT; +extern bool IsWin2000; +extern bool IsWinNTUp; +extern bool IsWin2000Up; +extern bool IsWinXP; +extern bool IsWinXPUp; +extern bool IsWin95OSR2; +extern bool IsWin98; +extern bool IsWinME; +extern bool IsWin98Up; + + +#ifdef _WIN32 +bool SupportsTSNames(void); +#endif +void* MCMemAlloc(long Size); +void MCMemFree(void* Block); +void MCFreeNull(void*& Block); + + +enum { + MCError_WrongReceiverThread = 1, + MCError_WrongSenderThread = 2, + + MCError_NoQueueName = 3, + MCError_BadTransport = 4, + MCError_BadDestinationName = 5, + MCError_SecurityInitFailed = 6, + MCError_GenTransportFailure = 8, + MCError_NoDecryptor = 9, + MCError_NoDecompressor = 10, + MCError_NoSignatureHandler = 11, + MCError_InvalidSignature = 12, + MCError_TransportTimeout = 13, + MCError_InvalidEncryptionKey= 14, + MCError_NotEnoughMemory = 15, + MCError_WrongCredentials = 16, + //MCError_CheckSynchronizeError = 18, + MCError_ThreadCreateError = 19, + MCError_ThreadError = 20, + MCError_ReplyDeferred = 25, + MCError_NoTransformer = 26, + MCError_RoutingNotAllowed = 27, + MCError_TransportInactive = 28, + MCError_SEHRaised = 29, + MCError_SynchroObjectFailed = 30, + MCError_Cancelled = 50, + MCError_Shutdown = 51, + MCError_PacketTooLarge = 52, + + MCError_NoMessengerName = 101, + MCError_MMFCreationFailed = 102, + MCError_MutexCreationFailed = 103, + + MCError_NotASocket = 201, + MCError_WrongSocketState = 202, + MCError_WinsockInitFailed = 203, + MCError_InvalidAddress = 204, + MCError_ConnectionFailed = 205, + MCError_ConnectionLost = 206, + MCError_WrongSocketResult = 207, + MCError_WrongSocketType = 208, + + MCError_InvalidHTTP = 301, + + MCError_SocksNoAcceptableAuthMethods = 501, + MCError_SocksAuthFailure = 502, + MCError_SocksGenFailure = 503, + MCError_SocksNotallowed = 504, + MCError_SocksNetUnreachable = 505, + MCError_SocksHostUnreachable = 506, + MCError_SocksConnectionRefused = 507, + MCError_SocksTTLExpired = 508, + MCError_SocksCmdNotSupported = 509, + MCError_SocksAddrTypeNotSupported = 510, + + MCError_WebTunnelConnectionFailed = 550, + MCError_WebTunnelAuthRequired = 551, + MCError_WebTunnelFailure = 552, + +}; + +class MCObject +{ +protected: +// MCLogger* FLogger; +public: + MCObject(void); + virtual ~MCObject(); +// void setLogger(MCLogger* Logger); +}; + + +#if defined(_WIN32) && defined(USE_CPPEXCEPTIONS) && defined(SEH2CPP) && !defined(__BORLANDC__) +# define ENABLE_SEH2CPP +#endif + +class EMCError +{ +#ifdef ENABLE_SEH2CPP +friend void SEHTranslator(unsigned int u, PEXCEPTION_POINTERS pExp); +#endif +friend class MCWorkerThread; +private: + long FErrorCode; + long FSubCode; + TCHAR* msg; +#ifdef ENABLE_SEH2CPP + EXCEPTION_POINTERS* FExPtr; + EMCError(long ErrorCode, long SubCode, EXCEPTION_POINTERS* ExpPtr); +#endif +public: + EMCError(long ErrorCode); + EMCError(long ErrorCode, long SubCode); + + long ErrorCode(void) const ; + long SubCode(void) const ; + TCHAR* GetErrorMessage() const ; +}; + +#ifdef USE_NAMESPACE +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/MCZLib.cpp b/libraries/external/eldos/pc/include/MCZLib.cpp new file mode 100755 index 0000000..ca48fe5 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCZLib.cpp @@ -0,0 +1,127 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== +#include "MC.h" +#include "MCUtils.h" +#include "MCZLib.h" +#include "zlib.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +void* mem_realloc(void* data, long old_size, long delta) +{ + void* t = MCMemAlloc(old_size + delta); + if(data) { + memmove(t, data, old_size); + MCMemFree(data); + } + return(t); +} + +int MCuncompress (char** dest, unsigned long* destLen, const char* source, unsigned long sourceLen) +{ + const long z_delta = 16; //8192; + z_stream stream; + int err; + long got = 0; + char* got_data = NULL; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) + return Z_BUF_ERROR; + + stream.next_out = NULL; + stream.avail_out = 0; +// if ((uLong)stream.avail_out != *destLen) +// return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + err = inflateInit(&stream); + if (err != Z_OK) + return err; + + do { + got_data = (char*)mem_realloc(got_data, got, z_delta); + stream.next_out = (unsigned char*)got_data + got; + got += z_delta; + stream.avail_out = z_delta; + err = inflate(&stream, Z_SYNC_FLUSH); + if (err == Z_STREAM_END) + { + *dest = got_data; + *destLen = stream.total_out; + err = inflateEnd(&stream); + return(err); + } + } while(err == Z_OK); + + MCMemFree(got_data); + inflateEnd(&stream); + return(err); +} + +MCZLibCompression::MCZLibCompression(void):MCBaseCompression() +{ + FCompressionLevel = 0; +} + +void MCZLibCompression::Compress(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, bool& Success) +{ + if((InDataSize == 0) || (!InData)) + { + OutData = InData; + OutDataSize = InDataSize; + Success = false; + return; + } + OutDataSize = InDataSize + InDataSize / 100 + 13; // according to compress2 description + OutData = MCMemAlloc(OutDataSize); + Success = compress2 ((unsigned char*)OutData, (unsigned long*)&OutDataSize, (unsigned char*)InData, InDataSize, FCompressionLevel) == Z_OK; + MCMemFree(InData); +} + +void MCZLibCompression::Decompress(char* /*Remote*/, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long /*TransformID*/, bool& Success) +{ + if((InDataSize == 0) || (!InData)) + { + OutData = InData; + OutDataSize = InDataSize; + Success = false; + return; + } + Success = MCuncompress((char**)&OutData, (unsigned long*)&OutDataSize, (char*)InData, InDataSize) == Z_OK; + MCMemFree(InData); +} + +long MCZLibCompression::GetID(void) +{ + return(1); +} + +void MCZLibCompression::setCompressionLevel(long Value) +{ + if(FCompressionLevel != Value) + FCompressionLevel = Value; +} + +long MCZLibCompression::getCompressionLevel(void) +{ + return FCompressionLevel; +} + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/include/MCZLib.h b/libraries/external/eldos/pc/include/MCZLib.h new file mode 100755 index 0000000..b6271d9 --- /dev/null +++ b/libraries/external/eldos/pc/include/MCZLib.h @@ -0,0 +1,44 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +#ifndef __MCZLIB__ +#define __MCZLIB__ + +#include "MC.h" +#include "MCBase.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +class MCZLibCompression:public MCBaseCompression { +protected: + long FCompressionLevel; +public: + MCZLibCompression(void); + virtual void Compress(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize,bool& Success); + virtual void Decompress(char* Remote, void* InData, long InDataSize, + void*& OutData, long& OutDataSize, long TransformID, + bool& Success); +public: + virtual long GetID(void); +/* + Use these functions to specify compression level. Possible values are 0..9. +*/ + void setCompressionLevel(long Value); + long getCompressionLevel(void); +}; + +#ifdef USE_NAMESPACE + +} +#endif + +#endif diff --git a/libraries/external/eldos/pc/include/wince_rewrites.cpp b/libraries/external/eldos/pc/include/wince_rewrites.cpp new file mode 100755 index 0000000..995a629 --- /dev/null +++ b/libraries/external/eldos/pc/include/wince_rewrites.cpp @@ -0,0 +1,76 @@ +//==================================================== +// +// EldoS MsgConnect +// +// Copyright (c) 2001-2005, EldoS +// +//==================================================== + +/* + + IMPORTANT NOTE: These rewrites are not fully functional equivalents +to the corresponding ANSI functions but have enough functionality to +supply this library. + +*/ + +#include "MC.h" +#include "MCPlatforms.h" + +#ifdef USE_NAMESPACE +namespace MsgConnect +{ +#endif + +#ifdef WINCE + +/*DEFSECT int isspace(char c) +{ + return(c == ' ' || c == '\t' || c == '\n' || c == '\r'); +}*/ + +DEFSECT char* strrchr(const char* s,char c) +{ + if(s || strlen(s) > 0) + for(const char* p=s+strlen(s)-1; *p; p--) + if(*p == c) + return (char*)p; + return NULL; +} + +DEFSECT long strtol(char * s, char ** z, int n) +{ + long l = strlen(s)+1,r; + wchar_t *w = new wchar_t[l],*wz; + mbstowcs(w, s, l); + r=wcstol(w, &wz, n); + if(z) + if(!*wz) + *z = &s[l-1]; + else + *z = s; + delete w; + return r; +} + +DEFSECT double strtod(char* s, char** z) +{ + long l = strlen(s) + 1; + double r; + wchar_t *w = new wchar_t[l], *wz; + mbstowcs(w, s, l); + r = wcstod(w, &wz); + if(z) + if(!*wz) + *z = &s[l-1]; + else + *z = s; + delete w; + return r; +} + +#endif + +#ifdef USE_NAMESPACE +} +#endif diff --git a/libraries/external/eldos/pc/lib/MC_VC.lib b/libraries/external/eldos/pc/lib/MC_VC.lib new file mode 100755 index 0000000..7b0dcd1 Binary files /dev/null and b/libraries/external/eldos/pc/lib/MC_VC.lib differ diff --git a/libraries/external/freeglut/freeglut-2.4.0.tar.gz b/libraries/external/freeglut/freeglut-2.4.0.tar.gz new file mode 100755 index 0000000..1cb8e48 --- /dev/null +++ b/libraries/external/freeglut/freeglut-2.4.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:269f2d50ba30b381622eb36f20b552ad43a1b43d544b9075e484e7146e81b052 +size 469557 diff --git a/libraries/external/freeglut/pc/bin/freeglut.dll b/libraries/external/freeglut/pc/bin/freeglut.dll new file mode 100755 index 0000000..2572f02 Binary files /dev/null and b/libraries/external/freeglut/pc/bin/freeglut.dll differ diff --git a/libraries/external/freeglut/pc/bin/vssver.scc b/libraries/external/freeglut/pc/bin/vssver.scc new file mode 100755 index 0000000..b81410d Binary files /dev/null and b/libraries/external/freeglut/pc/bin/vssver.scc differ diff --git a/libraries/external/freeglut/pc/include/GL/freeglut.h b/libraries/external/freeglut/pc/include/GL/freeglut.h new file mode 100755 index 0000000..241b7fc --- /dev/null +++ b/libraries/external/freeglut/pc/include/GL/freeglut.h @@ -0,0 +1,22 @@ +#ifndef __FREEGLUT_H__ +#define __FREEGLUT_H__ + +/* + * freeglut.h + * + * The freeglut library include file + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "freeglut_std.h" +#include "freeglut_ext.h" + +/*** END OF FILE ***/ + +#endif /* __FREEGLUT_H__ */ diff --git a/libraries/external/freeglut/pc/include/GL/freeglut_ext.h b/libraries/external/freeglut/pc/include/GL/freeglut_ext.h new file mode 100755 index 0000000..a8b04f6 --- /dev/null +++ b/libraries/external/freeglut/pc/include/GL/freeglut_ext.h @@ -0,0 +1,115 @@ +#ifndef __FREEGLUT_EXT_H__ +#define __FREEGLUT_EXT_H__ + +/* + * freeglut_ext.h + * + * The non-GLUT-compatible extensions to the freeglut library include file + * + * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. + * Written by Pawel W. Olszta, + * Creation date: Thu Dec 2 1999 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef __cplusplus + extern "C" { +#endif + +/* + * GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window + */ +#define GLUT_ACTION_EXIT 0 +#define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1 +#define GLUT_ACTION_CONTINUE_EXECUTION 2 + +/* + * Create a new rendering context when the user opens a new window? + */ +#define GLUT_CREATE_NEW_CONTEXT 0 +#define GLUT_USE_CURRENT_CONTEXT 1 + +/* + * GLUT API Extension macro definitions -- the glutGet parameters + */ +#define GLUT_ACTION_ON_WINDOW_CLOSE 0x01F9 + +#define GLUT_WINDOW_BORDER_WIDTH 0x01FA +#define GLUT_WINDOW_HEADER_HEIGHT 0x01FB + +#define GLUT_VERSION 0x01FC + +#define GLUT_RENDERING_CONTEXT 0x01FD + +/* + * Process loop function, see freeglut_main.c + */ +FGAPI void FGAPIENTRY glutMainLoopEvent( void ); +FGAPI void FGAPIENTRY glutLeaveMainLoop( void ); + +/* + * Window-specific callback functions, see freeglut_callbacks.c + */ +FGAPI void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) ); +FGAPI void FGAPIENTRY glutCloseFunc( void (* callback)( void ) ); +FGAPI void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) ); +/* A. Donev: Also a destruction callback for menus */ +FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) ); + +/* + * State setting and retrieval functions, see freeglut_state.c + */ +FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value ) ; +/* A.Donev: User-data manipulation */ +FGAPI void* FGAPIENTRY glutGetWindowData( void ); +FGAPI void FGAPIENTRY glutSetWindowData(void* data); +FGAPI void* FGAPIENTRY glutGetMenuData( void ); +FGAPI void FGAPIENTRY glutSetMenuData(void* data); + +/* + * Font stuff, see freeglut_font.c + */ +FGAPI int FGAPIENTRY glutBitmapHeight( void* font ); +FGAPI GLfloat FGAPIENTRY glutStrokeHeight( void* font ); +FGAPI void FGAPIENTRY glutBitmapString( void* font, const unsigned char *string ); +FGAPI void FGAPIENTRY glutStrokeString( void* font, const unsigned char *string ); + +/* + * Geometry functions, see freeglut_geometry.c + */ +FGAPI void FGAPIENTRY glutWireRhombicDodecahedron( void ); +FGAPI void FGAPIENTRY glutSolidRhombicDodecahedron( void ); +FGAPI void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ; +FGAPI void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ; +FGAPI void FGAPIENTRY glutWireCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks); +FGAPI void FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks); + +/* + * Extension functions, see freeglut_ext.c + */ +FGAPI void * FGAPIENTRY glutGetProcAddress( const char *procName ); + + +#ifdef __cplusplus + } +#endif + +/*** END OF FILE ***/ + +#endif /* __FREEGLUT_EXT_H__ */ diff --git a/libraries/external/freeglut/pc/include/GL/freeglut_std.h b/libraries/external/freeglut/pc/include/GL/freeglut_std.h new file mode 100755 index 0000000..b42e0f5 --- /dev/null +++ b/libraries/external/freeglut/pc/include/GL/freeglut_std.h @@ -0,0 +1,547 @@ +#ifndef __FREEGLUT_STD_H__ +#define __FREEGLUT_STD_H__ + +/* + * freeglut_std.h + * + * The GLUT-compatible part of the freeglut library include file + * + * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. + * Written by Pawel W. Olszta, + * Creation date: Thu Dec 2 1999 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef __cplusplus + extern "C" { +#endif + +/* + * Under windows, we have to differentiate between static and dynamic libraries + */ +#if defined(WIN32) +# include +# include +# include +# define WINDOWS +#ifdef FREEGLUT_STATIC +# define FGAPI +# define FGAPIENTRY + +# pragma comment (lib, "freeglut_static.lib") /* link with Win32 static freeglut lib */ + +#else + +# if defined(FREEGLUT_EXPORTS) +# define FGAPI __declspec(dllexport) +/* # define FGAPI */ +# else +# define FGAPI __declspec(dllimport) +# pragma comment (lib, "freeglut.lib") /* link with Win32 freeglut lib */ +# endif +# define FGAPIENTRY __stdcall + +#endif + +#pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */ +#pragma comment (lib, "user32.lib") /* link with Windows user lib */ +#pragma comment (lib, "gdi32.lib") /* link with Windows GDI lib */ +#pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */ +#pragma comment (lib, "glu32.lib") /* link with OpenGL Utility lib */ + + +#else +# define FGAPI +# define FGAPIENTRY +#endif + +/* + * The freeglut and GLUT API versions + */ +#define FREEGLUT 1 +#define GLUT_API_VERSION 4 +#define FREEGLUT_VERSION_2_0 1 + +/* + * Always include OpenGL and GLU headers + */ +#include +#include + +/* + * GLUT API macro definitions -- the special key codes: + */ +#define GLUT_KEY_F1 0x0001 +#define GLUT_KEY_F2 0x0002 +#define GLUT_KEY_F3 0x0003 +#define GLUT_KEY_F4 0x0004 +#define GLUT_KEY_F5 0x0005 +#define GLUT_KEY_F6 0x0006 +#define GLUT_KEY_F7 0x0007 +#define GLUT_KEY_F8 0x0008 +#define GLUT_KEY_F9 0x0009 +#define GLUT_KEY_F10 0x000A +#define GLUT_KEY_F11 0x000B +#define GLUT_KEY_F12 0x000C +#define GLUT_KEY_LEFT 0x0064 +#define GLUT_KEY_UP 0x0065 +#define GLUT_KEY_RIGHT 0x0066 +#define GLUT_KEY_DOWN 0x0067 +#define GLUT_KEY_PAGE_UP 0x0068 +#define GLUT_KEY_PAGE_DOWN 0x0069 +#define GLUT_KEY_HOME 0x006A +#define GLUT_KEY_END 0x006B +#define GLUT_KEY_INSERT 0x006C + +/* + * GLUT API macro definitions -- mouse state definitions + */ +#define GLUT_LEFT_BUTTON 0x0000 +#define GLUT_MIDDLE_BUTTON 0x0001 +#define GLUT_RIGHT_BUTTON 0x0002 +#define GLUT_DOWN 0x0000 +#define GLUT_UP 0x0001 +#define GLUT_LEFT 0x0000 +#define GLUT_ENTERED 0x0001 + +/* + * GLUT API macro definitions -- the display mode definitions + */ +#define GLUT_RGB 0x0000 +#define GLUT_RGBA 0x0000 +#define GLUT_INDEX 0x0001 +#define GLUT_SINGLE 0x0000 +#define GLUT_DOUBLE 0x0002 +#define GLUT_ACCUM 0x0004 +#define GLUT_ALPHA 0x0008 +#define GLUT_DEPTH 0x0010 +#define GLUT_STENCIL 0x0020 +#define GLUT_MULTISAMPLE 0x0080 +#define GLUT_STEREO 0x0100 +#define GLUT_LUMINANCE 0x0200 + +/* + * GLUT API macro definitions -- windows and menu related definitions + */ +#define GLUT_MENU_NOT_IN_USE 0x0000 +#define GLUT_MENU_IN_USE 0x0001 +#define GLUT_NOT_VISIBLE 0x0000 +#define GLUT_VISIBLE 0x0001 +#define GLUT_HIDDEN 0x0000 +#define GLUT_FULLY_RETAINED 0x0001 +#define GLUT_PARTIALLY_RETAINED 0x0002 +#define GLUT_FULLY_COVERED 0x0003 + +/* + * GLUT API macro definitions -- fonts definitions + * + * Steve Baker suggested to make it binary compatible with GLUT: + */ +#if defined(WIN32) +# define GLUT_STROKE_ROMAN ((void *)0x0000) +# define GLUT_STROKE_MONO_ROMAN ((void *)0x0001) +# define GLUT_BITMAP_9_BY_15 ((void *)0x0002) +# define GLUT_BITMAP_8_BY_13 ((void *)0x0003) +# define GLUT_BITMAP_TIMES_ROMAN_10 ((void *)0x0004) +# define GLUT_BITMAP_TIMES_ROMAN_24 ((void *)0x0005) +# define GLUT_BITMAP_HELVETICA_10 ((void *)0x0006) +# define GLUT_BITMAP_HELVETICA_12 ((void *)0x0007) +# define GLUT_BITMAP_HELVETICA_18 ((void *)0x0008) +#else + /* + * I don't really know if it's a good idea... But here it goes: + */ + extern void* glutStrokeRoman; + extern void* glutStrokeMonoRoman; + extern void* glutBitmap9By15; + extern void* glutBitmap8By13; + extern void* glutBitmapTimesRoman10; + extern void* glutBitmapTimesRoman24; + extern void* glutBitmapHelvetica10; + extern void* glutBitmapHelvetica12; + extern void* glutBitmapHelvetica18; + + /* + * Those pointers will be used by following definitions: + */ +# define GLUT_STROKE_ROMAN ((void *) &glutStrokeRoman) +# define GLUT_STROKE_MONO_ROMAN ((void *) &glutStrokeMonoRoman) +# define GLUT_BITMAP_9_BY_15 ((void *) &glutBitmap9By15) +# define GLUT_BITMAP_8_BY_13 ((void *) &glutBitmap8By13) +# define GLUT_BITMAP_TIMES_ROMAN_10 ((void *) &glutBitmapTimesRoman10) +# define GLUT_BITMAP_TIMES_ROMAN_24 ((void *) &glutBitmapTimesRoman24) +# define GLUT_BITMAP_HELVETICA_10 ((void *) &glutBitmapHelvetica10) +# define GLUT_BITMAP_HELVETICA_12 ((void *) &glutBitmapHelvetica12) +# define GLUT_BITMAP_HELVETICA_18 ((void *) &glutBitmapHelvetica18) +#endif + +/* + * GLUT API macro definitions -- the glutGet parameters + */ +#define GLUT_WINDOW_X 0x0064 +#define GLUT_WINDOW_Y 0x0065 +#define GLUT_WINDOW_WIDTH 0x0066 +#define GLUT_WINDOW_HEIGHT 0x0067 +#define GLUT_WINDOW_BUFFER_SIZE 0x0068 +#define GLUT_WINDOW_STENCIL_SIZE 0x0069 +#define GLUT_WINDOW_DEPTH_SIZE 0x006A +#define GLUT_WINDOW_RED_SIZE 0x006B +#define GLUT_WINDOW_GREEN_SIZE 0x006C +#define GLUT_WINDOW_BLUE_SIZE 0x006D +#define GLUT_WINDOW_ALPHA_SIZE 0x006E +#define GLUT_WINDOW_ACCUM_RED_SIZE 0x006F +#define GLUT_WINDOW_ACCUM_GREEN_SIZE 0x0070 +#define GLUT_WINDOW_ACCUM_BLUE_SIZE 0x0071 +#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 0x0072 +#define GLUT_WINDOW_DOUBLEBUFFER 0x0073 +#define GLUT_WINDOW_RGBA 0x0074 +#define GLUT_WINDOW_PARENT 0x0075 +#define GLUT_WINDOW_NUM_CHILDREN 0x0076 +#define GLUT_WINDOW_COLORMAP_SIZE 0x0077 +#define GLUT_WINDOW_NUM_SAMPLES 0x0078 +#define GLUT_WINDOW_STEREO 0x0079 +#define GLUT_WINDOW_CURSOR 0x007A + +#define GLUT_SCREEN_WIDTH 0x00C8 +#define GLUT_SCREEN_HEIGHT 0x00C9 +#define GLUT_SCREEN_WIDTH_MM 0x00CA +#define GLUT_SCREEN_HEIGHT_MM 0x00CB +#define GLUT_MENU_NUM_ITEMS 0x012C +#define GLUT_DISPLAY_MODE_POSSIBLE 0x0190 +#define GLUT_INIT_WINDOW_X 0x01F4 +#define GLUT_INIT_WINDOW_Y 0x01F5 +#define GLUT_INIT_WINDOW_WIDTH 0x01F6 +#define GLUT_INIT_WINDOW_HEIGHT 0x01F7 +#define GLUT_INIT_DISPLAY_MODE 0x01F8 +#define GLUT_ELAPSED_TIME 0x02BC +#define GLUT_WINDOW_FORMAT_ID 0x007B +#define GLUT_INIT_STATE 0x007C + +/* + * GLUT API macro definitions -- the glutDeviceGet parameters + */ +#define GLUT_HAS_KEYBOARD 0x0258 +#define GLUT_HAS_MOUSE 0x0259 +#define GLUT_HAS_SPACEBALL 0x025A +#define GLUT_HAS_DIAL_AND_BUTTON_BOX 0x025B +#define GLUT_HAS_TABLET 0x025C +#define GLUT_NUM_MOUSE_BUTTONS 0x025D +#define GLUT_NUM_SPACEBALL_BUTTONS 0x025E +#define GLUT_NUM_BUTTON_BOX_BUTTONS 0x025F +#define GLUT_NUM_DIALS 0x0260 +#define GLUT_NUM_TABLET_BUTTONS 0x0261 +#define GLUT_DEVICE_IGNORE_KEY_REPEAT 0x0262 +#define GLUT_DEVICE_KEY_REPEAT 0x0263 +#define GLUT_HAS_JOYSTICK 0x0264 +#define GLUT_OWNS_JOYSTICK 0x0265 +#define GLUT_JOYSTICK_BUTTONS 0x0266 +#define GLUT_JOYSTICK_AXES 0x0267 +#define GLUT_JOYSTICK_POLL_RATE 0x0268 + +/* + * GLUT API macro definitions -- the glutLayerGet parameters + */ +#define GLUT_OVERLAY_POSSIBLE 0x0320 +#define GLUT_LAYER_IN_USE 0x0321 +#define GLUT_HAS_OVERLAY 0x0322 +#define GLUT_TRANSPARENT_INDEX 0x0323 +#define GLUT_NORMAL_DAMAGED 0x0324 +#define GLUT_OVERLAY_DAMAGED 0x0325 + +/* + * GLUT API macro definitions -- the glutVideoResizeGet parameters + */ +#define GLUT_VIDEO_RESIZE_POSSIBLE 0x0384 +#define GLUT_VIDEO_RESIZE_IN_USE 0x0385 +#define GLUT_VIDEO_RESIZE_X_DELTA 0x0386 +#define GLUT_VIDEO_RESIZE_Y_DELTA 0x0387 +#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 0x0388 +#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 0x0389 +#define GLUT_VIDEO_RESIZE_X 0x038A +#define GLUT_VIDEO_RESIZE_Y 0x038B +#define GLUT_VIDEO_RESIZE_WIDTH 0x038C +#define GLUT_VIDEO_RESIZE_HEIGHT 0x038D + +/* + * GLUT API macro definitions -- the glutUseLayer parameters + */ +#define GLUT_NORMAL 0x0000 +#define GLUT_OVERLAY 0x0001 + +/* + * GLUT API macro definitions -- the glutGetModifiers parameters + */ +#define GLUT_ACTIVE_SHIFT 0x0001 +#define GLUT_ACTIVE_CTRL 0x0002 +#define GLUT_ACTIVE_ALT 0x0004 + +/* + * GLUT API macro definitions -- the glutSetCursor parameters + */ +#define GLUT_CURSOR_RIGHT_ARROW 0x0000 +#define GLUT_CURSOR_LEFT_ARROW 0x0001 +#define GLUT_CURSOR_INFO 0x0002 +#define GLUT_CURSOR_DESTROY 0x0003 +#define GLUT_CURSOR_HELP 0x0004 +#define GLUT_CURSOR_CYCLE 0x0005 +#define GLUT_CURSOR_SPRAY 0x0006 +#define GLUT_CURSOR_WAIT 0x0007 +#define GLUT_CURSOR_TEXT 0x0008 +#define GLUT_CURSOR_CROSSHAIR 0x0009 +#define GLUT_CURSOR_UP_DOWN 0x000A +#define GLUT_CURSOR_LEFT_RIGHT 0x000B +#define GLUT_CURSOR_TOP_SIDE 0x000C +#define GLUT_CURSOR_BOTTOM_SIDE 0x000D +#define GLUT_CURSOR_LEFT_SIDE 0x000E +#define GLUT_CURSOR_RIGHT_SIDE 0x000F +#define GLUT_CURSOR_TOP_LEFT_CORNER 0x0010 +#define GLUT_CURSOR_TOP_RIGHT_CORNER 0x0011 +#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 0x0012 +#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 0x0013 +#define GLUT_CURSOR_INHERIT 0x0064 +#define GLUT_CURSOR_NONE 0x0065 +#define GLUT_CURSOR_FULL_CROSSHAIR 0x0066 + +/* + * GLUT API macro definitions -- RGB color component specification definitions + */ +#define GLUT_RED 0x0000 +#define GLUT_GREEN 0x0001 +#define GLUT_BLUE 0x0002 + +/* + * GLUT API macro definitions -- additional keyboard and joystick definitions + */ +#define GLUT_KEY_REPEAT_OFF 0x0000 +#define GLUT_KEY_REPEAT_ON 0x0001 +#define GLUT_KEY_REPEAT_DEFAULT 0x0002 + +#define GLUT_JOYSTICK_BUTTON_A 0x0001 +#define GLUT_JOYSTICK_BUTTON_B 0x0002 +#define GLUT_JOYSTICK_BUTTON_C 0x0004 +#define GLUT_JOYSTICK_BUTTON_D 0x0008 + +/* + * GLUT API macro definitions -- game mode definitions + */ +#define GLUT_GAME_MODE_ACTIVE 0x0000 +#define GLUT_GAME_MODE_POSSIBLE 0x0001 +#define GLUT_GAME_MODE_WIDTH 0x0002 +#define GLUT_GAME_MODE_HEIGHT 0x0003 +#define GLUT_GAME_MODE_PIXEL_DEPTH 0x0004 +#define GLUT_GAME_MODE_REFRESH_RATE 0x0005 +#define GLUT_GAME_MODE_DISPLAY_CHANGED 0x0006 + +/* + * Initialization functions, see fglut_init.c + */ +FGAPI void FGAPIENTRY glutInit( int* pargc, char** argv ); +FGAPI void FGAPIENTRY glutInitWindowPosition( int x, int y ); +FGAPI void FGAPIENTRY glutInitWindowSize( int width, int height ); +FGAPI void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode ); +FGAPI void FGAPIENTRY glutInitDisplayString( const char* displayMode ); + +/* + * Process loop function, see freeglut_main.c + */ +FGAPI void FGAPIENTRY glutMainLoop( void ); + +/* + * Window management functions, see freeglut_window.c + */ +FGAPI int FGAPIENTRY glutCreateWindow( const char* title ); +FGAPI int FGAPIENTRY glutCreateSubWindow( int window, int x, int y, int width, int height ); +FGAPI void FGAPIENTRY glutDestroyWindow( int window ); +FGAPI void FGAPIENTRY glutSetWindow( int window ); +FGAPI int FGAPIENTRY glutGetWindow( void ); +FGAPI void FGAPIENTRY glutSetWindowTitle( const char* title ); +FGAPI void FGAPIENTRY glutSetIconTitle( const char* title ); +FGAPI void FGAPIENTRY glutReshapeWindow( int width, int height ); +FGAPI void FGAPIENTRY glutPositionWindow( int x, int y ); +FGAPI void FGAPIENTRY glutShowWindow( void ); +FGAPI void FGAPIENTRY glutHideWindow( void ); +FGAPI void FGAPIENTRY glutIconifyWindow( void ); +FGAPI void FGAPIENTRY glutPushWindow( void ); +FGAPI void FGAPIENTRY glutPopWindow( void ); +FGAPI void FGAPIENTRY glutFullScreen( void ); + +/* + * Display-connected functions, see freeglut_display.c + */ +FGAPI void FGAPIENTRY glutPostWindowRedisplay( int window ); +FGAPI void FGAPIENTRY glutPostRedisplay( void ); +FGAPI void FGAPIENTRY glutSwapBuffers( void ); + +/* + * Mouse cursor functions, see freeglut_cursor.c + */ +FGAPI void FGAPIENTRY glutWarpPointer( int x, int y ); +FGAPI void FGAPIENTRY glutSetCursor( int cursor ); + +/* + * Overlay stuff, see freeglut_overlay.c + */ +FGAPI void FGAPIENTRY glutEstablishOverlay( void ); +FGAPI void FGAPIENTRY glutRemoveOverlay( void ); +FGAPI void FGAPIENTRY glutUseLayer( GLenum layer ); +FGAPI void FGAPIENTRY glutPostOverlayRedisplay( void ); +FGAPI void FGAPIENTRY glutPostWindowOverlayRedisplay( int window ); +FGAPI void FGAPIENTRY glutShowOverlay( void ); +FGAPI void FGAPIENTRY glutHideOverlay( void ); + +/* + * Menu stuff, see freeglut_menu.c + */ +FGAPI int FGAPIENTRY glutCreateMenu( void (* callback)( int menu ) ); +FGAPI void FGAPIENTRY glutDestroyMenu( int menu ); +FGAPI int FGAPIENTRY glutGetMenu( void ); +FGAPI void FGAPIENTRY glutSetMenu( int menu ); +FGAPI void FGAPIENTRY glutAddMenuEntry( const char* label, int value ); +FGAPI void FGAPIENTRY glutAddSubMenu( const char* label, int subMenu ); +FGAPI void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value ); +FGAPI void FGAPIENTRY glutChangeToSubMenu( int item, const char* label, int value ); +FGAPI void FGAPIENTRY glutRemoveMenuItem( int item ); +FGAPI void FGAPIENTRY glutAttachMenu( int button ); +FGAPI void FGAPIENTRY glutDetachMenu( int button ); + +/* + * Global callback functions, see freeglut_callbacks.c + */ +FGAPI void FGAPIENTRY glutTimerFunc( unsigned int time, void (* callback)( int ), int value ); +FGAPI void FGAPIENTRY glutIdleFunc( void (* callback)( void ) ); + +/* + * Window-specific callback functions, see freeglut_callbacks.c + */ +FGAPI void FGAPIENTRY glutKeyboardFunc( void (* callback)( unsigned char, int, int ) ); +FGAPI void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) ); +FGAPI void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) ); +FGAPI void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) ); +FGAPI void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) ); +FGAPI void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutEntryFunc( void (* callback)( int ) ); + +FGAPI void FGAPIENTRY glutKeyboardUpFunc( void (* callback)( unsigned char, int, int ) ); +FGAPI void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) ); +FGAPI void FGAPIENTRY glutJoystickFunc( void (* callback)( unsigned int, int, int, int ), int pollInterval ); +FGAPI void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) ); +FGAPI void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) ); +FGAPI void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) ); +FGAPI void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) ); + +FGAPI void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) ); +FGAPI void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) ); +FGAPI void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) ); + +/* + * State setting and retrieval functions, see freeglut_state.c + */ +FGAPI int FGAPIENTRY glutGet( GLenum query ); +FGAPI int FGAPIENTRY glutDeviceGet( GLenum query ); +FGAPI int FGAPIENTRY glutGetModifiers( void ); +FGAPI int FGAPIENTRY glutLayerGet( GLenum query ); + +/* + * Font stuff, see freeglut_font.c + */ +FGAPI void FGAPIENTRY glutBitmapCharacter( void* font, int character ); +FGAPI int FGAPIENTRY glutBitmapWidth( void* font, int character ); +FGAPI void FGAPIENTRY glutStrokeCharacter( void* font, int character ); +FGAPI int FGAPIENTRY glutStrokeWidth( void* font, int character ); +FGAPI int FGAPIENTRY glutBitmapLength( void* font, const unsigned char* string ); +FGAPI int FGAPIENTRY glutStrokeLength( void* font, const unsigned char* string ); + +/* + * Geometry functions, see freeglut_geometry.c + */ +FGAPI void FGAPIENTRY glutWireCube( GLdouble size ); +FGAPI void FGAPIENTRY glutSolidCube( GLdouble size ); +FGAPI void FGAPIENTRY glutWireSphere( GLdouble radius, GLint slices, GLint stacks ); +FGAPI void FGAPIENTRY glutSolidSphere( GLdouble radius, GLint slices, GLint stacks ); +FGAPI void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks ); +FGAPI void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks ); + +FGAPI void FGAPIENTRY glutWireTorus( GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings ); +FGAPI void FGAPIENTRY glutSolidTorus( GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings ); +FGAPI void FGAPIENTRY glutWireDodecahedron( void ); +FGAPI void FGAPIENTRY glutSolidDodecahedron( void ); +FGAPI void FGAPIENTRY glutWireOctahedron( void ); +FGAPI void FGAPIENTRY glutSolidOctahedron( void ); +FGAPI void FGAPIENTRY glutWireTetrahedron( void ); +FGAPI void FGAPIENTRY glutSolidTetrahedron( void ); +FGAPI void FGAPIENTRY glutWireIcosahedron( void ); +FGAPI void FGAPIENTRY glutSolidIcosahedron( void ); + +/* + * Teapot rendering functions, found in freeglut_teapot.c + */ +FGAPI void FGAPIENTRY glutWireTeapot( GLdouble size ); +FGAPI void FGAPIENTRY glutSolidTeapot( GLdouble size ); + +/* + * Game mode functions, see freeglut_gamemode.c + */ +FGAPI void FGAPIENTRY glutGameModeString( const char* string ); +FGAPI int FGAPIENTRY glutEnterGameMode( void ); +FGAPI void FGAPIENTRY glutLeaveGameMode( void ); +FGAPI int FGAPIENTRY glutGameModeGet( GLenum query ); + +/* + * Video resize functions, see freeglut_videoresize.c + */ +FGAPI int FGAPIENTRY glutVideoResizeGet( GLenum query ); +FGAPI void FGAPIENTRY glutSetupVideoResizing( void ); +FGAPI void FGAPIENTRY glutStopVideoResizing( void ); +FGAPI void FGAPIENTRY glutVideoResize( int x, int y, int width, int height ); +FGAPI void FGAPIENTRY glutVideoPan( int x, int y, int width, int height ); + +/* + * Colormap functions, see freeglut_misc.c + */ +FGAPI void FGAPIENTRY glutSetColor( int color, GLfloat red, GLfloat green, GLfloat blue ); +FGAPI GLfloat FGAPIENTRY glutGetColor( int color, int component ); +FGAPI void FGAPIENTRY glutCopyColormap( int window ); + +/* + * Misc keyboard and joystick functions, see freeglut_misc.c + */ +FGAPI void FGAPIENTRY glutIgnoreKeyRepeat( int ignore ); +FGAPI void FGAPIENTRY glutSetKeyRepeat( int repeatMode ); /* DEPRECATED 11/4/02 - Do not use */ +FGAPI void FGAPIENTRY glutForceJoystickFunc( void ); + +/* + * Misc functions, see freeglut_misc.c + */ +FGAPI int FGAPIENTRY glutExtensionSupported( const char* extension ); +FGAPI void FGAPIENTRY glutReportErrors( void ); + +#ifdef __cplusplus + } +#endif + +/*** END OF FILE ***/ + +#endif /* __FREEGLUT_STD_H__ */ + diff --git a/libraries/external/freeglut/pc/include/GL/vssver.scc b/libraries/external/freeglut/pc/include/GL/vssver.scc new file mode 100755 index 0000000..0885fe8 Binary files /dev/null and b/libraries/external/freeglut/pc/include/GL/vssver.scc differ diff --git a/libraries/external/freeglut/pc/lib/freeglut.lib b/libraries/external/freeglut/pc/lib/freeglut.lib new file mode 100755 index 0000000..3555f4f Binary files /dev/null and b/libraries/external/freeglut/pc/lib/freeglut.lib differ diff --git a/libraries/external/freeglut/pc/lib/vssver.scc b/libraries/external/freeglut/pc/lib/vssver.scc new file mode 100755 index 0000000..3996d1f Binary files /dev/null and b/libraries/external/freeglut/pc/lib/vssver.scc differ diff --git a/libraries/external/freeglut/vssver.scc b/libraries/external/freeglut/vssver.scc new file mode 100755 index 0000000..0eb4ac5 Binary files /dev/null and b/libraries/external/freeglut/vssver.scc differ diff --git a/libraries/external/glew/glew-1.4.0-src.tgz b/libraries/external/glew/glew-1.4.0-src.tgz new file mode 100755 index 0000000..d309c69 Binary files /dev/null and b/libraries/external/glew/glew-1.4.0-src.tgz differ diff --git a/libraries/external/glew/glew-1.4.0-win32.zip b/libraries/external/glew/glew-1.4.0-win32.zip new file mode 100755 index 0000000..f859cf3 Binary files /dev/null and b/libraries/external/glew/glew-1.4.0-win32.zip differ diff --git a/libraries/external/glew/linux/include/GL/glew.h b/libraries/external/glew/linux/include/GL/glew.h new file mode 100755 index 0000000..0bae8c1 --- /dev/null +++ b/libraries/external/glew/linux/include/GL/glew.h @@ -0,0 +1,10716 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2007, Milan Ikits +** Copyright (C) 2002-2007, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#ifndef __glew_h__ +#define __glew_h__ +#define __GLEW_H__ + +#if defined(__gl_h_) || defined(__GL_H__) +#error gl.h included before glew.h +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) +#error glext.h included before glew.h +#endif +#if defined(__gl_ATI_h_) +#error glATI.h included before glew.h +#endif + +#define __gl_h_ +#define __GL_H__ +#define __glext_h_ +#define __GLEXT_H_ +#define __gl_ATI_h_ + +#if defined(_WIN32) + +/* + * GLEW does not include to avoid name space pollution. + * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t + * defined properly. + */ +/* */ +#ifndef APIENTRY +#define GLEW_APIENTRY_DEFINED +# if defined(__MINGW32__) +# define APIENTRY __stdcall +# elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) +# define APIENTRY __stdcall +# else +# define APIENTRY +# endif +#endif +#ifndef GLAPI +# if defined(__MINGW32__) +# define GLAPI extern +# endif +#endif +/* */ +#ifndef CALLBACK +#define GLEW_CALLBACK_DEFINED +# if defined(__MINGW32__) +# define CALLBACK __attribute__ ((__stdcall__)) +# elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) +# define CALLBACK __stdcall +# else +# define CALLBACK +# endif +#endif +/* and */ +#ifndef WINGDIAPI +#define GLEW_WINGDIAPI_DEFINED +#define WINGDIAPI __declspec(dllimport) +#endif +/* */ +#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +#endif +/* */ +#if !defined(_W64) +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif +#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) +# ifdef _WIN64 +typedef __int64 ptrdiff_t; +# else +typedef _W64 int ptrdiff_t; +# endif +# define _PTRDIFF_T_DEFINED +# define _PTRDIFF_T_ +#endif + +#ifndef GLAPI +# if defined(__MINGW32__) +# define GLAPI extern +# else +# define GLAPI WINGDIAPI +# endif +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY APIENTRY +#endif + +/* + * GLEW_STATIC needs to be set when using the static version. + * GLEW_BUILD is set when building the DLL version. + */ +#ifdef GLEW_STATIC +# define GLEWAPI extern +#else +# ifdef GLEW_BUILD +# define GLEWAPI extern __declspec(dllexport) +# else +# define GLEWAPI extern __declspec(dllimport) +# endif +#endif + +#else /* _UNIX */ + +/* + * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO + * C. On my system, this amounts to _3 lines_ of included code, all of + * them pretty much harmless. If you know of a way of detecting 32 vs + * 64 _targets_ at compile time you are free to replace this with + * something that's portable. For now, _this_ is the portable solution. + * (mem, 2004-01-04) + */ + +#include + +#define GLEW_APIENTRY_DEFINED +#define APIENTRY +#define GLEWAPI extern + +/* */ +#ifndef GLAPI +#define GLAPI extern +#endif +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#endif /* _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 + +#if defined(__APPLE__) +typedef unsigned long GLenum; +typedef unsigned long GLbitfield; +typedef unsigned long GLuint; +typedef long GLint; +typedef long GLsizei; +#else +typedef unsigned int GLenum; +typedef unsigned int GLbitfield; +typedef unsigned int GLuint; +typedef int GLint; +typedef int GLsizei; +#endif +typedef unsigned char GLboolean; +typedef signed char GLbyte; +typedef short GLshort; +typedef unsigned char GLubyte; +typedef unsigned short GLushort; +typedef float GLfloat; +typedef float GLclampf; +typedef double GLdouble; +typedef double GLclampd; +typedef void GLvoid; +#if defined(_MSC_VER) && _MSC_VER < 1310 +# ifdef _WIN64 +typedef __int64 GLint64EXT; +typedef unsigned __int64 GLuint64EXT; +# else +typedef _W64 int GLint64EXT; +typedef _W64 unsigned int GLuint64EXT; +# endif +#else +typedef signed long long GLint64EXT; +typedef unsigned long long GLuint64EXT; +#endif + +#define GL_ACCUM 0x0100 +#define GL_LOAD 0x0101 +#define GL_RETURN 0x0102 +#define GL_MULT 0x0103 +#define GL_ADD 0x0104 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000fffff +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_TRUE 1 +#define GL_FALSE 0 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LIST_MODE 0x0B30 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_SHADE_MODEL 0x0B54 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_FOG 0x0B60 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_NORMALIZE 0x0BA1 +#define GL_VIEWPORT 0x0BA2 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_INDEX_MODE 0x0C30 +#define GL_RGBA_MODE 0x0C31 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_RENDER_MODE 0x0C40 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_INDEX_BITS 0x0D51 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_COLOR_INDEX 0x1900 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_BITMAP 0x1A00 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_RENDER 0x1C00 +#define GL_FEEDBACK 0x1C01 +#define GL_SELECT 0x1C02 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_ENV 0x2300 +#define GL_EYE_LINEAR 0x2400 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_SPHERE_MAP 0x2402 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_PLANE 0x2502 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_CLAMP 0x2900 +#define GL_REPEAT 0x2901 +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D +#define GL_LOGIC_OP GL_INDEX_LOGIC_OP +#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 + +GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); +GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); +GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void GLAPIENTRY glArrayElement (GLint i); +GLAPI void GLAPIENTRY glBegin (GLenum mode); +GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); +GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GLAPI void GLAPIENTRY glCallList (GLuint list); +GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); +GLAPI void GLAPIENTRY glClear (GLbitfield mask); +GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); +GLAPI void GLAPIENTRY glClearIndex (GLfloat c); +GLAPI void GLAPIENTRY glClearStencil (GLint s); +GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); +GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); +GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); +GLAPI void GLAPIENTRY glColor3iv (const GLint *v); +GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); +GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); +GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); +GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); +GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); +GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void GLAPIENTRY glColor4iv (const GLint *v); +GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); +GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); +GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); +GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); +GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); +GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); +GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); +GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void GLAPIENTRY glCullFace (GLenum mode); +GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); +GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GLAPI void GLAPIENTRY glDepthFunc (GLenum func); +GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); +GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); +GLAPI void GLAPIENTRY glDisable (GLenum cap); +GLAPI void GLAPIENTRY glDisableClientState (GLenum array); +GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); +GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); +GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); +GLAPI void GLAPIENTRY glEnable (GLenum cap); +GLAPI void GLAPIENTRY glEnableClientState (GLenum array); +GLAPI void GLAPIENTRY glEnd (void); +GLAPI void GLAPIENTRY glEndList (void); +GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); +GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); +GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); +GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); +GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); +GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); +GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); +GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); +GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); +GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); +GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); +GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); +GLAPI void GLAPIENTRY glFinish (void); +GLAPI void GLAPIENTRY glFlush (void); +GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glFrontFace (GLenum mode); +GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); +GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); +GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); +GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); +GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); +GLAPI GLenum GLAPIENTRY glGetError (void); +GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); +GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); +GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); +GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); +GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); +GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); +GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params); +GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); +GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); +GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); +GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); +GLAPI void GLAPIENTRY glIndexMask (GLuint mask); +GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glIndexd (GLdouble c); +GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); +GLAPI void GLAPIENTRY glIndexf (GLfloat c); +GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); +GLAPI void GLAPIENTRY glIndexi (GLint c); +GLAPI void GLAPIENTRY glIndexiv (const GLint *c); +GLAPI void GLAPIENTRY glIndexs (GLshort c); +GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); +GLAPI void GLAPIENTRY glIndexub (GLubyte c); +GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); +GLAPI void GLAPIENTRY glInitNames (void); +GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); +GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); +GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); +GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); +GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); +GLAPI void GLAPIENTRY glLineWidth (GLfloat width); +GLAPI void GLAPIENTRY glListBase (GLuint base); +GLAPI void GLAPIENTRY glLoadIdentity (void); +GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); +GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); +GLAPI void GLAPIENTRY glLoadName (GLuint name); +GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); +GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); +GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); +GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); +GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); +GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); +GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); +GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); +GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); +GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); +GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); +GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); +GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void GLAPIENTRY glPassThrough (GLfloat token); +GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); +GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); +GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); +GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); +GLAPI void GLAPIENTRY glPointSize (GLfloat size); +GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); +GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); +GLAPI void GLAPIENTRY glPopAttrib (void); +GLAPI void GLAPIENTRY glPopClientAttrib (void); +GLAPI void GLAPIENTRY glPopMatrix (void); +GLAPI void GLAPIENTRY glPopName (void); +GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); +GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); +GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); +GLAPI void GLAPIENTRY glPushMatrix (void); +GLAPI void GLAPIENTRY glPushName (GLuint name); +GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); +GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); +GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); +GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); +GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); +GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); +GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); +GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); +GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); +GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); +GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); +GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); +GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); +GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); +GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); +GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); +GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); +GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); +GLAPI void GLAPIENTRY glShadeModel (GLenum mode); +GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GLAPI void GLAPIENTRY glStencilMask (GLuint mask); +GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); +GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); +GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord1i (GLint s); +GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); +GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); +GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); +GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); +GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); +GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); +GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); +GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); +GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); +GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); +GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); +GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) + +#endif /* GL_VERSION_1_1 */ + +/* ---------------------------------- GLU ---------------------------------- */ + +/* this is where we can safely include GLU */ +#if defined(__APPLE__) && defined(__MACH__) +#include +#else +#include +#endif + +/* ----------------------------- GL_VERSION_1_2 ---------------------------- */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 + +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E + +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + +#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) +#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) +#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) +#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) + +#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) + +#endif /* GL_VERSION_1_2 */ + +/* ----------------------------- GL_VERSION_1_3 ---------------------------- */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 + +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_SUBTRACT 0x84E7 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#define GL_MULTISAMPLE_BIT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); + +#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) +#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) +#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) +#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) +#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) +#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) +#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) +#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) +#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) +#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) +#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) +#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) +#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) +#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) +#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) +#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) +#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) +#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) +#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) +#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) +#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) +#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) +#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) +#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) +#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) +#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) +#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) +#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) +#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) +#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) +#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) +#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) +#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) +#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) +#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) +#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) +#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) +#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) +#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) +#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) +#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) +#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) +#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) +#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) +#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) +#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) + +#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) + +#endif /* GL_VERSION_1_3 */ + +/* ----------------------------- GL_VERSION_1_4 ---------------------------- */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 + +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E + +typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); + +#define glBlendColor GLEW_GET_FUN(__glewBlendColor) +#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) +#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) +#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) +#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) +#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) +#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) +#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) +#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) +#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) +#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) +#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) +#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) +#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) +#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) +#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) +#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) +#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) +#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) +#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) +#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) +#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) +#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) +#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) +#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) +#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) +#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) +#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) +#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) +#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) +#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) +#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) +#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) +#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) +#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) +#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) +#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) +#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) +#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) +#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) +#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) +#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) +#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) +#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) +#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) + +#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) + +#endif /* GL_VERSION_1_4 */ + +/* ----------------------------- GL_VERSION_1_5 ---------------------------- */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 + +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 + +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); +typedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); + +#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) +#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) +#define glBufferData GLEW_GET_FUN(__glewBufferData) +#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) +#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) +#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) +#define glEndQuery GLEW_GET_FUN(__glewEndQuery) +#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) +#define glGenQueries GLEW_GET_FUN(__glewGenQueries) +#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) +#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) +#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) +#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) +#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) +#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) +#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) +#define glIsQuery GLEW_GET_FUN(__glewIsQuery) +#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) +#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) + +#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) + +#endif /* GL_VERSION_1_5 */ + +/* ----------------------------- GL_VERSION_2_0 ---------------------------- */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 + +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 + +typedef char GLchar; + +typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); +typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); +typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); +typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); +typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); +typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); +typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); +typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); +typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); + +#define glAttachShader GLEW_GET_FUN(__glewAttachShader) +#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) +#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) +#define glCompileShader GLEW_GET_FUN(__glewCompileShader) +#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) +#define glCreateShader GLEW_GET_FUN(__glewCreateShader) +#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) +#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) +#define glDetachShader GLEW_GET_FUN(__glewDetachShader) +#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) +#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) +#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) +#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) +#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) +#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) +#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) +#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) +#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) +#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) +#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) +#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) +#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) +#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) +#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) +#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) +#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) +#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) +#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) +#define glIsProgram GLEW_GET_FUN(__glewIsProgram) +#define glIsShader GLEW_GET_FUN(__glewIsShader) +#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) +#define glShaderSource GLEW_GET_FUN(__glewShaderSource) +#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) +#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) +#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) +#define glUniform1f GLEW_GET_FUN(__glewUniform1f) +#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) +#define glUniform1i GLEW_GET_FUN(__glewUniform1i) +#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) +#define glUniform2f GLEW_GET_FUN(__glewUniform2f) +#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) +#define glUniform2i GLEW_GET_FUN(__glewUniform2i) +#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) +#define glUniform3f GLEW_GET_FUN(__glewUniform3f) +#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) +#define glUniform3i GLEW_GET_FUN(__glewUniform3i) +#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) +#define glUniform4f GLEW_GET_FUN(__glewUniform4f) +#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) +#define glUniform4i GLEW_GET_FUN(__glewUniform4i) +#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) +#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) +#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) +#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) +#define glUseProgram GLEW_GET_FUN(__glewUseProgram) +#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) +#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) +#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) +#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) +#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) +#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) +#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) +#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) +#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) +#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) +#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) +#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) +#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) +#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) +#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) +#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) +#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) +#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) +#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) +#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) +#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) +#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) +#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) +#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) +#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) +#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) +#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) +#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) +#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) +#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) +#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) +#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) +#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) +#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) +#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) +#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) +#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) +#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) + +#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) + +#endif /* GL_VERSION_2_0 */ + +/* ----------------------------- GL_VERSION_2_1 ---------------------------- */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 + +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B + +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + +#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) +#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) +#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) +#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) +#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) +#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) + +#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) + +#endif /* GL_VERSION_2_1 */ + +/* -------------------------- GL_3DFX_multisample -------------------------- */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 + +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 + +#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) + +#endif /* GL_3DFX_multisample */ + +/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 + +typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); + +#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) + +#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) + +#endif /* GL_3DFX_tbuffer */ + +/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 + +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 + +#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) + +#endif /* GL_3DFX_texture_compression_FXT1 */ + +/* ------------------------ GL_APPLE_client_storage ------------------------ */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 + +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 + +#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) + +#endif /* GL_APPLE_client_storage */ + +/* ------------------------- GL_APPLE_element_array ------------------------ */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 + +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A + +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); + +#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) +#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) +#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) +#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) +#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) + +#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) + +#endif /* GL_APPLE_element_array */ + +/* ----------------------------- GL_APPLE_fence ---------------------------- */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 + +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B + +typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); +typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); +typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); + +#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) +#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) +#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) +#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) +#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) +#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) +#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) +#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) + +#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) + +#endif /* GL_APPLE_fence */ + +/* ------------------------- GL_APPLE_float_pixels ------------------------- */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 + +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F + +#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) + +#endif /* GL_APPLE_float_pixels */ + +/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ + +#ifndef GL_APPLE_pixel_buffer +#define GL_APPLE_pixel_buffer 1 + +#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 + +#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) + +#endif /* GL_APPLE_pixel_buffer */ + +/* ------------------------ GL_APPLE_specular_vector ----------------------- */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 + +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 + +#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) + +#endif /* GL_APPLE_specular_vector */ + +/* ------------------------- GL_APPLE_texture_range ------------------------ */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 + +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); +typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer); + +#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) +#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) + +#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) + +#endif /* GL_APPLE_texture_range */ + +/* ------------------------ GL_APPLE_transform_hint ------------------------ */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 + +#define GL_TRANSFORM_HINT_APPLE 0x85B1 + +#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) + +#endif /* GL_APPLE_transform_hint */ + +/* ---------------------- GL_APPLE_vertex_array_object --------------------- */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 + +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 + +typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); +typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); +typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); + +#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) +#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) +#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) +#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) + +#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) + +#endif /* GL_APPLE_vertex_array_object */ + +/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 + +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + +typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); + +#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) +#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) +#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) + +#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) + +#endif /* GL_APPLE_vertex_array_range */ + +/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 + +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB + +#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) + +#endif /* GL_APPLE_ycbcr_422 */ + +/* ----------------------- GL_ARB_color_buffer_float ----------------------- */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 + +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D + +typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); + +#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) + +#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) + +#endif /* GL_ARB_color_buffer_float */ + +/* -------------------------- GL_ARB_depth_texture ------------------------- */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B + +#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) + +#endif /* GL_ARB_depth_texture */ + +/* -------------------------- GL_ARB_draw_buffers -------------------------- */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 + +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 + +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); + +#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) + +#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) + +#endif /* GL_ARB_draw_buffers */ + +/* ------------------------ GL_ARB_fragment_program ------------------------ */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 + +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 + +#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) + +#endif /* GL_ARB_fragment_program */ + +/* --------------------- GL_ARB_fragment_program_shadow -------------------- */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 + +#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) + +#endif /* GL_ARB_fragment_program_shadow */ + +/* ------------------------- GL_ARB_fragment_shader ------------------------ */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 + +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B + +#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) + +#endif /* GL_ARB_fragment_shader */ + +/* ------------------------ GL_ARB_half_float_pixel ------------------------ */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 + +#define GL_HALF_FLOAT_ARB 0x140B + +#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) + +#endif /* GL_ARB_half_float_pixel */ + +/* ----------------------------- GL_ARB_imaging ---------------------------- */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_IGNORE_BORDER 0x8150 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_WRAP_BORDER 0x8152 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 + +typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + +#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) +#define glColorTable GLEW_GET_FUN(__glewColorTable) +#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) +#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) +#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) +#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) +#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) +#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) +#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) +#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) +#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) +#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) +#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) +#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) +#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) +#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) +#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) +#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) +#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) +#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) +#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) +#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) +#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) +#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) +#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) +#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) +#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) +#define glHistogram GLEW_GET_FUN(__glewHistogram) +#define glMinmax GLEW_GET_FUN(__glewMinmax) +#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) +#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) +#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) + +#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) + +#endif /* GL_ARB_imaging */ + +/* ------------------------- GL_ARB_matrix_palette ------------------------- */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 + +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 + +typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); + +#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) +#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) +#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) +#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) +#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) + +#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) + +#endif /* GL_ARB_matrix_palette */ + +/* --------------------------- GL_ARB_multisample -------------------------- */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 + +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); + +#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) + +#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) + +#endif /* GL_ARB_multisample */ + +/* -------------------------- GL_ARB_multitexture -------------------------- */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) +#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) +#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) +#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) +#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) +#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) +#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) +#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) +#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) +#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) +#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) +#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) +#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) +#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) +#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) +#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) +#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) +#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) +#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) +#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) +#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) +#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) +#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) +#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) +#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) +#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) +#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) +#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) +#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) +#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) +#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) +#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) +#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) +#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) + +#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) + +#endif /* GL_ARB_multitexture */ + +/* ------------------------- GL_ARB_occlusion_query ------------------------ */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 + +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); + +#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) +#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) +#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) +#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) +#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) +#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) +#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) +#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) + +#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) + +#endif /* GL_ARB_occlusion_query */ + +/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 + +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF + +#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) + +#endif /* GL_ARB_pixel_buffer_object */ + +/* ------------------------ GL_ARB_point_parameters ------------------------ */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 + +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, GLfloat* params); + +#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) +#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) + +#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) + +#endif /* GL_ARB_point_parameters */ + +/* -------------------------- GL_ARB_point_sprite -------------------------- */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 + +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 + +#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) + +#endif /* GL_ARB_point_sprite */ + +/* ------------------------- GL_ARB_shader_objects ------------------------- */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 + +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 + +typedef char GLcharARB; +typedef unsigned int GLhandleARB; + +typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); +typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); +typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); +typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); + +#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) +#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) +#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) +#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) +#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) +#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) +#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) +#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) +#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) +#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) +#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) +#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) +#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) +#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) +#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) +#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) +#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) +#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) +#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) +#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) +#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) +#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) +#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) +#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) +#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) +#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) +#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) +#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) +#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) +#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) +#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) +#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) +#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) +#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) +#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) +#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) +#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) +#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) +#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) + +#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) + +#endif /* GL_ARB_shader_objects */ + +/* ---------------------- GL_ARB_shading_language_100 ---------------------- */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 + +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C + +#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) + +#endif /* GL_ARB_shading_language_100 */ + +/* ----------------------------- GL_ARB_shadow ----------------------------- */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 + +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E + +#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) + +#endif /* GL_ARB_shadow */ + +/* ------------------------- GL_ARB_shadow_ambient ------------------------- */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 + +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF + +#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) + +#endif /* GL_ARB_shadow_ambient */ + +/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_ARB 0x812D + +#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) + +#endif /* GL_ARB_texture_border_clamp */ + +/* ----------------------- GL_ARB_texture_compression ---------------------- */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 + +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 + +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img); + +#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) +#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) +#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) +#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) +#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) +#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) +#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) + +#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) + +#endif /* GL_ARB_texture_compression */ + +/* ------------------------ GL_ARB_texture_cube_map ------------------------ */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 + +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C + +#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) + +#endif /* GL_ARB_texture_cube_map */ + +/* ------------------------- GL_ARB_texture_env_add ------------------------ */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 + +#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) + +#endif /* GL_ARB_texture_env_add */ + +/* ----------------------- GL_ARB_texture_env_combine ---------------------- */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 + +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A + +#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) + +#endif /* GL_ARB_texture_env_combine */ + +/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 + +#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) + +#endif /* GL_ARB_texture_env_crossbar */ + +/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 + +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF + +#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) + +#endif /* GL_ARB_texture_env_dot3 */ + +/* -------------------------- GL_ARB_texture_float ------------------------- */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 + +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 + +#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) + +#endif /* GL_ARB_texture_float */ + +/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_ARB 0x8370 + +#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) + +#endif /* GL_ARB_texture_mirrored_repeat */ + +/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 + +#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) + +#endif /* GL_ARB_texture_non_power_of_two */ + +/* ------------------------ GL_ARB_texture_rectangle ----------------------- */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 + +#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) + +#endif /* GL_ARB_texture_rectangle */ + +/* ------------------------ GL_ARB_transpose_matrix ------------------------ */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 + +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 + +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); + +#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) +#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) +#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) +#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) + +#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) + +#endif /* GL_ARB_transpose_matrix */ + +/* -------------------------- GL_ARB_vertex_blend -------------------------- */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 + +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F + +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); +typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); + +#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) +#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) +#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) +#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) +#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) +#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) +#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) +#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) +#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) +#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) + +#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) + +#endif /* GL_ARB_vertex_blend */ + +/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 + +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA + +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; + +typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage); +typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data); +typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); + +#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) +#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) +#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) +#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) +#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) +#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) +#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) +#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) +#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) +#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) +#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) + +#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) + +#endif /* GL_ARB_vertex_buffer_object */ + +/* ------------------------- GL_ARB_vertex_program ------------------------- */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 + +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF + +typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); +typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); + +#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) +#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) +#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) +#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) +#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) +#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) +#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) +#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) +#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) +#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) +#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) +#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) +#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) +#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) +#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) +#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) +#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) +#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) +#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) +#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) +#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) +#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) +#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) +#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) +#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) +#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) +#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) +#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) +#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) +#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) +#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) +#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) +#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) +#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) +#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) +#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) +#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) +#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) +#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) +#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) +#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) +#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) +#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) +#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) +#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) +#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) +#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) +#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) +#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) +#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) +#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) +#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) +#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) +#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) +#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) +#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) +#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) +#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) +#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) +#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) +#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) +#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) + +#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) + +#endif /* GL_ARB_vertex_program */ + +/* -------------------------- GL_ARB_vertex_shader ------------------------- */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 + +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A + +typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); +typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); + +#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) +#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) +#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) + +#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) + +#endif /* GL_ARB_vertex_shader */ + +/* --------------------------- GL_ARB_window_pos --------------------------- */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 + +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); + +#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) +#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) +#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) +#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) +#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) +#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) +#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) +#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) +#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) +#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) +#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) +#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) +#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) +#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) +#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) +#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) + +#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) + +#endif /* GL_ARB_window_pos */ + +/* ------------------------- GL_ATIX_point_sprites ------------------------- */ + +#ifndef GL_ATIX_point_sprites +#define GL_ATIX_point_sprites 1 + +#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 +#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 +#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 +#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 +#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 +#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 + +#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) + +#endif /* GL_ATIX_point_sprites */ + +/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ + +#ifndef GL_ATIX_texture_env_combine3 +#define GL_ATIX_texture_env_combine3 1 + +#define GL_MODULATE_ADD_ATIX 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 +#define GL_MODULATE_SUBTRACT_ATIX 0x8746 + +#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) + +#endif /* GL_ATIX_texture_env_combine3 */ + +/* ----------------------- GL_ATIX_texture_env_route ----------------------- */ + +#ifndef GL_ATIX_texture_env_route +#define GL_ATIX_texture_env_route 1 + +#define GL_SECONDARY_COLOR_ATIX 0x8747 +#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 +#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 + +#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) + +#endif /* GL_ATIX_texture_env_route */ + +/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ + +#ifndef GL_ATIX_vertex_shader_output_point_size +#define GL_ATIX_vertex_shader_output_point_size 1 + +#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E + +#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) + +#endif /* GL_ATIX_vertex_shader_output_point_size */ + +/* -------------------------- GL_ATI_draw_buffers -------------------------- */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 + +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 + +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); + +#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) + +#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) + +#endif /* GL_ATI_draw_buffers */ + +/* -------------------------- GL_ATI_element_array ------------------------- */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 + +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A + +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer); + +#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) +#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) +#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) + +#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) + +#endif /* GL_ATI_element_array */ + +/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 + +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C + +typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); + +#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) +#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) +#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) +#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) + +#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) + +#endif /* GL_ATI_envmap_bumpmap */ + +/* ------------------------- GL_ATI_fragment_shader ------------------------ */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 + +#define GL_RED_BIT_ATI 0x00000001 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B + +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); + +#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) +#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) +#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) +#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) +#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) +#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) +#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) +#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) +#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) +#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) +#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) +#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) +#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) +#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) + +#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) + +#endif /* GL_ATI_fragment_shader */ + +/* ------------------------ GL_ATI_map_object_buffer ----------------------- */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 + +typedef void* (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); + +#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) +#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) + +#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) + +#endif /* GL_ATI_map_object_buffer */ + +/* -------------------------- GL_ATI_pn_triangles -------------------------- */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 + +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 + +typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); + +#define glPNTrianglesfATI GLEW_GET_FUN(__glPNTrianglewesfATI) +#define glPNTrianglesiATI GLEW_GET_FUN(__glPNTrianglewesiATI) + +#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) + +#endif /* GL_ATI_pn_triangles */ + +/* ------------------------ GL_ATI_separate_stencil ------------------------ */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 + +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 + +typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + +#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) +#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) + +#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) + +#endif /* GL_ATI_separate_stencil */ + +/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ + +#ifndef GL_ATI_shader_texture_lod +#define GL_ATI_shader_texture_lod 1 + +#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) + +#endif /* GL_ATI_shader_texture_lod */ + +/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 + +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 + +#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) + +#endif /* GL_ATI_text_fragment_shader */ + +/* --------------------- GL_ATI_texture_compression_3dc -------------------- */ + +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 + +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 + +#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) + +#endif /* GL_ATI_texture_compression_3dc */ + +/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 + +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 + +#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) + +#endif /* GL_ATI_texture_env_combine3 */ + +/* -------------------------- GL_ATI_texture_float ------------------------- */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 + +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F + +#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) + +#endif /* GL_ATI_texture_float */ + +/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 + +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 + +#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) + +#endif /* GL_ATI_texture_mirror_once */ + +/* ----------------------- GL_ATI_vertex_array_object ---------------------- */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 + +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 + +typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage); +typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve); +typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + +#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) +#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) +#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) +#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) +#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) +#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) +#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) +#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) +#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) +#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) +#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) +#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) + +#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) + +#endif /* GL_ATI_vertex_array_object */ + +/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 + +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); + +#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) +#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) +#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) + +#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) + +#endif /* GL_ATI_vertex_attrib_array_object */ + +/* ------------------------- GL_ATI_vertex_streams ------------------------- */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 + +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_SOURCE_ATI 0x876C +#define GL_VERTEX_STREAM0_ATI 0x876D +#define GL_VERTEX_STREAM1_ATI 0x876E +#define GL_VERTEX_STREAM2_ATI 0x876F +#define GL_VERTEX_STREAM3_ATI 0x8770 +#define GL_VERTEX_STREAM4_ATI 0x8771 +#define GL_VERTEX_STREAM5_ATI 0x8772 +#define GL_VERTEX_STREAM6_ATI 0x8773 +#define GL_VERTEX_STREAM7_ATI 0x8774 + +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *v); + +#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) +#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) +#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) +#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) +#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) +#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) +#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) +#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) +#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) +#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) +#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) +#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) +#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) +#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) +#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) +#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) +#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) +#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) +#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) +#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) +#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) +#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) +#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) +#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) +#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) +#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) +#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) +#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) +#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) +#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) +#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) +#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) +#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) +#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) +#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) +#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) +#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) + +#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) + +#endif /* GL_ATI_vertex_streams */ + +/* --------------------------- GL_EXT_422_pixels --------------------------- */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 + +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF + +#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) + +#endif /* GL_EXT_422_pixels */ + +/* ---------------------------- GL_EXT_Cg_shader --------------------------- */ + +#ifndef GL_EXT_Cg_shader +#define GL_EXT_Cg_shader 1 + +#define GL_CG_VERTEX_SHADER_EXT 0x890E +#define GL_CG_FRAGMENT_SHADER_EXT 0x890F + +#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) + +#endif /* GL_EXT_Cg_shader */ + +/* ------------------------------ GL_EXT_abgr ------------------------------ */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 + +#define GL_ABGR_EXT 0x8000 + +#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) + +#endif /* GL_EXT_abgr */ + +/* ------------------------------ GL_EXT_bgra ------------------------------ */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 + +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 + +#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) + +#endif /* GL_EXT_bgra */ + +/* ------------------------ GL_EXT_bindable_uniform ------------------------ */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 + +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF + +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); + +#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) +#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) +#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) + +#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) + +#endif /* GL_EXT_bindable_uniform */ + +/* --------------------------- GL_EXT_blend_color -------------------------- */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 + +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 + +typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + +#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) + +#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) + +#endif /* GL_EXT_blend_color */ + +/* --------------------- GL_EXT_blend_equation_separate -------------------- */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 + +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); + +#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) + +#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) + +#endif /* GL_EXT_blend_equation_separate */ + +/* ----------------------- GL_EXT_blend_func_separate ---------------------- */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 + +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB + +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + +#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) + +#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) + +#endif /* GL_EXT_blend_func_separate */ + +/* ------------------------- GL_EXT_blend_logic_op ------------------------- */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 + +#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) + +#endif /* GL_EXT_blend_logic_op */ + +/* -------------------------- GL_EXT_blend_minmax -------------------------- */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 + +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); + +#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) + +#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) + +#endif /* GL_EXT_blend_minmax */ + +/* ------------------------- GL_EXT_blend_subtract ------------------------- */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 + +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B + +#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) + +#endif /* GL_EXT_blend_subtract */ + +/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 + +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 + +#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) + +#endif /* GL_EXT_clip_volume_hint */ + +/* ------------------------------ GL_EXT_cmyka ----------------------------- */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 + +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F + +#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) + +#endif /* GL_EXT_cmyka */ + +/* ------------------------- GL_EXT_color_subtable ------------------------- */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 + +typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + +#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) +#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) + +#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) + +#endif /* GL_EXT_color_subtable */ + +/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 + +typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); + +#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) +#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) + +#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) + +#endif /* GL_EXT_compiled_vertex_array */ + +/* --------------------------- GL_EXT_convolution -------------------------- */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 + +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 + +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span); +typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column); + +#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) +#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) +#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) +#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) +#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) +#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) +#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) +#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) +#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) +#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) +#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) +#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) +#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) + +#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) + +#endif /* GL_EXT_convolution */ + +/* ------------------------ GL_EXT_coordinate_frame ------------------------ */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 + +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 + +typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); +typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); + +#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) +#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) + +#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) + +#endif /* GL_EXT_coordinate_frame */ + +/* -------------------------- GL_EXT_copy_texture -------------------------- */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 + +typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + +#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) +#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) +#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) +#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) +#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) + +#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) + +#endif /* GL_EXT_copy_texture */ + +/* --------------------------- GL_EXT_cull_vertex -------------------------- */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 + +typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); + +#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) +#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) + +#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) + +#endif /* GL_EXT_cull_vertex */ + +/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 + +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 + +typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); + +#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) + +#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) + +#endif /* GL_EXT_depth_bounds_test */ + +/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 + +typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); + +#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) +#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) +#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) +#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) +#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) +#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) + +#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) + +#endif /* GL_EXT_draw_buffers2 */ + +/* ------------------------- GL_EXT_draw_instanced ------------------------- */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 + +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); + +#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) +#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) + +#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) + +#endif /* GL_EXT_draw_instanced */ + +/* ----------------------- GL_EXT_draw_range_elements ---------------------- */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 + +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 + +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) + +#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) + +#endif /* GL_EXT_draw_range_elements */ + +/* ---------------------------- GL_EXT_fog_coord --------------------------- */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 + +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 + +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); + +#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) +#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) +#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) +#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) +#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) + +#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) + +#endif /* GL_EXT_fog_coord */ + +/* ------------------------ GL_EXT_fragment_lighting ----------------------- */ + +#ifndef GL_EXT_fragment_lighting +#define GL_EXT_fragment_lighting 1 + +#define GL_FRAGMENT_LIGHTING_EXT 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 +#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 +#define GL_LIGHT_ENV_MODE_EXT 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B +#define GL_FRAGMENT_LIGHT0_EXT 0x840C +#define GL_FRAGMENT_LIGHT7_EXT 0x8413 + +typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); + +#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) +#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) +#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) +#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) +#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) +#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) +#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) +#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) +#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) +#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) +#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) +#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) +#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) +#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) +#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) +#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) +#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) +#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) + +#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) + +#endif /* GL_EXT_fragment_lighting */ + +/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 + +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA + +typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + +#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) + +#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) + +#endif /* GL_EXT_framebuffer_blit */ + +/* --------------------- GL_EXT_framebuffer_multisample -------------------- */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 + +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 + +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + +#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) + +#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) + +#endif /* GL_EXT_framebuffer_multisample */ + +/* ----------------------- GL_EXT_framebuffer_object ----------------------- */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 + +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 + +typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); +typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); +typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); +typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + +#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) +#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) +#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) +#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) +#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) +#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) +#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) +#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) +#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) +#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) +#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) +#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) +#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) +#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) +#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) +#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) +#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) + +#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) + +#endif /* GL_EXT_framebuffer_object */ + +/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 + +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA + +#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) + +#endif /* GL_EXT_framebuffer_sRGB */ + +/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 + +#define GL_LINES_ADJACENCY_EXT 0xA +#define GL_LINE_STRIP_ADJACENCY_EXT 0xB +#define GL_TRIANGLES_ADJACENCY_EXT 0xC +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 + +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); + +#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) +#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) +#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) +#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) + +#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) + +#endif /* GL_EXT_geometry_shader4 */ + +/* --------------------- GL_EXT_gpu_program_parameters --------------------- */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 + +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); + +#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) +#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) + +#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) + +#endif /* GL_EXT_gpu_program_parameters */ + +/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 + +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 + +typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); + +#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) +#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) +#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) +#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) +#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) +#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) +#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) +#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) +#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) +#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) +#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) +#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) +#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) +#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) +#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) +#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) +#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) +#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) +#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) +#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) +#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) +#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) +#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) +#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) +#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) +#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) +#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) +#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) +#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) +#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) +#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) +#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) +#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) +#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) + +#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) + +#endif /* GL_EXT_gpu_shader4 */ + +/* ---------------------------- GL_EXT_histogram --------------------------- */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 + +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 + +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); + +#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) +#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) +#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) +#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) +#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) +#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) +#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) +#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) +#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) +#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) + +#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) + +#endif /* GL_EXT_histogram */ + +/* ----------------------- GL_EXT_index_array_formats ---------------------- */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 + +#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) + +#endif /* GL_EXT_index_array_formats */ + +/* --------------------------- GL_EXT_index_func --------------------------- */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 + +typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); + +#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) + +#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) + +#endif /* GL_EXT_index_func */ + +/* ------------------------- GL_EXT_index_material ------------------------- */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 + +typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); + +#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) + +#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) + +#endif /* GL_EXT_index_material */ + +/* -------------------------- GL_EXT_index_texture ------------------------- */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 + +#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) + +#endif /* GL_EXT_index_texture */ + +/* -------------------------- GL_EXT_light_texture ------------------------- */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 + +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 + +typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); + +#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) +#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) +#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) + +#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) + +#endif /* GL_EXT_light_texture */ + +/* ------------------------- GL_EXT_misc_attribute ------------------------- */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 + +#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) + +#endif /* GL_EXT_misc_attribute */ + +/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 + +typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint* first, GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount); + +#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) +#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) + +#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) + +#endif /* GL_EXT_multi_draw_arrays */ + +/* --------------------------- GL_EXT_multisample -------------------------- */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 + +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); + +#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) +#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) + +#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) + +#endif /* GL_EXT_multisample */ + +/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 + +#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) + +#endif /* GL_EXT_packed_depth_stencil */ + +/* -------------------------- GL_EXT_packed_float -------------------------- */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 + +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C + +#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) + +#endif /* GL_EXT_packed_float */ + +/* -------------------------- GL_EXT_packed_pixels ------------------------- */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 + +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 + +#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) + +#endif /* GL_EXT_packed_pixels */ + +/* ------------------------ GL_EXT_paletted_texture ------------------------ */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 + +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 +#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B + +typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); + +#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) +#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) +#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) +#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) + +#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) + +#endif /* GL_EXT_paletted_texture */ + +/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 + +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF + +#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) + +#endif /* GL_EXT_pixel_buffer_object */ + +/* ------------------------- GL_EXT_pixel_transform ------------------------ */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 + +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 + +typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) +#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) +#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) +#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) +#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) +#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) + +#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) + +#endif /* GL_EXT_pixel_transform */ + +/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 + +#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) + +#endif /* GL_EXT_pixel_transform_color_table */ + +/* ------------------------ GL_EXT_point_parameters ------------------------ */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 + +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); + +#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) +#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) + +#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) + +#endif /* GL_EXT_point_parameters */ + +/* ------------------------- GL_EXT_polygon_offset ------------------------- */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 + +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 + +typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); + +#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) + +#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) + +#endif /* GL_EXT_polygon_offset */ + +/* ------------------------- GL_EXT_rescale_normal ------------------------- */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 + +#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) + +#endif /* GL_EXT_rescale_normal */ + +/* -------------------------- GL_EXT_scene_marker -------------------------- */ + +#ifndef GL_EXT_scene_marker +#define GL_EXT_scene_marker 1 + +typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); + +#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) +#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) + +#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) + +#endif /* GL_EXT_scene_marker */ + +/* ------------------------- GL_EXT_secondary_color ------------------------ */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 + +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E + +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); + +#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) +#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) +#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) +#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) +#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) +#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) +#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) +#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) +#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) +#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) +#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) +#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) +#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) +#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) +#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) +#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) +#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) + +#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) + +#endif /* GL_EXT_secondary_color */ + +/* --------------------- GL_EXT_separate_specular_color -------------------- */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 + +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA + +#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) + +#endif /* GL_EXT_separate_specular_color */ + +/* -------------------------- GL_EXT_shadow_funcs -------------------------- */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 + +#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) + +#endif /* GL_EXT_shadow_funcs */ + +/* --------------------- GL_EXT_shared_texture_palette --------------------- */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 + +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB + +#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) + +#endif /* GL_EXT_shared_texture_palette */ + +/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 + +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 + +#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) + +#endif /* GL_EXT_stencil_clear_tag */ + +/* ------------------------ GL_EXT_stencil_two_side ------------------------ */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 + +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 + +typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); + +#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) + +#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) + +#endif /* GL_EXT_stencil_two_side */ + +/* -------------------------- GL_EXT_stencil_wrap -------------------------- */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 + +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 + +#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) + +#endif /* GL_EXT_stencil_wrap */ + +/* --------------------------- GL_EXT_subtexture --------------------------- */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 + +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); + +#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) +#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) +#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) + +#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) + +#endif /* GL_EXT_subtexture */ + +/* ----------------------------- GL_EXT_texture ---------------------------- */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 + +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 + +#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) + +#endif /* GL_EXT_texture */ + +/* ---------------------------- GL_EXT_texture3D --------------------------- */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 + +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 + +typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); + +#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) + +#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) + +#endif /* GL_EXT_texture3D */ + +/* -------------------------- GL_EXT_texture_array ------------------------- */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 + +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D + +#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) + +#endif /* GL_EXT_texture_array */ + +/* ---------------------- GL_EXT_texture_buffer_object --------------------- */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 + +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E + +typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); + +#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) + +#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) + +#endif /* GL_EXT_texture_buffer_object */ + +/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ + +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 + +#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) + +#endif /* GL_EXT_texture_compression_dxt1 */ + +/* -------------------- GL_EXT_texture_compression_latc -------------------- */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 + +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 + +#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) + +#endif /* GL_EXT_texture_compression_latc */ + +/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 + +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE + +#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) + +#endif /* GL_EXT_texture_compression_rgtc */ + +/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 + +#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) + +#endif /* GL_EXT_texture_compression_s3tc */ + +/* ------------------------ GL_EXT_texture_cube_map ------------------------ */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 + +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C + +#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) + +#endif /* GL_EXT_texture_cube_map */ + +/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ + +#ifndef GL_EXT_texture_edge_clamp +#define GL_EXT_texture_edge_clamp 1 + +#define GL_CLAMP_TO_EDGE_EXT 0x812F + +#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) + +#endif /* GL_EXT_texture_edge_clamp */ + +/* --------------------------- GL_EXT_texture_env -------------------------- */ + +#ifndef GL_EXT_texture_env +#define GL_EXT_texture_env 1 + +#define GL_TEXTURE_ENV0_EXT 0 +#define GL_ENV_BLEND_EXT 0 +#define GL_TEXTURE_ENV_SHIFT_EXT 0 +#define GL_ENV_REPLACE_EXT 0 +#define GL_ENV_ADD_EXT 0 +#define GL_ENV_SUBTRACT_EXT 0 +#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0 +#define GL_ENV_REVERSE_SUBTRACT_EXT 0 +#define GL_ENV_REVERSE_BLEND_EXT 0 +#define GL_ENV_COPY_EXT 0 +#define GL_ENV_MODULATE_EXT 0 + +#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) + +#endif /* GL_EXT_texture_env */ + +/* ------------------------- GL_EXT_texture_env_add ------------------------ */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 + +#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) + +#endif /* GL_EXT_texture_env_add */ + +/* ----------------------- GL_EXT_texture_env_combine ---------------------- */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 + +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A + +#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) + +#endif /* GL_EXT_texture_env_combine */ + +/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 + +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 + +#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) + +#endif /* GL_EXT_texture_env_dot3 */ + +/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 + +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + +#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) + +#endif /* GL_EXT_texture_filter_anisotropic */ + +/* ------------------------- GL_EXT_texture_integer ------------------------ */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 + +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E + +typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); + +#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) +#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) +#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) +#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) +#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) +#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) + +#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) + +#endif /* GL_EXT_texture_integer */ + +/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 + +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 + +#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) + +#endif /* GL_EXT_texture_lod_bias */ + +/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 + +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 + +#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) + +#endif /* GL_EXT_texture_mirror_clamp */ + +/* ------------------------- GL_EXT_texture_object ------------------------- */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 + +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A + +typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); +typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); +typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); +typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); + +#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) +#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) +#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) +#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) +#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) +#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) + +#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) + +#endif /* GL_EXT_texture_object */ + +/* --------------------- GL_EXT_texture_perturb_normal --------------------- */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 + +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF + +typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); + +#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) + +#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) + +#endif /* GL_EXT_texture_perturb_normal */ + +/* ------------------------ GL_EXT_texture_rectangle ----------------------- */ + +#ifndef GL_EXT_texture_rectangle +#define GL_EXT_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 + +#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) + +#endif /* GL_EXT_texture_rectangle */ + +/* -------------------------- GL_EXT_texture_sRGB -------------------------- */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 + +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F + +#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) + +#endif /* GL_EXT_texture_sRGB */ + +/* --------------------- GL_EXT_texture_shared_exponent -------------------- */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 + +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F + +#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) + +#endif /* GL_EXT_texture_shared_exponent */ + +/* --------------------------- GL_EXT_timer_query -------------------------- */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 + +#define GL_TIME_ELAPSED_EXT 0x88BF + +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); + +#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) +#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) + +#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) + +#endif /* GL_EXT_timer_query */ + +/* -------------------------- GL_EXT_vertex_array -------------------------- */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 + +#define GL_DOUBLE_EXT 0x140A +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 + +typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); +typedef void (GLAPIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, void** params); +typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); + +#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) +#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) +#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) +#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) +#define glGetPointervEXT GLEW_GET_FUN(__glewGetPointervEXT) +#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) +#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) +#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) +#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) + +#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) + +#endif /* GL_EXT_vertex_array */ + +/* -------------------------- GL_EXT_vertex_shader ------------------------- */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 + +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED + +typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); +typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); +typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); +typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + +#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) +#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) +#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) +#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) +#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) +#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) +#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) +#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) +#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) +#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) +#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) +#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) +#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) +#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) +#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) +#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) +#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) +#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) +#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) +#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) +#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) +#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) +#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) +#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) +#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) +#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) +#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) +#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) +#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) +#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) +#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) +#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) +#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) +#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) +#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) +#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) +#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) +#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) +#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) +#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) +#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) +#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) + +#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) + +#endif /* GL_EXT_vertex_shader */ + +/* ------------------------ GL_EXT_vertex_weighting ------------------------ */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 + +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 + +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); + +#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) +#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) +#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) + +#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) + +#endif /* GL_EXT_vertex_weighting */ + +/* ------------------------ GL_GREMEDY_string_marker ----------------------- */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 + +typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string); + +#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) + +#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) + +#endif /* GL_GREMEDY_string_marker */ + +/* --------------------- GL_HP_convolution_border_modes -------------------- */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 + +#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) + +#endif /* GL_HP_convolution_border_modes */ + +/* ------------------------- GL_HP_image_transform ------------------------- */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 + +typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) +#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) +#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) +#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) +#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) +#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) + +#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) + +#endif /* GL_HP_image_transform */ + +/* -------------------------- GL_HP_occlusion_test ------------------------- */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 + +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 + +#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) + +#endif /* GL_HP_occlusion_test */ + +/* ------------------------- GL_HP_texture_lighting ------------------------ */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 + +#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) + +#endif /* GL_HP_texture_lighting */ + +/* --------------------------- GL_IBM_cull_vertex -------------------------- */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 + +#define GL_CULL_VERTEX_IBM 103050 + +#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) + +#endif /* GL_IBM_cull_vertex */ + +/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 + +typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride); + +#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) +#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) + +#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) + +#endif /* GL_IBM_multimode_draw_arrays */ + +/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 + +#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 + +#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) + +#endif /* GL_IBM_rasterpos_clip */ + +/* --------------------------- GL_IBM_static_data -------------------------- */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 + +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 + +#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) + +#endif /* GL_IBM_static_data */ + +/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_IBM 0x8370 + +#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) + +#endif /* GL_IBM_texture_mirrored_repeat */ + +/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 + +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 + +typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); + +#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) +#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) +#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) +#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) +#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) +#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) +#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) +#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) + +#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) + +#endif /* GL_IBM_vertex_array_lists */ + +/* -------------------------- GL_INGR_color_clamp -------------------------- */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 + +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 + +#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) + +#endif /* GL_INGR_color_clamp */ + +/* ------------------------- GL_INGR_interlace_read ------------------------ */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 + +#define GL_INTERLACE_READ_INGR 0x8568 + +#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) + +#endif /* GL_INGR_interlace_read */ + +/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 + +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 + +typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); + +#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) +#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) +#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) +#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) + +#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) + +#endif /* GL_INTEL_parallel_arrays */ + +/* ------------------------ GL_INTEL_texture_scissor ----------------------- */ + +#ifndef GL_INTEL_texture_scissor +#define GL_INTEL_texture_scissor 1 + +typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); +typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); + +#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) +#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) + +#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) + +#endif /* GL_INTEL_texture_scissor */ + +/* -------------------------- GL_KTX_buffer_region ------------------------- */ + +#ifndef GL_KTX_buffer_region +#define GL_KTX_buffer_region 1 + +#define GL_KTX_FRONT_REGION 0x0 +#define GL_KTX_BACK_REGION 0x1 +#define GL_KTX_Z_REGION 0x2 +#define GL_KTX_STENCIL_REGION 0x3 + +typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDEXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONEXTPROC) (GLenum region); +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); +typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONEXTPROC) (GLenum region); +typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); + +#define glBufferRegionEnabledEXT GLEW_GET_FUN(__glewBufferRegionEnabledEXT) +#define glDeleteBufferRegionEXT GLEW_GET_FUN(__glewDeleteBufferRegionEXT) +#define glDrawBufferRegionEXT GLEW_GET_FUN(__glewDrawBufferRegionEXT) +#define glNewBufferRegionEXT GLEW_GET_FUN(__glewNewBufferRegionEXT) +#define glReadBufferRegionEXT GLEW_GET_FUN(__glewReadBufferRegionEXT) + +#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) + +#endif /* GL_KTX_buffer_region */ + +/* ------------------------- GL_MESAX_texture_stack ------------------------ */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 + +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E + +#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) + +#endif /* GL_MESAX_texture_stack */ + +/* -------------------------- GL_MESA_pack_invert -------------------------- */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 + +#define GL_PACK_INVERT_MESA 0x8758 + +#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) + +#endif /* GL_MESA_pack_invert */ + +/* ------------------------- GL_MESA_resize_buffers ------------------------ */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 + +typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); + +#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) + +#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) + +#endif /* GL_MESA_resize_buffers */ + +/* --------------------------- GL_MESA_window_pos -------------------------- */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 + +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); + +#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) +#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) +#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) +#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) +#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) +#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) +#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) +#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) +#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) +#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) +#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) +#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) +#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) +#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) +#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) +#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) +#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) +#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) +#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) +#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) +#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) +#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) +#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) +#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) + +#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) + +#endif /* GL_MESA_window_pos */ + +/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 + +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 + +#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) + +#endif /* GL_MESA_ycbcr_texture */ + +/* --------------------------- GL_NV_blend_square -------------------------- */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 + +#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) + +#endif /* GL_NV_blend_square */ + +/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 + +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F + +#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) + +#endif /* GL_NV_copy_depth_to_color */ + +/* ------------------------ GL_NV_depth_buffer_float ----------------------- */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 + +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF + +typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); + +#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) +#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) +#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) + +#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) + +#endif /* GL_NV_depth_buffer_float */ + +/* --------------------------- GL_NV_depth_clamp --------------------------- */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 + +#define GL_DEPTH_CLAMP_NV 0x864F + +#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) + +#endif /* GL_NV_depth_clamp */ + +/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ + +#ifndef GL_NV_depth_range_unclamped +#define GL_NV_depth_range_unclamped 1 + +#define GL_SAMPLE_COUNT_BITS_NV 0x8864 +#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 +#define GL_QUERY_RESULT_NV 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 +#define GL_SAMPLE_COUNT_NV 0x8914 + +#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) + +#endif /* GL_NV_depth_range_unclamped */ + +/* ---------------------------- GL_NV_evaluators --------------------------- */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 + +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 + +typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points); +typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points); +typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) +#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) +#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) +#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) +#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) +#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) +#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) +#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) +#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) + +#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) + +#endif /* GL_NV_evaluators */ + +/* ------------------------------ GL_NV_fence ------------------------------ */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 + +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 + +typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); +typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); +typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); + +#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) +#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) +#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) +#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) +#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) +#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) +#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) + +#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) + +#endif /* GL_NV_fence */ + +/* --------------------------- GL_NV_float_buffer -------------------------- */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 + +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E + +#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) + +#endif /* GL_NV_float_buffer */ + +/* --------------------------- GL_NV_fog_distance -------------------------- */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 + +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C + +#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) + +#endif /* GL_NV_fog_distance */ + +/* ------------------------- GL_NV_fragment_program ------------------------ */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 + +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 + +typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); + +#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) +#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) +#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) +#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) +#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) +#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) + +#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) + +#endif /* GL_NV_fragment_program */ + +/* ------------------------ GL_NV_fragment_program2 ------------------------ */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 + +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 + +#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) + +#endif /* GL_NV_fragment_program2 */ + +/* ------------------------ GL_NV_fragment_program4 ------------------------ */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 + +#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) + +#endif /* GL_NV_fragment_program4 */ + +/* --------------------- GL_NV_fragment_program_option --------------------- */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 + +#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) + +#endif /* GL_NV_fragment_program_option */ + +/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 + +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 + +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + +#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) + +#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) + +#endif /* GL_NV_framebuffer_multisample_coverage */ + +/* ------------------------ GL_NV_geometry_program4 ------------------------ */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 + +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 + +typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); + +#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) + +#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) + +#endif /* GL_NV_geometry_program4 */ + +/* ------------------------- GL_NV_geometry_shader4 ------------------------ */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 + +#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) + +#endif /* GL_NV_geometry_shader4 */ + +/* --------------------------- GL_NV_gpu_program4 -------------------------- */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 + +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 + +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); + +#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) +#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) +#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) +#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) +#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) +#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) +#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) +#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) +#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) +#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) +#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) +#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) + +#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) + +#endif /* GL_NV_gpu_program4 */ + +/* ---------------------------- GL_NV_half_float --------------------------- */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 + +#define GL_HALF_FLOAT_NV 0x140B + +typedef unsigned short GLhalf; + +typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); +typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); +typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); +typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); +typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); +typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); +typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); +typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); +typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); +typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); + +#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) +#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) +#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) +#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) +#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) +#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) +#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) +#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) +#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) +#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) +#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) +#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) +#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) +#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) +#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) +#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) +#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) +#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) +#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) +#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) +#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) +#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) +#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) +#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) +#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) +#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) +#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) +#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) +#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) +#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) +#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) +#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) +#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) +#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) +#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) +#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) +#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) +#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) +#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) +#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) +#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) +#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) +#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) +#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) +#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) +#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) + +#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) + +#endif /* GL_NV_half_float */ + +/* ------------------------ GL_NV_light_max_exponent ----------------------- */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 + +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 + +#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) + +#endif /* GL_NV_light_max_exponent */ + +/* --------------------- GL_NV_multisample_filter_hint --------------------- */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 + +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 + +#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) + +#endif /* GL_NV_multisample_filter_hint */ + +/* ------------------------- GL_NV_occlusion_query ------------------------- */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 + +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 + +typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); + +#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) +#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) +#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) +#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) +#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) +#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) +#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) + +#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) + +#endif /* GL_NV_occlusion_query */ + +/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA + +#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) + +#endif /* GL_NV_packed_depth_stencil */ + +/* --------------------- GL_NV_parameter_buffer_object --------------------- */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 + +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 + +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); + +#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) +#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) +#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) + +#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) + +#endif /* GL_NV_parameter_buffer_object */ + +/* ------------------------- GL_NV_pixel_data_range ------------------------ */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 + +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D + +typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer); + +#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) +#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) + +#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) + +#endif /* GL_NV_pixel_data_range */ + +/* --------------------------- GL_NV_point_sprite -------------------------- */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 + +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); + +#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) +#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) + +#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) + +#endif /* GL_NV_point_sprite */ + +/* ------------------------ GL_NV_primitive_restart ------------------------ */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 + +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 + +typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); + +#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) +#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) + +#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) + +#endif /* GL_NV_primitive_restart */ + +/* ------------------------ GL_NV_register_combiners ----------------------- */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 + +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 + +typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); + +#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) +#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) +#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) +#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) +#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) +#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) +#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) +#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) +#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) +#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) +#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) +#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) +#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) + +#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) + +#endif /* GL_NV_register_combiners */ + +/* ----------------------- GL_NV_register_combiners2 ----------------------- */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 + +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 + +typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); + +#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) +#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) + +#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) + +#endif /* GL_NV_register_combiners2 */ + +/* -------------------------- GL_NV_texgen_emboss -------------------------- */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 + +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F + +#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) + +#endif /* GL_NV_texgen_emboss */ + +/* ------------------------ GL_NV_texgen_reflection ------------------------ */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 + +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 + +#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) + +#endif /* GL_NV_texgen_reflection */ + +/* --------------------- GL_NV_texture_compression_vtc --------------------- */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 + +#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) + +#endif /* GL_NV_texture_compression_vtc */ + +/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 + +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B + +#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) + +#endif /* GL_NV_texture_env_combine4 */ + +/* ---------------------- GL_NV_texture_expand_normal ---------------------- */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 + +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F + +#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) + +#endif /* GL_NV_texture_expand_normal */ + +/* ------------------------ GL_NV_texture_rectangle ------------------------ */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 + +#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) + +#endif /* GL_NV_texture_rectangle */ + +/* -------------------------- GL_NV_texture_shader ------------------------- */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 + +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F + +#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) + +#endif /* GL_NV_texture_shader */ + +/* ------------------------- GL_NV_texture_shader2 ------------------------- */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 + +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D + +#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) + +#endif /* GL_NV_texture_shader2 */ + +/* ------------------------- GL_NV_texture_shader3 ------------------------- */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 + +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 + +#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) + +#endif /* GL_NV_texture_shader3 */ + +/* ------------------------ GL_NV_transform_feedback ----------------------- */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 + +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F + +typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); + +#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) +#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) +#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) +#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) +#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) +#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) +#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) +#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) +#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) +#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) +#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) + +#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) + +#endif /* GL_NV_transform_feedback */ + +/* ------------------------ GL_NV_vertex_array_range ----------------------- */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 + +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 + +typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer); + +#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) +#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) + +#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) + +#endif /* GL_NV_vertex_array_range */ + +/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 + +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 + +#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) + +#endif /* GL_NV_vertex_array_range2 */ + +/* -------------------------- GL_NV_vertex_program ------------------------- */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 + +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F + +typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); +typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint num, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint num, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); + +#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) +#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) +#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) +#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) +#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) +#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) +#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) +#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) +#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) +#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) +#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) +#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) +#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) +#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) +#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) +#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) +#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) +#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) +#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) +#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) +#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) +#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) +#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) +#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) +#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) +#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) +#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) +#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) +#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) +#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) +#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) +#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) +#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) +#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) +#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) +#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) +#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) +#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) +#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) +#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) +#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) +#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) +#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) +#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) +#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) +#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) +#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) +#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) +#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) +#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) +#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) +#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) +#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) +#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) +#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) +#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) +#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) +#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) +#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) +#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) +#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) +#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) +#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) +#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) + +#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) + +#endif /* GL_NV_vertex_program */ + +/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 + +#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) + +#endif /* GL_NV_vertex_program1_1 */ + +/* ------------------------- GL_NV_vertex_program2 ------------------------- */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 + +#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) + +#endif /* GL_NV_vertex_program2 */ + +/* ---------------------- GL_NV_vertex_program2_option --------------------- */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 + +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 + +#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) + +#endif /* GL_NV_vertex_program2_option */ + +/* ------------------------- GL_NV_vertex_program3 ------------------------- */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 + +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C + +#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) + +#endif /* GL_NV_vertex_program3 */ + +/* ------------------------- GL_NV_vertex_program4 ------------------------- */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 + +#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) + +#endif /* GL_NV_vertex_program4 */ + +/* ------------------------ GL_OES_byte_coordinates ------------------------ */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 + +#define GL_BYTE 0x1400 + +#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) + +#endif /* GL_OES_byte_coordinates */ + +/* ------------------- GL_OES_compressed_paletted_texture ------------------ */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 + +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 + +#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) + +#endif /* GL_OES_compressed_paletted_texture */ + +/* --------------------------- GL_OES_read_format -------------------------- */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 + +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B + +#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) + +#endif /* GL_OES_read_format */ + +/* ------------------------ GL_OES_single_precision ------------------------ */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 + +typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth); +typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); +typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); +typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); + +#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) +#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) +#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) +#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) +#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) +#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) + +#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) + +#endif /* GL_OES_single_precision */ + +/* ---------------------------- GL_OML_interlace --------------------------- */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 + +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 + +#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) + +#endif /* GL_OML_interlace */ + +/* ---------------------------- GL_OML_resample ---------------------------- */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 + +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 + +#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) + +#endif /* GL_OML_resample */ + +/* ---------------------------- GL_OML_subsample --------------------------- */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 + +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 + +#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) + +#endif /* GL_OML_subsample */ + +/* --------------------------- GL_PGI_misc_hints --------------------------- */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 + +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 +#define GL_CONSERVE_MEMORY_HINT_PGI 107005 +#define GL_RECLAIM_MEMORY_HINT_PGI 107006 +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 +#define GL_ALWAYS_FAST_HINT_PGI 107020 +#define GL_ALWAYS_SOFT_HINT_PGI 107021 +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 +#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 +#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 +#define GL_STRICT_LIGHTING_HINT_PGI 107031 +#define GL_STRICT_SCISSOR_HINT_PGI 107032 +#define GL_FULL_STIPPLE_HINT_PGI 107033 +#define GL_CLIP_NEAR_HINT_PGI 107040 +#define GL_CLIP_FAR_HINT_PGI 107041 +#define GL_WIDE_LINE_HINT_PGI 107042 +#define GL_BACK_NORMALS_HINT_PGI 107043 + +#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) + +#endif /* GL_PGI_misc_hints */ + +/* -------------------------- GL_PGI_vertex_hints -------------------------- */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 + +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_VERTEX_DATA_HINT_PGI 107050 +#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 +#define GL_MATERIAL_SIDE_HINT_PGI 107052 +#define GL_MAX_VERTEX_HINT_PGI 107053 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 + +#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) + +#endif /* GL_PGI_vertex_hints */ + +/* ----------------------- GL_REND_screen_coordinates ---------------------- */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 + +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 + +#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) + +#endif /* GL_REND_screen_coordinates */ + +/* ------------------------------- GL_S3_s3tc ------------------------------ */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 + +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 + +#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) + +#endif /* GL_S3_s3tc */ + +/* -------------------------- GL_SGIS_color_range -------------------------- */ + +#ifndef GL_SGIS_color_range +#define GL_SGIS_color_range 1 + +#define GL_EXTENDED_RANGE_SGIS 0x85A5 +#define GL_MIN_RED_SGIS 0x85A6 +#define GL_MAX_RED_SGIS 0x85A7 +#define GL_MIN_GREEN_SGIS 0x85A8 +#define GL_MAX_GREEN_SGIS 0x85A9 +#define GL_MIN_BLUE_SGIS 0x85AA +#define GL_MAX_BLUE_SGIS 0x85AB +#define GL_MIN_ALPHA_SGIS 0x85AC +#define GL_MAX_ALPHA_SGIS 0x85AD + +#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) + +#endif /* GL_SGIS_color_range */ + +/* ------------------------- GL_SGIS_detail_texture ------------------------ */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 + +typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); +typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); + +#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) +#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) + +#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) + +#endif /* GL_SGIS_detail_texture */ + +/* -------------------------- GL_SGIS_fog_function ------------------------- */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 + +typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); +typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); + +#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) +#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) + +#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) + +#endif /* GL_SGIS_fog_function */ + +/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 + +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 + +#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) + +#endif /* GL_SGIS_generate_mipmap */ + +/* -------------------------- GL_SGIS_multisample -------------------------- */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 + +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); + +#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) +#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) + +#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) + +#endif /* GL_SGIS_multisample */ + +/* ------------------------- GL_SGIS_pixel_texture ------------------------- */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 + +#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) + +#endif /* GL_SGIS_pixel_texture */ + +/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 + +typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); +typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); + +#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) +#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) + +#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) + +#endif /* GL_SGIS_sharpen_texture */ + +/* --------------------------- GL_SGIS_texture4D --------------------------- */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 + +typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels); + +#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) +#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) + +#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) + +#endif /* GL_SGIS_texture4D */ + +/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_SGIS 0x812D + +#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) + +#endif /* GL_SGIS_texture_border_clamp */ + +/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 + +#define GL_CLAMP_TO_EDGE_SGIS 0x812F + +#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) + +#endif /* GL_SGIS_texture_edge_clamp */ + +/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 + +typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); +typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); + +#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) +#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) + +#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) + +#endif /* GL_SGIS_texture_filter4 */ + +/* -------------------------- GL_SGIS_texture_lod -------------------------- */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 + +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D + +#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) + +#endif /* GL_SGIS_texture_lod */ + +/* ------------------------- GL_SGIS_texture_select ------------------------ */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 + +#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) + +#endif /* GL_SGIS_texture_select */ + +/* ----------------------------- GL_SGIX_async ----------------------------- */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 + +#define GL_ASYNC_MARKER_SGIX 0x8329 + +typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); +typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); + +#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) +#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) +#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) +#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) +#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) +#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) + +#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) + +#endif /* GL_SGIX_async */ + +/* ------------------------ GL_SGIX_async_histogram ------------------------ */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 + +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D + +#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) + +#endif /* GL_SGIX_async_histogram */ + +/* -------------------------- GL_SGIX_async_pixel -------------------------- */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 + +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 + +#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) + +#endif /* GL_SGIX_async_pixel */ + +/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 + +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 + +#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) + +#endif /* GL_SGIX_blend_alpha_minmax */ + +/* ---------------------------- GL_SGIX_clipmap ---------------------------- */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 + +#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) + +#endif /* GL_SGIX_clipmap */ + +/* ------------------------- GL_SGIX_depth_texture ------------------------- */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 + +#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) + +#endif /* GL_SGIX_depth_texture */ + +/* -------------------------- GL_SGIX_flush_raster ------------------------- */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 + +typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); + +#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) + +#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) + +#endif /* GL_SGIX_flush_raster */ + +/* --------------------------- GL_SGIX_fog_offset -------------------------- */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 + +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 + +#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) + +#endif /* GL_SGIX_fog_offset */ + +/* -------------------------- GL_SGIX_fog_texture -------------------------- */ + +#ifndef GL_SGIX_fog_texture +#define GL_SGIX_fog_texture 1 + +#define GL_TEXTURE_FOG_SGIX 0 +#define GL_FOG_PATCHY_FACTOR_SGIX 0 +#define GL_FRAGMENT_FOG_SGIX 0 + +typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); + +#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) + +#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) + +#endif /* GL_SGIX_fog_texture */ + +/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ + +#ifndef GL_SGIX_fragment_specular_lighting +#define GL_SGIX_fragment_specular_lighting 1 + +typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); + +#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) +#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) +#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) +#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) +#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) +#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) +#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) +#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) +#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) +#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) +#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) +#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) +#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) +#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) +#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) +#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) +#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) + +#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) + +#endif /* GL_SGIX_fragment_specular_lighting */ + +/* --------------------------- GL_SGIX_framezoom --------------------------- */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 + +typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); + +#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) + +#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) + +#endif /* GL_SGIX_framezoom */ + +/* --------------------------- GL_SGIX_interlace --------------------------- */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 + +#define GL_INTERLACE_SGIX 0x8094 + +#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) + +#endif /* GL_SGIX_interlace */ + +/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 + +#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) + +#endif /* GL_SGIX_ir_instrument1 */ + +/* ------------------------- GL_SGIX_list_priority ------------------------- */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 + +#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) + +#endif /* GL_SGIX_list_priority */ + +/* ------------------------- GL_SGIX_pixel_texture ------------------------- */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 + +typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); + +#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) + +#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) + +#endif /* GL_SGIX_pixel_texture */ + +/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ + +#ifndef GL_SGIX_pixel_texture_bits +#define GL_SGIX_pixel_texture_bits 1 + +#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) + +#endif /* GL_SGIX_pixel_texture_bits */ + +/* ------------------------ GL_SGIX_reference_plane ------------------------ */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 + +typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); + +#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) + +#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) + +#endif /* GL_SGIX_reference_plane */ + +/* ---------------------------- GL_SGIX_resample --------------------------- */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 + +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 + +#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) + +#endif /* GL_SGIX_resample */ + +/* ----------------------------- GL_SGIX_shadow ---------------------------- */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 + +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D + +#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) + +#endif /* GL_SGIX_shadow */ + +/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 + +#define GL_SHADOW_AMBIENT_SGIX 0x80BF + +#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) + +#endif /* GL_SGIX_shadow_ambient */ + +/* ----------------------------- GL_SGIX_sprite ---------------------------- */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 + +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); + +#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) +#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) +#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) +#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) + +#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) + +#endif /* GL_SGIX_sprite */ + +/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 + +typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); + +#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) + +#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) + +#endif /* GL_SGIX_tag_sample_buffer */ + +/* ------------------------ GL_SGIX_texture_add_env ------------------------ */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 + +#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) + +#endif /* GL_SGIX_texture_add_env */ + +/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 + +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B + +#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) + +#endif /* GL_SGIX_texture_coordinate_clamp */ + +/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 + +#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) + +#endif /* GL_SGIX_texture_lod_bias */ + +/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 + +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E + +#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) + +#endif /* GL_SGIX_texture_multi_buffer */ + +/* ------------------------- GL_SGIX_texture_range ------------------------- */ + +#ifndef GL_SGIX_texture_range +#define GL_SGIX_texture_range 1 + +#define GL_RGB_SIGNED_SGIX 0x85E0 +#define GL_RGBA_SIGNED_SGIX 0x85E1 +#define GL_ALPHA_SIGNED_SGIX 0x85E2 +#define GL_LUMINANCE_SIGNED_SGIX 0x85E3 +#define GL_INTENSITY_SIGNED_SGIX 0x85E4 +#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 +#define GL_RGB16_SIGNED_SGIX 0x85E6 +#define GL_RGBA16_SIGNED_SGIX 0x85E7 +#define GL_ALPHA16_SIGNED_SGIX 0x85E8 +#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 +#define GL_INTENSITY16_SIGNED_SGIX 0x85EA +#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB +#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC +#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED +#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE +#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF +#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 +#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 +#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 +#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 +#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 +#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 +#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 +#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 +#define GL_MIN_LUMINANCE_SGIS 0x85F8 +#define GL_MAX_LUMINANCE_SGIS 0x85F9 +#define GL_MIN_INTENSITY_SGIS 0x85FA +#define GL_MAX_INTENSITY_SGIS 0x85FB + +#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) + +#endif /* GL_SGIX_texture_range */ + +/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 + +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C + +#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) + +#endif /* GL_SGIX_texture_scale_bias */ + +/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) + +#endif /* GL_SGIX_vertex_preclip */ + +/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ + +#ifndef GL_SGIX_vertex_preclip_hint +#define GL_SGIX_vertex_preclip_hint 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) + +#endif /* GL_SGIX_vertex_preclip_hint */ + +/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 + +#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) + +#endif /* GL_SGIX_ycrcb */ + +/* -------------------------- GL_SGI_color_matrix -------------------------- */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 + +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB + +#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) + +#endif /* GL_SGI_color_matrix */ + +/* --------------------------- GL_SGI_color_table -------------------------- */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 + +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF + +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table); + +#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) +#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) +#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) +#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) +#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) +#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) +#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) + +#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) + +#endif /* GL_SGI_color_table */ + +/* ----------------------- GL_SGI_texture_color_table ---------------------- */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 + +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD + +#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) + +#endif /* GL_SGI_texture_color_table */ + +/* ------------------------- GL_SUNX_constant_data ------------------------- */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 + +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 + +typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); + +#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) + +#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) + +#endif /* GL_SUNX_constant_data */ + +/* -------------------- GL_SUN_convolution_border_modes -------------------- */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 + +#define GL_WRAP_BORDER_SUN 0x81D4 + +#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) + +#endif /* GL_SUN_convolution_border_modes */ + +/* -------------------------- GL_SUN_global_alpha -------------------------- */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 + +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA + +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); + +#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) +#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) +#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) +#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) +#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) +#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) +#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) +#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) + +#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) + +#endif /* GL_SUN_global_alpha */ + +/* --------------------------- GL_SUN_mesh_array --------------------------- */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 + +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 + +#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) + +#endif /* GL_SUN_mesh_array */ + +/* ------------------------ GL_SUN_read_video_pixels ----------------------- */ + +#ifndef GL_SUN_read_video_pixels +#define GL_SUN_read_video_pixels 1 + +typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); + +#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) + +#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) + +#endif /* GL_SUN_read_video_pixels */ + +/* --------------------------- GL_SUN_slice_accum -------------------------- */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 + +#define GL_SLICE_ACCUM_SUN 0x85CC + +#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) + +#endif /* GL_SUN_slice_accum */ + +/* -------------------------- GL_SUN_triangle_list ------------------------- */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 + +#define GL_RESTART_SUN 0x01 +#define GL_REPLACE_MIDDLE_SUN 0x02 +#define GL_REPLACE_OLDEST_SUN 0x03 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB + +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); + +#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) +#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) +#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) +#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) +#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) +#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) +#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) + +#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) + +#endif /* GL_SUN_triangle_list */ + +/* ----------------------------- GL_SUN_vertex ----------------------------- */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 + +typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); + +#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) +#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) +#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) +#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) +#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) +#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) +#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) +#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) +#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) +#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) +#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) +#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) +#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) +#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) +#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) +#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) +#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) +#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) +#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) +#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) +#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) +#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) +#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) +#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) +#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) +#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) +#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) +#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) +#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) +#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) +#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) +#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) +#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) +#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) + +#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) + +#endif /* GL_SUN_vertex */ + +/* -------------------------- GL_WIN_phong_shading ------------------------- */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 + +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB + +#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) + +#endif /* GL_WIN_phong_shading */ + +/* -------------------------- GL_WIN_specular_fog -------------------------- */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 + +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC + +#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) + +#endif /* GL_WIN_specular_fog */ + +/* ---------------------------- GL_WIN_swap_hint --------------------------- */ + +#ifndef GL_WIN_swap_hint +#define GL_WIN_swap_hint 1 + +typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + +#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) + +#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) + +#endif /* GL_WIN_swap_hint */ + +/* ------------------------------------------------------------------------- */ + +#if defined(GLEW_MX) && defined(_WIN32) +#define GLEW_FUN_EXPORT +#else +#define GLEW_FUN_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#if defined(GLEW_MX) +#define GLEW_VAR_EXPORT +#else +#define GLEW_VAR_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#if defined(GLEW_MX) && defined(_WIN32) +struct GLEWContextStruct +{ +#endif /* GLEW_MX */ + +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; +GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; + +GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; +GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; +GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; +GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; + +GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; +GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; +GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; +GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; +GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; +GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; +GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; +GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; +GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; +GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; +GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; +GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; +GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; +GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; +GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; +GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; +GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; +GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; +GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; +GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; +GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; + +GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; +GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; +GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; +GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; +GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; +GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; +GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; +GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; +GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; +GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; +GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; +GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; +GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; +GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; +GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; +GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; +GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; +GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; +GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; +GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; +GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; +GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; +GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; +GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; +GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; +GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; +GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; +GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; +GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; +GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; +GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; +GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; +GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; +GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; +GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; +GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; +GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; +GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; +GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; +GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; +GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; +GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; +GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; +GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; +GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; + +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; + +GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; + +GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; + +GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; +GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; +GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; +GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; +GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; +GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; +GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; +GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; + +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; +GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; + +GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; +GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; +GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; +GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; + +GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; + +GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; + +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; + +GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; +GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; +GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; +GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; +GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; +GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; +GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; +GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; +GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; +GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; + +GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; + +GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; + +GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; +GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; +GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; +GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; +GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; +GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; +GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; + +GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; +GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; +GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; +GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; +GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; +GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; +GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; +GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; +GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; +GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; +GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; +GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; +GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; +GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; +GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; +GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; + +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; +GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; + +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; + +GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; +GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; +GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; +GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; + +GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; +GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; +GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; +GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; +GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; +GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; +GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; + +GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; +GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; +GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; +GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; +GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; + +GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; +GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; +GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; + +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; + +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; + +GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; +GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; + +GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; +GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; +GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; +GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; + +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; +GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; +GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; +GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; +GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; +GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; + +GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; +GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; + +GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI; +GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI; + +GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; +GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; + +GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; +GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; +GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; +GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; +GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; +GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; +GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; +GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; + +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; + +GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; +GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; +GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; + +GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; +GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; +GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; + +GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; + +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; + +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; + +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; + +GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; +GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; + +GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; +GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; + +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; +GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; + +GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; +GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; + +GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; + +GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; +GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; + +GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; + +GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; +GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; +GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; +GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; +GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; +GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; + +GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; +GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; + +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; + +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; + +GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; +GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; + +GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; + +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; + +GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; +GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; +GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; +GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; +GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; +GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; +GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; +GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; +GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; +GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; + +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; + +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; + +GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; +GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; + +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; +GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; +GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; +GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; +GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; + +GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; + +GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; + +GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; +GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; +GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; + +GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; + +GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; +GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; + +GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; + +GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; + +GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; + +GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; +GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; + +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; + +GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; + +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; + +GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; + +GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; + +GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; +GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; +GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; +GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; + +GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; +GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; +GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; +GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; +GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; + +GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; + +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; + +GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; +GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; +GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; +GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; +GLEW_FUN_EXPORT PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT; +GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; +GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; + +GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; +GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; +GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; +GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; +GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; +GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; +GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; +GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; +GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; +GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; +GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; +GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; +GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; +GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; +GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; +GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; +GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; + +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; + +GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; + +GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; +GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; + +GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; +GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; + +GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; +GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; +GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; +GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; + +GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; +GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; + +GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; +GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; + +GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT; + +GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; + +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; + +GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; +GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; +GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; + +GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; +GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; +GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; +GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; +GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; +GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; +GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; + +GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; +GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; +GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; +GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; +GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; +GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; +GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; + +GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; + +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; + +GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; +GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; +GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; +GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; +GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; +GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; +GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; +GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; +GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; +GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; +GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; + +GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; +GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; +GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; +GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; +GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; +GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; +GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; + +GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; +GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; + +GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; +GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; + +GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; +GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; +GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; +GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; + +GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; + +GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; +GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; +GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; +GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; +GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; +GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; +GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; +GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; + +GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; + +GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; +GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; +GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; +GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; +GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; +GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; +GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; +GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; +GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; + +GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; +GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; +GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; +GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; +GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; +GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; + +GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; +GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; + +GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; +GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; + +GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; +GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; + +GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; +GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; + +GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; + +GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; +GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; + +GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; +GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; +GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; +GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; +GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; +GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; + +GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; + +GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; + +GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; + +GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; + +GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; + +GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; + +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; + +GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; + +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; +GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; +GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; + +GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; + +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; + +GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; + +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; + +GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; + +GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; + +#if defined(GLEW_MX) && !defined(_WIN32) +struct GLEWContextStruct +{ +#endif /* GLEW_MX */ + +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; +GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; +GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; +GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; +GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; +GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; +GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; +GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; +GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; +GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; + +#ifdef GLEW_MX +}; /* GLEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------- */ + +/* error codes */ +#define GLEW_OK 0 +#define GLEW_NO_ERROR 0 +#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ +#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */ +#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */ + +/* string codes */ +#define GLEW_VERSION 1 + +/* API */ +#ifdef GLEW_MX + +typedef struct GLEWContextStruct GLEWContext; +GLEWAPI GLenum glewContextInit (GLEWContext* ctx); +GLEWAPI GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name); + +#define glewInit() glewContextInit(glewGetContext()) +#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) +#define glewIsExtensionSupported(x) glewIsSupported(x) + +#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) +#ifdef _WIN32 +# define GLEW_GET_FUN(x) glewGetContext()->x +#else +# define GLEW_GET_FUN(x) x +#endif + +#else /* GLEW_MX */ + +GLEWAPI GLenum glewInit (); +GLEWAPI GLboolean glewIsSupported (const char* name); +#define glewIsExtensionSupported(x) glewIsSupported(x) + +#define GLEW_GET_VAR(x) (*(const GLboolean*)&x) +#define GLEW_GET_FUN(x) x + +#endif /* GLEW_MX */ + +GLEWAPI GLboolean glewExperimental; +GLEWAPI GLboolean glewGetExtension (const char* name); +GLEWAPI const GLubyte* glewGetErrorString (GLenum error); +GLEWAPI const GLubyte* glewGetString (GLenum name); + +#ifdef __cplusplus +} +#endif + +#ifdef GLEW_APIENTRY_DEFINED +#undef GLEW_APIENTRY_DEFINED +#undef APIENTRY +#undef GLAPIENTRY +#endif + +#ifdef GLEW_CALLBACK_DEFINED +#undef GLEW_CALLBACK_DEFINED +#undef CALLBACK +#endif + +#ifdef GLEW_WINGDIAPI_DEFINED +#undef GLEW_WINGDIAPI_DEFINED +#undef WINGDIAPI +#endif + +#undef GLAPI +/* #undef GLEWAPI */ + +#endif /* __glew_h__ */ diff --git a/libraries/external/glew/linux/include/GL/vssver.scc b/libraries/external/glew/linux/include/GL/vssver.scc new file mode 100755 index 0000000..44f14c5 Binary files /dev/null and b/libraries/external/glew/linux/include/GL/vssver.scc differ diff --git a/libraries/external/glew/linux/lib/libGLEW.a b/libraries/external/glew/linux/lib/libGLEW.a new file mode 100755 index 0000000..9fb2cef Binary files /dev/null and b/libraries/external/glew/linux/lib/libGLEW.a differ diff --git a/libraries/external/glew/linux/lib/vssver.scc b/libraries/external/glew/linux/lib/vssver.scc new file mode 100755 index 0000000..015e128 Binary files /dev/null and b/libraries/external/glew/linux/lib/vssver.scc differ diff --git a/libraries/external/glew/pc/bin/glew32.dll b/libraries/external/glew/pc/bin/glew32.dll new file mode 100755 index 0000000..9908dda Binary files /dev/null and b/libraries/external/glew/pc/bin/glew32.dll differ diff --git a/libraries/external/glew/pc/bin/vssver.scc b/libraries/external/glew/pc/bin/vssver.scc new file mode 100755 index 0000000..14b9c36 Binary files /dev/null and b/libraries/external/glew/pc/bin/vssver.scc differ diff --git a/libraries/external/glew/pc/include/GL/glew.h b/libraries/external/glew/pc/include/GL/glew.h new file mode 100755 index 0000000..0bae8c1 --- /dev/null +++ b/libraries/external/glew/pc/include/GL/glew.h @@ -0,0 +1,10716 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2007, Milan Ikits +** Copyright (C) 2002-2007, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#ifndef __glew_h__ +#define __glew_h__ +#define __GLEW_H__ + +#if defined(__gl_h_) || defined(__GL_H__) +#error gl.h included before glew.h +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) +#error glext.h included before glew.h +#endif +#if defined(__gl_ATI_h_) +#error glATI.h included before glew.h +#endif + +#define __gl_h_ +#define __GL_H__ +#define __glext_h_ +#define __GLEXT_H_ +#define __gl_ATI_h_ + +#if defined(_WIN32) + +/* + * GLEW does not include to avoid name space pollution. + * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t + * defined properly. + */ +/* */ +#ifndef APIENTRY +#define GLEW_APIENTRY_DEFINED +# if defined(__MINGW32__) +# define APIENTRY __stdcall +# elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) +# define APIENTRY __stdcall +# else +# define APIENTRY +# endif +#endif +#ifndef GLAPI +# if defined(__MINGW32__) +# define GLAPI extern +# endif +#endif +/* */ +#ifndef CALLBACK +#define GLEW_CALLBACK_DEFINED +# if defined(__MINGW32__) +# define CALLBACK __attribute__ ((__stdcall__)) +# elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) +# define CALLBACK __stdcall +# else +# define CALLBACK +# endif +#endif +/* and */ +#ifndef WINGDIAPI +#define GLEW_WINGDIAPI_DEFINED +#define WINGDIAPI __declspec(dllimport) +#endif +/* */ +#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +#endif +/* */ +#if !defined(_W64) +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif +#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) +# ifdef _WIN64 +typedef __int64 ptrdiff_t; +# else +typedef _W64 int ptrdiff_t; +# endif +# define _PTRDIFF_T_DEFINED +# define _PTRDIFF_T_ +#endif + +#ifndef GLAPI +# if defined(__MINGW32__) +# define GLAPI extern +# else +# define GLAPI WINGDIAPI +# endif +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY APIENTRY +#endif + +/* + * GLEW_STATIC needs to be set when using the static version. + * GLEW_BUILD is set when building the DLL version. + */ +#ifdef GLEW_STATIC +# define GLEWAPI extern +#else +# ifdef GLEW_BUILD +# define GLEWAPI extern __declspec(dllexport) +# else +# define GLEWAPI extern __declspec(dllimport) +# endif +#endif + +#else /* _UNIX */ + +/* + * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO + * C. On my system, this amounts to _3 lines_ of included code, all of + * them pretty much harmless. If you know of a way of detecting 32 vs + * 64 _targets_ at compile time you are free to replace this with + * something that's portable. For now, _this_ is the portable solution. + * (mem, 2004-01-04) + */ + +#include + +#define GLEW_APIENTRY_DEFINED +#define APIENTRY +#define GLEWAPI extern + +/* */ +#ifndef GLAPI +#define GLAPI extern +#endif +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#endif /* _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 + +#if defined(__APPLE__) +typedef unsigned long GLenum; +typedef unsigned long GLbitfield; +typedef unsigned long GLuint; +typedef long GLint; +typedef long GLsizei; +#else +typedef unsigned int GLenum; +typedef unsigned int GLbitfield; +typedef unsigned int GLuint; +typedef int GLint; +typedef int GLsizei; +#endif +typedef unsigned char GLboolean; +typedef signed char GLbyte; +typedef short GLshort; +typedef unsigned char GLubyte; +typedef unsigned short GLushort; +typedef float GLfloat; +typedef float GLclampf; +typedef double GLdouble; +typedef double GLclampd; +typedef void GLvoid; +#if defined(_MSC_VER) && _MSC_VER < 1310 +# ifdef _WIN64 +typedef __int64 GLint64EXT; +typedef unsigned __int64 GLuint64EXT; +# else +typedef _W64 int GLint64EXT; +typedef _W64 unsigned int GLuint64EXT; +# endif +#else +typedef signed long long GLint64EXT; +typedef unsigned long long GLuint64EXT; +#endif + +#define GL_ACCUM 0x0100 +#define GL_LOAD 0x0101 +#define GL_RETURN 0x0102 +#define GL_MULT 0x0103 +#define GL_ADD 0x0104 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000fffff +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_TRUE 1 +#define GL_FALSE 0 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LIST_MODE 0x0B30 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_SHADE_MODEL 0x0B54 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_FOG 0x0B60 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_NORMALIZE 0x0BA1 +#define GL_VIEWPORT 0x0BA2 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_INDEX_MODE 0x0C30 +#define GL_RGBA_MODE 0x0C31 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_RENDER_MODE 0x0C40 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_INDEX_BITS 0x0D51 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_COLOR_INDEX 0x1900 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_BITMAP 0x1A00 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_RENDER 0x1C00 +#define GL_FEEDBACK 0x1C01 +#define GL_SELECT 0x1C02 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_ENV 0x2300 +#define GL_EYE_LINEAR 0x2400 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_SPHERE_MAP 0x2402 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_PLANE 0x2502 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_CLAMP 0x2900 +#define GL_REPEAT 0x2901 +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D +#define GL_LOGIC_OP GL_INDEX_LOGIC_OP +#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 + +GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); +GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); +GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void GLAPIENTRY glArrayElement (GLint i); +GLAPI void GLAPIENTRY glBegin (GLenum mode); +GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); +GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GLAPI void GLAPIENTRY glCallList (GLuint list); +GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); +GLAPI void GLAPIENTRY glClear (GLbitfield mask); +GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); +GLAPI void GLAPIENTRY glClearIndex (GLfloat c); +GLAPI void GLAPIENTRY glClearStencil (GLint s); +GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); +GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); +GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); +GLAPI void GLAPIENTRY glColor3iv (const GLint *v); +GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); +GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); +GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); +GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); +GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); +GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void GLAPIENTRY glColor4iv (const GLint *v); +GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); +GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); +GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); +GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); +GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); +GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); +GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); +GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void GLAPIENTRY glCullFace (GLenum mode); +GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); +GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GLAPI void GLAPIENTRY glDepthFunc (GLenum func); +GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); +GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); +GLAPI void GLAPIENTRY glDisable (GLenum cap); +GLAPI void GLAPIENTRY glDisableClientState (GLenum array); +GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); +GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); +GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); +GLAPI void GLAPIENTRY glEnable (GLenum cap); +GLAPI void GLAPIENTRY glEnableClientState (GLenum array); +GLAPI void GLAPIENTRY glEnd (void); +GLAPI void GLAPIENTRY glEndList (void); +GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); +GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); +GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); +GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); +GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); +GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); +GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); +GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); +GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); +GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); +GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); +GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); +GLAPI void GLAPIENTRY glFinish (void); +GLAPI void GLAPIENTRY glFlush (void); +GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glFrontFace (GLenum mode); +GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); +GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); +GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); +GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); +GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); +GLAPI GLenum GLAPIENTRY glGetError (void); +GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); +GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); +GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); +GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); +GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); +GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); +GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params); +GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); +GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); +GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); +GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); +GLAPI void GLAPIENTRY glIndexMask (GLuint mask); +GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glIndexd (GLdouble c); +GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); +GLAPI void GLAPIENTRY glIndexf (GLfloat c); +GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); +GLAPI void GLAPIENTRY glIndexi (GLint c); +GLAPI void GLAPIENTRY glIndexiv (const GLint *c); +GLAPI void GLAPIENTRY glIndexs (GLshort c); +GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); +GLAPI void GLAPIENTRY glIndexub (GLubyte c); +GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); +GLAPI void GLAPIENTRY glInitNames (void); +GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); +GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); +GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); +GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); +GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); +GLAPI void GLAPIENTRY glLineWidth (GLfloat width); +GLAPI void GLAPIENTRY glListBase (GLuint base); +GLAPI void GLAPIENTRY glLoadIdentity (void); +GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); +GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); +GLAPI void GLAPIENTRY glLoadName (GLuint name); +GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); +GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); +GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); +GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); +GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); +GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); +GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); +GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); +GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); +GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); +GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); +GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); +GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void GLAPIENTRY glPassThrough (GLfloat token); +GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); +GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); +GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); +GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); +GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); +GLAPI void GLAPIENTRY glPointSize (GLfloat size); +GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); +GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); +GLAPI void GLAPIENTRY glPopAttrib (void); +GLAPI void GLAPIENTRY glPopClientAttrib (void); +GLAPI void GLAPIENTRY glPopMatrix (void); +GLAPI void GLAPIENTRY glPopName (void); +GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); +GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); +GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); +GLAPI void GLAPIENTRY glPushMatrix (void); +GLAPI void GLAPIENTRY glPushName (GLuint name); +GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); +GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); +GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); +GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); +GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); +GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); +GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); +GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); +GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); +GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); +GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); +GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); +GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); +GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); +GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); +GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); +GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); +GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); +GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); +GLAPI void GLAPIENTRY glShadeModel (GLenum mode); +GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GLAPI void GLAPIENTRY glStencilMask (GLuint mask); +GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); +GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); +GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord1i (GLint s); +GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); +GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); +GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); +GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); +GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); +GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); +GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); +GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); +GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); +GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); +GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); +GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); +GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); +GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); +GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); +GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); +GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); +GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) + +#endif /* GL_VERSION_1_1 */ + +/* ---------------------------------- GLU ---------------------------------- */ + +/* this is where we can safely include GLU */ +#if defined(__APPLE__) && defined(__MACH__) +#include +#else +#include +#endif + +/* ----------------------------- GL_VERSION_1_2 ---------------------------- */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 + +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E + +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + +#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) +#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) +#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) +#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) + +#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) + +#endif /* GL_VERSION_1_2 */ + +/* ----------------------------- GL_VERSION_1_3 ---------------------------- */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 + +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_SUBTRACT 0x84E7 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#define GL_MULTISAMPLE_BIT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); + +#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) +#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) +#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) +#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) +#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) +#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) +#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) +#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) +#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) +#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) +#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) +#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) +#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) +#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) +#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) +#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) +#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) +#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) +#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) +#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) +#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) +#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) +#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) +#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) +#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) +#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) +#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) +#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) +#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) +#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) +#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) +#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) +#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) +#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) +#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) +#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) +#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) +#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) +#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) +#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) +#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) +#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) +#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) +#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) +#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) +#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) + +#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) + +#endif /* GL_VERSION_1_3 */ + +/* ----------------------------- GL_VERSION_1_4 ---------------------------- */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 + +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E + +typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); + +#define glBlendColor GLEW_GET_FUN(__glewBlendColor) +#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) +#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) +#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) +#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) +#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) +#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) +#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) +#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) +#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) +#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) +#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) +#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) +#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) +#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) +#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) +#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) +#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) +#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) +#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) +#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) +#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) +#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) +#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) +#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) +#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) +#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) +#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) +#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) +#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) +#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) +#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) +#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) +#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) +#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) +#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) +#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) +#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) +#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) +#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) +#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) +#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) +#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) +#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) +#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) + +#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) + +#endif /* GL_VERSION_1_4 */ + +/* ----------------------------- GL_VERSION_1_5 ---------------------------- */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 + +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 + +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); +typedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); + +#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) +#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) +#define glBufferData GLEW_GET_FUN(__glewBufferData) +#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) +#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) +#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) +#define glEndQuery GLEW_GET_FUN(__glewEndQuery) +#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) +#define glGenQueries GLEW_GET_FUN(__glewGenQueries) +#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) +#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) +#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) +#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) +#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) +#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) +#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) +#define glIsQuery GLEW_GET_FUN(__glewIsQuery) +#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) +#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) + +#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) + +#endif /* GL_VERSION_1_5 */ + +/* ----------------------------- GL_VERSION_2_0 ---------------------------- */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 + +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 + +typedef char GLchar; + +typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); +typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); +typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); +typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); +typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); +typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); +typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); +typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); +typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); + +#define glAttachShader GLEW_GET_FUN(__glewAttachShader) +#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) +#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) +#define glCompileShader GLEW_GET_FUN(__glewCompileShader) +#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) +#define glCreateShader GLEW_GET_FUN(__glewCreateShader) +#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) +#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) +#define glDetachShader GLEW_GET_FUN(__glewDetachShader) +#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) +#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) +#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) +#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) +#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) +#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) +#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) +#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) +#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) +#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) +#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) +#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) +#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) +#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) +#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) +#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) +#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) +#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) +#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) +#define glIsProgram GLEW_GET_FUN(__glewIsProgram) +#define glIsShader GLEW_GET_FUN(__glewIsShader) +#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) +#define glShaderSource GLEW_GET_FUN(__glewShaderSource) +#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) +#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) +#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) +#define glUniform1f GLEW_GET_FUN(__glewUniform1f) +#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) +#define glUniform1i GLEW_GET_FUN(__glewUniform1i) +#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) +#define glUniform2f GLEW_GET_FUN(__glewUniform2f) +#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) +#define glUniform2i GLEW_GET_FUN(__glewUniform2i) +#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) +#define glUniform3f GLEW_GET_FUN(__glewUniform3f) +#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) +#define glUniform3i GLEW_GET_FUN(__glewUniform3i) +#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) +#define glUniform4f GLEW_GET_FUN(__glewUniform4f) +#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) +#define glUniform4i GLEW_GET_FUN(__glewUniform4i) +#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) +#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) +#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) +#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) +#define glUseProgram GLEW_GET_FUN(__glewUseProgram) +#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) +#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) +#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) +#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) +#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) +#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) +#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) +#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) +#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) +#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) +#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) +#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) +#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) +#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) +#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) +#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) +#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) +#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) +#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) +#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) +#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) +#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) +#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) +#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) +#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) +#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) +#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) +#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) +#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) +#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) +#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) +#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) +#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) +#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) +#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) +#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) +#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) +#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) + +#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) + +#endif /* GL_VERSION_2_0 */ + +/* ----------------------------- GL_VERSION_2_1 ---------------------------- */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 + +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B + +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + +#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) +#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) +#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) +#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) +#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) +#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) + +#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) + +#endif /* GL_VERSION_2_1 */ + +/* -------------------------- GL_3DFX_multisample -------------------------- */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 + +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 + +#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) + +#endif /* GL_3DFX_multisample */ + +/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 + +typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); + +#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) + +#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) + +#endif /* GL_3DFX_tbuffer */ + +/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 + +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 + +#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) + +#endif /* GL_3DFX_texture_compression_FXT1 */ + +/* ------------------------ GL_APPLE_client_storage ------------------------ */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 + +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 + +#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) + +#endif /* GL_APPLE_client_storage */ + +/* ------------------------- GL_APPLE_element_array ------------------------ */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 + +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A + +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); + +#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) +#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) +#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) +#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) +#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) + +#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) + +#endif /* GL_APPLE_element_array */ + +/* ----------------------------- GL_APPLE_fence ---------------------------- */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 + +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B + +typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); +typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); +typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); + +#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) +#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) +#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) +#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) +#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) +#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) +#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) +#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) + +#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) + +#endif /* GL_APPLE_fence */ + +/* ------------------------- GL_APPLE_float_pixels ------------------------- */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 + +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F + +#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) + +#endif /* GL_APPLE_float_pixels */ + +/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ + +#ifndef GL_APPLE_pixel_buffer +#define GL_APPLE_pixel_buffer 1 + +#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 + +#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) + +#endif /* GL_APPLE_pixel_buffer */ + +/* ------------------------ GL_APPLE_specular_vector ----------------------- */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 + +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 + +#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) + +#endif /* GL_APPLE_specular_vector */ + +/* ------------------------- GL_APPLE_texture_range ------------------------ */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 + +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); +typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer); + +#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) +#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) + +#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) + +#endif /* GL_APPLE_texture_range */ + +/* ------------------------ GL_APPLE_transform_hint ------------------------ */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 + +#define GL_TRANSFORM_HINT_APPLE 0x85B1 + +#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) + +#endif /* GL_APPLE_transform_hint */ + +/* ---------------------- GL_APPLE_vertex_array_object --------------------- */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 + +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 + +typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); +typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); +typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); + +#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) +#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) +#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) +#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) + +#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) + +#endif /* GL_APPLE_vertex_array_object */ + +/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 + +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF + +typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); + +#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) +#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) +#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) + +#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) + +#endif /* GL_APPLE_vertex_array_range */ + +/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 + +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB + +#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) + +#endif /* GL_APPLE_ycbcr_422 */ + +/* ----------------------- GL_ARB_color_buffer_float ----------------------- */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 + +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D + +typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); + +#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) + +#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) + +#endif /* GL_ARB_color_buffer_float */ + +/* -------------------------- GL_ARB_depth_texture ------------------------- */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B + +#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) + +#endif /* GL_ARB_depth_texture */ + +/* -------------------------- GL_ARB_draw_buffers -------------------------- */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 + +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 + +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); + +#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) + +#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) + +#endif /* GL_ARB_draw_buffers */ + +/* ------------------------ GL_ARB_fragment_program ------------------------ */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 + +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 + +#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) + +#endif /* GL_ARB_fragment_program */ + +/* --------------------- GL_ARB_fragment_program_shadow -------------------- */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 + +#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) + +#endif /* GL_ARB_fragment_program_shadow */ + +/* ------------------------- GL_ARB_fragment_shader ------------------------ */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 + +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B + +#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) + +#endif /* GL_ARB_fragment_shader */ + +/* ------------------------ GL_ARB_half_float_pixel ------------------------ */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 + +#define GL_HALF_FLOAT_ARB 0x140B + +#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) + +#endif /* GL_ARB_half_float_pixel */ + +/* ----------------------------- GL_ARB_imaging ---------------------------- */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_IGNORE_BORDER 0x8150 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_WRAP_BORDER 0x8152 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 + +typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + +#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) +#define glColorTable GLEW_GET_FUN(__glewColorTable) +#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) +#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) +#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) +#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) +#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) +#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) +#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) +#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) +#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) +#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) +#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) +#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) +#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) +#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) +#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) +#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) +#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) +#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) +#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) +#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) +#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) +#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) +#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) +#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) +#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) +#define glHistogram GLEW_GET_FUN(__glewHistogram) +#define glMinmax GLEW_GET_FUN(__glewMinmax) +#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) +#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) +#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) + +#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) + +#endif /* GL_ARB_imaging */ + +/* ------------------------- GL_ARB_matrix_palette ------------------------- */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 + +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 + +typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); +typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); + +#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) +#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) +#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) +#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) +#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) + +#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) + +#endif /* GL_ARB_matrix_palette */ + +/* --------------------------- GL_ARB_multisample -------------------------- */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 + +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); + +#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) + +#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) + +#endif /* GL_ARB_multisample */ + +/* -------------------------- GL_ARB_multitexture -------------------------- */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) +#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) +#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) +#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) +#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) +#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) +#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) +#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) +#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) +#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) +#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) +#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) +#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) +#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) +#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) +#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) +#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) +#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) +#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) +#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) +#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) +#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) +#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) +#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) +#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) +#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) +#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) +#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) +#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) +#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) +#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) +#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) +#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) +#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) + +#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) + +#endif /* GL_ARB_multitexture */ + +/* ------------------------- GL_ARB_occlusion_query ------------------------ */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 + +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); + +#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) +#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) +#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) +#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) +#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) +#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) +#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) +#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) + +#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) + +#endif /* GL_ARB_occlusion_query */ + +/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 + +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF + +#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) + +#endif /* GL_ARB_pixel_buffer_object */ + +/* ------------------------ GL_ARB_point_parameters ------------------------ */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 + +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, GLfloat* params); + +#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) +#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) + +#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) + +#endif /* GL_ARB_point_parameters */ + +/* -------------------------- GL_ARB_point_sprite -------------------------- */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 + +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 + +#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) + +#endif /* GL_ARB_point_sprite */ + +/* ------------------------- GL_ARB_shader_objects ------------------------- */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 + +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 + +typedef char GLcharARB; +typedef unsigned int GLhandleARB; + +typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); +typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); +typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); +typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); + +#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) +#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) +#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) +#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) +#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) +#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) +#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) +#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) +#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) +#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) +#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) +#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) +#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) +#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) +#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) +#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) +#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) +#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) +#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) +#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) +#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) +#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) +#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) +#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) +#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) +#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) +#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) +#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) +#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) +#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) +#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) +#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) +#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) +#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) +#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) +#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) +#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) +#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) +#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) + +#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) + +#endif /* GL_ARB_shader_objects */ + +/* ---------------------- GL_ARB_shading_language_100 ---------------------- */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 + +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C + +#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) + +#endif /* GL_ARB_shading_language_100 */ + +/* ----------------------------- GL_ARB_shadow ----------------------------- */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 + +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E + +#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) + +#endif /* GL_ARB_shadow */ + +/* ------------------------- GL_ARB_shadow_ambient ------------------------- */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 + +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF + +#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) + +#endif /* GL_ARB_shadow_ambient */ + +/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_ARB 0x812D + +#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) + +#endif /* GL_ARB_texture_border_clamp */ + +/* ----------------------- GL_ARB_texture_compression ---------------------- */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 + +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 + +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); +typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img); + +#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) +#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) +#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) +#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) +#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) +#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) +#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) + +#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) + +#endif /* GL_ARB_texture_compression */ + +/* ------------------------ GL_ARB_texture_cube_map ------------------------ */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 + +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C + +#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) + +#endif /* GL_ARB_texture_cube_map */ + +/* ------------------------- GL_ARB_texture_env_add ------------------------ */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 + +#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) + +#endif /* GL_ARB_texture_env_add */ + +/* ----------------------- GL_ARB_texture_env_combine ---------------------- */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 + +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A + +#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) + +#endif /* GL_ARB_texture_env_combine */ + +/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 + +#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) + +#endif /* GL_ARB_texture_env_crossbar */ + +/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 + +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF + +#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) + +#endif /* GL_ARB_texture_env_dot3 */ + +/* -------------------------- GL_ARB_texture_float ------------------------- */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 + +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 + +#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) + +#endif /* GL_ARB_texture_float */ + +/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_ARB 0x8370 + +#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) + +#endif /* GL_ARB_texture_mirrored_repeat */ + +/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 + +#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) + +#endif /* GL_ARB_texture_non_power_of_two */ + +/* ------------------------ GL_ARB_texture_rectangle ----------------------- */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 + +#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) + +#endif /* GL_ARB_texture_rectangle */ + +/* ------------------------ GL_ARB_transpose_matrix ------------------------ */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 + +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 + +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); +typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); + +#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) +#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) +#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) +#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) + +#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) + +#endif /* GL_ARB_transpose_matrix */ + +/* -------------------------- GL_ARB_vertex_blend -------------------------- */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 + +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F + +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); +typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); +typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); + +#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) +#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) +#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) +#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) +#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) +#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) +#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) +#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) +#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) +#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) + +#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) + +#endif /* GL_ARB_vertex_blend */ + +/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 + +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA + +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; + +typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage); +typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params); +typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data); +typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); + +#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) +#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) +#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) +#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) +#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) +#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) +#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) +#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) +#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) +#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) +#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) + +#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) + +#endif /* GL_ARB_vertex_buffer_object */ + +/* ------------------------- GL_ARB_vertex_program ------------------------- */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 + +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF + +typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); +typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); + +#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) +#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) +#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) +#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) +#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) +#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) +#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) +#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) +#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) +#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) +#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) +#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) +#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) +#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) +#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) +#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) +#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) +#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) +#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) +#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) +#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) +#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) +#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) +#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) +#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) +#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) +#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) +#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) +#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) +#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) +#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) +#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) +#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) +#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) +#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) +#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) +#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) +#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) +#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) +#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) +#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) +#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) +#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) +#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) +#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) +#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) +#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) +#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) +#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) +#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) +#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) +#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) +#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) +#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) +#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) +#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) +#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) +#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) +#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) +#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) +#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) +#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) + +#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) + +#endif /* GL_ARB_vertex_program */ + +/* -------------------------- GL_ARB_vertex_shader ------------------------- */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 + +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A + +typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); +typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); + +#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) +#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) +#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) + +#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) + +#endif /* GL_ARB_vertex_shader */ + +/* --------------------------- GL_ARB_window_pos --------------------------- */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 + +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); + +#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) +#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) +#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) +#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) +#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) +#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) +#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) +#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) +#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) +#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) +#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) +#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) +#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) +#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) +#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) +#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) + +#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) + +#endif /* GL_ARB_window_pos */ + +/* ------------------------- GL_ATIX_point_sprites ------------------------- */ + +#ifndef GL_ATIX_point_sprites +#define GL_ATIX_point_sprites 1 + +#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 +#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 +#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 +#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 +#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 +#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 + +#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) + +#endif /* GL_ATIX_point_sprites */ + +/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ + +#ifndef GL_ATIX_texture_env_combine3 +#define GL_ATIX_texture_env_combine3 1 + +#define GL_MODULATE_ADD_ATIX 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 +#define GL_MODULATE_SUBTRACT_ATIX 0x8746 + +#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) + +#endif /* GL_ATIX_texture_env_combine3 */ + +/* ----------------------- GL_ATIX_texture_env_route ----------------------- */ + +#ifndef GL_ATIX_texture_env_route +#define GL_ATIX_texture_env_route 1 + +#define GL_SECONDARY_COLOR_ATIX 0x8747 +#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 +#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 + +#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) + +#endif /* GL_ATIX_texture_env_route */ + +/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ + +#ifndef GL_ATIX_vertex_shader_output_point_size +#define GL_ATIX_vertex_shader_output_point_size 1 + +#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E + +#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) + +#endif /* GL_ATIX_vertex_shader_output_point_size */ + +/* -------------------------- GL_ATI_draw_buffers -------------------------- */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 + +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 + +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); + +#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) + +#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) + +#endif /* GL_ATI_draw_buffers */ + +/* -------------------------- GL_ATI_element_array ------------------------- */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 + +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A + +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer); + +#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) +#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) +#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) + +#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) + +#endif /* GL_ATI_element_array */ + +/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 + +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C + +typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); + +#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) +#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) +#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) +#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) + +#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) + +#endif /* GL_ATI_envmap_bumpmap */ + +/* ------------------------- GL_ATI_fragment_shader ------------------------ */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 + +#define GL_RED_BIT_ATI 0x00000001 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B + +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); + +#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) +#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) +#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) +#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) +#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) +#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) +#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) +#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) +#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) +#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) +#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) +#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) +#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) +#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) + +#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) + +#endif /* GL_ATI_fragment_shader */ + +/* ------------------------ GL_ATI_map_object_buffer ----------------------- */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 + +typedef void* (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); + +#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) +#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) + +#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) + +#endif /* GL_ATI_map_object_buffer */ + +/* -------------------------- GL_ATI_pn_triangles -------------------------- */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 + +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 + +typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); + +#define glPNTrianglesfATI GLEW_GET_FUN(__glPNTrianglewesfATI) +#define glPNTrianglesiATI GLEW_GET_FUN(__glPNTrianglewesiATI) + +#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) + +#endif /* GL_ATI_pn_triangles */ + +/* ------------------------ GL_ATI_separate_stencil ------------------------ */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 + +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 + +typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + +#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) +#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) + +#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) + +#endif /* GL_ATI_separate_stencil */ + +/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ + +#ifndef GL_ATI_shader_texture_lod +#define GL_ATI_shader_texture_lod 1 + +#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) + +#endif /* GL_ATI_shader_texture_lod */ + +/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 + +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 + +#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) + +#endif /* GL_ATI_text_fragment_shader */ + +/* --------------------- GL_ATI_texture_compression_3dc -------------------- */ + +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 + +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 + +#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) + +#endif /* GL_ATI_texture_compression_3dc */ + +/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 + +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 + +#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) + +#endif /* GL_ATI_texture_env_combine3 */ + +/* -------------------------- GL_ATI_texture_float ------------------------- */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 + +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F + +#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) + +#endif /* GL_ATI_texture_float */ + +/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 + +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 + +#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) + +#endif /* GL_ATI_texture_mirror_once */ + +/* ----------------------- GL_ATI_vertex_array_object ---------------------- */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 + +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 + +typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage); +typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve); +typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); + +#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) +#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) +#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) +#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) +#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) +#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) +#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) +#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) +#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) +#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) +#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) +#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) + +#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) + +#endif /* GL_ATI_vertex_array_object */ + +/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 + +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); + +#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) +#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) +#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) + +#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) + +#endif /* GL_ATI_vertex_attrib_array_object */ + +/* ------------------------- GL_ATI_vertex_streams ------------------------- */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 + +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_SOURCE_ATI 0x876C +#define GL_VERTEX_STREAM0_ATI 0x876D +#define GL_VERTEX_STREAM1_ATI 0x876E +#define GL_VERTEX_STREAM2_ATI 0x876F +#define GL_VERTEX_STREAM3_ATI 0x8770 +#define GL_VERTEX_STREAM4_ATI 0x8771 +#define GL_VERTEX_STREAM5_ATI 0x8772 +#define GL_VERTEX_STREAM6_ATI 0x8773 +#define GL_VERTEX_STREAM7_ATI 0x8774 + +typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *v); + +#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) +#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) +#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) +#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) +#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) +#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) +#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) +#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) +#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) +#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) +#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) +#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) +#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) +#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) +#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) +#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) +#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) +#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) +#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) +#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) +#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) +#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) +#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) +#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) +#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) +#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) +#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) +#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) +#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) +#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) +#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) +#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) +#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) +#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) +#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) +#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) +#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) + +#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) + +#endif /* GL_ATI_vertex_streams */ + +/* --------------------------- GL_EXT_422_pixels --------------------------- */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 + +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF + +#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) + +#endif /* GL_EXT_422_pixels */ + +/* ---------------------------- GL_EXT_Cg_shader --------------------------- */ + +#ifndef GL_EXT_Cg_shader +#define GL_EXT_Cg_shader 1 + +#define GL_CG_VERTEX_SHADER_EXT 0x890E +#define GL_CG_FRAGMENT_SHADER_EXT 0x890F + +#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) + +#endif /* GL_EXT_Cg_shader */ + +/* ------------------------------ GL_EXT_abgr ------------------------------ */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 + +#define GL_ABGR_EXT 0x8000 + +#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) + +#endif /* GL_EXT_abgr */ + +/* ------------------------------ GL_EXT_bgra ------------------------------ */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 + +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 + +#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) + +#endif /* GL_EXT_bgra */ + +/* ------------------------ GL_EXT_bindable_uniform ------------------------ */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 + +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF + +typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); + +#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) +#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) +#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) + +#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) + +#endif /* GL_EXT_bindable_uniform */ + +/* --------------------------- GL_EXT_blend_color -------------------------- */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 + +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 + +typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + +#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) + +#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) + +#endif /* GL_EXT_blend_color */ + +/* --------------------- GL_EXT_blend_equation_separate -------------------- */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 + +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); + +#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) + +#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) + +#endif /* GL_EXT_blend_equation_separate */ + +/* ----------------------- GL_EXT_blend_func_separate ---------------------- */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 + +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB + +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + +#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) + +#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) + +#endif /* GL_EXT_blend_func_separate */ + +/* ------------------------- GL_EXT_blend_logic_op ------------------------- */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 + +#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) + +#endif /* GL_EXT_blend_logic_op */ + +/* -------------------------- GL_EXT_blend_minmax -------------------------- */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 + +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); + +#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) + +#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) + +#endif /* GL_EXT_blend_minmax */ + +/* ------------------------- GL_EXT_blend_subtract ------------------------- */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 + +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B + +#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) + +#endif /* GL_EXT_blend_subtract */ + +/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 + +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 + +#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) + +#endif /* GL_EXT_clip_volume_hint */ + +/* ------------------------------ GL_EXT_cmyka ----------------------------- */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 + +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F + +#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) + +#endif /* GL_EXT_cmyka */ + +/* ------------------------- GL_EXT_color_subtable ------------------------- */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 + +typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + +#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) +#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) + +#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) + +#endif /* GL_EXT_color_subtable */ + +/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 + +typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); + +#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) +#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) + +#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) + +#endif /* GL_EXT_compiled_vertex_array */ + +/* --------------------------- GL_EXT_convolution -------------------------- */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 + +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 + +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span); +typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column); + +#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) +#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) +#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) +#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) +#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) +#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) +#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) +#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) +#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) +#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) +#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) +#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) +#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) + +#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) + +#endif /* GL_EXT_convolution */ + +/* ------------------------ GL_EXT_coordinate_frame ------------------------ */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 + +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 + +typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); +typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); + +#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) +#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) + +#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) + +#endif /* GL_EXT_coordinate_frame */ + +/* -------------------------- GL_EXT_copy_texture -------------------------- */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 + +typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + +#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) +#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) +#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) +#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) +#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) + +#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) + +#endif /* GL_EXT_copy_texture */ + +/* --------------------------- GL_EXT_cull_vertex -------------------------- */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 + +typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); + +#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) +#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) + +#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) + +#endif /* GL_EXT_cull_vertex */ + +/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 + +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 + +typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); + +#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) + +#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) + +#endif /* GL_EXT_depth_bounds_test */ + +/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 + +typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); + +#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) +#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) +#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) +#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) +#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) +#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) + +#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) + +#endif /* GL_EXT_draw_buffers2 */ + +/* ------------------------- GL_EXT_draw_instanced ------------------------- */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 + +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); + +#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) +#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) + +#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) + +#endif /* GL_EXT_draw_instanced */ + +/* ----------------------- GL_EXT_draw_range_elements ---------------------- */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 + +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 + +typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) + +#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) + +#endif /* GL_EXT_draw_range_elements */ + +/* ---------------------------- GL_EXT_fog_coord --------------------------- */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 + +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 + +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); + +#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) +#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) +#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) +#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) +#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) + +#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) + +#endif /* GL_EXT_fog_coord */ + +/* ------------------------ GL_EXT_fragment_lighting ----------------------- */ + +#ifndef GL_EXT_fragment_lighting +#define GL_EXT_fragment_lighting 1 + +#define GL_FRAGMENT_LIGHTING_EXT 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 +#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 +#define GL_LIGHT_ENV_MODE_EXT 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B +#define GL_FRAGMENT_LIGHT0_EXT 0x840C +#define GL_FRAGMENT_LIGHT7_EXT 0x8413 + +typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); + +#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) +#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) +#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) +#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) +#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) +#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) +#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) +#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) +#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) +#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) +#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) +#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) +#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) +#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) +#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) +#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) +#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) +#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) + +#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) + +#endif /* GL_EXT_fragment_lighting */ + +/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 + +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA + +typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + +#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) + +#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) + +#endif /* GL_EXT_framebuffer_blit */ + +/* --------------------- GL_EXT_framebuffer_multisample -------------------- */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 + +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 + +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + +#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) + +#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) + +#endif /* GL_EXT_framebuffer_multisample */ + +/* ----------------------- GL_EXT_framebuffer_object ----------------------- */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 + +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 + +typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); +typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); +typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); +typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + +#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) +#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) +#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) +#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) +#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) +#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) +#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) +#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) +#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) +#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) +#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) +#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) +#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) +#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) +#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) +#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) +#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) + +#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) + +#endif /* GL_EXT_framebuffer_object */ + +/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 + +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA + +#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) + +#endif /* GL_EXT_framebuffer_sRGB */ + +/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 + +#define GL_LINES_ADJACENCY_EXT 0xA +#define GL_LINE_STRIP_ADJACENCY_EXT 0xB +#define GL_TRIANGLES_ADJACENCY_EXT 0xC +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 + +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); + +#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) +#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) +#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) +#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) + +#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) + +#endif /* GL_EXT_geometry_shader4 */ + +/* --------------------- GL_EXT_gpu_program_parameters --------------------- */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 + +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); + +#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) +#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) + +#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) + +#endif /* GL_EXT_gpu_program_parameters */ + +/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 + +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 + +typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); + +#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) +#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) +#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) +#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) +#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) +#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) +#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) +#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) +#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) +#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) +#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) +#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) +#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) +#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) +#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) +#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) +#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) +#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) +#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) +#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) +#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) +#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) +#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) +#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) +#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) +#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) +#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) +#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) +#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) +#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) +#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) +#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) +#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) +#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) + +#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) + +#endif /* GL_EXT_gpu_shader4 */ + +/* ---------------------------- GL_EXT_histogram --------------------------- */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 + +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 + +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); + +#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) +#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) +#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) +#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) +#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) +#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) +#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) +#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) +#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) +#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) + +#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) + +#endif /* GL_EXT_histogram */ + +/* ----------------------- GL_EXT_index_array_formats ---------------------- */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 + +#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) + +#endif /* GL_EXT_index_array_formats */ + +/* --------------------------- GL_EXT_index_func --------------------------- */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 + +typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); + +#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) + +#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) + +#endif /* GL_EXT_index_func */ + +/* ------------------------- GL_EXT_index_material ------------------------- */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 + +typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); + +#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) + +#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) + +#endif /* GL_EXT_index_material */ + +/* -------------------------- GL_EXT_index_texture ------------------------- */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 + +#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) + +#endif /* GL_EXT_index_texture */ + +/* -------------------------- GL_EXT_light_texture ------------------------- */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 + +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 + +typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); + +#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) +#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) +#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) + +#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) + +#endif /* GL_EXT_light_texture */ + +/* ------------------------- GL_EXT_misc_attribute ------------------------- */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 + +#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) + +#endif /* GL_EXT_misc_attribute */ + +/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 + +typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint* first, GLsizei *count, GLsizei primcount); +typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount); + +#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) +#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) + +#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) + +#endif /* GL_EXT_multi_draw_arrays */ + +/* --------------------------- GL_EXT_multisample -------------------------- */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 + +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); + +#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) +#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) + +#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) + +#endif /* GL_EXT_multisample */ + +/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 + +#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) + +#endif /* GL_EXT_packed_depth_stencil */ + +/* -------------------------- GL_EXT_packed_float -------------------------- */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 + +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C + +#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) + +#endif /* GL_EXT_packed_float */ + +/* -------------------------- GL_EXT_packed_pixels ------------------------- */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 + +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 + +#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) + +#endif /* GL_EXT_packed_pixels */ + +/* ------------------------ GL_EXT_paletted_texture ------------------------ */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 + +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 +#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B + +typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); + +#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) +#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) +#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) +#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) + +#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) + +#endif /* GL_EXT_paletted_texture */ + +/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 + +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF + +#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) + +#endif /* GL_EXT_pixel_buffer_object */ + +/* ------------------------- GL_EXT_pixel_transform ------------------------ */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 + +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 + +typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) +#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) +#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) +#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) +#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) +#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) + +#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) + +#endif /* GL_EXT_pixel_transform */ + +/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 + +#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) + +#endif /* GL_EXT_pixel_transform_color_table */ + +/* ------------------------ GL_EXT_point_parameters ------------------------ */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 + +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); + +#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) +#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) + +#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) + +#endif /* GL_EXT_point_parameters */ + +/* ------------------------- GL_EXT_polygon_offset ------------------------- */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 + +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 + +typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); + +#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) + +#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) + +#endif /* GL_EXT_polygon_offset */ + +/* ------------------------- GL_EXT_rescale_normal ------------------------- */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 + +#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) + +#endif /* GL_EXT_rescale_normal */ + +/* -------------------------- GL_EXT_scene_marker -------------------------- */ + +#ifndef GL_EXT_scene_marker +#define GL_EXT_scene_marker 1 + +typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); + +#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) +#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) + +#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) + +#endif /* GL_EXT_scene_marker */ + +/* ------------------------- GL_EXT_secondary_color ------------------------ */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 + +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E + +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); + +#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) +#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) +#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) +#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) +#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) +#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) +#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) +#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) +#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) +#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) +#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) +#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) +#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) +#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) +#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) +#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) +#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) + +#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) + +#endif /* GL_EXT_secondary_color */ + +/* --------------------- GL_EXT_separate_specular_color -------------------- */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 + +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA + +#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) + +#endif /* GL_EXT_separate_specular_color */ + +/* -------------------------- GL_EXT_shadow_funcs -------------------------- */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 + +#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) + +#endif /* GL_EXT_shadow_funcs */ + +/* --------------------- GL_EXT_shared_texture_palette --------------------- */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 + +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB + +#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) + +#endif /* GL_EXT_shared_texture_palette */ + +/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 + +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 + +#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) + +#endif /* GL_EXT_stencil_clear_tag */ + +/* ------------------------ GL_EXT_stencil_two_side ------------------------ */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 + +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 + +typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); + +#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) + +#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) + +#endif /* GL_EXT_stencil_two_side */ + +/* -------------------------- GL_EXT_stencil_wrap -------------------------- */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 + +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 + +#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) + +#endif /* GL_EXT_stencil_wrap */ + +/* --------------------------- GL_EXT_subtexture --------------------------- */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 + +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); + +#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) +#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) +#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) + +#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) + +#endif /* GL_EXT_subtexture */ + +/* ----------------------------- GL_EXT_texture ---------------------------- */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 + +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 + +#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) + +#endif /* GL_EXT_texture */ + +/* ---------------------------- GL_EXT_texture3D --------------------------- */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 + +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 + +typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); + +#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) + +#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) + +#endif /* GL_EXT_texture3D */ + +/* -------------------------- GL_EXT_texture_array ------------------------- */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 + +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D + +#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) + +#endif /* GL_EXT_texture_array */ + +/* ---------------------- GL_EXT_texture_buffer_object --------------------- */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 + +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E + +typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); + +#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) + +#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) + +#endif /* GL_EXT_texture_buffer_object */ + +/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ + +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 + +#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) + +#endif /* GL_EXT_texture_compression_dxt1 */ + +/* -------------------- GL_EXT_texture_compression_latc -------------------- */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 + +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 + +#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) + +#endif /* GL_EXT_texture_compression_latc */ + +/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 + +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE + +#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) + +#endif /* GL_EXT_texture_compression_rgtc */ + +/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 + +#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) + +#endif /* GL_EXT_texture_compression_s3tc */ + +/* ------------------------ GL_EXT_texture_cube_map ------------------------ */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 + +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C + +#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) + +#endif /* GL_EXT_texture_cube_map */ + +/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ + +#ifndef GL_EXT_texture_edge_clamp +#define GL_EXT_texture_edge_clamp 1 + +#define GL_CLAMP_TO_EDGE_EXT 0x812F + +#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) + +#endif /* GL_EXT_texture_edge_clamp */ + +/* --------------------------- GL_EXT_texture_env -------------------------- */ + +#ifndef GL_EXT_texture_env +#define GL_EXT_texture_env 1 + +#define GL_TEXTURE_ENV0_EXT 0 +#define GL_ENV_BLEND_EXT 0 +#define GL_TEXTURE_ENV_SHIFT_EXT 0 +#define GL_ENV_REPLACE_EXT 0 +#define GL_ENV_ADD_EXT 0 +#define GL_ENV_SUBTRACT_EXT 0 +#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0 +#define GL_ENV_REVERSE_SUBTRACT_EXT 0 +#define GL_ENV_REVERSE_BLEND_EXT 0 +#define GL_ENV_COPY_EXT 0 +#define GL_ENV_MODULATE_EXT 0 + +#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) + +#endif /* GL_EXT_texture_env */ + +/* ------------------------- GL_EXT_texture_env_add ------------------------ */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 + +#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) + +#endif /* GL_EXT_texture_env_add */ + +/* ----------------------- GL_EXT_texture_env_combine ---------------------- */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 + +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A + +#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) + +#endif /* GL_EXT_texture_env_combine */ + +/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 + +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 + +#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) + +#endif /* GL_EXT_texture_env_dot3 */ + +/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 + +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + +#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) + +#endif /* GL_EXT_texture_filter_anisotropic */ + +/* ------------------------- GL_EXT_texture_integer ------------------------ */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 + +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E + +typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); + +#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) +#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) +#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) +#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) +#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) +#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) + +#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) + +#endif /* GL_EXT_texture_integer */ + +/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 + +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 + +#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) + +#endif /* GL_EXT_texture_lod_bias */ + +/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 + +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 + +#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) + +#endif /* GL_EXT_texture_mirror_clamp */ + +/* ------------------------- GL_EXT_texture_object ------------------------- */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 + +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A + +typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); +typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); +typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); +typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); + +#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) +#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) +#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) +#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) +#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) +#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) + +#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) + +#endif /* GL_EXT_texture_object */ + +/* --------------------- GL_EXT_texture_perturb_normal --------------------- */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 + +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF + +typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); + +#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) + +#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) + +#endif /* GL_EXT_texture_perturb_normal */ + +/* ------------------------ GL_EXT_texture_rectangle ----------------------- */ + +#ifndef GL_EXT_texture_rectangle +#define GL_EXT_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 + +#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) + +#endif /* GL_EXT_texture_rectangle */ + +/* -------------------------- GL_EXT_texture_sRGB -------------------------- */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 + +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F + +#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) + +#endif /* GL_EXT_texture_sRGB */ + +/* --------------------- GL_EXT_texture_shared_exponent -------------------- */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 + +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F + +#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) + +#endif /* GL_EXT_texture_shared_exponent */ + +/* --------------------------- GL_EXT_timer_query -------------------------- */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 + +#define GL_TIME_ELAPSED_EXT 0x88BF + +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); + +#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) +#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) + +#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) + +#endif /* GL_EXT_timer_query */ + +/* -------------------------- GL_EXT_vertex_array -------------------------- */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 + +#define GL_DOUBLE_EXT 0x140A +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 + +typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); +typedef void (GLAPIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, void** params); +typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); + +#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) +#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) +#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) +#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) +#define glGetPointervEXT GLEW_GET_FUN(__glewGetPointervEXT) +#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) +#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) +#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) +#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) + +#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) + +#endif /* GL_EXT_vertex_array */ + +/* -------------------------- GL_EXT_vertex_shader ------------------------- */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 + +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED + +typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); +typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); +typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); +typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); +typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); + +#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) +#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) +#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) +#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) +#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) +#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) +#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) +#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) +#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) +#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) +#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) +#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) +#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) +#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) +#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) +#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) +#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) +#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) +#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) +#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) +#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) +#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) +#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) +#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) +#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) +#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) +#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) +#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) +#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) +#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) +#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) +#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) +#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) +#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) +#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) +#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) +#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) +#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) +#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) +#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) +#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) +#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) + +#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) + +#endif /* GL_EXT_vertex_shader */ + +/* ------------------------ GL_EXT_vertex_weighting ------------------------ */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 + +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 + +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); + +#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) +#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) +#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) + +#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) + +#endif /* GL_EXT_vertex_weighting */ + +/* ------------------------ GL_GREMEDY_string_marker ----------------------- */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 + +typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string); + +#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) + +#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) + +#endif /* GL_GREMEDY_string_marker */ + +/* --------------------- GL_HP_convolution_border_modes -------------------- */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 + +#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) + +#endif /* GL_HP_convolution_border_modes */ + +/* ------------------------- GL_HP_image_transform ------------------------- */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 + +typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) +#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) +#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) +#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) +#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) +#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) + +#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) + +#endif /* GL_HP_image_transform */ + +/* -------------------------- GL_HP_occlusion_test ------------------------- */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 + +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 + +#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) + +#endif /* GL_HP_occlusion_test */ + +/* ------------------------- GL_HP_texture_lighting ------------------------ */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 + +#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) + +#endif /* GL_HP_texture_lighting */ + +/* --------------------------- GL_IBM_cull_vertex -------------------------- */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 + +#define GL_CULL_VERTEX_IBM 103050 + +#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) + +#endif /* GL_IBM_cull_vertex */ + +/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 + +typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride); + +#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) +#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) + +#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) + +#endif /* GL_IBM_multimode_draw_arrays */ + +/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 + +#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 + +#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) + +#endif /* GL_IBM_rasterpos_clip */ + +/* --------------------------- GL_IBM_static_data -------------------------- */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 + +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 + +#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) + +#endif /* GL_IBM_static_data */ + +/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_IBM 0x8370 + +#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) + +#endif /* GL_IBM_texture_mirrored_repeat */ + +/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 + +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 + +typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); + +#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) +#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) +#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) +#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) +#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) +#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) +#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) +#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) + +#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) + +#endif /* GL_IBM_vertex_array_lists */ + +/* -------------------------- GL_INGR_color_clamp -------------------------- */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 + +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 + +#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) + +#endif /* GL_INGR_color_clamp */ + +/* ------------------------- GL_INGR_interlace_read ------------------------ */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 + +#define GL_INTERLACE_READ_INGR 0x8568 + +#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) + +#endif /* GL_INGR_interlace_read */ + +/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 + +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 + +typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); + +#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) +#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) +#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) +#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) + +#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) + +#endif /* GL_INTEL_parallel_arrays */ + +/* ------------------------ GL_INTEL_texture_scissor ----------------------- */ + +#ifndef GL_INTEL_texture_scissor +#define GL_INTEL_texture_scissor 1 + +typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); +typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); + +#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) +#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) + +#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) + +#endif /* GL_INTEL_texture_scissor */ + +/* -------------------------- GL_KTX_buffer_region ------------------------- */ + +#ifndef GL_KTX_buffer_region +#define GL_KTX_buffer_region 1 + +#define GL_KTX_FRONT_REGION 0x0 +#define GL_KTX_BACK_REGION 0x1 +#define GL_KTX_Z_REGION 0x2 +#define GL_KTX_STENCIL_REGION 0x3 + +typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDEXTPROC) (void); +typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONEXTPROC) (GLenum region); +typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); +typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONEXTPROC) (GLenum region); +typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); + +#define glBufferRegionEnabledEXT GLEW_GET_FUN(__glewBufferRegionEnabledEXT) +#define glDeleteBufferRegionEXT GLEW_GET_FUN(__glewDeleteBufferRegionEXT) +#define glDrawBufferRegionEXT GLEW_GET_FUN(__glewDrawBufferRegionEXT) +#define glNewBufferRegionEXT GLEW_GET_FUN(__glewNewBufferRegionEXT) +#define glReadBufferRegionEXT GLEW_GET_FUN(__glewReadBufferRegionEXT) + +#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) + +#endif /* GL_KTX_buffer_region */ + +/* ------------------------- GL_MESAX_texture_stack ------------------------ */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 + +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E + +#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) + +#endif /* GL_MESAX_texture_stack */ + +/* -------------------------- GL_MESA_pack_invert -------------------------- */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 + +#define GL_PACK_INVERT_MESA 0x8758 + +#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) + +#endif /* GL_MESA_pack_invert */ + +/* ------------------------- GL_MESA_resize_buffers ------------------------ */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 + +typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); + +#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) + +#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) + +#endif /* GL_MESA_resize_buffers */ + +/* --------------------------- GL_MESA_window_pos -------------------------- */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 + +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); + +#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) +#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) +#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) +#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) +#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) +#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) +#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) +#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) +#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) +#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) +#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) +#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) +#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) +#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) +#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) +#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) +#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) +#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) +#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) +#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) +#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) +#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) +#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) +#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) + +#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) + +#endif /* GL_MESA_window_pos */ + +/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 + +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 + +#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) + +#endif /* GL_MESA_ycbcr_texture */ + +/* --------------------------- GL_NV_blend_square -------------------------- */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 + +#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) + +#endif /* GL_NV_blend_square */ + +/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 + +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F + +#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) + +#endif /* GL_NV_copy_depth_to_color */ + +/* ------------------------ GL_NV_depth_buffer_float ----------------------- */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 + +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF + +typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); + +#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) +#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) +#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) + +#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) + +#endif /* GL_NV_depth_buffer_float */ + +/* --------------------------- GL_NV_depth_clamp --------------------------- */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 + +#define GL_DEPTH_CLAMP_NV 0x864F + +#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) + +#endif /* GL_NV_depth_clamp */ + +/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ + +#ifndef GL_NV_depth_range_unclamped +#define GL_NV_depth_range_unclamped 1 + +#define GL_SAMPLE_COUNT_BITS_NV 0x8864 +#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 +#define GL_QUERY_RESULT_NV 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 +#define GL_SAMPLE_COUNT_NV 0x8914 + +#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) + +#endif /* GL_NV_depth_range_unclamped */ + +/* ---------------------------- GL_NV_evaluators --------------------------- */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 + +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 + +typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points); +typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points); +typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); + +#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) +#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) +#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) +#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) +#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) +#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) +#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) +#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) +#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) + +#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) + +#endif /* GL_NV_evaluators */ + +/* ------------------------------ GL_NV_fence ------------------------------ */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 + +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 + +typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); +typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); +typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); +typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); + +#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) +#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) +#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) +#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) +#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) +#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) +#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) + +#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) + +#endif /* GL_NV_fence */ + +/* --------------------------- GL_NV_float_buffer -------------------------- */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 + +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E + +#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) + +#endif /* GL_NV_float_buffer */ + +/* --------------------------- GL_NV_fog_distance -------------------------- */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 + +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C + +#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) + +#endif /* GL_NV_fog_distance */ + +/* ------------------------- GL_NV_fragment_program ------------------------ */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 + +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 + +typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); + +#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) +#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) +#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) +#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) +#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) +#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) + +#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) + +#endif /* GL_NV_fragment_program */ + +/* ------------------------ GL_NV_fragment_program2 ------------------------ */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 + +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 + +#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) + +#endif /* GL_NV_fragment_program2 */ + +/* ------------------------ GL_NV_fragment_program4 ------------------------ */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 + +#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) + +#endif /* GL_NV_fragment_program4 */ + +/* --------------------- GL_NV_fragment_program_option --------------------- */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 + +#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) + +#endif /* GL_NV_fragment_program_option */ + +/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 + +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 + +typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); + +#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) + +#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) + +#endif /* GL_NV_framebuffer_multisample_coverage */ + +/* ------------------------ GL_NV_geometry_program4 ------------------------ */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 + +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 + +typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); + +#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) + +#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) + +#endif /* GL_NV_geometry_program4 */ + +/* ------------------------- GL_NV_geometry_shader4 ------------------------ */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 + +#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) + +#endif /* GL_NV_geometry_shader4 */ + +/* --------------------------- GL_NV_gpu_program4 -------------------------- */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 + +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 + +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); + +#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) +#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) +#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) +#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) +#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) +#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) +#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) +#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) +#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) +#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) +#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) +#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) + +#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) + +#endif /* GL_NV_gpu_program4 */ + +/* ---------------------------- GL_NV_half_float --------------------------- */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 + +#define GL_HALF_FLOAT_NV 0x140B + +typedef unsigned short GLhalf; + +typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); +typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); +typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); +typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); +typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); +typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); +typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); +typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); +typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); +typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); +typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); + +#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) +#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) +#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) +#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) +#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) +#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) +#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) +#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) +#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) +#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) +#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) +#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) +#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) +#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) +#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) +#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) +#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) +#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) +#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) +#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) +#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) +#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) +#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) +#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) +#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) +#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) +#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) +#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) +#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) +#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) +#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) +#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) +#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) +#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) +#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) +#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) +#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) +#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) +#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) +#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) +#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) +#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) +#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) +#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) +#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) +#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) + +#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) + +#endif /* GL_NV_half_float */ + +/* ------------------------ GL_NV_light_max_exponent ----------------------- */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 + +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 + +#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) + +#endif /* GL_NV_light_max_exponent */ + +/* --------------------- GL_NV_multisample_filter_hint --------------------- */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 + +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 + +#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) + +#endif /* GL_NV_multisample_filter_hint */ + +/* ------------------------- GL_NV_occlusion_query ------------------------- */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 + +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 + +typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); + +#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) +#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) +#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) +#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) +#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) +#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) +#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) + +#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) + +#endif /* GL_NV_occlusion_query */ + +/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA + +#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) + +#endif /* GL_NV_packed_depth_stencil */ + +/* --------------------- GL_NV_parameter_buffer_object --------------------- */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 + +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 + +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); + +#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) +#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) +#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) + +#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) + +#endif /* GL_NV_parameter_buffer_object */ + +/* ------------------------- GL_NV_pixel_data_range ------------------------ */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 + +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D + +typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer); + +#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) +#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) + +#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) + +#endif /* GL_NV_pixel_data_range */ + +/* --------------------------- GL_NV_point_sprite -------------------------- */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 + +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 + +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); + +#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) +#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) + +#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) + +#endif /* GL_NV_point_sprite */ + +/* ------------------------ GL_NV_primitive_restart ------------------------ */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 + +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 + +typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); + +#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) +#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) + +#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) + +#endif /* GL_NV_primitive_restart */ + +/* ------------------------ GL_NV_register_combiners ----------------------- */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 + +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 + +typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); + +#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) +#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) +#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) +#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) +#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) +#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) +#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) +#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) +#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) +#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) +#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) +#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) +#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) + +#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) + +#endif /* GL_NV_register_combiners */ + +/* ----------------------- GL_NV_register_combiners2 ----------------------- */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 + +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 + +typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); + +#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) +#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) + +#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) + +#endif /* GL_NV_register_combiners2 */ + +/* -------------------------- GL_NV_texgen_emboss -------------------------- */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 + +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F + +#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) + +#endif /* GL_NV_texgen_emboss */ + +/* ------------------------ GL_NV_texgen_reflection ------------------------ */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 + +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 + +#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) + +#endif /* GL_NV_texgen_reflection */ + +/* --------------------- GL_NV_texture_compression_vtc --------------------- */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 + +#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) + +#endif /* GL_NV_texture_compression_vtc */ + +/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 + +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B + +#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) + +#endif /* GL_NV_texture_env_combine4 */ + +/* ---------------------- GL_NV_texture_expand_normal ---------------------- */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 + +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F + +#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) + +#endif /* GL_NV_texture_expand_normal */ + +/* ------------------------ GL_NV_texture_rectangle ------------------------ */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 + +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 + +#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) + +#endif /* GL_NV_texture_rectangle */ + +/* -------------------------- GL_NV_texture_shader ------------------------- */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 + +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F + +#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) + +#endif /* GL_NV_texture_shader */ + +/* ------------------------- GL_NV_texture_shader2 ------------------------- */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 + +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D + +#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) + +#endif /* GL_NV_texture_shader2 */ + +/* ------------------------- GL_NV_texture_shader3 ------------------------- */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 + +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 + +#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) + +#endif /* GL_NV_texture_shader3 */ + +/* ------------------------ GL_NV_transform_feedback ----------------------- */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 + +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F + +typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); + +#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) +#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) +#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) +#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) +#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) +#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) +#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) +#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) +#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) +#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) +#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) + +#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) + +#endif /* GL_NV_transform_feedback */ + +/* ------------------------ GL_NV_vertex_array_range ----------------------- */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 + +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 + +typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer); + +#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) +#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) + +#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) + +#endif /* GL_NV_vertex_array_range */ + +/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 + +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 + +#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) + +#endif /* GL_NV_vertex_array_range2 */ + +/* -------------------------- GL_NV_vertex_program ------------------------- */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 + +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F + +typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); +typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint num, const GLdouble* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint num, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); +typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); + +#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) +#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) +#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) +#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) +#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) +#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) +#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) +#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) +#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) +#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) +#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) +#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) +#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) +#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) +#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) +#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) +#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) +#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) +#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) +#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) +#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) +#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) +#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) +#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) +#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) +#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) +#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) +#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) +#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) +#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) +#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) +#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) +#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) +#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) +#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) +#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) +#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) +#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) +#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) +#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) +#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) +#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) +#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) +#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) +#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) +#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) +#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) +#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) +#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) +#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) +#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) +#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) +#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) +#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) +#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) +#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) +#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) +#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) +#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) +#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) +#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) +#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) +#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) +#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) + +#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) + +#endif /* GL_NV_vertex_program */ + +/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 + +#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) + +#endif /* GL_NV_vertex_program1_1 */ + +/* ------------------------- GL_NV_vertex_program2 ------------------------- */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 + +#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) + +#endif /* GL_NV_vertex_program2 */ + +/* ---------------------- GL_NV_vertex_program2_option --------------------- */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 + +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 + +#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) + +#endif /* GL_NV_vertex_program2_option */ + +/* ------------------------- GL_NV_vertex_program3 ------------------------- */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 + +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C + +#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) + +#endif /* GL_NV_vertex_program3 */ + +/* ------------------------- GL_NV_vertex_program4 ------------------------- */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 + +#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) + +#endif /* GL_NV_vertex_program4 */ + +/* ------------------------ GL_OES_byte_coordinates ------------------------ */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 + +#define GL_BYTE 0x1400 + +#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) + +#endif /* GL_OES_byte_coordinates */ + +/* ------------------- GL_OES_compressed_paletted_texture ------------------ */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 + +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 + +#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) + +#endif /* GL_OES_compressed_paletted_texture */ + +/* --------------------------- GL_OES_read_format -------------------------- */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 + +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B + +#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) + +#endif /* GL_OES_read_format */ + +/* ------------------------ GL_OES_single_precision ------------------------ */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 + +typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth); +typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); +typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); +typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); + +#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) +#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) +#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) +#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) +#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) +#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) + +#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) + +#endif /* GL_OES_single_precision */ + +/* ---------------------------- GL_OML_interlace --------------------------- */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 + +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 + +#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) + +#endif /* GL_OML_interlace */ + +/* ---------------------------- GL_OML_resample ---------------------------- */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 + +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 + +#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) + +#endif /* GL_OML_resample */ + +/* ---------------------------- GL_OML_subsample --------------------------- */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 + +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 + +#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) + +#endif /* GL_OML_subsample */ + +/* --------------------------- GL_PGI_misc_hints --------------------------- */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 + +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 +#define GL_CONSERVE_MEMORY_HINT_PGI 107005 +#define GL_RECLAIM_MEMORY_HINT_PGI 107006 +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 +#define GL_ALWAYS_FAST_HINT_PGI 107020 +#define GL_ALWAYS_SOFT_HINT_PGI 107021 +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 +#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 +#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 +#define GL_STRICT_LIGHTING_HINT_PGI 107031 +#define GL_STRICT_SCISSOR_HINT_PGI 107032 +#define GL_FULL_STIPPLE_HINT_PGI 107033 +#define GL_CLIP_NEAR_HINT_PGI 107040 +#define GL_CLIP_FAR_HINT_PGI 107041 +#define GL_WIDE_LINE_HINT_PGI 107042 +#define GL_BACK_NORMALS_HINT_PGI 107043 + +#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) + +#endif /* GL_PGI_misc_hints */ + +/* -------------------------- GL_PGI_vertex_hints -------------------------- */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 + +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_VERTEX_DATA_HINT_PGI 107050 +#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 +#define GL_MATERIAL_SIDE_HINT_PGI 107052 +#define GL_MAX_VERTEX_HINT_PGI 107053 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 + +#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) + +#endif /* GL_PGI_vertex_hints */ + +/* ----------------------- GL_REND_screen_coordinates ---------------------- */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 + +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 + +#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) + +#endif /* GL_REND_screen_coordinates */ + +/* ------------------------------- GL_S3_s3tc ------------------------------ */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 + +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 + +#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) + +#endif /* GL_S3_s3tc */ + +/* -------------------------- GL_SGIS_color_range -------------------------- */ + +#ifndef GL_SGIS_color_range +#define GL_SGIS_color_range 1 + +#define GL_EXTENDED_RANGE_SGIS 0x85A5 +#define GL_MIN_RED_SGIS 0x85A6 +#define GL_MAX_RED_SGIS 0x85A7 +#define GL_MIN_GREEN_SGIS 0x85A8 +#define GL_MAX_GREEN_SGIS 0x85A9 +#define GL_MIN_BLUE_SGIS 0x85AA +#define GL_MAX_BLUE_SGIS 0x85AB +#define GL_MIN_ALPHA_SGIS 0x85AC +#define GL_MAX_ALPHA_SGIS 0x85AD + +#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) + +#endif /* GL_SGIS_color_range */ + +/* ------------------------- GL_SGIS_detail_texture ------------------------ */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 + +typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); +typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); + +#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) +#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) + +#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) + +#endif /* GL_SGIS_detail_texture */ + +/* -------------------------- GL_SGIS_fog_function ------------------------- */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 + +typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); +typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); + +#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) +#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) + +#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) + +#endif /* GL_SGIS_fog_function */ + +/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 + +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 + +#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) + +#endif /* GL_SGIS_generate_mipmap */ + +/* -------------------------- GL_SGIS_multisample -------------------------- */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 + +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 + +typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); + +#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) +#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) + +#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) + +#endif /* GL_SGIS_multisample */ + +/* ------------------------- GL_SGIS_pixel_texture ------------------------- */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 + +#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) + +#endif /* GL_SGIS_pixel_texture */ + +/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 + +typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); +typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); + +#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) +#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) + +#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) + +#endif /* GL_SGIS_sharpen_texture */ + +/* --------------------------- GL_SGIS_texture4D --------------------------- */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 + +typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels); +typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels); + +#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) +#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) + +#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) + +#endif /* GL_SGIS_texture4D */ + +/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_SGIS 0x812D + +#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) + +#endif /* GL_SGIS_texture_border_clamp */ + +/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 + +#define GL_CLAMP_TO_EDGE_SGIS 0x812F + +#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) + +#endif /* GL_SGIS_texture_edge_clamp */ + +/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 + +typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); +typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); + +#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) +#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) + +#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) + +#endif /* GL_SGIS_texture_filter4 */ + +/* -------------------------- GL_SGIS_texture_lod -------------------------- */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 + +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D + +#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) + +#endif /* GL_SGIS_texture_lod */ + +/* ------------------------- GL_SGIS_texture_select ------------------------ */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 + +#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) + +#endif /* GL_SGIS_texture_select */ + +/* ----------------------------- GL_SGIX_async ----------------------------- */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 + +#define GL_ASYNC_MARKER_SGIX 0x8329 + +typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); +typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); + +#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) +#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) +#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) +#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) +#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) +#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) + +#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) + +#endif /* GL_SGIX_async */ + +/* ------------------------ GL_SGIX_async_histogram ------------------------ */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 + +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D + +#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) + +#endif /* GL_SGIX_async_histogram */ + +/* -------------------------- GL_SGIX_async_pixel -------------------------- */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 + +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 + +#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) + +#endif /* GL_SGIX_async_pixel */ + +/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 + +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 + +#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) + +#endif /* GL_SGIX_blend_alpha_minmax */ + +/* ---------------------------- GL_SGIX_clipmap ---------------------------- */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 + +#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) + +#endif /* GL_SGIX_clipmap */ + +/* ------------------------- GL_SGIX_depth_texture ------------------------- */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 + +#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) + +#endif /* GL_SGIX_depth_texture */ + +/* -------------------------- GL_SGIX_flush_raster ------------------------- */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 + +typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); + +#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) + +#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) + +#endif /* GL_SGIX_flush_raster */ + +/* --------------------------- GL_SGIX_fog_offset -------------------------- */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 + +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 + +#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) + +#endif /* GL_SGIX_fog_offset */ + +/* -------------------------- GL_SGIX_fog_texture -------------------------- */ + +#ifndef GL_SGIX_fog_texture +#define GL_SGIX_fog_texture 1 + +#define GL_TEXTURE_FOG_SGIX 0 +#define GL_FOG_PATCHY_FACTOR_SGIX 0 +#define GL_FRAGMENT_FOG_SGIX 0 + +typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); + +#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) + +#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) + +#endif /* GL_SGIX_fog_texture */ + +/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ + +#ifndef GL_SGIX_fragment_specular_lighting +#define GL_SGIX_fragment_specular_lighting 1 + +typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); +typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); +typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); + +#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) +#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) +#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) +#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) +#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) +#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) +#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) +#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) +#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) +#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) +#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) +#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) +#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) +#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) +#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) +#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) +#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) + +#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) + +#endif /* GL_SGIX_fragment_specular_lighting */ + +/* --------------------------- GL_SGIX_framezoom --------------------------- */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 + +typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); + +#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) + +#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) + +#endif /* GL_SGIX_framezoom */ + +/* --------------------------- GL_SGIX_interlace --------------------------- */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 + +#define GL_INTERLACE_SGIX 0x8094 + +#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) + +#endif /* GL_SGIX_interlace */ + +/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 + +#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) + +#endif /* GL_SGIX_ir_instrument1 */ + +/* ------------------------- GL_SGIX_list_priority ------------------------- */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 + +#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) + +#endif /* GL_SGIX_list_priority */ + +/* ------------------------- GL_SGIX_pixel_texture ------------------------- */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 + +typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); + +#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) + +#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) + +#endif /* GL_SGIX_pixel_texture */ + +/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ + +#ifndef GL_SGIX_pixel_texture_bits +#define GL_SGIX_pixel_texture_bits 1 + +#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) + +#endif /* GL_SGIX_pixel_texture_bits */ + +/* ------------------------ GL_SGIX_reference_plane ------------------------ */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 + +typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); + +#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) + +#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) + +#endif /* GL_SGIX_reference_plane */ + +/* ---------------------------- GL_SGIX_resample --------------------------- */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 + +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 + +#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) + +#endif /* GL_SGIX_resample */ + +/* ----------------------------- GL_SGIX_shadow ---------------------------- */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 + +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D + +#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) + +#endif /* GL_SGIX_shadow */ + +/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 + +#define GL_SHADOW_AMBIENT_SGIX 0x80BF + +#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) + +#endif /* GL_SGIX_shadow_ambient */ + +/* ----------------------------- GL_SGIX_sprite ---------------------------- */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 + +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); + +#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) +#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) +#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) +#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) + +#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) + +#endif /* GL_SGIX_sprite */ + +/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 + +typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); + +#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) + +#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) + +#endif /* GL_SGIX_tag_sample_buffer */ + +/* ------------------------ GL_SGIX_texture_add_env ------------------------ */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 + +#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) + +#endif /* GL_SGIX_texture_add_env */ + +/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 + +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B + +#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) + +#endif /* GL_SGIX_texture_coordinate_clamp */ + +/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 + +#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) + +#endif /* GL_SGIX_texture_lod_bias */ + +/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 + +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E + +#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) + +#endif /* GL_SGIX_texture_multi_buffer */ + +/* ------------------------- GL_SGIX_texture_range ------------------------- */ + +#ifndef GL_SGIX_texture_range +#define GL_SGIX_texture_range 1 + +#define GL_RGB_SIGNED_SGIX 0x85E0 +#define GL_RGBA_SIGNED_SGIX 0x85E1 +#define GL_ALPHA_SIGNED_SGIX 0x85E2 +#define GL_LUMINANCE_SIGNED_SGIX 0x85E3 +#define GL_INTENSITY_SIGNED_SGIX 0x85E4 +#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 +#define GL_RGB16_SIGNED_SGIX 0x85E6 +#define GL_RGBA16_SIGNED_SGIX 0x85E7 +#define GL_ALPHA16_SIGNED_SGIX 0x85E8 +#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 +#define GL_INTENSITY16_SIGNED_SGIX 0x85EA +#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB +#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC +#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED +#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE +#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF +#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 +#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 +#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 +#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 +#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 +#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 +#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 +#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 +#define GL_MIN_LUMINANCE_SGIS 0x85F8 +#define GL_MAX_LUMINANCE_SGIS 0x85F9 +#define GL_MIN_INTENSITY_SGIS 0x85FA +#define GL_MAX_INTENSITY_SGIS 0x85FB + +#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) + +#endif /* GL_SGIX_texture_range */ + +/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 + +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C + +#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) + +#endif /* GL_SGIX_texture_scale_bias */ + +/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) + +#endif /* GL_SGIX_vertex_preclip */ + +/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ + +#ifndef GL_SGIX_vertex_preclip_hint +#define GL_SGIX_vertex_preclip_hint 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) + +#endif /* GL_SGIX_vertex_preclip_hint */ + +/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 + +#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) + +#endif /* GL_SGIX_ycrcb */ + +/* -------------------------- GL_SGI_color_matrix -------------------------- */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 + +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB + +#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) + +#endif /* GL_SGI_color_matrix */ + +/* --------------------------- GL_SGI_color_table -------------------------- */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 + +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF + +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table); +typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table); + +#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) +#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) +#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) +#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) +#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) +#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) +#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) + +#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) + +#endif /* GL_SGI_color_table */ + +/* ----------------------- GL_SGI_texture_color_table ---------------------- */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 + +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD + +#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) + +#endif /* GL_SGI_texture_color_table */ + +/* ------------------------- GL_SUNX_constant_data ------------------------- */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 + +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 + +typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); + +#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) + +#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) + +#endif /* GL_SUNX_constant_data */ + +/* -------------------- GL_SUN_convolution_border_modes -------------------- */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 + +#define GL_WRAP_BORDER_SUN 0x81D4 + +#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) + +#endif /* GL_SUN_convolution_border_modes */ + +/* -------------------------- GL_SUN_global_alpha -------------------------- */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 + +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA + +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); + +#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) +#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) +#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) +#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) +#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) +#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) +#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) +#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) + +#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) + +#endif /* GL_SUN_global_alpha */ + +/* --------------------------- GL_SUN_mesh_array --------------------------- */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 + +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 + +#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) + +#endif /* GL_SUN_mesh_array */ + +/* ------------------------ GL_SUN_read_video_pixels ----------------------- */ + +#ifndef GL_SUN_read_video_pixels +#define GL_SUN_read_video_pixels 1 + +typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); + +#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) + +#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) + +#endif /* GL_SUN_read_video_pixels */ + +/* --------------------------- GL_SUN_slice_accum -------------------------- */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 + +#define GL_SLICE_ACCUM_SUN 0x85CC + +#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) + +#endif /* GL_SUN_slice_accum */ + +/* -------------------------- GL_SUN_triangle_list ------------------------- */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 + +#define GL_RESTART_SUN 0x01 +#define GL_REPLACE_MIDDLE_SUN 0x02 +#define GL_REPLACE_OLDEST_SUN 0x03 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB + +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); + +#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) +#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) +#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) +#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) +#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) +#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) +#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) + +#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) + +#endif /* GL_SUN_triangle_list */ + +/* ----------------------------- GL_SUN_vertex ----------------------------- */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 + +typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); + +#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) +#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) +#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) +#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) +#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) +#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) +#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) +#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) +#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) +#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) +#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) +#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) +#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) +#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) +#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) +#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) +#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) +#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) +#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) +#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) +#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) +#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) +#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) +#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) +#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) +#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) +#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) +#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) +#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) +#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) +#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) +#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) +#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) +#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) +#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) +#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) + +#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) + +#endif /* GL_SUN_vertex */ + +/* -------------------------- GL_WIN_phong_shading ------------------------- */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 + +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB + +#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) + +#endif /* GL_WIN_phong_shading */ + +/* -------------------------- GL_WIN_specular_fog -------------------------- */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 + +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC + +#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) + +#endif /* GL_WIN_specular_fog */ + +/* ---------------------------- GL_WIN_swap_hint --------------------------- */ + +#ifndef GL_WIN_swap_hint +#define GL_WIN_swap_hint 1 + +typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + +#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) + +#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) + +#endif /* GL_WIN_swap_hint */ + +/* ------------------------------------------------------------------------- */ + +#if defined(GLEW_MX) && defined(_WIN32) +#define GLEW_FUN_EXPORT +#else +#define GLEW_FUN_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#if defined(GLEW_MX) +#define GLEW_VAR_EXPORT +#else +#define GLEW_VAR_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#if defined(GLEW_MX) && defined(_WIN32) +struct GLEWContextStruct +{ +#endif /* GLEW_MX */ + +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; +GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; + +GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; +GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; +GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; +GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; + +GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; +GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; +GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; +GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; +GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; +GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; +GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; +GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; +GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; +GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; +GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; +GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; +GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; +GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; +GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; +GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; +GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; +GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; +GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; +GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; +GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; + +GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; +GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; +GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; +GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; +GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; +GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; +GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; +GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; +GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; +GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; +GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; +GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; +GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; +GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; +GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; +GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; +GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; +GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; +GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; +GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; +GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; +GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; +GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; +GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; +GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; +GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; +GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; +GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; +GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; +GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; +GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; +GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; +GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; +GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; +GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; +GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; +GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; +GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; +GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; +GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; +GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; +GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; +GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; +GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; +GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; + +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; + +GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; + +GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; +GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; + +GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; +GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; +GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; +GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; +GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; +GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; +GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; +GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; + +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; +GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; + +GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; +GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; +GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; +GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; + +GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; + +GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; + +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; + +GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; +GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; +GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; +GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; +GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; +GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; +GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; +GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; +GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; +GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; + +GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; +GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; + +GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; + +GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; +GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; +GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; +GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; +GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; +GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; +GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; + +GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; +GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; +GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; +GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; +GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; +GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; +GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; +GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; +GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; +GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; +GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; +GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; +GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; +GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; +GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; +GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; +GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; +GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; +GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; + +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; +GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; +GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; + +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; +GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; +GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; + +GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; +GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; +GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; +GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; +GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; + +GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; +GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; +GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; +GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; +GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; +GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; +GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; +GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; + +GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; +GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; +GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; +GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; +GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; +GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; + +GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; +GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; +GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; + +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; + +GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; + +GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; +GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; + +GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; +GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; +GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; +GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; + +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; +GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; +GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; +GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; +GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; +GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; +GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; +GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; +GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; + +GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; +GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; + +GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI; +GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI; + +GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; +GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; + +GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; +GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; +GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; +GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; +GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; +GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; +GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; +GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; + +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; + +GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; +GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; +GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; +GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; +GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; + +GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; +GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; +GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; + +GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; + +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; + +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; + +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; + +GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; +GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; + +GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; +GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; + +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; +GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; +GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; + +GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; +GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; + +GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; +GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; + +GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; +GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; + +GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; + +GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; +GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; +GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; +GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; +GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; +GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; + +GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; +GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; + +GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; + +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; +GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; + +GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; +GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; + +GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; + +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; + +GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; +GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; +GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; +GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; +GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; +GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; +GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; +GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; +GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; +GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; + +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; +GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; + +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; + +GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; +GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; +GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; +GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; + +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; +GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; +GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; +GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; +GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; + +GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; + +GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; + +GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; +GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; +GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; + +GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; +GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; + +GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; +GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; + +GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; + +GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; +GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; +GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; + +GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; + +GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; +GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; + +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; + +GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; + +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; + +GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; + +GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; + +GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; +GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; +GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; +GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; +GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; + +GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; +GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; +GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; +GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; +GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; + +GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; + +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; + +GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; +GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; +GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; +GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; +GLEW_FUN_EXPORT PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT; +GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; +GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; + +GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; +GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; +GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; +GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; +GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; +GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; +GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; +GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; +GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; +GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; +GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; +GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; +GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; +GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; +GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; +GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; +GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; +GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; +GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; +GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; +GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; + +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; + +GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; + +GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; +GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; +GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; + +GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; +GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; + +GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; +GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; +GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; +GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; +GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; + +GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; +GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; +GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; +GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; + +GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; +GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; + +GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT; +GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT; +GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT; + +GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; + +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; +GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; + +GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; +GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; +GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; + +GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; +GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; +GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; +GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; +GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; +GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; +GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; + +GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; +GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; +GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; +GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; +GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; +GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; +GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; + +GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; +GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; + +GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; + +GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; +GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; +GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; +GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; +GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; +GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; +GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; +GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; +GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; +GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; +GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; +GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; +GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; + +GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; +GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; +GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; +GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; +GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; +GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; +GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; + +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; +GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; + +GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; +GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; + +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; +GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; + +GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; +GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; + +GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; +GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; +GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; +GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; +GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; + +GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; + +GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; +GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; +GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; +GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; +GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; +GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; +GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; +GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; +GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; + +GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; + +GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; +GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; +GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; +GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; +GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; +GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; +GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; +GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; +GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; +GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; +GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; +GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; + +GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; +GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; +GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; +GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; +GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; +GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; + +GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; +GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; + +GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; +GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; + +GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; +GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; + +GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; +GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; + +GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; +GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; + +GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; +GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; + +GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; +GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; +GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; +GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; +GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; +GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; + +GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; + +GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; + +GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; +GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; +GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; + +GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; + +GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; + +GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; + +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; +GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; + +GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; + +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; +GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; +GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; +GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; +GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; + +GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; + +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; +GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; + +GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; + +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; + +GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; +GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; +GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; + +GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; + +#if defined(GLEW_MX) && !defined(_WIN32) +struct GLEWContextStruct +{ +#endif /* GLEW_MX */ + +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; +GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; +GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; +GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; +GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; +GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; +GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; +GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; +GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; +GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; +GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; +GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; +GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; +GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; +GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; +GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; +GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; +GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; +GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; +GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; +GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; +GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; +GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; + +#ifdef GLEW_MX +}; /* GLEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------- */ + +/* error codes */ +#define GLEW_OK 0 +#define GLEW_NO_ERROR 0 +#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ +#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */ +#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */ + +/* string codes */ +#define GLEW_VERSION 1 + +/* API */ +#ifdef GLEW_MX + +typedef struct GLEWContextStruct GLEWContext; +GLEWAPI GLenum glewContextInit (GLEWContext* ctx); +GLEWAPI GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name); + +#define glewInit() glewContextInit(glewGetContext()) +#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) +#define glewIsExtensionSupported(x) glewIsSupported(x) + +#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) +#ifdef _WIN32 +# define GLEW_GET_FUN(x) glewGetContext()->x +#else +# define GLEW_GET_FUN(x) x +#endif + +#else /* GLEW_MX */ + +GLEWAPI GLenum glewInit (); +GLEWAPI GLboolean glewIsSupported (const char* name); +#define glewIsExtensionSupported(x) glewIsSupported(x) + +#define GLEW_GET_VAR(x) (*(const GLboolean*)&x) +#define GLEW_GET_FUN(x) x + +#endif /* GLEW_MX */ + +GLEWAPI GLboolean glewExperimental; +GLEWAPI GLboolean glewGetExtension (const char* name); +GLEWAPI const GLubyte* glewGetErrorString (GLenum error); +GLEWAPI const GLubyte* glewGetString (GLenum name); + +#ifdef __cplusplus +} +#endif + +#ifdef GLEW_APIENTRY_DEFINED +#undef GLEW_APIENTRY_DEFINED +#undef APIENTRY +#undef GLAPIENTRY +#endif + +#ifdef GLEW_CALLBACK_DEFINED +#undef GLEW_CALLBACK_DEFINED +#undef CALLBACK +#endif + +#ifdef GLEW_WINGDIAPI_DEFINED +#undef GLEW_WINGDIAPI_DEFINED +#undef WINGDIAPI +#endif + +#undef GLAPI +/* #undef GLEWAPI */ + +#endif /* __glew_h__ */ diff --git a/libraries/external/glew/pc/include/GL/vssver.scc b/libraries/external/glew/pc/include/GL/vssver.scc new file mode 100755 index 0000000..e57d003 Binary files /dev/null and b/libraries/external/glew/pc/include/GL/vssver.scc differ diff --git a/libraries/external/glew/pc/lib/glew32.lib b/libraries/external/glew/pc/lib/glew32.lib new file mode 100755 index 0000000..28531b9 Binary files /dev/null and b/libraries/external/glew/pc/lib/glew32.lib differ diff --git a/libraries/external/glew/pc/lib/vssver.scc b/libraries/external/glew/pc/lib/vssver.scc new file mode 100755 index 0000000..b5ddd15 Binary files /dev/null and b/libraries/external/glew/pc/lib/vssver.scc differ diff --git a/libraries/external/glew/vssver.scc b/libraries/external/glew/vssver.scc new file mode 100755 index 0000000..2443126 Binary files /dev/null and b/libraries/external/glew/vssver.scc differ diff --git a/libraries/external/glext/OpenGL Nvidia.zip b/libraries/external/glext/OpenGL Nvidia.zip new file mode 100755 index 0000000..4da84eb Binary files /dev/null and b/libraries/external/glext/OpenGL Nvidia.zip differ diff --git a/libraries/external/glext/README.txt b/libraries/external/glext/README.txt new file mode 100755 index 0000000..aca6a32 --- /dev/null +++ b/libraries/external/glext/README.txt @@ -0,0 +1,4 @@ +glext - GL Extensions header + +PC files were taken from the NVidia SDK. +Linux files are part of the standard OpenGL slackware install and therefore not included here. diff --git a/libraries/external/glext/pc/include/GL/glext.h b/libraries/external/glext/pc/include/GL/glext.h new file mode 100755 index 0000000..838b416 --- /dev/null +++ b/libraries/external/glext/pc/include/GL/glext.h @@ -0,0 +1,6569 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + + Copyright NVIDIA Corporation 2005 + + TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED + *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS + OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL + NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR + CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR + LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, + OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE + THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + DAMAGES. + +******************************************************************************/ + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2005/06/06 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 28 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX_EXT 0x8D45 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_Cg_shader +#define GL_CG_VERTEX_SHADER_EXT 0x890E +#define GL_CG_FRAGMENT_SHADER_EXT 0x890E +#endif + +#ifndef GL_NV_element_array +#define GL_ELEMENT_ARRAY_TYPE_NV 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_NV 0x876A +#endif + +#ifndef GL_NV_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_NV 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_NV 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_NV 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_NV 0x88EF +#endif + +#ifndef GL_NV_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_NV 0x8910 +#define GL_ACTIVE_STENCIL_FACE_NV 0x8911 +#endif + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_EXT_color_matrix +#define GL_EXT_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_Cg_shader +#define GL_EXT_Cg_shader 1 +#endif + +#ifndef GL_NV_element_array +#define GL_NV_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +extern void APIENTRY glElementPointerNV(GLenum type, const GLvoid *pointer); +extern void APIENTRY glDrawElementArrayNV(GLenum mode, GLint first, GLsizei count); +extern void APIENTRY glDrawRangeElementArrayNV(GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +extern void APIENTRY glMultiDrawElementArrayNV(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +extern void APIENTRY glMultiDrawRangeElementArrayNV(GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +typedef void (APIENTRY * PFNGLELEMENTPOINTERNVPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRY * PFNGLDRAWELEMENTARRAYNVPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTARRAYNVPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRY * PFNGLMULTIDRAWELEMENTARRAYNVPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYNVPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_NV_pixel_buffer_object +#define GL_NV_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_stencil_two_side +#define GL_NV_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +extern void APIENTRY glActiveStencilFaceNV(GLenum face); +#endif +typedef void (APIENTRY * PFNGLACTIVESTENCILFACENVPROC) (GLenum face); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/glext/pc/include/GL/vssver.scc b/libraries/external/glext/pc/include/GL/vssver.scc new file mode 100755 index 0000000..4ac1e48 Binary files /dev/null and b/libraries/external/glext/pc/include/GL/vssver.scc differ diff --git a/libraries/external/glext/pc/include/GL/wglext.h b/libraries/external/glext/pc/include/GL/wglext.h new file mode 100755 index 0000000..3024f7a --- /dev/null +++ b/libraries/external/glext/pc/include/GL/wglext.h @@ -0,0 +1,662 @@ +#ifndef __wglext_h_ +#define __wglext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number */ +/* wglext.h last updated 2005/01/07 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define WGL_WGLEXT_VERSION 6 + +#ifndef WGL_ARB_buffer_region +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +#endif + +#ifndef WGL_ARB_multisample +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif + +#ifndef WGL_ARB_extensions_string +#endif + +#ifndef WGL_ARB_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +#endif + +#ifndef WGL_ARB_make_current_read +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +#endif + +#ifndef WGL_ARB_pbuffer +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +#endif + +#ifndef WGL_ARB_render_texture +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif + +#ifndef WGL_EXT_make_current_read +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +#endif + +#ifndef WGL_EXT_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +#endif + +#ifndef WGL_EXT_pbuffer +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +#endif + +#ifndef WGL_EXT_depth_float +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif + +#ifndef WGL_3DFX_multisample +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif + +#ifndef WGL_EXT_multisample +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif + +#ifndef WGL_I3D_digital_video_control +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +#endif + +#ifndef WGL_I3D_gamma +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +#endif + +#ifndef WGL_I3D_genlock +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +#endif + +#ifndef WGL_I3D_image_buffer +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +#endif + +#ifndef WGL_I3D_swap_frame_lock +#endif + +#ifndef WGL_NV_render_depth_texture +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif + +#ifndef WGL_ATI_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#define WGL_RGBA_FLOAT_MODE_ATI 0x8820 +#define WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef WGL_NV_float_buffer +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif + +#ifndef WGL_NV_swap_group +#endif + + +/*************************************************************/ + +#ifndef WGL_ARB_pbuffer +DECLARE_HANDLE(HPBUFFERARB); +#endif +#ifndef WGL_EXT_pbuffer +DECLARE_HANDLE(HPBUFFEREXT); +#endif + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); +extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); +extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); +extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#endif + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern const char * WINAPI wglGetExtensionsStringARB (HDC); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#endif + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); +extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); +extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); +extern HDC WINAPI wglGetCurrentReadDCARB (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#endif + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); +extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); +extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); +extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); +extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); +extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); +extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#endif + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); +extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); +extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); +extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#endif + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern const char * WINAPI wglGetExtensionsStringEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#endif + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); +extern HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#endif + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); +extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); +extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); +extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); +extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); +extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); +extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglSwapIntervalEXT (int); +extern int WINAPI wglGetSwapIntervalEXT (void); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#endif + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#endif + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); +extern void WINAPI wglFreeMemoryNV (void *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#endif + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#endif + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#endif + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); +extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); +extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); +extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); +extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); +extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); +extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#endif + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); +extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); +extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); +extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnableGenlockI3D (HDC); +extern BOOL WINAPI wglDisableGenlockI3D (HDC); +extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); +extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); +extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); +extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); +extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); +extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); +extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); +extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); +extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); +extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#endif + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglEnableFrameLockI3D (void); +extern BOOL WINAPI wglDisableFrameLockI3D (void); +extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); +extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#endif + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglGetFrameUsageI3D (float *); +extern BOOL WINAPI wglBeginFrameTrackingI3D (void); +extern BOOL WINAPI wglEndFrameTrackingI3D (void); +extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#endif + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#endif + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#endif + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#endif + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +#ifdef WGL_WGLEXT_PROTOTYPES +extern BOOL WINAPI wglJoinSwapGroupNV(HDC hDC, GLuint group); +extern BOOL WINAPI wglBindSwapBarrierNV(GLuint group, GLuint barrier); +extern BOOL WINAPI wglQuerySwapGroupNV(HDC hDC GLuint *group, GLuint *barrier); +extern BOOL WINAPI wglQueryMaxSwapGroupsNV(HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +extern BOOL WINAPI wglQueryFrameCountNV(HDC hDC, GLuint *count); +extern BOOL WINAPI wglResetFrameCountNV(HDC hDC); +#endif /* WGL_WGLEXT_PROTOTYPES */ +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/glext/vssver.scc b/libraries/external/glext/vssver.scc new file mode 100755 index 0000000..f847242 Binary files /dev/null and b/libraries/external/glext/vssver.scc differ diff --git a/libraries/external/glut/glut-3.7.6-bin.zip b/libraries/external/glut/glut-3.7.6-bin.zip new file mode 100755 index 0000000..ebdf080 Binary files /dev/null and b/libraries/external/glut/glut-3.7.6-bin.zip differ diff --git a/libraries/external/glut/glut-3.7.6-src.zip b/libraries/external/glut/glut-3.7.6-src.zip new file mode 100755 index 0000000..6882d0c Binary files /dev/null and b/libraries/external/glut/glut-3.7.6-src.zip differ diff --git a/libraries/external/glut/pc/bin/glut32.dll b/libraries/external/glut/pc/bin/glut32.dll new file mode 100755 index 0000000..106646f Binary files /dev/null and b/libraries/external/glut/pc/bin/glut32.dll differ diff --git a/libraries/external/glut/pc/bin/vssver.scc b/libraries/external/glut/pc/bin/vssver.scc new file mode 100755 index 0000000..7962887 Binary files /dev/null and b/libraries/external/glut/pc/bin/vssver.scc differ diff --git a/libraries/external/glut/pc/include/GL/glut.h b/libraries/external/glut/pc/include/GL/glut.h new file mode 100755 index 0000000..aa7428f --- /dev/null +++ b/libraries/external/glut/pc/include/GL/glut.h @@ -0,0 +1,716 @@ +#ifndef __glut_h__ +#define __glut_h__ + +/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */ + +/* This program is freely distributable without licensing fees and is + provided without guarantee or warrantee expressed or implied. This + program is -not- in the public domain. */ + +#if defined(_WIN32) + +/* GLUT 3.7 now tries to avoid including + to avoid name space pollution, but Win32's + needs APIENTRY and WINGDIAPI defined properly. */ +# if 0 + /* This would put tons of macros and crap in our clean name space. */ +# define WIN32_LEAN_AND_MEAN +# include +# else + /* XXX This is from Win32's */ +# ifndef APIENTRY +# define GLUT_APIENTRY_DEFINED +# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__) +# define APIENTRY __stdcall +# else +# define APIENTRY +# endif +# endif + /* XXX This is from Win32's */ +# ifndef CALLBACK +# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) || defined(__LCC__) +# define CALLBACK __stdcall +# else +# define CALLBACK +# endif +# endif + /* XXX Hack for lcc compiler. It doesn't support __declspec(dllimport), just __stdcall. */ +# if defined( __LCC__ ) +# undef WINGDIAPI +# define WINGDIAPI __stdcall +# else + /* XXX This is from Win32's and */ +# ifndef WINGDIAPI +# define GLUT_WINGDIAPI_DEFINED +# define WINGDIAPI __declspec(dllimport) +# endif +# endif + /* XXX This is from Win32's */ +# ifndef _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +# endif +# endif + +/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA + in your compile preprocessor options. */ +# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA) +# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */ +/* To enable automatic SGI OpenGL for Windows library usage for GLUT, + define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */ +# ifdef GLUT_USE_SGI_OPENGL +# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */ +# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */ +# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */ +# else +# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */ +# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */ +# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */ +# endif +# endif + +/* To disable supression of annoying warnings about floats being promoted + to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor + options. */ +# ifndef GLUT_NO_WARNING_DISABLE +# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */ +# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */ +# endif + +/* Win32 has an annoying issue where there are multiple C run-time + libraries (CRTs). If the executable is linked with a different CRT + from the GLUT DLL, the GLUT DLL will not share the same CRT static + data seen by the executable. In particular, atexit callbacks registered + in the executable will not be called if GLUT calls its (different) + exit routine). GLUT is typically built with the + "/MD" option (the CRT with multithreading DLL support), but the Visual + C++ linker default is "/ML" (the single threaded CRT). + + One workaround to this issue is requiring users to always link with + the same CRT as GLUT is compiled with. That requires users supply a + non-standard option. GLUT 3.7 has its own built-in workaround where + the executable's "exit" function pointer is covertly passed to GLUT. + GLUT then calls the executable's exit function pointer to ensure that + any "atexit" calls registered by the application are called if GLUT + needs to exit. + + Note that the __glut*WithExit routines should NEVER be called directly. + To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */ + +/* XXX This is from Win32's */ +# if !defined(_MSC_VER) && !defined(__cdecl) + /* Define __cdecl for non-Microsoft compilers. */ +# define __cdecl +# define GLUT_DEFINED___CDECL +# endif +# ifndef _CRTIMP +# ifdef _NTSDK + /* Definition compatible with NT SDK */ +# define _CRTIMP +# else + /* Current definition */ +# ifdef _DLL +# define _CRTIMP __declspec(dllimport) +# else +# define _CRTIMP +# endif +# endif +# define GLUT_DEFINED__CRTIMP +# endif + +/* GLUT API entry point declarations for Win32. */ +# ifdef GLUT_BUILDING_LIB +# define GLUTAPI __declspec(dllexport) +# else +# ifdef _DLL +# define GLUTAPI __declspec(dllimport) +# else +# define GLUTAPI extern +# endif +# endif + +/* GLUT callback calling convention for Win32. */ +# define GLUTCALLBACK __cdecl + +#endif /* _WIN32 */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) +# ifndef GLUT_BUILDING_LIB +extern _CRTIMP void __cdecl exit(int); +# endif +#else +/* non-Win32 case. */ +/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */ +# define APIENTRY +# define GLUT_APIENTRY_DEFINED +# define CALLBACK +/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */ +# define GLUTAPI extern +# define GLUTCALLBACK +/* Prototype exit for the non-Win32 case (see above). */ +extern void exit(int); +#endif + +/** + GLUT API revision history: + + GLUT_API_VERSION is updated to reflect incompatible GLUT + API changes (interface changes, semantic changes, deletions, + or additions). + + GLUT_API_VERSION=1 First public release of GLUT. 11/29/94 + + GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling, + extension. Supports new input devices like tablet, dial and button + box, and Spaceball. Easy to query OpenGL extensions. + + GLUT_API_VERSION=3 glutMenuStatus added. + + GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer, + glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic + video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc, + glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat, + glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!). +**/ +#ifndef GLUT_API_VERSION /* allow this to be overriden */ +#define GLUT_API_VERSION 3 +#endif + +/** + GLUT implementation revision history: + + GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT + API revisions and implementation revisions (ie, bug fixes). + + GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of + GLUT Xlib-based implementation. 11/29/94 + + GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of + GLUT Xlib-based implementation providing GLUT version 2 + interfaces. + + GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95 + + GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95 + + GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95 + + GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96 + + GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner + and video resize. 1/3/97 + + GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines. + + GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release. + + GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling. + + GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support. + + GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface. + + GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa +**/ +#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */ +#define GLUT_XLIB_IMPLEMENTATION 15 +#endif + +/* Display mode bit masks. */ +#define GLUT_RGB 0 +#define GLUT_RGBA GLUT_RGB +#define GLUT_INDEX 1 +#define GLUT_SINGLE 0 +#define GLUT_DOUBLE 2 +#define GLUT_ACCUM 4 +#define GLUT_ALPHA 8 +#define GLUT_DEPTH 16 +#define GLUT_STENCIL 32 +#if (GLUT_API_VERSION >= 2) +#define GLUT_MULTISAMPLE 128 +#define GLUT_STEREO 256 +#endif +#if (GLUT_API_VERSION >= 3) +#define GLUT_LUMINANCE 512 +#endif + +/* Mouse buttons. */ +#define GLUT_LEFT_BUTTON 0 +#define GLUT_MIDDLE_BUTTON 1 +#define GLUT_RIGHT_BUTTON 2 + +/* Mouse button state. */ +#define GLUT_DOWN 0 +#define GLUT_UP 1 + +#if (GLUT_API_VERSION >= 2) +/* function keys */ +#define GLUT_KEY_F1 1 +#define GLUT_KEY_F2 2 +#define GLUT_KEY_F3 3 +#define GLUT_KEY_F4 4 +#define GLUT_KEY_F5 5 +#define GLUT_KEY_F6 6 +#define GLUT_KEY_F7 7 +#define GLUT_KEY_F8 8 +#define GLUT_KEY_F9 9 +#define GLUT_KEY_F10 10 +#define GLUT_KEY_F11 11 +#define GLUT_KEY_F12 12 +/* directional keys */ +#define GLUT_KEY_LEFT 100 +#define GLUT_KEY_UP 101 +#define GLUT_KEY_RIGHT 102 +#define GLUT_KEY_DOWN 103 +#define GLUT_KEY_PAGE_UP 104 +#define GLUT_KEY_PAGE_DOWN 105 +#define GLUT_KEY_HOME 106 +#define GLUT_KEY_END 107 +#define GLUT_KEY_INSERT 108 +#endif + +/* Entry/exit state. */ +#define GLUT_LEFT 0 +#define GLUT_ENTERED 1 + +/* Menu usage state. */ +#define GLUT_MENU_NOT_IN_USE 0 +#define GLUT_MENU_IN_USE 1 + +/* Visibility state. */ +#define GLUT_NOT_VISIBLE 0 +#define GLUT_VISIBLE 1 + +/* Window status state. */ +#define GLUT_HIDDEN 0 +#define GLUT_FULLY_RETAINED 1 +#define GLUT_PARTIALLY_RETAINED 2 +#define GLUT_FULLY_COVERED 3 + +/* Color index component selection values. */ +#define GLUT_RED 0 +#define GLUT_GREEN 1 +#define GLUT_BLUE 2 + +#if defined(_WIN32) +/* Stroke font constants (use these in GLUT program). */ +#define GLUT_STROKE_ROMAN ((void*)0) +#define GLUT_STROKE_MONO_ROMAN ((void*)1) + +/* Bitmap font constants (use these in GLUT program). */ +#define GLUT_BITMAP_9_BY_15 ((void*)2) +#define GLUT_BITMAP_8_BY_13 ((void*)3) +#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4) +#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5) +#if (GLUT_API_VERSION >= 3) +#define GLUT_BITMAP_HELVETICA_10 ((void*)6) +#define GLUT_BITMAP_HELVETICA_12 ((void*)7) +#define GLUT_BITMAP_HELVETICA_18 ((void*)8) +#endif +#else +/* Stroke font opaque addresses (use constants instead in source code). */ +GLUTAPI void *glutStrokeRoman; +GLUTAPI void *glutStrokeMonoRoman; + +/* Stroke font constants (use these in GLUT program). */ +#define GLUT_STROKE_ROMAN (&glutStrokeRoman) +#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman) + +/* Bitmap font opaque addresses (use constants instead in source code). */ +GLUTAPI void *glutBitmap9By15; +GLUTAPI void *glutBitmap8By13; +GLUTAPI void *glutBitmapTimesRoman10; +GLUTAPI void *glutBitmapTimesRoman24; +GLUTAPI void *glutBitmapHelvetica10; +GLUTAPI void *glutBitmapHelvetica12; +GLUTAPI void *glutBitmapHelvetica18; + +/* Bitmap font constants (use these in GLUT program). */ +#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15) +#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13) +#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10) +#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24) +#if (GLUT_API_VERSION >= 3) +#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10) +#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12) +#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18) +#endif +#endif + +/* glutGet parameters. */ +#define GLUT_WINDOW_X ((GLenum) 100) +#define GLUT_WINDOW_Y ((GLenum) 101) +#define GLUT_WINDOW_WIDTH ((GLenum) 102) +#define GLUT_WINDOW_HEIGHT ((GLenum) 103) +#define GLUT_WINDOW_BUFFER_SIZE ((GLenum) 104) +#define GLUT_WINDOW_STENCIL_SIZE ((GLenum) 105) +#define GLUT_WINDOW_DEPTH_SIZE ((GLenum) 106) +#define GLUT_WINDOW_RED_SIZE ((GLenum) 107) +#define GLUT_WINDOW_GREEN_SIZE ((GLenum) 108) +#define GLUT_WINDOW_BLUE_SIZE ((GLenum) 109) +#define GLUT_WINDOW_ALPHA_SIZE ((GLenum) 110) +#define GLUT_WINDOW_ACCUM_RED_SIZE ((GLenum) 111) +#define GLUT_WINDOW_ACCUM_GREEN_SIZE ((GLenum) 112) +#define GLUT_WINDOW_ACCUM_BLUE_SIZE ((GLenum) 113) +#define GLUT_WINDOW_ACCUM_ALPHA_SIZE ((GLenum) 114) +#define GLUT_WINDOW_DOUBLEBUFFER ((GLenum) 115) +#define GLUT_WINDOW_RGBA ((GLenum) 116) +#define GLUT_WINDOW_PARENT ((GLenum) 117) +#define GLUT_WINDOW_NUM_CHILDREN ((GLenum) 118) +#define GLUT_WINDOW_COLORMAP_SIZE ((GLenum) 119) +#if (GLUT_API_VERSION >= 2) +#define GLUT_WINDOW_NUM_SAMPLES ((GLenum) 120) +#define GLUT_WINDOW_STEREO ((GLenum) 121) +#endif +#if (GLUT_API_VERSION >= 3) +#define GLUT_WINDOW_CURSOR ((GLenum) 122) +#endif +#define GLUT_SCREEN_WIDTH ((GLenum) 200) +#define GLUT_SCREEN_HEIGHT ((GLenum) 201) +#define GLUT_SCREEN_WIDTH_MM ((GLenum) 202) +#define GLUT_SCREEN_HEIGHT_MM ((GLenum) 203) +#define GLUT_MENU_NUM_ITEMS ((GLenum) 300) +#define GLUT_DISPLAY_MODE_POSSIBLE ((GLenum) 400) +#define GLUT_INIT_WINDOW_X ((GLenum) 500) +#define GLUT_INIT_WINDOW_Y ((GLenum) 501) +#define GLUT_INIT_WINDOW_WIDTH ((GLenum) 502) +#define GLUT_INIT_WINDOW_HEIGHT ((GLenum) 503) +#define GLUT_INIT_DISPLAY_MODE ((GLenum) 504) +#if (GLUT_API_VERSION >= 2) +#define GLUT_ELAPSED_TIME ((GLenum) 700) +#endif +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +#define GLUT_WINDOW_FORMAT_ID ((GLenum) 123) +#endif + +#if (GLUT_API_VERSION >= 2) +/* glutDeviceGet parameters. */ +#define GLUT_HAS_KEYBOARD ((GLenum) 600) +#define GLUT_HAS_MOUSE ((GLenum) 601) +#define GLUT_HAS_SPACEBALL ((GLenum) 602) +#define GLUT_HAS_DIAL_AND_BUTTON_BOX ((GLenum) 603) +#define GLUT_HAS_TABLET ((GLenum) 604) +#define GLUT_NUM_MOUSE_BUTTONS ((GLenum) 605) +#define GLUT_NUM_SPACEBALL_BUTTONS ((GLenum) 606) +#define GLUT_NUM_BUTTON_BOX_BUTTONS ((GLenum) 607) +#define GLUT_NUM_DIALS ((GLenum) 608) +#define GLUT_NUM_TABLET_BUTTONS ((GLenum) 609) +#endif +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +#define GLUT_DEVICE_IGNORE_KEY_REPEAT ((GLenum) 610) +#define GLUT_DEVICE_KEY_REPEAT ((GLenum) 611) +#define GLUT_HAS_JOYSTICK ((GLenum) 612) +#define GLUT_OWNS_JOYSTICK ((GLenum) 613) +#define GLUT_JOYSTICK_BUTTONS ((GLenum) 614) +#define GLUT_JOYSTICK_AXES ((GLenum) 615) +#define GLUT_JOYSTICK_POLL_RATE ((GLenum) 616) +#endif + +#if (GLUT_API_VERSION >= 3) +/* glutLayerGet parameters. */ +#define GLUT_OVERLAY_POSSIBLE ((GLenum) 800) +#define GLUT_LAYER_IN_USE ((GLenum) 801) +#define GLUT_HAS_OVERLAY ((GLenum) 802) +#define GLUT_TRANSPARENT_INDEX ((GLenum) 803) +#define GLUT_NORMAL_DAMAGED ((GLenum) 804) +#define GLUT_OVERLAY_DAMAGED ((GLenum) 805) + +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +/* glutVideoResizeGet parameters. */ +#define GLUT_VIDEO_RESIZE_POSSIBLE ((GLenum) 900) +#define GLUT_VIDEO_RESIZE_IN_USE ((GLenum) 901) +#define GLUT_VIDEO_RESIZE_X_DELTA ((GLenum) 902) +#define GLUT_VIDEO_RESIZE_Y_DELTA ((GLenum) 903) +#define GLUT_VIDEO_RESIZE_WIDTH_DELTA ((GLenum) 904) +#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA ((GLenum) 905) +#define GLUT_VIDEO_RESIZE_X ((GLenum) 906) +#define GLUT_VIDEO_RESIZE_Y ((GLenum) 907) +#define GLUT_VIDEO_RESIZE_WIDTH ((GLenum) 908) +#define GLUT_VIDEO_RESIZE_HEIGHT ((GLenum) 909) +#endif + +/* glutUseLayer parameters. */ +#define GLUT_NORMAL ((GLenum) 0) +#define GLUT_OVERLAY ((GLenum) 1) + +/* glutGetModifiers return mask. */ +#define GLUT_ACTIVE_SHIFT 1 +#define GLUT_ACTIVE_CTRL 2 +#define GLUT_ACTIVE_ALT 4 + +/* glutSetCursor parameters. */ +/* Basic arrows. */ +#define GLUT_CURSOR_RIGHT_ARROW 0 +#define GLUT_CURSOR_LEFT_ARROW 1 +/* Symbolic cursor shapes. */ +#define GLUT_CURSOR_INFO 2 +#define GLUT_CURSOR_DESTROY 3 +#define GLUT_CURSOR_HELP 4 +#define GLUT_CURSOR_CYCLE 5 +#define GLUT_CURSOR_SPRAY 6 +#define GLUT_CURSOR_WAIT 7 +#define GLUT_CURSOR_TEXT 8 +#define GLUT_CURSOR_CROSSHAIR 9 +/* Directional cursors. */ +#define GLUT_CURSOR_UP_DOWN 10 +#define GLUT_CURSOR_LEFT_RIGHT 11 +/* Sizing cursors. */ +#define GLUT_CURSOR_TOP_SIDE 12 +#define GLUT_CURSOR_BOTTOM_SIDE 13 +#define GLUT_CURSOR_LEFT_SIDE 14 +#define GLUT_CURSOR_RIGHT_SIDE 15 +#define GLUT_CURSOR_TOP_LEFT_CORNER 16 +#define GLUT_CURSOR_TOP_RIGHT_CORNER 17 +#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18 +#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19 +/* Inherit from parent window. */ +#define GLUT_CURSOR_INHERIT 100 +/* Blank cursor. */ +#define GLUT_CURSOR_NONE 101 +/* Fullscreen crosshair (if available). */ +#define GLUT_CURSOR_FULL_CROSSHAIR 102 +#endif + +/* GLUT initialization sub-API. */ +GLUTAPI void APIENTRY glutInit(int *argcp, char **argv); +#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) +GLUTAPI void APIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int)); +#ifndef GLUT_BUILDING_LIB +static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); } +#define glutInit glutInit_ATEXIT_HACK +#endif +#endif +GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI void APIENTRY glutInitDisplayString(const char *string); +#endif +GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y); +GLUTAPI void APIENTRY glutInitWindowSize(int width, int height); +GLUTAPI void APIENTRY glutMainLoop(void); + +/* GLUT window sub-API. */ +GLUTAPI int APIENTRY glutCreateWindow(const char *title); +#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) +GLUTAPI int APIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int)); +#ifndef GLUT_BUILDING_LIB +static int APIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); } +#define glutCreateWindow glutCreateWindow_ATEXIT_HACK +#endif +#endif +GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height); +GLUTAPI void APIENTRY glutDestroyWindow(int win); +GLUTAPI void APIENTRY glutPostRedisplay(void); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11) +GLUTAPI void APIENTRY glutPostWindowRedisplay(int win); +#endif +GLUTAPI void APIENTRY glutSwapBuffers(void); +GLUTAPI int APIENTRY glutGetWindow(void); +GLUTAPI void APIENTRY glutSetWindow(int win); +GLUTAPI void APIENTRY glutSetWindowTitle(const char *title); +GLUTAPI void APIENTRY glutSetIconTitle(const char *title); +GLUTAPI void APIENTRY glutPositionWindow(int x, int y); +GLUTAPI void APIENTRY glutReshapeWindow(int width, int height); +GLUTAPI void APIENTRY glutPopWindow(void); +GLUTAPI void APIENTRY glutPushWindow(void); +GLUTAPI void APIENTRY glutIconifyWindow(void); +GLUTAPI void APIENTRY glutShowWindow(void); +GLUTAPI void APIENTRY glutHideWindow(void); +#if (GLUT_API_VERSION >= 3) +GLUTAPI void APIENTRY glutFullScreen(void); +GLUTAPI void APIENTRY glutSetCursor(int cursor); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI void APIENTRY glutWarpPointer(int x, int y); +#endif + +/* GLUT overlay sub-API. */ +GLUTAPI void APIENTRY glutEstablishOverlay(void); +GLUTAPI void APIENTRY glutRemoveOverlay(void); +GLUTAPI void APIENTRY glutUseLayer(GLenum layer); +GLUTAPI void APIENTRY glutPostOverlayRedisplay(void); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11) +GLUTAPI void APIENTRY glutPostWindowOverlayRedisplay(int win); +#endif +GLUTAPI void APIENTRY glutShowOverlay(void); +GLUTAPI void APIENTRY glutHideOverlay(void); +#endif + +/* GLUT menu sub-API. */ +GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int)); +#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) +GLUTAPI int APIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int)); +#ifndef GLUT_BUILDING_LIB +static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); } +#define glutCreateMenu glutCreateMenu_ATEXIT_HACK +#endif +#endif +GLUTAPI void APIENTRY glutDestroyMenu(int menu); +GLUTAPI int APIENTRY glutGetMenu(void); +GLUTAPI void APIENTRY glutSetMenu(int menu); +GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value); +GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu); +GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value); +GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu); +GLUTAPI void APIENTRY glutRemoveMenuItem(int item); +GLUTAPI void APIENTRY glutAttachMenu(int button); +GLUTAPI void APIENTRY glutDetachMenu(int button); + +/* GLUT window callback sub-API. */ +GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void)); +GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height)); +GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y)); +GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y)); +GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); +GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); +GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state)); +GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state)); +GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void)); +GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value); +GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state)); +#if (GLUT_API_VERSION >= 2) +GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y)); +GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z)); +GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z)); +GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state)); +GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state)); +GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value)); +GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); +GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y)); +#if (GLUT_API_VERSION >= 3) +GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y)); +GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void)); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state)); +#endif +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +GLUTAPI void APIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y)); +GLUTAPI void APIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y)); +GLUTAPI void APIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval); +#endif +#endif +#endif + +/* GLUT color index sub-API. */ +GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue); +GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component); +GLUTAPI void APIENTRY glutCopyColormap(int win); + +/* GLUT state retrieval sub-API. */ +GLUTAPI int APIENTRY glutGet(GLenum type); +GLUTAPI int APIENTRY glutDeviceGet(GLenum type); +#if (GLUT_API_VERSION >= 2) +/* GLUT extension support sub-API */ +GLUTAPI int APIENTRY glutExtensionSupported(const char *name); +#endif +#if (GLUT_API_VERSION >= 3) +GLUTAPI int APIENTRY glutGetModifiers(void); +GLUTAPI int APIENTRY glutLayerGet(GLenum type); +#endif + +/* GLUT font sub-API */ +GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character); +GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character); +GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character); +GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character); +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +GLUTAPI int APIENTRY glutBitmapLength(void *font, const unsigned char *string); +GLUTAPI int APIENTRY glutStrokeLength(void *font, const unsigned char *string); +#endif + +/* GLUT pre-built models sub-API */ +GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); +GLUTAPI void APIENTRY glutWireCube(GLdouble size); +GLUTAPI void APIENTRY glutSolidCube(GLdouble size); +GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); +GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); +GLUTAPI void APIENTRY glutWireDodecahedron(void); +GLUTAPI void APIENTRY glutSolidDodecahedron(void); +GLUTAPI void APIENTRY glutWireTeapot(GLdouble size); +GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size); +GLUTAPI void APIENTRY glutWireOctahedron(void); +GLUTAPI void APIENTRY glutSolidOctahedron(void); +GLUTAPI void APIENTRY glutWireTetrahedron(void); +GLUTAPI void APIENTRY glutSolidTetrahedron(void); +GLUTAPI void APIENTRY glutWireIcosahedron(void); +GLUTAPI void APIENTRY glutSolidIcosahedron(void); + +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) +/* GLUT video resize sub-API. */ +GLUTAPI int APIENTRY glutVideoResizeGet(GLenum param); +GLUTAPI void APIENTRY glutSetupVideoResizing(void); +GLUTAPI void APIENTRY glutStopVideoResizing(void); +GLUTAPI void APIENTRY glutVideoResize(int x, int y, int width, int height); +GLUTAPI void APIENTRY glutVideoPan(int x, int y, int width, int height); + +/* GLUT debugging sub-API. */ +GLUTAPI void APIENTRY glutReportErrors(void); +#endif + +#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) +/* GLUT device control sub-API. */ +/* glutSetKeyRepeat modes. */ +#define GLUT_KEY_REPEAT_OFF 0 +#define GLUT_KEY_REPEAT_ON 1 +#define GLUT_KEY_REPEAT_DEFAULT 2 + +/* Joystick button masks. */ +#define GLUT_JOYSTICK_BUTTON_A 1 +#define GLUT_JOYSTICK_BUTTON_B 2 +#define GLUT_JOYSTICK_BUTTON_C 4 +#define GLUT_JOYSTICK_BUTTON_D 8 + +GLUTAPI void APIENTRY glutIgnoreKeyRepeat(int ignore); +GLUTAPI void APIENTRY glutSetKeyRepeat(int repeatMode); +GLUTAPI void APIENTRY glutForceJoystickFunc(void); + +/* GLUT game mode sub-API. */ +/* glutGameModeGet. */ +#define GLUT_GAME_MODE_ACTIVE ((GLenum) 0) +#define GLUT_GAME_MODE_POSSIBLE ((GLenum) 1) +#define GLUT_GAME_MODE_WIDTH ((GLenum) 2) +#define GLUT_GAME_MODE_HEIGHT ((GLenum) 3) +#define GLUT_GAME_MODE_PIXEL_DEPTH ((GLenum) 4) +#define GLUT_GAME_MODE_REFRESH_RATE ((GLenum) 5) +#define GLUT_GAME_MODE_DISPLAY_CHANGED ((GLenum) 6) + +GLUTAPI void APIENTRY glutGameModeString(const char *string); +GLUTAPI int APIENTRY glutEnterGameMode(void); +GLUTAPI void APIENTRY glutLeaveGameMode(void); +GLUTAPI int APIENTRY glutGameModeGet(GLenum mode); +#endif + +#ifdef __cplusplus +} + +#endif + +#ifdef GLUT_APIENTRY_DEFINED +# undef GLUT_APIENTRY_DEFINED +# undef APIENTRY +#endif + +#ifdef GLUT_WINGDIAPI_DEFINED +# undef GLUT_WINGDIAPI_DEFINED +# undef WINGDIAPI +#endif + +#ifdef GLUT_DEFINED___CDECL +# undef GLUT_DEFINED___CDECL +# undef __cdecl +#endif + +#ifdef GLUT_DEFINED__CRTIMP +# undef GLUT_DEFINED__CRTIMP +# undef _CRTIMP +#endif + +#endif /* __glut_h__ */ diff --git a/libraries/external/glut/pc/include/GL/vssver.scc b/libraries/external/glut/pc/include/GL/vssver.scc new file mode 100755 index 0000000..80cec2d Binary files /dev/null and b/libraries/external/glut/pc/include/GL/vssver.scc differ diff --git a/libraries/external/glut/pc/lib/glut32.lib b/libraries/external/glut/pc/lib/glut32.lib new file mode 100755 index 0000000..c25583d Binary files /dev/null and b/libraries/external/glut/pc/lib/glut32.lib differ diff --git a/libraries/external/glut/pc/lib/vssver.scc b/libraries/external/glut/pc/lib/vssver.scc new file mode 100755 index 0000000..ce238df Binary files /dev/null and b/libraries/external/glut/pc/lib/vssver.scc differ diff --git a/libraries/external/glut/vssver.scc b/libraries/external/glut/vssver.scc new file mode 100755 index 0000000..d070eed Binary files /dev/null and b/libraries/external/glut/vssver.scc differ diff --git a/libraries/external/hasp/linux/lib/libHASP.a b/libraries/external/hasp/linux/lib/libHASP.a new file mode 100755 index 0000000..0c8de7f Binary files /dev/null and b/libraries/external/hasp/linux/lib/libHASP.a differ diff --git a/libraries/external/hasp/linux/lib/vssver.scc b/libraries/external/hasp/linux/lib/vssver.scc new file mode 100755 index 0000000..b1b6bf5 Binary files /dev/null and b/libraries/external/hasp/linux/lib/vssver.scc differ diff --git a/libraries/external/hasp/pc/lib/libhasp.lib b/libraries/external/hasp/pc/lib/libhasp.lib new file mode 100755 index 0000000..0076c3e Binary files /dev/null and b/libraries/external/hasp/pc/lib/libhasp.lib differ diff --git a/libraries/external/hasp/pc/lib/vssver.scc b/libraries/external/hasp/pc/lib/vssver.scc new file mode 100755 index 0000000..d3c4faa Binary files /dev/null and b/libraries/external/hasp/pc/lib/vssver.scc differ diff --git a/libraries/external/icmp/pc/dll/iphlpapi.dll b/libraries/external/icmp/pc/dll/iphlpapi.dll new file mode 100755 index 0000000..8f58ea1 Binary files /dev/null and b/libraries/external/icmp/pc/dll/iphlpapi.dll differ diff --git a/libraries/external/icmp/pc/dll/vssver.scc b/libraries/external/icmp/pc/dll/vssver.scc new file mode 100755 index 0000000..95fb50a Binary files /dev/null and b/libraries/external/icmp/pc/dll/vssver.scc differ diff --git a/libraries/external/icmp/pc/include/IPExport.h b/libraries/external/icmp/pc/include/IPExport.h new file mode 100755 index 0000000..86191bd --- /dev/null +++ b/libraries/external/icmp/pc/include/IPExport.h @@ -0,0 +1,292 @@ +/********************************************************************/ +/** Microsoft LAN Manager **/ +/** Copyright (c) Microsoft Corporation. All rights reserved. **/ +/********************************************************************/ +/* :ts=4 */ + +//** IPEXPORT.H - IP public definitions. +// +// This file contains public definitions exported to transport layer and +// application software. +// + +#ifndef IP_EXPORT_INCLUDED +#define IP_EXPORT_INCLUDED 1 + +#if _MSC_VER > 1000 +#pragma once +#endif + +// +// IP type definitions. +// +typedef ULONG IPAddr; // An IP address. +typedef ULONG IPMask; // An IP subnet mask. +typedef ULONG IP_STATUS; // Status code returned from IP APIs. + +#ifndef s6_addr +// +// Duplicate these definitions here so that this file can be included by +// kernel-mode components which cannot include ws2tcpip.h, as well as +// by user-mode components which do. +// + +typedef struct in6_addr { + union { + UCHAR Byte[16]; + USHORT Word[8]; + } u; +} IN6_ADDR; + +#define in_addr6 in6_addr + +// +// Defines to match RFC 2553. +// +#define _S6_un u +#define _S6_u8 Byte +#define s6_addr _S6_un._S6_u8 + +// +// Defines for our implementation. +// +#define s6_bytes u.Byte +#define s6_words u.Word + +#endif + +typedef struct in6_addr IPv6Addr; + +#ifndef s_addr + +struct in_addr { + union { + struct { UCHAR s_b1,s_b2,s_b3,s_b4; } S_un_b; + struct { USHORT s_w1,s_w2; } S_un_w; + ULONG S_addr; + } S_un; +}; +#define s_addr S_un.S_addr /* can be used for most tcp & ip code */ + +#endif + +/*INC*/ + +// +// The ip_option_information structure describes the options to be +// included in the header of an IP packet. The TTL, TOS, and Flags +// values are carried in specific fields in the header. The OptionsData +// bytes are carried in the options area following the standard IP header. +// With the exception of source route options, this data must be in the +// format to be transmitted on the wire as specified in RFC 791. A source +// route option should contain the full route - first hop thru final +// destination - in the route data. The first hop will be pulled out of the +// data and the option will be reformatted accordingly. Otherwise, the route +// option should be formatted as specified in RFC 791. +// + +typedef struct ip_option_information { + UCHAR Ttl; // Time To Live + UCHAR Tos; // Type Of Service + UCHAR Flags; // IP header flags + UCHAR OptionsSize; // Size in bytes of options data + PUCHAR OptionsData; // Pointer to options data +} IP_OPTION_INFORMATION, *PIP_OPTION_INFORMATION; + +#if defined(_WIN64) + +typedef struct ip_option_information32 { + UCHAR Ttl; + UCHAR Tos; + UCHAR Flags; + UCHAR OptionsSize; + UCHAR * POINTER_32 OptionsData; +} IP_OPTION_INFORMATION32, *PIP_OPTION_INFORMATION32; + +#endif // _WIN64 + +// +// The icmp_echo_reply structure describes the data returned in response +// to an echo request. +// + +typedef struct icmp_echo_reply { + IPAddr Address; // Replying address + ULONG Status; // Reply IP_STATUS + ULONG RoundTripTime; // RTT in milliseconds + USHORT DataSize; // Reply data size in bytes + USHORT Reserved; // Reserved for system use + PVOID Data; // Pointer to the reply data + struct ip_option_information Options; // Reply options +} ICMP_ECHO_REPLY, *PICMP_ECHO_REPLY; + +#if defined(_WIN64) + +typedef struct icmp_echo_reply32 { + IPAddr Address; + ULONG Status; + ULONG RoundTripTime; + USHORT DataSize; + USHORT Reserved; + VOID * POINTER_32 Data; + struct ip_option_information32 Options; +} ICMP_ECHO_REPLY32, *PICMP_ECHO_REPLY32; + +#endif // _WIN64 + +typedef struct arp_send_reply { + IPAddr DestAddress; + IPAddr SrcAddress; +} ARP_SEND_REPLY, *PARP_SEND_REPLY; + +typedef struct tcp_reserve_port_range { + USHORT UpperRange; + USHORT LowerRange; +} TCP_RESERVE_PORT_RANGE, *PTCP_RESERVE_PORT_RANGE; + +#define MAX_ADAPTER_NAME 128 + +typedef struct _IP_ADAPTER_INDEX_MAP { + ULONG Index; + WCHAR Name[MAX_ADAPTER_NAME]; +} IP_ADAPTER_INDEX_MAP, *PIP_ADAPTER_INDEX_MAP; + +typedef struct _IP_INTERFACE_INFO { + LONG NumAdapters; + IP_ADAPTER_INDEX_MAP Adapter[1]; +} IP_INTERFACE_INFO,*PIP_INTERFACE_INFO; + +typedef struct _IP_UNIDIRECTIONAL_ADAPTER_ADDRESS { + ULONG NumAdapters; + IPAddr Address[1]; +} IP_UNIDIRECTIONAL_ADAPTER_ADDRESS, *PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS; + +typedef struct _IP_ADAPTER_ORDER_MAP { + ULONG NumAdapters; + ULONG AdapterOrder[1]; +} IP_ADAPTER_ORDER_MAP, *PIP_ADAPTER_ORDER_MAP; + +typedef struct _IP_MCAST_COUNTER_INFO { + ULONG64 InMcastOctets; + ULONG64 OutMcastOctets; + ULONG64 InMcastPkts; + ULONG64 OutMcastPkts; +} IP_MCAST_COUNTER_INFO, *PIP_MCAST_COUNTER_INFO; + +// +// IP_STATUS codes returned from IP APIs +// + +#define IP_STATUS_BASE 11000 + +#define IP_SUCCESS 0 +#define IP_BUF_TOO_SMALL (IP_STATUS_BASE + 1) +#define IP_DEST_NET_UNREACHABLE (IP_STATUS_BASE + 2) +#define IP_DEST_HOST_UNREACHABLE (IP_STATUS_BASE + 3) +#define IP_DEST_PROT_UNREACHABLE (IP_STATUS_BASE + 4) +#define IP_DEST_PORT_UNREACHABLE (IP_STATUS_BASE + 5) +#define IP_NO_RESOURCES (IP_STATUS_BASE + 6) +#define IP_BAD_OPTION (IP_STATUS_BASE + 7) +#define IP_HW_ERROR (IP_STATUS_BASE + 8) +#define IP_PACKET_TOO_BIG (IP_STATUS_BASE + 9) +#define IP_REQ_TIMED_OUT (IP_STATUS_BASE + 10) +#define IP_BAD_REQ (IP_STATUS_BASE + 11) +#define IP_BAD_ROUTE (IP_STATUS_BASE + 12) +#define IP_TTL_EXPIRED_TRANSIT (IP_STATUS_BASE + 13) +#define IP_TTL_EXPIRED_REASSEM (IP_STATUS_BASE + 14) +#define IP_PARAM_PROBLEM (IP_STATUS_BASE + 15) +#define IP_SOURCE_QUENCH (IP_STATUS_BASE + 16) +#define IP_OPTION_TOO_BIG (IP_STATUS_BASE + 17) +#define IP_BAD_DESTINATION (IP_STATUS_BASE + 18) + +// +// Variants of the above using IPv6 terminology, where different +// + +#define IP_DEST_NO_ROUTE (IP_STATUS_BASE + 2) +#define IP_DEST_ADDR_UNREACHABLE (IP_STATUS_BASE + 3) +#define IP_DEST_PROHIBITED (IP_STATUS_BASE + 4) +#define IP_DEST_PORT_UNREACHABLE (IP_STATUS_BASE + 5) +#define IP_HOP_LIMIT_EXCEEDED (IP_STATUS_BASE + 13) +#define IP_REASSEMBLY_TIME_EXCEEDED (IP_STATUS_BASE + 14) +#define IP_PARAMETER_PROBLEM (IP_STATUS_BASE + 15) + +// +// IPv6-only status codes +// + +#define IP_DEST_UNREACHABLE (IP_STATUS_BASE + 40) +#define IP_TIME_EXCEEDED (IP_STATUS_BASE + 41) +#define IP_BAD_HEADER (IP_STATUS_BASE + 42) +#define IP_UNRECOGNIZED_NEXT_HEADER (IP_STATUS_BASE + 43) +#define IP_ICMP_ERROR (IP_STATUS_BASE + 44) +#define IP_DEST_SCOPE_MISMATCH (IP_STATUS_BASE + 45) + +// +// The next group are status codes passed up on status indications to +// transport layer protocols. +// +#define IP_ADDR_DELETED (IP_STATUS_BASE + 19) +#define IP_SPEC_MTU_CHANGE (IP_STATUS_BASE + 20) +#define IP_MTU_CHANGE (IP_STATUS_BASE + 21) +#define IP_UNLOAD (IP_STATUS_BASE + 22) +#define IP_ADDR_ADDED (IP_STATUS_BASE + 23) +#define IP_MEDIA_CONNECT (IP_STATUS_BASE + 24) +#define IP_MEDIA_DISCONNECT (IP_STATUS_BASE + 25) +#define IP_BIND_ADAPTER (IP_STATUS_BASE + 26) +#define IP_UNBIND_ADAPTER (IP_STATUS_BASE + 27) +#define IP_DEVICE_DOES_NOT_EXIST (IP_STATUS_BASE + 28) +#define IP_DUPLICATE_ADDRESS (IP_STATUS_BASE + 29) +#define IP_INTERFACE_METRIC_CHANGE (IP_STATUS_BASE + 30) +#define IP_RECONFIG_SECFLTR (IP_STATUS_BASE + 31) +#define IP_NEGOTIATING_IPSEC (IP_STATUS_BASE + 32) +#define IP_INTERFACE_WOL_CAPABILITY_CHANGE (IP_STATUS_BASE + 33) +#define IP_DUPLICATE_IPADD (IP_STATUS_BASE + 34) +#define IP_NO_FURTHER_SENDS (IP_STATUS_BASE + 35) + +#define IP_GENERAL_FAILURE (IP_STATUS_BASE + 50) +#define MAX_IP_STATUS IP_GENERAL_FAILURE +#define IP_PENDING (IP_STATUS_BASE + 255) + + +// +// Values used in the IP header Flags field. +// +#define IP_FLAG_DF 0x2 // Don't fragment this packet. + +// +// Supported IP Option Types. +// +// These types define the options which may be used in the OptionsData field +// of the ip_option_information structure. See RFC 791 for a complete +// description of each. +// +#define IP_OPT_EOL 0 // End of list option +#define IP_OPT_NOP 1 // No operation +#define IP_OPT_SECURITY 0x82 // Security option +#define IP_OPT_LSRR 0x83 // Loose source route +#define IP_OPT_SSRR 0x89 // Strict source route +#define IP_OPT_RR 0x7 // Record route +#define IP_OPT_TS 0x44 // Timestamp +#define IP_OPT_SID 0x88 // Stream ID (obsolete) +#define IP_OPT_ROUTER_ALERT 0x94 // Router Alert Option + +#define MAX_OPT_SIZE 40 // Maximum length of IP options in bytes + +#ifdef CHICAGO + +// Ioctls code exposed by Memphis tcpip stack. +// For NT these ioctls are define in ntddip.h (private\inc) + +#define IOCTL_IP_RTCHANGE_NOTIFY_REQUEST 101 +#define IOCTL_IP_ADDCHANGE_NOTIFY_REQUEST 102 +#define IOCTL_ARP_SEND_REQUEST 103 +#define IOCTL_IP_INTERFACE_INFO 104 +#define IOCTL_IP_GET_BEST_INTERFACE 105 +#define IOCTL_IP_UNIDIRECTIONAL_ADAPTER_ADDRESS 106 + +#endif + + +#endif // IP_EXPORT_INCLUDED + diff --git a/libraries/external/icmp/pc/include/IPHlpApi.h b/libraries/external/icmp/pc/include/IPHlpApi.h new file mode 100755 index 0000000..cbd10fb --- /dev/null +++ b/libraries/external/icmp/pc/include/IPHlpApi.h @@ -0,0 +1,588 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + + iphlpapi.h + +Abstract: + Header file for functions to interact with the IP Stack for MIB-II and + related functionality + +--*/ + +#ifndef __IPHLPAPI_H__ +#define __IPHLPAPI_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +////////////////////////////////////////////////////////////////////////////// +// // +// IPRTRMIB.H has the definitions of the strcutures used to set and get // +// information // +// // +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +////////////////////////////////////////////////////////////////////////////// +// // +// The GetXXXTable APIs take a buffer and a size of buffer. If the buffer // +// is not large enough, the APIs return ERROR_INSUFFICIENT_BUFFER and // +// *pdwSize is the required buffer size // +// The bOrder is a BOOLEAN, which if TRUE sorts the table according to // +// MIB-II (RFC XXXX) // +// // +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// // +// Retrieves the number of interfaces in the system. These include LAN and // +// WAN interfaces // +// // +////////////////////////////////////////////////////////////////////////////// + + +DWORD +WINAPI +GetNumberOfInterfaces( + OUT PDWORD pdwNumIf + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the MIB-II ifEntry // +// The dwIndex field of the MIB_IFROW should be set to the index of the // +// interface being queried // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetIfEntry( + IN OUT PMIB_IFROW pIfRow + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the MIB-II IfTable // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetIfTable( + OUT PMIB_IFTABLE pIfTable, + IN OUT PULONG pdwSize, + IN BOOL bOrder + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the Interface to IP Address mapping // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetIpAddrTable( + OUT PMIB_IPADDRTABLE pIpAddrTable, + IN OUT PULONG pdwSize, + IN BOOL bOrder + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the current IP Address to Physical Address (ARP) mapping // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetIpNetTable( + OUT PMIB_IPNETTABLE pIpNetTable, + IN OUT PULONG pdwSize, + IN BOOL bOrder + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the IP Routing Table (RFX XXXX) // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetIpForwardTable( + OUT PMIB_IPFORWARDTABLE pIpForwardTable, + IN OUT PULONG pdwSize, + IN BOOL bOrder + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets TCP Connection/UDP Listener Table // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetTcpTable( + OUT PMIB_TCPTABLE pTcpTable, + IN OUT PDWORD pdwSize, + IN BOOL bOrder + ); + +DWORD +WINAPI +GetUdpTable( + OUT PMIB_UDPTABLE pUdpTable, + IN OUT PDWORD pdwSize, + IN BOOL bOrder + ); + + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets IP/ICMP/TCP/UDP Statistics // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetIpStatistics( + OUT PMIB_IPSTATS pStats + ); + +DWORD +WINAPI +GetIpStatisticsEx( + OUT PMIB_IPSTATS pStats, + IN DWORD dwFamily + ); + +DWORD +WINAPI +GetIcmpStatistics( + OUT PMIB_ICMP pStats + ); + +DWORD +WINAPI +GetIcmpStatisticsEx( + OUT PMIB_ICMP_EX pStats, + IN DWORD dwFamily + ); + +DWORD +WINAPI +GetTcpStatistics( + OUT PMIB_TCPSTATS pStats + ); + +DWORD +WINAPI +GetTcpStatisticsEx( + OUT PMIB_TCPSTATS pStats, + IN DWORD dwFamily + ); + +DWORD +WINAPI +GetUdpStatistics( + OUT PMIB_UDPSTATS pStats + ); + +DWORD +WINAPI +GetUdpStatisticsEx( + OUT PMIB_UDPSTATS pStats, + IN DWORD dwFamily + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to set the ifAdminStatus on an interface. The only fields of the // +// MIB_IFROW that are relevant are the dwIndex (index of the interface // +// whose status needs to be set) and the dwAdminStatus which can be either // +// MIB_IF_ADMIN_STATUS_UP or MIB_IF_ADMIN_STATUS_DOWN // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +SetIfEntry( + IN PMIB_IFROW pIfRow + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to create, modify or delete a route. In all cases the // +// dwForwardIfIndex, dwForwardDest, dwForwardMask, dwForwardNextHop and // +// dwForwardPolicy MUST BE SPECIFIED. Currently dwForwardPolicy is unused // +// and MUST BE 0. // +// For a set, the complete MIB_IPFORWARDROW structure must be specified // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +CreateIpForwardEntry( + IN PMIB_IPFORWARDROW pRoute + ); + +DWORD +WINAPI +SetIpForwardEntry( + IN PMIB_IPFORWARDROW pRoute + ); + +DWORD +WINAPI +DeleteIpForwardEntry( + IN PMIB_IPFORWARDROW pRoute + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to set the ipForwarding to ON or OFF (currently only ON->OFF is // +// allowed) and to set the defaultTTL. If only one of the fields needs to // +// be modified and the other needs to be the same as before the other field // +// needs to be set to MIB_USE_CURRENT_TTL or MIB_USE_CURRENT_FORWARDING as // +// the case may be // +// // +////////////////////////////////////////////////////////////////////////////// + + +DWORD +WINAPI +SetIpStatistics( + IN PMIB_IPSTATS pIpStats + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to set the defaultTTL. // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +SetIpTTL( + UINT nTTL + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to create, modify or delete an ARP entry. In all cases the dwIndex // +// dwAddr field MUST BE SPECIFIED. // +// For a set, the complete MIB_IPNETROW structure must be specified // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +CreateIpNetEntry( + IN PMIB_IPNETROW pArpEntry + ); + +DWORD +WINAPI +SetIpNetEntry( + IN PMIB_IPNETROW pArpEntry + ); + +DWORD +WINAPI +DeleteIpNetEntry( + IN PMIB_IPNETROW pArpEntry + ); + +DWORD +WINAPI +FlushIpNetTable( + IN DWORD dwIfIndex + ); + + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to create or delete a Proxy ARP entry. The dwIndex is the index of // +// the interface on which to PARP for the dwAddress. If the interface is // +// of a type that doesnt support ARP, e.g. PPP, then the call will fail // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +CreateProxyArpEntry( + IN DWORD dwAddress, + IN DWORD dwMask, + IN DWORD dwIfIndex + ); + +DWORD +WINAPI +DeleteProxyArpEntry( + IN DWORD dwAddress, + IN DWORD dwMask, + IN DWORD dwIfIndex + ); + +////////////////////////////////////////////////////////////////////////////// +// // +// Used to set the state of a TCP Connection. The only state that it can be // +// set to is MIB_TCP_STATE_DELETE_TCB. The complete MIB_TCPROW structure // +// MUST BE SPECIFIED // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +SetTcpEntry( + IN PMIB_TCPROW pTcpRow + ); + + +DWORD +WINAPI +GetInterfaceInfo( + IN PIP_INTERFACE_INFO pIfTable, + OUT PULONG dwOutBufLen + ); + +DWORD +WINAPI +GetUniDirectionalAdapterInfo(OUT PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, + OUT PULONG dwOutBufLen + ); + +#ifndef NhpAllocateAndGetInterfaceInfoFromStack_DEFINED +#define NhpAllocateAndGetInterfaceInfoFromStack_DEFINED + +DWORD +WINAPI +NhpAllocateAndGetInterfaceInfoFromStack( + OUT IP_INTERFACE_NAME_INFO **ppTable, + OUT PDWORD pdwCount, + IN BOOL bOrder, + IN HANDLE hHeap, + IN DWORD dwFlags + ); + +#endif + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the "best" outgoing interface for the specified destination address // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetBestInterface( + IN IPAddr dwDestAddr, + OUT PDWORD pdwBestIfIndex + ); + +#pragma warning(push) +#pragma warning(disable:4115) +DWORD +WINAPI +GetBestInterfaceEx( + IN struct sockaddr *pDestAddr, + OUT PDWORD pdwBestIfIndex + ); +#pragma warning(pop) + +////////////////////////////////////////////////////////////////////////////// +// // +// Gets the best (longest matching prefix) route for the given destination // +// If the source address is also specified (i.e. is not 0x00000000), and // +// there are multiple "best" routes to the given destination, the returned // +// route will be one that goes out over the interface which has an address // +// that matches the source address // +// // +////////////////////////////////////////////////////////////////////////////// + +DWORD +WINAPI +GetBestRoute( + IN DWORD dwDestAddr, + IN DWORD dwSourceAddr, OPTIONAL + OUT PMIB_IPFORWARDROW pBestRoute + ); + +DWORD +WINAPI +NotifyAddrChange( + OUT PHANDLE Handle, + IN LPOVERLAPPED overlapped + ); + + +DWORD +WINAPI +NotifyRouteChange( + OUT PHANDLE Handle, + IN LPOVERLAPPED overlapped + ); + +BOOL +WINAPI +CancelIPChangeNotify( + IN LPOVERLAPPED notifyOverlapped + ); + +DWORD +WINAPI +GetAdapterIndex( + IN LPWSTR AdapterName, + OUT PULONG IfIndex + ); + +DWORD +WINAPI +AddIPAddress( + IPAddr Address, + IPMask IpMask, + DWORD IfIndex, + PULONG NTEContext, + PULONG NTEInstance + ); + +DWORD +WINAPI +DeleteIPAddress( + ULONG NTEContext + ); + +DWORD +WINAPI +GetNetworkParams( + PFIXED_INFO pFixedInfo, PULONG pOutBufLen + ); + +DWORD +WINAPI +GetAdaptersInfo( + PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen + ); + +PIP_ADAPTER_ORDER_MAP +WINAPI +GetAdapterOrderMap( + VOID + ); + +#ifdef _WINSOCK2API_ + +// +// The following functions require Winsock2. +// + +DWORD +WINAPI +GetAdaptersAddresses( + IN ULONG Family, + IN DWORD Flags, + IN PVOID Reserved, + OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses, + IN OUT PULONG pOutBufLen + ); + +#endif + +DWORD +WINAPI +GetPerAdapterInfo( + ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen + ); + +DWORD +WINAPI +IpReleaseAddress( + PIP_ADAPTER_INDEX_MAP AdapterInfo + ); + + +DWORD +WINAPI +IpRenewAddress( + PIP_ADAPTER_INDEX_MAP AdapterInfo + ); + +DWORD +WINAPI +SendARP( + IPAddr DestIP, + IPAddr SrcIP, + PULONG pMacAddr, + PULONG PhyAddrLen + ); + +BOOL +WINAPI +GetRTTAndHopCount( + IPAddr DestIpAddress, + PULONG HopCount, + ULONG MaxHops, + PULONG RTT + ); + +DWORD +WINAPI +GetFriendlyIfIndex( + DWORD IfIndex + ); + +DWORD +WINAPI +EnableRouter( + HANDLE* pHandle, + OVERLAPPED* pOverlapped + ); + +DWORD +WINAPI +UnenableRouter( + OVERLAPPED* pOverlapped, + LPDWORD lpdwEnableCount OPTIONAL + ); +DWORD +WINAPI +DisableMediaSense( + HANDLE *pHandle, + OVERLAPPED *pOverLapped + ); + +DWORD +WINAPI +RestoreMediaSense( + OVERLAPPED* pOverlapped, + LPDWORD lpdwEnableCount OPTIONAL + ); + +DWORD +WINAPI +GetIpErrorString( + IN IP_STATUS ErrorCode, + OUT PWCHAR Buffer, + IN OUT PDWORD Size + ); + +#ifdef __cplusplus +} +#endif + +#endif //__IPHLPAPI_H__ diff --git a/libraries/external/icmp/pc/include/IPTypes.h b/libraries/external/icmp/pc/include/IPTypes.h new file mode 100755 index 0000000..471007f --- /dev/null +++ b/libraries/external/icmp/pc/include/IPTypes.h @@ -0,0 +1,328 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + + iptypes.h + +--*/ + +#ifndef IP_TYPES_INCLUDED +#define IP_TYPES_INCLUDED + +#if _MSC_VER > 1000 +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma warning(push) +#pragma warning(disable:4201) + +#include + +// Definitions and structures used by getnetworkparams and getadaptersinfo apis + +#define MAX_ADAPTER_DESCRIPTION_LENGTH 128 // arb. +#define MAX_ADAPTER_NAME_LENGTH 256 // arb. +#define MAX_ADAPTER_ADDRESS_LENGTH 8 // arb. +#define DEFAULT_MINIMUM_ENTITIES 32 // arb. +#define MAX_HOSTNAME_LEN 128 // arb. +#define MAX_DOMAIN_NAME_LEN 128 // arb. +#define MAX_SCOPE_ID_LEN 256 // arb. + +// +// types +// + +// Node Type + +#define BROADCAST_NODETYPE 1 +#define PEER_TO_PEER_NODETYPE 2 +#define MIXED_NODETYPE 4 +#define HYBRID_NODETYPE 8 + +// +// IP_ADDRESS_STRING - store an IP address as a dotted decimal string +// + +typedef struct { + char String[4 * 4]; +} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING; + +// +// IP_ADDR_STRING - store an IP address with its corresponding subnet mask, +// both as dotted decimal strings +// + +typedef struct _IP_ADDR_STRING { + struct _IP_ADDR_STRING* Next; + IP_ADDRESS_STRING IpAddress; + IP_MASK_STRING IpMask; + DWORD Context; +} IP_ADDR_STRING, *PIP_ADDR_STRING; + +// +// ADAPTER_INFO - per-adapter information. All IP addresses are stored as +// strings +// + +typedef struct _IP_ADAPTER_INFO { + struct _IP_ADAPTER_INFO* Next; + DWORD ComboIndex; + char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4]; + char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]; + UINT AddressLength; + BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]; + DWORD Index; + UINT Type; + UINT DhcpEnabled; + PIP_ADDR_STRING CurrentIpAddress; + IP_ADDR_STRING IpAddressList; + IP_ADDR_STRING GatewayList; + IP_ADDR_STRING DhcpServer; + BOOL HaveWins; + IP_ADDR_STRING PrimaryWinsServer; + IP_ADDR_STRING SecondaryWinsServer; + time_t LeaseObtained; + time_t LeaseExpires; +} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO; + +#ifdef _WINSOCK2API_ + +// +// The following types require Winsock2. +// + +typedef enum { + IpPrefixOriginOther = 0, + IpPrefixOriginManual, + IpPrefixOriginWellKnown, + IpPrefixOriginDhcp, + IpPrefixOriginRouterAdvertisement, +} IP_PREFIX_ORIGIN; + +typedef enum { + IpSuffixOriginOther = 0, + IpSuffixOriginManual, + IpSuffixOriginWellKnown, + IpSuffixOriginDhcp, + IpSuffixOriginLinkLayerAddress, + IpSuffixOriginRandom, +} IP_SUFFIX_ORIGIN; + +typedef enum { + IpDadStateInvalid = 0, + IpDadStateTentative, + IpDadStateDuplicate, + IpDadStateDeprecated, + IpDadStatePreferred, +} IP_DAD_STATE; + +typedef struct _IP_ADAPTER_UNICAST_ADDRESS { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD Flags; + }; + }; + struct _IP_ADAPTER_UNICAST_ADDRESS *Next; + SOCKET_ADDRESS Address; + + IP_PREFIX_ORIGIN PrefixOrigin; + IP_SUFFIX_ORIGIN SuffixOrigin; + IP_DAD_STATE DadState; + + ULONG ValidLifetime; + ULONG PreferredLifetime; + ULONG LeaseLifetime; +} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS; + +typedef struct _IP_ADAPTER_ANYCAST_ADDRESS { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD Flags; + }; + }; + struct _IP_ADAPTER_ANYCAST_ADDRESS *Next; + SOCKET_ADDRESS Address; +} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS; + +typedef struct _IP_ADAPTER_MULTICAST_ADDRESS { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD Flags; + }; + }; + struct _IP_ADAPTER_MULTICAST_ADDRESS *Next; + SOCKET_ADDRESS Address; +} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS; + +// +// Per-address Flags +// +#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x01 +#define IP_ADAPTER_ADDRESS_TRANSIENT 0x02 +#define IP_ADAPTER_ADDRESS_PRIMARY 0x04 + +typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD Reserved; + }; + }; + struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next; + SOCKET_ADDRESS Address; +} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS; + +typedef struct _IP_ADAPTER_PREFIX { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD Flags; + }; + }; + struct _IP_ADAPTER_PREFIX *Next; + SOCKET_ADDRESS Address; + ULONG PrefixLength; +} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX; + +// +// Per-adapter Flags +// +#define IP_ADAPTER_DDNS_ENABLED 0x01 +#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02 +#define IP_ADAPTER_DHCP_ENABLED 0x04 +#define IP_ADAPTER_RECEIVE_ONLY 0x08 +#define IP_ADAPTER_NO_MULTICAST 0x10 +#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20 + +// +// OperStatus values from RFC 2863 +// +typedef enum { + IfOperStatusUp = 1, + IfOperStatusDown, + IfOperStatusTesting, + IfOperStatusUnknown, + IfOperStatusDormant, + IfOperStatusNotPresent, + IfOperStatusLowerLayerDown +} IF_OPER_STATUS; + +// +// Scope levels from RFC 2373 used with ZoneIndices array. +// +typedef enum { + ScopeLevelInterface = 1, + ScopeLevelLink = 2, + ScopeLevelSubnet = 3, + ScopeLevelAdmin = 4, + ScopeLevelSite = 5, + ScopeLevelOrganization = 8, + ScopeLevelGlobal = 14 +} SCOPE_LEVEL; + +typedef struct _IP_ADAPTER_ADDRESSES { + union { + ULONGLONG Alignment; + struct { + ULONG Length; + DWORD IfIndex; + }; + }; + struct _IP_ADAPTER_ADDRESSES *Next; + PCHAR AdapterName; + PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress; + PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress; + PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress; + PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress; + PWCHAR DnsSuffix; + PWCHAR Description; + PWCHAR FriendlyName; + BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH]; + DWORD PhysicalAddressLength; + DWORD Flags; + DWORD Mtu; + DWORD IfType; + IF_OPER_STATUS OperStatus; + DWORD Ipv6IfIndex; + DWORD ZoneIndices[16]; + PIP_ADAPTER_PREFIX FirstPrefix; +} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES; + +// +// Flags used as argument to GetAdaptersAddresses(). +// "SKIP" flags are added when the default is to include the information. +// "INCLUDE" flags are added when the default is to skip the information. +// +#define GAA_FLAG_SKIP_UNICAST 0x0001 +#define GAA_FLAG_SKIP_ANYCAST 0x0002 +#define GAA_FLAG_SKIP_MULTICAST 0x0004 +#define GAA_FLAG_SKIP_DNS_SERVER 0x0008 +#define GAA_FLAG_INCLUDE_PREFIX 0x0010 +#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020 + +#endif /* _WINSOCK2API_ */ + +// +// IP_PER_ADAPTER_INFO - per-adapter IP information such as DNS server list. +// + +typedef struct _IP_PER_ADAPTER_INFO { + UINT AutoconfigEnabled; + UINT AutoconfigActive; + PIP_ADDR_STRING CurrentDnsServer; + IP_ADDR_STRING DnsServerList; +} IP_PER_ADAPTER_INFO, *PIP_PER_ADAPTER_INFO; + +// +// FIXED_INFO - the set of IP-related information which does not depend on DHCP +// + +typedef struct { + char HostName[MAX_HOSTNAME_LEN + 4] ; + char DomainName[MAX_DOMAIN_NAME_LEN + 4]; + PIP_ADDR_STRING CurrentDnsServer; + IP_ADDR_STRING DnsServerList; + UINT NodeType; + char ScopeId[MAX_SCOPE_ID_LEN + 4]; + UINT EnableRouting; + UINT EnableProxy; + UINT EnableDns; +} FIXED_INFO, *PFIXED_INFO; + +#ifndef IP_INTERFACE_NAME_INFO_DEFINED +#define IP_INTERFACE_NAME_INFO_DEFINED + +typedef struct ip_interface_name_info { + ULONG Index; // Interface Index + ULONG MediaType; // Interface Types - see ipifcons.h + UCHAR ConnectionType; + UCHAR AccessType; + GUID DeviceGuid; // Device GUID is the guid of the device + // that IP exposes + GUID InterfaceGuid; // Interface GUID, if not GUID_NULL is the + // GUID for the interface mapped to the device. +} IP_INTERFACE_NAME_INFO, *PIP_INTERFACE_NAME_INFO; + +#endif + +#pragma warning(pop) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/icmp/pc/include/IcmpAPI.h b/libraries/external/icmp/pc/include/IcmpAPI.h new file mode 100755 index 0000000..2dad2a1 --- /dev/null +++ b/libraries/external/icmp/pc/include/IcmpAPI.h @@ -0,0 +1,335 @@ +/*++ + +Copyright (c) 1991-1999 Microsoft Corporation + +Module Name: + + icmpapi.h + +Abstract: + + Declarations for the Win32 ICMP Echo request API. + +Author: + + Portable Systems Group 30-December-1993 + +Revision History: + + +Notes: + +--*/ + +#ifndef _ICMP_INCLUDED_ +#define _ICMP_INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// +// Exported Routines. +// + +//++ +// +// Routine Name: +// +// IcmpCreateFile +// +// Routine Description: +// +// Opens a handle on which ICMP Echo Requests can be issued. +// +// Arguments: +// +// None. +// +// Return Value: +// +// An open file handle or INVALID_HANDLE_VALUE. Extended error information +// is available by calling GetLastError(). +// +//-- + +HANDLE +WINAPI +IcmpCreateFile( + VOID + ); + +//++ +// +// Routine Name: +// +// Icmp6CreateFile +// +// Routine Description: +// +// Opens a handle on which ICMPv6 Echo Requests can be issued. +// +// Arguments: +// +// None. +// +// Return Value: +// +// An open file handle or INVALID_HANDLE_VALUE. Extended error information +// is available by calling GetLastError(). +// +//-- + +HANDLE +WINAPI +Icmp6CreateFile( + VOID + ); + + +//++ +// +// Routine Name: +// +// IcmpCloseHandle +// +// Routine Description: +// +// Closes a handle opened by ICMPOpenFile. +// +// Arguments: +// +// IcmpHandle - The handle to close. +// +// Return Value: +// +// TRUE if the handle was closed successfully, otherwise FALSE. Extended +// error information is available by calling GetLastError(). +// +//-- + +BOOL +WINAPI +IcmpCloseHandle( + HANDLE IcmpHandle + ); + + + +//++ +// +// Routine Name: +// +// IcmpSendEcho +// +// Routine Description: +// +// Sends an ICMP Echo request and returns any replies. The +// call returns when the timeout has expired or the reply buffer +// is filled. +// +// Arguments: +// +// IcmpHandle - An open handle returned by ICMPCreateFile. +// +// DestinationAddress - The destination of the echo request. +// +// RequestData - A buffer containing the data to send in the +// request. +// +// RequestSize - The number of bytes in the request data buffer. +// +// RequestOptions - Pointer to the IP header options for the request. +// May be NULL. +// +// ReplyBuffer - A buffer to hold any replies to the request. +// On return, the buffer will contain an array of +// ICMP_ECHO_REPLY structures followed by the +// options and data for the replies. The buffer +// should be large enough to hold at least one +// ICMP_ECHO_REPLY structure plus +// MAX(RequestSize, 8) bytes of data since an ICMP +// error message contains 8 bytes of data. +// +// ReplySize - The size in bytes of the reply buffer. +// +// Timeout - The time in milliseconds to wait for replies. +// +// Return Value: +// +// Returns the number of ICMP_ECHO_REPLY structures stored in ReplyBuffer. +// The status of each reply is contained in the structure. If the return +// value is zero, extended error information is available via +// GetLastError(). +// +//-- + +DWORD +WINAPI +IcmpSendEcho( + HANDLE IcmpHandle, + IPAddr DestinationAddress, + LPVOID RequestData, + WORD RequestSize, + PIP_OPTION_INFORMATION RequestOptions, + LPVOID ReplyBuffer, + DWORD ReplySize, + DWORD Timeout + ); + + +//++ +// +// Routine Description: +// +// Sends an ICMP Echo request and the call returns either immediately +// (if Event or ApcRoutine is NonNULL) or returns after the specified +// timeout. The ReplyBuffer contains the ICMP responses, if any. +// +// Arguments: +// +// IcmpHandle - An open handle returned by ICMPCreateFile. +// +// Event - This is the event to be signalled whenever an IcmpResponse +// comes in. +// +// ApcRoutine - This routine would be called when the calling thread +// is in an alertable thread and an ICMP reply comes in. +// +// ApcContext - This optional parameter is given to the ApcRoutine when +// this call succeeds. +// +// DestinationAddress - The destination of the echo request. +// +// RequestData - A buffer containing the data to send in the +// request. +// +// RequestSize - The number of bytes in the request data buffer. +// +// RequestOptions - Pointer to the IP header options for the request. +// May be NULL. +// +// ReplyBuffer - A buffer to hold any replies to the request. +// On return, the buffer will contain an array of +// ICMP_ECHO_REPLY structures followed by options +// and data. The buffer must be large enough to +// hold at least one ICMP_ECHO_REPLY structure. +// It should be large enough to also hold +// 8 more bytes of data - this is the size of +// an ICMP error message. +// +// ReplySize - The size in bytes of the reply buffer. +// +// Timeout - The time in milliseconds to wait for replies. +// This is NOT used if ApcRoutine is not NULL or if Event +// is not NULL. +// +// Return Value: +// +// Returns the number of replies received and stored in ReplyBuffer. If +// the return value is zero, extended error information is available +// via GetLastError(). +// +// Remarks: +// +// On NT platforms, +// If used Asynchronously (either ApcRoutine or Event is specified), then +// ReplyBuffer and ReplySize are still needed. This is where the response +// comes in. +// ICMP Response data is copied to the ReplyBuffer provided, and the caller of +// this function has to parse it asynchronously. The function IcmpParseReply +// is provided for this purpose. +// +// On non-NT platforms, +// Event, ApcRoutine and ApcContext are IGNORED. +// +//-- + + +DWORD +WINAPI +IcmpSendEcho2( + HANDLE IcmpHandle, + HANDLE Event, +#ifdef PIO_APC_ROUTINE_DEFINED + PIO_APC_ROUTINE ApcRoutine, +#else + FARPROC ApcRoutine, +#endif + PVOID ApcContext, + IPAddr DestinationAddress, + LPVOID RequestData, + WORD RequestSize, + PIP_OPTION_INFORMATION RequestOptions, + LPVOID ReplyBuffer, + DWORD ReplySize, + DWORD Timeout + ); + +DWORD +WINAPI +Icmp6SendEcho2( + HANDLE IcmpHandle, + HANDLE Event, +#ifdef PIO_APC_ROUTINE_DEFINED + PIO_APC_ROUTINE ApcRoutine, +#else + FARPROC ApcRoutine, +#endif + PVOID ApcContext, + struct sockaddr_in6 *SourceAddress, + struct sockaddr_in6 *DestinationAddress, + LPVOID RequestData, + WORD RequestSize, + PIP_OPTION_INFORMATION RequestOptions, + LPVOID ReplyBuffer, + DWORD ReplySize, + DWORD Timeout + ); + + +//++ +// +// Routine Description: +// +// Parses the reply buffer provided and returns the number of ICMP responses found. +// +// Arguments: +// +// ReplyBuffer - This must be the same buffer that was passed to IcmpSendEcho2 +// This is rewritten to hold an array of ICMP_ECHO_REPLY structures. +// (i.e. the type is PICMP_ECHO_REPLY). +// +// ReplySize - This must be the size of the above buffer. +// +// Return Value: +// Returns the number of ICMP responses found. If there is an errors, return value is +// zero. The error can be determined by a call to GetLastError. +// +// Remarks: +// This function SHOULD NOT BE USED on a reply buffer that was passed to SendIcmpEcho. +// SendIcmpEcho actually parses the buffer before returning back to the user. This function +// is meant to be used only with SendIcmpEcho2. +//-- + +DWORD +IcmpParseReplies( + LPVOID ReplyBuffer, + DWORD ReplySize + ); + +DWORD +Icmp6ParseReplies( + LPVOID ReplyBuffer, + DWORD ReplySize + ); + +#ifdef __cplusplus +} +#endif + +#endif // _ICMP_INCLUDED_ diff --git a/libraries/external/icmp/pc/include/vssver.scc b/libraries/external/icmp/pc/include/vssver.scc new file mode 100755 index 0000000..11b575e Binary files /dev/null and b/libraries/external/icmp/pc/include/vssver.scc differ diff --git a/libraries/external/icmp/pc/lib/IPHlpApi.Lib b/libraries/external/icmp/pc/lib/IPHlpApi.Lib new file mode 100755 index 0000000..cc6540f Binary files /dev/null and b/libraries/external/icmp/pc/lib/IPHlpApi.Lib differ diff --git a/libraries/external/icmp/pc/lib/vssver.scc b/libraries/external/icmp/pc/lib/vssver.scc new file mode 100755 index 0000000..7894141 Binary files /dev/null and b/libraries/external/icmp/pc/lib/vssver.scc differ diff --git a/libraries/external/jpeglib/Debug/jcapimin.obj b/libraries/external/jpeglib/Debug/jcapimin.obj new file mode 100755 index 0000000..ebf69b5 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcapimin.obj differ diff --git a/libraries/external/jpeglib/Debug/jcapistd.obj b/libraries/external/jpeglib/Debug/jcapistd.obj new file mode 100755 index 0000000..53b80c2 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcapistd.obj differ diff --git a/libraries/external/jpeglib/Debug/jccoefct.obj b/libraries/external/jpeglib/Debug/jccoefct.obj new file mode 100755 index 0000000..46ed7b5 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jccoefct.obj differ diff --git a/libraries/external/jpeglib/Debug/jccolor.obj b/libraries/external/jpeglib/Debug/jccolor.obj new file mode 100755 index 0000000..8deda1a Binary files /dev/null and b/libraries/external/jpeglib/Debug/jccolor.obj differ diff --git a/libraries/external/jpeglib/Debug/jcdctmgr.obj b/libraries/external/jpeglib/Debug/jcdctmgr.obj new file mode 100755 index 0000000..3d677ff Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcdctmgr.obj differ diff --git a/libraries/external/jpeglib/Debug/jchuff.obj b/libraries/external/jpeglib/Debug/jchuff.obj new file mode 100755 index 0000000..75641e9 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jchuff.obj differ diff --git a/libraries/external/jpeglib/Debug/jcinit.obj b/libraries/external/jpeglib/Debug/jcinit.obj new file mode 100755 index 0000000..de15ba6 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcinit.obj differ diff --git a/libraries/external/jpeglib/Debug/jcmainct.obj b/libraries/external/jpeglib/Debug/jcmainct.obj new file mode 100755 index 0000000..161388e Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcmainct.obj differ diff --git a/libraries/external/jpeglib/Debug/jcmarker.obj b/libraries/external/jpeglib/Debug/jcmarker.obj new file mode 100755 index 0000000..9d9d506 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcmarker.obj differ diff --git a/libraries/external/jpeglib/Debug/jcmaster.obj b/libraries/external/jpeglib/Debug/jcmaster.obj new file mode 100755 index 0000000..ebd760a Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcmaster.obj differ diff --git a/libraries/external/jpeglib/Debug/jcomapi.obj b/libraries/external/jpeglib/Debug/jcomapi.obj new file mode 100755 index 0000000..2eb85d8 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcomapi.obj differ diff --git a/libraries/external/jpeglib/Debug/jcparam.obj b/libraries/external/jpeglib/Debug/jcparam.obj new file mode 100755 index 0000000..ea495ef Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcparam.obj differ diff --git a/libraries/external/jpeglib/Debug/jcphuff.obj b/libraries/external/jpeglib/Debug/jcphuff.obj new file mode 100755 index 0000000..c994ce1 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcphuff.obj differ diff --git a/libraries/external/jpeglib/Debug/jcprepct.obj b/libraries/external/jpeglib/Debug/jcprepct.obj new file mode 100755 index 0000000..c829a19 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcprepct.obj differ diff --git a/libraries/external/jpeglib/Debug/jcsample.obj b/libraries/external/jpeglib/Debug/jcsample.obj new file mode 100755 index 0000000..f3a5acd Binary files /dev/null and b/libraries/external/jpeglib/Debug/jcsample.obj differ diff --git a/libraries/external/jpeglib/Debug/jctrans.obj b/libraries/external/jpeglib/Debug/jctrans.obj new file mode 100755 index 0000000..b00bbdf Binary files /dev/null and b/libraries/external/jpeglib/Debug/jctrans.obj differ diff --git a/libraries/external/jpeglib/Debug/jdapimin.obj b/libraries/external/jpeglib/Debug/jdapimin.obj new file mode 100755 index 0000000..4012231 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdapimin.obj differ diff --git a/libraries/external/jpeglib/Debug/jdapistd.obj b/libraries/external/jpeglib/Debug/jdapistd.obj new file mode 100755 index 0000000..c9cd8d0 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdapistd.obj differ diff --git a/libraries/external/jpeglib/Debug/jdatadst.obj b/libraries/external/jpeglib/Debug/jdatadst.obj new file mode 100755 index 0000000..0b73032 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdatadst.obj differ diff --git a/libraries/external/jpeglib/Debug/jdatasrc.obj b/libraries/external/jpeglib/Debug/jdatasrc.obj new file mode 100755 index 0000000..7007ac0 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdatasrc.obj differ diff --git a/libraries/external/jpeglib/Debug/jdcoefct.obj b/libraries/external/jpeglib/Debug/jdcoefct.obj new file mode 100755 index 0000000..0f4bb2a Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdcoefct.obj differ diff --git a/libraries/external/jpeglib/Debug/jdcolor.obj b/libraries/external/jpeglib/Debug/jdcolor.obj new file mode 100755 index 0000000..a6a792d Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdcolor.obj differ diff --git a/libraries/external/jpeglib/Debug/jddctmgr.obj b/libraries/external/jpeglib/Debug/jddctmgr.obj new file mode 100755 index 0000000..b648f16 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jddctmgr.obj differ diff --git a/libraries/external/jpeglib/Debug/jdhuff.obj b/libraries/external/jpeglib/Debug/jdhuff.obj new file mode 100755 index 0000000..4d7e612 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdhuff.obj differ diff --git a/libraries/external/jpeglib/Debug/jdinput.obj b/libraries/external/jpeglib/Debug/jdinput.obj new file mode 100755 index 0000000..890f276 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdinput.obj differ diff --git a/libraries/external/jpeglib/Debug/jdmainct.obj b/libraries/external/jpeglib/Debug/jdmainct.obj new file mode 100755 index 0000000..5cb3727 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdmainct.obj differ diff --git a/libraries/external/jpeglib/Debug/jdmarker.obj b/libraries/external/jpeglib/Debug/jdmarker.obj new file mode 100755 index 0000000..1b9d860 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdmarker.obj differ diff --git a/libraries/external/jpeglib/Debug/jdmaster.obj b/libraries/external/jpeglib/Debug/jdmaster.obj new file mode 100755 index 0000000..917459b Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdmaster.obj differ diff --git a/libraries/external/jpeglib/Debug/jdmerge.obj b/libraries/external/jpeglib/Debug/jdmerge.obj new file mode 100755 index 0000000..02aba85 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdmerge.obj differ diff --git a/libraries/external/jpeglib/Debug/jdphuff.obj b/libraries/external/jpeglib/Debug/jdphuff.obj new file mode 100755 index 0000000..29446c3 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdphuff.obj differ diff --git a/libraries/external/jpeglib/Debug/jdpostct.obj b/libraries/external/jpeglib/Debug/jdpostct.obj new file mode 100755 index 0000000..5c2f201 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdpostct.obj differ diff --git a/libraries/external/jpeglib/Debug/jdsample.obj b/libraries/external/jpeglib/Debug/jdsample.obj new file mode 100755 index 0000000..17f0f8e Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdsample.obj differ diff --git a/libraries/external/jpeglib/Debug/jdtrans.obj b/libraries/external/jpeglib/Debug/jdtrans.obj new file mode 100755 index 0000000..d19797a Binary files /dev/null and b/libraries/external/jpeglib/Debug/jdtrans.obj differ diff --git a/libraries/external/jpeglib/Debug/jerror.obj b/libraries/external/jpeglib/Debug/jerror.obj new file mode 100755 index 0000000..13a85c7 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jerror.obj differ diff --git a/libraries/external/jpeglib/Debug/jfdctflt.obj b/libraries/external/jpeglib/Debug/jfdctflt.obj new file mode 100755 index 0000000..31cf5dc Binary files /dev/null and b/libraries/external/jpeglib/Debug/jfdctflt.obj differ diff --git a/libraries/external/jpeglib/Debug/jfdctfst.obj b/libraries/external/jpeglib/Debug/jfdctfst.obj new file mode 100755 index 0000000..ee3cafb Binary files /dev/null and b/libraries/external/jpeglib/Debug/jfdctfst.obj differ diff --git a/libraries/external/jpeglib/Debug/jfdctint.obj b/libraries/external/jpeglib/Debug/jfdctint.obj new file mode 100755 index 0000000..9baeb7f Binary files /dev/null and b/libraries/external/jpeglib/Debug/jfdctint.obj differ diff --git a/libraries/external/jpeglib/Debug/jidctflt.obj b/libraries/external/jpeglib/Debug/jidctflt.obj new file mode 100755 index 0000000..d833603 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jidctflt.obj differ diff --git a/libraries/external/jpeglib/Debug/jidctfst.obj b/libraries/external/jpeglib/Debug/jidctfst.obj new file mode 100755 index 0000000..6940fbd Binary files /dev/null and b/libraries/external/jpeglib/Debug/jidctfst.obj differ diff --git a/libraries/external/jpeglib/Debug/jidctint.obj b/libraries/external/jpeglib/Debug/jidctint.obj new file mode 100755 index 0000000..5a5b56f Binary files /dev/null and b/libraries/external/jpeglib/Debug/jidctint.obj differ diff --git a/libraries/external/jpeglib/Debug/jidctred.obj b/libraries/external/jpeglib/Debug/jidctred.obj new file mode 100755 index 0000000..9fbc470 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jidctred.obj differ diff --git a/libraries/external/jpeglib/Debug/jmemansi.obj b/libraries/external/jpeglib/Debug/jmemansi.obj new file mode 100755 index 0000000..9b21865 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jmemansi.obj differ diff --git a/libraries/external/jpeglib/Debug/jmemmgr.obj b/libraries/external/jpeglib/Debug/jmemmgr.obj new file mode 100755 index 0000000..a3ea0c0 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jmemmgr.obj differ diff --git a/libraries/external/jpeglib/Debug/jpeglib.lib b/libraries/external/jpeglib/Debug/jpeglib.lib new file mode 100755 index 0000000..e2bf6b7 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jpeglib.lib differ diff --git a/libraries/external/jpeglib/Debug/jpeglib.pch b/libraries/external/jpeglib/Debug/jpeglib.pch new file mode 100755 index 0000000..82b4172 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jpeglib.pch differ diff --git a/libraries/external/jpeglib/Debug/jquant1.obj b/libraries/external/jpeglib/Debug/jquant1.obj new file mode 100755 index 0000000..ac541c0 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jquant1.obj differ diff --git a/libraries/external/jpeglib/Debug/jquant2.obj b/libraries/external/jpeglib/Debug/jquant2.obj new file mode 100755 index 0000000..a396b4a Binary files /dev/null and b/libraries/external/jpeglib/Debug/jquant2.obj differ diff --git a/libraries/external/jpeglib/Debug/jutils.obj b/libraries/external/jpeglib/Debug/jutils.obj new file mode 100755 index 0000000..f9d0c30 Binary files /dev/null and b/libraries/external/jpeglib/Debug/jutils.obj differ diff --git a/libraries/external/jpeglib/Debug/vc60.idb b/libraries/external/jpeglib/Debug/vc60.idb new file mode 100755 index 0000000..4327577 Binary files /dev/null and b/libraries/external/jpeglib/Debug/vc60.idb differ diff --git a/libraries/external/jpeglib/Debug/vc60.pdb b/libraries/external/jpeglib/Debug/vc60.pdb new file mode 100755 index 0000000..3e9be29 Binary files /dev/null and b/libraries/external/jpeglib/Debug/vc60.pdb differ diff --git a/libraries/external/jpeglib/Release/jcapimin.obj b/libraries/external/jpeglib/Release/jcapimin.obj new file mode 100755 index 0000000..72e35ad Binary files /dev/null and b/libraries/external/jpeglib/Release/jcapimin.obj differ diff --git a/libraries/external/jpeglib/Release/jcapistd.obj b/libraries/external/jpeglib/Release/jcapistd.obj new file mode 100755 index 0000000..b19ec68 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcapistd.obj differ diff --git a/libraries/external/jpeglib/Release/jccoefct.obj b/libraries/external/jpeglib/Release/jccoefct.obj new file mode 100755 index 0000000..b6ec255 Binary files /dev/null and b/libraries/external/jpeglib/Release/jccoefct.obj differ diff --git a/libraries/external/jpeglib/Release/jccolor.obj b/libraries/external/jpeglib/Release/jccolor.obj new file mode 100755 index 0000000..0938396 Binary files /dev/null and b/libraries/external/jpeglib/Release/jccolor.obj differ diff --git a/libraries/external/jpeglib/Release/jcdctmgr.obj b/libraries/external/jpeglib/Release/jcdctmgr.obj new file mode 100755 index 0000000..32fdb8a Binary files /dev/null and b/libraries/external/jpeglib/Release/jcdctmgr.obj differ diff --git a/libraries/external/jpeglib/Release/jchuff.obj b/libraries/external/jpeglib/Release/jchuff.obj new file mode 100755 index 0000000..9c8094f Binary files /dev/null and b/libraries/external/jpeglib/Release/jchuff.obj differ diff --git a/libraries/external/jpeglib/Release/jcinit.obj b/libraries/external/jpeglib/Release/jcinit.obj new file mode 100755 index 0000000..9b38621 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcinit.obj differ diff --git a/libraries/external/jpeglib/Release/jcmainct.obj b/libraries/external/jpeglib/Release/jcmainct.obj new file mode 100755 index 0000000..fa86a90 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcmainct.obj differ diff --git a/libraries/external/jpeglib/Release/jcmarker.obj b/libraries/external/jpeglib/Release/jcmarker.obj new file mode 100755 index 0000000..5771344 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcmarker.obj differ diff --git a/libraries/external/jpeglib/Release/jcmaster.obj b/libraries/external/jpeglib/Release/jcmaster.obj new file mode 100755 index 0000000..ced45e7 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcmaster.obj differ diff --git a/libraries/external/jpeglib/Release/jcomapi.obj b/libraries/external/jpeglib/Release/jcomapi.obj new file mode 100755 index 0000000..4bd7eec Binary files /dev/null and b/libraries/external/jpeglib/Release/jcomapi.obj differ diff --git a/libraries/external/jpeglib/Release/jcparam.obj b/libraries/external/jpeglib/Release/jcparam.obj new file mode 100755 index 0000000..25ebca4 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcparam.obj differ diff --git a/libraries/external/jpeglib/Release/jcphuff.obj b/libraries/external/jpeglib/Release/jcphuff.obj new file mode 100755 index 0000000..d85a7cd Binary files /dev/null and b/libraries/external/jpeglib/Release/jcphuff.obj differ diff --git a/libraries/external/jpeglib/Release/jcprepct.obj b/libraries/external/jpeglib/Release/jcprepct.obj new file mode 100755 index 0000000..75db899 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcprepct.obj differ diff --git a/libraries/external/jpeglib/Release/jcsample.obj b/libraries/external/jpeglib/Release/jcsample.obj new file mode 100755 index 0000000..c234375 Binary files /dev/null and b/libraries/external/jpeglib/Release/jcsample.obj differ diff --git a/libraries/external/jpeglib/Release/jctrans.obj b/libraries/external/jpeglib/Release/jctrans.obj new file mode 100755 index 0000000..bdee390 Binary files /dev/null and b/libraries/external/jpeglib/Release/jctrans.obj differ diff --git a/libraries/external/jpeglib/Release/jdapimin.obj b/libraries/external/jpeglib/Release/jdapimin.obj new file mode 100755 index 0000000..57bc32a Binary files /dev/null and b/libraries/external/jpeglib/Release/jdapimin.obj differ diff --git a/libraries/external/jpeglib/Release/jdapistd.obj b/libraries/external/jpeglib/Release/jdapistd.obj new file mode 100755 index 0000000..f2ae2fd Binary files /dev/null and b/libraries/external/jpeglib/Release/jdapistd.obj differ diff --git a/libraries/external/jpeglib/Release/jdatadst.obj b/libraries/external/jpeglib/Release/jdatadst.obj new file mode 100755 index 0000000..9612906 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdatadst.obj differ diff --git a/libraries/external/jpeglib/Release/jdatasrc.obj b/libraries/external/jpeglib/Release/jdatasrc.obj new file mode 100755 index 0000000..24bb336 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdatasrc.obj differ diff --git a/libraries/external/jpeglib/Release/jdcoefct.obj b/libraries/external/jpeglib/Release/jdcoefct.obj new file mode 100755 index 0000000..4294cd9 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdcoefct.obj differ diff --git a/libraries/external/jpeglib/Release/jdcolor.obj b/libraries/external/jpeglib/Release/jdcolor.obj new file mode 100755 index 0000000..d11f0fd Binary files /dev/null and b/libraries/external/jpeglib/Release/jdcolor.obj differ diff --git a/libraries/external/jpeglib/Release/jddctmgr.obj b/libraries/external/jpeglib/Release/jddctmgr.obj new file mode 100755 index 0000000..e836a2e Binary files /dev/null and b/libraries/external/jpeglib/Release/jddctmgr.obj differ diff --git a/libraries/external/jpeglib/Release/jdhuff.obj b/libraries/external/jpeglib/Release/jdhuff.obj new file mode 100755 index 0000000..5b17c08 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdhuff.obj differ diff --git a/libraries/external/jpeglib/Release/jdinput.obj b/libraries/external/jpeglib/Release/jdinput.obj new file mode 100755 index 0000000..d918d93 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdinput.obj differ diff --git a/libraries/external/jpeglib/Release/jdmainct.obj b/libraries/external/jpeglib/Release/jdmainct.obj new file mode 100755 index 0000000..6a0116b Binary files /dev/null and b/libraries/external/jpeglib/Release/jdmainct.obj differ diff --git a/libraries/external/jpeglib/Release/jdmarker.obj b/libraries/external/jpeglib/Release/jdmarker.obj new file mode 100755 index 0000000..3f6312e Binary files /dev/null and b/libraries/external/jpeglib/Release/jdmarker.obj differ diff --git a/libraries/external/jpeglib/Release/jdmaster.obj b/libraries/external/jpeglib/Release/jdmaster.obj new file mode 100755 index 0000000..7ebd09c Binary files /dev/null and b/libraries/external/jpeglib/Release/jdmaster.obj differ diff --git a/libraries/external/jpeglib/Release/jdmerge.obj b/libraries/external/jpeglib/Release/jdmerge.obj new file mode 100755 index 0000000..257c384 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdmerge.obj differ diff --git a/libraries/external/jpeglib/Release/jdphuff.obj b/libraries/external/jpeglib/Release/jdphuff.obj new file mode 100755 index 0000000..7b48348 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdphuff.obj differ diff --git a/libraries/external/jpeglib/Release/jdpostct.obj b/libraries/external/jpeglib/Release/jdpostct.obj new file mode 100755 index 0000000..5ecff00 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdpostct.obj differ diff --git a/libraries/external/jpeglib/Release/jdsample.obj b/libraries/external/jpeglib/Release/jdsample.obj new file mode 100755 index 0000000..85a43bf Binary files /dev/null and b/libraries/external/jpeglib/Release/jdsample.obj differ diff --git a/libraries/external/jpeglib/Release/jdtrans.obj b/libraries/external/jpeglib/Release/jdtrans.obj new file mode 100755 index 0000000..1ee5d26 Binary files /dev/null and b/libraries/external/jpeglib/Release/jdtrans.obj differ diff --git a/libraries/external/jpeglib/Release/jerror.obj b/libraries/external/jpeglib/Release/jerror.obj new file mode 100755 index 0000000..6d3f2e4 Binary files /dev/null and b/libraries/external/jpeglib/Release/jerror.obj differ diff --git a/libraries/external/jpeglib/Release/jfdctflt.obj b/libraries/external/jpeglib/Release/jfdctflt.obj new file mode 100755 index 0000000..22447a9 Binary files /dev/null and b/libraries/external/jpeglib/Release/jfdctflt.obj differ diff --git a/libraries/external/jpeglib/Release/jfdctfst.obj b/libraries/external/jpeglib/Release/jfdctfst.obj new file mode 100755 index 0000000..22b912e Binary files /dev/null and b/libraries/external/jpeglib/Release/jfdctfst.obj differ diff --git a/libraries/external/jpeglib/Release/jfdctint.obj b/libraries/external/jpeglib/Release/jfdctint.obj new file mode 100755 index 0000000..c939063 Binary files /dev/null and b/libraries/external/jpeglib/Release/jfdctint.obj differ diff --git a/libraries/external/jpeglib/Release/jidctflt.obj b/libraries/external/jpeglib/Release/jidctflt.obj new file mode 100755 index 0000000..2ee0a1b Binary files /dev/null and b/libraries/external/jpeglib/Release/jidctflt.obj differ diff --git a/libraries/external/jpeglib/Release/jidctfst.obj b/libraries/external/jpeglib/Release/jidctfst.obj new file mode 100755 index 0000000..0623b09 Binary files /dev/null and b/libraries/external/jpeglib/Release/jidctfst.obj differ diff --git a/libraries/external/jpeglib/Release/jidctint.obj b/libraries/external/jpeglib/Release/jidctint.obj new file mode 100755 index 0000000..1272293 Binary files /dev/null and b/libraries/external/jpeglib/Release/jidctint.obj differ diff --git a/libraries/external/jpeglib/Release/jidctred.obj b/libraries/external/jpeglib/Release/jidctred.obj new file mode 100755 index 0000000..45ec67a Binary files /dev/null and b/libraries/external/jpeglib/Release/jidctred.obj differ diff --git a/libraries/external/jpeglib/Release/jmemansi.obj b/libraries/external/jpeglib/Release/jmemansi.obj new file mode 100755 index 0000000..cd8d42e Binary files /dev/null and b/libraries/external/jpeglib/Release/jmemansi.obj differ diff --git a/libraries/external/jpeglib/Release/jmemmgr.obj b/libraries/external/jpeglib/Release/jmemmgr.obj new file mode 100755 index 0000000..4799f05 Binary files /dev/null and b/libraries/external/jpeglib/Release/jmemmgr.obj differ diff --git a/libraries/external/jpeglib/Release/jpeglib.lib b/libraries/external/jpeglib/Release/jpeglib.lib new file mode 100755 index 0000000..7796e42 Binary files /dev/null and b/libraries/external/jpeglib/Release/jpeglib.lib differ diff --git a/libraries/external/jpeglib/Release/jpeglib.pch b/libraries/external/jpeglib/Release/jpeglib.pch new file mode 100755 index 0000000..f034df5 Binary files /dev/null and b/libraries/external/jpeglib/Release/jpeglib.pch differ diff --git a/libraries/external/jpeglib/Release/jquant1.obj b/libraries/external/jpeglib/Release/jquant1.obj new file mode 100755 index 0000000..4df6efe Binary files /dev/null and b/libraries/external/jpeglib/Release/jquant1.obj differ diff --git a/libraries/external/jpeglib/Release/jquant2.obj b/libraries/external/jpeglib/Release/jquant2.obj new file mode 100755 index 0000000..fdc0964 Binary files /dev/null and b/libraries/external/jpeglib/Release/jquant2.obj differ diff --git a/libraries/external/jpeglib/Release/jutils.obj b/libraries/external/jpeglib/Release/jutils.obj new file mode 100755 index 0000000..97c7964 Binary files /dev/null and b/libraries/external/jpeglib/Release/jutils.obj differ diff --git a/libraries/external/jpeglib/Release/vc60.idb b/libraries/external/jpeglib/Release/vc60.idb new file mode 100755 index 0000000..b03e00e Binary files /dev/null and b/libraries/external/jpeglib/Release/vc60.idb differ diff --git a/libraries/external/jpeglib/jcapimin.c b/libraries/external/jpeglib/jcapimin.c new file mode 100755 index 0000000..493af5c --- /dev/null +++ b/libraries/external/jpeglib/jcapimin.c @@ -0,0 +1,280 @@ +/* + * jcapimin.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-compression case or the transcoding-only + * case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jcapistd.c. But also see jcparam.c for + * parameter-setup helper routines, jcomapi.c for routines shared by + * compression and decompression, and jctrans.c for the transcoding case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG compression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_compress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); + + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = FALSE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->dest = NULL; + + cinfo->comp_info = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + cinfo->script_space = NULL; + + cinfo->input_gamma = 1.0; /* in case application forgets */ + + /* OK, I'm ready */ + cinfo->global_state = CSTATE_START; +} + + +/* + * Destruction of a JPEG compression object + */ + +GLOBAL(void) +jpeg_destroy_compress (j_compress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG compression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_compress (j_compress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Forcibly suppress or un-suppress all quantization and Huffman tables. + * Marks all currently defined tables as already written (if suppress) + * or not written (if !suppress). This will control whether they get emitted + * by a subsequent jpeg_start_compress call. + * + * This routine is exported for use by applications that want to produce + * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but + * since it is called by jpeg_start_compress, we put it here --- otherwise + * jcparam.o would be linked whether the application used it or not. + */ + +GLOBAL(void) +jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) +{ + int i; + JQUANT_TBL * qtbl; + JHUFF_TBL * htbl; + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) + qtbl->sent_table = suppress; + } + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) + htbl->sent_table = suppress; + } +} + + +/* + * Finish JPEG compression. + * + * If a multipass operating mode was selected, this may do a great deal of + * work including most of the actual output. + */ + +GLOBAL(void) +jpeg_finish_compress (j_compress_ptr cinfo) +{ + JDIMENSION iMCU_row; + + if (cinfo->global_state == CSTATE_SCANNING || + cinfo->global_state == CSTATE_RAW_OK) { + /* Terminate first pass */ + if (cinfo->next_scanline < cinfo->image_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_pass) (cinfo); + } else if (cinfo->global_state != CSTATE_WRCOEFS) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any remaining passes */ + while (! cinfo->master->is_last_pass) { + (*cinfo->master->prepare_for_pass) (cinfo); + for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) iMCU_row; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* We bypass the main controller and invoke coef controller directly; + * all work is being done from the coefficient buffer. + */ + if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } + (*cinfo->master->finish_pass) (cinfo); + } + /* Write EOI, do final cleanup */ + (*cinfo->marker->write_file_trailer) (cinfo); + (*cinfo->dest->term_destination) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); +} + + +/* + * Write a special marker. + * This is only recommended for writing COM or APPn markers. + * Must be called after jpeg_start_compress() and before + * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). + */ + +GLOBAL(void) +jpeg_write_marker (j_compress_ptr cinfo, int marker, + const JOCTET *dataptr, unsigned int datalen) +{ + JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); + + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); + write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ + while (datalen--) { + (*write_marker_byte) (cinfo, *dataptr); + dataptr++; + } +} + +/* Same, but piecemeal. */ + +GLOBAL(void) +jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) +{ + if (cinfo->next_scanline != 0 || + (cinfo->global_state != CSTATE_SCANNING && + cinfo->global_state != CSTATE_RAW_OK && + cinfo->global_state != CSTATE_WRCOEFS)) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); +} + +GLOBAL(void) +jpeg_write_m_byte (j_compress_ptr cinfo, int val) +{ + (*cinfo->marker->write_marker_byte) (cinfo, val); +} + + +/* + * Alternate compression function: just write an abbreviated table file. + * Before calling this, all parameters and a data destination must be set up. + * + * To produce a pair of files containing abbreviated tables and abbreviated + * image data, one would proceed as follows: + * + * initialize JPEG object + * set JPEG parameters + * set destination to table file + * jpeg_write_tables(cinfo); + * set destination to image file + * jpeg_start_compress(cinfo, FALSE); + * write data... + * jpeg_finish_compress(cinfo); + * + * jpeg_write_tables has the side effect of marking all tables written + * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress + * will not re-emit the tables unless it is passed write_all_tables=TRUE. + */ + +GLOBAL(void) +jpeg_write_tables (j_compress_ptr cinfo) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Initialize the marker writer ... bit of a crock to do it here. */ + jinit_marker_writer(cinfo); + /* Write them tables! */ + (*cinfo->marker->write_tables_only) (cinfo); + /* And clean up. */ + (*cinfo->dest->term_destination) (cinfo); + /* + * In library releases up through v6a, we called jpeg_abort() here to free + * any working memory allocated by the destination manager and marker + * writer. Some applications had a problem with that: they allocated space + * of their own from the library memory manager, and didn't want it to go + * away during write_tables. So now we do nothing. This will cause a + * memory leak if an app calls write_tables repeatedly without doing a full + * compression cycle or otherwise resetting the JPEG object. However, that + * seems less bad than unexpectedly freeing memory in the normal case. + * An app that prefers the old behavior can call jpeg_abort for itself after + * each call to jpeg_write_tables(). + */ +} diff --git a/libraries/external/jpeglib/jcapimin.o b/libraries/external/jpeglib/jcapimin.o new file mode 100644 index 0000000..2773649 Binary files /dev/null and b/libraries/external/jpeglib/jcapimin.o differ diff --git a/libraries/external/jpeglib/jcapistd.c b/libraries/external/jpeglib/jcapistd.c new file mode 100755 index 0000000..fed66ca --- /dev/null +++ b/libraries/external/jpeglib/jcapistd.c @@ -0,0 +1,161 @@ +/* + * jcapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the compression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-compression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_compress, it will end up linking in the entire compressor. + * We thus must separate this file from jcapimin.c to avoid linking the + * whole compression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Compression initialization. + * Before calling this, all parameters and a data destination must be set up. + * + * We require a write_all_tables parameter as a failsafe check when writing + * multiple datastreams from the same compression object. Since prior runs + * will have left all the tables marked sent_table=TRUE, a subsequent run + * would emit an abbreviated stream (no tables) by default. This may be what + * is wanted, but for safety's sake it should not be the default behavior: + * programmers should have to make a deliberate choice to emit abbreviated + * images. Therefore the documentation and examples should encourage people + * to pass write_all_tables=TRUE; then it will take active thought to do the + * wrong thing. + */ + +GLOBAL(void) +jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (write_all_tables) + jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ + + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + jinit_compress_master(cinfo); + /* Set up for the first pass */ + (*cinfo->master->prepare_for_pass) (cinfo); + /* Ready for application to drive first pass through jpeg_write_scanlines + * or jpeg_write_raw_data. + */ + cinfo->next_scanline = 0; + cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); +} + + +/* + * Write some scanlines of data to the JPEG compressor. + * + * The return value will be the number of lines actually written. + * This should be less than the supplied num_lines only in case that + * the data destination module has requested suspension of the compressor, + * or if more than image_height scanlines are passed in. + * + * Note: we warn about excess calls to jpeg_write_scanlines() since + * this likely signals an application programmer error. However, + * excess scanlines passed in the last valid call are *silently* ignored, + * so that the application need not adjust num_lines for end-of-image + * when using a multiple-scanline buffer. + */ + +GLOBAL(JDIMENSION) +jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION num_lines) +{ + JDIMENSION row_ctr, rows_left; + + if (cinfo->global_state != CSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_scanlines. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_scanlines. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Ignore any extra scanlines at bottom of image. */ + rows_left = cinfo->image_height - cinfo->next_scanline; + if (num_lines > rows_left) + num_lines = rows_left; + + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); + cinfo->next_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to write raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION num_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != CSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->next_scanline >= cinfo->image_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->next_scanline; + cinfo->progress->pass_limit = (long) cinfo->image_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Give master control module another chance if this is first call to + * jpeg_write_raw_data. This lets output of the frame/scan headers be + * delayed so that application can write COM, etc, markers between + * jpeg_start_compress and jpeg_write_raw_data. + */ + if (cinfo->master->call_pass_startup) + (*cinfo->master->pass_startup) (cinfo); + + /* Verify that at least one iMCU row has been passed. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; + if (num_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Directly compress the row. */ + if (! (*cinfo->coef->compress_data) (cinfo, data)) { + /* If compressor did not consume the whole row, suspend processing. */ + return 0; + } + + /* OK, we processed one iMCU row. */ + cinfo->next_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} diff --git a/libraries/external/jpeglib/jcapistd.o b/libraries/external/jpeglib/jcapistd.o new file mode 100644 index 0000000..8274650 Binary files /dev/null and b/libraries/external/jpeglib/jcapistd.o differ diff --git a/libraries/external/jpeglib/jccoefct.c b/libraries/external/jpeglib/jccoefct.c new file mode 100755 index 0000000..c713b85 --- /dev/null +++ b/libraries/external/jpeglib/jccoefct.c @@ -0,0 +1,449 @@ +/* + * jccoefct.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for compression. + * This controller is the top level of the JPEG compressor proper. + * The coefficient buffer lies between forward-DCT and entropy encoding steps. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* We use a full-image coefficient buffer when doing Huffman optimization, + * and also for writing multiple-scan JPEG files. In all cases, the DCT + * step is run during the first pass, and subsequent passes need only read + * the buffered coefficients. + */ +#ifdef ENTROPY_OPT_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#else +#ifdef C_MULTISCAN_FILES_SUPPORTED +#define FULL_COEF_BUFFER_SUPPORTED +#endif +#endif + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* For single-pass compression, it's sufficient to buffer just one MCU + * (although this may prove a bit slow in practice). We allocate a + * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each + * MCU constructed and sent. (On 80x86, the workspace is FAR even though + * it's not really very big; this is to keep the module interfaces unchanged + * when a large coefficient buffer is necessary.) + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays. + */ + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +/* Forward declarations */ +METHODDEF(boolean) compress_data + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#ifdef FULL_COEF_BUFFER_SUPPORTED +METHODDEF(boolean) compress_first_pass + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +METHODDEF(boolean) compress_output + JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->mcu_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (coef->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_data; + break; +#ifdef FULL_COEF_BUFFER_SUPPORTED + case JBUF_SAVE_AND_PASS: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_first_pass; + break; + case JBUF_CRANK_DEST: + if (coef->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + coef->pub.compress_data = compress_output; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data in the single-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf contains a plane for each component in image, + * which we index according to the component's SOF position. + */ + +METHODDEF(boolean) +compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, bi, ci, yindex, yoffset, blockcnt; + JDIMENSION ypos, xpos; + jpeg_component_info *compptr; + + /* Loop to write as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Determine where data comes from in input_buf and do the DCT thing. + * Each call on forward_DCT processes a horizontal row of DCT blocks + * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks + * sequentially. Dummy blocks at the right or bottom edge are filled in + * specially. The data in them does not matter for image reconstruction, + * so we fill them with values that will encode to the smallest amount of + * data, viz: all zeroes in the AC entries, DC entries equal to previous + * block's DC value. (Thanks to Thomas Kinsman for this idea.) + */ + blkn = 0; + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + xpos = MCU_col_num * compptr->MCU_sample_width; + ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yoffset+yindex < compptr->last_row_height) { + (*cinfo->fdct->forward_DCT) (cinfo, compptr, + input_buf[compptr->component_index], + coef->MCU_buffer[blkn], + ypos, xpos, (JDIMENSION) blockcnt); + if (blockcnt < compptr->MCU_width) { + /* Create some dummy blocks at the right edge of the image. */ + jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], + (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); + for (bi = blockcnt; bi < compptr->MCU_width; bi++) { + coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; + } + } + } else { + /* Create a row of dummy blocks at the bottom of the image. */ + jzero_far((void FAR *) coef->MCU_buffer[blkn], + compptr->MCU_width * SIZEOF(JBLOCK)); + for (bi = 0; bi < compptr->MCU_width; bi++) { + coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; + } + } + blkn += compptr->MCU_width; + ypos += DCTSIZE; + } + } + /* Try to write the MCU. In event of a suspension failure, we will + * re-DCT the MCU on restart (a bit inefficient, could be fixed...) + */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +#ifdef FULL_COEF_BUFFER_SUPPORTED + +/* + * Process some data in the first pass of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the image. + * This amount of data is read from the source buffer, DCT'd and quantized, + * and saved into the virtual arrays. We also generate suitable dummy blocks + * as needed at the right and lower edges. (The dummy blocks are constructed + * in the virtual arrays, which have been padded appropriately.) This makes + * it possible for subsequent passes not to worry about real vs. dummy blocks. + * + * We must also emit the data to the entropy encoder. This is conveniently + * done by calling compress_output() after we've loaded the current strip + * of the virtual arrays. + * + * NB: input_buf contains a plane for each component in image. All + * components are DCT'd and loaded into the virtual arrays in this pass. + * However, it may be that only a subset of the components are emitted to + * the entropy encoder during this first pass; be careful about looking + * at the scan-dependent variables (MCU dimensions, etc). + */ + +METHODDEF(boolean) +compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION blocks_across, MCUs_across, MCUindex; + int bi, ci, h_samp_factor, block_row, block_rows, ndummy; + JCOEF lastDC; + jpeg_component_info *compptr; + JBLOCKARRAY buffer; + JBLOCKROW thisblockrow, lastblockrow; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (coef->iMCU_row_num < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here, since may not be set! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + blocks_across = compptr->width_in_blocks; + h_samp_factor = compptr->h_samp_factor; + /* Count number of dummy blocks to be added at the right margin. */ + ndummy = (int) (blocks_across % h_samp_factor); + if (ndummy > 0) + ndummy = h_samp_factor - ndummy; + /* Perform DCT for all non-dummy blocks in this iMCU row. Each call + * on forward_DCT processes a complete horizontal row of DCT blocks. + */ + for (block_row = 0; block_row < block_rows; block_row++) { + thisblockrow = buffer[block_row]; + (*cinfo->fdct->forward_DCT) (cinfo, compptr, + input_buf[ci], thisblockrow, + (JDIMENSION) (block_row * DCTSIZE), + (JDIMENSION) 0, blocks_across); + if (ndummy > 0) { + /* Create dummy blocks at the right edge of the image. */ + thisblockrow += blocks_across; /* => first dummy block */ + jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); + lastDC = thisblockrow[-1][0]; + for (bi = 0; bi < ndummy; bi++) { + thisblockrow[bi][0] = lastDC; + } + } + } + /* If at end of image, create dummy block rows as needed. + * The tricky part here is that within each MCU, we want the DC values + * of the dummy blocks to match the last real block's DC value. + * This squeezes a few more bytes out of the resulting file... + */ + if (coef->iMCU_row_num == last_iMCU_row) { + blocks_across += ndummy; /* include lower right corner */ + MCUs_across = blocks_across / h_samp_factor; + for (block_row = block_rows; block_row < compptr->v_samp_factor; + block_row++) { + thisblockrow = buffer[block_row]; + lastblockrow = buffer[block_row-1]; + jzero_far((void FAR *) thisblockrow, + (size_t) (blocks_across * SIZEOF(JBLOCK))); + for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { + lastDC = lastblockrow[h_samp_factor-1][0]; + for (bi = 0; bi < h_samp_factor; bi++) { + thisblockrow[bi][0] = lastDC; + } + thisblockrow += h_samp_factor; /* advance to next MCU in row */ + lastblockrow += h_samp_factor; + } + } + } + } + /* NB: compress_output will increment iMCU_row_num if successful. + * A suspension return will result in redoing all the work above next time. + */ + + /* Emit data to the entropy encoder, sharing code with subsequent passes */ + return compress_output(cinfo, input_buf); +} + + +/* + * Process some data in subsequent passes of a multi-pass case. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int blkn, ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. + * NB: during first pass, this is safe only because the buffers will + * already be aligned properly, so jmemmgr.c won't need to do any I/O. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < compptr->MCU_width; xindex++) { + coef->MCU_buffer[blkn++] = buffer_ptr++; + } + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + +#endif /* FULL_COEF_BUFFER_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_c_coef_controller *) coef; + coef->pub.start_pass = start_pass_coef; + + /* Create the coefficient buffer. */ + if (need_full_buffer) { +#ifdef FULL_COEF_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + int ci; + jpeg_component_info *compptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) compptr->v_samp_factor); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKROW buffer; + int i; + + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { + coef->MCU_buffer[i] = buffer + i; + } + coef->whole_image[0] = NULL; /* flag for no virtual arrays */ + } +} diff --git a/libraries/external/jpeglib/jccoefct.o b/libraries/external/jpeglib/jccoefct.o new file mode 100644 index 0000000..82398d1 Binary files /dev/null and b/libraries/external/jpeglib/jccoefct.o differ diff --git a/libraries/external/jpeglib/jccolor.c b/libraries/external/jpeglib/jccolor.c new file mode 100755 index 0000000..2663724 --- /dev/null +++ b/libraries/external/jpeglib/jccolor.c @@ -0,0 +1,459 @@ +/* + * jccolor.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_converter pub; /* public fields */ + + /* Private state for RGB->YCC conversion */ + INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ +} my_color_converter; + +typedef my_color_converter * my_cconvert_ptr; + + +/**************** RGB -> YCbCr conversion: most common case **************/ + +/* + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * The conversion equations to be implemented are therefore + * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B + * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE + * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) + * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, + * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and + * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) + * were not represented exactly. Now we sacrifice exact representation of + * maximum red and maximum blue in order to get exact grayscales. + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times R,G,B for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 12-bit samples it is still acceptable. It's not very reasonable for + * 16-bit samples, but if you want lossless storage you shouldn't be changing + * colorspace anyway. + * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included + * in the tables to save adding them separately in the inner loop. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L< Y section */ +#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ +#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ +#define R_CB_OFF (3*(MAXJSAMPLE+1)) +#define G_CB_OFF (4*(MAXJSAMPLE+1)) +#define B_CB_OFF (5*(MAXJSAMPLE+1)) +#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ +#define G_CR_OFF (6*(MAXJSAMPLE+1)) +#define B_CR_OFF (7*(MAXJSAMPLE+1)) +#define TABLE_SIZE (8*(MAXJSAMPLE+1)) + + +/* + * Initialize for RGB->YCC colorspace conversion. + */ + +METHODDEF(void) +rgb_ycc_start (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + INT32 * rgb_ycc_tab; + INT32 i; + + /* Allocate and fill in the conversion tables. */ + cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (TABLE_SIZE * SIZEOF(INT32))); + + for (i = 0; i <= MAXJSAMPLE; i++) { + rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; + rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; + rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; + rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; + rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; + /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. + * This ensures that the maximum output will round to MAXJSAMPLE + * not MAXJSAMPLE+1, and thus that we don't have to range-limit. + */ + rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; +/* B=>Cb and R=>Cr tables are the same + rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; +*/ + rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; + rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * + * Note that we change from the application's interleaved-pixel format + * to our internal noninterleaved, one-plane-per-component format. + * The input buffer is therefore three times as wide as the output buffer. + * + * A starting row offset is provided only for the output buffer. The caller + * can easily adjust the passed input_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +rgb_ycc_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/**************** Cases other than RGB -> YCbCr **************/ + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles RGB->grayscale conversion, which is the same + * as the RGB->Y portion of RGB->YCbCr. + * We assume rgb_ycc_start has been called (we only use the Y tables). + */ + +METHODDEF(void) +rgb_gray_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = GETJSAMPLE(inptr[RGB_RED]); + g = GETJSAMPLE(inptr[RGB_GREEN]); + b = GETJSAMPLE(inptr[RGB_BLUE]); + inptr += RGB_PIXELSIZE; + /* Y */ + outptr[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles Adobe-style CMYK->YCCK conversion, + * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same + * conversion as above, while passing K (black) unchanged. + * We assume rgb_ycc_start has been called. + */ + +METHODDEF(void) +cmyk_ycck_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int r, g, b; + register INT32 * ctab = cconvert->rgb_ycc_tab; + register JSAMPROW inptr; + register JSAMPROW outptr0, outptr1, outptr2, outptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr0 = output_buf[0][output_row]; + outptr1 = output_buf[1][output_row]; + outptr2 = output_buf[2][output_row]; + outptr3 = output_buf[3][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); + g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); + b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); + /* K passes through as-is */ + outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ + inptr += 4; + /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations + * must be too; we do not need an explicit range-limiting operation. + * Hence the value being shifted is never negative, and we don't + * need the general RIGHT_SHIFT macro. + */ + /* Y */ + outptr0[col] = (JSAMPLE) + ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) + >> SCALEBITS); + /* Cb */ + outptr1[col] = (JSAMPLE) + ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) + >> SCALEBITS); + /* Cr */ + outptr2[col] = (JSAMPLE) + ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) + >> SCALEBITS); + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles grayscale output with no conversion. + * The source can be either plain grayscale or YCbCr (since Y == gray). + */ + +METHODDEF(void) +grayscale_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->image_width; + int instride = cinfo->input_components; + + while (--num_rows >= 0) { + inptr = *input_buf++; + outptr = output_buf[0][output_row]; + output_row++; + for (col = 0; col < num_cols; col++) { + outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ + inptr += instride; + } + } +} + + +/* + * Convert some rows of samples to the JPEG colorspace. + * This version handles multi-component colorspaces without conversion. + * We assume input_components == num_components. + */ + +METHODDEF(void) +null_convert (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows) +{ + register JSAMPROW inptr; + register JSAMPROW outptr; + register JDIMENSION col; + register int ci; + int nc = cinfo->num_components; + JDIMENSION num_cols = cinfo->image_width; + + while (--num_rows >= 0) { + /* It seems fastest to make a separate pass for each component. */ + for (ci = 0; ci < nc; ci++) { + inptr = *input_buf; + outptr = output_buf[ci][output_row]; + for (col = 0; col < num_cols; col++) { + outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ + inptr += nc; + } + } + input_buf++; + output_row++; + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +null_method (j_compress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for input colorspace conversion. + */ + +GLOBAL(void) +jinit_color_converter (j_compress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + + cconvert = (my_cconvert_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_color_converter)); + cinfo->cconvert = (struct jpeg_color_converter *) cconvert; + /* set start_pass to null method until we find out differently */ + cconvert->pub.start_pass = null_method; + + /* Make sure input_components agrees with in_color_space */ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + if (cinfo->input_components != 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_RGB: +#if RGB_PIXELSIZE != 3 + if (cinfo->input_components != RGB_PIXELSIZE) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; +#endif /* else share code with YCbCr */ + + case JCS_YCbCr: + if (cinfo->input_components != 3) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->input_components != 4) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->input_components < 1) + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + break; + } + + /* Check num_components, set conversion method based on requested space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_GRAYSCALE) + cconvert->pub.color_convert = grayscale_convert; + else if (cinfo->in_color_space == JCS_RGB) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_gray_convert; + } else if (cinfo->in_color_space == JCS_YCbCr) + cconvert->pub.color_convert = grayscale_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_RGB: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_RGB) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = rgb_ycc_convert; + } else if (cinfo->in_color_space == JCS_YCbCr) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_CMYK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_CMYK) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + if (cinfo->in_color_space == JCS_CMYK) { + cconvert->pub.start_pass = rgb_ycc_start; + cconvert->pub.color_convert = cmyk_ycck_convert; + } else if (cinfo->in_color_space == JCS_YCCK) + cconvert->pub.color_convert = null_convert; + else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + default: /* allow null conversion of JCS_UNKNOWN */ + if (cinfo->jpeg_color_space != cinfo->in_color_space || + cinfo->num_components != cinfo->input_components) + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + cconvert->pub.color_convert = null_convert; + break; + } +} diff --git a/libraries/external/jpeglib/jccolor.o b/libraries/external/jpeglib/jccolor.o new file mode 100644 index 0000000..400e0cc Binary files /dev/null and b/libraries/external/jpeglib/jccolor.o differ diff --git a/libraries/external/jpeglib/jcdctmgr.c b/libraries/external/jpeglib/jcdctmgr.c new file mode 100755 index 0000000..e3f90dc --- /dev/null +++ b/libraries/external/jpeglib/jcdctmgr.c @@ -0,0 +1,387 @@ +/* + * jcdctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the forward-DCT management logic. + * This code selects a particular DCT implementation to be used, + * and it performs related housekeeping chores including coefficient + * quantization. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_forward_dct pub; /* public fields */ + + /* Pointer to the DCT routine actually in use */ + forward_DCT_method_ptr do_dct; + + /* The actual post-DCT divisors --- not identical to the quant table + * entries, because of scaling (especially for an unnormalized DCT). + * Each table is given in normal array order. + */ + DCTELEM * divisors[NUM_QUANT_TBLS]; + +#ifdef DCT_FLOAT_SUPPORTED + /* Same as above for the floating-point case. */ + float_DCT_method_ptr do_float_dct; + FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; +#endif +} my_fdct_controller; + +typedef my_fdct_controller * my_fdct_ptr; + + +/* + * Initialize for a processing pass. + * Verify that all referenced Q-tables are present, and set up + * the divisor table for each one. + * In the current implementation, DCT of all components is done during + * the first pass, even if only some components will be output in the + * first scan. Hence all components should be examined here. + */ + +METHODDEF(void) +start_pass_fdctmgr (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + int ci, qtblno, i; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + DCTELEM * dtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + qtblno = compptr->quant_tbl_no; + /* Make sure specified quantization table is present */ + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + qtbl = cinfo->quant_tbl_ptrs[qtblno]; + /* Compute divisors for this quant table */ + /* We may do this more than once for same table, but it's not a big deal */ + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + /* For LL&M IDCT method, divisors are equal to raw quantization + * coefficients multiplied by 8 (to counteract scaling). + */ + if (fdct->divisors[qtblno] == NULL) { + fdct->divisors[qtblno] = (DCTELEM *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(DCTELEM)); + } + dtbl = fdct->divisors[qtblno]; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + */ +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + if (fdct->divisors[qtblno] == NULL) { + fdct->divisors[qtblno] = (DCTELEM *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(DCTELEM)); + } + dtbl = fdct->divisors[qtblno]; + for (i = 0; i < DCTSIZE2; i++) { + dtbl[i] = (DCTELEM) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-3); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, divisors are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * We apply a further scale factor of 8. + * What's actually stored is 1/divisor so that the inner loop can + * use a multiplication rather than a division. + */ + FAST_FLOAT * fdtbl; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + if (fdct->float_divisors[qtblno] == NULL) { + fdct->float_divisors[qtblno] = (FAST_FLOAT *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + DCTSIZE2 * SIZEOF(FAST_FLOAT)); + } + fdtbl = fdct->float_divisors[qtblno]; + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fdtbl[i] = (FAST_FLOAT) + (1.0 / (((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col] * 8.0))); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Perform forward DCT on one or more blocks of a component. + * + * The input samples are taken from the sample_data[] array starting at + * position start_row/start_col, and moving to the right for any additional + * blocks. The quantized coefficients are returned in coef_blocks[]. + */ + +METHODDEF(void) +forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks) +/* This version is used for integer DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + forward_DCT_method_ptr do_dct = fdct->do_dct; + DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; + DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + sample_data += start_row; /* fold in the vertical offset once */ + + for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { + /* Load data into workspace, applying unsigned->signed conversion */ + { register DCTELEM *workspaceptr; + register JSAMPROW elemptr; + register int elemr; + + workspaceptr = workspace; + for (elemr = 0; elemr < DCTSIZE; elemr++) { + elemptr = sample_data[elemr] + start_col; +#if DCTSIZE == 8 /* unroll the inner loop */ + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; +#else + { register int elemc; + for (elemc = DCTSIZE; elemc > 0; elemc--) { + *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; + } + } +#endif + } + } + + /* Perform the DCT */ + (*do_dct) (workspace); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register DCTELEM temp, qval; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + qval = divisors[i]; + temp = workspace[i]; + /* Divide the coefficient value by qval, ensuring proper rounding. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * + * In most files, at least half of the output values will be zero + * (at default quantization settings, more like three-quarters...) + * so we should ensure that this case is fast. On many machines, + * a comparison is enough cheaper than a divide to make a special test + * a win. Since both inputs will be nonnegative, we need only test + * for a < b to discover whether a/b is 0. + * If your machine's division is fast enough, define FAST_DIVIDE. + */ +#ifdef FAST_DIVIDE +#define DIVIDE_BY(a,b) a /= b +#else +#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 +#endif + if (temp < 0) { + temp = -temp; + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + temp = -temp; + } else { + temp += qval>>1; /* for rounding */ + DIVIDE_BY(temp, qval); + } + output_ptr[i] = (JCOEF) temp; + } + } + } +} + + +#ifdef DCT_FLOAT_SUPPORTED + +METHODDEF(void) +forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks) +/* This version is used for floating-point DCT implementations. */ +{ + /* This routine is heavily used, so it's worth coding it tightly. */ + my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; + float_DCT_method_ptr do_dct = fdct->do_float_dct; + FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; + FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ + JDIMENSION bi; + + sample_data += start_row; /* fold in the vertical offset once */ + + for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { + /* Load data into workspace, applying unsigned->signed conversion */ + { register FAST_FLOAT *workspaceptr; + register JSAMPROW elemptr; + register int elemr; + + workspaceptr = workspace; + for (elemr = 0; elemr < DCTSIZE; elemr++) { + elemptr = sample_data[elemr] + start_col; +#if DCTSIZE == 8 /* unroll the inner loop */ + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); +#else + { register int elemc; + for (elemc = DCTSIZE; elemc > 0; elemc--) { + *workspaceptr++ = (FAST_FLOAT) + (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); + } + } +#endif + } + } + + /* Perform the DCT */ + (*do_dct) (workspace); + + /* Quantize/descale the coefficients, and store into coef_blocks[] */ + { register FAST_FLOAT temp; + register int i; + register JCOEFPTR output_ptr = coef_blocks[bi]; + + for (i = 0; i < DCTSIZE2; i++) { + /* Apply the quantization and scaling factor */ + temp = workspace[i] * divisors[i]; + /* Round to nearest integer. + * Since C does not specify the direction of rounding for negative + * quotients, we have to force the dividend positive for portability. + * The maximum coefficient size is +-16K (for 12-bit data), so this + * code should work for either 16-bit or 32-bit ints. + */ + output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); + } + } + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ + + +/* + * Initialize FDCT manager. + */ + +GLOBAL(void) +jinit_forward_dct (j_compress_ptr cinfo) +{ + my_fdct_ptr fdct; + int i; + + fdct = (my_fdct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_fdct_controller)); + cinfo->fdct = (struct jpeg_forward_dct *) fdct; + fdct->pub.start_pass = start_pass_fdctmgr; + + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + fdct->pub.forward_DCT = forward_DCT; + fdct->do_dct = jpeg_fdct_islow; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + fdct->pub.forward_DCT = forward_DCT; + fdct->do_dct = jpeg_fdct_ifast; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + fdct->pub.forward_DCT = forward_DCT_float; + fdct->do_float_dct = jpeg_fdct_float; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + + /* Mark divisor tables unallocated */ + for (i = 0; i < NUM_QUANT_TBLS; i++) { + fdct->divisors[i] = NULL; +#ifdef DCT_FLOAT_SUPPORTED + fdct->float_divisors[i] = NULL; +#endif + } +} diff --git a/libraries/external/jpeglib/jcdctmgr.o b/libraries/external/jpeglib/jcdctmgr.o new file mode 100644 index 0000000..94873bc Binary files /dev/null and b/libraries/external/jpeglib/jcdctmgr.o differ diff --git a/libraries/external/jpeglib/jchuff.c b/libraries/external/jpeglib/jchuff.c new file mode 100755 index 0000000..16d9366 --- /dev/null +++ b/libraries/external/jpeglib/jchuff.c @@ -0,0 +1,909 @@ +/* + * jchuff.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines. + * + * Much of the complexity here has to do with supporting output suspension. + * If the data destination module demands suspension, we want to be able to + * back up to the start of the current MCU. To do this, we copy state + * variables into local working storage, and update them back to the + * permanent JPEG objects only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jchuff.h" /* Declarations shared with jcphuff.c */ + + +/* Expanded entropy encoder object for Huffman encoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).put_buffer = (src).put_buffer, \ + (dest).put_bits = (src).put_bits, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + savable_state saved; /* Bit buffer & DC state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + +#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ + long * dc_count_ptrs[NUM_HUFF_TBLS]; + long * ac_count_ptrs[NUM_HUFF_TBLS]; +#endif +} huff_entropy_encoder; + +typedef huff_entropy_encoder * huff_entropy_ptr; + +/* Working state while writing an MCU. + * This struct contains all the fields that are needed by subroutines. + */ + +typedef struct { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + savable_state cur; /* Current bit buffer & DC state */ + j_compress_ptr cinfo; /* dump_buffer needs access to this */ +} working_state; + + +/* Forward declarations */ +METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); +#ifdef ENTROPY_OPT_SUPPORTED +METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); +#endif + + +/* + * Initialize for a Huffman-compressed scan. + * If gather_statistics is TRUE, we do not output anything during the scan, + * just count the Huffman symbols used and generate Huffman code tables. + */ + +METHODDEF(void) +start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + + if (gather_statistics) { +#ifdef ENTROPY_OPT_SUPPORTED + entropy->pub.encode_mcu = encode_mcu_gather; + entropy->pub.finish_pass = finish_pass_gather; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + entropy->pub.encode_mcu = encode_mcu_huff; + entropy->pub.finish_pass = finish_pass_huff; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + if (gather_statistics) { +#ifdef ENTROPY_OPT_SUPPORTED + /* Check for invalid table indexes */ + /* (make_c_derived_tbl does this in the other path) */ + if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); + if (actbl < 0 || actbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->dc_count_ptrs[dctbl] == NULL) + entropy->dc_count_ptrs[dctbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); + if (entropy->ac_count_ptrs[actbl] == NULL) + entropy->ac_count_ptrs[actbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); +#endif + } else { + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, + & entropy->dc_derived_tbls[dctbl]); + jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, + & entropy->ac_derived_tbls[actbl]); + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bit buffer to empty */ + entropy->saved.put_buffer = 0; + entropy->saved.put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* + * Compute the derived values for a Huffman table. + * This routine also performs some validation checks on the table. + * + * Note this is also used by jcphuff.c. + */ + +GLOBAL(void) +jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, + c_derived_tbl ** pdtbl) +{ + JHUFF_TBL *htbl; + c_derived_tbl *dtbl; + int p, i, l, lastp, si, maxsymbol; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Note that huffsize[] and huffcode[] are filled in code-length order, + * paralleling the order of the symbols themselves in htbl->huffval[]. + */ + + /* Find the input Huffman table */ + if (tblno < 0 || tblno >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + htbl = + isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (c_derived_tbl *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(c_derived_tbl)); + dtbl = *pdtbl; + + /* Figure C.1: make table of Huffman code length for each symbol */ + + p = 0; + for (l = 1; l <= 16; l++) { + i = (int) htbl->bits[l]; + if (i < 0 || p + i > 256) /* protect against table overrun */ + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + while (i--) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + lastp = p; + + /* Figure C.2: generate the codes themselves */ + /* We also validate that the counts represent a legal Huffman code tree. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + /* code is now 1 more than the last code used for codelength si; but + * it must still fit in si bits, since no code is allowed to be all ones. + */ + if (((INT32) code) >= (((INT32) 1) << si)) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + code <<= 1; + si++; + } + + /* Figure C.3: generate encoding tables */ + /* These are code and size indexed by symbol value */ + + /* Set all codeless symbols to have code length 0; + * this lets us detect duplicate VAL entries here, and later + * allows emit_bits to detect any attempt to emit such symbols. + */ + MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); + + /* This is also a convenient place to check for out-of-range + * and duplicated VAL entries. We allow 0..255 for AC symbols + * but only 0..15 for DC. (We could constrain them further + * based on data depth and mode, but this seems enough.) + */ + maxsymbol = isDC ? 15 : 255; + + for (p = 0; p < lastp; p++) { + i = htbl->huffval[p]; + if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + dtbl->ehufco[i] = huffcode[p]; + dtbl->ehufsi[i] = huffsize[p]; + } +} + + +/* Outputting bytes to the file */ + +/* Emit a byte, taking 'action' if must suspend. */ +#define emit_byte(state,val,action) \ + { *(state)->next_output_byte++ = (JOCTET) (val); \ + if (--(state)->free_in_buffer == 0) \ + if (! dump_buffer(state)) \ + { action; } } + + +LOCAL(boolean) +dump_buffer (working_state * state) +/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ +{ + struct jpeg_destination_mgr * dest = state->cinfo->dest; + + if (! (*dest->empty_output_buffer) (state->cinfo)) + return FALSE; + /* After a successful buffer dump, must reset buffer pointers */ + state->next_output_byte = dest->next_output_byte; + state->free_in_buffer = dest->free_in_buffer; + return TRUE; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(boolean) +emit_bits (working_state * state, unsigned int code, int size) +/* Emit some bits; return TRUE if successful, FALSE if must suspend */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer = (INT32) code; + register int put_bits = state->cur.put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); + + put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte(state, c, return FALSE); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte(state, 0, return FALSE); + } + put_buffer <<= 8; + put_bits -= 8; + } + + state->cur.put_buffer = put_buffer; /* update state variables */ + state->cur.put_bits = put_bits; + + return TRUE; +} + + +LOCAL(boolean) +flush_bits (working_state * state) +{ + if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ + return FALSE; + state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ + state->cur.put_bits = 0; + return TRUE; +} + + +/* Encode a single block's worth of coefficients */ + +LOCAL(boolean) +encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, + c_derived_tbl *dctbl, c_derived_tbl *actbl) +{ + register int temp, temp2; + register int nbits; + register int k, r, i; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = temp2 = block[0] - last_dc_val; + + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); + + /* Emit the Huffman-coded symbol for the number of bits */ + if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + if (! emit_bits(state, (unsigned int) temp2, nbits)) + return FALSE; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k < DCTSIZE2; k++) { + if ((temp = block[jpeg_natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) + return FALSE; + r -= 16; + } + + temp2 = temp; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); + + /* Emit Huffman symbol for run length / number of bits */ + i = (r << 4) + nbits; + if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) + return FALSE; + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (! emit_bits(state, (unsigned int) temp2, nbits)) + return FALSE; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) + return FALSE; + + return TRUE; +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(boolean) +emit_restart (working_state * state, int restart_num) +{ + int ci; + + if (! flush_bits(state)) + return FALSE; + + emit_byte(state, 0xFF, return FALSE); + emit_byte(state, JPEG_RST0 + restart_num, return FALSE); + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) + state->cur.last_dc_val[ci] = 0; + + /* The restart counter is not updated until we successfully write the MCU. */ + + return TRUE; +} + + +/* + * Encode and output one MCU's worth of Huffman-compressed coefficients. + */ + +METHODDEF(boolean) +encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + int blkn, ci; + jpeg_component_info * compptr; + + /* Load up working state */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! emit_restart(&state, entropy->next_restart_num)) + return FALSE; + } + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + if (! encode_one_block(&state, + MCU_data[blkn][0], state.cur.last_dc_val[ci], + entropy->dc_derived_tbls[compptr->dc_tbl_no], + entropy->ac_derived_tbls[compptr->ac_tbl_no])) + return FALSE; + /* Update last_dc_val */ + state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + /* Completed MCU, so update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed scan. + */ + +METHODDEF(void) +finish_pass_huff (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + working_state state; + + /* Load up working state ... flush_bits needs it */ + state.next_output_byte = cinfo->dest->next_output_byte; + state.free_in_buffer = cinfo->dest->free_in_buffer; + ASSIGN_STATE(state.cur, entropy->saved); + state.cinfo = cinfo; + + /* Flush out the last data */ + if (! flush_bits(&state)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + + /* Update state */ + cinfo->dest->next_output_byte = state.next_output_byte; + cinfo->dest->free_in_buffer = state.free_in_buffer; + ASSIGN_STATE(entropy->saved, state.cur); +} + + +/* + * Huffman coding optimization. + * + * We first scan the supplied data and count the number of uses of each symbol + * that is to be Huffman-coded. (This process MUST agree with the code above.) + * Then we build a Huffman coding tree for the observed counts. + * Symbols which are not needed at all for the particular image are not + * assigned any code, which saves space in the DHT marker as well as in + * the compressed data. + */ + +#ifdef ENTROPY_OPT_SUPPORTED + + +/* Process a single block's worth of coefficients */ + +LOCAL(void) +htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, + long dc_counts[], long ac_counts[]) +{ + register int temp; + register int nbits; + register int k, r; + + /* Encode the DC coefficient difference per section F.1.2.1 */ + + temp = block[0] - last_dc_val; + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count the Huffman symbol for the number of bits */ + dc_counts[nbits]++; + + /* Encode the AC coefficients per section F.1.2.2 */ + + r = 0; /* r = run length of zeros */ + + for (k = 1; k < DCTSIZE2; k++) { + if ((temp = block[jpeg_natural_order[k]]) == 0) { + r++; + } else { + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + ac_counts[0xF0]++; + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + if (temp < 0) + temp = -temp; + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count Huffman symbol for run length / number of bits */ + ac_counts[(r << 4) + nbits]++; + + r = 0; + } + } + + /* If the last coef(s) were zero, emit an end-of-block code */ + if (r > 0) + ac_counts[0]++; +} + + +/* + * Trial-encode one MCU's worth of Huffman-compressed coefficients. + * No data is actually output, so no suspension return is possible. + */ + +METHODDEF(boolean) +encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn, ci; + jpeg_component_info * compptr; + + /* Take care of restart intervals if needed */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Update restart state */ + entropy->restarts_to_go = cinfo->restart_interval; + } + entropy->restarts_to_go--; + } + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], + entropy->dc_count_ptrs[compptr->dc_tbl_no], + entropy->ac_count_ptrs[compptr->ac_tbl_no]); + entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; + } + + return TRUE; +} + + +/* + * Generate the best Huffman code table for the given counts, fill htbl. + * Note this is also used by jcphuff.c. + * + * The JPEG standard requires that no symbol be assigned a codeword of all + * one bits (so that padding bits added at the end of a compressed segment + * can't look like a valid code). Because of the canonical ordering of + * codewords, this just means that there must be an unused slot in the + * longest codeword length category. Section K.2 of the JPEG spec suggests + * reserving such a slot by pretending that symbol 256 is a valid symbol + * with count 1. In theory that's not optimal; giving it count zero but + * including it in the symbol set anyway should give a better Huffman code. + * But the theoretically better code actually seems to come out worse in + * practice, because it produces more all-ones bytes (which incur stuffed + * zero bytes in the final file). In any case the difference is tiny. + * + * The JPEG standard requires Huffman codes to be no more than 16 bits long. + * If some symbols have a very small but nonzero probability, the Huffman tree + * must be adjusted to meet the code length restriction. We currently use + * the adjustment method suggested in JPEG section K.2. This method is *not* + * optimal; it may not choose the best possible limited-length code. But + * typically only very-low-frequency symbols will be given less-than-optimal + * lengths, so the code is almost optimal. Experimental comparisons against + * an optimal limited-length-code algorithm indicate that the difference is + * microscopic --- usually less than a hundredth of a percent of total size. + * So the extra complexity of an optimal algorithm doesn't seem worthwhile. + */ + +GLOBAL(void) +jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) +{ +#define MAX_CLEN 32 /* assumed maximum initial code length */ + UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ + int codesize[257]; /* codesize[k] = code length of symbol k */ + int others[257]; /* next symbol in current branch of tree */ + int c1, c2; + int p, i, j; + long v; + + /* This algorithm is explained in section K.2 of the JPEG standard */ + + MEMZERO(bits, SIZEOF(bits)); + MEMZERO(codesize, SIZEOF(codesize)); + for (i = 0; i < 257; i++) + others[i] = -1; /* init links to empty */ + + freq[256] = 1; /* make sure 256 has a nonzero count */ + /* Including the pseudo-symbol 256 in the Huffman procedure guarantees + * that no real symbol is given code-value of all ones, because 256 + * will be placed last in the largest codeword category. + */ + + /* Huffman's basic algorithm to assign optimal code lengths to symbols */ + + for (;;) { + /* Find the smallest nonzero frequency, set c1 = its symbol */ + /* In case of ties, take the larger symbol number */ + c1 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v) { + v = freq[i]; + c1 = i; + } + } + + /* Find the next smallest nonzero frequency, set c2 = its symbol */ + /* In case of ties, take the larger symbol number */ + c2 = -1; + v = 1000000000L; + for (i = 0; i <= 256; i++) { + if (freq[i] && freq[i] <= v && i != c1) { + v = freq[i]; + c2 = i; + } + } + + /* Done if we've merged everything into one frequency */ + if (c2 < 0) + break; + + /* Else merge the two counts/trees */ + freq[c1] += freq[c2]; + freq[c2] = 0; + + /* Increment the codesize of everything in c1's tree branch */ + codesize[c1]++; + while (others[c1] >= 0) { + c1 = others[c1]; + codesize[c1]++; + } + + others[c1] = c2; /* chain c2 onto c1's tree branch */ + + /* Increment the codesize of everything in c2's tree branch */ + codesize[c2]++; + while (others[c2] >= 0) { + c2 = others[c2]; + codesize[c2]++; + } + } + + /* Now count the number of symbols of each code length */ + for (i = 0; i <= 256; i++) { + if (codesize[i]) { + /* The JPEG standard seems to think that this can't happen, */ + /* but I'm paranoid... */ + if (codesize[i] > MAX_CLEN) + ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); + + bits[codesize[i]]++; + } + } + + /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure + * Huffman procedure assigned any such lengths, we must adjust the coding. + * Here is what the JPEG spec says about how this next bit works: + * Since symbols are paired for the longest Huffman code, the symbols are + * removed from this length category two at a time. The prefix for the pair + * (which is one bit shorter) is allocated to one of the pair; then, + * skipping the BITS entry for that prefix length, a code word from the next + * shortest nonzero BITS entry is converted into a prefix for two code words + * one bit longer. + */ + + for (i = MAX_CLEN; i > 16; i--) { + while (bits[i] > 0) { + j = i - 2; /* find length of new prefix to be used */ + while (bits[j] == 0) + j--; + + bits[i] -= 2; /* remove two symbols */ + bits[i-1]++; /* one goes in this length */ + bits[j+1] += 2; /* two new symbols in this length */ + bits[j]--; /* symbol of this length is now a prefix */ + } + } + + /* Remove the count for the pseudo-symbol 256 from the largest codelength */ + while (bits[i] == 0) /* find largest codelength still in use */ + i--; + bits[i]--; + + /* Return final symbol counts (only for lengths 0..16) */ + MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); + + /* Return a list of the symbols sorted by code length */ + /* It's not real clear to me why we don't need to consider the codelength + * changes made above, but the JPEG spec seems to think this works. + */ + p = 0; + for (i = 1; i <= MAX_CLEN; i++) { + for (j = 0; j <= 255; j++) { + if (codesize[j] == i) { + htbl->huffval[p] = (UINT8) j; + p++; + } + } + } + + /* Set sent_table FALSE so updated table will be written to JPEG file. */ + htbl->sent_table = FALSE; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, dctbl, actbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did_dc[NUM_HUFF_TBLS]; + boolean did_ac[NUM_HUFF_TBLS]; + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did_dc, SIZEOF(did_dc)); + MEMZERO(did_ac, SIZEOF(did_ac)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + if (! did_dc[dctbl]) { + htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); + did_dc[dctbl] = TRUE; + } + if (! did_ac[actbl]) { + htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); + did_ac[actbl] = TRUE; + } + } +} + + +#endif /* ENTROPY_OPT_SUPPORTED */ + + +/* + * Module initialization routine for Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_huff_encoder (j_compress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(huff_entropy_encoder)); + cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; + entropy->pub.start_pass = start_pass_huff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; +#ifdef ENTROPY_OPT_SUPPORTED + entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; +#endif + } +} diff --git a/libraries/external/jpeglib/jchuff.h b/libraries/external/jpeglib/jchuff.h new file mode 100755 index 0000000..8c02c09 --- /dev/null +++ b/libraries/external/jpeglib/jchuff.h @@ -0,0 +1,47 @@ +/* + * jchuff.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for Huffman entropy encoding routines + * that are shared between the sequential encoder (jchuff.c) and the + * progressive encoder (jcphuff.c). No other modules need to see these. + */ + +/* The legal range of a DCT coefficient is + * -1024 .. +1023 for 8-bit data; + * -16384 .. +16383 for 12-bit data. + * Hence the magnitude should always fit in 10 or 14 bits respectively. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MAX_COEF_BITS 10 +#else +#define MAX_COEF_BITS 14 +#endif + +/* Derived data constructed for each Huffman table */ + +typedef struct { + unsigned int ehufco[256]; /* code for each symbol */ + char ehufsi[256]; /* length of code for each symbol */ + /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ +} c_derived_tbl; + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_make_c_derived_tbl jMkCDerived +#define jpeg_gen_optimal_table jGenOptTbl +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Expand a Huffman table definition into the derived format */ +EXTERN(void) jpeg_make_c_derived_tbl + JPP((j_compress_ptr cinfo, boolean isDC, int tblno, + c_derived_tbl ** pdtbl)); + +/* Generate an optimal table definition given the specified counts */ +EXTERN(void) jpeg_gen_optimal_table + JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/libraries/external/jpeglib/jchuff.o b/libraries/external/jpeglib/jchuff.o new file mode 100644 index 0000000..dcf6eb2 Binary files /dev/null and b/libraries/external/jpeglib/jchuff.o differ diff --git a/libraries/external/jpeglib/jcinit.c b/libraries/external/jpeglib/jcinit.c new file mode 100755 index 0000000..19de8d0 --- /dev/null +++ b/libraries/external/jpeglib/jcinit.c @@ -0,0 +1,72 @@ +/* + * jcinit.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains initialization logic for the JPEG compressor. + * This routine is in charge of selecting the modules to be executed and + * making an initialization call to each one. + * + * Logically, this code belongs in jcmaster.c. It's split out because + * linking this routine implies linking the entire compression library. + * For a transcoding-only application, we want to be able to use jcmaster.c + * without linking in the whole library. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Master selection of compression modules. + * This is done once at the start of processing an image. We determine + * which modules will be used and give them appropriate initialization calls. + */ + +GLOBAL(void) +jinit_compress_master (j_compress_ptr cinfo) +{ + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, FALSE /* full compression */); + + /* Preprocessing */ + if (! cinfo->raw_data_in) { + jinit_color_converter(cinfo); + jinit_downsampler(cinfo); + jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); + } + /* Forward DCT */ + jinit_forward_dct(cinfo); + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + jinit_phuff_encoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_encoder(cinfo); + } + + /* Need a full-image coefficient buffer in any multi-pass mode. */ + jinit_c_coef_controller(cinfo, + (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); + jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} diff --git a/libraries/external/jpeglib/jcinit.o b/libraries/external/jpeglib/jcinit.o new file mode 100644 index 0000000..92d7092 Binary files /dev/null and b/libraries/external/jpeglib/jcinit.o differ diff --git a/libraries/external/jpeglib/jcmainct.c b/libraries/external/jpeglib/jcmainct.c new file mode 100755 index 0000000..14aa4c7 --- /dev/null +++ b/libraries/external/jpeglib/jcmainct.c @@ -0,0 +1,293 @@ +/* + * jcmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for compression. + * The main buffer lies between the pre-processor and the JPEG + * compressor proper; it holds downsampled data in the JPEG colorspace. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Note: currently, there is no operating mode in which a full-image buffer + * is needed at this step. If there were, that mode could not be used with + * "raw data" input, since this module is bypassed in that case. However, + * we've left the code here for possible use in special applications. + */ +#undef FULL_MAIN_BUFFER_SUPPORTED + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_main_controller pub; /* public fields */ + + JDIMENSION cur_iMCU_row; /* number of current iMCU row */ + JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ + boolean suspended; /* remember if we suspended output */ + J_BUF_MODE pass_mode; /* current operating mode */ + + /* If using just a strip buffer, this points to the entire set of buffers + * (we allocate one for each component). In the full-image case, this + * points to the currently accessible strips of the virtual arrays. + */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* If using full-image storage, this array holds pointers to virtual-array + * control blocks for each component. Unused if not full-image storage. + */ + jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; +#endif +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#ifdef FULL_MAIN_BUFFER_SUPPORTED +METHODDEF(void) process_data_buffer_main + JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + /* Do nothing in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + main->cur_iMCU_row = 0; /* initialize counters */ + main->rowgroup_ctr = 0; + main->suspended = FALSE; + main->pass_mode = pass_mode; /* save mode for use by process_data */ + + switch (pass_mode) { + case JBUF_PASS_THRU: +#ifdef FULL_MAIN_BUFFER_SUPPORTED + if (main->whole_image[0] != NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + main->pub.process_data = process_data_simple_main; + break; +#ifdef FULL_MAIN_BUFFER_SUPPORTED + case JBUF_SAVE_SOURCE: + case JBUF_CRANK_DEST: + case JBUF_SAVE_AND_PASS: + if (main->whole_image[0] == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + main->pub.process_data = process_data_buffer_main; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This routine handles the simple pass-through mode, + * where we have only a strip buffer. + */ + +METHODDEF(void) +process_data_simple_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Read input data if we haven't filled the main buffer yet */ + if (main->rowgroup_ctr < DCTSIZE) + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + main->buffer, &main->rowgroup_ctr, + (JDIMENSION) DCTSIZE); + + /* If we don't have a full iMCU row buffered, return to application for + * more data. Note that preprocessor will always pad to fill the iMCU row + * at the bottom of the image. + */ + if (main->rowgroup_ctr != DCTSIZE) + return; + + /* Send the completed row to the compressor */ + if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! main->suspended) { + (*in_row_ctr)--; + main->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (main->suspended) { + (*in_row_ctr)++; + main->suspended = FALSE; + } + main->rowgroup_ctr = 0; + main->cur_iMCU_row++; + } +} + + +#ifdef FULL_MAIN_BUFFER_SUPPORTED + +/* + * Process some data. + * This routine handles all of the modes that use a full-size buffer. + */ + +METHODDEF(void) +process_data_buffer_main (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci; + jpeg_component_info *compptr; + boolean writing = (main->pass_mode != JBUF_CRANK_DEST); + + while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { + /* Realign the virtual buffers if at the start of an iMCU row. */ + if (main->rowgroup_ctr == 0) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->buffer[ci] = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, main->whole_image[ci], + main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); + } + /* In a read pass, pretend we just read some source data. */ + if (! writing) { + *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; + main->rowgroup_ctr = DCTSIZE; + } + } + + /* If a write pass, read input data until the current iMCU row is full. */ + /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ + if (writing) { + (*cinfo->prep->pre_process_data) (cinfo, + input_buf, in_row_ctr, in_rows_avail, + main->buffer, &main->rowgroup_ctr, + (JDIMENSION) DCTSIZE); + /* Return to application if we need more data to fill the iMCU row. */ + if (main->rowgroup_ctr < DCTSIZE) + return; + } + + /* Emit data, unless this is a sink-only pass. */ + if (main->pass_mode != JBUF_SAVE_SOURCE) { + if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { + /* If compressor did not consume the whole row, then we must need to + * suspend processing and return to the application. In this situation + * we pretend we didn't yet consume the last input row; otherwise, if + * it happened to be the last row of the image, the application would + * think we were done. + */ + if (! main->suspended) { + (*in_row_ctr)--; + main->suspended = TRUE; + } + return; + } + /* We did finish the row. Undo our little suspension hack if a previous + * call suspended; then mark the main buffer empty. + */ + if (main->suspended) { + (*in_row_ctr)++; + main->suspended = FALSE; + } + } + + /* If get here, we are done with this iMCU row. Mark buffer empty. */ + main->rowgroup_ctr = 0; + main->cur_iMCU_row++; + } +} + +#endif /* FULL_MAIN_BUFFER_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr main; + int ci; + jpeg_component_info *compptr; + + main = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = (struct jpeg_c_main_controller *) main; + main->pub.start_pass = start_pass_main; + + /* We don't need to create a buffer in raw-data mode. */ + if (cinfo->raw_data_in) + return; + + /* Create the buffer. It holds downsampled data, so each component + * may be of a different size. + */ + if (need_full_buffer) { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + /* Allocate a full-image virtual array for each component */ + /* Note we pad the bottom to a multiple of the iMCU height */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor) * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); + } +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif + } else { +#ifdef FULL_MAIN_BUFFER_SUPPORTED + main->whole_image[0] = NULL; /* flag for no virtual arrays */ +#endif + /* Allocate a strip buffer for each component */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + main->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); + } + } +} diff --git a/libraries/external/jpeglib/jcmainct.o b/libraries/external/jpeglib/jcmainct.o new file mode 100644 index 0000000..7a23d33 Binary files /dev/null and b/libraries/external/jpeglib/jcmainct.o differ diff --git a/libraries/external/jpeglib/jcmarker.c b/libraries/external/jpeglib/jcmarker.c new file mode 100755 index 0000000..0d3ca5e --- /dev/null +++ b/libraries/external/jpeglib/jcmarker.c @@ -0,0 +1,664 @@ +/* + * jcmarker.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to write JPEG datastream markers. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* Private state */ + +typedef struct { + struct jpeg_marker_writer pub; /* public fields */ + + unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ +} my_marker_writer; + +typedef my_marker_writer * my_marker_ptr; + + +/* + * Basic output routines. + * + * Note that we do not support suspension while writing a marker. + * Therefore, an application using suspension must ensure that there is + * enough buffer space for the initial markers (typ. 600-700 bytes) before + * calling jpeg_start_compress, and enough space to write the trailing EOI + * (a few bytes) before calling jpeg_finish_compress. Multipass compression + * modes are not supported at all with suspension, so those two are the only + * points where markers will be written. + */ + +LOCAL(void) +emit_byte (j_compress_ptr cinfo, int val) +/* Emit a byte */ +{ + struct jpeg_destination_mgr * dest = cinfo->dest; + + *(dest->next_output_byte)++ = (JOCTET) val; + if (--dest->free_in_buffer == 0) { + if (! (*dest->empty_output_buffer) (cinfo)) + ERREXIT(cinfo, JERR_CANT_SUSPEND); + } +} + + +LOCAL(void) +emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) +/* Emit a marker code */ +{ + emit_byte(cinfo, 0xFF); + emit_byte(cinfo, (int) mark); +} + + +LOCAL(void) +emit_2bytes (j_compress_ptr cinfo, int value) +/* Emit a 2-byte integer; these are always MSB first in JPEG files */ +{ + emit_byte(cinfo, (value >> 8) & 0xFF); + emit_byte(cinfo, value & 0xFF); +} + + +/* + * Routines to write specific marker types. + */ + +LOCAL(int) +emit_dqt (j_compress_ptr cinfo, int index) +/* Emit a DQT marker */ +/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ +{ + JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; + int prec; + int i; + + if (qtbl == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); + + prec = 0; + for (i = 0; i < DCTSIZE2; i++) { + if (qtbl->quantval[i] > 255) + prec = 1; + } + + if (! qtbl->sent_table) { + emit_marker(cinfo, M_DQT); + + emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); + + emit_byte(cinfo, index + (prec<<4)); + + for (i = 0; i < DCTSIZE2; i++) { + /* The table entries must be emitted in zigzag order. */ + unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; + if (prec) + emit_byte(cinfo, (int) (qval >> 8)); + emit_byte(cinfo, (int) (qval & 0xFF)); + } + + qtbl->sent_table = TRUE; + } + + return prec; +} + + +LOCAL(void) +emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) +/* Emit a DHT marker */ +{ + JHUFF_TBL * htbl; + int length, i; + + if (is_ac) { + htbl = cinfo->ac_huff_tbl_ptrs[index]; + index += 0x10; /* output index has AC bit set */ + } else { + htbl = cinfo->dc_huff_tbl_ptrs[index]; + } + + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); + + if (! htbl->sent_table) { + emit_marker(cinfo, M_DHT); + + length = 0; + for (i = 1; i <= 16; i++) + length += htbl->bits[i]; + + emit_2bytes(cinfo, length + 2 + 1 + 16); + emit_byte(cinfo, index); + + for (i = 1; i <= 16; i++) + emit_byte(cinfo, htbl->bits[i]); + + for (i = 0; i < length; i++) + emit_byte(cinfo, htbl->huffval[i]); + + htbl->sent_table = TRUE; + } +} + + +LOCAL(void) +emit_dac (j_compress_ptr cinfo) +/* Emit a DAC marker */ +/* Since the useful info is so small, we want to emit all the tables in */ +/* one DAC marker. Therefore this routine does its own scan of the table. */ +{ +#ifdef C_ARITH_CODING_SUPPORTED + char dc_in_use[NUM_ARITH_TBLS]; + char ac_in_use[NUM_ARITH_TBLS]; + int length, i; + jpeg_component_info *compptr; + + for (i = 0; i < NUM_ARITH_TBLS; i++) + dc_in_use[i] = ac_in_use[i] = 0; + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + dc_in_use[compptr->dc_tbl_no] = 1; + ac_in_use[compptr->ac_tbl_no] = 1; + } + + length = 0; + for (i = 0; i < NUM_ARITH_TBLS; i++) + length += dc_in_use[i] + ac_in_use[i]; + + emit_marker(cinfo, M_DAC); + + emit_2bytes(cinfo, length*2 + 2); + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + if (dc_in_use[i]) { + emit_byte(cinfo, i); + emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); + } + if (ac_in_use[i]) { + emit_byte(cinfo, i + 0x10); + emit_byte(cinfo, cinfo->arith_ac_K[i]); + } + } +#endif /* C_ARITH_CODING_SUPPORTED */ +} + + +LOCAL(void) +emit_dri (j_compress_ptr cinfo) +/* Emit a DRI marker */ +{ + emit_marker(cinfo, M_DRI); + + emit_2bytes(cinfo, 4); /* fixed length */ + + emit_2bytes(cinfo, (int) cinfo->restart_interval); +} + + +LOCAL(void) +emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) +/* Emit a SOF marker */ +{ + int ci; + jpeg_component_info *compptr; + + emit_marker(cinfo, code); + + emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ + + /* Make sure image isn't bigger than SOF field can handle */ + if ((long) cinfo->image_height > 65535L || + (long) cinfo->image_width > 65535L) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); + + emit_byte(cinfo, cinfo->data_precision); + emit_2bytes(cinfo, (int) cinfo->image_height); + emit_2bytes(cinfo, (int) cinfo->image_width); + + emit_byte(cinfo, cinfo->num_components); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + emit_byte(cinfo, compptr->component_id); + emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); + emit_byte(cinfo, compptr->quant_tbl_no); + } +} + + +LOCAL(void) +emit_sos (j_compress_ptr cinfo) +/* Emit a SOS marker */ +{ + int i, td, ta; + jpeg_component_info *compptr; + + emit_marker(cinfo, M_SOS); + + emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ + + emit_byte(cinfo, cinfo->comps_in_scan); + + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + emit_byte(cinfo, compptr->component_id); + td = compptr->dc_tbl_no; + ta = compptr->ac_tbl_no; + if (cinfo->progressive_mode) { + /* Progressive mode: only DC or only AC tables are used in one scan; + * furthermore, Huffman coding of DC refinement uses no table at all. + * We emit 0 for unused field(s); this is recommended by the P&M text + * but does not seem to be specified in the standard. + */ + if (cinfo->Ss == 0) { + ta = 0; /* DC scan */ + if (cinfo->Ah != 0 && !cinfo->arith_code) + td = 0; /* no DC table either */ + } else { + td = 0; /* AC scan */ + } + } + emit_byte(cinfo, (td << 4) + ta); + } + + emit_byte(cinfo, cinfo->Ss); + emit_byte(cinfo, cinfo->Se); + emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); +} + + +LOCAL(void) +emit_jfif_app0 (j_compress_ptr cinfo) +/* Emit a JFIF-compliant APP0 marker */ +{ + /* + * Length of APP0 block (2 bytes) + * Block ID (4 bytes - ASCII "JFIF") + * Zero byte (1 byte to terminate the ID string) + * Version Major, Minor (2 bytes - major first) + * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) + * Xdpu (2 bytes - dots per unit horizontal) + * Ydpu (2 bytes - dots per unit vertical) + * Thumbnail X size (1 byte) + * Thumbnail Y size (1 byte) + */ + + emit_marker(cinfo, M_APP0); + + emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ + + emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0x49); + emit_byte(cinfo, 0x46); + emit_byte(cinfo, 0); + emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ + emit_byte(cinfo, cinfo->JFIF_minor_version); + emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ + emit_2bytes(cinfo, (int) cinfo->X_density); + emit_2bytes(cinfo, (int) cinfo->Y_density); + emit_byte(cinfo, 0); /* No thumbnail image */ + emit_byte(cinfo, 0); +} + + +LOCAL(void) +emit_adobe_app14 (j_compress_ptr cinfo) +/* Emit an Adobe APP14 marker */ +{ + /* + * Length of APP14 block (2 bytes) + * Block ID (5 bytes - ASCII "Adobe") + * Version Number (2 bytes - currently 100) + * Flags0 (2 bytes - currently 0) + * Flags1 (2 bytes - currently 0) + * Color transform (1 byte) + * + * Although Adobe TN 5116 mentions Version = 101, all the Adobe files + * now in circulation seem to use Version = 100, so that's what we write. + * + * We write the color transform byte as 1 if the JPEG color space is + * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with + * whether the encoder performed a transformation, which is pretty useless. + */ + + emit_marker(cinfo, M_APP14); + + emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ + + emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ + emit_byte(cinfo, 0x64); + emit_byte(cinfo, 0x6F); + emit_byte(cinfo, 0x62); + emit_byte(cinfo, 0x65); + emit_2bytes(cinfo, 100); /* Version */ + emit_2bytes(cinfo, 0); /* Flags0 */ + emit_2bytes(cinfo, 0); /* Flags1 */ + switch (cinfo->jpeg_color_space) { + case JCS_YCbCr: + emit_byte(cinfo, 1); /* Color transform = 1 */ + break; + case JCS_YCCK: + emit_byte(cinfo, 2); /* Color transform = 2 */ + break; + default: + emit_byte(cinfo, 0); /* Color transform = 0 */ + break; + } +} + + +/* + * These routines allow writing an arbitrary marker with parameters. + * The only intended use is to emit COM or APPn markers after calling + * write_file_header and before calling write_frame_header. + * Other uses are not guaranteed to produce desirable results. + * Counting the parameter bytes properly is the caller's responsibility. + */ + +METHODDEF(void) +write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) +/* Emit an arbitrary marker header */ +{ + if (datalen > (unsigned int) 65533) /* safety check */ + ERREXIT(cinfo, JERR_BAD_LENGTH); + + emit_marker(cinfo, (JPEG_MARKER) marker); + + emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ +} + +METHODDEF(void) +write_marker_byte (j_compress_ptr cinfo, int val) +/* Emit one byte of marker parameters following write_marker_header */ +{ + emit_byte(cinfo, val); +} + + +/* + * Write datastream header. + * This consists of an SOI and optional APPn markers. + * We recommend use of the JFIF marker, but not the Adobe marker, + * when using YCbCr or grayscale data. The JFIF marker should NOT + * be used for any other JPEG colorspace. The Adobe marker is helpful + * to distinguish RGB, CMYK, and YCCK colorspaces. + * Note that an application can write additional header markers after + * jpeg_start_compress returns. + */ + +METHODDEF(void) +write_file_header (j_compress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + emit_marker(cinfo, M_SOI); /* first the SOI */ + + /* SOI is defined to reset restart interval to 0 */ + marker->last_restart_interval = 0; + + if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ + emit_jfif_app0(cinfo); + if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ + emit_adobe_app14(cinfo); +} + + +/* + * Write frame header. + * This consists of DQT and SOFn markers. + * Note that we do not emit the SOF until we have emitted the DQT(s). + * This avoids compatibility problems with incorrect implementations that + * try to error-check the quant table numbers as soon as they see the SOF. + */ + +METHODDEF(void) +write_frame_header (j_compress_ptr cinfo) +{ + int ci, prec; + boolean is_baseline; + jpeg_component_info *compptr; + + /* Emit DQT for each quantization table. + * Note that emit_dqt() suppresses any duplicate tables. + */ + prec = 0; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prec += emit_dqt(cinfo, compptr->quant_tbl_no); + } + /* now prec is nonzero iff there are any 16-bit quant tables. */ + + /* Check for a non-baseline specification. + * Note we assume that Huffman table numbers won't be changed later. + */ + if (cinfo->arith_code || cinfo->progressive_mode || + cinfo->data_precision != 8) { + is_baseline = FALSE; + } else { + is_baseline = TRUE; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) + is_baseline = FALSE; + } + if (prec && is_baseline) { + is_baseline = FALSE; + /* If it's baseline except for quantizer size, warn the user */ + TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); + } + } + + /* Emit the proper SOF marker */ + if (cinfo->arith_code) { + emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ + } else { + if (cinfo->progressive_mode) + emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ + else if (is_baseline) + emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ + else + emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ + } +} + + +/* + * Write scan header. + * This consists of DHT or DAC markers, optional DRI, and SOS. + * Compressed data will be written following the SOS. + */ + +METHODDEF(void) +write_scan_header (j_compress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + int i; + jpeg_component_info *compptr; + + if (cinfo->arith_code) { + /* Emit arith conditioning info. We may have some duplication + * if the file has multiple scans, but it's so small it's hardly + * worth worrying about. + */ + emit_dac(cinfo); + } else { + /* Emit Huffman tables. + * Note that emit_dht() suppresses any duplicate tables. + */ + for (i = 0; i < cinfo->comps_in_scan; i++) { + compptr = cinfo->cur_comp_info[i]; + if (cinfo->progressive_mode) { + /* Progressive mode: only DC or only AC tables are used in one scan */ + if (cinfo->Ss == 0) { + if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + } else { + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } else { + /* Sequential mode: need both DC and AC tables */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } + } + } + + /* Emit DRI if required --- note that DRI value could change for each scan. + * We avoid wasting space with unnecessary DRIs, however. + */ + if (cinfo->restart_interval != marker->last_restart_interval) { + emit_dri(cinfo); + marker->last_restart_interval = cinfo->restart_interval; + } + + emit_sos(cinfo); +} + + +/* + * Write datastream trailer. + */ + +METHODDEF(void) +write_file_trailer (j_compress_ptr cinfo) +{ + emit_marker(cinfo, M_EOI); +} + + +/* + * Write an abbreviated table-specification datastream. + * This consists of SOI, DQT and DHT tables, and EOI. + * Any table that is defined and not marked sent_table = TRUE will be + * emitted. Note that all tables will be marked sent_table = TRUE at exit. + */ + +METHODDEF(void) +write_tables_only (j_compress_ptr cinfo) +{ + int i; + + emit_marker(cinfo, M_SOI); + + for (i = 0; i < NUM_QUANT_TBLS; i++) { + if (cinfo->quant_tbl_ptrs[i] != NULL) + (void) emit_dqt(cinfo, i); + } + + if (! cinfo->arith_code) { + for (i = 0; i < NUM_HUFF_TBLS; i++) { + if (cinfo->dc_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, FALSE); + if (cinfo->ac_huff_tbl_ptrs[i] != NULL) + emit_dht(cinfo, i, TRUE); + } + } + + emit_marker(cinfo, M_EOI); +} + + +/* + * Initialize the marker writer module. + */ + +GLOBAL(void) +jinit_marker_writer (j_compress_ptr cinfo) +{ + my_marker_ptr marker; + + /* Create the subobject */ + marker = (my_marker_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_marker_writer)); + cinfo->marker = (struct jpeg_marker_writer *) marker; + /* Initialize method pointers */ + marker->pub.write_file_header = write_file_header; + marker->pub.write_frame_header = write_frame_header; + marker->pub.write_scan_header = write_scan_header; + marker->pub.write_file_trailer = write_file_trailer; + marker->pub.write_tables_only = write_tables_only; + marker->pub.write_marker_header = write_marker_header; + marker->pub.write_marker_byte = write_marker_byte; + /* Initialize private state */ + marker->last_restart_interval = 0; +} diff --git a/libraries/external/jpeglib/jcmarker.o b/libraries/external/jpeglib/jcmarker.o new file mode 100644 index 0000000..8154917 Binary files /dev/null and b/libraries/external/jpeglib/jcmarker.o differ diff --git a/libraries/external/jpeglib/jcmaster.c b/libraries/external/jpeglib/jcmaster.c new file mode 100755 index 0000000..e61138b --- /dev/null +++ b/libraries/external/jpeglib/jcmaster.c @@ -0,0 +1,590 @@ +/* + * jcmaster.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG compressor. + * These routines are concerned with parameter validation, initial setup, + * and inter-pass control (determining the number of passes and the work + * to be done in each pass). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef enum { + main_pass, /* input data, also do first output step */ + huff_opt_pass, /* Huffman code optimization pass */ + output_pass /* data output pass */ +} c_pass_type; + +typedef struct { + struct jpeg_comp_master pub; /* public fields */ + + c_pass_type pass_type; /* the type of the current pass */ + + int pass_number; /* # of passes completed */ + int total_passes; /* total # of passes needed */ + + int scan_number; /* current index in scan_info[] */ +} my_comp_master; + +typedef my_comp_master * my_master_ptr; + + +/* + * Support routines that do various essential calculations. + */ + +LOCAL(void) +initial_setup (j_compress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ + int ci; + jpeg_component_info *compptr; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* Sanity check on image dimensions */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 + || cinfo->num_components <= 0 || cinfo->input_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* Width of an input scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Fill in the correct component_index value; don't rely on application */ + compptr->component_index = ci; + /* For compression, we never do DCT scaling. */ + compptr->DCT_scaled_size = DCTSIZE; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed (this flag isn't actually used for compression) */ + compptr->component_needed = TRUE; + } + + /* Compute number of fully interleaved MCU rows (number of times that + * main controller will call coefficient controller). + */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); +} + + +#ifdef C_MULTISCAN_FILES_SUPPORTED + +LOCAL(void) +validate_script (j_compress_ptr cinfo) +/* Verify that the scan script in cinfo->scan_info[] is valid; also + * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. + */ +{ + const jpeg_scan_info * scanptr; + int scanno, ncomps, ci, coefi, thisi; + int Ss, Se, Ah, Al; + boolean component_sent[MAX_COMPONENTS]; +#ifdef C_PROGRESSIVE_SUPPORTED + int * last_bitpos_ptr; + int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; + /* -1 until that coefficient has been seen; then last Al for it */ +#endif + + if (cinfo->num_scans <= 0) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); + + /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; + * for progressive JPEG, no scan can have this. + */ + scanptr = cinfo->scan_info; + if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { +#ifdef C_PROGRESSIVE_SUPPORTED + cinfo->progressive_mode = TRUE; + last_bitpos_ptr = & last_bitpos[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (coefi = 0; coefi < DCTSIZE2; coefi++) + *last_bitpos_ptr++ = -1; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + for (ci = 0; ci < cinfo->num_components; ci++) + component_sent[ci] = FALSE; + } + + for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { + /* Validate component indexes */ + ncomps = scanptr->comps_in_scan; + if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (thisi < 0 || thisi >= cinfo->num_components) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + /* Components must appear in SOF order within each scan */ + if (ci > 0 && thisi <= scanptr->component_index[ci-1]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + } + /* Validate progression parameters */ + Ss = scanptr->Ss; + Se = scanptr->Se; + Ah = scanptr->Ah; + Al = scanptr->Al; + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that + * seems wrong: the upper bound ought to depend on data precision. + * Perhaps they really meant 0..N+1 for N-bit precision. + * Here we allow 0..10 for 8-bit data; Al larger than 10 results in + * out-of-range reconstructed DC values during the first DC scan, + * which might cause problems for some decoders. + */ +#if BITS_IN_JSAMPLE == 8 +#define MAX_AH_AL 10 +#else +#define MAX_AH_AL 13 +#endif + if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || + Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + if (Ss == 0) { + if (Se != 0) /* DC and AC together not OK */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + if (ncomps != 1) /* AC scans must be for only one component */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + for (ci = 0; ci < ncomps; ci++) { + last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; + if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + for (coefi = Ss; coefi <= Se; coefi++) { + if (last_bitpos_ptr[coefi] < 0) { + /* first scan of this coefficient */ + if (Ah != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } else { + /* not first scan */ + if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + } + last_bitpos_ptr[coefi] = Al; + } + } +#endif + } else { + /* For sequential JPEG, all progression parameters must be these: */ + if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) + ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); + /* Make sure components are not sent twice */ + for (ci = 0; ci < ncomps; ci++) { + thisi = scanptr->component_index[ci]; + if (component_sent[thisi]) + ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); + component_sent[thisi] = TRUE; + } + } + } + + /* Now verify that everything got sent. */ + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + /* For progressive mode, we only check that at least some DC data + * got sent for each component; the spec does not require that all bits + * of all coefficients be transmitted. Would it be wiser to enforce + * transmission of all coefficient bits?? + */ + for (ci = 0; ci < cinfo->num_components; ci++) { + if (last_bitpos[ci][0] < 0) + ERREXIT(cinfo, JERR_MISSING_DATA); + } +#endif + } else { + for (ci = 0; ci < cinfo->num_components; ci++) { + if (! component_sent[ci]) + ERREXIT(cinfo, JERR_MISSING_DATA); + } + } +} + +#endif /* C_MULTISCAN_FILES_SUPPORTED */ + + +LOCAL(void) +select_scan_parameters (j_compress_ptr cinfo) +/* Set up the scan parameters for the current scan */ +{ + int ci; + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (cinfo->scan_info != NULL) { + /* Prepare for current scan --- the script is already validated */ + my_master_ptr master = (my_master_ptr) cinfo->master; + const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; + + cinfo->comps_in_scan = scanptr->comps_in_scan; + for (ci = 0; ci < scanptr->comps_in_scan; ci++) { + cinfo->cur_comp_info[ci] = + &cinfo->comp_info[scanptr->component_index[ci]]; + } + cinfo->Ss = scanptr->Ss; + cinfo->Se = scanptr->Se; + cinfo->Ah = scanptr->Ah; + cinfo->Al = scanptr->Al; + } + else +#endif + { + /* Prepare for single sequential-JPEG scan containing all components */ + if (cinfo->num_components > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPS_IN_SCAN); + cinfo->comps_in_scan = cinfo->num_components; + for (ci = 0; ci < cinfo->num_components; ci++) { + cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; + } + cinfo->Ss = 0; + cinfo->Se = DCTSIZE2-1; + cinfo->Ah = 0; + cinfo->Al = 0; + } +} + + +LOCAL(void) +per_scan_setup (j_compress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = DCTSIZE; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor*DCTSIZE)); + cinfo->MCU_rows_in_scan = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } + + /* Convert restart specified in rows to actual MCU count. */ + /* Note that count must fit in 16 bits, so we provide limiting. */ + if (cinfo->restart_in_rows > 0) { + long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; + cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); + } +} + + +/* + * Per-pass setup. + * This is called at the beginning of each pass. We determine which modules + * will be active during this pass and give them appropriate start_pass calls. + * We also set is_last_pass to indicate whether any more passes will be + * required. + */ + +METHODDEF(void) +prepare_for_pass (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + switch (master->pass_type) { + case main_pass: + /* Initial pass: will collect input data, and do either Huffman + * optimization or data output for the first scan. + */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (! cinfo->raw_data_in) { + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->downsample->start_pass) (cinfo); + (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); + } + (*cinfo->fdct->start_pass) (cinfo); + (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); + (*cinfo->coef->start_pass) (cinfo, + (master->total_passes > 1 ? + JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + if (cinfo->optimize_coding) { + /* No immediate data output; postpone writing frame/scan headers */ + master->pub.call_pass_startup = FALSE; + } else { + /* Will write frame/scan headers at first jpeg_write_scanlines call */ + master->pub.call_pass_startup = TRUE; + } + break; +#ifdef ENTROPY_OPT_SUPPORTED + case huff_opt_pass: + /* Do Huffman optimization for a scan after the first one. */ + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { + (*cinfo->entropy->start_pass) (cinfo, TRUE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + master->pub.call_pass_startup = FALSE; + break; + } + /* Special case: Huffman DC refinement scans need no Huffman table + * and therefore we can skip the optimization pass for them. + */ + master->pass_type = output_pass; + master->pass_number++; + /*FALLTHROUGH*/ +#endif + case output_pass: + /* Do a data-output pass. */ + /* We need not repeat per-scan setup if prior optimization pass did it. */ + if (! cinfo->optimize_coding) { + select_scan_parameters(cinfo); + per_scan_setup(cinfo); + } + (*cinfo->entropy->start_pass) (cinfo, FALSE); + (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); + /* We emit frame/scan headers now */ + if (master->scan_number == 0) + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); + master->pub.call_pass_startup = FALSE; + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + } + + master->pub.is_last_pass = (master->pass_number == master->total_passes-1); + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->total_passes; + } +} + + +/* + * Special start-of-pass hook. + * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. + * In single-pass processing, we need this hook because we don't want to + * write frame/scan headers during jpeg_start_compress; we want to let the + * application write COM markers etc. between jpeg_start_compress and the + * jpeg_write_scanlines loop. + * In multi-pass processing, this routine is not used. + */ + +METHODDEF(void) +pass_startup (j_compress_ptr cinfo) +{ + cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ + + (*cinfo->marker->write_frame_header) (cinfo); + (*cinfo->marker->write_scan_header) (cinfo); +} + + +/* + * Finish up at end of pass. + */ + +METHODDEF(void) +finish_pass_master (j_compress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* The entropy coder always needs an end-of-pass call, + * either to analyze statistics or to flush its output buffer. + */ + (*cinfo->entropy->finish_pass) (cinfo); + + /* Update state for next pass */ + switch (master->pass_type) { + case main_pass: + /* next pass is either output of scan 0 (after optimization) + * or output of scan 1 (if no optimization). + */ + master->pass_type = output_pass; + if (! cinfo->optimize_coding) + master->scan_number++; + break; + case huff_opt_pass: + /* next pass is always output of current scan */ + master->pass_type = output_pass; + break; + case output_pass: + /* next pass is either optimization or output of next scan */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + master->scan_number++; + break; + } + + master->pass_number++; +} + + +/* + * Initialize master compression control. + */ + +GLOBAL(void) +jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) +{ + my_master_ptr master; + + master = (my_master_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_comp_master)); + cinfo->master = (struct jpeg_comp_master *) master; + master->pub.prepare_for_pass = prepare_for_pass; + master->pub.pass_startup = pass_startup; + master->pub.finish_pass = finish_pass_master; + master->pub.is_last_pass = FALSE; + + /* Validate parameters, determine derived values */ + initial_setup(cinfo); + + if (cinfo->scan_info != NULL) { +#ifdef C_MULTISCAN_FILES_SUPPORTED + validate_script(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + cinfo->progressive_mode = FALSE; + cinfo->num_scans = 1; + } + + if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ + cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ + + /* Initialize my private state */ + if (transcode_only) { + /* no main pass in transcoding */ + if (cinfo->optimize_coding) + master->pass_type = huff_opt_pass; + else + master->pass_type = output_pass; + } else { + /* for normal compression, first pass is always this type: */ + master->pass_type = main_pass; + } + master->scan_number = 0; + master->pass_number = 0; + if (cinfo->optimize_coding) + master->total_passes = cinfo->num_scans * 2; + else + master->total_passes = cinfo->num_scans; +} diff --git a/libraries/external/jpeglib/jcmaster.o b/libraries/external/jpeglib/jcmaster.o new file mode 100644 index 0000000..a52e079 Binary files /dev/null and b/libraries/external/jpeglib/jcmaster.o differ diff --git a/libraries/external/jpeglib/jcomapi.c b/libraries/external/jpeglib/jcomapi.c new file mode 100755 index 0000000..1b1a340 --- /dev/null +++ b/libraries/external/jpeglib/jcomapi.c @@ -0,0 +1,106 @@ +/* + * jcomapi.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface routines that are used for both + * compression and decompression. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Abort processing of a JPEG compression or decompression operation, + * but don't destroy the object itself. + * + * For this, we merely clean up all the nonpermanent memory pools. + * Note that temp files (virtual arrays) are not allowed to belong to + * the permanent pool, so we will be able to close all temp files here. + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_abort (j_common_ptr cinfo) +{ + int pool; + + /* Do nothing if called on a not-initialized or destroyed JPEG object. */ + if (cinfo->mem == NULL) + return; + + /* Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { + (*cinfo->mem->free_pool) (cinfo, pool); + } + + /* Reset overall state for possible reuse of object */ + if (cinfo->is_decompressor) { + cinfo->global_state = DSTATE_START; + /* Try to keep application from accessing now-deleted marker list. + * A bit kludgy to do it here, but this is the most central place. + */ + ((j_decompress_ptr) cinfo)->marker_list = NULL; + } else { + cinfo->global_state = CSTATE_START; + } +} + + +/* + * Destruction of a JPEG object. + * + * Everything gets deallocated except the master jpeg_compress_struct itself + * and the error manager struct. Both of these are supplied by the application + * and must be freed, if necessary, by the application. (Often they are on + * the stack and so don't need to be freed anyway.) + * Closing a data source or destination, if necessary, is the application's + * responsibility. + */ + +GLOBAL(void) +jpeg_destroy (j_common_ptr cinfo) +{ + /* We need only tell the memory manager to release everything. */ + /* NB: mem pointer is NULL if memory mgr failed to initialize. */ + if (cinfo->mem != NULL) + (*cinfo->mem->self_destruct) (cinfo); + cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ + cinfo->global_state = 0; /* mark it destroyed */ +} + + +/* + * Convenience routines for allocating quantization and Huffman tables. + * (Would jutils.c be a more reasonable place to put these?) + */ + +GLOBAL(JQUANT_TBL *) +jpeg_alloc_quant_table (j_common_ptr cinfo) +{ + JQUANT_TBL *tbl; + + tbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} + + +GLOBAL(JHUFF_TBL *) +jpeg_alloc_huff_table (j_common_ptr cinfo) +{ + JHUFF_TBL *tbl; + + tbl = (JHUFF_TBL *) + (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); + tbl->sent_table = FALSE; /* make sure this is false in any new table */ + return tbl; +} diff --git a/libraries/external/jpeglib/jcomapi.o b/libraries/external/jpeglib/jcomapi.o new file mode 100644 index 0000000..dbf5d2a Binary files /dev/null and b/libraries/external/jpeglib/jcomapi.o differ diff --git a/libraries/external/jpeglib/jconfig.h b/libraries/external/jpeglib/jconfig.h new file mode 100755 index 0000000..2f4da14 --- /dev/null +++ b/libraries/external/jpeglib/jconfig.h @@ -0,0 +1,45 @@ +/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +/* Define "boolean" as unsigned char, not int, per Windows custom */ +#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +typedef unsigned char boolean; +#endif +#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ + + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#define TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Microsoft has setmode() */ +#undef NEED_SIGNAL_CATCHER +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/libraries/external/jpeglib/jcparam.c b/libraries/external/jpeglib/jcparam.c new file mode 100755 index 0000000..bbd175c --- /dev/null +++ b/libraries/external/jpeglib/jcparam.c @@ -0,0 +1,610 @@ +/* + * jcparam.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains optional default-setting code for the JPEG compressor. + * Applications do not have to use this file, but those that don't use it + * must know a lot more about the innards of the JPEG code. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Quantization table setup routines + */ + +GLOBAL(void) +jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, boolean force_baseline) +/* Define a quantization table equal to the basic_table times + * a scale factor (given as a percentage). + * If force_baseline is TRUE, the computed quantization table entries + * are limited to 1..255 for JPEG baseline compatibility. + */ +{ + JQUANT_TBL ** qtblptr; + int i; + long temp; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); + + qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; + + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); + + for (i = 0; i < DCTSIZE2; i++) { + temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; + /* limit the values to the valid range */ + if (temp <= 0L) temp = 1L; + if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ + if (force_baseline && temp > 255L) + temp = 255L; /* limit to baseline range if requested */ + (*qtblptr)->quantval[i] = (UINT16) temp; + } + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*qtblptr)->sent_table = FALSE; +} + + +GLOBAL(void) +jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, + boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables + * and a straight percentage-scaling quality scale. In most cases it's better + * to use jpeg_set_quality (below); this entry point is provided for + * applications that insist on a linear percentage scaling. + */ +{ + /* These are the sample quantization tables given in JPEG spec section K.1. + * The spec says that the values given produce "good" quality, and + * when divided by 2, "very good" quality. + */ + static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68, 109, 103, 77, + 24, 35, 55, 64, 81, 104, 113, 92, + 49, 64, 78, 87, 103, 121, 120, 101, + 72, 92, 95, 98, 112, 100, 103, 99 + }; + static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { + 17, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 + }; + + /* Set up two quantization tables using the specified scaling */ + jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, + scale_factor, force_baseline); + jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, + scale_factor, force_baseline); +} + + +GLOBAL(int) +jpeg_quality_scaling (int quality) +/* Convert a user-specified quality rating to a percentage scaling factor + * for an underlying quantization table, using our recommended scaling curve. + * The input 'quality' factor should be 0 (terrible) to 100 (very good). + */ +{ + /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ + if (quality <= 0) quality = 1; + if (quality > 100) quality = 100; + + /* The basic table is used as-is (scaling 100) for a quality of 50. + * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; + * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table + * to make all the table entries 1 (hence, minimum quantization loss). + * Qualities 1..50 are converted to scaling percentage 5000/Q. + */ + if (quality < 50) + quality = 5000 / quality; + else + quality = 200 - quality*2; + + return quality; +} + + +GLOBAL(void) +jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) +/* Set or change the 'quality' (quantization) setting, using default tables. + * This is the standard quality-adjusting entry point for typical user + * interfaces; only those who want detailed control over quantization tables + * would use the preceding three routines directly. + */ +{ + /* Convert user 0-100 rating to percentage scaling */ + quality = jpeg_quality_scaling(quality); + + /* Set up standard quality tables */ + jpeg_set_linear_quality(cinfo, quality, force_baseline); +} + + +/* + * Huffman table setup routines + */ + +LOCAL(void) +add_huff_table (j_compress_ptr cinfo, + JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) +/* Define a Huffman table */ +{ + int nsymbols, len; + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + /* Copy the number-of-symbols-of-each-code-length counts */ + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + + /* Validate the counts. We do this here mainly so we can copy the right + * number of symbols from the val[] array, without risking marching off + * the end of memory. jchuff.c will do a more thorough test later. + */ + nsymbols = 0; + for (len = 1; len <= 16; len++) + nsymbols += bits[len]; + if (nsymbols < 1 || nsymbols > 256) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*htblptr)->sent_table = FALSE; +} + + +LOCAL(void) +std_huff_tables (j_compress_ptr cinfo) +/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ +/* IMPORTANT: these are only valid for 8-bit data precision! */ +{ + static const UINT8 bits_dc_luminance[17] = + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_luminance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_dc_chrominance[17] = + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_chrominance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + static const UINT8 bits_ac_luminance[17] = + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const UINT8 val_ac_luminance[] = + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + static const UINT8 bits_ac_chrominance[17] = + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + static const UINT8 val_ac_chrominance[] = + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; + + add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], + bits_dc_luminance, val_dc_luminance); + add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], + bits_ac_luminance, val_ac_luminance); + add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], + bits_dc_chrominance, val_dc_chrominance); + add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], + bits_ac_chrominance, val_ac_chrominance); +} + + +/* + * Default parameter setup for compression. + * + * Applications that don't choose to use this routine must do their + * own setup of all these parameters. Alternately, you can call this + * to establish defaults and then alter parameters selectively. This + * is the recommended approach since, if we add any new parameters, + * your code will still work (they'll be set to reasonable defaults). + */ + +GLOBAL(void) +jpeg_set_defaults (j_compress_ptr cinfo) +{ + int i; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Allocate comp_info array large enough for maximum component count. + * Array is made permanent in case application wants to compress + * multiple images at same param settings. + */ + if (cinfo->comp_info == NULL) + cinfo->comp_info = (jpeg_component_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + MAX_COMPONENTS * SIZEOF(jpeg_component_info)); + + /* Initialize everything not dependent on the color space */ + + cinfo->data_precision = BITS_IN_JSAMPLE; + /* Set up two quantization tables using default quality of 75 */ + jpeg_set_quality(cinfo, 75, TRUE); + /* Set up two Huffman tables */ + std_huff_tables(cinfo); + + /* Initialize default arithmetic coding conditioning */ + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + + /* Default is no multiple-scan output */ + cinfo->scan_info = NULL; + cinfo->num_scans = 0; + + /* Expect normal source image, not raw downsampled data */ + cinfo->raw_data_in = FALSE; + + /* Use Huffman coding, not arithmetic coding, by default */ + cinfo->arith_code = FALSE; + + /* By default, don't do extra passes to optimize entropy coding */ + cinfo->optimize_coding = FALSE; + /* The standard Huffman tables are only valid for 8-bit data precision. + * If the precision is higher, force optimization on so that usable + * tables will be computed. This test can be removed if default tables + * are supplied that are valid for the desired precision. + */ + if (cinfo->data_precision > 8) + cinfo->optimize_coding = TRUE; + + /* By default, use the simpler non-cosited sampling alignment */ + cinfo->CCIR601_sampling = FALSE; + + /* No input smoothing */ + cinfo->smoothing_factor = 0; + + /* DCT algorithm preference */ + cinfo->dct_method = JDCT_DEFAULT; + + /* No restart markers */ + cinfo->restart_interval = 0; + cinfo->restart_in_rows = 0; + + /* Fill in default JFIF marker parameters. Note that whether the marker + * will actually be written is determined by jpeg_set_colorspace. + * + * By default, the library emits JFIF version code 1.01. + * An application that wants to emit JFIF 1.02 extension markers should set + * JFIF_minor_version to 2. We could probably get away with just defaulting + * to 1.02, but there may still be some decoders in use that will complain + * about that; saying 1.01 should minimize compatibility problems. + */ + cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ + cinfo->JFIF_minor_version = 1; + cinfo->density_unit = 0; /* Pixel size is unknown by default */ + cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ + cinfo->Y_density = 1; + + /* Choose JPEG colorspace based on input space, set defaults accordingly */ + + jpeg_default_colorspace(cinfo); +} + + +/* + * Select an appropriate JPEG colorspace for in_color_space. + */ + +GLOBAL(void) +jpeg_default_colorspace (j_compress_ptr cinfo) +{ + switch (cinfo->in_color_space) { + case JCS_GRAYSCALE: + jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); + break; + case JCS_RGB: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_YCbCr: + jpeg_set_colorspace(cinfo, JCS_YCbCr); + break; + case JCS_CMYK: + jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ + break; + case JCS_YCCK: + jpeg_set_colorspace(cinfo, JCS_YCCK); + break; + case JCS_UNKNOWN: + jpeg_set_colorspace(cinfo, JCS_UNKNOWN); + break; + default: + ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); + } +} + + +/* + * Set the JPEG colorspace, and choose colorspace-dependent default values. + */ + +GLOBAL(void) +jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) +{ + jpeg_component_info * compptr; + int ci; + +#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ + (compptr = &cinfo->comp_info[index], \ + compptr->component_id = (id), \ + compptr->h_samp_factor = (hsamp), \ + compptr->v_samp_factor = (vsamp), \ + compptr->quant_tbl_no = (quant), \ + compptr->dc_tbl_no = (dctbl), \ + compptr->ac_tbl_no = (actbl) ) + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* For all colorspaces, we use Q and Huff tables 0 for luminance components, + * tables 1 for chrominance components. + */ + + cinfo->jpeg_color_space = colorspace; + + cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ + cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ + + switch (colorspace) { + case JCS_GRAYSCALE: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 1; + /* JFIF specifies component ID 1 */ + SET_COMP(0, 1, 1,1, 0, 0,0); + break; + case JCS_RGB: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ + cinfo->num_components = 3; + SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); + SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); + SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); + break; + case JCS_YCbCr: + cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ + cinfo->num_components = 3; + /* JFIF specifies component IDs 1,2,3 */ + /* We default to 2x2 subsamples of chrominance */ + SET_COMP(0, 1, 2,2, 0, 0,0); + SET_COMP(1, 2, 1,1, 1, 1,1); + SET_COMP(2, 3, 1,1, 1, 1,1); + break; + case JCS_CMYK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ + cinfo->num_components = 4; + SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); + SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); + SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); + SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); + break; + case JCS_YCCK: + cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ + cinfo->num_components = 4; + SET_COMP(0, 1, 2,2, 0, 0,0); + SET_COMP(1, 2, 1,1, 1, 1,1); + SET_COMP(2, 3, 1,1, 1, 1,1); + SET_COMP(3, 4, 2,2, 0, 0,0); + break; + case JCS_UNKNOWN: + cinfo->num_components = cinfo->input_components; + if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + for (ci = 0; ci < cinfo->num_components; ci++) { + SET_COMP(ci, ci, 1,1, 0, 0,0); + } + break; + default: + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + } +} + + +#ifdef C_PROGRESSIVE_SUPPORTED + +LOCAL(jpeg_scan_info *) +fill_a_scan (jpeg_scan_info * scanptr, int ci, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for specified component */ +{ + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_scans (jpeg_scan_info * scanptr, int ncomps, + int Ss, int Se, int Ah, int Al) +/* Support routine: generate one scan for each component */ +{ + int ci; + + for (ci = 0; ci < ncomps; ci++) { + scanptr->comps_in_scan = 1; + scanptr->component_index[0] = ci; + scanptr->Ss = Ss; + scanptr->Se = Se; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } + return scanptr; +} + +LOCAL(jpeg_scan_info *) +fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) +/* Support routine: generate interleaved DC scan if possible, else N scans */ +{ + int ci; + + if (ncomps <= MAX_COMPS_IN_SCAN) { + /* Single interleaved DC scan */ + scanptr->comps_in_scan = ncomps; + for (ci = 0; ci < ncomps; ci++) + scanptr->component_index[ci] = ci; + scanptr->Ss = scanptr->Se = 0; + scanptr->Ah = Ah; + scanptr->Al = Al; + scanptr++; + } else { + /* Noninterleaved DC scan for each component */ + scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); + } + return scanptr; +} + + +/* + * Create a recommended progressive-JPEG script. + * cinfo->num_components and cinfo->jpeg_color_space must be correct. + */ + +GLOBAL(void) +jpeg_simple_progression (j_compress_ptr cinfo) +{ + int ncomps = cinfo->num_components; + int nscans; + jpeg_scan_info * scanptr; + + /* Safety check to ensure start_compress not called yet. */ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + /* Figure space needed for script. Calculation must match code below! */ + if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { + /* Custom script for YCbCr color images. */ + nscans = 10; + } else { + /* All-purpose script for other color spaces. */ + if (ncomps > MAX_COMPS_IN_SCAN) + nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ + else + nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ + } + + /* Allocate space for script. + * We need to put it in the permanent pool in case the application performs + * multiple compressions without changing the settings. To avoid a memory + * leak if jpeg_simple_progression is called repeatedly for the same JPEG + * object, we try to re-use previously allocated space, and we allocate + * enough space to handle YCbCr even if initially asked for grayscale. + */ + if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { + cinfo->script_space_size = MAX(nscans, 10); + cinfo->script_space = (jpeg_scan_info *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + cinfo->script_space_size * SIZEOF(jpeg_scan_info)); + } + scanptr = cinfo->script_space; + cinfo->scan_info = scanptr; + cinfo->num_scans = nscans; + + if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { + /* Custom script for YCbCr color images. */ + /* Initial DC scan */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + /* Initial AC scan: get some luma data out in a hurry */ + scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); + /* Chroma data is too small to be worth expending many scans on */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); + /* Complete spectral selection for luma AC */ + scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); + /* Refine next bit of luma AC */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); + /* Finish DC successive approximation */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + /* Finish AC successive approximation */ + scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); + scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); + /* Luma bottom bit comes last since it's usually largest scan */ + scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); + } else { + /* All-purpose script for other color spaces. */ + /* Successive approximation first pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); + scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); + scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); + /* Successive approximation second pass */ + scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); + /* Successive approximation final pass */ + scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); + scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); + } +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/libraries/external/jpeglib/jcparam.o b/libraries/external/jpeglib/jcparam.o new file mode 100644 index 0000000..a2b0392 Binary files /dev/null and b/libraries/external/jpeglib/jcparam.o differ diff --git a/libraries/external/jpeglib/jcphuff.c b/libraries/external/jpeglib/jcphuff.c new file mode 100755 index 0000000..a4ee850 --- /dev/null +++ b/libraries/external/jpeglib/jcphuff.c @@ -0,0 +1,833 @@ +/* + * jcphuff.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy encoding routines for progressive JPEG. + * + * We do not support output suspension in this module, since the library + * currently does not allow multiple-scan files to be written with output + * suspension. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jchuff.h" /* Declarations shared with jchuff.c */ + +#ifdef C_PROGRESSIVE_SUPPORTED + +/* Expanded entropy encoder object for progressive Huffman encoding. */ + +typedef struct { + struct jpeg_entropy_encoder pub; /* public fields */ + + /* Mode flag: TRUE for optimization, FALSE for actual data output */ + boolean gather_statistics; + + /* Bit-level coding status. + * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. + */ + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + INT32 put_buffer; /* current bit-accumulation buffer */ + int put_bits; /* # of bits now in it */ + j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ + + /* Coding status for DC components */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ + + /* Coding status for AC components */ + int ac_tbl_no; /* the table number of the single component */ + unsigned int EOBRUN; /* run length of EOBs */ + unsigned int BE; /* # of buffered correction bits before MCU */ + char * bit_buffer; /* buffer for correction bits (1 per char) */ + /* packing correction bits tightly would save some space but cost time... */ + + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + int next_restart_num; /* next restart number to write (0-7) */ + + /* Pointers to derived tables (these workspaces have image lifespan). + * Since any one scan codes only DC or only AC, we only need one set + * of tables, not one for DC and one for AC. + */ + c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + /* Statistics tables for optimization; again, one set is enough */ + long * count_ptrs[NUM_HUFF_TBLS]; +} phuff_entropy_encoder; + +typedef phuff_entropy_encoder * phuff_entropy_ptr; + +/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit + * buffer can hold. Larger sizes may slightly improve compression, but + * 1000 is already well into the realm of overkill. + * The minimum safe size is 64 bits. + */ + +#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ + +/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. + * We assume that int right shift is unsigned if INT32 right shift is, + * which should be safe. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS int ishift_temp; +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +/* Forward declarations */ +METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); +METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); + + +/* + * Initialize for a Huffman-compressed scan using progressive JPEG. + */ + +METHODDEF(void) +start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band; + int ci, tbl; + jpeg_component_info * compptr; + + entropy->cinfo = cinfo; + entropy->gather_statistics = gather_statistics; + + is_DC_band = (cinfo->Ss == 0); + + /* We assume jcmaster.c already validated the scan parameters. */ + + /* Select execution routines */ + if (cinfo->Ah == 0) { + if (is_DC_band) + entropy->pub.encode_mcu = encode_mcu_DC_first; + else + entropy->pub.encode_mcu = encode_mcu_AC_first; + } else { + if (is_DC_band) + entropy->pub.encode_mcu = encode_mcu_DC_refine; + else { + entropy->pub.encode_mcu = encode_mcu_AC_refine; + /* AC refinement needs a correction bit buffer */ + if (entropy->bit_buffer == NULL) + entropy->bit_buffer = (char *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + MAX_CORR_BITS * SIZEOF(char)); + } + } + if (gather_statistics) + entropy->pub.finish_pass = finish_pass_gather_phuff; + else + entropy->pub.finish_pass = finish_pass_phuff; + + /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 + * for AC coefficients. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Initialize DC predictions to 0 */ + entropy->last_dc_val[ci] = 0; + /* Get table index */ + if (is_DC_band) { + if (cinfo->Ah != 0) /* DC refinement needs no table */ + continue; + tbl = compptr->dc_tbl_no; + } else { + entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; + } + if (gather_statistics) { + /* Check for invalid table index */ + /* (make_c_derived_tbl does this in the other path) */ + if (tbl < 0 || tbl >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); + /* Allocate and zero the statistics tables */ + /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ + if (entropy->count_ptrs[tbl] == NULL) + entropy->count_ptrs[tbl] = (long *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 257 * SIZEOF(long)); + MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); + } else { + /* Compute derived values for Huffman table */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, + & entropy->derived_tbls[tbl]); + } + } + + /* Initialize AC stuff */ + entropy->EOBRUN = 0; + entropy->BE = 0; + + /* Initialize bit buffer to empty */ + entropy->put_buffer = 0; + entropy->put_bits = 0; + + /* Initialize restart stuff */ + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num = 0; +} + + +/* Outputting bytes to the file. + * NB: these must be called only when actually outputting, + * that is, entropy->gather_statistics == FALSE. + */ + +/* Emit a byte */ +#define emit_byte(entropy,val) \ + { *(entropy)->next_output_byte++ = (JOCTET) (val); \ + if (--(entropy)->free_in_buffer == 0) \ + dump_buffer(entropy); } + + +LOCAL(void) +dump_buffer (phuff_entropy_ptr entropy) +/* Empty the output buffer; we do not support suspension in this module. */ +{ + struct jpeg_destination_mgr * dest = entropy->cinfo->dest; + + if (! (*dest->empty_output_buffer) (entropy->cinfo)) + ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); + /* After a successful buffer dump, must reset buffer pointers */ + entropy->next_output_byte = dest->next_output_byte; + entropy->free_in_buffer = dest->free_in_buffer; +} + + +/* Outputting bits to the file */ + +/* Only the right 24 bits of put_buffer are used; the valid bits are + * left-justified in this part. At most 16 bits can be passed to emit_bits + * in one call, and we never retain more than 7 bits in put_buffer + * between calls, so 24 bits are sufficient. + */ + +INLINE +LOCAL(void) +emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) +/* Emit some bits, unless we are in gather mode */ +{ + /* This routine is heavily used, so it's worth coding tightly. */ + register INT32 put_buffer = (INT32) code; + register int put_bits = entropy->put_bits; + + /* if size is 0, caller used an invalid Huffman table entry */ + if (size == 0) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + if (entropy->gather_statistics) + return; /* do nothing if we're only getting stats */ + + put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ + + while (put_bits >= 8) { + int c = (int) ((put_buffer >> 16) & 0xFF); + + emit_byte(entropy, c); + if (c == 0xFF) { /* need to stuff a zero byte? */ + emit_byte(entropy, 0); + } + put_buffer <<= 8; + put_bits -= 8; + } + + entropy->put_buffer = put_buffer; /* update variables */ + entropy->put_bits = put_bits; +} + + +LOCAL(void) +flush_bits (phuff_entropy_ptr entropy) +{ + emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ + entropy->put_buffer = 0; /* and reset bit-buffer to empty */ + entropy->put_bits = 0; +} + + +/* + * Emit (or just count) a Huffman symbol. + */ + +INLINE +LOCAL(void) +emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) +{ + if (entropy->gather_statistics) + entropy->count_ptrs[tbl_no][symbol]++; + else { + c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; + emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); + } +} + + +/* + * Emit bits from a correction bit buffer. + */ + +LOCAL(void) +emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, + unsigned int nbits) +{ + if (entropy->gather_statistics) + return; /* no real work */ + + while (nbits > 0) { + emit_bits(entropy, (unsigned int) (*bufstart), 1); + bufstart++; + nbits--; + } +} + + +/* + * Emit any pending EOBRUN symbol. + */ + +LOCAL(void) +emit_eobrun (phuff_entropy_ptr entropy) +{ + register int temp, nbits; + + if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ + temp = entropy->EOBRUN; + nbits = 0; + while ((temp >>= 1)) + nbits++; + /* safety check: shouldn't happen given limited correction-bit buffer */ + if (nbits > 14) + ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); + + emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); + if (nbits) + emit_bits(entropy, entropy->EOBRUN, nbits); + + entropy->EOBRUN = 0; + + /* Emit any buffered correction bits */ + emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); + entropy->BE = 0; + } +} + + +/* + * Emit a restart marker & resynchronize predictions. + */ + +LOCAL(void) +emit_restart (phuff_entropy_ptr entropy, int restart_num) +{ + int ci; + + emit_eobrun(entropy); + + if (! entropy->gather_statistics) { + flush_bits(entropy); + emit_byte(entropy, 0xFF); + emit_byte(entropy, JPEG_RST0 + restart_num); + } + + if (entropy->cinfo->Ss == 0) { + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) + entropy->last_dc_val[ci] = 0; + } else { + /* Re-initialize all AC-related fields to 0 */ + entropy->EOBRUN = 0; + entropy->BE = 0; + } +} + + +/* + * MCU encoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + int blkn, ci; + int Al = cinfo->Al; + JBLOCKROW block; + jpeg_component_info * compptr; + ISHIFT_TEMPS + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + + /* Compute the DC value after the required point transform by Al. + * This is simply an arithmetic right shift. + */ + temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); + + /* DC differences are figured on the point-transformed values. */ + temp = temp2 - entropy->last_dc_val[ci]; + entropy->last_dc_val[ci] = temp2; + + /* Encode the DC coefficient difference per section G.1.2.1 */ + temp2 = temp; + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + /* For a negative input, want temp2 = bitwise complement of abs(input) */ + /* This code assumes we are on a two's complement machine */ + temp2--; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 0; + while (temp) { + nbits++; + temp >>= 1; + } + /* Check for out-of-range coefficient values. + * Since we're encoding a difference, the range limit is twice as much. + */ + if (nbits > MAX_COEF_BITS+1) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count/emit the Huffman-coded symbol for the number of bits */ + emit_symbol(entropy, compptr->dc_tbl_no, nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + if (nbits) /* emit_bits rejects calls with size 0 */ + emit_bits(entropy, (unsigned int) temp2, nbits); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp, temp2; + register int nbits; + register int r, k; + int Se = cinfo->Se; + int Al = cinfo->Al; + JBLOCKROW block; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ + + r = 0; /* r = run length of zeros */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { + r++; + continue; + } + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value; so the code is + * interwoven with finding the abs value (temp) and output bits (temp2). + */ + if (temp < 0) { + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ + temp2 = ~temp; + } else { + temp >>= Al; /* apply the point transform */ + temp2 = temp; + } + /* Watch out for case that nonzero coef is zero after point transform */ + if (temp == 0) { + r++; + continue; + } + + /* Emit any pending EOBRUN */ + if (entropy->EOBRUN > 0) + emit_eobrun(entropy); + /* if run length > 15, must emit special run-length-16 codes (0xF0) */ + while (r > 15) { + emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + } + + /* Find the number of bits needed for the magnitude of the coefficient */ + nbits = 1; /* there must be at least one 1 bit */ + while ((temp >>= 1)) + nbits++; + /* Check for out-of-range coefficient values */ + if (nbits > MAX_COEF_BITS) + ERREXIT(cinfo, JERR_BAD_DCT_COEF); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); + + /* Emit that number of bits of the value, if positive, */ + /* or the complement of its magnitude, if negative. */ + emit_bits(entropy, (unsigned int) temp2, nbits); + + r = 0; /* reset zero run length */ + } + + if (r > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + if (entropy->EOBRUN == 0x7FFF) + emit_eobrun(entropy); /* force it out to avoid overflow */ + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, although the spec + * is not very clear on the point. + */ + +METHODDEF(boolean) +encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp; + int blkn; + int Al = cinfo->Al; + JBLOCKROW block; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data blocks */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + + /* We simply emit the Al'th bit of the DC coefficient value. */ + temp = (*block)[0]; + emit_bits(entropy, (unsigned int) (temp >> Al), 1); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * MCU encoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + register int temp; + register int r, k; + int EOB; + char *BR_buffer; + unsigned int BR; + int Se = cinfo->Se; + int Al = cinfo->Al; + JBLOCKROW block; + int absvalues[DCTSIZE2]; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Emit restart marker if needed */ + if (cinfo->restart_interval) + if (entropy->restarts_to_go == 0) + emit_restart(entropy, entropy->next_restart_num); + + /* Encode the MCU data block */ + block = MCU_data[0]; + + /* It is convenient to make a pre-pass to determine the transformed + * coefficients' absolute values and the EOB position. + */ + EOB = 0; + for (k = cinfo->Ss; k <= Se; k++) { + temp = (*block)[jpeg_natural_order[k]]; + /* We must apply the point transform by Al. For AC coefficients this + * is an integer division with rounding towards 0. To do this portably + * in C, we shift after obtaining the absolute value. + */ + if (temp < 0) + temp = -temp; /* temp is abs value of input */ + temp >>= Al; /* apply the point transform */ + absvalues[k] = temp; /* save abs value for main pass */ + if (temp == 1) + EOB = k; /* EOB = index of last newly-nonzero coef */ + } + + /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ + + r = 0; /* r = run length of zeros */ + BR = 0; /* BR = count of buffered bits added now */ + BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ + + for (k = cinfo->Ss; k <= Se; k++) { + if ((temp = absvalues[k]) == 0) { + r++; + continue; + } + + /* Emit any required ZRLs, but not if they can be folded into EOB */ + while (r > 15 && k <= EOB) { + /* emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + /* Emit ZRL */ + emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); + r -= 16; + /* Emit buffered correction bits that must be associated with ZRL */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + } + + /* If the coef was previously nonzero, it only needs a correction bit. + * NOTE: a straight translation of the spec's figure G.7 would suggest + * that we also need to test r > 15. But if r > 15, we can only get here + * if k > EOB, which implies that this coefficient is not 1. + */ + if (temp > 1) { + /* The correction bit is the next bit of the absolute value. */ + BR_buffer[BR++] = (char) (temp & 1); + continue; + } + + /* Emit any pending EOBRUN and the BE correction bits */ + emit_eobrun(entropy); + + /* Count/emit Huffman symbol for run length / number of bits */ + emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); + + /* Emit output bit for newly-nonzero coef */ + temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; + emit_bits(entropy, (unsigned int) temp, 1); + + /* Emit buffered correction bits that must be associated with this code */ + emit_buffered_bits(entropy, BR_buffer, BR); + BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ + BR = 0; + r = 0; /* reset zero run length */ + } + + if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ + entropy->EOBRUN++; /* count an EOB */ + entropy->BE += BR; /* concat my correction bits to older ones */ + /* We force out the EOB if we risk either: + * 1. overflow of the EOB counter; + * 2. overflow of the correction bit buffer during the next MCU. + */ + if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) + emit_eobrun(entropy); + } + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; + + /* Update restart-interval state too */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) { + entropy->restarts_to_go = cinfo->restart_interval; + entropy->next_restart_num++; + entropy->next_restart_num &= 7; + } + entropy->restarts_to_go--; + } + + return TRUE; +} + + +/* + * Finish up at the end of a Huffman-compressed progressive scan. + */ + +METHODDEF(void) +finish_pass_phuff (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + + entropy->next_output_byte = cinfo->dest->next_output_byte; + entropy->free_in_buffer = cinfo->dest->free_in_buffer; + + /* Flush out any buffered data */ + emit_eobrun(entropy); + flush_bits(entropy); + + cinfo->dest->next_output_byte = entropy->next_output_byte; + cinfo->dest->free_in_buffer = entropy->free_in_buffer; +} + + +/* + * Finish up a statistics-gathering pass and create the new Huffman tables. + */ + +METHODDEF(void) +finish_pass_gather_phuff (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band; + int ci, tbl; + jpeg_component_info * compptr; + JHUFF_TBL **htblptr; + boolean did[NUM_HUFF_TBLS]; + + /* Flush out buffered data (all we care about is counting the EOB symbol) */ + emit_eobrun(entropy); + + is_DC_band = (cinfo->Ss == 0); + + /* It's important not to apply jpeg_gen_optimal_table more than once + * per table, because it clobbers the input frequency counts! + */ + MEMZERO(did, SIZEOF(did)); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + if (is_DC_band) { + if (cinfo->Ah != 0) /* DC refinement needs no table */ + continue; + tbl = compptr->dc_tbl_no; + } else { + tbl = compptr->ac_tbl_no; + } + if (! did[tbl]) { + if (is_DC_band) + htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; + else + htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); + did[tbl] = TRUE; + } + } +} + + +/* + * Module initialization routine for progressive Huffman entropy encoding. + */ + +GLOBAL(void) +jinit_phuff_encoder (j_compress_ptr cinfo) +{ + phuff_entropy_ptr entropy; + int i; + + entropy = (phuff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(phuff_entropy_encoder)); + cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; + entropy->pub.start_pass = start_pass_phuff; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + entropy->count_ptrs[i] = NULL; + } + entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ +} + +#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/libraries/external/jpeglib/jcphuff.o b/libraries/external/jpeglib/jcphuff.o new file mode 100644 index 0000000..782cca4 Binary files /dev/null and b/libraries/external/jpeglib/jcphuff.o differ diff --git a/libraries/external/jpeglib/jcprepct.c b/libraries/external/jpeglib/jcprepct.c new file mode 100755 index 0000000..fdc4bc2 --- /dev/null +++ b/libraries/external/jpeglib/jcprepct.c @@ -0,0 +1,354 @@ +/* + * jcprepct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the compression preprocessing controller. + * This controller manages the color conversion, downsampling, + * and edge expansion steps. + * + * Most of the complexity here is associated with buffering input rows + * as required by the downsampler. See the comments at the head of + * jcsample.c for the downsampler's needs. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* At present, jcsample.c can request context rows only for smoothing. + * In the future, we might also need context rows for CCIR601 sampling + * or other more-complex downsampling procedures. The code to support + * context rows should be compiled only if needed. + */ +#ifdef INPUT_SMOOTHING_SUPPORTED +#define CONTEXT_ROWS_SUPPORTED +#endif + + +/* + * For the simple (no-context-row) case, we just need to buffer one + * row group's worth of pixels for the downsampling step. At the bottom of + * the image, we pad to a full row group by replicating the last pixel row. + * The downsampler's last output row is then replicated if needed to pad + * out to a full iMCU row. + * + * When providing context rows, we must buffer three row groups' worth of + * pixels. Three row groups are physically allocated, but the row pointer + * arrays are made five row groups high, with the extra pointers above and + * below "wrapping around" to point to the last and first real row groups. + * This allows the downsampler to access the proper context rows. + * At the top and bottom of the image, we create dummy context rows by + * copying the first or last real pixel row. This copying could be avoided + * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the + * trouble on the compression side. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_prep_controller pub; /* public fields */ + + /* Downsampling input buffer. This buffer holds color-converted data + * until we have enough to do a downsample step. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + JDIMENSION rows_to_go; /* counts rows remaining in source image */ + int next_buf_row; /* index of next row to store in color_buf */ + +#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ + int this_row_group; /* starting row index of group to process */ + int next_buf_stop; /* downsample when we reach this index */ +#endif +} my_prep_controller; + +typedef my_prep_controller * my_prep_ptr; + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + + if (pass_mode != JBUF_PASS_THRU) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Initialize total-height counter for detecting bottom of image */ + prep->rows_to_go = cinfo->image_height; + /* Mark the conversion buffer empty */ + prep->next_buf_row = 0; +#ifdef CONTEXT_ROWS_SUPPORTED + /* Preset additional state variables for context mode. + * These aren't used in non-context mode, so we needn't test which mode. + */ + prep->this_row_group = 0; + /* Set next_buf_stop to stop after two row groups have been read in. */ + prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; +#endif +} + + +/* + * Expand an image vertically from height input_rows to height output_rows, + * by duplicating the bottom row. + */ + +LOCAL(void) +expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, + int input_rows, int output_rows) +{ + register int row; + + for (row = input_rows; row < output_rows; row++) { + jcopy_sample_rows(image_data, input_rows-1, image_data, row, + 1, num_cols); + } +} + + +/* + * Process some data in the simple no-context case. + * + * Preprocessor output data is counted in "row groups". A row group + * is defined to be v_samp_factor sample rows of each component. + * Downsampling will produce this much data from each max_v_samp_factor + * input rows. + */ + +METHODDEF(void) +pre_process_data (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + JDIMENSION inrows; + jpeg_component_info * compptr; + + while (*in_row_ctr < in_rows_avail && + *out_row_group_ctr < out_row_groups_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = cinfo->max_v_samp_factor - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + /* If at bottom of image, pad to fill the conversion buffer. */ + if (prep->rows_to_go == 0 && + prep->next_buf_row < cinfo->max_v_samp_factor) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, cinfo->max_v_samp_factor); + } + prep->next_buf_row = cinfo->max_v_samp_factor; + } + /* If we've filled the conversion buffer, empty it. */ + if (prep->next_buf_row == cinfo->max_v_samp_factor) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, (JDIMENSION) 0, + output_buf, *out_row_group_ctr); + prep->next_buf_row = 0; + (*out_row_group_ctr)++; + } + /* If at bottom of image, pad the output to a full iMCU height. + * Note we assume the caller is providing a one-iMCU-height output buffer! + */ + if (prep->rows_to_go == 0 && + *out_row_group_ctr < out_row_groups_avail) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + expand_bottom_edge(output_buf[ci], + compptr->width_in_blocks * DCTSIZE, + (int) (*out_row_group_ctr * compptr->v_samp_factor), + (int) (out_row_groups_avail * compptr->v_samp_factor)); + } + *out_row_group_ctr = out_row_groups_avail; + break; /* can exit outer loop without test */ + } + } +} + + +#ifdef CONTEXT_ROWS_SUPPORTED + +/* + * Process some data in the context case. + */ + +METHODDEF(void) +pre_process_context (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int numrows, ci; + int buf_height = cinfo->max_v_samp_factor * 3; + JDIMENSION inrows; + + while (*out_row_group_ctr < out_row_groups_avail) { + if (*in_row_ctr < in_rows_avail) { + /* Do color conversion to fill the conversion buffer. */ + inrows = in_rows_avail - *in_row_ctr; + numrows = prep->next_buf_stop - prep->next_buf_row; + numrows = (int) MIN((JDIMENSION) numrows, inrows); + (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, + prep->color_buf, + (JDIMENSION) prep->next_buf_row, + numrows); + /* Pad at top of image, if first time through */ + if (prep->rows_to_go == cinfo->image_height) { + for (ci = 0; ci < cinfo->num_components; ci++) { + int row; + for (row = 1; row <= cinfo->max_v_samp_factor; row++) { + jcopy_sample_rows(prep->color_buf[ci], 0, + prep->color_buf[ci], -row, + 1, cinfo->image_width); + } + } + } + *in_row_ctr += numrows; + prep->next_buf_row += numrows; + prep->rows_to_go -= numrows; + } else { + /* Return for more data, unless we are at the bottom of the image. */ + if (prep->rows_to_go != 0) + break; + /* When at bottom of image, pad to fill the conversion buffer. */ + if (prep->next_buf_row < prep->next_buf_stop) { + for (ci = 0; ci < cinfo->num_components; ci++) { + expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, + prep->next_buf_row, prep->next_buf_stop); + } + prep->next_buf_row = prep->next_buf_stop; + } + } + /* If we've gotten enough data, downsample a row group. */ + if (prep->next_buf_row == prep->next_buf_stop) { + (*cinfo->downsample->downsample) (cinfo, + prep->color_buf, + (JDIMENSION) prep->this_row_group, + output_buf, *out_row_group_ctr); + (*out_row_group_ctr)++; + /* Advance pointers with wraparound as necessary. */ + prep->this_row_group += cinfo->max_v_samp_factor; + if (prep->this_row_group >= buf_height) + prep->this_row_group = 0; + if (prep->next_buf_row >= buf_height) + prep->next_buf_row = 0; + prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; + } + } +} + + +/* + * Create the wrapped-around downsampling input buffer needed for context mode. + */ + +LOCAL(void) +create_context_buffer (j_compress_ptr cinfo) +{ + my_prep_ptr prep = (my_prep_ptr) cinfo->prep; + int rgroup_height = cinfo->max_v_samp_factor; + int ci, i; + jpeg_component_info * compptr; + JSAMPARRAY true_buffer, fake_buffer; + + /* Grab enough space for fake row pointers for all the components; + * we need five row groups' worth of pointers for each component. + */ + fake_buffer = (JSAMPARRAY) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (cinfo->num_components * 5 * rgroup_height) * + SIZEOF(JSAMPROW)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate the actual buffer space (3 row groups) for this component. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + true_buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) (3 * rgroup_height)); + /* Copy true buffer row pointers into the middle of the fake row array */ + MEMCOPY(fake_buffer + rgroup_height, true_buffer, + 3 * rgroup_height * SIZEOF(JSAMPROW)); + /* Fill in the above and below wraparound pointers */ + for (i = 0; i < rgroup_height; i++) { + fake_buffer[i] = true_buffer[2 * rgroup_height + i]; + fake_buffer[4 * rgroup_height + i] = true_buffer[i]; + } + prep->color_buf[ci] = fake_buffer + rgroup_height; + fake_buffer += 5 * rgroup_height; /* point to space for next component */ + } +} + +#endif /* CONTEXT_ROWS_SUPPORTED */ + + +/* + * Initialize preprocessing controller. + */ + +GLOBAL(void) +jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) +{ + my_prep_ptr prep; + int ci; + jpeg_component_info * compptr; + + if (need_full_buffer) /* safety check */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + prep = (my_prep_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_prep_controller)); + cinfo->prep = (struct jpeg_c_prep_controller *) prep; + prep->pub.start_pass = start_pass_prep; + + /* Allocate the color conversion buffer. + * We make the buffer wide enough to allow the downsampler to edge-expand + * horizontally within the buffer, if it so chooses. + */ + if (cinfo->downsample->need_context_rows) { + /* Set up to provide context rows */ +#ifdef CONTEXT_ROWS_SUPPORTED + prep->pub.pre_process_data = pre_process_context; + create_context_buffer(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* No context, just make it tall enough for one row group */ + prep->pub.pre_process_data = pre_process_data; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * + cinfo->max_h_samp_factor) / compptr->h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/libraries/external/jpeglib/jcprepct.o b/libraries/external/jpeglib/jcprepct.o new file mode 100644 index 0000000..5f67c29 Binary files /dev/null and b/libraries/external/jpeglib/jcprepct.o differ diff --git a/libraries/external/jpeglib/jcsample.c b/libraries/external/jpeglib/jcsample.c new file mode 100755 index 0000000..fe29fca --- /dev/null +++ b/libraries/external/jpeglib/jcsample.c @@ -0,0 +1,519 @@ +/* + * jcsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains downsampling routines. + * + * Downsampling input data is counted in "row groups". A row group + * is defined to be max_v_samp_factor pixel rows of each component, + * from which the downsampler produces v_samp_factor sample rows. + * A single row group is processed in each call to the downsampler module. + * + * The downsampler is responsible for edge-expansion of its output data + * to fill an integral number of DCT blocks horizontally. The source buffer + * may be modified if it is helpful for this purpose (the source buffer is + * allocated wide enough to correspond to the desired output width). + * The caller (the prep controller) is responsible for vertical padding. + * + * The downsampler may request "context rows" by setting need_context_rows + * during startup. In this case, the input arrays will contain at least + * one row group's worth of pixels above and below the passed-in data; + * the caller will create dummy rows at image top and bottom by replicating + * the first or last real pixel row. + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + * + * The downsampling algorithm used here is a simple average of the source + * pixels covered by the output pixel. The hi-falutin sampling literature + * refers to this as a "box filter". In general the characteristics of a box + * filter are not very good, but for the specific cases we normally use (1:1 + * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not + * nearly so bad. If you intend to use other sampling ratios, you'd be well + * advised to improve this code. + * + * A simple input-smoothing capability is provided. This is mainly intended + * for cleaning up color-dithered GIF input files (if you find it inadequate, + * we suggest using an external filtering program such as pnmconvol). When + * enabled, each input pixel P is replaced by a weighted sum of itself and its + * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, + * where SF = (smoothing_factor / 1024). + * Currently, smoothing is only supported for 2h2v sampling factors. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to downsample a single component */ +typedef JMETHOD(void, downsample1_ptr, + (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data)); + +/* Private subobject */ + +typedef struct { + struct jpeg_downsampler pub; /* public fields */ + + /* Downsampling method pointers, one per component */ + downsample1_ptr methods[MAX_COMPONENTS]; +} my_downsampler; + +typedef my_downsampler * my_downsample_ptr; + + +/* + * Initialize for a downsampling pass. + */ + +METHODDEF(void) +start_pass_downsample (j_compress_ptr cinfo) +{ + /* no work for now */ +} + + +/* + * Expand a component horizontally from width input_cols to width output_cols, + * by duplicating the rightmost samples. + */ + +LOCAL(void) +expand_right_edge (JSAMPARRAY image_data, int num_rows, + JDIMENSION input_cols, JDIMENSION output_cols) +{ + register JSAMPROW ptr; + register JSAMPLE pixval; + register int count; + int row; + int numcols = (int) (output_cols - input_cols); + + if (numcols > 0) { + for (row = 0; row < num_rows; row++) { + ptr = image_data[row] + input_cols; + pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ + for (count = numcols; count > 0; count--) + *ptr++ = pixval; + } + } +} + + +/* + * Do downsampling for a whole row group (all components). + * + * In this version we simply downsample each component independently. + */ + +METHODDEF(void) +sep_downsample (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) +{ + my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; + int ci; + jpeg_component_info * compptr; + JSAMPARRAY in_ptr, out_ptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + in_ptr = input_buf[ci] + in_row_index; + out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); + (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); + } +} + + +/* + * Downsample pixel values of a single component. + * One row group is processed per call. + * This version handles arbitrary integral sampling ratios, without smoothing. + * Note that this version is not actually used for customary sampling ratios. + */ + +METHODDEF(void) +int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; + JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + JSAMPROW inptr, outptr; + INT32 outvalue; + + h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; + v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; + numpix = h_expand * v_expand; + numpix2 = numpix/2; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * h_expand); + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + for (outcol = 0, outcol_h = 0; outcol < output_cols; + outcol++, outcol_h += h_expand) { + outvalue = 0; + for (v = 0; v < v_expand; v++) { + inptr = input_data[inrow+v] + outcol_h; + for (h = 0; h < h_expand; h++) { + outvalue += (INT32) GETJSAMPLE(*inptr++); + } + } + *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); + } + inrow += v_expand; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * without smoothing. + */ + +METHODDEF(void) +fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + /* Copy the data */ + jcopy_sample_rows(input_data, 0, output_data, 0, + cinfo->max_v_samp_factor, cinfo->image_width); + /* Edge-expand */ + expand_right_edge(output_data, cinfo->max_v_samp_factor, + cinfo->image_width, compptr->width_in_blocks * DCTSIZE); +} + + +/* + * Downsample pixel values of a single component. + * This version handles the common case of 2:1 horizontal and 1:1 vertical, + * without smoothing. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr = input_data[outrow]; + bias = 0; /* bias = 0,1,0,1,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) + + bias) >> 1); + bias ^= 1; /* 0=>1, 1=>0 */ + inptr += 2; + } + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * without smoothing. + */ + +METHODDEF(void) +h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION outcol; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr0, inptr1, outptr; + register int bias; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data, cinfo->max_v_samp_factor, + cinfo->image_width, output_cols * 2); + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + bias = 1; /* bias = 1,2,1,2,... for successive samples */ + for (outcol = 0; outcol < output_cols; outcol++) { + *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + + bias) >> 2); + bias ^= 3; /* 1=>2, 2=>1 */ + inptr0 += 2; inptr1 += 2; + } + inrow += 2; + } +} + + +#ifdef INPUT_SMOOTHING_SUPPORTED + +/* + * Downsample pixel values of a single component. + * This version handles the standard case of 2:1 horizontal and 2:1 vertical, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int inrow, outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols * 2); + + /* We don't bother to form the individual "smoothed" input pixel values; + * we can directly compute the output which is the average of the four + * smoothed values. Each of the four member pixels contributes a fraction + * (1-8*SF) to its own smoothed image and a fraction SF to each of the three + * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final + * output. The four corner-adjacent neighbor pixels contribute a fraction + * SF to just one smoothed pixel, or SF/4 to the final output; while the + * eight edge-adjacent neighbors contribute SF to each of two smoothed + * pixels, or SF/2 overall. In order to use integer arithmetic, these + * factors are scaled by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ + neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ + + inrow = 0; + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr0 = input_data[inrow]; + inptr1 = input_data[inrow+1]; + above_ptr = input_data[inrow-1]; + below_ptr = input_data[inrow+2]; + + /* Special case for first column: pretend column -1 is same as column 0 */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); + neighsum += neighsum; + neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + /* sum of pixels directly mapped to this output element */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + /* sum of edge-neighbor pixels */ + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); + /* The edge-neighbors count twice as much as corner-neighbors */ + neighsum += neighsum; + /* Add in the corner-neighbors */ + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); + /* form final output scaled up by 2^16 */ + membersum = membersum * memberscale + neighsum * neighscale; + /* round, descale and output it */ + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); + neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + + GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + + GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); + neighsum += neighsum; + neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + + GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + inrow += 2; + } +} + + +/* + * Downsample pixel values of a single component. + * This version handles the special case of a full-size component, + * with smoothing. One row of context is required. + */ + +METHODDEF(void) +fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, + JSAMPARRAY input_data, JSAMPARRAY output_data) +{ + int outrow; + JDIMENSION colctr; + JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; + register JSAMPROW inptr, above_ptr, below_ptr, outptr; + INT32 membersum, neighsum, memberscale, neighscale; + int colsum, lastcolsum, nextcolsum; + + /* Expand input data enough to let all the output samples be generated + * by the standard loop. Special-casing padded output would be more + * efficient. + */ + expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, + cinfo->image_width, output_cols); + + /* Each of the eight neighbor pixels contributes a fraction SF to the + * smoothed pixel, while the main pixel contributes (1-8*SF). In order + * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. + * Also recall that SF = smoothing_factor / 1024. + */ + + memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ + neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ + + for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { + outptr = output_data[outrow]; + inptr = input_data[outrow]; + above_ptr = input_data[outrow-1]; + below_ptr = input_data[outrow+1]; + + /* Special case for first column */ + colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + + GETJSAMPLE(*inptr); + membersum = GETJSAMPLE(*inptr++); + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = colsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + + for (colctr = output_cols - 2; colctr > 0; colctr--) { + membersum = GETJSAMPLE(*inptr++); + above_ptr++; below_ptr++; + nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + + GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + nextcolsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); + lastcolsum = colsum; colsum = nextcolsum; + } + + /* Special case for last column */ + membersum = GETJSAMPLE(*inptr); + neighsum = lastcolsum + (colsum - membersum) + colsum; + membersum = membersum * memberscale + neighsum * neighscale; + *outptr = (JSAMPLE) ((membersum + 32768) >> 16); + + } +} + +#endif /* INPUT_SMOOTHING_SUPPORTED */ + + +/* + * Module initialization routine for downsampling. + * Note that we must select a routine for each component. + */ + +GLOBAL(void) +jinit_downsampler (j_compress_ptr cinfo) +{ + my_downsample_ptr downsample; + int ci; + jpeg_component_info * compptr; + boolean smoothok = TRUE; + + downsample = (my_downsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_downsampler)); + cinfo->downsample = (struct jpeg_downsampler *) downsample; + downsample->pub.start_pass = start_pass_downsample; + downsample->pub.downsample = sep_downsample; + downsample->pub.need_context_rows = FALSE; + + if (cinfo->CCIR601_sampling) + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* Verify we can handle the sampling factors, and set up method pointers */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor == cinfo->max_h_samp_factor && + compptr->v_samp_factor == cinfo->max_v_samp_factor) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = fullsize_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = fullsize_downsample; + } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && + compptr->v_samp_factor == cinfo->max_v_samp_factor) { + smoothok = FALSE; + downsample->methods[ci] = h2v1_downsample; + } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && + compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor) { + downsample->methods[ci] = h2v2_smooth_downsample; + downsample->pub.need_context_rows = TRUE; + } else +#endif + downsample->methods[ci] = h2v2_downsample; + } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && + (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { + smoothok = FALSE; + downsample->methods[ci] = int_downsample; + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + } + +#ifdef INPUT_SMOOTHING_SUPPORTED + if (cinfo->smoothing_factor && !smoothok) + TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); +#endif +} diff --git a/libraries/external/jpeglib/jcsample.o b/libraries/external/jpeglib/jcsample.o new file mode 100644 index 0000000..38585e6 Binary files /dev/null and b/libraries/external/jpeglib/jcsample.o differ diff --git a/libraries/external/jpeglib/jctrans.c b/libraries/external/jpeglib/jctrans.c new file mode 100755 index 0000000..8b36e36 --- /dev/null +++ b/libraries/external/jpeglib/jctrans.c @@ -0,0 +1,388 @@ +/* + * jctrans.c + * + * Copyright (C) 1995-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding compression, + * that is, writing raw DCT coefficient arrays to an output JPEG file. + * The routines in jcapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transencode_master_selection + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); +LOCAL(void) transencode_coef_controller + JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); + + +/* + * Compression initialization for writing raw-coefficient data. + * Before calling this, all parameters and a data destination must be set up. + * Call jpeg_finish_compress() to actually write the data. + * + * The number of passed virtual arrays must match cinfo->num_components. + * Note that the virtual arrays need not be filled or even realized at + * the time write_coefficients is called; indeed, if the virtual arrays + * were requested from this compression object's memory manager, they + * typically will be realized during this routine and filled afterwards. + */ + +GLOBAL(void) +jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) +{ + if (cinfo->global_state != CSTATE_START) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Mark all tables to be written */ + jpeg_suppress_tables(cinfo, FALSE); + /* (Re)initialize error mgr and destination modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->dest->init_destination) (cinfo); + /* Perform master selection of active modules */ + transencode_master_selection(cinfo, coef_arrays); + /* Wait for jpeg_finish_compress() call */ + cinfo->next_scanline = 0; /* so jpeg_write_marker works */ + cinfo->global_state = CSTATE_WRCOEFS; +} + + +/* + * Initialize the compression object with default parameters, + * then copy from the source object all parameters needed for lossless + * transcoding. Parameters that can be varied without loss (such as + * scan script and Huffman optimization) are left in their default states. + */ + +GLOBAL(void) +jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, + j_compress_ptr dstinfo) +{ + JQUANT_TBL ** qtblptr; + jpeg_component_info *incomp, *outcomp; + JQUANT_TBL *c_quant, *slot_quant; + int tblno, ci, coefi; + + /* Safety check to ensure start_compress not called yet. */ + if (dstinfo->global_state != CSTATE_START) + ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); + /* Copy fundamental image dimensions */ + dstinfo->image_width = srcinfo->image_width; + dstinfo->image_height = srcinfo->image_height; + dstinfo->input_components = srcinfo->num_components; + dstinfo->in_color_space = srcinfo->jpeg_color_space; + /* Initialize all parameters to default values */ + jpeg_set_defaults(dstinfo); + /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. + * Fix it to get the right header markers for the image colorspace. + */ + jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); + dstinfo->data_precision = srcinfo->data_precision; + dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; + /* Copy the source's quantization tables. */ + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { + qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; + if (*qtblptr == NULL) + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); + MEMCOPY((*qtblptr)->quantval, + srcinfo->quant_tbl_ptrs[tblno]->quantval, + SIZEOF((*qtblptr)->quantval)); + (*qtblptr)->sent_table = FALSE; + } + } + /* Copy the source's per-component info. + * Note we assume jpeg_set_defaults has allocated the dest comp_info array. + */ + dstinfo->num_components = srcinfo->num_components; + if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) + ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, + MAX_COMPONENTS); + for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; + ci < dstinfo->num_components; ci++, incomp++, outcomp++) { + outcomp->component_id = incomp->component_id; + outcomp->h_samp_factor = incomp->h_samp_factor; + outcomp->v_samp_factor = incomp->v_samp_factor; + outcomp->quant_tbl_no = incomp->quant_tbl_no; + /* Make sure saved quantization table for component matches the qtable + * slot. If not, the input file re-used this qtable slot. + * IJG encoder currently cannot duplicate this. + */ + tblno = outcomp->quant_tbl_no; + if (tblno < 0 || tblno >= NUM_QUANT_TBLS || + srcinfo->quant_tbl_ptrs[tblno] == NULL) + ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); + slot_quant = srcinfo->quant_tbl_ptrs[tblno]; + c_quant = incomp->quant_table; + if (c_quant != NULL) { + for (coefi = 0; coefi < DCTSIZE2; coefi++) { + if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) + ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); + } + } + /* Note: we do not copy the source's Huffman table assignments; + * instead we rely on jpeg_set_colorspace to have made a suitable choice. + */ + } + /* Also copy JFIF version and resolution information, if available. + * Strictly speaking this isn't "critical" info, but it's nearly + * always appropriate to copy it if available. In particular, + * if the application chooses to copy JFIF 1.02 extension markers from + * the source file, we need to copy the version to make sure we don't + * emit a file that has 1.02 extensions but a claimed version of 1.01. + * We will *not*, however, copy version info from mislabeled "2.01" files. + */ + if (srcinfo->saw_JFIF_marker) { + if (srcinfo->JFIF_major_version == 1) { + dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; + dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; + } + dstinfo->density_unit = srcinfo->density_unit; + dstinfo->X_density = srcinfo->X_density; + dstinfo->Y_density = srcinfo->Y_density; + } +} + + +/* + * Master selection of compression modules for transcoding. + * This substitutes for jcinit.c's initialization of the full compressor. + */ + +LOCAL(void) +transencode_master_selection (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + /* Although we don't actually use input_components for transcoding, + * jcmaster.c's initial_setup will complain if input_components is 0. + */ + cinfo->input_components = 1; + /* Initialize master control (includes parameter checking/processing) */ + jinit_c_master_control(cinfo, TRUE /* transcode only */); + + /* Entropy encoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef C_PROGRESSIVE_SUPPORTED + jinit_phuff_encoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_encoder(cinfo); + } + + /* We need a special coefficient buffer controller. */ + transencode_coef_controller(cinfo, coef_arrays); + + jinit_marker_writer(cinfo); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Write the datastream header (SOI, JFIF) immediately. + * Frame and scan headers are postponed till later. + * This lets application insert special markers after the SOI. + */ + (*cinfo->marker->write_file_header) (cinfo); +} + + +/* + * The rest of this file is a special implementation of the coefficient + * buffer controller. This is similar to jccoefct.c, but it handles only + * output from presupplied virtual arrays. Furthermore, we generate any + * dummy padding blocks on-the-fly rather than expecting them to be present + * in the arrays. + */ + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_c_coef_controller pub; /* public fields */ + + JDIMENSION iMCU_row_num; /* iMCU row # within image */ + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* Virtual block array for each component. */ + jvirt_barray_ptr * whole_image; + + /* Workspace for constructing dummy blocks at right/bottom edges. */ + JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + + +LOCAL(void) +start_iMCU_row (j_compress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->mcu_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + if (pass_mode != JBUF_CRANK_DEST) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + coef->iMCU_row_num = 0; + start_iMCU_row(cinfo); +} + + +/* + * Process some data. + * We process the equivalent of one fully interleaved MCU row ("iMCU" row) + * per call, ie, v_samp_factor block rows for each component in the scan. + * The data is obtained from the virtual arrays and fed to the entropy coder. + * Returns TRUE if the iMCU row is completed, FALSE if suspended. + * + * NB: input_buf is ignored; it is likely to be a NULL pointer. + */ + +METHODDEF(boolean) +compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, blockcnt; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + coef->iMCU_row_num * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (coef->iMCU_row_num < last_iMCU_row || + yindex+yoffset < compptr->last_row_height) { + /* Fill in pointers to real blocks in this row */ + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < blockcnt; xindex++) + MCU_buffer[blkn++] = buffer_ptr++; + } else { + /* At bottom of image, need a whole row of dummy blocks */ + xindex = 0; + } + /* Fill in any dummy blocks needed in this row. + * Dummy blocks are filled in the same way as in jccoefct.c: + * all zeroes in the AC entries, DC entries equal to previous + * block's DC value. The init routine has already zeroed the + * AC entries, so we need only set the DC entries correctly. + */ + for (; xindex < compptr->MCU_width; xindex++) { + MCU_buffer[blkn] = coef->dummy_buffer[blkn]; + MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; + blkn++; + } + } + } + /* Try to write the MCU. */ + if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->mcu_ctr = MCU_col_num; + return FALSE; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->mcu_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + coef->iMCU_row_num++; + start_iMCU_row(cinfo); + return TRUE; +} + + +/* + * Initialize coefficient buffer controller. + * + * Each passed coefficient array must be the right size for that + * coefficient: width_in_blocks wide and height_in_blocks high, + * with unitheight at least v_samp_factor. + */ + +LOCAL(void) +transencode_coef_controller (j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays) +{ + my_coef_ptr coef; + JBLOCKROW buffer; + int i; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_c_coef_controller *) coef; + coef->pub.start_pass = start_pass_coef; + coef->pub.compress_data = compress_output; + + /* Save pointer to virtual arrays */ + coef->whole_image = coef_arrays; + + /* Allocate and pre-zero space for dummy DCT blocks. */ + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { + coef->dummy_buffer[i] = buffer + i; + } +} diff --git a/libraries/external/jpeglib/jctrans.o b/libraries/external/jpeglib/jctrans.o new file mode 100644 index 0000000..2229755 Binary files /dev/null and b/libraries/external/jpeglib/jctrans.o differ diff --git a/libraries/external/jpeglib/jdapimin.c b/libraries/external/jpeglib/jdapimin.c new file mode 100755 index 0000000..160f5dc --- /dev/null +++ b/libraries/external/jpeglib/jdapimin.c @@ -0,0 +1,395 @@ +/* + * jdapimin.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "minimum" API routines that may be + * needed in either the normal full-decompression case or the + * transcoding-only case. + * + * Most of the routines intended to be called directly by an application + * are in this file or in jdapistd.c. But also see jcomapi.c for routines + * shared by compression and decompression, and jdtrans.c for the transcoding + * case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * Initialization of a JPEG decompression object. + * The error manager must already be set up (in case memory manager fails). + */ + +GLOBAL(void) +jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) +{ + int i; + + /* Guard against version mismatches between library and caller. */ + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ + if (version != JPEG_LIB_VERSION) + ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); + if (structsize != SIZEOF(struct jpeg_decompress_struct)) + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, + (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); + + /* For debugging purposes, we zero the whole master structure. + * But the application has already set the err pointer, and may have set + * client_data, so we have to save and restore those fields. + * Note: if application hasn't set client_data, tools like Purify may + * complain here. + */ + { + struct jpeg_error_mgr * err = cinfo->err; + void * client_data = cinfo->client_data; /* ignore Purify complaint here */ + MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); + cinfo->err = err; + cinfo->client_data = client_data; + } + cinfo->is_decompressor = TRUE; + + /* Initialize a memory manager instance for this object */ + jinit_memory_mgr((j_common_ptr) cinfo); + + /* Zero out pointers to permanent structures. */ + cinfo->progress = NULL; + cinfo->src = NULL; + + for (i = 0; i < NUM_QUANT_TBLS; i++) + cinfo->quant_tbl_ptrs[i] = NULL; + + for (i = 0; i < NUM_HUFF_TBLS; i++) { + cinfo->dc_huff_tbl_ptrs[i] = NULL; + cinfo->ac_huff_tbl_ptrs[i] = NULL; + } + + /* Initialize marker processor so application can override methods + * for COM, APPn markers before calling jpeg_read_header. + */ + cinfo->marker_list = NULL; + jinit_marker_reader(cinfo); + + /* And initialize the overall input controller. */ + jinit_input_controller(cinfo); + + /* OK, I'm ready */ + cinfo->global_state = DSTATE_START; +} + + +/* + * Destruction of a JPEG decompression object + */ + +//GLOBAL(void) +void jpeg_destroy_decompress (j_decompress_ptr cinfo) +{ + jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Abort processing of a JPEG decompression operation, + * but don't destroy the object itself. + */ + +GLOBAL(void) +jpeg_abort_decompress (j_decompress_ptr cinfo) +{ + jpeg_abort((j_common_ptr) cinfo); /* use common routine */ +} + + +/* + * Set default decompression parameters. + */ + +LOCAL(void) +default_decompress_parms (j_decompress_ptr cinfo) +{ + /* Guess the input colorspace, and set output colorspace accordingly. */ + /* (Wish JPEG committee had provided a real way to specify this...) */ + /* Note application may override our guesses. */ + switch (cinfo->num_components) { + case 1: + cinfo->jpeg_color_space = JCS_GRAYSCALE; + cinfo->out_color_space = JCS_GRAYSCALE; + break; + + case 3: + if (cinfo->saw_JFIF_marker) { + cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ + } else if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_RGB; + break; + case 1: + cinfo->jpeg_color_space = JCS_YCbCr; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + break; + } + } else { + /* Saw no special markers, try to guess from the component IDs */ + int cid0 = cinfo->comp_info[0].component_id; + int cid1 = cinfo->comp_info[1].component_id; + int cid2 = cinfo->comp_info[2].component_id; + + if (cid0 == 1 && cid1 == 2 && cid2 == 3) + cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ + else if (cid0 == 82 && cid1 == 71 && cid2 == 66) + cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ + else { + TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ + } + } + /* Always guess RGB is proper output colorspace. */ + cinfo->out_color_space = JCS_RGB; + break; + + case 4: + if (cinfo->saw_Adobe_marker) { + switch (cinfo->Adobe_transform) { + case 0: + cinfo->jpeg_color_space = JCS_CMYK; + break; + case 2: + cinfo->jpeg_color_space = JCS_YCCK; + break; + default: + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); + cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ + break; + } + } else { + /* No special markers, assume straight CMYK. */ + cinfo->jpeg_color_space = JCS_CMYK; + } + cinfo->out_color_space = JCS_CMYK; + break; + + default: + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->out_color_space = JCS_UNKNOWN; + break; + } + + /* Set defaults for other decompression parameters. */ + cinfo->scale_num = 1; /* 1:1 scaling */ + cinfo->scale_denom = 1; + cinfo->output_gamma = 1.0; + cinfo->buffered_image = FALSE; + cinfo->raw_data_out = FALSE; + cinfo->dct_method = JDCT_DEFAULT; + cinfo->do_fancy_upsampling = TRUE; + cinfo->do_block_smoothing = TRUE; + cinfo->quantize_colors = FALSE; + /* We set these in case application only sets quantize_colors. */ + cinfo->dither_mode = JDITHER_FS; +#ifdef QUANT_2PASS_SUPPORTED + cinfo->two_pass_quantize = TRUE; +#else + cinfo->two_pass_quantize = FALSE; +#endif + cinfo->desired_number_of_colors = 256; + cinfo->colormap = NULL; + /* Initialize for no mode change in buffered-image mode. */ + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; +} + + +/* + * Decompression startup: read start of JPEG datastream to see what's there. + * Need only initialize JPEG object and supply a data source before calling. + * + * This routine will read as far as the first SOS marker (ie, actual start of + * compressed data), and will save all tables and parameters in the JPEG + * object. It will also initialize the decompression parameters to default + * values, and finally return JPEG_HEADER_OK. On return, the application may + * adjust the decompression parameters and then call jpeg_start_decompress. + * (Or, if the application only wanted to determine the image parameters, + * the data need not be decompressed. In that case, call jpeg_abort or + * jpeg_destroy to release any temporary space.) + * If an abbreviated (tables only) datastream is presented, the routine will + * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then + * re-use the JPEG object to read the abbreviated image datastream(s). + * It is unnecessary (but OK) to call jpeg_abort in this case. + * The JPEG_SUSPENDED return code only occurs if the data source module + * requests suspension of the decompressor. In this case the application + * should load more source data and then re-call jpeg_read_header to resume + * processing. + * If a non-suspending data source is used and require_image is TRUE, then the + * return code need not be inspected since only JPEG_HEADER_OK is possible. + * + * This routine is now just a front end to jpeg_consume_input, with some + * extra error checking. + */ + +GLOBAL(int) +jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) +{ + int retcode; + + if (cinfo->global_state != DSTATE_START && + cinfo->global_state != DSTATE_INHEADER) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + retcode = jpeg_consume_input(cinfo); + + switch (retcode) { + case JPEG_REACHED_SOS: + retcode = JPEG_HEADER_OK; + break; + case JPEG_REACHED_EOI: + if (require_image) /* Complain if application wanted an image */ + ERREXIT(cinfo, JERR_NO_IMAGE); + /* Reset to start state; it would be safer to require the application to + * call jpeg_abort, but we can't change it now for compatibility reasons. + * A side effect is to free any temporary memory (there shouldn't be any). + */ + jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ + retcode = JPEG_HEADER_TABLES_ONLY; + break; + case JPEG_SUSPENDED: + /* no work */ + break; + } + + return retcode; +} + + +/* + * Consume data in advance of what the decompressor requires. + * This can be called at any time once the decompressor object has + * been created and a data source has been set up. + * + * This routine is essentially a state machine that handles a couple + * of critical state-transition actions, namely initial setup and + * transition from header scanning to ready-for-start_decompress. + * All the actual input is done via the input controller's consume_input + * method. + */ + +GLOBAL(int) +jpeg_consume_input (j_decompress_ptr cinfo) +{ + int retcode = JPEG_SUSPENDED; + + /* NB: every possible DSTATE value should be listed in this switch */ + switch (cinfo->global_state) { + case DSTATE_START: + /* Start-of-datastream actions: reset appropriate modules */ + (*cinfo->inputctl->reset_input_controller) (cinfo); + /* Initialize application's data source module */ + (*cinfo->src->init_source) (cinfo); + cinfo->global_state = DSTATE_INHEADER; + /*FALLTHROUGH*/ + case DSTATE_INHEADER: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ + /* Set up default parameters based on header data */ + default_decompress_parms(cinfo); + /* Set global state: ready for start_decompress */ + cinfo->global_state = DSTATE_READY; + } + break; + case DSTATE_READY: + /* Can't advance past first SOS until start_decompress is called */ + retcode = JPEG_REACHED_SOS; + break; + case DSTATE_PRELOAD: + case DSTATE_PRESCAN: + case DSTATE_SCANNING: + case DSTATE_RAW_OK: + case DSTATE_BUFIMAGE: + case DSTATE_BUFPOST: + case DSTATE_STOPPING: + retcode = (*cinfo->inputctl->consume_input) (cinfo); + break; + default: + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + return retcode; +} + + +/* + * Have we finished reading the input file? + */ + +GLOBAL(boolean) +jpeg_input_complete (j_decompress_ptr cinfo) +{ + /* Check for valid jpeg object */ + if (cinfo->global_state < DSTATE_START || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->eoi_reached; +} + + +/* + * Is there more than one scan? + */ + +GLOBAL(boolean) +jpeg_has_multiple_scans (j_decompress_ptr cinfo) +{ + /* Only valid after jpeg_read_header completes */ + if (cinfo->global_state < DSTATE_READY || + cinfo->global_state > DSTATE_STOPPING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return cinfo->inputctl->has_multiple_scans; +} + + +/* + * Finish JPEG decompression. + * + * This will normally just verify the file trailer and release temp storage. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_decompress (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { + /* Terminate final pass of non-buffered mode */ + if (cinfo->output_scanline < cinfo->output_height) + ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state == DSTATE_BUFIMAGE) { + /* Finishing after a buffered-image operation */ + cinfo->global_state = DSTATE_STOPPING; + } else if (cinfo->global_state != DSTATE_STOPPING) { + /* STOPPING = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read until EOI */ + while (! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + /* Do final cleanup */ + (*cinfo->src->term_source) (cinfo); + /* We can use jpeg_abort to release memory and reset global_state */ + jpeg_abort((j_common_ptr) cinfo); + return TRUE; +} diff --git a/libraries/external/jpeglib/jdapimin.o b/libraries/external/jpeglib/jdapimin.o new file mode 100644 index 0000000..491b520 Binary files /dev/null and b/libraries/external/jpeglib/jdapimin.o differ diff --git a/libraries/external/jpeglib/jdapistd.c b/libraries/external/jpeglib/jdapistd.c new file mode 100755 index 0000000..f6c7fff --- /dev/null +++ b/libraries/external/jpeglib/jdapistd.c @@ -0,0 +1,275 @@ +/* + * jdapistd.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains application interface code for the decompression half + * of the JPEG library. These are the "standard" API routines that are + * used in the normal full-decompression case. They are not used by a + * transcoding-only application. Note that if an application links in + * jpeg_start_decompress, it will end up linking in the entire decompressor. + * We thus must separate this file from jdapimin.c to avoid linking the + * whole decompression library into a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); + + +/* + * Decompression initialization. + * jpeg_read_header must be completed before calling this. + * + * If a multipass operating mode was selected, this will do all but the + * last pass, and thus may take a great deal of time. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_start_decompress (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize master control, select active modules */ + jinit_master_decompress(cinfo); + if (cinfo->buffered_image) { + /* No more work here; expecting jpeg_start_output next */ + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; + } + cinfo->global_state = DSTATE_PRELOAD; + } + if (cinfo->global_state == DSTATE_PRELOAD) { + /* If file has multiple scans, absorb them all into the coef buffer */ + if (cinfo->inputctl->has_multiple_scans) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return FALSE; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* jdmaster underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + } + cinfo->output_scan_number = cinfo->input_scan_number; + } else if (cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Perform any dummy output passes, and set up for the final pass */ + return output_pass_setup(cinfo); +} + + +/* + * Set up for an output pass, and perform any dummy pass(es) needed. + * Common subroutine for jpeg_start_decompress and jpeg_start_output. + * Entry: global_state = DSTATE_PRESCAN only if previously suspended. + * Exit: If done, returns TRUE and sets global_state for proper output mode. + * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. + */ + +LOCAL(boolean) +output_pass_setup (j_decompress_ptr cinfo) +{ + if (cinfo->global_state != DSTATE_PRESCAN) { + /* First call: do pass setup */ + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; + cinfo->global_state = DSTATE_PRESCAN; + } + /* Loop over any required dummy passes */ + while (cinfo->master->is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Crank through the dummy pass */ + while (cinfo->output_scanline < cinfo->output_height) { + JDIMENSION last_scanline; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + /* Process some data */ + last_scanline = cinfo->output_scanline; + (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, + &cinfo->output_scanline, (JDIMENSION) 0); + if (cinfo->output_scanline == last_scanline) + return FALSE; /* No progress made, must suspend */ + } + /* Finish up dummy pass, and set up for another one */ + (*cinfo->master->finish_output_pass) (cinfo); + (*cinfo->master->prepare_for_output_pass) (cinfo); + cinfo->output_scanline = 0; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } + /* Ready for application to drive output pass through + * jpeg_read_scanlines or jpeg_read_raw_data. + */ + cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; + return TRUE; +} + + +/* + * Read some scanlines of data from the JPEG decompressor. + * + * The return value will be the number of lines actually read. + * This may be less than the number requested in several cases, + * including bottom of image, data source suspension, and operating + * modes that emit multiple scanlines at a time. + * + * Note: we warn about excess calls to jpeg_read_scanlines() since + * this likely signals an application programmer error. However, + * an oversize buffer (max_lines > scanlines remaining) is not an error. + */ + +GLOBAL(JDIMENSION) +jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, + JDIMENSION max_lines) +{ + JDIMENSION row_ctr; + + if (cinfo->global_state != DSTATE_SCANNING) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Process some data */ + row_ctr = 0; + (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); + cinfo->output_scanline += row_ctr; + return row_ctr; +} + + +/* + * Alternate entry point to read raw data. + * Processes exactly one iMCU row per call, unless suspended. + */ + +GLOBAL(JDIMENSION) +jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, + JDIMENSION max_lines) +{ + JDIMENSION lines_per_iMCU_row; + + if (cinfo->global_state != DSTATE_RAW_OK) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + if (cinfo->output_scanline >= cinfo->output_height) { + WARNMS(cinfo, JWRN_TOO_MUCH_DATA); + return 0; + } + + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) { + cinfo->progress->pass_counter = (long) cinfo->output_scanline; + cinfo->progress->pass_limit = (long) cinfo->output_height; + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + } + + /* Verify that at least one iMCU row can be returned. */ + lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; + if (max_lines < lines_per_iMCU_row) + ERREXIT(cinfo, JERR_BUFFER_SIZE); + + /* Decompress directly into user's buffer. */ + if (! (*cinfo->coef->decompress_data) (cinfo, data)) + return 0; /* suspension forced, can do nothing more */ + + /* OK, we processed one iMCU row. */ + cinfo->output_scanline += lines_per_iMCU_row; + return lines_per_iMCU_row; +} + + +/* Additional entry points for buffered-image mode. */ + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Initialize for an output pass in buffered-image mode. + */ + +GLOBAL(boolean) +jpeg_start_output (j_decompress_ptr cinfo, int scan_number) +{ + if (cinfo->global_state != DSTATE_BUFIMAGE && + cinfo->global_state != DSTATE_PRESCAN) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + /* Limit scan number to valid range */ + if (scan_number <= 0) + scan_number = 1; + if (cinfo->inputctl->eoi_reached && + scan_number > cinfo->input_scan_number) + scan_number = cinfo->input_scan_number; + cinfo->output_scan_number = scan_number; + /* Perform any dummy output passes, and set up for the real pass */ + return output_pass_setup(cinfo); +} + + +/* + * Finish up after an output pass in buffered-image mode. + * + * Returns FALSE if suspended. The return value need be inspected only if + * a suspending data source is used. + */ + +GLOBAL(boolean) +jpeg_finish_output (j_decompress_ptr cinfo) +{ + if ((cinfo->global_state == DSTATE_SCANNING || + cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { + /* Terminate this pass. */ + /* We do not require the whole pass to have been completed. */ + (*cinfo->master->finish_output_pass) (cinfo); + cinfo->global_state = DSTATE_BUFPOST; + } else if (cinfo->global_state != DSTATE_BUFPOST) { + /* BUFPOST = repeat call after a suspension, anything else is error */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + } + /* Read markers looking for SOS or EOI */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) + return FALSE; /* Suspend, come back later */ + } + cinfo->global_state = DSTATE_BUFIMAGE; + return TRUE; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/libraries/external/jpeglib/jdapistd.o b/libraries/external/jpeglib/jdapistd.o new file mode 100644 index 0000000..d66e55a Binary files /dev/null and b/libraries/external/jpeglib/jdapistd.o differ diff --git a/libraries/external/jpeglib/jdatadst.c b/libraries/external/jpeglib/jdatadst.c new file mode 100755 index 0000000..2ece4e9 --- /dev/null +++ b/libraries/external/jpeglib/jdatadst.c @@ -0,0 +1,151 @@ +/* + * jdatadst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains compression data destination routines for the case of + * emitting JPEG data to a file (or any stdio stream). While these routines + * are sufficient for most applications, some will want to use a different + * destination manager. + * IMPORTANT: we assume that fwrite() will correctly transcribe an array of + * JOCTETs into 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data destination object for stdio output */ + +typedef struct { + struct jpeg_destination_mgr pub; /* public fields */ + + FILE * outfile; /* target stream */ + JOCTET * buffer; /* start of buffer */ +} my_destination_mgr; + +typedef my_destination_mgr * my_dest_ptr; + +#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ + + +/* + * Initialize destination --- called by jpeg_start_compress + * before any data is actually written. + */ + +METHODDEF(void) +init_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + /* Allocate the output buffer --- it will be released when done with image */ + dest->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; +} + + +/* + * Empty the output buffer --- called whenever buffer fills up. + * + * In typical applications, this should write the entire output buffer + * (ignoring the current state of next_output_byte & free_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been dumped. + * + * In applications that need to be able to suspend compression due to output + * overrun, a FALSE return indicates that the buffer cannot be emptied now. + * In this situation, the compressor will return to its caller (possibly with + * an indication that it has not accepted all the supplied scanlines). The + * application should resume compression after it has made more room in the + * output buffer. Note that there are substantial restrictions on the use of + * suspension --- see the documentation. + * + * When suspending, the compressor will back up to a convenient restart point + * (typically the start of the current MCU). next_output_byte & free_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point will be regenerated after resumption, so do not + * write it out when emptying the buffer externally. + */ + +METHODDEF(boolean) +empty_output_buffer (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + + if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != + (size_t) OUTPUT_BUF_SIZE) + ERREXIT(cinfo, JERR_FILE_WRITE); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + + return TRUE; +} + + +/* + * Terminate destination --- called by jpeg_finish_compress + * after all data has been written. Usually needs to flush buffer. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_destination (j_compress_ptr cinfo) +{ + my_dest_ptr dest = (my_dest_ptr) cinfo->dest; + size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + + /* Write any data remaining in the buffer */ + if (datacount > 0) { + if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) + ERREXIT(cinfo, JERR_FILE_WRITE); + } + fflush(dest->outfile); + /* Make sure we wrote the output file OK */ + if (ferror(dest->outfile)) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + + +/* + * Prepare for output to a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing compression. + */ + +GLOBAL(void) +jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) +{ + my_dest_ptr dest; + + /* The destination object is made permanent so that multiple JPEG images + * can be written to the same file without re-executing jpeg_stdio_dest. + * This makes it dangerous to use this manager and a different destination + * manager serially with the same JPEG object, because their private object + * sizes may be different. Caveat programmer. + */ + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_destination_mgr)); + } + + dest = (my_dest_ptr) cinfo->dest; + dest->pub.init_destination = init_destination; + dest->pub.empty_output_buffer = empty_output_buffer; + dest->pub.term_destination = term_destination; + dest->outfile = outfile; +} diff --git a/libraries/external/jpeglib/jdatadst.o b/libraries/external/jpeglib/jdatadst.o new file mode 100644 index 0000000..c95a5ea Binary files /dev/null and b/libraries/external/jpeglib/jdatadst.o differ diff --git a/libraries/external/jpeglib/jdatasrc.c b/libraries/external/jpeglib/jdatasrc.c new file mode 100755 index 0000000..29b6983 --- /dev/null +++ b/libraries/external/jpeglib/jdatasrc.c @@ -0,0 +1,212 @@ +/* + * jdatasrc.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains decompression data source routines for the case of + * reading JPEG data from a file (or any stdio stream). While these routines + * are sufficient for most applications, some will want to use a different + * source manager. + * IMPORTANT: we assume that fread() will correctly transcribe an array of + * JOCTETs from 8-bit-wide elements on external storage. If char is wider + * than 8 bits on your machine, you may need to do some tweaking. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jerror.h" + + +/* Expanded data source object for stdio input */ + +typedef struct { + struct jpeg_source_mgr pub; /* public fields */ + + FILE * infile; /* source stream */ + JOCTET * buffer; /* start of buffer */ + boolean start_of_file; /* have we gotten any data yet? */ +} my_source_mgr; + +typedef my_source_mgr * my_src_ptr; + +#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ + + +/* + * Initialize source --- called by jpeg_read_header + * before any data is actually read. + */ + +METHODDEF(void) +init_source (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* We reset the empty-input-file flag for each image, + * but we don't clear the input buffer. + * This is correct behavior for reading a series of images from one source. + */ + src->start_of_file = TRUE; +} + + +/* + * Fill the input buffer --- called whenever buffer is emptied. + * + * In typical applications, this should read fresh data into the buffer + * (ignoring the current state of next_input_byte & bytes_in_buffer), + * reset the pointer & count to the start of the buffer, and return TRUE + * indicating that the buffer has been reloaded. It is not necessary to + * fill the buffer entirely, only to obtain at least one more byte. + * + * There is no such thing as an EOF return. If the end of the file has been + * reached, the routine has a choice of ERREXIT() or inserting fake data into + * the buffer. In most cases, generating a warning message and inserting a + * fake EOI marker is the best course of action --- this will allow the + * decompressor to output however much of the image is there. However, + * the resulting error message is misleading if the real problem is an empty + * input file, so we handle that case specially. + * + * In applications that need to be able to suspend compression due to input + * not being available yet, a FALSE return indicates that no more data can be + * obtained right now, but more may be forthcoming later. In this situation, + * the decompressor will return to its caller (with an indication of the + * number of scanlines it has read, if any). The application should resume + * decompression after it has loaded more data into the input buffer. Note + * that there are substantial restrictions on the use of suspension --- see + * the documentation. + * + * When suspending, the decompressor will back up to a convenient restart point + * (typically the start of the current MCU). next_input_byte & bytes_in_buffer + * indicate where the restart point will be if the current call returns FALSE. + * Data beyond this point must be rescanned after resumption, so move it to + * the front of the buffer rather than discarding it. + */ + +METHODDEF(boolean) +fill_input_buffer (j_decompress_ptr cinfo) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + size_t nbytes; + + nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); + + if (nbytes <= 0) { + if (src->start_of_file) /* Treat empty input file as fatal error */ + ERREXIT(cinfo, JERR_INPUT_EMPTY); + WARNMS(cinfo, JWRN_JPEG_EOF); + /* Insert a fake EOI marker */ + src->buffer[0] = (JOCTET) 0xFF; + src->buffer[1] = (JOCTET) JPEG_EOI; + nbytes = 2; + } + + src->pub.next_input_byte = src->buffer; + src->pub.bytes_in_buffer = nbytes; + src->start_of_file = FALSE; + + return TRUE; +} + + +/* + * Skip data --- used to skip over a potentially large amount of + * uninteresting data (such as an APPn marker). + * + * Writers of suspendable-input applications must note that skip_input_data + * is not granted the right to give a suspension return. If the skip extends + * beyond the data currently in the buffer, the buffer can be marked empty so + * that the next read will cause a fill_input_buffer call that can suspend. + * Arranging for additional bytes to be discarded before reloading the input + * buffer is the application writer's problem. + */ + +METHODDEF(void) +skip_input_data (j_decompress_ptr cinfo, long num_bytes) +{ + my_src_ptr src = (my_src_ptr) cinfo->src; + + /* Just a dumb implementation for now. Could use fseek() except + * it doesn't work on pipes. Not clear that being smart is worth + * any trouble anyway --- large skips are infrequent. + */ + if (num_bytes > 0) { + while (num_bytes > (long) src->pub.bytes_in_buffer) { + num_bytes -= (long) src->pub.bytes_in_buffer; + (void) fill_input_buffer(cinfo); + /* note we assume that fill_input_buffer will never return FALSE, + * so suspension need not be handled. + */ + } + src->pub.next_input_byte += (size_t) num_bytes; + src->pub.bytes_in_buffer -= (size_t) num_bytes; + } +} + + +/* + * An additional method that can be provided by data source modules is the + * resync_to_restart method for error recovery in the presence of RST markers. + * For the moment, this source module just uses the default resync method + * provided by the JPEG library. That method assumes that no backtracking + * is possible. + */ + + +/* + * Terminate source --- called by jpeg_finish_decompress + * after all data has been read. Often a no-op. + * + * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding + * application must deal with any cleanup that should happen even + * for error exit. + */ + +METHODDEF(void) +term_source (j_decompress_ptr cinfo) +{ + /* no work necessary here */ +} + + +/* + * Prepare for input from a stdio stream. + * The caller must have already opened the stream, and is responsible + * for closing it after finishing decompression. + */ + +GLOBAL(void) +jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) +{ + my_src_ptr src; + + /* The source object and input buffer are made permanent so that a series + * of JPEG images can be read from the same file by calling jpeg_stdio_src + * only before the first one. (If we discarded the buffer at the end of + * one image, we'd likely lose the start of the next one.) + * This makes it unsafe to use this manager and a different source + * manager serially with the same JPEG object. Caveat programmer. + */ + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_source_mgr)); + src = (my_src_ptr) cinfo->src; + src->buffer = (JOCTET *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + INPUT_BUF_SIZE * SIZEOF(JOCTET)); + } + + src = (my_src_ptr) cinfo->src; + src->pub.init_source = init_source; + src->pub.fill_input_buffer = fill_input_buffer; + src->pub.skip_input_data = skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->pub.term_source = term_source; + src->infile = infile; + src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ + src->pub.next_input_byte = NULL; /* until buffer loaded */ +} diff --git a/libraries/external/jpeglib/jdatasrc.o b/libraries/external/jpeglib/jdatasrc.o new file mode 100644 index 0000000..be4383a Binary files /dev/null and b/libraries/external/jpeglib/jdatasrc.o differ diff --git a/libraries/external/jpeglib/jdcoefct.c b/libraries/external/jpeglib/jdcoefct.c new file mode 100755 index 0000000..992bd10 --- /dev/null +++ b/libraries/external/jpeglib/jdcoefct.c @@ -0,0 +1,736 @@ +/* + * jdcoefct.c + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the coefficient buffer controller for decompression. + * This controller is the top level of the JPEG decompressor proper. + * The coefficient buffer lies between entropy decoding and inverse-DCT steps. + * + * In buffered-image mode, this controller is the interface between + * input-oriented processing and output-oriented processing. + * Also, the input side (only) is used when reading a file for transcoding. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +/* Block smoothing is only applicable for progressive JPEG, so: */ +#ifndef D_PROGRESSIVE_SUPPORTED +#undef BLOCK_SMOOTHING_SUPPORTED +#endif + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_coef_controller pub; /* public fields */ + + /* These variables keep track of the current location of the input side. */ + /* cinfo->input_iMCU_row is also used for this. */ + JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ + int MCU_vert_offset; /* counts MCU rows within iMCU row */ + int MCU_rows_per_iMCU_row; /* number of such rows needed */ + + /* The output side's location is represented by cinfo->output_iMCU_row. */ + + /* In single-pass modes, it's sufficient to buffer just one MCU. + * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, + * and let the entropy decoder write into that workspace each time. + * (On 80x86, the workspace is FAR even though it's not really very big; + * this is to keep the module interfaces unchanged when a large coefficient + * buffer is necessary.) + * In multi-pass modes, this array points to the current MCU's blocks + * within the virtual arrays; it is used only by the input side. + */ + JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* In multi-pass modes, we need a virtual block array for each component. */ + jvirt_barray_ptr whole_image[MAX_COMPONENTS]; +#endif + +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* When doing block smoothing, we latch coefficient Al values here */ + int * coef_bits_latch; +#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ +#endif +} my_coef_controller; + +typedef my_coef_controller * my_coef_ptr; + +/* Forward declarations */ +METHODDEF(int) decompress_onepass + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#ifdef D_MULTISCAN_FILES_SUPPORTED +METHODDEF(int) decompress_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif +#ifdef BLOCK_SMOOTHING_SUPPORTED +LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); +METHODDEF(int) decompress_smooth_data + JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); +#endif + + +LOCAL(void) +start_iMCU_row (j_decompress_ptr cinfo) +/* Reset within-iMCU-row counters for a new row (input side) */ +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* In an interleaved scan, an MCU row is the same as an iMCU row. + * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. + * But at the bottom of the image, process only what's left. + */ + if (cinfo->comps_in_scan > 1) { + coef->MCU_rows_per_iMCU_row = 1; + } else { + if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; + else + coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; + } + + coef->MCU_ctr = 0; + coef->MCU_vert_offset = 0; +} + + +/* + * Initialize for an input processing pass. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + cinfo->input_iMCU_row = 0; + start_iMCU_row(cinfo); +} + + +/* + * Initialize for an output processing pass. + */ + +METHODDEF(void) +start_output_pass (j_decompress_ptr cinfo) +{ +#ifdef BLOCK_SMOOTHING_SUPPORTED + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + + /* If multipass, check to see whether to use block smoothing on this pass */ + if (coef->pub.coef_arrays != NULL) { + if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) + coef->pub.decompress_data = decompress_smooth_data; + else + coef->pub.decompress_data = decompress_data; + } +#endif + cinfo->output_iMCU_row = 0; +} + + +/* + * Decompress and return some data in the single-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Input and output must run in lockstep since we have only a one-MCU buffer. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image, + * which we index according to the component's SOF position. + */ + +METHODDEF(int) +decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + int blkn, ci, xindex, yindex, yoffset, useful_width; + JSAMPARRAY output_ptr; + JDIMENSION start_col, output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Loop to process as much as one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; + MCU_col_num++) { + /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ + jzero_far((void FAR *) coef->MCU_buffer[0], + (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + /* Determine where data should go in output_buf and do the IDCT thing. + * We skip dummy blocks at the right and bottom edges (but blkn gets + * incremented past them!). Note the inner loop relies on having + * allocated the MCU_buffer[] blocks sequentially. + */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) { + blkn += compptr->MCU_blocks; + continue; + } + inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; + useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width + : compptr->last_col_width; + output_ptr = output_buf[compptr->component_index] + + yoffset * compptr->DCT_scaled_size; + start_col = MCU_col_num * compptr->MCU_sample_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + if (cinfo->input_iMCU_row < last_iMCU_row || + yoffset+yindex < compptr->last_row_height) { + output_col = start_col; + for (xindex = 0; xindex < useful_width; xindex++) { + (*inverse_DCT) (cinfo, compptr, + (JCOEFPTR) coef->MCU_buffer[blkn+xindex], + output_ptr, output_col); + output_col += compptr->DCT_scaled_size; + } + } + blkn += compptr->MCU_width; + output_ptr += compptr->DCT_scaled_size; + } + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + cinfo->output_iMCU_row++; + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Dummy consume-input routine for single-pass operation. + */ + +METHODDEF(int) +dummy_consume_data (j_decompress_ptr cinfo) +{ + return JPEG_SUSPENDED; /* Always indicate nothing was done */ +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Consume input data and store it in the full-image coefficient buffer. + * We read as much as one fully interleaved MCU row ("iMCU" row) per call, + * ie, v_samp_factor block rows for each component in the scan. + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + */ + +METHODDEF(int) +consume_data (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION MCU_col_num; /* index of current MCU within row */ + int blkn, ci, xindex, yindex, yoffset; + JDIMENSION start_col; + JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; + JBLOCKROW buffer_ptr; + jpeg_component_info *compptr; + + /* Align the virtual buffers for the components used in this scan. */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + buffer[ci] = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], + cinfo->input_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, TRUE); + /* Note: entropy decoder expects buffer to be zeroed, + * but this is handled automatically by the memory manager + * because we requested a pre-zeroed array. + */ + } + + /* Loop to process one whole iMCU row */ + for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; + yoffset++) { + for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; + MCU_col_num++) { + /* Construct list of pointers to DCT blocks belonging to this MCU */ + blkn = 0; /* index of current DCT block within MCU */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + start_col = MCU_col_num * compptr->MCU_width; + for (yindex = 0; yindex < compptr->MCU_height; yindex++) { + buffer_ptr = buffer[ci][yindex+yoffset] + start_col; + for (xindex = 0; xindex < compptr->MCU_width; xindex++) { + coef->MCU_buffer[blkn++] = buffer_ptr++; + } + } + } + /* Try to fetch the MCU. */ + if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { + /* Suspension forced; update state counters and exit */ + coef->MCU_vert_offset = yoffset; + coef->MCU_ctr = MCU_col_num; + return JPEG_SUSPENDED; + } + } + /* Completed an MCU row, but perhaps not an iMCU row */ + coef->MCU_ctr = 0; + } + /* Completed the iMCU row, advance counters for next one */ + if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { + start_iMCU_row(cinfo); + return JPEG_ROW_COMPLETED; + } + /* Completed the scan */ + (*cinfo->inputctl->finish_input_pass) (cinfo); + return JPEG_SCAN_COMPLETED; +} + + +/* + * Decompress and return some data in the multi-pass case. + * Always attempts to emit one fully interleaved MCU row ("iMCU" row). + * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. + * + * NB: output_buf contains a plane for each component in image. + */ + +METHODDEF(int) +decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num; + int ci, block_row, block_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number < cinfo->output_scan_number || + (cinfo->input_scan_number == cinfo->output_scan_number && + cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Align the virtual buffer for this component. */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + cinfo->output_iMCU_row * compptr->v_samp_factor, + (JDIMENSION) compptr->v_samp_factor, FALSE); + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) + block_rows = compptr->v_samp_factor; + else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + } + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + output_col = 0; + for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { + (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, + output_ptr, output_col); + buffer_ptr++; + output_col += compptr->DCT_scaled_size; + } + output_ptr += compptr->DCT_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +#ifdef BLOCK_SMOOTHING_SUPPORTED + +/* + * This code applies interblock smoothing as described by section K.8 + * of the JPEG standard: the first 5 AC coefficients are estimated from + * the DC values of a DCT block and its 8 neighboring blocks. + * We apply smoothing only for progressive JPEG decoding, and only if + * the coefficients it can estimate are not yet known to full precision. + */ + +/* Natural-order array positions of the first 5 zigzag-order coefficients */ +#define Q01_POS 1 +#define Q10_POS 8 +#define Q20_POS 16 +#define Q11_POS 9 +#define Q02_POS 2 + +/* + * Determine whether block smoothing is applicable and safe. + * We also latch the current states of the coef_bits[] entries for the + * AC coefficients; otherwise, if the input side of the decompressor + * advances into a new scan, we might think the coefficients are known + * more accurately than they really are. + */ + +LOCAL(boolean) +smoothing_ok (j_decompress_ptr cinfo) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + boolean smoothing_useful = FALSE; + int ci, coefi; + jpeg_component_info *compptr; + JQUANT_TBL * qtable; + int * coef_bits; + int * coef_bits_latch; + + if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) + return FALSE; + + /* Allocate latch area if not already done */ + if (coef->coef_bits_latch == NULL) + coef->coef_bits_latch = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * + (SAVED_COEFS * SIZEOF(int))); + coef_bits_latch = coef->coef_bits_latch; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* All components' quantization values must already be latched. */ + if ((qtable = compptr->quant_table) == NULL) + return FALSE; + /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ + if (qtable->quantval[0] == 0 || + qtable->quantval[Q01_POS] == 0 || + qtable->quantval[Q10_POS] == 0 || + qtable->quantval[Q20_POS] == 0 || + qtable->quantval[Q11_POS] == 0 || + qtable->quantval[Q02_POS] == 0) + return FALSE; + /* DC values must be at least partly known for all components. */ + coef_bits = cinfo->coef_bits[ci]; + if (coef_bits[0] < 0) + return FALSE; + /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ + for (coefi = 1; coefi <= 5; coefi++) { + coef_bits_latch[coefi] = coef_bits[coefi]; + if (coef_bits[coefi] != 0) + smoothing_useful = TRUE; + } + coef_bits_latch += SAVED_COEFS; + } + + return smoothing_useful; +} + + +/* + * Variant of decompress_data for use when doing block smoothing. + */ + +METHODDEF(int) +decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) +{ + my_coef_ptr coef = (my_coef_ptr) cinfo->coef; + JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; + JDIMENSION block_num, last_block_column; + int ci, block_row, block_rows, access_rows; + JBLOCKARRAY buffer; + JBLOCKROW buffer_ptr, prev_block_row, next_block_row; + JSAMPARRAY output_ptr; + JDIMENSION output_col; + jpeg_component_info *compptr; + inverse_DCT_method_ptr inverse_DCT; + boolean first_row, last_row; + JBLOCK workspace; + int *coef_bits; + JQUANT_TBL *quanttbl; + INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; + int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; + int Al, pred; + + /* Force some input to be done if we are getting ahead of the input. */ + while (cinfo->input_scan_number <= cinfo->output_scan_number && + ! cinfo->inputctl->eoi_reached) { + if (cinfo->input_scan_number == cinfo->output_scan_number) { + /* If input is working on current scan, we ordinarily want it to + * have completed the current row. But if input scan is DC, + * we want it to keep one row ahead so that next block row's DC + * values are up to date. + */ + JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; + if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) + break; + } + if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) + return JPEG_SUSPENDED; + } + + /* OK, output from the virtual arrays. */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Don't bother to IDCT an uninteresting component. */ + if (! compptr->component_needed) + continue; + /* Count non-dummy DCT block rows in this iMCU row. */ + if (cinfo->output_iMCU_row < last_iMCU_row) { + block_rows = compptr->v_samp_factor; + access_rows = block_rows * 2; /* this and next iMCU row */ + last_row = FALSE; + } else { + /* NB: can't use last_row_height here; it is input-side-dependent! */ + block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (block_rows == 0) block_rows = compptr->v_samp_factor; + access_rows = block_rows; /* this iMCU row only */ + last_row = TRUE; + } + /* Align the virtual buffer for this component. */ + if (cinfo->output_iMCU_row > 0) { + access_rows += compptr->v_samp_factor; /* prior iMCU row too */ + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, + (JDIMENSION) access_rows, FALSE); + buffer += compptr->v_samp_factor; /* point to current iMCU row */ + first_row = FALSE; + } else { + buffer = (*cinfo->mem->access_virt_barray) + ((j_common_ptr) cinfo, coef->whole_image[ci], + (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); + first_row = TRUE; + } + /* Fetch component-dependent info */ + coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); + quanttbl = compptr->quant_table; + Q00 = quanttbl->quantval[0]; + Q01 = quanttbl->quantval[Q01_POS]; + Q10 = quanttbl->quantval[Q10_POS]; + Q20 = quanttbl->quantval[Q20_POS]; + Q11 = quanttbl->quantval[Q11_POS]; + Q02 = quanttbl->quantval[Q02_POS]; + inverse_DCT = cinfo->idct->inverse_DCT[ci]; + output_ptr = output_buf[ci]; + /* Loop over all DCT blocks to be processed. */ + for (block_row = 0; block_row < block_rows; block_row++) { + buffer_ptr = buffer[block_row]; + if (first_row && block_row == 0) + prev_block_row = buffer_ptr; + else + prev_block_row = buffer[block_row-1]; + if (last_row && block_row == block_rows-1) + next_block_row = buffer_ptr; + else + next_block_row = buffer[block_row+1]; + /* We fetch the surrounding DC values using a sliding-register approach. + * Initialize all nine here so as to do the right thing on narrow pics. + */ + DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; + DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; + DC7 = DC8 = DC9 = (int) next_block_row[0][0]; + output_col = 0; + last_block_column = compptr->width_in_blocks - 1; + for (block_num = 0; block_num <= last_block_column; block_num++) { + /* Fetch current DCT block into workspace so we can modify it. */ + jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); + /* Update DC values */ + if (block_num < last_block_column) { + DC3 = (int) prev_block_row[1][0]; + DC6 = (int) buffer_ptr[1][0]; + DC9 = (int) next_block_row[1][0]; + } + /* Compute coefficient estimates per K.8. + * An estimate is applied only if coefficient is still zero, + * and is not known to be fully accurate. + */ + /* AC01 */ + if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { + num = 36 * Q00 * (DC4 - DC6); + if (num >= 0) { + pred = (int) (((Q01<<7) + num) / (Q01<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q10<<7) + num) / (Q10<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q20<<7) + num) / (Q20<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q11<<7) + num) / (Q11<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { + pred = (int) (((Q02<<7) + num) / (Q02<<8)); + if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; + } + output_ptr += compptr->DCT_scaled_size; + } + } + + if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) + return JPEG_ROW_COMPLETED; + return JPEG_SCAN_COMPLETED; +} + +#endif /* BLOCK_SMOOTHING_SUPPORTED */ + + +/* + * Initialize coefficient buffer controller. + */ + +GLOBAL(void) +jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_coef_ptr coef; + + coef = (my_coef_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_coef_controller)); + cinfo->coef = (struct jpeg_d_coef_controller *) coef; + coef->pub.start_input_pass = start_input_pass; + coef->pub.start_output_pass = start_output_pass; +#ifdef BLOCK_SMOOTHING_SUPPORTED + coef->coef_bits_latch = NULL; +#endif + + /* Create the coefficient buffer. */ + if (need_full_buffer) { +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* Allocate a full-image virtual array for each component, */ + /* padded to a multiple of samp_factor DCT blocks in each direction. */ + /* Note we ask for a pre-zeroed array. */ + int ci, access_rows; + jpeg_component_info *compptr; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + access_rows = compptr->v_samp_factor; +#ifdef BLOCK_SMOOTHING_SUPPORTED + /* If block smoothing could be used, need a bigger window */ + if (cinfo->progressive_mode) + access_rows *= 3; +#endif + coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, + (JDIMENSION) jround_up((long) compptr->width_in_blocks, + (long) compptr->h_samp_factor), + (JDIMENSION) jround_up((long) compptr->height_in_blocks, + (long) compptr->v_samp_factor), + (JDIMENSION) access_rows); + } + coef->pub.consume_data = consume_data; + coef->pub.decompress_data = decompress_data; + coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + /* We only need a single-MCU buffer. */ + JBLOCKROW buffer; + int i; + + buffer = (JBLOCKROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { + coef->MCU_buffer[i] = buffer + i; + } + coef->pub.consume_data = dummy_consume_data; + coef->pub.decompress_data = decompress_onepass; + coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ + } +} diff --git a/libraries/external/jpeglib/jdcoefct.o b/libraries/external/jpeglib/jdcoefct.o new file mode 100644 index 0000000..047dd20 Binary files /dev/null and b/libraries/external/jpeglib/jdcoefct.o differ diff --git a/libraries/external/jpeglib/jdcolor.c b/libraries/external/jpeglib/jdcolor.c new file mode 100755 index 0000000..fd7b138 --- /dev/null +++ b/libraries/external/jpeglib/jdcolor.c @@ -0,0 +1,396 @@ +/* + * jdcolor.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains output colorspace conversion routines. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private subobject */ + +typedef struct { + struct jpeg_color_deconverter pub; /* public fields */ + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ +} my_color_deconverter; + +typedef my_color_deconverter * my_cconvert_ptr; + + +/**************** YCbCr -> RGB conversion: most common case **************/ + +/* + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. + * The conversion equations to be implemented are therefore + * R = Y + 1.40200 * Cr + * G = Y - 0.34414 * Cb - 0.71414 * Cr + * B = Y + 1.77200 * Cb + * where Cb and Cr represent the incoming values less CENTERJSAMPLE. + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) + * + * To avoid floating-point arithmetic, we represent the fractional constants + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide + * the products by 2^16, with appropriate rounding, to get the correct answer. + * Notice that Y, being an integral input, does not contribute any fraction + * so it need not participate in the rounding. + * + * For even more speed, we avoid doing any multiplications in the inner loop + * by precalculating the constants times Cb and Cr for all possible values. + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); + * for 12-bit samples it is still acceptable. It's not very reasonable for + * 16-bit samples, but if you want lossless storage you shouldn't be changing + * colorspace anyway. + * The Cr=>R and Cb=>B values can be rounded to integers in advance; the + * values for the G calculation are left scaled up, since we must add them + * together before rounding. + */ + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + int i; + INT32 x; + SHIFT_TEMPS + + cconvert->Cr_r_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cb_b_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + cconvert->Cr_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + cconvert->Cb_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.40200 * x */ + cconvert->Cr_r_tab[i] = (int) + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); + /* Cb=>B value is nearest int to 1.77200 * x */ + cconvert->Cb_b_tab[i] = (int) + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); + /* Cr=>G value is scaled-up -0.71414 * x */ + cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; + /* Cb=>G value is scaled-up -0.34414 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; + } +} + + +/* + * Convert some rows of samples to the output colorspace. + * + * Note that we change from noninterleaved, one-plane-per-component format + * to interleaved-pixel format. The output buffer is therefore three times + * as wide as the input buffer. + * A starting row offset is provided only for the input buffer. The caller + * can easily adjust the passed output_buf value to accommodate any row + * offset required on that side. + */ + +METHODDEF(void) +ycc_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses. */ + outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; + outptr[RGB_GREEN] = range_limit[y + + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS))]; + outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/**************** Cases other than YCbCr -> RGB **************/ + + +/* + * Color conversion for no colorspace change: just copy the data, + * converting from separate-planes to interleaved representation. + */ + +METHODDEF(void) +null_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW inptr, outptr; + register JDIMENSION count; + register int num_components = cinfo->num_components; + JDIMENSION num_cols = cinfo->output_width; + int ci; + + while (--num_rows >= 0) { + for (ci = 0; ci < num_components; ci++) { + inptr = input_buf[ci][input_row]; + outptr = output_buf[0] + ci; + for (count = num_cols; count > 0; count--) { + *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ + outptr += num_components; + } + } + input_row++; + output_buf++; + } +} + + +/* + * Color conversion for grayscale: just copy the data. + * This also works for YCbCr -> grayscale conversion, in which + * we just copy the Y (luminance) component and ignore chrominance. + */ + +METHODDEF(void) +grayscale_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, + num_rows, cinfo->output_width); +} + + +/* + * Convert grayscale to RGB: just duplicate the graylevel three times. + * This is provided to support applications that don't want to cope + * with grayscale as a separate case. + */ + +METHODDEF(void) +gray_rgb_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + register JSAMPROW inptr, outptr; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + + while (--num_rows >= 0) { + inptr = input_buf[0][input_row++]; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + /* We can dispense with GETJSAMPLE() here */ + outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; + outptr += RGB_PIXELSIZE; + } + } +} + + +/* + * Adobe-style YCCK->CMYK conversion. + * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same + * conversion as above, while passing K (black) unchanged. + * We assume build_ycc_rgb_table has been called. + */ + +METHODDEF(void) +ycck_cmyk_convert (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows) +{ + my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; + register int y, cb, cr; + register JSAMPROW outptr; + register JSAMPROW inptr0, inptr1, inptr2, inptr3; + register JDIMENSION col; + JDIMENSION num_cols = cinfo->output_width; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + register int * Crrtab = cconvert->Cr_r_tab; + register int * Cbbtab = cconvert->Cb_b_tab; + register INT32 * Crgtab = cconvert->Cr_g_tab; + register INT32 * Cbgtab = cconvert->Cb_g_tab; + SHIFT_TEMPS + + while (--num_rows >= 0) { + inptr0 = input_buf[0][input_row]; + inptr1 = input_buf[1][input_row]; + inptr2 = input_buf[2][input_row]; + inptr3 = input_buf[3][input_row]; + input_row++; + outptr = *output_buf++; + for (col = 0; col < num_cols; col++) { + y = GETJSAMPLE(inptr0[col]); + cb = GETJSAMPLE(inptr1[col]); + cr = GETJSAMPLE(inptr2[col]); + /* Range-limiting is essential due to noise introduced by DCT losses. */ + outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ + outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], + SCALEBITS)))]; + outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ + /* K passes through unchanged */ + outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ + outptr += 4; + } + } +} + + +/* + * Empty method for start_pass. + */ + +METHODDEF(void) +start_pass_dcolor (j_decompress_ptr cinfo) +{ + /* no work needed */ +} + + +/* + * Module initialization routine for output colorspace conversion. + */ + +GLOBAL(void) +jinit_color_deconverter (j_decompress_ptr cinfo) +{ + my_cconvert_ptr cconvert; + int ci; + + cconvert = (my_cconvert_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_color_deconverter)); + cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; + cconvert->pub.start_pass = start_pass_dcolor; + + /* Make sure num_components agrees with jpeg_color_space */ + switch (cinfo->jpeg_color_space) { + case JCS_GRAYSCALE: + if (cinfo->num_components != 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_RGB: + case JCS_YCbCr: + if (cinfo->num_components != 3) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + case JCS_CMYK: + case JCS_YCCK: + if (cinfo->num_components != 4) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + + default: /* JCS_UNKNOWN can be anything */ + if (cinfo->num_components < 1) + ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); + break; + } + + /* Set out_color_components and conversion method based on requested space. + * Also clear the component_needed flags for any unused components, + * so that earlier pipeline stages can avoid useless computation. + */ + + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + if (cinfo->jpeg_color_space == JCS_GRAYSCALE || + cinfo->jpeg_color_space == JCS_YCbCr) { + cconvert->pub.color_convert = grayscale_convert; + /* For color->grayscale conversion, only the Y (0) component is needed */ + for (ci = 1; ci < cinfo->num_components; ci++) + cinfo->comp_info[ci].component_needed = FALSE; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_RGB: + cinfo->out_color_components = RGB_PIXELSIZE; + if (cinfo->jpeg_color_space == JCS_YCbCr) { + cconvert->pub.color_convert = ycc_rgb_convert; + build_ycc_rgb_table(cinfo); + } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { + cconvert->pub.color_convert = gray_rgb_convert; + } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { + cconvert->pub.color_convert = null_convert; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + case JCS_CMYK: + cinfo->out_color_components = 4; + if (cinfo->jpeg_color_space == JCS_YCCK) { + cconvert->pub.color_convert = ycck_cmyk_convert; + build_ycc_rgb_table(cinfo); + } else if (cinfo->jpeg_color_space == JCS_CMYK) { + cconvert->pub.color_convert = null_convert; + } else + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + + default: + /* Permit null conversion to same output space */ + if (cinfo->out_color_space == cinfo->jpeg_color_space) { + cinfo->out_color_components = cinfo->num_components; + cconvert->pub.color_convert = null_convert; + } else /* unsupported non-null conversion */ + ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); + break; + } + + if (cinfo->quantize_colors) + cinfo->output_components = 1; /* single colormapped output component */ + else + cinfo->output_components = cinfo->out_color_components; +} diff --git a/libraries/external/jpeglib/jdcolor.o b/libraries/external/jpeglib/jdcolor.o new file mode 100644 index 0000000..ab564e5 Binary files /dev/null and b/libraries/external/jpeglib/jdcolor.o differ diff --git a/libraries/external/jpeglib/jdct.h b/libraries/external/jpeglib/jdct.h new file mode 100755 index 0000000..b664cab --- /dev/null +++ b/libraries/external/jpeglib/jdct.h @@ -0,0 +1,176 @@ +/* + * jdct.h + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file contains common declarations for the forward and + * inverse DCT modules. These declarations are private to the DCT managers + * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. + * The individual DCT algorithms are kept in separate files to ease + * machine-dependent tuning (e.g., assembly coding). + */ + + +/* + * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; + * the DCT is to be performed in-place in that buffer. Type DCTELEM is int + * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT + * implementations use an array of type FAST_FLOAT, instead.) + * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). + * The DCT outputs are returned scaled up by a factor of 8; they therefore + * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This + * convention improves accuracy in integer implementations and saves some + * work in floating-point ones. + * Quantization of the output coefficients is done by jcdctmgr.c. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef int DCTELEM; /* 16 or 32 bits is fine */ +#else +typedef INT32 DCTELEM; /* must have 32 bits */ +#endif + +typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); +typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); + + +/* + * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer + * to an output sample array. The routine must dequantize the input data as + * well as perform the IDCT; for dequantization, it uses the multiplier table + * pointed to by compptr->dct_table. The output data is to be placed into the + * sample array starting at a specified column. (Any row offset needed will + * be applied to the array pointer before it is passed to the IDCT code.) + * Note that the number of samples emitted by the IDCT routine is + * DCT_scaled_size * DCT_scaled_size. + */ + +/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ + +/* + * Each IDCT routine has its own ideas about the best dct_table element type. + */ + +typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ +#if BITS_IN_JSAMPLE == 8 +typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ +#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ +#else +typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ +#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ +#endif +typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ + + +/* + * Each IDCT routine is responsible for range-limiting its results and + * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could + * be quite far out of range if the input data is corrupt, so a bulletproof + * range-limiting step is required. We use a mask-and-table-lookup method + * to do the combined operations quickly. See the comments with + * prepare_range_limit_table (in jdmaster.c) for more info. + */ + +#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) + +#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_fdct_islow jFDislow +#define jpeg_fdct_ifast jFDifast +#define jpeg_fdct_float jFDfloat +#define jpeg_idct_islow jRDislow +#define jpeg_idct_ifast jRDifast +#define jpeg_idct_float jRDfloat +#define jpeg_idct_4x4 jRD4x4 +#define jpeg_idct_2x2 jRD2x2 +#define jpeg_idct_1x1 jRD1x1 +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + +/* Extern declarations for the forward and inverse DCT routines. */ + +EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); +EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); +EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); + +EXTERN(void) jpeg_idct_islow + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_ifast + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_float + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_4x4 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_2x2 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); +EXTERN(void) jpeg_idct_1x1 + JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); + + +/* + * Macros for handling fixed-point arithmetic; these are used by many + * but not all of the DCT/IDCT modules. + * + * All values are expected to be of type INT32. + * Fractional constants are scaled left by CONST_BITS bits. + * CONST_BITS is defined within each module using these macros, + * and may differ from one module to the next. + */ + +#define ONE ((INT32) 1) +#define CONST_SCALE (ONE << CONST_BITS) + +/* Convert a positive real constant to an integer scaled by CONST_SCALE. + * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, + * thus causing a lot of useless floating-point operations at run time. + */ + +#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) + +/* Descale and correctly round an INT32 value that's scaled by N bits. + * We assume RIGHT_SHIFT rounds towards minus infinity, so adding + * the fudge factor is correct for either sign of X. + */ + +#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * This macro is used only when the two inputs will actually be no more than + * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a + * full 32x32 multiply. This provides a useful speedup on many machines. + * Unfortunately there is no way to specify a 16x16->32 multiply portably + * in C, but some C compilers will do the right thing if you provide the + * correct combination of casts. + */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) +#endif +#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ +#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) +#endif + +#ifndef MULTIPLY16C16 /* default definition */ +#define MULTIPLY16C16(var,const) ((var) * (const)) +#endif + +/* Same except both inputs are variables. */ + +#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ +#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) +#endif + +#ifndef MULTIPLY16V16 /* default definition */ +#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) +#endif diff --git a/libraries/external/jpeglib/jddctmgr.c b/libraries/external/jpeglib/jddctmgr.c new file mode 100755 index 0000000..0e44eb1 --- /dev/null +++ b/libraries/external/jpeglib/jddctmgr.c @@ -0,0 +1,269 @@ +/* + * jddctmgr.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the inverse-DCT management logic. + * This code selects a particular IDCT implementation to be used, + * and it performs related housekeeping chores. No code in this file + * is executed per IDCT step, only during output pass setup. + * + * Note that the IDCT routines are responsible for performing coefficient + * dequantization as well as the IDCT proper. This module sets up the + * dequantization multiplier table needed by the IDCT routine. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + + +/* + * The decompressor input side (jdinput.c) saves away the appropriate + * quantization table for each component at the start of the first scan + * involving that component. (This is necessary in order to correctly + * decode files that reuse Q-table slots.) + * When we are ready to make an output pass, the saved Q-table is converted + * to a multiplier table that will actually be used by the IDCT routine. + * The multiplier table contents are IDCT-method-dependent. To support + * application changes in IDCT method between scans, we can remake the + * multiplier tables if necessary. + * In buffered-image mode, the first output pass may occur before any data + * has been seen for some components, and thus before their Q-tables have + * been saved away. To handle this case, multiplier tables are preset + * to zeroes; the result of the IDCT will be a neutral gray level. + */ + + +/* Private subobject for this module */ + +typedef struct { + struct jpeg_inverse_dct pub; /* public fields */ + + /* This array contains the IDCT method code that each multiplier table + * is currently set up for, or -1 if it's not yet set up. + * The actual multiplier tables are pointed to by dct_table in the + * per-component comp_info structures. + */ + int cur_method[MAX_COMPONENTS]; +} my_idct_controller; + +typedef my_idct_controller * my_idct_ptr; + + +/* Allocated multiplier tables: big enough for any supported variant */ + +typedef union { + ISLOW_MULT_TYPE islow_array[DCTSIZE2]; +#ifdef DCT_IFAST_SUPPORTED + IFAST_MULT_TYPE ifast_array[DCTSIZE2]; +#endif +#ifdef DCT_FLOAT_SUPPORTED + FLOAT_MULT_TYPE float_array[DCTSIZE2]; +#endif +} multiplier_table; + + +/* The current scaled-IDCT routines require ISLOW-style multiplier tables, + * so be sure to compile that code if either ISLOW or SCALING is requested. + */ +#ifdef DCT_ISLOW_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#else +#ifdef IDCT_SCALING_SUPPORTED +#define PROVIDE_ISLOW_TABLES +#endif +#endif + + +/* + * Prepare for an output pass. + * Here we select the proper IDCT routine for each component and build + * a matching multiplier table. + */ + +METHODDEF(void) +start_pass (j_decompress_ptr cinfo) +{ + my_idct_ptr idct = (my_idct_ptr) cinfo->idct; + int ci, i; + jpeg_component_info *compptr; + int method = 0; + inverse_DCT_method_ptr method_ptr = NULL; + JQUANT_TBL * qtbl; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Select the proper IDCT routine for this component's scaling */ + switch (compptr->DCT_scaled_size) { +#ifdef IDCT_SCALING_SUPPORTED + case 1: + method_ptr = jpeg_idct_1x1; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; + case 2: + method_ptr = jpeg_idct_2x2; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; + case 4: + method_ptr = jpeg_idct_4x4; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; +#endif + case DCTSIZE: + switch (cinfo->dct_method) { +#ifdef DCT_ISLOW_SUPPORTED + case JDCT_ISLOW: + method_ptr = jpeg_idct_islow; + method = JDCT_ISLOW; + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + method_ptr = jpeg_idct_ifast; + method = JDCT_IFAST; + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + method_ptr = jpeg_idct_float; + method = JDCT_FLOAT; + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + break; + default: + ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); + break; + } + idct->pub.inverse_DCT[ci] = method_ptr; + /* Create multiplier table from quant table. + * However, we can skip this if the component is uninteresting + * or if we already built the table. Also, if no quant table + * has yet been saved for the component, we leave the + * multiplier table all-zero; we'll be reading zeroes from the + * coefficient controller's buffer anyway. + */ + if (! compptr->component_needed || idct->cur_method[ci] == method) + continue; + qtbl = compptr->quant_table; + if (qtbl == NULL) /* happens if no data yet for component */ + continue; + idct->cur_method[ci] = method; + switch (method) { +#ifdef PROVIDE_ISLOW_TABLES + case JDCT_ISLOW: + { + /* For LL&M IDCT method, multipliers are equal to raw quantization + * coefficients, but are stored as ints to ensure access efficiency. + */ + ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; + for (i = 0; i < DCTSIZE2; i++) { + ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; + } + } + break; +#endif +#ifdef DCT_IFAST_SUPPORTED + case JDCT_IFAST: + { + /* For AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + * For integer operation, the multiplier table is to be scaled by + * IFAST_SCALE_BITS. + */ + IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; +#define CONST_BITS 14 + static const INT16 aanscales[DCTSIZE2] = { + /* precomputed values scaled up by 14 bits */ + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, + 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, + 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, + 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, + 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, + 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, + 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 + }; + SHIFT_TEMPS + + for (i = 0; i < DCTSIZE2; i++) { + ifmtbl[i] = (IFAST_MULT_TYPE) + DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], + (INT32) aanscales[i]), + CONST_BITS-IFAST_SCALE_BITS); + } + } + break; +#endif +#ifdef DCT_FLOAT_SUPPORTED + case JDCT_FLOAT: + { + /* For float AA&N IDCT method, multipliers are equal to quantization + * coefficients scaled by scalefactor[row]*scalefactor[col], where + * scalefactor[0] = 1 + * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 + */ + FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; + int row, col; + static const double aanscalefactor[DCTSIZE] = { + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + }; + + i = 0; + for (row = 0; row < DCTSIZE; row++) { + for (col = 0; col < DCTSIZE; col++) { + fmtbl[i] = (FLOAT_MULT_TYPE) + ((double) qtbl->quantval[i] * + aanscalefactor[row] * aanscalefactor[col]); + i++; + } + } + } + break; +#endif + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } + } +} + + +/* + * Initialize IDCT manager. + */ + +GLOBAL(void) +jinit_inverse_dct (j_decompress_ptr cinfo) +{ + my_idct_ptr idct; + int ci; + jpeg_component_info *compptr; + + idct = (my_idct_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_idct_controller)); + cinfo->idct = (struct jpeg_inverse_dct *) idct; + idct->pub.start_pass = start_pass; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Allocate and pre-zero a multiplier table for each component */ + compptr->dct_table = + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(multiplier_table)); + MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); + /* Mark multiplier table not yet set up for any method */ + idct->cur_method[ci] = -1; + } +} diff --git a/libraries/external/jpeglib/jddctmgr.o b/libraries/external/jpeglib/jddctmgr.o new file mode 100644 index 0000000..f297a1a Binary files /dev/null and b/libraries/external/jpeglib/jddctmgr.o differ diff --git a/libraries/external/jpeglib/jdhuff.c b/libraries/external/jpeglib/jdhuff.c new file mode 100755 index 0000000..b2ad66d --- /dev/null +++ b/libraries/external/jpeglib/jdhuff.c @@ -0,0 +1,651 @@ +/* + * jdhuff.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdhuff.h" /* Declarations shared with jdphuff.c */ + + +/* + * Expanded entropy decoder object for Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; + d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; + + /* Precalculated info set up by start_pass for use in decode_mcu: */ + + /* Pointers to derived tables to be used for each block within an MCU */ + d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; + d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; + /* Whether we care about the DC and AC coefficient values for each block */ + boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; + boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; +} huff_entropy_decoder; + +typedef huff_entropy_decoder * huff_entropy_ptr; + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci, blkn, dctbl, actbl; + jpeg_component_info * compptr; + + /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. + * This ought to be an error condition, but we make it a warning because + * there are some baseline files out there with all zeroes in these bytes. + */ + if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || + cinfo->Ah != 0 || cinfo->Al != 0) + WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + dctbl = compptr->dc_tbl_no; + actbl = compptr->ac_tbl_no; + /* Compute derived values for Huffman tables */ + /* We may do this more than once for a table, but it's not expensive */ + jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, + & entropy->dc_derived_tbls[dctbl]); + jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, + & entropy->ac_derived_tbls[actbl]); + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Precalculate decoding info for each block in an MCU of this scan */ + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + /* Precalculate which table to use for each block */ + entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; + entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; + /* Decide whether we really care about the coefficient values */ + if (compptr->component_needed) { + entropy->dc_needed[blkn] = TRUE; + /* we don't need the ACs if producing a 1/8th-size image */ + entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); + } else { + entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; + } + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->pub.insufficient_data = FALSE; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Compute the derived values for a Huffman table. + * This routine also performs some validation checks on the table. + * + * Note this is also used by jdphuff.c. + */ + +GLOBAL(void) +jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, + d_derived_tbl ** pdtbl) +{ + JHUFF_TBL *htbl; + d_derived_tbl *dtbl; + int p, i, l, si, numsymbols; + int lookbits, ctr; + char huffsize[257]; + unsigned int huffcode[257]; + unsigned int code; + + /* Note that huffsize[] and huffcode[] are filled in code-length order, + * paralleling the order of the symbols themselves in htbl->huffval[]. + */ + + /* Find the input Huffman table */ + if (tblno < 0 || tblno >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + htbl = + isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; + if (htbl == NULL) + ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); + + /* Allocate a workspace if we haven't already done so. */ + if (*pdtbl == NULL) + *pdtbl = (d_derived_tbl *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(d_derived_tbl)); + dtbl = *pdtbl; + dtbl->pub = htbl; /* fill in back link */ + + /* Figure C.1: make table of Huffman code length for each symbol */ + + p = 0; + for (l = 1; l <= 16; l++) { + i = (int) htbl->bits[l]; + if (i < 0 || p + i > 256) /* protect against table overrun */ + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + while (i--) + huffsize[p++] = (char) l; + } + huffsize[p] = 0; + numsymbols = p; + + /* Figure C.2: generate the codes themselves */ + /* We also validate that the counts represent a legal Huffman code tree. */ + + code = 0; + si = huffsize[0]; + p = 0; + while (huffsize[p]) { + while (((int) huffsize[p]) == si) { + huffcode[p++] = code; + code++; + } + /* code is now 1 more than the last code used for codelength si; but + * it must still fit in si bits, since no code is allowed to be all ones. + */ + if (((INT32) code) >= (((INT32) 1) << si)) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + code <<= 1; + si++; + } + + /* Figure F.15: generate decoding tables for bit-sequential decoding */ + + p = 0; + for (l = 1; l <= 16; l++) { + if (htbl->bits[l]) { + /* valoffset[l] = huffval[] index of 1st symbol of code length l, + * minus the minimum code of length l + */ + dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; + p += htbl->bits[l]; + dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ + } else { + dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ + } + } + dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ + + /* Compute lookahead tables to speed up decoding. + * First we set all the table entries to 0, indicating "too long"; + * then we iterate through the Huffman codes that are short enough and + * fill in all the entries that correspond to bit sequences starting + * with that code. + */ + + MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); + + p = 0; + for (l = 1; l <= HUFF_LOOKAHEAD; l++) { + for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { + /* l = current code's length, p = its index in huffcode[] & huffval[]. */ + /* Generate left-justified code followed by all possible bit sequences */ + lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); + for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { + dtbl->look_nbits[lookbits] = l; + dtbl->look_sym[lookbits] = htbl->huffval[p]; + lookbits++; + } + } + } + + /* Validate symbols as being reasonable. + * For AC tables, we make no check, but accept all byte values 0..255. + * For DC tables, we require the symbols to be in range 0..15. + * (Tighter bounds could be applied depending on the data depth and mode, + * but this is sufficient to ensure safe decoding.) + */ + if (isDC) { + for (i = 0; i < numsymbols; i++) { + int sym = htbl->huffval[i]; + if (sym < 0 || sym > 15) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + } + } +} + + +/* + * Out-of-line code for bit fetching (shared with jdphuff.c). + * See jdhuff.h for info about usage. + * Note: current values of get_buffer and bits_left are passed as parameters, + * but are returned in the corresponding fields of the state struct. + * + * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width + * of get_buffer to be used. (On machines with wider words, an even larger + * buffer could be used.) However, on some machines 32-bit shifts are + * quite slow and take time proportional to the number of places shifted. + * (This is true with most PC compilers, for instance.) In this case it may + * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the + * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. + */ + +#ifdef SLOW_SHIFT_32 +#define MIN_GET_BITS 15 /* minimum allowable value */ +#else +#define MIN_GET_BITS (BIT_BUF_SIZE-7) +#endif + + +GLOBAL(boolean) +jpeg_fill_bit_buffer (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + int nbits) +/* Load up the bit buffer to a depth of at least nbits */ +{ + /* Copy heavily used state fields into locals (hopefully registers) */ + register const JOCTET * next_input_byte = state->next_input_byte; + register size_t bytes_in_buffer = state->bytes_in_buffer; + j_decompress_ptr cinfo = state->cinfo; + + /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ + /* (It is assumed that no request will be for more than that many bits.) */ + /* We fail to do so only if we hit a marker or are forced to suspend. */ + + if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ + while (bits_left < MIN_GET_BITS) { + register int c; + + /* Attempt to read a byte */ + if (bytes_in_buffer == 0) { + if (! (*cinfo->src->fill_input_buffer) (cinfo)) + return FALSE; + next_input_byte = cinfo->src->next_input_byte; + bytes_in_buffer = cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + + /* If it's 0xFF, check and discard stuffed zero byte */ + if (c == 0xFF) { + /* Loop here to discard any padding FF's on terminating marker, + * so that we can save a valid unread_marker value. NOTE: we will + * accept multiple FF's followed by a 0 as meaning a single FF data + * byte. This data pattern is not valid according to the standard. + */ + do { + if (bytes_in_buffer == 0) { + if (! (*cinfo->src->fill_input_buffer) (cinfo)) + return FALSE; + next_input_byte = cinfo->src->next_input_byte; + bytes_in_buffer = cinfo->src->bytes_in_buffer; + } + bytes_in_buffer--; + c = GETJOCTET(*next_input_byte++); + } while (c == 0xFF); + + if (c == 0) { + /* Found FF/00, which represents an FF data byte */ + c = 0xFF; + } else { + /* Oops, it's actually a marker indicating end of compressed data. + * Save the marker code for later use. + * Fine point: it might appear that we should save the marker into + * bitread working state, not straight into permanent state. But + * once we have hit a marker, we cannot need to suspend within the + * current MCU, because we will read no more bytes from the data + * source. So it is OK to update permanent state right away. + */ + cinfo->unread_marker = c; + /* See if we need to insert some fake zero bits. */ + goto no_more_bytes; + } + } + + /* OK, load c into get_buffer */ + get_buffer = (get_buffer << 8) | c; + bits_left += 8; + } /* end while */ + } else { + no_more_bytes: + /* We get here if we've read the marker that terminates the compressed + * data segment. There should be enough bits in the buffer register + * to satisfy the request; if so, no problem. + */ + if (nbits > bits_left) { + /* Uh-oh. Report corrupted data to user and stuff zeroes into + * the data stream, so that we can produce some kind of image. + * We use a nonvolatile flag to ensure that only one warning message + * appears per data segment. + */ + if (! cinfo->entropy->insufficient_data) { + WARNMS(cinfo, JWRN_HIT_MARKER); + cinfo->entropy->insufficient_data = TRUE; + } + /* Fill the buffer with zero bits */ + get_buffer <<= MIN_GET_BITS - bits_left; + bits_left = MIN_GET_BITS; + } + } + + /* Unload the local registers */ + state->next_input_byte = next_input_byte; + state->bytes_in_buffer = bytes_in_buffer; + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + return TRUE; +} + + +/* + * Out-of-line code for Huffman code decoding. + * See jdhuff.h for info about usage. + */ + +GLOBAL(int) +jpeg_huff_decode (bitread_working_state * state, + register bit_buf_type get_buffer, register int bits_left, + d_derived_tbl * htbl, int min_bits) +{ + register int l = min_bits; + register INT32 code; + + /* HUFF_DECODE has determined that the code is at least min_bits */ + /* bits long, so fetch that many bits in one swoop. */ + + CHECK_BIT_BUFFER(*state, l, return -1); + code = GET_BITS(l); + + /* Collect the rest of the Huffman code one bit at a time. */ + /* This is per Figure F.16 in the JPEG spec. */ + + while (code > htbl->maxcode[l]) { + code <<= 1; + CHECK_BIT_BUFFER(*state, 1, return -1); + code |= GET_BITS(1); + l++; + } + + /* Unload the local registers */ + state->get_buffer = get_buffer; + state->bits_left = bits_left; + + /* With garbage input we may reach the sentinel value l = 17. */ + + if (l > 16) { + WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); + return 0; /* fake a zero as the safest result */ + } + + return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and add will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) + +#else + +#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) + +static const int extend_test[16] = /* entry n is 2**(n-1) */ + { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, + 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; + +static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ + { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, + ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, + ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, + ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; + +#endif /* AVOID_TABLES */ + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int ci; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Reset out-of-data flag, unless read_restart_marker left us smack up + * against a marker. In that case we will end up treating the next data + * segment as empty, and we can avoid producing bogus output pixels by + * leaving the flag set. + */ + if (cinfo->unread_marker == 0) + entropy->pub.insufficient_data = FALSE; + + return TRUE; +} + + +/* + * Decode and return one MCU's worth of Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. + * (Wholesale zeroing is usually a little faster than retail...) + * + * Returns FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * this module, since we'll just re-assign them on the next call.) + */ + +METHODDEF(boolean) +decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; + int blkn; + BITREAD_STATE_VARS; + savable_state state; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + JBLOCKROW block = MCU_data[blkn]; + d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; + d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; + register int s, k, r; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + if (entropy->dc_needed[blkn]) { + /* Convert DC difference to actual value, update last_dc_val */ + int ci = cinfo->MCU_membership[blkn]; + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ + (*block)[0] = (JCOEF) s; + } + + if (entropy->ac_needed[blkn]) { + + /* Section F.2.2.2: decode the AC coefficients */ + /* Since zeroes are skipped, output area must be cleared beforehand */ + for (k = 1; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, actbl, return FALSE, label2); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Output coefficient in natural (dezigzagged) order. + * Note: the extra entries in jpeg_natural_order[] will save us + * if k >= DCTSIZE2, which could happen if the data is corrupted. + */ + (*block)[jpeg_natural_order[k]] = (JCOEF) s; + } else { + if (r != 15) + break; + k += 15; + } + } + + } else { + + /* Section F.2.2.2: decode the AC coefficients */ + /* In this path we just discard the values */ + for (k = 1; k < DCTSIZE2; k++) { + HUFF_DECODE(s, br_state, actbl, return FALSE, label3); + + r = s >> 4; + s &= 15; + + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + DROP_BITS(s); + } else { + if (r != 15) + break; + k += 15; + } + } + + } + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * Module initialization routine for Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_huff_decoder (j_decompress_ptr cinfo) +{ + huff_entropy_ptr entropy; + int i; + + entropy = (huff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(huff_entropy_decoder)); + cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; + entropy->pub.start_pass = start_pass_huff_decoder; + entropy->pub.decode_mcu = decode_mcu; + + /* Mark tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; + } +} diff --git a/libraries/external/jpeglib/jdhuff.h b/libraries/external/jpeglib/jdhuff.h new file mode 100755 index 0000000..12c0747 --- /dev/null +++ b/libraries/external/jpeglib/jdhuff.h @@ -0,0 +1,201 @@ +/* + * jdhuff.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains declarations for Huffman entropy decoding routines + * that are shared between the sequential decoder (jdhuff.c) and the + * progressive decoder (jdphuff.c). No other modules need to see these. + */ + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_make_d_derived_tbl jMkDDerived +#define jpeg_fill_bit_buffer jFilBitBuf +#define jpeg_huff_decode jHufDecode +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Derived data constructed for each Huffman table */ + +#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ + +typedef struct { + /* Basic tables: (element [0] of each array is unused) */ + INT32 maxcode[18]; /* largest code of length k (-1 if none) */ + /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ + INT32 valoffset[17]; /* huffval[] offset for codes of length k */ + /* valoffset[k] = huffval[] index of 1st symbol of code length k, less + * the smallest code of length k; so given a code of length k, the + * corresponding symbol is huffval[code + valoffset[k]] + */ + + /* Link to public Huffman table (needed only in jpeg_huff_decode) */ + JHUFF_TBL *pub; + + /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of + * the input data stream. If the next Huffman code is no more + * than HUFF_LOOKAHEAD bits long, we can obtain its length and + * the corresponding symbol directly from these tables. + */ + int look_nbits[1< 32 bits on your machine, and shifting/masking longs is + * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE + * appropriately should be a win. Unfortunately we can't define the size + * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) + * because not all machines measure sizeof in 8-bit bytes. + */ + +typedef struct { /* Bitreading state saved across MCUs */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ +} bitread_perm_state; + +typedef struct { /* Bitreading working state within an MCU */ + /* Current data source location */ + /* We need a copy, rather than munging the original, in case of suspension */ + const JOCTET * next_input_byte; /* => next byte to read from source */ + size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ + /* Bit input buffer --- note these values are kept in register variables, + * not in this struct, inside the inner loops. + */ + bit_buf_type get_buffer; /* current bit-extraction buffer */ + int bits_left; /* # of unused bits in it */ + /* Pointer needed by jpeg_fill_bit_buffer. */ + j_decompress_ptr cinfo; /* back link to decompress master record */ +} bitread_working_state; + +/* Macros to declare and load/save bitread local variables. */ +#define BITREAD_STATE_VARS \ + register bit_buf_type get_buffer; \ + register int bits_left; \ + bitread_working_state br_state + +#define BITREAD_LOAD_STATE(cinfop,permstate) \ + br_state.cinfo = cinfop; \ + br_state.next_input_byte = cinfop->src->next_input_byte; \ + br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ + get_buffer = permstate.get_buffer; \ + bits_left = permstate.bits_left; + +#define BITREAD_SAVE_STATE(cinfop,permstate) \ + cinfop->src->next_input_byte = br_state.next_input_byte; \ + cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ + permstate.get_buffer = get_buffer; \ + permstate.bits_left = bits_left + +/* + * These macros provide the in-line portion of bit fetching. + * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer + * before using GET_BITS, PEEK_BITS, or DROP_BITS. + * The variables get_buffer and bits_left are assumed to be locals, + * but the state struct might not be (jpeg_huff_decode needs this). + * CHECK_BIT_BUFFER(state,n,action); + * Ensure there are N bits in get_buffer; if suspend, take action. + * val = GET_BITS(n); + * Fetch next N bits. + * val = PEEK_BITS(n); + * Fetch next N bits without removing them from the buffer. + * DROP_BITS(n); + * Discard next N bits. + * The value N should be a simple variable, not an expression, because it + * is evaluated multiple times. + */ + +#define CHECK_BIT_BUFFER(state,nbits,action) \ + { if (bits_left < (nbits)) { \ + if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ + { action; } \ + get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } + +#define GET_BITS(nbits) \ + (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) + +#define PEEK_BITS(nbits) \ + (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) + +#define DROP_BITS(nbits) \ + (bits_left -= (nbits)) + +/* Load up the bit buffer to a depth of at least nbits */ +EXTERN(boolean) jpeg_fill_bit_buffer + JPP((bitread_working_state * state, register bit_buf_type get_buffer, + register int bits_left, int nbits)); + + +/* + * Code for extracting next Huffman-coded symbol from input bit stream. + * Again, this is time-critical and we make the main paths be macros. + * + * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits + * without looping. Usually, more than 95% of the Huffman codes will be 8 + * or fewer bits long. The few overlength codes are handled with a loop, + * which need not be inline code. + * + * Notes about the HUFF_DECODE macro: + * 1. Near the end of the data segment, we may fail to get enough bits + * for a lookahead. In that case, we do it the hard way. + * 2. If the lookahead table contains no entry, the next code must be + * more than HUFF_LOOKAHEAD bits long. + * 3. jpeg_huff_decode returns -1 if forced to suspend. + */ + +#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ +{ register int nb, look; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + if (bits_left < HUFF_LOOKAHEAD) { \ + nb = 1; goto slowlabel; \ + } \ + } \ + look = PEEK_BITS(HUFF_LOOKAHEAD); \ + if ((nb = htbl->look_nbits[look]) != 0) { \ + DROP_BITS(nb); \ + result = htbl->look_sym[look]; \ + } else { \ + nb = HUFF_LOOKAHEAD+1; \ +slowlabel: \ + if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ + { failaction; } \ + get_buffer = state.get_buffer; bits_left = state.bits_left; \ + } \ +} + +/* Out-of-line case for Huffman code fetching */ +EXTERN(int) jpeg_huff_decode + JPP((bitread_working_state * state, register bit_buf_type get_buffer, + register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/libraries/external/jpeglib/jdhuff.o b/libraries/external/jpeglib/jdhuff.o new file mode 100644 index 0000000..6a938c4 Binary files /dev/null and b/libraries/external/jpeglib/jdhuff.o differ diff --git a/libraries/external/jpeglib/jdinput.c b/libraries/external/jpeglib/jdinput.c new file mode 100755 index 0000000..2d5c747 --- /dev/null +++ b/libraries/external/jpeglib/jdinput.c @@ -0,0 +1,381 @@ +/* + * jdinput.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains input control logic for the JPEG decompressor. + * These routines are concerned with controlling the decompressor's input + * processing (marker reading and coefficient decoding). The actual input + * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_input_controller pub; /* public fields */ + + boolean inheaders; /* TRUE until first SOS is reached */ +} my_input_controller; + +typedef my_input_controller * my_inputctl_ptr; + + +/* Forward declarations */ +METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); + + +/* + * Routines to calculate various quantities related to the size of the image. + */ + +LOCAL(void) +initial_setup (j_decompress_ptr cinfo) +/* Called once, when first SOS marker is reached */ +{ + int ci; + jpeg_component_info *compptr; + + /* Make sure image isn't bigger than I can handle */ + if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || + (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) + ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); + + /* For now, precision must match compiled-in value... */ + if (cinfo->data_precision != BITS_IN_JSAMPLE) + ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); + + /* Check that number of components won't exceed internal array sizes */ + if (cinfo->num_components > MAX_COMPONENTS) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, + MAX_COMPONENTS); + + /* Compute maximum sampling factors; check factor validity */ + cinfo->max_h_samp_factor = 1; + cinfo->max_v_samp_factor = 1; + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || + compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) + ERREXIT(cinfo, JERR_BAD_SAMPLING); + cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, + compptr->h_samp_factor); + cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, + compptr->v_samp_factor); + } + + /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. + * In the full decompressor, this will be overridden by jdmaster.c; + * but in the transcoder, jdmaster.c is not used, so we must do it here. + */ + cinfo->min_DCT_scaled_size = DCTSIZE; + + /* Compute dimensions of components */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->DCT_scaled_size = DCTSIZE; + /* Size in DCT blocks */ + compptr->width_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->height_in_blocks = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + /* downsampled_width and downsampled_height will also be overridden by + * jdmaster.c if we are doing full decompression. The transcoder library + * doesn't use these values, but the calling application might. + */ + /* Size in samples */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, + (long) cinfo->max_h_samp_factor); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, + (long) cinfo->max_v_samp_factor); + /* Mark component needed, until color conversion says otherwise */ + compptr->component_needed = TRUE; + /* Mark no quantization table yet saved for component */ + compptr->quant_table = NULL; + } + + /* Compute number of fully interleaved MCU rows. */ + cinfo->total_iMCU_rows = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + /* Decide whether file contains multiple scans */ + if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) + cinfo->inputctl->has_multiple_scans = TRUE; + else + cinfo->inputctl->has_multiple_scans = FALSE; +} + + +LOCAL(void) +per_scan_setup (j_decompress_ptr cinfo) +/* Do computations that are needed before processing a JPEG scan */ +/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ +{ + int ci, mcublks, tmp; + jpeg_component_info *compptr; + + if (cinfo->comps_in_scan == 1) { + + /* Noninterleaved (single-component) scan */ + compptr = cinfo->cur_comp_info[0]; + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = compptr->width_in_blocks; + cinfo->MCU_rows_in_scan = compptr->height_in_blocks; + + /* For noninterleaved scan, always one block per MCU */ + compptr->MCU_width = 1; + compptr->MCU_height = 1; + compptr->MCU_blocks = 1; + compptr->MCU_sample_width = compptr->DCT_scaled_size; + compptr->last_col_width = 1; + /* For noninterleaved scans, it is convenient to define last_row_height + * as the number of block rows present in the last iMCU row. + */ + tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + if (tmp == 0) tmp = compptr->v_samp_factor; + compptr->last_row_height = tmp; + + /* Prepare array describing MCU composition */ + cinfo->blocks_in_MCU = 1; + cinfo->MCU_membership[0] = 0; + + } else { + + /* Interleaved (multi-component) scan */ + if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) + ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, + MAX_COMPS_IN_SCAN); + + /* Overall image size in MCUs */ + cinfo->MCUs_per_row = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, + (long) (cinfo->max_h_samp_factor*DCTSIZE)); + cinfo->MCU_rows_in_scan = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, + (long) (cinfo->max_v_samp_factor*DCTSIZE)); + + cinfo->blocks_in_MCU = 0; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Sampling factors give # of blocks of component in each MCU */ + compptr->MCU_width = compptr->h_samp_factor; + compptr->MCU_height = compptr->v_samp_factor; + compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; + compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; + /* Figure number of non-dummy blocks in last MCU column & row */ + tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); + if (tmp == 0) tmp = compptr->MCU_width; + compptr->last_col_width = tmp; + tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); + if (tmp == 0) tmp = compptr->MCU_height; + compptr->last_row_height = tmp; + /* Prepare array describing MCU composition */ + mcublks = compptr->MCU_blocks; + if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) + ERREXIT(cinfo, JERR_BAD_MCU_SIZE); + while (mcublks-- > 0) { + cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; + } + } + + } +} + + +/* + * Save away a copy of the Q-table referenced by each component present + * in the current scan, unless already saved during a prior scan. + * + * In a multiple-scan JPEG file, the encoder could assign different components + * the same Q-table slot number, but change table definitions between scans + * so that each component uses a different Q-table. (The IJG encoder is not + * currently capable of doing this, but other encoders might.) Since we want + * to be able to dequantize all the components at the end of the file, this + * means that we have to save away the table actually used for each component. + * We do this by copying the table at the start of the first scan containing + * the component. + * The JPEG spec prohibits the encoder from changing the contents of a Q-table + * slot between scans of a component using that slot. If the encoder does so + * anyway, this decoder will simply use the Q-table values that were current + * at the start of the first scan for the component. + * + * The decompressor output side looks only at the saved quant tables, + * not at the current Q-table slots. + */ + +LOCAL(void) +latch_quant_tables (j_decompress_ptr cinfo) +{ + int ci, qtblno; + jpeg_component_info *compptr; + JQUANT_TBL * qtbl; + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* No work if we already saved Q-table for this component */ + if (compptr->quant_table != NULL) + continue; + /* Make sure specified quantization table is present */ + qtblno = compptr->quant_tbl_no; + if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || + cinfo->quant_tbl_ptrs[qtblno] == NULL) + ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); + /* OK, save away the quantization table */ + qtbl = (JQUANT_TBL *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(JQUANT_TBL)); + MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); + compptr->quant_table = qtbl; + } +} + + +/* + * Initialize the input modules to read a scan of compressed data. + * The first call to this is done by jdmaster.c after initializing + * the entire decompressor (during jpeg_start_decompress). + * Subsequent calls come from consume_markers, below. + */ + +METHODDEF(void) +start_input_pass (j_decompress_ptr cinfo) +{ + per_scan_setup(cinfo); + latch_quant_tables(cinfo); + (*cinfo->entropy->start_pass) (cinfo); + (*cinfo->coef->start_input_pass) (cinfo); + cinfo->inputctl->consume_input = cinfo->coef->consume_data; +} + + +/* + * Finish up after inputting a compressed-data scan. + * This is called by the coefficient controller after it's read all + * the expected data of the scan. + */ + +METHODDEF(void) +finish_input_pass (j_decompress_ptr cinfo) +{ + cinfo->inputctl->consume_input = consume_markers; +} + + +/* + * Read JPEG markers before, between, or after compressed-data scans. + * Change state as necessary when a new scan is reached. + * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + * + * The consume_input method pointer points either here or to the + * coefficient controller's consume_data routine, depending on whether + * we are reading a compressed data segment or inter-segment markers. + */ + +METHODDEF(int) +consume_markers (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + int val; + + if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ + return JPEG_REACHED_EOI; + + val = (*cinfo->marker->read_markers) (cinfo); + + switch (val) { + case JPEG_REACHED_SOS: /* Found SOS */ + if (inputctl->inheaders) { /* 1st SOS */ + initial_setup(cinfo); + inputctl->inheaders = FALSE; + /* Note: start_input_pass must be called by jdmaster.c + * before any more input can be consumed. jdapimin.c is + * responsible for enforcing this sequencing. + */ + } else { /* 2nd or later SOS marker */ + if (! inputctl->pub.has_multiple_scans) + ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ + start_input_pass(cinfo); + } + break; + case JPEG_REACHED_EOI: /* Found EOI */ + inputctl->pub.eoi_reached = TRUE; + if (inputctl->inheaders) { /* Tables-only datastream, apparently */ + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_NO_SOS); + } else { + /* Prevent infinite loop in coef ctlr's decompress_data routine + * if user set output_scan_number larger than number of scans. + */ + if (cinfo->output_scan_number > cinfo->input_scan_number) + cinfo->output_scan_number = cinfo->input_scan_number; + } + break; + case JPEG_SUSPENDED: + break; + } + + return val; +} + + +/* + * Reset state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; + + inputctl->pub.consume_input = consume_markers; + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = TRUE; + /* Reset other modules */ + (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); + (*cinfo->marker->reset_marker_reader) (cinfo); + /* Reset progression state -- would be cleaner if entropy decoder did this */ + cinfo->coef_bits = NULL; +} + + +/* + * Initialize the input controller module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_input_controller (j_decompress_ptr cinfo) +{ + my_inputctl_ptr inputctl; + + /* Create subobject in permanent pool */ + inputctl = (my_inputctl_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_input_controller)); + cinfo->inputctl = (struct jpeg_input_controller *) inputctl; + /* Initialize method pointers */ + inputctl->pub.consume_input = consume_markers; + inputctl->pub.reset_input_controller = reset_input_controller; + inputctl->pub.start_input_pass = start_input_pass; + inputctl->pub.finish_input_pass = finish_input_pass; + /* Initialize state: can't use reset_input_controller since we don't + * want to try to reset other modules yet. + */ + inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ + inputctl->pub.eoi_reached = FALSE; + inputctl->inheaders = TRUE; +} diff --git a/libraries/external/jpeglib/jdinput.o b/libraries/external/jpeglib/jdinput.o new file mode 100644 index 0000000..73015f1 Binary files /dev/null and b/libraries/external/jpeglib/jdinput.o differ diff --git a/libraries/external/jpeglib/jdmainct.c b/libraries/external/jpeglib/jdmainct.c new file mode 100755 index 0000000..6b0f06f --- /dev/null +++ b/libraries/external/jpeglib/jdmainct.c @@ -0,0 +1,512 @@ +/* + * jdmainct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the main buffer controller for decompression. + * The main buffer lies between the JPEG decompressor proper and the + * post-processor; it holds downsampled data in the JPEG colorspace. + * + * Note that this code is bypassed in raw-data mode, since the application + * supplies the equivalent of the main buffer in that case. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * In the current system design, the main buffer need never be a full-image + * buffer; any full-height buffers will be found inside the coefficient or + * postprocessing controllers. Nonetheless, the main controller is not + * trivial. Its responsibility is to provide context rows for upsampling/ + * rescaling, and doing this in an efficient fashion is a bit tricky. + * + * Postprocessor input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) + * sample rows of each component. (We require DCT_scaled_size values to be + * chosen such that these numbers are integers. In practice DCT_scaled_size + * values will likely be powers of two, so we actually have the stronger + * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) + * Upsampling will typically produce max_v_samp_factor pixel rows from each + * row group (times any additional scale factor that the upsampler is + * applying). + * + * The coefficient controller will deliver data to us one iMCU row at a time; + * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or + * exactly min_DCT_scaled_size row groups. (This amount of data corresponds + * to one row of MCUs when the image is fully interleaved.) Note that the + * number of sample rows varies across components, but the number of row + * groups does not. Some garbage sample rows may be included in the last iMCU + * row at the bottom of the image. + * + * Depending on the vertical scaling algorithm used, the upsampler may need + * access to the sample row(s) above and below its current input row group. + * The upsampler is required to set need_context_rows TRUE at global selection + * time if so. When need_context_rows is FALSE, this controller can simply + * obtain one iMCU row at a time from the coefficient controller and dole it + * out as row groups to the postprocessor. + * + * When need_context_rows is TRUE, this controller guarantees that the buffer + * passed to postprocessing contains at least one row group's worth of samples + * above and below the row group(s) being processed. Note that the context + * rows "above" the first passed row group appear at negative row offsets in + * the passed buffer. At the top and bottom of the image, the required + * context rows are manufactured by duplicating the first or last real sample + * row; this avoids having special cases in the upsampling inner loops. + * + * The amount of context is fixed at one row group just because that's a + * convenient number for this controller to work with. The existing + * upsamplers really only need one sample row of context. An upsampler + * supporting arbitrary output rescaling might wish for more than one row + * group of context when shrinking the image; tough, we don't handle that. + * (This is justified by the assumption that downsizing will be handled mostly + * by adjusting the DCT_scaled_size values, so that the actual scale factor at + * the upsample step needn't be much less than one.) + * + * To provide the desired context, we have to retain the last two row groups + * of one iMCU row while reading in the next iMCU row. (The last row group + * can't be processed until we have another row group for its below-context, + * and so we have to save the next-to-last group too for its above-context.) + * We could do this most simply by copying data around in our buffer, but + * that'd be very slow. We can avoid copying any data by creating a rather + * strange pointer structure. Here's how it works. We allocate a workspace + * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number + * of row groups per iMCU row). We create two sets of redundant pointers to + * the workspace. Labeling the physical row groups 0 to M+1, the synthesized + * pointer lists look like this: + * M+1 M-1 + * master pointer --> 0 master pointer --> 0 + * 1 1 + * ... ... + * M-3 M-3 + * M-2 M + * M-1 M+1 + * M M-2 + * M+1 M-1 + * 0 0 + * We read alternate iMCU rows using each master pointer; thus the last two + * row groups of the previous iMCU row remain un-overwritten in the workspace. + * The pointer lists are set up so that the required context rows appear to + * be adjacent to the proper places when we pass the pointer lists to the + * upsampler. + * + * The above pictures describe the normal state of the pointer lists. + * At top and bottom of the image, we diddle the pointer lists to duplicate + * the first or last sample row as necessary (this is cheaper than copying + * sample rows around). + * + * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that + * situation each iMCU row provides only one row group so the buffering logic + * must be different (eg, we must read two iMCU rows before we can emit the + * first row group). For now, we simply do not support providing context + * rows when min_DCT_scaled_size is 1. That combination seems unlikely to + * be worth providing --- if someone wants a 1/8th-size preview, they probably + * want it quick and dirty, so a context-free upsampler is sufficient. + */ + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_main_controller pub; /* public fields */ + + /* Pointer to allocated workspace (M or M+2 row groups). */ + JSAMPARRAY buffer[MAX_COMPONENTS]; + + boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ + JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ + + /* Remaining fields are only used in the context case. */ + + /* These are the master pointers to the funny-order pointer lists. */ + JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ + + int whichptr; /* indicates which pointer set is now in use */ + int context_state; /* process_data state machine status */ + JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ + JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ +} my_main_controller; + +typedef my_main_controller * my_main_ptr; + +/* context_state values: */ +#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ +#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ +#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ + + +/* Forward declarations */ +METHODDEF(void) process_data_simple_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +METHODDEF(void) process_data_context_main + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) process_data_crank_post + JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); +#endif + + +LOCAL(void) +alloc_funny_pointers (j_decompress_ptr cinfo) +/* Allocate space for the funny pointer lists. + * This is done only once, not once per pass. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + /* Get top-level space for component array pointers. + * We alloc both arrays with one call to save a few cycles. + */ + main->xbuffer[0] = (JSAMPIMAGE) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); + main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + /* Get space for pointer lists --- M+4 row groups in each list. + * We alloc both pointer lists with one call to save a few cycles. + */ + xbuf = (JSAMPARRAY) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); + xbuf += rgroup; /* want one row group at negative offsets */ + main->xbuffer[0][ci] = xbuf; + xbuf += rgroup * (M + 4); + main->xbuffer[1][ci] = xbuf; + } +} + + +LOCAL(void) +make_funny_pointers (j_decompress_ptr cinfo) +/* Create the funny pointer lists discussed in the comments above. + * The actual workspace is already allocated (in main->buffer), + * and the space for the pointer lists is allocated too. + * This routine just fills in the curiously ordered lists. + * This will be repeated at the beginning of each pass. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY buf, xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + xbuf0 = main->xbuffer[0][ci]; + xbuf1 = main->xbuffer[1][ci]; + /* First copy the workspace pointers as-is */ + buf = main->buffer[ci]; + for (i = 0; i < rgroup * (M + 2); i++) { + xbuf0[i] = xbuf1[i] = buf[i]; + } + /* In the second list, put the last four row groups in swapped order */ + for (i = 0; i < rgroup * 2; i++) { + xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; + xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; + } + /* The wraparound pointers at top and bottom will be filled later + * (see set_wraparound_pointers, below). Initially we want the "above" + * pointers to duplicate the first actual data line. This only needs + * to happen in xbuffer[0]. + */ + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[0]; + } + } +} + + +LOCAL(void) +set_wraparound_pointers (j_decompress_ptr cinfo) +/* Set up the "wraparound" pointers at top and bottom of the pointer lists. + * This changes the pointer list state from top-of-image to the normal state. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup; + int M = cinfo->min_DCT_scaled_size; + jpeg_component_info *compptr; + JSAMPARRAY xbuf0, xbuf1; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + xbuf0 = main->xbuffer[0][ci]; + xbuf1 = main->xbuffer[1][ci]; + for (i = 0; i < rgroup; i++) { + xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; + xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; + xbuf0[rgroup*(M+2) + i] = xbuf0[i]; + xbuf1[rgroup*(M+2) + i] = xbuf1[i]; + } + } +} + + +LOCAL(void) +set_bottom_pointers (j_decompress_ptr cinfo) +/* Change the pointer lists to duplicate the last sample row at the bottom + * of the image. whichptr indicates which xbuffer holds the final iMCU row. + * Also sets rowgroups_avail to indicate number of nondummy row groups in row. + */ +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + int ci, i, rgroup, iMCUheight, rows_left; + jpeg_component_info *compptr; + JSAMPARRAY xbuf; + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Count sample rows in one iMCU row and in one row group */ + iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; + rgroup = iMCUheight / cinfo->min_DCT_scaled_size; + /* Count nondummy sample rows remaining for this component */ + rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); + if (rows_left == 0) rows_left = iMCUheight; + /* Count nondummy row groups. Should get same answer for each component, + * so we need only do it once. + */ + if (ci == 0) { + main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); + } + /* Duplicate the last real sample row rgroup*2 times; this pads out the + * last partial rowgroup and ensures at least one full rowgroup of context. + */ + xbuf = main->xbuffer[main->whichptr][ci]; + for (i = 0; i < rgroup * 2; i++) { + xbuf[rows_left + i] = xbuf[rows_left-1]; + } + } +} + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->upsample->need_context_rows) { + main->pub.process_data = process_data_context_main; + make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ + main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ + main->context_state = CTX_PREPARE_FOR_IMCU; + main->iMCU_row_ctr = 0; + } else { + /* Simple case with no context needed */ + main->pub.process_data = process_data_simple_main; + } + main->buffer_full = FALSE; /* Mark buffer empty */ + main->rowgroup_ctr = 0; + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_CRANK_DEST: + /* For last pass of 2-pass quantization, just crank the postprocessor */ + main->pub.process_data = process_data_crank_post; + break; +#endif + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } +} + + +/* + * Process some data. + * This handles the simple case where no context is required. + */ + +METHODDEF(void) +process_data_simple_main (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + JDIMENSION rowgroups_avail; + + /* Read input data if we haven't filled the main buffer yet */ + if (! main->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) + return; /* suspension forced, can do nothing more */ + main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + } + + /* There are always min_DCT_scaled_size row groups in an iMCU row. */ + rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; + /* Note: at the bottom of the image, we may pass extra garbage row groups + * to the postprocessor. The postprocessor has to check for bottom + * of image anyway (at row resolution), so no point in us doing it too. + */ + + /* Feed the postprocessor */ + (*cinfo->post->post_process_data) (cinfo, main->buffer, + &main->rowgroup_ctr, rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + + /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ + if (main->rowgroup_ctr >= rowgroups_avail) { + main->buffer_full = FALSE; + main->rowgroup_ctr = 0; + } +} + + +/* + * Process some data. + * This handles the case where context rows must be provided. + */ + +METHODDEF(void) +process_data_context_main (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_main_ptr main = (my_main_ptr) cinfo->main; + + /* Read input data if we haven't filled the main buffer yet */ + if (! main->buffer_full) { + if (! (*cinfo->coef->decompress_data) (cinfo, + main->xbuffer[main->whichptr])) + return; /* suspension forced, can do nothing more */ + main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ + main->iMCU_row_ctr++; /* count rows received */ + } + + /* Postprocessor typically will not swallow all the input data it is handed + * in one call (due to filling the output buffer first). Must be prepared + * to exit and restart. This switch lets us keep track of how far we got. + * Note that each case falls through to the next on successful completion. + */ + switch (main->context_state) { + case CTX_POSTPONED_ROW: + /* Call postprocessor using previously set pointers for postponed row */ + (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], + &main->rowgroup_ctr, main->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (main->rowgroup_ctr < main->rowgroups_avail) + return; /* Need to suspend */ + main->context_state = CTX_PREPARE_FOR_IMCU; + if (*out_row_ctr >= out_rows_avail) + return; /* Postprocessor exactly filled output buf */ + /*FALLTHROUGH*/ + case CTX_PREPARE_FOR_IMCU: + /* Prepare to process first M-1 row groups of this iMCU row */ + main->rowgroup_ctr = 0; + main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); + /* Check for bottom of image: if so, tweak pointers to "duplicate" + * the last sample row, and adjust rowgroups_avail to ignore padding rows. + */ + if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) + set_bottom_pointers(cinfo); + main->context_state = CTX_PROCESS_IMCU; + /*FALLTHROUGH*/ + case CTX_PROCESS_IMCU: + /* Call postprocessor using previously set pointers */ + (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], + &main->rowgroup_ctr, main->rowgroups_avail, + output_buf, out_row_ctr, out_rows_avail); + if (main->rowgroup_ctr < main->rowgroups_avail) + return; /* Need to suspend */ + /* After the first iMCU, change wraparound pointers to normal state */ + if (main->iMCU_row_ctr == 1) + set_wraparound_pointers(cinfo); + /* Prepare to load new iMCU row using other xbuffer list */ + main->whichptr ^= 1; /* 0=>1 or 1=>0 */ + main->buffer_full = FALSE; + /* Still need to process last row group of this iMCU row, */ + /* which is saved at index M+1 of the other xbuffer */ + main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); + main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); + main->context_state = CTX_POSTPONED_ROW; + } +} + + +/* + * Process some data. + * Final pass of two-pass quantization: just call the postprocessor. + * Source data will be the postprocessor controller's internal buffer. + */ + +#ifdef QUANT_2PASS_SUPPORTED + +METHODDEF(void) +process_data_crank_post (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, + (JDIMENSION *) NULL, (JDIMENSION) 0, + output_buf, out_row_ctr, out_rows_avail); +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize main buffer controller. + */ + +GLOBAL(void) +jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_main_ptr main; + int ci, rgroup, ngroups; + jpeg_component_info *compptr; + + main = (my_main_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_main_controller)); + cinfo->main = (struct jpeg_d_main_controller *) main; + main->pub.start_pass = start_pass_main; + + if (need_full_buffer) /* shouldn't happen */ + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + + /* Allocate the workspace. + * ngroups is the number of row groups we need. + */ + if (cinfo->upsample->need_context_rows) { + if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ + ERREXIT(cinfo, JERR_NOTIMPL); + alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ + ngroups = cinfo->min_DCT_scaled_size + 2; + } else { + ngroups = cinfo->min_DCT_scaled_size; + } + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; /* height of a row group of component */ + main->buffer[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + compptr->width_in_blocks * compptr->DCT_scaled_size, + (JDIMENSION) (rgroup * ngroups)); + } +} diff --git a/libraries/external/jpeglib/jdmainct.o b/libraries/external/jpeglib/jdmainct.o new file mode 100644 index 0000000..70328dd Binary files /dev/null and b/libraries/external/jpeglib/jdmainct.o differ diff --git a/libraries/external/jpeglib/jdmarker.c b/libraries/external/jpeglib/jdmarker.c new file mode 100755 index 0000000..9811761 --- /dev/null +++ b/libraries/external/jpeglib/jdmarker.c @@ -0,0 +1,1360 @@ +/* + * jdmarker.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains routines to decode JPEG datastream markers. + * Most of the complexity arises from our desire to support input + * suspension: if not all of the data for a marker is available, + * we must exit back to the application. On resumption, we reprocess + * the marker. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, + M_SOF1 = 0xc1, + M_SOF2 = 0xc2, + M_SOF3 = 0xc3, + + M_SOF5 = 0xc5, + M_SOF6 = 0xc6, + M_SOF7 = 0xc7, + + M_JPG = 0xc8, + M_SOF9 = 0xc9, + M_SOF10 = 0xca, + M_SOF11 = 0xcb, + + M_SOF13 = 0xcd, + M_SOF14 = 0xce, + M_SOF15 = 0xcf, + + M_DHT = 0xc4, + + M_DAC = 0xcc, + + M_RST0 = 0xd0, + M_RST1 = 0xd1, + M_RST2 = 0xd2, + M_RST3 = 0xd3, + M_RST4 = 0xd4, + M_RST5 = 0xd5, + M_RST6 = 0xd6, + M_RST7 = 0xd7, + + M_SOI = 0xd8, + M_EOI = 0xd9, + M_SOS = 0xda, + M_DQT = 0xdb, + M_DNL = 0xdc, + M_DRI = 0xdd, + M_DHP = 0xde, + M_EXP = 0xdf, + + M_APP0 = 0xe0, + M_APP1 = 0xe1, + M_APP2 = 0xe2, + M_APP3 = 0xe3, + M_APP4 = 0xe4, + M_APP5 = 0xe5, + M_APP6 = 0xe6, + M_APP7 = 0xe7, + M_APP8 = 0xe8, + M_APP9 = 0xe9, + M_APP10 = 0xea, + M_APP11 = 0xeb, + M_APP12 = 0xec, + M_APP13 = 0xed, + M_APP14 = 0xee, + M_APP15 = 0xef, + + M_JPG0 = 0xf0, + M_JPG13 = 0xfd, + M_COM = 0xfe, + + M_TEM = 0x01, + + M_ERROR = 0x100 +} JPEG_MARKER; + + +/* Private state */ + +typedef struct { + struct jpeg_marker_reader pub; /* public fields */ + + /* Application-overridable marker processing methods */ + jpeg_marker_parser_method process_COM; + jpeg_marker_parser_method process_APPn[16]; + + /* Limit on marker data length to save for each marker type */ + unsigned int length_limit_COM; + unsigned int length_limit_APPn[16]; + + /* Status of COM/APPn marker saving */ + jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ + unsigned int bytes_read; /* data bytes read so far in marker */ + /* Note: cur_marker is not linked into marker_list until it's all read. */ +} my_marker_reader; + +typedef my_marker_reader * my_marker_ptr; + + +/* + * Macros for fetching data from the data source module. + * + * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect + * the current restart point; we update them only when we have reached a + * suitable place to restart if a suspension occurs. + */ + +/* Declare and initialize local copies of input pointer/count */ +#define INPUT_VARS(cinfo) \ + struct jpeg_source_mgr * datasrc = (cinfo)->src; \ + const JOCTET * next_input_byte = datasrc->next_input_byte; \ + size_t bytes_in_buffer = datasrc->bytes_in_buffer + +/* Unload the local copies --- do this only at a restart boundary */ +#define INPUT_SYNC(cinfo) \ + ( datasrc->next_input_byte = next_input_byte, \ + datasrc->bytes_in_buffer = bytes_in_buffer ) + +/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ +#define INPUT_RELOAD(cinfo) \ + ( next_input_byte = datasrc->next_input_byte, \ + bytes_in_buffer = datasrc->bytes_in_buffer ) + +/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. + * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, + * but we must reload the local copies after a successful fill. + */ +#define MAKE_BYTE_AVAIL(cinfo,action) \ + if (bytes_in_buffer == 0) { \ + if (! (*datasrc->fill_input_buffer) (cinfo)) \ + { action; } \ + INPUT_RELOAD(cinfo); \ + } + +/* Read a byte into variable V. + * If must suspend, take the specified action (typically "return FALSE"). + */ +#define INPUT_BYTE(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V = GETJOCTET(*next_input_byte++); ) + +/* As above, but read two bytes interpreted as an unsigned 16-bit integer. + * V should be declared unsigned int or perhaps INT32. + */ +#define INPUT_2BYTES(cinfo,V,action) \ + MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ + MAKE_BYTE_AVAIL(cinfo,action); \ + bytes_in_buffer--; \ + V += GETJOCTET(*next_input_byte++); ) + + +/* + * Routines to process JPEG markers. + * + * Entry condition: JPEG marker itself has been read and its code saved + * in cinfo->unread_marker; input restart point is just after the marker. + * + * Exit: if return TRUE, have read and processed any parameters, and have + * updated the restart point to point after the parameters. + * If return FALSE, was forced to suspend before reaching end of + * marker parameters; restart point has not been moved. Same routine + * will be called again after application supplies more input data. + * + * This approach to suspension assumes that all of a marker's parameters + * can fit into a single input bufferload. This should hold for "normal" + * markers. Some COM/APPn markers might have large parameter segments + * that might not fit. If we are simply dropping such a marker, we use + * skip_input_data to get past it, and thereby put the problem on the + * source manager's shoulders. If we are saving the marker's contents + * into memory, we use a slightly different convention: when forced to + * suspend, the marker processor updates the restart point to the end of + * what it's consumed (ie, the end of the buffer) before returning FALSE. + * On resumption, cinfo->unread_marker still contains the marker code, + * but the data source will point to the next chunk of marker data. + * The marker processor must retain internal state to deal with this. + * + * Note that we don't bother to avoid duplicate trace messages if a + * suspension occurs within marker parameters. Other side effects + * require more care. + */ + + +LOCAL(boolean) +get_soi (j_decompress_ptr cinfo) +/* Process an SOI marker */ +{ + int i; + + TRACEMS(cinfo, 1, JTRC_SOI); + + if (cinfo->marker->saw_SOI) + ERREXIT(cinfo, JERR_SOI_DUPLICATE); + + /* Reset all parameters that are defined to be reset by SOI */ + + for (i = 0; i < NUM_ARITH_TBLS; i++) { + cinfo->arith_dc_L[i] = 0; + cinfo->arith_dc_U[i] = 1; + cinfo->arith_ac_K[i] = 5; + } + cinfo->restart_interval = 0; + + /* Set initial assumptions for colorspace etc */ + + cinfo->jpeg_color_space = JCS_UNKNOWN; + cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ + + cinfo->saw_JFIF_marker = FALSE; + cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ + cinfo->JFIF_minor_version = 1; + cinfo->density_unit = 0; + cinfo->X_density = 1; + cinfo->Y_density = 1; + cinfo->saw_Adobe_marker = FALSE; + cinfo->Adobe_transform = 0; + + cinfo->marker->saw_SOI = TRUE; + + return TRUE; +} + + +LOCAL(boolean) +get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) +/* Process a SOFn marker */ +{ + INT32 length; + int c, ci; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + cinfo->progressive_mode = is_prog; + cinfo->arith_code = is_arith; + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); + INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); + INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); + + length -= 8; + + TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, + (int) cinfo->image_width, (int) cinfo->image_height, + cinfo->num_components); + + if (cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOF_DUPLICATE); + + /* We don't support files in which the image height is initially specified */ + /* as 0 and is later redefined by DNL. As long as we have to check that, */ + /* might as well have a general sanity check. */ + if (cinfo->image_height <= 0 || cinfo->image_width <= 0 + || cinfo->num_components <= 0) + ERREXIT(cinfo, JERR_EMPTY_IMAGE); + + if (length != (cinfo->num_components * 3)) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + if (cinfo->comp_info == NULL) /* do only once, even if suspend */ + cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components * SIZEOF(jpeg_component_info)); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + compptr->component_index = ci; + INPUT_BYTE(cinfo, compptr->component_id, return FALSE); + INPUT_BYTE(cinfo, c, return FALSE); + compptr->h_samp_factor = (c >> 4) & 15; + compptr->v_samp_factor = (c ) & 15; + INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); + + TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, + compptr->component_id, compptr->h_samp_factor, + compptr->v_samp_factor, compptr->quant_tbl_no); + } + + cinfo->marker->saw_SOF = TRUE; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_sos (j_decompress_ptr cinfo) +/* Process a SOS marker */ +{ + INT32 length; + int i, ci, n, c, cc; + jpeg_component_info * compptr; + INPUT_VARS(cinfo); + + if (! cinfo->marker->saw_SOF) + ERREXIT(cinfo, JERR_SOS_NO_SOF); + + INPUT_2BYTES(cinfo, length, return FALSE); + + INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ + + TRACEMS1(cinfo, 1, JTRC_SOS, n); + + if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + cinfo->comps_in_scan = n; + + /* Collect the component-spec parameters */ + + for (i = 0; i < n; i++) { + INPUT_BYTE(cinfo, cc, return FALSE); + INPUT_BYTE(cinfo, c, return FALSE); + + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + if (cc == compptr->component_id) + goto id_found; + } + + ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); + + id_found: + + cinfo->cur_comp_info[i] = compptr; + compptr->dc_tbl_no = (c >> 4) & 15; + compptr->ac_tbl_no = (c ) & 15; + + TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, + compptr->dc_tbl_no, compptr->ac_tbl_no); + } + + /* Collect the additional scan parameters Ss, Se, Ah/Al. */ + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ss = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Se = c; + INPUT_BYTE(cinfo, c, return FALSE); + cinfo->Ah = (c >> 4) & 15; + cinfo->Al = (c ) & 15; + + TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, + cinfo->Ah, cinfo->Al); + + /* Prepare to scan data & restart markers */ + cinfo->marker->next_restart_num = 0; + + /* Count another SOS marker */ + cinfo->input_scan_number++; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +#ifdef D_ARITH_CODING_SUPPORTED + +LOCAL(boolean) +get_dac (j_decompress_ptr cinfo) +/* Process a DAC marker */ +{ + INT32 length; + int index, val; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, index, return FALSE); + INPUT_BYTE(cinfo, val, return FALSE); + + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_DAC, index, val); + + if (index < 0 || index >= (2*NUM_ARITH_TBLS)) + ERREXIT1(cinfo, JERR_DAC_INDEX, index); + + if (index >= NUM_ARITH_TBLS) { /* define AC table */ + cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; + } else { /* define DC table */ + cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); + cinfo->arith_dc_U[index] = (UINT8) (val >> 4); + if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) + ERREXIT1(cinfo, JERR_DAC_VALUE, val); + } + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + +#else /* ! D_ARITH_CODING_SUPPORTED */ + +#define get_dac(cinfo) skip_variable(cinfo) + +#endif /* D_ARITH_CODING_SUPPORTED */ + + +LOCAL(boolean) +get_dht (j_decompress_ptr cinfo) +/* Process a DHT marker */ +{ + INT32 length; + UINT8 bits[17]; + UINT8 huffval[256]; + int i, index, count; + JHUFF_TBL **htblptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 16) { + INPUT_BYTE(cinfo, index, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DHT, index); + + bits[0] = 0; + count = 0; + for (i = 1; i <= 16; i++) { + INPUT_BYTE(cinfo, bits[i], return FALSE); + count += bits[i]; + } + + length -= 1 + 16; + + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[1], bits[2], bits[3], bits[4], + bits[5], bits[6], bits[7], bits[8]); + TRACEMS8(cinfo, 2, JTRC_HUFFBITS, + bits[9], bits[10], bits[11], bits[12], + bits[13], bits[14], bits[15], bits[16]); + + /* Here we just do minimal validation of the counts to avoid walking + * off the end of our table space. jdhuff.c will check more carefully. + */ + if (count > 256 || ((INT32) count) > length) + ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); + + for (i = 0; i < count; i++) + INPUT_BYTE(cinfo, huffval[i], return FALSE); + + length -= count; + + if (index & 0x10) { /* AC table definition */ + index -= 0x10; + htblptr = &cinfo->ac_huff_tbl_ptrs[index]; + } else { /* DC table definition */ + htblptr = &cinfo->dc_huff_tbl_ptrs[index]; + } + + if (index < 0 || index >= NUM_HUFF_TBLS) + ERREXIT1(cinfo, JERR_DHT_INDEX, index); + + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); + + MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); + MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dqt (j_decompress_ptr cinfo) +/* Process a DQT marker */ +{ + INT32 length; + int n, i, prec; + unsigned int tmp; + JQUANT_TBL *quant_ptr; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + while (length > 0) { + INPUT_BYTE(cinfo, n, return FALSE); + prec = n >> 4; + n &= 0x0F; + + TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); + + if (n >= NUM_QUANT_TBLS) + ERREXIT1(cinfo, JERR_DQT_INDEX, n); + + if (cinfo->quant_tbl_ptrs[n] == NULL) + cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); + quant_ptr = cinfo->quant_tbl_ptrs[n]; + + for (i = 0; i < DCTSIZE2; i++) { + if (prec) + INPUT_2BYTES(cinfo, tmp, return FALSE); + else + INPUT_BYTE(cinfo, tmp, return FALSE); + /* We convert the zigzag-order table to natural array order. */ + quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; + } + + if (cinfo->err->trace_level >= 2) { + for (i = 0; i < DCTSIZE2; i += 8) { + TRACEMS8(cinfo, 2, JTRC_QUANTVALS, + quant_ptr->quantval[i], quant_ptr->quantval[i+1], + quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], + quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], + quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); + } + } + + length -= DCTSIZE2+1; + if (prec) length -= DCTSIZE2; + } + + if (length != 0) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +get_dri (j_decompress_ptr cinfo) +/* Process a DRI marker */ +{ + INT32 length; + unsigned int tmp; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + + if (length != 4) + ERREXIT(cinfo, JERR_BAD_LENGTH); + + INPUT_2BYTES(cinfo, tmp, return FALSE); + + TRACEMS1(cinfo, 1, JTRC_DRI, tmp); + + cinfo->restart_interval = tmp; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Routines for processing APPn and COM markers. + * These are either saved in memory or discarded, per application request. + * APP0 and APP14 are specially checked to see if they are + * JFIF and Adobe markers, respectively. + */ + +#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ +#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ +#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ + + +LOCAL(void) +examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, + unsigned int datalen, INT32 remaining) +/* Examine first few bytes from an APP0. + * Take appropriate action if it is a JFIF marker. + * datalen is # of bytes at data[], remaining is length of rest of marker data. + */ +{ + INT32 totallen = (INT32) datalen + remaining; + + if (datalen >= APP0_DATA_LEN && + GETJOCTET(data[0]) == 0x4A && + GETJOCTET(data[1]) == 0x46 && + GETJOCTET(data[2]) == 0x49 && + GETJOCTET(data[3]) == 0x46 && + GETJOCTET(data[4]) == 0) { + /* Found JFIF APP0 marker: save info */ + cinfo->saw_JFIF_marker = TRUE; + cinfo->JFIF_major_version = GETJOCTET(data[5]); + cinfo->JFIF_minor_version = GETJOCTET(data[6]); + cinfo->density_unit = GETJOCTET(data[7]); + cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); + cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); + /* Check version. + * Major version must be 1, anything else signals an incompatible change. + * (We used to treat this as an error, but now it's a nonfatal warning, + * because some bozo at Hijaak couldn't read the spec.) + * Minor version should be 0..2, but process anyway if newer. + */ + if (cinfo->JFIF_major_version != 1) + WARNMS2(cinfo, JWRN_JFIF_MAJOR, + cinfo->JFIF_major_version, cinfo->JFIF_minor_version); + /* Generate trace messages */ + TRACEMS5(cinfo, 1, JTRC_JFIF, + cinfo->JFIF_major_version, cinfo->JFIF_minor_version, + cinfo->X_density, cinfo->Y_density, cinfo->density_unit); + /* Validate thumbnail dimensions and issue appropriate messages */ + if (GETJOCTET(data[12]) | GETJOCTET(data[13])) + TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, + GETJOCTET(data[12]), GETJOCTET(data[13])); + totallen -= APP0_DATA_LEN; + if (totallen != + ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) + TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); + } else if (datalen >= 6 && + GETJOCTET(data[0]) == 0x4A && + GETJOCTET(data[1]) == 0x46 && + GETJOCTET(data[2]) == 0x58 && + GETJOCTET(data[3]) == 0x58 && + GETJOCTET(data[4]) == 0) { + /* Found JFIF "JFXX" extension APP0 marker */ + /* The library doesn't actually do anything with these, + * but we try to produce a helpful trace message. + */ + switch (GETJOCTET(data[5])) { + case 0x10: + TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); + break; + case 0x11: + TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); + break; + case 0x13: + TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); + break; + default: + TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, + GETJOCTET(data[5]), (int) totallen); + break; + } + } else { + /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ + TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); + } +} + + +LOCAL(void) +examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, + unsigned int datalen, INT32 remaining) +/* Examine first few bytes from an APP14. + * Take appropriate action if it is an Adobe marker. + * datalen is # of bytes at data[], remaining is length of rest of marker data. + */ +{ + unsigned int version, flags0, flags1, transform; + + if (datalen >= APP14_DATA_LEN && + GETJOCTET(data[0]) == 0x41 && + GETJOCTET(data[1]) == 0x64 && + GETJOCTET(data[2]) == 0x6F && + GETJOCTET(data[3]) == 0x62 && + GETJOCTET(data[4]) == 0x65) { + /* Found Adobe APP14 marker */ + version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); + flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); + flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); + transform = GETJOCTET(data[11]); + TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); + cinfo->saw_Adobe_marker = TRUE; + cinfo->Adobe_transform = (UINT8) transform; + } else { + /* Start of APP14 does not match "Adobe", or too short */ + TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); + } +} + + +METHODDEF(boolean) +get_interesting_appn (j_decompress_ptr cinfo) +/* Process an APP0 or APP14 marker without saving it */ +{ + INT32 length; + JOCTET b[APPN_DATA_LEN]; + unsigned int i, numtoread; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + /* get the interesting part of the marker data */ + if (length >= APPN_DATA_LEN) + numtoread = APPN_DATA_LEN; + else if (length > 0) + numtoread = (unsigned int) length; + else + numtoread = 0; + for (i = 0; i < numtoread; i++) + INPUT_BYTE(cinfo, b[i], return FALSE); + length -= numtoread; + + /* process it */ + switch (cinfo->unread_marker) { + case M_APP0: + examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); + break; + case M_APP14: + examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); + break; + default: + /* can't get here unless jpeg_save_markers chooses wrong processor */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + break; + } + + /* skip any remaining data -- could be lots */ + INPUT_SYNC(cinfo); + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +#ifdef SAVE_MARKERS_SUPPORTED + +METHODDEF(boolean) +save_marker (j_decompress_ptr cinfo) +/* Save an APPn or COM marker into the marker list */ +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + jpeg_saved_marker_ptr cur_marker = marker->cur_marker; + unsigned int bytes_read, data_length; + JOCTET FAR * data; + INT32 length = 0; + INPUT_VARS(cinfo); + + if (cur_marker == NULL) { + /* begin reading a marker */ + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + if (length >= 0) { /* watch out for bogus length word */ + /* figure out how much we want to save */ + unsigned int limit; + if (cinfo->unread_marker == (int) M_COM) + limit = marker->length_limit_COM; + else + limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; + if ((unsigned int) length < limit) + limit = (unsigned int) length; + /* allocate and initialize the marker item */ + cur_marker = (jpeg_saved_marker_ptr) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(struct jpeg_marker_struct) + limit); + cur_marker->next = NULL; + cur_marker->marker = (UINT8) cinfo->unread_marker; + cur_marker->original_length = (unsigned int) length; + cur_marker->data_length = limit; + /* data area is just beyond the jpeg_marker_struct */ + data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); + marker->cur_marker = cur_marker; + marker->bytes_read = 0; + bytes_read = 0; + data_length = limit; + } else { + /* deal with bogus length word */ + bytes_read = data_length = 0; + data = NULL; + } + } else { + /* resume reading a marker */ + bytes_read = marker->bytes_read; + data_length = cur_marker->data_length; + data = cur_marker->data + bytes_read; + } + + while (bytes_read < data_length) { + INPUT_SYNC(cinfo); /* move the restart point to here */ + marker->bytes_read = bytes_read; + /* If there's not at least one byte in buffer, suspend */ + MAKE_BYTE_AVAIL(cinfo, return FALSE); + /* Copy bytes with reasonable rapidity */ + while (bytes_read < data_length && bytes_in_buffer > 0) { + *data++ = *next_input_byte++; + bytes_in_buffer--; + bytes_read++; + } + } + + /* Done reading what we want to read */ + if (cur_marker != NULL) { /* will be NULL if bogus length word */ + /* Add new marker to end of list */ + if (cinfo->marker_list == NULL) { + cinfo->marker_list = cur_marker; + } else { + jpeg_saved_marker_ptr prev = cinfo->marker_list; + while (prev->next != NULL) + prev = prev->next; + prev->next = cur_marker; + } + /* Reset pointer & calc remaining data length */ + data = cur_marker->data; + length = cur_marker->original_length - data_length; + } + /* Reset to initial state for next marker */ + marker->cur_marker = NULL; + + /* Process the marker if interesting; else just make a generic trace msg */ + switch (cinfo->unread_marker) { + case M_APP0: + examine_app0(cinfo, data, data_length, length); + break; + case M_APP14: + examine_app14(cinfo, data, data_length, length); + break; + default: + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, + (int) (data_length + length)); + break; + } + + /* skip any remaining data -- could be lots */ + INPUT_SYNC(cinfo); /* do before skip_input_data */ + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + +#endif /* SAVE_MARKERS_SUPPORTED */ + + +METHODDEF(boolean) +skip_variable (j_decompress_ptr cinfo) +/* Skip over an unknown or uninteresting variable-length marker */ +{ + INT32 length; + INPUT_VARS(cinfo); + + INPUT_2BYTES(cinfo, length, return FALSE); + length -= 2; + + TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); + + INPUT_SYNC(cinfo); /* do before skip_input_data */ + if (length > 0) + (*cinfo->src->skip_input_data) (cinfo, (long) length); + + return TRUE; +} + + +/* + * Find the next JPEG marker, save it in cinfo->unread_marker. + * Returns FALSE if had to suspend before reaching a marker; + * in that case cinfo->unread_marker is unchanged. + * + * Note that the result might not be a valid marker code, + * but it will never be 0 or FF. + */ + +LOCAL(boolean) +next_marker (j_decompress_ptr cinfo) +{ + int c; + INPUT_VARS(cinfo); + + for (;;) { + INPUT_BYTE(cinfo, c, return FALSE); + /* Skip any non-FF bytes. + * This may look a bit inefficient, but it will not occur in a valid file. + * We sync after each discarded byte so that a suspending data source + * can discard the byte from its buffer. + */ + while (c != 0xFF) { + cinfo->marker->discarded_bytes++; + INPUT_SYNC(cinfo); + INPUT_BYTE(cinfo, c, return FALSE); + } + /* This loop swallows any duplicate FF bytes. Extra FFs are legal as + * pad bytes, so don't count them in discarded_bytes. We assume there + * will not be so many consecutive FF bytes as to overflow a suspending + * data source's input buffer. + */ + do { + INPUT_BYTE(cinfo, c, return FALSE); + } while (c == 0xFF); + if (c != 0) + break; /* found a valid marker, exit loop */ + /* Reach here if we found a stuffed-zero data sequence (FF/00). + * Discard it and loop back to try again. + */ + cinfo->marker->discarded_bytes += 2; + INPUT_SYNC(cinfo); + } + + if (cinfo->marker->discarded_bytes != 0) { + WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); + cinfo->marker->discarded_bytes = 0; + } + + cinfo->unread_marker = c; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +LOCAL(boolean) +first_marker (j_decompress_ptr cinfo) +/* Like next_marker, but used to obtain the initial SOI marker. */ +/* For this marker, we do not allow preceding garbage or fill; otherwise, + * we might well scan an entire input file before realizing it ain't JPEG. + * If an application wants to process non-JFIF files, it must seek to the + * SOI before calling the JPEG library. + */ +{ + int c, c2; + INPUT_VARS(cinfo); + + INPUT_BYTE(cinfo, c, return FALSE); + INPUT_BYTE(cinfo, c2, return FALSE); + if (c != 0xFF || c2 != (int) M_SOI) + ERREXIT2(cinfo, JERR_NO_SOI, c, c2); + + cinfo->unread_marker = c2; + + INPUT_SYNC(cinfo); + return TRUE; +} + + +/* + * Read markers until SOS or EOI. + * + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + +METHODDEF(int) +read_markers (j_decompress_ptr cinfo) +{ + /* Outer loop repeats once for each marker. */ + for (;;) { + /* Collect the marker proper, unless we already did. */ + /* NB: first_marker() enforces the requirement that SOI appear first. */ + if (cinfo->unread_marker == 0) { + if (! cinfo->marker->saw_SOI) { + if (! first_marker(cinfo)) + return JPEG_SUSPENDED; + } else { + if (! next_marker(cinfo)) + return JPEG_SUSPENDED; + } + } + /* At this point cinfo->unread_marker contains the marker code and the + * input point is just past the marker proper, but before any parameters. + * A suspension will cause us to return with this state still true. + */ + switch (cinfo->unread_marker) { + case M_SOI: + if (! get_soi(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_SOF0: /* Baseline */ + case M_SOF1: /* Extended sequential, Huffman */ + if (! get_sof(cinfo, FALSE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF2: /* Progressive, Huffman */ + if (! get_sof(cinfo, TRUE, FALSE)) + return JPEG_SUSPENDED; + break; + + case M_SOF9: /* Extended sequential, arithmetic */ + if (! get_sof(cinfo, FALSE, TRUE)) + return JPEG_SUSPENDED; + break; + + case M_SOF10: /* Progressive, arithmetic */ + if (! get_sof(cinfo, TRUE, TRUE)) + return JPEG_SUSPENDED; + break; + + /* Currently unsupported SOFn types */ + case M_SOF3: /* Lossless, Huffman */ + case M_SOF5: /* Differential sequential, Huffman */ + case M_SOF6: /* Differential progressive, Huffman */ + case M_SOF7: /* Differential lossless, Huffman */ + case M_JPG: /* Reserved for JPEG extensions */ + case M_SOF11: /* Lossless, arithmetic */ + case M_SOF13: /* Differential sequential, arithmetic */ + case M_SOF14: /* Differential progressive, arithmetic */ + case M_SOF15: /* Differential lossless, arithmetic */ + ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); + break; + + case M_SOS: + if (! get_sos(cinfo)) + return JPEG_SUSPENDED; + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_SOS; + + case M_EOI: + TRACEMS(cinfo, 1, JTRC_EOI); + cinfo->unread_marker = 0; /* processed the marker */ + return JPEG_REACHED_EOI; + + case M_DAC: + if (! get_dac(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DHT: + if (! get_dht(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DQT: + if (! get_dqt(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_DRI: + if (! get_dri(cinfo)) + return JPEG_SUSPENDED; + break; + + case M_APP0: + case M_APP1: + case M_APP2: + case M_APP3: + case M_APP4: + case M_APP5: + case M_APP6: + case M_APP7: + case M_APP8: + case M_APP9: + case M_APP10: + case M_APP11: + case M_APP12: + case M_APP13: + case M_APP14: + case M_APP15: + if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ + cinfo->unread_marker - (int) M_APP0]) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_COM: + if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) + return JPEG_SUSPENDED; + break; + + case M_RST0: /* these are all parameterless */ + case M_RST1: + case M_RST2: + case M_RST3: + case M_RST4: + case M_RST5: + case M_RST6: + case M_RST7: + case M_TEM: + TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); + break; + + case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ + if (! skip_variable(cinfo)) + return JPEG_SUSPENDED; + break; + + default: /* must be DHP, EXP, JPGn, or RESn */ + /* For now, we treat the reserved markers as fatal errors since they are + * likely to be used to signal incompatible JPEG Part 3 extensions. + * Once the JPEG 3 version-number marker is well defined, this code + * ought to change! + */ + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); + break; + } + /* Successfully processed marker, so reset state variable */ + cinfo->unread_marker = 0; + } /* end loop */ +} + + +/* + * Read a restart marker, which is expected to appear next in the datastream; + * if the marker is not there, take appropriate recovery action. + * Returns FALSE if suspension is required. + * + * This is called by the entropy decoder after it has read an appropriate + * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder + * has already read a marker from the data source. Under normal conditions + * cinfo->unread_marker will be reset to 0 before returning; if not reset, + * it holds a marker which the decoder will be unable to read past. + */ + +METHODDEF(boolean) +read_restart_marker (j_decompress_ptr cinfo) +{ + /* Obtain a marker unless we already did. */ + /* Note that next_marker will complain if it skips any data. */ + if (cinfo->unread_marker == 0) { + if (! next_marker(cinfo)) + return FALSE; + } + + if (cinfo->unread_marker == + ((int) M_RST0 + cinfo->marker->next_restart_num)) { + /* Normal case --- swallow the marker and let entropy decoder continue */ + TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); + cinfo->unread_marker = 0; + } else { + /* Uh-oh, the restart markers have been messed up. */ + /* Let the data source manager determine how to resync. */ + if (! (*cinfo->src->resync_to_restart) (cinfo, + cinfo->marker->next_restart_num)) + return FALSE; + } + + /* Update next-restart state */ + cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; + + return TRUE; +} + + +/* + * This is the default resync_to_restart method for data source managers + * to use if they don't have any better approach. Some data source managers + * may be able to back up, or may have additional knowledge about the data + * which permits a more intelligent recovery strategy; such managers would + * presumably supply their own resync method. + * + * read_restart_marker calls resync_to_restart if it finds a marker other than + * the restart marker it was expecting. (This code is *not* used unless + * a nonzero restart interval has been declared.) cinfo->unread_marker is + * the marker code actually found (might be anything, except 0 or FF). + * The desired restart marker number (0..7) is passed as a parameter. + * This routine is supposed to apply whatever error recovery strategy seems + * appropriate in order to position the input stream to the next data segment. + * Note that cinfo->unread_marker is treated as a marker appearing before + * the current data-source input point; usually it should be reset to zero + * before returning. + * Returns FALSE if suspension is required. + * + * This implementation is substantially constrained by wanting to treat the + * input as a data stream; this means we can't back up. Therefore, we have + * only the following actions to work with: + * 1. Simply discard the marker and let the entropy decoder resume at next + * byte of file. + * 2. Read forward until we find another marker, discarding intervening + * data. (In theory we could look ahead within the current bufferload, + * without having to discard data if we don't find the desired marker. + * This idea is not implemented here, in part because it makes behavior + * dependent on buffer size and chance buffer-boundary positions.) + * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). + * This will cause the entropy decoder to process an empty data segment, + * inserting dummy zeroes, and then we will reprocess the marker. + * + * #2 is appropriate if we think the desired marker lies ahead, while #3 is + * appropriate if the found marker is a future restart marker (indicating + * that we have missed the desired restart marker, probably because it got + * corrupted). + * We apply #2 or #3 if the found marker is a restart marker no more than + * two counts behind or ahead of the expected one. We also apply #2 if the + * found marker is not a legal JPEG marker code (it's certainly bogus data). + * If the found marker is a restart marker more than 2 counts away, we do #1 + * (too much risk that the marker is erroneous; with luck we will be able to + * resync at some future point). + * For any valid non-restart JPEG marker, we apply #3. This keeps us from + * overrunning the end of a scan. An implementation limited to single-scan + * files might find it better to apply #2 for markers other than EOI, since + * any other marker would have to be bogus data in that case. + */ + +GLOBAL(boolean) +jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) +{ + int marker = cinfo->unread_marker; + int action = 1; + + /* Always put up a warning. */ + WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); + + /* Outer loop handles repeated decision after scanning forward. */ + for (;;) { + if (marker < (int) M_SOF0) + action = 2; /* invalid marker */ + else if (marker < (int) M_RST0 || marker > (int) M_RST7) + action = 3; /* valid non-restart marker */ + else { + if (marker == ((int) M_RST0 + ((desired+1) & 7)) || + marker == ((int) M_RST0 + ((desired+2) & 7))) + action = 3; /* one of the next two expected restarts */ + else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || + marker == ((int) M_RST0 + ((desired-2) & 7))) + action = 2; /* a prior restart, so advance */ + else + action = 1; /* desired restart or too far away */ + } + TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); + switch (action) { + case 1: + /* Discard marker and let entropy decoder resume processing. */ + cinfo->unread_marker = 0; + return TRUE; + case 2: + /* Scan to the next marker, and repeat the decision loop. */ + if (! next_marker(cinfo)) + return FALSE; + marker = cinfo->unread_marker; + break; + case 3: + /* Return without advancing past this marker. */ + /* Entropy decoder will be forced to process an empty segment. */ + return TRUE; + } + } /* end loop */ +} + + +/* + * Reset marker processing state to begin a fresh datastream. + */ + +METHODDEF(void) +reset_marker_reader (j_decompress_ptr cinfo) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + cinfo->comp_info = NULL; /* until allocated by get_sof */ + cinfo->input_scan_number = 0; /* no SOS seen yet */ + cinfo->unread_marker = 0; /* no pending marker */ + marker->pub.saw_SOI = FALSE; /* set internal state too */ + marker->pub.saw_SOF = FALSE; + marker->pub.discarded_bytes = 0; + marker->cur_marker = NULL; +} + + +/* + * Initialize the marker reader module. + * This is called only once, when the decompression object is created. + */ + +GLOBAL(void) +jinit_marker_reader (j_decompress_ptr cinfo) +{ + my_marker_ptr marker; + int i; + + /* Create subobject in permanent pool */ + marker = (my_marker_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + SIZEOF(my_marker_reader)); + cinfo->marker = (struct jpeg_marker_reader *) marker; + /* Initialize public method pointers */ + marker->pub.reset_marker_reader = reset_marker_reader; + marker->pub.read_markers = read_markers; + marker->pub.read_restart_marker = read_restart_marker; + /* Initialize COM/APPn processing. + * By default, we examine and then discard APP0 and APP14, + * but simply discard COM and all other APPn. + */ + marker->process_COM = skip_variable; + marker->length_limit_COM = 0; + for (i = 0; i < 16; i++) { + marker->process_APPn[i] = skip_variable; + marker->length_limit_APPn[i] = 0; + } + marker->process_APPn[0] = get_interesting_appn; + marker->process_APPn[14] = get_interesting_appn; + /* Reset marker processing state */ + reset_marker_reader(cinfo); +} + + +/* + * Control saving of COM and APPn markers into marker_list. + */ + +#ifdef SAVE_MARKERS_SUPPORTED + +GLOBAL(void) +jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + long maxlength; + jpeg_marker_parser_method processor; + + /* Length limit mustn't be larger than what we can allocate + * (should only be a concern in a 16-bit environment). + */ + maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); + if (((long) length_limit) > maxlength) + length_limit = (unsigned int) maxlength; + + /* Choose processor routine to use. + * APP0/APP14 have special requirements. + */ + if (length_limit) { + processor = save_marker; + /* If saving APP0/APP14, save at least enough for our internal use. */ + if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) + length_limit = APP0_DATA_LEN; + else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) + length_limit = APP14_DATA_LEN; + } else { + processor = skip_variable; + /* If discarding APP0/APP14, use our regular on-the-fly processor. */ + if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) + processor = get_interesting_appn; + } + + if (marker_code == (int) M_COM) { + marker->process_COM = processor; + marker->length_limit_COM = length_limit; + } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { + marker->process_APPn[marker_code - (int) M_APP0] = processor; + marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; + } else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} + +#endif /* SAVE_MARKERS_SUPPORTED */ + + +/* + * Install a special processing method for COM or APPn markers. + */ + +GLOBAL(void) +jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine) +{ + my_marker_ptr marker = (my_marker_ptr) cinfo->marker; + + if (marker_code == (int) M_COM) + marker->process_COM = routine; + else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) + marker->process_APPn[marker_code - (int) M_APP0] = routine; + else + ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); +} diff --git a/libraries/external/jpeglib/jdmarker.o b/libraries/external/jpeglib/jdmarker.o new file mode 100644 index 0000000..90b3c8c Binary files /dev/null and b/libraries/external/jpeglib/jdmarker.o differ diff --git a/libraries/external/jpeglib/jdmaster.c b/libraries/external/jpeglib/jdmaster.c new file mode 100755 index 0000000..eda4b3f --- /dev/null +++ b/libraries/external/jpeglib/jdmaster.c @@ -0,0 +1,557 @@ +/* + * jdmaster.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains master control logic for the JPEG decompressor. + * These routines are concerned with selecting the modules to be executed + * and with determining the number of passes and the work to be done in each + * pass. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private state */ + +typedef struct { + struct jpeg_decomp_master pub; /* public fields */ + + int pass_number; /* # of passes completed */ + + boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ + + /* Saved references to initialized quantizer modules, + * in case we need to switch modes. + */ + struct jpeg_color_quantizer * quantizer_1pass; + struct jpeg_color_quantizer * quantizer_2pass; +} my_decomp_master; + +typedef my_decomp_master * my_master_ptr; + + +/* + * Determine whether merged upsample/color conversion should be used. + * CRUCIAL: this must match the actual capabilities of jdmerge.c! + */ + +LOCAL(boolean) +use_merged_upsample (j_decompress_ptr cinfo) +{ +#ifdef UPSAMPLE_MERGING_SUPPORTED + /* Merging is the equivalent of plain box-filter upsampling */ + if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) + return FALSE; + /* jdmerge.c only supports YCC=>RGB color conversion */ + if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || + cinfo->out_color_space != JCS_RGB || + cinfo->out_color_components != RGB_PIXELSIZE) + return FALSE; + /* and it only handles 2h1v or 2h2v sampling ratios */ + if (cinfo->comp_info[0].h_samp_factor != 2 || + cinfo->comp_info[1].h_samp_factor != 1 || + cinfo->comp_info[2].h_samp_factor != 1 || + cinfo->comp_info[0].v_samp_factor > 2 || + cinfo->comp_info[1].v_samp_factor != 1 || + cinfo->comp_info[2].v_samp_factor != 1) + return FALSE; + /* furthermore, it doesn't work if we've scaled the IDCTs differently */ + if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || + cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || + cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) + return FALSE; + /* ??? also need to test for upsample-time rescaling, when & if supported */ + return TRUE; /* by golly, it'll work... */ +#else + return FALSE; +#endif +} + + +/* + * Compute output image dimensions and related values. + * NOTE: this is exported for possible use by application. + * Hence it mustn't do anything that can't be done twice. + * Also note that it may be called before the master module is initialized! + */ + +GLOBAL(void) +jpeg_calc_output_dimensions (j_decompress_ptr cinfo) +/* Do computations that are needed before master selection phase */ +{ +#ifdef IDCT_SCALING_SUPPORTED + int ci; + jpeg_component_info *compptr; +#endif + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_READY) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + +#ifdef IDCT_SCALING_SUPPORTED + + /* Compute actual output image dimensions and DCT scaling choices. */ + if (cinfo->scale_num * 8 <= cinfo->scale_denom) { + /* Provide 1/8 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 8L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 8L); + cinfo->min_DCT_scaled_size = 1; + } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { + /* Provide 1/4 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 4L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 4L); + cinfo->min_DCT_scaled_size = 2; + } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { + /* Provide 1/2 scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width, 2L); + cinfo->output_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height, 2L); + cinfo->min_DCT_scaled_size = 4; + } else { + /* Provide 1/1 scaling */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + cinfo->min_DCT_scaled_size = DCTSIZE; + } + /* In selecting the actual DCT scaling for each component, we try to + * scale up the chroma components via IDCT scaling rather than upsampling. + * This saves time if the upsampler gets to use 1:1 scaling. + * Note this code assumes that the supported DCT scalings are powers of 2. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + int ssize = cinfo->min_DCT_scaled_size; + while (ssize < DCTSIZE && + (compptr->h_samp_factor * ssize * 2 <= + cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && + (compptr->v_samp_factor * ssize * 2 <= + cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { + ssize = ssize * 2; + } + compptr->DCT_scaled_size = ssize; + } + + /* Recompute downsampled dimensions of components; + * application needs to know these if using raw downsampled data. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Size in samples, after IDCT scaling */ + compptr->downsampled_width = (JDIMENSION) + jdiv_round_up((long) cinfo->image_width * + (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), + (long) (cinfo->max_h_samp_factor * DCTSIZE)); + compptr->downsampled_height = (JDIMENSION) + jdiv_round_up((long) cinfo->image_height * + (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), + (long) (cinfo->max_v_samp_factor * DCTSIZE)); + } + +#else /* !IDCT_SCALING_SUPPORTED */ + + /* Hardwire it to "no scaling" */ + cinfo->output_width = cinfo->image_width; + cinfo->output_height = cinfo->image_height; + /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, + * and has computed unscaled downsampled_width and downsampled_height. + */ + +#endif /* IDCT_SCALING_SUPPORTED */ + + /* Report number of components in selected colorspace. */ + /* Probably this should be in the color conversion module... */ + switch (cinfo->out_color_space) { + case JCS_GRAYSCALE: + cinfo->out_color_components = 1; + break; + case JCS_RGB: +#if RGB_PIXELSIZE != 3 + cinfo->out_color_components = RGB_PIXELSIZE; + break; +#endif /* else share code with YCbCr */ + case JCS_YCbCr: + cinfo->out_color_components = 3; + break; + case JCS_CMYK: + case JCS_YCCK: + cinfo->out_color_components = 4; + break; + default: /* else must be same colorspace as in file */ + cinfo->out_color_components = cinfo->num_components; + break; + } + cinfo->output_components = (cinfo->quantize_colors ? 1 : + cinfo->out_color_components); + + /* See if upsampler will want to emit more than one row at a time */ + if (use_merged_upsample(cinfo)) + cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; + else + cinfo->rec_outbuf_height = 1; +} + + +/* + * Several decompression processes need to range-limit values to the range + * 0..MAXJSAMPLE; the input value may fall somewhat outside this range + * due to noise introduced by quantization, roundoff error, etc. These + * processes are inner loops and need to be as fast as possible. On most + * machines, particularly CPUs with pipelines or instruction prefetch, + * a (subscript-check-less) C table lookup + * x = sample_range_limit[x]; + * is faster than explicit tests + * if (x < 0) x = 0; + * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; + * These processes all use a common table prepared by the routine below. + * + * For most steps we can mathematically guarantee that the initial value + * of x is within MAXJSAMPLE+1 of the legal range, so a table running from + * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial + * limiting step (just after the IDCT), a wildly out-of-range value is + * possible if the input data is corrupt. To avoid any chance of indexing + * off the end of memory and getting a bad-pointer trap, we perform the + * post-IDCT limiting thus: + * x = range_limit[x & MASK]; + * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit + * samples. Under normal circumstances this is more than enough range and + * a correct output will be generated; with bogus input data the mask will + * cause wraparound, and we will safely generate a bogus-but-in-range output. + * For the post-IDCT step, we want to convert the data from signed to unsigned + * representation by adding CENTERJSAMPLE at the same time that we limit it. + * So the post-IDCT limiting table ends up looking like this: + * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, + * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), + * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), + * 0,1,...,CENTERJSAMPLE-1 + * Negative inputs select values from the upper half of the table after + * masking. + * + * We can save some space by overlapping the start of the post-IDCT table + * with the simpler range limiting table. The post-IDCT table begins at + * sample_range_limit + CENTERJSAMPLE. + * + * Note that the table is allocated in near data space on PCs; it's small + * enough and used often enough to justify this. + */ + +LOCAL(void) +prepare_range_limit_table (j_decompress_ptr cinfo) +/* Allocate and fill in the sample_range_limit table */ +{ + JSAMPLE * table; + int i; + + table = (JSAMPLE *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); + table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ + cinfo->sample_range_limit = table; + /* First segment of "simple" table: limit[x] = 0 for x < 0 */ + MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); + /* Main part of "simple" table: limit[x] = x */ + for (i = 0; i <= MAXJSAMPLE; i++) + table[i] = (JSAMPLE) i; + table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ + /* End of simple table, rest of first half of post-IDCT table */ + for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) + table[i] = MAXJSAMPLE; + /* Second half of post-IDCT table */ + MEMZERO(table + (2 * (MAXJSAMPLE+1)), + (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); + MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), + cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); +} + + +/* + * Master selection of decompression modules. + * This is done once at jpeg_start_decompress time. We determine + * which modules will be used and give them appropriate initialization calls. + * We also initialize the decompressor input side to begin consuming data. + * + * Since jpeg_read_header has finished, we know what is in the SOF + * and (first) SOS markers. We also have all the application parameter + * settings. + */ + +LOCAL(void) +master_selection (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + boolean use_c_buffer; + long samplesperrow; + JDIMENSION jd_samplesperrow; + + /* Initialize dimensions and other stuff */ + jpeg_calc_output_dimensions(cinfo); + prepare_range_limit_table(cinfo); + + /* Width of an output scanline must be representable as JDIMENSION. */ + samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; + jd_samplesperrow = (JDIMENSION) samplesperrow; + if ((long) jd_samplesperrow != samplesperrow) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + + /* Initialize my private state */ + master->pass_number = 0; + master->using_merged_upsample = use_merged_upsample(cinfo); + + /* Color quantizer selection */ + master->quantizer_1pass = NULL; + master->quantizer_2pass = NULL; + /* No mode changes if not using buffered-image mode. */ + if (! cinfo->quantize_colors || ! cinfo->buffered_image) { + cinfo->enable_1pass_quant = FALSE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + } + if (cinfo->quantize_colors) { + if (cinfo->raw_data_out) + ERREXIT(cinfo, JERR_NOTIMPL); + /* 2-pass quantizer only works in 3-component color space. */ + if (cinfo->out_color_components != 3) { + cinfo->enable_1pass_quant = TRUE; + cinfo->enable_external_quant = FALSE; + cinfo->enable_2pass_quant = FALSE; + cinfo->colormap = NULL; + } else if (cinfo->colormap != NULL) { + cinfo->enable_external_quant = TRUE; + } else if (cinfo->two_pass_quantize) { + cinfo->enable_2pass_quant = TRUE; + } else { + cinfo->enable_1pass_quant = TRUE; + } + + if (cinfo->enable_1pass_quant) { +#ifdef QUANT_1PASS_SUPPORTED + jinit_1pass_quantizer(cinfo); + master->quantizer_1pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + + /* We use the 2-pass code to map to external colormaps. */ + if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { +#ifdef QUANT_2PASS_SUPPORTED + jinit_2pass_quantizer(cinfo); + master->quantizer_2pass = cinfo->cquantize; +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } + /* If both quantizers are initialized, the 2-pass one is left active; + * this is necessary for starting with quantization to an external map. + */ + } + + /* Post-processing: in particular, color conversion first */ + if (! cinfo->raw_data_out) { + if (master->using_merged_upsample) { +#ifdef UPSAMPLE_MERGING_SUPPORTED + jinit_merged_upsampler(cinfo); /* does color conversion too */ +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else { + jinit_color_deconverter(cinfo); + jinit_upsampler(cinfo); + } + jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); + } + /* Inverse DCT */ + jinit_inverse_dct(cinfo); + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef D_PROGRESSIVE_SUPPORTED + jinit_phuff_decoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_decoder(cinfo); + } + + /* Initialize principal buffer controllers. */ + use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; + jinit_d_coef_controller(cinfo, use_c_buffer); + + if (! cinfo->raw_data_out) + jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + +#ifdef D_MULTISCAN_FILES_SUPPORTED + /* If jpeg_start_decompress will read the whole file, initialize + * progress monitoring appropriately. The input step is counted + * as one pass. + */ + if (cinfo->progress != NULL && ! cinfo->buffered_image && + cinfo->inputctl->has_multiple_scans) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); + /* Count the input pass as done */ + master->pass_number++; + } +#endif /* D_MULTISCAN_FILES_SUPPORTED */ +} + + +/* + * Per-pass setup. + * This is called at the beginning of each output pass. We determine which + * modules will be active during this pass and give them appropriate + * start_pass calls. We also set is_dummy_pass to indicate whether this + * is a "real" output pass or a dummy pass for color quantization. + * (In the latter case, jdapistd.c will crank the pass to completion.) + */ + +METHODDEF(void) +prepare_for_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (master->pub.is_dummy_pass) { +#ifdef QUANT_2PASS_SUPPORTED + /* Final pass of 2-pass quantization */ + master->pub.is_dummy_pass = FALSE; + (*cinfo->cquantize->start_pass) (cinfo, FALSE); + (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); + (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + if (cinfo->quantize_colors && cinfo->colormap == NULL) { + /* Select new quantization method */ + if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { + cinfo->cquantize = master->quantizer_2pass; + master->pub.is_dummy_pass = TRUE; + } else if (cinfo->enable_1pass_quant) { + cinfo->cquantize = master->quantizer_1pass; + } else { + ERREXIT(cinfo, JERR_MODE_CHANGE); + } + } + (*cinfo->idct->start_pass) (cinfo); + (*cinfo->coef->start_output_pass) (cinfo); + if (! cinfo->raw_data_out) { + if (! master->using_merged_upsample) + (*cinfo->cconvert->start_pass) (cinfo); + (*cinfo->upsample->start_pass) (cinfo); + if (cinfo->quantize_colors) + (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); + (*cinfo->post->start_pass) (cinfo, + (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); + (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); + } + } + + /* Set up progress monitor's pass info if present */ + if (cinfo->progress != NULL) { + cinfo->progress->completed_passes = master->pass_number; + cinfo->progress->total_passes = master->pass_number + + (master->pub.is_dummy_pass ? 2 : 1); + /* In buffered-image mode, we assume one more output pass if EOI not + * yet reached, but no more passes if EOI has been reached. + */ + if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { + cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); + } + } +} + + +/* + * Finish up at end of an output pass. + */ + +METHODDEF(void) +finish_output_pass (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + if (cinfo->quantize_colors) + (*cinfo->cquantize->finish_pass) (cinfo); + master->pass_number++; +} + + +#ifdef D_MULTISCAN_FILES_SUPPORTED + +/* + * Switch to a new external colormap between output passes. + */ + +GLOBAL(void) +jpeg_new_colormap (j_decompress_ptr cinfo) +{ + my_master_ptr master = (my_master_ptr) cinfo->master; + + /* Prevent application from calling me at wrong times */ + if (cinfo->global_state != DSTATE_BUFIMAGE) + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + + if (cinfo->quantize_colors && cinfo->enable_external_quant && + cinfo->colormap != NULL) { + /* Select 2-pass quantizer for external colormap use */ + cinfo->cquantize = master->quantizer_2pass; + /* Notify quantizer of colormap change */ + (*cinfo->cquantize->new_color_map) (cinfo); + master->pub.is_dummy_pass = FALSE; /* just in case */ + } else + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + +#endif /* D_MULTISCAN_FILES_SUPPORTED */ + + +/* + * Initialize master decompression control and select active modules. + * This is performed at the start of jpeg_start_decompress. + */ + +GLOBAL(void) +jinit_master_decompress (j_decompress_ptr cinfo) +{ + my_master_ptr master; + + master = (my_master_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_decomp_master)); + cinfo->master = (struct jpeg_decomp_master *) master; + master->pub.prepare_for_output_pass = prepare_for_output_pass; + master->pub.finish_output_pass = finish_output_pass; + + master->pub.is_dummy_pass = FALSE; + + master_selection(cinfo); +} diff --git a/libraries/external/jpeglib/jdmaster.o b/libraries/external/jpeglib/jdmaster.o new file mode 100644 index 0000000..678d526 Binary files /dev/null and b/libraries/external/jpeglib/jdmaster.o differ diff --git a/libraries/external/jpeglib/jdmerge.c b/libraries/external/jpeglib/jdmerge.c new file mode 100755 index 0000000..9e3a595 --- /dev/null +++ b/libraries/external/jpeglib/jdmerge.c @@ -0,0 +1,400 @@ +/* + * jdmerge.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains code for merged upsampling/color conversion. + * + * This file combines functions from jdsample.c and jdcolor.c; + * read those files first to understand what's going on. + * + * When the chroma components are to be upsampled by simple replication + * (ie, box filtering), we can save some work in color conversion by + * calculating all the output pixels corresponding to a pair of chroma + * samples at one time. In the conversion equations + * R = Y + K1 * Cr + * G = Y + K2 * Cb + K3 * Cr + * B = Y + K4 * Cb + * only the Y term varies among the group of pixels corresponding to a pair + * of chroma samples, so the rest of the terms can be calculated just once. + * At typical sampling ratios, this eliminates half or three-quarters of the + * multiplications needed for color conversion. + * + * This file currently provides implementations for the following cases: + * YCbCr => RGB color conversion only. + * Sampling ratios of 2h1v or 2h2v. + * No scaling needed at upsample time. + * Corner-aligned (non-CCIR601) sampling alignment. + * Other special cases could be added, but in most applications these are + * the only common cases. (For uncommon cases we fall back on the more + * general code in jdsample.c and jdcolor.c.) + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef UPSAMPLE_MERGING_SUPPORTED + + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Pointer to routine to do actual upsampling/conversion of one row group */ + JMETHOD(void, upmethod, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf)); + + /* Private state for YCC->RGB conversion */ + int * Cr_r_tab; /* => table for Cr to R conversion */ + int * Cb_b_tab; /* => table for Cb to B conversion */ + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ + + /* For 2:1 vertical sampling, we produce two output rows at a time. + * We need a "spare" row buffer to hold the second output row if the + * application provides just a one-row buffer; we also use the spare + * to discard the dummy last row if the image height is odd. + */ + JSAMPROW spare_row; + boolean spare_full; /* T if spare buffer is occupied */ + + JDIMENSION out_row_width; /* samples per output row */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + +#define SCALEBITS 16 /* speediest right-shift on some machines */ +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) +#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. + * This is taken directly from jdcolor.c; see that file for more info. + */ + +LOCAL(void) +build_ycc_rgb_table (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int i; + INT32 x; + SHIFT_TEMPS + + upsample->Cr_r_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cb_b_tab = (int *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(int)); + upsample->Cr_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + upsample->Cb_g_tab = (INT32 *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (MAXJSAMPLE+1) * SIZEOF(INT32)); + + for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { + /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ + /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ + /* Cr=>R value is nearest int to 1.40200 * x */ + upsample->Cr_r_tab[i] = (int) + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); + /* Cb=>B value is nearest int to 1.77200 * x */ + upsample->Cb_b_tab[i] = (int) + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); + /* Cr=>G value is scaled-up -0.71414 * x */ + upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; + /* Cb=>G value is scaled-up -0.34414 * x */ + /* We also add in ONE_HALF so that need not do it in inner loop */ + upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; + } +} + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_merged_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the spare buffer empty */ + upsample->spare_full = FALSE; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * The control routine just handles the row buffering considerations. + */ + +METHODDEF(void) +merged_2v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 2:1 vertical sampling case: may need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPROW work_ptrs[2]; + JDIMENSION num_rows; /* number of rows returned to caller */ + + if (upsample->spare_full) { + /* If we have a spare row saved from a previous cycle, just return it. */ + jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, + 1, upsample->out_row_width); + num_rows = 1; + upsample->spare_full = FALSE; + } else { + /* Figure number of rows to return to caller. */ + num_rows = 2; + /* Not more than the distance to the end of the image. */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + /* Create output pointer array for upsampler. */ + work_ptrs[0] = output_buf[*out_row_ctr]; + if (num_rows > 1) { + work_ptrs[1] = output_buf[*out_row_ctr + 1]; + } else { + work_ptrs[1] = upsample->spare_row; + upsample->spare_full = TRUE; + } + /* Now do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); + } + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (! upsample->spare_full) + (*in_row_group_ctr)++; +} + + +METHODDEF(void) +merged_1v_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +/* 1:1 vertical sampling case: much easier, never need a spare row. */ +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Just do the upsampling. */ + (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, + output_buf + *out_row_ctr); + /* Adjust counts */ + (*out_row_ctr)++; + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by the control routines to do + * the actual upsampling/conversion. One row group is processed per call. + * + * Note: since we may be writing directly into application-supplied buffers, + * we have to be honest about the output width; we can't assume the buffer + * has been rounded up to an even width. + */ + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. + */ + +METHODDEF(void) +h2v1_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr; + JSAMPROW inptr0, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr0 = input_buf[0][in_row_group_ctr]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr = output_buf[0]; + /* Loop for each pair of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 2 Y values and emit 2 pixels */ + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr0++); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + outptr += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr0); + outptr[RGB_RED] = range_limit[y + cred]; + outptr[RGB_GREEN] = range_limit[y + cgreen]; + outptr[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. + */ + +METHODDEF(void) +h2v2_merged_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, + JSAMPARRAY output_buf) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + register int y, cred, cgreen, cblue; + int cb, cr; + register JSAMPROW outptr0, outptr1; + JSAMPROW inptr00, inptr01, inptr1, inptr2; + JDIMENSION col; + /* copy these pointers into registers if possible */ + register JSAMPLE * range_limit = cinfo->sample_range_limit; + int * Crrtab = upsample->Cr_r_tab; + int * Cbbtab = upsample->Cb_b_tab; + INT32 * Crgtab = upsample->Cr_g_tab; + INT32 * Cbgtab = upsample->Cb_g_tab; + SHIFT_TEMPS + + inptr00 = input_buf[0][in_row_group_ctr*2]; + inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; + inptr1 = input_buf[1][in_row_group_ctr]; + inptr2 = input_buf[2][in_row_group_ctr]; + outptr0 = output_buf[0]; + outptr1 = output_buf[1]; + /* Loop for each group of output pixels */ + for (col = cinfo->output_width >> 1; col > 0; col--) { + /* Do the chroma part of the calculation */ + cb = GETJSAMPLE(*inptr1++); + cr = GETJSAMPLE(*inptr2++); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + /* Fetch 4 Y values and emit 4 pixels */ + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr00++); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + outptr0 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + y = GETJSAMPLE(*inptr01++); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + outptr1 += RGB_PIXELSIZE; + } + /* If image width is odd, do the last output column separately */ + if (cinfo->output_width & 1) { + cb = GETJSAMPLE(*inptr1); + cr = GETJSAMPLE(*inptr2); + cred = Crrtab[cr]; + cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); + cblue = Cbbtab[cb]; + y = GETJSAMPLE(*inptr00); + outptr0[RGB_RED] = range_limit[y + cred]; + outptr0[RGB_GREEN] = range_limit[y + cgreen]; + outptr0[RGB_BLUE] = range_limit[y + cblue]; + y = GETJSAMPLE(*inptr01); + outptr1[RGB_RED] = range_limit[y + cred]; + outptr1[RGB_GREEN] = range_limit[y + cgreen]; + outptr1[RGB_BLUE] = range_limit[y + cblue]; + } +} + + +/* + * Module initialization routine for merged upsampling/color conversion. + * + * NB: this is called under the conditions determined by use_merged_upsample() + * in jdmaster.c. That routine MUST correspond to the actual capabilities + * of this module; no safety checks are made here. + */ + +GLOBAL(void) +jinit_merged_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + + upsample = (my_upsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_upsampler)); + cinfo->upsample = (struct jpeg_upsampler *) upsample; + upsample->pub.start_pass = start_pass_merged_upsample; + upsample->pub.need_context_rows = FALSE; + + upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; + + if (cinfo->max_v_samp_factor == 2) { + upsample->pub.upsample = merged_2v_upsample; + upsample->upmethod = h2v2_merged_upsample; + /* Allocate a spare row buffer */ + upsample->spare_row = (JSAMPROW) + (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); + } else { + upsample->pub.upsample = merged_1v_upsample; + upsample->upmethod = h2v1_merged_upsample; + /* No spare row needed */ + upsample->spare_row = NULL; + } + + build_ycc_rgb_table(cinfo); +} + +#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/libraries/external/jpeglib/jdmerge.o b/libraries/external/jpeglib/jdmerge.o new file mode 100644 index 0000000..fc279ce Binary files /dev/null and b/libraries/external/jpeglib/jdmerge.o differ diff --git a/libraries/external/jpeglib/jdphuff.c b/libraries/external/jpeglib/jdphuff.c new file mode 100755 index 0000000..2404743 --- /dev/null +++ b/libraries/external/jpeglib/jdphuff.c @@ -0,0 +1,668 @@ +/* + * jdphuff.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains Huffman entropy decoding routines for progressive JPEG. + * + * Much of the complexity here has to do with supporting input suspension. + * If the data source module demands suspension, we want to be able to back + * up to the start of the current MCU. To do this, we copy state variables + * into local working storage, and update them back to the permanent + * storage only upon successful completion of an MCU. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdhuff.h" /* Declarations shared with jdhuff.c */ + + +#ifdef D_PROGRESSIVE_SUPPORTED + +/* + * Expanded entropy decoder object for progressive Huffman decoding. + * + * The savable_state subrecord contains fields that change within an MCU, + * but must not be updated permanently until we complete the MCU. + */ + +typedef struct { + unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ + int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ +} savable_state; + +/* This macro is to work around compilers with missing or broken + * structure assignment. You'll need to fix this code if you have + * such a compiler and you change MAX_COMPS_IN_SCAN. + */ + +#ifndef NO_STRUCT_ASSIGN +#define ASSIGN_STATE(dest,src) ((dest) = (src)) +#else +#if MAX_COMPS_IN_SCAN == 4 +#define ASSIGN_STATE(dest,src) \ + ((dest).EOBRUN = (src).EOBRUN, \ + (dest).last_dc_val[0] = (src).last_dc_val[0], \ + (dest).last_dc_val[1] = (src).last_dc_val[1], \ + (dest).last_dc_val[2] = (src).last_dc_val[2], \ + (dest).last_dc_val[3] = (src).last_dc_val[3]) +#endif +#endif + + +typedef struct { + struct jpeg_entropy_decoder pub; /* public fields */ + + /* These fields are loaded into local variables at start of each MCU. + * In case of suspension, we exit WITHOUT updating them. + */ + bitread_perm_state bitstate; /* Bit buffer at start of MCU */ + savable_state saved; /* Other state at start of MCU */ + + /* These fields are NOT loaded into local working state. */ + unsigned int restarts_to_go; /* MCUs left in this restart interval */ + + /* Pointers to derived tables (these workspaces have image lifespan) */ + d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; + + d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ +} phuff_entropy_decoder; + +typedef phuff_entropy_decoder * phuff_entropy_ptr; + +/* Forward declarations */ +METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); +METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); + + +/* + * Initialize for a Huffman-compressed scan. + */ + +METHODDEF(void) +start_pass_phuff_decoder (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + boolean is_DC_band, bad; + int ci, coefi, tbl; + int *coef_bit_ptr; + jpeg_component_info * compptr; + + is_DC_band = (cinfo->Ss == 0); + + /* Validate scan parameters */ + bad = FALSE; + if (is_DC_band) { + if (cinfo->Se != 0) + bad = TRUE; + } else { + /* need not check Ss/Se < 0 since they came from unsigned bytes */ + if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) + bad = TRUE; + /* AC scans may have only one component */ + if (cinfo->comps_in_scan != 1) + bad = TRUE; + } + if (cinfo->Ah != 0) { + /* Successive approximation refinement scan: must have Al = Ah-1. */ + if (cinfo->Al != cinfo->Ah-1) + bad = TRUE; + } + if (cinfo->Al > 13) /* need not check for < 0 */ + bad = TRUE; + /* Arguably the maximum Al value should be less than 13 for 8-bit precision, + * but the spec doesn't say so, and we try to be liberal about what we + * accept. Note: large Al values could result in out-of-range DC + * coefficients during early scans, leading to bizarre displays due to + * overflows in the IDCT math. But we won't crash. + */ + if (bad) + ERREXIT4(cinfo, JERR_BAD_PROGRESSION, + cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); + /* Update progression status, and verify that scan order is legal. + * Note that inter-scan inconsistencies are treated as warnings + * not fatal errors ... not clear if this is right way to behave. + */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + int cindex = cinfo->cur_comp_info[ci]->component_index; + coef_bit_ptr = & cinfo->coef_bits[cindex][0]; + if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); + for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { + int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; + if (cinfo->Ah != expected) + WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); + coef_bit_ptr[coefi] = cinfo->Al; + } + } + + /* Select MCU decoding routine */ + if (cinfo->Ah == 0) { + if (is_DC_band) + entropy->pub.decode_mcu = decode_mcu_DC_first; + else + entropy->pub.decode_mcu = decode_mcu_AC_first; + } else { + if (is_DC_band) + entropy->pub.decode_mcu = decode_mcu_DC_refine; + else + entropy->pub.decode_mcu = decode_mcu_AC_refine; + } + + for (ci = 0; ci < cinfo->comps_in_scan; ci++) { + compptr = cinfo->cur_comp_info[ci]; + /* Make sure requested tables are present, and compute derived tables. + * We may build same derived table more than once, but it's not expensive. + */ + if (is_DC_band) { + if (cinfo->Ah == 0) { /* DC refinement needs no table */ + tbl = compptr->dc_tbl_no; + jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, + & entropy->derived_tbls[tbl]); + } + } else { + tbl = compptr->ac_tbl_no; + jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, + & entropy->derived_tbls[tbl]); + /* remember the single active table */ + entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; + } + /* Initialize DC predictions to 0 */ + entropy->saved.last_dc_val[ci] = 0; + } + + /* Initialize bitread state variables */ + entropy->bitstate.bits_left = 0; + entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ + entropy->pub.insufficient_data = FALSE; + + /* Initialize private state variables */ + entropy->saved.EOBRUN = 0; + + /* Initialize restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; +} + + +/* + * Figure F.12: extend sign bit. + * On some machines, a shift and add will be faster than a table lookup. + */ + +#ifdef AVOID_TABLES + +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) + +#else + +#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) + +static const int extend_test[16] = /* entry n is 2**(n-1) */ + { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, + 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; + +static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ + { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, + ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, + ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, + ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; + +#endif /* AVOID_TABLES */ + + +/* + * Check for a restart marker & resynchronize decoder. + * Returns FALSE if must suspend. + */ + +LOCAL(boolean) +process_restart (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int ci; + + /* Throw away any unused bits remaining in bit buffer; */ + /* include any full bytes in next_marker's count of discarded bytes */ + cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; + entropy->bitstate.bits_left = 0; + + /* Advance past the RSTn marker */ + if (! (*cinfo->marker->read_restart_marker) (cinfo)) + return FALSE; + + /* Re-initialize DC predictions to 0 */ + for (ci = 0; ci < cinfo->comps_in_scan; ci++) + entropy->saved.last_dc_val[ci] = 0; + /* Re-init EOB run count, too */ + entropy->saved.EOBRUN = 0; + + /* Reset restart counter */ + entropy->restarts_to_go = cinfo->restart_interval; + + /* Reset out-of-data flag, unless read_restart_marker left us smack up + * against a marker. In that case we will end up treating the next data + * segment as empty, and we can avoid producing bogus output pixels by + * leaving the flag set. + */ + if (cinfo->unread_marker == 0) + entropy->pub.insufficient_data = FALSE; + + return TRUE; +} + + +/* + * Huffman MCU decoding. + * Each of these routines decodes and returns one MCU's worth of + * Huffman-compressed coefficients. + * The coefficients are reordered from zigzag order into natural array order, + * but are not dequantized. + * + * The i'th block of the MCU is stored into the block pointed to by + * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. + * + * We return FALSE if data source requested suspension. In that case no + * changes have been made to permanent state. (Exception: some output + * coefficients may already have been assigned. This is harmless for + * spectral selection, since we'll just re-assign them on the next call. + * Successive approximation AC refinement has to be more careful, however.) + */ + +/* + * MCU decoding for DC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Al = cinfo->Al; + register int s, r; + int blkn, ci; + JBLOCKROW block; + BITREAD_STATE_VARS; + savable_state state; + d_derived_tbl * tbl; + jpeg_component_info * compptr; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(state, entropy->saved); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + ci = cinfo->MCU_membership[blkn]; + compptr = cinfo->cur_comp_info[ci]; + tbl = entropy->derived_tbls[compptr->dc_tbl_no]; + + /* Decode a single block's worth of coefficients */ + + /* Section F.2.2.1: decode the DC coefficient difference */ + HUFF_DECODE(s, br_state, tbl, return FALSE, label1); + if (s) { + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + } + + /* Convert DC difference to actual value, update last_dc_val */ + s += state.last_dc_val[ci]; + state.last_dc_val[ci] = s; + /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ + (*block)[0] = (JCOEF) (s << Al); + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + ASSIGN_STATE(entropy->saved, state); + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC initial scan (either spectral selection, + * or first pass of successive approximation). + */ + +METHODDEF(boolean) +decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Se = cinfo->Se; + int Al = cinfo->Al; + register int s, k, r; + unsigned int EOBRUN; + JBLOCKROW block; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, just leave the MCU set to zeroes. + * This way, we return uniform gray for the remainder of the segment. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state. + * We can avoid loading/saving bitread state if in an EOB run. + */ + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ + + /* There is always only one block per MCU */ + + if (EOBRUN > 0) /* if it's a band of zeroes... */ + EOBRUN--; /* ...process it now (we do nothing) */ + else { + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + for (k = cinfo->Ss; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, return FALSE, label2); + r = s >> 4; + s &= 15; + if (s) { + k += r; + CHECK_BIT_BUFFER(br_state, s, return FALSE); + r = GET_BITS(s); + s = HUFF_EXTEND(r, s); + /* Scale and output coefficient in natural (dezigzagged) order */ + (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); + } else { + if (r == 15) { /* ZRL */ + k += 15; /* skip 15 zeroes in band */ + } else { /* EOBr, run length is 2^r + appended bits */ + EOBRUN = 1 << r; + if (r) { /* EOBr, r > 0 */ + CHECK_BIT_BUFFER(br_state, r, return FALSE); + r = GET_BITS(r); + EOBRUN += r; + } + EOBRUN--; /* this band is processed at this moment */ + break; /* force end-of-band */ + } + } + } + + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + } + + /* Completed MCU, so update state */ + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for DC successive approximation refinement scan. + * Note: we assume such scans can be multi-component, although the spec + * is not very clear on the point. + */ + +METHODDEF(boolean) +decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + int blkn; + JBLOCKROW block; + BITREAD_STATE_VARS; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* Not worth the cycles to check insufficient_data here, + * since we will not change the data anyway if we read zeroes. + */ + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + + /* Outer loop handles each block in the MCU */ + + for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { + block = MCU_data[blkn]; + + /* Encoded data is simply the next bit of the two's-complement DC value */ + CHECK_BIT_BUFFER(br_state, 1, return FALSE); + if (GET_BITS(1)) + (*block)[0] |= p1; + /* Note: since we use |=, repeating the assignment later is safe */ + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; +} + + +/* + * MCU decoding for AC successive approximation refinement scan. + */ + +METHODDEF(boolean) +decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) +{ + phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; + int Se = cinfo->Se; + int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ + int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ + register int s, k, r; + unsigned int EOBRUN; + JBLOCKROW block; + JCOEFPTR thiscoef; + BITREAD_STATE_VARS; + d_derived_tbl * tbl; + int num_newnz; + int newnz_pos[DCTSIZE2]; + + /* Process restart marker if needed; may have to suspend */ + if (cinfo->restart_interval) { + if (entropy->restarts_to_go == 0) + if (! process_restart(cinfo)) + return FALSE; + } + + /* If we've run out of data, don't modify the MCU. + */ + if (! entropy->pub.insufficient_data) { + + /* Load up working state */ + BITREAD_LOAD_STATE(cinfo,entropy->bitstate); + EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ + + /* There is always only one block per MCU */ + block = MCU_data[0]; + tbl = entropy->ac_derived_tbl; + + /* If we are forced to suspend, we must undo the assignments to any newly + * nonzero coefficients in the block, because otherwise we'd get confused + * next time about which coefficients were already nonzero. + * But we need not undo addition of bits to already-nonzero coefficients; + * instead, we can test the current bit to see if we already did it. + */ + num_newnz = 0; + + /* initialize coefficient loop counter to start of band */ + k = cinfo->Ss; + + if (EOBRUN == 0) { + for (; k <= Se; k++) { + HUFF_DECODE(s, br_state, tbl, goto undoit, label3); + r = s >> 4; + s &= 15; + if (s) { + if (s != 1) /* size of new coef should always be 1 */ + WARNMS(cinfo, JWRN_HUFF_BAD_CODE); + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) + s = p1; /* newly nonzero coef is positive */ + else + s = m1; /* newly nonzero coef is negative */ + } else { + if (r != 15) { + EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ + if (r) { + CHECK_BIT_BUFFER(br_state, r, goto undoit); + r = GET_BITS(r); + EOBRUN += r; + } + break; /* rest of block is handled by EOB logic */ + } + /* note s = 0 for processing ZRL */ + } + /* Advance over already-nonzero coefs and r still-zero coefs, + * appending correction bits to the nonzeroes. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + do { + thiscoef = *block + jpeg_natural_order[k]; + if (*thiscoef != 0) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } else { + if (--r < 0) + break; /* reached target zero coefficient */ + } + k++; + } while (k <= Se); + if (s) { + int pos = jpeg_natural_order[k]; + /* Output newly nonzero coefficient */ + (*block)[pos] = (JCOEF) s; + /* Remember its position in case we have to suspend */ + newnz_pos[num_newnz++] = pos; + } + } + } + + if (EOBRUN > 0) { + /* Scan any remaining coefficient positions after the end-of-band + * (the last newly nonzero coefficient, if any). Append a correction + * bit to each already-nonzero coefficient. A correction bit is 1 + * if the absolute value of the coefficient must be increased. + */ + for (; k <= Se; k++) { + thiscoef = *block + jpeg_natural_order[k]; + if (*thiscoef != 0) { + CHECK_BIT_BUFFER(br_state, 1, goto undoit); + if (GET_BITS(1)) { + if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ + if (*thiscoef >= 0) + *thiscoef += p1; + else + *thiscoef += m1; + } + } + } + } + /* Count one block completed in EOB run */ + EOBRUN--; + } + + /* Completed MCU, so update state */ + BITREAD_SAVE_STATE(cinfo,entropy->bitstate); + entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ + } + + /* Account for restart interval (no-op if not using restarts) */ + entropy->restarts_to_go--; + + return TRUE; + +undoit: + /* Re-zero any output coefficients that we made newly nonzero */ + while (num_newnz > 0) + (*block)[newnz_pos[--num_newnz]] = 0; + + return FALSE; +} + + +/* + * Module initialization routine for progressive Huffman entropy decoding. + */ + +GLOBAL(void) +jinit_phuff_decoder (j_decompress_ptr cinfo) +{ + phuff_entropy_ptr entropy; + int *coef_bit_ptr; + int ci, i; + + entropy = (phuff_entropy_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(phuff_entropy_decoder)); + cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; + entropy->pub.start_pass = start_pass_phuff_decoder; + + /* Mark derived tables unallocated */ + for (i = 0; i < NUM_HUFF_TBLS; i++) { + entropy->derived_tbls[i] = NULL; + } + + /* Create progression status table */ + cinfo->coef_bits = (int (*)[DCTSIZE2]) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->num_components*DCTSIZE2*SIZEOF(int)); + coef_bit_ptr = & cinfo->coef_bits[0][0]; + for (ci = 0; ci < cinfo->num_components; ci++) + for (i = 0; i < DCTSIZE2; i++) + *coef_bit_ptr++ = -1; +} + +#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/libraries/external/jpeglib/jdphuff.o b/libraries/external/jpeglib/jdphuff.o new file mode 100644 index 0000000..1e127fb Binary files /dev/null and b/libraries/external/jpeglib/jdphuff.o differ diff --git a/libraries/external/jpeglib/jdpostct.c b/libraries/external/jpeglib/jdpostct.c new file mode 100755 index 0000000..7ba9eed --- /dev/null +++ b/libraries/external/jpeglib/jdpostct.c @@ -0,0 +1,290 @@ +/* + * jdpostct.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the decompression postprocessing controller. + * This controller manages the upsampling, color conversion, and color + * quantization/reduction steps; specifically, it controls the buffering + * between upsample/color conversion and color quantization/reduction. + * + * If no color quantization/reduction is required, then this module has no + * work to do, and it just hands off to the upsample/color conversion code. + * An integrated upsample/convert/quantize process would replace this module + * entirely. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Private buffer controller object */ + +typedef struct { + struct jpeg_d_post_controller pub; /* public fields */ + + /* Color quantization source buffer: this holds output data from + * the upsample/color conversion step to be passed to the quantizer. + * For two-pass color quantization, we need a full-image buffer; + * for one-pass operation, a strip buffer is sufficient. + */ + jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ + JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ + JDIMENSION strip_height; /* buffer size in rows */ + /* for two-pass mode only: */ + JDIMENSION starting_row; /* row # of first row in current strip */ + JDIMENSION next_row; /* index of next row to fill/empty in strip */ +} my_post_controller; + +typedef my_post_controller * my_post_ptr; + + +/* Forward declarations */ +METHODDEF(void) post_process_1pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#ifdef QUANT_2PASS_SUPPORTED +METHODDEF(void) post_process_prepass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +METHODDEF(void) post_process_2pass + JPP((j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +#endif + + +/* + * Initialize for a processing pass. + */ + +METHODDEF(void) +start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + + switch (pass_mode) { + case JBUF_PASS_THRU: + if (cinfo->quantize_colors) { + /* Single-pass processing with color quantization. */ + post->pub.post_process_data = post_process_1pass; + /* We could be doing buffered-image output before starting a 2-pass + * color quantization; in that case, jinit_d_post_controller did not + * allocate a strip buffer. Use the virtual-array buffer as workspace. + */ + if (post->buffer == NULL) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + (JDIMENSION) 0, post->strip_height, TRUE); + } + } else { + /* For single-pass processing without color quantization, + * I have no work to do; just call the upsampler directly. + */ + post->pub.post_process_data = cinfo->upsample->upsample; + } + break; +#ifdef QUANT_2PASS_SUPPORTED + case JBUF_SAVE_AND_PASS: + /* First pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_prepass; + break; + case JBUF_CRANK_DEST: + /* Second pass of 2-pass quantization */ + if (post->whole_image == NULL) + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + post->pub.post_process_data = post_process_2pass; + break; +#endif /* QUANT_2PASS_SUPPORTED */ + default: + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); + break; + } + post->starting_row = post->next_row = 0; +} + + +/* + * Process some data in the one-pass (strip buffer) case. + * This is used for color precision reduction as well as one-pass quantization. + */ + +METHODDEF(void) +post_process_1pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Fill the buffer, but not more than what we can dump out in one go. */ + /* Note we rely on the upsampler to detect bottom of image. */ + max_rows = out_rows_avail - *out_row_ctr; + if (max_rows > post->strip_height) + max_rows = post->strip_height; + num_rows = 0; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &num_rows, max_rows); + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer, output_buf + *out_row_ctr, (int) num_rows); + *out_row_ctr += num_rows; +} + + +#ifdef QUANT_2PASS_SUPPORTED + +/* + * Process some data in the first pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_prepass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION old_next_row, num_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, TRUE); + } + + /* Upsample some data (up to a strip height's worth). */ + old_next_row = post->next_row; + (*cinfo->upsample->upsample) (cinfo, + input_buf, in_row_group_ctr, in_row_groups_avail, + post->buffer, &post->next_row, post->strip_height); + + /* Allow quantizer to scan new data. No data is emitted, */ + /* but we advance out_row_ctr so outer loop can tell when we're done. */ + if (post->next_row > old_next_row) { + num_rows = post->next_row - old_next_row; + (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, + (JSAMPARRAY) NULL, (int) num_rows); + *out_row_ctr += num_rows; + } + + /* Advance if we filled the strip. */ + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + + +/* + * Process some data in the second pass of 2-pass quantization. + */ + +METHODDEF(void) +post_process_2pass (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_post_ptr post = (my_post_ptr) cinfo->post; + JDIMENSION num_rows, max_rows; + + /* Reposition virtual buffer if at start of strip. */ + if (post->next_row == 0) { + post->buffer = (*cinfo->mem->access_virt_sarray) + ((j_common_ptr) cinfo, post->whole_image, + post->starting_row, post->strip_height, FALSE); + } + + /* Determine number of rows to emit. */ + num_rows = post->strip_height - post->next_row; /* available in strip */ + max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ + if (num_rows > max_rows) + num_rows = max_rows; + /* We have to check bottom of image here, can't depend on upsampler. */ + max_rows = cinfo->output_height - post->starting_row; + if (num_rows > max_rows) + num_rows = max_rows; + + /* Quantize and emit data. */ + (*cinfo->cquantize->color_quantize) (cinfo, + post->buffer + post->next_row, output_buf + *out_row_ctr, + (int) num_rows); + *out_row_ctr += num_rows; + + /* Advance if we filled the strip. */ + post->next_row += num_rows; + if (post->next_row >= post->strip_height) { + post->starting_row += post->strip_height; + post->next_row = 0; + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ + + +/* + * Initialize postprocessing controller. + */ + +GLOBAL(void) +jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) +{ + my_post_ptr post; + + post = (my_post_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_post_controller)); + cinfo->post = (struct jpeg_d_post_controller *) post; + post->pub.start_pass = start_pass_dpost; + post->whole_image = NULL; /* flag for no virtual arrays */ + post->buffer = NULL; /* flag for no strip buffer */ + + /* Create the quantization buffer, if needed */ + if (cinfo->quantize_colors) { + /* The buffer strip height is max_v_samp_factor, which is typically + * an efficient number of rows for upsampling to return. + * (In the presence of output rescaling, we might want to be smarter?) + */ + post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; + if (need_full_buffer) { + /* Two-pass color quantization: need full-image storage. */ + /* We round up the number of rows to a multiple of the strip height. */ +#ifdef QUANT_2PASS_SUPPORTED + post->whole_image = (*cinfo->mem->request_virt_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, + cinfo->output_width * cinfo->out_color_components, + (JDIMENSION) jround_up((long) cinfo->output_height, + (long) post->strip_height), + post->strip_height); +#else + ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); +#endif /* QUANT_2PASS_SUPPORTED */ + } else { + /* One-pass color quantization: just make a strip buffer. */ + post->buffer = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + cinfo->output_width * cinfo->out_color_components, + post->strip_height); + } + } +} diff --git a/libraries/external/jpeglib/jdpostct.o b/libraries/external/jpeglib/jdpostct.o new file mode 100644 index 0000000..ee1fc31 Binary files /dev/null and b/libraries/external/jpeglib/jdpostct.o differ diff --git a/libraries/external/jpeglib/jdsample.c b/libraries/external/jpeglib/jdsample.c new file mode 100755 index 0000000..e0d9040 --- /dev/null +++ b/libraries/external/jpeglib/jdsample.c @@ -0,0 +1,478 @@ +/* + * jdsample.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains upsampling routines. + * + * Upsampling input data is counted in "row groups". A row group + * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) + * sample rows of each component. Upsampling will normally produce + * max_v_samp_factor pixel rows from each row group (but this could vary + * if the upsampler is applying a scale factor of its own). + * + * An excellent reference for image resampling is + * Digital Image Warping, George Wolberg, 1990. + * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Pointer to routine to upsample a single component */ +typedef JMETHOD(void, upsample1_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); + +/* Private subobject */ + +typedef struct { + struct jpeg_upsampler pub; /* public fields */ + + /* Color conversion buffer. When using separate upsampling and color + * conversion steps, this buffer holds one upsampled row group until it + * has been color converted and output. + * Note: we do not allocate any storage for component(s) which are full-size, + * ie do not need rescaling. The corresponding entry of color_buf[] is + * simply set to point to the input data array, thereby avoiding copying. + */ + JSAMPARRAY color_buf[MAX_COMPONENTS]; + + /* Per-component upsampling method pointers */ + upsample1_ptr methods[MAX_COMPONENTS]; + + int next_row_out; /* counts rows emitted from color_buf */ + JDIMENSION rows_to_go; /* counts rows remaining in image */ + + /* Height of an input row group for each component. */ + int rowgroup_height[MAX_COMPONENTS]; + + /* These arrays save pixel expansion factors so that int_expand need not + * recompute them each time. They are unused for other upsampling methods. + */ + UINT8 h_expand[MAX_COMPONENTS]; + UINT8 v_expand[MAX_COMPONENTS]; +} my_upsampler; + +typedef my_upsampler * my_upsample_ptr; + + +/* + * Initialize for an upsampling pass. + */ + +METHODDEF(void) +start_pass_upsample (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + + /* Mark the conversion buffer empty */ + upsample->next_row_out = cinfo->max_v_samp_factor; + /* Initialize total-height counter for detecting bottom of image */ + upsample->rows_to_go = cinfo->output_height; +} + + +/* + * Control routine to do upsampling (and color conversion). + * + * In this version we upsample each component independently. + * We upsample one row group into the conversion buffer, then apply + * color conversion a row at a time. + */ + +METHODDEF(void) +sep_upsample (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + int ci; + jpeg_component_info * compptr; + JDIMENSION num_rows; + + /* Fill the conversion buffer, if it's empty */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) { + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Invoke per-component upsample method. Notice we pass a POINTER + * to color_buf[ci], so that fullsize_upsample can change it. + */ + (*upsample->methods[ci]) (cinfo, compptr, + input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), + upsample->color_buf + ci); + } + upsample->next_row_out = 0; + } + + /* Color-convert and emit rows */ + + /* How many we have in the buffer: */ + num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); + /* Not more than the distance to the end of the image. Need this test + * in case the image height is not a multiple of max_v_samp_factor: + */ + if (num_rows > upsample->rows_to_go) + num_rows = upsample->rows_to_go; + /* And not more than what the client can accept: */ + out_rows_avail -= *out_row_ctr; + if (num_rows > out_rows_avail) + num_rows = out_rows_avail; + + (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, + (JDIMENSION) upsample->next_row_out, + output_buf + *out_row_ctr, + (int) num_rows); + + /* Adjust counts */ + *out_row_ctr += num_rows; + upsample->rows_to_go -= num_rows; + upsample->next_row_out += num_rows; + /* When the buffer is emptied, declare this input row group consumed */ + if (upsample->next_row_out >= cinfo->max_v_samp_factor) + (*in_row_group_ctr)++; +} + + +/* + * These are the routines invoked by sep_upsample to upsample pixel values + * of a single component. One row group is processed per call. + */ + + +/* + * For full-size components, we just make color_buf[ci] point at the + * input buffer, and thus avoid copying any data. Note that this is + * safe only because sep_upsample doesn't declare the input row group + * "consumed" until we are done color converting and emitting it. + */ + +METHODDEF(void) +fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + *output_data_ptr = input_data; +} + + +/* + * This is a no-op version used for "uninteresting" components. + * These components will not be referenced by color conversion. + */ + +METHODDEF(void) +noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + *output_data_ptr = NULL; /* safety check */ +} + + +/* + * This version handles any integral sampling ratios. + * This is not used for typical JPEG files, so it need not be fast. + * Nor, for that matter, is it particularly accurate: the algorithm is + * simple replication of the input pixel onto the corresponding output + * pixels. The hi-falutin sampling literature refers to this as a + * "box filter". A box filter tends to introduce visible artifacts, + * so if you are actually going to use 3:1 or 4:1 sampling ratios + * you would be well advised to improve this code. + */ + +METHODDEF(void) +int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + register int h; + JSAMPROW outend; + int h_expand, v_expand; + int inrow, outrow; + + h_expand = upsample->h_expand[compptr->component_index]; + v_expand = upsample->v_expand[compptr->component_index]; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + /* Generate one output row with proper horizontal expansion */ + inptr = input_data[inrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + for (h = h_expand; h > 0; h--) { + *outptr++ = invalue; + } + } + /* Generate any additional output rows by duplicating the first one */ + if (v_expand > 1) { + jcopy_sample_rows(output_data, outrow, output_data, outrow+1, + v_expand-1, cinfo->output_width); + } + inrow++; + outrow += v_expand; + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int inrow; + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + inptr = input_data[inrow]; + outptr = output_data[inrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + } +} + + +/* + * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. + * It's still a box filter. + */ + +METHODDEF(void) +h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register JSAMPLE invalue; + JSAMPROW outend; + int inrow, outrow; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + inptr = input_data[inrow]; + outptr = output_data[outrow]; + outend = outptr + cinfo->output_width; + while (outptr < outend) { + invalue = *inptr++; /* don't need GETJSAMPLE() here */ + *outptr++ = invalue; + *outptr++ = invalue; + } + jcopy_sample_rows(output_data, outrow, output_data, outrow+1, + 1, cinfo->output_width); + inrow++; + outrow += 2; + } +} + + +/* + * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. + * + * The upsampling algorithm is linear interpolation between pixel centers, + * also known as a "triangle filter". This is a good compromise between + * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 + * of the way between input pixel centers. + * + * A note about the "bias" calculations: when rounding fractional values to + * integer, we do not want to always round 0.5 up to the next integer. + * If we did that, we'd introduce a noticeable bias towards larger values. + * Instead, this code is arranged so that 0.5 will be rounded up or down at + * alternate pixel locations (a simple ordered dither pattern). + */ + +METHODDEF(void) +h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr, outptr; + register int invalue; + register JDIMENSION colctr; + int inrow; + + for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { + inptr = input_data[inrow]; + outptr = output_data[inrow]; + /* Special case for first column */ + invalue = GETJSAMPLE(*inptr++); + *outptr++ = (JSAMPLE) invalue; + *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); + + for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { + /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ + invalue = GETJSAMPLE(*inptr++) * 3; + *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); + *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); + } + + /* Special case for last column */ + invalue = GETJSAMPLE(*inptr); + *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); + *outptr++ = (JSAMPLE) invalue; + } +} + + +/* + * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. + * Again a triangle filter; see comments for h2v1 case, above. + * + * It is OK for us to reference the adjacent input rows because we demanded + * context from the main buffer controller (see initialization code). + */ + +METHODDEF(void) +h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) +{ + JSAMPARRAY output_data = *output_data_ptr; + register JSAMPROW inptr0, inptr1, outptr; +#if BITS_IN_JSAMPLE == 8 + register int thiscolsum, lastcolsum, nextcolsum; +#else + register INT32 thiscolsum, lastcolsum, nextcolsum; +#endif + register JDIMENSION colctr; + int inrow, outrow, v; + + inrow = outrow = 0; + while (outrow < cinfo->max_v_samp_factor) { + for (v = 0; v < 2; v++) { + /* inptr0 points to nearest input row, inptr1 points to next nearest */ + inptr0 = input_data[inrow]; + if (v == 0) /* next nearest is row above */ + inptr1 = input_data[inrow-1]; + else /* next nearest is row below */ + inptr1 = input_data[inrow+1]; + outptr = output_data[outrow++]; + + /* Special case for first column */ + thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); + lastcolsum = thiscolsum; thiscolsum = nextcolsum; + + for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { + /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ + /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ + nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); + lastcolsum = thiscolsum; thiscolsum = nextcolsum; + } + + /* Special case for last column */ + *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); + *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); + } + inrow++; + } +} + + +/* + * Module initialization routine for upsampling. + */ + +GLOBAL(void) +jinit_upsampler (j_decompress_ptr cinfo) +{ + my_upsample_ptr upsample; + int ci; + jpeg_component_info * compptr; + boolean need_buffer, do_fancy; + int h_in_group, v_in_group, h_out_group, v_out_group; + + upsample = (my_upsample_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_upsampler)); + cinfo->upsample = (struct jpeg_upsampler *) upsample; + upsample->pub.start_pass = start_pass_upsample; + upsample->pub.upsample = sep_upsample; + upsample->pub.need_context_rows = FALSE; /* until we find out differently */ + + if (cinfo->CCIR601_sampling) /* this isn't supported */ + ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); + + /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, + * so don't ask for it. + */ + do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; + + /* Verify we can handle the sampling factors, select per-component methods, + * and create storage as needed. + */ + for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; + ci++, compptr++) { + /* Compute size of an "input group" after IDCT scaling. This many samples + * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. + */ + h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; + v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / + cinfo->min_DCT_scaled_size; + h_out_group = cinfo->max_h_samp_factor; + v_out_group = cinfo->max_v_samp_factor; + upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ + need_buffer = TRUE; + if (! compptr->component_needed) { + /* Don't bother to upsample an uninteresting component. */ + upsample->methods[ci] = noop_upsample; + need_buffer = FALSE; + } else if (h_in_group == h_out_group && v_in_group == v_out_group) { + /* Fullsize components can be processed without any work. */ + upsample->methods[ci] = fullsize_upsample; + need_buffer = FALSE; + } else if (h_in_group * 2 == h_out_group && + v_in_group == v_out_group) { + /* Special cases for 2h1v upsampling */ + if (do_fancy && compptr->downsampled_width > 2) + upsample->methods[ci] = h2v1_fancy_upsample; + else + upsample->methods[ci] = h2v1_upsample; + } else if (h_in_group * 2 == h_out_group && + v_in_group * 2 == v_out_group) { + /* Special cases for 2h2v upsampling */ + if (do_fancy && compptr->downsampled_width > 2) { + upsample->methods[ci] = h2v2_fancy_upsample; + upsample->pub.need_context_rows = TRUE; + } else + upsample->methods[ci] = h2v2_upsample; + } else if ((h_out_group % h_in_group) == 0 && + (v_out_group % v_in_group) == 0) { + /* Generic integral-factors upsampling method */ + upsample->methods[ci] = int_upsample; + upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); + upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); + } else + ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); + if (need_buffer) { + upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) jround_up((long) cinfo->output_width, + (long) cinfo->max_h_samp_factor), + (JDIMENSION) cinfo->max_v_samp_factor); + } + } +} diff --git a/libraries/external/jpeglib/jdsample.o b/libraries/external/jpeglib/jdsample.o new file mode 100644 index 0000000..8662783 Binary files /dev/null and b/libraries/external/jpeglib/jdsample.o differ diff --git a/libraries/external/jpeglib/jdtrans.c b/libraries/external/jpeglib/jdtrans.c new file mode 100755 index 0000000..12c193c --- /dev/null +++ b/libraries/external/jpeglib/jdtrans.c @@ -0,0 +1,143 @@ +/* + * jdtrans.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains library routines for transcoding decompression, + * that is, reading raw DCT coefficient arrays from an input JPEG file. + * The routines in jdapimin.c will also be needed by a transcoder. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* Forward declarations */ +LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); + + +/* + * Read the coefficient arrays from a JPEG file. + * jpeg_read_header must be completed before calling this. + * + * The entire image is read into a set of virtual coefficient-block arrays, + * one per component. The return value is a pointer to the array of + * virtual-array descriptors. These can be manipulated directly via the + * JPEG memory manager, or handed off to jpeg_write_coefficients(). + * To release the memory occupied by the virtual arrays, call + * jpeg_finish_decompress() when done with the data. + * + * An alternative usage is to simply obtain access to the coefficient arrays + * during a buffered-image-mode decompression operation. This is allowed + * after any jpeg_finish_output() call. The arrays can be accessed until + * jpeg_finish_decompress() is called. (Note that any call to the library + * may reposition the arrays, so don't rely on access_virt_barray() results + * to stay valid across library calls.) + * + * Returns NULL if suspended. This case need be checked only if + * a suspending data source is used. + */ + +GLOBAL(jvirt_barray_ptr *) +jpeg_read_coefficients (j_decompress_ptr cinfo) +{ + if (cinfo->global_state == DSTATE_READY) { + /* First call: initialize active modules */ + transdecode_master_selection(cinfo); + cinfo->global_state = DSTATE_RDCOEFS; + } + if (cinfo->global_state == DSTATE_RDCOEFS) { + /* Absorb whole file into the coef buffer */ + for (;;) { + int retcode; + /* Call progress monitor hook if present */ + if (cinfo->progress != NULL) + (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); + /* Absorb some more input */ + retcode = (*cinfo->inputctl->consume_input) (cinfo); + if (retcode == JPEG_SUSPENDED) + return NULL; + if (retcode == JPEG_REACHED_EOI) + break; + /* Advance progress counter if appropriate */ + if (cinfo->progress != NULL && + (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { + if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { + /* startup underestimated number of scans; ratchet up one scan */ + cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; + } + } + } + /* Set state so that jpeg_finish_decompress does the right thing */ + cinfo->global_state = DSTATE_STOPPING; + } + /* At this point we should be in state DSTATE_STOPPING if being used + * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access + * to the coefficients during a full buffered-image-mode decompression. + */ + if ((cinfo->global_state == DSTATE_STOPPING || + cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { + return cinfo->coef->coef_arrays; + } + /* Oops, improper usage */ + ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); + return NULL; /* keep compiler happy */ +} + + +/* + * Master selection of decompression modules for transcoding. + * This substitutes for jdmaster.c's initialization of the full decompressor. + */ + +LOCAL(void) +transdecode_master_selection (j_decompress_ptr cinfo) +{ + /* This is effectively a buffered-image operation. */ + cinfo->buffered_image = TRUE; + + /* Entropy decoding: either Huffman or arithmetic coding. */ + if (cinfo->arith_code) { + ERREXIT(cinfo, JERR_ARITH_NOTIMPL); + } else { + if (cinfo->progressive_mode) { +#ifdef D_PROGRESSIVE_SUPPORTED + jinit_phuff_decoder(cinfo); +#else + ERREXIT(cinfo, JERR_NOT_COMPILED); +#endif + } else + jinit_huff_decoder(cinfo); + } + + /* Always get a full-image coefficient buffer. */ + jinit_d_coef_controller(cinfo, TRUE); + + /* We can now tell the memory manager to allocate virtual arrays. */ + (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); + + /* Initialize input side of decompressor to consume first scan. */ + (*cinfo->inputctl->start_input_pass) (cinfo); + + /* Initialize progress monitoring. */ + if (cinfo->progress != NULL) { + int nscans; + /* Estimate number of scans to set pass_limit. */ + if (cinfo->progressive_mode) { + /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ + nscans = 2 + 3 * cinfo->num_components; + } else if (cinfo->inputctl->has_multiple_scans) { + /* For a nonprogressive multiscan file, estimate 1 scan per component. */ + nscans = cinfo->num_components; + } else { + nscans = 1; + } + cinfo->progress->pass_counter = 0L; + cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; + cinfo->progress->completed_passes = 0; + cinfo->progress->total_passes = 1; + } +} diff --git a/libraries/external/jpeglib/jdtrans.o b/libraries/external/jpeglib/jdtrans.o new file mode 100644 index 0000000..2ea4e62 Binary files /dev/null and b/libraries/external/jpeglib/jdtrans.o differ diff --git a/libraries/external/jpeglib/jerror.c b/libraries/external/jpeglib/jerror.c new file mode 100755 index 0000000..c98aed7 --- /dev/null +++ b/libraries/external/jpeglib/jerror.c @@ -0,0 +1,252 @@ +/* + * jerror.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains simple error-reporting and trace-message routines. + * These are suitable for Unix-like systems and others where writing to + * stderr is the right thing to do. Many applications will want to replace + * some or all of these routines. + * + * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, + * you get a Windows-specific hack to display error messages in a dialog box. + * It ain't much, but it beats dropping error messages into the bit bucket, + * which is what happens to output to stderr under most Windows C compilers. + * + * These routines are used by both the compression and decompression code. + */ + +/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jversion.h" +#include "jerror.h" + +#ifdef USE_WINDOWS_MESSAGEBOX +#include +#endif + +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif + + +/* + * Create the message string table. + * We do this from the master message list in jerror.h by re-reading + * jerror.h with a suitable definition for macro JMESSAGE. + * The message table is made an external symbol just in case any applications + * want to refer to it directly. + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_message_table jMsgTable +#endif + +#define JMESSAGE(code,string) string , + +const char * const jpeg_std_message_table[] = { +#include "jerror.h" + NULL +}; + + +/* + * Error exit handler: must not return to caller. + * + * Applications may override this if they want to get control back after + * an error. Typically one would longjmp somewhere instead of exiting. + * The setjmp buffer can be made a private field within an expanded error + * handler object. Note that the info needed to generate an error message + * is stored in the error object, so you can generate the message now or + * later, at your convenience. + * You should make sure that the JPEG object is cleaned up (with jpeg_abort + * or jpeg_destroy) at some point. + */ + +METHODDEF(void) +error_exit (j_common_ptr cinfo) +{ + /* Always display the message */ + (*cinfo->err->output_message) (cinfo); + + /* Let the memory manager delete any temp files before we die */ + jpeg_destroy(cinfo); + + exit(EXIT_FAILURE); +} + + +/* + * Actual output of an error or trace message. + * Applications may override this method to send JPEG messages somewhere + * other than stderr. + * + * On Windows, printing to stderr is generally completely useless, + * so we provide optional code to produce an error-dialog popup. + * Most Windows applications will still prefer to override this routine, + * but if they don't, it'll do something at least marginally useful. + * + * NOTE: to use the library in an environment that doesn't support the + * C stdio library, you may have to delete the call to fprintf() entirely, + * not just not use this routine. + */ + +METHODDEF(void) +output_message (j_common_ptr cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + + /* Create the message */ + (*cinfo->err->format_message) (cinfo, buffer); + +#ifdef USE_WINDOWS_MESSAGEBOX + /* Display it in a message dialog box */ + MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", + MB_OK | MB_ICONERROR); +#else + /* Send it to stderr, adding a newline */ + fprintf(stderr, "%s\n", buffer); +#endif +} + + +/* + * Decide whether to emit a trace or warning message. + * msg_level is one of: + * -1: recoverable corrupt-data warning, may want to abort. + * 0: important advisory messages (always display to user). + * 1: first level of tracing detail. + * 2,3,...: successively more detailed tracing messages. + * An application might override this method if it wanted to abort on warnings + * or change the policy about which messages to display. + */ + +METHODDEF(void) +emit_message (j_common_ptr cinfo, int msg_level) +{ + struct jpeg_error_mgr * err = cinfo->err; + + if (msg_level < 0) { + /* It's a warning message. Since corrupt files may generate many warnings, + * the policy implemented here is to show only the first warning, + * unless trace_level >= 3. + */ + if (err->num_warnings == 0 || err->trace_level >= 3) + (*err->output_message) (cinfo); + /* Always count warnings in num_warnings. */ + err->num_warnings++; + } else { + /* It's a trace message. Show it if trace_level >= msg_level. */ + if (err->trace_level >= msg_level) + (*err->output_message) (cinfo); + } +} + + +/* + * Format a message string for the most recent JPEG error or message. + * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX + * characters. Note that no '\n' character is added to the string. + * Few applications should need to override this method. + */ + +METHODDEF(void) +format_message (j_common_ptr cinfo, char * buffer) +{ + struct jpeg_error_mgr * err = cinfo->err; + int msg_code = err->msg_code; + const char * msgtext = NULL; + const char * msgptr; + char ch; + boolean isstring; + + /* Look up message string in proper table */ + if (msg_code > 0 && msg_code <= err->last_jpeg_message) { + msgtext = err->jpeg_message_table[msg_code]; + } else if (err->addon_message_table != NULL && + msg_code >= err->first_addon_message && + msg_code <= err->last_addon_message) { + msgtext = err->addon_message_table[msg_code - err->first_addon_message]; + } + + /* Defend against bogus message number */ + if (msgtext == NULL) { + err->msg_parm.i[0] = msg_code; + msgtext = err->jpeg_message_table[0]; + } + + /* Check for string parameter, as indicated by %s in the message text */ + isstring = FALSE; + msgptr = msgtext; + while ((ch = *msgptr++) != '\0') { + if (ch == '%') { + if (*msgptr == 's') isstring = TRUE; + break; + } + } + + /* Format the message into the passed buffer */ + if (isstring) + sprintf(buffer, msgtext, err->msg_parm.s); + else + sprintf(buffer, msgtext, + err->msg_parm.i[0], err->msg_parm.i[1], + err->msg_parm.i[2], err->msg_parm.i[3], + err->msg_parm.i[4], err->msg_parm.i[5], + err->msg_parm.i[6], err->msg_parm.i[7]); +} + + +/* + * Reset error state variables at start of a new image. + * This is called during compression startup to reset trace/error + * processing to default state, without losing any application-specific + * method pointers. An application might possibly want to override + * this method if it has additional error processing state. + */ + +METHODDEF(void) +reset_error_mgr (j_common_ptr cinfo) +{ + cinfo->err->num_warnings = 0; + /* trace_level is not reset since it is an application-supplied parameter */ + cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ +} + + +/* + * Fill in the standard error-handling methods in a jpeg_error_mgr object. + * Typical call is: + * struct jpeg_compress_struct cinfo; + * struct jpeg_error_mgr err; + * + * cinfo.err = jpeg_std_error(&err); + * after which the application may override some of the methods. + */ + +GLOBAL(struct jpeg_error_mgr *) +jpeg_std_error (struct jpeg_error_mgr * err) +{ + err->error_exit = error_exit; + err->emit_message = emit_message; + err->output_message = output_message; + err->format_message = format_message; + err->reset_error_mgr = reset_error_mgr; + + err->trace_level = 0; /* default = no tracing */ + err->num_warnings = 0; /* no warnings emitted yet */ + err->msg_code = 0; /* may be useful as a flag for "no error" */ + + /* Initialize message table pointers */ + err->jpeg_message_table = jpeg_std_message_table; + err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; + + err->addon_message_table = NULL; + err->first_addon_message = 0; /* for safety */ + err->last_addon_message = 0; + + return err; +} diff --git a/libraries/external/jpeglib/jerror.h b/libraries/external/jpeglib/jerror.h new file mode 100755 index 0000000..79084f2 --- /dev/null +++ b/libraries/external/jpeglib/jerror.h @@ -0,0 +1,291 @@ +/* + * jerror.h + * + * Copyright (C) 1994-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the error and message codes for the JPEG library. + * Edit this file to add new codes, or to translate the message strings to + * some other language. + * A set of error-reporting macros are defined too. Some applications using + * the JPEG library may wish to include this file to get the error codes + * and/or the macros. + */ + +/* + * To define the enum list of message codes, include this file without + * defining macro JMESSAGE. To create a message string table, include it + * again with a suitable JMESSAGE definition (see jerror.c for an example). + */ +#ifndef JMESSAGE +#ifndef JERROR_H +/* First time through, define the enum list */ +#define JMAKE_ENUM_LIST +#else +/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ +#define JMESSAGE(code,string) +#endif /* JERROR_H */ +#endif /* JMESSAGE */ + +#ifdef JMAKE_ENUM_LIST + +typedef enum { + +#define JMESSAGE(code,string) code , + +#endif /* JMAKE_ENUM_LIST */ + +JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ + +/* For maintenance convenience, list is alphabetical by message code name */ +JMESSAGE(JERR_ARITH_NOTIMPL, + "Sorry, there are legal restrictions on arithmetic coding") +JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") +JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") +JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") +JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") +JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") +JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") +JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") +JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") +JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") +JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") +JMESSAGE(JERR_BAD_LIB_VERSION, + "Wrong JPEG library version: library is %d, caller expects %d") +JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") +JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") +JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") +JMESSAGE(JERR_BAD_PROGRESSION, + "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") +JMESSAGE(JERR_BAD_PROG_SCRIPT, + "Invalid progressive parameters at scan script entry %d") +JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") +JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") +JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") +JMESSAGE(JERR_BAD_STRUCT_SIZE, + "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") +JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") +JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") +JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") +JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") +JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") +JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") +JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") +JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") +JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") +JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") +JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") +JMESSAGE(JERR_EMS_READ, "Read from EMS failed") +JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") +JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") +JMESSAGE(JERR_FILE_READ, "Input file read error") +JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") +JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") +JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") +JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") +JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") +JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") +JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") +JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, + "Cannot transcode due to multiple use of quantization table %d") +JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") +JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") +JMESSAGE(JERR_NOTIMPL, "Not implemented yet") +JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") +JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") +JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") +JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") +JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") +JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") +JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") +JMESSAGE(JERR_QUANT_COMPONENTS, + "Cannot quantize more than %d color components") +JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") +JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") +JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") +JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") +JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") +JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") +JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") +JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") +JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") +JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") +JMESSAGE(JERR_TFILE_WRITE, + "Write failed on temporary file --- out of disk space?") +JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") +JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") +JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") +JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") +JMESSAGE(JERR_XMS_READ, "Read from XMS failed") +JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") +JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) +JMESSAGE(JMSG_VERSION, JVERSION) +JMESSAGE(JTRC_16BIT_TABLES, + "Caution: quantization tables are too coarse for baseline JPEG") +JMESSAGE(JTRC_ADOBE, + "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") +JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") +JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") +JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") +JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") +JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") +JMESSAGE(JTRC_DRI, "Define Restart Interval %u") +JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") +JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") +JMESSAGE(JTRC_EOI, "End Of Image") +JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") +JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") +JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, + "Warning: thumbnail image size does not match data length %u") +JMESSAGE(JTRC_JFIF_EXTENSION, + "JFIF extension marker: type 0x%02x, length %u") +JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") +JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") +JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") +JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") +JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") +JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") +JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") +JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") +JMESSAGE(JTRC_RST, "RST%d") +JMESSAGE(JTRC_SMOOTH_NOTIMPL, + "Smoothing not supported with nonstandard sampling ratios") +JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") +JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") +JMESSAGE(JTRC_SOI, "Start of Image") +JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") +JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") +JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") +JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") +JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") +JMESSAGE(JTRC_THUMB_JPEG, + "JFIF extension marker: JPEG-compressed thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_PALETTE, + "JFIF extension marker: palette thumbnail image, length %u") +JMESSAGE(JTRC_THUMB_RGB, + "JFIF extension marker: RGB thumbnail image, length %u") +JMESSAGE(JTRC_UNKNOWN_IDS, + "Unrecognized component IDs %d %d %d, assuming YCbCr") +JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") +JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") +JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") +JMESSAGE(JWRN_BOGUS_PROGRESSION, + "Inconsistent progression sequence for component %d coefficient %d") +JMESSAGE(JWRN_EXTRANEOUS_DATA, + "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") +JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") +JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") +JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") +JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") +JMESSAGE(JWRN_MUST_RESYNC, + "Corrupt JPEG data: found marker 0x%02x instead of RST%d") +JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") +JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") + +#ifdef JMAKE_ENUM_LIST + + JMSG_LASTMSGCODE +} J_MESSAGE_CODE; + +#undef JMAKE_ENUM_LIST +#endif /* JMAKE_ENUM_LIST */ + +/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ +#undef JMESSAGE + + +#ifndef JERROR_H +#define JERROR_H + +/* Macros to simplify using the error and trace message stuff */ +/* The first parameter is either type of cinfo pointer */ + +/* Fatal errors (print message and exit) */ +#define ERREXIT(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT3(cinfo,code,p1,p2,p3) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (cinfo)->err->msg_parm.i[2] = (p3), \ + (cinfo)->err->msg_parm.i[3] = (p4), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) +#define ERREXITS(cinfo,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) + +#define MAKESTMT(stuff) do { stuff } while (0) + +/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ +#define WARNMS(cinfo,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS1(cinfo,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) +#define WARNMS2(cinfo,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) + +/* Informational/debugging messages */ +#define TRACEMS(cinfo,lvl,code) \ + ((cinfo)->err->msg_code = (code), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS1(cinfo,lvl,code,p1) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS2(cinfo,lvl,code,p1,p2) \ + ((cinfo)->err->msg_code = (code), \ + (cinfo)->err->msg_parm.i[0] = (p1), \ + (cinfo)->err->msg_parm.i[1] = (p2), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) +#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ + MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ + _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ + _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ + (cinfo)->err->msg_code = (code); \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) +#define TRACEMSS(cinfo,lvl,code,str) \ + ((cinfo)->err->msg_code = (code), \ + strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ + (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) + +#endif /* JERROR_H */ diff --git a/libraries/external/jpeglib/jerror.o b/libraries/external/jpeglib/jerror.o new file mode 100644 index 0000000..fb489a6 Binary files /dev/null and b/libraries/external/jpeglib/jerror.o differ diff --git a/libraries/external/jpeglib/jfdctflt.c b/libraries/external/jpeglib/jfdctflt.c new file mode 100755 index 0000000..7ccfb38 --- /dev/null +++ b/libraries/external/jpeglib/jfdctflt.c @@ -0,0 +1,168 @@ +/* + * jfdctflt.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * forward DCT (Discrete Cosine Transform). + * + * This implementation should be more accurate than either of the integer + * DCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_float (FAST_FLOAT * data) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; + FAST_FLOAT *dataptr; + int ctr; + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = tmp10 + tmp11; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ + z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ + z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/libraries/external/jpeglib/jfdctflt.o b/libraries/external/jpeglib/jfdctflt.o new file mode 100644 index 0000000..bcd155c Binary files /dev/null and b/libraries/external/jpeglib/jfdctflt.o differ diff --git a/libraries/external/jpeglib/jfdctfst.c b/libraries/external/jpeglib/jfdctfst.c new file mode 100755 index 0000000..005a74f --- /dev/null +++ b/libraries/external/jpeglib/jfdctfst.c @@ -0,0 +1,224 @@ +/* + * jfdctfst.c + * + * Copyright (C) 1994-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jfdctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * Again to save a few shifts, the intermediate results between pass 1 and + * pass 2 are not upscaled, but are represented only to integral precision. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#define CONST_BITS 8 + + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ +#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ +#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ +#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ +#else +#define FIX_0_382683433 FIX(0.382683433) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_707106781 FIX(0.707106781) +#define FIX_1_306562965 FIX(1.306562965) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_ifast (DCTELEM * data) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z1, z2, z3, z4, z5, z11, z13; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = tmp10 + tmp11; /* phase 3 */ + dataptr[4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[2] = tmp13 + z1; /* phase 5 */ + dataptr[6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[5] = z13 + z2; /* phase 6 */ + dataptr[3] = z13 - z2; + dataptr[1] = z11 + z4; + dataptr[7] = z11 - z4; + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part */ + + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ + dataptr[DCTSIZE*4] = tmp10 - tmp11; + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ + dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ + dataptr[DCTSIZE*6] = tmp13 - z1; + + /* Odd part */ + + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ + z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ + z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ + z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ + dataptr[DCTSIZE*3] = z13 - z2; + dataptr[DCTSIZE*1] = z11 + z4; + dataptr[DCTSIZE*7] = z11 - z4; + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/libraries/external/jpeglib/jfdctfst.o b/libraries/external/jpeglib/jfdctfst.o new file mode 100644 index 0000000..f0ed95c Binary files /dev/null and b/libraries/external/jpeglib/jfdctfst.o differ diff --git a/libraries/external/jpeglib/jfdctint.c b/libraries/external/jpeglib/jfdctint.c new file mode 100755 index 0000000..d626927 --- /dev/null +++ b/libraries/external/jpeglib/jfdctint.c @@ -0,0 +1,283 @@ +/* + * jfdctint.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * forward DCT (Discrete Cosine Transform). + * + * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT + * on each column. Direct algorithms are also available, but they are + * much more complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D DCT step produces outputs which are a factor of sqrt(N) + * larger than the true DCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D DCT, + * because the y0 and y4 outputs need not be divided by sqrt(N). + * In the IJG code, this factor of 8 is removed by the quantization step + * (in jcdctmgr.c), NOT in this module. + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (For 12-bit sample data, the intermediate + * array is INT32 anyway.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +jpeg_fdct_islow (DCTELEM * data) +{ + INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3, z4, z5; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + /* Pass 1: process rows. */ + /* Note results are scaled up by sqrt(8) compared to a true DCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[0] + dataptr[7]; + tmp7 = dataptr[0] - dataptr[7]; + tmp1 = dataptr[1] + dataptr[6]; + tmp6 = dataptr[1] - dataptr[6]; + tmp2 = dataptr[2] + dataptr[5]; + tmp5 = dataptr[2] - dataptr[5]; + tmp3 = dataptr[3] + dataptr[4]; + tmp4 = dataptr[3] - dataptr[4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); + dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS-PASS1_BITS); + dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS-PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); + dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); + dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); + dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); + + dataptr += DCTSIZE; /* advance pointer to next row */ + } + + /* Pass 2: process columns. + * We remove the PASS1_BITS scaling, but leave the results scaled up + * by an overall factor of 8. + */ + + dataptr = data; + for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { + tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; + tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; + tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; + tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; + tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; + tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; + tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; + tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; + + /* Even part per LL&M figure 1 --- note that published figure is faulty; + * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". + */ + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); + dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); + + z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); + dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), + CONST_BITS+PASS1_BITS); + + /* Odd part per figure 8 --- note paper omits factor of sqrt(2). + * cK represents cos(K*pi/16). + * i0..i3 in the paper are tmp4..tmp7 here. + */ + + z1 = tmp4 + tmp7; + z2 = tmp5 + tmp6; + z3 = tmp4 + tmp6; + z4 = tmp5 + tmp7; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, + CONST_BITS+PASS1_BITS); + dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, + CONST_BITS+PASS1_BITS); + + dataptr++; /* advance pointer to next column */ + } +} + +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/libraries/external/jpeglib/jfdctint.o b/libraries/external/jpeglib/jfdctint.o new file mode 100644 index 0000000..a096a41 Binary files /dev/null and b/libraries/external/jpeglib/jfdctint.o differ diff --git a/libraries/external/jpeglib/jidctflt.c b/libraries/external/jpeglib/jidctflt.c new file mode 100755 index 0000000..5fea54c --- /dev/null +++ b/libraries/external/jpeglib/jidctflt.c @@ -0,0 +1,242 @@ +/* + * jidctflt.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a floating-point implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * This implementation should be more accurate than either of the integer + * IDCT implementations. However, it may not give the same results on all + * machines because of differences in roundoff behavior. Speed will depend + * on the hardware's floating point capacity. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with a fixed-point + * implementation, accuracy is lost due to imprecise representation of the + * scaled quantization values. However, that problem does not arise if + * we use floating point arithmetic. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_FLOAT_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a float result. + */ + +#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FAST_FLOAT tmp10, tmp11, tmp12, tmp13; + FAST_FLOAT z5, z10, z11, z12, z13; + JCOEFPTR inptr; + FLOAT_MULT_TYPE * quantptr; + FAST_FLOAT * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ + tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + wsptr[DCTSIZE*0] = tmp0 + tmp7; + wsptr[DCTSIZE*7] = tmp0 - tmp7; + wsptr[DCTSIZE*1] = tmp1 + tmp6; + wsptr[DCTSIZE*6] = tmp1 - tmp6; + wsptr[DCTSIZE*2] = tmp2 + tmp5; + wsptr[DCTSIZE*5] = tmp2 - tmp5; + wsptr[DCTSIZE*4] = tmp3 + tmp4; + wsptr[DCTSIZE*3] = tmp3 - tmp4; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * And testing floats for zero is relatively expensive, so we don't bother. + */ + + /* Even part */ + + tmp10 = wsptr[0] + wsptr[4]; + tmp11 = wsptr[0] - wsptr[4]; + + tmp13 = wsptr[2] + wsptr[6]; + tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = wsptr[5] + wsptr[3]; + z10 = wsptr[5] - wsptr[3]; + z11 = wsptr[1] + wsptr[7]; + z12 = wsptr[1] - wsptr[7]; + + tmp7 = z11 + z13; + tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); + + z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ + tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ + tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/libraries/external/jpeglib/jidctflt.o b/libraries/external/jpeglib/jidctflt.o new file mode 100644 index 0000000..f61c94b Binary files /dev/null and b/libraries/external/jpeglib/jidctflt.o differ diff --git a/libraries/external/jpeglib/jidctfst.c b/libraries/external/jpeglib/jidctfst.c new file mode 100755 index 0000000..078b8c4 --- /dev/null +++ b/libraries/external/jpeglib/jidctfst.c @@ -0,0 +1,368 @@ +/* + * jidctfst.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a fast, not so accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on Arai, Agui, and Nakajima's algorithm for + * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in + * Japanese, but the algorithm is described in the Pennebaker & Mitchell + * JPEG textbook (see REFERENCES section in file README). The following code + * is based directly on figure 4-8 in P&M. + * While an 8-point DCT cannot be done in less than 11 multiplies, it is + * possible to arrange the computation so that many of the multiplies are + * simple scalings of the final outputs. These multiplies can then be + * folded into the multiplications or divisions by the JPEG quantization + * table entries. The AA&N method leaves only 5 multiplies and 29 adds + * to be done in the DCT itself. + * The primary disadvantage of this method is that with fixed-point math, + * accuracy is lost due to imprecise representation of the scaled + * quantization values. The smaller the quantization table entry, the less + * precise the scaled value, so this implementation does worse with high- + * quality-setting files than with low-quality ones. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_IFAST_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling decisions are generally the same as in the LL&M algorithm; + * see jidctint.c for more details. However, we choose to descale + * (right shift) multiplication products as soon as they are formed, + * rather than carrying additional fractional bits into subsequent additions. + * This compromises accuracy slightly, but it lets us save a few shifts. + * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) + * everywhere except in the multiplications proper; this saves a good deal + * of work on 16-bit-int machines. + * + * The dequantized coefficients are not integers because the AA&N scaling + * factors have been incorporated. We represent them scaled up by PASS1_BITS, + * so that the first and second IDCT rounds have the same input scaling. + * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to + * avoid a descaling shift; this compromises accuracy rather drastically + * for small quantization table entries, but it saves a lot of shifts. + * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, + * so we use a much larger scaling factor to preserve accuracy. + * + * A final compromise is to represent the multiplicative constants to only + * 8 fractional bits, rather than 13. This saves some shifting work on some + * machines, and may also reduce the cost of multiplication (since there + * are fewer one-bits in the constants). + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 8 +#define PASS1_BITS 2 +#else +#define CONST_BITS 8 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 8 +#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ +#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ +#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ +#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ +#else +#define FIX_1_082392200 FIX(1.082392200) +#define FIX_1_414213562 FIX(1.414213562) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_613125930 FIX(2.613125930) +#endif + + +/* We can gain a little more speed, with a further compromise in accuracy, + * by omitting the addition in a descaling shift. This yields an incorrectly + * rounded result half the time... + */ + +#ifndef USE_ACCURATE_ROUNDING +#undef DESCALE +#define DESCALE(x,n) RIGHT_SHIFT(x, n) +#endif + + +/* Multiply a DCTELEM variable by an INT32 constant, and immediately + * descale to yield a DCTELEM result. + */ + +#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 + * multiplication will do. For 12-bit data, the multiplier table is + * declared INT32, so a 32-bit multiply will be used. + */ + +#if BITS_IN_JSAMPLE == 8 +#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) +#else +#define DEQUANTIZE(coef,quantval) \ + DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) +#endif + + +/* Like DESCALE, but applies to a DCTELEM and produces an int. + * We assume that int right shift is unsigned if INT32 right shift is. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define ISHIFT_TEMPS DCTELEM ishift_temp; +#if BITS_IN_JSAMPLE == 8 +#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ +#else +#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ +#endif +#define IRIGHT_SHIFT(x,shft) \ + ((ishift_temp = (x)) < 0 ? \ + (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ + (ishift_temp >> (shft))) +#else +#define ISHIFT_TEMPS +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + +#ifdef USE_ACCURATE_ROUNDING +#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) +#else +#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) +#endif + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + DCTELEM tmp10, tmp11, tmp12, tmp13; + DCTELEM z5, z10, z11, z12, z13; + JCOEFPTR inptr; + IFAST_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS /* for DESCALE */ + ISHIFT_TEMPS /* for IDESCALE */ + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp10 = tmp0 + tmp2; /* phase 3 */ + tmp11 = tmp0 - tmp2; + + tmp13 = tmp1 + tmp3; /* phases 5-3 */ + tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ + + tmp0 = tmp10 + tmp13; /* phase 2 */ + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + + z13 = tmp6 + tmp5; /* phase 6 */ + z10 = tmp6 - tmp5; + z11 = tmp4 + tmp7; + z12 = tmp4 - tmp7; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ + tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); + wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); + wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); + wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); + wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); + wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); + wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); + wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3, */ + /* and also undo the PASS1_BITS scaling. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); + tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); + + tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); + tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) + - tmp13; + + tmp0 = tmp10 + tmp13; + tmp3 = tmp10 - tmp13; + tmp1 = tmp11 + tmp12; + tmp2 = tmp11 - tmp12; + + /* Odd part */ + + z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; + z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; + z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; + z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; + + tmp7 = z11 + z13; /* phase 5 */ + tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ + + z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ + tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ + tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ + + tmp6 = tmp12 - tmp7; /* phase 2 */ + tmp5 = tmp11 - tmp6; + tmp4 = tmp10 + tmp5; + + /* Final output stage: scale down by a factor of 8 and range-limit */ + + outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_IFAST_SUPPORTED */ diff --git a/libraries/external/jpeglib/jidctfst.o b/libraries/external/jpeglib/jidctfst.o new file mode 100644 index 0000000..ab423bb Binary files /dev/null and b/libraries/external/jpeglib/jidctfst.o differ diff --git a/libraries/external/jpeglib/jidctint.c b/libraries/external/jpeglib/jidctint.c new file mode 100755 index 0000000..4f47fe8 --- /dev/null +++ b/libraries/external/jpeglib/jidctint.c @@ -0,0 +1,389 @@ +/* + * jidctint.c + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a slow-but-accurate integer implementation of the + * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine + * must also perform dequantization of the input coefficients. + * + * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT + * on each row (or vice versa, but it's more convenient to emit a row at + * a time). Direct algorithms are also available, but they are much more + * complex and seem not to be any faster when reduced to code. + * + * This implementation is based on an algorithm described in + * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT + * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, + * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. + * The primary algorithm described there uses 11 multiplies and 29 adds. + * We use their alternate method with 12 multiplies and 32 adds. + * The advantage of this method is that no data path contains more than one + * multiplication; this allows a very simple and accurate implementation in + * scaled fixed-point arithmetic, with a minimal number of shifts. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef DCT_ISLOW_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* + * The poop on this scaling stuff is as follows: + * + * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) + * larger than the true IDCT outputs. The final outputs are therefore + * a factor of N larger than desired; since N=8 this can be cured by + * a simple right shift at the end of the algorithm. The advantage of + * this arrangement is that we save two multiplications per 1-D IDCT, + * because the y0 and y4 inputs need not be divided by sqrt(N). + * + * We have to do addition and subtraction of the integer inputs, which + * is no problem, and multiplication by fractional constants, which is + * a problem to do in integer arithmetic. We multiply all the constants + * by CONST_SCALE and convert them to integer constants (thus retaining + * CONST_BITS bits of precision in the constants). After doing a + * multiplication we have to divide the product by CONST_SCALE, with proper + * rounding, to produce the correct output. This division can be done + * cheaply as a right shift of CONST_BITS bits. We postpone shifting + * as long as possible so that partial sums can be added together with + * full fractional precision. + * + * The outputs of the first pass are scaled up by PASS1_BITS bits so that + * they are represented to better-than-integral precision. These outputs + * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word + * with the recommended scaling. (To scale up 12-bit sample data further, an + * intermediate INT32 array would be needed.) + * + * To avoid overflow of the 32-bit intermediate results in pass 2, we must + * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis + * shows that the values given below are the most effective. + */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ +#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ +#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ +#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ +#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ +#else +#define FIX_0_298631336 FIX(0.298631336) +#define FIX_0_390180644 FIX(0.390180644) +#define FIX_0_541196100 FIX(0.541196100) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_175875602 FIX(1.175875602) +#define FIX_1_501321110 FIX(1.501321110) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_1_961570560 FIX(1.961570560) +#define FIX_2_053119869 FIX(2.053119869) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_072711026 FIX(3.072711026) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients. + */ + +GLOBAL(void) +jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp1, tmp2, tmp3; + INT32 tmp10, tmp11, tmp12, tmp13; + INT32 z1, z2, z3, z4, z5; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ + /* furthermore, we scale the results by 2**PASS1_BITS. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; ctr--) { + /* Due to quantization, we will usually find that many of the input + * coefficients are zero, especially the AC terms. We can exploit this + * by short-circuiting the IDCT calculation for any column in which all + * the AC terms are zero. In that case each output is equal to the + * DC coefficient (with scale factor as needed). + * With typical images and quantization tables, half or more of the + * column DCT calculations can be simplified this way. + */ + + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && + inptr[DCTSIZE*7] == 0) { + /* AC terms all zero */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + wsptr[DCTSIZE*4] = dcval; + wsptr[DCTSIZE*5] = dcval; + wsptr[DCTSIZE*6] = dcval; + wsptr[DCTSIZE*7] = dcval; + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + continue; + } + + /* Even part: reverse the even part of the forward DCT. */ + /* The rotator is sqrt(2)*c(-6). */ + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); + tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); + tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); + + z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); + + tmp0 = (z2 + z3) << CONST_BITS; + tmp1 = (z2 - z3) << CONST_BITS; + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + z1 = tmp0 + tmp3; + z2 = tmp1 + tmp2; + z3 = tmp0 + tmp2; + z4 = tmp1 + tmp3; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + tmp0 += z1 + z3; + tmp1 += z2 + z4; + tmp2 += z2 + z3; + tmp3 += z1 + z4; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); + wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); + + inptr++; /* advance pointers to next column */ + quantptr++; + wsptr++; + } + + /* Pass 2: process rows from work array, store into output array. */ + /* Note that we must descale the results by a factor of 8 == 2**3, */ + /* and also undo the PASS1_BITS scaling. */ + + wsptr = workspace; + for (ctr = 0; ctr < DCTSIZE; ctr++) { + outptr = output_buf[ctr] + output_col; + /* Rows of zeroes can be exploited in the same way as we did with columns. + * However, the column calculation has created many nonzero AC terms, so + * the simplification applies less often (typically 5% to 10% of the time). + * On machines with very fast multiplication, it's possible that the + * test takes more time than it's worth. In that case this section + * may be commented out. + */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + outptr[4] = dcval; + outptr[5] = dcval; + outptr[6] = dcval; + outptr[7] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part: reverse the even part of the forward DCT. */ + /* The rotator is sqrt(2)*c(-6). */ + + z2 = (INT32) wsptr[2]; + z3 = (INT32) wsptr[6]; + + z1 = MULTIPLY(z2 + z3, FIX_0_541196100); + tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); + tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); + + tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; + tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; + + tmp10 = tmp0 + tmp3; + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + /* Odd part per figure 8; the matrix is unitary and hence its + * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. + */ + + tmp0 = (INT32) wsptr[7]; + tmp1 = (INT32) wsptr[5]; + tmp2 = (INT32) wsptr[3]; + tmp3 = (INT32) wsptr[1]; + + z1 = tmp0 + tmp3; + z2 = tmp1 + tmp2; + z3 = tmp0 + tmp2; + z4 = tmp1 + tmp3; + z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ + + tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ + tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ + tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ + tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ + z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ + z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ + z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ + z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ + + z3 += z5; + z4 += z5; + + tmp0 += z1 + z3; + tmp1 += z2 + z4; + tmp2 += z2 + z3; + tmp3 += z1 + z4; + + /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, + CONST_BITS+PASS1_BITS+3) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + +#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/libraries/external/jpeglib/jidctint.o b/libraries/external/jpeglib/jidctint.o new file mode 100644 index 0000000..4a05bd5 Binary files /dev/null and b/libraries/external/jpeglib/jidctint.o differ diff --git a/libraries/external/jpeglib/jidctred.c b/libraries/external/jpeglib/jidctred.c new file mode 100755 index 0000000..911899b --- /dev/null +++ b/libraries/external/jpeglib/jidctred.c @@ -0,0 +1,398 @@ +/* + * jidctred.c + * + * Copyright (C) 1994-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains inverse-DCT routines that produce reduced-size output: + * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. + * + * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) + * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step + * with an 8-to-4 step that produces the four averages of two adjacent outputs + * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). + * These steps were derived by computing the corresponding values at the end + * of the normal LL&M code, then simplifying as much as possible. + * + * 1x1 is trivial: just take the DC coefficient divided by 8. + * + * See jidctint.c for additional comments. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jdct.h" /* Private declarations for DCT subsystem */ + +#ifdef IDCT_SCALING_SUPPORTED + + +/* + * This module is specialized to the case DCTSIZE = 8. + */ + +#if DCTSIZE != 8 + Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ +#endif + + +/* Scaling is the same as in jidctint.c. */ + +#if BITS_IN_JSAMPLE == 8 +#define CONST_BITS 13 +#define PASS1_BITS 2 +#else +#define CONST_BITS 13 +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ +#endif + +/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus + * causing a lot of useless floating-point operations at run time. + * To get around this we use the following pre-calculated constants. + * If you change CONST_BITS you may want to add appropriate values. + * (With a reasonable C compiler, you can just rely on the FIX() macro...) + */ + +#if CONST_BITS == 13 +#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ +#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ +#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ +#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ +#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ +#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ +#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ +#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ +#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ +#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ +#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ +#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ +#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ +#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ +#else +#define FIX_0_211164243 FIX(0.211164243) +#define FIX_0_509795579 FIX(0.509795579) +#define FIX_0_601344887 FIX(0.601344887) +#define FIX_0_720959822 FIX(0.720959822) +#define FIX_0_765366865 FIX(0.765366865) +#define FIX_0_850430095 FIX(0.850430095) +#define FIX_0_899976223 FIX(0.899976223) +#define FIX_1_061594337 FIX(1.061594337) +#define FIX_1_272758580 FIX(1.272758580) +#define FIX_1_451774981 FIX(1.451774981) +#define FIX_1_847759065 FIX(1.847759065) +#define FIX_2_172734803 FIX(2.172734803) +#define FIX_2_562915447 FIX(2.562915447) +#define FIX_3_624509785 FIX(3.624509785) +#endif + + +/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. + * For 8-bit samples with the recommended scaling, all the variable + * and constant values involved are no more than 16 bits wide, so a + * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. + * For 12-bit samples, a full 32-bit multiplication will be needed. + */ + +#if BITS_IN_JSAMPLE == 8 +#define MULTIPLY(var,const) MULTIPLY16C16(var,const) +#else +#define MULTIPLY(var,const) ((var) * (const)) +#endif + + +/* Dequantize a coefficient by multiplying it by the multiplier-table + * entry; produce an int result. In this module, both inputs and result + * are 16 bits or less, so either int or short multiply will work. + */ + +#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 4x4 output block. + */ + +GLOBAL(void) +jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp2, tmp10, tmp12; + INT32 z1, z2, z3, z4; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE*4]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { + /* Don't bother to process column 4, because second pass won't use it */ + if (ctr == DCTSIZE-4) + continue; + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && + inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { + /* AC terms all zero; we need not examine term 4 for 4x4 output */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + wsptr[DCTSIZE*2] = dcval; + wsptr[DCTSIZE*3] = dcval; + + continue; + } + + /* Even part */ + + tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp0 <<= (CONST_BITS+1); + + z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); + z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); + + tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + + tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ + + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ + + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ + + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ + + tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ + + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ + + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ + + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ + + /* Final output stage */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); + wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); + } + + /* Pass 2: process 4 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 4; ctr++) { + outptr = output_buf[ctr] + output_col; + /* It's not clear whether a zero row test is worthwhile here ... */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + outptr[2] = dcval; + outptr[3] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); + + tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) + + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); + + tmp10 = tmp0 + tmp2; + tmp12 = tmp0 - tmp2; + + /* Odd part */ + + z1 = (INT32) wsptr[7]; + z2 = (INT32) wsptr[5]; + z3 = (INT32) wsptr[3]; + z4 = (INT32) wsptr[1]; + + tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ + + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ + + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ + + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ + + tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ + + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ + + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ + + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, + CONST_BITS+PASS1_BITS+3+1) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 2x2 output block. + */ + +GLOBAL(void) +jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + INT32 tmp0, tmp10, z1; + JCOEFPTR inptr; + ISLOW_MULT_TYPE * quantptr; + int * wsptr; + JSAMPROW outptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + int ctr; + int workspace[DCTSIZE*2]; /* buffers data between passes */ + SHIFT_TEMPS + + /* Pass 1: process columns from input, store into work array. */ + + inptr = coef_block; + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + wsptr = workspace; + for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { + /* Don't bother to process columns 2,4,6 */ + if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) + continue; + if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { + /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ + int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; + + wsptr[DCTSIZE*0] = dcval; + wsptr[DCTSIZE*1] = dcval; + + continue; + } + + /* Even part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); + tmp10 = z1 << (CONST_BITS+2); + + /* Odd part */ + + z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); + tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); + tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); + tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ + z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); + tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ + + /* Final output stage */ + + wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); + wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); + } + + /* Pass 2: process 2 rows from work array, store into output array. */ + + wsptr = workspace; + for (ctr = 0; ctr < 2; ctr++) { + outptr = output_buf[ctr] + output_col; + /* It's not clear whether a zero row test is worthwhile here ... */ + +#ifndef NO_ZERO_ROW_TEST + if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { + /* AC terms all zero */ + JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) + & RANGE_MASK]; + + outptr[0] = dcval; + outptr[1] = dcval; + + wsptr += DCTSIZE; /* advance pointer to next row */ + continue; + } +#endif + + /* Even part */ + + tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); + + /* Odd part */ + + tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ + + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ + + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ + + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ + + /* Final output stage */ + + outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, + CONST_BITS+PASS1_BITS+3+2) + & RANGE_MASK]; + outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, + CONST_BITS+PASS1_BITS+3+2) + & RANGE_MASK]; + + wsptr += DCTSIZE; /* advance pointer to next row */ + } +} + + +/* + * Perform dequantization and inverse DCT on one block of coefficients, + * producing a reduced-size 1x1 output block. + */ + +GLOBAL(void) +jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col) +{ + int dcval; + ISLOW_MULT_TYPE * quantptr; + JSAMPLE *range_limit = IDCT_range_limit(cinfo); + SHIFT_TEMPS + + /* We hardly need an inverse DCT routine for this: just take the + * average pixel value, which is one-eighth of the DC coefficient. + */ + quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; + dcval = DEQUANTIZE(coef_block[0], quantptr[0]); + dcval = (int) DESCALE((INT32) dcval, 3); + + output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; +} + +#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/libraries/external/jpeglib/jidctred.o b/libraries/external/jpeglib/jidctred.o new file mode 100644 index 0000000..95f76d2 Binary files /dev/null and b/libraries/external/jpeglib/jidctred.o differ diff --git a/libraries/external/jpeglib/jinclude.h b/libraries/external/jpeglib/jinclude.h new file mode 100755 index 0000000..5ff60fe --- /dev/null +++ b/libraries/external/jpeglib/jinclude.h @@ -0,0 +1,91 @@ +/* + * jinclude.h + * + * Copyright (C) 1991-1994, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file exists to provide a single place to fix any problems with + * including the wrong system include files. (Common problems are taken + * care of by the standard jconfig symbols, but on really weird systems + * you may have to edit this file.) + * + * NOTE: this file is NOT intended to be included by applications using the + * JPEG library. Most applications need only include jpeglib.h. + */ + + +/* Include auto-config file to find out which system include files we need. */ + +#include "jconfig.h" /* auto configuration options */ +#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ + +/* + * We need the NULL macro and size_t typedef. + * On an ANSI-conforming system it is sufficient to include . + * Otherwise, we get them from or ; we may have to + * pull in as well. + * Note that the core JPEG library does not require ; + * only the default error handler and data source/destination modules do. + * But we must pull it in because of the references to FILE in jpeglib.h. + * You can remove those references if you want to compile without . + */ + +#ifdef HAVE_STDDEF_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef NEED_SYS_TYPES_H +#include +#endif + +#include + +/* + * We need memory copying and zeroing functions, plus strncpy(). + * ANSI and System V implementations declare these in . + * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). + * Some systems may declare memset and memcpy in . + * + * NOTE: we assume the size parameters to these functions are of type size_t. + * Change the casts in these macros if not! + */ + +#ifdef NEED_BSD_STRINGS + +#include +#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) +#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) + +#else /* not BSD, assume ANSI/SysV string lib */ + +#include +#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) +#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) + +#endif + +/* + * In ANSI C, and indeed any rational implementation, size_t is also the + * type returned by sizeof(). However, it seems there are some irrational + * implementations out there, in which sizeof() returns an int even though + * size_t is defined as long or unsigned long. To ensure consistent results + * we always use this SIZEOF() macro in place of using sizeof() directly. + */ + +#define SIZEOF(object) ((size_t) sizeof(object)) + +/* + * The modules that use fread() and fwrite() always invoke them through + * these macros. On some systems you may need to twiddle the argument casts. + * CAUTION: argument order is different from underlying functions! + */ + +#define JFREAD(file,buf,sizeofbuf) \ + ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) +#define JFWRITE(file,buf,sizeofbuf) \ + ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/libraries/external/jpeglib/jmemansi.c b/libraries/external/jpeglib/jmemansi.c new file mode 100755 index 0000000..b5da474 --- /dev/null +++ b/libraries/external/jpeglib/jmemansi.c @@ -0,0 +1,167 @@ +/* + * jmemansi.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a simple generic implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that you have the ANSI-standard library routine tmpfile(). + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); + /* Since this implementation uses tmpfile() to create the file, + * no explicit file deletion is needed. + */ +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses tmpfile(), which constructs a suitable file name + * behind the scenes. We don't have to use info->temp_name[] at all; + * indeed, we can't even find out the actual name of the temp file. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + if ((info->temp_file = tmpfile()) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/libraries/external/jpeglib/jmemdos.c b/libraries/external/jpeglib/jmemdos.c new file mode 100755 index 0000000..0955047 --- /dev/null +++ b/libraries/external/jpeglib/jmemdos.c @@ -0,0 +1,638 @@ +/* + * jmemdos.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides an MS-DOS-compatible implementation of the system- + * dependent portion of the JPEG memory manager. Temporary data can be + * stored in extended or expanded memory as well as in regular DOS files. + * + * If you use this file, you must be sure that NEED_FAR_POINTERS is defined + * if you compile in a small-data memory model; it should NOT be defined if + * you use a large-data memory model. This file is not recommended if you + * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. + * Also, this code will NOT work if struct fields are aligned on greater than + * 2-byte boundaries. + * + * Based on code contributed by Ge' Weijers. + */ + +/* + * If you have both extended and expanded memory, you may want to change the + * order in which they are tried in jopen_backing_store. On a 286 machine + * expanded memory is usually faster, since extended memory access involves + * an expensive protected-mode-and-back switch. On 386 and better, extended + * memory is usually faster. As distributed, the code tries extended memory + * first (what? not everyone has a 386? :-). + * + * You can disable use of extended/expanded memory entirely by altering these + * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). + */ + +#ifndef XMS_SUPPORTED +#define XMS_SUPPORTED 1 +#endif +#ifndef EMS_SUPPORTED +#define EMS_SUPPORTED 1 +#endif + + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare these */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +extern char * getenv JPP((const char * name)); +#endif + +#ifdef NEED_FAR_POINTERS + +#ifdef __TURBOC__ +/* These definitions work for Borland C (Turbo C) */ +#include /* need farmalloc(), farfree() */ +#define far_malloc(x) farmalloc(x) +#define far_free(x) farfree(x) +#else +/* These definitions work for Microsoft C and compatible compilers */ +#include /* need _fmalloc(), _ffree() */ +#define far_malloc(x) _fmalloc(x) +#define far_free(x) _ffree(x) +#endif + +#else /* not NEED_FAR_POINTERS */ + +#define far_malloc(x) malloc(x) +#define far_free(x) free(x) + +#endif /* NEED_FAR_POINTERS */ + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#else +#define READ_BINARY "rb" +#endif + +#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ + You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ +#endif + +#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ + MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ +#endif + + +/* + * Declarations for assembly-language support routines (see jmemdosa.asm). + * + * The functions are declared "far" as are all their pointer arguments; + * this ensures the assembly source code will work regardless of the + * compiler memory model. We assume "short" is 16 bits, "long" is 32. + */ + +typedef void far * XMSDRIVER; /* actually a pointer to code */ +typedef struct { /* registers for calling XMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } XMScontext; +typedef struct { /* registers for calling EMS driver */ + unsigned short ax, dx, bx; + void far * ds_si; + } EMScontext; + +extern short far jdos_open JPP((short far * handle, char far * filename)); +extern short far jdos_close JPP((short handle)); +extern short far jdos_seek JPP((short handle, long offset)); +extern short far jdos_read JPP((short handle, void far * buffer, + unsigned short count)); +extern short far jdos_write JPP((short handle, void far * buffer, + unsigned short count)); +extern void far jxms_getdriver JPP((XMSDRIVER far *)); +extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); +extern short far jems_available JPP((void)); +extern void far jems_calldriver JPP((EMScontext far *)); + + +/* + * Selection of a file name for a temporary file. + * This is highly system-dependent, and you may want to customize it. + */ + +static int next_file_num; /* to distinguish among several temp files */ + +LOCAL(void) +select_file_name (char * fname) +{ + const char * env; + char * ptr; + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + /* Get temp directory name from environment TMP or TEMP variable; + * if none, use "." + */ + if ((env = (const char *) getenv("TMP")) == NULL) + if ((env = (const char *) getenv("TEMP")) == NULL) + env = "."; + if (*env == '\0') /* null string means "." */ + env = "."; + ptr = fname; /* copy name to fname */ + while (*env != '\0') + *ptr++ = *env++; + if (ptr[-1] != '\\' && ptr[-1] != '/') + *ptr++ = '\\'; /* append backslash if not in env variable */ + /* Append a suitable file name */ + next_file_num++; /* advance counter */ + sprintf(ptr, "JPG%03d.TMP", next_file_num); + /* Probe to see if file name is already in use */ + if ((tfile = fopen(fname, READ_BINARY)) == NULL) + break; + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + + +/* + * Near-memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are allocated in far memory, if possible + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) far_malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + far_free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + +/* + * For MS-DOS we support three types of backing storage: + * 1. Conventional DOS files. We access these by direct DOS calls rather + * than via the stdio package. This provides a bit better performance, + * but the real reason is that the buffers to be read or written are FAR. + * The stdio library for small-data memory models can't cope with that. + * 2. Extended memory, accessed per the XMS V2.0 specification. + * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. + * You'll need copies of those specs to make sense of the related code. + * The specs are available by Internet FTP from the SIMTEL archives + * (oak.oakland.edu and its various mirror sites). See files + * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. + */ + + +/* + * Access methods for a DOS file. + */ + + +METHODDEF(void) +read_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_read(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_file_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (jdos_seek(info->handle.file_handle, file_offset)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ + if (byte_count > 65535L) /* safety check */ + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + if (jdos_write(info->handle.file_handle, buffer_address, + (unsigned short) byte_count)) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_file_store (j_common_ptr cinfo, backing_store_ptr info) +{ + jdos_close(info->handle.file_handle); /* close the file */ + remove(info->temp_name); /* delete the file */ +/* If your system doesn't have remove(), try unlink() instead. + * remove() is the ANSI-standard name for this function, but + * unlink() was more common in pre-ANSI systems. + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +LOCAL(boolean) +open_file_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short handle; + + select_file_name(info->temp_name); + if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { + /* might as well exit since jpeg_open_backing_store will fail anyway */ + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + return FALSE; + } + info->handle.file_handle = handle; + info->read_backing_store = read_file_store; + info->write_backing_store = write_file_store; + info->close_backing_store = close_file_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); + return TRUE; /* succeeded */ +} + + +/* + * Access methods for extended memory. + */ + +#if XMS_SUPPORTED + +static XMSDRIVER xms_driver; /* saved address of XMS driver */ + +typedef union { /* either long offset or real-mode pointer */ + long offset; + void far * ptr; + } XMSPTR; + +typedef struct { /* XMS move specification structure */ + long length; + XMSH src_handle; + XMSPTR src; + XMSH dst_handle; + XMSPTR dst; + } XMSspec; + +#define ODD(X) (((X) & 1L) != 0) + + +METHODDEF(void) +read_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = info->handle.xms_handle; + spec.src.offset = file_offset; + spec.dst_handle = 0; + spec.dst.ptr = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_READ); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; + } +} + + +METHODDEF(void) +write_xms_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + XMScontext ctx; + XMSspec spec; + char endbuffer[2]; + + /* The XMS driver can't cope with an odd length, so handle the last byte + * specially if byte_count is odd. We don't expect this to be common. + */ + + spec.length = byte_count & (~ 1L); + spec.src_handle = 0; + spec.src.ptr = buffer_address; + spec.dst_handle = info->handle.xms_handle; + spec.dst.offset = file_offset; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x0b00; /* EMB move */ + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + ERREXIT(cinfo, JERR_XMS_WRITE); + + if (ODD(byte_count)) { + read_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; + write_xms_store(cinfo, info, (void FAR *) endbuffer, + file_offset + byte_count - 1L, 2L); + } +} + + +METHODDEF(void) +close_xms_store (j_common_ptr cinfo, backing_store_ptr info) +{ + XMScontext ctx; + + ctx.dx = info->handle.xms_handle; + ctx.ax = 0x0a00; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_xms_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + XMScontext ctx; + + /* Get address of XMS driver */ + jxms_getdriver((XMSDRIVER far *) & xms_driver); + if (xms_driver == NULL) + return FALSE; /* no driver to be had */ + + /* Get version number, must be >= 2.00 */ + ctx.ax = 0x0000; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax < (unsigned short) 0x0200) + return FALSE; + + /* Try to get space (expressed in kilobytes) */ + ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); + ctx.ax = 0x0900; + jxms_calldriver(xms_driver, (XMScontext far *) & ctx); + if (ctx.ax != 1) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.xms_handle = ctx.dx; + info->read_backing_store = read_xms_store; + info->write_backing_store = write_xms_store; + info->close_backing_store = close_xms_store; + TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* XMS_SUPPORTED */ + + +/* + * Access methods for expanded memory. + */ + +#if EMS_SUPPORTED + +/* The EMS move specification structure requires word and long fields aligned + * at odd byte boundaries. Some compilers will align struct fields at even + * byte boundaries. While it's usually possible to force byte alignment, + * that causes an overall performance penalty and may pose problems in merging + * JPEG into a larger application. Instead we accept some rather dirty code + * here. Note this code would fail if the hardware did not allow odd-byte + * word & long accesses, but all 80x86 CPUs do. + */ + +typedef void far * EMSPTR; + +typedef union { /* EMS move specification structure */ + long length; /* It's easy to access first 4 bytes */ + char bytes[18]; /* Misaligned fields in here! */ + } EMSspec; + +/* Macros for accessing misaligned fields */ +#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) +#define SRC_TYPE(spec) FIELD_AT(spec,4,char) +#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) +#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) +#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) +#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) +#define DST_TYPE(spec) FIELD_AT(spec,11,char) +#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) +#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) +#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) +#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) + +#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ + +#define HIBYTE(W) (((W) >> 8) & 0xFF) +#define LOBYTE(W) ((W) & 0xFF) + + +METHODDEF(void) +read_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 1; + SRC_HANDLE(spec) = info->handle.ems_handle; + SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + DST_TYPE(spec) = 0; + DST_HANDLE(spec) = 0; + DST_PTR(spec) = buffer_address; + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_READ); +} + + +METHODDEF(void) +write_ems_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + EMScontext ctx; + EMSspec spec; + + spec.length = byte_count; + SRC_TYPE(spec) = 0; + SRC_HANDLE(spec) = 0; + SRC_PTR(spec) = buffer_address; + DST_TYPE(spec) = 1; + DST_HANDLE(spec) = info->handle.ems_handle; + DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); + DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); + + ctx.ds_si = (void far *) & spec; + ctx.ax = 0x5700; /* move memory region */ + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + ERREXIT(cinfo, JERR_EMS_WRITE); +} + + +METHODDEF(void) +close_ems_store (j_common_ptr cinfo, backing_store_ptr info) +{ + EMScontext ctx; + + ctx.ax = 0x4500; + ctx.dx = info->handle.ems_handle; + jems_calldriver((EMScontext far *) & ctx); + TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); + /* we ignore any error return from the driver */ +} + + +LOCAL(boolean) +open_ems_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + EMScontext ctx; + + /* Is EMS driver there? */ + if (! jems_available()) + return FALSE; + + /* Get status, make sure EMS is OK */ + ctx.ax = 0x4000; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Get version, must be >= 4.0 */ + ctx.ax = 0x4600; + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) + return FALSE; + + /* Try to allocate requested space */ + ctx.ax = 0x4300; + ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); + jems_calldriver((EMScontext far *) & ctx); + if (HIBYTE(ctx.ax) != 0) + return FALSE; + + /* Succeeded, save the handle and away we go */ + info->handle.ems_handle = ctx.dx; + info->read_backing_store = read_ems_store; + info->write_backing_store = write_ems_store; + info->close_backing_store = close_ems_store; + TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); + return TRUE; /* succeeded */ +} + +#endif /* EMS_SUPPORTED */ + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + /* Try extended memory, then expanded memory, then regular file. */ +#if XMS_SUPPORTED + if (open_xms_store(cinfo, info, total_bytes_needed)) + return; +#endif +#if EMS_SUPPORTED + if (open_ems_store(cinfo, info, total_bytes_needed)) + return; +#endif + if (open_file_store(cinfo, info, total_bytes_needed)) + return; + ERREXITS(cinfo, JERR_TFILE_CREATE, ""); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* Microsoft C, at least in v6.00A, will not successfully reclaim freed + * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: + */ +#ifdef NEED_FHEAPMIN + _fheapmin(); +#endif +} diff --git a/libraries/external/jpeglib/jmemmac.c b/libraries/external/jpeglib/jmemmac.c new file mode 100755 index 0000000..a6f043e --- /dev/null +++ b/libraries/external/jpeglib/jmemmac.c @@ -0,0 +1,289 @@ +/* + * jmemmac.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * jmemmac.c provides an Apple Macintosh implementation of the system- + * dependent portion of the JPEG memory manager. + * + * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the + * JPEG_INTERNALS part of jconfig.h. + * + * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr + * instead of malloc and free. It accurately determines the amount of + * memory available by using CompactMem. Notice that if left to its + * own devices, this code can chew up all available space in the + * application's zone, with the exception of the rather small "slop" + * factor computed in jpeg_mem_available(). The application can ensure + * that more space is left over by reducing max_memory_to_use. + * + * Large images are swapped to disk using temporary files and System 7.0+'s + * temporary folder functionality. + * + * Note that jmemmac.c depends on two features of MacOS that were first + * introduced in System 7: FindFolder and the FSSpec-based calls. + * If your application uses jmemmac.c and is run under System 6 or earlier, + * and the jpeg library decides it needs a temporary file, it will abort, + * printing error messages about requiring System 7. (If no temporary files + * are created, it will run fine.) + * + * If you want to use jmemmac.c in an application that might be used with + * System 6 or earlier, then you should remove dependencies on FindFolder + * and the FSSpec calls. You will need to replace FindFolder with some + * other mechanism for finding a place to put temporary files, and you + * should replace the FSSpec calls with their HFS equivalents: + * + * FSpDelete -> HDelete + * FSpGetFInfo -> HGetFInfo + * FSpCreate -> HCreate + * FSpOpenDF -> HOpen *** Note: not HOpenDF *** + * FSMakeFSSpec -> (fill in spec by hand.) + * + * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, + * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the + * ages-old problem of names starting with a period.) + * + * Contributed by Sam Bushell (jsam@iagu.on.net) and + * Dan Gildor (gyld@in-touch.com). + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ + You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ +#endif + +#include /* we use the MacOS memory manager */ +#include /* we use the MacOS File stuff */ +#include /* we use the MacOS HFS stuff */ +#include /* for smSystemScript */ +#include /* we use Gestalt to test for specific functionality */ + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "JPG%03d.TMP" +#endif + +static int next_file_num; /* to distinguish among several temp files */ + + +/* + * Memory allocation and freeing are controlled by the MacOS library + * routines NewPtr() and DisposePtr(), which allocate fixed-address + * storage. Unfortunately, the IJG library isn't smart enough to cope + * with relocatable storage. + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: we include FAR keywords in the routine declarations simply for + * consistency with the rest of the IJG code; FAR should expand to empty + * on rational architectures like the Mac. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) NewPtr(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + DisposePtr((Ptr) object); +} + + +/* + * This routine computes the total memory space available for allocation. + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + long limit = cinfo->mem->max_memory_to_use - already_allocated; + long slop, mem; + + /* Don't ask for more than what application has told us we may use */ + if (max_bytes_needed > limit && limit > 0) + max_bytes_needed = limit; + /* Find whether there's a big enough free block in the heap. + * CompactMem tries to create a contiguous block of the requested size, + * and then returns the size of the largest free block (which could be + * much more or much less than we asked for). + * We add some slop to ensure we don't use up all available memory. + */ + slop = max_bytes_needed / 16 + 32768L; + mem = CompactMem(max_bytes_needed + slop) - slop; + if (mem < 0) + mem = 0; /* sigh, couldn't even get the slop */ + /* Don't take more than the application says we can have */ + if (mem > limit && limit > 0) + mem = limit; + return mem; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + long bytes = byte_count; + long retVal; + + if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) + ERREXIT(cinfo, JERR_TFILE_SEEK); + + retVal = FSRead ( info->temp_file, &bytes, + (unsigned char *) buffer_address ); + if ( retVal != noErr || bytes != byte_count ) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + long bytes = byte_count; + long retVal; + + if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) + ERREXIT(cinfo, JERR_TFILE_SEEK); + + retVal = FSWrite ( info->temp_file, &bytes, + (unsigned char *) buffer_address ); + if ( retVal != noErr || bytes != byte_count ) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + FSClose ( info->temp_file ); + FSpDelete ( &(info->tempSpec) ); +} + + +/* + * Initial opening of a backing-store object. + * + * This version uses FindFolder to find the Temporary Items folder, + * and puts the temporary file in there. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + short tmpRef, vRefNum; + long dirID; + FInfo finderInfo; + FSSpec theSpec; + Str255 fName; + OSErr osErr; + long gestaltResponse = 0; + + /* Check that FSSpec calls are available. */ + osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); + if ( ( osErr != noErr ) + || !( gestaltResponse & (1<temp_name, TEMP_FILE_NAME, next_file_num); + strcpy ( (Ptr)fName+1, info->temp_name ); + *fName = strlen (info->temp_name); + osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); + + if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) + break; + } + + osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); + if ( osErr != noErr ) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + + osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); + if ( osErr != noErr ) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + + info->tempSpec = theSpec; + + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; + + /* max_memory_to_use will be initialized to FreeMem()'s result; + * the calling application might later reduce it, for example + * to leave room to invoke multiple JPEG objects. + * Note that FreeMem returns the total number of free bytes; + * it may not be possible to allocate a single block of this size. + */ + return FreeMem(); +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/libraries/external/jpeglib/jmemmgr.c b/libraries/external/jpeglib/jmemmgr.c new file mode 100755 index 0000000..b636f1b --- /dev/null +++ b/libraries/external/jpeglib/jmemmgr.c @@ -0,0 +1,1118 @@ +/* + * jmemmgr.c + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains the JPEG system-independent memory management + * routines. This code is usable across a wide variety of machines; most + * of the system dependencies have been isolated in a separate file. + * The major functions provided here are: + * * pool-based allocation and freeing of memory; + * * policy decisions about how to divide available memory among the + * virtual arrays; + * * control logic for swapping virtual arrays between main memory and + * backing storage. + * The separate system-dependent file provides the actual backing-storage + * access code, and it contains the policy decision about how much total + * main memory to use. + * This file is system-dependent in the sense that some of its functions + * are unnecessary in some systems. For example, if there is enough virtual + * memory so that backing storage will never be used, much of the virtual + * array control logic could be removed. (Of course, if you have that much + * memory then you shouldn't care about a little bit of unused code...) + */ + +#define JPEG_INTERNALS +#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef NO_GETENV +#ifndef HAVE_STDLIB_H /* should declare getenv() */ +extern char * getenv JPP((const char * name)); +#endif +#endif + + +/* + * Some important notes: + * The allocation routines provided here must never return NULL. + * They should exit to error_exit if unsuccessful. + * + * It's not a good idea to try to merge the sarray and barray routines, + * even though they are textually almost the same, because samples are + * usually stored as bytes while coefficients are shorts or ints. Thus, + * in machines where byte pointers have a different representation from + * word pointers, the resulting machine code could not be the same. + */ + + +/* + * Many machines require storage alignment: longs must start on 4-byte + * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() + * always returns pointers that are multiples of the worst-case alignment + * requirement, and we had better do so too. + * There isn't any really portable way to determine the worst-case alignment + * requirement. This module assumes that the alignment requirement is + * multiples of sizeof(ALIGN_TYPE). + * By default, we define ALIGN_TYPE as double. This is necessary on some + * workstations (where doubles really do need 8-byte alignment) and will work + * fine on nearly everything. If your machine has lesser alignment needs, + * you can save a few bytes by making ALIGN_TYPE smaller. + * The only place I know of where this will NOT work is certain Macintosh + * 680x0 compilers that define double as a 10-byte IEEE extended float. + * Doing 10-byte alignment is counterproductive because longwords won't be + * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have + * such a compiler. + */ + +#ifndef ALIGN_TYPE /* so can override from jconfig.h */ +#define ALIGN_TYPE double +#endif + + +/* + * We allocate objects from "pools", where each pool is gotten with a single + * request to jpeg_get_small() or jpeg_get_large(). There is no per-object + * overhead within a pool, except for alignment padding. Each pool has a + * header with a link to the next pool of the same class. + * Small and large pool headers are identical except that the latter's + * link pointer must be FAR on 80x86 machines. + * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE + * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple + * of the alignment requirement of ALIGN_TYPE. + */ + +typedef union small_pool_struct * small_pool_ptr; + +typedef union small_pool_struct { + struct { + small_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} small_pool_hdr; + +typedef union large_pool_struct FAR * large_pool_ptr; + +typedef union large_pool_struct { + struct { + large_pool_ptr next; /* next in list of pools */ + size_t bytes_used; /* how many bytes already used within pool */ + size_t bytes_left; /* bytes still available in this pool */ + } hdr; + ALIGN_TYPE dummy; /* included in union to ensure alignment */ +} large_pool_hdr; + + +/* + * Here is the full definition of a memory manager object. + */ + +typedef struct { + struct jpeg_memory_mgr pub; /* public fields */ + + /* Each pool identifier (lifetime class) names a linked list of pools. */ + small_pool_ptr small_list[JPOOL_NUMPOOLS]; + large_pool_ptr large_list[JPOOL_NUMPOOLS]; + + /* Since we only have one lifetime class of virtual arrays, only one + * linked list is necessary (for each datatype). Note that the virtual + * array control blocks being linked together are actually stored somewhere + * in the small-pool list. + */ + jvirt_sarray_ptr virt_sarray_list; + jvirt_barray_ptr virt_barray_list; + + /* This counts total space obtained from jpeg_get_small/large */ + long total_space_allocated; + + /* alloc_sarray and alloc_barray set this value for use by virtual + * array routines. + */ + JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ +} my_memory_mgr; + +typedef my_memory_mgr * my_mem_ptr; + + +/* + * The control blocks for virtual arrays. + * Note that these blocks are allocated in the "small" pool area. + * System-dependent info for the associated backing store (if any) is hidden + * inside the backing_store_info struct. + */ + +struct jvirt_sarray_control { + JSAMPARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_sarray_ptr next; /* link to next virtual sarray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + +struct jvirt_barray_control { + JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ + JDIMENSION rows_in_array; /* total virtual array height */ + JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ + JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ + JDIMENSION rows_in_mem; /* height of memory buffer */ + JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ + JDIMENSION cur_start_row; /* first logical row # in the buffer */ + JDIMENSION first_undef_row; /* row # of first uninitialized row */ + boolean pre_zero; /* pre-zero mode requested? */ + boolean dirty; /* do current buffer contents need written? */ + boolean b_s_open; /* is backing-store data valid? */ + jvirt_barray_ptr next; /* link to next virtual barray control block */ + backing_store_info b_s_info; /* System-dependent control info */ +}; + + +#ifdef MEM_STATS /* optional extra stuff for statistics */ + +LOCAL(void) +print_mem_stats (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + + /* Since this is only a debugging stub, we can cheat a little by using + * fprintf directly rather than going through the trace message code. + * This is helpful because message parm array can't handle longs. + */ + fprintf(stderr, "Freeing pool %d, total space = %ld\n", + pool_id, mem->total_space_allocated); + + for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; + lhdr_ptr = lhdr_ptr->hdr.next) { + fprintf(stderr, " Large chunk used %ld\n", + (long) lhdr_ptr->hdr.bytes_used); + } + + for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; + shdr_ptr = shdr_ptr->hdr.next) { + fprintf(stderr, " Small chunk used %ld free %ld\n", + (long) shdr_ptr->hdr.bytes_used, + (long) shdr_ptr->hdr.bytes_left); + } +} + +#endif /* MEM_STATS */ + + +LOCAL(void) +out_of_memory (j_common_ptr cinfo, int which) +/* Report an out-of-memory error and stop execution */ +/* If we compiled MEM_STATS support, report alloc requests before dying */ +{ +#ifdef MEM_STATS + cinfo->err->trace_level = 2; /* force self_destruct to report stats */ +#endif + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); +} + + +/* + * Allocation of "small" objects. + * + * For these, we use pooled storage. When a new pool must be created, + * we try to get enough space for the current request plus a "slop" factor, + * where the slop will be the amount of leftover space in the new pool. + * The speed vs. space tradeoff is largely determined by the slop values. + * A different slop value is provided for each pool class (lifetime), + * and we also distinguish the first pool of a class from later ones. + * NOTE: the values given work fairly well on both 16- and 32-bit-int + * machines, but may be too small if longs are 64 bits or more. + */ + +static const size_t first_pool_slop[JPOOL_NUMPOOLS] = +{ + 1600, /* first PERMANENT pool */ + 16000 /* first IMAGE pool */ +}; + +static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = +{ + 0, /* additional PERMANENT pools */ + 5000 /* additional IMAGE pools */ +}; + +#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ + + +METHODDEF(void *) +alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "small" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr hdr_ptr, prev_hdr_ptr; + char * data_ptr; + size_t odd_bytes, min_request, slop; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) + out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* See if space is available in any existing pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + prev_hdr_ptr = NULL; + hdr_ptr = mem->small_list[pool_id]; + while (hdr_ptr != NULL) { + if (hdr_ptr->hdr.bytes_left >= sizeofobject) + break; /* found pool with enough space */ + prev_hdr_ptr = hdr_ptr; + hdr_ptr = hdr_ptr->hdr.next; + } + + /* Time to make a new pool? */ + if (hdr_ptr == NULL) { + /* min_request is what we need now, slop is what will be leftover */ + min_request = sizeofobject + SIZEOF(small_pool_hdr); + if (prev_hdr_ptr == NULL) /* first pool in class? */ + slop = first_pool_slop[pool_id]; + else + slop = extra_pool_slop[pool_id]; + /* Don't ask for more than MAX_ALLOC_CHUNK */ + if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) + slop = (size_t) (MAX_ALLOC_CHUNK-min_request); + /* Try to get space, if fail reduce slop and try again */ + for (;;) { + hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); + if (hdr_ptr != NULL) + break; + slop /= 2; + if (slop < MIN_SLOP) /* give up when it gets real small */ + out_of_memory(cinfo, 2); /* jpeg_get_small failed */ + } + mem->total_space_allocated += min_request + slop; + /* Success, initialize the new pool header and add to end of list */ + hdr_ptr->hdr.next = NULL; + hdr_ptr->hdr.bytes_used = 0; + hdr_ptr->hdr.bytes_left = sizeofobject + slop; + if (prev_hdr_ptr == NULL) /* first pool in class? */ + mem->small_list[pool_id] = hdr_ptr; + else + prev_hdr_ptr->hdr.next = hdr_ptr; + } + + /* OK, allocate the object from the current pool */ + data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ + data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ + hdr_ptr->hdr.bytes_used += sizeofobject; + hdr_ptr->hdr.bytes_left -= sizeofobject; + + return (void *) data_ptr; +} + + +/* + * Allocation of "large" objects. + * + * The external semantics of these are the same as "small" objects, + * except that FAR pointers are used on 80x86. However the pool + * management heuristics are quite different. We assume that each + * request is large enough that it may as well be passed directly to + * jpeg_get_large; the pool management just links everything together + * so that we can free it all on demand. + * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY + * structures. The routines that create these structures (see below) + * deliberately bunch rows together to ensure a large request size. + */ + +METHODDEF(void FAR *) +alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) +/* Allocate a "large" object */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + large_pool_ptr hdr_ptr; + size_t odd_bytes; + + /* Check for unsatisfiable request (do now to ensure no overflow below) */ + if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) + out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ + + /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ + odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); + if (odd_bytes > 0) + sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; + + /* Always make a new pool */ + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + + SIZEOF(large_pool_hdr)); + if (hdr_ptr == NULL) + out_of_memory(cinfo, 4); /* jpeg_get_large failed */ + mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); + + /* Success, initialize the new pool header and add to list */ + hdr_ptr->hdr.next = mem->large_list[pool_id]; + /* We maintain space counts in each pool header for statistical purposes, + * even though they are not needed for allocation. + */ + hdr_ptr->hdr.bytes_used = sizeofobject; + hdr_ptr->hdr.bytes_left = 0; + mem->large_list[pool_id] = hdr_ptr; + + return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ +} + + +/* + * Creation of 2-D sample arrays. + * The pointers are in near heap, the samples themselves in FAR heap. + * + * To minimize allocation overhead and to allow I/O of large contiguous + * blocks, we allocate the sample rows in groups of as many rows as possible + * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. + * NB: the virtual array control routines, later in this file, know about + * this chunking of rows. The rowsperchunk value is left in the mem manager + * object so that it can be saved away if this sarray is the workspace for + * a virtual array. + */ + +METHODDEF(JSAMPARRAY) +alloc_sarray (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, JDIMENSION numrows) +/* Allocate a 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JSAMPARRAY result; + JSAMPROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / + ((long) samplesperrow * SIZEOF(JSAMPLE)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JSAMPARRAY) alloc_small(cinfo, pool_id, + (size_t) (numrows * SIZEOF(JSAMPROW))); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JSAMPROW) alloc_large(cinfo, pool_id, + (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow + * SIZEOF(JSAMPLE))); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += samplesperrow; + } + } + + return result; +} + + +/* + * Creation of 2-D coefficient-block arrays. + * This is essentially the same as the code for sample arrays, above. + */ + +METHODDEF(JBLOCKARRAY) +alloc_barray (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, JDIMENSION numrows) +/* Allocate a 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + JBLOCKARRAY result; + JBLOCKROW workspace; + JDIMENSION rowsperchunk, currow, i; + long ltemp; + + /* Calculate max # of rows allowed in one allocation chunk */ + ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / + ((long) blocksperrow * SIZEOF(JBLOCK)); + if (ltemp <= 0) + ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); + if (ltemp < (long) numrows) + rowsperchunk = (JDIMENSION) ltemp; + else + rowsperchunk = numrows; + mem->last_rowsperchunk = rowsperchunk; + + /* Get space for row pointers (small object) */ + result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, + (size_t) (numrows * SIZEOF(JBLOCKROW))); + + /* Get the rows themselves (large objects) */ + currow = 0; + while (currow < numrows) { + rowsperchunk = MIN(rowsperchunk, numrows - currow); + workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, + (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow + * SIZEOF(JBLOCK))); + for (i = rowsperchunk; i > 0; i--) { + result[currow++] = workspace; + workspace += blocksperrow; + } + } + + return result; +} + + +/* + * About virtual array management: + * + * The above "normal" array routines are only used to allocate strip buffers + * (as wide as the image, but just a few rows high). Full-image-sized buffers + * are handled as "virtual" arrays. The array is still accessed a strip at a + * time, but the memory manager must save the whole array for repeated + * accesses. The intended implementation is that there is a strip buffer in + * memory (as high as is possible given the desired memory limit), plus a + * backing file that holds the rest of the array. + * + * The request_virt_array routines are told the total size of the image and + * the maximum number of rows that will be accessed at once. The in-memory + * buffer must be at least as large as the maxaccess value. + * + * The request routines create control blocks but not the in-memory buffers. + * That is postponed until realize_virt_arrays is called. At that time the + * total amount of space needed is known (approximately, anyway), so free + * memory can be divided up fairly. + * + * The access_virt_array routines are responsible for making a specific strip + * area accessible (after reading or writing the backing file, if necessary). + * Note that the access routines are told whether the caller intends to modify + * the accessed strip; during a read-only pass this saves having to rewrite + * data to disk. The access routines are also responsible for pre-zeroing + * any newly accessed rows, if pre-zeroing was requested. + * + * In current usage, the access requests are usually for nonoverlapping + * strips; that is, successive access start_row numbers differ by exactly + * num_rows = maxaccess. This means we can get good performance with simple + * buffer dump/reload logic, by making the in-memory buffer be a multiple + * of the access height; then there will never be accesses across bufferload + * boundaries. The code will still work with overlapping access requests, + * but it doesn't handle bufferload overlaps very efficiently. + */ + + +METHODDEF(jvirt_sarray_ptr) +request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION samplesperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D sample array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_sarray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_sarray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->samplesperrow = samplesperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ + mem->virt_sarray_list = result; + + return result; +} + + +METHODDEF(jvirt_barray_ptr) +request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, + JDIMENSION blocksperrow, JDIMENSION numrows, + JDIMENSION maxaccess) +/* Request a virtual 2-D coefficient-block array */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + jvirt_barray_ptr result; + + /* Only IMAGE-lifetime virtual arrays are currently supported */ + if (pool_id != JPOOL_IMAGE) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + + /* get control block */ + result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, + SIZEOF(struct jvirt_barray_control)); + + result->mem_buffer = NULL; /* marks array not yet realized */ + result->rows_in_array = numrows; + result->blocksperrow = blocksperrow; + result->maxaccess = maxaccess; + result->pre_zero = pre_zero; + result->b_s_open = FALSE; /* no associated backing-store object */ + result->next = mem->virt_barray_list; /* add to list of virtual arrays */ + mem->virt_barray_list = result; + + return result; +} + + +METHODDEF(void) +realize_virt_arrays (j_common_ptr cinfo) +/* Allocate the in-memory buffers for any unrealized virtual arrays */ +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + long space_per_minheight, maximum_space, avail_mem; + long minheights, max_minheights; + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + /* Compute the minimum space needed (maxaccess rows in each buffer) + * and the maximum space needed (full image height in each buffer). + * These may be of use to the system-dependent jpeg_mem_available routine. + */ + space_per_minheight = 0; + maximum_space = 0; + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + space_per_minheight += (long) sptr->maxaccess * + (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + maximum_space += (long) sptr->rows_in_array * + (long) sptr->samplesperrow * SIZEOF(JSAMPLE); + } + } + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + space_per_minheight += (long) bptr->maxaccess * + (long) bptr->blocksperrow * SIZEOF(JBLOCK); + maximum_space += (long) bptr->rows_in_array * + (long) bptr->blocksperrow * SIZEOF(JBLOCK); + } + } + + if (space_per_minheight <= 0) + return; /* no unrealized arrays, no work */ + + /* Determine amount of memory to actually use; this is system-dependent. */ + avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, + mem->total_space_allocated); + + /* If the maximum space needed is available, make all the buffers full + * height; otherwise parcel it out with the same number of minheights + * in each buffer. + */ + if (avail_mem >= maximum_space) + max_minheights = 1000000000L; + else { + max_minheights = avail_mem / space_per_minheight; + /* If there doesn't seem to be enough space, try to get the minimum + * anyway. This allows a "stub" implementation of jpeg_mem_available(). + */ + if (max_minheights <= 0) + max_minheights = 1; + } + + /* Allocate the in-memory buffers and initialize backing store as needed. */ + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + sptr->rows_in_mem = sptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); + jpeg_open_backing_store(cinfo, & sptr->b_s_info, + (long) sptr->rows_in_array * + (long) sptr->samplesperrow * + (long) SIZEOF(JSAMPLE)); + sptr->b_s_open = TRUE; + } + sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, + sptr->samplesperrow, sptr->rows_in_mem); + sptr->rowsperchunk = mem->last_rowsperchunk; + sptr->cur_start_row = 0; + sptr->first_undef_row = 0; + sptr->dirty = FALSE; + } + } + + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->mem_buffer == NULL) { /* if not realized yet */ + minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; + if (minheights <= max_minheights) { + /* This buffer fits in memory */ + bptr->rows_in_mem = bptr->rows_in_array; + } else { + /* It doesn't fit in memory, create backing store. */ + bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); + jpeg_open_backing_store(cinfo, & bptr->b_s_info, + (long) bptr->rows_in_array * + (long) bptr->blocksperrow * + (long) SIZEOF(JBLOCK)); + bptr->b_s_open = TRUE; + } + bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, + bptr->blocksperrow, bptr->rows_in_mem); + bptr->rowsperchunk = mem->last_rowsperchunk; + bptr->cur_start_row = 0; + bptr->first_undef_row = 0; + bptr->dirty = FALSE; + } + } +} + + +LOCAL(void) +do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual sample array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); + file_offset = ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +LOCAL(void) +do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) +/* Do backing store read or write of a virtual coefficient-block array */ +{ + long bytesperrow, file_offset, byte_count, rows, thisrow, i; + + bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); + file_offset = ptr->cur_start_row * bytesperrow; + /* Loop to read or write each allocation chunk in mem_buffer */ + for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { + /* One chunk, but check for short chunk at end of buffer */ + rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); + /* Transfer no more than is currently defined */ + thisrow = (long) ptr->cur_start_row + i; + rows = MIN(rows, (long) ptr->first_undef_row - thisrow); + /* Transfer no more than fits in file */ + rows = MIN(rows, (long) ptr->rows_in_array - thisrow); + if (rows <= 0) /* this chunk might be past end of file! */ + break; + byte_count = rows * bytesperrow; + if (writing) + (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + else + (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, + (void FAR *) ptr->mem_buffer[i], + file_offset, byte_count); + file_offset += byte_count; + } +} + + +METHODDEF(JSAMPARRAY) +access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual sample array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row+ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_sarray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_sarray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +METHODDEF(JBLOCKARRAY) +access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, + JDIMENSION start_row, JDIMENSION num_rows, + boolean writable) +/* Access the part of a virtual block array starting at start_row */ +/* and extending for num_rows rows. writable is true if */ +/* caller intends to modify the accessed area. */ +{ + JDIMENSION end_row = start_row + num_rows; + JDIMENSION undef_row; + + /* debugging check */ + if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || + ptr->mem_buffer == NULL) + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + + /* Make the desired part of the virtual array accessible */ + if (start_row < ptr->cur_start_row || + end_row > ptr->cur_start_row+ptr->rows_in_mem) { + if (! ptr->b_s_open) + ERREXIT(cinfo, JERR_VIRTUAL_BUG); + /* Flush old buffer contents if necessary */ + if (ptr->dirty) { + do_barray_io(cinfo, ptr, TRUE); + ptr->dirty = FALSE; + } + /* Decide what part of virtual array to access. + * Algorithm: if target address > current window, assume forward scan, + * load starting at target address. If target address < current window, + * assume backward scan, load so that target area is top of window. + * Note that when switching from forward write to forward read, will have + * start_row = 0, so the limiting case applies and we load from 0 anyway. + */ + if (start_row > ptr->cur_start_row) { + ptr->cur_start_row = start_row; + } else { + /* use long arithmetic here to avoid overflow & unsigned problems */ + long ltemp; + + ltemp = (long) end_row - (long) ptr->rows_in_mem; + if (ltemp < 0) + ltemp = 0; /* don't fall off front end of file */ + ptr->cur_start_row = (JDIMENSION) ltemp; + } + /* Read in the selected part of the array. + * During the initial write pass, we will do no actual read + * because the selected part is all undefined. + */ + do_barray_io(cinfo, ptr, FALSE); + } + /* Ensure the accessed part of the array is defined; prezero if needed. + * To improve locality of access, we only prezero the part of the array + * that the caller is about to access, not the entire in-memory array. + */ + if (ptr->first_undef_row < end_row) { + if (ptr->first_undef_row < start_row) { + if (writable) /* writer skipped over a section of array */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + undef_row = start_row; /* but reader is allowed to read ahead */ + } else { + undef_row = ptr->first_undef_row; + } + if (writable) + ptr->first_undef_row = end_row; + if (ptr->pre_zero) { + size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); + undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ + end_row -= ptr->cur_start_row; + while (undef_row < end_row) { + jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + undef_row++; + } + } else { + if (! writable) /* reader looking at undefined data */ + ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); + } + } + /* Flag the buffer dirty if caller will write in it */ + if (writable) + ptr->dirty = TRUE; + /* Return address of proper part of the buffer */ + return ptr->mem_buffer + (start_row - ptr->cur_start_row); +} + + +/* + * Release all objects belonging to a specified pool. + */ + +METHODDEF(void) +free_pool (j_common_ptr cinfo, int pool_id) +{ + my_mem_ptr mem = (my_mem_ptr) cinfo->mem; + small_pool_ptr shdr_ptr; + large_pool_ptr lhdr_ptr; + size_t space_freed; + + if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) + ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ + +#ifdef MEM_STATS + if (cinfo->err->trace_level > 1) + print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ +#endif + + /* If freeing IMAGE pool, close any virtual arrays first */ + if (pool_id == JPOOL_IMAGE) { + jvirt_sarray_ptr sptr; + jvirt_barray_ptr bptr; + + for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { + if (sptr->b_s_open) { /* there may be no backing store */ + sptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); + } + } + mem->virt_sarray_list = NULL; + for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { + if (bptr->b_s_open) { /* there may be no backing store */ + bptr->b_s_open = FALSE; /* prevent recursive close if error */ + (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); + } + } + mem->virt_barray_list = NULL; + } + + /* Release large objects */ + lhdr_ptr = mem->large_list[pool_id]; + mem->large_list[pool_id] = NULL; + + while (lhdr_ptr != NULL) { + large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; + space_freed = lhdr_ptr->hdr.bytes_used + + lhdr_ptr->hdr.bytes_left + + SIZEOF(large_pool_hdr); + jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + lhdr_ptr = next_lhdr_ptr; + } + + /* Release small objects */ + shdr_ptr = mem->small_list[pool_id]; + mem->small_list[pool_id] = NULL; + + while (shdr_ptr != NULL) { + small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; + space_freed = shdr_ptr->hdr.bytes_used + + shdr_ptr->hdr.bytes_left + + SIZEOF(small_pool_hdr); + jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); + mem->total_space_allocated -= space_freed; + shdr_ptr = next_shdr_ptr; + } +} + + +/* + * Close up shop entirely. + * Note that this cannot be called unless cinfo->mem is non-NULL. + */ + +METHODDEF(void) +self_destruct (j_common_ptr cinfo) +{ + int pool; + + /* Close all backing store, release all memory. + * Releasing pools in reverse order might help avoid fragmentation + * with some (brain-damaged) malloc libraries. + */ + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + free_pool(cinfo, pool); + } + + /* Release the memory manager control block too. */ + jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); + cinfo->mem = NULL; /* ensures I will be called only once */ + + jpeg_mem_term(cinfo); /* system-dependent cleanup */ +} + + +/* + * Memory manager initialization. + * When this is called, only the error manager pointer is valid in cinfo! + */ + +GLOBAL(void) +jinit_memory_mgr (j_common_ptr cinfo) +{ + my_mem_ptr mem; + long max_to_use; + int pool; + size_t test_mac; + + cinfo->mem = NULL; /* for safety if init fails */ + + /* Check for configuration errors. + * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably + * doesn't reflect any real hardware alignment requirement. + * The test is a little tricky: for X>0, X and X-1 have no one-bits + * in common if and only if X is a power of 2, ie has only one one-bit. + * Some compilers may give an "unreachable code" warning here; ignore it. + */ + if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) + ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); + /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be + * a multiple of SIZEOF(ALIGN_TYPE). + * Again, an "unreachable code" warning may be ignored here. + * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. + */ + test_mac = (size_t) MAX_ALLOC_CHUNK; + if ((long) test_mac != MAX_ALLOC_CHUNK || + (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) + ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); + + max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ + + /* Attempt to allocate memory manager's control block */ + mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); + + if (mem == NULL) { + jpeg_mem_term(cinfo); /* system-dependent cleanup */ + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); + } + + /* OK, fill in the method pointers */ + mem->pub.alloc_small = alloc_small; + mem->pub.alloc_large = alloc_large; + mem->pub.alloc_sarray = alloc_sarray; + mem->pub.alloc_barray = alloc_barray; + mem->pub.request_virt_sarray = request_virt_sarray; + mem->pub.request_virt_barray = request_virt_barray; + mem->pub.realize_virt_arrays = realize_virt_arrays; + mem->pub.access_virt_sarray = access_virt_sarray; + mem->pub.access_virt_barray = access_virt_barray; + mem->pub.free_pool = free_pool; + mem->pub.self_destruct = self_destruct; + + /* Make MAX_ALLOC_CHUNK accessible to other modules */ + mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; + + /* Initialize working state */ + mem->pub.max_memory_to_use = max_to_use; + + for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { + mem->small_list[pool] = NULL; + mem->large_list[pool] = NULL; + } + mem->virt_sarray_list = NULL; + mem->virt_barray_list = NULL; + + mem->total_space_allocated = SIZEOF(my_memory_mgr); + + /* Declare ourselves open for business */ + cinfo->mem = & mem->pub; + + /* Check for an environment variable JPEGMEM; if found, override the + * default max_memory setting from jpeg_mem_init. Note that the + * surrounding application may again override this value. + * If your system doesn't support getenv(), define NO_GETENV to disable + * this feature. + */ +#ifndef NO_GETENV + { char * memenv; + + if ((memenv = getenv("JPEGMEM")) != NULL) { + char ch = 'x'; + + if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { + if (ch == 'm' || ch == 'M') + max_to_use *= 1000L; + mem->pub.max_memory_to_use = max_to_use * 1000L; + } + } + } +#endif + +} diff --git a/libraries/external/jpeglib/jmemmgr.o b/libraries/external/jpeglib/jmemmgr.o new file mode 100644 index 0000000..2a4327d Binary files /dev/null and b/libraries/external/jpeglib/jmemmgr.o differ diff --git a/libraries/external/jpeglib/jmemname.c b/libraries/external/jpeglib/jmemname.c new file mode 100755 index 0000000..e28b212 --- /dev/null +++ b/libraries/external/jpeglib/jmemname.c @@ -0,0 +1,276 @@ +/* + * jmemname.c + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a generic implementation of the system-dependent + * portion of the JPEG memory manager. This implementation assumes that + * you must explicitly construct a name for each temp file. + * Also, the problem of determining the amount of memory available + * is shoved onto the user. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + +#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ +#define SEEK_SET 0 /* if not, assume 0 is correct */ +#endif + +#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ +#define READ_BINARY "r" +#define RW_BINARY "w+" +#else +#ifdef VMS /* VMS is very nonstandard */ +#define READ_BINARY "rb", "ctx=stm" +#define RW_BINARY "w+b", "ctx=stm" +#else /* standard ANSI-compliant case */ +#define READ_BINARY "rb" +#define RW_BINARY "w+b" +#endif +#endif + + +/* + * Selection of a file name for a temporary file. + * This is system-dependent! + * + * The code as given is suitable for most Unix systems, and it is easily + * modified for most non-Unix systems. Some notes: + * 1. The temp file is created in the directory named by TEMP_DIRECTORY. + * The default value is /usr/tmp, which is the conventional place for + * creating large temp files on Unix. On other systems you'll probably + * want to change the file location. You can do this by editing the + * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. + * + * 2. If you need to change the file name as well as its location, + * you can override the TEMP_FILE_NAME macro. (Note that this is + * actually a printf format string; it must contain %s and %d.) + * Few people should need to do this. + * + * 3. mktemp() is used to ensure that multiple processes running + * simultaneously won't select the same file names. If your system + * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. + * (If you don't have , also define NO_ERRNO_H.) + * + * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c + * will cause the temp files to be removed if you stop the program early. + */ + +#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ +#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ +#endif + +static int next_file_num; /* to distinguish among several temp files */ + +#ifdef NO_MKTEMP + +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%03d.TMP" +#endif + +#ifndef NO_ERRNO_H +#include /* to define ENOENT */ +#endif + +/* ANSI C specifies that errno is a macro, but on older systems it's more + * likely to be a plain int variable. And not all versions of errno.h + * bother to declare it, so we have to in order to be most portable. Thus: + */ +#ifndef errno +extern int errno; +#endif + + +LOCAL(void) +select_file_name (char * fname) +{ + FILE * tfile; + + /* Keep generating file names till we find one that's not in use */ + for (;;) { + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + if ((tfile = fopen(fname, READ_BINARY)) == NULL) { + /* fopen could have failed for a reason other than the file not + * being there; for example, file there but unreadable. + * If isn't available, then we cannot test the cause. + */ +#ifdef ENOENT + if (errno != ENOENT) + continue; +#endif + break; + } + fclose(tfile); /* oops, it's there; close tfile & try again */ + } +} + +#else /* ! NO_MKTEMP */ + +/* Note that mktemp() requires the initial filename to end in six X's */ +#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ +#define TEMP_FILE_NAME "%sJPG%dXXXXXX" +#endif + +LOCAL(void) +select_file_name (char * fname) +{ + next_file_num++; /* advance counter */ + sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); + mktemp(fname); /* make sure file name is unique */ + /* mktemp replaces the trailing XXXXXX with a unique string of characters */ +} + +#endif /* NO_MKTEMP */ + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * It's impossible to do this in a portable way; our current solution is + * to make the user tell us (with a default value set at compile time). + * If you can actually get the available space, it's a good idea to subtract + * a slop factor of 5% or so. + */ + +#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ +#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ +#endif + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return cinfo->mem->max_memory_to_use - already_allocated; +} + + +/* + * Backing store (temporary file) management. + * Backing store objects are only used when the value returned by + * jpeg_mem_available is less than the total space needed. You can dispense + * with these routines if you have plenty of virtual memory; see jmemnobs.c. + */ + + +METHODDEF(void) +read_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFREAD(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_READ); +} + + +METHODDEF(void) +write_backing_store (j_common_ptr cinfo, backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count) +{ + if (fseek(info->temp_file, file_offset, SEEK_SET)) + ERREXIT(cinfo, JERR_TFILE_SEEK); + if (JFWRITE(info->temp_file, buffer_address, byte_count) + != (size_t) byte_count) + ERREXIT(cinfo, JERR_TFILE_WRITE); +} + + +METHODDEF(void) +close_backing_store (j_common_ptr cinfo, backing_store_ptr info) +{ + fclose(info->temp_file); /* close the file */ + unlink(info->temp_name); /* delete the file */ +/* If your system doesn't have unlink(), use remove() instead. + * remove() is the ANSI-standard name for this function, but if + * your system was ANSI you'd be using jmemansi.c, right? + */ + TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); +} + + +/* + * Initial opening of a backing-store object. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + select_file_name(info->temp_name); + if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) + ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); + info->read_backing_store = read_backing_store; + info->write_backing_store = write_backing_store; + info->close_backing_store = close_backing_store; + TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + next_file_num = 0; /* initialize temp file name generator */ + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/libraries/external/jpeglib/jmemnobs.c b/libraries/external/jpeglib/jmemnobs.c new file mode 100755 index 0000000..6aa1e92 --- /dev/null +++ b/libraries/external/jpeglib/jmemnobs.c @@ -0,0 +1,109 @@ +/* + * jmemnobs.c + * + * Copyright (C) 1992-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides a really simple implementation of the system- + * dependent portion of the JPEG memory manager. This implementation + * assumes that no backing-store files are needed: all required space + * can be obtained from malloc(). + * This is very portable in the sense that it'll compile on almost anything, + * but you'd better have lots of main memory (or virtual memory) if you want + * to process big images. + * Note that the max_memory_to_use option is ignored by this implementation. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" +#include "jmemsys.h" /* import the system-dependent declarations */ + +#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ +extern void * malloc JPP((size_t size)); +extern void free JPP((void *ptr)); +#endif + + +/* + * Memory allocation and freeing are controlled by the regular library + * routines malloc() and free(). + */ + +GLOBAL(void *) +jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * "Large" objects are treated the same as "small" ones. + * NB: although we include FAR keywords in the routine declarations, + * this file won't actually work in 80x86 small/medium model; at least, + * you probably won't be able to process useful-size images in only 64KB. + */ + +GLOBAL(void FAR *) +jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) +{ + return (void FAR *) malloc(sizeofobject); +} + +GLOBAL(void) +jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +{ + free(object); +} + + +/* + * This routine computes the total memory space available for allocation. + * Here we always say, "we got all you want bud!" + */ + +GLOBAL(long) +jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, + long max_bytes_needed, long already_allocated) +{ + return max_bytes_needed; +} + + +/* + * Backing store (temporary file) management. + * Since jpeg_mem_available always promised the moon, + * this should never be called and we can just error out. + */ + +GLOBAL(void) +jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, + long total_bytes_needed) +{ + ERREXIT(cinfo, JERR_NO_BACKING_STORE); +} + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. Here, there isn't any. + */ + +GLOBAL(long) +jpeg_mem_init (j_common_ptr cinfo) +{ + return 0; /* just set max_memory_to_use to 0 */ +} + +GLOBAL(void) +jpeg_mem_term (j_common_ptr cinfo) +{ + /* no work */ +} diff --git a/libraries/external/jpeglib/jmemnobs.o b/libraries/external/jpeglib/jmemnobs.o new file mode 100644 index 0000000..8835ddd Binary files /dev/null and b/libraries/external/jpeglib/jmemnobs.o differ diff --git a/libraries/external/jpeglib/jmemsys.h b/libraries/external/jpeglib/jmemsys.h new file mode 100755 index 0000000..2a87961 --- /dev/null +++ b/libraries/external/jpeglib/jmemsys.h @@ -0,0 +1,198 @@ +/* + * jmemsys.h + * + * Copyright (C) 1992-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This include file defines the interface between the system-independent + * and system-dependent portions of the JPEG memory manager. No other + * modules need include it. (The system-independent portion is jmemmgr.c; + * there are several different versions of the system-dependent portion.) + * + * This file works as-is for the system-dependent memory managers supplied + * in the IJG distribution. You may need to modify it if you write a + * custom memory manager. If system-dependent changes are needed in + * this file, the best method is to #ifdef them based on a configuration + * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR + * and USE_MAC_MEMMGR. + */ + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_get_small jGetSmall +#define jpeg_free_small jFreeSmall +#define jpeg_get_large jGetLarge +#define jpeg_free_large jFreeLarge +#define jpeg_mem_available jMemAvail +#define jpeg_open_backing_store jOpenBackStore +#define jpeg_mem_init jMemInit +#define jpeg_mem_term jMemTerm +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* + * These two functions are used to allocate and release small chunks of + * memory. (Typically the total amount requested through jpeg_get_small is + * no more than 20K or so; this will be requested in chunks of a few K each.) + * Behavior should be the same as for the standard library functions malloc + * and free; in particular, jpeg_get_small must return NULL on failure. + * On most systems, these ARE malloc and free. jpeg_free_small is passed the + * size of the object being freed, just in case it's needed. + * On an 80x86 machine using small-data memory model, these manage near heap. + */ + +EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); +EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, + size_t sizeofobject)); + +/* + * These two functions are used to allocate and release large chunks of + * memory (up to the total free space designated by jpeg_mem_available). + * The interface is the same as above, except that on an 80x86 machine, + * far pointers are used. On most other machines these are identical to + * the jpeg_get/free_small routines; but we keep them separate anyway, + * in case a different allocation strategy is desirable for large chunks. + */ + +EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, + size_t sizeofobject)); +EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, + size_t sizeofobject)); + +/* + * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may + * be requested in a single call to jpeg_get_large (and jpeg_get_small for that + * matter, but that case should never come into play). This macro is needed + * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. + * On those machines, we expect that jconfig.h will provide a proper value. + * On machines with 32-bit flat address spaces, any large constant may be used. + * + * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type + * size_t and will be a multiple of sizeof(align_type). + */ + +#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ +#define MAX_ALLOC_CHUNK 1000000000L +#endif + +/* + * This routine computes the total space still available for allocation by + * jpeg_get_large. If more space than this is needed, backing store will be + * used. NOTE: any memory already allocated must not be counted. + * + * There is a minimum space requirement, corresponding to the minimum + * feasible buffer sizes; jmemmgr.c will request that much space even if + * jpeg_mem_available returns zero. The maximum space needed, enough to hold + * all working storage in memory, is also passed in case it is useful. + * Finally, the total space already allocated is passed. If no better + * method is available, cinfo->mem->max_memory_to_use - already_allocated + * is often a suitable calculation. + * + * It is OK for jpeg_mem_available to underestimate the space available + * (that'll just lead to more backing-store access than is really necessary). + * However, an overestimate will lead to failure. Hence it's wise to subtract + * a slop factor from the true available space. 5% should be enough. + * + * On machines with lots of virtual memory, any large constant may be returned. + * Conversely, zero may be returned to always use the minimum amount of memory. + */ + +EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, + long min_bytes_needed, + long max_bytes_needed, + long already_allocated)); + + +/* + * This structure holds whatever state is needed to access a single + * backing-store object. The read/write/close method pointers are called + * by jmemmgr.c to manipulate the backing-store object; all other fields + * are private to the system-dependent backing store routines. + */ + +#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ + + +#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ + +typedef unsigned short XMSH; /* type of extended-memory handles */ +typedef unsigned short EMSH; /* type of expanded-memory handles */ + +typedef union { + short file_handle; /* DOS file handle if it's a temp file */ + XMSH xms_handle; /* handle if it's a chunk of XMS */ + EMSH ems_handle; /* handle if it's a chunk of EMS */ +} handle_union; + +#endif /* USE_MSDOS_MEMMGR */ + +#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ +#include +#endif /* USE_MAC_MEMMGR */ + + +typedef struct backing_store_struct * backing_store_ptr; + +typedef struct backing_store_struct { + /* Methods for reading/writing/closing this backing-store object */ + JMETHOD(void, read_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, write_backing_store, (j_common_ptr cinfo, + backing_store_ptr info, + void FAR * buffer_address, + long file_offset, long byte_count)); + JMETHOD(void, close_backing_store, (j_common_ptr cinfo, + backing_store_ptr info)); + + /* Private fields for system-dependent backing-store management */ +#ifdef USE_MSDOS_MEMMGR + /* For the MS-DOS manager (jmemdos.c), we need: */ + handle_union handle; /* reference to backing-store storage object */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else +#ifdef USE_MAC_MEMMGR + /* For the Mac manager (jmemmac.c), we need: */ + short temp_file; /* file reference number to temp file */ + FSSpec tempSpec; /* the FSSpec for the temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ +#else + /* For a typical implementation with temp files, we need: */ + FILE * temp_file; /* stdio reference to temp file */ + char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ +#endif +#endif +} backing_store_info; + + +/* + * Initial opening of a backing-store object. This must fill in the + * read/write/close pointers in the object. The read/write routines + * may take an error exit if the specified maximum file size is exceeded. + * (If jpeg_mem_available always returns a large value, this routine can + * just take an error exit.) + */ + +EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, + backing_store_ptr info, + long total_bytes_needed)); + + +/* + * These routines take care of any system-dependent initialization and + * cleanup required. jpeg_mem_init will be called before anything is + * allocated (and, therefore, nothing in cinfo is of use except the error + * manager pointer). It should return a suitable default value for + * max_memory_to_use; this may subsequently be overridden by the surrounding + * application. (Note that max_memory_to_use is only important if + * jpeg_mem_available chooses to consult it ... no one else will.) + * jpeg_mem_term may assume that all requested memory has been freed and that + * all opened backing-store objects have been closed. + */ + +EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/libraries/external/jpeglib/jmorecfg.h b/libraries/external/jpeglib/jmorecfg.h new file mode 100755 index 0000000..2a9a345 --- /dev/null +++ b/libraries/external/jpeglib/jmorecfg.h @@ -0,0 +1,363 @@ +/* + * jmorecfg.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains additional configuration options that customize the + * JPEG software for special applications or support machine-dependent + * optimizations. Most users will not need to touch this file. + */ + + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 12 for 12-bit sample values + * Only 8 and 12 are legal data precisions for lossy JPEG according to the + * JPEG standard, and the IJG code does not support anything else! + * We do not support run-time selection of data precision, sorry. + */ + +#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ + + +/* + * Maximum number of components (color channels) allowed in JPEG image. + * To meet the letter of the JPEG spec, set this to 255. However, darn + * few applications need more than 4 channels (maybe 5 for CMYK + alpha + * mask). We recommend 10 as a reasonable compromise; use 4 if you are + * really short on memory. (Each allowed component costs a hundred or so + * bytes of storage, whether actually used in an image or not.) + */ + +#define MAX_COMPONENTS 10 /* maximum number of image components */ + + +/* + * Basic data types. + * You may need to change these if you have a machine with unusual data + * type sizes; for example, "char" not 8 bits, "short" not 16 bits, + * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, + * but it had better be at least 16. + */ + +/* Representation of a single sample (pixel element value). + * We frequently allocate large arrays of these, so it's important to keep + * them small. But if you have memory to burn and access to char or short + * arrays is very slow on your hardware, you might want to change these. + */ + +#if BITS_IN_JSAMPLE == 8 +/* JSAMPLE should be the smallest type that will hold the values 0..255. + * You can use a signed char by having GETJSAMPLE mask it with 0xFF. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JSAMPLE; +#ifdef CHAR_IS_UNSIGNED +#define GETJSAMPLE(value) ((int) (value)) +#else +#define GETJSAMPLE(value) ((int) (value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + +#define MAXJSAMPLE 255 +#define CENTERJSAMPLE 128 + +#endif /* BITS_IN_JSAMPLE == 8 */ + + +#if BITS_IN_JSAMPLE == 12 +/* JSAMPLE should be the smallest type that will hold the values 0..4095. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 4095 +#define CENTERJSAMPLE 2048 + +#endif /* BITS_IN_JSAMPLE == 12 */ + + +/* Representation of a DCT frequency coefficient. + * This should be a signed value of at least 16 bits; "short" is usually OK. + * Again, we allocate large arrays of these, but you can change to int + * if you have memory to burn and "short" is really slow. + */ + +typedef short JCOEF; + + +/* Compressed datastreams are represented as arrays of JOCTET. + * These must be EXACTLY 8 bits wide, at least once they are written to + * external storage. Note that when using the stdio data source/destination + * managers, this is also the data type passed to fread/fwrite. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JOCTET; +#define GETJOCTET(value) (value) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JOCTET; +#ifdef CHAR_IS_UNSIGNED +#define GETJOCTET(value) (value) +#else +#define GETJOCTET(value) ((value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + + +/* These typedefs are used for various table entries and so forth. + * They must be at least as wide as specified; but making them too big + * won't cost a huge amount of memory, so we don't provide special + * extraction code like we did for JSAMPLE. (In other words, these + * typedefs live at a different point on the speed/space tradeoff curve.) + */ + +/* UINT8 must hold at least the values 0..255. */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char UINT8; +#else /* not HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char UINT8; +#else /* not CHAR_IS_UNSIGNED */ +typedef short UINT8; +#endif /* CHAR_IS_UNSIGNED */ +#endif /* HAVE_UNSIGNED_CHAR */ + +/* UINT16 must hold at least the values 0..65535. */ + +#ifdef HAVE_UNSIGNED_SHORT +typedef unsigned short UINT16; +#else /* not HAVE_UNSIGNED_SHORT */ +typedef unsigned int UINT16; +#endif /* HAVE_UNSIGNED_SHORT */ + +/* INT16 must hold at least the values -32768..32767. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ +typedef short INT16; +#endif + +/* INT32 must hold at least signed 32-bit values. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +typedef int INT32; +#endif + +/* Datatype used for image dimensions. The JPEG standard only supports + * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + * "unsigned int" is sufficient on all machines. However, if you need to + * handle larger images and you don't mind deviating from the spec, you + * can change this datatype. + */ + +typedef unsigned int JDIMENSION; + +#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ + + +/* These macros are used in all function definitions and extern declarations. + * You could modify them if you need to change function linkage conventions; + * in particular, you'll need to do that to make the library a Windows DLL. + * Another application is to make all functions global for use with debuggers + * or code profilers that require it. + */ + +/* a function called through method pointers: */ +#define METHODDEF(type) static type +/* a function used only in its module: */ +#define LOCAL(type) static type +/* a function referenced thru EXTERNs: */ +#define GLOBAL(type) type +/* a reference to a GLOBAL function: */ +#define EXTERN(type) extern type + + +/* This macro is used to declare a "method", that is, a function pointer. + * We want to supply prototype parameters if the compiler can cope. + * Note that the arglist parameter must be parenthesized! + * Again, you can customize this if you need special linkage keywords. + */ + +#ifdef HAVE_PROTOTYPES +#define JMETHOD(type,methodname,arglist) type (*methodname) arglist +#else +#define JMETHOD(type,methodname,arglist) type (*methodname) () +#endif + + +/* Here is the pseudo-keyword for declaring pointers that must be "far" + * on 80x86 machines. Most of the specialized coding for 80x86 is handled + * by just saying "FAR *" where such a pointer is needed. In a few places + * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. + */ + +#ifdef NEED_FAR_POINTERS +#define FAR far +#else +#define FAR +#endif + + +/* + * On a few systems, type boolean and/or its values FALSE, TRUE may appear + * in standard header files. Or you may have conflicts with application- + * specific header files that you want to include together with these files. + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +#ifndef HAVE_BOOLEAN +typedef int boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif + + +/* + * The remaining options affect code selection within the JPEG library, + * but they don't need to be visible to most applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. + */ + +#ifdef JPEG_INTERNALS +#define JPEG_INTERNAL_OPTIONS +#endif + +#ifdef JPEG_INTERNAL_OPTIONS + + +/* + * These defines indicate whether to include various optional functions. + * Undefining some of these symbols will produce a smaller but less capable + * library. Note that you can leave certain source files out of the + * compilation/linking process if you've #undef'd the corresponding symbols. + * (You may HAVE to do that if your compiler doesn't like null source files.) + */ + +/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ + +/* Capability options common to encoder and decoder: */ + +#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ +#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ +#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ + +/* Encoder capability options: */ + +#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ +/* Note: if you selected 12-bit data precision, it is dangerous to turn off + * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit + * precision, so jchuff.c normally uses entropy optimization to compute + * usable tables for higher precision. If you don't want to do optimization, + * you'll have to supply different default Huffman tables. + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + +/* Decoder capability options: */ + +#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ +#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ +#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + +/* more capability options later, no doubt */ + + +/* + * Ordering of RGB data in scanlines passed to or from the application. + * If your application wants to deal with data in the order B,G,R, just + * change these macros. You can also deal with formats such as R,G,B,X + * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing + * the offsets will also change the order in which colormap data is organized. + * RESTRICTIONS: + * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. + * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not + * useful if you are using JPEG color spaces other than YCbCr or grayscale. + * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE + * is not 3 (they don't understand about dummy color components!). So you + * can't use color quantization if you change that value. + */ + +#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ +#define RGB_GREEN 1 /* Offset of Green */ +#define RGB_BLUE 2 /* Offset of Blue */ +#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ + + +/* Definitions for speed-related optimizations. */ + + +/* If your compiler supports inline functions, define INLINE + * as the inline keyword; otherwise define it as empty. + */ + +#ifndef INLINE +#ifdef __GNUC__ /* for instance, GNU C knows about inline */ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE /* default is to define it as empty */ +#endif +#endif + + +/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying + * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER + * as short on such a machine. MULTIPLIER must be at least 16 bits wide. + */ + +#ifndef MULTIPLIER +#define MULTIPLIER int /* type for fastest integer multiply */ +#endif + + +/* FAST_FLOAT should be either float or double, whichever is done faster + * by your compiler. (Note that this type is only used in the floating point + * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) + * Typically, float is faster in ANSI C compilers, while double is faster in + * pre-ANSI compilers (because they insist on converting to double anyway). + * The code below therefore chooses float if we have ANSI-style prototypes. + */ + +#ifndef FAST_FLOAT +#ifdef HAVE_PROTOTYPES +#define FAST_FLOAT float +#else +#define FAST_FLOAT double +#endif +#endif + +#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/libraries/external/jpeglib/jpegint.h b/libraries/external/jpeglib/jpegint.h new file mode 100755 index 0000000..685a361 --- /dev/null +++ b/libraries/external/jpeglib/jpegint.h @@ -0,0 +1,392 @@ +/* + * jpegint.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file provides common declarations for the various JPEG modules. + * These declarations are considered internal to the JPEG library; most + * applications using the library shouldn't need to include this file. + */ + + +/* Declarations for both compression & decompression */ + +typedef enum { /* Operating modes for buffer controllers */ + JBUF_PASS_THRU, /* Plain stripwise operation */ + /* Remaining modes require a full-image buffer to have been created */ + JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ + JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ + JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ +} J_BUF_MODE; + +/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ +#define CSTATE_START 100 /* after create_compress */ +#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ +#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ +#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ +#define DSTATE_START 200 /* after create_decompress */ +#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ +#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ +#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ +#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ +#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ +#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ +#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ +#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ +#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ +#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ + + +/* Declarations for compression modules */ + +/* Master control module */ +struct jpeg_comp_master { + JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); + JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean call_pass_startup; /* True if pass_startup must be called */ + boolean is_last_pass; /* True during last pass */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_c_main_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail)); +}; + +/* Compression preprocessing (downsampling input buffer control) */ +struct jpeg_c_prep_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, + JDIMENSION *in_row_ctr, + JDIMENSION in_rows_avail, + JSAMPIMAGE output_buf, + JDIMENSION *out_row_group_ctr, + JDIMENSION out_row_groups_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_c_coef_controller { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf)); +}; + +/* Colorspace conversion */ +struct jpeg_color_converter { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, color_convert, (j_compress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, + JDIMENSION output_row, int num_rows)); +}; + +/* Downsampling */ +struct jpeg_downsampler { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + JMETHOD(void, downsample, (j_compress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION in_row_index, + JSAMPIMAGE output_buf, + JDIMENSION out_row_group_index)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Forward DCT (also controls coefficient quantization) */ +struct jpeg_forward_dct { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); + /* perhaps this should be an array??? */ + JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, + jpeg_component_info * compptr, + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, + JDIMENSION start_row, JDIMENSION start_col, + JDIMENSION num_blocks)); +}; + +/* Entropy encoding */ +struct jpeg_entropy_encoder { + JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); + JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); +}; + +/* Marker writing */ +struct jpeg_marker_writer { + JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); + JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); + JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); + /* These routines are exported to allow insertion of extra markers */ + /* Probably only COM and APPn markers should be written this way */ + JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, + unsigned int datalen)); + JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); +}; + + +/* Declarations for decompression modules */ + +/* Master control module */ +struct jpeg_decomp_master { + JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ +}; + +/* Input control module */ +struct jpeg_input_controller { + JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); + JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); + + /* State variables made visible to other modules */ + boolean has_multiple_scans; /* True if file has multiple scans */ + boolean eoi_reached; /* True when EOI has been consumed */ +}; + +/* Main buffer control (downsampled-data buffer) */ +struct jpeg_d_main_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, process_data, (j_decompress_ptr cinfo, + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Coefficient buffer control */ +struct jpeg_d_coef_controller { + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); + JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); + JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, + JSAMPIMAGE output_buf)); + /* Pointer to array of coefficient virtual arrays, or NULL if none */ + jvirt_barray_ptr *coef_arrays; +}; + +/* Decompression postprocessing (color quantization buffer control) */ +struct jpeg_d_post_controller { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); + JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); +}; + +/* Marker reading & parsing */ +struct jpeg_marker_reader { + JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); + /* Read markers until SOS or EOI. + * Returns same codes as are defined for jpeg_consume_input: + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. + */ + JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); + /* Read a restart marker --- exported for use by entropy decoder only */ + jpeg_marker_parser_method read_restart_marker; + + /* State of marker reader --- nominally internal, but applications + * supplying COM or APPn handlers might like to know the state. + */ + boolean saw_SOI; /* found SOI? */ + boolean saw_SOF; /* found SOF? */ + int next_restart_num; /* next restart number expected (0-7) */ + unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ +}; + +/* Entropy decoding */ +struct jpeg_entropy_decoder { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); + + /* This is here to share code between baseline and progressive decoders; */ + /* other modules probably should not use it */ + boolean insufficient_data; /* set TRUE after emitting warning */ +}; + +/* Inverse DCT (also performs dequantization) */ +typedef JMETHOD(void, inverse_DCT_method_ptr, + (j_decompress_ptr cinfo, jpeg_component_info * compptr, + JCOEFPTR coef_block, + JSAMPARRAY output_buf, JDIMENSION output_col)); + +struct jpeg_inverse_dct { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + /* It is useful to allow each component to have a separate IDCT method. */ + inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; +}; + +/* Upsampling (note that upsampler must also call color converter) */ +struct jpeg_upsampler { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, upsample, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, + JDIMENSION *in_row_group_ctr, + JDIMENSION in_row_groups_avail, + JSAMPARRAY output_buf, + JDIMENSION *out_row_ctr, + JDIMENSION out_rows_avail)); + + boolean need_context_rows; /* TRUE if need rows above & below */ +}; + +/* Colorspace conversion */ +struct jpeg_color_deconverter { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, color_convert, (j_decompress_ptr cinfo, + JSAMPIMAGE input_buf, JDIMENSION input_row, + JSAMPARRAY output_buf, int num_rows)); +}; + +/* Color quantization or color precision reduction */ +struct jpeg_color_quantizer { + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); + JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, + int num_rows)); + JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); + JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); +}; + + +/* Miscellaneous useful macros */ + +#undef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#undef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + + +/* We assume that right shift corresponds to signed division by 2 with + * rounding towards minus infinity. This is correct for typical "arithmetic + * shift" instructions that shift in copies of the sign bit. But some + * C compilers implement >> with an unsigned shift. For these machines you + * must define RIGHT_SHIFT_IS_UNSIGNED. + * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. + * It is only applied with constant shift counts. SHIFT_TEMPS must be + * included in the variables of any routine using RIGHT_SHIFT. + */ + +#ifdef RIGHT_SHIFT_IS_UNSIGNED +#define SHIFT_TEMPS INT32 shift_temp; +#define RIGHT_SHIFT(x,shft) \ + ((shift_temp = (x)) < 0 ? \ + (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ + (shift_temp >> (shft))) +#else +#define SHIFT_TEMPS +#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jinit_compress_master jICompress +#define jinit_c_master_control jICMaster +#define jinit_c_main_controller jICMainC +#define jinit_c_prep_controller jICPrepC +#define jinit_c_coef_controller jICCoefC +#define jinit_color_converter jICColor +#define jinit_downsampler jIDownsampler +#define jinit_forward_dct jIFDCT +#define jinit_huff_encoder jIHEncoder +#define jinit_phuff_encoder jIPHEncoder +#define jinit_marker_writer jIMWriter +#define jinit_master_decompress jIDMaster +#define jinit_d_main_controller jIDMainC +#define jinit_d_coef_controller jIDCoefC +#define jinit_d_post_controller jIDPostC +#define jinit_input_controller jIInCtlr +#define jinit_marker_reader jIMReader +#define jinit_huff_decoder jIHDecoder +#define jinit_phuff_decoder jIPHDecoder +#define jinit_inverse_dct jIIDCT +#define jinit_upsampler jIUpsampler +#define jinit_color_deconverter jIDColor +#define jinit_1pass_quantizer jI1Quant +#define jinit_2pass_quantizer jI2Quant +#define jinit_merged_upsampler jIMUpsampler +#define jinit_memory_mgr jIMemMgr +#define jdiv_round_up jDivRound +#define jround_up jRound +#define jcopy_sample_rows jCopySamples +#define jcopy_block_row jCopyBlocks +#define jzero_far jZeroFar +#define jpeg_zigzag_order jZIGTable +#define jpeg_natural_order jZAGTable +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Compression module initialization routines */ +EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, + boolean transcode_only)); +EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); +EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); +/* Decompression module initialization routines */ +EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, + boolean need_full_buffer)); +EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); +EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); +/* Memory manager initialization */ +EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); + +/* Utility routines in jutils.c */ +EXTERN(long) jdiv_round_up JPP((long a, long b)); +EXTERN(long) jround_up JPP((long a, long b)); +EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, + JSAMPARRAY output_array, int dest_row, + int num_rows, JDIMENSION num_cols)); +EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks)); +EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); +/* Constant tables in jutils.c */ +#if 0 /* This table is not actually needed in v6a */ +extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ +#endif +extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ + +/* Suppress undefined-structure complaints if necessary. */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +#endif +#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/libraries/external/jpeglib/jpeglib.a b/libraries/external/jpeglib/jpeglib.a new file mode 100644 index 0000000..cbf7b7a Binary files /dev/null and b/libraries/external/jpeglib/jpeglib.a differ diff --git a/libraries/external/jpeglib/jpeglib.dsp b/libraries/external/jpeglib/jpeglib.dsp new file mode 100755 index 0000000..f4a2b97 --- /dev/null +++ b/libraries/external/jpeglib/jpeglib.dsp @@ -0,0 +1,281 @@ +# Microsoft Developer Studio Project File - Name="jpeglib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=jpeglib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "jpeglib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "jpeglib.mak" CFG="jpeglib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "jpeglib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "jpeglib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/jpeglib", TKJAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "jpeglib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "jpeglib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copying libs & hdrs to lib directory +PostBuild_Cmds=copy Debug\jpeglib.lib c:\g3\lib copy jpeglib.h c:\g3\include copy jconfig.h c:\g3\include copy jmorecfg.h c:\g3\include +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "jpeglib - Win32 Release" +# Name "jpeglib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\jcapimin.c +# End Source File +# Begin Source File + +SOURCE=.\jcapistd.c +# End Source File +# Begin Source File + +SOURCE=.\jccoefct.c +# End Source File +# Begin Source File + +SOURCE=.\jccolor.c +# End Source File +# Begin Source File + +SOURCE=.\jcdctmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jchuff.c +# End Source File +# Begin Source File + +SOURCE=.\jcinit.c +# End Source File +# Begin Source File + +SOURCE=.\jcmainct.c +# End Source File +# Begin Source File + +SOURCE=.\jcmarker.c +# End Source File +# Begin Source File + +SOURCE=.\jcmaster.c +# End Source File +# Begin Source File + +SOURCE=.\jcomapi.c +# End Source File +# Begin Source File + +SOURCE=.\jcparam.c +# End Source File +# Begin Source File + +SOURCE=.\jcphuff.c +# End Source File +# Begin Source File + +SOURCE=.\jcprepct.c +# End Source File +# Begin Source File + +SOURCE=.\jcsample.c +# End Source File +# Begin Source File + +SOURCE=.\jctrans.c +# End Source File +# Begin Source File + +SOURCE=.\jdapimin.c +# End Source File +# Begin Source File + +SOURCE=.\jdapistd.c +# End Source File +# Begin Source File + +SOURCE=.\jdatadst.c +# End Source File +# Begin Source File + +SOURCE=.\jdatasrc.c +# End Source File +# Begin Source File + +SOURCE=.\jdcoefct.c +# End Source File +# Begin Source File + +SOURCE=.\jdcolor.c +# End Source File +# Begin Source File + +SOURCE=.\jddctmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jdhuff.c +# End Source File +# Begin Source File + +SOURCE=.\jdinput.c +# End Source File +# Begin Source File + +SOURCE=.\jdmainct.c +# End Source File +# Begin Source File + +SOURCE=.\jdmarker.c +# End Source File +# Begin Source File + +SOURCE=.\jdmaster.c +# End Source File +# Begin Source File + +SOURCE=.\jdmerge.c +# End Source File +# Begin Source File + +SOURCE=.\jdphuff.c +# End Source File +# Begin Source File + +SOURCE=.\jdpostct.c +# End Source File +# Begin Source File + +SOURCE=.\jdsample.c +# End Source File +# Begin Source File + +SOURCE=.\jdtrans.c +# End Source File +# Begin Source File + +SOURCE=.\jerror.c +# End Source File +# Begin Source File + +SOURCE=.\jfdctflt.c +# End Source File +# Begin Source File + +SOURCE=.\jfdctfst.c +# End Source File +# Begin Source File + +SOURCE=.\jfdctint.c +# End Source File +# Begin Source File + +SOURCE=.\jidctflt.c +# End Source File +# Begin Source File + +SOURCE=.\jidctfst.c +# End Source File +# Begin Source File + +SOURCE=.\jidctint.c +# End Source File +# Begin Source File + +SOURCE=.\jidctred.c +# End Source File +# Begin Source File + +SOURCE=.\jmemansi.c +# End Source File +# Begin Source File + +SOURCE=.\jmemmgr.c +# End Source File +# Begin Source File + +SOURCE=.\jquant1.c +# End Source File +# Begin Source File + +SOURCE=.\jquant2.c +# End Source File +# Begin Source File + +SOURCE=.\jutils.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# End Target +# End Project diff --git a/libraries/external/jpeglib/jpeglib.dsw b/libraries/external/jpeglib/jpeglib.dsw new file mode 100755 index 0000000..4adeb52 --- /dev/null +++ b/libraries/external/jpeglib/jpeglib.dsw @@ -0,0 +1,37 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "jpeglib"=.\jpeglib.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/jpeglib", TKJAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/jpeglib", TKJAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/external/jpeglib/jpeglib.h b/libraries/external/jpeglib/jpeglib.h new file mode 100755 index 0000000..04cd066 --- /dev/null +++ b/libraries/external/jpeglib/jpeglib.h @@ -0,0 +1,1098 @@ +/* + * jpeglib.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the application interface for the JPEG library. + * Most applications using the library need only include this file, + * and perhaps jerror.h if they want to know the exact error codes. + */ + +#ifndef JPEGLIB_H +#define JPEGLIB_H + +/* + * First we include the configuration files that record how this + * installation of the JPEG library is set up. jconfig.h can be + * generated automatically for many systems. jmorecfg.h contains + * manual configuration options that most people need not worry about. + */ + +#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ +#include "jconfig.h" /* widely used configuration options */ +#endif +#include "jmorecfg.h" /* seldom changed options */ + + +/* Version ID for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". + */ + +#define JPEG_LIB_VERSION 62 /* Version 6b */ + + +/* Various constants determining the sizes of things. + * All of these are specified by the JPEG standard, so don't change them + * if you want to be compatible. + */ + +#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ +#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ +#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ +#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ +#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ +#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ +#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ +/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; + * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. + * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU + * to handle it. We even let you do this from the jconfig.h file. However, + * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe + * sometimes emits noncompliant files doesn't mean you should too. + */ +#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ +#ifndef D_MAX_BLOCKS_IN_MCU +#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ +#endif + + +/* Data structures for images (arrays of samples and of DCT coefficients). + * On 80x86 machines, the image arrays are too big for near pointers, + * but the pointer arrays can fit in near memory. + */ + +typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ +typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ + +typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ +typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ +typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ + +typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ + + +/* Types for JPEG compression parameters and working tables. */ + + +/* DCT coefficient quantization tables. */ + +typedef struct { + /* This array gives the coefficient quantizers in natural array order + * (not the zigzag order in which they are stored in a JPEG DQT marker). + * CAUTION: IJG versions prior to v6a kept this array in zigzag order. + */ + UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JQUANT_TBL; + + +/* Huffman coding tables. */ + +typedef struct { + /* These two fields directly represent the contents of a JPEG DHT marker */ + UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ + /* length k bits; bits[0] is unused */ + UINT8 huffval[256]; /* The symbols, in order of incr code length */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JHUFF_TBL; + + +/* Basic info about one component (color channel). */ + +typedef struct { + /* These values are fixed over the whole image. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOF marker. */ + int component_id; /* identifier for this component (0..255) */ + int component_index; /* its index in SOF or cinfo->comp_info[] */ + int h_samp_factor; /* horizontal sampling factor (1..4) */ + int v_samp_factor; /* vertical sampling factor (1..4) */ + int quant_tbl_no; /* quantization table selector (0..3) */ + /* These values may vary between scans. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOS marker. */ + /* The decompressor output side may not use these variables. */ + int dc_tbl_no; /* DC entropy table selector (0..3) */ + int ac_tbl_no; /* AC entropy table selector (0..3) */ + + /* Remaining fields should be treated as private by applications. */ + + /* These values are computed during compression or decompression startup: */ + /* Component's size in DCT blocks. + * Any dummy blocks added to complete an MCU are not counted; therefore + * these values do not depend on whether a scan is interleaved or not. + */ + JDIMENSION width_in_blocks; + JDIMENSION height_in_blocks; + /* Size of a DCT block in samples. Always DCTSIZE for compression. + * For decompression this is the size of the output from one DCT block, + * reflecting any scaling we choose to apply during the IDCT step. + * Values of 1,2,4,8 are likely to be supported. Note that different + * components may receive different IDCT scalings. + */ + int DCT_scaled_size; + /* The downsampled dimensions are the component's actual, unpadded number + * of samples at the main buffer (preprocessing/compression interface), thus + * downsampled_width = ceil(image_width * Hi/Hmax) + * and similarly for height. For decompression, IDCT scaling is included, so + * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) + */ + JDIMENSION downsampled_width; /* actual width in samples */ + JDIMENSION downsampled_height; /* actual height in samples */ + /* This flag is used only for decompression. In cases where some of the + * components will be ignored (eg grayscale output from YCbCr image), + * we can skip most computations for the unused components. + */ + boolean component_needed; /* do we need the value of this component? */ + + /* These values are computed before starting a scan of the component. */ + /* The decompressor output side may not use these variables. */ + int MCU_width; /* number of blocks per MCU, horizontally */ + int MCU_height; /* number of blocks per MCU, vertically */ + int MCU_blocks; /* MCU_width * MCU_height */ + int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ + int last_col_width; /* # of non-dummy blocks across in last MCU */ + int last_row_height; /* # of non-dummy blocks down in last MCU */ + + /* Saved quantization table for component; NULL if none yet saved. + * See jdinput.c comments about the need for this information. + * This field is currently used only for decompression. + */ + JQUANT_TBL * quant_table; + + /* Private per-component storage for DCT or IDCT subsystem. */ + void * dct_table; +} jpeg_component_info; + + +/* The script for encoding a multiple-scan file is an array of these: */ + +typedef struct { + int comps_in_scan; /* number of components encoded in this scan */ + int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ + int Ss, Se; /* progressive JPEG spectral selection parms */ + int Ah, Al; /* progressive JPEG successive approx. parms */ +} jpeg_scan_info; + +/* The decompressor can save APPn and COM markers in a list of these: */ + +typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; + +struct jpeg_marker_struct { + jpeg_saved_marker_ptr next; /* next in list, or NULL */ + UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ + unsigned int original_length; /* # bytes of data in the file */ + unsigned int data_length; /* # bytes of data saved at data[] */ + JOCTET FAR * data; /* the data contained in the marker */ + /* the marker length word is not counted in data_length or original_length */ +}; + +/* Known color spaces. */ + +typedef enum { + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK /* Y/Cb/Cr/K */ +} J_COLOR_SPACE; + +/* DCT/IDCT algorithm options. */ + +typedef enum { + JDCT_ISLOW, /* slow but accurate integer algorithm */ + JDCT_IFAST, /* faster, less accurate integer method */ + JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ +} J_DCT_METHOD; + +#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ +#define JDCT_DEFAULT JDCT_ISLOW +#endif +#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ +#define JDCT_FASTEST JDCT_IFAST +#endif + +/* Dithering options for decompression. */ + +typedef enum { + JDITHER_NONE, /* no dithering */ + JDITHER_ORDERED, /* simple ordered dither */ + JDITHER_FS /* Floyd-Steinberg error diffusion dither */ +} J_DITHER_MODE; + + +/* Common fields between JPEG compression and decompression master structs. */ + +#define jpeg_common_fields \ + struct jpeg_error_mgr * err; /* Error handler module */\ + struct jpeg_memory_mgr * mem; /* Memory manager module */\ + struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ + void * client_data; /* Available for use by application */\ + boolean is_decompressor; /* So common code can tell which is which */\ + int global_state /* For checking call sequence validity */ + +/* Routines that are to be used by both halves of the library are declared + * to receive a pointer to this structure. There are no actual instances of + * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. + */ +struct jpeg_common_struct { + jpeg_common_fields; /* Fields common to both master struct types */ + /* Additional fields follow in an actual jpeg_compress_struct or + * jpeg_decompress_struct. All three structs must agree on these + * initial fields! (This would be a lot cleaner in C++.) + */ +}; + +typedef struct jpeg_common_struct * j_common_ptr; +typedef struct jpeg_compress_struct * j_compress_ptr; +typedef struct jpeg_decompress_struct * j_decompress_ptr; + + +/* Master record for a compression instance */ + +struct jpeg_compress_struct { + jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ + + /* Destination for compressed data */ + struct jpeg_destination_mgr * dest; + + /* Description of source image --- these fields must be filled in by + * outer application before starting compression. in_color_space must + * be correct before you can even call jpeg_set_defaults(). + */ + + JDIMENSION image_width; /* input image width */ + JDIMENSION image_height; /* input image height */ + int input_components; /* # of color components in input image */ + J_COLOR_SPACE in_color_space; /* colorspace of input image */ + + double input_gamma; /* image gamma of input image */ + + /* Compression parameters --- these fields must be set before calling + * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to + * initialize everything to reasonable defaults, then changing anything + * the application specifically wants to change. That way you won't get + * burnt when new parameters are added. Also note that there are several + * helper routines to simplify changing parameters. + */ + + int data_precision; /* bits of precision in image data */ + + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + int num_scans; /* # of entries in scan_info array */ + const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ + /* The default value of scan_info is NULL, which causes a single-scan + * sequential JPEG file to be emitted. To create a multi-scan file, + * set num_scans and scan_info to point to an array of scan definitions. + */ + + boolean raw_data_in; /* TRUE=caller supplies downsampled data */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + int smoothing_factor; /* 1..100, or 0 for no input smoothing */ + J_DCT_METHOD dct_method; /* DCT algorithm selector */ + + /* The restart interval can be specified in absolute MCUs by setting + * restart_interval, or in MCU rows by setting restart_in_rows + * (in which case the correct restart_interval will be figured + * for each scan). + */ + unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ + int restart_in_rows; /* if > 0, MCU rows per restart interval */ + + /* Parameters controlling emission of special markers. */ + + boolean write_JFIF_header; /* should a JFIF marker be written? */ + UINT8 JFIF_major_version; /* What to write for the JFIF version number */ + UINT8 JFIF_minor_version; + /* These three values are not used by the JPEG code, merely copied */ + /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ + /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ + /* ratio is defined by X_density/Y_density even when density_unit=0. */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean write_Adobe_marker; /* should an Adobe marker be written? */ + + /* State variable: index of next scanline to be written to + * jpeg_write_scanlines(). Application may use this to control its + * processing loop, e.g., "while (next_scanline < image_height)". + */ + + JDIMENSION next_scanline; /* 0 .. image_height-1 */ + + /* Remaining fields are known throughout compressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during compression startup + */ + boolean progressive_mode; /* TRUE if scan script uses progressive mode */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ + /* The coefficient controller receives data in units of MCU rows as defined + * for fully interleaved scans (whether the JPEG file is interleaved or not). + * There are v_samp_factor * DCTSIZE sample rows of each component in an + * "iMCU" (interleaved MCU) row. + */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[C_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* + * Links to compression subobjects (methods and private variables of modules) + */ + struct jpeg_comp_master * master; + struct jpeg_c_main_controller * main; + struct jpeg_c_prep_controller * prep; + struct jpeg_c_coef_controller * coef; + struct jpeg_marker_writer * marker; + struct jpeg_color_converter * cconvert; + struct jpeg_downsampler * downsample; + struct jpeg_forward_dct * fdct; + struct jpeg_entropy_encoder * entropy; + jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ + int script_space_size; +}; + + +/* Master record for a decompression instance */ + +struct jpeg_decompress_struct { + jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ + + /* Source of compressed data */ + struct jpeg_source_mgr * src; + + /* Basic description of image --- filled in by jpeg_read_header(). */ + /* Application may inspect these values to decide how to process image. */ + + JDIMENSION image_width; /* nominal image width (from SOF marker) */ + JDIMENSION image_height; /* nominal image height */ + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + /* Decompression processing parameters --- these fields must be set before + * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes + * them to default values. + */ + + J_COLOR_SPACE out_color_space; /* colorspace for output */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + double output_gamma; /* image gamma wanted in output */ + + boolean buffered_image; /* TRUE=multiple output passes */ + boolean raw_data_out; /* TRUE=downsampled data wanted */ + + J_DCT_METHOD dct_method; /* IDCT algorithm selector */ + boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ + boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ + + boolean quantize_colors; /* TRUE=colormapped output wanted */ + /* the following are ignored if not quantize_colors: */ + J_DITHER_MODE dither_mode; /* type of color dithering to use */ + boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ + int desired_number_of_colors; /* max # colors to use in created colormap */ + /* these are significant only in buffered-image mode: */ + boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ + boolean enable_external_quant;/* enable future use of external colormap */ + boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ + + /* Description of actual output image that will be returned to application. + * These fields are computed by jpeg_start_decompress(). + * You can also use jpeg_calc_output_dimensions() to determine these values + * in advance of calling jpeg_start_decompress(). + */ + + JDIMENSION output_width; /* scaled image width */ + JDIMENSION output_height; /* scaled image height */ + int out_color_components; /* # of color components in out_color_space */ + int output_components; /* # of color components returned */ + /* output_components is 1 (a colormap index) when quantizing colors; + * otherwise it equals out_color_components. + */ + int rec_outbuf_height; /* min recommended height of scanline buffer */ + /* If the buffer passed to jpeg_read_scanlines() is less than this many rows + * high, space and time will be wasted due to unnecessary data copying. + * Usually rec_outbuf_height will be 1 or 2, at most 4. + */ + + /* When quantizing colors, the output colormap is described by these fields. + * The application can supply a colormap by setting colormap non-NULL before + * calling jpeg_start_decompress; otherwise a colormap is created during + * jpeg_start_decompress or jpeg_start_output. + * The map has out_color_components rows and actual_number_of_colors columns. + */ + int actual_number_of_colors; /* number of entries in use */ + JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ + + /* State variables: these variables indicate the progress of decompression. + * The application may examine these but must not modify them. + */ + + /* Row index of next scanline to be read from jpeg_read_scanlines(). + * Application may use this to control its processing loop, e.g., + * "while (output_scanline < output_height)". + */ + JDIMENSION output_scanline; /* 0 .. output_height-1 */ + + /* Current input scan number and number of iMCU rows completed in scan. + * These indicate the progress of the decompressor input side. + */ + int input_scan_number; /* Number of SOS markers seen so far */ + JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ + + /* The "output scan number" is the notional scan being displayed by the + * output side. The decompressor will not allow output scan/row number + * to get ahead of input scan/row, but it can fall arbitrarily far behind. + */ + int output_scan_number; /* Nominal scan number being displayed */ + JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ + + /* Current progression status. coef_bits[c][i] indicates the precision + * with which component c's DCT coefficient i (in zigzag order) is known. + * It is -1 when no data has yet been received, otherwise it is the point + * transform (shift) value for the most recent scan of the coefficient + * (thus, 0 at completion of the progression). + * This pointer is NULL when reading a non-progressive file. + */ + int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ + + /* Internal JPEG parameters --- the application usually need not look at + * these fields. Note that the decompressor output side may not use + * any parameters that can change between scans. + */ + + /* Quantization and Huffman tables are carried forward across input + * datastreams when processing abbreviated JPEG datastreams. + */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + /* These parameters are never carried across datastreams, since they + * are given in SOF/SOS markers or defined to be reset by SOI. + */ + + int data_precision; /* bits of precision in image data */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ + + /* These fields record data obtained from optional markers recognized by + * the JPEG library. + */ + boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ + /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ + UINT8 JFIF_major_version; /* JFIF version number */ + UINT8 JFIF_minor_version; + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ + UINT8 Adobe_transform; /* Color transform code from Adobe marker */ + + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + + /* Aside from the specific data retained from APPn markers known to the + * library, the uninterpreted contents of any or all APPn and COM markers + * can be saved in a list for examination by the application. + */ + jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ + + /* Remaining fields are known throughout decompressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during decompression startup + */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ + /* The coefficient controller's input and output progress is measured in + * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows + * in fully interleaved JPEG scans, but are used whether the scan is + * interleaved or not. We define an iMCU row as v_samp_factor DCT block + * rows of each component. Therefore, the IDCT output contains + * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. + */ + + JSAMPLE * sample_range_limit; /* table for fast range-limiting */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + * Note that the decompressor output side must not use these fields. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[D_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* This field is shared between entropy decoder and marker parser. + * It is either zero or the code of a JPEG marker that has been + * read from the data source, but has not yet been processed. + */ + int unread_marker; + + /* + * Links to decompression subobjects (methods, private variables of modules) + */ + struct jpeg_decomp_master * master; + struct jpeg_d_main_controller * main; + struct jpeg_d_coef_controller * coef; + struct jpeg_d_post_controller * post; + struct jpeg_input_controller * inputctl; + struct jpeg_marker_reader * marker; + struct jpeg_entropy_decoder * entropy; + struct jpeg_inverse_dct * idct; + struct jpeg_upsampler * upsample; + struct jpeg_color_deconverter * cconvert; + struct jpeg_color_quantizer * cquantize; +}; + + +/* "Object" declarations for JPEG modules that may be supplied or called + * directly by the surrounding application. + * As with all objects in the JPEG library, these structs only define the + * publicly visible methods and state variables of a module. Additional + * private fields may exist after the public ones. + */ + + +/* Error handler object */ + +struct jpeg_error_mgr { + /* Error exit handler: does not return to caller */ + JMETHOD(void, error_exit, (j_common_ptr cinfo)); + /* Conditionally emit a trace or warning message */ + JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); + /* Routine that actually outputs a trace or error message */ + JMETHOD(void, output_message, (j_common_ptr cinfo)); + /* Format a message string for the most recent JPEG error or message */ + JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); +#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ + /* Reset error state variables at start of a new image */ + JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); + + /* The message ID code and any parameters are saved here. + * A message can have one string parameter or up to 8 int parameters. + */ + int msg_code; +#define JMSG_STR_PARM_MAX 80 + union { + int i[8]; + char s[JMSG_STR_PARM_MAX]; + } msg_parm; + + /* Standard state variables for error facility */ + + int trace_level; /* max msg_level that will be displayed */ + + /* For recoverable corrupt-data errors, we emit a warning message, + * but keep going unless emit_message chooses to abort. emit_message + * should count warnings in num_warnings. The surrounding application + * can check for bad data by seeing if num_warnings is nonzero at the + * end of processing. + */ + long num_warnings; /* number of corrupt-data warnings */ + + /* These fields point to the table(s) of error message strings. + * An application can change the table pointer to switch to a different + * message list (typically, to change the language in which errors are + * reported). Some applications may wish to add additional error codes + * that will be handled by the JPEG library error mechanism; the second + * table pointer is used for this purpose. + * + * First table includes all errors generated by JPEG library itself. + * Error code 0 is reserved for a "no such error string" message. + */ + const char * const * jpeg_message_table; /* Library errors */ + int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ + /* Second table can be added by application (see cjpeg/djpeg for example). + * It contains strings numbered first_addon_message..last_addon_message. + */ + const char * const * addon_message_table; /* Non-library errors */ + int first_addon_message; /* code for first string in addon table */ + int last_addon_message; /* code for last string in addon table */ +}; + + +/* Progress monitor object */ + +struct jpeg_progress_mgr { + JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); + + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +}; + + +/* Data destination object for compression */ + +struct jpeg_destination_mgr { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + + JMETHOD(void, init_destination, (j_compress_ptr cinfo)); + JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); + JMETHOD(void, term_destination, (j_compress_ptr cinfo)); +}; + + +/* Data source object for decompression */ + +struct jpeg_source_mgr { + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + + JMETHOD(void, init_source, (j_decompress_ptr cinfo)); + JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); + JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); + JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); + JMETHOD(void, term_source, (j_decompress_ptr cinfo)); +}; + + +/* Memory manager object. + * Allocates "small" objects (a few K total), "large" objects (tens of K), + * and "really big" objects (virtual arrays with backing store if needed). + * The memory manager does not allow individual objects to be freed; rather, + * each created object is assigned to a pool, and whole pools can be freed + * at once. This is faster and more convenient than remembering exactly what + * to free, especially where malloc()/free() are not too speedy. + * NB: alloc routines never return NULL. They exit to error_exit if not + * successful. + */ + +#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ +#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ +#define JPOOL_NUMPOOLS 2 + +typedef struct jvirt_sarray_control * jvirt_sarray_ptr; +typedef struct jvirt_barray_control * jvirt_barray_ptr; + + +struct jpeg_memory_mgr { + /* Method pointers */ + JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, + JDIMENSION numrows)); + JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, + JDIMENSION numrows)); + JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION samplesperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION blocksperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); + JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, + jvirt_sarray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, + jvirt_barray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); + JMETHOD(void, self_destruct, (j_common_ptr cinfo)); + + /* Limit on memory allocation for this JPEG object. (Note that this is + * merely advisory, not a guaranteed maximum; it only affects the space + * used for virtual-array buffers.) May be changed by outer application + * after creating the JPEG object. + */ + long max_memory_to_use; + + /* Maximum allocation request accepted by alloc_large. */ + long max_alloc_chunk; +}; + + +/* Routine signature for application-supplied marker processing methods. + * Need not pass marker code since it is stored in cinfo->unread_marker. + */ +typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); + + +/* Declarations for routines called by application. + * The JPP macro hides prototype parameters from compilers that can't cope. + * Note JPP requires double parentheses. + */ + +#ifdef HAVE_PROTOTYPES +#define JPP(arglist) arglist +#else +#define JPP(arglist) () +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. + * We shorten external names to be unique in the first six letters, which + * is good enough for all known systems. + * (If your compiler itself needs names to be unique in less than 15 + * characters, you are out of luck. Get a better compiler.) + */ + +#if 0 +//#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_error jStdError +#define jpeg_CreateCompress jCreaCompress +#define jpeg_CreateDecompress jCreaDecompress +#define jpeg_destroy_compress jDestCompress +#define jpeg_destroy_decompress jDestDecompress +#define jpeg_stdio_dest jStdDest +#define jpeg_stdio_src jStdSrc +#define jpeg_set_defaults jSetDefaults +#define jpeg_set_colorspace jSetColorspace +#define jpeg_default_colorspace jDefColorspace +#define jpeg_set_quality jSetQuality +#define jpeg_set_linear_quality jSetLQuality +#define jpeg_add_quant_table jAddQuantTable +#define jpeg_quality_scaling jQualityScaling +#define jpeg_simple_progression jSimProgress +#define jpeg_suppress_tables jSuppressTables +#define jpeg_alloc_quant_table jAlcQTable +#define jpeg_alloc_huff_table jAlcHTable +#define jpeg_start_compress jStrtCompress +#define jpeg_write_scanlines jWrtScanlines +#define jpeg_finish_compress jFinCompress +#define jpeg_write_raw_data jWrtRawData +#define jpeg_write_marker jWrtMarker +#define jpeg_write_m_header jWrtMHeader +#define jpeg_write_m_byte jWrtMByte +#define jpeg_write_tables jWrtTables +#define jpeg_read_header jReadHeader +#define jpeg_start_decompress jStrtDecompress +#define jpeg_read_scanlines jReadScanlines +#define jpeg_finish_decompress jFinDecompress +#define jpeg_read_raw_data jReadRawData +#define jpeg_has_multiple_scans jHasMultScn +#define jpeg_start_output jStrtOutput +#define jpeg_finish_output jFinOutput +#define jpeg_input_complete jInComplete +#define jpeg_new_colormap jNewCMap +#define jpeg_consume_input jConsumeInput +#define jpeg_calc_output_dimensions jCalcDimensions +#define jpeg_save_markers jSaveMarkers +#define jpeg_set_marker_processor jSetMarker +#define jpeg_read_coefficients jReadCoefs +#define jpeg_write_coefficients jWrtCoefs +#define jpeg_copy_critical_parameters jCopyCrit +#define jpeg_abort_compress jAbrtCompress +#define jpeg_abort_decompress jAbrtDecompress +#define jpeg_abort jAbort +#define jpeg_destroy jDestroy +#define jpeg_resync_to_restart jResyncRestart +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Default error-management setup */ +EXTERN(struct jpeg_error_mgr *) jpeg_std_error + JPP((struct jpeg_error_mgr * err)); + +/* Initialization of JPEG compression objects. + * jpeg_create_compress() and jpeg_create_decompress() are the exported + * names that applications should call. These expand to calls on + * jpeg_CreateCompress and jpeg_CreateDecompress with additional information + * passed for version mismatch checking. + * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. + */ +#define jpeg_create_compress(cinfo) \ + jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_compress_struct)) +#define jpeg_create_decompress(cinfo) \ + jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_decompress_struct)) +EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, + int version, size_t structsize)); +EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, + int version, size_t structsize)); +/* Destruction of JPEG compression objects */ +EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); + +EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); + +/* Standard data source and destination managers: stdio streams. */ +/* Caller is responsible for opening the file before and closing after. */ +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* Default parameter setup for compression */ +EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); +/* Compression parameter setup aids */ +EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, + J_COLOR_SPACE colorspace)); +EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, + boolean force_baseline)); +EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, + int scale_factor, + boolean force_baseline)); +EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, + boolean force_baseline)); +EXTERN(int) jpeg_quality_scaling JPP((int quality)); +EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, + boolean suppress)); +EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); + +/* Main entry points for compression */ +EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, + boolean write_all_tables)); +EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION num_lines)); +EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); + +/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION num_lines)); + +/* Write a special marker. See libjpeg.doc concerning safe usage. */ +EXTERN(void) jpeg_write_marker + JPP((j_compress_ptr cinfo, int marker, + const JOCTET * dataptr, unsigned int datalen)); +/* Same, but piecemeal. */ +EXTERN(void) jpeg_write_m_header + JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); +EXTERN(void) jpeg_write_m_byte + JPP((j_compress_ptr cinfo, int val)); + +/* Alternate compression function: just write an abbreviated table file */ +EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); + +/* Decompression startup: read start of JPEG datastream to see what's there */ +EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, + boolean require_image)); +/* Return value is one of: */ +#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ +#define JPEG_HEADER_OK 1 /* Found valid image datastream */ +#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ +/* If you pass require_image = TRUE (normal case), you need not check for + * a TABLES_ONLY return code; an abbreviated file will cause an error exit. + * JPEG_SUSPENDED is only possible if you use a data source module that can + * give a suspension return (the stdio source module doesn't). + */ + +/* Main entry points for decompression */ +EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION max_lines)); +EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); + +/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION max_lines)); + +/* Additional entry points for buffered-image mode. */ +EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, + int scan_number)); +EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); +EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); +/* Return value is one of: */ +/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ +#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ +#define JPEG_REACHED_EOI 2 /* Reached end of image */ +#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ +#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ + +/* Precalculate output dimensions for current decompression parameters. */ +EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); + +/* Control saving of COM and APPn markers into marker_list. */ +EXTERN(void) jpeg_save_markers + JPP((j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit)); + +/* Install a special processing method for COM or APPn markers. */ +EXTERN(void) jpeg_set_marker_processor + JPP((j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine)); + +/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ +EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays)); +EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, + j_compress_ptr dstinfo)); + +/* If you choose to abort compression or decompression before completing + * jpeg_finish_(de)compress, then you need to clean up to release memory, + * temporary files, etc. You can just call jpeg_destroy_(de)compress + * if you're done with the JPEG object, but if you want to clean it up and + * reuse it, call this: + */ +EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); + +/* Generic versions of jpeg_abort and jpeg_destroy that work on either + * flavor of JPEG object. These may be more convenient in some places. + */ +EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); + +/* Default restart-marker-resync procedure for use by data source modules */ +EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, + int desired)); + + +/* These marker codes are exported since applications and data source modules + * are likely to want to use them. + */ + +#define JPEG_RST0 0xD0 /* RST0 marker code */ +#define JPEG_EOI 0xD9 /* EOI marker code */ +#define JPEG_APP0 0xE0 /* APP0 marker code */ +#define JPEG_COM 0xFE /* COM marker code */ + + +/* If we have a brain-damaged compiler that emits warnings (or worse, errors) + * for structure definitions that are never filled in, keep it quiet by + * supplying dummy definitions for the various substructures. + */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +struct jpeg_comp_master { long dummy; }; +struct jpeg_c_main_controller { long dummy; }; +struct jpeg_c_prep_controller { long dummy; }; +struct jpeg_c_coef_controller { long dummy; }; +struct jpeg_marker_writer { long dummy; }; +struct jpeg_color_converter { long dummy; }; +struct jpeg_downsampler { long dummy; }; +struct jpeg_forward_dct { long dummy; }; +struct jpeg_entropy_encoder { long dummy; }; +struct jpeg_decomp_master { long dummy; }; +struct jpeg_d_main_controller { long dummy; }; +struct jpeg_d_coef_controller { long dummy; }; +struct jpeg_d_post_controller { long dummy; }; +struct jpeg_input_controller { long dummy; }; +struct jpeg_marker_reader { long dummy; }; +struct jpeg_entropy_decoder { long dummy; }; +struct jpeg_inverse_dct { long dummy; }; +struct jpeg_upsampler { long dummy; }; +struct jpeg_color_deconverter { long dummy; }; +struct jpeg_color_quantizer { long dummy; }; +#endif /* JPEG_INTERNALS */ +#endif /* INCOMPLETE_TYPES_BROKEN */ + + +/* + * The JPEG library modules define JPEG_INTERNALS before including this file. + * The internal structure declarations are read only when that is true. + * Applications using the library should not include jpegint.h, but may wish + * to include jerror.h. + */ + +#ifdef JPEG_INTERNALS +#include "jpegint.h" /* fetch private declarations */ +#include "jerror.h" /* fetch error codes too */ +#endif + +#endif /* JPEGLIB_H */ diff --git a/libraries/external/jpeglib/jpeglib.plg b/libraries/external/jpeglib/jpeglib.plg new file mode 100755 index 0000000..768d022 --- /dev/null +++ b/libraries/external/jpeglib/jpeglib.plg @@ -0,0 +1,181 @@ + + +
+

Build Log

+

+--------------------Configuration: jpeglib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3BD.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"Debug/jpeglib.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\external\jpeglib\jcapimin.c" +"C:\g3\libraries\external\jpeglib\jcapistd.c" +"C:\g3\libraries\external\jpeglib\jccoefct.c" +"C:\g3\libraries\external\jpeglib\jccolor.c" +"C:\g3\libraries\external\jpeglib\jcdctmgr.c" +"C:\g3\libraries\external\jpeglib\jchuff.c" +"C:\g3\libraries\external\jpeglib\jcinit.c" +"C:\g3\libraries\external\jpeglib\jcmainct.c" +"C:\g3\libraries\external\jpeglib\jcmarker.c" +"C:\g3\libraries\external\jpeglib\jcmaster.c" +"C:\g3\libraries\external\jpeglib\jcomapi.c" +"C:\g3\libraries\external\jpeglib\jcparam.c" +"C:\g3\libraries\external\jpeglib\jcphuff.c" +"C:\g3\libraries\external\jpeglib\jcprepct.c" +"C:\g3\libraries\external\jpeglib\jcsample.c" +"C:\g3\libraries\external\jpeglib\jctrans.c" +"C:\g3\libraries\external\jpeglib\jdapimin.c" +"C:\g3\libraries\external\jpeglib\jdapistd.c" +"C:\g3\libraries\external\jpeglib\jdatadst.c" +"C:\g3\libraries\external\jpeglib\jdatasrc.c" +"C:\g3\libraries\external\jpeglib\jdcoefct.c" +"C:\g3\libraries\external\jpeglib\jdcolor.c" +"C:\g3\libraries\external\jpeglib\jddctmgr.c" +"C:\g3\libraries\external\jpeglib\jdhuff.c" +"C:\g3\libraries\external\jpeglib\jdinput.c" +"C:\g3\libraries\external\jpeglib\jdmainct.c" +"C:\g3\libraries\external\jpeglib\jdmarker.c" +"C:\g3\libraries\external\jpeglib\jdmaster.c" +"C:\g3\libraries\external\jpeglib\jdmerge.c" +"C:\g3\libraries\external\jpeglib\jdphuff.c" +"C:\g3\libraries\external\jpeglib\jdpostct.c" +"C:\g3\libraries\external\jpeglib\jdsample.c" +"C:\g3\libraries\external\jpeglib\jdtrans.c" +"C:\g3\libraries\external\jpeglib\jerror.c" +"C:\g3\libraries\external\jpeglib\jfdctflt.c" +"C:\g3\libraries\external\jpeglib\jfdctfst.c" +"C:\g3\libraries\external\jpeglib\jfdctint.c" +"C:\g3\libraries\external\jpeglib\jidctflt.c" +"C:\g3\libraries\external\jpeglib\jidctfst.c" +"C:\g3\libraries\external\jpeglib\jidctint.c" +"C:\g3\libraries\external\jpeglib\jidctred.c" +"C:\g3\libraries\external\jpeglib\jmemansi.c" +"C:\g3\libraries\external\jpeglib\jmemmgr.c" +"C:\g3\libraries\external\jpeglib\jquant1.c" +"C:\g3\libraries\external\jpeglib\jquant2.c" +"C:\g3\libraries\external\jpeglib\jutils.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3BD.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3BF.tmp" with contents +[ +/nologo /out:"Debug\jpeglib.lib" +.\Debug\jcapimin.obj +.\Debug\jcapistd.obj +.\Debug\jccoefct.obj +.\Debug\jccolor.obj +.\Debug\jcdctmgr.obj +.\Debug\jchuff.obj +.\Debug\jcinit.obj +.\Debug\jcmainct.obj +.\Debug\jcmarker.obj +.\Debug\jcmaster.obj +.\Debug\jcomapi.obj +.\Debug\jcparam.obj +.\Debug\jcphuff.obj +.\Debug\jcprepct.obj +.\Debug\jcsample.obj +.\Debug\jctrans.obj +.\Debug\jdapimin.obj +.\Debug\jdapistd.obj +.\Debug\jdatadst.obj +.\Debug\jdatasrc.obj +.\Debug\jdcoefct.obj +.\Debug\jdcolor.obj +.\Debug\jddctmgr.obj +.\Debug\jdhuff.obj +.\Debug\jdinput.obj +.\Debug\jdmainct.obj +.\Debug\jdmarker.obj +.\Debug\jdmaster.obj +.\Debug\jdmerge.obj +.\Debug\jdphuff.obj +.\Debug\jdpostct.obj +.\Debug\jdsample.obj +.\Debug\jdtrans.obj +.\Debug\jerror.obj +.\Debug\jfdctflt.obj +.\Debug\jfdctfst.obj +.\Debug\jfdctint.obj +.\Debug\jidctflt.obj +.\Debug\jidctfst.obj +.\Debug\jidctint.obj +.\Debug\jidctred.obj +.\Debug\jmemansi.obj +.\Debug\jmemmgr.obj +.\Debug\jquant1.obj +.\Debug\jquant2.obj +.\Debug\jutils.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3BF.tmp" +

Output Window

+Compiling... +jcapimin.c +jcapistd.c +jccoefct.c +jccolor.c +jcdctmgr.c +jchuff.c +jcinit.c +jcmainct.c +jcmarker.c +jcmaster.c +jcomapi.c +jcparam.c +jcphuff.c +jcprepct.c +jcsample.c +jctrans.c +jdapimin.c +jdapistd.c +jdatadst.c +jdatasrc.c +jdcoefct.c +jdcolor.c +jddctmgr.c +jdhuff.c +jdinput.c +jdmainct.c +jdmarker.c +jdmaster.c +jdmerge.c +jdphuff.c +jdpostct.c +jdsample.c +jdtrans.c +jerror.c +jfdctflt.c +jfdctfst.c +jfdctint.c +jidctflt.c +jidctfst.c +jidctint.c +jidctred.c +jmemansi.c +jmemmgr.c +jquant1.c +jquant2.c +jutils.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3C0.bat" with contents +[ +@echo off +copy Debug\jpeglib.lib c:\g3\lib +copy jpeglib.h c:\g3\include +copy jconfig.h c:\g3\include +copy jmorecfg.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3C0.bat" +Copying libs & hdrs to lib directory + 1 file(s) copied. + 1 file(s) copied. + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jpeglib.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/external/jpeglib/jpegsrc.v6b.tar.gz b/libraries/external/jpeglib/jpegsrc.v6b.tar.gz new file mode 100755 index 0000000..4e22d0a --- /dev/null +++ b/libraries/external/jpeglib/jpegsrc.v6b.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75c3ec241e9996504fe02a9ed4d12f16b74ade713972f3db9e65ce95cd27e35d +size 613261 diff --git a/libraries/external/jpeglib/jpegtran.c b/libraries/external/jpeglib/jpegtran.c new file mode 100755 index 0000000..719aaa7 --- /dev/null +++ b/libraries/external/jpeglib/jpegtran.c @@ -0,0 +1,504 @@ +/* + * jpegtran.c + * + * Copyright (C) 1995-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains a command-line user interface for JPEG transcoding. + * It is very similar to cjpeg.c, but provides lossless transcoding between + * different JPEG file formats. It also provides some lossless and sort-of- + * lossless transformations of JPEG data. + */ + +#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ +#include "transupp.h" /* Support routines for jpegtran */ +#include "jversion.h" /* for version message */ + +#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ +#ifdef __MWERKS__ +#include /* Metrowerks needs this */ +#include /* ... and this */ +#endif +#ifdef THINK_C +#include /* Think declares it here */ +#endif +#endif + + +/* + * Argument-parsing code. + * The switch parser is designed to be useful with DOS-style command line + * syntax, ie, intermixed switches and file names, where only the switches + * to the left of a given file name affect processing of that file. + * The main program in this file doesn't actually use this capability... + */ + + +static const char * progname; /* program name for error messages */ +static char * outfilename; /* for -outfile switch */ +static JCOPY_OPTION copyoption; /* -copy switch */ +static jpeg_transform_info transformoption; /* image transformation options */ + + +LOCAL(void) +usage (void) +/* complain about bad command line */ +{ + fprintf(stderr, "usage: %s [switches] ", progname); +#ifdef TWO_FILE_COMMANDLINE + fprintf(stderr, "inputfile outputfile\n"); +#else + fprintf(stderr, "[inputfile]\n"); +#endif + + fprintf(stderr, "Switches (names may be abbreviated):\n"); + fprintf(stderr, " -copy none Copy no extra markers from source file\n"); + fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); + fprintf(stderr, " -copy all Copy all extra markers\n"); +#ifdef ENTROPY_OPT_SUPPORTED + fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); +#endif +#ifdef C_PROGRESSIVE_SUPPORTED + fprintf(stderr, " -progressive Create progressive JPEG file\n"); +#endif +#if TRANSFORMS_SUPPORTED + fprintf(stderr, "Switches for modifying the image:\n"); + fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); + fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); + fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); + fprintf(stderr, " -transpose Transpose image\n"); + fprintf(stderr, " -transverse Transverse transpose image\n"); + fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); +#endif /* TRANSFORMS_SUPPORTED */ + fprintf(stderr, "Switches for advanced users:\n"); + fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); + fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); + fprintf(stderr, " -outfile name Specify name for output file\n"); + fprintf(stderr, " -verbose or -debug Emit debug output\n"); + fprintf(stderr, "Switches for wizards:\n"); +#ifdef C_ARITH_CODING_SUPPORTED + fprintf(stderr, " -arithmetic Use arithmetic coding\n"); +#endif +#ifdef C_MULTISCAN_FILES_SUPPORTED + fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); +#endif + exit(EXIT_FAILURE); +} + + +LOCAL(void) +select_transform (JXFORM_CODE transform) +/* Silly little routine to detect multiple transform options, + * which we can't handle. + */ +{ +#if TRANSFORMS_SUPPORTED + if (transformoption.transform == JXFORM_NONE || + transformoption.transform == transform) { + transformoption.transform = transform; + } else { + fprintf(stderr, "%s: can only do one image transformation at a time\n", + progname); + usage(); + } +#else + fprintf(stderr, "%s: sorry, image transformation was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif +} + + +LOCAL(int) +parse_switches (j_compress_ptr cinfo, int argc, char **argv, + int last_file_arg_seen, boolean for_real) +/* Parse optional switches. + * Returns argv[] index of first file-name argument (== argc if none). + * Any file names with indexes <= last_file_arg_seen are ignored; + * they have presumably been processed in a previous iteration. + * (Pass 0 for last_file_arg_seen on the first or only iteration.) + * for_real is FALSE on the first (dummy) pass; we may skip any expensive + * processing. + */ +{ + int argn; + char * arg; + boolean simple_progressive; + char * scansarg = NULL; /* saves -scans parm if any */ + + /* Set up default JPEG parameters. */ + simple_progressive = FALSE; + outfilename = NULL; + copyoption = JCOPYOPT_DEFAULT; + transformoption.transform = JXFORM_NONE; + transformoption.trim = FALSE; + transformoption.force_grayscale = FALSE; + cinfo->err->trace_level = 0; + + /* Scan command line options, adjust parameters */ + + for (argn = 1; argn < argc; argn++) { + arg = argv[argn]; + if (*arg != '-') { + /* Not a switch, must be a file name argument */ + if (argn <= last_file_arg_seen) { + outfilename = NULL; /* -outfile applies to just one input file */ + continue; /* ignore this name if previously processed */ + } + break; /* else done parsing switches */ + } + arg++; /* advance past switch marker character */ + + if (keymatch(arg, "arithmetic", 1)) { + /* Use arithmetic coding. */ +#ifdef C_ARITH_CODING_SUPPORTED + cinfo->arith_code = TRUE; +#else + fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "copy", 1)) { + /* Select which extra markers to copy. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "none", 1)) { + copyoption = JCOPYOPT_NONE; + } else if (keymatch(argv[argn], "comments", 1)) { + copyoption = JCOPYOPT_COMMENTS; + } else if (keymatch(argv[argn], "all", 1)) { + copyoption = JCOPYOPT_ALL; + } else + usage(); + + } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { + /* Enable debug printouts. */ + /* On first -d, print version identification */ + static boolean printed_version = FALSE; + + if (! printed_version) { + fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", + JVERSION, JCOPYRIGHT); + printed_version = TRUE; + } + cinfo->err->trace_level++; + + } else if (keymatch(arg, "flip", 1)) { + /* Mirror left-right or top-bottom. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "horizontal", 1)) + select_transform(JXFORM_FLIP_H); + else if (keymatch(argv[argn], "vertical", 1)) + select_transform(JXFORM_FLIP_V); + else + usage(); + + } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { + /* Force to grayscale. */ +#if TRANSFORMS_SUPPORTED + transformoption.force_grayscale = TRUE; +#else + select_transform(JXFORM_NONE); /* force an error */ +#endif + + } else if (keymatch(arg, "maxmemory", 3)) { + /* Maximum memory in Kb (or Mb with 'm'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (ch == 'm' || ch == 'M') + lval *= 1000L; + cinfo->mem->max_memory_to_use = lval * 1000L; + + } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { + /* Enable entropy parm optimization. */ +#ifdef ENTROPY_OPT_SUPPORTED + cinfo->optimize_coding = TRUE; +#else + fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "outfile", 4)) { + /* Set output file name. */ + if (++argn >= argc) /* advance to next argument */ + usage(); + outfilename = argv[argn]; /* save it away for later use */ + + } else if (keymatch(arg, "progressive", 1)) { + /* Select simple progressive mode. */ +#ifdef C_PROGRESSIVE_SUPPORTED + simple_progressive = TRUE; + /* We must postpone execution until num_components is known. */ +#else + fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "restart", 1)) { + /* Restart interval in MCU rows (or in MCUs with 'b'). */ + long lval; + char ch = 'x'; + + if (++argn >= argc) /* advance to next argument */ + usage(); + if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) + usage(); + if (lval < 0 || lval > 65535L) + usage(); + if (ch == 'b' || ch == 'B') { + cinfo->restart_interval = (unsigned int) lval; + cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ + } else { + cinfo->restart_in_rows = (int) lval; + /* restart_interval will be computed during startup */ + } + + } else if (keymatch(arg, "rotate", 2)) { + /* Rotate 90, 180, or 270 degrees (measured clockwise). */ + if (++argn >= argc) /* advance to next argument */ + usage(); + if (keymatch(argv[argn], "90", 2)) + select_transform(JXFORM_ROT_90); + else if (keymatch(argv[argn], "180", 3)) + select_transform(JXFORM_ROT_180); + else if (keymatch(argv[argn], "270", 3)) + select_transform(JXFORM_ROT_270); + else + usage(); + + } else if (keymatch(arg, "scans", 1)) { + /* Set scan script. */ +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (++argn >= argc) /* advance to next argument */ + usage(); + scansarg = argv[argn]; + /* We must postpone reading the file in case -progressive appears. */ +#else + fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + progname); + exit(EXIT_FAILURE); +#endif + + } else if (keymatch(arg, "transpose", 1)) { + /* Transpose (across UL-to-LR axis). */ + select_transform(JXFORM_TRANSPOSE); + + } else if (keymatch(arg, "transverse", 6)) { + /* Transverse transpose (across UR-to-LL axis). */ + select_transform(JXFORM_TRANSVERSE); + + } else if (keymatch(arg, "trim", 3)) { + /* Trim off any partial edge MCUs that the transform can't handle. */ + transformoption.trim = TRUE; + + } else { + usage(); /* bogus switch */ + } + } + + /* Post-switch-scanning cleanup */ + + if (for_real) { + +#ifdef C_PROGRESSIVE_SUPPORTED + if (simple_progressive) /* process -progressive; -scans can override */ + jpeg_simple_progression(cinfo); +#endif + +#ifdef C_MULTISCAN_FILES_SUPPORTED + if (scansarg != NULL) /* process -scans if it was present */ + if (! read_scan_script(cinfo, scansarg)) + usage(); +#endif + } + + return argn; /* return index of next arg (file name) */ +} + + +/* + * The main program. + */ + +int +main (int argc, char **argv) +{ + struct jpeg_decompress_struct srcinfo; + struct jpeg_compress_struct dstinfo; + struct jpeg_error_mgr jsrcerr, jdsterr; +#ifdef PROGRESS_REPORT + struct cdjpeg_progress_mgr progress; +#endif + jvirt_barray_ptr * src_coef_arrays; + jvirt_barray_ptr * dst_coef_arrays; + int file_index; + FILE * input_file; + FILE * output_file; + + /* On Mac, fetch a command line. */ +#ifdef USE_CCOMMAND + argc = ccommand(&argv); +#endif + + progname = argv[0]; + if (progname == NULL || progname[0] == 0) + progname = "jpegtran"; /* in case C library doesn't provide it */ + + /* Initialize the JPEG decompression object with default error handling. */ + srcinfo.err = jpeg_std_error(&jsrcerr); + jpeg_create_decompress(&srcinfo); + /* Initialize the JPEG compression object with default error handling. */ + dstinfo.err = jpeg_std_error(&jdsterr); + jpeg_create_compress(&dstinfo); + + /* Now safe to enable signal catcher. + * Note: we assume only the decompression object will have virtual arrays. + */ +#ifdef NEED_SIGNAL_CATCHER + enable_signal_catcher((j_common_ptr) &srcinfo); +#endif + + /* Scan command line to find file names. + * It is convenient to use just one switch-parsing routine, but the switch + * values read here are mostly ignored; we will rescan the switches after + * opening the input file. Also note that most of the switches affect the + * destination JPEG object, so we parse into that and then copy over what + * needs to affects the source too. + */ + + file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); + jsrcerr.trace_level = jdsterr.trace_level; + srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; + +#ifdef TWO_FILE_COMMANDLINE + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + } +#else + /* Unix style: expect zero or one file name */ + if (file_index < argc-1) { + fprintf(stderr, "%s: only one input file\n", progname); + usage(); + } +#endif /* TWO_FILE_COMMANDLINE */ + + /* Open the input file. */ + if (file_index < argc) { + if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); + exit(EXIT_FAILURE); + } + } else { + /* default input file is stdin */ + input_file = read_stdin(); + } + + /* Open the output file. */ + if (outfilename != NULL) { + if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); + exit(EXIT_FAILURE); + } + } else { + /* default output file is stdout */ + output_file = write_stdout(); + } + +#ifdef PROGRESS_REPORT + start_progress_monitor((j_common_ptr) &dstinfo, &progress); +#endif + + /* Specify data source for decompression */ + jpeg_stdio_src(&srcinfo, input_file); + + /* Enable saving of extra markers that we want to copy */ + jcopy_markers_setup(&srcinfo, copyoption); + + /* Read file header */ + (void) jpeg_read_header(&srcinfo, TRUE); + + /* Any space needed by a transform option must be requested before + * jpeg_read_coefficients so that memory allocation will be done right. + */ +#if TRANSFORMS_SUPPORTED + jtransform_request_workspace(&srcinfo, &transformoption); +#endif + + /* Read source file as DCT coefficients */ + src_coef_arrays = jpeg_read_coefficients(&srcinfo); + + /* Initialize destination compression parameters from source values */ + jpeg_copy_critical_parameters(&srcinfo, &dstinfo); + + /* Adjust destination parameters if required by transform options; + * also find out which set of coefficient arrays will hold the output. + */ +#if TRANSFORMS_SUPPORTED + dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, + src_coef_arrays, + &transformoption); +#else + dst_coef_arrays = src_coef_arrays; +#endif + + /* Adjust default compression parameters by re-parsing the options */ + file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); + + /* Specify data destination for compression */ + jpeg_stdio_dest(&dstinfo, output_file); + + /* Start compressor (note no image data is actually written here) */ + jpeg_write_coefficients(&dstinfo, dst_coef_arrays); + + /* Copy to the output file any extra markers that we want to preserve */ + jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); + + /* Execute image transformation, if any */ +#if TRANSFORMS_SUPPORTED + jtransform_execute_transformation(&srcinfo, &dstinfo, + src_coef_arrays, + &transformoption); +#endif + + /* Finish compression and release memory */ + jpeg_finish_compress(&dstinfo); + jpeg_destroy_compress(&dstinfo); + (void) jpeg_finish_decompress(&srcinfo); + jpeg_destroy_decompress(&srcinfo); + + /* Close files, if we opened them */ + if (input_file != stdin) + fclose(input_file); + if (output_file != stdout) + fclose(output_file); + +#ifdef PROGRESS_REPORT + end_progress_monitor((j_common_ptr) &dstinfo); +#endif + + /* All done. */ + exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); + return 0; /* suppress no-return-value warnings */ +} diff --git a/libraries/external/jpeglib/jquant1.c b/libraries/external/jpeglib/jquant1.c new file mode 100755 index 0000000..aaa34a1 --- /dev/null +++ b/libraries/external/jpeglib/jquant1.c @@ -0,0 +1,856 @@ +/* + * jquant1.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 1-pass color quantization (color mapping) routines. + * These routines provide mapping to a fixed color map using equally spaced + * color values. Optional Floyd-Steinberg or ordered dithering is available. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_1PASS_SUPPORTED + + +/* + * The main purpose of 1-pass quantization is to provide a fast, if not very + * high quality, colormapped output capability. A 2-pass quantizer usually + * gives better visual quality; however, for quantized grayscale output this + * quantizer is perfectly adequate. Dithering is highly recommended with this + * quantizer, though you can turn it off if you really want to. + * + * In 1-pass quantization the colormap must be chosen in advance of seeing the + * image. We use a map consisting of all combinations of Ncolors[i] color + * values for the i'th component. The Ncolors[] values are chosen so that + * their product, the total number of colors, is no more than that requested. + * (In most cases, the product will be somewhat less.) + * + * Since the colormap is orthogonal, the representative value for each color + * component can be determined without considering the other components; + * then these indexes can be combined into a colormap index by a standard + * N-dimensional-array-subscript calculation. Most of the arithmetic involved + * can be precalculated and stored in the lookup table colorindex[]. + * colorindex[i][j] maps pixel value j in component i to the nearest + * representative value (grid plane) for that component; this index is + * multiplied by the array stride for component i, so that the + * index of the colormap entry closest to a given pixel value is just + * sum( colorindex[component-number][pixel-component-value] ) + * Aside from being fast, this scheme allows for variable spacing between + * representative values with no additional lookup cost. + * + * If gamma correction has been applied in color conversion, it might be wise + * to adjust the color grid spacing so that the representative colors are + * equidistant in linear space. At this writing, gamma correction is not + * implemented by jdcolor, so nothing is done here. + */ + + +/* Declarations for ordered dithering. + * + * We use a standard 16x16 ordered dither array. The basic concept of ordered + * dithering is described in many references, for instance Dale Schumacher's + * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). + * In place of Schumacher's comparisons against a "threshold" value, we add a + * "dither" value to the input pixel and then round the result to the nearest + * output value. The dither value is equivalent to (0.5 - threshold) times + * the distance between output values. For ordered dithering, we assume that + * the output colors are equally spaced; if not, results will probably be + * worse, since the dither may be too much or too little at a given point. + * + * The normal calculation would be to form pixel value + dither, range-limit + * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. + * We can skip the separate range-limiting step by extending the colorindex + * table in both directions. + */ + +#define ODITHER_SIZE 16 /* dimension of dither matrix */ +/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ +#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ +#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ + +typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; +typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; + +static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { + /* Bayer's order-4 dither array. Generated by the code given in + * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. + * The values in this array must range from 0 to ODITHER_CELLS-1. + */ + { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, + { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, + { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, + { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, + { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, + { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, + { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, + { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, + { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, + { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, + { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, + { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, + { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, + { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, + { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, + { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } +}; + + +/* Declarations for Floyd-Steinberg dithering. + * + * Errors are accumulated into the array fserrors[], at a resolution of + * 1/16th of a pixel count. The error at a given pixel is propagated + * to its not-yet-processed neighbors using the standard F-S fractions, + * ... (here) 7/16 + * 3/16 5/16 1/16 + * We work left-to-right on even rows, right-to-left on odd rows. + * + * We can get away with a single array (holding one row's worth of errors) + * by using it to store the current row's errors at pixel columns not yet + * processed, but the next row's errors at columns already processed. We + * need only a few extra variables to hold the errors immediately around the + * current column. (If we are lucky, those variables are in registers, but + * even if not, they're probably cheaper to access than array elements are.) + * + * The fserrors[] array is indexed [component#][position]. + * We provide (#columns + 2) entries per component; the extra entry at each + * end saves us from special-casing the first and last pixels. + * + * Note: on a wide image, we might not have enough room in a PC's near data + * segment to hold the error array; so it is allocated with alloc_large. + */ + +#if BITS_IN_JSAMPLE == 8 +typedef INT16 FSERROR; /* 16 bits should be enough */ +typedef int LOCFSERROR; /* use 'int' for calculation temps */ +#else +typedef INT32 FSERROR; /* may need more than 16 bits */ +typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ +#endif + +typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ + + +/* Private subobject */ + +#define MAX_Q_COMPS 4 /* max components I can handle */ + +typedef struct { + struct jpeg_color_quantizer pub; /* public fields */ + + /* Initially allocated colormap is saved here */ + JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ + int sv_actual; /* number of entries in use */ + + JSAMPARRAY colorindex; /* Precomputed mapping for speed */ + /* colorindex[i][j] = index of color closest to pixel value j in component i, + * premultiplied as described above. Since colormap indexes must fit into + * JSAMPLEs, the entries of this array will too. + */ + boolean is_padded; /* is the colorindex padded for odither? */ + + int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ + + /* Variables for ordered dithering */ + int row_index; /* cur row's vertical index in dither matrix */ + ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ + + /* Variables for Floyd-Steinberg dithering */ + FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ + boolean on_odd_row; /* flag to remember which row we are on */ +} my_cquantizer; + +typedef my_cquantizer * my_cquantize_ptr; + + +/* + * Policy-making subroutines for create_colormap and create_colorindex. + * These routines determine the colormap to be used. The rest of the module + * only assumes that the colormap is orthogonal. + * + * * select_ncolors decides how to divvy up the available colors + * among the components. + * * output_value defines the set of representative values for a component. + * * largest_input_value defines the mapping from input values to + * representative values for a component. + * Note that the latter two routines may impose different policies for + * different components, though this is not currently done. + */ + + +LOCAL(int) +select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) +/* Determine allocation of desired colors to components, */ +/* and fill in Ncolors[] array to indicate choice. */ +/* Return value is total number of colors (product of Ncolors[] values). */ +{ + int nc = cinfo->out_color_components; /* number of color components */ + int max_colors = cinfo->desired_number_of_colors; + int total_colors, iroot, i, j; + boolean changed; + long temp; + static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; + + /* We can allocate at least the nc'th root of max_colors per component. */ + /* Compute floor(nc'th root of max_colors). */ + iroot = 1; + do { + iroot++; + temp = iroot; /* set temp = iroot ** nc */ + for (i = 1; i < nc; i++) + temp *= iroot; + } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ + iroot--; /* now iroot = floor(root) */ + + /* Must have at least 2 color values per component */ + if (iroot < 2) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); + + /* Initialize to iroot color values for each component */ + total_colors = 1; + for (i = 0; i < nc; i++) { + Ncolors[i] = iroot; + total_colors *= iroot; + } + /* We may be able to increment the count for one or more components without + * exceeding max_colors, though we know not all can be incremented. + * Sometimes, the first component can be incremented more than once! + * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) + * In RGB colorspace, try to increment G first, then R, then B. + */ + do { + changed = FALSE; + for (i = 0; i < nc; i++) { + j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); + /* calculate new total_colors if Ncolors[j] is incremented */ + temp = total_colors / Ncolors[j]; + temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ + if (temp > (long) max_colors) + break; /* won't fit, done with this pass */ + Ncolors[j]++; /* OK, apply the increment */ + total_colors = (int) temp; + changed = TRUE; + } + } while (changed); + + return total_colors; +} + + +LOCAL(int) +output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return j'th output value, where j will range from 0 to maxj */ +/* The output values must fall in 0..MAXJSAMPLE in increasing order */ +{ + /* We always provide values 0 and MAXJSAMPLE for each component; + * any additional values are equally spaced between these limits. + * (Forcing the upper and lower values to the limits ensures that + * dithering can't produce a color outside the selected gamut.) + */ + return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); +} + + +LOCAL(int) +largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) +/* Return largest input value that should map to j'th output value */ +/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ +{ + /* Breakpoints are halfway between values returned by output_value */ + return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); +} + + +/* + * Create the colormap. + */ + +LOCAL(void) +create_colormap (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colormap; /* Created colormap */ + int total_colors; /* Number of distinct output colors */ + int i,j,k, nci, blksize, blkdist, ptr, val; + + /* Select number of colors for each component */ + total_colors = select_ncolors(cinfo, cquantize->Ncolors); + + /* Report selected color counts */ + if (cinfo->out_color_components == 3) + TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, + total_colors, cquantize->Ncolors[0], + cquantize->Ncolors[1], cquantize->Ncolors[2]); + else + TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); + + /* Allocate and fill in the colormap. */ + /* The colors are ordered in the map in standard row-major order, */ + /* i.e. rightmost (highest-indexed) color changes most rapidly. */ + + colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + /* blkdist is distance between groups of identical entries for a component */ + blkdist = total_colors; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colormap entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blkdist / nci; + for (j = 0; j < nci; j++) { + /* Compute j'th output value (out of nci) for component */ + val = output_value(cinfo, i, j, nci-1); + /* Fill in all colormap entries that have this value of this component */ + for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { + /* fill in blksize entries beginning at ptr */ + for (k = 0; k < blksize; k++) + colormap[i][ptr+k] = (JSAMPLE) val; + } + } + blkdist = blksize; /* blksize of this color is blkdist of next */ + } + + /* Save the colormap in private storage, + * where it will survive color quantization mode changes. + */ + cquantize->sv_colormap = colormap; + cquantize->sv_actual = total_colors; +} + + +/* + * Create the color index table. + */ + +LOCAL(void) +create_colorindex (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPROW indexptr; + int i,j,k, nci, blksize, val, pad; + + /* For ordered dither, we pad the color index tables by MAXJSAMPLE in + * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). + * This is not necessary in the other dithering modes. However, we + * flag whether it was done in case user changes dithering mode. + */ + if (cinfo->dither_mode == JDITHER_ORDERED) { + pad = MAXJSAMPLE*2; + cquantize->is_padded = TRUE; + } else { + pad = 0; + cquantize->is_padded = FALSE; + } + + cquantize->colorindex = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (JDIMENSION) (MAXJSAMPLE+1 + pad), + (JDIMENSION) cinfo->out_color_components); + + /* blksize is number of adjacent repeated entries for a component */ + blksize = cquantize->sv_actual; + + for (i = 0; i < cinfo->out_color_components; i++) { + /* fill in colorindex entries for i'th color component */ + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + blksize = blksize / nci; + + /* adjust colorindex pointers to provide padding at negative indexes. */ + if (pad) + cquantize->colorindex[i] += MAXJSAMPLE; + + /* in loop, val = index of current output value, */ + /* and k = largest j that maps to current val */ + indexptr = cquantize->colorindex[i]; + val = 0; + k = largest_input_value(cinfo, i, 0, nci-1); + for (j = 0; j <= MAXJSAMPLE; j++) { + while (j > k) /* advance val if past boundary */ + k = largest_input_value(cinfo, i, ++val, nci-1); + /* premultiply so that no multiplication needed in main processing */ + indexptr[j] = (JSAMPLE) (val * blksize); + } + /* Pad at both ends if necessary */ + if (pad) + for (j = 1; j <= MAXJSAMPLE; j++) { + indexptr[-j] = indexptr[0]; + indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; + } + } +} + + +/* + * Create an ordered-dither array for a component having ncolors + * distinct output values. + */ + +LOCAL(ODITHER_MATRIX_PTR) +make_odither_array (j_decompress_ptr cinfo, int ncolors) +{ + ODITHER_MATRIX_PTR odither; + int j,k; + INT32 num,den; + + odither = (ODITHER_MATRIX_PTR) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(ODITHER_MATRIX)); + /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). + * Hence the dither value for the matrix cell with fill order f + * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). + * On 16-bit-int machine, be careful to avoid overflow. + */ + den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); + for (j = 0; j < ODITHER_SIZE; j++) { + for (k = 0; k < ODITHER_SIZE; k++) { + num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) + * MAXJSAMPLE; + /* Ensure round towards zero despite C's lack of consistency + * about rounding negative values in integer division... + */ + odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); + } + } + return odither; +} + + +/* + * Create the ordered-dither tables. + * Components having the same number of representative colors may + * share a dither table. + */ + +LOCAL(void) +create_odither_tables (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + ODITHER_MATRIX_PTR odither; + int i, j, nci; + + for (i = 0; i < cinfo->out_color_components; i++) { + nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ + odither = NULL; /* search for matching prior component */ + for (j = 0; j < i; j++) { + if (nci == cquantize->Ncolors[j]) { + odither = cquantize->odither[j]; + break; + } + } + if (odither == NULL) /* need a new table? */ + odither = make_odither_array(cinfo, nci); + cquantize->odither[i] = odither; + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + JSAMPARRAY colorindex = cquantize->colorindex; + register int pixcode, ci; + register JSAMPROW ptrin, ptrout; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + register int nc = cinfo->out_color_components; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = 0; + for (ci = 0; ci < nc; ci++) { + pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); + } + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW ptrin, ptrout; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptrin = input_buf[row]; + ptrout = output_buf[row]; + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); + *ptrout++ = (JSAMPLE) pixcode; + } + } +} + + +METHODDEF(void) +quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + int * dither; /* points to active row of dither matrix */ + int row_index, col_index; /* current indexes into dither matrix */ + int nc = cinfo->out_color_components; + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + jzero_far((void FAR *) output_buf[row], + (size_t) (width * SIZEOF(JSAMPLE))); + row_index = cquantize->row_index; + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + colorindex_ci = cquantize->colorindex[ci]; + dither = cquantize->odither[ci][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, + * select output value, accumulate into output code for this pixel. + * Range-limiting need not be done explicitly, as we have extended + * the colorindex table to produce the right answers for out-of-range + * inputs. The maximum dither is +- MAXJSAMPLE; this sets the + * required amount of padding. + */ + *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; + input_ptr += nc; + output_ptr++; + col_index = (col_index + 1) & ODITHER_MASK; + } + } + /* Advance row index for next row */ + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* Fast path for out_color_components==3, with ordered dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register int pixcode; + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex0 = cquantize->colorindex[0]; + JSAMPROW colorindex1 = cquantize->colorindex[1]; + JSAMPROW colorindex2 = cquantize->colorindex[2]; + int * dither0; /* points to active row of dither matrix */ + int * dither1; + int * dither2; + int row_index, col_index; /* current indexes into dither matrix */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + row_index = cquantize->row_index; + input_ptr = input_buf[row]; + output_ptr = output_buf[row]; + dither0 = cquantize->odither[0][row_index]; + dither1 = cquantize->odither[1][row_index]; + dither2 = cquantize->odither[2][row_index]; + col_index = 0; + + for (col = width; col > 0; col--) { + pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + + dither0[col_index]]); + pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + + dither1[col_index]]); + pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + + dither2[col_index]]); + *output_ptr++ = (JSAMPLE) pixcode; + col_index = (col_index + 1) & ODITHER_MASK; + } + row_index = (row_index + 1) & ODITHER_MASK; + cquantize->row_index = row_index; + } +} + + +METHODDEF(void) +quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, + JSAMPARRAY output_buf, int num_rows) +/* General case, with Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + register LOCFSERROR cur; /* current error or pixel value */ + LOCFSERROR belowerr; /* error for pixel below cur */ + LOCFSERROR bpreverr; /* error for below/prev col */ + LOCFSERROR bnexterr; /* error for below/next col */ + LOCFSERROR delta; + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + register JSAMPROW input_ptr; + register JSAMPROW output_ptr; + JSAMPROW colorindex_ci; + JSAMPROW colormap_ci; + int pixcode; + int nc = cinfo->out_color_components; + int dir; /* 1 for left-to-right, -1 for right-to-left */ + int dirnc; /* dir * nc */ + int ci; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + /* Initialize output values to 0 so can process components separately */ + jzero_far((void FAR *) output_buf[row], + (size_t) (width * SIZEOF(JSAMPLE))); + for (ci = 0; ci < nc; ci++) { + input_ptr = input_buf[row] + ci; + output_ptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + input_ptr += (width-1) * nc; /* so point to rightmost pixel */ + output_ptr += width-1; + dir = -1; + dirnc = -nc; + errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ + } else { + /* work left to right in this row */ + dir = 1; + dirnc = nc; + errorptr = cquantize->fserrors[ci]; /* => entry before first column */ + } + colorindex_ci = cquantize->colorindex[ci]; + colormap_ci = cquantize->sv_colormap[ci]; + /* Preset error values: no error propagated to first pixel from left */ + cur = 0; + /* and no error propagated to row below yet */ + belowerr = bpreverr = 0; + + for (col = width; col > 0; col--) { + /* cur holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE; this sets the required size + * of the range_limit array. + */ + cur += GETJSAMPLE(*input_ptr); + cur = GETJSAMPLE(range_limit[cur]); + /* Select output value, accumulate into output code for this pixel */ + pixcode = GETJSAMPLE(colorindex_ci[cur]); + *output_ptr += (JSAMPLE) pixcode; + /* Compute actual representation error at this pixel */ + /* Note: we can do this even though we don't have the final */ + /* pixel code, because the colormap is orthogonal. */ + cur -= GETJSAMPLE(colormap_ci[pixcode]); + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + bnexterr = cur; + delta = cur * 2; + cur += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr + cur); + cur += delta; /* form error * 5 */ + bpreverr = belowerr + cur; + belowerr = bnexterr; + cur += delta; /* form error * 7 */ + /* At this point cur contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + input_ptr += dirnc; /* advance input ptr to next column */ + output_ptr += dir; /* advance output ptr to next column */ + errorptr += dir; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error value into the + * final fserrors[] entry. Note we need not unload belowerr because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ + } + cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); + } +} + + +/* + * Allocate workspace for Floyd-Steinberg errors. + */ + +LOCAL(void) +alloc_fs_workspace (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); + for (i = 0; i < cinfo->out_color_components; i++) { + cquantize->fserrors[i] = (FSERRPTR) + (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + } +} + + +/* + * Initialize for one-pass color quantization. + */ + +METHODDEF(void) +start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + size_t arraysize; + int i; + + /* Install my colormap. */ + cinfo->colormap = cquantize->sv_colormap; + cinfo->actual_number_of_colors = cquantize->sv_actual; + + /* Initialize for desired dithering mode. */ + switch (cinfo->dither_mode) { + case JDITHER_NONE: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = color_quantize3; + else + cquantize->pub.color_quantize = color_quantize; + break; + case JDITHER_ORDERED: + if (cinfo->out_color_components == 3) + cquantize->pub.color_quantize = quantize3_ord_dither; + else + cquantize->pub.color_quantize = quantize_ord_dither; + cquantize->row_index = 0; /* initialize state for ordered dither */ + /* If user changed to ordered dither from another mode, + * we must recreate the color index table with padding. + * This will cost extra space, but probably isn't very likely. + */ + if (! cquantize->is_padded) + create_colorindex(cinfo); + /* Create ordered-dither tables if we didn't already. */ + if (cquantize->odither[0] == NULL) + create_odither_tables(cinfo); + break; + case JDITHER_FS: + cquantize->pub.color_quantize = quantize_fs_dither; + cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ + /* Allocate Floyd-Steinberg workspace if didn't already. */ + if (cquantize->fserrors[0] == NULL) + alloc_fs_workspace(cinfo); + /* Initialize the propagated errors to zero. */ + arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); + for (i = 0; i < cinfo->out_color_components; i++) + jzero_far((void FAR *) cquantize->fserrors[i], arraysize); + break; + default: + ERREXIT(cinfo, JERR_NOT_COMPILED); + break; + } +} + + +/* + * Finish up at the end of the pass. + */ + +METHODDEF(void) +finish_pass_1_quant (j_decompress_ptr cinfo) +{ + /* no work in 1-pass case */ +} + + +/* + * Switch to a new external colormap between output passes. + * Shouldn't get to this module! + */ + +METHODDEF(void) +new_color_map_1_quant (j_decompress_ptr cinfo) +{ + ERREXIT(cinfo, JERR_MODE_CHANGE); +} + + +/* + * Module initialization routine for 1-pass color quantization. + */ + +GLOBAL(void) +jinit_1pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + + cquantize = (my_cquantize_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_cquantizer)); + cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; + cquantize->pub.start_pass = start_pass_1_quant; + cquantize->pub.finish_pass = finish_pass_1_quant; + cquantize->pub.new_color_map = new_color_map_1_quant; + cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ + cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ + + /* Make sure my internal arrays won't overflow */ + if (cinfo->out_color_components > MAX_Q_COMPS) + ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); + + /* Create the colormap and color index table. */ + create_colormap(cinfo); + create_colorindex(cinfo); + + /* Allocate Floyd-Steinberg workspace now if requested. + * We do this now since it is FAR storage and may affect the memory + * manager's space calculations. If the user changes to FS dither + * mode in a later pass, we will allocate the space then, and will + * possibly overrun the max_memory_to_use setting. + */ + if (cinfo->dither_mode == JDITHER_FS) + alloc_fs_workspace(cinfo); +} + +#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/libraries/external/jpeglib/jquant1.o b/libraries/external/jpeglib/jquant1.o new file mode 100644 index 0000000..03fdf15 Binary files /dev/null and b/libraries/external/jpeglib/jquant1.o differ diff --git a/libraries/external/jpeglib/jquant2.c b/libraries/external/jpeglib/jquant2.c new file mode 100755 index 0000000..87a3920 --- /dev/null +++ b/libraries/external/jpeglib/jquant2.c @@ -0,0 +1,1310 @@ +/* + * jquant2.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains 2-pass color quantization (color mapping) routines. + * These routines provide selection of a custom color map for an image, + * followed by mapping of the image to that color map, with optional + * Floyd-Steinberg dithering. + * It is also possible to use just the second pass to map to an arbitrary + * externally-given color map. + * + * Note: ordered dithering is not supported, since there isn't any fast + * way to compute intercolor distances; it's unclear that ordered dither's + * fundamental assumptions even hold with an irregularly spaced color map. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#ifdef QUANT_2PASS_SUPPORTED + + +/* + * This module implements the well-known Heckbert paradigm for color + * quantization. Most of the ideas used here can be traced back to + * Heckbert's seminal paper + * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", + * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. + * + * In the first pass over the image, we accumulate a histogram showing the + * usage count of each possible color. To keep the histogram to a reasonable + * size, we reduce the precision of the input; typical practice is to retain + * 5 or 6 bits per color, so that 8 or 4 different input values are counted + * in the same histogram cell. + * + * Next, the color-selection step begins with a box representing the whole + * color space, and repeatedly splits the "largest" remaining box until we + * have as many boxes as desired colors. Then the mean color in each + * remaining box becomes one of the possible output colors. + * + * The second pass over the image maps each input pixel to the closest output + * color (optionally after applying a Floyd-Steinberg dithering correction). + * This mapping is logically trivial, but making it go fast enough requires + * considerable care. + * + * Heckbert-style quantizers vary a good deal in their policies for choosing + * the "largest" box and deciding where to cut it. The particular policies + * used here have proved out well in experimental comparisons, but better ones + * may yet be found. + * + * In earlier versions of the IJG code, this module quantized in YCbCr color + * space, processing the raw upsampled data without a color conversion step. + * This allowed the color conversion math to be done only once per colormap + * entry, not once per pixel. However, that optimization precluded other + * useful optimizations (such as merging color conversion with upsampling) + * and it also interfered with desired capabilities such as quantizing to an + * externally-supplied colormap. We have therefore abandoned that approach. + * The present code works in the post-conversion color space, typically RGB. + * + * To improve the visual quality of the results, we actually work in scaled + * RGB space, giving G distances more weight than R, and R in turn more than + * B. To do everything in integer math, we must use integer scale factors. + * The 2/3/1 scale factors used here correspond loosely to the relative + * weights of the colors in the NTSC grayscale equation. + * If you want to use this code to quantize a non-RGB color space, you'll + * probably need to change these scale factors. + */ + +#define R_SCALE 2 /* scale R distances by this much */ +#define G_SCALE 3 /* scale G distances by this much */ +#define B_SCALE 1 /* and B by this much */ + +/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined + * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B + * and B,G,R orders. If you define some other weird order in jmorecfg.h, + * you'll get compile errors until you extend this logic. In that case + * you'll probably want to tweak the histogram sizes too. + */ + +#if RGB_RED == 0 +#define C0_SCALE R_SCALE +#endif +#if RGB_BLUE == 0 +#define C0_SCALE B_SCALE +#endif +#if RGB_GREEN == 1 +#define C1_SCALE G_SCALE +#endif +#if RGB_RED == 2 +#define C2_SCALE R_SCALE +#endif +#if RGB_BLUE == 2 +#define C2_SCALE B_SCALE +#endif + + +/* + * First we have the histogram data structure and routines for creating it. + * + * The number of bits of precision can be adjusted by changing these symbols. + * We recommend keeping 6 bits for G and 5 each for R and B. + * If you have plenty of memory and cycles, 6 bits all around gives marginally + * better results; if you are short of memory, 5 bits all around will save + * some space but degrade the results. + * To maintain a fully accurate histogram, we'd need to allocate a "long" + * (preferably unsigned long) for each cell. In practice this is overkill; + * we can get by with 16 bits per cell. Few of the cell counts will overflow, + * and clamping those that do overflow to the maximum value will give close- + * enough results. This reduces the recommended histogram size from 256Kb + * to 128Kb, which is a useful savings on PC-class machines. + * (In the second pass the histogram space is re-used for pixel mapping data; + * in that capacity, each cell must be able to store zero to the number of + * desired colors. 16 bits/cell is plenty for that too.) + * Since the JPEG code is intended to run in small memory model on 80x86 + * machines, we can't just allocate the histogram in one chunk. Instead + * of a true 3-D array, we use a row of pointers to 2-D arrays. Each + * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and + * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that + * on 80x86 machines, the pointer row is in near memory but the actual + * arrays are in far memory (same arrangement as we use for image arrays). + */ + +#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ + +/* These will do the right thing for either R,G,B or B,G,R color order, + * but you may not like the results for other color orders. + */ +#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ +#define HIST_C1_BITS 6 /* bits of precision in G histogram */ +#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ + +/* Number of elements along histogram axes. */ +#define HIST_C0_ELEMS (1<cquantize; + register JSAMPROW ptr; + register histptr histp; + register hist3d histogram = cquantize->histogram; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + ptr = input_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the histogram */ + histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] + [GETJSAMPLE(ptr[1]) >> C1_SHIFT] + [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; + /* increment, check for overflow and undo increment if so. */ + if (++(*histp) <= 0) + (*histp)--; + ptr += 3; + } + } +} + + +/* + * Next we have the really interesting routines: selection of a colormap + * given the completed histogram. + * These routines work with a list of "boxes", each representing a rectangular + * subset of the input color space (to histogram precision). + */ + +typedef struct { + /* The bounds of the box (inclusive); expressed as histogram indexes */ + int c0min, c0max; + int c1min, c1max; + int c2min, c2max; + /* The volume (actually 2-norm) of the box */ + INT32 volume; + /* The number of nonzero histogram cells within this box */ + long colorcount; +} box; + +typedef box * boxptr; + + +LOCAL(boxptr) +find_biggest_color_pop (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest color population */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register long maxc = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->colorcount > maxc && boxp->volume > 0) { + which = boxp; + maxc = boxp->colorcount; + } + } + return which; +} + + +LOCAL(boxptr) +find_biggest_volume (boxptr boxlist, int numboxes) +/* Find the splittable box with the largest (scaled) volume */ +/* Returns NULL if no splittable boxes remain */ +{ + register boxptr boxp; + register int i; + register INT32 maxv = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->volume > maxv) { + which = boxp; + maxv = boxp->volume; + } + } + return which; +} + + +LOCAL(void) +update_box (j_decompress_ptr cinfo, boxptr boxp) +/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ +/* and recompute its volume and population */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + INT32 dist0,dist1,dist2; + long ccount; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + if (c0max > c0min) + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0min = c0min = c0; + goto have_c0min; + } + } + have_c0min: + if (c0max > c0min) + for (c0 = c0max; c0 >= c0min; c0--) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0max = c0max = c0; + goto have_c0max; + } + } + have_c0max: + if (c1max > c1min) + for (c1 = c1min; c1 <= c1max; c1++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1min = c1min = c1; + goto have_c1min; + } + } + have_c1min: + if (c1max > c1min) + for (c1 = c1max; c1 >= c1min; c1--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1max = c1max = c1; + goto have_c1max; + } + } + have_c1max: + if (c2max > c2min) + for (c2 = c2min; c2 <= c2max; c2++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2min = c2min = c2; + goto have_c2min; + } + } + have_c2min: + if (c2max > c2min) + for (c2 = c2max; c2 >= c2min; c2--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2max = c2max = c2; + goto have_c2max; + } + } + have_c2max: + + /* Update box volume. + * We use 2-norm rather than real volume here; this biases the method + * against making long narrow boxes, and it has the side benefit that + * a box is splittable iff norm > 0. + * Since the differences are expressed in histogram-cell units, + * we have to shift back to JSAMPLE units to get consistent distances; + * after which, we scale according to the selected distance scale factors. + */ + dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; + dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; + dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; + boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; + + /* Now scan remaining volume of box and compute population */ + ccount = 0; + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++, histp++) + if (*histp != 0) { + ccount++; + } + } + boxp->colorcount = ccount; +} + + +LOCAL(int) +median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, + int desired_colors) +/* Repeatedly select and split the largest box until we have enough boxes */ +{ + int n,lb; + int c0,c1,c2,cmax; + register boxptr b1,b2; + + while (numboxes < desired_colors) { + /* Select box to split. + * Current algorithm: by population for first half, then by volume. + */ + if (numboxes*2 <= desired_colors) { + b1 = find_biggest_color_pop(boxlist, numboxes); + } else { + b1 = find_biggest_volume(boxlist, numboxes); + } + if (b1 == NULL) /* no splittable boxes left! */ + break; + b2 = &boxlist[numboxes]; /* where new box will go */ + /* Copy the color bounds to the new box. */ + b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; + b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; + /* Choose which axis to split the box on. + * Current algorithm: longest scaled axis. + * See notes in update_box about scaling distances. + */ + c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; + c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; + c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; + /* We want to break any ties in favor of green, then red, blue last. + * This code does the right thing for R,G,B or B,G,R color orders only. + */ +#if RGB_RED == 0 + cmax = c1; n = 1; + if (c0 > cmax) { cmax = c0; n = 0; } + if (c2 > cmax) { n = 2; } +#else + cmax = c1; n = 1; + if (c2 > cmax) { cmax = c2; n = 2; } + if (c0 > cmax) { n = 0; } +#endif + /* Choose split point along selected axis, and update box bounds. + * Current algorithm: split at halfway point. + * (Since the box has been shrunk to minimum volume, + * any split will produce two nonempty subboxes.) + * Note that lb value is max for lower box, so must be < old max. + */ + switch (n) { + case 0: + lb = (b1->c0max + b1->c0min) / 2; + b1->c0max = lb; + b2->c0min = lb+1; + break; + case 1: + lb = (b1->c1max + b1->c1min) / 2; + b1->c1max = lb; + b2->c1min = lb+1; + break; + case 2: + lb = (b1->c2max + b1->c2min) / 2; + b1->c2max = lb; + b2->c2min = lb+1; + break; + } + /* Update stats for boxes */ + update_box(cinfo, b1); + update_box(cinfo, b2); + numboxes++; + } + return numboxes; +} + + +LOCAL(void) +compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) +/* Compute representative color for a box, put it in colormap[icolor] */ +{ + /* Current algorithm: mean weighted by pixels (not colors) */ + /* Note it is important to get the rounding correct! */ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + long count; + long total = 0; + long c0total = 0; + long c1total = 0; + long c2total = 0; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) { + if ((count = *histp++) != 0) { + total += count; + c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; + c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; + c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; + } + } + } + + cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); + cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); + cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); +} + + +LOCAL(void) +select_colors (j_decompress_ptr cinfo, int desired_colors) +/* Master routine for color selection */ +{ + boxptr boxlist; + int numboxes; + int i; + + /* Allocate workspace for box list */ + boxlist = (boxptr) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); + /* Initialize one box containing whole space */ + numboxes = 1; + boxlist[0].c0min = 0; + boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; + boxlist[0].c1min = 0; + boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; + boxlist[0].c2min = 0; + boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; + /* Shrink it to actually-used volume and set its statistics */ + update_box(cinfo, & boxlist[0]); + /* Perform median-cut to produce final box list */ + numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); + /* Compute the representative color for each box, fill colormap */ + for (i = 0; i < numboxes; i++) + compute_color(cinfo, & boxlist[i], i); + cinfo->actual_number_of_colors = numboxes; + TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); +} + + +/* + * These routines are concerned with the time-critical task of mapping input + * colors to the nearest color in the selected colormap. + * + * We re-use the histogram space as an "inverse color map", essentially a + * cache for the results of nearest-color searches. All colors within a + * histogram cell will be mapped to the same colormap entry, namely the one + * closest to the cell's center. This may not be quite the closest entry to + * the actual input color, but it's almost as good. A zero in the cache + * indicates we haven't found the nearest color for that cell yet; the array + * is cleared to zeroes before starting the mapping pass. When we find the + * nearest color for a cell, its colormap index plus one is recorded in the + * cache for future use. The pass2 scanning routines call fill_inverse_cmap + * when they need to use an unfilled entry in the cache. + * + * Our method of efficiently finding nearest colors is based on the "locally + * sorted search" idea described by Heckbert and on the incremental distance + * calculation described by Spencer W. Thomas in chapter III.1 of Graphics + * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that + * the distances from a given colormap entry to each cell of the histogram can + * be computed quickly using an incremental method: the differences between + * distances to adjacent cells themselves differ by a constant. This allows a + * fairly fast implementation of the "brute force" approach of computing the + * distance from every colormap entry to every histogram cell. Unfortunately, + * it needs a work array to hold the best-distance-so-far for each histogram + * cell (because the inner loop has to be over cells, not colormap entries). + * The work array elements have to be INT32s, so the work array would need + * 256Kb at our recommended precision. This is not feasible in DOS machines. + * + * To get around these problems, we apply Thomas' method to compute the + * nearest colors for only the cells within a small subbox of the histogram. + * The work array need be only as big as the subbox, so the memory usage + * problem is solved. Furthermore, we need not fill subboxes that are never + * referenced in pass2; many images use only part of the color gamut, so a + * fair amount of work is saved. An additional advantage of this + * approach is that we can apply Heckbert's locality criterion to quickly + * eliminate colormap entries that are far away from the subbox; typically + * three-fourths of the colormap entries are rejected by Heckbert's criterion, + * and we need not compute their distances to individual cells in the subbox. + * The speed of this approach is heavily influenced by the subbox size: too + * small means too much overhead, too big loses because Heckbert's criterion + * can't eliminate as many colormap entries. Empirically the best subbox + * size seems to be about 1/512th of the histogram (1/8th in each direction). + * + * Thomas' article also describes a refined method which is asymptotically + * faster than the brute-force method, but it is also far more complex and + * cannot efficiently be applied to small subboxes. It is therefore not + * useful for programs intended to be portable to DOS machines. On machines + * with plenty of memory, filling the whole histogram in one shot with Thomas' + * refined method might be faster than the present code --- but then again, + * it might not be any faster, and it's certainly more complicated. + */ + + +/* log2(histogram cells in update box) for each axis; this can be adjusted */ +#define BOX_C0_LOG (HIST_C0_BITS-3) +#define BOX_C1_LOG (HIST_C1_BITS-3) +#define BOX_C2_LOG (HIST_C2_BITS-3) + +#define BOX_C0_ELEMS (1<actual_number_of_colors; + int maxc0, maxc1, maxc2; + int centerc0, centerc1, centerc2; + int i, x, ncolors; + INT32 minmaxdist, min_dist, max_dist, tdist; + INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ + + /* Compute true coordinates of update box's upper corner and center. + * Actually we compute the coordinates of the center of the upper-corner + * histogram cell, which are the upper bounds of the volume we care about. + * Note that since ">>" rounds down, the "center" values may be closer to + * min than to max; hence comparisons to them must be "<=", not "<". + */ + maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); + centerc0 = (minc0 + maxc0) >> 1; + maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); + centerc1 = (minc1 + maxc1) >> 1; + maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); + centerc2 = (minc2 + maxc2) >> 1; + + /* For each color in colormap, find: + * 1. its minimum squared-distance to any point in the update box + * (zero if color is within update box); + * 2. its maximum squared-distance to any point in the update box. + * Both of these can be found by considering only the corners of the box. + * We save the minimum distance for each color in mindist[]; + * only the smallest maximum distance is of interest. + */ + minmaxdist = 0x7FFFFFFFL; + + for (i = 0; i < numcolors; i++) { + /* We compute the squared-c0-distance term, then add in the other two. */ + x = GETJSAMPLE(cinfo->colormap[0][i]); + if (x < minc0) { + tdist = (x - minc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else if (x > maxc0) { + tdist = (x - maxc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + min_dist = 0; + if (x <= centerc0) { + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[1][i]); + if (x < minc1) { + tdist = (x - minc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc1) { + tdist = (x - maxc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc1) { + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } + } + + x = GETJSAMPLE(cinfo->colormap[2][i]); + if (x < minc2) { + tdist = (x - minc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc2) { + tdist = (x - maxc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc2) { + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } + } + + mindist[i] = min_dist; /* save away the results */ + if (max_dist < minmaxdist) + minmaxdist = max_dist; + } + + /* Now we know that no cell in the update box is more than minmaxdist + * away from some colormap entry. Therefore, only colors that are + * within minmaxdist of some part of the box need be considered. + */ + ncolors = 0; + for (i = 0; i < numcolors; i++) { + if (mindist[i] <= minmaxdist) + colorlist[ncolors++] = (JSAMPLE) i; + } + return ncolors; +} + + +LOCAL(void) +find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, + int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) +/* Find the closest colormap entry for each cell in the update box, + * given the list of candidate colors prepared by find_nearby_colors. + * Return the indexes of the closest entries in the bestcolor[] array. + * This routine uses Thomas' incremental distance calculation method to + * find the distance from a colormap entry to successive cells in the box. + */ +{ + int ic0, ic1, ic2; + int i, icolor; + register INT32 * bptr; /* pointer into bestdist[] array */ + JSAMPLE * cptr; /* pointer into bestcolor[] array */ + INT32 dist0, dist1; /* initial distance values */ + register INT32 dist2; /* current distance in inner loop */ + INT32 xx0, xx1; /* distance increments */ + register INT32 xx2; + INT32 inc0, inc1, inc2; /* initial values for increments */ + /* This array holds the distance to the nearest-so-far color for each cell */ + INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Initialize best-distance for each cell of the update box */ + bptr = bestdist; + for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) + *bptr++ = 0x7FFFFFFFL; + + /* For each color selected by find_nearby_colors, + * compute its distance to the center of each cell in the box. + * If that's less than best-so-far, update best distance and color number. + */ + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) +#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) +#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) + + for (i = 0; i < numcolors; i++) { + icolor = GETJSAMPLE(colorlist[i]); + /* Compute (square of) distance from minc0/c1/c2 to this color */ + inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; + dist0 = inc0*inc0; + inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; + dist0 += inc1*inc1; + inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; + dist0 += inc2*inc2; + /* Form the initial difference increments */ + inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; + inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; + inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; + /* Now loop over all cells in box, updating distance per Thomas method */ + bptr = bestdist; + cptr = bestcolor; + xx0 = inc0; + for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { + dist1 = dist0; + xx1 = inc1; + for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { + dist2 = dist1; + xx2 = inc2; + for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { + if (dist2 < *bptr) { + *bptr = dist2; + *cptr = (JSAMPLE) icolor; + } + dist2 += xx2; + xx2 += 2 * STEP_C2 * STEP_C2; + bptr++; + cptr++; + } + dist1 += xx1; + xx1 += 2 * STEP_C1 * STEP_C1; + } + dist0 += xx0; + xx0 += 2 * STEP_C0 * STEP_C0; + } + } +} + + +LOCAL(void) +fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) +/* Fill the inverse-colormap entries in the update box that contains */ +/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ +/* we can fill as many others as we wish.) */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int minc0, minc1, minc2; /* lower left corner of update box */ + int ic0, ic1, ic2; + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ + /* This array lists the candidate colormap indexes. */ + JSAMPLE colorlist[MAXNUMCOLORS]; + int numcolors; /* number of candidate colors */ + /* This array holds the actually closest colormap index for each cell. */ + JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Convert cell coordinates to update box ID */ + c0 >>= BOX_C0_LOG; + c1 >>= BOX_C1_LOG; + c2 >>= BOX_C2_LOG; + + /* Compute true coordinates of update box's origin corner. + * Actually we compute the coordinates of the center of the corner + * histogram cell, which are the lower bounds of the volume we care about. + */ + minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); + minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); + minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); + + /* Determine which colormap entries are close enough to be candidates + * for the nearest entry to some cell in the update box. + */ + numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); + + /* Determine the actually nearest colors. */ + find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, + bestcolor); + + /* Save the best color numbers (plus 1) in the main cache array */ + c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ + c1 <<= BOX_C1_LOG; + c2 <<= BOX_C2_LOG; + cptr = bestcolor; + for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { + for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { + cachep = & histogram[c0+ic0][c1+ic1][c2]; + for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { + *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); + } + } + } +} + + +/* + * Map some rows of pixels to the output colormapped representation. + */ + +METHODDEF(void) +pass2_no_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs no dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register JSAMPROW inptr, outptr; + register histptr cachep; + register int c0, c1, c2; + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + for (col = width; col > 0; col--) { + /* get pixel value and index into the cache */ + c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; + c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; + c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; + cachep = & histogram[c0][c1][c2]; + /* If we have not seen this color before, find nearest colormap entry */ + /* and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, c0,c1,c2); + /* Now emit the colormap index for this cell */ + *outptr++ = (JSAMPLE) (*cachep - 1); + } + } +} + + +METHODDEF(void) +pass2_fs_dither (j_decompress_ptr cinfo, + JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) +/* This version performs Floyd-Steinberg dithering */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ + LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + JSAMPROW inptr; /* => current input pixel */ + JSAMPROW outptr; /* => current output pixel */ + histptr cachep; + int dir; /* +1 or -1 depending on direction */ + int dir3; /* 3*dir, for advancing inptr & errorptr */ + int row; + JDIMENSION col; + JDIMENSION width = cinfo->output_width; + JSAMPLE *range_limit = cinfo->sample_range_limit; + int *error_limit = cquantize->error_limiter; + JSAMPROW colormap0 = cinfo->colormap[0]; + JSAMPROW colormap1 = cinfo->colormap[1]; + JSAMPROW colormap2 = cinfo->colormap[2]; + SHIFT_TEMPS + + for (row = 0; row < num_rows; row++) { + inptr = input_buf[row]; + outptr = output_buf[row]; + if (cquantize->on_odd_row) { + /* work right to left in this row */ + inptr += (width-1) * 3; /* so point to rightmost pixel */ + outptr += width-1; + dir = -1; + dir3 = -3; + errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ + cquantize->on_odd_row = FALSE; /* flip for next time */ + } else { + /* work left to right in this row */ + dir = 1; + dir3 = 3; + errorptr = cquantize->fserrors; /* => entry before first real column */ + cquantize->on_odd_row = TRUE; /* flip for next time */ + } + /* Preset error values: no error propagated to first pixel from left */ + cur0 = cur1 = cur2 = 0; + /* and no error propagated to row below yet */ + belowerr0 = belowerr1 = belowerr2 = 0; + bpreverr0 = bpreverr1 = bpreverr2 = 0; + + for (col = width; col > 0; col--) { + /* curN holds the error propagated from the previous pixel on the + * current line. Add the error propagated from the previous line + * to form the complete error correction term for this pixel, and + * round the error term (which is expressed * 16) to an integer. + * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct + * for either sign of the error value. + * Note: errorptr points to *previous* column's array entry. + */ + cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); + cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); + cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); + /* Limit the error using transfer function set by init_error_limit. + * See comments with init_error_limit for rationale. + */ + cur0 = error_limit[cur0]; + cur1 = error_limit[cur1]; + cur2 = error_limit[cur2]; + /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. + * The maximum error is +- MAXJSAMPLE (or less with error limiting); + * this sets the required size of the range_limit array. + */ + cur0 += GETJSAMPLE(inptr[0]); + cur1 += GETJSAMPLE(inptr[1]); + cur2 += GETJSAMPLE(inptr[2]); + cur0 = GETJSAMPLE(range_limit[cur0]); + cur1 = GETJSAMPLE(range_limit[cur1]); + cur2 = GETJSAMPLE(range_limit[cur2]); + /* Index into the cache with adjusted pixel value */ + cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; + /* If we have not seen this color before, find nearest colormap */ + /* entry and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); + /* Now emit the colormap index for this cell */ + { register int pixcode = *cachep - 1; + *outptr = (JSAMPLE) pixcode; + /* Compute representation error for this pixel */ + cur0 -= GETJSAMPLE(colormap0[pixcode]); + cur1 -= GETJSAMPLE(colormap1[pixcode]); + cur2 -= GETJSAMPLE(colormap2[pixcode]); + } + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + { register LOCFSERROR bnexterr, delta; + + bnexterr = cur0; /* Process component 0 */ + delta = cur0 * 2; + cur0 += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr0 + cur0); + cur0 += delta; /* form error * 5 */ + bpreverr0 = belowerr0 + cur0; + belowerr0 = bnexterr; + cur0 += delta; /* form error * 7 */ + bnexterr = cur1; /* Process component 1 */ + delta = cur1 * 2; + cur1 += delta; /* form error * 3 */ + errorptr[1] = (FSERROR) (bpreverr1 + cur1); + cur1 += delta; /* form error * 5 */ + bpreverr1 = belowerr1 + cur1; + belowerr1 = bnexterr; + cur1 += delta; /* form error * 7 */ + bnexterr = cur2; /* Process component 2 */ + delta = cur2 * 2; + cur2 += delta; /* form error * 3 */ + errorptr[2] = (FSERROR) (bpreverr2 + cur2); + cur2 += delta; /* form error * 5 */ + bpreverr2 = belowerr2 + cur2; + belowerr2 = bnexterr; + cur2 += delta; /* form error * 7 */ + } + /* At this point curN contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + inptr += dir3; /* Advance pixel pointers to next column */ + outptr += dir; + errorptr += dir3; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error values into the + * final fserrors[] entry. Note we need not unload belowerrN because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ + errorptr[1] = (FSERROR) bpreverr1; + errorptr[2] = (FSERROR) bpreverr2; + } +} + + +/* + * Initialize the error-limiting transfer function (lookup table). + * The raw F-S error computation can potentially compute error values of up to + * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be + * much less, otherwise obviously wrong pixels will be created. (Typical + * effects include weird fringes at color-area boundaries, isolated bright + * pixels in a dark area, etc.) The standard advice for avoiding this problem + * is to ensure that the "corners" of the color cube are allocated as output + * colors; then repeated errors in the same direction cannot cause cascading + * error buildup. However, that only prevents the error from getting + * completely out of hand; Aaron Giles reports that error limiting improves + * the results even with corner colors allocated. + * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty + * well, but the smoother transfer function used below is even better. Thanks + * to Aaron Giles for this idea. + */ + +LOCAL(void) +init_error_limit (j_decompress_ptr cinfo) +/* Allocate and fill in the error_limiter table */ +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + int * table; + int in, out; + + table = (int *) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); + table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ + cquantize->error_limiter = table; + +#define STEPSIZE ((MAXJSAMPLE+1)/16) + /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ + out = 0; + for (in = 0; in < STEPSIZE; in++, out++) { + table[in] = out; table[-in] = -out; + } + /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ + for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { + table[in] = out; table[-in] = -out; + } + /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ + for (; in <= MAXJSAMPLE; in++) { + table[in] = out; table[-in] = -out; + } +#undef STEPSIZE +} + + +/* + * Finish up at the end of each pass. + */ + +METHODDEF(void) +finish_pass1 (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Select the representative colors and fill in cinfo->colormap */ + cinfo->colormap = cquantize->sv_colormap; + select_colors(cinfo, cquantize->desired); + /* Force next pass to zero the color index table */ + cquantize->needs_zeroed = TRUE; +} + + +METHODDEF(void) +finish_pass2 (j_decompress_ptr cinfo) +{ + /* no work */ +} + + +/* + * Initialize for each processing pass. + */ + +METHODDEF(void) +start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + hist3d histogram = cquantize->histogram; + int i; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + if (is_pre_scan) { + /* Set up method pointers */ + cquantize->pub.color_quantize = prescan_quantize; + cquantize->pub.finish_pass = finish_pass1; + cquantize->needs_zeroed = TRUE; /* Always zero histogram */ + } else { + /* Set up method pointers */ + if (cinfo->dither_mode == JDITHER_FS) + cquantize->pub.color_quantize = pass2_fs_dither; + else + cquantize->pub.color_quantize = pass2_no_dither; + cquantize->pub.finish_pass = finish_pass2; + + /* Make sure color count is acceptable */ + i = cinfo->actual_number_of_colors; + if (i < 1) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); + if (i > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + + if (cinfo->dither_mode == JDITHER_FS) { + size_t arraysize = (size_t) ((cinfo->output_width + 2) * + (3 * SIZEOF(FSERROR))); + /* Allocate Floyd-Steinberg workspace if we didn't already. */ + if (cquantize->fserrors == NULL) + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); + /* Initialize the propagated errors to zero. */ + jzero_far((void FAR *) cquantize->fserrors, arraysize); + /* Make the error-limit table if we didn't already. */ + if (cquantize->error_limiter == NULL) + init_error_limit(cinfo); + cquantize->on_odd_row = FALSE; + } + + } + /* Zero the histogram or inverse color map, if necessary */ + if (cquantize->needs_zeroed) { + for (i = 0; i < HIST_C0_ELEMS; i++) { + jzero_far((void FAR *) histogram[i], + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = FALSE; + } +} + + +/* + * Switch to a new external colormap between output passes. + */ + +METHODDEF(void) +new_color_map_2_quant (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; + + /* Reset the inverse color map */ + cquantize->needs_zeroed = TRUE; +} + + +/* + * Module initialization routine for 2-pass color quantization. + */ + +GLOBAL(void) +jinit_2pass_quantizer (j_decompress_ptr cinfo) +{ + my_cquantize_ptr cquantize; + int i; + + cquantize = (my_cquantize_ptr) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, + SIZEOF(my_cquantizer)); + cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; + cquantize->pub.start_pass = start_pass_2_quant; + cquantize->pub.new_color_map = new_color_map_2_quant; + cquantize->fserrors = NULL; /* flag optional arrays not allocated */ + cquantize->error_limiter = NULL; + + /* Make sure jdmaster didn't give me a case I can't handle */ + if (cinfo->out_color_components != 3) + ERREXIT(cinfo, JERR_NOTIMPL); + + /* Allocate the histogram/inverse colormap storage */ + cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); + for (i = 0; i < HIST_C0_ELEMS; i++) { + cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); + } + cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ + + /* Allocate storage for the completed colormap, if required. + * We do this now since it is FAR storage and may affect + * the memory manager's space calculations. + */ + if (cinfo->enable_2pass_quant) { + /* Make sure color count is acceptable */ + int desired = cinfo->desired_number_of_colors; + /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ + if (desired < 8) + ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); + /* Make sure colormap indexes can be represented by JSAMPLEs */ + if (desired > MAXNUMCOLORS) + ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); + cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) + ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); + cquantize->desired = desired; + } else + cquantize->sv_colormap = NULL; + + /* Only F-S dithering or no dithering is supported. */ + /* If user asks for ordered dither, give him F-S. */ + if (cinfo->dither_mode != JDITHER_NONE) + cinfo->dither_mode = JDITHER_FS; + + /* Allocate Floyd-Steinberg workspace if necessary. + * This isn't really needed until pass 2, but again it is FAR storage. + * Although we will cope with a later change in dither_mode, + * we do not promise to honor max_memory_to_use if dither_mode changes. + */ + if (cinfo->dither_mode == JDITHER_FS) { + cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) + ((j_common_ptr) cinfo, JPOOL_IMAGE, + (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); + /* Might as well create the error-limiting table too. */ + init_error_limit(cinfo); + } +} + +#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/libraries/external/jpeglib/jquant2.o b/libraries/external/jpeglib/jquant2.o new file mode 100644 index 0000000..c611c9f Binary files /dev/null and b/libraries/external/jpeglib/jquant2.o differ diff --git a/libraries/external/jpeglib/jutils.c b/libraries/external/jpeglib/jutils.c new file mode 100755 index 0000000..286cda2 --- /dev/null +++ b/libraries/external/jpeglib/jutils.c @@ -0,0 +1,179 @@ +/* + * jutils.c + * + * Copyright (C) 1991-1996, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains tables and miscellaneous utility routines needed + * for both compression and decompression. + * Note we prefix all global names with "j" to minimize conflicts with + * a surrounding application. + */ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + + +/* + * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element + * of a DCT block read in natural order (left to right, top to bottom). + */ + +#if 0 /* This table is not actually needed in v6a */ + +const int jpeg_zigzag_order[DCTSIZE2] = { + 0, 1, 5, 6, 14, 15, 27, 28, + 2, 4, 7, 13, 16, 26, 29, 42, + 3, 8, 12, 17, 25, 30, 41, 43, + 9, 11, 18, 24, 31, 40, 44, 53, + 10, 19, 23, 32, 39, 45, 52, 54, + 20, 22, 33, 38, 46, 51, 55, 60, + 21, 34, 37, 47, 50, 56, 59, 61, + 35, 36, 48, 49, 57, 58, 62, 63 +}; + +#endif + +/* + * jpeg_natural_order[i] is the natural-order position of the i'th element + * of zigzag order. + * + * When reading corrupted data, the Huffman decoders could attempt + * to reference an entry beyond the end of this array (if the decoded + * zero run length reaches past the end of the block). To prevent + * wild stores without adding an inner-loop test, we put some extra + * "63"s after the real entries. This will cause the extra coefficient + * to be stored in location 63 of the block, not somewhere random. + * The worst case would be a run-length of 15, which means we need 16 + * fake entries. + */ + +const int jpeg_natural_order[DCTSIZE2+16] = { + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ + 63, 63, 63, 63, 63, 63, 63, 63 +}; + + +/* + * Arithmetic utilities + */ + +GLOBAL(long) +jdiv_round_up (long a, long b) +/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ +/* Assumes a >= 0, b > 0 */ +{ + return (a + b - 1L) / b; +} + + +GLOBAL(long) +jround_up (long a, long b) +/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ +/* Assumes a >= 0, b > 0 */ +{ + a += b - 1L; + return a - (a % b); +} + + +/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays + * and coefficient-block arrays. This won't work on 80x86 because the arrays + * are FAR and we're assuming a small-pointer memory model. However, some + * DOS compilers provide far-pointer versions of memcpy() and memset() even + * in the small-model libraries. These will be used if USE_FMEM is defined. + * Otherwise, the routines below do it the hard way. (The performance cost + * is not all that great, because these routines aren't very heavily used.) + */ + +#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ +#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) +#define FMEMZERO(target,size) MEMZERO(target,size) +#else /* 80x86 case, define if we can */ +#ifdef USE_FMEM +#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) +#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) +#endif +#endif + + +GLOBAL(void) +jcopy_sample_rows (JSAMPARRAY input_array, int source_row, + JSAMPARRAY output_array, int dest_row, + int num_rows, JDIMENSION num_cols) +/* Copy some rows of samples from one place to another. + * num_rows rows are copied from input_array[source_row++] + * to output_array[dest_row++]; these areas may overlap for duplication. + * The source and destination arrays must be at least as wide as num_cols. + */ +{ + register JSAMPROW inptr, outptr; +#ifdef FMEMCOPY + register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); +#else + register JDIMENSION count; +#endif + register int row; + + input_array += source_row; + output_array += dest_row; + + for (row = num_rows; row > 0; row--) { + inptr = *input_array++; + outptr = *output_array++; +#ifdef FMEMCOPY + FMEMCOPY(outptr, inptr, count); +#else + for (count = num_cols; count > 0; count--) + *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ +#endif + } +} + + +GLOBAL(void) +jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks) +/* Copy a row of coefficient blocks from one place to another. */ +{ +#ifdef FMEMCOPY + FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); +#else + register JCOEFPTR inptr, outptr; + register long count; + + inptr = (JCOEFPTR) input_row; + outptr = (JCOEFPTR) output_row; + for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { + *outptr++ = *inptr++; + } +#endif +} + + +GLOBAL(void) +jzero_far (void FAR * target, size_t bytestozero) +/* Zero out a chunk of FAR memory. */ +/* This might be sample-array data, block-array data, or alloc_large data. */ +{ +#ifdef FMEMZERO + FMEMZERO(target, bytestozero); +#else + register char FAR * ptr = (char FAR *) target; + register size_t count; + + for (count = bytestozero; count > 0; count--) { + *ptr++ = 0; + } +#endif +} diff --git a/libraries/external/jpeglib/jutils.o b/libraries/external/jpeglib/jutils.o new file mode 100644 index 0000000..53bb614 Binary files /dev/null and b/libraries/external/jpeglib/jutils.o differ diff --git a/libraries/external/jpeglib/jversion.h b/libraries/external/jpeglib/jversion.h new file mode 100755 index 0000000..dadd453 --- /dev/null +++ b/libraries/external/jpeglib/jversion.h @@ -0,0 +1,14 @@ +/* + * jversion.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains software version identification. + */ + + +#define JVERSION "6b 27-Mar-1998" + +#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" diff --git a/libraries/external/jpeglib/makefile b/libraries/external/jpeglib/makefile new file mode 100755 index 0000000..c7888bc --- /dev/null +++ b/libraries/external/jpeglib/makefile @@ -0,0 +1,115 @@ +# Makefile for Independent JPEG Group's software + +# This makefile is suitable for Unix-like systems with non-ANSI compilers. +# If you have an ANSI compiler, makefile.ansi is a better starting point. + +# Read installation instructions before saying "make" !! + +# The name of your C compiler: +CC= cc + +# You may need to adjust these cc options: +CFLAGS= -O +# Generally, we recommend defining any configuration symbols in jconfig.h, +# NOT via -D switches here. +# However, any special defines for ansi2knr.c may be included here: +ANSI2KNRFLAGS= + +# Link-time cc options: +LDFLAGS= + +# To link any special libraries, add the necessary -l commands here. +LDLIBS= + +# Put here the object file name for the correct system-dependent memory +# manager file. For Unix this is usually jmemnobs.o, but you may want +# to use jmemansi.o or jmemname.o if you have limited swap space. +SYSDEPMEM= jmemnobs.o + +# miscellaneous OS-dependent stuff +# linker +LN= $(CC) + +# End of configurable options. + +TARGETLIB = jpeglib.a + +# library object files common to compression and decompression +COMOBJECTS= jcomapi.o jutils.o jerror.o jmemmgr.o $(SYSDEPMEM) + +# compression library object files +CLIBOBJECTS= jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o \ + jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o \ + jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o \ + jfdctint.o +# decompression library object files +DLIBOBJECTS= jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o \ + jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o \ + jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o \ + jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o +# These objectfiles are included in jpeglib.a +LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS) + +all: $(TARGETLIB) + +$(TARGETLIB): $(LIBOBJECTS) makefile + ar rs $(TARGETLIB) $(LIBOBJECTS) + cp $(TARGETLIB) /g3/lib + cp jpeglib.h /g3/include + cp jconfig.h /g3/include + cp jmorecfg.h /g3/include + +clean: + -rm *.o jpeglib.a + + +jcapimin.o: jcapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcapistd.o: jcapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccoefct.o: jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jccolor.o: jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcdctmgr.o: jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jchuff.o: jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcinit.o: jcinit.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmainct.o: jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmarker.o: jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcmaster.o: jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcomapi.o: jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcparam.o: jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcphuff.o: jcphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jchuff.h +jcprepct.o: jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jcsample.o: jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jctrans.o: jctrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapimin.o: jdapimin.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdapistd.o: jdapistd.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdatadst.o: jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdatasrc.o: jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h +jdcoefct.o: jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdcolor.o: jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jddctmgr.o: jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jdhuff.o: jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdinput.o: jdinput.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmainct.o: jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmarker.o: jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmaster.o: jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdmerge.o: jdmerge.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdphuff.o: jdphuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdhuff.h +jdpostct.o: jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdsample.o: jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jdtrans.o: jdtrans.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jerror.o: jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h +jfdctflt.o: jfdctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctfst.o: jfdctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jfdctint.o: jfdctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctflt.o: jidctflt.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctfst.o: jidctfst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctint.o: jidctint.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jidctred.o: jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h +jquant1.o: jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jquant2.o: jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jutils.o: jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h +jmemmgr.o: jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemansi.o: jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemname.o: jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemnobs.o: jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemdos.o: jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h +jmemmac.o: jmemmac.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h diff --git a/libraries/external/jpeglib/mssccprj.scc b/libraries/external/jpeglib/mssccprj.scc new file mode 100755 index 0000000..6489dfd --- /dev/null +++ b/libraries/external/jpeglib/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[jpeglib.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/external/jpeglib", TKJAAAAA diff --git a/libraries/external/jpeglib/vssver.scc b/libraries/external/jpeglib/vssver.scc new file mode 100755 index 0000000..cfdc95a Binary files /dev/null and b/libraries/external/jpeglib/vssver.scc differ diff --git a/libraries/external/libhid/README.txt b/libraries/external/libhid/README.txt new file mode 100755 index 0000000..1714d01 --- /dev/null +++ b/libraries/external/libhid/README.txt @@ -0,0 +1,21 @@ +libhid - linux HID device library + +This is a linux-only library so there are no windows files here. + +LINUX BUILD INSTRUCTIONS: + +1) this library uses libusb, so you should build and install that library first + +2) at prompt type: export PATH="/g3/libusb/bin:$PATH" + this directs the build process to use '/g3/libusb/bin/libusb-config' + instead of the default ('/usr/bin/libusb-config') which in turn + directs the compiler to use the version of the libusb libraries and headers + in /g3/libusb instead of the rusty old version of libusb installed in /usr/lib + + +3) gunzip and untar the src tarball + +4) run ./configure --prefix=/g3/libhid --disable-shared + we don't use the shared lib so don't bother building it. + +5) run make and make install diff --git a/libraries/external/libhid/include/hid.h b/libraries/external/libhid/include/hid.h new file mode 100755 index 0000000..9f47587 --- /dev/null +++ b/libraries/external/libhid/include/hid.h @@ -0,0 +1,197 @@ +#ifndef __INCLUDED_HID_H__ +#define __INCLUDED_HID_H__ + +#include +#include +#include + +/*!@file + * @brief Main libhid API header file + * + * This header file forms the public API for libhid. Functions not prototyped + * here are most likely for internal use only, and may change without notice. + */ + +#ifndef byte + typedef unsigned char byte; +#endif + +#ifdef HAVE_STDBOOL_H +# include +#else +# define bool _Bool +# define true 1 +# define false 0 +#endif + +typedef enum hid_return_t { + HID_RET_SUCCESS = 0, + HID_RET_INVALID_PARAMETER, + HID_RET_NOT_INITIALISED, + HID_RET_ALREADY_INITIALISED, + HID_RET_FAIL_FIND_BUSSES, + HID_RET_FAIL_FIND_DEVICES, + HID_RET_FAIL_OPEN_DEVICE, + HID_RET_DEVICE_NOT_FOUND, + HID_RET_DEVICE_NOT_OPENED, + HID_RET_DEVICE_ALREADY_OPENED, + HID_RET_FAIL_CLOSE_DEVICE, + HID_RET_FAIL_CLAIM_IFACE, + HID_RET_FAIL_DETACH_DRIVER, + HID_RET_NOT_HID_DEVICE, + HID_RET_HID_DESC_SHORT, + HID_RET_REPORT_DESC_SHORT, + HID_RET_REPORT_DESC_LONG, + HID_RET_FAIL_ALLOC, + HID_RET_OUT_OF_SPACE, + HID_RET_FAIL_SET_REPORT, + HID_RET_FAIL_GET_REPORT, + HID_RET_FAIL_INT_READ, + HID_RET_NOT_FOUND, + HID_RET_TIMEOUT +} hid_return; + +struct usb_dev_handle; + +/*!@brief Interface description + * + * This structure contains information associated with a given USB device + * interface. The identification information allows multiple HID-class + * interfaces to be accessed on a single device. + * + * Also available are raw and parsed descriptor information. + */ +typedef struct HIDInterface_t { + struct usb_dev_handle *dev_handle; + struct usb_device *device; + int interface; + char id[32]; + HIDData* hid_data; + HIDParser* hid_parser; +} HIDInterface; + +typedef bool (*matcher_fn_t)(struct usb_dev_handle const* usbdev, + void* custom, unsigned int len); + +typedef struct HIDInterfaceMatcher_t { + unsigned short vendor_id; + unsigned short product_id; +#ifndef SWIG + matcher_fn_t matcher_fn; //!< Only supported in C library (not via SWIG) + void* custom_data; //!< Only used by matcher_fn + unsigned int custom_data_length; //!< Only used by matcher_fn +#endif +} HIDInterfaceMatcher; + +#define HID_ID_MATCH_ANY 0x0000 + +/*!@brief Bitmask for selection of debugging messages + * + * The values of this enumeration can be combined with the bitwise-OR operator + * to select which debug messages should be printed. The selection can be set + * with hid_set_debug(). You can set a file descriptor for error messages with + * hid_set_debug_stream(). + */ +typedef enum HIDDebugLevel_t { + HID_DEBUG_NONE = 0x0, //!< Default + HID_DEBUG_ERRORS = 0x1, //!< Serious conditions + HID_DEBUG_WARNINGS = 0x2, //!< Less serious conditions + HID_DEBUG_NOTICES = 0x4, //!< Informational messages + HID_DEBUG_TRACES = 0x8, //!< Verbose tracing of functions + HID_DEBUG_ASSERTS = 0x10, //!< Assertions for sanity checking + HID_DEBUG_NOTRACES = HID_DEBUG_ERRORS | HID_DEBUG_WARNINGS | HID_DEBUG_NOTICES | HID_DEBUG_ASSERTS, + //!< This is what you probably want to start with while developing with libhid + HID_DEBUG_ALL = HID_DEBUG_ERRORS | HID_DEBUG_WARNINGS | HID_DEBUG_NOTICES | HID_DEBUG_TRACES | HID_DEBUG_ASSERTS +} HIDDebugLevel; + +#ifdef __cplusplus +extern "C" { +#endif + +void hid_set_debug(HIDDebugLevel const level); +void hid_set_debug_stream(FILE* const outstream); +void hid_set_usb_debug(int const level); + +HIDInterface* hid_new_HIDInterface(); + +void hid_delete_HIDInterface(HIDInterface** const hidif); + +void hid_reset_HIDInterface(HIDInterface* const hidif); + +hid_return hid_init(); + +hid_return hid_cleanup(); + +bool hid_is_initialised(); + +hid_return hid_open(HIDInterface* const hidif, int const interface, + HIDInterfaceMatcher const* const matcher); +hid_return hid_force_open(HIDInterface* const hidif, int const interface, + HIDInterfaceMatcher const* const matcher, unsigned short retries); + +hid_return hid_close(HIDInterface* const hidif); + +bool hid_is_opened(HIDInterface const* const hidif); + +const char *hid_strerror(hid_return ret); + +hid_return hid_get_input_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char* const buffer, unsigned int const size); + +hid_return hid_set_output_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char const* const buffer, unsigned int const size); + +hid_return hid_get_feature_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char* const buffer, unsigned int const size); + +hid_return hid_set_feature_report(HIDInterface* const hidif, int const path[], + unsigned int const depth, char const* const buffer, unsigned int const size); + +hid_return hid_get_item_value(HIDInterface* const hidif, + int const path[], unsigned int const depth, + double *const value); + +/* +hid_return hid_get_item_string(HIDInterface* const hidif, + int const path[], unsigned int const depth, + char *const value, unsigned int const maxlen); + +hid_return hid_set_item_value(HIDInterface* const hidif, + int const path[], unsigned int const depth, + double const value); +*/ +hid_return hid_write_identification(FILE* const out, + HIDInterface const* const hidif); + +hid_return hid_dump_tree(FILE* const out, HIDInterface* const hidif); + +hid_return hid_interrupt_read(HIDInterface* const hidif, unsigned int const ep, + char* const bytes, unsigned int const size, unsigned int const timeout); + +hid_return hid_interrupt_write(HIDInterface* const hidif, unsigned int const ep, + const char* const bytes, unsigned int const size, unsigned int const timeout); + +hid_return hid_set_idle(HIDInterface * const hidif, + unsigned duration, unsigned report_id); + + +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDED_HID_H__ */ + +/* COPYRIGHT -- + * + * This file is part of libhid, a user-space HID access library. + * libhid is (c) 2003-2006 + * Martin F. Krafft + * Charles Lepple + * Arnaud Quette && + * and distributed under the terms of the GNU General Public License. + * See the file ./COPYING in the source distribution for more information. + * + * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES + * OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ diff --git a/libraries/external/libhid/include/hidparser.h b/libraries/external/libhid/include/hidparser.h new file mode 100755 index 0000000..612f59f --- /dev/null +++ b/libraries/external/libhid/include/hidparser.h @@ -0,0 +1,70 @@ +/*!@file + *@brief HID Parser header file + * + * This file is part of the MGE UPS SYSTEMS HID Parser. + * + * Copyright (C) 1998-2003 MGE UPS SYSTEMS, + * Written by Luc Descotils. + * + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* -------------------------------------------------------------------------- */ + +#ifndef HIDPARS_H +#define HIDPARS_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hidtypes.h" + +/* + * HIDParse + * -------------------------------------------------------------------------- */ +int HIDParse(HIDParser* pParser, HIDData* pData); + +/* + * ResetParser + * -------------------------------------------------------------------------- */ +void ResetParser(HIDParser* pParser); + +/* + * FindObject + * -------------------------------------------------------------------------- */ +int FindObject(HIDParser* pParser, HIDData* pData); + +/* + * GetValue + * -------------------------------------------------------------------------- */ +void GetValue(const uchar* Buf, HIDData* pData); + +/* + * SetValue + * -------------------------------------------------------------------------- */ +void SetValue(const HIDData* pData, uchar* Buf); + +/* + * GetReportOffset + * -------------------------------------------------------------------------- */ +uchar* GetReportOffset(HIDParser* pParser, const uchar ReportID, + const uchar ReportType); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif diff --git a/libraries/external/libhid/include/hidtypes.h b/libraries/external/libhid/include/hidtypes.h new file mode 100755 index 0000000..7b3fe77 --- /dev/null +++ b/libraries/external/libhid/include/hidtypes.h @@ -0,0 +1,157 @@ +/*!@file + *@brief HID parser type definitions + * + * Header GPL + * @todo Properly tag all files with GPL (as appropriate) + */ + +#ifndef TYPE_H +#define TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +/* + * Types + */ +#if !AIX +typedef unsigned char uchar; +#endif + +#if HPUX || __APPLE__ +typedef unsigned long ulong; +#endif + +typedef short wchar; + +/* + * Constants + */ +#define PATH_SIZE 10 /*!< maximum depth for Path */ +#define USAGE_TAB_SIZE 50 /*!< Size of usage stack */ + +/*! Including FEATURE, INPUT and OUTPUT */ +#define MAX_REPORT 300 + +/*! Size max of Report Descriptor */ +#define REPORT_DSC_SIZE 6144 + +/* + * Items + * -------------------------------------------------------------------------- */ +#define SIZE_0 0x00 +#define SIZE_1 0x01 +#define SIZE_2 0x02 +#define SIZE_4 0x03 +#define SIZE_MASK 0x03 + +#define TYPE_MAIN 0x00 +#define TYPE_GLOBAL 0x04 +#define TYPE_LOCAL 0x08 +#define TYPE_MASK 0x0C + +/* Main items */ +#define ITEM_COLLECTION 0xA0 +#define ITEM_END_COLLECTION 0xC0 +#define ITEM_FEATURE 0xB0 +#define ITEM_INPUT 0x80 +#define ITEM_OUTPUT 0x90 + +/* Global items */ +#define ITEM_UPAGE 0x04 +#define ITEM_LOG_MIN 0x14 +#define ITEM_LOG_MAX 0x24 +#define ITEM_PHY_MIN 0x34 +#define ITEM_PHY_MAX 0x44 +#define ITEM_UNIT_EXP 0x54 +#define ITEM_UNIT 0x64 +#define ITEM_REP_SIZE 0x74 +#define ITEM_REP_ID 0x84 +#define ITEM_REP_COUNT 0x94 + +/* Local items */ +#define ITEM_USAGE 0x08 +#define ITEM_STRING 0x78 + +/* Long item */ +#define ITEM_LONG 0xFC + +#define ITEM_MASK 0xFC + +/* Attribute Flags */ +#define ATTR_DATA_CST 0x01 +#define ATTR_NVOL_VOL 0x80 + +/*! + * Describe a HID Path point + */ +typedef struct +{ + ushort UPage; + ushort Usage; +} HIDNode; + +/*! + * Describe a HID Path + */ +typedef struct +{ + uchar Size; /*!< HID Path size */ + HIDNode Node[PATH_SIZE]; /*!< HID Path */ +} HIDPath; + +/*! + * Describe a HID Data with its location in report + */ +typedef struct +{ + long Value; /*!< HID Object Value */ + HIDPath Path; /*!< HID Path */ + + uchar ReportID; /*!< Report ID, (from incoming report) ??? */ + uchar Offset; /*!< Offset of data in report */ + uchar Size; /*!< Size of data in bit */ + + uchar Type; /*!< Type : FEATURE / INPUT / OUTPUT */ + uchar Attribute; /*!< Report field attribute */ + + ulong Unit; /*!< HID Unit */ + char UnitExp; /*!< Unit exponent */ + + long LogMin; /*!< Logical Min */ + long LogMax; /*!< Logical Max */ + long PhyMin; /*!< Physical Min */ + long PhyMax; /*!< Physical Max */ +} HIDData; + +/* -------------------------------------------------------------------------- */ +typedef struct +{ + uchar ReportDesc[REPORT_DSC_SIZE]; /*!< Store Report Descriptor */ + ushort ReportDescSize; /*!< Size of Report Descriptor */ + ushort Pos; /*!< Store current pos in descriptor */ + uchar Item; /*!< Store current Item */ + long Value; /*!< Store current Value */ + + HIDData Data; /*!< Store current environment */ + + uchar OffsetTab[MAX_REPORT][3]; /*!< Store ID, type & offset of report*/ + uchar ReportCount; /*!< Store Report Count */ + uchar Count; /*!< Store local report count */ + + ushort UPage; /*!< Global UPage */ + HIDNode UsageTab[USAGE_TAB_SIZE]; /*!< Usage stack */ + uchar UsageSize; /*!< Design number of usage used */ + + uchar nObject; /*!< Count objects in Report Descriptor */ + uchar nReport; /*!< Count reports in Report Descriptor */ +} HIDParser; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif diff --git a/libraries/external/libhid/include/vssver.scc b/libraries/external/libhid/include/vssver.scc new file mode 100755 index 0000000..fa7235d Binary files /dev/null and b/libraries/external/libhid/include/vssver.scc differ diff --git a/libraries/external/libhid/lib/libhid.a b/libraries/external/libhid/lib/libhid.a new file mode 100755 index 0000000..4ac95ec Binary files /dev/null and b/libraries/external/libhid/lib/libhid.a differ diff --git a/libraries/external/libhid/lib/libhid.la b/libraries/external/libhid/lib/libhid.la new file mode 100755 index 0000000..2242634 --- /dev/null +++ b/libraries/external/libhid/lib/libhid.la @@ -0,0 +1,35 @@ +# libhid.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libhid.a' + +# Libraries that this one depends upon. +dependency_libs=' -L/g3/libusb/lib /g3/libusb/lib/libusb.la' + +# Version information for libhid. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libhid/lib' diff --git a/libraries/external/libhid/lib/vssver.scc b/libraries/external/libhid/lib/vssver.scc new file mode 100755 index 0000000..58d4aad Binary files /dev/null and b/libraries/external/libhid/lib/vssver.scc differ diff --git a/libraries/external/libhid/libhid-0.2.16.tar.gz b/libraries/external/libhid/libhid-0.2.16.tar.gz new file mode 100755 index 0000000..7a0c339 --- /dev/null +++ b/libraries/external/libhid/libhid-0.2.16.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dcc31466f5517abf079acbd5d7715c128f66e713f21e1d21c69ee500e983cc93 +size 435245 diff --git a/libraries/external/libhid/vssver.scc b/libraries/external/libhid/vssver.scc new file mode 100755 index 0000000..0aeac8f Binary files /dev/null and b/libraries/external/libhid/vssver.scc differ diff --git a/libraries/external/libiconv/README.txt b/libraries/external/libiconv/README.txt new file mode 100755 index 0000000..dfd3c0a --- /dev/null +++ b/libraries/external/libiconv/README.txt @@ -0,0 +1,5 @@ +libiconv + +Windows headers and binaries taken from libiconv-1.9.2-1-lib.zip + +libiconv is part of default libs in linux build so there are no linux files here. diff --git a/libraries/external/libiconv/libiconv-1.11.tar.gz b/libraries/external/libiconv/libiconv-1.11.tar.gz new file mode 100755 index 0000000..3270828 --- /dev/null +++ b/libraries/external/libiconv/libiconv-1.11.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7869a97faa47ee3d4f2c56d43c349965037a5c9337d141178211cf19f3c46cb3 +size 4430930 diff --git a/libraries/external/libiconv/libiconv-1.9.2-1-bin.zip b/libraries/external/libiconv/libiconv-1.9.2-1-bin.zip new file mode 100755 index 0000000..b349b16 Binary files /dev/null and b/libraries/external/libiconv/libiconv-1.9.2-1-bin.zip differ diff --git a/libraries/external/libiconv/libiconv-1.9.2-1-lib.zip b/libraries/external/libiconv/libiconv-1.9.2-1-lib.zip new file mode 100755 index 0000000..80bd730 Binary files /dev/null and b/libraries/external/libiconv/libiconv-1.9.2-1-lib.zip differ diff --git a/libraries/external/libiconv/libiconv-1.9.2-1-src.zip b/libraries/external/libiconv/libiconv-1.9.2-1-src.zip new file mode 100755 index 0000000..116b406 Binary files /dev/null and b/libraries/external/libiconv/libiconv-1.9.2-1-src.zip differ diff --git a/libraries/external/libiconv/pc/include/iconv.h b/libraries/external/libiconv/pc/include/iconv.h new file mode 100755 index 0000000..6794206 --- /dev/null +++ b/libraries/external/libiconv/pc/include/iconv.h @@ -0,0 +1,141 @@ +/* Copyright (C) 1999-2003 Free Software Foundation, Inc. + This file is part of the GNU LIBICONV Library. + + The GNU LIBICONV Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + The GNU LIBICONV Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU LIBICONV Library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. */ + +/* When installed, this file is called "iconv.h". */ + +#ifndef _LIBICONV_H +#define _LIBICONV_H + +#define _LIBICONV_VERSION 0x0109 /* version number: (major<<8) + minor */ + +#ifdef LIBICONV_STATIC +#define LIBICONV_DLL_EXPORTED +#else /* LIBICONV_STATIC */ +#ifdef BUILDING_LIBICONV +#define LIBICONV_DLL_EXPORTED __declspec(dllexport) +#else +#define LIBICONV_DLL_EXPORTED __declspec(dllimport) +#endif +#endif /* LIBICONV_STATIC */ +extern LIBICONV_DLL_EXPORTED int _libiconv_version; /* Likewise */ + +/* We would like to #include any system header file which could define + iconv_t, 1. in order to eliminate the risk that the user gets compilation + errors because some other system header file includes /usr/include/iconv.h + which defines iconv_t or declares iconv after this file, 2. when compiling + for LIBICONV_PLUG, we need the proper iconv_t type in order to produce + binary compatible code. + But gcc's #include_next is not portable. Thus, once libiconv's iconv.h + has been installed in /usr/local/include, there is no way any more to + include the original /usr/include/iconv.h. We simply have to get away + without it. + Ad 1. The risk that a system header file does + #include "iconv.h" or #include_next "iconv.h" + is small. They all do #include . + Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It + has to be a scalar type because (iconv_t)(-1) is a possible return value + from iconv_open().) */ + +/* Define iconv_t ourselves. */ +#undef iconv_t +#define iconv_t libiconv_t +typedef void* iconv_t; + +/* Get size_t declaration. */ +#include + +/* Get errno declaration and values. */ +#include +/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, + have EILSEQ in a different header. On these systems, define EILSEQ + ourselves. */ +#ifndef EILSEQ +#define EILSEQ +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Allocates descriptor for code conversion from encoding `fromcode' to + encoding `tocode'. */ +#ifndef LIBICONV_PLUG +#define iconv_open libiconv_open +#endif +extern LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode); + +/* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes + starting at `*inbuf', writing at most `*outbytesleft' bytes starting at + `*outbuf'. + Decrements `*inbytesleft' and increments `*inbuf' by the same amount. + Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */ +#ifndef LIBICONV_PLUG +#define iconv libiconv +#endif +extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); + +/* Frees resources allocated for conversion descriptor `cd'. */ +#ifndef LIBICONV_PLUG +#define iconv_close libiconv_close +#endif +extern LIBICONV_DLL_EXPORTED int iconv_close (iconv_t cd); + + +#ifndef LIBICONV_PLUG + +/* Nonstandard extensions. */ + +/* Control of attributes. */ +#define iconvctl libiconvctl +extern LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argument); + +/* Requests for iconvctl. */ +#define ICONV_TRIVIALP 0 /* int *argument */ +#define ICONV_GET_TRANSLITERATE 1 /* int *argument */ +#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ +#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ +#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ + +/* Listing of locale independent encodings. */ +#define iconvlist libiconvlist +extern LIBICONV_DLL_EXPORTED void iconvlist (int (*do_one) (unsigned int namescount, + const char * const * names, + void* data), + void* data); + +/* Support for relocatable packages. */ + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +extern LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LIBICONV_H */ diff --git a/libraries/external/libiconv/pc/include/libcharset.h b/libraries/external/libiconv/pc/include/libcharset.h new file mode 100755 index 0000000..ddc4be0 --- /dev/null +++ b/libraries/external/libiconv/pc/include/libcharset.h @@ -0,0 +1,56 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU CHARSET Library. + + The GNU CHARSET Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU CHARSET Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with the GNU CHARSET Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _LIBCHARSET_H +#define _LIBCHARSET_H + +#ifdef LIBCHARSET_STATIC +#define LIBCHARSET_DLL_EXPORTED +#else /* LIBCHARSET_STATIC */ +#ifdef BUILDING_LIBCHARSET +#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport) +#else +#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport) +#endif +#endif /* LIBCHARSET_STATIC */ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Support for relocatable packages. */ + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +extern LIBCHARSET_DLL_EXPORTED void libcharset_set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LIBCHARSET_H */ diff --git a/libraries/external/libiconv/pc/include/localcharset.h b/libraries/external/libiconv/pc/include/localcharset.h new file mode 100755 index 0000000..44f9e8d --- /dev/null +++ b/libraries/external/libiconv/pc/include/localcharset.h @@ -0,0 +1,51 @@ +/* Determine a canonical name for the current locale's character encoding. + Copyright (C) 2000-2003 Free Software Foundation, Inc. + This file is part of the GNU CHARSET Library. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifndef _LOCALCHARSET_H +#define _LOCALCHARSET_H + +#ifdef LIBCHARSET_STATIC +#define LIBCHARSET_DLL_EXPORTED +#else /* LIBCHARSET_STATIC */ +#ifdef BUILDING_LIBCHARSET +#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport) +#else +#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport) +#endif +#endif /* LIBCHARSET_STATIC */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Determine the current locale's character encoding, and canonicalize it + into one of the canonical names listed in config.charset. + The result must not be freed; it is statically allocated. + If the canonical name cannot be determined, the result is a non-canonical + name. */ +extern LIBCHARSET_DLL_EXPORTED const char * locale_charset (void); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LOCALCHARSET_H */ diff --git a/libraries/external/libiconv/pc/include/vssver.scc b/libraries/external/libiconv/pc/include/vssver.scc new file mode 100755 index 0000000..61b0b22 Binary files /dev/null and b/libraries/external/libiconv/pc/include/vssver.scc differ diff --git a/libraries/external/libiconv/pc/lib/libcharset-bcc.lib b/libraries/external/libiconv/pc/lib/libcharset-bcc.lib new file mode 100755 index 0000000..9b20240 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libcharset-bcc.lib differ diff --git a/libraries/external/libiconv/pc/lib/libcharset.a b/libraries/external/libiconv/pc/lib/libcharset.a new file mode 100755 index 0000000..462923b Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libcharset.a differ diff --git a/libraries/external/libiconv/pc/lib/libcharset.dll.a b/libraries/external/libiconv/pc/lib/libcharset.dll.a new file mode 100755 index 0000000..0bae002 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libcharset.dll.a differ diff --git a/libraries/external/libiconv/pc/lib/libcharset.lib b/libraries/external/libiconv/pc/lib/libcharset.lib new file mode 100755 index 0000000..5bce435 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libcharset.lib differ diff --git a/libraries/external/libiconv/pc/lib/libcharset1.def b/libraries/external/libiconv/pc/lib/libcharset1.def new file mode 100755 index 0000000..a07a9b5 --- /dev/null +++ b/libraries/external/libiconv/pc/lib/libcharset1.def @@ -0,0 +1,6 @@ +; h:\mingw\3.3.1\bin\dlltool.exe --export-all-symbols --output-def=libcharset1.def localcharset.o relocatable.o libcharset-dllversion.o libcharset-dll-rc.o +EXPORTS + libcharset_relocate @ 1 ; + libcharset_set_relocation_prefix @ 2 ; + locale_charset @ 3 ; + DllGetVersion @ 4 ; diff --git a/libraries/external/libiconv/pc/lib/libiconv-bcc.lib b/libraries/external/libiconv/pc/lib/libiconv-bcc.lib new file mode 100755 index 0000000..bbd9f97 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libiconv-bcc.lib differ diff --git a/libraries/external/libiconv/pc/lib/libiconv.a b/libraries/external/libiconv/pc/lib/libiconv.a new file mode 100755 index 0000000..27f23f9 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libiconv.a differ diff --git a/libraries/external/libiconv/pc/lib/libiconv.dll.a b/libraries/external/libiconv/pc/lib/libiconv.dll.a new file mode 100755 index 0000000..d6be004 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libiconv.dll.a differ diff --git a/libraries/external/libiconv/pc/lib/libiconv.lib b/libraries/external/libiconv/pc/lib/libiconv.lib new file mode 100755 index 0000000..e974f86 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/libiconv.lib differ diff --git a/libraries/external/libiconv/pc/lib/libiconv2.def b/libraries/external/libiconv/pc/lib/libiconv2.def new file mode 100755 index 0000000..bb80dc8 --- /dev/null +++ b/libraries/external/libiconv/pc/lib/libiconv2.def @@ -0,0 +1,14 @@ +; h:\mingw\3.3.1\bin\dlltool.exe --export-all-symbols --output-def=libiconv2.def iconv.o localcharset.o relocatable.o libiconv-dllversion.o libiconv-dll-rc.o +EXPORTS + DllGetVersion @ 1 ; + _libiconv_version @ 2 DATA ; + aliases2_lookup @ 3 ; + aliases_lookup @ 4 ; + libiconv @ 5 ; + libiconv_close @ 6 ; + libiconv_open @ 7 ; + libiconv_relocate @ 8 ; + libiconv_set_relocation_prefix @ 9 ; + libiconvctl @ 10 ; + libiconvlist @ 11 ; + locale_charset @ 12 ; diff --git a/libraries/external/libiconv/pc/lib/vssver.scc b/libraries/external/libiconv/pc/lib/vssver.scc new file mode 100755 index 0000000..288b0f5 Binary files /dev/null and b/libraries/external/libiconv/pc/lib/vssver.scc differ diff --git a/libraries/external/libiconv/vssver.scc b/libraries/external/libiconv/vssver.scc new file mode 100755 index 0000000..977e20b Binary files /dev/null and b/libraries/external/libiconv/vssver.scc differ diff --git a/libraries/external/libusb/README.txt b/libraries/external/libusb/README.txt new file mode 100755 index 0000000..4e2485e --- /dev/null +++ b/libraries/external/libusb/README.txt @@ -0,0 +1,11 @@ +libusb - linux USB library + +This is a linux-only library so there are no windows files here + +LINUX BUILD INSTRUCTIONS: + +1) gunzip and untar the src tarball + +2) run ./configure --prefix=/g3/libusb + +3) run make and make install diff --git a/libraries/external/libusb/bin/libusb-config b/libraries/external/libusb/bin/libusb-config new file mode 100755 index 0000000..50af50d --- /dev/null +++ b/libraries/external/libusb/bin/libusb-config @@ -0,0 +1,79 @@ +#!/bin/sh + +prefix=/g3/libusb +exec_prefix=${prefix} +exec_prefix_set=no + +usage() +{ + cat <&2 +fi + +while test $# -gt 0; do + case "$1" in + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + case $1 in + --prefix=*) + prefix=$optarg + if test $exec_prefix_set = no ; then + exec_prefix=$optarg + fi + ;; + --prefix) + echo_prefix=yes + ;; + --exec-prefix=*) + exec_prefix=$optarg + exec_prefix_set=yes + ;; + --exec-prefix) + echo_exec_prefix=yes + ;; + --version) + echo 0.1.12 + exit 0 + ;; + --cflags) + if test "${prefix}/include" != /usr/include ; then + includes="-I${prefix}/include" + fi + echo_cflags=yes + ;; + --libs) + echo_libs=yes + ;; + *) + usage 1 1>&2 + ;; + esac + shift +done + +if test "$echo_prefix" = "yes"; then + echo $prefix +fi +if test "$echo_exec_prefix" = "yes"; then + echo $exec_prefix +fi +if test "$echo_cflags" = "yes"; then + echo $includes +fi +if test "$echo_libs" = "yes"; then + echo -L${exec_prefix}/lib -lusb +fi diff --git a/libraries/external/libusb/bin/vssver.scc b/libraries/external/libusb/bin/vssver.scc new file mode 100755 index 0000000..73e217c Binary files /dev/null and b/libraries/external/libusb/bin/vssver.scc differ diff --git a/libraries/external/libusb/include/usb.h b/libraries/external/libusb/include/usb.h new file mode 100755 index 0000000..02d1244 --- /dev/null +++ b/libraries/external/libusb/include/usb.h @@ -0,0 +1,337 @@ +/* + * Prototypes, structure definitions and macros. + * + * Copyright (c) 2000-2003 Johannes Erdfelt + * + * This library is covered by the LGPL, read LICENSE for details. + * + * This file (and only this file) may alternatively be licensed under the + * BSD license as well, read LICENSE for details. + */ +#ifndef __USB_H__ +#define __USB_H__ + +#include +#include +#include + +#include + +/* + * USB spec information + * + * This is all stuff grabbed from various USB specs and is pretty much + * not subject to change + */ + +/* + * Device and/or Interface Class codes + */ +#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ +#define USB_CLASS_AUDIO 1 +#define USB_CLASS_COMM 2 +#define USB_CLASS_HID 3 +#define USB_CLASS_PRINTER 7 +#define USB_CLASS_PTP 6 +#define USB_CLASS_MASS_STORAGE 8 +#define USB_CLASS_HUB 9 +#define USB_CLASS_DATA 10 +#define USB_CLASS_VENDOR_SPEC 0xff + +/* + * Descriptor types + */ +#define USB_DT_DEVICE 0x01 +#define USB_DT_CONFIG 0x02 +#define USB_DT_STRING 0x03 +#define USB_DT_INTERFACE 0x04 +#define USB_DT_ENDPOINT 0x05 + +#define USB_DT_HID 0x21 +#define USB_DT_REPORT 0x22 +#define USB_DT_PHYSICAL 0x23 +#define USB_DT_HUB 0x29 + +/* + * Descriptor sizes per descriptor type + */ +#define USB_DT_DEVICE_SIZE 18 +#define USB_DT_CONFIG_SIZE 9 +#define USB_DT_INTERFACE_SIZE 9 +#define USB_DT_ENDPOINT_SIZE 7 +#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ +#define USB_DT_HUB_NONVAR_SIZE 7 + +/* All standard descriptors have these 2 fields in common */ +struct usb_descriptor_header { + u_int8_t bLength; + u_int8_t bDescriptorType; +}; + +/* String descriptor */ +struct usb_string_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t wData[1]; +}; + +/* HID descriptor */ +struct usb_hid_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t bcdHID; + u_int8_t bCountryCode; + u_int8_t bNumDescriptors; + /* u_int8_t bReportDescriptorType; */ + /* u_int16_t wDescriptorLength; */ + /* ... */ +}; + +/* Endpoint descriptor */ +#define USB_MAXENDPOINTS 32 +struct usb_endpoint_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int8_t bEndpointAddress; + u_int8_t bmAttributes; + u_int16_t wMaxPacketSize; + u_int8_t bInterval; + u_int8_t bRefresh; + u_int8_t bSynchAddress; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +}; + +#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ +#define USB_ENDPOINT_DIR_MASK 0x80 + +#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ +#define USB_ENDPOINT_TYPE_CONTROL 0 +#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 +#define USB_ENDPOINT_TYPE_BULK 2 +#define USB_ENDPOINT_TYPE_INTERRUPT 3 + +/* Interface descriptor */ +#define USB_MAXINTERFACES 32 +struct usb_interface_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int8_t bInterfaceNumber; + u_int8_t bAlternateSetting; + u_int8_t bNumEndpoints; + u_int8_t bInterfaceClass; + u_int8_t bInterfaceSubClass; + u_int8_t bInterfaceProtocol; + u_int8_t iInterface; + + struct usb_endpoint_descriptor *endpoint; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +}; + +#define USB_MAXALTSETTING 128 /* Hard limit */ +struct usb_interface { + struct usb_interface_descriptor *altsetting; + + int num_altsetting; +}; + +/* Configuration descriptor information.. */ +#define USB_MAXCONFIG 8 +struct usb_config_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t wTotalLength; + u_int8_t bNumInterfaces; + u_int8_t bConfigurationValue; + u_int8_t iConfiguration; + u_int8_t bmAttributes; + u_int8_t MaxPower; + + struct usb_interface *interface; + + unsigned char *extra; /* Extra descriptors */ + int extralen; +}; + +/* Device descriptor */ +struct usb_device_descriptor { + u_int8_t bLength; + u_int8_t bDescriptorType; + u_int16_t bcdUSB; + u_int8_t bDeviceClass; + u_int8_t bDeviceSubClass; + u_int8_t bDeviceProtocol; + u_int8_t bMaxPacketSize0; + u_int16_t idVendor; + u_int16_t idProduct; + u_int16_t bcdDevice; + u_int8_t iManufacturer; + u_int8_t iProduct; + u_int8_t iSerialNumber; + u_int8_t bNumConfigurations; +}; + +struct usb_ctrl_setup { + u_int8_t bRequestType; + u_int8_t bRequest; + u_int16_t wValue; + u_int16_t wIndex; + u_int16_t wLength; +}; + +/* + * Standard requests + */ +#define USB_REQ_GET_STATUS 0x00 +#define USB_REQ_CLEAR_FEATURE 0x01 +/* 0x02 is reserved */ +#define USB_REQ_SET_FEATURE 0x03 +/* 0x04 is reserved */ +#define USB_REQ_SET_ADDRESS 0x05 +#define USB_REQ_GET_DESCRIPTOR 0x06 +#define USB_REQ_SET_DESCRIPTOR 0x07 +#define USB_REQ_GET_CONFIGURATION 0x08 +#define USB_REQ_SET_CONFIGURATION 0x09 +#define USB_REQ_GET_INTERFACE 0x0A +#define USB_REQ_SET_INTERFACE 0x0B +#define USB_REQ_SYNCH_FRAME 0x0C + +#define USB_TYPE_STANDARD (0x00 << 5) +#define USB_TYPE_CLASS (0x01 << 5) +#define USB_TYPE_VENDOR (0x02 << 5) +#define USB_TYPE_RESERVED (0x03 << 5) + +#define USB_RECIP_DEVICE 0x00 +#define USB_RECIP_INTERFACE 0x01 +#define USB_RECIP_ENDPOINT 0x02 +#define USB_RECIP_OTHER 0x03 + +/* + * Various libusb API related stuff + */ + +#define USB_ENDPOINT_IN 0x80 +#define USB_ENDPOINT_OUT 0x00 + +/* Error codes */ +#define USB_ERROR_BEGIN 500000 + +/* + * This is supposed to look weird. This file is generated from autoconf + * and I didn't want to make this too complicated. + */ +#if 0 +#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0) +#else +#define USB_LE16_TO_CPU(x) +#endif + +/* Data types */ +struct usb_device; +struct usb_bus; + +/* + * To maintain compatibility with applications already built with libusb, + * we must only add entries to the end of this structure. NEVER delete or + * move members and only change types if you really know what you're doing. + */ +struct usb_device { + struct usb_device *next, *prev; + + char filename[PATH_MAX + 1]; + + struct usb_bus *bus; + + struct usb_device_descriptor descriptor; + struct usb_config_descriptor *config; + + void *dev; /* Darwin support */ + + u_int8_t devnum; + + unsigned char num_children; + struct usb_device **children; +}; + +struct usb_bus { + struct usb_bus *next, *prev; + + char dirname[PATH_MAX + 1]; + + struct usb_device *devices; + u_int32_t location; + + struct usb_device *root_dev; +}; + +struct usb_dev_handle; +typedef struct usb_dev_handle usb_dev_handle; + +/* Variables */ +extern struct usb_bus *usb_busses; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/* usb.c */ +usb_dev_handle *usb_open(struct usb_device *dev); +int usb_close(usb_dev_handle *dev); +int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, + size_t buflen); +int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, + size_t buflen); + +/* descriptors.c */ +int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, + unsigned char type, unsigned char index, void *buf, int size); +int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, + unsigned char index, void *buf, int size); + +/* .c */ +int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout); +int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, + int value, int index, char *bytes, int size, int timeout); +int usb_set_configuration(usb_dev_handle *dev, int configuration); +int usb_claim_interface(usb_dev_handle *dev, int interface); +int usb_release_interface(usb_dev_handle *dev, int interface); +int usb_set_altinterface(usb_dev_handle *dev, int alternate); +int usb_resetep(usb_dev_handle *dev, unsigned int ep); +int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); +int usb_reset(usb_dev_handle *dev); + +#if 1 +#define LIBUSB_HAS_GET_DRIVER_NP 1 +int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name, + unsigned int namelen); +#define LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 1 +int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface); +#endif + +char *usb_strerror(void); + +void usb_init(void); +void usb_set_debug(int level); +int usb_find_busses(void); +int usb_find_devices(void); +struct usb_device *usb_device(usb_dev_handle *dev); +struct usb_bus *usb_get_busses(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_H__ */ + diff --git a/libraries/external/libusb/include/usbpp.h b/libraries/external/libusb/include/usbpp.h new file mode 100755 index 0000000..525e217 --- /dev/null +++ b/libraries/external/libusb/include/usbpp.h @@ -0,0 +1,855 @@ +// -*- C++;indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- +#ifndef __USBPP_HEADER__ +#define __USBPP_HEADER__ + +#include +#include + +#include + +/* + * The following usb.h function is not wrapped yet: + * char *usb_strerror(void); + */ + + +/** + * \brief Classes to access Universal Serial Bus devices + * + * The USB Namespace provides a number of classes to work + * with Universal Serial Bus (USB) devices attached to the + * system. + * + * \author Brad Hards + */ +namespace USB { + + class Device; + + /** + * \brief Class representing a device endpoint + * + * This class represents a device endpoint. You need this class to + * perform bulk reads and writes. + * + */ + class Endpoint { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + Endpoint() {}; + +#ifdef USE_UNTESTED_LIBUSBPP_METHODS + /** + * \brief Bulk write + * + * This method performs a bulk transfer to the endpoint. + * + * \param message is the message to be sent. + * \param timeout is the USB transaction timeout in milliseconds + * + * \returns the number of bytes sent, or a negative value on + * failure + */ + int bulkWrite(QByteArray message, int timeout = 100); + + /** + * \brief Bulk read + * + * This method performs a bulk transfer from the endpoint. + * + * \param length is the maximum data transfer required. + * \param message is the message that was received. + * \param timeout is the USB transaction timeout in milliseconds + * + * \returns the number of bytes received, or a negative value on + * failure + */ + int bulkRead(int length, unsigned char *message, int timeout = 100); + + /** + * \brief Reset endpoint + * + * This method resets the endpoint. + */ + int reset(void); + + /** + * \brief Clear halt + * + * This method clears a halt (stall) on the endpoint. + */ + int clearHalt(void); + +#endif /* USE_UNTESTED_LIBUSBPP_METHODS */ + + /** + * \brief Endpoint descriptor information output + * + * This method dumps out the various characteristics + * of the endpoint to standard output. + * + * It is mostly useful for debugging. + */ + void dumpDescriptor(void); + + private: + void setDescriptor(struct usb_endpoint_descriptor); + void setParent(Device *parent); + u_int8_t m_Length; + u_int8_t m_DescriptorType; + u_int8_t m_EndpointAddress; + u_int8_t m_Attributes; + u_int16_t m_MaxPacketSize; + u_int8_t m_Interval; + u_int8_t m_Refresh; + u_int8_t m_SynchAddress; + Device *m_parent; + }; + + class AltSetting : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + AltSetting() {}; + u_int8_t numEndpoints(void); + + /** + * \brief AltSetting descriptor information output + * + * This method dumps out the various characteristics + * of the alternate setting to standard output. + * + * It is mostly useful for debugging. + */ + void dumpDescriptor(void); + + Endpoint *firstEndpoint(void); + Endpoint *nextEndpoint(void); + Endpoint *lastEndpoint(void); + + private: + std::list::const_iterator iter; + + void setDescriptor(struct usb_interface_descriptor); + /* we don't use a normal usb_interface_descriptor */ + /* because that would bring in the endpoint list */ + u_int8_t m_Length; + u_int8_t m_DescriptorType; + u_int8_t m_InterfaceNumber; + u_int8_t m_AlternateSetting; + u_int8_t m_NumEndpoints; + u_int8_t m_InterfaceClass; + u_int8_t m_InterfaceSubClass; + u_int8_t m_InterfaceProtocol; + u_int8_t m_Interface; + }; + + /** + * \brief Class representing an interface of a Device + * + * The Interface class represents a USB interface + * for a device attached to a Universal Serial Bus. + * + * Interfaces are the main element of the USB class + * structure. + * + * \author Brad Hards + */ + class Interface : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + Interface() {}; + +#ifdef LIBUSB_HAS_GET_DRIVER_NP + /** + * \brief get the current driver for an interface + * + * \param driver a string containing the name of the current + * driver for the interface. You can typically pass in an empty + * string for this. + * + * \return length of string, or 0 on error. + */ + int driverName(std::string &driver); +#endif + +#ifdef USE_UNTESTED_LIBUSBPP_METHODS + /** + * \brief Claim this interface + * + * This method claims the interface. You have to claim the + * interface before performing any operations on the interface (or + * on endpoints that are part of the interface). + * + * \return 0 on success or negative number on error. + */ + int claim(void); + + /** + * \brief Release this interface + * + * This method releases the interface. You should release the + * interface after all operations on it (and any lower level + * endpoints) are completed. + * + * \return 0 on success or negative number on error. + */ + int release(void); + + /** + * \brief Set interface alternate setting + * + * This method sets the interface to a particular AltSetting. + * + * \param altSettingNumber the AltSetting that the interface + * should be changed to. + * + * \return 0 on success, or a negative number in case of error. + */ + int setAltSetting(int altSettingNumber); +#endif /* USE_UNTESTED_LIBUSBPP_METHODS */ + + /** + * \brief Number of Alternative Settings that this interface has + * + * This is a simple accessor method that specifies the number + * alternative settings that this device interface has. + */ + u_int8_t numAltSettings(void); + + /** + * \brief First AltSetting for the Interface + * + * This method returns a pointer to the first AltSetting + * for the Interface. + * + * See nextAltSetting() for an example of how it might be + * used. + * + * \see nextAltSetting(), lastAltSetting(), numAltSettings() + */ + AltSetting *firstAltSetting(void); + + /** + * \brief Next AltSetting for the Interface + * + * This method returns a pointer to the next AltSetting + * for the Interface. + * + * If you want to iterate through each AltSetting on + * a device, you can use something like the following: + * \code + * USB::Configuration *this_Configuration; + * this_Configuration = device->firstConfiguration(); + * for (i=0; i < device->numConfigurations(); i++) { + * this_Configuration->dumpDescriptor(); + * USB::Interface *this_Interface; + * this_Interface = this_Configuration->firstInterface(); + * for (j=0; j < this_Configuration->numInterfaces(); j++) { + * USB::AltSetting *this_AltSetting; + * this_AltSetting = this_Interface->firstAltSetting(); + * for (k=0; k < this_Interface->numAltSettings(); k++) { + * // do something with this_AltSetting + * this_AltSetting = this_Interface->nextAltSetting(); + * } + * this_Interface = this_Configuration->nextInterface(); + * } + * this_Configuration = device->nextConfiguration(); + * } + * \endcode + * + * \see firstAltSetting(), lastAltSetting(), numAltSettings() + */ + AltSetting *nextAltSetting(void); + + /** + * \brief Last AltSetting for the Interface + * + * This method returns a pointer to the last AltSetting + * for the Interface. + * + * \see firstAltSetting(), nextAltSetting(), numAltSettings() + */ + + AltSetting *lastAltSetting(void); + + private: + std::list::const_iterator iter; + + void setNumAltSettings(u_int8_t); + void setParent(Device *parent); + u_int8_t m_numAltSettings; + Device *m_parent; + + /* index representing the interface, in this configuration */ + int m_interfaceNumber; + void setInterfaceNumber(int interfaceNumber); + }; + + /** + * \brief Class representing a configuration of a Device + * + * The Configuration class represents a single configuration + * of a device attached to a Universal Serial Bus. + * + * \author Brad Hards + */ + class Configuration : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + public: + Configuration() {}; + + /** + * \brief Configuration descriptor information output + * + * This method dumps out the various characteristics + * of the configuration to standard output. + * + * It is mostly useful for debugging. + */ + void dumpDescriptor(void); + + /** + * \brief Number of Interfaces that this device has + * + * This is a simple accessor method that specifies the number + * Interfaces that this device configuration has. + */ + u_int8_t numInterfaces(void); + + /** + * \brief First Interface for the Configuration + * + * This method returns a pointer to the first Interface + * for the Configuration. + * + * See nextInterface() for an example of how it might be + * used. + * + * \see nextInterface(), lastInterface(), numInterfaces() + */ + Interface *firstInterface(void); + + /** + * \brief Next Interface for the Configuration + * + * This method returns a pointer to the next Interface + * for the Configuration. + * + * If you want to iterate through each Interface on + * a device, you can use something like the following: + * \code + * USB::Configuration *this_Configuration; + * this_Configuration = device->firstConfiguration(); + * for (i=0; i < device->numConfigurations(); i++) { + * this_Interface = this_Configuration->firstInterface(); + * for (j=0; j < this_Configuration->numInterfaces(); j++) { + * // do something with this_Interface + * this_Interface = this_Configuration->nextInterface(); + * } + * this_Configuration->nextConfiguration(); + * } + * \endcode + * + * \see firstInterface(), lastInterface(), numInterfaces() + */ + Interface *nextInterface(void); + + /** + * \brief Last Interface for the Configuration + * + * This method returns a pointer to the last Interface + * for the Configuration. + * + * \see firstInterface(), nextInterface(), numInterfaces() + */ + Interface *lastInterface(void); + + private: + std::list::const_iterator iter; + + void setDescriptor(struct usb_config_descriptor); + /* we don't use a normal usb_config_descriptor */ + /* because that would bring in the interface list */ + u_int8_t m_Length; + u_int8_t m_DescriptorType; + u_int16_t m_TotalLength; + u_int8_t m_NumInterfaces; + u_int8_t m_ConfigurationValue; + u_int8_t m_Configuration; + u_int8_t m_Attributes; + u_int8_t m_MaxPower; + }; + + /** + * \brief Class representing a Device on the Bus + * + * The Device class represents a single device + * attached to a Universal Serial Bus. + * + * \author Brad Hards + */ + class Device : public std::list { + /** + * Busses is a friend because it fills in the descriptor type + * information on initialisation and rescan. + */ + friend class Busses; + /** + * Interface is a friend because it needs the handle() function to + * perform claim(), release(). + */ + friend class Interface; + /** + * Endpoint is a friend because it needs the handle() function to + * perform reads, writes, and other transactions. + */ + friend class Endpoint; + + public: + Device() {}; + ~Device(); + + /** + * \brief OS representation of filename for this device + * + * libusb++ provides a uniform way of accessing USB + * devices irrespective of the underlying Operation System + * representation. If you want to map the libusb++ representation + * to the Operating System representation, you can do this + * with filename(). + * + * On Linux, the filename is usually something like 002, which + * represents the second device (usually the first real device, + * after the root hub pseudo-device) on the bus. + * + * \see Bus::directoryName() + */ + std::string fileName(void); + + /** + * \brief The vendor ID number, as provided by the device. + * + * This method returns a number containing the vendor + * (manufacturer) identification number. These are allocated + * by the USB Implementers Forum, and you can construct a + * lookup based on the number to get the manufacturer's name, + * even if the device does not contain a vendor string. + * + * \see Vendor() + */ + u_int16_t idVendor(void); + + /** + * \brief The product ID number, as provided by the device. + * + * This method returns a number containing the product + * identification number. These are allocated + * by the manufacturer, and should be different on each device. + * + * \see Product() + */ + u_int16_t idProduct(void); + + /** + * \brief The product's revision ID, as provided by the device. + * + * This method returns a number containing the product's revision. + * This revision level is nominally binary coded decimal, but + * hexadecimal revision levels are not uncommon. The binary coded + * decimal version nominally has a major version in the high byte, + * and a minor version in the low byte. + */ + u_int16_t idRevision(void); + + /** + * \brief The device's USB class, as provided by the device. + * + * This method returns a number containing the device's class. + * These are defined by the USB Implementer's Forum. + * + * A code of Zero is special (and common) - it means that the + * class is found in the Interface descriptor, rather than in the + * Device descriptor. + * + * A code of 0xFF is also special (and far too common) - it means + * that the manufacturer didn't conform to one of the defined + * class specifications, and chose to implement a vendor specified + * protocol. + * + */ + u_int8_t devClass(void); + + /** + * \brief The device's USB subclass, as provided by the device. + * + * This method returns a number containing the device's subclass. + * These subclasses are defined by the USB Implementer's Forum, + * and only have meaning in the context of a specified class. + */ + u_int8_t devSubClass(void); + + /** + * \brief The device's USB protocol, as provided by the device. + * + * This method returns a number containing the device's protocol. + * These protocols are defined by the USB Implementer's Forum, and + * only have meaning in the context of a specified class and + * subclass. + */ + u_int8_t devProtocol(void); + + + /** + * \brief The vendor name string, as provided by the device. + * + * This method returns a string containing the name of the + * device's vendor (manufacturer), as encoded into the device. + * + * Note that not all devices contain a vendor name, and also + * that under some operating systems you may not be able to + * read the vendor name without elevated privledges (typically + * root privledges). + * + * \see idVendor() + **/ + std::string Vendor(void); + + /** + * \brief The product name string, as provided by the device. + * + * This method returns a string containing the name of the + * device's product name, as encoded into the device. + * + * Note that not all devices contain a product name, and also + * that under some operating systems you may not be able to + * read the vendor name without elevated privledges (typically + * root privledges). + * + * \see idProduct() + **/ + std::string Product(void); + + /** + * \brief The serial number string, as provided by the device. + * + * This method returns a string containing a serial number for + * the device, as encoded into the device. + * + * Note that few devices contain a serial number string, and also + * that under some operating systems you may not be able to + * read the serial number without elevated privledges (typically + * root privledges). The USB specification requires that serial + * numbers are unique if they are provided, but adherence to this + * requirement by manufacturers is not universal. + **/ + std::string SerialNumber(void); + + /** + * \brief Number of Configurations that this device has + * + * This is a simple accessor method that specifies the number + * configurations that this device has. + */ + u_int8_t numConfigurations(void); + + /** + * \brief fetch an arbitrary string from the device + * + * \param string the string from the device. You can typically + * pass in an empty string for this. + * \param index the index of the string required + * \param lang the language ID to use. Defaults to using the + * first language ID. + * + * \return length of string, or 0 on error. + */ + int string(std::string &buf, int index, u_int16_t lang=0); + + /** + * \brief First Configuration for the Device + * + * This method returns a pointer to the first Configuration + * for the Device. + * + * See nextConfiguration() for an example of how it might be + * used. + */ + Configuration *firstConfiguration(void); + + /** + * \brief Next Configuration for the Device + * + * This method returns a pointer to the next Configuration + * for the Device. + * + * If you want to iterate through each Configuration on + * a device, you can use something like the following: + * \code + * USB::Configuration *this_Configuration; + * this_Configuration = device->firstConfiguration(); + * for (i=0; i < device->numConfigurations(); i++) { + * // do something with this_Configuration + * this_Configuration->nextConfiguration(); + * } + * \endcode + */ + Configuration *nextConfiguration(void); + + /** + * \brief Last Configuration for the Device + * + * This method returns a pointer to the last Configuration + * for the Device. + * + */ + Configuration *lastConfiguration(void); + + /** + * \brief USB control transfer + * + * This method performs a standard control transfer to the default + * endpoint. See the USB specification for more details on this. + * + * \param requestType corresponds to the bmRequestType field + * in the transfer + * \param request corresponds to the bRequest field in the + * transfer + * \param value corresponds to the wValue field in the transfer + * \param index corresponds to the wIndex field in the transfer + * \param length corresponds to the wLength field in the transfer + * \param payload corresponds to the data phase of a control + * transfer + * \param timeout is the timeout period for the control transfer, + * in milliseconds + * + * \return number of bytes sent or received, or a negative number + * in case of error. + */ + int controlTransfer(u_int8_t requestType, u_int8_t request, + u_int16_t value, u_int16_t index, u_int16_t length, + unsigned char *payload, + int timeout = 100); + +#ifdef USE_UNTESTED_LIBUSBPP_METHODS + /** + * \brief USB device reset + * + * This method performs a device reset - see USB Specification + * 9.1 for how this changes the device state to the Default state. + * + * \return 0 on success, or a negative number in case of error. + */ + int reset(void); + + /** + * \brief Set device configuration + * + * This method sets the device to a particular Configuration. + * + * \param configurationNumber the configuration that the device + * should be changed to. + * + * \return 0 on success, or a negative number in case of error. + */ + int setConfiguration(int configurationNumber); +#endif /* USE_UNTESTED_LIBUSBPP_METHODS */ + + private: + std::list::const_iterator iter; + + struct usb_dev_handle *handle(); + void setFileName(std::string); + void setDescriptor(struct usb_device_descriptor); + void setVendor(std::string); + void setProduct(std::string); + void setSerialNumber(std::string); + void setDevHandle(struct usb_dev_handle *); + std::string m_fileName; + std::string m_Vendor; + std::string m_Product; + std::string m_SerialNumber; + struct usb_device *m_dev; + struct usb_dev_handle *m_handle; + struct usb_device_descriptor m_descriptor; + }; + + /** + * \brief Class representing a single bus on the machine + * + * This class is essentially a list of Device class instances + */ + class Bus : public std::list { + /** + * Busses is a friend because it fills in the directory name + * information on initialisation and rescan. + */ + friend class Busses; + public: + Bus() {}; + /** + * \brief OS representation of directory name for this Bus + * + * libusb++ provides a uniform way of accessing USB + * busses irrespective of the underlying Operation System + * representation. If you want to map the libusb++ representation + * to the Operating System representation, you can do this + * with directory name(). + * + * On Linux, the directoryname is usually something like 003, which + * represents the third bus on the host. + * + * \see Directory::filename() + */ + std::string directoryName(void); + private: + std::list::const_iterator iter; + + void setDirectoryName(std::string); + std::string m_directoryName; + }; + + /** + * \brief A vendor/product ID pair + * + * DeviceID provides a list of (vendor, product) identification + * pairs. It is intended for use in a list of device numbers to + * search for, but there is no reason why it couldn't be used for a + * general purpose (vendor,product) tuple if you had some reason for + * this. + * + * The description for Busses::match() provides an example of how + * this class might be used. + * + * \see DeviceIDList, Busses::match() + */ + class DeviceID { + public: + DeviceID() {}; + /** + * \brief Standard constructor + * + * This constructor takes (vendor, product) tuple, which are + * stored away. + * + * \param vendor the 16 bit vendor number for the device + * \param product the 16 bit product number for the device + */ + DeviceID(u_int16_t vendor, u_int16_t product); + + /** + * \brief vendor number for the device + * + * This method returns the 16 bit vendor number. + */ + u_int16_t vendor(void); + + /** + * \brief product number for the device + * + * This method returns the 16 bit product number. + */ + u_int16_t product(void); + + private: + u_int16_t m_vendor; + u_int16_t m_product; + }; + + /** + * \brief A list of vendor/product pairs + * + * DeviceIDList provides a list of DeviceID classes, which is + * essentially a list of (vendor, product) identification pairs. + * + * \see DeviceID + */ + typedef std::list DeviceIDList; + + /** + * \brief Class representing all the busses on the machine + * + * This class is essentially a list of Bus class instances + */ + class Busses : public std::list { + public: + Busses(); + + /** + * \brief Update method + * + * This method can be called to rescan the various devices + * attached to the various busses. You should use it to + * update if things change. Unfortunately there is no + * way to automatically detect this change in a portable way, + * so worst case is that you need to call this using some + * kind of timer in the background. + */ + void rescan(void); + + /** + * \brief find all devices with matching device class designator + * + * This method searches every device on every bus, and returns a + * list of pointers to the devices that have a matching device + * class code + */ + std::list match(u_int8_t Class); + + /** + * \brief find all devices with matching device IDs + * + * This method searches every device on every bus, and returns a + * list of pointers to the devices that have a matching device + * ID. That is, if the (vendor, product) tuple of a device matches + * one of the tuples on the list, then the device will be added to + * the list of matches. + * + * An example of usage is shown below: + * \code + * USB::Busses buslist; + * USB::Device *device; + * std::list miceFound; + * USB::DeviceIDList mouseList; + * + * mouseList.append(USB::DeviceID(VENDOR_LOGITECH, 0xC00E)); // Wheel Mouse Optical + * mouseList.append(USB::DeviceID(VENDOR_LOGITECH, 0xC012)); // MouseMan Dual Optical + * mouseList.append(USB::DeviceID(VENDOR_LOGITECH, 0xC506)); // MX700 Optical Mouse + * + * miceFound = buslist.match(mouseList); + * + * for ( device = miceFound.first(); device; device = miceFound.next() ) { + * // do something with each mouse that matched + * } + * FIXME: This is incorrect now + * \endcode + */ + std::list match(DeviceIDList); + + private: + std::list::const_iterator iter; + }; + + class Error { + public: + private: + }; + +} +#endif /* __USBPP_HEADER__ */ + diff --git a/libraries/external/libusb/include/vssver.scc b/libraries/external/libusb/include/vssver.scc new file mode 100755 index 0000000..34efe96 Binary files /dev/null and b/libraries/external/libusb/include/vssver.scc differ diff --git a/libraries/external/libusb/lib/libusb-0.1.so.4 b/libraries/external/libusb/lib/libusb-0.1.so.4 new file mode 100755 index 0000000..a0d84bc Binary files /dev/null and b/libraries/external/libusb/lib/libusb-0.1.so.4 differ diff --git a/libraries/external/libusb/lib/libusb-0.1.so.4.4.4 b/libraries/external/libusb/lib/libusb-0.1.so.4.4.4 new file mode 100755 index 0000000..a0d84bc Binary files /dev/null and b/libraries/external/libusb/lib/libusb-0.1.so.4.4.4 differ diff --git a/libraries/external/libusb/lib/libusb.a b/libraries/external/libusb/lib/libusb.a new file mode 100755 index 0000000..a75e6e4 Binary files /dev/null and b/libraries/external/libusb/lib/libusb.a differ diff --git a/libraries/external/libusb/lib/libusb.la b/libraries/external/libusb/lib/libusb.la new file mode 100755 index 0000000..9708651 --- /dev/null +++ b/libraries/external/libusb/lib/libusb.la @@ -0,0 +1,35 @@ +# libusb.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.6 (1.1220.2.95 2004/04/11 05:50:42) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libusb-0.1.so.4' + +# Names of this library. +library_names='libusb-0.1.so.4.4.4 libusb-0.1.so.4 libusb.so' + +# The name of the static archive. +old_library='libusb.a' + +# Libraries that this one depends upon. +dependency_libs='' + +# Version information for libusb. +current=8 +age=4 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libusb/lib' diff --git a/libraries/external/libusb/lib/libusb.so b/libraries/external/libusb/lib/libusb.so new file mode 100755 index 0000000..6a50e0c Binary files /dev/null and b/libraries/external/libusb/lib/libusb.so differ diff --git a/libraries/external/libusb/lib/libusbpp-0.1.so.4 b/libraries/external/libusb/lib/libusbpp-0.1.so.4 new file mode 100755 index 0000000..7e7a6ad Binary files /dev/null and b/libraries/external/libusb/lib/libusbpp-0.1.so.4 differ diff --git a/libraries/external/libusb/lib/libusbpp-0.1.so.4.4.4 b/libraries/external/libusb/lib/libusbpp-0.1.so.4.4.4 new file mode 100755 index 0000000..7e7a6ad Binary files /dev/null and b/libraries/external/libusb/lib/libusbpp-0.1.so.4.4.4 differ diff --git a/libraries/external/libusb/lib/libusbpp.a b/libraries/external/libusb/lib/libusbpp.a new file mode 100755 index 0000000..96cfc9e Binary files /dev/null and b/libraries/external/libusb/lib/libusbpp.a differ diff --git a/libraries/external/libusb/lib/libusbpp.la b/libraries/external/libusb/lib/libusbpp.la new file mode 100755 index 0000000..999c2b6 --- /dev/null +++ b/libraries/external/libusb/lib/libusbpp.la @@ -0,0 +1,35 @@ +# libusbpp.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.6 (1.1220.2.95 2004/04/11 05:50:42) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libusbpp-0.1.so.4' + +# Names of this library. +library_names='libusbpp-0.1.so.4.4.4 libusbpp-0.1.so.4 libusbpp.so' + +# The name of the static archive. +old_library='libusbpp.a' + +# Libraries that this one depends upon. +dependency_libs=' /g3/libusb/lib/libusb.la /usr/lib/./libstdc++.la -L/usr/i486-slackware-linux/bin -L/usr/i486-slackware-linux/lib' + +# Version information for libusbpp. +current=8 +age=4 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/g3/libusb/lib' diff --git a/libraries/external/libusb/lib/libusbpp.so b/libraries/external/libusb/lib/libusbpp.so new file mode 100755 index 0000000..7e7a6ad Binary files /dev/null and b/libraries/external/libusb/lib/libusbpp.so differ diff --git a/libraries/external/libusb/lib/vssver.scc b/libraries/external/libusb/lib/vssver.scc new file mode 100755 index 0000000..4606ea5 Binary files /dev/null and b/libraries/external/libusb/lib/vssver.scc differ diff --git a/libraries/external/libusb/libusb-0.1.12.tar.gz b/libraries/external/libusb/libusb-0.1.12.tar.gz new file mode 100755 index 0000000..b154956 --- /dev/null +++ b/libraries/external/libusb/libusb-0.1.12.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37f6f7d9de74196eb5fc0bbe0aea9b5c939de7f500acba3af6fd643f3b538b44 +size 389343 diff --git a/libraries/external/libusb/vssver.scc b/libraries/external/libusb/vssver.scc new file mode 100755 index 0000000..8ad915f Binary files /dev/null and b/libraries/external/libusb/vssver.scc differ diff --git a/libraries/external/lungif/dgif_lib.c b/libraries/external/lungif/dgif_lib.c new file mode 100755 index 0000000..189b8ae --- /dev/null +++ b/libraries/external/lungif/dgif_lib.c @@ -0,0 +1,1013 @@ +/****************************************************************************** +* "Gif-Lib" - Yet another gif library. * +* * +* Written by: Gershon Elber IBM PC Ver 1.1, Aug. 1990 * +******************************************************************************* +* The kernel of the GIF Decoding process can be found here. * +******************************************************************************* +* History: * +* 16 Jun 89 - Version 1.0 by Gershon Elber. * +* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * +******************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#if defined(__MWERKS__) +#pragma warn_unusedarg off +#pragma warn_unusedvar off +#endif + +#if defined (__MSDOS__) && !defined(__DJGPP__) && !defined(__GNUC__) +#include +#include +#include +#include +#else +//#include +//#include +#endif /* __MSDOS__ */ + +#ifndef __MSDOS__ +#include +#endif +//#include +#include +#include +#include "gif_lib.h" +#include "gif_lib_private.h" + +#define COMMENT_EXT_FUNC_CODE 0xfe /* Extension function code for comment. */ + +/* avoid extra function call in case we use fread (TVT) */ + +#define READ(_gif,_buf,_len) fread(_buf, 1, _len, ((GifFilePrivateType*)_gif->Private)->File) + +static int DGifGetWord(GifFileType *GifFile, int *Word); +static int DGifSetupDecompress(GifFileType *GifFile); +static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, + int LineLen); +static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode); +static int DGifDecompressInput(GifFileType *GifFile, int *Code); +static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, + GifByteType *NextByte); + +/****************************************************************************** +* Open a new gif file for read, given by its name. * +* Returns GifFileType pointer dynamically allocated which serves as the gif * +* info record. _GifError is cleared if succesfull. * +******************************************************************************/ + +GifFileType *DGifOpenFileName(const char *FileName) +{ + FILE *FileHandle; + GifFileType *GifFile; + + FileHandle = fopen(FileName, "rb"); + if (!FileHandle) + { + _GifError = D_GIF_ERR_OPEN_FAILED; + return NULL; + } + + GifFile = DGifOpenFileHandle(FileHandle); + if (GifFile == (GifFileType *)NULL) + fclose(FileHandle); + + return GifFile; +} + +/****************************************************************************** +* Update a new gif file, given its file handle. * +* Returns GifFileType pointer dynamically allocated which serves as the gif * +* info record. _GifError is cleared if succesfull. * +******************************************************************************/ + +GifFileType *DGifOpenFileHandle(FILE *FileHandle) +{ + char Buf[GIF_STAMP_LEN+1]; + GifFileType *GifFile; + GifFilePrivateType *Private; + FILE *f; + + if ((GifFile = (GifFileType *) malloc(sizeof(GifFileType))) == NULL) { + _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; + return NULL; + } + + memset(GifFile, '\0', sizeof(GifFileType)); + + if ((Private = (GifFilePrivateType *) malloc(sizeof(GifFilePrivateType))) + == NULL) { + _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; + free((char *) GifFile); + return NULL; + } + + f = FileHandle; + +#ifdef __MSDOS__ + setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/ +#endif /* __MSDOS__ */ + + GifFile->Private = (VoidPtr) Private; + Private->FileHandle = FileHandle; + Private->File = f; + Private->FileState = FILE_STATE_READ; + Private->Read = 0; /* don't use alternate input method (TVT) */ + GifFile->UserData = 0; /* TVT */ + + /* Lets see if this is a GIF file: */ + if (READ(GifFile,Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) { + _GifError = D_GIF_ERR_READ_FAILED; + fclose(f); + free((char *) Private); + free((char *) GifFile); + return NULL; + } + + /* The GIF Version number is ignored at this time. Maybe we should do */ + /* something more useful with it. */ + Buf[GIF_STAMP_LEN] = 0; + if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) { + _GifError = D_GIF_ERR_NOT_GIF_FILE; + fclose(f); + free((char *) Private); + free((char *) GifFile); + return NULL; + } + + if (DGifGetScreenDesc(GifFile) == GIF_ERROR) { + fclose(f); + free((char *) Private); + free((char *) GifFile); + return NULL; + } + + _GifError = 0; + + return GifFile; +} + +/****************************************************************************** +* GifFileType constructor with user supplied input function (TVT) * +* * +******************************************************************************/ +GifFileType *DGifOpen( void* userData, InputFunc readFunc ) +{ + char Buf[GIF_STAMP_LEN+1]; + GifFileType *GifFile; + GifFilePrivateType *Private; + + + if ((GifFile = (GifFileType *) malloc(sizeof(GifFileType))) == NULL) { + _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; + return NULL; + } + + memset(GifFile, '\0', sizeof(GifFileType)); + + if (!(Private = (GifFilePrivateType*) malloc(sizeof(GifFilePrivateType)))){ + _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; + free((char *) GifFile); + return NULL; + } + + GifFile->Private = (VoidPtr) Private; + Private->FileHandle = 0; + Private->File = 0; + Private->FileState = FILE_STATE_READ; + + Private->Read = readFunc; /* TVT */ + GifFile->UserData = userData; /* TVT */ + + /* Lets see if this is a GIF file: */ + if ( READ( GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) { + _GifError = D_GIF_ERR_READ_FAILED; + free((char *) Private); + free((char *) GifFile); + return NULL; + } + + /* The GIF Version number is ignored at this time. Maybe we should do */ + /* something more useful with it. */ + Buf[GIF_STAMP_LEN] = 0; + if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) { + _GifError = D_GIF_ERR_NOT_GIF_FILE; + free((char *) Private); + free((char *) GifFile); + return NULL; + } + + if (DGifGetScreenDesc(GifFile) == GIF_ERROR) { + free((char *) Private); + free((char *) GifFile); + return NULL; + } + + _GifError = 0; + + return GifFile; +} + +/****************************************************************************** +* This routine should be called before any other DGif calls. Note that * +* this routine is called automatically from DGif file open routines. * +******************************************************************************/ +int DGifGetScreenDesc(GifFileType *GifFile) +{ + int i, BitsPerPixel; + GifByteType Buf[3]; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + /* Put the screen descriptor into the file: */ + if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR || + DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR) + return GIF_ERROR; + + if (READ( GifFile, Buf, 3) != 3) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1; + BitsPerPixel = (Buf[0] & 0x07) + 1; + GifFile->SBackGroundColor = Buf[1]; + if (Buf[0] & 0x80) { /* Do we have global color map? */ + + GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL); + + /* Get the global color map: */ + for (i = 0; i < GifFile->SColorMap->ColorCount; i++) { + if (READ(GifFile, Buf, 3) != 3) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + GifFile->SColorMap->Colors[i].Red = Buf[0]; + GifFile->SColorMap->Colors[i].Green = Buf[1]; + GifFile->SColorMap->Colors[i].Blue = Buf[2]; + } + } + + return GIF_OK; +} + +/****************************************************************************** +* This routine should be called before any attemp to read an image. * +******************************************************************************/ +int DGifGetRecordType(GifFileType *GifFile, GifRecordType *Type) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + if (READ( GifFile, &Buf, 1) != 1) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + + switch (Buf) { + case ',': + *Type = IMAGE_DESC_RECORD_TYPE; + break; + case '!': + *Type = EXTENSION_RECORD_TYPE; + break; + case ';': + *Type = TERMINATE_RECORD_TYPE; + break; + default: + *Type = UNDEFINED_RECORD_TYPE; + _GifError = D_GIF_ERR_WRONG_RECORD; + return GIF_ERROR; + } + + return GIF_OK; +} + +/****************************************************************************** +* This routine should be called before any attemp to read an image. * +* Note it is assumed the Image desc. header (',') has been read. * +******************************************************************************/ +int DGifGetImageDesc(GifFileType *GifFile) +{ + int i, BitsPerPixel; + GifByteType Buf[3]; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + SavedImage *sp; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR || + DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR || + DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR || + DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR) + return GIF_ERROR; + if (READ(GifFile,Buf, 1) != 1) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + BitsPerPixel = (Buf[0] & 0x07) + 1; + GifFile->Image.Interlace = (Buf[0] & 0x40); + if (Buf[0] & 0x80) { /* Does this image have local color map? */ + + if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL) + FreeMapObject(GifFile->Image.ColorMap); + + GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL); + + /* Get the image local color map: */ + for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) { + if (READ(GifFile,Buf, 3) != 3) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + GifFile->Image.ColorMap->Colors[i].Red = Buf[0]; + GifFile->Image.ColorMap->Colors[i].Green = Buf[1]; + GifFile->Image.ColorMap->Colors[i].Blue = Buf[2]; + } + } + + if (GifFile->SavedImages) { + if ((GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, + sizeof(SavedImage) * (GifFile->ImageCount + 1))) == NULL) { + _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; + return GIF_ERROR; + } + } else { + if ((GifFile->SavedImages = + (SavedImage *)malloc(sizeof(SavedImage))) == NULL) { + _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; + return GIF_ERROR; + } + } + + sp = &GifFile->SavedImages[GifFile->ImageCount]; + memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc)); + if (GifFile->Image.ColorMap != NULL) { + sp->ImageDesc.ColorMap = MakeMapObject( + GifFile->Image.ColorMap->ColorCount, + GifFile->Image.ColorMap->Colors); + } + sp->RasterBits = (char *)NULL; + sp->ExtensionBlockCount = 0; + sp->ExtensionBlocks = (ExtensionBlock *)NULL; + + GifFile->ImageCount++; + + Private->PixelCount = (long) GifFile->Image.Width * + (long) GifFile->Image.Height; + + DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */ + + return GIF_OK; +} + +/****************************************************************************** +* Get one full scanned line (Line) of length LineLen from GIF file. * +******************************************************************************/ +int DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) +{ + GifByteType *Dummy; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + if (!LineLen) LineLen = GifFile->Image.Width; + +#if defined(__MSDOS__) || defined(__GNUC__) + if ((Private->PixelCount -= LineLen) > 0xffff0000UL) { +#else + if ((Private->PixelCount -= LineLen) > 0xffff0000) { +#endif /* __MSDOS__ */ + _GifError = D_GIF_ERR_DATA_TOO_BIG; + return GIF_ERROR; + } + + if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) { + if (Private->PixelCount == 0) { + /* We probably would not be called any more, so lets clean */ + /* everything before we return: need to flush out all rest of */ + /* image until empty block (size 0) detected. We use GetCodeNext.*/ + do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) + return GIF_ERROR; + while (Dummy != NULL); + } + return GIF_OK; + } + else + return GIF_ERROR; +} + +/****************************************************************************** +* Put one pixel (Pixel) into GIF file. * +******************************************************************************/ +int DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel) +{ + GifByteType *Dummy; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + +#if defined(__MSDOS__) || defined(__GNUC__) + if (--Private->PixelCount > 0xffff0000UL) +#else + if (--Private->PixelCount > 0xffff0000) +#endif /* __MSDOS__ */ + { + _GifError = D_GIF_ERR_DATA_TOO_BIG; + return GIF_ERROR; + } + + if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) { + if (Private->PixelCount == 0) { + /* We probably would not be called any more, so lets clean */ + /* everything before we return: need to flush out all rest of */ + /* image until empty block (size 0) detected. We use GetCodeNext.*/ + do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) + return GIF_ERROR; + while (Dummy != NULL); + } + return GIF_OK; + } + else + return GIF_ERROR; +} + +/****************************************************************************** +* Get an extension block (see GIF manual) from gif file. This routine only * +* returns the first data block, and DGifGetExtensionNext shouldbe called * +* after this one until NULL extension is returned. * +* The Extension should NOT be freed by the user (not dynamically allocated).* +* Note it is assumed the Extension desc. header ('!') has been read. * +******************************************************************************/ +int DGifGetExtension(GifFileType *GifFile, int *ExtCode, + GifByteType **Extension) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + if (READ(GifFile,&Buf, 1) != 1) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + *ExtCode = Buf; + + return DGifGetExtensionNext(GifFile, Extension); +} + +/****************************************************************************** +* Get a following extension block (see GIF manual) from gif file. This * +* routine should be called until NULL Extension is returned. * +* The Extension should NOT be freed by the user (not dynamically allocated).* +******************************************************************************/ +int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (READ(GifFile,&Buf, 1) != 1) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + if (Buf > 0) { + *Extension = Private->Buf; /* Use private unused buffer. */ + (*Extension)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */ + if (READ(GifFile,&((*Extension)[1]), Buf) != Buf) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + } + else + *Extension = NULL; + + return GIF_OK; +} + +/****************************************************************************** +* This routine should be called last, to close the GIF file. * +******************************************************************************/ +int DGifCloseFile(GifFileType *GifFile) +{ + GifFilePrivateType *Private; + int *File; + + if (GifFile == NULL) return GIF_ERROR; + + Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + File = Private->File; + + if (GifFile->Image.ColorMap) + { + FreeMapObject(GifFile->Image.ColorMap); + GifFile->Image.ColorMap = NULL; + } + + if (GifFile->SColorMap) + { + FreeMapObject(GifFile->SColorMap); + GifFile->SColorMap = NULL; + } + + if (Private) + { + free((char *) Private); + Private = NULL; + } + + if (GifFile->SavedImages) + { + FreeSavedImages(GifFile); + GifFile = NULL; + } + + free(GifFile); + + if ( File && (fclose(File) != 0)) { + _GifError = D_GIF_ERR_CLOSE_FAILED; + return GIF_ERROR; + } + return GIF_OK; +} + +/****************************************************************************** +* Get 2 bytes (word) from the given file: * +******************************************************************************/ +static int DGifGetWord(GifFileType *GifFile, int *Word) +{ + unsigned char c[2]; + + if (READ(GifFile,c, 2) != 2) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + + *Word = (((unsigned int) c[1]) << 8) + c[0]; + return GIF_OK; +} + +/****************************************************************************** +* Get the image code in compressed form. his routine can be called if the * +* information needed to be piped out as is. Obviously this is much faster * +* than decoding and encoding again. This routine should be followed by calls * +* to DGifGetCodeNext, until NULL block is returned. * +* The block should NOT be freed by the user (not dynamically allocated). * +******************************************************************************/ +int DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock) +{ + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + *CodeSize = Private->BitsPerPixel; + + return DGifGetCodeNext(GifFile, CodeBlock); +} + +/****************************************************************************** +* Continue to get the image code in compressed form. This routine should be * +* called until NULL block is returned. * +* The block should NOT be freed by the user (not dynamically allocated). * +******************************************************************************/ +int DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (READ(GifFile,&Buf, 1) != 1) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + + if (Buf > 0) { + *CodeBlock = Private->Buf; /* Use private unused buffer. */ + (*CodeBlock)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */ + if (READ(GifFile,&((*CodeBlock)[1]), Buf) != Buf) { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + } + else { + *CodeBlock = NULL; + Private->Buf[0] = 0; /* Make sure the buffer is empty! */ + Private->PixelCount = 0; /* And local info. indicate image read. */ + } + + return GIF_OK; +} + +/****************************************************************************** +* Setup the LZ decompression for this image: * +******************************************************************************/ +static int DGifSetupDecompress(GifFileType *GifFile) +{ + int i, BitsPerPixel; + GifByteType CodeSize; + unsigned int *Prefix; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + READ(GifFile,&CodeSize, 1); /* Read Code size from file. */ + BitsPerPixel = CodeSize; + + Private->Buf[0] = 0; /* Input Buffer empty. */ + Private->BitsPerPixel = BitsPerPixel; + Private->ClearCode = (1 << BitsPerPixel); + Private->EOFCode = Private->ClearCode + 1; + Private->RunningCode = Private->EOFCode + 1; + Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */ + Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */ + Private->StackPtr = 0; /* No pixels on the pixel stack. */ + Private->LastCode = NO_SUCH_CODE; + Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */ + Private->CrntShiftDWord = 0; + + Prefix = Private->Prefix; + for (i = 0; i <= LZ_MAX_CODE; i++) Prefix[i] = NO_SUCH_CODE; + + return GIF_OK; +} + +/****************************************************************************** +* The LZ decompression routine: * +* This version decompress the given gif file into Line of length LineLen. * +* This routine can be called few times (one per scan line, for example), in * +* order the complete the whole image. * +******************************************************************************/ +static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, + int LineLen) +{ + int i = 0, j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr; + GifByteType *Stack, *Suffix; + unsigned int *Prefix; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + StackPtr = Private->StackPtr; + Prefix = Private->Prefix; + Suffix = Private->Suffix; + Stack = Private->Stack; + EOFCode = Private->EOFCode; + ClearCode = Private->ClearCode; + LastCode = Private->LastCode; + + if (StackPtr != 0) { + /* Let pop the stack off before continueing to read the gif file: */ + while (StackPtr != 0 && i < LineLen) Line[i++] = Stack[--StackPtr]; + } + + while (i < LineLen) { /* Decode LineLen items. */ + if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR) + return GIF_ERROR; + + if (CrntCode == EOFCode) { + /* Note however that usually we will not be here as we will stop */ + /* decoding as soon as we got all the pixel, or EOF code will */ + /* not be read at all, and DGifGetLine/Pixel clean everything. */ + if (i != LineLen - 1 || Private->PixelCount != 0) { + _GifError = D_GIF_ERR_EOF_TOO_SOON; + return GIF_ERROR; + } + i++; + } + else if (CrntCode == ClearCode) { + /* We need to start over again: */ + for (j = 0; j <= LZ_MAX_CODE; j++) Prefix[j] = NO_SUCH_CODE; + Private->RunningCode = Private->EOFCode + 1; + Private->RunningBits = Private->BitsPerPixel + 1; + Private->MaxCode1 = 1 << Private->RunningBits; + LastCode = Private->LastCode = NO_SUCH_CODE; + } + else { + /* Its regular code - if in pixel range simply add it to output */ + /* stream, otherwise trace to codes linked list until the prefix */ + /* is in pixel range: */ + if (CrntCode < ClearCode) { + /* This is simple - its pixel scalar, so add it to output: */ + Line[i++] = CrntCode; + } + else { + /* Its a code to needed to be traced: trace the linked list */ + /* until the prefix is a pixel, while pushing the suffix */ + /* pixels on our stack. If we done, pop the stack in reverse */ + /* (thats what stack is good for!) order to output. */ + if (Prefix[CrntCode] == NO_SUCH_CODE) { + /* Only allowed if CrntCode is exactly the running code: */ + /* In that case CrntCode = XXXCode, CrntCode or the */ + /* prefix code is last code and the suffix char is */ + /* exactly the prefix of last code! */ + if (CrntCode == Private->RunningCode - 2) { + CrntPrefix = LastCode; + Suffix[Private->RunningCode - 2] = + Stack[StackPtr++] = DGifGetPrefixChar(Prefix, + LastCode, ClearCode); + } + else { + _GifError = D_GIF_ERR_IMAGE_DEFECT; + return GIF_ERROR; + } + } + else + CrntPrefix = CrntCode; + + /* Now (if image is O.K.) we should not get an NO_SUCH_CODE */ + /* During the trace. As we might loop forever, in case of */ + /* defective image, we count the number of loops we trace */ + /* and stop if we got LZ_MAX_CODE. obviously we can not */ + /* loop more than that. */ + j = 0; + while (j++ <= LZ_MAX_CODE && + CrntPrefix > ClearCode && + CrntPrefix <= LZ_MAX_CODE) { + Stack[StackPtr++] = Suffix[CrntPrefix]; + CrntPrefix = Prefix[CrntPrefix]; + } + if (j >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) { + _GifError = D_GIF_ERR_IMAGE_DEFECT; + return GIF_ERROR; + } + /* Push the last character on stack: */ + Stack[StackPtr++] = CrntPrefix; + + /* Now lets pop all the stack into output: */ + while (StackPtr != 0 && i < LineLen) + Line[i++] = Stack[--StackPtr]; + } + if (LastCode != NO_SUCH_CODE) { + Prefix[Private->RunningCode - 2] = LastCode; + + if (CrntCode == Private->RunningCode - 2) { + /* Only allowed if CrntCode is exactly the running code: */ + /* In that case CrntCode = XXXCode, CrntCode or the */ + /* prefix code is last code and the suffix char is */ + /* exactly the prefix of last code! */ + Suffix[Private->RunningCode - 2] = + DGifGetPrefixChar(Prefix, LastCode, ClearCode); + } + else { + Suffix[Private->RunningCode - 2] = + DGifGetPrefixChar(Prefix, CrntCode, ClearCode); + } + } + LastCode = CrntCode; + } + } + + Private->LastCode = LastCode; + Private->StackPtr = StackPtr; + + return GIF_OK; +} + +/****************************************************************************** +* Routine to trace the Prefixes linked list until we get a prefix which is * +* not code, but a pixel value (less than ClearCode). Returns that pixel value.* +* If image is defective, we might loop here forever, so we limit the loops to * +* the maximum possible if image O.k. - LZ_MAX_CODE times. * +******************************************************************************/ +static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode) +{ + int i = 0; + + while (Code > ClearCode && i++ <= LZ_MAX_CODE) Code = Prefix[Code]; + return Code; +} + +/****************************************************************************** +* Interface for accessing the LZ codes directly. Set Code to the real code * +* (12bits), or to -1 if EOF code is returned. * +******************************************************************************/ +int DGifGetLZCodes(GifFileType *GifFile, int *Code) +{ + GifByteType *CodeBlock; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_READABLE(Private)) { + /* This file was NOT open for reading: */ + _GifError = D_GIF_ERR_NOT_READABLE; + return GIF_ERROR; + } + + if (DGifDecompressInput(GifFile, Code) == GIF_ERROR) + return GIF_ERROR; + + if (*Code == Private->EOFCode) { + /* Skip rest of codes (hopefully only NULL terminating block): */ + do if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR) + return GIF_ERROR; + while (CodeBlock != NULL); + + *Code = -1; + } + else if (*Code == Private->ClearCode) { + /* We need to start over again: */ + Private->RunningCode = Private->EOFCode + 1; + Private->RunningBits = Private->BitsPerPixel + 1; + Private->MaxCode1 = 1 << Private->RunningBits; + } + + return GIF_OK; +} + +/****************************************************************************** +* The LZ decompression input routine: * +* This routine is responsable for the decompression of the bit stream from * +* 8 bits (bytes) packets, into the real codes. * +* Returns GIF_OK if read succesfully. * +******************************************************************************/ +static int DGifDecompressInput(GifFileType *GifFile, int *Code) +{ + GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; + + GifByteType NextByte; + static unsigned int CodeMasks[] = { + 0x0000, 0x0001, 0x0003, 0x0007, + 0x000f, 0x001f, 0x003f, 0x007f, + 0x00ff, 0x01ff, 0x03ff, 0x07ff, + 0x0fff + }; + + while (Private->CrntShiftState < Private->RunningBits) { + /* Needs to get more bytes from input stream for next code: */ + if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) + == GIF_ERROR) { + return GIF_ERROR; + } + Private->CrntShiftDWord |= + ((unsigned long) NextByte) << Private->CrntShiftState; + Private->CrntShiftState += 8; + } + *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits]; + + Private->CrntShiftDWord >>= Private->RunningBits; + Private->CrntShiftState -= Private->RunningBits; + + /* If code cannt fit into RunningBits bits, must raise its size. Note */ + /* however that codes above 4095 are used for special signaling. */ + if (++Private->RunningCode > Private->MaxCode1 && + Private->RunningBits < LZ_BITS) { + Private->MaxCode1 <<= 1; + Private->RunningBits++; + } + return GIF_OK; +} + +/****************************************************************************** +* This routines read one gif data block at a time and buffers it internally * +* so that the decompression routine could access it. * +* The routine returns the next byte from its internal buffer (or read next * +* block in if buffer empty) and returns GIF_OK if succesful. * +******************************************************************************/ +static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, + GifByteType *NextByte) +{ + if (Buf[0] == 0) { + /* Needs to read the next buffer - this one is empty: */ + if (READ(GifFile, Buf, 1) != 1) + { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + if (READ(GifFile,&Buf[1], Buf[0]) != Buf[0]) + { + _GifError = D_GIF_ERR_READ_FAILED; + return GIF_ERROR; + } + *NextByte = Buf[1]; + Buf[1] = 2; /* We use now the second place as last char read! */ + Buf[0]--; + } + else { + *NextByte = Buf[Buf[1]++]; + Buf[0]--; + } + + return GIF_OK; +} + +/****************************************************************************** +* This routine reads an entire GIF into core, hanging all its state info off * +* the GifFileType pointer. Call DGifOpenFileName() or DGifOpenFileHandle() * +* first to initialize I/O. Its inverse is EGifSpew(). * +* + ******************************************************************************/ +int DGifSlurp(GifFileType *GifFile) +{ + int i, j, Error, ImageSize; + GifRecordType RecordType; + SavedImage *sp; + GifByteType *ExtData; + SavedImage temp_save; + + temp_save.ExtensionBlocks=NULL; + temp_save.ExtensionBlockCount=0; + + do { + if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) + return(GIF_ERROR); + + switch (RecordType) { + case IMAGE_DESC_RECORD_TYPE: + if (DGifGetImageDesc(GifFile) == GIF_ERROR) + return(GIF_ERROR); + + sp = &GifFile->SavedImages[GifFile->ImageCount-1]; + ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height; + + sp->RasterBits + = (char *) malloc(ImageSize * sizeof(GifPixelType)); + + if (DGifGetLine(GifFile, (GifByteType*)sp->RasterBits, ImageSize) + == GIF_ERROR) + return(GIF_ERROR); + + if (temp_save.ExtensionBlocks) { + sp->ExtensionBlocks = temp_save.ExtensionBlocks; + sp->ExtensionBlockCount = temp_save.ExtensionBlockCount; + + temp_save.ExtensionBlocks = NULL; + temp_save.ExtensionBlockCount=0; + + /* FIXME: The following is wrong. It is left in only for backwards + * compatibility. Someday it should go away. Use the + * sp->ExtensionBlocks->Function variable instead. + */ + sp->Function = sp->ExtensionBlocks[0].Function; + + } + + break; + + case EXTENSION_RECORD_TYPE: + if (DGifGetExtension(GifFile,&temp_save.Function,&ExtData)==GIF_ERROR) + return(GIF_ERROR); + while (ExtData != NULL) { + + /* Create an extension block with our data */ + if (AddExtensionBlock(&temp_save, ExtData[0], (char*)&ExtData[1]) + == GIF_ERROR) + return (GIF_ERROR); + + if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR) + return(GIF_ERROR); + temp_save.Function = 0; + } + break; + + case TERMINATE_RECORD_TYPE: + break; + + default: /* Should be trapped by DGifGetRecordType */ + break; + } + } while (RecordType != TERMINATE_RECORD_TYPE); + + /* Just in case the Gif has an extension block without an associated + * image... (Should we save this into a savefile structure with no image + * instead? Have to check if the present writing code can handle that as + * well.... + */ + if (temp_save.ExtensionBlocks) + FreeExtension(&temp_save); + + return(GIF_OK); +} + diff --git a/libraries/external/lungif/dgif_lib.o b/libraries/external/lungif/dgif_lib.o new file mode 100644 index 0000000..40ff54f Binary files /dev/null and b/libraries/external/lungif/dgif_lib.o differ diff --git a/libraries/external/lungif/egif_lib.c b/libraries/external/lungif/egif_lib.c new file mode 100755 index 0000000..2e82b66 --- /dev/null +++ b/libraries/external/lungif/egif_lib.c @@ -0,0 +1,926 @@ +/****************************************************************************** +* "Gif-Lib" - Yet another gif library. * +* * +* Written by: Gershon Elber Ver 1.1, Aug. 1990 * +******************************************************************************* +* The kernel of the GIF Encoding process can be found here. * +******************************************************************************* +* History: * +* 14 Jun 89 - Version 1.0 by Gershon Elber. * +* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * +* 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) +******************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#if defined(__MWERKS__) +#pragma warn_unusedarg off +#pragma warn_unusedvar off +#endif + +#ifdef __MSDOS__ +#include +#include +#include +#else +//#include +//#include +#ifdef R6000 +/* FIXME: What is sys/mode.h? Can we substitute a check for this file rather + * than a check based on machine type? + */ +#include +#endif +#endif /* __MSDOS__ */ + +//#include +#include +#include +#include +#include "gif_lib.h" +#include "gif_lib_private.h" + +/* #define DEBUG_NO_PREFIX Dump only compressed data. */ + +/* Masks given codes to BitsPerPixel, to make sure all codes are in range: */ +static GifPixelType CodeMask[] = { + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff +}; + +static char GifVersionPrefix[GIF_STAMP_LEN + 1] = GIF87_STAMP; + +#define WRITE(_gif,_buf,_len) \ + ((GifFilePrivateType*)_gif->Private)->Write(_gif,(GifByteType*)_buf,_len) +// (((GifFilePrivateType*)_gif->Private)->Write ? \ +// ((GifFilePrivateType*)_gif->Private)->Write(_gif,_buf,_len) : \ +// fwrite(_buf, 1, _len, ((GifFilePrivateType*)_gif->Private)->File)) + +static int EGifPutWord(int Word, GifFileType *GifFile); +static int EGifSetupCompress(GifFileType *GifFile); +static int EGifCompressLine(GifFileType *GifFile, GifPixelType *Line, + int LineLen); +static int EGifCompressOutput(GifFileType *GifFile, int Code); +static int EGifBufferedOutput(GifFileType *GifFile, GifByteType *Buf, int c); + +/****************************************************************************** +* Open a new gif file for write, given by its name. If TestExistance then * +* if the file exists this routines fails (returns NULL). * +* Returns GifFileType pointer dynamically allocated which serves as the gif * +* info record. _GifError is cleared if succesfull. * +******************************************************************************/ +//GifFileType *EGifOpenFileName(const char *FileName, int TestExistance) +//{ +// int FileHandle; +// GifFileType *GifFile; +// +// if (TestExistance) +// FileHandle = open(FileName, +// O_WRONLY | O_CREAT | O_EXCL +//#ifdef __MSDOS__ +// | O_BINARY +//#endif /* __MSDOS__ */ +// , +// S_IREAD | S_IWRITE); +// else +// FileHandle = open(FileName, +// O_WRONLY | O_CREAT | O_TRUNC +//#ifdef __MSDOS__ +// | O_BINARY +//#endif /* __MSDOS__ */ +// , +// S_IREAD | S_IWRITE); +// +// if (FileHandle == -1) { +// _GifError = E_GIF_ERR_OPEN_FAILED; +// return NULL; +// } +// GifFile = EGifOpenFileHandle(FileHandle); +// if (GifFile == (GifFileType*)NULL) +// close(FileHandle); +// return GifFile; +//} + +/****************************************************************************** +* Update a new gif file, given its file handle, which must be opened for * +* write in binary mode. * +* Returns GifFileType pointer dynamically allocated which serves as the gif * +* info record. _GifError is cleared if succesfull. * +******************************************************************************/ +//GifFileType *EGifOpenFileHandle(int FileHandle) +//{ +// GifFileType *GifFile; +// GifFilePrivateType *Private; +// FILE *f; +// +// if ((GifFile = (GifFileType *) malloc(sizeof(GifFileType))) == NULL) { +// _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; +// return NULL; +// } +// +// memset(GifFile, '\0', sizeof(GifFileType)); +// +// if ((Private = (GifFilePrivateType *) +// malloc(sizeof(GifFilePrivateType))) == NULL) { +// free(GifFile); +// _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; +// return NULL; +// } +// +//#ifdef __MSDOS__ +// setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ +//#endif /* __MSDOS__ */ +// +// f = fdopen(FileHandle, "wb"); /* Make it into a stream: */ +// +//#ifdef __MSDOS__ +// setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE); /* And inc. stream buffer. */ +//#endif /* __MSDOS__ */ +// +// GifFile->Private = (VoidPtr) Private; +// Private->FileHandle = FileHandle; +// Private->File = f; +// Private->FileState = FILE_STATE_WRITE; +// +// Private->Write = (OutputFunc)0; /* No user write routine (MRB) */ +// GifFile->UserData = (VoidPtr)0; /* No user write handle (MRB) */ +// +// _GifError = 0; +// +// return GifFile; +//} + +/****************************************************************************** +* Output constructor that takes user supplied output function. * +* Basically just a copy of EGifOpenFileHandle. (MRB) * +******************************************************************************/ +GifFileType* EGifOpen(void* userData, OutputFunc writeFunc) +{ + GifFileType* GifFile; + GifFilePrivateType* Private; + + if ((GifFile = (GifFileType *) malloc(sizeof(GifFileType))) == NULL) { + _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; + return NULL; + } + + memset(GifFile, '\0', sizeof(GifFileType)); + + if ((Private = (GifFilePrivateType *) + malloc(sizeof(GifFilePrivateType))) == NULL) { + free(GifFile); + _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; + return NULL; + } + + GifFile->Private = (VoidPtr) Private; + Private->FileHandle = 0; + Private->File = 0; + Private->FileState = FILE_STATE_WRITE; + + Private->Write = writeFunc; /* User write routine (MRB) */ + GifFile->UserData = userData; /* User write handle (MRB) */ + + _GifError = 0; + + return GifFile; +} + +/****************************************************************************** +* Routine to set current GIF version. All files open for write will be * +* using this version until next call to this routine. Version consists of * +* 3 characters as "87a" or "89a". No test is made to validate the version. * +******************************************************************************/ +void EGifSetGifVersion(const char *Version) +{ + strncpy(GifVersionPrefix + GIF_VERSION_POS, Version, 3); +} + +/****************************************************************************** +* This routine should be called before any other EGif calls, immediately * +* follows the GIF file openning. * +******************************************************************************/ +int EGifPutScreenDesc(GifFileType *GifFile, + int Width, int Height, int ColorRes, int BackGround, + const ColorMapObject *ColorMap) +{ + int i; + GifByteType Buf[3]; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (Private->FileState & FILE_STATE_SCREEN) { + /* If already has screen descriptor - something is wrong! */ + _GifError = E_GIF_ERR_HAS_SCRN_DSCR; + return GIF_ERROR; + } + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + +/* First write the version prefix into the file. */ +#ifndef DEBUG_NO_PREFIX + if (WRITE(GifFile, GifVersionPrefix, strlen(GifVersionPrefix)) != + strlen(GifVersionPrefix)) { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } +#endif /* DEBUG_NO_PREFIX */ + + GifFile->SWidth = Width; + GifFile->SHeight = Height; + GifFile->SColorResolution = ColorRes; + GifFile->SBackGroundColor = BackGround; + if(ColorMap) + GifFile->SColorMap=MakeMapObject(ColorMap->ColorCount,ColorMap->Colors); + else + GifFile->SColorMap=NULL; + + /* Put the screen descriptor into the file: */ + EGifPutWord(Width, GifFile); + EGifPutWord(Height, GifFile); + Buf[0] = (ColorMap ? 0x80 : 0x00) | + ((ColorRes - 1) << 4) | + (ColorMap->BitsPerPixel - 1); + Buf[1] = BackGround; + Buf[2] = 0; +#ifndef DEBUG_NO_PREFIX + WRITE(GifFile, Buf, 3); +#endif /* DEBUG_NO_PREFIX */ + + /* If we have Global color map - dump it also: */ +#ifndef DEBUG_NO_PREFIX + if (ColorMap != NULL) + for (i = 0; i < ColorMap->ColorCount; i++) { + /* Put the ColorMap out also: */ + Buf[0] = ColorMap->Colors[i].Red; + Buf[1] = ColorMap->Colors[i].Green; + Buf[2] = ColorMap->Colors[i].Blue; + if (WRITE(GifFile, Buf, 3) != 3) { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + } +#endif /* DEBUG_NO_PREFIX */ + + /* Mark this file as has screen descriptor, and no pixel written yet: */ + Private->FileState |= FILE_STATE_SCREEN; + + return GIF_OK; +} + +/****************************************************************************** +* This routine should be called before any attemp to dump an image - any * +* call to any of the pixel dump routines. * +******************************************************************************/ +int EGifPutImageDesc(GifFileType *GifFile, + int Left, int Top, int Width, int Height, int Interlace, + const ColorMapObject *ColorMap) +{ + int i; + GifByteType Buf[3]; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (Private->FileState & FILE_STATE_IMAGE && +#if defined(__MSDOS__) || defined(__GNUC__) + Private->PixelCount > 0xffff0000UL) { +#else + Private->PixelCount > 0xffff0000) { +#endif /* __MSDOS__ */ + /* If already has active image descriptor - something is wrong! */ + _GifError = E_GIF_ERR_HAS_IMAG_DSCR; + return GIF_ERROR; + } + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + GifFile->Image.Left = Left; + GifFile->Image.Top = Top; + GifFile->Image.Width = Width; + GifFile->Image.Height = Height; + GifFile->Image.Interlace = Interlace; + if(ColorMap) + GifFile->Image.ColorMap =MakeMapObject(ColorMap->ColorCount,ColorMap->Colors); + else + GifFile->Image.ColorMap = NULL; + + /* Put the image descriptor into the file: */ + Buf[0] = ','; /* Image seperator character. */ +#ifndef DEBUG_NO_PREFIX + WRITE(GifFile, Buf, 1); +#endif /* DEBUG_NO_PREFIX */ + EGifPutWord(Left, GifFile); + EGifPutWord(Top, GifFile); + EGifPutWord(Width, GifFile); + EGifPutWord(Height, GifFile); + Buf[0] = (ColorMap ? 0x80 : 0x00) | + (Interlace ? 0x40 : 0x00) | + (ColorMap ? ColorMap->BitsPerPixel - 1 : 0); +#ifndef DEBUG_NO_PREFIX + WRITE(GifFile, Buf, 1); +#endif /* DEBUG_NO_PREFIX */ + + /* If we have Global color map - dump it also: */ +#ifndef DEBUG_NO_PREFIX + if (ColorMap != NULL) + for (i = 0; i < ColorMap->ColorCount; i++) { + /* Put the ColorMap out also: */ + Buf[0] = ColorMap->Colors[i].Red; + Buf[1] = ColorMap->Colors[i].Green; + Buf[2] = ColorMap->Colors[i].Blue; + if (WRITE(GifFile, Buf, 3) != 3) { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + } +#endif /* DEBUG_NO_PREFIX */ + if (GifFile->SColorMap == NULL && GifFile->Image.ColorMap == NULL) + { + _GifError = E_GIF_ERR_NO_COLOR_MAP; + return GIF_ERROR; + } + + /* Mark this file as has screen descriptor: */ + Private->FileState |= FILE_STATE_IMAGE; + Private->PixelCount = (long) Width * (long) Height; + + EGifSetupCompress(GifFile); /* Reset compress algorithm parameters. */ + + return GIF_OK; +} + +/****************************************************************************** +* Put one full scanned line (Line) of length LineLen into GIF file. * +******************************************************************************/ +int EGifPutLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) +{ + int i; + GifPixelType Mask; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + if (!LineLen) + LineLen = GifFile->Image.Width; + if (Private->PixelCount < (unsigned)LineLen) { + _GifError = E_GIF_ERR_DATA_TOO_BIG; + return GIF_ERROR; + } + Private->PixelCount -= LineLen; + + /* Make sure the codes are not out of bit range, as we might generate */ + /* wrong code (because of overflow when we combine them) in this case: */ + Mask = CodeMask[Private->BitsPerPixel]; + for (i = 0; i < LineLen; i++) Line[i] &= Mask; + + return EGifCompressLine(GifFile, Line, LineLen); +} + +/****************************************************************************** +* Put one pixel (Pixel) into GIF file. * +******************************************************************************/ +int EGifPutPixel(GifFileType *GifFile, GifPixelType Pixel) +{ + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + if (Private->PixelCount == 0) + { + _GifError = E_GIF_ERR_DATA_TOO_BIG; + return GIF_ERROR; + } + --Private->PixelCount; + + /* Make sure the code is not out of bit range, as we might generate */ + /* wrong code (because of overflow when we combine them) in this case: */ + Pixel &= CodeMask[Private->BitsPerPixel]; + + return EGifCompressLine(GifFile, &Pixel, 1); +} + +/****************************************************************************** +* Put a comment into GIF file using the GIF89 comment extension block. * +******************************************************************************/ +int EGifPutComment(GifFileType *GifFile, const char *Comment) +{ + return EGifPutExtension(GifFile, COMMENT_EXT_FUNC_CODE, strlen(Comment), + Comment); +} + +/****************************************************************************** +* Put a first extension block (see GIF manual) into gif file. Here more * +* extensions can be dumped using EGifPutExtensionMid until * +* EGifPutExtensionLast is invoked. * +******************************************************************************/ +int EGifPutExtensionFirst(GifFileType *GifFile, int ExtCode, int ExtLen, + const VoidPtr Extension) +{ + GifByteType Buf[3]; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + if (ExtCode == 0) + WRITE(GifFile, &ExtLen, 1); + //fwrite(&ExtLen, 1, 1, Private->File); + else + { + Buf[0] = '!'; + Buf[1] = ExtCode; + Buf[2] = ExtLen; + WRITE(GifFile, Buf, 3); + //fwrite(Buf, 1, 3, Private->File); + } + WRITE(GifFile, Extension, ExtLen); + //fwrite(Extension, 1, ExtLen, Private->File); + + return GIF_OK; +} + +/****************************************************************************** +* Put a middle extension block (see GIF manual) into gif file. * +******************************************************************************/ +int EGifPutExtensionNext(GifFileType *GifFile, int ExtCode, int ExtLen, + const VoidPtr Extension) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + Buf = ExtLen; + WRITE(GifFile, &Buf, 1); + WRITE(GifFile, Extension, ExtLen); + //fwrite(&Buf, 1, 1, Private->File); + //fwrite(Extension, 1, ExtLen, Private->File); + + return GIF_OK; +} + +/****************************************************************************** +* Put a last extension block (see GIF manual) into gif file. * +******************************************************************************/ +int EGifPutExtensionLast(GifFileType *GifFile, int ExtCode, int ExtLen, + const VoidPtr Extension) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + Buf = ExtLen; + WRITE(GifFile, &Buf, 1); + WRITE(GifFile, Extension, ExtLen); + //fwrite(&Buf, 1, 1, Private->File); + //fwrite(Extension, 1, ExtLen, Private->File); + + Buf = 0; + WRITE(GifFile, &Buf, 1); + //fwrite(&Buf, 1, 1, Private->File); + + return GIF_OK; +} + +/****************************************************************************** +* Put an extension block (see GIF manual) into gif file. * +******************************************************************************/ +int EGifPutExtension(GifFileType *GifFile, int ExtCode, int ExtLen, + const VoidPtr Extension) +{ + GifByteType Buf[3]; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + if (ExtCode == 0) + WRITE(GifFile, (GifByteType*)&ExtLen, 1); + else { + Buf[0] = '!'; + Buf[1] = ExtCode; + Buf[2] = ExtLen; + WRITE(GifFile, Buf, 3); + } + WRITE(GifFile, Extension, ExtLen); + Buf[0] = 0; + WRITE(GifFile, Buf, 1); + + return GIF_OK; +} + +/****************************************************************************** +* Put the image code in compressed form. This routine can be called if the * +* information needed to be piped out as is. Obviously this is much faster * +* than decoding and encoding again. This routine should be followed by calls * +* to EGifPutCodeNext, until NULL block is given. * +* The block should NOT be freed by the user (not dynamically allocated). * +******************************************************************************/ +int EGifPutCode(GifFileType *GifFile, int CodeSize, const GifByteType *CodeBlock) +{ + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + /* No need to dump code size as Compression set up does any for us: */ + /* + Buf = CodeSize; + if (WRITE(GifFile, &Buf, 1) != 1) { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + */ + + return EGifPutCodeNext(GifFile, CodeBlock); +} + +/****************************************************************************** +* Continue to put the image code in compressed form. This routine should be * +* called with blocks of code as read via DGifGetCode/DGifGetCodeNext. If * +* given buffer pointer is NULL, empty block is written to mark end of code. * +******************************************************************************/ +int EGifPutCodeNext(GifFileType *GifFile, const GifByteType *CodeBlock) +{ + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (CodeBlock != NULL) { + if (WRITE(GifFile, CodeBlock, CodeBlock[0] + 1) + != (unsigned)(CodeBlock[0] + 1)) { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + } else { + Buf = 0; + if (WRITE(GifFile, &Buf, 1) != 1) { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + Private->PixelCount = 0; /* And local info. indicate image read. */ + } + + return GIF_OK; +} + +/****************************************************************************** +* This routine should be called last, to close GIF file. * +******************************************************************************/ +int EGifCloseFile(GifFileType *GifFile) +{ + GifByteType Buf; + GifFilePrivateType *Private; + int *File; + + if (GifFile == NULL) return GIF_ERROR; + + Private = (GifFilePrivateType *) GifFile->Private; + if (!IS_WRITEABLE(Private)) { + /* This file was NOT open for writing: */ + _GifError = E_GIF_ERR_NOT_WRITEABLE; + return GIF_ERROR; + } + + File = Private->File; + + Buf = ';'; + WRITE(GifFile, &Buf, 1); + + if (GifFile->Image.ColorMap) + FreeMapObject(GifFile->Image.ColorMap); + if (GifFile->SColorMap) + FreeMapObject(GifFile->SColorMap); + if (Private) { + free((char *) Private); + } + free(GifFile); + +// if (File && fclose(File) != 0) { +// _GifError = E_GIF_ERR_CLOSE_FAILED; +// return GIF_ERROR; +// } + return GIF_OK; +} + +/****************************************************************************** +* Put 2 bytes (word) into the given file: * +******************************************************************************/ +static int EGifPutWord(int Word, GifFileType *GifFile) +{ + char c[2]; + + c[0] = Word & 0xff; + c[1] = (Word >> 8) & 0xff; +#ifndef DEBUG_NO_PREFIX + if (WRITE(GifFile, c, 2) == 2) + return GIF_OK; + else + return GIF_ERROR; +#else + return GIF_OK; +#endif /* DEBUG_NO_PREFIX */ +} + +/****************************************************************************** +* Setup the LZ compression for this image: * +******************************************************************************/ +static int EGifSetupCompress(GifFileType *GifFile) +{ + int BitsPerPixel; + GifByteType Buf; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + /* Test and see what color map to use, and from it # bits per pixel: */ + if (GifFile->Image.ColorMap) + BitsPerPixel = GifFile->Image.ColorMap->BitsPerPixel; + else if (GifFile->SColorMap) + BitsPerPixel = GifFile->SColorMap->BitsPerPixel; + else { + _GifError = E_GIF_ERR_NO_COLOR_MAP; + return GIF_ERROR; + } + + Buf = BitsPerPixel = (BitsPerPixel < 2 ? 2 : BitsPerPixel); + WRITE(GifFile, &Buf, 1); /* Write the Code size to file. */ + + Private->Buf[0] = 0; /* Nothing was output yet. */ + Private->BitsPerPixel = BitsPerPixel; + Private->ClearCode = (1 << BitsPerPixel); + Private->EOFCode = Private->ClearCode + 1; + Private->RunningCode = 0; + Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */ + Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */ + Private->CrntCode = FIRST_CODE; /* Signal that this is first one! */ + Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */ + Private->CrntShiftDWord = 0; + + /* Send Clear to make sure the encoder is initialized. */ + if (EGifCompressOutput(GifFile, Private->ClearCode) == GIF_ERROR) { + _GifError = E_GIF_ERR_DISK_IS_FULL; + return GIF_ERROR; + } + return GIF_OK; +} + +/****************************************************************************** +* The LZ compression routine: * +* This version compress the given buffer Line of length LineLen. * +* This routine can be called few times (one per scan line, for example), in * +* order the complete the whole image. * +******************************************************************************/ +static int EGifCompressLine(GifFileType *GifFile, GifPixelType *Line, + int LineLen) +{ + int i = 0, CrntCode, NewCode; + unsigned long NewKey; + GifPixelType Pixel; + GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; + + if (Private->CrntCode == FIRST_CODE) /* Its first time! */ + CrntCode = Line[i++]; + else + CrntCode = Private->CrntCode; /* Get last code in compression. */ + + while (i < LineLen) { /* Decode LineLen items. */ + Pixel = Line[i++]; /* Get next pixel from stream. */ + if (EGifCompressOutput(GifFile, CrntCode) + == GIF_ERROR) { + _GifError = E_GIF_ERR_DISK_IS_FULL; + return GIF_ERROR; + } + Private->RunningCode++; + CrntCode = Pixel; + if (Private->RunningCode >= (1 << (Private->BitsPerPixel)) - 2) { + if (EGifCompressOutput(GifFile, Private->ClearCode) + == GIF_ERROR) { + _GifError = E_GIF_ERR_DISK_IS_FULL; + return GIF_ERROR; + } + Private->RunningCode=0; + } + } + + /* Preserve the current state of the compression algorithm: */ + Private->CrntCode = CrntCode; + + if (Private->PixelCount == 0) + { + /* We are done - output last Code and flush output buffers: */ + if (EGifCompressOutput(GifFile, CrntCode) + == GIF_ERROR) { + _GifError = E_GIF_ERR_DISK_IS_FULL; + return GIF_ERROR; + } + if (EGifCompressOutput(GifFile, Private->EOFCode) + == GIF_ERROR) { + _GifError = E_GIF_ERR_DISK_IS_FULL; + return GIF_ERROR; + } + if (EGifCompressOutput(GifFile, FLUSH_OUTPUT) == GIF_ERROR) { + _GifError = E_GIF_ERR_DISK_IS_FULL; + return GIF_ERROR; + } + } + + return GIF_OK; +} + +/****************************************************************************** +* The LZ compression output routine: * +* This routine is responsible for the compression of the bit stream into * +* 8 bits (bytes) packets. * +* Returns GIF_OK if written succesfully. * +******************************************************************************/ +static int EGifCompressOutput(GifFileType *GifFile, int Code) +{ + GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; + int retval = GIF_OK; + + if (Code == FLUSH_OUTPUT) { + while (Private->CrntShiftState > 0) { + /* Get Rid of what is left in DWord, and flush it. */ + if (EGifBufferedOutput(GifFile, Private->Buf, + Private->CrntShiftDWord & 0xff) == GIF_ERROR) + retval = GIF_ERROR; + Private->CrntShiftDWord >>= 8; + Private->CrntShiftState -= 8; + } + Private->CrntShiftState = 0; /* For next time. */ + if (EGifBufferedOutput(GifFile, Private->Buf, + FLUSH_OUTPUT) == GIF_ERROR) + retval = GIF_ERROR; + } + else { + Private->CrntShiftDWord |= ((long) Code) << Private->CrntShiftState; + Private->CrntShiftState += Private->RunningBits; + while (Private->CrntShiftState >= 8) { + /* Dump out full bytes: */ + if (EGifBufferedOutput(GifFile, Private->Buf, + Private->CrntShiftDWord & 0xff) == GIF_ERROR) + retval = GIF_ERROR; + Private->CrntShiftDWord >>= 8; + Private->CrntShiftState -= 8; + } + } + + return retval; +} + +/****************************************************************************** +* This routines buffers the given characters until 255 characters are ready * +* to be output. If Code is equal to -1 the buffer is flushed (EOF). * +* The buffer is Dumped with first byte as its size, as GIF format requires. * +* Returns GIF_OK if written succesfully. * +******************************************************************************/ +static int EGifBufferedOutput(GifFileType *GifFile, GifByteType *Buf, int c) +{ + if (c == FLUSH_OUTPUT) { + /* Flush everything out. */ + if (Buf[0] != 0 && WRITE(GifFile, Buf, Buf[0]+1) != (unsigned)(Buf[0] + 1)) + { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + /* Mark end of compressed data, by an empty block (see GIF doc): */ + Buf[0] = 0; + if (WRITE(GifFile, Buf, 1) != 1) + { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + } + else { + if (Buf[0] == 255) { + /* Dump out this buffer - it is full: */ + if (WRITE(GifFile, Buf, Buf[0] + 1) != (unsigned)(Buf[0] + 1)) + { + _GifError = E_GIF_ERR_WRITE_FAILED; + return GIF_ERROR; + } + Buf[0] = 0; + } + Buf[++Buf[0]] = c; + } + + return GIF_OK; +} + +/****************************************************************************** +* This routine writes to disk an in-core representation of a GIF previously * +* created by DGifSlurp(). * +******************************************************************************/ +int EGifSpew(GifFileType *GifFileOut) +{ + int i, j, gif89 = FALSE; + char SavedStamp[GIF_STAMP_LEN + 1]; + + for (i = 0; i < GifFileOut->ImageCount; i++) + { + for (j = 0; j < GifFileOut->SavedImages[i].ExtensionBlockCount; j++) { + int function=GifFileOut->SavedImages[i].ExtensionBlocks[j].Function; + + if (function == COMMENT_EXT_FUNC_CODE + || function == GRAPHICS_EXT_FUNC_CODE + || function == PLAINTEXT_EXT_FUNC_CODE + || function == APPLICATION_EXT_FUNC_CODE) + gif89 = TRUE; + } + } + + strncpy(SavedStamp, GifVersionPrefix, GIF_STAMP_LEN); + if (gif89) + { + strncpy(GifVersionPrefix, GIF89_STAMP, GIF_STAMP_LEN); + } + else + { + strncpy(GifVersionPrefix, GIF87_STAMP, GIF_STAMP_LEN); + } + if (EGifPutScreenDesc(GifFileOut, + GifFileOut->SWidth, + GifFileOut->SHeight, + GifFileOut->SColorResolution, + GifFileOut->SBackGroundColor, + GifFileOut->SColorMap) == GIF_ERROR) + { + strncpy(GifVersionPrefix, SavedStamp, GIF_STAMP_LEN); + return(GIF_ERROR); + } + strncpy(GifVersionPrefix, SavedStamp, GIF_STAMP_LEN); + + for (i = 0; i < GifFileOut->ImageCount; i++) + { + SavedImage *sp = &GifFileOut->SavedImages[i]; + int SavedHeight = sp->ImageDesc.Height; + int SavedWidth = sp->ImageDesc.Width; + ExtensionBlock *ep; + + /* this allows us to delete images by nuking their rasters */ + if (sp->RasterBits == NULL) + continue; + + if (sp->ExtensionBlocks) + { + for ( j = 0; j < sp->ExtensionBlockCount; j++) { + ep = &sp->ExtensionBlocks[j]; + if (EGifPutExtension(GifFileOut, + (ep->Function != 0) ? ep->Function : '\0', + ep->ByteCount, ep->Bytes) == GIF_ERROR) + return (GIF_ERROR); + } + } + + if (EGifPutImageDesc(GifFileOut, + sp->ImageDesc.Left, + sp->ImageDesc.Top, + SavedWidth, + SavedHeight, + sp->ImageDesc.Interlace, + sp->ImageDesc.ColorMap + ) == GIF_ERROR) + return(GIF_ERROR); + + for (j = 0; j < SavedHeight; j++) + { + if (EGifPutLine(GifFileOut, + (GifByteType*)(sp->RasterBits + j * SavedWidth), + SavedWidth) == GIF_ERROR) + return(GIF_ERROR); + } + } + + if (EGifCloseFile(GifFileOut) == GIF_ERROR) + return(GIF_ERROR); + + return(GIF_OK); +} diff --git a/libraries/external/lungif/egif_lib.o b/libraries/external/lungif/egif_lib.o new file mode 100644 index 0000000..f3a0f80 Binary files /dev/null and b/libraries/external/lungif/egif_lib.o differ diff --git a/libraries/external/lungif/gif2tmap.txt b/libraries/external/lungif/gif2tmap.txt new file mode 100755 index 0000000..4ea4076 --- /dev/null +++ b/libraries/external/lungif/gif2tmap.txt @@ -0,0 +1,134 @@ +#include "gif_lib.h" + +// ------------------------------------------------------------------- +// gif2tmap +// +// - load a gif file into an opengl texture map. returns 1 on +// success, 0 on faliure. + +int gif2tmap(char *filename, int glTex) +{ + GifFileType *gifObj = NULL; + unsigned char *pBuf = NULL, *pixels; + int i, w, h, bpp, c, r, ii, il_idx; + int trans = 0, transIndex = 0; + int il_row[4] = { 8, 8, 4, 2 }; + int il_srt[4] = { 0, 4, 2, 1 }; + + gifObj = DGifOpenFileName(filename); + if (!gifObj) + return 0; + + if (DGifSlurp(gifObj) != GIF_OK) + return 0; + + // - if this is an animated gif, we can't load it! + // + // NOTE: if we choose to continue loading animated gifs, + // only the first frame will work. "exotic" gifs that + // contain pixel information for only sections of the + // screen are almost always animated, and since subsections + // are currently unsupported, animated files SHOULD be + // unsupported as well. + + /* + if (gifObj->ImageCount > 1) + { + DGifCloseFile(gifObj); + return 0; + } + */ + + // - if the first bit of the extension block is set, we + // know that we have transparency. + + if (gifObj->SavedImages->ExtensionBlocks->Bytes[0] & 1) + { + trans = 1; + + // - the fourth byte in the block contains our + // transparency index; + + transIndex = gifObj->SavedImages->ExtensionBlocks->Bytes[3]; + } + + // - allocate our image + + bpp = trans ? 4 : 3; + + w = gifObj->SavedImages->ImageDesc.Width; + h = gifObj->SavedImages->ImageDesc.Height; + + pBuf = (unsigned char*)malloc(w * h * bpp); + pixels = pBuf; + + if (!gifObj->Image.Interlace) + { + // - non-interlaced: standard read + + for (i = 0; i < (w * h); i++) + { + c = (unsigned char)gifObj->SavedImages->RasterBits[i]; + + *pBuf++ = gifObj->SColorMap->Colors[c].Red; + *pBuf++ = gifObj->SColorMap->Colors[c].Green; + *pBuf++ = gifObj->SColorMap->Colors[c].Blue; + + if (trans && (transIndex == c)) + *pBuf++ = 0; + else if (trans) + *pBuf++ = 255; + } + } + else + { + // - interlaced: four groups of data + + ii = 0; + + for (il_idx = 0; il_idx < 4; il_idx++) + { + for (r = il_srt[il_idx]; r < h; r += il_row[il_idx]) + { + pBuf = pixels; + pBuf += (r * w * bpp); + + for (i = 0; i < w; i++) + { + c = (unsigned char)gifObj->SavedImages->RasterBits[ii++]; + + *pBuf++ = gifObj->SColorMap->Colors[c].Red; + *pBuf++ = gifObj->SColorMap->Colors[c].Green; + *pBuf++ = gifObj->SColorMap->Colors[c].Blue; + + if (trans && (transIndex == c)) + *pBuf++ = 0; + else if (trans) + *pBuf++ = 255; + } + + } + } + } + + // - copy the image to our gl texture + + glBindTexture(GL_TEXTURE_2D, glTex); + + if (trans) + glTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + else + glTexImage2D(GL_TEXTURE_2D, 0, 3, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + // - free up and leave! + + free(pixels); + + if (DGifCloseFile(gifObj) != GIF_OK) + return 0; + + return 1; +} \ No newline at end of file diff --git a/libraries/external/lungif/gif_err.c b/libraries/external/lungif/gif_err.c new file mode 100755 index 0000000..411b4a9 --- /dev/null +++ b/libraries/external/lungif/gif_err.c @@ -0,0 +1,134 @@ +/***************************************************************************** +* "Gif-Lib" - Yet another gif library. * +* * +* Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 * +****************************************************************************** +* Handle error reporting for the GIF library. * +****************************************************************************** +* History: * +* 17 Jun 89 - Version 1.0 by Gershon Elber. * +*****************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include "gif_lib.h" + +#define PROGRAM_NAME "GIF_LIBRARY" + +int _GifError = 0; + +#ifdef SYSV +static char *VersionStr = + "Gif library module,\t\tEric S. Raymond\n\ + (C) Copyright 1997 Eric S. Raymond\n"; +#else +static char *VersionStr = + PROGRAM_NAME + " IBMPC " + GIF_LIB_VERSION + " Eric S. Raymond, " + __DATE__ ", " __TIME__ "\n" + "(C) Copyright 1997 Eric S. Raymond\n"; +#endif /* SYSV */ + +/***************************************************************************** +* Return the last GIF error (0 if none) and reset the error. * +*****************************************************************************/ +int GifLastError(void) +{ + int i = _GifError; + + _GifError = 0; + + return i; +} + +/***************************************************************************** +* Print the last GIF error to stderr. * +*****************************************************************************/ +void PrintGifError(void) +{ + char *Err; + + switch(_GifError) { + case E_GIF_ERR_OPEN_FAILED: + Err = "Failed to open given file"; + break; + case E_GIF_ERR_WRITE_FAILED: + Err = "Failed to Write to given file"; + break; + case E_GIF_ERR_HAS_SCRN_DSCR: + Err = "Screen Descriptor already been set"; + break; + case E_GIF_ERR_HAS_IMAG_DSCR: + Err = "Image Descriptor is still active"; + break; + case E_GIF_ERR_NO_COLOR_MAP: + Err = "Neither Global Nor Local color map"; + break; + case E_GIF_ERR_DATA_TOO_BIG: + Err = "#Pixels bigger than Width * Height"; + break; + case E_GIF_ERR_NOT_ENOUGH_MEM: + Err = "Fail to allocate required memory"; + break; + case E_GIF_ERR_DISK_IS_FULL: + Err = "Write failed (disk full?)"; + break; + case E_GIF_ERR_CLOSE_FAILED: + Err = "Failed to close given file"; + break; + case E_GIF_ERR_NOT_WRITEABLE: + Err = "Given file was not opened for write"; + break; + case D_GIF_ERR_OPEN_FAILED: + Err = "Failed to open given file"; + break; + case D_GIF_ERR_READ_FAILED: + Err = "Failed to Read from given file"; + break; + case D_GIF_ERR_NOT_GIF_FILE: + Err = "Given file is NOT GIF file"; + break; + case D_GIF_ERR_NO_SCRN_DSCR: + Err = "No Screen Descriptor detected"; + break; + case D_GIF_ERR_NO_IMAG_DSCR: + Err = "No Image Descriptor detected"; + break; + case D_GIF_ERR_NO_COLOR_MAP: + Err = "Neither Global Nor Local color map"; + break; + case D_GIF_ERR_WRONG_RECORD: + Err = "Wrong record type detected"; + break; + case D_GIF_ERR_DATA_TOO_BIG: + Err = "#Pixels bigger than Width * Height"; + break; + case D_GIF_ERR_NOT_ENOUGH_MEM: + Err = "Fail to allocate required memory"; + break; + case D_GIF_ERR_CLOSE_FAILED: + Err = "Failed to close given file"; + break; + case D_GIF_ERR_NOT_READABLE: + Err = "Given file was not opened for read"; + break; + case D_GIF_ERR_IMAGE_DEFECT: + Err = "Image is defective, decoding aborted"; + break; + case D_GIF_ERR_EOF_TOO_SOON: + Err = "Image EOF detected, before image complete"; + break; + default: + Err = NULL; + break; + } + if (Err != NULL) + fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); + else + fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError); +} diff --git a/libraries/external/lungif/gif_err.o b/libraries/external/lungif/gif_err.o new file mode 100644 index 0000000..be1ad94 Binary files /dev/null and b/libraries/external/lungif/gif_err.o differ diff --git a/libraries/external/lungif/gif_lib.h b/libraries/external/lungif/gif_lib.h new file mode 100755 index 0000000..3515acc --- /dev/null +++ b/libraries/external/lungif/gif_lib.h @@ -0,0 +1,323 @@ +/****************************************************************************** +* In order to make life a little bit easier when using the GIF file format, * +* this library was written, and which does all the dirty work... * +* * +* Written by Gershon Elber, Jun. 1989 * +* Hacks by Eric S. Raymond, Sep. 1992 * +******************************************************************************* +* History: * +* 14 Jun 89 - Version 1.0 by Gershon Elber. * +* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names) * +* 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp) * +* 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) * +* 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code) * +******************************************************************************/ + +#ifndef _GIF_LIB_H +#define _GIF_LIB_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define GIF_LIB_VERSION " Version 4.0, " + +#define GIF_ERROR 0 +#define GIF_OK 1 + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif /* NULL */ + +#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */ +#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1 +#define GIF_VERSION_POS 3 /* Version first character in stamp. */ +#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */ +#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */ + +#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */ + +typedef int GifBooleanType; +typedef unsigned char GifPixelType; +typedef unsigned char * GifRowType; +typedef unsigned char GifByteType; + +#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg) +#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); } + +#ifdef SYSV +#define VoidPtr char * +#else +#define VoidPtr void * +#endif /* SYSV */ + +typedef struct GifColorType { + GifByteType Red, Green, Blue; +} GifColorType; + +typedef struct ColorMapObject +{ + int ColorCount; + int BitsPerPixel; + GifColorType *Colors; /* on malloc(3) heap */ +} +ColorMapObject; + +typedef struct GifImageDesc { + int Left, Top, Width, Height, /* Current image dimensions. */ + Interlace; /* Sequential/Interlaced lines. */ + ColorMapObject *ColorMap; /* The local color map */ +} GifImageDesc; + +typedef struct GifFileType { + int SWidth, SHeight, /* Screen dimensions. */ + SColorResolution, /* How many colors can we generate? */ + SBackGroundColor; /* I hope you understand this one... */ + ColorMapObject *SColorMap; /* NULL if not exists. */ + int ImageCount; /* Number of current image */ + GifImageDesc Image; /* Block describing current image */ + struct SavedImage *SavedImages; /* Use this to accumulate file state */ + VoidPtr UserData; /* hook to attach user data (TVT) */ + VoidPtr Private; /* Don't mess with this! */ +} GifFileType; + +typedef enum { + UNDEFINED_RECORD_TYPE, + SCREEN_DESC_RECORD_TYPE, + IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */ + EXTENSION_RECORD_TYPE, /* Begin with '!' */ + TERMINATE_RECORD_TYPE /* Begin with ';' */ +} GifRecordType; + +/* DumpScreen2Gif routine constants identify type of window/screen to dump. */ +/* Note all values below 1000 are reserved for the IBMPC different display */ +/* devices (it has many!) and are compatible with the numbering TC2.0 */ +/* (Turbo C 2.0 compiler for IBM PC) gives to these devices. */ +typedef enum { + GIF_DUMP_SGI_WINDOW = 1000, + GIF_DUMP_X_WINDOW = 1001 +} GifScreenDumpType; + +/* func type to read gif data from arbitrary sources (TVT) */ +typedef int (*InputFunc)(GifFileType*,GifByteType*,int); + +/* func type to write gif data ro arbitrary targets. + * Returns count of bytes written. (MRB) + */ +typedef int (*OutputFunc)(GifFileType *, const GifByteType *, int); +/****************************************************************************** +* GIF89 extension function codes * +******************************************************************************/ + +#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */ +#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control */ +#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */ +#define APPLICATION_EXT_FUNC_CODE 0xff /* application block */ + +/****************************************************************************** +* O.K., here are the routines one can access in order to encode GIF file: * +* (GIF_LIB file EGIF_LIB.C). * +******************************************************************************/ + +GifFileType *EGifOpenFileName(const char *GifFileName, int GifTestExistance); +GifFileType *EGifOpenFileHandle(int GifFileHandle); +GifFileType *EgifOpen(void *userPtr, OutputFunc writeFunc); +int EGifSpew(GifFileType *GifFile); +void EGifSetGifVersion(const char *Version); +int EGifPutScreenDesc(GifFileType *GifFile, + int GifWidth, int GifHeight, int GifColorRes, int GifBackGround, + const ColorMapObject *GifColorMap); +int EGifPutImageDesc(GifFileType *GifFile, + int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace, + const ColorMapObject *GifColorMap); +int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); +int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel); +int EGifPutComment(GifFileType *GifFile, const char *GifComment); +int EGifPutExtensionFirst(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutExtensionNext(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutExtensionLast(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen, + const VoidPtr GifExtension); +int EGifPutCode(GifFileType *GifFile, int GifCodeSize, + const GifByteType *GifCodeBlock); +int EGifPutCodeNext(GifFileType *GifFile, const GifByteType *GifCodeBlock); +int EGifCloseFile(GifFileType *GifFile); + +#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */ +#define E_GIF_ERR_WRITE_FAILED 2 +#define E_GIF_ERR_HAS_SCRN_DSCR 3 +#define E_GIF_ERR_HAS_IMAG_DSCR 4 +#define E_GIF_ERR_NO_COLOR_MAP 5 +#define E_GIF_ERR_DATA_TOO_BIG 6 +#define E_GIF_ERR_NOT_ENOUGH_MEM 7 +#define E_GIF_ERR_DISK_IS_FULL 8 +#define E_GIF_ERR_CLOSE_FAILED 9 +#define E_GIF_ERR_NOT_WRITEABLE 10 + +/****************************************************************************** +* O.K., here are the routines one can access in order to decode GIF file: * +* (GIF_LIB file DGIF_LIB.C). * +******************************************************************************/ + +GifFileType *DGifOpenFileName(const char *GifFileName); +GifFileType *DGifOpenFileHandle(FILE *FileHandle); +GifFileType *DGifOpen( void* userPtr, InputFunc readFunc ); /* new one (TVT) */ +int DGifSlurp(GifFileType *GifFile); +int DGifGetScreenDesc(GifFileType *GifFile); +int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType); +int DGifGetImageDesc(GifFileType *GifFile); +int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); +int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel); +int DGifGetComment(GifFileType *GifFile, char *GifComment); +int DGifGetExtension(GifFileType *GifFile, int *GifExtCode, + GifByteType **GifExtension); +int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension); +int DGifGetCode(GifFileType *GifFile, int *GifCodeSize, + GifByteType **GifCodeBlock); +int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock); +int DGifGetLZCodes(GifFileType *GifFile, int *GifCode); +int DGifCloseFile(GifFileType *GifFile); + +#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */ +#define D_GIF_ERR_READ_FAILED 102 +#define D_GIF_ERR_NOT_GIF_FILE 103 +#define D_GIF_ERR_NO_SCRN_DSCR 104 +#define D_GIF_ERR_NO_IMAG_DSCR 105 +#define D_GIF_ERR_NO_COLOR_MAP 106 +#define D_GIF_ERR_WRONG_RECORD 107 +#define D_GIF_ERR_DATA_TOO_BIG 108 +#define D_GIF_ERR_NOT_ENOUGH_MEM 109 +#define D_GIF_ERR_CLOSE_FAILED 110 +#define D_GIF_ERR_NOT_READABLE 111 +#define D_GIF_ERR_IMAGE_DEFECT 112 +#define D_GIF_ERR_EOF_TOO_SOON 113 + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file QUANTIZE.C. * +******************************************************************************/ +int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize, + GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput, + GifByteType *OutputBuffer, GifColorType *OutputColorMap); + + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file QPRINTF.C. * +******************************************************************************/ +extern int GifQuietPrint; + +#ifdef HAVE_VARARGS_H +extern void GifQprintf(); +#else +extern void GifQprintf(char *Format, ...); +#endif /* HAVE_VARARGS_H */ + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file GIF_ERR.C. * +******************************************************************************/ +extern void PrintGifError(void); +extern int GifLastError(void); + +/****************************************************************************** +* O.K., here are the routines from GIF_LIB file DEV2GIF.C. * +******************************************************************************/ +extern int DumpScreen2Gif(const char *FileName, + int ReqGraphDriver, + int ReqGraphMode1, + int ReqGraphMode2, + int ReqGraphMode3); + +/***************************************************************************** + * + * Everything below this point is new after version 1.2, supporting `slurp + * mode' for doing I/O in two big belts with all the image-bashing in core. + * + *****************************************************************************/ + +/****************************************************************************** +* Color Map handling from ALLOCGIF.C * +******************************************************************************/ + +extern ColorMapObject *MakeMapObject(int ColorCount, const GifColorType *ColorMap); +extern void FreeMapObject(ColorMapObject *Object); +extern ColorMapObject *UnionColorMap( + const ColorMapObject *ColorIn1, + const ColorMapObject *ColorIn2, + GifPixelType ColorTransIn2[]); +extern int BitSize(int n); + +/****************************************************************************** +* Support for the in-core structures allocation (slurp mode). * +******************************************************************************/ + +/* This is the in-core version of an extension record */ +typedef struct { + int ByteCount; + char *Bytes; /* on malloc(3) heap */ + int Function; /* Holds the type of the Extension block. */ +} ExtensionBlock; + +/* This holds an image header, its unpacked raster bits, and extensions */ +typedef struct SavedImage { + GifImageDesc ImageDesc; + + char *RasterBits; /* on malloc(3) heap */ + + int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function + * instead */ + int ExtensionBlockCount; + ExtensionBlock *ExtensionBlocks; /* on malloc(3) heap */ +} SavedImage; + +extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]); + +extern void MakeExtension(SavedImage *New, int Function); +extern int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]); +extern void FreeExtension(SavedImage *Image); + +extern SavedImage *MakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom); +extern void FreeSavedImages(GifFileType *GifFile); + +/****************************************************************************** +* The library's internal utility font * +******************************************************************************/ + +#define GIF_FONT_WIDTH 8 +#define GIF_FONT_HEIGHT 8 +extern unsigned char AsciiTable[][GIF_FONT_WIDTH]; + +extern void DrawText(SavedImage *Image, + const int x, const int y, + const char *legend, + const int color); + +extern void DrawBox(SavedImage *Image, + const int x, const int y, + const int w, const int d, + const int color); + +void DrawRectangle(SavedImage *Image, + const int x, const int y, + const int w, const int d, + const int color); + +extern void DrawBoxedText(SavedImage *Image, + const int x, const int y, + const char *legend, + const int border, + const int bg, + const int fg); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _GIF_LIB_H */ diff --git a/libraries/external/lungif/gif_lib_private.h b/libraries/external/lungif/gif_lib_private.h new file mode 100755 index 0000000..5dc93ff --- /dev/null +++ b/libraries/external/lungif/gif_lib_private.h @@ -0,0 +1,64 @@ +#ifndef _GIF_LIB_PRIVATE_H +#define _GIF_LIB_PRIVATE_H + +#include "gif_lib.h" + +#define PROGRAM_NAME "GIFLIB" + +#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ +#define LZ_BITS 12 + +#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */ +#define FIRST_CODE 4097 /* Impossible code, to signal first. */ +#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */ + +#define FILE_STATE_WRITE 0x01 +#define FILE_STATE_SCREEN 0x02 +#define FILE_STATE_IMAGE 0x04 +#define FILE_STATE_READ 0x08 + +#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ) +#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE) + + +typedef struct GifFilePrivateType { + int FileState, + FileHandle, /* Where all this data goes to! */ + BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */ + ClearCode, /* The CLEAR LZ code. */ + EOFCode, /* The EOF LZ code. */ + RunningCode, /* The next code algorithm can generate. */ + RunningBits,/* The number of bits required to represent RunningCode. */ + MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ + LastCode, /* The code before the current code. */ + CrntCode, /* Current algorithm code. */ + StackPtr, /* For character stack (see below). */ + CrntShiftState; /* Number of bits in CrntShiftDWord. */ + unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */ + unsigned long PixelCount; /* Number of pixels in image. */ + int *File; /* File as stream. */ + InputFunc Read; /* function to read gif input (TVT) */ + OutputFunc Write; /* function to write gif output (MRB) */ + GifByteType Buf[256]; /* Compressed input is buffered here. */ + GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */ + GifByteType Suffix[LZ_MAX_CODE+1]; /* So we can trace the codes. */ + unsigned int Prefix[LZ_MAX_CODE+1]; +} GifFilePrivateType; + +extern int _GifError; + +#ifdef SYSV +static char *VersionStr = + "Gif library module,\t\tEric S. Raymond\n\ + (C) Copyright 1997 Eric S. Raymond\n"; +#else +static char *VersionStr = + PROGRAM_NAME + " IBMPC " + GIF_LIB_VERSION + " Eric S. Raymond, " + __DATE__ ", " __TIME__ "\n" + "(C) Copyright 1997 Eric S. Raymond\n"; +#endif /* SYSV */ + +#endif /* _GIF_LIB_PRIVATE_H */ diff --git a/libraries/external/lungif/gifalloc.c b/libraries/external/lungif/gifalloc.c new file mode 100755 index 0000000..0d581c3 --- /dev/null +++ b/libraries/external/lungif/gifalloc.c @@ -0,0 +1,350 @@ +/***************************************************************************** +* "Gif-Lib" - Yet another gif library. * +* * +* Written by: Gershon Elber Ver 0.1, Jun. 1989 * +* Extensively hacked by: Eric S. Raymond Ver 1.?, Sep 1992 * +****************************************************************************** +* GIF construction tools * +****************************************************************************** +* History: * +* 15 Sep 92 - Version 1.0 by Eric Raymond. * +*****************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include "gif_lib.h" + +#define MAX(x, y) (((x) > (y)) ? (x) : (y)) + +/****************************************************************************** +* Miscellaneous utility functions * +******************************************************************************/ + +int BitSize(int n) +/* return smallest bitfield size n will fit in */ +{ + register i; + + for (i = 1; i <= 8; i++) + if ((1 << i) >= n) + break; + return(i); +} + + +/****************************************************************************** +* Color map object functions * +******************************************************************************/ + +ColorMapObject *MakeMapObject(int ColorCount, const GifColorType *ColorMap) +/* + * Allocate a color map of given size; initialize with contents of + * ColorMap if that pointer is non-NULL. + */ +{ + ColorMapObject *Object; + + if (ColorCount != (1 << BitSize(ColorCount))) + return((ColorMapObject *)NULL); + + Object = (ColorMapObject *)malloc(sizeof(ColorMapObject)); + if (Object == (ColorMapObject *)NULL) + return((ColorMapObject *)NULL); + + Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType)); + if (Object->Colors == (GifColorType *)NULL) + return((ColorMapObject *)NULL); + + Object->ColorCount = ColorCount; + Object->BitsPerPixel = BitSize(ColorCount); + + if (ColorMap) + memcpy((char *)Object->Colors, + (char *)ColorMap, ColorCount * sizeof(GifColorType)); + + return(Object); +} + +void FreeMapObject(ColorMapObject *Object) +/* + * Free a color map object + */ +{ + free(Object->Colors); + free(Object); +} + +#ifdef DEBUG +void DumpColorMap(ColorMapObject *Object, FILE *fp) +{ + if (Object) + { + int i, j, Len = Object->ColorCount; + + for (i = 0; i < Len; i+=4) { + for (j = 0; j < 4 && j < Len; j++) { + fprintf(fp, + "%3d: %02x %02x %02x ", i + j, + Object->Colors[i + j].Red, + Object->Colors[i + j].Green, + Object->Colors[i + j].Blue); + } + fprintf(fp, "\n"); + } + } +} +#endif /* DEBUG */ + +ColorMapObject *UnionColorMap( + const ColorMapObject *ColorIn1, + const ColorMapObject *ColorIn2, + GifPixelType ColorTransIn2[]) +/* + * Compute the union of two given color maps and return it. If result can't + * fit into 256 colors, NULL is returned, the allocated union otherwise. + * ColorIn1 is copied as is to ColorUnion, while colors from ColorIn2 are + * copied iff they didn't exist before. ColorTransIn2 maps the old + * ColorIn2 into ColorUnion color map table. + */ +{ + int i, j, CrntSlot, RoundUpTo, NewBitSize; + ColorMapObject *ColorUnion; + + /* + * Allocate table which will hold the result for sure. + */ + ColorUnion + = MakeMapObject(MAX(ColorIn1->ColorCount,ColorIn2->ColorCount)*2,NULL); + + if (ColorUnion == NULL) + return(NULL); + + /* Copy ColorIn1 to ColorUnionSize; */ + for (i = 0; i < ColorIn1->ColorCount; i++) + ColorUnion->Colors[i] = ColorIn1->Colors[i]; + CrntSlot = ColorIn1->ColorCount; + + /* + * Potentially obnoxious hack: + * + * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end + * of table 1. This is very useful if your display is limited to + * 16 colors. + */ + while (ColorIn1->Colors[CrntSlot-1].Red == 0 + && ColorIn1->Colors[CrntSlot-1].Green == 0 + && ColorIn1->Colors[CrntSlot-1].Red == 0) + CrntSlot--; + + /* Copy ColorIn2 to ColorUnionSize (use old colors if they exist): */ + for (i = 0; i < ColorIn2->ColorCount && CrntSlot<=256; i++) + { + /* Let's see if this color already exists: */ + for (j = 0; j < ColorIn1->ColorCount; j++) + if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i], sizeof(GifColorType)) == 0) + break; + + if (j < ColorIn1->ColorCount) + ColorTransIn2[i] = j; /* color exists in Color1 */ + else + { + /* Color is new - copy it to a new slot: */ + ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i]; + ColorTransIn2[i] = CrntSlot++; + } + } + + if (CrntSlot > 256) + { + FreeMapObject(ColorUnion); + return((ColorMapObject *)NULL); + } + + NewBitSize = BitSize(CrntSlot); + RoundUpTo = (1 << NewBitSize); + + if (RoundUpTo != ColorUnion->ColorCount) + { + register GifColorType *Map = ColorUnion->Colors; + + /* + * Zero out slots up to next power of 2. + * We know these slots exist because of the way ColorUnion's + * start dimension was computed. + */ + for (j = CrntSlot; j < RoundUpTo; j++) + Map[j].Red = Map[j].Green = Map[j].Blue = 0; + + /* perhaps we can shrink the map? */ + if (RoundUpTo < ColorUnion->ColorCount) + ColorUnion->Colors + = (GifColorType *)realloc(Map, sizeof(GifColorType)*RoundUpTo); + } + + ColorUnion->ColorCount = RoundUpTo; + ColorUnion->BitsPerPixel = NewBitSize; + + return(ColorUnion); +} + +void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]) +/* + * Apply a given color translation to the raster bits of an image + */ +{ + register int i; + register int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width; + + for (i = 0; i < RasterSize; i++) + Image->RasterBits[i] = Translation[Image->RasterBits[i]]; +} + +/****************************************************************************** +* Extension record functions * +******************************************************************************/ + +void MakeExtension(SavedImage *New, int Function) +{ + New->Function = Function; + /* + * Someday we might have to deal with multiple extensions. + */ +} + +int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]) +{ + ExtensionBlock *ep; + + if (New->ExtensionBlocks == NULL) + New->ExtensionBlocks = (ExtensionBlock *)malloc(sizeof(ExtensionBlock)); + else + New->ExtensionBlocks = + (ExtensionBlock *)realloc(New->ExtensionBlocks, + sizeof(ExtensionBlock) * (New->ExtensionBlockCount + 1)); + + if (New->ExtensionBlocks == NULL) + return(GIF_ERROR); + + ep = &New->ExtensionBlocks[New->ExtensionBlockCount++]; + + if ((ep->Bytes = (char *)malloc(ep->ByteCount = Len)) == NULL) + return(GIF_ERROR); + + if (ExtData) { + memcpy(ep->Bytes, ExtData, Len); + ep->Function = New->Function; + } + + return(GIF_OK); +} + +void FreeExtension(SavedImage *Image) +{ + ExtensionBlock *ep; + + for (ep = Image->ExtensionBlocks; + ep < Image->ExtensionBlocks + Image->ExtensionBlockCount; + ep++) + (void) free((char *)ep->Bytes); + free((char *)Image->ExtensionBlocks); + Image->ExtensionBlocks = NULL; +} + +/****************************************************************************** +* Image block allocation functions * +******************************************************************************/ +SavedImage *MakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) +/* + * Append an image block to the SavedImages array + */ +{ + SavedImage *sp; + + if (GifFile->SavedImages == NULL) + GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); + else + GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, + sizeof(SavedImage) * (GifFile->ImageCount+1)); + + if (GifFile->SavedImages == NULL) + return((SavedImage *)NULL); + else + { + sp = &GifFile->SavedImages[GifFile->ImageCount++]; + memset((char *)sp, '\0', sizeof(SavedImage)); + + if (CopyFrom) + { + memcpy((char *)sp, CopyFrom, sizeof(SavedImage)); + + /* + * Make our own allocated copies of the heap fields in the + * copied record. This guards against potential aliasing + * problems. + */ + + /* first, the local color map */ + if (sp->ImageDesc.ColorMap) + sp->ImageDesc.ColorMap = + MakeMapObject(CopyFrom->ImageDesc.ColorMap->ColorCount, + CopyFrom->ImageDesc.ColorMap->Colors); + + /* next, the raster */ + sp->RasterBits = (char *)malloc(sizeof(GifPixelType) + * CopyFrom->ImageDesc.Height + * CopyFrom->ImageDesc.Width); + memcpy(sp->RasterBits, + CopyFrom->RasterBits, + sizeof(GifPixelType) + * CopyFrom->ImageDesc.Height + * CopyFrom->ImageDesc.Width); + + /* finally, the extension blocks */ + if (sp->ExtensionBlocks) + { + sp->ExtensionBlocks + = (ExtensionBlock*)malloc(sizeof(ExtensionBlock) + * CopyFrom->ExtensionBlockCount); + memcpy(sp->ExtensionBlocks, + CopyFrom->ExtensionBlocks, + sizeof(ExtensionBlock) + * CopyFrom->ExtensionBlockCount); + + /* + * For the moment, the actual blocks can take their + * chances with free(). We'll fix this later. + */ + } + } + + return(sp); + } +} + +void FreeSavedImages(GifFileType *GifFile) +{ + SavedImage *sp; + + for (sp = GifFile->SavedImages; + sp < GifFile->SavedImages + GifFile->ImageCount; + sp++) + { + if (sp->ImageDesc.ColorMap) + FreeMapObject(sp->ImageDesc.ColorMap); + + if (sp->RasterBits) + free((char *)sp->RasterBits); + + if (sp->ExtensionBlocks) + FreeExtension(sp); + } + free((char *) GifFile->SavedImages); +} + + + diff --git a/libraries/external/lungif/gifalloc.o b/libraries/external/lungif/gifalloc.o new file mode 100644 index 0000000..cbed296 Binary files /dev/null and b/libraries/external/lungif/gifalloc.o differ diff --git a/libraries/external/lungif/lungif.a b/libraries/external/lungif/lungif.a new file mode 100644 index 0000000..b78049a Binary files /dev/null and b/libraries/external/lungif/lungif.a differ diff --git a/libraries/external/lungif/lungif.dsp b/libraries/external/lungif/lungif.dsp new file mode 100755 index 0000000..f7c9ac3 --- /dev/null +++ b/libraries/external/lungif/lungif.dsp @@ -0,0 +1,120 @@ +# Microsoft Developer Studio Project File - Name="lungif" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=lungif - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "lungif.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "lungif.mak" CFG="lungif - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "lungif - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "lungif - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/lungif", IFNAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "lungif - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "lungif - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=copy .\Debug\lungif.lib c:\G3\lib\ copy .\gif_lib.h c:\G3\include\ +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "lungif - Win32 Release" +# Name "lungif - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\dgif_lib.c +# End Source File +# Begin Source File + +SOURCE=.\egif_lib.c +# End Source File +# Begin Source File + +SOURCE=.\gif_err.c +# End Source File +# Begin Source File + +SOURCE=.\gifalloc.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\gif_lib.h +# End Source File +# Begin Source File + +SOURCE=.\gif_lib_private.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/external/lungif/lungif.dsw b/libraries/external/lungif/lungif.dsw new file mode 100755 index 0000000..326a479 --- /dev/null +++ b/libraries/external/lungif/lungif.dsw @@ -0,0 +1,37 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "lungif"=.\lungif.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/lungif", IFNAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/lungif", IFNAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/external/lungif/lungif.plg b/libraries/external/lungif/lungif.plg new file mode 100755 index 0000000..483c5bc --- /dev/null +++ b/libraries/external/lungif/lungif.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: lungif - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+lungif.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/external/lungif/makefile b/libraries/external/lungif/makefile new file mode 100755 index 0000000..cd42204 --- /dev/null +++ b/libraries/external/lungif/makefile @@ -0,0 +1,22 @@ +# makefile for linux lungif library + +.CFILES = dgif_lib.c egif_lib.c gif_err.c gifalloc.c + +.OFILES = $(.CFILES:.c=.o) + +TARGET = lungif.a + +CFLAGS = -w -O0 -g -I./ + +$(TARGET) : $(.OFILES) $(LIBS) $(DEPENDFILE) makefile + ar rs $(TARGET) $(.OFILES) + cp $(TARGET) /g3/lib + cp gif_lib.h /g3/include + +clean: + -rm $(.OFILES) $(DEPENDFILE) $(TARGET) + +$(DEPENDFILE): + $(CC) $(CFLAGS) -M $(.CFILES) > $(DEPENDFILE) + +include $(DEPENDFILE) diff --git a/libraries/external/lungif/mssccprj.scc b/libraries/external/lungif/mssccprj.scc new file mode 100755 index 0000000..872de43 --- /dev/null +++ b/libraries/external/lungif/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[lungif.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/external/lungif", IFNAAAAA diff --git a/libraries/external/lungif/vssver.scc b/libraries/external/lungif/vssver.scc new file mode 100755 index 0000000..85cab73 Binary files /dev/null and b/libraries/external/lungif/vssver.scc differ diff --git a/libraries/external/opencv/README.txt b/libraries/external/opencv/README.txt new file mode 100755 index 0000000..d6d69a6 --- /dev/null +++ b/libraries/external/opencv/README.txt @@ -0,0 +1,4 @@ +OpenCV - Open Computer Vision Library + +The Linux files are the limited subset that are needed for the IRTrack +system. \ No newline at end of file diff --git a/libraries/external/opencv/linux/include/cv.h b/libraries/external/opencv/linux/include/cv.h new file mode 100755 index 0000000..b35724d --- /dev/null +++ b/libraries/external/opencv/linux/include/cv.h @@ -0,0 +1,1208 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + + +#ifndef _CV_H_ +#define _CV_H_ + +#ifdef __IPL_H__ +#define HAVE_IPL +#endif + +#ifndef SKIP_INCLUDES + #if defined(_CH_) + #pragma package + #include + LOAD_CHDL(cv) + #endif +#endif + +#include "cxcore.h" +#include "cvtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Image Processing * +\****************************************************************************************/ + +/* Copies source 2D array inside of the larger destination array and + makes a border of the specified type (IPL_BORDER_*) around the copied area. */ +CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset, + int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0))); + +#define CV_BLUR_NO_SCALE 0 +#define CV_BLUR 1 +#define CV_GAUSSIAN 2 +#define CV_MEDIAN 3 +#define CV_BILATERAL 4 + +/* Smoothes array (removes noise) */ +CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst, + int smoothtype CV_DEFAULT(CV_GAUSSIAN), + int param1 CV_DEFAULT(3), + int param2 CV_DEFAULT(0), + double param3 CV_DEFAULT(0), + double param4 CV_DEFAULT(0)); + +/* Convolves the image with the kernel */ +CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, + CvPoint anchor CV_DEFAULT(cvPoint(-1,-1))); + +/* Finds integral image: SUM(X,Y) = sum(xnext[(edge + (int)type) & 3]; + return (edge & ~3) + ((edge + ((int)type >> 4)) & 3); +} + + +CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge ) +{ + CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); + return (CvSubdiv2DPoint*)e->pt[edge & 3]; +} + + +CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge ) +{ + CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3); + return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3]; +} + + +CV_INLINE double cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c ) +{ + return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); +} + + +/****************************************************************************************\ +* Contour Processing and Shape Analysis * +\****************************************************************************************/ + +#define CV_POLY_APPROX_DP 0 + +/* Approximates a single polygonal curve (contour) or + a tree of polygonal curves (contours) */ +CVAPI(CvSeq*) cvApproxPoly( const void* src_seq, + int header_size, CvMemStorage* storage, + int method, double parameter, + int parameter2 CV_DEFAULT(0)); + +#define CV_DOMINANT_IPAN 1 + +/* Finds high-curvature points of the contour */ +CVAPI(CvSeq*) cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage, + int method CV_DEFAULT(CV_DOMINANT_IPAN), + double parameter1 CV_DEFAULT(0), + double parameter2 CV_DEFAULT(0), + double parameter3 CV_DEFAULT(0), + double parameter4 CV_DEFAULT(0)); + +/* Calculates perimeter of a contour or length of a part of contour */ +CVAPI(double) cvArcLength( const void* curve, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ), + int is_closed CV_DEFAULT(-1)); +#define cvContourPerimeter( contour ) cvArcLength( contour, CV_WHOLE_SEQ, 1 ) + +/* Calculates contour boundning rectangle (update=1) or + just retrieves pre-calculated rectangle (update=0) */ +CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) ); + +/* Calculates area of a contour or contour segment */ +CVAPI(double) cvContourArea( const CvArr* contour, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ)); + +/* Finds minimum area rotated rectangle bounding a set of points */ +CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points, + CvMemStorage* storage CV_DEFAULT(NULL)); + +/* Finds minimum enclosing circle for a set of points */ +CVAPI(int) cvMinEnclosingCircle( const CvArr* points, + CvPoint2D32f* center, float* radius ); + +#define CV_CONTOURS_MATCH_I1 1 +#define CV_CONTOURS_MATCH_I2 2 +#define CV_CONTOURS_MATCH_I3 3 + +/* Compares two contours by matching their moments */ +CVAPI(double) cvMatchShapes( const void* object1, const void* object2, + int method, double parameter CV_DEFAULT(0)); + +/* Builds hierarhical representation of a contour */ +CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour, + CvMemStorage* storage, + double threshold ); + +/* Reconstruct (completelly or partially) contour a from contour tree */ +CVAPI(CvSeq*) cvContourFromContourTree( const CvContourTree* tree, + CvMemStorage* storage, + CvTermCriteria criteria ); + +/* Compares two contour trees */ +#define CV_CONTOUR_TREES_MATCH_I1 1 + +CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1, + const CvContourTree* tree2, + int method, double threshold ); + +/* Calculates histogram of a contour */ +CVAPI(void) cvCalcPGH( const CvSeq* contour, CvHistogram* hist ); + +#define CV_CLOCKWISE 1 +#define CV_COUNTER_CLOCKWISE 2 + +/* Calculates exact convex hull of 2d point set */ +CVAPI(CvSeq*) cvConvexHull2( const CvArr* input, + void* hull_storage CV_DEFAULT(NULL), + int orientation CV_DEFAULT(CV_CLOCKWISE), + int return_points CV_DEFAULT(0)); + +/* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */ +CVAPI(int) cvCheckContourConvexity( const CvArr* contour ); + +/* Finds convexity defects for the contour */ +CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull, + CvMemStorage* storage CV_DEFAULT(NULL)); + +/* Fits ellipse into a set of 2d points */ +CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points ); + +/* Finds minimum rectangle containing two given rectangles */ +CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 ); + +/* Finds coordinates of the box vertices */ +CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] ); + +/* Initializes sequence header for a matrix (column or row vector) of points - + a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */ +CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat, + CvContour* contour_header, + CvSeqBlock* block ); + +/* Checks whether the point is inside polygon, outside, on an edge (at a vertex). + Returns positive, negative or zero value, correspondingly. + Optionally, measures a signed distance between + the point and the nearest polygon edge (measure_dist=1) */ +CVAPI(double) cvPointPolygonTest( const CvArr* contour, + CvPoint2D32f pt, int measure_dist ); + +/****************************************************************************************\ +* Histogram functions * +\****************************************************************************************/ + +/* Creates new histogram */ +CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type, + float** ranges CV_DEFAULT(NULL), + int uniform CV_DEFAULT(1)); + +/* Assignes histogram bin ranges */ +CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges, + int uniform CV_DEFAULT(1)); + +/* Creates histogram header for array */ +CVAPI(CvHistogram*) cvMakeHistHeaderForArray( + int dims, int* sizes, CvHistogram* hist, + float* data, float** ranges CV_DEFAULT(NULL), + int uniform CV_DEFAULT(1)); + +/* Releases histogram */ +CVAPI(void) cvReleaseHist( CvHistogram** hist ); + +/* Clears all the histogram bins */ +CVAPI(void) cvClearHist( CvHistogram* hist ); + +/* Finds indices and values of minimum and maximum histogram bins */ +CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist, + float* min_value, float* max_value, + int* min_idx CV_DEFAULT(NULL), + int* max_idx CV_DEFAULT(NULL)); + + +/* Normalizes histogram by dividing all bins by sum of the bins, multiplied by . + After that sum of histogram bins is equal to */ +CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor ); + + +/* Clear all histogram bins that are below the threshold */ +CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold ); + +#define CV_COMP_CORREL 0 +#define CV_COMP_CHISQR 1 +#define CV_COMP_INTERSECT 2 +#define CV_COMP_BHATTACHARYYA 3 + +/* Compares two histogram */ +CVAPI(double) cvCompareHist( const CvHistogram* hist1, + const CvHistogram* hist2, + int method); + +/* Copies one histogram to another. Destination histogram is created if + the destination pointer is NULL */ +CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst ); + + +/* Calculates bayesian probabilistic histograms + (each or src and dst is an array of histograms */ +CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number, + CvHistogram** dst); + +/* Calculates array histogram */ +CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist, + int accumulate CV_DEFAULT(0), + const CvArr* mask CV_DEFAULT(NULL) ); + +CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist, + int accumulate CV_DEFAULT(0), + const CvArr* mask CV_DEFAULT(NULL) ) +{ + cvCalcArrHist( (CvArr**)image, hist, accumulate, mask ); +} + +/* Calculates back project */ +CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst, + const CvHistogram* hist ); +#define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist) + + +/* Does some sort of template matching but compares histograms of + template and each window location */ +CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range, + CvHistogram* hist, int method, + double factor ); +#define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \ + cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor ) + + +/* calculates probabilistic density (divides one histogram by another) */ +CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2, + CvHistogram* dst_hist, double scale CV_DEFAULT(255) ); + +/* equalizes histogram of 8-bit single-channel image */ +CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst ); + + +#define CV_VALUE 1 +#define CV_ARRAY 2 +/* Updates active contour in order to minimize its cummulative + (internal and external) energy. */ +CVAPI(void) cvSnakeImage( const IplImage* image, CvPoint* points, + int length, float* alpha, + float* beta, float* gamma, + int coeff_usage, CvSize win, + CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1)); + +/* Calculates the cooficients of the homography matrix */ +CVAPI(void) cvCalcImageHomography( float* line, CvPoint3D32f* center, + float* intrinsic, float* homography ); + +#define CV_DIST_MASK_3 3 +#define CV_DIST_MASK_5 5 +#define CV_DIST_MASK_PRECISE 0 + +/* Applies distance transform to binary image */ +CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst, + int distance_type CV_DEFAULT(CV_DIST_L2), + int mask_size CV_DEFAULT(3), + const float* mask CV_DEFAULT(NULL), + CvArr* labels CV_DEFAULT(NULL)); + + +/* Types of thresholding */ +#define CV_THRESH_BINARY 0 /* value = value > threshold ? max_value : 0 */ +#define CV_THRESH_BINARY_INV 1 /* value = value > threshold ? 0 : max_value */ +#define CV_THRESH_TRUNC 2 /* value = value > threshold ? threshold : value */ +#define CV_THRESH_TOZERO 3 /* value = value > threshold ? value : 0 */ +#define CV_THRESH_TOZERO_INV 4 /* value = value > threshold ? 0 : value */ +#define CV_THRESH_MASK 7 + +#define CV_THRESH_OTSU 8 /* use Otsu algorithm to choose the optimal threshold value; + combine the flag with one of the above CV_THRESH_* values */ + +/* Applies fixed-level threshold to grayscale image. + This is a basic operation applied before retrieving contours */ +CVAPI(void) cvThreshold( const CvArr* src, CvArr* dst, + double threshold, double max_value, + int threshold_type ); + +#define CV_ADAPTIVE_THRESH_MEAN_C 0 +#define CV_ADAPTIVE_THRESH_GAUSSIAN_C 1 + +/* Applies adaptive threshold to grayscale image. + The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and + CV_ADAPTIVE_THRESH_GAUSSIAN_C are: + neighborhood size (3, 5, 7 etc.), + and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */ +CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value, + int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C), + int threshold_type CV_DEFAULT(CV_THRESH_BINARY), + int block_size CV_DEFAULT(3), + double param1 CV_DEFAULT(5)); + +#define CV_FLOODFILL_FIXED_RANGE (1 << 16) +#define CV_FLOODFILL_MASK_ONLY (1 << 17) + +/* Fills the connected component until the color difference gets large enough */ +CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point, + CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)), + CvScalar up_diff CV_DEFAULT(cvScalarAll(0)), + CvConnectedComp* comp CV_DEFAULT(NULL), + int flags CV_DEFAULT(4), + CvArr* mask CV_DEFAULT(NULL)); + +/****************************************************************************************\ +* Feature detection * +\****************************************************************************************/ + +#define CV_CANNY_L2_GRADIENT (1 << 31) + +/* Runs canny edge detector */ +CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1, + double threshold2, int aperture_size CV_DEFAULT(3) ); + +/* Calculates constraint image for corner detection + Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. + Applying threshold to the result gives coordinates of corners */ +CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners, + int aperture_size CV_DEFAULT(3) ); + +/* Calculates eigen values and vectors of 2x2 + gradient covariation matrix at every image pixel */ +CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at + every image pixel */ +CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/* Harris corner detector: + Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */ +CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_responce, + int block_size, int aperture_size CV_DEFAULT(3), + double k CV_DEFAULT(0.04) ); + +/* Adjust corner position using some sort of gradient search */ +CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, + int count, CvSize win, CvSize zero_zone, + CvTermCriteria criteria ); + +/* Finds a sparse set of points within the selected region + that seem to be easy to track */ +CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, + CvArr* temp_image, CvPoint2D32f* corners, + int* corner_count, double quality_level, + double min_distance, + const CvArr* mask CV_DEFAULT(NULL), + int block_size CV_DEFAULT(3), + int use_harris CV_DEFAULT(0), + double k CV_DEFAULT(0.04) ); + +#define CV_HOUGH_STANDARD 0 +#define CV_HOUGH_PROBABILISTIC 1 +#define CV_HOUGH_MULTI_SCALE 2 +#define CV_HOUGH_GRADIENT 3 + +/* Finds lines on binary image using one of several methods. + line_storage is either memory storage or 1 x CvMat, its + number of columns is changed by the function. + method is one of CV_HOUGH_*; + rho, theta and threshold are used for each of those methods; + param1 ~ line length, param2 ~ line gap - for probabilistic, + param1 ~ srn, param2 ~ stn - for multi-scale */ +CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method, + double rho, double theta, int threshold, + double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0)); + +/* Finds circles in the image */ +CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage, + int method, double dp, double min_dist, + double param1 CV_DEFAULT(100), + double param2 CV_DEFAULT(100), + int min_radius CV_DEFAULT(0), + int max_radius CV_DEFAULT(0)); + +/* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */ +CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, + double reps, double aeps, float* line ); + +/****************************************************************************************\ +* Haar-like Object Detection functions * +\****************************************************************************************/ + +/* Loads haar classifier cascade from a directory. + It is obsolete: convert your cascade to xml and use cvLoad instead */ +CVAPI(CvHaarClassifierCascade*) cvLoadHaarClassifierCascade( + const char* directory, CvSize orig_window_size); + +CVAPI(void) cvReleaseHaarClassifierCascade( CvHaarClassifierCascade** cascade ); + +#define CV_HAAR_DO_CANNY_PRUNING 1 +#define CV_HAAR_SCALE_IMAGE 2 + +CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image, + CvHaarClassifierCascade* cascade, + CvMemStorage* storage, double scale_factor CV_DEFAULT(1.1), + int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0), + CvSize min_size CV_DEFAULT(cvSize(0,0))); + +/* sets images for haar classifier cascade */ +CVAPI(void) cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade, + const CvArr* sum, const CvArr* sqsum, + const CvArr* tilted_sum, double scale ); + +/* runs the cascade on the specified window */ +CVAPI(int) cvRunHaarClassifierCascade( CvHaarClassifierCascade* cascade, + CvPoint pt, int start_stage CV_DEFAULT(0)); + +/****************************************************************************************\ +* Camera Calibration and Rectification functions * +\****************************************************************************************/ + +/* transforms the input image to compensate lens distortion */ +CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst, + const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs ); + +/* computes transformation map from intrinsic camera parameters + that can used by cvRemap */ +CVAPI(void) cvInitUndistortMap( const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs, + CvArr* mapx, CvArr* mapy ); + +/* converts rotation vector to rotation matrix or vice versa */ +CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst, + CvMat* jacobian CV_DEFAULT(0) ); + +/* finds perspective transformation between the object plane and image (view) plane */ +CVAPI(void) cvFindHomography( const CvMat* src_points, + const CvMat* dst_points, + CvMat* homography ); + +/* projects object points to the view plane using + the specified extrinsic and intrinsic camera parameters */ +CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector, + const CvMat* translation_vector, const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs, CvMat* image_points, + CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL), + CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL), + CvMat* dpddist CV_DEFAULT(NULL) ); + +/* finds extrinsic camera parameters from + a few known corresponding point pairs and intrinsic parameters */ +CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points, + const CvMat* image_points, + const CvMat* intrinsic_matrix, + const CvMat* distortion_coeffs, + CvMat* rotation_vector, + CvMat* translation_vector ); + +#define CV_CALIB_USE_INTRINSIC_GUESS 1 +#define CV_CALIB_FIX_ASPECT_RATIO 2 +#define CV_CALIB_FIX_PRINCIPAL_POINT 4 +#define CV_CALIB_ZERO_TANGENT_DIST 8 + +/* finds intrinsic and extrinsic camera parameters + from a few views of known calibration pattern */ +CVAPI(void) cvCalibrateCamera2( const CvMat* object_points, + const CvMat* image_points, + const CvMat* point_counts, + CvSize image_size, + CvMat* intrinsic_matrix, + CvMat* distortion_coeffs, + CvMat* rotation_vectors CV_DEFAULT(NULL), + CvMat* translation_vectors CV_DEFAULT(NULL), + int flags CV_DEFAULT(0) ); + +#define CV_CALIB_CB_ADAPTIVE_THRESH 1 +#define CV_CALIB_CB_NORMALIZE_IMAGE 2 +#define CV_CALIB_CB_FILTER_QUADS 4 + +/* Detects corners on a chessboard calibration pattern */ +CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size, + CvPoint2D32f* corners, + int* corner_count CV_DEFAULT(NULL), + int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH) ); + +/* Draws individual chessboard corners or the whole chessboard detected */ +CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size, + CvPoint2D32f* corners, + int count, int pattern_was_found ); + +typedef struct CvPOSITObject CvPOSITObject; + +/* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */ +CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count ); + + +/* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of + an object given its model and projection in a weak-perspective case */ +CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points, + double focal_length, CvTermCriteria criteria, + CvMatr32f rotation_matrix, CvVect32f translation_vector); + +/* Releases CvPOSITObject structure */ +CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object ); + + +/****************************************************************************************\ +* Epipolar Geometry * +\****************************************************************************************/ + +CVAPI(void) cvConvertPointsHomogenious( const CvMat* src, CvMat* dst ); + +/* Calculates fundamental matrix given a set of corresponding points */ +#define CV_FM_7POINT 1 +#define CV_FM_8POINT 2 +#define CV_FM_LMEDS_ONLY 4 +#define CV_FM_RANSAC_ONLY 8 +#define CV_FM_LMEDS (CV_FM_LMEDS_ONLY + CV_FM_8POINT) +#define CV_FM_RANSAC (CV_FM_RANSAC_ONLY + CV_FM_8POINT) +CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2, + CvMat* fundamental_matrix, + int method CV_DEFAULT(CV_FM_RANSAC), + double param1 CV_DEFAULT(1.), double param2 CV_DEFAULT(0.99), + CvMat* status CV_DEFAULT(NULL) ); + +/* For each input point on one of images + computes parameters of the corresponding + epipolar line on the other image */ +CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points, + int which_image, + const CvMat* fundamental_matrix, + CvMat* correspondent_lines ); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +#include "cv.hpp" +#endif + +/****************************************************************************************\ +* Backward compatibility * +\****************************************************************************************/ + +#ifndef CV_NO_BACKWARD_COMPATIBILITY +#include "cvcompat.h" +#endif + +#endif /*_CV_H_*/ diff --git a/libraries/external/opencv/linux/include/cv.hpp b/libraries/external/opencv/linux/include/cv.hpp new file mode 100755 index 0000000..7d19e59 --- /dev/null +++ b/libraries/external/opencv/linux/include/cv.hpp @@ -0,0 +1,372 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CV_HPP_ +#define _CV_HPP_ + +#ifdef __cplusplus + +/****************************************************************************************\ +* CvBaseImageFilter: Base class for filtering operations * +\****************************************************************************************/ + +#define CV_WHOLE 0 +#define CV_START 1 +#define CV_END 2 +#define CV_MIDDLE 4 +#define CV_ISOLATED_ROI 8 + +typedef void (*CvRowFilterFunc)( const uchar* src, uchar* dst, void* params ); +typedef void (*CvColumnFilterFunc)( uchar** src, uchar* dst, int dst_step, int count, void* params ); + +class CV_EXPORTS CvBaseImageFilter +{ +public: + CvBaseImageFilter(); + /* calls init() */ + CvBaseImageFilter( int _max_width, int _src_type, int _dst_type, + bool _is_separable, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual ~CvBaseImageFilter(); + + /* initializes the class for processing an image of maximal width _max_width, + input image has data type _src_type, the output will have _dst_type. + _is_separable != 0 if the filter is separable + (specific behaviour is defined in a derived class), 0 otherwise. + _ksize and _anchor specify the kernel size and the anchor point. _anchor=(-1,-1) means + that the anchor is at the center. + to get interpolate pixel values outside the image _border_mode=IPL_BORDER_*** is used, + _border_value specify the pixel value in case of IPL_BORDER_CONSTANT border mode. + before initialization clear() is called if necessary. + */ + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _is_separable, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + /* releases all the internal buffers. + for the further use of the object, init() needs to be called. */ + virtual void clear(); + /* processes input image or a part of it. + input is represented either as matrix (CvMat* src) + or a list of row pointers (uchar** src2). + in the later case width, _src_y1 and _src_y2 are used to specify the size. + _dst is the output image/matrix. + _src_roi specifies the roi inside the input image to process, + (0,0,-1,-1) denotes the whole image. + _dst_origin is the upper-left corner of the filtered roi within the output image. + _phase is either CV_START, or CV_END, or CV_MIDDLE, or CV_START|CV_END, or CV_WHOLE, + which is the same as CV_START|CV_END. + CV_START means that the input is the first (top) stripe of the processed image [roi], + CV_END - the input is the last (bottom) stripe of the processed image [roi], + CV_MIDDLE - the input is neither first nor last stripe. + CV_WHOLE - the input is the whole processed image [roi]. + */ + virtual int process( const CvMat* _src, CvMat* _dst, + CvRect _src_roi=cvRect(0,0,-1,-1), + CvPoint _dst_origin=cvPoint(0,0), int _flags=0 ); + /* retrieve various parameters of the filtering object */ + int get_src_type() const { return src_type; } + int get_dst_type() const { return dst_type; } + int get_work_type() const { return work_type; } + CvSize get_kernel_size() const { return ksize; } + CvPoint get_anchor() const { return anchor; } + int get_width() const { return prev_x_range.end_index - prev_x_range.start_index; } + CvRowFilterFunc get_x_filter_func() const { return x_func; } + CvColumnFilterFunc get_y_filter_func() const { return y_func; } + +protected: + /* initializes work_type, buf_size and max_rows */ + virtual void get_work_params(); + /* it is called (not always) from process when _phase=CV_START or CV_WHOLE. + the method initializes ring buffer (buf_end, buf_head, buf_tail, buf_count, rows), + prev_width, prev_x_range, const_row, border_tab, border_tab_sz* */ + virtual void start_process( CvSlice x_range, int width ); + /* forms pointers to "virtual rows" above or below the processed roi using the specified + border mode */ + virtual void make_y_border( int row_count, int top_rows, int bottom_rows ); + + virtual int fill_cyclic_buffer( const uchar* src, int src_step, + int y, int y1, int y2 ); + + enum { ALIGN=32 }; + + int max_width; + /* currently, work_type must be the same as src_type in case of non-separable filters */ + int min_depth, src_type, dst_type, work_type; + + /* pointers to convolution functions, initialized by init method. + for non-separable filters only y_conv should be set */ + CvRowFilterFunc x_func; + CvColumnFilterFunc y_func; + + uchar* buffer; + uchar** rows; + int top_rows, bottom_rows, max_rows; + uchar *buf_start, *buf_end, *buf_head, *buf_tail; + int buf_size, buf_step, buf_count, buf_max_count; + + bool is_separable; + CvSize ksize; + CvPoint anchor; + int max_ky, border_mode; + CvScalar border_value; + uchar* const_row; + int* border_tab; + int border_tab_sz1, border_tab_sz; + + CvSlice prev_x_range; + int prev_width; +}; + + +/* Derived class, for linear separable filtering. */ +class CV_EXPORTS CvSepFilter : public CvBaseImageFilter +{ +public: + CvSepFilter(); + CvSepFilter( int _max_width, int _src_type, int _dst_type, + const CvMat* _kx, const CvMat* _ky, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual ~CvSepFilter(); + + virtual void init( int _max_width, int _src_type, int _dst_type, + const CvMat* _kx, const CvMat* _ky, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual void init_deriv( int _max_width, int _src_type, int _dst_type, + int dx, int dy, int aperture_size, int flags=0 ); + virtual void init_gaussian( int _max_width, int _src_type, int _dst_type, + int gaussian_size, double sigma ); + + /* dummy method to avoid compiler warnings */ + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _is_separable, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + virtual void clear(); + const CvMat* get_x_kernel() const { return kx; } + const CvMat* get_y_kernel() const { return ky; } + int get_x_kernel_flags() const { return kx_flags; } + int get_y_kernel_flags() const { return ky_flags; } + + enum { GENERIC=0, ASYMMETRICAL=1, SYMMETRICAL=2, POSITIVE=4, SUM_TO_1=8, INTEGER=16 }; + enum { NORMALIZE_KERNEL=1, FLIP_KERNEL=2 }; + + static void init_gaussian_kernel( CvMat* kernel, double sigma=-1 ); + static void init_sobel_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int flags=0 ); + static void init_scharr_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int flags=0 ); + +protected: + CvMat *kx, *ky; + int kx_flags, ky_flags; +}; + + +/* Derived class, for linear non-separable filtering. */ +class CV_EXPORTS CvLinearFilter : public CvBaseImageFilter +{ +public: + CvLinearFilter(); + CvLinearFilter( int _max_width, int _src_type, int _dst_type, + const CvMat* _kernel, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual ~CvLinearFilter(); + + virtual void init( int _max_width, int _src_type, int _dst_type, + const CvMat* _kernel, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + /* dummy method to avoid compiler warnings */ + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _is_separable, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + virtual void clear(); + const CvMat* get_kernel() const { return kernel; } + uchar* get_kernel_sparse_buf() { return k_sparse; } + int get_kernel_sparse_count() const { return k_sparse_count; } + +protected: + CvMat *kernel; + uchar* k_sparse; + int k_sparse_count; +}; + + +/* Box filter ("all 1's", optionally normalized) filter. */ +class CV_EXPORTS CvBoxFilter : public CvBaseImageFilter +{ +public: + CvBoxFilter(); + CvBoxFilter( int _max_width, int _src_type, int _dst_type, + bool _normalized, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _normalized, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + virtual ~CvBoxFilter(); + bool is_normalized() const { return normalized; } + double get_scale() const { return scale; } + uchar* get_sum_buf() { return sum; } + int* get_sum_count_ptr() { return &sum_count; } + +protected: + virtual void start_process( CvSlice x_range, int width ); + + uchar* sum; + int sum_count; + bool normalized; + double scale; +}; + + +/* Laplacian operator: (d2/dx + d2/dy)I. */ +class CV_EXPORTS CvLaplaceFilter : public CvSepFilter +{ +public: + CvLaplaceFilter(); + CvLaplaceFilter( int _max_width, int _src_type, int _dst_type, + bool _normalized, int _ksize, + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual ~CvLaplaceFilter(); + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _normalized, int _ksize, + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + /* dummy methods to avoid compiler warnings */ + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _is_separable, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + virtual void init( int _max_width, int _src_type, int _dst_type, + const CvMat* _kx, const CvMat* _ky, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + bool is_normalized() const { return normalized; } + bool is_basic_laplacian() const { return basic_laplacian; } +protected: + void get_work_params(); + + bool basic_laplacian; + bool normalized; +}; + + +/* basic morphological operations: erosion & dilation */ +class CV_EXPORTS CvMorphology : public CvBaseImageFilter +{ +public: + CvMorphology(); + CvMorphology( int _operation, int _max_width, int _src_dst_type, + int _element_shape, CvMat* _element, + CvSize _ksize=cvSize(0,0), CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + virtual ~CvMorphology(); + virtual void init( int _operation, int _max_width, int _src_dst_type, + int _element_shape, CvMat* _element, + CvSize _ksize=cvSize(0,0), CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + /* dummy method to avoid compiler warnings */ + virtual void init( int _max_width, int _src_type, int _dst_type, + bool _is_separable, CvSize _ksize, + CvPoint _anchor=cvPoint(-1,-1), + int _border_mode=IPL_BORDER_REPLICATE, + CvScalar _border_value=cvScalarAll(0) ); + + virtual void clear(); + const CvMat* get_element() const { return element; } + int get_element_shape() const { return el_shape; } + int get_operation() const { return operation; } + uchar* get_element_sparse_buf() { return el_sparse; } + int get_element_sparse_count() const { return el_sparse_count; } + + enum { RECT=0, CROSS=1, ELLIPSE=2, CUSTOM=100, BINARY = 0, GRAYSCALE=256 }; + enum { ERODE=0, DILATE=1 }; + + static void init_binary_element( CvMat* _element, int _element_shape, + CvPoint _anchor=cvPoint(-1,-1) ); +protected: + + void start_process( CvSlice x_range, int width ); + int fill_cyclic_buffer( const uchar* src, int src_step, + int y0, int y1, int y2 ); + uchar* el_sparse; + int el_sparse_count; + + CvMat *element; + int el_shape; + int operation; +}; + + +#endif /* __cplusplus */ + +#endif /* _CV_HPP_ */ + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/cvaux.h b/libraries/external/opencv/linux/include/cvaux.h new file mode 100755 index 0000000..df430e5 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvaux.h @@ -0,0 +1,1464 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __CVAUX__H__ +#define __CVAUX__H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +CVAPI(CvSeq*) cvSegmentImage( const CvArr* srcarr, CvArr* dstarr, + double canny_threshold, + double ffill_threshold, + CvMemStorage* storage ); + +/****************************************************************************************\ +* Eigen objects * +\****************************************************************************************/ + +typedef int (CV_CDECL * CvCallback)(int index, void* buffer, void* user_data); +typedef union +{ + CvCallback callback; + void* data; +} +CvInput; + +#define CV_EIGOBJ_NO_CALLBACK 0 +#define CV_EIGOBJ_INPUT_CALLBACK 1 +#define CV_EIGOBJ_OUTPUT_CALLBACK 2 +#define CV_EIGOBJ_BOTH_CALLBACK 3 + +/* Calculates covariation matrix of a set of arrays */ +CVAPI(void) cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags, + int ioBufSize, uchar* buffer, void* userData, + IplImage* avg, float* covarMatrix ); + +/* Calculates eigen values and vectors of covariation matrix of a set of + arrays */ +CVAPI(void) cvCalcEigenObjects( int nObjects, void* input, void* output, + int ioFlags, int ioBufSize, void* userData, + CvTermCriteria* calcLimit, IplImage* avg, + float* eigVals ); + +/* Calculates dot product (obj - avg) * eigObj (i.e. projects image to eigen vector) */ +CVAPI(double) cvCalcDecompCoeff( IplImage* obj, IplImage* eigObj, IplImage* avg ); + +/* Projects image to eigen space (finds all decomposion coefficients */ +CVAPI(void) cvEigenDecomposite( IplImage* obj, int nEigObjs, void* eigInput, + int ioFlags, void* userData, IplImage* avg, + float* coeffs ); + +/* Projects original objects used to calculate eigen space basis to that space */ +CVAPI(void) cvEigenProjection( void* eigInput, int nEigObjs, int ioFlags, + void* userData, float* coeffs, IplImage* avg, + IplImage* proj ); + +/****************************************************************************************\ +* 1D/2D HMM * +\****************************************************************************************/ + +typedef struct CvImgObsInfo +{ + int obs_x; + int obs_y; + int obs_size; + float* obs;//consequtive observations + + int* state;/* arr of pairs superstate/state to which observation belong */ + int* mix; /* number of mixture to which observation belong */ + +} +CvImgObsInfo;/*struct for 1 image*/ + +typedef CvImgObsInfo Cv1DObsInfo; + +typedef struct CvEHMMState +{ + int num_mix; /*number of mixtures in this state*/ + float* mu; /*mean vectors corresponding to each mixture*/ + float* inv_var; /* square root of inversed variances corresp. to each mixture*/ + float* log_var_val; /* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n */ + float* weight; /*array of mixture weights. Summ of all weights in state is 1. */ + +} +CvEHMMState; + +typedef struct CvEHMM +{ + int level; /* 0 - lowest(i.e its states are real states), ..... */ + int num_states; /* number of HMM states */ + float* transP;/*transition probab. matrices for states */ + float** obsProb; /* if level == 0 - array of brob matrices corresponding to hmm + if level == 1 - martix of matrices */ + union + { + CvEHMMState* state; /* if level == 0 points to real states array, + if not - points to embedded hmms */ + struct CvEHMM* ehmm; /* pointer to an embedded model or NULL, if it is a leaf */ + } u; + +} +CvEHMM; + +/*CVAPI(int) icvCreate1DHMM( CvEHMM** this_hmm, + int state_number, int* num_mix, int obs_size ); + +CVAPI(int) icvRelease1DHMM( CvEHMM** phmm ); + +CVAPI(int) icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm ); + +CVAPI(int) icvInit1DMixSegm( Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm); + +CVAPI(int) icvEstimate1DHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm); + +CVAPI(int) icvEstimate1DObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm ); + +CVAPI(int) icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array, + int num_seq, + CvEHMM* hmm ); + +CVAPI(float) icvViterbi( Cv1DObsInfo* obs_info, CvEHMM* hmm); + +CVAPI(int) icv1DMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm );*/ + +/*********************************** Embedded HMMs *************************************/ + +/* Creates 2D HMM */ +CVAPI(CvEHMM*) cvCreate2DHMM( int* stateNumber, int* numMix, int obsSize ); + +/* Releases HMM */ +CVAPI(void) cvRelease2DHMM( CvEHMM** hmm ); + +#define CV_COUNT_OBS(roi, win, delta, numObs ) \ +{ \ + (numObs)->width =((roi)->width -(win)->width +(delta)->width)/(delta)->width; \ + (numObs)->height =((roi)->height -(win)->height +(delta)->height)/(delta)->height;\ +} + +/* Creates storage for observation vectors */ +CVAPI(CvImgObsInfo*) cvCreateObsInfo( CvSize numObs, int obsSize ); + +/* Releases storage for observation vectors */ +CVAPI(void) cvReleaseObsInfo( CvImgObsInfo** obs_info ); + + +/* The function takes an image on input and and returns the sequnce of observations + to be used with an embedded HMM; Each observation is top-left block of DCT + coefficient matrix */ +CVAPI(void) cvImgToObs_DCT( const CvArr* arr, float* obs, CvSize dctSize, + CvSize obsSize, CvSize delta ); + + +/* Uniformly segments all observation vectors extracted from image */ +CVAPI(void) cvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* ehmm ); + +/* Does mixture segmentation of the states of embedded HMM */ +CVAPI(void) cvInitMixSegm( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/* Function calculates means, variances, weights of every Gaussian mixture + of every low-level state of embedded HMM */ +CVAPI(void) cvEstimateHMMStateParams( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/* Function computes transition probability matrices of embedded HMM + given observations segmentation */ +CVAPI(void) cvEstimateTransProb( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/* Function computes probabilities of appearing observations at any state + (i.e. computes P(obs|state) for every pair(obs,state)) */ +CVAPI(void) cvEstimateObsProb( CvImgObsInfo* obs_info, + CvEHMM* hmm ); + +/* Runs Viterbi algorithm for embedded HMM */ +CVAPI(float) cvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm ); + + +/* Function clusters observation vectors from several images + given observations segmentation. + Euclidean distance used for clustering vectors. + Centers of clusters are given means of every mixture */ +CVAPI(void) cvMixSegmL2( CvImgObsInfo** obs_info_array, + int num_img, CvEHMM* hmm ); + +/****************************************************************************************\ +* A few functions from old stereo gesture recognition demosions * +\****************************************************************************************/ + +/* Creates hand mask image given several points on the hand */ +CVAPI(void) cvCreateHandMask( CvSeq* hand_points, + IplImage *img_mask, CvRect *roi); + +/* Finds hand region in range image data */ +CVAPI(void) cvFindHandRegion (CvPoint3D32f* points, int count, + CvSeq* indexs, + float* line, CvSize2D32f size, int flag, + CvPoint3D32f* center, + CvMemStorage* storage, CvSeq **numbers); + +/* Finds hand region in range image data (advanced version) */ +CVAPI(void) cvFindHandRegionA( CvPoint3D32f* points, int count, + CvSeq* indexs, + float* line, CvSize2D32f size, int jc, + CvPoint3D32f* center, + CvMemStorage* storage, CvSeq **numbers); + +/****************************************************************************************\ +* Additional operations on Subdivisions * +\****************************************************************************************/ + +// paints voronoi diagram: just demo function +CVAPI(void) icvDrawMosaic( CvSubdiv2D* subdiv, IplImage* src, IplImage* dst ); + +// checks planar subdivision for correctness. It is not an absolute check, +// but it verifies some relations between quad-edges +CVAPI(int) icvSubdiv2DCheck( CvSubdiv2D* subdiv ); + +// returns squared distance between two 2D points with floating-point coordinates. +CV_INLINE double icvSqDist2D32f( CvPoint2D32f pt1, CvPoint2D32f pt2 ) +{ + double dx = pt1.x - pt2.x; + double dy = pt1.y - pt2.y; + + return dx*dx + dy*dy; +} + + +/****************************************************************************************\ +* More operations on sequences * +\****************************************************************************************/ + +/*****************************************************************************************/ + +#define CV_CURRENT_INT( reader ) (*((int *)(reader).ptr)) +#define CV_PREV_INT( reader ) (*((int *)(reader).prev_elem)) + +#define CV_GRAPH_WEIGHTED_VERTEX_FIELDS() CV_GRAPH_VERTEX_FIELDS()\ + float weight; + +#define CV_GRAPH_WEIGHTED_EDGE_FIELDS() CV_GRAPH_EDGE_FIELDS() + +typedef struct CvGraphWeightedVtx +{ + CV_GRAPH_WEIGHTED_VERTEX_FIELDS() +} +CvGraphWeightedVtx; + +typedef struct CvGraphWeightedEdge +{ + CV_GRAPH_WEIGHTED_EDGE_FIELDS() +} +CvGraphWeightedEdge; + +typedef enum CvGraphWeightType +{ + CV_NOT_WEIGHTED, + CV_WEIGHTED_VTX, + CV_WEIGHTED_EDGE, + CV_WEIGHTED_ALL +} CvGraphWeightType; + + +/*****************************************************************************************/ + + +/*******************************Stereo correspondence*************************************/ + +typedef struct CvCliqueFinder +{ + CvGraph* graph; + int** adj_matr; + int N; //graph size + + // stacks, counters etc/ + int k; //stack size + int* current_comp; + int** All; + + int* ne; + int* ce; + int* fixp; //node with minimal disconnections + int* nod; + int* s; //for selected candidate + int status; + int best_score; + int weighted; + int weighted_edges; + float best_weight; + float* edge_weights; + float* vertex_weights; + float* cur_weight; + float* cand_weight; + +} CvCliqueFinder; + +#define CLIQUE_TIME_OFF 2 +#define CLIQUE_FOUND 1 +#define CLIQUE_END 0 + +/*CVAPI(void) cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse, + int weighted CV_DEFAULT(0), int weighted_edges CV_DEFAULT(0)); +CVAPI(int) cvFindNextMaximalClique( CvCliqueFinder* finder, int* clock_rest CV_DEFAULT(0) ); +CVAPI(void) cvEndFindCliques( CvCliqueFinder* finder ); + +CVAPI(void) cvBronKerbosch( CvGraph* graph );*/ + + +/*F/////////////////////////////////////////////////////////////////////////////////////// +// +// Name: cvSubgraphWeight +// Purpose: finds weight of subgraph in a graph +// Context: +// Parameters: +// graph - input graph. +// subgraph - sequence of pairwise different ints. These are indices of vertices of subgraph. +// weight_type - describes the way we measure weight. +// one of the following: +// CV_NOT_WEIGHTED - weight of a clique is simply its size +// CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices +// CV_WEIGHTED_EDGE - the same but edges +// CV_WEIGHTED_ALL - the same but both edges and vertices +// weight_vtx - optional vector of floats, with size = graph->total. +// If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL +// weights of vertices must be provided. If weight_vtx not zero +// these weights considered to be here, otherwise function assumes +// that vertices of graph are inherited from CvGraphWeightedVtx. +// weight_edge - optional matrix of floats, of width and height = graph->total. +// If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL +// weights of edges ought to be supplied. If weight_edge is not zero +// function finds them here, otherwise function expects +// edges of graph to be inherited from CvGraphWeightedEdge. +// If this parameter is not zero structure of the graph is determined from matrix +// rather than from CvGraphEdge's. In particular, elements corresponding to +// absent edges should be zero. +// Returns: +// weight of subgraph. +// Notes: +//F*/ +/*CVAPI(float) cvSubgraphWeight( CvGraph *graph, CvSeq *subgraph, + CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), + CvVect32f weight_vtx CV_DEFAULT(0), + CvMatr32f weight_edge CV_DEFAULT(0) );*/ + + +/*F/////////////////////////////////////////////////////////////////////////////////////// +// +// Name: cvFindCliqueEx +// Purpose: tries to find clique with maximum possible weight in a graph +// Context: +// Parameters: +// graph - input graph. +// storage - memory storage to be used by the result. +// is_complementary - optional flag showing whether function should seek for clique +// in complementary graph. +// weight_type - describes our notion about weight. +// one of the following: +// CV_NOT_WEIGHTED - weight of a clique is simply its size +// CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices +// CV_WEIGHTED_EDGE - the same but edges +// CV_WEIGHTED_ALL - the same but both edges and vertices +// weight_vtx - optional vector of floats, with size = graph->total. +// If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL +// weights of vertices must be provided. If weight_vtx not zero +// these weights considered to be here, otherwise function assumes +// that vertices of graph are inherited from CvGraphWeightedVtx. +// weight_edge - optional matrix of floats, of width and height = graph->total. +// If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL +// weights of edges ought to be supplied. If weight_edge is not zero +// function finds them here, otherwise function expects +// edges of graph to be inherited from CvGraphWeightedEdge. +// Note that in case of CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL +// nonzero is_complementary implies nonzero weight_edge. +// start_clique - optional sequence of pairwise different ints. They are indices of +// vertices that shall be present in the output clique. +// subgraph_of_ban - optional sequence of (maybe equal) ints. They are indices of +// vertices that shall not be present in the output clique. +// clique_weight_ptr - optional output parameter. Weight of found clique stored here. +// num_generations - optional number of generations in evolutionary part of algorithm, +// zero forces to return first found clique. +// quality - optional parameter determining degree of required quality/speed tradeoff. +// Must be in the range from 0 to 9. +// 0 is fast and dirty, 9 is slow but hopefully yields good clique. +// Returns: +// sequence of pairwise different ints. +// These are indices of vertices that form found clique. +// Notes: +// in cases of CV_WEIGHTED_EDGE and CV_WEIGHTED_ALL weights should be nonnegative. +// start_clique has a priority over subgraph_of_ban. +//F*/ +/*CVAPI(CvSeq*) cvFindCliqueEx( CvGraph *graph, CvMemStorage *storage, + int is_complementary CV_DEFAULT(0), + CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED), + CvVect32f weight_vtx CV_DEFAULT(0), + CvMatr32f weight_edge CV_DEFAULT(0), + CvSeq *start_clique CV_DEFAULT(0), + CvSeq *subgraph_of_ban CV_DEFAULT(0), + float *clique_weight_ptr CV_DEFAULT(0), + int num_generations CV_DEFAULT(3), + int quality CV_DEFAULT(2) );*/ + + +#define CV_UNDEF_SC_PARAM 12345 //default value of parameters + +#define CV_IDP_BIRCHFIELD_PARAM1 25 +#define CV_IDP_BIRCHFIELD_PARAM2 5 +#define CV_IDP_BIRCHFIELD_PARAM3 12 +#define CV_IDP_BIRCHFIELD_PARAM4 15 +#define CV_IDP_BIRCHFIELD_PARAM5 25 + + +#define CV_DISPARITY_BIRCHFIELD 0 + + +/*F/////////////////////////////////////////////////////////////////////////// +// +// Name: cvFindStereoCorrespondence +// Purpose: find stereo correspondence on stereo-pair +// Context: +// Parameters: +// leftImage - left image of stereo-pair (format 8uC1). +// rightImage - right image of stereo-pair (format 8uC1). +// mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only) +// dispImage - destination disparity image +// maxDisparity - maximal disparity +// param1, param2, param3, param4, param5 - parameters of algorithm +// Returns: +// Notes: +// Images must be rectified. +// All images must have format 8uC1. +//F*/ +CVAPI(void) +cvFindStereoCorrespondence( + const CvArr* leftImage, const CvArr* rightImage, + int mode, + CvArr* dispImage, + int maxDisparity, + double param1 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param2 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param3 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param4 CV_DEFAULT(CV_UNDEF_SC_PARAM), + double param5 CV_DEFAULT(CV_UNDEF_SC_PARAM) ); + +/*****************************************************************************************/ +/************ Epiline functions *******************/ + + + +typedef struct CvStereoLineCoeff +{ + double Xcoef; + double XcoefA; + double XcoefB; + double XcoefAB; + + double Ycoef; + double YcoefA; + double YcoefB; + double YcoefAB; + + double Zcoef; + double ZcoefA; + double ZcoefB; + double ZcoefAB; +}CvStereoLineCoeff; + + +typedef struct CvCamera +{ + float imgSize[2]; /* size of the camera view, used during calibration */ + float matrix[9]; /* intinsic camera parameters: [ fx 0 cx; 0 fy cy; 0 0 1 ] */ + float distortion[4]; /* distortion coefficients - two coefficients for radial distortion + and another two for tangential: [ k1 k2 p1 p2 ] */ + float rotMatr[9]; + float transVect[3]; /* rotation matrix and transition vector relatively + to some reference point in the space. */ +} +CvCamera; + +typedef struct CvStereoCamera +{ + CvCamera* camera[2]; /* two individual camera parameters */ + float fundMatr[9]; /* fundamental matrix */ + + /* New part for stereo */ + CvPoint3D32f epipole[2]; + CvPoint2D32f quad[2][4]; /* coordinates of destination quadrangle after + epipolar geometry rectification */ + double coeffs[2][3][3];/* coefficients for transformation */ + CvPoint2D32f border[2][4]; + CvSize warpSize; + CvStereoLineCoeff* lineCoeffs; + int needSwapCameras;/* flag set to 1 if need to swap cameras for good reconstruction */ + float rotMatrix[9]; + float transVector[3]; +} +CvStereoCamera; + + +typedef struct CvContourOrientation +{ + float egvals[2]; + float egvects[4]; + + float max, min; // minimum and maximum projections + int imax, imin; +} CvContourOrientation; + +#define CV_CAMERA_TO_WARP 1 +#define CV_WARP_TO_CAMERA 2 + +CVAPI(int) icvConvertWarpCoordinates(double coeffs[3][3], + CvPoint2D32f* cameraPoint, + CvPoint2D32f* warpPoint, + int direction); + +CVAPI(int) icvGetSymPoint3D( CvPoint3D64d pointCorner, + CvPoint3D64d point1, + CvPoint3D64d point2, + CvPoint3D64d *pointSym2); + +CVAPI(void) icvGetPieceLength3D(CvPoint3D64d point1,CvPoint3D64d point2,double* dist); + +CVAPI(int) icvCompute3DPoint( double alpha,double betta, + CvStereoLineCoeff* coeffs, + CvPoint3D64d* point); + +CVAPI(int) icvCreateConvertMatrVect( CvMatr64d rotMatr1, + CvMatr64d transVect1, + CvMatr64d rotMatr2, + CvMatr64d transVect2, + CvMatr64d convRotMatr, + CvMatr64d convTransVect); + +CVAPI(int) icvConvertPointSystem(CvPoint3D64d M2, + CvPoint3D64d* M1, + CvMatr64d rotMatr, + CvMatr64d transVect + ); + +CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera); + +CVAPI(int) icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross); +CVAPI(int) icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross); +CVAPI(float) icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point); +CVAPI(int) icvStereoCalibration( int numImages, + int* nums, + CvSize imageSize, + CvPoint2D32f* imagePoints1, + CvPoint2D32f* imagePoints2, + CvPoint3D32f* objectPoints, + CvStereoCamera* stereoparams + ); + + +CVAPI(int) icvComputeRestStereoParams(CvStereoCamera *stereoparams); + +CVAPI(void) cvComputePerspectiveMap( const double coeffs[3][3], CvArr* rectMapX, CvArr* rectMapY ); + +CVAPI(int) icvComCoeffForLine( CvPoint2D64d point1, + CvPoint2D64d point2, + CvPoint2D64d point3, + CvPoint2D64d point4, + CvMatr64d camMatr1, + CvMatr64d rotMatr1, + CvMatr64d transVect1, + CvMatr64d camMatr2, + CvMatr64d rotMatr2, + CvMatr64d transVect2, + CvStereoLineCoeff* coeffs, + int* needSwapCameras); + +CVAPI(int) icvGetDirectionForPoint( CvPoint2D64d point, + CvMatr64d camMatr, + CvPoint3D64d* direct); + +CVAPI(int) icvGetCrossLines(CvPoint3D64d point11,CvPoint3D64d point12, + CvPoint3D64d point21,CvPoint3D64d point22, + CvPoint3D64d* midPoint); + +CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64d pointA, + CvPoint3D64d pointB, + CvPoint3D64d pointCam1, + double gamma, + CvStereoLineCoeff* coeffs); + +/*CVAPI(int) icvComputeFundMatrEpipoles ( CvMatr64d camMatr1, + CvMatr64d rotMatr1, + CvVect64d transVect1, + CvMatr64d camMatr2, + CvMatr64d rotMatr2, + CvVect64d transVect2, + CvPoint2D64d* epipole1, + CvPoint2D64d* epipole2, + CvMatr64d fundMatr);*/ + +CVAPI(int) icvGetAngleLine( CvPoint2D64d startPoint, CvSize imageSize,CvPoint2D64d *point1,CvPoint2D64d *point2); + +CVAPI(void) icvGetCoefForPiece( CvPoint2D64d p_start,CvPoint2D64d p_end, + double *a,double *b,double *c, + int* result); + +/*CVAPI(void) icvGetCommonArea( CvSize imageSize, + CvPoint2D64d epipole1,CvPoint2D64d epipole2, + CvMatr64d fundMatr, + CvVect64d coeff11,CvVect64d coeff12, + CvVect64d coeff21,CvVect64d coeff22, + int* result);*/ + +CVAPI(void) icvComputeeInfiniteProject1(CvMatr64d rotMatr, + CvMatr64d camMatr1, + CvMatr64d camMatr2, + CvPoint2D32f point1, + CvPoint2D32f *point2); + +CVAPI(void) icvComputeeInfiniteProject2(CvMatr64d rotMatr, + CvMatr64d camMatr1, + CvMatr64d camMatr2, + CvPoint2D32f* point1, + CvPoint2D32f point2); + +CVAPI(void) icvGetCrossDirectDirect( CvVect64d direct1,CvVect64d direct2, + CvPoint2D64d *cross,int* result); + +CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64d p_start,CvPoint2D64d p_end, + double a,double b,double c, + CvPoint2D64d *cross,int* result); + +CVAPI(void) icvGetCrossPiecePiece( CvPoint2D64d p1_start,CvPoint2D64d p1_end, + CvPoint2D64d p2_start,CvPoint2D64d p2_end, + CvPoint2D64d* cross, + int* result); + +CVAPI(void) icvGetPieceLength(CvPoint2D64d point1,CvPoint2D64d point2,double* dist); + +CVAPI(void) icvGetCrossRectDirect( CvSize imageSize, + double a,double b,double c, + CvPoint2D64d *start,CvPoint2D64d *end, + int* result); + +CVAPI(void) icvProjectPointToImage( CvPoint3D64d point, + CvMatr64d camMatr,CvMatr64d rotMatr,CvVect64d transVect, + CvPoint2D64d* projPoint); + +CVAPI(void) icvGetQuadsTransform( CvSize imageSize, + CvMatr64d camMatr1, + CvMatr64d rotMatr1, + CvVect64d transVect1, + CvMatr64d camMatr2, + CvMatr64d rotMatr2, + CvVect64d transVect2, + CvSize* warpSize, + double quad1[4][2], + double quad2[4][2], + CvMatr64d fundMatr, + CvPoint3D64d* epipole1, + CvPoint3D64d* epipole2 + ); + +CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera); + +CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera); + +CVAPI(void) icvGetCutPiece( CvVect64d areaLineCoef1,CvVect64d areaLineCoef2, + CvPoint2D64d epipole, + CvSize imageSize, + CvPoint2D64d* point11,CvPoint2D64d* point12, + CvPoint2D64d* point21,CvPoint2D64d* point22, + int* result); + +CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64d basePoint, + CvPoint2D64d point1,CvPoint2D64d point2, + CvPoint2D64d* midPoint); + +CVAPI(void) icvGetNormalDirect(CvVect64d direct,CvPoint2D64d point,CvVect64d normDirect); + +CVAPI(double) icvGetVect(CvPoint2D64d basePoint,CvPoint2D64d point1,CvPoint2D64d point2); + +CVAPI(void) icvProjectPointToDirect( CvPoint2D64d point,CvVect64d lineCoeff, + CvPoint2D64d* projectPoint); + +CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64d point,CvVect64d lineCoef,double*dist); + +CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst, + int desired_depth, int desired_num_channels ); + +CVAPI(void) cvDeInterlace( const CvArr* frame, CvArr* fieldEven, CvArr* fieldOdd ); + +/*CVAPI(int) icvSelectBestRt( int numImages, + int* numPoints, + CvSize imageSize, + CvPoint2D32f* imagePoints1, + CvPoint2D32f* imagePoints2, + CvPoint3D32f* objectPoints, + + CvMatr32f cameraMatrix1, + CvVect32f distortion1, + CvMatr32f rotMatrs1, + CvVect32f transVects1, + + CvMatr32f cameraMatrix2, + CvVect32f distortion2, + CvMatr32f rotMatrs2, + CvVect32f transVects2, + + CvMatr32f bestRotMatr, + CvVect32f bestTransVect + );*/ + +/****************************************************************************************\ +* Contour Morphing * +\****************************************************************************************/ + +/* finds correspondence between two contours */ +CvSeq* cvCalcContoursCorrespondence( const CvSeq* contour1, + const CvSeq* contour2, + CvMemStorage* storage); + +/* morphs contours using the pre-calculated correspondence: + alpha=0 ~ contour1, alpha=1 ~ contour2 */ +CvSeq* cvMorphContours( const CvSeq* contour1, const CvSeq* contour2, + CvSeq* corr, double alpha, + CvMemStorage* storage ); + +/****************************************************************************************\ +* Texture Descriptors * +\****************************************************************************************/ + +#define CV_GLCM_OPTIMIZATION_NONE -2 +#define CV_GLCM_OPTIMIZATION_LUT -1 +#define CV_GLCM_OPTIMIZATION_HISTOGRAM 0 + +#define CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST 10 +#define CV_GLCMDESC_OPTIMIZATION_ALLOWTRIPLENEST 11 +#define CV_GLCMDESC_OPTIMIZATION_HISTOGRAM 4 + +#define CV_GLCMDESC_ENTROPY 0 +#define CV_GLCMDESC_ENERGY 1 +#define CV_GLCMDESC_HOMOGENITY 2 +#define CV_GLCMDESC_CONTRAST 3 +#define CV_GLCMDESC_CLUSTERTENDENCY 4 +#define CV_GLCMDESC_CLUSTERSHADE 5 +#define CV_GLCMDESC_CORRELATION 6 +#define CV_GLCMDESC_CORRELATIONINFO1 7 +#define CV_GLCMDESC_CORRELATIONINFO2 8 +#define CV_GLCMDESC_MAXIMUMPROBABILITY 9 + +#define CV_GLCM_ALL 0 +#define CV_GLCM_GLCM 1 +#define CV_GLCM_DESC 2 + +typedef struct CvGLCM CvGLCM; + +CVAPI(CvGLCM*) cvCreateGLCM( const IplImage* srcImage, + int stepMagnitude, + const int* stepDirections CV_DEFAULT(0), + int numStepDirections CV_DEFAULT(0), + int optimizationType CV_DEFAULT(CV_GLCM_OPTIMIZATION_NONE)); + +CVAPI(void) cvReleaseGLCM( CvGLCM** GLCM, int flag CV_DEFAULT(CV_GLCM_ALL)); + +CVAPI(void) cvCreateGLCMDescriptors( CvGLCM* destGLCM, + int descriptorOptimizationType + CV_DEFAULT(CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST)); + +CVAPI(double) cvGetGLCMDescriptor( CvGLCM* GLCM, int step, int descriptor ); + +CVAPI(void) cvGetGLCMDescriptorStatistics( CvGLCM* GLCM, int descriptor, + double* average, double* standardDeviation ); + +CVAPI(IplImage*) cvCreateGLCMImage( CvGLCM* GLCM, int step ); + +/****************************************************************************************\ +* Face eyes&mouth tracking * +\****************************************************************************************/ + + +typedef struct CvFaceTracker CvFaceTracker; + +#define CV_NUM_FACE_ELEMENTS 3 +enum CV_FACE_ELEMENTS +{ + CV_FACE_MOUTH = 0, + CV_FACE_LEFT_EYE = 1, + CV_FACE_RIGHT_EYE = 2 +}; + +CVAPI(CvFaceTracker*) cvInitFaceTracker(CvFaceTracker* pFaceTracking, const IplImage* imgGray, + CvRect* pRects, int nRects); +CVAPI(int) cvTrackFace( CvFaceTracker* pFaceTracker, IplImage* imgGray, + CvRect* pRects, int nRects, + CvPoint* ptRotate, double* dbAngleRotate); +CVAPI(void) cvReleaseFaceTracker(CvFaceTracker** ppFaceTracker); + + +typedef struct CvFace +{ + CvRect MouthRect; + CvRect LeftEyeRect; + CvRect RightEyeRect; +} CvFaceData; + +CvSeq * cvFindFace(IplImage * Image,CvMemStorage* storage); +CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage); + + +/****************************************************************************************\ +* 3D Tracker * +\****************************************************************************************/ + +typedef unsigned char CvBool; + +typedef struct +{ + int id; + CvPoint2D32f p; // pgruebele: So we do not loose precision, this needs to be float +} Cv3dTracker2dTrackedObject; + +CV_INLINE Cv3dTracker2dTrackedObject cv3dTracker2dTrackedObject(int id, CvPoint2D32f p) +{ + Cv3dTracker2dTrackedObject r; + r.id = id; + r.p = p; + return r; +} + +typedef struct +{ + int id; + CvPoint3D32f p; // location of the tracked object +} Cv3dTrackerTrackedObject; + +CV_INLINE Cv3dTrackerTrackedObject cv3dTrackerTrackedObject(int id, CvPoint3D32f p) +{ + Cv3dTrackerTrackedObject r; + r.id = id; + r.p = p; + return r; +} + +typedef struct +{ + CvBool valid; + float mat[4][4]; /* maps camera coordinates to world coordinates */ + CvPoint2D32f principal_point; /* copied from intrinsics so this structure */ + /* has all the info we need */ +} Cv3dTrackerCameraInfo; + +typedef struct +{ + CvPoint2D32f principal_point; + float focal_length[2]; + float distortion[4]; +} Cv3dTrackerCameraIntrinsics; + +CVAPI(CvBool) cv3dTrackerCalibrateCameras(int num_cameras, + const Cv3dTrackerCameraIntrinsics camera_intrinsics[], /* size is num_cameras */ + CvSize etalon_size, + float square_size, + IplImage *samples[], /* size is num_cameras */ + Cv3dTrackerCameraInfo camera_info[]); /* size is num_cameras */ + +CVAPI(int) cv3dTrackerLocateObjects(int num_cameras, int num_objects, + const Cv3dTrackerCameraInfo camera_info[], /* size is num_cameras */ + const Cv3dTracker2dTrackedObject tracking_info[], /* size is num_objects*num_cameras */ + Cv3dTrackerTrackedObject tracked_objects[]); /* size is num_objects */ +/**************************************************************************************** + tracking_info is a rectangular array; one row per camera, num_objects elements per row. + The id field of any unused slots must be -1. Ids need not be ordered or consecutive. On + completion, the return value is the number of objects located; i.e., the number of objects + visible by more than one camera. The id field of any unused slots in tracked objects is + set to -1. +****************************************************************************************/ + + +/****************************************************************************************\ +* Skeletons and Linear-Contour Models * +\****************************************************************************************/ + +typedef enum CvLeeParameters +{ + CV_LEE_INT = 0, + CV_LEE_FLOAT = 1, + CV_LEE_DOUBLE = 2, + CV_LEE_AUTO = -1, + CV_LEE_ERODE = 0, + CV_LEE_ZOOM = 1, + CV_LEE_NON = 2 +} CvLeeParameters; + +#define CV_NEXT_VORONOISITE2D( SITE ) ((SITE)->edge[0]->site[((SITE)->edge[0]->site[0] == (SITE))]) +#define CV_PREV_VORONOISITE2D( SITE ) ((SITE)->edge[1]->site[((SITE)->edge[1]->site[0] == (SITE))]) +#define CV_FIRST_VORONOIEDGE2D( SITE ) ((SITE)->edge[0]) +#define CV_LAST_VORONOIEDGE2D( SITE ) ((SITE)->edge[1]) +#define CV_NEXT_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[(EDGE)->site[0] != (SITE)]) +#define CV_PREV_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[2 + ((EDGE)->site[0] != (SITE))]) +#define CV_VORONOIEDGE2D_BEGINNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] != (SITE))]) +#define CV_VORONOIEDGE2D_ENDNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] == (SITE))]) +#define CV_TWIN_VORONOISITE2D( SITE, EDGE ) ( (EDGE)->site[((EDGE)->site[0] == (SITE))]) + +#define CV_VORONOISITE2D_FIELDS() \ + struct CvVoronoiNode2D *node[2]; \ + struct CvVoronoiEdge2D *edge[2]; + +typedef struct CvVoronoiSite2D +{ + CV_VORONOISITE2D_FIELDS() + struct CvVoronoiSite2D *next[2]; +} CvVoronoiSite2D; + +#define CV_VORONOIEDGE2D_FIELDS() \ + struct CvVoronoiNode2D *node[2]; \ + struct CvVoronoiSite2D *site[2]; \ + struct CvVoronoiEdge2D *next[4]; + +typedef struct CvVoronoiEdge2D +{ + CV_VORONOIEDGE2D_FIELDS() +} CvVoronoiEdge2D; + +#define CV_VORONOINODE2D_FIELDS() \ + CV_SET_ELEM_FIELDS(CvVoronoiNode2D) \ + CvPoint2D32f pt; \ + float radius; + +typedef struct CvVoronoiNode2D +{ + CV_VORONOINODE2D_FIELDS() +} CvVoronoiNode2D; + +#define CV_VORONOIDIAGRAM2D_FIELDS() \ + CV_GRAPH_FIELDS() \ + CvSet *sites; + +typedef struct CvVoronoiDiagram2D +{ + CV_VORONOIDIAGRAM2D_FIELDS() +} CvVoronoiDiagram2D; + +/* Computes Voronoi Diagram for given polygons with holes */ +CVAPI(int) cvVoronoiDiagramFromContour(CvSeq* ContourSeq, + CvVoronoiDiagram2D** VoronoiDiagram, + CvMemStorage* VoronoiStorage, + CvLeeParameters contour_type CV_DEFAULT(CV_LEE_INT), + int contour_orientation CV_DEFAULT(-1), + int attempt_number CV_DEFAULT(10)); + +/* Computes Voronoi Diagram for domains in given image */ +CVAPI(int) cvVoronoiDiagramFromImage(IplImage* pImage, + CvSeq** ContourSeq, + CvVoronoiDiagram2D** VoronoiDiagram, + CvMemStorage* VoronoiStorage, + CvLeeParameters regularization_method CV_DEFAULT(CV_LEE_NON), + float approx_precision CV_DEFAULT(CV_LEE_AUTO)); + +/* Deallocates the storage */ +CVAPI(void) cvReleaseVoronoiStorage(CvVoronoiDiagram2D* VoronoiDiagram, + CvMemStorage** pVoronoiStorage); + +/*********************** Linear-Contour Model ****************************/ + +struct CvLCMEdge; +struct CvLCMNode; + +typedef struct CvLCMEdge +{ + CV_GRAPH_EDGE_FIELDS() + CvSeq* chain; + float width; + int index1; + int index2; +} CvLCMEdge; + +typedef struct CvLCMNode +{ + CV_GRAPH_VERTEX_FIELDS() + CvContour* contour; +} CvLCMNode; + + +/* Computes hybrid model from Voronoi Diagram */ +CVAPI(CvGraph*) cvLinearContorModelFromVoronoiDiagram(CvVoronoiDiagram2D* VoronoiDiagram, + float maxWidth); + +/* Releases hybrid model storage */ +CVAPI(int) cvReleaseLinearContorModelStorage(CvGraph** Graph); + + +/* two stereo-related functions */ + +CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4], double matrix[3][3], + CvArr* rectMap ); + +/*CVAPI(void) cvInitStereoRectification( CvStereoCamera* params, + CvArr* rectMap1, CvArr* rectMap2, + int do_undistortion );*/ + +/*************************** View Morphing Functions ************************/ + +/* The order of the function corresponds to the order they should appear in + the view morphing pipeline */ + +/* Finds ending points of scanlines on left and right images of stereo-pair */ +CVAPI(void) cvMakeScanlines( const CvMatrix3* matrix, CvSize img_size, + int* scanlines1, int* scanlines2, + int* lengths1, int* lengths2, + int* line_count ); + +/* Grab pixel values from scanlines and stores them sequentially + (some sort of perspective image transform) */ +CVAPI(void) cvPreWarpImage( int line_count, + IplImage* img, + uchar* dst, + int* dst_nums, + int* scanlines); + +/* Approximate each grabbed scanline by a sequence of runs + (lossy run-length compression) */ +CVAPI(void) cvFindRuns( int line_count, + uchar* prewarp1, + uchar* prewarp2, + int* line_lengths1, + int* line_lengths2, + int* runs1, + int* runs2, + int* num_runs1, + int* num_runs2); + +/* Compares two sets of compressed scanlines */ +CVAPI(void) cvDynamicCorrespondMulti( int line_count, + int* first, + int* first_runs, + int* second, + int* second_runs, + int* first_corr, + int* second_corr); + +/* Finds scanline ending coordinates for some intermediate "virtual" camera position */ +CVAPI(void) cvMakeAlphaScanlines( int* scanlines1, + int* scanlines2, + int* scanlinesA, + int* lengths, + int line_count, + float alpha); + +/* Blends data of the left and right image scanlines to get + pixel values of "virtual" image scanlines */ +CVAPI(void) cvMorphEpilinesMulti( int line_count, + uchar* first_pix, + int* first_num, + uchar* second_pix, + int* second_num, + uchar* dst_pix, + int* dst_num, + float alpha, + int* first, + int* first_runs, + int* second, + int* second_runs, + int* first_corr, + int* second_corr); + +/* Does reverse warping of the morphing result to make + it fill the destination image rectangle */ +CVAPI(void) cvPostWarpImage( int line_count, + uchar* src, + int* src_nums, + IplImage* img, + int* scanlines); + +/* Deletes Moire (missed pixels that appear due to discretization) */ +CVAPI(void) cvDeleteMoire( IplImage* img ); + + +/****************************************************************************************\ +* Background/foreground segmentation * +\****************************************************************************************/ + +#define CV_BG_MODEL_FGD 0 +#define CV_BG_MODEL_MOG 1 +#define CV_BG_MODEL_FGD_SIMPLE 2 + +struct CvBGStatModel; + +typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model ); +typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model ); + +#define CV_BG_STAT_MODEL_FIELDS() \ + int type; /*type of BG model*/ \ + CvReleaseBGStatModel release; \ + CvUpdateBGStatModel update; \ + IplImage* background; /*8UC3 reference background image*/ \ + IplImage* foreground; /*8UC1 foreground image*/ \ + IplImage** layers; /*8UC3 reference background image, can be null */ \ + int layer_count; /* can be zero */ \ + CvMemStorage* storage; /*storage for “foreground_regions”*/ \ + CvSeq* foreground_regions /*foreground object contours*/ + +typedef struct CvBGStatModel +{ + CV_BG_STAT_MODEL_FIELDS(); +} +CvBGStatModel; + +// + +// Releases memory used by BGStatModel +CV_INLINE void cvReleaseBGStatModel( CvBGStatModel** bg_model ) +{ + if( bg_model && *bg_model && (*bg_model)->release ) + (*bg_model)->release( bg_model ); +} + +// Updates statistical model and returns number of found foreground regions +CV_INLINE int cvUpdateBGStatModel( IplImage* current_frame, CvBGStatModel* bg_model ) +{ + return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model ) : 0; +} + +// Performs FG post-processing using segmentation +// (all pixels of a region will be classified as foreground if majority of pixels of the region are FG). +// parameters: +// segments - pointer to result of segmentation (for example MeanShiftSegmentation) +// bg_model - pointer to CvBGStatModel structure +CVAPI(void) cvRefineForegroundMaskBySegm( CvSeq* segments, CvBGStatModel* bg_model ); + +/* Common use change detection function */ +CVAPI(int) cvChangeDetection( IplImage* prev_frame, + IplImage* curr_frame, + IplImage* change_mask ); + +/* + Interface of ACM MM2003 algorithm + (Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian. + "Foreground Object Detection from Videos Containing Complex Background. ACM MM2003") +*/ + +/* default paremeters of foreground detection algorithm */ +#define CV_BGFG_FGD_LC 128 +#define CV_BGFG_FGD_N1C 15 +#define CV_BGFG_FGD_N2C 25 + +#define CV_BGFG_FGD_LCC 64 +#define CV_BGFG_FGD_N1CC 25 +#define CV_BGFG_FGD_N2CC 40 + +/* BG reference image update parameter */ +#define CV_BGFG_FGD_ALPHA_1 0.1f + +/* stat model update parameter + 0.002f ~ 1K frame(~45sec), 0.005 ~ 18sec (if 25fps and absolutely static BG) */ +#define CV_BGFG_FGD_ALPHA_2 0.005f + +/* start value for alpha parameter (to fast initiate statistic model) */ +#define CV_BGFG_FGD_ALPHA_3 0.1f + +#define CV_BGFG_FGD_DELTA 2 + +#define CV_BGFG_FGD_T 0.9f + +#define CV_BGFG_FGD_MINAREA 15.f + +#define CV_BGFG_FGD_BG_UPDATE_TRESH 0.5f + +typedef struct CvFGDStatModelParams +{ + int Lc, N1c, N2c, Lcc, N1cc, N2cc, is_obj_without_holes, perform_morphing; + float alpha1, alpha2, alpha3, delta, T, minArea; +} +CvFGDStatModelParams; + +typedef struct CvBGPixelCStatTable +{ + float Pv, Pvb; + uchar v[3]; +} +CvBGPixelCStatTable; + +typedef struct CvBGPixelCCStatTable +{ + float Pv, Pvb; + uchar v[6]; +} +CvBGPixelCCStatTable; + +typedef struct CvBGPixelStat +{ + float Pbc; + float Pbcc; + CvBGPixelCStatTable* ctable; + CvBGPixelCCStatTable* cctable; + uchar is_trained_st_model; + uchar is_trained_dyn_model; +} +CvBGPixelStat; + + +typedef struct CvFGDStatModel +{ + CV_BG_STAT_MODEL_FIELDS(); + CvBGPixelStat* pixel_stat; + IplImage* Ftd; + IplImage* Fbd; + IplImage* prev_frame; + CvFGDStatModelParams params; +} +CvFGDStatModel; + +/* Creates FGD model */ +CVAPI(CvBGStatModel*) cvCreateFGDStatModel( IplImage* first_frame, + CvFGDStatModelParams* parameters CV_DEFAULT(NULL)); + +/* + Interface of Gaussian mixture algorithm + (P. KadewTraKuPong and R. Bowden, + "An improved adaptive background mixture model for real-time tracking with shadow detection" + in Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001.") +*/ + +#define CV_BGFG_MOG_MAX_NGAUSSIANS 500 + +/* default parameters of gaussian background detection algorithm */ +#define CV_BGFG_MOG_BACKGROUND_THRESHOLD 0.7 /* threshold sum of weights for background test */ +#define CV_BGFG_MOG_STD_THRESHOLD 2.5 /* lambda=2.5 is 99% */ +#define CV_BGFG_MOG_WINDOW_SIZE 200 /* Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE */ +#define CV_BGFG_MOG_NGAUSSIANS 5 /* = K = number of Gaussians in mixture */ +#define CV_BGFG_MOG_WEIGHT_INIT 0.05 +#define CV_BGFG_MOG_SIGMA_INIT 30 +#define CV_BGFG_MOG_MINAREA 15.f + + +#define CV_BGFG_MOG_NCOLORS 3 + +typedef struct CvGaussBGStatModelParams +{ + int win_size; /* = 1/alpha */ + int n_gauss; + double bg_threshold, std_threshold, minArea; + double weight_init, variance_init; +}CvGaussBGStatModelParams; + +typedef struct CvGaussBGValues +{ + int match_sum; + double weight; + double variance[CV_BGFG_MOG_NCOLORS]; + double mean[CV_BGFG_MOG_NCOLORS]; +} +CvGaussBGValues; + +typedef struct CvGaussBGPoint +{ + CvGaussBGValues* g_values; +} +CvGaussBGPoint; + + +typedef struct CvGaussBGModel +{ + CV_BG_STAT_MODEL_FIELDS(); + CvGaussBGStatModelParams params; + CvGaussBGPoint* g_point; + int countFrames; +} +CvGaussBGModel; + + +/* Creates Gaussian mixture background model */ +CVAPI(CvBGStatModel*) cvCreateGaussianBGModel( IplImage* first_frame, + CvGaussBGStatModelParams* parameters CV_DEFAULT(NULL)); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus + +/****************************************************************************************\ +* Calibration engine * +\****************************************************************************************/ + +typedef enum CvCalibEtalonType +{ + CV_CALIB_ETALON_USER = -1, + CV_CALIB_ETALON_CHESSBOARD = 0, + CV_CALIB_ETALON_CHECKERBOARD = CV_CALIB_ETALON_CHESSBOARD +} +CvCalibEtalonType; + +class CV_EXPORTS CvCalibFilter +{ +public: + /* Constructor & destructor */ + CvCalibFilter(); + virtual ~CvCalibFilter(); + + /* Sets etalon type - one for all cameras. + etalonParams is used in case of pre-defined etalons (such as chessboard). + Number of elements in etalonParams is determined by etalonType. + E.g., if etalon type is CV_ETALON_TYPE_CHESSBOARD then: + etalonParams[0] is number of squares per one side of etalon + etalonParams[1] is number of squares per another side of etalon + etalonParams[2] is linear size of squares in the board in arbitrary units. + pointCount & points are used in case of + CV_CALIB_ETALON_USER (user-defined) etalon. */ + virtual bool + SetEtalon( CvCalibEtalonType etalonType, double* etalonParams, + int pointCount = 0, CvPoint2D32f* points = 0 ); + + /* Retrieves etalon parameters/or and points */ + virtual CvCalibEtalonType + GetEtalon( int* paramCount = 0, const double** etalonParams = 0, + int* pointCount = 0, const CvPoint2D32f** etalonPoints = 0 ) const; + + /* Sets number of cameras calibrated simultaneously. It is equal to 1 initially */ + virtual void SetCameraCount( int cameraCount ); + + /* Retrieves number of cameras */ + int GetCameraCount() const { return cameraCount; } + + /* Starts cameras calibration */ + virtual bool SetFrames( int totalFrames ); + + /* Stops cameras calibration */ + virtual void Stop( bool calibrate = false ); + + /* Retrieves number of cameras */ + bool IsCalibrated() const { return isCalibrated; } + + /* Feeds another serie of snapshots (one per each camera) to filter. + Etalon points on these images are found automatically. + If the function can't locate points, it returns false */ + virtual bool FindEtalon( IplImage** imgs ); + + /* The same but takes matrices */ + virtual bool FindEtalon( CvMat** imgs ); + + /* Lower-level function for feeding filter with already found etalon points. + Array of point arrays for each camera is passed. */ + virtual bool Push( const CvPoint2D32f** points = 0 ); + + /* Returns total number of accepted frames and, optionally, + total number of frames to collect */ + virtual int GetFrameCount( int* framesTotal = 0 ) const; + + /* Retrieves camera parameters for specified camera. + If camera is not calibrated the function returns 0 */ + virtual const CvCamera* GetCameraParams( int idx = 0 ) const; + + virtual const CvStereoCamera* GetStereoParams() const; + + /* Sets camera parameters for all cameras */ + virtual bool SetCameraParams( CvCamera* params ); + + /* Saves all camera parameters to file */ + virtual bool SaveCameraParams( const char* filename ); + + /* Loads all camera parameters from file */ + virtual bool LoadCameraParams( const char* filename ); + + /* Undistorts images using camera parameters. Some of src pointers can be NULL. */ + virtual bool Undistort( IplImage** src, IplImage** dst ); + + /* Undistorts images using camera parameters. Some of src pointers can be NULL. */ + virtual bool Undistort( CvMat** src, CvMat** dst ); + + /* Returns array of etalon points detected/partally detected + on the latest frame for idx-th camera */ + virtual bool GetLatestPoints( int idx, CvPoint2D32f** pts, + int* count, bool* found ); + + /* Draw the latest detected/partially detected etalon */ + virtual void DrawPoints( IplImage** dst ); + + /* Draw the latest detected/partially detected etalon */ + virtual void DrawPoints( CvMat** dst ); + + virtual bool Rectify( IplImage** srcarr, IplImage** dstarr ); + virtual bool Rectify( CvMat** srcarr, CvMat** dstarr ); + +protected: + + enum { MAX_CAMERAS = 3 }; + + /* etalon data */ + CvCalibEtalonType etalonType; + int etalonParamCount; + double* etalonParams; + int etalonPointCount; + CvPoint2D32f* etalonPoints; + CvSize imgSize; + CvMat* grayImg; + CvMat* tempImg; + CvMemStorage* storage; + + /* camera data */ + int cameraCount; + CvCamera cameraParams[MAX_CAMERAS]; + CvStereoCamera stereo; + CvPoint2D32f* points[MAX_CAMERAS]; + CvMat* undistMap[MAX_CAMERAS][2]; + CvMat* undistImg; + int latestCounts[MAX_CAMERAS]; + CvPoint2D32f* latestPoints[MAX_CAMERAS]; + CvMat* rectMap[MAX_CAMERAS][2]; + + /* Added by Valery */ + //CvStereoCamera stereoParams; + + int maxPoints; + int framesTotal; + int framesAccepted; + bool isCalibrated; +}; + +#include "cvaux.hpp" +#include "cvvidsurv.hpp" +/*#include "cvmat.hpp"*/ +#endif + +#endif + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/cvaux.hpp b/libraries/external/opencv/linux/include/cvaux.hpp new file mode 100755 index 0000000..573d666 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvaux.hpp @@ -0,0 +1,144 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __CVAUX_HPP__ +#define __CVAUX_HPP__ + +#ifdef __cplusplus + +/****************************************************************************************\ +* Image class * +\****************************************************************************************/ + +class CV_EXPORTS CvCamShiftTracker +{ +public: + + CvCamShiftTracker(); + virtual ~CvCamShiftTracker(); + + /**** Characteristics of the object that are calculated by track_object method *****/ + float get_orientation() const // orientation of the object in degrees + { return m_box.angle; } + float get_length() const // the larger linear size of the object + { return m_box.size.height; } + float get_width() const // the smaller linear size of the object + { return m_box.size.width; } + CvPoint2D32f get_center() const // center of the object + { return m_box.center; } + CvRect get_window() const // bounding rectangle for the object + { return m_comp.rect; } + + /*********************** Tracking parameters ************************/ + int get_threshold() const // thresholding value that applied to back project + { return m_threshold; } + + int get_hist_dims( int* dims = 0 ) const // returns number of histogram dimensions and sets + { return m_hist ? cvGetDims( m_hist->bins, dims ) : 0; } + + int get_min_ch_val( int channel ) const // get the minimum allowed value of the specified channel + { return m_min_ch_val[channel]; } + + int get_max_ch_val( int channel ) const // get the maximum allowed value of the specified channel + { return m_max_ch_val[channel]; } + + // set initial object rectangle (must be called before initial calculation of the histogram) + bool set_window( CvRect window) + { m_comp.rect = window; return true; } + + bool set_threshold( int threshold ) // threshold applied to the histogram bins + { m_threshold = threshold; return true; } + + bool set_hist_bin_range( int dim, int min_val, int max_val ); + + bool set_hist_dims( int c_dims, int* dims );// set the histogram parameters + + bool set_min_ch_val( int channel, int val ) // set the minimum allowed value of the specified channel + { m_min_ch_val[channel] = val; return true; } + bool set_max_ch_val( int channel, int val ) // set the maximum allowed value of the specified channel + { m_max_ch_val[channel] = val; return true; } + + /************************ The processing methods *********************************/ + // update object position + virtual bool track_object( const IplImage* cur_frame ); + + // update object histogram + virtual bool update_histogram( const IplImage* cur_frame ); + + // reset histogram + virtual void reset_histogram(); + + /************************ Retrieving internal data *******************************/ + // get back project image + virtual IplImage* get_back_project() + { return m_back_project; } + + float query( int* bin ) const + { return m_hist ? cvQueryHistValue_nD( m_hist, bin ) : 0.f; } + +protected: + + // internal method for color conversion: fills m_color_planes group + virtual void color_transform( const IplImage* img ); + + CvHistogram* m_hist; + + CvBox2D m_box; + CvConnectedComp m_comp; + + float m_hist_ranges_data[CV_MAX_DIM][2]; + float* m_hist_ranges[CV_MAX_DIM]; + + int m_min_ch_val[CV_MAX_DIM]; + int m_max_ch_val[CV_MAX_DIM]; + int m_threshold; + + IplImage* m_color_planes[CV_MAX_DIM]; + IplImage* m_back_project; + IplImage* m_temp; + IplImage* m_mask; +}; + +#endif /* __cplusplus */ + +#endif /* __CVAUX_HPP__ */ + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/cvcompat.h b/libraries/external/opencv/linux/include/cvcompat.h new file mode 100755 index 0000000..03280d8 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvcompat.h @@ -0,0 +1,1081 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright( C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +//(including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort(including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* + A few macros and definitions for backward compatibility + with the previous versions of OpenCV. They are obsolete and + are likely to be removed in future. To check whether your code + uses any of these, define CV_NO_BACKWARD_COMPATIBILITY before + including cv.h. +*/ + +#ifndef _CVCOMPAT_H_ +#define _CVCOMPAT_H_ + +#include + +#ifdef __cplusplus + #define CV_UNREFERENCED(arg) +#else + #define CV_UNREFERENCED(arg) arg +#endif + +#define CvMatType int +#define CvDisMaskType int +#define CvMatArray CvMat + +#define CvThreshType int +#define CvAdaptiveThreshMethod int +#define CvCompareMethod int +#define CvFontFace int +#define CvPolyApproxMethod int +#define CvContoursMatchMethod int +#define CvContourTreesMatchMethod int +#define CvCoeffType int +#define CvRodriguesType int +#define CvElementShape int +#define CvMorphOp int +#define CvTemplMatchMethod int + +#define CvPoint2D64d CvPoint2D64f +#define CvPoint3D64d CvPoint3D64f + +#define CV_MAT32F CV_32FC1 +#define CV_MAT3x1_32F CV_32FC1 +#define CV_MAT4x1_32F CV_32FC1 +#define CV_MAT3x3_32F CV_32FC1 +#define CV_MAT4x4_32F CV_32FC1 + +#define CV_MAT64D CV_64FC1 +#define CV_MAT3x1_64D CV_64FC1 +#define CV_MAT4x1_64D CV_64FC1 +#define CV_MAT3x3_64D CV_64FC1 +#define CV_MAT4x4_64D CV_64FC1 + +#define IPL_GAUSSIAN_5x5 7 +#define CvBox2D32f CvBox2D + +/* allocation/deallocation macros */ +#define cvCreateImageData cvCreateData +#define cvReleaseImageData cvReleaseData +#define cvSetImageData cvSetData +#define cvGetImageRawData cvGetRawData + +#define cvmAlloc cvCreateData +#define cvmFree cvReleaseData +#define cvmAllocArray cvCreateData +#define cvmFreeArray cvReleaseData + +#define cvIntegralImage cvIntegral +#define cvMatchContours cvMatchShapes + +CV_INLINE CvMat cvMatArray( int rows, int cols, int type, + int count, void* data CV_DEFAULT(0)) +{ + return cvMat( rows*count, cols, type, data ); +} + +#define cvUpdateMHIByTime cvUpdateMotionHistory + +#define cvAccMask cvAcc +#define cvSquareAccMask cvSquareAcc +#define cvMultiplyAccMask cvMultiplyAcc +#define cvRunningAvgMask(imgY, imgU, mask, alpha) cvRunningAvg(imgY, imgU, alpha, mask) + +#define cvSetHistThresh cvSetHistBinRanges +#define cvCalcHistMask(img, mask, hist, doNotClear) cvCalcHist(img, hist, doNotClear, mask) + +CV_INLINE double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0)) +{ + CvScalar mean = cvAvg( image, mask ); + return mean.val[0]; +} + + +CV_INLINE double cvSumPixels( const CvArr* image ) +{ + CvScalar scalar = cvSum( image ); + return scalar.val[0]; +} + +CV_INLINE void cvMean_StdDev( const CvArr* image, double* mean, double* sdv, + const CvArr* mask CV_DEFAULT(0)) +{ + CvScalar _mean, _sdv; + cvAvgSdv( image, &_mean, &_sdv, mask ); + + if( mean ) + *mean = _mean.val[0]; + + if( sdv ) + *sdv = _sdv.val[0]; +} + + +CV_INLINE void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst ) +{ + CvMat tsrc, tdst; + + cvReshape( src, &tsrc, 3, 0 ); + cvReshape( dst, &tdst, 3, 0 ); + + cvPerspectiveTransform( &tsrc, &tdst, mat ); +} + + +CV_INLINE void cvFillImage( CvArr* mat, double color ) +{ + cvSet( mat, cvColorToScalar(color, cvGetElemType(mat)), 0 ); +} + + +#define cvCvtPixToPlane cvSplit +#define cvCvtPlaneToPix cvMerge + +typedef struct CvRandState +{ + CvRNG state; /* RNG state (the current seed and carry)*/ + int disttype; /* distribution type */ + CvScalar param[2]; /* parameters of RNG */ +} +CvRandState; + + +/* Changes RNG range while preserving RNG state */ +CV_INLINE void cvRandSetRange( CvRandState* state, double param1, + double param2, int index CV_DEFAULT(-1)) +{ + if( !state ) + { + cvError( CV_StsNullPtr, "cvRandSetRange", "Null pointer to RNG state", "cvcompat.h", 0 ); + return; + } + + if( (unsigned)(index + 1) > 4 ) + { + cvError( CV_StsOutOfRange, "cvRandSetRange", "index is not in -1..3", "cvcompat.h", 0 ); + return; + } + + if( index < 0 ) + { + state->param[0].val[0] = state->param[0].val[1] = + state->param[0].val[2] = state->param[0].val[3] = param1; + state->param[1].val[0] = state->param[1].val[1] = + state->param[1].val[2] = state->param[1].val[3] = param2; + } + else + { + state->param[0].val[index] = param1; + state->param[1].val[index] = param2; + } +} + + +CV_INLINE void cvRandInit( CvRandState* state, double param1, + double param2, int seed, + int disttype CV_DEFAULT(CV_RAND_UNI)) +{ + if( !state ) + { + cvError( CV_StsNullPtr, "cvRandInit", "Null pointer to RNG state", "cvcompat.h", 0 ); + return; + } + + if( disttype != CV_RAND_UNI && disttype != CV_RAND_NORMAL ) + { + cvError( CV_StsBadFlag, "cvRandInit", "Unknown distribution type", "cvcompat.h", 0 ); + return; + } + + state->state = (uint64)(seed ? seed : -1); + state->disttype = disttype; + cvRandSetRange( state, param1, param2, -1 ); +} + + +/* Fills array with random numbers */ +CV_INLINE void cvRand( CvRandState* state, CvArr* arr ) +{ + if( !state ) + { + cvError( CV_StsNullPtr, "cvRand", "Null pointer to RNG state", "cvcompat.h", 0 ); + return; + } + cvRandArr( &state->state, arr, state->disttype, state->param[0], state->param[1] ); +} + +#define cvRandNext( _state ) cvRandInt( &(_state)->state ) + +CV_INLINE void cvbRand( CvRandState* state, float* dst, int len ) +{ + CvMat mat = cvMat( 1, len, CV_32F, (void*)dst ); + cvRand( state, &mat ); +} + + +CV_INLINE void cvbCartToPolar( const float* y, const float* x, + float* magnitude, float* angle, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + CvMat mm = mx; + CvMat ma = mx; + + my.data.fl = (float*)y; + mm.data.fl = (float*)magnitude; + ma.data.fl = (float*)angle; + + cvCartToPolar( &mx, &my, &mm, angle ? &ma : NULL, 1 ); +} + + +CV_INLINE void cvbFastArctan( const float* y, const float* x, + float* angle, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + CvMat ma = mx; + + my.data.fl = (float*)y; + ma.data.fl = (float*)angle; + + cvCartToPolar( &mx, &my, NULL, &ma, 1 ); +} + + +CV_INLINE void cvbSqrt( const float* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + my.data.fl = (float*)y; + + cvPow( &mx, &my, 0.5 ); +} + + +CV_INLINE void cvbInvSqrt( const float* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + my.data.fl = (float*)y; + + cvPow( &mx, &my, -0.5 ); +} + + +CV_INLINE void cvbReciprocal( const float* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = mx; + my.data.fl = (float*)y; + + cvPow( &mx, &my, -1 ); +} + + +CV_INLINE void cvbFastExp( const float* x, double* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_32F, (void*)x ); + CvMat my = cvMat( 1, len, CV_64F, y ); + cvExp( &mx, &my ); +} + + +CV_INLINE void cvbFastLog( const double* x, float* y, int len ) +{ + CvMat mx = cvMat( 1, len, CV_64F, (void*)x ); + CvMat my = cvMat( 1, len, CV_32F, y ); + cvLog( &mx, &my ); +} + + +CV_INLINE CvRect cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0)) +{ + return cvBoundingRect( point_set, update ); +} + + +CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst ) +{ + return cvInvert( src, dst, CV_SVD ); +} + +#define cvPseudoInv cvPseudoInverse + +#define cvContourMoments( contour, moments ) \ + cvMoments( contour, moments, 0 ) + +#define cvGetPtrAt cvPtr2D +#define cvGetAt cvGet2D +#define cvSetAt(arr,val,y,x) cvSet2D((arr),(y),(x),(val)) + +#define cvMeanMask cvMean +#define cvMean_StdDevMask(img,mask,mean,sdv) cvMean_StdDev(img,mean,sdv,mask) + +#define cvNormMask(imgA,imgB,mask,normType) cvNorm(imgA,imgB,normType,mask) + +#define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \ + cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask) + +#define cvRemoveMemoryManager cvSetMemoryManager + +#define cvmSetZero( mat ) cvSetZero( mat ) +#define cvmSetIdentity( mat ) cvSetIdentity( mat ) +#define cvmAdd( src1, src2, dst ) cvAdd( src1, src2, dst, 0 ) +#define cvmSub( src1, src2, dst ) cvSub( src1, src2, dst, 0 ) +#define cvmCopy( src, dst ) cvCopy( src, dst, 0 ) +#define cvmMul( src1, src2, dst ) cvMatMulAdd( src1, src2, 0, dst ) +#define cvmTranspose( src, dst ) cvT( src, dst ) +#define cvmInvert( src, dst ) cvInv( src, dst ) +#define cvmMahalanobis(vec1, vec2, mat) cvMahalanobis( vec1, vec2, mat ) +#define cvmDotProduct( vec1, vec2 ) cvDotProduct( vec1, vec2 ) +#define cvmCrossProduct(vec1, vec2,dst) cvCrossProduct( vec1, vec2, dst ) +#define cvmTrace( mat ) (cvTrace( mat )).val[0] +#define cvmMulTransposed( src, dst, order ) cvMulTransposed( src, dst, order ) +#define cvmEigenVV( mat, evec, eval, eps) cvEigenVV( mat, evec, eval, eps ) +#define cvmDet( mat ) cvDet( mat ) +#define cvmScale( src, dst, scale ) cvScale( src, dst, scale ) + +#define cvCopyImage( src, dst ) cvCopy( src, dst, 0 ) +#define cvReleaseMatHeader cvReleaseMat + +/* Calculates exact convex hull of 2d point set */ +CV_INLINE void cvConvexHull( CvPoint* points, int num_points, + CvRect* CV_UNREFERENCED(bound_rect), + int orientation, int* hull, int* hullsize ) +{ + CvMat points1 = cvMat( 1, num_points, CV_32SC2, points ); + CvMat hull1 = cvMat( 1, num_points, CV_32SC1, hull ); + + cvConvexHull2( &points1, &hull1, orientation, 0 ); + *hullsize = hull1.cols; +} + +/* Calculates exact convex hull of 2d point set stored in a sequence */ +#define cvContourConvexHull( contour, orientation, storage ) \ + cvConvexHull2( contour, storage, orientation ) + +/* Calculates approximate convex hull of 2d point set */ +#define cvConvexHullApprox( points, num_points, bound_rect, bandwidth, \ + orientation, hull, hullsize ) \ +cvConvexHull( points, num_points, bound_rect, orientation, hull, hullsize ) + +/* Calculates approximate convex hull of 2d point set stored in a sequence */ +#define cvContourConvexHullApprox( contour, bandwidth, orientation, storage ) \ + cvConvexHull2( contour, storage, orientation ) + + +CV_INLINE void cvMinAreaRect( CvPoint* points, int n, + int CV_UNREFERENCED(left), int CV_UNREFERENCED(bottom), + int CV_UNREFERENCED(right), int CV_UNREFERENCED(top), + CvPoint2D32f* anchor, + CvPoint2D32f* vect1, + CvPoint2D32f* vect2 ) +{ + CvMat mat = cvMat( 1, n, CV_32SC2, points ); + CvBox2D box = cvMinAreaRect2( &mat, 0 ); + CvPoint2D32f pt[4]; + + cvBoxPoints( box, pt ); + *anchor = pt[0]; + vect1->x = pt[1].x - pt[0].x; + vect1->y = pt[1].y - pt[0].y; + vect2->x = pt[3].x - pt[0].x; + vect2->y = pt[3].y - pt[0].y; + + CV_UNREFERENCED((void)left); + CV_UNREFERENCED((void)bottom); + CV_UNREFERENCED((void)right); + CV_UNREFERENCED((void)top); +} + +typedef int CvDisType; +typedef int CvChainApproxMethod; +typedef int CvContourRetrievalMode; + +CV_INLINE void cvFitLine3D( CvPoint3D32f* points, int count, int dist, + void *param, float reps, float aeps, float* line ) +{ + CvMat mat = cvMat( 1, count, CV_32FC3, points ); + float _param = param != NULL ? *(float*)param : 0.f; + assert( dist != CV_DIST_USER ); + cvFitLine( &mat, dist, _param, reps, aeps, line ); +} + +/* Fits a line into set of 2d points in a robust way (M-estimator technique) */ +CV_INLINE void cvFitLine2D( CvPoint2D32f* points, int count, int dist, + void *param, float reps, float aeps, float* line ) +{ + CvMat mat = cvMat( 1, count, CV_32FC2, points ); + float _param = param != NULL ? *(float*)param : 0.f; + assert( dist != CV_DIST_USER ); + cvFitLine( &mat, dist, _param, reps, aeps, line ); +} + + +CV_INLINE void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box ) +{ + CvMat mat = cvMat( 1, count, CV_32FC2, (void*)points ); + *box = cvFitEllipse2( &mat ); +} + +/* Projects 2d points to one of standard coordinate planes + (i.e. removes one of coordinates) */ +CV_INLINE void cvProject3D( CvPoint3D32f* points3D, int count, + CvPoint2D32f* points2D, + int xIndx CV_DEFAULT(0), + int yIndx CV_DEFAULT(1)) +{ + CvMat src = cvMat( 1, count, CV_32FC3, points3D ); + CvMat dst = cvMat( 1, count, CV_32FC2, points2D ); + float m[6] = {0,0,0,0,0,0}; + CvMat M = cvMat( 2, 3, CV_32F, m ); + + assert( (unsigned)xIndx < 3 && (unsigned)yIndx < 3 ); + m[xIndx] = m[yIndx+3] = 1.f; + + cvTransform( &src, &dst, &M, NULL ); +} + + +/* Retrieves value of the particular bin + of x-dimensional (x=1,2,3,...) histogram */ +#define cvQueryHistValue_1D( hist, idx0 ) \ + ((float)cvGetReal1D( (hist)->bins, (idx0))) +#define cvQueryHistValue_2D( hist, idx0, idx1 ) \ + ((float)cvGetReal2D( (hist)->bins, (idx0), (idx1))) +#define cvQueryHistValue_3D( hist, idx0, idx1, idx2 ) \ + ((float)cvGetReal3D( (hist)->bins, (idx0), (idx1), (idx2))) +#define cvQueryHistValue_nD( hist, idx ) \ + ((float)cvGetRealND( (hist)->bins, (idx))) + +/* Returns pointer to the particular bin of x-dimesional histogram. + For sparse histogram the bin is created if it didn't exist before */ +#define cvGetHistValue_1D( hist, idx0 ) \ + ((float*)cvPtr1D( (hist)->bins, (idx0), 0)) +#define cvGetHistValue_2D( hist, idx0, idx1 ) \ + ((float*)cvPtr2D( (hist)->bins, (idx0), (idx1), 0)) +#define cvGetHistValue_3D( hist, idx0, idx1, idx2 ) \ + ((float*)cvPtr3D( (hist)->bins, (idx0), (idx1), (idx2), 0)) +#define cvGetHistValue_nD( hist, idx ) \ + ((float*)cvPtrND( (hist)->bins, (idx), 0)) + + +#define CV_IS_SET_ELEM_EXISTS CV_IS_SET_ELEM + + +CV_INLINE int cvHoughLines( CvArr* image, double rho, + double theta, int threshold, + float* lines, int linesNumber ) +{ + CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines ); + cvHoughLines2( image, &linesMat, CV_HOUGH_STANDARD, + rho, theta, threshold, 0, 0 ); + + return linesMat.cols; +} + + +CV_INLINE int cvHoughLinesP( CvArr* image, double rho, + double theta, int threshold, + int lineLength, int lineGap, + int* lines, int linesNumber ) +{ + CvMat linesMat = cvMat( 1, linesNumber, CV_32SC4, lines ); + cvHoughLines2( image, &linesMat, CV_HOUGH_PROBABILISTIC, + rho, theta, threshold, lineLength, lineGap ); + + return linesMat.cols; +} + + +CV_INLINE int cvHoughLinesSDiv( CvArr* image, double rho, int srn, + double theta, int stn, int threshold, + float* lines, int linesNumber ) +{ + CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines ); + cvHoughLines2( image, &linesMat, CV_HOUGH_MULTI_SCALE, + rho, theta, threshold, srn, stn ); + + return linesMat.cols; +} + + +/* Find fundamental matrix */ +CV_INLINE void cvFindFundamentalMatrix( int* points1, int* points2, + int numpoints, int CV_UNREFERENCED(method), float* matrix ) +{ + CvMat* pointsMat1; + CvMat* pointsMat2; + CvMat fundMatr = cvMat(3,3,CV_32F,matrix); + int i, curr = 0; + + pointsMat1 = cvCreateMat(3,numpoints,CV_64F); + pointsMat2 = cvCreateMat(3,numpoints,CV_64F); + + for( i = 0; i < numpoints; i++ ) + { + cvmSet(pointsMat1,0,i,points1[curr]);//x + cvmSet(pointsMat1,1,i,points1[curr+1]);//y + cvmSet(pointsMat1,2,i,1.0); + + cvmSet(pointsMat2,0,i,points2[curr]);//x + cvmSet(pointsMat2,1,i,points2[curr+1]);//y + cvmSet(pointsMat2,2,i,1.0); + curr += 2; + } + + cvFindFundamentalMat(pointsMat1,pointsMat2,&fundMatr,CV_FM_RANSAC,1,0.99,0); + + cvReleaseMat(&pointsMat1); + cvReleaseMat(&pointsMat2); +} + + + +CV_INLINE int +cvFindChessBoardCornerGuesses( const void* arr, void* CV_UNREFERENCED(thresharr), + CvMemStorage * CV_UNREFERENCED(storage), + CvSize pattern_size, CvPoint2D32f * corners, + int *corner_count ) +{ + return cvFindChessboardCorners( arr, pattern_size, corners, + corner_count, CV_CALIB_CB_ADAPTIVE_THRESH ); +} + + +/* Calibrates camera using multiple views of calibration pattern */ +CV_INLINE void cvCalibrateCamera( int image_count, int* _point_counts, + CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points, + float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors, + float* _rotation_matrices, int flags ) +{ + int i, total = 0; + CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts ); + CvMat image_points, object_points; + CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs ); + CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, _camera_matrix ); + CvMat rotation_matrices = cvMat( image_count, 9, CV_32FC1, _rotation_matrices ); + CvMat translation_vectors = cvMat( image_count, 3, CV_32FC1, _translation_vectors ); + + for( i = 0; i < image_count; i++ ) + total += _point_counts[i]; + + image_points = cvMat( total, 1, CV_32FC2, _image_points ); + object_points = cvMat( total, 1, CV_32FC3, _object_points ); + + cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size, + &camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors, + flags ); +} + + +CV_INLINE void cvCalibrateCamera_64d( int image_count, int* _point_counts, + CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points, + double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors, + double* _rotation_matrices, int flags ) +{ + int i, total = 0; + CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts ); + CvMat image_points, object_points; + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs ); + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix ); + CvMat rotation_matrices = cvMat( image_count, 9, CV_64FC1, _rotation_matrices ); + CvMat translation_vectors = cvMat( image_count, 3, CV_64FC1, _translation_vectors ); + + for( i = 0; i < image_count; i++ ) + total += _point_counts[i]; + + image_points = cvMat( total, 1, CV_64FC2, _image_points ); + object_points = cvMat( total, 1, CV_64FC3, _object_points ); + + cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size, + &camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors, + flags ); +} + + + +/* Find 3d position of object given intrinsic camera parameters, + 3d model of the object and projection of the object into view plane */ +CV_INLINE void cvFindExtrinsicCameraParams( int point_count, + CvSize CV_UNREFERENCED(image_size), CvPoint2D32f* _image_points, + CvPoint3D32f* _object_points, float* focal_length, + CvPoint2D32f principal_point, float* _distortion_coeffs, + float* _rotation_vector, float* _translation_vector ) +{ + CvMat image_points = cvMat( point_count, 1, CV_32FC2, _image_points ); + CvMat object_points = cvMat( point_count, 1, CV_32FC3, _object_points ); + CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs ); + float a[9]; + CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, a ); + CvMat rotation_vector = cvMat( 1, 1, CV_32FC3, _rotation_vector ); + CvMat translation_vector = cvMat( 1, 1, CV_32FC3, _translation_vector ); + + a[0] = focal_length[0]; a[4] = focal_length[1]; + a[2] = principal_point.x; a[5] = principal_point.y; + a[1] = a[3] = a[6] = a[7] = 0.f; + a[8] = 1.f; + + cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix, + &dist_coeffs, &rotation_vector, &translation_vector ); +} + + +/* Variant of the previous function that takes double-precision parameters */ +CV_INLINE void cvFindExtrinsicCameraParams_64d( int point_count, + CvSize CV_UNREFERENCED(image_size), CvPoint2D64f* _image_points, + CvPoint3D64f* _object_points, double* focal_length, + CvPoint2D64f principal_point, double* _distortion_coeffs, + double* _rotation_vector, double* _translation_vector ) +{ + CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points ); + CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points ); + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs ); + double a[9]; + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a ); + CvMat rotation_vector = cvMat( 1, 1, CV_64FC3, _rotation_vector ); + CvMat translation_vector = cvMat( 1, 1, CV_64FC3, _translation_vector ); + + a[0] = focal_length[0]; a[4] = focal_length[1]; + a[2] = principal_point.x; a[5] = principal_point.y; + a[1] = a[3] = a[6] = a[7] = 0.; + a[8] = 1.; + + cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix, + &dist_coeffs, &rotation_vector, &translation_vector ); +} + + +/* Rodrigues transform */ +#define CV_RODRIGUES_M2V 0 +#define CV_RODRIGUES_V2M 1 + +/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */ +CV_INLINE void cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector, + CvMat* jacobian, int conv_type ) +{ + if( conv_type == CV_RODRIGUES_V2M ) + cvRodrigues2( rotation_vector, rotation_matrix, jacobian ); + else + cvRodrigues2( rotation_matrix, rotation_vector, jacobian ); +} + + +/* Does reprojection of 3d object points to the view plane */ +CV_INLINE void cvProjectPoints( int point_count, CvPoint3D64f* _object_points, + double* _rotation_vector, double* _translation_vector, + double* focal_length, CvPoint2D64f principal_point, + double* _distortion, CvPoint2D64f* _image_points, + double* _deriv_points_rotation_matrix, + double* _deriv_points_translation_vect, + double* _deriv_points_focal, + double* _deriv_points_principal_point, + double* _deriv_points_distortion_coeffs ) +{ + CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points ); + CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points ); + CvMat rotation_vector = cvMat( 3, 1, CV_64FC1, _rotation_vector ); + CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector ); + double a[9]; + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a ); + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion ); + CvMat dpdr = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_rotation_matrix ); + CvMat dpdt = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_translation_vect ); + CvMat dpdf = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_focal ); + CvMat dpdc = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_principal_point ); + CvMat dpdk = cvMat( 2*point_count, 4, CV_64FC1, _deriv_points_distortion_coeffs ); + + a[0] = focal_length[0]; a[4] = focal_length[1]; + a[2] = principal_point.x; a[5] = principal_point.y; + a[1] = a[3] = a[6] = a[7] = 0.; + a[8] = 1.; + + cvProjectPoints2( &object_points, &rotation_vector, &translation_vector, + &camera_matrix, &dist_coeffs, &image_points, + &dpdr, &dpdt, &dpdf, &dpdc, &dpdk ); +} + + +/* Simpler version of the previous function */ +CV_INLINE void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points, + double* _rotation_matrix, double* _translation_vector, + double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points ) +{ + CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points ); + CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points ); + CvMat rotation_matrix = cvMat( 3, 3, CV_64FC1, _rotation_matrix ); + CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector ); + CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix ); + CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion ); + + cvProjectPoints2( &object_points, &rotation_matrix, &translation_vector, + &camera_matrix, &dist_coeffs, &image_points, + 0, 0, 0, 0, 0 ); +} + + +CV_INLINE void cvUnDistortOnce( const CvArr* src, CvArr* dst, + const float* intrinsic_matrix, + const float* distortion_coeffs, + int CV_UNREFERENCED(interpolate) ) +{ + CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix ); + CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs ); + cvUndistort2( src, dst, &_a, &_k ); +} + + +/* the two functions below have quite hackerish implementations, use with care + (or, which is better, switch to cvUndistortInitMap and cvRemap instead */ +CV_INLINE void cvUnDistortInit( const CvArr* CV_UNREFERENCED(src), + CvArr* undistortion_map, + const float* A, const float* k, + int CV_UNREFERENCED(interpolate) ) +{ + union { uchar* ptr; float* fl; } data; + CvSize sz; + cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); + assert( sz.width >= 8 ); + /* just save the intrinsic parameters to the map */ + data.fl[0] = A[0]; data.fl[1] = A[4]; + data.fl[2] = A[2]; data.fl[3] = A[5]; + data.fl[4] = k[0]; data.fl[5] = k[1]; + data.fl[6] = k[2]; data.fl[7] = k[3]; +} + +CV_INLINE void cvUnDistort( const CvArr* src, CvArr* dst, + const CvArr* undistortion_map, + int CV_UNREFERENCED(interpolate) ) +{ + union { uchar* ptr; float* fl; } data; + float a[] = {0,0,0,0,0,0,0,0,1}; + CvSize sz; + cvGetRawData( undistortion_map, &data.ptr, 0, &sz ); + assert( sz.width >= 8 ); + a[0] = data.fl[0]; a[4] = data.fl[1]; + a[2] = data.fl[2]; a[5] = data.fl[3]; + cvUnDistortOnce( src, dst, a, data.fl + 4, 1 ); +} + + +CV_INLINE float cvCalcEMD( const float* signature1, int size1, + const float* signature2, int size2, + int dims, int dist_type CV_DEFAULT(CV_DIST_L2), + CvDistanceFunction dist_func CV_DEFAULT(0), + float* lower_bound CV_DEFAULT(0), + void* user_param CV_DEFAULT(0)) +{ + CvMat sign1 = cvMat( size1, dims + 1, CV_32FC1, (void*)signature1 ); + CvMat sign2 = cvMat( size2, dims + 1, CV_32FC1, (void*)signature2 ); + + return cvCalcEMD2( &sign1, &sign2, dist_type, dist_func, 0, 0, lower_bound, user_param ); +} + + +CV_INLINE void cvKMeans( int num_clusters, float** samples, + int num_samples, int vec_size, + CvTermCriteria termcrit, int* cluster_idx ) +{ + CvMat* samples_mat = cvCreateMat( num_samples, vec_size, CV_32FC1 ); + CvMat cluster_idx_mat = cvMat( num_samples, 1, CV_32SC1, cluster_idx ); + int i; + for( i = 0; i < num_samples; i++ ) + memcpy( samples_mat->data.fl + i*vec_size, samples[i], vec_size*sizeof(float)); + cvKMeans2( samples_mat, num_clusters, &cluster_idx_mat, termcrit ); + cvReleaseMat( &samples_mat ); +} + + +CV_INLINE void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner, + CvGraphVtx* vtx CV_DEFAULT(NULL), + int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)) +{ + CvGraphScanner* temp_scanner; + + if( !scanner ) + cvError( CV_StsNullPtr, "cvStartScanGraph", "Null scanner pointer", "cvcompat.h", 0 ); + + temp_scanner = cvCreateGraphScanner( graph, vtx, mask ); + *scanner = *temp_scanner; + cvFree( &temp_scanner ); +} + + +CV_INLINE void cvEndScanGraph( CvGraphScanner* scanner ) +{ + if( !scanner ) + cvError( CV_StsNullPtr, "cvEndScanGraph", "Null scanner pointer", "cvcompat.h", 0 ); + + if( scanner->stack ) + { + CvGraphScanner* temp_scanner = (CvGraphScanner*)cvAlloc( sizeof(*temp_scanner) ); + *temp_scanner = *scanner; + cvReleaseGraphScanner( &temp_scanner ); + memset( scanner, 0, sizeof(*scanner) ); + } +} + + +#define cvKalmanUpdateByTime cvKalmanPredict +#define cvKalmanUpdateByMeasurement cvKalmanCorrect + +/* old drawing functions */ +CV_INLINE void cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2, + double color, int scale CV_DEFAULT(0)) +{ + cvLine( img, pt1, pt2, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale ); +} + +CV_INLINE void cvCircleAA( CvArr* img, CvPoint center, int radius, + double color, int scale CV_DEFAULT(0) ) +{ + cvCircle( img, center, radius, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale ); +} + +CV_INLINE void cvEllipseAA( CvArr* img, CvPoint center, CvSize axes, + double angle, double start_angle, + double end_angle, double color, + int scale CV_DEFAULT(0) ) +{ + cvEllipse( img, center, axes, angle, start_angle, end_angle, + cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale ); +} + +CV_INLINE void cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours, + int is_closed, double color, int scale CV_DEFAULT(0) ) +{ + cvPolyLine( img, pts, npts, contours, is_closed, + cvColorToScalar(color, cvGetElemType(img)), + 1, CV_AA, scale ); +} + + +#define cvMake2DPoints cvConvertPointsHomogenious +#define cvMake3DPoints cvConvertPointsHomogenious + +#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform + +/****************************************************************************************\ +* Pixel Access Macros * +\****************************************************************************************/ + +typedef struct _CvPixelPosition8u +{ + unsigned char* currline; /* pointer to the start of the current pixel line */ + unsigned char* topline; /* pointer to the start of the top pixel line */ + unsigned char* bottomline; /* pointer to the start of the first line */ + /* which is below the image */ + int x; /* current x coordinate ( in pixels ) */ + int width; /* width of the image ( in pixels ) */ + int height; /* height of the image ( in pixels ) */ + int step; /* distance between lines ( in elements of single */ + /* plane ) */ + int step_arr[3]; /* array: ( 0, -step, step ). It is used for */ + /* vertical moving */ +} CvPixelPosition8u; + +/* this structure differs from the above only in data type */ +typedef struct _CvPixelPosition8s +{ + char* currline; + char* topline; + char* bottomline; + int x; + int width; + int height; + int step; + int step_arr[3]; +} CvPixelPosition8s; + +/* this structure differs from the CvPixelPosition8u only in data type */ +typedef struct _CvPixelPosition32f +{ + float* currline; + float* topline; + float* bottomline; + int x; + int width; + int height; + int step; + int step_arr[3]; +} CvPixelPosition32f; + + +/* Initialize one of the CvPixelPosition structures. */ +/* pos - initialized structure */ +/* origin - pointer to the left-top corner of the ROI */ +/* step - width of the whole image in bytes */ +/* roi - width & height of the ROI */ +/* x, y - initial position */ +#define CV_INIT_PIXEL_POS(pos, origin, _step, roi, _x, _y, orientation) \ + ( \ + (pos).step = (_step)/sizeof((pos).currline[0]) * (orientation ? -1 : 1), \ + (pos).width = (roi).width, \ + (pos).height = (roi).height, \ + (pos).bottomline = (origin) + (pos).step*(pos).height, \ + (pos).topline = (origin) - (pos).step, \ + (pos).step_arr[0] = 0, \ + (pos).step_arr[1] = -(pos).step, \ + (pos).step_arr[2] = (pos).step, \ + (pos).x = (_x), \ + (pos).currline = (origin) + (pos).step*(_y) ) + + +/* Move to specified point ( absolute shift ) */ +/* pos - position structure */ +/* x, y - coordinates of the new position */ +/* cs - number of the image channels */ +#define CV_MOVE_TO( pos, _x, _y, cs ) \ +((pos).currline = (_y) >= 0 && (_y) < (pos).height ? (pos).topline + ((_y)+1)*(pos).step : 0, \ + (pos).x = (_x) >= 0 && (_x) < (pos).width ? (_x) : 0, (pos).currline + (_x) * (cs) ) + +/* Get current coordinates */ +/* pos - position structure */ +/* x, y - coordinates of the new position */ +/* cs - number of the image channels */ +#define CV_GET_CURRENT( pos, cs ) ((pos).currline + (pos).x * (cs)) + +/* Move by one pixel relatively to current position */ +/* pos - position structure */ +/* cs - number of the image channels */ + +/* left */ +#define CV_MOVE_LEFT( pos, cs ) \ + ( --(pos).x >= 0 ? (pos).currline + (pos).x*(cs) : 0 ) + +/* right */ +#define CV_MOVE_RIGHT( pos, cs ) \ + ( ++(pos).x < (pos).width ? (pos).currline + (pos).x*(cs) : 0 ) + +/* up */ +#define CV_MOVE_UP( pos, cs ) \ + (((pos).currline -= (pos).step) != (pos).topline ? (pos).currline + (pos).x*(cs) : 0 ) + +/* down */ +#define CV_MOVE_DOWN( pos, cs ) \ + (((pos).currline += (pos).step) != (pos).bottomline ? (pos).currline + (pos).x*(cs) : 0 ) + +/* left up */ +#define CV_MOVE_LU( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_UP(pos, cs)) + +/* right up */ +#define CV_MOVE_RU( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_UP(pos, cs)) + +/* left down */ +#define CV_MOVE_LD( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_DOWN(pos, cs)) + +/* right down */ +#define CV_MOVE_RD( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_DOWN(pos, cs)) + + + +/* Move by one pixel relatively to current position with wrapping when the position */ +/* achieves image boundary */ +/* pos - position structure */ +/* cs - number of the image channels */ + +/* left */ +#define CV_MOVE_LEFT_WRAP( pos, cs ) \ + ((pos).currline + ( --(pos).x >= 0 ? (pos).x : ((pos).x = (pos).width-1))*(cs)) + +/* right */ +#define CV_MOVE_RIGHT_WRAP( pos, cs ) \ + ((pos).currline + ( ++(pos).x < (pos).width ? (pos).x : ((pos).x = 0))*(cs) ) + +/* up */ +#define CV_MOVE_UP_WRAP( pos, cs ) \ + ((((pos).currline -= (pos).step) != (pos).topline ? \ + (pos).currline : ((pos).currline = (pos).bottomline - (pos).step)) + (pos).x*(cs) ) + +/* down */ +#define CV_MOVE_DOWN_WRAP( pos, cs ) \ + ((((pos).currline += (pos).step) != (pos).bottomline ? \ + (pos).currline : ((pos).currline = (pos).topline + (pos).step)) + (pos).x*(cs) ) + +/* left up */ +#define CV_MOVE_LU_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs)) +/* right up */ +#define CV_MOVE_RU_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs)) +/* left down */ +#define CV_MOVE_LD_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs)) +/* right down */ +#define CV_MOVE_RD_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs)) + +/* Numeric constants which used for moving in arbitrary direction */ +#define CV_SHIFT_NONE 2 +#define CV_SHIFT_LEFT 1 +#define CV_SHIFT_RIGHT 3 +#define CV_SHIFT_UP 6 +#define CV_SHIFT_DOWN 10 +#define CV_SHIFT_LU 5 +#define CV_SHIFT_RU 7 +#define CV_SHIFT_LD 9 +#define CV_SHIFT_RD 11 + +/* Move by one pixel in specified direction */ +/* pos - position structure */ +/* shift - direction ( it's value must be one of the CV_SHIFT_… constants ) */ +/* cs - number of the image channels */ +#define CV_MOVE_PARAM( pos, shift, cs ) \ + ( (pos).currline += (pos).step_arr[(shift)>>2], (pos).x += ((shift)&3)-2, \ + ((pos).currline != (pos).topline && (pos).currline != (pos).bottomline && \ + (pos).x >= 0 && (pos).x < (pos).width) ? (pos).currline + (pos).x*(cs) : 0 ) + +/* Move by one pixel in specified direction with wrapping when the */ +/* position achieves image boundary */ +/* pos - position structure */ +/* shift - direction ( it's value must be one of the CV_SHIFT_… constants ) */ +/* cs - number of the image channels */ +#define CV_MOVE_PARAM_WRAP( pos, shift, cs ) \ + ( (pos).currline += (pos).step_arr[(shift)>>2], \ + (pos).currline = ((pos).currline == (pos).topline ? \ + (pos).bottomline - (pos).step : \ + (pos).currline == (pos).bottomline ? \ + (pos).topline + (pos).step : (pos).currline), \ + \ + (pos).x += ((shift)&3)-2, \ + (pos).x = ((pos).x < 0 ? (pos).width-1 : (pos).x >= (pos).width ? 0 : (pos).x), \ + \ + (pos).currline + (pos).x*(cs) ) + +#endif/*_CVCOMPAT_H_*/ diff --git a/libraries/external/opencv/linux/include/cvhaartraining.h b/libraries/external/opencv/linux/include/cvhaartraining.h new file mode 100755 index 0000000..eb533d3 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvhaartraining.h @@ -0,0 +1,191 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* + * cvhaartraining.h + * + * haar training functions + */ + +#ifndef _CVHAARTRAINING_H_ +#define _CVHAARTRAINING_H_ + +/* + * cvCreateTrainingSamples + * + * Create training samples applying random distortions to sample image and + * store them in .vec file + * + * filename - .vec file name + * imgfilename - sample image file name + * bgcolor - background color for sample image + * bgthreshold - background color threshold. Pixels those colors are in range + * [bgcolor-bgthreshold, bgcolor+bgthreshold] are considered as transparent + * bgfilename - background description file name. If not NULL samples + * will be put on arbitrary background + * count - desired number of samples + * invert - if not 0 sample foreground pixels will be inverted + * if invert == CV_RANDOM_INVERT then samples will be inverted randomly + * maxintensitydev - desired max intensity deviation of foreground samples pixels + * maxxangle - max rotation angles + * maxyangle + * maxzangle + * showsamples - if not 0 samples will be shown + * winwidth - desired samples width + * winheight - desired samples height + */ +#define CV_RANDOM_INVERT 0x7FFFFFFF + +void cvCreateTrainingSamples( const char* filename, + const char* imgfilename, int bgcolor, int bgthreshold, + const char* bgfilename, int count, + int invert = 0, int maxintensitydev = 40, + double maxxangle = 1.1, + double maxyangle = 1.1, + double maxzangle = 0.5, + int showsamples = 0, + int winwidth = 24, int winheight = 24 ); + +void cvCreateTestSamples( const char* infoname, + const char* imgfilename, int bgcolor, int bgthreshold, + const char* bgfilename, int count, + int invert, int maxintensitydev, + double maxxangle, double maxyangle, double maxzangle, + int showsamples, + int winwidth, int winheight ); + +/* + * cvCreateTrainingSamplesFromInfo + * + * Create training samples from a set of marked up images and store them into .vec file + * infoname - file in which marked up image descriptions are stored + * num - desired number of samples + * showsamples - if not 0 samples will be shown + * winwidth - sample width + * winheight - sample height + * + * Return number of successfully created samples + */ +int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename, + int num, + int showsamples, + int winwidth, int winheight ); + +/* + * cvShowVecSamples + * + * Shows samples stored in .vec file + * + * filename + * .vec file name + * winwidth + * sample width + * winheight + * sample height + * scale + * the scale each sample is adjusted to + */ +void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale ); + + +/* + * cvCreateCascadeClassifier + * + * Create cascade classifier + * dirname - directory name in which cascade classifier will be created. + * It must exist and contain subdirectories 0, 1, 2, ... (nstages-1). + * vecfilename - name of .vec file with object's images + * bgfilename - name of background description file + * npos - number of positive samples used in training of each stage + * nneg - number of negative samples used in training of each stage + * nstages - number of stages + * numprecalculated - number of features being precalculated. Each precalculated feature + * requires (number_of_samples*(sizeof( float ) + sizeof( short ))) bytes of memory + * numsplits - number of binary splits in each weak classifier + * 1 - stumps, 2 and more - trees. + * minhitrate - desired min hit rate of each stage + * maxfalsealarm - desired max false alarm of each stage + * weightfraction - weight trimming parameter + * mode - 0 - BASIC = Viola + * 1 - CORE = All upright + * 2 - ALL = All features + * symmetric - if not 0 vertical symmetry is assumed + * equalweights - if not 0 initial weights of all samples will be equal + * winwidth - sample width + * winheight - sample height + * boosttype - type of applied boosting algorithm + * 0 - Discrete AdaBoost + * 1 - Real AdaBoost + * 2 - LogitBoost + * 3 - Gentle AdaBoost + * stumperror - type of used error if Discrete AdaBoost algorithm is applied + * 0 - misclassification error + * 1 - gini error + * 2 - entropy error + */ +void cvCreateCascadeClassifier( const char* dirname, + const char* vecfilename, + const char* bgfilename, + int npos, int nneg, int nstages, + int numprecalculated, + int numsplits, + float minhitrate = 0.995F, float maxfalsealarm = 0.5F, + float weightfraction = 0.95F, + int mode = 0, int symmetric = 1, + int equalweights = 1, + int winwidth = 24, int winheight = 24, + int boosttype = 3, int stumperror = 0 ); + +void cvCreateTreeCascadeClassifier( const char* dirname, + const char* vecfilename, + const char* bgfilename, + int npos, int nneg, int nstages, + int numprecalculated, + int numsplits, + float minhitrate, float maxfalsealarm, + float weightfraction, + int mode, int symmetric, + int equalweights, + int winwidth, int winheight, + int boosttype, int stumperror, + int maxtreesplits, int minpos ); + +#endif /* _CVHAARTRAINING_H_ */ diff --git a/libraries/external/opencv/linux/include/cvmat.hpp b/libraries/external/opencv/linux/include/cvmat.hpp new file mode 100755 index 0000000..36ad8d9 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvmat.hpp @@ -0,0 +1,2326 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CVMAT_HPP_ +#define _CVMAT_HPP_ + +#if 0 && (defined __cplusplus && (_MSC_VER>=1200 || defined __BORLANDC__ || defined __GNUC__)) + +#if _MSC_VER >= 1200 +#pragma warning( disable: 4710 ) /* suppress "function ... is not inlined" */ +#endif + +#include +#include + +#undef min +#undef max + +/****************************************************************************************\ +* C++ - like operations on CvScalar * +\****************************************************************************************/ + +inline CvScalar& operator += ( CvScalar& a, const CvScalar& b ) +{ + double t0 = a.val[0] + b.val[0]; + double t1 = a.val[1] + b.val[1]; + a.val[0] = t0; + a.val[1] = t1; + + t0 = a.val[2] + b.val[2]; + t1 = a.val[3] + b.val[3]; + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar& operator -= ( CvScalar& a, const CvScalar& b ) +{ + double t0 = a.val[0] - b.val[0]; + double t1 = a.val[1] - b.val[1]; + a.val[0] = t0; + a.val[1] = t1; + + t0 = a.val[2] - b.val[2]; + t1 = a.val[3] - b.val[3]; + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar& operator *= ( CvScalar& a, double b ) +{ + double t0 = a.val[0] * b; + double t1 = a.val[1] * b; + a.val[0] = t0; + a.val[1] = t1; + + t0 = a.val[2] * b; + t1 = a.val[3] * b; + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar& operator /= ( CvScalar& a, double b ) +{ + double inv_b = 1./b; + double t0 = a.val[0] * inv_b; + double t1 = a.val[1] * inv_b; + a.val[0] = t0; + a.val[1] = t1; + + t0 = a.val[2] * inv_b; + t1 = a.val[3] * inv_b; + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar& operator *= ( CvScalar& a, const CvScalar& b ) +{ + double t0 = a.val[0]*b.val[0] - a.val[1]*b.val[1] - + a.val[2]*b.val[2] - a.val[3]*b.val[3]; + + double t1 = a.val[0]*b.val[1] + a.val[1]*b.val[0] + + a.val[2]*b.val[3] - a.val[3]*b.val[2]; + + double t2 = a.val[0]*b.val[2] - a.val[1]*b.val[3] + + a.val[2]*b.val[0] + a.val[3]*b.val[1]; + + double t3 = a.val[0]*b.val[3] + a.val[1]*b.val[2] - + a.val[2]*b.val[1] + a.val[3]*b.val[0]; + + a.val[0] = t0; + a.val[1] = t1; + a.val[2] = t2; + a.val[3] = t3; + + return a; +} + + +inline CvScalar& operator /= ( CvScalar& a, const CvScalar& b ) +{ + double inv_d = -1./(b.val[0]*b.val[0] + b.val[1]*b.val[1] + + b.val[2]*b.val[2] + b.val[3]*b.val[3]); + return a *= cvScalar( b.val[0] * -inv_d, b.val[1] * inv_d, + b.val[2] * inv_d, b.val[3] * inv_d ); +} + + +inline CvScalar& operator += ( CvScalar& a, double b ) +{ + a.val[0] += b; + return a; +} + + +inline CvScalar& operator -= ( CvScalar& a, double b ) +{ + a.val[0] -= b; + return a; +} + + +inline CvScalar operator + ( const CvScalar& a, const CvScalar& b ) +{ + return cvScalar( a.val[0] + b.val[0], a.val[1] + b.val[1], + a.val[2] + b.val[2], a.val[3] + b.val[3] ); +} + + +inline CvScalar operator - ( const CvScalar& a, const CvScalar& b ) +{ + return cvScalar( a.val[0] - b.val[0], a.val[1] - b.val[1], + a.val[2] - b.val[2], a.val[3] - b.val[3] ); +} + + +inline CvScalar operator + ( const CvScalar& a, double b ) +{ + return cvScalar( a.val[0] + b, a.val[1], a.val[2], a.val[3] ); +} + + +inline CvScalar operator - ( const CvScalar& a, double b ) +{ + return cvScalar( a.val[0] - b, a.val[1], a.val[2], a.val[3] ); +} + + +inline CvScalar operator + ( double a, const CvScalar& b ) +{ + return cvScalar( a + b.val[0], b.val[1], b.val[2], b.val[3] ); +} + + +inline CvScalar operator - ( double a, const CvScalar& b ) +{ + return cvScalar( a - b.val[0], -b.val[1], -b.val[2], -b.val[3] ); +} + + +inline CvScalar operator - ( const CvScalar& b ) +{ + return cvScalar( -b.val[0], -b.val[1], -b.val[2], -b.val[3] ); +} + + +inline CvScalar operator * ( const CvScalar& a, const CvScalar& b ) +{ + CvScalar c = a; + + return (c *= b); +} + + +inline CvScalar operator * ( const CvScalar& a, double b ) +{ + return cvScalar( a.val[0]*b, a.val[1]*b, a.val[2]*b, a.val[3]*b ); +} + + +inline CvScalar operator * ( double a, const CvScalar& b ) +{ + return cvScalar( b.val[0]*a, b.val[1]*a, b.val[2]*a, b.val[3]*a ); +} + + +inline CvScalar operator / ( const CvScalar& a, const CvScalar& b ) +{ + CvScalar c = a; + return (c /= b); +} + + +inline CvScalar operator / ( const CvScalar& a, double b ) +{ + double inv_b = 1./b; + return cvScalar( a.val[0]*inv_b, a.val[1]*inv_b, + a.val[2]*inv_b, a.val[3]*inv_b ); +} + + +inline CvScalar operator / ( double a, const CvScalar& b ) +{ + double inv_d = -a/(b.val[0]*b.val[0] + b.val[1]*b.val[1] + + b.val[2]*b.val[2] + b.val[3]*b.val[3]); + return cvScalar( b.val[0] * -inv_d, b.val[1] * inv_d, + b.val[2] * inv_d, b.val[3] * inv_d ); +} + + +inline CvScalar& operator &= ( CvScalar& a, const CvScalar& b ) +{ + int t0 = cvRound(a.val[0]) & cvRound(b.val[0]); + int t1 = cvRound(a.val[1]) & cvRound(b.val[1]); + a.val[0] = t0; + a.val[1] = t1; + + t0 = cvRound(a.val[2]) & cvRound(b.val[2]); + t1 = cvRound(a.val[3]) & cvRound(b.val[3]); + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar& operator |= ( CvScalar& a, const CvScalar& b ) +{ + int t0 = cvRound(a.val[0]) | cvRound(b.val[0]); + int t1 = cvRound(a.val[1]) | cvRound(b.val[1]); + a.val[0] = t0; + a.val[1] = t1; + + t0 = cvRound(a.val[2]) | cvRound(b.val[2]); + t1 = cvRound(a.val[3]) | cvRound(b.val[3]); + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar& operator ^= ( CvScalar& a, const CvScalar& b ) +{ + int t0 = cvRound(a.val[0]) ^ cvRound(b.val[0]); + int t1 = cvRound(a.val[1]) ^ cvRound(b.val[1]); + a.val[0] = t0; + a.val[1] = t1; + + t0 = cvRound(a.val[2]) ^ cvRound(b.val[2]); + t1 = cvRound(a.val[3]) ^ cvRound(b.val[3]); + a.val[2] = t0; + a.val[3] = t1; + + return a; +} + + +inline CvScalar operator & ( const CvScalar& a, const CvScalar& b ) +{ + CvScalar c = a; + return (c &= b); +} + + +inline CvScalar operator | ( const CvScalar& a, const CvScalar& b ) +{ + CvScalar c = a; + return (c |= b); +} + + +inline CvScalar operator ^ ( const CvScalar& a, const CvScalar& b ) +{ + CvScalar c = a; + return (c ^= b); +} + + +inline CvScalar operator ~ ( const CvScalar& a ) +{ + return cvScalar( ~cvRound(a.val[0]), ~cvRound(a.val[1]), + ~cvRound(a.val[2]), ~cvRound(a.val[3])); +} + + +/****************************************************************************************\ +* C++ Matrix Class * +\****************************************************************************************/ + +struct _CvMATConstElem_; +struct _CvMATElem_; +struct _CvMATElemCn_; + +struct _CvMAT_T_; +struct _CvMAT_MUL_; +struct _CvMAT_INV_; +struct _CvMAT_SCALE_; +struct _CvMAT_SCALE_SHIFT_; +struct _CvMAT_ADD_; +struct _CvMAT_ADD_EX_; +struct _CvMAT_MUL_ADD_; +struct _CvMAT_LOGIC_; +struct _CvMAT_UN_LOGIC_; +struct _CvMAT_NOT_; +struct _CvMAT_CVT_; +struct _CvMAT_COPY_; +struct _CvMAT_DOT_OP_; +struct _CvMAT_SOLVE_; +struct _CvMAT_CMP_; + +class CV_EXPORTS CvMAT : public CvMat +{ +protected: + +public: + /* helper methods for retrieving/setting matrix elements */ + static double get( const uchar* ptr, int type, int coi = 0 ); + static void set( uchar* ptr, int type, int coi, double d ); + static void set( uchar* ptr, int type, int coi, int i ); + static void set( uchar* ptr, int type, double d ); + static void set( uchar* ptr, int type, int i ); + + /******************* constructors ********************/ + /* empty */ + explicit CvMAT(); + + /* creation */ + explicit CvMAT( int rows, int cols, int type, void* data, int step = CV_AUTOSTEP ); + explicit CvMAT( int rows, int type, void* data, int step = CV_AUTOSTEP ); + explicit CvMAT( int rows, int cols, int type ); + explicit CvMAT( int rows, int type ); + + /* extracting part of an existing matrix */ + explicit CvMAT( const CvMat& mat, CvRect rect ); /* submatrix */ + explicit CvMAT( const CvMat& mat, int k, int i ); /* submatrix: + k == 0 - i-th row + k > 0 - i-th column + k < 0 - i-th diagonal */ + /* copying */ + CvMAT( const CvMat& mat ); + CvMAT( const CvMAT& mat ); + CvMAT( const IplImage& img ); + + /* CvMAT b = op(a1,a2,...) */ + explicit CvMAT( const _CvMAT_T_& mat_t ); + explicit CvMAT( const _CvMAT_INV_& inv_mat ); + explicit CvMAT( const _CvMAT_ADD_& mat_add ); + explicit CvMAT( const _CvMAT_ADD_EX_& mat_add ); + explicit CvMAT( const _CvMAT_SCALE_& scale_mat ); + explicit CvMAT( const _CvMAT_SCALE_SHIFT_& scale_shift_mat ); + explicit CvMAT( const _CvMAT_MUL_& mmul ); + explicit CvMAT( const _CvMAT_MUL_ADD_& mmuladd ); + explicit CvMAT( const _CvMAT_LOGIC_& mat_logic ); + explicit CvMAT( const _CvMAT_UN_LOGIC_& mat_logic ); + explicit CvMAT( const _CvMAT_NOT_& not_mat ); + explicit CvMAT( const _CvMAT_COPY_& mat_copy ); + explicit CvMAT( const _CvMAT_CVT_& mat_copy ); + explicit CvMAT( const _CvMAT_DOT_OP_& dot_mul ); + explicit CvMAT( const _CvMAT_SOLVE_& solve_mat ); + explicit CvMAT( const _CvMAT_CMP_& cmp_mat ); + + /* desctructor */ + ~CvMAT(); + + /* copying and filling with a constant */ + CvMAT& operator = ( const CvMAT& mat ); + CvMAT& operator = ( const CvMat& mat ); + CvMAT& operator = ( const IplImage& img ); + CvMAT& operator = ( double fillval ); + CvMAT& operator = ( const CvScalar& fillval ); + + /* b = op(a1, a2,...) */ + CvMAT& operator = ( const _CvMAT_T_& mat_t ); + CvMAT& operator = ( const _CvMAT_INV_& inv_mat ); + CvMAT& operator = ( const _CvMAT_ADD_& mat_add ); + CvMAT& operator = ( const _CvMAT_ADD_EX_& mat_add ); + CvMAT& operator = ( const _CvMAT_SCALE_& scale_mat ); + CvMAT& operator = ( const _CvMAT_SCALE_SHIFT_& scale_shift_mat ); + CvMAT& operator = ( const _CvMAT_MUL_& mmul ); + CvMAT& operator = ( const _CvMAT_MUL_ADD_& mmuladd ); + CvMAT& operator = ( const _CvMAT_LOGIC_& mat_logic ); + CvMAT& operator = ( const _CvMAT_UN_LOGIC_& mat_logic ); + CvMAT& operator = ( const _CvMAT_NOT_& not_mat ); + CvMAT& operator = ( const _CvMAT_DOT_OP_& dot_mul ); + CvMAT& operator = ( const _CvMAT_SOLVE_& solve_mat ); + CvMAT& operator = ( const _CvMAT_CMP_& cmp_mat ); + CvMAT& operator = ( const _CvMAT_CVT_& mat_cvt ); + + /* copy matrix data, not only matrix header */ + CvMAT& operator = ( const _CvMAT_COPY_& mat_copy ); + + /* augmented assignments */ + CvMAT& operator += ( const CvMat& mat ); + CvMAT& operator += ( double val ); + CvMAT& operator += ( const CvScalar& val ); + CvMAT& operator += ( const _CvMAT_SCALE_& scale_mat ); + CvMAT& operator += ( const _CvMAT_SCALE_SHIFT_& scale_mat ); + CvMAT& operator += ( const _CvMAT_MUL_& mmul ); + + CvMAT& operator -= ( const CvMat& mat ); + CvMAT& operator -= ( double val ); + CvMAT& operator -= ( const CvScalar& val ); + CvMAT& operator -= ( const _CvMAT_SCALE_& scale_mat ); + CvMAT& operator -= ( const _CvMAT_SCALE_SHIFT_& scale_mat ); + CvMAT& operator -= ( const _CvMAT_MUL_& mmul ); + + CvMAT& operator *= ( const CvMat& mat ); + CvMAT& operator *= ( double val ); + CvMAT& operator *= ( const CvScalar& val ); + CvMAT& operator *= ( const _CvMAT_SCALE_& scale_mat ); + CvMAT& operator *= ( const _CvMAT_SCALE_SHIFT_& scale_mat ); + + CvMAT& operator &= ( const CvMat& mat ); + CvMAT& operator &= ( double val ); + CvMAT& operator &= ( const CvScalar& val ); + + CvMAT& operator |= ( const CvMat& mat ); + CvMAT& operator |= ( double val ); + CvMAT& operator |= ( const CvScalar& val ); + + CvMAT& operator ^= ( const CvMat& mat ); + CvMAT& operator ^= ( double val ); + CvMAT& operator ^= ( const CvScalar& val ); + + /* various scalar charactertics */ + double norm( int norm_type = CV_L2 ) const; + double norm( CvMat& mat, int norm_type = CV_L2 ) const; + CvScalar sum() const; + + double det() const; + double trace() const; + + _CvMAT_T_ t() const; /* transposition */ + _CvMAT_INV_ inv(int method = 0) const; + /* inversion using one of the following methods: + method = 0 - Gaussian elimination, + method = 1 - SVD */ + + _CvMAT_DOT_OP_ mul( const CvMAT& mat ) const; + _CvMAT_DOT_OP_ mul( const _CvMAT_SCALE_& mat ) const; + + _CvMAT_DOT_OP_ div( const CvMAT& mat ) const; + _CvMAT_DOT_OP_ div( const _CvMAT_SCALE_& mat ) const; + + _CvMAT_DOT_OP_ min( const CvMAT& mat ) const; + _CvMAT_DOT_OP_ max( const CvMAT& mat ) const; + _CvMAT_DOT_OP_ min( double value ) const; + _CvMAT_DOT_OP_ max( double value ) const; + double min( CvPoint* minloc = 0 ) const; + double max( CvPoint* maxloc = 0 ) const; + + _CvMAT_DOT_OP_ abs() const; + + /* accessing matrix elements */ + _CvMATElem_ operator ()( int row ); + _CvMATConstElem_ operator ()( int row ) const; + + _CvMATElem_ operator ()( int row, int col ); + _CvMATConstElem_ operator ()( int row, int col ) const; + + _CvMATElem_ operator ()( CvPoint loc ); + _CvMATConstElem_ operator ()( CvPoint loc ) const; + + _CvMATElemCn_ operator()( int row, int col, int coi ); + double operator()( int row, int col, int coi ) const; + + _CvMATElemCn_ operator()( CvPoint pt, int coi ); + double operator()( CvPoint pt, int coi ) const; + + void* ptr( int row ); + const void* ptr( int row ) const; + + void* ptr( int row, int col ); + const void* ptr( int row, int col ) const; + + void* ptr( CvPoint pt ); + const void* ptr( CvPoint pt ) const; + + /* accessing matrix parts */ + CvMAT row( int row ) const; + CvMAT rowrange( int row1, int row2 ) const; + CvMAT col( int col ) const; + CvMAT colrange( int col1, int col2 ) const; + CvMAT rect( CvRect rect ) const; + CvMAT diag( int diag = 0 ) const; + + _CvMAT_COPY_ clone() const; + + /* convert matrix */ + _CvMAT_CVT_ cvt( int newdepth = -1, double scale = 1, + double shift = 0 ) const; + + /* matrix transformation */ + void reshape( int newcn, int newrows = 0 ); + void flipX(); + void flipY(); + void flipXY(); + + /* matrix I/O: use dynamically linked runtime libraries */ + void write( const char* name = 0, FILE* f = 0, const char* fmt = 0 ); + void read( char** name = 0, FILE* f = 0 ); + + /* decrease matrix data reference counter and clear data pointer */ + void release(); +protected: + + void create( int rows, int cols, int type ); +}; + + +/* !!! Internal Use Only !!! */ +/* proxies for matrix elements */ + +/* const_A(i,j) */ +struct CV_EXPORTS _CvMATConstElem_ +{ + explicit _CvMATConstElem_( const uchar* ptr, int type ); + operator CvScalar () const; + double operator ()( int coi = 0 ) const; + + uchar* ptr; + int type; +}; + + +/* A(i,j,cn) or A(i,j)(cn) */ +struct CV_EXPORTS _CvMATElemCn_ +{ + explicit _CvMATElemCn_( uchar* ptr, int type, int coi ); + operator double() const; + + _CvMATElemCn_& operator = ( const _CvMATConstElem_& elem ); + _CvMATElemCn_& operator = ( const _CvMATElemCn_& elem ); + _CvMATElemCn_& operator = ( const CvScalar& scalar ); + _CvMATElemCn_& operator = ( double d ); + _CvMATElemCn_& operator = ( float f ); + _CvMATElemCn_& operator = ( int i ); + + uchar* ptr; + int type; +}; + + +/* A(i,j) */ +struct CV_EXPORTS _CvMATElem_ : public _CvMATConstElem_ +{ + explicit _CvMATElem_( uchar* ptr, int type ); + _CvMATElemCn_ operator ()( int coi = 0 ); + + _CvMATElem_& operator = ( const _CvMATConstElem_& elem ); + _CvMATElem_& operator = ( const _CvMATElem_& elem ); + _CvMATElem_& operator = ( const _CvMATElemCn_& elem ); + _CvMATElem_& operator = ( const CvScalar& val ); + _CvMATElem_& operator = ( double d ); + _CvMATElem_& operator = ( float f ); + _CvMATElem_& operator = ( int i ); +}; + + +struct CV_EXPORTS _CvMAT_BASE_OP_ +{ + _CvMAT_BASE_OP_() {}; + virtual operator CvMAT() const = 0; + + _CvMAT_DOT_OP_ mul( const CvMAT& a ) const; + _CvMAT_DOT_OP_ mul( const _CvMAT_SCALE_& a ) const; + + _CvMAT_DOT_OP_ div( const CvMAT& a ) const; + _CvMAT_DOT_OP_ div( const _CvMAT_SCALE_& a ) const; + + _CvMAT_DOT_OP_ max( const CvMAT& a ) const; + _CvMAT_DOT_OP_ min( const CvMAT& a ) const; + + _CvMAT_DOT_OP_ max( double value ) const; + _CvMAT_DOT_OP_ min( double value ) const; + + double max( CvPoint* maxloc = 0 ) const; + double min( CvPoint* minloc = 0 ) const; + + _CvMAT_DOT_OP_ abs() const; + + _CvMAT_INV_ inv( int method = 0 ) const; + _CvMAT_T_ t() const; + + CvMAT row( int row ) const; + CvMAT rowrange( int row1, int row2 ) const; + CvMAT col( int col ) const; + CvMAT colrange( int col1, int col2 ) const; + CvMAT rect( CvRect rect ) const; + CvMAT diag( int diag = 0 ) const; + _CvMAT_CVT_ cvt( int newdepth = -1, double scale = 1, double shift = 0 ) const; + + double norm( int norm_type = CV_L2 ) const; + double det() const; + double trace() const; + CvScalar sum() const; +}; + + +/* (A^t)*alpha */ +struct CV_EXPORTS _CvMAT_T_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_T_( const CvMAT* a ); + explicit _CvMAT_T_( const CvMAT* a, double alpha ); + + double det() const; + double norm( int normType = CV_L2 ) const; + operator CvMAT() const; + + CvMAT a; + double alpha; +}; + + +/* inv(A) */ +struct CV_EXPORTS _CvMAT_INV_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_INV_( const CvMAT* mat, int method ); + operator CvMAT() const; + + CvMAT a; + int method; +}; + + +/* (A^ta)*(B^tb)*alpha */ +struct CV_EXPORTS _CvMAT_MUL_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_MUL_( const CvMAT* a, const CvMAT* b, int t_ab ); + explicit _CvMAT_MUL_( const CvMAT* a, const CvMAT* b, + double alpha, int t_abc ); + operator CvMAT() const; + + double alpha; + CvMAT* a; + CvMAT* b; + int t_ab; /* (t_ab & 1) = ta, (t_ab & 2) = tb */ +}; + + +/* (A^ta)*(B^tb)*alpha + (C^tc)*beta */ +struct CV_EXPORTS _CvMAT_MUL_ADD_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_MUL_ADD_( const CvMAT* a, const CvMAT* b, + const CvMAT* c, int t_abc ); + explicit _CvMAT_MUL_ADD_( const CvMAT* a, const CvMAT* b, double alpha, + const CvMAT* c, double beta, int t_abc ); + operator CvMAT() const; + + double alpha, beta; + CvMAT* a; + CvMAT* b; + CvMAT* c; + int t_abc; /* (t_abc & 1) = ta, (t_abc & 2) = tb, (t_abc & 4) = tc */ +}; + + +/* A + B*beta */ +struct CV_EXPORTS _CvMAT_ADD_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_ADD_( const CvMAT* a, const CvMAT* b, double beta = 1 ); + operator CvMAT() const; + + double norm( int norm_type = CV_L2 ) const; + _CvMAT_DOT_OP_ abs() const; + + double beta; + CvMAT* a; + CvMAT* b; +}; + + +/* A*alpha + B*beta + gamma */ +struct CV_EXPORTS _CvMAT_ADD_EX_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_ADD_EX_( const CvMAT* a, double alpha, + const CvMAT* b, double beta, double gamma = 0 ); + operator CvMAT() const; + + double alpha, beta, gamma; + CvMAT* a; + CvMAT* b; +}; + + +/* A*alpha */ +struct CV_EXPORTS _CvMAT_SCALE_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_SCALE_( const CvMAT* a, double alpha ); + operator CvMAT() const; + + _CvMAT_DOT_OP_ mul( const CvMAT& a ) const; + _CvMAT_DOT_OP_ mul( const _CvMAT_SCALE_& a ) const; + + _CvMAT_DOT_OP_ div( const CvMAT& a ) const; + _CvMAT_DOT_OP_ div( const _CvMAT_SCALE_& a ) const; + + double alpha; + CvMAT* a; +}; + + +/* A*alpha + beta */ +struct CV_EXPORTS _CvMAT_SCALE_SHIFT_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_SCALE_SHIFT_( const CvMAT* a, double alpha, double beta ); + operator CvMAT() const; + + _CvMAT_DOT_OP_ abs() const; + + double alpha, beta; + CvMAT* a; +}; + + +/* (A & B), (A | B) or (A ^ B) */ +struct CV_EXPORTS _CvMAT_LOGIC_ : public _CvMAT_BASE_OP_ +{ + enum Op { AND = 0, OR = 1, XOR = 2 }; + explicit _CvMAT_LOGIC_( const CvMAT* a, const CvMAT* b, Op op, int flags = 0 ); + operator CvMAT() const; + + CvMAT* a; + CvMAT* b; + Op op; + int flags; +}; + + +/* (A & scalar), (A | scalar) or (A ^ scalar) */ +struct CV_EXPORTS _CvMAT_UN_LOGIC_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_UN_LOGIC_( const CvMAT* a, double alpha, + _CvMAT_LOGIC_::Op op, int flags = 0 ); + operator CvMAT() const; + + CvMAT* a; + double alpha; + _CvMAT_LOGIC_::Op op; + int flags; +}; + + +/* ~A */ +struct CV_EXPORTS _CvMAT_NOT_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_NOT_( const CvMAT* a ); + operator CvMAT() const; + + CvMAT* a; +}; + + +/* conversion of data type */ +struct CV_EXPORTS _CvMAT_CVT_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_CVT_( const CvMAT* a, int newdepth = -1, + double scale = 1, double shift = 0 ); + operator CvMAT() const; + + CvMAT a; + int newdepth; + double scale, shift; +}; + + +/* conversion of data type */ +struct CV_EXPORTS _CvMAT_COPY_ +{ + explicit _CvMAT_COPY_( const CvMAT* a ); + operator CvMAT() const; + CvMAT* a; +}; + + +/* a.op(b), where op = mul, div, min, max ... */ +struct CV_EXPORTS _CvMAT_DOT_OP_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_DOT_OP_( const CvMAT* a, const CvMAT* b, + int op, double alpha = 1 ); + operator CvMAT() const; + + CvMAT a; /* keep the left operand copy */ + CvMAT* b; + double alpha; + int op; +}; + + +/* A.inv()*B or A.pinv()*B */ +struct CV_EXPORTS _CvMAT_SOLVE_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_SOLVE_( const CvMAT* a, const CvMAT* b, int method ); + operator CvMAT() const; + + CvMAT* a; + CvMAT* b; + int method; +}; + + +/* A <=> B */ +struct CV_EXPORTS _CvMAT_CMP_ : public _CvMAT_BASE_OP_ +{ + explicit _CvMAT_CMP_( const CvMAT* a, const CvMAT* b, int cmp_op ); + explicit _CvMAT_CMP_( const CvMAT* a, double alpha, int cmp_op ); + operator CvMAT() const; + + CvMAT* a; + CvMAT* b; + double alpha; + int cmp_op; +}; + + +/************************* _CvMATConstElem_ inline methods ******************************/ + +inline _CvMATConstElem_::_CvMATConstElem_(const uchar* p, int t) : ptr((uchar*)p), type(t) +{} + + +inline _CvMATConstElem_::operator CvScalar() const +{ + CvScalar scalar; + cvRawDataToScalar( ptr, type, &scalar ); + + return scalar; +} + + +inline double _CvMATConstElem_::operator ()( int coi ) const +{ return CvMAT::get( ptr, type, coi ); } + + +inline _CvMATElemCn_::_CvMATElemCn_( uchar* p, int t, int coi ) : + ptr(p), type(CV_MAT_DEPTH(t)) +{ + if( coi ) + { + assert( (unsigned)coi < (unsigned)CV_MAT_CN(t) ); + ptr += coi * CV_ELEM_SIZE(type); + } +} + + +inline _CvMATElemCn_::operator double() const +{ return CvMAT::get( ptr, type ); } + + +inline _CvMATElemCn_& _CvMATElemCn_::operator = ( const _CvMATConstElem_& elem ) +{ + if( type == elem.type ) + memcpy( ptr, elem.ptr, CV_ELEM_SIZE(type) ); + else + { + assert( CV_MAT_CN(elem.type) == 1 ); + CvMAT::set( ptr, type, 0, elem(0)); + } + + return *this; +} + + +inline _CvMATElemCn_& _CvMATElemCn_::operator = ( const _CvMATElemCn_& elem ) +{ + if( type == elem.type ) + memcpy( ptr, elem.ptr, CV_ELEM_SIZE(type) ); + else + CvMAT::set( ptr, type, 0, (double)elem ); + return *this; +} + + +inline _CvMATElemCn_& _CvMATElemCn_::operator = ( const CvScalar& scalar ) +{ + CvMAT::set( ptr, type, 0, scalar.val[0] ); + return *this; +} + + +inline _CvMATElemCn_& _CvMATElemCn_::operator = ( double d ) +{ + CvMAT::set( ptr, type, 0, d ); + return *this; +} + + +inline _CvMATElemCn_& _CvMATElemCn_::operator = ( float f ) +{ + CvMAT::set( ptr, type, 0, (double)f ); + return *this; +} + + +inline _CvMATElemCn_& _CvMATElemCn_::operator = ( int i ) +{ + CvMAT::set( ptr, type, 0, i ); + return *this; +} + + +inline _CvMATElem_::_CvMATElem_( uchar* p, int t ) : _CvMATConstElem_( (const uchar*)p, t ) +{} + + +inline _CvMATElemCn_ _CvMATElem_::operator ()( int coi ) +{ return _CvMATElemCn_( ptr, type, coi ); } + + +inline _CvMATElem_& _CvMATElem_::operator = ( const _CvMATConstElem_& elem ) +{ + if( type == elem.type ) + memcpy( ptr, elem.ptr, CV_ELEM_SIZE(type) ); + else + { + assert( CV_MAT_CN( type ^ elem.type ) == 0 ); + CvScalar sc = (CvScalar)elem; + cvScalarToRawData( &sc, ptr, type, 0 ); + } + + return *this; +} + + +inline _CvMATElem_& _CvMATElem_::operator = ( const _CvMATElem_& elem ) +{ + *this = (const _CvMATConstElem_&)elem; + return *this; +} + + +inline _CvMATElem_& _CvMATElem_::operator = ( const _CvMATElemCn_& elem ) +{ + if( type == elem.type ) + memcpy( ptr, elem.ptr, CV_ELEM_SIZE(type) ); + else + CvMAT::set( ptr, type, (double)elem ); + + return *this; +} + + +inline _CvMATElem_& _CvMATElem_::operator = ( const CvScalar& scalar ) +{ + cvScalarToRawData( &scalar, ptr, type, 0 ); + return *this; +} + + +inline _CvMATElem_& _CvMATElem_::operator = ( double d ) +{ + CvMAT::set( ptr, type, d ); + return *this; +} + + +inline _CvMATElem_& _CvMATElem_::operator = ( float f ) +{ + CvMAT::set( ptr, type, (double)f ); + return *this; +} + + +inline _CvMATElem_& _CvMATElem_::operator = ( int i ) +{ + CvMAT::set( ptr, type, i ); + return *this; +} + + +/********************************** CvMAT inline methods ********************************/ + +inline CvMAT::CvMAT() +{ + memset( this, 0, sizeof(*this)); +} + + +inline CvMAT::CvMAT( int rows, int cols, int type, void* data, int step ) +{ + cvInitMatHeader( this, rows, cols, type, data, step ); +} + + +inline CvMAT::CvMAT( int rows, int type, void* data, int step ) +{ + cvInitMatHeader( this, rows, 1, type, data, step ); +} + + +inline void CvMAT::create( int rows, int cols, int type ) +{ + int step = cols*CV_ELEM_SIZE(type), total_size = step*rows; + this->rows = rows; + this->cols = cols; + this->step = rows == 1 ? 0 : step; + this->type = CV_MAT_MAGIC_VAL | (type & CV_MAT_TYPE_MASK) | CV_MAT_CONT_FLAG; + refcount = (int*)cvAlloc((size_t)total_size + 8); + data.ptr = (uchar*)(((size_t)(refcount + 1) + 7) & -8); + *refcount = 1; +} + + +inline CvMAT::CvMAT( int rows, int cols, int type ) +{ + create( rows, cols, type ); +} + + +inline CvMAT::CvMAT( int rows, int type ) +{ + create( rows, 1, type ); +} + + +inline CvMAT::CvMAT( const CvMat& mat ) +{ + memcpy( this, &mat, sizeof(mat)); + if( refcount ) + (*refcount)++; +} + + +inline CvMAT::CvMAT( const CvMAT& mat ) +{ + memcpy( this, &mat, sizeof(mat)); + if( refcount ) + (*refcount)++; +} + + +inline CvMAT::CvMAT( const IplImage& img ) +{ + cvGetMat( &img, this ); +} + + +inline void CvMAT::release() +{ + data.ptr = NULL; + if( refcount != NULL && --*refcount == 0 ) + cvFree( (void**)&refcount ); + refcount = 0; +} + + +inline CvMAT::~CvMAT() +{ + release(); +} + + +inline CvMAT& CvMAT::operator = ( const CvMAT& mat ) +{ + if( this != &mat ) + { + release(); + memcpy( this, &mat, sizeof(mat)); + if( refcount ) + (*refcount)++; + } + return *this; +} + + +inline CvMAT& CvMAT::operator = ( const CvMat& mat ) +{ + *this = (const CvMAT&)mat; + return *this; +} + + +inline CvMAT& CvMAT::operator = ( const IplImage& img ) +{ + release(); + cvGetMat( &img, this ); + + return *this; +} + + +inline CvMAT& CvMAT::operator = ( double fillval ) +{ + cvFillImage( this, fillval ); + return *this; +} + + +inline CvMAT& CvMAT::operator = ( const CvScalar& fillval ) +{ + cvSet( this, fillval ); + return *this; +} + + +inline CvMAT& CvMAT::operator += ( const CvMat& mat ) +{ + cvAdd( this, &mat, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator += ( double val ) +{ + cvAddS( this, cvScalar(val), this ); + return *this; +} + + +inline CvMAT& CvMAT::operator += ( const CvScalar& val ) +{ + cvAddS( this, val, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator -= ( const CvMat& mat ) +{ + cvSub( this, &mat, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator -= ( double val ) +{ + cvSubS( this, cvScalar(val), this ); + return *this; +} + + +inline CvMAT& CvMAT::operator -= ( const CvScalar& val ) +{ + cvSubS( this, val, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator *= ( const CvMat& mat ) +{ + cvMul( this, &mat, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator *= ( double val ) +{ + cvScale( this, this, val, 0 ); + return *this; +} + + +inline CvMAT& CvMAT::operator *= ( const CvScalar& val ) +{ + cvScaleAdd( this, val, 0, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator &= ( const CvMat& mat ) +{ + cvAnd( this, &mat, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator &= ( double val ) +{ + cvAndS( this, cvScalarAll(val), this ); + return *this; +} + + +inline CvMAT& CvMAT::operator &= ( const CvScalar& val ) +{ + cvAndS( this, val, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator |= ( const CvMat& mat ) +{ + cvOr( this, &mat, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator |= ( double val ) +{ + cvOrS( this, cvScalarAll(val), this ); + return *this; +} + + +inline CvMAT& CvMAT::operator |= ( const CvScalar& val ) +{ + cvOrS( this, val, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator ^= ( const CvMat& mat ) +{ + cvXor( this, &mat, this ); + return *this; +} + + +inline CvMAT& CvMAT::operator ^= ( double val ) +{ + cvXorS( this, cvScalarAll(val), this ); + return *this; +} + + +inline CvMAT& CvMAT::operator ^= ( const CvScalar& val ) +{ + cvXorS( this, val, this ); + return *this; +} + + +inline double CvMAT::norm( int normType ) const +{ return cvNorm( this, 0, normType ); } + + +inline double CvMAT::min( CvPoint* minloc ) const +{ + double t; + cvMinMaxLoc( this, &t, 0, minloc, 0, 0 ); + return t; +} + +inline double CvMAT::max( CvPoint* maxloc ) const +{ + double t; + cvMinMaxLoc( this, 0, &t, 0, maxloc, 0 ); + return t; +} + + +inline double CvMAT::norm( CvMat& mat, int normType ) const +{ return cvNorm( this, &mat, normType ); } + + +inline CvScalar CvMAT::sum() const +{ return cvSum( this ); } + + +inline double CvMAT::det() const +{ return cvDet( this ); } + + +inline void CvMAT::reshape( int newcn, int newrows ) +{ cvReshape( this, this, newcn, newrows ); } + + +inline void CvMAT::flipX() +{ cvFlip( this, this, 1 ); } + + +inline void CvMAT::flipY() +{ cvFlip( this, this, 0 ); } + + +inline void CvMAT::flipXY() +{ cvFlip( this, this, -1 ); } + + +inline _CvMATElem_ CvMAT::operator ()( int row ) +{ return _CvMATElem_( CV_MAT_ELEM_PTR( *this, row, 0 ), type ); } + + +inline _CvMATConstElem_ CvMAT::operator ()( int row ) const +{ return _CvMATConstElem_( CV_MAT_ELEM_PTR( *this, row, 0 ), type ); } + + +inline _CvMATElem_ CvMAT::operator ()( int row, int col ) +{ return _CvMATElem_( CV_MAT_ELEM_PTR( *this, row, col ), type ); } + + +inline _CvMATConstElem_ CvMAT::operator ()( int row, int col ) const +{ return _CvMATConstElem_( CV_MAT_ELEM_PTR( *this, row, col ), type ); } + + +inline _CvMATElemCn_ CvMAT::operator()( int row, int col, int coi ) +{ return _CvMATElemCn_( CV_MAT_ELEM_PTR( *this, row, col ), type, coi ); } + + +inline _CvMATElemCn_ CvMAT::operator()( CvPoint pt, int coi ) +{ return _CvMATElemCn_( CV_MAT_ELEM_PTR( *this, pt.y, pt.x ), type, coi ); } + + +inline double CvMAT::operator()( int row, int col, int coi ) const +{ return get( CV_MAT_ELEM_PTR( *this, row, col ), type, coi ); } + + +inline _CvMATElem_ CvMAT::operator ()( CvPoint pt ) +{ return _CvMATElem_( CV_MAT_ELEM_PTR( *this, pt.y, pt.x ), type ); } + + +inline _CvMATConstElem_ CvMAT::operator ()( CvPoint pt ) const +{ return _CvMATConstElem_( CV_MAT_ELEM_PTR( *this, pt.y, pt.x ), type ); } + + +inline double CvMAT::operator()( CvPoint pt, int coi ) const +{ return get( CV_MAT_ELEM_PTR( *this, pt.y, pt.x ), type, coi ); } + + +inline void* CvMAT::ptr( int row ) +{ return CV_MAT_ELEM_PTR( *this, row, 0 ); } + + +inline const void* CvMAT::ptr( int row ) const +{ return (const void*)CV_MAT_ELEM_PTR( *this, row, 0 ); } + + +inline void* CvMAT::ptr( int row, int col ) +{ return CV_MAT_ELEM_PTR( *this, row, col ); } + + +inline const void* CvMAT::ptr( int row, int col ) const +{ return (const void*)CV_MAT_ELEM_PTR( *this, row, col ); } + + +inline void* CvMAT::ptr( CvPoint pt ) +{ return CV_MAT_ELEM_PTR( *this, pt.y, pt.x ); } + + +inline const void* CvMAT::ptr( CvPoint pt ) const +{ return (const void*)CV_MAT_ELEM_PTR( *this, pt.y, pt.x ); } + + +inline _CvMAT_INV_ CvMAT::inv( int method ) const +{ return _CvMAT_INV_( this, method ); } + + +inline _CvMAT_T_ CvMAT::t() const +{ return _CvMAT_T_( this ); } + + +inline _CvMAT_COPY_ CvMAT::clone() const +{ return _CvMAT_COPY_( this ); } + +inline _CvMAT_CVT_ CvMAT::cvt( int newdepth, double scale, double shift ) const +{ return _CvMAT_CVT_( this, newdepth, scale, shift ); } + + +inline CvMAT::CvMAT( const CvMat& mat, CvRect rect ) +{ + type = 0; + cvGetSubArr( &mat, this, rect ); + cvIncRefData( this ); +} + + +/* submatrix: + k == 0 - i-th row + k > 0 - i-th column + k < 0 - i-th diagonal */ +inline CvMAT::CvMAT( const CvMat& mat, int k, int i ) +{ + type = 0; + if( k == 0 ) + cvGetRow( &mat, this, i ); + else if( k > 0 ) + cvGetCol( &mat, this, i ); + else + cvGetDiag( &mat, this, i ); + cvIncRefData( this ); +} + + +inline CvMAT CvMAT::row( int r ) const +{ return CvMAT( *this, 0, r ); } + + +inline CvMAT CvMAT::col( int c ) const +{ return CvMAT( *this, 1, c ); } + + +inline CvMAT CvMAT::diag( int d ) const +{ return CvMAT( *this, -1, d ); } + + +inline CvMAT CvMAT::rect( CvRect rect ) const +{ return CvMAT( *this, rect ); } + +inline CvMAT CvMAT::rowrange( int row1, int row2 ) const +{ + assert( 0 <= row1 && row1 < row2 && row2 <= height ); + return CvMAT( *this, cvRect( 0, row1, width, row2 - row1 )); +} + +inline CvMAT CvMAT::colrange( int col1, int col2 ) const +{ + assert( 0 <= col1 && col1 < col2 && col2 <= width ); + return CvMAT( *this, cvRect( col1, 0, col2 - col1, height )); +} + +inline _CvMAT_DOT_OP_ CvMAT::mul( const CvMAT& mat ) const +{ return _CvMAT_DOT_OP_( this, &mat, '*' ); } + +inline _CvMAT_DOT_OP_ CvMAT::mul( const _CvMAT_SCALE_& mat ) const +{ return _CvMAT_DOT_OP_( this, mat.a, '*', mat.alpha ); } + +inline _CvMAT_DOT_OP_ CvMAT::div( const CvMAT& mat ) const +{ return _CvMAT_DOT_OP_( this, &mat, '/' ); } + +inline _CvMAT_DOT_OP_ CvMAT::div( const _CvMAT_SCALE_& mat ) const +{ return _CvMAT_DOT_OP_( this, mat.a, '/', 1./mat.alpha ); } + +inline _CvMAT_DOT_OP_ CvMAT::min( const CvMAT& mat ) const +{ return _CvMAT_DOT_OP_( this, &mat, 'm' ); } + +inline _CvMAT_DOT_OP_ CvMAT::max( const CvMAT& mat ) const +{ return _CvMAT_DOT_OP_( this, &mat, 'M' ); } + +inline _CvMAT_DOT_OP_ CvMAT::min( double value ) const +{ return _CvMAT_DOT_OP_( this, 0, 'm', value ); } + +inline _CvMAT_DOT_OP_ CvMAT::max( double value ) const +{ return _CvMAT_DOT_OP_( this, 0, 'M', value ); } + +inline _CvMAT_DOT_OP_ CvMAT::abs() const +{ return _CvMAT_DOT_OP_( this, 0, 'a', 0 ); } + +/****************************************************************************************\ +* binary operations (+,-,*) * +\****************************************************************************************/ + +/* +* PART I. Scaling, shifting, addition/subtraction operations +*/ + +/* (mat2^t) = (mat1^t) * scalar */ +inline _CvMAT_T_ operator * ( const _CvMAT_T_& a, double alpha ) +{ return _CvMAT_T_( &a.a, a.alpha*alpha ); } + +/* (mat2^t) = scalar * (mat1^t) */ +inline _CvMAT_T_ operator * ( double alpha, const _CvMAT_T_& a ) +{ return _CvMAT_T_( &a.a, a.alpha*alpha ); } + +/* -(mat^t) */ +inline _CvMAT_T_ operator - ( const _CvMAT_T_& a ) +{ return _CvMAT_T_( &a.a, -a.alpha ); } + +/* mat_scaled = mat * scalar */ +inline _CvMAT_SCALE_ operator * ( const CvMAT& a, double alpha ) +{ return _CvMAT_SCALE_( &a, alpha ); } + +/* mat_scaled = scalar * mat */ +inline _CvMAT_SCALE_ operator * ( double alpha, const CvMAT& a ) +{ return _CvMAT_SCALE_( &a, alpha ); } + +/* mat_scaled2 = mat_scaled1 * scalar */ +inline _CvMAT_SCALE_ operator * ( const _CvMAT_SCALE_& a, double alpha ) +{ return _CvMAT_SCALE_( a.a, a.alpha*alpha ); } + +/* mat_scaled2 = scalar * mat_scaled1 */ +inline _CvMAT_SCALE_ operator * ( double alpha, const _CvMAT_SCALE_& a ) +{ return _CvMAT_SCALE_( a.a, a.alpha*alpha ); } + +/* -mat_scaled */ +inline _CvMAT_SCALE_ operator - ( const _CvMAT_SCALE_& a ) +{ return _CvMAT_SCALE_( a.a, -a.alpha ); } + + +/* mat_scaled_shifted = mat + scalar */ +inline _CvMAT_SCALE_SHIFT_ operator + ( const CvMAT& a, double beta ) +{ return _CvMAT_SCALE_SHIFT_( &a, 1, beta ); } + +/* mat_scaled_shifted = scalar + mat */ +inline _CvMAT_SCALE_SHIFT_ operator + ( double beta, const CvMAT& a ) +{ return _CvMAT_SCALE_SHIFT_( &a, 1, beta ); } + +/* mat_scaled_shifted = mat - scalar */ +inline _CvMAT_SCALE_SHIFT_ operator - ( const CvMAT& a, double beta ) +{ return _CvMAT_SCALE_SHIFT_( &a, 1, -beta ); } + +/* mat_scaled_shifted = scalar - mat */ +inline _CvMAT_SCALE_SHIFT_ operator - ( double beta, const CvMAT& a ) +{ return _CvMAT_SCALE_SHIFT_( &a, -1, beta ); } + +/* mat_scaled_shifted = mat_scaled + scalar */ +inline _CvMAT_SCALE_SHIFT_ operator + ( const _CvMAT_SCALE_& a, double beta ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha, beta ); } + +/* mat_scaled_shifted = scalar + mat_scaled */ +inline _CvMAT_SCALE_SHIFT_ operator + ( double beta, const _CvMAT_SCALE_& a ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha, beta ); } + +/* mat_scaled_shifted = mat_scaled - scalar */ +inline _CvMAT_SCALE_SHIFT_ operator - ( const _CvMAT_SCALE_& a, double beta ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha, -beta ); } + +/* mat_scaled_shifted = scalar - mat_scaled */ +inline _CvMAT_SCALE_SHIFT_ operator - ( double beta, const _CvMAT_SCALE_& a ) +{ return _CvMAT_SCALE_SHIFT_( a.a, -a.alpha, beta ); } + +/* mat_scaled_shifted2 = mat_scaled_shifted1 + scalar */ +inline _CvMAT_SCALE_SHIFT_ operator + ( const _CvMAT_SCALE_SHIFT_& a, double beta ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha, a.beta + beta ); } + +/* mat_scaled_shifted2 = scalar + mat_scaled_shifted1 */ +inline _CvMAT_SCALE_SHIFT_ operator + ( double beta, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha, a.beta + beta ); } + +/* mat_scaled_shifted2 = mat_scaled_shifted1 - scalar */ +inline _CvMAT_SCALE_SHIFT_ operator - ( const _CvMAT_SCALE_SHIFT_& a, double beta ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha, a.beta - beta ); } + +/* mat_scaled_shifted2 = scalar - mat_scaled_shifted1 */ +inline _CvMAT_SCALE_SHIFT_ operator - ( double beta, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_SCALE_SHIFT_( a.a, -a.alpha, beta - a.beta ); } + +/* mat_scaled_shifted2 = mat_scaled_shifted1 * scalar */ +inline _CvMAT_SCALE_SHIFT_ operator * ( const _CvMAT_SCALE_SHIFT_& a, double alpha ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha*alpha, a.beta*alpha ); } + +/* mat_scaled_shifted2 = scalar * mat_scaled_shifted1 */ +inline _CvMAT_SCALE_SHIFT_ operator * ( double alpha, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_SCALE_SHIFT_( a.a, a.alpha*alpha, a.beta*alpha ); } + +/* -mat_scaled_shifted */ +inline _CvMAT_SCALE_SHIFT_ operator - ( const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_SCALE_SHIFT_( a.a, -a.alpha, -a.beta ); } + + +/* -mat1 */ +inline _CvMAT_SCALE_ operator - ( const CvMAT& a ) +{ return _CvMAT_SCALE_( &a, -1 ); } + +/* mat_add = mat1 + mat2 */ +inline _CvMAT_ADD_ operator + ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_ADD_( &a, &b ); } + +/* mat_add = mat1 - mat2 */ +inline _CvMAT_ADD_ operator - ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_ADD_( &a, &b, -1 ); } + +/* mat_add = mat_scaled1 + mat2 */ +inline _CvMAT_ADD_ operator + ( const _CvMAT_SCALE_& a, const CvMAT& b ) +{ return _CvMAT_ADD_( &b, a.a, a.alpha ); } + +/* mat_add = mat1 + mat_scaled2 */ +inline _CvMAT_ADD_ operator + ( const CvMAT& b, const _CvMAT_SCALE_& a ) +{ return _CvMAT_ADD_( &b, a.a, a.alpha ); } + +/* -mat_add */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_ADD_& a ) +{ return _CvMAT_ADD_EX_( a.a, -1, a.b, -a.beta ); } + +/* mat_add = mat_scaled1 - mat2 */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_SCALE_& a, const CvMAT& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, &b, -1 ); } + +/* mat_add = mat1 - mat_scaled2 */ +inline _CvMAT_ADD_ operator - ( const CvMAT& b, const _CvMAT_SCALE_& a ) +{ return _CvMAT_ADD_( &b, a.a, -a.alpha ); } + +/* mat_add = mat_scaled_shifted1 + mat2 */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_SCALE_SHIFT_& a, const CvMAT& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, &b, 1, a.beta ); } + +/* mat_add = mat1 + mat_scaled_shifted2 */ +inline _CvMAT_ADD_EX_ operator + ( const CvMAT& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, &b, 1, a.beta ); } + +/* mat_add = mat_scaled_shifted1 - mat2 */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_SCALE_SHIFT_& a, const CvMAT& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, &b, -1, a.beta ); } + +/* mat_add = mat1 - mat_scaled_shifted2 */ +inline _CvMAT_ADD_EX_ operator - ( const CvMAT& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_ADD_EX_( a.a, -a.alpha, &b, 1, -a.beta ); } + +/* mat_add = mat_scaled_shifted1 + mat_scaled2 */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_SCALE_SHIFT_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, b.alpha, a.beta ); } + +/* mat_add = mat_scaled1 + mat_scaled_shifted2 */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_SCALE_& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, b.alpha, a.beta ); } + +/* mat_add = mat_scaled_shifted1 - mat_scaled2 */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_SCALE_SHIFT_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, -b.alpha, a.beta ); } + +/* mat_add = mat_scaled1 - mat_scaled_shifted2 */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_SCALE_& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_ADD_EX_( a.a, -a.alpha, b.a, b.alpha, -a.beta ); } + +/* mat_add = mat_scaled1 + mat_scaled2 */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_SCALE_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, b.alpha ); } + +/* mat_add = mat_scaled1 - mat_scaled2 */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_SCALE_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, -b.alpha ); } + +/* mat_add = mat_scaled_shifted1 + mat_scaled_shifted2 */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_SCALE_SHIFT_& a, + const _CvMAT_SCALE_SHIFT_& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, b.alpha, a.beta + b.beta ); } + +/* mat_add = mat_scaled_shifted1 - mat_scaled_shifted2 */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_SCALE_SHIFT_& a, + const _CvMAT_SCALE_SHIFT_& b ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, b.a, -b.alpha, a.beta - b.beta ); } + +/* mat_add2 = mat_add1 + scalar */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_ADD_EX_& a, double gamma ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, a.b, a.beta, a.gamma + gamma ); } + +/* mat_add2 = scalar + mat_add1 */ +inline _CvMAT_ADD_EX_ operator + ( double gamma, const _CvMAT_ADD_EX_& a ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, a.b, a.beta, a.gamma + gamma ); } + +/* mat_add2 = mat_add1 - scalar */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_ADD_EX_& a, double gamma ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha, a.b, a.beta, a.gamma - gamma ); } + +/* mat_add2 = scalar - mat_add1 */ +inline _CvMAT_ADD_EX_ operator - ( double gamma, const _CvMAT_ADD_EX_& a ) +{ return _CvMAT_ADD_EX_( a.a, -a.alpha, a.b, -a.beta, gamma - a.gamma ); } + +/* mat_add2 = mat_add1 * scalar */ +inline _CvMAT_ADD_EX_ operator * ( const _CvMAT_ADD_EX_& a, double alpha ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha*alpha, a.b, a.beta*alpha, a.gamma*alpha ); } + +/* mat_add2 = scalar * mat_add1 */ +inline _CvMAT_ADD_EX_ operator * ( double alpha, const _CvMAT_ADD_EX_& a ) +{ return _CvMAT_ADD_EX_( a.a, a.alpha*alpha, a.b, a.beta*alpha, a.gamma*alpha ); } + +/* mat_add2 = mat_add1 + scalar */ +inline _CvMAT_ADD_EX_ operator + ( const _CvMAT_ADD_& a, double gamma ) +{ return _CvMAT_ADD_EX_( a.a, 1, a.b, a.beta, gamma ); } + +/* mat_add2 = scalar + mat_add1 */ +inline _CvMAT_ADD_EX_ operator + ( double gamma, const _CvMAT_ADD_& a ) +{ return _CvMAT_ADD_EX_( a.a, 1, a.b, a.beta, gamma ); } + +/* mat_add2 = mat_add1 - scalar */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_ADD_& a, double gamma ) +{ return _CvMAT_ADD_EX_( a.a, 1, a.b, a.beta, -gamma ); } + +/* mat_add2 = scalar - mat_add1 */ +inline _CvMAT_ADD_EX_ operator - ( double gamma, const _CvMAT_ADD_& a ) +{ return _CvMAT_ADD_EX_( a.a, -1, a.b, -a.beta, gamma ); } + +/* mat_add2 = mat_add1 * scalar */ +inline _CvMAT_ADD_EX_ operator * ( const _CvMAT_ADD_& a, double alpha ) +{ return _CvMAT_ADD_EX_( a.a, alpha, a.b, a.beta*alpha, 0 ); } + +/* mat_add2 = scalar * mat_add1 */ +inline _CvMAT_ADD_EX_ operator * ( double alpha, const _CvMAT_ADD_& a ) +{ return _CvMAT_ADD_EX_( a.a, alpha, a.b, a.beta*alpha, 0 ); } + +/* -mat_add_ex */ +inline _CvMAT_ADD_EX_ operator - ( const _CvMAT_ADD_EX_& a ) +{ return _CvMAT_ADD_EX_( a.a, -a.alpha, a.b, -a.beta, -a.gamma ); } + + +/* +* PART II. Matrix multiplication. +*/ + +/* mmul = mat1 * mat2 */ +inline _CvMAT_MUL_ operator * ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_MUL_( &a, &b, 0 ); } + +/* mmul = (mat1^t) * mat2 */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_T_& a, const CvMAT& b ) +{ return _CvMAT_MUL_( &a.a, &b, a.alpha, 1 ); } + +/* mmul = mat1 * (mat2^t) */ +inline _CvMAT_MUL_ operator * ( const CvMAT& b, const _CvMAT_T_& a ) +{ return _CvMAT_MUL_( &b, &a.a, a.alpha, 2 ); } + +/* mmul = (mat1^t) * (mat2^t) */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_T_& a, const _CvMAT_T_& b ) +{ return _CvMAT_MUL_( &a.a, &b.a, a.alpha*b.alpha, 3 ); } + +/* mmul = mat_scaled1 * mat2 */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_SCALE_& a, const CvMAT& b ) +{ return _CvMAT_MUL_( a.a, &b, a.alpha, 0 ); } + +/* mmul = mat1 * mat_scaled2 */ +inline _CvMAT_MUL_ operator * ( const CvMAT& b, const _CvMAT_SCALE_& a ) +{ return _CvMAT_MUL_( &b, a.a, a.alpha, 0 ); } + +/* mmul = (mat1^t) * mat_scaled1 */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_T_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_MUL_( &a.a, b.a, a.alpha*b.alpha, 1 ); } + +/* mmul = mat_scaled1 * (mat2^t) */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_SCALE_& b, const _CvMAT_T_& a ) +{ return _CvMAT_MUL_( b.a, &a.a, a.alpha*b.alpha, 2 ); } + +/* mmul = mat_scaled1 * mat_scaled2 */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_SCALE_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_MUL_( a.a, b.a, a.alpha*b.alpha, 0 ); } + +/* mmul2 = mmul1 * scalar */ +inline _CvMAT_MUL_ operator * ( const _CvMAT_MUL_& a, double alpha ) +{ return _CvMAT_MUL_( a.a, a.b, a.alpha*alpha, a.t_ab ); } + +/* mmul2 = scalar * mmul1 */ +inline _CvMAT_MUL_ operator * ( double alpha, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_( a.a, a.b, a.alpha*alpha, a.t_ab ); } + +/* -mmul */ +inline _CvMAT_MUL_ operator - ( const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_( a.a, a.b, -a.alpha, a.t_ab ); } + +/* mmuladd = mmul + mat */ +inline _CvMAT_MUL_ADD_ operator + ( const _CvMAT_MUL_& a, const CvMAT& b ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, &b, 1, a.t_ab ); } + +/* !!! Comment this off because of ambigous conversion error !!! + mmuladd = mat + mmul */ +/* inline _CvMAT_MUL_ADD_ operator + ( const CvMAT& b, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, &b, 1, a.t_ab ); }*/ + +/* mmuladd = mmul - mat */ +inline _CvMAT_MUL_ADD_ operator - ( const _CvMAT_MUL_& a, const CvMAT& b ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, &b, -1, a.t_ab ); } + +/* !!! Comment this off because of ambigous conversion error !!! + mmuladd = mat - mmul */ +/*inline _CvMAT_MUL_ADD_ operator - ( const CvMAT& b, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, -a.alpha, &b, 1, a.t_ab ); }*/ + +/* mmuladd = mmul + mat_scaled */ +inline _CvMAT_MUL_ADD_ operator + ( const _CvMAT_MUL_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, b.a, b.alpha, a.t_ab ); } + +/* mmuladd = mat_scaled + mmul */ +inline _CvMAT_MUL_ADD_ operator + ( const _CvMAT_SCALE_& b, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, b.a, b.alpha, a.t_ab ); } + +/* mmuladd = mmul - mat_scaled */ +inline _CvMAT_MUL_ADD_ operator - ( const _CvMAT_MUL_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, b.a, -b.alpha, a.t_ab ); } + +/* mmuladd = mat_scaled - mmul */ +inline _CvMAT_MUL_ADD_ operator - ( const _CvMAT_SCALE_& b, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, -a.alpha, b.a, b.alpha, a.t_ab ); } + +/* mmuladd = mmul + (mat^t) */ +inline _CvMAT_MUL_ADD_ operator + ( const _CvMAT_MUL_& a, const _CvMAT_T_& b ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, &b.a, b.alpha, a.t_ab + 4 ); } + +/* mmuladd = (mat^t) + mmul */ +inline _CvMAT_MUL_ADD_ operator + ( const _CvMAT_T_& b, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, &b.a, b.alpha, a.t_ab + 4 ); } + +/* mmuladd = mmul - (mat^t) */ +inline _CvMAT_MUL_ADD_ operator - ( const _CvMAT_MUL_& a, const _CvMAT_T_& b ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha, &b.a, -b.alpha, a.t_ab + 4 ); } + +/* mmuladd = (mat^t) - mmul */ +inline _CvMAT_MUL_ADD_ operator - ( const _CvMAT_T_& b, const _CvMAT_MUL_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, -a.alpha, &b.a, b.alpha, a.t_ab + 4 ); } + + +/* mmuladd = mat_scaled_shited * mat */ +inline _CvMAT_MUL_ADD_ operator * ( const _CvMAT_SCALE_SHIFT_& a, const CvMAT& b ) +{ return _CvMAT_MUL_ADD_( a.a, &b, a.alpha, &b, a.beta, 0 ); } + +/* mmuladd = mat * mat_scaled_shited */ +inline _CvMAT_MUL_ADD_ operator * ( const CvMAT& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_MUL_ADD_( &b, a.a, a.alpha, &b, a.beta, 0 ); } + +/* mmuladd = mat_scaled_shited * mat_scaled */ +inline _CvMAT_MUL_ADD_ operator * ( const _CvMAT_SCALE_SHIFT_& a, const _CvMAT_SCALE_& b ) +{ return _CvMAT_MUL_ADD_( a.a, b.a, a.alpha*b.alpha, b.a, a.beta*b.alpha, 0 ); } + +/* mmuladd = mat_scaled * mat_scaled_shited */ +inline _CvMAT_MUL_ADD_ operator * ( const _CvMAT_SCALE_& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_MUL_ADD_( b.a, a.a, a.alpha*b.alpha, b.a, a.beta*b.alpha, 0 ); } + +/* mmuladd = mat_scaled_shited * (mat^t) */ +inline _CvMAT_MUL_ADD_ operator * ( const _CvMAT_SCALE_SHIFT_& a, const _CvMAT_T_& b ) +{ return _CvMAT_MUL_ADD_( a.a, &b.a, a.alpha*b.alpha, &b.a, a.beta*b.alpha, 6 ); } + +/* mmuladd = (mat^t) * mat_scaled_shited */ +inline _CvMAT_MUL_ADD_ operator * ( const _CvMAT_T_& b, const _CvMAT_SCALE_SHIFT_& a ) +{ return _CvMAT_MUL_ADD_( &b.a, a.a, a.alpha*b.alpha, &b.a, a.beta*b.alpha, 5 ); } + +/* mmuladd2 = mmuladd1 * scalar */ +inline _CvMAT_MUL_ADD_ operator * ( const _CvMAT_MUL_ADD_& a, double alpha ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha*alpha, a.c, a.beta*alpha, a.t_abc ); } + +/* mmuladd2 = scalar * mmuladd1 */ +inline _CvMAT_MUL_ADD_ operator * ( double alpha, const _CvMAT_MUL_ADD_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, a.alpha*alpha, a.c, a.beta*alpha, a.t_abc ); } + +/* -mmuladd */ +inline _CvMAT_MUL_ADD_ operator - ( const _CvMAT_MUL_ADD_& a ) +{ return _CvMAT_MUL_ADD_( a.a, a.b, -a.alpha, a.c, -a.beta, a.t_abc ); } + +/* inv(a)*b, i.e. solve a*x = b */ +inline _CvMAT_SOLVE_ operator * ( const _CvMAT_INV_& a, const CvMAT& b ) +{ return _CvMAT_SOLVE_( &a.a, &b, a.method ); } + + +/* +* PART III. Logical operations +*/ +inline _CvMAT_NOT_ operator ~ ( const CvMAT& a ) +{ return _CvMAT_NOT_(&a); } + +inline _CvMAT_LOGIC_ operator & ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_LOGIC_( &a, &b, _CvMAT_LOGIC_::AND, 0 ); } + +inline _CvMAT_LOGIC_ operator & ( const _CvMAT_NOT_& a, const CvMAT& b ) +{ return _CvMAT_LOGIC_( a.a, &b, _CvMAT_LOGIC_::AND, 1 ); } + +inline _CvMAT_LOGIC_ operator & ( const CvMAT& a, const _CvMAT_NOT_& b ) +{ return _CvMAT_LOGIC_( &a, b.a, _CvMAT_LOGIC_::AND, 2 ); } + +inline _CvMAT_LOGIC_ operator & ( const _CvMAT_NOT_& a, const _CvMAT_NOT_& b ) +{ return _CvMAT_LOGIC_( a.a, b.a, _CvMAT_LOGIC_::AND, 3 ); } + + +inline _CvMAT_LOGIC_ operator | ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_LOGIC_( &a, &b, _CvMAT_LOGIC_::OR, 0 ); } + +inline _CvMAT_LOGIC_ operator | ( const _CvMAT_NOT_& a, const CvMAT& b ) +{ return _CvMAT_LOGIC_( a.a, &b, _CvMAT_LOGIC_::OR, 1 ); } + +inline _CvMAT_LOGIC_ operator | ( const CvMAT& a, const _CvMAT_NOT_& b ) +{ return _CvMAT_LOGIC_( &a, b.a, _CvMAT_LOGIC_::OR, 2 ); } + +inline _CvMAT_LOGIC_ operator | ( const _CvMAT_NOT_& a, const _CvMAT_NOT_& b ) +{ return _CvMAT_LOGIC_( a.a, b.a, _CvMAT_LOGIC_::OR, 3 ); } + + +inline _CvMAT_LOGIC_ operator ^ ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_LOGIC_( &a, &b, _CvMAT_LOGIC_::XOR, 0 ); } + +inline _CvMAT_LOGIC_ operator ^ ( const _CvMAT_NOT_& a, const CvMAT& b ) +{ return _CvMAT_LOGIC_( a.a, &b, _CvMAT_LOGIC_::XOR, 1 ); } + +inline _CvMAT_LOGIC_ operator ^ ( const CvMAT& a, const _CvMAT_NOT_& b ) +{ return _CvMAT_LOGIC_( &a, b.a, _CvMAT_LOGIC_::XOR, 2 ); } + +inline _CvMAT_LOGIC_ operator ^ ( const _CvMAT_NOT_& a, const _CvMAT_NOT_& b ) +{ return _CvMAT_LOGIC_( a.a, b.a, _CvMAT_LOGIC_::XOR, 3 ); } + + +inline _CvMAT_UN_LOGIC_ operator & ( const CvMAT& a, double alpha ) +{ return _CvMAT_UN_LOGIC_( &a, alpha, _CvMAT_LOGIC_::AND, 0 ); } + +inline _CvMAT_UN_LOGIC_ operator & ( double alpha, const CvMAT& a ) +{ return _CvMAT_UN_LOGIC_( &a, alpha, _CvMAT_LOGIC_::AND, 0 ); } + +inline _CvMAT_UN_LOGIC_ operator & ( const _CvMAT_NOT_& a, double alpha ) +{ return _CvMAT_UN_LOGIC_( a.a, alpha, _CvMAT_LOGIC_::AND, 1 ); } + +inline _CvMAT_UN_LOGIC_ operator & ( double alpha, const _CvMAT_NOT_& a ) +{ return _CvMAT_UN_LOGIC_( a.a, alpha, _CvMAT_LOGIC_::AND, 1 ); } + + +inline _CvMAT_UN_LOGIC_ operator | ( const CvMAT& a, double alpha ) +{ return _CvMAT_UN_LOGIC_( &a, alpha, _CvMAT_LOGIC_::OR, 0 ); } + +inline _CvMAT_UN_LOGIC_ operator | ( double alpha, const CvMAT& a ) +{ return _CvMAT_UN_LOGIC_( &a, alpha, _CvMAT_LOGIC_::OR, 0 ); } + +inline _CvMAT_UN_LOGIC_ operator | ( const _CvMAT_NOT_& a, double alpha ) +{ return _CvMAT_UN_LOGIC_( a.a, alpha, _CvMAT_LOGIC_::OR, 1 ); } + +inline _CvMAT_UN_LOGIC_ operator | ( double alpha, const _CvMAT_NOT_& a ) +{ return _CvMAT_UN_LOGIC_( a.a, alpha, _CvMAT_LOGIC_::OR, 1 ); } + + +inline _CvMAT_UN_LOGIC_ operator ^ ( const CvMAT& a, double alpha ) +{ return _CvMAT_UN_LOGIC_( &a, alpha, _CvMAT_LOGIC_::XOR, 0 ); } + +inline _CvMAT_UN_LOGIC_ operator ^ ( double alpha, const CvMAT& a ) +{ return _CvMAT_UN_LOGIC_( &a, alpha, _CvMAT_LOGIC_::XOR, 0 ); } + +inline _CvMAT_UN_LOGIC_ operator ^ ( const _CvMAT_NOT_& a, double alpha ) +{ return _CvMAT_UN_LOGIC_( a.a, alpha, _CvMAT_LOGIC_::XOR, 1 ); } + +inline _CvMAT_UN_LOGIC_ operator ^ ( double alpha, const _CvMAT_NOT_& a ) +{ return _CvMAT_UN_LOGIC_( a.a, alpha, _CvMAT_LOGIC_::XOR, 1 ); } + + +/* +* PART IV. Comparison operations +*/ +inline _CvMAT_CMP_ operator > ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_CMP_( &a, &b, CV_CMP_GT ); } + +inline _CvMAT_CMP_ operator >= ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_CMP_( &a, &b, CV_CMP_GE ); } + +inline _CvMAT_CMP_ operator < ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_CMP_( &a, &b, CV_CMP_LT ); } + +inline _CvMAT_CMP_ operator <= ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_CMP_( &a, &b, CV_CMP_LE ); } + +inline _CvMAT_CMP_ operator == ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_CMP_( &a, &b, CV_CMP_EQ ); } + +inline _CvMAT_CMP_ operator != ( const CvMAT& a, const CvMAT& b ) +{ return _CvMAT_CMP_( &a, &b, CV_CMP_NE ); } + + +inline _CvMAT_CMP_ operator > ( const CvMAT& a, double alpha ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_GT ); } + +inline _CvMAT_CMP_ operator > ( double alpha, const CvMAT& a ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_LT ); } + +inline _CvMAT_CMP_ operator >= ( const CvMAT& a, double alpha ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_GE ); } + +inline _CvMAT_CMP_ operator >= ( double alpha, const CvMAT& a ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_LE ); } + +inline _CvMAT_CMP_ operator < ( const CvMAT& a, double alpha ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_LT ); } + +inline _CvMAT_CMP_ operator < ( double alpha, const CvMAT& a ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_GT ); } + +inline _CvMAT_CMP_ operator <= ( const CvMAT& a, double alpha ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_LE ); } + +inline _CvMAT_CMP_ operator <= ( double alpha, const CvMAT& a ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_GE ); } + +inline _CvMAT_CMP_ operator == ( const CvMAT& a, double alpha ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_EQ ); } + +inline _CvMAT_CMP_ operator == ( double alpha, const CvMAT& a ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_EQ ); } + +inline _CvMAT_CMP_ operator != ( const CvMAT& a, double alpha ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_NE ); } + +inline _CvMAT_CMP_ operator != ( double alpha, const CvMAT& a ) +{ return _CvMAT_CMP_( &a, alpha, CV_CMP_NE ); } + + +/* +* PART V. Speedup for some augmented assignments to CvMAT +*/ + +inline CvMAT& CvMAT::operator += ( const _CvMAT_SCALE_& scale_mat ) +{ return (*this = *this + scale_mat); } + +inline CvMAT& CvMAT::operator += ( const _CvMAT_SCALE_SHIFT_& scale_mat ) +{ return (*this = *this + scale_mat); } + +inline CvMAT& CvMAT::operator += ( const _CvMAT_MUL_& mmul ) +{ return (*this = mmul + *this); } + +inline CvMAT& CvMAT::operator -= ( const _CvMAT_SCALE_& scale_mat ) +{ return (*this = *this - scale_mat); } + +inline CvMAT& CvMAT::operator -= ( const _CvMAT_SCALE_SHIFT_& scale_mat ) +{ return (*this = *this - scale_mat); } + +inline CvMAT& CvMAT::operator -= ( const _CvMAT_MUL_& mmul ) +{ return (*this = -mmul + *this); } + +inline CvMAT& CvMAT::operator *= ( const _CvMAT_SCALE_& scale_mat ) +{ return (*this = *this * scale_mat); } + +inline CvMAT& CvMAT::operator *= ( const _CvMAT_SCALE_SHIFT_& scale_mat ) +{ return (*this = *this * scale_mat); } + +/****************************************************************************************\ +* misc. operations on temporary matrices (+,-,*) * +\****************************************************************************************/ + +/* +* the base proxy class implementation +*/ + +/* a.*b */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::mul( const CvMAT& a ) const +{ return ((CvMAT)*this).mul(a); } + +/* a.*b*alpha */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::mul( const _CvMAT_SCALE_& a ) const +{ return ((CvMAT)*this).mul(a); } + +/* a./b */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::div( const CvMAT& a ) const +{ return ((CvMAT)*this).div(a); } + +/* a./(b*alpha) */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::div( const _CvMAT_SCALE_& a ) const +{ return ((CvMAT)*this).div(a); } + +/* a.max(b) */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::min( const CvMAT& a ) const +{ return ((CvMAT)*this).min(a); } + +/* a.min(b) */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::max( const CvMAT& a ) const +{ return ((CvMAT)*this).max(a); } + +/* a.max(alpha) */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::min( double alpha ) const +{ return ((CvMAT)*this).min(alpha); } + +/* a.min(alpha) */ +inline _CvMAT_DOT_OP_ _CvMAT_BASE_OP_::max( double alpha ) const +{ return ((CvMAT)*this).max(alpha); } + + +inline _CvMAT_INV_ _CvMAT_BASE_OP_::inv( int method ) const +{ return ((CvMAT)*this).inv(method); } + +inline _CvMAT_T_ _CvMAT_BASE_OP_::t() const +{ return ((CvMAT)*this).t(); } + +inline _CvMAT_CVT_ _CvMAT_BASE_OP_::cvt( int newdepth, double scale, double shift ) const +{ return ((CvMAT)*this).cvt( newdepth, scale, shift ); } + +inline CvMAT _CvMAT_BASE_OP_::row( int r ) const +{ return CvMAT((CvMAT)*this, 0, r ); } + +inline CvMAT _CvMAT_BASE_OP_::rowrange( int row1, int row2 ) const +{ + CvMAT m = (CvMAT)*this; + assert( 0 <= row1 && row1 < row2 && row2 <= m.height ); + return CvMAT( m, cvRect( 0, row1, m.width, row2 - row1 )); +} + +inline CvMAT _CvMAT_BASE_OP_::col( int c ) const +{ return CvMAT( (CvMAT)*this, 1, c ); } + +inline CvMAT _CvMAT_BASE_OP_::colrange( int col1, int col2 ) const +{ + CvMAT m = (CvMAT)*this; + assert( 0 <= col1 && col1 < col2 && col2 <= m.width ); + return CvMAT( m, cvRect( col1, 0, col2 - col1, m.height )); +} + +inline CvMAT _CvMAT_BASE_OP_::rect( CvRect r ) const +{ return CvMAT( (CvMAT)*this, r ); } + +inline CvMAT _CvMAT_BASE_OP_::diag( int d ) const +{ return CvMAT( (CvMAT)*this, -1, d ); } + +inline double _CvMAT_BASE_OP_::det() const +{ return ((CvMAT)*this).det(); } + +inline double _CvMAT_BASE_OP_::norm( int norm_type ) const +{ return ((CvMAT)*this).norm( norm_type ); } + +inline CvScalar _CvMAT_BASE_OP_::sum() const +{ return ((CvMAT)*this).sum(); } + +inline double _CvMAT_BASE_OP_::min( CvPoint* minloc ) const +{ return ((CvMAT)*this).min( minloc ); } + +inline double _CvMAT_BASE_OP_::max( CvPoint* maxloc ) const +{ return ((CvMAT)*this).max( maxloc ); } + + +/****************************************************************************************/ +/* proxy classes implementation. */ +/* part I. constructors */ +/****************************************************************************************/ + +/* constructors */ +inline _CvMAT_COPY_::_CvMAT_COPY_( const CvMAT* _a ) : a((CvMAT*)_a) {} + +inline _CvMAT_CVT_::_CvMAT_CVT_( const CvMAT* _a, int _newdepth, + double _scale, double _shift ) : + a(*(CvMAT*)_a), newdepth(_newdepth), scale(_scale), shift(_shift) {} + +inline _CvMAT_T_::_CvMAT_T_( const CvMAT* _a ) : a(*(CvMAT*)_a), alpha(1) {} + + +inline _CvMAT_T_::_CvMAT_T_( const CvMAT* _a, double _alpha ) : + a(*(CvMAT*)_a), alpha(_alpha) {} + + +inline _CvMAT_INV_::_CvMAT_INV_( const CvMAT* _a, int _method ) : + a(*(CvMAT*)_a), method(_method) {} + + +inline _CvMAT_MUL_::_CvMAT_MUL_( const CvMAT* _a, const CvMAT* _b, int _t_ab ) : + a((CvMAT*)_a), b((CvMAT*)_b), alpha(1), t_ab(_t_ab) {} + + +inline _CvMAT_MUL_::_CvMAT_MUL_( const CvMAT* _a, const CvMAT* _b, + double _alpha, int _t_ab ) : + a((CvMAT*)_a), b((CvMAT*)_b), alpha(_alpha), t_ab(_t_ab) {} + + +inline _CvMAT_MUL_ADD_::_CvMAT_MUL_ADD_( const CvMAT* _a, const CvMAT* _b, + const CvMAT* _c, int _t_abc ) : + a((CvMAT*)_a), b((CvMAT*)_b), c((CvMAT*)_c), t_abc(_t_abc) {} + + +inline _CvMAT_MUL_ADD_::_CvMAT_MUL_ADD_( const CvMAT* _a, const CvMAT* _b, double _alpha, + const CvMAT* _c, double _beta, int _t_abc ) : + a((CvMAT*)_a), b((CvMAT*)_b), alpha(_alpha), + c((CvMAT*)_c), beta(_beta), t_abc(_t_abc) {} + + +inline _CvMAT_ADD_::_CvMAT_ADD_( const CvMAT* _a, const CvMAT* _b, double _beta ) : + a((CvMAT*)_a), b((CvMAT*)_b), beta(_beta) {} + + +inline _CvMAT_ADD_EX_::_CvMAT_ADD_EX_( const CvMAT* _a, double _alpha, + const CvMAT* _b, double _beta, double _gamma ) : + a((CvMAT*)_a), alpha(_alpha), b((CvMAT*)_b), beta(_beta), gamma(_gamma) {} + + +inline _CvMAT_SCALE_::_CvMAT_SCALE_( const CvMAT* _a, double _alpha ) : + a((CvMAT*)_a), alpha(_alpha) {} + + +inline _CvMAT_SCALE_SHIFT_::_CvMAT_SCALE_SHIFT_( const CvMAT* _a, + double _alpha, double _beta ) : + a((CvMAT*)_a), alpha(_alpha), beta(_beta) {} + + +inline _CvMAT_LOGIC_::_CvMAT_LOGIC_( const CvMAT* _a, const CvMAT* _b, + _CvMAT_LOGIC_::Op _op, int _flags ) : + a((CvMAT*)_a), b((CvMAT*)_b), op(_op), flags(_flags) {} + + +inline _CvMAT_UN_LOGIC_::_CvMAT_UN_LOGIC_( const CvMAT* _a, double _alpha, + _CvMAT_LOGIC_::Op _op, int _flags ) : + a((CvMAT*)_a), alpha(_alpha), op(_op), flags(_flags) {} + + +inline _CvMAT_NOT_::_CvMAT_NOT_( const CvMAT* _a ) : + a((CvMAT*)_a) {} + + +inline _CvMAT_DOT_OP_::_CvMAT_DOT_OP_( const CvMAT* _a, const CvMAT* _b, + int _op, double _alpha ) : + a(*_a), b((CvMAT*)_b), op(_op), alpha(_alpha) {} + + +inline _CvMAT_SOLVE_::_CvMAT_SOLVE_( const CvMAT* _a, const CvMAT* _b, int _method ) : + a((CvMAT*)_a), b((CvMAT*)_b), method(_method) {} + +inline _CvMAT_CMP_::_CvMAT_CMP_( const CvMAT* _a, const CvMAT* _b, int _cmp_op ) : + a((CvMAT*)_a), b((CvMAT*)_b), alpha(0), cmp_op(_cmp_op) {} + +inline _CvMAT_CMP_::_CvMAT_CMP_( const CvMAT* _a, double _alpha, int _cmp_op ) : + a((CvMAT*)_a), b(0), alpha(_alpha), cmp_op(_cmp_op) {} + +/****************************************************************************************/ +/* proxy classes implementation. */ +/* part II. conversion to CvMAT */ +/****************************************************************************************/ + +inline _CvMAT_T_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_INV_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_MUL_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_SCALE_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_SCALE_SHIFT_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_ADD_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_ADD_EX_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_MUL_ADD_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_LOGIC_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_UN_LOGIC_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_NOT_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_DOT_OP_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_SOLVE_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_CMP_::operator CvMAT() const +{ return CvMAT( *this ); } + +inline _CvMAT_CVT_::operator CvMAT() const +{ return CvMAT(*this); } + +inline _CvMAT_COPY_::operator CvMAT() const +{ return *a; } + +/****************************************************************************************/ +/* proxy classes implementation. */ +/* part III. custom overrided methods */ +/****************************************************************************************/ + +inline _CvMAT_DOT_OP_ _CvMAT_SCALE_::mul( const CvMAT& mat ) const +{ return _CvMAT_DOT_OP_( a, &mat, '*', alpha ); } + +inline _CvMAT_DOT_OP_ _CvMAT_SCALE_::mul( const _CvMAT_SCALE_& mat ) const +{ return _CvMAT_DOT_OP_( a, mat.a, '*', alpha*mat.alpha ); } + +inline _CvMAT_DOT_OP_ _CvMAT_SCALE_::div( const CvMAT& mat ) const +{ return _CvMAT_DOT_OP_( a, &mat, '/', alpha ); } + +inline _CvMAT_DOT_OP_ _CvMAT_SCALE_::div( const _CvMAT_SCALE_& mat ) const +{ return _CvMAT_DOT_OP_( a, mat.a, '/', alpha/mat.alpha ); } + +inline _CvMAT_DOT_OP_ operator * ( const _CvMAT_DOT_OP_& dot_op, double alpha ) +{ return _CvMAT_DOT_OP_( &dot_op.a, dot_op.b, dot_op.op, dot_op.alpha * alpha ); } + +inline _CvMAT_DOT_OP_ operator * ( double alpha, const _CvMAT_DOT_OP_& dot_op ) +{ return _CvMAT_DOT_OP_( &dot_op.a, dot_op.b, dot_op.op, dot_op.alpha * alpha ); } + +inline _CvMAT_DOT_OP_ operator / ( double alpha, const CvMAT& mat ) +{ return _CvMAT_DOT_OP_( &mat, 0, '/', alpha ); } + +inline _CvMAT_DOT_OP_ operator / ( double alpha, const _CvMAT_SCALE_& mat ) +{ return _CvMAT_DOT_OP_( mat.a, 0, '/', alpha/mat.alpha ); } + + +inline double _CvMAT_T_::det() const +{ return a.det(); } + +inline double _CvMAT_T_::norm( int norm_type ) const +{ return a.norm( norm_type ); } + +inline double _CvMAT_ADD_::norm( int norm_type ) const +{ + if( beta == -1 ) + return cvNorm( a, b, norm_type ); + else + return ((CvMAT)*this).norm( norm_type ); +} + +inline _CvMAT_DOT_OP_ _CvMAT_ADD_::abs() const +{ + if( beta == -1 ) + return _CvMAT_DOT_OP_( a, b, 'a', 0 ); + else + return ((CvMAT)*this).abs(); +} + +inline _CvMAT_DOT_OP_ _CvMAT_SCALE_SHIFT_::abs() const +{ + if( alpha == 1 ) + return _CvMAT_DOT_OP_( a, 0, 'a', -beta ); + else + return ((CvMAT)*this).abs(); +} + +#endif /* __cplusplus */ + +#endif /*_CVMAT_HPP_*/ + diff --git a/libraries/external/opencv/linux/include/cvtypes.h b/libraries/external/opencv/linux/include/cvtypes.h new file mode 100755 index 0000000..fb7aaf9 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvtypes.h @@ -0,0 +1,384 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CVTYPES_H_ +#define _CVTYPES_H_ + +#ifndef SKIP_INCLUDES + #include + #include +#endif + +/* spatial and central moments */ +typedef struct CvMoments +{ + double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */ + double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */ + double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */ +} +CvMoments; + +/* Hu invariants */ +typedef struct CvHuMoments +{ + double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */ +} +CvHuMoments; + +/**************************** Connected Component **************************************/ + +typedef struct CvConnectedComp +{ + double area; /* area of the connected component */ + CvScalar value; /* average color of the connected component */ + CvRect rect; /* ROI of the component */ + CvSeq* contour; /* optional component boundary + (the contour might have child contours corresponding to the holes)*/ +} +CvConnectedComp; + +/* +Internal structure that is used for sequental retrieving contours from the image. +It supports both hierarchical and plane variants of Suzuki algorithm. +*/ +typedef struct _CvContourScanner* CvContourScanner; + +/* contour retrieval mode */ +#define CV_RETR_EXTERNAL 0 +#define CV_RETR_LIST 1 +#define CV_RETR_CCOMP 2 +#define CV_RETR_TREE 3 + +/* contour approximation method */ +#define CV_CHAIN_CODE 0 +#define CV_CHAIN_APPROX_NONE 1 +#define CV_CHAIN_APPROX_SIMPLE 2 +#define CV_CHAIN_APPROX_TC89_L1 3 +#define CV_CHAIN_APPROX_TC89_KCOS 4 +#define CV_LINK_RUNS 5 + +/* Freeman chain reader state */ +typedef struct CvChainPtReader +{ + CV_SEQ_READER_FIELDS() + char code; + CvPoint pt; + char deltas[8][2]; +} +CvChainPtReader; + +/* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */ +#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \ + ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ + (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ + (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ + (deltas)[6] = (step), (deltas)[7] = (step) + (nch)) + +/* Contour tree header */ +typedef struct CvContourTree +{ + CV_SEQUENCE_FIELDS() + CvPoint p1; /* the first point of the binary tree root segment */ + CvPoint p2; /* the last point of the binary tree root segment */ +} +CvContourTree; + +/* Finds a sequence of convexity defects of given contour */ +typedef struct CvConvexityDefect +{ + CvPoint* start; /* point of the contour where the defect begins */ + CvPoint* end; /* point of the contour where the defect ends */ + CvPoint* depth_point; /* the farthest from the convex hull point within the defect */ + float depth; /* distance between the farthest point and the convex hull */ +} +CvConvexityDefect; + +/************ Data structures and related enumerations for Planar Subdivisions ************/ + +typedef size_t CvSubdiv2DEdge; + +#define CV_QUADEDGE2D_FIELDS() \ + int flags; \ + struct CvSubdiv2DPoint* pt[4]; \ + CvSubdiv2DEdge next[4]; + +#define CV_SUBDIV2D_POINT_FIELDS()\ + int flags; \ + CvSubdiv2DEdge first; \ + CvPoint2D32f pt; + +#define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30) + +typedef struct CvQuadEdge2D +{ + CV_QUADEDGE2D_FIELDS() +} +CvQuadEdge2D; + +typedef struct CvSubdiv2DPoint +{ + CV_SUBDIV2D_POINT_FIELDS() +} +CvSubdiv2DPoint; + +#define CV_SUBDIV2D_FIELDS() \ + CV_GRAPH_FIELDS() \ + int quad_edges; \ + int is_geometry_valid; \ + CvSubdiv2DEdge recent_edge; \ + CvPoint2D32f topleft; \ + CvPoint2D32f bottomright; + +typedef struct CvSubdiv2D +{ + CV_SUBDIV2D_FIELDS() +} +CvSubdiv2D; + + +typedef enum CvSubdiv2DPointLocation +{ + CV_PTLOC_ERROR = -2, + CV_PTLOC_OUTSIDE_RECT = -1, + CV_PTLOC_INSIDE = 0, + CV_PTLOC_VERTEX = 1, + CV_PTLOC_ON_EDGE = 2 +} +CvSubdiv2DPointLocation; + +typedef enum CvNextEdgeType +{ + CV_NEXT_AROUND_ORG = 0x00, + CV_NEXT_AROUND_DST = 0x22, + CV_PREV_AROUND_ORG = 0x11, + CV_PREV_AROUND_DST = 0x33, + CV_NEXT_AROUND_LEFT = 0x13, + CV_NEXT_AROUND_RIGHT = 0x31, + CV_PREV_AROUND_LEFT = 0x20, + CV_PREV_AROUND_RIGHT = 0x02 +} +CvNextEdgeType; + +/* get the next edge with the same origin point (counterwise) */ +#define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3]) + + +/* Defines for Distance Transform */ +#define CV_DIST_USER -1 /* User defined distance */ +#define CV_DIST_L1 1 /* distance = |x1-x2| + |y1-y2| */ +#define CV_DIST_L2 2 /* the simple euclidean distance */ +#define CV_DIST_C 3 /* distance = max(|x1-x2|,|y1-y2|) */ +#define CV_DIST_L12 4 /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */ +#define CV_DIST_FAIR 5 /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */ +#define CV_DIST_WELSCH 6 /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */ +#define CV_DIST_HUBER 7 /* distance = |x|data.fl */ + float* PriorState; /* =state_post->data.fl */ + float* DynamMatr; /* =transition_matrix->data.fl */ + float* MeasurementMatr; /* =measurement_matrix->data.fl */ + float* MNCovariance; /* =measurement_noise_cov->data.fl */ + float* PNCovariance; /* =process_noise_cov->data.fl */ + float* KalmGainMatr; /* =gain->data.fl */ + float* PriorErrorCovariance;/* =error_cov_pre->data.fl */ + float* PosterErrorCovariance;/* =error_cov_post->data.fl */ + float* Temp1; /* temp1->data.fl */ + float* Temp2; /* temp2->data.fl */ +#endif + + CvMat* state_pre; /* predicted state (x'(k)): + x(k)=A*x(k-1)+B*u(k) */ + CvMat* state_post; /* corrected state (x(k)): + x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */ + CvMat* transition_matrix; /* state transition matrix (A) */ + CvMat* control_matrix; /* control matrix (B) + (it is not used if there is no control)*/ + CvMat* measurement_matrix; /* measurement matrix (H) */ + CvMat* process_noise_cov; /* process noise covariance matrix (Q) */ + CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */ + CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)): + P'(k)=A*P(k-1)*At + Q)*/ + CvMat* gain; /* Kalman gain matrix (K(k)): + K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/ + CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)): + P(k)=(I-K(k)*H)*P'(k) */ + CvMat* temp1; /* temporary matrices */ + CvMat* temp2; + CvMat* temp3; + CvMat* temp4; + CvMat* temp5; +} +CvKalman; + + +/*********************** Haar-like Object Detection structures **************************/ +#define CV_HAAR_MAGIC_VAL 0x42500000 +#define CV_TYPE_NAME_HAAR "opencv-haar-classifier" + +#define CV_IS_HAAR_CLASSIFIER( haar ) \ + ((haar) != NULL && \ + (((const CvHaarClassifierCascade*)(haar))->flags & CV_MAGIC_MASK)==CV_HAAR_MAGIC_VAL) + +#define CV_HAAR_FEATURE_MAX 3 + +typedef struct CvHaarFeature +{ + int tilted; + struct + { + CvRect r; + float weight; + } rect[CV_HAAR_FEATURE_MAX]; +} +CvHaarFeature; + +typedef struct CvHaarClassifier +{ + int count; + CvHaarFeature* haar_feature; + float* threshold; + int* left; + int* right; + float* alpha; +} +CvHaarClassifier; + +typedef struct CvHaarStageClassifier +{ + int count; + float threshold; + CvHaarClassifier* classifier; + + int next; + int child; + int parent; +} +CvHaarStageClassifier; + +typedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade; + +typedef struct CvHaarClassifierCascade +{ + int flags; + int count; + CvSize orig_window_size; + CvSize real_window_size; + double scale; + CvHaarStageClassifier* stage_classifier; + CvHidHaarClassifierCascade* hid_cascade; +} +CvHaarClassifierCascade; + +typedef struct CvAvgComp +{ + CvRect rect; + int neighbors; +} +CvAvgComp; + +#endif /*_CVTYPES_H_*/ + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/cvver.h b/libraries/external/opencv/linux/include/cvver.h new file mode 100755 index 0000000..ac89efe --- /dev/null +++ b/libraries/external/opencv/linux/include/cvver.h @@ -0,0 +1,55 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright( C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +//(including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort(including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* + definition of the current version of OpenCV + Usefull to test in user programs +*/ + +#ifndef _CVVERSION_H_ +#define _CVVERSION_H_ + +#define CV_MAJOR_VERSION 1 +#define CV_MINOR_VERSION 0 +#define CV_SUBMINOR_VERSION 0 +#define CV_VERSION "1.0.0" + +#endif /*_CVVERSION_H_*/ diff --git a/libraries/external/opencv/linux/include/cvvidsurv.hpp b/libraries/external/opencv/linux/include/cvvidsurv.hpp new file mode 100755 index 0000000..cd3ea81 --- /dev/null +++ b/libraries/external/opencv/linux/include/cvvidsurv.hpp @@ -0,0 +1,1265 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + + +#ifndef __CVVIDEOSURVEILLANCE_H__ +#define __CVVIDEOSURVEILLANCE_H__ + +/* turn off the functionality until cvaux/src/Makefile.am gets updated */ +//#if _MSC_VER >= 1200 + +#include + +#if _MSC_VER >= 1200 || defined __BORLANDC__ +#define cv_stricmp stricmp +#define cv_strnicmp strnicmp +#elif defined __GNUC__ +#define cv_stricmp strcasecmp +#define cv_strnicmp strncasecmp +#else +#error Do not know how to make case-insensitive string comparison on this platform +#endif + +//struct DefParam; +struct CvDefParam +{ + struct CvDefParam* next; + char* pName; + char* pComment; + double* pDouble; + double Double; + float* pFloat; + float Float; + int* pInt; + int Int; + char** pStr; + char* Str; +}; + +class CV_EXPORTS CvVSModule +{ +private: /* internal data */ + CvDefParam* m_pParamList; + char* m_pModuleTypeName; + char* m_pModuleName; + char* m_pNickName; +protected: + int m_Wnd; +public: /* constructor and destructor */ + CvVSModule() + { + m_pNickName = NULL; + m_pParamList = NULL; + m_pModuleTypeName = NULL; + m_pModuleName = NULL; + m_Wnd = 0; + AddParam("DebugWnd",&m_Wnd); + } + virtual ~CvVSModule() + { + CvDefParam* p = m_pParamList; + for(;p;) + { + CvDefParam* pf = p; + p=p->next; + FreeParam(&pf); + } + m_pParamList=NULL; + if(m_pModuleTypeName)free(m_pModuleTypeName); + if(m_pModuleName)free(m_pModuleName); + } +private: /* internal functions */ + void FreeParam(CvDefParam** pp) + { + CvDefParam* p = pp[0]; + if(p->Str)free(p->Str); + if(p->pName)free(p->pName); + if(p->pComment)free(p->pComment); + cvFree((void**)pp); + } + CvDefParam* NewParam(char* name) + { + CvDefParam* pNew = (CvDefParam*)cvAlloc(sizeof(CvDefParam)); + memset(pNew,0,sizeof(CvDefParam)); + pNew->pName = strdup(name); + if(m_pParamList==NULL) + { + m_pParamList = pNew; + } + else + { + CvDefParam* p = m_pParamList; + for(;p->next;p=p->next); + p->next = pNew; + } + return pNew; + }; + + CvDefParam* GetParamPtr(int index) + { + CvDefParam* p = m_pParamList; + for(;index>0 && p;index--,p=p->next); + return p; + } + CvDefParam* GetParamPtr(char* name) + { + CvDefParam* p = m_pParamList; + for(;p;p=p->next) + { + if(cv_stricmp(p->pName,name)==0) break; + } + return p; + } +protected: /* INTERNAL INTERFACE */ + int IsParam(char* name) + { + return GetParamPtr(name)?1:0; + }; + void AddParam(char* name, double* pAddr) + { + NewParam(name)->pDouble = pAddr; + }; + void AddParam(char* name, float* pAddr) + { + NewParam(name)->pFloat=pAddr; + }; + void AddParam(char* name, int* pAddr) + { + NewParam(name)->pInt=pAddr; + }; + void AddParam(char* name, char** pAddr) + { + CvDefParam* pP = NewParam(name); + char* p = pAddr?pAddr[0]:NULL; + pP->pStr = pAddr?pAddr:&(pP->Str); + if(p) + { + pP->Str = strdup(p); + pP->pStr[0] = pP->Str; + } + }; + void AddParam(char* name) + { + CvDefParam* p = NewParam(name); + p->pDouble = &p->Double; + }; + void CommentParam(char* name, char* pComment) + { + CvDefParam* p = GetParamPtr(name); + if(p)p->pComment = pComment ? strdup(pComment) : 0; + }; + void SetTypeName(char* name){m_pModuleTypeName = strdup(name);} + void SetModuleName(char* name){m_pModuleName = strdup(name);} + void DelParam(char* name) + { + CvDefParam* p = m_pParamList; + CvDefParam* pPrev = NULL; + for(;p;p=p->next) + { + if(cv_stricmp(p->pName,name)==0) break; + pPrev = p; + } + if(p) + { + if(pPrev) + { + pPrev->next = p->next; + } + else + { + m_pParamList = p->next; + } + FreeParam(&p); + } + }/* DelParam */ + +public: /* EXTERNAL INTERFACE */ + char* GetParamName(int index) + { + CvDefParam* p = GetParamPtr(index); + return p?p->pName:NULL; + } + char* GetParamComment(char* name) + { + CvDefParam* p = GetParamPtr(name); + if(p && p->pComment) return p->pComment; + return NULL; + } + double GetParam(char* name) + { + CvDefParam* p = GetParamPtr(name); + if(p) + { + if(p->pDouble) return p->pDouble[0]; + if(p->pFloat) return p->pFloat[0]; + if(p->pInt) return p->pInt[0]; + } + return 0; + }; + + char* GetParamStr(char* name) + { + CvDefParam* p = GetParamPtr(name); + return p?p->Str:NULL; + } + void SetParam(char* name, double val) + { + CvDefParam* p = m_pParamList; + for(;p;p=p->next) + { + if(cv_stricmp(p->pName,name) != 0) continue; + if(p->pDouble)p->pDouble[0] = val; + if(p->pFloat)p->pFloat[0] = (float)val; + if(p->pInt)p->pInt[0] = cvRound(val); + } + } + void SetParamStr(char* name, char* str) + { + CvDefParam* p = m_pParamList; + for(;p;p=p->next) + { + if(cv_stricmp(p->pName,name) != 0) continue; + if(p->pStr) + { + if(p->Str)free(p->Str); + p->Str = NULL; + if(str)p->Str = strdup(str); + p->pStr[0] = p->Str; + } + } + /* convert to double and set */ + if(str)SetParam(name,atof(str)); + } + void TransferParamsFromChild(CvVSModule* pM, char* prefix = NULL) + { + char tmp[1024]; + char* FN = NULL; + int i; + for(i=0;;++i) + { + char* N = pM->GetParamName(i); + if(N == NULL) break; + FN = N; + if(prefix) + { + strcpy(tmp,prefix); + strcat(tmp,"_"); + FN = strcat(tmp,N); + } + + if(!IsParam(FN)) + { + if(pM->GetParamStr(N)) + { + AddParam(FN,(char**)NULL); + } + else + { + AddParam(FN); + } + } + if(pM->GetParamStr(N)) + { + char* val = pM->GetParamStr(N); + SetParamStr(FN,val); + } + else + { + double val = pM->GetParam(N); + SetParam(FN,val); + } + CommentParam(FN, pM->GetParamComment(N)); + }/* transfer next param */ + }/* Transfer params */ + + void TransferParamsToChild(CvVSModule* pM, char* prefix = NULL) + { + char tmp[1024]; + int i; + for(i=0;;++i) + { + char* N = pM->GetParamName(i); + if(N == NULL) break; + if(prefix) + { + strcpy(tmp,prefix); + strcat(tmp,"_"); + strcat(tmp,N); + } + else + { + strcpy(tmp,N); + } + + if(IsParam(tmp)) + { + if(GetParamStr(tmp)) + pM->SetParamStr(N,GetParamStr(tmp)); + else + pM->SetParam(N,GetParam(tmp)); + } + }/* transfer next param */ + pM->ParamUpdate(); + }/* Transfer params */ + + virtual void ParamUpdate(){}; + char* GetTypeName() + { + return m_pModuleTypeName; + } + int IsModuleTypeName(char* name) + { + return m_pModuleTypeName?(cv_stricmp(m_pModuleTypeName,name)==0):0; + } + char* GetModuleName() + { + return m_pModuleName; + } + int IsModuleName(char* name) + { + return m_pModuleName?(cv_stricmp(m_pModuleName,name)==0):0; + } + void SetNickName(char* pStr) + { + + if(m_pNickName) + free(m_pNickName); + m_pNickName = NULL; + if(pStr) + m_pNickName = strdup(pStr); + } + char* GetNickName() + { + return m_pNickName ? m_pNickName : (char *)"unknown"; + } + virtual void SaveState(CvFileStorage*){}; + virtual void LoadState(CvFileStorage*, CvFileNode*){}; + + virtual void Release() = 0; +};/* CvVMModule */ +void inline cvWriteStruct(CvFileStorage* fs, char* name, void* addr, char* desc, int num=1) +{ + cvStartWriteStruct(fs,name,CV_NODE_SEQ|CV_NODE_FLOW); + cvWriteRawData(fs,addr,num,desc); + cvEndWriteStruct(fs); +} +void inline cvReadStructByName(CvFileStorage* fs, CvFileNode* node, char* name, void* addr, char* desc) +{ + CvFileNode* pSeqNode = cvGetFileNodeByName(fs, node, name); + if(pSeqNode==NULL) + { + printf("WARNING!!! Can't read structure %s\n",name); + } + else + { + if(CV_NODE_IS_SEQ(pSeqNode->tag)) + { + cvReadRawData( fs, pSeqNode, addr, desc ); + } + else + { + printf("WARNING!!! Structure %s is not sequence and can not be read\n",name); + } + } +} + + +/* FOREGROUND DETECTOR INTERFACE */ +class CV_EXPORTS CvFGDetector: public CvVSModule +{ +public: + virtual IplImage* GetMask() = 0; + /* process current image */ + virtual void Process(IplImage* pImg) = 0; + /* release foreground detector */ + virtual void Release() = 0; +}; +inline void cvReleaseFGDetector(CvFGDetector** ppT ) +{ + ppT[0]->Release(); + ppT[0] = 0; +} +/* FOREGROUND DETECTOR INTERFACE */ + +CV_EXPORTS CvFGDetector* cvCreateFGDetectorBase(int type, void *param); + + +/* BLOB STRUCTURE*/ +struct CvBlob +{ + float x,y; /* blob position */ + float w,h; /* blob sizes */ + int ID; /* blbo ID */ +}; + +inline CvBlob cvBlob(float x,float y, float w, float h) +{ + CvBlob B = {x,y,w,h,0}; + return B; +} +#define CV_BLOB_MINW 5 +#define CV_BLOB_MINH 5 +#define CV_BLOB_ID(pB) (((CvBlob*)(pB))->ID) +#define CV_BLOB_CENTER(pB) cvPoint2D32f(((CvBlob*)(pB))->x,((CvBlob*)(pB))->y) +#define CV_BLOB_X(pB) (((CvBlob*)(pB))->x) +#define CV_BLOB_Y(pB) (((CvBlob*)(pB))->y) +#define CV_BLOB_WX(pB) (((CvBlob*)(pB))->w) +#define CV_BLOB_WY(pB) (((CvBlob*)(pB))->h) +#define CV_BLOB_RX(pB) (0.5f*CV_BLOB_WX(pB)) +#define CV_BLOB_RY(pB) (0.5f*CV_BLOB_WY(pB)) +#define CV_BLOB_RECT(pB) cvRect(cvRound(((CvBlob*)(pB))->x-CV_BLOB_RX(pB)),cvRound(((CvBlob*)(pB))->y-CV_BLOB_RY(pB)),cvRound(CV_BLOB_WX(pB)),cvRound(CV_BLOB_WY(pB))) +/* END BLOB STRUCTURE*/ + + +/* simple BLOBLIST */ +class CV_EXPORTS CvBlobSeq +{ +public: + CvBlobSeq(int BlobSize = sizeof(CvBlob)) + { + m_pMem = cvCreateMemStorage(); + m_pSeq = cvCreateSeq(0,sizeof(CvSeq),BlobSize,m_pMem); + strcpy(m_pElemFormat,"ffffi"); + } + virtual ~CvBlobSeq() + { + cvReleaseMemStorage(&m_pMem); + }; + virtual CvBlob* GetBlob(int BlobIndex) + { + return (CvBlob*)cvGetSeqElem(m_pSeq,BlobIndex); + }; + virtual CvBlob* GetBlobByID(int BlobID) + { + int i; + for(i=0;itotal;++i) + if(BlobID == CV_BLOB_ID(GetBlob(i))) + return GetBlob(i); + return NULL; + }; + virtual void DelBlob(int BlobIndex) + { + cvSeqRemove(m_pSeq,BlobIndex); + }; + virtual void DelBlobByID(int BlobID) + { + int i; + for(i=0;itotal;++i) + { + if(BlobID == CV_BLOB_ID(GetBlob(i))) + { + DelBlob(i); + return; + } + } + }; + virtual void Clear() + { + cvClearSeq(m_pSeq); + }; + virtual void AddBlob(CvBlob* pB) + { + cvSeqPush(m_pSeq,pB); + }; + virtual int GetBlobNum() + { + return m_pSeq->total; + }; + virtual void Write(CvFileStorage* fs, char* name) + { + char* attr[] = {"dt",m_pElemFormat,NULL}; + if(fs) + { + cvWrite(fs,name,m_pSeq,cvAttrList((const char**)attr,NULL)); + } + } + virtual void Load(CvFileStorage* fs, CvFileNode* node) + { + if(fs==NULL) return; + CvSeq* pSeq = (CvSeq*)cvRead(fs, node); + if(pSeq) + { + int i; + cvClearSeq(m_pSeq); + for(i=0;itotal;++i) + { + void* pB = cvGetSeqElem( pSeq, i ); + cvSeqPush( m_pSeq, pB ); + } + } + } + void AddFormat(char* str){strcat(m_pElemFormat,str);} +protected: + CvMemStorage* m_pMem; + CvSeq* m_pSeq; + char m_pElemFormat[1024]; +}; +/* simple BLOBLIST */ + + +/* simple TRACKLIST */ +struct CvBlobTrack +{ + int TrackID; + int StartFrame; + CvBlobSeq* pBlobSeq; +}; + +class CV_EXPORTS CvBlobTrackSeq +{ +public: + CvBlobTrackSeq(int TrackSize = sizeof(CvBlobTrack)) + { + m_pMem = cvCreateMemStorage(); + m_pSeq = cvCreateSeq(0,sizeof(CvSeq),TrackSize,m_pMem); + } + virtual ~CvBlobTrackSeq() + { + Clear(); + cvReleaseMemStorage(&m_pMem); + }; + virtual CvBlobTrack* GetBlobTrack(int TrackIndex) + { + return (CvBlobTrack*)cvGetSeqElem(m_pSeq,TrackIndex); + }; + virtual CvBlobTrack* GetBlobTrackByID(int TrackID) + { + int i; + for(i=0;itotal;++i) + { + CvBlobTrack* pP = GetBlobTrack(i); + if(pP && pP->TrackID == TrackID) + return pP; + } + return NULL; + }; + virtual void DelBlobTrack(int TrackIndex) + { + CvBlobTrack* pP = GetBlobTrack(TrackIndex); + if(pP && pP->pBlobSeq) delete pP->pBlobSeq; + cvSeqRemove(m_pSeq,TrackIndex); + }; + virtual void DelBlobTrackByID(int TrackID) + { + int i; + for(i=0;itotal;++i) + { + CvBlobTrack* pP = GetBlobTrack(i); + if(TrackID == pP->TrackID) + { + DelBlobTrack(i); + return; + } + } + }; + virtual void Clear() + { + int i; + for(i=GetBlobTrackNum();i>0;i--) + { + DelBlobTrack(i-1); + } + cvClearSeq(m_pSeq); + }; + virtual void AddBlobTrack(int TrackID, int StartFrame = 0) + { + CvBlobTrack N; + N.TrackID = TrackID; + N.StartFrame = StartFrame; + N.pBlobSeq = new CvBlobSeq; + cvSeqPush(m_pSeq,&N); + }; + virtual int GetBlobTrackNum() + { + return m_pSeq->total; + }; +protected: + CvMemStorage* m_pMem; + CvSeq* m_pSeq; +}; + +/* simple TRACKLIST */ + + +/* BLOB DETECTOR INTERFACE */ +class CV_EXPORTS CvBlobDetector: public CvVSModule +{ +public: + /* try to detect new blob entrance based on foreground mask */ + /* pFGMask - image of foreground mask */ + /* pNewBlob - pointer to CvBlob structure which will bew filled if new blob entrance detected */ + /* pOldBlobList - pointer to blob list which already exist on image */ + virtual int DetectNewBlob(IplImage* pImg, IplImage* pImgFG, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList) = 0; + /* release blob detector */ + virtual void Release()=0; +}; +/* release any blob detector*/ +inline void cvReleaseBlobDetector(CvBlobDetector** ppBD) +{ + ppBD[0]->Release(); + ppBD[0] = NULL; +} +/* END BLOB DETECTOR INTERFACE */ + +/* declaration of constructors of implemented modules */ +CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorSimple(); +CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorCC(); + + +struct CV_EXPORTS CvDetectedBlob : public CvBlob +{ + float response; +}; + +CV_INLINE CvDetectedBlob cvDetectedBlob( float x, float y, float w, float h, int ID = 0, float response = 0.0F ) +{ + CvDetectedBlob b; + b.x = x; b.y = y; b.w = w; b.h = h; b.ID = ID; b.response = response; + return b; +} + + +class CV_EXPORTS CvObjectDetector +{ +public: + CvObjectDetector( const char* /*detector_file_name*/ = 0 ) {}; + + ~CvObjectDetector() {}; + + /* + * Releases the current detector and loads new detector from file + * (if detector_file_name is not 0) + * Returns true on success + */ + bool Load( const char* /*detector_file_name*/ = 0 ) { return false; } + + /* Returns min detector window size */ + CvSize GetMinWindowSize() const { return cvSize(0,0); } + + /* Returns max border */ + int GetMaxBorderSize() const { return 0; } + + /* + * Detects the objects on the image and pushes the detected + * blobs into which must be the sequence of s + */ + void Detect( const CvArr* /*img*/, /* out */ CvBlobSeq* /*detected_blob_seq*/ = 0 ) {}; + +protected: + class CvObjectDetectorImpl* impl; +}; + + +CV_INLINE CvRect cvRectIntersection( const CvRect r1, const CvRect r2 ) +{ + CvRect r = cvRect( MAX(r1.x, r2.x), MAX(r1.y, r2.y), 0, 0 ); + + r.width = MIN(r1.x + r1.width, r2.x + r2.width) - r.x; + r.height = MIN(r1.y + r1.height, r2.y + r2.height) - r.y; + + return r; +} + + +/* + * CvImageDrawer + * + * Draws on an image the specified ROIs from the source image and + * given blobs as ellipses or rectangles + */ + +struct CvDrawShape +{ + enum {RECT, ELLIPSE} shape; + CvScalar color; +}; + +/*extern const CvDrawShape icv_shape[] = +{ + { CvDrawShape::ELLIPSE, CV_RGB(255,0,0) }, + { CvDrawShape::ELLIPSE, CV_RGB(0,255,0) }, + { CvDrawShape::ELLIPSE, CV_RGB(0,0,255) }, + { CvDrawShape::ELLIPSE, CV_RGB(255,255,0) }, + { CvDrawShape::ELLIPSE, CV_RGB(0,255,255) }, + { CvDrawShape::ELLIPSE, CV_RGB(255,0,255) } +};*/ + +class CV_EXPORTS CvImageDrawer +{ +public: + CvImageDrawer() : m_image(0) {} + ~CvImageDrawer() { cvReleaseImage( &m_image ); } + void SetShapes( const CvDrawShape* shapes, int num ); + /* must be the sequence of s */ + IplImage* Draw( const CvArr* src, CvBlobSeq* blob_seq = 0, const CvSeq* roi_seq = 0 ); + IplImage* GetImage() { return m_image; } +protected: + //static const int MAX_SHAPES = sizeof(icv_shape) / sizeof(icv_shape[0]);; + + IplImage* m_image; + CvDrawShape m_shape[16]; +}; + + + +/* Trajectory generation module */ +class CV_EXPORTS CvBlobTrackGen: public CvVSModule +{ +public: + virtual void SetFileName(char* pFileName) = 0; + virtual void AddBlob(CvBlob* pBlob) = 0; + virtual void Process(IplImage* pImg = NULL, IplImage* pFG = NULL) = 0; + virtual void Release() = 0; +}; + +inline void cvReleaseBlobTrackGen(CvBlobTrackGen** pBTGen) +{ + if(*pBTGen)(*pBTGen)->Release(); + *pBTGen = 0; +} + +/* declaration of constructors of implemented modules */ +CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGen1(); +CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGenYML(); + + + +/* BLOB TRACKER INTERFACE */ +class CV_EXPORTS CvBlobTracker: public CvVSModule +{ +public: + CvBlobTracker(){SetTypeName("BlobTracker");}; + /* Add new blob to track it and assign to this blob personal ID */ + /* pBlob - pinter to structure with blob parameters (ID is ignored)*/ + /* pImg - current image */ + /* pImgFG - current foreground mask */ + /* return pointer to new added blob */ + virtual CvBlob* AddBlob(CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG = NULL ) = 0; + /* return number of currently tracked blobs */ + virtual int GetBlobNum() = 0; + /* return pointer to specified by index blob */ + virtual CvBlob* GetBlob(int BlobIndex) = 0; + + /* delete blob by its index */ + virtual void DelBlob(int BlobIndex) = 0; + /* process current image and track all existed blobs */ + virtual void Process(IplImage* pImg, IplImage* pImgFG = NULL) = 0; + /* release blob tracker */ + virtual void Release() = 0; + + + /* Process on blob (for multi hypothesis tracing) */ + virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL) + { + CvBlob* pB; + int ID = 0; + assert(pBlob); + //pBlob->ID; + pB = GetBlob(BlobIndex); + if(pB) + pBlob[0] = pB[0]; + pBlob->ID = ID; + }; + /* get confidence/wieght/probability (0-1) for blob */ + virtual double GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL) + { + return 1; + }; + virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL) + { + int b,bN = pBlobList->GetBlobNum(); + double W = 1; + for(b=0;bGetBlob(b); + int BI = GetBlobIndexByID(pB->ID); + W *= GetConfidence(BI,pB,pImg,pImgFG); + } + return W; + }; + virtual void UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){}; + /* update all blob models */ + virtual void Update(IplImage* pImg, IplImage* pImgFG = NULL) + { + int i; + for(i=GetBlobNum();i>0;i--) + { + CvBlob* pB=GetBlob(i-1); + UpdateBlob(i-1, pB, pImg, pImgFG); + } + + }; + + /* return pinter to blob by its unique ID */ + virtual int GetBlobIndexByID(int BlobID) + { + int i; + for(i=GetBlobNum();i>0;i--) + { + CvBlob* pB=GetBlob(i-1); + if(CV_BLOB_ID(pB) == BlobID) return i-1; + } + return -1; + }; + /* return pinter to blob by its unique ID */ + virtual CvBlob* GetBlobByID(int BlobID){return GetBlob(GetBlobIndexByID(BlobID));}; + /* delete blob by its ID */ + virtual void DelBlobByID(int BlobID){DelBlob(GetBlobIndexByID(BlobID));}; + /* Set new parameters for specified (by index) blob */ + virtual void SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/){}; + /* Set new parameters for specified (by ID) blob */ + virtual void SetBlobByID(int BlobID, CvBlob* pBlob) + { + SetBlob(GetBlobIndexByID(BlobID),pBlob); + }; + + /* =============== MULTI HYPOTHESIS INTERFACE ================== */ + /* return number of position hyposetis of currently tracked blob */ + virtual int GetBlobHypNum(int /*BlobIdx*/){return 1;}; + /* return pointer to specified blob hypothesis by index blob */ + virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/){return GetBlob(BlobIndex);}; + /* Set new parameters for specified (by index) blob hyp (can be called several times for each hyp )*/ + virtual void SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/){}; +}; +inline void cvReleaseBlobTracker(CvBlobTracker**ppT ) +{ + ppT[0]->Release(); + ppT[0] = 0; +} +/* BLOB TRACKER INTERFACE */ + +/*BLOB TRACKER ONE INTERFACE */ +class CV_EXPORTS CvBlobTrackerOne:public CvVSModule +{ +public: + virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL) = 0; + virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL) = 0; + virtual void Release() = 0; + /*not required methods */ + virtual void SkipProcess(CvBlob* /*pBlobPrev*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){}; + virtual void Update(CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){}; + virtual void SetCollision(int /*CollisionFlag*/){}; /* call in case of blob collision situation*/ + virtual double GetConfidence(CvBlob* /*pBlob*/, IplImage* /*pImg*/, + IplImage* /*pImgFG*/ = NULL, IplImage* /*pImgUnusedReg*/ = NULL) + { + return 1; + }; +}; +inline void cvReleaseBlobTrackerOne(CvBlobTrackerOne **ppT ) +{ + ppT[0]->Release(); + ppT[0] = 0; +} +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerList(CvBlobTrackerOne* (*create)()); +/*BLOB TRACKER ONE INTERFACE */ + +/* declaration of constructors of implemented modules */ + +/* some declaration for specific MeanShift tracker */ +#define PROFILE_EPANECHNIKOV 0 +#define PROFILE_DOG 1 +struct CvBlobTrackerParamMS +{ + int noOfSigBits; + int appearance_profile; + int meanshift_profile; + float sigma; +}; + +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1(CvBlobTrackerParamMS* param); +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS2(CvBlobTrackerParamMS* param); +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1ByList(); + +/* some declaration for specific Liklyhood tracker */ +struct CvBlobTrackerParamLH +{ + int HistType; /* see Prob.h */ + int ScaleAfter; +}; + +/* no scale optimization */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHR(CvBlobTrackerParamLH* /*param*/ = NULL); +/* scale optimization */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHRS(CvBlobTrackerParamLH* /*param*/ = NULL); + +/* simple blob tracker based on connected component tracking */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCC(); +/* connected component tracking and MSPF resolver for collision */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCCMSPF(); +/* blob tracker that integrate MS and CC */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFG(); +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFGS(); +/* MS without CC */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS(); +/* particle filtering using bahata... coefficient */ +CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSPF(); + +/* =========== tracker integrators trackers =============*/ +/* integrator based on Partical Filtering method */ +//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPF(); +/* rule based integrator */ +//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIRB(); +/* integrator based on data fusion used particle filtering */ +//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPFDF(); + + + + +/* Trajectory postprocessing module */ +class CV_EXPORTS CvBlobTrackPostProc: public CvVSModule +{ +public: + virtual void AddBlob(CvBlob* pBlob) = 0; + virtual void Process() = 0; + virtual int GetBlobNum() = 0; + virtual CvBlob* GetBlob(int index) = 0; + virtual void Release() = 0; + + /* additional functionality */ + virtual CvBlob* GetBlobByID(int BlobID) + { + int i; + for(i=GetBlobNum();i>0;i--) + { + CvBlob* pB=GetBlob(i-1); + if(pB->ID==BlobID) return pB; + } + return NULL; + }; +}; + +inline void cvReleaseBlobTrackPostProc(CvBlobTrackPostProc** pBTPP) +{ + if(pBTPP == NULL) return; + if(*pBTPP)(*pBTPP)->Release(); + *pBTPP = 0; +} + +/* Trajectory generation module */ +class CV_EXPORTS CvBlobTrackPostProcOne: public CvVSModule +{ +public: + virtual CvBlob* Process(CvBlob* pBlob) = 0; + virtual void Release() = 0; +}; +/* create blob traking post processing module based on simle module */ +CV_EXPORTS CvBlobTrackPostProc* cvCreateBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)()); + + +/* declaration of constructors of implemented modules */ +CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcKalman(); +CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverRect(); +CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverExp(); + + +/* PREDICTORS */ +/* blob PREDICTOR */ +class CvBlobTrackPredictor: public CvVSModule +{ +public: + virtual CvBlob* Predict() = 0; + virtual void Update(CvBlob* pBlob) = 0; + virtual void Release() = 0; +}; +CV_EXPORTS CvBlobTrackPredictor* cvCreateModuleBlobTrackPredictKalman(); + + + +/* Trajectory analyser module */ +class CV_EXPORTS CvBlobTrackAnalysis: public CvVSModule +{ +public: + virtual void AddBlob(CvBlob* pBlob) = 0; + virtual void Process(IplImage* pImg, IplImage* pFG) = 0; + virtual float GetState(int BlobID) = 0; + /* return 0 if trajectory is normal + return >0 if trajectory abnormal */ + virtual char* GetStateDesc(int /*BlobID*/){return NULL;}; + virtual void SetFileName(char* /*DataBaseName*/){}; + virtual void Release() = 0; +}; + + +inline void cvReleaseBlobTrackAnalysis(CvBlobTrackAnalysis** pBTPP) +{ + if(pBTPP == NULL) return; + if(*pBTPP)(*pBTPP)->Release(); + *pBTPP = 0; +} + +/* feature vector generation module */ +class CV_EXPORTS CvBlobTrackFVGen : public CvVSModule +{ +public: + virtual void AddBlob(CvBlob* pBlob) = 0; + virtual void Process(IplImage* pImg, IplImage* pFG) = 0; + virtual void Release() = 0; + virtual int GetFVSize() = 0; + virtual int GetFVNum() = 0; + virtual float* GetFV(int index, int* pFVID) = 0; /* pointer to FV, if return 0 then FV does not created */ + virtual float* GetFVVar(){return NULL;}; /* returned pointer to array of variation of values of FV, if return 0 then FVVar is not exist */ + virtual float* GetFVMin() = 0; /* returned pointer to array of minimal values of FV, if return 0 then FVrange is not exist */ + virtual float* GetFVMax() = 0; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */ +}; + + +/* Trajectory Analyser module */ +class CV_EXPORTS CvBlobTrackAnalysisOne +{ +public: + virtual ~CvBlobTrackAnalysisOne() {}; + virtual int Process(CvBlob* pBlob, IplImage* pImg, IplImage* pFG) = 0; + /* return 0 if trajectory is normal + return >0 if trajectory abnormal */ + virtual void Release() = 0; +}; + +/* create blob traking post processing module based on simle module */ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)()); + +/* declaration of constructors of implemented modules */ +/* based on histogramm analysis of 2D FV (x,y)*/ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistP(); +/* based on histogramm analysis of 4D FV (x,y,vx,vy)*/ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPV(); +/* based on histogramm analysis of 5D FV (x,y,vx,vy,state)*/ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPVS(); +/* based on histogramm analysis of 4D FV (startpos,stoppos)*/ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistSS(); + +/* based on SVM classifier analysis of 2D FV (x,y)*/ +//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMP(); +/* based on SVM classifier analysis of 4D FV (x,y,vx,vy)*/ +//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPV(); +/* based on SVM classifier analysis of 5D FV (x,y,vx,vy,state)*/ +//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPVS(); +/* based on SVM classifier analysis of 4D FV (startpos,stoppos)*/ +//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMSS(); + +/* track analysis based on distance between tracks */ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisTrackDist(); + +/* analizer based on reation Road and height map*/ +//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysis3DRoadMap(); + +/* analizer that make OR desicion using set of analizers */ +CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisIOR(); + +/* estimator of human height */ +class CV_EXPORTS CvBlobTrackAnalysisHeight: public CvBlobTrackAnalysis +{ +public: + virtual double GetHeight(CvBlob* pB) = 0; +}; +//CV_EXPORTS CvBlobTrackAnalysisHeight* cvCreateModuleBlobTrackAnalysisHeightScale(); + + + +/* AUTO BLOB TRACKER INTERFACE - pipeline of 3 modules */ +class CV_EXPORTS CvBlobTrackerAuto: public CvVSModule +{ +public: + virtual void Process(IplImage* pImg, IplImage* pMask = NULL) = 0; + virtual CvBlob* GetBlob(int index) = 0; + virtual CvBlob* GetBlobByID(int ID) = 0; + virtual int GetBlobNum() = 0; + virtual IplImage* GetFGMask(){return NULL;}; + virtual float GetState(int BlobID) = 0; + virtual char* GetStateDesc(int BlobID) = 0; + /* return 0 if trajectory is normal + return >0 if trajectory abnormal */ + virtual void Release() = 0; +}; +inline void cvReleaseBlobTrackerAuto(CvBlobTrackerAuto** ppT) +{ + ppT[0]->Release(); + ppT[0] = 0; +} +/* END AUTO BLOB TRACKER INTERFACE */ + + +/* creation function and data for specific BlobTRackerAuto modules */ +/* parameters of blobtracker auto ver1 */ +struct CvBlobTrackerAutoParam1 +{ + int FGTrainFrames; /* number of frames are needed for FG detector to train */ + CvFGDetector* pFG; /* FGDetector module, if this filed is NULL the Process FG mask is used */ + CvBlobDetector* pBD; /* existed blob detector module + if this filed is NULL default blobdetector module will be created */ + CvBlobTracker* pBT; /* existed blob tracking module + if this filed is NULL default blobtracker module will be created */ + CvBlobTrackGen* pBTGen; /* existed blob trajectory generator, + if this filed is NULL no any generator is used */ + CvBlobTrackPostProc* pBTPP; /* existed blob trajectory postprocessing module + if this filed is NULL no any postprocessing is used */ + int UsePPData; + CvBlobTrackAnalysis* pBTA; /* existed blob trajectory analysis module */ + /* if this filed is NULL no any analysis is made */ +}; + +/* create blob tracker auto ver1 */ +CV_EXPORTS CvBlobTrackerAuto* cvCreateBlobTrackerAuto1(CvBlobTrackerAutoParam1* param = NULL); + +/* simple loader for many auto trackers by its type */ +inline CvBlobTrackerAuto* cvCreateBlobTrackerAuto(int type, void* param) +{ + if(type == 0) return cvCreateBlobTrackerAuto1((CvBlobTrackerAutoParam1*)param); + return 0; +} + + + +struct CvTracksTimePos +{ + int len1,len2; + int beg1,beg2; + int end1,end2; + int comLen; //common length for two tracks + int shift1,shift2; +}; + +/*CV_EXPORTS int cvCompareTracks( CvBlobTrackSeq *groundTruth, + CvBlobTrackSeq *result, + FILE *file);*/ + + +/* Create functions */ + +CV_EXPORTS void cvCreateTracks_One(CvBlobTrackSeq *TS); +CV_EXPORTS void cvCreateTracks_Same(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2); +CV_EXPORTS void cvCreateTracks_AreaErr(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2, int addW, int addH); + + +/* HIST API */ +class CV_EXPORTS CvProb +{ +public: + virtual ~CvProb() {}; + /* calculate probability value */ + virtual double Value(int* /*comp*/, int /*x*/ = 0, int /*y*/ = 0){return -1;}; + /* update histograpp Pnew = (1-W)*Pold + W*Padd*/ + /* W weight of new added prob */ + /* comps - matrix of new fetature vectors used to update prob */ + virtual void AddFeature(float W, int* comps, int x =0, int y = 0) = 0; + virtual void Scale(float factor = 0, int x = -1, int y = -1) = 0; + virtual void Release() = 0; +}; +inline void cvReleaseProb(CvProb** ppProb){ppProb[0]->Release();ppProb[0]=NULL;} +/* HIST API */ + +/* some Prob */ +CV_EXPORTS CvProb* cvCreateProbS(int dim, CvSize size, int sample_num); +CV_EXPORTS CvProb* cvCreateProbMG(int dim, CvSize size, int sample_num); +CV_EXPORTS CvProb* cvCreateProbMG2(int dim, CvSize size, int sample_num); +CV_EXPORTS CvProb* cvCreateProbHist(int dim, CvSize size); + +#define CV_BT_HIST_TYPE_S 0 +#define CV_BT_HIST_TYPE_MG 1 +#define CV_BT_HIST_TYPE_MG2 2 +#define CV_BT_HIST_TYPE_H 3 +inline CvProb* cvCreateProb(int type, int dim, CvSize size = cvSize(1,1), void* /*param*/ = NULL) +{ + if(type == CV_BT_HIST_TYPE_S) return cvCreateProbS(dim, size, -1); + if(type == CV_BT_HIST_TYPE_MG) return cvCreateProbMG(dim, size, -1); + if(type == CV_BT_HIST_TYPE_MG2) return cvCreateProbMG2(dim, size, -1); + if(type == CV_BT_HIST_TYPE_H) return cvCreateProbHist(dim, size); + return NULL; +} + + + +/* noise types defenition */ +#define CV_NOISE_NONE 0 +#define CV_NOISE_GAUSSIAN 1 +#define CV_NOISE_UNIFORM 2 +#define CV_NOISE_SPECKLE 3 +#define CV_NOISE_SALT_AND_PEPPER 4 +/* Add some noise to image */ +/* pImg - (input) image without noise */ +/* pImg - (output) image with noise */ +/* noise_type - type of added noise */ +/* CV_NOISE_GAUSSIAN - pImg += n , n - is gaussian noise with Ampl standart deviation */ +/* CV_NOISE_UNIFORM - pImg += n , n - is uniform noise with Ampl standart deviation */ +/* CV_NOISE_SPECKLE - pImg += n*pImg , n - is gaussian noise with Ampl standart deviation */ +/* CV_NOISE_SALT_AND_PAPPER - pImg = pImg with blacked and whited pixels, + Ampl is density of brocken pixels (0-there are not broken pixels, 1 - all pixels are broken)*/ +/* Ampl - "amplitude" of noise */ +CV_EXPORTS void cvAddNoise(IplImage* pImg, int noise_type, double Ampl, CvRandState* rnd_state = NULL); + +/*================== GENERATOR OF TEST VIDEO SEQUENCE ===================== */ +typedef void CvTestSeq; + +/* pConfigfile - name of file (yml or xml) with description of test sequence */ +/* videos - array of names of test videos described in "pConfigfile" file */ +/* numvideos - size of "videos" array */ +CV_EXPORTS CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float Scale = 1, int noise_type = CV_NOISE_NONE, double noise_ampl = 0); +CV_EXPORTS void cvReleaseTestSeq(CvTestSeq** ppTestSeq); + +/* generete next frame from test video seq and return pointer to it */ +CV_EXPORTS IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq); +/* return pointer to current foreground mask */ +CV_EXPORTS IplImage* cvTestSeqGetFGMask(CvTestSeq* pTestSeq); +/* return pointer to current image */ +CV_EXPORTS IplImage* cvTestSeqGetImage(CvTestSeq* pTestSeq); +/* return frame size of result test video */ +CV_EXPORTS CvSize cvTestSeqGetImageSize(CvTestSeq* pTestSeq); +/* return number of frames result test video */ +CV_EXPORTS int cvTestSeqFrameNum(CvTestSeq* pTestSeq); + +/* return number of existed objects + this is general number of any objects. +for example number of trajectories may be equal or less than returned value*/ +CV_EXPORTS int cvTestSeqGetObjectNum(CvTestSeq* pTestSeq); + +/* return 0 if there is not position for current defined on current frame */ +/* return 1 if there is object position and pPos was filled */ +CV_EXPORTS int cvTestSeqGetObjectPos(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pPos); +CV_EXPORTS int cvTestSeqGetObjectSize(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pSize); + +/* add noise to finile image */ +CV_EXPORTS void cvTestSeqAddNoise(CvTestSeq* pTestSeq, int noise_type = CV_NOISE_NONE, double noise_ampl = 0); +/* add Intensity variation */ +CV_EXPORTS void cvTestSeqAddIntensityVariation(CvTestSeq* pTestSeq, float DI_per_frame, float MinI, float MaxI); +CV_EXPORTS void cvTestSeqSetFrame(CvTestSeq* pTestSeq, int n); + +#endif + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/cxcore.h b/libraries/external/opencv/linux/include/cxcore.h new file mode 100755 index 0000000..adbb041 --- /dev/null +++ b/libraries/external/opencv/linux/include/cxcore.h @@ -0,0 +1,1750 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + + +#ifndef _CXCORE_H_ +#define _CXCORE_H_ + +#ifdef __IPL_H__ +#define HAVE_IPL +#endif + +#ifndef SKIP_INCLUDES + #if defined HAVE_IPL && !defined __IPL_H__ + #ifndef _INC_WINDOWS + #define CV_PRETEND_WINDOWS + #define _INC_WINDOWS + typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER; + typedef int BOOL; + #endif + #if defined WIN32 || defined WIN64 + #include "ipl.h" + #else + #include "ipl/ipl.h" + #endif + #ifdef CV_PRETEND_WINDOWS + #undef _INC_WINDOWS + #endif + #endif +#endif // SKIP_INCLUDES + +#include "cxtypes.h" +#include "cxerror.h" +#include "cvver.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Array allocation, deallocation, initialization and access to elements * +\****************************************************************************************/ + +/* wrapper. + If there is no enough memory, the function + (as well as other OpenCV functions that call cvAlloc) + raises an error. */ +CVAPI(void*) cvAlloc( size_t size ); + +/* wrapper. + Here and further all the memory releasing functions + (that all call cvFree) take double pointer in order to + to clear pointer to the data after releasing it. + Passing pointer to NULL pointer is Ok: nothing happens in this case +*/ +CVAPI(void) cvFree_( void* ptr ); +#define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0) + +/* Allocates and initializes IplImage header */ +CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); + +/* Inializes IplImage header */ +CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth, + int channels, int origin CV_DEFAULT(0), + int align CV_DEFAULT(4)); + +/* Creates IPL image (header and data) */ +CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); + +/* Releases (i.e. deallocates) IPL image header */ +CVAPI(void) cvReleaseImageHeader( IplImage** image ); + +/* Releases IPL image header and data */ +CVAPI(void) cvReleaseImage( IplImage** image ); + +/* Creates a copy of IPL image (widthStep may differ) */ +CVAPI(IplImage*) cvCloneImage( const IplImage* image ); + +/* Sets a Channel Of Interest (only a few functions support COI) - + use cvCopy to extract the selected channel and/or put it back */ +CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); + +/* Retrieves image Channel Of Interest */ +CVAPI(int) cvGetImageCOI( const IplImage* image ); + +/* Sets image ROI (region of interest) (COI is not changed) */ +CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); + +/* Resets image ROI and COI */ +CVAPI(void) cvResetImageROI( IplImage* image ); + +/* Retrieves image ROI */ +CVAPI(CvRect) cvGetImageROI( const IplImage* image ); + +/* Allocates and initalizes CvMat header */ +CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); + +#define CV_AUTOSTEP 0x7fffffff + +/* Initializes CvMat header */ +CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols, + int type, void* data CV_DEFAULT(NULL), + int step CV_DEFAULT(CV_AUTOSTEP) ); + +/* Allocates and initializes CvMat header and allocates data */ +CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); + +/* Releases CvMat header and deallocates matrix data + (reference counting is used for data) */ +CVAPI(void) cvReleaseMat( CvMat** mat ); + +/* Decrements CvMat data reference counter and deallocates the data if + it reaches 0 */ +CV_INLINE void cvDecRefData( CvArr* arr ) +{ + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } +} + +/* Increments CvMat data reference counter */ +CV_INLINE int cvIncRefData( CvArr* arr ) +{ + int refcount = 0; + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + return refcount; +} + + +/* Creates an exact copy of the input matrix (except, may be, step value) */ +CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); + + +/* Makes a new matrix from subrectangle of input array. + No data is copied */ +CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); +#define cvGetSubArr cvGetSubRect + +/* Selects row span of the input array: arr(start_row:delta_row:end_row,:) + (end_row is not included into the span). */ +CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat, + int start_row, int end_row, + int delta_row CV_DEFAULT(1)); + +CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) +{ + return cvGetRows( arr, submat, row, row + 1, 1 ); +} + + +/* Selects column span of the input array: arr(:,start_col:end_col) + (end_col is not included into the span) */ +CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat, + int start_col, int end_col ); + +CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col ) +{ + return cvGetCols( arr, submat, col, col + 1 ); +} + +/* Select a diagonal of the input array. + (diag = 0 means the main diagonal, >0 means a diagonal above the main one, + <0 - below the main one). + The diagonal will be represented as a column (nx1 matrix). */ +CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat, + int diag CV_DEFAULT(0)); + +/* low-level scalar <-> raw data conversion functions */ +CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, + int extend_to_12 CV_DEFAULT(0) ); + +CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); + +/* Allocates and initializes CvMatND header */ +CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); + +/* Allocates and initializes CvMatND header and allocates data */ +CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); + +/* Initializes preallocated CvMatND header */ +CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, + int type, void* data CV_DEFAULT(NULL) ); + +/* Releases CvMatND */ +CV_INLINE void cvReleaseMatND( CvMatND** mat ) +{ + cvReleaseMat( (CvMat**)mat ); +} + +/* Creates a copy of CvMatND (except, may be, steps) */ +CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); + +/* Allocates and initializes CvSparseMat header and allocates data */ +CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); + +/* Releases CvSparseMat */ +CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); + +/* Creates a copy of CvSparseMat (except, may be, zero items) */ +CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); + +/* Initializes sparse array iterator + (returns the first node or NULL if the array is empty) */ +CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, + CvSparseMatIterator* mat_iterator ); + +// returns next sparse array node (or NULL if there is no more nodes) +CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator ) +{ + if( mat_iterator->node->next ) + return mat_iterator->node = mat_iterator->node->next; + else + { + int idx; + for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ ) + { + CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx]; + if( node ) + { + mat_iterator->curidx = idx; + return mat_iterator->node = node; + } + } + return NULL; + } +} + +/**************** matrix iterator: used for n-ary operations on dense arrays *********/ + +#define CV_MAX_ARR 10 + +typedef struct CvNArrayIterator +{ + int count; /* number of arrays */ + int dims; /* number of dimensions to iterate */ + CvSize size; /* maximal common linear size: { width = size, height = 1 } */ + uchar* ptr[CV_MAX_ARR]; /* pointers to the array slices */ + int stack[CV_MAX_DIM]; /* for internal use */ + CvMatND* hdr[CV_MAX_ARR]; /* pointers to the headers of the + matrices that are processed */ +} +CvNArrayIterator; + +#define CV_NO_DEPTH_CHECK 1 +#define CV_NO_CN_CHECK 2 +#define CV_NO_SIZE_CHECK 4 + +/* initializes iterator that traverses through several arrays simulteneously + (the function together with cvNextArraySlice is used for + N-ari element-wise operations) */ +CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs, + const CvArr* mask, CvMatND* stubs, + CvNArrayIterator* array_iterator, + int flags CV_DEFAULT(0) ); + +/* returns zero value if iteration is finished, non-zero (slice length) otherwise */ +CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); + + +/* Returns type of array elements: + CV_8UC1 ... CV_64FC4 ... */ +CVAPI(int) cvGetElemType( const CvArr* arr ); + +/* Retrieves number of an array dimensions and + optionally sizes of the dimensions */ +CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) ); + + +/* Retrieves size of a particular array dimension. + For 2d arrays cvGetDimSize(arr,0) returns number of rows (image height) + and cvGetDimSize(arr,1) returns number of columns (image width) */ +CVAPI(int) cvGetDimSize( const CvArr* arr, int index ); + + +/* ptr = &arr(idx0,idx1,...). All indexes are zero-based, + the major dimensions go first (e.g. (y,x) for 2D, (z,y,x) for 3D */ +CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL)); +CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) ); +CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, + int* type CV_DEFAULT(NULL)); + +/* For CvMat or IplImage number of indices should be 2 + (row index (y) goes first, column index (x) goes next). + For CvMatND or CvSparseMat number of infices should match number of and + indices order should match the array dimension order. */ +CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL), + int create_node CV_DEFAULT(1), + unsigned* precalc_hashval CV_DEFAULT(NULL)); + +/* value = arr(idx0,idx1,...) */ +CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 ); +CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 ); +CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx ); + +/* for 1-channel arrays */ +CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 ); +CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 ); +CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx ); + +/* arr(idx0,idx1,...) = value */ +CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value ); +CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value ); +CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); +CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value ); + +/* for 1-channel arrays */ +CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value ); +CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value ); +CVAPI(void) cvSetReal3D( CvArr* arr, int idx0, + int idx1, int idx2, double value ); +CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value ); + +/* clears element of ND dense array, + in case of sparse arrays it deletes the specified node */ +CVAPI(void) cvClearND( CvArr* arr, const int* idx ); + +/* Converts CvArr (IplImage or CvMat,...) to CvMat. + If the last parameter is non-zero, function can + convert multi(>2)-dimensional array to CvMat as long as + the last array's dimension is continous. The resultant + matrix will be have appropriate (a huge) number of rows */ +CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header, + int* coi CV_DEFAULT(NULL), + int allowND CV_DEFAULT(0)); + +/* Converts CvArr (IplImage or CvMat) to IplImage */ +CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header ); + + +/* Changes a shape of multi-dimensional array. + new_cn == 0 means that number of channels remains unchanged. + new_dims == 0 means that number and sizes of dimensions remain the same + (unless they need to be changed to set the new number of channels) + if new_dims == 1, there is no need to specify new dimension sizes + The resultant configuration should be achievable w/o data copying. + If the resultant array is sparse, CvSparseMat header should be passed + to the function else if the result is 1 or 2 dimensional, + CvMat header should be passed to the function + else CvMatND header should be passed */ +CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr, + int sizeof_header, CvArr* header, + int new_cn, int new_dims, int* new_sizes ); + +#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \ + cvReshapeMatND( (arr), sizeof(*(header)), (header), \ + (new_cn), (new_dims), (new_sizes)) + +CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header, + int new_cn, int new_rows CV_DEFAULT(0) ); + +/* Repeats source 2d array several times in both horizontal and + vertical direction to fill destination array */ +CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst ); + +/* Allocates array data */ +CVAPI(void) cvCreateData( CvArr* arr ); + +/* Releases array data */ +CVAPI(void) cvReleaseData( CvArr* arr ); + +/* Attaches user data to the array header. The step is reffered to + the pre-last dimension. That is, all the planes of the array + must be joint (w/o gaps) */ +CVAPI(void) cvSetData( CvArr* arr, void* data, int step ); + +/* Retrieves raw data of CvMat, IplImage or CvMatND. + In the latter case the function raises an error if + the array can not be represented as a matrix */ +CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data, + int* step CV_DEFAULT(NULL), + CvSize* roi_size CV_DEFAULT(NULL)); + +/* Returns width and height of array in elements */ +CVAPI(CvSize) cvGetSize( const CvArr* arr ); + +/* Copies source array to destination array */ +CVAPI(void) cvCopy( const CvArr* src, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL) ); + +/* Sets all or "masked" elements of input array + to the same value*/ +CVAPI(void) cvSet( CvArr* arr, CvScalar value, + const CvArr* mask CV_DEFAULT(NULL) ); + +/* Clears all the array elements (sets them to 0) */ +CVAPI(void) cvSetZero( CvArr* arr ); +#define cvZero cvSetZero + + +/* Splits a multi-channel array into the set of single-channel arrays or + extracts particular [color] plane */ +CVAPI(void) cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1, + CvArr* dst2, CvArr* dst3 ); + +/* Merges a set of single-channel arrays into the single multi-channel array + or inserts one particular [color] plane to the array */ +CVAPI(void) cvMerge( const CvArr* src0, const CvArr* src1, + const CvArr* src2, const CvArr* src3, + CvArr* dst ); + +/* Copies several channels from input arrays to + certain channels of output arrays */ +CVAPI(void) cvMixChannels( const CvArr** src, int src_count, + CvArr** dst, int dst_count, + const int* from_to, int pair_count ); + +/* Performs linear transformation on every source array element: + dst(x,y,c) = scale*src(x,y,c)+shift. + Arbitrary combination of input and output array depths are allowed + (number of channels must be the same), thus the function can be used + for type conversion */ +CVAPI(void) cvConvertScale( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScale cvConvertScale +#define cvScale cvConvertScale +#define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 ) + + +/* Performs linear transformation on every source array element, + stores absolute value of the result: + dst(x,y,c) = abs(scale*src(x,y,c)+shift). + destination array must have 8u type. + In other cases one may use cvConvertScale + cvAbsDiffS */ +CVAPI(void) cvConvertScaleAbs( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScaleAbs cvConvertScaleAbs + + +/* checks termination criteria validity and + sets eps to default_eps (if it is not set), + max_iter to default_max_iters (if it is not set) +*/ +CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria, + double default_eps, + int default_max_iters ); + +/****************************************************************************************\ +* Arithmetic, logic and comparison operations * +\****************************************************************************************/ + +/* dst(mask) = src1(mask) + src2(mask) */ +CVAPI(void) cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(mask) = src(mask) + value */ +CVAPI(void) cvAddS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(mask) = src1(mask) - src2(mask) */ +CVAPI(void) cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(mask) = src(mask) - value = src(mask) + (-value) */ +CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)) +{ + cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]), + dst, mask ); +} + +/* dst(mask) = value - src(mask) */ +CVAPI(void) cvSubRS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src1(idx) * src2(idx) * scale + (scaled element-wise multiplication of 2 arrays) */ +CVAPI(void) cvMul( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1) ); + +/* element-wise division/inversion with scaling: + dst(idx) = src1(idx) * scale / src2(idx) + or dst(idx) = scale / src2(idx) if src1 == 0 */ +CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1)); + +/* dst = src1 * scale + src2 */ +CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale, + const CvArr* src2, CvArr* dst ); +#define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C) + +/* dst = src1 * alpha + src2 * beta + gamma */ +CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha, + const CvArr* src2, double beta, + double gamma, CvArr* dst ); + +/* result = sum_i(src1(i) * src2(i)) (results for all channels are accumulated together) */ +CVAPI(double) cvDotProduct( const CvArr* src1, const CvArr* src2 ); + +/* dst(idx) = src1(idx) & src2(idx) */ +CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src(idx) & value */ +CVAPI(void) cvAndS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src1(idx) | src2(idx) */ +CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src(idx) | value */ +CVAPI(void) cvOrS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src1(idx) ^ src2(idx) */ +CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = src(idx) ^ value */ +CVAPI(void) cvXorS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/* dst(idx) = ~src(idx) */ +CVAPI(void) cvNot( const CvArr* src, CvArr* dst ); + +/* dst(idx) = lower(idx) <= src(idx) < upper(idx) */ +CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower, + const CvArr* upper, CvArr* dst ); + +/* dst(idx) = lower <= src(idx) < upper */ +CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower, + CvScalar upper, CvArr* dst ); + +#define CV_CMP_EQ 0 +#define CV_CMP_GT 1 +#define CV_CMP_GE 2 +#define CV_CMP_LT 3 +#define CV_CMP_LE 4 +#define CV_CMP_NE 5 + +/* The comparison operation support single-channel arrays only. + Destination image should be 8uC1 or 8sC1 */ + +/* dst(idx) = src1(idx) _cmp_op_ src2(idx) */ +CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op ); + +/* dst(idx) = src1(idx) _cmp_op_ value */ +CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op ); + +/* dst(idx) = min(src1(idx),src2(idx)) */ +CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* dst(idx) = max(src1(idx),src2(idx)) */ +CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* dst(idx) = min(src(idx),value) */ +CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst ); + +/* dst(idx) = max(src(idx),value) */ +CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst ); + +/* dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */ +CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* dst(x,y,c) = abs(src(x,y,c) - value(c)) */ +CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); +#define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0)) + +/****************************************************************************************\ +* Math operations * +\****************************************************************************************/ + +/* Does cartesian->polar coordinates conversion. + Either of output components (magnitude or angle) is optional */ +CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y, + CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL), + int angle_in_degrees CV_DEFAULT(0)); + +/* Does polar->cartesian coordinates conversion. + Either of output components (magnitude or angle) is optional. + If magnitude is missing it is assumed to be all 1's */ +CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle, + CvArr* x, CvArr* y, + int angle_in_degrees CV_DEFAULT(0)); + +/* Does powering: dst(idx) = src(idx)^power */ +CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power ); + +/* Does exponention: dst(idx) = exp(src(idx)). + Overflow is not handled yet. Underflow is handled. + Maximal relative error is ~7e-6 for single-precision input */ +CVAPI(void) cvExp( const CvArr* src, CvArr* dst ); + +/* Calculates natural logarithms: dst(idx) = log(abs(src(idx))). + Logarithm of 0 gives large negative number(~-700) + Maximal relative error is ~3e-7 for single-precision output +*/ +CVAPI(void) cvLog( const CvArr* src, CvArr* dst ); + +/* Fast arctangent calculation */ +CVAPI(float) cvFastArctan( float y, float x ); + +/* Fast cubic root calculation */ +CVAPI(float) cvCbrt( float value ); + +/* Checks array values for NaNs, Infs or simply for too large numbers + (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set, + no runtime errors is raised (function returns zero value in case of "bad" values). + Otherwise cvError is called */ +#define CV_CHECK_RANGE 1 +#define CV_CHECK_QUIET 2 +CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), + double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0)); +#define cvCheckArray cvCheckArr + +#define CV_RAND_UNI 0 +#define CV_RAND_NORMAL 1 +CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, + CvScalar param1, CvScalar param2 ); + +CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, + double iter_factor CV_DEFAULT(1.)); + +/* Finds real roots of a cubic equation */ +CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots ); + +/****************************************************************************************\ +* Matrix operations * +\****************************************************************************************/ + +/* Calculates cross product of two 3d vectors */ +CVAPI(void) cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/* Matrix transform: dst = A*B + C, C is optional */ +#define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 ) +#define cvMatMul( src1, src2, dst ) cvMatMulAdd( (src1), (src2), NULL, (dst)) + +#define CV_GEMM_A_T 1 +#define CV_GEMM_B_T 2 +#define CV_GEMM_C_T 4 +/* Extended matrix transform: + dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */ +CVAPI(void) cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, + const CvArr* src3, double beta, CvArr* dst, + int tABC CV_DEFAULT(0)); +#define cvMatMulAddEx cvGEMM + +/* Transforms each element of source array and stores + resultant vectors in destination array */ +CVAPI(void) cvTransform( const CvArr* src, CvArr* dst, + const CvMat* transmat, + const CvMat* shiftvec CV_DEFAULT(NULL)); +#define cvMatMulAddS cvTransform + +/* Does perspective transform on every element of input array */ +CVAPI(void) cvPerspectiveTransform( const CvArr* src, CvArr* dst, + const CvMat* mat ); + +/* Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */ +CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order, + const CvArr* delta CV_DEFAULT(NULL), + double scale CV_DEFAULT(1.) ); + +/* Tranposes matrix. Square matrices can be transposed in-place */ +CVAPI(void) cvTranspose( const CvArr* src, CvArr* dst ); +#define cvT cvTranspose + + +/* Mirror array data around horizontal (flip=0), + vertical (flip=1) or both(flip=-1) axises: + cvFlip(src) flips images vertically and sequences horizontally (inplace) */ +CVAPI(void) cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), + int flip_mode CV_DEFAULT(0)); +#define cvMirror cvFlip + + +#define CV_SVD_MODIFY_A 1 +#define CV_SVD_U_T 2 +#define CV_SVD_V_T 4 + +/* Performs Singular Value Decomposition of a matrix */ +CVAPI(void) cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL), + CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0)); + +/* Performs Singular Value Back Substitution (solves A*X = B): + flags must be the same as in cvSVD */ +CVAPI(void) cvSVBkSb( const CvArr* W, const CvArr* U, + const CvArr* V, const CvArr* B, + CvArr* X, int flags ); + +#define CV_LU 0 +#define CV_SVD 1 +#define CV_SVD_SYM 2 +/* Inverts matrix */ +CVAPI(double) cvInvert( const CvArr* src, CvArr* dst, + int method CV_DEFAULT(CV_LU)); +#define cvInv cvInvert + +/* Solves linear system (src1)*(dst) = (src2) + (returns 0 if src1 is a singular and CV_LU method is used) */ +CVAPI(int) cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst, + int method CV_DEFAULT(CV_LU)); + +/* Calculates determinant of input matrix */ +CVAPI(double) cvDet( const CvArr* mat ); + +/* Calculates trace of the matrix (sum of elements on the main diagonal) */ +CVAPI(CvScalar) cvTrace( const CvArr* mat ); + +/* Finds eigen values and vectors of a symmetric matrix */ +CVAPI(void) cvEigenVV( CvArr* mat, CvArr* evects, + CvArr* evals, double eps CV_DEFAULT(0)); + +/* Makes an identity matrix (mat_ij = i == j) */ +CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) ); + +/* Fills matrix with given range of numbers */ +CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end ); + +/* Calculates covariation matrix for a set of vectors */ +/* transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */ +#define CV_COVAR_SCRAMBLED 0 + +/* [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */ +#define CV_COVAR_NORMAL 1 + +/* do not calc average (i.e. mean vector) - use the input vector instead + (useful for calculating covariance matrix by parts) */ +#define CV_COVAR_USE_AVG 2 + +/* scale the covariance matrix coefficients by number of the vectors */ +#define CV_COVAR_SCALE 4 + +/* all the input vectors are stored in a single matrix, as its rows */ +#define CV_COVAR_ROWS 8 + +/* all the input vectors are stored in a single matrix, as its columns */ +#define CV_COVAR_COLS 16 + +CVAPI(void) cvCalcCovarMatrix( const CvArr** vects, int count, + CvArr* cov_mat, CvArr* avg, int flags ); + +#define CV_PCA_DATA_AS_ROW 0 +#define CV_PCA_DATA_AS_COL 1 +#define CV_PCA_USE_AVG 2 +CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean, + CvArr* eigenvals, CvArr* eigenvects, int flags ); + +CVAPI(void) cvProjectPCA( const CvArr* data, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +CVAPI(void) cvBackProjectPCA( const CvArr* proj, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +/* Calculates Mahalanobis(weighted) distance */ +CVAPI(double) cvMahalanobis( const CvArr* vec1, const CvArr* vec2, CvArr* mat ); +#define cvMahalonobis cvMahalanobis + +/****************************************************************************************\ +* Array Statistics * +\****************************************************************************************/ + +/* Finds sum of array elements */ +CVAPI(CvScalar) cvSum( const CvArr* arr ); + +/* Calculates number of non-zero pixels */ +CVAPI(int) cvCountNonZero( const CvArr* arr ); + +/* Calculates mean value of array elements */ +CVAPI(CvScalar) cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) ); + +/* Calculates mean and standard deviation of pixel values */ +CVAPI(void) cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev, + const CvArr* mask CV_DEFAULT(NULL) ); + +/* Finds global minimum, maximum and their positions */ +CVAPI(void) cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val, + CvPoint* min_loc CV_DEFAULT(NULL), + CvPoint* max_loc CV_DEFAULT(NULL), + const CvArr* mask CV_DEFAULT(NULL) ); + +/* types of array norm */ +#define CV_C 1 +#define CV_L1 2 +#define CV_L2 4 +#define CV_NORM_MASK 7 +#define CV_RELATIVE 8 +#define CV_DIFF 16 +#define CV_MINMAX 32 + +#define CV_DIFF_C (CV_DIFF | CV_C) +#define CV_DIFF_L1 (CV_DIFF | CV_L1) +#define CV_DIFF_L2 (CV_DIFF | CV_L2) +#define CV_RELATIVE_C (CV_RELATIVE | CV_C) +#define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1) +#define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2) + +/* Finds norm, difference norm or relative difference norm for an array (or two arrays) */ +CVAPI(double) cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + +CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst, + double a CV_DEFAULT(1.), double b CV_DEFAULT(0.), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + + +#define CV_REDUCE_SUM 0 +#define CV_REDUCE_AVG 1 +#define CV_REDUCE_MAX 2 +#define CV_REDUCE_MIN 3 + +CVAPI(void) cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1), + int op CV_DEFAULT(CV_REDUCE_SUM) ); + +/****************************************************************************************\ +* Discrete Linear Transforms and Related Functions * +\****************************************************************************************/ + +#define CV_DXT_FORWARD 0 +#define CV_DXT_INVERSE 1 +#define CV_DXT_SCALE 2 /* divide result by size of array */ +#define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE) +#define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE +#define CV_DXT_ROWS 4 /* transform each row individually */ +#define CV_DXT_MUL_CONJ 8 /* conjugate the second argument of cvMulSpectrums */ + +/* Discrete Fourier Transform: + complex->complex, + real->ccs (forward), + ccs->real (inverse) */ +CVAPI(void) cvDFT( const CvArr* src, CvArr* dst, int flags, + int nonzero_rows CV_DEFAULT(0) ); +#define cvFFT cvDFT + +/* Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) */ +CVAPI(void) cvMulSpectrums( const CvArr* src1, const CvArr* src2, + CvArr* dst, int flags ); + +/* Finds optimal DFT vector size >= size0 */ +CVAPI(int) cvGetOptimalDFTSize( int size0 ); + +/* Discrete Cosine Transform */ +CVAPI(void) cvDCT( const CvArr* src, CvArr* dst, int flags ); + +/****************************************************************************************\ +* Dynamic data structures * +\****************************************************************************************/ + +/* Calculates length of sequence slice (with support of negative indices). */ +CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq ); + + +/* Creates new memory storage. + block_size == 0 means that default, + somewhat optimal size, is used (currently, it is 64K) */ +CVAPI(CvMemStorage*) cvCreateMemStorage( int block_size CV_DEFAULT(0)); + + +/* Creates a memory storage that will borrow memory blocks from parent storage */ +CVAPI(CvMemStorage*) cvCreateChildMemStorage( CvMemStorage* parent ); + + +/* Releases memory storage. All the children of a parent must be released before + the parent. A child storage returns all the blocks to parent when it is released */ +CVAPI(void) cvReleaseMemStorage( CvMemStorage** storage ); + + +/* Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) + to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... + do not free any memory. + A child storage returns all the blocks to the parent when it is cleared */ +CVAPI(void) cvClearMemStorage( CvMemStorage* storage ); + +/* Remember a storage "free memory" position */ +CVAPI(void) cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos ); + +/* Restore a storage "free memory" position */ +CVAPI(void) cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos ); + +/* Allocates continuous buffer of the specified size in the storage */ +CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); + +/* Allocates string in memory storage */ +CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, + int len CV_DEFAULT(-1) ); + +/* Creates new empty sequence that will reside in the specified storage */ +CVAPI(CvSeq*) cvCreateSeq( int seq_flags, int header_size, + int elem_size, CvMemStorage* storage ); + +/* Changes default size (granularity) of sequence blocks. + The default size is ~1Kbyte */ +CVAPI(void) cvSetSeqBlockSize( CvSeq* seq, int delta_elems ); + + +/* Adds new element to the end of sequence. Returns pointer to the element */ +CVAPI(char*) cvSeqPush( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/* Adds new element to the beginning of sequence. Returns pointer to it */ +CVAPI(char*) cvSeqPushFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/* Removes the last element from sequence and optionally saves it */ +CVAPI(void) cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/* Removes the first element from sequence and optioanally saves it */ +CVAPI(void) cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +#define CV_FRONT 1 +#define CV_BACK 0 +/* Adds several new elements to the end of sequence */ +CVAPI(void) cvSeqPushMulti( CvSeq* seq, void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/* Removes several elements from the end of sequence and optionally saves them */ +CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/* Inserts a new element in the middle of sequence. + cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */ +CVAPI(char*) cvSeqInsert( CvSeq* seq, int before_index, + void* element CV_DEFAULT(NULL)); + +/* Removes specified sequence element */ +CVAPI(void) cvSeqRemove( CvSeq* seq, int index ); + + +/* Removes all the elements from the sequence. The freed memory + can be reused later only by the same sequence unless cvClearMemStorage + or cvRestoreMemStoragePos is called */ +CVAPI(void) cvClearSeq( CvSeq* seq ); + + +/* Retrives pointer to specified sequence element. + Negative indices are supported and mean counting from the end + (e.g -1 means the last sequence element) */ +CVAPI(char*) cvGetSeqElem( const CvSeq* seq, int index ); + +/* Calculates index of the specified sequence element. + Returns -1 if element does not belong to the sequence */ +CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element, + CvSeqBlock** block CV_DEFAULT(NULL) ); + +/* Initializes sequence writer. The new elements will be added to the end of sequence */ +CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer ); + + +/* Combination of cvCreateSeq and cvStartAppendToSeq */ +CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size, + int elem_size, CvMemStorage* storage, + CvSeqWriter* writer ); + +/* Closes sequence writer, updates sequence header and returns pointer + to the resultant sequence + (which may be useful if the sequence was created using cvStartWriteSeq)) +*/ +CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer ); + + +/* Updates sequence header. May be useful to get access to some of previously + written elements via cvGetSeqElem or sequence reader */ +CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer ); + + +/* Initializes sequence reader. + The sequence can be read in forward or backward direction */ +CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, + int reverse CV_DEFAULT(0) ); + + +/* Returns current sequence reader position (currently observed sequence element) */ +CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader ); + + +/* Changes sequence reader position. It may seek to an absolute or + to relative to the current position */ +CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index, + int is_relative CV_DEFAULT(0)); + +/* Copies sequence content to a continuous piece of memory */ +CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) ); + +/* Creates sequence header for array. + After that all the operations on sequences that do not alter the content + can be applied to the resultant sequence */ +CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size, + int elem_size, void* elements, int total, + CvSeq* seq, CvSeqBlock* block ); + +/* Extracts sequence slice (with or without copying sequence elements) */ +CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice, + CvMemStorage* storage CV_DEFAULT(NULL), + int copy_data CV_DEFAULT(0)); + +CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL)) +{ + return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 ); +} + +/* Removes sequence slice */ +CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ); + +/* Inserts a sequence or array into another sequence */ +CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); + +/* a < b ? -1 : a > b ? 1 : 0 */ +typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata ); + +/* Sorts sequence in-place given element comparison function */ +CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) ); + +/* Finds element in a [sorted] sequence */ +CVAPI(char*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func, + int is_sorted, int* elem_idx, + void* userdata CV_DEFAULT(NULL) ); + +/* Reverses order of sequence elements in-place */ +CVAPI(void) cvSeqInvert( CvSeq* seq ); + +/* Splits sequence into one or more equivalence classes using the specified criteria */ +CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, + CvSeq** labels, CvCmpFunc is_equal, void* userdata ); + +/************ Internal sequence functions ************/ +CVAPI(void) cvChangeSeqBlock( void* reader, int direction ); +CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer ); + + +/* Creates a new set */ +CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size, + int elem_size, CvMemStorage* storage ); + +/* Adds new element to the set and returns pointer to it */ +CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL), + CvSetElem** inserted_elem CV_DEFAULT(NULL) ); + +/* Fast variant of cvSetAdd */ +CV_INLINE CvSetElem* cvSetNew( CvSet* set_header ) +{ + CvSetElem* elem = set_header->free_elems; + if( elem ) + { + set_header->free_elems = elem->next_free; + elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK; + set_header->active_count++; + } + else + cvSetAdd( set_header, NULL, (CvSetElem**)&elem ); + return elem; +} + +/* Removes set element given its pointer */ +CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem ) +{ + CvSetElem* _elem = (CvSetElem*)elem; + assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ ); + _elem->next_free = set_header->free_elems; + _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG; + set_header->free_elems = _elem; + set_header->active_count--; +} + +/* Removes element from the set by its index */ +CVAPI(void) cvSetRemove( CvSet* set_header, int index ); + +/* Returns a set element by index. If the element doesn't belong to the set, + NULL is returned */ +CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int index ) +{ + CvSetElem* elem = (CvSetElem*)cvGetSeqElem( (CvSeq*)set_header, index ); + return elem && CV_IS_SET_ELEM( elem ) ? elem : 0; +} + +/* Removes all the elements from the set */ +CVAPI(void) cvClearSet( CvSet* set_header ); + +/* Creates new graph */ +CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size, + int vtx_size, int edge_size, + CvMemStorage* storage ); + +/* Adds new vertex to the graph */ +CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL), + CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) ); + + +/* Removes vertex from the graph together with all incident edges */ +CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index ); +CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx ); + + +/* Link two vertices specifed by indices or pointers if they + are not connected or return pointer to already existing edge + connecting the vertices. + Functions return 1 if a new edge was created, 0 otherwise */ +CVAPI(int) cvGraphAddEdge( CvGraph* graph, + int start_idx, int end_idx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph, + CvGraphVtx* start_vtx, CvGraphVtx* end_vtx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +/* Remove edge connecting two vertices */ +CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx ); +CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, + CvGraphVtx* end_vtx ); + +/* Find edge connecting two vertices */ +CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx ); +CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph, + const CvGraphVtx* start_vtx, + const CvGraphVtx* end_vtx ); +#define cvGraphFindEdge cvFindGraphEdge +#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr + +/* Remove all vertices and edges from the graph */ +CVAPI(void) cvClearGraph( CvGraph* graph ); + + +/* Count number of edges incident to the vertex */ +CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx ); +CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx ); + + +/* Retrieves graph vertex by given index */ +#define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx)) + +/* Retrieves index of a graph vertex given its pointer */ +#define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK) + +/* Retrieves index of a graph edge given its pointer */ +#define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK) + +#define cvGraphGetVtxCount( graph ) ((graph)->active_count) +#define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count) + +#define CV_GRAPH_VERTEX 1 +#define CV_GRAPH_TREE_EDGE 2 +#define CV_GRAPH_BACK_EDGE 4 +#define CV_GRAPH_FORWARD_EDGE 8 +#define CV_GRAPH_CROSS_EDGE 16 +#define CV_GRAPH_ANY_EDGE 30 +#define CV_GRAPH_NEW_TREE 32 +#define CV_GRAPH_BACKTRACKING 64 +#define CV_GRAPH_OVER -1 + +#define CV_GRAPH_ALL_ITEMS -1 + +/* flags for graph vertices and edges */ +#define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30) +#define CV_IS_GRAPH_VERTEX_VISITED(vtx) \ + (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_IS_GRAPH_EDGE_VISITED(edge) \ + (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29) +#define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28) + +typedef struct CvGraphScanner +{ + CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */ + CvGraphVtx* dst; /* current graph edge destination vertex */ + CvGraphEdge* edge; /* current edge */ + + CvGraph* graph; /* the graph */ + CvSeq* stack; /* the graph vertex stack */ + int index; /* the lower bound of certainly visited vertices */ + int mask; /* event mask */ +} +CvGraphScanner; + +/* Creates new graph scanner. */ +CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph, + CvGraphVtx* vtx CV_DEFAULT(NULL), + int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)); + +/* Releases graph scanner. */ +CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner ); + +/* Get next graph element */ +CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner ); + +/* Creates a copy of graph */ +CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ); + +/****************************************************************************************\ +* Drawing * +\****************************************************************************************/ + +/****************************************************************************************\ +* Drawing functions work with images/matrices of arbitrary type. * +* For color images the channel order is BGR[A] * +* Antialiasing is supported only for 8-bit image now. * +* All the functions include parameter color that means rgb value (that may be * +* constructed with CV_RGB macro) for color images and brightness * +* for grayscale images. * +* If a drawn figure is partially or completely outside of the image, it is clipped.* +\****************************************************************************************/ + +#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 ) +#define CV_FILLED -1 + +#define CV_AA 16 + +/* Draws 4-connected, 8-connected or antialiased line segment connecting two points */ +CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/* Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2), + if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn */ +CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + int shift CV_DEFAULT(0)); + +/* Draws a circle with specified center and radius. + Thickness works in the same way as with cvRectangle */ +CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/* Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector, + depending on , and parameters. The resultant figure + is rotated by . All the angles are in degrees */ +CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, + double angle, double start_angle, double end_angle, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color, + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ) +{ + CvSize axes; + axes.width = cvRound(box.size.height*0.5); + axes.height = cvRound(box.size.width*0.5); + + cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle, + 0, 360, color, thickness, line_type, shift ); +} + +/* Fills convex or monotonous polygon. */ +CVAPI(void) cvFillConvexPoly( CvArr* img, CvPoint* pts, int npts, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/* Fills an area bounded by one or more arbitrary polygons */ +CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, int* npts, int contours, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/* Draws one or more polygonal curves */ +CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours, + int is_closed, CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +#define cvDrawRect cvRectangle +#define cvDrawLine cvLine +#define cvDrawCircle cvCircle +#define cvDrawEllipse cvEllipse +#define cvDrawPolyLine cvPolyLine + +/* Clips the line segment connecting *pt1 and *pt2 + by the rectangular window + (0<=xptr will point + to pt1 (or pt2, see left_to_right description) location in the image. + Returns the number of pixels on the line between the ending points. */ +CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2, + CvLineIterator* line_iterator, + int connectivity CV_DEFAULT(8), + int left_to_right CV_DEFAULT(0)); + +/* Moves iterator to the next line point */ +#define CV_NEXT_LINE_POINT( line_iterator ) \ +{ \ + int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \ + (line_iterator).err += (line_iterator).minus_delta + \ + ((line_iterator).plus_delta & _line_iterator_mask); \ + (line_iterator).ptr += (line_iterator).minus_step + \ + ((line_iterator).plus_step & _line_iterator_mask); \ +} + + +/* basic font types */ +#define CV_FONT_HERSHEY_SIMPLEX 0 +#define CV_FONT_HERSHEY_PLAIN 1 +#define CV_FONT_HERSHEY_DUPLEX 2 +#define CV_FONT_HERSHEY_COMPLEX 3 +#define CV_FONT_HERSHEY_TRIPLEX 4 +#define CV_FONT_HERSHEY_COMPLEX_SMALL 5 +#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6 +#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7 + +/* font flags */ +#define CV_FONT_ITALIC 16 + +#define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX + +/* Font structure */ +typedef struct CvFont +{ + int font_face; /* =CV_FONT_* */ + const int* ascii; /* font data and metrics */ + const int* greek; + const int* cyrillic; + float hscale, vscale; + float shear; /* slope coefficient: 0 - normal, >0 - italic */ + int thickness; /* letters thickness */ + float dx; /* horizontal interval between letters */ + int line_type; +} +CvFont; + +/* Initializes font structure used further in cvPutText */ +CVAPI(void) cvInitFont( CvFont* font, int font_face, + double hscale, double vscale, + double shear CV_DEFAULT(0), + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8)); + +CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) ) +{ + CvFont font; + cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA ); + return font; +} + +/* Renders text stroke with specified font and color at specified location. + CvFont should be initialized with cvInitFont */ +CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org, + const CvFont* font, CvScalar color ); + +/* Calculates bounding box of text stroke (useful for alignment) */ +CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font, + CvSize* text_size, int* baseline ); + +/* Unpacks color value, if arrtype is CV_8UC?, is treated as + packed color value, otherwise the first channels (depending on arrtype) + of destination scalar are set to the same value = */ +CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype ); + +/* Returns the polygon points which make up the given ellipse. The ellipse is define by + the box of size 'axes' rotated 'angle' around the 'center'. A partial sweep + of the ellipse arc can be done by spcifying arc_start and arc_end to be something + other than 0 and 360, respectively. The input array 'pts' must be large enough to + hold the result. The total number of points stored into 'pts' is returned by this + function. */ +CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes, + int angle, int arc_start, int arc_end, CvPoint * pts, int delta ); + +/* Draws contour outlines or filled interiors on the image */ +CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, + CvScalar external_color, CvScalar hole_color, + int max_level, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + CvPoint offset CV_DEFAULT(cvPoint(0,0))); + +/* Does look-up transformation. Elements of the source array + (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */ +CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut ); + + +/******************* Iteration through the sequence tree *****************/ +typedef struct CvTreeNodeIterator +{ + const void* node; + int level; + int max_level; +} +CvTreeNodeIterator; + +CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, + const void* first, int max_level ); +CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator ); +CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator ); + +/* Inserts sequence into tree with specified "parent" sequence. + If parent is equal to frame (e.g. the most external contour), + then added contour will have null pointer to parent. */ +CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame ); + +/* Removes contour from tree (together with the contour children). */ +CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame ); + +/* Gathers pointers to all the sequences, + accessible from the , to the single sequence */ +CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, + CvMemStorage* storage ); + +/* The function implements the K-means algorithm for clustering an array of sample + vectors in a specified number of classes */ +CVAPI(void) cvKMeans2( const CvArr* samples, int cluster_count, + CvArr* labels, CvTermCriteria termcrit ); + +/****************************************************************************************\ +* System functions * +\****************************************************************************************/ + +/* Add the function pointers table with associated information to the IPP primitives list */ +CVAPI(int) cvRegisterModule( const CvModuleInfo* module_info ); + +/* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ +CVAPI(int) cvUseOptimized( int on_off ); + +/* Retrieves information about the registered modules and loaded optimized plugins */ +CVAPI(void) cvGetModuleInfo( const char* module_name, + const char** version, + const char** loaded_addon_plugins ); + +/* Get current OpenCV error status */ +CVAPI(int) cvGetErrStatus( void ); + +/* Sets error status silently */ +CVAPI(void) cvSetErrStatus( int status ); + +#define CV_ErrModeLeaf 0 /* Print error and exit program */ +#define CV_ErrModeParent 1 /* Print error and continue */ +#define CV_ErrModeSilent 2 /* Don't print and continue */ + +/* Retrives current error processing mode */ +CVAPI(int) cvGetErrMode( void ); + +/* Sets error processing mode, returns previously used mode */ +CVAPI(int) cvSetErrMode( int mode ); + +/* Sets error status and performs some additonal actions (displaying message box, + writing message to stderr, terminating application etc.) + depending on the current error mode */ +CVAPI(void) cvError( int status, const char* func_name, + const char* err_msg, const char* file_name, int line ); + +/* Retrieves textual description of the error given its code */ +CVAPI(const char*) cvErrorStr( int status ); + +/* Retrieves detailed information about the last error occured */ +CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, + const char** filename, int* line ); + +/* Maps IPP error codes to the counterparts from OpenCV */ +CVAPI(int) cvErrorFromIppStatus( int ipp_status ); + +typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, int line, void* userdata ); + +/* Assigns a new error-handling function */ +CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, + void* userdata CV_DEFAULT(NULL), + void** prev_userdata CV_DEFAULT(NULL) ); + +/* + Output to: + cvNulDevReport - nothing + cvStdErrReport - console(fprintf(stderr,...)) + cvGuiBoxReport - MessageBox(WIN32) +*/ +CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +typedef void* (CV_CDECL *CvAllocFunc)(size_t size, void* userdata); +typedef int (CV_CDECL *CvFreeFunc)(void* pptr, void* userdata); + +/* Set user-defined memory managment functions (substitutors for malloc and free) that + will be called by cvAlloc, cvFree and higher-level functions (e.g. cvCreateImage) */ +CVAPI(void) cvSetMemoryManager( CvAllocFunc alloc_func CV_DEFAULT(NULL), + CvFreeFunc free_func CV_DEFAULT(NULL), + void* userdata CV_DEFAULT(NULL)); + + +typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) + (int,int,int,char*,char*,int,int,int,int,int, + IplROI*,IplImage*,void*,IplTileInfo*); +typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int); +typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int); +typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int); +typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*); + +/* Makes OpenCV use IPL functions for IplImage allocation/deallocation */ +CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, + Cv_iplAllocateImageData allocate_data, + Cv_iplDeallocate deallocate, + Cv_iplCreateROI create_roi, + Cv_iplCloneImage clone_image ); + +#define CV_TURN_ON_IPL_COMPATIBILITY() \ + cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ + iplDeallocate, iplCreateROI, iplCloneImage ) + +/****************************************************************************************\ +* Data Persistence * +\****************************************************************************************/ + +/********************************** High-level functions ********************************/ + +/* opens existing or creates new file storage */ +CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, + CvMemStorage* memstorage, + int flags ); + +/* closes file storage and deallocates buffers */ +CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs ); + +/* returns attribute value or 0 (NULL) if there is no such attribute */ +CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name ); + +/* starts writing compound structure (map or sequence) */ +CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name, + int struct_flags, const char* type_name CV_DEFAULT(NULL), + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/* finishes writing compound structure */ +CVAPI(void) cvEndWriteStruct( CvFileStorage* fs ); + +/* writes an integer */ +CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value ); + +/* writes a floating-point number */ +CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value ); + +/* writes a string */ +CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name, + const char* str, int quote CV_DEFAULT(0) ); + +/* writes a comment */ +CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment, + int eol_comment ); + +/* writes instance of a standard type (matrix, image, sequence, graph etc.) + or user-defined type */ +CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr, + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/* starts the next stream */ +CVAPI(void) cvStartNextStream( CvFileStorage* fs ); + +/* helper function: writes multiple integer or floating-point numbers */ +CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src, + int len, const char* dt ); + +/* returns the hash entry corresponding to the specified literal key string or 0 + if there is no such a key in the storage */ +CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name, + int len CV_DEFAULT(-1), + int create_missing CV_DEFAULT(0)); + +/* returns file node with the specified key within the specified map + (collection of named nodes) */ +CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs, + int stream_index CV_DEFAULT(0) ); + +/* returns file node with the specified key within the specified map + (collection of named nodes) */ +CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map, + const CvStringHashNode* key, + int create_missing CV_DEFAULT(0) ); + +/* this is a slower version of cvGetFileNode that takes the key as a literal string */ +CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs, + const CvFileNode* map, + const char* name ); + +CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? node->data.i : + CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff; +} + + +CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, int default_value CV_DEFAULT(0) ) +{ + return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? (double)node->data.i : + CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300; +} + + +CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, double default_value CV_DEFAULT(0.) ) +{ + return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +CV_INLINE const char* cvReadString( const CvFileNode* node, + const char* default_value CV_DEFAULT(NULL) ) +{ + return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0; +} + + +CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, const char* default_value CV_DEFAULT(NULL) ) +{ + return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +/* decodes standard or user-defined object and returns it */ +CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node, + CvAttrList* attributes CV_DEFAULT(NULL)); + +/* decodes standard or user-defined object and returns it */ +CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map, + const char* name, CvAttrList* attributes CV_DEFAULT(NULL) ) +{ + return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes ); +} + + +/* starts reading data from sequence or scalar numeric node */ +CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, + CvSeqReader* reader ); + +/* reads multiple numbers and stores them to array */ +CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, + int count, void* dst, const char* dt ); + +/* combination of two previous functions for easier reading of whole sequences */ +CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, + void* dst, const char* dt ); + +/* writes a copy of file node to file storage */ +CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, + const CvFileNode* node, int embed ); + +/* returns name of file node */ +CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node ); + +/*********************************** Adding own types ***********************************/ + +CVAPI(void) cvRegisterType( const CvTypeInfo* info ); +CVAPI(void) cvUnregisterType( const char* type_name ); +CVAPI(CvTypeInfo*) cvFirstType(void); +CVAPI(CvTypeInfo*) cvFindType( const char* type_name ); +CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr ); + +/* universal functions */ +CVAPI(void) cvRelease( void** struct_ptr ); +CVAPI(void*) cvClone( const void* struct_ptr ); + +/* simple API for reading/writing data */ +CVAPI(void) cvSave( const char* filename, const void* struct_ptr, + const char* name CV_DEFAULT(NULL), + const char* comment CV_DEFAULT(NULL), + CvAttrList attributes CV_DEFAULT(cvAttrList())); +CVAPI(void*) cvLoad( const char* filename, + CvMemStorage* memstorage CV_DEFAULT(NULL), + const char* name CV_DEFAULT(NULL), + const char** real_name CV_DEFAULT(NULL) ); + +/*********************************** Measuring Execution Time ***************************/ + +/* helper functions for RNG initialization and accurate time measurement: + uses internal clock counter on x86 */ +CVAPI(int64) cvGetTickCount( void ); +CVAPI(double) cvGetTickFrequency( void ); + +/*********************************** Multi-Threading ************************************/ + +/* retrieve/set the number of threads used in OpenMP implementations */ +CVAPI(int) cvGetNumThreads( void ); +CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) ); +/* get index of the thread being executed */ +CVAPI(int) cvGetThreadNum( void ); + +#ifdef __cplusplus +} + +#include "cxcore.hpp" +#endif + +#endif /*_CXCORE_H_*/ diff --git a/libraries/external/opencv/linux/include/cxcore.hpp b/libraries/external/opencv/linux/include/cxcore.hpp new file mode 100755 index 0000000..ed8f684 --- /dev/null +++ b/libraries/external/opencv/linux/include/cxcore.hpp @@ -0,0 +1,382 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + + +#ifndef _CXCORE_HPP_ +#define _CXCORE_HPP_ + +class CV_EXPORTS CvImage +{ +public: + CvImage() : image(0), refcount(0) {} + CvImage( CvSize size, int depth, int channels ) + { + image = cvCreateImage( size, depth, channels ); + refcount = image ? new int(1) : 0; + } + + CvImage( IplImage* img ) : image(img) + { + refcount = image ? new int(1) : 0; + } + + CvImage( const CvImage& img ) : image(img.image), refcount(img.refcount) + { + if( refcount ) ++(*refcount); + } + + CvImage( const char* filename, const char* imgname=0, int color=-1 ) : image(0), refcount(0) + { load( filename, imgname, color ); } + + CvImage( CvFileStorage* fs, const char* mapname, const char* imgname ) : image(0), refcount(0) + { read( fs, mapname, imgname ); } + + CvImage( CvFileStorage* fs, const char* seqname, int idx ) : image(0), refcount(0) + { read( fs, seqname, idx ); } + + ~CvImage() + { + if( refcount && !(--*refcount) ) + { + cvReleaseImage( &image ); + delete refcount; + } + } + + CvImage clone() { return CvImage(image ? cvCloneImage(image) : 0); } + + void create( CvSize size, int depth, int channels ) + { + attach( cvCreateImage( size, depth, channels )); + } + + void release() { detach(); } + void clear() { detach(); } + + void attach( IplImage* img, bool use_refcount=true ) + { + if( refcount ) + { + if( --*refcount == 0 ) + cvReleaseImage( &image ); + delete refcount; + } + image = img; + refcount = use_refcount && image ? new int(1) : 0; + } + + void detach() + { + if( refcount ) + { + if( --*refcount == 0 ) + cvReleaseImage( &image ); + delete refcount; + refcount = 0; + } + image = 0; + } + + bool load( const char* filename, const char* imgname=0, int color=-1 ); + bool read( CvFileStorage* fs, const char* mapname, const char* imgname ); + bool read( CvFileStorage* fs, const char* seqname, int idx ); + void save( const char* filename, const char* imgname ); + void write( CvFileStorage* fs, const char* imgname ); + + void show( const char* window_name ); + bool is_valid() { return image != 0; } + + int width() const { return image ? image->width : 0; } + int height() const { return image ? image->height : 0; } + + CvSize size() const { return image ? cvSize(image->width, image->height) : cvSize(0,0); } + + CvSize roi_size() const + { + return !image ? cvSize(0,0) : + !image->roi ? cvSize(image->width,image->height) : + cvSize(image->roi->width, image->roi->height); + } + + CvRect roi() const + { + return !image ? cvRect(0,0,0,0) : + !image->roi ? cvRect(0,0,image->width,image->height) : + cvRect(image->roi->xOffset,image->roi->yOffset, + image->roi->width,image->roi->height); + } + + int coi() const { return !image || !image->roi ? 0 : image->roi->coi; } + + void set_roi(CvRect roi) { cvSetImageROI(image,roi); } + void reset_roi() { cvResetImageROI(image); } + void set_coi(int coi) { cvSetImageCOI(image,coi); } + int depth() const { return image ? image->depth : 0; } + int channels() const { return image ? image->nChannels : 0; } + int pix_size() const { return image ? ((image->depth & 255)>>3)*image->nChannels : 0; } + + uchar* data() { return image ? (uchar*)image->imageData : 0; } + const uchar* data() const { return image ? (const uchar*)image->imageData : 0; } + int step() const { return image ? image->widthStep : 0; } + int origin() const { return image ? image->origin : 0; } + + uchar* roi_row(int y) + { + assert(0<=y); + assert(!image ? + 1 : image->roi ? + yroi->height : yheight); + + return !image ? 0 : + !image->roi ? + (uchar*)(image->imageData + y*image->widthStep) : + (uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep + + image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels); + } + + const uchar* roi_row(int y) const + { + assert(0<=y); + assert(!image ? + 1 : image->roi ? + yroi->height : yheight); + + return !image ? 0 : + !image->roi ? + (const uchar*)(image->imageData + y*image->widthStep) : + (const uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep + + image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels); + } + + operator const IplImage* () const { return image; } + operator IplImage* () { return image; } + + CvImage& operator = (const CvImage& img) + { + if( img.refcount ) + ++*img.refcount; + if( refcount && !(--*refcount) ) + cvReleaseImage( &image ); + image=img.image; + refcount=img.refcount; + return *this; + } + +protected: + IplImage* image; + int* refcount; +}; + + +class CV_EXPORTS CvMatrix +{ +public: + CvMatrix() : matrix(0) {} + CvMatrix( int rows, int cols, int type ) + { matrix = cvCreateMat( rows, cols, type ); } + + CvMatrix( int rows, int cols, int type, CvMat* hdr, + void* data=0, int step=CV_AUTOSTEP ) + { matrix = cvInitMatHeader( hdr, rows, cols, type, data, step ); } + + CvMatrix( int rows, int cols, int type, CvMemStorage* storage, bool alloc_data=true ); + + CvMatrix( int rows, int cols, int type, void* data, int step=CV_AUTOSTEP ) + { matrix = cvCreateMatHeader( rows, cols, type ); + cvSetData( matrix, data, step ); } + + CvMatrix( CvMat* m ) + { matrix = m; } + + CvMatrix( const CvMatrix& m ) + { + matrix = m.matrix; + addref(); + } + + CvMatrix( const char* filename, const char* matname=0, int color=-1 ) : matrix(0) + { load( filename, matname, color ); } + + CvMatrix( CvFileStorage* fs, const char* mapname, const char* matname ) : matrix(0) + { read( fs, mapname, matname ); } + + CvMatrix( CvFileStorage* fs, const char* seqname, int idx ) : matrix(0) + { read( fs, seqname, idx ); } + + ~CvMatrix() + { + release(); + } + + CvMatrix clone() { return CvMatrix(matrix ? cvCloneMat(matrix) : 0); } + + void set( CvMat* m, bool add_ref ) + { + release(); + matrix = m; + if( add_ref ) + addref(); + } + + void create( int rows, int cols, int type ) + { + set( cvCreateMat( rows, cols, type ), false ); + } + + void addref() const + { + if( matrix ) + { + if( matrix->hdr_refcount ) + ++matrix->hdr_refcount; + else if( matrix->refcount ) + ++*matrix->refcount; + } + } + + void release() + { + if( matrix ) + { + if( matrix->hdr_refcount ) + { + if( --matrix->hdr_refcount == 0 ) + cvReleaseMat( &matrix ); + } + else if( matrix->refcount ) + { + if( --*matrix->refcount == 0 ) + cvFree( &matrix->refcount ); + } + matrix = 0; + } + } + + void clear() + { + release(); + } + + bool load( const char* filename, const char* matname=0, int color=-1 ); + bool read( CvFileStorage* fs, const char* mapname, const char* matname ); + bool read( CvFileStorage* fs, const char* seqname, int idx ); + void save( const char* filename, const char* matname ); + void write( CvFileStorage* fs, const char* matname ); + + void show( const char* window_name ); + + bool is_valid() { return matrix != 0; } + + int rows() const { return matrix ? matrix->rows : 0; } + int cols() const { return matrix ? matrix->cols : 0; } + + CvSize size() const + { + return !matrix ? cvSize(0,0) : cvSize(matrix->rows,matrix->cols); + } + + int type() const { return matrix ? CV_MAT_TYPE(matrix->type) : 0; } + int depth() const { return matrix ? CV_MAT_DEPTH(matrix->type) : 0; } + int channels() const { return matrix ? CV_MAT_CN(matrix->type) : 0; } + int pix_size() const { return matrix ? CV_ELEM_SIZE(matrix->type) : 0; } + + uchar* data() { return matrix ? matrix->data.ptr : 0; } + const uchar* data() const { return matrix ? matrix->data.ptr : 0; } + int step() const { return matrix ? matrix->step : 0; } + + void set_data( void* data, int step=CV_AUTOSTEP ) + { cvSetData( matrix, data, step ); } + + uchar* row(int i) { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; } + const uchar* row(int i) const + { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; } + + operator const CvMat* () const { return matrix; } + operator CvMat* () { return matrix; } + + CvMatrix& operator = (const CvMatrix& _m) + { + _m.addref(); + release(); + matrix = _m.matrix; + return *this; + } + +protected: + CvMat* matrix; +}; + + +typedef IplImage* (CV_CDECL * CvLoadImageFunc)( const char* filename, int colorness ); +typedef CvMat* (CV_CDECL * CvLoadImageMFunc)( const char* filename, int colorness ); +typedef int (CV_CDECL * CvSaveImageFunc)( const char* filename, const CvArr* image ); +typedef void (CV_CDECL * CvShowImageFunc)( const char* windowname, const CvArr* image ); + +CVAPI(int) cvSetImageIOFunctions( CvLoadImageFunc _load_image, CvLoadImageMFunc _load_image_m, + CvSaveImageFunc _save_image, CvShowImageFunc _show_image ); + +#define CV_SET_IMAGE_IO_FUNCTIONS() \ + cvSetImageIOFunctions( cvLoadImage, cvLoadImageM, cvSaveImage, cvShowImage ) + +// classes for automatic module/RTTI data registration/unregistration +struct CV_EXPORTS CvModule +{ + CvModule( CvModuleInfo* _info ); + ~CvModule(); + CvModuleInfo* info; + + static CvModuleInfo* first; + static CvModuleInfo* last; +}; + +struct CV_EXPORTS CvType +{ + CvType( const char* type_name, + CvIsInstanceFunc is_instance, CvReleaseFunc release=0, + CvReadFunc read=0, CvWriteFunc write=0, CvCloneFunc clone=0 ); + ~CvType(); + CvTypeInfo* info; + + static CvTypeInfo* first; + static CvTypeInfo* last; +}; + +#endif /*_CXCORE_HPP_*/ diff --git a/libraries/external/opencv/linux/include/cxerror.h b/libraries/external/opencv/linux/include/cxerror.h new file mode 100755 index 0000000..e7540bc --- /dev/null +++ b/libraries/external/opencv/linux/include/cxerror.h @@ -0,0 +1,189 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CXCORE_ERROR_H_ +#define _CXCORE_ERROR_H_ + +/************Below is declaration of error handling stuff in PLSuite manner**/ + +typedef int CVStatus; + +/* this part of CVStatus is compatible with IPLStatus + Some of below symbols are not [yet] used in OpenCV +*/ +#define CV_StsOk 0 /* everithing is ok */ +#define CV_StsBackTrace -1 /* pseudo error for back trace */ +#define CV_StsError -2 /* unknown /unspecified error */ +#define CV_StsInternal -3 /* internal error (bad state) */ +#define CV_StsNoMem -4 /* insufficient memory */ +#define CV_StsBadArg -5 /* function arg/param is bad */ +#define CV_StsBadFunc -6 /* unsupported function */ +#define CV_StsNoConv -7 /* iter. didn't converge */ +#define CV_StsAutoTrace -8 /* tracing */ + +#define CV_HeaderIsNull -9 /* image header is NULL */ +#define CV_BadImageSize -10 /* image size is invalid */ +#define CV_BadOffset -11 /* offset is invalid */ +#define CV_BadDataPtr -12 /**/ +#define CV_BadStep -13 /**/ +#define CV_BadModelOrChSeq -14 /**/ +#define CV_BadNumChannels -15 /**/ +#define CV_BadNumChannel1U -16 /**/ +#define CV_BadDepth -17 /**/ +#define CV_BadAlphaChannel -18 /**/ +#define CV_BadOrder -19 /**/ +#define CV_BadOrigin -20 /**/ +#define CV_BadAlign -21 /**/ +#define CV_BadCallBack -22 /**/ +#define CV_BadTileSize -23 /**/ +#define CV_BadCOI -24 /**/ +#define CV_BadROISize -25 /**/ + +#define CV_MaskIsTiled -26 /**/ + +#define CV_StsNullPtr -27 /* null pointer */ +#define CV_StsVecLengthErr -28 /* incorrect vector length */ +#define CV_StsFilterStructContentErr -29 /* incorr. filter structure content */ +#define CV_StsKernelStructContentErr -30 /* incorr. transform kernel content */ +#define CV_StsFilterOffsetErr -31 /* incorrect filter ofset value */ + +/*extra for CV */ +#define CV_StsBadSize -201 /* the input/output structure size is incorrect */ +#define CV_StsDivByZero -202 /* division by zero */ +#define CV_StsInplaceNotSupported -203 /* in-place operation is not supported */ +#define CV_StsObjectNotFound -204 /* request can't be completed */ +#define CV_StsUnmatchedFormats -205 /* formats of input/output arrays differ */ +#define CV_StsBadFlag -206 /* flag is wrong or not supported */ +#define CV_StsBadPoint -207 /* bad CvPoint */ +#define CV_StsBadMask -208 /* bad format of mask (neither 8uC1 nor 8sC1)*/ +#define CV_StsUnmatchedSizes -209 /* sizes of input/output structures do not match */ +#define CV_StsUnsupportedFormat -210 /* the data format/type is not supported by the function*/ +#define CV_StsOutOfRange -211 /* some of parameters are out of range */ +#define CV_StsParseError -212 /* invalid syntax/structure of the parsed file */ +#define CV_StsNotImplemented -213 /* the requested function/feature is not implemented */ +#define CV_StsBadMemBlock -214 /* an allocated block has been corrupted */ + +/********************************* Error handling Macros ********************************/ + +#define OPENCV_ERROR(status,func,context) \ + cvError((status),(func),(context),__FILE__,__LINE__) + +#define OPENCV_ERRCHK(func,context) \ + {if (cvGetErrStatus() >= 0) \ + {OPENCV_ERROR(CV_StsBackTrace,(func),(context));}} + +#define OPENCV_ASSERT(expr,func,context) \ + {if (! (expr)) \ + {OPENCV_ERROR(CV_StsInternal,(func),(context));}} + +#define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk)) + +#define OPENCV_CALL( Func ) \ +{ \ + Func; \ +} + + +/**************************** OpenCV-style error handling *******************************/ + +/* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */ +#ifdef CV_NO_FUNC_NAMES + #define CV_FUNCNAME( Name ) + #define cvFuncName "" +#else + #define CV_FUNCNAME( Name ) \ + static char cvFuncName[] = Name +#endif + + +/* + CV_ERROR macro unconditionally raises error with passed code and message. + After raising error, control will be transferred to the exit label. +*/ +#define CV_ERROR( Code, Msg ) \ +{ \ + cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \ + EXIT; \ +} + +/* Simplified form of CV_ERROR */ +#define CV_ERROR_FROM_CODE( code ) \ + CV_ERROR( code, "" ) + +/* + CV_CHECK macro checks error status after CV (or IPL) + function call. If error detected, control will be transferred to the exit + label. +*/ +#define CV_CHECK() \ +{ \ + if( cvGetErrStatus() < 0 ) \ + CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ +} + + +/* + CV_CALL macro calls CV (or IPL) function, checks error status and + signals a error if the function failed. Useful in "parent node" + error procesing mode +*/ +#define CV_CALL( Func ) \ +{ \ + Func; \ + CV_CHECK(); \ +} + + +/* Runtime assertion macro */ +#define CV_ASSERT( Condition ) \ +{ \ + if( !(Condition) ) \ + CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \ +} + +#define __BEGIN__ { +#define __END__ goto exit; exit: ; } +#define __CLEANUP__ +#define EXIT goto exit + +#endif /* _CXCORE_ERROR_H_ */ + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/cxmisc.h b/libraries/external/opencv/linux/include/cxmisc.h new file mode 100755 index 0000000..b97878f --- /dev/null +++ b/libraries/external/opencv/linux/include/cxmisc.h @@ -0,0 +1,922 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +/* The header is mostly for internal use and it is likely to change. + It contains some macro definitions that are used in cxcore, cv, cvaux + and, probably, other libraries. If you need some of this functionality, + the safe way is to copy it into your code and rename the macros. +*/ +#ifndef _CXCORE_MISC_H_ +#define _CXCORE_MISC_H_ + +#ifdef HAVE_CONFIG_H + #include "cvconfig.h" +#endif + +#include +#ifdef _OPENMP +#include "omp.h" +#endif + +/****************************************************************************************\ +* Compile-time tuning parameters * +\****************************************************************************************/ + +/* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */ +#define CV_MAX_INLINE_MAT_OP_SIZE 10 + +/* maximal linear size of matrix to allocate it on stack. */ +#define CV_MAX_LOCAL_MAT_SIZE 32 + +/* maximal size of local memory storage */ +#define CV_MAX_LOCAL_SIZE \ + (CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double)) + +/* default image row align (in bytes) */ +#define CV_DEFAULT_IMAGE_ROW_ALIGN 4 + +/* matrices are continuous by default */ +#define CV_DEFAULT_MAT_ROW_ALIGN 1 + +/* maximum size of dynamic memory buffer. + cvAlloc reports an error if a larger block is requested. */ +#define CV_MAX_ALLOC_SIZE (((size_t)1 << (sizeof(size_t)*8-2))) + +/* the alignment of all the allocated buffers */ +#define CV_MALLOC_ALIGN 32 + +/* default alignment for dynamic data strucutures, resided in storages. */ +#define CV_STRUCT_ALIGN ((int)sizeof(double)) + +/* default storage block size */ +#define CV_STORAGE_BLOCK_SIZE ((1<<16) - 128) + +/* default memory block for sparse array elements */ +#define CV_SPARSE_MAT_BLOCK (1<<12) + +/* initial hash table size */ +#define CV_SPARSE_HASH_SIZE0 (1<<10) + +/* maximal average node_count/hash_size ratio beyond which hash table is resized */ +#define CV_SPARSE_HASH_RATIO 3 + +/* max length of strings */ +#define CV_MAX_STRLEN 1024 + +/* maximum possible number of threads in parallel implementations */ +#ifdef _OPENMP +#define CV_MAX_THREADS 128 +#else +#define CV_MAX_THREADS 1 +#endif + +#if 0 /*def CV_CHECK_FOR_NANS*/ + #define CV_CHECK_NANS( arr ) cvCheckArray((arr)) +#else + #define CV_CHECK_NANS( arr ) +#endif + +/****************************************************************************************\ +* Common declarations * +\****************************************************************************************/ + +/* get alloca declaration */ +#ifdef __GNUC__ + #undef alloca + #define alloca __builtin_alloca +#elif defined WIN32 || defined WIN64 + #if defined _MSC_VER || defined __BORLANDC__ + #include + #endif +#elif defined HAVE_ALLOCA_H + #include +#elif defined HAVE_ALLOCA + #include +#elif + #error +#endif + +/* ! DO NOT make it an inline function */ +#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN ) + +#if defined _MSC_VER || defined __BORLANDC__ + #define CV_BIG_INT(n) n##I64 + #define CV_BIG_UINT(n) n##UI64 +#else + #define CV_BIG_INT(n) n##LL + #define CV_BIG_UINT(n) n##ULL +#endif + +#define CV_IMPL CV_EXTERN_C + +#if defined WIN32 && !defined WIN64 && (_MSC_VER >= 1200 || defined CV_ICC) + #define CV_DBG_BREAK() __asm int 3 +#else + #define CV_DBG_BREAK() assert(0); +#endif + +/* default step, set in case of continuous data + to work around checks for valid step in some ipp functions */ +#define CV_STUB_STEP (1 << 30) + +#define CV_SIZEOF_FLOAT ((int)sizeof(float)) +#define CV_SIZEOF_SHORT ((int)sizeof(short)) + +#define CV_ORIGIN_TL 0 +#define CV_ORIGIN_BL 1 + +/* IEEE754 constants and macros */ +#define CV_POS_INF 0x7f800000 +#define CV_NEG_INF 0x807fffff /* CV_TOGGLE_FLT(0xff800000) */ +#define CV_1F 0x3f800000 +#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0)) +#define CV_TOGGLE_DBL(x) \ + ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0)) + +#define CV_NOP(a) (a) +#define CV_ADD(a, b) ((a) + (b)) +#define CV_SUB(a, b) ((a) - (b)) +#define CV_MUL(a, b) ((a) * (b)) +#define CV_AND(a, b) ((a) & (b)) +#define CV_OR(a, b) ((a) | (b)) +#define CV_XOR(a, b) ((a) ^ (b)) +#define CV_ANDN(a, b) (~(a) & (b)) +#define CV_ORN(a, b) (~(a) | (b)) +#define CV_SQR(a) ((a) * (a)) + +#define CV_LT(a, b) ((a) < (b)) +#define CV_LE(a, b) ((a) <= (b)) +#define CV_EQ(a, b) ((a) == (b)) +#define CV_NE(a, b) ((a) != (b)) +#define CV_GT(a, b) ((a) > (b)) +#define CV_GE(a, b) ((a) >= (b)) + +#define CV_NONZERO(a) ((a) != 0) +#define CV_NONZERO_FLT(a) (((a)+(a)) != 0) + +/* general-purpose saturation macros */ +#define CV_CAST_8U(t) (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0) +#define CV_CAST_8S(t) (char)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128) +#define CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0) +#define CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768) +#define CV_CAST_32S(t) (int)(t) +#define CV_CAST_64S(t) (int64)(t) +#define CV_CAST_32F(t) (float)(t) +#define CV_CAST_64F(t) (double)(t) + +#define CV_PASTE2(a,b) a##b +#define CV_PASTE(a,b) CV_PASTE2(a,b) + +#define CV_EMPTY +#define CV_MAKE_STR(a) #a + +#define CV_DEFINE_MASK \ + float maskTab[2]; maskTab[0] = 0.f; maskTab[1] = 1.f; +#define CV_ANDMASK( m, x ) ((x) & (((m) == 0) - 1)) + +/* (x) * ((m) == 1 ? 1.f : (m) == 0 ? 0.f : */ +#define CV_MULMASK( m, x ) (maskTab[(m) != 0]*(x)) + +/* (x) * ((m) == -1 ? 1.f : (m) == 0 ? 0.f : */ +#define CV_MULMASK1( m, x ) (maskTab[(m)+1]*(x)) + +#define CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x))) + +#define CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0]))) + +#define CV_UN_ENTRY_C1(worktype) \ + worktype s0 = scalar[0] + +#define CV_UN_ENTRY_C2(worktype) \ + worktype s0 = scalar[0], s1 = scalar[1] + +#define CV_UN_ENTRY_C3(worktype) \ + worktype s0 = scalar[0], s1 = scalar[1], s2 = scalar[2] + +#define CV_UN_ENTRY_C4(worktype) \ + worktype s0 = scalar[0], s1 = scalar[1], s2 = scalar[2], s3 = scalar[3] + +#define cvUnsupportedFormat "Unsupported format" + +CV_INLINE void* cvAlignPtr( const void* ptr, int align=32 ) +{ + assert( (align & (align-1)) == 0 ); + return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) ); +} + +CV_INLINE int cvAlign( int size, int align ) +{ + assert( (align & (align-1)) == 0 && size < INT_MAX ); + return (size + align - 1) & -align; +} + +CV_INLINE CvSize cvGetMatSize( const CvMat* mat ) +{ + CvSize size = { mat->width, mat->height }; + return size; +} + +#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n)) +#define CV_FLT_TO_FIX(x,n) cvRound((x)*(1<<(n))) + +#if 0 +/* This is a small engine for performing fast division of multiple numbers + by the same constant. Most compilers do it too if they know the divisor value + at compile-time. The algorithm was taken from Agner Fog's optimization guide + at http://www.agner.org/assem */ +typedef struct CvFastDiv +{ + unsigned delta, scale, divisor; +} +CvFastDiv; + +#define CV_FAST_DIV_SHIFT 32 + +CV_INLINE CvFastDiv cvFastDiv( int divisor ) +{ + CvFastDiv fastdiv; + + assert( divisor >= 1 ); + uint64 temp = ((uint64)1 << CV_FAST_DIV_SHIFT)/divisor; + + fastdiv.divisor = divisor; + fastdiv.delta = (unsigned)(((temp & 1) ^ 1) + divisor - 1); + fastdiv.scale = (unsigned)((temp + 1) >> 1); + + return fastdiv; +} + +#define CV_FAST_DIV( x, fastdiv ) \ + ((int)(((int64)((x)*2 + (int)(fastdiv).delta))*(int)(fastdiv).scale>>CV_FAST_DIV_SHIFT)) + +#define CV_FAST_UDIV( x, fastdiv ) \ + ((int)(((uint64)((x)*2 + (fastdiv).delta))*(fastdiv).scale>>CV_FAST_DIV_SHIFT)) +#endif + +#define CV_MEMCPY_CHAR( dst, src, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + char* _icv_memcpy_dst_ = (char*)(dst); \ + const char* _icv_memcpy_src_ = (const char*)(src); \ + \ + for( _icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; _icv_memcpy_i_++ ) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = _icv_memcpy_src_[_icv_memcpy_i_]; \ +} + + +#define CV_MEMCPY_INT( dst, src, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + int* _icv_memcpy_dst_ = (int*)(dst); \ + const int* _icv_memcpy_src_ = (const int*)(src); \ + assert( ((size_t)_icv_memcpy_src_&(sizeof(int)-1)) == 0 && \ + ((size_t)_icv_memcpy_dst_&(sizeof(int)-1)) == 0 ); \ + \ + for(_icv_memcpy_i_=0;_icv_memcpy_i_<_icv_memcpy_len_;_icv_memcpy_i_++) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = _icv_memcpy_src_[_icv_memcpy_i_]; \ +} + + +#define CV_MEMCPY_AUTO( dst, src, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + char* _icv_memcpy_dst_ = (char*)(dst); \ + const char* _icv_memcpy_src_ = (const char*)(src); \ + if( (_icv_memcpy_len_ & (sizeof(int)-1)) == 0 ) \ + { \ + assert( ((size_t)_icv_memcpy_src_&(sizeof(int)-1)) == 0 && \ + ((size_t)_icv_memcpy_dst_&(sizeof(int)-1)) == 0 ); \ + for( _icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; \ + _icv_memcpy_i_+=sizeof(int) ) \ + { \ + *(int*)(_icv_memcpy_dst_+_icv_memcpy_i_) = \ + *(const int*)(_icv_memcpy_src_+_icv_memcpy_i_); \ + } \ + } \ + else \ + { \ + for(_icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; _icv_memcpy_i_++)\ + _icv_memcpy_dst_[_icv_memcpy_i_] = _icv_memcpy_src_[_icv_memcpy_i_]; \ + } \ +} + + +#define CV_ZERO_CHAR( dst, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + char* _icv_memcpy_dst_ = (char*)(dst); \ + \ + for( _icv_memcpy_i_ = 0; _icv_memcpy_i_ < _icv_memcpy_len_; _icv_memcpy_i_++ ) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = '\0'; \ +} + + +#define CV_ZERO_INT( dst, len ) \ +{ \ + size_t _icv_memcpy_i_, _icv_memcpy_len_ = (len); \ + int* _icv_memcpy_dst_ = (int*)(dst); \ + assert( ((size_t)_icv_memcpy_dst_&(sizeof(int)-1)) == 0 ); \ + \ + for(_icv_memcpy_i_=0;_icv_memcpy_i_<_icv_memcpy_len_;_icv_memcpy_i_++) \ + _icv_memcpy_dst_[_icv_memcpy_i_] = 0; \ +} + + +/****************************************************************************************\ + + Generic implementation of QuickSort algorithm. + ---------------------------------------------- + Using this macro user can declare customized sort function that can be much faster + than built-in qsort function because of lower overhead on elements + comparison and exchange. The macro takes less_than (or LT) argument - a macro or function + that takes 2 arguments returns non-zero if the first argument should be before the second + one in the sorted sequence and zero otherwise. + + Example: + + Suppose that the task is to sort points by ascending of y coordinates and if + y's are equal x's should ascend. + + The code is: + ------------------------------------------------------------------------------ + #define cmp_pts( pt1, pt2 ) \ + ((pt1).y < (pt2).y || ((pt1).y < (pt2).y && (pt1).x < (pt2).x)) + + [static] CV_IMPLEMENT_QSORT( icvSortPoints, CvPoint, cmp_pts ) + ------------------------------------------------------------------------------ + + After that the function "void icvSortPoints( CvPoint* array, size_t total, int aux );" + is available to user. + + aux is an additional parameter, which can be used when comparing elements. + The current implementation was derived from *BSD system qsort(): + + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + +\****************************************************************************************/ + +#define CV_IMPLEMENT_QSORT_EX( func_name, T, LT, user_data_type ) \ +void func_name( T *array, size_t total, user_data_type aux ) \ +{ \ + int isort_thresh = 7; \ + T t; \ + int sp = 0; \ + \ + struct \ + { \ + T *lb; \ + T *ub; \ + } \ + stack[48]; \ + \ + aux = aux; \ + \ + if( total <= 1 ) \ + return; \ + \ + stack[0].lb = array; \ + stack[0].ub = array + (total - 1); \ + \ + while( sp >= 0 ) \ + { \ + T* left = stack[sp].lb; \ + T* right = stack[sp--].ub; \ + \ + for(;;) \ + { \ + int i, n = (int)(right - left) + 1, m; \ + T* ptr; \ + T* ptr2; \ + \ + if( n <= isort_thresh ) \ + { \ + insert_sort: \ + for( ptr = left + 1; ptr <= right; ptr++ ) \ + { \ + for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--) \ + CV_SWAP( ptr2[0], ptr2[-1], t ); \ + } \ + break; \ + } \ + else \ + { \ + T* left0; \ + T* left1; \ + T* right0; \ + T* right1; \ + T* pivot; \ + T* a; \ + T* b; \ + T* c; \ + int swap_cnt = 0; \ + \ + left0 = left; \ + right0 = right; \ + pivot = left + (n/2); \ + \ + if( n > 40 ) \ + { \ + int d = n / 8; \ + a = left, b = left + d, c = left + 2*d; \ + left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + \ + a = pivot - d, b = pivot, c = pivot + d; \ + pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + \ + a = right - 2*d, b = right - d, c = right; \ + right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + } \ + \ + a = left, b = pivot, c = right; \ + pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ + : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ + if( pivot != left0 ) \ + { \ + CV_SWAP( *pivot, *left0, t ); \ + pivot = left0; \ + } \ + left = left1 = left0 + 1; \ + right = right1 = right0; \ + \ + for(;;) \ + { \ + while( left <= right && !LT(*pivot, *left) ) \ + { \ + if( !LT(*left, *pivot) ) \ + { \ + if( left > left1 ) \ + CV_SWAP( *left1, *left, t ); \ + swap_cnt = 1; \ + left1++; \ + } \ + left++; \ + } \ + \ + while( left <= right && !LT(*right, *pivot) ) \ + { \ + if( !LT(*pivot, *right) ) \ + { \ + if( right < right1 ) \ + CV_SWAP( *right1, *right, t ); \ + swap_cnt = 1; \ + right1--; \ + } \ + right--; \ + } \ + \ + if( left > right ) \ + break; \ + CV_SWAP( *left, *right, t ); \ + swap_cnt = 1; \ + left++; \ + right--; \ + } \ + \ + if( swap_cnt == 0 ) \ + { \ + left = left0, right = right0; \ + goto insert_sort; \ + } \ + \ + n = MIN( (int)(left1 - left0), (int)(left - left1) ); \ + for( i = 0; i < n; i++ ) \ + CV_SWAP( left0[i], left[i-n], t ); \ + \ + n = MIN( (int)(right0 - right1), (int)(right1 - right) ); \ + for( i = 0; i < n; i++ ) \ + CV_SWAP( left[i], right0[i-n+1], t ); \ + n = (int)(left - left1); \ + m = (int)(right1 - right); \ + if( n > 1 ) \ + { \ + if( m > 1 ) \ + { \ + if( n > m ) \ + { \ + stack[++sp].lb = left0; \ + stack[sp].ub = left0 + n - 1; \ + left = right0 - m + 1, right = right0; \ + } \ + else \ + { \ + stack[++sp].lb = right0 - m + 1; \ + stack[sp].ub = right0; \ + left = left0, right = left0 + n - 1; \ + } \ + } \ + else \ + left = left0, right = left0 + n - 1; \ + } \ + else if( m > 1 ) \ + left = right0 - m + 1, right = right0; \ + else \ + break; \ + } \ + } \ + } \ +} + +#define CV_IMPLEMENT_QSORT( func_name, T, cmp ) \ + CV_IMPLEMENT_QSORT_EX( func_name, T, cmp, int ) + +/****************************************************************************************\ +* Structures and macros for integration with IPP * +\****************************************************************************************/ + +/* IPP-compatible return codes */ +typedef enum CvStatus +{ + CV_BADMEMBLOCK_ERR = -113, + CV_INPLACE_NOT_SUPPORTED_ERR= -112, + CV_UNMATCHED_ROI_ERR = -111, + CV_NOTFOUND_ERR = -110, + CV_BADCONVERGENCE_ERR = -109, + + CV_BADDEPTH_ERR = -107, + CV_BADROI_ERR = -106, + CV_BADHEADER_ERR = -105, + CV_UNMATCHED_FORMATS_ERR = -104, + CV_UNSUPPORTED_COI_ERR = -103, + CV_UNSUPPORTED_CHANNELS_ERR = -102, + CV_UNSUPPORTED_DEPTH_ERR = -101, + CV_UNSUPPORTED_FORMAT_ERR = -100, + + CV_BADARG_ERR = -49, //ipp comp + CV_NOTDEFINED_ERR = -48, //ipp comp + + CV_BADCHANNELS_ERR = -47, //ipp comp + CV_BADRANGE_ERR = -44, //ipp comp + CV_BADSTEP_ERR = -29, //ipp comp + + CV_BADFLAG_ERR = -12, + CV_DIV_BY_ZERO_ERR = -11, //ipp comp + CV_BADCOEF_ERR = -10, + + CV_BADFACTOR_ERR = -7, + CV_BADPOINT_ERR = -6, + CV_BADSCALE_ERR = -4, + CV_OUTOFMEM_ERR = -3, + CV_NULLPTR_ERR = -2, + CV_BADSIZE_ERR = -1, + CV_NO_ERR = 0, + CV_OK = CV_NO_ERR +} +CvStatus; + +#define CV_ERROR_FROM_STATUS( result ) \ + CV_ERROR( cvErrorFromIppStatus( result ), "OpenCV function failed" ) + +#define IPPI_CALL( Func ) \ +{ \ + CvStatus ippi_call_result; \ + ippi_call_result = Func; \ + \ + if( ippi_call_result < 0 ) \ + CV_ERROR_FROM_STATUS( (ippi_call_result)); \ +} + +#define CV_PLUGIN_NONE 0 +#define CV_PLUGIN_OPTCV 1 /* custom "emerged" ippopencv library */ +#define CV_PLUGIN_IPPCV 2 /* IPP: computer vision */ +#define CV_PLUGIN_IPPI 3 /* IPP: image processing */ +#define CV_PLUGIN_IPPS 4 /* IPP: signal processing */ +#define CV_PLUGIN_IPPVM 5 /* IPP: vector math functions */ +#define CV_PLUGIN_IPPCC 6 /* IPP: color space conversion */ +#define CV_PLUGIN_MKL 8 /* Intel Math Kernel Library */ + +#define CV_PLUGIN_MAX 16 + +#define CV_PLUGINS1(lib1) ((lib1)&15) +#define CV_PLUGINS2(lib1,lib2) (((lib1)&15)|(((lib2)&15)<<4)) +#define CV_PLUGINS3(lib1,lib2,lib3) (((lib1)&15)|(((lib2)&15)<<4)|(((lib2)&15)<<8)) + +#define CV_NOTHROW throw() + +#ifndef IPCVAPI +#define IPCVAPI(type,declspec,name,args) \ + /* function pointer */ \ + typedef type (declspec* name##_t) args; \ + extern name##_t name##_p; \ + type declspec name args; +#endif + +#define IPCVAPI_EX(type,name,ipp_name,ipp_search_modules,args) \ + IPCVAPI(type,CV_STDCALL,name,args) + +#define IPCVAPI_C_EX(type,name,ipp_name,ipp_search_modules,args)\ + IPCVAPI(type,CV_CDECL,name,args) + +#ifndef IPCVAPI_IMPL +#define IPCVAPI_IMPL(type,name,args,arg_names) \ + static type CV_STDCALL name##_f args; \ + name##_t name##_p = name##_f; \ + type CV_STDCALL name args { return name##_p arg_names; } \ + static type CV_STDCALL name##_f args +#endif + +/* IPP types' enumeration */ +typedef enum CvDataType { + cv1u, + cv8u, cv8s, + cv16u, cv16s, cv16sc, + cv32u, cv32s, cv32sc, + cv32f, cv32fc, + cv64u, cv64s, cv64sc, + cv64f, cv64fc +} CvDataType; + +typedef enum CvHintAlgorithm { + cvAlgHintNone, + cvAlgHintFast, + cvAlgHintAccurate +} CvHintAlgorithm; + +typedef enum CvCmpOp { + cvCmpLess, + cvCmpLessEq, + cvCmpEq, + cvCmpGreaterEq, + cvCmpGreater +} CvCmpOp; + +typedef struct CvFuncTable +{ + void* fn_2d[CV_DEPTH_MAX]; +} +CvFuncTable; + +typedef struct CvBigFuncTable +{ + void* fn_2d[CV_DEPTH_MAX*CV_CN_MAX]; +} +CvBigFuncTable; + + +typedef struct CvBtFuncTable +{ + void* fn_2d[33]; +} +CvBtFuncTable; + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A)(void* arr, int step, CvSize size); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A1P)(void* arr, int step, CvSize size, void* param); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A1P1I)(void* arr, int step, CvSize size, + void* param, int flag); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A1P)( void* arr, int step, CvSize size, + int cn, int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A1P)( void* arr, int step, CvSize size, + int cn, int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A2P)( void* arr, int step, CvSize size, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A2P)( void* arr, int step, + CvSize size, int cn, int coi, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_1A4P)( void* arr, int step, CvSize size, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A4P)( void* arr, int step, + CvSize size, int cn, int coi, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A)( void* arr0, int step0, + void* arr1, int step1, CvSize size ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A1P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A1P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, int cn, + int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A1P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, int cn, + int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A2P)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A2P)( void* arr0, int step0, + void* arr1, int step1, + CvSize size, int cn, int coi, + void* param1, void* param2 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A1P1I)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + void* param, int flag ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_2A4P)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A4P)( void* arr0, int step0, + void* arr1, int step1, CvSize size, + int cn, int coi, + void* param1, void* param2, + void* param3, void* param4 ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_3A)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, CvSize size ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_3A1P)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + CvSize size, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_3A1I)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + CvSize size, int flag ); + +typedef CvStatus (CV_STDCALL *CvFunc2DnC_3A1P)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + CvSize size, int cn, + int coi, void* param ); + +typedef CvStatus (CV_STDCALL *CvFunc2D_4A)( void* arr0, int step0, + void* arr1, int step1, + void* arr2, int step2, + void* arr3, int step3, + CvSize size ); + +typedef CvStatus (CV_STDCALL *CvFunc0D)( const void* src, void* dst, int param ); + +#define CV_DEF_INIT_FUNC_TAB_2D( FUNCNAME, FLAG ) \ +static void icvInit##FUNCNAME##FLAG##Table( CvFuncTable* tab ) \ +{ \ + assert( tab ); \ + \ + tab->fn_2d[CV_8U] = (void*)icv##FUNCNAME##_8u_##FLAG; \ + tab->fn_2d[CV_8S] = (void*)icv##FUNCNAME##_8s_##FLAG; \ + tab->fn_2d[CV_16U] = (void*)icv##FUNCNAME##_16u_##FLAG; \ + tab->fn_2d[CV_16S] = (void*)icv##FUNCNAME##_16s_##FLAG; \ + tab->fn_2d[CV_32S] = (void*)icv##FUNCNAME##_32s_##FLAG; \ + tab->fn_2d[CV_32F] = (void*)icv##FUNCNAME##_32f_##FLAG; \ + tab->fn_2d[CV_64F] = (void*)icv##FUNCNAME##_64f_##FLAG; \ +} + + +#define CV_DEF_INIT_BIG_FUNC_TAB_2D( FUNCNAME, FLAG ) \ +static void icvInit##FUNCNAME##FLAG##Table( CvBigFuncTable* tab ) \ +{ \ + assert( tab ); \ + \ + tab->fn_2d[CV_8UC1] = (void*)icv##FUNCNAME##_8u_C1##FLAG; \ + tab->fn_2d[CV_8UC2] = (void*)icv##FUNCNAME##_8u_C2##FLAG; \ + tab->fn_2d[CV_8UC3] = (void*)icv##FUNCNAME##_8u_C3##FLAG; \ + tab->fn_2d[CV_8UC4] = (void*)icv##FUNCNAME##_8u_C4##FLAG; \ + \ + tab->fn_2d[CV_8SC1] = (void*)icv##FUNCNAME##_8s_C1##FLAG; \ + tab->fn_2d[CV_8SC2] = (void*)icv##FUNCNAME##_8s_C2##FLAG; \ + tab->fn_2d[CV_8SC3] = (void*)icv##FUNCNAME##_8s_C3##FLAG; \ + tab->fn_2d[CV_8SC4] = (void*)icv##FUNCNAME##_8s_C4##FLAG; \ + \ + tab->fn_2d[CV_16UC1] = (void*)icv##FUNCNAME##_16u_C1##FLAG; \ + tab->fn_2d[CV_16UC2] = (void*)icv##FUNCNAME##_16u_C2##FLAG; \ + tab->fn_2d[CV_16UC3] = (void*)icv##FUNCNAME##_16u_C3##FLAG; \ + tab->fn_2d[CV_16UC4] = (void*)icv##FUNCNAME##_16u_C4##FLAG; \ + \ + tab->fn_2d[CV_16SC1] = (void*)icv##FUNCNAME##_16s_C1##FLAG; \ + tab->fn_2d[CV_16SC2] = (void*)icv##FUNCNAME##_16s_C2##FLAG; \ + tab->fn_2d[CV_16SC3] = (void*)icv##FUNCNAME##_16s_C3##FLAG; \ + tab->fn_2d[CV_16SC4] = (void*)icv##FUNCNAME##_16s_C4##FLAG; \ + \ + tab->fn_2d[CV_32SC1] = (void*)icv##FUNCNAME##_32s_C1##FLAG; \ + tab->fn_2d[CV_32SC2] = (void*)icv##FUNCNAME##_32s_C2##FLAG; \ + tab->fn_2d[CV_32SC3] = (void*)icv##FUNCNAME##_32s_C3##FLAG; \ + tab->fn_2d[CV_32SC4] = (void*)icv##FUNCNAME##_32s_C4##FLAG; \ + \ + tab->fn_2d[CV_32FC1] = (void*)icv##FUNCNAME##_32f_C1##FLAG; \ + tab->fn_2d[CV_32FC2] = (void*)icv##FUNCNAME##_32f_C2##FLAG; \ + tab->fn_2d[CV_32FC3] = (void*)icv##FUNCNAME##_32f_C3##FLAG; \ + tab->fn_2d[CV_32FC4] = (void*)icv##FUNCNAME##_32f_C4##FLAG; \ + \ + tab->fn_2d[CV_64FC1] = (void*)icv##FUNCNAME##_64f_C1##FLAG; \ + tab->fn_2d[CV_64FC2] = (void*)icv##FUNCNAME##_64f_C2##FLAG; \ + tab->fn_2d[CV_64FC3] = (void*)icv##FUNCNAME##_64f_C3##FLAG; \ + tab->fn_2d[CV_64FC4] = (void*)icv##FUNCNAME##_64f_C4##FLAG; \ +} + +#define CV_DEF_INIT_FUNC_TAB_0D( FUNCNAME ) \ +static void icvInit##FUNCNAME##Table( CvFuncTable* tab ) \ +{ \ + tab->fn_2d[CV_8U] = (void*)icv##FUNCNAME##_8u; \ + tab->fn_2d[CV_8S] = (void*)icv##FUNCNAME##_8s; \ + tab->fn_2d[CV_16U] = (void*)icv##FUNCNAME##_16u; \ + tab->fn_2d[CV_16S] = (void*)icv##FUNCNAME##_16s; \ + tab->fn_2d[CV_32S] = (void*)icv##FUNCNAME##_32s; \ + tab->fn_2d[CV_32F] = (void*)icv##FUNCNAME##_32f; \ + tab->fn_2d[CV_64F] = (void*)icv##FUNCNAME##_64f; \ +} + +#define CV_DEF_INIT_FUNC_TAB_1D CV_DEF_INIT_FUNC_TAB_0D + + +#define CV_DEF_INIT_PIXSIZE_TAB_2D( FUNCNAME, FLAG ) \ +static void icvInit##FUNCNAME##FLAG##Table( CvBtFuncTable* table ) \ +{ \ + table->fn_2d[1] = (void*)icv##FUNCNAME##_8u_C1##FLAG; \ + table->fn_2d[2] = (void*)icv##FUNCNAME##_8u_C2##FLAG; \ + table->fn_2d[3] = (void*)icv##FUNCNAME##_8u_C3##FLAG; \ + table->fn_2d[4] = (void*)icv##FUNCNAME##_16u_C2##FLAG; \ + table->fn_2d[6] = (void*)icv##FUNCNAME##_16u_C3##FLAG; \ + table->fn_2d[8] = (void*)icv##FUNCNAME##_32s_C2##FLAG; \ + table->fn_2d[12] = (void*)icv##FUNCNAME##_32s_C3##FLAG; \ + table->fn_2d[16] = (void*)icv##FUNCNAME##_64s_C2##FLAG; \ + table->fn_2d[24] = (void*)icv##FUNCNAME##_64s_C3##FLAG; \ + table->fn_2d[32] = (void*)icv##FUNCNAME##_64s_C4##FLAG; \ +} + +#define CV_GET_FUNC_PTR( func, table_entry ) \ + func = (table_entry); \ + \ + if( !func ) \ + CV_ERROR( CV_StsUnsupportedFormat, "" ) + + +#endif /*_CXCORE_MISC_H_*/ diff --git a/libraries/external/opencv/linux/include/cxtypes.h b/libraries/external/opencv/linux/include/cxtypes.h new file mode 100755 index 0000000..94f88ed --- /dev/null +++ b/libraries/external/opencv/linux/include/cxtypes.h @@ -0,0 +1,1771 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _CXCORE_TYPES_H_ +#define _CXCORE_TYPES_H_ + +#if !defined _CRT_SECURE_NO_DEPRECATE && _MSC_VER > 1300 +#define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */ +#endif + +#ifndef SKIP_INCLUDES + #include + #include + #include + #include + + #if defined __ICL + #define CV_ICC __ICL + #elif defined __ICC + #define CV_ICC __ICC + #elif defined __ECL + #define CV_ICC __ECL + #elif defined __ECC + #define CV_ICC __ECC + #endif + + #if defined WIN64 && defined EM64T && (defined _MSC_VER || defined CV_ICC) \ + || defined __SSE2__ || defined _MM_SHUFFLE2 || defined __x86_64__ + #include + #define CV_SSE2 1 + #else + #define CV_SSE2 0 + #endif + + #if defined __BORLANDC__ + #include + #elif defined WIN64 && !defined EM64T && defined CV_ICC + #include + #else + #include + #endif + + #ifdef HAVE_IPL + #ifndef __IPL_H__ + #if defined WIN32 || defined WIN64 + #include + #else + #include + #endif + #endif + #elif defined __IPL_H__ + #define HAVE_IPL + #endif +#endif // SKIP_INCLUDES + +#if defined WIN32 || defined WIN64 + #define CV_CDECL __cdecl + #define CV_STDCALL __stdcall +#else + #define CV_CDECL + #define CV_STDCALL +#endif + +#ifndef CV_EXTERN_C + #ifdef __cplusplus + #define CV_EXTERN_C extern "C" + #define CV_DEFAULT(val) = val + #else + #define CV_EXTERN_C + #define CV_DEFAULT(val) + #endif +#endif + +#ifndef CV_EXTERN_C_FUNCPTR + #ifdef __cplusplus + #define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } + #else + #define CV_EXTERN_C_FUNCPTR(x) typedef x + #endif +#endif + +#ifndef CV_INLINE +#if defined __cplusplus + #define CV_INLINE inline +#elif (defined WIN32 || defined WIN64) && !defined __GNUC__ + #define CV_INLINE __inline +#else + #define CV_INLINE static inline +#endif +#endif /* CV_INLINE */ + +#if (defined WIN32 || defined WIN64) && defined CVAPI_EXPORTS + #define CV_EXPORTS __declspec(dllexport) +#else + #define CV_EXPORTS +#endif + +#ifndef CVAPI + #define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL +#endif + +#if defined _MSC_VER || defined __BORLANDC__ +typedef __int64 int64; +typedef unsigned __int64 uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif + +#ifndef HAVE_IPL +typedef unsigned char uchar; +typedef unsigned short ushort; +#endif + +/* CvArr* is used to pass arbitrary array-like data structures + into the functions where the particular + array type is recognized at runtime */ +typedef void CvArr; + +typedef union Cv32suf +{ + int i; + unsigned u; + float f; +} +Cv32suf; + +typedef union Cv64suf +{ + int64 i; + uint64 u; + double f; +} +Cv64suf; + +/****************************************************************************************\ +* Common macros and inline functions * +\****************************************************************************************/ + +#define CV_PI 3.1415926535897932384626433832795 +#define CV_LOG2 0.69314718055994530941723212145818 + +#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t)) + +#ifndef MIN +#define MIN(a,b) ((a) > (b) ? (b) : (a)) +#endif + +#ifndef MAX +#define MAX(a,b) ((a) < (b) ? (b) : (a)) +#endif + +/* min & max without jumps */ +#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1))) + +#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1))) + +/* absolute value without jumps */ +#ifndef __cplusplus +#define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0)) +#else +#define CV_IABS(a) abs(a) +#endif +#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b))) +#define CV_SIGN(a) CV_CMP((a),0) + +CV_INLINE int cvRound( double value ) +{ +#if CV_SSE2 + __m128d t = _mm_load_sd( &value ); + return _mm_cvtsd_si32(t); +#elif defined WIN32 && !defined WIN64 && defined _MSC_VER + int t; + __asm + { + fld value; + fistp t; + } + return t; +#elif (defined HAVE_LRINT) || (defined WIN64 && !defined EM64T && defined CV_ICC) + return (int)lrint(value); +#else + /* + the algorithm was taken from Agner Fog's optimization guide + at http://www.agner.org/assem + */ + Cv64suf temp; + temp.f = value + 6755399441055744.0; + return (int)temp.u; +#endif +} + + +CV_INLINE int cvFloor( double value ) +{ +#if CV_SSE2 + __m128d t = _mm_load_sd( &value ); + int i = _mm_cvtsd_si32(t); + return i - _mm_movemask_pd(_mm_cmplt_sd(t,_mm_cvtsi32_sd(t,i))); +#else + int temp = cvRound(value); + Cv32suf diff; + diff.f = (float)(value - temp); + return temp - (diff.i < 0); +#endif +} + + +CV_INLINE int cvCeil( double value ) +{ +#if CV_SSE2 + __m128d t = _mm_load_sd( &value ); + int i = _mm_cvtsd_si32(t); + return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i),t)); +#else + int temp = cvRound(value); + Cv32suf diff; + diff.f = (float)(temp - value); + return temp + (diff.i < 0); +#endif +} + +#define cvInvSqrt(value) ((float)(1./sqrt(value))) +#define cvSqrt(value) ((float)sqrt(value)) + +CV_INLINE int cvIsNaN( double value ) +{ +#if 1/*defined _MSC_VER || defined __BORLANDC__ + return _isnan(value); +#elif defined __GNUC__ + return isnan(value); +#else*/ + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) + + ((unsigned)ieee754.u != 0) > 0x7ff00000; +#endif +} + + +CV_INLINE int cvIsInf( double value ) +{ +#if 1/*defined _MSC_VER || defined __BORLANDC__ + return !_finite(value); +#elif defined __GNUC__ + return isinf(value); +#else*/ + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && + (unsigned)ieee754.u == 0; +#endif +} + + +/*************** Random number generation *******************/ + +typedef uint64 CvRNG; + +CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1)) +{ + CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1; + return rng; +} + +/* returns random 32-bit unsigned integer */ +CV_INLINE unsigned cvRandInt( CvRNG* rng ) +{ + uint64 temp = *rng; + temp = (uint64)(unsigned)temp*1554115554 + (temp >> 32); + *rng = temp; + return (unsigned)temp; +} + +/* returns random floating-point number between 0 and 1 */ +CV_INLINE double cvRandReal( CvRNG* rng ) +{ + return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */; +} + +/****************************************************************************************\ +* Image type (IplImage) * +\****************************************************************************************/ + +#ifndef HAVE_IPL + +/* + * The following definitions (until #endif) + * is an extract from IPL headers. + * Copyright (c) 1995 Intel Corporation. + */ +#define IPL_DEPTH_SIGN 0x80000000 + +#define IPL_DEPTH_1U 1 +#define IPL_DEPTH_8U 8 +#define IPL_DEPTH_16U 16 +#define IPL_DEPTH_32F 32 + +#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8) +#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16) +#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32) + +#define IPL_DATA_ORDER_PIXEL 0 +#define IPL_DATA_ORDER_PLANE 1 + +#define IPL_ORIGIN_TL 0 +#define IPL_ORIGIN_BL 1 + +#define IPL_ALIGN_4BYTES 4 +#define IPL_ALIGN_8BYTES 8 +#define IPL_ALIGN_16BYTES 16 +#define IPL_ALIGN_32BYTES 32 + +#define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES +#define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES + +#define IPL_BORDER_CONSTANT 0 +#define IPL_BORDER_REPLICATE 1 +#define IPL_BORDER_REFLECT 2 +#define IPL_BORDER_WRAP 3 + +typedef struct _IplImage +{ + int nSize; /* sizeof(IplImage) */ + int ID; /* version (=0)*/ + int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */ + int alphaChannel; /* ignored by OpenCV */ + int depth; /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, + IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */ + char colorModel[4]; /* ignored by OpenCV */ + char channelSeq[4]; /* ditto */ + int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels. + cvCreateImage can only create interleaved images */ + int origin; /* 0 - top-left origin, + 1 - bottom-left origin (Windows bitmaps style) */ + int align; /* Alignment of image rows (4 or 8). + OpenCV ignores it and uses widthStep instead */ + int width; /* image width in pixels */ + int height; /* image height in pixels */ + struct _IplROI *roi;/* image ROI. if NULL, the whole image is selected */ + struct _IplImage *maskROI; /* must be NULL */ + void *imageId; /* ditto */ + struct _IplTileInfo *tileInfo; /* ditto */ + int imageSize; /* image data size in bytes + (==image->height*image->widthStep + in case of interleaved data)*/ + char *imageData; /* pointer to aligned image data */ + int widthStep; /* size of aligned image row in bytes */ + int BorderMode[4]; /* ignored by OpenCV */ + int BorderConst[4]; /* ditto */ + char *imageDataOrigin; /* pointer to very origin of image data + (not necessarily aligned) - + needed for correct deallocation */ +} +IplImage; + +typedef struct _IplTileInfo IplTileInfo; + +typedef struct _IplROI +{ + int coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/ + int xOffset; + int yOffset; + int width; + int height; +} +IplROI; + +typedef struct _IplConvKernel +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + int *values; + int nShiftR; +} +IplConvKernel; + +typedef struct _IplConvKernelFP +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + float *values; +} +IplConvKernelFP; + +#define IPL_IMAGE_HEADER 1 +#define IPL_IMAGE_DATA 2 +#define IPL_IMAGE_ROI 4 + +#endif/*HAVE_IPL*/ + +/* extra border mode */ +#define IPL_BORDER_REFLECT_101 4 + +#define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage)) +#define CV_TYPE_NAME_IMAGE "opencv-image" + +#define CV_IS_IMAGE_HDR(img) \ + ((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage)) + +#define CV_IS_IMAGE(img) \ + (CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->imageData != NULL) + +/* for storing double-precision + floating point data in IplImage's */ +#define IPL_DEPTH_64F 64 + +/* get reference to pixel at (col,row), + for multi-channel images (col) should be multiplied by number of channels */ +#define CV_IMAGE_ELEM( image, elemtype, row, col ) \ + (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)]) + +/****************************************************************************************\ +* Matrix type (CvMat) * +\****************************************************************************************/ + +#define CV_CN_MAX 64 +#define CV_CN_SHIFT 3 +#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) + +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 +#define CV_USRTYPE1 7 + +#define CV_MAKETYPE(depth,cn) ((depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKE_TYPE CV_MAKETYPE + +#define CV_8UC1 CV_MAKETYPE(CV_8U,1) +#define CV_8UC2 CV_MAKETYPE(CV_8U,2) +#define CV_8UC3 CV_MAKETYPE(CV_8U,3) +#define CV_8UC4 CV_MAKETYPE(CV_8U,4) +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) + +#define CV_8SC1 CV_MAKETYPE(CV_8S,1) +#define CV_8SC2 CV_MAKETYPE(CV_8S,2) +#define CV_8SC3 CV_MAKETYPE(CV_8S,3) +#define CV_8SC4 CV_MAKETYPE(CV_8S,4) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) + +#define CV_16UC1 CV_MAKETYPE(CV_16U,1) +#define CV_16UC2 CV_MAKETYPE(CV_16U,2) +#define CV_16UC3 CV_MAKETYPE(CV_16U,3) +#define CV_16UC4 CV_MAKETYPE(CV_16U,4) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) + +#define CV_16SC1 CV_MAKETYPE(CV_16S,1) +#define CV_16SC2 CV_MAKETYPE(CV_16S,2) +#define CV_16SC3 CV_MAKETYPE(CV_16S,3) +#define CV_16SC4 CV_MAKETYPE(CV_16S,4) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_32SC1 CV_MAKETYPE(CV_32S,1) +#define CV_32SC2 CV_MAKETYPE(CV_32S,2) +#define CV_32SC3 CV_MAKETYPE(CV_32S,3) +#define CV_32SC4 CV_MAKETYPE(CV_32S,4) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) + +#define CV_32FC1 CV_MAKETYPE(CV_32F,1) +#define CV_32FC2 CV_MAKETYPE(CV_32F,2) +#define CV_32FC3 CV_MAKETYPE(CV_32F,3) +#define CV_32FC4 CV_MAKETYPE(CV_32F,4) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) + +#define CV_64FC1 CV_MAKETYPE(CV_64F,1) +#define CV_64FC2 CV_MAKETYPE(CV_64F,2) +#define CV_64FC3 CV_MAKETYPE(CV_64F,3) +#define CV_64FC4 CV_MAKETYPE(CV_64F,4) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + +#define CV_AUTO_STEP 0x7fffffff +#define CV_WHOLE_ARR cvSlice( 0, 0x3fffffff ) + +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) +#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) +#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_CONT_FLAG_SHIFT 14 +#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) +#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) +#define CV_IS_CONT_MAT CV_IS_MAT_CONT +#define CV_MAT_TEMP_FLAG_SHIFT 15 +#define CV_MAT_TEMP_FLAG (1 << CV_MAT_TEMP_FLAG_SHIFT) +#define CV_IS_TEMP_MAT(flags) ((flags) & CV_MAT_TEMP_FLAG) + +#define CV_MAGIC_MASK 0xFFFF0000 +#define CV_MAT_MAGIC_VAL 0x42420000 +#define CV_TYPE_NAME_MAT "opencv-matrix" + +typedef struct CvMat +{ + int type; + int step; + + /* for internal use only */ + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + short* s; + int* i; + float* fl; + double* db; + } data; + +#ifdef __cplusplus + union + { + int rows; + int height; + }; + + union + { + int cols; + int width; + }; +#else + int rows; + int cols; +#endif + +} +CvMat; + + +#define CV_IS_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ + ((const CvMat*)(mat))->cols > 0 && ((const CvMat*)(mat))->rows > 0) + +#define CV_IS_MAT(mat) \ + (CV_IS_MAT_HDR(mat) && ((const CvMat*)(mat))->data.ptr != NULL) + +#define CV_IS_MASK_ARR(mat) \ + (((mat)->type & (CV_MAT_TYPE_MASK & ~CV_8SC1)) == 0) + +#define CV_ARE_TYPES_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_TYPE_MASK) == 0) + +#define CV_ARE_CNS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_CN_MASK) == 0) + +#define CV_ARE_DEPTHS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_DEPTH_MASK) == 0) + +#define CV_ARE_SIZES_EQ(mat1, mat2) \ + ((mat1)->height == (mat2)->height && (mat1)->width == (mat2)->width) + +#define CV_IS_MAT_CONST(mat) \ + (((mat)->height|(mat)->width) == 1) + +/* size of each channel item, + 0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ +#define CV_ELEM_SIZE1(type) \ + ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15) + +/* 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */ +#define CV_ELEM_SIZE(type) \ + (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)) + +/* inline constructor. No data is allocated internally!!! + (use together with cvCreateData, or use cvCreateMat instead to + get a matrix with allocated data) */ +CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)) +{ + CvMat m; + + assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); + type = CV_MAT_TYPE(type); + m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; + m.cols = cols; + m.rows = rows; + m.step = rows > 1 ? m.cols*CV_ELEM_SIZE(type) : 0; + m.data.ptr = (uchar*)data; + m.refcount = NULL; + m.hdr_refcount = 0; + + return m; +} + + +#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \ + (assert( (unsigned)(row) < (unsigned)(mat).rows && \ + (unsigned)(col) < (unsigned)(mat).cols ), \ + (mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col)) + +#define CV_MAT_ELEM_PTR( mat, row, col ) \ + CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) ) + +#define CV_MAT_ELEM( mat, elemtype, row, col ) \ + (*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype))) + + +CV_INLINE double cvmGet( const CvMat* mat, int row, int col ) +{ + int type; + + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + return ((float*)(mat->data.ptr + (size_t)mat->step*row))[col]; + else + { + assert( type == CV_64FC1 ); + return ((double*)(mat->data.ptr + (size_t)mat->step*row))[col]; + } +} + + +CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) +{ + int type; + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + ((float*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value; + else + { + assert( type == CV_64FC1 ); + ((double*)(mat->data.ptr + (size_t)mat->step*row))[col] = (double)value; + } +} + + +CV_INLINE int cvCvToIplDepth( int type ) +{ + int depth = CV_MAT_DEPTH(type); + return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || + depth == CV_32S ? IPL_DEPTH_SIGN : 0); +} + + +/****************************************************************************************\ +* Multi-dimensional dense array (CvMatND) * +\****************************************************************************************/ + +#define CV_MATND_MAGIC_VAL 0x42430000 +#define CV_TYPE_NAME_MATND "opencv-nd-matrix" + +#define CV_MAX_DIM 32 +#define CV_MAX_DIM_HEAP (1 << 16) + +typedef struct CvMatND +{ + int type; + int dims; + + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + float* fl; + double* db; + int* i; + short* s; + } data; + + struct + { + int size; + int step; + } + dim[CV_MAX_DIM]; +} +CvMatND; + +#define CV_IS_MATND_HDR(mat) \ + ((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL) + +#define CV_IS_MATND(mat) \ + (CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL) + + +/****************************************************************************************\ +* Multi-dimensional sparse array (CvSparseMat) * +\****************************************************************************************/ + +#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000 +#define CV_TYPE_NAME_SPARSE_MAT "opencv-sparse-matrix" + +struct CvSet; + +typedef struct CvSparseMat +{ + int type; + int dims; + int* refcount; + int hdr_refcount; + + struct CvSet* heap; + void** hashtable; + int hashsize; + int valoffset; + int idxoffset; + int size[CV_MAX_DIM]; +} +CvSparseMat; + +#define CV_IS_SPARSE_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL) + +#define CV_IS_SPARSE_MAT(mat) \ + CV_IS_SPARSE_MAT_HDR(mat) + +/**************** iteration through a sparse array *****************/ + +typedef struct CvSparseNode +{ + unsigned hashval; + struct CvSparseNode* next; +} +CvSparseNode; + +typedef struct CvSparseMatIterator +{ + CvSparseMat* mat; + CvSparseNode* node; + int curidx; +} +CvSparseMatIterator; + +#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset)) +#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset)) + +/****************************************************************************************\ +* Histogram * +\****************************************************************************************/ + +typedef int CvHistType; + +#define CV_HIST_MAGIC_VAL 0x42450000 +#define CV_HIST_UNIFORM_FLAG (1 << 10) + +/* indicates whether bin ranges are set already or not */ +#define CV_HIST_RANGES_FLAG (1 << 11) + +#define CV_HIST_ARRAY 0 +#define CV_HIST_SPARSE 1 +#define CV_HIST_TREE CV_HIST_SPARSE + +/* should be used as a parameter only, + it turns to CV_HIST_UNIFORM_FLAG of hist->type */ +#define CV_HIST_UNIFORM 1 + +typedef struct CvHistogram +{ + int type; + CvArr* bins; + float thresh[CV_MAX_DIM][2]; /* for uniform histograms */ + float** thresh2; /* for non-uniform histograms */ + CvMatND mat; /* embedded matrix header for array histograms */ +} +CvHistogram; + +#define CV_IS_HIST( hist ) \ + ((hist) != NULL && \ + (((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \ + (hist)->bins != NULL) + +#define CV_IS_UNIFORM_HIST( hist ) \ + (((hist)->type & CV_HIST_UNIFORM_FLAG) != 0) + +#define CV_IS_SPARSE_HIST( hist ) \ + CV_IS_SPARSE_MAT((hist)->bins) + +#define CV_HIST_HAS_RANGES( hist ) \ + (((hist)->type & CV_HIST_RANGES_FLAG) != 0) + +/****************************************************************************************\ +* Other supplementary data type definitions * +\****************************************************************************************/ + +/*************************************** CvRect *****************************************/ + +typedef struct CvRect +{ + int x; + int y; + int width; + int height; +} +CvRect; + +CV_INLINE CvRect cvRect( int x, int y, int width, int height ) +{ + CvRect r; + + r.x = x; + r.y = y; + r.width = width; + r.height = height; + + return r; +} + + +CV_INLINE IplROI cvRectToROI( CvRect rect, int coi ) +{ + IplROI roi; + roi.xOffset = rect.x; + roi.yOffset = rect.y; + roi.width = rect.width; + roi.height = rect.height; + roi.coi = coi; + + return roi; +} + + +CV_INLINE CvRect cvROIToRect( IplROI roi ) +{ + return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height ); +} + +/*********************************** CvTermCriteria *************************************/ + +#define CV_TERMCRIT_ITER 1 +#define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER +#define CV_TERMCRIT_EPS 2 + +typedef struct CvTermCriteria +{ + int type; /* may be combination of + CV_TERMCRIT_ITER + CV_TERMCRIT_EPS */ + int max_iter; + double epsilon; +} +CvTermCriteria; + +CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon ) +{ + CvTermCriteria t; + + t.type = type; + t.max_iter = max_iter; + t.epsilon = (float)epsilon; + + return t; +} + + +/******************************* CvPoint and variants ***********************************/ + +typedef struct CvPoint +{ + int x; + int y; +} +CvPoint; + + +CV_INLINE CvPoint cvPoint( int x, int y ) +{ + CvPoint p; + + p.x = x; + p.y = y; + + return p; +} + + +typedef struct CvPoint2D32f +{ + float x; + float y; +} +CvPoint2D32f; + + +CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y ) +{ + CvPoint2D32f p; + + p.x = (float)x; + p.y = (float)y; + + return p; +} + + +CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point ) +{ + return cvPoint2D32f( (float)point.x, (float)point.y ); +} + + +CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point ) +{ + CvPoint ipt; + ipt.x = cvRound(point.x); + ipt.y = cvRound(point.y); + + return ipt; +} + + +typedef struct CvPoint3D32f +{ + float x; + float y; + float z; +} +CvPoint3D32f; + + +CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z ) +{ + CvPoint3D32f p; + + p.x = (float)x; + p.y = (float)y; + p.z = (float)z; + + return p; +} + + +typedef struct CvPoint2D64f +{ + double x; + double y; +} +CvPoint2D64f; + + +CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y ) +{ + CvPoint2D64f p; + + p.x = x; + p.y = y; + + return p; +} + + +typedef struct CvPoint3D64f +{ + double x; + double y; + double z; +} +CvPoint3D64f; + + +CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z ) +{ + CvPoint3D64f p; + + p.x = x; + p.y = y; + p.z = z; + + return p; +} + + +/******************************** CvSize's & CvBox **************************************/ + +typedef struct +{ + int width; + int height; +} +CvSize; + +CV_INLINE CvSize cvSize( int width, int height ) +{ + CvSize s; + + s.width = width; + s.height = height; + + return s; +} + +typedef struct CvSize2D32f +{ + float width; + float height; +} +CvSize2D32f; + + +CV_INLINE CvSize2D32f cvSize2D32f( double width, double height ) +{ + CvSize2D32f s; + + s.width = (float)width; + s.height = (float)height; + + return s; +} + +typedef struct CvBox2D +{ + CvPoint2D32f center; /* center of the box */ + CvSize2D32f size; /* box width and length */ + float angle; /* angle between the horizontal axis + and the first side (i.e. length) in degrees */ +} +CvBox2D; + + +/* Line iterator state */ +typedef struct CvLineIterator +{ + /* pointer to the current point */ + uchar* ptr; + + /* Bresenham algorithm state */ + int err; + int plus_delta; + int minus_delta; + int plus_step; + int minus_step; +} +CvLineIterator; + + + +/************************************* CvSlice ******************************************/ + +typedef struct CvSlice +{ + int start_index, end_index; +} +CvSlice; + +CV_INLINE CvSlice cvSlice( int start, int end ) +{ + CvSlice slice; + slice.start_index = start; + slice.end_index = end; + + return slice; +} + +#define CV_WHOLE_SEQ_END_INDEX 0x3fffffff +#define CV_WHOLE_SEQ cvSlice(0, CV_WHOLE_SEQ_END_INDEX) + + +/************************************* CvScalar *****************************************/ + +typedef struct CvScalar +{ + double val[4]; +} +CvScalar; + +CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0), + double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0)) +{ + CvScalar scalar; + scalar.val[0] = val0; scalar.val[1] = val1; + scalar.val[2] = val2; scalar.val[3] = val3; + return scalar; +} + + +CV_INLINE CvScalar cvRealScalar( double val0 ) +{ + CvScalar scalar; + scalar.val[0] = val0; + scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; + return scalar; +} + +CV_INLINE CvScalar cvScalarAll( double val0123 ) +{ + CvScalar scalar; + scalar.val[0] = val0123; + scalar.val[1] = val0123; + scalar.val[2] = val0123; + scalar.val[3] = val0123; + return scalar; +} + +/****************************************************************************************\ +* Dynamic Data structures * +\****************************************************************************************/ + +/******************************** Memory storage ****************************************/ + +typedef struct CvMemBlock +{ + struct CvMemBlock* prev; + struct CvMemBlock* next; +} +CvMemBlock; + +#define CV_STORAGE_MAGIC_VAL 0x42890000 + +typedef struct CvMemStorage +{ + int signature; + CvMemBlock* bottom;/* first allocated block */ + CvMemBlock* top; /* current memory block - top of the stack */ + struct CvMemStorage* parent; /* borrows new blocks from */ + int block_size; /* block size */ + int free_space; /* free space in the current block */ +} +CvMemStorage; + +#define CV_IS_STORAGE(storage) \ + ((storage) != NULL && \ + (((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) == CV_STORAGE_MAGIC_VAL) + + +typedef struct CvMemStoragePos +{ + CvMemBlock* top; + int free_space; +} +CvMemStoragePos; + + +/*********************************** Sequence *******************************************/ + +typedef struct CvSeqBlock +{ + struct CvSeqBlock* prev; /* previous sequence block */ + struct CvSeqBlock* next; /* next sequence block */ + int start_index; /* index of the first element in the block + + sequence->first->start_index */ + int count; /* number of elements in the block */ + char* data; /* pointer to the first element of the block */ +} +CvSeqBlock; + + +#define CV_TREE_NODE_FIELDS(node_type) \ + int flags; /* micsellaneous flags */ \ + int header_size; /* size of sequence header */ \ + struct node_type* h_prev; /* previous sequence */ \ + struct node_type* h_next; /* next sequence */ \ + struct node_type* v_prev; /* 2nd previous sequence */ \ + struct node_type* v_next /* 2nd next sequence */ + +/* + Read/Write sequence. + Elements can be dynamically inserted to or deleted from the sequence. +*/ +#define CV_SEQUENCE_FIELDS() \ + CV_TREE_NODE_FIELDS(CvSeq); \ + int total; /* total number of elements */ \ + int elem_size; /* size of sequence element in bytes */ \ + char* block_max; /* maximal bound of the last block */ \ + char* ptr; /* current write pointer */ \ + int delta_elems; /* how many elements allocated when the seq grows */ \ + CvMemStorage* storage; /* where the seq is stored */ \ + CvSeqBlock* free_blocks; /* free blocks list */ \ + CvSeqBlock* first; /* pointer to the first sequence block */ + +typedef struct CvSeq +{ + CV_SEQUENCE_FIELDS() +} +CvSeq; + +#define CV_TYPE_NAME_SEQ "opencv-sequence" +#define CV_TYPE_NAME_SEQ_TREE "opencv-sequence-tree" + +/*************************************** Set ********************************************/ +/* + Set. + Order is not preserved. There can be gaps between sequence elements. + After the element has been inserted it stays in the same place all the time. + The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists. +*/ +#define CV_SET_ELEM_FIELDS(elem_type) \ + int flags; \ + struct elem_type* next_free; + +typedef struct CvSetElem +{ + CV_SET_ELEM_FIELDS(CvSetElem) +} +CvSetElem; + +#define CV_SET_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvSetElem* free_elems; \ + int active_count; + +typedef struct CvSet +{ + CV_SET_FIELDS() +} +CvSet; + + +#define CV_SET_ELEM_IDX_MASK ((1 << 26) - 1) +#define CV_SET_ELEM_FREE_FLAG (1 << (sizeof(int)*8-1)) + +/* Checks whether the element pointed by ptr belongs to a set or not */ +#define CV_IS_SET_ELEM( ptr ) (((CvSetElem*)(ptr))->flags >= 0) + +/************************************* Graph ********************************************/ + +/* + Graph is represented as a set of vertices. + Vertices contain their adjacency lists (more exactly, pointers to first incoming or + outcoming edge (or 0 if isolated vertex)). Edges are stored in another set. + There is a single-linked list of incoming/outcoming edges for each vertex. + + Each edge consists of: + two pointers to the starting and the ending vertices (vtx[0] and vtx[1], + respectively). Graph may be oriented or not. In the second case, edges between + vertex i to vertex j are not distingueshed (during the search operations). + + two pointers to next edges for the starting and the ending vertices. + next[0] points to the next edge in the vtx[0] adjacency list and + next[1] points to the next edge in the vtx[1] adjacency list. +*/ +#define CV_GRAPH_EDGE_FIELDS() \ + int flags; \ + float weight; \ + struct CvGraphEdge* next[2]; \ + struct CvGraphVtx* vtx[2]; + + +#define CV_GRAPH_VERTEX_FIELDS() \ + int flags; \ + struct CvGraphEdge* first; + + +typedef struct CvGraphEdge +{ + CV_GRAPH_EDGE_FIELDS() +} +CvGraphEdge; + +typedef struct CvGraphVtx +{ + CV_GRAPH_VERTEX_FIELDS() +} +CvGraphVtx; + +typedef struct CvGraphVtx2D +{ + CV_GRAPH_VERTEX_FIELDS() + CvPoint2D32f* ptr; +} +CvGraphVtx2D; + +/* + Graph is "derived" from the set (this is set a of vertices) + and includes another set (edges) +*/ +#define CV_GRAPH_FIELDS() \ + CV_SET_FIELDS() \ + CvSet* edges; + +typedef struct CvGraph +{ + CV_GRAPH_FIELDS() +} +CvGraph; + +#define CV_TYPE_NAME_GRAPH "opencv-graph" + +/*********************************** Chain/Countour *************************************/ + +typedef struct CvChain +{ + CV_SEQUENCE_FIELDS() + CvPoint origin; +} +CvChain; + +#define CV_CONTOUR_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvRect rect; \ + int color; \ + int reserved[3]; + +typedef struct CvContour +{ + CV_CONTOUR_FIELDS() +} +CvContour; + +typedef CvContour CvPoint2DSeq; + +/****************************************************************************************\ +* Sequence types * +\****************************************************************************************/ + +#define CV_SEQ_MAGIC_VAL 0x42990000 + +#define CV_IS_SEQ(seq) \ + ((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL) + +#define CV_SET_MAGIC_VAL 0x42980000 +#define CV_IS_SET(set) \ + ((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL) + +#define CV_SEQ_ELTYPE_BITS 9 +#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1) + +#define CV_SEQ_ELTYPE_POINT CV_32SC2 /* (x,y) */ +#define CV_SEQ_ELTYPE_CODE CV_8UC1 /* freeman code: 0..7 */ +#define CV_SEQ_ELTYPE_GENERIC 0 +#define CV_SEQ_ELTYPE_PTR CV_USRTYPE1 +#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /* &(x,y) */ +#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /* #(x,y) */ +#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /* &next_o, &next_d, &vtx_o, &vtx_d */ +#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /* first_edge, &(x,y) */ +#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /* vertex of the binary tree */ +#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /* connected component */ +#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /* (x,y,z) */ + +#define CV_SEQ_KIND_BITS 3 +#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<flags & CV_SEQ_ELTYPE_MASK) +#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK ) + +/* flag checking */ +#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC)) + +#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE) +#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0) +#define CV_IS_SEQ_CONVEX( seq ) (((seq)->flags & CV_SEQ_FLAG_CONVEX) != 0) +#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0) +#define CV_IS_SEQ_SIMPLE( seq ) ((((seq)->flags & CV_SEQ_FLAG_SIMPLE) != 0) || \ + CV_IS_SEQ_CONVEX(seq)) + +/* type checking macros */ +#define CV_IS_SEQ_POINT_SET( seq ) \ + ((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2)) + +#define CV_IS_SEQ_POINT_SUBSET( seq ) \ + (CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT) + +#define CV_IS_SEQ_POLYLINE( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq)) + +#define CV_IS_SEQ_POLYGON( seq ) \ + (CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq)) + +#define CV_IS_SEQ_CHAIN( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1) + +#define CV_IS_SEQ_CONTOUR( seq ) \ + (CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq))) + +#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \ + (CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq )) + +#define CV_IS_SEQ_POLYGON_TREE( seq ) \ + (CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \ + CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE ) + +#define CV_IS_GRAPH( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH) + +#define CV_IS_GRAPH_ORIENTED( seq ) \ + (((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0) + +#define CV_IS_SUBDIV2D( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D) + +/****************************************************************************************/ +/* Sequence writer & reader */ +/****************************************************************************************/ + +#define CV_SEQ_WRITER_FIELDS() \ + int header_size; \ + CvSeq* seq; /* the sequence written */ \ + CvSeqBlock* block; /* current block */ \ + char* ptr; /* pointer to free space */ \ + char* block_min; /* pointer to the beginning of block*/\ + char* block_max; /* pointer to the end of block */ + +typedef struct CvSeqWriter +{ + CV_SEQ_WRITER_FIELDS() +} +CvSeqWriter; + + +#define CV_SEQ_READER_FIELDS() \ + int header_size; \ + CvSeq* seq; /* sequence, beign read */ \ + CvSeqBlock* block; /* current block */ \ + char* ptr; /* pointer to element be read next */ \ + char* block_min; /* pointer to the beginning of block */\ + char* block_max; /* pointer to the end of block */ \ + int delta_index;/* = seq->first->start_index */ \ + char* prev_elem; /* pointer to previous element */ + + +typedef struct CvSeqReader +{ + CV_SEQ_READER_FIELDS() +} +CvSeqReader; + +/****************************************************************************************/ +/* Operations on sequences */ +/****************************************************************************************/ + +#define CV_SEQ_ELEM( seq, elem_type, index ) \ +/* assert gives some guarantee that parameter is valid */ \ +( assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && \ + (seq)->elem_size == sizeof(elem_type)), \ + (elem_type*)((seq)->first && (unsigned)index < \ + (unsigned)((seq)->first->count) ? \ + (seq)->first->data + (index) * sizeof(elem_type) : \ + cvGetSeqElem( (CvSeq*)(seq), (index) ))) +#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) ) + +/* macro that adds element to sequence */ +#define CV_WRITE_SEQ_ELEM_VAR( elem_ptr, writer ) \ +{ \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + memcpy((writer).ptr, elem_ptr, (writer).seq->elem_size);\ + (writer).ptr += (writer).seq->elem_size; \ +} + +#define CV_WRITE_SEQ_ELEM( elem, writer ) \ +{ \ + assert( (writer).seq->elem_size == sizeof(elem)); \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + assert( (writer).ptr <= (writer).block_max - sizeof(elem));\ + memcpy((writer).ptr, &(elem), sizeof(elem)); \ + (writer).ptr += sizeof(elem); \ +} + + +/* move reader position forward */ +#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr += (elem_size)) >= (reader).block_max ) \ + { \ + cvChangeSeqBlock( &(reader), 1 ); \ + } \ +} + + +/* move reader position backward */ +#define CV_PREV_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr -= (elem_size)) < (reader).block_min ) \ + { \ + cvChangeSeqBlock( &(reader), -1 ); \ + } \ +} + +/* read element and move read position forward */ +#define CV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy( &(elem), (reader).ptr, sizeof((elem))); \ + CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \ +} + +/* read element and move read position backward */ +#define CV_REV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy(&(elem), (reader).ptr, sizeof((elem))); \ + CV_PREV_SEQ_ELEM( sizeof(elem), reader ) \ +} + + +#define CV_READ_CHAIN_POINT( _pt, reader ) \ +{ \ + (_pt) = (reader).pt; \ + if( (reader).ptr ) \ + { \ + CV_READ_SEQ_ELEM( (reader).code, (reader)); \ + assert( ((reader).code & ~7) == 0 ); \ + (reader).pt.x += (reader).deltas[(int)(reader).code][0]; \ + (reader).pt.y += (reader).deltas[(int)(reader).code][1]; \ + } \ +} + +#define CV_CURRENT_POINT( reader ) (*((CvPoint*)((reader).ptr))) +#define CV_PREV_POINT( reader ) (*((CvPoint*)((reader).prev_elem))) + +#define CV_READ_EDGE( pt1, pt2, reader ) \ +{ \ + assert( sizeof(pt1) == sizeof(CvPoint) && \ + sizeof(pt2) == sizeof(CvPoint) && \ + reader.seq->elem_size == sizeof(CvPoint)); \ + (pt1) = CV_PREV_POINT( reader ); \ + (pt2) = CV_CURRENT_POINT( reader ); \ + (reader).prev_elem = (reader).ptr; \ + CV_NEXT_SEQ_ELEM( sizeof(CvPoint), (reader)); \ +} + +/************ Graph macros ************/ + +/* returns next graph edge for given vertex */ +#define CV_NEXT_GRAPH_EDGE( edge, vertex ) \ + (assert((edge)->vtx[0] == (vertex) || (edge)->vtx[1] == (vertex)), \ + (edge)->next[(edge)->vtx[1] == (vertex)]) + + + +/****************************************************************************************\ +* Data structures for persistence (a.k.a serialization) functionality * +\****************************************************************************************/ + +/* "black box" file storage */ +typedef struct CvFileStorage CvFileStorage; + +/* storage flags */ +#define CV_STORAGE_READ 0 +#define CV_STORAGE_WRITE 1 +#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE +#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE +#define CV_STORAGE_APPEND 2 + +/* list of attributes */ +typedef struct CvAttrList +{ + const char** attr; /* NULL-terminated array of (attribute_name,attribute_value) pairs */ + struct CvAttrList* next; /* pointer to next chunk of the attributes list */ +} +CvAttrList; + +CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL), + CvAttrList* next CV_DEFAULT(NULL) ) +{ + CvAttrList l; + l.attr = attr; + l.next = next; + + return l; +} + +struct CvTypeInfo; + +#define CV_NODE_NONE 0 +#define CV_NODE_INT 1 +#define CV_NODE_INTEGER CV_NODE_INT +#define CV_NODE_REAL 2 +#define CV_NODE_FLOAT CV_NODE_REAL +#define CV_NODE_STR 3 +#define CV_NODE_STRING CV_NODE_STR +#define CV_NODE_REF 4 /* not used */ +#define CV_NODE_SEQ 5 +#define CV_NODE_MAP 6 +#define CV_NODE_TYPE_MASK 7 + +#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK) + +/* file node flags */ +#define CV_NODE_FLOW 8 /* used only for writing structures to YAML format */ +#define CV_NODE_USER 16 +#define CV_NODE_EMPTY 32 +#define CV_NODE_NAMED 64 + +#define CV_NODE_IS_INT(flags) (CV_NODE_TYPE(flags) == CV_NODE_INT) +#define CV_NODE_IS_REAL(flags) (CV_NODE_TYPE(flags) == CV_NODE_REAL) +#define CV_NODE_IS_STRING(flags) (CV_NODE_TYPE(flags) == CV_NODE_STRING) +#define CV_NODE_IS_SEQ(flags) (CV_NODE_TYPE(flags) == CV_NODE_SEQ) +#define CV_NODE_IS_MAP(flags) (CV_NODE_TYPE(flags) == CV_NODE_MAP) +#define CV_NODE_IS_COLLECTION(flags) (CV_NODE_TYPE(flags) >= CV_NODE_SEQ) +#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0) +#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0) +#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0) +#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0) + +#define CV_NODE_SEQ_SIMPLE 256 +#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0) + +typedef struct CvString +{ + int len; + char* ptr; +} +CvString; + +/* all the keys (names) of elements in the readed file storage + are stored in the hash to speed up the lookup operations */ +typedef struct CvStringHashNode +{ + unsigned hashval; + CvString str; + struct CvStringHashNode* next; +} +CvStringHashNode; + +typedef struct CvGenericHash CvFileNodeHash; + +/* basic element of the file storage - scalar or collection */ +typedef struct CvFileNode +{ + int tag; + struct CvTypeInfo* info; /* type information + (only for user-defined object, for others it is 0) */ + union + { + double f; /* scalar floating-point number */ + int i; /* scalar integer number */ + CvString str; /* text string */ + CvSeq* seq; /* sequence (ordered collection of file nodes) */ + CvFileNodeHash* map; /* map (collection of named file nodes) */ + } data; +} +CvFileNode; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr ); +typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr ); +typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); +typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name, + const void* struct_ptr, CvAttrList attributes ); +typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); +#ifdef __cplusplus +} +#endif + +typedef struct CvTypeInfo +{ + int flags; + int header_size; + struct CvTypeInfo* prev; + struct CvTypeInfo* next; + const char* type_name; + CvIsInstanceFunc is_instance; + CvReleaseFunc release; + CvReadFunc read; + CvWriteFunc write; + CvCloneFunc clone; +} +CvTypeInfo; + + +/**** System data types ******/ + +typedef struct CvPluginFuncInfo +{ + void** func_addr; + void* default_func_addr; + const char* func_names; + int search_modules; + int loaded_from; +} +CvPluginFuncInfo; + +typedef struct CvModuleInfo +{ + struct CvModuleInfo* next; + const char* name; + const char* version; + CvPluginFuncInfo* func_tab; +} +CvModuleInfo; + +#endif /*_CXCORE_TYPES_H_*/ + +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/highgui.h b/libraries/external/opencv/linux/include/highgui.h new file mode 100755 index 0000000..aa004e9 --- /dev/null +++ b/libraries/external/opencv/linux/include/highgui.h @@ -0,0 +1,486 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef _HIGH_GUI_ +#define _HIGH_GUI_ + +#ifndef SKIP_INCLUDES + + #include "cxcore.h" + #if defined WIN32 || defined WIN64 + #include + #endif + +#else // SKIP_INCLUDES + + #if defined WIN32 || defined WIN64 + #define CV_CDECL __cdecl + #define CV_STDCALL __stdcall + #else + #define CV_CDECL + #define CV_STDCALL + #endif + + #ifndef CV_EXTERN_C + #ifdef __cplusplus + #define CV_EXTERN_C extern "C" + #define CV_DEFAULT(val) = val + #else + #define CV_EXTERN_C + #define CV_DEFAULT(val) + #endif + #endif + + #ifndef CV_EXTERN_C_FUNCPTR + #ifdef __cplusplus + #define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } + #else + #define CV_EXTERN_C_FUNCPTR(x) typedef x + #endif + #endif + + #ifndef CV_INLINE + #if defined __cplusplus + #define CV_INLINE inline + #elif (defined WIN32 || defined WIN64) && !defined __GNUC__ + #define CV_INLINE __inline + #else + #define CV_INLINE static inline + #endif + #endif /* CV_INLINE */ + + #if (defined WIN32 || defined WIN64) && defined CVAPI_EXPORTS + #define CV_EXPORTS __declspec(dllexport) + #else + #define CV_EXPORTS + #endif + + #ifndef CVAPI + #define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL + #endif + +#endif // SKIP_INCLUDES + +#if defined(_CH_) + #pragma package + #include + LOAD_CHDL(highgui) +#endif + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + +/****************************************************************************************\ +* Basic GUI functions * +\****************************************************************************************/ + +/* this function is used to set some external parameters in case of X Window */ +CVAPI(int) cvInitSystem( int argc, char** argv ); + +CVAPI(int) cvStartWindowThread(); + +#define CV_WINDOW_AUTOSIZE 1 +/* create window */ +CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) ); + +/* display image within window (highgui windows remember their content) */ +CVAPI(void) cvShowImage( const char* name, const CvArr* image ); + +/* resize/move window */ +CVAPI(void) cvResizeWindow( const char* name, int width, int height ); +CVAPI(void) cvMoveWindow( const char* name, int x, int y ); + + +/* destroy window and all the trackers associated with it */ +CVAPI(void) cvDestroyWindow( const char* name ); + +CVAPI(void) cvDestroyAllWindows(void); + +/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */ +CVAPI(void*) cvGetWindowHandle( const char* name ); + +/* get name of highgui window given its native handle */ +CVAPI(const char*) cvGetWindowName( void* window_handle ); + + +typedef void (CV_CDECL *CvTrackbarCallback)(int pos); + +/* create trackbar and display it on top of given window, set callback */ +CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name, + int* value, int count, CvTrackbarCallback on_change ); + +/* retrieve or set trackbar position */ +CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name ); +CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos ); + +#define CV_EVENT_MOUSEMOVE 0 +#define CV_EVENT_LBUTTONDOWN 1 +#define CV_EVENT_RBUTTONDOWN 2 +#define CV_EVENT_MBUTTONDOWN 3 +#define CV_EVENT_LBUTTONUP 4 +#define CV_EVENT_RBUTTONUP 5 +#define CV_EVENT_MBUTTONUP 6 +#define CV_EVENT_LBUTTONDBLCLK 7 +#define CV_EVENT_RBUTTONDBLCLK 8 +#define CV_EVENT_MBUTTONDBLCLK 9 + +#define CV_EVENT_FLAG_LBUTTON 1 +#define CV_EVENT_FLAG_RBUTTON 2 +#define CV_EVENT_FLAG_MBUTTON 4 +#define CV_EVENT_FLAG_CTRLKEY 8 +#define CV_EVENT_FLAG_SHIFTKEY 16 +#define CV_EVENT_FLAG_ALTKEY 32 + +typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param); + +/* assign callback for mouse events */ +CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, + void* param CV_DEFAULT(NULL)); + +/* 8bit, color or not */ +#define CV_LOAD_IMAGE_UNCHANGED -1 +/* 8bit, gray */ +#define CV_LOAD_IMAGE_GRAYSCALE 0 +/* ?, color */ +#define CV_LOAD_IMAGE_COLOR 1 +/* any depth, ? */ +#define CV_LOAD_IMAGE_ANYDEPTH 2 +/* ?, any color */ +#define CV_LOAD_IMAGE_ANYCOLOR 4 + +/* load image from file + iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED + overrides the other flags + using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED + unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit +*/ +CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); +CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); + +/* save image to file */ +CVAPI(int) cvSaveImage( const char* filename, const CvArr* image ); + +#define CV_CVTIMG_FLIP 1 +#define CV_CVTIMG_SWAP_RB 2 +/* utility function: convert one image to another with optional vertical flip */ +CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0)); + +/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */ +CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0)); + + +/****************************************************************************************\ +* Working with Video Files and Cameras * +\****************************************************************************************/ + +/* "black box" capture structure */ +typedef struct CvCapture CvCapture; + +/* start capturing frames from video file */ +CVAPI(CvCapture*) cvCreateFileCapture( const char* filename ); + +#define CV_CAP_ANY 0 // autodetect + +#define CV_CAP_MIL 100 // MIL proprietary drivers + +#define CV_CAP_VFW 200 // platform native +#define CV_CAP_V4L 200 +#define CV_CAP_V4L2 200 + +#define CV_CAP_FIREWARE 300 // IEEE 1394 drivers +#define CV_CAP_IEEE1394 300 +#define CV_CAP_DC1394 300 +#define CV_CAP_CMU1394 300 + +#define CV_CAP_STEREO 400 // TYZX proprietary drivers +#define CV_CAP_TYZX 400 +#define CV_TYZX_LEFT 400 +#define CV_TYZX_RIGHT 401 +#define CV_TYZX_COLOR 402 +#define CV_TYZX_Z 403 + +#define CV_CAP_QT 500 // QuickTime + +/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */ +CVAPI(CvCapture*) cvCreateCameraCapture( int index ); + +/* grab a frame, return 1 on success, 0 on fail. + this function is thought to be fast */ +CVAPI(int) cvGrabFrame( CvCapture* capture ); + +/* get the frame grabbed with cvGrabFrame(..) + This function may apply some frame processing like + frame decompression, flipping etc. + !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */ +CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture ); + +/* Just a combination of cvGrabFrame and cvRetrieveFrame + !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */ +CVAPI(IplImage*) cvQueryFrame( CvCapture* capture ); + +/* stop capturing/reading and free resources */ +CVAPI(void) cvReleaseCapture( CvCapture** capture ); + +#define CV_CAP_PROP_POS_MSEC 0 +#define CV_CAP_PROP_POS_FRAMES 1 +#define CV_CAP_PROP_POS_AVI_RATIO 2 +#define CV_CAP_PROP_FRAME_WIDTH 3 +#define CV_CAP_PROP_FRAME_HEIGHT 4 +#define CV_CAP_PROP_FPS 5 +#define CV_CAP_PROP_FOURCC 6 +#define CV_CAP_PROP_FRAME_COUNT 7 +#define CV_CAP_PROP_FORMAT 8 +#define CV_CAP_PROP_MODE 9 +#define CV_CAP_PROP_BRIGHTNESS 10 +#define CV_CAP_PROP_CONTRAST 11 +#define CV_CAP_PROP_SATURATION 12 +#define CV_CAP_PROP_HUE 13 +#define CV_CAP_PROP_GAIN 14 +#define CV_CAP_PROP_CONVERT_RGB 15 + + +/* retrieve or set capture properties */ +CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id ); +CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value ); + +/* "black box" video file writer structure */ +typedef struct CvVideoWriter CvVideoWriter; + +#define CV_FOURCC(c1,c2,c3,c4) \ + (((c1)&255) + (((c2)&255)<<8) + (((c3)&255)<<16) + (((c4)&255)<<24)) + +/* initialize video file writer */ +CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc, + double fps, CvSize frame_size, + int is_color CV_DEFAULT(1)); + +/* write frame to video file */ +CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image ); + +/* close video file writer */ +CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer ); + +/****************************************************************************************\ +* Obsolete functions/synonyms * +\****************************************************************************************/ + +#ifndef HIGHGUI_NO_BACKWARD_COMPATIBILITY + #define HIGHGUI_BACKWARD_COMPATIBILITY +#endif + +#ifdef HIGHGUI_BACKWARD_COMPATIBILITY + +#define cvCaptureFromFile cvCreateFileCapture +#define cvCaptureFromCAM cvCreateCameraCapture +#define cvCaptureFromAVI cvCaptureFromFile +#define cvCreateAVIWriter cvCreateVideoWriter +#define cvWriteToAVI cvWriteFrame +#define cvAddSearchPath(path) +#define cvvInitSystem cvInitSystem +#define cvvNamedWindow cvNamedWindow +#define cvvShowImage cvShowImage +#define cvvResizeWindow cvResizeWindow +#define cvvDestroyWindow cvDestroyWindow +#define cvvCreateTrackbar cvCreateTrackbar +#define cvvLoadImage(name) cvLoadImage((name),1) +#define cvvSaveImage cvSaveImage +#define cvvAddSearchPath cvAddSearchPath +#define cvvWaitKey(name) cvWaitKey(0) +#define cvvWaitKeyEx(name,delay) cvWaitKey(delay) +#define cvvConvertImage cvConvertImage +#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE +#define set_preprocess_func cvSetPreprocessFuncWin32 +#define set_postprocess_func cvSetPostprocessFuncWin32 + +#ifdef WIN32 + +typedef int (CV_CDECL * CvWin32WindowCallback)(HWND, UINT, WPARAM, LPARAM, int*); +CVAPI(void) cvSetPreprocessFuncWin32( CvWin32WindowCallback on_preprocess ); +CVAPI(void) cvSetPostprocessFuncWin32( CvWin32WindowCallback on_postprocess ); + +CV_INLINE int iplWidth( const IplImage* img ); +CV_INLINE int iplWidth( const IplImage* img ) +{ + return !img ? 0 : !img->roi ? img->width : img->roi->width; +} + +CV_INLINE int iplHeight( const IplImage* img ); +CV_INLINE int iplHeight( const IplImage* img ) +{ + return !img ? 0 : !img->roi ? img->height : img->roi->height; +} + +#endif + +#endif /* obsolete functions */ + +/* For use with Win32 */ +#ifdef WIN32 + +CV_INLINE RECT NormalizeRect( RECT r ); +CV_INLINE RECT NormalizeRect( RECT r ) +{ + int t; + + if( r.left > r.right ) + { + t = r.left; + r.left = r.right; + r.right = t; + } + + if( r.top > r.bottom ) + { + t = r.top; + r.top = r.bottom; + r.bottom = t; + } + + return r; +} + +CV_INLINE CvRect RectToCvRect( RECT sr ); +CV_INLINE CvRect RectToCvRect( RECT sr ) +{ + sr = NormalizeRect( sr ); + return cvRect( sr.left, sr.top, sr.right - sr.left, sr.bottom - sr.top ); +} + +CV_INLINE RECT CvRectToRect( CvRect sr ); +CV_INLINE RECT CvRectToRect( CvRect sr ) +{ + RECT dr; + dr.left = sr.x; + dr.top = sr.y; + dr.right = sr.x + sr.width; + dr.bottom = sr.y + sr.height; + + return dr; +} + +CV_INLINE IplROI RectToROI( RECT r ); +CV_INLINE IplROI RectToROI( RECT r ) +{ + IplROI roi; + r = NormalizeRect( r ); + roi.xOffset = r.left; + roi.yOffset = r.top; + roi.width = r.right - r.left; + roi.height = r.bottom - r.top; + roi.coi = 0; + + return roi; +} + +#endif /* WIN32 */ + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif /* __cplusplus */ + + +#if defined __cplusplus && (!defined WIN32 || !defined (__GNUC__)) + +#define CImage CvvImage + +/* CvvImage class definition */ +class CV_EXPORTS CvvImage +{ +public: + CvvImage(); + virtual ~CvvImage(); + + /* Create image (BGR or grayscale) */ + virtual bool Create( int width, int height, int bits_per_pixel, int image_origin = 0 ); + + /* Load image from specified file */ + virtual bool Load( const char* filename, int desired_color = 1 ); + + /* Load rectangle from the file */ + virtual bool LoadRect( const char* filename, + int desired_color, CvRect r ); + +#ifdef WIN32 + virtual bool LoadRect( const char* filename, + int desired_color, RECT r ) + { + return LoadRect( filename, desired_color, + cvRect( r.left, r.top, r.right - r.left, r.bottom - r.top )); + } +#endif + + /* Save entire image to specified file. */ + virtual bool Save( const char* filename ); + + /* Get copy of input image ROI */ + virtual void CopyOf( CvvImage& image, int desired_color = -1 ); + virtual void CopyOf( IplImage* img, int desired_color = -1 ); + + IplImage* GetImage() { return m_img; }; + virtual void Destroy(void); + + /* width and height of ROI */ + int Width() { return !m_img ? 0 : !m_img->roi ? m_img->width : m_img->roi->width; }; + int Height() { return !m_img ? 0 : !m_img->roi ? m_img->height : m_img->roi->height;}; + int Bpp() { return m_img ? (m_img->depth & 255)*m_img->nChannels : 0; }; + + virtual void Fill( int color ); + + /* draw to highgui window */ + virtual void Show( const char* window ); + +#ifdef WIN32 + /* draw part of image to the specified DC */ + virtual void Show( HDC dc, int x, int y, int width, int height, + int from_x = 0, int from_y = 0 ); + /* draw the current image ROI to the specified rectangle of the destination DC */ + virtual void DrawToHDC( HDC hDCDst, RECT* pDstRect ); +#endif + +protected: + + IplImage* m_img; +}; + +#endif /* __cplusplus */ + +#endif /* _HIGH_GUI_ */ diff --git a/libraries/external/opencv/linux/include/ml.h b/libraries/external/opencv/linux/include/ml.h new file mode 100755 index 0000000..fdf6fa6 --- /dev/null +++ b/libraries/external/opencv/linux/include/ml.h @@ -0,0 +1,1476 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __ML_H__ +#define __ML_H__ + +// disable deprecation warning which appears in VisualStudio 8.0 +#if _MSC_VER >= 1400 +#pragma warning( disable : 4996 ) +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Main struct definitions * +\****************************************************************************************/ + +/* log(2*PI) */ +#define CV_LOG2PI (1.8378770664093454835606594728112) + +/* columns of matrix are training samples */ +#define CV_COL_SAMPLE 0 + +/* rows of matrix are training samples */ +#define CV_ROW_SAMPLE 1 + +#define CV_IS_ROW_SAMPLE(flags) ((flags) & CV_ROW_SAMPLE) + +struct CvVectors +{ + int type; + int dims, count; + CvVectors* next; + union + { + uchar** ptr; + float** fl; + double** db; + } data; +}; + +#if 0 +/* A structure, representing the lattice range of statmodel parameters. + It is used for optimizing statmodel parameters by cross-validation method. + The lattice is logarithmic, so must be greater then 1. */ +typedef struct CvParamLattice +{ + double min_val; + double max_val; + double step; +} +CvParamLattice; + +CV_INLINE CvParamLattice cvParamLattice( double min_val, double max_val, + double log_step ) +{ + CvParamLattice pl; + pl.min_val = MIN( min_val, max_val ); + pl.max_val = MAX( min_val, max_val ); + pl.step = MAX( log_step, 1. ); + return pl; +} + +CV_INLINE CvParamLattice cvDefaultParamLattice( void ) +{ + CvParamLattice pl = {0,0,0}; + return pl; +} +#endif + +/* Variable type */ +#define CV_VAR_NUMERICAL 0 +#define CV_VAR_ORDERED 0 +#define CV_VAR_CATEGORICAL 1 + +#define CV_TYPE_NAME_ML_SVM "opencv-ml-svm" +#define CV_TYPE_NAME_ML_KNN "opencv-ml-knn" +#define CV_TYPE_NAME_ML_NBAYES "opencv-ml-bayesian" +#define CV_TYPE_NAME_ML_EM "opencv-ml-em" +#define CV_TYPE_NAME_ML_BOOSTING "opencv-ml-boost-tree" +#define CV_TYPE_NAME_ML_TREE "opencv-ml-tree" +#define CV_TYPE_NAME_ML_ANN_MLP "opencv-ml-ann-mlp" +#define CV_TYPE_NAME_ML_CNN "opencv-ml-cnn" +#define CV_TYPE_NAME_ML_RTREES "opencv-ml-random-trees" + +class CV_EXPORTS CvStatModel +{ +public: + CvStatModel(); + virtual ~CvStatModel(); + + virtual void clear(); + + virtual void save( const char* filename, const char* name=0 ); + virtual void load( const char* filename, const char* name=0 ); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + +protected: + const char* default_model_name; +}; + + +/****************************************************************************************\ +* Normal Bayes Classifier * +\****************************************************************************************/ + +class CV_EXPORTS CvNormalBayesClassifier : public CvStatModel +{ +public: + CvNormalBayesClassifier(); + virtual ~CvNormalBayesClassifier(); + + CvNormalBayesClassifier( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx=0, const CvMat* _sample_idx=0 ); + + virtual bool train( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx = 0, const CvMat* _sample_idx=0, bool update=false ); + + virtual float predict( const CvMat* _samples, CvMat* results=0 ) const; + virtual void clear(); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + +protected: + int var_count, var_all; + CvMat* var_idx; + CvMat* cls_labels; + CvMat** count; + CvMat** sum; + CvMat** productsum; + CvMat** avg; + CvMat** inv_eigen_values; + CvMat** cov_rotate_mats; + CvMat* c; +}; + + +/****************************************************************************************\ +* K-Nearest Neighbour Classifier * +\****************************************************************************************/ + +// k Nearest Neighbors +class CV_EXPORTS CvKNearest : public CvStatModel +{ +public: + + CvKNearest(); + virtual ~CvKNearest(); + + CvKNearest( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _sample_idx=0, bool _is_regression=false, int max_k=32 ); + + virtual bool train( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _sample_idx=0, bool is_regression=false, + int _max_k=32, bool _update_base=false ); + + virtual float find_nearest( const CvMat* _samples, int k, CvMat* results=0, + const float** neighbors=0, CvMat* neighbor_responses=0, CvMat* dist=0 ) const; + + virtual void clear(); + int get_max_k() const; + int get_var_count() const; + int get_sample_count() const; + bool is_regression() const; + +protected: + + virtual float write_results( int k, int k1, int start, int end, + const float* neighbor_responses, const float* dist, CvMat* _results, + CvMat* _neighbor_responses, CvMat* _dist, Cv32suf* sort_buf ) const; + + virtual void find_neighbors_direct( const CvMat* _samples, int k, int start, int end, + float* neighbor_responses, const float** neighbors, float* dist ) const; + + + int max_k, var_count; + int total; + bool regression; + CvVectors* samples; +}; + +/****************************************************************************************\ +* Support Vector Machines * +\****************************************************************************************/ + +// SVM training parameters +struct CV_EXPORTS CvSVMParams +{ + CvSVMParams(); + CvSVMParams( int _svm_type, int _kernel_type, + double _degree, double _gamma, double _coef0, + double _C, double _nu, double _p, + CvMat* _class_weights, CvTermCriteria _term_crit ); + + int svm_type; + int kernel_type; + double degree; // for poly + double gamma; // for poly/rbf/sigmoid + double coef0; // for poly/sigmoid + + double C; // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR + double nu; // for CV_SVM_NU_SVC, CV_SVM_ONE_CLASS, and CV_SVM_NU_SVR + double p; // for CV_SVM_EPS_SVR + CvMat* class_weights; // for CV_SVM_C_SVC + CvTermCriteria term_crit; // termination criteria +}; + + +struct CV_EXPORTS CvSVMKernel +{ + typedef void (CvSVMKernel::*Calc)( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + CvSVMKernel(); + CvSVMKernel( const CvSVMParams* _params, Calc _calc_func ); + virtual bool create( const CvSVMParams* _params, Calc _calc_func ); + virtual ~CvSVMKernel(); + + virtual void clear(); + virtual void calc( int vcount, int n, const float** vecs, const float* another, float* results ); + + const CvSVMParams* params; + Calc calc_func; + + virtual void calc_non_rbf_base( int vec_count, int vec_size, const float** vecs, + const float* another, float* results, + double alpha, double beta ); + + virtual void calc_linear( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + virtual void calc_rbf( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + virtual void calc_poly( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); + virtual void calc_sigmoid( int vec_count, int vec_size, const float** vecs, + const float* another, float* results ); +}; + + +struct CvSVMKernelRow +{ + CvSVMKernelRow* prev; + CvSVMKernelRow* next; + float* data; +}; + + +struct CvSVMSolutionInfo +{ + double obj; + double rho; + double upper_bound_p; + double upper_bound_n; + double r; // for Solver_NU +}; + +class CV_EXPORTS CvSVMSolver +{ +public: + typedef bool (CvSVMSolver::*SelectWorkingSet)( int& i, int& j ); + typedef float* (CvSVMSolver::*GetRow)( int i, float* row, float* dst, bool existed ); + typedef void (CvSVMSolver::*CalcRho)( double& rho, double& r ); + + CvSVMSolver(); + + CvSVMSolver( int count, int var_count, const float** samples, char* y, + int alpha_count, double* alpha, double Cp, double Cn, + CvMemStorage* storage, CvSVMKernel* kernel, GetRow get_row, + SelectWorkingSet select_working_set, CalcRho calc_rho ); + virtual bool create( int count, int var_count, const float** samples, char* y, + int alpha_count, double* alpha, double Cp, double Cn, + CvMemStorage* storage, CvSVMKernel* kernel, GetRow get_row, + SelectWorkingSet select_working_set, CalcRho calc_rho ); + virtual ~CvSVMSolver(); + + virtual void clear(); + virtual bool solve_generic( CvSVMSolutionInfo& si ); + + virtual bool solve_c_svc( int count, int var_count, const float** samples, char* y, + double Cp, double Cn, CvMemStorage* storage, + CvSVMKernel* kernel, double* alpha, CvSVMSolutionInfo& si ); + virtual bool solve_nu_svc( int count, int var_count, const float** samples, char* y, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + virtual bool solve_one_class( int count, int var_count, const float** samples, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + + virtual bool solve_eps_svr( int count, int var_count, const float** samples, const float* y, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + + virtual bool solve_nu_svr( int count, int var_count, const float** samples, const float* y, + CvMemStorage* storage, CvSVMKernel* kernel, + double* alpha, CvSVMSolutionInfo& si ); + + virtual float* get_row_base( int i, bool* _existed ); + virtual float* get_row( int i, float* dst ); + + int sample_count; + int var_count; + int cache_size; + int cache_line_size; + const float** samples; + const CvSVMParams* params; + CvMemStorage* storage; + CvSVMKernelRow lru_list; + CvSVMKernelRow* rows; + + int alpha_count; + + double* G; + double* alpha; + + // -1 - lower bound, 0 - free, 1 - upper bound + char* alpha_status; + + char* y; + double* b; + float* buf[2]; + double eps; + int max_iter; + double C[2]; // C[0] == Cn, C[1] == Cp + CvSVMKernel* kernel; + + SelectWorkingSet select_working_set_func; + CalcRho calc_rho_func; + GetRow get_row_func; + + virtual bool select_working_set( int& i, int& j ); + virtual bool select_working_set_nu_svm( int& i, int& j ); + virtual void calc_rho( double& rho, double& r ); + virtual void calc_rho_nu_svm( double& rho, double& r ); + + virtual float* get_row_svc( int i, float* row, float* dst, bool existed ); + virtual float* get_row_one_class( int i, float* row, float* dst, bool existed ); + virtual float* get_row_svr( int i, float* row, float* dst, bool existed ); +}; + + +struct CvSVMDecisionFunc +{ + double rho; + int sv_count; + double* alpha; + int* sv_index; +}; + + +// SVM model +class CV_EXPORTS CvSVM : public CvStatModel +{ +public: + // SVM type + enum { C_SVC=100, NU_SVC=101, ONE_CLASS=102, EPS_SVR=103, NU_SVR=104 }; + + // SVM kernel type + enum { LINEAR=0, POLY=1, RBF=2, SIGMOID=3 }; + + CvSVM(); + virtual ~CvSVM(); + + CvSVM( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx=0, const CvMat* _sample_idx=0, + CvSVMParams _params=CvSVMParams() ); + + virtual bool train( const CvMat* _train_data, const CvMat* _responses, + const CvMat* _var_idx=0, const CvMat* _sample_idx=0, + CvSVMParams _params=CvSVMParams() ); + + virtual float predict( const CvMat* _sample ) const; + virtual int get_support_vector_count() const; + virtual const float* get_support_vector(int i) const; + virtual void clear(); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + int get_var_count() const { return var_idx ? var_idx->cols : var_all; } + +protected: + + virtual bool set_params( const CvSVMParams& _params ); + virtual bool train1( int sample_count, int var_count, const float** samples, + const void* _responses, double Cp, double Cn, + CvMemStorage* _storage, double* alpha, double& rho ); + virtual void create_kernel(); + virtual void create_solver(); + + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + CvSVMParams params; + CvMat* class_labels; + int var_all; + float** sv; + int sv_total; + CvMat* var_idx; + CvMat* class_weights; + CvSVMDecisionFunc* decision_func; + CvMemStorage* storage; + + CvSVMSolver* solver; + CvSVMKernel* kernel; +}; + + +/* The function trains SVM model with optimal parameters, obtained by using cross-validation. +The parameters to be estimated should be indicated by setting theirs values to FLT_MAX. +The optimal parameters are saved in */ +/*CVAPI(CvStatModel*) +cvTrainSVM_CrossValidation( const CvMat* train_data, int tflag, + const CvMat* responses, + CvStatModelParams* model_params, + const CvStatModelParams* cross_valid_params, + const CvMat* comp_idx CV_DEFAULT(0), + const CvMat* sample_idx CV_DEFAULT(0), + const CvParamLattice* degree_lattice CV_DEFAULT(0), + const CvParamLattice* gamma_lattice CV_DEFAULT(0), + const CvParamLattice* coef0_lattice CV_DEFAULT(0), + const CvParamLattice* C_lattice CV_DEFAULT(0), + const CvParamLattice* nu_lattice CV_DEFAULT(0), + const CvParamLattice* p_lattice CV_DEFAULT(0) );*/ + +/****************************************************************************************\ +* Expectation - Maximization * +\****************************************************************************************/ + +struct CV_EXPORTS CvEMParams +{ + CvEMParams() : nclusters(10), cov_mat_type(1/*CvEM::COV_MAT_DIAGONAL*/), + start_step(0/*CvEM::START_AUTO_STEP*/), probs(0), weights(0), means(0), covs(0) + { + term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON ); + } + + CvEMParams( int _nclusters, int _cov_mat_type=1/*CvEM::COV_MAT_DIAGONAL*/, + int _start_step=0/*CvEM::START_AUTO_STEP*/, + CvTermCriteria _term_crit=cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON), + const CvMat* _probs=0, const CvMat* _weights=0, const CvMat* _means=0, const CvMat** _covs=0 ) : + nclusters(_nclusters), cov_mat_type(_cov_mat_type), start_step(_start_step), + probs(_probs), weights(_weights), means(_means), covs(_covs), term_crit(_term_crit) + {} + + int nclusters; + int cov_mat_type; + int start_step; + const CvMat* probs; + const CvMat* weights; + const CvMat* means; + const CvMat** covs; + CvTermCriteria term_crit; +}; + + +class CV_EXPORTS CvEM : public CvStatModel +{ +public: + // Type of covariation matrices + enum { COV_MAT_SPHERICAL=0, COV_MAT_DIAGONAL=1, COV_MAT_GENERIC=2 }; + + // The initial step + enum { START_E_STEP=1, START_M_STEP=2, START_AUTO_STEP=0 }; + + CvEM(); + CvEM( const CvMat* samples, const CvMat* sample_idx=0, + CvEMParams params=CvEMParams(), CvMat* labels=0 ); + virtual ~CvEM(); + + virtual bool train( const CvMat* samples, const CvMat* sample_idx=0, + CvEMParams params=CvEMParams(), CvMat* labels=0 ); + + virtual float predict( const CvMat* sample, CvMat* probs ) const; + virtual void clear(); + + int get_nclusters() const; + const CvMat* get_means() const; + const CvMat** get_covs() const; + const CvMat* get_weights() const; + const CvMat* get_probs() const; + +protected: + + virtual void set_params( const CvEMParams& params, + const CvVectors& train_data ); + virtual void init_em( const CvVectors& train_data ); + virtual double run_em( const CvVectors& train_data ); + virtual void init_auto( const CvVectors& samples ); + virtual void kmeans( const CvVectors& train_data, int nclusters, + CvMat* labels, CvTermCriteria criteria, + const CvMat* means ); + CvEMParams params; + double log_likelihood; + + CvMat* means; + CvMat** covs; + CvMat* weights; + CvMat* probs; + + CvMat* log_weight_div_det; + CvMat* inv_eigen_values; + CvMat** cov_rotate_mats; +}; + +/****************************************************************************************\ +* Decision Tree * +\****************************************************************************************/ + +struct CvPair32s32f +{ + int i; + float val; +}; + + +#define CV_DTREE_CAT_DIR(idx,subset) \ + (2*((subset[(idx)>>5]&(1 << ((idx) & 31)))==0)-1) + +struct CvDTreeSplit +{ + int var_idx; + int inversed; + float quality; + CvDTreeSplit* next; + union + { + int subset[2]; + struct + { + float c; + int split_point; + } + ord; + }; +}; + + +struct CvDTreeNode +{ + int class_idx; + int Tn; + double value; + + CvDTreeNode* parent; + CvDTreeNode* left; + CvDTreeNode* right; + + CvDTreeSplit* split; + + int sample_count; + int depth; + int* num_valid; + int offset; + int buf_idx; + double maxlr; + + // global pruning data + int complexity; + double alpha; + double node_risk, tree_risk, tree_error; + + // cross-validation pruning data + int* cv_Tn; + double* cv_node_risk; + double* cv_node_error; + + int get_num_valid(int vi) { return num_valid ? num_valid[vi] : sample_count; } + void set_num_valid(int vi, int n) { if( num_valid ) num_valid[vi] = n; } +}; + + +struct CV_EXPORTS CvDTreeParams +{ + int max_categories; + int max_depth; + int min_sample_count; + int cv_folds; + bool use_surrogates; + bool use_1se_rule; + bool truncate_pruned_tree; + float regression_accuracy; + const float* priors; + + CvDTreeParams() : max_categories(10), max_depth(INT_MAX), min_sample_count(10), + cv_folds(10), use_surrogates(true), use_1se_rule(true), + truncate_pruned_tree(true), regression_accuracy(0.01f), priors(0) + {} + + CvDTreeParams( int _max_depth, int _min_sample_count, + float _regression_accuracy, bool _use_surrogates, + int _max_categories, int _cv_folds, + bool _use_1se_rule, bool _truncate_pruned_tree, + const float* _priors ) : + max_categories(_max_categories), max_depth(_max_depth), + min_sample_count(_min_sample_count), cv_folds (_cv_folds), + use_surrogates(_use_surrogates), use_1se_rule(_use_1se_rule), + truncate_pruned_tree(_truncate_pruned_tree), + regression_accuracy(_regression_accuracy), + priors(_priors) + {} +}; + + +struct CV_EXPORTS CvDTreeTrainData +{ + CvDTreeTrainData(); + CvDTreeTrainData( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + const CvDTreeParams& _params=CvDTreeParams(), + bool _shared=false, bool _add_labels=false ); + virtual ~CvDTreeTrainData(); + + virtual void set_data( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + const CvDTreeParams& _params=CvDTreeParams(), + bool _shared=false, bool _add_labels=false, + bool _update_data=false ); + + virtual void get_vectors( const CvMat* _subsample_idx, + float* values, uchar* missing, float* responses, bool get_class_idx=false ); + + virtual CvDTreeNode* subsample_data( const CvMat* _subsample_idx ); + + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + // release all the data + virtual void clear(); + + int get_num_classes() const; + int get_var_type(int vi) const; + int get_work_var_count() const; + + virtual int* get_class_labels( CvDTreeNode* n ); + virtual float* get_ord_responses( CvDTreeNode* n ); + virtual int* get_labels( CvDTreeNode* n ); + virtual int* get_cat_var_data( CvDTreeNode* n, int vi ); + virtual CvPair32s32f* get_ord_var_data( CvDTreeNode* n, int vi ); + virtual int get_child_buf_idx( CvDTreeNode* n ); + + //////////////////////////////////// + + virtual bool set_params( const CvDTreeParams& params ); + virtual CvDTreeNode* new_node( CvDTreeNode* parent, int count, + int storage_idx, int offset ); + + virtual CvDTreeSplit* new_split_ord( int vi, float cmp_val, + int split_point, int inversed, float quality ); + virtual CvDTreeSplit* new_split_cat( int vi, float quality ); + virtual void free_node_data( CvDTreeNode* node ); + virtual void free_train_data(); + virtual void free_node( CvDTreeNode* node ); + + int sample_count, var_all, var_count, max_c_count; + int ord_var_count, cat_var_count; + bool have_labels, have_priors; + bool is_classifier; + + int buf_count, buf_size; + bool shared; + + CvMat* cat_count; + CvMat* cat_ofs; + CvMat* cat_map; + + CvMat* counts; + CvMat* buf; + CvMat* direction; + CvMat* split_buf; + + CvMat* var_idx; + CvMat* var_type; // i-th element = + // k<0 - ordered + // k>=0 - categorical, see k-th element of cat_* arrays + CvMat* priors; + CvMat* priors_mult; + + CvDTreeParams params; + + CvMemStorage* tree_storage; + CvMemStorage* temp_storage; + + CvDTreeNode* data_root; + + CvSet* node_heap; + CvSet* split_heap; + CvSet* cv_heap; + CvSet* nv_heap; + + CvRNG rng; +}; + + +class CV_EXPORTS CvDTree : public CvStatModel +{ +public: + CvDTree(); + virtual ~CvDTree(); + + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvDTreeParams params=CvDTreeParams() ); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx ); + + virtual CvDTreeNode* predict( const CvMat* _sample, const CvMat* _missing_data_mask=0, + bool preprocessed_input=false ) const; + virtual const CvMat* get_var_importance(); + virtual void clear(); + + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void write( CvFileStorage* fs, const char* name ); + + // special read & write methods for trees in the tree ensembles + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvDTreeTrainData* data ); + virtual void write( CvFileStorage* fs ); + + const CvDTreeNode* get_root() const; + int get_pruned_tree_idx() const; + CvDTreeTrainData* get_data(); + +protected: + + virtual bool do_train( const CvMat* _subsample_idx ); + + virtual void try_split_node( CvDTreeNode* n ); + virtual void split_node_data( CvDTreeNode* n ); + virtual CvDTreeSplit* find_best_split( CvDTreeNode* n ); + virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_surrogate_split_ord( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_surrogate_split_cat( CvDTreeNode* n, int vi ); + virtual double calc_node_dir( CvDTreeNode* node ); + virtual void complete_node_dir( CvDTreeNode* node ); + virtual void cluster_categories( const int* vectors, int vector_count, + int var_count, int* sums, int k, int* cluster_labels ); + + virtual void calc_node_value( CvDTreeNode* node ); + + virtual void prune_cv(); + virtual double update_tree_rnc( int T, int fold ); + virtual int cut_tree( int T, int fold, double min_alpha ); + virtual void free_prune_data(bool cut_tree); + virtual void free_tree(); + + virtual void write_node( CvFileStorage* fs, CvDTreeNode* node ); + virtual void write_split( CvFileStorage* fs, CvDTreeSplit* split ); + virtual CvDTreeNode* read_node( CvFileStorage* fs, CvFileNode* node, CvDTreeNode* parent ); + virtual CvDTreeSplit* read_split( CvFileStorage* fs, CvFileNode* node ); + virtual void write_tree_nodes( CvFileStorage* fs ); + virtual void read_tree_nodes( CvFileStorage* fs, CvFileNode* node ); + + CvDTreeNode* root; + + int pruned_tree_idx; + CvMat* var_importance; + + CvDTreeTrainData* data; +}; + + +/****************************************************************************************\ +* Random Trees Classifier * +\****************************************************************************************/ + +class CvRTrees; + +class CV_EXPORTS CvForestTree: public CvDTree +{ +public: + CvForestTree(); + virtual ~CvForestTree(); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx, CvRTrees* forest ); + + virtual int get_var_count() const {return data ? data->var_count : 0;} + virtual void read( CvFileStorage* fs, CvFileNode* node, CvRTrees* forest, CvDTreeTrainData* _data ); + + /* dummy methods to avoid warnings: BEGIN */ + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvDTreeParams params=CvDTreeParams() ); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx ); + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvDTreeTrainData* data ); + /* dummy methods to avoid warnings: END */ + +protected: + virtual CvDTreeSplit* find_best_split( CvDTreeNode* n ); + CvRTrees* forest; +}; + + +struct CV_EXPORTS CvRTParams : public CvDTreeParams +{ + //Parameters for the forest + bool calc_var_importance; // true <=> RF processes variable importance + int nactive_vars; + CvTermCriteria term_crit; + + CvRTParams() : CvDTreeParams( 5, 10, 0, false, 10, 0, false, false, 0 ), + calc_var_importance(false), nactive_vars(0) + { + term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 50, 0.1 ); + } + + CvRTParams( int _max_depth, int _min_sample_count, + float _regression_accuracy, bool _use_surrogates, + int _max_categories, const float* _priors, bool _calc_var_importance, + int _nactive_vars, int max_num_of_trees_in_the_forest, + float forest_accuracy, int termcrit_type ) : + CvDTreeParams( _max_depth, _min_sample_count, _regression_accuracy, + _use_surrogates, _max_categories, 0, + false, false, _priors ), + calc_var_importance(_calc_var_importance), + nactive_vars(_nactive_vars) + { + term_crit = cvTermCriteria(termcrit_type, + max_num_of_trees_in_the_forest, forest_accuracy); + } +}; + + +class CV_EXPORTS CvRTrees : public CvStatModel +{ +public: + CvRTrees(); + virtual ~CvRTrees(); + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvRTParams params=CvRTParams() ); + virtual float predict( const CvMat* sample, const CvMat* missing = 0 ) const; + virtual void clear(); + + virtual const CvMat* get_var_importance(); + virtual float get_proximity( const CvMat* sample1, const CvMat* sample2, + const CvMat* missing1 = 0, const CvMat* missing2 = 0 ) const; + + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void write( CvFileStorage* fs, const char* name ); + + CvMat* get_active_var_mask(); + CvRNG* get_rng(); + + int get_tree_count() const; + CvForestTree* get_tree(int i) const; + +protected: + + bool grow_forest( const CvTermCriteria term_crit ); + + // array of the trees of the forest + CvForestTree** trees; + CvDTreeTrainData* data; + int ntrees; + int nclasses; + double oob_error; + CvMat* var_importance; + int nsamples; + + CvRNG rng; + CvMat* active_var_mask; +}; + + +/****************************************************************************************\ +* Boosted tree classifier * +\****************************************************************************************/ + +struct CV_EXPORTS CvBoostParams : public CvDTreeParams +{ + int boost_type; + int weak_count; + int split_criteria; + double weight_trim_rate; + + CvBoostParams(); + CvBoostParams( int boost_type, int weak_count, double weight_trim_rate, + int max_depth, bool use_surrogates, const float* priors ); +}; + + +class CvBoost; + +class CV_EXPORTS CvBoostTree: public CvDTree +{ +public: + CvBoostTree(); + virtual ~CvBoostTree(); + + virtual bool train( CvDTreeTrainData* _train_data, + const CvMat* subsample_idx, CvBoost* ensemble ); + + virtual void scale( double s ); + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvBoost* ensemble, CvDTreeTrainData* _data ); + virtual void clear(); + + /* dummy methods to avoid warnings: BEGIN */ + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvDTreeParams params=CvDTreeParams() ); + + virtual bool train( CvDTreeTrainData* _train_data, const CvMat* _subsample_idx ); + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void read( CvFileStorage* fs, CvFileNode* node, + CvDTreeTrainData* data ); + /* dummy methods to avoid warnings: END */ + +protected: + + virtual void try_split_node( CvDTreeNode* n ); + virtual CvDTreeSplit* find_surrogate_split_ord( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_surrogate_split_cat( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_ord_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_class( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_ord_reg( CvDTreeNode* n, int vi ); + virtual CvDTreeSplit* find_split_cat_reg( CvDTreeNode* n, int vi ); + virtual void calc_node_value( CvDTreeNode* n ); + virtual double calc_node_dir( CvDTreeNode* n ); + + CvBoost* ensemble; +}; + + +class CV_EXPORTS CvBoost : public CvStatModel +{ +public: + // Boosting type + enum { DISCRETE=0, REAL=1, LOGIT=2, GENTLE=3 }; + + // Splitting criteria + enum { DEFAULT=0, GINI=1, MISCLASS=3, SQERR=4 }; + + CvBoost(); + virtual ~CvBoost(); + + CvBoost( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvBoostParams params=CvBoostParams() ); + + virtual bool train( const CvMat* _train_data, int _tflag, + const CvMat* _responses, const CvMat* _var_idx=0, + const CvMat* _sample_idx=0, const CvMat* _var_type=0, + const CvMat* _missing_mask=0, + CvBoostParams params=CvBoostParams(), + bool update=false ); + + virtual float predict( const CvMat* _sample, const CvMat* _missing=0, + CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, + bool raw_mode=false ) const; + + virtual void prune( CvSlice slice ); + + virtual void clear(); + + virtual void write( CvFileStorage* storage, const char* name ); + virtual void read( CvFileStorage* storage, CvFileNode* node ); + + CvSeq* get_weak_predictors(); + + CvMat* get_weights(); + CvMat* get_subtree_weights(); + CvMat* get_weak_response(); + const CvBoostParams& get_params() const; + +protected: + + virtual bool set_params( const CvBoostParams& _params ); + virtual void update_weights( CvBoostTree* tree ); + virtual void trim_weights(); + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + CvDTreeTrainData* data; + CvBoostParams params; + CvSeq* weak; + + CvMat* orig_response; + CvMat* sum_response; + CvMat* weak_eval; + CvMat* subsample_mask; + CvMat* weights; + CvMat* subtree_weights; + bool have_subsample; +}; + + +/****************************************************************************************\ +* Artificial Neural Networks (ANN) * +\****************************************************************************************/ + +/////////////////////////////////// Multi-Layer Perceptrons ////////////////////////////// + +struct CV_EXPORTS CvANN_MLP_TrainParams +{ + CvANN_MLP_TrainParams(); + CvANN_MLP_TrainParams( CvTermCriteria term_crit, int train_method, + double param1, double param2=0 ); + ~CvANN_MLP_TrainParams(); + + enum { BACKPROP=0, RPROP=1 }; + + CvTermCriteria term_crit; + int train_method; + + // backpropagation parameters + double bp_dw_scale, bp_moment_scale; + + // rprop parameters + double rp_dw0, rp_dw_plus, rp_dw_minus, rp_dw_min, rp_dw_max; +}; + + +class CV_EXPORTS CvANN_MLP : public CvStatModel +{ +public: + CvANN_MLP(); + CvANN_MLP( const CvMat* _layer_sizes, + int _activ_func=SIGMOID_SYM, + double _f_param1=0, double _f_param2=0 ); + + virtual ~CvANN_MLP(); + + virtual void create( const CvMat* _layer_sizes, + int _activ_func=SIGMOID_SYM, + double _f_param1=0, double _f_param2=0 ); + + virtual int train( const CvMat* _inputs, const CvMat* _outputs, + const CvMat* _sample_weights, const CvMat* _sample_idx=0, + CvANN_MLP_TrainParams _params = CvANN_MLP_TrainParams(), + int flags=0 ); + virtual float predict( const CvMat* _inputs, + CvMat* _outputs ) const; + + virtual void clear(); + + // possible activation functions + enum { IDENTITY = 0, SIGMOID_SYM = 1, GAUSSIAN = 2 }; + + // available training flags + enum { UPDATE_WEIGHTS = 1, NO_INPUT_SCALE = 2, NO_OUTPUT_SCALE = 4 }; + + virtual void read( CvFileStorage* fs, CvFileNode* node ); + virtual void write( CvFileStorage* storage, const char* name ); + + int get_layer_count() { return layer_sizes ? layer_sizes->cols : 0; } + const CvMat* get_layer_sizes() { return layer_sizes; } + double* get_weights(int layer) + { + return layer_sizes && weights && + (unsigned)layer <= (unsigned)layer_sizes->cols ? weights[layer] : 0; + } + +protected: + + virtual bool prepare_to_train( const CvMat* _inputs, const CvMat* _outputs, + const CvMat* _sample_weights, const CvMat* _sample_idx, + CvVectors* _ivecs, CvVectors* _ovecs, double** _sw, int _flags ); + + // sequential random backpropagation + virtual int train_backprop( CvVectors _ivecs, CvVectors _ovecs, const double* _sw ); + + // RPROP algorithm + virtual int train_rprop( CvVectors _ivecs, CvVectors _ovecs, const double* _sw ); + + virtual void calc_activ_func( CvMat* xf, const double* bias ) const; + virtual void calc_activ_func_deriv( CvMat* xf, CvMat* deriv, const double* bias ) const; + virtual void set_activ_func( int _activ_func=SIGMOID_SYM, + double _f_param1=0, double _f_param2=0 ); + virtual void init_weights(); + virtual void scale_input( const CvMat* _src, CvMat* _dst ) const; + virtual void scale_output( const CvMat* _src, CvMat* _dst ) const; + virtual void calc_input_scale( const CvVectors* vecs, int flags ); + virtual void calc_output_scale( const CvVectors* vecs, int flags ); + + virtual void write_params( CvFileStorage* fs ); + virtual void read_params( CvFileStorage* fs, CvFileNode* node ); + + CvMat* layer_sizes; + CvMat* wbuf; + CvMat* sample_weights; + double** weights; + double f_param1, f_param2; + double min_val, max_val, min_val1, max_val1; + int activ_func; + int max_count, max_buf_sz; + CvANN_MLP_TrainParams params; + CvRNG rng; +}; + +#if 0 +/****************************************************************************************\ +* Convolutional Neural Network * +\****************************************************************************************/ +typedef struct CvCNNLayer CvCNNLayer; +typedef struct CvCNNetwork CvCNNetwork; + +#define CV_CNN_LEARN_RATE_DECREASE_HYPERBOLICALLY 1 +#define CV_CNN_LEARN_RATE_DECREASE_SQRT_INV 2 +#define CV_CNN_LEARN_RATE_DECREASE_LOG_INV 3 + +#define CV_CNN_GRAD_ESTIM_RANDOM 0 +#define CV_CNN_GRAD_ESTIM_BY_WORST_IMG 1 + +#define ICV_CNN_LAYER 0x55550000 +#define ICV_CNN_CONVOLUTION_LAYER 0x00001111 +#define ICV_CNN_SUBSAMPLING_LAYER 0x00002222 +#define ICV_CNN_FULLCONNECT_LAYER 0x00003333 + +#define ICV_IS_CNN_LAYER( layer ) \ + ( ((layer) != NULL) && ((((CvCNNLayer*)(layer))->flags & CV_MAGIC_MASK)\ + == ICV_CNN_LAYER )) + +#define ICV_IS_CNN_CONVOLUTION_LAYER( layer ) \ + ( (ICV_IS_CNN_LAYER( layer )) && (((CvCNNLayer*) (layer))->flags \ + & ~CV_MAGIC_MASK) == ICV_CNN_CONVOLUTION_LAYER ) + +#define ICV_IS_CNN_SUBSAMPLING_LAYER( layer ) \ + ( (ICV_IS_CNN_LAYER( layer )) && (((CvCNNLayer*) (layer))->flags \ + & ~CV_MAGIC_MASK) == ICV_CNN_SUBSAMPLING_LAYER ) + +#define ICV_IS_CNN_FULLCONNECT_LAYER( layer ) \ + ( (ICV_IS_CNN_LAYER( layer )) && (((CvCNNLayer*) (layer))->flags \ + & ~CV_MAGIC_MASK) == ICV_CNN_FULLCONNECT_LAYER ) + +typedef void (CV_CDECL *CvCNNLayerForward) + ( CvCNNLayer* layer, const CvMat* input, CvMat* output ); + +typedef void (CV_CDECL *CvCNNLayerBackward) + ( CvCNNLayer* layer, int t, const CvMat* X, const CvMat* dE_dY, CvMat* dE_dX ); + +typedef void (CV_CDECL *CvCNNLayerRelease) + (CvCNNLayer** layer); + +typedef void (CV_CDECL *CvCNNetworkAddLayer) + (CvCNNetwork* network, CvCNNLayer* layer); + +typedef void (CV_CDECL *CvCNNetworkRelease) + (CvCNNetwork** network); + +#define CV_CNN_LAYER_FIELDS() \ + /* Indicator of the layer's type */ \ + int flags; \ + \ + /* Number of input images */ \ + int n_input_planes; \ + /* Height of each input image */ \ + int input_height; \ + /* Width of each input image */ \ + int input_width; \ + \ + /* Number of output images */ \ + int n_output_planes; \ + /* Height of each output image */ \ + int output_height; \ + /* Width of each output image */ \ + int output_width; \ + \ + /* Learning rate at the first iteration */ \ + float init_learn_rate; \ + /* Dynamics of learning rate decreasing */ \ + int learn_rate_decrease_type; \ + /* Trainable weights of the layer (including bias) */ \ + /* i-th row is a set of weights of the i-th output plane */ \ + CvMat* weights; \ + \ + CvCNNLayerForward forward; \ + CvCNNLayerBackward backward; \ + CvCNNLayerRelease release; \ + /* Pointers to the previous and next layers in the network */ \ + CvCNNLayer* prev_layer; \ + CvCNNLayer* next_layer + +typedef struct CvCNNLayer +{ + CV_CNN_LAYER_FIELDS(); +}CvCNNLayer; + +typedef struct CvCNNConvolutionLayer +{ + CV_CNN_LAYER_FIELDS(); + // Kernel size (height and width) for convolution. + int K; + // connections matrix, (i,j)-th element is 1 iff there is a connection between + // i-th plane of the current layer and j-th plane of the previous layer; + // (i,j)-th element is equal to 0 otherwise + CvMat *connect_mask; + // value of the learning rate for updating weights at the first iteration +}CvCNNConvolutionLayer; + +typedef struct CvCNNSubSamplingLayer +{ + CV_CNN_LAYER_FIELDS(); + // ratio between the heights (or widths - ratios are supposed to be equal) + // of the input and output planes + int sub_samp_scale; + // amplitude of sigmoid activation function + float a; + // scale parameter of sigmoid activation function + float s; + // exp2ssumWX = exp(2*(bias+w*(x1+...+x4))), where x1,...x4 are some elements of X + // - is the vector used in computing of the activation function in backward + CvMat* exp2ssumWX; + // (x1+x2+x3+x4), where x1,...x4 are some elements of X + // - is the vector used in computing of the activation function in backward + CvMat* sumX; +}CvCNNSubSamplingLayer; + +// Structure of the last layer. +typedef struct CvCNNFullConnectLayer +{ + CV_CNN_LAYER_FIELDS(); + // amplitude of sigmoid activation function + float a; + // scale parameter of sigmoid activation function + float s; + // exp2ssumWX = exp(2**(W*X)) - is the vector used in computing of the + // activation function and it's derivative by the formulae + // activ.func. = (exp(2WX)-1)/(exp(2WX)+1) == - 2/( + 1) + // (activ.func.)' = 4exp(2WX)/(exp(2WX)+1)^2 + CvMat* exp2ssumWX; +}CvCNNFullConnectLayer; + +typedef struct CvCNNetwork +{ + int n_layers; + CvCNNLayer* layers; + CvCNNetworkAddLayer add_layer; + CvCNNetworkRelease release; +}CvCNNetwork; + +typedef struct CvCNNStatModel +{ + CV_STAT_MODEL_FIELDS(); + CvCNNetwork* network; + // etalons are allocated as rows, the i-th etalon has label cls_labeles[i] + CvMat* etalons; + // classes labels + CvMat* cls_labels; +}CvCNNStatModel; + +typedef struct CvCNNStatModelParams +{ + CV_STAT_MODEL_PARAM_FIELDS(); + // network must be created by the functions cvCreateCNNetwork and + CvCNNetwork* network; + CvMat* etalons; + // termination criteria + int max_iter; + int start_iter; + int grad_estim_type; +}CvCNNStatModelParams; + +CVAPI(CvCNNLayer*) cvCreateCNNConvolutionLayer( + int n_input_planes, int input_height, int input_width, + int n_output_planes, int K, + float init_learn_rate, int learn_rate_decrease_type, + CvMat* connect_mask CV_DEFAULT(0), CvMat* weights CV_DEFAULT(0) ); + +CVAPI(CvCNNLayer*) cvCreateCNNSubSamplingLayer( + int n_input_planes, int input_height, int input_width, + int sub_samp_scale, float a, float s, + float init_learn_rate, int learn_rate_decrease_type, CvMat* weights CV_DEFAULT(0) ); + +CVAPI(CvCNNLayer*) cvCreateCNNFullConnectLayer( + int n_inputs, int n_outputs, float a, float s, + float init_learn_rate, int learning_type, CvMat* weights CV_DEFAULT(0) ); + +CVAPI(CvCNNetwork*) cvCreateCNNetwork( CvCNNLayer* first_layer ); + +CVAPI(CvStatModel*) cvTrainCNNClassifier( + const CvMat* train_data, int tflag, + const CvMat* responses, + const CvStatModelParams* params, + const CvMat* CV_DEFAULT(0), + const CvMat* sample_idx CV_DEFAULT(0), + const CvMat* CV_DEFAULT(0), const CvMat* CV_DEFAULT(0) ); + +/****************************************************************************************\ +* Estimate classifiers algorithms * +\****************************************************************************************/ +typedef const CvMat* (CV_CDECL *CvStatModelEstimateGetMat) + ( const CvStatModel* estimateModel ); + +typedef int (CV_CDECL *CvStatModelEstimateNextStep) + ( CvStatModel* estimateModel ); + +typedef void (CV_CDECL *CvStatModelEstimateCheckClassifier) + ( CvStatModel* estimateModel, + const CvStatModel* model, + const CvMat* features, + int sample_t_flag, + const CvMat* responses ); + +typedef void (CV_CDECL *CvStatModelEstimateCheckClassifierEasy) + ( CvStatModel* estimateModel, + const CvStatModel* model ); + +typedef float (CV_CDECL *CvStatModelEstimateGetCurrentResult) + ( const CvStatModel* estimateModel, + float* correlation ); + +typedef void (CV_CDECL *CvStatModelEstimateReset) + ( CvStatModel* estimateModel ); + +//-------------------------------- Cross-validation -------------------------------------- +#define CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_PARAM_FIELDS() \ + CV_STAT_MODEL_PARAM_FIELDS(); \ + int k_fold; \ + int is_regression; \ + CvRNG* rng + +typedef struct CvCrossValidationParams +{ + CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_PARAM_FIELDS(); +} CvCrossValidationParams; + +#define CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_FIELDS() \ + CvStatModelEstimateGetMat getTrainIdxMat; \ + CvStatModelEstimateGetMat getCheckIdxMat; \ + CvStatModelEstimateNextStep nextStep; \ + CvStatModelEstimateCheckClassifier check; \ + CvStatModelEstimateGetCurrentResult getResult; \ + CvStatModelEstimateReset reset; \ + int is_regression; \ + int folds_all; \ + int samples_all; \ + int* sampleIdxAll; \ + int* folds; \ + int max_fold_size; \ + int current_fold; \ + int is_checked; \ + CvMat* sampleIdxTrain; \ + CvMat* sampleIdxEval; \ + CvMat* predict_results; \ + int correct_results; \ + int all_results; \ + double sq_error; \ + double sum_correct; \ + double sum_predict; \ + double sum_cc; \ + double sum_pp; \ + double sum_cp + +typedef struct CvCrossValidationModel +{ + CV_STAT_MODEL_FIELDS(); + CV_CROSS_VALIDATION_ESTIMATE_CLASSIFIER_FIELDS(); +} CvCrossValidationModel; + +CVAPI(CvStatModel*) +cvCreateCrossValidationEstimateModel + ( int samples_all, + const CvStatModelParams* estimateParams CV_DEFAULT(0), + const CvMat* sampleIdx CV_DEFAULT(0) ); + +CVAPI(float) +cvCrossValidation( const CvMat* trueData, + int tflag, + const CvMat* trueClasses, + CvStatModel* (*createClassifier)( const CvMat*, + int, + const CvMat*, + const CvStatModelParams*, + const CvMat*, + const CvMat*, + const CvMat*, + const CvMat* ), + const CvStatModelParams* estimateParams CV_DEFAULT(0), + const CvStatModelParams* trainParams CV_DEFAULT(0), + const CvMat* compIdx CV_DEFAULT(0), + const CvMat* sampleIdx CV_DEFAULT(0), + CvStatModel** pCrValModel CV_DEFAULT(0), + const CvMat* typeMask CV_DEFAULT(0), + const CvMat* missedMeasurementMask CV_DEFAULT(0) ); +#endif + +/****************************************************************************************\ +* Auxilary functions declarations * +\****************************************************************************************/ + +/* Generates from multivariate normal distribution, where - is an + average row vector, - symmetric covariation matrix */ +CVAPI(void) cvRandMVNormal( CvMat* mean, CvMat* cov, CvMat* sample, + CvRNG* rng CV_DEFAULT(0) ); + +/* Generates sample from gaussian mixture distribution */ +CVAPI(void) cvRandGaussMixture( CvMat* means[], + CvMat* covs[], + float weights[], + int clsnum, + CvMat* sample, + CvMat* sampClasses CV_DEFAULT(0) ); + +#define CV_TS_CONCENTRIC_SPHERES 0 + +/* creates test set */ +CVAPI(void) cvCreateTestSet( int type, CvMat** samples, + int num_samples, + int num_features, + CvMat** responses, + int num_classes, ... ); + +/* Aij <- Aji for i > j if lower_to_upper != 0 + for i < j if lower_to_upper = 0 */ +CVAPI(void) cvCompleteSymm( CvMat* matrix, int lower_to_upper ); + +#ifdef __cplusplus +} +#endif + +#endif /*__ML_H__*/ +/* End of file. */ diff --git a/libraries/external/opencv/linux/include/vssver.scc b/libraries/external/opencv/linux/include/vssver.scc new file mode 100755 index 0000000..72f5df1 Binary files /dev/null and b/libraries/external/opencv/linux/include/vssver.scc differ diff --git a/libraries/external/opencv/linux/libs/libcv.a b/libraries/external/opencv/linux/libs/libcv.a new file mode 100755 index 0000000..dda1f62 Binary files /dev/null and b/libraries/external/opencv/linux/libs/libcv.a differ diff --git a/libraries/external/opencv/linux/libs/libcxcore.a b/libraries/external/opencv/linux/libs/libcxcore.a new file mode 100755 index 0000000..dd91a91 Binary files /dev/null and b/libraries/external/opencv/linux/libs/libcxcore.a differ diff --git a/libraries/external/opencv/linux/libs/vssver.scc b/libraries/external/opencv/linux/libs/vssver.scc new file mode 100755 index 0000000..cf39e1b Binary files /dev/null and b/libraries/external/opencv/linux/libs/vssver.scc differ diff --git a/libraries/external/opencv/opencv-1.0.0.tar.gz b/libraries/external/opencv/opencv-1.0.0.tar.gz new file mode 100755 index 0000000..b8cdad7 --- /dev/null +++ b/libraries/external/opencv/opencv-1.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9978dc757fd0e4956b35d27a8149f46219350c95ffb9b127631197a8e85bfe8 +size 11146334 diff --git a/libraries/external/opencv/vssver.scc b/libraries/external/opencv/vssver.scc new file mode 100755 index 0000000..08b9c17 Binary files /dev/null and b/libraries/external/opencv/vssver.scc differ diff --git a/libraries/external/openssl/ActivePerl-5.6.1.638-MSWin32-x86.msi b/libraries/external/openssl/ActivePerl-5.6.1.638-MSWin32-x86.msi new file mode 100755 index 0000000..fb1650f Binary files /dev/null and b/libraries/external/openssl/ActivePerl-5.6.1.638-MSWin32-x86.msi differ diff --git a/libraries/external/openssl/Readme.txt b/libraries/external/openssl/Readme.txt new file mode 100755 index 0000000..aa2059d --- /dev/null +++ b/libraries/external/openssl/Readme.txt @@ -0,0 +1,43 @@ +WINDOWS INSTALL INSTRUCTIONS: + +1) copy the contents of openssl\pc\lib and include to c:\g3\lib + +2) copy the contents of openssl\pc\bin to c:\windows\system32 + + +WINDOWS BUILD INSTRUCTIONS: + +1) unzip the nasm zip file and copy nasmw.exe and ndisasmw.exe to + C:\Program Files\Microsoft Visual Studio\Common\Tools\ + +2) Install ActivePerl + +3) gunzip and untar the openssl source tar ball + +4) Follow the instructions found in INSTALL.W32 + a) configure with '--prefix=c:\g3\openssl' + b) use 'ms\do_nasm' to compile with the nasm assembler + +tips: +you may need to specify the full path to perl when running the configure script, +for me this was 'c:\Perl\bin\perl.exe' +you can try to build using the microsoft assembler, I didn't have a copy on my PC +so I used nasm instead + + +LINUX INSTALL INSTRUCTIONS: + +1) copy the contents of openssl/linux/lib and include to /g3/lib + + +LINUX BUILD INSTRUCTIONS: + +1) openssl requires zlib 1.2.3 or newer (there is an exploitable buffer overflow in earlier versions of zlib) + so... build and install zlib 1.2.3 + +2) gunzip and untar the openssl source tar ball + +3) run ./Configure --prefix=/g3/openssl/linux zlib + +4) run make and make install + diff --git a/libraries/external/openssl/linux/bin/c_rehash b/libraries/external/openssl/linux/bin/c_rehash new file mode 100755 index 0000000..b6486a1 --- /dev/null +++ b/libraries/external/openssl/linux/bin/c_rehash @@ -0,0 +1,160 @@ +#!/usr/bin/perl + + +# Perl c_rehash script, scan all files in a directory +# and add symbolic links to their hash values. + +my $openssl; + +my $dir = "/g3/openssl/linux/ssl"; + +if(defined $ENV{OPENSSL}) { + $openssl = $ENV{OPENSSL}; +} else { + $openssl = "openssl"; + $ENV{OPENSSL} = $openssl; +} + +$ENV{PATH} .= ":$dir/bin"; + +if(! -x $openssl) { + my $found = 0; + foreach (split /:/, $ENV{PATH}) { + if(-x "$_/$openssl") { + $found = 1; + last; + } + } + if($found == 0) { + print STDERR "c_rehash: rehashing skipped ('openssl' program not available)\n"; + exit 0; + } +} + +if(@ARGV) { + @dirlist = @ARGV; +} elsif($ENV{SSL_CERT_DIR}) { + @dirlist = split /:/, $ENV{SSL_CERT_DIR}; +} else { + $dirlist[0] = "$dir/certs"; +} + + +foreach (@dirlist) { + if(-d $_ and -w $_) { + hash_dir($_); + } +} + +sub hash_dir { + my %hashlist; + print "Doing $_[0]\n"; + chdir $_[0]; + opendir(DIR, "."); + my @flist = readdir(DIR); + # Delete any existing symbolic links + foreach (grep {/^[\da-f]+\.r{0,1}\d+$/} @flist) { + if(-l $_) { + unlink $_; + } + } + closedir DIR; + FILE: foreach $fname (grep {/\.pem$/} @flist) { + # Check to see if certificates and/or CRLs present. + my ($cert, $crl) = check_file($fname); + if(!$cert && !$crl) { + print STDERR "WARNING: $fname does not contain a certificate or CRL: skipping\n"; + next; + } + link_hash_cert($fname) if($cert); + link_hash_crl($fname) if($crl); + } +} + +sub check_file { + my ($is_cert, $is_crl) = (0,0); + my $fname = $_[0]; + open IN, $fname; + while() { + if(/^-----BEGIN (.*)-----/) { + my $hdr = $1; + if($hdr =~ /^(X509 |TRUSTED |)CERTIFICATE$/) { + $is_cert = 1; + last if($is_crl); + } elsif($hdr eq "X509 CRL") { + $is_crl = 1; + last if($is_cert); + } + } + } + close IN; + return ($is_cert, $is_crl); +} + + +# Link a certificate to its subject name hash value, each hash is of +# the form . where n is an integer. If the hash value already exists +# then we need to up the value of n, unless its a duplicate in which +# case we skip the link. We check for duplicates by comparing the +# certificate fingerprints + +sub link_hash_cert { + my $fname = $_[0]; + $fname =~ s/'/'\\''/g; + my ($hash, $fprint) = `"$openssl" x509 -hash -fingerprint -noout -in '$fname'`; + chomp $hash; + chomp $fprint; + $fprint =~ s/^.*=//; + $fprint =~ tr/://d; + my $suffix = 0; + # Search for an unused hash filename + while(exists $hashlist{"$hash.$suffix"}) { + # Hash matches: if fingerprint matches its a duplicate cert + if($hashlist{"$hash.$suffix"} eq $fprint) { + print STDERR "WARNING: Skipping duplicate certificate $fname\n"; + return; + } + $suffix++; + } + $hash .= ".$suffix"; + print "$fname => $hash\n"; + $symlink_exists=eval {symlink("",""); 1}; + if ($symlink_exists) { + symlink $fname, $hash; + } else { + system ("cp", $fname, $hash); + } + $hashlist{$hash} = $fprint; +} + +# Same as above except for a CRL. CRL links are of the form .r + +sub link_hash_crl { + my $fname = $_[0]; + $fname =~ s/'/'\\''/g; + my ($hash, $fprint) = `"$openssl" crl -hash -fingerprint -noout -in '$fname'`; + chomp $hash; + chomp $fprint; + $fprint =~ s/^.*=//; + $fprint =~ tr/://d; + my $suffix = 0; + # Search for an unused hash filename + while(exists $hashlist{"$hash.r$suffix"}) { + # Hash matches: if fingerprint matches its a duplicate cert + if($hashlist{"$hash.r$suffix"} eq $fprint) { + print STDERR "WARNING: Skipping duplicate CRL $fname\n"; + return; + } + $suffix++; + } + $hash .= ".r$suffix"; + print "$fname => $hash\n"; + $symlink_exists=eval {symlink("",""); 1}; + if ($symlink_exists) { + symlink $fname, $hash; + } else { + system ("cp", $fname, $hash); + } + $hashlist{$hash} = $fprint; +} + diff --git a/libraries/external/openssl/linux/bin/openssl b/libraries/external/openssl/linux/bin/openssl new file mode 100755 index 0000000..81f0a0f Binary files /dev/null and b/libraries/external/openssl/linux/bin/openssl differ diff --git a/libraries/external/openssl/linux/bin/vssver.scc b/libraries/external/openssl/linux/bin/vssver.scc new file mode 100755 index 0000000..9088191 Binary files /dev/null and b/libraries/external/openssl/linux/bin/vssver.scc differ diff --git a/libraries/external/openssl/linux/include/openssl/aes.h b/libraries/external/openssl/linux/include/openssl/aes.h new file mode 100755 index 0000000..015a1e4 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/aes.h @@ -0,0 +1,138 @@ +/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + */ + +#ifndef HEADER_AES_H +#define HEADER_AES_H + +#include + +#ifdef OPENSSL_NO_AES +#error AES is disabled. +#endif + +#define AES_ENCRYPT 1 +#define AES_DECRYPT 0 + +/* Because array size can't be a const in C, the following two are macros. + Both sizes are in bytes. */ +#define AES_MAXNR 14 +#define AES_BLOCK_SIZE 16 + +#ifdef __cplusplus +extern "C" { +#endif + +/* This should be a hidden type, but EVP requires that the size be known */ +struct aes_key_st { +#ifdef AES_LONG + unsigned long rd_key[4 *(AES_MAXNR + 1)]; +#else + unsigned int rd_key[4 *(AES_MAXNR + 1)]; +#endif + int rounds; +}; +typedef struct aes_key_st AES_KEY; + +const char *AES_options(void); + +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); + +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); + +void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key, const int enc); +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, + const int nbits,const AES_KEY *key, + unsigned char *ivec,const int enc); +void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num); +void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char ivec[AES_BLOCK_SIZE], + unsigned char ecount_buf[AES_BLOCK_SIZE], + unsigned int *num); + +/* For IGE, see also http://www.links.org/files/openssl-ige.pdf */ +/* NB: the IV is _two_ blocks long */ +void AES_ige_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +/* NB: the IV is _four_ blocks long */ +void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + const AES_KEY *key2, const unsigned char *ivec, + const int enc); + + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_AES_H */ diff --git a/libraries/external/openssl/linux/include/openssl/asn1.h b/libraries/external/openssl/linux/include/openssl/asn1.h new file mode 100755 index 0000000..8671b80 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/asn1.h @@ -0,0 +1,1233 @@ +/* crypto/asn1/asn1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_H +#define HEADER_ASN1_H + +#include +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#include + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define V_ASN1_UNIVERSAL 0x00 +#define V_ASN1_APPLICATION 0x40 +#define V_ASN1_CONTEXT_SPECIFIC 0x80 +#define V_ASN1_PRIVATE 0xc0 + +#define V_ASN1_CONSTRUCTED 0x20 +#define V_ASN1_PRIMITIVE_TAG 0x1f +#define V_ASN1_PRIMATIVE_TAG 0x1f + +#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ +#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +#define V_ASN1_ANY -4 /* used in ASN1 template code */ + +#define V_ASN1_NEG 0x100 /* negative flag */ + +#define V_ASN1_UNDEF -1 +#define V_ASN1_EOC 0 +#define V_ASN1_BOOLEAN 1 /**/ +#define V_ASN1_INTEGER 2 +#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) +#define V_ASN1_BIT_STRING 3 +#define V_ASN1_OCTET_STRING 4 +#define V_ASN1_NULL 5 +#define V_ASN1_OBJECT 6 +#define V_ASN1_OBJECT_DESCRIPTOR 7 +#define V_ASN1_EXTERNAL 8 +#define V_ASN1_REAL 9 +#define V_ASN1_ENUMERATED 10 +#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) +#define V_ASN1_UTF8STRING 12 +#define V_ASN1_SEQUENCE 16 +#define V_ASN1_SET 17 +#define V_ASN1_NUMERICSTRING 18 /**/ +#define V_ASN1_PRINTABLESTRING 19 +#define V_ASN1_T61STRING 20 +#define V_ASN1_TELETEXSTRING 20 /* alias */ +#define V_ASN1_VIDEOTEXSTRING 21 /**/ +#define V_ASN1_IA5STRING 22 +#define V_ASN1_UTCTIME 23 +#define V_ASN1_GENERALIZEDTIME 24 /**/ +#define V_ASN1_GRAPHICSTRING 25 /**/ +#define V_ASN1_ISO64STRING 26 /**/ +#define V_ASN1_VISIBLESTRING 26 /* alias */ +#define V_ASN1_GENERALSTRING 27 /**/ +#define V_ASN1_UNIVERSALSTRING 28 /**/ +#define V_ASN1_BMPSTRING 30 + +/* For use with d2i_ASN1_type_bytes() */ +#define B_ASN1_NUMERICSTRING 0x0001 +#define B_ASN1_PRINTABLESTRING 0x0002 +#define B_ASN1_T61STRING 0x0004 +#define B_ASN1_TELETEXSTRING 0x0004 +#define B_ASN1_VIDEOTEXSTRING 0x0008 +#define B_ASN1_IA5STRING 0x0010 +#define B_ASN1_GRAPHICSTRING 0x0020 +#define B_ASN1_ISO64STRING 0x0040 +#define B_ASN1_VISIBLESTRING 0x0040 +#define B_ASN1_GENERALSTRING 0x0080 +#define B_ASN1_UNIVERSALSTRING 0x0100 +#define B_ASN1_OCTET_STRING 0x0200 +#define B_ASN1_BIT_STRING 0x0400 +#define B_ASN1_BMPSTRING 0x0800 +#define B_ASN1_UNKNOWN 0x1000 +#define B_ASN1_UTF8STRING 0x2000 +#define B_ASN1_UTCTIME 0x4000 +#define B_ASN1_GENERALIZEDTIME 0x8000 +#define B_ASN1_SEQUENCE 0x10000 + +/* For use with ASN1_mbstring_copy() */ +#define MBSTRING_FLAG 0x1000 +#define MBSTRING_UTF8 (MBSTRING_FLAG) +#define MBSTRING_ASC (MBSTRING_FLAG|1) +#define MBSTRING_BMP (MBSTRING_FLAG|2) +#define MBSTRING_UNIV (MBSTRING_FLAG|4) + +struct X509_algor_st; + +#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ +#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ + +/* We MUST make sure that, except for constness, asn1_ctx_st and + asn1_const_ctx are exactly the same. Fortunately, as soon as + the old ASN1 parsing macros are gone, we can throw this away + as well... */ +typedef struct asn1_ctx_st + { + unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + unsigned char *max; /* largest value of p allowed */ + unsigned char *q;/* temporary variable */ + unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_CTX; + +typedef struct asn1_const_ctx_st + { + const unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + const unsigned char *max; /* largest value of p allowed */ + const unsigned char *q;/* temporary variable */ + const unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_const_CTX; + +/* These are used internally in the ASN1_OBJECT to keep track of + * whether the names and data need to be free()ed */ +#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ +#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ +#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ +#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ +typedef struct asn1_object_st + { + const char *sn,*ln; + int nid; + int length; + unsigned char *data; + int flags; /* Should we free this one */ + } ASN1_OBJECT; + +#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ +/* This indicates that the ASN1_STRING is not a real value but just a place + * holder for the location where indefinite length constructed data should + * be inserted in the memory buffer + */ +#define ASN1_STRING_FLAG_NDEF 0x010 +/* This is the base type that holds just about everything :-) */ +typedef struct asn1_string_st + { + int length; + int type; + unsigned char *data; + /* The value of the following field depends on the type being + * held. It is mostly being used for BIT_STRING so if the + * input data has a non-zero 'unused bits' value, it will be + * handled correctly */ + long flags; + } ASN1_STRING; + +/* ASN1_ENCODING structure: this is used to save the received + * encoding of an ASN1 type. This is useful to get round + * problems with invalid encodings which can break signatures. + */ + +typedef struct ASN1_ENCODING_st + { + unsigned char *enc; /* DER encoding */ + long len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ + } ASN1_ENCODING; + +/* Used with ASN1 LONG type: if a long is set to this it is omitted */ +#define ASN1_LONG_UNDEF 0x7fffffffL + +#define STABLE_FLAGS_MALLOC 0x01 +#define STABLE_NO_MASK 0x02 +#define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) +#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) + +typedef struct asn1_string_table_st { + int nid; + long minsize; + long maxsize; + unsigned long mask; + unsigned long flags; +} ASN1_STRING_TABLE; + +DECLARE_STACK_OF(ASN1_STRING_TABLE) + +/* size limits: this stuff is taken straight from RFC2459 */ + +#define ub_name 32768 +#define ub_common_name 64 +#define ub_locality_name 128 +#define ub_state_name 128 +#define ub_organization_name 64 +#define ub_organization_unit_name 64 +#define ub_title 64 +#define ub_email_address 128 + +/* Declarations for template structures: for full definitions + * see asn1t.h + */ +typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; +typedef struct ASN1_ITEM_st ASN1_ITEM; +typedef struct ASN1_TLC_st ASN1_TLC; +/* This is just an opaque pointer */ +typedef struct ASN1_VALUE_st ASN1_VALUE; + +/* Declare ASN1 functions: the implement macro in in asn1t.h */ + +#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) + +#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(itname) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(const type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(name) + +#define DECLARE_ASN1_NDEF_FUNCTION(name) \ + int i2d_##name##_NDEF(name *a, unsigned char **out); + +#define DECLARE_ASN1_FUNCTIONS_const(name) \ + name *name##_new(void); \ + void name##_free(name *a); + +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + type *name##_new(void); \ + void name##_free(type *a); + +#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) +#define I2D_OF(type) int (*)(type *,unsigned char **) +#define I2D_OF_const(type) int (*)(const type *,unsigned char **) + +#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) +#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) +#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) + +TYPEDEF_D2I2D_OF(void); + +/* The following macros and typedefs allow an ASN1_ITEM + * to be embedded in a structure and referenced. Since + * the ASN1_ITEM pointers need to be globally accessible + * (possibly from shared libraries) they may exist in + * different forms. On platforms that support it the + * ASN1_ITEM structure itself will be globally exported. + * Other platforms will export a function that returns + * an ASN1_ITEM pointer. + * + * To handle both cases transparently the macros below + * should be used instead of hard coding an ASN1_ITEM + * pointer in a structure. + * + * The structure will look like this: + * + * typedef struct SOMETHING_st { + * ... + * ASN1_ITEM_EXP *iptr; + * ... + * } SOMETHING; + * + * It would be initialised as e.g.: + * + * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; + * + * and the actual pointer extracted with: + * + * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); + * + * Finally an ASN1_ITEM pointer can be extracted from an + * appropriate reference with: ASN1_ITEM_rptr(X509). This + * would be used when a function takes an ASN1_ITEM * argument. + * + */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM ASN1_ITEM_EXP; + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) + +#define ASN1_ITEM_rptr(ref) (&(ref##_it)) + +#define DECLARE_ASN1_ITEM(name) \ + OPENSSL_EXTERN const ASN1_ITEM name##_it; + +#else + +/* Platforms that can't easily handle shared global variables are declared + * as functions returning ASN1_ITEM pointers. + */ + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM * ASN1_ITEM_EXP(void); + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr()) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (iptr##_it) + +#define ASN1_ITEM_rptr(ref) (ref##_it()) + +#define DECLARE_ASN1_ITEM(name) \ + const ASN1_ITEM * name##_it(void); + +#endif + +/* Parameters used by ASN1_STRING_print_ex() */ + +/* These determine which characters to escape: + * RFC2253 special characters, control characters and + * MSB set characters + */ + +#define ASN1_STRFLGS_ESC_2253 1 +#define ASN1_STRFLGS_ESC_CTRL 2 +#define ASN1_STRFLGS_ESC_MSB 4 + + +/* This flag determines how we do escaping: normally + * RC2253 backslash only, set this to use backslash and + * quote. + */ + +#define ASN1_STRFLGS_ESC_QUOTE 8 + + +/* These three flags are internal use only. */ + +/* Character is a valid PrintableString character */ +#define CHARTYPE_PRINTABLESTRING 0x10 +/* Character needs escaping if it is the first character */ +#define CHARTYPE_FIRST_ESC_2253 0x20 +/* Character needs escaping if it is the last character */ +#define CHARTYPE_LAST_ESC_2253 0x40 + +/* NB the internal flags are safely reused below by flags + * handled at the top level. + */ + +/* If this is set we convert all character strings + * to UTF8 first + */ + +#define ASN1_STRFLGS_UTF8_CONVERT 0x10 + +/* If this is set we don't attempt to interpret content: + * just assume all strings are 1 byte per character. This + * will produce some pretty odd looking output! + */ + +#define ASN1_STRFLGS_IGNORE_TYPE 0x20 + +/* If this is set we include the string type in the output */ +#define ASN1_STRFLGS_SHOW_TYPE 0x40 + +/* This determines which strings to display and which to + * 'dump' (hex dump of content octets or DER encoding). We can + * only dump non character strings or everything. If we + * don't dump 'unknown' they are interpreted as character + * strings with 1 octet per character and are subject to + * the usual escaping options. + */ + +#define ASN1_STRFLGS_DUMP_ALL 0x80 +#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 + +/* These determine what 'dumping' does, we can dump the + * content octets or the DER encoding: both use the + * RFC2253 #XXXXX notation. + */ + +#define ASN1_STRFLGS_DUMP_DER 0x200 + +/* All the string flags consistent with RFC2253, + * escaping control characters isn't essential in + * RFC2253 but it is advisable anyway. + */ + +#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER) + +DECLARE_STACK_OF(ASN1_INTEGER) +DECLARE_ASN1_SET_OF(ASN1_INTEGER) + +DECLARE_STACK_OF(ASN1_GENERALSTRING) + +typedef struct asn1_type_st + { + int type; + union { + char *ptr; + ASN1_BOOLEAN boolean; + ASN1_STRING * asn1_string; + ASN1_OBJECT * object; + ASN1_INTEGER * integer; + ASN1_ENUMERATED * enumerated; + ASN1_BIT_STRING * bit_string; + ASN1_OCTET_STRING * octet_string; + ASN1_PRINTABLESTRING * printablestring; + ASN1_T61STRING * t61string; + ASN1_IA5STRING * ia5string; + ASN1_GENERALSTRING * generalstring; + ASN1_BMPSTRING * bmpstring; + ASN1_UNIVERSALSTRING * universalstring; + ASN1_UTCTIME * utctime; + ASN1_GENERALIZEDTIME * generalizedtime; + ASN1_VISIBLESTRING * visiblestring; + ASN1_UTF8STRING * utf8string; + /* set and sequence are left complete and still + * contain the set or sequence bytes */ + ASN1_STRING * set; + ASN1_STRING * sequence; + } value; + } ASN1_TYPE; + +DECLARE_STACK_OF(ASN1_TYPE) +DECLARE_ASN1_SET_OF(ASN1_TYPE) + +typedef struct asn1_method_st + { + i2d_of_void *i2d; + d2i_of_void *d2i; + void *(*create)(void); + void (*destroy)(void *); + } ASN1_METHOD; + +/* This is used when parsing some Netscape objects */ +typedef struct asn1_header_st + { + ASN1_OCTET_STRING *header; + void *data; + ASN1_METHOD *meth; + } ASN1_HEADER; + +/* This is used to contain a list of bit names */ +typedef struct BIT_STRING_BITNAME_st { + int bitnum; + const char *lname; + const char *sname; +} BIT_STRING_BITNAME; + + +#define M_ASN1_STRING_length(x) ((x)->length) +#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) +#define M_ASN1_STRING_type(x) ((x)->type) +#define M_ASN1_STRING_data(x) ((x)->data) + +/* Macros for string operations */ +#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ + ASN1_STRING_type_new(V_ASN1_BIT_STRING) +#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) + +#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ + ASN1_STRING_type_new(V_ASN1_INTEGER) +#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ + ASN1_STRING_type_new(V_ASN1_ENUMERATED) +#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ + ASN1_STRING_type_new(V_ASN1_OCTET_STRING) +#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) +#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) +#define M_i2d_ASN1_OCTET_STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ + V_ASN1_UNIVERSAL) + +#define B_ASN1_TIME \ + B_ASN1_UTCTIME | \ + B_ASN1_GENERALIZEDTIME + +#define B_ASN1_PRINTABLE \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_T61STRING| \ + B_ASN1_IA5STRING| \ + B_ASN1_BIT_STRING| \ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING|\ + B_ASN1_SEQUENCE|\ + B_ASN1_UNKNOWN + +#define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_TELETEXSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_UTF8STRING + +#define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING| \ + B_ASN1_VISIBLESTRING| \ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING + +#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_PRINTABLE) + +#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DIRECTORYSTRING(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DIRECTORYSTRING) + +#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DISPLAYTEXT(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DISPLAYTEXT) + +#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ + (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) + +#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ + ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_T61STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_T61STRING(a,pp,l) \ + (ASN1_T61STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) + +#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ + ASN1_STRING_type_new(V_ASN1_IA5STRING) +#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_IA5STRING_dup(a) \ + (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_i2d_ASN1_IA5STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_IA5STRING(a,pp,l) \ + (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ + B_ASN1_IA5STRING) + +#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ + ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) +#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ + (ASN1_STRING *)a) + +#define M_ASN1_TIME_new() (ASN1_TIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_GENERALSTRING) +#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_GENERALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ + (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) + +#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) +#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ + (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) + +#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ + ASN1_STRING_type_new(V_ASN1_BMPSTRING) +#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_BMPSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_BMPSTRING(a,pp,l) \ + (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) + +#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ + (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) + +#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ + ASN1_STRING_type_new(V_ASN1_UTF8STRING) +#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UTF8STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UTF8STRING(a,pp,l) \ + (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) + + /* for the is_set parameter to i2d_ASN1_SET */ +#define IS_SEQUENCE 0 +#define IS_SET 1 + +DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) + +int ASN1_TYPE_get(ASN1_TYPE *a); +void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); + +ASN1_OBJECT * ASN1_OBJECT_new(void ); +void ASN1_OBJECT_free(ASN1_OBJECT *a); +int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); +ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); +ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); + +DECLARE_ASN1_ITEM(ASN1_OBJECT) + +DECLARE_STACK_OF(ASN1_OBJECT) +DECLARE_ASN1_SET_OF(ASN1_OBJECT) + +ASN1_STRING * ASN1_STRING_new(void); +void ASN1_STRING_free(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_type_new(int type ); +int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); + /* Since this is used to store all sorts of things, via macros, for now, make + its data void * */ +int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); +int ASN1_STRING_length(ASN1_STRING *x); +void ASN1_STRING_length_set(ASN1_STRING *x, int n); +int ASN1_STRING_type(ASN1_STRING *x); +unsigned char * ASN1_STRING_data(ASN1_STRING *x); + +DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) +int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); +ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp, + long length); +int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, + int length ); +int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); +int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); + +#ifndef OPENSSL_NO_BIO +int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, + BIT_STRING_BITNAME *tbl, int indent); +#endif +int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); +int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, + BIT_STRING_BITNAME *tbl); + +int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); +int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) +int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); +ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); +int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); + +DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) + +int ASN1_UTCTIME_check(ASN1_UTCTIME *a); +ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); +int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); +int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); +#if 0 +time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); +#endif + +int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); +int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); + +DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) +ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); +int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); +int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); + +DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_NULL) +DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) + +int UTF8_getc(const unsigned char *str, int len, unsigned long *val); +int UTF8_putc(unsigned char *str, int len, unsigned long value); + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) +DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_TIME) + +DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) + +ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); +int ASN1_TIME_check(ASN1_TIME *t); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); + +int i2d_ASN1_SET(STACK *a, unsigned char **pp, + i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); +STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, + d2i_of_void *d2i, void (*free_func)(void *), + int ex_tag, int ex_class); + +#ifndef OPENSSL_NO_BIO +int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); +int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); +int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); +int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size); +int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); +int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size); +int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); +#endif +int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a); + +int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); +ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, + const char *sn, const char *ln); + +int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); +long ASN1_INTEGER_get(ASN1_INTEGER *a); +ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai); +BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn); + +int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); +long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); +ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); +BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); + +/* General */ +/* given a string, return the correct type, max is the maximum length */ +int ASN1_PRINTABLE_type(const unsigned char *s, int max); + +int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); +ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, + long length, int Ptag, int Pclass); +unsigned long ASN1_tag2bit(int tag); +/* type is one or more of the B_ASN1_ values. */ +ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, + long length,int type); + +/* PARSING */ +int asn1_Finish(ASN1_CTX *c); +int asn1_const_Finish(ASN1_const_CTX *c); + +/* SPECIALS */ +int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax); +int ASN1_check_infinite_end(unsigned char **p,long len); +int ASN1_const_check_infinite_end(const unsigned char **p,long len); +void ASN1_put_object(unsigned char **pp, int constructed, int length, + int tag, int xclass); +int ASN1_put_eoc(unsigned char **pp); +int ASN1_object_size(int constructed, int length, int tag); + +/* Used to implement other functions */ +void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); +#define ASN1_dup_of(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) +#define ASN1_dup_of_const(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) + +void *ASN1_item_dup(const ASN1_ITEM *it, void *x); + +#ifndef OPENSSL_NO_FP_API +void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); +#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x) +void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); +int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); +#define ASN1_i2d_fp_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +#define ASN1_i2d_fp_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); +int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); +#endif + +int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); + +#ifndef OPENSSL_NO_BIO +void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); +#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x) +void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); +int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); +#define ASN1_i2d_bio_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +#define ASN1_i2d_bio_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); +int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); +int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); +int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); +int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); +int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); +int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); +int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); +#endif +const char *ASN1_tag2str(int tag); + +/* Used to load and write netscape format cert/key */ +int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); +ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length); +ASN1_HEADER *ASN1_HEADER_new(void ); +void ASN1_HEADER_free(ASN1_HEADER *a); + +int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); + +/* Not used that much at this point, except for the first two */ +ASN1_METHOD *X509_asn1_meth(void); +ASN1_METHOD *RSAPrivateKey_asn1_meth(void); +ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void); +ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void); + +int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, + unsigned char *data, int len); +int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, + unsigned char *data, int max_len); +int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, + unsigned char *data, int max_len); + +STACK *ASN1_seq_unpack(const unsigned char *buf, int len, + d2i_of_void *d2i, void (*free_func)(void *)); +unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, + unsigned char **buf, int *len ); +void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); +void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); +ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, + ASN1_OCTET_STRING **oct); +#define ASN1_pack_string_of(type,obj,i2d,oct) \ + ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct) +ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); + +void ASN1_STRING_set_default_mask(unsigned long mask); +int ASN1_STRING_set_default_mask_asc(char *p); +unsigned long ASN1_STRING_get_default_mask(void); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask); +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask, + long minsize, long maxsize); + +ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, + const unsigned char *in, int inlen, int inform, int nid); +ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); +int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); +void ASN1_STRING_TABLE_cleanup(void); + +/* ASN1 template functions */ + +/* Old API compatible functions */ +ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); +void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); +ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); +int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); +int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); + +void ASN1_add_oid_module(void); + +ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); +ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ASN1_strings(void); + +/* Error codes for the ASN1 functions. */ + +/* Function codes. */ +#define ASN1_F_A2D_ASN1_OBJECT 100 +#define ASN1_F_A2I_ASN1_ENUMERATED 101 +#define ASN1_F_A2I_ASN1_INTEGER 102 +#define ASN1_F_A2I_ASN1_STRING 103 +#define ASN1_F_APPEND_EXP 176 +#define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 +#define ASN1_F_ASN1_CB 177 +#define ASN1_F_ASN1_CHECK_TLEN 104 +#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 +#define ASN1_F_ASN1_COLLECT 106 +#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 +#define ASN1_F_ASN1_D2I_FP 109 +#define ASN1_F_ASN1_D2I_READ_BIO 107 +#define ASN1_F_ASN1_DIGEST 184 +#define ASN1_F_ASN1_DO_ADB 110 +#define ASN1_F_ASN1_DUP 111 +#define ASN1_F_ASN1_ENUMERATED_SET 112 +#define ASN1_F_ASN1_ENUMERATED_TO_BN 113 +#define ASN1_F_ASN1_EX_C2I 204 +#define ASN1_F_ASN1_FIND_END 190 +#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 +#define ASN1_F_ASN1_GENERATE_V3 178 +#define ASN1_F_ASN1_GET_OBJECT 114 +#define ASN1_F_ASN1_HEADER_NEW 115 +#define ASN1_F_ASN1_I2D_BIO 116 +#define ASN1_F_ASN1_I2D_FP 117 +#define ASN1_F_ASN1_INTEGER_SET 118 +#define ASN1_F_ASN1_INTEGER_TO_BN 119 +#define ASN1_F_ASN1_ITEM_D2I_FP 206 +#define ASN1_F_ASN1_ITEM_DUP 191 +#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 +#define ASN1_F_ASN1_ITEM_EX_D2I 120 +#define ASN1_F_ASN1_ITEM_I2D_BIO 192 +#define ASN1_F_ASN1_ITEM_I2D_FP 193 +#define ASN1_F_ASN1_ITEM_PACK 198 +#define ASN1_F_ASN1_ITEM_SIGN 195 +#define ASN1_F_ASN1_ITEM_UNPACK 199 +#define ASN1_F_ASN1_ITEM_VERIFY 197 +#define ASN1_F_ASN1_MBSTRING_NCOPY 122 +#define ASN1_F_ASN1_OBJECT_NEW 123 +#define ASN1_F_ASN1_PACK_STRING 124 +#define ASN1_F_ASN1_PCTX_NEW 205 +#define ASN1_F_ASN1_PKCS5_PBE_SET 125 +#define ASN1_F_ASN1_SEQ_PACK 126 +#define ASN1_F_ASN1_SEQ_UNPACK 127 +#define ASN1_F_ASN1_SIGN 128 +#define ASN1_F_ASN1_STR2TYPE 179 +#define ASN1_F_ASN1_STRING_SET 186 +#define ASN1_F_ASN1_STRING_TABLE_ADD 129 +#define ASN1_F_ASN1_STRING_TYPE_NEW 130 +#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 +#define ASN1_F_ASN1_TEMPLATE_NEW 133 +#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 +#define ASN1_F_ASN1_TIME_SET 175 +#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 +#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 +#define ASN1_F_ASN1_UNPACK_STRING 136 +#define ASN1_F_ASN1_UTCTIME_SET 187 +#define ASN1_F_ASN1_VERIFY 137 +#define ASN1_F_BITSTR_CB 180 +#define ASN1_F_BN_TO_ASN1_ENUMERATED 138 +#define ASN1_F_BN_TO_ASN1_INTEGER 139 +#define ASN1_F_C2I_ASN1_BIT_STRING 189 +#define ASN1_F_C2I_ASN1_INTEGER 194 +#define ASN1_F_C2I_ASN1_OBJECT 196 +#define ASN1_F_COLLECT_DATA 140 +#define ASN1_F_D2I_ASN1_BIT_STRING 141 +#define ASN1_F_D2I_ASN1_BOOLEAN 142 +#define ASN1_F_D2I_ASN1_BYTES 143 +#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 +#define ASN1_F_D2I_ASN1_HEADER 145 +#define ASN1_F_D2I_ASN1_INTEGER 146 +#define ASN1_F_D2I_ASN1_OBJECT 147 +#define ASN1_F_D2I_ASN1_SET 148 +#define ASN1_F_D2I_ASN1_TYPE_BYTES 149 +#define ASN1_F_D2I_ASN1_UINTEGER 150 +#define ASN1_F_D2I_ASN1_UTCTIME 151 +#define ASN1_F_D2I_NETSCAPE_RSA 152 +#define ASN1_F_D2I_NETSCAPE_RSA_2 153 +#define ASN1_F_D2I_PRIVATEKEY 154 +#define ASN1_F_D2I_PUBLICKEY 155 +#define ASN1_F_D2I_RSA_NET 200 +#define ASN1_F_D2I_RSA_NET_2 201 +#define ASN1_F_D2I_X509 156 +#define ASN1_F_D2I_X509_CINF 157 +#define ASN1_F_D2I_X509_PKEY 159 +#define ASN1_F_I2D_ASN1_SET 188 +#define ASN1_F_I2D_ASN1_TIME 160 +#define ASN1_F_I2D_DSA_PUBKEY 161 +#define ASN1_F_I2D_EC_PUBKEY 181 +#define ASN1_F_I2D_PRIVATEKEY 163 +#define ASN1_F_I2D_PUBLICKEY 164 +#define ASN1_F_I2D_RSA_NET 162 +#define ASN1_F_I2D_RSA_PUBKEY 165 +#define ASN1_F_LONG_C2I 166 +#define ASN1_F_OID_MODULE_INIT 174 +#define ASN1_F_PARSE_TAGGING 182 +#define ASN1_F_PKCS5_PBE2_SET 167 +#define ASN1_F_PKCS5_PBE_SET 202 +#define ASN1_F_X509_CINF_NEW 168 +#define ASN1_F_X509_CRL_ADD0_REVOKED 169 +#define ASN1_F_X509_INFO_NEW 170 +#define ASN1_F_X509_NAME_ENCODE 203 +#define ASN1_F_X509_NAME_EX_D2I 158 +#define ASN1_F_X509_NAME_EX_NEW 171 +#define ASN1_F_X509_NEW 172 +#define ASN1_F_X509_PKEY_NEW 173 + +/* Reason codes. */ +#define ASN1_R_ADDING_OBJECT 171 +#define ASN1_R_AUX_ERROR 100 +#define ASN1_R_BAD_CLASS 101 +#define ASN1_R_BAD_OBJECT_HEADER 102 +#define ASN1_R_BAD_PASSWORD_READ 103 +#define ASN1_R_BAD_TAG 104 +#define ASN1_R_BN_LIB 105 +#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 +#define ASN1_R_BUFFER_TOO_SMALL 107 +#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 +#define ASN1_R_DATA_IS_WRONG 109 +#define ASN1_R_DECODE_ERROR 110 +#define ASN1_R_DECODING_ERROR 111 +#define ASN1_R_DEPTH_EXCEEDED 174 +#define ASN1_R_ENCODE_ERROR 112 +#define ASN1_R_ERROR_GETTING_TIME 173 +#define ASN1_R_ERROR_LOADING_SECTION 172 +#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 +#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 +#define ASN1_R_EXPECTING_AN_INTEGER 115 +#define ASN1_R_EXPECTING_AN_OBJECT 116 +#define ASN1_R_EXPECTING_A_BOOLEAN 117 +#define ASN1_R_EXPECTING_A_TIME 118 +#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 +#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 +#define ASN1_R_FIELD_MISSING 121 +#define ASN1_R_FIRST_NUM_TOO_LARGE 122 +#define ASN1_R_HEADER_TOO_LONG 123 +#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 +#define ASN1_R_ILLEGAL_BOOLEAN 176 +#define ASN1_R_ILLEGAL_CHARACTERS 124 +#define ASN1_R_ILLEGAL_FORMAT 177 +#define ASN1_R_ILLEGAL_HEX 178 +#define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 +#define ASN1_R_ILLEGAL_INTEGER 180 +#define ASN1_R_ILLEGAL_NESTED_TAGGING 181 +#define ASN1_R_ILLEGAL_NULL 125 +#define ASN1_R_ILLEGAL_NULL_VALUE 182 +#define ASN1_R_ILLEGAL_OBJECT 183 +#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 +#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 +#define ASN1_R_ILLEGAL_TAGGED_ANY 127 +#define ASN1_R_ILLEGAL_TIME_VALUE 184 +#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 +#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 +#define ASN1_R_INVALID_BMPSTRING_LENGTH 129 +#define ASN1_R_INVALID_DIGIT 130 +#define ASN1_R_INVALID_MODIFIER 186 +#define ASN1_R_INVALID_NUMBER 187 +#define ASN1_R_INVALID_SEPARATOR 131 +#define ASN1_R_INVALID_TIME_FORMAT 132 +#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 +#define ASN1_R_INVALID_UTF8STRING 134 +#define ASN1_R_IV_TOO_LARGE 135 +#define ASN1_R_LENGTH_ERROR 136 +#define ASN1_R_LIST_ERROR 188 +#define ASN1_R_MISSING_EOC 137 +#define ASN1_R_MISSING_SECOND_NUMBER 138 +#define ASN1_R_MISSING_VALUE 189 +#define ASN1_R_MSTRING_NOT_UNIVERSAL 139 +#define ASN1_R_MSTRING_WRONG_TAG 140 +#define ASN1_R_NESTED_ASN1_STRING 197 +#define ASN1_R_NON_HEX_CHARACTERS 141 +#define ASN1_R_NOT_ASCII_FORMAT 190 +#define ASN1_R_NOT_ENOUGH_DATA 142 +#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 +#define ASN1_R_NULL_IS_WRONG_LENGTH 144 +#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 +#define ASN1_R_ODD_NUMBER_OF_CHARS 145 +#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 +#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 +#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 +#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 +#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 +#define ASN1_R_SHORT_LINE 150 +#define ASN1_R_STRING_TOO_LONG 151 +#define ASN1_R_STRING_TOO_SHORT 152 +#define ASN1_R_TAG_VALUE_TOO_HIGH 153 +#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 +#define ASN1_R_TIME_NOT_ASCII_FORMAT 193 +#define ASN1_R_TOO_LONG 155 +#define ASN1_R_TYPE_NOT_CONSTRUCTED 156 +#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 +#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 +#define ASN1_R_UNEXPECTED_EOC 159 +#define ASN1_R_UNKNOWN_FORMAT 160 +#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 +#define ASN1_R_UNKNOWN_OBJECT_TYPE 162 +#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 +#define ASN1_R_UNKNOWN_TAG 194 +#define ASN1_R_UNKOWN_FORMAT 195 +#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 +#define ASN1_R_UNSUPPORTED_CIPHER 165 +#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 +#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 +#define ASN1_R_UNSUPPORTED_TYPE 196 +#define ASN1_R_WRONG_TAG 168 +#define ASN1_R_WRONG_TYPE 169 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/asn1_mac.h b/libraries/external/openssl/linux/include/openssl/asn1_mac.h new file mode 100755 index 0000000..1ac54cf --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/asn1_mac.h @@ -0,0 +1,571 @@ +/* crypto/asn1/asn1_mac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_MAC_H +#define HEADER_ASN1_MAC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASN1_MAC_ERR_LIB +#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1 +#endif + +#define ASN1_MAC_H_err(f,r,line) \ + ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line)) + +#define M_ASN1_D2I_vars(a,type,func) \ + ASN1_const_CTX c; \ + type ret=NULL; \ + \ + c.pp=(const unsigned char **)pp; \ + c.q= *(const unsigned char **)pp; \ + c.error=ERR_R_NESTED_ASN1_ERROR; \ + if ((a == NULL) || ((*a) == NULL)) \ + { if ((ret=(type)func()) == NULL) \ + { c.line=__LINE__; goto err; } } \ + else ret=(*a); + +#define M_ASN1_D2I_Init() \ + c.p= *(const unsigned char **)pp; \ + c.max=(length == 0)?0:(c.p+length); + +#define M_ASN1_D2I_Finish_2(a) \ + if (!asn1_const_Finish(&c)) \ + { c.line=__LINE__; goto err; } \ + *(const unsigned char **)pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); + +#define M_ASN1_D2I_Finish(a,func,e) \ + M_ASN1_D2I_Finish_2(a); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_start_sequence() \ + if (!asn1_GetSequence(&c,&length)) \ + { c.line=__LINE__; goto err; } +/* Begin reading ASN1 without a surrounding sequence */ +#define M_ASN1_D2I_begin() \ + c.slen = length; + +/* End reading ASN1 with no check on length */ +#define M_ASN1_D2I_Finish_nolen(a, func, e) \ + *pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_end_sequence() \ + (((c.inf&1) == 0)?(c.slen <= 0): \ + (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen))) + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get(b, func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get_x(type,b,func) \ + c.q=c.p; \ + if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* use this instead () */ +#define M_ASN1_D2I_get_int(b,func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) < 0) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_opt(b,func,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ + == (V_ASN1_UNIVERSAL|(type)))) \ + { \ + M_ASN1_D2I_get(b,func); \ + } + +#define M_ASN1_D2I_get_imp(b,func, type) \ + M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \ + c.slen-=(c.p-c.q);\ + M_ASN1_next_prev=_tmp; + +#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \ + (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \ + { \ + unsigned char _tmp = M_ASN1_next; \ + M_ASN1_D2I_get_imp(b,func, type);\ + } + +#define M_ASN1_D2I_get_set(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set(r,func,free_func); } + +#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set_type(type,r,func,free_func); } + +#define M_ASN1_I2D_len_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SET(a,f); + +#define M_ASN1_I2D_put_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SET(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE_type(type,a,f); + +#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set(b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_seq(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq(r,func,free_func); } + +#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq_type(type,r,func,free_func); } + +#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\ + (void (*)())free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\ + free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_set_strings(r,func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \ + if ((c.slen != 0L) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (func(&(r),&c.p,Tlen) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \ + (void (*)())free_func, \ + b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \ + free_func,b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +/* New macros */ +#define M_ASN1_New_Malloc(ret,type) \ + if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ + { c.line=__LINE__; goto err2; } + +#define M_ASN1_New(arg,func) \ + if (((arg)=func()) == NULL) return(NULL) + +#define M_ASN1_New_Error(a) \ +/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \ + return(NULL);*/ \ + err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \ + return(NULL) + + +/* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, + some macros that use ASN1_const_CTX still insist on writing in the input + stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. + Please? -- Richard Levitte */ +#define M_ASN1_next (*((unsigned char *)(c.p))) +#define M_ASN1_next_prev (*((unsigned char *)(c.q))) + +/*************************************************/ + +#define M_ASN1_I2D_vars(a) int r=0,ret=0; \ + unsigned char *p; \ + if (a == NULL) return(0) + +/* Length Macros */ +#define M_ASN1_I2D_len(a,f) ret+=f(a,NULL) +#define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f) + +#define M_ASN1_I2D_len_SET(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SET_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \ + V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SEQUENCE(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE(a,f); + +#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE_type(type,a,f); + +#define M_ASN1_I2D_len_IMP_SET(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \ + if (a != NULL)\ + { \ + v=f(a,NULL); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0))\ + { \ + v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \ + V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +/* Put Macros */ +#define M_ASN1_I2D_put(a,f) f(a,&p) + +#define M_ASN1_I2D_put_IMP_opt(a,f,t) \ + if (a != NULL) \ + { \ + unsigned char *q=p; \ + f(a,&p); \ + *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\ + } + +#define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\ + V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_SET_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \ + i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \ + if (a != NULL) \ + { \ + ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \ + f(a,&p); \ + } + +#define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_seq_total() \ + r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ + if (pp == NULL) return(r); \ + p= *pp; \ + ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_I2D_INF_seq_start(tag,ctx) \ + *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \ + *(p++)=0x80 + +#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00 + +#define M_ASN1_I2D_finish() *pp=p; \ + return(r); + +int asn1_GetSequence(ASN1_const_CTX *c, long *length); +void asn1_add_error(const unsigned char *address,int offset); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/asn1t.h b/libraries/external/openssl/linux/include/openssl/asn1t.h new file mode 100755 index 0000000..4fd99e3 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/asn1t.h @@ -0,0 +1,886 @@ +/* asn1t.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ASN1T_H +#define HEADER_ASN1T_H + +#include +#include +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +/* ASN1 template defines, structures and functions */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { + +#define ASN1_ITEM_end(itname) \ + }; + +#else + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + const ASN1_ITEM * itname##_it(void) \ + { \ + static const ASN1_ITEM local_it = { + +#define ASN1_ITEM_end(itname) \ + }; \ + return &local_it; \ + } + +#endif + + +/* Macros to aid ASN1 template writing */ + +#define ASN1_ITEM_TEMPLATE(tname) \ + static const ASN1_TEMPLATE tname##_item_tt + +#define ASN1_ITEM_TEMPLATE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_PRIMITIVE,\ + -1,\ + &tname##_item_tt,\ + 0,\ + NULL,\ + 0,\ + #tname \ + ASN1_ITEM_end(tname) + + +/* This is a ASN1 type which just embeds a template */ + +/* This pair helps declare a SEQUENCE. We can do: + * + * ASN1_SEQUENCE(stname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END(stname) + * + * This will produce an ASN1_ITEM called stname_it + * for a structure called stname. + * + * If you want the same structure but a different + * name then use: + * + * ASN1_SEQUENCE(itname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END_name(stname, itname) + * + * This will create an item called itname_it using + * a structure called stname. + */ + +#define ASN1_SEQUENCE(tname) \ + static const ASN1_TEMPLATE tname##_seq_tt[] + +#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) + +#define ASN1_SEQUENCE_END_name(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_NDEF_SEQUENCE(tname) \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_BROKEN_SEQUENCE(tname) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_ref(tname, cb, lck) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_enc(tname, enc, cb) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_NDEF_SEQUENCE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(tname),\ + #tname \ + ASN1_ITEM_end(tname) + +#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) + +#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_ref(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + + +/* This pair helps declare a CHOICE type. We can do: + * + * ASN1_CHOICE(chname) = { + * ... CHOICE options ... + * ASN1_CHOICE_END(chname) + * + * This will produce an ASN1_ITEM called chname_it + * for a structure called chname. The structure + * definition must look like this: + * typedef struct { + * int type; + * union { + * ASN1_SOMETHING *opt1; + * ASN1_SOMEOTHER *opt2; + * } value; + * } chname; + * + * the name of the selector must be 'type'. + * to use an alternative selector name use the + * ASN1_CHOICE_END_selector() version. + */ + +#define ASN1_CHOICE(tname) \ + static const ASN1_TEMPLATE tname##_ch_tt[] + +#define ASN1_CHOICE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_CHOICE(tname) + +#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) + +#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) + +#define ASN1_CHOICE_END_selector(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_CHOICE_END_cb(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +/* This helps with the template wrapper form of ASN1_ITEM */ + +#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ + (flags), (tag), 0,\ + #name, ASN1_ITEM_ref(type) } + +/* These help with SEQUENCE or CHOICE components */ + +/* used to declare other types */ + +#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ + (flags), (tag), offsetof(stname, field),\ + #field, ASN1_ITEM_ref(type) } + +/* used when the structure is combined with the parent */ + +#define ASN1_EX_COMBINE(flags, tag, type) { \ + (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } + +/* implicit and explicit helper macros */ + +#define ASN1_IMP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) + +#define ASN1_EXP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) + +/* Any defined by macros: the field used is in the table itself */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#else +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } +#endif +/* Plain simple type */ +#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) + +/* OPTIONAL simple type */ +#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* IMPLICIT tagged simple type */ +#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) + +/* IMPLICIT tagged OPTIONAL simple type */ +#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* Same as above but EXPLICIT */ + +#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) +#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* SEQUENCE OF type */ +#define ASN1_SEQUENCE_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) + +/* OPTIONAL SEQUENCE OF */ +#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Same as above but for SET OF */ + +#define ASN1_SET_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) + +#define ASN1_SET_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ + +#define ASN1_IMP_SET_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_EXP_SET_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +/* EXPLICIT OPTIONAL using indefinite length constructed form */ +#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) + +/* Macros for the ASN1_ADB structure */ + +#define ASN1_ADB(name) \ + static const ASN1_ADB_TABLE name##_adbtbl[] + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ADB name##_adb = {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + } + +#else + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ITEM *name##_adb(void) \ + { \ + static const ASN1_ADB internal_adb = \ + {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + }; \ + return (const ASN1_ITEM *) &internal_adb; \ + } \ + void dummy_function(void) + +#endif + +#define ADB_ENTRY(val, template) {val, template} + +#define ASN1_ADB_TEMPLATE(name) \ + static const ASN1_TEMPLATE name##_tt + +/* This is the ASN1 template structure that defines + * a wrapper round the actual type. It determines the + * actual position of the field in the value structure, + * various flags such as OPTIONAL and the field name. + */ + +struct ASN1_TEMPLATE_st { +unsigned long flags; /* Various flags */ +long tag; /* tag, not used if no tagging */ +unsigned long offset; /* Offset of this field in structure */ +#ifndef NO_ASN1_FIELD_NAMES +const char *field_name; /* Field name */ +#endif +ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ +}; + +/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ + +#define ASN1_TEMPLATE_item(t) (t->item_ptr) +#define ASN1_TEMPLATE_adb(t) (t->item_ptr) + +typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; +typedef struct ASN1_ADB_st ASN1_ADB; + +struct ASN1_ADB_st { + unsigned long flags; /* Various flags */ + unsigned long offset; /* Offset of selector field */ + STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ + const ASN1_ADB_TABLE *tbl; /* Table of possible types */ + long tblcount; /* Number of entries in tbl */ + const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ + const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ +}; + +struct ASN1_ADB_TABLE_st { + long value; /* NID for an object or value for an int */ + const ASN1_TEMPLATE tt; /* item for this value */ +}; + +/* template flags */ + +/* Field is optional */ +#define ASN1_TFLG_OPTIONAL (0x1) + +/* Field is a SET OF */ +#define ASN1_TFLG_SET_OF (0x1 << 1) + +/* Field is a SEQUENCE OF */ +#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) + +/* Special case: this refers to a SET OF that + * will be sorted into DER order when encoded *and* + * the corresponding STACK will be modified to match + * the new order. + */ +#define ASN1_TFLG_SET_ORDER (0x3 << 1) + +/* Mask for SET OF or SEQUENCE OF */ +#define ASN1_TFLG_SK_MASK (0x3 << 1) + +/* These flags mean the tag should be taken from the + * tag field. If EXPLICIT then the underlying type + * is used for the inner tag. + */ + +/* IMPLICIT tagging */ +#define ASN1_TFLG_IMPTAG (0x1 << 3) + + +/* EXPLICIT tagging, inner tag from underlying type */ +#define ASN1_TFLG_EXPTAG (0x2 << 3) + +#define ASN1_TFLG_TAG_MASK (0x3 << 3) + +/* context specific IMPLICIT */ +#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT + +/* context specific EXPLICIT */ +#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT + +/* If tagging is in force these determine the + * type of tag to use. Otherwise the tag is + * determined by the underlying type. These + * values reflect the actual octet format. + */ + +/* Universal tag */ +#define ASN1_TFLG_UNIVERSAL (0x0<<6) +/* Application tag */ +#define ASN1_TFLG_APPLICATION (0x1<<6) +/* Context specific tag */ +#define ASN1_TFLG_CONTEXT (0x2<<6) +/* Private tag */ +#define ASN1_TFLG_PRIVATE (0x3<<6) + +#define ASN1_TFLG_TAG_CLASS (0x3<<6) + +/* These are for ANY DEFINED BY type. In this case + * the 'item' field points to an ASN1_ADB structure + * which contains a table of values to decode the + * relevant type + */ + +#define ASN1_TFLG_ADB_MASK (0x3<<8) + +#define ASN1_TFLG_ADB_OID (0x1<<8) + +#define ASN1_TFLG_ADB_INT (0x1<<9) + +/* This flag means a parent structure is passed + * instead of the field: this is useful is a + * SEQUENCE is being combined with a CHOICE for + * example. Since this means the structure and + * item name will differ we need to use the + * ASN1_CHOICE_END_name() macro for example. + */ + +#define ASN1_TFLG_COMBINE (0x1<<10) + +/* This flag when present in a SEQUENCE OF, SET OF + * or EXPLICIT causes indefinite length constructed + * encoding to be used if required. + */ + +#define ASN1_TFLG_NDEF (0x1<<11) + +/* This is the actual ASN1 item itself */ + +struct ASN1_ITEM_st { +char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ +long utype; /* underlying type */ +const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ +long tcount; /* Number of templates if SEQUENCE or CHOICE */ +const void *funcs; /* functions that handle this type */ +long size; /* Structure size (usually)*/ +#ifndef NO_ASN1_FIELD_NAMES +const char *sname; /* Structure name */ +#endif +}; + +/* These are values for the itype field and + * determine how the type is interpreted. + * + * For PRIMITIVE types the underlying type + * determines the behaviour if items is NULL. + * + * Otherwise templates must contain a single + * template and the type is treated in the + * same way as the type specified in the template. + * + * For SEQUENCE types the templates field points + * to the members, the size field is the + * structure size. + * + * For CHOICE types the templates field points + * to each possible member (typically a union) + * and the 'size' field is the offset of the + * selector. + * + * The 'funcs' field is used for application + * specific functions. + * + * For COMPAT types the funcs field gives a + * set of functions that handle this type, this + * supports the old d2i, i2d convention. + * + * The EXTERN type uses a new style d2i/i2d. + * The new style should be used where possible + * because it avoids things like the d2i IMPLICIT + * hack. + * + * MSTRING is a multiple string type, it is used + * for a CHOICE of character strings where the + * actual strings all occupy an ASN1_STRING + * structure. In this case the 'utype' field + * has a special meaning, it is used as a mask + * of acceptable types using the B_ASN1 constants. + * + * NDEF_SEQUENCE is the same as SEQUENCE except + * that it will use indefinite length constructed + * encoding if requested. + * + */ + +#define ASN1_ITYPE_PRIMITIVE 0x0 + +#define ASN1_ITYPE_SEQUENCE 0x1 + +#define ASN1_ITYPE_CHOICE 0x2 + +#define ASN1_ITYPE_COMPAT 0x3 + +#define ASN1_ITYPE_EXTERN 0x4 + +#define ASN1_ITYPE_MSTRING 0x5 + +#define ASN1_ITYPE_NDEF_SEQUENCE 0x6 + +/* Cache for ASN1 tag and length, so we + * don't keep re-reading it for things + * like CHOICE + */ + +struct ASN1_TLC_st{ + char valid; /* Values below are valid */ + int ret; /* return value */ + long plen; /* length */ + int ptag; /* class value */ + int pclass; /* class value */ + int hdrlen; /* header length */ +}; + +/* Typedefs for ASN1 function pointers */ + +typedef ASN1_VALUE * ASN1_new_func(void); +typedef void ASN1_free_func(ASN1_VALUE *a); +typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); +typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); + +typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); +typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); + +typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +typedef struct ASN1_COMPAT_FUNCS_st { + ASN1_new_func *asn1_new; + ASN1_free_func *asn1_free; + ASN1_d2i_func *asn1_d2i; + ASN1_i2d_func *asn1_i2d; +} ASN1_COMPAT_FUNCS; + +typedef struct ASN1_EXTERN_FUNCS_st { + void *app_data; + ASN1_ex_new_func *asn1_ex_new; + ASN1_ex_free_func *asn1_ex_free; + ASN1_ex_free_func *asn1_ex_clear; + ASN1_ex_d2i *asn1_ex_d2i; + ASN1_ex_i2d *asn1_ex_i2d; +} ASN1_EXTERN_FUNCS; + +typedef struct ASN1_PRIMITIVE_FUNCS_st { + void *app_data; + unsigned long flags; + ASN1_ex_new_func *prim_new; + ASN1_ex_free_func *prim_free; + ASN1_ex_free_func *prim_clear; + ASN1_primitive_c2i *prim_c2i; + ASN1_primitive_i2c *prim_i2c; +} ASN1_PRIMITIVE_FUNCS; + +/* This is the ASN1_AUX structure: it handles various + * miscellaneous requirements. For example the use of + * reference counts and an informational callback. + * + * The "informational callback" is called at various + * points during the ASN1 encoding and decoding. It can + * be used to provide minor customisation of the structures + * used. This is most useful where the supplied routines + * *almost* do the right thing but need some extra help + * at a few points. If the callback returns zero then + * it is assumed a fatal error has occurred and the + * main operation should be abandoned. + * + * If major changes in the default behaviour are required + * then an external type is more appropriate. + */ + +typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it); + +typedef struct ASN1_AUX_st { + void *app_data; + int flags; + int ref_offset; /* Offset of reference value */ + int ref_lock; /* Lock type to use */ + ASN1_aux_cb *asn1_cb; + int enc_offset; /* Offset of ASN1_ENCODING structure */ +} ASN1_AUX; + +/* Flags in ASN1_AUX */ + +/* Use a reference count */ +#define ASN1_AFLG_REFCOUNT 1 +/* Save the encoding of structure (useful for signatures) */ +#define ASN1_AFLG_ENCODING 2 +/* The Sequence length is invalid */ +#define ASN1_AFLG_BROKEN 4 + +/* operation values for asn1_cb */ + +#define ASN1_OP_NEW_PRE 0 +#define ASN1_OP_NEW_POST 1 +#define ASN1_OP_FREE_PRE 2 +#define ASN1_OP_FREE_POST 3 +#define ASN1_OP_D2I_PRE 4 +#define ASN1_OP_D2I_POST 5 +#define ASN1_OP_I2D_PRE 6 +#define ASN1_OP_I2D_POST 7 + +/* Macro to implement a primitive type */ +#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) +#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement a multi string type */ +#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement an ASN1_ITEM in terms of old style funcs */ + +#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) + +#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ + static const ASN1_COMPAT_FUNCS sname##_ff = { \ + (ASN1_new_func *)sname##_new, \ + (ASN1_free_func *)sname##_free, \ + (ASN1_d2i_func *)d2i_##sname, \ + (ASN1_i2d_func *)i2d_##sname, \ + }; \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_COMPAT, \ + tag, \ + NULL, \ + 0, \ + &sname##_ff, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_EXTERN, \ + tag, \ + NULL, \ + 0, \ + &fptrs, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +/* Macro to implement standard functions in terms of ASN1_ITEM structures */ + +#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ + stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ + int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ + { \ + return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ + } + +/* This includes evil casts to remove const: they will go away when full + * ASN1 constification is done. + */ +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ + stname * stname##_dup(stname *x) \ + { \ + return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ + IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) + +#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +/* external definitions for primitive types */ + +DECLARE_ASN1_ITEM(ASN1_BOOLEAN) +DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_SEQUENCE) +DECLARE_ASN1_ITEM(CBIGNUM) +DECLARE_ASN1_ITEM(BIGNUM) +DECLARE_ASN1_ITEM(LONG) +DECLARE_ASN1_ITEM(ZLONG) + +DECLARE_STACK_OF(ASN1_VALUE) + +/* Functions used internally by the ASN1 code */ + +int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); + +void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); +void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); + +int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); + +ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + +const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr); + +int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); + +void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); +void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/bio.h b/libraries/external/openssl/linux/include/openssl/bio.h new file mode 100755 index 0000000..385ec12 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/bio.h @@ -0,0 +1,775 @@ +/* crypto/bio/bio.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BIO_H +#define HEADER_BIO_H + +#include + +#ifndef OPENSSL_NO_FP_API +# include +#endif +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These are the 'types' of BIOs */ +#define BIO_TYPE_NONE 0 +#define BIO_TYPE_MEM (1|0x0400) +#define BIO_TYPE_FILE (2|0x0400) + +#define BIO_TYPE_FD (4|0x0400|0x0100) +#define BIO_TYPE_SOCKET (5|0x0400|0x0100) +#define BIO_TYPE_NULL (6|0x0400) +#define BIO_TYPE_SSL (7|0x0200) +#define BIO_TYPE_MD (8|0x0200) /* passive filter */ +#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ +#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ +#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ +#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */ +#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */ +#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */ +#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NULL_FILTER (17|0x0200) +#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ +#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ +#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ +#define BIO_TYPE_DGRAM (21|0x0400|0x0100) + +#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ +#define BIO_TYPE_FILTER 0x0200 +#define BIO_TYPE_SOURCE_SINK 0x0400 + +/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. + * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ +#define BIO_NOCLOSE 0x00 +#define BIO_CLOSE 0x01 + +/* These are used in the following macros and are passed to + * BIO_ctrl() */ +#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ +#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ +#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ +#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ +#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ +#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ +#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ +#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ +#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ +#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ +#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ +#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ +#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ +/* callback is int cb(BIO *bio,state,ret); */ +#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ +#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ + +#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ + +/* dgram BIO stuff */ +#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ +#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally + * connected socket to be + * passed in */ +#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ +#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ + +#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ + +/* #ifdef IP_MTU_DISCOVER */ +#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ +/* #endif */ + +#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ +#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ +#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for + * MTU. want to use this + * if asking the kernel + * fails */ + +#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU + * was exceed in the + * previous write + * operation */ + +#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ + + +/* modifiers */ +#define BIO_FP_READ 0x02 +#define BIO_FP_WRITE 0x04 +#define BIO_FP_APPEND 0x08 +#define BIO_FP_TEXT 0x10 + +#define BIO_FLAGS_READ 0x01 +#define BIO_FLAGS_WRITE 0x02 +#define BIO_FLAGS_IO_SPECIAL 0x04 +#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) +#define BIO_FLAGS_SHOULD_RETRY 0x08 +#ifndef BIO_FLAGS_UPLINK +/* "UPLINK" flag denotes file descriptors provided by application. + It defaults to 0, as most platforms don't require UPLINK interface. */ +#define BIO_FLAGS_UPLINK 0 +#endif + +/* Used in BIO_gethostbyname() */ +#define BIO_GHBN_CTRL_HITS 1 +#define BIO_GHBN_CTRL_MISSES 2 +#define BIO_GHBN_CTRL_CACHE_SIZE 3 +#define BIO_GHBN_CTRL_GET_ENTRY 4 +#define BIO_GHBN_CTRL_FLUSH 5 + +/* Mostly used in the SSL BIO */ +/* Not used anymore + * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 + * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 + * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 + */ + +#define BIO_FLAGS_BASE64_NO_NL 0x100 + +/* This is used with memory BIOs: it means we shouldn't free up or change the + * data in any way. + */ +#define BIO_FLAGS_MEM_RDONLY 0x200 + +typedef struct bio_st BIO; + +void BIO_set_flags(BIO *b, int flags); +int BIO_test_flags(const BIO *b, int flags); +void BIO_clear_flags(BIO *b, int flags); + +#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) +#define BIO_set_retry_special(b) \ + BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_read(b) \ + BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_write(b) \ + BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) + +/* These are normally used internally in BIOs */ +#define BIO_clear_retry_flags(b) \ + BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_get_retry_flags(b) \ + BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) + +/* These should be used by the application to tell why we should retry */ +#define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) +#define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) +#define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) +#define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) +#define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) + +/* The next three are used in conjunction with the + * BIO_should_io_special() condition. After this returns true, + * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO + * stack and return the 'reason' for the special and the offending BIO. + * Given a BIO, BIO_get_retry_reason(bio) will return the code. */ +/* Returned from the SSL bio when the certificate retrieval code had an error */ +#define BIO_RR_SSL_X509_LOOKUP 0x01 +/* Returned from the connect BIO when a connect would have blocked */ +#define BIO_RR_CONNECT 0x02 +/* Returned from the accept BIO when an accept would have blocked */ +#define BIO_RR_ACCEPT 0x03 + +/* These are passed by the BIO callback */ +#define BIO_CB_FREE 0x01 +#define BIO_CB_READ 0x02 +#define BIO_CB_WRITE 0x03 +#define BIO_CB_PUTS 0x04 +#define BIO_CB_GETS 0x05 +#define BIO_CB_CTRL 0x06 + +/* The callback is called before and after the underling operation, + * The BIO_CB_RETURN flag indicates if it is after the call */ +#define BIO_CB_RETURN 0x80 +#define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) +#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) +#define BIO_cb_post(a) ((a)&BIO_CB_RETURN) + +long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long); +void BIO_set_callback(BIO *b, + long (*callback)(struct bio_st *,int,const char *,int, long,long)); +char *BIO_get_callback_arg(const BIO *b); +void BIO_set_callback_arg(BIO *b, char *arg); + +const char * BIO_method_name(const BIO *b); +int BIO_method_type(const BIO *b); + +typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); + +#ifndef OPENSSL_SYS_WIN16 +typedef struct bio_method_st + { + int type; + const char *name; + int (*bwrite)(BIO *, const char *, int); + int (*bread)(BIO *, char *, int); + int (*bputs)(BIO *, const char *); + int (*bgets)(BIO *, char *, int); + long (*ctrl)(BIO *, int, long, void *); + int (*create)(BIO *); + int (*destroy)(BIO *); + long (*callback_ctrl)(BIO *, int, bio_info_cb *); + } BIO_METHOD; +#else +typedef struct bio_method_st + { + int type; + const char *name; + int (_far *bwrite)(); + int (_far *bread)(); + int (_far *bputs)(); + int (_far *bgets)(); + long (_far *ctrl)(); + int (_far *create)(); + int (_far *destroy)(); + long (_far *callback_ctrl)(); + } BIO_METHOD; +#endif + +struct bio_st + { + BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + long (*callback)(struct bio_st *,int,const char *,int, long,long); + char *cb_arg; /* first argument for the callback */ + + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + int references; + unsigned long num_read; + unsigned long num_write; + + CRYPTO_EX_DATA ex_data; + }; + +DECLARE_STACK_OF(BIO) + +typedef struct bio_f_buffer_ctx_struct + { + /* BIO *bio; */ /* this is now in the BIO struct */ + int ibuf_size; /* how big is the input buffer */ + int obuf_size; /* how big is the output buffer */ + + char *ibuf; /* the char array */ + int ibuf_len; /* how many bytes are in it */ + int ibuf_off; /* write/read offset */ + + char *obuf; /* the char array */ + int obuf_len; /* how many bytes are in it */ + int obuf_off; /* write/read offset */ + } BIO_F_BUFFER_CTX; + +/* connect BIO stuff */ +#define BIO_CONN_S_BEFORE 1 +#define BIO_CONN_S_GET_IP 2 +#define BIO_CONN_S_GET_PORT 3 +#define BIO_CONN_S_CREATE_SOCKET 4 +#define BIO_CONN_S_CONNECT 5 +#define BIO_CONN_S_OK 6 +#define BIO_CONN_S_BLOCKED_CONNECT 7 +#define BIO_CONN_S_NBIO 8 +/*#define BIO_CONN_get_param_hostname BIO_ctrl */ + +#define BIO_C_SET_CONNECT 100 +#define BIO_C_DO_STATE_MACHINE 101 +#define BIO_C_SET_NBIO 102 +#define BIO_C_SET_PROXY_PARAM 103 +#define BIO_C_SET_FD 104 +#define BIO_C_GET_FD 105 +#define BIO_C_SET_FILE_PTR 106 +#define BIO_C_GET_FILE_PTR 107 +#define BIO_C_SET_FILENAME 108 +#define BIO_C_SET_SSL 109 +#define BIO_C_GET_SSL 110 +#define BIO_C_SET_MD 111 +#define BIO_C_GET_MD 112 +#define BIO_C_GET_CIPHER_STATUS 113 +#define BIO_C_SET_BUF_MEM 114 +#define BIO_C_GET_BUF_MEM_PTR 115 +#define BIO_C_GET_BUFF_NUM_LINES 116 +#define BIO_C_SET_BUFF_SIZE 117 +#define BIO_C_SET_ACCEPT 118 +#define BIO_C_SSL_MODE 119 +#define BIO_C_GET_MD_CTX 120 +#define BIO_C_GET_PROXY_PARAM 121 +#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */ +#define BIO_C_GET_CONNECT 123 +#define BIO_C_GET_ACCEPT 124 +#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 +#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 +#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 +#define BIO_C_FILE_SEEK 128 +#define BIO_C_GET_CIPHER_CTX 129 +#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ +#define BIO_C_SET_BIND_MODE 131 +#define BIO_C_GET_BIND_MODE 132 +#define BIO_C_FILE_TELL 133 +#define BIO_C_GET_SOCKS 134 +#define BIO_C_SET_SOCKS 135 + +#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ +#define BIO_C_GET_WRITE_BUF_SIZE 137 +#define BIO_C_MAKE_BIO_PAIR 138 +#define BIO_C_DESTROY_BIO_PAIR 139 +#define BIO_C_GET_WRITE_GUARANTEE 140 +#define BIO_C_GET_READ_REQUEST 141 +#define BIO_C_SHUTDOWN_WR 142 +#define BIO_C_NREAD0 143 +#define BIO_C_NREAD 144 +#define BIO_C_NWRITE0 145 +#define BIO_C_NWRITE 146 +#define BIO_C_RESET_READ_REQUEST 147 +#define BIO_C_SET_MD_CTX 148 + + +#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) +#define BIO_get_app_data(s) BIO_get_ex_data(s,0) + +/* BIO_s_connect() and BIO_s_socks4a_connect() */ +#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) +#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) +#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) +#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) +#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) +#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) +#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) +#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3) + + +#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) + +/* BIO_s_accept_socket() */ +#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) +#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) +/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ +#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) +#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) + +#define BIO_BIND_NORMAL 0 +#define BIO_BIND_REUSEADDR_IF_UNUSED 1 +#define BIO_BIND_REUSEADDR 2 +#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) +#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) + +#define BIO_do_connect(b) BIO_do_handshake(b) +#define BIO_do_accept(b) BIO_do_handshake(b) +#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) + +/* BIO_s_proxy_client() */ +#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) +#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) +/* BIO_set_nbio(b,n) */ +#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) +/* BIO *BIO_get_filter_bio(BIO *bio); */ +#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) +#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) +#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) + +#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) +#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) +#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) +#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) + +#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) +#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) + +#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) +#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) + +#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) +#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) + +/* name is cast to lose const, but might be better to route through a function + so we can do it safely */ +#ifdef CONST_STRICT +/* If you are wondering why this isn't defined, its because CONST_STRICT is + * purely a compile-time kludge to allow const to be checked. + */ +int BIO_read_filename(BIO *b,const char *name); +#else +#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ,(char *)name) +#endif +#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_WRITE,name) +#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_APPEND,name) +#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) + +/* WARNING WARNING, this ups the reference count on the read bio of the + * SSL structure. This is because the ssl read BIO is now pointed to by + * the next_bio field in the bio. So when you free the BIO, make sure + * you are doing a BIO_free_all() to catch the underlying BIO. */ +#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) +#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) +#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) +#define BIO_set_ssl_renegotiate_bytes(b,num) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); +#define BIO_get_num_renegotiates(b) \ + BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); +#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); + +/* defined in evp.h */ +/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ + +#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) +#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) +#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) +#define BIO_set_mem_eof_return(b,v) \ + BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) + +/* For the BIO_f_buffer() type */ +#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) +#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) +#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) +#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) +#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) + +/* Don't use the next one unless you know what you are doing :-) */ +#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) + +#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) +#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) +#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) +#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) +#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) +#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) +/* ...pending macros have inappropriate return type */ +size_t BIO_ctrl_pending(BIO *b); +size_t BIO_ctrl_wpending(BIO *b); +#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) +#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ + cbp) +#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) + +/* For the BIO_f_buffer() type */ +#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) + +/* For BIO_s_bio() */ +#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) +#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) +#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) +#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) +#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) +/* macros with inappropriate type -- but ...pending macros use int too: */ +#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) +#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) +size_t BIO_ctrl_get_write_guarantee(BIO *b); +size_t BIO_ctrl_get_read_request(BIO *b); +int BIO_ctrl_reset_read_request(BIO *b); + +/* ctrl macros for dgram */ +#define BIO_ctrl_dgram_connect(b,peer) \ + (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) +#define BIO_ctrl_set_connected(b, state, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) +#define BIO_dgram_recv_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) +#define BIO_dgram_send_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) +#define BIO_dgram_set_peer(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) + +/* These two aren't currently implemented */ +/* int BIO_get_ex_num(BIO *bio); */ +/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ +int BIO_set_ex_data(BIO *bio,int idx,void *data); +void *BIO_get_ex_data(BIO *bio,int idx); +int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +unsigned long BIO_number_read(BIO *bio); +unsigned long BIO_number_written(BIO *bio); + +# ifndef OPENSSL_NO_FP_API +# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL) +BIO_METHOD *BIO_s_file_internal(void); +BIO *BIO_new_file_internal(char *filename, char *mode); +BIO *BIO_new_fp_internal(FILE *stream, int close_flag); +# define BIO_s_file BIO_s_file_internal +# define BIO_new_file BIO_new_file_internal +# define BIO_new_fp BIO_new_fp_internal +# else /* FP_API */ +BIO_METHOD *BIO_s_file(void ); +BIO *BIO_new_file(const char *filename, const char *mode); +BIO *BIO_new_fp(FILE *stream, int close_flag); +# define BIO_s_file_internal BIO_s_file +# define BIO_new_file_internal BIO_new_file +# define BIO_new_fp_internal BIO_s_file +# endif /* FP_API */ +# endif +BIO * BIO_new(BIO_METHOD *type); +int BIO_set(BIO *a,BIO_METHOD *type); +int BIO_free(BIO *a); +void BIO_vfree(BIO *a); +int BIO_read(BIO *b, void *data, int len); +int BIO_gets(BIO *bp,char *buf, int size); +int BIO_write(BIO *b, const void *data, int len); +int BIO_puts(BIO *bp,const char *buf); +int BIO_indent(BIO *b,int indent,int max); +long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); +long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); +char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); +long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); +BIO * BIO_push(BIO *b,BIO *append); +BIO * BIO_pop(BIO *b); +void BIO_free_all(BIO *a); +BIO * BIO_find_type(BIO *b,int bio_type); +BIO * BIO_next(BIO *b); +BIO * BIO_get_retry_BIO(BIO *bio, int *reason); +int BIO_get_retry_reason(BIO *bio); +BIO * BIO_dup_chain(BIO *in); + +int BIO_nread0(BIO *bio, char **buf); +int BIO_nread(BIO *bio, char **buf, int num); +int BIO_nwrite0(BIO *bio, char **buf); +int BIO_nwrite(BIO *bio, char **buf, int num); + +#ifndef OPENSSL_SYS_WIN16 +long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#else +long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#endif + +BIO_METHOD *BIO_s_mem(void); +BIO *BIO_new_mem_buf(void *buf, int len); +BIO_METHOD *BIO_s_socket(void); +BIO_METHOD *BIO_s_connect(void); +BIO_METHOD *BIO_s_accept(void); +BIO_METHOD *BIO_s_fd(void); +#ifndef OPENSSL_SYS_OS2 +BIO_METHOD *BIO_s_log(void); +#endif +BIO_METHOD *BIO_s_bio(void); +BIO_METHOD *BIO_s_null(void); +BIO_METHOD *BIO_f_null(void); +BIO_METHOD *BIO_f_buffer(void); +#ifdef OPENSSL_SYS_VMS +BIO_METHOD *BIO_f_linebuffer(void); +#endif +BIO_METHOD *BIO_f_nbio_test(void); +#ifndef OPENSSL_NO_DGRAM +BIO_METHOD *BIO_s_datagram(void); +#endif + +/* BIO_METHOD *BIO_f_ber(void); */ + +int BIO_sock_should_retry(int i); +int BIO_sock_non_fatal_error(int error); +int BIO_dgram_non_fatal_error(int error); + +int BIO_fd_should_retry(int i); +int BIO_fd_non_fatal_error(int error); +int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len); +int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len, int indent); +int BIO_dump(BIO *b,const char *bytes,int len); +int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); +#ifndef OPENSSL_NO_FP_API +int BIO_dump_fp(FILE *fp, const char *s, int len); +int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); +#endif +struct hostent *BIO_gethostbyname(const char *name); +/* We might want a thread-safe interface too: + * struct hostent *BIO_gethostbyname_r(const char *name, + * struct hostent *result, void *buffer, size_t buflen); + * or something similar (caller allocates a struct hostent, + * pointed to by "result", and additional buffer space for the various + * substructures; if the buffer does not suffice, NULL is returned + * and an appropriate error code is set). + */ +int BIO_sock_error(int sock); +int BIO_socket_ioctl(int fd, long type, void *arg); +int BIO_socket_nbio(int fd,int mode); +int BIO_get_port(const char *str, unsigned short *port_ptr); +int BIO_get_host_ip(const char *str, unsigned char *ip); +int BIO_get_accept_socket(char *host_port,int mode); +int BIO_accept(int sock,char **ip_port); +int BIO_sock_init(void ); +void BIO_sock_cleanup(void); +int BIO_set_tcp_ndelay(int sock,int turn_on); + +BIO *BIO_new_socket(int sock, int close_flag); +BIO *BIO_new_dgram(int fd, int close_flag); +BIO *BIO_new_fd(int fd, int close_flag); +BIO *BIO_new_connect(char *host_port); +BIO *BIO_new_accept(char *host_port); + +int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, + BIO **bio2, size_t writebuf2); +/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. + * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. + * Size 0 uses default value. + */ + +void BIO_copy_next_retry(BIO *b); + +/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ + +#ifdef __GNUC__ +# define __bio_h__attr__ __attribute__ +#else +# define __bio_h__attr__(x) +#endif +int BIO_printf(BIO *bio, const char *format, ...) + __bio_h__attr__((__format__(__printf__,2,3))); +int BIO_vprintf(BIO *bio, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,2,0))); +int BIO_snprintf(char *buf, size_t n, const char *format, ...) + __bio_h__attr__((__format__(__printf__,3,4))); +int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,3,0))); +#undef __bio_h__attr__ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BIO_strings(void); + +/* Error codes for the BIO functions. */ + +/* Function codes. */ +#define BIO_F_ACPT_STATE 100 +#define BIO_F_BIO_ACCEPT 101 +#define BIO_F_BIO_BER_GET_HEADER 102 +#define BIO_F_BIO_CALLBACK_CTRL 131 +#define BIO_F_BIO_CTRL 103 +#define BIO_F_BIO_GETHOSTBYNAME 120 +#define BIO_F_BIO_GETS 104 +#define BIO_F_BIO_GET_ACCEPT_SOCKET 105 +#define BIO_F_BIO_GET_HOST_IP 106 +#define BIO_F_BIO_GET_PORT 107 +#define BIO_F_BIO_MAKE_PAIR 121 +#define BIO_F_BIO_NEW 108 +#define BIO_F_BIO_NEW_FILE 109 +#define BIO_F_BIO_NEW_MEM_BUF 126 +#define BIO_F_BIO_NREAD 123 +#define BIO_F_BIO_NREAD0 124 +#define BIO_F_BIO_NWRITE 125 +#define BIO_F_BIO_NWRITE0 122 +#define BIO_F_BIO_PUTS 110 +#define BIO_F_BIO_READ 111 +#define BIO_F_BIO_SOCK_INIT 112 +#define BIO_F_BIO_WRITE 113 +#define BIO_F_BUFFER_CTRL 114 +#define BIO_F_CONN_CTRL 127 +#define BIO_F_CONN_STATE 115 +#define BIO_F_FILE_CTRL 116 +#define BIO_F_FILE_READ 130 +#define BIO_F_LINEBUFFER_CTRL 129 +#define BIO_F_MEM_READ 128 +#define BIO_F_MEM_WRITE 117 +#define BIO_F_SSL_NEW 118 +#define BIO_F_WSASTARTUP 119 + +/* Reason codes. */ +#define BIO_R_ACCEPT_ERROR 100 +#define BIO_R_BAD_FOPEN_MODE 101 +#define BIO_R_BAD_HOSTNAME_LOOKUP 102 +#define BIO_R_BROKEN_PIPE 124 +#define BIO_R_CONNECT_ERROR 103 +#define BIO_R_EOF_ON_MEMORY_BIO 127 +#define BIO_R_ERROR_SETTING_NBIO 104 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 +#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +#define BIO_R_INVALID_ARGUMENT 125 +#define BIO_R_INVALID_IP_ADDRESS 108 +#define BIO_R_IN_USE 123 +#define BIO_R_KEEPALIVE 109 +#define BIO_R_NBIO_CONNECT_ERROR 110 +#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 +#define BIO_R_NO_HOSTNAME_SPECIFIED 112 +#define BIO_R_NO_PORT_DEFINED 113 +#define BIO_R_NO_PORT_SPECIFIED 114 +#define BIO_R_NO_SUCH_FILE 128 +#define BIO_R_NULL_PARAMETER 115 +#define BIO_R_TAG_MISMATCH 116 +#define BIO_R_UNABLE_TO_BIND_SOCKET 117 +#define BIO_R_UNABLE_TO_CREATE_SOCKET 118 +#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 +#define BIO_R_UNINITIALIZED 120 +#define BIO_R_UNSUPPORTED_METHOD 121 +#define BIO_R_WRITE_TO_READ_ONLY_BIO 126 +#define BIO_R_WSASTARTUP 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/blowfish.h b/libraries/external/openssl/linux/include/openssl/blowfish.h new file mode 100755 index 0000000..ec7b869 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/blowfish.h @@ -0,0 +1,127 @@ +/* crypto/bf/blowfish.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BLOWFISH_H +#define HEADER_BLOWFISH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_BF +#error BF is disabled. +#endif + +#define BF_ENCRYPT 1 +#define BF_DECRYPT 0 + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! BF_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define BF_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define BF_LONG unsigned long +#define BF_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define BF_LONG unsigned int +#endif + +#define BF_ROUNDS 16 +#define BF_BLOCK 8 + +typedef struct bf_key_st + { + BF_LONG P[BF_ROUNDS+2]; + BF_LONG S[4*256]; + } BF_KEY; + + +void BF_set_key(BF_KEY *key, int len, const unsigned char *data); + +void BF_encrypt(BF_LONG *data,const BF_KEY *key); +void BF_decrypt(BF_LONG *data,const BF_KEY *key); + +void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int enc); +void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int enc); +void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); +void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num); +const char *BF_options(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/bn.h b/libraries/external/openssl/linux/include/openssl/bn.h new file mode 100755 index 0000000..8c800ee --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/bn.h @@ -0,0 +1,827 @@ +/* crypto/bn/bn.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the Eric Young open source + * license provided above. + * + * The binary polynomial arithmetic software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_BN_H +#define HEADER_BN_H + +#include +#ifndef OPENSSL_NO_FP_API +#include /* FILE */ +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These preprocessor symbols control various aspects of the bignum headers and + * library code. They're not defined by any "normal" configuration, as they are + * intended for development and testing purposes. NB: defining all three can be + * useful for debugging application code as well as openssl itself. + * + * BN_DEBUG - turn on various debugging alterations to the bignum code + * BN_DEBUG_RAND - uses random poisoning of unused words to trip up + * mismanagement of bignum internals. You must also define BN_DEBUG. + */ +/* #define BN_DEBUG */ +/* #define BN_DEBUG_RAND */ + +#define BN_MUL_COMBA +#define BN_SQR_COMBA +#define BN_RECURSION + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using normal cc. This would + * be a common occurrence because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assembler code. */ +#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ + defined(OPENSSL_SYS_WIN32) || defined(linux) +# ifndef BN_DIV2W +# define BN_DIV2W +# endif +#endif + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits :-(, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000UL) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +/* This is where the long long data type is 64 bits, but long is 32. + * For machines where there are 64bit registers, this is the mode to use. + * IRIX, on R4000 and above should use this mode, along with the relevant + * assembler code :-). Do NOT define BN_LLONG. + */ +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG +#undef BN_ULLONG +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000ULL) +#define BN_DEC_FMT1 "%llu" +#define BN_DEC_FMT2 "%019llu" +#define BN_DEC_NUM 19 +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef BN_LLONG +# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) +# define BN_ULLONG unsigned __int64 +# else +# define BN_ULLONG unsigned long long +# endif +#endif +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +#ifdef OPENSSL_SYS_WIN32 +/* VC++ doesn't like the LL suffix */ +#define BN_MASK (0xffffffffffffffffL) +#else +#define BN_MASK (0xffffffffffffffffLL) +#endif +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK (0xffffffff) +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (100000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%05u" +#define BN_DEC_NUM 5 +#endif + +#ifdef EIGHT_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK (0xffff) +#define BN_MASK2 (0xff) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#endif + +#define BN_DEFAULT_BITS 1280 + +#define BN_FLG_MALLOCED 0x01 +#define BN_FLG_STATIC_DATA 0x02 +#define BN_FLG_EXP_CONSTTIME 0x04 /* avoid leaking exponent information through timings + * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ +#ifndef OPENSSL_NO_DEPRECATED +#define BN_FLG_FREE 0x8000 /* used for debuging */ +#endif +#define BN_set_flags(b,n) ((b)->flags|=(n)) +#define BN_get_flags(b,n) ((b)->flags&(n)) + +/* get a clone of a BIGNUM with changed flags, for *temporary* use only + * (the two BIGNUMs cannot not be used in parallel!) */ +#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ + (dest)->top=(b)->top, \ + (dest)->dmax=(b)->dmax, \ + (dest)->neg=(b)->neg, \ + (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ + | ((b)->flags & ~BN_FLG_MALLOCED) \ + | BN_FLG_STATIC_DATA \ + | (n))) + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct bignum_st BIGNUM; +/* Used for temp variables (declaration hidden in bn_lcl.h) */ +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; +#endif + +struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int dmax; /* Size of the d array. */ + int neg; /* one if the number is negative */ + int flags; + }; + +/* Used for montgomery multiplication */ +struct bn_mont_ctx_st + { + int ri; /* number of bits in R */ + BIGNUM RR; /* used to convert to montgomery form */ + BIGNUM N; /* The modulus */ + BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 + * (Ni is only stored for bignum algorithm) */ + BN_ULONG n0; /* least significant word of Ni */ + int flags; + }; + +/* Used for reciprocal division/mod functions + * It cannot be shared between threads + */ +struct bn_recp_ctx_st + { + BIGNUM N; /* the divisor */ + BIGNUM Nr; /* the reciprocal */ + int num_bits; + int shift; + int flags; + }; + +/* Used for slow "generation" functions. */ +struct bn_gencb_st + { + unsigned int ver; /* To handle binary (in)compatibility */ + void *arg; /* callback-specific data */ + union + { + /* if(ver==1) - handles old style callbacks */ + void (*cb_1)(int, int, void *); + /* if(ver==2) - new callback style */ + int (*cb_2)(int, int, BN_GENCB *); + } cb; + }; +/* Wrapper function to make using BN_GENCB easier, */ +int BN_GENCB_call(BN_GENCB *cb, int a, int b); +/* Macro to populate a BN_GENCB structure with an "old"-style callback */ +#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 1; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_1 = (callback); } +/* Macro to populate a BN_GENCB structure with a "new"-style callback */ +#define BN_GENCB_set(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 2; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_2 = (callback); } + +#define BN_prime_checks 0 /* default: select number of iterations + based on the size of the number */ + +/* number of Miller-Rabin iterations for an error rate of less than 2^-80 + * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook + * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; + * original paper: Damgaard, Landrock, Pomerance: Average case error estimates + * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ +#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ + (b) >= 850 ? 3 : \ + (b) >= 650 ? 4 : \ + (b) >= 550 ? 5 : \ + (b) >= 450 ? 6 : \ + (b) >= 400 ? 7 : \ + (b) >= 350 ? 8 : \ + (b) >= 300 ? 9 : \ + (b) >= 250 ? 12 : \ + (b) >= 200 ? 15 : \ + (b) >= 150 ? 18 : \ + /* b >= 100 */ 27) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) + +/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ +#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ + (((w) == 0) && ((a)->top == 0))) +#define BN_is_zero(a) ((a)->top == 0) +#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) +#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) +#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) + +#define BN_one(a) (BN_set_word((a),1)) +#define BN_zero_ex(a) \ + do { \ + BIGNUM *_tmp_bn = (a); \ + _tmp_bn->top = 0; \ + _tmp_bn->neg = 0; \ + } while(0) +#ifdef OPENSSL_NO_DEPRECATED +#define BN_zero(a) BN_zero_ex(a) +#else +#define BN_zero(a) (BN_set_word((a),0)) +#endif + +const BIGNUM *BN_value_one(void); +char * BN_options(void); +BN_CTX *BN_CTX_new(void); +#ifndef OPENSSL_NO_DEPRECATED +void BN_CTX_init(BN_CTX *c); +#endif +void BN_CTX_free(BN_CTX *c); +void BN_CTX_start(BN_CTX *ctx); +BIGNUM *BN_CTX_get(BN_CTX *ctx); +void BN_CTX_end(BN_CTX *ctx); +int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_num_bits(const BIGNUM *a); +int BN_num_bits_word(BN_ULONG); +BIGNUM *BN_new(void); +void BN_init(BIGNUM *); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); +void BN_swap(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(const BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(const BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); +/** BN_set_negative sets sign of a BIGNUM + * \param b pointer to the BIGNUM object + * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise + */ +void BN_set_negative(BIGNUM *b, int n); +/** BN_is_negative returns 1 if the BIGNUM is negative + * \param a pointer to the BIGNUM object + * \return 1 if a < 0 and 0 otherwise + */ +#define BN_is_negative(a) ((a)->neg != 0) + +int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); +#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) +int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); +int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); + +BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); +int BN_mul_word(BIGNUM *a, BN_ULONG w); +int BN_add_word(BIGNUM *a, BN_ULONG w); +int BN_sub_word(BIGNUM *a, BN_ULONG w); +int BN_set_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_get_word(const BIGNUM *a); + +int BN_cmp(const BIGNUM *a, const BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(const BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, const BIGNUM *a); +int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); + +int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); +int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, + BN_CTX *ctx,BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); + +int BN_mask_bits(BIGNUM *a,int n); +#ifndef OPENSSL_NO_FP_API +int BN_print_fp(FILE *fp, const BIGNUM *a); +#endif +#ifdef HEADER_BIO_H +int BN_print(BIO *fp, const BIGNUM *a); +#else +int BN_print(void *fp, const BIGNUM *a); +#endif +int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, const BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *BN_dup(const BIGNUM *a); +int BN_ucmp(const BIGNUM *a, const BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(const BIGNUM *a); +char * BN_bn2dec(const BIGNUM *a); +int BN_hex2bn(BIGNUM **a, const char *str); +int BN_dec2bn(BIGNUM **a, const char *str); +int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); +int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ +BIGNUM *BN_mod_inverse(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); +BIGNUM *BN_mod_sqrt(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); + +/* Deprecated versions */ +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, + const BIGNUM *add, const BIGNUM *rem, + void (*callback)(int,int,void *),void *cb_arg); +int BN_is_prime(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *), + BN_CTX *ctx,void *cb_arg); +int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, + int do_trial_division); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* Newer versions */ +int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); +int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); +int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, + int do_trial_division, BN_GENCB *cb); + +BN_MONT_CTX *BN_MONT_CTX_new(void ); +void BN_MONT_CTX_init(BN_MONT_CTX *ctx); +int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + (r),(a),&((mont)->RR),(mont),(ctx)) +int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, + BN_MONT_CTX *mont, BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); +BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); +BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, + const BIGNUM *mod, BN_CTX *ctx); + +/* BN_BLINDING flags */ +#define BN_BLINDING_NO_UPDATE 0x00000001 +#define BN_BLINDING_NO_RECREATE 0x00000002 + +BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); +int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); +unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); +void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); +unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); +void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); +BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, + const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); + +#ifndef OPENSSL_NO_DEPRECATED +void BN_set_params(int mul,int high,int low,int mont); +int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ +#endif + +void BN_RECP_CTX_init(BN_RECP_CTX *recp); +BN_RECP_CTX *BN_RECP_CTX_new(void); +void BN_RECP_CTX_free(BN_RECP_CTX *recp); +int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); +int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, + BN_RECP_CTX *recp,BN_CTX *ctx); +int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, + BN_RECP_CTX *recp, BN_CTX *ctx); + +/* Functions for arithmetic over binary polynomials represented by BIGNUMs. + * + * The BIGNUM::neg property of BIGNUMs representing binary polynomials is + * ignored. + * + * Note that input arguments are not const so that their bit arrays can + * be expanded to the appropriate size if needed. + */ + +int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/ +#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) +int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/ +int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r^2 + r = a mod p */ +#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) +/* Some functions allow for representation of the irreducible polynomials + * as an unsigned int[], say p. The irreducible f(t) is then of the form: + * t^p[0] + t^p[1] + ... + t^p[k] + * where m = p[0] > p[1] > ... > p[k] = 0. + */ +int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); + /* r = a mod p */ +int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ +int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); +int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); + +/* faster mod functions for the 'NIST primes' + * 0 <= a < p^2 */ +int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); + +const BIGNUM *BN_get0_nist_prime_192(void); +const BIGNUM *BN_get0_nist_prime_224(void); +const BIGNUM *BN_get0_nist_prime_256(void); +const BIGNUM *BN_get0_nist_prime_384(void); +const BIGNUM *BN_get0_nist_prime_521(void); + +/* library internal functions */ + +#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ + (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) +#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) +BIGNUM *bn_expand2(BIGNUM *a, int words); +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ +#endif + +/* Bignum consistency macros + * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from + * bignum data after direct manipulations on the data. There is also an + * "internal" macro, bn_check_top(), for verifying that there are no leading + * zeroes. Unfortunately, some auditing is required due to the fact that + * bn_fix_top() has become an overabused duct-tape because bignum data is + * occasionally passed around in an inconsistent state. So the following + * changes have been made to sort this out; + * - bn_fix_top()s implementation has been moved to bn_correct_top() + * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and + * bn_check_top() is as before. + * - if BN_DEBUG *is* defined; + * - bn_check_top() tries to pollute unused words even if the bignum 'top' is + * consistent. (ed: only if BN_DEBUG_RAND is defined) + * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. + * The idea is to have debug builds flag up inconsistent bignums when they + * occur. If that occurs in a bn_fix_top(), we examine the code in question; if + * the use of bn_fix_top() was appropriate (ie. it follows directly after code + * that manipulates the bignum) it is converted to bn_correct_top(), and if it + * was not appropriate, we convert it permanently to bn_check_top() and track + * down the cause of the bug. Eventually, no internal code should be using the + * bn_fix_top() macro. External applications and libraries should try this with + * their own code too, both in terms of building against the openssl headers + * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it + * defined. This not only improves external code, it provides more test + * coverage for openssl's own code. + */ + +#ifdef BN_DEBUG + +/* We only need assert() when debugging */ +#include + +#ifdef BN_DEBUG_RAND +/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */ +#ifndef RAND_pseudo_bytes +int RAND_pseudo_bytes(unsigned char *buf,int num); +#define BN_DEBUG_TRIX +#endif +#define bn_pollute(a) \ + do { \ + const BIGNUM *_bnum1 = (a); \ + if(_bnum1->top < _bnum1->dmax) { \ + unsigned char _tmp_char; \ + /* We cast away const without the compiler knowing, any \ + * *genuinely* constant variables that aren't mutable \ + * wouldn't be constructed with top!=dmax. */ \ + BN_ULONG *_not_const; \ + memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ + RAND_pseudo_bytes(&_tmp_char, 1); \ + memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ + (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ + } \ + } while(0) +#ifdef BN_DEBUG_TRIX +#undef RAND_pseudo_bytes +#endif +#else +#define bn_pollute(a) +#endif +#define bn_check_top(a) \ + do { \ + const BIGNUM *_bnum2 = (a); \ + if (_bnum2 != NULL) { \ + assert((_bnum2->top == 0) || \ + (_bnum2->d[_bnum2->top - 1] != 0)); \ + bn_pollute(_bnum2); \ + } \ + } while(0) + +#define bn_fix_top(a) bn_check_top(a) + +#else /* !BN_DEBUG */ + +#define bn_pollute(a) +#define bn_check_top(a) +#define bn_fix_top(a) bn_correct_top(a) + +#endif + +#define bn_correct_top(a) \ + { \ + BN_ULONG *ftl; \ + if ((a)->top > 0) \ + { \ + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(ftl--)) break; \ + } \ + bn_pollute(a); \ + } + +BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); +BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); +BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); +BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); + +/* Primes from RFC 2409 */ +BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); +BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); + +/* Primes from RFC 3526 */ +BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); + +int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BN_strings(void); + +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BNRAND 127 +#define BN_F_BN_BLINDING_CONVERT_EX 100 +#define BN_F_BN_BLINDING_CREATE_PARAM 128 +#define BN_F_BN_BLINDING_INVERT_EX 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_GET 116 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_CTX_START 129 +#define BN_F_BN_DIV 107 +#define BN_F_BN_DIV_RECP 130 +#define BN_F_BN_EXP 123 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_EXPAND_INTERNAL 120 +#define BN_F_BN_GF2M_MOD 131 +#define BN_F_BN_GF2M_MOD_EXP 132 +#define BN_F_BN_GF2M_MOD_MUL 133 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 +#define BN_F_BN_GF2M_MOD_SQR 136 +#define BN_F_BN_GF2M_MOD_SQRT 137 +#define BN_F_BN_MOD_EXP2_MONT 118 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 +#define BN_F_BN_MOD_EXP_MONT_WORD 117 +#define BN_F_BN_MOD_EXP_RECP 125 +#define BN_F_BN_MOD_EXP_SIMPLE 126 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_LSHIFT_QUICK 119 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MOD_SQRT 121 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 +#define BN_F_BN_RAND_RANGE 122 +#define BN_F_BN_USUB 115 + +/* Reason codes. */ +#define BN_R_ARG2_LT_ARG3 100 +#define BN_R_BAD_RECIPROCAL 101 +#define BN_R_BIGNUM_TOO_LONG 114 +#define BN_R_CALLED_WITH_EVEN_MODULUS 102 +#define BN_R_DIV_BY_ZERO 103 +#define BN_R_ENCODING_ERROR 104 +#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 +#define BN_R_INPUT_NOT_REDUCED 110 +#define BN_R_INVALID_LENGTH 106 +#define BN_R_INVALID_RANGE 115 +#define BN_R_NOT_A_SQUARE 111 +#define BN_R_NOT_INITIALIZED 107 +#define BN_R_NO_INVERSE 108 +#define BN_R_NO_SOLUTION 116 +#define BN_R_P_IS_NOT_PRIME 112 +#define BN_R_TOO_MANY_ITERATIONS 113 +#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/buffer.h b/libraries/external/openssl/linux/include/openssl/buffer.h new file mode 100755 index 0000000..e3f394c --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/buffer.h @@ -0,0 +1,118 @@ +/* crypto/buffer/buffer.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BUFFER_H +#define HEADER_BUFFER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if !defined(NO_SYS_TYPES_H) +#include +#endif + +/* Already declared in ossl_typ.h */ +/* typedef struct buf_mem_st BUF_MEM; */ + +struct buf_mem_st + { + int length; /* current number of bytes */ + char *data; + int max; /* size of buffer */ + }; + +BUF_MEM *BUF_MEM_new(void); +void BUF_MEM_free(BUF_MEM *a); +int BUF_MEM_grow(BUF_MEM *str, int len); +int BUF_MEM_grow_clean(BUF_MEM *str, int len); +char * BUF_strdup(const char *str); +char * BUF_strndup(const char *str, size_t siz); +void * BUF_memdup(const void *data, size_t siz); + +/* safe string functions */ +size_t BUF_strlcpy(char *dst,const char *src,size_t siz); +size_t BUF_strlcat(char *dst,const char *src,size_t siz); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BUF_strings(void); + +/* Error codes for the BUF functions. */ + +/* Function codes. */ +#define BUF_F_BUF_MEMDUP 103 +#define BUF_F_BUF_MEM_GROW 100 +#define BUF_F_BUF_MEM_GROW_CLEAN 105 +#define BUF_F_BUF_MEM_NEW 101 +#define BUF_F_BUF_STRDUP 102 +#define BUF_F_BUF_STRNDUP 104 + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/cast.h b/libraries/external/openssl/linux/include/openssl/cast.h new file mode 100755 index 0000000..6948e64 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/cast.h @@ -0,0 +1,105 @@ +/* crypto/cast/cast.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CAST_H +#define HEADER_CAST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef OPENSSL_NO_CAST +#error CAST is disabled. +#endif + +#define CAST_ENCRYPT 1 +#define CAST_DECRYPT 0 + +#define CAST_LONG unsigned long + +#define CAST_BLOCK 8 +#define CAST_KEY_LENGTH 16 + +typedef struct cast_key_st + { + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ + } CAST_KEY; + + +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); +void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, + int enc); +void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + CAST_KEY *ks, unsigned char *iv, int enc); +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/comp.h b/libraries/external/openssl/linux/include/openssl/comp.h new file mode 100755 index 0000000..9e77ebc --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/comp.h @@ -0,0 +1,66 @@ + +#ifndef HEADER_COMP_H +#define HEADER_COMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct comp_ctx_st COMP_CTX; + +typedef struct comp_method_st + { + int type; /* NID for compression library */ + const char *name; /* A text string to identify the library */ + int (*init)(COMP_CTX *ctx); + void (*finish)(COMP_CTX *ctx); + int (*compress)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + int (*expand)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + /* The following two do NOTHING, but are kept for backward compatibility */ + long (*ctrl)(void); + long (*callback_ctrl)(void); + } COMP_METHOD; + +struct comp_ctx_st + { + COMP_METHOD *meth; + unsigned long compress_in; + unsigned long compress_out; + unsigned long expand_in; + unsigned long expand_out; + + CRYPTO_EX_DATA ex_data; + }; + + +COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); +void COMP_CTX_free(COMP_CTX *ctx); +int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +COMP_METHOD *COMP_rle(void ); +COMP_METHOD *COMP_zlib(void ); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_COMP_strings(void); + +/* Error codes for the COMP functions. */ + +/* Function codes. */ + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/conf.h b/libraries/external/openssl/linux/include/openssl/conf.h new file mode 100755 index 0000000..bc8f95d --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/conf.h @@ -0,0 +1,253 @@ +/* crypto/conf/conf.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_H +#define HEADER_CONF_H + +#include +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct + { + char *section; + char *name; + char *value; + } CONF_VALUE; + +DECLARE_STACK_OF(CONF_VALUE) +DECLARE_STACK_OF(CONF_MODULE) +DECLARE_STACK_OF(CONF_IMODULE) + +struct conf_st; +struct conf_method_st; +typedef struct conf_method_st CONF_METHOD; + +struct conf_method_st + { + const char *name; + CONF *(*create)(CONF_METHOD *meth); + int (*init)(CONF *conf); + int (*destroy)(CONF *conf); + int (*destroy_data)(CONF *conf); + int (*load_bio)(CONF *conf, BIO *bp, long *eline); + int (*dump)(const CONF *conf, BIO *bp); + int (*is_number)(const CONF *conf, char c); + int (*to_int)(const CONF *conf, char c); + int (*load)(CONF *conf, const char *name, long *eline); + }; + +/* Module definitions */ + +typedef struct conf_imodule_st CONF_IMODULE; +typedef struct conf_module_st CONF_MODULE; + +/* DSO module function typedefs */ +typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); +typedef void conf_finish_func(CONF_IMODULE *md); + +#define CONF_MFLAGS_IGNORE_ERRORS 0x1 +#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 +#define CONF_MFLAGS_SILENT 0x4 +#define CONF_MFLAGS_NO_DSO 0x8 +#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 + +int CONF_set_default_method(CONF_METHOD *meth); +void CONF_set_nconf(CONF *conf,LHASH *hash); +LHASH *CONF_load(LHASH *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); +#endif +LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); +char *CONF_get_string(LHASH *conf,const char *group,const char *name); +long CONF_get_number(LHASH *conf,const char *group,const char *name); +void CONF_free(LHASH *conf); +int CONF_dump_fp(LHASH *conf, FILE *out); +int CONF_dump_bio(LHASH *conf, BIO *out); + +void OPENSSL_config(const char *config_name); +void OPENSSL_no_config(void); + +/* New conf code. The semantics are different from the functions above. + If that wasn't the case, the above functions would have been replaced */ + +struct conf_st + { + CONF_METHOD *meth; + void *meth_data; + LHASH *data; + }; + +CONF *NCONF_new(CONF_METHOD *meth); +CONF_METHOD *NCONF_default(void); +CONF_METHOD *NCONF_WIN32(void); +#if 0 /* Just to give you an idea of what I have in mind */ +CONF_METHOD *NCONF_XML(void); +#endif +void NCONF_free(CONF *conf); +void NCONF_free_data(CONF *conf); + +int NCONF_load(CONF *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); +#endif +int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); +char *NCONF_get_string(const CONF *conf,const char *group,const char *name); +int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, + long *result); +int NCONF_dump_fp(const CONF *conf, FILE *out); +int NCONF_dump_bio(const CONF *conf, BIO *out); + +#if 0 /* The following function has no error checking, + and should therefore be avoided */ +long NCONF_get_number(CONF *conf,char *group,char *name); +#else +#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) +#endif + +/* Module functions */ + +int CONF_modules_load(const CONF *cnf, const char *appname, + unsigned long flags); +int CONF_modules_load_file(const char *filename, const char *appname, + unsigned long flags); +void CONF_modules_unload(int all); +void CONF_modules_finish(void); +void CONF_modules_free(void); +int CONF_module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); + +const char *CONF_imodule_get_name(const CONF_IMODULE *md); +const char *CONF_imodule_get_value(const CONF_IMODULE *md); +void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); +void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); +CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); +unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); +void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); +void *CONF_module_get_usr_data(CONF_MODULE *pmod); +void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); + +char *CONF_get1_default_config_file(void); + +int CONF_parse_list(const char *list, int sep, int nospc, + int (*list_cb)(const char *elem, int len, void *usr), void *arg); + +void OPENSSL_load_builtin_modules(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CONF_strings(void); + +/* Error codes for the CONF functions. */ + +/* Function codes. */ +#define CONF_F_CONF_DUMP_FP 104 +#define CONF_F_CONF_LOAD 100 +#define CONF_F_CONF_LOAD_BIO 102 +#define CONF_F_CONF_LOAD_FP 103 +#define CONF_F_CONF_MODULES_LOAD 116 +#define CONF_F_DEF_LOAD 120 +#define CONF_F_DEF_LOAD_BIO 121 +#define CONF_F_MODULE_INIT 115 +#define CONF_F_MODULE_LOAD_DSO 117 +#define CONF_F_MODULE_RUN 118 +#define CONF_F_NCONF_DUMP_BIO 105 +#define CONF_F_NCONF_DUMP_FP 106 +#define CONF_F_NCONF_GET_NUMBER 107 +#define CONF_F_NCONF_GET_NUMBER_E 112 +#define CONF_F_NCONF_GET_SECTION 108 +#define CONF_F_NCONF_GET_STRING 109 +#define CONF_F_NCONF_LOAD 113 +#define CONF_F_NCONF_LOAD_BIO 110 +#define CONF_F_NCONF_LOAD_FP 114 +#define CONF_F_NCONF_NEW 111 +#define CONF_F_STR_COPY 101 + +/* Reason codes. */ +#define CONF_R_ERROR_LOADING_DSO 110 +#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +#define CONF_R_MISSING_EQUAL_SIGN 101 +#define CONF_R_MISSING_FINISH_FUNCTION 111 +#define CONF_R_MISSING_INIT_FUNCTION 112 +#define CONF_R_MODULE_INITIALIZATION_ERROR 109 +#define CONF_R_NO_CLOSE_BRACE 102 +#define CONF_R_NO_CONF 105 +#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 +#define CONF_R_NO_SECTION 107 +#define CONF_R_NO_SUCH_FILE 114 +#define CONF_R_NO_VALUE 108 +#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +#define CONF_R_UNKNOWN_MODULE_NAME 113 +#define CONF_R_VARIABLE_HAS_NO_VALUE 104 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/conf_api.h b/libraries/external/openssl/linux/include/openssl/conf_api.h new file mode 100755 index 0000000..8e7d5d5 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/conf_api.h @@ -0,0 +1,89 @@ +/* conf_api.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_API_H +#define HEADER_CONF_API_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Up until OpenSSL 0.9.5a, this was new_section */ +CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was get_section */ +CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ +STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, + const char *section); + +int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); +char *_CONF_get_string(const CONF *conf, const char *section, + const char *name); +long _CONF_get_number(const CONF *conf, const char *section, const char *name); + +int _CONF_new_data(CONF *conf); +void _CONF_free_data(CONF *conf); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/crypto.h b/libraries/external/openssl/linux/include/openssl/crypto.h new file mode 100755 index 0000000..fcba789 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/crypto.h @@ -0,0 +1,550 @@ +/* crypto/crypto.h */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_CRYPTO_H +#define HEADER_CRYPTO_H + +#include + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#include +#include +#include +#include + +#ifdef CHARSET_EBCDIC +#include +#endif + +/* Resolve problems on some operating systems with symbol names that clash + one way or another */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Backward compatibility to SSLeay */ +/* This is more to be used to check the correct DLL is being used + * in the MS world. */ +#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER +#define SSLEAY_VERSION 0 +/* #define SSLEAY_OPTIONS 1 no longer supported */ +#define SSLEAY_CFLAGS 2 +#define SSLEAY_BUILT_ON 3 +#define SSLEAY_PLATFORM 4 +#define SSLEAY_DIR 5 + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Called when a new object is created */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when an object is free()ed */ +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when we need to dup an object */ +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); +#endif + +/* A generic structure to pass assorted data in a expandable way */ +typedef struct openssl_item_st + { + int code; + void *value; /* Not used for flag attributes */ + size_t value_size; /* Max size of value for output, length for input */ + size_t *value_length; /* Returned length of value for output */ + } OPENSSL_ITEM; + + +/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock + * names in cryptlib.c + */ + +#define CRYPTO_LOCK_ERR 1 +#define CRYPTO_LOCK_EX_DATA 2 +#define CRYPTO_LOCK_X509 3 +#define CRYPTO_LOCK_X509_INFO 4 +#define CRYPTO_LOCK_X509_PKEY 5 +#define CRYPTO_LOCK_X509_CRL 6 +#define CRYPTO_LOCK_X509_REQ 7 +#define CRYPTO_LOCK_DSA 8 +#define CRYPTO_LOCK_RSA 9 +#define CRYPTO_LOCK_EVP_PKEY 10 +#define CRYPTO_LOCK_X509_STORE 11 +#define CRYPTO_LOCK_SSL_CTX 12 +#define CRYPTO_LOCK_SSL_CERT 13 +#define CRYPTO_LOCK_SSL_SESSION 14 +#define CRYPTO_LOCK_SSL_SESS_CERT 15 +#define CRYPTO_LOCK_SSL 16 +#define CRYPTO_LOCK_SSL_METHOD 17 +#define CRYPTO_LOCK_RAND 18 +#define CRYPTO_LOCK_RAND2 19 +#define CRYPTO_LOCK_MALLOC 20 +#define CRYPTO_LOCK_BIO 21 +#define CRYPTO_LOCK_GETHOSTBYNAME 22 +#define CRYPTO_LOCK_GETSERVBYNAME 23 +#define CRYPTO_LOCK_READDIR 24 +#define CRYPTO_LOCK_RSA_BLINDING 25 +#define CRYPTO_LOCK_DH 26 +#define CRYPTO_LOCK_MALLOC2 27 +#define CRYPTO_LOCK_DSO 28 +#define CRYPTO_LOCK_DYNLOCK 29 +#define CRYPTO_LOCK_ENGINE 30 +#define CRYPTO_LOCK_UI 31 +#define CRYPTO_LOCK_ECDSA 32 +#define CRYPTO_LOCK_EC 33 +#define CRYPTO_LOCK_ECDH 34 +#define CRYPTO_LOCK_BN 35 +#define CRYPTO_LOCK_EC_PRE_COMP 36 +#define CRYPTO_LOCK_STORE 37 +#define CRYPTO_LOCK_COMP 38 +#define CRYPTO_NUM_LOCKS 39 + +#define CRYPTO_LOCK 1 +#define CRYPTO_UNLOCK 2 +#define CRYPTO_READ 4 +#define CRYPTO_WRITE 8 + +#ifndef OPENSSL_NO_LOCKING +#ifndef CRYPTO_w_lock +#define CRYPTO_w_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_w_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_r_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_r_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_add(addr,amount,type) \ + CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) +#endif +#else +#define CRYPTO_w_lock(a) +#define CRYPTO_w_unlock(a) +#define CRYPTO_r_lock(a) +#define CRYPTO_r_unlock(a) +#define CRYPTO_add(a,b,c) ((*(a))+=(b)) +#endif + +/* Some applications as well as some parts of OpenSSL need to allocate + and deallocate locks in a dynamic fashion. The following typedef + makes this possible in a type-safe manner. */ +/* struct CRYPTO_dynlock_value has to be defined by the application. */ +typedef struct + { + int references; + struct CRYPTO_dynlock_value *data; + } CRYPTO_dynlock; + + +/* The following can be used to detect memory leaks in the SSLeay library. + * It used, it turns on malloc checking */ + +#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ +#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ +#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ +#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ + +/* The following are bit values to turn on or off options connected to the + * malloc checking functionality */ + +/* Adds time to the memory checking information */ +#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ +/* Adds thread number to the memory checking information */ +#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ + +#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) + + +/* predec of the BIO type */ +typedef struct bio_st BIO_dummy; + +struct crypto_ex_data_st + { + STACK *sk; + int dummy; /* gcc is screwing up this data structure :-( */ + }; + +/* This stuff is basically class callback functions + * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ + +typedef struct crypto_ex_data_func_st + { + long argl; /* Arbitary long */ + void *argp; /* Arbitary void * */ + CRYPTO_EX_new *new_func; + CRYPTO_EX_free *free_func; + CRYPTO_EX_dup *dup_func; + } CRYPTO_EX_DATA_FUNCS; + +DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) + +/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA + * entry. + */ + +#define CRYPTO_EX_INDEX_BIO 0 +#define CRYPTO_EX_INDEX_SSL 1 +#define CRYPTO_EX_INDEX_SSL_CTX 2 +#define CRYPTO_EX_INDEX_SSL_SESSION 3 +#define CRYPTO_EX_INDEX_X509_STORE 4 +#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 +#define CRYPTO_EX_INDEX_RSA 6 +#define CRYPTO_EX_INDEX_DSA 7 +#define CRYPTO_EX_INDEX_DH 8 +#define CRYPTO_EX_INDEX_ENGINE 9 +#define CRYPTO_EX_INDEX_X509 10 +#define CRYPTO_EX_INDEX_UI 11 +#define CRYPTO_EX_INDEX_ECDSA 12 +#define CRYPTO_EX_INDEX_ECDH 13 +#define CRYPTO_EX_INDEX_COMP 14 +#define CRYPTO_EX_INDEX_STORE 15 + +/* Dynamically assigned indexes start from this value (don't use directly, use + * via CRYPTO_ex_data_new_class). */ +#define CRYPTO_EX_INDEX_USER 100 + + +/* This is the default callbacks, but we can have others as well: + * this is needed in Win32 where the application malloc and the + * library malloc may not be the same. + */ +#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ + malloc, realloc, free) + +#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD +# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ +# define CRYPTO_MDEBUG +# endif +#endif + +/* Set standard debugging functions (not done by default + * unless CRYPTO_MDEBUG is defined) */ +#define CRYPTO_malloc_debug_init() do {\ + CRYPTO_set_mem_debug_functions(\ + CRYPTO_dbg_malloc,\ + CRYPTO_dbg_realloc,\ + CRYPTO_dbg_free,\ + CRYPTO_dbg_set_options,\ + CRYPTO_dbg_get_options);\ + } while(0) + +int CRYPTO_mem_ctrl(int mode); +int CRYPTO_is_mem_check_on(void); + +/* for applications */ +#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) +#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) + +/* for library-internal use */ +#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) +#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) +#define is_MemCheck_on() CRYPTO_is_mem_check_on() + +#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) +#define OPENSSL_realloc(addr,num) \ + CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_realloc_clean(addr,old_num,num) \ + CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) +#define OPENSSL_remalloc(addr,num) \ + CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_freeFunc CRYPTO_free +#define OPENSSL_free(addr) CRYPTO_free(addr) + +#define OPENSSL_malloc_locked(num) \ + CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) +#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) + + +const char *SSLeay_version(int type); +unsigned long SSLeay(void); + +int OPENSSL_issetugid(void); + +/* An opaque type representing an implementation of "ex_data" support */ +typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; +/* Return an opaque pointer to the current "ex_data" implementation */ +const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); +/* Sets the "ex_data" implementation to be used (if it's not too late) */ +int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); +/* Get a new "ex_data" class, and return the corresponding "class_index" */ +int CRYPTO_ex_data_new_class(void); +/* Within a given class, get/register a new index */ +int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, + CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func); +/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given + * class (invokes whatever per-class callbacks are applicable) */ +int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, + CRYPTO_EX_DATA *from); +void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index + * (relative to the class type involved) */ +int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); +void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); +/* This function cleans up all "ex_data" state. It mustn't be called under + * potential race-conditions. */ +void CRYPTO_cleanup_all_ex_data(void); + +int CRYPTO_get_new_lockid(char *name); + +int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ +void CRYPTO_lock(int mode, int type,const char *file,int line); +void CRYPTO_set_locking_callback(void (*func)(int mode,int type, + const char *file,int line)); +void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, + int line); +void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, + const char *file, int line)); +int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, + const char *file,int line); +void CRYPTO_set_id_callback(unsigned long (*func)(void)); +unsigned long (*CRYPTO_get_id_callback(void))(void); +unsigned long CRYPTO_thread_id(void); +const char *CRYPTO_get_lock_name(int type); +int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, + int line); + +int CRYPTO_get_new_dynlockid(void); +void CRYPTO_destroy_dynlockid(int i); +struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); +void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); +void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); +void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); +struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); +void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); +void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); + +/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- + * call the latter last if you need different functions */ +int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); +int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); +int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), + void *(*r)(void *,size_t,const char *,int), + void (*f)(void *)); +int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), + void (*free_func)(void *)); +int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), + void (*r)(void *,void *,int,const char *,int,int), + void (*f)(void *,int), + void (*so)(long), + long (*go)(void)); +void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); +void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); +void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), + void *(**r)(void *, size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), + void (**r)(void *,void *,int,const char *,int,int), + void (**f)(void *,int), + void (**so)(long), + long (**go)(void)); + +void *CRYPTO_malloc_locked(int num, const char *file, int line); +void CRYPTO_free_locked(void *); +void *CRYPTO_malloc(int num, const char *file, int line); +void CRYPTO_free(void *); +void *CRYPTO_realloc(void *addr,int num, const char *file, int line); +void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, + int line); +void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); + +void OPENSSL_cleanse(void *ptr, size_t len); + +void CRYPTO_set_mem_debug_options(long bits); +long CRYPTO_get_mem_debug_options(void); + +#define CRYPTO_push_info(info) \ + CRYPTO_push_info_(info, __FILE__, __LINE__); +int CRYPTO_push_info_(const char *info, const char *file, int line); +int CRYPTO_pop_info(void); +int CRYPTO_remove_all_info(void); + + +/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; + * used as default in CRYPTO_MDEBUG compilations): */ +/* The last argument has the following significance: + * + * 0: called before the actual memory allocation has taken place + * 1: called after the actual memory allocation has taken place + */ +void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_free(void *addr,int before_p); +/* Tell the debugging code about options. By default, the following values + * apply: + * + * 0: Clear all options. + * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. + * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. + * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 + */ +void CRYPTO_dbg_set_options(long bits); +long CRYPTO_dbg_get_options(void); + + +#ifndef OPENSSL_NO_FP_API +void CRYPTO_mem_leaks_fp(FILE *); +#endif +void CRYPTO_mem_leaks(struct bio_st *bio); +/* unsigned long order, char *file, int line, int num_bytes, char *addr */ +typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); +void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); + +/* die if we have to */ +void OpenSSLDie(const char *file,int line,const char *assertion); +#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) + +unsigned long *OPENSSL_ia32cap_loc(void); +#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CRYPTO_strings(void); + +/* Error codes for the CRYPTO functions. */ + +/* Function codes. */ +#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 +#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 +#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 +#define CRYPTO_F_DEF_ADD_INDEX 104 +#define CRYPTO_F_DEF_GET_CLASS 105 +#define CRYPTO_F_INT_DUP_EX_DATA 106 +#define CRYPTO_F_INT_FREE_EX_DATA 107 +#define CRYPTO_F_INT_NEW_EX_DATA 108 + +/* Reason codes. */ +#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/des.h b/libraries/external/openssl/linux/include/openssl/des.h new file mode 100755 index 0000000..5ed8747 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/des.h @@ -0,0 +1,244 @@ +/* crypto/des/des.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_NEW_DES_H +#define HEADER_NEW_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, + DES_LONG (via openssl/opensslconf.h */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char DES_cblock[8]; +typedef /* const */ unsigned char const_DES_cblock[8]; +/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * + * and const_DES_cblock * are incompatible pointer types. */ + +typedef struct DES_ks + { + union + { + DES_cblock cblock; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG deslong[2]; + } ks[16]; + } DES_key_schedule; + +#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT +# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT +# define OPENSSL_ENABLE_OLD_DES_SUPPORT +# endif +#endif + +#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT +# include +#endif + +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define DES_ecb2_encrypt(i,o,k1,k2,e) \ + DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ +#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) +OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ +#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) + +const char *DES_options(void); +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); +DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, + long length,DES_key_schedule *schedule, + const_DES_cblock *ivec); +/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ +void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + const_DES_cblock *inw,const_DES_cblock *outw,int enc); +void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, + DES_key_schedule *ks,int enc); + +/* This is the DES encryption function that gets called by just about + every other DES routine in the library. You should not use this + function except to implement 'modes' of DES. I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. The characters are loaded 'little endian'. + Data is a pointer to 2 unsigned long's and ks is the + DES_key_schedule to use. enc, is non zero specifies encryption, + zero if decryption. */ +void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); + +/* This functions is the same as DES_encrypt1() except that the DES + initial permutation (IP) and final permutation (FP) have been left + out. As for DES_encrypt1(), you should not use this function. + It is used by the routines in the library that implement triple DES. + IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same + as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ +void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); + +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3,DES_cblock *ivec,int enc); +void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, + DES_cblock *ivec1,DES_cblock *ivec2, + int enc); +void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num,int enc); +void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, + int numbits,long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int enc); +void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num); + +void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, + DES_cblock *out_white); + +int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +char *DES_fcrypt(const char *buf,const char *salt, char *ret); +char *DES_crypt(const char *buf,const char *salt); +void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec); +void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], + long length,int out_count,DES_cblock *seed); +int DES_random_key(DES_cblock *ret); +void DES_set_odd_parity(DES_cblock *key); +int DES_check_key_parity(const_DES_cblock *key); +int DES_is_weak_key(const_DES_cblock *key); +/* DES_set_key (= set_key = DES_key_sched = key_sched) calls + * DES_set_key_checked if global variable DES_check_key is set, + * DES_set_key_unchecked otherwise. */ +int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_string_to_key(const char *str,DES_cblock *key); +void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); +void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num, + int enc); +void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num); + +int DES_read_password(DES_cblock *key, const char *prompt, int verify); +int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, + int verify); + +#define DES_fixup_key_parity DES_set_odd_parity + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/des_old.h b/libraries/external/openssl/linux/include/openssl/des_old.h new file mode 100755 index 0000000..caaa1da --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/des_old.h @@ -0,0 +1,445 @@ +/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * The function names in here are deprecated and are only present to + * provide an interface compatible with openssl 0.9.6 and older as + * well as libdes. OpenSSL now provides functions where "des_" has + * been replaced with "DES_" in the names, to make it possible to + * make incompatible changes that are needed for C type security and + * other stuff. + * + * This include files has two compatibility modes: + * + * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API + * that is compatible with libdes and SSLeay. + * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an + * API that is compatible with OpenSSL 0.9.5x to 0.9.6x. + * + * Note that these modes break earlier snapshots of OpenSSL, where + * libdes compatibility was the only available mode or (later on) the + * prefered compatibility mode. However, after much consideration + * (and more or less violent discussions with external parties), it + * was concluded that OpenSSL should be compatible with earlier versions + * of itself before anything else. Also, in all honesty, libdes is + * an old beast that shouldn't really be used any more. + * + * Please consider starting to use the DES_ functions rather than the + * des_ ones. The des_ functions will disappear completely before + * OpenSSL 1.0! + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DES_H +#define HEADER_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifndef HEADER_NEW_DES_H +#error You must include des.h, not des_old.h directly. +#endif + +#ifdef _KERBEROS_DES_H +#error replaces . +#endif + +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _ +#undef _ +#endif + +typedef unsigned char _ossl_old_des_cblock[8]; +typedef struct _ossl_old_des_ks_struct + { + union { + _ossl_old_des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; + } _ossl_old_des_key_schedule[16]; + +#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY +#define des_cblock DES_cblock +#define const_des_cblock const_DES_cblock +#define des_key_schedule DES_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e)) +#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\ + DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n)) +#define des_options()\ + DES_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + DES_cbc_cksum((i),(o),(l),&(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + DES_ecb_encrypt((i),(o),&(k),(e)) +#define des_encrypt1(d,k,e)\ + DES_encrypt1((d),&(k),(e)) +#define des_encrypt2(d,k,e)\ + DES_encrypt2((d),&(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + DES_encrypt3((d),&(k1),&(k2),&(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + DES_decrypt3((d),&(k1),&(k2),&(k3)) +#define des_xwhite_in2out(k,i,o)\ + DES_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + DES_enc_read((f),(b),(l),&(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + DES_enc_write((f),(b),(l),&(k),(iv)) +#define des_fcrypt(b,s,r)\ + DES_fcrypt((b),(s),(r)) +#if 0 +#define des_crypt(b,s)\ + DES_crypt((b),(s)) +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) +#define crypt(b,s)\ + DES_crypt((b),(s)) +#endif +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + DES_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_096_des_random_seed((k)) +#define des_random_key(r)\ + DES_random_key((r)) +#define des_read_password(k,p,v) \ + DES_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + DES_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + DES_set_odd_parity((k)) +#define des_check_key_parity(k)\ + DES_check_key_parity((k)) +#define des_is_weak_key(k)\ + DES_is_weak_key((k)) +#define des_set_key(k,ks)\ + DES_set_key((k),&(ks)) +#define des_key_sched(k,ks)\ + DES_key_sched((k),&(ks)) +#define des_set_key_checked(k,ks)\ + DES_set_key_checked((k),&(ks)) +#define des_set_key_unchecked(k,ks)\ + DES_set_key_unchecked((k),&(ks)) +#define des_string_to_key(s,k)\ + DES_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + DES_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#else /* libdes compatibility */ +/* Map all symbol names to _ossl_old_des_* form, so we avoid all + clashes with libdes */ +#define des_cblock _ossl_old_des_cblock +#define des_key_schedule _ossl_old_des_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n)) +#define des_options()\ + _ossl_old_des_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + _ossl_old_des_ecb_encrypt((i),(o),(k),(e)) +#define des_encrypt(d,k,e)\ + _ossl_old_des_encrypt((d),(k),(e)) +#define des_encrypt2(d,k,e)\ + _ossl_old_des_encrypt2((d),(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + _ossl_old_des_encrypt3((d),(k1),(k2),(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + _ossl_old_des_decrypt3((d),(k1),(k2),(k3)) +#define des_xwhite_in2out(k,i,o)\ + _ossl_old_des_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + _ossl_old_des_enc_read((f),(b),(l),(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + _ossl_old_des_enc_write((f),(b),(l),(k),(iv)) +#define des_fcrypt(b,s,r)\ + _ossl_old_des_fcrypt((b),(s),(r)) +#define des_crypt(b,s)\ + _ossl_old_des_crypt((b),(s)) +#if 0 +#define crypt(b,s)\ + _ossl_old_crypt((b),(s)) +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + _ossl_old_des_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_old_des_random_seed((k)) +#define des_random_key(r)\ + _ossl_old_des_random_key((r)) +#define des_read_password(k,p,v) \ + _ossl_old_des_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + _ossl_old_des_set_odd_parity((k)) +#define des_is_weak_key(k)\ + _ossl_old_des_is_weak_key((k)) +#define des_set_key(k,ks)\ + _ossl_old_des_set_key((k),(ks)) +#define des_key_sched(k,ks)\ + _ossl_old_des_key_sched((k),(ks)) +#define des_string_to_key(s,k)\ + _ossl_old_des_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + _ossl_old_des_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#endif + +const char *_ossl_old_des_options(void); +void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, int enc); +DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec, + _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc); +void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks,int enc); +void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc); +void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), + _ossl_old_des_cblock (*out_white)); + +int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret); +char *_ossl_old_des_crypt(const char *buf,const char *salt); +#if !defined(PERL5) && !defined(NeXT) +char *_ossl_old_crypt(const char *buf,const char *salt); +#endif +void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,int out_count,_ossl_old_des_cblock *seed); +void _ossl_old_des_random_seed(_ossl_old_des_cblock key); +void _ossl_old_des_random_key(_ossl_old_des_cblock ret); +int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify); +int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2, + const char *prompt,int verify); +void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key); +int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key); +int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key); +void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2); +void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_096_des_random_seed(des_cblock *key); + +/* The following definitions provide compatibility with the MIT Kerberos + * library. The _ossl_old_des_key_schedule structure is not binary compatible. */ + +#define _KERBEROS_DES_H + +#define KRBDES_ENCRYPT DES_ENCRYPT +#define KRBDES_DECRYPT DES_DECRYPT + +#ifdef KERBEROS +# define ENCRYPT DES_ENCRYPT +# define DECRYPT DES_DECRYPT +#endif + +#ifndef NCOMPAT +# define C_Block des_cblock +# define Key_schedule des_key_schedule +# define KEY_SZ DES_KEY_SZ +# define string_to_key des_string_to_key +# define read_pw_string des_read_pw_string +# define random_key des_random_key +# define pcbc_encrypt des_pcbc_encrypt +# define set_key des_set_key +# define key_sched des_key_sched +# define ecb_encrypt des_ecb_encrypt +# define cbc_encrypt des_cbc_encrypt +# define ncbc_encrypt des_ncbc_encrypt +# define xcbc_encrypt des_xcbc_encrypt +# define cbc_cksum des_cbc_cksum +# define quad_cksum des_quad_cksum +# define check_parity des_check_key_parity +#endif + +#define des_fixup_key_parity DES_fixup_key_parity + +#ifdef __cplusplus +} +#endif + +/* for DES_read_pw_string et al */ +#include + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/dh.h b/libraries/external/openssl/linux/include/openssl/dh.h new file mode 100755 index 0000000..44158f8 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/dh.h @@ -0,0 +1,234 @@ +/* crypto/dh/dh.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_DH_H +#define HEADER_DH_H + +#include + +#ifdef OPENSSL_NO_DH +#error DH is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifndef OPENSSL_DH_MAX_MODULUS_BITS +# define OPENSSL_DH_MAX_MODULUS_BITS 10000 +#endif + +#define DH_FLAG_CACHE_MONT_P 0x01 +#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dh_st DH; */ +/* typedef struct dh_method DH_METHOD; */ + +struct dh_method + { + const char *name; + /* Methods here */ + int (*generate_key)(DH *dh); + int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh); + int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a, + const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + + int (*init)(DH *dh); + int (*finish)(DH *dh); + int flags; + char *app_data; + /* If this is non-NULL, it will be used to generate parameters */ + int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb); + }; + +struct dh_st + { + /* This first argument is used to pick up errors when + * a DH is passed instead of a EVP_PKEY */ + int pad; + int version; + BIGNUM *p; + BIGNUM *g; + long length; /* optional */ + BIGNUM *pub_key; /* g^x */ + BIGNUM *priv_key; /* x */ + + int flags; + BN_MONT_CTX *method_mont_p; + /* Place holders if we want to do X9.42 DH */ + BIGNUM *q; + BIGNUM *j; + unsigned char *seed; + int seedlen; + BIGNUM *counter; + + int references; + CRYPTO_EX_DATA ex_data; + const DH_METHOD *meth; + ENGINE *engine; + }; + +#define DH_GENERATOR_2 2 +/* #define DH_GENERATOR_3 3 */ +#define DH_GENERATOR_5 5 + +/* DH_check error codes */ +#define DH_CHECK_P_NOT_PRIME 0x01 +#define DH_CHECK_P_NOT_SAFE_PRIME 0x02 +#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 +#define DH_NOT_SUITABLE_GENERATOR 0x08 + +/* DH_check_pub_key error codes */ +#define DH_CHECK_PUBKEY_TOO_SMALL 0x01 +#define DH_CHECK_PUBKEY_TOO_LARGE 0x02 + +/* primes p where (p-1)/2 is prime too are called "safe"; we define + this for backward compatibility: */ +#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME + +#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x) +#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ + (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) +#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) +#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) + +const DH_METHOD *DH_OpenSSL(void); + +void DH_set_default_method(const DH_METHOD *meth); +const DH_METHOD *DH_get_default_method(void); +int DH_set_method(DH *dh, const DH_METHOD *meth); +DH *DH_new_method(ENGINE *engine); + +DH * DH_new(void); +void DH_free(DH *dh); +int DH_up_ref(DH *dh); +int DH_size(const DH *dh); +int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DH_set_ex_data(DH *d, int idx, void *arg); +void *DH_get_ex_data(DH *d, int idx); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DH * DH_generate_parameters(int prime_len,int generator, + void (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); + +int DH_check(const DH *dh,int *codes); +int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes); +int DH_generate_key(DH *dh); +int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh); +DH * d2i_DHparams(DH **a,const unsigned char **pp, long length); +int i2d_DHparams(const DH *a,unsigned char **pp); +#ifndef OPENSSL_NO_FP_API +int DHparams_print_fp(FILE *fp, const DH *x); +#endif +#ifndef OPENSSL_NO_BIO +int DHparams_print(BIO *bp, const DH *x); +#else +int DHparams_print(char *bp, const DH *x); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DH_strings(void); + +/* Error codes for the DH functions. */ + +/* Function codes. */ +#define DH_F_COMPUTE_KEY 102 +#define DH_F_DHPARAMS_PRINT 100 +#define DH_F_DHPARAMS_PRINT_FP 101 +#define DH_F_DH_BUILTIN_GENPARAMS 106 +#define DH_F_DH_NEW_METHOD 105 +#define DH_F_GENERATE_KEY 103 +#define DH_F_GENERATE_PARAMETERS 104 + +/* Reason codes. */ +#define DH_R_BAD_GENERATOR 101 +#define DH_R_INVALID_PUBKEY 102 +#define DH_R_MODULUS_TOO_LARGE 103 +#define DH_R_NO_PRIVATE_VALUE 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/dsa.h b/libraries/external/openssl/linux/include/openssl/dsa.h new file mode 100755 index 0000000..fa58369 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/dsa.h @@ -0,0 +1,285 @@ +/* crypto/dsa/dsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* + * The DSS routines are based on patches supplied by + * Steven Schoch . He basically did the + * work and I have just tweaked them a little to fit into my + * stylistic vision for SSLeay :-) */ + +#ifndef HEADER_DSA_H +#define HEADER_DSA_H + +#include + +#ifdef OPENSSL_NO_DSA +#error DSA is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_DH +# include +#endif +#endif + +#ifndef OPENSSL_DSA_MAX_MODULUS_BITS +# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 +#endif + +#define DSA_FLAG_CACHE_MONT_P 0x01 +#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dsa_st DSA; */ +/* typedef struct dsa_method DSA_METHOD; */ + +typedef struct DSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } DSA_SIG; + +struct dsa_method + { + const char *name; + DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa); + int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); + int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); + int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, + BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); + int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(DSA *dsa); + int (*finish)(DSA *dsa); + int flags; + char *app_data; + /* If this is non-NULL, it is used to generate DSA parameters */ + int (*dsa_paramgen)(DSA *dsa, int bits, + unsigned char *seed, int seed_len, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); + /* If this is non-NULL, it is used to generate DSA keys */ + int (*dsa_keygen)(DSA *dsa); + }; + +struct dsa_st + { + /* This first variable is used to pick up errors where + * a DSA is passed instead of of a EVP_PKEY */ + int pad; + long version; + int write_params; + BIGNUM *p; + BIGNUM *q; /* == 20 */ + BIGNUM *g; + + BIGNUM *pub_key; /* y public key */ + BIGNUM *priv_key; /* x private key */ + + BIGNUM *kinv; /* Signing pre-calc */ + BIGNUM *r; /* Signing pre-calc */ + + int flags; + /* Normally used to cache montgomery values */ + BN_MONT_CTX *method_mont_p; + int references; + CRYPTO_EX_DATA ex_data; + const DSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + }; + +#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x) +#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ + (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) +#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) +#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) + + +DSA_SIG * DSA_SIG_new(void); +void DSA_SIG_free(DSA_SIG *a); +int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); +DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); + +DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); +int DSA_do_verify(const unsigned char *dgst,int dgst_len, + DSA_SIG *sig,DSA *dsa); + +const DSA_METHOD *DSA_OpenSSL(void); + +void DSA_set_default_method(const DSA_METHOD *); +const DSA_METHOD *DSA_get_default_method(void); +int DSA_set_method(DSA *dsa, const DSA_METHOD *); + +DSA * DSA_new(void); +DSA * DSA_new_method(ENGINE *engine); +void DSA_free (DSA *r); +/* "up" the DSA object's reference count */ +int DSA_up_ref(DSA *r); +int DSA_size(const DSA *); + /* next 4 return -1 on error */ +int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); +int DSA_sign(int type,const unsigned char *dgst,int dlen, + unsigned char *sig, unsigned int *siglen, DSA *dsa); +int DSA_verify(int type,const unsigned char *dgst,int dgst_len, + const unsigned char *sigbuf, int siglen, DSA *dsa); +int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DSA_set_ex_data(DSA *d, int idx, void *arg); +void *DSA_get_ex_data(DSA *d, int idx); + +DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DSA * DSA_generate_parameters(int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret,void + (*callback)(int, int, void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DSA_generate_parameters_ex(DSA *dsa, int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); + +int DSA_generate_key(DSA *a); +int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); +int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); +int i2d_DSAparams(const DSA *a,unsigned char **pp); + +#ifndef OPENSSL_NO_BIO +int DSAparams_print(BIO *bp, const DSA *x); +int DSA_print(BIO *bp, const DSA *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int DSAparams_print_fp(FILE *fp, const DSA *x); +int DSA_print_fp(FILE *bp, const DSA *x, int off); +#endif + +#define DSS_prime_checks 50 +/* Primality test according to FIPS PUB 186[-1], Appendix 2.1: + * 50 rounds of Rabin-Miller */ +#define DSA_is_prime(n, callback, cb_arg) \ + BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) + +#ifndef OPENSSL_NO_DH +/* Convert DSA structure (key or just parameters) into DH structure + * (be careful to avoid small subgroup attacks when using this!) */ +DH *DSA_dup_DH(const DSA *r); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSA_strings(void); + +/* Error codes for the DSA functions. */ + +/* Function codes. */ +#define DSA_F_D2I_DSA_SIG 110 +#define DSA_F_DSAPARAMS_PRINT 100 +#define DSA_F_DSAPARAMS_PRINT_FP 101 +#define DSA_F_DSA_DO_SIGN 112 +#define DSA_F_DSA_DO_VERIFY 113 +#define DSA_F_DSA_NEW_METHOD 103 +#define DSA_F_DSA_PRINT 104 +#define DSA_F_DSA_PRINT_FP 105 +#define DSA_F_DSA_SIGN 106 +#define DSA_F_DSA_SIGN_SETUP 107 +#define DSA_F_DSA_SIG_NEW 109 +#define DSA_F_DSA_VERIFY 108 +#define DSA_F_I2D_DSA_SIG 111 +#define DSA_F_SIG_CB 114 + +/* Reason codes. */ +#define DSA_R_BAD_Q_VALUE 102 +#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 +#define DSA_R_MISSING_PARAMETERS 101 +#define DSA_R_MODULUS_TOO_LARGE 103 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/dso.h b/libraries/external/openssl/linux/include/openssl/dso.h new file mode 100755 index 0000000..1836231 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/dso.h @@ -0,0 +1,368 @@ +/* dso.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DSO_H +#define HEADER_DSO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These values are used as commands to DSO_ctrl() */ +#define DSO_CTRL_GET_FLAGS 1 +#define DSO_CTRL_SET_FLAGS 2 +#define DSO_CTRL_OR_FLAGS 3 + +/* By default, DSO_load() will translate the provided filename into a form + * typical for the platform (more specifically the DSO_METHOD) using the + * dso_name_converter function of the method. Eg. win32 will transform "blah" + * into "blah.dll", and dlfcn will transform it into "libblah.so". The + * behaviour can be overriden by setting the name_converter callback in the DSO + * object (using DSO_set_name_converter()). This callback could even utilise + * the DSO_METHOD's converter too if it only wants to override behaviour for + * one or two possible DSO methods. However, the following flag can be set in a + * DSO to prevent *any* native name-translation at all - eg. if the caller has + * prompted the user for a path to a driver library so the filename should be + * interpreted as-is. */ +#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 +/* An extra flag to give if only the extension should be added as + * translation. This is obviously only of importance on Unix and + * other operating systems where the translation also may prefix + * the name with something, like 'lib', and ignored everywhere else. + * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used + * at the same time. */ +#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 + +/* The following flag controls the translation of symbol names to upper + * case. This is currently only being implemented for OpenVMS. + */ +#define DSO_FLAG_UPCASE_SYMBOL 0x10 + +/* This flag loads the library with public symbols. + * Meaning: The exported symbols of this library are public + * to all libraries loaded after this library. + * At the moment only implemented in unix. + */ +#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 + + +typedef void (*DSO_FUNC_TYPE)(void); + +typedef struct dso_st DSO; + +/* The function prototype used for method functions (or caller-provided + * callbacks) that transform filenames. They are passed a DSO structure pointer + * (or NULL if they are to be used independantly of a DSO object) and a + * filename to transform. They should either return NULL (if there is an error + * condition) or a newly allocated string containing the transformed form that + * the caller will need to free with OPENSSL_free() when done. */ +typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); +/* The function prototype used for method functions (or caller-provided + * callbacks) that merge two file specifications. They are passed a + * DSO structure pointer (or NULL if they are to be used independantly of + * a DSO object) and two file specifications to merge. They should + * either return NULL (if there is an error condition) or a newly allocated + * string containing the result of merging that the caller will need + * to free with OPENSSL_free() when done. + * Here, merging means that bits and pieces are taken from each of the + * file specifications and added together in whatever fashion that is + * sensible for the DSO method in question. The only rule that really + * applies is that if the two specification contain pieces of the same + * type, the copy from the first string takes priority. One could see + * it as the first specification is the one given by the user and the + * second being a bunch of defaults to add on if they're missing in the + * first. */ +typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); + +typedef struct dso_meth_st + { + const char *name; + /* Loads a shared library, NB: new DSO_METHODs must ensure that a + * successful load populates the loaded_filename field, and likewise a + * successful unload OPENSSL_frees and NULLs it out. */ + int (*dso_load)(DSO *dso); + /* Unloads a shared library */ + int (*dso_unload)(DSO *dso); + /* Binds a variable */ + void *(*dso_bind_var)(DSO *dso, const char *symname); + /* Binds a function - assumes a return type of DSO_FUNC_TYPE. + * This should be cast to the real function prototype by the + * caller. Platforms that don't have compatible representations + * for different prototypes (this is possible within ANSI C) + * are highly unlikely to have shared libraries at all, let + * alone a DSO_METHOD implemented for them. */ + DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); + +/* I don't think this would actually be used in any circumstances. */ +#if 0 + /* Unbinds a variable */ + int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr); + /* Unbinds a function */ + int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); +#endif + /* The generic (yuck) "ctrl()" function. NB: Negative return + * values (rather than zero) indicate errors. */ + long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_NAME_CONVERTER_FUNC dso_name_converter; + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_MERGER_FUNC dso_merger; + + /* [De]Initialisation handlers. */ + int (*init)(DSO *dso); + int (*finish)(DSO *dso); + } DSO_METHOD; + +/**********************************************************************/ +/* The low-level handle type used to refer to a loaded shared library */ + +struct dso_st + { + DSO_METHOD *meth; + /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS + * doesn't use anything but will need to cache the filename + * for use in the dso_bind handler. All in all, let each + * method control its own destiny. "Handles" and such go in + * a STACK. */ + STACK *meth_data; + int references; + int flags; + /* For use by applications etc ... use this for your bits'n'pieces, + * don't touch meth_data! */ + CRYPTO_EX_DATA ex_data; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_name_converter. NB: This + * should normally set using DSO_set_name_converter(). */ + DSO_NAME_CONVERTER_FUNC name_converter; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_merger. NB: This + * should normally set using DSO_set_merger(). */ + DSO_MERGER_FUNC merger; + /* This is populated with (a copy of) the platform-independant + * filename used for this DSO. */ + char *filename; + /* This is populated with (a copy of) the translated filename by which + * the DSO was actually loaded. It is NULL iff the DSO is not currently + * loaded. NB: This is here because the filename translation process + * may involve a callback being invoked more than once not only to + * convert to a platform-specific form, but also to try different + * filenames in the process of trying to perform a load. As such, this + * variable can be used to indicate (a) whether this DSO structure + * corresponds to a loaded library or not, and (b) the filename with + * which it was actually loaded. */ + char *loaded_filename; + }; + + +DSO * DSO_new(void); +DSO * DSO_new_method(DSO_METHOD *method); +int DSO_free(DSO *dso); +int DSO_flags(DSO *dso); +int DSO_up_ref(DSO *dso); +long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); + +/* This function sets the DSO's name_converter callback. If it is non-NULL, + * then it will be used instead of the associated DSO_METHOD's function. If + * oldcb is non-NULL then it is set to the function pointer value being + * replaced. Return value is non-zero for success. */ +int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, + DSO_NAME_CONVERTER_FUNC *oldcb); +/* These functions can be used to get/set the platform-independant filename + * used for a DSO. NB: set will fail if the DSO is already loaded. */ +const char *DSO_get_filename(DSO *dso); +int DSO_set_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's name_converter callback to translate a + * filename, or if the callback isn't set it will instead use the DSO_METHOD's + * converter. If "filename" is NULL, the "filename" in the DSO itself will be + * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is + * simply duplicated. NB: This function is usually called from within a + * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that + * caller-created DSO_METHODs can do the same thing. A non-NULL return value + * will need to be OPENSSL_free()'d. */ +char *DSO_convert_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's merger callback to merge two file + * specifications, or if the callback isn't set it will instead use the + * DSO_METHOD's merger. A non-NULL return value will need to be + * OPENSSL_free()'d. */ +char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); +/* If the DSO is currently loaded, this returns the filename that it was loaded + * under, otherwise it returns NULL. So it is also useful as a test as to + * whether the DSO is currently loaded. NB: This will not necessarily return + * the same value as DSO_convert_filename(dso, dso->filename), because the + * DSO_METHOD's load function may have tried a variety of filenames (with + * and/or without the aid of the converters) before settling on the one it + * actually loaded. */ +const char *DSO_get_loaded_filename(DSO *dso); + +void DSO_set_default_method(DSO_METHOD *meth); +DSO_METHOD *DSO_get_default_method(void); +DSO_METHOD *DSO_get_method(DSO *dso); +DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); + +/* The all-singing all-dancing load function, you normally pass NULL + * for the first and third parameters. Use DSO_up and DSO_free for + * subsequent reference count handling. Any flags passed in will be set + * in the constructed DSO after its init() function but before the + * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ +DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); + +/* This function binds to a variable inside a shared library. */ +void *DSO_bind_var(DSO *dso, const char *symname); + +/* This function binds to a function inside a shared library. */ +DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); + +/* This method is the default, but will beg, borrow, or steal whatever + * method should be the default on any particular platform (including + * DSO_METH_null() if necessary). */ +DSO_METHOD *DSO_METHOD_openssl(void); + +/* This method is defined for all platforms - if a platform has no + * DSO support then this will be the only method! */ +DSO_METHOD *DSO_METHOD_null(void); + +/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions + * (dlopen, dlclose, dlsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dlfcn(void); + +/* If DSO_DL is defined, the standard dl.h-style functions (shl_load, + * shl_unload, shl_findsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dl(void); + +/* If WIN32 is defined, use DLLs. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_win32(void); + +/* If VMS is defined, use shared images. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_vms(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSO_strings(void); + +/* Error codes for the DSO functions. */ + +/* Function codes. */ +#define DSO_F_DLFCN_BIND_FUNC 100 +#define DSO_F_DLFCN_BIND_VAR 101 +#define DSO_F_DLFCN_LOAD 102 +#define DSO_F_DLFCN_MERGER 130 +#define DSO_F_DLFCN_NAME_CONVERTER 123 +#define DSO_F_DLFCN_UNLOAD 103 +#define DSO_F_DL_BIND_FUNC 104 +#define DSO_F_DL_BIND_VAR 105 +#define DSO_F_DL_LOAD 106 +#define DSO_F_DL_MERGER 131 +#define DSO_F_DL_NAME_CONVERTER 124 +#define DSO_F_DL_UNLOAD 107 +#define DSO_F_DSO_BIND_FUNC 108 +#define DSO_F_DSO_BIND_VAR 109 +#define DSO_F_DSO_CONVERT_FILENAME 126 +#define DSO_F_DSO_CTRL 110 +#define DSO_F_DSO_FREE 111 +#define DSO_F_DSO_GET_FILENAME 127 +#define DSO_F_DSO_GET_LOADED_FILENAME 128 +#define DSO_F_DSO_LOAD 112 +#define DSO_F_DSO_MERGE 132 +#define DSO_F_DSO_NEW_METHOD 113 +#define DSO_F_DSO_SET_FILENAME 129 +#define DSO_F_DSO_SET_NAME_CONVERTER 122 +#define DSO_F_DSO_UP_REF 114 +#define DSO_F_VMS_BIND_SYM 115 +#define DSO_F_VMS_LOAD 116 +#define DSO_F_VMS_MERGER 133 +#define DSO_F_VMS_UNLOAD 117 +#define DSO_F_WIN32_BIND_FUNC 118 +#define DSO_F_WIN32_BIND_VAR 119 +#define DSO_F_WIN32_JOINER 135 +#define DSO_F_WIN32_LOAD 120 +#define DSO_F_WIN32_MERGER 134 +#define DSO_F_WIN32_NAME_CONVERTER 125 +#define DSO_F_WIN32_SPLITTER 136 +#define DSO_F_WIN32_UNLOAD 121 + +/* Reason codes. */ +#define DSO_R_CTRL_FAILED 100 +#define DSO_R_DSO_ALREADY_LOADED 110 +#define DSO_R_EMPTY_FILE_STRUCTURE 113 +#define DSO_R_FAILURE 114 +#define DSO_R_FILENAME_TOO_BIG 101 +#define DSO_R_FINISH_FAILED 102 +#define DSO_R_INCORRECT_FILE_SYNTAX 115 +#define DSO_R_LOAD_FAILED 103 +#define DSO_R_NAME_TRANSLATION_FAILED 109 +#define DSO_R_NO_FILENAME 111 +#define DSO_R_NO_FILE_SPECIFICATION 116 +#define DSO_R_NULL_HANDLE 104 +#define DSO_R_SET_FILENAME_FAILED 112 +#define DSO_R_STACK_ERROR 105 +#define DSO_R_SYM_FAILURE 106 +#define DSO_R_UNLOAD_FAILED 107 +#define DSO_R_UNSUPPORTED 108 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/dtls1.h b/libraries/external/openssl/linux/include/openssl/dtls1.h new file mode 100755 index 0000000..8093a8f --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/dtls1.h @@ -0,0 +1,212 @@ +/* ssl/dtls1.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DTLS1_H +#define HEADER_DTLS1_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DTLS1_VERSION 0x0100 +#define DTLS1_VERSION_MAJOR 0x01 +#define DTLS1_VERSION_MINOR 0x00 + +#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 + +/* lengths of messages */ +#define DTLS1_COOKIE_LENGTH 32 + +#define DTLS1_RT_HEADER_LENGTH 13 + +#define DTLS1_HM_HEADER_LENGTH 12 + +#define DTLS1_HM_BAD_FRAGMENT -2 +#define DTLS1_HM_FRAGMENT_RETRY -3 + +#define DTLS1_CCS_HEADER_LENGTH 3 + +#define DTLS1_AL_HEADER_LENGTH 7 + + +typedef struct dtls1_bitmap_st + { + PQ_64BIT map; + unsigned long length; /* sizeof the bitmap in bits */ + PQ_64BIT max_seq_num; /* max record number seen so far */ + } DTLS1_BITMAP; + +struct hm_header_st + { + unsigned char type; + unsigned long msg_len; + unsigned short seq; + unsigned long frag_off; + unsigned long frag_len; + unsigned int is_ccs; + }; + +struct ccs_header_st + { + unsigned char type; + unsigned short seq; + }; + +struct dtls1_timeout_st + { + /* Number of read timeouts so far */ + unsigned int read_timeouts; + + /* Number of write timeouts so far */ + unsigned int write_timeouts; + + /* Number of alerts received so far */ + unsigned int num_alerts; + }; + +typedef struct record_pqueue_st + { + unsigned short epoch; + pqueue q; + } record_pqueue; + +typedef struct hm_fragment_st + { + struct hm_header_st msg_header; + unsigned char *fragment; + } hm_fragment; + +typedef struct dtls1_state_st + { + unsigned int send_cookie; + unsigned char cookie[DTLS1_COOKIE_LENGTH]; + unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; + unsigned int cookie_len; + + /* + * The current data and handshake epoch. This is initially + * undefined, and starts at zero once the initial handshake is + * completed + */ + unsigned short r_epoch; + unsigned short w_epoch; + + /* records being received in the current epoch */ + DTLS1_BITMAP bitmap; + + /* renegotiation starts a new set of sequence numbers */ + DTLS1_BITMAP next_bitmap; + + /* handshake message numbers */ + unsigned short handshake_write_seq; + unsigned short next_handshake_write_seq; + + unsigned short handshake_read_seq; + + /* Received handshake records (processed and unprocessed) */ + record_pqueue unprocessed_rcds; + record_pqueue processed_rcds; + + /* Buffered handshake messages */ + pqueue buffered_messages; + + /* Buffered (sent) handshake records */ + pqueue sent_messages; + + unsigned int mtu; /* max wire packet size */ + + struct hm_header_st w_msg_hdr; + struct hm_header_st r_msg_hdr; + + struct dtls1_timeout_st timeout; + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; + unsigned int handshake_fragment_len; + + unsigned int retransmitting; + + } DTLS1_STATE; + +typedef struct dtls1_record_data_st + { + unsigned char *packet; + unsigned int packet_length; + SSL3_BUFFER rbuf; + SSL3_RECORD rrec; + } DTLS1_RECORD_DATA; + + +/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ +#define DTLS1_TMO_READ_COUNT 2 +#define DTLS1_TMO_WRITE_COUNT 2 + +#define DTLS1_TMO_ALERT_COUNT 12 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/e_os2.h b/libraries/external/openssl/linux/include/openssl/e_os2.h new file mode 100755 index 0000000..79bfe24 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/e_os2.h @@ -0,0 +1,279 @@ +/* e_os2.h */ +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#ifndef HEADER_E_OS2_H +#define HEADER_E_OS2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + * Detect operating systems. This probably needs completing. + * The result is that at least one OPENSSL_SYS_os macro should be defined. + * However, if none is defined, Unix is assumed. + **/ + +#define OPENSSL_SYS_UNIX + +/* ----------------------- Macintosh, before MacOS X ----------------------- */ +#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MACINTOSH_CLASSIC +#endif + +/* ----------------------- NetWare ----------------------------------------- */ +#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_NETWARE +#endif + +/* ---------------------- Microsoft operating systems ---------------------- */ + +/* Note that MSDOS actually denotes 32-bit environments running on top of + MS-DOS, such as DJGPP one. */ +#if defined(OPENSSL_SYSNAME_MSDOS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MSDOS +#endif + +/* For 32 bit environment, there seems to be the CygWin environment and then + all the others that try to do the same thing Microsoft does... */ +#if defined(OPENSSL_SYSNAME_UWIN) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_UWIN +#else +# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_CYGWIN +# else +# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32 +# endif +# if defined(OPENSSL_SYSNAME_WINNT) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINNT +# endif +# if defined(OPENSSL_SYSNAME_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINCE +# endif +# endif +#endif + +/* Anything that tries to look like Microsoft is "Windows" */ +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_SYS_MSDOS +# define OPENSSL_SYS_MSDOS +# endif +#endif + +/* DLL settings. This part is a bit tough, because it's up to the application + implementor how he or she will link the application, so it requires some + macro to be used. */ +#ifdef OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_OPT_WINDLL +# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that + DLL linkage should be used */ +# define OPENSSL_OPT_WINDLL +# endif +# endif +#endif + +/* -------------------------------- OpenVMS -------------------------------- */ +#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_VMS +# if defined(__DECC) +# define OPENSSL_SYS_VMS_DECC +# elif defined(__DECCXX) +# define OPENSSL_SYS_VMS_DECC +# define OPENSSL_SYS_VMS_DECCXX +# else +# define OPENSSL_SYS_VMS_NODECC +# endif +#endif + +/* --------------------------------- OS/2 ---------------------------------- */ +#if defined(__EMX__) || defined(__OS2__) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_OS2 +#endif + +/* --------------------------------- Unix ---------------------------------- */ +#ifdef OPENSSL_SYS_UNIX +# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) +# define OPENSSL_SYS_LINUX +# endif +# ifdef OPENSSL_SYSNAME_MPE +# define OPENSSL_SYS_MPE +# endif +# ifdef OPENSSL_SYSNAME_SNI +# define OPENSSL_SYS_SNI +# endif +# ifdef OPENSSL_SYSNAME_ULTRASPARC +# define OPENSSL_SYS_ULTRASPARC +# endif +# ifdef OPENSSL_SYSNAME_NEWS4 +# define OPENSSL_SYS_NEWS4 +# endif +# ifdef OPENSSL_SYSNAME_MACOSX +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_SUNOS +# define OPENSSL_SYS_SUNOS +#endif +# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) +# define OPENSSL_SYS_CRAY +# endif +# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) +# define OPENSSL_SYS_AIX +# endif +#endif + +/* --------------------------------- VOS ----------------------------------- */ +#ifdef OPENSSL_SYSNAME_VOS +# define OPENSSL_SYS_VOS +#endif + +/* ------------------------------- VxWorks --------------------------------- */ +#ifdef OPENSSL_SYSNAME_VXWORKS +# define OPENSSL_SYS_VXWORKS +#endif + +/** + * That's it for OS-specific stuff + *****************************************************************************/ + + +/* Specials for I/O an exit */ +#ifdef OPENSSL_SYS_MSDOS +# define OPENSSL_UNISTD_IO +# define OPENSSL_DECLARE_EXIT extern void exit(int); +#else +# define OPENSSL_UNISTD_IO OPENSSL_UNISTD +# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ +#endif + +/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare + certain global symbols that, with some compilers under VMS, have to be + defined and declared explicitely with globaldef and globalref. + Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare + DLL exports and imports for compilers under Win32. These are a little + more complicated to use. Basically, for any library that exports some + global variables, the following code must be present in the header file + that declares them, before OPENSSL_EXTERN is used: + + #ifdef SOME_BUILD_FLAG_MACRO + # undef OPENSSL_EXTERN + # define OPENSSL_EXTERN OPENSSL_EXPORT + #endif + + The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL + have some generally sensible values, and for OPENSSL_EXTERN to have the + value OPENSSL_IMPORT. +*/ + +#if defined(OPENSSL_SYS_VMS_NODECC) +# define OPENSSL_EXPORT globalref +# define OPENSSL_IMPORT globalref +# define OPENSSL_GLOBAL globaldef +#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) +# define OPENSSL_EXPORT extern __declspec(dllexport) +# define OPENSSL_IMPORT extern __declspec(dllimport) +# define OPENSSL_GLOBAL +#else +# define OPENSSL_EXPORT extern +# define OPENSSL_IMPORT extern +# define OPENSSL_GLOBAL +#endif +#define OPENSSL_EXTERN OPENSSL_IMPORT + +/* Macros to allow global variables to be reached through function calls when + required (if a shared library version requvres it, for example. + The way it's done allows definitions like this: + + // in foobar.c + OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; + // in foobar.h + OPENSSL_DECLARE_GLOBAL(int,foobar); + #define foobar OPENSSL_GLOBAL_REF(foobar) +*/ +#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ + extern type _hide_##name; \ + type *_shadow_##name(void) { return &_hide_##name; } \ + static type _hide_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) +# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) +#else +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name +# define OPENSSL_GLOBAL_REF(name) _shadow_##name +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ebcdic.h b/libraries/external/openssl/linux/include/openssl/ebcdic.h new file mode 100755 index 0000000..0941c8b --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ebcdic.h @@ -0,0 +1,19 @@ +/* crypto/ebcdic.h */ + +#ifndef HEADER_EBCDIC_H +#define HEADER_EBCDIC_H + +#include + +/* Avoid name clashes with other applications */ +#define os_toascii _openssl_os_toascii +#define os_toebcdic _openssl_os_toebcdic +#define ebcdic2ascii _openssl_ebcdic2ascii +#define ascii2ebcdic _openssl_ascii2ebcdic + +extern const unsigned char os_toascii[256]; +extern const unsigned char os_toebcdic[256]; +void *ebcdic2ascii(void *dest, const void *srce, size_t count); +void *ascii2ebcdic(void *dest, const void *srce, size_t count); + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ec.h b/libraries/external/openssl/linux/include/openssl/ec.h new file mode 100755 index 0000000..51304f7 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ec.h @@ -0,0 +1,525 @@ +/* crypto/ec/ec.h */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_EC_H +#define HEADER_EC_H + +#include + +#ifdef OPENSSL_NO_EC +#error EC is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#elif defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + + +#ifndef OPENSSL_ECC_MAX_FIELD_BITS +# define OPENSSL_ECC_MAX_FIELD_BITS 661 +#endif + +typedef enum { + /* values as defined in X9.62 (ECDSA) and elsewhere */ + POINT_CONVERSION_COMPRESSED = 2, + POINT_CONVERSION_UNCOMPRESSED = 4, + POINT_CONVERSION_HYBRID = 6 +} point_conversion_form_t; + + +typedef struct ec_method_st EC_METHOD; + +typedef struct ec_group_st + /* + EC_METHOD *meth; + -- field definition + -- curve coefficients + -- optional generator with associated information (order, cofactor) + -- optional extra data (precomputed table for fast computation of multiples of generator) + -- ASN1 stuff + */ + EC_GROUP; + +typedef struct ec_point_st EC_POINT; + + +/* EC_METHODs for curves over GF(p). + * EC_GFp_simple_method provides the basis for the optimized methods. + */ +const EC_METHOD *EC_GFp_simple_method(void); +const EC_METHOD *EC_GFp_mont_method(void); +const EC_METHOD *EC_GFp_nist_method(void); + +/* EC_METHOD for curves over GF(2^m). + */ +const EC_METHOD *EC_GF2m_simple_method(void); + + +EC_GROUP *EC_GROUP_new(const EC_METHOD *); +void EC_GROUP_free(EC_GROUP *); +void EC_GROUP_clear_free(EC_GROUP *); +int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); +EC_GROUP *EC_GROUP_dup(const EC_GROUP *); + +const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); +int EC_METHOD_get_field_type(const EC_METHOD *); + +int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); +int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); +int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); + +void EC_GROUP_set_curve_name(EC_GROUP *, int nid); +int EC_GROUP_get_curve_name(const EC_GROUP *); + +void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); +int EC_GROUP_get_asn1_flag(const EC_GROUP *); + +void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); +size_t EC_GROUP_get_seed_len(const EC_GROUP *); +size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); + +int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); +int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); + +/* returns the number of bits needed to represent a field element */ +int EC_GROUP_get_degree(const EC_GROUP *); + +/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); +/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the + * elliptic curve is not zero, 0 otherwise */ +int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ +int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() + * after choosing an appropriate EC_METHOD */ +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + +/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure + * specified by a curve name (in form of a NID) */ +EC_GROUP *EC_GROUP_new_by_curve_name(int nid); +/* handling of internal curves */ +typedef struct { + int nid; + const char *comment; + } EC_builtin_curve; +/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number + * of all available curves or zero if a error occurred. + * In case r ist not zero nitems EC_builtin_curve structures + * are filled with the data of the first nitems internal groups */ +size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); + + +/* EC_POINT functions */ + +EC_POINT *EC_POINT_new(const EC_GROUP *); +void EC_POINT_free(EC_POINT *); +void EC_POINT_clear_free(EC_POINT *); +int EC_POINT_copy(EC_POINT *, const EC_POINT *); +EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); + +const EC_METHOD *EC_POINT_method_of(const EC_POINT *); + +int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); +int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); +int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); + +/* other interfaces to point2oct/oct2point: */ +BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BIGNUM *, BN_CTX *); +EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, + EC_POINT *, BN_CTX *); +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, + EC_POINT *, BN_CTX *); + +int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); +int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); + +int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + +int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); + + +int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); +int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); + +/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ +int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); +/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ +int EC_GROUP_have_precompute_mult(const EC_GROUP *); + + + +/* ASN1 stuff */ + +/* EC_GROUP_get_basis_type() returns the NID of the basis type + * used to represent the field elements */ +int EC_GROUP_get_basis_type(const EC_GROUP *); +int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); + +#define OPENSSL_EC_NAMED_CURVE 0x001 + +typedef struct ecpk_parameters_st ECPKPARAMETERS; + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); +int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); + +#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) +#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) +#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ + (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) +#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ + (unsigned char *)(x)) + +#ifndef OPENSSL_NO_BIO +int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); +#endif + +/* the EC_KEY stuff */ +typedef struct ec_key_st EC_KEY; + +/* some values for the encoding_flag */ +#define EC_PKEY_NO_PARAMETERS 0x001 +#define EC_PKEY_NO_PUBKEY 0x002 + +EC_KEY *EC_KEY_new(void); +EC_KEY *EC_KEY_new_by_curve_name(int nid); +void EC_KEY_free(EC_KEY *); +EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); +EC_KEY *EC_KEY_dup(const EC_KEY *); + +int EC_KEY_up_ref(EC_KEY *); + +const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); +int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); +const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); +int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); +const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); +int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); +unsigned EC_KEY_get_enc_flags(const EC_KEY *); +void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); +void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); +/* functions to set/get method specific data */ +void *EC_KEY_get_key_method_data(EC_KEY *, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_KEY_insert_key_method_data(EC_KEY *, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +/* wrapper functions for the underlying EC_GROUP object */ +void EC_KEY_set_asn1_flag(EC_KEY *, int); +int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); + +/* EC_KEY_generate_key() creates a ec private (public) key */ +int EC_KEY_generate_key(EC_KEY *); +/* EC_KEY_check_key() */ +int EC_KEY_check_key(const EC_KEY *); + +/* de- and encoding functions for SEC1 ECPrivateKey */ +EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC parameters */ +EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECParameters(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC public key + * (octet string, not DER -- hence 'o2i' and 'i2o') */ +EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); +int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); + +#ifndef OPENSSL_NO_BIO +int ECParameters_print(BIO *bp, const EC_KEY *x); +int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECParameters_print_fp(FILE *fp, const EC_KEY *x); +int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); +#endif + +#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) + +#ifndef __cplusplus +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +# endif +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EC_strings(void); + +/* Error codes for the EC functions. */ + +/* Function codes. */ +#define EC_F_COMPUTE_WNAF 143 +#define EC_F_D2I_ECPARAMETERS 144 +#define EC_F_D2I_ECPKPARAMETERS 145 +#define EC_F_D2I_ECPRIVATEKEY 146 +#define EC_F_ECPARAMETERS_PRINT 147 +#define EC_F_ECPARAMETERS_PRINT_FP 148 +#define EC_F_ECPKPARAMETERS_PRINT 149 +#define EC_F_ECPKPARAMETERS_PRINT_FP 150 +#define EC_F_ECP_NIST_MOD_192 203 +#define EC_F_ECP_NIST_MOD_224 204 +#define EC_F_ECP_NIST_MOD_256 205 +#define EC_F_ECP_NIST_MOD_521 206 +#define EC_F_EC_ASN1_GROUP2CURVE 153 +#define EC_F_EC_ASN1_GROUP2FIELDID 154 +#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 +#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 +#define EC_F_EC_ASN1_PARAMETERS2GROUP 157 +#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 +#define EC_F_EC_EX_DATA_SET_DATA 211 +#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 +#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 +#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 +#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 +#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 +#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 +#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 +#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 +#define EC_F_EC_GFP_MONT_FIELD_DECODE 133 +#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 +#define EC_F_EC_GFP_MONT_FIELD_MUL 131 +#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 +#define EC_F_EC_GFP_MONT_FIELD_SQR 132 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 +#define EC_F_EC_GFP_NIST_FIELD_MUL 200 +#define EC_F_EC_GFP_NIST_FIELD_SQR 201 +#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 +#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 +#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 +#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 +#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 +#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 +#define EC_F_EC_GROUP_CHECK 170 +#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 +#define EC_F_EC_GROUP_COPY 106 +#define EC_F_EC_GROUP_GET0_GENERATOR 139 +#define EC_F_EC_GROUP_GET_COFACTOR 140 +#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 +#define EC_F_EC_GROUP_GET_CURVE_GFP 130 +#define EC_F_EC_GROUP_GET_DEGREE 173 +#define EC_F_EC_GROUP_GET_ORDER 141 +#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 +#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 +#define EC_F_EC_GROUP_NEW 108 +#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 +#define EC_F_EC_GROUP_NEW_FROM_DATA 175 +#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 +#define EC_F_EC_GROUP_SET_CURVE_GF2M 176 +#define EC_F_EC_GROUP_SET_CURVE_GFP 109 +#define EC_F_EC_GROUP_SET_EXTRA_DATA 110 +#define EC_F_EC_GROUP_SET_GENERATOR 111 +#define EC_F_EC_KEY_CHECK_KEY 177 +#define EC_F_EC_KEY_COPY 178 +#define EC_F_EC_KEY_GENERATE_KEY 179 +#define EC_F_EC_KEY_NEW 182 +#define EC_F_EC_KEY_PRINT 180 +#define EC_F_EC_KEY_PRINT_FP 181 +#define EC_F_EC_POINTS_MAKE_AFFINE 136 +#define EC_F_EC_POINTS_MUL 138 +#define EC_F_EC_POINT_ADD 112 +#define EC_F_EC_POINT_CMP 113 +#define EC_F_EC_POINT_COPY 114 +#define EC_F_EC_POINT_DBL 115 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 +#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 +#define EC_F_EC_POINT_INVERT 210 +#define EC_F_EC_POINT_IS_AT_INFINITY 118 +#define EC_F_EC_POINT_IS_ON_CURVE 119 +#define EC_F_EC_POINT_MAKE_AFFINE 120 +#define EC_F_EC_POINT_MUL 184 +#define EC_F_EC_POINT_NEW 121 +#define EC_F_EC_POINT_OCT2POINT 122 +#define EC_F_EC_POINT_POINT2OCT 123 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 +#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 +#define EC_F_EC_POINT_SET_TO_INFINITY 127 +#define EC_F_EC_PRE_COMP_DUP 207 +#define EC_F_EC_WNAF_MUL 187 +#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 +#define EC_F_I2D_ECPARAMETERS 190 +#define EC_F_I2D_ECPKPARAMETERS 191 +#define EC_F_I2D_ECPRIVATEKEY 192 +#define EC_F_I2O_ECPUBLICKEY 151 +#define EC_F_O2I_ECPUBLICKEY 152 + +/* Reason codes. */ +#define EC_R_ASN1_ERROR 115 +#define EC_R_ASN1_UNKNOWN_FIELD 116 +#define EC_R_BUFFER_TOO_SMALL 100 +#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 +#define EC_R_DISCRIMINANT_IS_ZERO 118 +#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +#define EC_R_FIELD_TOO_LARGE 138 +#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +#define EC_R_INCOMPATIBLE_OBJECTS 101 +#define EC_R_INVALID_ARGUMENT 112 +#define EC_R_INVALID_COMPRESSED_POINT 110 +#define EC_R_INVALID_COMPRESSION_BIT 109 +#define EC_R_INVALID_ENCODING 102 +#define EC_R_INVALID_FIELD 103 +#define EC_R_INVALID_FORM 104 +#define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_PENTANOMIAL_BASIS 132 +#define EC_R_INVALID_PRIVATE_KEY 123 +#define EC_R_INVALID_TRINOMIAL_BASIS 137 +#define EC_R_MISSING_PARAMETERS 124 +#define EC_R_MISSING_PRIVATE_KEY 125 +#define EC_R_NOT_A_NIST_PRIME 135 +#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 +#define EC_R_NOT_IMPLEMENTED 126 +#define EC_R_NOT_INITIALIZED 111 +#define EC_R_NO_FIELD_MOD 133 +#define EC_R_PASSED_NULL_PARAMETER 134 +#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 +#define EC_R_POINT_AT_INFINITY 106 +#define EC_R_POINT_IS_NOT_ON_CURVE 107 +#define EC_R_SLOT_FULL 108 +#define EC_R_UNDEFINED_GENERATOR 113 +#define EC_R_UNDEFINED_ORDER 128 +#define EC_R_UNKNOWN_GROUP 129 +#define EC_R_UNKNOWN_ORDER 114 +#define EC_R_UNSUPPORTED_FIELD 131 +#define EC_R_WRONG_ORDER 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ecdh.h b/libraries/external/openssl/linux/include/openssl/ecdh.h new file mode 100755 index 0000000..c2c00b8 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ecdh.h @@ -0,0 +1,123 @@ +/* crypto/ecdh/ecdh.h */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDH_H +#define HEADER_ECDH_H + +#include + +#ifdef OPENSSL_NO_ECDH +#error ECDH is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +const ECDH_METHOD *ECDH_OpenSSL(void); + +void ECDH_set_default_method(const ECDH_METHOD *); +const ECDH_METHOD *ECDH_get_default_method(void); +int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); + +int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); + +int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDH_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDH_strings(void); + +/* Error codes for the ECDH functions. */ + +/* Function codes. */ +#define ECDH_F_ECDH_COMPUTE_KEY 100 +#define ECDH_F_ECDH_DATA_NEW_METHOD 101 + +/* Reason codes. */ +#define ECDH_R_KDF_FAILED 102 +#define ECDH_R_NO_PRIVATE_VALUE 100 +#define ECDH_R_POINT_ARITHMETIC_FAILURE 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ecdsa.h b/libraries/external/openssl/linux/include/openssl/ecdsa.h new file mode 100755 index 0000000..294e2ba --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ecdsa.h @@ -0,0 +1,271 @@ +/* crypto/ecdsa/ecdsa.h */ +/** + * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions + * \author Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDSA_H +#define HEADER_ECDSA_H + +#include + +#ifdef OPENSSL_NO_ECDSA +#error ECDSA is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ECDSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } ECDSA_SIG; + +/** ECDSA_SIG *ECDSA_SIG_new(void) + * allocates and initialize a ECDSA_SIG structure + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_SIG_new(void); + +/** ECDSA_SIG_free + * frees a ECDSA_SIG structure + * \param a pointer to the ECDSA_SIG structure + */ +void ECDSA_SIG_free(ECDSA_SIG *a); + +/** i2d_ECDSA_SIG + * DER encode content of ECDSA_SIG object (note: this function modifies *pp + * (*pp += length of the DER encoded signature)). + * \param a pointer to the ECDSA_SIG object + * \param pp pointer to a unsigned char pointer for the output or NULL + * \return the length of the DER encoded ECDSA_SIG object or 0 + */ +int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp); + +/** d2i_ECDSA_SIG + * decodes a DER encoded ECDSA signature (note: this function changes *pp + * (*pp += len)). + * \param v pointer to ECDSA_SIG pointer (may be NULL) + * \param pp buffer with the DER encoded signature + * \param len bufferlength + * \return pointer to the decoded ECDSA_SIG structure (or NULL) + */ +ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len); + +/** ECDSA_do_sign + * computes the ECDSA signature of the given hash value using + * the supplied private key and returns the created signature. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); + +/** ECDSA_do_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, + const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_do_verify + * verifies that the supplied signature is a valid ECDSA + * signature of the supplied hash value using the supplied public key. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param sig pointer to the ECDSA_SIG structure + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY* eckey); + +const ECDSA_METHOD *ECDSA_OpenSSL(void); + +/** ECDSA_set_default_method + * sets the default ECDSA method + * \param meth the new default ECDSA_METHOD + */ +void ECDSA_set_default_method(const ECDSA_METHOD *meth); + +/** ECDSA_get_default_method + * returns the default ECDSA method + * \return pointer to ECDSA_METHOD structure containing the default method + */ +const ECDSA_METHOD *ECDSA_get_default_method(void); + +/** ECDSA_set_method + * sets method to be used for the ECDSA operations + * \param eckey pointer to the EC_KEY object + * \param meth pointer to the new method + * \return 1 on success and 0 otherwise + */ +int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); + +/** ECDSA_size + * returns the maximum length of the DER encoded signature + * \param eckey pointer to a EC_KEY object + * \return numbers of bytes required for the DER encoded signature + */ +int ECDSA_size(const EC_KEY *eckey); + +/** ECDSA_sign_setup + * precompute parts of the signing operation. + * \param eckey pointer to the EC_KEY object containing a private EC key + * \param ctx pointer to a BN_CTX object (may be NULL) + * \param kinv pointer to a BIGNUM pointer for the inverse of k + * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, + BIGNUM **rp); + +/** ECDSA_sign + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); + + +/** ECDSA_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_verify + * verifies that the given signature is valid ECDSA signature + * of the supplied hash value using the specified public key. + * \param type this parameter is ignored + * \param dgst pointer to the hash value + * \param dgstlen length of the hash value + * \param sig pointer to the DER encoded signature + * \param siglen length of the DER encoded signature + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int siglen, EC_KEY *eckey); + +/* the standard ex_data functions */ +int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDSA_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDSA_strings(void); + +/* Error codes for the ECDSA functions. */ + +/* Function codes. */ +#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 +#define ECDSA_F_ECDSA_DO_SIGN 101 +#define ECDSA_F_ECDSA_DO_VERIFY 102 +#define ECDSA_F_ECDSA_SIGN_SETUP 103 + +/* Reason codes. */ +#define ECDSA_R_BAD_SIGNATURE 100 +#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101 +#define ECDSA_R_ERR_EC_LIB 102 +#define ECDSA_R_MISSING_PARAMETERS 103 +#define ECDSA_R_NEED_NEW_SETUP_VALUES 106 +#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 +#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/engine.h b/libraries/external/openssl/linux/include/openssl/engine.h new file mode 100755 index 0000000..4fd0f09 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/engine.h @@ -0,0 +1,785 @@ +/* openssl/engine.h */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_ENGINE_H +#define HEADER_ENGINE_H + +#include + +#ifdef OPENSSL_NO_ENGINE +#error ENGINE is disabled. +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#ifndef OPENSSL_NO_ECDH +#include +#endif +#ifndef OPENSSL_NO_ECDSA +#include +#endif +#include +#include +#include +#include +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These flags are used to control combinations of algorithm (methods) + * by bitwise "OR"ing. */ +#define ENGINE_METHOD_RSA (unsigned int)0x0001 +#define ENGINE_METHOD_DSA (unsigned int)0x0002 +#define ENGINE_METHOD_DH (unsigned int)0x0004 +#define ENGINE_METHOD_RAND (unsigned int)0x0008 +#define ENGINE_METHOD_ECDH (unsigned int)0x0010 +#define ENGINE_METHOD_ECDSA (unsigned int)0x0020 +#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 +#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 +#define ENGINE_METHOD_STORE (unsigned int)0x0100 +/* Obvious all-or-nothing cases. */ +#define ENGINE_METHOD_ALL (unsigned int)0xFFFF +#define ENGINE_METHOD_NONE (unsigned int)0x0000 + +/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used + * internally to control registration of ENGINE implementations, and can be set + * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to + * initialise registered ENGINEs if they are not already initialised. */ +#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 + +/* ENGINE flags that can be set by ENGINE_set_flags(). */ +/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */ + +/* This flag is for ENGINEs that wish to handle the various 'CMD'-related + * control commands on their own. Without this flag, ENGINE_ctrl() handles these + * control commands on behalf of the ENGINE using their "cmd_defns" data. */ +#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 + +/* This flag is for ENGINEs who return new duplicate structures when found via + * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl() + * commands are called in sequence as part of some stateful process like + * key-generation setup and execution), it can set this flag - then each attempt + * to obtain the ENGINE will result in it being copied into a new structure. + * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments + * the existing ENGINE's structural reference count. */ +#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 + +/* ENGINEs can support their own command types, and these flags are used in + * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each + * command expects. Currently only numeric and string input is supported. If a + * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options, + * then it is regarded as an "internal" control command - and not for use in + * config setting situations. As such, they're not available to the + * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to + * this list of 'command types' should be reflected carefully in + * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */ + +/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 +/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to + * ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 +/* Indicates that the control command takes *no* input. Ie. the control command + * is unparameterised. */ +#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 +/* Indicates that the control command is internal. This control command won't + * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() + * function. */ +#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 + +/* NB: These 3 control commands are deprecated and should not be used. ENGINEs + * relying on these commands should compile conditional support for + * compatibility (eg. if these symbols are defined) but should also migrate the + * same functionality to their own ENGINE-specific control functions that can be + * "discovered" by calling applications. The fact these control commands + * wouldn't be "executable" (ie. usable by text-based config) doesn't change the + * fact that application code can find and use them without requiring per-ENGINE + * hacking. */ + +/* These flags are used to tell the ctrl function what should be done. + * All command numbers are shared between all engines, even if some don't + * make sense to some engines. In such a case, they do nothing but return + * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ +#define ENGINE_CTRL_SET_LOGSTREAM 1 +#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 +#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any + handles/connections etc. */ +#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ +#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used + when calling the password + callback and the user + interface */ +#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given + a string that represents a + file name or so */ +#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given + section in the already loaded + configuration */ + +/* These control commands allow an application to deal with an arbitrary engine + * in a dynamic way. Warn: Negative return values indicate errors FOR THESE + * COMMANDS because zero is used to indicate 'end-of-list'. Other commands, + * including ENGINE-specific command types, return zero for an error. + * + * An ENGINE can choose to implement these ctrl functions, and can internally + * manage things however it chooses - it does so by setting the + * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the + * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns + * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl() + * handler need only implement its own commands - the above "meta" commands will + * be taken care of. */ + +/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then + * all the remaining control commands will return failure, so it is worth + * checking this first if the caller is trying to "discover" the engine's + * capabilities and doesn't want errors generated unnecessarily. */ +#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 +/* Returns a positive command number for the first command supported by the + * engine. Returns zero if no ctrl commands are supported. */ +#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 +/* The 'long' argument specifies a command implemented by the engine, and the + * return value is the next command supported, or zero if there are no more. */ +#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 +/* The 'void*' argument is a command name (cast from 'const char *'), and the + * return value is the command that corresponds to it. */ +#define ENGINE_CTRL_GET_CMD_FROM_NAME 13 +/* The next two allow a command to be converted into its corresponding string + * form. In each case, the 'long' argument supplies the command. In the NAME_LEN + * case, the return value is the length of the command name (not counting a + * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer + * large enough, and it will be populated with the name of the command (WITH a + * trailing EOL). */ +#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 +#define ENGINE_CTRL_GET_NAME_FROM_CMD 15 +/* The next two are similar but give a "short description" of a command. */ +#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 +#define ENGINE_CTRL_GET_DESC_FROM_CMD 17 +/* With this command, the return value is the OR'd combination of + * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given + * engine-specific ctrl command expects. */ +#define ENGINE_CTRL_GET_CMD_FLAGS 18 + +/* ENGINE implementations should start the numbering of their own control + * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ +#define ENGINE_CMD_BASE 200 + +/* NB: These 2 nCipher "chil" control commands are deprecated, and their + * functionality is now available through ENGINE-specific control commands + * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 + * commands should be migrated to the more general command handling before these + * are removed. */ + +/* Flags specific to the nCipher "chil" engine */ +#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 + /* Depending on the value of the (long)i argument, this sets or + * unsets the SimpleForkCheck flag in the CHIL API to enable or + * disable checking and workarounds for applications that fork(). + */ +#define ENGINE_CTRL_CHIL_NO_LOCKING 101 + /* This prevents the initialisation function from providing mutex + * callbacks to the nCipher library. */ + +/* If an ENGINE supports its own specific control commands and wishes the + * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its + * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries + * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that + * supports the stated commands (ie. the "cmd_num" entries as described by the + * array). NB: The array must be ordered in increasing order of cmd_num. + * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set + * to zero and/or cmd_name set to NULL. */ +typedef struct ENGINE_CMD_DEFN_st + { + unsigned int cmd_num; /* The command number */ + const char *cmd_name; /* The command name itself */ + const char *cmd_desc; /* A short description of the command */ + unsigned int cmd_flags; /* The input the command expects */ + } ENGINE_CMD_DEFN; + +/* Generic function pointer */ +typedef int (*ENGINE_GEN_FUNC_PTR)(void); +/* Generic function pointer taking no arguments */ +typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); +/* Generic load_key function pointer */ +typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, + UI_METHOD *ui_method, void *callback_data); +/* These callback types are for an ENGINE's handler for cipher and digest logic. + * These handlers have these prototypes; + * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); + * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); + * Looking at how to implement these handlers in the case of cipher support, if + * the framework wants the EVP_CIPHER for 'nid', it will call; + * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) + * If the framework wants a list of supported 'nid's, it will call; + * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) + */ +/* Returns to a pointer to the array of supported cipher 'nid's. If the second + * parameter is non-NULL it is set to the size of the returned array. */ +typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); +typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); + +/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE + * structures where the pointers have a "structural reference". This means that + * their reference is to allowed access to the structure but it does not imply + * that the structure is functional. To simply increment or decrement the + * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not + * required when iterating using ENGINE_get_next as it will automatically + * decrement the structural reference count of the "current" ENGINE and + * increment the structural reference count of the ENGINE it returns (unless it + * is NULL). */ + +/* Get the first/last "ENGINE" type available. */ +ENGINE *ENGINE_get_first(void); +ENGINE *ENGINE_get_last(void); +/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ +ENGINE *ENGINE_get_next(ENGINE *e); +ENGINE *ENGINE_get_prev(ENGINE *e); +/* Add another "ENGINE" type into the array. */ +int ENGINE_add(ENGINE *e); +/* Remove an existing "ENGINE" type from the array. */ +int ENGINE_remove(ENGINE *e); +/* Retrieve an engine from the list by its unique "id" value. */ +ENGINE *ENGINE_by_id(const char *id); +/* Add all the built-in engines. */ +void ENGINE_load_openssl(void); +void ENGINE_load_dynamic(void); +#ifndef OPENSSL_NO_STATIC_ENGINE +void ENGINE_load_4758cca(void); +void ENGINE_load_aep(void); +void ENGINE_load_atalla(void); +void ENGINE_load_chil(void); +void ENGINE_load_cswift(void); +#ifndef OPENSSL_NO_GMP +void ENGINE_load_gmp(void); +#endif +void ENGINE_load_nuron(void); +void ENGINE_load_sureware(void); +void ENGINE_load_ubsec(void); +#endif +void ENGINE_load_cryptodev(void); +void ENGINE_load_padlock(void); +void ENGINE_load_builtin_engines(void); + +/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation + * "registry" handling. */ +unsigned int ENGINE_get_table_flags(void); +void ENGINE_set_table_flags(unsigned int flags); + +/* Manage registration of ENGINEs per "table". For each type, there are 3 + * functions; + * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) + * ENGINE_unregister_***(e) - unregister the implementation from 'e' + * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list + * Cleanup is automatically registered from each table when required, so + * ENGINE_cleanup() will reverse any "register" operations. */ + +int ENGINE_register_RSA(ENGINE *e); +void ENGINE_unregister_RSA(ENGINE *e); +void ENGINE_register_all_RSA(void); + +int ENGINE_register_DSA(ENGINE *e); +void ENGINE_unregister_DSA(ENGINE *e); +void ENGINE_register_all_DSA(void); + +int ENGINE_register_ECDH(ENGINE *e); +void ENGINE_unregister_ECDH(ENGINE *e); +void ENGINE_register_all_ECDH(void); + +int ENGINE_register_ECDSA(ENGINE *e); +void ENGINE_unregister_ECDSA(ENGINE *e); +void ENGINE_register_all_ECDSA(void); + +int ENGINE_register_DH(ENGINE *e); +void ENGINE_unregister_DH(ENGINE *e); +void ENGINE_register_all_DH(void); + +int ENGINE_register_RAND(ENGINE *e); +void ENGINE_unregister_RAND(ENGINE *e); +void ENGINE_register_all_RAND(void); + +int ENGINE_register_STORE(ENGINE *e); +void ENGINE_unregister_STORE(ENGINE *e); +void ENGINE_register_all_STORE(void); + +int ENGINE_register_ciphers(ENGINE *e); +void ENGINE_unregister_ciphers(ENGINE *e); +void ENGINE_register_all_ciphers(void); + +int ENGINE_register_digests(ENGINE *e); +void ENGINE_unregister_digests(ENGINE *e); +void ENGINE_register_all_digests(void); + +/* These functions register all support from the above categories. Note, use of + * these functions can result in static linkage of code your application may not + * need. If you only need a subset of functionality, consider using more + * selective initialisation. */ +int ENGINE_register_complete(ENGINE *e); +int ENGINE_register_all_complete(void); + +/* Send parametrised control commands to the engine. The possibilities to send + * down an integer, a pointer to data or a function pointer are provided. Any of + * the parameters may or may not be NULL, depending on the command number. In + * actuality, this function only requires a structural (rather than functional) + * reference to an engine, but many control commands may require the engine be + * functional. The caller should be aware of trying commands that require an + * operational ENGINE, and only use functional references in such situations. */ +int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); + +/* This function tests if an ENGINE-specific command is usable as a "setting". + * Eg. in an application's config file that gets processed through + * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to + * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */ +int ENGINE_cmd_is_executable(ENGINE *e, int cmd); + +/* This function works like ENGINE_ctrl() with the exception of taking a + * command name instead of a command number, and can handle optional commands. + * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to + * use the cmd_name and cmd_optional. */ +int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, + long i, void *p, void (*f)(void), int cmd_optional); + +/* This function passes a command-name and argument to an ENGINE. The cmd_name + * is converted to a command number and the control command is called using + * 'arg' as an argument (unless the ENGINE doesn't support such a command, in + * which case no control command is called). The command is checked for input + * flags, and if necessary the argument will be converted to a numeric value. If + * cmd_optional is non-zero, then if the ENGINE doesn't support the given + * cmd_name the return value will be success anyway. This function is intended + * for applications to use so that users (or config files) can supply + * engine-specific config data to the ENGINE at run-time to control behaviour of + * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl() + * functions that return data, deal with binary data, or that are otherwise + * supposed to be used directly through ENGINE_ctrl() in application code. Any + * "return" data from an ENGINE_ctrl() operation in this function will be lost - + * the return value is interpreted as failure if the return value is zero, + * success otherwise, and this function returns a boolean value as a result. In + * other words, vendors of 'ENGINE'-enabled devices should write ENGINE + * implementations with parameterisations that work in this scheme, so that + * compliant ENGINE-based applications can work consistently with the same + * configuration for the same ENGINE-enabled devices, across applications. */ +int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, + int cmd_optional); + +/* These functions are useful for manufacturing new ENGINE structures. They + * don't address reference counting at all - one uses them to populate an ENGINE + * structure with personalised implementations of things prior to using it + * directly or adding it to the builtin ENGINE list in OpenSSL. These are also + * here so that the ENGINE structure doesn't have to be exposed and break binary + * compatibility! */ +ENGINE *ENGINE_new(void); +int ENGINE_free(ENGINE *e); +int ENGINE_up_ref(ENGINE *e); +int ENGINE_set_id(ENGINE *e, const char *id); +int ENGINE_set_name(ENGINE *e, const char *name); +int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); +int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); +int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); +int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); +int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); +int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); +int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); +int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); +int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); +int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); +int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); +int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); +int ENGINE_set_flags(ENGINE *e, int flags); +int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); +/* These functions allow control over any per-structure ENGINE data. */ +int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); +void *ENGINE_get_ex_data(const ENGINE *e, int idx); + +/* This function cleans up anything that needs it. Eg. the ENGINE_add() function + * automatically ensures the list cleanup function is registered to be called + * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure + * ENGINE_cleanup() will clean up after them. */ +void ENGINE_cleanup(void); + +/* These return values from within the ENGINE structure. These can be useful + * with functional references as well as structural references - it depends + * which you obtained. Using the result for functional purposes if you only + * obtained a structural reference may be problematic! */ +const char *ENGINE_get_id(const ENGINE *e); +const char *ENGINE_get_name(const ENGINE *e); +const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); +const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); +const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); +const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); +const DH_METHOD *ENGINE_get_DH(const ENGINE *e); +const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); +const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); +ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); +ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); +const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); +const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); +const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); +int ENGINE_get_flags(const ENGINE *e); + +/* FUNCTIONAL functions. These functions deal with ENGINE structures + * that have (or will) be initialised for use. Broadly speaking, the + * structural functions are useful for iterating the list of available + * engine types, creating new engine types, and other "list" operations. + * These functions actually deal with ENGINEs that are to be used. As + * such these functions can fail (if applicable) when particular + * engines are unavailable - eg. if a hardware accelerator is not + * attached or not functioning correctly. Each ENGINE has 2 reference + * counts; structural and functional. Every time a functional reference + * is obtained or released, a corresponding structural reference is + * automatically obtained or released too. */ + +/* Initialise a engine type for use (or up its reference count if it's + * already in use). This will fail if the engine is not currently + * operational and cannot initialise. */ +int ENGINE_init(ENGINE *e); +/* Free a functional reference to a engine type. This does not require + * a corresponding call to ENGINE_free as it also releases a structural + * reference. */ +int ENGINE_finish(ENGINE *e); + +/* The following functions handle keys that are stored in some secondary + * location, handled by the engine. The storage may be on a card or + * whatever. */ +EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); + +/* This returns a pointer for the current ENGINE structure that + * is (by default) performing any RSA operations. The value returned + * is an incremented reference, so it should be free'd (ENGINE_finish) + * before it is discarded. */ +ENGINE *ENGINE_get_default_RSA(void); +/* Same for the other "methods" */ +ENGINE *ENGINE_get_default_DSA(void); +ENGINE *ENGINE_get_default_ECDH(void); +ENGINE *ENGINE_get_default_ECDSA(void); +ENGINE *ENGINE_get_default_DH(void); +ENGINE *ENGINE_get_default_RAND(void); +/* These functions can be used to get a functional reference to perform + * ciphering or digesting corresponding to "nid". */ +ENGINE *ENGINE_get_cipher_engine(int nid); +ENGINE *ENGINE_get_digest_engine(int nid); + +/* This sets a new default ENGINE structure for performing RSA + * operations. If the result is non-zero (success) then the ENGINE + * structure will have had its reference count up'd so the caller + * should still free their own reference 'e'. */ +int ENGINE_set_default_RSA(ENGINE *e); +int ENGINE_set_default_string(ENGINE *e, const char *def_list); +/* Same for the other "methods" */ +int ENGINE_set_default_DSA(ENGINE *e); +int ENGINE_set_default_ECDH(ENGINE *e); +int ENGINE_set_default_ECDSA(ENGINE *e); +int ENGINE_set_default_DH(ENGINE *e); +int ENGINE_set_default_RAND(ENGINE *e); +int ENGINE_set_default_ciphers(ENGINE *e); +int ENGINE_set_default_digests(ENGINE *e); + +/* The combination "set" - the flags are bitwise "OR"d from the + * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" + * function, this function can result in unnecessary static linkage. If your + * application requires only specific functionality, consider using more + * selective functions. */ +int ENGINE_set_default(ENGINE *e, unsigned int flags); + +void ENGINE_add_conf_module(void); + +/* Deprecated functions ... */ +/* int ENGINE_clear_defaults(void); */ + +/**************************/ +/* DYNAMIC ENGINE SUPPORT */ +/**************************/ + +/* Binary/behaviour compatibility levels */ +#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000 +/* Binary versions older than this are too old for us (whether we're a loader or + * a loadee) */ +#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000 + +/* When compiling an ENGINE entirely as an external shared library, loadable by + * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure + * type provides the calling application's (or library's) error functionality + * and memory management function pointers to the loaded library. These should + * be used/set in the loaded library code so that the loading application's + * 'state' will be used/changed in all operations. The 'static_state' pointer + * allows the loaded library to know if it shares the same static data as the + * calling application (or library), and thus whether these callbacks need to be + * set or not. */ +typedef void *(*dyn_MEM_malloc_cb)(size_t); +typedef void *(*dyn_MEM_realloc_cb)(void *, size_t); +typedef void (*dyn_MEM_free_cb)(void *); +typedef struct st_dynamic_MEM_fns { + dyn_MEM_malloc_cb malloc_cb; + dyn_MEM_realloc_cb realloc_cb; + dyn_MEM_free_cb free_cb; + } dynamic_MEM_fns; +/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use + * these types so we (and any other dependant code) can simplify a bit?? */ +typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); +typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); +typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( + const char *,int); +typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, + const char *,int); +typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, + const char *,int); +typedef struct st_dynamic_LOCK_fns { + dyn_lock_locking_cb lock_locking_cb; + dyn_lock_add_lock_cb lock_add_lock_cb; + dyn_dynlock_create_cb dynlock_create_cb; + dyn_dynlock_lock_cb dynlock_lock_cb; + dyn_dynlock_destroy_cb dynlock_destroy_cb; + } dynamic_LOCK_fns; +/* The top-level structure */ +typedef struct st_dynamic_fns { + void *static_state; + const ERR_FNS *err_fns; + const CRYPTO_EX_DATA_IMPL *ex_data_fns; + dynamic_MEM_fns mem_fns; + dynamic_LOCK_fns lock_fns; + } dynamic_fns; + +/* The version checking function should be of this prototype. NB: The + * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. + * If this function returns zero, it indicates a (potential) version + * incompatibility and the loaded library doesn't believe it can proceed. + * Otherwise, the returned value is the (latest) version supported by the + * loading library. The loader may still decide that the loaded code's version + * is unsatisfactory and could veto the load. The function is expected to + * be implemented with the symbol name "v_check", and a default implementation + * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ +typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); +#define IMPLEMENT_DYNAMIC_CHECK_FN() \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ + if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ + return 0; } + +/* This function is passed the ENGINE structure to initialise with its own + * function and command settings. It should not adjust the structural or + * functional reference counts. If this function returns zero, (a) the load will + * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the + * structure, and (c) the shared library will be unloaded. So implementations + * should do their own internal cleanup in failure circumstances otherwise they + * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that + * the loader is looking for. If this is NULL, the shared library can choose to + * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared + * library must initialise only an ENGINE matching the passed 'id'. The function + * is expected to be implemented with the symbol name "bind_engine". A standard + * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where + * the parameter 'fn' is a callback function that populates the ENGINE structure + * and returns an int value (zero for failure). 'fn' should have prototype; + * [static] int fn(ENGINE *e, const char *id); */ +typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, + const dynamic_fns *fns); +#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ + if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ + if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ + fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \ + return 0; \ + CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \ + CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \ + CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \ + CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \ + CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \ + if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \ + return 0; \ + if(!ERR_set_implementation(fns->err_fns)) return 0; \ + skip_cbs: \ + if(!fn(e,id)) return 0; \ + return 1; } + +/* If the loading application (or library) and the loaded ENGINE library share + * the same static data (eg. they're both dynamically linked to the same + * libcrypto.so) we need a way to avoid trying to set system callbacks - this + * would fail, and for the same reason that it's unnecessary to try. If the + * loaded ENGINE has (or gets from through the loader) its own copy of the + * libcrypto static data, we will need to set the callbacks. The easiest way to + * detect this is to have a function that returns a pointer to some static data + * and let the loading application and loaded ENGINE compare their respective + * values. */ +void *ENGINE_get_static_state(void); + +#if defined(__OpenBSD__) || defined(__FreeBSD__) +void ENGINE_setup_bsd_cryptodev(void); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ENGINE_strings(void); + +/* Error codes for the ENGINE functions. */ + +/* Function codes. */ +#define ENGINE_F_DYNAMIC_CTRL 180 +#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 +#define ENGINE_F_DYNAMIC_LOAD 182 +#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 +#define ENGINE_F_ENGINE_ADD 105 +#define ENGINE_F_ENGINE_BY_ID 106 +#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 +#define ENGINE_F_ENGINE_CTRL 142 +#define ENGINE_F_ENGINE_CTRL_CMD 178 +#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 +#define ENGINE_F_ENGINE_FINISH 107 +#define ENGINE_F_ENGINE_FREE_UTIL 108 +#define ENGINE_F_ENGINE_GET_CIPHER 185 +#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 +#define ENGINE_F_ENGINE_GET_DIGEST 186 +#define ENGINE_F_ENGINE_GET_NEXT 115 +#define ENGINE_F_ENGINE_GET_PREV 116 +#define ENGINE_F_ENGINE_INIT 119 +#define ENGINE_F_ENGINE_LIST_ADD 120 +#define ENGINE_F_ENGINE_LIST_REMOVE 121 +#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 +#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 +#define ENGINE_F_ENGINE_NEW 122 +#define ENGINE_F_ENGINE_REMOVE 123 +#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 +#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 +#define ENGINE_F_ENGINE_SET_ID 129 +#define ENGINE_F_ENGINE_SET_NAME 130 +#define ENGINE_F_ENGINE_TABLE_REGISTER 184 +#define ENGINE_F_ENGINE_UNLOAD_KEY 152 +#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 +#define ENGINE_F_ENGINE_UP_REF 190 +#define ENGINE_F_INT_CTRL_HELPER 172 +#define ENGINE_F_INT_ENGINE_CONFIGURE 188 +#define ENGINE_F_INT_ENGINE_MODULE_INIT 187 +#define ENGINE_F_LOG_MESSAGE 141 + +/* Reason codes. */ +#define ENGINE_R_ALREADY_LOADED 100 +#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 +#define ENGINE_R_CMD_NOT_EXECUTABLE 134 +#define ENGINE_R_COMMAND_TAKES_INPUT 135 +#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 +#define ENGINE_R_CONFLICTING_ENGINE_ID 103 +#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 +#define ENGINE_R_DH_NOT_IMPLEMENTED 139 +#define ENGINE_R_DSA_NOT_IMPLEMENTED 140 +#define ENGINE_R_DSO_FAILURE 104 +#define ENGINE_R_DSO_NOT_FOUND 132 +#define ENGINE_R_ENGINES_SECTION_ERROR 148 +#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 +#define ENGINE_R_ENGINE_SECTION_ERROR 149 +#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 +#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 +#define ENGINE_R_FINISH_FAILED 106 +#define ENGINE_R_GET_HANDLE_FAILED 107 +#define ENGINE_R_ID_OR_NAME_MISSING 108 +#define ENGINE_R_INIT_FAILED 109 +#define ENGINE_R_INTERNAL_LIST_ERROR 110 +#define ENGINE_R_INVALID_ARGUMENT 143 +#define ENGINE_R_INVALID_CMD_NAME 137 +#define ENGINE_R_INVALID_CMD_NUMBER 138 +#define ENGINE_R_INVALID_INIT_VALUE 151 +#define ENGINE_R_INVALID_STRING 150 +#define ENGINE_R_NOT_INITIALISED 117 +#define ENGINE_R_NOT_LOADED 112 +#define ENGINE_R_NO_CONTROL_FUNCTION 120 +#define ENGINE_R_NO_INDEX 144 +#define ENGINE_R_NO_LOAD_FUNCTION 125 +#define ENGINE_R_NO_REFERENCE 130 +#define ENGINE_R_NO_SUCH_ENGINE 116 +#define ENGINE_R_NO_UNLOAD_FUNCTION 126 +#define ENGINE_R_PROVIDE_PARAMETERS 113 +#define ENGINE_R_RSA_NOT_IMPLEMENTED 141 +#define ENGINE_R_UNIMPLEMENTED_CIPHER 146 +#define ENGINE_R_UNIMPLEMENTED_DIGEST 147 +#define ENGINE_R_VERSION_INCOMPATIBILITY 145 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/err.h b/libraries/external/openssl/linux/include/openssl/err.h new file mode 100755 index 0000000..ed38141 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/err.h @@ -0,0 +1,318 @@ +/* crypto/err/err.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ERR_H +#define HEADER_ERR_H + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#include +#endif + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_LHASH +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef OPENSSL_NO_ERR +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) +#else +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) +#endif + +#include + +#define ERR_TXT_MALLOCED 0x01 +#define ERR_TXT_STRING 0x02 + +#define ERR_FLAG_MARK 0x01 + +#define ERR_NUM_ERRORS 16 +typedef struct err_state_st + { + unsigned long pid; + int err_flags[ERR_NUM_ERRORS]; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_data[ERR_NUM_ERRORS]; + int err_data_flags[ERR_NUM_ERRORS]; + const char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + int top,bottom; + } ERR_STATE; + +/* library */ +#define ERR_LIB_NONE 1 +#define ERR_LIB_SYS 2 +#define ERR_LIB_BN 3 +#define ERR_LIB_RSA 4 +#define ERR_LIB_DH 5 +#define ERR_LIB_EVP 6 +#define ERR_LIB_BUF 7 +#define ERR_LIB_OBJ 8 +#define ERR_LIB_PEM 9 +#define ERR_LIB_DSA 10 +#define ERR_LIB_X509 11 +/* #define ERR_LIB_METH 12 */ +#define ERR_LIB_ASN1 13 +#define ERR_LIB_CONF 14 +#define ERR_LIB_CRYPTO 15 +#define ERR_LIB_EC 16 +#define ERR_LIB_SSL 20 +/* #define ERR_LIB_SSL23 21 */ +/* #define ERR_LIB_SSL2 22 */ +/* #define ERR_LIB_SSL3 23 */ +/* #define ERR_LIB_RSAREF 30 */ +/* #define ERR_LIB_PROXY 31 */ +#define ERR_LIB_BIO 32 +#define ERR_LIB_PKCS7 33 +#define ERR_LIB_X509V3 34 +#define ERR_LIB_PKCS12 35 +#define ERR_LIB_RAND 36 +#define ERR_LIB_DSO 37 +#define ERR_LIB_ENGINE 38 +#define ERR_LIB_OCSP 39 +#define ERR_LIB_UI 40 +#define ERR_LIB_COMP 41 +#define ERR_LIB_ECDSA 42 +#define ERR_LIB_ECDH 43 +#define ERR_LIB_STORE 44 + +#define ERR_LIB_USER 128 + +#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__) +#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__) +#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__) +#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__) +#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__) +#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__) +#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__) +#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__) +#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__) +#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__) +#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__) +#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__) +#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__) +#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__) +#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__) +#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__) +#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__) +#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__) +#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__) +#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__) +#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__) +#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__) +#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) +#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) +#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) +#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__) +#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__) +#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) + +/* Borland C seems too stupid to be able to shift and do longs in + * the pre-processor :-( */ +#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \ + ((((unsigned long)f)&0xfffL)*0x1000)| \ + ((((unsigned long)r)&0xfffL))) +#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) +#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) +#define ERR_GET_REASON(l) (int)((l)&0xfffL) +#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) + + +/* OS functions */ +#define SYS_F_FOPEN 1 +#define SYS_F_CONNECT 2 +#define SYS_F_GETSERVBYNAME 3 +#define SYS_F_SOCKET 4 +#define SYS_F_IOCTLSOCKET 5 +#define SYS_F_BIND 6 +#define SYS_F_LISTEN 7 +#define SYS_F_ACCEPT 8 +#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ +#define SYS_F_OPENDIR 10 +#define SYS_F_FREAD 11 + + +/* reasons */ +#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */ +#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */ +#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */ +#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */ +#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */ +#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */ +#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */ +#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */ +#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */ +#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */ +#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */ +#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */ +#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */ +#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */ +#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */ +#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */ +#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */ +#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */ +#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */ +#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */ +#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */ +#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */ +#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */ +#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */ +#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */ +#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */ +#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */ +#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */ + +#define ERR_R_NESTED_ASN1_ERROR 58 +#define ERR_R_BAD_ASN1_OBJECT_HEADER 59 +#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60 +#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61 +#define ERR_R_ASN1_LENGTH_MISMATCH 62 +#define ERR_R_MISSING_ASN1_EOS 63 + +/* fatal error */ +#define ERR_R_FATAL 64 +#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) +#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) +#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) +#define ERR_R_DISABLED (5|ERR_R_FATAL) + +/* 99 is the maximum possible ERR_R_... code, higher values + * are reserved for the individual libraries */ + + +typedef struct ERR_string_data_st + { + unsigned long error; + const char *string; + } ERR_STRING_DATA; + +void ERR_put_error(int lib, int func,int reason,const char *file,int line); +void ERR_set_error_data(char *data,int flags); + +unsigned long ERR_get_error(void); +unsigned long ERR_get_error_line(const char **file,int *line); +unsigned long ERR_get_error_line_data(const char **file,int *line, + const char **data, int *flags); +unsigned long ERR_peek_error(void); +unsigned long ERR_peek_error_line(const char **file,int *line); +unsigned long ERR_peek_error_line_data(const char **file,int *line, + const char **data,int *flags); +unsigned long ERR_peek_last_error(void); +unsigned long ERR_peek_last_error_line(const char **file,int *line); +unsigned long ERR_peek_last_error_line_data(const char **file,int *line, + const char **data,int *flags); +void ERR_clear_error(void ); +char *ERR_error_string(unsigned long e,char *buf); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +const char *ERR_lib_error_string(unsigned long e); +const char *ERR_func_error_string(unsigned long e); +const char *ERR_reason_error_string(unsigned long e); +void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); +#ifndef OPENSSL_NO_FP_API +void ERR_print_errors_fp(FILE *fp); +#endif +#ifndef OPENSSL_NO_BIO +void ERR_print_errors(BIO *bp); +void ERR_add_error_data(int num, ...); +#endif +void ERR_load_strings(int lib,ERR_STRING_DATA str[]); +void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); +void ERR_load_ERR_strings(void); +void ERR_load_crypto_strings(void); +void ERR_free_strings(void); + +void ERR_remove_state(unsigned long pid); /* if zero we look it up */ +ERR_STATE *ERR_get_state(void); + +#ifndef OPENSSL_NO_LHASH +LHASH *ERR_get_string_table(void); +LHASH *ERR_get_err_state_table(void); +void ERR_release_err_state_table(LHASH **hash); +#endif + +int ERR_get_next_error_library(void); + +int ERR_set_mark(void); +int ERR_pop_to_mark(void); + +/* Already defined in ossl_typ.h */ +/* typedef struct st_ERR_FNS ERR_FNS; */ +/* An application can use this function and provide the return value to loaded + * modules that should use the application's ERR state/functionality */ +const ERR_FNS *ERR_get_implementation(void); +/* A loaded module should call this function prior to any ERR operations using + * the application's "ERR_FNS". */ +int ERR_set_implementation(const ERR_FNS *fns); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/evp.h b/libraries/external/openssl/linux/include/openssl/evp.h new file mode 100755 index 0000000..7b13fd7 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/evp.h @@ -0,0 +1,970 @@ +/* crypto/evp/evp.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ENVELOPE_H +#define HEADER_ENVELOPE_H + +#ifdef OPENSSL_ALGORITHM_DEFINES +# include +#else +# define OPENSSL_ALGORITHM_DEFINES +# include +# undef OPENSSL_ALGORITHM_DEFINES +#endif + +#include + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif + +/* +#define EVP_RC2_KEY_SIZE 16 +#define EVP_RC4_KEY_SIZE 16 +#define EVP_BLOWFISH_KEY_SIZE 16 +#define EVP_CAST5_KEY_SIZE 16 +#define EVP_RC5_32_12_16_KEY_SIZE 16 +*/ +#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ +#define EVP_MAX_KEY_LENGTH 32 +#define EVP_MAX_IV_LENGTH 16 +#define EVP_MAX_BLOCK_LENGTH 32 + +#define PKCS5_SALT_LEN 8 +/* Default PKCS#5 iteration count */ +#define PKCS5_DEFAULT_ITER 2048 + +#include + +#define EVP_PK_RSA 0x0001 +#define EVP_PK_DSA 0x0002 +#define EVP_PK_DH 0x0004 +#define EVP_PK_EC 0x0008 +#define EVP_PKT_SIGN 0x0010 +#define EVP_PKT_ENC 0x0020 +#define EVP_PKT_EXCH 0x0040 +#define EVP_PKS_RSA 0x0100 +#define EVP_PKS_DSA 0x0200 +#define EVP_PKS_EC 0x0400 +#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ + +#define EVP_PKEY_NONE NID_undef +#define EVP_PKEY_RSA NID_rsaEncryption +#define EVP_PKEY_RSA2 NID_rsa +#define EVP_PKEY_DSA NID_dsa +#define EVP_PKEY_DSA1 NID_dsa_2 +#define EVP_PKEY_DSA2 NID_dsaWithSHA +#define EVP_PKEY_DSA3 NID_dsaWithSHA1 +#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 +#define EVP_PKEY_DH NID_dhKeyAgreement +#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type needs to be a bit field + * Sub-type needs to be for variations on the method, as in, can it do + * arbitrary encryption.... */ +struct evp_pkey_st + { + int type; + int save_type; + int references; + union { + char *ptr; +#ifndef OPENSSL_NO_RSA + struct rsa_st *rsa; /* RSA */ +#endif +#ifndef OPENSSL_NO_DSA + struct dsa_st *dsa; /* DSA */ +#endif +#ifndef OPENSSL_NO_DH + struct dh_st *dh; /* DH */ +#endif +#ifndef OPENSSL_NO_EC + struct ec_key_st *ec; /* ECC */ +#endif + } pkey; + int save_parameters; + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } /* EVP_PKEY */; + +#define EVP_PKEY_MO_SIGN 0x0001 +#define EVP_PKEY_MO_VERIFY 0x0002 +#define EVP_PKEY_MO_ENCRYPT 0x0004 +#define EVP_PKEY_MO_DECRYPT 0x0008 + +#if 0 +/* This structure is required to tie the message digest and signing together. + * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or + * oid, md and pkey. + * This is required because for various smart-card perform the digest and + * signing/verification on-board. To handle this case, the specific + * EVP_MD and EVP_PKEY_METHODs need to be closely associated. + * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. + * This can either be software or a token to provide the required low level + * routines. + */ +typedef struct evp_pkey_md_st + { + int oid; + EVP_MD *md; + EVP_PKEY_METHOD *pkey; + } EVP_PKEY_MD; + +#define EVP_rsa_md2() \ + EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md2()) +#define EVP_rsa_md5() \ + EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md5()) +#define EVP_rsa_sha0() \ + EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha()) +#define EVP_rsa_sha1() \ + EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha1()) +#define EVP_rsa_ripemd160() \ + EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ + EVP_rsa_pkcs1(),EVP_ripemd160()) +#define EVP_rsa_mdc2() \ + EVP_PKEY_MD_add(NID_mdc2WithRSA,\ + EVP_rsa_octet_string(),EVP_mdc2()) +#define EVP_dsa_sha() \ + EVP_PKEY_MD_add(NID_dsaWithSHA,\ + EVP_dsa(),EVP_sha()) +#define EVP_dsa_sha1() \ + EVP_PKEY_MD_add(NID_dsaWithSHA1,\ + EVP_dsa(),EVP_sha1()) + +typedef struct evp_pkey_method_st + { + char *name; + int flags; + int type; /* RSA, DSA, an SSLeay specific constant */ + int oid; /* For the pub-key type */ + int encrypt_oid; /* pub/priv key encryption */ + + int (*sign)(); + int (*verify)(); + struct { + int (*set)(); /* get and/or set the underlying type */ + int (*get)(); + int (*encrypt)(); + int (*decrypt)(); + int (*i2d)(); + int (*d2i)(); + int (*dup)(); + } pub,priv; + int (*set_asn1_parameters)(); + int (*get_asn1_parameters)(); + } EVP_PKEY_METHOD; +#endif + +#ifndef EVP_MD +struct env_md_st + { + int type; + int pkey_type; + int md_size; + unsigned long flags; + int (*init)(EVP_MD_CTX *ctx); + int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count); + int (*final)(EVP_MD_CTX *ctx,unsigned char *md); + int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); + int (*cleanup)(EVP_MD_CTX *ctx); + + /* FIXME: prototype these some day */ + int (*sign)(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, void *key); + int (*verify)(int type, const unsigned char *m, unsigned int m_length, + const unsigned char *sigbuf, unsigned int siglen, + void *key); + int required_pkey_type[5]; /*EVP_PKEY_xxx */ + int block_size; + int ctx_size; /* how big does the ctx->md_data need to be */ + } /* EVP_MD */; + +typedef int evp_sign_method(int type,const unsigned char *m, + unsigned int m_length,unsigned char *sigret, + unsigned int *siglen, void *key); +typedef int evp_verify_method(int type,const unsigned char *m, + unsigned int m_length,const unsigned char *sigbuf, + unsigned int siglen, void *key); + +#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single + * block */ + +#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \ + (evp_verify_method *)DSA_verify, \ + {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ + EVP_PKEY_DSA4,0} +#else +#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_ECDSA +#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \ + (evp_verify_method *)ECDSA_verify, \ + {EVP_PKEY_EC,0,0,0} +#else +#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \ + (evp_verify_method *)RSA_verify, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ + (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \ + (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#else +#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method +#endif + +#endif /* !EVP_MD */ + +struct env_md_ctx_st + { + const EVP_MD *digest; + ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ + unsigned long flags; + void *md_data; + } /* EVP_MD_CTX */; + +/* values for EVP_MD_CTX flags */ + +#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called + * once only */ +#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been + * cleaned */ +#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data + * in EVP_MD_CTX_cleanup */ + +struct evp_cipher_st + { + int nid; + int block_size; + int key_len; /* Default value for variable length ciphers */ + int iv_len; + unsigned long flags; /* Various flags */ + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc); /* init key */ + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ + int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ + int ctx_size; /* how big ctx->cipher_data needs to be */ + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ + void *app_data; /* Application data */ + } /* EVP_CIPHER */; + +/* Values for cipher flags */ + +/* Modes for ciphers */ + +#define EVP_CIPH_STREAM_CIPHER 0x0 +#define EVP_CIPH_ECB_MODE 0x1 +#define EVP_CIPH_CBC_MODE 0x2 +#define EVP_CIPH_CFB_MODE 0x3 +#define EVP_CIPH_OFB_MODE 0x4 +#define EVP_CIPH_MODE 0x7 +/* Set if variable length cipher */ +#define EVP_CIPH_VARIABLE_LENGTH 0x8 +/* Set if the iv handling should be done by the cipher itself */ +#define EVP_CIPH_CUSTOM_IV 0x10 +/* Set if the cipher's init() function should be called if key is NULL */ +#define EVP_CIPH_ALWAYS_CALL_INIT 0x20 +/* Call ctrl() to init cipher parameters */ +#define EVP_CIPH_CTRL_INIT 0x40 +/* Don't use standard key length function */ +#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 +/* Don't use standard block padding */ +#define EVP_CIPH_NO_PADDING 0x100 +/* cipher handles random key generation */ +#define EVP_CIPH_RAND_KEY 0x200 + +/* ctrl() values */ + +#define EVP_CTRL_INIT 0x0 +#define EVP_CTRL_SET_KEY_LENGTH 0x1 +#define EVP_CTRL_GET_RC2_KEY_BITS 0x2 +#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 +#define EVP_CTRL_GET_RC5_ROUNDS 0x4 +#define EVP_CTRL_SET_RC5_ROUNDS 0x5 +#define EVP_CTRL_RAND_KEY 0x6 + +typedef struct evp_cipher_info_st + { + const EVP_CIPHER *cipher; + unsigned char iv[EVP_MAX_IV_LENGTH]; + } EVP_CIPHER_INFO; + +struct evp_cipher_ctx_st + { + const EVP_CIPHER *cipher; + ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ + int encrypt; /* encrypt or decrypt */ + int buf_len; /* number we have left */ + + unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ + unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ + unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ + int num; /* used by cfb/ofb mode */ + + void *app_data; /* application stuff */ + int key_len; /* May change for variable length cipher */ + unsigned long flags; /* Various flags */ + void *cipher_data; /* per EVP data */ + int final_used; + int block_mask; + unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ + } /* EVP_CIPHER_CTX */; + +typedef struct evp_Encode_Ctx_st + { + int num; /* number saved in a partial encode/decode */ + int length; /* The length is either the output line length + * (in input bytes) or the shortest input line + * length that is ok. Once decoding begins, + * the length is adjusted up each time a longer + * line is decoded */ + unsigned char enc_data[80]; /* data to encode */ + int line_num; /* number read on current line */ + int expect_nl; + } EVP_ENCODE_CTX; + +/* Password based encryption function */ +typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ + (char *)(rsa)) +#endif + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ + (char *)(dsa)) +#endif + +#ifndef OPENSSL_NO_DH +#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ + (char *)(dh)) +#endif + +#ifndef OPENSSL_NO_EC +#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ + (char *)(eckey)) +#endif + +/* Add some extra combinations */ +#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) +#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) +#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) +#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) + +int EVP_MD_type(const EVP_MD *md); +#define EVP_MD_nid(e) EVP_MD_type(e) +#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) +int EVP_MD_pkey_type(const EVP_MD *md); +int EVP_MD_size(const EVP_MD *md); +int EVP_MD_block_size(const EVP_MD *md); + +const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx); +#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) +#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e)) +#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e)) + +int EVP_CIPHER_nid(const EVP_CIPHER *cipher); +#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) +int EVP_CIPHER_block_size(const EVP_CIPHER *cipher); +int EVP_CIPHER_key_length(const EVP_CIPHER *cipher); +int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher); +unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher); +#define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE) + +const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); +void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); +void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); +#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) +unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx); +#define EVP_CIPHER_CTX_mode(e) (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE) + +#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) +#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) + +#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_SignInit(a,b) EVP_DigestInit(a,b) +#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) +#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) +#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) + +#ifdef CONST_STRICT +void BIO_set_md(BIO *,const EVP_MD *md); +#else +# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) +#endif +#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) +#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) +#define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp) +#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) +#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) + +int EVP_Cipher(EVP_CIPHER_CTX *c, + unsigned char *out, + const unsigned char *in, + unsigned int inl); + +#define EVP_add_cipher_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_add_digest_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_delete_cipher_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); +#define EVP_delete_digest_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); + +void EVP_MD_CTX_init(EVP_MD_CTX *ctx); +int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); +EVP_MD_CTX *EVP_MD_CTX_create(void); +void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); +int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); +void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); +void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); +int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags); +int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); +int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, + size_t cnt); +int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); +int EVP_Digest(const void *data, size_t count, + unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); + +int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); +int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); +int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); + +int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); +void EVP_set_pw_prompt(const char *prompt); +char * EVP_get_pw_prompt(void); + +int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, + const unsigned char *salt, const unsigned char *data, + int datal, int count, unsigned char *key,unsigned char *iv); + +int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); +int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, + EVP_PKEY *pkey); + +int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf, + unsigned int siglen,EVP_PKEY *pkey); + +int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, + const unsigned char *ek, int ekl, const unsigned char *iv, + EVP_PKEY *priv); +int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); +int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); + +void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); +void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in,int inl); +void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); +int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in, int inl); +int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned + char *out, int *outl); +int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); +EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); +void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); +int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); +int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); +int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_md(void); +BIO_METHOD *BIO_f_base64(void); +BIO_METHOD *BIO_f_cipher(void); +BIO_METHOD *BIO_f_reliable(void); +void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k, + const unsigned char *i, int enc); +#endif + +const EVP_MD *EVP_md_null(void); +#ifndef OPENSSL_NO_MD2 +const EVP_MD *EVP_md2(void); +#endif +#ifndef OPENSSL_NO_MD4 +const EVP_MD *EVP_md4(void); +#endif +#ifndef OPENSSL_NO_MD5 +const EVP_MD *EVP_md5(void); +#endif +#ifndef OPENSSL_NO_SHA +const EVP_MD *EVP_sha(void); +const EVP_MD *EVP_sha1(void); +const EVP_MD *EVP_dss(void); +const EVP_MD *EVP_dss1(void); +const EVP_MD *EVP_ecdsa(void); +#endif +#ifndef OPENSSL_NO_SHA256 +const EVP_MD *EVP_sha224(void); +const EVP_MD *EVP_sha256(void); +#endif +#ifndef OPENSSL_NO_SHA512 +const EVP_MD *EVP_sha384(void); +const EVP_MD *EVP_sha512(void); +#endif +#ifndef OPENSSL_NO_MDC2 +const EVP_MD *EVP_mdc2(void); +#endif +#ifndef OPENSSL_NO_RIPEMD +const EVP_MD *EVP_ripemd160(void); +#endif +const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ +#ifndef OPENSSL_NO_DES +const EVP_CIPHER *EVP_des_ecb(void); +const EVP_CIPHER *EVP_des_ede(void); +const EVP_CIPHER *EVP_des_ede3(void); +const EVP_CIPHER *EVP_des_ede_ecb(void); +const EVP_CIPHER *EVP_des_ede3_ecb(void); +const EVP_CIPHER *EVP_des_cfb64(void); +# define EVP_des_cfb EVP_des_cfb64 +const EVP_CIPHER *EVP_des_cfb1(void); +const EVP_CIPHER *EVP_des_cfb8(void); +const EVP_CIPHER *EVP_des_ede_cfb64(void); +# define EVP_des_ede_cfb EVP_des_ede_cfb64 +#if 0 +const EVP_CIPHER *EVP_des_ede_cfb1(void); +const EVP_CIPHER *EVP_des_ede_cfb8(void); +#endif +const EVP_CIPHER *EVP_des_ede3_cfb64(void); +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb1(void); +const EVP_CIPHER *EVP_des_ede3_cfb8(void); +const EVP_CIPHER *EVP_des_ofb(void); +const EVP_CIPHER *EVP_des_ede_ofb(void); +const EVP_CIPHER *EVP_des_ede3_ofb(void); +const EVP_CIPHER *EVP_des_cbc(void); +const EVP_CIPHER *EVP_des_ede_cbc(void); +const EVP_CIPHER *EVP_des_ede3_cbc(void); +const EVP_CIPHER *EVP_desx_cbc(void); +/* This should now be supported through the dev_crypto ENGINE. But also, why are + * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ +#if 0 +# ifdef OPENSSL_OPENBSD_DEV_CRYPTO +const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); +const EVP_CIPHER *EVP_dev_crypto_rc4(void); +const EVP_MD *EVP_dev_crypto_md5(void); +# endif +#endif +#endif +#ifndef OPENSSL_NO_RC4 +const EVP_CIPHER *EVP_rc4(void); +const EVP_CIPHER *EVP_rc4_40(void); +#endif +#ifndef OPENSSL_NO_IDEA +const EVP_CIPHER *EVP_idea_ecb(void); +const EVP_CIPHER *EVP_idea_cfb64(void); +# define EVP_idea_cfb EVP_idea_cfb64 +const EVP_CIPHER *EVP_idea_ofb(void); +const EVP_CIPHER *EVP_idea_cbc(void); +#endif +#ifndef OPENSSL_NO_RC2 +const EVP_CIPHER *EVP_rc2_ecb(void); +const EVP_CIPHER *EVP_rc2_cbc(void); +const EVP_CIPHER *EVP_rc2_40_cbc(void); +const EVP_CIPHER *EVP_rc2_64_cbc(void); +const EVP_CIPHER *EVP_rc2_cfb64(void); +# define EVP_rc2_cfb EVP_rc2_cfb64 +const EVP_CIPHER *EVP_rc2_ofb(void); +#endif +#ifndef OPENSSL_NO_BF +const EVP_CIPHER *EVP_bf_ecb(void); +const EVP_CIPHER *EVP_bf_cbc(void); +const EVP_CIPHER *EVP_bf_cfb64(void); +# define EVP_bf_cfb EVP_bf_cfb64 +const EVP_CIPHER *EVP_bf_ofb(void); +#endif +#ifndef OPENSSL_NO_CAST +const EVP_CIPHER *EVP_cast5_ecb(void); +const EVP_CIPHER *EVP_cast5_cbc(void); +const EVP_CIPHER *EVP_cast5_cfb64(void); +# define EVP_cast5_cfb EVP_cast5_cfb64 +const EVP_CIPHER *EVP_cast5_ofb(void); +#endif +#ifndef OPENSSL_NO_RC5 +const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); +const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); +const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 +const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); +#endif +#ifndef OPENSSL_NO_AES +const EVP_CIPHER *EVP_aes_128_ecb(void); +const EVP_CIPHER *EVP_aes_128_cbc(void); +const EVP_CIPHER *EVP_aes_128_cfb1(void); +const EVP_CIPHER *EVP_aes_128_cfb8(void); +const EVP_CIPHER *EVP_aes_128_cfb128(void); +# define EVP_aes_128_cfb EVP_aes_128_cfb128 +const EVP_CIPHER *EVP_aes_128_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_128_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_192_ecb(void); +const EVP_CIPHER *EVP_aes_192_cbc(void); +const EVP_CIPHER *EVP_aes_192_cfb1(void); +const EVP_CIPHER *EVP_aes_192_cfb8(void); +const EVP_CIPHER *EVP_aes_192_cfb128(void); +# define EVP_aes_192_cfb EVP_aes_192_cfb128 +const EVP_CIPHER *EVP_aes_192_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_192_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_256_ecb(void); +const EVP_CIPHER *EVP_aes_256_cbc(void); +const EVP_CIPHER *EVP_aes_256_cfb1(void); +const EVP_CIPHER *EVP_aes_256_cfb8(void); +const EVP_CIPHER *EVP_aes_256_cfb128(void); +# define EVP_aes_256_cfb EVP_aes_256_cfb128 +const EVP_CIPHER *EVP_aes_256_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_256_ctr(void); +#endif +#endif +#ifndef OPENSSL_NO_CAMELLIA +const EVP_CIPHER *EVP_camellia_128_ecb(void); +const EVP_CIPHER *EVP_camellia_128_cbc(void); +const EVP_CIPHER *EVP_camellia_128_cfb1(void); +const EVP_CIPHER *EVP_camellia_128_cfb8(void); +const EVP_CIPHER *EVP_camellia_128_cfb128(void); +# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 +const EVP_CIPHER *EVP_camellia_128_ofb(void); +const EVP_CIPHER *EVP_camellia_192_ecb(void); +const EVP_CIPHER *EVP_camellia_192_cbc(void); +const EVP_CIPHER *EVP_camellia_192_cfb1(void); +const EVP_CIPHER *EVP_camellia_192_cfb8(void); +const EVP_CIPHER *EVP_camellia_192_cfb128(void); +# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 +const EVP_CIPHER *EVP_camellia_192_ofb(void); +const EVP_CIPHER *EVP_camellia_256_ecb(void); +const EVP_CIPHER *EVP_camellia_256_cbc(void); +const EVP_CIPHER *EVP_camellia_256_cfb1(void); +const EVP_CIPHER *EVP_camellia_256_cfb8(void); +const EVP_CIPHER *EVP_camellia_256_cfb128(void); +# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 +const EVP_CIPHER *EVP_camellia_256_ofb(void); +#endif + +void OPENSSL_add_all_algorithms_noconf(void); +void OPENSSL_add_all_algorithms_conf(void); + +#ifdef OPENSSL_LOAD_CONF +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_conf() +#else +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_noconf() +#endif + +void OpenSSL_add_all_ciphers(void); +void OpenSSL_add_all_digests(void); +#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() +#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() +#define SSLeay_add_all_digests() OpenSSL_add_all_digests() + +int EVP_add_cipher(const EVP_CIPHER *cipher); +int EVP_add_digest(const EVP_MD *digest); + +const EVP_CIPHER *EVP_get_cipherbyname(const char *name); +const EVP_MD *EVP_get_digestbyname(const char *name); +void EVP_cleanup(void); + +int EVP_PKEY_decrypt(unsigned char *dec_key, + const unsigned char *enc_key,int enc_key_len, + EVP_PKEY *private_key); +int EVP_PKEY_encrypt(unsigned char *enc_key, + const unsigned char *key,int key_len, + EVP_PKEY *pub_key); +int EVP_PKEY_type(int type); +int EVP_PKEY_bits(EVP_PKEY *pkey); +int EVP_PKEY_size(EVP_PKEY *pkey); +int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); + +#ifndef OPENSSL_NO_RSA +struct rsa_st; +int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key); +struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DSA +struct dsa_st; +int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key); +struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DH +struct dh_st; +int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); +struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_EC +struct ec_key_st; +int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key); +struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); +#endif + +EVP_PKEY * EVP_PKEY_new(void); +void EVP_PKEY_free(EVP_PKEY *pkey); + +EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); + +EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); + +int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); +int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); +int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); +int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_CIPHER_type(const EVP_CIPHER *ctx); + +/* calls methods */ +int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); + +/* These are used by EVP_CIPHER methods */ +int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); +int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); + +/* PKCS5 password based encryption */ +int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); +int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + int keylen, unsigned char *out); +int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); + +void PKCS5_PBE_add(void); + +int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); +int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, + EVP_PBE_KEYGEN *keygen); +void EVP_PBE_cleanup(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EVP_strings(void); + +/* Error codes for the EVP functions. */ + +/* Function codes. */ +#define EVP_F_AES_INIT_KEY 133 +#define EVP_F_CAMELLIA_INIT_KEY 159 +#define EVP_F_D2I_PKEY 100 +#define EVP_F_DSAPKEY2PKCS8 134 +#define EVP_F_DSA_PKEY2PKCS8 135 +#define EVP_F_ECDSA_PKEY2PKCS8 129 +#define EVP_F_ECKEY_PKEY2PKCS8 132 +#define EVP_F_EVP_CIPHERINIT_EX 123 +#define EVP_F_EVP_CIPHER_CTX_CTRL 124 +#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 +#define EVP_F_EVP_DECRYPTFINAL_EX 101 +#define EVP_F_EVP_DIGESTINIT_EX 128 +#define EVP_F_EVP_ENCRYPTFINAL_EX 127 +#define EVP_F_EVP_MD_CTX_COPY_EX 110 +#define EVP_F_EVP_OPENINIT 102 +#define EVP_F_EVP_PBE_ALG_ADD 115 +#define EVP_F_EVP_PBE_CIPHERINIT 116 +#define EVP_F_EVP_PKCS82PKEY 111 +#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113 +#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 +#define EVP_F_EVP_PKEY_DECRYPT 104 +#define EVP_F_EVP_PKEY_ENCRYPT 105 +#define EVP_F_EVP_PKEY_GET1_DH 119 +#define EVP_F_EVP_PKEY_GET1_DSA 120 +#define EVP_F_EVP_PKEY_GET1_ECDSA 130 +#define EVP_F_EVP_PKEY_GET1_EC_KEY 131 +#define EVP_F_EVP_PKEY_GET1_RSA 121 +#define EVP_F_EVP_PKEY_NEW 106 +#define EVP_F_EVP_RIJNDAEL 126 +#define EVP_F_EVP_SIGNFINAL 107 +#define EVP_F_EVP_VERIFYFINAL 108 +#define EVP_F_PKCS5_PBE_KEYIVGEN 117 +#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 +#define EVP_F_PKCS8_SET_BROKEN 112 +#define EVP_F_RC2_MAGIC_TO_METH 109 +#define EVP_F_RC5_CTRL 125 + +/* Reason codes. */ +#define EVP_R_AES_KEY_SETUP_FAILED 143 +#define EVP_R_ASN1_LIB 140 +#define EVP_R_BAD_BLOCK_LENGTH 136 +#define EVP_R_BAD_DECRYPT 100 +#define EVP_R_BAD_KEY_LENGTH 137 +#define EVP_R_BN_DECODE_ERROR 112 +#define EVP_R_BN_PUBKEY_ERROR 113 +#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 +#define EVP_R_CIPHER_PARAMETER_ERROR 122 +#define EVP_R_CTRL_NOT_IMPLEMENTED 132 +#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 +#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 +#define EVP_R_DECODE_ERROR 114 +#define EVP_R_DIFFERENT_KEY_TYPES 101 +#define EVP_R_ENCODE_ERROR 115 +#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 +#define EVP_R_EXPECTING_AN_RSA_KEY 127 +#define EVP_R_EXPECTING_A_DH_KEY 128 +#define EVP_R_EXPECTING_A_DSA_KEY 129 +#define EVP_R_EXPECTING_A_ECDSA_KEY 141 +#define EVP_R_EXPECTING_A_EC_KEY 142 +#define EVP_R_INITIALIZATION_ERROR 134 +#define EVP_R_INPUT_NOT_INITIALIZED 111 +#define EVP_R_INVALID_KEY_LENGTH 130 +#define EVP_R_IV_TOO_LARGE 102 +#define EVP_R_KEYGEN_FAILURE 120 +#define EVP_R_MISSING_PARAMETERS 103 +#define EVP_R_NO_CIPHER_SET 131 +#define EVP_R_NO_DIGEST_SET 139 +#define EVP_R_NO_DSA_PARAMETERS 116 +#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 +#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 +#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 +#define EVP_R_UNSUPPORTED_CIPHER 107 +#define EVP_R_UNSUPPORTED_KEYLENGTH 123 +#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 +#define EVP_R_UNSUPPORTED_KEY_SIZE 108 +#define EVP_R_UNSUPPORTED_PRF 125 +#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 +#define EVP_R_UNSUPPORTED_SALT_TYPE 126 +#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 +#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/hmac.h b/libraries/external/openssl/linux/include/openssl/hmac.h new file mode 100755 index 0000000..943869a --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/hmac.h @@ -0,0 +1,108 @@ +/* crypto/hmac/hmac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#ifndef HEADER_HMAC_H +#define HEADER_HMAC_H + +#include + +#ifdef OPENSSL_NO_HMAC +#error HMAC is disabled. +#endif + +#include + +#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct hmac_ctx_st + { + const EVP_MD *md; + EVP_MD_CTX md_ctx; + EVP_MD_CTX i_ctx; + EVP_MD_CTX o_ctx; + unsigned int key_length; + unsigned char key[HMAC_MAX_MD_CBLOCK]; + } HMAC_CTX; + +#define HMAC_size(e) (EVP_MD_size((e)->md)) + + +void HMAC_CTX_init(HMAC_CTX *ctx); +void HMAC_CTX_cleanup(HMAC_CTX *ctx); + +#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ + +void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md); /* deprecated */ +void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md, ENGINE *impl); +void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); +void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); +unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, + const unsigned char *d, size_t n, unsigned char *md, + unsigned int *md_len); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/idea.h b/libraries/external/openssl/linux/include/openssl/idea.h new file mode 100755 index 0000000..d96154a --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/idea.h @@ -0,0 +1,100 @@ +/* crypto/idea/idea.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_IDEA_H +#define HEADER_IDEA_H + +#include /* IDEA_INT, OPENSSL_NO_IDEA */ + +#ifdef OPENSSL_NO_IDEA +#error IDEA is disabled. +#endif + +#define IDEA_ENCRYPT 1 +#define IDEA_DECRYPT 0 + +#define IDEA_BLOCK 8 +#define IDEA_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct idea_key_st + { + IDEA_INT data[9][6]; + } IDEA_KEY_SCHEDULE; + +const char *idea_options(void); +void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, + IDEA_KEY_SCHEDULE *ks); +void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); +void idea_set_decrypt_key(const IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); +void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc); +void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, + int *num,int enc); +void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num); +void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/krb5_asn.h b/libraries/external/openssl/linux/include/openssl/krb5_asn.h new file mode 100755 index 0000000..fa08967 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/krb5_asn.h @@ -0,0 +1,256 @@ +/* krb5_asn.h */ +/* Written by Vern Staats for the OpenSSL project, +** using ocsp/{*.h,*asn*.c} as a starting point +*/ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_KRB5_ASN_H +#define HEADER_KRB5_ASN_H + +/* +#include +*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ASN.1 from Kerberos RFC 1510 +*/ + +/* EncryptedData ::= SEQUENCE { +** etype[0] INTEGER, -- EncryptionType +** kvno[1] INTEGER OPTIONAL, +** cipher[2] OCTET STRING -- ciphertext +** } +*/ +typedef struct krb5_encdata_st + { + ASN1_INTEGER *etype; + ASN1_INTEGER *kvno; + ASN1_OCTET_STRING *cipher; + } KRB5_ENCDATA; + +DECLARE_STACK_OF(KRB5_ENCDATA) + +/* PrincipalName ::= SEQUENCE { +** name-type[0] INTEGER, +** name-string[1] SEQUENCE OF GeneralString +** } +*/ +typedef struct krb5_princname_st + { + ASN1_INTEGER *nametype; + STACK_OF(ASN1_GENERALSTRING) *namestring; + } KRB5_PRINCNAME; + +DECLARE_STACK_OF(KRB5_PRINCNAME) + + +/* Ticket ::= [APPLICATION 1] SEQUENCE { +** tkt-vno[0] INTEGER, +** realm[1] Realm, +** sname[2] PrincipalName, +** enc-part[3] EncryptedData +** } +*/ +typedef struct krb5_tktbody_st + { + ASN1_INTEGER *tktvno; + ASN1_GENERALSTRING *realm; + KRB5_PRINCNAME *sname; + KRB5_ENCDATA *encdata; + } KRB5_TKTBODY; + +typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET; +DECLARE_STACK_OF(KRB5_TKTBODY) + + +/* AP-REQ ::= [APPLICATION 14] SEQUENCE { +** pvno[0] INTEGER, +** msg-type[1] INTEGER, +** ap-options[2] APOptions, +** ticket[3] Ticket, +** authenticator[4] EncryptedData +** } +** +** APOptions ::= BIT STRING { +** reserved(0), use-session-key(1), mutual-required(2) } +*/ +typedef struct krb5_ap_req_st + { + ASN1_INTEGER *pvno; + ASN1_INTEGER *msgtype; + ASN1_BIT_STRING *apoptions; + KRB5_TICKET *ticket; + KRB5_ENCDATA *authenticator; + } KRB5_APREQBODY; + +typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ; +DECLARE_STACK_OF(KRB5_APREQBODY) + + +/* Authenticator Stuff */ + + +/* Checksum ::= SEQUENCE { +** cksumtype[0] INTEGER, +** checksum[1] OCTET STRING +** } +*/ +typedef struct krb5_checksum_st + { + ASN1_INTEGER *ctype; + ASN1_OCTET_STRING *checksum; + } KRB5_CHECKSUM; + +DECLARE_STACK_OF(KRB5_CHECKSUM) + + +/* EncryptionKey ::= SEQUENCE { +** keytype[0] INTEGER, +** keyvalue[1] OCTET STRING +** } +*/ +typedef struct krb5_encryptionkey_st + { + ASN1_INTEGER *ktype; + ASN1_OCTET_STRING *keyvalue; + } KRB5_ENCKEY; + +DECLARE_STACK_OF(KRB5_ENCKEY) + + +/* AuthorizationData ::= SEQUENCE OF SEQUENCE { +** ad-type[0] INTEGER, +** ad-data[1] OCTET STRING +** } +*/ +typedef struct krb5_authorization_st + { + ASN1_INTEGER *adtype; + ASN1_OCTET_STRING *addata; + } KRB5_AUTHDATA; + +DECLARE_STACK_OF(KRB5_AUTHDATA) + + +/* -- Unencrypted authenticator +** Authenticator ::= [APPLICATION 2] SEQUENCE { +** authenticator-vno[0] INTEGER, +** crealm[1] Realm, +** cname[2] PrincipalName, +** cksum[3] Checksum OPTIONAL, +** cusec[4] INTEGER, +** ctime[5] KerberosTime, +** subkey[6] EncryptionKey OPTIONAL, +** seq-number[7] INTEGER OPTIONAL, +** authorization-data[8] AuthorizationData OPTIONAL +** } +*/ +typedef struct krb5_authenticator_st + { + ASN1_INTEGER *avno; + ASN1_GENERALSTRING *crealm; + KRB5_PRINCNAME *cname; + KRB5_CHECKSUM *cksum; + ASN1_INTEGER *cusec; + ASN1_GENERALIZEDTIME *ctime; + KRB5_ENCKEY *subkey; + ASN1_INTEGER *seqnum; + KRB5_AUTHDATA *authorization; + } KRB5_AUTHENTBODY; + +typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT; +DECLARE_STACK_OF(KRB5_AUTHENTBODY) + + +/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) = +** type *name##_new(void); +** void name##_free(type *a); +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) = +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) = +** type *d2i_##name(type **a, const unsigned char **in, long len); +** int i2d_##name(type *a, unsigned char **out); +** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it +*/ + +DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME) +DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_TICKET) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQ) + +DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM) +DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT) + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/kssl.h b/libraries/external/openssl/linux/include/openssl/kssl.h new file mode 100755 index 0000000..c84820f --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/kssl.h @@ -0,0 +1,179 @@ +/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */ +/* Written by Vern Staats for the OpenSSL project 2000. + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* +** 19990701 VRS Started. +*/ + +#ifndef KSSL_H +#define KSSL_H + +#include + +#ifndef OPENSSL_NO_KRB5 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Depending on which KRB5 implementation used, some types from +** the other may be missing. Resolve that here and now +*/ +#ifdef KRB5_HEIMDAL +typedef unsigned char krb5_octet; +#define FAR +#else + +#ifndef FAR +#define FAR +#endif + +#endif + +/* Uncomment this to debug kssl problems or +** to trace usage of the Kerberos session key +** +** #define KSSL_DEBUG +*/ + +#ifndef KRB5SVC +#define KRB5SVC "host" +#endif + +#ifndef KRB5KEYTAB +#define KRB5KEYTAB "/etc/krb5.keytab" +#endif + +#ifndef KRB5SENDAUTH +#define KRB5SENDAUTH 1 +#endif + +#ifndef KRB5CHECKAUTH +#define KRB5CHECKAUTH 1 +#endif + +#ifndef KSSL_CLOCKSKEW +#define KSSL_CLOCKSKEW 300; +#endif + +#define KSSL_ERR_MAX 255 +typedef struct kssl_err_st { + int reason; + char text[KSSL_ERR_MAX+1]; + } KSSL_ERR; + + +/* Context for passing +** (1) Kerberos session key to SSL, and +** (2) Config data between application and SSL lib +*/ +typedef struct kssl_ctx_st + { + /* used by: disposition: */ + char *service_name; /* C,S default ok (kssl) */ + char *service_host; /* C input, REQUIRED */ + char *client_princ; /* S output from krb5 ticket */ + char *keytab_file; /* S NULL (/etc/krb5.keytab) */ + char *cred_cache; /* C NULL (default) */ + krb5_enctype enctype; + int length; + krb5_octet FAR *key; + } KSSL_CTX; + +#define KSSL_CLIENT 1 +#define KSSL_SERVER 2 +#define KSSL_SERVICE 3 +#define KSSL_KEYTAB 4 + +#define KSSL_CTX_OK 0 +#define KSSL_CTX_ERR 1 +#define KSSL_NOMEM 2 + +/* Public (for use by applications that use OpenSSL with Kerberos 5 support */ +krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text); +KSSL_CTX *kssl_ctx_new(void); +KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx); +void kssl_ctx_show(KSSL_CTX *kssl_ctx); +krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, + krb5_data *realm, krb5_data *entity, int nentities); +krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp, + krb5_data *authenp, KSSL_ERR *kssl_err); +krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata, + krb5_ticket_times *ttimes, KSSL_ERR *kssl_err); +krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session); +void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text); +void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data); +krb5_error_code kssl_build_principal_2(krb5_context context, + krb5_principal *princ, int rlen, const char *realm, + int slen, const char *svc, int hlen, const char *host); +krb5_error_code kssl_validate_times(krb5_timestamp atime, + krb5_ticket_times *ttimes); +krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp, + krb5_timestamp *atimep, KSSL_ERR *kssl_err); +unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn); + +#ifdef __cplusplus +} +#endif +#endif /* OPENSSL_NO_KRB5 */ +#endif /* KSSL_H */ diff --git a/libraries/external/openssl/linux/include/openssl/lhash.h b/libraries/external/openssl/linux/include/openssl/lhash.h new file mode 100755 index 0000000..d0b1daf --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/lhash.h @@ -0,0 +1,200 @@ +/* crypto/lhash/lhash.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ + +#ifndef HEADER_LHASH_H +#define HEADER_LHASH_H + +#include +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct lhash_node_st + { + void *data; + struct lhash_node_st *next; +#ifndef OPENSSL_NO_HASH_COMP + unsigned long hash; +#endif + } LHASH_NODE; + +typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); +typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); +typedef void (*LHASH_DOALL_FN_TYPE)(void *); +typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); + +/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. + * This way, callbacks can be provided to LHASH structures without function + * pointer casting and the macro-defined callbacks provide per-variable casting + * before deferring to the underlying type-specific callbacks. NB: It is + * possible to place a "static" in front of both the DECLARE and IMPLEMENT + * macros if the functions are strictly internal. */ + +/* First: "hash" functions */ +#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *); +#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *arg) { \ + o_type a = (o_type)arg; \ + return f_name(a); } +#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH + +/* Second: "compare" functions */ +#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *, const void *); +#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ + o_type a = (o_type)arg1; \ + o_type b = (o_type)arg2; \ + return f_name(a,b); } +#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP + +/* Third: "doall" functions */ +#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *); +#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *arg) { \ + o_type a = (o_type)arg; \ + f_name(a); } +#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL + +/* Fourth: "doall_arg" functions */ +#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *, void *); +#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ + o_type a = (o_type)arg1; \ + a_type b = (a_type)arg2; \ + f_name(a,b); } +#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG + +typedef struct lhash_st + { + LHASH_NODE **b; + LHASH_COMP_FN_TYPE comp; + LHASH_HASH_FN_TYPE hash; + unsigned int num_nodes; + unsigned int num_alloc_nodes; + unsigned int p; + unsigned int pmax; + unsigned long up_load; /* load times 256 */ + unsigned long down_load; /* load times 256 */ + unsigned long num_items; + + unsigned long num_expands; + unsigned long num_expand_reallocs; + unsigned long num_contracts; + unsigned long num_contract_reallocs; + unsigned long num_hash_calls; + unsigned long num_comp_calls; + unsigned long num_insert; + unsigned long num_replace; + unsigned long num_delete; + unsigned long num_no_delete; + unsigned long num_retrieve; + unsigned long num_retrieve_miss; + unsigned long num_hash_comps; + + int error; + } LHASH; + +#define LH_LOAD_MULT 256 + +/* Indicates a malloc() error in the last call, this is only bad + * in lh_insert(). */ +#define lh_error(lh) ((lh)->error) + +LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); +void lh_free(LHASH *lh); +void *lh_insert(LHASH *lh, void *data); +void *lh_delete(LHASH *lh, const void *data); +void *lh_retrieve(LHASH *lh, const void *data); +void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); +unsigned long lh_strhash(const char *c); +unsigned long lh_num_items(const LHASH *lh); + +#ifndef OPENSSL_NO_FP_API +void lh_stats(const LHASH *lh, FILE *out); +void lh_node_stats(const LHASH *lh, FILE *out); +void lh_node_usage_stats(const LHASH *lh, FILE *out); +#endif + +#ifndef OPENSSL_NO_BIO +void lh_stats_bio(const LHASH *lh, BIO *out); +void lh_node_stats_bio(const LHASH *lh, BIO *out); +void lh_node_usage_stats_bio(const LHASH *lh, BIO *out); +#endif +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/md2.h b/libraries/external/openssl/linux/include/openssl/md2.h new file mode 100755 index 0000000..442fc5a --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/md2.h @@ -0,0 +1,92 @@ +/* crypto/md/md2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD2_H +#define HEADER_MD2_H + +#include /* OPENSSL_NO_MD2, MD2_INT */ +#ifdef OPENSSL_NO_MD2 +#error MD2 is disabled. +#endif +#include + +#define MD2_DIGEST_LENGTH 16 +#define MD2_BLOCK 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct MD2state_st + { + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; + } MD2_CTX; + +const char *MD2_options(void); +int MD2_Init(MD2_CTX *c); +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); +int MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/md4.h b/libraries/external/openssl/linux/include/openssl/md4.h new file mode 100755 index 0000000..8315d5c --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/md4.h @@ -0,0 +1,117 @@ +/* crypto/md4/md4.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD4_H +#define HEADER_MD4_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD4 +#error MD4 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD4_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD4_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD4_LONG unsigned long +#define MD4_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD4_LONG unsigned int +#endif + +#define MD4_CBLOCK 64 +#define MD4_LBLOCK (MD4_CBLOCK/4) +#define MD4_DIGEST_LENGTH 16 + +typedef struct MD4state_st + { + MD4_LONG A,B,C,D; + MD4_LONG Nl,Nh; + MD4_LONG data[MD4_LBLOCK]; + unsigned int num; + } MD4_CTX; + +int MD4_Init(MD4_CTX *c); +int MD4_Update(MD4_CTX *c, const void *data, size_t len); +int MD4_Final(unsigned char *md, MD4_CTX *c); +unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); +void MD4_Transform(MD4_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/md5.h b/libraries/external/openssl/linux/include/openssl/md5.h new file mode 100755 index 0000000..d09e099 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/md5.h @@ -0,0 +1,117 @@ +/* crypto/md5/md5.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD5_H +#define HEADER_MD5_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD5 +#error MD5 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD5_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD5_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD5_LONG unsigned long +#define MD5_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD5_LONG unsigned int +#endif + +#define MD5_CBLOCK 64 +#define MD5_LBLOCK (MD5_CBLOCK/4) +#define MD5_DIGEST_LENGTH 16 + +typedef struct MD5state_st + { + MD5_LONG A,B,C,D; + MD5_LONG Nl,Nh; + MD5_LONG data[MD5_LBLOCK]; + unsigned int num; + } MD5_CTX; + +int MD5_Init(MD5_CTX *c); +int MD5_Update(MD5_CTX *c, const void *data, size_t len); +int MD5_Final(unsigned char *md, MD5_CTX *c); +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); +void MD5_Transform(MD5_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/obj_mac.h b/libraries/external/openssl/linux/include/openssl/obj_mac.h new file mode 100755 index 0000000..d53e809 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/obj_mac.h @@ -0,0 +1,3408 @@ +/* crypto/objects/obj_mac.h */ + +/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the + * following command: + * perl objects.pl objects.txt obj_mac.num obj_mac.h + */ + +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_itu_t "ITU-T" +#define LN_itu_t "itu-t" +#define NID_itu_t 645 +#define OBJ_itu_t 0L + +#define NID_ccitt 404 +#define OBJ_ccitt OBJ_itu_t + +#define SN_iso "ISO" +#define LN_iso "iso" +#define NID_iso 181 +#define OBJ_iso 1L + +#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" +#define LN_joint_iso_itu_t "joint-iso-itu-t" +#define NID_joint_iso_itu_t 646 +#define OBJ_joint_iso_itu_t 2L + +#define NID_joint_iso_ccitt 393 +#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t + +#define SN_member_body "member-body" +#define LN_member_body "ISO Member Body" +#define NID_member_body 182 +#define OBJ_member_body OBJ_iso,2L + +#define SN_identified_organization "identified-organization" +#define NID_identified_organization 676 +#define OBJ_identified_organization OBJ_iso,3L + +#define SN_certicom_arc "certicom-arc" +#define NID_certicom_arc 677 +#define OBJ_certicom_arc OBJ_identified_organization,132L + +#define SN_international_organizations "international-organizations" +#define LN_international_organizations "International Organizations" +#define NID_international_organizations 647 +#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L + +#define SN_wap "wap" +#define NID_wap 678 +#define OBJ_wap OBJ_international_organizations,43L + +#define SN_wap_wsg "wap-wsg" +#define NID_wap_wsg 679 +#define OBJ_wap_wsg OBJ_wap,13L + +#define SN_selected_attribute_types "selected-attribute-types" +#define LN_selected_attribute_types "Selected Attribute Types" +#define NID_selected_attribute_types 394 +#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L + +#define SN_clearance "clearance" +#define NID_clearance 395 +#define OBJ_clearance OBJ_selected_attribute_types,55L + +#define SN_ISO_US "ISO-US" +#define LN_ISO_US "ISO US Member Body" +#define NID_ISO_US 183 +#define OBJ_ISO_US OBJ_member_body,840L + +#define SN_X9_57 "X9-57" +#define LN_X9_57 "X9.57" +#define NID_X9_57 184 +#define OBJ_X9_57 OBJ_ISO_US,10040L + +#define SN_X9cm "X9cm" +#define LN_X9cm "X9.57 CM ?" +#define NID_X9cm 185 +#define OBJ_X9cm OBJ_X9_57,4L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa OBJ_X9cm,1L + +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 OBJ_X9cm,3L + +#define SN_ansi_X9_62 "ansi-X9-62" +#define LN_ansi_X9_62 "ANSI X9.62" +#define NID_ansi_X9_62 405 +#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L + +#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L + +#define SN_X9_62_prime_field "prime-field" +#define NID_X9_62_prime_field 406 +#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L + +#define SN_X9_62_characteristic_two_field "characteristic-two-field" +#define NID_X9_62_characteristic_two_field 407 +#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L + +#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" +#define NID_X9_62_id_characteristic_two_basis 680 +#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L + +#define SN_X9_62_onBasis "onBasis" +#define NID_X9_62_onBasis 681 +#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L + +#define SN_X9_62_tpBasis "tpBasis" +#define NID_X9_62_tpBasis 682 +#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L + +#define SN_X9_62_ppBasis "ppBasis" +#define NID_X9_62_ppBasis 683 +#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L + +#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L + +#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" +#define NID_X9_62_id_ecPublicKey 408 +#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L + +#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L + +#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L + +#define SN_X9_62_c2pnb163v1 "c2pnb163v1" +#define NID_X9_62_c2pnb163v1 684 +#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L + +#define SN_X9_62_c2pnb163v2 "c2pnb163v2" +#define NID_X9_62_c2pnb163v2 685 +#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L + +#define SN_X9_62_c2pnb163v3 "c2pnb163v3" +#define NID_X9_62_c2pnb163v3 686 +#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L + +#define SN_X9_62_c2pnb176v1 "c2pnb176v1" +#define NID_X9_62_c2pnb176v1 687 +#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L + +#define SN_X9_62_c2tnb191v1 "c2tnb191v1" +#define NID_X9_62_c2tnb191v1 688 +#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L + +#define SN_X9_62_c2tnb191v2 "c2tnb191v2" +#define NID_X9_62_c2tnb191v2 689 +#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L + +#define SN_X9_62_c2tnb191v3 "c2tnb191v3" +#define NID_X9_62_c2tnb191v3 690 +#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L + +#define SN_X9_62_c2onb191v4 "c2onb191v4" +#define NID_X9_62_c2onb191v4 691 +#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L + +#define SN_X9_62_c2onb191v5 "c2onb191v5" +#define NID_X9_62_c2onb191v5 692 +#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L + +#define SN_X9_62_c2pnb208w1 "c2pnb208w1" +#define NID_X9_62_c2pnb208w1 693 +#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L + +#define SN_X9_62_c2tnb239v1 "c2tnb239v1" +#define NID_X9_62_c2tnb239v1 694 +#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L + +#define SN_X9_62_c2tnb239v2 "c2tnb239v2" +#define NID_X9_62_c2tnb239v2 695 +#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L + +#define SN_X9_62_c2tnb239v3 "c2tnb239v3" +#define NID_X9_62_c2tnb239v3 696 +#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L + +#define SN_X9_62_c2onb239v4 "c2onb239v4" +#define NID_X9_62_c2onb239v4 697 +#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L + +#define SN_X9_62_c2onb239v5 "c2onb239v5" +#define NID_X9_62_c2onb239v5 698 +#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L + +#define SN_X9_62_c2pnb272w1 "c2pnb272w1" +#define NID_X9_62_c2pnb272w1 699 +#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L + +#define SN_X9_62_c2pnb304w1 "c2pnb304w1" +#define NID_X9_62_c2pnb304w1 700 +#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L + +#define SN_X9_62_c2tnb359v1 "c2tnb359v1" +#define NID_X9_62_c2tnb359v1 701 +#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L + +#define SN_X9_62_c2pnb368w1 "c2pnb368w1" +#define NID_X9_62_c2pnb368w1 702 +#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L + +#define SN_X9_62_c2tnb431r1 "c2tnb431r1" +#define NID_X9_62_c2tnb431r1 703 +#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L + +#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L + +#define SN_X9_62_prime192v1 "prime192v1" +#define NID_X9_62_prime192v1 409 +#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L + +#define SN_X9_62_prime192v2 "prime192v2" +#define NID_X9_62_prime192v2 410 +#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L + +#define SN_X9_62_prime192v3 "prime192v3" +#define NID_X9_62_prime192v3 411 +#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L + +#define SN_X9_62_prime239v1 "prime239v1" +#define NID_X9_62_prime239v1 412 +#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L + +#define SN_X9_62_prime239v2 "prime239v2" +#define NID_X9_62_prime239v2 413 +#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L + +#define SN_X9_62_prime239v3 "prime239v3" +#define NID_X9_62_prime239v3 414 +#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L + +#define SN_X9_62_prime256v1 "prime256v1" +#define NID_X9_62_prime256v1 415 +#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L + +#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L + +#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" +#define NID_ecdsa_with_SHA1 416 +#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L + +#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L + +#define SN_secp112r1 "secp112r1" +#define NID_secp112r1 704 +#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L + +#define SN_secp112r2 "secp112r2" +#define NID_secp112r2 705 +#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L + +#define SN_secp128r1 "secp128r1" +#define NID_secp128r1 706 +#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L + +#define SN_secp128r2 "secp128r2" +#define NID_secp128r2 707 +#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L + +#define SN_secp160k1 "secp160k1" +#define NID_secp160k1 708 +#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L + +#define SN_secp160r1 "secp160r1" +#define NID_secp160r1 709 +#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L + +#define SN_secp160r2 "secp160r2" +#define NID_secp160r2 710 +#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L + +#define SN_secp192k1 "secp192k1" +#define NID_secp192k1 711 +#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L + +#define SN_secp224k1 "secp224k1" +#define NID_secp224k1 712 +#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L + +#define SN_secp224r1 "secp224r1" +#define NID_secp224r1 713 +#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L + +#define SN_secp256k1 "secp256k1" +#define NID_secp256k1 714 +#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L + +#define SN_secp384r1 "secp384r1" +#define NID_secp384r1 715 +#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L + +#define SN_secp521r1 "secp521r1" +#define NID_secp521r1 716 +#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L + +#define SN_sect113r1 "sect113r1" +#define NID_sect113r1 717 +#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L + +#define SN_sect113r2 "sect113r2" +#define NID_sect113r2 718 +#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L + +#define SN_sect131r1 "sect131r1" +#define NID_sect131r1 719 +#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L + +#define SN_sect131r2 "sect131r2" +#define NID_sect131r2 720 +#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L + +#define SN_sect163k1 "sect163k1" +#define NID_sect163k1 721 +#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L + +#define SN_sect163r1 "sect163r1" +#define NID_sect163r1 722 +#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L + +#define SN_sect163r2 "sect163r2" +#define NID_sect163r2 723 +#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L + +#define SN_sect193r1 "sect193r1" +#define NID_sect193r1 724 +#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L + +#define SN_sect193r2 "sect193r2" +#define NID_sect193r2 725 +#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L + +#define SN_sect233k1 "sect233k1" +#define NID_sect233k1 726 +#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L + +#define SN_sect233r1 "sect233r1" +#define NID_sect233r1 727 +#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L + +#define SN_sect239k1 "sect239k1" +#define NID_sect239k1 728 +#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L + +#define SN_sect283k1 "sect283k1" +#define NID_sect283k1 729 +#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L + +#define SN_sect283r1 "sect283r1" +#define NID_sect283r1 730 +#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L + +#define SN_sect409k1 "sect409k1" +#define NID_sect409k1 731 +#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L + +#define SN_sect409r1 "sect409r1" +#define NID_sect409r1 732 +#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L + +#define SN_sect571k1 "sect571k1" +#define NID_sect571k1 733 +#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L + +#define SN_sect571r1 "sect571r1" +#define NID_sect571r1 734 +#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L + +#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L + +#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" +#define NID_wap_wsg_idm_ecid_wtls1 735 +#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L + +#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" +#define NID_wap_wsg_idm_ecid_wtls3 736 +#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L + +#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" +#define NID_wap_wsg_idm_ecid_wtls4 737 +#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L + +#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" +#define NID_wap_wsg_idm_ecid_wtls5 738 +#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L + +#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" +#define NID_wap_wsg_idm_ecid_wtls6 739 +#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L + +#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" +#define NID_wap_wsg_idm_ecid_wtls7 740 +#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L + +#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" +#define NID_wap_wsg_idm_ecid_wtls8 741 +#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L + +#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" +#define NID_wap_wsg_idm_ecid_wtls9 742 +#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L + +#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" +#define NID_wap_wsg_idm_ecid_wtls10 743 +#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L + +#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" +#define NID_wap_wsg_idm_ecid_wtls11 744 +#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L + +#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" +#define NID_wap_wsg_idm_ecid_wtls12 745 +#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L + +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L + +#define SN_rsadsi "rsadsi" +#define LN_rsadsi "RSA Data Security, Inc." +#define NID_rsadsi 1 +#define OBJ_rsadsi OBJ_ISO_US,113549L + +#define SN_pkcs "pkcs" +#define LN_pkcs "RSA Data Security, Inc. PKCS" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_pkcs1 "pkcs1" +#define NID_pkcs1 186 +#define OBJ_pkcs1 OBJ_pkcs,1L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs1,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L + +#define SN_md4WithRSAEncryption "RSA-MD4" +#define LN_md4WithRSAEncryption "md4WithRSAEncryption" +#define NID_md4WithRSAEncryption 396 +#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L + +#define SN_sha256WithRSAEncryption "RSA-SHA256" +#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" +#define NID_sha256WithRSAEncryption 668 +#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L + +#define SN_sha384WithRSAEncryption "RSA-SHA384" +#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" +#define NID_sha384WithRSAEncryption 669 +#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L + +#define SN_sha512WithRSAEncryption "RSA-SHA512" +#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" +#define NID_sha512WithRSAEncryption 670 +#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L + +#define SN_sha224WithRSAEncryption "RSA-SHA224" +#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" +#define NID_sha224WithRSAEncryption 671 +#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L + +#define SN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_pkcs5 "pkcs5" +#define NID_pkcs5 187 +#define OBJ_pkcs5 OBJ_pkcs,5L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L + +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L + +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs5,12L + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs5,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs5,14L + +#define SN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define SN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_ext_req "extReq" +#define LN_ext_req "Extension Request" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_SMIME "SMIME" +#define LN_SMIME "S/MIME" +#define NID_SMIME 188 +#define OBJ_SMIME OBJ_pkcs9,16L + +#define SN_id_smime_mod "id-smime-mod" +#define NID_id_smime_mod 189 +#define OBJ_id_smime_mod OBJ_SMIME,0L + +#define SN_id_smime_ct "id-smime-ct" +#define NID_id_smime_ct 190 +#define OBJ_id_smime_ct OBJ_SMIME,1L + +#define SN_id_smime_aa "id-smime-aa" +#define NID_id_smime_aa 191 +#define OBJ_id_smime_aa OBJ_SMIME,2L + +#define SN_id_smime_alg "id-smime-alg" +#define NID_id_smime_alg 192 +#define OBJ_id_smime_alg OBJ_SMIME,3L + +#define SN_id_smime_cd "id-smime-cd" +#define NID_id_smime_cd 193 +#define OBJ_id_smime_cd OBJ_SMIME,4L + +#define SN_id_smime_spq "id-smime-spq" +#define NID_id_smime_spq 194 +#define OBJ_id_smime_spq OBJ_SMIME,5L + +#define SN_id_smime_cti "id-smime-cti" +#define NID_id_smime_cti 195 +#define OBJ_id_smime_cti OBJ_SMIME,6L + +#define SN_id_smime_mod_cms "id-smime-mod-cms" +#define NID_id_smime_mod_cms 196 +#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L + +#define SN_id_smime_mod_ess "id-smime-mod-ess" +#define NID_id_smime_mod_ess 197 +#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L + +#define SN_id_smime_mod_oid "id-smime-mod-oid" +#define NID_id_smime_mod_oid 198 +#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L + +#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" +#define NID_id_smime_mod_msg_v3 199 +#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L + +#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" +#define NID_id_smime_mod_ets_eSignature_88 200 +#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L + +#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" +#define NID_id_smime_mod_ets_eSignature_97 201 +#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L + +#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" +#define NID_id_smime_mod_ets_eSigPolicy_88 202 +#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L + +#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" +#define NID_id_smime_mod_ets_eSigPolicy_97 203 +#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L + +#define SN_id_smime_ct_receipt "id-smime-ct-receipt" +#define NID_id_smime_ct_receipt 204 +#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L + +#define SN_id_smime_ct_authData "id-smime-ct-authData" +#define NID_id_smime_ct_authData 205 +#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L + +#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" +#define NID_id_smime_ct_publishCert 206 +#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L + +#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" +#define NID_id_smime_ct_TSTInfo 207 +#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L + +#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" +#define NID_id_smime_ct_TDTInfo 208 +#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L + +#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" +#define NID_id_smime_ct_contentInfo 209 +#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L + +#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" +#define NID_id_smime_ct_DVCSRequestData 210 +#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L + +#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" +#define NID_id_smime_ct_DVCSResponseData 211 +#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L + +#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" +#define NID_id_smime_aa_receiptRequest 212 +#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L + +#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" +#define NID_id_smime_aa_securityLabel 213 +#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L + +#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" +#define NID_id_smime_aa_mlExpandHistory 214 +#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L + +#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" +#define NID_id_smime_aa_contentHint 215 +#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L + +#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" +#define NID_id_smime_aa_msgSigDigest 216 +#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L + +#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" +#define NID_id_smime_aa_encapContentType 217 +#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L + +#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" +#define NID_id_smime_aa_contentIdentifier 218 +#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L + +#define SN_id_smime_aa_macValue "id-smime-aa-macValue" +#define NID_id_smime_aa_macValue 219 +#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L + +#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" +#define NID_id_smime_aa_equivalentLabels 220 +#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L + +#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" +#define NID_id_smime_aa_contentReference 221 +#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L + +#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" +#define NID_id_smime_aa_encrypKeyPref 222 +#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L + +#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" +#define NID_id_smime_aa_signingCertificate 223 +#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L + +#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" +#define NID_id_smime_aa_smimeEncryptCerts 224 +#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L + +#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" +#define NID_id_smime_aa_timeStampToken 225 +#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L + +#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" +#define NID_id_smime_aa_ets_sigPolicyId 226 +#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L + +#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" +#define NID_id_smime_aa_ets_commitmentType 227 +#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L + +#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" +#define NID_id_smime_aa_ets_signerLocation 228 +#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L + +#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" +#define NID_id_smime_aa_ets_signerAttr 229 +#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L + +#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" +#define NID_id_smime_aa_ets_otherSigCert 230 +#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L + +#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" +#define NID_id_smime_aa_ets_contentTimestamp 231 +#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L + +#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" +#define NID_id_smime_aa_ets_CertificateRefs 232 +#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L + +#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" +#define NID_id_smime_aa_ets_RevocationRefs 233 +#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L + +#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" +#define NID_id_smime_aa_ets_certValues 234 +#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L + +#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" +#define NID_id_smime_aa_ets_revocationValues 235 +#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L + +#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" +#define NID_id_smime_aa_ets_escTimeStamp 236 +#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L + +#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" +#define NID_id_smime_aa_ets_certCRLTimestamp 237 +#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L + +#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" +#define NID_id_smime_aa_ets_archiveTimeStamp 238 +#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L + +#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" +#define NID_id_smime_aa_signatureType 239 +#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L + +#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" +#define NID_id_smime_aa_dvcs_dvc 240 +#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L + +#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" +#define NID_id_smime_alg_ESDHwith3DES 241 +#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L + +#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" +#define NID_id_smime_alg_ESDHwithRC2 242 +#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L + +#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" +#define NID_id_smime_alg_3DESwrap 243 +#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L + +#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" +#define NID_id_smime_alg_RC2wrap 244 +#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L + +#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" +#define NID_id_smime_alg_ESDH 245 +#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L + +#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" +#define NID_id_smime_alg_CMS3DESwrap 246 +#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L + +#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" +#define NID_id_smime_alg_CMSRC2wrap 247 +#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L + +#define SN_id_smime_cd_ldap "id-smime-cd-ldap" +#define NID_id_smime_cd_ldap 248 +#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L + +#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" +#define NID_id_smime_spq_ets_sqt_uri 249 +#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L + +#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" +#define NID_id_smime_spq_ets_sqt_unotice 250 +#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L + +#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" +#define NID_id_smime_cti_ets_proofOfOrigin 251 +#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L + +#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" +#define NID_id_smime_cti_ets_proofOfReceipt 252 +#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L + +#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" +#define NID_id_smime_cti_ets_proofOfDelivery 253 +#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L + +#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" +#define NID_id_smime_cti_ets_proofOfSender 254 +#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L + +#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" +#define NID_id_smime_cti_ets_proofOfApproval 255 +#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L + +#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" +#define NID_id_smime_cti_ets_proofOfCreation 256 +#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9,20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9,21L + +#define SN_ms_csp_name "CSPName" +#define LN_ms_csp_name "Microsoft CSP Name" +#define NID_ms_csp_name 417 +#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L + +#define OBJ_certTypes OBJ_pkcs9,22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes,1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes,2L + +#define OBJ_crlTypes OBJ_pkcs9,23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes,1L + +#define OBJ_pkcs12 OBJ_pkcs,12L + +#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds,1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds,3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds,4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds,5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md4 "MD4" +#define LN_md4 "md4" +#define NID_md4 257 +#define OBJ_md4 OBJ_rsadsi,2L,4L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" +#define NID_md5_sha1 114 + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_ms_ext_req "msExtReq" +#define LN_ms_ext_req "Microsoft Extension Request" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +#define SN_ms_smartcard_login "msSmartcardLogin" +#define LN_ms_smartcard_login "Microsoft Smartcardlogin" +#define NID_ms_smartcard_login 648 +#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L + +#define SN_ms_upn "msUPN" +#define LN_ms_upn "Microsoft Universal Principal Name" +#define NID_ms_upn 649 +#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_pkix_mod "id-pkix-mod" +#define NID_id_pkix_mod 258 +#define OBJ_id_pkix_mod OBJ_id_pkix,0L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_qt "id-qt" +#define NID_id_qt 259 +#define OBJ_id_qt OBJ_id_pkix,2L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +#define SN_id_it "id-it" +#define NID_id_it 260 +#define OBJ_id_it OBJ_id_pkix,4L + +#define SN_id_pkip "id-pkip" +#define NID_id_pkip 261 +#define OBJ_id_pkip OBJ_id_pkix,5L + +#define SN_id_alg "id-alg" +#define NID_id_alg 262 +#define OBJ_id_alg OBJ_id_pkix,6L + +#define SN_id_cmc "id-cmc" +#define NID_id_cmc 263 +#define OBJ_id_cmc OBJ_id_pkix,7L + +#define SN_id_on "id-on" +#define NID_id_on 264 +#define OBJ_id_on OBJ_id_pkix,8L + +#define SN_id_pda "id-pda" +#define NID_id_pda 265 +#define OBJ_id_pda OBJ_id_pkix,9L + +#define SN_id_aca "id-aca" +#define NID_id_aca 266 +#define OBJ_id_aca OBJ_id_pkix,10L + +#define SN_id_qcs "id-qcs" +#define NID_id_qcs 267 +#define OBJ_id_qcs OBJ_id_pkix,11L + +#define SN_id_cct "id-cct" +#define NID_id_cct 268 +#define OBJ_id_cct OBJ_id_pkix,12L + +#define SN_id_ppl "id-ppl" +#define NID_id_ppl 662 +#define OBJ_id_ppl OBJ_id_pkix,21L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" +#define NID_id_pkix1_explicit_88 269 +#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L + +#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" +#define NID_id_pkix1_implicit_88 270 +#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L + +#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" +#define NID_id_pkix1_explicit_93 271 +#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L + +#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" +#define NID_id_pkix1_implicit_93 272 +#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L + +#define SN_id_mod_crmf "id-mod-crmf" +#define NID_id_mod_crmf 273 +#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L + +#define SN_id_mod_cmc "id-mod-cmc" +#define NID_id_mod_cmc 274 +#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L + +#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" +#define NID_id_mod_kea_profile_88 275 +#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L + +#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" +#define NID_id_mod_kea_profile_93 276 +#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L + +#define SN_id_mod_cmp "id-mod-cmp" +#define NID_id_mod_cmp 277 +#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L + +#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" +#define NID_id_mod_qualified_cert_88 278 +#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L + +#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" +#define NID_id_mod_qualified_cert_93 279 +#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L + +#define SN_id_mod_attribute_cert "id-mod-attribute-cert" +#define NID_id_mod_attribute_cert 280 +#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L + +#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" +#define NID_id_mod_timestamp_protocol 281 +#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L + +#define SN_id_mod_ocsp "id-mod-ocsp" +#define NID_id_mod_ocsp 282 +#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L + +#define SN_id_mod_dvcs "id-mod-dvcs" +#define NID_id_mod_dvcs 283 +#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L + +#define SN_id_mod_cmp2000 "id-mod-cmp2000" +#define NID_id_mod_cmp2000 284 +#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_biometricInfo "biometricInfo" +#define LN_biometricInfo "Biometric Info" +#define NID_biometricInfo 285 +#define OBJ_biometricInfo OBJ_id_pe,2L + +#define SN_qcStatements "qcStatements" +#define NID_qcStatements 286 +#define OBJ_qcStatements OBJ_id_pe,3L + +#define SN_ac_auditEntity "ac-auditEntity" +#define NID_ac_auditEntity 287 +#define OBJ_ac_auditEntity OBJ_id_pe,4L + +#define SN_ac_targeting "ac-targeting" +#define NID_ac_targeting 288 +#define OBJ_ac_targeting OBJ_id_pe,5L + +#define SN_aaControls "aaControls" +#define NID_aaControls 289 +#define OBJ_aaControls OBJ_id_pe,6L + +#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" +#define NID_sbgp_ipAddrBlock 290 +#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L + +#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" +#define NID_sbgp_autonomousSysNum 291 +#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L + +#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" +#define NID_sbgp_routerIdentifier 292 +#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L + +#define SN_ac_proxying "ac-proxying" +#define NID_ac_proxying 397 +#define OBJ_ac_proxying OBJ_id_pe,10L + +#define SN_sinfo_access "subjectInfoAccess" +#define LN_sinfo_access "Subject Information Access" +#define NID_sinfo_access 398 +#define OBJ_sinfo_access OBJ_id_pe,11L + +#define SN_proxyCertInfo "proxyCertInfo" +#define LN_proxyCertInfo "Proxy Certificate Information" +#define NID_proxyCertInfo 663 +#define OBJ_proxyCertInfo OBJ_id_pe,14L + +#define SN_id_qt_cps "id-qt-cps" +#define LN_id_qt_cps "Policy Qualifier CPS" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_qt,1L + +#define SN_id_qt_unotice "id-qt-unotice" +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_qt,2L + +#define SN_textNotice "textNotice" +#define NID_textNotice 293 +#define OBJ_textNotice OBJ_id_qt,3L + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_ipsecEndSystem "ipsecEndSystem" +#define LN_ipsecEndSystem "IPSec End System" +#define NID_ipsecEndSystem 294 +#define OBJ_ipsecEndSystem OBJ_id_kp,5L + +#define SN_ipsecTunnel "ipsecTunnel" +#define LN_ipsecTunnel "IPSec Tunnel" +#define NID_ipsecTunnel 295 +#define OBJ_ipsecTunnel OBJ_id_kp,6L + +#define SN_ipsecUser "ipsecUser" +#define LN_ipsecUser "IPSec User" +#define NID_ipsecUser 296 +#define OBJ_ipsecUser OBJ_id_kp,7L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L + +#define SN_dvcs "DVCS" +#define LN_dvcs "dvcs" +#define NID_dvcs 297 +#define OBJ_dvcs OBJ_id_kp,10L + +#define SN_id_it_caProtEncCert "id-it-caProtEncCert" +#define NID_id_it_caProtEncCert 298 +#define OBJ_id_it_caProtEncCert OBJ_id_it,1L + +#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" +#define NID_id_it_signKeyPairTypes 299 +#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L + +#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" +#define NID_id_it_encKeyPairTypes 300 +#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L + +#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" +#define NID_id_it_preferredSymmAlg 301 +#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L + +#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" +#define NID_id_it_caKeyUpdateInfo 302 +#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L + +#define SN_id_it_currentCRL "id-it-currentCRL" +#define NID_id_it_currentCRL 303 +#define OBJ_id_it_currentCRL OBJ_id_it,6L + +#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" +#define NID_id_it_unsupportedOIDs 304 +#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L + +#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" +#define NID_id_it_subscriptionRequest 305 +#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L + +#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" +#define NID_id_it_subscriptionResponse 306 +#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L + +#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" +#define NID_id_it_keyPairParamReq 307 +#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L + +#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" +#define NID_id_it_keyPairParamRep 308 +#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L + +#define SN_id_it_revPassphrase "id-it-revPassphrase" +#define NID_id_it_revPassphrase 309 +#define OBJ_id_it_revPassphrase OBJ_id_it,12L + +#define SN_id_it_implicitConfirm "id-it-implicitConfirm" +#define NID_id_it_implicitConfirm 310 +#define OBJ_id_it_implicitConfirm OBJ_id_it,13L + +#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" +#define NID_id_it_confirmWaitTime 311 +#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L + +#define SN_id_it_origPKIMessage "id-it-origPKIMessage" +#define NID_id_it_origPKIMessage 312 +#define OBJ_id_it_origPKIMessage OBJ_id_it,15L + +#define SN_id_regCtrl "id-regCtrl" +#define NID_id_regCtrl 313 +#define OBJ_id_regCtrl OBJ_id_pkip,1L + +#define SN_id_regInfo "id-regInfo" +#define NID_id_regInfo 314 +#define OBJ_id_regInfo OBJ_id_pkip,2L + +#define SN_id_regCtrl_regToken "id-regCtrl-regToken" +#define NID_id_regCtrl_regToken 315 +#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L + +#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" +#define NID_id_regCtrl_authenticator 316 +#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L + +#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" +#define NID_id_regCtrl_pkiPublicationInfo 317 +#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L + +#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" +#define NID_id_regCtrl_pkiArchiveOptions 318 +#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L + +#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" +#define NID_id_regCtrl_oldCertID 319 +#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L + +#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" +#define NID_id_regCtrl_protocolEncrKey 320 +#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L + +#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" +#define NID_id_regInfo_utf8Pairs 321 +#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L + +#define SN_id_regInfo_certReq "id-regInfo-certReq" +#define NID_id_regInfo_certReq 322 +#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L + +#define SN_id_alg_des40 "id-alg-des40" +#define NID_id_alg_des40 323 +#define OBJ_id_alg_des40 OBJ_id_alg,1L + +#define SN_id_alg_noSignature "id-alg-noSignature" +#define NID_id_alg_noSignature 324 +#define OBJ_id_alg_noSignature OBJ_id_alg,2L + +#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" +#define NID_id_alg_dh_sig_hmac_sha1 325 +#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L + +#define SN_id_alg_dh_pop "id-alg-dh-pop" +#define NID_id_alg_dh_pop 326 +#define OBJ_id_alg_dh_pop OBJ_id_alg,4L + +#define SN_id_cmc_statusInfo "id-cmc-statusInfo" +#define NID_id_cmc_statusInfo 327 +#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L + +#define SN_id_cmc_identification "id-cmc-identification" +#define NID_id_cmc_identification 328 +#define OBJ_id_cmc_identification OBJ_id_cmc,2L + +#define SN_id_cmc_identityProof "id-cmc-identityProof" +#define NID_id_cmc_identityProof 329 +#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L + +#define SN_id_cmc_dataReturn "id-cmc-dataReturn" +#define NID_id_cmc_dataReturn 330 +#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L + +#define SN_id_cmc_transactionId "id-cmc-transactionId" +#define NID_id_cmc_transactionId 331 +#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L + +#define SN_id_cmc_senderNonce "id-cmc-senderNonce" +#define NID_id_cmc_senderNonce 332 +#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L + +#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" +#define NID_id_cmc_recipientNonce 333 +#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L + +#define SN_id_cmc_addExtensions "id-cmc-addExtensions" +#define NID_id_cmc_addExtensions 334 +#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L + +#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" +#define NID_id_cmc_encryptedPOP 335 +#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L + +#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" +#define NID_id_cmc_decryptedPOP 336 +#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L + +#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" +#define NID_id_cmc_lraPOPWitness 337 +#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L + +#define SN_id_cmc_getCert "id-cmc-getCert" +#define NID_id_cmc_getCert 338 +#define OBJ_id_cmc_getCert OBJ_id_cmc,15L + +#define SN_id_cmc_getCRL "id-cmc-getCRL" +#define NID_id_cmc_getCRL 339 +#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L + +#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" +#define NID_id_cmc_revokeRequest 340 +#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L + +#define SN_id_cmc_regInfo "id-cmc-regInfo" +#define NID_id_cmc_regInfo 341 +#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L + +#define SN_id_cmc_responseInfo "id-cmc-responseInfo" +#define NID_id_cmc_responseInfo 342 +#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L + +#define SN_id_cmc_queryPending "id-cmc-queryPending" +#define NID_id_cmc_queryPending 343 +#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L + +#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" +#define NID_id_cmc_popLinkRandom 344 +#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L + +#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" +#define NID_id_cmc_popLinkWitness 345 +#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L + +#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" +#define NID_id_cmc_confirmCertAcceptance 346 +#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L + +#define SN_id_on_personalData "id-on-personalData" +#define NID_id_on_personalData 347 +#define OBJ_id_on_personalData OBJ_id_on,1L + +#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" +#define NID_id_pda_dateOfBirth 348 +#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L + +#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" +#define NID_id_pda_placeOfBirth 349 +#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L + +#define SN_id_pda_gender "id-pda-gender" +#define NID_id_pda_gender 351 +#define OBJ_id_pda_gender OBJ_id_pda,3L + +#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" +#define NID_id_pda_countryOfCitizenship 352 +#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L + +#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" +#define NID_id_pda_countryOfResidence 353 +#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L + +#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" +#define NID_id_aca_authenticationInfo 354 +#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L + +#define SN_id_aca_accessIdentity "id-aca-accessIdentity" +#define NID_id_aca_accessIdentity 355 +#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L + +#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" +#define NID_id_aca_chargingIdentity 356 +#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L + +#define SN_id_aca_group "id-aca-group" +#define NID_id_aca_group 357 +#define OBJ_id_aca_group OBJ_id_aca,4L + +#define SN_id_aca_role "id-aca-role" +#define NID_id_aca_role 358 +#define OBJ_id_aca_role OBJ_id_aca,5L + +#define SN_id_aca_encAttrs "id-aca-encAttrs" +#define NID_id_aca_encAttrs 399 +#define OBJ_id_aca_encAttrs OBJ_id_aca,6L + +#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" +#define NID_id_qcs_pkixQCSyntax_v1 359 +#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L + +#define SN_id_cct_crs "id-cct-crs" +#define NID_id_cct_crs 360 +#define OBJ_id_cct_crs OBJ_id_cct,1L + +#define SN_id_cct_PKIData "id-cct-PKIData" +#define NID_id_cct_PKIData 361 +#define OBJ_id_cct_PKIData OBJ_id_cct,2L + +#define SN_id_cct_PKIResponse "id-cct-PKIResponse" +#define NID_id_cct_PKIResponse 362 +#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L + +#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" +#define LN_id_ppl_anyLanguage "Any language" +#define NID_id_ppl_anyLanguage 664 +#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L + +#define SN_id_ppl_inheritAll "id-ppl-inheritAll" +#define LN_id_ppl_inheritAll "Inherit all" +#define NID_id_ppl_inheritAll 665 +#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L + +#define SN_Independent "id-ppl-independent" +#define LN_Independent "Independent" +#define NID_Independent 667 +#define OBJ_Independent OBJ_id_ppl,2L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_ad_timeStamping "ad_timestamping" +#define LN_ad_timeStamping "AD Time Stamping" +#define NID_ad_timeStamping 363 +#define OBJ_ad_timeStamping OBJ_id_ad,3L + +#define SN_ad_dvcs "AD_DVCS" +#define LN_ad_dvcs "ad dvcs" +#define NID_ad_dvcs 364 +#define OBJ_ad_dvcs OBJ_id_ad,4L + +#define OBJ_id_pkix_OCSP OBJ_ad_OCSP + +#define SN_id_pkix_OCSP_basic "basicOCSPResponse" +#define LN_id_pkix_OCSP_basic "Basic OCSP Response" +#define NID_id_pkix_OCSP_basic 365 +#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L + +#define SN_id_pkix_OCSP_Nonce "Nonce" +#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" +#define NID_id_pkix_OCSP_Nonce 366 +#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L + +#define SN_id_pkix_OCSP_CrlID "CrlID" +#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" +#define NID_id_pkix_OCSP_CrlID 367 +#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L + +#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" +#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" +#define NID_id_pkix_OCSP_acceptableResponses 368 +#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L + +#define SN_id_pkix_OCSP_noCheck "noCheck" +#define LN_id_pkix_OCSP_noCheck "OCSP No Check" +#define NID_id_pkix_OCSP_noCheck 369 +#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L + +#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" +#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" +#define NID_id_pkix_OCSP_archiveCutoff 370 +#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L + +#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" +#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" +#define NID_id_pkix_OCSP_serviceLocator 371 +#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L + +#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" +#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" +#define NID_id_pkix_OCSP_extendedStatus 372 +#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L + +#define SN_id_pkix_OCSP_valid "valid" +#define NID_id_pkix_OCSP_valid 373 +#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L + +#define SN_id_pkix_OCSP_path "path" +#define NID_id_pkix_OCSP_path 374 +#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L + +#define SN_id_pkix_OCSP_trustRoot "trustRoot" +#define LN_id_pkix_OCSP_trustRoot "Trust Root" +#define NID_id_pkix_OCSP_trustRoot 375 +#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L + +#define SN_algorithm "algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 376 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_rsaSignature "rsaSignature" +#define NID_rsaSignature 377 +#define OBJ_rsaSignature OBJ_algorithm,11L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_ecb "DES-EDE" +#define LN_des_ede_ecb "des-ede" +#define NID_des_ede_ecb 32 +#define OBJ_des_ede_ecb OBJ_algorithm,17L + +#define SN_des_ede3_ecb "DES-EDE3" +#define LN_des_ede3_ecb "des-ede3" +#define NID_des_ede3_ecb 33 + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +#define SN_X500 "X500" +#define LN_X500 "directory services (X.500)" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define SN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_surname "SN" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define LN_streetAddress "streetAddress" +#define NID_streetAddress 660 +#define OBJ_streetAddress OBJ_X509,9L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +#define LN_postalCode "postalCode" +#define NID_postalCode 661 +#define OBJ_postalCode OBJ_X509,17L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_givenName "GN" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define LN_generationQualifier "generationQualifier" +#define NID_generationQualifier 509 +#define OBJ_generationQualifier OBJ_X509,44L + +#define LN_x500UniqueIdentifier "x500UniqueIdentifier" +#define NID_x500UniqueIdentifier 503 +#define OBJ_x500UniqueIdentifier OBJ_X509,45L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define LN_pseudonym "pseudonym" +#define NID_pseudonym 510 +#define OBJ_pseudonym OBJ_X509,65L + +#define SN_role "role" +#define LN_role "role" +#define NID_role 400 +#define OBJ_role OBJ_X509,72L + +#define SN_X500algorithms "X500algorithms" +#define LN_X500algorithms "directory services - algorithms" +#define NID_X500algorithms 378 +#define OBJ_X500algorithms OBJ_X500,8L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500algorithms,1L,1L + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2WithRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 OBJ_X500algorithms,3L,101L + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce OBJ_X500,29L + +#define SN_subject_directory_attributes "subjectDirectoryAttributes" +#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" +#define NID_subject_directory_attributes 769 +#define OBJ_subject_directory_attributes OBJ_id_ce,9L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "X509v3 CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_issuing_distribution_point "issuingDistributionPoint" +#define LN_issuing_distribution_point "X509v3 Issuing Distrubution Point" +#define NID_issuing_distribution_point 770 +#define OBJ_issuing_distribution_point OBJ_id_ce,28L + +#define SN_certificate_issuer "certificateIssuer" +#define LN_certificate_issuer "X509v3 Certificate Issuer" +#define NID_certificate_issuer 771 +#define OBJ_certificate_issuer OBJ_id_ce,29L + +#define SN_name_constraints "nameConstraints" +#define LN_name_constraints "X509v3 Name Constraints" +#define NID_name_constraints 666 +#define OBJ_name_constraints OBJ_id_ce,30L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_any_policy "anyPolicy" +#define LN_any_policy "X509v3 Any Policy" +#define NID_any_policy 746 +#define OBJ_any_policy OBJ_certificate_policies,0L + +#define SN_policy_mappings "policyMappings" +#define LN_policy_mappings "X509v3 Policy Mappings" +#define NID_policy_mappings 747 +#define OBJ_policy_mappings OBJ_id_ce,33L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_policy_constraints "policyConstraints" +#define LN_policy_constraints "X509v3 Policy Constraints" +#define NID_policy_constraints 401 +#define OBJ_policy_constraints OBJ_id_ce,36L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37L + +#define SN_inhibit_any_policy "inhibitAnyPolicy" +#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" +#define NID_inhibit_any_policy 748 +#define OBJ_inhibit_any_policy OBJ_id_ce,54L + +#define SN_target_information "targetInformation" +#define LN_target_information "X509v3 AC Targeting" +#define NID_target_information 402 +#define OBJ_target_information OBJ_id_ce,55L + +#define SN_no_rev_avail "noRevAvail" +#define LN_no_rev_avail "X509v3 No Revocation Available" +#define NID_no_rev_avail 403 +#define OBJ_no_rev_avail OBJ_id_ce,56L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_org "ORG" +#define LN_org "org" +#define NID_org 379 +#define OBJ_org OBJ_iso,3L + +#define SN_dod "DOD" +#define LN_dod "dod" +#define NID_dod 380 +#define OBJ_dod OBJ_org,6L + +#define SN_iana "IANA" +#define LN_iana "iana" +#define NID_iana 381 +#define OBJ_iana OBJ_dod,1L + +#define OBJ_internet OBJ_iana + +#define SN_Directory "directory" +#define LN_Directory "Directory" +#define NID_Directory 382 +#define OBJ_Directory OBJ_internet,1L + +#define SN_Management "mgmt" +#define LN_Management "Management" +#define NID_Management 383 +#define OBJ_Management OBJ_internet,2L + +#define SN_Experimental "experimental" +#define LN_Experimental "Experimental" +#define NID_Experimental 384 +#define OBJ_Experimental OBJ_internet,3L + +#define SN_Private "private" +#define LN_Private "Private" +#define NID_Private 385 +#define OBJ_Private OBJ_internet,4L + +#define SN_Security "security" +#define LN_Security "Security" +#define NID_Security 386 +#define OBJ_Security OBJ_internet,5L + +#define SN_SNMPv2 "snmpv2" +#define LN_SNMPv2 "SNMPv2" +#define NID_SNMPv2 387 +#define OBJ_SNMPv2 OBJ_internet,6L + +#define LN_Mail "Mail" +#define NID_Mail 388 +#define OBJ_Mail OBJ_internet,7L + +#define SN_Enterprises "enterprises" +#define LN_Enterprises "Enterprises" +#define NID_Enterprises 389 +#define OBJ_Enterprises OBJ_Private,1L + +#define SN_dcObject "dcobject" +#define LN_dcObject "dcObject" +#define NID_dcObject 390 +#define OBJ_dcObject OBJ_Enterprises,1466L,344L + +#define SN_mime_mhs "mime-mhs" +#define LN_mime_mhs "MIME MHS" +#define NID_mime_mhs 504 +#define OBJ_mime_mhs OBJ_Mail,1L + +#define SN_mime_mhs_headings "mime-mhs-headings" +#define LN_mime_mhs_headings "mime-mhs-headings" +#define NID_mime_mhs_headings 505 +#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L + +#define SN_mime_mhs_bodies "mime-mhs-bodies" +#define LN_mime_mhs_bodies "mime-mhs-bodies" +#define NID_mime_mhs_bodies 506 +#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L + +#define SN_id_hex_partial_message "id-hex-partial-message" +#define LN_id_hex_partial_message "id-hex-partial-message" +#define NID_id_hex_partial_message 507 +#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L + +#define SN_id_hex_multipart_message "id-hex-multipart-message" +#define LN_id_hex_multipart_message "id-hex-multipart-message" +#define NID_id_hex_multipart_message 508 +#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define OBJ_csor 2L,16L,840L,1L,101L,3L + +#define OBJ_nistAlgorithms OBJ_csor,4L + +#define OBJ_aes OBJ_nistAlgorithms,1L + +#define SN_aes_128_ecb "AES-128-ECB" +#define LN_aes_128_ecb "aes-128-ecb" +#define NID_aes_128_ecb 418 +#define OBJ_aes_128_ecb OBJ_aes,1L + +#define SN_aes_128_cbc "AES-128-CBC" +#define LN_aes_128_cbc "aes-128-cbc" +#define NID_aes_128_cbc 419 +#define OBJ_aes_128_cbc OBJ_aes,2L + +#define SN_aes_128_ofb128 "AES-128-OFB" +#define LN_aes_128_ofb128 "aes-128-ofb" +#define NID_aes_128_ofb128 420 +#define OBJ_aes_128_ofb128 OBJ_aes,3L + +#define SN_aes_128_cfb128 "AES-128-CFB" +#define LN_aes_128_cfb128 "aes-128-cfb" +#define NID_aes_128_cfb128 421 +#define OBJ_aes_128_cfb128 OBJ_aes,4L + +#define SN_aes_192_ecb "AES-192-ECB" +#define LN_aes_192_ecb "aes-192-ecb" +#define NID_aes_192_ecb 422 +#define OBJ_aes_192_ecb OBJ_aes,21L + +#define SN_aes_192_cbc "AES-192-CBC" +#define LN_aes_192_cbc "aes-192-cbc" +#define NID_aes_192_cbc 423 +#define OBJ_aes_192_cbc OBJ_aes,22L + +#define SN_aes_192_ofb128 "AES-192-OFB" +#define LN_aes_192_ofb128 "aes-192-ofb" +#define NID_aes_192_ofb128 424 +#define OBJ_aes_192_ofb128 OBJ_aes,23L + +#define SN_aes_192_cfb128 "AES-192-CFB" +#define LN_aes_192_cfb128 "aes-192-cfb" +#define NID_aes_192_cfb128 425 +#define OBJ_aes_192_cfb128 OBJ_aes,24L + +#define SN_aes_256_ecb "AES-256-ECB" +#define LN_aes_256_ecb "aes-256-ecb" +#define NID_aes_256_ecb 426 +#define OBJ_aes_256_ecb OBJ_aes,41L + +#define SN_aes_256_cbc "AES-256-CBC" +#define LN_aes_256_cbc "aes-256-cbc" +#define NID_aes_256_cbc 427 +#define OBJ_aes_256_cbc OBJ_aes,42L + +#define SN_aes_256_ofb128 "AES-256-OFB" +#define LN_aes_256_ofb128 "aes-256-ofb" +#define NID_aes_256_ofb128 428 +#define OBJ_aes_256_ofb128 OBJ_aes,43L + +#define SN_aes_256_cfb128 "AES-256-CFB" +#define LN_aes_256_cfb128 "aes-256-cfb" +#define NID_aes_256_cfb128 429 +#define OBJ_aes_256_cfb128 OBJ_aes,44L + +#define SN_aes_128_cfb1 "AES-128-CFB1" +#define LN_aes_128_cfb1 "aes-128-cfb1" +#define NID_aes_128_cfb1 650 + +#define SN_aes_192_cfb1 "AES-192-CFB1" +#define LN_aes_192_cfb1 "aes-192-cfb1" +#define NID_aes_192_cfb1 651 + +#define SN_aes_256_cfb1 "AES-256-CFB1" +#define LN_aes_256_cfb1 "aes-256-cfb1" +#define NID_aes_256_cfb1 652 + +#define SN_aes_128_cfb8 "AES-128-CFB8" +#define LN_aes_128_cfb8 "aes-128-cfb8" +#define NID_aes_128_cfb8 653 + +#define SN_aes_192_cfb8 "AES-192-CFB8" +#define LN_aes_192_cfb8 "aes-192-cfb8" +#define NID_aes_192_cfb8 654 + +#define SN_aes_256_cfb8 "AES-256-CFB8" +#define LN_aes_256_cfb8 "aes-256-cfb8" +#define NID_aes_256_cfb8 655 + +#define SN_des_cfb1 "DES-CFB1" +#define LN_des_cfb1 "des-cfb1" +#define NID_des_cfb1 656 + +#define SN_des_cfb8 "DES-CFB8" +#define LN_des_cfb8 "des-cfb8" +#define NID_des_cfb8 657 + +#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" +#define LN_des_ede3_cfb1 "des-ede3-cfb1" +#define NID_des_ede3_cfb1 658 + +#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" +#define LN_des_ede3_cfb8 "des-ede3-cfb8" +#define NID_des_ede3_cfb8 659 + +#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L + +#define SN_sha256 "SHA256" +#define LN_sha256 "sha256" +#define NID_sha256 672 +#define OBJ_sha256 OBJ_nist_hashalgs,1L + +#define SN_sha384 "SHA384" +#define LN_sha384 "sha384" +#define NID_sha384 673 +#define OBJ_sha384 OBJ_nist_hashalgs,2L + +#define SN_sha512 "SHA512" +#define LN_sha512 "sha512" +#define NID_sha512 674 +#define OBJ_sha512 OBJ_nist_hashalgs,3L + +#define SN_sha224 "SHA224" +#define LN_sha224 "sha224" +#define NID_sha224 675 +#define OBJ_sha224 OBJ_nist_hashalgs,4L + +#define SN_hold_instruction_code "holdInstructionCode" +#define LN_hold_instruction_code "Hold Instruction Code" +#define NID_hold_instruction_code 430 +#define OBJ_hold_instruction_code OBJ_id_ce,23L + +#define OBJ_holdInstruction OBJ_X9_57,2L + +#define SN_hold_instruction_none "holdInstructionNone" +#define LN_hold_instruction_none "Hold Instruction None" +#define NID_hold_instruction_none 431 +#define OBJ_hold_instruction_none OBJ_holdInstruction,1L + +#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" +#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" +#define NID_hold_instruction_call_issuer 432 +#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L + +#define SN_hold_instruction_reject "holdInstructionReject" +#define LN_hold_instruction_reject "Hold Instruction Reject" +#define NID_hold_instruction_reject 433 +#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L + +#define SN_data "data" +#define NID_data 434 +#define OBJ_data OBJ_itu_t,9L + +#define SN_pss "pss" +#define NID_pss 435 +#define OBJ_pss OBJ_data,2342L + +#define SN_ucl "ucl" +#define NID_ucl 436 +#define OBJ_ucl OBJ_pss,19200300L + +#define SN_pilot "pilot" +#define NID_pilot 437 +#define OBJ_pilot OBJ_ucl,100L + +#define LN_pilotAttributeType "pilotAttributeType" +#define NID_pilotAttributeType 438 +#define OBJ_pilotAttributeType OBJ_pilot,1L + +#define LN_pilotAttributeSyntax "pilotAttributeSyntax" +#define NID_pilotAttributeSyntax 439 +#define OBJ_pilotAttributeSyntax OBJ_pilot,3L + +#define LN_pilotObjectClass "pilotObjectClass" +#define NID_pilotObjectClass 440 +#define OBJ_pilotObjectClass OBJ_pilot,4L + +#define LN_pilotGroups "pilotGroups" +#define NID_pilotGroups 441 +#define OBJ_pilotGroups OBJ_pilot,10L + +#define LN_iA5StringSyntax "iA5StringSyntax" +#define NID_iA5StringSyntax 442 +#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L + +#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" +#define NID_caseIgnoreIA5StringSyntax 443 +#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L + +#define LN_pilotObject "pilotObject" +#define NID_pilotObject 444 +#define OBJ_pilotObject OBJ_pilotObjectClass,3L + +#define LN_pilotPerson "pilotPerson" +#define NID_pilotPerson 445 +#define OBJ_pilotPerson OBJ_pilotObjectClass,4L + +#define SN_account "account" +#define NID_account 446 +#define OBJ_account OBJ_pilotObjectClass,5L + +#define SN_document "document" +#define NID_document 447 +#define OBJ_document OBJ_pilotObjectClass,6L + +#define SN_room "room" +#define NID_room 448 +#define OBJ_room OBJ_pilotObjectClass,7L + +#define LN_documentSeries "documentSeries" +#define NID_documentSeries 449 +#define OBJ_documentSeries OBJ_pilotObjectClass,9L + +#define SN_Domain "domain" +#define LN_Domain "Domain" +#define NID_Domain 392 +#define OBJ_Domain OBJ_pilotObjectClass,13L + +#define LN_rFC822localPart "rFC822localPart" +#define NID_rFC822localPart 450 +#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L + +#define LN_dNSDomain "dNSDomain" +#define NID_dNSDomain 451 +#define OBJ_dNSDomain OBJ_pilotObjectClass,15L + +#define LN_domainRelatedObject "domainRelatedObject" +#define NID_domainRelatedObject 452 +#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L + +#define LN_friendlyCountry "friendlyCountry" +#define NID_friendlyCountry 453 +#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L + +#define LN_simpleSecurityObject "simpleSecurityObject" +#define NID_simpleSecurityObject 454 +#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L + +#define LN_pilotOrganization "pilotOrganization" +#define NID_pilotOrganization 455 +#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L + +#define LN_pilotDSA "pilotDSA" +#define NID_pilotDSA 456 +#define OBJ_pilotDSA OBJ_pilotObjectClass,21L + +#define LN_qualityLabelledData "qualityLabelledData" +#define NID_qualityLabelledData 457 +#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L + +#define SN_userId "UID" +#define LN_userId "userId" +#define NID_userId 458 +#define OBJ_userId OBJ_pilotAttributeType,1L + +#define LN_textEncodedORAddress "textEncodedORAddress" +#define NID_textEncodedORAddress 459 +#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L + +#define SN_rfc822Mailbox "mail" +#define LN_rfc822Mailbox "rfc822Mailbox" +#define NID_rfc822Mailbox 460 +#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L + +#define SN_info "info" +#define NID_info 461 +#define OBJ_info OBJ_pilotAttributeType,4L + +#define LN_favouriteDrink "favouriteDrink" +#define NID_favouriteDrink 462 +#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L + +#define LN_roomNumber "roomNumber" +#define NID_roomNumber 463 +#define OBJ_roomNumber OBJ_pilotAttributeType,6L + +#define SN_photo "photo" +#define NID_photo 464 +#define OBJ_photo OBJ_pilotAttributeType,7L + +#define LN_userClass "userClass" +#define NID_userClass 465 +#define OBJ_userClass OBJ_pilotAttributeType,8L + +#define SN_host "host" +#define NID_host 466 +#define OBJ_host OBJ_pilotAttributeType,9L + +#define SN_manager "manager" +#define NID_manager 467 +#define OBJ_manager OBJ_pilotAttributeType,10L + +#define LN_documentIdentifier "documentIdentifier" +#define NID_documentIdentifier 468 +#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L + +#define LN_documentTitle "documentTitle" +#define NID_documentTitle 469 +#define OBJ_documentTitle OBJ_pilotAttributeType,12L + +#define LN_documentVersion "documentVersion" +#define NID_documentVersion 470 +#define OBJ_documentVersion OBJ_pilotAttributeType,13L + +#define LN_documentAuthor "documentAuthor" +#define NID_documentAuthor 471 +#define OBJ_documentAuthor OBJ_pilotAttributeType,14L + +#define LN_documentLocation "documentLocation" +#define NID_documentLocation 472 +#define OBJ_documentLocation OBJ_pilotAttributeType,15L + +#define LN_homeTelephoneNumber "homeTelephoneNumber" +#define NID_homeTelephoneNumber 473 +#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L + +#define SN_secretary "secretary" +#define NID_secretary 474 +#define OBJ_secretary OBJ_pilotAttributeType,21L + +#define LN_otherMailbox "otherMailbox" +#define NID_otherMailbox 475 +#define OBJ_otherMailbox OBJ_pilotAttributeType,22L + +#define LN_lastModifiedTime "lastModifiedTime" +#define NID_lastModifiedTime 476 +#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L + +#define LN_lastModifiedBy "lastModifiedBy" +#define NID_lastModifiedBy 477 +#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L + +#define SN_domainComponent "DC" +#define LN_domainComponent "domainComponent" +#define NID_domainComponent 391 +#define OBJ_domainComponent OBJ_pilotAttributeType,25L + +#define LN_aRecord "aRecord" +#define NID_aRecord 478 +#define OBJ_aRecord OBJ_pilotAttributeType,26L + +#define LN_pilotAttributeType27 "pilotAttributeType27" +#define NID_pilotAttributeType27 479 +#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L + +#define LN_mXRecord "mXRecord" +#define NID_mXRecord 480 +#define OBJ_mXRecord OBJ_pilotAttributeType,28L + +#define LN_nSRecord "nSRecord" +#define NID_nSRecord 481 +#define OBJ_nSRecord OBJ_pilotAttributeType,29L + +#define LN_sOARecord "sOARecord" +#define NID_sOARecord 482 +#define OBJ_sOARecord OBJ_pilotAttributeType,30L + +#define LN_cNAMERecord "cNAMERecord" +#define NID_cNAMERecord 483 +#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L + +#define LN_associatedDomain "associatedDomain" +#define NID_associatedDomain 484 +#define OBJ_associatedDomain OBJ_pilotAttributeType,37L + +#define LN_associatedName "associatedName" +#define NID_associatedName 485 +#define OBJ_associatedName OBJ_pilotAttributeType,38L + +#define LN_homePostalAddress "homePostalAddress" +#define NID_homePostalAddress 486 +#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L + +#define LN_personalTitle "personalTitle" +#define NID_personalTitle 487 +#define OBJ_personalTitle OBJ_pilotAttributeType,40L + +#define LN_mobileTelephoneNumber "mobileTelephoneNumber" +#define NID_mobileTelephoneNumber 488 +#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L + +#define LN_pagerTelephoneNumber "pagerTelephoneNumber" +#define NID_pagerTelephoneNumber 489 +#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L + +#define LN_friendlyCountryName "friendlyCountryName" +#define NID_friendlyCountryName 490 +#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L + +#define LN_organizationalStatus "organizationalStatus" +#define NID_organizationalStatus 491 +#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L + +#define LN_janetMailbox "janetMailbox" +#define NID_janetMailbox 492 +#define OBJ_janetMailbox OBJ_pilotAttributeType,46L + +#define LN_mailPreferenceOption "mailPreferenceOption" +#define NID_mailPreferenceOption 493 +#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L + +#define LN_buildingName "buildingName" +#define NID_buildingName 494 +#define OBJ_buildingName OBJ_pilotAttributeType,48L + +#define LN_dSAQuality "dSAQuality" +#define NID_dSAQuality 495 +#define OBJ_dSAQuality OBJ_pilotAttributeType,49L + +#define LN_singleLevelQuality "singleLevelQuality" +#define NID_singleLevelQuality 496 +#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L + +#define LN_subtreeMinimumQuality "subtreeMinimumQuality" +#define NID_subtreeMinimumQuality 497 +#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L + +#define LN_subtreeMaximumQuality "subtreeMaximumQuality" +#define NID_subtreeMaximumQuality 498 +#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L + +#define LN_personalSignature "personalSignature" +#define NID_personalSignature 499 +#define OBJ_personalSignature OBJ_pilotAttributeType,53L + +#define LN_dITRedirect "dITRedirect" +#define NID_dITRedirect 500 +#define OBJ_dITRedirect OBJ_pilotAttributeType,54L + +#define SN_audio "audio" +#define NID_audio 501 +#define OBJ_audio OBJ_pilotAttributeType,55L + +#define LN_documentPublisher "documentPublisher" +#define NID_documentPublisher 502 +#define OBJ_documentPublisher OBJ_pilotAttributeType,56L + +#define SN_id_set "id-set" +#define LN_id_set "Secure Electronic Transactions" +#define NID_id_set 512 +#define OBJ_id_set OBJ_international_organizations,42L + +#define SN_set_ctype "set-ctype" +#define LN_set_ctype "content types" +#define NID_set_ctype 513 +#define OBJ_set_ctype OBJ_id_set,0L + +#define SN_set_msgExt "set-msgExt" +#define LN_set_msgExt "message extensions" +#define NID_set_msgExt 514 +#define OBJ_set_msgExt OBJ_id_set,1L + +#define SN_set_attr "set-attr" +#define NID_set_attr 515 +#define OBJ_set_attr OBJ_id_set,3L + +#define SN_set_policy "set-policy" +#define NID_set_policy 516 +#define OBJ_set_policy OBJ_id_set,5L + +#define SN_set_certExt "set-certExt" +#define LN_set_certExt "certificate extensions" +#define NID_set_certExt 517 +#define OBJ_set_certExt OBJ_id_set,7L + +#define SN_set_brand "set-brand" +#define NID_set_brand 518 +#define OBJ_set_brand OBJ_id_set,8L + +#define SN_setct_PANData "setct-PANData" +#define NID_setct_PANData 519 +#define OBJ_setct_PANData OBJ_set_ctype,0L + +#define SN_setct_PANToken "setct-PANToken" +#define NID_setct_PANToken 520 +#define OBJ_setct_PANToken OBJ_set_ctype,1L + +#define SN_setct_PANOnly "setct-PANOnly" +#define NID_setct_PANOnly 521 +#define OBJ_setct_PANOnly OBJ_set_ctype,2L + +#define SN_setct_OIData "setct-OIData" +#define NID_setct_OIData 522 +#define OBJ_setct_OIData OBJ_set_ctype,3L + +#define SN_setct_PI "setct-PI" +#define NID_setct_PI 523 +#define OBJ_setct_PI OBJ_set_ctype,4L + +#define SN_setct_PIData "setct-PIData" +#define NID_setct_PIData 524 +#define OBJ_setct_PIData OBJ_set_ctype,5L + +#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" +#define NID_setct_PIDataUnsigned 525 +#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L + +#define SN_setct_HODInput "setct-HODInput" +#define NID_setct_HODInput 526 +#define OBJ_setct_HODInput OBJ_set_ctype,7L + +#define SN_setct_AuthResBaggage "setct-AuthResBaggage" +#define NID_setct_AuthResBaggage 527 +#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L + +#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" +#define NID_setct_AuthRevReqBaggage 528 +#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L + +#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" +#define NID_setct_AuthRevResBaggage 529 +#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L + +#define SN_setct_CapTokenSeq "setct-CapTokenSeq" +#define NID_setct_CapTokenSeq 530 +#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L + +#define SN_setct_PInitResData "setct-PInitResData" +#define NID_setct_PInitResData 531 +#define OBJ_setct_PInitResData OBJ_set_ctype,12L + +#define SN_setct_PI_TBS "setct-PI-TBS" +#define NID_setct_PI_TBS 532 +#define OBJ_setct_PI_TBS OBJ_set_ctype,13L + +#define SN_setct_PResData "setct-PResData" +#define NID_setct_PResData 533 +#define OBJ_setct_PResData OBJ_set_ctype,14L + +#define SN_setct_AuthReqTBS "setct-AuthReqTBS" +#define NID_setct_AuthReqTBS 534 +#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L + +#define SN_setct_AuthResTBS "setct-AuthResTBS" +#define NID_setct_AuthResTBS 535 +#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L + +#define SN_setct_AuthResTBSX "setct-AuthResTBSX" +#define NID_setct_AuthResTBSX 536 +#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L + +#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" +#define NID_setct_AuthTokenTBS 537 +#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L + +#define SN_setct_CapTokenData "setct-CapTokenData" +#define NID_setct_CapTokenData 538 +#define OBJ_setct_CapTokenData OBJ_set_ctype,20L + +#define SN_setct_CapTokenTBS "setct-CapTokenTBS" +#define NID_setct_CapTokenTBS 539 +#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L + +#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" +#define NID_setct_AcqCardCodeMsg 540 +#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L + +#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" +#define NID_setct_AuthRevReqTBS 541 +#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L + +#define SN_setct_AuthRevResData "setct-AuthRevResData" +#define NID_setct_AuthRevResData 542 +#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L + +#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" +#define NID_setct_AuthRevResTBS 543 +#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L + +#define SN_setct_CapReqTBS "setct-CapReqTBS" +#define NID_setct_CapReqTBS 544 +#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L + +#define SN_setct_CapReqTBSX "setct-CapReqTBSX" +#define NID_setct_CapReqTBSX 545 +#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L + +#define SN_setct_CapResData "setct-CapResData" +#define NID_setct_CapResData 546 +#define OBJ_setct_CapResData OBJ_set_ctype,28L + +#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" +#define NID_setct_CapRevReqTBS 547 +#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L + +#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" +#define NID_setct_CapRevReqTBSX 548 +#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L + +#define SN_setct_CapRevResData "setct-CapRevResData" +#define NID_setct_CapRevResData 549 +#define OBJ_setct_CapRevResData OBJ_set_ctype,31L + +#define SN_setct_CredReqTBS "setct-CredReqTBS" +#define NID_setct_CredReqTBS 550 +#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L + +#define SN_setct_CredReqTBSX "setct-CredReqTBSX" +#define NID_setct_CredReqTBSX 551 +#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L + +#define SN_setct_CredResData "setct-CredResData" +#define NID_setct_CredResData 552 +#define OBJ_setct_CredResData OBJ_set_ctype,34L + +#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" +#define NID_setct_CredRevReqTBS 553 +#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L + +#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" +#define NID_setct_CredRevReqTBSX 554 +#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L + +#define SN_setct_CredRevResData "setct-CredRevResData" +#define NID_setct_CredRevResData 555 +#define OBJ_setct_CredRevResData OBJ_set_ctype,37L + +#define SN_setct_PCertReqData "setct-PCertReqData" +#define NID_setct_PCertReqData 556 +#define OBJ_setct_PCertReqData OBJ_set_ctype,38L + +#define SN_setct_PCertResTBS "setct-PCertResTBS" +#define NID_setct_PCertResTBS 557 +#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L + +#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" +#define NID_setct_BatchAdminReqData 558 +#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L + +#define SN_setct_BatchAdminResData "setct-BatchAdminResData" +#define NID_setct_BatchAdminResData 559 +#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L + +#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" +#define NID_setct_CardCInitResTBS 560 +#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L + +#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" +#define NID_setct_MeAqCInitResTBS 561 +#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L + +#define SN_setct_RegFormResTBS "setct-RegFormResTBS" +#define NID_setct_RegFormResTBS 562 +#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L + +#define SN_setct_CertReqData "setct-CertReqData" +#define NID_setct_CertReqData 563 +#define OBJ_setct_CertReqData OBJ_set_ctype,45L + +#define SN_setct_CertReqTBS "setct-CertReqTBS" +#define NID_setct_CertReqTBS 564 +#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L + +#define SN_setct_CertResData "setct-CertResData" +#define NID_setct_CertResData 565 +#define OBJ_setct_CertResData OBJ_set_ctype,47L + +#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" +#define NID_setct_CertInqReqTBS 566 +#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L + +#define SN_setct_ErrorTBS "setct-ErrorTBS" +#define NID_setct_ErrorTBS 567 +#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L + +#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" +#define NID_setct_PIDualSignedTBE 568 +#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L + +#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" +#define NID_setct_PIUnsignedTBE 569 +#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L + +#define SN_setct_AuthReqTBE "setct-AuthReqTBE" +#define NID_setct_AuthReqTBE 570 +#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L + +#define SN_setct_AuthResTBE "setct-AuthResTBE" +#define NID_setct_AuthResTBE 571 +#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L + +#define SN_setct_AuthResTBEX "setct-AuthResTBEX" +#define NID_setct_AuthResTBEX 572 +#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L + +#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" +#define NID_setct_AuthTokenTBE 573 +#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L + +#define SN_setct_CapTokenTBE "setct-CapTokenTBE" +#define NID_setct_CapTokenTBE 574 +#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L + +#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" +#define NID_setct_CapTokenTBEX 575 +#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L + +#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" +#define NID_setct_AcqCardCodeMsgTBE 576 +#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L + +#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" +#define NID_setct_AuthRevReqTBE 577 +#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L + +#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" +#define NID_setct_AuthRevResTBE 578 +#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L + +#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" +#define NID_setct_AuthRevResTBEB 579 +#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L + +#define SN_setct_CapReqTBE "setct-CapReqTBE" +#define NID_setct_CapReqTBE 580 +#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L + +#define SN_setct_CapReqTBEX "setct-CapReqTBEX" +#define NID_setct_CapReqTBEX 581 +#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L + +#define SN_setct_CapResTBE "setct-CapResTBE" +#define NID_setct_CapResTBE 582 +#define OBJ_setct_CapResTBE OBJ_set_ctype,64L + +#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" +#define NID_setct_CapRevReqTBE 583 +#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L + +#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" +#define NID_setct_CapRevReqTBEX 584 +#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L + +#define SN_setct_CapRevResTBE "setct-CapRevResTBE" +#define NID_setct_CapRevResTBE 585 +#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L + +#define SN_setct_CredReqTBE "setct-CredReqTBE" +#define NID_setct_CredReqTBE 586 +#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L + +#define SN_setct_CredReqTBEX "setct-CredReqTBEX" +#define NID_setct_CredReqTBEX 587 +#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L + +#define SN_setct_CredResTBE "setct-CredResTBE" +#define NID_setct_CredResTBE 588 +#define OBJ_setct_CredResTBE OBJ_set_ctype,70L + +#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" +#define NID_setct_CredRevReqTBE 589 +#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L + +#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" +#define NID_setct_CredRevReqTBEX 590 +#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L + +#define SN_setct_CredRevResTBE "setct-CredRevResTBE" +#define NID_setct_CredRevResTBE 591 +#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L + +#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" +#define NID_setct_BatchAdminReqTBE 592 +#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L + +#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" +#define NID_setct_BatchAdminResTBE 593 +#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L + +#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" +#define NID_setct_RegFormReqTBE 594 +#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L + +#define SN_setct_CertReqTBE "setct-CertReqTBE" +#define NID_setct_CertReqTBE 595 +#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L + +#define SN_setct_CertReqTBEX "setct-CertReqTBEX" +#define NID_setct_CertReqTBEX 596 +#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L + +#define SN_setct_CertResTBE "setct-CertResTBE" +#define NID_setct_CertResTBE 597 +#define OBJ_setct_CertResTBE OBJ_set_ctype,79L + +#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" +#define NID_setct_CRLNotificationTBS 598 +#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L + +#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" +#define NID_setct_CRLNotificationResTBS 599 +#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L + +#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" +#define NID_setct_BCIDistributionTBS 600 +#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L + +#define SN_setext_genCrypt "setext-genCrypt" +#define LN_setext_genCrypt "generic cryptogram" +#define NID_setext_genCrypt 601 +#define OBJ_setext_genCrypt OBJ_set_msgExt,1L + +#define SN_setext_miAuth "setext-miAuth" +#define LN_setext_miAuth "merchant initiated auth" +#define NID_setext_miAuth 602 +#define OBJ_setext_miAuth OBJ_set_msgExt,3L + +#define SN_setext_pinSecure "setext-pinSecure" +#define NID_setext_pinSecure 603 +#define OBJ_setext_pinSecure OBJ_set_msgExt,4L + +#define SN_setext_pinAny "setext-pinAny" +#define NID_setext_pinAny 604 +#define OBJ_setext_pinAny OBJ_set_msgExt,5L + +#define SN_setext_track2 "setext-track2" +#define NID_setext_track2 605 +#define OBJ_setext_track2 OBJ_set_msgExt,7L + +#define SN_setext_cv "setext-cv" +#define LN_setext_cv "additional verification" +#define NID_setext_cv 606 +#define OBJ_setext_cv OBJ_set_msgExt,8L + +#define SN_set_policy_root "set-policy-root" +#define NID_set_policy_root 607 +#define OBJ_set_policy_root OBJ_set_policy,0L + +#define SN_setCext_hashedRoot "setCext-hashedRoot" +#define NID_setCext_hashedRoot 608 +#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L + +#define SN_setCext_certType "setCext-certType" +#define NID_setCext_certType 609 +#define OBJ_setCext_certType OBJ_set_certExt,1L + +#define SN_setCext_merchData "setCext-merchData" +#define NID_setCext_merchData 610 +#define OBJ_setCext_merchData OBJ_set_certExt,2L + +#define SN_setCext_cCertRequired "setCext-cCertRequired" +#define NID_setCext_cCertRequired 611 +#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L + +#define SN_setCext_tunneling "setCext-tunneling" +#define NID_setCext_tunneling 612 +#define OBJ_setCext_tunneling OBJ_set_certExt,4L + +#define SN_setCext_setExt "setCext-setExt" +#define NID_setCext_setExt 613 +#define OBJ_setCext_setExt OBJ_set_certExt,5L + +#define SN_setCext_setQualf "setCext-setQualf" +#define NID_setCext_setQualf 614 +#define OBJ_setCext_setQualf OBJ_set_certExt,6L + +#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" +#define NID_setCext_PGWYcapabilities 615 +#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L + +#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" +#define NID_setCext_TokenIdentifier 616 +#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L + +#define SN_setCext_Track2Data "setCext-Track2Data" +#define NID_setCext_Track2Data 617 +#define OBJ_setCext_Track2Data OBJ_set_certExt,9L + +#define SN_setCext_TokenType "setCext-TokenType" +#define NID_setCext_TokenType 618 +#define OBJ_setCext_TokenType OBJ_set_certExt,10L + +#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" +#define NID_setCext_IssuerCapabilities 619 +#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L + +#define SN_setAttr_Cert "setAttr-Cert" +#define NID_setAttr_Cert 620 +#define OBJ_setAttr_Cert OBJ_set_attr,0L + +#define SN_setAttr_PGWYcap "setAttr-PGWYcap" +#define LN_setAttr_PGWYcap "payment gateway capabilities" +#define NID_setAttr_PGWYcap 621 +#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L + +#define SN_setAttr_TokenType "setAttr-TokenType" +#define NID_setAttr_TokenType 622 +#define OBJ_setAttr_TokenType OBJ_set_attr,2L + +#define SN_setAttr_IssCap "setAttr-IssCap" +#define LN_setAttr_IssCap "issuer capabilities" +#define NID_setAttr_IssCap 623 +#define OBJ_setAttr_IssCap OBJ_set_attr,3L + +#define SN_set_rootKeyThumb "set-rootKeyThumb" +#define NID_set_rootKeyThumb 624 +#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L + +#define SN_set_addPolicy "set-addPolicy" +#define NID_set_addPolicy 625 +#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L + +#define SN_setAttr_Token_EMV "setAttr-Token-EMV" +#define NID_setAttr_Token_EMV 626 +#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L + +#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" +#define NID_setAttr_Token_B0Prime 627 +#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L + +#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" +#define NID_setAttr_IssCap_CVM 628 +#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L + +#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" +#define NID_setAttr_IssCap_T2 629 +#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L + +#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" +#define NID_setAttr_IssCap_Sig 630 +#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L + +#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" +#define LN_setAttr_GenCryptgrm "generate cryptogram" +#define NID_setAttr_GenCryptgrm 631 +#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L + +#define SN_setAttr_T2Enc "setAttr-T2Enc" +#define LN_setAttr_T2Enc "encrypted track 2" +#define NID_setAttr_T2Enc 632 +#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L + +#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" +#define LN_setAttr_T2cleartxt "cleartext track 2" +#define NID_setAttr_T2cleartxt 633 +#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L + +#define SN_setAttr_TokICCsig "setAttr-TokICCsig" +#define LN_setAttr_TokICCsig "ICC or token signature" +#define NID_setAttr_TokICCsig 634 +#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L + +#define SN_setAttr_SecDevSig "setAttr-SecDevSig" +#define LN_setAttr_SecDevSig "secure device signature" +#define NID_setAttr_SecDevSig 635 +#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L + +#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" +#define NID_set_brand_IATA_ATA 636 +#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L + +#define SN_set_brand_Diners "set-brand-Diners" +#define NID_set_brand_Diners 637 +#define OBJ_set_brand_Diners OBJ_set_brand,30L + +#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" +#define NID_set_brand_AmericanExpress 638 +#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L + +#define SN_set_brand_JCB "set-brand-JCB" +#define NID_set_brand_JCB 639 +#define OBJ_set_brand_JCB OBJ_set_brand,35L + +#define SN_set_brand_Visa "set-brand-Visa" +#define NID_set_brand_Visa 640 +#define OBJ_set_brand_Visa OBJ_set_brand,4L + +#define SN_set_brand_MasterCard "set-brand-MasterCard" +#define NID_set_brand_MasterCard 641 +#define OBJ_set_brand_MasterCard OBJ_set_brand,5L + +#define SN_set_brand_Novus "set-brand-Novus" +#define NID_set_brand_Novus 642 +#define OBJ_set_brand_Novus OBJ_set_brand,6011L + +#define SN_des_cdmf "DES-CDMF" +#define LN_des_cdmf "des-cdmf" +#define NID_des_cdmf 643 +#define OBJ_des_cdmf OBJ_rsadsi,3L,10L + +#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" +#define NID_rsaOAEPEncryptionSET 644 +#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L + +#define SN_ipsec3 "Oakley-EC2N-3" +#define LN_ipsec3 "ipsec3" +#define NID_ipsec3 749 + +#define SN_ipsec4 "Oakley-EC2N-4" +#define LN_ipsec4 "ipsec4" +#define NID_ipsec4 750 + +#define SN_camellia_128_cbc "CAMELLIA-128-CBC" +#define LN_camellia_128_cbc "camellia-128-cbc" +#define NID_camellia_128_cbc 751 +#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L + +#define SN_camellia_192_cbc "CAMELLIA-192-CBC" +#define LN_camellia_192_cbc "camellia-192-cbc" +#define NID_camellia_192_cbc 752 +#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L + +#define SN_camellia_256_cbc "CAMELLIA-256-CBC" +#define LN_camellia_256_cbc "camellia-256-cbc" +#define NID_camellia_256_cbc 753 +#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L + +#define OBJ_ntt_ds 0L,3L,4401L,5L + +#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L + +#define SN_camellia_128_ecb "CAMELLIA-128-ECB" +#define LN_camellia_128_ecb "camellia-128-ecb" +#define NID_camellia_128_ecb 754 +#define OBJ_camellia_128_ecb OBJ_camellia,1L + +#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" +#define LN_camellia_128_ofb128 "camellia-128-ofb" +#define NID_camellia_128_ofb128 766 +#define OBJ_camellia_128_ofb128 OBJ_camellia,3L + +#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" +#define LN_camellia_128_cfb128 "camellia-128-cfb" +#define NID_camellia_128_cfb128 757 +#define OBJ_camellia_128_cfb128 OBJ_camellia,4L + +#define SN_camellia_192_ecb "CAMELLIA-192-ECB" +#define LN_camellia_192_ecb "camellia-192-ecb" +#define NID_camellia_192_ecb 755 +#define OBJ_camellia_192_ecb OBJ_camellia,21L + +#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" +#define LN_camellia_192_ofb128 "camellia-192-ofb" +#define NID_camellia_192_ofb128 767 +#define OBJ_camellia_192_ofb128 OBJ_camellia,23L + +#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" +#define LN_camellia_192_cfb128 "camellia-192-cfb" +#define NID_camellia_192_cfb128 758 +#define OBJ_camellia_192_cfb128 OBJ_camellia,24L + +#define SN_camellia_256_ecb "CAMELLIA-256-ECB" +#define LN_camellia_256_ecb "camellia-256-ecb" +#define NID_camellia_256_ecb 756 +#define OBJ_camellia_256_ecb OBJ_camellia,41L + +#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" +#define LN_camellia_256_ofb128 "camellia-256-ofb" +#define NID_camellia_256_ofb128 768 +#define OBJ_camellia_256_ofb128 OBJ_camellia,43L + +#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" +#define LN_camellia_256_cfb128 "camellia-256-cfb" +#define NID_camellia_256_cfb128 759 +#define OBJ_camellia_256_cfb128 OBJ_camellia,44L + +#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" +#define LN_camellia_128_cfb1 "camellia-128-cfb1" +#define NID_camellia_128_cfb1 760 + +#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" +#define LN_camellia_192_cfb1 "camellia-192-cfb1" +#define NID_camellia_192_cfb1 761 + +#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" +#define LN_camellia_256_cfb1 "camellia-256-cfb1" +#define NID_camellia_256_cfb1 762 + +#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" +#define LN_camellia_128_cfb8 "camellia-128-cfb8" +#define NID_camellia_128_cfb8 763 + +#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" +#define LN_camellia_192_cfb8 "camellia-192-cfb8" +#define NID_camellia_192_cfb8 764 + +#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" +#define LN_camellia_256_cfb8 "camellia-256-cfb8" +#define NID_camellia_256_cfb8 765 + diff --git a/libraries/external/openssl/linux/include/openssl/objects.h b/libraries/external/openssl/linux/include/openssl/objects.h new file mode 100755 index 0000000..7700894 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/objects.h @@ -0,0 +1,1049 @@ +/* crypto/objects/objects.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_OBJECTS_H +#define HEADER_OBJECTS_H + +#define USE_OBJ_MAC + +#ifdef USE_OBJ_MAC +#include +#else +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_Algorithm "Algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 38 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define LN_rsadsi "rsadsi" +#define NID_rsadsi 1 +#define OBJ_rsadsi 1L,2L,840L,113549L + +#define LN_pkcs "pkcs" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs,1L,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L + +#define LN_X500 "X500" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define LN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +/* Postal Address? PA */ + +/* should be "ST" (rfc1327) but MS uses 'S' */ +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500,8L,1L,1L + +#define LN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define LN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +/* IV + num */ +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +/* IV */ +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ede "DES-EDE" +#define LN_des_ede "des-ede" +#define NID_des_ede 32 +/* ?? */ +#define OBJ_des_ede OBJ_algorithm,17L + +#define SN_des_ede3 "DES-EDE3" +#define LN_des_ede3 "des-ede3" +#define NID_des_ede3 33 + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define LN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define SN_pkcs9_emailAddress "Email" +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +/* I'm not sure about the object ID */ +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L +/* 28 Jun 1996 - eay */ +/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +/* proposed by microsoft to RSA */ +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L + +/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now + * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something + * completely different. + */ +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce 2L,5L,29L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 2L,5L,8L,3L,101L +/* An alternative? 1L,3L,14L,3L,2L,19L */ + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2withRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_givenName "G" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define SN_surname "S" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define SN_initials "I" +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define SN_uniqueIdentifier "UID" +#define LN_uniqueIdentifier "uniqueIdentifier" +#define NID_uniqueIdentifier 102 +#define OBJ_uniqueIdentifier OBJ_X509,45L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_serialNumber "SN" +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_title "T" +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define SN_description "D" +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +/* CAST5 is CAST-128, I'm just sticking with the documentation */ +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L + +/* This is one sun will soon be using :-( + * id-dsa-with-sha1 ID ::= { + * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } + */ +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L + +#define NID_md5_sha1 114 +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa 1L,2L,840L,10040L,4L,1L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +/* The name should actually be rsaSignatureWithripemd160, but I'm going + * to continue using the convention I'm using with the other ciphers */ +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +/* Taken from rfc2040 + * RC5_CBC_Parameters ::= SEQUENCE { + * version INTEGER (v1_0(16)), + * rounds INTEGER (8..127), + * blockSizeInBits INTEGER (64, 128), + * iv OCTET STRING OPTIONAL + * } + */ +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +/* PKIX extended key usage OIDs */ + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +/* Additional extended key usage OIDs: Microsoft */ + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +/* Additional usage: Netscape */ + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +/* PKCS12 and related OBJECT IDENTIFIERS */ + +#define OBJ_pkcs12 OBJ_pkcs,12L +#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds, 3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9, 20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9, 21L + +#define OBJ_certTypes OBJ_pkcs9, 22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes, 1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes, 2L + +#define OBJ_crlTypes OBJ_pkcs9, 23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes, 1L + +/* PKCS#5 v2 OIDs */ + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs,5L,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs,5L,14L + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +/* Policy Qualifier Ids */ + +#define LN_id_qt_cps "Policy Qualifier CPS" +#define SN_id_qt_cps "id-qt-cps" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L + +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define SN_id_qt_unotice "id-qt-unotice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L + +/* Extension request OIDs */ + +#define LN_ms_ext_req "Microsoft Extension Request" +#define SN_ms_ext_req "msExtReq" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define LN_ext_req "Extension Request" +#define SN_ext_req "extReq" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L +#endif /* USE_OBJ_MAC */ + +#include +#include + +#define OBJ_NAME_TYPE_UNDEF 0x00 +#define OBJ_NAME_TYPE_MD_METH 0x01 +#define OBJ_NAME_TYPE_CIPHER_METH 0x02 +#define OBJ_NAME_TYPE_PKEY_METH 0x03 +#define OBJ_NAME_TYPE_COMP_METH 0x04 +#define OBJ_NAME_TYPE_NUM 0x05 + +#define OBJ_NAME_ALIAS 0x8000 + +#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 +#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct obj_name_st + { + int type; + int alias; + const char *name; + const char *data; + } OBJ_NAME; + +#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) + + +int OBJ_NAME_init(void); +int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), + int (*cmp_func)(const char *, const char *), + void (*free_func)(const char *, int, const char *)); +const char *OBJ_NAME_get(const char *name,int type); +int OBJ_NAME_add(const char *name,int type,const char *data); +int OBJ_NAME_remove(const char *name,int type); +void OBJ_NAME_cleanup(int type); /* -1 for everything */ +void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); +void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); + +ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_nid2obj(int n); +const char * OBJ_nid2ln(int n); +const char * OBJ_nid2sn(int n); +int OBJ_obj2nid(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); +int OBJ_txt2nid(const char *s); +int OBJ_ln2nid(const char *s); +int OBJ_sn2nid(const char *s); +int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); +const char * OBJ_bsearch(const char *key,const char *base,int num,int size, + int (*cmp)(const void *, const void *)); +const char * OBJ_bsearch_ex(const char *key,const char *base,int num, + int size, int (*cmp)(const void *, const void *), int flags); + +int OBJ_new_nid(int num); +int OBJ_add_object(const ASN1_OBJECT *obj); +int OBJ_create(const char *oid,const char *sn,const char *ln); +void OBJ_cleanup(void ); +int OBJ_create_objects(BIO *in); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OBJ_strings(void); + +/* Error codes for the OBJ functions. */ + +/* Function codes. */ +#define OBJ_F_OBJ_ADD_OBJECT 105 +#define OBJ_F_OBJ_CREATE 100 +#define OBJ_F_OBJ_DUP 101 +#define OBJ_F_OBJ_NAME_NEW_INDEX 106 +#define OBJ_F_OBJ_NID2LN 102 +#define OBJ_F_OBJ_NID2OBJ 103 +#define OBJ_F_OBJ_NID2SN 104 + +/* Reason codes. */ +#define OBJ_R_MALLOC_FAILURE 100 +#define OBJ_R_UNKNOWN_NID 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ocsp.h b/libraries/external/openssl/linux/include/openssl/ocsp.h new file mode 100755 index 0000000..830d428 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ocsp.h @@ -0,0 +1,614 @@ +/* ocsp.h */ +/* Written by Tom Titchener for the OpenSSL + * project. */ + +/* History: + This file was transfered to Richard Levitte from CertCo by Kathy + Weinhold in mid-spring 2000 to be included in OpenSSL or released + as a patch kit. */ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OCSP_H +#define HEADER_OCSP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Various flags and values */ + +#define OCSP_DEFAULT_NONCE_LENGTH 16 + +#define OCSP_NOCERTS 0x1 +#define OCSP_NOINTERN 0x2 +#define OCSP_NOSIGS 0x4 +#define OCSP_NOCHAIN 0x8 +#define OCSP_NOVERIFY 0x10 +#define OCSP_NOEXPLICIT 0x20 +#define OCSP_NOCASIGN 0x40 +#define OCSP_NODELEGATED 0x80 +#define OCSP_NOCHECKS 0x100 +#define OCSP_TRUSTOTHER 0x200 +#define OCSP_RESPID_KEY 0x400 +#define OCSP_NOTIME 0x800 + +/* CertID ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier, + * issuerNameHash OCTET STRING, -- Hash of Issuer's DN + * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) + * serialNumber CertificateSerialNumber } + */ +typedef struct ocsp_cert_id_st + { + X509_ALGOR *hashAlgorithm; + ASN1_OCTET_STRING *issuerNameHash; + ASN1_OCTET_STRING *issuerKeyHash; + ASN1_INTEGER *serialNumber; + } OCSP_CERTID; + +DECLARE_STACK_OF(OCSP_CERTID) + +/* Request ::= SEQUENCE { + * reqCert CertID, + * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_one_request_st + { + OCSP_CERTID *reqCert; + STACK_OF(X509_EXTENSION) *singleRequestExtensions; + } OCSP_ONEREQ; + +DECLARE_STACK_OF(OCSP_ONEREQ) +DECLARE_ASN1_SET_OF(OCSP_ONEREQ) + + +/* TBSRequest ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * requestorName [1] EXPLICIT GeneralName OPTIONAL, + * requestList SEQUENCE OF Request, + * requestExtensions [2] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_req_info_st + { + ASN1_INTEGER *version; + GENERAL_NAME *requestorName; + STACK_OF(OCSP_ONEREQ) *requestList; + STACK_OF(X509_EXTENSION) *requestExtensions; + } OCSP_REQINFO; + +/* Signature ::= SEQUENCE { + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ +typedef struct ocsp_signature_st + { + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_SIGNATURE; + +/* OCSPRequest ::= SEQUENCE { + * tbsRequest TBSRequest, + * optionalSignature [0] EXPLICIT Signature OPTIONAL } + */ +typedef struct ocsp_request_st + { + OCSP_REQINFO *tbsRequest; + OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ + } OCSP_REQUEST; + +/* OCSPResponseStatus ::= ENUMERATED { + * successful (0), --Response has valid confirmations + * malformedRequest (1), --Illegal confirmation request + * internalError (2), --Internal error in issuer + * tryLater (3), --Try again later + * --(4) is not used + * sigRequired (5), --Must sign the request + * unauthorized (6) --Request unauthorized + * } + */ +#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 +#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 +#define OCSP_RESPONSE_STATUS_INTERNALERROR 2 +#define OCSP_RESPONSE_STATUS_TRYLATER 3 +#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 +#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 + +/* ResponseBytes ::= SEQUENCE { + * responseType OBJECT IDENTIFIER, + * response OCTET STRING } + */ +typedef struct ocsp_resp_bytes_st + { + ASN1_OBJECT *responseType; + ASN1_OCTET_STRING *response; + } OCSP_RESPBYTES; + +/* OCSPResponse ::= SEQUENCE { + * responseStatus OCSPResponseStatus, + * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } + */ +typedef struct ocsp_response_st + { + ASN1_ENUMERATED *responseStatus; + OCSP_RESPBYTES *responseBytes; + } OCSP_RESPONSE; + +/* ResponderID ::= CHOICE { + * byName [1] Name, + * byKey [2] KeyHash } + */ +#define V_OCSP_RESPID_NAME 0 +#define V_OCSP_RESPID_KEY 1 +typedef struct ocsp_responder_id_st + { + int type; + union { + X509_NAME* byName; + ASN1_OCTET_STRING *byKey; + } value; + } OCSP_RESPID; +/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key + * --(excluding the tag and length fields) + */ + +/* RevokedInfo ::= SEQUENCE { + * revocationTime GeneralizedTime, + * revocationReason [0] EXPLICIT CRLReason OPTIONAL } + */ +typedef struct ocsp_revoked_info_st + { + ASN1_GENERALIZEDTIME *revocationTime; + ASN1_ENUMERATED *revocationReason; + } OCSP_REVOKEDINFO; + +/* CertStatus ::= CHOICE { + * good [0] IMPLICIT NULL, + * revoked [1] IMPLICIT RevokedInfo, + * unknown [2] IMPLICIT UnknownInfo } + */ +#define V_OCSP_CERTSTATUS_GOOD 0 +#define V_OCSP_CERTSTATUS_REVOKED 1 +#define V_OCSP_CERTSTATUS_UNKNOWN 2 +typedef struct ocsp_cert_status_st + { + int type; + union { + ASN1_NULL *good; + OCSP_REVOKEDINFO *revoked; + ASN1_NULL *unknown; + } value; + } OCSP_CERTSTATUS; + +/* SingleResponse ::= SEQUENCE { + * certID CertID, + * certStatus CertStatus, + * thisUpdate GeneralizedTime, + * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, + * singleExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_single_response_st + { + OCSP_CERTID *certId; + OCSP_CERTSTATUS *certStatus; + ASN1_GENERALIZEDTIME *thisUpdate; + ASN1_GENERALIZEDTIME *nextUpdate; + STACK_OF(X509_EXTENSION) *singleExtensions; + } OCSP_SINGLERESP; + +DECLARE_STACK_OF(OCSP_SINGLERESP) +DECLARE_ASN1_SET_OF(OCSP_SINGLERESP) + +/* ResponseData ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * responderID ResponderID, + * producedAt GeneralizedTime, + * responses SEQUENCE OF SingleResponse, + * responseExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_response_data_st + { + ASN1_INTEGER *version; + OCSP_RESPID *responderId; + ASN1_GENERALIZEDTIME *producedAt; + STACK_OF(OCSP_SINGLERESP) *responses; + STACK_OF(X509_EXTENSION) *responseExtensions; + } OCSP_RESPDATA; + +/* BasicOCSPResponse ::= SEQUENCE { + * tbsResponseData ResponseData, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ + /* Note 1: + The value for "signature" is specified in the OCSP rfc2560 as follows: + "The value for the signature SHALL be computed on the hash of the DER + encoding ResponseData." This means that you must hash the DER-encoded + tbsResponseData, and then run it through a crypto-signing function, which + will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems + a bit odd, but that's the spec. Also note that the data structures do not + leave anywhere to independently specify the algorithm used for the initial + hash. So, we look at the signature-specification algorithm, and try to do + something intelligent. -- Kathy Weinhold, CertCo */ + /* Note 2: + It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open + for interpretation. I've done tests against another responder, and found + that it doesn't do the double hashing that the RFC seems to say one + should. Therefore, all relevant functions take a flag saying which + variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */ +typedef struct ocsp_basic_response_st + { + OCSP_RESPDATA *tbsResponseData; + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_BASICRESP; + +/* + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * removeFromCRL (8) } + */ +#define OCSP_REVOKED_STATUS_NOSTATUS -1 +#define OCSP_REVOKED_STATUS_UNSPECIFIED 0 +#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 +#define OCSP_REVOKED_STATUS_CACOMPROMISE 2 +#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 +#define OCSP_REVOKED_STATUS_SUPERSEDED 4 +#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 +#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 +#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 + +/* CrlID ::= SEQUENCE { + * crlUrl [0] EXPLICIT IA5String OPTIONAL, + * crlNum [1] EXPLICIT INTEGER OPTIONAL, + * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } + */ +typedef struct ocsp_crl_id_st + { + ASN1_IA5STRING *crlUrl; + ASN1_INTEGER *crlNum; + ASN1_GENERALIZEDTIME *crlTime; + } OCSP_CRLID; + +/* ServiceLocator ::= SEQUENCE { + * issuer Name, + * locator AuthorityInfoAccessSyntax OPTIONAL } + */ +typedef struct ocsp_service_locator_st + { + X509_NAME* issuer; + STACK_OF(ACCESS_DESCRIPTION) *locator; + } OCSP_SERVICELOC; + +#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" +#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" + +#define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) + +#define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) + +#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL) + +#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ + (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL) + +#define PEM_write_bio_OCSP_REQUEST(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_OCSP_RESPONSE(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) + +#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) + +#define OCSP_REQUEST_sign(o,pkey,md) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ + o->optionalSignature->signatureAlgorithm,NULL,\ + o->optionalSignature->signature,o->tbsRequest,pkey,md) + +#define OCSP_BASICRESP_sign(o,pkey,md,d) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\ + o->signature,o->tbsResponseData,pkey,md) + +#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ + a->optionalSignature->signatureAlgorithm,\ + a->optionalSignature->signature,a->tbsRequest,r) + +#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ + a->signatureAlgorithm,a->signature,a->tbsResponseData,r) + +#define ASN1_BIT_STRING_digest(data,type,md,len) \ + ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) + +#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid) + +#define OCSP_CERTSTATUS_dup(cs)\ + (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ + (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) + +OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); + +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); + +OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, + X509_NAME *issuerName, + ASN1_BIT_STRING* issuerKey, + ASN1_INTEGER *serialNumber); + +OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); + +int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); +int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); +int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); +int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); + +int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); +int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); + +int OCSP_request_sign(OCSP_REQUEST *req, + X509 *signer, + EVP_PKEY *key, + const EVP_MD *dgst, + STACK_OF(X509) *certs, + unsigned long flags); + +int OCSP_response_status(OCSP_RESPONSE *resp); +OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); + +int OCSP_resp_count(OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); +int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); +int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, + int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, + ASN1_GENERALIZEDTIME *nextupd, + long sec, long maxsec); + +int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags); + +int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl); + +int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); +int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); + +int OCSP_request_onereq_count(OCSP_REQUEST *req); +OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); +OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); +int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, + ASN1_OCTET_STRING **pikeyHash, + ASN1_INTEGER **pserial, OCSP_CERTID *cid); +int OCSP_request_is_signed(OCSP_REQUEST *req); +OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, + OCSP_CERTID *cid, + int status, int reason, + ASN1_TIME *revtime, + ASN1_TIME *thisupd, ASN1_TIME *nextupd); +int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); +int OCSP_basic_sign(OCSP_BASICRESP *brsp, + X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, + STACK_OF(X509) *certs, unsigned long flags); + +ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, + void *data, STACK_OF(ASN1_OBJECT) *sk); +#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \ +((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk) + +X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); + +X509_EXTENSION *OCSP_accept_responses_new(char **oids); + +X509_EXTENSION *OCSP_archive_cutoff_new(char* tim); + +X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls); + +int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); +int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); +X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); +X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); +void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx); +int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); + +int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); +int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); +X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); +X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); +void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); +int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); + +int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); +int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); +X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); +void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx); +int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); + +int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); +int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); +X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); +void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx); +int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); + +DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) +DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) +DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) +DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) +DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) +DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) +DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) + +char *OCSP_response_status_str(long s); +char *OCSP_cert_status_str(long s); +char *OCSP_crl_reason_str(long s); + +int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags); +int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags); + +int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, + X509_STORE *st, unsigned long flags); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OCSP_strings(void); + +/* Error codes for the OCSP functions. */ + +/* Function codes. */ +#define OCSP_F_ASN1_STRING_ENCODE 100 +#define OCSP_F_D2I_OCSP_NONCE 102 +#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 +#define OCSP_F_OCSP_BASIC_SIGN 104 +#define OCSP_F_OCSP_BASIC_VERIFY 105 +#define OCSP_F_OCSP_CERT_ID_NEW 101 +#define OCSP_F_OCSP_CHECK_DELEGATED 106 +#define OCSP_F_OCSP_CHECK_IDS 107 +#define OCSP_F_OCSP_CHECK_ISSUER 108 +#define OCSP_F_OCSP_CHECK_VALIDITY 115 +#define OCSP_F_OCSP_MATCH_ISSUERID 109 +#define OCSP_F_OCSP_PARSE_URL 114 +#define OCSP_F_OCSP_REQUEST_SIGN 110 +#define OCSP_F_OCSP_REQUEST_VERIFY 116 +#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 +#define OCSP_F_OCSP_SENDREQ_BIO 112 +#define OCSP_F_REQUEST_VERIFY 113 + +/* Reason codes. */ +#define OCSP_R_BAD_DATA 100 +#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 +#define OCSP_R_DIGEST_ERR 102 +#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 +#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 +#define OCSP_R_ERROR_PARSING_URL 121 +#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 +#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 +#define OCSP_R_NOT_BASIC_RESPONSE 104 +#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 +#define OCSP_R_NO_CONTENT 106 +#define OCSP_R_NO_PUBLIC_KEY 107 +#define OCSP_R_NO_RESPONSE_DATA 108 +#define OCSP_R_NO_REVOKED_TIME 109 +#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 +#define OCSP_R_REQUEST_NOT_SIGNED 128 +#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 +#define OCSP_R_ROOT_CA_NOT_TRUSTED 112 +#define OCSP_R_SERVER_READ_ERROR 113 +#define OCSP_R_SERVER_RESPONSE_ERROR 114 +#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 +#define OCSP_R_SERVER_WRITE_ERROR 116 +#define OCSP_R_SIGNATURE_FAILURE 117 +#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 +#define OCSP_R_STATUS_EXPIRED 125 +#define OCSP_R_STATUS_NOT_YET_VALID 126 +#define OCSP_R_STATUS_TOO_OLD 127 +#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 +#define OCSP_R_UNKNOWN_NID 120 +#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/opensslconf.h b/libraries/external/openssl/linux/include/openssl/opensslconf.h new file mode 100755 index 0000000..3942a69 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/opensslconf.h @@ -0,0 +1,219 @@ +/* opensslconf.h */ +/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ + +/* OpenSSL was configured with the following options: */ +#ifndef OPENSSL_DOING_MAKEDEPEND + +#ifndef OPENSSL_NO_CAMELLIA +# define OPENSSL_NO_CAMELLIA +#endif +#ifndef OPENSSL_NO_GMP +# define OPENSSL_NO_GMP +#endif +#ifndef OPENSSL_NO_KRB5 +# define OPENSSL_NO_KRB5 +#endif +#ifndef OPENSSL_NO_MDC2 +# define OPENSSL_NO_MDC2 +#endif +#ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +#endif +#ifndef OPENSSL_NO_RFC3779 +# define OPENSSL_NO_RFC3779 +#endif + +#endif /* OPENSSL_DOING_MAKEDEPEND */ +#ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +#endif +#ifndef OPENSSL_NO_DYNAMIC_ENGINE +# define OPENSSL_NO_DYNAMIC_ENGINE +#endif + +/* The OPENSSL_NO_* macros are also defined as NO_* if the application + asks for it. This is a transient feature that is provided for those + who haven't had the time to do the appropriate changes in their + applications. */ +#ifdef OPENSSL_ALGORITHM_DEFINES +# if defined(OPENSSL_NO_CAMELLIA) && !defined(NO_CAMELLIA) +# define NO_CAMELLIA +# endif +# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) +# define NO_GMP +# endif +# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) +# define NO_KRB5 +# endif +# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2) +# define NO_MDC2 +# endif +# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) +# define NO_RC5 +# endif +# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779) +# define NO_RFC3779 +# endif +#endif + +#define OPENSSL_CPUID_OBJ + +/* crypto/opensslconf.h.in */ + +/* Generate 80386 code? */ +#undef I386_ONLY + +#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define ENGINESDIR "/g3/openssl/linux/lib/engines" +#define OPENSSLDIR "/g3/openssl/linux/ssl" +#endif +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#define DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#define DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/libraries/external/openssl/linux/include/openssl/opensslv.h b/libraries/external/openssl/linux/include/openssl/opensslv.h new file mode 100755 index 0000000..c801bdb --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/opensslv.h @@ -0,0 +1,89 @@ +#ifndef HEADER_OPENSSLV_H +#define HEADER_OPENSSLV_H + +/* Numeric release version identifier: + * MNNFFPPS: major minor fix patch status + * The status nibble has one of the values 0 for development, 1 to e for betas + * 1 to 14, and f for release. The patch level is exactly that. + * For example: + * 0.9.3-dev 0x00903000 + * 0.9.3-beta1 0x00903001 + * 0.9.3-beta2-dev 0x00903002 + * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) + * 0.9.3 0x0090300f + * 0.9.3a 0x0090301f + * 0.9.4 0x0090400f + * 1.2.3z 0x102031af + * + * For continuity reasons (because 0.9.5 is already out, and is coded + * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level + * part is slightly different, by setting the highest bit. This means + * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start + * with 0x0090600S... + * + * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) + * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for + * major minor fix final patch/beta) + */ +#define OPENSSL_VERSION_NUMBER 0x0090805fL +#ifdef OPENSSL_FIPS +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8e-fips 23 Feb 2007" +#else +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8e 23 Feb 2007" +#endif +#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT + + +/* The macros below are to be used for shared library (.so, .dll, ...) + * versioning. That kind of versioning works a bit differently between + * operating systems. The most usual scheme is to set a major and a minor + * number, and have the runtime loader check that the major number is equal + * to what it was at application link time, while the minor number has to + * be greater or equal to what it was at application link time. With this + * scheme, the version number is usually part of the file name, like this: + * + * libcrypto.so.0.9 + * + * Some unixen also make a softlink with the major verson number only: + * + * libcrypto.so.0 + * + * On Tru64 and IRIX 6.x it works a little bit differently. There, the + * shared library version is stored in the file, and is actually a series + * of versions, separated by colons. The rightmost version present in the + * library when linking an application is stored in the application to be + * matched at run time. When the application is run, a check is done to + * see if the library version stored in the application matches any of the + * versions in the version string of the library itself. + * This version string can be constructed in any way, depending on what + * kind of matching is desired. However, to implement the same scheme as + * the one used in the other unixen, all compatible versions, from lowest + * to highest, should be part of the string. Consecutive builds would + * give the following versions strings: + * + * 3.0 + * 3.0:3.1 + * 3.0:3.1:3.2 + * 4.0 + * 4.0:4.1 + * + * Notice how version 4 is completely incompatible with version, and + * therefore give the breach you can see. + * + * There may be other schemes as well that I haven't yet discovered. + * + * So, here's the way it works here: first of all, the library version + * number doesn't need at all to match the overall OpenSSL version. + * However, it's nice and more understandable if it actually does. + * The current library version is stored in the macro SHLIB_VERSION_NUMBER, + * which is just a piece of text in the format "M.m.e" (Major, minor, edit). + * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, + * we need to keep a history of version numbers, which is done in the + * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and + * should only keep the versions that are binary compatible with the current. + */ +#define SHLIB_VERSION_HISTORY "" +#define SHLIB_VERSION_NUMBER "0.9.8" + + +#endif /* HEADER_OPENSSLV_H */ diff --git a/libraries/external/openssl/linux/include/openssl/ossl_typ.h b/libraries/external/openssl/linux/include/openssl/ossl_typ.h new file mode 100755 index 0000000..9115bcc --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ossl_typ.h @@ -0,0 +1,174 @@ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OPENSSL_TYPES_H +#define HEADER_OPENSSL_TYPES_H + +#include + +#ifdef NO_ASN1_TYPEDEFS +#define ASN1_INTEGER ASN1_STRING +#define ASN1_ENUMERATED ASN1_STRING +#define ASN1_BIT_STRING ASN1_STRING +#define ASN1_OCTET_STRING ASN1_STRING +#define ASN1_PRINTABLESTRING ASN1_STRING +#define ASN1_T61STRING ASN1_STRING +#define ASN1_IA5STRING ASN1_STRING +#define ASN1_UTCTIME ASN1_STRING +#define ASN1_GENERALIZEDTIME ASN1_STRING +#define ASN1_TIME ASN1_STRING +#define ASN1_GENERALSTRING ASN1_STRING +#define ASN1_UNIVERSALSTRING ASN1_STRING +#define ASN1_BMPSTRING ASN1_STRING +#define ASN1_VISIBLESTRING ASN1_STRING +#define ASN1_UTF8STRING ASN1_STRING +#define ASN1_BOOLEAN int +#define ASN1_NULL int +#else +typedef struct asn1_string_st ASN1_INTEGER; +typedef struct asn1_string_st ASN1_ENUMERATED; +typedef struct asn1_string_st ASN1_BIT_STRING; +typedef struct asn1_string_st ASN1_OCTET_STRING; +typedef struct asn1_string_st ASN1_PRINTABLESTRING; +typedef struct asn1_string_st ASN1_T61STRING; +typedef struct asn1_string_st ASN1_IA5STRING; +typedef struct asn1_string_st ASN1_GENERALSTRING; +typedef struct asn1_string_st ASN1_UNIVERSALSTRING; +typedef struct asn1_string_st ASN1_BMPSTRING; +typedef struct asn1_string_st ASN1_UTCTIME; +typedef struct asn1_string_st ASN1_TIME; +typedef struct asn1_string_st ASN1_GENERALIZEDTIME; +typedef struct asn1_string_st ASN1_VISIBLESTRING; +typedef struct asn1_string_st ASN1_UTF8STRING; +typedef int ASN1_BOOLEAN; +typedef int ASN1_NULL; +#endif + +#ifdef OPENSSL_SYS_WIN32 +#undef X509_NAME +#undef X509_CERT_PAIR +#undef PKCS7_ISSUER_AND_SERIAL +#endif + +#ifdef BIGNUM +#undef BIGNUM +#endif +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; + +typedef struct buf_mem_st BUF_MEM; + +typedef struct evp_cipher_st EVP_CIPHER; +typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; +typedef struct env_md_st EVP_MD; +typedef struct env_md_ctx_st EVP_MD_CTX; +typedef struct evp_pkey_st EVP_PKEY; + +typedef struct dh_st DH; +typedef struct dh_method DH_METHOD; + +typedef struct dsa_st DSA; +typedef struct dsa_method DSA_METHOD; + +typedef struct rsa_st RSA; +typedef struct rsa_meth_st RSA_METHOD; + +typedef struct rand_meth_st RAND_METHOD; + +typedef struct ecdh_method ECDH_METHOD; +typedef struct ecdsa_method ECDSA_METHOD; + +typedef struct x509_st X509; +typedef struct X509_algor_st X509_ALGOR; +typedef struct X509_crl_st X509_CRL; +typedef struct X509_name_st X509_NAME; +typedef struct x509_store_st X509_STORE; +typedef struct x509_store_ctx_st X509_STORE_CTX; + +typedef struct v3_ext_ctx X509V3_CTX; +typedef struct conf_st CONF; + +typedef struct store_st STORE; +typedef struct store_method_st STORE_METHOD; + +typedef struct ui_st UI; +typedef struct ui_method_st UI_METHOD; + +typedef struct st_ERR_FNS ERR_FNS; + +typedef struct engine_st ENGINE; + +typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; +typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; +typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; +typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; + + /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ +#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ +#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ + +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Callback types for crypto.h */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); + +#endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/libraries/external/openssl/linux/include/openssl/pem.h b/libraries/external/openssl/linux/include/openssl/pem.h new file mode 100755 index 0000000..c003eec --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/pem.h @@ -0,0 +1,737 @@ +/* crypto/pem/pem.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PEM_H +#define HEADER_PEM_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_STACK +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PEM_BUFSIZE 1024 + +#define PEM_OBJ_UNDEF 0 +#define PEM_OBJ_X509 1 +#define PEM_OBJ_X509_REQ 2 +#define PEM_OBJ_CRL 3 +#define PEM_OBJ_SSL_SESSION 4 +#define PEM_OBJ_PRIV_KEY 10 +#define PEM_OBJ_PRIV_RSA 11 +#define PEM_OBJ_PRIV_DSA 12 +#define PEM_OBJ_PRIV_DH 13 +#define PEM_OBJ_PUB_RSA 14 +#define PEM_OBJ_PUB_DSA 15 +#define PEM_OBJ_PUB_DH 16 +#define PEM_OBJ_DHPARAMS 17 +#define PEM_OBJ_DSAPARAMS 18 +#define PEM_OBJ_PRIV_RSA_PUBLIC 19 +#define PEM_OBJ_PRIV_ECDSA 20 +#define PEM_OBJ_PUB_ECDSA 21 +#define PEM_OBJ_ECPARAMETERS 22 + +#define PEM_ERROR 30 +#define PEM_DEK_DES_CBC 40 +#define PEM_DEK_IDEA_CBC 45 +#define PEM_DEK_DES_EDE 50 +#define PEM_DEK_DES_ECB 60 +#define PEM_DEK_RSA 70 +#define PEM_DEK_RSA_MD2 80 +#define PEM_DEK_RSA_MD5 90 + +#define PEM_MD_MD2 NID_md2 +#define PEM_MD_MD5 NID_md5 +#define PEM_MD_SHA NID_sha +#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption +#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption +#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption + +#define PEM_STRING_X509_OLD "X509 CERTIFICATE" +#define PEM_STRING_X509 "CERTIFICATE" +#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" +#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" +#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +#define PEM_STRING_X509_CRL "X509 CRL" +#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" +#define PEM_STRING_PUBLIC "PUBLIC KEY" +#define PEM_STRING_RSA "RSA PRIVATE KEY" +#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +#define PEM_STRING_DSA "DSA PRIVATE KEY" +#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" +#define PEM_STRING_PKCS7 "PKCS7" +#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" +#define PEM_STRING_PKCS8INF "PRIVATE KEY" +#define PEM_STRING_DHPARAMS "DH PARAMETERS" +#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" +#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" +#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" +#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" + + /* Note that this structure is initialised by PEM_SealInit and cleaned up + by PEM_SealFinal (at least for now) */ +typedef struct PEM_Encode_Seal_st + { + EVP_ENCODE_CTX encode; + EVP_MD_CTX md; + EVP_CIPHER_CTX cipher; + } PEM_ENCODE_SEAL_CTX; + +/* enc_type is one off */ +#define PEM_TYPE_ENCRYPTED 10 +#define PEM_TYPE_MIC_ONLY 20 +#define PEM_TYPE_MIC_CLEAR 30 +#define PEM_TYPE_CLEAR 40 + +typedef struct pem_recip_st + { + char *name; + X509_NAME *dn; + + int cipher; + int key_enc; + /* char iv[8]; unused and wrong size */ + } PEM_USER; + +typedef struct pem_ctx_st + { + int type; /* what type of object */ + + struct { + int version; + int mode; + } proc_type; + + char *domain; + + struct { + int cipher; + /* unused, and wrong size + unsigned char iv[8]; */ + } DEK_info; + + PEM_USER *originator; + + int num_recipient; + PEM_USER **recipient; + +#ifndef OPENSSL_NO_STACK + STACK *x509_chain; /* certificate chain */ +#else + char *x509_chain; /* certificate chain */ +#endif + EVP_MD *md; /* signature type */ + + int md_enc; /* is the md encrypted or not? */ + int md_len; /* length of md_data */ + char *md_data; /* message digest, could be pkey encrypted */ + + EVP_CIPHER *dec; /* date encryption cipher */ + int key_len; /* key length */ + unsigned char *key; /* key */ + /* unused, and wrong size + unsigned char iv[8]; */ + + + int data_enc; /* is the data encrypted */ + int data_len; + unsigned char *data; + } PEM_CTX; + +/* These macros make the PEM_read/PEM_write functions easier to maintain and + * write. Now they are all implemented with either: + * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) + */ + +#ifdef OPENSSL_NO_FP_API + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ + +#else + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ +type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#endif + +#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ +type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_read_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb(name, type, str, asn1) + +/* These are the same except they are for the declarations */ + +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) + +#define DECLARE_PEM_read_fp(name, type) /**/ +#define DECLARE_PEM_write_fp(name, type) /**/ +#define DECLARE_PEM_write_cb_fp(name, type) /**/ + +#else + +#define DECLARE_PEM_read_fp(name, type) \ + type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x); + +#define DECLARE_PEM_write_fp_const(name, type) \ + int PEM_write_##name(FILE *fp, const type *x); + +#define DECLARE_PEM_write_cb_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#endif + +#ifndef OPENSSL_NO_BIO +#define DECLARE_PEM_read_bio(name, type) \ + type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x); + +#define DECLARE_PEM_write_bio_const(name, type) \ + int PEM_write_bio_##name(BIO *bp, const type *x); + +#define DECLARE_PEM_write_cb_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#else + +#define DECLARE_PEM_read_bio(name, type) /**/ +#define DECLARE_PEM_write_bio(name, type) /**/ +#define DECLARE_PEM_write_cb_bio(name, type) /**/ + +#endif + +#define DECLARE_PEM_write(name, type) \ + DECLARE_PEM_write_bio(name, type) \ + DECLARE_PEM_write_fp(name, type) + +#define DECLARE_PEM_write_const(name, type) \ + DECLARE_PEM_write_bio_const(name, type) \ + DECLARE_PEM_write_fp_const(name, type) + +#define DECLARE_PEM_write_cb(name, type) \ + DECLARE_PEM_write_cb_bio(name, type) \ + DECLARE_PEM_write_cb_fp(name, type) + +#define DECLARE_PEM_read(name, type) \ + DECLARE_PEM_read_bio(name, type) \ + DECLARE_PEM_read_fp(name, type) + +#define DECLARE_PEM_rw(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write(name, type) + +#define DECLARE_PEM_rw_const(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_const(name, type) + +#define DECLARE_PEM_rw_cb(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_cb(name, type) + +#ifdef SSLEAY_MACROS + +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_CRL(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ + fp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_RSAPublicKey(fp,x) \ + PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ + PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PKCS7(fp,x) \ + PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_DHparams(fp,x) \ + PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ + (char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ + PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \ + (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u) +#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u) +#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u) +#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u) +#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u) +#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u) +#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u) +#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u) +#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u) + +#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ + (char **)x,cb,u) + +#define PEM_write_bio_X509(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_CRL(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ + bp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_RSAPublicKey(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ + PEM_STRING_RSA_PUBLIC,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PKCS7(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DHparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ + PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u) +#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u) + +#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u) +#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u) + +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ + (char **)x,cb,u) + +#endif + +#if 1 +/* "userdata": new with OpenSSL 0.9.4 */ +typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); +#else +/* OpenSSL 0.9.3, 0.9.3a */ +typedef int pem_password_cb(char *buf, int size, int rwflag); +#endif + +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + pem_password_cb *callback,void *u); + +#ifndef OPENSSL_NO_BIO +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, + long len); +int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, + pem_password_cb *cb, void *u); +void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, + void **x, pem_password_cb *cb, void *u); +#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ +((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u) +int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, + const EVP_CIPHER *enc,unsigned char *kstr,int klen, + pem_password_cb *cb, void *u); +#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ + ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u) + +STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); +int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, + unsigned char *kstr, int klen, pem_password_cb *cd, void *u); +#endif + +#ifndef OPENSSL_SYS_WIN16 +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); +void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, + char *x,const EVP_CIPHER *enc,unsigned char *kstr, + int klen,pem_password_cb *callback, void *u); +STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u); +#endif + +int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, + EVP_MD *md_type, unsigned char **ek, int *ekl, + unsigned char *iv, EVP_PKEY **pubk, int npubk); +void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, + unsigned char *in, int inl); +int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, + unsigned char *out, int *outl, EVP_PKEY *priv); + +void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +int PEM_def_callback(char *buf, int num, int w, void *key); +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, const char *type, int len, char *str); + +#ifndef SSLEAY_MACROS + +#include + +DECLARE_PEM_rw(X509, X509) + +DECLARE_PEM_rw(X509_AUX, X509) + +DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) + +DECLARE_PEM_rw(X509_REQ, X509_REQ) +DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) + +DECLARE_PEM_rw(X509_CRL, X509_CRL) + +DECLARE_PEM_rw(PKCS7, PKCS7) + +DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) + +DECLARE_PEM_rw(PKCS8, X509_SIG) + +DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) + +#ifndef OPENSSL_NO_RSA + +DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) + +DECLARE_PEM_rw_const(RSAPublicKey, RSA) +DECLARE_PEM_rw(RSA_PUBKEY, RSA) + +#endif + +#ifndef OPENSSL_NO_DSA + +DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) + +DECLARE_PEM_rw(DSA_PUBKEY, DSA) + +DECLARE_PEM_rw_const(DSAparams, DSA) + +#endif + +#ifndef OPENSSL_NO_EC +DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) +DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) +DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) +#endif + +#ifndef OPENSSL_NO_DH + +DECLARE_PEM_rw_const(DHparams, DH) + +#endif + +DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) + +DECLARE_PEM_rw(PUBKEY, EVP_PKEY) + +int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, + char *, int, pem_password_cb *, void *); +int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); + +EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, + char *kstr,int klen, pem_password_cb *cd, void *u); + +#endif /* SSLEAY_MACROS */ + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PEM_strings(void); + +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 +#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 +#define PEM_F_DO_PK8PKEY 126 +#define PEM_F_DO_PK8PKEY_FP 125 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DEF_CALLBACK 100 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_PK8PKEY 119 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 +#define PEM_F_PEM_READ_PRIVATEKEY 124 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/pem2.h b/libraries/external/openssl/linux/include/openssl/pem2.h new file mode 100755 index 0000000..97ba68a --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/pem2.h @@ -0,0 +1,70 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* + * This header only exists to break a circular dependency between pem and err + * Ben 30 Jan 1999. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HEADER_PEM_H +void ERR_load_PEM_strings(void); +#endif + +#ifdef __cplusplus +} +#endif diff --git a/libraries/external/openssl/linux/include/openssl/pkcs12.h b/libraries/external/openssl/linux/include/openssl/pkcs12.h new file mode 100755 index 0000000..46d8dad --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/pkcs12.h @@ -0,0 +1,333 @@ +/* pkcs12.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PKCS12_H +#define HEADER_PKCS12_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PKCS12_KEY_ID 1 +#define PKCS12_IV_ID 2 +#define PKCS12_MAC_ID 3 + +/* Default iteration count */ +#ifndef PKCS12_DEFAULT_ITER +#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER +#endif + +#define PKCS12_MAC_KEY_LENGTH 20 + +#define PKCS12_SALT_LEN 8 + +/* Uncomment out next line for unicode password and names, otherwise ASCII */ + +/*#define PBE_UNICODE*/ + +#ifdef PBE_UNICODE +#define PKCS12_key_gen PKCS12_key_gen_uni +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni +#else +#define PKCS12_key_gen PKCS12_key_gen_asc +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc +#endif + +/* MS key usage constants */ + +#define KEY_EX 0x10 +#define KEY_SIG 0x80 + +typedef struct { +X509_SIG *dinfo; +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; /* defaults to 1 */ +} PKCS12_MAC_DATA; + +typedef struct { +ASN1_INTEGER *version; +PKCS12_MAC_DATA *mac; +PKCS7 *authsafes; +} PKCS12; + +PREDECLARE_STACK_OF(PKCS12_SAFEBAG) + +typedef struct { +ASN1_OBJECT *type; +union { + struct pkcs12_bag_st *bag; /* secret, crl and certbag */ + struct pkcs8_priv_key_info_st *keybag; /* keybag */ + X509_SIG *shkeybag; /* shrouded key bag */ + STACK_OF(PKCS12_SAFEBAG) *safes; + ASN1_TYPE *other; +}value; +STACK_OF(X509_ATTRIBUTE) *attrib; +} PKCS12_SAFEBAG; + +DECLARE_STACK_OF(PKCS12_SAFEBAG) +DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG) +DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG) + +typedef struct pkcs12_bag_st { +ASN1_OBJECT *type; +union { + ASN1_OCTET_STRING *x509cert; + ASN1_OCTET_STRING *x509crl; + ASN1_OCTET_STRING *octet; + ASN1_IA5STRING *sdsicert; + ASN1_TYPE *other; /* Secret or other bag */ +}value; +} PKCS12_BAGS; + +#define PKCS12_ERROR 0 +#define PKCS12_OK 1 + +/* Compatibility macros */ + +#define M_PKCS12_x5092certbag PKCS12_x5092certbag +#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag + +#define M_PKCS12_certbag2x509 PKCS12_certbag2x509 +#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl + +#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data +#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes +#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes +#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata + +#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey +#define M_PKCS8_decrypt PKCS8_decrypt + +#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type) +#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type) +#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type + +#define PKCS12_get_attr(bag, attr_nid) \ + PKCS12_get_attr_gen(bag->attrib, attr_nid) + +#define PKCS8_get_attr(p8, attr_nid) \ + PKCS12_get_attr_gen(p8->attributes, attr_nid) + +#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) + + +PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509); +PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl); +X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag); +X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); + +PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, + int nid2); +PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, + int passlen); +X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, + int passlen, unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); +PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) *bags); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); + +int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); +STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); + +int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); +int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, + int namelen); +int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); +ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); +char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); +unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, + int passlen, unsigned char *in, int inlen, + unsigned char **data, int *datalen, int en_de); +void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf); +PKCS12 *PKCS12_init(int mode); +int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); +int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type, + int en_de); +int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *mac, unsigned int *maclen); +int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); +int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type); +int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, + int saltlen, const EVP_MD *md_type); +unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); +char *uni2asc(unsigned char *uni, int unilen); + +DECLARE_ASN1_FUNCTIONS(PKCS12) +DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) +DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) +DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) + +DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) +DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) + +void PKCS12_PBE_add(void); +int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, + STACK_OF(X509) **ca); +PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, + STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, + int mac_iter, int keytype); + +PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); +PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, + int key_usage, int iter, + int key_nid, char *pass); +int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, + int safe_nid, int iter, char *pass); +PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); + +int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); +int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); +PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); +PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); +int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS12_strings(void); + +/* Error codes for the PKCS12 functions. */ + +/* Function codes. */ +#define PKCS12_F_PARSE_BAG 129 +#define PKCS12_F_PARSE_BAGS 103 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102 +#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104 +#define PKCS12_F_PKCS12_CREATE 105 +#define PKCS12_F_PKCS12_GEN_MAC 107 +#define PKCS12_F_PKCS12_INIT 109 +#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 +#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 +#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 +#define PKCS12_F_PKCS12_KEY_GEN_ASC 110 +#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 +#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 +#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 +#define PKCS12_F_PKCS12_NEWPASS 128 +#define PKCS12_F_PKCS12_PACK_P7DATA 114 +#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 +#define PKCS12_F_PKCS12_PARSE 118 +#define PKCS12_F_PKCS12_PBE_CRYPT 119 +#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 +#define PKCS12_F_PKCS12_SETUP_MAC 122 +#define PKCS12_F_PKCS12_SET_MAC 123 +#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 +#define PKCS12_F_PKCS12_UNPACK_P7DATA 131 +#define PKCS12_F_PKCS12_VERIFY_MAC 126 +#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124 +#define PKCS12_F_PKCS8_ENCRYPT 125 + +/* Reason codes. */ +#define PKCS12_R_CANT_PACK_STRUCTURE 100 +#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 +#define PKCS12_R_DECODE_ERROR 101 +#define PKCS12_R_ENCODE_ERROR 102 +#define PKCS12_R_ENCRYPT_ERROR 103 +#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 +#define PKCS12_R_INVALID_NULL_ARGUMENT 104 +#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 +#define PKCS12_R_IV_GEN_ERROR 106 +#define PKCS12_R_KEY_GEN_ERROR 107 +#define PKCS12_R_MAC_ABSENT 108 +#define PKCS12_R_MAC_GENERATION_ERROR 109 +#define PKCS12_R_MAC_SETUP_ERROR 110 +#define PKCS12_R_MAC_STRING_SET_ERROR 111 +#define PKCS12_R_MAC_VERIFY_ERROR 112 +#define PKCS12_R_MAC_VERIFY_FAILURE 113 +#define PKCS12_R_PARSE_ERROR 114 +#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 +#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 +#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 +#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 +#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/pkcs7.h b/libraries/external/openssl/linux/include/openssl/pkcs7.h new file mode 100755 index 0000000..eeb0532 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/pkcs7.h @@ -0,0 +1,464 @@ +/* crypto/pkcs7/pkcs7.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PKCS7_H +#define HEADER_PKCS7_H + +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 thes are defined in wincrypt.h */ +#undef PKCS7_ISSUER_AND_SERIAL +#undef PKCS7_SIGNER_INFO +#endif + +/* +Encryption_ID DES-CBC +Digest_ID MD5 +Digest_Encryption_ID rsaEncryption +Key_Encryption_ID rsaEncryption +*/ + +typedef struct pkcs7_issuer_and_serial_st + { + X509_NAME *issuer; + ASN1_INTEGER *serial; + } PKCS7_ISSUER_AND_SERIAL; + +typedef struct pkcs7_signer_info_st + { + ASN1_INTEGER *version; /* version 1 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *digest_alg; + STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ + X509_ALGOR *digest_enc_alg; + ASN1_OCTET_STRING *enc_digest; + STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ + + /* The private key to sign with */ + EVP_PKEY *pkey; + } PKCS7_SIGNER_INFO; + +DECLARE_STACK_OF(PKCS7_SIGNER_INFO) +DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) + +typedef struct pkcs7_recip_info_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *key_enc_algor; + ASN1_OCTET_STRING *enc_key; + X509 *cert; /* get the pub-key from this */ + } PKCS7_RECIP_INFO; + +DECLARE_STACK_OF(PKCS7_RECIP_INFO) +DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) + +typedef struct pkcs7_signed_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + struct pkcs7_st *contents; + } PKCS7_SIGNED; +/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE. + * How about merging the two */ + +typedef struct pkcs7_enc_content_st + { + ASN1_OBJECT *content_type; + X509_ALGOR *algorithm; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + const EVP_CIPHER *cipher; + } PKCS7_ENC_CONTENT; + +typedef struct pkcs7_enveloped_st + { + ASN1_INTEGER *version; /* version 0 */ + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENVELOPE; + +typedef struct pkcs7_signedandenveloped_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + PKCS7_ENC_CONTENT *enc_data; + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + } PKCS7_SIGN_ENVELOPE; + +typedef struct pkcs7_digest_st + { + ASN1_INTEGER *version; /* version 0 */ + X509_ALGOR *md; /* md used */ + struct pkcs7_st *contents; + ASN1_OCTET_STRING *digest; + } PKCS7_DIGEST; + +typedef struct pkcs7_encrypted_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENCRYPT; + +typedef struct pkcs7_st + { + /* The following is non NULL if it contains ASN1 encoding of + * this structure */ + unsigned char *asn1; + long length; + +#define PKCS7_S_HEADER 0 +#define PKCS7_S_BODY 1 +#define PKCS7_S_TAIL 2 + int state; /* used during processing */ + + int detached; + + ASN1_OBJECT *type; + /* content as defined by the type */ + /* all encryption/message digests are applied to the 'contents', + * leaving out the 'type' field. */ + union { + char *ptr; + + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + + /* NID_pkcs7_signed */ + PKCS7_SIGNED *sign; + + /* NID_pkcs7_enveloped */ + PKCS7_ENVELOPE *enveloped; + + /* NID_pkcs7_signedAndEnveloped */ + PKCS7_SIGN_ENVELOPE *signed_and_enveloped; + + /* NID_pkcs7_digest */ + PKCS7_DIGEST *digest; + + /* NID_pkcs7_encrypted */ + PKCS7_ENCRYPT *encrypted; + + /* Anything else */ + ASN1_TYPE *other; + } d; + } PKCS7; + +DECLARE_STACK_OF(PKCS7) +DECLARE_ASN1_SET_OF(PKCS7) +DECLARE_PKCS12_STACK_OF(PKCS7) + +#define PKCS7_OP_SET_DETACHED_SIGNATURE 1 +#define PKCS7_OP_GET_DETACHED_SIGNATURE 2 + +#define PKCS7_get_signed_attributes(si) ((si)->auth_attr) +#define PKCS7_get_attributes(si) ((si)->unauth_attr) + +#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) +#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) +#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +#define PKCS7_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) + +#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) + +#define PKCS7_set_detached(p,v) \ + PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) +#define PKCS7_get_detached(p) \ + PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) + +#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) + +#ifdef SSLEAY_MACROS +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +/* S/MIME related flags */ + +#define PKCS7_TEXT 0x1 +#define PKCS7_NOCERTS 0x2 +#define PKCS7_NOSIGS 0x4 +#define PKCS7_NOCHAIN 0x8 +#define PKCS7_NOINTERN 0x10 +#define PKCS7_NOVERIFY 0x20 +#define PKCS7_DETACHED 0x40 +#define PKCS7_BINARY 0x80 +#define PKCS7_NOATTR 0x100 +#define PKCS7_NOSMIMECAP 0x200 +#define PKCS7_NOOLDMIMETYPE 0x400 +#define PKCS7_CRLFEOL 0x800 +#define PKCS7_STREAM 0x1000 +#define PKCS7_NOCRL 0x2000 + +/* Flags: for compatibility with older code */ + +#define SMIME_TEXT PKCS7_TEXT +#define SMIME_NOCERTS PKCS7_NOCERTS +#define SMIME_NOSIGS PKCS7_NOSIGS +#define SMIME_NOCHAIN PKCS7_NOCHAIN +#define SMIME_NOINTERN PKCS7_NOINTERN +#define SMIME_NOVERIFY PKCS7_NOVERIFY +#define SMIME_DETACHED PKCS7_DETACHED +#define SMIME_BINARY PKCS7_BINARY +#define SMIME_NOATTR PKCS7_NOATTR + +DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) + +#ifndef SSLEAY_MACROS +int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, + unsigned char *md,unsigned int *len); +#ifndef OPENSSL_NO_FP_API +PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); +int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7); +#endif +PKCS7 *PKCS7_dup(PKCS7 *p7); +PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7); +int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); +#endif + +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) +DECLARE_ASN1_FUNCTIONS(PKCS7) + +DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) +DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) + +DECLARE_ASN1_NDEF_FUNCTION(PKCS7) + +long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); + +int PKCS7_set_type(PKCS7 *p7, int type); +int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); +int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); +int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); +int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); +int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); +int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); +int PKCS7_content_new(PKCS7 *p7, int nid); +int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, + BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, + X509 *x509); + +BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); +int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); +BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); + + +PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, + EVP_PKEY *pkey, const EVP_MD *dgst); +X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); +STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); + +PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); +int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); +int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); +int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); + +PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); +ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type, + void *data); +int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, + void *value); +ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); +ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); +int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); + + +PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, + BIO *data, int flags); +int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, + BIO *indata, BIO *out, int flags); +STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); +PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, + int flags); +int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); + +int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, + STACK_OF(X509_ALGOR) *cap); +STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); +int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); + +int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); +PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); +int SMIME_crlf_copy(BIO *in, BIO *out, int flags); +int SMIME_text(BIO *in, BIO *out); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS7_strings(void); + +/* Error codes for the PKCS7 functions. */ + +/* Function codes. */ +#define PKCS7_F_B64_READ_PKCS7 120 +#define PKCS7_F_B64_WRITE_PKCS7 121 +#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 +#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 +#define PKCS7_F_PKCS7_ADD_CRL 101 +#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 +#define PKCS7_F_PKCS7_ADD_SIGNER 103 +#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 +#define PKCS7_F_PKCS7_CTRL 104 +#define PKCS7_F_PKCS7_DATADECODE 112 +#define PKCS7_F_PKCS7_DATAFINAL 128 +#define PKCS7_F_PKCS7_DATAINIT 105 +#define PKCS7_F_PKCS7_DATASIGN 106 +#define PKCS7_F_PKCS7_DATAVERIFY 107 +#define PKCS7_F_PKCS7_DECRYPT 114 +#define PKCS7_F_PKCS7_ENCRYPT 115 +#define PKCS7_F_PKCS7_FIND_DIGEST 127 +#define PKCS7_F_PKCS7_GET0_SIGNERS 124 +#define PKCS7_F_PKCS7_SET_CIPHER 108 +#define PKCS7_F_PKCS7_SET_CONTENT 109 +#define PKCS7_F_PKCS7_SET_DIGEST 126 +#define PKCS7_F_PKCS7_SET_TYPE 110 +#define PKCS7_F_PKCS7_SIGN 116 +#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 +#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 +#define PKCS7_F_PKCS7_VERIFY 117 +#define PKCS7_F_SMIME_READ_PKCS7 122 +#define PKCS7_F_SMIME_TEXT 123 + +/* Reason codes. */ +#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 +#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 +#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 +#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 +#define PKCS7_R_DECODE_ERROR 130 +#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 +#define PKCS7_R_DECRYPT_ERROR 119 +#define PKCS7_R_DIGEST_FAILURE 101 +#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 +#define PKCS7_R_ERROR_SETTING_CIPHER 121 +#define PKCS7_R_INVALID_MIME_TYPE 131 +#define PKCS7_R_INVALID_NULL_POINTER 143 +#define PKCS7_R_MIME_NO_CONTENT_TYPE 132 +#define PKCS7_R_MIME_PARSE_ERROR 133 +#define PKCS7_R_MIME_SIG_PARSE_ERROR 134 +#define PKCS7_R_MISSING_CERIPEND_INFO 103 +#define PKCS7_R_NO_CONTENT 122 +#define PKCS7_R_NO_CONTENT_TYPE 135 +#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136 +#define PKCS7_R_NO_MULTIPART_BOUNDARY 137 +#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 +#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY 146 +#define PKCS7_R_NO_SIGNATURES_ON_DATA 123 +#define PKCS7_R_NO_SIGNERS 142 +#define PKCS7_R_NO_SIG_CONTENT_TYPE 138 +#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 +#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 +#define PKCS7_R_PKCS7_DATAFINAL 126 +#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125 +#define PKCS7_R_PKCS7_DATASIGN 145 +#define PKCS7_R_PKCS7_PARSE_ERROR 139 +#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140 +#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 +#define PKCS7_R_SIGNATURE_FAILURE 105 +#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 +#define PKCS7_R_SIG_INVALID_MIME_TYPE 141 +#define PKCS7_R_SMIME_TEXT_ERROR 129 +#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 +#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 +#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 +#define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 +#define PKCS7_R_UNKNOWN_OPERATION 110 +#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 +#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 +#define PKCS7_R_WRONG_CONTENT_TYPE 113 +#define PKCS7_R_WRONG_PKCS7_TYPE 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/pq_compat.h b/libraries/external/openssl/linux/include/openssl/pq_compat.h new file mode 100755 index 0000000..2075042 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/pq_compat.h @@ -0,0 +1,147 @@ +/* crypto/pqueue/pqueue_compat.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "opensslconf.h" +#include + +/* + * The purpose of this header file is for supporting 64-bit integer + * manipulation on 32-bit (and lower) machines. Currently the only + * such environment is VMS, Utrix and those with smaller default integer + * sizes than 32 bits. For all such environment, we fall back to using + * BIGNUM. We may need to fine tune the conditions for systems that + * are incorrectly configured. + * + * The only clients of this code are (1) pqueue for priority, and + * (2) DTLS, for sequence number manipulation. + */ + +#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT) + +#define PQ_64BIT_IS_INTEGER 0 +#define PQ_64BIT_IS_BIGNUM 1 + +#define PQ_64BIT BIGNUM +#define PQ_64BIT_CTX BN_CTX + +#define pq_64bit_init(x) BN_init(x) +#define pq_64bit_free(x) BN_free(x) + +#define pq_64bit_ctx_new(ctx) BN_CTX_new() +#define pq_64bit_ctx_free(x) BN_CTX_free(x) + +#define pq_64bit_assign(x, y) BN_copy(x, y) +#define pq_64bit_assign_word(x, y) BN_set_word(x, y) +#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0 +#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0 +#define pq_64bit_add_word(x, w) BN_add_word(x, w) +#define pq_64bit_sub(r, x, y) BN_sub(r, x, y) +#define pq_64bit_sub_word(x, w) BN_sub_word(x, w) +#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn) +#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes) +#define pq_64bit_get_word(x) BN_get_word(x) +#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset) +#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift) +#define pq_64bit_set_bit(x, num) BN_set_bit(x, num) +#define pq_64bit_get_length(x) BN_num_bits((x)) + +#else + +#define PQ_64BIT_IS_INTEGER 1 +#define PQ_64BIT_IS_BIGNUM 0 + +#if defined(SIXTY_FOUR_BIT) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%lld" +#elif defined(SIXTY_FOUR_BIT_LONG) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%ld" +#elif defined(THIRTY_TWO_BIT) +#define PQ_64BIT BN_ULLONG +#define PQ_64BIT_PRINT "%lld" +#endif + +#define PQ_64BIT_CTX void + +#define pq_64bit_init(x) +#define pq_64bit_free(x) +#define pq_64bit_ctx_new(ctx) (ctx) +#define pq_64bit_ctx_free(x) + +#define pq_64bit_assign(x, y) (*(x) = *(y)) +#define pq_64bit_assign_word(x, y) (*(x) = y) +#define pq_64bit_gt(x, y) (*(x) > *(y)) +#define pq_64bit_eq(x, y) (*(x) == *(y)) +#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w))) +#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y))) +#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w))) +#define pq_64bit_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num) +#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes) +#define pq_64bit_get_word(x) *(x) +#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift))) +#define pq_64bit_set_bit(x, num) do { \ + PQ_64BIT mask = 1; \ + mask = mask << (num); \ + *(x) |= mask; \ + } while(0) +#endif /* OPENSSL_SYS_VMS */ diff --git a/libraries/external/openssl/linux/include/openssl/pqueue.h b/libraries/external/openssl/linux/include/openssl/pqueue.h new file mode 100755 index 0000000..699095f --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/pqueue.h @@ -0,0 +1,95 @@ +/* crypto/pqueue/pqueue.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PQUEUE_H +#define HEADER_PQUEUE_H + +#include +#include +#include + +#include + +typedef struct _pqueue *pqueue; + +typedef struct _pitem + { + PQ_64BIT priority; + void *data; + struct _pitem *next; + } pitem; + +typedef struct _pitem *piterator; + +pitem *pitem_new(PQ_64BIT priority, void *data); +void pitem_free(pitem *item); + +pqueue pqueue_new(void); +void pqueue_free(pqueue pq); + +pitem *pqueue_insert(pqueue pq, pitem *item); +pitem *pqueue_peek(pqueue pq); +pitem *pqueue_pop(pqueue pq); +pitem *pqueue_find(pqueue pq, PQ_64BIT priority); +pitem *pqueue_iterator(pqueue pq); +pitem *pqueue_next(piterator *iter); + +void pqueue_print(pqueue pq); + +#endif /* ! HEADER_PQUEUE_H */ diff --git a/libraries/external/openssl/linux/include/openssl/rand.h b/libraries/external/openssl/linux/include/openssl/rand.h new file mode 100755 index 0000000..e2f9f82 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/rand.h @@ -0,0 +1,140 @@ +/* crypto/rand/rand.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RAND_H +#define HEADER_RAND_H + +#include +#include +#include + +#if defined(OPENSSL_SYS_WINDOWS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_RAND_SIZE_T size_t +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct rand_meth_st RAND_METHOD; */ + +struct rand_meth_st + { + void (*seed)(const void *buf, int num); + int (*bytes)(unsigned char *buf, int num); + void (*cleanup)(void); + void (*add)(const void *buf, int num, double entropy); + int (*pseudorand)(unsigned char *buf, int num); + int (*status)(void); + }; + +#ifdef BN_DEBUG +extern int rand_predictable; +#endif + +int RAND_set_rand_method(const RAND_METHOD *meth); +const RAND_METHOD *RAND_get_rand_method(void); +#ifndef OPENSSL_NO_ENGINE +int RAND_set_rand_engine(ENGINE *engine); +#endif +RAND_METHOD *RAND_SSLeay(void); +void RAND_cleanup(void ); +int RAND_bytes(unsigned char *buf,int num); +int RAND_pseudo_bytes(unsigned char *buf,int num); +void RAND_seed(const void *buf,int num); +void RAND_add(const void *buf,int num,double entropy); +int RAND_load_file(const char *file,long max_bytes); +int RAND_write_file(const char *file); +const char *RAND_file_name(char *file,size_t num); +int RAND_status(void); +int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); +int RAND_egd(const char *path); +int RAND_egd_bytes(const char *path,int bytes); +int RAND_poll(void); + +#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) + +void RAND_screen(void); +int RAND_event(UINT, WPARAM, LPARAM); + +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RAND_strings(void); + +/* Error codes for the RAND functions. */ + +/* Function codes. */ +#define RAND_F_RAND_GET_RAND_METHOD 101 +#define RAND_F_SSLEAY_RAND_BYTES 100 + +/* Reason codes. */ +#define RAND_R_PRNG_NOT_SEEDED 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/rc2.h b/libraries/external/openssl/linux/include/openssl/rc2.h new file mode 100755 index 0000000..13edfaf --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/rc2.h @@ -0,0 +1,101 @@ +/* crypto/rc2/rc2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC2_H +#define HEADER_RC2_H + +#include /* OPENSSL_NO_RC2, RC2_INT */ +#ifdef OPENSSL_NO_RC2 +#error RC2 is disabled. +#endif + +#define RC2_ENCRYPT 1 +#define RC2_DECRYPT 0 + +#define RC2_BLOCK 8 +#define RC2_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc2_key_st + { + RC2_INT data[64]; + } RC2_KEY; + + +void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); +void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, + int enc); +void RC2_encrypt(unsigned long *data,RC2_KEY *key); +void RC2_decrypt(unsigned long *data,RC2_KEY *key); +void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, int enc); +void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/rc4.h b/libraries/external/openssl/linux/include/openssl/rc4.h new file mode 100755 index 0000000..676ffdb --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/rc4.h @@ -0,0 +1,87 @@ +/* crypto/rc4/rc4.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC4_H +#define HEADER_RC4_H + +#include /* OPENSSL_NO_RC4, RC4_INT */ +#ifdef OPENSSL_NO_RC4 +#error RC4 is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc4_key_st + { + RC4_INT x,y; + RC4_INT data[256]; + } RC4_KEY; + + +const char *RC4_options(void); +void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); +void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, + unsigned char *outdata); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ripemd.h b/libraries/external/openssl/linux/include/openssl/ripemd.h new file mode 100755 index 0000000..e0474f0 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ripemd.h @@ -0,0 +1,104 @@ +/* crypto/ripemd/ripemd.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RIPEMD_H +#define HEADER_RIPEMD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_RIPEMD +#error RIPEMD is disabled. +#endif + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define RIPEMD160_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define RIPEMD160_LONG unsigned long +#define RIPEMD160_LONG_LOG2 3 +#else +#define RIPEMD160_LONG unsigned int +#endif + +#define RIPEMD160_CBLOCK 64 +#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) +#define RIPEMD160_DIGEST_LENGTH 20 + +typedef struct RIPEMD160state_st + { + RIPEMD160_LONG A,B,C,D,E; + RIPEMD160_LONG Nl,Nh; + RIPEMD160_LONG data[RIPEMD160_LBLOCK]; + unsigned int num; + } RIPEMD160_CTX; + +int RIPEMD160_Init(RIPEMD160_CTX *c); +int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); +int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); +unsigned char *RIPEMD160(const unsigned char *d, size_t n, + unsigned char *md); +void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/rsa.h b/libraries/external/openssl/linux/include/openssl/rsa.h new file mode 100755 index 0000000..f650681 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/rsa.h @@ -0,0 +1,441 @@ +/* crypto/rsa/rsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RSA_H +#define HEADER_RSA_H + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_NO_RSA +#error RSA is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct rsa_st RSA; */ +/* typedef struct rsa_meth_st RSA_METHOD; */ + +struct rsa_meth_st + { + const char *name; + int (*rsa_pub_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_pub_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */ + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(RSA *rsa); /* called at new */ + int (*finish)(RSA *rsa); /* called at free */ + int flags; /* RSA_METHOD_FLAG_* things */ + char *app_data; /* may be needed! */ +/* New sign and verify functions: some libraries don't allow arbitrary data + * to be signed/verified: this allows them to be used. Note: for this to work + * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used + * RSA_sign(), RSA_verify() should be used instead. Note: for backwards + * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER + * option is set in 'flags'. + */ + int (*rsa_sign)(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, const RSA *rsa); + int (*rsa_verify)(int dtype, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); +/* If this callback is NULL, the builtin software RSA key-gen will be used. This + * is for behavioural compatibility whilst the code gets rewired, but one day + * it would be nice to assume there are no such things as "builtin software" + * implementations. */ + int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + }; + +struct rsa_st + { + /* The first parameter is used to pickup errors where + * this is passed instead of aEVP_PKEY, it is set to 0 */ + int pad; + long version; + const RSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + BIGNUM *n; + BIGNUM *e; + BIGNUM *d; + BIGNUM *p; + BIGNUM *q; + BIGNUM *dmp1; + BIGNUM *dmq1; + BIGNUM *iqmp; + /* be careful using this if the RSA structure is shared */ + CRYPTO_EX_DATA ex_data; + int references; + int flags; + + /* Used to cache montgomery values */ + BN_MONT_CTX *_method_mod_n; + BN_MONT_CTX *_method_mod_p; + BN_MONT_CTX *_method_mod_q; + + /* all BIGNUM values are actually in the following data, if it is not + * NULL */ + char *bignum_data; + BN_BLINDING *blinding; + BN_BLINDING *mt_blinding; + }; + +#ifndef OPENSSL_RSA_MAX_MODULUS_BITS +# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 +#endif + +#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS +# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 +#endif +#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS +# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "large" modulus only */ +#endif + +#define RSA_3 0x3L +#define RSA_F4 0x10001L + +#define RSA_METHOD_FLAG_NO_CHECK 0x0001 /* don't check pub/private match */ + +#define RSA_FLAG_CACHE_PUBLIC 0x0002 +#define RSA_FLAG_CACHE_PRIVATE 0x0004 +#define RSA_FLAG_BLINDING 0x0008 +#define RSA_FLAG_THREAD_SAFE 0x0010 +/* This flag means the private key operations will be handled by rsa_mod_exp + * and that they do not depend on the private key components being present: + * for example a key stored in external hardware. Without this flag bn_mod_exp + * gets called when private key components are absent. + */ +#define RSA_FLAG_EXT_PKEY 0x0020 + +/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions. + */ +#define RSA_FLAG_SIGN_VER 0x0040 + +#define RSA_FLAG_NO_BLINDING 0x0080 /* new with 0.9.6j and 0.9.7b; the built-in + * RSA implementation now uses blinding by + * default (ignoring RSA_FLAG_BLINDING), + * but other engines might not need it + */ +#define RSA_FLAG_NO_EXP_CONSTTIME 0x0100 /* new with 0.9.7h; the built-in RSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#define RSA_PKCS1_PADDING 1 +#define RSA_SSLV23_PADDING 2 +#define RSA_NO_PADDING 3 +#define RSA_PKCS1_OAEP_PADDING 4 +#define RSA_X931_PADDING 5 + +#define RSA_PKCS1_PADDING_SIZE 11 + +#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) +#define RSA_get_app_data(s) RSA_get_ex_data(s,0) + +RSA * RSA_new(void); +RSA * RSA_new_method(ENGINE *engine); +int RSA_size(const RSA *); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +RSA * RSA_generate_key(int bits, unsigned long e,void + (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + +int RSA_check_key(const RSA *); + /* next 4 return -1 on error */ +int RSA_public_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_public_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +void RSA_free (RSA *r); +/* "up" the RSA object's reference count */ +int RSA_up_ref(RSA *r); + +int RSA_flags(const RSA *r); + +void RSA_set_default_method(const RSA_METHOD *meth); +const RSA_METHOD *RSA_get_default_method(void); +const RSA_METHOD *RSA_get_method(const RSA *rsa); +int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); + +/* This function needs the memory locking malloc callbacks to be installed */ +int RSA_memory_lock(RSA *r); + +/* these are the actual SSLeay RSA functions */ +const RSA_METHOD *RSA_PKCS1_SSLeay(void); + +const RSA_METHOD *RSA_null_method(void); + +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) + +#ifndef OPENSSL_NO_FP_API +int RSA_print_fp(FILE *fp, const RSA *r,int offset); +#endif + +#ifndef OPENSSL_NO_BIO +int RSA_print(BIO *bp, const RSA *r,int offset); +#endif + +int i2d_RSA_NET(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); +RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); + +int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); +RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); + +/* The following 2 functions sign and verify a X509_SIG ASN1 object + * inside PKCS#1 padded RSA encryption */ +int RSA_sign(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +/* The following 2 function sign and verify a ASN1_OCTET_STRING + * object inside PKCS#1 padded RSA encryption */ +int RSA_sign_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); +void RSA_blinding_off(RSA *rsa); +BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); + +int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int PKCS1_MGF1(unsigned char *mask, long len, + const unsigned char *seed, long seedlen, const EVP_MD *dgst); +int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl, + const unsigned char *p,int pl); +int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len, + const unsigned char *p,int pl); +int RSA_padding_add_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_none(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_none(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_X931_hash_id(int nid); + +int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const unsigned char *EM, int sLen); +int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, int sLen); + +int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int RSA_set_ex_data(RSA *r,int idx,void *arg); +void *RSA_get_ex_data(const RSA *r, int idx); + +RSA *RSAPublicKey_dup(RSA *rsa); +RSA *RSAPrivateKey_dup(RSA *rsa); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RSA_strings(void); + +/* Error codes for the RSA functions. */ + +/* Function codes. */ +#define RSA_F_MEMORY_LOCK 100 +#define RSA_F_RSA_BUILTIN_KEYGEN 129 +#define RSA_F_RSA_CHECK_KEY 123 +#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 +#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 +#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 +#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 +#define RSA_F_RSA_GENERATE_KEY 105 +#define RSA_F_RSA_MEMORY_LOCK 130 +#define RSA_F_RSA_NEW_METHOD 106 +#define RSA_F_RSA_NULL 124 +#define RSA_F_RSA_NULL_MOD_EXP 131 +#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 +#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 +#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 +#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 +#define RSA_F_RSA_PADDING_ADD_NONE 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 +#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 +#define RSA_F_RSA_PADDING_ADD_SSLV23 110 +#define RSA_F_RSA_PADDING_ADD_X931 127 +#define RSA_F_RSA_PADDING_CHECK_NONE 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 114 +#define RSA_F_RSA_PADDING_CHECK_X931 128 +#define RSA_F_RSA_PRINT 115 +#define RSA_F_RSA_PRINT_FP 116 +#define RSA_F_RSA_SETUP_BLINDING 136 +#define RSA_F_RSA_SIGN 117 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 +#define RSA_F_RSA_VERIFY 119 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 +#define RSA_F_RSA_VERIFY_PKCS1_PSS 126 + +/* Reason codes. */ +#define RSA_R_ALGORITHM_MISMATCH 100 +#define RSA_R_BAD_E_VALUE 101 +#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +#define RSA_R_BAD_PAD_BYTE_COUNT 103 +#define RSA_R_BAD_SIGNATURE 104 +#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +#define RSA_R_DATA_TOO_LARGE 109 +#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 +#define RSA_R_DATA_TOO_SMALL 111 +#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 +#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 +#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 +#define RSA_R_FIRST_OCTET_INVALID 133 +#define RSA_R_INVALID_HEADER 137 +#define RSA_R_INVALID_MESSAGE_LENGTH 131 +#define RSA_R_INVALID_PADDING 138 +#define RSA_R_INVALID_TRAILER 139 +#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 +#define RSA_R_KEY_SIZE_TOO_SMALL 120 +#define RSA_R_LAST_OCTET_INVALID 134 +#define RSA_R_MODULUS_TOO_LARGE 105 +#define RSA_R_NO_PUBLIC_EXPONENT 140 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 +#define RSA_R_OAEP_DECODING_ERROR 121 +#define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_P_NOT_PRIME 128 +#define RSA_R_Q_NOT_PRIME 129 +#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 +#define RSA_R_SLEN_CHECK_FAILED 136 +#define RSA_R_SLEN_RECOVERY_FAILED 135 +#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +#define RSA_R_UNKNOWN_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/safestack.h b/libraries/external/openssl/linux/include/openssl/safestack.h new file mode 100755 index 0000000..8515019 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/safestack.h @@ -0,0 +1,1850 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SAFESTACK_H +#define HEADER_SAFESTACK_H + +#include + +typedef void (*openssl_fptr)(void); +#define openssl_fcast(f) ((openssl_fptr)f) + +#ifdef DEBUG_SAFESTACK + +#define STACK_OF(type) struct stack_st_##type +#define PREDECLARE_STACK_OF(type) STACK_OF(type); + +#define DECLARE_STACK_OF(type) \ +STACK_OF(type) \ + { \ + STACK stack; \ + }; + +#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ + +/* SKM_sk_... stack macros are internal to safestack.h: + * never use them directly, use sk__... instead */ +#define SKM_sk_new(type, cmp) \ + ((STACK_OF(type) * (*)(int (*)(const type * const *, const type * const *)))openssl_fcast(sk_new))(cmp) +#define SKM_sk_new_null(type) \ + ((STACK_OF(type) * (*)(void))openssl_fcast(sk_new_null))() +#define SKM_sk_free(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_free))(st) +#define SKM_sk_num(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_num))(st) +#define SKM_sk_value(type, st,i) \ + ((type * (*)(const STACK_OF(type) *, int))openssl_fcast(sk_value))(st, i) +#define SKM_sk_set(type, st,i,val) \ + ((type * (*)(STACK_OF(type) *, int, type *))openssl_fcast(sk_set))(st, i, val) +#define SKM_sk_zero(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_zero))(st) +#define SKM_sk_push(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_push))(st, val) +#define SKM_sk_unshift(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_unshift))(st, val) +#define SKM_sk_find(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_find))(st, val) +#define SKM_sk_delete(type, st,i) \ + ((type * (*)(STACK_OF(type) *, int))openssl_fcast(sk_delete))(st, i) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type * (*)(STACK_OF(type) *, type *))openssl_fcast(sk_delete_ptr))(st, ptr) +#define SKM_sk_insert(type, st,val,i) \ + ((int (*)(STACK_OF(type) *, type *, int))openssl_fcast(sk_insert))(st, val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*(*)(STACK_OF(type) *, int (*)(const type * const *, const type * const *))) \ + (const type * const *, const type * const *))openssl_fcast(sk_set_cmp_func))\ + (st, cmp) +#define SKM_sk_dup(type, st) \ + ((STACK_OF(type) *(*)(STACK_OF(type) *))openssl_fcast(sk_dup))(st) +#define SKM_sk_pop_free(type, st,free_func) \ + ((void (*)(STACK_OF(type) *, void (*)(type *)))openssl_fcast(sk_pop_free))\ + (st, free_func) +#define SKM_sk_shift(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_shift))(st) +#define SKM_sk_pop(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_pop))(st) +#define SKM_sk_sort(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_sort))(st) +#define SKM_sk_is_sorted(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_is_sorted))(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ +((STACK_OF(type) * (*) (STACK_OF(type) **,const unsigned char **, long , \ + type *(*)(type **, const unsigned char **,long), \ + void (*)(type *), int ,int )) openssl_fcast(d2i_ASN1_SET)) \ + (st,pp,length, d2i_func, free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + ((int (*)(STACK_OF(type) *,unsigned char **, \ + int (*)(type *,unsigned char **), int , int , int)) openssl_fcast(i2d_ASN1_SET)) \ + (st,pp,i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ((unsigned char *(*)(STACK_OF(type) *, \ + int (*)(type *,unsigned char **), unsigned char **,int *)) openssl_fcast(ASN1_seq_pack)) \ + (st, i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ((STACK_OF(type) * (*)(const unsigned char *,int, \ + type *(*)(type **,const unsigned char **, long), \ + void (*)(type *)))openssl_fcast(ASN1_seq_unpack)) \ + (buf,len,d2i_func, free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK_OF(type) * (*)(X509_ALGOR *, \ + type *(*)(type **, const unsigned char **, long), \ + void (*)(type *), \ + const char *, int, \ + ASN1_STRING *, int))PKCS12_decrypt_d2i) \ + (algor,d2i_func,free_func,pass,passlen,oct,seq) + +#else + +#define STACK_OF(type) STACK +#define PREDECLARE_STACK_OF(type) /* nada */ +#define DECLARE_STACK_OF(type) /* nada */ +#define IMPLEMENT_STACK_OF(type) /* nada */ + +#define SKM_sk_new(type, cmp) \ + sk_new((int (*)(const char * const *, const char * const *))(cmp)) +#define SKM_sk_new_null(type) \ + sk_new_null() +#define SKM_sk_free(type, st) \ + sk_free(st) +#define SKM_sk_num(type, st) \ + sk_num(st) +#define SKM_sk_value(type, st,i) \ + ((type *)sk_value(st, i)) +#define SKM_sk_set(type, st,i,val) \ + ((type *)sk_set(st, i,(char *)val)) +#define SKM_sk_zero(type, st) \ + sk_zero(st) +#define SKM_sk_push(type, st,val) \ + sk_push(st, (char *)val) +#define SKM_sk_unshift(type, st,val) \ + sk_unshift(st, val) +#define SKM_sk_find(type, st,val) \ + sk_find(st, (char *)val) +#define SKM_sk_delete(type, st,i) \ + ((type *)sk_delete(st, i)) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type *)sk_delete_ptr(st,(char *)ptr)) +#define SKM_sk_insert(type, st,val,i) \ + sk_insert(st, (char *)val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*)(const type * const *,const type * const *)) \ + sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp))) +#define SKM_sk_dup(type, st) \ + sk_dup(st) +#define SKM_sk_pop_free(type, st,free_func) \ + sk_pop_free(st, (void (*)(void *))free_func) +#define SKM_sk_shift(type, st) \ + ((type *)sk_shift(st)) +#define SKM_sk_pop(type, st) \ + ((type *)sk_pop(st)) +#define SKM_sk_sort(type, st) \ + sk_sort(st) +#define SKM_sk_is_sorted(type, st) \ + sk_is_sorted(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq)) + +#endif + +/* This block of defines is updated by util/mkstack.pl, please do not touch! */ +#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION) +#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val)) +#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr)) +#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i)) +#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp)) +#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st) +#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func)) +#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st)) + +#define sk_ASIdOrRange_new(st) SKM_sk_new(ASIdOrRange, (st)) +#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange) +#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st)) +#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st)) +#define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i)) +#define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val)) +#define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st)) +#define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i)) +#define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr)) +#define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i)) +#define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp)) +#define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st) +#define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func)) +#define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st)) +#define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st)) +#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st)) +#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st)) + +#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING) +#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val)) +#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr)) +#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i)) +#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp)) +#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st) +#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func)) +#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st)) + +#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) +#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val)) +#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr)) +#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i)) +#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp)) +#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st) +#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func)) +#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st)) + +#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT) +#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val)) +#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr)) +#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i)) +#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp)) +#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st) +#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func)) +#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st)) + +#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE) +#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val)) +#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr)) +#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i)) +#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp)) +#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st) +#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func)) +#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st)) + +#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE) +#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val)) +#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr)) +#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i)) +#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp)) +#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st) +#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func)) +#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st)) + +#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE) +#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val)) +#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr)) +#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i)) +#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp)) +#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st) +#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func)) +#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st)) + +#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) +#define sk_BIO_new_null() SKM_sk_new_null(BIO) +#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) +#define sk_BIO_num(st) SKM_sk_num(BIO, (st)) +#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i)) +#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val)) +#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st)) +#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val)) +#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val)) +#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val)) +#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val)) +#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i)) +#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr)) +#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i)) +#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp)) +#define sk_BIO_dup(st) SKM_sk_dup(BIO, st) +#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func)) +#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st)) +#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st)) +#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) +#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st)) + +#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE) +#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val)) +#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr)) +#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i)) +#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp)) +#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st) +#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func)) +#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st)) + +#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st)) +#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE) +#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st)) +#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st)) +#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val)) +#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st)) +#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr)) +#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i)) +#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp)) +#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st) +#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func)) +#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st)) +#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st)) +#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st)) +#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st)) + +#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) +#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) +#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) +#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st)) +#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val)) +#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st)) +#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr)) +#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i)) +#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp)) +#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st) +#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func)) +#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st)) +#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st)) +#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st)) +#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st)) + +#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS) +#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr)) +#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp)) +#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st) +#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func)) +#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st)) + +#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock) +#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val)) +#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr)) +#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i)) +#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp)) +#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st) +#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func)) +#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st)) + +#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st)) +#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT) +#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st)) +#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st)) +#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val)) +#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st)) +#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr)) +#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i)) +#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp)) +#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st) +#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func)) +#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st)) +#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st)) +#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) +#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st)) + +#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st)) +#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE) +#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st)) +#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st)) +#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i)) +#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val)) +#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st)) +#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val)) +#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val)) +#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val)) +#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val)) +#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i)) +#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr)) +#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i)) +#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp)) +#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st) +#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func)) +#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st)) +#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st)) +#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st)) +#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st)) + +#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM) +#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val)) +#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr)) +#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp)) +#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st) +#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func)) +#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st)) + +#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) +#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val)) +#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr)) +#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i)) +#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp)) +#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st) +#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func)) +#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st)) + +#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE) +#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val)) +#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr)) +#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i)) +#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp)) +#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st) +#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func)) +#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st)) + +#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st)) +#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily) +#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st)) +#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st)) +#define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i)) +#define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val)) +#define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st)) +#define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i)) +#define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr)) +#define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i)) +#define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp)) +#define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st) +#define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func)) +#define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st)) +#define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st)) +#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st)) +#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st)) + +#define sk_IPAddressOrRange_new(st) SKM_sk_new(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange) +#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i)) +#define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val)) +#define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i)) +#define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr)) +#define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i)) +#define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp)) +#define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st) +#define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func)) +#define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st)) + +#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY) +#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val)) +#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr)) +#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i)) +#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp)) +#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st) +#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func)) +#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st)) + +#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA) +#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val)) +#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr)) +#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i)) +#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp)) +#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st) +#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func)) +#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st)) + +#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY) +#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val)) +#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr)) +#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i)) +#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp)) +#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st) +#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func)) +#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st)) + +#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM) +#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val)) +#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr)) +#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i)) +#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp)) +#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st) +#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func)) +#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st)) + +#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA) +#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val)) +#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr)) +#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i)) +#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp)) +#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st) +#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func)) +#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st)) + +#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY) +#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val)) +#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr)) +#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i)) +#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp)) +#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st) +#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func)) +#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st)) + +#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME) +#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val)) +#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr)) +#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i)) +#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp)) +#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st) +#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func)) +#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st)) + +#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY) +#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val)) +#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr)) +#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i)) +#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp)) +#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st) +#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func)) +#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st)) + +#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) +#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) +#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) +#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st)) +#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val)) +#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st)) +#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr)) +#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i)) +#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp)) +#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st) +#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func)) +#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st)) +#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st)) +#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st)) +#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st)) + +#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st)) +#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM) +#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st)) +#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st)) +#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val)) +#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st)) +#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr)) +#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i)) +#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp)) +#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st) +#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func)) +#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st)) +#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st)) +#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st)) +#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st)) + +#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS) +#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val)) +#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr)) +#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i)) +#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp)) +#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st) +#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func)) +#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st)) + +#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID) +#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val)) +#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr)) +#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i)) +#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp)) +#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st) +#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func)) +#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st)) + +#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ) +#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val)) +#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr)) +#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i)) +#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp)) +#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st) +#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func)) +#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st)) + +#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP) +#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val)) +#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr)) +#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i)) +#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp)) +#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st) +#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func)) +#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st)) + +#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) +#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val)) +#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr)) +#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i)) +#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp)) +#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st) +#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func)) +#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st)) + +#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st)) +#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7) +#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st)) +#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st)) +#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i)) +#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val)) +#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st)) +#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val)) +#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val)) +#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val)) +#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val)) +#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i)) +#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr)) +#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i)) +#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp)) +#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st) +#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func)) +#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st)) +#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st)) +#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st)) +#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st)) + +#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO) +#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val)) +#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr)) +#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i)) +#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp)) +#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st) +#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func)) +#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st)) + +#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO) +#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val)) +#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr)) +#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i)) +#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp)) +#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st) +#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func)) +#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st)) + +#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st)) +#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO) +#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st)) +#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st)) +#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val)) +#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st)) +#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr)) +#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i)) +#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp)) +#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st) +#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func)) +#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st)) +#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st)) +#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st)) +#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st)) + +#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO) +#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val)) +#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr)) +#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i)) +#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp)) +#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st) +#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func)) +#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st)) + +#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING) +#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val)) +#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr)) +#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i)) +#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp)) +#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st) +#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func)) +#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st)) + +#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER) +#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val)) +#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr)) +#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i)) +#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp)) +#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st) +#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func)) +#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st)) + +#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st)) +#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP) +#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st)) +#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st)) +#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val)) +#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st)) +#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr)) +#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i)) +#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp)) +#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st) +#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func)) +#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st)) +#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st)) +#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st)) +#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st)) + +#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT) +#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val)) +#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr)) +#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i)) +#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp)) +#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st) +#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func)) +#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st)) + +#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st)) +#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID) +#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st)) +#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st)) +#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i)) +#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val)) +#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st)) +#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val)) +#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val)) +#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val)) +#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val)) +#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i)) +#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr)) +#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i)) +#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp)) +#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st) +#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func)) +#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st)) +#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st)) +#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) +#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st)) + +#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st)) +#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING) +#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st)) +#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st)) +#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i)) +#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val)) +#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st)) +#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val)) +#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val)) +#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val)) +#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val)) +#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i)) +#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr)) +#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i)) +#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp)) +#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st) +#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func)) +#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st)) +#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st)) +#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st)) +#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st)) + +#define sk_X509_new(st) SKM_sk_new(X509, (st)) +#define sk_X509_new_null() SKM_sk_new_null(X509) +#define sk_X509_free(st) SKM_sk_free(X509, (st)) +#define sk_X509_num(st) SKM_sk_num(X509, (st)) +#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i)) +#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val)) +#define sk_X509_zero(st) SKM_sk_zero(X509, (st)) +#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val)) +#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val)) +#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val)) +#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val)) +#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i)) +#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr)) +#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i)) +#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp)) +#define sk_X509_dup(st) SKM_sk_dup(X509, st) +#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func)) +#define sk_X509_shift(st) SKM_sk_shift(X509, (st)) +#define sk_X509_pop(st) SKM_sk_pop(X509, (st)) +#define sk_X509_sort(st) SKM_sk_sort(X509, (st)) +#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st)) + +#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD) +#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val)) +#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr)) +#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i)) +#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp)) +#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st) +#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func)) +#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st)) + +#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st)) +#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR) +#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st)) +#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st)) +#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val)) +#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st)) +#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr)) +#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i)) +#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp)) +#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st) +#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func)) +#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st)) +#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st)) +#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st)) +#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st)) + +#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE) +#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val)) +#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr)) +#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i)) +#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp)) +#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st) +#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func)) +#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st)) + +#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st)) +#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL) +#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st)) +#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st)) +#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i)) +#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val)) +#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st)) +#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val)) +#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val)) +#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val)) +#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val)) +#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i)) +#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr)) +#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i)) +#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp)) +#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st) +#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func)) +#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st)) +#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st)) +#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st)) +#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st)) + +#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION) +#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val)) +#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr)) +#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i)) +#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp)) +#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st) +#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func)) +#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st)) + +#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st)) +#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO) +#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st)) +#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st)) +#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i)) +#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val)) +#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st)) +#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val)) +#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val)) +#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val)) +#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val)) +#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i)) +#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr)) +#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i)) +#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp)) +#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st) +#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func)) +#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st)) +#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st)) +#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st)) +#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st)) + +#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP) +#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val)) +#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr)) +#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i)) +#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp)) +#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st) +#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func)) +#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st)) + +#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st)) +#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME) +#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st)) +#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st)) +#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i)) +#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val)) +#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st)) +#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val)) +#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val)) +#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val)) +#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val)) +#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i)) +#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr)) +#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i)) +#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp)) +#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st) +#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func)) +#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st)) +#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st)) +#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st)) +#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st)) + +#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY) +#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val)) +#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr)) +#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i)) +#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp)) +#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st) +#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func)) +#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st)) + +#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st)) +#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT) +#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st)) +#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st)) +#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val)) +#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st)) +#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr)) +#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i)) +#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp)) +#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st) +#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func)) +#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st)) +#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st)) +#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st)) +#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st)) + +#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA) +#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val)) +#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr)) +#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i)) +#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp)) +#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st) +#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func)) +#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st)) + +#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE) +#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val)) +#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr)) +#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i)) +#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp)) +#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st) +#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func)) +#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st)) + +#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF) +#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val)) +#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr)) +#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i)) +#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp)) +#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st) +#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func)) +#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st)) + +#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE) +#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val)) +#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr)) +#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i)) +#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp)) +#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st) +#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func)) +#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st)) + +#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st)) +#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED) +#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st)) +#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st)) +#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val)) +#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st)) +#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr)) +#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i)) +#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp)) +#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st) +#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func)) +#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st)) +#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st)) +#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st)) +#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st)) + +#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st)) +#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST) +#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st)) +#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st)) +#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val)) +#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st)) +#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr)) +#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i)) +#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp)) +#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st) +#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func)) +#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st)) +#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st)) +#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st)) +#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st)) + +#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM) +#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val)) +#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr)) +#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i)) +#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp)) +#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st) +#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func)) +#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st)) + +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func)) + +#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) + +#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) +/* End of util/mkstack.pl block, you may now edit :-) */ + +#endif /* !defined HEADER_SAFESTACK_H */ diff --git a/libraries/external/openssl/linux/include/openssl/sha.h b/libraries/external/openssl/linux/include/openssl/sha.h new file mode 100755 index 0000000..5064482 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/sha.h @@ -0,0 +1,200 @@ +/* crypto/sha/sha.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SHA_H +#define HEADER_SHA_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) +#error SHA is disabled. +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_SHA_SIZE_T size_t +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! SHA_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define SHA_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define SHA_LONG unsigned long +#define SHA_LONG_LOG2 3 +#else +#define SHA_LONG unsigned int +#endif + +#define SHA_LBLOCK 16 +#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA_LAST_BLOCK (SHA_CBLOCK-8) +#define SHA_DIGEST_LENGTH 20 + +typedef struct SHAstate_st + { + SHA_LONG h0,h1,h2,h3,h4; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num; + } SHA_CTX; + +#ifndef OPENSSL_NO_SHA0 +int SHA_Init(SHA_CTX *c); +int SHA_Update(SHA_CTX *c, const void *data, size_t len); +int SHA_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); +void SHA_Transform(SHA_CTX *c, const unsigned char *data); +#endif +#ifndef OPENSSL_NO_SHA1 +int SHA1_Init(SHA_CTX *c); +int SHA1_Update(SHA_CTX *c, const void *data, size_t len); +int SHA1_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); +void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +#endif + +#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA224_DIGEST_LENGTH 28 +#define SHA256_DIGEST_LENGTH 32 + +typedef struct SHA256state_st + { + SHA_LONG h[8]; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num,md_len; + } SHA256_CTX; + +#ifndef OPENSSL_NO_SHA256 +int SHA224_Init(SHA256_CTX *c); +int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA224_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md); +int SHA256_Init(SHA256_CTX *c); +int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA256_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md); +void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); +#endif + +#define SHA384_DIGEST_LENGTH 48 +#define SHA512_DIGEST_LENGTH 64 + +#ifndef OPENSSL_NO_SHA512 +/* + * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 + * being exactly 64-bit wide. See Implementation Notes in sha512.c + * for further details. + */ +#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a + * contiguous array of 64 bit + * wide big-endian values. */ +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +#define SHA_LONG64 unsigned __int64 +#define U64(C) C##UI64 +#elif defined(__arch64__) +#define SHA_LONG64 unsigned long +#define U64(C) C##UL +#else +#define SHA_LONG64 unsigned long long +#define U64(C) C##ULL +#endif + +typedef struct SHA512state_st + { + SHA_LONG64 h[8]; + SHA_LONG64 Nl,Nh; + union { + SHA_LONG64 d[SHA_LBLOCK]; + unsigned char p[SHA512_CBLOCK]; + } u; + unsigned int num,md_len; + } SHA512_CTX; +#endif + +#ifndef OPENSSL_NO_SHA512 +int SHA384_Init(SHA512_CTX *c); +int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA384_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); +int SHA512_Init(SHA512_CTX *c); +int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA512_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); +void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ssl.h b/libraries/external/openssl/linux/include/openssl/ssl.h new file mode 100755 index 0000000..36e347b --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ssl.h @@ -0,0 +1,1960 @@ +/* ssl/ssl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL_H +#define HEADER_SSL_H + +#include + +#ifndef OPENSSL_NO_COMP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_X509 +#include +#endif +#include +#include +#include +#endif +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* SSLeay version number for ASN.1 encoding of the session information */ +/* Version 0 - initial version + * Version 1 - added the optional peer certificate + */ +#define SSL_SESSION_ASN1_VERSION 0x0001 + +/* text strings for the ciphers */ +#define SSL_TXT_NULL_WITH_MD5 SSL2_TXT_NULL_WITH_MD5 +#define SSL_TXT_RC4_128_WITH_MD5 SSL2_TXT_RC4_128_WITH_MD5 +#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_WITH_MD5 SSL2_TXT_RC2_128_CBC_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 +#define SSL_TXT_IDEA_128_CBC_WITH_MD5 SSL2_TXT_IDEA_128_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_MD5 SSL2_TXT_DES_64_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_SHA SSL2_TXT_DES_64_CBC_WITH_SHA +#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 +#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA + +/* VRS Additional Kerberos5 entries + */ +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA +#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5 +#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA +#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5 +#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256 + +#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 +#define SSL_MAX_SID_CTX_LENGTH 32 + +#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) +#define SSL_MAX_KEY_ARG_LENGTH 8 +#define SSL_MAX_MASTER_KEY_LENGTH 48 + +/* These are used to specify which ciphers to use and not to use */ +#define SSL_TXT_LOW "LOW" +#define SSL_TXT_MEDIUM "MEDIUM" +#define SSL_TXT_HIGH "HIGH" +#define SSL_TXT_kFZA "kFZA" +#define SSL_TXT_aFZA "aFZA" +#define SSL_TXT_eFZA "eFZA" +#define SSL_TXT_FZA "FZA" + +#define SSL_TXT_aNULL "aNULL" +#define SSL_TXT_eNULL "eNULL" +#define SSL_TXT_NULL "NULL" + +#define SSL_TXT_kKRB5 "kKRB5" +#define SSL_TXT_aKRB5 "aKRB5" +#define SSL_TXT_KRB5 "KRB5" + +#define SSL_TXT_kRSA "kRSA" +#define SSL_TXT_kDHr "kDHr" +#define SSL_TXT_kDHd "kDHd" +#define SSL_TXT_kEDH "kEDH" +#define SSL_TXT_aRSA "aRSA" +#define SSL_TXT_aDSS "aDSS" +#define SSL_TXT_aDH "aDH" +#define SSL_TXT_DSS "DSS" +#define SSL_TXT_DH "DH" +#define SSL_TXT_EDH "EDH" +#define SSL_TXT_ADH "ADH" +#define SSL_TXT_RSA "RSA" +#define SSL_TXT_DES "DES" +#define SSL_TXT_3DES "3DES" +#define SSL_TXT_RC4 "RC4" +#define SSL_TXT_RC2 "RC2" +#define SSL_TXT_IDEA "IDEA" +#define SSL_TXT_AES "AES" +#define SSL_TXT_CAMELLIA "CAMELLIA" +#define SSL_TXT_MD5 "MD5" +#define SSL_TXT_SHA1 "SHA1" +#define SSL_TXT_SHA "SHA" +#define SSL_TXT_EXP "EXP" +#define SSL_TXT_EXPORT "EXPORT" +#define SSL_TXT_EXP40 "EXPORT40" +#define SSL_TXT_EXP56 "EXPORT56" +#define SSL_TXT_SSLV2 "SSLv2" +#define SSL_TXT_SSLV3 "SSLv3" +#define SSL_TXT_TLSV1 "TLSv1" +#define SSL_TXT_ALL "ALL" +#define SSL_TXT_ECC "ECCdraft" /* ECC ciphersuites are not yet official */ + +/* + * COMPLEMENTOF* definitions. These identifiers are used to (de-select) + * ciphers normally not being used. + * Example: "RC4" will activate all ciphers using RC4 including ciphers + * without authentication, which would normally disabled by DEFAULT (due + * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" + * will make sure that it is also disabled in the specific selection. + * COMPLEMENTOF* identifiers are portable between version, as adjustments + * to the default cipher setup will also be included here. + * + * COMPLEMENTOFDEFAULT does not experience the same special treatment that + * DEFAULT gets, as only selection is being done and no sorting as needed + * for DEFAULT. + */ +#define SSL_TXT_CMPALL "COMPLEMENTOFALL" +#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" + +/* The following cipher list is used by default. + * It also is substituted when an application-defined cipher list string + * starts with 'DEFAULT'. */ +#ifdef OPENSSL_NO_CAMELLIA +# define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ +#else +# define SSL_DEFAULT_CIPHER_LIST "AES:CAMELLIA:ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ +#endif + +/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ +#define SSL_SENT_SHUTDOWN 1 +#define SSL_RECEIVED_SHUTDOWN 2 + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) +#define OPENSSL_NO_SSL2 +#endif + +#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 +#define SSL_FILETYPE_PEM X509_FILETYPE_PEM + +/* This is needed to stop compilers complaining about the + * 'struct ssl_st *' function parameters used to prototype callbacks + * in SSL_CTX. */ +typedef struct ssl_st *ssl_crock_st; + +/* used to hold info on the particular ciphers used */ +typedef struct ssl_cipher_st + { + int valid; + const char *name; /* text name */ + unsigned long id; /* id, 4 bytes, first is version */ + unsigned long algorithms; /* what ciphers are used */ + unsigned long algo_strength; /* strength and export flags */ + unsigned long algorithm2; /* Extra flags */ + int strength_bits; /* Number of bits really used */ + int alg_bits; /* Number of bits for algorithm */ + unsigned long mask; /* used for matching */ + unsigned long mask_strength; /* also used for matching */ + } SSL_CIPHER; + +DECLARE_STACK_OF(SSL_CIPHER) + +typedef struct ssl_st SSL; +typedef struct ssl_ctx_st SSL_CTX; + +/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ +typedef struct ssl_method_st + { + int version; + int (*ssl_new)(SSL *s); + void (*ssl_clear)(SSL *s); + void (*ssl_free)(SSL *s); + int (*ssl_accept)(SSL *s); + int (*ssl_connect)(SSL *s); + int (*ssl_read)(SSL *s,void *buf,int len); + int (*ssl_peek)(SSL *s,void *buf,int len); + int (*ssl_write)(SSL *s,const void *buf,int len); + int (*ssl_shutdown)(SSL *s); + int (*ssl_renegotiate)(SSL *s); + int (*ssl_renegotiate_check)(SSL *s); + long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long + max, int *ok); + int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len, + int peek); + int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); + int (*ssl_dispatch_alert)(SSL *s); + long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg); + long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg); + SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); + int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); + int (*ssl_pending)(const SSL *s); + int (*num_ciphers)(void); + SSL_CIPHER *(*get_cipher)(unsigned ncipher); + struct ssl_method_st *(*get_ssl_method)(int version); + long (*get_timeout)(void); + struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ + int (*ssl_version)(void); + long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void)); + long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void)); + } SSL_METHOD; + +/* Lets make this into an ASN.1 type structure as follows + * SSL_SESSION_ID ::= SEQUENCE { + * version INTEGER, -- structure version number + * SSLversion INTEGER, -- SSL version number + * Cipher OCTET_STRING, -- the 3 byte cipher ID + * Session_ID OCTET_STRING, -- the Session ID + * Master_key OCTET_STRING, -- the master key + * KRB5_principal OCTET_STRING -- optional Kerberos principal + * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument + * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time + * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds + * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate + * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context + * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer' + * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX + * } + * Look in ssl/ssl_asn1.c for more details + * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). + */ +typedef struct ssl_session_st + { + int ssl_version; /* what ssl version session info is + * being kept in here? */ + + /* only really used in SSLv2 */ + unsigned int key_arg_length; + unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH]; + int master_key_length; + unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH]; + /* session_id - valid? */ + unsigned int session_id_length; + unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + /* this is used to determine whether the session is being reused in + * the appropriate context. It is up to the application to set this, + * via SSL_new */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + +#ifndef OPENSSL_NO_KRB5 + unsigned int krb5_client_princ_len; + unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH]; +#endif /* OPENSSL_NO_KRB5 */ + + int not_resumable; + + /* The cert is the certificate used to establish this connection */ + struct sess_cert_st /* SESS_CERT */ *sess_cert; + + /* This is the cert for the other end. + * On clients, it will be the same as sess_cert->peer_key->x509 + * (the latter is not enough as sess_cert is not retained + * in the external representation of sessions, see ssl_asn1.c). */ + X509 *peer; + /* when app_verify_callback accepts a session where the peer's certificate + * is not ok, we must remember the error for session reuse: */ + long verify_result; /* only for servers */ + + int references; + long timeout; + long time; + + int compress_meth; /* Need to lookup the method */ + + SSL_CIPHER *cipher; + unsigned long cipher_id; /* when ASN.1 loaded, this + * needs to be used to load + * the 'cipher' structure */ + + STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */ + + CRYPTO_EX_DATA ex_data; /* application specific data */ + + /* These are used to make removal of session-ids more + * efficient and to implement a maximum cache size. */ + struct ssl_session_st *prev,*next; + } SSL_SESSION; + + +#define SSL_OP_MICROSOFT_SESS_ID_BUG 0x00000001L +#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x00000002L +#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L +#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L +#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L +#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */ +#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L +#define SSL_OP_TLS_D5_BUG 0x00000100L +#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L + +/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added + * in OpenSSL 0.9.6d. Usually (depending on the application protocol) + * the workaround is not needed. Unfortunately some broken SSL/TLS + * implementations cannot handle it at all, which is why we include + * it in SSL_OP_ALL. */ +#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L /* added in 0.9.6e */ + +/* SSL_OP_ALL: various bug workarounds that should be rather harmless. + * This used to be 0x000FFFFFL before 0.9.7. */ +#define SSL_OP_ALL 0x00000FFFL + +/* DTLS options */ +#define SSL_OP_NO_QUERY_MTU 0x00001000L +/* Turn on Cookie Exchange (on relevant for servers) */ +#define SSL_OP_COOKIE_EXCHANGE 0x00002000L + +/* As server, disallow session resumption on renegotiation */ +#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000L +/* If set, always create a new key when using tmp_ecdh parameters */ +#define SSL_OP_SINGLE_ECDH_USE 0x00080000L +/* If set, always create a new key when using tmp_dh parameters */ +#define SSL_OP_SINGLE_DH_USE 0x00100000L +/* Set to always use the tmp_rsa key when doing RSA operations, + * even when this violates protocol specs */ +#define SSL_OP_EPHEMERAL_RSA 0x00200000L +/* Set on servers to choose the cipher according to the server's + * preferences */ +#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L +/* If set, a server will allow a client to issue a SSLv3.0 version number + * as latest version supported in the premaster secret, even when TLSv1.0 + * (version 3.1) was announced in the client hello. Normally this is + * forbidden to prevent version rollback attacks. */ +#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L + +#define SSL_OP_NO_SSLv2 0x01000000L +#define SSL_OP_NO_SSLv3 0x02000000L +#define SSL_OP_NO_TLSv1 0x04000000L + +/* The next flag deliberately changes the ciphertest, this is a check + * for the PKCS#1 attack */ +#define SSL_OP_PKCS1_CHECK_1 0x08000000L +#define SSL_OP_PKCS1_CHECK_2 0x10000000L +#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L +#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L + + +/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success + * when just a single record has been written): */ +#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L +/* Make it possible to retry SSL_write() with changed buffer location + * (buffer contents must stay the same!); this is not the default to avoid + * the misconception that non-blocking SSL_write() behaves like + * non-blocking write(): */ +#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L +/* Never bother the application with retries if the transport + * is blocking: */ +#define SSL_MODE_AUTO_RETRY 0x00000004L +/* Don't attempt to automatically build certificate chain */ +#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L + + +/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, + * they cannot be used to clear bits. */ + +#define SSL_CTX_set_options(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_CTX_get_options(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL) +#define SSL_set_options(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_get_options(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL) + +#define SSL_CTX_set_mode(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) +#define SSL_CTX_get_mode(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mode(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) +#define SSL_get_mode(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mtu(ssl, mtu) \ + SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) + + +void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) +#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) + + + +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) +#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */ +#else +#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ +#endif + +#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) + +/* This callback type is used inside SSL_CTX, SSL, and in the functions that set + * them. It is used to override the generation of SSL/TLS session IDs in a + * server. Return value should be zero on an error, non-zero to proceed. Also, + * callbacks should themselves check if the id they generate is unique otherwise + * the SSL handshake will fail with an error - callbacks can do this using the + * 'ssl' value they're passed by; + * SSL_has_matching_session_id(ssl, id, *id_len) + * The length value passed in is set at the maximum size the session ID can be. + * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback + * can alter this length to be less if desired, but under SSLv2 session IDs are + * supposed to be fixed at 16 bytes so the id will be padded after the callback + * returns in this case. It is also an error for the callback to set the size to + * zero. */ +typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, + unsigned int *id_len); + +typedef struct ssl_comp_st + { + int id; + const char *name; +#ifndef OPENSSL_NO_COMP + COMP_METHOD *method; +#else + char *method; +#endif + } SSL_COMP; + +DECLARE_STACK_OF(SSL_COMP) + +struct ssl_ctx_st + { + SSL_METHOD *method; + + STACK_OF(SSL_CIPHER) *cipher_list; + /* same as above but sorted for lookup */ + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + struct x509_store_st /* X509_STORE */ *cert_store; + struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */ + /* Most session-ids that will be cached, default is + * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ + unsigned long session_cache_size; + struct ssl_session_st *session_cache_head; + struct ssl_session_st *session_cache_tail; + + /* This can have one of 2 values, ored together, + * SSL_SESS_CACHE_CLIENT, + * SSL_SESS_CACHE_SERVER, + * Default is SSL_SESSION_CACHE_SERVER, which means only + * SSL_accept which cache SSL_SESSIONS. */ + int session_cache_mode; + + /* If timeout is not 0, it is the default timeout value set + * when SSL_new() is called. This has been put in to make + * life easier to set things up */ + long session_timeout; + + /* If this callback is not null, it will be called each + * time a session id is added to the cache. If this function + * returns 1, it means that the callback will do a + * SSL_SESSION_free() when it has finished using it. Otherwise, + * on 0, it means the callback has finished with it. + * If remove_session_cb is not null, it will be called when + * a session-id is removed from the cache. After the call, + * OpenSSL will SSL_SESSION_free() it. */ + int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); + void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); + SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, + unsigned char *data,int len,int *copy); + + struct + { + int sess_connect; /* SSL new conn - started */ + int sess_connect_renegotiate;/* SSL reneg - requested */ + int sess_connect_good; /* SSL new conne/reneg - finished */ + int sess_accept; /* SSL new accept - started */ + int sess_accept_renegotiate;/* SSL reneg - requested */ + int sess_accept_good; /* SSL accept/reneg - finished */ + int sess_miss; /* session lookup misses */ + int sess_timeout; /* reuse attempt on timeouted session */ + int sess_cache_full; /* session removed due to full cache */ + int sess_hit; /* session reuse actually done */ + int sess_cb_hit; /* session-id that was not + * in the cache was + * passed back via the callback. This + * indicates that the application is + * supplying session-id's from other + * processes - spooky :-) */ + } stats; + + int references; + + /* if defined, these override the X509_verify_cert() calls */ + int (*app_verify_callback)(X509_STORE_CTX *, void *); + void *app_verify_arg; + /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored + * ('app_verify_callback' was called with just one argument) */ + + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + + /* get client cert callback */ + int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); + + /* cookie generate callback */ + int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len); + + /* verify cookie callback */ + int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int cookie_len); + + CRYPTO_EX_DATA ex_data; + + const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ + const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ + const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ + + STACK_OF(X509) *extra_certs; + STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ + + + /* Default values used when no per-SSL value is defined follow */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ + + /* what we put in client cert requests */ + STACK_OF(X509_NAME) *client_CA; + + + /* Default values to use in SSL structures follow (these are copied by SSL_new) */ + + unsigned long options; + unsigned long mode; + long max_cert_list; + + struct cert_st /* CERT */ *cert; + int read_ahead; + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int verify_mode; + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + int quiet_shutdown; + }; + +#define SSL_SESS_CACHE_OFF 0x0000 +#define SSL_SESS_CACHE_CLIENT 0x0001 +#define SSL_SESS_CACHE_SERVER 0x0002 +#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) +#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 +/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ +#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 +#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 +#define SSL_SESS_CACHE_NO_INTERNAL \ + (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) + + struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); +#define SSL_CTX_sess_number(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) +#define SSL_CTX_sess_connect(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) +#define SSL_CTX_sess_connect_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) +#define SSL_CTX_sess_connect_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) +#define SSL_CTX_sess_accept_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) +#define SSL_CTX_sess_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) +#define SSL_CTX_sess_cb_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) +#define SSL_CTX_sess_misses(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) +#define SSL_CTX_sess_timeouts(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) +#define SSL_CTX_sess_cache_full(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) + +void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess)); +int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess); +void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess)); +void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess); +void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,int len,int *copy)); +SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *Data, int len, int *copy); +void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl,int type,int val); +void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); +int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey); +void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len)); +void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len)); + +#define SSL_NOTHING 1 +#define SSL_WRITING 2 +#define SSL_READING 3 +#define SSL_X509_LOOKUP 4 + +/* These will only be used when doing non-blocking IO */ +#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) +#define SSL_want_read(s) (SSL_want(s) == SSL_READING) +#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) +#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) + +struct ssl_st + { + /* protocol version + * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) + */ + int version; + int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ + + SSL_METHOD *method; /* SSLv3 */ + + /* There are 2 BIO's even though they are normally both the + * same. This is so data can be read and written to different + * handlers */ + +#ifndef OPENSSL_NO_BIO + BIO *rbio; /* used by SSL_read */ + BIO *wbio; /* used by SSL_write */ + BIO *bbio; /* used during session-id reuse to concatenate + * messages */ +#else + char *rbio; /* used by SSL_read */ + char *wbio; /* used by SSL_write */ + char *bbio; +#endif + /* This holds a variable that indicates what we were doing + * when a 0 or -1 is returned. This is needed for + * non-blocking IO so we know what request needs re-doing when + * in SSL_accept or SSL_connect */ + int rwstate; + + /* true when we are actually in SSL_accept() or SSL_connect() */ + int in_handshake; + int (*handshake_func)(SSL *); + + /* Imagine that here's a boolean member "init" that is + * switched as soon as SSL_set_{accept/connect}_state + * is called for the first time, so that "state" and + * "handshake_func" are properly initialized. But as + * handshake_func is == 0 until then, we use this + * test instead of an "init" member. + */ + + int server; /* are we the server side? - mostly used by SSL_clear*/ + + int new_session;/* 1 if we are to use a new session. + * 2 if we are a server and are inside a handshake + * (i.e. not just sending a HelloRequest) + * NB: For servers, the 'new' session may actually be a previously + * cached session or even the previous session unless + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ + int quiet_shutdown;/* don't send shutdown packets */ + int shutdown; /* we have shut things down, 0x01 sent, 0x02 + * for received */ + int state; /* where we are */ + int rstate; /* where we are when reading */ + + BUF_MEM *init_buf; /* buffer used during init */ + void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */ + int init_num; /* amount read/written */ + int init_off; /* amount read/written */ + + /* used internally to point at a raw packet */ + unsigned char *packet; + unsigned int packet_length; + + struct ssl2_state_st *s2; /* SSLv2 variables */ + struct ssl3_state_st *s3; /* SSLv3 variables */ + struct dtls1_state_st *d1; /* DTLSv1 variables */ + + int read_ahead; /* Read as many input bytes as possible + * (for non-blocking reads) */ + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int hit; /* reusing a previous session */ + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + /* crypto */ + STACK_OF(SSL_CIPHER) *cipher_list; + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + /* These are the ones being used, the ones in SSL_SESSION are + * the ones to be 'copied' into these ones */ + + EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ + const EVP_MD *read_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *expand; /* uncompress */ +#else + char *expand; +#endif + + EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ + const EVP_MD *write_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *compress; /* compression */ +#else + char *compress; +#endif + + /* session info */ + + /* client cert? */ + /* This is used to hold the server certificate used */ + struct cert_st /* CERT */ *cert; + + /* the session_id_context is used to ensure sessions are only reused + * in the appropriate context */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + + /* This can also be in the session once a session is established */ + SSL_SESSION *session; + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + /* Used in SSL2 and SSL3 */ + int verify_mode; /* 0 don't care about verify failure. + * 1 fail if verify fails */ + int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */ + + int error; /* error bytes to be written */ + int error_code; /* actual code */ + +#ifndef OPENSSL_NO_KRB5 + KSSL_CTX *kssl_ctx; /* Kerberos 5 context */ +#endif /* OPENSSL_NO_KRB5 */ + + SSL_CTX *ctx; + /* set this flag to 1 and a sleep(1) is put into all SSL_read() + * and SSL_write() calls, good for nbio debuging :-) */ + int debug; + + /* extra application data */ + long verify_result; + CRYPTO_EX_DATA ex_data; + + /* for server side, keep the list of CA_dn we can use */ + STACK_OF(X509_NAME) *client_CA; + + int references; + unsigned long options; /* protocol behaviour */ + unsigned long mode; /* API behaviour */ + long max_cert_list; + int first_packet; + int client_version; /* what was passed, used for + * SSLv3/TLS rollback check */ + }; + +#ifdef __cplusplus +} +#endif + +#include +#include +#include /* This is mostly sslv3 with a few tweaks */ +#include /* Datagram TLS */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* compatibility */ +#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) +#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) +#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) +#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) +#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) +#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) + +/* The following are the possible values for ssl->state are are + * used to indicate where we are up to in the SSL connection establishment. + * The macros that follow are about the only things you should need to use + * and even then, only when using non-blocking IO. + * It can also be useful to work out where you were when the connection + * failed */ + +#define SSL_ST_CONNECT 0x1000 +#define SSL_ST_ACCEPT 0x2000 +#define SSL_ST_MASK 0x0FFF +#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT) +#define SSL_ST_BEFORE 0x4000 +#define SSL_ST_OK 0x03 +#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT) + +#define SSL_CB_LOOP 0x01 +#define SSL_CB_EXIT 0x02 +#define SSL_CB_READ 0x04 +#define SSL_CB_WRITE 0x08 +#define SSL_CB_ALERT 0x4000 /* used in callback */ +#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) +#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) +#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) +#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) +#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) +#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) +#define SSL_CB_HANDSHAKE_START 0x10 +#define SSL_CB_HANDSHAKE_DONE 0x20 + +/* Is the SSL_connection established? */ +#define SSL_get_state(a) SSL_state(a) +#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) +#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT) +#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE) +#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT) +#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT) + +/* The following 2 states are kept in ssl->rstate when reads fail, + * you should not need these */ +#define SSL_ST_READ_HEADER 0xF0 +#define SSL_ST_READ_BODY 0xF1 +#define SSL_ST_READ_DONE 0xF2 + +/* Obtain latest Finished message + * -- that we sent (SSL_get_finished) + * -- that we expected from peer (SSL_get_peer_finished). + * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ +size_t SSL_get_finished(const SSL *s, void *buf, size_t count); +size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); + +/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options + * are 'ored' with SSL_VERIFY_PEER if they are desired */ +#define SSL_VERIFY_NONE 0x00 +#define SSL_VERIFY_PEER 0x01 +#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 +#define SSL_VERIFY_CLIENT_ONCE 0x04 + +#define OpenSSL_add_ssl_algorithms() SSL_library_init() +#define SSLeay_add_ssl_algorithms() SSL_library_init() + +/* this is for backward compatibility */ +#if 0 /* NEW_SSLEAY */ +#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) +#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) +#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b)) +#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) +#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) +#endif +/* More backward compatibility */ +#define SSL_get_cipher(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_cipher_bits(s,np) \ + SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) +#define SSL_get_cipher_version(s) \ + SSL_CIPHER_get_version(SSL_get_current_cipher(s)) +#define SSL_get_cipher_name(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_time(a) SSL_SESSION_get_time(a) +#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) +#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) +#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) + +#if 1 /*SSLEAY_MACROS*/ +#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) +#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u) +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_SSL_SESSION(bp,x) \ + PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL) +#endif + +#define SSL_AD_REASON_OFFSET 1000 +/* These alert types are for SSLv3 and TLSv1 */ +#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY +#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ +#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */ +#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED +#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW +#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */ +#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */ +#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */ +#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE +#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE +#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED +#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED +#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN +#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */ +#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */ +#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ +#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ +#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR +#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */ +#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ +#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ +#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ +#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED +#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION + +#define SSL_ERROR_NONE 0 +#define SSL_ERROR_SSL 1 +#define SSL_ERROR_WANT_READ 2 +#define SSL_ERROR_WANT_WRITE 3 +#define SSL_ERROR_WANT_X509_LOOKUP 4 +#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ +#define SSL_ERROR_ZERO_RETURN 6 +#define SSL_ERROR_WANT_CONNECT 7 +#define SSL_ERROR_WANT_ACCEPT 8 + +#define SSL_CTRL_NEED_TMP_RSA 1 +#define SSL_CTRL_SET_TMP_RSA 2 +#define SSL_CTRL_SET_TMP_DH 3 +#define SSL_CTRL_SET_TMP_ECDH 4 +#define SSL_CTRL_SET_TMP_RSA_CB 5 +#define SSL_CTRL_SET_TMP_DH_CB 6 +#define SSL_CTRL_SET_TMP_ECDH_CB 7 + +#define SSL_CTRL_GET_SESSION_REUSED 8 +#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 +#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 +#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 +#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 +#define SSL_CTRL_GET_FLAGS 13 +#define SSL_CTRL_EXTRA_CHAIN_CERT 14 + +#define SSL_CTRL_SET_MSG_CALLBACK 15 +#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 + +/* only applies to datagram connections */ +#define SSL_CTRL_SET_MTU 17 +/* Stats */ +#define SSL_CTRL_SESS_NUMBER 20 +#define SSL_CTRL_SESS_CONNECT 21 +#define SSL_CTRL_SESS_CONNECT_GOOD 22 +#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 +#define SSL_CTRL_SESS_ACCEPT 24 +#define SSL_CTRL_SESS_ACCEPT_GOOD 25 +#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 +#define SSL_CTRL_SESS_HIT 27 +#define SSL_CTRL_SESS_CB_HIT 28 +#define SSL_CTRL_SESS_MISSES 29 +#define SSL_CTRL_SESS_TIMEOUTS 30 +#define SSL_CTRL_SESS_CACHE_FULL 31 +#define SSL_CTRL_OPTIONS 32 +#define SSL_CTRL_MODE 33 + +#define SSL_CTRL_GET_READ_AHEAD 40 +#define SSL_CTRL_SET_READ_AHEAD 41 +#define SSL_CTRL_SET_SESS_CACHE_SIZE 42 +#define SSL_CTRL_GET_SESS_CACHE_SIZE 43 +#define SSL_CTRL_SET_SESS_CACHE_MODE 44 +#define SSL_CTRL_GET_SESS_CACHE_MODE 45 + +#define SSL_CTRL_GET_MAX_CERT_LIST 50 +#define SSL_CTRL_SET_MAX_CERT_LIST 51 + +#define SSL_session_reused(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) +#define SSL_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_clear_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_total_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) + +#define SSL_CTX_need_tmp_RSA(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_CTX_set_tmp_rsa(ctx,rsa) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_CTX_set_tmp_dh(ctx,dh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_need_tmp_RSA(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_set_tmp_rsa(ssl,rsa) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_set_tmp_dh(ssl,dh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_set_tmp_ecdh(ssl,ecdh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_ssl(void); +BIO *BIO_new_ssl(SSL_CTX *ctx,int client); +BIO *BIO_new_ssl_connect(SSL_CTX *ctx); +BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); +int BIO_ssl_copy_session_id(BIO *to,BIO *from); +void BIO_ssl_shutdown(BIO *ssl_bio); + +#endif + +int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str); +SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); +void SSL_CTX_free(SSL_CTX *); +long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); +long SSL_CTX_get_timeout(const SSL_CTX *ctx); +X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); +void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); +int SSL_want(const SSL *s); +int SSL_clear(SSL *s); + +void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); + +SSL_CIPHER *SSL_get_current_cipher(const SSL *s); +int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits); +char * SSL_CIPHER_get_version(const SSL_CIPHER *c); +const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); + +int SSL_get_fd(const SSL *s); +int SSL_get_rfd(const SSL *s); +int SSL_get_wfd(const SSL *s); +const char * SSL_get_cipher_list(const SSL *s,int n); +char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len); +int SSL_get_read_ahead(const SSL * s); +int SSL_pending(const SSL *s); +#ifndef OPENSSL_NO_SOCK +int SSL_set_fd(SSL *s, int fd); +int SSL_set_rfd(SSL *s, int fd); +int SSL_set_wfd(SSL *s, int fd); +#endif +#ifndef OPENSSL_NO_BIO +void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); +BIO * SSL_get_rbio(const SSL *s); +BIO * SSL_get_wbio(const SSL *s); +#endif +int SSL_set_cipher_list(SSL *s, const char *str); +void SSL_set_read_ahead(SSL *s, int yes); +int SSL_get_verify_mode(const SSL *s); +int SSL_get_verify_depth(const SSL *s); +int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *); +void SSL_set_verify(SSL *s, int mode, + int (*callback)(int ok,X509_STORE_CTX *ctx)); +void SSL_set_verify_depth(SSL *s, int depth); +#ifndef OPENSSL_NO_RSA +int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); +#endif +int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); +int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); +int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len); +int SSL_use_certificate(SSL *ssl, X509 *x); +int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); + +#ifndef OPENSSL_NO_STDIO +int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_certificate_file(SSL *ssl, const char *file, int type); +int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */ +STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); +int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *file); +#ifndef OPENSSL_SYS_VMS +#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *dir); +#endif +#endif + +#endif + +void SSL_load_error_strings(void ); +const char *SSL_state_string(const SSL *s); +const char *SSL_rstate_string(const SSL *s); +const char *SSL_state_string_long(const SSL *s); +const char *SSL_rstate_string_long(const SSL *s); +long SSL_SESSION_get_time(const SSL_SESSION *s); +long SSL_SESSION_set_time(SSL_SESSION *s, long t); +long SSL_SESSION_get_timeout(const SSL_SESSION *s); +long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); +void SSL_copy_session_id(SSL *to,const SSL *from); + +SSL_SESSION *SSL_SESSION_new(void); +unsigned long SSL_SESSION_hash(const SSL_SESSION *a); +int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b); +const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); +#ifndef OPENSSL_NO_FP_API +int SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses); +#endif +#ifndef OPENSSL_NO_BIO +int SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses); +#endif +void SSL_SESSION_free(SSL_SESSION *ses); +int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); +int SSL_set_session(SSL *to, SSL_SESSION *session); +int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); +int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); +int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); +int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); +int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, + unsigned int id_len); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,const unsigned char **pp, + long length); + +#ifdef HEADER_X509_H +X509 * SSL_get_peer_certificate(const SSL *s); +#endif + +STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); + +int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); +int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); +int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *); +void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, + int (*callback)(int, X509_STORE_CTX *)); +void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); +void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg); +#ifndef OPENSSL_NO_RSA +int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); +#endif +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); +int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); +int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, + const unsigned char *d, long len); +int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); +int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d); + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); + +int SSL_CTX_check_private_key(const SSL_CTX *ctx); +int SSL_check_private_key(const SSL *ctx); + +int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +SSL * SSL_new(SSL_CTX *ctx); +int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); +int SSL_set_purpose(SSL *s, int purpose); +int SSL_CTX_set_trust(SSL_CTX *s, int trust); +int SSL_set_trust(SSL *s, int trust); + +void SSL_free(SSL *ssl); +int SSL_accept(SSL *ssl); +int SSL_connect(SSL *ssl); +int SSL_read(SSL *ssl,void *buf,int num); +int SSL_peek(SSL *ssl,void *buf,int num); +int SSL_write(SSL *ssl,const void *buf,int num); +long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg); +long SSL_callback_ctrl(SSL *, int, void (*)(void)); +long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg); +long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); + +int SSL_get_error(const SSL *s,int ret_code); +const char *SSL_get_version(const SSL *s); + +/* This sets the 'default' SSL version that SSL_new() will create */ +int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); + +SSL_METHOD *SSLv2_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */ + +SSL_METHOD *SSLv3_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */ + +SSL_METHOD *SSLv23_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_server_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_client_method(void); /* SSLv3 but can rollback to v2 */ + +SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ + +SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */ + +STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); + +int SSL_do_handshake(SSL *s); +int SSL_renegotiate(SSL *s); +int SSL_renegotiate_pending(SSL *s); +int SSL_shutdown(SSL *s); + +SSL_METHOD *SSL_get_ssl_method(SSL *s); +int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); +const char *SSL_alert_type_string_long(int value); +const char *SSL_alert_type_string(int value); +const char *SSL_alert_desc_string_long(int value); +const char *SSL_alert_desc_string(int value); + +void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); +void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); +STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); +STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); +int SSL_add_client_CA(SSL *ssl,X509 *x); +int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); + +void SSL_set_connect_state(SSL *s); +void SSL_set_accept_state(SSL *s); + +long SSL_get_default_timeout(const SSL *s); + +int SSL_library_init(void ); + +char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); +STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); + +SSL *SSL_dup(SSL *ssl); + +X509 *SSL_get_certificate(const SSL *ssl); +/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl); + +void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode); +int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); +void SSL_set_quiet_shutdown(SSL *ssl,int mode); +int SSL_get_quiet_shutdown(const SSL *ssl); +void SSL_set_shutdown(SSL *ssl,int mode); +int SSL_get_shutdown(const SSL *ssl); +int SSL_version(const SSL *ssl); +int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); +int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, + const char *CApath); +#define SSL_get0_session SSL_get_session /* just peek at pointer */ +SSL_SESSION *SSL_get_session(const SSL *ssl); +SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ +SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); +void SSL_set_info_callback(SSL *ssl, + void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val); +int SSL_state(const SSL *ssl); + +void SSL_set_verify_result(SSL *ssl,long v); +long SSL_get_verify_result(const SSL *ssl); + +int SSL_set_ex_data(SSL *ssl,int idx,void *data); +void *SSL_get_ex_data(const SSL *ssl,int idx); +int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); +void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss,int idx); +int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); +void *SSL_CTX_get_ex_data(const SSL_CTX *ssl,int idx); +int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_get_ex_data_X509_STORE_CTX_idx(void ); + +#define SSL_CTX_sess_set_cache_size(ctx,t) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) +#define SSL_CTX_sess_get_cache_size(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) +#define SSL_CTX_set_session_cache_mode(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) +#define SSL_CTX_get_session_cache_mode(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) + +#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) +#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) +#define SSL_CTX_get_read_ahead(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) +#define SSL_CTX_set_read_ahead(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) +#define SSL_CTX_get_max_cert_list(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_CTX_set_max_cert_list(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) +#define SSL_get_max_cert_list(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_set_max_cert_list(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) + + /* NB: the keylength is only applicable when is_export is true */ +#ifndef OPENSSL_NO_RSA +void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); + +void SSL_set_tmp_rsa_callback(SSL *ssl, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_DH +void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_dh_callback(SSL *ssl, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_ECDH +void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_ecdh_callback(SSL *ssl, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +#endif + +#ifndef OPENSSL_NO_COMP +const COMP_METHOD *SSL_get_current_compression(SSL *s); +const COMP_METHOD *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const COMP_METHOD *comp); +STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); +#else +const void *SSL_get_current_compression(SSL *s); +const void *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const void *comp); +void *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,void *cm); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_SSL_strings(void); + +/* Error codes for the SSL functions. */ + +/* Function codes. */ +#define SSL_F_CLIENT_CERTIFICATE 100 +#define SSL_F_CLIENT_FINISHED 167 +#define SSL_F_CLIENT_HELLO 101 +#define SSL_F_CLIENT_MASTER_KEY 102 +#define SSL_F_D2I_SSL_SESSION 103 +#define SSL_F_DO_DTLS1_WRITE 245 +#define SSL_F_DO_SSL3_WRITE 104 +#define SSL_F_DTLS1_ACCEPT 246 +#define SSL_F_DTLS1_BUFFER_RECORD 247 +#define SSL_F_DTLS1_CLIENT_HELLO 248 +#define SSL_F_DTLS1_CONNECT 249 +#define SSL_F_DTLS1_ENC 250 +#define SSL_F_DTLS1_GET_HELLO_VERIFY 251 +#define SSL_F_DTLS1_GET_MESSAGE 252 +#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT 253 +#define SSL_F_DTLS1_GET_RECORD 254 +#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN 255 +#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE 256 +#define SSL_F_DTLS1_PROCESS_RECORD 257 +#define SSL_F_DTLS1_READ_BYTES 258 +#define SSL_F_DTLS1_READ_FAILED 259 +#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST 260 +#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE 261 +#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE 262 +#define SSL_F_DTLS1_SEND_CLIENT_VERIFY 263 +#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST 264 +#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE 265 +#define SSL_F_DTLS1_SEND_SERVER_HELLO 266 +#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267 +#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 +#define SSL_F_GET_CLIENT_FINISHED 105 +#define SSL_F_GET_CLIENT_HELLO 106 +#define SSL_F_GET_CLIENT_MASTER_KEY 107 +#define SSL_F_GET_SERVER_FINISHED 108 +#define SSL_F_GET_SERVER_HELLO 109 +#define SSL_F_GET_SERVER_VERIFY 110 +#define SSL_F_I2D_SSL_SESSION 111 +#define SSL_F_READ_N 112 +#define SSL_F_REQUEST_CERTIFICATE 113 +#define SSL_F_SERVER_FINISH 239 +#define SSL_F_SERVER_HELLO 114 +#define SSL_F_SERVER_VERIFY 240 +#define SSL_F_SSL23_ACCEPT 115 +#define SSL_F_SSL23_CLIENT_HELLO 116 +#define SSL_F_SSL23_CONNECT 117 +#define SSL_F_SSL23_GET_CLIENT_HELLO 118 +#define SSL_F_SSL23_GET_SERVER_HELLO 119 +#define SSL_F_SSL23_PEEK 237 +#define SSL_F_SSL23_READ 120 +#define SSL_F_SSL23_WRITE 121 +#define SSL_F_SSL2_ACCEPT 122 +#define SSL_F_SSL2_CONNECT 123 +#define SSL_F_SSL2_ENC_INIT 124 +#define SSL_F_SSL2_GENERATE_KEY_MATERIAL 241 +#define SSL_F_SSL2_PEEK 234 +#define SSL_F_SSL2_READ 125 +#define SSL_F_SSL2_READ_INTERNAL 236 +#define SSL_F_SSL2_SET_CERTIFICATE 126 +#define SSL_F_SSL2_WRITE 127 +#define SSL_F_SSL3_ACCEPT 128 +#define SSL_F_SSL3_CALLBACK_CTRL 233 +#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 +#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CLIENT_HELLO 131 +#define SSL_F_SSL3_CONNECT 132 +#define SSL_F_SSL3_CTRL 213 +#define SSL_F_SSL3_CTX_CTRL 133 +#define SSL_F_SSL3_ENC 134 +#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 +#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 +#define SSL_F_SSL3_GET_CERT_VERIFY 136 +#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 +#define SSL_F_SSL3_GET_CLIENT_HELLO 138 +#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139 +#define SSL_F_SSL3_GET_FINISHED 140 +#define SSL_F_SSL3_GET_KEY_EXCHANGE 141 +#define SSL_F_SSL3_GET_MESSAGE 142 +#define SSL_F_SSL3_GET_RECORD 143 +#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144 +#define SSL_F_SSL3_GET_SERVER_DONE 145 +#define SSL_F_SSL3_GET_SERVER_HELLO 146 +#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 +#define SSL_F_SSL3_PEEK 235 +#define SSL_F_SSL3_READ_BYTES 148 +#define SSL_F_SSL3_READ_N 149 +#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 +#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151 +#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152 +#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153 +#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154 +#define SSL_F_SSL3_SEND_SERVER_HELLO 242 +#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155 +#define SSL_F_SSL3_SETUP_BUFFERS 156 +#define SSL_F_SSL3_SETUP_KEY_BLOCK 157 +#define SSL_F_SSL3_WRITE_BYTES 158 +#define SSL_F_SSL3_WRITE_PENDING 159 +#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 +#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 +#define SSL_F_SSL_BAD_METHOD 160 +#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 +#define SSL_F_SSL_CERT_DUP 221 +#define SSL_F_SSL_CERT_INST 222 +#define SSL_F_SSL_CERT_INSTANTIATE 214 +#define SSL_F_SSL_CERT_NEW 162 +#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 +#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 +#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 +#define SSL_F_SSL_CLEAR 164 +#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 +#define SSL_F_SSL_CREATE_CIPHER_LIST 166 +#define SSL_F_SSL_CTRL 232 +#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 +#define SSL_F_SSL_CTX_NEW 169 +#define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 +#define SSL_F_SSL_CTX_SET_PURPOSE 226 +#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 +#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 +#define SSL_F_SSL_CTX_SET_TRUST 229 +#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 +#define SSL_F_SSL_DO_HANDSHAKE 180 +#define SSL_F_SSL_GET_NEW_SESSION 181 +#define SSL_F_SSL_GET_PREV_SESSION 217 +#define SSL_F_SSL_GET_SERVER_SEND_CERT 182 +#define SSL_F_SSL_GET_SIGN_PKEY 183 +#define SSL_F_SSL_INIT_WBIO_BUFFER 184 +#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 +#define SSL_F_SSL_NEW 186 +#define SSL_F_SSL_PEEK 270 +#define SSL_F_SSL_READ 223 +#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187 +#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188 +#define SSL_F_SSL_SESSION_NEW 189 +#define SSL_F_SSL_SESSION_PRINT_FP 190 +#define SSL_F_SSL_SESS_CERT_NEW 225 +#define SSL_F_SSL_SET_CERT 191 +#define SSL_F_SSL_SET_CIPHER_LIST 271 +#define SSL_F_SSL_SET_FD 192 +#define SSL_F_SSL_SET_PKEY 193 +#define SSL_F_SSL_SET_PURPOSE 227 +#define SSL_F_SSL_SET_RFD 194 +#define SSL_F_SSL_SET_SESSION 195 +#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 +#define SSL_F_SSL_SET_TRUST 228 +#define SSL_F_SSL_SET_WFD 196 +#define SSL_F_SSL_SHUTDOWN 224 +#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION 243 +#define SSL_F_SSL_UNDEFINED_FUNCTION 197 +#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 +#define SSL_F_SSL_USE_CERTIFICATE 198 +#define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 +#define SSL_F_SSL_USE_CERTIFICATE_FILE 200 +#define SSL_F_SSL_USE_PRIVATEKEY 201 +#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 +#define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 +#define SSL_F_SSL_USE_RSAPRIVATEKEY 204 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 +#define SSL_F_SSL_VERIFY_CERT_CHAIN 207 +#define SSL_F_SSL_WRITE 208 +#define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 +#define SSL_F_TLS1_ENC 210 +#define SSL_F_TLS1_SETUP_KEY_BLOCK 211 +#define SSL_F_WRITE_PENDING 212 + +/* Reason codes. */ +#define SSL_R_APP_DATA_IN_HANDSHAKE 100 +#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 +#define SSL_R_BAD_ALERT_RECORD 101 +#define SSL_R_BAD_AUTHENTICATION_TYPE 102 +#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 +#define SSL_R_BAD_CHECKSUM 104 +#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 +#define SSL_R_BAD_DECOMPRESSION 107 +#define SSL_R_BAD_DH_G_LENGTH 108 +#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 +#define SSL_R_BAD_DH_P_LENGTH 110 +#define SSL_R_BAD_DIGEST_LENGTH 111 +#define SSL_R_BAD_DSA_SIGNATURE 112 +#define SSL_R_BAD_ECC_CERT 304 +#define SSL_R_BAD_ECDSA_SIGNATURE 305 +#define SSL_R_BAD_ECPOINT 306 +#define SSL_R_BAD_HELLO_REQUEST 105 +#define SSL_R_BAD_LENGTH 271 +#define SSL_R_BAD_MAC_DECODE 113 +#define SSL_R_BAD_MESSAGE_TYPE 114 +#define SSL_R_BAD_PACKET_LENGTH 115 +#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 +#define SSL_R_BAD_RESPONSE_ARGUMENT 117 +#define SSL_R_BAD_RSA_DECRYPT 118 +#define SSL_R_BAD_RSA_ENCRYPT 119 +#define SSL_R_BAD_RSA_E_LENGTH 120 +#define SSL_R_BAD_RSA_MODULUS_LENGTH 121 +#define SSL_R_BAD_RSA_SIGNATURE 122 +#define SSL_R_BAD_SIGNATURE 123 +#define SSL_R_BAD_SSL_FILETYPE 124 +#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125 +#define SSL_R_BAD_STATE 126 +#define SSL_R_BAD_WRITE_RETRY 127 +#define SSL_R_BIO_NOT_SET 128 +#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 +#define SSL_R_BN_LIB 130 +#define SSL_R_CA_DN_LENGTH_MISMATCH 131 +#define SSL_R_CA_DN_TOO_LONG 132 +#define SSL_R_CCS_RECEIVED_EARLY 133 +#define SSL_R_CERTIFICATE_VERIFY_FAILED 134 +#define SSL_R_CERT_LENGTH_MISMATCH 135 +#define SSL_R_CHALLENGE_IS_DIFFERENT 136 +#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 +#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 +#define SSL_R_CIPHER_TABLE_SRC_ERROR 139 +#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 +#define SSL_R_COMPRESSION_FAILURE 141 +#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 +#define SSL_R_COMPRESSION_LIBRARY_ERROR 142 +#define SSL_R_CONNECTION_ID_IS_DIFFERENT 143 +#define SSL_R_CONNECTION_TYPE_NOT_SET 144 +#define SSL_R_COOKIE_MISMATCH 308 +#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 +#define SSL_R_DATA_LENGTH_TOO_LONG 146 +#define SSL_R_DECRYPTION_FAILED 147 +#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 +#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 +#define SSL_R_DIGEST_CHECK_FAILED 149 +#define SSL_R_DUPLICATE_COMPRESSION_ID 309 +#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER 310 +#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 +#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 282 +#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 +#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 +#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 +#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 +#define SSL_R_HTTPS_PROXY_REQUEST 155 +#define SSL_R_HTTP_REQUEST 156 +#define SSL_R_ILLEGAL_PADDING 283 +#define SSL_R_INVALID_CHALLENGE_LENGTH 158 +#define SSL_R_INVALID_COMMAND 280 +#define SSL_R_INVALID_PURPOSE 278 +#define SSL_R_INVALID_TRUST 279 +#define SSL_R_KEY_ARG_TOO_LONG 284 +#define SSL_R_KRB5 285 +#define SSL_R_KRB5_C_CC_PRINC 286 +#define SSL_R_KRB5_C_GET_CRED 287 +#define SSL_R_KRB5_C_INIT 288 +#define SSL_R_KRB5_C_MK_REQ 289 +#define SSL_R_KRB5_S_BAD_TICKET 290 +#define SSL_R_KRB5_S_INIT 291 +#define SSL_R_KRB5_S_RD_REQ 292 +#define SSL_R_KRB5_S_TKT_EXPIRED 293 +#define SSL_R_KRB5_S_TKT_NYV 294 +#define SSL_R_KRB5_S_TKT_SKEW 295 +#define SSL_R_LENGTH_MISMATCH 159 +#define SSL_R_LENGTH_TOO_SHORT 160 +#define SSL_R_LIBRARY_BUG 274 +#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 +#define SSL_R_MESSAGE_TOO_LONG 296 +#define SSL_R_MISSING_DH_DSA_CERT 162 +#define SSL_R_MISSING_DH_KEY 163 +#define SSL_R_MISSING_DH_RSA_CERT 164 +#define SSL_R_MISSING_DSA_SIGNING_CERT 165 +#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166 +#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167 +#define SSL_R_MISSING_RSA_CERTIFICATE 168 +#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 +#define SSL_R_MISSING_RSA_SIGNING_CERT 170 +#define SSL_R_MISSING_TMP_DH_KEY 171 +#define SSL_R_MISSING_TMP_ECDH_KEY 311 +#define SSL_R_MISSING_TMP_RSA_KEY 172 +#define SSL_R_MISSING_TMP_RSA_PKEY 173 +#define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_NON_SSLV2_INITIAL_PACKET 175 +#define SSL_R_NO_CERTIFICATES_RETURNED 176 +#define SSL_R_NO_CERTIFICATE_ASSIGNED 177 +#define SSL_R_NO_CERTIFICATE_RETURNED 178 +#define SSL_R_NO_CERTIFICATE_SET 179 +#define SSL_R_NO_CERTIFICATE_SPECIFIED 180 +#define SSL_R_NO_CIPHERS_AVAILABLE 181 +#define SSL_R_NO_CIPHERS_PASSED 182 +#define SSL_R_NO_CIPHERS_SPECIFIED 183 +#define SSL_R_NO_CIPHER_LIST 184 +#define SSL_R_NO_CIPHER_MATCH 185 +#define SSL_R_NO_CLIENT_CERT_RECEIVED 186 +#define SSL_R_NO_COMPRESSION_SPECIFIED 187 +#define SSL_R_NO_METHOD_SPECIFIED 188 +#define SSL_R_NO_PRIVATEKEY 189 +#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 +#define SSL_R_NO_PROTOCOLS_AVAILABLE 191 +#define SSL_R_NO_PUBLICKEY 192 +#define SSL_R_NO_SHARED_CIPHER 193 +#define SSL_R_NO_VERIFY_CALLBACK 194 +#define SSL_R_NULL_SSL_CTX 195 +#define SSL_R_NULL_SSL_METHOD_PASSED 196 +#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 +#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE 297 +#define SSL_R_PACKET_LENGTH_TOO_LONG 198 +#define SSL_R_PATH_TOO_LONG 270 +#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 +#define SSL_R_PEER_ERROR 200 +#define SSL_R_PEER_ERROR_CERTIFICATE 201 +#define SSL_R_PEER_ERROR_NO_CERTIFICATE 202 +#define SSL_R_PEER_ERROR_NO_CIPHER 203 +#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204 +#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205 +#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206 +#define SSL_R_PROTOCOL_IS_SHUTDOWN 207 +#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208 +#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209 +#define SSL_R_PUBLIC_KEY_NOT_RSA 210 +#define SSL_R_READ_BIO_NOT_SET 211 +#define SSL_R_READ_TIMEOUT_EXPIRED 312 +#define SSL_R_READ_WRONG_PACKET_TYPE 212 +#define SSL_R_RECORD_LENGTH_MISMATCH 213 +#define SSL_R_RECORD_TOO_LARGE 214 +#define SSL_R_RECORD_TOO_SMALL 298 +#define SSL_R_REQUIRED_CIPHER_MISSING 215 +#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216 +#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217 +#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218 +#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 +#define SSL_R_SHORT_READ 219 +#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 +#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221 +#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG 299 +#define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 +#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222 +#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 +#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 +#define SSL_R_SSL_HANDSHAKE_FAILURE 229 +#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 +#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 +#define SSL_R_SSL_SESSION_ID_CONFLICT 302 +#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 +#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 +#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 +#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 +#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 +#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 +#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 +#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 +#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 +#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 +#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 +#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 +#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 +#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 +#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 +#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 +#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 +#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 +#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235 +#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236 +#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS 313 +#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237 +#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238 +#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 +#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 +#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240 +#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241 +#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 +#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 +#define SSL_R_UNEXPECTED_MESSAGE 244 +#define SSL_R_UNEXPECTED_RECORD 245 +#define SSL_R_UNINITIALIZED 276 +#define SSL_R_UNKNOWN_ALERT_TYPE 246 +#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 +#define SSL_R_UNKNOWN_CIPHER_RETURNED 248 +#define SSL_R_UNKNOWN_CIPHER_TYPE 249 +#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 +#define SSL_R_UNKNOWN_PKEY_TYPE 251 +#define SSL_R_UNKNOWN_PROTOCOL 252 +#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253 +#define SSL_R_UNKNOWN_SSL_VERSION 254 +#define SSL_R_UNKNOWN_STATE 255 +#define SSL_R_UNSUPPORTED_CIPHER 256 +#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 +#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 +#define SSL_R_UNSUPPORTED_PROTOCOL 258 +#define SSL_R_UNSUPPORTED_SSL_VERSION 259 +#define SSL_R_WRITE_BIO_NOT_SET 260 +#define SSL_R_WRONG_CIPHER_RETURNED 261 +#define SSL_R_WRONG_MESSAGE_TYPE 262 +#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263 +#define SSL_R_WRONG_SIGNATURE_LENGTH 264 +#define SSL_R_WRONG_SIGNATURE_SIZE 265 +#define SSL_R_WRONG_SSL_VERSION 266 +#define SSL_R_WRONG_VERSION_NUMBER 267 +#define SSL_R_X509_LIB 268 +#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ssl2.h b/libraries/external/openssl/linux/include/openssl/ssl2.h new file mode 100755 index 0000000..c871efe --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ssl2.h @@ -0,0 +1,268 @@ +/* ssl/ssl2.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL2_H +#define HEADER_SSL2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Protocol Version Codes */ +#define SSL2_VERSION 0x0002 +#define SSL2_VERSION_MAJOR 0x00 +#define SSL2_VERSION_MINOR 0x02 +/* #define SSL2_CLIENT_VERSION 0x0002 */ +/* #define SSL2_SERVER_VERSION 0x0002 */ + +/* Protocol Message Codes */ +#define SSL2_MT_ERROR 0 +#define SSL2_MT_CLIENT_HELLO 1 +#define SSL2_MT_CLIENT_MASTER_KEY 2 +#define SSL2_MT_CLIENT_FINISHED 3 +#define SSL2_MT_SERVER_HELLO 4 +#define SSL2_MT_SERVER_VERIFY 5 +#define SSL2_MT_SERVER_FINISHED 6 +#define SSL2_MT_REQUEST_CERTIFICATE 7 +#define SSL2_MT_CLIENT_CERTIFICATE 8 + +/* Error Message Codes */ +#define SSL2_PE_UNDEFINED_ERROR 0x0000 +#define SSL2_PE_NO_CIPHER 0x0001 +#define SSL2_PE_NO_CERTIFICATE 0x0002 +#define SSL2_PE_BAD_CERTIFICATE 0x0004 +#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 + +/* Cipher Kind Values */ +#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */ +#define SSL2_CK_RC4_128_WITH_MD5 0x02010080 +#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080 +#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080 +#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080 +#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080 +#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040 +#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */ +#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0 +#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */ +#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */ + +#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */ +#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */ + +#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1" +#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5" +#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5" +#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5" +#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5" +#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5" +#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA" +#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5" + +#define SSL2_TXT_NULL "NULL" + +/* Flags for the SSL_CIPHER.algorithm2 field */ +#define SSL2_CF_5_BYTE_ENC 0x01 +#define SSL2_CF_8_BYTE_ENC 0x02 + +/* Certificate Type Codes */ +#define SSL2_CT_X509_CERTIFICATE 0x01 + +/* Authentication Type Code */ +#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01 + +#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32 + +/* Upper/Lower Bounds */ +#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 +#ifdef OPENSSL_SYS_MPE +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u +#else +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ +#endif +#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ + +#define SSL2_CHALLENGE_LENGTH 16 +/*#define SSL2_CHALLENGE_LENGTH 32 */ +#define SSL2_MIN_CHALLENGE_LENGTH 16 +#define SSL2_MAX_CHALLENGE_LENGTH 32 +#define SSL2_CONNECTION_ID_LENGTH 16 +#define SSL2_MAX_CONNECTION_ID_LENGTH 16 +#define SSL2_SSL_SESSION_ID_LENGTH 16 +#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32 +#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16 +#define SSL2_MAX_KEY_MATERIAL_LENGTH 24 + +#ifndef HEADER_SSL_LOCL_H +#define CERT char +#endif + +typedef struct ssl2_state_st + { + int three_byte_header; + int clear_text; /* clear text */ + int escape; /* not used in SSLv2 */ + int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */ + + /* non-blocking io info, used to make sure the same + * args were passwd */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; + const unsigned char *wpend_buf; + + int wpend_off; /* offset to data to write */ + int wpend_len; /* number of bytes passwd to write */ + int wpend_ret; /* number of bytes to return to caller */ + + /* buffer raw data */ + int rbuf_left; + int rbuf_offs; + unsigned char *rbuf; + unsigned char *wbuf; + + unsigned char *write_ptr;/* used to point to the start due to + * 2/3 byte header. */ + + unsigned int padding; + unsigned int rlength; /* passed to ssl2_enc */ + int ract_data_length; /* Set when things are encrypted. */ + unsigned int wlength; /* passed to ssl2_enc */ + int wact_data_length; /* Set when things are decrypted. */ + unsigned char *ract_data; + unsigned char *wact_data; + unsigned char *mac_data; + + unsigned char *read_key; + unsigned char *write_key; + + /* Stuff specifically to do with this SSL session */ + unsigned int challenge_length; + unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH]; + unsigned int conn_id_length; + unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH]; + unsigned int key_material_length; + unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2]; + + unsigned long read_sequence; + unsigned long write_sequence; + + struct { + unsigned int conn_id_length; + unsigned int cert_type; + unsigned int cert_length; + unsigned int csl; + unsigned int clear; + unsigned int enc; + unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; + unsigned int cipher_spec_length; + unsigned int session_id_length; + unsigned int clen; + unsigned int rlen; + } tmp; + } SSL2_STATE; + +/* SSLv2 */ +/* client */ +#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT) +#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT) +#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT) +/* server */ +#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT) +#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT) +#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/ssl23.h b/libraries/external/openssl/linux/include/openssl/ssl23.h new file mode 100755 index 0000000..1a87d8c --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ssl23.h @@ -0,0 +1,83 @@ +/* ssl/ssl23.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL23_H +#define HEADER_SSL23_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*client */ +/* write to server */ +#define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) +#define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) +/* read from server */ +#define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) +#define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) + +/* server */ +/* read from client */ +#define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) +#define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/ssl3.h b/libraries/external/openssl/linux/include/openssl/ssl3.h new file mode 100755 index 0000000..45e7c99 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ssl3.h @@ -0,0 +1,555 @@ +/* ssl/ssl3.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL3_H +#define HEADER_SSL3_H + +#ifndef OPENSSL_NO_COMP +#include +#endif +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SSL3_CK_RSA_NULL_MD5 0x03000001 +#define SSL3_CK_RSA_NULL_SHA 0x03000002 +#define SSL3_CK_RSA_RC4_40_MD5 0x03000003 +#define SSL3_CK_RSA_RC4_128_MD5 0x03000004 +#define SSL3_CK_RSA_RC4_128_SHA 0x03000005 +#define SSL3_CK_RSA_RC2_40_MD5 0x03000006 +#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 +#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 +#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 +#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A + +#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B +#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C +#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D +#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E +#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F +#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 + +#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 +#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 +#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 +#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 +#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 +#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 + +#define SSL3_CK_ADH_RC4_40_MD5 0x03000017 +#define SSL3_CK_ADH_RC4_128_MD5 0x03000018 +#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 +#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A +#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B + +#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C +#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D +#if 0 /* Because it clashes with KRB5, is never used any more, and is safe + to remove according to David Hopwood + of the ietf-tls list */ +#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E +#endif + +/* VRS Additional Kerberos5 entries + */ +#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E +#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F +#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 +#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 +#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 +#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 +#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 +#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 + +#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 +#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 +#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 +#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 +#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A +#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B + +#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" +#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" +#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" +#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" +#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" +#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" + +#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" +#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" +#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" + +#define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA" +#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" +#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" + +#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" +#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" +#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" +#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" +#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" + +#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" +#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" +#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" + +#define SSL3_SSL_SESSION_ID_LENGTH 32 +#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 + +#define SSL3_MASTER_SECRET_SIZE 48 +#define SSL3_RANDOM_SIZE 32 +#define SSL3_SESSION_ID_SIZE 32 +#define SSL3_RT_HEADER_LENGTH 5 + +/* Due to MS stuffing up, this can change.... */ +#if defined(OPENSSL_SYS_WIN16) || \ + (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) +#define SSL3_RT_MAX_EXTRA (14000) +#else +#define SSL3_RT_MAX_EXTRA (16384) +#endif + +#define SSL3_RT_MAX_PLAIN_LENGTH 16384 +#ifdef OPENSSL_NO_COMP +#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH +#else +#define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH) +#endif +#define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH) +#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) +#define SSL3_RT_MAX_DATA_SIZE (1024*1024) + +#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" +#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" + +#define SSL3_VERSION 0x0300 +#define SSL3_VERSION_MAJOR 0x03 +#define SSL3_VERSION_MINOR 0x00 + +#define SSL3_RT_CHANGE_CIPHER_SPEC 20 +#define SSL3_RT_ALERT 21 +#define SSL3_RT_HANDSHAKE 22 +#define SSL3_RT_APPLICATION_DATA 23 + +#define SSL3_AL_WARNING 1 +#define SSL3_AL_FATAL 2 + +#define SSL3_AD_CLOSE_NOTIFY 0 +#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ +#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ +#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ +#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ +#define SSL3_AD_NO_CERTIFICATE 41 +#define SSL3_AD_BAD_CERTIFICATE 42 +#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 +#define SSL3_AD_CERTIFICATE_REVOKED 44 +#define SSL3_AD_CERTIFICATE_EXPIRED 45 +#define SSL3_AD_CERTIFICATE_UNKNOWN 46 +#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ + +typedef struct ssl3_record_st + { +/*r */ int type; /* type of record */ +/*rw*/ unsigned int length; /* How many bytes available */ +/*r */ unsigned int off; /* read/write offset into 'buf' */ +/*rw*/ unsigned char *data; /* pointer to the record data */ +/*rw*/ unsigned char *input; /* where the decode bytes are */ +/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ +/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */ +/*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */ + } SSL3_RECORD; + +typedef struct ssl3_buffer_st + { + unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, + * see ssl3_setup_buffers() */ + size_t len; /* buffer size */ + int offset; /* where to 'copy from' */ + int left; /* how many bytes left */ + } SSL3_BUFFER; + +#define SSL3_CT_RSA_SIGN 1 +#define SSL3_CT_DSS_SIGN 2 +#define SSL3_CT_RSA_FIXED_DH 3 +#define SSL3_CT_DSS_FIXED_DH 4 +#define SSL3_CT_RSA_EPHEMERAL_DH 5 +#define SSL3_CT_DSS_EPHEMERAL_DH 6 +#define SSL3_CT_FORTEZZA_DMS 20 +/* SSL3_CT_NUMBER is used to size arrays and it must be large + * enough to contain all of the cert types defined either for + * SSLv3 and TLSv1. + */ +#define SSL3_CT_NUMBER 7 + + +#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 +#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 +#define SSL3_FLAGS_POP_BUFFER 0x0004 +#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +typedef struct ssl3_state_st + { + long flags; + int delay_buf_pop_ret; + + unsigned char read_sequence[8]; + unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; + unsigned char write_sequence[8]; + unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; + + unsigned char server_random[SSL3_RANDOM_SIZE]; + unsigned char client_random[SSL3_RANDOM_SIZE]; + + /* flags for countermeasure against known-IV weakness */ + int need_empty_fragments; + int empty_fragment_done; + + SSL3_BUFFER rbuf; /* read IO goes into here */ + SSL3_BUFFER wbuf; /* write IO goes into here */ + + SSL3_RECORD rrec; /* each decoded record goes in here */ + SSL3_RECORD wrec; /* goes out from here */ + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[2]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[4]; + unsigned int handshake_fragment_len; + + /* partial write - check the numbers match */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; /* number bytes written */ + int wpend_type; + int wpend_ret; /* number of bytes submitted */ + const unsigned char *wpend_buf; + + /* used during startup, digest all incoming/outgoing packets */ + EVP_MD_CTX finish_dgst1; + EVP_MD_CTX finish_dgst2; + + /* this is set whenerver we see a change_cipher_spec message + * come in when we are not looking for one */ + int change_cipher_spec; + + int warn_alert; + int fatal_alert; + /* we allow one fatal and one warning alert to be outstanding, + * send close alert via the warning alert */ + int alert_dispatch; + unsigned char send_alert[2]; + + /* This flag is set when we should renegotiate ASAP, basically when + * there is no more data in the read or write buffers */ + int renegotiate; + int total_renegotiations; + int num_renegotiations; + + int in_read_app_data; + + struct { + /* actually only needs to be 16+20 */ + unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; + + /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ + unsigned char finish_md[EVP_MAX_MD_SIZE*2]; + int finish_md_len; + unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; + int peer_finish_md_len; + + unsigned long message_size; + int message_type; + + /* used to hold the new cipher we are going to use */ + SSL_CIPHER *new_cipher; +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + +#ifndef OPENSSL_NO_ECDH + EC_KEY *ecdh; /* holds short lived ECDH key */ +#endif + + /* used when SSL_ST_FLUSH_DATA is entered */ + int next_state; + + int reuse_message; + + /* used for certificate requests */ + int cert_req; + int ctype_num; + char ctype[SSL3_CT_NUMBER]; + STACK_OF(X509_NAME) *ca_names; + + int use_rsa_tmp; + + int key_block_length; + unsigned char *key_block; + + const EVP_CIPHER *new_sym_enc; + const EVP_MD *new_hash; +#ifndef OPENSSL_NO_COMP + const SSL_COMP *new_compression; +#else + char *new_compression; +#endif + int cert_request; + } tmp; + + } SSL3_STATE; + + +/* SSLv3 */ +/*client */ +/* extra state */ +#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) +#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) +#define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) + +/* server */ +/* extra state */ +#define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) +/* read from client */ +/* Do not change the number values, they do matter */ +#define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) +/* write to client */ +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT) +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) +/* read from client */ +#define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) +/* write to client */ +#define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) + +#define SSL3_MT_HELLO_REQUEST 0 +#define SSL3_MT_CLIENT_HELLO 1 +#define SSL3_MT_SERVER_HELLO 2 +#define SSL3_MT_CERTIFICATE 11 +#define SSL3_MT_SERVER_KEY_EXCHANGE 12 +#define SSL3_MT_CERTIFICATE_REQUEST 13 +#define SSL3_MT_SERVER_DONE 14 +#define SSL3_MT_CERTIFICATE_VERIFY 15 +#define SSL3_MT_CLIENT_KEY_EXCHANGE 16 +#define SSL3_MT_FINISHED 20 +#define DTLS1_MT_HELLO_VERIFY_REQUEST 3 + + +#define SSL3_MT_CCS 1 + +/* These are used when changing over to a new cipher */ +#define SSL3_CC_READ 0x01 +#define SSL3_CC_WRITE 0x02 +#define SSL3_CC_CLIENT 0x10 +#define SSL3_CC_SERVER 0x20 +#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) +#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/stack.h b/libraries/external/openssl/linux/include/openssl/stack.h new file mode 100755 index 0000000..7f3b13d --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/stack.h @@ -0,0 +1,109 @@ +/* crypto/stack/stack.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_STACK_H +#define HEADER_STACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stack_st + { + int num; + char **data; + int sorted; + + int num_alloc; + int (*comp)(const char * const *, const char * const *); + } STACK; + +#define M_sk_num(sk) ((sk) ? (sk)->num:-1) +#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) + +int sk_num(const STACK *); +char *sk_value(const STACK *, int); + +char *sk_set(STACK *, int, char *); + +STACK *sk_new(int (*cmp)(const char * const *, const char * const *)); +STACK *sk_new_null(void); +void sk_free(STACK *); +void sk_pop_free(STACK *st, void (*func)(void *)); +int sk_insert(STACK *sk,char *data,int where); +char *sk_delete(STACK *st,int loc); +char *sk_delete_ptr(STACK *st, char *p); +int sk_find(STACK *st,char *data); +int sk_find_ex(STACK *st,char *data); +int sk_push(STACK *st,char *data); +int sk_unshift(STACK *st,char *data); +char *sk_shift(STACK *st); +char *sk_pop(STACK *st); +void sk_zero(STACK *st); +int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, + const char * const *))) + (const char * const *, const char * const *); +STACK *sk_dup(STACK *st); +void sk_sort(STACK *st); +int sk_is_sorted(const STACK *st); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/store.h b/libraries/external/openssl/linux/include/openssl/store.h new file mode 100755 index 0000000..9665d0d --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/store.h @@ -0,0 +1,554 @@ +/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2003. + */ +/* ==================================================================== + * Copyright (c) 2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_STORE_H +#define HEADER_STORE_H + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct store_st STORE; */ +/* typedef struct store_method_st STORE_METHOD; */ + + +/* All the following functions return 0, a negative number or NULL on error. + When everything is fine, they return a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +STORE *STORE_new_method(const STORE_METHOD *method); +STORE *STORE_new_engine(ENGINE *engine); +void STORE_free(STORE *ui); + + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a STORE. */ +int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); + +/* A control to set the directory with keys and certificates. Used by the + built-in directory level method. */ +#define STORE_CTRL_SET_DIRECTORY 0x0001 +/* A control to set a file to load. Used by the built-in file level method. */ +#define STORE_CTRL_SET_FILE 0x0002 +/* A control to set a configuration file to load. Can be used by any method + that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_FILE 0x0003 +/* A control to set a the section of the loaded configuration file. Can be + used by any method that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_SECTION 0x0004 + + +/* Some methods may use extra data */ +#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) +#define STORE_get_app_data(s) STORE_get_ex_data(s,0) +int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int STORE_set_ex_data(STORE *r,int idx,void *arg); +void *STORE_get_ex_data(STORE *r, int idx); + +/* Use specific methods instead of the built-in one */ +const STORE_METHOD *STORE_get_method(STORE *store); +const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); + +/* The standard OpenSSL methods. */ +/* This is the in-memory method. It does everything except revoking and updating, + and is of course volatile. It's used by other methods that have an in-memory + cache. */ +const STORE_METHOD *STORE_Memory(void); +#if 0 /* Not yet implemented */ +/* This is the directory store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. */ +const STORE_METHOD *STORE_Directory(void); +/* This is the file store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. Certificates are added + to it with the store operation, and it will only get cached certificates. */ +const STORE_METHOD *STORE_File(void); +#endif + +/* Store functions take a type code for the type of data they should store + or fetch */ +typedef enum STORE_object_types + { + STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ + STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ + STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ + STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ + STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known + object types */ + } STORE_OBJECT_TYPES; +/* List of text strings corresponding to the object types. */ +extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; + +/* Some store functions take a parameter list. Those parameters come with + one of the following codes. The comments following the codes below indicate + what type the value should be a pointer to. */ +typedef enum STORE_params + { + STORE_PARAM_EVP_TYPE= 0x01, /* int */ + STORE_PARAM_BITS= 0x02, /* size_t */ + STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ + STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ + STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ + STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ + STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known + parameter types */ + } STORE_PARAM_TYPES; +/* Parameter value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; + +/* Store functions take attribute lists. Those attributes come with codes. + The comments following the codes below indicate what type the value should + be a pointer to. */ +typedef enum STORE_attribs + { + STORE_ATTR_END= 0x00, + STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ + STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ + STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ + STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ + STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ + STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ + STORE_ATTR_EMAIL= 0x0a, /* C string */ + STORE_ATTR_FILENAME= 0x0b, /* C string */ + STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known + attribute types */ + STORE_ATTR_OR= 0xff /* This is a special + separator, which + expresses the OR + operation. */ + } STORE_ATTR_TYPES; +/* Attribute value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; + +typedef enum STORE_certificate_status + { + STORE_X509_VALID= 0x00, + STORE_X509_EXPIRED= 0x01, + STORE_X509_SUSPENDED= 0x02, + STORE_X509_REVOKED= 0x03 + } STORE_CERTIFICATE_STATUS; + +/* Engine store functions will return a structure that contains all the necessary + * information, including revokation status for certificates. This is really not + * needed for application authors, as the ENGINE framework functions will extract + * the OpenSSL-specific information when at all possible. However, for engine + * authors, it's crucial to know this structure. */ +typedef struct STORE_OBJECT_st + { + STORE_OBJECT_TYPES type; + union + { + struct + { + STORE_CERTIFICATE_STATUS status; + X509 *certificate; + } x509; + X509_CRL *crl; + EVP_PKEY *key; + BIGNUM *number; + BUF_MEM *arbitrary; + } data; + } STORE_OBJECT; +DECLARE_STACK_OF(STORE_OBJECT) +STORE_OBJECT *STORE_OBJECT_new(void); +void STORE_OBJECT_free(STORE_OBJECT *data); + + + +/* The following functions handle the storage. They return 0, a negative number + or NULL on error, anything else on success. */ +X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509 *STORE_list_certificate_next(STORE *e, void *handle); +int STORE_list_certificate_end(STORE *e, void *handle); +int STORE_list_certificate_endp(STORE *e, void *handle); +EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_private_key(STORE *e, EVP_PKEY *data, + OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); +int STORE_list_private_key_end(STORE *e, void *handle); +int STORE_list_private_key_endp(STORE *e, void *handle); +EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); +int STORE_list_public_key_end(STORE *e, void *handle); +int STORE_list_public_key_endp(STORE *e, void *handle); +X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_list_crl_next(STORE *e, void *handle); +int STORE_list_crl_end(STORE *e, void *handle); +int STORE_list_crl_endp(STORE *e, void *handle); +int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); + + +/* Create and manipulate methods */ +STORE_METHOD *STORE_create_method(char *name); +void STORE_destroy_method(STORE_METHOD *store_method); + +/* These callback types are use for store handlers */ +typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); +typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); +typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); + +int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); +int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); +int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); +int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); +int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); +int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); +int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); +int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); +int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); +int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); +int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); +int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); + +STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); +STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); +STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); +STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); +STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); +STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); +STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); +STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); +STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); +STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); + +/* Method helper structures and functions. */ + +/* This structure is the result of parsing through the information in a list + of OPENSSL_ITEMs. It stores all the necessary information in a structured + way.*/ +typedef struct STORE_attr_info_st STORE_ATTR_INFO; + +/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. + Note that we do this in the list form, since the list of OPENSSL_ITEMs can + come in blocks separated with STORE_ATTR_OR. Note that the value returned + by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ +void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); +STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); +int STORE_parse_attrs_end(void *handle); +int STORE_parse_attrs_endp(void *handle); + +/* Creator and destructor */ +STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); +int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); + +/* Manipulators */ +char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, + STORE_ATTR_TYPES code); +X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); +int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); + +/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values + in each contained attribute. */ +int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a is within the range of attributes + set in b. */ +int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a are also set in b. */ +int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ +int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_STORE_strings(void); + +/* Error codes for the STORE functions. */ + +/* Function codes. */ +#define STORE_F_MEM_DELETE 134 +#define STORE_F_MEM_GENERATE 135 +#define STORE_F_MEM_LIST_END 168 +#define STORE_F_MEM_LIST_NEXT 136 +#define STORE_F_MEM_LIST_START 137 +#define STORE_F_MEM_MODIFY 169 +#define STORE_F_MEM_STORE 138 +#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 +#define STORE_F_STORE_ATTR_INFO_GET0_DN 140 +#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 +#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 +#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 +#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 +#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 +#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 +#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 +#define STORE_F_STORE_ATTR_INFO_SET_DN 148 +#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 +#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 +#define STORE_F_STORE_CERTIFICATE 170 +#define STORE_F_STORE_CTRL 161 +#define STORE_F_STORE_DELETE_ARBITRARY 158 +#define STORE_F_STORE_DELETE_CERTIFICATE 102 +#define STORE_F_STORE_DELETE_CRL 103 +#define STORE_F_STORE_DELETE_NUMBER 104 +#define STORE_F_STORE_DELETE_PRIVATE_KEY 105 +#define STORE_F_STORE_DELETE_PUBLIC_KEY 106 +#define STORE_F_STORE_GENERATE_CRL 107 +#define STORE_F_STORE_GENERATE_KEY 108 +#define STORE_F_STORE_GET_ARBITRARY 159 +#define STORE_F_STORE_GET_CERTIFICATE 109 +#define STORE_F_STORE_GET_CRL 110 +#define STORE_F_STORE_GET_NUMBER 111 +#define STORE_F_STORE_GET_PRIVATE_KEY 112 +#define STORE_F_STORE_GET_PUBLIC_KEY 113 +#define STORE_F_STORE_LIST_CERTIFICATE_END 114 +#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 +#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 +#define STORE_F_STORE_LIST_CERTIFICATE_START 116 +#define STORE_F_STORE_LIST_CRL_END 117 +#define STORE_F_STORE_LIST_CRL_ENDP 154 +#define STORE_F_STORE_LIST_CRL_NEXT 118 +#define STORE_F_STORE_LIST_CRL_START 119 +#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 +#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 +#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 +#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 +#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 +#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 +#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 +#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 +#define STORE_F_STORE_MODIFY_ARBITRARY 162 +#define STORE_F_STORE_MODIFY_CERTIFICATE 163 +#define STORE_F_STORE_MODIFY_CRL 164 +#define STORE_F_STORE_MODIFY_NUMBER 165 +#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 +#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 +#define STORE_F_STORE_NEW_ENGINE 133 +#define STORE_F_STORE_NEW_METHOD 132 +#define STORE_F_STORE_PARSE_ATTRS_END 151 +#define STORE_F_STORE_PARSE_ATTRS_ENDP 172 +#define STORE_F_STORE_PARSE_ATTRS_NEXT 152 +#define STORE_F_STORE_PARSE_ATTRS_START 171 +#define STORE_F_STORE_REVOKE_CERTIFICATE 129 +#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 +#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 +#define STORE_F_STORE_STORE_ARBITRARY 157 +#define STORE_F_STORE_STORE_CERTIFICATE 100 +#define STORE_F_STORE_STORE_CRL 101 +#define STORE_F_STORE_STORE_NUMBER 126 +#define STORE_F_STORE_STORE_PRIVATE_KEY 127 +#define STORE_F_STORE_STORE_PUBLIC_KEY 128 + +/* Reason codes. */ +#define STORE_R_ALREADY_HAS_A_VALUE 127 +#define STORE_R_FAILED_DELETING_ARBITRARY 132 +#define STORE_R_FAILED_DELETING_CERTIFICATE 100 +#define STORE_R_FAILED_DELETING_KEY 101 +#define STORE_R_FAILED_DELETING_NUMBER 102 +#define STORE_R_FAILED_GENERATING_CRL 103 +#define STORE_R_FAILED_GENERATING_KEY 104 +#define STORE_R_FAILED_GETTING_ARBITRARY 133 +#define STORE_R_FAILED_GETTING_CERTIFICATE 105 +#define STORE_R_FAILED_GETTING_KEY 106 +#define STORE_R_FAILED_GETTING_NUMBER 107 +#define STORE_R_FAILED_LISTING_CERTIFICATES 108 +#define STORE_R_FAILED_LISTING_KEYS 109 +#define STORE_R_FAILED_MODIFYING_ARBITRARY 138 +#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 +#define STORE_R_FAILED_MODIFYING_CRL 140 +#define STORE_R_FAILED_MODIFYING_NUMBER 141 +#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 +#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 +#define STORE_R_FAILED_REVOKING_CERTIFICATE 110 +#define STORE_R_FAILED_REVOKING_KEY 111 +#define STORE_R_FAILED_STORING_ARBITRARY 134 +#define STORE_R_FAILED_STORING_CERTIFICATE 112 +#define STORE_R_FAILED_STORING_KEY 113 +#define STORE_R_FAILED_STORING_NUMBER 114 +#define STORE_R_NOT_IMPLEMENTED 128 +#define STORE_R_NO_CONTROL_FUNCTION 144 +#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 +#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 +#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 +#define STORE_R_NO_GENERATE_CRL_FUNCTION 117 +#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 +#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 +#define STORE_R_NO_GET_OBJECT_FUNCTION 119 +#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 +#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 +#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 +#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 +#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 +#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 +#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 +#define STORE_R_NO_STORE 129 +#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 +#define STORE_R_NO_STORE_OBJECT_FUNCTION 125 +#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 +#define STORE_R_NO_VALUE 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/symhacks.h b/libraries/external/openssl/linux/include/openssl/symhacks.h new file mode 100755 index 0000000..16df42d --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/symhacks.h @@ -0,0 +1,383 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SYMHACKS_H +#define HEADER_SYMHACKS_H + +#include + +/* Hacks to solve the problem with linkers incapable of handling very long + symbol names. In the case of VMS, the limit is 31 characters on VMS for + VAX. */ +#ifdef OPENSSL_SYS_VMS + +/* Hack a long name in crypto/ex_data.c */ +#undef CRYPTO_get_ex_data_implementation +#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl +#undef CRYPTO_set_ex_data_implementation +#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl + +/* Hack a long name in crypto/asn1/a_mbstr.c */ +#undef ASN1_STRING_set_default_mask_asc +#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF +#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF +#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */ +#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC +#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC +#endif + +/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ +#undef PEM_read_NETSCAPE_CERT_SEQUENCE +#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ +#undef PEM_write_NETSCAPE_CERT_SEQUENCE +#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ +#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ +#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ +#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ + +/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */ +#undef PEM_read_PKCS8_PRIV_KEY_INFO +#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO +#undef PEM_write_PKCS8_PRIV_KEY_INFO +#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO +#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO +#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO +#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO +#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO + +/* Hack other PEM names */ +#undef PEM_write_bio_PKCS8PrivateKey_nid +#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid + +/* Hack some long X509 names */ +#undef X509_REVOKED_get_ext_by_critical +#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic +#undef X509_policy_tree_get0_user_policies +#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies +#undef X509_policy_node_get0_qualifiers +#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers +#undef X509_STORE_CTX_get_explicit_policy +#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy + +/* Hack some long CRYPTO names */ +#undef CRYPTO_set_dynlock_destroy_callback +#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb +#undef CRYPTO_set_dynlock_create_callback +#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb +#undef CRYPTO_set_dynlock_lock_callback +#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb +#undef CRYPTO_get_dynlock_lock_callback +#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb +#undef CRYPTO_get_dynlock_destroy_callback +#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb +#undef CRYPTO_get_dynlock_create_callback +#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb +#undef CRYPTO_set_locked_mem_ex_functions +#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs +#undef CRYPTO_get_locked_mem_ex_functions +#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs + +/* Hack some long SSL names */ +#undef SSL_CTX_set_default_verify_paths +#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths +#undef SSL_get_ex_data_X509_STORE_CTX_idx +#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx +#undef SSL_add_file_cert_subjects_to_stack +#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk +#undef SSL_add_dir_cert_subjects_to_stack +#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk +#undef SSL_CTX_use_certificate_chain_file +#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file +#undef SSL_CTX_set_cert_verify_callback +#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb +#undef SSL_CTX_set_default_passwd_cb_userdata +#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud +#undef SSL_COMP_get_compression_methods +#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods + +/* Hack some long ENGINE names */ +#undef ENGINE_get_default_BN_mod_exp_crt +#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt +#undef ENGINE_set_default_BN_mod_exp_crt +#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt +#undef ENGINE_set_load_privkey_function +#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn +#undef ENGINE_get_load_privkey_function +#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn + +/* Hack some long OCSP names */ +#undef OCSP_REQUEST_get_ext_by_critical +#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit +#undef OCSP_BASICRESP_get_ext_by_critical +#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit +#undef OCSP_SINGLERESP_get_ext_by_critical +#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit + +/* Hack some long DES names */ +#undef _ossl_old_des_ede3_cfb64_encrypt +#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt +#undef _ossl_old_des_ede3_ofb64_encrypt +#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt + +/* Hack some long EVP names */ +#undef OPENSSL_add_all_algorithms_noconf +#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf +#undef OPENSSL_add_all_algorithms_conf +#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf + +/* Hack some long EC names */ +#undef EC_GROUP_set_point_conversion_form +#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form +#undef EC_GROUP_get_point_conversion_form +#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form +#undef EC_GROUP_clear_free_all_extra_data +#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data +#undef EC_POINT_set_Jprojective_coordinates_GFp +#define EC_POINT_set_Jprojective_coordinates_GFp \ + EC_POINT_set_Jproj_coords_GFp +#undef EC_POINT_get_Jprojective_coordinates_GFp +#define EC_POINT_get_Jprojective_coordinates_GFp \ + EC_POINT_get_Jproj_coords_GFp +#undef EC_POINT_set_affine_coordinates_GFp +#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp +#undef EC_POINT_get_affine_coordinates_GFp +#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp +#undef EC_POINT_set_compressed_coordinates_GFp +#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp +#undef EC_POINT_set_affine_coordinates_GF2m +#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m +#undef EC_POINT_get_affine_coordinates_GF2m +#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m +#undef EC_POINT_set_compressed_coordinates_GF2m +#define EC_POINT_set_compressed_coordinates_GF2m \ + EC_POINT_set_compr_coords_GF2m +#undef ec_GF2m_simple_group_clear_finish +#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish +#undef ec_GF2m_simple_group_check_discriminant +#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim +#undef ec_GF2m_simple_point_clear_finish +#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish +#undef ec_GF2m_simple_point_set_to_infinity +#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf +#undef ec_GF2m_simple_points_make_affine +#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine +#undef ec_GF2m_simple_point_set_affine_coordinates +#define ec_GF2m_simple_point_set_affine_coordinates \ + ec_GF2m_smp_pt_set_af_coords +#undef ec_GF2m_simple_point_get_affine_coordinates +#define ec_GF2m_simple_point_get_affine_coordinates \ + ec_GF2m_smp_pt_get_af_coords +#undef ec_GF2m_simple_set_compressed_coordinates +#define ec_GF2m_simple_set_compressed_coordinates \ + ec_GF2m_smp_set_compr_coords +#undef ec_GFp_simple_group_set_curve_GFp +#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_group_clear_finish +#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish +#undef ec_GFp_simple_group_set_generator +#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator +#undef ec_GFp_simple_group_get0_generator +#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator +#undef ec_GFp_simple_group_get_cofactor +#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor +#undef ec_GFp_simple_point_clear_finish +#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish +#undef ec_GFp_simple_point_set_to_infinity +#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf +#undef ec_GFp_simple_points_make_affine +#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_set_Jprojective_coordinates_GFp +#define ec_GFp_simple_set_Jprojective_coordinates_GFp \ + ec_GFp_smp_set_Jproj_coords_GFp +#undef ec_GFp_simple_get_Jprojective_coordinates_GFp +#define ec_GFp_simple_get_Jprojective_coordinates_GFp \ + ec_GFp_smp_get_Jproj_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates_GFp +#define ec_GFp_simple_point_set_affine_coordinates_GFp \ + ec_GFp_smp_pt_set_af_coords_GFp +#undef ec_GFp_simple_point_get_affine_coordinates_GFp +#define ec_GFp_simple_point_get_affine_coordinates_GFp \ + ec_GFp_smp_pt_get_af_coords_GFp +#undef ec_GFp_simple_set_compressed_coordinates_GFp +#define ec_GFp_simple_set_compressed_coordinates_GFp \ + ec_GFp_smp_set_compr_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates +#define ec_GFp_simple_point_set_affine_coordinates \ + ec_GFp_smp_pt_set_af_coords +#undef ec_GFp_simple_point_get_affine_coordinates +#define ec_GFp_simple_point_get_affine_coordinates \ + ec_GFp_smp_pt_get_af_coords +#undef ec_GFp_simple_set_compressed_coordinates +#define ec_GFp_simple_set_compressed_coordinates \ + ec_GFp_smp_set_compr_coords +#undef ec_GFp_simple_group_check_discriminant +#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim + +/* Hack som long STORE names */ +#undef STORE_method_set_initialise_function +#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn +#undef STORE_method_set_cleanup_function +#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn +#undef STORE_method_set_generate_function +#define STORE_method_set_generate_function STORE_meth_set_generate_fn +#undef STORE_method_set_modify_function +#define STORE_method_set_modify_function STORE_meth_set_modify_fn +#undef STORE_method_set_revoke_function +#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn +#undef STORE_method_set_delete_function +#define STORE_method_set_delete_function STORE_meth_set_delete_fn +#undef STORE_method_set_list_start_function +#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn +#undef STORE_method_set_list_next_function +#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn +#undef STORE_method_set_list_end_function +#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn +#undef STORE_method_set_update_store_function +#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn +#undef STORE_method_set_lock_store_function +#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn +#undef STORE_method_set_unlock_store_function +#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn +#undef STORE_method_get_initialise_function +#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn +#undef STORE_method_get_cleanup_function +#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn +#undef STORE_method_get_generate_function +#define STORE_method_get_generate_function STORE_meth_get_generate_fn +#undef STORE_method_get_modify_function +#define STORE_method_get_modify_function STORE_meth_get_modify_fn +#undef STORE_method_get_revoke_function +#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn +#undef STORE_method_get_delete_function +#define STORE_method_get_delete_function STORE_meth_get_delete_fn +#undef STORE_method_get_list_start_function +#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn +#undef STORE_method_get_list_next_function +#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn +#undef STORE_method_get_list_end_function +#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn +#undef STORE_method_get_update_store_function +#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn +#undef STORE_method_get_lock_store_function +#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn +#undef STORE_method_get_unlock_store_function +#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn + +#endif /* defined OPENSSL_SYS_VMS */ + + +/* Case insensiteve linking causes problems.... */ +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) +#undef ERR_load_CRYPTO_strings +#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings +#undef OCSP_crlID_new +#define OCSP_crlID_new OCSP_crlID2_new + +#undef d2i_ECPARAMETERS +#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS +#undef i2d_ECPARAMETERS +#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS +#undef d2i_ECPKPARAMETERS +#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS +#undef i2d_ECPKPARAMETERS +#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS + +/* These functions do not seem to exist! However, I'm paranoid... + Original command in x509v3.h: + These functions are being redefined in another directory, + and clash when the linker is case-insensitive, so let's + hide them a little, by giving them an extra 'o' at the + beginning of the name... */ +#undef X509v3_cleanup_extensions +#define X509v3_cleanup_extensions oX509v3_cleanup_extensions +#undef X509v3_add_extension +#define X509v3_add_extension oX509v3_add_extension +#undef X509v3_add_netscape_extensions +#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions +#undef X509v3_add_standard_extensions +#define X509v3_add_standard_extensions oX509v3_add_standard_extensions + + +#endif + + +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/libraries/external/openssl/linux/include/openssl/tls1.h b/libraries/external/openssl/linux/include/openssl/tls1.h new file mode 100755 index 0000000..1fabd50 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/tls1.h @@ -0,0 +1,305 @@ +/* ssl/tls1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * ECC cipher suite support in OpenSSL originally written by + * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_TLS1_H +#define HEADER_TLS1_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 + +#define TLS1_VERSION 0x0301 +#define TLS1_VERSION_MAJOR 0x03 +#define TLS1_VERSION_MINOR 0x01 + +#define TLS1_AD_DECRYPTION_FAILED 21 +#define TLS1_AD_RECORD_OVERFLOW 22 +#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ +#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ +#define TLS1_AD_DECODE_ERROR 50 /* fatal */ +#define TLS1_AD_DECRYPT_ERROR 51 +#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ +#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ +#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ +#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ +#define TLS1_AD_USER_CANCELLED 90 +#define TLS1_AD_NO_RENEGOTIATION 100 + +/* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt + * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see + * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably + * shouldn't. */ +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 +#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 +#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 + +/* AES ciphersuites from RFC3268 */ + +#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F +#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 +#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 +#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 +#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 +#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 + +#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 +#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 +#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 +#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 +#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 +#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A + +/* Camellia ciphersuites from RFC4132 */ +#define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 +#define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 +#define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 +#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 +#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 +#define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 + +#define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 +#define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 +#define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 +#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 +#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 +#define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 + +/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */ +#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 +#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 +#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 + +#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 +#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 +#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A + +#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B +#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C +#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D +#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E +#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F + +#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 +#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 +#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 +#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 +#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 + +#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 +#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 +#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 +#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 +#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 + +/* XXX + * Inconsistency alert: + * The OpenSSL names of ciphers with ephemeral DH here include the string + * "DHE", while elsewhere it has always been "EDH". + * (The alias for the list of all such ciphers also is "EDH".) + * The specifications speak of "EDH"; maybe we should allow both forms + * for everything. */ +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" +#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" + +/* AES ciphersuites from RFC3268 */ +#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" +#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" + +#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" +#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" + +/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" + +#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" +#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" +#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" + +/* Camellia ciphersuites form RFC4132 */ +#define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" +#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" +#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" +#define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" + +#define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" +#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" +#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" +#define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" + + +#define TLS_CT_RSA_SIGN 1 +#define TLS_CT_DSS_SIGN 2 +#define TLS_CT_RSA_FIXED_DH 3 +#define TLS_CT_DSS_FIXED_DH 4 +#define TLS_CT_ECDSA_SIGN 64 +#define TLS_CT_RSA_FIXED_ECDH 65 +#define TLS_CT_ECDSA_FIXED_ECDH 66 +#define TLS_CT_NUMBER 7 + +#define TLS1_FINISH_MAC_LENGTH 12 + +#define TLS_MD_MAX_CONST_SIZE 20 +#define TLS_MD_CLIENT_FINISH_CONST "client finished" +#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_FINISH_CONST "server finished" +#define TLS_MD_SERVER_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_KEY_EXPANSION_CONST "key expansion" +#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 +#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" +#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_IV_BLOCK_CONST "IV block" +#define TLS_MD_IV_BLOCK_CONST_SIZE 8 +#define TLS_MD_MASTER_SECRET_CONST "master secret" +#define TLS_MD_MASTER_SECRET_CONST_SIZE 13 + +#ifdef CHARSET_EBCDIC +#undef TLS_MD_CLIENT_FINISH_CONST +#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/ +#undef TLS_MD_SERVER_FINISH_CONST +#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_KEY_EXPANSION_CONST +#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/ +#undef TLS_MD_CLIENT_WRITE_KEY_CONST +#define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_IV_BLOCK_CONST +#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/ +#undef TLS_MD_MASTER_SECRET_CONST +#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ +#endif + +#ifdef __cplusplus +} +#endif +#endif + + + diff --git a/libraries/external/openssl/linux/include/openssl/tmdiff.h b/libraries/external/openssl/linux/include/openssl/tmdiff.h new file mode 100755 index 0000000..6ed309e --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/tmdiff.h @@ -0,0 +1,93 @@ +/* crypto/tmdiff.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ +/* ... erm yeah, "dynamic hash tables" you say? + * + * And what would dynamic hash tables have to do with any of this code *now*? + * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused + * file that I doubt compiles any more. speed.c is the only thing that could + * use this (and it has nothing to do with hash tables), yet it instead has its + * own duplication of all this stuff and looks, if anything, more complete. See + * the corresponding note in apps/speed.c. + * The Bemused - Geoff + */ + +#ifndef HEADER_TMDIFF_H +#define HEADER_TMDIFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ms_tm MS_TM; + +MS_TM *ms_time_new(void ); +void ms_time_free(MS_TM *a); +void ms_time_get(MS_TM *a); +double ms_time_diff(MS_TM *start, MS_TM *end); +int ms_time_cmp(const MS_TM *ap, const MS_TM *bp); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/txt_db.h b/libraries/external/openssl/linux/include/openssl/txt_db.h new file mode 100755 index 0000000..a767e45 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/txt_db.h @@ -0,0 +1,109 @@ +/* crypto/txt_db/txt_db.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_TXT_DB_H +#define HEADER_TXT_DB_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#define DB_ERROR_OK 0 +#define DB_ERROR_MALLOC 1 +#define DB_ERROR_INDEX_CLASH 2 +#define DB_ERROR_INDEX_OUT_OF_RANGE 3 +#define DB_ERROR_NO_INDEX 4 +#define DB_ERROR_INSERT_INDEX_CLASH 5 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct txt_db_st + { + int num_fields; + STACK /* char ** */ *data; + LHASH **index; + int (**qual)(char **); + long error; + long arg1; + long arg2; + char **arg_row; + } TXT_DB; + +#ifndef OPENSSL_NO_BIO +TXT_DB *TXT_DB_read(BIO *in, int num); +long TXT_DB_write(BIO *out, TXT_DB *db); +#else +TXT_DB *TXT_DB_read(char *in, int num); +long TXT_DB_write(char *out, TXT_DB *db); +#endif +int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **), + LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp); +void TXT_DB_free(TXT_DB *db); +char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); +int TXT_DB_insert(TXT_DB *db,char **value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ui.h b/libraries/external/openssl/linux/include/openssl/ui.h new file mode 100755 index 0000000..5570e0d --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ui.h @@ -0,0 +1,381 @@ +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_H +#define HEADER_UI_H + +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct ui_st UI; */ +/* typedef struct ui_method_st UI_METHOD; */ + + +/* All the following functions return -1 or NULL on error and in some cases + (UI_process()) -2 if interrupted or in some other way cancelled. + When everything is fine, they return 0, a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +UI *UI_new(void); +UI *UI_new_method(const UI_METHOD *method); +void UI_free(UI *ui); + +/* The following functions are used to add strings to be printed and prompt + strings to prompt for data. The names are UI_{add,dup}__string + and UI_{add,dup}_input_boolean. + + UI_{add,dup}__string have the following meanings: + add add a text or prompt string. The pointers given to these + functions are used verbatim, no copying is done. + dup make a copy of the text or prompt string, then add the copy + to the collection of strings in the user interface. + + The function is a name for the functionality that the given + string shall be used for. It can be one of: + input use the string as data prompt. + verify use the string as verification prompt. This + is used to verify a previous input. + info use the string for informational output. + error use the string for error output. + Honestly, there's currently no difference between info and error for the + moment. + + UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", + and are typically used when one wants to prompt for a yes/no response. + + + All of the functions in this group take a UI and a prompt string. + The string input and verify addition functions also take a flag argument, + a buffer for the result to end up with, a minimum input size and a maximum + input size (the result buffer MUST be large enough to be able to contain + the maximum number of characters). Additionally, the verify addition + functions takes another buffer to compare the result against. + The boolean input functions take an action description string (which should + be safe to ignore if the expected user action is obvious, for example with + a dialog box with an OK button and a Cancel button), a string of acceptable + characters to mean OK and to mean Cancel. The two last strings are checked + to make sure they don't have common characters. Additionally, the same + flag argument as for the string input is taken, as well as a result buffer. + The result buffer is required to be at least one byte long. Depending on + the answer, the first character from the OK or the Cancel character strings + will be stored in the first byte of the result buffer. No NUL will be + added, so the result is *not* a string. + + On success, the all return an index of the added information. That index + is usefull when retrieving results with UI_get0_result(). */ +int UI_add_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_dup_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_add_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_dup_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_add_info_string(UI *ui, const char *text); +int UI_dup_info_string(UI *ui, const char *text); +int UI_add_error_string(UI *ui, const char *text); +int UI_dup_error_string(UI *ui, const char *text); + +/* These are the possible flags. They can be or'ed together. */ +/* Use to have echoing of input */ +#define UI_INPUT_FLAG_ECHO 0x01 +/* Use a default password. Where that password is found is completely + up to the application, it might for example be in the user data set + with UI_add_user_data(). It is not recommended to have more than + one input in each UI being marked with this flag, or the application + might get confused. */ +#define UI_INPUT_FLAG_DEFAULT_PWD 0x02 + +/* The user of these routines may want to define flags of their own. The core + UI won't look at those, but will pass them on to the method routines. They + must use higher bits so they don't get confused with the UI bits above. + UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good + example of use is this: + + #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) + +*/ +#define UI_INPUT_FLAG_USER_BASE 16 + + +/* The following function helps construct a prompt. object_desc is a + textual short description of the object, for example "pass phrase", + and object_name is the name of the object (might be a card name or + a file name. + The returned string shall always be allocated on the heap with + OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). + + If the ui_method doesn't contain a pointer to a user-defined prompt + constructor, a default string is built, looking like this: + + "Enter {object_desc} for {object_name}:" + + So, if object_desc has the value "pass phrase" and object_name has + the value "foo.key", the resulting string is: + + "Enter pass phrase for foo.key:" +*/ +char *UI_construct_prompt(UI *ui_method, + const char *object_desc, const char *object_name); + + +/* The following function is used to store a pointer to user-specific data. + Any previous such pointer will be returned and replaced. + + For callback purposes, this function makes a lot more sense than using + ex_data, since the latter requires that different parts of OpenSSL or + applications share the same ex_data index. + + Note that the UI_OpenSSL() method completely ignores the user data. + Other methods may not, however. */ +void *UI_add_user_data(UI *ui, void *user_data); +/* We need a user data retrieving function as well. */ +void *UI_get0_user_data(UI *ui); + +/* Return the result associated with a prompt given with the index i. */ +const char *UI_get0_result(UI *ui, int i); + +/* When all strings have been added, process the whole thing. */ +int UI_process(UI *ui); + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a UI. */ +int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); + +/* The commands */ +/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the + OpenSSL error stack before printing any info or added error messages and + before any prompting. */ +#define UI_CTRL_PRINT_ERRORS 1 +/* Check if a UI_process() is possible to do again with the same instance of + a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 + if not. */ +#define UI_CTRL_IS_REDOABLE 2 + + +/* Some methods may use extra data */ +#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) +#define UI_get_app_data(s) UI_get_ex_data(s,0) +int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int UI_set_ex_data(UI *r,int idx,void *arg); +void *UI_get_ex_data(UI *r, int idx); + +/* Use specific methods instead of the built-in one */ +void UI_set_default_method(const UI_METHOD *meth); +const UI_METHOD *UI_get_default_method(void); +const UI_METHOD *UI_get_method(UI *ui); +const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); + +/* The method with all the built-in thingies */ +UI_METHOD *UI_OpenSSL(void); + + +/* ---------- For method writers ---------- */ +/* A method contains a number of functions that implement the low level + of the User Interface. The functions are: + + an opener This function starts a session, maybe by opening + a channel to a tty, or by opening a window. + a writer This function is called to write a given string, + maybe to the tty, maybe as a field label in a + window. + a flusher This function is called to flush everything that + has been output so far. It can be used to actually + display a dialog box after it has been built. + a reader This function is called to read a given prompt, + maybe from the tty, maybe from a field in a + window. Note that it's called wth all string + structures, not only the prompt ones, so it must + check such things itself. + a closer This function closes the session, maybe by closing + the channel to the tty, or closing the window. + + All these functions are expected to return: + + 0 on error. + 1 on success. + -1 on out-of-band events, for example if some prompting has + been canceled (by pressing Ctrl-C, for example). This is + only checked when returned by the flusher or the reader. + + The way this is used, the opener is first called, then the writer for all + strings, then the flusher, then the reader for all strings and finally the + closer. Note that if you want to prompt from a terminal or other command + line interface, the best is to have the reader also write the prompts + instead of having the writer do it. If you want to prompt from a dialog + box, the writer can be used to build up the contents of the box, and the + flusher to actually display the box and run the event loop until all data + has been given, after which the reader only grabs the given data and puts + them back into the UI strings. + + All method functions take a UI as argument. Additionally, the writer and + the reader take a UI_STRING. +*/ + +/* The UI_STRING type is the data structure that contains all the needed info + about a string or a prompt, including test data for a verification prompt. +*/ +DECLARE_STACK_OF(UI_STRING) +typedef struct ui_string_st UI_STRING; + +/* The different types of strings that are currently supported. + This is only needed by method authors. */ +enum UI_string_types + { + UIT_NONE=0, + UIT_PROMPT, /* Prompt for a string */ + UIT_VERIFY, /* Prompt for a string and verify */ + UIT_BOOLEAN, /* Prompt for a yes/no response */ + UIT_INFO, /* Send info to the user */ + UIT_ERROR /* Send an error message to the user */ + }; + +/* Create and manipulate methods */ +UI_METHOD *UI_create_method(char *name); +void UI_destroy_method(UI_METHOD *ui_method); +int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); +int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); +int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); +int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); +int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); +int (*UI_method_get_opener(UI_METHOD *method))(UI*); +int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_flusher(UI_METHOD *method))(UI*); +int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_closer(UI_METHOD *method))(UI*); + +/* The following functions are helpers for method writers to access relevant + data from a UI_STRING. */ + +/* Return type of the UI_STRING */ +enum UI_string_types UI_get_string_type(UI_STRING *uis); +/* Return input flags of the UI_STRING */ +int UI_get_input_flags(UI_STRING *uis); +/* Return the actual string to output (the prompt, info or error) */ +const char *UI_get0_output_string(UI_STRING *uis); +/* Return the optional action string to output (the boolean promtp instruction) */ +const char *UI_get0_action_string(UI_STRING *uis); +/* Return the result of a prompt */ +const char *UI_get0_result_string(UI_STRING *uis); +/* Return the string to test the result against. Only useful with verifies. */ +const char *UI_get0_test_string(UI_STRING *uis); +/* Return the required minimum size of the result */ +int UI_get_result_minsize(UI_STRING *uis); +/* Return the required maximum size of the result */ +int UI_get_result_maxsize(UI_STRING *uis); +/* Set the result of a UI_STRING. */ +int UI_set_result(UI *ui, UI_STRING *uis, const char *result); + + +/* A couple of popular utility functions */ +int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); +int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_UI_strings(void); + +/* Error codes for the UI functions. */ + +/* Function codes. */ +#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 +#define UI_F_GENERAL_ALLOCATE_PROMPT 109 +#define UI_F_GENERAL_ALLOCATE_STRING 100 +#define UI_F_UI_CTRL 111 +#define UI_F_UI_DUP_ERROR_STRING 101 +#define UI_F_UI_DUP_INFO_STRING 102 +#define UI_F_UI_DUP_INPUT_BOOLEAN 110 +#define UI_F_UI_DUP_INPUT_STRING 103 +#define UI_F_UI_DUP_VERIFY_STRING 106 +#define UI_F_UI_GET0_RESULT 107 +#define UI_F_UI_NEW_METHOD 104 +#define UI_F_UI_SET_RESULT 105 + +/* Reason codes. */ +#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 +#define UI_R_INDEX_TOO_LARGE 102 +#define UI_R_INDEX_TOO_SMALL 103 +#define UI_R_NO_RESULT_BUFFER 105 +#define UI_R_RESULT_TOO_LARGE 100 +#define UI_R_RESULT_TOO_SMALL 101 +#define UI_R_UNKNOWN_CONTROL_COMMAND 106 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/ui_compat.h b/libraries/external/openssl/linux/include/openssl/ui_compat.h new file mode 100755 index 0000000..0209438 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/ui_compat.h @@ -0,0 +1,83 @@ +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_COMPAT_H +#define HEADER_UI_COMPAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following functions were previously part of the DES section, + and are provided here for backward compatibility reasons. */ + +#define des_read_pw_string(b,l,p,v) \ + _ossl_old_des_read_pw_string((b),(l),(p),(v)) +#define des_read_pw(b,bf,s,p,v) \ + _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) + +int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); +int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/vssver.scc b/libraries/external/openssl/linux/include/openssl/vssver.scc new file mode 100755 index 0000000..5a05a5f Binary files /dev/null and b/libraries/external/openssl/linux/include/openssl/vssver.scc differ diff --git a/libraries/external/openssl/linux/include/openssl/x509.h b/libraries/external/openssl/linux/include/openssl/x509.h new file mode 100755 index 0000000..5e36aca --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/x509.h @@ -0,0 +1,1344 @@ +/* crypto/x509/x509.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_X509_H +#define HEADER_X509_H + +#include +#include +#ifndef OPENSSL_NO_BUFFER +#include +#endif +#ifndef OPENSSL_NO_EVP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#include + +#ifndef OPENSSL_NO_EC +#include +#endif + +#ifndef OPENSSL_NO_ECDSA +#include +#endif + +#ifndef OPENSSL_NO_ECDH +#include +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#endif + +#ifndef OPENSSL_NO_SHA +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 these are defined in wincrypt.h */ +#undef X509_NAME +#undef X509_CERT_PAIR +#endif + +#define X509_FILETYPE_PEM 1 +#define X509_FILETYPE_ASN1 2 +#define X509_FILETYPE_DEFAULT 3 + +#define X509v3_KU_DIGITAL_SIGNATURE 0x0080 +#define X509v3_KU_NON_REPUDIATION 0x0040 +#define X509v3_KU_KEY_ENCIPHERMENT 0x0020 +#define X509v3_KU_DATA_ENCIPHERMENT 0x0010 +#define X509v3_KU_KEY_AGREEMENT 0x0008 +#define X509v3_KU_KEY_CERT_SIGN 0x0004 +#define X509v3_KU_CRL_SIGN 0x0002 +#define X509v3_KU_ENCIPHER_ONLY 0x0001 +#define X509v3_KU_DECIPHER_ONLY 0x8000 +#define X509v3_KU_UNDEF 0xffff + +typedef struct X509_objects_st + { + int nid; + int (*a2i)(void); + int (*i2a)(void); + } X509_OBJECTS; + +struct X509_algor_st + { + ASN1_OBJECT *algorithm; + ASN1_TYPE *parameter; + } /* X509_ALGOR */; + +DECLARE_STACK_OF(X509_ALGOR) +DECLARE_ASN1_SET_OF(X509_ALGOR) + +typedef struct X509_val_st + { + ASN1_TIME *notBefore; + ASN1_TIME *notAfter; + } X509_VAL; + +typedef struct X509_pubkey_st + { + X509_ALGOR *algor; + ASN1_BIT_STRING *public_key; + EVP_PKEY *pkey; + } X509_PUBKEY; + +typedef struct X509_sig_st + { + X509_ALGOR *algor; + ASN1_OCTET_STRING *digest; + } X509_SIG; + +typedef struct X509_name_entry_st + { + ASN1_OBJECT *object; + ASN1_STRING *value; + int set; + int size; /* temp variable */ + } X509_NAME_ENTRY; + +DECLARE_STACK_OF(X509_NAME_ENTRY) +DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) + +/* we always keep X509_NAMEs in 2 forms. */ +struct X509_name_st + { + STACK_OF(X509_NAME_ENTRY) *entries; + int modified; /* true if 'bytes' needs to be built */ +#ifndef OPENSSL_NO_BUFFER + BUF_MEM *bytes; +#else + char *bytes; +#endif + unsigned long hash; /* Keep the hash around for lookups */ + } /* X509_NAME */; + +DECLARE_STACK_OF(X509_NAME) + +#define X509_EX_V_NETSCAPE_HACK 0x8000 +#define X509_EX_V_INIT 0x0001 +typedef struct X509_extension_st + { + ASN1_OBJECT *object; + ASN1_BOOLEAN critical; + ASN1_OCTET_STRING *value; + } X509_EXTENSION; + +DECLARE_STACK_OF(X509_EXTENSION) +DECLARE_ASN1_SET_OF(X509_EXTENSION) + +/* a sequence of these are used */ +typedef struct x509_attributes_st + { + ASN1_OBJECT *object; + int single; /* 0 for a set, 1 for a single item (which is wrong) */ + union { + char *ptr; +/* 0 */ STACK_OF(ASN1_TYPE) *set; +/* 1 */ ASN1_TYPE *single; + } value; + } X509_ATTRIBUTE; + +DECLARE_STACK_OF(X509_ATTRIBUTE) +DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) + + +typedef struct X509_req_info_st + { + ASN1_ENCODING enc; + ASN1_INTEGER *version; + X509_NAME *subject; + X509_PUBKEY *pubkey; + /* d=2 hl=2 l= 0 cons: cont: 00 */ + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } X509_REQ_INFO; + +typedef struct X509_req_st + { + X509_REQ_INFO *req_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } X509_REQ; + +typedef struct x509_cinf_st + { + ASN1_INTEGER *version; /* [ 0 ] default of v1 */ + ASN1_INTEGER *serialNumber; + X509_ALGOR *signature; + X509_NAME *issuer; + X509_VAL *validity; + X509_NAME *subject; + X509_PUBKEY *key; + ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ + ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ + STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ + } X509_CINF; + +/* This stuff is certificate "auxiliary info" + * it contains details which are useful in certificate + * stores and databases. When used this is tagged onto + * the end of the certificate itself + */ + +typedef struct x509_cert_aux_st + { + STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ + STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ + ASN1_UTF8STRING *alias; /* "friendly name" */ + ASN1_OCTET_STRING *keyid; /* key id of private key */ + STACK_OF(X509_ALGOR) *other; /* other unspecified info */ + } X509_CERT_AUX; + +struct x509_st + { + X509_CINF *cert_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int valid; + int references; + char *name; + CRYPTO_EX_DATA ex_data; + /* These contain copies of various extension values */ + long ex_pathlen; + long ex_pcpathlen; + unsigned long ex_flags; + unsigned long ex_kusage; + unsigned long ex_xkusage; + unsigned long ex_nscert; + ASN1_OCTET_STRING *skid; + struct AUTHORITY_KEYID_st *akid; + X509_POLICY_CACHE *policy_cache; +#ifndef OPENSSL_NO_RFC3779 + STACK_OF(IPAddressFamily) *rfc3779_addr; + struct ASIdentifiers_st *rfc3779_asid; +#endif +#ifndef OPENSSL_NO_SHA + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; +#endif + X509_CERT_AUX *aux; + } /* X509 */; + +DECLARE_STACK_OF(X509) +DECLARE_ASN1_SET_OF(X509) + +/* This is used for a table of trust checking functions */ + +typedef struct x509_trust_st { + int trust; + int flags; + int (*check_trust)(struct x509_trust_st *, X509 *, int); + char *name; + int arg1; + void *arg2; +} X509_TRUST; + +DECLARE_STACK_OF(X509_TRUST) + +typedef struct x509_cert_pair_st { + X509 *forward; + X509 *reverse; +} X509_CERT_PAIR; + +/* standard trust ids */ + +#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */ + +#define X509_TRUST_COMPAT 1 +#define X509_TRUST_SSL_CLIENT 2 +#define X509_TRUST_SSL_SERVER 3 +#define X509_TRUST_EMAIL 4 +#define X509_TRUST_OBJECT_SIGN 5 +#define X509_TRUST_OCSP_SIGN 6 +#define X509_TRUST_OCSP_REQUEST 7 + +/* Keep these up to date! */ +#define X509_TRUST_MIN 1 +#define X509_TRUST_MAX 7 + + +/* trust_flags values */ +#define X509_TRUST_DYNAMIC 1 +#define X509_TRUST_DYNAMIC_NAME 2 + +/* check_trust return codes */ + +#define X509_TRUST_TRUSTED 1 +#define X509_TRUST_REJECTED 2 +#define X509_TRUST_UNTRUSTED 3 + +/* Flags for X509_print_ex() */ + +#define X509_FLAG_COMPAT 0 +#define X509_FLAG_NO_HEADER 1L +#define X509_FLAG_NO_VERSION (1L << 1) +#define X509_FLAG_NO_SERIAL (1L << 2) +#define X509_FLAG_NO_SIGNAME (1L << 3) +#define X509_FLAG_NO_ISSUER (1L << 4) +#define X509_FLAG_NO_VALIDITY (1L << 5) +#define X509_FLAG_NO_SUBJECT (1L << 6) +#define X509_FLAG_NO_PUBKEY (1L << 7) +#define X509_FLAG_NO_EXTENSIONS (1L << 8) +#define X509_FLAG_NO_SIGDUMP (1L << 9) +#define X509_FLAG_NO_AUX (1L << 10) +#define X509_FLAG_NO_ATTRIBUTES (1L << 11) + +/* Flags specific to X509_NAME_print_ex() */ + +/* The field separator information */ + +#define XN_FLAG_SEP_MASK (0xf << 16) + +#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */ +#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ +#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ +#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ +#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ + +#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ + +/* How the field name is shown */ + +#define XN_FLAG_FN_MASK (0x3 << 21) + +#define XN_FLAG_FN_SN 0 /* Object short name */ +#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ +#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ +#define XN_FLAG_FN_NONE (3 << 21) /* No field names */ + +#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ + +/* This determines if we dump fields we don't recognise: + * RFC2253 requires this. + */ + +#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) + +#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */ + +/* Complete set of RFC2253 flags */ + +#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ + XN_FLAG_SEP_COMMA_PLUS | \ + XN_FLAG_DN_REV | \ + XN_FLAG_FN_SN | \ + XN_FLAG_DUMP_UNKNOWN_FIELDS) + +/* readable oneline form */ + +#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ + ASN1_STRFLGS_ESC_QUOTE | \ + XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_SN) + +/* readable multiline form */ + +#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + XN_FLAG_SEP_MULTILINE | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_LN | \ + XN_FLAG_FN_ALIGN) + +typedef struct X509_revoked_st + { + ASN1_INTEGER *serialNumber; + ASN1_TIME *revocationDate; + STACK_OF(X509_EXTENSION) /* optional */ *extensions; + int sequence; /* load sequence */ + } X509_REVOKED; + +DECLARE_STACK_OF(X509_REVOKED) +DECLARE_ASN1_SET_OF(X509_REVOKED) + +typedef struct X509_crl_info_st + { + ASN1_INTEGER *version; + X509_ALGOR *sig_alg; + X509_NAME *issuer; + ASN1_TIME *lastUpdate; + ASN1_TIME *nextUpdate; + STACK_OF(X509_REVOKED) *revoked; + STACK_OF(X509_EXTENSION) /* [0] */ *extensions; + ASN1_ENCODING enc; + } X509_CRL_INFO; + +struct X509_crl_st + { + /* actual signature */ + X509_CRL_INFO *crl; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } /* X509_CRL */; + +DECLARE_STACK_OF(X509_CRL) +DECLARE_ASN1_SET_OF(X509_CRL) + +typedef struct private_key_st + { + int version; + /* The PKCS#8 data types */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + + /* When decrypted, the following will not be NULL */ + EVP_PKEY *dec_pkey; + + /* used to encrypt and decrypt */ + int key_length; + char *key_data; + int key_free; /* true if we should auto free key_data */ + + /* expanded version of 'enc_algor' */ + EVP_CIPHER_INFO cipher; + + int references; + } X509_PKEY; + +#ifndef OPENSSL_NO_EVP +typedef struct X509_info_st + { + X509 *x509; + X509_CRL *crl; + X509_PKEY *x_pkey; + + EVP_CIPHER_INFO enc_cipher; + int enc_len; + char *enc_data; + + int references; + } X509_INFO; + +DECLARE_STACK_OF(X509_INFO) +#endif + +/* The next 2 structures and their 8 routines were sent to me by + * Pat Richard and are used to manipulate + * Netscapes spki structures - useful if you are writing a CA web page + */ +typedef struct Netscape_spkac_st + { + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ + } NETSCAPE_SPKAC; + +typedef struct Netscape_spki_st + { + NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ + X509_ALGOR *sig_algor; + ASN1_BIT_STRING *signature; + } NETSCAPE_SPKI; + +/* Netscape certificate sequence structure */ +typedef struct Netscape_certificate_sequence + { + ASN1_OBJECT *type; + STACK_OF(X509) *certs; + } NETSCAPE_CERT_SEQUENCE; + +/* Unused (and iv length is wrong) +typedef struct CBCParameter_st + { + unsigned char iv[8]; + } CBC_PARAM; +*/ + +/* Password based encryption structure */ + +typedef struct PBEPARAM_st { +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; +} PBEPARAM; + +/* Password based encryption V2 structures */ + +typedef struct PBE2PARAM_st { +X509_ALGOR *keyfunc; +X509_ALGOR *encryption; +} PBE2PARAM; + +typedef struct PBKDF2PARAM_st { +ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ +ASN1_INTEGER *iter; +ASN1_INTEGER *keylength; +X509_ALGOR *prf; +} PBKDF2PARAM; + + +/* PKCS#8 private key info structure */ + +typedef struct pkcs8_priv_key_info_st + { + int broken; /* Flag for various broken formats */ +#define PKCS8_OK 0 +#define PKCS8_NO_OCTET 1 +#define PKCS8_EMBEDDED_PARAM 2 +#define PKCS8_NS_DB 3 + ASN1_INTEGER *version; + X509_ALGOR *pkeyalg; + ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ + STACK_OF(X509_ATTRIBUTE) *attributes; + } PKCS8_PRIV_KEY_INFO; + +#ifdef __cplusplus +} +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SSLEAY_MACROS +#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\ + a->signature,(char *)a->cert_info,r) +#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \ + a->sig_alg,a->signature,(char *)a->req_info,r) +#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \ + a->sig_alg, a->signature,(char *)a->crl,r) + +#define X509_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \ + x->sig_alg, x->signature, (char *)x->cert_info,pkey,md) +#define X509_REQ_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \ + x->signature, (char *)x->req_info,pkey,md) +#define X509_CRL_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \ + x->signature, (char *)x->crl,pkey,md) +#define NETSCAPE_SPKI_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \ + x->signature, (char *)x->spkac,pkey,md) + +#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \ + (char *(*)())d2i_X509,(char *)x509) +#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\ + (int (*)())i2d_X509_ATTRIBUTE, \ + (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa) +#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \ + (int (*)())i2d_X509_EXTENSION, \ + (char *(*)())d2i_X509_EXTENSION,(char *)ex) +#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)) +#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509) +#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) +#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) + +#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \ + (char *(*)())d2i_X509_CRL,(char *)crl) +#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\ + (unsigned char *)crl) +#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\ + (unsigned char *)crl) + +#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \ + (char *(*)())d2i_PKCS7,(char *)p7) +#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\ + (unsigned char *)p7) +#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\ + (unsigned char *)p7) + +#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \ + (char *(*)())d2i_X509_REQ,(char *)req) +#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\ + (unsigned char *)req) +#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\ + (unsigned char *)req) + +#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \ + (char *(*)())d2i_RSAPublicKey,(char *)rsa) +#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \ + (char *(*)())d2i_RSAPrivateKey,(char *)rsa) + +#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \ + (unsigned char *)rsa) + +#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \ + (unsigned char *)rsa) + +#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \ + (unsigned char *)dsa) +#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \ + (unsigned char *)dsa) + +#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \ + (unsigned char *)ecdsa) +#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \ + (unsigned char *)ecdsa) + +#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\ + (char *(*)())d2i_X509_ALGOR,(char *)xn) + +#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \ + (char *(*)())d2i_X509_NAME,(char *)xn) +#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \ + (int (*)())i2d_X509_NAME_ENTRY, \ + (char *(*)())d2i_X509_NAME_ENTRY,\ + (char *)ne) + +#define X509_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len) +#define X509_NAME_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len) +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +#define X509_EXT_PACK_UNKNOWN 1 +#define X509_EXT_PACK_STRING 2 + +#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) +/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ +#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) +#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) +#define X509_extract_key(x) X509_get_pubkey(x) /*****/ +#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) +#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) +#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) +#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) +#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) + +#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) +#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) +#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) +#define X509_CRL_get_issuer(x) ((x)->crl->issuer) +#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) + +/* This one is only used so that a binary form can output, as in + * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ +#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) + + +const char *X509_verify_cert_error_string(long n); + +#ifndef SSLEAY_MACROS +#ifndef OPENSSL_NO_EVP +int X509_verify(X509 *a, EVP_PKEY *r); + +int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); +int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); +int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); + +NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); +char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); +EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); +int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); + +int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); + +int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); + +int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); +int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); + +int X509_pubkey_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +#endif + +#ifndef OPENSSL_NO_FP_API +X509 *d2i_X509_fp(FILE *fp, X509 **x509); +int i2d_X509_fp(FILE *fp,X509 *x509); +X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); +int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); +int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); +int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); +int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); +DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); +int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); +int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); +int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); +int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); +int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); +int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); +#endif + +#ifndef OPENSSL_NO_BIO +X509 *d2i_X509_bio(BIO *bp,X509 **x509); +int i2d_X509_bio(BIO *bp,X509 *x509); +X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); +int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); +int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); +int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); +int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); +DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); +int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); +int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); +int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); +int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); +int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); +int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); +#endif + +X509 *X509_dup(X509 *x509); +X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); +X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); +X509_CRL *X509_CRL_dup(X509_CRL *crl); +X509_REQ *X509_REQ_dup(X509_REQ *req); +X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); +X509_NAME *X509_NAME_dup(X509_NAME *xn); +X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); + +#endif /* !SSLEAY_MACROS */ + +int X509_cmp_time(ASN1_TIME *s, time_t *t); +int X509_cmp_current_time(ASN1_TIME *s); +ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); +ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); + +const char * X509_get_default_cert_area(void ); +const char * X509_get_default_cert_dir(void ); +const char * X509_get_default_cert_file(void ); +const char * X509_get_default_cert_dir_env(void ); +const char * X509_get_default_cert_file_env(void ); +const char * X509_get_default_private_dir(void ); + +X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); + +DECLARE_ASN1_FUNCTIONS(X509_ALGOR) +DECLARE_ASN1_FUNCTIONS(X509_VAL) + +DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) + +int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); +EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); +int X509_get_pubkey_parameters(EVP_PKEY *pkey, + STACK_OF(X509) *chain); +int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp); +EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp, + long length); +#ifndef OPENSSL_NO_RSA +int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp); +RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_DSA +int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp); +DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_EC +int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); +EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, + long length); +#endif + +DECLARE_ASN1_FUNCTIONS(X509_SIG) +DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) +DECLARE_ASN1_FUNCTIONS(X509_REQ) + +DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) +X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); + +DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) + +DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) + +DECLARE_ASN1_FUNCTIONS(X509_NAME) + +int X509_NAME_set(X509_NAME **xn, X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(X509_CINF) + +DECLARE_ASN1_FUNCTIONS(X509) +DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) + +DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR) + +int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_set_ex_data(X509 *r, int idx, void *arg); +void *X509_get_ex_data(X509 *r, int idx); +int i2d_X509_AUX(X509 *a,unsigned char **pp); +X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); + +int X509_alias_set1(X509 *x, unsigned char *name, int len); +int X509_keyid_set1(X509 *x, unsigned char *id, int len); +unsigned char * X509_alias_get0(X509 *x, int *len); +unsigned char * X509_keyid_get0(X509 *x, int *len); +int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); +int X509_TRUST_set(int *t, int trust); +int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); +int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); +void X509_trust_clear(X509 *x); +void X509_reject_clear(X509 *x); + +DECLARE_ASN1_FUNCTIONS(X509_REVOKED) +DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) +DECLARE_ASN1_FUNCTIONS(X509_CRL) + +int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); + +X509_PKEY * X509_PKEY_new(void ); +void X509_PKEY_free(X509_PKEY *a); +int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); +X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) + +#ifndef OPENSSL_NO_EVP +X509_INFO * X509_INFO_new(void); +void X509_INFO_free(X509_INFO *a); +char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); + +int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); + +int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data, + unsigned char *md,unsigned int *len); + +int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + char *data,EVP_PKEY *pkey, const EVP_MD *type); + +int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, + unsigned char *md,unsigned int *len); + +int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey); + +int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, + void *data, EVP_PKEY *pkey, const EVP_MD *type); +#endif + +int X509_set_version(X509 *x,long version); +int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); +ASN1_INTEGER * X509_get_serialNumber(X509 *x); +int X509_set_issuer_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_issuer_name(X509 *a); +int X509_set_subject_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_subject_name(X509 *a); +int X509_set_notBefore(X509 *x, ASN1_TIME *tm); +int X509_set_notAfter(X509 *x, ASN1_TIME *tm); +int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); +EVP_PKEY * X509_get_pubkey(X509 *x); +ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); +int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); + +int X509_REQ_set_version(X509_REQ *x,long version); +int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); +int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); +EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); +int X509_REQ_extension_nid(int nid); +int * X509_REQ_get_extension_nids(void); +void X509_REQ_set_extension_nids(int *nids); +STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); +int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, + int nid); +int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); +int X509_REQ_get_attr_count(const X509_REQ *req); +int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, + int lastpos); +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); +X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); +int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); +int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_NID(X509_REQ *req, + int nid, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_txt(X509_REQ *req, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_CRL_set_version(X509_CRL *x, long version); +int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); +int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_sort(X509_CRL *crl); + +int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); +int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); + +int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); + +int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); + +int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_and_serial_hash(X509 *a); + +int X509_issuer_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_name_hash(X509 *a); + +int X509_subject_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_subject_name_hash(X509 *x); + +int X509_cmp(const X509 *a, const X509 *b); +int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); +unsigned long X509_NAME_hash(X509_NAME *x); + +int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); +#ifndef OPENSSL_NO_FP_API +int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print_fp(FILE *bp,X509 *x); +int X509_CRL_print_fp(FILE *bp,X509_CRL *x); +int X509_REQ_print_fp(FILE *bp,X509_REQ *req); +int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); +#endif + +#ifndef OPENSSL_NO_BIO +int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); +int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); +int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print(BIO *bp,X509 *x); +int X509_ocspid_print(BIO *bp,X509 *x); +int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); +int X509_CRL_print(BIO *bp,X509_CRL *x); +int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); +int X509_REQ_print(BIO *bp,X509_REQ *req); +#endif + +int X509_NAME_entry_count(X509_NAME *name); +int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, + char *buf,int len); +int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, + char *buf,int len); + +/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use + * lastpos, search after that position on. */ +int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); +int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, + int lastpos); +X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); +X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); +int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, + int loc, int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, + unsigned char *bytes, int len, int loc, int set); +int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, + unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, + const char *field, int type, const unsigned char *bytes, int len); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, + int type,unsigned char *bytes, int len); +int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, + const unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, + ASN1_OBJECT *obj, int type,const unsigned char *bytes, + int len); +int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, + ASN1_OBJECT *obj); +int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, + const unsigned char *bytes, int len); +ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); +ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); + +int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); +int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, + int nid, int lastpos); +int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, + ASN1_OBJECT *obj,int lastpos); +int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, + int crit, int lastpos); +X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); +X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); +STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, + X509_EXTENSION *ex, int loc); + +int X509_get_ext_count(X509 *x); +int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); +int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); +int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); +X509_EXTENSION *X509_get_ext(X509 *x, int loc); +X509_EXTENSION *X509_delete_ext(X509 *x, int loc); +int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); +void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); +int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_CRL_get_ext_count(X509_CRL *x); +int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); +int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); +int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); +X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); +X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); +int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); +void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_REVOKED_get_ext_count(X509_REVOKED *x); +int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); +int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); +int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); +X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); +X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); +int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); +void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, + unsigned long flags); + +X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, + int nid, int crit, ASN1_OCTET_STRING *data); +X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, + ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); +int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); +int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); +int X509_EXTENSION_set_data(X509_EXTENSION *ex, + ASN1_OCTET_STRING *data); +ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); +ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); +int X509_EXTENSION_get_critical(X509_EXTENSION *ex); + +int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); +int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, + int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); +X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, + X509_ATTRIBUTE *attr); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, + int nid, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, + const char *attrname, int type, + const unsigned char *bytes, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, + int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, + const ASN1_OBJECT *obj, int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, + const char *atrname, int type, const unsigned char *bytes, int len); +int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); +int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); +void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, + int atrtype, void *data); +int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); +ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); +ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); + +int EVP_PKEY_get_attr_count(const EVP_PKEY *key); +int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, + int lastpos); +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); +X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); +int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); +int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, + int nid, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_verify_cert(X509_STORE_CTX *ctx); + +/* lookup a cert from a X509 STACK */ +X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, + ASN1_INTEGER *serial); +X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(PBEPARAM) +DECLARE_ASN1_FUNCTIONS(PBE2PARAM) +DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) + +X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen); + +/* PKCS#8 utilities */ + +DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) + +EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); +PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); + +int X509_check_trust(X509 *x, int id, int flags); +int X509_TRUST_get_count(void); +X509_TRUST * X509_TRUST_get0(int idx); +int X509_TRUST_get_by_id(int id); +int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), + char *name, int arg1, void *arg2); +void X509_TRUST_cleanup(void); +int X509_TRUST_get_flags(X509_TRUST *xp); +char *X509_TRUST_get0_name(X509_TRUST *xp); +int X509_TRUST_get_trust(X509_TRUST *xp); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509_strings(void); + +/* Error codes for the X509 functions. */ + +/* Function codes. */ +#define X509_F_ADD_CERT_DIR 100 +#define X509_F_BY_FILE_CTRL 101 +#define X509_F_CHECK_POLICY 145 +#define X509_F_DIR_CTRL 102 +#define X509_F_GET_CERT_BY_SUBJECT 103 +#define X509_F_NETSCAPE_SPKI_B64_DECODE 129 +#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 +#define X509_F_X509AT_ADD1_ATTR 135 +#define X509_F_X509V3_ADD_EXT 104 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 +#define X509_F_X509_ATTRIBUTE_GET0_DATA 139 +#define X509_F_X509_ATTRIBUTE_SET1_DATA 138 +#define X509_F_X509_CHECK_PRIVATE_KEY 128 +#define X509_F_X509_CRL_PRINT_FP 147 +#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 +#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 +#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 +#define X509_F_X509_LOAD_CERT_CRL_FILE 132 +#define X509_F_X509_LOAD_CERT_FILE 111 +#define X509_F_X509_LOAD_CRL_FILE 112 +#define X509_F_X509_NAME_ADD_ENTRY 113 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 +#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 +#define X509_F_X509_NAME_ONELINE 116 +#define X509_F_X509_NAME_PRINT 117 +#define X509_F_X509_PRINT_EX_FP 118 +#define X509_F_X509_PUBKEY_GET 119 +#define X509_F_X509_PUBKEY_SET 120 +#define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 +#define X509_F_X509_REQ_PRINT_EX 121 +#define X509_F_X509_REQ_PRINT_FP 122 +#define X509_F_X509_REQ_TO_X509 123 +#define X509_F_X509_STORE_ADD_CERT 124 +#define X509_F_X509_STORE_ADD_CRL 125 +#define X509_F_X509_STORE_CTX_GET1_ISSUER 146 +#define X509_F_X509_STORE_CTX_INIT 143 +#define X509_F_X509_STORE_CTX_NEW 142 +#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 +#define X509_F_X509_TO_X509_REQ 126 +#define X509_F_X509_TRUST_ADD 133 +#define X509_F_X509_TRUST_SET 141 +#define X509_F_X509_VERIFY_CERT 127 + +/* Reason codes. */ +#define X509_R_BAD_X509_FILETYPE 100 +#define X509_R_BASE64_DECODE_ERROR 118 +#define X509_R_CANT_CHECK_DH_KEY 114 +#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +#define X509_R_ERR_ASN1_LIB 102 +#define X509_R_INVALID_DIRECTORY 113 +#define X509_R_INVALID_FIELD_NAME 119 +#define X509_R_INVALID_TRUST 123 +#define X509_R_KEY_TYPE_MISMATCH 115 +#define X509_R_KEY_VALUES_MISMATCH 116 +#define X509_R_LOADING_CERT_DIR 103 +#define X509_R_LOADING_DEFAULTS 104 +#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +#define X509_R_SHOULD_RETRY 106 +#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +#define X509_R_UNKNOWN_KEY_TYPE 117 +#define X509_R_UNKNOWN_NID 109 +#define X509_R_UNKNOWN_PURPOSE_ID 121 +#define X509_R_UNKNOWN_TRUST_ID 120 +#define X509_R_UNSUPPORTED_ALGORITHM 111 +#define X509_R_WRONG_LOOKUP_TYPE 112 +#define X509_R_WRONG_TYPE 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/include/openssl/x509_vfy.h b/libraries/external/openssl/linux/include/openssl/x509_vfy.h new file mode 100755 index 0000000..09c3191 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/x509_vfy.h @@ -0,0 +1,531 @@ +/* crypto/x509/x509_vfy.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_X509_H +#include +/* openssl/x509.h ends up #include-ing this file at about the only + * appropriate moment. */ +#endif + +#ifndef HEADER_X509_VFY_H +#define HEADER_X509_VFY_H + +#include +#ifndef OPENSSL_NO_LHASH +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Outer object */ +typedef struct x509_hash_dir_st + { + int num_dirs; + char **dirs; + int *dirs_type; + int num_dirs_alloced; + } X509_HASH_DIR_CTX; + +typedef struct x509_file_st + { + int num_paths; /* number of paths to files or directories */ + int num_alloced; + char **paths; /* the list of paths or directories */ + int *path_type; + } X509_CERT_FILE_CTX; + +/*******************************/ +/* +SSL_CTX -> X509_STORE + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + +SSL -> X509_STORE_CTX + ->X509_STORE + +The X509_STORE holds the tables etc for verification stuff. +A X509_STORE_CTX is used while validating a single certificate. +The X509_STORE has X509_LOOKUPs for looking up certs. +The X509_STORE then calls a function to actually verify the +certificate chain. +*/ + +#define X509_LU_RETRY -1 +#define X509_LU_FAIL 0 +#define X509_LU_X509 1 +#define X509_LU_CRL 2 +#define X509_LU_PKEY 3 + +typedef struct x509_object_st + { + /* one of the above types */ + int type; + union { + char *ptr; + X509 *x509; + X509_CRL *crl; + EVP_PKEY *pkey; + } data; + } X509_OBJECT; + +typedef struct x509_lookup_st X509_LOOKUP; + +DECLARE_STACK_OF(X509_LOOKUP) +DECLARE_STACK_OF(X509_OBJECT) + +/* This is a static that defines the function interface */ +typedef struct x509_lookup_method_st + { + const char *name; + int (*new_item)(X509_LOOKUP *ctx); + void (*free)(X509_LOOKUP *ctx); + int (*init)(X509_LOOKUP *ctx); + int (*shutdown)(X509_LOOKUP *ctx); + int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, + char **ret); + int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, + X509_OBJECT *ret); + int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, + ASN1_INTEGER *serial,X509_OBJECT *ret); + int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, + unsigned char *bytes,int len, + X509_OBJECT *ret); + int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, + X509_OBJECT *ret); + } X509_LOOKUP_METHOD; + +/* This structure hold all parameters associated with a verify operation + * by including an X509_VERIFY_PARAM structure in related structures the + * parameters used can be customized + */ + +typedef struct X509_VERIFY_PARAM_st + { + char *name; + time_t check_time; /* Time to use */ + unsigned long inh_flags; /* Inheritance flags */ + unsigned long flags; /* Various verify flags */ + int purpose; /* purpose to check untrusted certificates */ + int trust; /* trust setting to check */ + int depth; /* Verify depth */ + STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ + } X509_VERIFY_PARAM; + +DECLARE_STACK_OF(X509_VERIFY_PARAM) + +/* This is used to hold everything. It is used for all certificate + * validation. Once we have a certificate chain, the 'verify' + * function is then called to actually check the cert chain. */ +struct x509_store_st + { + /* The following is a cache of trusted certs */ + int cache; /* if true, stash any hits */ + STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ + + /* These are external lookup methods */ + STACK_OF(X509_LOOKUP) *get_cert_methods; + + X509_VERIFY_PARAM *param; + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*cleanup)(X509_STORE_CTX *ctx); + + CRYPTO_EX_DATA ex_data; + int references; + } /* X509_STORE */; + +int X509_STORE_set_depth(X509_STORE *store, int depth); + +#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) +#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) + +/* This is the functions plus an instance of the local variables. */ +struct x509_lookup_st + { + int init; /* have we been started */ + int skip; /* don't use us. */ + X509_LOOKUP_METHOD *method; /* the functions */ + char *method_data; /* method data */ + + X509_STORE *store_ctx; /* who owns us */ + } /* X509_LOOKUP */; + +/* This is a used when verifying cert chains. Since the + * gathering of the cert chain can take some time (and have to be + * 'retried', this needs to be kept and passed around. */ +struct x509_store_ctx_st /* X509_STORE_CTX */ + { + X509_STORE *ctx; + int current_method; /* used when looking up certs */ + + /* The following are set by the caller */ + X509 *cert; /* The cert to check */ + STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ + STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ + + X509_VERIFY_PARAM *param; + void *other_ctx; /* Other info for use with get_issuer() */ + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*check_policy)(X509_STORE_CTX *ctx); + int (*cleanup)(X509_STORE_CTX *ctx); + + /* The following is built up */ + int valid; /* if 0, rebuild chain */ + int last_untrusted; /* index of last untrusted cert */ + STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ + X509_POLICY_TREE *tree; /* Valid policy tree */ + + int explicit_policy; /* Require explicit policy value */ + + /* When something goes wrong, this is why */ + int error_depth; + int error; + X509 *current_cert; + X509 *current_issuer; /* cert currently being tested as valid issuer */ + X509_CRL *current_crl; /* current CRL */ + + CRYPTO_EX_DATA ex_data; + } /* X509_STORE_CTX */; + +void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); + +#define X509_STORE_CTX_set_app_data(ctx,data) \ + X509_STORE_CTX_set_ex_data(ctx,0,data) +#define X509_STORE_CTX_get_app_data(ctx) \ + X509_STORE_CTX_get_ex_data(ctx,0) + +#define X509_L_FILE_LOAD 1 +#define X509_L_ADD_DIR 2 + +#define X509_LOOKUP_load_file(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) + +#define X509_LOOKUP_add_dir(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) + +#define X509_V_OK 0 +/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ + +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 +#define X509_V_ERR_UNABLE_TO_GET_CRL 3 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 +#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 +#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 +#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 +#define X509_V_ERR_CERT_NOT_YET_VALID 9 +#define X509_V_ERR_CERT_HAS_EXPIRED 10 +#define X509_V_ERR_CRL_NOT_YET_VALID 11 +#define X509_V_ERR_CRL_HAS_EXPIRED 12 +#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 +#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 +#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 +#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 +#define X509_V_ERR_OUT_OF_MEM 17 +#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 +#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 +#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 +#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 +#define X509_V_ERR_CERT_REVOKED 23 +#define X509_V_ERR_INVALID_CA 24 +#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 +#define X509_V_ERR_INVALID_PURPOSE 26 +#define X509_V_ERR_CERT_UNTRUSTED 27 +#define X509_V_ERR_CERT_REJECTED 28 +/* These are 'informational' when looking for issuer cert */ +#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 +#define X509_V_ERR_AKID_SKID_MISMATCH 30 +#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 +#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 + +#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 +#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 +#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 +#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 +#define X509_V_ERR_INVALID_NON_CA 37 +#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 +#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 +#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 + +#define X509_V_ERR_INVALID_EXTENSION 41 +#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 +#define X509_V_ERR_NO_EXPLICIT_POLICY 43 + +#define X509_V_ERR_UNNESTED_RESOURCE 44 + +/* The application is not happy */ +#define X509_V_ERR_APPLICATION_VERIFICATION 50 + +/* Certificate verify flags */ + +/* Send issuer+subject checks to verify_cb */ +#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 +/* Use check time instead of current time */ +#define X509_V_FLAG_USE_CHECK_TIME 0x2 +/* Lookup CRLs */ +#define X509_V_FLAG_CRL_CHECK 0x4 +/* Lookup CRLs for whole chain */ +#define X509_V_FLAG_CRL_CHECK_ALL 0x8 +/* Ignore unhandled critical extensions */ +#define X509_V_FLAG_IGNORE_CRITICAL 0x10 +/* Disable workarounds for broken certificates */ +#define X509_V_FLAG_X509_STRICT 0x20 +/* Enable proxy certificate validation */ +#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 +/* Enable policy checking */ +#define X509_V_FLAG_POLICY_CHECK 0x80 +/* Policy variable require-explicit-policy */ +#define X509_V_FLAG_EXPLICIT_POLICY 0x100 +/* Policy variable inhibit-any-policy */ +#define X509_V_FLAG_INHIBIT_ANY 0x200 +/* Policy variable inhibit-policy-mapping */ +#define X509_V_FLAG_INHIBIT_MAP 0x400 +/* Notify callback that policy is OK */ +#define X509_V_FLAG_NOTIFY_POLICY 0x800 + +#define X509_VP_FLAG_DEFAULT 0x1 +#define X509_VP_FLAG_OVERWRITE 0x2 +#define X509_VP_FLAG_RESET_FLAGS 0x4 +#define X509_VP_FLAG_LOCKED 0x8 +#define X509_VP_FLAG_ONCE 0x10 + +/* Internal use: mask of policy related options */ +#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ + | X509_V_FLAG_EXPLICIT_POLICY \ + | X509_V_FLAG_INHIBIT_ANY \ + | X509_V_FLAG_INHIBIT_MAP) + +int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, + X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); +void X509_OBJECT_up_ref_count(X509_OBJECT *a); +void X509_OBJECT_free_contents(X509_OBJECT *a); +X509_STORE *X509_STORE_new(void ); +void X509_STORE_free(X509_STORE *v); + +int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); +int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); +int X509_STORE_set_trust(X509_STORE *ctx, int trust); +int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); + +X509_STORE_CTX *X509_STORE_CTX_new(void); + +int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + +void X509_STORE_CTX_free(X509_STORE_CTX *ctx); +int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, + X509 *x509, STACK_OF(X509) *chain); +void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); +void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); + +X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); + +X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); +X509_LOOKUP_METHOD *X509_LOOKUP_file(void); + +int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); +int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); + +int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name, + X509_OBJECT *ret); + +int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); + +#ifndef OPENSSL_NO_STDIO +int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); +#endif + + +X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); +void X509_LOOKUP_free(X509_LOOKUP *ctx); +int X509_LOOKUP_init(X509_LOOKUP *ctx); +int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, + X509_OBJECT *ret); +int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, + ASN1_INTEGER *serial, X509_OBJECT *ret); +int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, + unsigned char *bytes, int len, X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, + int len, X509_OBJECT *ret); +int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); + +#ifndef OPENSSL_NO_STDIO +int X509_STORE_load_locations (X509_STORE *ctx, + const char *file, const char *dir); +int X509_STORE_set_default_paths(X509_STORE *ctx); +#endif + +int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); +void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); +int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); +int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); +X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); +void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); +void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); +int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); +int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); +int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, + int purpose, int trust); +void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); +void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, + time_t t); +void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, + int (*verify_cb)(int, X509_STORE_CTX *)); + +X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); +int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); + +X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); +int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); + +/* X509_VERIFY_PARAM functions */ + +X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); +void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); +int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); +int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, + unsigned long flags); +unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); +int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); +void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); +void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); +int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, + ASN1_OBJECT *policy); +int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, + STACK_OF(ASN1_OBJECT) *policies); +int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); + +int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); +const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); +void X509_VERIFY_PARAM_table_cleanup(void); + +int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, + STACK_OF(X509) *certs, + STACK_OF(ASN1_OBJECT) *policy_oids, + unsigned int flags); + +void X509_policy_tree_free(X509_POLICY_TREE *tree); + +int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); +X509_POLICY_LEVEL * + X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); + +int X509_policy_level_node_count(X509_POLICY_LEVEL *level); + +X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); + +const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); + +STACK_OF(POLICYQUALINFO) * + X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); +const X509_POLICY_NODE * + X509_policy_node_get0_parent(const X509_POLICY_NODE *node); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/linux/include/openssl/x509v3.h b/libraries/external/openssl/linux/include/openssl/x509v3.h new file mode 100755 index 0000000..0a84264 --- /dev/null +++ b/libraries/external/openssl/linux/include/openssl/x509v3.h @@ -0,0 +1,919 @@ +/* x509v3.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_X509V3_H +#define HEADER_X509V3_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward reference */ +struct v3_ext_method; +struct v3_ext_ctx; + +/* Useful typedefs */ + +typedef void * (*X509V3_EXT_NEW)(void); +typedef void (*X509V3_EXT_FREE)(void *); +typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); +typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); +typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); +typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); +typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); +typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); +typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); +typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); + +/* V3 extension structure */ + +struct v3_ext_method { +int ext_nid; +int ext_flags; +/* If this is set the following four fields are ignored */ +ASN1_ITEM_EXP *it; +/* Old style ASN1 calls */ +X509V3_EXT_NEW ext_new; +X509V3_EXT_FREE ext_free; +X509V3_EXT_D2I d2i; +X509V3_EXT_I2D i2d; + +/* The following pair is used for string extensions */ +X509V3_EXT_I2S i2s; +X509V3_EXT_S2I s2i; + +/* The following pair is used for multi-valued extensions */ +X509V3_EXT_I2V i2v; +X509V3_EXT_V2I v2i; + +/* The following are used for raw extensions */ +X509V3_EXT_I2R i2r; +X509V3_EXT_R2I r2i; + +void *usr_data; /* Any extension specific data */ +}; + +typedef struct X509V3_CONF_METHOD_st { +char * (*get_string)(void *db, char *section, char *value); +STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); +void (*free_string)(void *db, char * string); +void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); +} X509V3_CONF_METHOD; + +/* Context specific info */ +struct v3_ext_ctx { +#define CTX_TEST 0x1 +int flags; +X509 *issuer_cert; +X509 *subject_cert; +X509_REQ *subject_req; +X509_CRL *crl; +X509V3_CONF_METHOD *db_meth; +void *db; +/* Maybe more here */ +}; + +typedef struct v3_ext_method X509V3_EXT_METHOD; + +DECLARE_STACK_OF(X509V3_EXT_METHOD) + +/* ext_flags values */ +#define X509V3_EXT_DYNAMIC 0x1 +#define X509V3_EXT_CTX_DEP 0x2 +#define X509V3_EXT_MULTILINE 0x4 + +typedef BIT_STRING_BITNAME ENUMERATED_NAMES; + +typedef struct BASIC_CONSTRAINTS_st { +int ca; +ASN1_INTEGER *pathlen; +} BASIC_CONSTRAINTS; + + +typedef struct PKEY_USAGE_PERIOD_st { +ASN1_GENERALIZEDTIME *notBefore; +ASN1_GENERALIZEDTIME *notAfter; +} PKEY_USAGE_PERIOD; + +typedef struct otherName_st { +ASN1_OBJECT *type_id; +ASN1_TYPE *value; +} OTHERNAME; + +typedef struct EDIPartyName_st { + ASN1_STRING *nameAssigner; + ASN1_STRING *partyName; +} EDIPARTYNAME; + +typedef struct GENERAL_NAME_st { + +#define GEN_OTHERNAME 0 +#define GEN_EMAIL 1 +#define GEN_DNS 2 +#define GEN_X400 3 +#define GEN_DIRNAME 4 +#define GEN_EDIPARTY 5 +#define GEN_URI 6 +#define GEN_IPADD 7 +#define GEN_RID 8 + +int type; +union { + char *ptr; + OTHERNAME *otherName; /* otherName */ + ASN1_IA5STRING *rfc822Name; + ASN1_IA5STRING *dNSName; + ASN1_TYPE *x400Address; + X509_NAME *directoryName; + EDIPARTYNAME *ediPartyName; + ASN1_IA5STRING *uniformResourceIdentifier; + ASN1_OCTET_STRING *iPAddress; + ASN1_OBJECT *registeredID; + + /* Old names */ + ASN1_OCTET_STRING *ip; /* iPAddress */ + X509_NAME *dirn; /* dirn */ + ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ + ASN1_OBJECT *rid; /* registeredID */ + ASN1_TYPE *other; /* x400Address */ +} d; +} GENERAL_NAME; + +typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; + +typedef struct ACCESS_DESCRIPTION_st { + ASN1_OBJECT *method; + GENERAL_NAME *location; +} ACCESS_DESCRIPTION; + +typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; + +typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; + +DECLARE_STACK_OF(GENERAL_NAME) +DECLARE_ASN1_SET_OF(GENERAL_NAME) + +DECLARE_STACK_OF(ACCESS_DESCRIPTION) +DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) + +typedef struct DIST_POINT_NAME_st { +int type; +union { + GENERAL_NAMES *fullname; + STACK_OF(X509_NAME_ENTRY) *relativename; +} name; +} DIST_POINT_NAME; + +typedef struct DIST_POINT_st { +DIST_POINT_NAME *distpoint; +ASN1_BIT_STRING *reasons; +GENERAL_NAMES *CRLissuer; +} DIST_POINT; + +typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; + +DECLARE_STACK_OF(DIST_POINT) +DECLARE_ASN1_SET_OF(DIST_POINT) + +typedef struct AUTHORITY_KEYID_st { +ASN1_OCTET_STRING *keyid; +GENERAL_NAMES *issuer; +ASN1_INTEGER *serial; +} AUTHORITY_KEYID; + +/* Strong extranet structures */ + +typedef struct SXNET_ID_st { + ASN1_INTEGER *zone; + ASN1_OCTET_STRING *user; +} SXNETID; + +DECLARE_STACK_OF(SXNETID) +DECLARE_ASN1_SET_OF(SXNETID) + +typedef struct SXNET_st { + ASN1_INTEGER *version; + STACK_OF(SXNETID) *ids; +} SXNET; + +typedef struct NOTICEREF_st { + ASN1_STRING *organization; + STACK_OF(ASN1_INTEGER) *noticenos; +} NOTICEREF; + +typedef struct USERNOTICE_st { + NOTICEREF *noticeref; + ASN1_STRING *exptext; +} USERNOTICE; + +typedef struct POLICYQUALINFO_st { + ASN1_OBJECT *pqualid; + union { + ASN1_IA5STRING *cpsuri; + USERNOTICE *usernotice; + ASN1_TYPE *other; + } d; +} POLICYQUALINFO; + +DECLARE_STACK_OF(POLICYQUALINFO) +DECLARE_ASN1_SET_OF(POLICYQUALINFO) + +typedef struct POLICYINFO_st { + ASN1_OBJECT *policyid; + STACK_OF(POLICYQUALINFO) *qualifiers; +} POLICYINFO; + +typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; + +DECLARE_STACK_OF(POLICYINFO) +DECLARE_ASN1_SET_OF(POLICYINFO) + +typedef struct POLICY_MAPPING_st { + ASN1_OBJECT *issuerDomainPolicy; + ASN1_OBJECT *subjectDomainPolicy; +} POLICY_MAPPING; + +DECLARE_STACK_OF(POLICY_MAPPING) + +typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; + +typedef struct GENERAL_SUBTREE_st { + GENERAL_NAME *base; + ASN1_INTEGER *minimum; + ASN1_INTEGER *maximum; +} GENERAL_SUBTREE; + +DECLARE_STACK_OF(GENERAL_SUBTREE) + +typedef struct NAME_CONSTRAINTS_st { + STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; + STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; +} NAME_CONSTRAINTS; + +typedef struct POLICY_CONSTRAINTS_st { + ASN1_INTEGER *requireExplicitPolicy; + ASN1_INTEGER *inhibitPolicyMapping; +} POLICY_CONSTRAINTS; + +/* Proxy certificate structures, see RFC 3820 */ +typedef struct PROXY_POLICY_st + { + ASN1_OBJECT *policyLanguage; + ASN1_OCTET_STRING *policy; + } PROXY_POLICY; + +typedef struct PROXY_CERT_INFO_EXTENSION_st + { + ASN1_INTEGER *pcPathLengthConstraint; + PROXY_POLICY *proxyPolicy; + } PROXY_CERT_INFO_EXTENSION; + +DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) +DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) + + +#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ +",name:", val->name, ",value:", val->value); + +#define X509V3_set_ctx_test(ctx) \ + X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) +#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; + +#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ + 0,0,0,0, \ + 0,0, \ + (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ + (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ + NULL, NULL, \ + table} + +#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ + 0,0,0,0, \ + (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ + 0,0,0,0, \ + NULL} + +#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + + +/* X509_PURPOSE stuff */ + +#define EXFLAG_BCONS 0x1 +#define EXFLAG_KUSAGE 0x2 +#define EXFLAG_XKUSAGE 0x4 +#define EXFLAG_NSCERT 0x8 + +#define EXFLAG_CA 0x10 +#define EXFLAG_SS 0x20 +#define EXFLAG_V1 0x40 +#define EXFLAG_INVALID 0x80 +#define EXFLAG_SET 0x100 +#define EXFLAG_CRITICAL 0x200 +#define EXFLAG_PROXY 0x400 + +#define EXFLAG_INVALID_POLICY 0x400 + +#define KU_DIGITAL_SIGNATURE 0x0080 +#define KU_NON_REPUDIATION 0x0040 +#define KU_KEY_ENCIPHERMENT 0x0020 +#define KU_DATA_ENCIPHERMENT 0x0010 +#define KU_KEY_AGREEMENT 0x0008 +#define KU_KEY_CERT_SIGN 0x0004 +#define KU_CRL_SIGN 0x0002 +#define KU_ENCIPHER_ONLY 0x0001 +#define KU_DECIPHER_ONLY 0x8000 + +#define NS_SSL_CLIENT 0x80 +#define NS_SSL_SERVER 0x40 +#define NS_SMIME 0x20 +#define NS_OBJSIGN 0x10 +#define NS_SSL_CA 0x04 +#define NS_SMIME_CA 0x02 +#define NS_OBJSIGN_CA 0x01 +#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) + +#define XKU_SSL_SERVER 0x1 +#define XKU_SSL_CLIENT 0x2 +#define XKU_SMIME 0x4 +#define XKU_CODE_SIGN 0x8 +#define XKU_SGC 0x10 +#define XKU_OCSP_SIGN 0x20 +#define XKU_TIMESTAMP 0x40 +#define XKU_DVCS 0x80 + +#define X509_PURPOSE_DYNAMIC 0x1 +#define X509_PURPOSE_DYNAMIC_NAME 0x2 + +typedef struct x509_purpose_st { + int purpose; + int trust; /* Default trust ID */ + int flags; + int (*check_purpose)(const struct x509_purpose_st *, + const X509 *, int); + char *name; + char *sname; + void *usr_data; +} X509_PURPOSE; + +#define X509_PURPOSE_SSL_CLIENT 1 +#define X509_PURPOSE_SSL_SERVER 2 +#define X509_PURPOSE_NS_SSL_SERVER 3 +#define X509_PURPOSE_SMIME_SIGN 4 +#define X509_PURPOSE_SMIME_ENCRYPT 5 +#define X509_PURPOSE_CRL_SIGN 6 +#define X509_PURPOSE_ANY 7 +#define X509_PURPOSE_OCSP_HELPER 8 + +#define X509_PURPOSE_MIN 1 +#define X509_PURPOSE_MAX 8 + +/* Flags for X509V3_EXT_print() */ + +#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) +/* Return error for unknown extensions */ +#define X509V3_EXT_DEFAULT 0 +/* Print error for unknown extensions */ +#define X509V3_EXT_ERROR_UNKNOWN (1L << 16) +/* ASN1 parse unknown extensions */ +#define X509V3_EXT_PARSE_UNKNOWN (2L << 16) +/* BIO_dump unknown extensions */ +#define X509V3_EXT_DUMP_UNKNOWN (3L << 16) + +/* Flags for X509V3_add1_i2d */ + +#define X509V3_ADD_OP_MASK 0xfL +#define X509V3_ADD_DEFAULT 0L +#define X509V3_ADD_APPEND 1L +#define X509V3_ADD_REPLACE 2L +#define X509V3_ADD_REPLACE_EXISTING 3L +#define X509V3_ADD_KEEP_EXISTING 4L +#define X509V3_ADD_DELETE 5L +#define X509V3_ADD_SILENT 0x10 + +DECLARE_STACK_OF(X509_PURPOSE) + +DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) + +DECLARE_ASN1_FUNCTIONS(SXNET) +DECLARE_ASN1_FUNCTIONS(SXNETID) + +int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); + +ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); +ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); +ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); + +DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) + +DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) + + +ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); +STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + ASN1_BIT_STRING *bits, + STACK_OF(CONF_VALUE) *extlist); + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); +int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, + GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); +GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); + +DECLARE_ASN1_FUNCTIONS(OTHERNAME) +DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) + +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); + +DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) +int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); + +DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) +DECLARE_ASN1_FUNCTIONS(POLICYINFO) +DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) +DECLARE_ASN1_FUNCTIONS(USERNOTICE) +DECLARE_ASN1_FUNCTIONS(NOTICEREF) + +DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) +DECLARE_ASN1_FUNCTIONS(DIST_POINT) +DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) + +DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) +DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) + +DECLARE_ASN1_ITEM(POLICY_MAPPING) +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) +DECLARE_ASN1_ITEM(POLICY_MAPPINGS) + +DECLARE_ASN1_ITEM(GENERAL_SUBTREE) +DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) + +DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) +DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) +DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) + +#ifdef HEADER_CONF_H +GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + CONF_VALUE *cnf); +GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); +void X509V3_conf_free(CONF_VALUE *val); + +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +int X509V3_add_value_bool_nf(char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); +int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); +void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); +void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); +#endif + +char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); +STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); +void X509V3_string_free(X509V3_CTX *ctx, char *str); +void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); +void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, + X509_REQ *req, X509_CRL *crl, int flags); + +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_uchar(const char *name, const unsigned char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_bool(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, + STACK_OF(CONF_VALUE) **extlist); +char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); +ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); +char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +int X509V3_EXT_add(X509V3_EXT_METHOD *ext); +int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); +int X509V3_EXT_add_alias(int nid_to, int nid_from); +void X509V3_EXT_cleanup(void); + +X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); +X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); +int X509V3_add_standard_extensions(void); +STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); +void *X509V3_EXT_d2i(X509_EXTENSION *ext); +void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); + + +X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); +int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); + +char *hex_to_string(unsigned char *buffer, long len); +unsigned char *string_to_hex(char *str, long *len); +int name_cmp(const char *name, const char *cmp); + +void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, + int ml); +int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); +int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); + +int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); + +int X509_check_ca(X509 *x); +int X509_check_purpose(X509 *x, int id, int ca); +int X509_supported_extension(X509_EXTENSION *ex); +int X509_PURPOSE_set(int *p, int purpose); +int X509_check_issued(X509 *issuer, X509 *subject); +int X509_PURPOSE_get_count(void); +X509_PURPOSE * X509_PURPOSE_get0(int idx); +int X509_PURPOSE_get_by_sname(char *sname); +int X509_PURPOSE_get_by_id(int id); +int X509_PURPOSE_add(int id, int trust, int flags, + int (*ck)(const X509_PURPOSE *, const X509 *, int), + char *name, char *sname, void *arg); +char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); +char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); +int X509_PURPOSE_get_trust(X509_PURPOSE *xp); +void X509_PURPOSE_cleanup(void); +int X509_PURPOSE_get_id(X509_PURPOSE *); + +STACK *X509_get1_email(X509 *x); +STACK *X509_REQ_get1_email(X509_REQ *x); +void X509_email_free(STACK *sk); + +ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); +ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); +int a2i_ipadd(unsigned char *ipout, const char *ipasc); +int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, + unsigned long chtype); + +void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); + +#ifndef OPENSSL_NO_RFC3779 + +typedef struct ASRange_st { + ASN1_INTEGER *min, *max; +} ASRange; + +#define ASIdOrRange_id 0 +#define ASIdOrRange_range 1 + +typedef struct ASIdOrRange_st { + int type; + union { + ASN1_INTEGER *id; + ASRange *range; + } u; +} ASIdOrRange; + +typedef STACK_OF(ASIdOrRange) ASIdOrRanges; +DECLARE_STACK_OF(ASIdOrRange) + +#define ASIdentifierChoice_inherit 0 +#define ASIdentifierChoice_asIdsOrRanges 1 + +typedef struct ASIdentifierChoice_st { + int type; + union { + ASN1_NULL *inherit; + ASIdOrRanges *asIdsOrRanges; + } u; +} ASIdentifierChoice; + +typedef struct ASIdentifiers_st { + ASIdentifierChoice *asnum, *rdi; +} ASIdentifiers; + +DECLARE_ASN1_FUNCTIONS(ASRange) +DECLARE_ASN1_FUNCTIONS(ASIdOrRange) +DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) +DECLARE_ASN1_FUNCTIONS(ASIdentifiers) + + +typedef struct IPAddressRange_st { + ASN1_BIT_STRING *min, *max; +} IPAddressRange; + +#define IPAddressOrRange_addressPrefix 0 +#define IPAddressOrRange_addressRange 1 + +typedef struct IPAddressOrRange_st { + int type; + union { + ASN1_BIT_STRING *addressPrefix; + IPAddressRange *addressRange; + } u; +} IPAddressOrRange; + +typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; +DECLARE_STACK_OF(IPAddressOrRange) + +#define IPAddressChoice_inherit 0 +#define IPAddressChoice_addressesOrRanges 1 + +typedef struct IPAddressChoice_st { + int type; + union { + ASN1_NULL *inherit; + IPAddressOrRanges *addressesOrRanges; + } u; +} IPAddressChoice; + +typedef struct IPAddressFamily_st { + ASN1_OCTET_STRING *addressFamily; + IPAddressChoice *ipAddressChoice; +} IPAddressFamily; + +typedef STACK_OF(IPAddressFamily) IPAddrBlocks; +DECLARE_STACK_OF(IPAddressFamily) + +DECLARE_ASN1_FUNCTIONS(IPAddressRange) +DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) +DECLARE_ASN1_FUNCTIONS(IPAddressChoice) +DECLARE_ASN1_FUNCTIONS(IPAddressFamily) + +/* + * API tag for elements of the ASIdentifer SEQUENCE. + */ +#define V3_ASID_ASNUM 0 +#define V3_ASID_RDI 1 + +/* + * AFI values, assigned by IANA. It'd be nice to make the AFI + * handling code totally generic, but there are too many little things + * that would need to be defined for other address families for it to + * be worth the trouble. + */ +#define IANA_AFI_IPV4 1 +#define IANA_AFI_IPV6 2 + +/* + * Utilities to construct and extract values from RFC3779 extensions, + * since some of the encodings (particularly for IP address prefixes + * and ranges) are a bit tedious to work with directly. + */ +int v3_asid_add_inherit(ASIdentifiers *asid, int which); +int v3_asid_add_id_or_range(ASIdentifiers *asid, int which, + ASN1_INTEGER *min, ASN1_INTEGER *max); +int v3_addr_add_inherit(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi); +int v3_addr_add_prefix(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *a, const int prefixlen); +int v3_addr_add_range(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *min, unsigned char *max); +unsigned v3_addr_get_afi(const IPAddressFamily *f); +int v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, + unsigned char *min, unsigned char *max, + const int length); + +/* + * Canonical forms. + */ +int v3_asid_is_canonical(ASIdentifiers *asid); +int v3_addr_is_canonical(IPAddrBlocks *addr); +int v3_asid_canonize(ASIdentifiers *asid); +int v3_addr_canonize(IPAddrBlocks *addr); + +/* + * Tests for inheritance and containment. + */ +int v3_asid_inherits(ASIdentifiers *asid); +int v3_addr_inherits(IPAddrBlocks *addr); +int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); +int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); + +/* + * Check whether RFC 3779 extensions nest properly in chains. + */ +int v3_asid_validate_path(X509_STORE_CTX *); +int v3_addr_validate_path(X509_STORE_CTX *); +int v3_asid_validate_resource_set(STACK_OF(X509) *chain, + ASIdentifiers *ext, + int allow_inheritance); +int v3_addr_validate_resource_set(STACK_OF(X509) *chain, + IPAddrBlocks *ext, + int allow_inheritance); + +#endif /* OPENSSL_NO_RFC3779 */ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509V3_strings(void); + +/* Error codes for the X509V3 functions. */ + +/* Function codes. */ +#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 156 +#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 157 +#define X509V3_F_COPY_EMAIL 122 +#define X509V3_F_COPY_ISSUER 123 +#define X509V3_F_DO_DIRNAME 144 +#define X509V3_F_DO_EXT_CONF 124 +#define X509V3_F_DO_EXT_I2D 135 +#define X509V3_F_DO_EXT_NCONF 151 +#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148 +#define X509V3_F_HEX_TO_STRING 111 +#define X509V3_F_I2S_ASN1_ENUMERATED 121 +#define X509V3_F_I2S_ASN1_IA5STRING 149 +#define X509V3_F_I2S_ASN1_INTEGER 120 +#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 +#define X509V3_F_NOTICE_SECTION 132 +#define X509V3_F_NREF_NOS 133 +#define X509V3_F_POLICY_SECTION 131 +#define X509V3_F_PROCESS_PCI_VALUE 150 +#define X509V3_F_R2I_CERTPOL 130 +#define X509V3_F_R2I_PCI 155 +#define X509V3_F_S2I_ASN1_IA5STRING 100 +#define X509V3_F_S2I_ASN1_INTEGER 108 +#define X509V3_F_S2I_ASN1_OCTET_STRING 112 +#define X509V3_F_S2I_ASN1_SKEY_ID 114 +#define X509V3_F_S2I_SKEY_ID 115 +#define X509V3_F_STRING_TO_HEX 113 +#define X509V3_F_SXNET_ADD_ID_ASC 125 +#define X509V3_F_SXNET_ADD_ID_INTEGER 126 +#define X509V3_F_SXNET_ADD_ID_ULONG 127 +#define X509V3_F_SXNET_GET_ID_ASC 128 +#define X509V3_F_SXNET_GET_ID_ULONG 129 +#define X509V3_F_V2I_ASIDENTIFIERS 158 +#define X509V3_F_V2I_ASN1_BIT_STRING 101 +#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 +#define X509V3_F_V2I_AUTHORITY_KEYID 119 +#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 +#define X509V3_F_V2I_CRLD 134 +#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 +#define X509V3_F_V2I_GENERAL_NAMES 118 +#define X509V3_F_V2I_GENERAL_NAME_EX 117 +#define X509V3_F_V2I_IPADDRBLOCKS 159 +#define X509V3_F_V2I_ISSUER_ALT 153 +#define X509V3_F_V2I_NAME_CONSTRAINTS 147 +#define X509V3_F_V2I_POLICY_CONSTRAINTS 146 +#define X509V3_F_V2I_POLICY_MAPPINGS 145 +#define X509V3_F_V2I_SUBJECT_ALT 154 +#define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL 160 +#define X509V3_F_V3_GENERIC_EXTENSION 116 +#define X509V3_F_X509V3_ADD1_I2D 140 +#define X509V3_F_X509V3_ADD_VALUE 105 +#define X509V3_F_X509V3_EXT_ADD 104 +#define X509V3_F_X509V3_EXT_ADD_ALIAS 106 +#define X509V3_F_X509V3_EXT_CONF 107 +#define X509V3_F_X509V3_EXT_I2D 136 +#define X509V3_F_X509V3_EXT_NCONF 152 +#define X509V3_F_X509V3_GET_SECTION 142 +#define X509V3_F_X509V3_GET_STRING 143 +#define X509V3_F_X509V3_GET_VALUE_BOOL 110 +#define X509V3_F_X509V3_PARSE_LIST 109 +#define X509V3_F_X509_PURPOSE_ADD 137 +#define X509V3_F_X509_PURPOSE_SET 141 + +/* Reason codes. */ +#define X509V3_R_BAD_IP_ADDRESS 118 +#define X509V3_R_BAD_OBJECT 119 +#define X509V3_R_BN_DEC2BN_ERROR 100 +#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 +#define X509V3_R_DIRNAME_ERROR 149 +#define X509V3_R_DUPLICATE_ZONE_ID 133 +#define X509V3_R_ERROR_CONVERTING_ZONE 131 +#define X509V3_R_ERROR_CREATING_EXTENSION 144 +#define X509V3_R_ERROR_IN_EXTENSION 128 +#define X509V3_R_EXPECTED_A_SECTION_NAME 137 +#define X509V3_R_EXTENSION_EXISTS 145 +#define X509V3_R_EXTENSION_NAME_ERROR 115 +#define X509V3_R_EXTENSION_NOT_FOUND 102 +#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 +#define X509V3_R_EXTENSION_VALUE_ERROR 116 +#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 +#define X509V3_R_ILLEGAL_HEX_DIGIT 113 +#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 +#define X509V3_R_INVALID_ASNUMBER 160 +#define X509V3_R_INVALID_ASRANGE 161 +#define X509V3_R_INVALID_BOOLEAN_STRING 104 +#define X509V3_R_INVALID_EXTENSION_STRING 105 +#define X509V3_R_INVALID_INHERITANCE 162 +#define X509V3_R_INVALID_IPADDRESS 163 +#define X509V3_R_INVALID_NAME 106 +#define X509V3_R_INVALID_NULL_ARGUMENT 107 +#define X509V3_R_INVALID_NULL_NAME 108 +#define X509V3_R_INVALID_NULL_VALUE 109 +#define X509V3_R_INVALID_NUMBER 140 +#define X509V3_R_INVALID_NUMBERS 141 +#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 +#define X509V3_R_INVALID_OPTION 138 +#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 +#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 +#define X509V3_R_INVALID_PURPOSE 146 +#define X509V3_R_INVALID_SAFI 164 +#define X509V3_R_INVALID_SECTION 135 +#define X509V3_R_INVALID_SYNTAX 143 +#define X509V3_R_ISSUER_DECODE_ERROR 126 +#define X509V3_R_MISSING_VALUE 124 +#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 +#define X509V3_R_NO_CONFIG_DATABASE 136 +#define X509V3_R_NO_ISSUER_CERTIFICATE 121 +#define X509V3_R_NO_ISSUER_DETAILS 127 +#define X509V3_R_NO_POLICY_IDENTIFIER 139 +#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 +#define X509V3_R_NO_PUBLIC_KEY 114 +#define X509V3_R_NO_SUBJECT_DETAILS 125 +#define X509V3_R_ODD_NUMBER_OF_DIGITS 112 +#define X509V3_R_OPERATION_NOT_DEFINED 148 +#define X509V3_R_OTHERNAME_ERROR 147 +#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155 +#define X509V3_R_POLICY_PATH_LENGTH 156 +#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157 +#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158 +#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 +#define X509V3_R_SECTION_NOT_FOUND 150 +#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 +#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 +#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 +#define X509V3_R_UNKNOWN_EXTENSION 129 +#define X509V3_R_UNKNOWN_EXTENSION_NAME 130 +#define X509V3_R_UNKNOWN_OPTION 120 +#define X509V3_R_UNSUPPORTED_OPTION 117 +#define X509V3_R_USER_TOO_LONG 132 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/linux/lib/libcrypto.a b/libraries/external/openssl/linux/lib/libcrypto.a new file mode 100755 index 0000000..21c6742 Binary files /dev/null and b/libraries/external/openssl/linux/lib/libcrypto.a differ diff --git a/libraries/external/openssl/linux/lib/libssl.a b/libraries/external/openssl/linux/lib/libssl.a new file mode 100755 index 0000000..2c8cf64 Binary files /dev/null and b/libraries/external/openssl/linux/lib/libssl.a differ diff --git a/libraries/external/openssl/linux/lib/vssver.scc b/libraries/external/openssl/linux/lib/vssver.scc new file mode 100755 index 0000000..a6c9373 Binary files /dev/null and b/libraries/external/openssl/linux/lib/vssver.scc differ diff --git a/libraries/external/openssl/nasm-0.98.39-win32.zip b/libraries/external/openssl/nasm-0.98.39-win32.zip new file mode 100755 index 0000000..3754989 Binary files /dev/null and b/libraries/external/openssl/nasm-0.98.39-win32.zip differ diff --git a/libraries/external/openssl/openssl-0.9.8e.tar.gz b/libraries/external/openssl/openssl-0.9.8e.tar.gz new file mode 100755 index 0000000..b8446d1 --- /dev/null +++ b/libraries/external/openssl/openssl-0.9.8e.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:414e8428b95fbc51707965fda31390497d058290356426bfe084b49464a60340 +size 3341665 diff --git a/libraries/external/openssl/pc/bin/libeay32.dll b/libraries/external/openssl/pc/bin/libeay32.dll new file mode 100755 index 0000000..3d3fef8 Binary files /dev/null and b/libraries/external/openssl/pc/bin/libeay32.dll differ diff --git a/libraries/external/openssl/pc/bin/openssl.exe b/libraries/external/openssl/pc/bin/openssl.exe new file mode 100755 index 0000000..8f519e1 Binary files /dev/null and b/libraries/external/openssl/pc/bin/openssl.exe differ diff --git a/libraries/external/openssl/pc/bin/ssleay32.dll b/libraries/external/openssl/pc/bin/ssleay32.dll new file mode 100755 index 0000000..0ab2762 Binary files /dev/null and b/libraries/external/openssl/pc/bin/ssleay32.dll differ diff --git a/libraries/external/openssl/pc/bin/vssver.scc b/libraries/external/openssl/pc/bin/vssver.scc new file mode 100755 index 0000000..0344628 Binary files /dev/null and b/libraries/external/openssl/pc/bin/vssver.scc differ diff --git a/libraries/external/openssl/pc/include/openssl/aes.h b/libraries/external/openssl/pc/include/openssl/aes.h new file mode 100755 index 0000000..015a1e4 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/aes.h @@ -0,0 +1,138 @@ +/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + */ + +#ifndef HEADER_AES_H +#define HEADER_AES_H + +#include + +#ifdef OPENSSL_NO_AES +#error AES is disabled. +#endif + +#define AES_ENCRYPT 1 +#define AES_DECRYPT 0 + +/* Because array size can't be a const in C, the following two are macros. + Both sizes are in bytes. */ +#define AES_MAXNR 14 +#define AES_BLOCK_SIZE 16 + +#ifdef __cplusplus +extern "C" { +#endif + +/* This should be a hidden type, but EVP requires that the size be known */ +struct aes_key_st { +#ifdef AES_LONG + unsigned long rd_key[4 *(AES_MAXNR + 1)]; +#else + unsigned int rd_key[4 *(AES_MAXNR + 1)]; +#endif + int rounds; +}; +typedef struct aes_key_st AES_KEY; + +const char *AES_options(void); + +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); + +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); + +void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key, const int enc); +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num, const int enc); +void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out, + const int nbits,const AES_KEY *key, + unsigned char *ivec,const int enc); +void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, int *num); +void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char ivec[AES_BLOCK_SIZE], + unsigned char ecount_buf[AES_BLOCK_SIZE], + unsigned int *num); + +/* For IGE, see also http://www.links.org/files/openssl-ige.pdf */ +/* NB: the IV is _two_ blocks long */ +void AES_ige_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + unsigned char *ivec, const int enc); +/* NB: the IV is _four_ blocks long */ +void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, + const unsigned long length, const AES_KEY *key, + const AES_KEY *key2, const unsigned char *ivec, + const int enc); + + +#ifdef __cplusplus +} +#endif + +#endif /* !HEADER_AES_H */ diff --git a/libraries/external/openssl/pc/include/openssl/applink.c b/libraries/external/openssl/pc/include/openssl/applink.c new file mode 100755 index 0000000..7789bd9 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/applink.c @@ -0,0 +1,94 @@ +#define APPLINK_STDIN 1 +#define APPLINK_STDOUT 2 +#define APPLINK_STDERR 3 +#define APPLINK_FPRINTF 4 +#define APPLINK_FGETS 5 +#define APPLINK_FREAD 6 +#define APPLINK_FWRITE 7 +#define APPLINK_FSETMOD 8 +#define APPLINK_FEOF 9 +#define APPLINK_FCLOSE 10 /* should not be used */ + +#define APPLINK_FOPEN 11 /* solely for completeness */ +#define APPLINK_FSEEK 12 +#define APPLINK_FTELL 13 +#define APPLINK_FFLUSH 14 +#define APPLINK_FERROR 15 +#define APPLINK_CLEARERR 16 +#define APPLINK_FILENO 17 /* to be used with below */ + +#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */ +#define APPLINK_READ 19 +#define APPLINK_WRITE 20 +#define APPLINK_LSEEK 21 +#define APPLINK_CLOSE 22 +#define APPLINK_MAX 22 /* always same as last macro */ + +#ifndef APPMACROS_ONLY +#include +#include +#include + +static void *app_stdin(void) { return stdin; } +static void *app_stdout(void) { return stdout; } +static void *app_stderr(void) { return stderr; } +static int app_feof(FILE *fp) { return feof(fp); } +static int app_ferror(FILE *fp) { return ferror(fp); } +static void app_clearerr(FILE *fp) { clearerr(fp); } +static int app_fileno(FILE *fp) { return _fileno(fp); } +static int app_fsetmod(FILE *fp,char mod) +{ return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); } + +#ifdef __cplusplus +extern "C" { +#endif + +__declspec(dllexport) +void ** +#if defined(__BORLANDC__) +__stdcall /* __stdcall appears to be the only way to get the name + * decoration right with Borland C. Otherwise it works + * purely incidentally, as we pass no parameters. */ +#else +__cdecl +#endif +OPENSSL_Applink(void) +{ static int once=1; + static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX}; + + if (once) + { OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; + OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; + OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; + OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; + OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; + OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; + OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; + OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; + OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; + OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; + + OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; + OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; + OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; + OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; + OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; + OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; + OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; + + OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; + OPENSSL_ApplinkTable[APPLINK_READ] = _read; + OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; + OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; + OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; + + once = 0; + } + + return OPENSSL_ApplinkTable; +} + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/asn1.h b/libraries/external/openssl/pc/include/openssl/asn1.h new file mode 100755 index 0000000..8671b80 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/asn1.h @@ -0,0 +1,1233 @@ +/* crypto/asn1/asn1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_H +#define HEADER_ASN1_H + +#include +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#include + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define V_ASN1_UNIVERSAL 0x00 +#define V_ASN1_APPLICATION 0x40 +#define V_ASN1_CONTEXT_SPECIFIC 0x80 +#define V_ASN1_PRIVATE 0xc0 + +#define V_ASN1_CONSTRUCTED 0x20 +#define V_ASN1_PRIMITIVE_TAG 0x1f +#define V_ASN1_PRIMATIVE_TAG 0x1f + +#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ +#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +#define V_ASN1_ANY -4 /* used in ASN1 template code */ + +#define V_ASN1_NEG 0x100 /* negative flag */ + +#define V_ASN1_UNDEF -1 +#define V_ASN1_EOC 0 +#define V_ASN1_BOOLEAN 1 /**/ +#define V_ASN1_INTEGER 2 +#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) +#define V_ASN1_BIT_STRING 3 +#define V_ASN1_OCTET_STRING 4 +#define V_ASN1_NULL 5 +#define V_ASN1_OBJECT 6 +#define V_ASN1_OBJECT_DESCRIPTOR 7 +#define V_ASN1_EXTERNAL 8 +#define V_ASN1_REAL 9 +#define V_ASN1_ENUMERATED 10 +#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) +#define V_ASN1_UTF8STRING 12 +#define V_ASN1_SEQUENCE 16 +#define V_ASN1_SET 17 +#define V_ASN1_NUMERICSTRING 18 /**/ +#define V_ASN1_PRINTABLESTRING 19 +#define V_ASN1_T61STRING 20 +#define V_ASN1_TELETEXSTRING 20 /* alias */ +#define V_ASN1_VIDEOTEXSTRING 21 /**/ +#define V_ASN1_IA5STRING 22 +#define V_ASN1_UTCTIME 23 +#define V_ASN1_GENERALIZEDTIME 24 /**/ +#define V_ASN1_GRAPHICSTRING 25 /**/ +#define V_ASN1_ISO64STRING 26 /**/ +#define V_ASN1_VISIBLESTRING 26 /* alias */ +#define V_ASN1_GENERALSTRING 27 /**/ +#define V_ASN1_UNIVERSALSTRING 28 /**/ +#define V_ASN1_BMPSTRING 30 + +/* For use with d2i_ASN1_type_bytes() */ +#define B_ASN1_NUMERICSTRING 0x0001 +#define B_ASN1_PRINTABLESTRING 0x0002 +#define B_ASN1_T61STRING 0x0004 +#define B_ASN1_TELETEXSTRING 0x0004 +#define B_ASN1_VIDEOTEXSTRING 0x0008 +#define B_ASN1_IA5STRING 0x0010 +#define B_ASN1_GRAPHICSTRING 0x0020 +#define B_ASN1_ISO64STRING 0x0040 +#define B_ASN1_VISIBLESTRING 0x0040 +#define B_ASN1_GENERALSTRING 0x0080 +#define B_ASN1_UNIVERSALSTRING 0x0100 +#define B_ASN1_OCTET_STRING 0x0200 +#define B_ASN1_BIT_STRING 0x0400 +#define B_ASN1_BMPSTRING 0x0800 +#define B_ASN1_UNKNOWN 0x1000 +#define B_ASN1_UTF8STRING 0x2000 +#define B_ASN1_UTCTIME 0x4000 +#define B_ASN1_GENERALIZEDTIME 0x8000 +#define B_ASN1_SEQUENCE 0x10000 + +/* For use with ASN1_mbstring_copy() */ +#define MBSTRING_FLAG 0x1000 +#define MBSTRING_UTF8 (MBSTRING_FLAG) +#define MBSTRING_ASC (MBSTRING_FLAG|1) +#define MBSTRING_BMP (MBSTRING_FLAG|2) +#define MBSTRING_UNIV (MBSTRING_FLAG|4) + +struct X509_algor_st; + +#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ +#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ + +/* We MUST make sure that, except for constness, asn1_ctx_st and + asn1_const_ctx are exactly the same. Fortunately, as soon as + the old ASN1 parsing macros are gone, we can throw this away + as well... */ +typedef struct asn1_ctx_st + { + unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + unsigned char *max; /* largest value of p allowed */ + unsigned char *q;/* temporary variable */ + unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_CTX; + +typedef struct asn1_const_ctx_st + { + const unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + long slen; /* length of last 'get object' */ + const unsigned char *max; /* largest value of p allowed */ + const unsigned char *q;/* temporary variable */ + const unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_const_CTX; + +/* These are used internally in the ASN1_OBJECT to keep track of + * whether the names and data need to be free()ed */ +#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ +#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ +#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ +#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ +typedef struct asn1_object_st + { + const char *sn,*ln; + int nid; + int length; + unsigned char *data; + int flags; /* Should we free this one */ + } ASN1_OBJECT; + +#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ +/* This indicates that the ASN1_STRING is not a real value but just a place + * holder for the location where indefinite length constructed data should + * be inserted in the memory buffer + */ +#define ASN1_STRING_FLAG_NDEF 0x010 +/* This is the base type that holds just about everything :-) */ +typedef struct asn1_string_st + { + int length; + int type; + unsigned char *data; + /* The value of the following field depends on the type being + * held. It is mostly being used for BIT_STRING so if the + * input data has a non-zero 'unused bits' value, it will be + * handled correctly */ + long flags; + } ASN1_STRING; + +/* ASN1_ENCODING structure: this is used to save the received + * encoding of an ASN1 type. This is useful to get round + * problems with invalid encodings which can break signatures. + */ + +typedef struct ASN1_ENCODING_st + { + unsigned char *enc; /* DER encoding */ + long len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ + } ASN1_ENCODING; + +/* Used with ASN1 LONG type: if a long is set to this it is omitted */ +#define ASN1_LONG_UNDEF 0x7fffffffL + +#define STABLE_FLAGS_MALLOC 0x01 +#define STABLE_NO_MASK 0x02 +#define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) +#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) + +typedef struct asn1_string_table_st { + int nid; + long minsize; + long maxsize; + unsigned long mask; + unsigned long flags; +} ASN1_STRING_TABLE; + +DECLARE_STACK_OF(ASN1_STRING_TABLE) + +/* size limits: this stuff is taken straight from RFC2459 */ + +#define ub_name 32768 +#define ub_common_name 64 +#define ub_locality_name 128 +#define ub_state_name 128 +#define ub_organization_name 64 +#define ub_organization_unit_name 64 +#define ub_title 64 +#define ub_email_address 128 + +/* Declarations for template structures: for full definitions + * see asn1t.h + */ +typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; +typedef struct ASN1_ITEM_st ASN1_ITEM; +typedef struct ASN1_TLC_st ASN1_TLC; +/* This is just an opaque pointer */ +typedef struct ASN1_VALUE_st ASN1_VALUE; + +/* Declare ASN1 functions: the implement macro in in asn1t.h */ + +#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) + +#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(itname) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + type *d2i_##name(type **a, const unsigned char **in, long len); \ + int i2d_##name(const type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(name) + +#define DECLARE_ASN1_NDEF_FUNCTION(name) \ + int i2d_##name##_NDEF(name *a, unsigned char **out); + +#define DECLARE_ASN1_FUNCTIONS_const(name) \ + name *name##_new(void); \ + void name##_free(name *a); + +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + type *name##_new(void); \ + void name##_free(type *a); + +#define D2I_OF(type) type *(*)(type **,const unsigned char **,long) +#define I2D_OF(type) int (*)(type *,unsigned char **) +#define I2D_OF_const(type) int (*)(const type *,unsigned char **) + +#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) +#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) +#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) + +TYPEDEF_D2I2D_OF(void); + +/* The following macros and typedefs allow an ASN1_ITEM + * to be embedded in a structure and referenced. Since + * the ASN1_ITEM pointers need to be globally accessible + * (possibly from shared libraries) they may exist in + * different forms. On platforms that support it the + * ASN1_ITEM structure itself will be globally exported. + * Other platforms will export a function that returns + * an ASN1_ITEM pointer. + * + * To handle both cases transparently the macros below + * should be used instead of hard coding an ASN1_ITEM + * pointer in a structure. + * + * The structure will look like this: + * + * typedef struct SOMETHING_st { + * ... + * ASN1_ITEM_EXP *iptr; + * ... + * } SOMETHING; + * + * It would be initialised as e.g.: + * + * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; + * + * and the actual pointer extracted with: + * + * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); + * + * Finally an ASN1_ITEM pointer can be extracted from an + * appropriate reference with: ASN1_ITEM_rptr(X509). This + * would be used when a function takes an ASN1_ITEM * argument. + * + */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM ASN1_ITEM_EXP; + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) + +#define ASN1_ITEM_rptr(ref) (&(ref##_it)) + +#define DECLARE_ASN1_ITEM(name) \ + OPENSSL_EXTERN const ASN1_ITEM name##_it; + +#else + +/* Platforms that can't easily handle shared global variables are declared + * as functions returning ASN1_ITEM pointers. + */ + +/* ASN1_ITEM pointer exported type */ +typedef const ASN1_ITEM * ASN1_ITEM_EXP(void); + +/* Macro to obtain ASN1_ITEM pointer from exported type */ +#define ASN1_ITEM_ptr(iptr) (iptr()) + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (iptr##_it) + +#define ASN1_ITEM_rptr(ref) (ref##_it()) + +#define DECLARE_ASN1_ITEM(name) \ + const ASN1_ITEM * name##_it(void); + +#endif + +/* Parameters used by ASN1_STRING_print_ex() */ + +/* These determine which characters to escape: + * RFC2253 special characters, control characters and + * MSB set characters + */ + +#define ASN1_STRFLGS_ESC_2253 1 +#define ASN1_STRFLGS_ESC_CTRL 2 +#define ASN1_STRFLGS_ESC_MSB 4 + + +/* This flag determines how we do escaping: normally + * RC2253 backslash only, set this to use backslash and + * quote. + */ + +#define ASN1_STRFLGS_ESC_QUOTE 8 + + +/* These three flags are internal use only. */ + +/* Character is a valid PrintableString character */ +#define CHARTYPE_PRINTABLESTRING 0x10 +/* Character needs escaping if it is the first character */ +#define CHARTYPE_FIRST_ESC_2253 0x20 +/* Character needs escaping if it is the last character */ +#define CHARTYPE_LAST_ESC_2253 0x40 + +/* NB the internal flags are safely reused below by flags + * handled at the top level. + */ + +/* If this is set we convert all character strings + * to UTF8 first + */ + +#define ASN1_STRFLGS_UTF8_CONVERT 0x10 + +/* If this is set we don't attempt to interpret content: + * just assume all strings are 1 byte per character. This + * will produce some pretty odd looking output! + */ + +#define ASN1_STRFLGS_IGNORE_TYPE 0x20 + +/* If this is set we include the string type in the output */ +#define ASN1_STRFLGS_SHOW_TYPE 0x40 + +/* This determines which strings to display and which to + * 'dump' (hex dump of content octets or DER encoding). We can + * only dump non character strings or everything. If we + * don't dump 'unknown' they are interpreted as character + * strings with 1 octet per character and are subject to + * the usual escaping options. + */ + +#define ASN1_STRFLGS_DUMP_ALL 0x80 +#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 + +/* These determine what 'dumping' does, we can dump the + * content octets or the DER encoding: both use the + * RFC2253 #XXXXX notation. + */ + +#define ASN1_STRFLGS_DUMP_DER 0x200 + +/* All the string flags consistent with RFC2253, + * escaping control characters isn't essential in + * RFC2253 but it is advisable anyway. + */ + +#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER) + +DECLARE_STACK_OF(ASN1_INTEGER) +DECLARE_ASN1_SET_OF(ASN1_INTEGER) + +DECLARE_STACK_OF(ASN1_GENERALSTRING) + +typedef struct asn1_type_st + { + int type; + union { + char *ptr; + ASN1_BOOLEAN boolean; + ASN1_STRING * asn1_string; + ASN1_OBJECT * object; + ASN1_INTEGER * integer; + ASN1_ENUMERATED * enumerated; + ASN1_BIT_STRING * bit_string; + ASN1_OCTET_STRING * octet_string; + ASN1_PRINTABLESTRING * printablestring; + ASN1_T61STRING * t61string; + ASN1_IA5STRING * ia5string; + ASN1_GENERALSTRING * generalstring; + ASN1_BMPSTRING * bmpstring; + ASN1_UNIVERSALSTRING * universalstring; + ASN1_UTCTIME * utctime; + ASN1_GENERALIZEDTIME * generalizedtime; + ASN1_VISIBLESTRING * visiblestring; + ASN1_UTF8STRING * utf8string; + /* set and sequence are left complete and still + * contain the set or sequence bytes */ + ASN1_STRING * set; + ASN1_STRING * sequence; + } value; + } ASN1_TYPE; + +DECLARE_STACK_OF(ASN1_TYPE) +DECLARE_ASN1_SET_OF(ASN1_TYPE) + +typedef struct asn1_method_st + { + i2d_of_void *i2d; + d2i_of_void *d2i; + void *(*create)(void); + void (*destroy)(void *); + } ASN1_METHOD; + +/* This is used when parsing some Netscape objects */ +typedef struct asn1_header_st + { + ASN1_OCTET_STRING *header; + void *data; + ASN1_METHOD *meth; + } ASN1_HEADER; + +/* This is used to contain a list of bit names */ +typedef struct BIT_STRING_BITNAME_st { + int bitnum; + const char *lname; + const char *sname; +} BIT_STRING_BITNAME; + + +#define M_ASN1_STRING_length(x) ((x)->length) +#define M_ASN1_STRING_length_set(x, n) ((x)->length = (n)) +#define M_ASN1_STRING_type(x) ((x)->type) +#define M_ASN1_STRING_data(x) ((x)->data) + +/* Macros for string operations */ +#define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\ + ASN1_STRING_type_new(V_ASN1_BIT_STRING) +#define M_ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) + +#define M_ASN1_INTEGER_new() (ASN1_INTEGER *)\ + ASN1_STRING_type_new(V_ASN1_INTEGER) +#define M_ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\ + ASN1_STRING_type_new(V_ASN1_ENUMERATED) +#define M_ASN1_ENUMERATED_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_ENUMERATED_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) + +#define M_ASN1_OCTET_STRING_new() (ASN1_OCTET_STRING *)\ + ASN1_STRING_type_new(V_ASN1_OCTET_STRING) +#define M_ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\ + ASN1_STRING_dup((ASN1_STRING *)a) +#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\ + (ASN1_STRING *)a,(ASN1_STRING *)b) +#define M_ASN1_OCTET_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c) +#define M_ASN1_OCTET_STRING_print(a,b) ASN1_STRING_print(a,(ASN1_STRING *)b) +#define M_i2d_ASN1_OCTET_STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ + V_ASN1_UNIVERSAL) + +#define B_ASN1_TIME \ + B_ASN1_UTCTIME | \ + B_ASN1_GENERALIZEDTIME + +#define B_ASN1_PRINTABLE \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_T61STRING| \ + B_ASN1_IA5STRING| \ + B_ASN1_BIT_STRING| \ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING|\ + B_ASN1_SEQUENCE|\ + B_ASN1_UNKNOWN + +#define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_TELETEXSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_UTF8STRING + +#define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING| \ + B_ASN1_VISIBLESTRING| \ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING + +#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_PRINTABLE) + +#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DIRECTORYSTRING(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DIRECTORYSTRING) + +#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ + pp,a->type,V_ASN1_UNIVERSAL) +#define M_d2i_DISPLAYTEXT(a,pp,l) \ + d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ + B_ASN1_DISPLAYTEXT) + +#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) +#define M_ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \ + (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING) + +#define M_ASN1_T61STRING_new() (ASN1_T61STRING *)\ + ASN1_STRING_type_new(V_ASN1_T61STRING) +#define M_ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_T61STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_T61STRING(a,pp,l) \ + (ASN1_T61STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING) + +#define M_ASN1_IA5STRING_new() (ASN1_IA5STRING *)\ + ASN1_STRING_type_new(V_ASN1_IA5STRING) +#define M_ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_IA5STRING_dup(a) \ + (ASN1_IA5STRING *)ASN1_STRING_dup((ASN1_STRING *)a) +#define M_i2d_ASN1_IA5STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_IA5STRING(a,pp,l) \ + (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\ + B_ASN1_IA5STRING) + +#define M_ASN1_UTCTIME_new() (ASN1_UTCTIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALIZEDTIME_new() (ASN1_GENERALIZEDTIME *)\ + ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME) +#define M_ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\ + (ASN1_STRING *)a) + +#define M_ASN1_TIME_new() (ASN1_TIME *)\ + ASN1_STRING_type_new(V_ASN1_UTCTIME) +#define M_ASN1_TIME_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_ASN1_TIME_dup(a) (ASN1_TIME *)ASN1_STRING_dup((ASN1_STRING *)a) + +#define M_ASN1_GENERALSTRING_new() (ASN1_GENERALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_GENERALSTRING) +#define M_ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_GENERALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \ + (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING) + +#define M_ASN1_UNIVERSALSTRING_new() (ASN1_UNIVERSALSTRING *)\ + ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING) +#define M_ASN1_UNIVERSALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \ + (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING) + +#define M_ASN1_BMPSTRING_new() (ASN1_BMPSTRING *)\ + ASN1_STRING_type_new(V_ASN1_BMPSTRING) +#define M_ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_BMPSTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_BMPSTRING(a,pp,l) \ + (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING) + +#define M_ASN1_VISIBLESTRING_new() (ASN1_VISIBLESTRING *)\ + ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) +#define M_ASN1_VISIBLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_VISIBLESTRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \ + (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING) + +#define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\ + ASN1_STRING_type_new(V_ASN1_UTF8STRING) +#define M_ASN1_UTF8STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) +#define M_i2d_ASN1_UTF8STRING(a,pp) \ + i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\ + V_ASN1_UNIVERSAL) +#define M_d2i_ASN1_UTF8STRING(a,pp,l) \ + (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\ + ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING) + + /* for the is_set parameter to i2d_ASN1_SET */ +#define IS_SEQUENCE 0 +#define IS_SET 1 + +DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) + +int ASN1_TYPE_get(ASN1_TYPE *a); +void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); + +ASN1_OBJECT * ASN1_OBJECT_new(void ); +void ASN1_OBJECT_free(ASN1_OBJECT *a); +int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); +ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); +ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,const unsigned char **pp, + long length); + +DECLARE_ASN1_ITEM(ASN1_OBJECT) + +DECLARE_STACK_OF(ASN1_OBJECT) +DECLARE_ASN1_SET_OF(ASN1_OBJECT) + +ASN1_STRING * ASN1_STRING_new(void); +void ASN1_STRING_free(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); +ASN1_STRING * ASN1_STRING_type_new(int type ); +int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); + /* Since this is used to store all sorts of things, via macros, for now, make + its data void * */ +int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); +int ASN1_STRING_length(ASN1_STRING *x); +void ASN1_STRING_length_set(ASN1_STRING *x, int n); +int ASN1_STRING_type(ASN1_STRING *x); +unsigned char * ASN1_STRING_data(ASN1_STRING *x); + +DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) +int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); +ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,const unsigned char **pp, + long length); +int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, + int length ); +int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); +int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); + +#ifndef OPENSSL_NO_BIO +int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, + BIT_STRING_BITNAME *tbl, int indent); +#endif +int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl); +int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, + BIT_STRING_BITNAME *tbl); + +int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); +int d2i_ASN1_BOOLEAN(int *a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) +int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); +ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,const unsigned char **pp, + long length); +ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); +int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); + +DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) + +int ASN1_UTCTIME_check(ASN1_UTCTIME *a); +ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); +int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); +int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); +#if 0 +time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s); +#endif + +int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); +int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); + +DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) +ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); +int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); +int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); + +DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_NULL) +DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) + +int UTF8_getc(const unsigned char *str, int len, unsigned long *val); +int UTF8_putc(unsigned char *str, int len, unsigned long value); + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) + +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) +DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) +DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) +DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) +DECLARE_ASN1_FUNCTIONS(ASN1_TIME) + +DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) + +ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); +int ASN1_TIME_check(ASN1_TIME *t); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); + +int i2d_ASN1_SET(STACK *a, unsigned char **pp, + i2d_of_void *i2d, int ex_tag, int ex_class, int is_set); +STACK * d2i_ASN1_SET(STACK **a, const unsigned char **pp, long length, + d2i_of_void *d2i, void (*free_func)(void *), + int ex_tag, int ex_class); + +#ifndef OPENSSL_NO_BIO +int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); +int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); +int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); +int a2i_ASN1_ENUMERATED(BIO *bp,ASN1_ENUMERATED *bs,char *buf,int size); +int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *a); +int a2i_ASN1_STRING(BIO *bp,ASN1_STRING *bs,char *buf,int size); +int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type); +#endif +int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a); + +int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); +ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, + const char *sn, const char *ln); + +int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); +long ASN1_INTEGER_get(ASN1_INTEGER *a); +ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai); +BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn); + +int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); +long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a); +ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai); +BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai,BIGNUM *bn); + +/* General */ +/* given a string, return the correct type, max is the maximum length */ +int ASN1_PRINTABLE_type(const unsigned char *s, int max); + +int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); +ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, + long length, int Ptag, int Pclass); +unsigned long ASN1_tag2bit(int tag); +/* type is one or more of the B_ASN1_ values. */ +ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,const unsigned char **pp, + long length,int type); + +/* PARSING */ +int asn1_Finish(ASN1_CTX *c); +int asn1_const_Finish(ASN1_const_CTX *c); + +/* SPECIALS */ +int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax); +int ASN1_check_infinite_end(unsigned char **p,long len); +int ASN1_const_check_infinite_end(const unsigned char **p,long len); +void ASN1_put_object(unsigned char **pp, int constructed, int length, + int tag, int xclass); +int ASN1_put_eoc(unsigned char **pp); +int ASN1_object_size(int constructed, int length, int tag); + +/* Used to implement other functions */ +void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); +#define ASN1_dup_of(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) +#define ASN1_dup_of_const(type,i2d,d2i,x) \ + ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) + +void *ASN1_item_dup(const ASN1_ITEM *it, void *x); + +#ifndef OPENSSL_NO_FP_API +void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); +#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x) +void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); +int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); +#define ASN1_i2d_fp_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +#define ASN1_i2d_fp_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) +int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); +int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); +#endif + +int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); + +#ifndef OPENSSL_NO_BIO +void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); +#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ + ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x) +void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); +int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); +#define ASN1_i2d_bio_of(type,i2d,out,x) \ + ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +#define ASN1_i2d_bio_of_const(type,i2d,out,x) \ + ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) +int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); +int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); +int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); +int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); +int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); +int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); +int ASN1_parse(BIO *bp,const unsigned char *pp,long len,int indent); +int ASN1_parse_dump(BIO *bp,const unsigned char *pp,long len,int indent,int dump); +#endif +const char *ASN1_tag2str(int tag); + +/* Used to load and write netscape format cert/key */ +int i2d_ASN1_HEADER(ASN1_HEADER *a,unsigned char **pp); +ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a,const unsigned char **pp, long length); +ASN1_HEADER *ASN1_HEADER_new(void ); +void ASN1_HEADER_free(ASN1_HEADER *a); + +int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); + +/* Not used that much at this point, except for the first two */ +ASN1_METHOD *X509_asn1_meth(void); +ASN1_METHOD *RSAPrivateKey_asn1_meth(void); +ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void); +ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void); + +int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, + unsigned char *data, int len); +int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, + unsigned char *data, int max_len); +int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num, + unsigned char *data, int max_len); + +STACK *ASN1_seq_unpack(const unsigned char *buf, int len, + d2i_of_void *d2i, void (*free_func)(void *)); +unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, + unsigned char **buf, int *len ); +void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i); +void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); +ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, + ASN1_OCTET_STRING **oct); +#define ASN1_pack_string_of(type,obj,i2d,oct) \ + ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct) +ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); + +void ASN1_STRING_set_default_mask(unsigned long mask); +int ASN1_STRING_set_default_mask_asc(char *p); +unsigned long ASN1_STRING_get_default_mask(void); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask); +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask, + long minsize, long maxsize); + +ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, + const unsigned char *in, int inlen, int inform, int nid); +ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); +int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); +void ASN1_STRING_TABLE_cleanup(void); + +/* ASN1 template functions */ + +/* Old API compatible functions */ +ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); +void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); +ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); +int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); +int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); + +void ASN1_add_oid_module(void); + +ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); +ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ASN1_strings(void); + +/* Error codes for the ASN1 functions. */ + +/* Function codes. */ +#define ASN1_F_A2D_ASN1_OBJECT 100 +#define ASN1_F_A2I_ASN1_ENUMERATED 101 +#define ASN1_F_A2I_ASN1_INTEGER 102 +#define ASN1_F_A2I_ASN1_STRING 103 +#define ASN1_F_APPEND_EXP 176 +#define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 +#define ASN1_F_ASN1_CB 177 +#define ASN1_F_ASN1_CHECK_TLEN 104 +#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105 +#define ASN1_F_ASN1_COLLECT 106 +#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 +#define ASN1_F_ASN1_D2I_FP 109 +#define ASN1_F_ASN1_D2I_READ_BIO 107 +#define ASN1_F_ASN1_DIGEST 184 +#define ASN1_F_ASN1_DO_ADB 110 +#define ASN1_F_ASN1_DUP 111 +#define ASN1_F_ASN1_ENUMERATED_SET 112 +#define ASN1_F_ASN1_ENUMERATED_TO_BN 113 +#define ASN1_F_ASN1_EX_C2I 204 +#define ASN1_F_ASN1_FIND_END 190 +#define ASN1_F_ASN1_GENERALIZEDTIME_SET 185 +#define ASN1_F_ASN1_GENERATE_V3 178 +#define ASN1_F_ASN1_GET_OBJECT 114 +#define ASN1_F_ASN1_HEADER_NEW 115 +#define ASN1_F_ASN1_I2D_BIO 116 +#define ASN1_F_ASN1_I2D_FP 117 +#define ASN1_F_ASN1_INTEGER_SET 118 +#define ASN1_F_ASN1_INTEGER_TO_BN 119 +#define ASN1_F_ASN1_ITEM_D2I_FP 206 +#define ASN1_F_ASN1_ITEM_DUP 191 +#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW 121 +#define ASN1_F_ASN1_ITEM_EX_D2I 120 +#define ASN1_F_ASN1_ITEM_I2D_BIO 192 +#define ASN1_F_ASN1_ITEM_I2D_FP 193 +#define ASN1_F_ASN1_ITEM_PACK 198 +#define ASN1_F_ASN1_ITEM_SIGN 195 +#define ASN1_F_ASN1_ITEM_UNPACK 199 +#define ASN1_F_ASN1_ITEM_VERIFY 197 +#define ASN1_F_ASN1_MBSTRING_NCOPY 122 +#define ASN1_F_ASN1_OBJECT_NEW 123 +#define ASN1_F_ASN1_PACK_STRING 124 +#define ASN1_F_ASN1_PCTX_NEW 205 +#define ASN1_F_ASN1_PKCS5_PBE_SET 125 +#define ASN1_F_ASN1_SEQ_PACK 126 +#define ASN1_F_ASN1_SEQ_UNPACK 127 +#define ASN1_F_ASN1_SIGN 128 +#define ASN1_F_ASN1_STR2TYPE 179 +#define ASN1_F_ASN1_STRING_SET 186 +#define ASN1_F_ASN1_STRING_TABLE_ADD 129 +#define ASN1_F_ASN1_STRING_TYPE_NEW 130 +#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 +#define ASN1_F_ASN1_TEMPLATE_NEW 133 +#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 +#define ASN1_F_ASN1_TIME_SET 175 +#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 +#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 +#define ASN1_F_ASN1_UNPACK_STRING 136 +#define ASN1_F_ASN1_UTCTIME_SET 187 +#define ASN1_F_ASN1_VERIFY 137 +#define ASN1_F_BITSTR_CB 180 +#define ASN1_F_BN_TO_ASN1_ENUMERATED 138 +#define ASN1_F_BN_TO_ASN1_INTEGER 139 +#define ASN1_F_C2I_ASN1_BIT_STRING 189 +#define ASN1_F_C2I_ASN1_INTEGER 194 +#define ASN1_F_C2I_ASN1_OBJECT 196 +#define ASN1_F_COLLECT_DATA 140 +#define ASN1_F_D2I_ASN1_BIT_STRING 141 +#define ASN1_F_D2I_ASN1_BOOLEAN 142 +#define ASN1_F_D2I_ASN1_BYTES 143 +#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144 +#define ASN1_F_D2I_ASN1_HEADER 145 +#define ASN1_F_D2I_ASN1_INTEGER 146 +#define ASN1_F_D2I_ASN1_OBJECT 147 +#define ASN1_F_D2I_ASN1_SET 148 +#define ASN1_F_D2I_ASN1_TYPE_BYTES 149 +#define ASN1_F_D2I_ASN1_UINTEGER 150 +#define ASN1_F_D2I_ASN1_UTCTIME 151 +#define ASN1_F_D2I_NETSCAPE_RSA 152 +#define ASN1_F_D2I_NETSCAPE_RSA_2 153 +#define ASN1_F_D2I_PRIVATEKEY 154 +#define ASN1_F_D2I_PUBLICKEY 155 +#define ASN1_F_D2I_RSA_NET 200 +#define ASN1_F_D2I_RSA_NET_2 201 +#define ASN1_F_D2I_X509 156 +#define ASN1_F_D2I_X509_CINF 157 +#define ASN1_F_D2I_X509_PKEY 159 +#define ASN1_F_I2D_ASN1_SET 188 +#define ASN1_F_I2D_ASN1_TIME 160 +#define ASN1_F_I2D_DSA_PUBKEY 161 +#define ASN1_F_I2D_EC_PUBKEY 181 +#define ASN1_F_I2D_PRIVATEKEY 163 +#define ASN1_F_I2D_PUBLICKEY 164 +#define ASN1_F_I2D_RSA_NET 162 +#define ASN1_F_I2D_RSA_PUBKEY 165 +#define ASN1_F_LONG_C2I 166 +#define ASN1_F_OID_MODULE_INIT 174 +#define ASN1_F_PARSE_TAGGING 182 +#define ASN1_F_PKCS5_PBE2_SET 167 +#define ASN1_F_PKCS5_PBE_SET 202 +#define ASN1_F_X509_CINF_NEW 168 +#define ASN1_F_X509_CRL_ADD0_REVOKED 169 +#define ASN1_F_X509_INFO_NEW 170 +#define ASN1_F_X509_NAME_ENCODE 203 +#define ASN1_F_X509_NAME_EX_D2I 158 +#define ASN1_F_X509_NAME_EX_NEW 171 +#define ASN1_F_X509_NEW 172 +#define ASN1_F_X509_PKEY_NEW 173 + +/* Reason codes. */ +#define ASN1_R_ADDING_OBJECT 171 +#define ASN1_R_AUX_ERROR 100 +#define ASN1_R_BAD_CLASS 101 +#define ASN1_R_BAD_OBJECT_HEADER 102 +#define ASN1_R_BAD_PASSWORD_READ 103 +#define ASN1_R_BAD_TAG 104 +#define ASN1_R_BN_LIB 105 +#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 +#define ASN1_R_BUFFER_TOO_SMALL 107 +#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 +#define ASN1_R_DATA_IS_WRONG 109 +#define ASN1_R_DECODE_ERROR 110 +#define ASN1_R_DECODING_ERROR 111 +#define ASN1_R_DEPTH_EXCEEDED 174 +#define ASN1_R_ENCODE_ERROR 112 +#define ASN1_R_ERROR_GETTING_TIME 173 +#define ASN1_R_ERROR_LOADING_SECTION 172 +#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 +#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 +#define ASN1_R_EXPECTING_AN_INTEGER 115 +#define ASN1_R_EXPECTING_AN_OBJECT 116 +#define ASN1_R_EXPECTING_A_BOOLEAN 117 +#define ASN1_R_EXPECTING_A_TIME 118 +#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 +#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 +#define ASN1_R_FIELD_MISSING 121 +#define ASN1_R_FIRST_NUM_TOO_LARGE 122 +#define ASN1_R_HEADER_TOO_LONG 123 +#define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 +#define ASN1_R_ILLEGAL_BOOLEAN 176 +#define ASN1_R_ILLEGAL_CHARACTERS 124 +#define ASN1_R_ILLEGAL_FORMAT 177 +#define ASN1_R_ILLEGAL_HEX 178 +#define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 +#define ASN1_R_ILLEGAL_INTEGER 180 +#define ASN1_R_ILLEGAL_NESTED_TAGGING 181 +#define ASN1_R_ILLEGAL_NULL 125 +#define ASN1_R_ILLEGAL_NULL_VALUE 182 +#define ASN1_R_ILLEGAL_OBJECT 183 +#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 +#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 +#define ASN1_R_ILLEGAL_TAGGED_ANY 127 +#define ASN1_R_ILLEGAL_TIME_VALUE 184 +#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 +#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 +#define ASN1_R_INVALID_BMPSTRING_LENGTH 129 +#define ASN1_R_INVALID_DIGIT 130 +#define ASN1_R_INVALID_MODIFIER 186 +#define ASN1_R_INVALID_NUMBER 187 +#define ASN1_R_INVALID_SEPARATOR 131 +#define ASN1_R_INVALID_TIME_FORMAT 132 +#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 +#define ASN1_R_INVALID_UTF8STRING 134 +#define ASN1_R_IV_TOO_LARGE 135 +#define ASN1_R_LENGTH_ERROR 136 +#define ASN1_R_LIST_ERROR 188 +#define ASN1_R_MISSING_EOC 137 +#define ASN1_R_MISSING_SECOND_NUMBER 138 +#define ASN1_R_MISSING_VALUE 189 +#define ASN1_R_MSTRING_NOT_UNIVERSAL 139 +#define ASN1_R_MSTRING_WRONG_TAG 140 +#define ASN1_R_NESTED_ASN1_STRING 197 +#define ASN1_R_NON_HEX_CHARACTERS 141 +#define ASN1_R_NOT_ASCII_FORMAT 190 +#define ASN1_R_NOT_ENOUGH_DATA 142 +#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 +#define ASN1_R_NULL_IS_WRONG_LENGTH 144 +#define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 +#define ASN1_R_ODD_NUMBER_OF_CHARS 145 +#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146 +#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 +#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 +#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 +#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 +#define ASN1_R_SHORT_LINE 150 +#define ASN1_R_STRING_TOO_LONG 151 +#define ASN1_R_STRING_TOO_SHORT 152 +#define ASN1_R_TAG_VALUE_TOO_HIGH 153 +#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 +#define ASN1_R_TIME_NOT_ASCII_FORMAT 193 +#define ASN1_R_TOO_LONG 155 +#define ASN1_R_TYPE_NOT_CONSTRUCTED 156 +#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157 +#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158 +#define ASN1_R_UNEXPECTED_EOC 159 +#define ASN1_R_UNKNOWN_FORMAT 160 +#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 +#define ASN1_R_UNKNOWN_OBJECT_TYPE 162 +#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 +#define ASN1_R_UNKNOWN_TAG 194 +#define ASN1_R_UNKOWN_FORMAT 195 +#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 +#define ASN1_R_UNSUPPORTED_CIPHER 165 +#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166 +#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 +#define ASN1_R_UNSUPPORTED_TYPE 196 +#define ASN1_R_WRONG_TAG 168 +#define ASN1_R_WRONG_TYPE 169 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/asn1_mac.h b/libraries/external/openssl/pc/include/openssl/asn1_mac.h new file mode 100755 index 0000000..1ac54cf --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/asn1_mac.h @@ -0,0 +1,571 @@ +/* crypto/asn1/asn1_mac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ASN1_MAC_H +#define HEADER_ASN1_MAC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASN1_MAC_ERR_LIB +#define ASN1_MAC_ERR_LIB ERR_LIB_ASN1 +#endif + +#define ASN1_MAC_H_err(f,r,line) \ + ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line)) + +#define M_ASN1_D2I_vars(a,type,func) \ + ASN1_const_CTX c; \ + type ret=NULL; \ + \ + c.pp=(const unsigned char **)pp; \ + c.q= *(const unsigned char **)pp; \ + c.error=ERR_R_NESTED_ASN1_ERROR; \ + if ((a == NULL) || ((*a) == NULL)) \ + { if ((ret=(type)func()) == NULL) \ + { c.line=__LINE__; goto err; } } \ + else ret=(*a); + +#define M_ASN1_D2I_Init() \ + c.p= *(const unsigned char **)pp; \ + c.max=(length == 0)?0:(c.p+length); + +#define M_ASN1_D2I_Finish_2(a) \ + if (!asn1_const_Finish(&c)) \ + { c.line=__LINE__; goto err; } \ + *(const unsigned char **)pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); + +#define M_ASN1_D2I_Finish(a,func,e) \ + M_ASN1_D2I_Finish_2(a); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_start_sequence() \ + if (!asn1_GetSequence(&c,&length)) \ + { c.line=__LINE__; goto err; } +/* Begin reading ASN1 without a surrounding sequence */ +#define M_ASN1_D2I_begin() \ + c.slen = length; + +/* End reading ASN1 with no check on length */ +#define M_ASN1_D2I_Finish_nolen(a, func, e) \ + *pp=c.p; \ + if (a != NULL) (*a)=ret; \ + return(ret); \ +err:\ + ASN1_MAC_H_err((e),c.error,c.line); \ + asn1_add_error(*pp,(int)(c.q- *pp)); \ + if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ + return(NULL) + +#define M_ASN1_D2I_end_sequence() \ + (((c.inf&1) == 0)?(c.slen <= 0): \ + (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen))) + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get(b, func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* Don't use this with d2i_ASN1_BOOLEAN() */ +#define M_ASN1_D2I_get_x(type,b,func) \ + c.q=c.p; \ + if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +/* use this instead () */ +#define M_ASN1_D2I_get_int(b,func) \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) < 0) \ + {c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_opt(b,func,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \ + == (V_ASN1_UNIVERSAL|(type)))) \ + { \ + M_ASN1_D2I_get(b,func); \ + } + +#define M_ASN1_D2I_get_imp(b,func, type) \ + M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \ + c.q=c.p; \ + if (func(&(b),&c.p,c.slen) == NULL) \ + {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \ + c.slen-=(c.p-c.q);\ + M_ASN1_next_prev=_tmp; + +#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \ + if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \ + (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \ + { \ + unsigned char _tmp = M_ASN1_next; \ + M_ASN1_D2I_get_imp(b,func, type);\ + } + +#define M_ASN1_D2I_get_set(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \ + V_ASN1_SET,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_set_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set(r,func,free_func); } + +#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SET)))\ + { M_ASN1_D2I_get_set_type(type,r,func,free_func); } + +#define M_ASN1_I2D_len_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SET(a,f); + +#define M_ASN1_I2D_put_SET_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SET(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE_type(type,a,f); + +#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set(b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \ + if ((c.slen != 0) && \ + (M_ASN1_next == \ + (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\ + { \ + M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\ + tag,V_ASN1_CONTEXT_SPECIFIC); \ + } + +#define M_ASN1_D2I_get_seq(r,func,free_func) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); + +#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_D2I_get_seq_opt(r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq(r,func,free_func); } + +#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \ + if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \ + V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\ + { M_ASN1_D2I_get_seq_type(type,r,func,free_func); } + +#define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set(r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \ + M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\ + x,V_ASN1_CONTEXT_SPECIFIC); + +#define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\ + (void (*)())free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\ + free_func,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_set_strings(r,func,a,b) \ + c.q=c.p; \ + if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \ + { c.line=__LINE__; goto err; } \ + c.slen-=(c.p-c.q); + +#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \ + if ((c.slen != 0L) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (func(&(r),&c.p,Tlen) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \ + (void (*)())free_func, \ + b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \ + if ((c.slen != 0) && (M_ASN1_next == \ + (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \ + { \ + int Tinf,Ttag,Tclass; \ + long Tlen; \ + \ + c.q=c.p; \ + Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \ + if (Tinf & 0x80) \ + { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \ + c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) \ + Tlen = c.slen - (c.p - c.q) - 2; \ + if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \ + free_func,b,V_ASN1_UNIVERSAL) == NULL) \ + { c.line=__LINE__; goto err; } \ + if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \ + Tlen = c.slen - (c.p - c.q); \ + if(!ASN1_check_infinite_end(&c.p, Tlen)) \ + { c.error=ERR_R_MISSING_ASN1_EOS; \ + c.line=__LINE__; goto err; } \ + }\ + c.slen-=(c.p-c.q); \ + } + +/* New macros */ +#define M_ASN1_New_Malloc(ret,type) \ + if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \ + { c.line=__LINE__; goto err2; } + +#define M_ASN1_New(arg,func) \ + if (((arg)=func()) == NULL) return(NULL) + +#define M_ASN1_New_Error(a) \ +/* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \ + return(NULL);*/ \ + err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \ + return(NULL) + + +/* BIG UGLY WARNING! This is so damn ugly I wanna puke. Unfortunately, + some macros that use ASN1_const_CTX still insist on writing in the input + stream. ARGH! ARGH! ARGH! Let's get rid of this macro package. + Please? -- Richard Levitte */ +#define M_ASN1_next (*((unsigned char *)(c.p))) +#define M_ASN1_next_prev (*((unsigned char *)(c.q))) + +/*************************************************/ + +#define M_ASN1_I2D_vars(a) int r=0,ret=0; \ + unsigned char *p; \ + if (a == NULL) return(0) + +/* Length Macros */ +#define M_ASN1_I2D_len(a,f) ret+=f(a,NULL) +#define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f) + +#define M_ASN1_I2D_len_SET(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SET_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \ + V_ASN1_UNIVERSAL,IS_SET); + +#define M_ASN1_I2D_len_SEQUENCE(a,f) \ + ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE(a,f); + +#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + M_ASN1_I2D_len_SEQUENCE_type(type,a,f); + +#define M_ASN1_I2D_len_IMP_SET(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); + +#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC,IS_SET); + +#define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); + +#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \ + if (a != NULL)\ + { \ + v=f(a,NULL); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0))\ + { \ + v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0))\ + { \ + v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \ + V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + ret+=ASN1_object_size(1,v,mtag); \ + } + +/* Put Macros */ +#define M_ASN1_I2D_put(a,f) f(a,&p) + +#define M_ASN1_I2D_put_IMP_opt(a,f,t) \ + if (a != NULL) \ + { \ + unsigned char *q=p; \ + f(a,&p); \ + *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\ + } + +#define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\ + V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_SET_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET) +#define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \ + i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET) +#define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\ + V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\ + V_ASN1_UNIVERSAL,IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \ + i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE) + +#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + M_ASN1_I2D_put_SEQUENCE(a,f); + +#define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SET); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { i2d_ASN1_SET_OF_##type(a,&p,f,x, \ + V_ASN1_CONTEXT_SPECIFIC, \ + IS_SEQUENCE); } + +#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \ + if (a != NULL) \ + { \ + ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \ + f(a,&p); \ + } + +#define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \ + if ((a != NULL) && (sk_##type##_num(a) != 0)) \ + { \ + ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \ + i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \ + IS_SEQUENCE); \ + } + +#define M_ASN1_I2D_seq_total() \ + r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ + if (pp == NULL) return(r); \ + p= *pp; \ + ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL) + +#define M_ASN1_I2D_INF_seq_start(tag,ctx) \ + *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \ + *(p++)=0x80 + +#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00 + +#define M_ASN1_I2D_finish() *pp=p; \ + return(r); + +int asn1_GetSequence(ASN1_const_CTX *c, long *length); +void asn1_add_error(const unsigned char *address,int offset); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/asn1t.h b/libraries/external/openssl/pc/include/openssl/asn1t.h new file mode 100755 index 0000000..4fd99e3 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/asn1t.h @@ -0,0 +1,886 @@ +/* asn1t.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ASN1T_H +#define HEADER_ASN1T_H + +#include +#include +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +/* ASN1 template defines, structures and functions */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { + +#define ASN1_ITEM_end(itname) \ + }; + +#else + +/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ +#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) + + +/* Macros for start and end of ASN1_ITEM definition */ + +#define ASN1_ITEM_start(itname) \ + const ASN1_ITEM * itname##_it(void) \ + { \ + static const ASN1_ITEM local_it = { + +#define ASN1_ITEM_end(itname) \ + }; \ + return &local_it; \ + } + +#endif + + +/* Macros to aid ASN1 template writing */ + +#define ASN1_ITEM_TEMPLATE(tname) \ + static const ASN1_TEMPLATE tname##_item_tt + +#define ASN1_ITEM_TEMPLATE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_PRIMITIVE,\ + -1,\ + &tname##_item_tt,\ + 0,\ + NULL,\ + 0,\ + #tname \ + ASN1_ITEM_end(tname) + + +/* This is a ASN1 type which just embeds a template */ + +/* This pair helps declare a SEQUENCE. We can do: + * + * ASN1_SEQUENCE(stname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END(stname) + * + * This will produce an ASN1_ITEM called stname_it + * for a structure called stname. + * + * If you want the same structure but a different + * name then use: + * + * ASN1_SEQUENCE(itname) = { + * ... SEQUENCE components ... + * } ASN1_SEQUENCE_END_name(stname, itname) + * + * This will create an item called itname_it using + * a structure called stname. + */ + +#define ASN1_SEQUENCE(tname) \ + static const ASN1_TEMPLATE tname##_seq_tt[] + +#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) + +#define ASN1_SEQUENCE_END_name(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_NDEF_SEQUENCE(tname) \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_BROKEN_SEQUENCE(tname) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_ref(tname, cb, lck) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_SEQUENCE_enc(tname, enc, cb) \ + static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ + ASN1_SEQUENCE(tname) + +#define ASN1_NDEF_SEQUENCE_END(tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_NDEF_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(tname),\ + #tname \ + ASN1_ITEM_end(tname) + +#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) + +#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) + +#define ASN1_SEQUENCE_END_ref(stname, tname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_SEQUENCE,\ + V_ASN1_SEQUENCE,\ + tname##_seq_tt,\ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + + +/* This pair helps declare a CHOICE type. We can do: + * + * ASN1_CHOICE(chname) = { + * ... CHOICE options ... + * ASN1_CHOICE_END(chname) + * + * This will produce an ASN1_ITEM called chname_it + * for a structure called chname. The structure + * definition must look like this: + * typedef struct { + * int type; + * union { + * ASN1_SOMETHING *opt1; + * ASN1_SOMEOTHER *opt2; + * } value; + * } chname; + * + * the name of the selector must be 'type'. + * to use an alternative selector name use the + * ASN1_CHOICE_END_selector() version. + */ + +#define ASN1_CHOICE(tname) \ + static const ASN1_TEMPLATE tname##_ch_tt[] + +#define ASN1_CHOICE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ + ASN1_CHOICE(tname) + +#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) + +#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) + +#define ASN1_CHOICE_END_selector(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + NULL,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +#define ASN1_CHOICE_END_cb(stname, tname, selname) \ + ;\ + ASN1_ITEM_start(tname) \ + ASN1_ITYPE_CHOICE,\ + offsetof(stname,selname) ,\ + tname##_ch_tt,\ + sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ + &tname##_aux,\ + sizeof(stname),\ + #stname \ + ASN1_ITEM_end(tname) + +/* This helps with the template wrapper form of ASN1_ITEM */ + +#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ + (flags), (tag), 0,\ + #name, ASN1_ITEM_ref(type) } + +/* These help with SEQUENCE or CHOICE components */ + +/* used to declare other types */ + +#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ + (flags), (tag), offsetof(stname, field),\ + #field, ASN1_ITEM_ref(type) } + +/* used when the structure is combined with the parent */ + +#define ASN1_EX_COMBINE(flags, tag, type) { \ + (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) } + +/* implicit and explicit helper macros */ + +#define ASN1_IMP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) + +#define ASN1_EXP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) + +/* Any defined by macros: the field used is in the table itself */ + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } +#else +#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } +#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } +#endif +/* Plain simple type */ +#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) + +/* OPTIONAL simple type */ +#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* IMPLICIT tagged simple type */ +#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) + +/* IMPLICIT tagged OPTIONAL simple type */ +#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* Same as above but EXPLICIT */ + +#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) +#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) + +/* SEQUENCE OF type */ +#define ASN1_SEQUENCE_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) + +/* OPTIONAL SEQUENCE OF */ +#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Same as above but for SET OF */ + +#define ASN1_SET_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) + +#define ASN1_SET_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) + +/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ + +#define ASN1_IMP_SET_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_EXP_SET_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) + +#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) + +#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) + +/* EXPLICIT OPTIONAL using indefinite length constructed form */ +#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) + +/* Macros for the ASN1_ADB structure */ + +#define ASN1_ADB(name) \ + static const ASN1_ADB_TABLE name##_adbtbl[] + +#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ADB name##_adb = {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + } + +#else + +#define ASN1_ADB_END(name, flags, field, app_table, def, none) \ + ;\ + static const ASN1_ITEM *name##_adb(void) \ + { \ + static const ASN1_ADB internal_adb = \ + {\ + flags,\ + offsetof(name, field),\ + app_table,\ + name##_adbtbl,\ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ + def,\ + none\ + }; \ + return (const ASN1_ITEM *) &internal_adb; \ + } \ + void dummy_function(void) + +#endif + +#define ADB_ENTRY(val, template) {val, template} + +#define ASN1_ADB_TEMPLATE(name) \ + static const ASN1_TEMPLATE name##_tt + +/* This is the ASN1 template structure that defines + * a wrapper round the actual type. It determines the + * actual position of the field in the value structure, + * various flags such as OPTIONAL and the field name. + */ + +struct ASN1_TEMPLATE_st { +unsigned long flags; /* Various flags */ +long tag; /* tag, not used if no tagging */ +unsigned long offset; /* Offset of this field in structure */ +#ifndef NO_ASN1_FIELD_NAMES +const char *field_name; /* Field name */ +#endif +ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ +}; + +/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ + +#define ASN1_TEMPLATE_item(t) (t->item_ptr) +#define ASN1_TEMPLATE_adb(t) (t->item_ptr) + +typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; +typedef struct ASN1_ADB_st ASN1_ADB; + +struct ASN1_ADB_st { + unsigned long flags; /* Various flags */ + unsigned long offset; /* Offset of selector field */ + STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */ + const ASN1_ADB_TABLE *tbl; /* Table of possible types */ + long tblcount; /* Number of entries in tbl */ + const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ + const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ +}; + +struct ASN1_ADB_TABLE_st { + long value; /* NID for an object or value for an int */ + const ASN1_TEMPLATE tt; /* item for this value */ +}; + +/* template flags */ + +/* Field is optional */ +#define ASN1_TFLG_OPTIONAL (0x1) + +/* Field is a SET OF */ +#define ASN1_TFLG_SET_OF (0x1 << 1) + +/* Field is a SEQUENCE OF */ +#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) + +/* Special case: this refers to a SET OF that + * will be sorted into DER order when encoded *and* + * the corresponding STACK will be modified to match + * the new order. + */ +#define ASN1_TFLG_SET_ORDER (0x3 << 1) + +/* Mask for SET OF or SEQUENCE OF */ +#define ASN1_TFLG_SK_MASK (0x3 << 1) + +/* These flags mean the tag should be taken from the + * tag field. If EXPLICIT then the underlying type + * is used for the inner tag. + */ + +/* IMPLICIT tagging */ +#define ASN1_TFLG_IMPTAG (0x1 << 3) + + +/* EXPLICIT tagging, inner tag from underlying type */ +#define ASN1_TFLG_EXPTAG (0x2 << 3) + +#define ASN1_TFLG_TAG_MASK (0x3 << 3) + +/* context specific IMPLICIT */ +#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT + +/* context specific EXPLICIT */ +#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT + +/* If tagging is in force these determine the + * type of tag to use. Otherwise the tag is + * determined by the underlying type. These + * values reflect the actual octet format. + */ + +/* Universal tag */ +#define ASN1_TFLG_UNIVERSAL (0x0<<6) +/* Application tag */ +#define ASN1_TFLG_APPLICATION (0x1<<6) +/* Context specific tag */ +#define ASN1_TFLG_CONTEXT (0x2<<6) +/* Private tag */ +#define ASN1_TFLG_PRIVATE (0x3<<6) + +#define ASN1_TFLG_TAG_CLASS (0x3<<6) + +/* These are for ANY DEFINED BY type. In this case + * the 'item' field points to an ASN1_ADB structure + * which contains a table of values to decode the + * relevant type + */ + +#define ASN1_TFLG_ADB_MASK (0x3<<8) + +#define ASN1_TFLG_ADB_OID (0x1<<8) + +#define ASN1_TFLG_ADB_INT (0x1<<9) + +/* This flag means a parent structure is passed + * instead of the field: this is useful is a + * SEQUENCE is being combined with a CHOICE for + * example. Since this means the structure and + * item name will differ we need to use the + * ASN1_CHOICE_END_name() macro for example. + */ + +#define ASN1_TFLG_COMBINE (0x1<<10) + +/* This flag when present in a SEQUENCE OF, SET OF + * or EXPLICIT causes indefinite length constructed + * encoding to be used if required. + */ + +#define ASN1_TFLG_NDEF (0x1<<11) + +/* This is the actual ASN1 item itself */ + +struct ASN1_ITEM_st { +char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */ +long utype; /* underlying type */ +const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */ +long tcount; /* Number of templates if SEQUENCE or CHOICE */ +const void *funcs; /* functions that handle this type */ +long size; /* Structure size (usually)*/ +#ifndef NO_ASN1_FIELD_NAMES +const char *sname; /* Structure name */ +#endif +}; + +/* These are values for the itype field and + * determine how the type is interpreted. + * + * For PRIMITIVE types the underlying type + * determines the behaviour if items is NULL. + * + * Otherwise templates must contain a single + * template and the type is treated in the + * same way as the type specified in the template. + * + * For SEQUENCE types the templates field points + * to the members, the size field is the + * structure size. + * + * For CHOICE types the templates field points + * to each possible member (typically a union) + * and the 'size' field is the offset of the + * selector. + * + * The 'funcs' field is used for application + * specific functions. + * + * For COMPAT types the funcs field gives a + * set of functions that handle this type, this + * supports the old d2i, i2d convention. + * + * The EXTERN type uses a new style d2i/i2d. + * The new style should be used where possible + * because it avoids things like the d2i IMPLICIT + * hack. + * + * MSTRING is a multiple string type, it is used + * for a CHOICE of character strings where the + * actual strings all occupy an ASN1_STRING + * structure. In this case the 'utype' field + * has a special meaning, it is used as a mask + * of acceptable types using the B_ASN1 constants. + * + * NDEF_SEQUENCE is the same as SEQUENCE except + * that it will use indefinite length constructed + * encoding if requested. + * + */ + +#define ASN1_ITYPE_PRIMITIVE 0x0 + +#define ASN1_ITYPE_SEQUENCE 0x1 + +#define ASN1_ITYPE_CHOICE 0x2 + +#define ASN1_ITYPE_COMPAT 0x3 + +#define ASN1_ITYPE_EXTERN 0x4 + +#define ASN1_ITYPE_MSTRING 0x5 + +#define ASN1_ITYPE_NDEF_SEQUENCE 0x6 + +/* Cache for ASN1 tag and length, so we + * don't keep re-reading it for things + * like CHOICE + */ + +struct ASN1_TLC_st{ + char valid; /* Values below are valid */ + int ret; /* return value */ + long plen; /* length */ + int ptag; /* class value */ + int pclass; /* class value */ + int hdrlen; /* header length */ +}; + +/* Typedefs for ASN1 function pointers */ + +typedef ASN1_VALUE * ASN1_new_func(void); +typedef void ASN1_free_func(ASN1_VALUE *a); +typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length); +typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in); + +typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); +typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); + +typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +typedef struct ASN1_COMPAT_FUNCS_st { + ASN1_new_func *asn1_new; + ASN1_free_func *asn1_free; + ASN1_d2i_func *asn1_d2i; + ASN1_i2d_func *asn1_i2d; +} ASN1_COMPAT_FUNCS; + +typedef struct ASN1_EXTERN_FUNCS_st { + void *app_data; + ASN1_ex_new_func *asn1_ex_new; + ASN1_ex_free_func *asn1_ex_free; + ASN1_ex_free_func *asn1_ex_clear; + ASN1_ex_d2i *asn1_ex_d2i; + ASN1_ex_i2d *asn1_ex_i2d; +} ASN1_EXTERN_FUNCS; + +typedef struct ASN1_PRIMITIVE_FUNCS_st { + void *app_data; + unsigned long flags; + ASN1_ex_new_func *prim_new; + ASN1_ex_free_func *prim_free; + ASN1_ex_free_func *prim_clear; + ASN1_primitive_c2i *prim_c2i; + ASN1_primitive_i2c *prim_i2c; +} ASN1_PRIMITIVE_FUNCS; + +/* This is the ASN1_AUX structure: it handles various + * miscellaneous requirements. For example the use of + * reference counts and an informational callback. + * + * The "informational callback" is called at various + * points during the ASN1 encoding and decoding. It can + * be used to provide minor customisation of the structures + * used. This is most useful where the supplied routines + * *almost* do the right thing but need some extra help + * at a few points. If the callback returns zero then + * it is assumed a fatal error has occurred and the + * main operation should be abandoned. + * + * If major changes in the default behaviour are required + * then an external type is more appropriate. + */ + +typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it); + +typedef struct ASN1_AUX_st { + void *app_data; + int flags; + int ref_offset; /* Offset of reference value */ + int ref_lock; /* Lock type to use */ + ASN1_aux_cb *asn1_cb; + int enc_offset; /* Offset of ASN1_ENCODING structure */ +} ASN1_AUX; + +/* Flags in ASN1_AUX */ + +/* Use a reference count */ +#define ASN1_AFLG_REFCOUNT 1 +/* Save the encoding of structure (useful for signatures) */ +#define ASN1_AFLG_ENCODING 2 +/* The Sequence length is invalid */ +#define ASN1_AFLG_BROKEN 4 + +/* operation values for asn1_cb */ + +#define ASN1_OP_NEW_PRE 0 +#define ASN1_OP_NEW_POST 1 +#define ASN1_OP_FREE_PRE 2 +#define ASN1_OP_FREE_POST 3 +#define ASN1_OP_D2I_PRE 4 +#define ASN1_OP_D2I_POST 5 +#define ASN1_OP_I2D_PRE 6 +#define ASN1_OP_I2D_POST 7 + +/* Macro to implement a primitive type */ +#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) +#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement a multi string type */ +#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ + ASN1_ITEM_start(itname) \ + ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ + ASN1_ITEM_end(itname) + +/* Macro to implement an ASN1_ITEM in terms of old style funcs */ + +#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE) + +#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \ + static const ASN1_COMPAT_FUNCS sname##_ff = { \ + (ASN1_new_func *)sname##_new, \ + (ASN1_free_func *)sname##_free, \ + (ASN1_d2i_func *)d2i_##sname, \ + (ASN1_i2d_func *)i2d_##sname, \ + }; \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_COMPAT, \ + tag, \ + NULL, \ + 0, \ + &sname##_ff, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ + ASN1_ITEM_start(sname) \ + ASN1_ITYPE_EXTERN, \ + tag, \ + NULL, \ + 0, \ + &fptrs, \ + 0, \ + #sname \ + ASN1_ITEM_end(sname) + +/* Macro to implement standard functions in terms of ASN1_ITEM structures */ + +#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) + +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ + stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ + int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ + { \ + return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ + } + +/* This includes evil casts to remove const: they will go away when full + * ASN1 constification is done. + */ +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ + } \ + int i2d_##fname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ + } + +#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ + stname * stname##_dup(stname *x) \ + { \ + return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ + } + +#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ + IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) + +#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) + +/* external definitions for primitive types */ + +DECLARE_ASN1_ITEM(ASN1_BOOLEAN) +DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) +DECLARE_ASN1_ITEM(ASN1_SEQUENCE) +DECLARE_ASN1_ITEM(CBIGNUM) +DECLARE_ASN1_ITEM(BIGNUM) +DECLARE_ASN1_ITEM(LONG) +DECLARE_ASN1_ITEM(ZLONG) + +DECLARE_STACK_OF(ASN1_VALUE) + +/* Functions used internally by the ASN1 code */ + +int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); + +void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + +int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); +int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); +void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); + +int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); +int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); + +int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); + +ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + +const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr); + +int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); + +void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); +void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/bio.h b/libraries/external/openssl/pc/include/openssl/bio.h new file mode 100755 index 0000000..385ec12 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/bio.h @@ -0,0 +1,775 @@ +/* crypto/bio/bio.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BIO_H +#define HEADER_BIO_H + +#include + +#ifndef OPENSSL_NO_FP_API +# include +#endif +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These are the 'types' of BIOs */ +#define BIO_TYPE_NONE 0 +#define BIO_TYPE_MEM (1|0x0400) +#define BIO_TYPE_FILE (2|0x0400) + +#define BIO_TYPE_FD (4|0x0400|0x0100) +#define BIO_TYPE_SOCKET (5|0x0400|0x0100) +#define BIO_TYPE_NULL (6|0x0400) +#define BIO_TYPE_SSL (7|0x0200) +#define BIO_TYPE_MD (8|0x0200) /* passive filter */ +#define BIO_TYPE_BUFFER (9|0x0200) /* filter */ +#define BIO_TYPE_CIPHER (10|0x0200) /* filter */ +#define BIO_TYPE_BASE64 (11|0x0200) /* filter */ +#define BIO_TYPE_CONNECT (12|0x0400|0x0100) /* socket - connect */ +#define BIO_TYPE_ACCEPT (13|0x0400|0x0100) /* socket for accept */ +#define BIO_TYPE_PROXY_CLIENT (14|0x0200) /* client proxy BIO */ +#define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ +#define BIO_TYPE_NULL_FILTER (17|0x0200) +#define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ +#define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ +#define BIO_TYPE_LINEBUFFER (20|0x0200) /* filter */ +#define BIO_TYPE_DGRAM (21|0x0400|0x0100) + +#define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ +#define BIO_TYPE_FILTER 0x0200 +#define BIO_TYPE_SOURCE_SINK 0x0400 + +/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. + * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ +#define BIO_NOCLOSE 0x00 +#define BIO_CLOSE 0x01 + +/* These are used in the following macros and are passed to + * BIO_ctrl() */ +#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ +#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ +#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ +#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ +#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ +#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ +#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ +#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ +#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ +#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ +#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ +#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ +#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ +/* callback is int cb(BIO *bio,state,ret); */ +#define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ +#define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ + +#define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ + +/* dgram BIO stuff */ +#define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ +#define BIO_CTRL_DGRAM_SET_CONNECTED 32 /* allow for an externally + * connected socket to be + * passed in */ +#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ +#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */ + +#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */ +#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */ + +/* #ifdef IP_MTU_DISCOVER */ +#define BIO_CTRL_DGRAM_MTU_DISCOVER 39 /* set DF bit on egress packets */ +/* #endif */ + +#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ +#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ +#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for + * MTU. want to use this + * if asking the kernel + * fails */ + +#define BIO_CTRL_DGRAM_MTU_EXCEEDED 43 /* check whether the MTU + * was exceed in the + * previous write + * operation */ + +#define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ + + +/* modifiers */ +#define BIO_FP_READ 0x02 +#define BIO_FP_WRITE 0x04 +#define BIO_FP_APPEND 0x08 +#define BIO_FP_TEXT 0x10 + +#define BIO_FLAGS_READ 0x01 +#define BIO_FLAGS_WRITE 0x02 +#define BIO_FLAGS_IO_SPECIAL 0x04 +#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) +#define BIO_FLAGS_SHOULD_RETRY 0x08 +#ifndef BIO_FLAGS_UPLINK +/* "UPLINK" flag denotes file descriptors provided by application. + It defaults to 0, as most platforms don't require UPLINK interface. */ +#define BIO_FLAGS_UPLINK 0 +#endif + +/* Used in BIO_gethostbyname() */ +#define BIO_GHBN_CTRL_HITS 1 +#define BIO_GHBN_CTRL_MISSES 2 +#define BIO_GHBN_CTRL_CACHE_SIZE 3 +#define BIO_GHBN_CTRL_GET_ENTRY 4 +#define BIO_GHBN_CTRL_FLUSH 5 + +/* Mostly used in the SSL BIO */ +/* Not used anymore + * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 + * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 + * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 + */ + +#define BIO_FLAGS_BASE64_NO_NL 0x100 + +/* This is used with memory BIOs: it means we shouldn't free up or change the + * data in any way. + */ +#define BIO_FLAGS_MEM_RDONLY 0x200 + +typedef struct bio_st BIO; + +void BIO_set_flags(BIO *b, int flags); +int BIO_test_flags(const BIO *b, int flags); +void BIO_clear_flags(BIO *b, int flags); + +#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) +#define BIO_set_retry_special(b) \ + BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_read(b) \ + BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_write(b) \ + BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) + +/* These are normally used internally in BIOs */ +#define BIO_clear_retry_flags(b) \ + BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) +#define BIO_get_retry_flags(b) \ + BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) + +/* These should be used by the application to tell why we should retry */ +#define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) +#define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) +#define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) +#define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) +#define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) + +/* The next three are used in conjunction with the + * BIO_should_io_special() condition. After this returns true, + * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO + * stack and return the 'reason' for the special and the offending BIO. + * Given a BIO, BIO_get_retry_reason(bio) will return the code. */ +/* Returned from the SSL bio when the certificate retrieval code had an error */ +#define BIO_RR_SSL_X509_LOOKUP 0x01 +/* Returned from the connect BIO when a connect would have blocked */ +#define BIO_RR_CONNECT 0x02 +/* Returned from the accept BIO when an accept would have blocked */ +#define BIO_RR_ACCEPT 0x03 + +/* These are passed by the BIO callback */ +#define BIO_CB_FREE 0x01 +#define BIO_CB_READ 0x02 +#define BIO_CB_WRITE 0x03 +#define BIO_CB_PUTS 0x04 +#define BIO_CB_GETS 0x05 +#define BIO_CB_CTRL 0x06 + +/* The callback is called before and after the underling operation, + * The BIO_CB_RETURN flag indicates if it is after the call */ +#define BIO_CB_RETURN 0x80 +#define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) +#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) +#define BIO_cb_post(a) ((a)&BIO_CB_RETURN) + +long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long); +void BIO_set_callback(BIO *b, + long (*callback)(struct bio_st *,int,const char *,int, long,long)); +char *BIO_get_callback_arg(const BIO *b); +void BIO_set_callback_arg(BIO *b, char *arg); + +const char * BIO_method_name(const BIO *b); +int BIO_method_type(const BIO *b); + +typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); + +#ifndef OPENSSL_SYS_WIN16 +typedef struct bio_method_st + { + int type; + const char *name; + int (*bwrite)(BIO *, const char *, int); + int (*bread)(BIO *, char *, int); + int (*bputs)(BIO *, const char *); + int (*bgets)(BIO *, char *, int); + long (*ctrl)(BIO *, int, long, void *); + int (*create)(BIO *); + int (*destroy)(BIO *); + long (*callback_ctrl)(BIO *, int, bio_info_cb *); + } BIO_METHOD; +#else +typedef struct bio_method_st + { + int type; + const char *name; + int (_far *bwrite)(); + int (_far *bread)(); + int (_far *bputs)(); + int (_far *bgets)(); + long (_far *ctrl)(); + int (_far *create)(); + int (_far *destroy)(); + long (_far *callback_ctrl)(); + } BIO_METHOD; +#endif + +struct bio_st + { + BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + long (*callback)(struct bio_st *,int,const char *,int, long,long); + char *cb_arg; /* first argument for the callback */ + + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + int references; + unsigned long num_read; + unsigned long num_write; + + CRYPTO_EX_DATA ex_data; + }; + +DECLARE_STACK_OF(BIO) + +typedef struct bio_f_buffer_ctx_struct + { + /* BIO *bio; */ /* this is now in the BIO struct */ + int ibuf_size; /* how big is the input buffer */ + int obuf_size; /* how big is the output buffer */ + + char *ibuf; /* the char array */ + int ibuf_len; /* how many bytes are in it */ + int ibuf_off; /* write/read offset */ + + char *obuf; /* the char array */ + int obuf_len; /* how many bytes are in it */ + int obuf_off; /* write/read offset */ + } BIO_F_BUFFER_CTX; + +/* connect BIO stuff */ +#define BIO_CONN_S_BEFORE 1 +#define BIO_CONN_S_GET_IP 2 +#define BIO_CONN_S_GET_PORT 3 +#define BIO_CONN_S_CREATE_SOCKET 4 +#define BIO_CONN_S_CONNECT 5 +#define BIO_CONN_S_OK 6 +#define BIO_CONN_S_BLOCKED_CONNECT 7 +#define BIO_CONN_S_NBIO 8 +/*#define BIO_CONN_get_param_hostname BIO_ctrl */ + +#define BIO_C_SET_CONNECT 100 +#define BIO_C_DO_STATE_MACHINE 101 +#define BIO_C_SET_NBIO 102 +#define BIO_C_SET_PROXY_PARAM 103 +#define BIO_C_SET_FD 104 +#define BIO_C_GET_FD 105 +#define BIO_C_SET_FILE_PTR 106 +#define BIO_C_GET_FILE_PTR 107 +#define BIO_C_SET_FILENAME 108 +#define BIO_C_SET_SSL 109 +#define BIO_C_GET_SSL 110 +#define BIO_C_SET_MD 111 +#define BIO_C_GET_MD 112 +#define BIO_C_GET_CIPHER_STATUS 113 +#define BIO_C_SET_BUF_MEM 114 +#define BIO_C_GET_BUF_MEM_PTR 115 +#define BIO_C_GET_BUFF_NUM_LINES 116 +#define BIO_C_SET_BUFF_SIZE 117 +#define BIO_C_SET_ACCEPT 118 +#define BIO_C_SSL_MODE 119 +#define BIO_C_GET_MD_CTX 120 +#define BIO_C_GET_PROXY_PARAM 121 +#define BIO_C_SET_BUFF_READ_DATA 122 /* data to read first */ +#define BIO_C_GET_CONNECT 123 +#define BIO_C_GET_ACCEPT 124 +#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 +#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 +#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 +#define BIO_C_FILE_SEEK 128 +#define BIO_C_GET_CIPHER_CTX 129 +#define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ +#define BIO_C_SET_BIND_MODE 131 +#define BIO_C_GET_BIND_MODE 132 +#define BIO_C_FILE_TELL 133 +#define BIO_C_GET_SOCKS 134 +#define BIO_C_SET_SOCKS 135 + +#define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ +#define BIO_C_GET_WRITE_BUF_SIZE 137 +#define BIO_C_MAKE_BIO_PAIR 138 +#define BIO_C_DESTROY_BIO_PAIR 139 +#define BIO_C_GET_WRITE_GUARANTEE 140 +#define BIO_C_GET_READ_REQUEST 141 +#define BIO_C_SHUTDOWN_WR 142 +#define BIO_C_NREAD0 143 +#define BIO_C_NREAD 144 +#define BIO_C_NWRITE0 145 +#define BIO_C_NWRITE 146 +#define BIO_C_RESET_READ_REQUEST 147 +#define BIO_C_SET_MD_CTX 148 + + +#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) +#define BIO_get_app_data(s) BIO_get_ex_data(s,0) + +/* BIO_s_connect() and BIO_s_socks4a_connect() */ +#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) +#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) +#define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) +#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) +#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) +#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) +#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) +#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3) + + +#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) + +/* BIO_s_accept_socket() */ +#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) +#define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) +/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ +#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) +#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) + +#define BIO_BIND_NORMAL 0 +#define BIO_BIND_REUSEADDR_IF_UNUSED 1 +#define BIO_BIND_REUSEADDR 2 +#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) +#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) + +#define BIO_do_connect(b) BIO_do_handshake(b) +#define BIO_do_accept(b) BIO_do_handshake(b) +#define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) + +/* BIO_s_proxy_client() */ +#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) +#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) +/* BIO_set_nbio(b,n) */ +#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) +/* BIO *BIO_get_filter_bio(BIO *bio); */ +#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) +#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) +#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) + +#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) +#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) +#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) +#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) + +#define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) +#define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) + +#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) +#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) + +#define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) +#define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) + +/* name is cast to lose const, but might be better to route through a function + so we can do it safely */ +#ifdef CONST_STRICT +/* If you are wondering why this isn't defined, its because CONST_STRICT is + * purely a compile-time kludge to allow const to be checked. + */ +int BIO_read_filename(BIO *b,const char *name); +#else +#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ,(char *)name) +#endif +#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_WRITE,name) +#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_APPEND,name) +#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ + BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) + +/* WARNING WARNING, this ups the reference count on the read bio of the + * SSL structure. This is because the ssl read BIO is now pointed to by + * the next_bio field in the bio. So when you free the BIO, make sure + * you are doing a BIO_free_all() to catch the underlying BIO. */ +#define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) +#define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) +#define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) +#define BIO_set_ssl_renegotiate_bytes(b,num) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); +#define BIO_get_num_renegotiates(b) \ + BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); +#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ + BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); + +/* defined in evp.h */ +/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ + +#define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) +#define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) +#define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) +#define BIO_set_mem_eof_return(b,v) \ + BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) + +/* For the BIO_f_buffer() type */ +#define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) +#define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) +#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) +#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) +#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) + +/* Don't use the next one unless you know what you are doing :-) */ +#define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) + +#define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) +#define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) +#define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) +#define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) +#define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) +#define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) +/* ...pending macros have inappropriate return type */ +size_t BIO_ctrl_pending(BIO *b); +size_t BIO_ctrl_wpending(BIO *b); +#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) +#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ + cbp) +#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) + +/* For the BIO_f_buffer() type */ +#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) + +/* For BIO_s_bio() */ +#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) +#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) +#define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) +#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) +#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) +/* macros with inappropriate type -- but ...pending macros use int too: */ +#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) +#define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) +size_t BIO_ctrl_get_write_guarantee(BIO *b); +size_t BIO_ctrl_get_read_request(BIO *b); +int BIO_ctrl_reset_read_request(BIO *b); + +/* ctrl macros for dgram */ +#define BIO_ctrl_dgram_connect(b,peer) \ + (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) +#define BIO_ctrl_set_connected(b, state, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) +#define BIO_dgram_recv_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) +#define BIO_dgram_send_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) +#define BIO_dgram_set_peer(b,peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) + +/* These two aren't currently implemented */ +/* int BIO_get_ex_num(BIO *bio); */ +/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ +int BIO_set_ex_data(BIO *bio,int idx,void *data); +void *BIO_get_ex_data(BIO *bio,int idx); +int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +unsigned long BIO_number_read(BIO *bio); +unsigned long BIO_number_written(BIO *bio); + +# ifndef OPENSSL_NO_FP_API +# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL) +BIO_METHOD *BIO_s_file_internal(void); +BIO *BIO_new_file_internal(char *filename, char *mode); +BIO *BIO_new_fp_internal(FILE *stream, int close_flag); +# define BIO_s_file BIO_s_file_internal +# define BIO_new_file BIO_new_file_internal +# define BIO_new_fp BIO_new_fp_internal +# else /* FP_API */ +BIO_METHOD *BIO_s_file(void ); +BIO *BIO_new_file(const char *filename, const char *mode); +BIO *BIO_new_fp(FILE *stream, int close_flag); +# define BIO_s_file_internal BIO_s_file +# define BIO_new_file_internal BIO_new_file +# define BIO_new_fp_internal BIO_s_file +# endif /* FP_API */ +# endif +BIO * BIO_new(BIO_METHOD *type); +int BIO_set(BIO *a,BIO_METHOD *type); +int BIO_free(BIO *a); +void BIO_vfree(BIO *a); +int BIO_read(BIO *b, void *data, int len); +int BIO_gets(BIO *bp,char *buf, int size); +int BIO_write(BIO *b, const void *data, int len); +int BIO_puts(BIO *bp,const char *buf); +int BIO_indent(BIO *b,int indent,int max); +long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); +long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); +char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); +long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); +BIO * BIO_push(BIO *b,BIO *append); +BIO * BIO_pop(BIO *b); +void BIO_free_all(BIO *a); +BIO * BIO_find_type(BIO *b,int bio_type); +BIO * BIO_next(BIO *b); +BIO * BIO_get_retry_BIO(BIO *bio, int *reason); +int BIO_get_retry_reason(BIO *bio); +BIO * BIO_dup_chain(BIO *in); + +int BIO_nread0(BIO *bio, char **buf); +int BIO_nread(BIO *bio, char **buf, int num); +int BIO_nwrite0(BIO *bio, char **buf); +int BIO_nwrite(BIO *bio, char **buf, int num); + +#ifndef OPENSSL_SYS_WIN16 +long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#else +long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, + long argl,long ret); +#endif + +BIO_METHOD *BIO_s_mem(void); +BIO *BIO_new_mem_buf(void *buf, int len); +BIO_METHOD *BIO_s_socket(void); +BIO_METHOD *BIO_s_connect(void); +BIO_METHOD *BIO_s_accept(void); +BIO_METHOD *BIO_s_fd(void); +#ifndef OPENSSL_SYS_OS2 +BIO_METHOD *BIO_s_log(void); +#endif +BIO_METHOD *BIO_s_bio(void); +BIO_METHOD *BIO_s_null(void); +BIO_METHOD *BIO_f_null(void); +BIO_METHOD *BIO_f_buffer(void); +#ifdef OPENSSL_SYS_VMS +BIO_METHOD *BIO_f_linebuffer(void); +#endif +BIO_METHOD *BIO_f_nbio_test(void); +#ifndef OPENSSL_NO_DGRAM +BIO_METHOD *BIO_s_datagram(void); +#endif + +/* BIO_METHOD *BIO_f_ber(void); */ + +int BIO_sock_should_retry(int i); +int BIO_sock_non_fatal_error(int error); +int BIO_dgram_non_fatal_error(int error); + +int BIO_fd_should_retry(int i); +int BIO_fd_non_fatal_error(int error); +int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len); +int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const char *s, int len, int indent); +int BIO_dump(BIO *b,const char *bytes,int len); +int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent); +#ifndef OPENSSL_NO_FP_API +int BIO_dump_fp(FILE *fp, const char *s, int len); +int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); +#endif +struct hostent *BIO_gethostbyname(const char *name); +/* We might want a thread-safe interface too: + * struct hostent *BIO_gethostbyname_r(const char *name, + * struct hostent *result, void *buffer, size_t buflen); + * or something similar (caller allocates a struct hostent, + * pointed to by "result", and additional buffer space for the various + * substructures; if the buffer does not suffice, NULL is returned + * and an appropriate error code is set). + */ +int BIO_sock_error(int sock); +int BIO_socket_ioctl(int fd, long type, void *arg); +int BIO_socket_nbio(int fd,int mode); +int BIO_get_port(const char *str, unsigned short *port_ptr); +int BIO_get_host_ip(const char *str, unsigned char *ip); +int BIO_get_accept_socket(char *host_port,int mode); +int BIO_accept(int sock,char **ip_port); +int BIO_sock_init(void ); +void BIO_sock_cleanup(void); +int BIO_set_tcp_ndelay(int sock,int turn_on); + +BIO *BIO_new_socket(int sock, int close_flag); +BIO *BIO_new_dgram(int fd, int close_flag); +BIO *BIO_new_fd(int fd, int close_flag); +BIO *BIO_new_connect(char *host_port); +BIO *BIO_new_accept(char *host_port); + +int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, + BIO **bio2, size_t writebuf2); +/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. + * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. + * Size 0 uses default value. + */ + +void BIO_copy_next_retry(BIO *b); + +/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ + +#ifdef __GNUC__ +# define __bio_h__attr__ __attribute__ +#else +# define __bio_h__attr__(x) +#endif +int BIO_printf(BIO *bio, const char *format, ...) + __bio_h__attr__((__format__(__printf__,2,3))); +int BIO_vprintf(BIO *bio, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,2,0))); +int BIO_snprintf(char *buf, size_t n, const char *format, ...) + __bio_h__attr__((__format__(__printf__,3,4))); +int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) + __bio_h__attr__((__format__(__printf__,3,0))); +#undef __bio_h__attr__ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BIO_strings(void); + +/* Error codes for the BIO functions. */ + +/* Function codes. */ +#define BIO_F_ACPT_STATE 100 +#define BIO_F_BIO_ACCEPT 101 +#define BIO_F_BIO_BER_GET_HEADER 102 +#define BIO_F_BIO_CALLBACK_CTRL 131 +#define BIO_F_BIO_CTRL 103 +#define BIO_F_BIO_GETHOSTBYNAME 120 +#define BIO_F_BIO_GETS 104 +#define BIO_F_BIO_GET_ACCEPT_SOCKET 105 +#define BIO_F_BIO_GET_HOST_IP 106 +#define BIO_F_BIO_GET_PORT 107 +#define BIO_F_BIO_MAKE_PAIR 121 +#define BIO_F_BIO_NEW 108 +#define BIO_F_BIO_NEW_FILE 109 +#define BIO_F_BIO_NEW_MEM_BUF 126 +#define BIO_F_BIO_NREAD 123 +#define BIO_F_BIO_NREAD0 124 +#define BIO_F_BIO_NWRITE 125 +#define BIO_F_BIO_NWRITE0 122 +#define BIO_F_BIO_PUTS 110 +#define BIO_F_BIO_READ 111 +#define BIO_F_BIO_SOCK_INIT 112 +#define BIO_F_BIO_WRITE 113 +#define BIO_F_BUFFER_CTRL 114 +#define BIO_F_CONN_CTRL 127 +#define BIO_F_CONN_STATE 115 +#define BIO_F_FILE_CTRL 116 +#define BIO_F_FILE_READ 130 +#define BIO_F_LINEBUFFER_CTRL 129 +#define BIO_F_MEM_READ 128 +#define BIO_F_MEM_WRITE 117 +#define BIO_F_SSL_NEW 118 +#define BIO_F_WSASTARTUP 119 + +/* Reason codes. */ +#define BIO_R_ACCEPT_ERROR 100 +#define BIO_R_BAD_FOPEN_MODE 101 +#define BIO_R_BAD_HOSTNAME_LOOKUP 102 +#define BIO_R_BROKEN_PIPE 124 +#define BIO_R_CONNECT_ERROR 103 +#define BIO_R_EOF_ON_MEMORY_BIO 127 +#define BIO_R_ERROR_SETTING_NBIO 104 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 +#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 +#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 +#define BIO_R_INVALID_ARGUMENT 125 +#define BIO_R_INVALID_IP_ADDRESS 108 +#define BIO_R_IN_USE 123 +#define BIO_R_KEEPALIVE 109 +#define BIO_R_NBIO_CONNECT_ERROR 110 +#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 +#define BIO_R_NO_HOSTNAME_SPECIFIED 112 +#define BIO_R_NO_PORT_DEFINED 113 +#define BIO_R_NO_PORT_SPECIFIED 114 +#define BIO_R_NO_SUCH_FILE 128 +#define BIO_R_NULL_PARAMETER 115 +#define BIO_R_TAG_MISMATCH 116 +#define BIO_R_UNABLE_TO_BIND_SOCKET 117 +#define BIO_R_UNABLE_TO_CREATE_SOCKET 118 +#define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 +#define BIO_R_UNINITIALIZED 120 +#define BIO_R_UNSUPPORTED_METHOD 121 +#define BIO_R_WRITE_TO_READ_ONLY_BIO 126 +#define BIO_R_WSASTARTUP 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/blowfish.h b/libraries/external/openssl/pc/include/openssl/blowfish.h new file mode 100755 index 0000000..ec7b869 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/blowfish.h @@ -0,0 +1,127 @@ +/* crypto/bf/blowfish.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BLOWFISH_H +#define HEADER_BLOWFISH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_BF +#error BF is disabled. +#endif + +#define BF_ENCRYPT 1 +#define BF_DECRYPT 0 + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! BF_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define BF_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define BF_LONG unsigned long +#define BF_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define BF_LONG unsigned int +#endif + +#define BF_ROUNDS 16 +#define BF_BLOCK 8 + +typedef struct bf_key_st + { + BF_LONG P[BF_ROUNDS+2]; + BF_LONG S[4*256]; + } BF_KEY; + + +void BF_set_key(BF_KEY *key, int len, const unsigned char *data); + +void BF_encrypt(BF_LONG *data,const BF_KEY *key); +void BF_decrypt(BF_LONG *data,const BF_KEY *key); + +void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int enc); +void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int enc); +void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); +void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num); +const char *BF_options(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/bn.h b/libraries/external/openssl/pc/include/openssl/bn.h new file mode 100755 index 0000000..8c800ee --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/bn.h @@ -0,0 +1,827 @@ +/* crypto/bn/bn.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the Eric Young open source + * license provided above. + * + * The binary polynomial arithmetic software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_BN_H +#define HEADER_BN_H + +#include +#ifndef OPENSSL_NO_FP_API +#include /* FILE */ +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These preprocessor symbols control various aspects of the bignum headers and + * library code. They're not defined by any "normal" configuration, as they are + * intended for development and testing purposes. NB: defining all three can be + * useful for debugging application code as well as openssl itself. + * + * BN_DEBUG - turn on various debugging alterations to the bignum code + * BN_DEBUG_RAND - uses random poisoning of unused words to trip up + * mismanagement of bignum internals. You must also define BN_DEBUG. + */ +/* #define BN_DEBUG */ +/* #define BN_DEBUG_RAND */ + +#define BN_MUL_COMBA +#define BN_SQR_COMBA +#define BN_RECURSION + +/* This next option uses the C libraries (2 word)/(1 word) function. + * If it is not defined, I use my C version (which is slower). + * The reason for this flag is that when the particular C compiler + * library routine is used, and the library is linked with a different + * compiler, the library is missing. This mostly happens when the + * library is built with gcc and then linked using normal cc. This would + * be a common occurrence because gcc normally produces code that is + * 2 times faster than system compilers for the big number stuff. + * For machines with only one compiler (or shared libraries), this should + * be on. Again this in only really a problem on machines + * using "long long's", are 32bit, and are not using my assembler code. */ +#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ + defined(OPENSSL_SYS_WIN32) || defined(linux) +# ifndef BN_DIV2W +# define BN_DIV2W +# endif +#endif + +/* assuming long is 64bit - this is the DEC Alpha + * unsigned long long is only 64 bits :-(, don't define + * BN_LLONG for the DEC Alpha */ +#ifdef SIXTY_FOUR_BIT_LONG +#define BN_ULLONG unsigned long long +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK (0xffffffffffffffffffffffffffffffffLL) +#define BN_MASK2 (0xffffffffffffffffL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000L) +#define BN_MASK2h1 (0xffffffff80000000L) +#define BN_TBIT (0x8000000000000000L) +#define BN_DEC_CONV (10000000000000000000UL) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%019lu" +#define BN_DEC_NUM 19 +#endif + +/* This is where the long long data type is 64 bits, but long is 32. + * For machines where there are 64bit registers, this is the mode to use. + * IRIX, on R4000 and above should use this mode, along with the relevant + * assembler code :-). Do NOT define BN_LLONG. + */ +#ifdef SIXTY_FOUR_BIT +#undef BN_LLONG +#undef BN_ULLONG +#define BN_ULONG unsigned long long +#define BN_LONG long long +#define BN_BITS 128 +#define BN_BYTES 8 +#define BN_BITS2 64 +#define BN_BITS4 32 +#define BN_MASK2 (0xffffffffffffffffLL) +#define BN_MASK2l (0xffffffffL) +#define BN_MASK2h (0xffffffff00000000LL) +#define BN_MASK2h1 (0xffffffff80000000LL) +#define BN_TBIT (0x8000000000000000LL) +#define BN_DEC_CONV (10000000000000000000ULL) +#define BN_DEC_FMT1 "%llu" +#define BN_DEC_FMT2 "%019llu" +#define BN_DEC_NUM 19 +#endif + +#ifdef THIRTY_TWO_BIT +#ifdef BN_LLONG +# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) +# define BN_ULLONG unsigned __int64 +# else +# define BN_ULLONG unsigned long long +# endif +#endif +#define BN_ULONG unsigned long +#define BN_LONG long +#define BN_BITS 64 +#define BN_BYTES 4 +#define BN_BITS2 32 +#define BN_BITS4 16 +#ifdef OPENSSL_SYS_WIN32 +/* VC++ doesn't like the LL suffix */ +#define BN_MASK (0xffffffffffffffffL) +#else +#define BN_MASK (0xffffffffffffffffLL) +#endif +#define BN_MASK2 (0xffffffffL) +#define BN_MASK2l (0xffff) +#define BN_MASK2h1 (0xffff8000L) +#define BN_MASK2h (0xffff0000L) +#define BN_TBIT (0x80000000L) +#define BN_DEC_CONV (1000000000L) +#define BN_DEC_FMT1 "%lu" +#define BN_DEC_FMT2 "%09lu" +#define BN_DEC_NUM 9 +#endif + +#ifdef SIXTEEN_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned long +#define BN_ULONG unsigned short +#define BN_LONG short +#define BN_BITS 32 +#define BN_BYTES 2 +#define BN_BITS2 16 +#define BN_BITS4 8 +#define BN_MASK (0xffffffff) +#define BN_MASK2 (0xffff) +#define BN_MASK2l (0xff) +#define BN_MASK2h1 (0xff80) +#define BN_MASK2h (0xff00) +#define BN_TBIT (0x8000) +#define BN_DEC_CONV (100000) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%05u" +#define BN_DEC_NUM 5 +#endif + +#ifdef EIGHT_BIT +#ifndef BN_DIV2W +#define BN_DIV2W +#endif +#define BN_ULLONG unsigned short +#define BN_ULONG unsigned char +#define BN_LONG char +#define BN_BITS 16 +#define BN_BYTES 1 +#define BN_BITS2 8 +#define BN_BITS4 4 +#define BN_MASK (0xffff) +#define BN_MASK2 (0xff) +#define BN_MASK2l (0xf) +#define BN_MASK2h1 (0xf8) +#define BN_MASK2h (0xf0) +#define BN_TBIT (0x80) +#define BN_DEC_CONV (100) +#define BN_DEC_FMT1 "%u" +#define BN_DEC_FMT2 "%02u" +#define BN_DEC_NUM 2 +#endif + +#define BN_DEFAULT_BITS 1280 + +#define BN_FLG_MALLOCED 0x01 +#define BN_FLG_STATIC_DATA 0x02 +#define BN_FLG_EXP_CONSTTIME 0x04 /* avoid leaking exponent information through timings + * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ +#ifndef OPENSSL_NO_DEPRECATED +#define BN_FLG_FREE 0x8000 /* used for debuging */ +#endif +#define BN_set_flags(b,n) ((b)->flags|=(n)) +#define BN_get_flags(b,n) ((b)->flags&(n)) + +/* get a clone of a BIGNUM with changed flags, for *temporary* use only + * (the two BIGNUMs cannot not be used in parallel!) */ +#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ + (dest)->top=(b)->top, \ + (dest)->dmax=(b)->dmax, \ + (dest)->neg=(b)->neg, \ + (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ + | ((b)->flags & ~BN_FLG_MALLOCED) \ + | BN_FLG_STATIC_DATA \ + | (n))) + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct bignum_st BIGNUM; +/* Used for temp variables (declaration hidden in bn_lcl.h) */ +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; +#endif + +struct bignum_st + { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int dmax; /* Size of the d array. */ + int neg; /* one if the number is negative */ + int flags; + }; + +/* Used for montgomery multiplication */ +struct bn_mont_ctx_st + { + int ri; /* number of bits in R */ + BIGNUM RR; /* used to convert to montgomery form */ + BIGNUM N; /* The modulus */ + BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 + * (Ni is only stored for bignum algorithm) */ + BN_ULONG n0; /* least significant word of Ni */ + int flags; + }; + +/* Used for reciprocal division/mod functions + * It cannot be shared between threads + */ +struct bn_recp_ctx_st + { + BIGNUM N; /* the divisor */ + BIGNUM Nr; /* the reciprocal */ + int num_bits; + int shift; + int flags; + }; + +/* Used for slow "generation" functions. */ +struct bn_gencb_st + { + unsigned int ver; /* To handle binary (in)compatibility */ + void *arg; /* callback-specific data */ + union + { + /* if(ver==1) - handles old style callbacks */ + void (*cb_1)(int, int, void *); + /* if(ver==2) - new callback style */ + int (*cb_2)(int, int, BN_GENCB *); + } cb; + }; +/* Wrapper function to make using BN_GENCB easier, */ +int BN_GENCB_call(BN_GENCB *cb, int a, int b); +/* Macro to populate a BN_GENCB structure with an "old"-style callback */ +#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 1; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_1 = (callback); } +/* Macro to populate a BN_GENCB structure with a "new"-style callback */ +#define BN_GENCB_set(gencb, callback, cb_arg) { \ + BN_GENCB *tmp_gencb = (gencb); \ + tmp_gencb->ver = 2; \ + tmp_gencb->arg = (cb_arg); \ + tmp_gencb->cb.cb_2 = (callback); } + +#define BN_prime_checks 0 /* default: select number of iterations + based on the size of the number */ + +/* number of Miller-Rabin iterations for an error rate of less than 2^-80 + * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook + * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; + * original paper: Damgaard, Landrock, Pomerance: Average case error estimates + * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */ +#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ + (b) >= 850 ? 3 : \ + (b) >= 650 ? 4 : \ + (b) >= 550 ? 5 : \ + (b) >= 450 ? 6 : \ + (b) >= 400 ? 7 : \ + (b) >= 350 ? 8 : \ + (b) >= 300 ? 9 : \ + (b) >= 250 ? 12 : \ + (b) >= 200 ? 15 : \ + (b) >= 150 ? 18 : \ + /* b >= 100 */ 27) + +#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) + +/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ +#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ + (((w) == 0) && ((a)->top == 0))) +#define BN_is_zero(a) ((a)->top == 0) +#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) +#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) +#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) + +#define BN_one(a) (BN_set_word((a),1)) +#define BN_zero_ex(a) \ + do { \ + BIGNUM *_tmp_bn = (a); \ + _tmp_bn->top = 0; \ + _tmp_bn->neg = 0; \ + } while(0) +#ifdef OPENSSL_NO_DEPRECATED +#define BN_zero(a) BN_zero_ex(a) +#else +#define BN_zero(a) (BN_set_word((a),0)) +#endif + +const BIGNUM *BN_value_one(void); +char * BN_options(void); +BN_CTX *BN_CTX_new(void); +#ifndef OPENSSL_NO_DEPRECATED +void BN_CTX_init(BN_CTX *c); +#endif +void BN_CTX_free(BN_CTX *c); +void BN_CTX_start(BN_CTX *ctx); +BIGNUM *BN_CTX_get(BN_CTX *ctx); +void BN_CTX_end(BN_CTX *ctx); +int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_num_bits(const BIGNUM *a); +int BN_num_bits_word(BN_ULONG); +BIGNUM *BN_new(void); +void BN_init(BIGNUM *); +void BN_clear_free(BIGNUM *a); +BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); +void BN_swap(BIGNUM *a, BIGNUM *b); +BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2bin(const BIGNUM *a, unsigned char *to); +BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); +int BN_bn2mpi(const BIGNUM *a, unsigned char *to); +int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); +int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); +/** BN_set_negative sets sign of a BIGNUM + * \param b pointer to the BIGNUM object + * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise + */ +void BN_set_negative(BIGNUM *b, int n); +/** BN_is_negative returns 1 if the BIGNUM is negative + * \param a pointer to the BIGNUM object + * \return 1 if a < 0 and 0 otherwise + */ +#define BN_is_negative(a) ((a)->neg != 0) + +int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); +#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) +int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); +int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); + +BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); +int BN_mul_word(BIGNUM *a, BN_ULONG w); +int BN_add_word(BIGNUM *a, BN_ULONG w); +int BN_sub_word(BIGNUM *a, BN_ULONG w); +int BN_set_word(BIGNUM *a, BN_ULONG w); +BN_ULONG BN_get_word(const BIGNUM *a); + +int BN_cmp(const BIGNUM *a, const BIGNUM *b); +void BN_free(BIGNUM *a); +int BN_is_bit_set(const BIGNUM *a, int n); +int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_lshift1(BIGNUM *r, const BIGNUM *a); +int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); + +int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); +int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, + BN_CTX *ctx,BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m,BN_CTX *ctx); + +int BN_mask_bits(BIGNUM *a,int n); +#ifndef OPENSSL_NO_FP_API +int BN_print_fp(FILE *fp, const BIGNUM *a); +#endif +#ifdef HEADER_BIO_H +int BN_print(BIO *fp, const BIGNUM *a); +#else +int BN_print(void *fp, const BIGNUM *a); +#endif +int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); +int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); +int BN_rshift1(BIGNUM *r, const BIGNUM *a); +void BN_clear(BIGNUM *a); +BIGNUM *BN_dup(const BIGNUM *a); +int BN_ucmp(const BIGNUM *a, const BIGNUM *b); +int BN_set_bit(BIGNUM *a, int n); +int BN_clear_bit(BIGNUM *a, int n); +char * BN_bn2hex(const BIGNUM *a); +char * BN_bn2dec(const BIGNUM *a); +int BN_hex2bn(BIGNUM **a, const char *str); +int BN_dec2bn(BIGNUM **a, const char *str); +int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); +int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ +BIGNUM *BN_mod_inverse(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); +BIGNUM *BN_mod_sqrt(BIGNUM *ret, + const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); + +/* Deprecated versions */ +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, + const BIGNUM *add, const BIGNUM *rem, + void (*callback)(int,int,void *),void *cb_arg); +int BN_is_prime(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *), + BN_CTX *ctx,void *cb_arg); +int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, + void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, + int do_trial_division); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* Newer versions */ +int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); +int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); +int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, + int do_trial_division, BN_GENCB *cb); + +BN_MONT_CTX *BN_MONT_CTX_new(void ); +void BN_MONT_CTX_init(BN_MONT_CTX *ctx); +int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ + (r),(a),&((mont)->RR),(mont),(ctx)) +int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, + BN_MONT_CTX *mont, BN_CTX *ctx); +void BN_MONT_CTX_free(BN_MONT_CTX *mont); +int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx); +BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); +BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, + const BIGNUM *mod, BN_CTX *ctx); + +/* BN_BLINDING flags */ +#define BN_BLINDING_NO_UPDATE 0x00000001 +#define BN_BLINDING_NO_RECREATE 0x00000002 + +BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); +void BN_BLINDING_free(BN_BLINDING *b); +int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); +int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); +int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); +unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); +void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); +unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); +void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); +BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, + const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); + +#ifndef OPENSSL_NO_DEPRECATED +void BN_set_params(int mul,int high,int low,int mont); +int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ +#endif + +void BN_RECP_CTX_init(BN_RECP_CTX *recp); +BN_RECP_CTX *BN_RECP_CTX_new(void); +void BN_RECP_CTX_free(BN_RECP_CTX *recp); +int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); +int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, + BN_RECP_CTX *recp,BN_CTX *ctx); +int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, + BN_RECP_CTX *recp, BN_CTX *ctx); + +/* Functions for arithmetic over binary polynomials represented by BIGNUMs. + * + * The BIGNUM::neg property of BIGNUMs representing binary polynomials is + * ignored. + * + * Note that input arguments are not const so that their bit arrays can + * be expanded to the appropriate size if needed. + */ + +int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/ +#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) +int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/ +int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); /* r^2 + r = a mod p */ +#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) +/* Some functions allow for representation of the irreducible polynomials + * as an unsigned int[], say p. The irreducible f(t) is then of the form: + * t^p[0] + t^p[1] + ... + t^p[k] + * where m = p[0] > p[1] > ... > p[k] = 0. + */ +int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); + /* r = a mod p */ +int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ +int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], + BN_CTX *ctx); /* r = (a * a) mod p */ +int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], + BN_CTX *ctx); /* r = (1 / b) mod p */ +int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ +int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ +int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ +int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, + const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ +int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); +int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); + +/* faster mod functions for the 'NIST primes' + * 0 <= a < p^2 */ +int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); +int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); + +const BIGNUM *BN_get0_nist_prime_192(void); +const BIGNUM *BN_get0_nist_prime_224(void); +const BIGNUM *BN_get0_nist_prime_256(void); +const BIGNUM *BN_get0_nist_prime_384(void); +const BIGNUM *BN_get0_nist_prime_521(void); + +/* library internal functions */ + +#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ + (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) +#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) +BIGNUM *bn_expand2(BIGNUM *a, int words); +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ +#endif + +/* Bignum consistency macros + * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from + * bignum data after direct manipulations on the data. There is also an + * "internal" macro, bn_check_top(), for verifying that there are no leading + * zeroes. Unfortunately, some auditing is required due to the fact that + * bn_fix_top() has become an overabused duct-tape because bignum data is + * occasionally passed around in an inconsistent state. So the following + * changes have been made to sort this out; + * - bn_fix_top()s implementation has been moved to bn_correct_top() + * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and + * bn_check_top() is as before. + * - if BN_DEBUG *is* defined; + * - bn_check_top() tries to pollute unused words even if the bignum 'top' is + * consistent. (ed: only if BN_DEBUG_RAND is defined) + * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. + * The idea is to have debug builds flag up inconsistent bignums when they + * occur. If that occurs in a bn_fix_top(), we examine the code in question; if + * the use of bn_fix_top() was appropriate (ie. it follows directly after code + * that manipulates the bignum) it is converted to bn_correct_top(), and if it + * was not appropriate, we convert it permanently to bn_check_top() and track + * down the cause of the bug. Eventually, no internal code should be using the + * bn_fix_top() macro. External applications and libraries should try this with + * their own code too, both in terms of building against the openssl headers + * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it + * defined. This not only improves external code, it provides more test + * coverage for openssl's own code. + */ + +#ifdef BN_DEBUG + +/* We only need assert() when debugging */ +#include + +#ifdef BN_DEBUG_RAND +/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */ +#ifndef RAND_pseudo_bytes +int RAND_pseudo_bytes(unsigned char *buf,int num); +#define BN_DEBUG_TRIX +#endif +#define bn_pollute(a) \ + do { \ + const BIGNUM *_bnum1 = (a); \ + if(_bnum1->top < _bnum1->dmax) { \ + unsigned char _tmp_char; \ + /* We cast away const without the compiler knowing, any \ + * *genuinely* constant variables that aren't mutable \ + * wouldn't be constructed with top!=dmax. */ \ + BN_ULONG *_not_const; \ + memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ + RAND_pseudo_bytes(&_tmp_char, 1); \ + memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ + (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ + } \ + } while(0) +#ifdef BN_DEBUG_TRIX +#undef RAND_pseudo_bytes +#endif +#else +#define bn_pollute(a) +#endif +#define bn_check_top(a) \ + do { \ + const BIGNUM *_bnum2 = (a); \ + if (_bnum2 != NULL) { \ + assert((_bnum2->top == 0) || \ + (_bnum2->d[_bnum2->top - 1] != 0)); \ + bn_pollute(_bnum2); \ + } \ + } while(0) + +#define bn_fix_top(a) bn_check_top(a) + +#else /* !BN_DEBUG */ + +#define bn_pollute(a) +#define bn_check_top(a) +#define bn_fix_top(a) bn_correct_top(a) + +#endif + +#define bn_correct_top(a) \ + { \ + BN_ULONG *ftl; \ + if ((a)->top > 0) \ + { \ + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(ftl--)) break; \ + } \ + bn_pollute(a); \ + } + +BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); +void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); +BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); +BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); +BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); + +/* Primes from RFC 2409 */ +BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); +BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); + +/* Primes from RFC 3526 */ +BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn); +BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn); + +int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BN_strings(void); + +/* Error codes for the BN functions. */ + +/* Function codes. */ +#define BN_F_BNRAND 127 +#define BN_F_BN_BLINDING_CONVERT_EX 100 +#define BN_F_BN_BLINDING_CREATE_PARAM 128 +#define BN_F_BN_BLINDING_INVERT_EX 101 +#define BN_F_BN_BLINDING_NEW 102 +#define BN_F_BN_BLINDING_UPDATE 103 +#define BN_F_BN_BN2DEC 104 +#define BN_F_BN_BN2HEX 105 +#define BN_F_BN_CTX_GET 116 +#define BN_F_BN_CTX_NEW 106 +#define BN_F_BN_CTX_START 129 +#define BN_F_BN_DIV 107 +#define BN_F_BN_DIV_RECP 130 +#define BN_F_BN_EXP 123 +#define BN_F_BN_EXPAND2 108 +#define BN_F_BN_EXPAND_INTERNAL 120 +#define BN_F_BN_GF2M_MOD 131 +#define BN_F_BN_GF2M_MOD_EXP 132 +#define BN_F_BN_GF2M_MOD_MUL 133 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 +#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 +#define BN_F_BN_GF2M_MOD_SQR 136 +#define BN_F_BN_GF2M_MOD_SQRT 137 +#define BN_F_BN_MOD_EXP2_MONT 118 +#define BN_F_BN_MOD_EXP_MONT 109 +#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 +#define BN_F_BN_MOD_EXP_MONT_WORD 117 +#define BN_F_BN_MOD_EXP_RECP 125 +#define BN_F_BN_MOD_EXP_SIMPLE 126 +#define BN_F_BN_MOD_INVERSE 110 +#define BN_F_BN_MOD_LSHIFT_QUICK 119 +#define BN_F_BN_MOD_MUL_RECIPROCAL 111 +#define BN_F_BN_MOD_SQRT 121 +#define BN_F_BN_MPI2BN 112 +#define BN_F_BN_NEW 113 +#define BN_F_BN_RAND 114 +#define BN_F_BN_RAND_RANGE 122 +#define BN_F_BN_USUB 115 + +/* Reason codes. */ +#define BN_R_ARG2_LT_ARG3 100 +#define BN_R_BAD_RECIPROCAL 101 +#define BN_R_BIGNUM_TOO_LONG 114 +#define BN_R_CALLED_WITH_EVEN_MODULUS 102 +#define BN_R_DIV_BY_ZERO 103 +#define BN_R_ENCODING_ERROR 104 +#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 +#define BN_R_INPUT_NOT_REDUCED 110 +#define BN_R_INVALID_LENGTH 106 +#define BN_R_INVALID_RANGE 115 +#define BN_R_NOT_A_SQUARE 111 +#define BN_R_NOT_INITIALIZED 107 +#define BN_R_NO_INVERSE 108 +#define BN_R_NO_SOLUTION 116 +#define BN_R_P_IS_NOT_PRIME 112 +#define BN_R_TOO_MANY_ITERATIONS 113 +#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/buffer.h b/libraries/external/openssl/pc/include/openssl/buffer.h new file mode 100755 index 0000000..e3f394c --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/buffer.h @@ -0,0 +1,118 @@ +/* crypto/buffer/buffer.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_BUFFER_H +#define HEADER_BUFFER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if !defined(NO_SYS_TYPES_H) +#include +#endif + +/* Already declared in ossl_typ.h */ +/* typedef struct buf_mem_st BUF_MEM; */ + +struct buf_mem_st + { + int length; /* current number of bytes */ + char *data; + int max; /* size of buffer */ + }; + +BUF_MEM *BUF_MEM_new(void); +void BUF_MEM_free(BUF_MEM *a); +int BUF_MEM_grow(BUF_MEM *str, int len); +int BUF_MEM_grow_clean(BUF_MEM *str, int len); +char * BUF_strdup(const char *str); +char * BUF_strndup(const char *str, size_t siz); +void * BUF_memdup(const void *data, size_t siz); + +/* safe string functions */ +size_t BUF_strlcpy(char *dst,const char *src,size_t siz); +size_t BUF_strlcat(char *dst,const char *src,size_t siz); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_BUF_strings(void); + +/* Error codes for the BUF functions. */ + +/* Function codes. */ +#define BUF_F_BUF_MEMDUP 103 +#define BUF_F_BUF_MEM_GROW 100 +#define BUF_F_BUF_MEM_GROW_CLEAN 105 +#define BUF_F_BUF_MEM_NEW 101 +#define BUF_F_BUF_STRDUP 102 +#define BUF_F_BUF_STRNDUP 104 + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/cast.h b/libraries/external/openssl/pc/include/openssl/cast.h new file mode 100755 index 0000000..6948e64 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/cast.h @@ -0,0 +1,105 @@ +/* crypto/cast/cast.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CAST_H +#define HEADER_CAST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef OPENSSL_NO_CAST +#error CAST is disabled. +#endif + +#define CAST_ENCRYPT 1 +#define CAST_DECRYPT 0 + +#define CAST_LONG unsigned long + +#define CAST_BLOCK 8 +#define CAST_KEY_LENGTH 16 + +typedef struct cast_key_st + { + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ + } CAST_KEY; + + +void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); +void CAST_ecb_encrypt(const unsigned char *in,unsigned char *out,CAST_KEY *key, + int enc); +void CAST_encrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_decrypt(CAST_LONG *data,CAST_KEY *key); +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + CAST_KEY *ks, unsigned char *iv, int enc); +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, CAST_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/comp.h b/libraries/external/openssl/pc/include/openssl/comp.h new file mode 100755 index 0000000..9e77ebc --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/comp.h @@ -0,0 +1,66 @@ + +#ifndef HEADER_COMP_H +#define HEADER_COMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct comp_ctx_st COMP_CTX; + +typedef struct comp_method_st + { + int type; /* NID for compression library */ + const char *name; /* A text string to identify the library */ + int (*init)(COMP_CTX *ctx); + void (*finish)(COMP_CTX *ctx); + int (*compress)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + int (*expand)(COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + /* The following two do NOTHING, but are kept for backward compatibility */ + long (*ctrl)(void); + long (*callback_ctrl)(void); + } COMP_METHOD; + +struct comp_ctx_st + { + COMP_METHOD *meth; + unsigned long compress_in; + unsigned long compress_out; + unsigned long expand_in; + unsigned long expand_out; + + CRYPTO_EX_DATA ex_data; + }; + + +COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); +void COMP_CTX_free(COMP_CTX *ctx); +int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +COMP_METHOD *COMP_rle(void ); +COMP_METHOD *COMP_zlib(void ); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_COMP_strings(void); + +/* Error codes for the COMP functions. */ + +/* Function codes. */ + +/* Reason codes. */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/conf.h b/libraries/external/openssl/pc/include/openssl/conf.h new file mode 100755 index 0000000..bc8f95d --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/conf.h @@ -0,0 +1,253 @@ +/* crypto/conf/conf.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_H +#define HEADER_CONF_H + +#include +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct + { + char *section; + char *name; + char *value; + } CONF_VALUE; + +DECLARE_STACK_OF(CONF_VALUE) +DECLARE_STACK_OF(CONF_MODULE) +DECLARE_STACK_OF(CONF_IMODULE) + +struct conf_st; +struct conf_method_st; +typedef struct conf_method_st CONF_METHOD; + +struct conf_method_st + { + const char *name; + CONF *(*create)(CONF_METHOD *meth); + int (*init)(CONF *conf); + int (*destroy)(CONF *conf); + int (*destroy_data)(CONF *conf); + int (*load_bio)(CONF *conf, BIO *bp, long *eline); + int (*dump)(const CONF *conf, BIO *bp); + int (*is_number)(const CONF *conf, char c); + int (*to_int)(const CONF *conf, char c); + int (*load)(CONF *conf, const char *name, long *eline); + }; + +/* Module definitions */ + +typedef struct conf_imodule_st CONF_IMODULE; +typedef struct conf_module_st CONF_MODULE; + +/* DSO module function typedefs */ +typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf); +typedef void conf_finish_func(CONF_IMODULE *md); + +#define CONF_MFLAGS_IGNORE_ERRORS 0x1 +#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 +#define CONF_MFLAGS_SILENT 0x4 +#define CONF_MFLAGS_NO_DSO 0x8 +#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 + +int CONF_set_default_method(CONF_METHOD *meth); +void CONF_set_nconf(CONF *conf,LHASH *hash); +LHASH *CONF_load(LHASH *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); +#endif +LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section); +char *CONF_get_string(LHASH *conf,const char *group,const char *name); +long CONF_get_number(LHASH *conf,const char *group,const char *name); +void CONF_free(LHASH *conf); +int CONF_dump_fp(LHASH *conf, FILE *out); +int CONF_dump_bio(LHASH *conf, BIO *out); + +void OPENSSL_config(const char *config_name); +void OPENSSL_no_config(void); + +/* New conf code. The semantics are different from the functions above. + If that wasn't the case, the above functions would have been replaced */ + +struct conf_st + { + CONF_METHOD *meth; + void *meth_data; + LHASH *data; + }; + +CONF *NCONF_new(CONF_METHOD *meth); +CONF_METHOD *NCONF_default(void); +CONF_METHOD *NCONF_WIN32(void); +#if 0 /* Just to give you an idea of what I have in mind */ +CONF_METHOD *NCONF_XML(void); +#endif +void NCONF_free(CONF *conf); +void NCONF_free_data(CONF *conf); + +int NCONF_load(CONF *conf,const char *file,long *eline); +#ifndef OPENSSL_NO_FP_API +int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); +#endif +int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section); +char *NCONF_get_string(const CONF *conf,const char *group,const char *name); +int NCONF_get_number_e(const CONF *conf,const char *group,const char *name, + long *result); +int NCONF_dump_fp(const CONF *conf, FILE *out); +int NCONF_dump_bio(const CONF *conf, BIO *out); + +#if 0 /* The following function has no error checking, + and should therefore be avoided */ +long NCONF_get_number(CONF *conf,char *group,char *name); +#else +#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) +#endif + +/* Module functions */ + +int CONF_modules_load(const CONF *cnf, const char *appname, + unsigned long flags); +int CONF_modules_load_file(const char *filename, const char *appname, + unsigned long flags); +void CONF_modules_unload(int all); +void CONF_modules_finish(void); +void CONF_modules_free(void); +int CONF_module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); + +const char *CONF_imodule_get_name(const CONF_IMODULE *md); +const char *CONF_imodule_get_value(const CONF_IMODULE *md); +void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); +void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); +CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); +unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); +void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); +void *CONF_module_get_usr_data(CONF_MODULE *pmod); +void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); + +char *CONF_get1_default_config_file(void); + +int CONF_parse_list(const char *list, int sep, int nospc, + int (*list_cb)(const char *elem, int len, void *usr), void *arg); + +void OPENSSL_load_builtin_modules(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CONF_strings(void); + +/* Error codes for the CONF functions. */ + +/* Function codes. */ +#define CONF_F_CONF_DUMP_FP 104 +#define CONF_F_CONF_LOAD 100 +#define CONF_F_CONF_LOAD_BIO 102 +#define CONF_F_CONF_LOAD_FP 103 +#define CONF_F_CONF_MODULES_LOAD 116 +#define CONF_F_DEF_LOAD 120 +#define CONF_F_DEF_LOAD_BIO 121 +#define CONF_F_MODULE_INIT 115 +#define CONF_F_MODULE_LOAD_DSO 117 +#define CONF_F_MODULE_RUN 118 +#define CONF_F_NCONF_DUMP_BIO 105 +#define CONF_F_NCONF_DUMP_FP 106 +#define CONF_F_NCONF_GET_NUMBER 107 +#define CONF_F_NCONF_GET_NUMBER_E 112 +#define CONF_F_NCONF_GET_SECTION 108 +#define CONF_F_NCONF_GET_STRING 109 +#define CONF_F_NCONF_LOAD 113 +#define CONF_F_NCONF_LOAD_BIO 110 +#define CONF_F_NCONF_LOAD_FP 114 +#define CONF_F_NCONF_NEW 111 +#define CONF_F_STR_COPY 101 + +/* Reason codes. */ +#define CONF_R_ERROR_LOADING_DSO 110 +#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 +#define CONF_R_MISSING_EQUAL_SIGN 101 +#define CONF_R_MISSING_FINISH_FUNCTION 111 +#define CONF_R_MISSING_INIT_FUNCTION 112 +#define CONF_R_MODULE_INITIALIZATION_ERROR 109 +#define CONF_R_NO_CLOSE_BRACE 102 +#define CONF_R_NO_CONF 105 +#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 +#define CONF_R_NO_SECTION 107 +#define CONF_R_NO_SUCH_FILE 114 +#define CONF_R_NO_VALUE 108 +#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 +#define CONF_R_UNKNOWN_MODULE_NAME 113 +#define CONF_R_VARIABLE_HAS_NO_VALUE 104 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/conf_api.h b/libraries/external/openssl/pc/include/openssl/conf_api.h new file mode 100755 index 0000000..8e7d5d5 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/conf_api.h @@ -0,0 +1,89 @@ +/* conf_api.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_CONF_API_H +#define HEADER_CONF_API_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Up until OpenSSL 0.9.5a, this was new_section */ +CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was get_section */ +CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); +/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ +STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, + const char *section); + +int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); +char *_CONF_get_string(const CONF *conf, const char *section, + const char *name); +long _CONF_get_number(const CONF *conf, const char *section, const char *name); + +int _CONF_new_data(CONF *conf); +void _CONF_free_data(CONF *conf); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/crypto.h b/libraries/external/openssl/pc/include/openssl/crypto.h new file mode 100755 index 0000000..fcba789 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/crypto.h @@ -0,0 +1,550 @@ +/* crypto/crypto.h */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_CRYPTO_H +#define HEADER_CRYPTO_H + +#include + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#include +#include +#include +#include + +#ifdef CHARSET_EBCDIC +#include +#endif + +/* Resolve problems on some operating systems with symbol names that clash + one way or another */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Backward compatibility to SSLeay */ +/* This is more to be used to check the correct DLL is being used + * in the MS world. */ +#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER +#define SSLEAY_VERSION 0 +/* #define SSLEAY_OPTIONS 1 no longer supported */ +#define SSLEAY_CFLAGS 2 +#define SSLEAY_BUILT_ON 3 +#define SSLEAY_PLATFORM 4 +#define SSLEAY_DIR 5 + +/* Already declared in ossl_typ.h */ +#if 0 +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Called when a new object is created */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when an object is free()ed */ +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +/* Called when we need to dup an object */ +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); +#endif + +/* A generic structure to pass assorted data in a expandable way */ +typedef struct openssl_item_st + { + int code; + void *value; /* Not used for flag attributes */ + size_t value_size; /* Max size of value for output, length for input */ + size_t *value_length; /* Returned length of value for output */ + } OPENSSL_ITEM; + + +/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock + * names in cryptlib.c + */ + +#define CRYPTO_LOCK_ERR 1 +#define CRYPTO_LOCK_EX_DATA 2 +#define CRYPTO_LOCK_X509 3 +#define CRYPTO_LOCK_X509_INFO 4 +#define CRYPTO_LOCK_X509_PKEY 5 +#define CRYPTO_LOCK_X509_CRL 6 +#define CRYPTO_LOCK_X509_REQ 7 +#define CRYPTO_LOCK_DSA 8 +#define CRYPTO_LOCK_RSA 9 +#define CRYPTO_LOCK_EVP_PKEY 10 +#define CRYPTO_LOCK_X509_STORE 11 +#define CRYPTO_LOCK_SSL_CTX 12 +#define CRYPTO_LOCK_SSL_CERT 13 +#define CRYPTO_LOCK_SSL_SESSION 14 +#define CRYPTO_LOCK_SSL_SESS_CERT 15 +#define CRYPTO_LOCK_SSL 16 +#define CRYPTO_LOCK_SSL_METHOD 17 +#define CRYPTO_LOCK_RAND 18 +#define CRYPTO_LOCK_RAND2 19 +#define CRYPTO_LOCK_MALLOC 20 +#define CRYPTO_LOCK_BIO 21 +#define CRYPTO_LOCK_GETHOSTBYNAME 22 +#define CRYPTO_LOCK_GETSERVBYNAME 23 +#define CRYPTO_LOCK_READDIR 24 +#define CRYPTO_LOCK_RSA_BLINDING 25 +#define CRYPTO_LOCK_DH 26 +#define CRYPTO_LOCK_MALLOC2 27 +#define CRYPTO_LOCK_DSO 28 +#define CRYPTO_LOCK_DYNLOCK 29 +#define CRYPTO_LOCK_ENGINE 30 +#define CRYPTO_LOCK_UI 31 +#define CRYPTO_LOCK_ECDSA 32 +#define CRYPTO_LOCK_EC 33 +#define CRYPTO_LOCK_ECDH 34 +#define CRYPTO_LOCK_BN 35 +#define CRYPTO_LOCK_EC_PRE_COMP 36 +#define CRYPTO_LOCK_STORE 37 +#define CRYPTO_LOCK_COMP 38 +#define CRYPTO_NUM_LOCKS 39 + +#define CRYPTO_LOCK 1 +#define CRYPTO_UNLOCK 2 +#define CRYPTO_READ 4 +#define CRYPTO_WRITE 8 + +#ifndef OPENSSL_NO_LOCKING +#ifndef CRYPTO_w_lock +#define CRYPTO_w_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_w_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) +#define CRYPTO_r_lock(type) \ + CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_r_unlock(type) \ + CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) +#define CRYPTO_add(addr,amount,type) \ + CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) +#endif +#else +#define CRYPTO_w_lock(a) +#define CRYPTO_w_unlock(a) +#define CRYPTO_r_lock(a) +#define CRYPTO_r_unlock(a) +#define CRYPTO_add(a,b,c) ((*(a))+=(b)) +#endif + +/* Some applications as well as some parts of OpenSSL need to allocate + and deallocate locks in a dynamic fashion. The following typedef + makes this possible in a type-safe manner. */ +/* struct CRYPTO_dynlock_value has to be defined by the application. */ +typedef struct + { + int references; + struct CRYPTO_dynlock_value *data; + } CRYPTO_dynlock; + + +/* The following can be used to detect memory leaks in the SSLeay library. + * It used, it turns on malloc checking */ + +#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ +#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ +#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ +#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ + +/* The following are bit values to turn on or off options connected to the + * malloc checking functionality */ + +/* Adds time to the memory checking information */ +#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ +/* Adds thread number to the memory checking information */ +#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ + +#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) + + +/* predec of the BIO type */ +typedef struct bio_st BIO_dummy; + +struct crypto_ex_data_st + { + STACK *sk; + int dummy; /* gcc is screwing up this data structure :-( */ + }; + +/* This stuff is basically class callback functions + * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ + +typedef struct crypto_ex_data_func_st + { + long argl; /* Arbitary long */ + void *argp; /* Arbitary void * */ + CRYPTO_EX_new *new_func; + CRYPTO_EX_free *free_func; + CRYPTO_EX_dup *dup_func; + } CRYPTO_EX_DATA_FUNCS; + +DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) + +/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA + * entry. + */ + +#define CRYPTO_EX_INDEX_BIO 0 +#define CRYPTO_EX_INDEX_SSL 1 +#define CRYPTO_EX_INDEX_SSL_CTX 2 +#define CRYPTO_EX_INDEX_SSL_SESSION 3 +#define CRYPTO_EX_INDEX_X509_STORE 4 +#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 +#define CRYPTO_EX_INDEX_RSA 6 +#define CRYPTO_EX_INDEX_DSA 7 +#define CRYPTO_EX_INDEX_DH 8 +#define CRYPTO_EX_INDEX_ENGINE 9 +#define CRYPTO_EX_INDEX_X509 10 +#define CRYPTO_EX_INDEX_UI 11 +#define CRYPTO_EX_INDEX_ECDSA 12 +#define CRYPTO_EX_INDEX_ECDH 13 +#define CRYPTO_EX_INDEX_COMP 14 +#define CRYPTO_EX_INDEX_STORE 15 + +/* Dynamically assigned indexes start from this value (don't use directly, use + * via CRYPTO_ex_data_new_class). */ +#define CRYPTO_EX_INDEX_USER 100 + + +/* This is the default callbacks, but we can have others as well: + * this is needed in Win32 where the application malloc and the + * library malloc may not be the same. + */ +#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ + malloc, realloc, free) + +#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD +# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ +# define CRYPTO_MDEBUG +# endif +#endif + +/* Set standard debugging functions (not done by default + * unless CRYPTO_MDEBUG is defined) */ +#define CRYPTO_malloc_debug_init() do {\ + CRYPTO_set_mem_debug_functions(\ + CRYPTO_dbg_malloc,\ + CRYPTO_dbg_realloc,\ + CRYPTO_dbg_free,\ + CRYPTO_dbg_set_options,\ + CRYPTO_dbg_get_options);\ + } while(0) + +int CRYPTO_mem_ctrl(int mode); +int CRYPTO_is_mem_check_on(void); + +/* for applications */ +#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) +#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) + +/* for library-internal use */ +#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) +#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) +#define is_MemCheck_on() CRYPTO_is_mem_check_on() + +#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) +#define OPENSSL_realloc(addr,num) \ + CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_realloc_clean(addr,old_num,num) \ + CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) +#define OPENSSL_remalloc(addr,num) \ + CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) +#define OPENSSL_freeFunc CRYPTO_free +#define OPENSSL_free(addr) CRYPTO_free(addr) + +#define OPENSSL_malloc_locked(num) \ + CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) +#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) + + +const char *SSLeay_version(int type); +unsigned long SSLeay(void); + +int OPENSSL_issetugid(void); + +/* An opaque type representing an implementation of "ex_data" support */ +typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; +/* Return an opaque pointer to the current "ex_data" implementation */ +const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); +/* Sets the "ex_data" implementation to be used (if it's not too late) */ +int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); +/* Get a new "ex_data" class, and return the corresponding "class_index" */ +int CRYPTO_ex_data_new_class(void); +/* Within a given class, get/register a new index */ +int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, + CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func); +/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given + * class (invokes whatever per-class callbacks are applicable) */ +int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, + CRYPTO_EX_DATA *from); +void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); +/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index + * (relative to the class type involved) */ +int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); +void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); +/* This function cleans up all "ex_data" state. It mustn't be called under + * potential race-conditions. */ +void CRYPTO_cleanup_all_ex_data(void); + +int CRYPTO_get_new_lockid(char *name); + +int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ +void CRYPTO_lock(int mode, int type,const char *file,int line); +void CRYPTO_set_locking_callback(void (*func)(int mode,int type, + const char *file,int line)); +void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, + int line); +void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, + const char *file, int line)); +int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, + const char *file,int line); +void CRYPTO_set_id_callback(unsigned long (*func)(void)); +unsigned long (*CRYPTO_get_id_callback(void))(void); +unsigned long CRYPTO_thread_id(void); +const char *CRYPTO_get_lock_name(int type); +int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, + int line); + +int CRYPTO_get_new_dynlockid(void); +void CRYPTO_destroy_dynlockid(int i); +struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); +void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); +void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); +void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); +struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); +void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); +void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); + +/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- + * call the latter last if you need different functions */ +int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); +int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); +int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), + void *(*r)(void *,size_t,const char *,int), + void (*f)(void *)); +int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), + void (*free_func)(void *)); +int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), + void (*r)(void *,void *,int,const char *,int,int), + void (*f)(void *,int), + void (*so)(long), + long (*go)(void)); +void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); +void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); +void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), + void *(**r)(void *, size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), + void (**f)(void *)); +void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), + void (**r)(void *,void *,int,const char *,int,int), + void (**f)(void *,int), + void (**so)(long), + long (**go)(void)); + +void *CRYPTO_malloc_locked(int num, const char *file, int line); +void CRYPTO_free_locked(void *); +void *CRYPTO_malloc(int num, const char *file, int line); +void CRYPTO_free(void *); +void *CRYPTO_realloc(void *addr,int num, const char *file, int line); +void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, + int line); +void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); + +void OPENSSL_cleanse(void *ptr, size_t len); + +void CRYPTO_set_mem_debug_options(long bits); +long CRYPTO_get_mem_debug_options(void); + +#define CRYPTO_push_info(info) \ + CRYPTO_push_info_(info, __FILE__, __LINE__); +int CRYPTO_push_info_(const char *info, const char *file, int line); +int CRYPTO_pop_info(void); +int CRYPTO_remove_all_info(void); + + +/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; + * used as default in CRYPTO_MDEBUG compilations): */ +/* The last argument has the following significance: + * + * 0: called before the actual memory allocation has taken place + * 1: called after the actual memory allocation has taken place + */ +void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); +void CRYPTO_dbg_free(void *addr,int before_p); +/* Tell the debugging code about options. By default, the following values + * apply: + * + * 0: Clear all options. + * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. + * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. + * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 + */ +void CRYPTO_dbg_set_options(long bits); +long CRYPTO_dbg_get_options(void); + + +#ifndef OPENSSL_NO_FP_API +void CRYPTO_mem_leaks_fp(FILE *); +#endif +void CRYPTO_mem_leaks(struct bio_st *bio); +/* unsigned long order, char *file, int line, int num_bytes, char *addr */ +typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); +void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); + +/* die if we have to */ +void OpenSSLDie(const char *file,int line,const char *assertion); +#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) + +unsigned long *OPENSSL_ia32cap_loc(void); +#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CRYPTO_strings(void); + +/* Error codes for the CRYPTO functions. */ + +/* Function codes. */ +#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 +#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 +#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 +#define CRYPTO_F_DEF_ADD_INDEX 104 +#define CRYPTO_F_DEF_GET_CLASS 105 +#define CRYPTO_F_INT_DUP_EX_DATA 106 +#define CRYPTO_F_INT_FREE_EX_DATA 107 +#define CRYPTO_F_INT_NEW_EX_DATA 108 + +/* Reason codes. */ +#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/des.h b/libraries/external/openssl/pc/include/openssl/des.h new file mode 100755 index 0000000..5ed8747 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/des.h @@ -0,0 +1,244 @@ +/* crypto/des/des.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_NEW_DES_H +#define HEADER_NEW_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, + DES_LONG (via openssl/opensslconf.h */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char DES_cblock[8]; +typedef /* const */ unsigned char const_DES_cblock[8]; +/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * + * and const_DES_cblock * are incompatible pointer types. */ + +typedef struct DES_ks + { + union + { + DES_cblock cblock; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG deslong[2]; + } ks[16]; + } DES_key_schedule; + +#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT +# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT +# define OPENSSL_ENABLE_OLD_DES_SUPPORT +# endif +#endif + +#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT +# include +#endif + +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define DES_ecb2_encrypt(i,o,k1,k2,e) \ + DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ +#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) +OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ +#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) + +const char *DES_options(void); +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); +DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, + long length,DES_key_schedule *schedule, + const_DES_cblock *ivec); +/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ +void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + const_DES_cblock *inw,const_DES_cblock *outw,int enc); +void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, + DES_key_schedule *ks,int enc); + +/* This is the DES encryption function that gets called by just about + every other DES routine in the library. You should not use this + function except to implement 'modes' of DES. I say this because the + functions that call this routine do the conversion from 'char *' to + long, and this needs to be done to make sure 'non-aligned' memory + access do not occur. The characters are loaded 'little endian'. + Data is a pointer to 2 unsigned long's and ks is the + DES_key_schedule to use. enc, is non zero specifies encryption, + zero if decryption. */ +void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); + +/* This functions is the same as DES_encrypt1() except that the DES + initial permutation (IP) and final permutation (FP) have been left + out. As for DES_encrypt1(), you should not use this function. + It is used by the routines in the library that implement triple DES. + IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same + as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ +void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); + +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3,DES_cblock *ivec,int enc); +void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, + long length, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, + DES_cblock *ivec1,DES_cblock *ivec2, + int enc); +void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num,int enc); +void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, + int numbits,long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int enc); +void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num); + +void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, + DES_cblock *out_white); + +int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +char *DES_fcrypt(const char *buf,const char *salt, char *ret); +char *DES_crypt(const char *buf,const char *salt); +void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec); +void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + int enc); +DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], + long length,int out_count,DES_cblock *seed); +int DES_random_key(DES_cblock *ret); +void DES_set_odd_parity(DES_cblock *key); +int DES_check_key_parity(const_DES_cblock *key); +int DES_is_weak_key(const_DES_cblock *key); +/* DES_set_key (= set_key = DES_key_sched = key_sched) calls + * DES_set_key_checked if global variable DES_check_key is set, + * DES_set_key_unchecked otherwise. */ +int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_string_to_key(const char *str,DES_cblock *key); +void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); +void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num, + int enc); +void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num); + +int DES_read_password(DES_cblock *key, const char *prompt, int verify); +int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, + int verify); + +#define DES_fixup_key_parity DES_set_odd_parity + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/des_old.h b/libraries/external/openssl/pc/include/openssl/des_old.h new file mode 100755 index 0000000..caaa1da --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/des_old.h @@ -0,0 +1,445 @@ +/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * The function names in here are deprecated and are only present to + * provide an interface compatible with openssl 0.9.6 and older as + * well as libdes. OpenSSL now provides functions where "des_" has + * been replaced with "DES_" in the names, to make it possible to + * make incompatible changes that are needed for C type security and + * other stuff. + * + * This include files has two compatibility modes: + * + * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API + * that is compatible with libdes and SSLeay. + * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an + * API that is compatible with OpenSSL 0.9.5x to 0.9.6x. + * + * Note that these modes break earlier snapshots of OpenSSL, where + * libdes compatibility was the only available mode or (later on) the + * prefered compatibility mode. However, after much consideration + * (and more or less violent discussions with external parties), it + * was concluded that OpenSSL should be compatible with earlier versions + * of itself before anything else. Also, in all honesty, libdes is + * an old beast that shouldn't really be used any more. + * + * Please consider starting to use the DES_ functions rather than the + * des_ ones. The des_ functions will disappear completely before + * OpenSSL 1.0! + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DES_H +#define HEADER_DES_H + +#include /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */ + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifndef HEADER_NEW_DES_H +#error You must include des.h, not des_old.h directly. +#endif + +#ifdef _KERBEROS_DES_H +#error replaces . +#endif + +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _ +#undef _ +#endif + +typedef unsigned char _ossl_old_des_cblock[8]; +typedef struct _ossl_old_des_ks_struct + { + union { + _ossl_old_des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; + } _ossl_old_des_key_schedule[16]; + +#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY +#define des_cblock DES_cblock +#define const_des_cblock const_DES_cblock +#define des_key_schedule DES_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e)) +#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\ + DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n)) +#define des_options()\ + DES_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + DES_cbc_cksum((i),(o),(l),&(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + DES_ecb_encrypt((i),(o),&(k),(e)) +#define des_encrypt1(d,k,e)\ + DES_encrypt1((d),&(k),(e)) +#define des_encrypt2(d,k,e)\ + DES_encrypt2((d),&(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + DES_encrypt3((d),&(k1),&(k2),&(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + DES_decrypt3((d),&(k1),&(k2),&(k3)) +#define des_xwhite_in2out(k,i,o)\ + DES_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + DES_enc_read((f),(b),(l),&(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + DES_enc_write((f),(b),(l),&(k),(iv)) +#define des_fcrypt(b,s,r)\ + DES_fcrypt((b),(s),(r)) +#if 0 +#define des_crypt(b,s)\ + DES_crypt((b),(s)) +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) +#define crypt(b,s)\ + DES_crypt((b),(s)) +#endif +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + DES_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_096_des_random_seed((k)) +#define des_random_key(r)\ + DES_random_key((r)) +#define des_read_password(k,p,v) \ + DES_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + DES_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + DES_set_odd_parity((k)) +#define des_check_key_parity(k)\ + DES_check_key_parity((k)) +#define des_is_weak_key(k)\ + DES_is_weak_key((k)) +#define des_set_key(k,ks)\ + DES_set_key((k),&(ks)) +#define des_key_sched(k,ks)\ + DES_key_sched((k),&(ks)) +#define des_set_key_checked(k,ks)\ + DES_set_key_checked((k),&(ks)) +#define des_set_key_unchecked(k,ks)\ + DES_set_key_unchecked((k),&(ks)) +#define des_string_to_key(s,k)\ + DES_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + DES_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#else /* libdes compatibility */ +/* Map all symbol names to _ossl_old_des_* form, so we avoid all + clashes with libdes */ +#define des_cblock _ossl_old_des_cblock +#define des_key_schedule _ossl_old_des_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n)) +#define des_options()\ + _ossl_old_des_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + _ossl_old_des_ecb_encrypt((i),(o),(k),(e)) +#define des_encrypt(d,k,e)\ + _ossl_old_des_encrypt((d),(k),(e)) +#define des_encrypt2(d,k,e)\ + _ossl_old_des_encrypt2((d),(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + _ossl_old_des_encrypt3((d),(k1),(k2),(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + _ossl_old_des_decrypt3((d),(k1),(k2),(k3)) +#define des_xwhite_in2out(k,i,o)\ + _ossl_old_des_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + _ossl_old_des_enc_read((f),(b),(l),(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + _ossl_old_des_enc_write((f),(b),(l),(k),(iv)) +#define des_fcrypt(b,s,r)\ + _ossl_old_des_fcrypt((b),(s),(r)) +#define des_crypt(b,s)\ + _ossl_old_des_crypt((b),(s)) +#if 0 +#define crypt(b,s)\ + _ossl_old_crypt((b),(s)) +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + _ossl_old_des_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_old_des_random_seed((k)) +#define des_random_key(r)\ + _ossl_old_des_random_key((r)) +#define des_read_password(k,p,v) \ + _ossl_old_des_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + _ossl_old_des_set_odd_parity((k)) +#define des_is_weak_key(k)\ + _ossl_old_des_is_weak_key((k)) +#define des_set_key(k,ks)\ + _ossl_old_des_set_key((k),(ks)) +#define des_key_sched(k,ks)\ + _ossl_old_des_key_sched((k),(ks)) +#define des_string_to_key(s,k)\ + _ossl_old_des_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + _ossl_old_des_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n)) + + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode +#endif + +const char *_ossl_old_des_options(void); +void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, int enc); +DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec, + _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc); +void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks,int enc); +void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc); +void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), + _ossl_old_des_cblock (*out_white)); + +int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret); +char *_ossl_old_des_crypt(const char *buf,const char *salt); +#if !defined(PERL5) && !defined(NeXT) +char *_ossl_old_crypt(const char *buf,const char *salt); +#endif +void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,int out_count,_ossl_old_des_cblock *seed); +void _ossl_old_des_random_seed(_ossl_old_des_cblock key); +void _ossl_old_des_random_key(_ossl_old_des_cblock ret); +int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify); +int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2, + const char *prompt,int verify); +void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key); +int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key); +int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key); +void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2); +void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_096_des_random_seed(des_cblock *key); + +/* The following definitions provide compatibility with the MIT Kerberos + * library. The _ossl_old_des_key_schedule structure is not binary compatible. */ + +#define _KERBEROS_DES_H + +#define KRBDES_ENCRYPT DES_ENCRYPT +#define KRBDES_DECRYPT DES_DECRYPT + +#ifdef KERBEROS +# define ENCRYPT DES_ENCRYPT +# define DECRYPT DES_DECRYPT +#endif + +#ifndef NCOMPAT +# define C_Block des_cblock +# define Key_schedule des_key_schedule +# define KEY_SZ DES_KEY_SZ +# define string_to_key des_string_to_key +# define read_pw_string des_read_pw_string +# define random_key des_random_key +# define pcbc_encrypt des_pcbc_encrypt +# define set_key des_set_key +# define key_sched des_key_sched +# define ecb_encrypt des_ecb_encrypt +# define cbc_encrypt des_cbc_encrypt +# define ncbc_encrypt des_ncbc_encrypt +# define xcbc_encrypt des_xcbc_encrypt +# define cbc_cksum des_cbc_cksum +# define quad_cksum des_quad_cksum +# define check_parity des_check_key_parity +#endif + +#define des_fixup_key_parity DES_fixup_key_parity + +#ifdef __cplusplus +} +#endif + +/* for DES_read_pw_string et al */ +#include + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/dh.h b/libraries/external/openssl/pc/include/openssl/dh.h new file mode 100755 index 0000000..44158f8 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/dh.h @@ -0,0 +1,234 @@ +/* crypto/dh/dh.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_DH_H +#define HEADER_DH_H + +#include + +#ifdef OPENSSL_NO_DH +#error DH is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifndef OPENSSL_DH_MAX_MODULUS_BITS +# define OPENSSL_DH_MAX_MODULUS_BITS 10000 +#endif + +#define DH_FLAG_CACHE_MONT_P 0x01 +#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dh_st DH; */ +/* typedef struct dh_method DH_METHOD; */ + +struct dh_method + { + const char *name; + /* Methods here */ + int (*generate_key)(DH *dh); + int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh); + int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a, + const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + + int (*init)(DH *dh); + int (*finish)(DH *dh); + int flags; + char *app_data; + /* If this is non-NULL, it will be used to generate parameters */ + int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb); + }; + +struct dh_st + { + /* This first argument is used to pick up errors when + * a DH is passed instead of a EVP_PKEY */ + int pad; + int version; + BIGNUM *p; + BIGNUM *g; + long length; /* optional */ + BIGNUM *pub_key; /* g^x */ + BIGNUM *priv_key; /* x */ + + int flags; + BN_MONT_CTX *method_mont_p; + /* Place holders if we want to do X9.42 DH */ + BIGNUM *q; + BIGNUM *j; + unsigned char *seed; + int seedlen; + BIGNUM *counter; + + int references; + CRYPTO_EX_DATA ex_data; + const DH_METHOD *meth; + ENGINE *engine; + }; + +#define DH_GENERATOR_2 2 +/* #define DH_GENERATOR_3 3 */ +#define DH_GENERATOR_5 5 + +/* DH_check error codes */ +#define DH_CHECK_P_NOT_PRIME 0x01 +#define DH_CHECK_P_NOT_SAFE_PRIME 0x02 +#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 +#define DH_NOT_SUITABLE_GENERATOR 0x08 + +/* DH_check_pub_key error codes */ +#define DH_CHECK_PUBKEY_TOO_SMALL 0x01 +#define DH_CHECK_PUBKEY_TOO_LARGE 0x02 + +/* primes p where (p-1)/2 is prime too are called "safe"; we define + this for backward compatibility: */ +#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME + +#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x) +#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ + (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) +#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) +#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) + +const DH_METHOD *DH_OpenSSL(void); + +void DH_set_default_method(const DH_METHOD *meth); +const DH_METHOD *DH_get_default_method(void); +int DH_set_method(DH *dh, const DH_METHOD *meth); +DH *DH_new_method(ENGINE *engine); + +DH * DH_new(void); +void DH_free(DH *dh); +int DH_up_ref(DH *dh); +int DH_size(const DH *dh); +int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DH_set_ex_data(DH *d, int idx, void *arg); +void *DH_get_ex_data(DH *d, int idx); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DH * DH_generate_parameters(int prime_len,int generator, + void (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); + +int DH_check(const DH *dh,int *codes); +int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes); +int DH_generate_key(DH *dh); +int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh); +DH * d2i_DHparams(DH **a,const unsigned char **pp, long length); +int i2d_DHparams(const DH *a,unsigned char **pp); +#ifndef OPENSSL_NO_FP_API +int DHparams_print_fp(FILE *fp, const DH *x); +#endif +#ifndef OPENSSL_NO_BIO +int DHparams_print(BIO *bp, const DH *x); +#else +int DHparams_print(char *bp, const DH *x); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DH_strings(void); + +/* Error codes for the DH functions. */ + +/* Function codes. */ +#define DH_F_COMPUTE_KEY 102 +#define DH_F_DHPARAMS_PRINT 100 +#define DH_F_DHPARAMS_PRINT_FP 101 +#define DH_F_DH_BUILTIN_GENPARAMS 106 +#define DH_F_DH_NEW_METHOD 105 +#define DH_F_GENERATE_KEY 103 +#define DH_F_GENERATE_PARAMETERS 104 + +/* Reason codes. */ +#define DH_R_BAD_GENERATOR 101 +#define DH_R_INVALID_PUBKEY 102 +#define DH_R_MODULUS_TOO_LARGE 103 +#define DH_R_NO_PRIVATE_VALUE 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/dsa.h b/libraries/external/openssl/pc/include/openssl/dsa.h new file mode 100755 index 0000000..fa58369 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/dsa.h @@ -0,0 +1,285 @@ +/* crypto/dsa/dsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* + * The DSS routines are based on patches supplied by + * Steven Schoch . He basically did the + * work and I have just tweaked them a little to fit into my + * stylistic vision for SSLeay :-) */ + +#ifndef HEADER_DSA_H +#define HEADER_DSA_H + +#include + +#ifdef OPENSSL_NO_DSA +#error DSA is disabled. +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_DH +# include +#endif +#endif + +#ifndef OPENSSL_DSA_MAX_MODULUS_BITS +# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 +#endif + +#define DSA_FLAG_CACHE_MONT_P 0x01 +#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct dsa_st DSA; */ +/* typedef struct dsa_method DSA_METHOD; */ + +typedef struct DSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } DSA_SIG; + +struct dsa_method + { + const char *name; + DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa); + int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); + int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); + int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, + BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); + int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(DSA *dsa); + int (*finish)(DSA *dsa); + int flags; + char *app_data; + /* If this is non-NULL, it is used to generate DSA parameters */ + int (*dsa_paramgen)(DSA *dsa, int bits, + unsigned char *seed, int seed_len, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); + /* If this is non-NULL, it is used to generate DSA keys */ + int (*dsa_keygen)(DSA *dsa); + }; + +struct dsa_st + { + /* This first variable is used to pick up errors where + * a DSA is passed instead of of a EVP_PKEY */ + int pad; + long version; + int write_params; + BIGNUM *p; + BIGNUM *q; /* == 20 */ + BIGNUM *g; + + BIGNUM *pub_key; /* y public key */ + BIGNUM *priv_key; /* x private key */ + + BIGNUM *kinv; /* Signing pre-calc */ + BIGNUM *r; /* Signing pre-calc */ + + int flags; + /* Normally used to cache montgomery values */ + BN_MONT_CTX *method_mont_p; + int references; + CRYPTO_EX_DATA ex_data; + const DSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + }; + +#define DSAparams_dup(x) ASN1_dup_of_const(DSA,i2d_DSAparams,d2i_DSAparams,x) +#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ + (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) +#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ + (unsigned char *)(x)) +#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) +#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) + + +DSA_SIG * DSA_SIG_new(void); +void DSA_SIG_free(DSA_SIG *a); +int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); +DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); + +DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); +int DSA_do_verify(const unsigned char *dgst,int dgst_len, + DSA_SIG *sig,DSA *dsa); + +const DSA_METHOD *DSA_OpenSSL(void); + +void DSA_set_default_method(const DSA_METHOD *); +const DSA_METHOD *DSA_get_default_method(void); +int DSA_set_method(DSA *dsa, const DSA_METHOD *); + +DSA * DSA_new(void); +DSA * DSA_new_method(ENGINE *engine); +void DSA_free (DSA *r); +/* "up" the DSA object's reference count */ +int DSA_up_ref(DSA *r); +int DSA_size(const DSA *); + /* next 4 return -1 on error */ +int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); +int DSA_sign(int type,const unsigned char *dgst,int dlen, + unsigned char *sig, unsigned int *siglen, DSA *dsa); +int DSA_verify(int type,const unsigned char *dgst,int dgst_len, + const unsigned char *sigbuf, int siglen, DSA *dsa); +int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int DSA_set_ex_data(DSA *d, int idx, void *arg); +void *DSA_get_ex_data(DSA *d, int idx); + +DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); +DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +DSA * DSA_generate_parameters(int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret,void + (*callback)(int, int, void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int DSA_generate_parameters_ex(DSA *dsa, int bits, + unsigned char *seed,int seed_len, + int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); + +int DSA_generate_key(DSA *a); +int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); +int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); +int i2d_DSAparams(const DSA *a,unsigned char **pp); + +#ifndef OPENSSL_NO_BIO +int DSAparams_print(BIO *bp, const DSA *x); +int DSA_print(BIO *bp, const DSA *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int DSAparams_print_fp(FILE *fp, const DSA *x); +int DSA_print_fp(FILE *bp, const DSA *x, int off); +#endif + +#define DSS_prime_checks 50 +/* Primality test according to FIPS PUB 186[-1], Appendix 2.1: + * 50 rounds of Rabin-Miller */ +#define DSA_is_prime(n, callback, cb_arg) \ + BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) + +#ifndef OPENSSL_NO_DH +/* Convert DSA structure (key or just parameters) into DH structure + * (be careful to avoid small subgroup attacks when using this!) */ +DH *DSA_dup_DH(const DSA *r); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSA_strings(void); + +/* Error codes for the DSA functions. */ + +/* Function codes. */ +#define DSA_F_D2I_DSA_SIG 110 +#define DSA_F_DSAPARAMS_PRINT 100 +#define DSA_F_DSAPARAMS_PRINT_FP 101 +#define DSA_F_DSA_DO_SIGN 112 +#define DSA_F_DSA_DO_VERIFY 113 +#define DSA_F_DSA_NEW_METHOD 103 +#define DSA_F_DSA_PRINT 104 +#define DSA_F_DSA_PRINT_FP 105 +#define DSA_F_DSA_SIGN 106 +#define DSA_F_DSA_SIGN_SETUP 107 +#define DSA_F_DSA_SIG_NEW 109 +#define DSA_F_DSA_VERIFY 108 +#define DSA_F_I2D_DSA_SIG 111 +#define DSA_F_SIG_CB 114 + +/* Reason codes. */ +#define DSA_R_BAD_Q_VALUE 102 +#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 +#define DSA_R_MISSING_PARAMETERS 101 +#define DSA_R_MODULUS_TOO_LARGE 103 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/dso.h b/libraries/external/openssl/pc/include/openssl/dso.h new file mode 100755 index 0000000..1836231 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/dso.h @@ -0,0 +1,368 @@ +/* dso.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DSO_H +#define HEADER_DSO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These values are used as commands to DSO_ctrl() */ +#define DSO_CTRL_GET_FLAGS 1 +#define DSO_CTRL_SET_FLAGS 2 +#define DSO_CTRL_OR_FLAGS 3 + +/* By default, DSO_load() will translate the provided filename into a form + * typical for the platform (more specifically the DSO_METHOD) using the + * dso_name_converter function of the method. Eg. win32 will transform "blah" + * into "blah.dll", and dlfcn will transform it into "libblah.so". The + * behaviour can be overriden by setting the name_converter callback in the DSO + * object (using DSO_set_name_converter()). This callback could even utilise + * the DSO_METHOD's converter too if it only wants to override behaviour for + * one or two possible DSO methods. However, the following flag can be set in a + * DSO to prevent *any* native name-translation at all - eg. if the caller has + * prompted the user for a path to a driver library so the filename should be + * interpreted as-is. */ +#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 +/* An extra flag to give if only the extension should be added as + * translation. This is obviously only of importance on Unix and + * other operating systems where the translation also may prefix + * the name with something, like 'lib', and ignored everywhere else. + * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used + * at the same time. */ +#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 + +/* The following flag controls the translation of symbol names to upper + * case. This is currently only being implemented for OpenVMS. + */ +#define DSO_FLAG_UPCASE_SYMBOL 0x10 + +/* This flag loads the library with public symbols. + * Meaning: The exported symbols of this library are public + * to all libraries loaded after this library. + * At the moment only implemented in unix. + */ +#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 + + +typedef void (*DSO_FUNC_TYPE)(void); + +typedef struct dso_st DSO; + +/* The function prototype used for method functions (or caller-provided + * callbacks) that transform filenames. They are passed a DSO structure pointer + * (or NULL if they are to be used independantly of a DSO object) and a + * filename to transform. They should either return NULL (if there is an error + * condition) or a newly allocated string containing the transformed form that + * the caller will need to free with OPENSSL_free() when done. */ +typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); +/* The function prototype used for method functions (or caller-provided + * callbacks) that merge two file specifications. They are passed a + * DSO structure pointer (or NULL if they are to be used independantly of + * a DSO object) and two file specifications to merge. They should + * either return NULL (if there is an error condition) or a newly allocated + * string containing the result of merging that the caller will need + * to free with OPENSSL_free() when done. + * Here, merging means that bits and pieces are taken from each of the + * file specifications and added together in whatever fashion that is + * sensible for the DSO method in question. The only rule that really + * applies is that if the two specification contain pieces of the same + * type, the copy from the first string takes priority. One could see + * it as the first specification is the one given by the user and the + * second being a bunch of defaults to add on if they're missing in the + * first. */ +typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); + +typedef struct dso_meth_st + { + const char *name; + /* Loads a shared library, NB: new DSO_METHODs must ensure that a + * successful load populates the loaded_filename field, and likewise a + * successful unload OPENSSL_frees and NULLs it out. */ + int (*dso_load)(DSO *dso); + /* Unloads a shared library */ + int (*dso_unload)(DSO *dso); + /* Binds a variable */ + void *(*dso_bind_var)(DSO *dso, const char *symname); + /* Binds a function - assumes a return type of DSO_FUNC_TYPE. + * This should be cast to the real function prototype by the + * caller. Platforms that don't have compatible representations + * for different prototypes (this is possible within ANSI C) + * are highly unlikely to have shared libraries at all, let + * alone a DSO_METHOD implemented for them. */ + DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); + +/* I don't think this would actually be used in any circumstances. */ +#if 0 + /* Unbinds a variable */ + int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr); + /* Unbinds a function */ + int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); +#endif + /* The generic (yuck) "ctrl()" function. NB: Negative return + * values (rather than zero) indicate errors. */ + long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_NAME_CONVERTER_FUNC dso_name_converter; + /* The default DSO_METHOD-specific function for converting filenames to + * a canonical native form. */ + DSO_MERGER_FUNC dso_merger; + + /* [De]Initialisation handlers. */ + int (*init)(DSO *dso); + int (*finish)(DSO *dso); + } DSO_METHOD; + +/**********************************************************************/ +/* The low-level handle type used to refer to a loaded shared library */ + +struct dso_st + { + DSO_METHOD *meth; + /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS + * doesn't use anything but will need to cache the filename + * for use in the dso_bind handler. All in all, let each + * method control its own destiny. "Handles" and such go in + * a STACK. */ + STACK *meth_data; + int references; + int flags; + /* For use by applications etc ... use this for your bits'n'pieces, + * don't touch meth_data! */ + CRYPTO_EX_DATA ex_data; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_name_converter. NB: This + * should normally set using DSO_set_name_converter(). */ + DSO_NAME_CONVERTER_FUNC name_converter; + /* If this callback function pointer is set to non-NULL, then it will + * be used in DSO_load() in place of meth->dso_merger. NB: This + * should normally set using DSO_set_merger(). */ + DSO_MERGER_FUNC merger; + /* This is populated with (a copy of) the platform-independant + * filename used for this DSO. */ + char *filename; + /* This is populated with (a copy of) the translated filename by which + * the DSO was actually loaded. It is NULL iff the DSO is not currently + * loaded. NB: This is here because the filename translation process + * may involve a callback being invoked more than once not only to + * convert to a platform-specific form, but also to try different + * filenames in the process of trying to perform a load. As such, this + * variable can be used to indicate (a) whether this DSO structure + * corresponds to a loaded library or not, and (b) the filename with + * which it was actually loaded. */ + char *loaded_filename; + }; + + +DSO * DSO_new(void); +DSO * DSO_new_method(DSO_METHOD *method); +int DSO_free(DSO *dso); +int DSO_flags(DSO *dso); +int DSO_up_ref(DSO *dso); +long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); + +/* This function sets the DSO's name_converter callback. If it is non-NULL, + * then it will be used instead of the associated DSO_METHOD's function. If + * oldcb is non-NULL then it is set to the function pointer value being + * replaced. Return value is non-zero for success. */ +int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, + DSO_NAME_CONVERTER_FUNC *oldcb); +/* These functions can be used to get/set the platform-independant filename + * used for a DSO. NB: set will fail if the DSO is already loaded. */ +const char *DSO_get_filename(DSO *dso); +int DSO_set_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's name_converter callback to translate a + * filename, or if the callback isn't set it will instead use the DSO_METHOD's + * converter. If "filename" is NULL, the "filename" in the DSO itself will be + * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is + * simply duplicated. NB: This function is usually called from within a + * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that + * caller-created DSO_METHODs can do the same thing. A non-NULL return value + * will need to be OPENSSL_free()'d. */ +char *DSO_convert_filename(DSO *dso, const char *filename); +/* This function will invoke the DSO's merger callback to merge two file + * specifications, or if the callback isn't set it will instead use the + * DSO_METHOD's merger. A non-NULL return value will need to be + * OPENSSL_free()'d. */ +char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); +/* If the DSO is currently loaded, this returns the filename that it was loaded + * under, otherwise it returns NULL. So it is also useful as a test as to + * whether the DSO is currently loaded. NB: This will not necessarily return + * the same value as DSO_convert_filename(dso, dso->filename), because the + * DSO_METHOD's load function may have tried a variety of filenames (with + * and/or without the aid of the converters) before settling on the one it + * actually loaded. */ +const char *DSO_get_loaded_filename(DSO *dso); + +void DSO_set_default_method(DSO_METHOD *meth); +DSO_METHOD *DSO_get_default_method(void); +DSO_METHOD *DSO_get_method(DSO *dso); +DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); + +/* The all-singing all-dancing load function, you normally pass NULL + * for the first and third parameters. Use DSO_up and DSO_free for + * subsequent reference count handling. Any flags passed in will be set + * in the constructed DSO after its init() function but before the + * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ +DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); + +/* This function binds to a variable inside a shared library. */ +void *DSO_bind_var(DSO *dso, const char *symname); + +/* This function binds to a function inside a shared library. */ +DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); + +/* This method is the default, but will beg, borrow, or steal whatever + * method should be the default on any particular platform (including + * DSO_METH_null() if necessary). */ +DSO_METHOD *DSO_METHOD_openssl(void); + +/* This method is defined for all platforms - if a platform has no + * DSO support then this will be the only method! */ +DSO_METHOD *DSO_METHOD_null(void); + +/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions + * (dlopen, dlclose, dlsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dlfcn(void); + +/* If DSO_DL is defined, the standard dl.h-style functions (shl_load, + * shl_unload, shl_findsym, etc) will be used and incorporated into + * this method. If not, this method will return NULL. */ +DSO_METHOD *DSO_METHOD_dl(void); + +/* If WIN32 is defined, use DLLs. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_win32(void); + +/* If VMS is defined, use shared images. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_vms(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_DSO_strings(void); + +/* Error codes for the DSO functions. */ + +/* Function codes. */ +#define DSO_F_DLFCN_BIND_FUNC 100 +#define DSO_F_DLFCN_BIND_VAR 101 +#define DSO_F_DLFCN_LOAD 102 +#define DSO_F_DLFCN_MERGER 130 +#define DSO_F_DLFCN_NAME_CONVERTER 123 +#define DSO_F_DLFCN_UNLOAD 103 +#define DSO_F_DL_BIND_FUNC 104 +#define DSO_F_DL_BIND_VAR 105 +#define DSO_F_DL_LOAD 106 +#define DSO_F_DL_MERGER 131 +#define DSO_F_DL_NAME_CONVERTER 124 +#define DSO_F_DL_UNLOAD 107 +#define DSO_F_DSO_BIND_FUNC 108 +#define DSO_F_DSO_BIND_VAR 109 +#define DSO_F_DSO_CONVERT_FILENAME 126 +#define DSO_F_DSO_CTRL 110 +#define DSO_F_DSO_FREE 111 +#define DSO_F_DSO_GET_FILENAME 127 +#define DSO_F_DSO_GET_LOADED_FILENAME 128 +#define DSO_F_DSO_LOAD 112 +#define DSO_F_DSO_MERGE 132 +#define DSO_F_DSO_NEW_METHOD 113 +#define DSO_F_DSO_SET_FILENAME 129 +#define DSO_F_DSO_SET_NAME_CONVERTER 122 +#define DSO_F_DSO_UP_REF 114 +#define DSO_F_VMS_BIND_SYM 115 +#define DSO_F_VMS_LOAD 116 +#define DSO_F_VMS_MERGER 133 +#define DSO_F_VMS_UNLOAD 117 +#define DSO_F_WIN32_BIND_FUNC 118 +#define DSO_F_WIN32_BIND_VAR 119 +#define DSO_F_WIN32_JOINER 135 +#define DSO_F_WIN32_LOAD 120 +#define DSO_F_WIN32_MERGER 134 +#define DSO_F_WIN32_NAME_CONVERTER 125 +#define DSO_F_WIN32_SPLITTER 136 +#define DSO_F_WIN32_UNLOAD 121 + +/* Reason codes. */ +#define DSO_R_CTRL_FAILED 100 +#define DSO_R_DSO_ALREADY_LOADED 110 +#define DSO_R_EMPTY_FILE_STRUCTURE 113 +#define DSO_R_FAILURE 114 +#define DSO_R_FILENAME_TOO_BIG 101 +#define DSO_R_FINISH_FAILED 102 +#define DSO_R_INCORRECT_FILE_SYNTAX 115 +#define DSO_R_LOAD_FAILED 103 +#define DSO_R_NAME_TRANSLATION_FAILED 109 +#define DSO_R_NO_FILENAME 111 +#define DSO_R_NO_FILE_SPECIFICATION 116 +#define DSO_R_NULL_HANDLE 104 +#define DSO_R_SET_FILENAME_FAILED 112 +#define DSO_R_STACK_ERROR 105 +#define DSO_R_SYM_FAILURE 106 +#define DSO_R_UNLOAD_FAILED 107 +#define DSO_R_UNSUPPORTED 108 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/dtls1.h b/libraries/external/openssl/pc/include/openssl/dtls1.h new file mode 100755 index 0000000..8093a8f --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/dtls1.h @@ -0,0 +1,212 @@ +/* ssl/dtls1.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_DTLS1_H +#define HEADER_DTLS1_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DTLS1_VERSION 0x0100 +#define DTLS1_VERSION_MAJOR 0x01 +#define DTLS1_VERSION_MINOR 0x00 + +#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110 + +/* lengths of messages */ +#define DTLS1_COOKIE_LENGTH 32 + +#define DTLS1_RT_HEADER_LENGTH 13 + +#define DTLS1_HM_HEADER_LENGTH 12 + +#define DTLS1_HM_BAD_FRAGMENT -2 +#define DTLS1_HM_FRAGMENT_RETRY -3 + +#define DTLS1_CCS_HEADER_LENGTH 3 + +#define DTLS1_AL_HEADER_LENGTH 7 + + +typedef struct dtls1_bitmap_st + { + PQ_64BIT map; + unsigned long length; /* sizeof the bitmap in bits */ + PQ_64BIT max_seq_num; /* max record number seen so far */ + } DTLS1_BITMAP; + +struct hm_header_st + { + unsigned char type; + unsigned long msg_len; + unsigned short seq; + unsigned long frag_off; + unsigned long frag_len; + unsigned int is_ccs; + }; + +struct ccs_header_st + { + unsigned char type; + unsigned short seq; + }; + +struct dtls1_timeout_st + { + /* Number of read timeouts so far */ + unsigned int read_timeouts; + + /* Number of write timeouts so far */ + unsigned int write_timeouts; + + /* Number of alerts received so far */ + unsigned int num_alerts; + }; + +typedef struct record_pqueue_st + { + unsigned short epoch; + pqueue q; + } record_pqueue; + +typedef struct hm_fragment_st + { + struct hm_header_st msg_header; + unsigned char *fragment; + } hm_fragment; + +typedef struct dtls1_state_st + { + unsigned int send_cookie; + unsigned char cookie[DTLS1_COOKIE_LENGTH]; + unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; + unsigned int cookie_len; + + /* + * The current data and handshake epoch. This is initially + * undefined, and starts at zero once the initial handshake is + * completed + */ + unsigned short r_epoch; + unsigned short w_epoch; + + /* records being received in the current epoch */ + DTLS1_BITMAP bitmap; + + /* renegotiation starts a new set of sequence numbers */ + DTLS1_BITMAP next_bitmap; + + /* handshake message numbers */ + unsigned short handshake_write_seq; + unsigned short next_handshake_write_seq; + + unsigned short handshake_read_seq; + + /* Received handshake records (processed and unprocessed) */ + record_pqueue unprocessed_rcds; + record_pqueue processed_rcds; + + /* Buffered handshake messages */ + pqueue buffered_messages; + + /* Buffered (sent) handshake records */ + pqueue sent_messages; + + unsigned int mtu; /* max wire packet size */ + + struct hm_header_st w_msg_hdr; + struct hm_header_st r_msg_hdr; + + struct dtls1_timeout_st timeout; + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; + unsigned int handshake_fragment_len; + + unsigned int retransmitting; + + } DTLS1_STATE; + +typedef struct dtls1_record_data_st + { + unsigned char *packet; + unsigned int packet_length; + SSL3_BUFFER rbuf; + SSL3_RECORD rrec; + } DTLS1_RECORD_DATA; + + +/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ +#define DTLS1_TMO_READ_COUNT 2 +#define DTLS1_TMO_WRITE_COUNT 2 + +#define DTLS1_TMO_ALERT_COUNT 12 + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/e_os2.h b/libraries/external/openssl/pc/include/openssl/e_os2.h new file mode 100755 index 0000000..79bfe24 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/e_os2.h @@ -0,0 +1,279 @@ +/* e_os2.h */ +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +#ifndef HEADER_E_OS2_H +#define HEADER_E_OS2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************** + * Detect operating systems. This probably needs completing. + * The result is that at least one OPENSSL_SYS_os macro should be defined. + * However, if none is defined, Unix is assumed. + **/ + +#define OPENSSL_SYS_UNIX + +/* ----------------------- Macintosh, before MacOS X ----------------------- */ +#if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MACINTOSH_CLASSIC +#endif + +/* ----------------------- NetWare ----------------------------------------- */ +#if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_NETWARE +#endif + +/* ---------------------- Microsoft operating systems ---------------------- */ + +/* Note that MSDOS actually denotes 32-bit environments running on top of + MS-DOS, such as DJGPP one. */ +#if defined(OPENSSL_SYSNAME_MSDOS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_MSDOS +#endif + +/* For 32 bit environment, there seems to be the CygWin environment and then + all the others that try to do the same thing Microsoft does... */ +#if defined(OPENSSL_SYSNAME_UWIN) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_UWIN +#else +# if defined(__CYGWIN32__) || defined(OPENSSL_SYSNAME_CYGWIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_CYGWIN +# else +# if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32 +# endif +# if defined(OPENSSL_SYSNAME_WINNT) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINNT +# endif +# if defined(OPENSSL_SYSNAME_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINCE +# endif +# endif +#endif + +/* Anything that tries to look like Microsoft is "Windows" */ +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_SYS_MSDOS +# define OPENSSL_SYS_MSDOS +# endif +#endif + +/* DLL settings. This part is a bit tough, because it's up to the application + implementor how he or she will link the application, so it requires some + macro to be used. */ +#ifdef OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_OPT_WINDLL +# if defined(_WINDLL) /* This is used when building OpenSSL to indicate that + DLL linkage should be used */ +# define OPENSSL_OPT_WINDLL +# endif +# endif +#endif + +/* -------------------------------- OpenVMS -------------------------------- */ +#if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_VMS +# if defined(__DECC) +# define OPENSSL_SYS_VMS_DECC +# elif defined(__DECCXX) +# define OPENSSL_SYS_VMS_DECC +# define OPENSSL_SYS_VMS_DECCXX +# else +# define OPENSSL_SYS_VMS_NODECC +# endif +#endif + +/* --------------------------------- OS/2 ---------------------------------- */ +#if defined(__EMX__) || defined(__OS2__) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_OS2 +#endif + +/* --------------------------------- Unix ---------------------------------- */ +#ifdef OPENSSL_SYS_UNIX +# if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX) +# define OPENSSL_SYS_LINUX +# endif +# ifdef OPENSSL_SYSNAME_MPE +# define OPENSSL_SYS_MPE +# endif +# ifdef OPENSSL_SYSNAME_SNI +# define OPENSSL_SYS_SNI +# endif +# ifdef OPENSSL_SYSNAME_ULTRASPARC +# define OPENSSL_SYS_ULTRASPARC +# endif +# ifdef OPENSSL_SYSNAME_NEWS4 +# define OPENSSL_SYS_NEWS4 +# endif +# ifdef OPENSSL_SYSNAME_MACOSX +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX_RHAPSODY +# define OPENSSL_SYS_MACOSX +# endif +# ifdef OPENSSL_SYSNAME_SUNOS +# define OPENSSL_SYS_SUNOS +#endif +# if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY) +# define OPENSSL_SYS_CRAY +# endif +# if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX) +# define OPENSSL_SYS_AIX +# endif +#endif + +/* --------------------------------- VOS ----------------------------------- */ +#ifdef OPENSSL_SYSNAME_VOS +# define OPENSSL_SYS_VOS +#endif + +/* ------------------------------- VxWorks --------------------------------- */ +#ifdef OPENSSL_SYSNAME_VXWORKS +# define OPENSSL_SYS_VXWORKS +#endif + +/** + * That's it for OS-specific stuff + *****************************************************************************/ + + +/* Specials for I/O an exit */ +#ifdef OPENSSL_SYS_MSDOS +# define OPENSSL_UNISTD_IO +# define OPENSSL_DECLARE_EXIT extern void exit(int); +#else +# define OPENSSL_UNISTD_IO OPENSSL_UNISTD +# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ +#endif + +/* Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare + certain global symbols that, with some compilers under VMS, have to be + defined and declared explicitely with globaldef and globalref. + Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare + DLL exports and imports for compilers under Win32. These are a little + more complicated to use. Basically, for any library that exports some + global variables, the following code must be present in the header file + that declares them, before OPENSSL_EXTERN is used: + + #ifdef SOME_BUILD_FLAG_MACRO + # undef OPENSSL_EXTERN + # define OPENSSL_EXTERN OPENSSL_EXPORT + #endif + + The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL + have some generally sensible values, and for OPENSSL_EXTERN to have the + value OPENSSL_IMPORT. +*/ + +#if defined(OPENSSL_SYS_VMS_NODECC) +# define OPENSSL_EXPORT globalref +# define OPENSSL_IMPORT globalref +# define OPENSSL_GLOBAL globaldef +#elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) +# define OPENSSL_EXPORT extern __declspec(dllexport) +# define OPENSSL_IMPORT extern __declspec(dllimport) +# define OPENSSL_GLOBAL +#else +# define OPENSSL_EXPORT extern +# define OPENSSL_IMPORT extern +# define OPENSSL_GLOBAL +#endif +#define OPENSSL_EXTERN OPENSSL_IMPORT + +/* Macros to allow global variables to be reached through function calls when + required (if a shared library version requvres it, for example. + The way it's done allows definitions like this: + + // in foobar.c + OPENSSL_IMPLEMENT_GLOBAL(int,foobar) = 0; + // in foobar.h + OPENSSL_DECLARE_GLOBAL(int,foobar); + #define foobar OPENSSL_GLOBAL_REF(foobar) +*/ +#ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) \ + extern type _hide_##name; \ + type *_shadow_##name(void) { return &_hide_##name; } \ + static type _hide_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) +# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) +#else +# define OPENSSL_IMPLEMENT_GLOBAL(type,name) OPENSSL_GLOBAL type _shadow_##name +# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name +# define OPENSSL_GLOBAL_REF(name) _shadow_##name +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ebcdic.h b/libraries/external/openssl/pc/include/openssl/ebcdic.h new file mode 100755 index 0000000..0941c8b --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ebcdic.h @@ -0,0 +1,19 @@ +/* crypto/ebcdic.h */ + +#ifndef HEADER_EBCDIC_H +#define HEADER_EBCDIC_H + +#include + +/* Avoid name clashes with other applications */ +#define os_toascii _openssl_os_toascii +#define os_toebcdic _openssl_os_toebcdic +#define ebcdic2ascii _openssl_ebcdic2ascii +#define ascii2ebcdic _openssl_ascii2ebcdic + +extern const unsigned char os_toascii[256]; +extern const unsigned char os_toebcdic[256]; +void *ebcdic2ascii(void *dest, const void *srce, size_t count); +void *ascii2ebcdic(void *dest, const void *srce, size_t count); + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ec.h b/libraries/external/openssl/pc/include/openssl/ec.h new file mode 100755 index 0000000..51304f7 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ec.h @@ -0,0 +1,525 @@ +/* crypto/ec/ec.h */ +/* + * Originally written by Bodo Moeller for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The elliptic curve binary polynomial software is originally written by + * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_EC_H +#define HEADER_EC_H + +#include + +#ifdef OPENSSL_NO_EC +#error EC is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#elif defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + + +#ifndef OPENSSL_ECC_MAX_FIELD_BITS +# define OPENSSL_ECC_MAX_FIELD_BITS 661 +#endif + +typedef enum { + /* values as defined in X9.62 (ECDSA) and elsewhere */ + POINT_CONVERSION_COMPRESSED = 2, + POINT_CONVERSION_UNCOMPRESSED = 4, + POINT_CONVERSION_HYBRID = 6 +} point_conversion_form_t; + + +typedef struct ec_method_st EC_METHOD; + +typedef struct ec_group_st + /* + EC_METHOD *meth; + -- field definition + -- curve coefficients + -- optional generator with associated information (order, cofactor) + -- optional extra data (precomputed table for fast computation of multiples of generator) + -- ASN1 stuff + */ + EC_GROUP; + +typedef struct ec_point_st EC_POINT; + + +/* EC_METHODs for curves over GF(p). + * EC_GFp_simple_method provides the basis for the optimized methods. + */ +const EC_METHOD *EC_GFp_simple_method(void); +const EC_METHOD *EC_GFp_mont_method(void); +const EC_METHOD *EC_GFp_nist_method(void); + +/* EC_METHOD for curves over GF(2^m). + */ +const EC_METHOD *EC_GF2m_simple_method(void); + + +EC_GROUP *EC_GROUP_new(const EC_METHOD *); +void EC_GROUP_free(EC_GROUP *); +void EC_GROUP_clear_free(EC_GROUP *); +int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *); +EC_GROUP *EC_GROUP_dup(const EC_GROUP *); + +const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); +int EC_METHOD_get_field_type(const EC_METHOD *); + +int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); +const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); +int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *); +int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *); + +void EC_GROUP_set_curve_name(EC_GROUP *, int nid); +int EC_GROUP_get_curve_name(const EC_GROUP *); + +void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag); +int EC_GROUP_get_asn1_flag(const EC_GROUP *); + +void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t); +point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); + +unsigned char *EC_GROUP_get0_seed(const EC_GROUP *); +size_t EC_GROUP_get_seed_len(const EC_GROUP *); +size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); + +int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); +int EC_GROUP_set_curve_GF2m(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +int EC_GROUP_get_curve_GF2m(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); + +/* returns the number of bits needed to represent a field element */ +int EC_GROUP_get_degree(const EC_GROUP *); + +/* EC_GROUP_check() returns 1 if 'group' defines a valid group, 0 otherwise */ +int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); +/* EC_GROUP_check_discriminant() returns 1 if the discriminant of the + * elliptic curve is not zero, 0 otherwise */ +int EC_GROUP_check_discriminant(const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_cmp() returns 0 if both groups are equal and 1 otherwise */ +int EC_GROUP_cmp(const EC_GROUP *, const EC_GROUP *, BN_CTX *); + +/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() + * after choosing an appropriate EC_METHOD */ +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + +/* EC_GROUP_new_by_curve_name() creates a EC_GROUP structure + * specified by a curve name (in form of a NID) */ +EC_GROUP *EC_GROUP_new_by_curve_name(int nid); +/* handling of internal curves */ +typedef struct { + int nid; + const char *comment; + } EC_builtin_curve; +/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number + * of all available curves or zero if a error occurred. + * In case r ist not zero nitems EC_builtin_curve structures + * are filled with the data of the first nitems internal groups */ +size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); + + +/* EC_POINT functions */ + +EC_POINT *EC_POINT_new(const EC_GROUP *); +void EC_POINT_free(EC_POINT *); +void EC_POINT_clear_free(EC_POINT *); +int EC_POINT_copy(EC_POINT *, const EC_POINT *); +EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); + +const EC_METHOD *EC_POINT_method_of(const EC_POINT *); + +int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *); +int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); +int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, const BIGNUM *y, BN_CTX *); +int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); +int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, BN_CTX *); + +size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); + +/* other interfaces to point2oct/oct2point: */ +BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BIGNUM *, BN_CTX *); +EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, + EC_POINT *, BN_CTX *); +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, + EC_POINT *, BN_CTX *); + +int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); +int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); +int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); + +int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + +int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); + + +int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *); +int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *); + +/* EC_GROUP_precompute_mult() stores multiples of generator for faster point multiplication */ +int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); +/* EC_GROUP_have_precompute_mult() reports whether such precomputation has been done */ +int EC_GROUP_have_precompute_mult(const EC_GROUP *); + + + +/* ASN1 stuff */ + +/* EC_GROUP_get_basis_type() returns the NID of the basis type + * used to represent the field elements */ +int EC_GROUP_get_basis_type(const EC_GROUP *); +int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); + +#define OPENSSL_EC_NAMED_CURVE 0x001 + +typedef struct ecpk_parameters_st ECPKPARAMETERS; + +EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); +int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); + +#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) +#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) +#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ + (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) +#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ + (unsigned char *)(x)) + +#ifndef OPENSSL_NO_BIO +int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); +#endif + +/* the EC_KEY stuff */ +typedef struct ec_key_st EC_KEY; + +/* some values for the encoding_flag */ +#define EC_PKEY_NO_PARAMETERS 0x001 +#define EC_PKEY_NO_PUBKEY 0x002 + +EC_KEY *EC_KEY_new(void); +EC_KEY *EC_KEY_new_by_curve_name(int nid); +void EC_KEY_free(EC_KEY *); +EC_KEY *EC_KEY_copy(EC_KEY *, const EC_KEY *); +EC_KEY *EC_KEY_dup(const EC_KEY *); + +int EC_KEY_up_ref(EC_KEY *); + +const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); +int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); +const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); +int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); +const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); +int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); +unsigned EC_KEY_get_enc_flags(const EC_KEY *); +void EC_KEY_set_enc_flags(EC_KEY *, unsigned int); +point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *); +void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t); +/* functions to set/get method specific data */ +void *EC_KEY_get_key_method_data(EC_KEY *, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +void EC_KEY_insert_key_method_data(EC_KEY *, void *data, + void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); +/* wrapper functions for the underlying EC_GROUP object */ +void EC_KEY_set_asn1_flag(EC_KEY *, int); +int EC_KEY_precompute_mult(EC_KEY *, BN_CTX *ctx); + +/* EC_KEY_generate_key() creates a ec private (public) key */ +int EC_KEY_generate_key(EC_KEY *); +/* EC_KEY_check_key() */ +int EC_KEY_check_key(const EC_KEY *); + +/* de- and encoding functions for SEC1 ECPrivateKey */ +EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC parameters */ +EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len); +int i2d_ECParameters(EC_KEY *a, unsigned char **out); +/* de- and encoding functions for EC public key + * (octet string, not DER -- hence 'o2i' and 'i2o') */ +EC_KEY *o2i_ECPublicKey(EC_KEY **a, const unsigned char **in, long len); +int i2o_ECPublicKey(EC_KEY *a, unsigned char **out); + +#ifndef OPENSSL_NO_BIO +int ECParameters_print(BIO *bp, const EC_KEY *x); +int EC_KEY_print(BIO *bp, const EC_KEY *x, int off); +#endif +#ifndef OPENSSL_NO_FP_API +int ECParameters_print_fp(FILE *fp, const EC_KEY *x); +int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off); +#endif + +#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) + +#ifndef __cplusplus +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +# endif +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EC_strings(void); + +/* Error codes for the EC functions. */ + +/* Function codes. */ +#define EC_F_COMPUTE_WNAF 143 +#define EC_F_D2I_ECPARAMETERS 144 +#define EC_F_D2I_ECPKPARAMETERS 145 +#define EC_F_D2I_ECPRIVATEKEY 146 +#define EC_F_ECPARAMETERS_PRINT 147 +#define EC_F_ECPARAMETERS_PRINT_FP 148 +#define EC_F_ECPKPARAMETERS_PRINT 149 +#define EC_F_ECPKPARAMETERS_PRINT_FP 150 +#define EC_F_ECP_NIST_MOD_192 203 +#define EC_F_ECP_NIST_MOD_224 204 +#define EC_F_ECP_NIST_MOD_256 205 +#define EC_F_ECP_NIST_MOD_521 206 +#define EC_F_EC_ASN1_GROUP2CURVE 153 +#define EC_F_EC_ASN1_GROUP2FIELDID 154 +#define EC_F_EC_ASN1_GROUP2PARAMETERS 155 +#define EC_F_EC_ASN1_GROUP2PKPARAMETERS 156 +#define EC_F_EC_ASN1_PARAMETERS2GROUP 157 +#define EC_F_EC_ASN1_PKPARAMETERS2GROUP 158 +#define EC_F_EC_EX_DATA_SET_DATA 211 +#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 +#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 +#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 +#define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 +#define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 +#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 +#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 +#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 +#define EC_F_EC_GFP_MONT_FIELD_DECODE 133 +#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 +#define EC_F_EC_GFP_MONT_FIELD_MUL 131 +#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 +#define EC_F_EC_GFP_MONT_FIELD_SQR 132 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 +#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP 135 +#define EC_F_EC_GFP_NIST_FIELD_MUL 200 +#define EC_F_EC_GFP_NIST_FIELD_SQR 201 +#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 +#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100 +#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101 +#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 +#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 +#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 +#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 +#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 +#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 +#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129 +#define EC_F_EC_GROUP_CHECK 170 +#define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 +#define EC_F_EC_GROUP_COPY 106 +#define EC_F_EC_GROUP_GET0_GENERATOR 139 +#define EC_F_EC_GROUP_GET_COFACTOR 140 +#define EC_F_EC_GROUP_GET_CURVE_GF2M 172 +#define EC_F_EC_GROUP_GET_CURVE_GFP 130 +#define EC_F_EC_GROUP_GET_DEGREE 173 +#define EC_F_EC_GROUP_GET_ORDER 141 +#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 +#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 +#define EC_F_EC_GROUP_NEW 108 +#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 +#define EC_F_EC_GROUP_NEW_FROM_DATA 175 +#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 +#define EC_F_EC_GROUP_SET_CURVE_GF2M 176 +#define EC_F_EC_GROUP_SET_CURVE_GFP 109 +#define EC_F_EC_GROUP_SET_EXTRA_DATA 110 +#define EC_F_EC_GROUP_SET_GENERATOR 111 +#define EC_F_EC_KEY_CHECK_KEY 177 +#define EC_F_EC_KEY_COPY 178 +#define EC_F_EC_KEY_GENERATE_KEY 179 +#define EC_F_EC_KEY_NEW 182 +#define EC_F_EC_KEY_PRINT 180 +#define EC_F_EC_KEY_PRINT_FP 181 +#define EC_F_EC_POINTS_MAKE_AFFINE 136 +#define EC_F_EC_POINTS_MUL 138 +#define EC_F_EC_POINT_ADD 112 +#define EC_F_EC_POINT_CMP 113 +#define EC_F_EC_POINT_COPY 114 +#define EC_F_EC_POINT_DBL 115 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 +#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 +#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 +#define EC_F_EC_POINT_INVERT 210 +#define EC_F_EC_POINT_IS_AT_INFINITY 118 +#define EC_F_EC_POINT_IS_ON_CURVE 119 +#define EC_F_EC_POINT_MAKE_AFFINE 120 +#define EC_F_EC_POINT_MUL 184 +#define EC_F_EC_POINT_NEW 121 +#define EC_F_EC_POINT_OCT2POINT 122 +#define EC_F_EC_POINT_POINT2OCT 123 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 +#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 +#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 +#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 +#define EC_F_EC_POINT_SET_TO_INFINITY 127 +#define EC_F_EC_PRE_COMP_DUP 207 +#define EC_F_EC_WNAF_MUL 187 +#define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 +#define EC_F_I2D_ECPARAMETERS 190 +#define EC_F_I2D_ECPKPARAMETERS 191 +#define EC_F_I2D_ECPRIVATEKEY 192 +#define EC_F_I2O_ECPUBLICKEY 151 +#define EC_F_O2I_ECPUBLICKEY 152 + +/* Reason codes. */ +#define EC_R_ASN1_ERROR 115 +#define EC_R_ASN1_UNKNOWN_FIELD 116 +#define EC_R_BUFFER_TOO_SMALL 100 +#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 +#define EC_R_DISCRIMINANT_IS_ZERO 118 +#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +#define EC_R_FIELD_TOO_LARGE 138 +#define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +#define EC_R_INCOMPATIBLE_OBJECTS 101 +#define EC_R_INVALID_ARGUMENT 112 +#define EC_R_INVALID_COMPRESSED_POINT 110 +#define EC_R_INVALID_COMPRESSION_BIT 109 +#define EC_R_INVALID_ENCODING 102 +#define EC_R_INVALID_FIELD 103 +#define EC_R_INVALID_FORM 104 +#define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_PENTANOMIAL_BASIS 132 +#define EC_R_INVALID_PRIVATE_KEY 123 +#define EC_R_INVALID_TRINOMIAL_BASIS 137 +#define EC_R_MISSING_PARAMETERS 124 +#define EC_R_MISSING_PRIVATE_KEY 125 +#define EC_R_NOT_A_NIST_PRIME 135 +#define EC_R_NOT_A_SUPPORTED_NIST_PRIME 136 +#define EC_R_NOT_IMPLEMENTED 126 +#define EC_R_NOT_INITIALIZED 111 +#define EC_R_NO_FIELD_MOD 133 +#define EC_R_PASSED_NULL_PARAMETER 134 +#define EC_R_PKPARAMETERS2GROUP_FAILURE 127 +#define EC_R_POINT_AT_INFINITY 106 +#define EC_R_POINT_IS_NOT_ON_CURVE 107 +#define EC_R_SLOT_FULL 108 +#define EC_R_UNDEFINED_GENERATOR 113 +#define EC_R_UNDEFINED_ORDER 128 +#define EC_R_UNKNOWN_GROUP 129 +#define EC_R_UNKNOWN_ORDER 114 +#define EC_R_UNSUPPORTED_FIELD 131 +#define EC_R_WRONG_ORDER 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ecdh.h b/libraries/external/openssl/pc/include/openssl/ecdh.h new file mode 100755 index 0000000..c2c00b8 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ecdh.h @@ -0,0 +1,123 @@ +/* crypto/ecdh/ecdh.h */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * The Elliptic Curve Public-Key Crypto Library (ECC Code) included + * herein is developed by SUN MICROSYSTEMS, INC., and is contributed + * to the OpenSSL project. + * + * The ECC Code is licensed pursuant to the OpenSSL open source + * license provided below. + * + * The ECDH software is originally written by Douglas Stebila of + * Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDH_H +#define HEADER_ECDH_H + +#include + +#ifdef OPENSSL_NO_ECDH +#error ECDH is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +const ECDH_METHOD *ECDH_OpenSSL(void); + +void ECDH_set_default_method(const ECDH_METHOD *); +const ECDH_METHOD *ECDH_get_default_method(void); +int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); + +int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); + +int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDH_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDH_strings(void); + +/* Error codes for the ECDH functions. */ + +/* Function codes. */ +#define ECDH_F_ECDH_COMPUTE_KEY 100 +#define ECDH_F_ECDH_DATA_NEW_METHOD 101 + +/* Reason codes. */ +#define ECDH_R_KDF_FAILED 102 +#define ECDH_R_NO_PRIVATE_VALUE 100 +#define ECDH_R_POINT_ARITHMETIC_FAILURE 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ecdsa.h b/libraries/external/openssl/pc/include/openssl/ecdsa.h new file mode 100755 index 0000000..294e2ba --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ecdsa.h @@ -0,0 +1,271 @@ +/* crypto/ecdsa/ecdsa.h */ +/** + * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions + * \author Written by Nils Larsch for the OpenSSL project + */ +/* ==================================================================== + * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_ECDSA_H +#define HEADER_ECDSA_H + +#include + +#ifdef OPENSSL_NO_ECDSA +#error ECDSA is disabled. +#endif + +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ECDSA_SIG_st + { + BIGNUM *r; + BIGNUM *s; + } ECDSA_SIG; + +/** ECDSA_SIG *ECDSA_SIG_new(void) + * allocates and initialize a ECDSA_SIG structure + * \return pointer to a ECDSA_SIG structure or NULL if an error occurred + */ +ECDSA_SIG *ECDSA_SIG_new(void); + +/** ECDSA_SIG_free + * frees a ECDSA_SIG structure + * \param a pointer to the ECDSA_SIG structure + */ +void ECDSA_SIG_free(ECDSA_SIG *a); + +/** i2d_ECDSA_SIG + * DER encode content of ECDSA_SIG object (note: this function modifies *pp + * (*pp += length of the DER encoded signature)). + * \param a pointer to the ECDSA_SIG object + * \param pp pointer to a unsigned char pointer for the output or NULL + * \return the length of the DER encoded ECDSA_SIG object or 0 + */ +int i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp); + +/** d2i_ECDSA_SIG + * decodes a DER encoded ECDSA signature (note: this function changes *pp + * (*pp += len)). + * \param v pointer to ECDSA_SIG pointer (may be NULL) + * \param pp buffer with the DER encoded signature + * \param len bufferlength + * \return pointer to the decoded ECDSA_SIG structure (or NULL) + */ +ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len); + +/** ECDSA_do_sign + * computes the ECDSA signature of the given hash value using + * the supplied private key and returns the created signature. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey); + +/** ECDSA_do_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return pointer to a ECDSA_SIG structure or NULL + */ +ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, + const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_do_verify + * verifies that the supplied signature is a valid ECDSA + * signature of the supplied hash value using the supplied public key. + * \param dgst pointer to the hash value + * \param dgst_len length of the hash value + * \param sig pointer to the ECDSA_SIG structure + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY* eckey); + +const ECDSA_METHOD *ECDSA_OpenSSL(void); + +/** ECDSA_set_default_method + * sets the default ECDSA method + * \param meth the new default ECDSA_METHOD + */ +void ECDSA_set_default_method(const ECDSA_METHOD *meth); + +/** ECDSA_get_default_method + * returns the default ECDSA method + * \return pointer to ECDSA_METHOD structure containing the default method + */ +const ECDSA_METHOD *ECDSA_get_default_method(void); + +/** ECDSA_set_method + * sets method to be used for the ECDSA operations + * \param eckey pointer to the EC_KEY object + * \param meth pointer to the new method + * \return 1 on success and 0 otherwise + */ +int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth); + +/** ECDSA_size + * returns the maximum length of the DER encoded signature + * \param eckey pointer to a EC_KEY object + * \return numbers of bytes required for the DER encoded signature + */ +int ECDSA_size(const EC_KEY *eckey); + +/** ECDSA_sign_setup + * precompute parts of the signing operation. + * \param eckey pointer to the EC_KEY object containing a private EC key + * \param ctx pointer to a BN_CTX object (may be NULL) + * \param kinv pointer to a BIGNUM pointer for the inverse of k + * \param rp pointer to a BIGNUM pointer for x coordinate of k * generator + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, + BIGNUM **rp); + +/** ECDSA_sign + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); + + +/** ECDSA_sign_ex + * computes ECDSA signature of a given hash value using the supplied + * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). + * \param type this parameter is ignored + * \param dgst pointer to the hash value to sign + * \param dgstlen length of the hash value + * \param sig buffer to hold the DER encoded signature + * \param siglen pointer to the length of the returned signature + * \param kinv optional pointer to a pre-computed inverse k + * \param rp optional pointer to the pre-computed rp value (see + * ECDSA_sign_setup + * \param eckey pointer to the EC_KEY object containing a private EC key + * \return 1 on success and 0 otherwise + */ +int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); + +/** ECDSA_verify + * verifies that the given signature is valid ECDSA signature + * of the supplied hash value using the specified public key. + * \param type this parameter is ignored + * \param dgst pointer to the hash value + * \param dgstlen length of the hash value + * \param sig pointer to the DER encoded signature + * \param siglen length of the DER encoded signature + * \param eckey pointer to the EC_KEY object containing a public EC key + * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error + */ +int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int siglen, EC_KEY *eckey); + +/* the standard ex_data functions */ +int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new + *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); +void *ECDSA_get_ex_data(EC_KEY *d, int idx); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ECDSA_strings(void); + +/* Error codes for the ECDSA functions. */ + +/* Function codes. */ +#define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 +#define ECDSA_F_ECDSA_DO_SIGN 101 +#define ECDSA_F_ECDSA_DO_VERIFY 102 +#define ECDSA_F_ECDSA_SIGN_SETUP 103 + +/* Reason codes. */ +#define ECDSA_R_BAD_SIGNATURE 100 +#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101 +#define ECDSA_R_ERR_EC_LIB 102 +#define ECDSA_R_MISSING_PARAMETERS 103 +#define ECDSA_R_NEED_NEW_SETUP_VALUES 106 +#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 +#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/engine.h b/libraries/external/openssl/pc/include/openssl/engine.h new file mode 100755 index 0000000..4fd0f09 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/engine.h @@ -0,0 +1,785 @@ +/* openssl/engine.h */ +/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_ENGINE_H +#define HEADER_ENGINE_H + +#include + +#ifdef OPENSSL_NO_ENGINE +#error ENGINE is disabled. +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#include +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#ifndef OPENSSL_NO_ECDH +#include +#endif +#ifndef OPENSSL_NO_ECDSA +#include +#endif +#include +#include +#include +#include +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These flags are used to control combinations of algorithm (methods) + * by bitwise "OR"ing. */ +#define ENGINE_METHOD_RSA (unsigned int)0x0001 +#define ENGINE_METHOD_DSA (unsigned int)0x0002 +#define ENGINE_METHOD_DH (unsigned int)0x0004 +#define ENGINE_METHOD_RAND (unsigned int)0x0008 +#define ENGINE_METHOD_ECDH (unsigned int)0x0010 +#define ENGINE_METHOD_ECDSA (unsigned int)0x0020 +#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 +#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 +#define ENGINE_METHOD_STORE (unsigned int)0x0100 +/* Obvious all-or-nothing cases. */ +#define ENGINE_METHOD_ALL (unsigned int)0xFFFF +#define ENGINE_METHOD_NONE (unsigned int)0x0000 + +/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used + * internally to control registration of ENGINE implementations, and can be set + * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to + * initialise registered ENGINEs if they are not already initialised. */ +#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 + +/* ENGINE flags that can be set by ENGINE_set_flags(). */ +/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */ + +/* This flag is for ENGINEs that wish to handle the various 'CMD'-related + * control commands on their own. Without this flag, ENGINE_ctrl() handles these + * control commands on behalf of the ENGINE using their "cmd_defns" data. */ +#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 + +/* This flag is for ENGINEs who return new duplicate structures when found via + * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl() + * commands are called in sequence as part of some stateful process like + * key-generation setup and execution), it can set this flag - then each attempt + * to obtain the ENGINE will result in it being copied into a new structure. + * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments + * the existing ENGINE's structural reference count. */ +#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 + +/* ENGINEs can support their own command types, and these flags are used in + * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each + * command expects. Currently only numeric and string input is supported. If a + * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options, + * then it is regarded as an "internal" control command - and not for use in + * config setting situations. As such, they're not available to the + * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to + * this list of 'command types' should be reflected carefully in + * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */ + +/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 +/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to + * ENGINE_ctrl) */ +#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 +/* Indicates that the control command takes *no* input. Ie. the control command + * is unparameterised. */ +#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 +/* Indicates that the control command is internal. This control command won't + * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() + * function. */ +#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 + +/* NB: These 3 control commands are deprecated and should not be used. ENGINEs + * relying on these commands should compile conditional support for + * compatibility (eg. if these symbols are defined) but should also migrate the + * same functionality to their own ENGINE-specific control functions that can be + * "discovered" by calling applications. The fact these control commands + * wouldn't be "executable" (ie. usable by text-based config) doesn't change the + * fact that application code can find and use them without requiring per-ENGINE + * hacking. */ + +/* These flags are used to tell the ctrl function what should be done. + * All command numbers are shared between all engines, even if some don't + * make sense to some engines. In such a case, they do nothing but return + * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ +#define ENGINE_CTRL_SET_LOGSTREAM 1 +#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 +#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any + handles/connections etc. */ +#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ +#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used + when calling the password + callback and the user + interface */ +#define ENGINE_CTRL_LOAD_CONFIGURATION 6 /* Load a configuration, given + a string that represents a + file name or so */ +#define ENGINE_CTRL_LOAD_SECTION 7 /* Load data from a given + section in the already loaded + configuration */ + +/* These control commands allow an application to deal with an arbitrary engine + * in a dynamic way. Warn: Negative return values indicate errors FOR THESE + * COMMANDS because zero is used to indicate 'end-of-list'. Other commands, + * including ENGINE-specific command types, return zero for an error. + * + * An ENGINE can choose to implement these ctrl functions, and can internally + * manage things however it chooses - it does so by setting the + * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the + * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns + * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl() + * handler need only implement its own commands - the above "meta" commands will + * be taken care of. */ + +/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then + * all the remaining control commands will return failure, so it is worth + * checking this first if the caller is trying to "discover" the engine's + * capabilities and doesn't want errors generated unnecessarily. */ +#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 +/* Returns a positive command number for the first command supported by the + * engine. Returns zero if no ctrl commands are supported. */ +#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 +/* The 'long' argument specifies a command implemented by the engine, and the + * return value is the next command supported, or zero if there are no more. */ +#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 +/* The 'void*' argument is a command name (cast from 'const char *'), and the + * return value is the command that corresponds to it. */ +#define ENGINE_CTRL_GET_CMD_FROM_NAME 13 +/* The next two allow a command to be converted into its corresponding string + * form. In each case, the 'long' argument supplies the command. In the NAME_LEN + * case, the return value is the length of the command name (not counting a + * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer + * large enough, and it will be populated with the name of the command (WITH a + * trailing EOL). */ +#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 +#define ENGINE_CTRL_GET_NAME_FROM_CMD 15 +/* The next two are similar but give a "short description" of a command. */ +#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 +#define ENGINE_CTRL_GET_DESC_FROM_CMD 17 +/* With this command, the return value is the OR'd combination of + * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given + * engine-specific ctrl command expects. */ +#define ENGINE_CTRL_GET_CMD_FLAGS 18 + +/* ENGINE implementations should start the numbering of their own control + * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ +#define ENGINE_CMD_BASE 200 + +/* NB: These 2 nCipher "chil" control commands are deprecated, and their + * functionality is now available through ENGINE-specific control commands + * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 + * commands should be migrated to the more general command handling before these + * are removed. */ + +/* Flags specific to the nCipher "chil" engine */ +#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 + /* Depending on the value of the (long)i argument, this sets or + * unsets the SimpleForkCheck flag in the CHIL API to enable or + * disable checking and workarounds for applications that fork(). + */ +#define ENGINE_CTRL_CHIL_NO_LOCKING 101 + /* This prevents the initialisation function from providing mutex + * callbacks to the nCipher library. */ + +/* If an ENGINE supports its own specific control commands and wishes the + * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its + * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries + * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that + * supports the stated commands (ie. the "cmd_num" entries as described by the + * array). NB: The array must be ordered in increasing order of cmd_num. + * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set + * to zero and/or cmd_name set to NULL. */ +typedef struct ENGINE_CMD_DEFN_st + { + unsigned int cmd_num; /* The command number */ + const char *cmd_name; /* The command name itself */ + const char *cmd_desc; /* A short description of the command */ + unsigned int cmd_flags; /* The input the command expects */ + } ENGINE_CMD_DEFN; + +/* Generic function pointer */ +typedef int (*ENGINE_GEN_FUNC_PTR)(void); +/* Generic function pointer taking no arguments */ +typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); +/* Generic load_key function pointer */ +typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, + UI_METHOD *ui_method, void *callback_data); +/* These callback types are for an ENGINE's handler for cipher and digest logic. + * These handlers have these prototypes; + * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); + * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); + * Looking at how to implement these handlers in the case of cipher support, if + * the framework wants the EVP_CIPHER for 'nid', it will call; + * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) + * If the framework wants a list of supported 'nid's, it will call; + * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) + */ +/* Returns to a pointer to the array of supported cipher 'nid's. If the second + * parameter is non-NULL it is set to the size of the returned array. */ +typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); +typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); + +/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE + * structures where the pointers have a "structural reference". This means that + * their reference is to allowed access to the structure but it does not imply + * that the structure is functional. To simply increment or decrement the + * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not + * required when iterating using ENGINE_get_next as it will automatically + * decrement the structural reference count of the "current" ENGINE and + * increment the structural reference count of the ENGINE it returns (unless it + * is NULL). */ + +/* Get the first/last "ENGINE" type available. */ +ENGINE *ENGINE_get_first(void); +ENGINE *ENGINE_get_last(void); +/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ +ENGINE *ENGINE_get_next(ENGINE *e); +ENGINE *ENGINE_get_prev(ENGINE *e); +/* Add another "ENGINE" type into the array. */ +int ENGINE_add(ENGINE *e); +/* Remove an existing "ENGINE" type from the array. */ +int ENGINE_remove(ENGINE *e); +/* Retrieve an engine from the list by its unique "id" value. */ +ENGINE *ENGINE_by_id(const char *id); +/* Add all the built-in engines. */ +void ENGINE_load_openssl(void); +void ENGINE_load_dynamic(void); +#ifndef OPENSSL_NO_STATIC_ENGINE +void ENGINE_load_4758cca(void); +void ENGINE_load_aep(void); +void ENGINE_load_atalla(void); +void ENGINE_load_chil(void); +void ENGINE_load_cswift(void); +#ifndef OPENSSL_NO_GMP +void ENGINE_load_gmp(void); +#endif +void ENGINE_load_nuron(void); +void ENGINE_load_sureware(void); +void ENGINE_load_ubsec(void); +#endif +void ENGINE_load_cryptodev(void); +void ENGINE_load_padlock(void); +void ENGINE_load_builtin_engines(void); + +/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation + * "registry" handling. */ +unsigned int ENGINE_get_table_flags(void); +void ENGINE_set_table_flags(unsigned int flags); + +/* Manage registration of ENGINEs per "table". For each type, there are 3 + * functions; + * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) + * ENGINE_unregister_***(e) - unregister the implementation from 'e' + * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list + * Cleanup is automatically registered from each table when required, so + * ENGINE_cleanup() will reverse any "register" operations. */ + +int ENGINE_register_RSA(ENGINE *e); +void ENGINE_unregister_RSA(ENGINE *e); +void ENGINE_register_all_RSA(void); + +int ENGINE_register_DSA(ENGINE *e); +void ENGINE_unregister_DSA(ENGINE *e); +void ENGINE_register_all_DSA(void); + +int ENGINE_register_ECDH(ENGINE *e); +void ENGINE_unregister_ECDH(ENGINE *e); +void ENGINE_register_all_ECDH(void); + +int ENGINE_register_ECDSA(ENGINE *e); +void ENGINE_unregister_ECDSA(ENGINE *e); +void ENGINE_register_all_ECDSA(void); + +int ENGINE_register_DH(ENGINE *e); +void ENGINE_unregister_DH(ENGINE *e); +void ENGINE_register_all_DH(void); + +int ENGINE_register_RAND(ENGINE *e); +void ENGINE_unregister_RAND(ENGINE *e); +void ENGINE_register_all_RAND(void); + +int ENGINE_register_STORE(ENGINE *e); +void ENGINE_unregister_STORE(ENGINE *e); +void ENGINE_register_all_STORE(void); + +int ENGINE_register_ciphers(ENGINE *e); +void ENGINE_unregister_ciphers(ENGINE *e); +void ENGINE_register_all_ciphers(void); + +int ENGINE_register_digests(ENGINE *e); +void ENGINE_unregister_digests(ENGINE *e); +void ENGINE_register_all_digests(void); + +/* These functions register all support from the above categories. Note, use of + * these functions can result in static linkage of code your application may not + * need. If you only need a subset of functionality, consider using more + * selective initialisation. */ +int ENGINE_register_complete(ENGINE *e); +int ENGINE_register_all_complete(void); + +/* Send parametrised control commands to the engine. The possibilities to send + * down an integer, a pointer to data or a function pointer are provided. Any of + * the parameters may or may not be NULL, depending on the command number. In + * actuality, this function only requires a structural (rather than functional) + * reference to an engine, but many control commands may require the engine be + * functional. The caller should be aware of trying commands that require an + * operational ENGINE, and only use functional references in such situations. */ +int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); + +/* This function tests if an ENGINE-specific command is usable as a "setting". + * Eg. in an application's config file that gets processed through + * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to + * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */ +int ENGINE_cmd_is_executable(ENGINE *e, int cmd); + +/* This function works like ENGINE_ctrl() with the exception of taking a + * command name instead of a command number, and can handle optional commands. + * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to + * use the cmd_name and cmd_optional. */ +int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, + long i, void *p, void (*f)(void), int cmd_optional); + +/* This function passes a command-name and argument to an ENGINE. The cmd_name + * is converted to a command number and the control command is called using + * 'arg' as an argument (unless the ENGINE doesn't support such a command, in + * which case no control command is called). The command is checked for input + * flags, and if necessary the argument will be converted to a numeric value. If + * cmd_optional is non-zero, then if the ENGINE doesn't support the given + * cmd_name the return value will be success anyway. This function is intended + * for applications to use so that users (or config files) can supply + * engine-specific config data to the ENGINE at run-time to control behaviour of + * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl() + * functions that return data, deal with binary data, or that are otherwise + * supposed to be used directly through ENGINE_ctrl() in application code. Any + * "return" data from an ENGINE_ctrl() operation in this function will be lost - + * the return value is interpreted as failure if the return value is zero, + * success otherwise, and this function returns a boolean value as a result. In + * other words, vendors of 'ENGINE'-enabled devices should write ENGINE + * implementations with parameterisations that work in this scheme, so that + * compliant ENGINE-based applications can work consistently with the same + * configuration for the same ENGINE-enabled devices, across applications. */ +int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, + int cmd_optional); + +/* These functions are useful for manufacturing new ENGINE structures. They + * don't address reference counting at all - one uses them to populate an ENGINE + * structure with personalised implementations of things prior to using it + * directly or adding it to the builtin ENGINE list in OpenSSL. These are also + * here so that the ENGINE structure doesn't have to be exposed and break binary + * compatibility! */ +ENGINE *ENGINE_new(void); +int ENGINE_free(ENGINE *e); +int ENGINE_up_ref(ENGINE *e); +int ENGINE_set_id(ENGINE *e, const char *id); +int ENGINE_set_name(ENGINE *e, const char *name); +int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); +int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); +int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); +int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); +int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); +int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); +int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); +int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); +int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); +int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); +int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); +int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); +int ENGINE_set_flags(ENGINE *e, int flags); +int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); +/* These functions allow control over any per-structure ENGINE data. */ +int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); +void *ENGINE_get_ex_data(const ENGINE *e, int idx); + +/* This function cleans up anything that needs it. Eg. the ENGINE_add() function + * automatically ensures the list cleanup function is registered to be called + * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure + * ENGINE_cleanup() will clean up after them. */ +void ENGINE_cleanup(void); + +/* These return values from within the ENGINE structure. These can be useful + * with functional references as well as structural references - it depends + * which you obtained. Using the result for functional purposes if you only + * obtained a structural reference may be problematic! */ +const char *ENGINE_get_id(const ENGINE *e); +const char *ENGINE_get_name(const ENGINE *e); +const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); +const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); +const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); +const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); +const DH_METHOD *ENGINE_get_DH(const ENGINE *e); +const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); +const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); +ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); +ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); +ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); +const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); +const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); +const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); +int ENGINE_get_flags(const ENGINE *e); + +/* FUNCTIONAL functions. These functions deal with ENGINE structures + * that have (or will) be initialised for use. Broadly speaking, the + * structural functions are useful for iterating the list of available + * engine types, creating new engine types, and other "list" operations. + * These functions actually deal with ENGINEs that are to be used. As + * such these functions can fail (if applicable) when particular + * engines are unavailable - eg. if a hardware accelerator is not + * attached or not functioning correctly. Each ENGINE has 2 reference + * counts; structural and functional. Every time a functional reference + * is obtained or released, a corresponding structural reference is + * automatically obtained or released too. */ + +/* Initialise a engine type for use (or up its reference count if it's + * already in use). This will fail if the engine is not currently + * operational and cannot initialise. */ +int ENGINE_init(ENGINE *e); +/* Free a functional reference to a engine type. This does not require + * a corresponding call to ENGINE_free as it also releases a structural + * reference. */ +int ENGINE_finish(ENGINE *e); + +/* The following functions handle keys that are stored in some secondary + * location, handled by the engine. The storage may be on a card or + * whatever. */ +EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); + +/* This returns a pointer for the current ENGINE structure that + * is (by default) performing any RSA operations. The value returned + * is an incremented reference, so it should be free'd (ENGINE_finish) + * before it is discarded. */ +ENGINE *ENGINE_get_default_RSA(void); +/* Same for the other "methods" */ +ENGINE *ENGINE_get_default_DSA(void); +ENGINE *ENGINE_get_default_ECDH(void); +ENGINE *ENGINE_get_default_ECDSA(void); +ENGINE *ENGINE_get_default_DH(void); +ENGINE *ENGINE_get_default_RAND(void); +/* These functions can be used to get a functional reference to perform + * ciphering or digesting corresponding to "nid". */ +ENGINE *ENGINE_get_cipher_engine(int nid); +ENGINE *ENGINE_get_digest_engine(int nid); + +/* This sets a new default ENGINE structure for performing RSA + * operations. If the result is non-zero (success) then the ENGINE + * structure will have had its reference count up'd so the caller + * should still free their own reference 'e'. */ +int ENGINE_set_default_RSA(ENGINE *e); +int ENGINE_set_default_string(ENGINE *e, const char *def_list); +/* Same for the other "methods" */ +int ENGINE_set_default_DSA(ENGINE *e); +int ENGINE_set_default_ECDH(ENGINE *e); +int ENGINE_set_default_ECDSA(ENGINE *e); +int ENGINE_set_default_DH(ENGINE *e); +int ENGINE_set_default_RAND(ENGINE *e); +int ENGINE_set_default_ciphers(ENGINE *e); +int ENGINE_set_default_digests(ENGINE *e); + +/* The combination "set" - the flags are bitwise "OR"d from the + * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" + * function, this function can result in unnecessary static linkage. If your + * application requires only specific functionality, consider using more + * selective functions. */ +int ENGINE_set_default(ENGINE *e, unsigned int flags); + +void ENGINE_add_conf_module(void); + +/* Deprecated functions ... */ +/* int ENGINE_clear_defaults(void); */ + +/**************************/ +/* DYNAMIC ENGINE SUPPORT */ +/**************************/ + +/* Binary/behaviour compatibility levels */ +#define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000 +/* Binary versions older than this are too old for us (whether we're a loader or + * a loadee) */ +#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000 + +/* When compiling an ENGINE entirely as an external shared library, loadable by + * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure + * type provides the calling application's (or library's) error functionality + * and memory management function pointers to the loaded library. These should + * be used/set in the loaded library code so that the loading application's + * 'state' will be used/changed in all operations. The 'static_state' pointer + * allows the loaded library to know if it shares the same static data as the + * calling application (or library), and thus whether these callbacks need to be + * set or not. */ +typedef void *(*dyn_MEM_malloc_cb)(size_t); +typedef void *(*dyn_MEM_realloc_cb)(void *, size_t); +typedef void (*dyn_MEM_free_cb)(void *); +typedef struct st_dynamic_MEM_fns { + dyn_MEM_malloc_cb malloc_cb; + dyn_MEM_realloc_cb realloc_cb; + dyn_MEM_free_cb free_cb; + } dynamic_MEM_fns; +/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use + * these types so we (and any other dependant code) can simplify a bit?? */ +typedef void (*dyn_lock_locking_cb)(int,int,const char *,int); +typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int); +typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( + const char *,int); +typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *, + const char *,int); +typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *, + const char *,int); +typedef struct st_dynamic_LOCK_fns { + dyn_lock_locking_cb lock_locking_cb; + dyn_lock_add_lock_cb lock_add_lock_cb; + dyn_dynlock_create_cb dynlock_create_cb; + dyn_dynlock_lock_cb dynlock_lock_cb; + dyn_dynlock_destroy_cb dynlock_destroy_cb; + } dynamic_LOCK_fns; +/* The top-level structure */ +typedef struct st_dynamic_fns { + void *static_state; + const ERR_FNS *err_fns; + const CRYPTO_EX_DATA_IMPL *ex_data_fns; + dynamic_MEM_fns mem_fns; + dynamic_LOCK_fns lock_fns; + } dynamic_fns; + +/* The version checking function should be of this prototype. NB: The + * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code. + * If this function returns zero, it indicates a (potential) version + * incompatibility and the loaded library doesn't believe it can proceed. + * Otherwise, the returned value is the (latest) version supported by the + * loading library. The loader may still decide that the loaded code's version + * is unsatisfactory and could veto the load. The function is expected to + * be implemented with the symbol name "v_check", and a default implementation + * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ +typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); +#define IMPLEMENT_DYNAMIC_CHECK_FN() \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ + if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ + return 0; } + +/* This function is passed the ENGINE structure to initialise with its own + * function and command settings. It should not adjust the structural or + * functional reference counts. If this function returns zero, (a) the load will + * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the + * structure, and (c) the shared library will be unloaded. So implementations + * should do their own internal cleanup in failure circumstances otherwise they + * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that + * the loader is looking for. If this is NULL, the shared library can choose to + * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared + * library must initialise only an ENGINE matching the passed 'id'. The function + * is expected to be implemented with the symbol name "bind_engine". A standard + * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where + * the parameter 'fn' is a callback function that populates the ENGINE structure + * and returns an int value (zero for failure). 'fn' should have prototype; + * [static] int fn(ENGINE *e, const char *id); */ +typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, + const dynamic_fns *fns); +#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ + if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ + if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ + fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \ + return 0; \ + CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \ + CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \ + CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \ + CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \ + CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \ + if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \ + return 0; \ + if(!ERR_set_implementation(fns->err_fns)) return 0; \ + skip_cbs: \ + if(!fn(e,id)) return 0; \ + return 1; } + +/* If the loading application (or library) and the loaded ENGINE library share + * the same static data (eg. they're both dynamically linked to the same + * libcrypto.so) we need a way to avoid trying to set system callbacks - this + * would fail, and for the same reason that it's unnecessary to try. If the + * loaded ENGINE has (or gets from through the loader) its own copy of the + * libcrypto static data, we will need to set the callbacks. The easiest way to + * detect this is to have a function that returns a pointer to some static data + * and let the loading application and loaded ENGINE compare their respective + * values. */ +void *ENGINE_get_static_state(void); + +#if defined(__OpenBSD__) || defined(__FreeBSD__) +void ENGINE_setup_bsd_cryptodev(void); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_ENGINE_strings(void); + +/* Error codes for the ENGINE functions. */ + +/* Function codes. */ +#define ENGINE_F_DYNAMIC_CTRL 180 +#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 +#define ENGINE_F_DYNAMIC_LOAD 182 +#define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 +#define ENGINE_F_ENGINE_ADD 105 +#define ENGINE_F_ENGINE_BY_ID 106 +#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 +#define ENGINE_F_ENGINE_CTRL 142 +#define ENGINE_F_ENGINE_CTRL_CMD 178 +#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 +#define ENGINE_F_ENGINE_FINISH 107 +#define ENGINE_F_ENGINE_FREE_UTIL 108 +#define ENGINE_F_ENGINE_GET_CIPHER 185 +#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177 +#define ENGINE_F_ENGINE_GET_DIGEST 186 +#define ENGINE_F_ENGINE_GET_NEXT 115 +#define ENGINE_F_ENGINE_GET_PREV 116 +#define ENGINE_F_ENGINE_INIT 119 +#define ENGINE_F_ENGINE_LIST_ADD 120 +#define ENGINE_F_ENGINE_LIST_REMOVE 121 +#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 +#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 +#define ENGINE_F_ENGINE_NEW 122 +#define ENGINE_F_ENGINE_REMOVE 123 +#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 +#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 +#define ENGINE_F_ENGINE_SET_ID 129 +#define ENGINE_F_ENGINE_SET_NAME 130 +#define ENGINE_F_ENGINE_TABLE_REGISTER 184 +#define ENGINE_F_ENGINE_UNLOAD_KEY 152 +#define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 +#define ENGINE_F_ENGINE_UP_REF 190 +#define ENGINE_F_INT_CTRL_HELPER 172 +#define ENGINE_F_INT_ENGINE_CONFIGURE 188 +#define ENGINE_F_INT_ENGINE_MODULE_INIT 187 +#define ENGINE_F_LOG_MESSAGE 141 + +/* Reason codes. */ +#define ENGINE_R_ALREADY_LOADED 100 +#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 +#define ENGINE_R_CMD_NOT_EXECUTABLE 134 +#define ENGINE_R_COMMAND_TAKES_INPUT 135 +#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 +#define ENGINE_R_CONFLICTING_ENGINE_ID 103 +#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 +#define ENGINE_R_DH_NOT_IMPLEMENTED 139 +#define ENGINE_R_DSA_NOT_IMPLEMENTED 140 +#define ENGINE_R_DSO_FAILURE 104 +#define ENGINE_R_DSO_NOT_FOUND 132 +#define ENGINE_R_ENGINES_SECTION_ERROR 148 +#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 +#define ENGINE_R_ENGINE_SECTION_ERROR 149 +#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 +#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 +#define ENGINE_R_FINISH_FAILED 106 +#define ENGINE_R_GET_HANDLE_FAILED 107 +#define ENGINE_R_ID_OR_NAME_MISSING 108 +#define ENGINE_R_INIT_FAILED 109 +#define ENGINE_R_INTERNAL_LIST_ERROR 110 +#define ENGINE_R_INVALID_ARGUMENT 143 +#define ENGINE_R_INVALID_CMD_NAME 137 +#define ENGINE_R_INVALID_CMD_NUMBER 138 +#define ENGINE_R_INVALID_INIT_VALUE 151 +#define ENGINE_R_INVALID_STRING 150 +#define ENGINE_R_NOT_INITIALISED 117 +#define ENGINE_R_NOT_LOADED 112 +#define ENGINE_R_NO_CONTROL_FUNCTION 120 +#define ENGINE_R_NO_INDEX 144 +#define ENGINE_R_NO_LOAD_FUNCTION 125 +#define ENGINE_R_NO_REFERENCE 130 +#define ENGINE_R_NO_SUCH_ENGINE 116 +#define ENGINE_R_NO_UNLOAD_FUNCTION 126 +#define ENGINE_R_PROVIDE_PARAMETERS 113 +#define ENGINE_R_RSA_NOT_IMPLEMENTED 141 +#define ENGINE_R_UNIMPLEMENTED_CIPHER 146 +#define ENGINE_R_UNIMPLEMENTED_DIGEST 147 +#define ENGINE_R_VERSION_INCOMPATIBILITY 145 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/err.h b/libraries/external/openssl/pc/include/openssl/err.h new file mode 100755 index 0000000..ed38141 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/err.h @@ -0,0 +1,318 @@ +/* crypto/err/err.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ERR_H +#define HEADER_ERR_H + +#include + +#ifndef OPENSSL_NO_FP_API +#include +#include +#endif + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_LHASH +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef OPENSSL_NO_ERR +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) +#else +#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) +#endif + +#include + +#define ERR_TXT_MALLOCED 0x01 +#define ERR_TXT_STRING 0x02 + +#define ERR_FLAG_MARK 0x01 + +#define ERR_NUM_ERRORS 16 +typedef struct err_state_st + { + unsigned long pid; + int err_flags[ERR_NUM_ERRORS]; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_data[ERR_NUM_ERRORS]; + int err_data_flags[ERR_NUM_ERRORS]; + const char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + int top,bottom; + } ERR_STATE; + +/* library */ +#define ERR_LIB_NONE 1 +#define ERR_LIB_SYS 2 +#define ERR_LIB_BN 3 +#define ERR_LIB_RSA 4 +#define ERR_LIB_DH 5 +#define ERR_LIB_EVP 6 +#define ERR_LIB_BUF 7 +#define ERR_LIB_OBJ 8 +#define ERR_LIB_PEM 9 +#define ERR_LIB_DSA 10 +#define ERR_LIB_X509 11 +/* #define ERR_LIB_METH 12 */ +#define ERR_LIB_ASN1 13 +#define ERR_LIB_CONF 14 +#define ERR_LIB_CRYPTO 15 +#define ERR_LIB_EC 16 +#define ERR_LIB_SSL 20 +/* #define ERR_LIB_SSL23 21 */ +/* #define ERR_LIB_SSL2 22 */ +/* #define ERR_LIB_SSL3 23 */ +/* #define ERR_LIB_RSAREF 30 */ +/* #define ERR_LIB_PROXY 31 */ +#define ERR_LIB_BIO 32 +#define ERR_LIB_PKCS7 33 +#define ERR_LIB_X509V3 34 +#define ERR_LIB_PKCS12 35 +#define ERR_LIB_RAND 36 +#define ERR_LIB_DSO 37 +#define ERR_LIB_ENGINE 38 +#define ERR_LIB_OCSP 39 +#define ERR_LIB_UI 40 +#define ERR_LIB_COMP 41 +#define ERR_LIB_ECDSA 42 +#define ERR_LIB_ECDH 43 +#define ERR_LIB_STORE 44 + +#define ERR_LIB_USER 128 + +#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__) +#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__) +#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__) +#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__) +#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__) +#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__) +#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__) +#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__) +#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__) +#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__) +#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__) +#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__) +#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__) +#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__) +#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__) +#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__) +#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__) +#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__) +#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__) +#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__) +#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__) +#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__) +#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__) +#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__) +#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__) +#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__) +#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__) +#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__) + +/* Borland C seems too stupid to be able to shift and do longs in + * the pre-processor :-( */ +#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)*0x1000000)| \ + ((((unsigned long)f)&0xfffL)*0x1000)| \ + ((((unsigned long)r)&0xfffL))) +#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL) +#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL) +#define ERR_GET_REASON(l) (int)((l)&0xfffL) +#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) + + +/* OS functions */ +#define SYS_F_FOPEN 1 +#define SYS_F_CONNECT 2 +#define SYS_F_GETSERVBYNAME 3 +#define SYS_F_SOCKET 4 +#define SYS_F_IOCTLSOCKET 5 +#define SYS_F_BIND 6 +#define SYS_F_LISTEN 7 +#define SYS_F_ACCEPT 8 +#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ +#define SYS_F_OPENDIR 10 +#define SYS_F_FREAD 11 + + +/* reasons */ +#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */ +#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */ +#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */ +#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */ +#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */ +#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */ +#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */ +#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */ +#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */ +#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */ +#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */ +#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */ +#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */ +#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */ +#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */ +#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */ +#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */ +#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */ +#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */ +#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */ +#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */ +#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */ +#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */ +#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */ +#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */ +#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */ +#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */ +#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */ + +#define ERR_R_NESTED_ASN1_ERROR 58 +#define ERR_R_BAD_ASN1_OBJECT_HEADER 59 +#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60 +#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61 +#define ERR_R_ASN1_LENGTH_MISMATCH 62 +#define ERR_R_MISSING_ASN1_EOS 63 + +/* fatal error */ +#define ERR_R_FATAL 64 +#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) +#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) +#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) +#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) +#define ERR_R_DISABLED (5|ERR_R_FATAL) + +/* 99 is the maximum possible ERR_R_... code, higher values + * are reserved for the individual libraries */ + + +typedef struct ERR_string_data_st + { + unsigned long error; + const char *string; + } ERR_STRING_DATA; + +void ERR_put_error(int lib, int func,int reason,const char *file,int line); +void ERR_set_error_data(char *data,int flags); + +unsigned long ERR_get_error(void); +unsigned long ERR_get_error_line(const char **file,int *line); +unsigned long ERR_get_error_line_data(const char **file,int *line, + const char **data, int *flags); +unsigned long ERR_peek_error(void); +unsigned long ERR_peek_error_line(const char **file,int *line); +unsigned long ERR_peek_error_line_data(const char **file,int *line, + const char **data,int *flags); +unsigned long ERR_peek_last_error(void); +unsigned long ERR_peek_last_error_line(const char **file,int *line); +unsigned long ERR_peek_last_error_line_data(const char **file,int *line, + const char **data,int *flags); +void ERR_clear_error(void ); +char *ERR_error_string(unsigned long e,char *buf); +void ERR_error_string_n(unsigned long e, char *buf, size_t len); +const char *ERR_lib_error_string(unsigned long e); +const char *ERR_func_error_string(unsigned long e); +const char *ERR_reason_error_string(unsigned long e); +void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); +#ifndef OPENSSL_NO_FP_API +void ERR_print_errors_fp(FILE *fp); +#endif +#ifndef OPENSSL_NO_BIO +void ERR_print_errors(BIO *bp); +void ERR_add_error_data(int num, ...); +#endif +void ERR_load_strings(int lib,ERR_STRING_DATA str[]); +void ERR_unload_strings(int lib,ERR_STRING_DATA str[]); +void ERR_load_ERR_strings(void); +void ERR_load_crypto_strings(void); +void ERR_free_strings(void); + +void ERR_remove_state(unsigned long pid); /* if zero we look it up */ +ERR_STATE *ERR_get_state(void); + +#ifndef OPENSSL_NO_LHASH +LHASH *ERR_get_string_table(void); +LHASH *ERR_get_err_state_table(void); +void ERR_release_err_state_table(LHASH **hash); +#endif + +int ERR_get_next_error_library(void); + +int ERR_set_mark(void); +int ERR_pop_to_mark(void); + +/* Already defined in ossl_typ.h */ +/* typedef struct st_ERR_FNS ERR_FNS; */ +/* An application can use this function and provide the return value to loaded + * modules that should use the application's ERR state/functionality */ +const ERR_FNS *ERR_get_implementation(void); +/* A loaded module should call this function prior to any ERR operations using + * the application's "ERR_FNS". */ +int ERR_set_implementation(const ERR_FNS *fns); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/evp.h b/libraries/external/openssl/pc/include/openssl/evp.h new file mode 100755 index 0000000..7b13fd7 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/evp.h @@ -0,0 +1,970 @@ +/* crypto/evp/evp.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_ENVELOPE_H +#define HEADER_ENVELOPE_H + +#ifdef OPENSSL_ALGORITHM_DEFINES +# include +#else +# define OPENSSL_ALGORITHM_DEFINES +# include +# undef OPENSSL_ALGORITHM_DEFINES +#endif + +#include + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif + +/* +#define EVP_RC2_KEY_SIZE 16 +#define EVP_RC4_KEY_SIZE 16 +#define EVP_BLOWFISH_KEY_SIZE 16 +#define EVP_CAST5_KEY_SIZE 16 +#define EVP_RC5_32_12_16_KEY_SIZE 16 +*/ +#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */ +#define EVP_MAX_KEY_LENGTH 32 +#define EVP_MAX_IV_LENGTH 16 +#define EVP_MAX_BLOCK_LENGTH 32 + +#define PKCS5_SALT_LEN 8 +/* Default PKCS#5 iteration count */ +#define PKCS5_DEFAULT_ITER 2048 + +#include + +#define EVP_PK_RSA 0x0001 +#define EVP_PK_DSA 0x0002 +#define EVP_PK_DH 0x0004 +#define EVP_PK_EC 0x0008 +#define EVP_PKT_SIGN 0x0010 +#define EVP_PKT_ENC 0x0020 +#define EVP_PKT_EXCH 0x0040 +#define EVP_PKS_RSA 0x0100 +#define EVP_PKS_DSA 0x0200 +#define EVP_PKS_EC 0x0400 +#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ + +#define EVP_PKEY_NONE NID_undef +#define EVP_PKEY_RSA NID_rsaEncryption +#define EVP_PKEY_RSA2 NID_rsa +#define EVP_PKEY_DSA NID_dsa +#define EVP_PKEY_DSA1 NID_dsa_2 +#define EVP_PKEY_DSA2 NID_dsaWithSHA +#define EVP_PKEY_DSA3 NID_dsaWithSHA1 +#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 +#define EVP_PKEY_DH NID_dhKeyAgreement +#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type needs to be a bit field + * Sub-type needs to be for variations on the method, as in, can it do + * arbitrary encryption.... */ +struct evp_pkey_st + { + int type; + int save_type; + int references; + union { + char *ptr; +#ifndef OPENSSL_NO_RSA + struct rsa_st *rsa; /* RSA */ +#endif +#ifndef OPENSSL_NO_DSA + struct dsa_st *dsa; /* DSA */ +#endif +#ifndef OPENSSL_NO_DH + struct dh_st *dh; /* DH */ +#endif +#ifndef OPENSSL_NO_EC + struct ec_key_st *ec; /* ECC */ +#endif + } pkey; + int save_parameters; + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } /* EVP_PKEY */; + +#define EVP_PKEY_MO_SIGN 0x0001 +#define EVP_PKEY_MO_VERIFY 0x0002 +#define EVP_PKEY_MO_ENCRYPT 0x0004 +#define EVP_PKEY_MO_DECRYPT 0x0008 + +#if 0 +/* This structure is required to tie the message digest and signing together. + * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or + * oid, md and pkey. + * This is required because for various smart-card perform the digest and + * signing/verification on-board. To handle this case, the specific + * EVP_MD and EVP_PKEY_METHODs need to be closely associated. + * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. + * This can either be software or a token to provide the required low level + * routines. + */ +typedef struct evp_pkey_md_st + { + int oid; + EVP_MD *md; + EVP_PKEY_METHOD *pkey; + } EVP_PKEY_MD; + +#define EVP_rsa_md2() \ + EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md2()) +#define EVP_rsa_md5() \ + EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_md5()) +#define EVP_rsa_sha0() \ + EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha()) +#define EVP_rsa_sha1() \ + EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ + EVP_rsa_pkcs1(),EVP_sha1()) +#define EVP_rsa_ripemd160() \ + EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ + EVP_rsa_pkcs1(),EVP_ripemd160()) +#define EVP_rsa_mdc2() \ + EVP_PKEY_MD_add(NID_mdc2WithRSA,\ + EVP_rsa_octet_string(),EVP_mdc2()) +#define EVP_dsa_sha() \ + EVP_PKEY_MD_add(NID_dsaWithSHA,\ + EVP_dsa(),EVP_sha()) +#define EVP_dsa_sha1() \ + EVP_PKEY_MD_add(NID_dsaWithSHA1,\ + EVP_dsa(),EVP_sha1()) + +typedef struct evp_pkey_method_st + { + char *name; + int flags; + int type; /* RSA, DSA, an SSLeay specific constant */ + int oid; /* For the pub-key type */ + int encrypt_oid; /* pub/priv key encryption */ + + int (*sign)(); + int (*verify)(); + struct { + int (*set)(); /* get and/or set the underlying type */ + int (*get)(); + int (*encrypt)(); + int (*decrypt)(); + int (*i2d)(); + int (*d2i)(); + int (*dup)(); + } pub,priv; + int (*set_asn1_parameters)(); + int (*get_asn1_parameters)(); + } EVP_PKEY_METHOD; +#endif + +#ifndef EVP_MD +struct env_md_st + { + int type; + int pkey_type; + int md_size; + unsigned long flags; + int (*init)(EVP_MD_CTX *ctx); + int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count); + int (*final)(EVP_MD_CTX *ctx,unsigned char *md); + int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); + int (*cleanup)(EVP_MD_CTX *ctx); + + /* FIXME: prototype these some day */ + int (*sign)(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, void *key); + int (*verify)(int type, const unsigned char *m, unsigned int m_length, + const unsigned char *sigbuf, unsigned int siglen, + void *key); + int required_pkey_type[5]; /*EVP_PKEY_xxx */ + int block_size; + int ctx_size; /* how big does the ctx->md_data need to be */ + } /* EVP_MD */; + +typedef int evp_sign_method(int type,const unsigned char *m, + unsigned int m_length,unsigned char *sigret, + unsigned int *siglen, void *key); +typedef int evp_verify_method(int type,const unsigned char *m, + unsigned int m_length,const unsigned char *sigbuf, + unsigned int siglen, void *key); + +#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single + * block */ + +#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \ + (evp_verify_method *)DSA_verify, \ + {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ + EVP_PKEY_DSA4,0} +#else +#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_ECDSA +#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \ + (evp_verify_method *)ECDSA_verify, \ + {EVP_PKEY_EC,0,0,0} +#else +#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method +#endif + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \ + (evp_verify_method *)RSA_verify, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ + (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \ + (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \ + {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} +#else +#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method +#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method +#endif + +#endif /* !EVP_MD */ + +struct env_md_ctx_st + { + const EVP_MD *digest; + ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ + unsigned long flags; + void *md_data; + } /* EVP_MD_CTX */; + +/* values for EVP_MD_CTX flags */ + +#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called + * once only */ +#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been + * cleaned */ +#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data + * in EVP_MD_CTX_cleanup */ + +struct evp_cipher_st + { + int nid; + int block_size; + int key_len; /* Default value for variable length ciphers */ + int iv_len; + unsigned long flags; /* Various flags */ + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc); /* init key */ + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ + int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ + int ctx_size; /* how big ctx->cipher_data needs to be */ + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ + void *app_data; /* Application data */ + } /* EVP_CIPHER */; + +/* Values for cipher flags */ + +/* Modes for ciphers */ + +#define EVP_CIPH_STREAM_CIPHER 0x0 +#define EVP_CIPH_ECB_MODE 0x1 +#define EVP_CIPH_CBC_MODE 0x2 +#define EVP_CIPH_CFB_MODE 0x3 +#define EVP_CIPH_OFB_MODE 0x4 +#define EVP_CIPH_MODE 0x7 +/* Set if variable length cipher */ +#define EVP_CIPH_VARIABLE_LENGTH 0x8 +/* Set if the iv handling should be done by the cipher itself */ +#define EVP_CIPH_CUSTOM_IV 0x10 +/* Set if the cipher's init() function should be called if key is NULL */ +#define EVP_CIPH_ALWAYS_CALL_INIT 0x20 +/* Call ctrl() to init cipher parameters */ +#define EVP_CIPH_CTRL_INIT 0x40 +/* Don't use standard key length function */ +#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 +/* Don't use standard block padding */ +#define EVP_CIPH_NO_PADDING 0x100 +/* cipher handles random key generation */ +#define EVP_CIPH_RAND_KEY 0x200 + +/* ctrl() values */ + +#define EVP_CTRL_INIT 0x0 +#define EVP_CTRL_SET_KEY_LENGTH 0x1 +#define EVP_CTRL_GET_RC2_KEY_BITS 0x2 +#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 +#define EVP_CTRL_GET_RC5_ROUNDS 0x4 +#define EVP_CTRL_SET_RC5_ROUNDS 0x5 +#define EVP_CTRL_RAND_KEY 0x6 + +typedef struct evp_cipher_info_st + { + const EVP_CIPHER *cipher; + unsigned char iv[EVP_MAX_IV_LENGTH]; + } EVP_CIPHER_INFO; + +struct evp_cipher_ctx_st + { + const EVP_CIPHER *cipher; + ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ + int encrypt; /* encrypt or decrypt */ + int buf_len; /* number we have left */ + + unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ + unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ + unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ + int num; /* used by cfb/ofb mode */ + + void *app_data; /* application stuff */ + int key_len; /* May change for variable length cipher */ + unsigned long flags; /* Various flags */ + void *cipher_data; /* per EVP data */ + int final_used; + int block_mask; + unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ + } /* EVP_CIPHER_CTX */; + +typedef struct evp_Encode_Ctx_st + { + int num; /* number saved in a partial encode/decode */ + int length; /* The length is either the output line length + * (in input bytes) or the shortest input line + * length that is ok. Once decoding begins, + * the length is adjusted up each time a longer + * line is decoded */ + unsigned char enc_data[80]; /* data to encode */ + int line_num; /* number read on current line */ + int expect_nl; + } EVP_ENCODE_CTX; + +/* Password based encryption function */ +typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); + +#ifndef OPENSSL_NO_RSA +#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ + (char *)(rsa)) +#endif + +#ifndef OPENSSL_NO_DSA +#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ + (char *)(dsa)) +#endif + +#ifndef OPENSSL_NO_DH +#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ + (char *)(dh)) +#endif + +#ifndef OPENSSL_NO_EC +#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ + (char *)(eckey)) +#endif + +/* Add some extra combinations */ +#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) +#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) +#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) +#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) + +int EVP_MD_type(const EVP_MD *md); +#define EVP_MD_nid(e) EVP_MD_type(e) +#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) +int EVP_MD_pkey_type(const EVP_MD *md); +int EVP_MD_size(const EVP_MD *md); +int EVP_MD_block_size(const EVP_MD *md); + +const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx); +#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) +#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e)) +#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e)) + +int EVP_CIPHER_nid(const EVP_CIPHER *cipher); +#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) +int EVP_CIPHER_block_size(const EVP_CIPHER *cipher); +int EVP_CIPHER_key_length(const EVP_CIPHER *cipher); +int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher); +unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher); +#define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE) + +const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); +int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); +void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); +void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); +#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) +unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx); +#define EVP_CIPHER_CTX_mode(e) (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE) + +#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) +#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) + +#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_SignInit(a,b) EVP_DigestInit(a,b) +#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) +#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) +#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) +#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) +#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) + +#ifdef CONST_STRICT +void BIO_set_md(BIO *,const EVP_MD *md); +#else +# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) +#endif +#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) +#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) +#define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp) +#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) +#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) + +int EVP_Cipher(EVP_CIPHER_CTX *c, + unsigned char *out, + const unsigned char *in, + unsigned int inl); + +#define EVP_add_cipher_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_add_digest_alias(n,alias) \ + OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) +#define EVP_delete_cipher_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); +#define EVP_delete_digest_alias(alias) \ + OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); + +void EVP_MD_CTX_init(EVP_MD_CTX *ctx); +int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); +EVP_MD_CTX *EVP_MD_CTX_create(void); +void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); +int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); +void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); +void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); +int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags); +int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); +int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, + size_t cnt); +int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); +int EVP_Digest(const void *data, size_t count, + unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); + +int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); +int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); +int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); + +int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); +void EVP_set_pw_prompt(const char *prompt); +char * EVP_get_pw_prompt(void); + +int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, + const unsigned char *salt, const unsigned char *data, + int datal, int count, unsigned char *key,unsigned char *iv); + +int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); +int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key, const unsigned char *iv); +int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl, + const unsigned char *key,const unsigned char *iv, + int enc); +int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); + +int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, + EVP_PKEY *pkey); + +int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf, + unsigned int siglen,EVP_PKEY *pkey); + +int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, + const unsigned char *ek, int ekl, const unsigned char *iv, + EVP_PKEY *priv); +int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + +int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); +int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); + +void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); +void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in,int inl); +void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); +int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, + const unsigned char *in, int inl); +int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned + char *out, int *outl); +int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); + +void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); +EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); +void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a); +int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); +int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); +int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); +int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_md(void); +BIO_METHOD *BIO_f_base64(void); +BIO_METHOD *BIO_f_cipher(void); +BIO_METHOD *BIO_f_reliable(void); +void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k, + const unsigned char *i, int enc); +#endif + +const EVP_MD *EVP_md_null(void); +#ifndef OPENSSL_NO_MD2 +const EVP_MD *EVP_md2(void); +#endif +#ifndef OPENSSL_NO_MD4 +const EVP_MD *EVP_md4(void); +#endif +#ifndef OPENSSL_NO_MD5 +const EVP_MD *EVP_md5(void); +#endif +#ifndef OPENSSL_NO_SHA +const EVP_MD *EVP_sha(void); +const EVP_MD *EVP_sha1(void); +const EVP_MD *EVP_dss(void); +const EVP_MD *EVP_dss1(void); +const EVP_MD *EVP_ecdsa(void); +#endif +#ifndef OPENSSL_NO_SHA256 +const EVP_MD *EVP_sha224(void); +const EVP_MD *EVP_sha256(void); +#endif +#ifndef OPENSSL_NO_SHA512 +const EVP_MD *EVP_sha384(void); +const EVP_MD *EVP_sha512(void); +#endif +#ifndef OPENSSL_NO_MDC2 +const EVP_MD *EVP_mdc2(void); +#endif +#ifndef OPENSSL_NO_RIPEMD +const EVP_MD *EVP_ripemd160(void); +#endif +const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ +#ifndef OPENSSL_NO_DES +const EVP_CIPHER *EVP_des_ecb(void); +const EVP_CIPHER *EVP_des_ede(void); +const EVP_CIPHER *EVP_des_ede3(void); +const EVP_CIPHER *EVP_des_ede_ecb(void); +const EVP_CIPHER *EVP_des_ede3_ecb(void); +const EVP_CIPHER *EVP_des_cfb64(void); +# define EVP_des_cfb EVP_des_cfb64 +const EVP_CIPHER *EVP_des_cfb1(void); +const EVP_CIPHER *EVP_des_cfb8(void); +const EVP_CIPHER *EVP_des_ede_cfb64(void); +# define EVP_des_ede_cfb EVP_des_ede_cfb64 +#if 0 +const EVP_CIPHER *EVP_des_ede_cfb1(void); +const EVP_CIPHER *EVP_des_ede_cfb8(void); +#endif +const EVP_CIPHER *EVP_des_ede3_cfb64(void); +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +const EVP_CIPHER *EVP_des_ede3_cfb1(void); +const EVP_CIPHER *EVP_des_ede3_cfb8(void); +const EVP_CIPHER *EVP_des_ofb(void); +const EVP_CIPHER *EVP_des_ede_ofb(void); +const EVP_CIPHER *EVP_des_ede3_ofb(void); +const EVP_CIPHER *EVP_des_cbc(void); +const EVP_CIPHER *EVP_des_ede_cbc(void); +const EVP_CIPHER *EVP_des_ede3_cbc(void); +const EVP_CIPHER *EVP_desx_cbc(void); +/* This should now be supported through the dev_crypto ENGINE. But also, why are + * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ +#if 0 +# ifdef OPENSSL_OPENBSD_DEV_CRYPTO +const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); +const EVP_CIPHER *EVP_dev_crypto_rc4(void); +const EVP_MD *EVP_dev_crypto_md5(void); +# endif +#endif +#endif +#ifndef OPENSSL_NO_RC4 +const EVP_CIPHER *EVP_rc4(void); +const EVP_CIPHER *EVP_rc4_40(void); +#endif +#ifndef OPENSSL_NO_IDEA +const EVP_CIPHER *EVP_idea_ecb(void); +const EVP_CIPHER *EVP_idea_cfb64(void); +# define EVP_idea_cfb EVP_idea_cfb64 +const EVP_CIPHER *EVP_idea_ofb(void); +const EVP_CIPHER *EVP_idea_cbc(void); +#endif +#ifndef OPENSSL_NO_RC2 +const EVP_CIPHER *EVP_rc2_ecb(void); +const EVP_CIPHER *EVP_rc2_cbc(void); +const EVP_CIPHER *EVP_rc2_40_cbc(void); +const EVP_CIPHER *EVP_rc2_64_cbc(void); +const EVP_CIPHER *EVP_rc2_cfb64(void); +# define EVP_rc2_cfb EVP_rc2_cfb64 +const EVP_CIPHER *EVP_rc2_ofb(void); +#endif +#ifndef OPENSSL_NO_BF +const EVP_CIPHER *EVP_bf_ecb(void); +const EVP_CIPHER *EVP_bf_cbc(void); +const EVP_CIPHER *EVP_bf_cfb64(void); +# define EVP_bf_cfb EVP_bf_cfb64 +const EVP_CIPHER *EVP_bf_ofb(void); +#endif +#ifndef OPENSSL_NO_CAST +const EVP_CIPHER *EVP_cast5_ecb(void); +const EVP_CIPHER *EVP_cast5_cbc(void); +const EVP_CIPHER *EVP_cast5_cfb64(void); +# define EVP_cast5_cfb EVP_cast5_cfb64 +const EVP_CIPHER *EVP_cast5_ofb(void); +#endif +#ifndef OPENSSL_NO_RC5 +const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); +const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); +const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 +const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); +#endif +#ifndef OPENSSL_NO_AES +const EVP_CIPHER *EVP_aes_128_ecb(void); +const EVP_CIPHER *EVP_aes_128_cbc(void); +const EVP_CIPHER *EVP_aes_128_cfb1(void); +const EVP_CIPHER *EVP_aes_128_cfb8(void); +const EVP_CIPHER *EVP_aes_128_cfb128(void); +# define EVP_aes_128_cfb EVP_aes_128_cfb128 +const EVP_CIPHER *EVP_aes_128_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_128_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_192_ecb(void); +const EVP_CIPHER *EVP_aes_192_cbc(void); +const EVP_CIPHER *EVP_aes_192_cfb1(void); +const EVP_CIPHER *EVP_aes_192_cfb8(void); +const EVP_CIPHER *EVP_aes_192_cfb128(void); +# define EVP_aes_192_cfb EVP_aes_192_cfb128 +const EVP_CIPHER *EVP_aes_192_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_192_ctr(void); +#endif +const EVP_CIPHER *EVP_aes_256_ecb(void); +const EVP_CIPHER *EVP_aes_256_cbc(void); +const EVP_CIPHER *EVP_aes_256_cfb1(void); +const EVP_CIPHER *EVP_aes_256_cfb8(void); +const EVP_CIPHER *EVP_aes_256_cfb128(void); +# define EVP_aes_256_cfb EVP_aes_256_cfb128 +const EVP_CIPHER *EVP_aes_256_ofb(void); +#if 0 +const EVP_CIPHER *EVP_aes_256_ctr(void); +#endif +#endif +#ifndef OPENSSL_NO_CAMELLIA +const EVP_CIPHER *EVP_camellia_128_ecb(void); +const EVP_CIPHER *EVP_camellia_128_cbc(void); +const EVP_CIPHER *EVP_camellia_128_cfb1(void); +const EVP_CIPHER *EVP_camellia_128_cfb8(void); +const EVP_CIPHER *EVP_camellia_128_cfb128(void); +# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 +const EVP_CIPHER *EVP_camellia_128_ofb(void); +const EVP_CIPHER *EVP_camellia_192_ecb(void); +const EVP_CIPHER *EVP_camellia_192_cbc(void); +const EVP_CIPHER *EVP_camellia_192_cfb1(void); +const EVP_CIPHER *EVP_camellia_192_cfb8(void); +const EVP_CIPHER *EVP_camellia_192_cfb128(void); +# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 +const EVP_CIPHER *EVP_camellia_192_ofb(void); +const EVP_CIPHER *EVP_camellia_256_ecb(void); +const EVP_CIPHER *EVP_camellia_256_cbc(void); +const EVP_CIPHER *EVP_camellia_256_cfb1(void); +const EVP_CIPHER *EVP_camellia_256_cfb8(void); +const EVP_CIPHER *EVP_camellia_256_cfb128(void); +# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 +const EVP_CIPHER *EVP_camellia_256_ofb(void); +#endif + +void OPENSSL_add_all_algorithms_noconf(void); +void OPENSSL_add_all_algorithms_conf(void); + +#ifdef OPENSSL_LOAD_CONF +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_conf() +#else +#define OpenSSL_add_all_algorithms() \ + OPENSSL_add_all_algorithms_noconf() +#endif + +void OpenSSL_add_all_ciphers(void); +void OpenSSL_add_all_digests(void); +#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() +#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() +#define SSLeay_add_all_digests() OpenSSL_add_all_digests() + +int EVP_add_cipher(const EVP_CIPHER *cipher); +int EVP_add_digest(const EVP_MD *digest); + +const EVP_CIPHER *EVP_get_cipherbyname(const char *name); +const EVP_MD *EVP_get_digestbyname(const char *name); +void EVP_cleanup(void); + +int EVP_PKEY_decrypt(unsigned char *dec_key, + const unsigned char *enc_key,int enc_key_len, + EVP_PKEY *private_key); +int EVP_PKEY_encrypt(unsigned char *enc_key, + const unsigned char *key,int key_len, + EVP_PKEY *pub_key); +int EVP_PKEY_type(int type); +int EVP_PKEY_bits(EVP_PKEY *pkey); +int EVP_PKEY_size(EVP_PKEY *pkey); +int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); + +#ifndef OPENSSL_NO_RSA +struct rsa_st; +int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key); +struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DSA +struct dsa_st; +int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key); +struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_DH +struct dh_st; +int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); +struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); +#endif +#ifndef OPENSSL_NO_EC +struct ec_key_st; +int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key); +struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); +#endif + +EVP_PKEY * EVP_PKEY_new(void); +void EVP_PKEY_free(EVP_PKEY *pkey); + +EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); + +EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp, + long length); +EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, + long length); +int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); + +int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); +int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); +int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); +int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); + +int EVP_CIPHER_type(const EVP_CIPHER *ctx); + +/* calls methods */ +int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); + +/* These are used by EVP_CIPHER methods */ +int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); +int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); + +/* PKCS5 password based encryption */ +int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); +int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + int keylen, unsigned char *out); +int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de); + +void PKCS5_PBE_add(void); + +int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); +int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, + EVP_PBE_KEYGEN *keygen); +void EVP_PBE_cleanup(void); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_EVP_strings(void); + +/* Error codes for the EVP functions. */ + +/* Function codes. */ +#define EVP_F_AES_INIT_KEY 133 +#define EVP_F_CAMELLIA_INIT_KEY 159 +#define EVP_F_D2I_PKEY 100 +#define EVP_F_DSAPKEY2PKCS8 134 +#define EVP_F_DSA_PKEY2PKCS8 135 +#define EVP_F_ECDSA_PKEY2PKCS8 129 +#define EVP_F_ECKEY_PKEY2PKCS8 132 +#define EVP_F_EVP_CIPHERINIT_EX 123 +#define EVP_F_EVP_CIPHER_CTX_CTRL 124 +#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 +#define EVP_F_EVP_DECRYPTFINAL_EX 101 +#define EVP_F_EVP_DIGESTINIT_EX 128 +#define EVP_F_EVP_ENCRYPTFINAL_EX 127 +#define EVP_F_EVP_MD_CTX_COPY_EX 110 +#define EVP_F_EVP_OPENINIT 102 +#define EVP_F_EVP_PBE_ALG_ADD 115 +#define EVP_F_EVP_PBE_CIPHERINIT 116 +#define EVP_F_EVP_PKCS82PKEY 111 +#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113 +#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 +#define EVP_F_EVP_PKEY_DECRYPT 104 +#define EVP_F_EVP_PKEY_ENCRYPT 105 +#define EVP_F_EVP_PKEY_GET1_DH 119 +#define EVP_F_EVP_PKEY_GET1_DSA 120 +#define EVP_F_EVP_PKEY_GET1_ECDSA 130 +#define EVP_F_EVP_PKEY_GET1_EC_KEY 131 +#define EVP_F_EVP_PKEY_GET1_RSA 121 +#define EVP_F_EVP_PKEY_NEW 106 +#define EVP_F_EVP_RIJNDAEL 126 +#define EVP_F_EVP_SIGNFINAL 107 +#define EVP_F_EVP_VERIFYFINAL 108 +#define EVP_F_PKCS5_PBE_KEYIVGEN 117 +#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 +#define EVP_F_PKCS8_SET_BROKEN 112 +#define EVP_F_RC2_MAGIC_TO_METH 109 +#define EVP_F_RC5_CTRL 125 + +/* Reason codes. */ +#define EVP_R_AES_KEY_SETUP_FAILED 143 +#define EVP_R_ASN1_LIB 140 +#define EVP_R_BAD_BLOCK_LENGTH 136 +#define EVP_R_BAD_DECRYPT 100 +#define EVP_R_BAD_KEY_LENGTH 137 +#define EVP_R_BN_DECODE_ERROR 112 +#define EVP_R_BN_PUBKEY_ERROR 113 +#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 +#define EVP_R_CIPHER_PARAMETER_ERROR 122 +#define EVP_R_CTRL_NOT_IMPLEMENTED 132 +#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 +#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 +#define EVP_R_DECODE_ERROR 114 +#define EVP_R_DIFFERENT_KEY_TYPES 101 +#define EVP_R_ENCODE_ERROR 115 +#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 +#define EVP_R_EXPECTING_AN_RSA_KEY 127 +#define EVP_R_EXPECTING_A_DH_KEY 128 +#define EVP_R_EXPECTING_A_DSA_KEY 129 +#define EVP_R_EXPECTING_A_ECDSA_KEY 141 +#define EVP_R_EXPECTING_A_EC_KEY 142 +#define EVP_R_INITIALIZATION_ERROR 134 +#define EVP_R_INPUT_NOT_INITIALIZED 111 +#define EVP_R_INVALID_KEY_LENGTH 130 +#define EVP_R_IV_TOO_LARGE 102 +#define EVP_R_KEYGEN_FAILURE 120 +#define EVP_R_MISSING_PARAMETERS 103 +#define EVP_R_NO_CIPHER_SET 131 +#define EVP_R_NO_DIGEST_SET 139 +#define EVP_R_NO_DSA_PARAMETERS 116 +#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 +#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 +#define EVP_R_PUBLIC_KEY_NOT_RSA 106 +#define EVP_R_UNKNOWN_PBE_ALGORITHM 121 +#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135 +#define EVP_R_UNSUPPORTED_CIPHER 107 +#define EVP_R_UNSUPPORTED_KEYLENGTH 123 +#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 +#define EVP_R_UNSUPPORTED_KEY_SIZE 108 +#define EVP_R_UNSUPPORTED_PRF 125 +#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 +#define EVP_R_UNSUPPORTED_SALT_TYPE 126 +#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 +#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/hmac.h b/libraries/external/openssl/pc/include/openssl/hmac.h new file mode 100755 index 0000000..943869a --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/hmac.h @@ -0,0 +1,108 @@ +/* crypto/hmac/hmac.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +#ifndef HEADER_HMAC_H +#define HEADER_HMAC_H + +#include + +#ifdef OPENSSL_NO_HMAC +#error HMAC is disabled. +#endif + +#include + +#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct hmac_ctx_st + { + const EVP_MD *md; + EVP_MD_CTX md_ctx; + EVP_MD_CTX i_ctx; + EVP_MD_CTX o_ctx; + unsigned int key_length; + unsigned char key[HMAC_MAX_MD_CBLOCK]; + } HMAC_CTX; + +#define HMAC_size(e) (EVP_MD_size((e)->md)) + + +void HMAC_CTX_init(HMAC_CTX *ctx); +void HMAC_CTX_cleanup(HMAC_CTX *ctx); + +#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ + +void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md); /* deprecated */ +void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md, ENGINE *impl); +void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); +void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); +unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, + const unsigned char *d, size_t n, unsigned char *md, + unsigned int *md_len); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/krb5_asn.h b/libraries/external/openssl/pc/include/openssl/krb5_asn.h new file mode 100755 index 0000000..fa08967 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/krb5_asn.h @@ -0,0 +1,256 @@ +/* krb5_asn.h */ +/* Written by Vern Staats for the OpenSSL project, +** using ocsp/{*.h,*asn*.c} as a starting point +*/ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_KRB5_ASN_H +#define HEADER_KRB5_ASN_H + +/* +#include +*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ASN.1 from Kerberos RFC 1510 +*/ + +/* EncryptedData ::= SEQUENCE { +** etype[0] INTEGER, -- EncryptionType +** kvno[1] INTEGER OPTIONAL, +** cipher[2] OCTET STRING -- ciphertext +** } +*/ +typedef struct krb5_encdata_st + { + ASN1_INTEGER *etype; + ASN1_INTEGER *kvno; + ASN1_OCTET_STRING *cipher; + } KRB5_ENCDATA; + +DECLARE_STACK_OF(KRB5_ENCDATA) + +/* PrincipalName ::= SEQUENCE { +** name-type[0] INTEGER, +** name-string[1] SEQUENCE OF GeneralString +** } +*/ +typedef struct krb5_princname_st + { + ASN1_INTEGER *nametype; + STACK_OF(ASN1_GENERALSTRING) *namestring; + } KRB5_PRINCNAME; + +DECLARE_STACK_OF(KRB5_PRINCNAME) + + +/* Ticket ::= [APPLICATION 1] SEQUENCE { +** tkt-vno[0] INTEGER, +** realm[1] Realm, +** sname[2] PrincipalName, +** enc-part[3] EncryptedData +** } +*/ +typedef struct krb5_tktbody_st + { + ASN1_INTEGER *tktvno; + ASN1_GENERALSTRING *realm; + KRB5_PRINCNAME *sname; + KRB5_ENCDATA *encdata; + } KRB5_TKTBODY; + +typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET; +DECLARE_STACK_OF(KRB5_TKTBODY) + + +/* AP-REQ ::= [APPLICATION 14] SEQUENCE { +** pvno[0] INTEGER, +** msg-type[1] INTEGER, +** ap-options[2] APOptions, +** ticket[3] Ticket, +** authenticator[4] EncryptedData +** } +** +** APOptions ::= BIT STRING { +** reserved(0), use-session-key(1), mutual-required(2) } +*/ +typedef struct krb5_ap_req_st + { + ASN1_INTEGER *pvno; + ASN1_INTEGER *msgtype; + ASN1_BIT_STRING *apoptions; + KRB5_TICKET *ticket; + KRB5_ENCDATA *authenticator; + } KRB5_APREQBODY; + +typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ; +DECLARE_STACK_OF(KRB5_APREQBODY) + + +/* Authenticator Stuff */ + + +/* Checksum ::= SEQUENCE { +** cksumtype[0] INTEGER, +** checksum[1] OCTET STRING +** } +*/ +typedef struct krb5_checksum_st + { + ASN1_INTEGER *ctype; + ASN1_OCTET_STRING *checksum; + } KRB5_CHECKSUM; + +DECLARE_STACK_OF(KRB5_CHECKSUM) + + +/* EncryptionKey ::= SEQUENCE { +** keytype[0] INTEGER, +** keyvalue[1] OCTET STRING +** } +*/ +typedef struct krb5_encryptionkey_st + { + ASN1_INTEGER *ktype; + ASN1_OCTET_STRING *keyvalue; + } KRB5_ENCKEY; + +DECLARE_STACK_OF(KRB5_ENCKEY) + + +/* AuthorizationData ::= SEQUENCE OF SEQUENCE { +** ad-type[0] INTEGER, +** ad-data[1] OCTET STRING +** } +*/ +typedef struct krb5_authorization_st + { + ASN1_INTEGER *adtype; + ASN1_OCTET_STRING *addata; + } KRB5_AUTHDATA; + +DECLARE_STACK_OF(KRB5_AUTHDATA) + + +/* -- Unencrypted authenticator +** Authenticator ::= [APPLICATION 2] SEQUENCE { +** authenticator-vno[0] INTEGER, +** crealm[1] Realm, +** cname[2] PrincipalName, +** cksum[3] Checksum OPTIONAL, +** cusec[4] INTEGER, +** ctime[5] KerberosTime, +** subkey[6] EncryptionKey OPTIONAL, +** seq-number[7] INTEGER OPTIONAL, +** authorization-data[8] AuthorizationData OPTIONAL +** } +*/ +typedef struct krb5_authenticator_st + { + ASN1_INTEGER *avno; + ASN1_GENERALSTRING *crealm; + KRB5_PRINCNAME *cname; + KRB5_CHECKSUM *cksum; + ASN1_INTEGER *cusec; + ASN1_GENERALIZEDTIME *ctime; + KRB5_ENCKEY *subkey; + ASN1_INTEGER *seqnum; + KRB5_AUTHDATA *authorization; + } KRB5_AUTHENTBODY; + +typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT; +DECLARE_STACK_OF(KRB5_AUTHENTBODY) + + +/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) = +** type *name##_new(void); +** void name##_free(type *a); +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) = +** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) = +** type *d2i_##name(type **a, const unsigned char **in, long len); +** int i2d_##name(type *a, unsigned char **out); +** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it +*/ + +DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME) +DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_TICKET) +DECLARE_ASN1_FUNCTIONS(KRB5_APREQ) + +DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM) +DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) +DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT) + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/kssl.h b/libraries/external/openssl/pc/include/openssl/kssl.h new file mode 100755 index 0000000..c84820f --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/kssl.h @@ -0,0 +1,179 @@ +/* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */ +/* Written by Vern Staats for the OpenSSL project 2000. + * project 2000. + */ +/* ==================================================================== + * Copyright (c) 2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* +** 19990701 VRS Started. +*/ + +#ifndef KSSL_H +#define KSSL_H + +#include + +#ifndef OPENSSL_NO_KRB5 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Depending on which KRB5 implementation used, some types from +** the other may be missing. Resolve that here and now +*/ +#ifdef KRB5_HEIMDAL +typedef unsigned char krb5_octet; +#define FAR +#else + +#ifndef FAR +#define FAR +#endif + +#endif + +/* Uncomment this to debug kssl problems or +** to trace usage of the Kerberos session key +** +** #define KSSL_DEBUG +*/ + +#ifndef KRB5SVC +#define KRB5SVC "host" +#endif + +#ifndef KRB5KEYTAB +#define KRB5KEYTAB "/etc/krb5.keytab" +#endif + +#ifndef KRB5SENDAUTH +#define KRB5SENDAUTH 1 +#endif + +#ifndef KRB5CHECKAUTH +#define KRB5CHECKAUTH 1 +#endif + +#ifndef KSSL_CLOCKSKEW +#define KSSL_CLOCKSKEW 300; +#endif + +#define KSSL_ERR_MAX 255 +typedef struct kssl_err_st { + int reason; + char text[KSSL_ERR_MAX+1]; + } KSSL_ERR; + + +/* Context for passing +** (1) Kerberos session key to SSL, and +** (2) Config data between application and SSL lib +*/ +typedef struct kssl_ctx_st + { + /* used by: disposition: */ + char *service_name; /* C,S default ok (kssl) */ + char *service_host; /* C input, REQUIRED */ + char *client_princ; /* S output from krb5 ticket */ + char *keytab_file; /* S NULL (/etc/krb5.keytab) */ + char *cred_cache; /* C NULL (default) */ + krb5_enctype enctype; + int length; + krb5_octet FAR *key; + } KSSL_CTX; + +#define KSSL_CLIENT 1 +#define KSSL_SERVER 2 +#define KSSL_SERVICE 3 +#define KSSL_KEYTAB 4 + +#define KSSL_CTX_OK 0 +#define KSSL_CTX_ERR 1 +#define KSSL_NOMEM 2 + +/* Public (for use by applications that use OpenSSL with Kerberos 5 support */ +krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text); +KSSL_CTX *kssl_ctx_new(void); +KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx); +void kssl_ctx_show(KSSL_CTX *kssl_ctx); +krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which, + krb5_data *realm, krb5_data *entity, int nentities); +krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp, + krb5_data *authenp, KSSL_ERR *kssl_err); +krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata, + krb5_ticket_times *ttimes, KSSL_ERR *kssl_err); +krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session); +void kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text); +void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data); +krb5_error_code kssl_build_principal_2(krb5_context context, + krb5_principal *princ, int rlen, const char *realm, + int slen, const char *svc, int hlen, const char *host); +krb5_error_code kssl_validate_times(krb5_timestamp atime, + krb5_ticket_times *ttimes); +krb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp, + krb5_timestamp *atimep, KSSL_ERR *kssl_err); +unsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn); + +#ifdef __cplusplus +} +#endif +#endif /* OPENSSL_NO_KRB5 */ +#endif /* KSSL_H */ diff --git a/libraries/external/openssl/pc/include/openssl/lhash.h b/libraries/external/openssl/pc/include/openssl/lhash.h new file mode 100755 index 0000000..d0b1daf --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/lhash.h @@ -0,0 +1,200 @@ +/* crypto/lhash/lhash.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ + +#ifndef HEADER_LHASH_H +#define HEADER_LHASH_H + +#include +#ifndef OPENSSL_NO_FP_API +#include +#endif + +#ifndef OPENSSL_NO_BIO +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct lhash_node_st + { + void *data; + struct lhash_node_st *next; +#ifndef OPENSSL_NO_HASH_COMP + unsigned long hash; +#endif + } LHASH_NODE; + +typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); +typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); +typedef void (*LHASH_DOALL_FN_TYPE)(void *); +typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); + +/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. + * This way, callbacks can be provided to LHASH structures without function + * pointer casting and the macro-defined callbacks provide per-variable casting + * before deferring to the underlying type-specific callbacks. NB: It is + * possible to place a "static" in front of both the DECLARE and IMPLEMENT + * macros if the functions are strictly internal. */ + +/* First: "hash" functions */ +#define DECLARE_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *); +#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ + unsigned long f_name##_LHASH_HASH(const void *arg) { \ + o_type a = (o_type)arg; \ + return f_name(a); } +#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH + +/* Second: "compare" functions */ +#define DECLARE_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *, const void *); +#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ + int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ + o_type a = (o_type)arg1; \ + o_type b = (o_type)arg2; \ + return f_name(a,b); } +#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP + +/* Third: "doall" functions */ +#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *); +#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ + void f_name##_LHASH_DOALL(void *arg) { \ + o_type a = (o_type)arg; \ + f_name(a); } +#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL + +/* Fourth: "doall_arg" functions */ +#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *, void *); +#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ + void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ + o_type a = (o_type)arg1; \ + a_type b = (a_type)arg2; \ + f_name(a,b); } +#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG + +typedef struct lhash_st + { + LHASH_NODE **b; + LHASH_COMP_FN_TYPE comp; + LHASH_HASH_FN_TYPE hash; + unsigned int num_nodes; + unsigned int num_alloc_nodes; + unsigned int p; + unsigned int pmax; + unsigned long up_load; /* load times 256 */ + unsigned long down_load; /* load times 256 */ + unsigned long num_items; + + unsigned long num_expands; + unsigned long num_expand_reallocs; + unsigned long num_contracts; + unsigned long num_contract_reallocs; + unsigned long num_hash_calls; + unsigned long num_comp_calls; + unsigned long num_insert; + unsigned long num_replace; + unsigned long num_delete; + unsigned long num_no_delete; + unsigned long num_retrieve; + unsigned long num_retrieve_miss; + unsigned long num_hash_comps; + + int error; + } LHASH; + +#define LH_LOAD_MULT 256 + +/* Indicates a malloc() error in the last call, this is only bad + * in lh_insert(). */ +#define lh_error(lh) ((lh)->error) + +LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); +void lh_free(LHASH *lh); +void *lh_insert(LHASH *lh, void *data); +void *lh_delete(LHASH *lh, const void *data); +void *lh_retrieve(LHASH *lh, const void *data); +void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); +unsigned long lh_strhash(const char *c); +unsigned long lh_num_items(const LHASH *lh); + +#ifndef OPENSSL_NO_FP_API +void lh_stats(const LHASH *lh, FILE *out); +void lh_node_stats(const LHASH *lh, FILE *out); +void lh_node_usage_stats(const LHASH *lh, FILE *out); +#endif + +#ifndef OPENSSL_NO_BIO +void lh_stats_bio(const LHASH *lh, BIO *out); +void lh_node_stats_bio(const LHASH *lh, BIO *out); +void lh_node_usage_stats_bio(const LHASH *lh, BIO *out); +#endif +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/md2.h b/libraries/external/openssl/pc/include/openssl/md2.h new file mode 100755 index 0000000..442fc5a --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/md2.h @@ -0,0 +1,92 @@ +/* crypto/md/md2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD2_H +#define HEADER_MD2_H + +#include /* OPENSSL_NO_MD2, MD2_INT */ +#ifdef OPENSSL_NO_MD2 +#error MD2 is disabled. +#endif +#include + +#define MD2_DIGEST_LENGTH 16 +#define MD2_BLOCK 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct MD2state_st + { + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; + } MD2_CTX; + +const char *MD2_options(void); +int MD2_Init(MD2_CTX *c); +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); +int MD2_Final(unsigned char *md, MD2_CTX *c); +unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/md4.h b/libraries/external/openssl/pc/include/openssl/md4.h new file mode 100755 index 0000000..8315d5c --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/md4.h @@ -0,0 +1,117 @@ +/* crypto/md4/md4.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD4_H +#define HEADER_MD4_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD4 +#error MD4 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD4_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD4_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD4_LONG unsigned long +#define MD4_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD4_LONG unsigned int +#endif + +#define MD4_CBLOCK 64 +#define MD4_LBLOCK (MD4_CBLOCK/4) +#define MD4_DIGEST_LENGTH 16 + +typedef struct MD4state_st + { + MD4_LONG A,B,C,D; + MD4_LONG Nl,Nh; + MD4_LONG data[MD4_LBLOCK]; + unsigned int num; + } MD4_CTX; + +int MD4_Init(MD4_CTX *c); +int MD4_Update(MD4_CTX *c, const void *data, size_t len); +int MD4_Final(unsigned char *md, MD4_CTX *c); +unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); +void MD4_Transform(MD4_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/md5.h b/libraries/external/openssl/pc/include/openssl/md5.h new file mode 100755 index 0000000..d09e099 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/md5.h @@ -0,0 +1,117 @@ +/* crypto/md5/md5.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_MD5_H +#define HEADER_MD5_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_MD5 +#error MD5 is disabled. +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! MD5_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define MD5_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define MD5_LONG unsigned long +#define MD5_LONG_LOG2 3 +/* + * _CRAY note. I could declare short, but I have no idea what impact + * does it have on performance on none-T3E machines. I could declare + * int, but at least on C90 sizeof(int) can be chosen at compile time. + * So I've chosen long... + * + */ +#else +#define MD5_LONG unsigned int +#endif + +#define MD5_CBLOCK 64 +#define MD5_LBLOCK (MD5_CBLOCK/4) +#define MD5_DIGEST_LENGTH 16 + +typedef struct MD5state_st + { + MD5_LONG A,B,C,D; + MD5_LONG Nl,Nh; + MD5_LONG data[MD5_LBLOCK]; + unsigned int num; + } MD5_CTX; + +int MD5_Init(MD5_CTX *c); +int MD5_Update(MD5_CTX *c, const void *data, size_t len); +int MD5_Final(unsigned char *md, MD5_CTX *c); +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); +void MD5_Transform(MD5_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/obj_mac.h b/libraries/external/openssl/pc/include/openssl/obj_mac.h new file mode 100755 index 0000000..d53e809 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/obj_mac.h @@ -0,0 +1,3408 @@ +/* crypto/objects/obj_mac.h */ + +/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the + * following command: + * perl objects.pl objects.txt obj_mac.num obj_mac.h + */ + +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_itu_t "ITU-T" +#define LN_itu_t "itu-t" +#define NID_itu_t 645 +#define OBJ_itu_t 0L + +#define NID_ccitt 404 +#define OBJ_ccitt OBJ_itu_t + +#define SN_iso "ISO" +#define LN_iso "iso" +#define NID_iso 181 +#define OBJ_iso 1L + +#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" +#define LN_joint_iso_itu_t "joint-iso-itu-t" +#define NID_joint_iso_itu_t 646 +#define OBJ_joint_iso_itu_t 2L + +#define NID_joint_iso_ccitt 393 +#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t + +#define SN_member_body "member-body" +#define LN_member_body "ISO Member Body" +#define NID_member_body 182 +#define OBJ_member_body OBJ_iso,2L + +#define SN_identified_organization "identified-organization" +#define NID_identified_organization 676 +#define OBJ_identified_organization OBJ_iso,3L + +#define SN_certicom_arc "certicom-arc" +#define NID_certicom_arc 677 +#define OBJ_certicom_arc OBJ_identified_organization,132L + +#define SN_international_organizations "international-organizations" +#define LN_international_organizations "International Organizations" +#define NID_international_organizations 647 +#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L + +#define SN_wap "wap" +#define NID_wap 678 +#define OBJ_wap OBJ_international_organizations,43L + +#define SN_wap_wsg "wap-wsg" +#define NID_wap_wsg 679 +#define OBJ_wap_wsg OBJ_wap,13L + +#define SN_selected_attribute_types "selected-attribute-types" +#define LN_selected_attribute_types "Selected Attribute Types" +#define NID_selected_attribute_types 394 +#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L + +#define SN_clearance "clearance" +#define NID_clearance 395 +#define OBJ_clearance OBJ_selected_attribute_types,55L + +#define SN_ISO_US "ISO-US" +#define LN_ISO_US "ISO US Member Body" +#define NID_ISO_US 183 +#define OBJ_ISO_US OBJ_member_body,840L + +#define SN_X9_57 "X9-57" +#define LN_X9_57 "X9.57" +#define NID_X9_57 184 +#define OBJ_X9_57 OBJ_ISO_US,10040L + +#define SN_X9cm "X9cm" +#define LN_X9cm "X9.57 CM ?" +#define NID_X9cm 185 +#define OBJ_X9cm OBJ_X9_57,4L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa OBJ_X9cm,1L + +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 OBJ_X9cm,3L + +#define SN_ansi_X9_62 "ansi-X9-62" +#define LN_ansi_X9_62 "ANSI X9.62" +#define NID_ansi_X9_62 405 +#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L + +#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L + +#define SN_X9_62_prime_field "prime-field" +#define NID_X9_62_prime_field 406 +#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L + +#define SN_X9_62_characteristic_two_field "characteristic-two-field" +#define NID_X9_62_characteristic_two_field 407 +#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L + +#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" +#define NID_X9_62_id_characteristic_two_basis 680 +#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L + +#define SN_X9_62_onBasis "onBasis" +#define NID_X9_62_onBasis 681 +#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L + +#define SN_X9_62_tpBasis "tpBasis" +#define NID_X9_62_tpBasis 682 +#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L + +#define SN_X9_62_ppBasis "ppBasis" +#define NID_X9_62_ppBasis 683 +#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L + +#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L + +#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" +#define NID_X9_62_id_ecPublicKey 408 +#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L + +#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L + +#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L + +#define SN_X9_62_c2pnb163v1 "c2pnb163v1" +#define NID_X9_62_c2pnb163v1 684 +#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L + +#define SN_X9_62_c2pnb163v2 "c2pnb163v2" +#define NID_X9_62_c2pnb163v2 685 +#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L + +#define SN_X9_62_c2pnb163v3 "c2pnb163v3" +#define NID_X9_62_c2pnb163v3 686 +#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L + +#define SN_X9_62_c2pnb176v1 "c2pnb176v1" +#define NID_X9_62_c2pnb176v1 687 +#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L + +#define SN_X9_62_c2tnb191v1 "c2tnb191v1" +#define NID_X9_62_c2tnb191v1 688 +#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L + +#define SN_X9_62_c2tnb191v2 "c2tnb191v2" +#define NID_X9_62_c2tnb191v2 689 +#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L + +#define SN_X9_62_c2tnb191v3 "c2tnb191v3" +#define NID_X9_62_c2tnb191v3 690 +#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L + +#define SN_X9_62_c2onb191v4 "c2onb191v4" +#define NID_X9_62_c2onb191v4 691 +#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L + +#define SN_X9_62_c2onb191v5 "c2onb191v5" +#define NID_X9_62_c2onb191v5 692 +#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L + +#define SN_X9_62_c2pnb208w1 "c2pnb208w1" +#define NID_X9_62_c2pnb208w1 693 +#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L + +#define SN_X9_62_c2tnb239v1 "c2tnb239v1" +#define NID_X9_62_c2tnb239v1 694 +#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L + +#define SN_X9_62_c2tnb239v2 "c2tnb239v2" +#define NID_X9_62_c2tnb239v2 695 +#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L + +#define SN_X9_62_c2tnb239v3 "c2tnb239v3" +#define NID_X9_62_c2tnb239v3 696 +#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L + +#define SN_X9_62_c2onb239v4 "c2onb239v4" +#define NID_X9_62_c2onb239v4 697 +#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L + +#define SN_X9_62_c2onb239v5 "c2onb239v5" +#define NID_X9_62_c2onb239v5 698 +#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L + +#define SN_X9_62_c2pnb272w1 "c2pnb272w1" +#define NID_X9_62_c2pnb272w1 699 +#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L + +#define SN_X9_62_c2pnb304w1 "c2pnb304w1" +#define NID_X9_62_c2pnb304w1 700 +#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L + +#define SN_X9_62_c2tnb359v1 "c2tnb359v1" +#define NID_X9_62_c2tnb359v1 701 +#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L + +#define SN_X9_62_c2pnb368w1 "c2pnb368w1" +#define NID_X9_62_c2pnb368w1 702 +#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L + +#define SN_X9_62_c2tnb431r1 "c2tnb431r1" +#define NID_X9_62_c2tnb431r1 703 +#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L + +#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L + +#define SN_X9_62_prime192v1 "prime192v1" +#define NID_X9_62_prime192v1 409 +#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L + +#define SN_X9_62_prime192v2 "prime192v2" +#define NID_X9_62_prime192v2 410 +#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L + +#define SN_X9_62_prime192v3 "prime192v3" +#define NID_X9_62_prime192v3 411 +#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L + +#define SN_X9_62_prime239v1 "prime239v1" +#define NID_X9_62_prime239v1 412 +#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L + +#define SN_X9_62_prime239v2 "prime239v2" +#define NID_X9_62_prime239v2 413 +#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L + +#define SN_X9_62_prime239v3 "prime239v3" +#define NID_X9_62_prime239v3 414 +#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L + +#define SN_X9_62_prime256v1 "prime256v1" +#define NID_X9_62_prime256v1 415 +#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L + +#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L + +#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" +#define NID_ecdsa_with_SHA1 416 +#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L + +#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L + +#define SN_secp112r1 "secp112r1" +#define NID_secp112r1 704 +#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L + +#define SN_secp112r2 "secp112r2" +#define NID_secp112r2 705 +#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L + +#define SN_secp128r1 "secp128r1" +#define NID_secp128r1 706 +#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L + +#define SN_secp128r2 "secp128r2" +#define NID_secp128r2 707 +#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L + +#define SN_secp160k1 "secp160k1" +#define NID_secp160k1 708 +#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L + +#define SN_secp160r1 "secp160r1" +#define NID_secp160r1 709 +#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L + +#define SN_secp160r2 "secp160r2" +#define NID_secp160r2 710 +#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L + +#define SN_secp192k1 "secp192k1" +#define NID_secp192k1 711 +#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L + +#define SN_secp224k1 "secp224k1" +#define NID_secp224k1 712 +#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L + +#define SN_secp224r1 "secp224r1" +#define NID_secp224r1 713 +#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L + +#define SN_secp256k1 "secp256k1" +#define NID_secp256k1 714 +#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L + +#define SN_secp384r1 "secp384r1" +#define NID_secp384r1 715 +#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L + +#define SN_secp521r1 "secp521r1" +#define NID_secp521r1 716 +#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L + +#define SN_sect113r1 "sect113r1" +#define NID_sect113r1 717 +#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L + +#define SN_sect113r2 "sect113r2" +#define NID_sect113r2 718 +#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L + +#define SN_sect131r1 "sect131r1" +#define NID_sect131r1 719 +#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L + +#define SN_sect131r2 "sect131r2" +#define NID_sect131r2 720 +#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L + +#define SN_sect163k1 "sect163k1" +#define NID_sect163k1 721 +#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L + +#define SN_sect163r1 "sect163r1" +#define NID_sect163r1 722 +#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L + +#define SN_sect163r2 "sect163r2" +#define NID_sect163r2 723 +#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L + +#define SN_sect193r1 "sect193r1" +#define NID_sect193r1 724 +#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L + +#define SN_sect193r2 "sect193r2" +#define NID_sect193r2 725 +#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L + +#define SN_sect233k1 "sect233k1" +#define NID_sect233k1 726 +#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L + +#define SN_sect233r1 "sect233r1" +#define NID_sect233r1 727 +#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L + +#define SN_sect239k1 "sect239k1" +#define NID_sect239k1 728 +#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L + +#define SN_sect283k1 "sect283k1" +#define NID_sect283k1 729 +#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L + +#define SN_sect283r1 "sect283r1" +#define NID_sect283r1 730 +#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L + +#define SN_sect409k1 "sect409k1" +#define NID_sect409k1 731 +#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L + +#define SN_sect409r1 "sect409r1" +#define NID_sect409r1 732 +#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L + +#define SN_sect571k1 "sect571k1" +#define NID_sect571k1 733 +#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L + +#define SN_sect571r1 "sect571r1" +#define NID_sect571r1 734 +#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L + +#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L + +#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" +#define NID_wap_wsg_idm_ecid_wtls1 735 +#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L + +#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" +#define NID_wap_wsg_idm_ecid_wtls3 736 +#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L + +#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" +#define NID_wap_wsg_idm_ecid_wtls4 737 +#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L + +#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" +#define NID_wap_wsg_idm_ecid_wtls5 738 +#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L + +#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" +#define NID_wap_wsg_idm_ecid_wtls6 739 +#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L + +#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" +#define NID_wap_wsg_idm_ecid_wtls7 740 +#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L + +#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" +#define NID_wap_wsg_idm_ecid_wtls8 741 +#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L + +#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" +#define NID_wap_wsg_idm_ecid_wtls9 742 +#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L + +#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" +#define NID_wap_wsg_idm_ecid_wtls10 743 +#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L + +#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" +#define NID_wap_wsg_idm_ecid_wtls11 744 +#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L + +#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" +#define NID_wap_wsg_idm_ecid_wtls12 745 +#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L + +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L + +#define SN_rsadsi "rsadsi" +#define LN_rsadsi "RSA Data Security, Inc." +#define NID_rsadsi 1 +#define OBJ_rsadsi OBJ_ISO_US,113549L + +#define SN_pkcs "pkcs" +#define LN_pkcs "RSA Data Security, Inc. PKCS" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_pkcs1 "pkcs1" +#define NID_pkcs1 186 +#define OBJ_pkcs1 OBJ_pkcs,1L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs1,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L + +#define SN_md4WithRSAEncryption "RSA-MD4" +#define LN_md4WithRSAEncryption "md4WithRSAEncryption" +#define NID_md4WithRSAEncryption 396 +#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L + +#define SN_sha256WithRSAEncryption "RSA-SHA256" +#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" +#define NID_sha256WithRSAEncryption 668 +#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L + +#define SN_sha384WithRSAEncryption "RSA-SHA384" +#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" +#define NID_sha384WithRSAEncryption 669 +#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L + +#define SN_sha512WithRSAEncryption "RSA-SHA512" +#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" +#define NID_sha512WithRSAEncryption 670 +#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L + +#define SN_sha224WithRSAEncryption "RSA-SHA224" +#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" +#define NID_sha224WithRSAEncryption 671 +#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L + +#define SN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_pkcs5 "pkcs5" +#define NID_pkcs5 187 +#define OBJ_pkcs5 OBJ_pkcs,5L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L + +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L + +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs5,12L + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs5,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs5,14L + +#define SN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define SN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_ext_req "extReq" +#define LN_ext_req "Extension Request" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_SMIME "SMIME" +#define LN_SMIME "S/MIME" +#define NID_SMIME 188 +#define OBJ_SMIME OBJ_pkcs9,16L + +#define SN_id_smime_mod "id-smime-mod" +#define NID_id_smime_mod 189 +#define OBJ_id_smime_mod OBJ_SMIME,0L + +#define SN_id_smime_ct "id-smime-ct" +#define NID_id_smime_ct 190 +#define OBJ_id_smime_ct OBJ_SMIME,1L + +#define SN_id_smime_aa "id-smime-aa" +#define NID_id_smime_aa 191 +#define OBJ_id_smime_aa OBJ_SMIME,2L + +#define SN_id_smime_alg "id-smime-alg" +#define NID_id_smime_alg 192 +#define OBJ_id_smime_alg OBJ_SMIME,3L + +#define SN_id_smime_cd "id-smime-cd" +#define NID_id_smime_cd 193 +#define OBJ_id_smime_cd OBJ_SMIME,4L + +#define SN_id_smime_spq "id-smime-spq" +#define NID_id_smime_spq 194 +#define OBJ_id_smime_spq OBJ_SMIME,5L + +#define SN_id_smime_cti "id-smime-cti" +#define NID_id_smime_cti 195 +#define OBJ_id_smime_cti OBJ_SMIME,6L + +#define SN_id_smime_mod_cms "id-smime-mod-cms" +#define NID_id_smime_mod_cms 196 +#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L + +#define SN_id_smime_mod_ess "id-smime-mod-ess" +#define NID_id_smime_mod_ess 197 +#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L + +#define SN_id_smime_mod_oid "id-smime-mod-oid" +#define NID_id_smime_mod_oid 198 +#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L + +#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" +#define NID_id_smime_mod_msg_v3 199 +#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L + +#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" +#define NID_id_smime_mod_ets_eSignature_88 200 +#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L + +#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" +#define NID_id_smime_mod_ets_eSignature_97 201 +#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L + +#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" +#define NID_id_smime_mod_ets_eSigPolicy_88 202 +#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L + +#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" +#define NID_id_smime_mod_ets_eSigPolicy_97 203 +#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L + +#define SN_id_smime_ct_receipt "id-smime-ct-receipt" +#define NID_id_smime_ct_receipt 204 +#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L + +#define SN_id_smime_ct_authData "id-smime-ct-authData" +#define NID_id_smime_ct_authData 205 +#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L + +#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" +#define NID_id_smime_ct_publishCert 206 +#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L + +#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" +#define NID_id_smime_ct_TSTInfo 207 +#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L + +#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" +#define NID_id_smime_ct_TDTInfo 208 +#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L + +#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" +#define NID_id_smime_ct_contentInfo 209 +#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L + +#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" +#define NID_id_smime_ct_DVCSRequestData 210 +#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L + +#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" +#define NID_id_smime_ct_DVCSResponseData 211 +#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L + +#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" +#define NID_id_smime_aa_receiptRequest 212 +#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L + +#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" +#define NID_id_smime_aa_securityLabel 213 +#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L + +#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" +#define NID_id_smime_aa_mlExpandHistory 214 +#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L + +#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" +#define NID_id_smime_aa_contentHint 215 +#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L + +#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" +#define NID_id_smime_aa_msgSigDigest 216 +#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L + +#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" +#define NID_id_smime_aa_encapContentType 217 +#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L + +#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" +#define NID_id_smime_aa_contentIdentifier 218 +#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L + +#define SN_id_smime_aa_macValue "id-smime-aa-macValue" +#define NID_id_smime_aa_macValue 219 +#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L + +#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" +#define NID_id_smime_aa_equivalentLabels 220 +#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L + +#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" +#define NID_id_smime_aa_contentReference 221 +#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L + +#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" +#define NID_id_smime_aa_encrypKeyPref 222 +#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L + +#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" +#define NID_id_smime_aa_signingCertificate 223 +#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L + +#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" +#define NID_id_smime_aa_smimeEncryptCerts 224 +#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L + +#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" +#define NID_id_smime_aa_timeStampToken 225 +#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L + +#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" +#define NID_id_smime_aa_ets_sigPolicyId 226 +#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L + +#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" +#define NID_id_smime_aa_ets_commitmentType 227 +#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L + +#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" +#define NID_id_smime_aa_ets_signerLocation 228 +#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L + +#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" +#define NID_id_smime_aa_ets_signerAttr 229 +#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L + +#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" +#define NID_id_smime_aa_ets_otherSigCert 230 +#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L + +#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" +#define NID_id_smime_aa_ets_contentTimestamp 231 +#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L + +#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" +#define NID_id_smime_aa_ets_CertificateRefs 232 +#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L + +#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" +#define NID_id_smime_aa_ets_RevocationRefs 233 +#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L + +#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" +#define NID_id_smime_aa_ets_certValues 234 +#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L + +#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" +#define NID_id_smime_aa_ets_revocationValues 235 +#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L + +#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" +#define NID_id_smime_aa_ets_escTimeStamp 236 +#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L + +#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" +#define NID_id_smime_aa_ets_certCRLTimestamp 237 +#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L + +#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" +#define NID_id_smime_aa_ets_archiveTimeStamp 238 +#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L + +#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" +#define NID_id_smime_aa_signatureType 239 +#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L + +#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" +#define NID_id_smime_aa_dvcs_dvc 240 +#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L + +#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" +#define NID_id_smime_alg_ESDHwith3DES 241 +#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L + +#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" +#define NID_id_smime_alg_ESDHwithRC2 242 +#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L + +#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" +#define NID_id_smime_alg_3DESwrap 243 +#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L + +#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" +#define NID_id_smime_alg_RC2wrap 244 +#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L + +#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" +#define NID_id_smime_alg_ESDH 245 +#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L + +#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" +#define NID_id_smime_alg_CMS3DESwrap 246 +#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L + +#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" +#define NID_id_smime_alg_CMSRC2wrap 247 +#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L + +#define SN_id_smime_cd_ldap "id-smime-cd-ldap" +#define NID_id_smime_cd_ldap 248 +#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L + +#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" +#define NID_id_smime_spq_ets_sqt_uri 249 +#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L + +#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" +#define NID_id_smime_spq_ets_sqt_unotice 250 +#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L + +#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" +#define NID_id_smime_cti_ets_proofOfOrigin 251 +#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L + +#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" +#define NID_id_smime_cti_ets_proofOfReceipt 252 +#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L + +#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" +#define NID_id_smime_cti_ets_proofOfDelivery 253 +#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L + +#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" +#define NID_id_smime_cti_ets_proofOfSender 254 +#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L + +#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" +#define NID_id_smime_cti_ets_proofOfApproval 255 +#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L + +#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" +#define NID_id_smime_cti_ets_proofOfCreation 256 +#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9,20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9,21L + +#define SN_ms_csp_name "CSPName" +#define LN_ms_csp_name "Microsoft CSP Name" +#define NID_ms_csp_name 417 +#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L + +#define OBJ_certTypes OBJ_pkcs9,22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes,1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes,2L + +#define OBJ_crlTypes OBJ_pkcs9,23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes,1L + +#define OBJ_pkcs12 OBJ_pkcs,12L + +#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds,1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds,3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds,4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds,5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md4 "MD4" +#define LN_md4 "md4" +#define NID_md4 257 +#define OBJ_md4 OBJ_rsadsi,2L,4L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" +#define NID_md5_sha1 114 + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_ms_ext_req "msExtReq" +#define LN_ms_ext_req "Microsoft Extension Request" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +#define SN_ms_smartcard_login "msSmartcardLogin" +#define LN_ms_smartcard_login "Microsoft Smartcardlogin" +#define NID_ms_smartcard_login 648 +#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L + +#define SN_ms_upn "msUPN" +#define LN_ms_upn "Microsoft Universal Principal Name" +#define NID_ms_upn 649 +#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_pkix_mod "id-pkix-mod" +#define NID_id_pkix_mod 258 +#define OBJ_id_pkix_mod OBJ_id_pkix,0L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_qt "id-qt" +#define NID_id_qt 259 +#define OBJ_id_qt OBJ_id_pkix,2L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +#define SN_id_it "id-it" +#define NID_id_it 260 +#define OBJ_id_it OBJ_id_pkix,4L + +#define SN_id_pkip "id-pkip" +#define NID_id_pkip 261 +#define OBJ_id_pkip OBJ_id_pkix,5L + +#define SN_id_alg "id-alg" +#define NID_id_alg 262 +#define OBJ_id_alg OBJ_id_pkix,6L + +#define SN_id_cmc "id-cmc" +#define NID_id_cmc 263 +#define OBJ_id_cmc OBJ_id_pkix,7L + +#define SN_id_on "id-on" +#define NID_id_on 264 +#define OBJ_id_on OBJ_id_pkix,8L + +#define SN_id_pda "id-pda" +#define NID_id_pda 265 +#define OBJ_id_pda OBJ_id_pkix,9L + +#define SN_id_aca "id-aca" +#define NID_id_aca 266 +#define OBJ_id_aca OBJ_id_pkix,10L + +#define SN_id_qcs "id-qcs" +#define NID_id_qcs 267 +#define OBJ_id_qcs OBJ_id_pkix,11L + +#define SN_id_cct "id-cct" +#define NID_id_cct 268 +#define OBJ_id_cct OBJ_id_pkix,12L + +#define SN_id_ppl "id-ppl" +#define NID_id_ppl 662 +#define OBJ_id_ppl OBJ_id_pkix,21L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" +#define NID_id_pkix1_explicit_88 269 +#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L + +#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" +#define NID_id_pkix1_implicit_88 270 +#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L + +#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" +#define NID_id_pkix1_explicit_93 271 +#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L + +#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" +#define NID_id_pkix1_implicit_93 272 +#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L + +#define SN_id_mod_crmf "id-mod-crmf" +#define NID_id_mod_crmf 273 +#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L + +#define SN_id_mod_cmc "id-mod-cmc" +#define NID_id_mod_cmc 274 +#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L + +#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" +#define NID_id_mod_kea_profile_88 275 +#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L + +#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" +#define NID_id_mod_kea_profile_93 276 +#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L + +#define SN_id_mod_cmp "id-mod-cmp" +#define NID_id_mod_cmp 277 +#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L + +#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" +#define NID_id_mod_qualified_cert_88 278 +#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L + +#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" +#define NID_id_mod_qualified_cert_93 279 +#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L + +#define SN_id_mod_attribute_cert "id-mod-attribute-cert" +#define NID_id_mod_attribute_cert 280 +#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L + +#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" +#define NID_id_mod_timestamp_protocol 281 +#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L + +#define SN_id_mod_ocsp "id-mod-ocsp" +#define NID_id_mod_ocsp 282 +#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L + +#define SN_id_mod_dvcs "id-mod-dvcs" +#define NID_id_mod_dvcs 283 +#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L + +#define SN_id_mod_cmp2000 "id-mod-cmp2000" +#define NID_id_mod_cmp2000 284 +#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_biometricInfo "biometricInfo" +#define LN_biometricInfo "Biometric Info" +#define NID_biometricInfo 285 +#define OBJ_biometricInfo OBJ_id_pe,2L + +#define SN_qcStatements "qcStatements" +#define NID_qcStatements 286 +#define OBJ_qcStatements OBJ_id_pe,3L + +#define SN_ac_auditEntity "ac-auditEntity" +#define NID_ac_auditEntity 287 +#define OBJ_ac_auditEntity OBJ_id_pe,4L + +#define SN_ac_targeting "ac-targeting" +#define NID_ac_targeting 288 +#define OBJ_ac_targeting OBJ_id_pe,5L + +#define SN_aaControls "aaControls" +#define NID_aaControls 289 +#define OBJ_aaControls OBJ_id_pe,6L + +#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" +#define NID_sbgp_ipAddrBlock 290 +#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L + +#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" +#define NID_sbgp_autonomousSysNum 291 +#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L + +#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" +#define NID_sbgp_routerIdentifier 292 +#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L + +#define SN_ac_proxying "ac-proxying" +#define NID_ac_proxying 397 +#define OBJ_ac_proxying OBJ_id_pe,10L + +#define SN_sinfo_access "subjectInfoAccess" +#define LN_sinfo_access "Subject Information Access" +#define NID_sinfo_access 398 +#define OBJ_sinfo_access OBJ_id_pe,11L + +#define SN_proxyCertInfo "proxyCertInfo" +#define LN_proxyCertInfo "Proxy Certificate Information" +#define NID_proxyCertInfo 663 +#define OBJ_proxyCertInfo OBJ_id_pe,14L + +#define SN_id_qt_cps "id-qt-cps" +#define LN_id_qt_cps "Policy Qualifier CPS" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_qt,1L + +#define SN_id_qt_unotice "id-qt-unotice" +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_qt,2L + +#define SN_textNotice "textNotice" +#define NID_textNotice 293 +#define OBJ_textNotice OBJ_id_qt,3L + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_ipsecEndSystem "ipsecEndSystem" +#define LN_ipsecEndSystem "IPSec End System" +#define NID_ipsecEndSystem 294 +#define OBJ_ipsecEndSystem OBJ_id_kp,5L + +#define SN_ipsecTunnel "ipsecTunnel" +#define LN_ipsecTunnel "IPSec Tunnel" +#define NID_ipsecTunnel 295 +#define OBJ_ipsecTunnel OBJ_id_kp,6L + +#define SN_ipsecUser "ipsecUser" +#define LN_ipsecUser "IPSec User" +#define NID_ipsecUser 296 +#define OBJ_ipsecUser OBJ_id_kp,7L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L + +#define SN_dvcs "DVCS" +#define LN_dvcs "dvcs" +#define NID_dvcs 297 +#define OBJ_dvcs OBJ_id_kp,10L + +#define SN_id_it_caProtEncCert "id-it-caProtEncCert" +#define NID_id_it_caProtEncCert 298 +#define OBJ_id_it_caProtEncCert OBJ_id_it,1L + +#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" +#define NID_id_it_signKeyPairTypes 299 +#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L + +#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" +#define NID_id_it_encKeyPairTypes 300 +#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L + +#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" +#define NID_id_it_preferredSymmAlg 301 +#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L + +#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" +#define NID_id_it_caKeyUpdateInfo 302 +#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L + +#define SN_id_it_currentCRL "id-it-currentCRL" +#define NID_id_it_currentCRL 303 +#define OBJ_id_it_currentCRL OBJ_id_it,6L + +#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" +#define NID_id_it_unsupportedOIDs 304 +#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L + +#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" +#define NID_id_it_subscriptionRequest 305 +#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L + +#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" +#define NID_id_it_subscriptionResponse 306 +#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L + +#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" +#define NID_id_it_keyPairParamReq 307 +#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L + +#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" +#define NID_id_it_keyPairParamRep 308 +#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L + +#define SN_id_it_revPassphrase "id-it-revPassphrase" +#define NID_id_it_revPassphrase 309 +#define OBJ_id_it_revPassphrase OBJ_id_it,12L + +#define SN_id_it_implicitConfirm "id-it-implicitConfirm" +#define NID_id_it_implicitConfirm 310 +#define OBJ_id_it_implicitConfirm OBJ_id_it,13L + +#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" +#define NID_id_it_confirmWaitTime 311 +#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L + +#define SN_id_it_origPKIMessage "id-it-origPKIMessage" +#define NID_id_it_origPKIMessage 312 +#define OBJ_id_it_origPKIMessage OBJ_id_it,15L + +#define SN_id_regCtrl "id-regCtrl" +#define NID_id_regCtrl 313 +#define OBJ_id_regCtrl OBJ_id_pkip,1L + +#define SN_id_regInfo "id-regInfo" +#define NID_id_regInfo 314 +#define OBJ_id_regInfo OBJ_id_pkip,2L + +#define SN_id_regCtrl_regToken "id-regCtrl-regToken" +#define NID_id_regCtrl_regToken 315 +#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L + +#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" +#define NID_id_regCtrl_authenticator 316 +#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L + +#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" +#define NID_id_regCtrl_pkiPublicationInfo 317 +#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L + +#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" +#define NID_id_regCtrl_pkiArchiveOptions 318 +#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L + +#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" +#define NID_id_regCtrl_oldCertID 319 +#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L + +#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" +#define NID_id_regCtrl_protocolEncrKey 320 +#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L + +#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" +#define NID_id_regInfo_utf8Pairs 321 +#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L + +#define SN_id_regInfo_certReq "id-regInfo-certReq" +#define NID_id_regInfo_certReq 322 +#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L + +#define SN_id_alg_des40 "id-alg-des40" +#define NID_id_alg_des40 323 +#define OBJ_id_alg_des40 OBJ_id_alg,1L + +#define SN_id_alg_noSignature "id-alg-noSignature" +#define NID_id_alg_noSignature 324 +#define OBJ_id_alg_noSignature OBJ_id_alg,2L + +#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" +#define NID_id_alg_dh_sig_hmac_sha1 325 +#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L + +#define SN_id_alg_dh_pop "id-alg-dh-pop" +#define NID_id_alg_dh_pop 326 +#define OBJ_id_alg_dh_pop OBJ_id_alg,4L + +#define SN_id_cmc_statusInfo "id-cmc-statusInfo" +#define NID_id_cmc_statusInfo 327 +#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L + +#define SN_id_cmc_identification "id-cmc-identification" +#define NID_id_cmc_identification 328 +#define OBJ_id_cmc_identification OBJ_id_cmc,2L + +#define SN_id_cmc_identityProof "id-cmc-identityProof" +#define NID_id_cmc_identityProof 329 +#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L + +#define SN_id_cmc_dataReturn "id-cmc-dataReturn" +#define NID_id_cmc_dataReturn 330 +#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L + +#define SN_id_cmc_transactionId "id-cmc-transactionId" +#define NID_id_cmc_transactionId 331 +#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L + +#define SN_id_cmc_senderNonce "id-cmc-senderNonce" +#define NID_id_cmc_senderNonce 332 +#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L + +#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" +#define NID_id_cmc_recipientNonce 333 +#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L + +#define SN_id_cmc_addExtensions "id-cmc-addExtensions" +#define NID_id_cmc_addExtensions 334 +#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L + +#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" +#define NID_id_cmc_encryptedPOP 335 +#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L + +#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" +#define NID_id_cmc_decryptedPOP 336 +#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L + +#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" +#define NID_id_cmc_lraPOPWitness 337 +#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L + +#define SN_id_cmc_getCert "id-cmc-getCert" +#define NID_id_cmc_getCert 338 +#define OBJ_id_cmc_getCert OBJ_id_cmc,15L + +#define SN_id_cmc_getCRL "id-cmc-getCRL" +#define NID_id_cmc_getCRL 339 +#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L + +#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" +#define NID_id_cmc_revokeRequest 340 +#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L + +#define SN_id_cmc_regInfo "id-cmc-regInfo" +#define NID_id_cmc_regInfo 341 +#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L + +#define SN_id_cmc_responseInfo "id-cmc-responseInfo" +#define NID_id_cmc_responseInfo 342 +#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L + +#define SN_id_cmc_queryPending "id-cmc-queryPending" +#define NID_id_cmc_queryPending 343 +#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L + +#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" +#define NID_id_cmc_popLinkRandom 344 +#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L + +#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" +#define NID_id_cmc_popLinkWitness 345 +#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L + +#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" +#define NID_id_cmc_confirmCertAcceptance 346 +#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L + +#define SN_id_on_personalData "id-on-personalData" +#define NID_id_on_personalData 347 +#define OBJ_id_on_personalData OBJ_id_on,1L + +#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" +#define NID_id_pda_dateOfBirth 348 +#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L + +#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" +#define NID_id_pda_placeOfBirth 349 +#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L + +#define SN_id_pda_gender "id-pda-gender" +#define NID_id_pda_gender 351 +#define OBJ_id_pda_gender OBJ_id_pda,3L + +#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" +#define NID_id_pda_countryOfCitizenship 352 +#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L + +#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" +#define NID_id_pda_countryOfResidence 353 +#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L + +#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" +#define NID_id_aca_authenticationInfo 354 +#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L + +#define SN_id_aca_accessIdentity "id-aca-accessIdentity" +#define NID_id_aca_accessIdentity 355 +#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L + +#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" +#define NID_id_aca_chargingIdentity 356 +#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L + +#define SN_id_aca_group "id-aca-group" +#define NID_id_aca_group 357 +#define OBJ_id_aca_group OBJ_id_aca,4L + +#define SN_id_aca_role "id-aca-role" +#define NID_id_aca_role 358 +#define OBJ_id_aca_role OBJ_id_aca,5L + +#define SN_id_aca_encAttrs "id-aca-encAttrs" +#define NID_id_aca_encAttrs 399 +#define OBJ_id_aca_encAttrs OBJ_id_aca,6L + +#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" +#define NID_id_qcs_pkixQCSyntax_v1 359 +#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L + +#define SN_id_cct_crs "id-cct-crs" +#define NID_id_cct_crs 360 +#define OBJ_id_cct_crs OBJ_id_cct,1L + +#define SN_id_cct_PKIData "id-cct-PKIData" +#define NID_id_cct_PKIData 361 +#define OBJ_id_cct_PKIData OBJ_id_cct,2L + +#define SN_id_cct_PKIResponse "id-cct-PKIResponse" +#define NID_id_cct_PKIResponse 362 +#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L + +#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" +#define LN_id_ppl_anyLanguage "Any language" +#define NID_id_ppl_anyLanguage 664 +#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L + +#define SN_id_ppl_inheritAll "id-ppl-inheritAll" +#define LN_id_ppl_inheritAll "Inherit all" +#define NID_id_ppl_inheritAll 665 +#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L + +#define SN_Independent "id-ppl-independent" +#define LN_Independent "Independent" +#define NID_Independent 667 +#define OBJ_Independent OBJ_id_ppl,2L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_ad_timeStamping "ad_timestamping" +#define LN_ad_timeStamping "AD Time Stamping" +#define NID_ad_timeStamping 363 +#define OBJ_ad_timeStamping OBJ_id_ad,3L + +#define SN_ad_dvcs "AD_DVCS" +#define LN_ad_dvcs "ad dvcs" +#define NID_ad_dvcs 364 +#define OBJ_ad_dvcs OBJ_id_ad,4L + +#define OBJ_id_pkix_OCSP OBJ_ad_OCSP + +#define SN_id_pkix_OCSP_basic "basicOCSPResponse" +#define LN_id_pkix_OCSP_basic "Basic OCSP Response" +#define NID_id_pkix_OCSP_basic 365 +#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L + +#define SN_id_pkix_OCSP_Nonce "Nonce" +#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" +#define NID_id_pkix_OCSP_Nonce 366 +#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L + +#define SN_id_pkix_OCSP_CrlID "CrlID" +#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" +#define NID_id_pkix_OCSP_CrlID 367 +#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L + +#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" +#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" +#define NID_id_pkix_OCSP_acceptableResponses 368 +#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L + +#define SN_id_pkix_OCSP_noCheck "noCheck" +#define LN_id_pkix_OCSP_noCheck "OCSP No Check" +#define NID_id_pkix_OCSP_noCheck 369 +#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L + +#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" +#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" +#define NID_id_pkix_OCSP_archiveCutoff 370 +#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L + +#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" +#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" +#define NID_id_pkix_OCSP_serviceLocator 371 +#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L + +#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" +#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" +#define NID_id_pkix_OCSP_extendedStatus 372 +#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L + +#define SN_id_pkix_OCSP_valid "valid" +#define NID_id_pkix_OCSP_valid 373 +#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L + +#define SN_id_pkix_OCSP_path "path" +#define NID_id_pkix_OCSP_path 374 +#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L + +#define SN_id_pkix_OCSP_trustRoot "trustRoot" +#define LN_id_pkix_OCSP_trustRoot "Trust Root" +#define NID_id_pkix_OCSP_trustRoot 375 +#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L + +#define SN_algorithm "algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 376 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_rsaSignature "rsaSignature" +#define NID_rsaSignature 377 +#define OBJ_rsaSignature OBJ_algorithm,11L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_ecb "DES-EDE" +#define LN_des_ede_ecb "des-ede" +#define NID_des_ede_ecb 32 +#define OBJ_des_ede_ecb OBJ_algorithm,17L + +#define SN_des_ede3_ecb "DES-EDE3" +#define LN_des_ede3_ecb "des-ede3" +#define NID_des_ede3_ecb 33 + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +#define SN_X500 "X500" +#define LN_X500 "directory services (X.500)" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define SN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_surname "SN" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define LN_streetAddress "streetAddress" +#define NID_streetAddress 660 +#define OBJ_streetAddress OBJ_X509,9L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +#define LN_postalCode "postalCode" +#define NID_postalCode 661 +#define OBJ_postalCode OBJ_X509,17L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_givenName "GN" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define LN_generationQualifier "generationQualifier" +#define NID_generationQualifier 509 +#define OBJ_generationQualifier OBJ_X509,44L + +#define LN_x500UniqueIdentifier "x500UniqueIdentifier" +#define NID_x500UniqueIdentifier 503 +#define OBJ_x500UniqueIdentifier OBJ_X509,45L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define LN_pseudonym "pseudonym" +#define NID_pseudonym 510 +#define OBJ_pseudonym OBJ_X509,65L + +#define SN_role "role" +#define LN_role "role" +#define NID_role 400 +#define OBJ_role OBJ_X509,72L + +#define SN_X500algorithms "X500algorithms" +#define LN_X500algorithms "directory services - algorithms" +#define NID_X500algorithms 378 +#define OBJ_X500algorithms OBJ_X500,8L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500algorithms,1L,1L + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2WithRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 OBJ_X500algorithms,3L,101L + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce OBJ_X500,29L + +#define SN_subject_directory_attributes "subjectDirectoryAttributes" +#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" +#define NID_subject_directory_attributes 769 +#define OBJ_subject_directory_attributes OBJ_id_ce,9L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "X509v3 CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_issuing_distribution_point "issuingDistributionPoint" +#define LN_issuing_distribution_point "X509v3 Issuing Distrubution Point" +#define NID_issuing_distribution_point 770 +#define OBJ_issuing_distribution_point OBJ_id_ce,28L + +#define SN_certificate_issuer "certificateIssuer" +#define LN_certificate_issuer "X509v3 Certificate Issuer" +#define NID_certificate_issuer 771 +#define OBJ_certificate_issuer OBJ_id_ce,29L + +#define SN_name_constraints "nameConstraints" +#define LN_name_constraints "X509v3 Name Constraints" +#define NID_name_constraints 666 +#define OBJ_name_constraints OBJ_id_ce,30L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_any_policy "anyPolicy" +#define LN_any_policy "X509v3 Any Policy" +#define NID_any_policy 746 +#define OBJ_any_policy OBJ_certificate_policies,0L + +#define SN_policy_mappings "policyMappings" +#define LN_policy_mappings "X509v3 Policy Mappings" +#define NID_policy_mappings 747 +#define OBJ_policy_mappings OBJ_id_ce,33L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_policy_constraints "policyConstraints" +#define LN_policy_constraints "X509v3 Policy Constraints" +#define NID_policy_constraints 401 +#define OBJ_policy_constraints OBJ_id_ce,36L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37L + +#define SN_inhibit_any_policy "inhibitAnyPolicy" +#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" +#define NID_inhibit_any_policy 748 +#define OBJ_inhibit_any_policy OBJ_id_ce,54L + +#define SN_target_information "targetInformation" +#define LN_target_information "X509v3 AC Targeting" +#define NID_target_information 402 +#define OBJ_target_information OBJ_id_ce,55L + +#define SN_no_rev_avail "noRevAvail" +#define LN_no_rev_avail "X509v3 No Revocation Available" +#define NID_no_rev_avail 403 +#define OBJ_no_rev_avail OBJ_id_ce,56L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_org "ORG" +#define LN_org "org" +#define NID_org 379 +#define OBJ_org OBJ_iso,3L + +#define SN_dod "DOD" +#define LN_dod "dod" +#define NID_dod 380 +#define OBJ_dod OBJ_org,6L + +#define SN_iana "IANA" +#define LN_iana "iana" +#define NID_iana 381 +#define OBJ_iana OBJ_dod,1L + +#define OBJ_internet OBJ_iana + +#define SN_Directory "directory" +#define LN_Directory "Directory" +#define NID_Directory 382 +#define OBJ_Directory OBJ_internet,1L + +#define SN_Management "mgmt" +#define LN_Management "Management" +#define NID_Management 383 +#define OBJ_Management OBJ_internet,2L + +#define SN_Experimental "experimental" +#define LN_Experimental "Experimental" +#define NID_Experimental 384 +#define OBJ_Experimental OBJ_internet,3L + +#define SN_Private "private" +#define LN_Private "Private" +#define NID_Private 385 +#define OBJ_Private OBJ_internet,4L + +#define SN_Security "security" +#define LN_Security "Security" +#define NID_Security 386 +#define OBJ_Security OBJ_internet,5L + +#define SN_SNMPv2 "snmpv2" +#define LN_SNMPv2 "SNMPv2" +#define NID_SNMPv2 387 +#define OBJ_SNMPv2 OBJ_internet,6L + +#define LN_Mail "Mail" +#define NID_Mail 388 +#define OBJ_Mail OBJ_internet,7L + +#define SN_Enterprises "enterprises" +#define LN_Enterprises "Enterprises" +#define NID_Enterprises 389 +#define OBJ_Enterprises OBJ_Private,1L + +#define SN_dcObject "dcobject" +#define LN_dcObject "dcObject" +#define NID_dcObject 390 +#define OBJ_dcObject OBJ_Enterprises,1466L,344L + +#define SN_mime_mhs "mime-mhs" +#define LN_mime_mhs "MIME MHS" +#define NID_mime_mhs 504 +#define OBJ_mime_mhs OBJ_Mail,1L + +#define SN_mime_mhs_headings "mime-mhs-headings" +#define LN_mime_mhs_headings "mime-mhs-headings" +#define NID_mime_mhs_headings 505 +#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L + +#define SN_mime_mhs_bodies "mime-mhs-bodies" +#define LN_mime_mhs_bodies "mime-mhs-bodies" +#define NID_mime_mhs_bodies 506 +#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L + +#define SN_id_hex_partial_message "id-hex-partial-message" +#define LN_id_hex_partial_message "id-hex-partial-message" +#define NID_id_hex_partial_message 507 +#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L + +#define SN_id_hex_multipart_message "id-hex-multipart-message" +#define LN_id_hex_multipart_message "id-hex-multipart-message" +#define NID_id_hex_multipart_message 508 +#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define OBJ_csor 2L,16L,840L,1L,101L,3L + +#define OBJ_nistAlgorithms OBJ_csor,4L + +#define OBJ_aes OBJ_nistAlgorithms,1L + +#define SN_aes_128_ecb "AES-128-ECB" +#define LN_aes_128_ecb "aes-128-ecb" +#define NID_aes_128_ecb 418 +#define OBJ_aes_128_ecb OBJ_aes,1L + +#define SN_aes_128_cbc "AES-128-CBC" +#define LN_aes_128_cbc "aes-128-cbc" +#define NID_aes_128_cbc 419 +#define OBJ_aes_128_cbc OBJ_aes,2L + +#define SN_aes_128_ofb128 "AES-128-OFB" +#define LN_aes_128_ofb128 "aes-128-ofb" +#define NID_aes_128_ofb128 420 +#define OBJ_aes_128_ofb128 OBJ_aes,3L + +#define SN_aes_128_cfb128 "AES-128-CFB" +#define LN_aes_128_cfb128 "aes-128-cfb" +#define NID_aes_128_cfb128 421 +#define OBJ_aes_128_cfb128 OBJ_aes,4L + +#define SN_aes_192_ecb "AES-192-ECB" +#define LN_aes_192_ecb "aes-192-ecb" +#define NID_aes_192_ecb 422 +#define OBJ_aes_192_ecb OBJ_aes,21L + +#define SN_aes_192_cbc "AES-192-CBC" +#define LN_aes_192_cbc "aes-192-cbc" +#define NID_aes_192_cbc 423 +#define OBJ_aes_192_cbc OBJ_aes,22L + +#define SN_aes_192_ofb128 "AES-192-OFB" +#define LN_aes_192_ofb128 "aes-192-ofb" +#define NID_aes_192_ofb128 424 +#define OBJ_aes_192_ofb128 OBJ_aes,23L + +#define SN_aes_192_cfb128 "AES-192-CFB" +#define LN_aes_192_cfb128 "aes-192-cfb" +#define NID_aes_192_cfb128 425 +#define OBJ_aes_192_cfb128 OBJ_aes,24L + +#define SN_aes_256_ecb "AES-256-ECB" +#define LN_aes_256_ecb "aes-256-ecb" +#define NID_aes_256_ecb 426 +#define OBJ_aes_256_ecb OBJ_aes,41L + +#define SN_aes_256_cbc "AES-256-CBC" +#define LN_aes_256_cbc "aes-256-cbc" +#define NID_aes_256_cbc 427 +#define OBJ_aes_256_cbc OBJ_aes,42L + +#define SN_aes_256_ofb128 "AES-256-OFB" +#define LN_aes_256_ofb128 "aes-256-ofb" +#define NID_aes_256_ofb128 428 +#define OBJ_aes_256_ofb128 OBJ_aes,43L + +#define SN_aes_256_cfb128 "AES-256-CFB" +#define LN_aes_256_cfb128 "aes-256-cfb" +#define NID_aes_256_cfb128 429 +#define OBJ_aes_256_cfb128 OBJ_aes,44L + +#define SN_aes_128_cfb1 "AES-128-CFB1" +#define LN_aes_128_cfb1 "aes-128-cfb1" +#define NID_aes_128_cfb1 650 + +#define SN_aes_192_cfb1 "AES-192-CFB1" +#define LN_aes_192_cfb1 "aes-192-cfb1" +#define NID_aes_192_cfb1 651 + +#define SN_aes_256_cfb1 "AES-256-CFB1" +#define LN_aes_256_cfb1 "aes-256-cfb1" +#define NID_aes_256_cfb1 652 + +#define SN_aes_128_cfb8 "AES-128-CFB8" +#define LN_aes_128_cfb8 "aes-128-cfb8" +#define NID_aes_128_cfb8 653 + +#define SN_aes_192_cfb8 "AES-192-CFB8" +#define LN_aes_192_cfb8 "aes-192-cfb8" +#define NID_aes_192_cfb8 654 + +#define SN_aes_256_cfb8 "AES-256-CFB8" +#define LN_aes_256_cfb8 "aes-256-cfb8" +#define NID_aes_256_cfb8 655 + +#define SN_des_cfb1 "DES-CFB1" +#define LN_des_cfb1 "des-cfb1" +#define NID_des_cfb1 656 + +#define SN_des_cfb8 "DES-CFB8" +#define LN_des_cfb8 "des-cfb8" +#define NID_des_cfb8 657 + +#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" +#define LN_des_ede3_cfb1 "des-ede3-cfb1" +#define NID_des_ede3_cfb1 658 + +#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" +#define LN_des_ede3_cfb8 "des-ede3-cfb8" +#define NID_des_ede3_cfb8 659 + +#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L + +#define SN_sha256 "SHA256" +#define LN_sha256 "sha256" +#define NID_sha256 672 +#define OBJ_sha256 OBJ_nist_hashalgs,1L + +#define SN_sha384 "SHA384" +#define LN_sha384 "sha384" +#define NID_sha384 673 +#define OBJ_sha384 OBJ_nist_hashalgs,2L + +#define SN_sha512 "SHA512" +#define LN_sha512 "sha512" +#define NID_sha512 674 +#define OBJ_sha512 OBJ_nist_hashalgs,3L + +#define SN_sha224 "SHA224" +#define LN_sha224 "sha224" +#define NID_sha224 675 +#define OBJ_sha224 OBJ_nist_hashalgs,4L + +#define SN_hold_instruction_code "holdInstructionCode" +#define LN_hold_instruction_code "Hold Instruction Code" +#define NID_hold_instruction_code 430 +#define OBJ_hold_instruction_code OBJ_id_ce,23L + +#define OBJ_holdInstruction OBJ_X9_57,2L + +#define SN_hold_instruction_none "holdInstructionNone" +#define LN_hold_instruction_none "Hold Instruction None" +#define NID_hold_instruction_none 431 +#define OBJ_hold_instruction_none OBJ_holdInstruction,1L + +#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" +#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" +#define NID_hold_instruction_call_issuer 432 +#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L + +#define SN_hold_instruction_reject "holdInstructionReject" +#define LN_hold_instruction_reject "Hold Instruction Reject" +#define NID_hold_instruction_reject 433 +#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L + +#define SN_data "data" +#define NID_data 434 +#define OBJ_data OBJ_itu_t,9L + +#define SN_pss "pss" +#define NID_pss 435 +#define OBJ_pss OBJ_data,2342L + +#define SN_ucl "ucl" +#define NID_ucl 436 +#define OBJ_ucl OBJ_pss,19200300L + +#define SN_pilot "pilot" +#define NID_pilot 437 +#define OBJ_pilot OBJ_ucl,100L + +#define LN_pilotAttributeType "pilotAttributeType" +#define NID_pilotAttributeType 438 +#define OBJ_pilotAttributeType OBJ_pilot,1L + +#define LN_pilotAttributeSyntax "pilotAttributeSyntax" +#define NID_pilotAttributeSyntax 439 +#define OBJ_pilotAttributeSyntax OBJ_pilot,3L + +#define LN_pilotObjectClass "pilotObjectClass" +#define NID_pilotObjectClass 440 +#define OBJ_pilotObjectClass OBJ_pilot,4L + +#define LN_pilotGroups "pilotGroups" +#define NID_pilotGroups 441 +#define OBJ_pilotGroups OBJ_pilot,10L + +#define LN_iA5StringSyntax "iA5StringSyntax" +#define NID_iA5StringSyntax 442 +#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L + +#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" +#define NID_caseIgnoreIA5StringSyntax 443 +#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L + +#define LN_pilotObject "pilotObject" +#define NID_pilotObject 444 +#define OBJ_pilotObject OBJ_pilotObjectClass,3L + +#define LN_pilotPerson "pilotPerson" +#define NID_pilotPerson 445 +#define OBJ_pilotPerson OBJ_pilotObjectClass,4L + +#define SN_account "account" +#define NID_account 446 +#define OBJ_account OBJ_pilotObjectClass,5L + +#define SN_document "document" +#define NID_document 447 +#define OBJ_document OBJ_pilotObjectClass,6L + +#define SN_room "room" +#define NID_room 448 +#define OBJ_room OBJ_pilotObjectClass,7L + +#define LN_documentSeries "documentSeries" +#define NID_documentSeries 449 +#define OBJ_documentSeries OBJ_pilotObjectClass,9L + +#define SN_Domain "domain" +#define LN_Domain "Domain" +#define NID_Domain 392 +#define OBJ_Domain OBJ_pilotObjectClass,13L + +#define LN_rFC822localPart "rFC822localPart" +#define NID_rFC822localPart 450 +#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L + +#define LN_dNSDomain "dNSDomain" +#define NID_dNSDomain 451 +#define OBJ_dNSDomain OBJ_pilotObjectClass,15L + +#define LN_domainRelatedObject "domainRelatedObject" +#define NID_domainRelatedObject 452 +#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L + +#define LN_friendlyCountry "friendlyCountry" +#define NID_friendlyCountry 453 +#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L + +#define LN_simpleSecurityObject "simpleSecurityObject" +#define NID_simpleSecurityObject 454 +#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L + +#define LN_pilotOrganization "pilotOrganization" +#define NID_pilotOrganization 455 +#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L + +#define LN_pilotDSA "pilotDSA" +#define NID_pilotDSA 456 +#define OBJ_pilotDSA OBJ_pilotObjectClass,21L + +#define LN_qualityLabelledData "qualityLabelledData" +#define NID_qualityLabelledData 457 +#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L + +#define SN_userId "UID" +#define LN_userId "userId" +#define NID_userId 458 +#define OBJ_userId OBJ_pilotAttributeType,1L + +#define LN_textEncodedORAddress "textEncodedORAddress" +#define NID_textEncodedORAddress 459 +#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L + +#define SN_rfc822Mailbox "mail" +#define LN_rfc822Mailbox "rfc822Mailbox" +#define NID_rfc822Mailbox 460 +#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L + +#define SN_info "info" +#define NID_info 461 +#define OBJ_info OBJ_pilotAttributeType,4L + +#define LN_favouriteDrink "favouriteDrink" +#define NID_favouriteDrink 462 +#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L + +#define LN_roomNumber "roomNumber" +#define NID_roomNumber 463 +#define OBJ_roomNumber OBJ_pilotAttributeType,6L + +#define SN_photo "photo" +#define NID_photo 464 +#define OBJ_photo OBJ_pilotAttributeType,7L + +#define LN_userClass "userClass" +#define NID_userClass 465 +#define OBJ_userClass OBJ_pilotAttributeType,8L + +#define SN_host "host" +#define NID_host 466 +#define OBJ_host OBJ_pilotAttributeType,9L + +#define SN_manager "manager" +#define NID_manager 467 +#define OBJ_manager OBJ_pilotAttributeType,10L + +#define LN_documentIdentifier "documentIdentifier" +#define NID_documentIdentifier 468 +#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L + +#define LN_documentTitle "documentTitle" +#define NID_documentTitle 469 +#define OBJ_documentTitle OBJ_pilotAttributeType,12L + +#define LN_documentVersion "documentVersion" +#define NID_documentVersion 470 +#define OBJ_documentVersion OBJ_pilotAttributeType,13L + +#define LN_documentAuthor "documentAuthor" +#define NID_documentAuthor 471 +#define OBJ_documentAuthor OBJ_pilotAttributeType,14L + +#define LN_documentLocation "documentLocation" +#define NID_documentLocation 472 +#define OBJ_documentLocation OBJ_pilotAttributeType,15L + +#define LN_homeTelephoneNumber "homeTelephoneNumber" +#define NID_homeTelephoneNumber 473 +#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L + +#define SN_secretary "secretary" +#define NID_secretary 474 +#define OBJ_secretary OBJ_pilotAttributeType,21L + +#define LN_otherMailbox "otherMailbox" +#define NID_otherMailbox 475 +#define OBJ_otherMailbox OBJ_pilotAttributeType,22L + +#define LN_lastModifiedTime "lastModifiedTime" +#define NID_lastModifiedTime 476 +#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L + +#define LN_lastModifiedBy "lastModifiedBy" +#define NID_lastModifiedBy 477 +#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L + +#define SN_domainComponent "DC" +#define LN_domainComponent "domainComponent" +#define NID_domainComponent 391 +#define OBJ_domainComponent OBJ_pilotAttributeType,25L + +#define LN_aRecord "aRecord" +#define NID_aRecord 478 +#define OBJ_aRecord OBJ_pilotAttributeType,26L + +#define LN_pilotAttributeType27 "pilotAttributeType27" +#define NID_pilotAttributeType27 479 +#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L + +#define LN_mXRecord "mXRecord" +#define NID_mXRecord 480 +#define OBJ_mXRecord OBJ_pilotAttributeType,28L + +#define LN_nSRecord "nSRecord" +#define NID_nSRecord 481 +#define OBJ_nSRecord OBJ_pilotAttributeType,29L + +#define LN_sOARecord "sOARecord" +#define NID_sOARecord 482 +#define OBJ_sOARecord OBJ_pilotAttributeType,30L + +#define LN_cNAMERecord "cNAMERecord" +#define NID_cNAMERecord 483 +#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L + +#define LN_associatedDomain "associatedDomain" +#define NID_associatedDomain 484 +#define OBJ_associatedDomain OBJ_pilotAttributeType,37L + +#define LN_associatedName "associatedName" +#define NID_associatedName 485 +#define OBJ_associatedName OBJ_pilotAttributeType,38L + +#define LN_homePostalAddress "homePostalAddress" +#define NID_homePostalAddress 486 +#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L + +#define LN_personalTitle "personalTitle" +#define NID_personalTitle 487 +#define OBJ_personalTitle OBJ_pilotAttributeType,40L + +#define LN_mobileTelephoneNumber "mobileTelephoneNumber" +#define NID_mobileTelephoneNumber 488 +#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L + +#define LN_pagerTelephoneNumber "pagerTelephoneNumber" +#define NID_pagerTelephoneNumber 489 +#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L + +#define LN_friendlyCountryName "friendlyCountryName" +#define NID_friendlyCountryName 490 +#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L + +#define LN_organizationalStatus "organizationalStatus" +#define NID_organizationalStatus 491 +#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L + +#define LN_janetMailbox "janetMailbox" +#define NID_janetMailbox 492 +#define OBJ_janetMailbox OBJ_pilotAttributeType,46L + +#define LN_mailPreferenceOption "mailPreferenceOption" +#define NID_mailPreferenceOption 493 +#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L + +#define LN_buildingName "buildingName" +#define NID_buildingName 494 +#define OBJ_buildingName OBJ_pilotAttributeType,48L + +#define LN_dSAQuality "dSAQuality" +#define NID_dSAQuality 495 +#define OBJ_dSAQuality OBJ_pilotAttributeType,49L + +#define LN_singleLevelQuality "singleLevelQuality" +#define NID_singleLevelQuality 496 +#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L + +#define LN_subtreeMinimumQuality "subtreeMinimumQuality" +#define NID_subtreeMinimumQuality 497 +#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L + +#define LN_subtreeMaximumQuality "subtreeMaximumQuality" +#define NID_subtreeMaximumQuality 498 +#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L + +#define LN_personalSignature "personalSignature" +#define NID_personalSignature 499 +#define OBJ_personalSignature OBJ_pilotAttributeType,53L + +#define LN_dITRedirect "dITRedirect" +#define NID_dITRedirect 500 +#define OBJ_dITRedirect OBJ_pilotAttributeType,54L + +#define SN_audio "audio" +#define NID_audio 501 +#define OBJ_audio OBJ_pilotAttributeType,55L + +#define LN_documentPublisher "documentPublisher" +#define NID_documentPublisher 502 +#define OBJ_documentPublisher OBJ_pilotAttributeType,56L + +#define SN_id_set "id-set" +#define LN_id_set "Secure Electronic Transactions" +#define NID_id_set 512 +#define OBJ_id_set OBJ_international_organizations,42L + +#define SN_set_ctype "set-ctype" +#define LN_set_ctype "content types" +#define NID_set_ctype 513 +#define OBJ_set_ctype OBJ_id_set,0L + +#define SN_set_msgExt "set-msgExt" +#define LN_set_msgExt "message extensions" +#define NID_set_msgExt 514 +#define OBJ_set_msgExt OBJ_id_set,1L + +#define SN_set_attr "set-attr" +#define NID_set_attr 515 +#define OBJ_set_attr OBJ_id_set,3L + +#define SN_set_policy "set-policy" +#define NID_set_policy 516 +#define OBJ_set_policy OBJ_id_set,5L + +#define SN_set_certExt "set-certExt" +#define LN_set_certExt "certificate extensions" +#define NID_set_certExt 517 +#define OBJ_set_certExt OBJ_id_set,7L + +#define SN_set_brand "set-brand" +#define NID_set_brand 518 +#define OBJ_set_brand OBJ_id_set,8L + +#define SN_setct_PANData "setct-PANData" +#define NID_setct_PANData 519 +#define OBJ_setct_PANData OBJ_set_ctype,0L + +#define SN_setct_PANToken "setct-PANToken" +#define NID_setct_PANToken 520 +#define OBJ_setct_PANToken OBJ_set_ctype,1L + +#define SN_setct_PANOnly "setct-PANOnly" +#define NID_setct_PANOnly 521 +#define OBJ_setct_PANOnly OBJ_set_ctype,2L + +#define SN_setct_OIData "setct-OIData" +#define NID_setct_OIData 522 +#define OBJ_setct_OIData OBJ_set_ctype,3L + +#define SN_setct_PI "setct-PI" +#define NID_setct_PI 523 +#define OBJ_setct_PI OBJ_set_ctype,4L + +#define SN_setct_PIData "setct-PIData" +#define NID_setct_PIData 524 +#define OBJ_setct_PIData OBJ_set_ctype,5L + +#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" +#define NID_setct_PIDataUnsigned 525 +#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L + +#define SN_setct_HODInput "setct-HODInput" +#define NID_setct_HODInput 526 +#define OBJ_setct_HODInput OBJ_set_ctype,7L + +#define SN_setct_AuthResBaggage "setct-AuthResBaggage" +#define NID_setct_AuthResBaggage 527 +#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L + +#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" +#define NID_setct_AuthRevReqBaggage 528 +#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L + +#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" +#define NID_setct_AuthRevResBaggage 529 +#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L + +#define SN_setct_CapTokenSeq "setct-CapTokenSeq" +#define NID_setct_CapTokenSeq 530 +#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L + +#define SN_setct_PInitResData "setct-PInitResData" +#define NID_setct_PInitResData 531 +#define OBJ_setct_PInitResData OBJ_set_ctype,12L + +#define SN_setct_PI_TBS "setct-PI-TBS" +#define NID_setct_PI_TBS 532 +#define OBJ_setct_PI_TBS OBJ_set_ctype,13L + +#define SN_setct_PResData "setct-PResData" +#define NID_setct_PResData 533 +#define OBJ_setct_PResData OBJ_set_ctype,14L + +#define SN_setct_AuthReqTBS "setct-AuthReqTBS" +#define NID_setct_AuthReqTBS 534 +#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L + +#define SN_setct_AuthResTBS "setct-AuthResTBS" +#define NID_setct_AuthResTBS 535 +#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L + +#define SN_setct_AuthResTBSX "setct-AuthResTBSX" +#define NID_setct_AuthResTBSX 536 +#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L + +#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" +#define NID_setct_AuthTokenTBS 537 +#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L + +#define SN_setct_CapTokenData "setct-CapTokenData" +#define NID_setct_CapTokenData 538 +#define OBJ_setct_CapTokenData OBJ_set_ctype,20L + +#define SN_setct_CapTokenTBS "setct-CapTokenTBS" +#define NID_setct_CapTokenTBS 539 +#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L + +#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" +#define NID_setct_AcqCardCodeMsg 540 +#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L + +#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" +#define NID_setct_AuthRevReqTBS 541 +#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L + +#define SN_setct_AuthRevResData "setct-AuthRevResData" +#define NID_setct_AuthRevResData 542 +#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L + +#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" +#define NID_setct_AuthRevResTBS 543 +#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L + +#define SN_setct_CapReqTBS "setct-CapReqTBS" +#define NID_setct_CapReqTBS 544 +#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L + +#define SN_setct_CapReqTBSX "setct-CapReqTBSX" +#define NID_setct_CapReqTBSX 545 +#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L + +#define SN_setct_CapResData "setct-CapResData" +#define NID_setct_CapResData 546 +#define OBJ_setct_CapResData OBJ_set_ctype,28L + +#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" +#define NID_setct_CapRevReqTBS 547 +#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L + +#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" +#define NID_setct_CapRevReqTBSX 548 +#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L + +#define SN_setct_CapRevResData "setct-CapRevResData" +#define NID_setct_CapRevResData 549 +#define OBJ_setct_CapRevResData OBJ_set_ctype,31L + +#define SN_setct_CredReqTBS "setct-CredReqTBS" +#define NID_setct_CredReqTBS 550 +#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L + +#define SN_setct_CredReqTBSX "setct-CredReqTBSX" +#define NID_setct_CredReqTBSX 551 +#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L + +#define SN_setct_CredResData "setct-CredResData" +#define NID_setct_CredResData 552 +#define OBJ_setct_CredResData OBJ_set_ctype,34L + +#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" +#define NID_setct_CredRevReqTBS 553 +#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L + +#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" +#define NID_setct_CredRevReqTBSX 554 +#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L + +#define SN_setct_CredRevResData "setct-CredRevResData" +#define NID_setct_CredRevResData 555 +#define OBJ_setct_CredRevResData OBJ_set_ctype,37L + +#define SN_setct_PCertReqData "setct-PCertReqData" +#define NID_setct_PCertReqData 556 +#define OBJ_setct_PCertReqData OBJ_set_ctype,38L + +#define SN_setct_PCertResTBS "setct-PCertResTBS" +#define NID_setct_PCertResTBS 557 +#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L + +#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" +#define NID_setct_BatchAdminReqData 558 +#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L + +#define SN_setct_BatchAdminResData "setct-BatchAdminResData" +#define NID_setct_BatchAdminResData 559 +#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L + +#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" +#define NID_setct_CardCInitResTBS 560 +#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L + +#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" +#define NID_setct_MeAqCInitResTBS 561 +#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L + +#define SN_setct_RegFormResTBS "setct-RegFormResTBS" +#define NID_setct_RegFormResTBS 562 +#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L + +#define SN_setct_CertReqData "setct-CertReqData" +#define NID_setct_CertReqData 563 +#define OBJ_setct_CertReqData OBJ_set_ctype,45L + +#define SN_setct_CertReqTBS "setct-CertReqTBS" +#define NID_setct_CertReqTBS 564 +#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L + +#define SN_setct_CertResData "setct-CertResData" +#define NID_setct_CertResData 565 +#define OBJ_setct_CertResData OBJ_set_ctype,47L + +#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" +#define NID_setct_CertInqReqTBS 566 +#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L + +#define SN_setct_ErrorTBS "setct-ErrorTBS" +#define NID_setct_ErrorTBS 567 +#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L + +#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" +#define NID_setct_PIDualSignedTBE 568 +#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L + +#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" +#define NID_setct_PIUnsignedTBE 569 +#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L + +#define SN_setct_AuthReqTBE "setct-AuthReqTBE" +#define NID_setct_AuthReqTBE 570 +#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L + +#define SN_setct_AuthResTBE "setct-AuthResTBE" +#define NID_setct_AuthResTBE 571 +#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L + +#define SN_setct_AuthResTBEX "setct-AuthResTBEX" +#define NID_setct_AuthResTBEX 572 +#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L + +#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" +#define NID_setct_AuthTokenTBE 573 +#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L + +#define SN_setct_CapTokenTBE "setct-CapTokenTBE" +#define NID_setct_CapTokenTBE 574 +#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L + +#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" +#define NID_setct_CapTokenTBEX 575 +#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L + +#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" +#define NID_setct_AcqCardCodeMsgTBE 576 +#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L + +#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" +#define NID_setct_AuthRevReqTBE 577 +#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L + +#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" +#define NID_setct_AuthRevResTBE 578 +#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L + +#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" +#define NID_setct_AuthRevResTBEB 579 +#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L + +#define SN_setct_CapReqTBE "setct-CapReqTBE" +#define NID_setct_CapReqTBE 580 +#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L + +#define SN_setct_CapReqTBEX "setct-CapReqTBEX" +#define NID_setct_CapReqTBEX 581 +#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L + +#define SN_setct_CapResTBE "setct-CapResTBE" +#define NID_setct_CapResTBE 582 +#define OBJ_setct_CapResTBE OBJ_set_ctype,64L + +#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" +#define NID_setct_CapRevReqTBE 583 +#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L + +#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" +#define NID_setct_CapRevReqTBEX 584 +#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L + +#define SN_setct_CapRevResTBE "setct-CapRevResTBE" +#define NID_setct_CapRevResTBE 585 +#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L + +#define SN_setct_CredReqTBE "setct-CredReqTBE" +#define NID_setct_CredReqTBE 586 +#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L + +#define SN_setct_CredReqTBEX "setct-CredReqTBEX" +#define NID_setct_CredReqTBEX 587 +#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L + +#define SN_setct_CredResTBE "setct-CredResTBE" +#define NID_setct_CredResTBE 588 +#define OBJ_setct_CredResTBE OBJ_set_ctype,70L + +#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" +#define NID_setct_CredRevReqTBE 589 +#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L + +#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" +#define NID_setct_CredRevReqTBEX 590 +#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L + +#define SN_setct_CredRevResTBE "setct-CredRevResTBE" +#define NID_setct_CredRevResTBE 591 +#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L + +#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" +#define NID_setct_BatchAdminReqTBE 592 +#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L + +#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" +#define NID_setct_BatchAdminResTBE 593 +#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L + +#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" +#define NID_setct_RegFormReqTBE 594 +#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L + +#define SN_setct_CertReqTBE "setct-CertReqTBE" +#define NID_setct_CertReqTBE 595 +#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L + +#define SN_setct_CertReqTBEX "setct-CertReqTBEX" +#define NID_setct_CertReqTBEX 596 +#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L + +#define SN_setct_CertResTBE "setct-CertResTBE" +#define NID_setct_CertResTBE 597 +#define OBJ_setct_CertResTBE OBJ_set_ctype,79L + +#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" +#define NID_setct_CRLNotificationTBS 598 +#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L + +#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" +#define NID_setct_CRLNotificationResTBS 599 +#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L + +#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" +#define NID_setct_BCIDistributionTBS 600 +#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L + +#define SN_setext_genCrypt "setext-genCrypt" +#define LN_setext_genCrypt "generic cryptogram" +#define NID_setext_genCrypt 601 +#define OBJ_setext_genCrypt OBJ_set_msgExt,1L + +#define SN_setext_miAuth "setext-miAuth" +#define LN_setext_miAuth "merchant initiated auth" +#define NID_setext_miAuth 602 +#define OBJ_setext_miAuth OBJ_set_msgExt,3L + +#define SN_setext_pinSecure "setext-pinSecure" +#define NID_setext_pinSecure 603 +#define OBJ_setext_pinSecure OBJ_set_msgExt,4L + +#define SN_setext_pinAny "setext-pinAny" +#define NID_setext_pinAny 604 +#define OBJ_setext_pinAny OBJ_set_msgExt,5L + +#define SN_setext_track2 "setext-track2" +#define NID_setext_track2 605 +#define OBJ_setext_track2 OBJ_set_msgExt,7L + +#define SN_setext_cv "setext-cv" +#define LN_setext_cv "additional verification" +#define NID_setext_cv 606 +#define OBJ_setext_cv OBJ_set_msgExt,8L + +#define SN_set_policy_root "set-policy-root" +#define NID_set_policy_root 607 +#define OBJ_set_policy_root OBJ_set_policy,0L + +#define SN_setCext_hashedRoot "setCext-hashedRoot" +#define NID_setCext_hashedRoot 608 +#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L + +#define SN_setCext_certType "setCext-certType" +#define NID_setCext_certType 609 +#define OBJ_setCext_certType OBJ_set_certExt,1L + +#define SN_setCext_merchData "setCext-merchData" +#define NID_setCext_merchData 610 +#define OBJ_setCext_merchData OBJ_set_certExt,2L + +#define SN_setCext_cCertRequired "setCext-cCertRequired" +#define NID_setCext_cCertRequired 611 +#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L + +#define SN_setCext_tunneling "setCext-tunneling" +#define NID_setCext_tunneling 612 +#define OBJ_setCext_tunneling OBJ_set_certExt,4L + +#define SN_setCext_setExt "setCext-setExt" +#define NID_setCext_setExt 613 +#define OBJ_setCext_setExt OBJ_set_certExt,5L + +#define SN_setCext_setQualf "setCext-setQualf" +#define NID_setCext_setQualf 614 +#define OBJ_setCext_setQualf OBJ_set_certExt,6L + +#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" +#define NID_setCext_PGWYcapabilities 615 +#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L + +#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" +#define NID_setCext_TokenIdentifier 616 +#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L + +#define SN_setCext_Track2Data "setCext-Track2Data" +#define NID_setCext_Track2Data 617 +#define OBJ_setCext_Track2Data OBJ_set_certExt,9L + +#define SN_setCext_TokenType "setCext-TokenType" +#define NID_setCext_TokenType 618 +#define OBJ_setCext_TokenType OBJ_set_certExt,10L + +#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" +#define NID_setCext_IssuerCapabilities 619 +#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L + +#define SN_setAttr_Cert "setAttr-Cert" +#define NID_setAttr_Cert 620 +#define OBJ_setAttr_Cert OBJ_set_attr,0L + +#define SN_setAttr_PGWYcap "setAttr-PGWYcap" +#define LN_setAttr_PGWYcap "payment gateway capabilities" +#define NID_setAttr_PGWYcap 621 +#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L + +#define SN_setAttr_TokenType "setAttr-TokenType" +#define NID_setAttr_TokenType 622 +#define OBJ_setAttr_TokenType OBJ_set_attr,2L + +#define SN_setAttr_IssCap "setAttr-IssCap" +#define LN_setAttr_IssCap "issuer capabilities" +#define NID_setAttr_IssCap 623 +#define OBJ_setAttr_IssCap OBJ_set_attr,3L + +#define SN_set_rootKeyThumb "set-rootKeyThumb" +#define NID_set_rootKeyThumb 624 +#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L + +#define SN_set_addPolicy "set-addPolicy" +#define NID_set_addPolicy 625 +#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L + +#define SN_setAttr_Token_EMV "setAttr-Token-EMV" +#define NID_setAttr_Token_EMV 626 +#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L + +#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" +#define NID_setAttr_Token_B0Prime 627 +#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L + +#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" +#define NID_setAttr_IssCap_CVM 628 +#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L + +#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" +#define NID_setAttr_IssCap_T2 629 +#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L + +#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" +#define NID_setAttr_IssCap_Sig 630 +#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L + +#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" +#define LN_setAttr_GenCryptgrm "generate cryptogram" +#define NID_setAttr_GenCryptgrm 631 +#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L + +#define SN_setAttr_T2Enc "setAttr-T2Enc" +#define LN_setAttr_T2Enc "encrypted track 2" +#define NID_setAttr_T2Enc 632 +#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L + +#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" +#define LN_setAttr_T2cleartxt "cleartext track 2" +#define NID_setAttr_T2cleartxt 633 +#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L + +#define SN_setAttr_TokICCsig "setAttr-TokICCsig" +#define LN_setAttr_TokICCsig "ICC or token signature" +#define NID_setAttr_TokICCsig 634 +#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L + +#define SN_setAttr_SecDevSig "setAttr-SecDevSig" +#define LN_setAttr_SecDevSig "secure device signature" +#define NID_setAttr_SecDevSig 635 +#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L + +#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" +#define NID_set_brand_IATA_ATA 636 +#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L + +#define SN_set_brand_Diners "set-brand-Diners" +#define NID_set_brand_Diners 637 +#define OBJ_set_brand_Diners OBJ_set_brand,30L + +#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" +#define NID_set_brand_AmericanExpress 638 +#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L + +#define SN_set_brand_JCB "set-brand-JCB" +#define NID_set_brand_JCB 639 +#define OBJ_set_brand_JCB OBJ_set_brand,35L + +#define SN_set_brand_Visa "set-brand-Visa" +#define NID_set_brand_Visa 640 +#define OBJ_set_brand_Visa OBJ_set_brand,4L + +#define SN_set_brand_MasterCard "set-brand-MasterCard" +#define NID_set_brand_MasterCard 641 +#define OBJ_set_brand_MasterCard OBJ_set_brand,5L + +#define SN_set_brand_Novus "set-brand-Novus" +#define NID_set_brand_Novus 642 +#define OBJ_set_brand_Novus OBJ_set_brand,6011L + +#define SN_des_cdmf "DES-CDMF" +#define LN_des_cdmf "des-cdmf" +#define NID_des_cdmf 643 +#define OBJ_des_cdmf OBJ_rsadsi,3L,10L + +#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" +#define NID_rsaOAEPEncryptionSET 644 +#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L + +#define SN_ipsec3 "Oakley-EC2N-3" +#define LN_ipsec3 "ipsec3" +#define NID_ipsec3 749 + +#define SN_ipsec4 "Oakley-EC2N-4" +#define LN_ipsec4 "ipsec4" +#define NID_ipsec4 750 + +#define SN_camellia_128_cbc "CAMELLIA-128-CBC" +#define LN_camellia_128_cbc "camellia-128-cbc" +#define NID_camellia_128_cbc 751 +#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L + +#define SN_camellia_192_cbc "CAMELLIA-192-CBC" +#define LN_camellia_192_cbc "camellia-192-cbc" +#define NID_camellia_192_cbc 752 +#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L + +#define SN_camellia_256_cbc "CAMELLIA-256-CBC" +#define LN_camellia_256_cbc "camellia-256-cbc" +#define NID_camellia_256_cbc 753 +#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L + +#define OBJ_ntt_ds 0L,3L,4401L,5L + +#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L + +#define SN_camellia_128_ecb "CAMELLIA-128-ECB" +#define LN_camellia_128_ecb "camellia-128-ecb" +#define NID_camellia_128_ecb 754 +#define OBJ_camellia_128_ecb OBJ_camellia,1L + +#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" +#define LN_camellia_128_ofb128 "camellia-128-ofb" +#define NID_camellia_128_ofb128 766 +#define OBJ_camellia_128_ofb128 OBJ_camellia,3L + +#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" +#define LN_camellia_128_cfb128 "camellia-128-cfb" +#define NID_camellia_128_cfb128 757 +#define OBJ_camellia_128_cfb128 OBJ_camellia,4L + +#define SN_camellia_192_ecb "CAMELLIA-192-ECB" +#define LN_camellia_192_ecb "camellia-192-ecb" +#define NID_camellia_192_ecb 755 +#define OBJ_camellia_192_ecb OBJ_camellia,21L + +#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" +#define LN_camellia_192_ofb128 "camellia-192-ofb" +#define NID_camellia_192_ofb128 767 +#define OBJ_camellia_192_ofb128 OBJ_camellia,23L + +#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" +#define LN_camellia_192_cfb128 "camellia-192-cfb" +#define NID_camellia_192_cfb128 758 +#define OBJ_camellia_192_cfb128 OBJ_camellia,24L + +#define SN_camellia_256_ecb "CAMELLIA-256-ECB" +#define LN_camellia_256_ecb "camellia-256-ecb" +#define NID_camellia_256_ecb 756 +#define OBJ_camellia_256_ecb OBJ_camellia,41L + +#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" +#define LN_camellia_256_ofb128 "camellia-256-ofb" +#define NID_camellia_256_ofb128 768 +#define OBJ_camellia_256_ofb128 OBJ_camellia,43L + +#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" +#define LN_camellia_256_cfb128 "camellia-256-cfb" +#define NID_camellia_256_cfb128 759 +#define OBJ_camellia_256_cfb128 OBJ_camellia,44L + +#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" +#define LN_camellia_128_cfb1 "camellia-128-cfb1" +#define NID_camellia_128_cfb1 760 + +#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" +#define LN_camellia_192_cfb1 "camellia-192-cfb1" +#define NID_camellia_192_cfb1 761 + +#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" +#define LN_camellia_256_cfb1 "camellia-256-cfb1" +#define NID_camellia_256_cfb1 762 + +#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" +#define LN_camellia_128_cfb8 "camellia-128-cfb8" +#define NID_camellia_128_cfb8 763 + +#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" +#define LN_camellia_192_cfb8 "camellia-192-cfb8" +#define NID_camellia_192_cfb8 764 + +#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" +#define LN_camellia_256_cfb8 "camellia-256-cfb8" +#define NID_camellia_256_cfb8 765 + diff --git a/libraries/external/openssl/pc/include/openssl/objects.h b/libraries/external/openssl/pc/include/openssl/objects.h new file mode 100755 index 0000000..7700894 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/objects.h @@ -0,0 +1,1049 @@ +/* crypto/objects/objects.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_OBJECTS_H +#define HEADER_OBJECTS_H + +#define USE_OBJ_MAC + +#ifdef USE_OBJ_MAC +#include +#else +#define SN_undef "UNDEF" +#define LN_undef "undefined" +#define NID_undef 0 +#define OBJ_undef 0L + +#define SN_Algorithm "Algorithm" +#define LN_algorithm "algorithm" +#define NID_algorithm 38 +#define OBJ_algorithm 1L,3L,14L,3L,2L + +#define LN_rsadsi "rsadsi" +#define NID_rsadsi 1 +#define OBJ_rsadsi 1L,2L,840L,113549L + +#define LN_pkcs "pkcs" +#define NID_pkcs 2 +#define OBJ_pkcs OBJ_rsadsi,1L + +#define SN_md2 "MD2" +#define LN_md2 "md2" +#define NID_md2 3 +#define OBJ_md2 OBJ_rsadsi,2L,2L + +#define SN_md5 "MD5" +#define LN_md5 "md5" +#define NID_md5 4 +#define OBJ_md5 OBJ_rsadsi,2L,5L + +#define SN_rc4 "RC4" +#define LN_rc4 "rc4" +#define NID_rc4 5 +#define OBJ_rc4 OBJ_rsadsi,3L,4L + +#define LN_rsaEncryption "rsaEncryption" +#define NID_rsaEncryption 6 +#define OBJ_rsaEncryption OBJ_pkcs,1L,1L + +#define SN_md2WithRSAEncryption "RSA-MD2" +#define LN_md2WithRSAEncryption "md2WithRSAEncryption" +#define NID_md2WithRSAEncryption 7 +#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L + +#define SN_md5WithRSAEncryption "RSA-MD5" +#define LN_md5WithRSAEncryption "md5WithRSAEncryption" +#define NID_md5WithRSAEncryption 8 +#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L + +#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" +#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" +#define NID_pbeWithMD2AndDES_CBC 9 +#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L + +#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" +#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" +#define NID_pbeWithMD5AndDES_CBC 10 +#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L + +#define LN_X500 "X500" +#define NID_X500 11 +#define OBJ_X500 2L,5L + +#define LN_X509 "X509" +#define NID_X509 12 +#define OBJ_X509 OBJ_X500,4L + +#define SN_commonName "CN" +#define LN_commonName "commonName" +#define NID_commonName 13 +#define OBJ_commonName OBJ_X509,3L + +#define SN_countryName "C" +#define LN_countryName "countryName" +#define NID_countryName 14 +#define OBJ_countryName OBJ_X509,6L + +#define SN_localityName "L" +#define LN_localityName "localityName" +#define NID_localityName 15 +#define OBJ_localityName OBJ_X509,7L + +/* Postal Address? PA */ + +/* should be "ST" (rfc1327) but MS uses 'S' */ +#define SN_stateOrProvinceName "ST" +#define LN_stateOrProvinceName "stateOrProvinceName" +#define NID_stateOrProvinceName 16 +#define OBJ_stateOrProvinceName OBJ_X509,8L + +#define SN_organizationName "O" +#define LN_organizationName "organizationName" +#define NID_organizationName 17 +#define OBJ_organizationName OBJ_X509,10L + +#define SN_organizationalUnitName "OU" +#define LN_organizationalUnitName "organizationalUnitName" +#define NID_organizationalUnitName 18 +#define OBJ_organizationalUnitName OBJ_X509,11L + +#define SN_rsa "RSA" +#define LN_rsa "rsa" +#define NID_rsa 19 +#define OBJ_rsa OBJ_X500,8L,1L,1L + +#define LN_pkcs7 "pkcs7" +#define NID_pkcs7 20 +#define OBJ_pkcs7 OBJ_pkcs,7L + +#define LN_pkcs7_data "pkcs7-data" +#define NID_pkcs7_data 21 +#define OBJ_pkcs7_data OBJ_pkcs7,1L + +#define LN_pkcs7_signed "pkcs7-signedData" +#define NID_pkcs7_signed 22 +#define OBJ_pkcs7_signed OBJ_pkcs7,2L + +#define LN_pkcs7_enveloped "pkcs7-envelopedData" +#define NID_pkcs7_enveloped 23 +#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L + +#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" +#define NID_pkcs7_signedAndEnveloped 24 +#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L + +#define LN_pkcs7_digest "pkcs7-digestData" +#define NID_pkcs7_digest 25 +#define OBJ_pkcs7_digest OBJ_pkcs7,5L + +#define LN_pkcs7_encrypted "pkcs7-encryptedData" +#define NID_pkcs7_encrypted 26 +#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L + +#define LN_pkcs3 "pkcs3" +#define NID_pkcs3 27 +#define OBJ_pkcs3 OBJ_pkcs,3L + +#define LN_dhKeyAgreement "dhKeyAgreement" +#define NID_dhKeyAgreement 28 +#define OBJ_dhKeyAgreement OBJ_pkcs3,1L + +#define SN_des_ecb "DES-ECB" +#define LN_des_ecb "des-ecb" +#define NID_des_ecb 29 +#define OBJ_des_ecb OBJ_algorithm,6L + +#define SN_des_cfb64 "DES-CFB" +#define LN_des_cfb64 "des-cfb" +#define NID_des_cfb64 30 +/* IV + num */ +#define OBJ_des_cfb64 OBJ_algorithm,9L + +#define SN_des_cbc "DES-CBC" +#define LN_des_cbc "des-cbc" +#define NID_des_cbc 31 +/* IV */ +#define OBJ_des_cbc OBJ_algorithm,7L + +#define SN_des_ede "DES-EDE" +#define LN_des_ede "des-ede" +#define NID_des_ede 32 +/* ?? */ +#define OBJ_des_ede OBJ_algorithm,17L + +#define SN_des_ede3 "DES-EDE3" +#define LN_des_ede3 "des-ede3" +#define NID_des_ede3 33 + +#define SN_idea_cbc "IDEA-CBC" +#define LN_idea_cbc "idea-cbc" +#define NID_idea_cbc 34 +#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L + +#define SN_idea_cfb64 "IDEA-CFB" +#define LN_idea_cfb64 "idea-cfb" +#define NID_idea_cfb64 35 + +#define SN_idea_ecb "IDEA-ECB" +#define LN_idea_ecb "idea-ecb" +#define NID_idea_ecb 36 + +#define SN_rc2_cbc "RC2-CBC" +#define LN_rc2_cbc "rc2-cbc" +#define NID_rc2_cbc 37 +#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L + +#define SN_rc2_ecb "RC2-ECB" +#define LN_rc2_ecb "rc2-ecb" +#define NID_rc2_ecb 38 + +#define SN_rc2_cfb64 "RC2-CFB" +#define LN_rc2_cfb64 "rc2-cfb" +#define NID_rc2_cfb64 39 + +#define SN_rc2_ofb64 "RC2-OFB" +#define LN_rc2_ofb64 "rc2-ofb" +#define NID_rc2_ofb64 40 + +#define SN_sha "SHA" +#define LN_sha "sha" +#define NID_sha 41 +#define OBJ_sha OBJ_algorithm,18L + +#define SN_shaWithRSAEncryption "RSA-SHA" +#define LN_shaWithRSAEncryption "shaWithRSAEncryption" +#define NID_shaWithRSAEncryption 42 +#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L + +#define SN_des_ede_cbc "DES-EDE-CBC" +#define LN_des_ede_cbc "des-ede-cbc" +#define NID_des_ede_cbc 43 + +#define SN_des_ede3_cbc "DES-EDE3-CBC" +#define LN_des_ede3_cbc "des-ede3-cbc" +#define NID_des_ede3_cbc 44 +#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L + +#define SN_des_ofb64 "DES-OFB" +#define LN_des_ofb64 "des-ofb" +#define NID_des_ofb64 45 +#define OBJ_des_ofb64 OBJ_algorithm,8L + +#define SN_idea_ofb64 "IDEA-OFB" +#define LN_idea_ofb64 "idea-ofb" +#define NID_idea_ofb64 46 + +#define LN_pkcs9 "pkcs9" +#define NID_pkcs9 47 +#define OBJ_pkcs9 OBJ_pkcs,9L + +#define SN_pkcs9_emailAddress "Email" +#define LN_pkcs9_emailAddress "emailAddress" +#define NID_pkcs9_emailAddress 48 +#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L + +#define LN_pkcs9_unstructuredName "unstructuredName" +#define NID_pkcs9_unstructuredName 49 +#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L + +#define LN_pkcs9_contentType "contentType" +#define NID_pkcs9_contentType 50 +#define OBJ_pkcs9_contentType OBJ_pkcs9,3L + +#define LN_pkcs9_messageDigest "messageDigest" +#define NID_pkcs9_messageDigest 51 +#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L + +#define LN_pkcs9_signingTime "signingTime" +#define NID_pkcs9_signingTime 52 +#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L + +#define LN_pkcs9_countersignature "countersignature" +#define NID_pkcs9_countersignature 53 +#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L + +#define LN_pkcs9_challengePassword "challengePassword" +#define NID_pkcs9_challengePassword 54 +#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L + +#define LN_pkcs9_unstructuredAddress "unstructuredAddress" +#define NID_pkcs9_unstructuredAddress 55 +#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L + +#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" +#define NID_pkcs9_extCertAttributes 56 +#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L + +#define SN_netscape "Netscape" +#define LN_netscape "Netscape Communications Corp." +#define NID_netscape 57 +#define OBJ_netscape 2L,16L,840L,1L,113730L + +#define SN_netscape_cert_extension "nsCertExt" +#define LN_netscape_cert_extension "Netscape Certificate Extension" +#define NID_netscape_cert_extension 58 +#define OBJ_netscape_cert_extension OBJ_netscape,1L + +#define SN_netscape_data_type "nsDataType" +#define LN_netscape_data_type "Netscape Data Type" +#define NID_netscape_data_type 59 +#define OBJ_netscape_data_type OBJ_netscape,2L + +#define SN_des_ede_cfb64 "DES-EDE-CFB" +#define LN_des_ede_cfb64 "des-ede-cfb" +#define NID_des_ede_cfb64 60 + +#define SN_des_ede3_cfb64 "DES-EDE3-CFB" +#define LN_des_ede3_cfb64 "des-ede3-cfb" +#define NID_des_ede3_cfb64 61 + +#define SN_des_ede_ofb64 "DES-EDE-OFB" +#define LN_des_ede_ofb64 "des-ede-ofb" +#define NID_des_ede_ofb64 62 + +#define SN_des_ede3_ofb64 "DES-EDE3-OFB" +#define LN_des_ede3_ofb64 "des-ede3-ofb" +#define NID_des_ede3_ofb64 63 + +/* I'm not sure about the object ID */ +#define SN_sha1 "SHA1" +#define LN_sha1 "sha1" +#define NID_sha1 64 +#define OBJ_sha1 OBJ_algorithm,26L +/* 28 Jun 1996 - eay */ +/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ + +#define SN_sha1WithRSAEncryption "RSA-SHA1" +#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" +#define NID_sha1WithRSAEncryption 65 +#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L + +#define SN_dsaWithSHA "DSA-SHA" +#define LN_dsaWithSHA "dsaWithSHA" +#define NID_dsaWithSHA 66 +#define OBJ_dsaWithSHA OBJ_algorithm,13L + +#define SN_dsa_2 "DSA-old" +#define LN_dsa_2 "dsaEncryption-old" +#define NID_dsa_2 67 +#define OBJ_dsa_2 OBJ_algorithm,12L + +/* proposed by microsoft to RSA */ +#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" +#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" +#define NID_pbeWithSHA1AndRC2_CBC 68 +#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L + +/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now + * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something + * completely different. + */ +#define LN_id_pbkdf2 "PBKDF2" +#define NID_id_pbkdf2 69 +#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L + +#define SN_dsaWithSHA1_2 "DSA-SHA1-old" +#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" +#define NID_dsaWithSHA1_2 70 +/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ +#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L + +#define SN_netscape_cert_type "nsCertType" +#define LN_netscape_cert_type "Netscape Cert Type" +#define NID_netscape_cert_type 71 +#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L + +#define SN_netscape_base_url "nsBaseUrl" +#define LN_netscape_base_url "Netscape Base Url" +#define NID_netscape_base_url 72 +#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L + +#define SN_netscape_revocation_url "nsRevocationUrl" +#define LN_netscape_revocation_url "Netscape Revocation Url" +#define NID_netscape_revocation_url 73 +#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L + +#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" +#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" +#define NID_netscape_ca_revocation_url 74 +#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L + +#define SN_netscape_renewal_url "nsRenewalUrl" +#define LN_netscape_renewal_url "Netscape Renewal Url" +#define NID_netscape_renewal_url 75 +#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L + +#define SN_netscape_ca_policy_url "nsCaPolicyUrl" +#define LN_netscape_ca_policy_url "Netscape CA Policy Url" +#define NID_netscape_ca_policy_url 76 +#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L + +#define SN_netscape_ssl_server_name "nsSslServerName" +#define LN_netscape_ssl_server_name "Netscape SSL Server Name" +#define NID_netscape_ssl_server_name 77 +#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L + +#define SN_netscape_comment "nsComment" +#define LN_netscape_comment "Netscape Comment" +#define NID_netscape_comment 78 +#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L + +#define SN_netscape_cert_sequence "nsCertSequence" +#define LN_netscape_cert_sequence "Netscape Certificate Sequence" +#define NID_netscape_cert_sequence 79 +#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L + +#define SN_desx_cbc "DESX-CBC" +#define LN_desx_cbc "desx-cbc" +#define NID_desx_cbc 80 + +#define SN_id_ce "id-ce" +#define NID_id_ce 81 +#define OBJ_id_ce 2L,5L,29L + +#define SN_subject_key_identifier "subjectKeyIdentifier" +#define LN_subject_key_identifier "X509v3 Subject Key Identifier" +#define NID_subject_key_identifier 82 +#define OBJ_subject_key_identifier OBJ_id_ce,14L + +#define SN_key_usage "keyUsage" +#define LN_key_usage "X509v3 Key Usage" +#define NID_key_usage 83 +#define OBJ_key_usage OBJ_id_ce,15L + +#define SN_private_key_usage_period "privateKeyUsagePeriod" +#define LN_private_key_usage_period "X509v3 Private Key Usage Period" +#define NID_private_key_usage_period 84 +#define OBJ_private_key_usage_period OBJ_id_ce,16L + +#define SN_subject_alt_name "subjectAltName" +#define LN_subject_alt_name "X509v3 Subject Alternative Name" +#define NID_subject_alt_name 85 +#define OBJ_subject_alt_name OBJ_id_ce,17L + +#define SN_issuer_alt_name "issuerAltName" +#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" +#define NID_issuer_alt_name 86 +#define OBJ_issuer_alt_name OBJ_id_ce,18L + +#define SN_basic_constraints "basicConstraints" +#define LN_basic_constraints "X509v3 Basic Constraints" +#define NID_basic_constraints 87 +#define OBJ_basic_constraints OBJ_id_ce,19L + +#define SN_crl_number "crlNumber" +#define LN_crl_number "X509v3 CRL Number" +#define NID_crl_number 88 +#define OBJ_crl_number OBJ_id_ce,20L + +#define SN_certificate_policies "certificatePolicies" +#define LN_certificate_policies "X509v3 Certificate Policies" +#define NID_certificate_policies 89 +#define OBJ_certificate_policies OBJ_id_ce,32L + +#define SN_authority_key_identifier "authorityKeyIdentifier" +#define LN_authority_key_identifier "X509v3 Authority Key Identifier" +#define NID_authority_key_identifier 90 +#define OBJ_authority_key_identifier OBJ_id_ce,35L + +#define SN_bf_cbc "BF-CBC" +#define LN_bf_cbc "bf-cbc" +#define NID_bf_cbc 91 +#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L + +#define SN_bf_ecb "BF-ECB" +#define LN_bf_ecb "bf-ecb" +#define NID_bf_ecb 92 + +#define SN_bf_cfb64 "BF-CFB" +#define LN_bf_cfb64 "bf-cfb" +#define NID_bf_cfb64 93 + +#define SN_bf_ofb64 "BF-OFB" +#define LN_bf_ofb64 "bf-ofb" +#define NID_bf_ofb64 94 + +#define SN_mdc2 "MDC2" +#define LN_mdc2 "mdc2" +#define NID_mdc2 95 +#define OBJ_mdc2 2L,5L,8L,3L,101L +/* An alternative? 1L,3L,14L,3L,2L,19L */ + +#define SN_mdc2WithRSA "RSA-MDC2" +#define LN_mdc2WithRSA "mdc2withRSA" +#define NID_mdc2WithRSA 96 +#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L + +#define SN_rc4_40 "RC4-40" +#define LN_rc4_40 "rc4-40" +#define NID_rc4_40 97 + +#define SN_rc2_40_cbc "RC2-40-CBC" +#define LN_rc2_40_cbc "rc2-40-cbc" +#define NID_rc2_40_cbc 98 + +#define SN_givenName "G" +#define LN_givenName "givenName" +#define NID_givenName 99 +#define OBJ_givenName OBJ_X509,42L + +#define SN_surname "S" +#define LN_surname "surname" +#define NID_surname 100 +#define OBJ_surname OBJ_X509,4L + +#define SN_initials "I" +#define LN_initials "initials" +#define NID_initials 101 +#define OBJ_initials OBJ_X509,43L + +#define SN_uniqueIdentifier "UID" +#define LN_uniqueIdentifier "uniqueIdentifier" +#define NID_uniqueIdentifier 102 +#define OBJ_uniqueIdentifier OBJ_X509,45L + +#define SN_crl_distribution_points "crlDistributionPoints" +#define LN_crl_distribution_points "X509v3 CRL Distribution Points" +#define NID_crl_distribution_points 103 +#define OBJ_crl_distribution_points OBJ_id_ce,31L + +#define SN_md5WithRSA "RSA-NP-MD5" +#define LN_md5WithRSA "md5WithRSA" +#define NID_md5WithRSA 104 +#define OBJ_md5WithRSA OBJ_algorithm,3L + +#define SN_serialNumber "SN" +#define LN_serialNumber "serialNumber" +#define NID_serialNumber 105 +#define OBJ_serialNumber OBJ_X509,5L + +#define SN_title "T" +#define LN_title "title" +#define NID_title 106 +#define OBJ_title OBJ_X509,12L + +#define SN_description "D" +#define LN_description "description" +#define NID_description 107 +#define OBJ_description OBJ_X509,13L + +/* CAST5 is CAST-128, I'm just sticking with the documentation */ +#define SN_cast5_cbc "CAST5-CBC" +#define LN_cast5_cbc "cast5-cbc" +#define NID_cast5_cbc 108 +#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L + +#define SN_cast5_ecb "CAST5-ECB" +#define LN_cast5_ecb "cast5-ecb" +#define NID_cast5_ecb 109 + +#define SN_cast5_cfb64 "CAST5-CFB" +#define LN_cast5_cfb64 "cast5-cfb" +#define NID_cast5_cfb64 110 + +#define SN_cast5_ofb64 "CAST5-OFB" +#define LN_cast5_ofb64 "cast5-ofb" +#define NID_cast5_ofb64 111 + +#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" +#define NID_pbeWithMD5AndCast5_CBC 112 +#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L + +/* This is one sun will soon be using :-( + * id-dsa-with-sha1 ID ::= { + * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } + */ +#define SN_dsaWithSHA1 "DSA-SHA1" +#define LN_dsaWithSHA1 "dsaWithSHA1" +#define NID_dsaWithSHA1 113 +#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L + +#define NID_md5_sha1 114 +#define SN_md5_sha1 "MD5-SHA1" +#define LN_md5_sha1 "md5-sha1" + +#define SN_sha1WithRSA "RSA-SHA1-2" +#define LN_sha1WithRSA "sha1WithRSA" +#define NID_sha1WithRSA 115 +#define OBJ_sha1WithRSA OBJ_algorithm,29L + +#define SN_dsa "DSA" +#define LN_dsa "dsaEncryption" +#define NID_dsa 116 +#define OBJ_dsa 1L,2L,840L,10040L,4L,1L + +#define SN_ripemd160 "RIPEMD160" +#define LN_ripemd160 "ripemd160" +#define NID_ripemd160 117 +#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L + +/* The name should actually be rsaSignatureWithripemd160, but I'm going + * to continue using the convention I'm using with the other ciphers */ +#define SN_ripemd160WithRSA "RSA-RIPEMD160" +#define LN_ripemd160WithRSA "ripemd160WithRSA" +#define NID_ripemd160WithRSA 119 +#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L + +/* Taken from rfc2040 + * RC5_CBC_Parameters ::= SEQUENCE { + * version INTEGER (v1_0(16)), + * rounds INTEGER (8..127), + * blockSizeInBits INTEGER (64, 128), + * iv OCTET STRING OPTIONAL + * } + */ +#define SN_rc5_cbc "RC5-CBC" +#define LN_rc5_cbc "rc5-cbc" +#define NID_rc5_cbc 120 +#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L + +#define SN_rc5_ecb "RC5-ECB" +#define LN_rc5_ecb "rc5-ecb" +#define NID_rc5_ecb 121 + +#define SN_rc5_cfb64 "RC5-CFB" +#define LN_rc5_cfb64 "rc5-cfb" +#define NID_rc5_cfb64 122 + +#define SN_rc5_ofb64 "RC5-OFB" +#define LN_rc5_ofb64 "rc5-ofb" +#define NID_rc5_ofb64 123 + +#define SN_rle_compression "RLE" +#define LN_rle_compression "run length compression" +#define NID_rle_compression 124 +#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L + +#define SN_zlib_compression "ZLIB" +#define LN_zlib_compression "zlib compression" +#define NID_zlib_compression 125 +#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L + +#define SN_ext_key_usage "extendedKeyUsage" +#define LN_ext_key_usage "X509v3 Extended Key Usage" +#define NID_ext_key_usage 126 +#define OBJ_ext_key_usage OBJ_id_ce,37 + +#define SN_id_pkix "PKIX" +#define NID_id_pkix 127 +#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L + +#define SN_id_kp "id-kp" +#define NID_id_kp 128 +#define OBJ_id_kp OBJ_id_pkix,3L + +/* PKIX extended key usage OIDs */ + +#define SN_server_auth "serverAuth" +#define LN_server_auth "TLS Web Server Authentication" +#define NID_server_auth 129 +#define OBJ_server_auth OBJ_id_kp,1L + +#define SN_client_auth "clientAuth" +#define LN_client_auth "TLS Web Client Authentication" +#define NID_client_auth 130 +#define OBJ_client_auth OBJ_id_kp,2L + +#define SN_code_sign "codeSigning" +#define LN_code_sign "Code Signing" +#define NID_code_sign 131 +#define OBJ_code_sign OBJ_id_kp,3L + +#define SN_email_protect "emailProtection" +#define LN_email_protect "E-mail Protection" +#define NID_email_protect 132 +#define OBJ_email_protect OBJ_id_kp,4L + +#define SN_time_stamp "timeStamping" +#define LN_time_stamp "Time Stamping" +#define NID_time_stamp 133 +#define OBJ_time_stamp OBJ_id_kp,8L + +/* Additional extended key usage OIDs: Microsoft */ + +#define SN_ms_code_ind "msCodeInd" +#define LN_ms_code_ind "Microsoft Individual Code Signing" +#define NID_ms_code_ind 134 +#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L + +#define SN_ms_code_com "msCodeCom" +#define LN_ms_code_com "Microsoft Commercial Code Signing" +#define NID_ms_code_com 135 +#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L + +#define SN_ms_ctl_sign "msCTLSign" +#define LN_ms_ctl_sign "Microsoft Trust List Signing" +#define NID_ms_ctl_sign 136 +#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L + +#define SN_ms_sgc "msSGC" +#define LN_ms_sgc "Microsoft Server Gated Crypto" +#define NID_ms_sgc 137 +#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L + +#define SN_ms_efs "msEFS" +#define LN_ms_efs "Microsoft Encrypted File System" +#define NID_ms_efs 138 +#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L + +/* Additional usage: Netscape */ + +#define SN_ns_sgc "nsSGC" +#define LN_ns_sgc "Netscape Server Gated Crypto" +#define NID_ns_sgc 139 +#define OBJ_ns_sgc OBJ_netscape,4L,1L + +#define SN_delta_crl "deltaCRL" +#define LN_delta_crl "X509v3 Delta CRL Indicator" +#define NID_delta_crl 140 +#define OBJ_delta_crl OBJ_id_ce,27L + +#define SN_crl_reason "CRLReason" +#define LN_crl_reason "CRL Reason Code" +#define NID_crl_reason 141 +#define OBJ_crl_reason OBJ_id_ce,21L + +#define SN_invalidity_date "invalidityDate" +#define LN_invalidity_date "Invalidity Date" +#define NID_invalidity_date 142 +#define OBJ_invalidity_date OBJ_id_ce,24L + +#define SN_sxnet "SXNetID" +#define LN_sxnet "Strong Extranet ID" +#define NID_sxnet 143 +#define OBJ_sxnet 1L,3L,101L,1L,4L,1L + +/* PKCS12 and related OBJECT IDENTIFIERS */ + +#define OBJ_pkcs12 OBJ_pkcs,12L +#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 + +#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" +#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" +#define NID_pbe_WithSHA1And128BitRC4 144 +#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L + +#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" +#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" +#define NID_pbe_WithSHA1And40BitRC4 145 +#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L + +#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" +#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 +#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L + +#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" +#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" +#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 +#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L + +#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" +#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" +#define NID_pbe_WithSHA1And128BitRC2_CBC 148 +#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L + +#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" +#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" +#define NID_pbe_WithSHA1And40BitRC2_CBC 149 +#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L + +#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L + +#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L + +#define LN_keyBag "keyBag" +#define NID_keyBag 150 +#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L + +#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" +#define NID_pkcs8ShroudedKeyBag 151 +#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L + +#define LN_certBag "certBag" +#define NID_certBag 152 +#define OBJ_certBag OBJ_pkcs12_BagIds, 3L + +#define LN_crlBag "crlBag" +#define NID_crlBag 153 +#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L + +#define LN_secretBag "secretBag" +#define NID_secretBag 154 +#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L + +#define LN_safeContentsBag "safeContentsBag" +#define NID_safeContentsBag 155 +#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L + +#define LN_friendlyName "friendlyName" +#define NID_friendlyName 156 +#define OBJ_friendlyName OBJ_pkcs9, 20L + +#define LN_localKeyID "localKeyID" +#define NID_localKeyID 157 +#define OBJ_localKeyID OBJ_pkcs9, 21L + +#define OBJ_certTypes OBJ_pkcs9, 22L + +#define LN_x509Certificate "x509Certificate" +#define NID_x509Certificate 158 +#define OBJ_x509Certificate OBJ_certTypes, 1L + +#define LN_sdsiCertificate "sdsiCertificate" +#define NID_sdsiCertificate 159 +#define OBJ_sdsiCertificate OBJ_certTypes, 2L + +#define OBJ_crlTypes OBJ_pkcs9, 23L + +#define LN_x509Crl "x509Crl" +#define NID_x509Crl 160 +#define OBJ_x509Crl OBJ_crlTypes, 1L + +/* PKCS#5 v2 OIDs */ + +#define LN_pbes2 "PBES2" +#define NID_pbes2 161 +#define OBJ_pbes2 OBJ_pkcs,5L,13L + +#define LN_pbmac1 "PBMAC1" +#define NID_pbmac1 162 +#define OBJ_pbmac1 OBJ_pkcs,5L,14L + +#define LN_hmacWithSHA1 "hmacWithSHA1" +#define NID_hmacWithSHA1 163 +#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L + +/* Policy Qualifier Ids */ + +#define LN_id_qt_cps "Policy Qualifier CPS" +#define SN_id_qt_cps "id-qt-cps" +#define NID_id_qt_cps 164 +#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L + +#define LN_id_qt_unotice "Policy Qualifier User Notice" +#define SN_id_qt_unotice "id-qt-unotice" +#define NID_id_qt_unotice 165 +#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L + +#define SN_rc2_64_cbc "RC2-64-CBC" +#define LN_rc2_64_cbc "rc2-64-cbc" +#define NID_rc2_64_cbc 166 + +#define SN_SMIMECapabilities "SMIME-CAPS" +#define LN_SMIMECapabilities "S/MIME Capabilities" +#define NID_SMIMECapabilities 167 +#define OBJ_SMIMECapabilities OBJ_pkcs9,15L + +#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" +#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" +#define NID_pbeWithMD2AndRC2_CBC 168 +#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L + +#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" +#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" +#define NID_pbeWithMD5AndRC2_CBC 169 +#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L + +#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" +#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" +#define NID_pbeWithSHA1AndDES_CBC 170 +#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L + +/* Extension request OIDs */ + +#define LN_ms_ext_req "Microsoft Extension Request" +#define SN_ms_ext_req "msExtReq" +#define NID_ms_ext_req 171 +#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L + +#define LN_ext_req "Extension Request" +#define SN_ext_req "extReq" +#define NID_ext_req 172 +#define OBJ_ext_req OBJ_pkcs9,14L + +#define SN_name "name" +#define LN_name "name" +#define NID_name 173 +#define OBJ_name OBJ_X509,41L + +#define SN_dnQualifier "dnQualifier" +#define LN_dnQualifier "dnQualifier" +#define NID_dnQualifier 174 +#define OBJ_dnQualifier OBJ_X509,46L + +#define SN_id_pe "id-pe" +#define NID_id_pe 175 +#define OBJ_id_pe OBJ_id_pkix,1L + +#define SN_id_ad "id-ad" +#define NID_id_ad 176 +#define OBJ_id_ad OBJ_id_pkix,48L + +#define SN_info_access "authorityInfoAccess" +#define LN_info_access "Authority Information Access" +#define NID_info_access 177 +#define OBJ_info_access OBJ_id_pe,1L + +#define SN_ad_OCSP "OCSP" +#define LN_ad_OCSP "OCSP" +#define NID_ad_OCSP 178 +#define OBJ_ad_OCSP OBJ_id_ad,1L + +#define SN_ad_ca_issuers "caIssuers" +#define LN_ad_ca_issuers "CA Issuers" +#define NID_ad_ca_issuers 179 +#define OBJ_ad_ca_issuers OBJ_id_ad,2L + +#define SN_OCSP_sign "OCSPSigning" +#define LN_OCSP_sign "OCSP Signing" +#define NID_OCSP_sign 180 +#define OBJ_OCSP_sign OBJ_id_kp,9L +#endif /* USE_OBJ_MAC */ + +#include +#include + +#define OBJ_NAME_TYPE_UNDEF 0x00 +#define OBJ_NAME_TYPE_MD_METH 0x01 +#define OBJ_NAME_TYPE_CIPHER_METH 0x02 +#define OBJ_NAME_TYPE_PKEY_METH 0x03 +#define OBJ_NAME_TYPE_COMP_METH 0x04 +#define OBJ_NAME_TYPE_NUM 0x05 + +#define OBJ_NAME_ALIAS 0x8000 + +#define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 +#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct obj_name_st + { + int type; + int alias; + const char *name; + const char *data; + } OBJ_NAME; + +#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) + + +int OBJ_NAME_init(void); +int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), + int (*cmp_func)(const char *, const char *), + void (*free_func)(const char *, int, const char *)); +const char *OBJ_NAME_get(const char *name,int type); +int OBJ_NAME_add(const char *name,int type,const char *data); +int OBJ_NAME_remove(const char *name,int type); +void OBJ_NAME_cleanup(int type); /* -1 for everything */ +void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); +void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg), + void *arg); + +ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_nid2obj(int n); +const char * OBJ_nid2ln(int n); +const char * OBJ_nid2sn(int n); +int OBJ_obj2nid(const ASN1_OBJECT *o); +ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); +int OBJ_txt2nid(const char *s); +int OBJ_ln2nid(const char *s); +int OBJ_sn2nid(const char *s); +int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); +const char * OBJ_bsearch(const char *key,const char *base,int num,int size, + int (*cmp)(const void *, const void *)); +const char * OBJ_bsearch_ex(const char *key,const char *base,int num, + int size, int (*cmp)(const void *, const void *), int flags); + +int OBJ_new_nid(int num); +int OBJ_add_object(const ASN1_OBJECT *obj); +int OBJ_create(const char *oid,const char *sn,const char *ln); +void OBJ_cleanup(void ); +int OBJ_create_objects(BIO *in); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OBJ_strings(void); + +/* Error codes for the OBJ functions. */ + +/* Function codes. */ +#define OBJ_F_OBJ_ADD_OBJECT 105 +#define OBJ_F_OBJ_CREATE 100 +#define OBJ_F_OBJ_DUP 101 +#define OBJ_F_OBJ_NAME_NEW_INDEX 106 +#define OBJ_F_OBJ_NID2LN 102 +#define OBJ_F_OBJ_NID2OBJ 103 +#define OBJ_F_OBJ_NID2SN 104 + +/* Reason codes. */ +#define OBJ_R_MALLOC_FAILURE 100 +#define OBJ_R_UNKNOWN_NID 101 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ocsp.h b/libraries/external/openssl/pc/include/openssl/ocsp.h new file mode 100755 index 0000000..830d428 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ocsp.h @@ -0,0 +1,614 @@ +/* ocsp.h */ +/* Written by Tom Titchener for the OpenSSL + * project. */ + +/* History: + This file was transfered to Richard Levitte from CertCo by Kathy + Weinhold in mid-spring 2000 to be included in OpenSSL or released + as a patch kit. */ + +/* ==================================================================== + * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OCSP_H +#define HEADER_OCSP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Various flags and values */ + +#define OCSP_DEFAULT_NONCE_LENGTH 16 + +#define OCSP_NOCERTS 0x1 +#define OCSP_NOINTERN 0x2 +#define OCSP_NOSIGS 0x4 +#define OCSP_NOCHAIN 0x8 +#define OCSP_NOVERIFY 0x10 +#define OCSP_NOEXPLICIT 0x20 +#define OCSP_NOCASIGN 0x40 +#define OCSP_NODELEGATED 0x80 +#define OCSP_NOCHECKS 0x100 +#define OCSP_TRUSTOTHER 0x200 +#define OCSP_RESPID_KEY 0x400 +#define OCSP_NOTIME 0x800 + +/* CertID ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier, + * issuerNameHash OCTET STRING, -- Hash of Issuer's DN + * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) + * serialNumber CertificateSerialNumber } + */ +typedef struct ocsp_cert_id_st + { + X509_ALGOR *hashAlgorithm; + ASN1_OCTET_STRING *issuerNameHash; + ASN1_OCTET_STRING *issuerKeyHash; + ASN1_INTEGER *serialNumber; + } OCSP_CERTID; + +DECLARE_STACK_OF(OCSP_CERTID) + +/* Request ::= SEQUENCE { + * reqCert CertID, + * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_one_request_st + { + OCSP_CERTID *reqCert; + STACK_OF(X509_EXTENSION) *singleRequestExtensions; + } OCSP_ONEREQ; + +DECLARE_STACK_OF(OCSP_ONEREQ) +DECLARE_ASN1_SET_OF(OCSP_ONEREQ) + + +/* TBSRequest ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * requestorName [1] EXPLICIT GeneralName OPTIONAL, + * requestList SEQUENCE OF Request, + * requestExtensions [2] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_req_info_st + { + ASN1_INTEGER *version; + GENERAL_NAME *requestorName; + STACK_OF(OCSP_ONEREQ) *requestList; + STACK_OF(X509_EXTENSION) *requestExtensions; + } OCSP_REQINFO; + +/* Signature ::= SEQUENCE { + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ +typedef struct ocsp_signature_st + { + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_SIGNATURE; + +/* OCSPRequest ::= SEQUENCE { + * tbsRequest TBSRequest, + * optionalSignature [0] EXPLICIT Signature OPTIONAL } + */ +typedef struct ocsp_request_st + { + OCSP_REQINFO *tbsRequest; + OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ + } OCSP_REQUEST; + +/* OCSPResponseStatus ::= ENUMERATED { + * successful (0), --Response has valid confirmations + * malformedRequest (1), --Illegal confirmation request + * internalError (2), --Internal error in issuer + * tryLater (3), --Try again later + * --(4) is not used + * sigRequired (5), --Must sign the request + * unauthorized (6) --Request unauthorized + * } + */ +#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 +#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 +#define OCSP_RESPONSE_STATUS_INTERNALERROR 2 +#define OCSP_RESPONSE_STATUS_TRYLATER 3 +#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 +#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 + +/* ResponseBytes ::= SEQUENCE { + * responseType OBJECT IDENTIFIER, + * response OCTET STRING } + */ +typedef struct ocsp_resp_bytes_st + { + ASN1_OBJECT *responseType; + ASN1_OCTET_STRING *response; + } OCSP_RESPBYTES; + +/* OCSPResponse ::= SEQUENCE { + * responseStatus OCSPResponseStatus, + * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } + */ +typedef struct ocsp_response_st + { + ASN1_ENUMERATED *responseStatus; + OCSP_RESPBYTES *responseBytes; + } OCSP_RESPONSE; + +/* ResponderID ::= CHOICE { + * byName [1] Name, + * byKey [2] KeyHash } + */ +#define V_OCSP_RESPID_NAME 0 +#define V_OCSP_RESPID_KEY 1 +typedef struct ocsp_responder_id_st + { + int type; + union { + X509_NAME* byName; + ASN1_OCTET_STRING *byKey; + } value; + } OCSP_RESPID; +/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key + * --(excluding the tag and length fields) + */ + +/* RevokedInfo ::= SEQUENCE { + * revocationTime GeneralizedTime, + * revocationReason [0] EXPLICIT CRLReason OPTIONAL } + */ +typedef struct ocsp_revoked_info_st + { + ASN1_GENERALIZEDTIME *revocationTime; + ASN1_ENUMERATED *revocationReason; + } OCSP_REVOKEDINFO; + +/* CertStatus ::= CHOICE { + * good [0] IMPLICIT NULL, + * revoked [1] IMPLICIT RevokedInfo, + * unknown [2] IMPLICIT UnknownInfo } + */ +#define V_OCSP_CERTSTATUS_GOOD 0 +#define V_OCSP_CERTSTATUS_REVOKED 1 +#define V_OCSP_CERTSTATUS_UNKNOWN 2 +typedef struct ocsp_cert_status_st + { + int type; + union { + ASN1_NULL *good; + OCSP_REVOKEDINFO *revoked; + ASN1_NULL *unknown; + } value; + } OCSP_CERTSTATUS; + +/* SingleResponse ::= SEQUENCE { + * certID CertID, + * certStatus CertStatus, + * thisUpdate GeneralizedTime, + * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, + * singleExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_single_response_st + { + OCSP_CERTID *certId; + OCSP_CERTSTATUS *certStatus; + ASN1_GENERALIZEDTIME *thisUpdate; + ASN1_GENERALIZEDTIME *nextUpdate; + STACK_OF(X509_EXTENSION) *singleExtensions; + } OCSP_SINGLERESP; + +DECLARE_STACK_OF(OCSP_SINGLERESP) +DECLARE_ASN1_SET_OF(OCSP_SINGLERESP) + +/* ResponseData ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * responderID ResponderID, + * producedAt GeneralizedTime, + * responses SEQUENCE OF SingleResponse, + * responseExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +typedef struct ocsp_response_data_st + { + ASN1_INTEGER *version; + OCSP_RESPID *responderId; + ASN1_GENERALIZEDTIME *producedAt; + STACK_OF(OCSP_SINGLERESP) *responses; + STACK_OF(X509_EXTENSION) *responseExtensions; + } OCSP_RESPDATA; + +/* BasicOCSPResponse ::= SEQUENCE { + * tbsResponseData ResponseData, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ + /* Note 1: + The value for "signature" is specified in the OCSP rfc2560 as follows: + "The value for the signature SHALL be computed on the hash of the DER + encoding ResponseData." This means that you must hash the DER-encoded + tbsResponseData, and then run it through a crypto-signing function, which + will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems + a bit odd, but that's the spec. Also note that the data structures do not + leave anywhere to independently specify the algorithm used for the initial + hash. So, we look at the signature-specification algorithm, and try to do + something intelligent. -- Kathy Weinhold, CertCo */ + /* Note 2: + It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open + for interpretation. I've done tests against another responder, and found + that it doesn't do the double hashing that the RFC seems to say one + should. Therefore, all relevant functions take a flag saying which + variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */ +typedef struct ocsp_basic_response_st + { + OCSP_RESPDATA *tbsResponseData; + X509_ALGOR *signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; + } OCSP_BASICRESP; + +/* + * CRLReason ::= ENUMERATED { + * unspecified (0), + * keyCompromise (1), + * cACompromise (2), + * affiliationChanged (3), + * superseded (4), + * cessationOfOperation (5), + * certificateHold (6), + * removeFromCRL (8) } + */ +#define OCSP_REVOKED_STATUS_NOSTATUS -1 +#define OCSP_REVOKED_STATUS_UNSPECIFIED 0 +#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 +#define OCSP_REVOKED_STATUS_CACOMPROMISE 2 +#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 +#define OCSP_REVOKED_STATUS_SUPERSEDED 4 +#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 +#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 +#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 + +/* CrlID ::= SEQUENCE { + * crlUrl [0] EXPLICIT IA5String OPTIONAL, + * crlNum [1] EXPLICIT INTEGER OPTIONAL, + * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } + */ +typedef struct ocsp_crl_id_st + { + ASN1_IA5STRING *crlUrl; + ASN1_INTEGER *crlNum; + ASN1_GENERALIZEDTIME *crlTime; + } OCSP_CRLID; + +/* ServiceLocator ::= SEQUENCE { + * issuer Name, + * locator AuthorityInfoAccessSyntax OPTIONAL } + */ +typedef struct ocsp_service_locator_st + { + X509_NAME* issuer; + STACK_OF(ACCESS_DESCRIPTION) *locator; + } OCSP_SERVICELOC; + +#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" +#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" + +#define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) + +#define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) + +#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL) + +#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ + (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL) + +#define PEM_write_bio_OCSP_REQUEST(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_OCSP_RESPONSE(bp,o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ + bp,(char *)o, NULL,NULL,0,NULL,NULL) + +#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) + +#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) + +#define OCSP_REQUEST_sign(o,pkey,md) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ + o->optionalSignature->signatureAlgorithm,NULL,\ + o->optionalSignature->signature,o->tbsRequest,pkey,md) + +#define OCSP_BASICRESP_sign(o,pkey,md,d) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\ + o->signature,o->tbsResponseData,pkey,md) + +#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ + a->optionalSignature->signatureAlgorithm,\ + a->optionalSignature->signature,a->tbsRequest,r) + +#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ + a->signatureAlgorithm,a->signature,a->tbsResponseData,r) + +#define ASN1_BIT_STRING_digest(data,type,md,len) \ + ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) + +#define OCSP_CERTID_dup(cid) ASN1_dup_of(OCSP_CERTID,i2d_OCSP_CERTID,d2i_OCSP_CERTID,cid) + +#define OCSP_CERTSTATUS_dup(cs)\ + (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ + (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) + +OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req); + +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer); + +OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, + X509_NAME *issuerName, + ASN1_BIT_STRING* issuerKey, + ASN1_INTEGER *serialNumber); + +OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); + +int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); +int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); +int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); +int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); + +int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); +int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); + +int OCSP_request_sign(OCSP_REQUEST *req, + X509 *signer, + EVP_PKEY *key, + const EVP_MD *dgst, + STACK_OF(X509) *certs, + unsigned long flags); + +int OCSP_response_status(OCSP_RESPONSE *resp); +OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); + +int OCSP_resp_count(OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); +int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); +int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, + int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, + ASN1_GENERALIZEDTIME *nextupd, + long sec, long maxsec); + +int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags); + +int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl); + +int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); +int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); + +int OCSP_request_onereq_count(OCSP_REQUEST *req); +OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); +OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); +int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, + ASN1_OCTET_STRING **pikeyHash, + ASN1_INTEGER **pserial, OCSP_CERTID *cid); +int OCSP_request_is_signed(OCSP_REQUEST *req); +OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); +OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, + OCSP_CERTID *cid, + int status, int reason, + ASN1_TIME *revtime, + ASN1_TIME *thisupd, ASN1_TIME *nextupd); +int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); +int OCSP_basic_sign(OCSP_BASICRESP *brsp, + X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, + STACK_OF(X509) *certs, unsigned long flags); + +ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, + void *data, STACK_OF(ASN1_OBJECT) *sk); +#define ASN1_STRING_encode_of(type,s,i2d,data,sk) \ +((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk) + +X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); + +X509_EXTENSION *OCSP_accept_responses_new(char **oids); + +X509_EXTENSION *OCSP_archive_cutoff_new(char* tim); + +X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls); + +int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); +int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); +X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); +X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); +void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx); +int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); + +int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); +int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); +X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); +X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); +void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); +int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); + +int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); +int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); +X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); +void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx); +int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); + +int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); +int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos); +int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); +X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); +X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); +void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx); +int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, + unsigned long flags); +int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); + +DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) +DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) +DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) +DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) +DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) +DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) +DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) +DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) +DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) +DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) + +char *OCSP_response_status_str(long s); +char *OCSP_cert_status_str(long s); +char *OCSP_crl_reason_str(long s); + +int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags); +int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags); + +int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, + X509_STORE *st, unsigned long flags); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_OCSP_strings(void); + +/* Error codes for the OCSP functions. */ + +/* Function codes. */ +#define OCSP_F_ASN1_STRING_ENCODE 100 +#define OCSP_F_D2I_OCSP_NONCE 102 +#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 +#define OCSP_F_OCSP_BASIC_SIGN 104 +#define OCSP_F_OCSP_BASIC_VERIFY 105 +#define OCSP_F_OCSP_CERT_ID_NEW 101 +#define OCSP_F_OCSP_CHECK_DELEGATED 106 +#define OCSP_F_OCSP_CHECK_IDS 107 +#define OCSP_F_OCSP_CHECK_ISSUER 108 +#define OCSP_F_OCSP_CHECK_VALIDITY 115 +#define OCSP_F_OCSP_MATCH_ISSUERID 109 +#define OCSP_F_OCSP_PARSE_URL 114 +#define OCSP_F_OCSP_REQUEST_SIGN 110 +#define OCSP_F_OCSP_REQUEST_VERIFY 116 +#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 +#define OCSP_F_OCSP_SENDREQ_BIO 112 +#define OCSP_F_REQUEST_VERIFY 113 + +/* Reason codes. */ +#define OCSP_R_BAD_DATA 100 +#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 +#define OCSP_R_DIGEST_ERR 102 +#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 +#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 +#define OCSP_R_ERROR_PARSING_URL 121 +#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 +#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 +#define OCSP_R_NOT_BASIC_RESPONSE 104 +#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 +#define OCSP_R_NO_CONTENT 106 +#define OCSP_R_NO_PUBLIC_KEY 107 +#define OCSP_R_NO_RESPONSE_DATA 108 +#define OCSP_R_NO_REVOKED_TIME 109 +#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 +#define OCSP_R_REQUEST_NOT_SIGNED 128 +#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 +#define OCSP_R_ROOT_CA_NOT_TRUSTED 112 +#define OCSP_R_SERVER_READ_ERROR 113 +#define OCSP_R_SERVER_RESPONSE_ERROR 114 +#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 +#define OCSP_R_SERVER_WRITE_ERROR 116 +#define OCSP_R_SIGNATURE_FAILURE 117 +#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 +#define OCSP_R_STATUS_EXPIRED 125 +#define OCSP_R_STATUS_NOT_YET_VALID 126 +#define OCSP_R_STATUS_TOO_OLD 127 +#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 +#define OCSP_R_UNKNOWN_NID 120 +#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/opensslconf.h b/libraries/external/openssl/pc/include/openssl/opensslconf.h new file mode 100755 index 0000000..e352852 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/opensslconf.h @@ -0,0 +1,224 @@ +/* opensslconf.h */ +/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ + +/* OpenSSL was configured with the following options: */ +#ifndef OPENSSL_SYSNAME_WIN32 +# define OPENSSL_SYSNAME_WIN32 +#endif +#ifndef OPENSSL_DOING_MAKEDEPEND + +#ifndef OPENSSL_NO_CAMELLIA +# define OPENSSL_NO_CAMELLIA +#endif +#ifndef OPENSSL_NO_GMP +# define OPENSSL_NO_GMP +#endif +#ifndef OPENSSL_NO_IDEA +# define OPENSSL_NO_IDEA +#endif +#ifndef OPENSSL_NO_KRB5 +# define OPENSSL_NO_KRB5 +#endif +#ifndef OPENSSL_NO_MDC2 +# define OPENSSL_NO_MDC2 +#endif +#ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +#endif +#ifndef OPENSSL_NO_RFC3779 +# define OPENSSL_NO_RFC3779 +#endif + +#endif /* OPENSSL_DOING_MAKEDEPEND */ +#ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +#endif + +/* The OPENSSL_NO_* macros are also defined as NO_* if the application + asks for it. This is a transient feature that is provided for those + who haven't had the time to do the appropriate changes in their + applications. */ +#ifdef OPENSSL_ALGORITHM_DEFINES +# if defined(OPENSSL_NO_CAMELLIA) && !defined(NO_CAMELLIA) +# define NO_CAMELLIA +# endif +# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) +# define NO_GMP +# endif +# if defined(OPENSSL_NO_IDEA) && !defined(NO_IDEA) +# define NO_IDEA +# endif +# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) +# define NO_KRB5 +# endif +# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2) +# define NO_MDC2 +# endif +# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) +# define NO_RC5 +# endif +# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779) +# define NO_RFC3779 +# endif +#endif + +/* crypto/opensslconf.h.in */ + +/* Generate 80386 code? */ +#undef I386_ONLY + +#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define ENGINESDIR "c:/g3/openssl/lib/engines" +#define OPENSSLDIR "c:/g3/openssl/ssl" +#endif +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION +#define OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debuging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/libraries/external/openssl/pc/include/openssl/opensslv.h b/libraries/external/openssl/pc/include/openssl/opensslv.h new file mode 100755 index 0000000..c801bdb --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/opensslv.h @@ -0,0 +1,89 @@ +#ifndef HEADER_OPENSSLV_H +#define HEADER_OPENSSLV_H + +/* Numeric release version identifier: + * MNNFFPPS: major minor fix patch status + * The status nibble has one of the values 0 for development, 1 to e for betas + * 1 to 14, and f for release. The patch level is exactly that. + * For example: + * 0.9.3-dev 0x00903000 + * 0.9.3-beta1 0x00903001 + * 0.9.3-beta2-dev 0x00903002 + * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) + * 0.9.3 0x0090300f + * 0.9.3a 0x0090301f + * 0.9.4 0x0090400f + * 1.2.3z 0x102031af + * + * For continuity reasons (because 0.9.5 is already out, and is coded + * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level + * part is slightly different, by setting the highest bit. This means + * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start + * with 0x0090600S... + * + * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) + * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for + * major minor fix final patch/beta) + */ +#define OPENSSL_VERSION_NUMBER 0x0090805fL +#ifdef OPENSSL_FIPS +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8e-fips 23 Feb 2007" +#else +#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8e 23 Feb 2007" +#endif +#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT + + +/* The macros below are to be used for shared library (.so, .dll, ...) + * versioning. That kind of versioning works a bit differently between + * operating systems. The most usual scheme is to set a major and a minor + * number, and have the runtime loader check that the major number is equal + * to what it was at application link time, while the minor number has to + * be greater or equal to what it was at application link time. With this + * scheme, the version number is usually part of the file name, like this: + * + * libcrypto.so.0.9 + * + * Some unixen also make a softlink with the major verson number only: + * + * libcrypto.so.0 + * + * On Tru64 and IRIX 6.x it works a little bit differently. There, the + * shared library version is stored in the file, and is actually a series + * of versions, separated by colons. The rightmost version present in the + * library when linking an application is stored in the application to be + * matched at run time. When the application is run, a check is done to + * see if the library version stored in the application matches any of the + * versions in the version string of the library itself. + * This version string can be constructed in any way, depending on what + * kind of matching is desired. However, to implement the same scheme as + * the one used in the other unixen, all compatible versions, from lowest + * to highest, should be part of the string. Consecutive builds would + * give the following versions strings: + * + * 3.0 + * 3.0:3.1 + * 3.0:3.1:3.2 + * 4.0 + * 4.0:4.1 + * + * Notice how version 4 is completely incompatible with version, and + * therefore give the breach you can see. + * + * There may be other schemes as well that I haven't yet discovered. + * + * So, here's the way it works here: first of all, the library version + * number doesn't need at all to match the overall OpenSSL version. + * However, it's nice and more understandable if it actually does. + * The current library version is stored in the macro SHLIB_VERSION_NUMBER, + * which is just a piece of text in the format "M.m.e" (Major, minor, edit). + * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, + * we need to keep a history of version numbers, which is done in the + * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and + * should only keep the versions that are binary compatible with the current. + */ +#define SHLIB_VERSION_HISTORY "" +#define SHLIB_VERSION_NUMBER "0.9.8" + + +#endif /* HEADER_OPENSSLV_H */ diff --git a/libraries/external/openssl/pc/include/openssl/ossl_typ.h b/libraries/external/openssl/pc/include/openssl/ossl_typ.h new file mode 100755 index 0000000..9115bcc --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ossl_typ.h @@ -0,0 +1,174 @@ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_OPENSSL_TYPES_H +#define HEADER_OPENSSL_TYPES_H + +#include + +#ifdef NO_ASN1_TYPEDEFS +#define ASN1_INTEGER ASN1_STRING +#define ASN1_ENUMERATED ASN1_STRING +#define ASN1_BIT_STRING ASN1_STRING +#define ASN1_OCTET_STRING ASN1_STRING +#define ASN1_PRINTABLESTRING ASN1_STRING +#define ASN1_T61STRING ASN1_STRING +#define ASN1_IA5STRING ASN1_STRING +#define ASN1_UTCTIME ASN1_STRING +#define ASN1_GENERALIZEDTIME ASN1_STRING +#define ASN1_TIME ASN1_STRING +#define ASN1_GENERALSTRING ASN1_STRING +#define ASN1_UNIVERSALSTRING ASN1_STRING +#define ASN1_BMPSTRING ASN1_STRING +#define ASN1_VISIBLESTRING ASN1_STRING +#define ASN1_UTF8STRING ASN1_STRING +#define ASN1_BOOLEAN int +#define ASN1_NULL int +#else +typedef struct asn1_string_st ASN1_INTEGER; +typedef struct asn1_string_st ASN1_ENUMERATED; +typedef struct asn1_string_st ASN1_BIT_STRING; +typedef struct asn1_string_st ASN1_OCTET_STRING; +typedef struct asn1_string_st ASN1_PRINTABLESTRING; +typedef struct asn1_string_st ASN1_T61STRING; +typedef struct asn1_string_st ASN1_IA5STRING; +typedef struct asn1_string_st ASN1_GENERALSTRING; +typedef struct asn1_string_st ASN1_UNIVERSALSTRING; +typedef struct asn1_string_st ASN1_BMPSTRING; +typedef struct asn1_string_st ASN1_UTCTIME; +typedef struct asn1_string_st ASN1_TIME; +typedef struct asn1_string_st ASN1_GENERALIZEDTIME; +typedef struct asn1_string_st ASN1_VISIBLESTRING; +typedef struct asn1_string_st ASN1_UTF8STRING; +typedef int ASN1_BOOLEAN; +typedef int ASN1_NULL; +#endif + +#ifdef OPENSSL_SYS_WIN32 +#undef X509_NAME +#undef X509_CERT_PAIR +#undef PKCS7_ISSUER_AND_SERIAL +#endif + +#ifdef BIGNUM +#undef BIGNUM +#endif +typedef struct bignum_st BIGNUM; +typedef struct bignum_ctx BN_CTX; +typedef struct bn_blinding_st BN_BLINDING; +typedef struct bn_mont_ctx_st BN_MONT_CTX; +typedef struct bn_recp_ctx_st BN_RECP_CTX; +typedef struct bn_gencb_st BN_GENCB; + +typedef struct buf_mem_st BUF_MEM; + +typedef struct evp_cipher_st EVP_CIPHER; +typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; +typedef struct env_md_st EVP_MD; +typedef struct env_md_ctx_st EVP_MD_CTX; +typedef struct evp_pkey_st EVP_PKEY; + +typedef struct dh_st DH; +typedef struct dh_method DH_METHOD; + +typedef struct dsa_st DSA; +typedef struct dsa_method DSA_METHOD; + +typedef struct rsa_st RSA; +typedef struct rsa_meth_st RSA_METHOD; + +typedef struct rand_meth_st RAND_METHOD; + +typedef struct ecdh_method ECDH_METHOD; +typedef struct ecdsa_method ECDSA_METHOD; + +typedef struct x509_st X509; +typedef struct X509_algor_st X509_ALGOR; +typedef struct X509_crl_st X509_CRL; +typedef struct X509_name_st X509_NAME; +typedef struct x509_store_st X509_STORE; +typedef struct x509_store_ctx_st X509_STORE_CTX; + +typedef struct v3_ext_ctx X509V3_CTX; +typedef struct conf_st CONF; + +typedef struct store_st STORE; +typedef struct store_method_st STORE_METHOD; + +typedef struct ui_st UI; +typedef struct ui_method_st UI_METHOD; + +typedef struct st_ERR_FNS ERR_FNS; + +typedef struct engine_st ENGINE; + +typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; +typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; +typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; +typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; + + /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ +#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ +#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ + +typedef struct crypto_ex_data_st CRYPTO_EX_DATA; +/* Callback types for crypto.h */ +typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); + +#endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/libraries/external/openssl/pc/include/openssl/pem.h b/libraries/external/openssl/pc/include/openssl/pem.h new file mode 100755 index 0000000..c003eec --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/pem.h @@ -0,0 +1,737 @@ +/* crypto/pem/pem.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PEM_H +#define HEADER_PEM_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_STACK +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PEM_BUFSIZE 1024 + +#define PEM_OBJ_UNDEF 0 +#define PEM_OBJ_X509 1 +#define PEM_OBJ_X509_REQ 2 +#define PEM_OBJ_CRL 3 +#define PEM_OBJ_SSL_SESSION 4 +#define PEM_OBJ_PRIV_KEY 10 +#define PEM_OBJ_PRIV_RSA 11 +#define PEM_OBJ_PRIV_DSA 12 +#define PEM_OBJ_PRIV_DH 13 +#define PEM_OBJ_PUB_RSA 14 +#define PEM_OBJ_PUB_DSA 15 +#define PEM_OBJ_PUB_DH 16 +#define PEM_OBJ_DHPARAMS 17 +#define PEM_OBJ_DSAPARAMS 18 +#define PEM_OBJ_PRIV_RSA_PUBLIC 19 +#define PEM_OBJ_PRIV_ECDSA 20 +#define PEM_OBJ_PUB_ECDSA 21 +#define PEM_OBJ_ECPARAMETERS 22 + +#define PEM_ERROR 30 +#define PEM_DEK_DES_CBC 40 +#define PEM_DEK_IDEA_CBC 45 +#define PEM_DEK_DES_EDE 50 +#define PEM_DEK_DES_ECB 60 +#define PEM_DEK_RSA 70 +#define PEM_DEK_RSA_MD2 80 +#define PEM_DEK_RSA_MD5 90 + +#define PEM_MD_MD2 NID_md2 +#define PEM_MD_MD5 NID_md5 +#define PEM_MD_SHA NID_sha +#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption +#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption +#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption + +#define PEM_STRING_X509_OLD "X509 CERTIFICATE" +#define PEM_STRING_X509 "CERTIFICATE" +#define PEM_STRING_X509_PAIR "CERTIFICATE PAIR" +#define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" +#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" +#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" +#define PEM_STRING_X509_CRL "X509 CRL" +#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" +#define PEM_STRING_PUBLIC "PUBLIC KEY" +#define PEM_STRING_RSA "RSA PRIVATE KEY" +#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" +#define PEM_STRING_DSA "DSA PRIVATE KEY" +#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" +#define PEM_STRING_PKCS7 "PKCS7" +#define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" +#define PEM_STRING_PKCS8INF "PRIVATE KEY" +#define PEM_STRING_DHPARAMS "DH PARAMETERS" +#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" +#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" +#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" +#define PEM_STRING_ECPARAMETERS "EC PARAMETERS" +#define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" + + /* Note that this structure is initialised by PEM_SealInit and cleaned up + by PEM_SealFinal (at least for now) */ +typedef struct PEM_Encode_Seal_st + { + EVP_ENCODE_CTX encode; + EVP_MD_CTX md; + EVP_CIPHER_CTX cipher; + } PEM_ENCODE_SEAL_CTX; + +/* enc_type is one off */ +#define PEM_TYPE_ENCRYPTED 10 +#define PEM_TYPE_MIC_ONLY 20 +#define PEM_TYPE_MIC_CLEAR 30 +#define PEM_TYPE_CLEAR 40 + +typedef struct pem_recip_st + { + char *name; + X509_NAME *dn; + + int cipher; + int key_enc; + /* char iv[8]; unused and wrong size */ + } PEM_USER; + +typedef struct pem_ctx_st + { + int type; /* what type of object */ + + struct { + int version; + int mode; + } proc_type; + + char *domain; + + struct { + int cipher; + /* unused, and wrong size + unsigned char iv[8]; */ + } DEK_info; + + PEM_USER *originator; + + int num_recipient; + PEM_USER **recipient; + +#ifndef OPENSSL_NO_STACK + STACK *x509_chain; /* certificate chain */ +#else + char *x509_chain; /* certificate chain */ +#endif + EVP_MD *md; /* signature type */ + + int md_enc; /* is the md encrypted or not? */ + int md_len; /* length of md_data */ + char *md_data; /* message digest, could be pkey encrypted */ + + EVP_CIPHER *dec; /* date encryption cipher */ + int key_len; /* key length */ + unsigned char *key; /* key */ + /* unused, and wrong size + unsigned char iv[8]; */ + + + int data_enc; /* is the data encrypted */ + int data_len; + unsigned char *data; + } PEM_CTX; + +/* These macros make the PEM_read/PEM_write functions easier to maintain and + * write. Now they are all implemented with either: + * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) + */ + +#ifdef OPENSSL_NO_FP_API + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ + +#else + +#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ +type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ +int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, \ + void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ + } + +#endif + +#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ +type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ +{ \ +return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \ +} + +#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x) \ +{ \ +return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, const type *x) \ +{ \ +return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ +} + +#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ +int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ + { \ + return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ + } + +#define IMPLEMENT_PEM_write(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_read_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_const(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb(name, type, str, asn1) + +/* These are the same except they are for the declarations */ + +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API) + +#define DECLARE_PEM_read_fp(name, type) /**/ +#define DECLARE_PEM_write_fp(name, type) /**/ +#define DECLARE_PEM_write_cb_fp(name, type) /**/ + +#else + +#define DECLARE_PEM_read_fp(name, type) \ + type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x); + +#define DECLARE_PEM_write_fp_const(name, type) \ + int PEM_write_##name(FILE *fp, const type *x); + +#define DECLARE_PEM_write_cb_fp(name, type) \ + int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#endif + +#ifndef OPENSSL_NO_BIO +#define DECLARE_PEM_read_bio(name, type) \ + type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); + +#define DECLARE_PEM_write_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x); + +#define DECLARE_PEM_write_bio_const(name, type) \ + int PEM_write_bio_##name(BIO *bp, const type *x); + +#define DECLARE_PEM_write_cb_bio(name, type) \ + int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ + unsigned char *kstr, int klen, pem_password_cb *cb, void *u); + +#else + +#define DECLARE_PEM_read_bio(name, type) /**/ +#define DECLARE_PEM_write_bio(name, type) /**/ +#define DECLARE_PEM_write_cb_bio(name, type) /**/ + +#endif + +#define DECLARE_PEM_write(name, type) \ + DECLARE_PEM_write_bio(name, type) \ + DECLARE_PEM_write_fp(name, type) + +#define DECLARE_PEM_write_const(name, type) \ + DECLARE_PEM_write_bio_const(name, type) \ + DECLARE_PEM_write_fp_const(name, type) + +#define DECLARE_PEM_write_cb(name, type) \ + DECLARE_PEM_write_cb_bio(name, type) \ + DECLARE_PEM_write_cb_fp(name, type) + +#define DECLARE_PEM_read(name, type) \ + DECLARE_PEM_read_bio(name, type) \ + DECLARE_PEM_read_fp(name, type) + +#define DECLARE_PEM_rw(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write(name, type) + +#define DECLARE_PEM_rw_const(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_const(name, type) + +#define DECLARE_PEM_rw_cb(name, type) \ + DECLARE_PEM_read(name, type) \ + DECLARE_PEM_write_cb(name, type) + +#ifdef SSLEAY_MACROS + +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_X509_CRL(fp,x) \ + PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \ + fp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_RSAPublicKey(fp,x) \ + PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\ + PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\ + (char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_PKCS7(fp,x) \ + PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_DHparams(fp,x) \ + PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\ + (char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_NETSCAPE_CERT_SEQUENCE(fp,x) \ + PEM_ASN1_write((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,fp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_X509(fp,x,cb,u) (X509 *)PEM_ASN1_read( \ + (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb,u) +#define PEM_read_X509_REQ(fp,x,cb,u) (X509_REQ *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb,u) +#define PEM_read_X509_CRL(fp,x,cb,u) (X509_CRL *)PEM_ASN1_read( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb,u) +#define PEM_read_RSAPrivateKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb,u) +#define PEM_read_RSAPublicKey(fp,x,cb,u) (RSA *)PEM_ASN1_read( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb,u) +#define PEM_read_DSAPrivateKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb,u) +#define PEM_read_PrivateKey(fp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb,u) +#define PEM_read_PKCS7(fp,x,cb,u) (PKCS7 *)PEM_ASN1_read( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb,u) +#define PEM_read_DHparams(fp,x,cb,u) (DH *)PEM_ASN1_read( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb,u) + +#define PEM_read_NETSCAPE_CERT_SEQUENCE(fp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\ + (char **)x,cb,u) + +#define PEM_write_bio_X509(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \ + (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \ + NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_X509_CRL(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\ + bp,(char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_RSAPublicKey(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \ + PEM_STRING_RSA_PUBLIC,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb,u) \ + PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\ + (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\ + bp,(char *)x,enc,kstr,klen,cb,u) +#define PEM_write_bio_PKCS7(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DHparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\ + bp,(char *)x,NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_DSAparams(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \ + PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL,NULL) + +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE(bp,x) \ + PEM_ASN1_write_bio((int (*)())i2d_NETSCAPE_CERT_SEQUENCE, \ + PEM_STRING_X509,bp, \ + (char *)x, NULL,NULL,0,NULL,NULL) + +#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb,u) +#define PEM_read_bio_X509_CRL(bp,x,cb,u) (X509_CRL *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPrivateKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb,u) +#define PEM_read_bio_RSAPublicKey(bp,x,cb,u) (RSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAPrivateKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb,u) +#define PEM_read_bio_PrivateKey(bp,x,cb,u) (EVP_PKEY *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb,u) + +#define PEM_read_bio_PKCS7(bp,x,cb,u) (PKCS7 *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb,u) +#define PEM_read_bio_DHparams(bp,x,cb,u) (DH *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb,u) +#define PEM_read_bio_DSAparams(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb,u) + +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE(bp,x,cb,u) \ + (NETSCAPE_CERT_SEQUENCE *)PEM_ASN1_read_bio( \ + (char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,bp,\ + (char **)x,cb,u) + +#endif + +#if 1 +/* "userdata": new with OpenSSL 0.9.4 */ +typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata); +#else +/* OpenSSL 0.9.3, 0.9.3a */ +typedef int pem_password_cb(char *buf, int size, int rwflag); +#endif + +int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); +int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, + pem_password_cb *callback,void *u); + +#ifndef OPENSSL_NO_BIO +int PEM_read_bio(BIO *bp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, + long len); +int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, + pem_password_cb *cb, void *u); +void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, + void **x, pem_password_cb *cb, void *u); +#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ +((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u) +int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, + const EVP_CIPHER *enc,unsigned char *kstr,int klen, + pem_password_cb *cb, void *u); +#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ + ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u) + +STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); +int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, + unsigned char *kstr, int klen, pem_password_cb *cd, void *u); +#endif + +#ifndef OPENSSL_SYS_WIN16 +int PEM_read(FILE *fp, char **name, char **header, + unsigned char **data,long *len); +int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); +void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write(i2d_of_void *i2d,const char *name,FILE *fp, + char *x,const EVP_CIPHER *enc,unsigned char *kstr, + int klen,pem_password_cb *callback, void *u); +STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, + pem_password_cb *cb, void *u); +#endif + +int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, + EVP_MD *md_type, unsigned char **ek, int *ekl, + unsigned char *iv, EVP_PKEY **pubk, int npubk); +void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, + unsigned char *in, int inl); +int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl, + unsigned char *out, int *outl, EVP_PKEY *priv); + +void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); +void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + unsigned int *siglen, EVP_PKEY *pkey); + +int PEM_def_callback(char *buf, int num, int w, void *key); +void PEM_proc_type(char *buf, int type); +void PEM_dek_info(char *buf, const char *type, int len, char *str); + +#ifndef SSLEAY_MACROS + +#include + +DECLARE_PEM_rw(X509, X509) + +DECLARE_PEM_rw(X509_AUX, X509) + +DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR) + +DECLARE_PEM_rw(X509_REQ, X509_REQ) +DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) + +DECLARE_PEM_rw(X509_CRL, X509_CRL) + +DECLARE_PEM_rw(PKCS7, PKCS7) + +DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) + +DECLARE_PEM_rw(PKCS8, X509_SIG) + +DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) + +#ifndef OPENSSL_NO_RSA + +DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) + +DECLARE_PEM_rw_const(RSAPublicKey, RSA) +DECLARE_PEM_rw(RSA_PUBKEY, RSA) + +#endif + +#ifndef OPENSSL_NO_DSA + +DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) + +DECLARE_PEM_rw(DSA_PUBKEY, DSA) + +DECLARE_PEM_rw_const(DSAparams, DSA) + +#endif + +#ifndef OPENSSL_NO_EC +DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) +DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) +DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) +#endif + +#ifndef OPENSSL_NO_DH + +DECLARE_PEM_rw_const(DHparams, DH) + +#endif + +DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) + +DECLARE_PEM_rw(PUBKEY, EVP_PKEY) + +int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, + char *, int, pem_password_cb *, void *); +int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, + char *kstr, int klen, + pem_password_cb *cb, void *u); + +EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); + +int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, + char *kstr,int klen, pem_password_cb *cd, void *u); + +#endif /* SSLEAY_MACROS */ + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PEM_strings(void); + +/* Error codes for the PEM functions. */ + +/* Function codes. */ +#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 +#define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 +#define PEM_F_DO_PK8PKEY 126 +#define PEM_F_DO_PK8PKEY_FP 125 +#define PEM_F_LOAD_IV 101 +#define PEM_F_PEM_ASN1_READ 102 +#define PEM_F_PEM_ASN1_READ_BIO 103 +#define PEM_F_PEM_ASN1_WRITE 104 +#define PEM_F_PEM_ASN1_WRITE_BIO 105 +#define PEM_F_PEM_DEF_CALLBACK 100 +#define PEM_F_PEM_DO_HEADER 106 +#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY 118 +#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 +#define PEM_F_PEM_PK8PKEY 119 +#define PEM_F_PEM_READ 108 +#define PEM_F_PEM_READ_BIO 109 +#define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 +#define PEM_F_PEM_READ_PRIVATEKEY 124 +#define PEM_F_PEM_SEALFINAL 110 +#define PEM_F_PEM_SEALINIT 111 +#define PEM_F_PEM_SIGNFINAL 112 +#define PEM_F_PEM_WRITE 113 +#define PEM_F_PEM_WRITE_BIO 114 +#define PEM_F_PEM_X509_INFO_READ 115 +#define PEM_F_PEM_X509_INFO_READ_BIO 116 +#define PEM_F_PEM_X509_INFO_WRITE_BIO 117 + +/* Reason codes. */ +#define PEM_R_BAD_BASE64_DECODE 100 +#define PEM_R_BAD_DECRYPT 101 +#define PEM_R_BAD_END_LINE 102 +#define PEM_R_BAD_IV_CHARS 103 +#define PEM_R_BAD_PASSWORD_READ 104 +#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 +#define PEM_R_NOT_DEK_INFO 105 +#define PEM_R_NOT_ENCRYPTED 106 +#define PEM_R_NOT_PROC_TYPE 107 +#define PEM_R_NO_START_LINE 108 +#define PEM_R_PROBLEMS_GETTING_PASSWORD 109 +#define PEM_R_PUBLIC_KEY_NO_RSA 110 +#define PEM_R_READ_KEY 111 +#define PEM_R_SHORT_HEADER 112 +#define PEM_R_UNSUPPORTED_CIPHER 113 +#define PEM_R_UNSUPPORTED_ENCRYPTION 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/pem2.h b/libraries/external/openssl/pc/include/openssl/pem2.h new file mode 100755 index 0000000..97ba68a --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/pem2.h @@ -0,0 +1,70 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* + * This header only exists to break a circular dependency between pem and err + * Ben 30 Jan 1999. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HEADER_PEM_H +void ERR_load_PEM_strings(void); +#endif + +#ifdef __cplusplus +} +#endif diff --git a/libraries/external/openssl/pc/include/openssl/pkcs12.h b/libraries/external/openssl/pc/include/openssl/pkcs12.h new file mode 100755 index 0000000..46d8dad --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/pkcs12.h @@ -0,0 +1,333 @@ +/* pkcs12.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PKCS12_H +#define HEADER_PKCS12_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PKCS12_KEY_ID 1 +#define PKCS12_IV_ID 2 +#define PKCS12_MAC_ID 3 + +/* Default iteration count */ +#ifndef PKCS12_DEFAULT_ITER +#define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER +#endif + +#define PKCS12_MAC_KEY_LENGTH 20 + +#define PKCS12_SALT_LEN 8 + +/* Uncomment out next line for unicode password and names, otherwise ASCII */ + +/*#define PBE_UNICODE*/ + +#ifdef PBE_UNICODE +#define PKCS12_key_gen PKCS12_key_gen_uni +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni +#else +#define PKCS12_key_gen PKCS12_key_gen_asc +#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc +#endif + +/* MS key usage constants */ + +#define KEY_EX 0x10 +#define KEY_SIG 0x80 + +typedef struct { +X509_SIG *dinfo; +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; /* defaults to 1 */ +} PKCS12_MAC_DATA; + +typedef struct { +ASN1_INTEGER *version; +PKCS12_MAC_DATA *mac; +PKCS7 *authsafes; +} PKCS12; + +PREDECLARE_STACK_OF(PKCS12_SAFEBAG) + +typedef struct { +ASN1_OBJECT *type; +union { + struct pkcs12_bag_st *bag; /* secret, crl and certbag */ + struct pkcs8_priv_key_info_st *keybag; /* keybag */ + X509_SIG *shkeybag; /* shrouded key bag */ + STACK_OF(PKCS12_SAFEBAG) *safes; + ASN1_TYPE *other; +}value; +STACK_OF(X509_ATTRIBUTE) *attrib; +} PKCS12_SAFEBAG; + +DECLARE_STACK_OF(PKCS12_SAFEBAG) +DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG) +DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG) + +typedef struct pkcs12_bag_st { +ASN1_OBJECT *type; +union { + ASN1_OCTET_STRING *x509cert; + ASN1_OCTET_STRING *x509crl; + ASN1_OCTET_STRING *octet; + ASN1_IA5STRING *sdsicert; + ASN1_TYPE *other; /* Secret or other bag */ +}value; +} PKCS12_BAGS; + +#define PKCS12_ERROR 0 +#define PKCS12_OK 1 + +/* Compatibility macros */ + +#define M_PKCS12_x5092certbag PKCS12_x5092certbag +#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag + +#define M_PKCS12_certbag2x509 PKCS12_certbag2x509 +#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl + +#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data +#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes +#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes +#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata + +#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey +#define M_PKCS8_decrypt PKCS8_decrypt + +#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type) +#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type) +#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type + +#define PKCS12_get_attr(bag, attr_nid) \ + PKCS12_get_attr_gen(bag->attrib, attr_nid) + +#define PKCS8_get_attr(p8, attr_nid) \ + PKCS12_get_attr_gen(p8->attributes, attr_nid) + +#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) + + +PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509); +PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl); +X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag); +X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag); + +PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, + int nid2); +PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, + int passlen); +X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, + int passlen, unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); +PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) *bags); +STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); + +int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); +STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12); + +int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); +int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, + int namelen); +int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); +ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid); +char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); +unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, + int passlen, unsigned char *in, int inlen, + unsigned char **data, int *datalen, int en_de); +void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf); +PKCS12 *PKCS12_init(int mode); +int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); +int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type, + int en_de); +int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *mac, unsigned int *maclen); +int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); +int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type); +int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, + int saltlen, const EVP_MD *md_type); +unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); +char *uni2asc(unsigned char *uni, int unilen); + +DECLARE_ASN1_FUNCTIONS(PKCS12) +DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) +DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) +DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) + +DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) +DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) + +void PKCS12_PBE_add(void); +int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, + STACK_OF(X509) **ca); +PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, + STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, + int mac_iter, int keytype); + +PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); +PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, + int key_usage, int iter, + int key_nid, char *pass); +int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, + int safe_nid, int iter, char *pass); +PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); + +int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); +int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); +PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); +PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); +int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS12_strings(void); + +/* Error codes for the PKCS12 functions. */ + +/* Function codes. */ +#define PKCS12_F_PARSE_BAG 129 +#define PKCS12_F_PARSE_BAGS 103 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME 100 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC 127 +#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI 102 +#define PKCS12_F_PKCS12_ADD_LOCALKEYID 104 +#define PKCS12_F_PKCS12_CREATE 105 +#define PKCS12_F_PKCS12_GEN_MAC 107 +#define PKCS12_F_PKCS12_INIT 109 +#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 +#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 +#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 +#define PKCS12_F_PKCS12_KEY_GEN_ASC 110 +#define PKCS12_F_PKCS12_KEY_GEN_UNI 111 +#define PKCS12_F_PKCS12_MAKE_KEYBAG 112 +#define PKCS12_F_PKCS12_MAKE_SHKEYBAG 113 +#define PKCS12_F_PKCS12_NEWPASS 128 +#define PKCS12_F_PKCS12_PACK_P7DATA 114 +#define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 +#define PKCS12_F_PKCS12_PARSE 118 +#define PKCS12_F_PKCS12_PBE_CRYPT 119 +#define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 +#define PKCS12_F_PKCS12_SETUP_MAC 122 +#define PKCS12_F_PKCS12_SET_MAC 123 +#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 +#define PKCS12_F_PKCS12_UNPACK_P7DATA 131 +#define PKCS12_F_PKCS12_VERIFY_MAC 126 +#define PKCS12_F_PKCS8_ADD_KEYUSAGE 124 +#define PKCS12_F_PKCS8_ENCRYPT 125 + +/* Reason codes. */ +#define PKCS12_R_CANT_PACK_STRUCTURE 100 +#define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 +#define PKCS12_R_DECODE_ERROR 101 +#define PKCS12_R_ENCODE_ERROR 102 +#define PKCS12_R_ENCRYPT_ERROR 103 +#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 +#define PKCS12_R_INVALID_NULL_ARGUMENT 104 +#define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 +#define PKCS12_R_IV_GEN_ERROR 106 +#define PKCS12_R_KEY_GEN_ERROR 107 +#define PKCS12_R_MAC_ABSENT 108 +#define PKCS12_R_MAC_GENERATION_ERROR 109 +#define PKCS12_R_MAC_SETUP_ERROR 110 +#define PKCS12_R_MAC_STRING_SET_ERROR 111 +#define PKCS12_R_MAC_VERIFY_ERROR 112 +#define PKCS12_R_MAC_VERIFY_FAILURE 113 +#define PKCS12_R_PARSE_ERROR 114 +#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 +#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 +#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 +#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 +#define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/pkcs7.h b/libraries/external/openssl/pc/include/openssl/pkcs7.h new file mode 100755 index 0000000..eeb0532 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/pkcs7.h @@ -0,0 +1,464 @@ +/* crypto/pkcs7/pkcs7.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_PKCS7_H +#define HEADER_PKCS7_H + +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 thes are defined in wincrypt.h */ +#undef PKCS7_ISSUER_AND_SERIAL +#undef PKCS7_SIGNER_INFO +#endif + +/* +Encryption_ID DES-CBC +Digest_ID MD5 +Digest_Encryption_ID rsaEncryption +Key_Encryption_ID rsaEncryption +*/ + +typedef struct pkcs7_issuer_and_serial_st + { + X509_NAME *issuer; + ASN1_INTEGER *serial; + } PKCS7_ISSUER_AND_SERIAL; + +typedef struct pkcs7_signer_info_st + { + ASN1_INTEGER *version; /* version 1 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *digest_alg; + STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ + X509_ALGOR *digest_enc_alg; + ASN1_OCTET_STRING *enc_digest; + STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ + + /* The private key to sign with */ + EVP_PKEY *pkey; + } PKCS7_SIGNER_INFO; + +DECLARE_STACK_OF(PKCS7_SIGNER_INFO) +DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) + +typedef struct pkcs7_recip_info_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *key_enc_algor; + ASN1_OCTET_STRING *enc_key; + X509 *cert; /* get the pub-key from this */ + } PKCS7_RECIP_INFO; + +DECLARE_STACK_OF(PKCS7_RECIP_INFO) +DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) + +typedef struct pkcs7_signed_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + struct pkcs7_st *contents; + } PKCS7_SIGNED; +/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE. + * How about merging the two */ + +typedef struct pkcs7_enc_content_st + { + ASN1_OBJECT *content_type; + X509_ALGOR *algorithm; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + const EVP_CIPHER *cipher; + } PKCS7_ENC_CONTENT; + +typedef struct pkcs7_enveloped_st + { + ASN1_INTEGER *version; /* version 0 */ + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENVELOPE; + +typedef struct pkcs7_signedandenveloped_st + { + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) *md_algs; /* md used */ + STACK_OF(X509) *cert; /* [ 0 ] */ + STACK_OF(X509_CRL) *crl; /* [ 1 ] */ + STACK_OF(PKCS7_SIGNER_INFO) *signer_info; + + PKCS7_ENC_CONTENT *enc_data; + STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; + } PKCS7_SIGN_ENVELOPE; + +typedef struct pkcs7_digest_st + { + ASN1_INTEGER *version; /* version 0 */ + X509_ALGOR *md; /* md used */ + struct pkcs7_st *contents; + ASN1_OCTET_STRING *digest; + } PKCS7_DIGEST; + +typedef struct pkcs7_encrypted_st + { + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ENC_CONTENT *enc_data; + } PKCS7_ENCRYPT; + +typedef struct pkcs7_st + { + /* The following is non NULL if it contains ASN1 encoding of + * this structure */ + unsigned char *asn1; + long length; + +#define PKCS7_S_HEADER 0 +#define PKCS7_S_BODY 1 +#define PKCS7_S_TAIL 2 + int state; /* used during processing */ + + int detached; + + ASN1_OBJECT *type; + /* content as defined by the type */ + /* all encryption/message digests are applied to the 'contents', + * leaving out the 'type' field. */ + union { + char *ptr; + + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + + /* NID_pkcs7_signed */ + PKCS7_SIGNED *sign; + + /* NID_pkcs7_enveloped */ + PKCS7_ENVELOPE *enveloped; + + /* NID_pkcs7_signedAndEnveloped */ + PKCS7_SIGN_ENVELOPE *signed_and_enveloped; + + /* NID_pkcs7_digest */ + PKCS7_DIGEST *digest; + + /* NID_pkcs7_encrypted */ + PKCS7_ENCRYPT *encrypted; + + /* Anything else */ + ASN1_TYPE *other; + } d; + } PKCS7; + +DECLARE_STACK_OF(PKCS7) +DECLARE_ASN1_SET_OF(PKCS7) +DECLARE_PKCS12_STACK_OF(PKCS7) + +#define PKCS7_OP_SET_DETACHED_SIGNATURE 1 +#define PKCS7_OP_GET_DETACHED_SIGNATURE 2 + +#define PKCS7_get_signed_attributes(si) ((si)->auth_attr) +#define PKCS7_get_attributes(si) ((si)->unauth_attr) + +#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) +#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) +#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +#define PKCS7_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) + +#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) + +#define PKCS7_set_detached(p,v) \ + PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) +#define PKCS7_get_detached(p) \ + PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) + +#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) + +#ifdef SSLEAY_MACROS +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +/* S/MIME related flags */ + +#define PKCS7_TEXT 0x1 +#define PKCS7_NOCERTS 0x2 +#define PKCS7_NOSIGS 0x4 +#define PKCS7_NOCHAIN 0x8 +#define PKCS7_NOINTERN 0x10 +#define PKCS7_NOVERIFY 0x20 +#define PKCS7_DETACHED 0x40 +#define PKCS7_BINARY 0x80 +#define PKCS7_NOATTR 0x100 +#define PKCS7_NOSMIMECAP 0x200 +#define PKCS7_NOOLDMIMETYPE 0x400 +#define PKCS7_CRLFEOL 0x800 +#define PKCS7_STREAM 0x1000 +#define PKCS7_NOCRL 0x2000 + +/* Flags: for compatibility with older code */ + +#define SMIME_TEXT PKCS7_TEXT +#define SMIME_NOCERTS PKCS7_NOCERTS +#define SMIME_NOSIGS PKCS7_NOSIGS +#define SMIME_NOCHAIN PKCS7_NOCHAIN +#define SMIME_NOINTERN PKCS7_NOINTERN +#define SMIME_NOVERIFY PKCS7_NOVERIFY +#define SMIME_DETACHED PKCS7_DETACHED +#define SMIME_BINARY PKCS7_BINARY +#define SMIME_NOATTR PKCS7_NOATTR + +DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) + +#ifndef SSLEAY_MACROS +int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, + unsigned char *md,unsigned int *len); +#ifndef OPENSSL_NO_FP_API +PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); +int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7); +#endif +PKCS7 *PKCS7_dup(PKCS7 *p7); +PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7); +int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); +#endif + +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) +DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) +DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) +DECLARE_ASN1_FUNCTIONS(PKCS7) + +DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) +DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) + +DECLARE_ASN1_NDEF_FUNCTION(PKCS7) + +long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); + +int PKCS7_set_type(PKCS7 *p7, int type); +int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); +int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); +int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); +int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); +int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); +int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); +int PKCS7_content_new(PKCS7 *p7, int nid); +int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, + BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, + X509 *x509); + +BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); +int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); +BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); + + +PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, + EVP_PKEY *pkey, const EVP_MD *dgst); +X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); +STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); + +PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); +int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); +int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); +int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); + +PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); +ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si,int nid,int type, + void *data); +int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, + void *value); +ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); +ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); +int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) *sk); +int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,STACK_OF(X509_ATTRIBUTE) *sk); + + +PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, + BIO *data, int flags); +int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, + BIO *indata, BIO *out, int flags); +STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); +PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, + int flags); +int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); + +int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, + STACK_OF(X509_ALGOR) *cap); +STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); +int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); + +int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); +PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); +int SMIME_crlf_copy(BIO *in, BIO *out, int flags); +int SMIME_text(BIO *in, BIO *out); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_PKCS7_strings(void); + +/* Error codes for the PKCS7 functions. */ + +/* Function codes. */ +#define PKCS7_F_B64_READ_PKCS7 120 +#define PKCS7_F_B64_WRITE_PKCS7 121 +#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 +#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 +#define PKCS7_F_PKCS7_ADD_CRL 101 +#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 +#define PKCS7_F_PKCS7_ADD_SIGNER 103 +#define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 +#define PKCS7_F_PKCS7_CTRL 104 +#define PKCS7_F_PKCS7_DATADECODE 112 +#define PKCS7_F_PKCS7_DATAFINAL 128 +#define PKCS7_F_PKCS7_DATAINIT 105 +#define PKCS7_F_PKCS7_DATASIGN 106 +#define PKCS7_F_PKCS7_DATAVERIFY 107 +#define PKCS7_F_PKCS7_DECRYPT 114 +#define PKCS7_F_PKCS7_ENCRYPT 115 +#define PKCS7_F_PKCS7_FIND_DIGEST 127 +#define PKCS7_F_PKCS7_GET0_SIGNERS 124 +#define PKCS7_F_PKCS7_SET_CIPHER 108 +#define PKCS7_F_PKCS7_SET_CONTENT 109 +#define PKCS7_F_PKCS7_SET_DIGEST 126 +#define PKCS7_F_PKCS7_SET_TYPE 110 +#define PKCS7_F_PKCS7_SIGN 116 +#define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 +#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 +#define PKCS7_F_PKCS7_VERIFY 117 +#define PKCS7_F_SMIME_READ_PKCS7 122 +#define PKCS7_F_SMIME_TEXT 123 + +/* Reason codes. */ +#define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 +#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 +#define PKCS7_R_CIPHER_NOT_INITIALIZED 116 +#define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 +#define PKCS7_R_DECODE_ERROR 130 +#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH 100 +#define PKCS7_R_DECRYPT_ERROR 119 +#define PKCS7_R_DIGEST_FAILURE 101 +#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 +#define PKCS7_R_ERROR_SETTING_CIPHER 121 +#define PKCS7_R_INVALID_MIME_TYPE 131 +#define PKCS7_R_INVALID_NULL_POINTER 143 +#define PKCS7_R_MIME_NO_CONTENT_TYPE 132 +#define PKCS7_R_MIME_PARSE_ERROR 133 +#define PKCS7_R_MIME_SIG_PARSE_ERROR 134 +#define PKCS7_R_MISSING_CERIPEND_INFO 103 +#define PKCS7_R_NO_CONTENT 122 +#define PKCS7_R_NO_CONTENT_TYPE 135 +#define PKCS7_R_NO_MULTIPART_BODY_FAILURE 136 +#define PKCS7_R_NO_MULTIPART_BOUNDARY 137 +#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 +#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY 146 +#define PKCS7_R_NO_SIGNATURES_ON_DATA 123 +#define PKCS7_R_NO_SIGNERS 142 +#define PKCS7_R_NO_SIG_CONTENT_TYPE 138 +#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 +#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 +#define PKCS7_R_PKCS7_DATAFINAL 126 +#define PKCS7_R_PKCS7_DATAFINAL_ERROR 125 +#define PKCS7_R_PKCS7_DATASIGN 145 +#define PKCS7_R_PKCS7_PARSE_ERROR 139 +#define PKCS7_R_PKCS7_SIG_PARSE_ERROR 140 +#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 +#define PKCS7_R_SIGNATURE_FAILURE 105 +#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 +#define PKCS7_R_SIG_INVALID_MIME_TYPE 141 +#define PKCS7_R_SMIME_TEXT_ERROR 129 +#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 +#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 +#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 +#define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 +#define PKCS7_R_UNKNOWN_OPERATION 110 +#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 +#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 +#define PKCS7_R_WRONG_CONTENT_TYPE 113 +#define PKCS7_R_WRONG_PKCS7_TYPE 114 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/pq_compat.h b/libraries/external/openssl/pc/include/openssl/pq_compat.h new file mode 100755 index 0000000..2075042 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/pq_compat.h @@ -0,0 +1,147 @@ +/* crypto/pqueue/pqueue_compat.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include "opensslconf.h" +#include + +/* + * The purpose of this header file is for supporting 64-bit integer + * manipulation on 32-bit (and lower) machines. Currently the only + * such environment is VMS, Utrix and those with smaller default integer + * sizes than 32 bits. For all such environment, we fall back to using + * BIGNUM. We may need to fine tune the conditions for systems that + * are incorrectly configured. + * + * The only clients of this code are (1) pqueue for priority, and + * (2) DTLS, for sequence number manipulation. + */ + +#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT) + +#define PQ_64BIT_IS_INTEGER 0 +#define PQ_64BIT_IS_BIGNUM 1 + +#define PQ_64BIT BIGNUM +#define PQ_64BIT_CTX BN_CTX + +#define pq_64bit_init(x) BN_init(x) +#define pq_64bit_free(x) BN_free(x) + +#define pq_64bit_ctx_new(ctx) BN_CTX_new() +#define pq_64bit_ctx_free(x) BN_CTX_free(x) + +#define pq_64bit_assign(x, y) BN_copy(x, y) +#define pq_64bit_assign_word(x, y) BN_set_word(x, y) +#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0 +#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0 +#define pq_64bit_add_word(x, w) BN_add_word(x, w) +#define pq_64bit_sub(r, x, y) BN_sub(r, x, y) +#define pq_64bit_sub_word(x, w) BN_sub_word(x, w) +#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn) +#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes) +#define pq_64bit_get_word(x) BN_get_word(x) +#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset) +#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift) +#define pq_64bit_set_bit(x, num) BN_set_bit(x, num) +#define pq_64bit_get_length(x) BN_num_bits((x)) + +#else + +#define PQ_64BIT_IS_INTEGER 1 +#define PQ_64BIT_IS_BIGNUM 0 + +#if defined(SIXTY_FOUR_BIT) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%lld" +#elif defined(SIXTY_FOUR_BIT_LONG) +#define PQ_64BIT BN_ULONG +#define PQ_64BIT_PRINT "%ld" +#elif defined(THIRTY_TWO_BIT) +#define PQ_64BIT BN_ULLONG +#define PQ_64BIT_PRINT "%lld" +#endif + +#define PQ_64BIT_CTX void + +#define pq_64bit_init(x) +#define pq_64bit_free(x) +#define pq_64bit_ctx_new(ctx) (ctx) +#define pq_64bit_ctx_free(x) + +#define pq_64bit_assign(x, y) (*(x) = *(y)) +#define pq_64bit_assign_word(x, y) (*(x) = y) +#define pq_64bit_gt(x, y) (*(x) > *(y)) +#define pq_64bit_eq(x, y) (*(x) == *(y)) +#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w))) +#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y))) +#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w))) +#define pq_64bit_mod(r, x, n, ctx) + +#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num) +#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes) +#define pq_64bit_get_word(x) *(x) +#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift))) +#define pq_64bit_set_bit(x, num) do { \ + PQ_64BIT mask = 1; \ + mask = mask << (num); \ + *(x) |= mask; \ + } while(0) +#endif /* OPENSSL_SYS_VMS */ diff --git a/libraries/external/openssl/pc/include/openssl/pqueue.h b/libraries/external/openssl/pc/include/openssl/pqueue.h new file mode 100755 index 0000000..699095f --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/pqueue.h @@ -0,0 +1,95 @@ +/* crypto/pqueue/pqueue.h */ +/* + * DTLS implementation written by Nagendra Modadugu + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + */ +/* ==================================================================== + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_PQUEUE_H +#define HEADER_PQUEUE_H + +#include +#include +#include + +#include + +typedef struct _pqueue *pqueue; + +typedef struct _pitem + { + PQ_64BIT priority; + void *data; + struct _pitem *next; + } pitem; + +typedef struct _pitem *piterator; + +pitem *pitem_new(PQ_64BIT priority, void *data); +void pitem_free(pitem *item); + +pqueue pqueue_new(void); +void pqueue_free(pqueue pq); + +pitem *pqueue_insert(pqueue pq, pitem *item); +pitem *pqueue_peek(pqueue pq); +pitem *pqueue_pop(pqueue pq); +pitem *pqueue_find(pqueue pq, PQ_64BIT priority); +pitem *pqueue_iterator(pqueue pq); +pitem *pqueue_next(piterator *iter); + +void pqueue_print(pqueue pq); + +#endif /* ! HEADER_PQUEUE_H */ diff --git a/libraries/external/openssl/pc/include/openssl/rand.h b/libraries/external/openssl/pc/include/openssl/rand.h new file mode 100755 index 0000000..e2f9f82 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/rand.h @@ -0,0 +1,140 @@ +/* crypto/rand/rand.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RAND_H +#define HEADER_RAND_H + +#include +#include +#include + +#if defined(OPENSSL_SYS_WINDOWS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_RAND_SIZE_T size_t +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct rand_meth_st RAND_METHOD; */ + +struct rand_meth_st + { + void (*seed)(const void *buf, int num); + int (*bytes)(unsigned char *buf, int num); + void (*cleanup)(void); + void (*add)(const void *buf, int num, double entropy); + int (*pseudorand)(unsigned char *buf, int num); + int (*status)(void); + }; + +#ifdef BN_DEBUG +extern int rand_predictable; +#endif + +int RAND_set_rand_method(const RAND_METHOD *meth); +const RAND_METHOD *RAND_get_rand_method(void); +#ifndef OPENSSL_NO_ENGINE +int RAND_set_rand_engine(ENGINE *engine); +#endif +RAND_METHOD *RAND_SSLeay(void); +void RAND_cleanup(void ); +int RAND_bytes(unsigned char *buf,int num); +int RAND_pseudo_bytes(unsigned char *buf,int num); +void RAND_seed(const void *buf,int num); +void RAND_add(const void *buf,int num,double entropy); +int RAND_load_file(const char *file,long max_bytes); +int RAND_write_file(const char *file); +const char *RAND_file_name(char *file,size_t num); +int RAND_status(void); +int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); +int RAND_egd(const char *path); +int RAND_egd_bytes(const char *path,int bytes); +int RAND_poll(void); + +#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) + +void RAND_screen(void); +int RAND_event(UINT, WPARAM, LPARAM); + +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RAND_strings(void); + +/* Error codes for the RAND functions. */ + +/* Function codes. */ +#define RAND_F_RAND_GET_RAND_METHOD 101 +#define RAND_F_SSLEAY_RAND_BYTES 100 + +/* Reason codes. */ +#define RAND_R_PRNG_NOT_SEEDED 100 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/rc2.h b/libraries/external/openssl/pc/include/openssl/rc2.h new file mode 100755 index 0000000..13edfaf --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/rc2.h @@ -0,0 +1,101 @@ +/* crypto/rc2/rc2.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC2_H +#define HEADER_RC2_H + +#include /* OPENSSL_NO_RC2, RC2_INT */ +#ifdef OPENSSL_NO_RC2 +#error RC2 is disabled. +#endif + +#define RC2_ENCRYPT 1 +#define RC2_DECRYPT 0 + +#define RC2_BLOCK 8 +#define RC2_KEY_LENGTH 16 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc2_key_st + { + RC2_INT data[64]; + } RC2_KEY; + + +void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits); +void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key, + int enc); +void RC2_encrypt(unsigned long *data,RC2_KEY *key); +void RC2_decrypt(unsigned long *data,RC2_KEY *key); +void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, int enc); +void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num, int enc); +void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, RC2_KEY *schedule, unsigned char *ivec, + int *num); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/rc4.h b/libraries/external/openssl/pc/include/openssl/rc4.h new file mode 100755 index 0000000..676ffdb --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/rc4.h @@ -0,0 +1,87 @@ +/* crypto/rc4/rc4.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RC4_H +#define HEADER_RC4_H + +#include /* OPENSSL_NO_RC4, RC4_INT */ +#ifdef OPENSSL_NO_RC4 +#error RC4 is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rc4_key_st + { + RC4_INT x,y; + RC4_INT data[256]; + } RC4_KEY; + + +const char *RC4_options(void); +void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); +void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, + unsigned char *outdata); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ripemd.h b/libraries/external/openssl/pc/include/openssl/ripemd.h new file mode 100755 index 0000000..e0474f0 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ripemd.h @@ -0,0 +1,104 @@ +/* crypto/ripemd/ripemd.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RIPEMD_H +#define HEADER_RIPEMD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_NO_RIPEMD +#error RIPEMD is disabled. +#endif + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define RIPEMD160_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define RIPEMD160_LONG unsigned long +#define RIPEMD160_LONG_LOG2 3 +#else +#define RIPEMD160_LONG unsigned int +#endif + +#define RIPEMD160_CBLOCK 64 +#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) +#define RIPEMD160_DIGEST_LENGTH 20 + +typedef struct RIPEMD160state_st + { + RIPEMD160_LONG A,B,C,D,E; + RIPEMD160_LONG Nl,Nh; + RIPEMD160_LONG data[RIPEMD160_LBLOCK]; + unsigned int num; + } RIPEMD160_CTX; + +int RIPEMD160_Init(RIPEMD160_CTX *c); +int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); +int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); +unsigned char *RIPEMD160(const unsigned char *d, size_t n, + unsigned char *md); +void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/rsa.h b/libraries/external/openssl/pc/include/openssl/rsa.h new file mode 100755 index 0000000..f650681 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/rsa.h @@ -0,0 +1,441 @@ +/* crypto/rsa/rsa.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_RSA_H +#define HEADER_RSA_H + +#include + +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif + +#ifdef OPENSSL_NO_RSA +#error RSA is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct rsa_st RSA; */ +/* typedef struct rsa_meth_st RSA_METHOD; */ + +struct rsa_meth_st + { + const char *name; + int (*rsa_pub_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_pub_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_enc)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_priv_dec)(int flen,const unsigned char *from, + unsigned char *to, + RSA *rsa,int padding); + int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */ + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); /* Can be null */ + int (*init)(RSA *rsa); /* called at new */ + int (*finish)(RSA *rsa); /* called at free */ + int flags; /* RSA_METHOD_FLAG_* things */ + char *app_data; /* may be needed! */ +/* New sign and verify functions: some libraries don't allow arbitrary data + * to be signed/verified: this allows them to be used. Note: for this to work + * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used + * RSA_sign(), RSA_verify() should be used instead. Note: for backwards + * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER + * option is set in 'flags'. + */ + int (*rsa_sign)(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, const RSA *rsa); + int (*rsa_verify)(int dtype, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); +/* If this callback is NULL, the builtin software RSA key-gen will be used. This + * is for behavioural compatibility whilst the code gets rewired, but one day + * it would be nice to assume there are no such things as "builtin software" + * implementations. */ + int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + }; + +struct rsa_st + { + /* The first parameter is used to pickup errors where + * this is passed instead of aEVP_PKEY, it is set to 0 */ + int pad; + long version; + const RSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + BIGNUM *n; + BIGNUM *e; + BIGNUM *d; + BIGNUM *p; + BIGNUM *q; + BIGNUM *dmp1; + BIGNUM *dmq1; + BIGNUM *iqmp; + /* be careful using this if the RSA structure is shared */ + CRYPTO_EX_DATA ex_data; + int references; + int flags; + + /* Used to cache montgomery values */ + BN_MONT_CTX *_method_mod_n; + BN_MONT_CTX *_method_mod_p; + BN_MONT_CTX *_method_mod_q; + + /* all BIGNUM values are actually in the following data, if it is not + * NULL */ + char *bignum_data; + BN_BLINDING *blinding; + BN_BLINDING *mt_blinding; + }; + +#ifndef OPENSSL_RSA_MAX_MODULUS_BITS +# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 +#endif + +#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS +# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 +#endif +#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS +# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "large" modulus only */ +#endif + +#define RSA_3 0x3L +#define RSA_F4 0x10001L + +#define RSA_METHOD_FLAG_NO_CHECK 0x0001 /* don't check pub/private match */ + +#define RSA_FLAG_CACHE_PUBLIC 0x0002 +#define RSA_FLAG_CACHE_PRIVATE 0x0004 +#define RSA_FLAG_BLINDING 0x0008 +#define RSA_FLAG_THREAD_SAFE 0x0010 +/* This flag means the private key operations will be handled by rsa_mod_exp + * and that they do not depend on the private key components being present: + * for example a key stored in external hardware. Without this flag bn_mod_exp + * gets called when private key components are absent. + */ +#define RSA_FLAG_EXT_PKEY 0x0020 + +/* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions. + */ +#define RSA_FLAG_SIGN_VER 0x0040 + +#define RSA_FLAG_NO_BLINDING 0x0080 /* new with 0.9.6j and 0.9.7b; the built-in + * RSA implementation now uses blinding by + * default (ignoring RSA_FLAG_BLINDING), + * but other engines might not need it + */ +#define RSA_FLAG_NO_EXP_CONSTTIME 0x0100 /* new with 0.9.7h; the built-in RSA + * implementation now uses constant time + * modular exponentiation for secret exponents + * by default. This flag causes the + * faster variable sliding window method to + * be used for all exponents. + */ + +#define RSA_PKCS1_PADDING 1 +#define RSA_SSLV23_PADDING 2 +#define RSA_NO_PADDING 3 +#define RSA_PKCS1_OAEP_PADDING 4 +#define RSA_X931_PADDING 5 + +#define RSA_PKCS1_PADDING_SIZE 11 + +#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) +#define RSA_get_app_data(s) RSA_get_ex_data(s,0) + +RSA * RSA_new(void); +RSA * RSA_new_method(ENGINE *engine); +int RSA_size(const RSA *); + +/* Deprecated version */ +#ifndef OPENSSL_NO_DEPRECATED +RSA * RSA_generate_key(int bits, unsigned long e,void + (*callback)(int,int,void *),void *cb_arg); +#endif /* !defined(OPENSSL_NO_DEPRECATED) */ + +/* New version */ +int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + +int RSA_check_key(const RSA *); + /* next 4 return -1 on error */ +int RSA_public_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_encrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_public_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +int RSA_private_decrypt(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa,int padding); +void RSA_free (RSA *r); +/* "up" the RSA object's reference count */ +int RSA_up_ref(RSA *r); + +int RSA_flags(const RSA *r); + +void RSA_set_default_method(const RSA_METHOD *meth); +const RSA_METHOD *RSA_get_default_method(void); +const RSA_METHOD *RSA_get_method(const RSA *rsa); +int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); + +/* This function needs the memory locking malloc callbacks to be installed */ +int RSA_memory_lock(RSA *r); + +/* these are the actual SSLeay RSA functions */ +const RSA_METHOD *RSA_PKCS1_SSLeay(void); + +const RSA_METHOD *RSA_null_method(void); + +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) + +#ifndef OPENSSL_NO_FP_API +int RSA_print_fp(FILE *fp, const RSA *r,int offset); +#endif + +#ifndef OPENSSL_NO_BIO +int RSA_print(BIO *bp, const RSA *r,int offset); +#endif + +int i2d_RSA_NET(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); +RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, int verify), + int sgckey); + +int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); +RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, + int (*cb)(char *buf, int len, const char *prompt, + int verify)); + +/* The following 2 functions sign and verify a X509_SIG ASN1 object + * inside PKCS#1 padded RSA encryption */ +int RSA_sign(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify(int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +/* The following 2 function sign and verify a ASN1_OCTET_STRING + * object inside PKCS#1 padded RSA encryption */ +int RSA_sign_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_verify_ASN1_OCTET_STRING(int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigbuf, unsigned int siglen, RSA *rsa); + +int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); +void RSA_blinding_off(RSA *rsa); +BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); + +int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int PKCS1_MGF1(unsigned char *mask, long len, + const unsigned char *seed, long seedlen, const EVP_MD *dgst); +int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl, + const unsigned char *p,int pl); +int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len, + const unsigned char *p,int pl); +int RSA_padding_add_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_SSLv23(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_none(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_none(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_padding_add_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl); +int RSA_padding_check_X931(unsigned char *to,int tlen, + const unsigned char *f,int fl,int rsa_len); +int RSA_X931_hash_id(int nid); + +int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const unsigned char *EM, int sLen); +int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, int sLen); + +int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int RSA_set_ex_data(RSA *r,int idx,void *arg); +void *RSA_get_ex_data(const RSA *r, int idx); + +RSA *RSAPublicKey_dup(RSA *rsa); +RSA *RSAPrivateKey_dup(RSA *rsa); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_RSA_strings(void); + +/* Error codes for the RSA functions. */ + +/* Function codes. */ +#define RSA_F_MEMORY_LOCK 100 +#define RSA_F_RSA_BUILTIN_KEYGEN 129 +#define RSA_F_RSA_CHECK_KEY 123 +#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 +#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 +#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 +#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 +#define RSA_F_RSA_GENERATE_KEY 105 +#define RSA_F_RSA_MEMORY_LOCK 130 +#define RSA_F_RSA_NEW_METHOD 106 +#define RSA_F_RSA_NULL 124 +#define RSA_F_RSA_NULL_MOD_EXP 131 +#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 +#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 +#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 +#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 +#define RSA_F_RSA_PADDING_ADD_NONE 107 +#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 +#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 +#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 +#define RSA_F_RSA_PADDING_ADD_SSLV23 110 +#define RSA_F_RSA_PADDING_ADD_X931 127 +#define RSA_F_RSA_PADDING_CHECK_NONE 111 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 +#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 +#define RSA_F_RSA_PADDING_CHECK_SSLV23 114 +#define RSA_F_RSA_PADDING_CHECK_X931 128 +#define RSA_F_RSA_PRINT 115 +#define RSA_F_RSA_PRINT_FP 116 +#define RSA_F_RSA_SETUP_BLINDING 136 +#define RSA_F_RSA_SIGN 117 +#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 +#define RSA_F_RSA_VERIFY 119 +#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 +#define RSA_F_RSA_VERIFY_PKCS1_PSS 126 + +/* Reason codes. */ +#define RSA_R_ALGORITHM_MISMATCH 100 +#define RSA_R_BAD_E_VALUE 101 +#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 +#define RSA_R_BAD_PAD_BYTE_COUNT 103 +#define RSA_R_BAD_SIGNATURE 104 +#define RSA_R_BLOCK_TYPE_IS_NOT_01 106 +#define RSA_R_BLOCK_TYPE_IS_NOT_02 107 +#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 +#define RSA_R_DATA_TOO_LARGE 109 +#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 +#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 +#define RSA_R_DATA_TOO_SMALL 111 +#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 +#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 +#define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 +#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 +#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 +#define RSA_R_FIRST_OCTET_INVALID 133 +#define RSA_R_INVALID_HEADER 137 +#define RSA_R_INVALID_MESSAGE_LENGTH 131 +#define RSA_R_INVALID_PADDING 138 +#define RSA_R_INVALID_TRAILER 139 +#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 +#define RSA_R_KEY_SIZE_TOO_SMALL 120 +#define RSA_R_LAST_OCTET_INVALID 134 +#define RSA_R_MODULUS_TOO_LARGE 105 +#define RSA_R_NO_PUBLIC_EXPONENT 140 +#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 +#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 +#define RSA_R_OAEP_DECODING_ERROR 121 +#define RSA_R_PADDING_CHECK_FAILED 114 +#define RSA_R_P_NOT_PRIME 128 +#define RSA_R_Q_NOT_PRIME 129 +#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 +#define RSA_R_SLEN_CHECK_FAILED 136 +#define RSA_R_SLEN_RECOVERY_FAILED 135 +#define RSA_R_SSLV3_ROLLBACK_ATTACK 115 +#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 +#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 +#define RSA_R_UNKNOWN_PADDING_TYPE 118 +#define RSA_R_WRONG_SIGNATURE_LENGTH 119 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/safestack.h b/libraries/external/openssl/pc/include/openssl/safestack.h new file mode 100755 index 0000000..8515019 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/safestack.h @@ -0,0 +1,1850 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SAFESTACK_H +#define HEADER_SAFESTACK_H + +#include + +typedef void (*openssl_fptr)(void); +#define openssl_fcast(f) ((openssl_fptr)f) + +#ifdef DEBUG_SAFESTACK + +#define STACK_OF(type) struct stack_st_##type +#define PREDECLARE_STACK_OF(type) STACK_OF(type); + +#define DECLARE_STACK_OF(type) \ +STACK_OF(type) \ + { \ + STACK stack; \ + }; + +#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ + +/* SKM_sk_... stack macros are internal to safestack.h: + * never use them directly, use sk__... instead */ +#define SKM_sk_new(type, cmp) \ + ((STACK_OF(type) * (*)(int (*)(const type * const *, const type * const *)))openssl_fcast(sk_new))(cmp) +#define SKM_sk_new_null(type) \ + ((STACK_OF(type) * (*)(void))openssl_fcast(sk_new_null))() +#define SKM_sk_free(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_free))(st) +#define SKM_sk_num(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_num))(st) +#define SKM_sk_value(type, st,i) \ + ((type * (*)(const STACK_OF(type) *, int))openssl_fcast(sk_value))(st, i) +#define SKM_sk_set(type, st,i,val) \ + ((type * (*)(STACK_OF(type) *, int, type *))openssl_fcast(sk_set))(st, i, val) +#define SKM_sk_zero(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_zero))(st) +#define SKM_sk_push(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_push))(st, val) +#define SKM_sk_unshift(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_unshift))(st, val) +#define SKM_sk_find(type, st,val) \ + ((int (*)(STACK_OF(type) *, type *))openssl_fcast(sk_find))(st, val) +#define SKM_sk_delete(type, st,i) \ + ((type * (*)(STACK_OF(type) *, int))openssl_fcast(sk_delete))(st, i) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type * (*)(STACK_OF(type) *, type *))openssl_fcast(sk_delete_ptr))(st, ptr) +#define SKM_sk_insert(type, st,val,i) \ + ((int (*)(STACK_OF(type) *, type *, int))openssl_fcast(sk_insert))(st, val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*(*)(STACK_OF(type) *, int (*)(const type * const *, const type * const *))) \ + (const type * const *, const type * const *))openssl_fcast(sk_set_cmp_func))\ + (st, cmp) +#define SKM_sk_dup(type, st) \ + ((STACK_OF(type) *(*)(STACK_OF(type) *))openssl_fcast(sk_dup))(st) +#define SKM_sk_pop_free(type, st,free_func) \ + ((void (*)(STACK_OF(type) *, void (*)(type *)))openssl_fcast(sk_pop_free))\ + (st, free_func) +#define SKM_sk_shift(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_shift))(st) +#define SKM_sk_pop(type, st) \ + ((type * (*)(STACK_OF(type) *))openssl_fcast(sk_pop))(st) +#define SKM_sk_sort(type, st) \ + ((void (*)(STACK_OF(type) *))openssl_fcast(sk_sort))(st) +#define SKM_sk_is_sorted(type, st) \ + ((int (*)(const STACK_OF(type) *))openssl_fcast(sk_is_sorted))(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ +((STACK_OF(type) * (*) (STACK_OF(type) **,const unsigned char **, long , \ + type *(*)(type **, const unsigned char **,long), \ + void (*)(type *), int ,int )) openssl_fcast(d2i_ASN1_SET)) \ + (st,pp,length, d2i_func, free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + ((int (*)(STACK_OF(type) *,unsigned char **, \ + int (*)(type *,unsigned char **), int , int , int)) openssl_fcast(i2d_ASN1_SET)) \ + (st,pp,i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ((unsigned char *(*)(STACK_OF(type) *, \ + int (*)(type *,unsigned char **), unsigned char **,int *)) openssl_fcast(ASN1_seq_pack)) \ + (st, i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ((STACK_OF(type) * (*)(const unsigned char *,int, \ + type *(*)(type **,const unsigned char **, long), \ + void (*)(type *)))openssl_fcast(ASN1_seq_unpack)) \ + (buf,len,d2i_func, free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK_OF(type) * (*)(X509_ALGOR *, \ + type *(*)(type **, const unsigned char **, long), \ + void (*)(type *), \ + const char *, int, \ + ASN1_STRING *, int))PKCS12_decrypt_d2i) \ + (algor,d2i_func,free_func,pass,passlen,oct,seq) + +#else + +#define STACK_OF(type) STACK +#define PREDECLARE_STACK_OF(type) /* nada */ +#define DECLARE_STACK_OF(type) /* nada */ +#define IMPLEMENT_STACK_OF(type) /* nada */ + +#define SKM_sk_new(type, cmp) \ + sk_new((int (*)(const char * const *, const char * const *))(cmp)) +#define SKM_sk_new_null(type) \ + sk_new_null() +#define SKM_sk_free(type, st) \ + sk_free(st) +#define SKM_sk_num(type, st) \ + sk_num(st) +#define SKM_sk_value(type, st,i) \ + ((type *)sk_value(st, i)) +#define SKM_sk_set(type, st,i,val) \ + ((type *)sk_set(st, i,(char *)val)) +#define SKM_sk_zero(type, st) \ + sk_zero(st) +#define SKM_sk_push(type, st,val) \ + sk_push(st, (char *)val) +#define SKM_sk_unshift(type, st,val) \ + sk_unshift(st, val) +#define SKM_sk_find(type, st,val) \ + sk_find(st, (char *)val) +#define SKM_sk_delete(type, st,i) \ + ((type *)sk_delete(st, i)) +#define SKM_sk_delete_ptr(type, st,ptr) \ + ((type *)sk_delete_ptr(st,(char *)ptr)) +#define SKM_sk_insert(type, st,val,i) \ + sk_insert(st, (char *)val, i) +#define SKM_sk_set_cmp_func(type, st,cmp) \ + ((int (*)(const type * const *,const type * const *)) \ + sk_set_cmp_func(st, (int (*)(const char * const *, const char * const *))(cmp))) +#define SKM_sk_dup(type, st) \ + sk_dup(st) +#define SKM_sk_pop_free(type, st,free_func) \ + sk_pop_free(st, (void (*)(void *))free_func) +#define SKM_sk_shift(type, st) \ + ((type *)sk_shift(st)) +#define SKM_sk_pop(type, st) \ + ((type *)sk_pop(st)) +#define SKM_sk_sort(type, st) \ + sk_sort(st) +#define SKM_sk_is_sorted(type, st) \ + sk_is_sorted(st) + +#define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + d2i_ASN1_SET(st,pp,length, (void *(*)(void ** ,const unsigned char ** ,long))d2i_func, (void (*)(void *))free_func, ex_tag,ex_class) +#define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \ + i2d_ASN1_SET(st,pp,(int (*)(void *, unsigned char **))i2d_func,ex_tag,ex_class,is_set) + +#define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \ + ASN1_seq_pack(st, (int (*)(void *, unsigned char **))i2d_func, buf, len) +#define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \ + ASN1_seq_unpack(buf,len,(void *(*)(void **,const unsigned char **,long))d2i_func, (void(*)(void *))free_func) + +#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \ + ((STACK *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i_func, (void(*)(void *))free_func,pass,passlen,oct,seq)) + +#endif + +/* This block of defines is updated by util/mkstack.pl, please do not touch! */ +#define sk_ACCESS_DESCRIPTION_new(st) SKM_sk_new(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION) +#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val)) +#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val)) +#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i)) +#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr)) +#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i)) +#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp)) +#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st) +#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func)) +#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) +#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st)) + +#define sk_ASIdOrRange_new(st) SKM_sk_new(ASIdOrRange, (st)) +#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange) +#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st)) +#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st)) +#define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i)) +#define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val)) +#define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st)) +#define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val)) +#define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i)) +#define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr)) +#define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i)) +#define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp)) +#define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st) +#define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func)) +#define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st)) +#define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st)) +#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st)) +#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st)) + +#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING) +#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val)) +#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val)) +#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i)) +#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr)) +#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i)) +#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp)) +#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st) +#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func)) +#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st)) +#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st)) + +#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) +#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val)) +#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val)) +#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i)) +#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr)) +#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i)) +#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp)) +#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st) +#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func)) +#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st)) +#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st)) + +#define sk_ASN1_OBJECT_new(st) SKM_sk_new(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT) +#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val)) +#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val)) +#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i)) +#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr)) +#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i)) +#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp)) +#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st) +#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func)) +#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st)) +#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st)) + +#define sk_ASN1_STRING_TABLE_new(st) SKM_sk_new(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE) +#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val)) +#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val)) +#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i)) +#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr)) +#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i)) +#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp)) +#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st) +#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func)) +#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st)) +#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st)) + +#define sk_ASN1_TYPE_new(st) SKM_sk_new(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE) +#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val)) +#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val)) +#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i)) +#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr)) +#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i)) +#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp)) +#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st) +#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func)) +#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) +#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st)) + +#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE) +#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val)) +#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val)) +#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i)) +#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr)) +#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i)) +#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp)) +#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st) +#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func)) +#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st)) +#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st)) + +#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) +#define sk_BIO_new_null() SKM_sk_new_null(BIO) +#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) +#define sk_BIO_num(st) SKM_sk_num(BIO, (st)) +#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i)) +#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val)) +#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st)) +#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val)) +#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val)) +#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val)) +#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val)) +#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i)) +#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr)) +#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i)) +#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp)) +#define sk_BIO_dup(st) SKM_sk_dup(BIO, st) +#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func)) +#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st)) +#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st)) +#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) +#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st)) + +#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE) +#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val)) +#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val)) +#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i)) +#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr)) +#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i)) +#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp)) +#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st) +#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func)) +#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st)) +#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st)) + +#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st)) +#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE) +#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st)) +#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st)) +#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val)) +#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st)) +#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val)) +#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i)) +#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr)) +#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i)) +#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp)) +#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st) +#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func)) +#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st)) +#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st)) +#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st)) +#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st)) + +#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) +#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) +#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) +#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st)) +#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val)) +#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st)) +#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val)) +#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i)) +#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr)) +#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i)) +#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp)) +#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st) +#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func)) +#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st)) +#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st)) +#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st)) +#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st)) + +#define sk_CRYPTO_EX_DATA_FUNCS_new(st) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS) +#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr)) +#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i)) +#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp)) +#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st) +#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func)) +#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st)) +#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st)) + +#define sk_CRYPTO_dynlock_new(st) SKM_sk_new(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock) +#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val)) +#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val)) +#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i)) +#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr)) +#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i)) +#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp)) +#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st) +#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func)) +#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st)) +#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st)) + +#define sk_DIST_POINT_new(st) SKM_sk_new(DIST_POINT, (st)) +#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT) +#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st)) +#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st)) +#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val)) +#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st)) +#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val)) +#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i)) +#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr)) +#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i)) +#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp)) +#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st) +#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func)) +#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st)) +#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st)) +#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) +#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st)) + +#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st)) +#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE) +#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st)) +#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st)) +#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i)) +#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val)) +#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st)) +#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val)) +#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val)) +#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val)) +#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val)) +#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i)) +#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr)) +#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i)) +#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp)) +#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st) +#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func)) +#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st)) +#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st)) +#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st)) +#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st)) + +#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM) +#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val)) +#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val)) +#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i)) +#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr)) +#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i)) +#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp)) +#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st) +#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func)) +#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st)) +#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st)) + +#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) +#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val)) +#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val)) +#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i)) +#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr)) +#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i)) +#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp)) +#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st) +#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func)) +#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) +#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st)) + +#define sk_GENERAL_SUBTREE_new(st) SKM_sk_new(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE) +#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val)) +#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val)) +#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i)) +#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr)) +#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i)) +#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp)) +#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st) +#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func)) +#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st)) +#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st)) + +#define sk_IPAddressFamily_new(st) SKM_sk_new(IPAddressFamily, (st)) +#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily) +#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st)) +#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st)) +#define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i)) +#define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val)) +#define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st)) +#define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val)) +#define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i)) +#define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr)) +#define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i)) +#define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp)) +#define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st) +#define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func)) +#define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st)) +#define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st)) +#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st)) +#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st)) + +#define sk_IPAddressOrRange_new(st) SKM_sk_new(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange) +#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i)) +#define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val)) +#define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val)) +#define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i)) +#define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr)) +#define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i)) +#define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp)) +#define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st) +#define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func)) +#define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st)) +#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st)) + +#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY) +#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val)) +#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val)) +#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i)) +#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr)) +#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i)) +#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp)) +#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st) +#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func)) +#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st)) +#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st)) + +#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA) +#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val)) +#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val)) +#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i)) +#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr)) +#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i)) +#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp)) +#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st) +#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func)) +#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st)) +#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st)) + +#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY) +#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val)) +#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val)) +#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i)) +#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr)) +#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i)) +#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp)) +#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st) +#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func)) +#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st)) +#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st)) + +#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM) +#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val)) +#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val)) +#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i)) +#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr)) +#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i)) +#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp)) +#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st) +#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func)) +#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st)) +#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st)) + +#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA) +#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val)) +#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val)) +#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i)) +#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr)) +#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i)) +#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp)) +#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st) +#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func)) +#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st)) +#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st)) + +#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY) +#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val)) +#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val)) +#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i)) +#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr)) +#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i)) +#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp)) +#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st) +#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func)) +#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st)) +#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st)) + +#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME) +#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val)) +#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val)) +#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i)) +#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr)) +#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i)) +#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp)) +#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st) +#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func)) +#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st)) +#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st)) + +#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY) +#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val)) +#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val)) +#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i)) +#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr)) +#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i)) +#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp)) +#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st) +#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func)) +#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st)) +#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st)) + +#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) +#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) +#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) +#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st)) +#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val)) +#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st)) +#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val)) +#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i)) +#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr)) +#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i)) +#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp)) +#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st) +#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func)) +#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st)) +#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st)) +#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st)) +#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st)) + +#define sk_MIME_PARAM_new(st) SKM_sk_new(MIME_PARAM, (st)) +#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM) +#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st)) +#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st)) +#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val)) +#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st)) +#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val)) +#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i)) +#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr)) +#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i)) +#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp)) +#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st) +#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func)) +#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st)) +#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st)) +#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st)) +#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st)) + +#define sk_NAME_FUNCS_new(st) SKM_sk_new(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS) +#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val)) +#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val)) +#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i)) +#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr)) +#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i)) +#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp)) +#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st) +#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func)) +#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) +#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st)) + +#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID) +#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val)) +#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val)) +#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i)) +#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr)) +#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i)) +#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp)) +#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st) +#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func)) +#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st)) +#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st)) + +#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ) +#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val)) +#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val)) +#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i)) +#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr)) +#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i)) +#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp)) +#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st) +#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func)) +#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st)) +#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st)) + +#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP) +#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val)) +#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val)) +#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i)) +#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr)) +#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i)) +#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp)) +#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st) +#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func)) +#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st)) +#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st)) + +#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) +#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val)) +#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val)) +#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i)) +#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr)) +#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i)) +#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp)) +#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st) +#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func)) +#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st)) +#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st)) + +#define sk_PKCS7_new(st) SKM_sk_new(PKCS7, (st)) +#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7) +#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st)) +#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st)) +#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i)) +#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val)) +#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st)) +#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val)) +#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val)) +#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val)) +#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val)) +#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i)) +#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr)) +#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i)) +#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp)) +#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st) +#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func)) +#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st)) +#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st)) +#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st)) +#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st)) + +#define sk_PKCS7_RECIP_INFO_new(st) SKM_sk_new(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO) +#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val)) +#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val)) +#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i)) +#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr)) +#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i)) +#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp)) +#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st) +#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func)) +#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st)) +#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st)) + +#define sk_PKCS7_SIGNER_INFO_new(st) SKM_sk_new(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO) +#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val)) +#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val)) +#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i)) +#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr)) +#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i)) +#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp)) +#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st) +#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func)) +#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st)) +#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st)) + +#define sk_POLICYINFO_new(st) SKM_sk_new(POLICYINFO, (st)) +#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO) +#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st)) +#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st)) +#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val)) +#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st)) +#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val)) +#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i)) +#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr)) +#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i)) +#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp)) +#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st) +#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func)) +#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st)) +#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st)) +#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st)) +#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st)) + +#define sk_POLICYQUALINFO_new(st) SKM_sk_new(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO) +#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val)) +#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val)) +#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i)) +#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr)) +#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i)) +#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp)) +#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st) +#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func)) +#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st)) +#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st)) + +#define sk_POLICY_MAPPING_new(st) SKM_sk_new(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING) +#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val)) +#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val)) +#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i)) +#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr)) +#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i)) +#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp)) +#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st) +#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func)) +#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st)) +#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st)) + +#define sk_SSL_CIPHER_new(st) SKM_sk_new(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER) +#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val)) +#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val)) +#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i)) +#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr)) +#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i)) +#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp)) +#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st) +#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func)) +#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st)) +#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st)) + +#define sk_SSL_COMP_new(st) SKM_sk_new(SSL_COMP, (st)) +#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP) +#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st)) +#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st)) +#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val)) +#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st)) +#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val)) +#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i)) +#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr)) +#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i)) +#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp)) +#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st) +#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func)) +#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st)) +#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st)) +#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st)) +#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st)) + +#define sk_STORE_OBJECT_new(st) SKM_sk_new(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT) +#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val)) +#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val)) +#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i)) +#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr)) +#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i)) +#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp)) +#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st) +#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func)) +#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st)) +#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st)) + +#define sk_SXNETID_new(st) SKM_sk_new(SXNETID, (st)) +#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID) +#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st)) +#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st)) +#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i)) +#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val)) +#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st)) +#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val)) +#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val)) +#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val)) +#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val)) +#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i)) +#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr)) +#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i)) +#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp)) +#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st) +#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func)) +#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st)) +#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st)) +#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) +#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st)) + +#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st)) +#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING) +#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st)) +#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st)) +#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i)) +#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val)) +#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st)) +#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val)) +#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val)) +#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val)) +#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val)) +#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i)) +#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr)) +#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i)) +#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp)) +#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st) +#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func)) +#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st)) +#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st)) +#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st)) +#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st)) + +#define sk_X509_new(st) SKM_sk_new(X509, (st)) +#define sk_X509_new_null() SKM_sk_new_null(X509) +#define sk_X509_free(st) SKM_sk_free(X509, (st)) +#define sk_X509_num(st) SKM_sk_num(X509, (st)) +#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i)) +#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val)) +#define sk_X509_zero(st) SKM_sk_zero(X509, (st)) +#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val)) +#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val)) +#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val)) +#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val)) +#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i)) +#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr)) +#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i)) +#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp)) +#define sk_X509_dup(st) SKM_sk_dup(X509, st) +#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func)) +#define sk_X509_shift(st) SKM_sk_shift(X509, (st)) +#define sk_X509_pop(st) SKM_sk_pop(X509, (st)) +#define sk_X509_sort(st) SKM_sk_sort(X509, (st)) +#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st)) + +#define sk_X509V3_EXT_METHOD_new(st) SKM_sk_new(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD) +#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val)) +#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val)) +#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i)) +#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr)) +#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i)) +#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp)) +#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st) +#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func)) +#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st)) +#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st)) + +#define sk_X509_ALGOR_new(st) SKM_sk_new(X509_ALGOR, (st)) +#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR) +#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st)) +#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st)) +#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val)) +#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st)) +#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val)) +#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i)) +#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr)) +#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i)) +#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp)) +#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st) +#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func)) +#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st)) +#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st)) +#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st)) +#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st)) + +#define sk_X509_ATTRIBUTE_new(st) SKM_sk_new(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE) +#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val)) +#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val)) +#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i)) +#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr)) +#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i)) +#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp)) +#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st) +#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func)) +#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st)) +#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st)) + +#define sk_X509_CRL_new(st) SKM_sk_new(X509_CRL, (st)) +#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL) +#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st)) +#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st)) +#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i)) +#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val)) +#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st)) +#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val)) +#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val)) +#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val)) +#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val)) +#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i)) +#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr)) +#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i)) +#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp)) +#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st) +#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func)) +#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st)) +#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st)) +#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st)) +#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st)) + +#define sk_X509_EXTENSION_new(st) SKM_sk_new(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION) +#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val)) +#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val)) +#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i)) +#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr)) +#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i)) +#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp)) +#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st) +#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func)) +#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st)) +#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st)) + +#define sk_X509_INFO_new(st) SKM_sk_new(X509_INFO, (st)) +#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO) +#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st)) +#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st)) +#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i)) +#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val)) +#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st)) +#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val)) +#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val)) +#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val)) +#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val)) +#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i)) +#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr)) +#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i)) +#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp)) +#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st) +#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func)) +#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st)) +#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st)) +#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st)) +#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st)) + +#define sk_X509_LOOKUP_new(st) SKM_sk_new(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP) +#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val)) +#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val)) +#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i)) +#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr)) +#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i)) +#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp)) +#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st) +#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func)) +#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st)) +#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st)) + +#define sk_X509_NAME_new(st) SKM_sk_new(X509_NAME, (st)) +#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME) +#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st)) +#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st)) +#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i)) +#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val)) +#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st)) +#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val)) +#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val)) +#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val)) +#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val)) +#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i)) +#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr)) +#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i)) +#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp)) +#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st) +#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func)) +#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st)) +#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st)) +#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st)) +#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st)) + +#define sk_X509_NAME_ENTRY_new(st) SKM_sk_new(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY) +#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val)) +#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val)) +#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i)) +#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr)) +#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i)) +#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp)) +#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st) +#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func)) +#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st)) +#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st)) + +#define sk_X509_OBJECT_new(st) SKM_sk_new(X509_OBJECT, (st)) +#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT) +#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st)) +#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st)) +#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val)) +#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st)) +#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val)) +#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i)) +#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr)) +#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i)) +#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp)) +#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st) +#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func)) +#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st)) +#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st)) +#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st)) +#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st)) + +#define sk_X509_POLICY_DATA_new(st) SKM_sk_new(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA) +#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val)) +#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val)) +#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i)) +#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr)) +#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i)) +#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp)) +#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st) +#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func)) +#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st)) +#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st)) + +#define sk_X509_POLICY_NODE_new(st) SKM_sk_new(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE) +#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val)) +#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val)) +#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i)) +#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr)) +#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i)) +#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp)) +#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st) +#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func)) +#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st)) +#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st)) + +#define sk_X509_POLICY_REF_new(st) SKM_sk_new(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_new_null() SKM_sk_new_null(X509_POLICY_REF) +#define sk_X509_POLICY_REF_free(st) SKM_sk_free(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_num(st) SKM_sk_num(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_value(st, i) SKM_sk_value(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_set(st, i, val) SKM_sk_set(X509_POLICY_REF, (st), (i), (val)) +#define sk_X509_POLICY_REF_zero(st) SKM_sk_zero(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_push(st, val) SKM_sk_push(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_unshift(st, val) SKM_sk_unshift(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find(st, val) SKM_sk_find(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_REF, (st), (val)) +#define sk_X509_POLICY_REF_delete(st, i) SKM_sk_delete(X509_POLICY_REF, (st), (i)) +#define sk_X509_POLICY_REF_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_REF, (st), (ptr)) +#define sk_X509_POLICY_REF_insert(st, val, i) SKM_sk_insert(X509_POLICY_REF, (st), (val), (i)) +#define sk_X509_POLICY_REF_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_REF, (st), (cmp)) +#define sk_X509_POLICY_REF_dup(st) SKM_sk_dup(X509_POLICY_REF, st) +#define sk_X509_POLICY_REF_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_REF, (st), (free_func)) +#define sk_X509_POLICY_REF_shift(st) SKM_sk_shift(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_pop(st) SKM_sk_pop(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_sort(st) SKM_sk_sort(X509_POLICY_REF, (st)) +#define sk_X509_POLICY_REF_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_REF, (st)) + +#define sk_X509_PURPOSE_new(st) SKM_sk_new(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE) +#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val)) +#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val)) +#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i)) +#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr)) +#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i)) +#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp)) +#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st) +#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func)) +#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st)) +#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st)) + +#define sk_X509_REVOKED_new(st) SKM_sk_new(X509_REVOKED, (st)) +#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED) +#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st)) +#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st)) +#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val)) +#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st)) +#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val)) +#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i)) +#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr)) +#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i)) +#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp)) +#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st) +#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func)) +#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st)) +#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st)) +#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st)) +#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st)) + +#define sk_X509_TRUST_new(st) SKM_sk_new(X509_TRUST, (st)) +#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST) +#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st)) +#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st)) +#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val)) +#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st)) +#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val)) +#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i)) +#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr)) +#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i)) +#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp)) +#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st) +#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func)) +#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st)) +#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st)) +#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st)) +#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st)) + +#define sk_X509_VERIFY_PARAM_new(st) SKM_sk_new(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM) +#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val)) +#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val)) +#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i)) +#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr)) +#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i)) +#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp)) +#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st) +#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func)) +#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st)) +#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st)) + +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func)) + +#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ + SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) +#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \ + SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) +#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \ + SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len)) +#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \ + SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func)) + +#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) + +#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \ + SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) +/* End of util/mkstack.pl block, you may now edit :-) */ + +#endif /* !defined HEADER_SAFESTACK_H */ diff --git a/libraries/external/openssl/pc/include/openssl/sha.h b/libraries/external/openssl/pc/include/openssl/sha.h new file mode 100755 index 0000000..5064482 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/sha.h @@ -0,0 +1,200 @@ +/* crypto/sha/sha.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SHA_H +#define HEADER_SHA_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) +#error SHA is disabled. +#endif + +#if defined(OPENSSL_FIPS) +#define FIPS_SHA_SIZE_T size_t +#endif + +/* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! + * ! SHA_LONG_LOG2 has to be defined along. ! + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + */ + +#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) +#define SHA_LONG unsigned long +#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) +#define SHA_LONG unsigned long +#define SHA_LONG_LOG2 3 +#else +#define SHA_LONG unsigned int +#endif + +#define SHA_LBLOCK 16 +#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA_LAST_BLOCK (SHA_CBLOCK-8) +#define SHA_DIGEST_LENGTH 20 + +typedef struct SHAstate_st + { + SHA_LONG h0,h1,h2,h3,h4; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num; + } SHA_CTX; + +#ifndef OPENSSL_NO_SHA0 +int SHA_Init(SHA_CTX *c); +int SHA_Update(SHA_CTX *c, const void *data, size_t len); +int SHA_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); +void SHA_Transform(SHA_CTX *c, const unsigned char *data); +#endif +#ifndef OPENSSL_NO_SHA1 +int SHA1_Init(SHA_CTX *c); +int SHA1_Update(SHA_CTX *c, const void *data, size_t len); +int SHA1_Final(unsigned char *md, SHA_CTX *c); +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); +void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +#endif + +#define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a + * contiguous array of 32 bit + * wide big-endian values. */ +#define SHA224_DIGEST_LENGTH 28 +#define SHA256_DIGEST_LENGTH 32 + +typedef struct SHA256state_st + { + SHA_LONG h[8]; + SHA_LONG Nl,Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num,md_len; + } SHA256_CTX; + +#ifndef OPENSSL_NO_SHA256 +int SHA224_Init(SHA256_CTX *c); +int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA224_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md); +int SHA256_Init(SHA256_CTX *c); +int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); +int SHA256_Final(unsigned char *md, SHA256_CTX *c); +unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md); +void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); +#endif + +#define SHA384_DIGEST_LENGTH 48 +#define SHA512_DIGEST_LENGTH 64 + +#ifndef OPENSSL_NO_SHA512 +/* + * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 + * being exactly 64-bit wide. See Implementation Notes in sha512.c + * for further details. + */ +#define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a + * contiguous array of 64 bit + * wide big-endian values. */ +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +#define SHA_LONG64 unsigned __int64 +#define U64(C) C##UI64 +#elif defined(__arch64__) +#define SHA_LONG64 unsigned long +#define U64(C) C##UL +#else +#define SHA_LONG64 unsigned long long +#define U64(C) C##ULL +#endif + +typedef struct SHA512state_st + { + SHA_LONG64 h[8]; + SHA_LONG64 Nl,Nh; + union { + SHA_LONG64 d[SHA_LBLOCK]; + unsigned char p[SHA512_CBLOCK]; + } u; + unsigned int num,md_len; + } SHA512_CTX; +#endif + +#ifndef OPENSSL_NO_SHA512 +int SHA384_Init(SHA512_CTX *c); +int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA384_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); +int SHA512_Init(SHA512_CTX *c); +int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); +int SHA512_Final(unsigned char *md, SHA512_CTX *c); +unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); +void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ssl.h b/libraries/external/openssl/pc/include/openssl/ssl.h new file mode 100755 index 0000000..36e347b --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ssl.h @@ -0,0 +1,1960 @@ +/* ssl/ssl.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL_H +#define HEADER_SSL_H + +#include + +#ifndef OPENSSL_NO_COMP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_X509 +#include +#endif +#include +#include +#include +#endif +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* SSLeay version number for ASN.1 encoding of the session information */ +/* Version 0 - initial version + * Version 1 - added the optional peer certificate + */ +#define SSL_SESSION_ASN1_VERSION 0x0001 + +/* text strings for the ciphers */ +#define SSL_TXT_NULL_WITH_MD5 SSL2_TXT_NULL_WITH_MD5 +#define SSL_TXT_RC4_128_WITH_MD5 SSL2_TXT_RC4_128_WITH_MD5 +#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_WITH_MD5 SSL2_TXT_RC2_128_CBC_WITH_MD5 +#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 +#define SSL_TXT_IDEA_128_CBC_WITH_MD5 SSL2_TXT_IDEA_128_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_MD5 SSL2_TXT_DES_64_CBC_WITH_MD5 +#define SSL_TXT_DES_64_CBC_WITH_SHA SSL2_TXT_DES_64_CBC_WITH_SHA +#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 +#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA + +/* VRS Additional Kerberos5 entries + */ +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA +#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5 +#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA +#define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5 +#define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5 + +#define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA +#define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 +#define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA +#define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 +#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA +#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 +#define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256 + +#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 +#define SSL_MAX_SID_CTX_LENGTH 32 + +#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) +#define SSL_MAX_KEY_ARG_LENGTH 8 +#define SSL_MAX_MASTER_KEY_LENGTH 48 + +/* These are used to specify which ciphers to use and not to use */ +#define SSL_TXT_LOW "LOW" +#define SSL_TXT_MEDIUM "MEDIUM" +#define SSL_TXT_HIGH "HIGH" +#define SSL_TXT_kFZA "kFZA" +#define SSL_TXT_aFZA "aFZA" +#define SSL_TXT_eFZA "eFZA" +#define SSL_TXT_FZA "FZA" + +#define SSL_TXT_aNULL "aNULL" +#define SSL_TXT_eNULL "eNULL" +#define SSL_TXT_NULL "NULL" + +#define SSL_TXT_kKRB5 "kKRB5" +#define SSL_TXT_aKRB5 "aKRB5" +#define SSL_TXT_KRB5 "KRB5" + +#define SSL_TXT_kRSA "kRSA" +#define SSL_TXT_kDHr "kDHr" +#define SSL_TXT_kDHd "kDHd" +#define SSL_TXT_kEDH "kEDH" +#define SSL_TXT_aRSA "aRSA" +#define SSL_TXT_aDSS "aDSS" +#define SSL_TXT_aDH "aDH" +#define SSL_TXT_DSS "DSS" +#define SSL_TXT_DH "DH" +#define SSL_TXT_EDH "EDH" +#define SSL_TXT_ADH "ADH" +#define SSL_TXT_RSA "RSA" +#define SSL_TXT_DES "DES" +#define SSL_TXT_3DES "3DES" +#define SSL_TXT_RC4 "RC4" +#define SSL_TXT_RC2 "RC2" +#define SSL_TXT_IDEA "IDEA" +#define SSL_TXT_AES "AES" +#define SSL_TXT_CAMELLIA "CAMELLIA" +#define SSL_TXT_MD5 "MD5" +#define SSL_TXT_SHA1 "SHA1" +#define SSL_TXT_SHA "SHA" +#define SSL_TXT_EXP "EXP" +#define SSL_TXT_EXPORT "EXPORT" +#define SSL_TXT_EXP40 "EXPORT40" +#define SSL_TXT_EXP56 "EXPORT56" +#define SSL_TXT_SSLV2 "SSLv2" +#define SSL_TXT_SSLV3 "SSLv3" +#define SSL_TXT_TLSV1 "TLSv1" +#define SSL_TXT_ALL "ALL" +#define SSL_TXT_ECC "ECCdraft" /* ECC ciphersuites are not yet official */ + +/* + * COMPLEMENTOF* definitions. These identifiers are used to (de-select) + * ciphers normally not being used. + * Example: "RC4" will activate all ciphers using RC4 including ciphers + * without authentication, which would normally disabled by DEFAULT (due + * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" + * will make sure that it is also disabled in the specific selection. + * COMPLEMENTOF* identifiers are portable between version, as adjustments + * to the default cipher setup will also be included here. + * + * COMPLEMENTOFDEFAULT does not experience the same special treatment that + * DEFAULT gets, as only selection is being done and no sorting as needed + * for DEFAULT. + */ +#define SSL_TXT_CMPALL "COMPLEMENTOFALL" +#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" + +/* The following cipher list is used by default. + * It also is substituted when an application-defined cipher list string + * starts with 'DEFAULT'. */ +#ifdef OPENSSL_NO_CAMELLIA +# define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ +#else +# define SSL_DEFAULT_CIPHER_LIST "AES:CAMELLIA:ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ +#endif + +/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ +#define SSL_SENT_SHUTDOWN 1 +#define SSL_RECEIVED_SHUTDOWN 2 + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) +#define OPENSSL_NO_SSL2 +#endif + +#define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 +#define SSL_FILETYPE_PEM X509_FILETYPE_PEM + +/* This is needed to stop compilers complaining about the + * 'struct ssl_st *' function parameters used to prototype callbacks + * in SSL_CTX. */ +typedef struct ssl_st *ssl_crock_st; + +/* used to hold info on the particular ciphers used */ +typedef struct ssl_cipher_st + { + int valid; + const char *name; /* text name */ + unsigned long id; /* id, 4 bytes, first is version */ + unsigned long algorithms; /* what ciphers are used */ + unsigned long algo_strength; /* strength and export flags */ + unsigned long algorithm2; /* Extra flags */ + int strength_bits; /* Number of bits really used */ + int alg_bits; /* Number of bits for algorithm */ + unsigned long mask; /* used for matching */ + unsigned long mask_strength; /* also used for matching */ + } SSL_CIPHER; + +DECLARE_STACK_OF(SSL_CIPHER) + +typedef struct ssl_st SSL; +typedef struct ssl_ctx_st SSL_CTX; + +/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ +typedef struct ssl_method_st + { + int version; + int (*ssl_new)(SSL *s); + void (*ssl_clear)(SSL *s); + void (*ssl_free)(SSL *s); + int (*ssl_accept)(SSL *s); + int (*ssl_connect)(SSL *s); + int (*ssl_read)(SSL *s,void *buf,int len); + int (*ssl_peek)(SSL *s,void *buf,int len); + int (*ssl_write)(SSL *s,const void *buf,int len); + int (*ssl_shutdown)(SSL *s); + int (*ssl_renegotiate)(SSL *s); + int (*ssl_renegotiate_check)(SSL *s); + long (*ssl_get_message)(SSL *s, int st1, int stn, int mt, long + max, int *ok); + int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf, int len, + int peek); + int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); + int (*ssl_dispatch_alert)(SSL *s); + long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg); + long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg); + SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); + int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); + int (*ssl_pending)(const SSL *s); + int (*num_ciphers)(void); + SSL_CIPHER *(*get_cipher)(unsigned ncipher); + struct ssl_method_st *(*get_ssl_method)(int version); + long (*get_timeout)(void); + struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ + int (*ssl_version)(void); + long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void)); + long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void)); + } SSL_METHOD; + +/* Lets make this into an ASN.1 type structure as follows + * SSL_SESSION_ID ::= SEQUENCE { + * version INTEGER, -- structure version number + * SSLversion INTEGER, -- SSL version number + * Cipher OCTET_STRING, -- the 3 byte cipher ID + * Session_ID OCTET_STRING, -- the Session ID + * Master_key OCTET_STRING, -- the master key + * KRB5_principal OCTET_STRING -- optional Kerberos principal + * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument + * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time + * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds + * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate + * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context + * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer' + * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX + * } + * Look in ssl/ssl_asn1.c for more details + * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). + */ +typedef struct ssl_session_st + { + int ssl_version; /* what ssl version session info is + * being kept in here? */ + + /* only really used in SSLv2 */ + unsigned int key_arg_length; + unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH]; + int master_key_length; + unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH]; + /* session_id - valid? */ + unsigned int session_id_length; + unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + /* this is used to determine whether the session is being reused in + * the appropriate context. It is up to the application to set this, + * via SSL_new */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + +#ifndef OPENSSL_NO_KRB5 + unsigned int krb5_client_princ_len; + unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH]; +#endif /* OPENSSL_NO_KRB5 */ + + int not_resumable; + + /* The cert is the certificate used to establish this connection */ + struct sess_cert_st /* SESS_CERT */ *sess_cert; + + /* This is the cert for the other end. + * On clients, it will be the same as sess_cert->peer_key->x509 + * (the latter is not enough as sess_cert is not retained + * in the external representation of sessions, see ssl_asn1.c). */ + X509 *peer; + /* when app_verify_callback accepts a session where the peer's certificate + * is not ok, we must remember the error for session reuse: */ + long verify_result; /* only for servers */ + + int references; + long timeout; + long time; + + int compress_meth; /* Need to lookup the method */ + + SSL_CIPHER *cipher; + unsigned long cipher_id; /* when ASN.1 loaded, this + * needs to be used to load + * the 'cipher' structure */ + + STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */ + + CRYPTO_EX_DATA ex_data; /* application specific data */ + + /* These are used to make removal of session-ids more + * efficient and to implement a maximum cache size. */ + struct ssl_session_st *prev,*next; + } SSL_SESSION; + + +#define SSL_OP_MICROSOFT_SESS_ID_BUG 0x00000001L +#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x00000002L +#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x00000008L +#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x00000010L +#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L +#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L /* no effect since 0.9.7h and 0.9.8b */ +#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L +#define SSL_OP_TLS_D5_BUG 0x00000100L +#define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L + +/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added + * in OpenSSL 0.9.6d. Usually (depending on the application protocol) + * the workaround is not needed. Unfortunately some broken SSL/TLS + * implementations cannot handle it at all, which is why we include + * it in SSL_OP_ALL. */ +#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L /* added in 0.9.6e */ + +/* SSL_OP_ALL: various bug workarounds that should be rather harmless. + * This used to be 0x000FFFFFL before 0.9.7. */ +#define SSL_OP_ALL 0x00000FFFL + +/* DTLS options */ +#define SSL_OP_NO_QUERY_MTU 0x00001000L +/* Turn on Cookie Exchange (on relevant for servers) */ +#define SSL_OP_COOKIE_EXCHANGE 0x00002000L + +/* As server, disallow session resumption on renegotiation */ +#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000L +/* If set, always create a new key when using tmp_ecdh parameters */ +#define SSL_OP_SINGLE_ECDH_USE 0x00080000L +/* If set, always create a new key when using tmp_dh parameters */ +#define SSL_OP_SINGLE_DH_USE 0x00100000L +/* Set to always use the tmp_rsa key when doing RSA operations, + * even when this violates protocol specs */ +#define SSL_OP_EPHEMERAL_RSA 0x00200000L +/* Set on servers to choose the cipher according to the server's + * preferences */ +#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L +/* If set, a server will allow a client to issue a SSLv3.0 version number + * as latest version supported in the premaster secret, even when TLSv1.0 + * (version 3.1) was announced in the client hello. Normally this is + * forbidden to prevent version rollback attacks. */ +#define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L + +#define SSL_OP_NO_SSLv2 0x01000000L +#define SSL_OP_NO_SSLv3 0x02000000L +#define SSL_OP_NO_TLSv1 0x04000000L + +/* The next flag deliberately changes the ciphertest, this is a check + * for the PKCS#1 attack */ +#define SSL_OP_PKCS1_CHECK_1 0x08000000L +#define SSL_OP_PKCS1_CHECK_2 0x10000000L +#define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L +#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L + + +/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success + * when just a single record has been written): */ +#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L +/* Make it possible to retry SSL_write() with changed buffer location + * (buffer contents must stay the same!); this is not the default to avoid + * the misconception that non-blocking SSL_write() behaves like + * non-blocking write(): */ +#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L +/* Never bother the application with retries if the transport + * is blocking: */ +#define SSL_MODE_AUTO_RETRY 0x00000004L +/* Don't attempt to automatically build certificate chain */ +#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L + + +/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, + * they cannot be used to clear bits. */ + +#define SSL_CTX_set_options(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_CTX_get_options(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL) +#define SSL_set_options(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL) +#define SSL_get_options(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL) + +#define SSL_CTX_set_mode(ctx,op) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) +#define SSL_CTX_get_mode(ctx) \ + SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mode(ssl,op) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) +#define SSL_get_mode(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) +#define SSL_set_mtu(ssl, mtu) \ + SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) + + +void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); +#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) +#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) + + + +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) +#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */ +#else +#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ +#endif + +#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) + +/* This callback type is used inside SSL_CTX, SSL, and in the functions that set + * them. It is used to override the generation of SSL/TLS session IDs in a + * server. Return value should be zero on an error, non-zero to proceed. Also, + * callbacks should themselves check if the id they generate is unique otherwise + * the SSL handshake will fail with an error - callbacks can do this using the + * 'ssl' value they're passed by; + * SSL_has_matching_session_id(ssl, id, *id_len) + * The length value passed in is set at the maximum size the session ID can be. + * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback + * can alter this length to be less if desired, but under SSLv2 session IDs are + * supposed to be fixed at 16 bytes so the id will be padded after the callback + * returns in this case. It is also an error for the callback to set the size to + * zero. */ +typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, + unsigned int *id_len); + +typedef struct ssl_comp_st + { + int id; + const char *name; +#ifndef OPENSSL_NO_COMP + COMP_METHOD *method; +#else + char *method; +#endif + } SSL_COMP; + +DECLARE_STACK_OF(SSL_COMP) + +struct ssl_ctx_st + { + SSL_METHOD *method; + + STACK_OF(SSL_CIPHER) *cipher_list; + /* same as above but sorted for lookup */ + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + struct x509_store_st /* X509_STORE */ *cert_store; + struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */ + /* Most session-ids that will be cached, default is + * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ + unsigned long session_cache_size; + struct ssl_session_st *session_cache_head; + struct ssl_session_st *session_cache_tail; + + /* This can have one of 2 values, ored together, + * SSL_SESS_CACHE_CLIENT, + * SSL_SESS_CACHE_SERVER, + * Default is SSL_SESSION_CACHE_SERVER, which means only + * SSL_accept which cache SSL_SESSIONS. */ + int session_cache_mode; + + /* If timeout is not 0, it is the default timeout value set + * when SSL_new() is called. This has been put in to make + * life easier to set things up */ + long session_timeout; + + /* If this callback is not null, it will be called each + * time a session id is added to the cache. If this function + * returns 1, it means that the callback will do a + * SSL_SESSION_free() when it has finished using it. Otherwise, + * on 0, it means the callback has finished with it. + * If remove_session_cb is not null, it will be called when + * a session-id is removed from the cache. After the call, + * OpenSSL will SSL_SESSION_free() it. */ + int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); + void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); + SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, + unsigned char *data,int len,int *copy); + + struct + { + int sess_connect; /* SSL new conn - started */ + int sess_connect_renegotiate;/* SSL reneg - requested */ + int sess_connect_good; /* SSL new conne/reneg - finished */ + int sess_accept; /* SSL new accept - started */ + int sess_accept_renegotiate;/* SSL reneg - requested */ + int sess_accept_good; /* SSL accept/reneg - finished */ + int sess_miss; /* session lookup misses */ + int sess_timeout; /* reuse attempt on timeouted session */ + int sess_cache_full; /* session removed due to full cache */ + int sess_hit; /* session reuse actually done */ + int sess_cb_hit; /* session-id that was not + * in the cache was + * passed back via the callback. This + * indicates that the application is + * supplying session-id's from other + * processes - spooky :-) */ + } stats; + + int references; + + /* if defined, these override the X509_verify_cert() calls */ + int (*app_verify_callback)(X509_STORE_CTX *, void *); + void *app_verify_arg; + /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored + * ('app_verify_callback' was called with just one argument) */ + + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + + /* get client cert callback */ + int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); + + /* cookie generate callback */ + int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len); + + /* verify cookie callback */ + int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int cookie_len); + + CRYPTO_EX_DATA ex_data; + + const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ + const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ + const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ + + STACK_OF(X509) *extra_certs; + STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ + + + /* Default values used when no per-SSL value is defined follow */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ + + /* what we put in client cert requests */ + STACK_OF(X509_NAME) *client_CA; + + + /* Default values to use in SSL structures follow (these are copied by SSL_new) */ + + unsigned long options; + unsigned long mode; + long max_cert_list; + + struct cert_st /* CERT */ *cert; + int read_ahead; + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int verify_mode; + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + int quiet_shutdown; + }; + +#define SSL_SESS_CACHE_OFF 0x0000 +#define SSL_SESS_CACHE_CLIENT 0x0001 +#define SSL_SESS_CACHE_SERVER 0x0002 +#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) +#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 +/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ +#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 +#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 +#define SSL_SESS_CACHE_NO_INTERNAL \ + (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) + + struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); +#define SSL_CTX_sess_number(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) +#define SSL_CTX_sess_connect(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) +#define SSL_CTX_sess_connect_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) +#define SSL_CTX_sess_connect_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) +#define SSL_CTX_sess_accept_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) +#define SSL_CTX_sess_accept_good(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) +#define SSL_CTX_sess_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) +#define SSL_CTX_sess_cb_hits(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) +#define SSL_CTX_sess_misses(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) +#define SSL_CTX_sess_timeouts(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) +#define SSL_CTX_sess_cache_full(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) + +void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess)); +int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess); +void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess)); +void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess); +void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,int len,int *copy)); +SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *Data, int len, int *copy); +void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl,int type,int val); +void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); +int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey); +void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len)); +void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len)); + +#define SSL_NOTHING 1 +#define SSL_WRITING 2 +#define SSL_READING 3 +#define SSL_X509_LOOKUP 4 + +/* These will only be used when doing non-blocking IO */ +#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) +#define SSL_want_read(s) (SSL_want(s) == SSL_READING) +#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) +#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) + +struct ssl_st + { + /* protocol version + * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) + */ + int version; + int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ + + SSL_METHOD *method; /* SSLv3 */ + + /* There are 2 BIO's even though they are normally both the + * same. This is so data can be read and written to different + * handlers */ + +#ifndef OPENSSL_NO_BIO + BIO *rbio; /* used by SSL_read */ + BIO *wbio; /* used by SSL_write */ + BIO *bbio; /* used during session-id reuse to concatenate + * messages */ +#else + char *rbio; /* used by SSL_read */ + char *wbio; /* used by SSL_write */ + char *bbio; +#endif + /* This holds a variable that indicates what we were doing + * when a 0 or -1 is returned. This is needed for + * non-blocking IO so we know what request needs re-doing when + * in SSL_accept or SSL_connect */ + int rwstate; + + /* true when we are actually in SSL_accept() or SSL_connect() */ + int in_handshake; + int (*handshake_func)(SSL *); + + /* Imagine that here's a boolean member "init" that is + * switched as soon as SSL_set_{accept/connect}_state + * is called for the first time, so that "state" and + * "handshake_func" are properly initialized. But as + * handshake_func is == 0 until then, we use this + * test instead of an "init" member. + */ + + int server; /* are we the server side? - mostly used by SSL_clear*/ + + int new_session;/* 1 if we are to use a new session. + * 2 if we are a server and are inside a handshake + * (i.e. not just sending a HelloRequest) + * NB: For servers, the 'new' session may actually be a previously + * cached session or even the previous session unless + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ + int quiet_shutdown;/* don't send shutdown packets */ + int shutdown; /* we have shut things down, 0x01 sent, 0x02 + * for received */ + int state; /* where we are */ + int rstate; /* where we are when reading */ + + BUF_MEM *init_buf; /* buffer used during init */ + void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */ + int init_num; /* amount read/written */ + int init_off; /* amount read/written */ + + /* used internally to point at a raw packet */ + unsigned char *packet; + unsigned int packet_length; + + struct ssl2_state_st *s2; /* SSLv2 variables */ + struct ssl3_state_st *s3; /* SSLv3 variables */ + struct dtls1_state_st *d1; /* DTLSv1 variables */ + + int read_ahead; /* Read as many input bytes as possible + * (for non-blocking reads) */ + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + int hit; /* reusing a previous session */ + + X509_VERIFY_PARAM *param; + +#if 0 + int purpose; /* Purpose setting */ + int trust; /* Trust setting */ +#endif + + /* crypto */ + STACK_OF(SSL_CIPHER) *cipher_list; + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + + /* These are the ones being used, the ones in SSL_SESSION are + * the ones to be 'copied' into these ones */ + + EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ + const EVP_MD *read_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *expand; /* uncompress */ +#else + char *expand; +#endif + + EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ + const EVP_MD *write_hash; /* used for mac generation */ +#ifndef OPENSSL_NO_COMP + COMP_CTX *compress; /* compression */ +#else + char *compress; +#endif + + /* session info */ + + /* client cert? */ + /* This is used to hold the server certificate used */ + struct cert_st /* CERT */ *cert; + + /* the session_id_context is used to ensure sessions are only reused + * in the appropriate context */ + unsigned int sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + + /* This can also be in the session once a session is established */ + SSL_SESSION *session; + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + /* Used in SSL2 and SSL3 */ + int verify_mode; /* 0 don't care about verify failure. + * 1 fail if verify fails */ + int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ + + void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */ + + int error; /* error bytes to be written */ + int error_code; /* actual code */ + +#ifndef OPENSSL_NO_KRB5 + KSSL_CTX *kssl_ctx; /* Kerberos 5 context */ +#endif /* OPENSSL_NO_KRB5 */ + + SSL_CTX *ctx; + /* set this flag to 1 and a sleep(1) is put into all SSL_read() + * and SSL_write() calls, good for nbio debuging :-) */ + int debug; + + /* extra application data */ + long verify_result; + CRYPTO_EX_DATA ex_data; + + /* for server side, keep the list of CA_dn we can use */ + STACK_OF(X509_NAME) *client_CA; + + int references; + unsigned long options; /* protocol behaviour */ + unsigned long mode; /* API behaviour */ + long max_cert_list; + int first_packet; + int client_version; /* what was passed, used for + * SSLv3/TLS rollback check */ + }; + +#ifdef __cplusplus +} +#endif + +#include +#include +#include /* This is mostly sslv3 with a few tweaks */ +#include /* Datagram TLS */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* compatibility */ +#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) +#define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) +#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) +#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) +#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) +#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) + +/* The following are the possible values for ssl->state are are + * used to indicate where we are up to in the SSL connection establishment. + * The macros that follow are about the only things you should need to use + * and even then, only when using non-blocking IO. + * It can also be useful to work out where you were when the connection + * failed */ + +#define SSL_ST_CONNECT 0x1000 +#define SSL_ST_ACCEPT 0x2000 +#define SSL_ST_MASK 0x0FFF +#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT) +#define SSL_ST_BEFORE 0x4000 +#define SSL_ST_OK 0x03 +#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT) + +#define SSL_CB_LOOP 0x01 +#define SSL_CB_EXIT 0x02 +#define SSL_CB_READ 0x04 +#define SSL_CB_WRITE 0x08 +#define SSL_CB_ALERT 0x4000 /* used in callback */ +#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) +#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) +#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) +#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) +#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) +#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) +#define SSL_CB_HANDSHAKE_START 0x10 +#define SSL_CB_HANDSHAKE_DONE 0x20 + +/* Is the SSL_connection established? */ +#define SSL_get_state(a) SSL_state(a) +#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) +#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT) +#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE) +#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT) +#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT) + +/* The following 2 states are kept in ssl->rstate when reads fail, + * you should not need these */ +#define SSL_ST_READ_HEADER 0xF0 +#define SSL_ST_READ_BODY 0xF1 +#define SSL_ST_READ_DONE 0xF2 + +/* Obtain latest Finished message + * -- that we sent (SSL_get_finished) + * -- that we expected from peer (SSL_get_peer_finished). + * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ +size_t SSL_get_finished(const SSL *s, void *buf, size_t count); +size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); + +/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options + * are 'ored' with SSL_VERIFY_PEER if they are desired */ +#define SSL_VERIFY_NONE 0x00 +#define SSL_VERIFY_PEER 0x01 +#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 +#define SSL_VERIFY_CLIENT_ONCE 0x04 + +#define OpenSSL_add_ssl_algorithms() SSL_library_init() +#define SSLeay_add_ssl_algorithms() SSL_library_init() + +/* this is for backward compatibility */ +#if 0 /* NEW_SSLEAY */ +#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) +#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) +#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b)) +#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) +#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) +#endif +/* More backward compatibility */ +#define SSL_get_cipher(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_cipher_bits(s,np) \ + SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) +#define SSL_get_cipher_version(s) \ + SSL_CIPHER_get_version(SSL_get_current_cipher(s)) +#define SSL_get_cipher_name(s) \ + SSL_CIPHER_get_name(SSL_get_current_cipher(s)) +#define SSL_get_time(a) SSL_SESSION_get_time(a) +#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) +#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) +#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) + +#if 1 /*SSLEAY_MACROS*/ +#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) +#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) +#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ + (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) +#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u) +#define PEM_write_SSL_SESSION(fp,x) \ + PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ + PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) +#define PEM_write_bio_SSL_SESSION(bp,x) \ + PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL) +#endif + +#define SSL_AD_REASON_OFFSET 1000 +/* These alert types are for SSLv3 and TLSv1 */ +#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY +#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ +#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */ +#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED +#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW +#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */ +#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */ +#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */ +#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE +#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE +#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED +#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED +#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN +#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */ +#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */ +#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ +#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ +#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR +#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */ +#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ +#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ +#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ +#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED +#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION + +#define SSL_ERROR_NONE 0 +#define SSL_ERROR_SSL 1 +#define SSL_ERROR_WANT_READ 2 +#define SSL_ERROR_WANT_WRITE 3 +#define SSL_ERROR_WANT_X509_LOOKUP 4 +#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ +#define SSL_ERROR_ZERO_RETURN 6 +#define SSL_ERROR_WANT_CONNECT 7 +#define SSL_ERROR_WANT_ACCEPT 8 + +#define SSL_CTRL_NEED_TMP_RSA 1 +#define SSL_CTRL_SET_TMP_RSA 2 +#define SSL_CTRL_SET_TMP_DH 3 +#define SSL_CTRL_SET_TMP_ECDH 4 +#define SSL_CTRL_SET_TMP_RSA_CB 5 +#define SSL_CTRL_SET_TMP_DH_CB 6 +#define SSL_CTRL_SET_TMP_ECDH_CB 7 + +#define SSL_CTRL_GET_SESSION_REUSED 8 +#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 +#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 +#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 +#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 +#define SSL_CTRL_GET_FLAGS 13 +#define SSL_CTRL_EXTRA_CHAIN_CERT 14 + +#define SSL_CTRL_SET_MSG_CALLBACK 15 +#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 + +/* only applies to datagram connections */ +#define SSL_CTRL_SET_MTU 17 +/* Stats */ +#define SSL_CTRL_SESS_NUMBER 20 +#define SSL_CTRL_SESS_CONNECT 21 +#define SSL_CTRL_SESS_CONNECT_GOOD 22 +#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 +#define SSL_CTRL_SESS_ACCEPT 24 +#define SSL_CTRL_SESS_ACCEPT_GOOD 25 +#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 +#define SSL_CTRL_SESS_HIT 27 +#define SSL_CTRL_SESS_CB_HIT 28 +#define SSL_CTRL_SESS_MISSES 29 +#define SSL_CTRL_SESS_TIMEOUTS 30 +#define SSL_CTRL_SESS_CACHE_FULL 31 +#define SSL_CTRL_OPTIONS 32 +#define SSL_CTRL_MODE 33 + +#define SSL_CTRL_GET_READ_AHEAD 40 +#define SSL_CTRL_SET_READ_AHEAD 41 +#define SSL_CTRL_SET_SESS_CACHE_SIZE 42 +#define SSL_CTRL_GET_SESS_CACHE_SIZE 43 +#define SSL_CTRL_SET_SESS_CACHE_MODE 44 +#define SSL_CTRL_GET_SESS_CACHE_MODE 45 + +#define SSL_CTRL_GET_MAX_CERT_LIST 50 +#define SSL_CTRL_SET_MAX_CERT_LIST 51 + +#define SSL_session_reused(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) +#define SSL_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_clear_num_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) +#define SSL_total_renegotiations(ssl) \ + SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) + +#define SSL_CTX_need_tmp_RSA(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_CTX_set_tmp_rsa(ctx,rsa) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_CTX_set_tmp_dh(ctx,dh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_need_tmp_RSA(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL) +#define SSL_set_tmp_rsa(ssl,rsa) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) +#define SSL_set_tmp_dh(ssl,dh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) +#define SSL_set_tmp_ecdh(ssl,ecdh) \ + SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) + +#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) + +#ifndef OPENSSL_NO_BIO +BIO_METHOD *BIO_f_ssl(void); +BIO *BIO_new_ssl(SSL_CTX *ctx,int client); +BIO *BIO_new_ssl_connect(SSL_CTX *ctx); +BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); +int BIO_ssl_copy_session_id(BIO *to,BIO *from); +void BIO_ssl_shutdown(BIO *ssl_bio); + +#endif + +int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str); +SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); +void SSL_CTX_free(SSL_CTX *); +long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); +long SSL_CTX_get_timeout(const SSL_CTX *ctx); +X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); +void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); +int SSL_want(const SSL *s); +int SSL_clear(SSL *s); + +void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); + +SSL_CIPHER *SSL_get_current_cipher(const SSL *s); +int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits); +char * SSL_CIPHER_get_version(const SSL_CIPHER *c); +const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); + +int SSL_get_fd(const SSL *s); +int SSL_get_rfd(const SSL *s); +int SSL_get_wfd(const SSL *s); +const char * SSL_get_cipher_list(const SSL *s,int n); +char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len); +int SSL_get_read_ahead(const SSL * s); +int SSL_pending(const SSL *s); +#ifndef OPENSSL_NO_SOCK +int SSL_set_fd(SSL *s, int fd); +int SSL_set_rfd(SSL *s, int fd); +int SSL_set_wfd(SSL *s, int fd); +#endif +#ifndef OPENSSL_NO_BIO +void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); +BIO * SSL_get_rbio(const SSL *s); +BIO * SSL_get_wbio(const SSL *s); +#endif +int SSL_set_cipher_list(SSL *s, const char *str); +void SSL_set_read_ahead(SSL *s, int yes); +int SSL_get_verify_mode(const SSL *s); +int SSL_get_verify_depth(const SSL *s); +int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *); +void SSL_set_verify(SSL *s, int mode, + int (*callback)(int ok,X509_STORE_CTX *ctx)); +void SSL_set_verify_depth(SSL *s, int depth); +#ifndef OPENSSL_NO_RSA +int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); +#endif +int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); +int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); +int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len); +int SSL_use_certificate(SSL *ssl, X509 *x); +int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); + +#ifndef OPENSSL_NO_STDIO +int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); +int SSL_use_certificate_file(SSL *ssl, const char *file, int type); +int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); +int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */ +STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); +int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *file); +#ifndef OPENSSL_SYS_VMS +#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, + const char *dir); +#endif +#endif + +#endif + +void SSL_load_error_strings(void ); +const char *SSL_state_string(const SSL *s); +const char *SSL_rstate_string(const SSL *s); +const char *SSL_state_string_long(const SSL *s); +const char *SSL_rstate_string_long(const SSL *s); +long SSL_SESSION_get_time(const SSL_SESSION *s); +long SSL_SESSION_set_time(SSL_SESSION *s, long t); +long SSL_SESSION_get_timeout(const SSL_SESSION *s); +long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); +void SSL_copy_session_id(SSL *to,const SSL *from); + +SSL_SESSION *SSL_SESSION_new(void); +unsigned long SSL_SESSION_hash(const SSL_SESSION *a); +int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b); +const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); +#ifndef OPENSSL_NO_FP_API +int SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses); +#endif +#ifndef OPENSSL_NO_BIO +int SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses); +#endif +void SSL_SESSION_free(SSL_SESSION *ses); +int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); +int SSL_set_session(SSL *to, SSL_SESSION *session); +int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); +int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); +int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); +int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); +int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, + unsigned int id_len); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,const unsigned char **pp, + long length); + +#ifdef HEADER_X509_H +X509 * SSL_get_peer_certificate(const SSL *s); +#endif + +STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); + +int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); +int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); +int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *); +void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, + int (*callback)(int, X509_STORE_CTX *)); +void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); +void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg); +#ifndef OPENSSL_NO_RSA +int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); +#endif +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); +int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); +int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, + const unsigned char *d, long len); +int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); +int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d); + +void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); +void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); + +int SSL_CTX_check_private_key(const SSL_CTX *ctx); +int SSL_check_private_key(const SSL *ctx); + +int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +SSL * SSL_new(SSL_CTX *ctx); +int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, + unsigned int sid_ctx_len); + +int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); +int SSL_set_purpose(SSL *s, int purpose); +int SSL_CTX_set_trust(SSL_CTX *s, int trust); +int SSL_set_trust(SSL *s, int trust); + +void SSL_free(SSL *ssl); +int SSL_accept(SSL *ssl); +int SSL_connect(SSL *ssl); +int SSL_read(SSL *ssl,void *buf,int num); +int SSL_peek(SSL *ssl,void *buf,int num); +int SSL_write(SSL *ssl,const void *buf,int num); +long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg); +long SSL_callback_ctrl(SSL *, int, void (*)(void)); +long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg); +long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); + +int SSL_get_error(const SSL *s,int ret_code); +const char *SSL_get_version(const SSL *s); + +/* This sets the 'default' SSL version that SSL_new() will create */ +int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); + +SSL_METHOD *SSLv2_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */ +SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */ + +SSL_METHOD *SSLv3_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */ +SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */ + +SSL_METHOD *SSLv23_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_server_method(void); /* SSLv3 but can rollback to v2 */ +SSL_METHOD *SSLv23_client_method(void); /* SSLv3 but can rollback to v2 */ + +SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ +SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ + +SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */ +SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */ + +STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); + +int SSL_do_handshake(SSL *s); +int SSL_renegotiate(SSL *s); +int SSL_renegotiate_pending(SSL *s); +int SSL_shutdown(SSL *s); + +SSL_METHOD *SSL_get_ssl_method(SSL *s); +int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); +const char *SSL_alert_type_string_long(int value); +const char *SSL_alert_type_string(int value); +const char *SSL_alert_desc_string_long(int value); +const char *SSL_alert_desc_string(int value); + +void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); +void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); +STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); +STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); +int SSL_add_client_CA(SSL *ssl,X509 *x); +int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); + +void SSL_set_connect_state(SSL *s); +void SSL_set_accept_state(SSL *s); + +long SSL_get_default_timeout(const SSL *s); + +int SSL_library_init(void ); + +char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); +STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); + +SSL *SSL_dup(SSL *ssl); + +X509 *SSL_get_certificate(const SSL *ssl); +/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl); + +void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode); +int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); +void SSL_set_quiet_shutdown(SSL *ssl,int mode); +int SSL_get_quiet_shutdown(const SSL *ssl); +void SSL_set_shutdown(SSL *ssl,int mode); +int SSL_get_shutdown(const SSL *ssl); +int SSL_version(const SSL *ssl); +int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); +int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, + const char *CApath); +#define SSL_get0_session SSL_get_session /* just peek at pointer */ +SSL_SESSION *SSL_get_session(const SSL *ssl); +SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ +SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); +void SSL_set_info_callback(SSL *ssl, + void (*cb)(const SSL *ssl,int type,int val)); +void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val); +int SSL_state(const SSL *ssl); + +void SSL_set_verify_result(SSL *ssl,long v); +long SSL_get_verify_result(const SSL *ssl); + +int SSL_set_ex_data(SSL *ssl,int idx,void *data); +void *SSL_get_ex_data(const SSL *ssl,int idx); +int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); +void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss,int idx); +int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); +void *SSL_CTX_get_ex_data(const SSL_CTX *ssl,int idx); +int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); + +int SSL_get_ex_data_X509_STORE_CTX_idx(void ); + +#define SSL_CTX_sess_set_cache_size(ctx,t) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) +#define SSL_CTX_sess_get_cache_size(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) +#define SSL_CTX_set_session_cache_mode(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) +#define SSL_CTX_get_session_cache_mode(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) + +#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) +#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) +#define SSL_CTX_get_read_ahead(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) +#define SSL_CTX_set_read_ahead(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) +#define SSL_CTX_get_max_cert_list(ctx) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_CTX_set_max_cert_list(ctx,m) \ + SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) +#define SSL_get_max_cert_list(ssl) \ + SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) +#define SSL_set_max_cert_list(ssl,m) \ + SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) + + /* NB: the keylength is only applicable when is_export is true */ +#ifndef OPENSSL_NO_RSA +void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); + +void SSL_set_tmp_rsa_callback(SSL *ssl, + RSA *(*cb)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_DH +void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_dh_callback(SSL *ssl, + DH *(*dh)(SSL *ssl,int is_export, + int keylength)); +#endif +#ifndef OPENSSL_NO_ECDH +void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +void SSL_set_tmp_ecdh_callback(SSL *ssl, + EC_KEY *(*ecdh)(SSL *ssl,int is_export, + int keylength)); +#endif + +#ifndef OPENSSL_NO_COMP +const COMP_METHOD *SSL_get_current_compression(SSL *s); +const COMP_METHOD *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const COMP_METHOD *comp); +STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); +#else +const void *SSL_get_current_compression(SSL *s); +const void *SSL_get_current_expansion(SSL *s); +const char *SSL_COMP_get_name(const void *comp); +void *SSL_COMP_get_compression_methods(void); +int SSL_COMP_add_compression_method(int id,void *cm); +#endif + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_SSL_strings(void); + +/* Error codes for the SSL functions. */ + +/* Function codes. */ +#define SSL_F_CLIENT_CERTIFICATE 100 +#define SSL_F_CLIENT_FINISHED 167 +#define SSL_F_CLIENT_HELLO 101 +#define SSL_F_CLIENT_MASTER_KEY 102 +#define SSL_F_D2I_SSL_SESSION 103 +#define SSL_F_DO_DTLS1_WRITE 245 +#define SSL_F_DO_SSL3_WRITE 104 +#define SSL_F_DTLS1_ACCEPT 246 +#define SSL_F_DTLS1_BUFFER_RECORD 247 +#define SSL_F_DTLS1_CLIENT_HELLO 248 +#define SSL_F_DTLS1_CONNECT 249 +#define SSL_F_DTLS1_ENC 250 +#define SSL_F_DTLS1_GET_HELLO_VERIFY 251 +#define SSL_F_DTLS1_GET_MESSAGE 252 +#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT 253 +#define SSL_F_DTLS1_GET_RECORD 254 +#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN 255 +#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE 256 +#define SSL_F_DTLS1_PROCESS_RECORD 257 +#define SSL_F_DTLS1_READ_BYTES 258 +#define SSL_F_DTLS1_READ_FAILED 259 +#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST 260 +#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE 261 +#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE 262 +#define SSL_F_DTLS1_SEND_CLIENT_VERIFY 263 +#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST 264 +#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE 265 +#define SSL_F_DTLS1_SEND_SERVER_HELLO 266 +#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267 +#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 +#define SSL_F_GET_CLIENT_FINISHED 105 +#define SSL_F_GET_CLIENT_HELLO 106 +#define SSL_F_GET_CLIENT_MASTER_KEY 107 +#define SSL_F_GET_SERVER_FINISHED 108 +#define SSL_F_GET_SERVER_HELLO 109 +#define SSL_F_GET_SERVER_VERIFY 110 +#define SSL_F_I2D_SSL_SESSION 111 +#define SSL_F_READ_N 112 +#define SSL_F_REQUEST_CERTIFICATE 113 +#define SSL_F_SERVER_FINISH 239 +#define SSL_F_SERVER_HELLO 114 +#define SSL_F_SERVER_VERIFY 240 +#define SSL_F_SSL23_ACCEPT 115 +#define SSL_F_SSL23_CLIENT_HELLO 116 +#define SSL_F_SSL23_CONNECT 117 +#define SSL_F_SSL23_GET_CLIENT_HELLO 118 +#define SSL_F_SSL23_GET_SERVER_HELLO 119 +#define SSL_F_SSL23_PEEK 237 +#define SSL_F_SSL23_READ 120 +#define SSL_F_SSL23_WRITE 121 +#define SSL_F_SSL2_ACCEPT 122 +#define SSL_F_SSL2_CONNECT 123 +#define SSL_F_SSL2_ENC_INIT 124 +#define SSL_F_SSL2_GENERATE_KEY_MATERIAL 241 +#define SSL_F_SSL2_PEEK 234 +#define SSL_F_SSL2_READ 125 +#define SSL_F_SSL2_READ_INTERNAL 236 +#define SSL_F_SSL2_SET_CERTIFICATE 126 +#define SSL_F_SSL2_WRITE 127 +#define SSL_F_SSL3_ACCEPT 128 +#define SSL_F_SSL3_CALLBACK_CTRL 233 +#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 +#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CLIENT_HELLO 131 +#define SSL_F_SSL3_CONNECT 132 +#define SSL_F_SSL3_CTRL 213 +#define SSL_F_SSL3_CTX_CTRL 133 +#define SSL_F_SSL3_ENC 134 +#define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 +#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 +#define SSL_F_SSL3_GET_CERT_VERIFY 136 +#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 +#define SSL_F_SSL3_GET_CLIENT_HELLO 138 +#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139 +#define SSL_F_SSL3_GET_FINISHED 140 +#define SSL_F_SSL3_GET_KEY_EXCHANGE 141 +#define SSL_F_SSL3_GET_MESSAGE 142 +#define SSL_F_SSL3_GET_RECORD 143 +#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144 +#define SSL_F_SSL3_GET_SERVER_DONE 145 +#define SSL_F_SSL3_GET_SERVER_HELLO 146 +#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 +#define SSL_F_SSL3_PEEK 235 +#define SSL_F_SSL3_READ_BYTES 148 +#define SSL_F_SSL3_READ_N 149 +#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 +#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151 +#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152 +#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153 +#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154 +#define SSL_F_SSL3_SEND_SERVER_HELLO 242 +#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155 +#define SSL_F_SSL3_SETUP_BUFFERS 156 +#define SSL_F_SSL3_SETUP_KEY_BLOCK 157 +#define SSL_F_SSL3_WRITE_BYTES 158 +#define SSL_F_SSL3_WRITE_PENDING 159 +#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 +#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 +#define SSL_F_SSL_BAD_METHOD 160 +#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 +#define SSL_F_SSL_CERT_DUP 221 +#define SSL_F_SSL_CERT_INST 222 +#define SSL_F_SSL_CERT_INSTANTIATE 214 +#define SSL_F_SSL_CERT_NEW 162 +#define SSL_F_SSL_CHECK_PRIVATE_KEY 163 +#define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 +#define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 +#define SSL_F_SSL_CLEAR 164 +#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 +#define SSL_F_SSL_CREATE_CIPHER_LIST 166 +#define SSL_F_SSL_CTRL 232 +#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 +#define SSL_F_SSL_CTX_NEW 169 +#define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 +#define SSL_F_SSL_CTX_SET_PURPOSE 226 +#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 +#define SSL_F_SSL_CTX_SET_SSL_VERSION 170 +#define SSL_F_SSL_CTX_SET_TRUST 229 +#define SSL_F_SSL_CTX_USE_CERTIFICATE 171 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 +#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 +#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 +#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 +#define SSL_F_SSL_DO_HANDSHAKE 180 +#define SSL_F_SSL_GET_NEW_SESSION 181 +#define SSL_F_SSL_GET_PREV_SESSION 217 +#define SSL_F_SSL_GET_SERVER_SEND_CERT 182 +#define SSL_F_SSL_GET_SIGN_PKEY 183 +#define SSL_F_SSL_INIT_WBIO_BUFFER 184 +#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 +#define SSL_F_SSL_NEW 186 +#define SSL_F_SSL_PEEK 270 +#define SSL_F_SSL_READ 223 +#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187 +#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188 +#define SSL_F_SSL_SESSION_NEW 189 +#define SSL_F_SSL_SESSION_PRINT_FP 190 +#define SSL_F_SSL_SESS_CERT_NEW 225 +#define SSL_F_SSL_SET_CERT 191 +#define SSL_F_SSL_SET_CIPHER_LIST 271 +#define SSL_F_SSL_SET_FD 192 +#define SSL_F_SSL_SET_PKEY 193 +#define SSL_F_SSL_SET_PURPOSE 227 +#define SSL_F_SSL_SET_RFD 194 +#define SSL_F_SSL_SET_SESSION 195 +#define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 +#define SSL_F_SSL_SET_TRUST 228 +#define SSL_F_SSL_SET_WFD 196 +#define SSL_F_SSL_SHUTDOWN 224 +#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION 243 +#define SSL_F_SSL_UNDEFINED_FUNCTION 197 +#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 +#define SSL_F_SSL_USE_CERTIFICATE 198 +#define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 +#define SSL_F_SSL_USE_CERTIFICATE_FILE 200 +#define SSL_F_SSL_USE_PRIVATEKEY 201 +#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 +#define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 +#define SSL_F_SSL_USE_RSAPRIVATEKEY 204 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 +#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 +#define SSL_F_SSL_VERIFY_CERT_CHAIN 207 +#define SSL_F_SSL_WRITE 208 +#define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 +#define SSL_F_TLS1_ENC 210 +#define SSL_F_TLS1_SETUP_KEY_BLOCK 211 +#define SSL_F_WRITE_PENDING 212 + +/* Reason codes. */ +#define SSL_R_APP_DATA_IN_HANDSHAKE 100 +#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 +#define SSL_R_BAD_ALERT_RECORD 101 +#define SSL_R_BAD_AUTHENTICATION_TYPE 102 +#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 +#define SSL_R_BAD_CHECKSUM 104 +#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 +#define SSL_R_BAD_DECOMPRESSION 107 +#define SSL_R_BAD_DH_G_LENGTH 108 +#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109 +#define SSL_R_BAD_DH_P_LENGTH 110 +#define SSL_R_BAD_DIGEST_LENGTH 111 +#define SSL_R_BAD_DSA_SIGNATURE 112 +#define SSL_R_BAD_ECC_CERT 304 +#define SSL_R_BAD_ECDSA_SIGNATURE 305 +#define SSL_R_BAD_ECPOINT 306 +#define SSL_R_BAD_HELLO_REQUEST 105 +#define SSL_R_BAD_LENGTH 271 +#define SSL_R_BAD_MAC_DECODE 113 +#define SSL_R_BAD_MESSAGE_TYPE 114 +#define SSL_R_BAD_PACKET_LENGTH 115 +#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 +#define SSL_R_BAD_RESPONSE_ARGUMENT 117 +#define SSL_R_BAD_RSA_DECRYPT 118 +#define SSL_R_BAD_RSA_ENCRYPT 119 +#define SSL_R_BAD_RSA_E_LENGTH 120 +#define SSL_R_BAD_RSA_MODULUS_LENGTH 121 +#define SSL_R_BAD_RSA_SIGNATURE 122 +#define SSL_R_BAD_SIGNATURE 123 +#define SSL_R_BAD_SSL_FILETYPE 124 +#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125 +#define SSL_R_BAD_STATE 126 +#define SSL_R_BAD_WRITE_RETRY 127 +#define SSL_R_BIO_NOT_SET 128 +#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 +#define SSL_R_BN_LIB 130 +#define SSL_R_CA_DN_LENGTH_MISMATCH 131 +#define SSL_R_CA_DN_TOO_LONG 132 +#define SSL_R_CCS_RECEIVED_EARLY 133 +#define SSL_R_CERTIFICATE_VERIFY_FAILED 134 +#define SSL_R_CERT_LENGTH_MISMATCH 135 +#define SSL_R_CHALLENGE_IS_DIFFERENT 136 +#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 +#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 +#define SSL_R_CIPHER_TABLE_SRC_ERROR 139 +#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 +#define SSL_R_COMPRESSION_FAILURE 141 +#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 +#define SSL_R_COMPRESSION_LIBRARY_ERROR 142 +#define SSL_R_CONNECTION_ID_IS_DIFFERENT 143 +#define SSL_R_CONNECTION_TYPE_NOT_SET 144 +#define SSL_R_COOKIE_MISMATCH 308 +#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 +#define SSL_R_DATA_LENGTH_TOO_LONG 146 +#define SSL_R_DECRYPTION_FAILED 147 +#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 +#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 +#define SSL_R_DIGEST_CHECK_FAILED 149 +#define SSL_R_DUPLICATE_COMPRESSION_ID 309 +#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER 310 +#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 +#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 282 +#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 +#define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 +#define SSL_R_EXTRA_DATA_IN_MESSAGE 153 +#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 +#define SSL_R_HTTPS_PROXY_REQUEST 155 +#define SSL_R_HTTP_REQUEST 156 +#define SSL_R_ILLEGAL_PADDING 283 +#define SSL_R_INVALID_CHALLENGE_LENGTH 158 +#define SSL_R_INVALID_COMMAND 280 +#define SSL_R_INVALID_PURPOSE 278 +#define SSL_R_INVALID_TRUST 279 +#define SSL_R_KEY_ARG_TOO_LONG 284 +#define SSL_R_KRB5 285 +#define SSL_R_KRB5_C_CC_PRINC 286 +#define SSL_R_KRB5_C_GET_CRED 287 +#define SSL_R_KRB5_C_INIT 288 +#define SSL_R_KRB5_C_MK_REQ 289 +#define SSL_R_KRB5_S_BAD_TICKET 290 +#define SSL_R_KRB5_S_INIT 291 +#define SSL_R_KRB5_S_RD_REQ 292 +#define SSL_R_KRB5_S_TKT_EXPIRED 293 +#define SSL_R_KRB5_S_TKT_NYV 294 +#define SSL_R_KRB5_S_TKT_SKEW 295 +#define SSL_R_LENGTH_MISMATCH 159 +#define SSL_R_LENGTH_TOO_SHORT 160 +#define SSL_R_LIBRARY_BUG 274 +#define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 +#define SSL_R_MESSAGE_TOO_LONG 296 +#define SSL_R_MISSING_DH_DSA_CERT 162 +#define SSL_R_MISSING_DH_KEY 163 +#define SSL_R_MISSING_DH_RSA_CERT 164 +#define SSL_R_MISSING_DSA_SIGNING_CERT 165 +#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166 +#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167 +#define SSL_R_MISSING_RSA_CERTIFICATE 168 +#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 +#define SSL_R_MISSING_RSA_SIGNING_CERT 170 +#define SSL_R_MISSING_TMP_DH_KEY 171 +#define SSL_R_MISSING_TMP_ECDH_KEY 311 +#define SSL_R_MISSING_TMP_RSA_KEY 172 +#define SSL_R_MISSING_TMP_RSA_PKEY 173 +#define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_NON_SSLV2_INITIAL_PACKET 175 +#define SSL_R_NO_CERTIFICATES_RETURNED 176 +#define SSL_R_NO_CERTIFICATE_ASSIGNED 177 +#define SSL_R_NO_CERTIFICATE_RETURNED 178 +#define SSL_R_NO_CERTIFICATE_SET 179 +#define SSL_R_NO_CERTIFICATE_SPECIFIED 180 +#define SSL_R_NO_CIPHERS_AVAILABLE 181 +#define SSL_R_NO_CIPHERS_PASSED 182 +#define SSL_R_NO_CIPHERS_SPECIFIED 183 +#define SSL_R_NO_CIPHER_LIST 184 +#define SSL_R_NO_CIPHER_MATCH 185 +#define SSL_R_NO_CLIENT_CERT_RECEIVED 186 +#define SSL_R_NO_COMPRESSION_SPECIFIED 187 +#define SSL_R_NO_METHOD_SPECIFIED 188 +#define SSL_R_NO_PRIVATEKEY 189 +#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 +#define SSL_R_NO_PROTOCOLS_AVAILABLE 191 +#define SSL_R_NO_PUBLICKEY 192 +#define SSL_R_NO_SHARED_CIPHER 193 +#define SSL_R_NO_VERIFY_CALLBACK 194 +#define SSL_R_NULL_SSL_CTX 195 +#define SSL_R_NULL_SSL_METHOD_PASSED 196 +#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 +#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE 297 +#define SSL_R_PACKET_LENGTH_TOO_LONG 198 +#define SSL_R_PATH_TOO_LONG 270 +#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 +#define SSL_R_PEER_ERROR 200 +#define SSL_R_PEER_ERROR_CERTIFICATE 201 +#define SSL_R_PEER_ERROR_NO_CERTIFICATE 202 +#define SSL_R_PEER_ERROR_NO_CIPHER 203 +#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204 +#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205 +#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206 +#define SSL_R_PROTOCOL_IS_SHUTDOWN 207 +#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208 +#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209 +#define SSL_R_PUBLIC_KEY_NOT_RSA 210 +#define SSL_R_READ_BIO_NOT_SET 211 +#define SSL_R_READ_TIMEOUT_EXPIRED 312 +#define SSL_R_READ_WRONG_PACKET_TYPE 212 +#define SSL_R_RECORD_LENGTH_MISMATCH 213 +#define SSL_R_RECORD_TOO_LARGE 214 +#define SSL_R_RECORD_TOO_SMALL 298 +#define SSL_R_REQUIRED_CIPHER_MISSING 215 +#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216 +#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217 +#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218 +#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 +#define SSL_R_SHORT_READ 219 +#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 +#define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221 +#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG 299 +#define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 +#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222 +#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 +#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 +#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 +#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 +#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 +#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 +#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 +#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 +#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 +#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 +#define SSL_R_SSL_HANDSHAKE_FAILURE 229 +#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 +#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 +#define SSL_R_SSL_SESSION_ID_CONFLICT 302 +#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 +#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 +#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 +#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 +#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 +#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 +#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 +#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 +#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 +#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 +#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 +#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 +#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 +#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 +#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 +#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 +#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 +#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 +#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235 +#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236 +#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS 313 +#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237 +#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238 +#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 +#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 +#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240 +#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241 +#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 +#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 +#define SSL_R_UNEXPECTED_MESSAGE 244 +#define SSL_R_UNEXPECTED_RECORD 245 +#define SSL_R_UNINITIALIZED 276 +#define SSL_R_UNKNOWN_ALERT_TYPE 246 +#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 +#define SSL_R_UNKNOWN_CIPHER_RETURNED 248 +#define SSL_R_UNKNOWN_CIPHER_TYPE 249 +#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 +#define SSL_R_UNKNOWN_PKEY_TYPE 251 +#define SSL_R_UNKNOWN_PROTOCOL 252 +#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253 +#define SSL_R_UNKNOWN_SSL_VERSION 254 +#define SSL_R_UNKNOWN_STATE 255 +#define SSL_R_UNSUPPORTED_CIPHER 256 +#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 +#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 +#define SSL_R_UNSUPPORTED_PROTOCOL 258 +#define SSL_R_UNSUPPORTED_SSL_VERSION 259 +#define SSL_R_WRITE_BIO_NOT_SET 260 +#define SSL_R_WRONG_CIPHER_RETURNED 261 +#define SSL_R_WRONG_MESSAGE_TYPE 262 +#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263 +#define SSL_R_WRONG_SIGNATURE_LENGTH 264 +#define SSL_R_WRONG_SIGNATURE_SIZE 265 +#define SSL_R_WRONG_SSL_VERSION 266 +#define SSL_R_WRONG_VERSION_NUMBER 267 +#define SSL_R_X509_LIB 268 +#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ssl2.h b/libraries/external/openssl/pc/include/openssl/ssl2.h new file mode 100755 index 0000000..c871efe --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ssl2.h @@ -0,0 +1,268 @@ +/* ssl/ssl2.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL2_H +#define HEADER_SSL2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Protocol Version Codes */ +#define SSL2_VERSION 0x0002 +#define SSL2_VERSION_MAJOR 0x00 +#define SSL2_VERSION_MINOR 0x02 +/* #define SSL2_CLIENT_VERSION 0x0002 */ +/* #define SSL2_SERVER_VERSION 0x0002 */ + +/* Protocol Message Codes */ +#define SSL2_MT_ERROR 0 +#define SSL2_MT_CLIENT_HELLO 1 +#define SSL2_MT_CLIENT_MASTER_KEY 2 +#define SSL2_MT_CLIENT_FINISHED 3 +#define SSL2_MT_SERVER_HELLO 4 +#define SSL2_MT_SERVER_VERIFY 5 +#define SSL2_MT_SERVER_FINISHED 6 +#define SSL2_MT_REQUEST_CERTIFICATE 7 +#define SSL2_MT_CLIENT_CERTIFICATE 8 + +/* Error Message Codes */ +#define SSL2_PE_UNDEFINED_ERROR 0x0000 +#define SSL2_PE_NO_CIPHER 0x0001 +#define SSL2_PE_NO_CERTIFICATE 0x0002 +#define SSL2_PE_BAD_CERTIFICATE 0x0004 +#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006 + +/* Cipher Kind Values */ +#define SSL2_CK_NULL_WITH_MD5 0x02000000 /* v3 */ +#define SSL2_CK_RC4_128_WITH_MD5 0x02010080 +#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5 0x02020080 +#define SSL2_CK_RC2_128_CBC_WITH_MD5 0x02030080 +#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5 0x02040080 +#define SSL2_CK_IDEA_128_CBC_WITH_MD5 0x02050080 +#define SSL2_CK_DES_64_CBC_WITH_MD5 0x02060040 +#define SSL2_CK_DES_64_CBC_WITH_SHA 0x02060140 /* v3 */ +#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5 0x020700c0 +#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA 0x020701c0 /* v3 */ +#define SSL2_CK_RC4_64_WITH_MD5 0x02080080 /* MS hack */ + +#define SSL2_CK_DES_64_CFB64_WITH_MD5_1 0x02ff0800 /* SSLeay */ +#define SSL2_CK_NULL 0x02ff0810 /* SSLeay */ + +#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1 "DES-CFB-M1" +#define SSL2_TXT_NULL_WITH_MD5 "NULL-MD5" +#define SSL2_TXT_RC4_128_WITH_MD5 "RC4-MD5" +#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5 "EXP-RC4-MD5" +#define SSL2_TXT_RC2_128_CBC_WITH_MD5 "RC2-CBC-MD5" +#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 "EXP-RC2-CBC-MD5" +#define SSL2_TXT_IDEA_128_CBC_WITH_MD5 "IDEA-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_MD5 "DES-CBC-MD5" +#define SSL2_TXT_DES_64_CBC_WITH_SHA "DES-CBC-SHA" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 "DES-CBC3-MD5" +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA "DES-CBC3-SHA" +#define SSL2_TXT_RC4_64_WITH_MD5 "RC4-64-MD5" + +#define SSL2_TXT_NULL "NULL" + +/* Flags for the SSL_CIPHER.algorithm2 field */ +#define SSL2_CF_5_BYTE_ENC 0x01 +#define SSL2_CF_8_BYTE_ENC 0x02 + +/* Certificate Type Codes */ +#define SSL2_CT_X509_CERTIFICATE 0x01 + +/* Authentication Type Code */ +#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION 0x01 + +#define SSL2_MAX_SSL_SESSION_ID_LENGTH 32 + +/* Upper/Lower Bounds */ +#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 +#ifdef OPENSSL_SYS_MPE +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u +#else +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ +#endif +#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ + +#define SSL2_CHALLENGE_LENGTH 16 +/*#define SSL2_CHALLENGE_LENGTH 32 */ +#define SSL2_MIN_CHALLENGE_LENGTH 16 +#define SSL2_MAX_CHALLENGE_LENGTH 32 +#define SSL2_CONNECTION_ID_LENGTH 16 +#define SSL2_MAX_CONNECTION_ID_LENGTH 16 +#define SSL2_SSL_SESSION_ID_LENGTH 16 +#define SSL2_MAX_CERT_CHALLENGE_LENGTH 32 +#define SSL2_MIN_CERT_CHALLENGE_LENGTH 16 +#define SSL2_MAX_KEY_MATERIAL_LENGTH 24 + +#ifndef HEADER_SSL_LOCL_H +#define CERT char +#endif + +typedef struct ssl2_state_st + { + int three_byte_header; + int clear_text; /* clear text */ + int escape; /* not used in SSLv2 */ + int ssl2_rollback; /* used if SSLv23 rolled back to SSLv2 */ + + /* non-blocking io info, used to make sure the same + * args were passwd */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; + const unsigned char *wpend_buf; + + int wpend_off; /* offset to data to write */ + int wpend_len; /* number of bytes passwd to write */ + int wpend_ret; /* number of bytes to return to caller */ + + /* buffer raw data */ + int rbuf_left; + int rbuf_offs; + unsigned char *rbuf; + unsigned char *wbuf; + + unsigned char *write_ptr;/* used to point to the start due to + * 2/3 byte header. */ + + unsigned int padding; + unsigned int rlength; /* passed to ssl2_enc */ + int ract_data_length; /* Set when things are encrypted. */ + unsigned int wlength; /* passed to ssl2_enc */ + int wact_data_length; /* Set when things are decrypted. */ + unsigned char *ract_data; + unsigned char *wact_data; + unsigned char *mac_data; + + unsigned char *read_key; + unsigned char *write_key; + + /* Stuff specifically to do with this SSL session */ + unsigned int challenge_length; + unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH]; + unsigned int conn_id_length; + unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH]; + unsigned int key_material_length; + unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2]; + + unsigned long read_sequence; + unsigned long write_sequence; + + struct { + unsigned int conn_id_length; + unsigned int cert_type; + unsigned int cert_length; + unsigned int csl; + unsigned int clear; + unsigned int enc; + unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; + unsigned int cipher_spec_length; + unsigned int session_id_length; + unsigned int clen; + unsigned int rlen; + } tmp; + } SSL2_STATE; + +/* SSLv2 */ +/* client */ +#define SSL2_ST_SEND_CLIENT_HELLO_A (0x10|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_HELLO_B (0x11|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_A (0x20|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_HELLO_B (0x21|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A (0x30|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B (0x31|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_A (0x40|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_FINISHED_B (0x41|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A (0x50|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B (0x51|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C (0x52|SSL_ST_CONNECT) +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D (0x53|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_A (0x60|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_VERIFY_B (0x61|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_A (0x70|SSL_ST_CONNECT) +#define SSL2_ST_GET_SERVER_FINISHED_B (0x71|SSL_ST_CONNECT) +#define SSL2_ST_CLIENT_START_ENCRYPTION (0x80|SSL_ST_CONNECT) +#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE (0x90|SSL_ST_CONNECT) +/* server */ +#define SSL2_ST_GET_CLIENT_HELLO_A (0x10|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_B (0x11|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_HELLO_C (0x12|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_A (0x20|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_HELLO_B (0x21|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_A (0x30|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_MASTER_KEY_B (0x31|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_A (0x40|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_B (0x41|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_VERIFY_C (0x42|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_A (0x50|SSL_ST_ACCEPT) +#define SSL2_ST_GET_CLIENT_FINISHED_B (0x51|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_A (0x60|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_SERVER_FINISHED_B (0x61|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A (0x70|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B (0x71|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C (0x72|SSL_ST_ACCEPT) +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D (0x73|SSL_ST_ACCEPT) +#define SSL2_ST_SERVER_START_ENCRYPTION (0x80|SSL_ST_ACCEPT) +#define SSL2_ST_X509_GET_SERVER_CERTIFICATE (0x90|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/ssl23.h b/libraries/external/openssl/pc/include/openssl/ssl23.h new file mode 100755 index 0000000..1a87d8c --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ssl23.h @@ -0,0 +1,83 @@ +/* ssl/ssl23.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_SSL23_H +#define HEADER_SSL23_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*client */ +/* write to server */ +#define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) +#define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) +/* read from server */ +#define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) +#define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) + +/* server */ +/* read from client */ +#define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) +#define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/ssl3.h b/libraries/external/openssl/pc/include/openssl/ssl3.h new file mode 100755 index 0000000..45e7c99 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ssl3.h @@ -0,0 +1,555 @@ +/* ssl/ssl3.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECC cipher suite support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_SSL3_H +#define HEADER_SSL3_H + +#ifndef OPENSSL_NO_COMP +#include +#endif +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define SSL3_CK_RSA_NULL_MD5 0x03000001 +#define SSL3_CK_RSA_NULL_SHA 0x03000002 +#define SSL3_CK_RSA_RC4_40_MD5 0x03000003 +#define SSL3_CK_RSA_RC4_128_MD5 0x03000004 +#define SSL3_CK_RSA_RC4_128_SHA 0x03000005 +#define SSL3_CK_RSA_RC2_40_MD5 0x03000006 +#define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 +#define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 +#define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 +#define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A + +#define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B +#define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C +#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D +#define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E +#define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F +#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 + +#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 +#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 +#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 +#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 +#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 +#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 + +#define SSL3_CK_ADH_RC4_40_MD5 0x03000017 +#define SSL3_CK_ADH_RC4_128_MD5 0x03000018 +#define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 +#define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A +#define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B + +#define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C +#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D +#if 0 /* Because it clashes with KRB5, is never used any more, and is safe + to remove according to David Hopwood + of the ietf-tls list */ +#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E +#endif + +/* VRS Additional Kerberos5 entries + */ +#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E +#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F +#define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 +#define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 +#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 +#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 +#define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 +#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 + +#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 +#define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 +#define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 +#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 +#define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A +#define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B + +#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" +#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" +#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" +#define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" +#define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" +#define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" +#define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" +#define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" + +#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" +#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" +#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" +#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" +#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" +#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" + +#define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" +#define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" +#define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" +#define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" + +#define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA" +#define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" +#define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" + +#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" +#define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" +#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" +#define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" +#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" + +#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" +#define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" +#define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" +#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" +#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" +#define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" + +#define SSL3_SSL_SESSION_ID_LENGTH 32 +#define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 + +#define SSL3_MASTER_SECRET_SIZE 48 +#define SSL3_RANDOM_SIZE 32 +#define SSL3_SESSION_ID_SIZE 32 +#define SSL3_RT_HEADER_LENGTH 5 + +/* Due to MS stuffing up, this can change.... */ +#if defined(OPENSSL_SYS_WIN16) || \ + (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) +#define SSL3_RT_MAX_EXTRA (14000) +#else +#define SSL3_RT_MAX_EXTRA (16384) +#endif + +#define SSL3_RT_MAX_PLAIN_LENGTH 16384 +#ifdef OPENSSL_NO_COMP +#define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH +#else +#define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH) +#endif +#define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH) +#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) +#define SSL3_RT_MAX_DATA_SIZE (1024*1024) + +#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" +#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" + +#define SSL3_VERSION 0x0300 +#define SSL3_VERSION_MAJOR 0x03 +#define SSL3_VERSION_MINOR 0x00 + +#define SSL3_RT_CHANGE_CIPHER_SPEC 20 +#define SSL3_RT_ALERT 21 +#define SSL3_RT_HANDSHAKE 22 +#define SSL3_RT_APPLICATION_DATA 23 + +#define SSL3_AL_WARNING 1 +#define SSL3_AL_FATAL 2 + +#define SSL3_AD_CLOSE_NOTIFY 0 +#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ +#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ +#define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ +#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ +#define SSL3_AD_NO_CERTIFICATE 41 +#define SSL3_AD_BAD_CERTIFICATE 42 +#define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 +#define SSL3_AD_CERTIFICATE_REVOKED 44 +#define SSL3_AD_CERTIFICATE_EXPIRED 45 +#define SSL3_AD_CERTIFICATE_UNKNOWN 46 +#define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ + +typedef struct ssl3_record_st + { +/*r */ int type; /* type of record */ +/*rw*/ unsigned int length; /* How many bytes available */ +/*r */ unsigned int off; /* read/write offset into 'buf' */ +/*rw*/ unsigned char *data; /* pointer to the record data */ +/*rw*/ unsigned char *input; /* where the decode bytes are */ +/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ +/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */ +/*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */ + } SSL3_RECORD; + +typedef struct ssl3_buffer_st + { + unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, + * see ssl3_setup_buffers() */ + size_t len; /* buffer size */ + int offset; /* where to 'copy from' */ + int left; /* how many bytes left */ + } SSL3_BUFFER; + +#define SSL3_CT_RSA_SIGN 1 +#define SSL3_CT_DSS_SIGN 2 +#define SSL3_CT_RSA_FIXED_DH 3 +#define SSL3_CT_DSS_FIXED_DH 4 +#define SSL3_CT_RSA_EPHEMERAL_DH 5 +#define SSL3_CT_DSS_EPHEMERAL_DH 6 +#define SSL3_CT_FORTEZZA_DMS 20 +/* SSL3_CT_NUMBER is used to size arrays and it must be large + * enough to contain all of the cert types defined either for + * SSLv3 and TLSv1. + */ +#define SSL3_CT_NUMBER 7 + + +#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 +#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 +#define SSL3_FLAGS_POP_BUFFER 0x0004 +#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +typedef struct ssl3_state_st + { + long flags; + int delay_buf_pop_ret; + + unsigned char read_sequence[8]; + unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; + unsigned char write_sequence[8]; + unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; + + unsigned char server_random[SSL3_RANDOM_SIZE]; + unsigned char client_random[SSL3_RANDOM_SIZE]; + + /* flags for countermeasure against known-IV weakness */ + int need_empty_fragments; + int empty_fragment_done; + + SSL3_BUFFER rbuf; /* read IO goes into here */ + SSL3_BUFFER wbuf; /* write IO goes into here */ + + SSL3_RECORD rrec; /* each decoded record goes in here */ + SSL3_RECORD wrec; /* goes out from here */ + + /* storage for Alert/Handshake protocol data received but not + * yet processed by ssl3_read_bytes: */ + unsigned char alert_fragment[2]; + unsigned int alert_fragment_len; + unsigned char handshake_fragment[4]; + unsigned int handshake_fragment_len; + + /* partial write - check the numbers match */ + unsigned int wnum; /* number of bytes sent so far */ + int wpend_tot; /* number bytes written */ + int wpend_type; + int wpend_ret; /* number of bytes submitted */ + const unsigned char *wpend_buf; + + /* used during startup, digest all incoming/outgoing packets */ + EVP_MD_CTX finish_dgst1; + EVP_MD_CTX finish_dgst2; + + /* this is set whenerver we see a change_cipher_spec message + * come in when we are not looking for one */ + int change_cipher_spec; + + int warn_alert; + int fatal_alert; + /* we allow one fatal and one warning alert to be outstanding, + * send close alert via the warning alert */ + int alert_dispatch; + unsigned char send_alert[2]; + + /* This flag is set when we should renegotiate ASAP, basically when + * there is no more data in the read or write buffers */ + int renegotiate; + int total_renegotiations; + int num_renegotiations; + + int in_read_app_data; + + struct { + /* actually only needs to be 16+20 */ + unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; + + /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ + unsigned char finish_md[EVP_MAX_MD_SIZE*2]; + int finish_md_len; + unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; + int peer_finish_md_len; + + unsigned long message_size; + int message_type; + + /* used to hold the new cipher we are going to use */ + SSL_CIPHER *new_cipher; +#ifndef OPENSSL_NO_DH + DH *dh; +#endif + +#ifndef OPENSSL_NO_ECDH + EC_KEY *ecdh; /* holds short lived ECDH key */ +#endif + + /* used when SSL_ST_FLUSH_DATA is entered */ + int next_state; + + int reuse_message; + + /* used for certificate requests */ + int cert_req; + int ctype_num; + char ctype[SSL3_CT_NUMBER]; + STACK_OF(X509_NAME) *ca_names; + + int use_rsa_tmp; + + int key_block_length; + unsigned char *key_block; + + const EVP_CIPHER *new_sym_enc; + const EVP_MD *new_hash; +#ifndef OPENSSL_NO_COMP + const SSL_COMP *new_compression; +#else + char *new_compression; +#endif + int cert_request; + } tmp; + + } SSL3_STATE; + + +/* SSLv3 */ +/*client */ +/* extra state */ +#define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) +#define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT) +#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) +#define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) +#define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) +#define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) +/* write to server */ +#define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) +#define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) +#define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) +#define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) +#define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) +/* read from server */ +#define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) +#define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) +#define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) + +/* server */ +/* extra state */ +#define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) +/* read from client */ +/* Do not change the number values, they do matter */ +#define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) +/* write to client */ +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT) +#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) +#define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) +#define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) +#define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) +/* read from client */ +#define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) +#define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) +#define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) +/* write to client */ +#define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) +#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) + +#define SSL3_MT_HELLO_REQUEST 0 +#define SSL3_MT_CLIENT_HELLO 1 +#define SSL3_MT_SERVER_HELLO 2 +#define SSL3_MT_CERTIFICATE 11 +#define SSL3_MT_SERVER_KEY_EXCHANGE 12 +#define SSL3_MT_CERTIFICATE_REQUEST 13 +#define SSL3_MT_SERVER_DONE 14 +#define SSL3_MT_CERTIFICATE_VERIFY 15 +#define SSL3_MT_CLIENT_KEY_EXCHANGE 16 +#define SSL3_MT_FINISHED 20 +#define DTLS1_MT_HELLO_VERIFY_REQUEST 3 + + +#define SSL3_MT_CCS 1 + +/* These are used when changing over to a new cipher */ +#define SSL3_CC_READ 0x01 +#define SSL3_CC_WRITE 0x02 +#define SSL3_CC_CLIENT 0x10 +#define SSL3_CC_SERVER 0x20 +#define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) +#define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) +#define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/stack.h b/libraries/external/openssl/pc/include/openssl/stack.h new file mode 100755 index 0000000..7f3b13d --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/stack.h @@ -0,0 +1,109 @@ +/* crypto/stack/stack.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_STACK_H +#define HEADER_STACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct stack_st + { + int num; + char **data; + int sorted; + + int num_alloc; + int (*comp)(const char * const *, const char * const *); + } STACK; + +#define M_sk_num(sk) ((sk) ? (sk)->num:-1) +#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) + +int sk_num(const STACK *); +char *sk_value(const STACK *, int); + +char *sk_set(STACK *, int, char *); + +STACK *sk_new(int (*cmp)(const char * const *, const char * const *)); +STACK *sk_new_null(void); +void sk_free(STACK *); +void sk_pop_free(STACK *st, void (*func)(void *)); +int sk_insert(STACK *sk,char *data,int where); +char *sk_delete(STACK *st,int loc); +char *sk_delete_ptr(STACK *st, char *p); +int sk_find(STACK *st,char *data); +int sk_find_ex(STACK *st,char *data); +int sk_push(STACK *st,char *data); +int sk_unshift(STACK *st,char *data); +char *sk_shift(STACK *st); +char *sk_pop(STACK *st); +void sk_zero(STACK *st); +int (*sk_set_cmp_func(STACK *sk, int (*c)(const char * const *, + const char * const *))) + (const char * const *, const char * const *); +STACK *sk_dup(STACK *st); +void sk_sort(STACK *st); +int sk_is_sorted(const STACK *st); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/store.h b/libraries/external/openssl/pc/include/openssl/store.h new file mode 100755 index 0000000..9665d0d --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/store.h @@ -0,0 +1,554 @@ +/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2003. + */ +/* ==================================================================== + * Copyright (c) 2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_STORE_H +#define HEADER_STORE_H + +#include +#ifndef OPENSSL_NO_DEPRECATED +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Already defined in ossl_typ.h */ +/* typedef struct store_st STORE; */ +/* typedef struct store_method_st STORE_METHOD; */ + + +/* All the following functions return 0, a negative number or NULL on error. + When everything is fine, they return a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +STORE *STORE_new_method(const STORE_METHOD *method); +STORE *STORE_new_engine(ENGINE *engine); +void STORE_free(STORE *ui); + + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a STORE. */ +int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void)); + +/* A control to set the directory with keys and certificates. Used by the + built-in directory level method. */ +#define STORE_CTRL_SET_DIRECTORY 0x0001 +/* A control to set a file to load. Used by the built-in file level method. */ +#define STORE_CTRL_SET_FILE 0x0002 +/* A control to set a configuration file to load. Can be used by any method + that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_FILE 0x0003 +/* A control to set a the section of the loaded configuration file. Can be + used by any method that wishes to load a configuration file. */ +#define STORE_CTRL_SET_CONF_SECTION 0x0004 + + +/* Some methods may use extra data */ +#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg) +#define STORE_get_app_data(s) STORE_get_ex_data(s,0) +int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int STORE_set_ex_data(STORE *r,int idx,void *arg); +void *STORE_get_ex_data(STORE *r, int idx); + +/* Use specific methods instead of the built-in one */ +const STORE_METHOD *STORE_get_method(STORE *store); +const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth); + +/* The standard OpenSSL methods. */ +/* This is the in-memory method. It does everything except revoking and updating, + and is of course volatile. It's used by other methods that have an in-memory + cache. */ +const STORE_METHOD *STORE_Memory(void); +#if 0 /* Not yet implemented */ +/* This is the directory store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. */ +const STORE_METHOD *STORE_Directory(void); +/* This is the file store. It does everything except revoking and updating, + and uses STORE_Memory() to cache things in memory. Certificates are added + to it with the store operation, and it will only get cached certificates. */ +const STORE_METHOD *STORE_File(void); +#endif + +/* Store functions take a type code for the type of data they should store + or fetch */ +typedef enum STORE_object_types + { + STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */ + STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */ + STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */ + STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */ + STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */ + STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known + object types */ + } STORE_OBJECT_TYPES; +/* List of text strings corresponding to the object types. */ +extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1]; + +/* Some store functions take a parameter list. Those parameters come with + one of the following codes. The comments following the codes below indicate + what type the value should be a pointer to. */ +typedef enum STORE_params + { + STORE_PARAM_EVP_TYPE= 0x01, /* int */ + STORE_PARAM_BITS= 0x02, /* size_t */ + STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */ + STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */ + STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */ + STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */ + STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known + parameter types */ + } STORE_PARAM_TYPES; +/* Parameter value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1]; + +/* Store functions take attribute lists. Those attributes come with codes. + The comments following the codes below indicate what type the value should + be a pointer to. */ +typedef enum STORE_attribs + { + STORE_ATTR_END= 0x00, + STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */ + STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */ + STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */ + STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */ + STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */ + STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */ + STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */ + STORE_ATTR_EMAIL= 0x0a, /* C string */ + STORE_ATTR_FILENAME= 0x0b, /* C string */ + STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known + attribute types */ + STORE_ATTR_OR= 0xff /* This is a special + separator, which + expresses the OR + operation. */ + } STORE_ATTR_TYPES; +/* Attribute value sizes. -1 means unknown, anything else is the required size. */ +extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1]; + +typedef enum STORE_certificate_status + { + STORE_X509_VALID= 0x00, + STORE_X509_EXPIRED= 0x01, + STORE_X509_SUSPENDED= 0x02, + STORE_X509_REVOKED= 0x03 + } STORE_CERTIFICATE_STATUS; + +/* Engine store functions will return a structure that contains all the necessary + * information, including revokation status for certificates. This is really not + * needed for application authors, as the ENGINE framework functions will extract + * the OpenSSL-specific information when at all possible. However, for engine + * authors, it's crucial to know this structure. */ +typedef struct STORE_OBJECT_st + { + STORE_OBJECT_TYPES type; + union + { + struct + { + STORE_CERTIFICATE_STATUS status; + X509 *certificate; + } x509; + X509_CRL *crl; + EVP_PKEY *key; + BIGNUM *number; + BUF_MEM *arbitrary; + } data; + } STORE_OBJECT; +DECLARE_STACK_OF(STORE_OBJECT) +STORE_OBJECT *STORE_OBJECT_new(void); +void STORE_OBJECT_free(STORE_OBJECT *data); + + + +/* The following functions handle the storage. They return 0, a negative number + or NULL on error, anything else on success. */ +X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509 *STORE_list_certificate_next(STORE *e, void *handle); +int STORE_list_certificate_end(STORE *e, void *handle); +int STORE_list_certificate_endp(STORE *e, void *handle); +EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_private_key(STORE *e, EVP_PKEY *data, + OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle); +int STORE_list_private_key_end(STORE *e, void *handle); +int STORE_list_private_key_endp(STORE *e, void *handle); +EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle); +int STORE_list_public_key_end(STORE *e, void *handle); +int STORE_list_public_key_endp(STORE *e, void *handle); +X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +X509_CRL *STORE_list_crl_next(STORE *e, void *handle); +int STORE_list_crl_end(STORE *e, void *handle); +int STORE_list_crl_endp(STORE *e, void *handle); +int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[], + OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[], + OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); +int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[], + OPENSSL_ITEM parameters[]); + + +/* Create and manipulate methods */ +STORE_METHOD *STORE_create_method(char *name); +void STORE_destroy_method(STORE_METHOD *store_method); + +/* These callback types are use for store handlers */ +typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *); +typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *); +typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle); +typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); +typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void)); + +int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f); +int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f); +int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f); +int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f); +int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f); +int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f); +int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f); +int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f); +int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f); +int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f); +int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f); +int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR); +int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f); + +STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm); +STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm); +STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm); +STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm); +STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm); +STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm); +STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm); +STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm); +STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm); +STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm); +STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm); +STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm); + +/* Method helper structures and functions. */ + +/* This structure is the result of parsing through the information in a list + of OPENSSL_ITEMs. It stores all the necessary information in a structured + way.*/ +typedef struct STORE_attr_info_st STORE_ATTR_INFO; + +/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO. + Note that we do this in the list form, since the list of OPENSSL_ITEMs can + come in blocks separated with STORE_ATTR_OR. Note that the value returned + by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */ +void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes); +STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle); +int STORE_parse_attrs_end(void *handle); +int STORE_parse_attrs_endp(void *handle); + +/* Creator and destructor */ +STORE_ATTR_INFO *STORE_ATTR_INFO_new(void); +int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs); + +/* Manipulators */ +char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs, + STORE_ATTR_TYPES code); +X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code); +int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); +int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + char *cstr, size_t cstr_size); +int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + unsigned char *sha1str, size_t sha1str_size); +int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + X509_NAME *dn); +int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code, + BIGNUM *number); + +/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values + in each contained attribute. */ +int STORE_ATTR_INFO_compare(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a is within the range of attributes + set in b. */ +int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Check if the set of attributes in a are also set in b. */ +int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); +/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */ +int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_STORE_strings(void); + +/* Error codes for the STORE functions. */ + +/* Function codes. */ +#define STORE_F_MEM_DELETE 134 +#define STORE_F_MEM_GENERATE 135 +#define STORE_F_MEM_LIST_END 168 +#define STORE_F_MEM_LIST_NEXT 136 +#define STORE_F_MEM_LIST_START 137 +#define STORE_F_MEM_MODIFY 169 +#define STORE_F_MEM_STORE 138 +#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139 +#define STORE_F_STORE_ATTR_INFO_GET0_DN 140 +#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141 +#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142 +#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143 +#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144 +#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145 +#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146 +#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147 +#define STORE_F_STORE_ATTR_INFO_SET_DN 148 +#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149 +#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150 +#define STORE_F_STORE_CERTIFICATE 170 +#define STORE_F_STORE_CTRL 161 +#define STORE_F_STORE_DELETE_ARBITRARY 158 +#define STORE_F_STORE_DELETE_CERTIFICATE 102 +#define STORE_F_STORE_DELETE_CRL 103 +#define STORE_F_STORE_DELETE_NUMBER 104 +#define STORE_F_STORE_DELETE_PRIVATE_KEY 105 +#define STORE_F_STORE_DELETE_PUBLIC_KEY 106 +#define STORE_F_STORE_GENERATE_CRL 107 +#define STORE_F_STORE_GENERATE_KEY 108 +#define STORE_F_STORE_GET_ARBITRARY 159 +#define STORE_F_STORE_GET_CERTIFICATE 109 +#define STORE_F_STORE_GET_CRL 110 +#define STORE_F_STORE_GET_NUMBER 111 +#define STORE_F_STORE_GET_PRIVATE_KEY 112 +#define STORE_F_STORE_GET_PUBLIC_KEY 113 +#define STORE_F_STORE_LIST_CERTIFICATE_END 114 +#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153 +#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115 +#define STORE_F_STORE_LIST_CERTIFICATE_START 116 +#define STORE_F_STORE_LIST_CRL_END 117 +#define STORE_F_STORE_LIST_CRL_ENDP 154 +#define STORE_F_STORE_LIST_CRL_NEXT 118 +#define STORE_F_STORE_LIST_CRL_START 119 +#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120 +#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155 +#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121 +#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122 +#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123 +#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156 +#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124 +#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125 +#define STORE_F_STORE_MODIFY_ARBITRARY 162 +#define STORE_F_STORE_MODIFY_CERTIFICATE 163 +#define STORE_F_STORE_MODIFY_CRL 164 +#define STORE_F_STORE_MODIFY_NUMBER 165 +#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166 +#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167 +#define STORE_F_STORE_NEW_ENGINE 133 +#define STORE_F_STORE_NEW_METHOD 132 +#define STORE_F_STORE_PARSE_ATTRS_END 151 +#define STORE_F_STORE_PARSE_ATTRS_ENDP 172 +#define STORE_F_STORE_PARSE_ATTRS_NEXT 152 +#define STORE_F_STORE_PARSE_ATTRS_START 171 +#define STORE_F_STORE_REVOKE_CERTIFICATE 129 +#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130 +#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131 +#define STORE_F_STORE_STORE_ARBITRARY 157 +#define STORE_F_STORE_STORE_CERTIFICATE 100 +#define STORE_F_STORE_STORE_CRL 101 +#define STORE_F_STORE_STORE_NUMBER 126 +#define STORE_F_STORE_STORE_PRIVATE_KEY 127 +#define STORE_F_STORE_STORE_PUBLIC_KEY 128 + +/* Reason codes. */ +#define STORE_R_ALREADY_HAS_A_VALUE 127 +#define STORE_R_FAILED_DELETING_ARBITRARY 132 +#define STORE_R_FAILED_DELETING_CERTIFICATE 100 +#define STORE_R_FAILED_DELETING_KEY 101 +#define STORE_R_FAILED_DELETING_NUMBER 102 +#define STORE_R_FAILED_GENERATING_CRL 103 +#define STORE_R_FAILED_GENERATING_KEY 104 +#define STORE_R_FAILED_GETTING_ARBITRARY 133 +#define STORE_R_FAILED_GETTING_CERTIFICATE 105 +#define STORE_R_FAILED_GETTING_KEY 106 +#define STORE_R_FAILED_GETTING_NUMBER 107 +#define STORE_R_FAILED_LISTING_CERTIFICATES 108 +#define STORE_R_FAILED_LISTING_KEYS 109 +#define STORE_R_FAILED_MODIFYING_ARBITRARY 138 +#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139 +#define STORE_R_FAILED_MODIFYING_CRL 140 +#define STORE_R_FAILED_MODIFYING_NUMBER 141 +#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142 +#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143 +#define STORE_R_FAILED_REVOKING_CERTIFICATE 110 +#define STORE_R_FAILED_REVOKING_KEY 111 +#define STORE_R_FAILED_STORING_ARBITRARY 134 +#define STORE_R_FAILED_STORING_CERTIFICATE 112 +#define STORE_R_FAILED_STORING_KEY 113 +#define STORE_R_FAILED_STORING_NUMBER 114 +#define STORE_R_NOT_IMPLEMENTED 128 +#define STORE_R_NO_CONTROL_FUNCTION 144 +#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135 +#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115 +#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116 +#define STORE_R_NO_GENERATE_CRL_FUNCTION 117 +#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118 +#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136 +#define STORE_R_NO_GET_OBJECT_FUNCTION 119 +#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120 +#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131 +#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121 +#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122 +#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123 +#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145 +#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124 +#define STORE_R_NO_STORE 129 +#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137 +#define STORE_R_NO_STORE_OBJECT_FUNCTION 125 +#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126 +#define STORE_R_NO_VALUE 130 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/symhacks.h b/libraries/external/openssl/pc/include/openssl/symhacks.h new file mode 100755 index 0000000..16df42d --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/symhacks.h @@ -0,0 +1,383 @@ +/* ==================================================================== + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_SYMHACKS_H +#define HEADER_SYMHACKS_H + +#include + +/* Hacks to solve the problem with linkers incapable of handling very long + symbol names. In the case of VMS, the limit is 31 characters on VMS for + VAX. */ +#ifdef OPENSSL_SYS_VMS + +/* Hack a long name in crypto/ex_data.c */ +#undef CRYPTO_get_ex_data_implementation +#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl +#undef CRYPTO_set_ex_data_implementation +#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl + +/* Hack a long name in crypto/asn1/a_mbstr.c */ +#undef ASN1_STRING_set_default_mask_asc +#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF +#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO +#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */ +#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO +#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF +#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO +#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF +#endif + +#if 0 /* No longer needed, since safestack macro magic does the job */ +/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */ +#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION +#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC +#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION +#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC +#endif + +/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */ +#undef PEM_read_NETSCAPE_CERT_SEQUENCE +#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ +#undef PEM_write_NETSCAPE_CERT_SEQUENCE +#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ +#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ +#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ +#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE +#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ + +/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */ +#undef PEM_read_PKCS8_PRIV_KEY_INFO +#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO +#undef PEM_write_PKCS8_PRIV_KEY_INFO +#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO +#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO +#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO +#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO +#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO +#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO + +/* Hack other PEM names */ +#undef PEM_write_bio_PKCS8PrivateKey_nid +#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid + +/* Hack some long X509 names */ +#undef X509_REVOKED_get_ext_by_critical +#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic +#undef X509_policy_tree_get0_user_policies +#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies +#undef X509_policy_node_get0_qualifiers +#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers +#undef X509_STORE_CTX_get_explicit_policy +#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy + +/* Hack some long CRYPTO names */ +#undef CRYPTO_set_dynlock_destroy_callback +#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb +#undef CRYPTO_set_dynlock_create_callback +#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb +#undef CRYPTO_set_dynlock_lock_callback +#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb +#undef CRYPTO_get_dynlock_lock_callback +#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb +#undef CRYPTO_get_dynlock_destroy_callback +#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb +#undef CRYPTO_get_dynlock_create_callback +#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb +#undef CRYPTO_set_locked_mem_ex_functions +#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs +#undef CRYPTO_get_locked_mem_ex_functions +#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs + +/* Hack some long SSL names */ +#undef SSL_CTX_set_default_verify_paths +#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths +#undef SSL_get_ex_data_X509_STORE_CTX_idx +#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx +#undef SSL_add_file_cert_subjects_to_stack +#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk +#undef SSL_add_dir_cert_subjects_to_stack +#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk +#undef SSL_CTX_use_certificate_chain_file +#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file +#undef SSL_CTX_set_cert_verify_callback +#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb +#undef SSL_CTX_set_default_passwd_cb_userdata +#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud +#undef SSL_COMP_get_compression_methods +#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods + +/* Hack some long ENGINE names */ +#undef ENGINE_get_default_BN_mod_exp_crt +#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt +#undef ENGINE_set_default_BN_mod_exp_crt +#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt +#undef ENGINE_set_load_privkey_function +#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn +#undef ENGINE_get_load_privkey_function +#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn + +/* Hack some long OCSP names */ +#undef OCSP_REQUEST_get_ext_by_critical +#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit +#undef OCSP_BASICRESP_get_ext_by_critical +#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit +#undef OCSP_SINGLERESP_get_ext_by_critical +#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit + +/* Hack some long DES names */ +#undef _ossl_old_des_ede3_cfb64_encrypt +#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt +#undef _ossl_old_des_ede3_ofb64_encrypt +#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt + +/* Hack some long EVP names */ +#undef OPENSSL_add_all_algorithms_noconf +#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf +#undef OPENSSL_add_all_algorithms_conf +#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf + +/* Hack some long EC names */ +#undef EC_GROUP_set_point_conversion_form +#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form +#undef EC_GROUP_get_point_conversion_form +#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form +#undef EC_GROUP_clear_free_all_extra_data +#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data +#undef EC_POINT_set_Jprojective_coordinates_GFp +#define EC_POINT_set_Jprojective_coordinates_GFp \ + EC_POINT_set_Jproj_coords_GFp +#undef EC_POINT_get_Jprojective_coordinates_GFp +#define EC_POINT_get_Jprojective_coordinates_GFp \ + EC_POINT_get_Jproj_coords_GFp +#undef EC_POINT_set_affine_coordinates_GFp +#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp +#undef EC_POINT_get_affine_coordinates_GFp +#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp +#undef EC_POINT_set_compressed_coordinates_GFp +#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp +#undef EC_POINT_set_affine_coordinates_GF2m +#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m +#undef EC_POINT_get_affine_coordinates_GF2m +#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m +#undef EC_POINT_set_compressed_coordinates_GF2m +#define EC_POINT_set_compressed_coordinates_GF2m \ + EC_POINT_set_compr_coords_GF2m +#undef ec_GF2m_simple_group_clear_finish +#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish +#undef ec_GF2m_simple_group_check_discriminant +#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim +#undef ec_GF2m_simple_point_clear_finish +#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish +#undef ec_GF2m_simple_point_set_to_infinity +#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf +#undef ec_GF2m_simple_points_make_affine +#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine +#undef ec_GF2m_simple_point_set_affine_coordinates +#define ec_GF2m_simple_point_set_affine_coordinates \ + ec_GF2m_smp_pt_set_af_coords +#undef ec_GF2m_simple_point_get_affine_coordinates +#define ec_GF2m_simple_point_get_affine_coordinates \ + ec_GF2m_smp_pt_get_af_coords +#undef ec_GF2m_simple_set_compressed_coordinates +#define ec_GF2m_simple_set_compressed_coordinates \ + ec_GF2m_smp_set_compr_coords +#undef ec_GFp_simple_group_set_curve_GFp +#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_group_clear_finish +#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish +#undef ec_GFp_simple_group_set_generator +#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator +#undef ec_GFp_simple_group_get0_generator +#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator +#undef ec_GFp_simple_group_get_cofactor +#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor +#undef ec_GFp_simple_point_clear_finish +#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish +#undef ec_GFp_simple_point_set_to_infinity +#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf +#undef ec_GFp_simple_points_make_affine +#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine +#undef ec_GFp_simple_group_get_curve_GFp +#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp +#undef ec_GFp_simple_set_Jprojective_coordinates_GFp +#define ec_GFp_simple_set_Jprojective_coordinates_GFp \ + ec_GFp_smp_set_Jproj_coords_GFp +#undef ec_GFp_simple_get_Jprojective_coordinates_GFp +#define ec_GFp_simple_get_Jprojective_coordinates_GFp \ + ec_GFp_smp_get_Jproj_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates_GFp +#define ec_GFp_simple_point_set_affine_coordinates_GFp \ + ec_GFp_smp_pt_set_af_coords_GFp +#undef ec_GFp_simple_point_get_affine_coordinates_GFp +#define ec_GFp_simple_point_get_affine_coordinates_GFp \ + ec_GFp_smp_pt_get_af_coords_GFp +#undef ec_GFp_simple_set_compressed_coordinates_GFp +#define ec_GFp_simple_set_compressed_coordinates_GFp \ + ec_GFp_smp_set_compr_coords_GFp +#undef ec_GFp_simple_point_set_affine_coordinates +#define ec_GFp_simple_point_set_affine_coordinates \ + ec_GFp_smp_pt_set_af_coords +#undef ec_GFp_simple_point_get_affine_coordinates +#define ec_GFp_simple_point_get_affine_coordinates \ + ec_GFp_smp_pt_get_af_coords +#undef ec_GFp_simple_set_compressed_coordinates +#define ec_GFp_simple_set_compressed_coordinates \ + ec_GFp_smp_set_compr_coords +#undef ec_GFp_simple_group_check_discriminant +#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim + +/* Hack som long STORE names */ +#undef STORE_method_set_initialise_function +#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn +#undef STORE_method_set_cleanup_function +#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn +#undef STORE_method_set_generate_function +#define STORE_method_set_generate_function STORE_meth_set_generate_fn +#undef STORE_method_set_modify_function +#define STORE_method_set_modify_function STORE_meth_set_modify_fn +#undef STORE_method_set_revoke_function +#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn +#undef STORE_method_set_delete_function +#define STORE_method_set_delete_function STORE_meth_set_delete_fn +#undef STORE_method_set_list_start_function +#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn +#undef STORE_method_set_list_next_function +#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn +#undef STORE_method_set_list_end_function +#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn +#undef STORE_method_set_update_store_function +#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn +#undef STORE_method_set_lock_store_function +#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn +#undef STORE_method_set_unlock_store_function +#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn +#undef STORE_method_get_initialise_function +#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn +#undef STORE_method_get_cleanup_function +#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn +#undef STORE_method_get_generate_function +#define STORE_method_get_generate_function STORE_meth_get_generate_fn +#undef STORE_method_get_modify_function +#define STORE_method_get_modify_function STORE_meth_get_modify_fn +#undef STORE_method_get_revoke_function +#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn +#undef STORE_method_get_delete_function +#define STORE_method_get_delete_function STORE_meth_get_delete_fn +#undef STORE_method_get_list_start_function +#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn +#undef STORE_method_get_list_next_function +#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn +#undef STORE_method_get_list_end_function +#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn +#undef STORE_method_get_update_store_function +#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn +#undef STORE_method_get_lock_store_function +#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn +#undef STORE_method_get_unlock_store_function +#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn + +#endif /* defined OPENSSL_SYS_VMS */ + + +/* Case insensiteve linking causes problems.... */ +#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) +#undef ERR_load_CRYPTO_strings +#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings +#undef OCSP_crlID_new +#define OCSP_crlID_new OCSP_crlID2_new + +#undef d2i_ECPARAMETERS +#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS +#undef i2d_ECPARAMETERS +#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS +#undef d2i_ECPKPARAMETERS +#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS +#undef i2d_ECPKPARAMETERS +#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS + +/* These functions do not seem to exist! However, I'm paranoid... + Original command in x509v3.h: + These functions are being redefined in another directory, + and clash when the linker is case-insensitive, so let's + hide them a little, by giving them an extra 'o' at the + beginning of the name... */ +#undef X509v3_cleanup_extensions +#define X509v3_cleanup_extensions oX509v3_cleanup_extensions +#undef X509v3_add_extension +#define X509v3_add_extension oX509v3_add_extension +#undef X509v3_add_netscape_extensions +#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions +#undef X509v3_add_standard_extensions +#define X509v3_add_standard_extensions oX509v3_add_standard_extensions + + +#endif + + +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/libraries/external/openssl/pc/include/openssl/tls1.h b/libraries/external/openssl/pc/include/openssl/tls1.h new file mode 100755 index 0000000..1fabd50 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/tls1.h @@ -0,0 +1,305 @@ +/* ssl/tls1.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * ECC cipher suite support in OpenSSL originally written by + * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. + * + */ + +#ifndef HEADER_TLS1_H +#define HEADER_TLS1_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 + +#define TLS1_VERSION 0x0301 +#define TLS1_VERSION_MAJOR 0x03 +#define TLS1_VERSION_MINOR 0x01 + +#define TLS1_AD_DECRYPTION_FAILED 21 +#define TLS1_AD_RECORD_OVERFLOW 22 +#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ +#define TLS1_AD_ACCESS_DENIED 49 /* fatal */ +#define TLS1_AD_DECODE_ERROR 50 /* fatal */ +#define TLS1_AD_DECRYPT_ERROR 51 +#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ +#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ +#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ +#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ +#define TLS1_AD_USER_CANCELLED 90 +#define TLS1_AD_NO_RENEGOTIATION 100 + +/* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt + * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see + * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably + * shouldn't. */ +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 +#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 +#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 +#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 +#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 + +/* AES ciphersuites from RFC3268 */ + +#define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F +#define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 +#define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 +#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 +#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 +#define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 + +#define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 +#define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 +#define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 +#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 +#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 +#define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A + +/* Camellia ciphersuites from RFC4132 */ +#define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 +#define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 +#define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 +#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 +#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 +#define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 + +#define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 +#define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 +#define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 +#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 +#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 +#define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 + +/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */ +#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 +#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 +#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 +#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 + +#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 +#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 +#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 +#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A + +#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B +#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C +#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D +#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E +#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F + +#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 +#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 +#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 +#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 +#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 + +#define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 +#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 +#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 +#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 +#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 + +/* XXX + * Inconsistency alert: + * The OpenSSL names of ciphers with ephemeral DH here include the string + * "DHE", while elsewhere it has always been "EDH". + * (The alias for the list of all such ciphers also is "EDH".) + * The specifications speak of "EDH"; maybe we should allow both forms + * for everything. */ +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" +#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" +#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" +#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" +#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" + +/* AES ciphersuites from RFC3268 */ +#define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" +#define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" + +#define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" +#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" +#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" +#define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" + +/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" + +#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" +#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" + +#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" +#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" + +#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" +#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" +#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" +#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" + +/* Camellia ciphersuites form RFC4132 */ +#define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" +#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" +#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" +#define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" + +#define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" +#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" +#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" +#define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" + + +#define TLS_CT_RSA_SIGN 1 +#define TLS_CT_DSS_SIGN 2 +#define TLS_CT_RSA_FIXED_DH 3 +#define TLS_CT_DSS_FIXED_DH 4 +#define TLS_CT_ECDSA_SIGN 64 +#define TLS_CT_RSA_FIXED_ECDH 65 +#define TLS_CT_ECDSA_FIXED_ECDH 66 +#define TLS_CT_NUMBER 7 + +#define TLS1_FINISH_MAC_LENGTH 12 + +#define TLS_MD_MAX_CONST_SIZE 20 +#define TLS_MD_CLIENT_FINISH_CONST "client finished" +#define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_FINISH_CONST "server finished" +#define TLS_MD_SERVER_FINISH_CONST_SIZE 15 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_KEY_EXPANSION_CONST "key expansion" +#define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 +#define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" +#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" +#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 +#define TLS_MD_IV_BLOCK_CONST "IV block" +#define TLS_MD_IV_BLOCK_CONST_SIZE 8 +#define TLS_MD_MASTER_SECRET_CONST "master secret" +#define TLS_MD_MASTER_SECRET_CONST_SIZE 13 + +#ifdef CHARSET_EBCDIC +#undef TLS_MD_CLIENT_FINISH_CONST +#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/ +#undef TLS_MD_SERVER_FINISH_CONST +#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_KEY_EXPANSION_CONST +#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/ +#undef TLS_MD_CLIENT_WRITE_KEY_CONST +#define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/ +#undef TLS_MD_SERVER_WRITE_KEY_CONST +#define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ +#undef TLS_MD_IV_BLOCK_CONST +#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/ +#undef TLS_MD_MASTER_SECRET_CONST +#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ +#endif + +#ifdef __cplusplus +} +#endif +#endif + + + diff --git a/libraries/external/openssl/pc/include/openssl/tmdiff.h b/libraries/external/openssl/pc/include/openssl/tmdiff.h new file mode 100755 index 0000000..6ed309e --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/tmdiff.h @@ -0,0 +1,93 @@ +/* crypto/tmdiff.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +/* Header for dynamic hash table routines + * Author - Eric Young + */ +/* ... erm yeah, "dynamic hash tables" you say? + * + * And what would dynamic hash tables have to do with any of this code *now*? + * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused + * file that I doubt compiles any more. speed.c is the only thing that could + * use this (and it has nothing to do with hash tables), yet it instead has its + * own duplication of all this stuff and looks, if anything, more complete. See + * the corresponding note in apps/speed.c. + * The Bemused - Geoff + */ + +#ifndef HEADER_TMDIFF_H +#define HEADER_TMDIFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ms_tm MS_TM; + +MS_TM *ms_time_new(void ); +void ms_time_free(MS_TM *a); +void ms_time_get(MS_TM *a); +double ms_time_diff(MS_TM *start, MS_TM *end); +int ms_time_cmp(const MS_TM *ap, const MS_TM *bp); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/txt_db.h b/libraries/external/openssl/pc/include/openssl/txt_db.h new file mode 100755 index 0000000..a767e45 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/txt_db.h @@ -0,0 +1,109 @@ +/* crypto/txt_db/txt_db.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_TXT_DB_H +#define HEADER_TXT_DB_H + +#include +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include + +#define DB_ERROR_OK 0 +#define DB_ERROR_MALLOC 1 +#define DB_ERROR_INDEX_CLASH 2 +#define DB_ERROR_INDEX_OUT_OF_RANGE 3 +#define DB_ERROR_NO_INDEX 4 +#define DB_ERROR_INSERT_INDEX_CLASH 5 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct txt_db_st + { + int num_fields; + STACK /* char ** */ *data; + LHASH **index; + int (**qual)(char **); + long error; + long arg1; + long arg2; + char **arg_row; + } TXT_DB; + +#ifndef OPENSSL_NO_BIO +TXT_DB *TXT_DB_read(BIO *in, int num); +long TXT_DB_write(BIO *out, TXT_DB *db); +#else +TXT_DB *TXT_DB_read(char *in, int num); +long TXT_DB_write(char *out, TXT_DB *db); +#endif +int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(char **), + LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp); +void TXT_DB_free(TXT_DB *db); +char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); +int TXT_DB_insert(TXT_DB *db,char **value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ui.h b/libraries/external/openssl/pc/include/openssl/ui.h new file mode 100755 index 0000000..5570e0d --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ui.h @@ -0,0 +1,381 @@ +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_H +#define HEADER_UI_H + +#ifndef OPENSSL_NO_DEPRECATED +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declared already in ossl_typ.h */ +/* typedef struct ui_st UI; */ +/* typedef struct ui_method_st UI_METHOD; */ + + +/* All the following functions return -1 or NULL on error and in some cases + (UI_process()) -2 if interrupted or in some other way cancelled. + When everything is fine, they return 0, a positive value or a non-NULL + pointer, all depending on their purpose. */ + +/* Creators and destructor. */ +UI *UI_new(void); +UI *UI_new_method(const UI_METHOD *method); +void UI_free(UI *ui); + +/* The following functions are used to add strings to be printed and prompt + strings to prompt for data. The names are UI_{add,dup}__string + and UI_{add,dup}_input_boolean. + + UI_{add,dup}__string have the following meanings: + add add a text or prompt string. The pointers given to these + functions are used verbatim, no copying is done. + dup make a copy of the text or prompt string, then add the copy + to the collection of strings in the user interface. + + The function is a name for the functionality that the given + string shall be used for. It can be one of: + input use the string as data prompt. + verify use the string as verification prompt. This + is used to verify a previous input. + info use the string for informational output. + error use the string for error output. + Honestly, there's currently no difference between info and error for the + moment. + + UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", + and are typically used when one wants to prompt for a yes/no response. + + + All of the functions in this group take a UI and a prompt string. + The string input and verify addition functions also take a flag argument, + a buffer for the result to end up with, a minimum input size and a maximum + input size (the result buffer MUST be large enough to be able to contain + the maximum number of characters). Additionally, the verify addition + functions takes another buffer to compare the result against. + The boolean input functions take an action description string (which should + be safe to ignore if the expected user action is obvious, for example with + a dialog box with an OK button and a Cancel button), a string of acceptable + characters to mean OK and to mean Cancel. The two last strings are checked + to make sure they don't have common characters. Additionally, the same + flag argument as for the string input is taken, as well as a result buffer. + The result buffer is required to be at least one byte long. Depending on + the answer, the first character from the OK or the Cancel character strings + will be stored in the first byte of the result buffer. No NUL will be + added, so the result is *not* a string. + + On success, the all return an index of the added information. That index + is usefull when retrieving results with UI_get0_result(). */ +int UI_add_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_dup_input_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize); +int UI_add_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_dup_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, const char *test_buf); +int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_add_info_string(UI *ui, const char *text); +int UI_dup_info_string(UI *ui, const char *text); +int UI_add_error_string(UI *ui, const char *text); +int UI_dup_error_string(UI *ui, const char *text); + +/* These are the possible flags. They can be or'ed together. */ +/* Use to have echoing of input */ +#define UI_INPUT_FLAG_ECHO 0x01 +/* Use a default password. Where that password is found is completely + up to the application, it might for example be in the user data set + with UI_add_user_data(). It is not recommended to have more than + one input in each UI being marked with this flag, or the application + might get confused. */ +#define UI_INPUT_FLAG_DEFAULT_PWD 0x02 + +/* The user of these routines may want to define flags of their own. The core + UI won't look at those, but will pass them on to the method routines. They + must use higher bits so they don't get confused with the UI bits above. + UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good + example of use is this: + + #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) + +*/ +#define UI_INPUT_FLAG_USER_BASE 16 + + +/* The following function helps construct a prompt. object_desc is a + textual short description of the object, for example "pass phrase", + and object_name is the name of the object (might be a card name or + a file name. + The returned string shall always be allocated on the heap with + OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). + + If the ui_method doesn't contain a pointer to a user-defined prompt + constructor, a default string is built, looking like this: + + "Enter {object_desc} for {object_name}:" + + So, if object_desc has the value "pass phrase" and object_name has + the value "foo.key", the resulting string is: + + "Enter pass phrase for foo.key:" +*/ +char *UI_construct_prompt(UI *ui_method, + const char *object_desc, const char *object_name); + + +/* The following function is used to store a pointer to user-specific data. + Any previous such pointer will be returned and replaced. + + For callback purposes, this function makes a lot more sense than using + ex_data, since the latter requires that different parts of OpenSSL or + applications share the same ex_data index. + + Note that the UI_OpenSSL() method completely ignores the user data. + Other methods may not, however. */ +void *UI_add_user_data(UI *ui, void *user_data); +/* We need a user data retrieving function as well. */ +void *UI_get0_user_data(UI *ui); + +/* Return the result associated with a prompt given with the index i. */ +const char *UI_get0_result(UI *ui, int i); + +/* When all strings have been added, process the whole thing. */ +int UI_process(UI *ui); + +/* Give a user interface parametrised control commands. This can be used to + send down an integer, a data pointer or a function pointer, as well as + be used to get information from a UI. */ +int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); + +/* The commands */ +/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the + OpenSSL error stack before printing any info or added error messages and + before any prompting. */ +#define UI_CTRL_PRINT_ERRORS 1 +/* Check if a UI_process() is possible to do again with the same instance of + a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 + if not. */ +#define UI_CTRL_IS_REDOABLE 2 + + +/* Some methods may use extra data */ +#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) +#define UI_get_app_data(s) UI_get_ex_data(s,0) +int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int UI_set_ex_data(UI *r,int idx,void *arg); +void *UI_get_ex_data(UI *r, int idx); + +/* Use specific methods instead of the built-in one */ +void UI_set_default_method(const UI_METHOD *meth); +const UI_METHOD *UI_get_default_method(void); +const UI_METHOD *UI_get_method(UI *ui); +const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); + +/* The method with all the built-in thingies */ +UI_METHOD *UI_OpenSSL(void); + + +/* ---------- For method writers ---------- */ +/* A method contains a number of functions that implement the low level + of the User Interface. The functions are: + + an opener This function starts a session, maybe by opening + a channel to a tty, or by opening a window. + a writer This function is called to write a given string, + maybe to the tty, maybe as a field label in a + window. + a flusher This function is called to flush everything that + has been output so far. It can be used to actually + display a dialog box after it has been built. + a reader This function is called to read a given prompt, + maybe from the tty, maybe from a field in a + window. Note that it's called wth all string + structures, not only the prompt ones, so it must + check such things itself. + a closer This function closes the session, maybe by closing + the channel to the tty, or closing the window. + + All these functions are expected to return: + + 0 on error. + 1 on success. + -1 on out-of-band events, for example if some prompting has + been canceled (by pressing Ctrl-C, for example). This is + only checked when returned by the flusher or the reader. + + The way this is used, the opener is first called, then the writer for all + strings, then the flusher, then the reader for all strings and finally the + closer. Note that if you want to prompt from a terminal or other command + line interface, the best is to have the reader also write the prompts + instead of having the writer do it. If you want to prompt from a dialog + box, the writer can be used to build up the contents of the box, and the + flusher to actually display the box and run the event loop until all data + has been given, after which the reader only grabs the given data and puts + them back into the UI strings. + + All method functions take a UI as argument. Additionally, the writer and + the reader take a UI_STRING. +*/ + +/* The UI_STRING type is the data structure that contains all the needed info + about a string or a prompt, including test data for a verification prompt. +*/ +DECLARE_STACK_OF(UI_STRING) +typedef struct ui_string_st UI_STRING; + +/* The different types of strings that are currently supported. + This is only needed by method authors. */ +enum UI_string_types + { + UIT_NONE=0, + UIT_PROMPT, /* Prompt for a string */ + UIT_VERIFY, /* Prompt for a string and verify */ + UIT_BOOLEAN, /* Prompt for a yes/no response */ + UIT_INFO, /* Send info to the user */ + UIT_ERROR /* Send an error message to the user */ + }; + +/* Create and manipulate methods */ +UI_METHOD *UI_create_method(char *name); +void UI_destroy_method(UI_METHOD *ui_method); +int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); +int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); +int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); +int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); +int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); +int (*UI_method_get_opener(UI_METHOD *method))(UI*); +int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_flusher(UI_METHOD *method))(UI*); +int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); +int (*UI_method_get_closer(UI_METHOD *method))(UI*); + +/* The following functions are helpers for method writers to access relevant + data from a UI_STRING. */ + +/* Return type of the UI_STRING */ +enum UI_string_types UI_get_string_type(UI_STRING *uis); +/* Return input flags of the UI_STRING */ +int UI_get_input_flags(UI_STRING *uis); +/* Return the actual string to output (the prompt, info or error) */ +const char *UI_get0_output_string(UI_STRING *uis); +/* Return the optional action string to output (the boolean promtp instruction) */ +const char *UI_get0_action_string(UI_STRING *uis); +/* Return the result of a prompt */ +const char *UI_get0_result_string(UI_STRING *uis); +/* Return the string to test the result against. Only useful with verifies. */ +const char *UI_get0_test_string(UI_STRING *uis); +/* Return the required minimum size of the result */ +int UI_get_result_minsize(UI_STRING *uis); +/* Return the required maximum size of the result */ +int UI_get_result_maxsize(UI_STRING *uis); +/* Set the result of a UI_STRING. */ +int UI_set_result(UI *ui, UI_STRING *uis, const char *result); + + +/* A couple of popular utility functions */ +int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); +int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_UI_strings(void); + +/* Error codes for the UI functions. */ + +/* Function codes. */ +#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 +#define UI_F_GENERAL_ALLOCATE_PROMPT 109 +#define UI_F_GENERAL_ALLOCATE_STRING 100 +#define UI_F_UI_CTRL 111 +#define UI_F_UI_DUP_ERROR_STRING 101 +#define UI_F_UI_DUP_INFO_STRING 102 +#define UI_F_UI_DUP_INPUT_BOOLEAN 110 +#define UI_F_UI_DUP_INPUT_STRING 103 +#define UI_F_UI_DUP_VERIFY_STRING 106 +#define UI_F_UI_GET0_RESULT 107 +#define UI_F_UI_NEW_METHOD 104 +#define UI_F_UI_SET_RESULT 105 + +/* Reason codes. */ +#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 +#define UI_R_INDEX_TOO_LARGE 102 +#define UI_R_INDEX_TOO_SMALL 103 +#define UI_R_NO_RESULT_BUFFER 105 +#define UI_R_RESULT_TOO_LARGE 100 +#define UI_R_RESULT_TOO_SMALL 101 +#define UI_R_UNKNOWN_CONTROL_COMMAND 106 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/ui_compat.h b/libraries/external/openssl/pc/include/openssl/ui_compat.h new file mode 100755 index 0000000..0209438 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/ui_compat.h @@ -0,0 +1,83 @@ +/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#ifndef HEADER_UI_COMPAT_H +#define HEADER_UI_COMPAT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The following functions were previously part of the DES section, + and are provided here for backward compatibility reasons. */ + +#define des_read_pw_string(b,l,p,v) \ + _ossl_old_des_read_pw_string((b),(l),(p),(v)) +#define des_read_pw(b,bf,s,p,v) \ + _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) + +int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); +int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/vssver.scc b/libraries/external/openssl/pc/include/openssl/vssver.scc new file mode 100755 index 0000000..b2ee9c2 Binary files /dev/null and b/libraries/external/openssl/pc/include/openssl/vssver.scc differ diff --git a/libraries/external/openssl/pc/include/openssl/x509.h b/libraries/external/openssl/pc/include/openssl/x509.h new file mode 100755 index 0000000..5e36aca --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/x509.h @@ -0,0 +1,1344 @@ +/* crypto/x509/x509.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#ifndef HEADER_X509_H +#define HEADER_X509_H + +#include +#include +#ifndef OPENSSL_NO_BUFFER +#include +#endif +#ifndef OPENSSL_NO_EVP +#include +#endif +#ifndef OPENSSL_NO_BIO +#include +#endif +#include +#include +#include + +#ifndef OPENSSL_NO_EC +#include +#endif + +#ifndef OPENSSL_NO_ECDSA +#include +#endif + +#ifndef OPENSSL_NO_ECDH +#include +#endif + +#ifndef OPENSSL_NO_DEPRECATED +#ifndef OPENSSL_NO_RSA +#include +#endif +#ifndef OPENSSL_NO_DSA +#include +#endif +#ifndef OPENSSL_NO_DH +#include +#endif +#endif + +#ifndef OPENSSL_NO_SHA +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OPENSSL_SYS_WIN32 +/* Under Win32 these are defined in wincrypt.h */ +#undef X509_NAME +#undef X509_CERT_PAIR +#endif + +#define X509_FILETYPE_PEM 1 +#define X509_FILETYPE_ASN1 2 +#define X509_FILETYPE_DEFAULT 3 + +#define X509v3_KU_DIGITAL_SIGNATURE 0x0080 +#define X509v3_KU_NON_REPUDIATION 0x0040 +#define X509v3_KU_KEY_ENCIPHERMENT 0x0020 +#define X509v3_KU_DATA_ENCIPHERMENT 0x0010 +#define X509v3_KU_KEY_AGREEMENT 0x0008 +#define X509v3_KU_KEY_CERT_SIGN 0x0004 +#define X509v3_KU_CRL_SIGN 0x0002 +#define X509v3_KU_ENCIPHER_ONLY 0x0001 +#define X509v3_KU_DECIPHER_ONLY 0x8000 +#define X509v3_KU_UNDEF 0xffff + +typedef struct X509_objects_st + { + int nid; + int (*a2i)(void); + int (*i2a)(void); + } X509_OBJECTS; + +struct X509_algor_st + { + ASN1_OBJECT *algorithm; + ASN1_TYPE *parameter; + } /* X509_ALGOR */; + +DECLARE_STACK_OF(X509_ALGOR) +DECLARE_ASN1_SET_OF(X509_ALGOR) + +typedef struct X509_val_st + { + ASN1_TIME *notBefore; + ASN1_TIME *notAfter; + } X509_VAL; + +typedef struct X509_pubkey_st + { + X509_ALGOR *algor; + ASN1_BIT_STRING *public_key; + EVP_PKEY *pkey; + } X509_PUBKEY; + +typedef struct X509_sig_st + { + X509_ALGOR *algor; + ASN1_OCTET_STRING *digest; + } X509_SIG; + +typedef struct X509_name_entry_st + { + ASN1_OBJECT *object; + ASN1_STRING *value; + int set; + int size; /* temp variable */ + } X509_NAME_ENTRY; + +DECLARE_STACK_OF(X509_NAME_ENTRY) +DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) + +/* we always keep X509_NAMEs in 2 forms. */ +struct X509_name_st + { + STACK_OF(X509_NAME_ENTRY) *entries; + int modified; /* true if 'bytes' needs to be built */ +#ifndef OPENSSL_NO_BUFFER + BUF_MEM *bytes; +#else + char *bytes; +#endif + unsigned long hash; /* Keep the hash around for lookups */ + } /* X509_NAME */; + +DECLARE_STACK_OF(X509_NAME) + +#define X509_EX_V_NETSCAPE_HACK 0x8000 +#define X509_EX_V_INIT 0x0001 +typedef struct X509_extension_st + { + ASN1_OBJECT *object; + ASN1_BOOLEAN critical; + ASN1_OCTET_STRING *value; + } X509_EXTENSION; + +DECLARE_STACK_OF(X509_EXTENSION) +DECLARE_ASN1_SET_OF(X509_EXTENSION) + +/* a sequence of these are used */ +typedef struct x509_attributes_st + { + ASN1_OBJECT *object; + int single; /* 0 for a set, 1 for a single item (which is wrong) */ + union { + char *ptr; +/* 0 */ STACK_OF(ASN1_TYPE) *set; +/* 1 */ ASN1_TYPE *single; + } value; + } X509_ATTRIBUTE; + +DECLARE_STACK_OF(X509_ATTRIBUTE) +DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) + + +typedef struct X509_req_info_st + { + ASN1_ENCODING enc; + ASN1_INTEGER *version; + X509_NAME *subject; + X509_PUBKEY *pubkey; + /* d=2 hl=2 l= 0 cons: cont: 00 */ + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + } X509_REQ_INFO; + +typedef struct X509_req_st + { + X509_REQ_INFO *req_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } X509_REQ; + +typedef struct x509_cinf_st + { + ASN1_INTEGER *version; /* [ 0 ] default of v1 */ + ASN1_INTEGER *serialNumber; + X509_ALGOR *signature; + X509_NAME *issuer; + X509_VAL *validity; + X509_NAME *subject; + X509_PUBKEY *key; + ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ + ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ + STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ + } X509_CINF; + +/* This stuff is certificate "auxiliary info" + * it contains details which are useful in certificate + * stores and databases. When used this is tagged onto + * the end of the certificate itself + */ + +typedef struct x509_cert_aux_st + { + STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ + STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ + ASN1_UTF8STRING *alias; /* "friendly name" */ + ASN1_OCTET_STRING *keyid; /* key id of private key */ + STACK_OF(X509_ALGOR) *other; /* other unspecified info */ + } X509_CERT_AUX; + +struct x509_st + { + X509_CINF *cert_info; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int valid; + int references; + char *name; + CRYPTO_EX_DATA ex_data; + /* These contain copies of various extension values */ + long ex_pathlen; + long ex_pcpathlen; + unsigned long ex_flags; + unsigned long ex_kusage; + unsigned long ex_xkusage; + unsigned long ex_nscert; + ASN1_OCTET_STRING *skid; + struct AUTHORITY_KEYID_st *akid; + X509_POLICY_CACHE *policy_cache; +#ifndef OPENSSL_NO_RFC3779 + STACK_OF(IPAddressFamily) *rfc3779_addr; + struct ASIdentifiers_st *rfc3779_asid; +#endif +#ifndef OPENSSL_NO_SHA + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; +#endif + X509_CERT_AUX *aux; + } /* X509 */; + +DECLARE_STACK_OF(X509) +DECLARE_ASN1_SET_OF(X509) + +/* This is used for a table of trust checking functions */ + +typedef struct x509_trust_st { + int trust; + int flags; + int (*check_trust)(struct x509_trust_st *, X509 *, int); + char *name; + int arg1; + void *arg2; +} X509_TRUST; + +DECLARE_STACK_OF(X509_TRUST) + +typedef struct x509_cert_pair_st { + X509 *forward; + X509 *reverse; +} X509_CERT_PAIR; + +/* standard trust ids */ + +#define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */ + +#define X509_TRUST_COMPAT 1 +#define X509_TRUST_SSL_CLIENT 2 +#define X509_TRUST_SSL_SERVER 3 +#define X509_TRUST_EMAIL 4 +#define X509_TRUST_OBJECT_SIGN 5 +#define X509_TRUST_OCSP_SIGN 6 +#define X509_TRUST_OCSP_REQUEST 7 + +/* Keep these up to date! */ +#define X509_TRUST_MIN 1 +#define X509_TRUST_MAX 7 + + +/* trust_flags values */ +#define X509_TRUST_DYNAMIC 1 +#define X509_TRUST_DYNAMIC_NAME 2 + +/* check_trust return codes */ + +#define X509_TRUST_TRUSTED 1 +#define X509_TRUST_REJECTED 2 +#define X509_TRUST_UNTRUSTED 3 + +/* Flags for X509_print_ex() */ + +#define X509_FLAG_COMPAT 0 +#define X509_FLAG_NO_HEADER 1L +#define X509_FLAG_NO_VERSION (1L << 1) +#define X509_FLAG_NO_SERIAL (1L << 2) +#define X509_FLAG_NO_SIGNAME (1L << 3) +#define X509_FLAG_NO_ISSUER (1L << 4) +#define X509_FLAG_NO_VALIDITY (1L << 5) +#define X509_FLAG_NO_SUBJECT (1L << 6) +#define X509_FLAG_NO_PUBKEY (1L << 7) +#define X509_FLAG_NO_EXTENSIONS (1L << 8) +#define X509_FLAG_NO_SIGDUMP (1L << 9) +#define X509_FLAG_NO_AUX (1L << 10) +#define X509_FLAG_NO_ATTRIBUTES (1L << 11) + +/* Flags specific to X509_NAME_print_ex() */ + +/* The field separator information */ + +#define XN_FLAG_SEP_MASK (0xf << 16) + +#define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */ +#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ +#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ +#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ +#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ + +#define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ + +/* How the field name is shown */ + +#define XN_FLAG_FN_MASK (0x3 << 21) + +#define XN_FLAG_FN_SN 0 /* Object short name */ +#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ +#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ +#define XN_FLAG_FN_NONE (3 << 21) /* No field names */ + +#define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ + +/* This determines if we dump fields we don't recognise: + * RFC2253 requires this. + */ + +#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) + +#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */ + +/* Complete set of RFC2253 flags */ + +#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ + XN_FLAG_SEP_COMMA_PLUS | \ + XN_FLAG_DN_REV | \ + XN_FLAG_FN_SN | \ + XN_FLAG_DUMP_UNKNOWN_FIELDS) + +/* readable oneline form */ + +#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ + ASN1_STRFLGS_ESC_QUOTE | \ + XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_SN) + +/* readable multiline form */ + +#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + XN_FLAG_SEP_MULTILINE | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_LN | \ + XN_FLAG_FN_ALIGN) + +typedef struct X509_revoked_st + { + ASN1_INTEGER *serialNumber; + ASN1_TIME *revocationDate; + STACK_OF(X509_EXTENSION) /* optional */ *extensions; + int sequence; /* load sequence */ + } X509_REVOKED; + +DECLARE_STACK_OF(X509_REVOKED) +DECLARE_ASN1_SET_OF(X509_REVOKED) + +typedef struct X509_crl_info_st + { + ASN1_INTEGER *version; + X509_ALGOR *sig_alg; + X509_NAME *issuer; + ASN1_TIME *lastUpdate; + ASN1_TIME *nextUpdate; + STACK_OF(X509_REVOKED) *revoked; + STACK_OF(X509_EXTENSION) /* [0] */ *extensions; + ASN1_ENCODING enc; + } X509_CRL_INFO; + +struct X509_crl_st + { + /* actual signature */ + X509_CRL_INFO *crl; + X509_ALGOR *sig_alg; + ASN1_BIT_STRING *signature; + int references; + } /* X509_CRL */; + +DECLARE_STACK_OF(X509_CRL) +DECLARE_ASN1_SET_OF(X509_CRL) + +typedef struct private_key_st + { + int version; + /* The PKCS#8 data types */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + + /* When decrypted, the following will not be NULL */ + EVP_PKEY *dec_pkey; + + /* used to encrypt and decrypt */ + int key_length; + char *key_data; + int key_free; /* true if we should auto free key_data */ + + /* expanded version of 'enc_algor' */ + EVP_CIPHER_INFO cipher; + + int references; + } X509_PKEY; + +#ifndef OPENSSL_NO_EVP +typedef struct X509_info_st + { + X509 *x509; + X509_CRL *crl; + X509_PKEY *x_pkey; + + EVP_CIPHER_INFO enc_cipher; + int enc_len; + char *enc_data; + + int references; + } X509_INFO; + +DECLARE_STACK_OF(X509_INFO) +#endif + +/* The next 2 structures and their 8 routines were sent to me by + * Pat Richard and are used to manipulate + * Netscapes spki structures - useful if you are writing a CA web page + */ +typedef struct Netscape_spkac_st + { + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ + } NETSCAPE_SPKAC; + +typedef struct Netscape_spki_st + { + NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ + X509_ALGOR *sig_algor; + ASN1_BIT_STRING *signature; + } NETSCAPE_SPKI; + +/* Netscape certificate sequence structure */ +typedef struct Netscape_certificate_sequence + { + ASN1_OBJECT *type; + STACK_OF(X509) *certs; + } NETSCAPE_CERT_SEQUENCE; + +/* Unused (and iv length is wrong) +typedef struct CBCParameter_st + { + unsigned char iv[8]; + } CBC_PARAM; +*/ + +/* Password based encryption structure */ + +typedef struct PBEPARAM_st { +ASN1_OCTET_STRING *salt; +ASN1_INTEGER *iter; +} PBEPARAM; + +/* Password based encryption V2 structures */ + +typedef struct PBE2PARAM_st { +X509_ALGOR *keyfunc; +X509_ALGOR *encryption; +} PBE2PARAM; + +typedef struct PBKDF2PARAM_st { +ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */ +ASN1_INTEGER *iter; +ASN1_INTEGER *keylength; +X509_ALGOR *prf; +} PBKDF2PARAM; + + +/* PKCS#8 private key info structure */ + +typedef struct pkcs8_priv_key_info_st + { + int broken; /* Flag for various broken formats */ +#define PKCS8_OK 0 +#define PKCS8_NO_OCTET 1 +#define PKCS8_EMBEDDED_PARAM 2 +#define PKCS8_NS_DB 3 + ASN1_INTEGER *version; + X509_ALGOR *pkeyalg; + ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */ + STACK_OF(X509_ATTRIBUTE) *attributes; + } PKCS8_PRIV_KEY_INFO; + +#ifdef __cplusplus +} +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SSLEAY_MACROS +#define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\ + a->signature,(char *)a->cert_info,r) +#define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \ + a->sig_alg,a->signature,(char *)a->req_info,r) +#define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \ + a->sig_alg, a->signature,(char *)a->crl,r) + +#define X509_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \ + x->sig_alg, x->signature, (char *)x->cert_info,pkey,md) +#define X509_REQ_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \ + x->signature, (char *)x->req_info,pkey,md) +#define X509_CRL_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \ + x->signature, (char *)x->crl,pkey,md) +#define NETSCAPE_SPKI_sign(x,pkey,md) \ + ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \ + x->signature, (char *)x->spkac,pkey,md) + +#define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \ + (char *(*)())d2i_X509,(char *)x509) +#define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\ + (int (*)())i2d_X509_ATTRIBUTE, \ + (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa) +#define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \ + (int (*)())i2d_X509_EXTENSION, \ + (char *(*)())d2i_X509_EXTENSION,(char *)ex) +#define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)) +#define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509) +#define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \ + (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)) +#define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509) + +#define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \ + (char *(*)())d2i_X509_CRL,(char *)crl) +#define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\ + (unsigned char *)crl) +#define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \ + X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\ + (unsigned char **)(crl)) +#define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\ + (unsigned char *)crl) + +#define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \ + (char *(*)())d2i_PKCS7,(char *)p7) +#define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\ + (unsigned char *)p7) +#define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \ + PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\ + (unsigned char **)(p7)) +#define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\ + (unsigned char *)p7) + +#define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \ + (char *(*)())d2i_X509_REQ,(char *)req) +#define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\ + (unsigned char *)req) +#define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\ + X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\ + (unsigned char **)(req)) +#define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\ + (unsigned char *)req) + +#define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \ + (char *(*)())d2i_RSAPublicKey,(char *)rsa) +#define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \ + (char *(*)())d2i_RSAPrivateKey,(char *)rsa) + +#define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \ + (unsigned char *)rsa) + +#define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \ + (unsigned char *)rsa) +#define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\ + RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \ + (unsigned char **)(rsa)) +#define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \ + (unsigned char *)rsa) + +#define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \ + (unsigned char *)dsa) +#define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\ + DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \ + (unsigned char **)(dsa)) +#define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \ + (unsigned char *)dsa) + +#define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \ + (unsigned char *)ecdsa) +#define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\ + EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \ + (unsigned char **)(ecdsa)) +#define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \ + (unsigned char *)ecdsa) + +#define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\ + (char *(*)())d2i_X509_ALGOR,(char *)xn) + +#define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \ + (char *(*)())d2i_X509_NAME,(char *)xn) +#define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \ + (int (*)())i2d_X509_NAME_ENTRY, \ + (char *(*)())d2i_X509_NAME_ENTRY,\ + (char *)ne) + +#define X509_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len) +#define X509_NAME_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len) +#ifndef PKCS7_ISSUER_AND_SERIAL_digest +#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ + ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\ + (char *)data,md,len) +#endif +#endif + +#define X509_EXT_PACK_UNKNOWN 1 +#define X509_EXT_PACK_STRING 2 + +#define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version) +/* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */ +#define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore) +#define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter) +#define X509_extract_key(x) X509_get_pubkey(x) /*****/ +#define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version) +#define X509_REQ_get_subject_name(x) ((x)->req_info->subject) +#define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) +#define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) +#define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm)) + +#define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version) +#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) +#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) +#define X509_CRL_get_issuer(x) ((x)->crl->issuer) +#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) + +/* This one is only used so that a binary form can output, as in + * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */ +#define X509_get_X509_PUBKEY(x) ((x)->cert_info->key) + + +const char *X509_verify_cert_error_string(long n); + +#ifndef SSLEAY_MACROS +#ifndef OPENSSL_NO_EVP +int X509_verify(X509 *a, EVP_PKEY *r); + +int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); +int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); +int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); + +NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len); +char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); +EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); +int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); + +int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); + +int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig); + +int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); +int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); +int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); + +int X509_pubkey_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_digest(const X509 *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type, + unsigned char *md, unsigned int *len); +#endif + +#ifndef OPENSSL_NO_FP_API +X509 *d2i_X509_fp(FILE *fp, X509 **x509); +int i2d_X509_fp(FILE *fp,X509 *x509); +X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); +int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); +int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); +int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); +int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); +int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); +DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); +int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); +int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); +int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8); +int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); +int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); +int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); +#endif + +#ifndef OPENSSL_NO_BIO +X509 *d2i_X509_bio(BIO *bp,X509 **x509); +int i2d_X509_bio(BIO *bp,X509 *x509); +X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); +int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); +X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); +int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); +#ifndef OPENSSL_NO_RSA +RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); +int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa); +RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); +int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); +#endif +#ifndef OPENSSL_NO_DSA +DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); +int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); +DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); +int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); +#endif +#ifndef OPENSSL_NO_EC +EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); +int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); +EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); +int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); +#endif +X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8); +int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, + PKCS8_PRIV_KEY_INFO **p8inf); +int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf); +int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); +int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); +int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); +EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); +#endif + +X509 *X509_dup(X509 *x509); +X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); +X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); +X509_CRL *X509_CRL_dup(X509_CRL *crl); +X509_REQ *X509_REQ_dup(X509_REQ *req); +X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); +X509_NAME *X509_NAME_dup(X509_NAME *xn); +X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); + +#endif /* !SSLEAY_MACROS */ + +int X509_cmp_time(ASN1_TIME *s, time_t *t); +int X509_cmp_current_time(ASN1_TIME *s); +ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t); +ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj); + +const char * X509_get_default_cert_area(void ); +const char * X509_get_default_cert_dir(void ); +const char * X509_get_default_cert_file(void ); +const char * X509_get_default_cert_dir_env(void ); +const char * X509_get_default_cert_file_env(void ); +const char * X509_get_default_private_dir(void ); + +X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); +X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); + +DECLARE_ASN1_FUNCTIONS(X509_ALGOR) +DECLARE_ASN1_FUNCTIONS(X509_VAL) + +DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) + +int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); +EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); +int X509_get_pubkey_parameters(EVP_PKEY *pkey, + STACK_OF(X509) *chain); +int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp); +EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp, + long length); +#ifndef OPENSSL_NO_RSA +int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp); +RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_DSA +int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp); +DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp, + long length); +#endif +#ifndef OPENSSL_NO_EC +int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); +EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, + long length); +#endif + +DECLARE_ASN1_FUNCTIONS(X509_SIG) +DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) +DECLARE_ASN1_FUNCTIONS(X509_REQ) + +DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) +X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); + +DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) + +DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) + +DECLARE_ASN1_FUNCTIONS(X509_NAME) + +int X509_NAME_set(X509_NAME **xn, X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(X509_CINF) + +DECLARE_ASN1_FUNCTIONS(X509) +DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) + +DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR) + +int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_set_ex_data(X509 *r, int idx, void *arg); +void *X509_get_ex_data(X509 *r, int idx); +int i2d_X509_AUX(X509 *a,unsigned char **pp); +X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length); + +int X509_alias_set1(X509 *x, unsigned char *name, int len); +int X509_keyid_set1(X509 *x, unsigned char *id, int len); +unsigned char * X509_alias_get0(X509 *x, int *len); +unsigned char * X509_keyid_get0(X509 *x, int *len); +int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); +int X509_TRUST_set(int *t, int trust); +int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); +int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); +void X509_trust_clear(X509 *x); +void X509_reject_clear(X509 *x); + +DECLARE_ASN1_FUNCTIONS(X509_REVOKED) +DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) +DECLARE_ASN1_FUNCTIONS(X509_CRL) + +int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); + +X509_PKEY * X509_PKEY_new(void ); +void X509_PKEY_free(X509_PKEY *a); +int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); +X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length); + +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) +DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) + +#ifndef OPENSSL_NO_EVP +X509_INFO * X509_INFO_new(void); +void X509_INFO_free(X509_INFO *a); +char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); + +int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey); + +int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data, + unsigned char *md,unsigned int *len); + +int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + char *data,EVP_PKEY *pkey, const EVP_MD *type); + +int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data, + unsigned char *md,unsigned int *len); + +int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey); + +int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, + void *data, EVP_PKEY *pkey, const EVP_MD *type); +#endif + +int X509_set_version(X509 *x,long version); +int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); +ASN1_INTEGER * X509_get_serialNumber(X509 *x); +int X509_set_issuer_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_issuer_name(X509 *a); +int X509_set_subject_name(X509 *x, X509_NAME *name); +X509_NAME * X509_get_subject_name(X509 *a); +int X509_set_notBefore(X509 *x, ASN1_TIME *tm); +int X509_set_notAfter(X509 *x, ASN1_TIME *tm); +int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); +EVP_PKEY * X509_get_pubkey(X509 *x); +ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x); +int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); + +int X509_REQ_set_version(X509_REQ *x,long version); +int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name); +int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); +EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req); +int X509_REQ_extension_nid(int nid); +int * X509_REQ_get_extension_nids(void); +void X509_REQ_set_extension_nids(int *nids); +STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); +int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, + int nid); +int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); +int X509_REQ_get_attr_count(const X509_REQ *req); +int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, + int lastpos); +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); +X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); +int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); +int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_NID(X509_REQ *req, + int nid, int type, + const unsigned char *bytes, int len); +int X509_REQ_add1_attr_by_txt(X509_REQ *req, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_CRL_set_version(X509_CRL *x, long version); +int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); +int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm); +int X509_CRL_sort(X509_CRL *crl); + +int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); +int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); + +int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey); + +int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); + +int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_and_serial_hash(X509 *a); + +int X509_issuer_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_issuer_name_hash(X509 *a); + +int X509_subject_name_cmp(const X509 *a, const X509 *b); +unsigned long X509_subject_name_hash(X509 *x); + +int X509_cmp(const X509 *a, const X509 *b); +int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); +unsigned long X509_NAME_hash(X509_NAME *x); + +int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); +#ifndef OPENSSL_NO_FP_API +int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print_fp(FILE *bp,X509 *x); +int X509_CRL_print_fp(FILE *bp,X509_CRL *x); +int X509_REQ_print_fp(FILE *bp,X509_REQ *req); +int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); +#endif + +#ifndef OPENSSL_NO_BIO +int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); +int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); +int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print(BIO *bp,X509 *x); +int X509_ocspid_print(BIO *bp,X509 *x); +int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); +int X509_CRL_print(BIO *bp,X509_CRL *x); +int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); +int X509_REQ_print(BIO *bp,X509_REQ *req); +#endif + +int X509_NAME_entry_count(X509_NAME *name); +int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, + char *buf,int len); +int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, + char *buf,int len); + +/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use + * lastpos, search after that position on. */ +int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); +int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, + int lastpos); +X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); +X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); +int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, + int loc, int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, + unsigned char *bytes, int len, int loc, int set); +int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, + unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, + const char *field, int type, const unsigned char *bytes, int len); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, + int type,unsigned char *bytes, int len); +int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, + const unsigned char *bytes, int len, int loc, int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, + ASN1_OBJECT *obj, int type,const unsigned char *bytes, + int len); +int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, + ASN1_OBJECT *obj); +int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, + const unsigned char *bytes, int len); +ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); +ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); + +int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); +int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, + int nid, int lastpos); +int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, + ASN1_OBJECT *obj,int lastpos); +int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, + int crit, int lastpos); +X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); +X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); +STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, + X509_EXTENSION *ex, int loc); + +int X509_get_ext_count(X509 *x); +int X509_get_ext_by_NID(X509 *x, int nid, int lastpos); +int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos); +int X509_get_ext_by_critical(X509 *x, int crit, int lastpos); +X509_EXTENSION *X509_get_ext(X509 *x, int loc); +X509_EXTENSION *X509_delete_ext(X509 *x, int loc); +int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); +void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); +int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_CRL_get_ext_count(X509_CRL *x); +int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); +int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos); +int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos); +X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc); +X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); +int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); +void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, + unsigned long flags); + +int X509_REVOKED_get_ext_count(X509_REVOKED *x); +int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); +int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos); +int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos); +X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc); +X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); +int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); +void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, + unsigned long flags); + +X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, + int nid, int crit, ASN1_OCTET_STRING *data); +X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, + ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data); +int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj); +int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); +int X509_EXTENSION_set_data(X509_EXTENSION *ex, + ASN1_OCTET_STRING *data); +ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex); +ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); +int X509_EXTENSION_get_critical(X509_EXTENSION *ex); + +int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); +int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, + int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); +X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, + X509_ATTRIBUTE *attr); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, + int nid, int type, + const unsigned char *bytes, int len); +STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, + const char *attrname, int type, + const unsigned char *bytes, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, + int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, + const ASN1_OBJECT *obj, int atrtype, const void *data, int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, + const char *atrname, int type, const unsigned char *bytes, int len); +int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); +int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); +void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, + int atrtype, void *data); +int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); +ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); +ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); + +int EVP_PKEY_get_attr_count(const EVP_PKEY *key); +int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, + int lastpos); +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, + int lastpos); +X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); +X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); +int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); +int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, + int nid, int type, + const unsigned char *bytes, int len); +int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, + const char *attrname, int type, + const unsigned char *bytes, int len); + +int X509_verify_cert(X509_STORE_CTX *ctx); + +/* lookup a cert from a X509 STACK */ +X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name, + ASN1_INTEGER *serial); +X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); + +DECLARE_ASN1_FUNCTIONS(PBEPARAM) +DECLARE_ASN1_FUNCTIONS(PBE2PARAM) +DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) + +X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen); + +/* PKCS#8 utilities */ + +DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) + +EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); +PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken); +PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken); + +int X509_check_trust(X509 *x, int id, int flags); +int X509_TRUST_get_count(void); +X509_TRUST * X509_TRUST_get0(int idx); +int X509_TRUST_get_by_id(int id); +int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), + char *name, int arg1, void *arg2); +void X509_TRUST_cleanup(void); +int X509_TRUST_get_flags(X509_TRUST *xp); +char *X509_TRUST_get0_name(X509_TRUST *xp); +int X509_TRUST_get_trust(X509_TRUST *xp); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509_strings(void); + +/* Error codes for the X509 functions. */ + +/* Function codes. */ +#define X509_F_ADD_CERT_DIR 100 +#define X509_F_BY_FILE_CTRL 101 +#define X509_F_CHECK_POLICY 145 +#define X509_F_DIR_CTRL 102 +#define X509_F_GET_CERT_BY_SUBJECT 103 +#define X509_F_NETSCAPE_SPKI_B64_DECODE 129 +#define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 +#define X509_F_X509AT_ADD1_ATTR 135 +#define X509_F_X509V3_ADD_EXT 104 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 +#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 +#define X509_F_X509_ATTRIBUTE_GET0_DATA 139 +#define X509_F_X509_ATTRIBUTE_SET1_DATA 138 +#define X509_F_X509_CHECK_PRIVATE_KEY 128 +#define X509_F_X509_CRL_PRINT_FP 147 +#define X509_F_X509_EXTENSION_CREATE_BY_NID 108 +#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 +#define X509_F_X509_GET_PUBKEY_PARAMETERS 110 +#define X509_F_X509_LOAD_CERT_CRL_FILE 132 +#define X509_F_X509_LOAD_CERT_FILE 111 +#define X509_F_X509_LOAD_CRL_FILE 112 +#define X509_F_X509_NAME_ADD_ENTRY 113 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 +#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 +#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 +#define X509_F_X509_NAME_ONELINE 116 +#define X509_F_X509_NAME_PRINT 117 +#define X509_F_X509_PRINT_EX_FP 118 +#define X509_F_X509_PUBKEY_GET 119 +#define X509_F_X509_PUBKEY_SET 120 +#define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 +#define X509_F_X509_REQ_PRINT_EX 121 +#define X509_F_X509_REQ_PRINT_FP 122 +#define X509_F_X509_REQ_TO_X509 123 +#define X509_F_X509_STORE_ADD_CERT 124 +#define X509_F_X509_STORE_ADD_CRL 125 +#define X509_F_X509_STORE_CTX_GET1_ISSUER 146 +#define X509_F_X509_STORE_CTX_INIT 143 +#define X509_F_X509_STORE_CTX_NEW 142 +#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 +#define X509_F_X509_TO_X509_REQ 126 +#define X509_F_X509_TRUST_ADD 133 +#define X509_F_X509_TRUST_SET 141 +#define X509_F_X509_VERIFY_CERT 127 + +/* Reason codes. */ +#define X509_R_BAD_X509_FILETYPE 100 +#define X509_R_BASE64_DECODE_ERROR 118 +#define X509_R_CANT_CHECK_DH_KEY 114 +#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 +#define X509_R_ERR_ASN1_LIB 102 +#define X509_R_INVALID_DIRECTORY 113 +#define X509_R_INVALID_FIELD_NAME 119 +#define X509_R_INVALID_TRUST 123 +#define X509_R_KEY_TYPE_MISMATCH 115 +#define X509_R_KEY_VALUES_MISMATCH 116 +#define X509_R_LOADING_CERT_DIR 103 +#define X509_R_LOADING_DEFAULTS 104 +#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 +#define X509_R_SHOULD_RETRY 106 +#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 +#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 +#define X509_R_UNKNOWN_KEY_TYPE 117 +#define X509_R_UNKNOWN_NID 109 +#define X509_R_UNKNOWN_PURPOSE_ID 121 +#define X509_R_UNKNOWN_TRUST_ID 120 +#define X509_R_UNSUPPORTED_ALGORITHM 111 +#define X509_R_WRONG_LOOKUP_TYPE 112 +#define X509_R_WRONG_TYPE 122 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/include/openssl/x509_vfy.h b/libraries/external/openssl/pc/include/openssl/x509_vfy.h new file mode 100755 index 0000000..09c3191 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/x509_vfy.h @@ -0,0 +1,531 @@ +/* crypto/x509/x509_vfy.h */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#ifndef HEADER_X509_H +#include +/* openssl/x509.h ends up #include-ing this file at about the only + * appropriate moment. */ +#endif + +#ifndef HEADER_X509_VFY_H +#define HEADER_X509_VFY_H + +#include +#ifndef OPENSSL_NO_LHASH +#include +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Outer object */ +typedef struct x509_hash_dir_st + { + int num_dirs; + char **dirs; + int *dirs_type; + int num_dirs_alloced; + } X509_HASH_DIR_CTX; + +typedef struct x509_file_st + { + int num_paths; /* number of paths to files or directories */ + int num_alloced; + char **paths; /* the list of paths or directories */ + int *path_type; + } X509_CERT_FILE_CTX; + +/*******************************/ +/* +SSL_CTX -> X509_STORE + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + -> X509_LOOKUP + ->X509_LOOKUP_METHOD + +SSL -> X509_STORE_CTX + ->X509_STORE + +The X509_STORE holds the tables etc for verification stuff. +A X509_STORE_CTX is used while validating a single certificate. +The X509_STORE has X509_LOOKUPs for looking up certs. +The X509_STORE then calls a function to actually verify the +certificate chain. +*/ + +#define X509_LU_RETRY -1 +#define X509_LU_FAIL 0 +#define X509_LU_X509 1 +#define X509_LU_CRL 2 +#define X509_LU_PKEY 3 + +typedef struct x509_object_st + { + /* one of the above types */ + int type; + union { + char *ptr; + X509 *x509; + X509_CRL *crl; + EVP_PKEY *pkey; + } data; + } X509_OBJECT; + +typedef struct x509_lookup_st X509_LOOKUP; + +DECLARE_STACK_OF(X509_LOOKUP) +DECLARE_STACK_OF(X509_OBJECT) + +/* This is a static that defines the function interface */ +typedef struct x509_lookup_method_st + { + const char *name; + int (*new_item)(X509_LOOKUP *ctx); + void (*free)(X509_LOOKUP *ctx); + int (*init)(X509_LOOKUP *ctx); + int (*shutdown)(X509_LOOKUP *ctx); + int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl, + char **ret); + int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name, + X509_OBJECT *ret); + int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name, + ASN1_INTEGER *serial,X509_OBJECT *ret); + int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type, + unsigned char *bytes,int len, + X509_OBJECT *ret); + int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len, + X509_OBJECT *ret); + } X509_LOOKUP_METHOD; + +/* This structure hold all parameters associated with a verify operation + * by including an X509_VERIFY_PARAM structure in related structures the + * parameters used can be customized + */ + +typedef struct X509_VERIFY_PARAM_st + { + char *name; + time_t check_time; /* Time to use */ + unsigned long inh_flags; /* Inheritance flags */ + unsigned long flags; /* Various verify flags */ + int purpose; /* purpose to check untrusted certificates */ + int trust; /* trust setting to check */ + int depth; /* Verify depth */ + STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ + } X509_VERIFY_PARAM; + +DECLARE_STACK_OF(X509_VERIFY_PARAM) + +/* This is used to hold everything. It is used for all certificate + * validation. Once we have a certificate chain, the 'verify' + * function is then called to actually check the cert chain. */ +struct x509_store_st + { + /* The following is a cache of trusted certs */ + int cache; /* if true, stash any hits */ + STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ + + /* These are external lookup methods */ + STACK_OF(X509_LOOKUP) *get_cert_methods; + + X509_VERIFY_PARAM *param; + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*cleanup)(X509_STORE_CTX *ctx); + + CRYPTO_EX_DATA ex_data; + int references; + } /* X509_STORE */; + +int X509_STORE_set_depth(X509_STORE *store, int depth); + +#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func)) +#define X509_STORE_set_verify_func(ctx,func) ((ctx)->verify=(func)) + +/* This is the functions plus an instance of the local variables. */ +struct x509_lookup_st + { + int init; /* have we been started */ + int skip; /* don't use us. */ + X509_LOOKUP_METHOD *method; /* the functions */ + char *method_data; /* method data */ + + X509_STORE *store_ctx; /* who owns us */ + } /* X509_LOOKUP */; + +/* This is a used when verifying cert chains. Since the + * gathering of the cert chain can take some time (and have to be + * 'retried', this needs to be kept and passed around. */ +struct x509_store_ctx_st /* X509_STORE_CTX */ + { + X509_STORE *ctx; + int current_method; /* used when looking up certs */ + + /* The following are set by the caller */ + X509 *cert; /* The cert to check */ + STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ + STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ + + X509_VERIFY_PARAM *param; + void *other_ctx; /* Other info for use with get_issuer() */ + + /* Callbacks for various operations */ + int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ + int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ + int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ + int (*check_policy)(X509_STORE_CTX *ctx); + int (*cleanup)(X509_STORE_CTX *ctx); + + /* The following is built up */ + int valid; /* if 0, rebuild chain */ + int last_untrusted; /* index of last untrusted cert */ + STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ + X509_POLICY_TREE *tree; /* Valid policy tree */ + + int explicit_policy; /* Require explicit policy value */ + + /* When something goes wrong, this is why */ + int error_depth; + int error; + X509 *current_cert; + X509 *current_issuer; /* cert currently being tested as valid issuer */ + X509_CRL *current_crl; /* current CRL */ + + CRYPTO_EX_DATA ex_data; + } /* X509_STORE_CTX */; + +void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); + +#define X509_STORE_CTX_set_app_data(ctx,data) \ + X509_STORE_CTX_set_ex_data(ctx,0,data) +#define X509_STORE_CTX_get_app_data(ctx) \ + X509_STORE_CTX_get_ex_data(ctx,0) + +#define X509_L_FILE_LOAD 1 +#define X509_L_ADD_DIR 2 + +#define X509_LOOKUP_load_file(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) + +#define X509_LOOKUP_add_dir(x,name,type) \ + X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) + +#define X509_V_OK 0 +/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ + +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 +#define X509_V_ERR_UNABLE_TO_GET_CRL 3 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 +#define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 +#define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 +#define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 +#define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 +#define X509_V_ERR_CERT_NOT_YET_VALID 9 +#define X509_V_ERR_CERT_HAS_EXPIRED 10 +#define X509_V_ERR_CRL_NOT_YET_VALID 11 +#define X509_V_ERR_CRL_HAS_EXPIRED 12 +#define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 +#define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 +#define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 +#define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 +#define X509_V_ERR_OUT_OF_MEM 17 +#define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 +#define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 +#define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 +#define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 +#define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 +#define X509_V_ERR_CERT_REVOKED 23 +#define X509_V_ERR_INVALID_CA 24 +#define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 +#define X509_V_ERR_INVALID_PURPOSE 26 +#define X509_V_ERR_CERT_UNTRUSTED 27 +#define X509_V_ERR_CERT_REJECTED 28 +/* These are 'informational' when looking for issuer cert */ +#define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 +#define X509_V_ERR_AKID_SKID_MISMATCH 30 +#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 +#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 + +#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 +#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 +#define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 +#define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 +#define X509_V_ERR_INVALID_NON_CA 37 +#define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 +#define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 +#define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 + +#define X509_V_ERR_INVALID_EXTENSION 41 +#define X509_V_ERR_INVALID_POLICY_EXTENSION 42 +#define X509_V_ERR_NO_EXPLICIT_POLICY 43 + +#define X509_V_ERR_UNNESTED_RESOURCE 44 + +/* The application is not happy */ +#define X509_V_ERR_APPLICATION_VERIFICATION 50 + +/* Certificate verify flags */ + +/* Send issuer+subject checks to verify_cb */ +#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 +/* Use check time instead of current time */ +#define X509_V_FLAG_USE_CHECK_TIME 0x2 +/* Lookup CRLs */ +#define X509_V_FLAG_CRL_CHECK 0x4 +/* Lookup CRLs for whole chain */ +#define X509_V_FLAG_CRL_CHECK_ALL 0x8 +/* Ignore unhandled critical extensions */ +#define X509_V_FLAG_IGNORE_CRITICAL 0x10 +/* Disable workarounds for broken certificates */ +#define X509_V_FLAG_X509_STRICT 0x20 +/* Enable proxy certificate validation */ +#define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 +/* Enable policy checking */ +#define X509_V_FLAG_POLICY_CHECK 0x80 +/* Policy variable require-explicit-policy */ +#define X509_V_FLAG_EXPLICIT_POLICY 0x100 +/* Policy variable inhibit-any-policy */ +#define X509_V_FLAG_INHIBIT_ANY 0x200 +/* Policy variable inhibit-policy-mapping */ +#define X509_V_FLAG_INHIBIT_MAP 0x400 +/* Notify callback that policy is OK */ +#define X509_V_FLAG_NOTIFY_POLICY 0x800 + +#define X509_VP_FLAG_DEFAULT 0x1 +#define X509_VP_FLAG_OVERWRITE 0x2 +#define X509_VP_FLAG_RESET_FLAGS 0x4 +#define X509_VP_FLAG_LOCKED 0x8 +#define X509_VP_FLAG_ONCE 0x10 + +/* Internal use: mask of policy related options */ +#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ + | X509_V_FLAG_EXPLICIT_POLICY \ + | X509_V_FLAG_INHIBIT_ANY \ + | X509_V_FLAG_INHIBIT_MAP) + +int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, + X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name); +X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); +void X509_OBJECT_up_ref_count(X509_OBJECT *a); +void X509_OBJECT_free_contents(X509_OBJECT *a); +X509_STORE *X509_STORE_new(void ); +void X509_STORE_free(X509_STORE *v); + +int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); +int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); +int X509_STORE_set_trust(X509_STORE *ctx, int trust); +int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); + +X509_STORE_CTX *X509_STORE_CTX_new(void); + +int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + +void X509_STORE_CTX_free(X509_STORE_CTX *ctx); +int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, + X509 *x509, STACK_OF(X509) *chain); +void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); +void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); + +X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); + +X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); +X509_LOOKUP_METHOD *X509_LOOKUP_file(void); + +int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); +int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); + +int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name, + X509_OBJECT *ret); + +int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); + +#ifndef OPENSSL_NO_STDIO +int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); +int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); +#endif + + +X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); +void X509_LOOKUP_free(X509_LOOKUP *ctx); +int X509_LOOKUP_init(X509_LOOKUP *ctx); +int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, + X509_OBJECT *ret); +int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, + ASN1_INTEGER *serial, X509_OBJECT *ret); +int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, + unsigned char *bytes, int len, X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, + int len, X509_OBJECT *ret); +int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); + +#ifndef OPENSSL_NO_STDIO +int X509_STORE_load_locations (X509_STORE *ctx, + const char *file, const char *dir); +int X509_STORE_set_default_paths(X509_STORE *ctx); +#endif + +int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data); +void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx); +int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); +int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); +X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); +STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x); +void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk); +void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk); +int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); +int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); +int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, + int purpose, int trust); +void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); +void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, + time_t t); +void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, + int (*verify_cb)(int, X509_STORE_CTX *)); + +X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); +int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); + +X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); +void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); +int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); + +/* X509_VERIFY_PARAM functions */ + +X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); +void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); +int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); +int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, + unsigned long flags); +unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); +int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); +int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); +void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); +void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); +int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, + ASN1_OBJECT *policy); +int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, + STACK_OF(ASN1_OBJECT) *policies); +int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); + +int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); +const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); +void X509_VERIFY_PARAM_table_cleanup(void); + +int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, + STACK_OF(X509) *certs, + STACK_OF(ASN1_OBJECT) *policy_oids, + unsigned int flags); + +void X509_policy_tree_free(X509_POLICY_TREE *tree); + +int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); +X509_POLICY_LEVEL * + X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); + +STACK_OF(X509_POLICY_NODE) * + X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); + +int X509_policy_level_node_count(X509_POLICY_LEVEL *level); + +X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); + +const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); + +STACK_OF(POLICYQUALINFO) * + X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); +const X509_POLICY_NODE * + X509_policy_node_get0_parent(const X509_POLICY_NODE *node); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/libraries/external/openssl/pc/include/openssl/x509v3.h b/libraries/external/openssl/pc/include/openssl/x509v3.h new file mode 100755 index 0000000..0a84264 --- /dev/null +++ b/libraries/external/openssl/pc/include/openssl/x509v3.h @@ -0,0 +1,919 @@ +/* x509v3.h */ +/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL + * project 1999. + */ +/* ==================================================================== + * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +#ifndef HEADER_X509V3_H +#define HEADER_X509V3_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward reference */ +struct v3_ext_method; +struct v3_ext_ctx; + +/* Useful typedefs */ + +typedef void * (*X509V3_EXT_NEW)(void); +typedef void (*X509V3_EXT_FREE)(void *); +typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long); +typedef int (*X509V3_EXT_I2D)(void *, unsigned char **); +typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) *extlist); +typedef void * (*X509V3_EXT_V2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) *values); +typedef char * (*X509V3_EXT_I2S)(struct v3_ext_method *method, void *ext); +typedef void * (*X509V3_EXT_S2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); +typedef int (*X509V3_EXT_I2R)(struct v3_ext_method *method, void *ext, BIO *out, int indent); +typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx *ctx, const char *str); + +/* V3 extension structure */ + +struct v3_ext_method { +int ext_nid; +int ext_flags; +/* If this is set the following four fields are ignored */ +ASN1_ITEM_EXP *it; +/* Old style ASN1 calls */ +X509V3_EXT_NEW ext_new; +X509V3_EXT_FREE ext_free; +X509V3_EXT_D2I d2i; +X509V3_EXT_I2D i2d; + +/* The following pair is used for string extensions */ +X509V3_EXT_I2S i2s; +X509V3_EXT_S2I s2i; + +/* The following pair is used for multi-valued extensions */ +X509V3_EXT_I2V i2v; +X509V3_EXT_V2I v2i; + +/* The following are used for raw extensions */ +X509V3_EXT_I2R i2r; +X509V3_EXT_R2I r2i; + +void *usr_data; /* Any extension specific data */ +}; + +typedef struct X509V3_CONF_METHOD_st { +char * (*get_string)(void *db, char *section, char *value); +STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); +void (*free_string)(void *db, char * string); +void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); +} X509V3_CONF_METHOD; + +/* Context specific info */ +struct v3_ext_ctx { +#define CTX_TEST 0x1 +int flags; +X509 *issuer_cert; +X509 *subject_cert; +X509_REQ *subject_req; +X509_CRL *crl; +X509V3_CONF_METHOD *db_meth; +void *db; +/* Maybe more here */ +}; + +typedef struct v3_ext_method X509V3_EXT_METHOD; + +DECLARE_STACK_OF(X509V3_EXT_METHOD) + +/* ext_flags values */ +#define X509V3_EXT_DYNAMIC 0x1 +#define X509V3_EXT_CTX_DEP 0x2 +#define X509V3_EXT_MULTILINE 0x4 + +typedef BIT_STRING_BITNAME ENUMERATED_NAMES; + +typedef struct BASIC_CONSTRAINTS_st { +int ca; +ASN1_INTEGER *pathlen; +} BASIC_CONSTRAINTS; + + +typedef struct PKEY_USAGE_PERIOD_st { +ASN1_GENERALIZEDTIME *notBefore; +ASN1_GENERALIZEDTIME *notAfter; +} PKEY_USAGE_PERIOD; + +typedef struct otherName_st { +ASN1_OBJECT *type_id; +ASN1_TYPE *value; +} OTHERNAME; + +typedef struct EDIPartyName_st { + ASN1_STRING *nameAssigner; + ASN1_STRING *partyName; +} EDIPARTYNAME; + +typedef struct GENERAL_NAME_st { + +#define GEN_OTHERNAME 0 +#define GEN_EMAIL 1 +#define GEN_DNS 2 +#define GEN_X400 3 +#define GEN_DIRNAME 4 +#define GEN_EDIPARTY 5 +#define GEN_URI 6 +#define GEN_IPADD 7 +#define GEN_RID 8 + +int type; +union { + char *ptr; + OTHERNAME *otherName; /* otherName */ + ASN1_IA5STRING *rfc822Name; + ASN1_IA5STRING *dNSName; + ASN1_TYPE *x400Address; + X509_NAME *directoryName; + EDIPARTYNAME *ediPartyName; + ASN1_IA5STRING *uniformResourceIdentifier; + ASN1_OCTET_STRING *iPAddress; + ASN1_OBJECT *registeredID; + + /* Old names */ + ASN1_OCTET_STRING *ip; /* iPAddress */ + X509_NAME *dirn; /* dirn */ + ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ + ASN1_OBJECT *rid; /* registeredID */ + ASN1_TYPE *other; /* x400Address */ +} d; +} GENERAL_NAME; + +typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; + +typedef struct ACCESS_DESCRIPTION_st { + ASN1_OBJECT *method; + GENERAL_NAME *location; +} ACCESS_DESCRIPTION; + +typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; + +typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; + +DECLARE_STACK_OF(GENERAL_NAME) +DECLARE_ASN1_SET_OF(GENERAL_NAME) + +DECLARE_STACK_OF(ACCESS_DESCRIPTION) +DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) + +typedef struct DIST_POINT_NAME_st { +int type; +union { + GENERAL_NAMES *fullname; + STACK_OF(X509_NAME_ENTRY) *relativename; +} name; +} DIST_POINT_NAME; + +typedef struct DIST_POINT_st { +DIST_POINT_NAME *distpoint; +ASN1_BIT_STRING *reasons; +GENERAL_NAMES *CRLissuer; +} DIST_POINT; + +typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; + +DECLARE_STACK_OF(DIST_POINT) +DECLARE_ASN1_SET_OF(DIST_POINT) + +typedef struct AUTHORITY_KEYID_st { +ASN1_OCTET_STRING *keyid; +GENERAL_NAMES *issuer; +ASN1_INTEGER *serial; +} AUTHORITY_KEYID; + +/* Strong extranet structures */ + +typedef struct SXNET_ID_st { + ASN1_INTEGER *zone; + ASN1_OCTET_STRING *user; +} SXNETID; + +DECLARE_STACK_OF(SXNETID) +DECLARE_ASN1_SET_OF(SXNETID) + +typedef struct SXNET_st { + ASN1_INTEGER *version; + STACK_OF(SXNETID) *ids; +} SXNET; + +typedef struct NOTICEREF_st { + ASN1_STRING *organization; + STACK_OF(ASN1_INTEGER) *noticenos; +} NOTICEREF; + +typedef struct USERNOTICE_st { + NOTICEREF *noticeref; + ASN1_STRING *exptext; +} USERNOTICE; + +typedef struct POLICYQUALINFO_st { + ASN1_OBJECT *pqualid; + union { + ASN1_IA5STRING *cpsuri; + USERNOTICE *usernotice; + ASN1_TYPE *other; + } d; +} POLICYQUALINFO; + +DECLARE_STACK_OF(POLICYQUALINFO) +DECLARE_ASN1_SET_OF(POLICYQUALINFO) + +typedef struct POLICYINFO_st { + ASN1_OBJECT *policyid; + STACK_OF(POLICYQUALINFO) *qualifiers; +} POLICYINFO; + +typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; + +DECLARE_STACK_OF(POLICYINFO) +DECLARE_ASN1_SET_OF(POLICYINFO) + +typedef struct POLICY_MAPPING_st { + ASN1_OBJECT *issuerDomainPolicy; + ASN1_OBJECT *subjectDomainPolicy; +} POLICY_MAPPING; + +DECLARE_STACK_OF(POLICY_MAPPING) + +typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; + +typedef struct GENERAL_SUBTREE_st { + GENERAL_NAME *base; + ASN1_INTEGER *minimum; + ASN1_INTEGER *maximum; +} GENERAL_SUBTREE; + +DECLARE_STACK_OF(GENERAL_SUBTREE) + +typedef struct NAME_CONSTRAINTS_st { + STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; + STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; +} NAME_CONSTRAINTS; + +typedef struct POLICY_CONSTRAINTS_st { + ASN1_INTEGER *requireExplicitPolicy; + ASN1_INTEGER *inhibitPolicyMapping; +} POLICY_CONSTRAINTS; + +/* Proxy certificate structures, see RFC 3820 */ +typedef struct PROXY_POLICY_st + { + ASN1_OBJECT *policyLanguage; + ASN1_OCTET_STRING *policy; + } PROXY_POLICY; + +typedef struct PROXY_CERT_INFO_EXTENSION_st + { + ASN1_INTEGER *pcPathLengthConstraint; + PROXY_POLICY *proxyPolicy; + } PROXY_CERT_INFO_EXTENSION; + +DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) +DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) + + +#define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ +",name:", val->name, ",value:", val->value); + +#define X509V3_set_ctx_test(ctx) \ + X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) +#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; + +#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ + 0,0,0,0, \ + 0,0, \ + (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ + (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ + NULL, NULL, \ + table} + +#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ + 0,0,0,0, \ + (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ + 0,0,0,0, \ + NULL} + +#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + + +/* X509_PURPOSE stuff */ + +#define EXFLAG_BCONS 0x1 +#define EXFLAG_KUSAGE 0x2 +#define EXFLAG_XKUSAGE 0x4 +#define EXFLAG_NSCERT 0x8 + +#define EXFLAG_CA 0x10 +#define EXFLAG_SS 0x20 +#define EXFLAG_V1 0x40 +#define EXFLAG_INVALID 0x80 +#define EXFLAG_SET 0x100 +#define EXFLAG_CRITICAL 0x200 +#define EXFLAG_PROXY 0x400 + +#define EXFLAG_INVALID_POLICY 0x400 + +#define KU_DIGITAL_SIGNATURE 0x0080 +#define KU_NON_REPUDIATION 0x0040 +#define KU_KEY_ENCIPHERMENT 0x0020 +#define KU_DATA_ENCIPHERMENT 0x0010 +#define KU_KEY_AGREEMENT 0x0008 +#define KU_KEY_CERT_SIGN 0x0004 +#define KU_CRL_SIGN 0x0002 +#define KU_ENCIPHER_ONLY 0x0001 +#define KU_DECIPHER_ONLY 0x8000 + +#define NS_SSL_CLIENT 0x80 +#define NS_SSL_SERVER 0x40 +#define NS_SMIME 0x20 +#define NS_OBJSIGN 0x10 +#define NS_SSL_CA 0x04 +#define NS_SMIME_CA 0x02 +#define NS_OBJSIGN_CA 0x01 +#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) + +#define XKU_SSL_SERVER 0x1 +#define XKU_SSL_CLIENT 0x2 +#define XKU_SMIME 0x4 +#define XKU_CODE_SIGN 0x8 +#define XKU_SGC 0x10 +#define XKU_OCSP_SIGN 0x20 +#define XKU_TIMESTAMP 0x40 +#define XKU_DVCS 0x80 + +#define X509_PURPOSE_DYNAMIC 0x1 +#define X509_PURPOSE_DYNAMIC_NAME 0x2 + +typedef struct x509_purpose_st { + int purpose; + int trust; /* Default trust ID */ + int flags; + int (*check_purpose)(const struct x509_purpose_st *, + const X509 *, int); + char *name; + char *sname; + void *usr_data; +} X509_PURPOSE; + +#define X509_PURPOSE_SSL_CLIENT 1 +#define X509_PURPOSE_SSL_SERVER 2 +#define X509_PURPOSE_NS_SSL_SERVER 3 +#define X509_PURPOSE_SMIME_SIGN 4 +#define X509_PURPOSE_SMIME_ENCRYPT 5 +#define X509_PURPOSE_CRL_SIGN 6 +#define X509_PURPOSE_ANY 7 +#define X509_PURPOSE_OCSP_HELPER 8 + +#define X509_PURPOSE_MIN 1 +#define X509_PURPOSE_MAX 8 + +/* Flags for X509V3_EXT_print() */ + +#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) +/* Return error for unknown extensions */ +#define X509V3_EXT_DEFAULT 0 +/* Print error for unknown extensions */ +#define X509V3_EXT_ERROR_UNKNOWN (1L << 16) +/* ASN1 parse unknown extensions */ +#define X509V3_EXT_PARSE_UNKNOWN (2L << 16) +/* BIO_dump unknown extensions */ +#define X509V3_EXT_DUMP_UNKNOWN (3L << 16) + +/* Flags for X509V3_add1_i2d */ + +#define X509V3_ADD_OP_MASK 0xfL +#define X509V3_ADD_DEFAULT 0L +#define X509V3_ADD_APPEND 1L +#define X509V3_ADD_REPLACE 2L +#define X509V3_ADD_REPLACE_EXISTING 3L +#define X509V3_ADD_KEEP_EXISTING 4L +#define X509V3_ADD_DELETE 5L +#define X509V3_ADD_SILENT 0x10 + +DECLARE_STACK_OF(X509_PURPOSE) + +DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) + +DECLARE_ASN1_FUNCTIONS(SXNET) +DECLARE_ASN1_FUNCTIONS(SXNETID) + +int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); + +ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone); +ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); +ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); + +DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) + +DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) + + +ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); +STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, + ASN1_BIT_STRING *bits, + STACK_OF(CONF_VALUE) *extlist); + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret); +int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); + +DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) + +STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, + GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist); +GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); + +DECLARE_ASN1_FUNCTIONS(OTHERNAME) +DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) + +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); + +DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) +int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a); + +DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) +DECLARE_ASN1_FUNCTIONS(POLICYINFO) +DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) +DECLARE_ASN1_FUNCTIONS(USERNOTICE) +DECLARE_ASN1_FUNCTIONS(NOTICEREF) + +DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) +DECLARE_ASN1_FUNCTIONS(DIST_POINT) +DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) + +DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) +DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) + +DECLARE_ASN1_ITEM(POLICY_MAPPING) +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) +DECLARE_ASN1_ITEM(POLICY_MAPPINGS) + +DECLARE_ASN1_ITEM(GENERAL_SUBTREE) +DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) + +DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) +DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) + +DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) +DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) + +#ifdef HEADER_CONF_H +GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + CONF_VALUE *cnf); +GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); +void X509V3_conf_free(CONF_VALUE *val); + +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); +X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); +int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); +int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); + +int X509V3_add_value_bool_nf(char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); +int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); +void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); +void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); +#endif + +char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section); +STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section); +void X509V3_string_free(X509V3_CTX *ctx, char *str); +void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); +void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, + X509_REQ *req, X509_CRL *crl, int flags); + +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_uchar(const char *name, const unsigned char *value, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_bool(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) **extlist); +int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, + STACK_OF(CONF_VALUE) **extlist); +char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint); +ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value); +char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint); +int X509V3_EXT_add(X509V3_EXT_METHOD *ext); +int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); +int X509V3_EXT_add_alias(int nid_to, int nid_from); +void X509V3_EXT_cleanup(void); + +X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); +X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); +int X509V3_add_standard_extensions(void); +STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); +void *X509V3_EXT_d2i(X509_EXTENSION *ext); +void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); + + +X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); +int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags); + +char *hex_to_string(unsigned char *buffer, long len); +unsigned char *string_to_hex(char *str, long *len); +int name_cmp(const char *name, const char *cmp); + +void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, + int ml); +int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); +int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); + +int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent); + +int X509_check_ca(X509 *x); +int X509_check_purpose(X509 *x, int id, int ca); +int X509_supported_extension(X509_EXTENSION *ex); +int X509_PURPOSE_set(int *p, int purpose); +int X509_check_issued(X509 *issuer, X509 *subject); +int X509_PURPOSE_get_count(void); +X509_PURPOSE * X509_PURPOSE_get0(int idx); +int X509_PURPOSE_get_by_sname(char *sname); +int X509_PURPOSE_get_by_id(int id); +int X509_PURPOSE_add(int id, int trust, int flags, + int (*ck)(const X509_PURPOSE *, const X509 *, int), + char *name, char *sname, void *arg); +char *X509_PURPOSE_get0_name(X509_PURPOSE *xp); +char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp); +int X509_PURPOSE_get_trust(X509_PURPOSE *xp); +void X509_PURPOSE_cleanup(void); +int X509_PURPOSE_get_id(X509_PURPOSE *); + +STACK *X509_get1_email(X509 *x); +STACK *X509_REQ_get1_email(X509_REQ *x); +void X509_email_free(STACK *sk); + +ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); +ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); +int a2i_ipadd(unsigned char *ipout, const char *ipasc); +int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, + unsigned long chtype); + +void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); + +#ifndef OPENSSL_NO_RFC3779 + +typedef struct ASRange_st { + ASN1_INTEGER *min, *max; +} ASRange; + +#define ASIdOrRange_id 0 +#define ASIdOrRange_range 1 + +typedef struct ASIdOrRange_st { + int type; + union { + ASN1_INTEGER *id; + ASRange *range; + } u; +} ASIdOrRange; + +typedef STACK_OF(ASIdOrRange) ASIdOrRanges; +DECLARE_STACK_OF(ASIdOrRange) + +#define ASIdentifierChoice_inherit 0 +#define ASIdentifierChoice_asIdsOrRanges 1 + +typedef struct ASIdentifierChoice_st { + int type; + union { + ASN1_NULL *inherit; + ASIdOrRanges *asIdsOrRanges; + } u; +} ASIdentifierChoice; + +typedef struct ASIdentifiers_st { + ASIdentifierChoice *asnum, *rdi; +} ASIdentifiers; + +DECLARE_ASN1_FUNCTIONS(ASRange) +DECLARE_ASN1_FUNCTIONS(ASIdOrRange) +DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) +DECLARE_ASN1_FUNCTIONS(ASIdentifiers) + + +typedef struct IPAddressRange_st { + ASN1_BIT_STRING *min, *max; +} IPAddressRange; + +#define IPAddressOrRange_addressPrefix 0 +#define IPAddressOrRange_addressRange 1 + +typedef struct IPAddressOrRange_st { + int type; + union { + ASN1_BIT_STRING *addressPrefix; + IPAddressRange *addressRange; + } u; +} IPAddressOrRange; + +typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; +DECLARE_STACK_OF(IPAddressOrRange) + +#define IPAddressChoice_inherit 0 +#define IPAddressChoice_addressesOrRanges 1 + +typedef struct IPAddressChoice_st { + int type; + union { + ASN1_NULL *inherit; + IPAddressOrRanges *addressesOrRanges; + } u; +} IPAddressChoice; + +typedef struct IPAddressFamily_st { + ASN1_OCTET_STRING *addressFamily; + IPAddressChoice *ipAddressChoice; +} IPAddressFamily; + +typedef STACK_OF(IPAddressFamily) IPAddrBlocks; +DECLARE_STACK_OF(IPAddressFamily) + +DECLARE_ASN1_FUNCTIONS(IPAddressRange) +DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) +DECLARE_ASN1_FUNCTIONS(IPAddressChoice) +DECLARE_ASN1_FUNCTIONS(IPAddressFamily) + +/* + * API tag for elements of the ASIdentifer SEQUENCE. + */ +#define V3_ASID_ASNUM 0 +#define V3_ASID_RDI 1 + +/* + * AFI values, assigned by IANA. It'd be nice to make the AFI + * handling code totally generic, but there are too many little things + * that would need to be defined for other address families for it to + * be worth the trouble. + */ +#define IANA_AFI_IPV4 1 +#define IANA_AFI_IPV6 2 + +/* + * Utilities to construct and extract values from RFC3779 extensions, + * since some of the encodings (particularly for IP address prefixes + * and ranges) are a bit tedious to work with directly. + */ +int v3_asid_add_inherit(ASIdentifiers *asid, int which); +int v3_asid_add_id_or_range(ASIdentifiers *asid, int which, + ASN1_INTEGER *min, ASN1_INTEGER *max); +int v3_addr_add_inherit(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi); +int v3_addr_add_prefix(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *a, const int prefixlen); +int v3_addr_add_range(IPAddrBlocks *addr, + const unsigned afi, const unsigned *safi, + unsigned char *min, unsigned char *max); +unsigned v3_addr_get_afi(const IPAddressFamily *f); +int v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, + unsigned char *min, unsigned char *max, + const int length); + +/* + * Canonical forms. + */ +int v3_asid_is_canonical(ASIdentifiers *asid); +int v3_addr_is_canonical(IPAddrBlocks *addr); +int v3_asid_canonize(ASIdentifiers *asid); +int v3_addr_canonize(IPAddrBlocks *addr); + +/* + * Tests for inheritance and containment. + */ +int v3_asid_inherits(ASIdentifiers *asid); +int v3_addr_inherits(IPAddrBlocks *addr); +int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); +int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); + +/* + * Check whether RFC 3779 extensions nest properly in chains. + */ +int v3_asid_validate_path(X509_STORE_CTX *); +int v3_addr_validate_path(X509_STORE_CTX *); +int v3_asid_validate_resource_set(STACK_OF(X509) *chain, + ASIdentifiers *ext, + int allow_inheritance); +int v3_addr_validate_resource_set(STACK_OF(X509) *chain, + IPAddrBlocks *ext, + int allow_inheritance); + +#endif /* OPENSSL_NO_RFC3779 */ + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_X509V3_strings(void); + +/* Error codes for the X509V3 functions. */ + +/* Function codes. */ +#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 156 +#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 157 +#define X509V3_F_COPY_EMAIL 122 +#define X509V3_F_COPY_ISSUER 123 +#define X509V3_F_DO_DIRNAME 144 +#define X509V3_F_DO_EXT_CONF 124 +#define X509V3_F_DO_EXT_I2D 135 +#define X509V3_F_DO_EXT_NCONF 151 +#define X509V3_F_DO_I2V_NAME_CONSTRAINTS 148 +#define X509V3_F_HEX_TO_STRING 111 +#define X509V3_F_I2S_ASN1_ENUMERATED 121 +#define X509V3_F_I2S_ASN1_IA5STRING 149 +#define X509V3_F_I2S_ASN1_INTEGER 120 +#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 +#define X509V3_F_NOTICE_SECTION 132 +#define X509V3_F_NREF_NOS 133 +#define X509V3_F_POLICY_SECTION 131 +#define X509V3_F_PROCESS_PCI_VALUE 150 +#define X509V3_F_R2I_CERTPOL 130 +#define X509V3_F_R2I_PCI 155 +#define X509V3_F_S2I_ASN1_IA5STRING 100 +#define X509V3_F_S2I_ASN1_INTEGER 108 +#define X509V3_F_S2I_ASN1_OCTET_STRING 112 +#define X509V3_F_S2I_ASN1_SKEY_ID 114 +#define X509V3_F_S2I_SKEY_ID 115 +#define X509V3_F_STRING_TO_HEX 113 +#define X509V3_F_SXNET_ADD_ID_ASC 125 +#define X509V3_F_SXNET_ADD_ID_INTEGER 126 +#define X509V3_F_SXNET_ADD_ID_ULONG 127 +#define X509V3_F_SXNET_GET_ID_ASC 128 +#define X509V3_F_SXNET_GET_ID_ULONG 129 +#define X509V3_F_V2I_ASIDENTIFIERS 158 +#define X509V3_F_V2I_ASN1_BIT_STRING 101 +#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 +#define X509V3_F_V2I_AUTHORITY_KEYID 119 +#define X509V3_F_V2I_BASIC_CONSTRAINTS 102 +#define X509V3_F_V2I_CRLD 134 +#define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 +#define X509V3_F_V2I_GENERAL_NAMES 118 +#define X509V3_F_V2I_GENERAL_NAME_EX 117 +#define X509V3_F_V2I_IPADDRBLOCKS 159 +#define X509V3_F_V2I_ISSUER_ALT 153 +#define X509V3_F_V2I_NAME_CONSTRAINTS 147 +#define X509V3_F_V2I_POLICY_CONSTRAINTS 146 +#define X509V3_F_V2I_POLICY_MAPPINGS 145 +#define X509V3_F_V2I_SUBJECT_ALT 154 +#define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL 160 +#define X509V3_F_V3_GENERIC_EXTENSION 116 +#define X509V3_F_X509V3_ADD1_I2D 140 +#define X509V3_F_X509V3_ADD_VALUE 105 +#define X509V3_F_X509V3_EXT_ADD 104 +#define X509V3_F_X509V3_EXT_ADD_ALIAS 106 +#define X509V3_F_X509V3_EXT_CONF 107 +#define X509V3_F_X509V3_EXT_I2D 136 +#define X509V3_F_X509V3_EXT_NCONF 152 +#define X509V3_F_X509V3_GET_SECTION 142 +#define X509V3_F_X509V3_GET_STRING 143 +#define X509V3_F_X509V3_GET_VALUE_BOOL 110 +#define X509V3_F_X509V3_PARSE_LIST 109 +#define X509V3_F_X509_PURPOSE_ADD 137 +#define X509V3_F_X509_PURPOSE_SET 141 + +/* Reason codes. */ +#define X509V3_R_BAD_IP_ADDRESS 118 +#define X509V3_R_BAD_OBJECT 119 +#define X509V3_R_BN_DEC2BN_ERROR 100 +#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 +#define X509V3_R_DIRNAME_ERROR 149 +#define X509V3_R_DUPLICATE_ZONE_ID 133 +#define X509V3_R_ERROR_CONVERTING_ZONE 131 +#define X509V3_R_ERROR_CREATING_EXTENSION 144 +#define X509V3_R_ERROR_IN_EXTENSION 128 +#define X509V3_R_EXPECTED_A_SECTION_NAME 137 +#define X509V3_R_EXTENSION_EXISTS 145 +#define X509V3_R_EXTENSION_NAME_ERROR 115 +#define X509V3_R_EXTENSION_NOT_FOUND 102 +#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 +#define X509V3_R_EXTENSION_VALUE_ERROR 116 +#define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 +#define X509V3_R_ILLEGAL_HEX_DIGIT 113 +#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 +#define X509V3_R_INVALID_ASNUMBER 160 +#define X509V3_R_INVALID_ASRANGE 161 +#define X509V3_R_INVALID_BOOLEAN_STRING 104 +#define X509V3_R_INVALID_EXTENSION_STRING 105 +#define X509V3_R_INVALID_INHERITANCE 162 +#define X509V3_R_INVALID_IPADDRESS 163 +#define X509V3_R_INVALID_NAME 106 +#define X509V3_R_INVALID_NULL_ARGUMENT 107 +#define X509V3_R_INVALID_NULL_NAME 108 +#define X509V3_R_INVALID_NULL_VALUE 109 +#define X509V3_R_INVALID_NUMBER 140 +#define X509V3_R_INVALID_NUMBERS 141 +#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 +#define X509V3_R_INVALID_OPTION 138 +#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 +#define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 +#define X509V3_R_INVALID_PURPOSE 146 +#define X509V3_R_INVALID_SAFI 164 +#define X509V3_R_INVALID_SECTION 135 +#define X509V3_R_INVALID_SYNTAX 143 +#define X509V3_R_ISSUER_DECODE_ERROR 126 +#define X509V3_R_MISSING_VALUE 124 +#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 +#define X509V3_R_NO_CONFIG_DATABASE 136 +#define X509V3_R_NO_ISSUER_CERTIFICATE 121 +#define X509V3_R_NO_ISSUER_DETAILS 127 +#define X509V3_R_NO_POLICY_IDENTIFIER 139 +#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 +#define X509V3_R_NO_PUBLIC_KEY 114 +#define X509V3_R_NO_SUBJECT_DETAILS 125 +#define X509V3_R_ODD_NUMBER_OF_DIGITS 112 +#define X509V3_R_OPERATION_NOT_DEFINED 148 +#define X509V3_R_OTHERNAME_ERROR 147 +#define X509V3_R_POLICY_LANGUAGE_ALREADTY_DEFINED 155 +#define X509V3_R_POLICY_PATH_LENGTH 156 +#define X509V3_R_POLICY_PATH_LENGTH_ALREADTY_DEFINED 157 +#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 158 +#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 +#define X509V3_R_SECTION_NOT_FOUND 150 +#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 +#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 +#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 +#define X509V3_R_UNKNOWN_EXTENSION 129 +#define X509V3_R_UNKNOWN_EXTENSION_NAME 130 +#define X509V3_R_UNKNOWN_OPTION 120 +#define X509V3_R_UNSUPPORTED_OPTION 117 +#define X509V3_R_USER_TOO_LONG 132 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/openssl/pc/lib/libeay32.lib b/libraries/external/openssl/pc/lib/libeay32.lib new file mode 100755 index 0000000..f9ac90f Binary files /dev/null and b/libraries/external/openssl/pc/lib/libeay32.lib differ diff --git a/libraries/external/openssl/pc/lib/ssleay32.lib b/libraries/external/openssl/pc/lib/ssleay32.lib new file mode 100755 index 0000000..d8536e7 Binary files /dev/null and b/libraries/external/openssl/pc/lib/ssleay32.lib differ diff --git a/libraries/external/openssl/pc/lib/vssver.scc b/libraries/external/openssl/pc/lib/vssver.scc new file mode 100755 index 0000000..f2cfd47 Binary files /dev/null and b/libraries/external/openssl/pc/lib/vssver.scc differ diff --git a/libraries/external/openssl/pc/openssl.cnf b/libraries/external/openssl/pc/openssl.cnf new file mode 100755 index 0000000..5018725 --- /dev/null +++ b/libraries/external/openssl/pc/openssl.cnf @@ -0,0 +1,313 @@ +# +# OpenSSL example configuration file. +# This is mostly being used for generation of certificate requests. +# + +# This definition stops the following lines choking if HOME isn't +# defined. +HOME = . +RANDFILE = $ENV::HOME/.rnd + +# Extra OBJECT IDENTIFIER info: +#oid_file = $ENV::HOME/.oid +oid_section = new_oids + +# To use this configuration file with the "-extfile" option of the +# "openssl x509" utility, name here the section containing the +# X.509v3 extensions to use: +# extensions = +# (Alternatively, use a configuration file that has only +# X.509v3 extensions in its main [= default] section.) + +[ new_oids ] + +# We can add new OIDs in here for use by 'ca' and 'req'. +# Add a simple OID like this: +# testoid1=1.2.3.4 +# Or use config file substitution like this: +# testoid2=${testoid1}.5.6 + +#################################################################### +[ ca ] +default_ca = CA_default # The default ca section + +#################################################################### +[ CA_default ] + +dir = ./demoCA # Where everything is kept +certs = $dir/certs # Where the issued certs are kept +crl_dir = $dir/crl # Where the issued crl are kept +database = $dir/index.txt # database index file. +#unique_subject = no # Set to 'no' to allow creation of + # several ctificates with same subject. +new_certs_dir = $dir/newcerts # default place for new certs. + +certificate = $dir/cacert.pem # The CA certificate +serial = $dir/serial # The current serial number +crlnumber = $dir/crlnumber # the current crl number + # must be commented out to leave a V1 CRL +crl = $dir/crl.pem # The current CRL +private_key = $dir/private/cakey.pem# The private key +RANDFILE = $dir/private/.rand # private random number file + +x509_extensions = usr_cert # The extentions to add to the cert + +# Comment out the following two lines for the "traditional" +# (and highly broken) format. +name_opt = ca_default # Subject Name options +cert_opt = ca_default # Certificate field options + +# Extension copying option: use with caution. +# copy_extensions = copy + +# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs +# so this is commented out by default to leave a V1 CRL. +# crlnumber must also be commented out to leave a V1 CRL. +# crl_extensions = crl_ext + +default_days = 365 # how long to certify for +default_crl_days= 30 # how long before next CRL +default_md = sha1 # which md to use. +preserve = no # keep passed DN ordering + +# A few difference way of specifying how similar the request should look +# For type CA, the listed attributes must be the same, and the optional +# and supplied fields are just that :-) +policy = policy_match + +# For the CA policy +[ policy_match ] +countryName = match +stateOrProvinceName = match +organizationName = match +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +# For the 'anything' policy +# At this point in time, you must list all acceptable 'object' +# types. +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +#################################################################### +[ req ] +default_bits = 1024 +default_keyfile = privkey.pem +distinguished_name = req_distinguished_name +attributes = req_attributes +x509_extensions = v3_ca # The extentions to add to the self signed cert + +# Passwords for private keys if not present they will be prompted for +# input_password = secret +# output_password = secret + +# This sets a mask for permitted string types. There are several options. +# default: PrintableString, T61String, BMPString. +# pkix : PrintableString, BMPString. +# utf8only: only UTF8Strings. +# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). +# MASK:XXXX a literal mask value. +# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings +# so use this option with caution! +string_mask = nombstr + +# req_extensions = v3_req # The extensions to add to a certificate request + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +countryName_default = AU +countryName_min = 2 +countryName_max = 2 + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State + +localityName = Locality Name (eg, city) + +0.organizationName = Organization Name (eg, company) +0.organizationName_default = Internet Widgits Pty Ltd + +# we can do this but it is not needed normally :-) +#1.organizationName = Second Organization Name (eg, company) +#1.organizationName_default = World Wide Web Pty Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +#organizationalUnitName_default = + +commonName = Common Name (eg, YOUR name) +commonName_max = 64 + +emailAddress = Email Address +emailAddress_max = 64 + +# SET-ex3 = SET extension number 3 + +[ req_attributes ] +challengePassword = A challenge password +challengePassword_min = 4 +challengePassword_max = 20 + +unstructuredName = An optional company name + +[ usr_cert ] + +# These extensions are added when 'ca' signs a request. + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +[ v3_req ] + +# Extensions to add to a certificate request + +basicConstraints = CA:FALSE +keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +[ v3_ca ] + + +# Extensions for a typical CA + + +# PKIX recommendation. + +subjectKeyIdentifier=hash + +authorityKeyIdentifier=keyid:always,issuer:always + +# This is what PKIX recommends but some broken software chokes on critical +# extensions. +#basicConstraints = critical,CA:true +# So we do this instead. +basicConstraints = CA:true + +# Key usage: this is typical for a CA certificate. However since it will +# prevent it being used as an test self-signed certificate it is best +# left out by default. +# keyUsage = cRLSign, keyCertSign + +# Some might want this also +# nsCertType = sslCA, emailCA + +# Include email address in subject alt name: another PKIX recommendation +# subjectAltName=email:copy +# Copy issuer details +# issuerAltName=issuer:copy + +# DER hex encoding of an extension: beware experts only! +# obj=DER:02:03 +# Where 'obj' is a standard or added object +# You can even override a supported extension: +# basicConstraints= critical, DER:30:03:01:01:FF + +[ crl_ext ] + +# CRL extensions. +# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL. + +# issuerAltName=issuer:copy +authorityKeyIdentifier=keyid:always,issuer:always + +[ proxy_cert_ext ] +# These extensions should be added when creating a proxy certificate + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer:always + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +# This really needs to be in place for it to be a proxy certificate. +proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo diff --git a/libraries/external/openssl/pc/ssl/openssl.cnf b/libraries/external/openssl/pc/ssl/openssl.cnf new file mode 100755 index 0000000..5018725 --- /dev/null +++ b/libraries/external/openssl/pc/ssl/openssl.cnf @@ -0,0 +1,313 @@ +# +# OpenSSL example configuration file. +# This is mostly being used for generation of certificate requests. +# + +# This definition stops the following lines choking if HOME isn't +# defined. +HOME = . +RANDFILE = $ENV::HOME/.rnd + +# Extra OBJECT IDENTIFIER info: +#oid_file = $ENV::HOME/.oid +oid_section = new_oids + +# To use this configuration file with the "-extfile" option of the +# "openssl x509" utility, name here the section containing the +# X.509v3 extensions to use: +# extensions = +# (Alternatively, use a configuration file that has only +# X.509v3 extensions in its main [= default] section.) + +[ new_oids ] + +# We can add new OIDs in here for use by 'ca' and 'req'. +# Add a simple OID like this: +# testoid1=1.2.3.4 +# Or use config file substitution like this: +# testoid2=${testoid1}.5.6 + +#################################################################### +[ ca ] +default_ca = CA_default # The default ca section + +#################################################################### +[ CA_default ] + +dir = ./demoCA # Where everything is kept +certs = $dir/certs # Where the issued certs are kept +crl_dir = $dir/crl # Where the issued crl are kept +database = $dir/index.txt # database index file. +#unique_subject = no # Set to 'no' to allow creation of + # several ctificates with same subject. +new_certs_dir = $dir/newcerts # default place for new certs. + +certificate = $dir/cacert.pem # The CA certificate +serial = $dir/serial # The current serial number +crlnumber = $dir/crlnumber # the current crl number + # must be commented out to leave a V1 CRL +crl = $dir/crl.pem # The current CRL +private_key = $dir/private/cakey.pem# The private key +RANDFILE = $dir/private/.rand # private random number file + +x509_extensions = usr_cert # The extentions to add to the cert + +# Comment out the following two lines for the "traditional" +# (and highly broken) format. +name_opt = ca_default # Subject Name options +cert_opt = ca_default # Certificate field options + +# Extension copying option: use with caution. +# copy_extensions = copy + +# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs +# so this is commented out by default to leave a V1 CRL. +# crlnumber must also be commented out to leave a V1 CRL. +# crl_extensions = crl_ext + +default_days = 365 # how long to certify for +default_crl_days= 30 # how long before next CRL +default_md = sha1 # which md to use. +preserve = no # keep passed DN ordering + +# A few difference way of specifying how similar the request should look +# For type CA, the listed attributes must be the same, and the optional +# and supplied fields are just that :-) +policy = policy_match + +# For the CA policy +[ policy_match ] +countryName = match +stateOrProvinceName = match +organizationName = match +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +# For the 'anything' policy +# At this point in time, you must list all acceptable 'object' +# types. +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +#################################################################### +[ req ] +default_bits = 1024 +default_keyfile = privkey.pem +distinguished_name = req_distinguished_name +attributes = req_attributes +x509_extensions = v3_ca # The extentions to add to the self signed cert + +# Passwords for private keys if not present they will be prompted for +# input_password = secret +# output_password = secret + +# This sets a mask for permitted string types. There are several options. +# default: PrintableString, T61String, BMPString. +# pkix : PrintableString, BMPString. +# utf8only: only UTF8Strings. +# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). +# MASK:XXXX a literal mask value. +# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings +# so use this option with caution! +string_mask = nombstr + +# req_extensions = v3_req # The extensions to add to a certificate request + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +countryName_default = AU +countryName_min = 2 +countryName_max = 2 + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State + +localityName = Locality Name (eg, city) + +0.organizationName = Organization Name (eg, company) +0.organizationName_default = Internet Widgits Pty Ltd + +# we can do this but it is not needed normally :-) +#1.organizationName = Second Organization Name (eg, company) +#1.organizationName_default = World Wide Web Pty Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +#organizationalUnitName_default = + +commonName = Common Name (eg, YOUR name) +commonName_max = 64 + +emailAddress = Email Address +emailAddress_max = 64 + +# SET-ex3 = SET extension number 3 + +[ req_attributes ] +challengePassword = A challenge password +challengePassword_min = 4 +challengePassword_max = 20 + +unstructuredName = An optional company name + +[ usr_cert ] + +# These extensions are added when 'ca' signs a request. + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +[ v3_req ] + +# Extensions to add to a certificate request + +basicConstraints = CA:FALSE +keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +[ v3_ca ] + + +# Extensions for a typical CA + + +# PKIX recommendation. + +subjectKeyIdentifier=hash + +authorityKeyIdentifier=keyid:always,issuer:always + +# This is what PKIX recommends but some broken software chokes on critical +# extensions. +#basicConstraints = critical,CA:true +# So we do this instead. +basicConstraints = CA:true + +# Key usage: this is typical for a CA certificate. However since it will +# prevent it being used as an test self-signed certificate it is best +# left out by default. +# keyUsage = cRLSign, keyCertSign + +# Some might want this also +# nsCertType = sslCA, emailCA + +# Include email address in subject alt name: another PKIX recommendation +# subjectAltName=email:copy +# Copy issuer details +# issuerAltName=issuer:copy + +# DER hex encoding of an extension: beware experts only! +# obj=DER:02:03 +# Where 'obj' is a standard or added object +# You can even override a supported extension: +# basicConstraints= critical, DER:30:03:01:01:FF + +[ crl_ext ] + +# CRL extensions. +# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL. + +# issuerAltName=issuer:copy +authorityKeyIdentifier=keyid:always,issuer:always + +[ proxy_cert_ext ] +# These extensions should be added when creating a proxy certificate + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer:always + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +# This really needs to be in place for it to be a proxy certificate. +proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo diff --git a/libraries/external/openssl/pc/ssl/vssver.scc b/libraries/external/openssl/pc/ssl/vssver.scc new file mode 100755 index 0000000..7cee5c6 Binary files /dev/null and b/libraries/external/openssl/pc/ssl/vssver.scc differ diff --git a/libraries/external/openssl/pc/vssver.scc b/libraries/external/openssl/pc/vssver.scc new file mode 100755 index 0000000..311def4 Binary files /dev/null and b/libraries/external/openssl/pc/vssver.scc differ diff --git a/libraries/external/openssl/vssver.scc b/libraries/external/openssl/vssver.scc new file mode 100755 index 0000000..0f456c9 Binary files /dev/null and b/libraries/external/openssl/vssver.scc differ diff --git a/libraries/external/physx/PhysX_2.8.1_SDK_Core.msi b/libraries/external/physx/PhysX_2.8.1_SDK_Core.msi new file mode 100755 index 0000000..0ede78b Binary files /dev/null and b/libraries/external/physx/PhysX_2.8.1_SDK_Core.msi differ diff --git a/libraries/external/physx/PhysX_8.04.25_SystemSoftware.exe b/libraries/external/physx/PhysX_8.04.25_SystemSoftware.exe new file mode 100755 index 0000000..f63b9ef Binary files /dev/null and b/libraries/external/physx/PhysX_8.04.25_SystemSoftware.exe differ diff --git a/libraries/external/physx/README.txt b/libraries/external/physx/README.txt new file mode 100755 index 0000000..6c6fe9d --- /dev/null +++ b/libraries/external/physx/README.txt @@ -0,0 +1,15 @@ +To install the SDK: +Run both PhysX_2.8.1_SDK_Core.msi and PhysX_8.04.25_SystemSoftware.exe + +(paths assume SDK installed in default location) +Includes copied from: +C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\Physics\include +C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\PhysXLoader\include +C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\Foundation\include +C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\Cooking\include + +Libraries copied from: +C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\SDKs\lib\Win32 + +DLLs copied from: +C:\Program Files\NVIDIA Corporation\NVIDIA PhysX SDK\v2.8.1\Bin\win32 \ No newline at end of file diff --git a/libraries/external/physx/Win32/Bin/NxCooking.dll b/libraries/external/physx/Win32/Bin/NxCooking.dll new file mode 100755 index 0000000..eca79d7 Binary files /dev/null and b/libraries/external/physx/Win32/Bin/NxCooking.dll differ diff --git a/libraries/external/physx/Win32/Bin/PhysXLoader.dll b/libraries/external/physx/Win32/Bin/PhysXLoader.dll new file mode 100755 index 0000000..15b4a56 Binary files /dev/null and b/libraries/external/physx/Win32/Bin/PhysXLoader.dll differ diff --git a/libraries/external/physx/Win32/Bin/vssver.scc b/libraries/external/physx/Win32/Bin/vssver.scc new file mode 100755 index 0000000..2e9d0ad Binary files /dev/null and b/libraries/external/physx/Win32/Bin/vssver.scc differ diff --git a/libraries/external/physx/Win32/include/PX/Nx.h b/libraries/external/physx/Win32/include/PX/Nx.h new file mode 100755 index 0000000..dba732a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/Nx.h @@ -0,0 +1,313 @@ +#ifndef NX_FOUNDATION_NX +#define NX_FOUNDATION_NX +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** \addtogroup foundation + @{ +*/ + +/** +DLL export macros +*/ +#ifndef NX_C_EXPORT + #define NX_C_EXPORT extern "C" +#endif + +#ifndef NX_CALL_CONV + #if defined WIN32 + #define NX_CALL_CONV __cdecl + #elif defined LINUX + #define NX_CALL_CONV + #elif defined __APPLE__ + #define NX_CALL_CONV + #elif defined __CELLOS_LV2__ + #define NX_CALL_CONV + #elif defined _XBOX + #define NX_CALL_CONV + #else + #error custom definition of NX_CALL_CONV for your OS needed! + #endif +#endif + +#if defined NX32 +#elif defined NX64 +#elif defined WIN32 + #ifdef NX64 + #error PhysX SDK: Platforms pointer size ambiguous! The defines WIN32 and NX64 are in conflict. + #endif + #define NX32 +#elif defined WIN64 + #ifdef NX32 + #error PhysX SDK: Platforms pointer size ambiguous! The defines WIN64 and NX32 are in conflict. + #endif + #define NX64 +#elif defined __CELLOS_LV2__ + #ifdef __LP32__ + #define NX32 + #else + #define NX64 + #endif +#elif defined _XBOX + #define NX32 +#elif defined LINUX + #define NX32 +#else + #error PhysX SDK: Platforms pointer size ambiguous. Please define NX32 or Nx64 in the compiler settings! +#endif + + +#if !defined __CELLOS_LV2__ + #define NX_COMPILE_TIME_ASSERT(exp) extern char NX_CompileTimeAssert[ size_t((exp) ? 1 : -1) ] +#else + // GCC4 don't like the line above + #define _CELL_NX_COMPILE_TIME_NAME_(x) NX_CompileTimeAssert ## x + #define _CELL_NX_COMPILE_TIME_NAME(x) _CELL_NX_COMPILE_TIME_NAME_(x) + #define NX_COMPILE_TIME_ASSERT(exp) extern char _CELL_NX_COMPILE_TIME_NAME(__LINE__)[ (exp) ? 1 : -1] +#endif + + +#if _MSC_VER + #define NX_MSVC // Compiling with VC++ + #if _MSC_VER >= 1400 + #define NX_VC8 + #elif _MSC_VER >= 1300 + #define NX_VC7 // Compiling with VC7 + #else + #define NX_VC6 // Compiling with VC6 + #define __FUNCTION__ "Undefined" + #endif +#endif + +/** + Nx SDK misc defines. +*/ + +//NX_INLINE +#if (_MSC_VER>=1000) + #define NX_INLINE __forceinline //alternative is simple inline + #pragma inline_depth( 255 ) + + #include + #include + #pragma intrinsic(memcmp) + #pragma intrinsic(memcpy) + #pragma intrinsic(memset) + #pragma intrinsic(strcat) + #pragma intrinsic(strcmp) + #pragma intrinsic(strcpy) + #pragma intrinsic(strlen) + #pragma intrinsic(abs) + #pragma intrinsic(labs) +#elif defined(__MWERKS__) + //optional: #pragma always_inline on + #define NX_INLINE inline +#else + #define NX_INLINE inline +#endif + + #define NX_DELETE(x) delete x + #define NX_DELETE_SINGLE(x) if (x) { delete x; x = NULL; } + #define NX_DELETE_ARRAY(x) if (x) { delete []x; x = NULL; } + + template NX_INLINE void NX_Swap(Type& a, Type& b) + { + const Type c = a; a = b; b = c; + } + +/** +\brief Error codes + +These error codes are passed to #NxUserOutputStream + +@see NxUserOutputStream +*/ + +enum NxErrorCode + { + /** + \brief no error + */ + NXE_NO_ERROR = 0, + /** + \brief method called with invalid parameter(s) + */ + NXE_INVALID_PARAMETER = 1, + /** + \brief method was called at a time when an operation is not possible + */ + NXE_INVALID_OPERATION = 2, + /** + \brief method failed to allocate some memory + */ + NXE_OUT_OF_MEMORY = 3, + /** + \brief The library failed for some reason. + + Usually because you have passed invalid values like NaNs into the system, which are not checked for. + */ + NXE_INTERNAL_ERROR = 4, + + /** + \brief an assertion failed. + */ + NXE_ASSERTION = 107, + + /** + \brief An informational message. + + Only emitted when NX_USER_DEBUG_MODE is defined. + */ + NXE_DB_INFO = 205, + /** + \brief a warning message for the user to help with debugging + + Only emitted when NX_USER_DEBUG_MODE is defined. + */ + NXE_DB_WARNING = 206, + /** + \brief the message should simply be printed without any additional infos (line number, etc). + + Only emitted when NX_USER_DEBUG_MODE is defined. + */ + NXE_DB_PRINT = 208 + + }; + +/** +\brief These errors are returned by the NxCreatePhysicsSDK() function +*/ +enum NxSDKCreateError + { + /** + \brief No errors occurred when creating the Physics SDK. + */ + NXCE_NO_ERROR = 0, + + /** + \brief Unable to find the PhysX libraries. The PhysX drivers are not installed correctly. + */ + NXCE_PHYSX_NOT_FOUND = 1, + + //wrong version of the SDK is being used + /** + \brief The application supplied a version number that does not match with the libraries. + */ + NXCE_WRONG_VERSION = 2, + + /** + \brief The supplied SDK descriptor is invalid. + */ + NXCE_DESCRIPTOR_INVALID = 3, + + /** + \brief A PhysX card was found, but there are problems when communicating with the card. + */ + NXCE_CONNECTION_ERROR = 4, + + /** + \brief A PhysX card was found, but it did not reset (or initialize) properly. + */ + NXCE_RESET_ERROR = 5, + + /** + \brief A PhysX card was found, but it is already in use by another application. + */ + NXCE_IN_USE_ERROR = 6, + + /** + \brief A PhysX card was found, but there are issues with loading the firmware. + */ + NXCE_BUNDLE_ERROR = 7 + + }; + +#if _MSC_VER +//get rid of browser info warnings +#pragma warning( disable : 4786 ) //identifier was truncated to '255' characters in the debug information +#pragma warning( disable : 4251 ) //class needs to have dll-interface to be used by clients of class +#endif + +//files to always include: +#ifdef LINUX +#include +#include +#include +#elif __APPLE__ +#include +#elif __CELLOS_LV2__ + #include +#endif +#include "PX/NxSimpleTypes.h" +#include "PX/NxAssert.h" + +#define NX_SIGN_BITMASK 0x80000000 + +#define NX_DEBUG_MALLOC 0 + +// Don't use inline for alloca !!! +#ifdef WIN32 + #include + #define NxAlloca(x) _alloca(x) +#elif LINUX + #include + #define NxAlloca(x) alloca(x) +#elif __APPLE__ + #include + #include + #define NxAlloca(x) alloca(x) +#elif __CELLOS_LV2__ + #include + #include + #define NxAlloca(x) alloca(x) +#elif _XBOX + #include + #define NxAlloca(x) _alloca(x) +#endif + +/** +\brief Used to specify a thread priority. +*/ +enum NxThreadPriority +{ + /** + \brief High priority + */ + NX_TP_HIGH =0, + + /** + \brief Above Normal priority + */ + NX_TP_ABOVE_NORMAL =1, + + /** + \brief Normal/default priority + */ + NX_TP_NORMAL =2, + + /** + \brief Below Normal priority + */ + NX_TP_BELOW_NORMAL =3, + + /** + \brief Low priority. + */ + NX_TP_LOW =4, + + NX_TP_FORCE_DWORD = 0xffFFffFF +}; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/Nx12F32.h b/libraries/external/physx/Win32/include/PX/Nx12F32.h new file mode 100755 index 0000000..63243ce --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/Nx12F32.h @@ -0,0 +1,43 @@ +#ifndef NX_FOUNDATION_NX12F32 +#define NX_FOUNDATION_NX12F32 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ +//Exclude file from docs +/** \cond */ + +//the file name of this header is legacy due to pain of renaming file in repository. + +#include "PX/Nxf.h" + +class Nx12Real + { + public: + union + { + struct S + { + NxReal _11, _12, _13, _14; + NxReal _21, _22, _23, _24; + NxReal _31, _32, _33, _34; + } s; + NxReal m[3][4]; + }; + }; + +/** \endcond */ + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/Nx16F32.h b/libraries/external/physx/Win32/include/PX/Nx16F32.h new file mode 100755 index 0000000..af07d42 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/Nx16F32.h @@ -0,0 +1,44 @@ +#ifndef NX_FOUNDATION_NX16F32 +#define NX_FOUNDATION_NX16F32 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ +//Exclude file from docs +/** \cond */ + +//the file name of this header is legacy due to pain of renaming file in repository. + +#include "PX/Nx.h" + +class Nx16Real + { + public: + union + { + struct S + { + NxReal _11, _12, _13, _14; + NxReal _21, _22, _23, _24; + NxReal _31, _32, _33, _34; + NxReal _41, _42, _43, _44; + } s; + NxReal m[4][4]; + }; + }; + +/** \endcond */ + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/Nx9F32.h b/libraries/external/physx/Win32/include/PX/Nx9F32.h new file mode 100755 index 0000000..86019f7 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/Nx9F32.h @@ -0,0 +1,53 @@ +#ifndef NX_FOUNDATION_NX9F32 +#define NX_FOUNDATION_NX9F32 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +//Exclude file from docs +/** \cond */ + +#include "PX/Nxf.h" + +//the file name of this header is legacy due to pain of renaming file in repository. + +class Nx9Real + { + + public: + struct S + { +#ifndef TRANSPOSED_MAT33 + NxReal _11, _12, _13; + NxReal _21, _22, _23; + NxReal _31, _32, _33; +#else + NxReal _11, _21, _31; + NxReal _12, _22, _32; + NxReal _13, _23, _33; +#endif + }; + + union + { + S s; + NxReal m[3][3]; + }; + }; + +/** \endcond */ + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxActor.h b/libraries/external/physx/Win32/include/PX/NxActor.h new file mode 100755 index 0000000..e0beede --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxActor.h @@ -0,0 +1,2363 @@ +#ifndef NX_PHYSICS_NX_ACTOR +#define NX_PHYSICS_NX_ACTOR +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxArray.h" +#include "PX/NxBounds3.h" +#include "PX/NxActorDesc.h" +#include "PX/NxPhysicsSDK.h" +#include "PX/NxUserEntityReport.h" + +class NxBodyDesc; +class NxShapeDesc; +class NxJoint; +class NxShape; + +#if NX_SUPPORT_SWEEP_API + struct NxSweepQueryHit; + + class NxSweepCache + { + protected: + NxSweepCache() {} + virtual ~NxSweepCache() {} + public: + virtual void setVolume(const NxBox& box) = 0; + }; +#endif + +/** +\brief NxActor is the main simulation object in the physics SDK. + +The actor is owned by and contained in a NxScene. + +An actor may optionally encapsulate a dynamic rigid body by setting the body member of the +actor's descriptor when it is created. Otherwise the actor will be static (fixed in the world). + +

Creation

+Instances of this class are created by calling #NxScene::createActor() and deleted with #NxScene::releaseActor(). + +See #NxActorDescBase for a more detailed description of the parameters which can be set when creating an actor. + +Example (Static Actor): + +\include NxActor_CreateStatic.cpp + +Example (Dynamic Actor): + +\include NxActor_CreateDynamic.cpp + +

Visualizations

+\li #NX_VISUALIZE_ACTOR_AXES +\li #NX_VISUALIZE_BODY_AXES +\li #NX_VISUALIZE_BODY_MASS_AXES +\li #NX_VISUALIZE_BODY_LIN_VELOCITY +\li #NX_VISUALIZE_BODY_ANG_VELOCITY +\li #NX_VISUALIZE_BODY_JOINT_GROUPS + + +@see NxActorDesc NxBodyDesc NxScene.createActor() NxScene.releaseActor() +*/ + +class NxActor + { + protected: + NX_INLINE NxActor() : userData(NULL) + {} + virtual ~NxActor() {} + + public: + /** + \brief Retrieves the scene which this actor belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + // Runtime modifications + + /** + \brief Saves the state of the actor to the passed descriptor. + + This method does not save out any shapes belonging to the actor to the descriptor's + shape vector, nor does it write to its body member. You have to iterate through + the shapes of the actor and save them manually. In addition for dynamic actors you + have to call the #saveBodyToDesc() method. + + \param[out] desc Descriptor to save object state to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActorDesc NxActorDescBase + */ + virtual void saveToDesc(NxActorDescBase& desc) = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, + only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName(const char* name) = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return Name string associated with object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName() const = 0; + +/************************************************************************************************/ +/** @name Global Pose Manipulation +*/ +//@{ + + /** + \brief Methods for setting a dynamic actor's pose in the world. + + These methods instantaneously change the actor space to world space transformation. + + One should exercise restraint in making use of these methods. + + Static actors should not be moved at all. There are various internal data structures for static actors + which may need to be recomputed when one moves. Also, moving static actors will not interact correctly + with dynamic actors or joints. If you would like to directly control an actor's position and would like to + have it correctly interact with dynamic bodies and joints, you should create a dynamic body with the + NX_BF_KINEMATIC flag, and then use the moveGlobal*() commands to move it along a path! + + When briefly moving dynamic actors, one should not: + + \li Move actors into other actors, thus causing interpenetration (an invalid physical state) + + \li Move an actor that is connected by a joint to another away from the other (thus causing joint error) + + \li When moving jointed actors the joints' cached transform information is destroyed and recreated next frame; + thus this call is expensive for jointed actors. + + setGlobalPose(m) has the same effect as calling + setGlobalOrientation(m.M); and setGlobalPosition(m.t); + but setGlobalPose() may be faster as it doesn't recompute some internal values twice. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Transformation from the actors local frame to the global frame. Range: rigid body transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGlobalPose() setGlobalPosition() setGlobalOrientation() getGlobalPose() + */ + virtual void setGlobalPose(const NxMat34& mat) = 0; + + /** + \brief Sets a dynamic actor's position in the world. + + see ::setGlobalPose() for information. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] vec New position for the actors frame relative to the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalPose() setGlobalOrientation() getGlobalPosition() + */ + virtual void setGlobalPosition(const NxVec3& vec) = 0; + + /** + \brief Sets a dynamic actor's orientation in the world. + + see ::setGlobalPose() for information. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat New orientation for the actors frame. Range: rotation matrix. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalPose() setGlobalPosition() getGlobalOrientation() setGlobalOrientationQuat() + */ + virtual void setGlobalOrientation(const NxMat33& mat) = 0; + + /** + \brief Sets a dynamic actor's orientation in the world. + + see ::setGlobalPose() for information. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat New orientation for the actors frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalOrientation() getGlobalOrientation() setGlobalPose() + */ + virtual void setGlobalOrientationQuat(const NxQuat& mat) = 0; + + /** + \brief Retrieves the actors world space transform. + + The getGlobal*() methods retrieve the actor's current actor space to world space transformation. + + \return Global pose matrix of object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalPose() getGlobalPosition() getGlobalOrientation() + */ + virtual NxMat34 getGlobalPose() const = 0; + + /** + \brief Retrieves the actors world space position. + + The getGlobal*() methods retrieve the actor's current actor space to world space transformation. + + \return Global position of object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalPosition() getGlobalPose() getGlobalOrientation() + */ + virtual NxVec3 getGlobalPosition() const = 0; + + /** + \brief Retrieves the actors world space orientation. + + The getGlobal*() methods retrieve the actor's current actor space to world space transformation. + + \return Global orientation of object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGlobalOrientationQuat() setGlobalOrientation() getGlobalPose() getGlobalPosition() + */ + virtual NxMat33 getGlobalOrientation() const = 0; + + /** + \brief Retrieves the actors world space orientation. + + The getGlobal*() methods retrieve the actor's current actor space to world space transformation. + + \return Global orientation of the actor as a quaternion. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGlobalOrientation() setGlobalOrientation() getGlobalPose() getGlobalPosition() + */ + virtual NxQuat getGlobalOrientationQuat()const = 0; + +/************************************************************************************************/ +//@} + +/** @name Kinematic Actors +*/ +//@{ + + /** + \brief The moveGlobal* calls serve to move kinematically controlled dynamic actors through the game world. + + You set a dynamic actor to be kinematic using the NX_BF_KINEMATIC body flag, + used either in the NxBodyDesc or with raiseBodyFlag(). + + The move command will result in a velocity that, when successfully carried + out (i.e. the motion is not blocked due to joints or collisions) inside run*(), + will move the body into the desired pose. After the move is carried out during + a single time step, the velocity is returned to zero. Thus, you must + continuously call this in every time step for kinematic actors so that they + move along a path. + + These functions simply store the move destination until run*() is called, + so consecutive calls will simply overwrite the stored target variable. + + Note that in the future we will provide a mechanism for the motion to be blocked + in certain cases (such as when a box jams in an automatic door), but currently + the motion is always fully carried out. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat The desired pose for the kinematic actor, in the global frame. Range: rigid body transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see moveGlobalPosition() moveGlobalOrientation() moveGlobalOrientationQuat() NxBodyFlag raiseBodyFlag() NxBodyDesc.flags + */ + virtual void moveGlobalPose(const NxMat34& mat) = 0; + + /** + \brief The moveGlobal* calls serve to move kinematically controlled dynamic actors through the game world. + + See ::moveGlobalPose() for more information. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] vec The desired position for the kinematic actor, in the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see moveGlobalPose() moveGlobalOrientation() moveGlobalOrientationQuat() NxBodyFlag raiseBodyFlag() NxBodyDesc.flags + */ + virtual void moveGlobalPosition(const NxVec3& vec) = 0; + + /** + \brief The moveGlobal* calls serve to move kinematically controlled dynamic actors through the game world. + + See ::moveGlobalPose() for more information. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat The desired orientation for the kinematic actor, in the global frame. Range: rotation matrix. + + \note Although it is possible to only specify the orientation, it might be needed to also specify the body position, using moveGlobalPosition(). + If you don't do this, the actor position can start to drift, because of numerical imprecision. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see moveGlobalOrientationQuat() moveGlobalPosition() moveGlobalPose() NxBodyFlag raiseBodyFlag() NxBodyDesc.flags + */ + virtual void moveGlobalOrientation(const NxMat33& mat) = 0; + + /** + \brief The moveGlobal* calls serve to move kinematically controlled dynamic actors through the game world. + + See ::moveGlobalPose() for more information. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] quat The desired orientation quaternion for the kinematic actor, in the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see moveGlobalPosition() moveGlobalPose() NxBodyFlag raiseBodyFlag() NxBodyDesc.flags + */ + virtual void moveGlobalOrientationQuat(const NxQuat& quat) = 0; + +/************************************************************************************************/ +//@} + +/** @name Shapes +*/ +//@{ + + /** + \brief Creates a new shape and adds it to the list of shapes of this actor. + + This invalidates the pointer returned by getShapes(). + + \note Mass properties of dynamic actors will not automatically be recomputed + to reflect the new mass distribution implied by the shape. Follow + this call with a call to updateMassFromShapes() to do that. + + \note Creating compounds with a very large number of shapes may adversly affect performance and stability. + When performing collision tests between a pair of actors containing multiple shapes, a collision check is + performed between each pair of shapes. This results in N^2 running time. + + Sleeping: Does NOT wake the actor up automatically. + + Only a subset of the shape types are supported in hardware scenes (others will fall back to running in software):- + + Fluids: + + \li Compounds are supported + \li #NxBoxShape + \li #NxCapsuleShape + \li #NxSphereShape + \li #NxConvexShape + + Hardware Rigid bodies: + + \li Compounds are supported + \li #NxBoxShape + \li #NxSphereShape + \li #NxCapsuleShape + \li #NxConvexShape (software fallback for > 32 vertices or faces) + \li #NxTriangleMeshShape + \li #NxPlaneShape + + In addition mesh pages must be mapped into PPU memory for hardware scenes. No collision detection will be performed + with portions of the mesh which have not been mapped to PPU memory. See #NxTriangleMeshShape.mapPageInstance() + + \param[in] desc The descriptor for the new shape. See e.g. #NxSphereShapeDesc. + \return The newly create shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback in some cases) + \li PS3 : Yes + \li XB360: Yes + + @see NxShape NxShapeDesc + @see NxBoxShape NxCapsuleShape NxConvexShape NxPlaneShape NxSphereShape NxTriangleMeshShape NxWheelShape + */ + virtual NxShape* createShape(const NxShapeDesc& desc) = 0; + + /** + \brief Deletes the specified shape. + + This invalidates the pointer returned by getShapes(). + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + Note that mass properties for the actor are unchanged by this call unless #updateMassFromShapes is also called. + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] shape Shape to be released. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape + @see NxBoxShape NxCapsuleShape NxConvexShape NxPlaneShape NxSphereShape NxTriangleMeshShape NxWheelShape + */ + virtual void releaseShape(NxShape& shape) = 0; + + /** + \brief Returns the number of shapes assigned to the actor. + + You can use #getShapes() to retrieve an array of shape pointers. + + For static actors it is not possible to release all actors associated with the shape. + An attempt to remove the last shape will be ignored. + + \return Number of shapes associated with this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape getShapes() + */ + virtual NxU32 getNbShapes() const = 0; + + + /** + \brief Returns an array of shape pointers belonging to the actor. + + These are the shapes used by the actor for collision detection. + + You can retrieve the number of shape pointers by calling #getNbShapes() + + Note: Adding or removing shapes with #createShape() or #releaseShape() will invalidate the pointer. + + \return Array of shapes which are associated with this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape getNbShapes() createShape() releaseShape() + */ + virtual NxShape*const * getShapes() const = 0; + +/************************************************************************************************/ +//@} + + /** + \brief Assigns the actor to a user defined group of actors. + + NxActorGroup is a 16 bit group identifier. + + This is similar to #NxShape groups, except those are only five bits and serve a different purpose. + + The NxScene::setActorGroupPairFlags() lets you set certain behaviors for pairs of actor groups. + By default every actor is created in group 0. + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] actorGroup The actor group flags. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see getGroup() NxActorGroup + */ + virtual void setGroup(NxActorGroup actorGroup) = 0; + + /** + \brief Retrieves the value set with setGroup(). + + \return The group ID of this actor. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see setGroup() NxActorGroup + */ + virtual NxActorGroup getGroup() const = 0; + + + /** + \brief Assigns dynamic actors a dominance group identifier. + + NxDominanceGroup is a 5 bit group identifier (legal range from 0 to 31). + + This is similar to #NxShape groups, except those serve a different purpose. + + The NxScene::setDominanceGroupPair() lets you set certain behaviors for pairs of dominance groups. + By default every actor is created in group 0. Static actors must stay in group 0; thus you can only + call this on dynamic actors. + + Sleeping: Changing the dominance group does NOT wake the actor up automatically. + + @see getDominanceGroup() NxDominanceGroup NxScene::setDominanceGroupPair() + */ + virtual void setDominanceGroup(NxDominanceGroup dominanceGroup) = 0; + + + /** + \brief Retrieves the value set with setDominanceGroup(). + + \return The dominance group of this actor. + + @see setDominanceGroup() NxDominanceGroup NxScene::setDominanceGroupPair() + */ + virtual NxDominanceGroup getDominanceGroup() const = 0; + + + /** + \brief Raises a particular actor flag. + + See the list of flags #NxActorFlag + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] actorFlag The actor flag to raise(set). See #NxActorFlag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActorFlag clearActorFlag() readActorFlag() NxActorDesc.flags + */ + virtual void raiseActorFlag(NxActorFlag actorFlag) = 0; + + /** + \brief Clears a particular actor flag. + + See the list of flags #NxActorFlag + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] actorFlag The actor flag to clear. See #NxActorFlag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActorFlag raiseActorFlag() readActorFlag() NxActorDesc.flags + */ + virtual void clearActorFlag(NxActorFlag actorFlag) = 0; + + /** + \brief Reads a particular actor flag. + + See the list of flags #NxActorFlag + + \param[in] actorFlag The actor flag to retrieve. See #NxActorFlag. + + \return The value of the actor flag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActorFlag raiseActorFlag() clearActorFlag() NxActorDesc.flags + */ + virtual bool readActorFlag(NxActorFlag actorFlag) const = 0; + + /** + \brief Reset the user actor pair filtering state for this actor. This will cause filtering + callbacks to be called again for any pairs involving this actor. Use this method + when you wish to change the filtering policy of an actor that may already be in contact + with other actors. + + @see NxUserActorPairFiltering + */ + virtual void resetUserActorPairFiltering() = 0; + + + /** + \brief Returns true if the actor is dynamic. + + \return True if this is a dynamic actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc + */ + virtual bool isDynamic() const = 0; + +/************************************************************************************************/ + +/** @name Mass Manipulation +*/ +//@{ + + /** + \brief The setCMassOffsetLocal*() methods set the pose of the center of mass relative to the actor. + + Methods that automatically compute the center of mass such as updateMassFromShapes() as well as computing + the mass and inertia using the actors shapes, will set this pose automatically. + + The actor must be dynamic. + + \note Changing this transform will not move the actor in the world! + + \note Setting an unrealistic center of mass which is a long way from the body can make it difficult for + the SDK to solve constraints. Perhaps leading to instability and jittering bodies. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Mass frame offset transform relative to the actor frame. Range: rigid body transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassOffsetLocalPosition() setCMassOffsetLocalOrientation() setCMassOffsetGlobalPose() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassOffsetLocalPose(const NxMat34& mat) = 0; + + /** + \brief The setCMassOffsetLocal*() methods set the pose of the center of mass relative to the actor. + + See ::setCMassOffsetLocalPose() for more information. + + \note Setting an unrealistic center of mass which is a long way from the body can make it difficult for + the SDK to solve constraints. Perhaps leading to instability and jittering bodies. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] vec Mass frame offset relative to the actor frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassOffsetLocalPose() setCMassOffsetLocalOrientation() setCMassOffsetGlobalPose() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassOffsetLocalPosition(const NxVec3& vec) = 0; + + /** + \brief The setCMassOffsetLocal*() methods set the pose of the center of mass relative to the actor. + + See ::setCMassOffsetLocalPose() for more information. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Mass frame orientation offset relative to the actor frame. Range: rotation matrix. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassOffsetLocalPose() setCMassOffsetLocalPosition() setCMassOffsetGlobalPose() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassOffsetLocalOrientation(const NxMat33& mat) = 0; + + /** + \brief The setCMassOffsetGlobal*() methods set the pose of the center of mass relative to world space. + + Note that this will simply transform the parameter to actor space and then call + setCMassLocal*(). In other words it only shifts the center of mass but does not move the actor. + + The actor must be dynamic. + + \note Setting an unrealistic center of mass which is a long way from the body can make it difficult for + the SDK to solve constraints. Perhaps leading to instability and jittering bodies. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Mass frame offset transform relative to the global frame. Range: rigid body transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassOffsetGlobalPosition() setCMassOffsetGlobalOrientation() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassOffsetGlobalPose(const NxMat34& mat) = 0; + + /** + \brief The setCMassOffsetGlobal*() methods set the pose of the center of mass relative to world space. + + See ::setCMassOffsetGlobalPose() for more information. + + \note Setting an unrealistic center of mass which is a long way from the body can make it difficult for + the SDK to solve constraints. Perhaps leading to instability and jittering bodies. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] vec Mass frame offset relative to the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassOffsetGlobalPose() setCMassOffsetGlobalOrientation() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassOffsetGlobalPosition(const NxVec3& vec) = 0; + + /** + \brief The setCMassOffsetGlobal*() methods set the pose of the center of mass relative to world space. + + See ::setCMassOffsetGlobalPose() for more information. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Mass frame orientation offset relative to the global frame. Range: rotation matrix. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassOffsetGlobalPose() setCMassOffsetGlobalPosition() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassOffsetGlobalOrientation(const NxMat33& mat) = 0; + + /** + \brief The setCMassGlobal*() methods move the actor by setting the pose of the center of mass. + + Here the transform between the center of mass and the actor frame is held fixed and the actor + to world transform is updated. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Actors new pose, from the transformation of the mass frame to the global frame. Range: rigid body transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassGlobalPosition() setCMassGlobalOrientation() getCMassLocalPose() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassGlobalPose(const NxMat34& mat) = 0; + + /** + \brief The setCMassGlobal*() methods move the actor by setting the pose of the center of mass. + + See ::setCMassGlobalPose() for more information. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] vec Actors new position, from the transformation of the mass frame to the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassGlobalPose() setCMassGlobalOrientation() getCMassLocalPose() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassGlobalPosition(const NxVec3& vec) = 0; + + /** + \brief The setCMassGlobal*() methods move the actor by setting the pose of the center of mass. + + See ::setCMassGlobalPose() for more information. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] mat Actors new orientation, from the transformation of the mass frame to the global frame. Range: rotation matrix. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCMassGlobalPose() setCMassGlobalPosition() getCMassLocalPose() + @see NxBodyDesc.massLocalPose + */ + virtual void setCMassGlobalOrientation(const NxMat33& mat) = 0; + + /** + \brief The getCMassLocal*() methods retrieve the center of mass pose relative to the actor. + + The actor must be dynamic. + + \return The center of mass pose relative to the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCMassLocalPosition() getCMassLocalOrientation() getCMassGlobalPose() + @see NxBodyDesc.massLocalPose + */ + virtual NxMat34 getCMassLocalPose() const = 0; + + /** + \brief The getCMassLocal*() methods retrieve the center of mass pose relative to the actor. + + The actor must be dynamic. + + \return The center of mass position relative to the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCMassLocalPose() getCMassLocalOrientation() getCMassGlobalPose() + @see NxBodyDesc.massLocalPose + */ + virtual NxVec3 getCMassLocalPosition() const = 0; + + /** + \brief The getCMassLocal*() methods retrieve the center of mass pose relative to the actor. + + The actor must be dynamic. + + \return The mass orientation relative to the actors frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCMassLocalPose() getCMassLocalPosition() getCMassGlobalPose() + @see NxBodyDesc.massLocalPose + */ + virtual NxMat33 getCMassLocalOrientation() const = 0; + + /** + \brief The getCMassGlobal*() methods retrieve the center of mass pose in world space. + + The actor must be dynamic. + + \return The Mass transform for this actor relative to the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCMassGlobalPosition() getCMassGlobalOrientation() getCMassLocalPose() + @see NxBodyDesc.massLocalPose + */ + virtual NxMat34 getCMassGlobalPose() const = 0; + + /** + \brief The getCMassGlobal*() methods retrieve the center of mass pose in world space. + + The actor must be dynamic. + + \return The position of the center of mass relative to the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCMassGlobalPose() getCMassGlobalOrientation() getCMassLocalPose() + @see NxBodyDesc.massLocalPose + */ + virtual NxVec3 getCMassGlobalPosition() const = 0; + + /** + \brief The getCMassGlobal*() methods retrieve the center of mass pose in world space. + + The actor must be dynamic. + + \return The orientation of the mass frame relative to the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCMassGlobalPose() getCMassGlobalPosition() getCMassLocalPose() + @see NxBodyDesc.massLocalPose + */ + virtual NxMat33 getCMassGlobalOrientation() const = 0; + + /** + \brief Sets the mass of a dynamic actor. + + The mass must be positive and the actor must be dynamic. + + setMass() does not update the inertial properties of the body, to change the inertia tensor + use setMassSpaceInertiaTensor() or updateMassFromShapes(). + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] mass New mass value for the actor. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getMass() NxBodyDesc.mass setMassSpaceInertiaTensor() updateMassFromShapes() + */ + virtual void setMass(NxReal mass) = 0; + + /** + \brief Retrieves the mass of the actor. + + Static actors will always return 0. + + \return The mass of this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setMass() NxBodyDesc.mass setMassSpaceInertiaTensor() + */ + virtual NxReal getMass() const = 0; + + /** + \brief Sets the inertia tensor, using a parameter specified in mass space coordinates. + + Note that such matrices are diagonal -- the passed vector is the diagonal. + + If you have a non diagonal world/actor space inertia tensor(3x3 matrix). Then you need to + diagonalize it and set an appropriate mass space transform. See #setCMassOffsetLocalPose(). + + The actor must be dynamic. + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] m New mass space inertia tensor for the actor. Range: inertia vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc.massSpaceInertia getMassSpaceInertia() setMass() setCMassOffsetLocalPose() + */ + virtual void setMassSpaceInertiaTensor(const NxVec3& m) = 0; + + /** + \brief Retrieves the diagonal inertia tensor of the actor relative to the mass coordinate frame. + + This method retrieves a mass frame inertia vector. If you want a global frame inertia tensor(3x3 matrix), + then see #getGlobalInertiaTensor(). + + The actor must be dynamic. + + \return The mass space inertia tensor of this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() setMass() CMassOffsetLocalPose() + */ + virtual NxVec3 getMassSpaceInertiaTensor() const = 0; + + /** + \brief Retrieves the inertia tensor of the actor relative to the world coordinate frame. + + The actor must be dynamic. + + \return The global frame inertia tensor of this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGlobalInertiaTensorInverse() NxBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() + */ + virtual NxMat33 getGlobalInertiaTensor() const = 0; + + /** + \brief Retrieves the inverse of the inertia tensor of the actor relative to the world coordinate frame. + + The actor must be dynamic. + + \return The inverse of the inertia tensor in the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGlobalInertiaTensor() NxBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() + */ + virtual NxMat33 getGlobalInertiaTensorInverse() const = 0; + + /** + \brief Recomputes a dynamic actor's mass properties from its shapes + + Given a constant density or total mass, the actors mass properties can be recomputed + using the shapes attached to the actor. If the actor has no shapes, then only the totalMass + parameter can be used. If all shapes in the actor are trigger shapes (non-physical), the call + will fail. + + The mass of each shape is either the shape's local density (as specified in the #NxShapeDesc; default 1.0) + multiplied by the shape's volume or a directly specified shape mass. + + The inertia tensor, mass frame and center of mass will always be recomputed. If there are no + shapes in the actor, the mass will be totalMass, and the mass frame will be set to the center + of the actor. + + If you supply a non-zero total mass, the actor's mass and inertia will first be computed as + above and then scaled to fit this total mass. + + If you supply a non-zero density, the actor's mass and inertia will first be computed as above + and then scaled by this factor. + + Either totalMass or density must be non-zero. + + The actor must be dynamic. + + \param[in] density Density scale factor of the shapes belonging to the actor. Range: [0,inf) + \param[in] totalMass Total mass of the actor(or zero). Range: [0,inf) + + \return True if successful. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActorDesc NxBodyDesc NxBodyDesc.mass NxActorDesc.density NxActorDesc.lockCOM + */ + virtual bool updateMassFromShapes(NxReal density, NxReal totalMass) = 0; + +//@} +/************************************************************************************************/ +/** @name Damping +*/ +//@{ + + /** + \brief Sets the linear damping coefficient. + + Zero represents no damping. The damping coefficient must be nonnegative. + + The actor must be dynamic. + + Default: 0. + + \param[in] linDamp Linear damping coefficient. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLinearDamping() setAngularDamping() NxBodyDesc.linearDamping + */ + virtual void setLinearDamping(NxReal linDamp) = 0; + + /** + \brief Retrieves the linear damping coefficient. + + The actor must be dynamic. + + \return The linear damping coefficient associated with this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLinearDamping() getAngularDamping() NxBodyDesc.linearDamping + */ + virtual NxReal getLinearDamping() const = 0; + + /** + \brief Sets the angular damping coefficient. + + Zero represents no damping. + + The angular damping coefficient must be nonnegative. + + The actor must be dynamic. + + Default: 0.05 + + \param[in] angDamp Angular damping coefficient. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getAngularDamping() NxBodyDesc.angularDamping setLinearDamping() + */ + virtual void setAngularDamping(NxReal angDamp) = 0; + + /** + \brief Retrieves the angular damping coefficient. + + The actor must be dynamic. + + \return The angular damping coefficient associated with this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setAngularDamping() NxBodyDesc.angularDamping getLinearDamping() + */ + virtual NxReal getAngularDamping() const = 0; + +//@} +/************************************************************************************************/ +/** @name Velocity +*/ +//@{ + + /** + \brief Sets the linear velocity of the actor. + + Note that if you continuously set the velocity of an actor yourself, + forces such as gravity or friction will not be able to manifest themselves, because forces directly + influence only the velocity/momentum of an actor. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] linVel New linear velocity of actor. Range: velocity vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLinearVelocity() setAngularVelocity() NxBodyDesc.linearVelocity + */ + virtual void setLinearVelocity(const NxVec3& linVel) = 0; + + /** + \brief Sets the angular velocity of the actor. + + Note that if you continuously set the angular velocity of an actor yourself, + forces such as friction will not be able to rotate the actor, because forces directly influence only the velocity/momentum. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] angVel New angular velocity of actor. Range: angular velocity vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getAngularVelocity() setLinearVelocity() NxBodyDesc.angularVelocity + */ + virtual void setAngularVelocity(const NxVec3& angVel) = 0; + + /** + \brief Retrieves the linear velocity of an actor. + + The actor must be dynamic. + + \return The linear velocity of the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLinearVelocity() getAngularVelocity() NxBodyDesc.linearVelocity + */ + virtual NxVec3 getLinearVelocity() const = 0; + + /** + \brief Retrieves the angular velocity of the actor. + + The actor must be dynamic. + + \return The angular velocity of the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setAngularVelocity() getLinearVelocity() NxBodyDesc.angularVelocity + */ + virtual NxVec3 getAngularVelocity() const = 0; + + /** + \brief Lets you set the maximum angular velocity permitted for this actor. + + Because for various internal computations, very quickly rotating actors introduce error + into the simulation, which leads to undesired results. + + With NxPhysicsSDK::setParameter(NX_MAX_ANGULAR_VELOCITY) you can set the default maximum velocity for actors created + after the call. Bodies' high angular velocities are clamped to this value. + + However, because some actors, such as car wheels, should be able to rotate quickly, you can override the default setting + on a per-actor basis with the below call. Note that objects such as wheels which are approximated with spherical or + other smooth collision primitives can be simulated with stability at a much higher angular velocity than, say, a box that + has corners. + + Note: The angular velocity is clamped to the set value before the solver, which means that + the limit may still be momentarily exceeded. + + The actor must be dynamic. + + \param[in] maxAngVel Max allowable angular velocity for actor. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getMaxAngularVelocity() NxBodyDesc.maxAngularVelocity + */ + virtual void setMaxAngularVelocity(NxReal maxAngVel) = 0; + + /** + \brief Retrieves the maximum angular velocity permitted for this actor. + + The actor must be dynamic. + + \return The maximum allowed angular velocity for this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setMaxAngularVelocity NxBodyDesc.maxAngularVelocity + */ + virtual NxReal getMaxAngularVelocity() const = 0; + +//@} +/************************************************************************************************/ +/** @name CCD +*/ +//@{ + + /** + \brief Sets the CCD Motion Threshold. + + If CCD is globally enabled (parameter NX_CONTINUOUS_CD), it is still skipped for bodies + which have no point on any of their shapes moving more than CCDMotionThreshold distance in + one time step. + + Hence, CCD is always performed if the threshold is 0. + + The actor must be dynamic and the CCD motion threshold must be non-negative. + +

Visualizations:

+ \li #NX_VISUALIZE_COLLISION_CCD + \li #NX_VISUALIZE_COLLISION_SKELETONS + + \param[in] thresh CCD Motion threshold. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCCDMotionThreshold NxParameter + */ + virtual void setCCDMotionThreshold(NxReal thresh) = 0; + + /** + \brief Retrieves the CCD Motion threshold for this actor. + + The actor must be dynamic. + + \return The CCD threshold for the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setCCDMotionThreshold NxParameter + */ + virtual NxReal getCCDMotionThreshold() const = 0; + +//@} +/************************************************************************************************/ + +/** @name Momentum +*/ +//@{ + + /** + \brief Sets the linear momentum of the actor. + + Note that if you continuously set the linear momentum of an actor yourself, + forces such as gravity or friction will not be able to manifest themselves, because forces directly + influence only the velocity/momentum of a actor. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] linMoment New linear momentum. Range: momentum vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLinearMomentum() setAngularMomentum() + */ + virtual void setLinearMomentum(const NxVec3& linMoment) = 0; + + /** + \brief Sets the angular momentum of the actor. + + Note that if you continuously set the angular velocity of an actor yourself, + forces such as friction will not be able to rotate the actor, because forces directly + influence only the velocity of actor. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] angMoment New angular momentum. Range: angular momentum vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getAngularMomentum() setLinearMomentum() + */ + virtual void setAngularMomentum(const NxVec3& angMoment) = 0; + + /** + \brief Retrieves the linear momentum of an actor. + + The momentum is equal to the velocity times the mass. + + The actor must be dynamic. + + \return The linear momentum for the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLinearMomentum() getAngularMomentum() + */ + virtual NxVec3 getLinearMomentum() const = 0; + + /** + \brief Retrieves the angular momentum of an actor. + + The angular momentum is equal to the angular velocity times the global space inertia tensor. + + The actor must be dynamic. + + \return The angular momentum for the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setAngularMomentum() getLinearMomentum() + */ + virtual NxVec3 getAngularMomentum() const = 0; + +//@} + +/************************************************************************************************/ + +/** @name Forces +*/ +//@{ + + /** + \brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular + point in global coordinates, to the actor. + + Note that if the force does not act along the center of mass of the actor, this + will also add the corresponding torque. Because forces are reset at the end of every timestep, + you can maintain a total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] force Force/impulse to add, defined in the global frame. Range: force vector + \param[in] pos Position in the global frame to add the force at. Range: position vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode) + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + @see addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce() addLocalForce() + */ + virtual void addForceAtPos(const NxVec3& force, const NxVec3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular + point in local coordinates, to the actor. + + Note that if the force does not act along the center of mass of the actor, this + will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a + total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] force Force/impulse to add, defined in the global frame. Range: force vector + \param[in] pos Position in the local frame to add the force at. Range: position vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode) + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + @see addForceAtPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce() addLocalForce() + */ + virtual void addForceAtLocalPos(const NxVec3& force, const NxVec3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a + particular point in global coordinates, to the actor. + + Note that if the force does not act along the center of mass of the actor, this + will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a + total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] force Force/impulse to add, defined in the local frame. Range: force vector + \param[in] pos Position in the global frame to add the force at. Range: position vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode) + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + @see addForceAtPos() addForceAtLocalPos() addLocalForceAtLocalPos() addForce() addLocalForce() + */ + virtual void addLocalForceAtPos(const NxVec3& force, const NxVec3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies a force (or impulse) defined in the actor local coordinate frame, acting at a + particular point in local coordinates, to the actor. + + Note that if the force does not act along the center of mass of the actor, this + will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a + total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] force Force/impulse to add, defined in the local frame. Range: force vector + \param[in] pos Position in the local frame to add the force at. Range: position vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode) + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + @see addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addForce() addLocalForce() + */ + virtual void addLocalForceAtLocalPos(const NxVec3& force, const NxVec3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies a force (or impulse) defined in the global coordinate frame to the actor. + + This will not induce a torque. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] force Force/Impulse to apply defined in the global frame. Range: force vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode) + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + @see addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addLocalForce() + */ + virtual void addForce(const NxVec3& force, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies a force (or impulse) defined in the actor local coordinate frame to the actor. + + This will not induce a torque. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] force Force/Impulse to apply defined in the local frame. Range: force vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode) + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + @see addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce() + */ + virtual void addLocalForce(const NxVec3& force, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies an impulsive torque defined in the global coordinate frame to the actor. + + ::NxForceMode determines if the torque is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] torque Torque to apply defined in the global frame. Range: torque vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode). + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode addLocalTorque() addForce() + */ + virtual void addTorque(const NxVec3& torque, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + + /** + \brief Applies an impulsive torque defined in the actor local coordinate frame to the actor. + + ::NxForceMode determines if the torque is to be conventional or impulsive. + + The actor must be dynamic. + + Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default). + + \param[in] torque Torque to apply defined in the local frame. Range: torque vector + \param[in] mode The mode to use when applying the force/impulse(see #NxForceMode). + \param[in] wakeup Specify if the call should wake up the actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode addTorque() addForce() + */ + virtual void addLocalTorque(const NxVec3& torque, NxForceMode mode = NX_FORCE, bool wakeup = true) = 0; + +//@} +/************************************************************************************************/ + + /** + \brief Computes the total kinetic (rotational and translational) energy of the object. + + The actor must be dynamic. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + \return The kinetic energy of the actor. + */ + virtual NxReal computeKineticEnergy() const = 0; + +/************************************************************************************************/ + +/** @name Point Velocity +*/ +//@{ + + /** + \brief Computes the velocity of a point given in world coordinates if it were attached to the + actor and moving with it. + + The actor must be dynamic. + + \param[in] point Point we wish to determine the velocity for, defined in the global frame. Range: position vector + \return The velocity of point in the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLocalPointVelocity() NxBodyDesc.linearVelocity NxBodyDesc.angularVelocity + */ + virtual NxVec3 getPointVelocity(const NxVec3& point) const = 0; + + /** + \brief Computes the velocity of a point given in body local coordinates as if it were attached to the + actor and moving with it. + + The actor must be dynamic. + + \param[in] point Point we wish to determine the velocity of, defined in the body local frame. Range: position vector + \return The velocity, in the global frame, of the point. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getPointVelocity() NxBodyDesc.linearVelocity NxBodyDesc.angularVelocity + */ + virtual NxVec3 getLocalPointVelocity(const NxVec3& point) const = 0; + +//@} +/************************************************************************************************/ + +/** @name Sleeping +*/ +//@{ + + /** + \brief Returns true if this body and all the actors it is touching or is linked to with joints are sleeping. + + When an actor does not move for a period of time, it is no longer simulated in order to save time. This state + is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object, + or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user. + + (Note: From version 2.5 this method is identical to isSleeping()) + + The actor must be dynamic. + + \return True if the actor's group is sleeping. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() getSleepEnergyThreshold() + */ + virtual bool isGroupSleeping() const = 0; + + /** + \brief Returns true if this body is sleeping. + + When an actor does not move for a period of time, it is no longer simulated in order to save time. This state + is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object, + or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user. + + If an actor is asleep after the call to NxScene::fetchResults() returns, it is guaranteed that the pose of the actor + was not changed. You can use this information to avoid updating the transforms of associated of dependent objects. + + The actor must be dynamic. + + \return True if the actor is sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() getSleepEnergyThreshold() + */ + virtual bool isSleeping() const = 0; + + /** + \brief Returns the linear velocity below which an actor may go to sleep. + + Actors whose linear velocity is above this threshold will not be put to sleep. + + The actor must be dynamic. + + @see isSleeping + + \return The threshold linear velocity for sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepLinearVelocity() setSleepEnergyThreshold() getSleepEnergyThreshold() + */ + virtual NxReal getSleepLinearVelocity() const = 0; + + /** + \brief Sets the linear velocity below which an actor may go to sleep. + + Actors whose linear velocity is above this threshold will not be put to sleep. + + If the threshold value is negative, the velocity threshold is set using the NxPhysicsSDK's + NX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter. + + Setting the sleep angular/linear velocity only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. In + version 2.5 and later a new method is used by default which uses the kinetic energy of the body to control + sleeping. + + + The actor must be dynamic. + + \param[in] threshold Linear velocity below which an actor may sleep. Range: (0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepEnergyThreshold() getSleepEnergyThreshold() + */ + virtual void setSleepLinearVelocity(NxReal threshold) = 0; + + /** + \brief Returns the angular velocity below which an actor may go to sleep. + + Actors whose angular velocity is above this threshold will not be put to sleep. + + The actor must be dynamic. + + \return The threshold angular velocity for sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepAngularVelocity() setSleepEnergyThreshold() getSleepEnergyThreshold() + */ + virtual NxReal getSleepAngularVelocity() const = 0; + + /** + \brief Sets the angular velocity below which an actor may go to sleep. + + Actors whose angular velocity is above this threshold will not be put to sleep. + + If the threshold value is negative, the velocity threshold is set using the NxPhysicsSDK's + NX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter. + + Setting the sleep angular/linear velocity only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. In + version 2.5 and later a new method is used by default which uses the kinetic energy of the body to control + sleeping. + + The actor must be dynamic. + + \param[in] threshold Angular velocity below which an actor may go to sleep. Range: (0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepLinearVelocity() setSleepEnergyThreshold() getSleepEnergyThreshold() + */ + virtual void setSleepAngularVelocity(NxReal threshold) = 0; + + /** + \brief Returns the energy below which an actor may go to sleep. + + Actors whose energy is above this threshold will not be put to sleep. + + The actor must be dynamic. + + \return The energy threshold for sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepAngularVelocity() NxBodyDesc.sleepEnergyThreshold + */ + virtual NxReal getSleepEnergyThreshold() const = 0; + + /** + \brief Sets the energy threshold below which an actor may go to sleep. + + Actors whose kinematic energy is above this threshold will not be put to sleep. + + If the threshold value is negative, the velocity threshold is set using the NxPhysicsSDK's + NX_DEFAULT_SLEEP_ENERGY parameter. + + Setting the sleep energy threshold only makes sense when the NX_BF_ENERGY_SLEEP_TEST is set. There + are also other types of sleeping that uses the linear and angular velocities directly instead of the + energy. + + The actor must be dynamic. + + \param[in] threshold Energy below which an actor may go to sleep. Range: (0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepEnergyThreshold() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepLinearVelocity() setSleepAngularVelocity() NxBodyDesc.sleepEnergyThreshold + */ + virtual void setSleepEnergyThreshold(NxReal threshold) = 0; + + /** + \brief Wakes up the actor if it is sleeping. + + The wakeCounterValue determines how long until the body is put to sleep, a value of zero means + that the body is sleeping. wakeUp(0) is equivalent to NxActor::putToSleep(). + + The actor must be dynamic. + + \param[in] wakeCounterValue New sleep counter value. Range: [0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() putToSleep() + */ + virtual void wakeUp(NxReal wakeCounterValue=NX_SLEEP_INTERVAL) = 0; + + /** + \brief Forces the actor to sleep. + + The actor will stay asleep until the next call to simulate, and will not wake up until then even when otherwise + it would (for example a force is applied to it). It can however wake up during + the next simulate call. + + The actor must be dynamic. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() + */ + virtual void putToSleep() = 0; +//@} +/************************************************************************************************/ + + /** + \brief Raises a particular body flag. + + See the actors body flags. See #NxBodyFlag for a list of flags. + + The actor must be dynamic. + + \param[in] bodyFlag Body flag to raise(set). See #NxBodyFlag. + + Platform: + \li PC SW: Yes + \li PPU : Partial (supports NX_BF_KINEMATIC, NX_BF_DISABLE_GRAVITY) + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyFlag clearBodyFlag() readBodyFlag() NxBodyDesc.flags + */ + virtual void raiseBodyFlag(NxBodyFlag bodyFlag) = 0; + + /** + \brief Clears a particular body flag. + + See #NxBodyFlag for a list of flags. + + The actor must be dynamic. + + \param[in] bodyFlag Body flag to clear. See #NxBodyFlag. + + Sleeping: Does NOT wake the actor up automatically. + + Platform: + \li PC SW: Yes + \li PPU : Partial (supports NX_BF_KINEMATIC, NX_BF_DISABLE_GRAVITY) + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyFlag raiseBodyFlag() readBodyFlag() NxBodyDesc.flags + */ + virtual void clearBodyFlag(NxBodyFlag bodyFlag) = 0; + /** + \brief Reads a particular body flag. + + See #NxBodyFlag for a list of flags. + + The actor must be dynamic. + + \param[in] bodyFlag Body flag to retrieve. See #NxBodyFlag. + \return The value of the body flag specified by bodyFlag. + + Platform: + \li PC SW: Yes + \li PPU : Partial (supports NX_BF_KINEMATIC, NX_BF_DISABLE_GRAVITY) + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyFlag raiseBodyFlag() clearBodyFlag() NxBodyDesc.flags + */ + virtual bool readBodyFlag(NxBodyFlag bodyFlag) const = 0; + + /** + \brief Saves the body information of a dynamic actor to the passed body descriptor. + + This method only save the dynamic(body) state for the actor. The user should use #saveToDesc() + to save the state common between static and dynamic actors. Plus manually saving the shapes + belonging to the actor. + + The actor must be dynamic. + + \param[out] bodyDesc Descriptor to save the state of the body to. + \return True for a dynamic body. Otherwise False. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc saveToDesc() getShape() + */ + virtual bool saveBodyToDesc(NxBodyDesc& bodyDesc) = 0; + + /** + \brief Sets the solver iteration count for the body. + + The solver iteration count determines how accurately joints and contacts are resolved. + If you are having trouble with jointed bodies oscillating and behaving erratically, then + setting a higher solver iteration count may improve their stability. + + The actor must be dynamic. + + \param[in] iterCount Number of iterations the solver should perform for this body. Range: [1,255] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSolverIterationCount() NxBodyDesc.solverIterationCount + */ + virtual void setSolverIterationCount(NxU32 iterCount) = 0; + + /** + \brief Retrieves the solver iteration count. + + See #setSolverIterationCount(). + + The actor must be dynamic. + + \return The solver iteration count for this body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setSolverIterationCount() NxBodyDesc.solverIterationCount + */ + virtual NxU32 getSolverIterationCount() const = 0; + + /** + \brief Retrieves the force threshold for contact reports. + + The contact report threshold is a force threshold. If the force between + two actors exceeds this threshold for either of the two actors, a contact report + will be generated according to the union of both actors' contact report threshold flags. + See #getContactReportFlags(). + + The actor must be dynamic. The threshold used for a collision between a dynamic actor + and the static environment is the threshold of the dynamic actor, and all contacts with + static actors are summed to find the total normal force. + + \return Force threshold for contact reports. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setContactReportThreshold getContactReportFlags NxContactPairFlag NxBodyDesc::contactReportThreshold + */ + virtual NxReal getContactReportThreshold() const = 0; + + /** + \brief Sets the force threshold for contact reports. + + See #getContactReportThreshold(). + + The actor must be dynamic. + + \param[in] threshold Force threshold for contact reports. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getContactReportThreshold getContactReportFlags NxContactPairFlag NxBodyDesc::contactReportThreshold + */ + virtual void setContactReportThreshold(NxReal threshold) = 0; + + /** + \brief Retrieves the actor's contact report flags. + + See #setContactReportFlags(). + + \return The contact reporting flags associated with this actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setContactReportFlags NxContactPairFlag NxActorDesc::contactReportFlags + */ + virtual NxU32 getContactReportFlags() const = 0; + + /** + \brief Sets the actor's contact report flags. + + These flags are used to determine the kind of report that is generated for interactions with other + actors. + + The following flags are permitted: + + NX_NOTIFY_ON_START_TOUCH + NX_NOTIFY_ON_END_TOUCH + NX_NOTIFY_ON_TOUCH + NX_NOTIFY_ON_IMPACT + NX_NOTIFY_ON_ROLL + NX_NOTIFY_ON_SLIDE + NX_NOTIFY_FORCE + NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD + NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD + NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD + + Please note: If the actor is part of an interacting pair for which the contact report generation + is controlled already through any other mechanism (for example by use of NxScene::setActorPairFlags) + then the union of all the specified contact report flags will be used to generate the report. + + See #getContactReportFlags(). + + \param[in] flags Flags to control contact reporting. See #NxContactPairFlag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getContactReportFlags NxContactPairFlag NxActorDesc::contactReportFlags + */ + virtual void setContactReportFlags(NxU32 flags) = 0; + +#if NX_SUPPORT_SWEEP_API + /** + \brief Performs a linear sweep through space with the actor. + + \param[in] motion Length and direction of the sweep + \param[in] flags Flags controlling the mode of the sweep + \param[in] userData User data to impart to the returned data struct + \param[in] nbShapes Maximum number of shapes to report Range: [1,NX_MAX_U32] + \param[out] shapes Pointer to buffer for reported shapes + \param[in] callback Callback function invoked on the closest hit (if any) + \param[in] sweepCache Sweep cache to use with the query + + The function sweeps the entire actor, with all its shapes, through space and reports any shapes in the scene + with which they intersect. Apart from the number of shapes intersected in this way, and the shapes + intersected, information on the closest intersection is put in an #NxSweepQueryHit structure which + can be processed in the callback function if provided. + Which shapes in the scene are regarded is specified through the flags parameter. + For persistent sweeps, a sweep cache may be used to improve performance. A sweep cache may be created + through NxScene::createSweepCache(). + Note that trigger shapes possibly contained in the actor are automatically filtered out. + + \return The number of hits reported. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSweepQueryHit NxSweepFlags NxUserEntityReport NxScene + */ + virtual NxU32 linearSweep(const NxVec3& motion, NxU32 flags, void* userData, NxU32 nbShapes, NxSweepQueryHit* shapes, NxUserEntityReport* callback, const NxSweepCache* sweepCache=NULL) = 0; +#endif + + /** + \brief Retrieves the actor's simulation compartment, if any. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartment + */ + virtual NxCompartment * getCompartment() const = 0; + + /** + \brief Retrieves the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxForceFieldMaterial getForceFieldMaterial() const = 0; + + /** + \brief Sets the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setForceFieldMaterial(NxForceFieldMaterial) = 0; + + //public variables: + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxActorDesc.h b/libraries/external/physx/Win32/include/PX/NxActorDesc.h new file mode 100755 index 0000000..c39c5b0 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxActorDesc.h @@ -0,0 +1,510 @@ +#ifndef NX_PHYSICS_NXACTORDESC +#define NX_PHYSICS_NXACTORDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxBodyDesc.h" +#include "PX/NxShapeDesc.h" + +class NxCompartment; + + /** + \brief Type of actor + */ + enum NxActorDescType + { + /** + \brief Not used*/ + NX_ADT_SHAPELESS, + NX_ADT_DEFAULT, + NX_ADT_ALLOCATOR, + /** + \brief Not used*/ + NX_ADT_LIST, + /** + \brief Not used*/ + NX_ADT_POINTER + }; + +/** + \brief Actor Descriptor. This structure is used to save and load the state of #NxActor objects. + + If the body descriptor contains a zero mass but the actor descriptor contains a non-zero density, + we compute a new mass automatically from the density and the shapes. + + Static or dynamic actors: + + \li To create a static actor, use a null body descriptor pointer(and not a body with zero mass). Shapes should + be specified for the static actor when it is created. + If you want to create a temporarily static actor that can be made dynamic at runtime, create your + dynamic actor as usual and use NX_BF_KINEMATIC flags in its body descriptor. + + \li To create a dynamic actor, provide a valid body descriptor with or without shape descriptors. The + shapes are not mandatory. + + Mass or density: + + To simulate a dynamic actor, the SDK needs a mass and an inertia tensor. + (The inertia tensor is the combination of bodyDesc.massLocalPose and bodyDesc.massSpaceInertia) + + These can be specified in several different ways: + + 1) actorDesc.density == 0, bodyDesc.mass > 0, bodyDesc.massSpaceInertia.magnitude() > 0 + + Here the mass properties are specified explicitly, there is nothing to compute. + + 2) actorDesc.density > 0, actorDesc.shapes.size() > 0, bodyDesc.mass == 0, bodyDesc.massSpaceInertia.magnitude() == 0 + + Here a density and the shapes are given. From this both the mass and the inertia tensor is computed. + + 3) actorDesc.density == 0, actorDesc.shapes.size() > 0, bodyDesc.mass > 0, bodyDesc.massSpaceInertia.magnitude() == 0 + + Here a mass and shapes are given. From this the inertia tensor is computed. + + Other combinations of settings are illegal. + + When the SDK computes the inertia properties it uses the actor's shapes. + For each shape, the shape geometry, shape mass (or density), and shape positioning within the actor + are used to compute the body's mass and inertia properties. + + Setting the individual masses or densities of the shapes of an actor is the most intuitive method + to specify the mass, center of mass, and inertial properties of a multi shape actor in order to achieve + correct behavior. + + If the actor body has a mass, then the computed inertial properties of the actor are scaled to the specified body mass. + Even then, the individual shape masses are still useful since they specify how that mass is distributed within the object. + i.e. When specified, the actor/body mass properties have priority. + + If you specify a shape density and an actor density then the two are multiplied together to obtain the effective density + of the actor. So if you set the density of the actor to 2 and the density of the shape to 3 then the effective density + of that shape will be 6. + + When the sdk computes the inertial properties the default is to also compute the center of mass. + To specify an actor's center of mass exactly but still let the SDK compute and diagonalize the inertia + tensor raise NxActorDescBase::flags | NX_AF_LOCK_COM. In this case the center of mass (bodydesc.massLocalPose.t) + will not be overridden and the computed inertial tensor will be transformed correctly so that + it will be as if the volume integrals for the moments had been done from the specified point. + + The NX_AF_LOCK_COM is only considered when computing the mass properties during creation, it will + not be considered when calling NxActor::updateMassFromShapes(). + + You should not use the NxActorDescBase class directly, instead use one of the derived classes, + NxActorDesc or NxActorDesc_Template. +*/ + +class NxActorDescBase + { + public: + /** + \brief The pose of the actor in the world. + + Range: rigid body transform
+ Default: Identity Matrix + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor::setGlobalPose() + */ + NxMat34 globalPose; + + /** + \brief Body descriptor, null for static actors + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc + */ + const NxBodyDesc* body; + + /** + \brief Density used during mass/inertia computation. + + We can compute the mass from a density and the shapes mass/density. + + See the notes for #NxActorDesc for more details. + + Range: (0,inf)
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActorDesc + */ + NxReal density; + + /** + \brief Combination of ::NxActorFlag flags + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor::raiseActorFlag() + */ + NxU32 flags; + + /** + \brief The actors group. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor::setGroup() + */ + NxActorGroup group; + + /** + \brief Dominance group for this actor. + + NxDominanceGroup is a 5 bit group identifier (legal range from 0 to 31). + The NxScene::setDominanceGroupPair() lets you set certain behaviors for pairs of dominance groups. + By default every actor is created in group 0. Static actors must stay in group 0. + + Default: 0 + */ + NxDominanceGroup dominanceGroup; + + /** + \brief Combination of ::NxContactPairFlag flags + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor::setContactReportFlags() + */ + NxU32 contactReportFlags; + + /** + \brief Force Field Material Index, index != 0 has to be created. + + Default: 0 + */ + NxU16 forceFieldMaterial; + + /** + \brief Will be copied to NxActor::userData + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.userData + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Default: NULL + */ + const char* name; + + /** + \brief The compartment to place the actor in. Must be either a pointer to an NxCompartment of type NX_SCT_RIGIDBODY, or NULL. + A NULL compartment means creating the actor in the scene proper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Default: NULL + */ + NxCompartment * compartment; + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Retrieve the actor type. + + \return The actor desc type. See #NxActorDescType + */ + NX_INLINE NxActorDescType getType() const; + protected: + /** + \brief constructor sets to default. + */ + NX_INLINE NxActorDescBase(); + + NX_INLINE bool isValidInternal(bool hasSolidShape) const; + + NxActorDescType type; + }; + +/** +\brief Actor Descriptor. This structure is used to save and load the state of #NxActor objects. + +Legacy implementation that works with existing code but does not permit the user +to supply his own allocator for NxArray shapes. +*/ +class NxActorDesc : public NxActorDescBase + { + public: + + /** + \brief Shapes composing the actor. + + Shapes should always be specified for static actors during creation. However it is optional for dynamic actors. + + See #NxActor.createShape() for additional notes and limitations. + + Default: empty + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxArray shapes; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxActorDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +/** +\brief Implementation of an actor descriptor that permits the user to supply his own allocator +*/ +template class NxActorDesc_Template : public NxActorDescBase + { + public: + + /** + \brief Shapes composing the actor + + Shapes should always be specified for static actors during creation. However it is optional for dynamic actors. + + See #NxActor.createShape() for additional notes and limitations. + + Default: empty + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxArray shapes; + + + + NX_INLINE NxActorDesc_Template() + { + setToDefault(); + type = NX_ADT_ALLOCATOR; + } + + NX_INLINE void setToDefault() + { + NxActorDescBase::setToDefault(); + shapes.clear(); + } + + NX_INLINE bool isValid() const + { + if (!NxActorDescBase::isValid()) + return false; + + unsigned int nNonTriggerShapes = 0; + + // Static actors need nothing but a shape + if (!body && shapes.size() > 0) + return true; + for (unsigned i = 0; i < shapes.size(); i++) + { + if (!shapes[i]->isValid()) + return false; + if ((shapes[i]->shapeFlags & NX_TRIGGER_ENABLE) == 0) + nNonTriggerShapes++; + } + + // If Actor is dynamic (body && !(body->flags & NX_BF_KINEMATIC) but has no solid shapes, + // it has to have mass and massSpaceInertia, otherwise NxScene::createActor returns 0 + if (nNonTriggerShapes == 0 && body && (!(body->flags & NX_BF_KINEMATIC)) && (body->mass < 0 || body->massSpaceInertia.isZero())) + return false; + + if (!NxActorDescBase::isValidInternal(nNonTriggerShapes > 0)) + return false; + + return true; + } + + + }; + + + +NX_INLINE NxActorDescBase::NxActorDescBase() + { + //nothing! Don't call setToDefault() here! + } + + +NX_INLINE void NxActorDescBase::setToDefault() + { + body = NULL; + density = 0.0f; + globalPose .id(); + flags = 0; + userData = NULL; + name = NULL; + group = 0; + dominanceGroup = 0; + contactReportFlags = 0; + forceFieldMaterial = 0; + compartment = NULL; + } + +NX_INLINE bool NxActorDescBase::isValid() const + { + if (density < 0) + return false; + + if (body && !body->isValid()) + return false; + if(!globalPose.isFinite()) + return false; + if (!body && dominanceGroup) //only dynamic actors may have a nonzero dominance group. + return false; + + return true; + } + +NX_INLINE NxActorDescType NxActorDescBase::getType() const + { + return type; + } + +NX_INLINE bool NxActorDescBase::isValidInternal(bool hasSolidShape) const + { + bool haveDensity = density!=0.0f; + bool haveMass = body && body->mass != 0.0f; + bool haveTensor = body && !(body->massSpaceInertia.isZero() > 0.0f); + + if (hasSolidShape && haveDensity && !haveMass && !haveTensor) return true; + else if (hasSolidShape && !haveDensity && haveMass && !haveTensor) return true; + else if (!haveDensity && haveMass && haveTensor) return true; + else return false; + } + + + + +NX_INLINE NxActorDesc::NxActorDesc() + { + memset(this,0,sizeof(NxActorDesc)); + setToDefault(); + type = NX_ADT_DEFAULT; + } + +NX_INLINE void NxActorDesc::setToDefault() + { + NxActorDescBase::setToDefault(); + shapes .clear(); + } + +NX_INLINE bool NxActorDesc::isValid() const + { + if (!NxActorDescBase::isValid()) + return false; + + unsigned int nNonTriggerShapes = 0; + + // Static actors need nothing but a shape + if (!body && shapes.size() > 0) + return true; + for (unsigned i = 0; i < shapes.size(); i++) + { + if (!shapes[i]->isValid()) + return false; + if ((shapes[i]->shapeFlags & NX_TRIGGER_ENABLE) == 0) + nNonTriggerShapes++; + } + + // If Actor is dynamic (body && !(body->flags & NX_BF_KINEMATIC) but has no solid shapes, + // it has to have mass and massSpaceInertia, otherwise NxScene::createActor returns 0 + if (nNonTriggerShapes == 0 && body && (!(body->flags & NX_BF_KINEMATIC)) && (body->mass < 0 || body->massSpaceInertia.isZero())) + return false; + + if (!NxActorDescBase::isValidInternal(nNonTriggerShapes > 0)) + return false; + + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxAllocateable.h b/libraries/external/physx/Win32/include/PX/NxAllocateable.h new file mode 100755 index 0000000..75d91a2 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxAllocateable.h @@ -0,0 +1,112 @@ +#ifndef NX_PHYSICS_ALLOCATEABLE +#define NX_PHYSICS_ALLOCATEABLE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxUserAllocator.h" +#include "PX/PhysXLoader.h" + + +/* +Should be called Allocateable but then we collide with Ice::Allocateable. +*/ + +/** +\brief Subclasses of this base class automatically take part in user memory management. +*/ +class NxAllocateable + { + public: + NX_INLINE void* operator new(size_t size, NxMemoryType type); + NX_INLINE void* operator new[](size_t size, NxMemoryType type); + NX_INLINE void operator delete(void* p); + NX_INLINE void operator delete[](void* p); +#ifdef _DEBUG + NX_INLINE void* operator new(size_t size, const char* fileName, int line, const char* className, NxMemoryType type); + NX_INLINE void* operator new[](size_t size, const char* fileName, int line, const char* className, NxMemoryType type); + NX_INLINE void operator delete(void* p, const char*, int, const char*, NxMemoryType type); + NX_INLINE void operator delete[](void* p, const char*, int, const char*, NxMemoryType type); +#endif + // PT: delete parameters have been added to fix warning C4291 in VC7. But they're not used. + }; + +NX_INLINE void* ::NxAllocateable::operator new(size_t size, NxMemoryType type) + { + return NxGetPhysicsSDKAllocator()->malloc(size, type); + } + +NX_INLINE void* ::NxAllocateable::operator new[](size_t size, NxMemoryType type) + { + return NxGetPhysicsSDKAllocator()->malloc(size, type); + } + +NX_INLINE void ::NxAllocateable::operator delete(void* p) + { + NxGetPhysicsSDKAllocator()->free(p); + } + +NX_INLINE void ::NxAllocateable::operator delete[](void* p) + { + NxGetPhysicsSDKAllocator()->free(p); + } + +#ifdef _DEBUG +NX_INLINE void* ::NxAllocateable::operator new(size_t size, const char* fileName, int line, const char* className, NxMemoryType type) + { + return NxGetPhysicsSDKAllocator()->mallocDEBUG(size, fileName, line, className, type); + } + +NX_INLINE void* ::NxAllocateable::operator new[](size_t size, const char* fileName, int line, const char* className, NxMemoryType type) + { + return NxGetPhysicsSDKAllocator()->mallocDEBUG(size, fileName, line, className, type); + } + +NX_INLINE void ::NxAllocateable::operator delete(void* p, const char*, int, const char*, NxMemoryType) + { + NxGetPhysicsSDKAllocator()->free(p); + } + +NX_INLINE void ::NxAllocateable::operator delete[](void* p, const char*, int, const char*, NxMemoryType) + { + NxGetPhysicsSDKAllocator()->free(p); + } +#endif + + + +#ifndef NX_PHYSICS_DLL //only define for user code, our internal versions are defined in foundation/src/include/Allocateable.h +#ifndef NX_USE_SDK_STATICLIBS +#ifndef CORELIB //TODO: this macro needs an NX prefix! +#ifdef NX_FOUNDATION_ALLOCATEABLE +#error Something went wrong, duplicate macro def! +#endif +#ifdef _DEBUG + #define NX_ALLOC_TMP(x) NxGetPhysicsSDKAllocator()->mallocDEBUG(x, (const char *)__FILE__, __LINE__, #x, NX_MEMORY_TEMP) + #define NX_ALLOC(x) NxGetPhysicsSDKAllocator()->mallocDEBUG(x, (const char *)__FILE__, __LINE__, #x, NX_MEMORY_PERSISTENT) +#else + #define NX_ALLOC_TMP(x) NxGetPhysicsSDKAllocator()->malloc(x, NX_MEMORY_TEMP) + #define NX_ALLOC(x) NxGetPhysicsSDKAllocator()->malloc(x, NX_MEMORY_PERSISTENT) +#endif + #define NX_FREE(x) if(x) { NxGetPhysicsSDKAllocator()->free(x); x = NULL; } + +#endif +#endif +#endif + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxAllocatorDefault.h b/libraries/external/physx/Win32/include/PX/NxAllocatorDefault.h new file mode 100755 index 0000000..a21a86a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxAllocatorDefault.h @@ -0,0 +1,108 @@ +#ifndef NX_FOUNDATION_NXALLOCATOR_DEFAULT +#define NX_FOUNDATION_NXALLOCATOR_DEFAULT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxUserAllocator.h" + +#include + +#if defined(WIN32) && NX_DEBUG_MALLOC + #include +#endif +/** +\brief Default memory allocator using standard C malloc / free / realloc. +*/ +class NxAllocatorDefault + { + public: + /** + Allocates size bytes of memory. + + Compatible with the standard C malloc(). + + \param size Number of bytes to allocate. + \param type A hint about what the memory will be used for. See #NxMemoryType. + */ + NX_INLINE void* malloc(size_t size, NxMemoryType type) + { + return ::malloc(size); + } + + /** + Allocates size bytes of memory. + + Same as above, but with extra debug info fields. + + \param size Number of bytes to allocate. + \param fileName File which is allocating the memory. + \param line Line which is allocating the memory. + \param className Name of the class which is allocating the memory. + \param type A hint about what the memory will be used for. See #NxMemoryType. + */ + NX_INLINE void* mallocDEBUG(size_t size, const char* fileName, int line, const char* className, NxMemoryType type) + { +#ifdef _DEBUG + #if defined(WIN32) && NX_DEBUG_MALLOC + return ::_malloc_dbg(size, _NORMAL_BLOCK, fileName, line); + #else + // TODO: insert a Linux Debugger Function + return ::malloc(size); + #endif +#else + NX_ASSERT(0);//Don't use debug malloc for release mode code! + return 0; +#endif + } + + /** + Resizes the memory block previously allocated with malloc() or + realloc() to be size() bytes, and returns the possibly moved memory. + + Compatible with the standard C realloc(). + + \param memory Memory block to change the size of. + \param size New size for memory block. + */ + NX_INLINE void* realloc(void* memory, size_t size) + { + return ::realloc(memory,size); + } + + /** + Frees the memory previously allocated by malloc() or realloc(). + + Compatible with the standard C free(). + + \param memory Memory to free. + */ + NX_INLINE void free(void* memory) + { + if(memory) ::free(memory); // Deleting null ptrs is valid, but still useless + } + + /** + Check a memory block is valid. + */ + NX_INLINE void check(void* memory) + { + } + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxArray.h b/libraries/external/physx/Win32/include/PX/NxArray.h new file mode 100755 index 0000000..ac645a4 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxArray.h @@ -0,0 +1,481 @@ +#ifndef NX_FOUNDATION_NXARRAY +#define NX_FOUNDATION_NXARRAY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxAllocatorDefault.h" +//#include "NxUserAllocatorAccess.h" +//#include "Allocateable.h" + +/** + \brief Simple 'std::vector' style template container. + + if no NxUserAllocator is specified, the NxDefaultAllocator is used. + + Note: the methods of this template are implemented inline in order to avoid the not yet very cross-compileable 'typename' keyword. +*/ +template +class NxArray// : public Allocateable + { + public: + typedef NxArray MyType; + typedef ElemType * Iterator; + typedef const ElemType * ConstIterator; + /* + Same as above with STL compliant syntax. Deprecated. + */ + typedef Iterator iterator; + typedef ConstIterator const_iterator; + + /** + creates an empty array + */ + NX_INLINE NxArray() : first(0), last(0), memEnd(0) + { + //nothing + } + + /** + creates an array of n elements with value x. + + \param n Number of elements to allocate + \param v Value to set elements to. + */ + NX_INLINE NxArray(unsigned n, const ElemType& v = ElemType() ) + { + first = allocate(n); + fill(first, n, v); + memEnd = last = first + n; + } + + /** + copy constructor + + \param other Array to copy from. + */ + NX_INLINE NxArray(const MyType & other) + { + first = allocate(other.size()); + memEnd = last = copy(other.begin(), other.end(), first); + } + + /** + destructor. Remember that if ElemType is a pointer type, then + the actual objects pointed to are not destroyed. + */ + NX_INLINE ~NxArray() + { + destroy(first, last); + deallocate(first); + first = 0; + last = 0; + memEnd = 0; + } + + /** + assignment + + \param other Array to copy from. + */ + NX_INLINE MyType& operator=(const MyType& other) + { + if (this != &other) + { + if (other.size() <= size()) + { + Iterator s = copy(other.begin(), other.end(), first); + destroy(s, last); + last = first + other.size(); + } + else if (other.size() <= capacity()) + { + ConstIterator s = other.begin() + size(); + copy(other.begin(), s, first); + copy(s, other.end(), last); + last = first + other.size(); + } + else + { + destroy(first, last); + deallocate(first); + first = allocate(other.size()); + last = copy(other.begin(), other.end(), first); + memEnd = last; + } + } + return *this; + } + + /** + The member function ensures that capacity() henceforth returns at least n. + + \param n Capacity to increase to. + */ + NX_INLINE void reserve(unsigned n) + { + if (capacity() < n) + { + + iterator s = allocate(n); + copy(first, last, s); + destroy(first, last); + deallocate(first); + //if we knew we just have atomics we could just do this: + //first = reallocate(n, first); + memEnd = s + n; + last = s + size(); + first = s; + } + } + + /** + The member function returns the storage currently allocated to hold the controlled sequence, a value at least as large as size(). + */ + NX_INLINE unsigned capacity() const + { + return (unsigned)(first == 0 ? 0 : memEnd - first); + } + + /** + The member function ensures that size() henceforth returns n. + If it must lengthen the controlled sequence, it appends elements with value x. + The capacity of the vector is set to fit the size. + + \param n New size. + \param v Value to fill new elements with. + */ + NX_INLINE void resize(unsigned n, const ElemType& v = ElemType()) + { + if (size() < n) + insert(end(), n - size(), v); + else if (n < size()) + erase(begin() + n, end()); + + if (first == last) + { + deallocate(first); + first = 0; + last = 0; + memEnd = 0; + } + + if (memEnd > last) //release unused memory + { + size_t s = (size_t)(last - first); + first = reallocate(size(), first); + memEnd = last = first + s; + } + } + + /** + The member function returns the length of the controlled sequence. + */ + NX_INLINE unsigned size() const + { + return (unsigned)(last - first); + } + + /** + The member function returns true for an empty controlled sequence. + */ + NX_INLINE bool isEmpty() const + { + return (size() == 0); + } + + /** + Same as above with STL compliant syntax. Deprecated. + */ + NX_INLINE bool empty() const + { + return isEmpty(); + } + + /** + The member function inserts an element with value x at the end of the controlled sequence. + + NOTE: This calls ElemType operator = if its defined, on an uninitialized object of type ElemType. + + \param x Element to add. + */ + NX_INLINE void pushBack(const ElemType& x) + { + //insert(end(), x); + if (memEnd <= last) + { + reserve((1 + size()) * 2); + } + *last = x; + last ++; + } + + /** + The member function inserts an uninitialized element at the end of the controlled sequence. This element is returned so that the user can initialize it. + */ + NX_INLINE ElemType & pushBack() + { + if (memEnd <= last) + { + reserve((1 + size()) * 2); + } + last ++; + return *(last-1); + } + /** + Same as above with STL compliant syntax. Deprecated. + + \param x Element to add. + */ + NX_INLINE void push_back(const ElemType& x) + { + pushBack(x); + } + + /** + The member function removes the last element of the controlled sequence, which must be non-empty. + */ + NX_INLINE void popBack() + { + --last; + last->~ElemType(); + } + + /** + Same as above with STL compliant syntax. Deprecated. + */ + NX_INLINE void pop_back() + { + popBack(); + } + + /** + Deletes all elements in the sequence. Does not release memory (capacity). + */ + NX_INLINE void clear() + { + destroy(begin(), end()); + last = first; + } + + /** + Removes a given element from the array, replaces it with the last element. + + \param position position to replace with the last element. + */ + NX_INLINE void replaceWithLast(unsigned position) + { + NX_ASSERT(position~ElemType(); + } + } + + Iterator first, last, memEnd; + + AllocType allocator; + }; + + + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxAssert.h b/libraries/external/physx/Win32/include/PX/NxAssert.h new file mode 100755 index 0000000..d94f025 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxAssert.h @@ -0,0 +1,36 @@ +#ifndef NX_FOUNDATION_NXASSERT +#define NX_FOUNDATION_NXASSERT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + + +/** +This ANSI assert is included so that NX_ASSERTs can continue to appear in user side +code, where the custom assert in Assert.h would not work. +*/ + +#include +#ifndef NX_ASSERT + #ifdef _DEBUG + #define NX_ASSERT(x) assert(x) + #else + #define NX_ASSERT(x) {} + #endif +#endif + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBitField.h b/libraries/external/physx/Win32/include/PX/NxBitField.h new file mode 100755 index 0000000..5dc5986 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBitField.h @@ -0,0 +1,228 @@ +#ifndef NX_FOUNDATION_NXBitField +#define NX_FOUNDATION_NXBitField +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" + +/** + \brief BitField class, for efficient storage of flags, and sub-byte width enums. + + Bits can hypothetically be changed by changing the integer type of the flags member var. + Previously this used to be a template class but it was too painful to maintain for what is probably zero benefit. +*/ +class NxBitField + { + public: + /** + this could be bool, but an integer type is more efficient. In any case, Flag variables + should either be 1 or 0. + */ + typedef NxU32 IntType; //currently I hardcode this to U32, it used to be templatized. If we need more sizes later we can try to put the template back, its in the repository. + + typedef NxU32 Flag; + typedef NxU32 Field; + typedef NxU32 Mask; + typedef NxU32 Shift; + + /** + \brief Refrences an individual flag. + */ + class FlagRef + { + public: + NX_INLINE FlagRef(NxBitField & x, NxU32 index) : bitField(x), bitIndex(index) { } + NX_INLINE const FlagRef & operator=(Flag f) + { + bitField.setFlag(bitIndex, f); + return *this; + } + NX_INLINE operator Flag() + { + return bitField.getFlag(bitIndex); + } + private: + + NxBitField & bitField; + NxU32 bitIndex; + }; + + + + //construction and assignment: + //! default constructor leaves uninitialized. + NX_INLINE NxBitField() { } + NX_INLINE NxBitField(IntType); + NX_INLINE NxBitField(const NxBitField &); + NX_INLINE operator IntType() { return bitField; } + + NX_INLINE const NxBitField & operator=(const NxBitField &); + NX_INLINE const NxBitField & operator=(IntType); + + //!manipulating a single bit using a bit index. The smallest bitIndex is 0. + NX_INLINE void setFlag(NxU32 bitIndex, Flag value); + NX_INLINE void raiseFlag(NxU32 bitIndex); + NX_INLINE void lowerFlag(NxU32 bitIndex); + NX_INLINE Flag getFlag(NxU32 bitIndex) const; + + + //manipulating a single bit, using a single bit bit-mask + NX_INLINE void setFlagMask(Mask mask, Flag value); + NX_INLINE void raiseFlagMask(Mask mask); + NX_INLINE void lowerFlagMask(Mask mask); + + NX_INLINE bool getFlagMask(Mask mask) const; + + + /** + manipulating a set of bits: + shift is the lsb of the field + mask is the value of all the raised flags in the field. + + Example: if the bits 4,5,6 of the bit field are being used, + then shift is 4 and mask is (1<<4)|(1<<5)|(1<<6) == 1110000b = 112 + + \param shift + \param mask + */ + NX_INLINE Field getField(Shift shift, Mask mask) const; + NX_INLINE void setField(Shift shift, Mask mask, Field field); + NX_INLINE void clearField(Mask mask); + + //! more operators + NX_INLINE FlagRef operator[](NxU32 bitIndex); + //!statics + + static NX_INLINE Mask rangeToDenseMask(NxU32 lowIndex, NxU32 highIndex); + static NX_INLINE Shift maskToShift(Mask mask); + + + IntType bitField; + }; + +typedef NxBitField NxBitField32; + + + +NX_INLINE NxBitField::NxBitField(IntType v) + { + bitField = v; + } + + +NX_INLINE NxBitField::NxBitField(const NxBitField & r) + { + bitField = r.bitField; + } + + +NX_INLINE void NxBitField::setFlag(NxU32 bitIndex, Flag value) + { + if (value) + raiseFlag(bitIndex); + else + lowerFlag(bitIndex); + } + + +NX_INLINE void NxBitField::raiseFlag(NxU32 bitIndex) + { + bitField |= (1 << bitIndex); + } + + +NX_INLINE void NxBitField::lowerFlag(NxU32 bitIndex) + { + bitField &= ~(1 << bitIndex); + } + + +NX_INLINE NxBitField::Flag NxBitField::getFlag(NxU32 bitIndex) const + { + return (bitField & (1 << bitIndex)) >> bitIndex; + } + + + +NX_INLINE void NxBitField::setFlagMask(Mask mask, Flag value) + { + if (value) + raiseFlagMask(mask); + else + lowerFlagMask(mask); + } + + +NX_INLINE void NxBitField::raiseFlagMask(Mask mask) + { + bitField |= mask; + } + + +NX_INLINE void NxBitField::lowerFlagMask(Mask mask) + { + bitField &= ~mask; + } + + +//NX_INLINE NxBitField::Flag NxBitField::getFlagMask(Mask mask) const +NX_INLINE bool NxBitField::getFlagMask(Mask mask) const + { + return (bitField & mask) != 0; + } + + +NX_INLINE NxBitField::Field NxBitField::getField(Shift shift, Mask mask) const + { + return ((bitField & mask) >> shift); + } + + +NX_INLINE void NxBitField::setField(Shift shift, Mask mask, Field field) + { + clearField(mask); + bitField |= field << shift; + } + + +NX_INLINE void NxBitField::clearField(Mask mask) + { + bitField &= ~mask; + } + + +NX_INLINE NxBitField::FlagRef NxBitField::operator[](NxU32 bitIndex) + { + return FlagRef(*this, bitIndex); + } + + +NX_INLINE const NxBitField & NxBitField::operator=(const NxBitField &x) + { + bitField = x.bitField; + return *this; + } + + +NX_INLINE const NxBitField & NxBitField::operator=(IntType x) + { + bitField = x; + return *this; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBodyDesc.h b/libraries/external/physx/Win32/include/PX/NxBodyDesc.h new file mode 100755 index 0000000..2fc8569 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBodyDesc.h @@ -0,0 +1,390 @@ +#ifndef NX_PHYSICS_NXBODYDESC +#define NX_PHYSICS_NXBODYDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** +\brief Descriptor for the optional rigid body dynamic state of #NxActor. + +@see NxActor NxActorDesc NxScene.createActor() +*/ +class NxBodyDesc + { + public: + + /** + \brief position and orientation of the center of mass + + Range: rigid body transform
+ Default: Identity Matrix + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setCMassOffsetLocalPose() NxActor.getCMassLocalPose() massSpaceInertia mass + */ + NxMat34 massLocalPose; + + /** + \brief Diagonal mass space inertia tensor in bodies mass frame. + + Set to all zeros to let the SDK compute it. + + Range: inertia vector
+ Default: Zero Matrix + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setMassSpaceInertiaTensor() NxActor.getMassSpaceInertiaTensor() mass massLocalPose + */ + NxVec3 massSpaceInertia; + + /** + \brief Mass of body + + Should not be zero, to create a static actor set the body member of #NxActorDesc to NULL. + + Range: (0,inf)
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setMass() NxActor.getMass() massSpaceInertia + */ + NxReal mass; + + /** + \brief Linear Velocity of the body + + Range: velocity vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setLinearVelocity() NxActor.getLinearVelocity() angularVelocity + */ + NxVec3 linearVelocity; + + /** + \brief Angular velocity of the body + + Range: angular velocity vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setAngularVelocity() NxActor.getAngularVelocity() linearVelocity + */ + NxVec3 angularVelocity; + + /** + \brief The body's initial wake up counter. + + Range: [0,inf)
+ Default: 20.0f*0.02f + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.wakeUp() NxActor.putToSleep() + */ + NxReal wakeUpCounter; + + /** + \brief Linear damping applied to the body + + Range: [0,inf)
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.getLinearDamping() NxActor.setLinearDamping() angularDamping + */ + NxReal linearDamping; + + /** + \brief Angular damping applied to the body + + Range: [0,inf)
+ Default: 0.05 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setAngularDamping() NxActor.getAngularDamping() linearDamping + */ + NxReal angularDamping; + + /** + \brief Maximum allowed angular velocity + + Use a negative value to use the default, specified using the #NX_MAX_ANGULAR_VELOCITY SDK parameter. + + Range: (0,inf)
+ Default: -1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Note: The angular velocity is clamped to the set value before the solver, which means that + the limit may still be momentarily exceeded. + + @see NxActor.setMaxAngularVelocity() NxActor.getMaxAngularVelocity() NxPhysicsSDK.setParameter() + */ + NxReal maxAngularVelocity; + + /** + \brief When CCD is globally enabled, it is still not performed if the motion distance of all points on the body + is below this threshold. + + Range: [0,inf)
+ Default: 0.0 (CCD enabled for any velocity) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setCCDMotionThreshold() NxActor.getCCDMotionThreshold() NxShape.setCCDSkeleton() NxPhysicsSDK.setParameter() + */ + NxReal CCDMotionThreshold; + + /** + \brief Combination of ::NxBodyFlag flags + + Default: NX_BF_VISUALIZATION | NX_BF_ENERGY_SLEEP_TEST + + Platform: + \li PC SW: Yes + \li PPU : Partial (only supports NX_BF_KINEMATIC, NX_BF_DISABLE_GRAVITY) + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyFlag NxActor.raiseBodyFlag() NxActor.clearBodyFlag() + */ + NxU32 flags; + + + /** + \brief Maximum linear velocity at which body can go to sleep. + + If negative, the global default will be used. + + Setting the sleep angular/linear velocity only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. In + version 2.5 and later a new method is used by default which uses the kinetic energy of the body to control + sleeping. + + + Range: [0,inf)
+ Default: -1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setSleepLinearVelocity() NxActor.getSleepLinearVelocity() sleepAngularVelocity + */ + NxReal sleepLinearVelocity; + + /** + \brief Maximum angular velocity at which body can go to sleep. + + If negative, the global default will be used. + + Setting the sleep angular/linear velocity only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. In + version 2.5 and later a new method is used by default which uses the kinetic energy of the body to control + sleeping. + + Range: [0,inf)
+ Default: -1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setSleepAngularVelocity() NxActor.getSleepAngularVelocity() sleepLinearVelocity + */ + NxReal sleepAngularVelocity; + + + /** + \brief Number of solver iterations performed when processing joint/contacts connected to this body. + + Range: [1,255]
+ Default: 4 + + Platform: + \li PC SW: Yes + \li PPU : No (Supported in FW, but will only influence per scene maxIterations) + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setSolverIterationCount() NxActor.getSolverIterationCount() + */ + NxU32 solverIterationCount; + + /** + \brief Threshold for the energy-based sleeping algorithm. Only used when the NX_BF_ENERGY_SLEEP_TEST flag is set. + + Range: [0, inf)
+ Default: 0.005 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NxReal sleepEnergyThreshold; + + /** + \brief Damping factor for bodies that are about to sleep. + + Range: [0, inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NxReal sleepDamping; + + /** + \brief The force threshold for contact reports. + + Range: (0,inf)
+ Default: NX_MAX_REAL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.setContactReportThreshold() NxActor.getContactReportThreshold() + */ + NxReal contactReportThreshold; + + /** + \brief Constructor sets to default, mass == 0 (an immediate call to isValid() will return false). + */ + NX_INLINE NxBodyDesc(); + /** + \brief (re)sets the structure to the default, mass == 0 (an immediate call to isValid() will return false). + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxBodyDesc::NxBodyDesc() //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxBodyDesc::setToDefault() + { + massLocalPose .id(); + massSpaceInertia .zero(); + linearVelocity .zero(); //setNotUsed(); //when doing a loadFromDesc, the user expects to set the complete state, so this is not OK. + angularVelocity .zero(); //setNotUsed(); + wakeUpCounter = 20.0f*0.02f; + mass = 0.0f; + linearDamping = 0.0f; + angularDamping = 0.05f; + maxAngularVelocity = -1.0f; + flags = NX_BF_VISUALIZATION; + sleepLinearVelocity = -1.0f; + sleepAngularVelocity = -1.0f; + CCDMotionThreshold = 0.0f; + solverIterationCount = 4; + flags |= NX_BF_ENERGY_SLEEP_TEST; + sleepEnergyThreshold = -1.0f; + sleepDamping = 0.0f; + contactReportThreshold = NX_MAX_REAL; + } + +NX_INLINE bool NxBodyDesc::isValid() const + { + if(mass<0.0f) //no negative masses plz. + return false; + if (wakeUpCounter < 0.0f) //must be nonnegative + return false; + if (linearDamping < 0.0f) //must be nonnegative + return false; + if (angularDamping < 0.0f) //must be nonnegative + return false; + if (CCDMotionThreshold < 0.0f) //must be nonnegative + return false; + if (solverIterationCount < 1) //must be positive + return false; + if (solverIterationCount > 255) + return false; + if (contactReportThreshold < 0.0f) //must be nonnegative + return false; + if(!massLocalPose.isFinite()) + return false; + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBounds3.h b/libraries/external/physx/Win32/include/PX/NxBounds3.h new file mode 100755 index 0000000..0d589bd --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBounds3.h @@ -0,0 +1,330 @@ +#ifndef NX_FOUNDATION_NXBOUNDS3 +#define NX_FOUNDATION_NXBOUNDS3 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nxf.h" +#include "PX/NxVec3.h" +#include "PX/NxMat33.h" + +/** + \brief Class representing 3D range or axis aligned bounding box. + + Stored as minimum and maximum extent corners. Alternate representation + would be center and dimensions. + May be empty or nonempty. If not empty, min <= max has to hold. +*/ +class NxBounds3 + { + public: + NX_INLINE NxBounds3(); + NX_INLINE ~NxBounds3(); + + /** + \brief Sets empty to true + */ + NX_INLINE void setEmpty(); + + /** + \brief Sets infinite bounds + */ + NX_INLINE void setInfinite(); + + /** + \brief low level assignment. + + \param minx Minimum X value + \param miny Minimum Y value + \param minz Minimum Z value + \param maxx Maximum X value + \param maxy Maximum Y value + \param maxz Maximum Z value + */ + NX_INLINE void set(NxReal minx, NxReal miny, NxReal minz, NxReal maxx, NxReal maxy,NxReal maxz); + + /** + \brief vector assignment. + + \param min Minimum point of bounds. + \param max Maximum point of bounds. + */ + NX_INLINE void set(const NxVec3& min, const NxVec3& max); + + /** + \brief expands the volume to include v + + \param v Point to expand to. + */ + NX_INLINE void include(const NxVec3& v); + + /** + \brief sets this to the union of this and b2. + + \param b2 Bounds to perform union with. + */ + NX_INLINE void combine(const NxBounds3& b2); + + /** + \brief sets this to the AABB of the OBB passed. + + \param orientation Orientation of the OBB. + \param translation Translation of the OBB. + \param halfDims radii of the OBB. + */ + NX_INLINE void boundsOfOBB(const NxMat33& orientation, const NxVec3& translation, const NxVec3& halfDims); + + /** + \brief transforms this volume as if it was an axis aligned bounding box, and then assigns the results' bounds to this. + + \param orientation Orientation to apply. + \param translation Translation to apply(applied after orientation transform) + */ + NX_INLINE void transform(const NxMat33& orientation, const NxVec3& translation); + + NX_INLINE bool isEmpty() const; + + /** + \brief indicates whether the intersection of this and b is empty or not. + + \param b Bounds to test for intersection. + */ + NX_INLINE bool intersects(const NxBounds3& b) const; + + /** + \brief indicates whether the intersection of this and b is empty or not in the plane orthogonal to the axis passed (X = 0, Y = 1 or Z = 2). + + \param b Bounds to test for intersection. + \param axisToIgnore Axis to ignore when performing the intersection test. + */ + NX_INLINE bool intersects2D(const NxBounds3& b, unsigned axisToIgnore) const; + + /** + \brief indicates if these bounds contain v. + + \param v Point to test against bounds. + */ + NX_INLINE bool contain(const NxVec3& v) const; + + /** + \brief returns the center of this axis aligned box. + + \param center The center of the bounds. + */ + NX_INLINE void getCenter(NxVec3& center) const; + + /** + \brief returns the dimensions (width/height/depth) of this axis aligned box. + + \param dims The dimensions of the bounds. + */ + NX_INLINE void getDimensions(NxVec3& dims) const; + + /** + \brief returns the extents, which are half of the width/height/depth. + + \param extents The extents/radii of the bounds. + */ + NX_INLINE void getExtents(NxVec3& extents) const; + + /** + \brief setups an AABB from center & extents vectors. + + \param c Center vector + \param e Extents vector + */ + NX_INLINE void setCenterExtents(const NxVec3& c, const NxVec3& e); + + /** + \brief scales the AABB. + + \param scale Factor to scale AABB by. + */ + NX_INLINE void scale(NxF32 scale); + + /** + fattens the AABB in all 3 dimensions by the given distance. + */ + NX_INLINE void fatten(NxReal distance); + + + //NX_INLINE void combine(NxReal extension); + + NxVec3 min, max; + }; + + +NX_INLINE NxBounds3::NxBounds3() + { + // Default to empty boxes for compatibility TODO: PT: remove this if useless + setEmpty(); + } + + +NX_INLINE NxBounds3::~NxBounds3() + { + //nothing + } + + +NX_INLINE void NxBounds3::setEmpty() + { + // We know use this particular pattern for empty boxes + set(NX_MAX_REAL, NX_MAX_REAL, NX_MAX_REAL, + NX_MIN_REAL, NX_MIN_REAL, NX_MIN_REAL); + } + +NX_INLINE void NxBounds3::setInfinite() + { + set(NX_MIN_REAL, NX_MIN_REAL, NX_MIN_REAL, + NX_MAX_REAL, NX_MAX_REAL, NX_MAX_REAL); + } + +NX_INLINE void NxBounds3::set(NxReal minx, NxReal miny, NxReal minz, NxReal maxx, NxReal maxy,NxReal maxz) + { + min.set(minx, miny, minz); + max.set(maxx, maxy, maxz); + } + +NX_INLINE void NxBounds3::set(const NxVec3& _min, const NxVec3& _max) + { + min = _min; + max = _max; + } + +NX_INLINE void NxBounds3::include(const NxVec3& v) + { + max.max(v); + min.min(v); + } + +NX_INLINE void NxBounds3::combine(const NxBounds3& b2) + { + // - if we're empty, min = MAX,MAX,MAX => min will be b2 in all cases => it will copy b2, ok + // - if b2 is empty, the opposite happens => keep us unchanged => ok + // => same behavior as before, automatically + min.min(b2.min); + max.max(b2.max); + } + +NX_INLINE void NxBounds3::boundsOfOBB(const NxMat33& orientation, const NxVec3& translation, const NxVec3& halfDims) + { + NxReal dimx = halfDims[0]; + NxReal dimy = halfDims[1]; + NxReal dimz = halfDims[2]; + + NxReal x = NxMath::abs(orientation(0,0) * dimx) + NxMath::abs(orientation(0,1) * dimy) + NxMath::abs(orientation(0,2) * dimz); + NxReal y = NxMath::abs(orientation(1,0) * dimx) + NxMath::abs(orientation(1,1) * dimy) + NxMath::abs(orientation(1,2) * dimz); + NxReal z = NxMath::abs(orientation(2,0) * dimx) + NxMath::abs(orientation(2,1) * dimy) + NxMath::abs(orientation(2,2) * dimz); + + set(-x + translation[0], -y + translation[1], -z + translation[2], x + translation[0], y + translation[1], z + translation[2]); + } + +NX_INLINE void NxBounds3::transform(const NxMat33& orientation, const NxVec3& translation) + { + // convert to center and extents form + NxVec3 center, extents; + getCenter(center); + getExtents(extents); + + center = orientation * center + translation; + boundsOfOBB(orientation, center, extents); + } + +NX_INLINE bool NxBounds3::isEmpty() const + { + // Consistency condition for (Min, Max) boxes: min < max + // TODO: PT: should we test against the explicit pattern ? + if(min.x < max.x) return false; + if(min.y < max.y) return false; + if(min.z < max.z) return false; + return true; + } + +NX_INLINE bool NxBounds3::intersects(const NxBounds3& b) const + { + if ((b.min.x > max.x) || (min.x > b.max.x)) return false; + if ((b.min.y > max.y) || (min.y > b.max.y)) return false; + if ((b.min.z > max.z) || (min.z > b.max.z)) return false; + return true; + } + +NX_INLINE bool NxBounds3::intersects2D(const NxBounds3& b, unsigned axis) const + { + // TODO: PT: could be static and like this: + // static unsigned i[3] = { 1,2,0,1 }; + // const unsigned ii = i[axis]; + // const unsigned jj = i[axis+1]; + const unsigned i[3] = { 1,0,0 }; + const unsigned j[3] = { 2,2,1 }; + const unsigned ii = i[axis]; + const unsigned jj = j[axis]; + if ((b.min[ii] > max[ii]) || (min[ii] > b.max[ii])) return false; + if ((b.min[jj] > max[jj]) || (min[jj] > b.max[jj])) return false; + return true; + } + +NX_INLINE bool NxBounds3::contain(const NxVec3& v) const + { + if ((v.x < min.x) || (v.x > max.x)) return false; + if ((v.y < min.y) || (v.y > max.y)) return false; + if ((v.z < min.z) || (v.z > max.z)) return false; + return true; + } + +NX_INLINE void NxBounds3::getCenter(NxVec3& center) const + { + center.add(min,max); + center *= NxReal(0.5); + } + +NX_INLINE void NxBounds3::getDimensions(NxVec3& dims) const + { + dims.subtract(max,min); + } + +NX_INLINE void NxBounds3::getExtents(NxVec3& extents) const + { + extents.subtract(max,min); + extents *= NxReal(0.5); + } + +NX_INLINE void NxBounds3::setCenterExtents(const NxVec3& c, const NxVec3& e) + { + min = c - e; + max = c + e; + } + +NX_INLINE void NxBounds3::scale(NxF32 scale) + { + NxVec3 center, extents; + getCenter(center); + getExtents(extents); + setCenterExtents(center, extents * scale); + } + +NX_INLINE void NxBounds3::fatten(NxReal distance) + { + min.x -= distance; + min.y -= distance; + min.z -= distance; + + max.x += distance; + max.y += distance; + max.z += distance; + } + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBox.h b/libraries/external/physx/Win32/include/PX/NxBox.h new file mode 100755 index 0000000..7c8a171 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBox.h @@ -0,0 +1,303 @@ +#ifndef NX_FOUNDATION_NXBOX +#define NX_FOUNDATION_NXBOX +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxVec3.h" +#include "PX/NxMat33.h" +#include "PX/NxMat34.h" + +class NxCapsule; +class NxPlane; +class NxBox; +class NxBounds3; + + +/** +\brief Represents an oriented bounding box. + +As a center point, extents(radii) and a rotation. i.e. the center of the box is at the center point, +the box is rotated around this point with the rotation and it is 2*extents in width, height and depth. +*/ +class NxBox + { + public: + /** + \brief Constructor + */ + NX_INLINE NxBox() + { + } + + /** + \brief Constructor + + \param _center Center of the OBB + \param _extents Extents/radii of the obb. + \param _rot rotation to apply to the obb. + */ + NX_INLINE NxBox(const NxVec3& _center, const NxVec3& _extents, const NxMat33& _rot) : center(_center), extents(_extents), rot(_rot) + { + } + + /** + \brief Destructor + */ + NX_INLINE ~NxBox() + { + } + + /** + \brief Setups an empty box. + */ + NX_INLINE void setEmpty() + { + center.zero(); + extents.set(NX_MIN_REAL, NX_MIN_REAL, NX_MIN_REAL); + rot.id(); + } +#ifdef FOUNDATION_EXPORTS + + /** + \brief Tests if a point is contained within the box + + See #NxBoxContainsPoint(). + + \param p [in] the world point to test + \return true if inside the box + */ + NX_INLINE bool containsPoint(const NxVec3& p) const + { + return NxBoxContainsPoint(*this, p); + } + + /** + \brief Builds a box from AABB and a world transform. + + See #NxCreateBox(). + + \param aabb [in] the aabb + \param mat [in] the world transform + */ + NX_INLINE void create(const NxBounds3& aabb, const NxMat34& mat) + { + NxCreateBox(*this, aabb, mat); + } +#endif + /** + \brief Recomputes the box after an arbitrary transform by a 4x4 matrix. + + \param mtx [in] the transform matrix + \param obb [out] the transformed OBB + */ + NX_INLINE void rotate(const NxMat34& mtx, NxBox& obb) const + { + obb.extents = extents;// The extents remain constant + obb.center = mtx.M * center + mtx.t; + obb.rot.multiply(mtx.M, rot); + } + + /** + \brief Checks the box is valid. + + \return true if the box is valid + */ + NX_INLINE bool isValid() const + { + // Consistency condition for (Center, Extents) boxes: Extents >= 0.0f + if(extents.x < 0.0f) return false; + if(extents.y < 0.0f) return false; + if(extents.z < 0.0f) return false; + return true; + } +#ifdef FOUNDATION_EXPORTS + + /** + \brief Computes the obb planes. + + See #NxComputeBoxPlanes(). + + \param planes [out] 6 box planes + \return true if success + */ + NX_INLINE bool computePlanes(NxPlane* planes) const + { + return NxComputeBoxPlanes(*this, planes); + } + + /** + \brief Computes the obb points. + + See #NxComputeBoxPoints(). + + \param pts [out] 8 box points + \return true if success + */ + NX_INLINE bool computePoints(NxVec3* pts) const + { + return NxComputeBoxPoints(*this, pts); + } + + /** + \brief Computes vertex normals. + + See #NxComputeBoxVertexNormals(). + + \param pts [out] 8 box points + \return true if success + */ + NX_INLINE bool computeVertexNormals(NxVec3* pts) const + { + return NxComputeBoxVertexNormals(*this, pts); + } + + /** + \brief Returns edges. + + See #NxGetBoxEdges(). + + \return 24 indices (12 edges) indexing the list returned by ComputePoints() + */ + NX_INLINE const NxU32* getEdges() const + { + return NxGetBoxEdges(); + } + + /** + \brief Return edge axes indices. + + See #NxgetBoxEdgeAxes(). + + \return Array of edge axes indices. + */ + + NX_INLINE const NxI32* getEdgesAxes() const + { + return NxGetBoxEdgesAxes(); + } + + /** + \brief Returns triangles. + + See #NxGetBoxTriangles(). + + + \return 36 indices (12 triangles) indexing the list returned by ComputePoints() + */ + NX_INLINE const NxU32* getTriangles() const + { + return NxGetBoxTriangles(); + } + + /** + \brief Returns local edge normals. + + See #NxGetBoxLocalEdgeNormals(). + + \return edge normals in local space + */ + NX_INLINE const NxVec3* getLocalEdgeNormals() const + { + return NxGetBoxLocalEdgeNormals(); + } + + /** + \brief Returns world edge normal + + See #NxComputeBoxWorldEdgeNormal(). + + \param edge_index [in] 0 <= edge index < 12 + \param world_normal [out] edge normal in world space + */ + NX_INLINE void computeWorldEdgeNormal(NxU32 edge_index, NxVec3& world_normal) const + { + NxComputeBoxWorldEdgeNormal(*this, edge_index, world_normal); + } + + /** + \brief Computes a capsule surrounding the box. + + See #NxComputeCapsuleAroundBox(). + + \param capsule [out] the capsule + */ + NX_INLINE void computeCapsule(NxCapsule& capsule) const + { + NxComputeCapsuleAroundBox(*this, capsule); + } + + /** + \brief Checks the box is inside another box + + See #NxIsBoxAInsideBoxB(). + + \param box [in] the other box + \return TRUE if we're inside the other box + */ + NX_INLINE bool isInside(const NxBox& box) const + { + return NxIsBoxAInsideBoxB(*this, box); + } +#endif + // Accessors + + /** + \brief Return center of box. + + \return Center of box. + */ + NX_INLINE const NxVec3& GetCenter() const + { + return center; + } + + /** + \brief Return extents(radii) of box. + + \return Extents of box. + */ + + NX_INLINE const NxVec3& GetExtents() const + { + return extents; + } + + /** + \brief return box rotation. + + \return Box Rotation. + */ + + NX_INLINE const NxMat33& GetRot() const + { + return rot; + } + +/* NX_INLINE void GetRotatedExtents(NxMat33& extents) const + { + extents = mRot; + extents.Scale(mExtents); + }*/ + + NxVec3 center; + NxVec3 extents; + NxMat33 rot; + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBoxForceFieldShape.h b/libraries/external/physx/Win32/include/PX/NxBoxForceFieldShape.h new file mode 100755 index 0000000..e2592ea --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBoxForceFieldShape.h @@ -0,0 +1,92 @@ +#ifndef NX_PHYSICS_NXBOXFORCEFIELDSHAPE +#define NX_PHYSICS_NXBOXFORCEFIELDSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxBoxForceFieldShapeDesc; + +/** + \brief Box shaped region used to define force field. + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShape +*/ +class NxBoxForceFieldShape : public NxForceFieldShape +{ + public: + /** + \brief Sets the box dimensions. + + The dimensions are the 'radii' of the box, meaning 1/2 extents in x dimension, + 1/2 extents in y dimension, 1/2 extents in z dimension. + + \param[in] vec The new 'radii' of the box. Range: direction vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxForceFieldShapeDesc.dimensions getDimensions() + */ + virtual void setDimensions(const NxVec3& vec) = 0; + + /** + \brief Retrieves the dimensions of the box. + + The dimensions are the 'radii' of the box, meaning 1/2 extents in x dimension, + 1/2 extents in y dimension, 1/2 extents in z dimension. + + \return The 'radii' of the box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxForceFieldShapeDesc.dimensions setDimensions() + */ + virtual NxVec3 getDimensions() const = 0; + + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxForceFieldShapeDesc + */ + virtual void saveToDesc(NxBoxForceFieldShapeDesc& desc) const=0; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBoxForceFieldShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxBoxForceFieldShapeDesc.h new file mode 100755 index 0000000..2ecf5c8 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBoxForceFieldShapeDesc.h @@ -0,0 +1,100 @@ +#ifndef NX_PHYSICS_NXBOXFORCEFIELDSHAPEDESC +#define NX_PHYSICS_NXBOXFORCEFIELDSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + + +/** + \brief A descriptor for NxBoxForceFieldShape + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxBoxForceFieldShape NxForceFieldShapeDesc NxBoxForceField +*/ +class NxBoxForceFieldShapeDesc : public NxForceFieldShapeDesc + { + public: + /** + \brief Dimensions of the box. + + The dimensions are the 'radii' of the box, meaning 1/2 extents in x dimension, + 1/2 extents in y dimension, 1/2 extents in z dimension. All three must be positive. + + Range: .x (0,inf) + Range: .y (0,inf) + Range: .z (0,inf) + Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxForceFieldShape.setDimensions() NxBoxForceFieldShape.getDimensions() + */ + NxVec3 dimensions; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxBoxForceFieldShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + + + }; + +NX_INLINE NxBoxForceFieldShapeDesc::NxBoxForceFieldShapeDesc() : NxForceFieldShapeDesc(NX_SHAPE_BOX) + { + setToDefault(); + } + +NX_INLINE void NxBoxForceFieldShapeDesc::setToDefault() + { + NxForceFieldShapeDesc::setToDefault(); + dimensions.set(1.0f, 1.0f, 1.0f); //note: NxBoxShape defaults to x0x0x but this is inconsistent with other shapes that are unity-sized by default. + } + +NX_INLINE bool NxBoxForceFieldShapeDesc::isValid() const + { + if(!dimensions.isFinite()) return false; + if(dimensions.x<0.0f) return false; + if(dimensions.y<0.0f) return false; + if(dimensions.z<0.0f) return false; + return NxForceFieldShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBoxShape.h b/libraries/external/physx/Win32/include/PX/NxBoxShape.h new file mode 100755 index 0000000..5c89edb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBoxShape.h @@ -0,0 +1,127 @@ +#ifndef NX_COLLISION_NXBOXSHAPE +#define NX_COLLISION_NXBOXSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" + +class NxBox; +class NxBoxShapeDesc; + +/** +\brief A box shaped collision detection primitive. + +Each shape is owned by the actor which it is attached to. + +

Creation

+ +An instance can be created by calling the createShape() method of the NxActor object +that will own it, with a NxBoxShapeDesc object as the parameter, or by adding the +shape descriptor to the NxActorDesc class before creating the actor. + +Example (adding shape descriptor to an NxActorDesc): + +\include NxBoxShape_CreateDesc.cpp + +Example (creating for an already existing actor): + +\include NxBoxShape_CreateWithActor.cpp + +The shape is deleted by calling NxActor::releaseShape() on the owning actor. + +

Visualizations

+\li NX_VISUALIZE_COLLISION_AABBS +\li NX_VISUALIZE_COLLISION_SHAPES +\li NX_VISUALIZE_COLLISION_AXES + +@see NxBoxShapeDesc NxShape NxActor.createShape() +*/ +class NxBoxShape: public NxShape + { + public: + /** + \brief Sets the box dimensions. + + The dimensions are the 'radii' of the box, meaning 1/2 extents in x dimension, + 1/2 extents in y dimension, 1/2 extents in z dimension. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] vec The new 'radii' of the box. Range: direction vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxShapeDesc.dimensions getDimensions() + */ + virtual void setDimensions(const NxVec3& vec) = 0; + + /** + \brief Retrieves the dimensions of the box. + + The dimensions are the 'radii' of the box, meaning 1/2 extents in x dimension, + 1/2 extents in y dimension, 1/2 extents in z dimension. + + \return The 'radii' of the box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxShapeDesc.dimensions setDimensions() + */ + virtual NxVec3 getDimensions() const = 0; + + /** + \brief Gets the box represented as a world space OBB. + + \param[out] obb The orientated bounding box in the global frame. See #NxBox. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox + */ + virtual void getWorldOBB(NxBox& obb) const = 0; + + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxShapeDesc + */ + virtual void saveToDesc(NxBoxShapeDesc& desc) const = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBoxShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxBoxShapeDesc.h new file mode 100755 index 0000000..a817048 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBoxShapeDesc.h @@ -0,0 +1,88 @@ +#ifndef NX_COLLISION_NXBOXSHAPEDESC +#define NX_COLLISION_NXBOXSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShapeDesc.h" + +/** +\brief Descriptor class for #NxBoxShape. + +@see NxBox NxShapeDesc NxActor.createShape() +*/ +class NxBoxShapeDesc : public NxShapeDesc + { + public: + /** + \brief Dimensions of the box. + + The dimensions are the 'radii' of the box, meaning 1/2 extents in x dimension, + 1/2 extents in y dimension, 1/2 extents in z dimension. All three must be positive. + + Range: .x (0,inf) + Range: .y (0,inf) + Range: .x (0,inf) + Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxShape.setDimensions() NxBoxShape.getDimensions() + */ + NxVec3 dimensions; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxBoxShapeDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxBoxShapeDesc::NxBoxShapeDesc() : NxShapeDesc(NX_SHAPE_BOX) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxBoxShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + dimensions.zero(); + } + +NX_INLINE bool NxBoxShapeDesc::isValid() const + { + if(!dimensions.isFinite()) return false; + if(dimensions.x<0.0f) return false; + if(dimensions.y<0.0f) return false; + if(dimensions.z<0.0f) return false; + return NxShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxBuildNumber.h b/libraries/external/physx/Win32/include/PX/NxBuildNumber.h new file mode 100755 index 0000000..a870542 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxBuildNumber.h @@ -0,0 +1,34 @@ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/* +This file has the repository build +number, and should be incremented +whenever the build number changes. + +It should only be included in files +that when changed dont force a massive recompile. +*/ + +/** \addtogroup foundation + @{ +*/ + +#include "PX/NxVersionNumber.h" + +#define NX_SDK_VERSION_BUILDNUM 4824 +#define NX_SDK_FULL_VERSION_STRING "2.1.2.4824" +// End.. + + /** @} */ +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCCDSkeleton.h b/libraries/external/physx/Win32/include/PX/NxCCDSkeleton.h new file mode 100755 index 0000000..3b942bc --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCCDSkeleton.h @@ -0,0 +1,66 @@ +#ifndef NX_PHYSICS_NXCCDSKELETON +#define NX_PHYSICS_NXCCDSKELETON +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** + \brief A mesh that is only used for continuous collision detection. +*/ +class NxCCDSkeleton + { + public: + /** + \brief saves out CCDSkeleton data. + + can be loaded again with NxPhysicsSDK::createCCDSkeleton(const void * , NxU32); + + returns number of bytes written. + */ + virtual NxU32 save(void * destBuffer, NxU32 bufferSize) = 0; + + /** + \brief returns number of bytes a call to ::save() will require. + */ + virtual NxU32 getDataSize() = 0; + + /** + \brief Returns the reference count for shared meshes. + + \return the current reference count, not used in any shapes if the count is 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getReferenceCount() = 0; + + /** + \brief writes the CCD skeleton back out as an NxSimpleTriangleMesh. + + \return The number of triangles in the skeleton or zero if failed. + */ + virtual NxU32 saveToDesc(NxSimpleTriangleMesh &desc) = 0; + + protected: + virtual ~NxCCDSkeleton(){}; + }; + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCapsule.h b/libraries/external/physx/Win32/include/PX/NxCapsule.h new file mode 100755 index 0000000..5d40e2f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCapsule.h @@ -0,0 +1,109 @@ +#ifndef NX_FOUNDATION_NXCAPSULE +#define NX_FOUNDATION_NXCAPSULE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxSegment.h" +#include "PX/NxSphere.h" + +class NxCapsule; +class NxBox; + +/** +\brief Represents a capsule. +*/ +class NxCapsule : public NxSegment + { + public: + /** + \brief Constructor + */ + NX_INLINE NxCapsule() + { + } + + /** + \brief Constructor + + \param seg Line segment to create capsule from. + \param _radius Radius of the capsule. + */ + NX_INLINE NxCapsule(const NxSegment& seg, NxF32 _radius) : NxSegment(seg), radius(_radius) + { + } + + /** + \brief Destructor + */ + NX_INLINE ~NxCapsule() + { + } + +#ifdef FOUNDATION_EXPORTS + + /** + Computes an OBB surrounding the capsule. + \param box [out] the OBB + */ + NX_INLINE void computeOBB(NxBox& box) const + { + NxComputeBoxAroundCapsule(*this, box); + } + /** + Tests if a point is contained within the capsule. + \param pt [in] the point to test + \return true if inside the capsule + \warning point and capsule must be in same space + */ + NX_INLINE bool contains(const NxVec3& pt) const + { + return squareDistance(pt) <= radius*radius; + } + + /** + Tests if a sphere is contained within the capsule. + \param sphere [in] the sphere to test + \return true if inside the capsule + \warning sphere and capsule must be in same space + */ + NX_INLINE bool contains(const NxSphere& sphere) const + { + NxF32 d = radius - sphere.radius; + if(d>=0.0f) return squareDistance(sphere.center) <= d*d; + else return false; + } + + /** + Tests if a capsule is contained within the capsule. + \param capsule [in] the capsule to test + \return true if inside the capsule + \warning both capsule must be in same space + */ + NX_INLINE bool contains(const NxCapsule& capsule) const + { + // We check the capsule contains the two spheres at the start and end of the sweep + return contains(NxSphere(capsule.p0, capsule.radius)) && contains(NxSphere(capsule.p1, capsule.radius)); + } +#endif + + NxF32 radius; + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCapsuleForceFieldShape.h b/libraries/external/physx/Win32/include/PX/NxCapsuleForceFieldShape.h new file mode 100755 index 0000000..b7762a8 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCapsuleForceFieldShape.h @@ -0,0 +1,134 @@ +#ifndef NX_PHYSICS_NXCAPSULEFORCEFIELDSHAPE +#define NX_PHYSICS_NXCAPSULEFORCEFIELDSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxCapsuleForceFieldShapeDesc; + +/** + \brief A capsule shaped region used to define a force field + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShape +*/ +class NxCapsuleForceFieldShape : public NxForceFieldShape + { + public: + /** + \brief Call this to initialize or alter the capsule. + + \param[in] radius The new radius of the capsule. Range: (0,inf) + \param[in] height The new height of the capsule. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setRadius() setHeight() + */ + virtual void setDimensions(NxReal radius, NxReal height) = 0; + + /** + \brief Alters the radius of the capsule. + + \param[in] radius The new radius of the capsule. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDimensions() NxCapsuleForceFieldShapeDesc.radius getRadius() + */ + virtual void setRadius(NxReal radius) = 0; + + /** + \brief Retrieves the radius of the capsule. + + \return The radius of the capsule. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setRadius() setDimensions() NxCapsuleForceFieldShapeDesc.radius + */ + virtual NxReal getRadius() const = 0; + + /** + \brief Alters the height of the capsule. + + \param[in] height The new height of the capsule. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getHeight() NxCapsuleForceFieldShapeDesc.height getRadius() setDimensions() + */ + virtual void setHeight(NxReal height) = 0; + + /** + \brief Retrieves the height of the capsule. + + \return The height of the capsule measured from end to end. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setHeight() setRadius() NxCapsuleForceFieldShapeDesc.height + */ + virtual NxReal getHeight() const = 0; + + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleForceFieldShapeDesc + */ + virtual void saveToDesc(NxCapsuleForceFieldShapeDesc& desc) const=0; +}; + + + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCapsuleForceFieldShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxCapsuleForceFieldShapeDesc.h new file mode 100755 index 0000000..58689ab --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCapsuleForceFieldShapeDesc.h @@ -0,0 +1,113 @@ +#ifndef NX_PHYSICS_NXCAPSULEFORCEFIELDSHAPEDESC +#define NX_PHYSICS_NXCAPSULEFORCEFIELDSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + + +/** + \brief A descriptor for NxCapsuleForceFieldShape + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShapeDesc NxCapsuleForceFieldShape NxForceField +*/ +class NxCapsuleForceFieldShapeDesc : public NxForceFieldShapeDesc + { + public: + /** + \brief Radius of the capsule's hemispherical ends and its trunk. + + Range: (0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleForceFieldShape.setRadius() NxCapsuleForceFieldShape.setDimensions() + */ + NxReal radius; + + /** + \brief The distance between the two hemispherical ends of the capsule. + + The height is along the capsule's Y axis. + + Range: (0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleForceFieldShape.setHeight() NxCapsuleForceFieldShape.setDimensions() + */ + NxReal height; //!< height of the capsule + + + /** + \brief constructor sets to default. + */ + NX_INLINE NxCapsuleForceFieldShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + }; + +NX_INLINE NxCapsuleForceFieldShapeDesc::NxCapsuleForceFieldShapeDesc() : NxForceFieldShapeDesc(NX_SHAPE_CAPSULE) + { + setToDefault(); + } + +NX_INLINE void NxCapsuleForceFieldShapeDesc::setToDefault() + { + NxForceFieldShapeDesc::setToDefault(); + radius = 1.0f; + height = 1.0f; + } + +NX_INLINE bool NxCapsuleForceFieldShapeDesc::isValid() const + { + if(!NxMath::isFinite(radius)) return false; + if(radius<=0.0f) return false; + if(!NxMath::isFinite(height)) return false; + if(height<=0.0f) return false; + return NxForceFieldShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCapsuleShape.h b/libraries/external/physx/Win32/include/PX/NxCapsuleShape.h new file mode 100755 index 0000000..2b5dac4 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCapsuleShape.h @@ -0,0 +1,173 @@ +#ifndef NX_COLLISION_NXCAPSULESHAPE +#define NX_COLLISION_NXCAPSULESHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" + +class NxShape; +class NxCapsule; +class NxCapsuleShapeDesc; + +/** +\brief A capsule shaped collision detection primitive, also known as a line swept sphere. + +'radius' is the radius of the capsule's hemispherical ends and its trunk. +'height' is the distance between the two hemispherical ends of the capsule. +The height is along the capsule's Y axis. + +Each shape is owned by an actor that it is attached to. + +

Creation

+ +An instance can be created by calling the createShape() method of the NxActor object +that should own it, with a NxCapsuleShapeDesc object as the parameter, or by adding the +shape descriptor into the NxActorDesc class before creating the actor. + +Example: + +\include NxCapsuleShape_Create.cpp + +The shape is deleted by calling NxActor::releaseShape() on the owning actor. + +

Visualizations

+\li NX_VISUALIZE_COLLISION_AABBS +\li NX_VISUALIZE_COLLISION_SHAPES +\li NX_VISUALIZE_COLLISION_AXES + +@see NxCapsuleShapeDesc NxShape NxActor.createShape() +*/ + +class NxCapsuleShape: public NxShape + { + public: + /** + \brief Call this to initialize or alter the capsule. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] radius The new radius of the capsule. Range: (0,inf) + \param[in] height The new height of the capsule. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setRadius() setHeight() + */ + virtual void setDimensions(NxReal radius, NxReal height) = 0; + + /** + \brief Alters the radius of the capsule. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] radius The new radius of the capsule. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDimensions() NxCapsuleShapeDesc.radius getRadius() + */ + virtual void setRadius(NxReal radius) = 0; + + /** + \brief Retrieves the radius of the capsule. + + \return The radius of the capsule. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setRadius() setDimensions() NxCapsuleShapeDesc.radius + */ + virtual NxReal getRadius() const = 0; + + /** + \brief Alters the height of the capsule. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] height The new height of the capsule. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getHeight() NxCapsuleShapeDesc.height getRadius() setDimensions() + */ + virtual void setHeight(NxReal height) = 0; + + /** + \brief Retrieves the height of the capsule. + + \return The height of the capsule measured from end to end. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setHeight() setRadius() NxCapsuleShapeDesc.height + */ + virtual NxReal getHeight() const = 0; + + /** + \brief Retrieves the capsule parameters in world space. See #NxCapsule. + + \param[out] worldCapsule Use to retrieve the capsule parameters in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsule + */ + virtual void getWorldCapsule(NxCapsule& worldCapsule) const = 0; + + /* + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save the state of the object to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleShapeDesc + */ + virtual void saveToDesc(NxCapsuleShapeDesc& desc) const = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCapsuleShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxCapsuleShapeDesc.h new file mode 100755 index 0000000..fb39e8d --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCapsuleShapeDesc.h @@ -0,0 +1,118 @@ +#ifndef NX_COLLISION_NXCAPSULESHAPEDESC +#define NX_COLLISION_NXCAPSULESHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxCapsuleShape.h" +#include "PX/NxShapeDesc.h" +/** +\brief Descriptor class for #NxCapsuleShape. + +@see NxCapsuleShape NxShapeDesc NxActor.createShape() NxCapsule +*/ +class NxCapsuleShapeDesc : public NxShapeDesc + { + public: + /** + \brief Radius of the capsule's hemispherical ends and its trunk. + + Range: (0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleShape.setRadius() NxCapsuleShape.setDimensions() + */ + NxReal radius; + + /** + \brief The distance between the two hemispherical ends of the capsule. + + The height is along the capsule's Y axis. + + Range: (0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleShape.setHeight() NxCapsuleShape.setDimensions() + */ + NxReal height; + + /** + \brief Combination of ::NxCapsuleShapeFlag + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleShapeFlag + */ + NxU32 flags; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxCapsuleShapeDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxCapsuleShapeDesc::NxCapsuleShapeDesc() : NxShapeDesc(NX_SHAPE_CAPSULE) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxCapsuleShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + radius = 1.0f; + height = 1.0f; + flags = 0; + } + +NX_INLINE bool NxCapsuleShapeDesc::isValid() const + { + if(!NxMath::isFinite(radius)) return false; + if(radius<=0.0f) return false; + if(!NxMath::isFinite(height)) return false; + if(height<=0.0f) return false; + return NxShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxClothUserNotify.h b/libraries/external/physx/Win32/include/PX/NxClothUserNotify.h new file mode 100755 index 0000000..b638547 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxClothUserNotify.h @@ -0,0 +1,41 @@ +#ifndef NX_PHYSICS_NXCLOTHUSERNOTIFY +#define NX_PHYSICS_NXCLOTHUSERNOTIFY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics +@{ +*/ + + +#include "PX/Nxp.h" + +class NxCloth; + +/** +\brief An interface class that the user can implement in order to receive simulation events. + +Threading: It is not necessary to make this class thread safe as it will only be called in the context of the +user thread. + +See the NxUserNotify documentation for an example of how to use notifications. + +@see NxScene.setClothUserNotify() NxScene.getClothUserNotify() NxUserNotify +*/ +class NxClothUserNotify +{ + virtual ~NxClothUserNotify(){}; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCompartment.h b/libraries/external/physx/Win32/include/PX/NxCompartment.h new file mode 100755 index 0000000..8a0da3a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCompartment.h @@ -0,0 +1,200 @@ +#ifndef NX_PHYSICS_NX_COMPARTMENT +#define NX_PHYSICS_NX_COMPARTMENT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxCompartmentDesc.h" + +/** +\brief A scene compartment is a portion of the scene that can +be simulated on a different hardware device than other parts of the scene. + +Note: You cannot release scene compartments explicitly, they are automatically released when the scene is released. +To create a compartment, call NxScene::createCompartment() +*/ +class NxCompartment + { + public: + /** + \return the compartment simulation type. Will be removed in 3.0, as compartments will become type-neutral. + */ + virtual NxCompartmentType getType() const = 0; + + /** + \brief The device code that is specified when creating a compartment or the automatically + assigned device code, if NX_DC_PPU_AUTO_ASSIGN was used. + + \return the ::NxDeviceCode of the compartment. + */ + virtual NxU32 getDeviceCode() const = 0; + + /** + \return the paging grid cell size. + */ + virtual NxReal getGridHashCellSize() const = 0; + + /** + \return the paging grid power. + */ + virtual NxU32 gridHashTablePower() const = 0; + + /** + \brief Sets the time scale for the compartment. + + @see NxCompartmentDesc::timeScale getTimeScale + */ + virtual void setTimeScale(NxReal) = 0; + + /** + \return the time scale for the compartment. + + @see NxCompartmentDesc::timeScale setTimeScale + */ + virtual NxReal getTimeScale() const = 0; + + /** + \brief Sets simulation timing parameters used to simulate the compartment. + + The initial default settings are inherited from the primary scene. + + If method is NX_TIMESTEP_FIXED, elapsedTime(simulate() parameter) is internally subdivided into up to + maxIter substeps no larger than maxTimestep. + + If elapsedTime is not a multiple of maxTimestep then any remaining time is accumulated + to be added onto the elapsedTime for the next time step. + + If more sub steps than maxIter are needed to advance the simulation by elapsed time, then + the remaining time is also accumulated for the next call to simulate(). + + The timestep method of TIMESTEP_FIXED is strongly preferred for stable, reproducible simulation. + + Alternatively NX_TIMESTEP_VARIABLE can be used, in this case the first two parameters + are not used. See also ::NxTimeStepMethod. + + \param[in] maxTimestep Maximum size of a substep. Range: (0,inf) + \param[in] maxIter Maximum number of iterations to divide a timestep into. + \param[in] method Method to use for timestep (either variable time step or fixed). See #NxTimeStepMethod. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setTimeScale() getTiming() + */ + virtual void setTiming(NxReal maxTimestep=1.0f/60.0f, NxU32 maxIter=8, NxTimeStepMethod method=NX_TIMESTEP_FIXED) = 0; + + /** + \brief Retrieves simulation timing parameters. + + \param[in] maxTimestep Maximum size to divide a substep into. Range: (0,inf) + \param[in] maxIter Maximum number of iterations to divide a timestep into. + \param[in] method Method to use for timestep (either variable time step or fixed). See #NxTimeStepMethod. + \param[in] numSubSteps The number of sub steps the time step will be divided into. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setTiming() setTimeScale() + */ + virtual void getTiming(NxReal& maxTimestep, NxU32& maxIter, NxTimeStepMethod& method, NxU32* numSubSteps=NULL) const = 0; + + + + /** + \brief This checks to see if the simulation of the objects in this compartment has completed. + + This does not cause the data available for reading to be updated with the results of the simulation, it is simply a status check. + The bool will allow it to either return immediately or block waiting for the condition to be met so that it can return true + + \param[in] block When set to true will block until the condition is met. + \return True if the results are available. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool checkResults(bool block = false) = 0; + + /** + This is the big brother to checkResults() it basically makes the results of the compartment's simulation readable. + + + The entire scene incl. the compartments will still be locked for writing until you call fetchResults(NX_RIGID_BODY_FINISHED). + + \param[in] block When set to true will block until the condition is met. + \return True if the results have been fetched. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool fetchResults(bool block = false) = 0; + + /** + \brief Saves the compartment to a descriptor. Please note that the device code will be the same as the + value returned by getDeviceCode(), i.e. not necessarily the same as the value you assigned when first + creating the compartment (when using auto-assign). + + \return true + */ + virtual bool saveToDesc(NxCompartmentDesc& desc) const = 0; + + /** + \brief Sets the compartment flags, a combination of the bits defined by the enum ::NxCompartmentFlag. + + \param[in] flags #NxCompartmentFlag combination. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartmentDesc.flags NxCompartmentFlag getFlags() + */ + + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief Retrieves the compartment flags. + + \return The compartment flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartmentDesc.flags NxCompartmentFlag setFlags() + */ + virtual NxU32 getFlags() const = 0; + + protected: + virtual ~NxCompartment(){}; + }; + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCompartmentDesc.h b/libraries/external/physx/Win32/include/PX/NxCompartmentDesc.h new file mode 100755 index 0000000..01d9d61 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCompartmentDesc.h @@ -0,0 +1,106 @@ +#ifndef NX_PHYSICS_NX_COMPARTMENT_DESC +#define NX_PHYSICS_NX_COMPARTMENT_DESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +enum NxCompartmentType + { + NX_SCT_RIGIDBODY = 0, + NX_SCT_FLUID = 1, + NX_SCT_CLOTH = 2, + NX_SCT_SOFTBODY = 2 //!< Currently SoftBody and Cloth use the same compartments, so you can create SoftBodies in a Cloth compartment. This might change in future versions. + }; + +enum NxDeviceCode + { + NX_DC_PPU_0 = 0, //!< Explicit PPU index corresponds to index numeric value (reserved for future use, currently only PPU 0 is valid) + NX_DC_PPU_1 = 1, + NX_DC_PPU_2 = 2, + NX_DC_PPU_3 = 3, + NX_DC_PPU_4 = 4, + NX_DC_PPU_5 = 5, + NX_DC_PPU_6 = 6, + NX_DC_PPU_7 = 7, + NX_DC_PPU_8 = 8, + // ... + + NX_DC_CPU = 0xffff0000, //!< Compartment is to be simulated on CPU + NX_DC_PPU_AUTO_ASSIGN = 0xffff0001, //!< Compartment is to be simulated on a processor (PPU or CPU) chosen by the HSM for best performance (CPU is only used in the absence of a PPU). + }; + + +/** +\brief Descriptor class for NxCompartment. A compartment is a portion of the scene that can +be simulated on a different hardware device than other parts of the scene. +*/ +class NxCompartmentDesc + { + public: + NxCompartmentType type; //!< Compartment meant for this type of simulation. Will be removed in 3.0, as comparments will become type-neutral. Cloth type compartments must have a non-CPU device code. + + /** + \brief A NxDeviceCode, incl. a PPU index from 0 to 31. + @see NxDeviceCode + */ + NxU32 deviceCode; + NxReal gridHashCellSize; //!< Size in distance units of a single cell in the paging grid. Should be set to the size of the largest common dynamic object in this compartment. + NxU32 gridHashTablePower; //!< 2-power used to determine size of the hash table that geometry gets hashed into. Hash table size is (1 << gridHashTablePower). + NxU32 flags; //!< Combination of ::NxCompartmentFlag values + NxU32 threadMask; //!< Thread affinity mask for the compartment thread. Defaults to 0 which means the SDK determines the affinity. + + /** + \brief It is possible to scale the simulation time steps of this compartment relative to the primary scene using this nonnegative value. A scale of zero does not simulate the compartment. The default value is 1.0f. + + Note: The time scale is taken into account after the number of substeps has been calculated. This means that the maximum timestep setting of the compartment can be exceeded when timeScale is above 1.0f. + */ + NxReal timeScale; + + NX_INLINE void setToDefault() + { + type = NX_SCT_RIGIDBODY; + deviceCode = NX_DC_CPU; + gridHashCellSize = 100.0f; //was 2.0f in 2.5, bumped up. + gridHashTablePower = 8; + flags = NX_CF_INHERIT_SETTINGS; + timeScale = 1.0f; + threadMask = 0; + } + + /** + \brief Returns true if the descriptor is valid. + + \return return true if the current settings are valid + */ + + NX_INLINE bool isValid() const + { + if (deviceCode != NX_DC_PPU_0 && + deviceCode != NX_DC_PPU_AUTO_ASSIGN && + deviceCode != NX_DC_CPU) + return false; + if (timeScale < 0.0f) + return false; + return (type <= NX_SCT_CLOTH) && (gridHashCellSize > 0.0f); + } + + NxCompartmentDesc() + { + setToDefault(); + } + }; + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxContactStreamIterator.h b/libraries/external/physx/Win32/include/PX/NxContactStreamIterator.h new file mode 100755 index 0000000..ee51187 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxContactStreamIterator.h @@ -0,0 +1,515 @@ +#ifndef NX_PHYSICS_NXCONTACTSTREAMITERATOR +#define NX_PHYSICS_NXCONTACTSTREAMITERATOR +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxShape; + +typedef NxU32 * NxContactStream; +typedef const NxU32 * NxConstContactStream; + + +/** +\brief Flags which describe a contact + +@see NxContactStreamIterator +*/ +enum NxShapePairStreamFlags + { + NX_SF_HAS_MATS_PER_POINT = (1<<0), //!< not used + NX_SF_HAS_FEATURES_PER_POINT = (1<<2), //!< the stream includes per-point feature data + //note: bits 8-15 are reserved for internal use (static ccd pullback counter) + }; + +/** +\brief NxContactStreamIterator is for iterating through packed contact streams. + +

The user code to use this iterator looks like this: +\code +void MyUserContactInfo::onContactNotify(NxContactPair & pair, NxU32 events) + { + NxContactStreamIterator i(pair.stream); + + while(i.goNextPair()) // user can call getNumPairs() here + { + while(i.goNextPatch()) // user can also call getShape() and getNumPatches() here + { + while(i.goNextPoint()) //user can also call getPatchNormal() and getNumPoints() here + { + //user can also call getPoint() and getSeparation() here + } + } + } + } +\endcode +

+ +\note It is NOT OK to skip any of the iteration calls. For example, you may NOT put a break or a continue +statement in any of the above blocks, short of completely aborting the iteration and deleting the +NxContactStreamIterator object. + +\note The user should not rely on the exact geometry or positioning of contact points. The SDK is free +to re-organise, merge or move contact points as long as the overall physical simulation is not affected.

+ +

Visualizations:

+\li #NX_VISUALIZE_CONTACT_POINT +\li #NX_VISUALIZE_CONTACT_NORMAL +\li #NX_VISUALIZE_CONTACT_ERROR +\li #NX_VISUALIZE_CONTACT_FORCE + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxConstContactStream NxUserContactReport +*/ + +class NxContactStreamIterator + { + public: + /** + \brief Starts the iteration, and returns the number of pairs. + + \param[in] stream + + @see NxConstContactStream + */ + NX_INLINE NxContactStreamIterator(NxConstContactStream stream); + +//iteration: + + + /** + \brief Goes on to the next pair, silently skipping invalid pairs. + + Returns false if there are no more pairs. Note that getNumPairs() also includes invalid pairs in the count. + + Once goNextPoint() returns false, the user should not call it again. + + \return True if there are more pairs. + + @see getNumPairs() getShape() + */ + NX_INLINE bool goNextPair(); + + /** + \brief Goes on to the next patch (contacts with the same normal). + + Returns false if there are no more. Once goNextPatch() returns false, the user should + not call it again until they move to the next pair. + + \return True if there are more patches. + + @see getPatchNormal() + */ + NX_INLINE bool goNextPatch(); + + /** + \brief Goes on to the next contact point. + + Returns false if there are no more. Once goNextPoint() returns false, the user should + not call it again unil they move to the next patch. + + \return True if there are more contact points. + + @see getPoint() + */ + NX_INLINE bool goNextPoint(); + +//accessors: + + /** + \brief Returns the number of pairs in the structure. + + May be called at any time. + + \return The number of pairs in the struct (including invalid pairs). + + @see goNextPair() + */ + NX_INLINE NxU32 getNumPairs(); + + /** + \brief Retrieves the shapes for the current pair. + + May be called after goNextPair() returned true. ShapeIndex is 0 or 1. + + \param[in] shapeIndex Used to choose which of the pair of shapes to retrieve(set to 0 or 1). + \return The shape specified by shapeIndex. + + @see goNextPair() NxShape + */ + NX_INLINE NxShape * getShape(NxU32 shapeIndex); + + /** + \brief Retrieves the shape flags for the current pair. + + May be called after goNextPair() returned true + + \return The shape flags for the current pair. See #NxShapeFlag. + + @see NxShapeFlag NxShape goNextPair() + */ + NX_INLINE NxU16 getShapeFlags(); + + /** + \brief Retrieves the number of patches for the current pair. + + May be called after goNextPair() returned true + + \return The number of patches in this pair. + + @see goNextPatch() + */ + NX_INLINE NxU32 getNumPatches(); + + /** + \brief Retrieves the number of remaining patches. + + May be called after goNextPair() returned true + + \return The number of patches remaining in this pair. + + @see goNextPatch() getNumPatches() + */ + NX_INLINE NxU32 getNumPatchesRemaining(); + + /** + \brief Retrieves the patch normal. + + May be called after goNextPatch() returned true + + \return The patch normal. + + @see goNextPatch() + */ + NX_INLINE const NxVec3 & getPatchNormal(); + + /** + \brief Retrieves the number of points in the current patch. + + May be called after goNextPatch() returned true + + \return The number of points in the current patch. + + @see goNextPoint() getNumPointsRemaining() + */ + NX_INLINE NxU32 getNumPoints(); + + /** + \brief Retrieves the number of points remaining in the current patch. + + May be called after goNextPatch() returned true + + \return The number of points remaining in the current patch. + + @see goNextPoint() getNumPoints() + */ + NX_INLINE NxU32 getNumPointsRemaining(); + + /** + \brief Returns the contact point position. + + May be called after goNextPoint() returned true + + \return the current contact point + + @see getShapeFlags() goNextPoint() getNumPoints() getSeparation() getFeatureIndex0() + */ + NX_INLINE const NxVec3 & getPoint(); + + /** + \brief Return the separation for the contact point. + + May be called after goNextPoint() returned true + + \return the seperation distance for the current point. + + @see goNextPoint() getPoint() + */ + NX_INLINE NxReal getSeparation(); + + /** + \brief Retrieves the feature index. + + Feature indices are only defined for triangle mesh and heightfield shapes. + + A feature index for a triangle mesh shape is the pre cooked triangle index. For a + heightfield shape a feature index is a triangle index as specified on creation, including + holes in the index. + + May be called after goNextPoint() returned true + If getShapeFlags()&NX_SF_HAS_FEATURES_PER_POINT is specified, this method returns a feature belonging to shape 0, + + \return The feature index on shape 0 for the current point. + + @see NX_SF_FEATURE_INDICES goNextPoint() getPoint() getSeparation() getFeatureIndex1() + */ + NX_INLINE NxU32 getFeatureIndex0(); + + /** + \brief Retrieves the feature index. + + may be called after goNextPoint() returned true + If getShapeFlags()&NX_SF_HAS_FEATURES_PER_POINT is specified, this method returns a feature belonging to shape 1, + + \return The feature index on shape1 for the current point. + + @see NX_SF_FEATURE_INDICES goNextPoint() getPoint() getSeparation() getFeatureIndex0() + */ + NX_INLINE NxU32 getFeatureIndex1(); + + + /** + \brief Retrieves the point normal force. + + May be called after goNextPoint() returned true + + If getShapeFlags()&NX_SF_POINT_CONTACT_FORCE is true (this is the case if this flag is raised for either shape in the pair), + this method returns the contact force at this contact point. + Returns 0 otherwise. + + \return The contact force for the current point. + + @see getShapeFlags goNextPoint() getPoint() + */ + NX_INLINE NxReal getPointNormalForce(); + + private: + //iterator variables -- are only initialized by stream iterator calls: + //Note: structs are used so that we can leave the iterators vars on the stack as they were + //and the user's iteration code doesn't have to change when we add members. + + //The number of pairs in the structure + NxU32 numPairs; + + //The shapes for the current pair + NxShape * shapes[2]; + //The shape flags for the current pair. + NxU16 shapeFlags; + //The number of patches for the current pair. + NxU16 numPatches; + + //The patch normal. + const NxVec3 * patchNormal; + //The number of points in the current patch. + NxU32 numPoints; + + //The contact point position. + const NxVec3 * point; + //The separation for the contact point. + NxReal separation; + //The feature index on shape 0. + NxU32 featureIndex0; + //The feature index on shape 1. + NxU32 featureIndex1; + + //Number of pairs remaining in the stream + NxU32 numPairsRemaining; + //Number of contact patches remaining for the current pair + NxU32 numPatchesRemaining; + //Number of contact points remaining in the current patch + NxU32 numPointsRemaining; + + protected: + /** + \brief Normal force for the current point + + Only exists if (shapeFlags & NX_SF_POINT_CONTACT_FORCE) + */ + const NxReal * pointNormalForce; + + /** + \brief The associated stream + */ + NxConstContactStream stream; + }; + +NX_INLINE NxContactStreamIterator::NxContactStreamIterator(NxConstContactStream s) + { + stream = s; + numPairsRemaining = numPairs = stream ? *stream++ : 0; + } + +NX_INLINE NxU32 NxContactStreamIterator::getNumPairs() + { + return numPairs; + } + +NX_INLINE NxShape * NxContactStreamIterator::getShape(NxU32 shapeIndex) + { + NX_ASSERT(shapeIndex<=1); + return shapes[shapeIndex]; + } + +NX_INLINE NxU16 NxContactStreamIterator::getShapeFlags() + { + return shapeFlags; + } + +NX_INLINE NxU32 NxContactStreamIterator::getNumPatches() + { + return numPatches; + } + +NX_INLINE NxU32 NxContactStreamIterator::getNumPatchesRemaining() + { + return numPatchesRemaining; + } + +NX_INLINE const NxVec3 & NxContactStreamIterator::getPatchNormal() + { + return *patchNormal; + } + +NX_INLINE NxU32 NxContactStreamIterator::getNumPoints() + { + return numPoints; + } + +NX_INLINE NxU32 NxContactStreamIterator::getNumPointsRemaining() + { + return numPointsRemaining; + } + +NX_INLINE const NxVec3 & NxContactStreamIterator::getPoint() + { + return *point; + } + +NX_INLINE NxReal NxContactStreamIterator::getSeparation() + { + return separation; + } + +NX_INLINE NxU32 NxContactStreamIterator::getFeatureIndex0() + { + return featureIndex0; + } +NX_INLINE NxU32 NxContactStreamIterator::getFeatureIndex1() + { + return featureIndex1; + } + +NX_INLINE NxReal NxContactStreamIterator::getPointNormalForce() + { + return pointNormalForce ? *pointNormalForce : 0; + } + +NX_INLINE bool NxContactStreamIterator::goNextPair() + { + while (numPairsRemaining--) + { +#ifdef NX32 + size_t bin0 = *stream++; + size_t bin1 = *stream++; + shapes[0] = (NxShape*)bin0; + shapes[1] = (NxShape*)bin1; +// shapes[0] = (NxShape*)*stream++; +// shapes[1] = (NxShape*)*stream++; +#else + NxU64 low = (NxU64)*stream++; + NxU64 high = (NxU64)*stream++; + NxU64 bits = low|(high<<32); + shapes[0] = (NxShape*)bits; + low = (NxU64)*stream++; + high = (NxU64)*stream++; + bits = low|(high<<32); + shapes[1] = (NxShape*)bits; +#endif + NxU32 t = *stream++; + numPatchesRemaining = numPatches = t & 0xffff; + shapeFlags = t >> 16; + return true; + + } + return false; + } + +NX_INLINE bool NxContactStreamIterator::goNextPatch() + { + if (numPatchesRemaining--) + { + patchNormal = reinterpret_cast(stream); + stream += 3; + numPointsRemaining = numPoints = *stream++; + return true; + } + else + return false; + } + +NX_INLINE bool NxContactStreamIterator::goNextPoint() + { + if (numPointsRemaining--) + { + // Get contact point + point = reinterpret_cast(stream); + stream += 3; + + // Get separation + NxU32 binary = *stream++; + NxU32 is32bits = binary & NX_SIGN_BITMASK; + binary |= NX_SIGN_BITMASK; // PT: separation is always negative, but the sign bit is used + // for other purposes in the stream. + // To avoid strict-aliasing warnings on gcc, unions are used to read from the stream. + // Note: You will still get a warning if gcc -Wstrict-aliasing=2 is used but this is a false positive. + NxU32F32* sep = reinterpret_cast(&binary); + separation = sep->f; + + if (shapeFlags & NX_SF_POINT_CONTACT_FORCE) + pointNormalForce = reinterpret_cast(stream++); + else + pointNormalForce = 0; //there is no contact force. + + + if (shapeFlags & NX_SF_HAS_FEATURES_PER_POINT) + { + if(is32bits) + { + featureIndex0 = *stream++; + featureIndex1 = *stream++; + } + else + { + featureIndex0 = *stream++; + featureIndex1 = featureIndex0>>16; + featureIndex0 &= 0xffff; + } + } + else + { + featureIndex0 = 0xffffffff; + featureIndex1 = 0xffffffff; + } + + //bind = *stream++; + //materialIDs[0] = bind & 0xffff; + //materialIDs[1] = bind >> 16; + + return true; + } + else + return false; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxConvexForceFieldShape.h b/libraries/external/physx/Win32/include/PX/NxConvexForceFieldShape.h new file mode 100755 index 0000000..23931e1 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxConvexForceFieldShape.h @@ -0,0 +1,56 @@ +#ifndef NX_PHYSICS_NXCONVEXFORCEFIELDSHAPE +#define NX_PHYSICS_NXCONVEXFORCEFIELDSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxConvexForceFieldShapeDesc; + +/** + \brief Convex shaped region used to define force field. + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShape +*/ +class NxConvexForceFieldShape : public NxForceFieldShape +{ +public: + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexForceFieldShapeDesc + */ + virtual void saveToDesc(NxConvexForceFieldShapeDesc& desc) const=0; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxConvexForceFieldShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxConvexForceFieldShapeDesc.h new file mode 100755 index 0000000..bbdb142 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxConvexForceFieldShapeDesc.h @@ -0,0 +1,91 @@ +#ifndef NX_PHYSICS_NXCONVEXFORCEFIELDSHAPEDESC +#define NX_PHYSICS_NXCONVEXFORCEFIELDSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** + \brief A descriptor for NxConvexForceFieldShape + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxConvexForceFieldShape NxForceFieldShapeDesc +*/ +class NxConvexForceFieldShapeDesc : public NxForceFieldShapeDesc + { + public: + + /** + \brief References the triangle mesh that we want to instance. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexMesh NxConvexMeshDesc NxPhysicsSDK.createConvexMesh() + */ + NxConvexMesh* meshData; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxConvexForceFieldShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + + + }; + +NX_INLINE NxConvexForceFieldShapeDesc::NxConvexForceFieldShapeDesc() : NxForceFieldShapeDesc(NX_SHAPE_CONVEX) + { + setToDefault(); + } + +NX_INLINE void NxConvexForceFieldShapeDesc::setToDefault() + { + NxForceFieldShapeDesc::setToDefault(); + meshData = NULL; + } + +NX_INLINE bool NxConvexForceFieldShapeDesc::isValid() const + { + if(!meshData) return false; + return NxForceFieldShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxConvexMesh.h b/libraries/external/physx/Win32/include/PX/NxConvexMesh.h new file mode 100755 index 0000000..240b775 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxConvexMesh.h @@ -0,0 +1,221 @@ +#ifndef NX_COLLISION_NXCONVEXMESH +#define NX_COLLISION_NXCONVEXMESH +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxTriangleMesh.h" + +class NxSimpleTriangleMesh; +class NxConvexMeshDesc; +class NxStream; + +/** +\brief A Convex Mesh. + +Internally represented as a list of convex polygons. The number +of polygons is limited to 256. + +To avoid duplicating data when you have several instances of a particular +mesh positioned differently, you do not use this class to represent a +convex object directly. Instead, you create an instance of this mesh via +the NxConvexShape class. + +

Creation

+ +

Creation

+ +To create an instance of this class call NxPhysicsSDK::createConvexMesh(), +and NxPhysicsSDK::releaseConvexMesh() to delete it. This is only possible +once you have released all of its #NxConvexShape instances. + +Example: + +\include NxConvexMesh_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_COLLISION_AABBS +\li #NX_VISUALIZE_COLLISION_SHAPES +\li #NX_VISUALIZE_COLLISION_AXES +\li #NX_VISUALIZE_COLLISION_VNORMALS +\li #NX_VISUALIZE_COLLISION_FNORMALS +\li #NX_VISUALIZE_COLLISION_EDGES +\li #NX_VISUALIZE_COLLISION_SPHERES + +@see NxConvexMeshDesc NxPhysics.createConvexMesh() +*/ + +class NxConvexMesh + { + public: + /** + \brief Saves the mesh to a descriptor. + + \param[out] desc Descriptor to store the state of the convex mesh into. + + \return true on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexMeshDesc + */ + virtual bool saveToDesc(NxConvexMeshDesc& desc) const = 0; + + /** + \brief Not used. + + */ + virtual NxU32 getSubmeshCount() const = 0; + + /** + \brief Retrieves the number of elements of a given internal array. + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array size to retrieve (e.g. triangles, vertices etc). See #NxInternalArray. + + \return The number of elements in the internal array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getFormat() getBase() getStride() + */ + virtual NxU32 getCount(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the format of a given internal array. + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array format to retrieve (e.g. triangles, vertices etc). See #NxInternalArray. + + \return The format of the internal array. See #NxInternalFormat. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCount() getBase() getStride() + */ + virtual NxInternalFormat getFormat(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the base pointer of a given internal array. + + Make sure you take into account the given format and stride. + + @see getStride + @see getFormat + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array pointer to retrieve (e.g. triangles, vertices etc). See #NxInternalArray. + + \return A pointer to the first element of the internal array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCount() getFormat() getStride() + */ + virtual const void* getBase(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the stride value of a given internal array. + + The stride value is always a number of bytes. You have to skip this number of bytes + to go from one element to the other in an array, starting from the base. + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array stride to retrieve (e.g. triangles, vertices etc). See #NxInternalArray. + + \return The stride(number of bytes from one element to the next) for the internal array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCount() getFormat() getBase() + */ + virtual NxU32 getStride(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Load the contents of this mesh from the provided stream. + + A stream of an appropriate format can be creating with the cooking library. + + \param[in] stream Stream to load this mesh from. See #NxStream. + \return True if successfully loaded. Otherwise False. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback for > 32 faces or vertices) + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool load(const NxStream& stream) = 0; + + /** + \brief Returns the reference count for shared meshes. + + \return the current reference count, not used in any shapes if the count is 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getReferenceCount() = 0; + + /** + \brief Returns the mass properties of the mesh. + + \param[out] mass The mass of the mesh. + \param[out] localInertia The inertia tensor in mesh local space. + \param[out] localCenterOfMass Position of center of mass in mesh local space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void getMassInformation(NxReal& mass, NxMat33& localInertia, NxVec3& localCenterOfMass) const = 0; + + + // TODO(djs): remove + virtual void * getInternal() = 0; + + protected: + virtual ~NxConvexMesh(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxConvexMeshDesc.h b/libraries/external/physx/Win32/include/PX/NxConvexMeshDesc.h new file mode 100755 index 0000000..7815695 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxConvexMeshDesc.h @@ -0,0 +1,261 @@ +#ifndef NX_COLLISION_NXCONVEXMESHDESC +#define NX_COLLISION_NXCONVEXMESHDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxConvexMesh.h" + +/** +\brief Flags which describe the format and behavior of a convex mesh. +*/ +enum NxConvexFlags + { + /** + \brief Used to flip the normals if the winding order is reversed. + + The Nx libraries assume that the face normal of a triangle with vertices [a,b,c] can be computed as: + edge1 = b-a + edge2 = c-a + face_normal = edge1 x edge2. + + Note: this is the same as counterclockwise winding in a right handed graphics coordinate system. + + If this does not match the winding order for your triangles, raise the below flag. + */ + NX_CF_FLIPNORMALS = (1<<0), + + /** + Denotes the use of 16-bit vertex indices in NxConvexMeshDesc::triangles. + (otherwise, 32-bit indices are assumed) + @see #NxConvexMeshDesc.triangles + */ + NX_CF_16_BIT_INDICES = (1<<1), + + /** + Automatically recomputes the hull from the vertices. If this flag is not set, you must provide the entire geometry manually. + */ + NX_CF_COMPUTE_CONVEX = (1<<2), + + /** + \brief Inflates the convex object according to skin width + + \note This flag is only used in combination with NX_CF_COMPUTE_CONVEX. + + @see NxCookingParams + */ + NX_CF_INFLATE_CONVEX = (1<<3), + + /** + \brief Instructs cooking to save normals uncompressed. The cooked hull data will be larger, but will load faster. + + @see NxCookingParams + */ + NX_CF_USE_UNCOMPRESSED_NORMALS = (1<<5), + }; + +typedef NxVec3 NxPoint; + +/** +\brief Descriptor class for #NxConvexMesh. + +@see NxConvexMesh NxConvexShape NxPhysicsSDK.createConvexMesh() + +*/ +class NxConvexMeshDesc + { + public: + + /** + \brief Number of vertices. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Max limit of 32 vertices for hardware rigid bodies) + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 numVertices; + + /** + \brief Number of triangles. + + Hardware rigid body scenes have a limit of 32 faces per convex. + Fluid scenes have a limit of 64 faces per cooked convex for dynamic actors. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Max 32 faces) + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 numTriangles; + + /** + \brief Offset between vertex points in bytes. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 pointStrideBytes; + + /** + \brief Offset between triangles in bytes. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 triangleStrideBytes; + + /** + \brief Pointer to array of vertex positions. + Pointer to first vertex point. Caller may add pointStrideBytes bytes to the pointer to access the next point. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + const void* points; + + /** + \brief Pointer to array of triangle indices. +

Pointer to first triangle. Caller may add triangleStrideBytes bytes to the pointer to access the next triangle.

+

These are triplets of 0 based indices:
+	vert0 vert1 vert2
+	vert0 vert1 vert2
+	vert0 vert1 vert2
+	...

+ +

Where vertex is either a 32 or 16 bit unsigned integer. There are numTriangles*3 indices.

+ +

This is declared as a void pointer because it is actually either an NxU16 or a NxU32 pointer.

+ + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexFlags.NX_CF_16_BIT_INDICES + */ + const void* triangles; + + /** + \brief Flags bits, combined from values of the enum ::NxConvexFlags + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 flags; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxConvexMeshDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxConvexMeshDesc::NxConvexMeshDesc() //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxConvexMeshDesc::setToDefault() + { + numVertices = 0; + numTriangles = 0; + pointStrideBytes = 0; + triangleStrideBytes = 0; + points = NULL; + triangles = NULL; + flags = 0; + } + +NX_INLINE bool NxConvexMeshDesc::isValid() const + { + // Check geometry + if(numVertices < 3 || //at least 1 trig's worth of points + (numVertices > 0xffff && flags & NX_CF_16_BIT_INDICES)) + return false; + if(!points) + return false; + if(pointStrideBytes < sizeof(NxPoint)) //should be at least one point's worth of data + return false; + + // Check topology + // The triangles pointer is not mandatory: the vertex cloud is enough to define the convex hull. + if(triangles) + { + // Indexed mesh + if(numTriangles < 2) //some algos require at least 2 trigs + return false; + if(flags & NX_CF_16_BIT_INDICES) + { + if((triangleStrideBytes < sizeof(NxU16)*3)) + return false; + } + else + { + if((triangleStrideBytes < sizeof(NxU32)*3)) + return false; + } + } + else + { + // We can compute the hull from the vertices + if(!(flags & NX_CF_COMPUTE_CONVEX)) + return false; // If the mesh is convex and we're not allowed to compute the hull, + // you have to provide it completely (geometry & topology). + } + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxConvexShape.h b/libraries/external/physx/Win32/include/PX/NxConvexShape.h new file mode 100755 index 0000000..3efbbdb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxConvexShape.h @@ -0,0 +1,93 @@ +#ifndef NX_COLLISION_NXCONVEXSHAPE +#define NX_COLLISION_NXCONVEXSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" + +class NxConvexShapeDesc; + +/** +\brief Used to represent an instance of an #NxConvexMesh. + +

Creation

+ +Example: + +\include NxConvexMesh_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_COLLISION_AABBS +\li #NX_VISUALIZE_COLLISION_SHAPES +\li #NX_VISUALIZE_COLLISION_AXES +\li #NX_VISUALIZE_COLLISION_VNORMALS +\li #NX_VISUALIZE_COLLISION_FNORMALS +\li #NX_VISUALIZE_COLLISION_EDGES +\li #NX_VISUALIZE_COLLISION_SPHERES + +@see NxConvexShapeDesc NxConvexMesh NxShape NxPhysicsSDK.createConvexMesh() NxActor.createShape() +*/ +class NxConvexShape: public NxShape + { + public: + + /** + + \brief Save shape to desc. + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexShapeDesc + */ + virtual void saveToDesc(NxConvexShapeDesc& desc) const = 0; + + /** + \brief Retrieves the convex mesh data associated with this instance. + + \return The convex mesh associated with this shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexMesh + */ + virtual NxConvexMesh& getConvexMesh() = 0; + + /** + \brief Retrieves the convex mesh data associated with this instance. + + Const version. + + \return The convex mesh associated with this shape. + + @see NxConvexMesh + */ + virtual const NxConvexMesh& getConvexMesh() const = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxConvexShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxConvexShapeDesc.h new file mode 100755 index 0000000..e7c4eae --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxConvexShapeDesc.h @@ -0,0 +1,108 @@ +#ifndef NX_COLLISION_NXCONVEXSHAPEDESC +#define NX_COLLISION_NXCONVEXSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShapeDesc.h" +#include "PX/NxConvexShape.h" + +class NxConvexMesh; + +/** +\brief Descriptor class for #NxConvexShape. + +@see NxConvexShape NxShapeDesc NxActor.createShape() NxConvexMesh NxPhysicsSDK.createConvexMesh() +*/ +class NxConvexShapeDesc : public NxShapeDesc + { + public: + + /** + \brief References the triangle mesh that we want to instance. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexMesh NxConvexMeshDesc NxPhysicsSDK.createConvexMesh() + */ + NxConvexMesh* meshData; + + /** + \brief Combination of ::NxMeshShapeFlag + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshShapeFlag + */ + NxU32 meshFlags; + +#ifdef NX_SUPPORT_CONVEX_SCALE + NxReal scale; +#endif + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxConvexShapeDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return returns true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxConvexShapeDesc::NxConvexShapeDesc() : NxShapeDesc(NX_SHAPE_CONVEX) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxConvexShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + meshData = NULL; + meshFlags = 0; +#ifdef NX_SUPPORT_CONVEX_SCALE + scale = 1.0f; +#endif + } + +NX_INLINE bool NxConvexShapeDesc::isValid() const + { + if(!meshData) return false; +#ifdef NX_SUPPORT_CONVEX_SCALE + if(scale<=0.0f) return false; +#endif + return NxShapeDesc::isValid(); + } +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCooking.h b/libraries/external/physx/Win32/include/PX/NxCooking.h new file mode 100755 index 0000000..feeb692 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCooking.h @@ -0,0 +1,466 @@ +#ifndef NX_COOKING_H +#define NX_COOKING_H +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxc.h" +#include "PX/Nxf.h" +#include "PX/NxArray.h" +class NxUserAllocator; +class NxUserOutputStream; +class NxTriangleMeshDesc; +class NxConvexMeshDesc; +class NxStream; +class NxTriangleMeshShape; +class NxClothMeshDesc; +class NxSoftBodyMeshDesc; +class NxTriangle; + + class NxVec3; + class NxPlane; + class NxConvexMeshDesc2; + + enum NxPlatform + { + PLATFORM_PC, + PLATFORM_XENON, + PLATFORM_PLAYSTATION3 + }; + + /** + + \brief Structure describing parameters affecting mesh cooking. + + @see NxSetCookingParams() NxGetCookingParams() + */ + struct NxCookingParams + { + /** + \brief Target platform + + Should be set to the platform which you intend to load the cooked mesh data on. This allows + the SDK to optimize the mesh data in an appropriate way for the platform and make sure that + endianness issues are accounted for correctly. + + Default value: Same as the platform on which the SDK is running. + */ + NxPlatform targetPlatform; + + /** + \brief Skin width for convexes + + Specifies the amount to inflate the convex mesh by when the new convex hull generator is used. + + Inflating the mesh allows the user to hide interpenetration errors by increasing the size of the + collision mesh with respect to the size of the rendered geometry. + + Default value: 0.025f + */ + float skinWidth; + + /** + \brief Hint to choose speed or less memory for collision structures + + Default value: false + */ + bool hintCollisionSpeed; + }; + + /** + \brief Sets cooking parameters + + \note #NxInitCooking() sets the parameters to their default values. + + \param[in] params Cooking parameters + + \return true on success. + + @see NxCookingParams NxGetCookingParams() + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxSetCookingParams(const NxCookingParams& params); + + /** + \brief Gets cooking parameters + + \return Current cooking parameters. + + @see NxCookingParams NxSetCookingParams() + */ + NX_C_EXPORT NXC_DLL_EXPORT const NxCookingParams& NX_CALL_CONV NxGetCookingParams(); + + /** + \brief Checks endianness is the same between cooking & target platforms + + \return True if there is and endian mismatch. + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxPlatformMismatch(); + + /** + \brief Initializes cooking. + + This must be called at least once, before any cooking method is called (otherwise cooking fails) and + should be matched with a call to NxCloseCooking() before you remove the allocator or output stream + objects. + + Please note that this also initializes the Foundation SDK. This is not an issue, unless you are linking + the AGEIA PhysX SDK using static libraries. When you are using static libraries, the cooking library + will share the same Foundation SDK as the rest of the application and this you will have to consider + when initializing the cooking library. In statically linked applications, you should specify the same + allocator and error stream to NxInitCooking() and NxCreatePhysicsSDK(). You are not compelled to + do so, but should be aware of the possible issues that could arise if you specify different values. + A common error would be to specify a user error stream when creating the Physics SDK, but omit it + when initializing the cooking, thus resulting in no error stream if the cooking is initialized last. + + The previous state of the cooking initialization is stored in a stack each time you call NxInitCooking() + and when you call NxCloseCooking() the previous state is activated again. The "state" that is saved is the + allocator and output stream settings. The stack size is currently 32 states, which means that you can + not call NxInitCooking() 33 consecutive times without at least one call to NxCloseCooking() in between. + + Note: Cooking parameters (as set by NxSetCookingParams) are reset by this function. You should call NxSetCookingParams + after this function, not before. + + \param[in] allocator The memory allocator to use. + \param[in] outputStream The output stream to use. + \return true on success. + + @see NxCloseCooking() + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxInitCooking(NxUserAllocator* allocator = NULL, NxUserOutputStream* outputStream = NULL); + + + /** + \brief Closes cooking. + + This must be called at the end of your app, to release cooking-related data. + + @see NxInitCooking() + */ + NX_C_EXPORT NXC_DLL_EXPORT void NX_CALL_CONV NxCloseCooking(); + + /** + \brief Cooks a triangle mesh. The results are written to the stream. + + To create a triangle mesh object(unlike previous versions) it is necessary to first 'cook' the mesh data into + a form which allows the SDK to perform efficient collision detection. + + NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream + suitable for loading and performing collision detection at runtime. + + \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called + when the application has finished using the cooking library. + + Example + + \include NxCookTriangleMesh_Example.cpp + + \param[in] desc The triangle mesh descriptor to read the mesh from. + \param[in] stream User stream to output the cooked data. + \return true on success + + @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() + */ + + + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxCookTriangleMesh(const NxTriangleMeshDesc& desc, NxStream& stream); + + /** + \brief Cooks a convex mesh. The results are written to the stream. + + To create a triangle mesh object(unlike previous versions) it is necessary to first 'cook' the mesh data into + a form which allows the SDK to perform efficient collision detection. + + NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream + suitable for loading and performing collision detection at runtime. + + NxCookConvex requires the input mesh to form a closed convex volume. This allows more efficient and robust + collision detection. The input mesh is not validated to make sure that the mesh is convex. + + \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called + when the application has finished using the cooking library. + + Example + + \include NxCookConvexMesh_Example.cpp + + \param[in] desc The convex mesh descriptor to read the mesh from. + \param[in] stream User stream to output the cooked data. + \return true on success + + @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxCookConvexMesh(const NxConvexMeshDesc& desc, NxStream& stream); + + /** + \brief Scales an existing cooked convex mesh and outputs it into another stream. + + \note #NxInitCooking() must be called before attempting to cook a mesh. #NxCloseCooking() should be called + when the application has finished using the cooking library. + + \param[in] source The source cooked convex mesh to scale. + \param[in] scale The uniform scale factor to apply to the convex mesh. + \param[in] dest User stream to output the cooked data. + \return true on success + + @see NxCookConvexMesh() NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxScaleCookedConvexMesh(const NxStream& source, NxReal scale, NxStream& dest); + + + /** + \brief Report state of cooking memory usage. + */ + NX_C_EXPORT NXC_DLL_EXPORT void NX_CALL_CONV NxReportCooking(); + + + /** + \brief Cooks a triangle mesh to a ClothMesh. + + \param desc The cloth mesh descriptor on which the generation of the cooked mesh depends. + \param stream The stream the cooked mesh is written to. + \return True if cooking was successful + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxCookClothMesh(const NxClothMeshDesc& desc, NxStream& stream); + + /** + \brief Cooks a tetrahedral mesh to a SoftBodyMesh. + + \param desc The soft body mesh descriptor on which the generation of the cooked mesh depends. + \param stream The stream the cooked mesh is written to. + \return True if cooking was successful + */ + NX_C_EXPORT NXC_DLL_EXPORT bool NX_CALL_CONV NxCookSoftBodyMesh(const NxSoftBodyMeshDesc& desc, NxStream& stream); + +class NxPMap; +class NxTriangleMesh; +class NxUserOutputStream; + +class NxCookingInterface +{ +public: + /** + \brief Sets cooking parameters + + \note #NxInitCooking() sets the parameters to their default values. + + \param[in] params Cooking parameters + + \return true on success. + + @see NxCookingParams NxGetCookingParams() + */ + virtual bool NxSetCookingParams(const NxCookingParams& params) = 0; + + /** + \brief Gets cooking parameters + + \return Current cooking parameters. + + @see NxCookingParams NxSetCookingParams() + */ + virtual const NxCookingParams& NxGetCookingParams() = 0; + + /** + \brief Checks endianness is the same between cooking & target platforms + + \return True if there is and endian mismatch. + */ + virtual bool NxPlatformMismatch() = 0; + + /** + \brief Initializes cooking. + + This must be called at least once, before any cooking method is called (otherwise cooking fails) and + should be matched with a call to NxCloseCooking() before you remove the allocator or output stream + objects. + + Please note that this also initializes the Foundation SDK. This is not an issue, unless you are linking + the AGEIA PhysX SDK using static libraries. When you are using static libraries, the cooking library + will share the same Foundation SDK as the rest of the application and this you will have to consider + when initializing the cooking library. In statically linked applications, you should specify the same + allocator and error stream to NxInitCooking() and NxCreatePhysicsSDK(). You are not compelled to + do so, but should be aware of the possible issues that could arise if you specify different values. + A common error would be to specify a user error stream when creating the Physics SDK, but omit it + when initializing the cooking, thus resulting in no error stream if the cooking is initialized last. + + The previous state of the cooking initialization is stored in a stack each time you call NxInitCooking() + and when you call NxCloseCooking() the previous state is activated again. The "state" that is saved is the + allocator and output stream settings. The stack size is currently 32 states, which means that you can + not call NxInitCooking() 33 consecutive times without at least one call to NxCloseCooking() in between. + + Note: Cooking parameters (as set by NxSetCookingParams) are reset by this function. You should call NxSetCookingParams + after this function, not before. + + \param[in] allocator The memory allocator to use. + \param[in] outputStream The output stream to use. + \return true on success. + + @see NxCloseCooking() + */ + virtual bool NxInitCooking(NxUserAllocator* allocator = NULL, NxUserOutputStream* outputStream = NULL) = 0; + + /** + \brief Closes cooking. + + This must be called at the end of your app, to release cooking-related data. + + @see NxInitCooking() + */ + virtual void NxCloseCooking() = 0; + + /** + \brief Cooks a triangle mesh. The results are written to the stream. + + To create a triangle mesh object(unlike previous versions) it is necessary to first 'cook' the mesh data into + a form which allows the SDK to perform efficient collision detection. + + NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream + suitable for loading and performing collision detection at runtime. + + NxCookConvex requires the input mesh to form a closed convex volume. This allows more efficient and robust + collision detection. + + \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called + when the application has finished using the cooking library. + + Example + + \include NxCookTriangleMesh_Example.cpp + + \param[in] desc The triangle mesh descriptor to read the mesh from. + \param[in] stream User stream to output the cooked data. + \return true on success + + @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() + */ + virtual bool NxCookTriangleMesh(const NxTriangleMeshDesc& desc, NxStream& stream) = 0; + + /** + \brief Cooks a convex mesh. The results are written to the stream. + + To create a triangle mesh object(unlike previous versions) it is necessary to first 'cook' the mesh data into + a form which allows the SDK to perform efficient collision detection. + + NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream + suitable for loading and performing collision detection at runtime. + + \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called + when the application has finished using the cooking library. + + Example + + \include NxCookConvexMesh_Example.cpp + + \param[in] desc The convex mesh descriptor to read the mesh from. + \param[in] stream User stream to output the cooked data. + \return true on success + + @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() + */ + virtual bool NxCookConvexMesh(const NxConvexMeshDesc& desc, NxStream& stream)= 0; + + + /** + \brief Cooks a triangle mesh to a ClothMesh. + + \param desc The cloth mesh descriptor on which the generation of the cooked mesh depends. + \param stream The stream the cooked mesh is written to. + \return True if cooking was successful + */ + virtual bool NxCookClothMesh(const NxClothMeshDesc& desc, NxStream& stream) = 0; + + /** + \brief Cooks a tetrahedral mesh to a SoftBodyMesh. + + \param desc The soft body mesh descriptor on which the generation of the cooked mesh depends. + \param stream The stream the cooked mesh is written to. + \return True if cooking was successful + */ + virtual bool NxCookSoftBodyMesh(const NxSoftBodyMeshDesc& desc, NxStream& stream) = 0; + + /** + \brief Creates a PMap from a triangle mesh. + + \warning Legacy function + + A PMap is an optional data structure which makes mesh-mesh collision + detection more robust at the cost of higher memory consumption. + + This structure can then be assigned to NxTriangleMeshDesc::pmap or passed to NxTriangleMesh::loadPMap(). + + You may wish to store the PMap on disk (just write the above data block to a file of your choice) after + computing it because the creation process can be quite expensive. Then you won't have to create it the next time + you need it. + + \param[out] pmap Used to store details of the created PMap. + \param[in] mesh Mesh to create PMap from. + \param[in] density The density(resolution) of the PMap. + \param[in] outputStream User supplied interface for reporting errors and displaying messages(see NxUserOutputStream) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxPMap NxTriangleMesh.loadPMap() NxConvexShape.loadPMap() NxReleasePMap + */ + virtual bool NxCreatePMap(NxPMap& pmap, const NxTriangleMesh& mesh, NxU32 density, NxUserOutputStream* outputStream = NULL)=0; + + /** + \brief Releases PMap previously created with NxCreatePMap. + + \warning Legacy function + + You should not call this on PMap data you have loaded from + disc yourself. Don't release a PMap while it is being used by a NxTriangleMesh object. + + \param[in] pmap Pmap to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxPMap NxTriangleMesh.loadPMap() NxConvexShape.loadPMap() NxCreatePMap + */ + virtual bool NxReleasePMap(NxPMap& pmap)=0; + + /** + \brief Scales an existing cooked convex mesh and outputs it into another stream. + + \param[in] source The source cooked convex mesh to scale. + \param[in] scale The uniform scale factor to apply to the convex mesh. + \param[in] dest User stream to output the cooked data. + \return true on success + + \note #NxInitCooking() must be called before attempting to cook a mesh. #NxCloseCooking() should be called + when the application has finished using the cooking library. + + @see NxCookConvexMesh() NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() + */ + virtual bool NxScaleCookedConvexMesh(const NxStream& source, NxReal scale, NxStream& dest)=0; + + /** + \brief Report state of cooking memory usage. + */ + virtual void NxReportCooking()=0; + + protected: + virtual ~NxCookingInterface(){}; +}; + + +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCylindricalJoint.h b/libraries/external/physx/Win32/include/PX/NxCylindricalJoint.h new file mode 100755 index 0000000..ddb07de --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCylindricalJoint.h @@ -0,0 +1,88 @@ +#ifndef NX_PHYSICS_NXSLIDINGJOINT +#define NX_PHYSICS_NXSLIDINGJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +#include "PX/NxJoint.h" +class NxCylindricalJointDesc; + +/** +\brief Cylindrical Joints permit relative translational movement between two bodies along + an axis, and also relative rotation along the axis. + + + \image html cylinderJoint.png + +

Creation

+ + Example: + + \include NxCylindricalJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxCylindricalJointDesc NxJoint NxScene.createJoint() +*/ +class NxCylindricalJoint : public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc() NxCylindricalJointDesc + */ + virtual void loadFromDesc(const NxCylindricalJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc() NxCylindricalJointDesc + */ + virtual void saveToDesc(NxCylindricalJointDesc& desc) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxCylindricalJointDesc.h b/libraries/external/physx/Win32/include/PX/NxCylindricalJointDesc.h new file mode 100755 index 0000000..7ef9f72 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxCylindricalJointDesc.h @@ -0,0 +1,69 @@ +#ifndef NX_PHYSICS_NXSLIDINGJOINTDESC +#define NX_PHYSICS_NXSLIDINGJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +/** +\brief Desc class for sliding joint. See #NxCylindricalJoint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxCylindricalJoint NxJointDesc NxScene.createJoint() +*/ +class NxCylindricalJointDesc : public NxJointDesc + { + public: + /** + \brief Constructor sets to default. + */ + NX_INLINE NxCylindricalJointDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxCylindricalJointDesc::NxCylindricalJointDesc() : NxJointDesc(NX_JOINT_CYLINDRICAL) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxCylindricalJointDesc::setToDefault() + { + NxJointDesc::setToDefault(); + } + +NX_INLINE bool NxCylindricalJointDesc::isValid() const + { + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxD6Joint.h b/libraries/external/physx/Win32/include/PX/NxD6Joint.h new file mode 100755 index 0000000..c3a6ee5 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxD6Joint.h @@ -0,0 +1,222 @@ +#ifndef NX_PHYSICS_NXD6Joint +#define NX_PHYSICS_NXD6Joint +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" + +class NxD6JointDesc; + +/** + \brief A D6 joint is a general constraint between two actors. + + It allows the user to individually define the linear and rotational degrees of freedom. + It also allows the user to configure the joint with limits and driven degrees of freedom as they wish. + + For example to create a fixed joint we would need to do: + + \code + ... + d6Desc.twistMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.swing1Motion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.swing2Motion = NX_D6JOINT_MOTION_LOCKED; + + d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED; + ... + \endcode + + Or a Revolute joint: + + \code + ... + d6Desc.twistMotion = NX_D6JOINT_MOTION_FREE; + d6Desc.swing1Motion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.swing2Motion = NX_D6JOINT_MOTION_LOCKED; + + d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED; + ... + + \endcode + + And a spherical joint: + + \code + ... + d6Desc.twistMotion = NX_D6JOINT_MOTION_FREE; + d6Desc.swing1Motion = NX_D6JOINT_MOTION_FREE; + d6Desc.swing2Motion = NX_D6JOINT_MOTION_FREE; + + d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED; + d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED; + ... + \endcode + + +

Creation

+ +Example: + +\include NxD6Joint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + +Platform: +\li PC SW: Yes +\li PPU : Partial(some features are not supported. Hardware D6 joints have different properties to +software joints so may behave slightly differently. See the user guide for details) +\li PS3 : Yes +\li XB360: Yes + +@see NxD6JointDesc NxJoint NxScene.createJoint() +*/ +class NxD6Joint: public NxJoint +{ + + public: + + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc NxD6JointDesc + */ + virtual void loadFromDesc(const NxD6JointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc NxD6JointDesc + */ + virtual void saveToDesc(NxD6JointDesc& desc) = 0; + + + /** + \brief Set the drive position goal position when it is being driven. + + The goal position is specified relative to the joint frame corresponding to actor[0]. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param position The goal position if NX_D6JOINT_DRIVE_POSITION is set for xDrive,yDrive or zDrive. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDriveOrientation() NxD6JointDesc.drivePosition + @see NxD6JointDesc + */ + virtual void setDrivePosition(const NxVec3 &position) = 0; + + /** + \brief Set the drive goal orientation when it is being driven. + + The goal orientation is specified relative to the joint frame corresponding to actor[0]. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param orientation The goal orientation if NX_D6JOINT_DRIVE_POSITION is set for swingDrive or + twistDrive. Range: unit quaternion + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDrivePosition NxD6JointDesc.driveOrientation + */ + virtual void setDriveOrientation(const NxQuat &orientation) = 0; + + /** + \brief Set the drive goal linear velocity when it is being driven. + + The drive linear velocity is specified relative to the actor[0] joint frame. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param linVel The goal velocity if NX_D6JOINT_DRIVE_VELOCITY is set for xDrive,yDrive or zDrive. + See #NxD6JointDesc. Range: velocity vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDriveAngularVelocity NxD6JointDesc.driveLinearVelocity + */ + virtual void setDriveLinearVelocity(const NxVec3 &linVel) = 0; + + /** + \brief Set the drive angular velocity goal when it is being driven. + + The drive angular velocity is specified relative to the drive orientation target in the case of a slerp drive. + + The drive angular velocity is specified in the actor[0] joint frame in all other cases. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param angVel The goal angular velocity if NX_D6JOINT_DRIVE_VELOCITY is set for swingDrive or + twistDrive. Range: angular velocity vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDriveLinearVelocity() NxD6JointDesc.driveAngularVelocity + */ + virtual void setDriveAngularVelocity(const NxVec3 &angVel) = 0; + }; +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxD6JointDesc.h b/libraries/external/physx/Win32/include/PX/NxD6JointDesc.h new file mode 100755 index 0000000..bec4faf --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxD6JointDesc.h @@ -0,0 +1,444 @@ +#ifndef NX_PHYSICS_NXD6JOINTDESC +#define NX_PHYSICS_NXD6JOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +#include "PX/NxJointLimitSoftPairDesc.h" +#include "PX/NxBitField.h" +#include "PX/NxMotorDesc.h" + +/** \addtogroup physics + @{ +*/ + + + + + +/////////////////////////////////////////////////////////// + +/** +\brief Descriptor class for the D6Joint. See #NxD6Joint. + +

In the D6Joint, the axes are assigned as follows: +

    +
  • x-axis = joint axis
  • +
  • y-axis = joint normal axis
  • +
  • z-axis = x-axis cross y-axis
  • +
+ These are defined relative to the parent body (0) of the joint.

+ +

+ Swing is defined as the rotation of the x-axis with respect to the y- and z-axis. +

+ +

+ Twist is defined as the rotation about the x-axis. +

+ +Platform: +\li PC SW: Yes +\li PPU : Partial(some features not supported) +\li PS3 : Yes +\li XB360: Yes + + @see NxD6Joint NxJointDesc NxScene.createJoint() +*/ + +class NxD6JointDesc : public NxJointDesc +{ +public: + +/* Constraints */ + /** + \brief Define the linear degrees of freedom + + Default: NX_D6JOINT_MOTION_FREE + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxD6JointMotion xMotion yMotion zMotion + */ + NxD6JointMotion xMotion, yMotion, zMotion; + + /** + \brief Define the angular degrees of freedom + + Default: NX_D6JOINT_MOTION_FREE + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxD6JointMotion swing1Motion swing2Motion twistMotion + */ + NxD6JointMotion swing1Motion, swing2Motion, twistMotion; + + /** + \brief If some linear DOF are limited, linearLimit defines the characteristics of these limits + + Range: See #NxJointLimitSoftDesc
+ Default: See #NxJointLimitSoftDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitSoftDesc swing1Limit swing2Limit twistLimit + */ + NxJointLimitSoftDesc linearLimit; + + /** + \brief If swing1Motion is NX_D6JOINT_MOTION_LIMITED, swing1Limit defines the characteristics of the limit + + Range: See #NxJointLimitSoftDesc
+ Default: See #NxJointLimitSoftDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitSoftDesc linearLimit swing2Limit twistLimit + */ + NxJointLimitSoftDesc swing1Limit; + + /** + \brief If swing2Motion is NX_D6JOINT_MOTION_LIMITED, swing2Limit defines the characteristics of the limit + + Range: See #NxJointLimitSoftDesc
+ Default: See #NxJointLimitSoftDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitSoftDesc linearLimit swing1Limit twistLimit + */ + NxJointLimitSoftDesc swing2Limit; + + /** + \brief If twistMotion is NX_D6JOINT_MOTION_LIMITED, twistLimit defines the characteristics of the limit + + Range: See #NxJointLimitSoftPairDesc
+ Default: See #NxJointLimitSoftDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitSoftDesc linearLimit swing1Limit swing2imit + */ + NxJointLimitSoftPairDesc twistLimit; + +/* drive */ + + /** + \brief Drive the three linear DOF + + Range: See #NxJointDriveDesc
+ Default: See #NxJointDriveDesc + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDriveDesc xDrive yDrive zDrive drivePosition + */ + NxJointDriveDesc xDrive, yDrive, zDrive; + + /** + \brief These drives are used if the flag NX_D6JOINT_SLERP_DRIVE is not set + + Range: See #NxJointDriveDesc
+ Default: See #NxJointDriveDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDriveDesc swingDrive twistDrive driveOrientation + */ + NxJointDriveDesc swingDrive, twistDrive; + + /** + \brief This drive is used if the flag NX_D6JOINT_SLERP_DRIVE is set + + Range: See #NxJointDriveDesc
+ Default: See #NxJointDriveDesc + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDriveDesc driveOrientation + */ + NxJointDriveDesc slerpDrive; + + + /** + \brief If the type of xDrive (yDrive,zDrive) is NX_D6JOINT_DRIVE_POSITION, drivePosition defines the goal position + + Range: position vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see xDrive yDrive zDrive NxD6Joint.setDrivePosition + */ + NxVec3 drivePosition; + + /** + \brief If the type of swingDrive or twistDrive is NX_D6JOINT_DRIVE_POSITION, driveOrientation defines the goal orientation + + Range: unit quaternion
+ Default: Identity Quaternion + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see slerpDrive swingDrive twistDrive NxD6Joint.setDriveOrientation() + */ + NxQuat driveOrientation; + + /** + \brief If the type of xDrive (yDrive,zDrive) is NX_D6JOINT_DRIVE_VELOCITY, driveLinearVelocity defines the goal linear velocity + + Range: velocity vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see xDrive yDrive zDrive NxD6Joint.setDriveLinearVelocity() + */ + NxVec3 driveLinearVelocity; + + /** + \brief If the type of swingDrive or twistDrive is NX_D6JOINT_DRIVE_VELOCITY, driveAngularVelocity defines the goal angular velocity + \li driveAngularVelocity.x - goal angular velocity about the twist axis + \li driveAngularVelocity.y - goal angular velocity about the swing1 axis + \li driveAngularVelocity.z - goal angular velocity about the swing2 axis + + Range: angular velocity vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see slerpDrive swingDrive twistDrive NxD6Joint.setDriveAngularVelocity() + */ + NxVec3 driveAngularVelocity; + + /** + \brief If projectionMode is NX_JPM_NONE, projection is disabled. If NX_JPM_POINT_MINDIST, bodies are projected to limits leaving an linear error of projectionDistance and an angular error of projectionAngle + + Default: NX_JPM_NONE + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointProjectionMode projectionDistance projectionAngle + */ + NxJointProjectionMode projectionMode; + + /** + \brief The distance above which to project the joint. + + Range: (0,inf)
+ Default: 0.1 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see projectionMode projectionAngle + */ + NxReal projectionDistance; + + /** + \brief The angle above which to project the joint. + + Range: (0,inf)
+ Default: 0.0872f (about 5 degrees in radians) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see projectionMode ProjectionDistance + */ + NxReal projectionAngle; + + /** + \brief when the flag NX_D6JOINT_GEAR_ENABLED is set, the angular velocity of the second actor is driven towards the angular velocity of the first actor times gearRatio (both w.r.t. their primary axis) + + Range: (-inf,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags + */ + NxReal gearRatio; + + /** + \brief This is a combination of the bits defined by ::NxD6JointFlag + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Partial (Slerp drive not supported) + \li PS3 : Yes + \li XB360: Yes + + @see NxD6JointFlag + */ + NxU32 flags; + + /** + \brief constructor sets to default. + */ + + NX_INLINE NxD6JointDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return returns true if the current settings are valid + */ + + NX_INLINE bool isValid() const; +}; + +NxD6JointDesc::NxD6JointDesc() : NxJointDesc(NX_JOINT_D6) +{ + setToDefault(); +} + +void NxD6JointDesc::setToDefault() +{ + NxJointDesc::setToDefault(); + + xMotion = NX_D6JOINT_MOTION_FREE; + yMotion = NX_D6JOINT_MOTION_FREE; + zMotion = NX_D6JOINT_MOTION_FREE; + twistMotion = NX_D6JOINT_MOTION_FREE; + swing1Motion = NX_D6JOINT_MOTION_FREE; + swing2Motion = NX_D6JOINT_MOTION_FREE; + + drivePosition.set(0,0,0); + driveOrientation.id(); + + driveLinearVelocity.set(0,0,0); + driveAngularVelocity.set(0,0,0); + + projectionMode = NX_JPM_NONE; // choose NX_JPM_POINT_MINDIST to turn projection on + projectionDistance = 0.1f; + projectionAngle = 0.0872f; //about 5 degrees in radians. + + flags = 0; + gearRatio = 1.0f; +} + +bool NxD6JointDesc::isValid() const +{ + if (flags & NX_D6JOINT_SLERP_DRIVE) { // only possible with all angular DOF available + if (swing1Motion == NX_D6JOINT_MOTION_LOCKED || + swing2Motion == NX_D6JOINT_MOTION_LOCKED || + twistMotion == NX_D6JOINT_MOTION_LOCKED) return false; + } + + // swing limits are symmetric, thus their range is 0..180 degrees + if (swing1Motion == NX_D6JOINT_MOTION_LIMITED) { + if (swing1Limit.value < 0.0f) return false; + if (swing1Limit.value > NxPi) return false; + } + if (swing2Motion == NX_D6JOINT_MOTION_LIMITED) { + if (swing2Limit.value < 0.0f) return false; + if (swing2Limit.value > NxPi) return false; + } + + // twist limits are asymmetric with -180 <= low < high <= 180 degrees + if (twistMotion == NX_D6JOINT_MOTION_LIMITED) { + if (twistLimit.low.value < -NxPi) return false; + if (twistLimit.high.value > NxPi) return false; + if (twistLimit.low.value > twistLimit.high.value) return false; + } + + // in angular limited-free mode, only -90..90 swings are possible + if (swing1Motion == NX_D6JOINT_MOTION_LIMITED && swing2Motion == NX_D6JOINT_MOTION_FREE) + if (swing1Limit.value > NxHalfPi) return false; + if (swing2Motion == NX_D6JOINT_MOTION_LIMITED && swing1Motion == NX_D6JOINT_MOTION_FREE) + if (swing2Limit.value > NxHalfPi) return false; + + if (flags & NX_D6JOINT_GEAR_ENABLED) // gear only with twist motion enabled + if (twistMotion == NX_D6JOINT_MOTION_LOCKED) return false; + + return NxJointDesc::isValid(); +} + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxDebugRenderable.h b/libraries/external/physx/Win32/include/PX/NxDebugRenderable.h new file mode 100755 index 0000000..d163336 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxDebugRenderable.h @@ -0,0 +1,134 @@ +#ifndef NX_FOUNDATION_NXDEBUGRENDERABLE +#define NX_FOUNDATION_NXDEBUGRENDERABLE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxBox.h" +#include "PX/NxBounds3.h" + +/** +\brief Default color values used for debug rendering. +*/ +enum NxDebugColor + { + NX_ARGB_BLACK = 0xff000000, + NX_ARGB_RED = 0xffff0000, + NX_ARGB_GREEN = 0xff00ff00, + NX_ARGB_BLUE = 0xff0000ff, + NX_ARGB_YELLOW = 0xffffff00, + NX_ARGB_MAGENTA = 0xffff00ff, + NX_ARGB_CYAN = 0xff00ffff, + NX_ARGB_WHITE = 0xffffffff, + }; + +/** +\brief Used to store a single point and colour for debug rendering. +*/ +struct NxDebugPoint + { + NxVec3 p; + NxU32 color; + }; + +/** +\brief Used to store a single line and colour for debug rendering. +*/ +struct NxDebugLine + { + NxVec3 p0; + NxVec3 p1; + NxU32 color; + }; + +/** +\brief Used to store a single triangle and colour for debug rendering. +*/ +struct NxDebugTriangle + { + NxVec3 p0; + NxVec3 p1; + NxVec3 p2; + NxU32 color; + }; + +/** +\brief This class references buffers with points, lines, and triangles. They represent visualizations +of SDK objects to help with debugging the user's code. + +The user should not have to instance this class. + +

Example

+ +\include NxUserDebugRenderer_Example.cpp +*/ +class NxDebugRenderable + { + public: + NX_INLINE NxDebugRenderable(NxU32 np, const NxDebugPoint* p, NxU32 nl, const NxDebugLine* l, NxU32 nt, const NxDebugTriangle* t) + : numPoints(np), numLines(nl), numTriangles(nt), points(p), lines(l), triangles(t) { } + + /** + \brief Retrieve the number of points to render. + \return Point count. + */ + NX_INLINE NxU32 getNbPoints() const { return numPoints; } + + /** + \brief Retrieve an array of points. + \return Array of #NxDebugPoint + */ + NX_INLINE const NxDebugPoint* getPoints() const { return points; } + + + + /** + \brief Retrieve the number of lines to render. + \return Line Count. + */ + NX_INLINE NxU32 getNbLines() const { return numLines; } + + /** + \brief Retrieve an array of lines to render. + \return Array of #NxDebugLine + */ + NX_INLINE const NxDebugLine* getLines() const { return lines; } + + /** + \brief Retrieve the number of triangles to render. + \return Array of #NxDebugTriangle + */ + NX_INLINE NxU32 getNbTriangles() const { return numTriangles; } + + /** + \brief Retrieve an array of triangles to render. + \return Array of #NxDebugTriangle + */ + NX_INLINE const NxDebugTriangle* getTriangles() const { return triangles; } + + private: + NxU32 numPoints; + NxU32 numLines; + NxU32 numTriangles; + + const NxDebugPoint* points; + const NxDebugLine* lines; + const NxDebugTriangle* triangles; + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxDistanceJoint.h b/libraries/external/physx/Win32/include/PX/NxDistanceJoint.h new file mode 100755 index 0000000..e279534 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxDistanceJoint.h @@ -0,0 +1,86 @@ +#ifndef NX_PHYSICS_NXDISTANCEJOINT +#define NX_PHYSICS_NXDISTANCEJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" + +class NxDistanceJointDesc; + +/** + \brief A distance joint maintains a certain distance between two points on two actors. + + \image html distanceJoint.png + +

Creation

+ + Example: + + \include NxDistanceJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxDistanceJointDesc NxJoint NxScene.createJoint() +*/ +class NxDistanceJoint : public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set this objects state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc() NxDistanceJointDesc + */ + virtual void loadFromDesc(const NxDistanceJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve this objects state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc() NxDistanceJointDesc + */ + virtual void saveToDesc(NxDistanceJointDesc& desc) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxDistanceJointDesc.h b/libraries/external/physx/Win32/include/PX/NxDistanceJointDesc.h new file mode 100755 index 0000000..ea4d0c7 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxDistanceJointDesc.h @@ -0,0 +1,132 @@ +#ifndef NX_PHYSICS_NXDISTANCEJOINTDESC +#define NX_PHYSICS_NXDISTANCEJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +#include "PX/NxSpringDesc.h" + +/** +\brief Desc class for distance joint. See #NxDistanceJoint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxDistanceJoint NxJointDesc NxScene.createJoint() + +*/ +class NxDistanceJointDesc : public NxJointDesc + { + public: + + /** + \brief The maximum rest length of the rope or rod between the two anchor points. + + Range: [#minDistance,inf)
+ Default: 0.0 + */ + NxReal maxDistance; + + /** + \brief The minimum rest length of the rope or rod between the two anchor points + + Range: [0,#maxDistance]
+ Default: 0.0 + */ + NxReal minDistance; + + /* + \brief How stiff the constraint is, between 0 and 1 (stiffest) + + Range: [0,1]
+ Default: 1.0 + */ + //NxReal stiffness; + + /** + \brief makes the joint springy. The spring.targetValue field is not used. + + Range: See #NxSpringDesc
+ Default: See #NxSpringDesc + */ + NxSpringDesc spring; + + /** + \brief This is a combination of the bits defined by ::NxDistanceJointFlag. + + Default: 0 + */ + NxU32 flags; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxDistanceJointDesc(); + /** + \brief (re)sets the structure to the default. + + \param[in] fromCtor skip redundant operations if called from contructor. + */ + NX_INLINE void setToDefault(bool fromCtor=false); + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxDistanceJointDesc::NxDistanceJointDesc() : NxJointDesc(NX_JOINT_DISTANCE) //constructor sets to default + { + setToDefault(true); + } + +NX_INLINE void NxDistanceJointDesc::setToDefault(bool fromCtor) + { + NxJointDesc::setToDefault(); + maxDistance = 0.0f; + minDistance = 0.0f; + //stiffness = 1.0f; + flags = 0; + + if (!fromCtor) + { + //this is redundant if we're being called from the ctor: + spring.setToDefault(); + } + } + +NX_INLINE bool NxDistanceJointDesc::isValid() const + { + if (maxDistance < 0) return false; + if (minDistance < 0) return false; + + // if both distance constrains are on, the min better be less than or equal to the max. + if ((minDistance > maxDistance) && (flags == (NX_DJF_MIN_DISTANCE_ENABLED | NX_DJF_MAX_DISTANCE_ENABLED))) return false; +// if (stiffness < 0 || stiffness > 1) return false; + if (!spring.isValid()) return false; + + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxEffector.h b/libraries/external/physx/Win32/include/PX/NxEffector.h new file mode 100755 index 0000000..9b9827c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxEffector.h @@ -0,0 +1,183 @@ +#ifndef NX_PHYSICS_NXEFFECTOR +#define NX_PHYSICS_NXEFFECTOR +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxEffectorDesc.h" + +class NxScene; +class NxSpringAndDamperEffector; + +/** + \brief An effector is a class that gets called before each tick of the + scene. + + At this point it may apply any permissible effect + to the objects. For example: #NxSpringAndDamperEffector + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxSpringAndDamperEffector NxScene.createSpringAndDamperEffector +*/ +class NxEffector + { + public: + /** + \brief Retrieve the type of this effector. + \return The type of effector. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxEffectorType + */ + virtual NxEffectorType getType() const = 0; + + /** + \brief Type casting operator. The result may be cast to the desired subclass type. + + \param[in] type Used to query for a specific effector type. + \return NULL if the object if not of type(see #NxEffectorType). Otherwise a pointer to this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxEffectorType + */ + NX_INLINE void* is(NxEffectorType type) { return (type == getType()) ? (void*)this : NULL; }; + + /** + \brief Type casting operator. The result may be cast to the desired subclass type. + + \param[in] type Used to query for a specific effector type. + \return NULL if the object if not of type(see #NxEffectorType). Otherwise a pointer to this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxEffectorType + */ + NX_INLINE const void* is(NxEffectorType type) const { return (type == getType()) ? (const void*)this : NULL; }; + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a spring and damper effector a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector + */ + NX_INLINE NxSpringAndDamperEffector* isSpringAndDamperEffector() { return (NxSpringAndDamperEffector*)is(NX_EFFECTOR_SPRING_AND_DAMPER);} + + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a spring and damper effector a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector + */ + NX_INLINE const NxSpringAndDamperEffector* isSpringAndDamperEffector() const { return (const NxSpringAndDamperEffector*)is(NX_EFFECTOR_SPRING_AND_DAMPER);} + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName(const char* name) = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The name string for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName() const = 0; + + /** + \brief Retrieves the owner scene + + \return The scene which this effector belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + + void * userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + void * appData; //!< used internally, do not change. + + protected: + + NX_INLINE NxEffector() : userData(NULL), appData(NULL) {} + virtual NX_INLINE ~NxEffector(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxEffectorDesc.h b/libraries/external/physx/Win32/include/PX/NxEffectorDesc.h new file mode 100755 index 0000000..3502fd4 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxEffectorDesc.h @@ -0,0 +1,141 @@ +#ifndef NX_PHYSICS_NXEFFECTORDESC +#define NX_PHYSICS_NXEFFECTORDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + + +enum NxEffectorType + { + NX_EFFECTOR_SPRING_AND_DAMPER, + }; + +/** + \brief Descriptor class for NxEffector class. + + Effector descriptors for all types are derived from this class. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxSpringAndDamperEffectorDesc +*/ +class NxEffectorDesc + { + protected: + /** + \brief The type of effector. This is set by the c'tor of the derived class. + */ + NxEffectorType type; + + public: + + /** + \brief Will be copied to NxEffector::userData. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief Constructor sets to default. + */ + virtual NX_INLINE ~NxEffectorDesc(); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + + /** + \brief Retrieves the effector type. + + \return The type of effector this descriptor describes. + + @see NxEffectorType + */ + NX_INLINE NxEffectorType getType() const; + + protected: + /** + \brief Constructor sets to default. + + \param type effector type + */ + NX_INLINE NxEffectorDesc(NxEffectorType type); + }; + +NX_INLINE NxEffectorDesc::NxEffectorDesc(NxEffectorType t) : type(t) + { + setToDefault(); + } + +NX_INLINE NxEffectorDesc::~NxEffectorDesc() + { + //nothing + } + +NX_INLINE void NxEffectorDesc::setToDefault() + { + userData = NULL; + name = NULL; + } + +NX_INLINE bool NxEffectorDesc::isValid() const + { + //nothing + return true; + } +NX_INLINE NxEffectorType NxEffectorDesc::getType() const + { + return type; + } + + + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxException.h b/libraries/external/physx/Win32/include/PX/NxException.h new file mode 100755 index 0000000..0586f3c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxException.h @@ -0,0 +1,33 @@ +#ifndef NX_FOUNDATION_NXEXCEPTION +#define NX_FOUNDATION_NXEXCEPTION +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +/** + \brief Objects of this class are optionally thrown by some classes as part of the error reporting mechanism. +*/ +class NxException + { + public: + virtual NxErrorCode getErrorCode() = 0; + virtual const char * getFile() = 0; + virtual int getLine() = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxExportedUtils.h b/libraries/external/physx/Win32/include/PX/NxExportedUtils.h new file mode 100755 index 0000000..66b04db --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxExportedUtils.h @@ -0,0 +1,812 @@ +#ifndef NX_PHYSICS_NXLEGACYEXPORTS +#define NX_PHYSICS_NXLEGACYEXPORTS +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + + +#include "PX/Nxp.h" +#include "PX/PhysXLoader.h" + +struct NxIntegrals; +/* +These are functions that used to be exported for the user from the foundation DLL, which doesn't exist anymore. +They are kept here and exported from the physics SDK DLL for backwards compatibility. +*/ + +/** + +\brief Test if an oriented box contains a point. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param[in] box Oriented Box to test point against. +\param[in] p Point to test. + +\return True if the box contains p. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox +*/ +NX_INLINE bool NxBoxContainsPoint(const NxBox& box, const NxVec3& p) + { + return NxGetUtilLib()->NxBoxContainsPoint(box,p); + } + +/** + +\brief Create an oriented box from an axis aligned box and a transformation. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param[out] box Used to store the oriented box. +\param[in] aabb Axis aligned box. +\param[in] mat Transformation to apply to the axis aligned box. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox NxBounds3 +*/ +NX_INLINE void NxCreateBox(NxBox& box, const NxBounds3& aabb, const NxMat34& mat) + { + NxGetUtilLib()->NxCreateBox(box,aabb,mat); + } + +/** + +\brief Computes plane equation for each face of an oriented box. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param[in] box The oriented box. +\param[out] planes Array to receive the computed planes(should be large enough to hold 6 planes) + +\return True on success. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox NxPlane +*/ +NX_INLINE bool NxComputeBoxPlanes(const NxBox& box, NxPlane* planes) + { + return NxGetUtilLib()->NxComputeBoxPlanes(box,planes); + } + +/** + +\brief Compute the corner points of an oriented box. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param[in] box The oriented box. +\param[out] pts Array to receive the box point (should be large enough to hold 8 points) + +\return True on success. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox +*/ +NX_INLINE bool NxComputeBoxPoints(const NxBox& box, NxVec3* pts) + { + return NxGetUtilLib()->NxComputeBoxPoints(box,pts); + } + +/** + +\brief Compute the vertex normals of an oriented box. These are smooth normals, i.e. averaged from the faces of the box. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param[in] box The oriented box. +\param[out] pts The normals for each vertex(should be large enough to hold 8 normals). + +\return True on success. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox +*/ +NX_INLINE bool NxComputeBoxVertexNormals(const NxBox& box, NxVec3* pts) + { + return NxGetUtilLib()->NxComputeBoxVertexNormals(box,pts); + } + +/** +\brief Return a list of edge indices. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\return List of edge indices. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxComputeBoxPoints +*/ +NX_INLINE const NxU32* NxGetBoxEdges() + { + return NxGetUtilLib()->NxGetBoxEdges(); + } + +/** +\brief Return a list of box edge axes. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\return List of box edge axes. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxComputeBoxPoints +*/ +NX_INLINE const NxI32* NxGetBoxEdgesAxes() + { + return NxGetUtilLib()->NxGetBoxEdgesAxes(); + } + +/** +\brief Return a set of triangle indices suitable for use with #NxComputeBoxPoints. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\return List of box triangles. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxComputeBoxPoints +*/ +NX_INLINE const NxU32* NxGetBoxTriangles() + { + return NxGetUtilLib()->NxGetBoxTriangles(); + } + +/** +\brief Returns a list of local space edge normals. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\return List of edge normals. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE const NxVec3* NxGetBoxLocalEdgeNormals() + { + return NxGetUtilLib()->NxGetBoxLocalEdgeNormals(); + } + +/** +\brief Compute and edge normals for an oriented box. + +This is an averaged normal, from the two faces sharing the edge. + +The edge index should be from 0 to 11 (i.e. a box has 12 edges). + +Edge ordering: + +\image html boxEdgeDiagram.png + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param[in] box The oriented box. +\param[in] edge_index The index of the edge to compute a normal for. +\param[out] world_normal The computed normal. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxComputeBoxWorldEdgeNormal(const NxBox& box, NxU32 edge_index, NxVec3& world_normal) + { + NxGetUtilLib()->NxComputeBoxWorldEdgeNormal(box,edge_index,world_normal); + } + +/** + +\brief Compute a capsule which encloses a box. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param box Box to generate capsule for. +\param capsule Stores the capsule which is generated. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox NxCapsule NxComputeBoxAroundCapsule +*/ +NX_INLINE void NxComputeCapsuleAroundBox(const NxBox& box, NxCapsule& capsule) + { + NxGetUtilLib()->NxComputeCapsuleAroundBox(box,capsule); + } + +/** +\brief Test if box A is inside another box B. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param a Box A +\param b Box B + +\return True if box A is inside box B. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBox +*/ +NX_INLINE bool NxIsBoxAInsideBoxB(const NxBox& a, const NxBox& b) + { + return NxGetUtilLib()->NxIsBoxAInsideBoxB(a,b); + } + +/** +\brief Get a list of indices representing the box as quads. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\return List of quad indices. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxComputeBoxPoints() +*/ +NX_INLINE const NxU32* NxGetBoxQuads() + { + return NxGetUtilLib()->NxGetBoxQuads(); + } + +/** +\brief Returns a list of quad indices sharing the vertex index. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param vertexIndex Vertex Index. +\return List of quad indices sharing the vertex index. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxComputeBoxPoints() NxGetBoxQuads() +*/ +NX_INLINE const NxU32* NxBoxVertexToQuad(NxU32 vertexIndex) + { + return NxGetUtilLib()->NxBoxVertexToQuad(vertexIndex); + } + +/** +\brief Compute a box which encloses a capsule. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param capsule Capsule to generate an enclosing box for. +\param box Generated box. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxComputeCapsuleAroundBox +*/ +NX_INLINE void NxComputeBoxAroundCapsule(const NxCapsule& capsule, NxBox& box) + { + NxGetUtilLib()->NxComputeBoxAroundCapsule(capsule,box); + } + +/** +\brief Set FPU precision. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPUPrecision24() + { + NxGetUtilLib()->NxSetFPUPrecision24(); + } + +/** +\brief Set FPU precision. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPUPrecision53() + { + NxGetUtilLib()->NxSetFPUPrecision53(); + } + +/** +\brief Set FPU precision + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPUPrecision64() + { + NxGetUtilLib()->NxSetFPUPrecision64(); + } + +/** +\brief Set FPU precision. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPURoundingChop() + { + NxGetUtilLib()->NxSetFPURoundingChop(); + } + +/** +\brief Set FPU rounding mode. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPURoundingUp() + { + NxGetUtilLib()->NxSetFPURoundingUp(); + } + +/** +\brief Set FPU rounding mode. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPURoundingDown() + { + NxGetUtilLib()->NxSetFPURoundingDown(); + } + +/** +\brief Set FPU rounding mode. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPURoundingNear() + { + NxGetUtilLib()->NxSetFPURoundingNear(); + } + +/** +\brief Enable/Disable FPU exception. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param b True to enable exception. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxSetFPUExceptions(bool b) + { + NxGetUtilLib()->NxSetFPUExceptions(b); + } + +/** +\brief Convert a floating point number to an integer. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param f Floating point number. + +\return The result. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE int NxIntChop(const NxF32& f) + { + return NxGetUtilLib()->NxIntChop(f); + } + +/** +\brief Convert a floating point number to an integer. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param f Floating point number. + +\return The result. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE int NxIntFloor(const NxF32& f) + { + return NxGetUtilLib()->NxIntFloor(f); + } + +/** +\brief Convert a floating point number to an integer. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param f Floating point number. + +\return The result. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE int NxIntCeil(const NxF32& f) + { + return NxGetUtilLib()->NxIntCeil(f); + } + +/** +\brief Compute the distance squared from a point to a ray. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param ray The ray. +\param point The point. +\param t Used to retrieve the closest parameter value on the ray. + +\return The squared distance. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxRay +*/ +NX_INLINE NxF32 NxComputeDistanceSquared(const NxRay& ray, const NxVec3& point, NxF32* t) + { + return NxGetUtilLib()->NxComputeDistanceSquared(ray,point,t); + } + +/** +\brief Compute the distance squared from a point to a line segment. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param seg The line segment. +\param point The point. +\param t Used to retrieve the closest parameter value on the line segment. + +\return The squared distance. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxSegment +*/ +NX_INLINE NxF32 NxComputeSquareDistance(const NxSegment& seg, const NxVec3& point, NxF32* t) + { + return NxGetUtilLib()->NxComputeSquareDistance(seg,point,t); + } + +/** +\brief Compute a bounding sphere for a point cloud. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param sphere The computed sphere. +\param nb_verts Number of points. +\param verts Array of points. + +\return The method used to compute the sphere, see #NxBSphereMethod. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxSphere NxFastComputeSphere +*/ +NX_INLINE NxBSphereMethod NxComputeSphere(NxSphere& sphere, unsigned nb_verts, const NxVec3* verts) + { + return NxGetUtilLib()->NxComputeSphere(sphere,nb_verts,verts); + } +/** +\brief Compute a bounding sphere for a point cloud. + +The sphere may not be as tight as #NxComputeSphere + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param sphere The computed sphere. +\param nb_verts Number of points. +\param verts Array of points. + +\return True on success. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxSphere NxComputeSphere +*/ +NX_INLINE bool NxFastComputeSphere(NxSphere& sphere, unsigned nb_verts, const NxVec3* verts) + { + return NxGetUtilLib()->NxFastComputeSphere(sphere,nb_verts,verts); + } + +/** +\brief Compute an overall bounding sphere for a pair of spheres. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param merged The computed sphere. +\param sphere0 First sphere. +\param sphere1 Second sphere. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxSphere NxComputeSphere +*/ +NX_INLINE void NxMergeSpheres(NxSphere& merged, const NxSphere& sphere0, const NxSphere& sphere1) + { + NxGetUtilLib()->NxMergeSpheres(merged,sphere0,sphere1); + } + +/** +\brief Get the tangent vectors associated with a normal. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param n Normal vector +\param t1 First tangent +\param t2 Second tangent + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxNormalToTangents(const NxVec3 & n, NxVec3 & t1, NxVec3 & t2) + { + NxGetUtilLib()->NxNormalToTangents(n,t1,t2); + } + +/** +\brief Rotates a 3x3 symmetric inertia tensor I into a space R where it can be represented with the diagonal matrix D. + +I = R * D * R' + +Returns false on failure. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param denseInertia The dense inertia tensor. +\param diagonalInertia The diagonalized inertia tensor. +\param rotation Rotation for the frame of the diagonalized inertia tensor. + +\return True if the inertia tensor can be diagonalized. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ + +NX_INLINE bool NxDiagonalizeInertiaTensor(const NxMat33 & denseInertia, NxVec3 & diagonalInertia, NxMat33 & rotation) + { + return NxGetUtilLib()->NxDiagonalizeInertiaTensor(denseInertia,diagonalInertia,rotation); + } + +/** +\brief Computes a rotation matrix. + +computes rotation matrix M so that: + +M * x = b + +x and b are unit vectors. + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param x Vector. +\param b Vector. +\param M Computed rotation matrix. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE void NxFindRotationMatrix(const NxVec3 & x, const NxVec3 & b, NxMat33 & M) + { + NxGetUtilLib()->NxFindRotationMatrix(x,b,M); + } + +/** +\brief Computes bounds of an array of vertices + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param min Computed minimum of the bounds. +\param max Maximum +\param nbVerts Number of input vertices. +\param verts Array of vertices. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBounds3 +*/ +NX_INLINE void NxComputeBounds(NxVec3& min, NxVec3& max, NxU32 nbVerts, const NxVec3* verts) + { + NxGetUtilLib()->NxComputeBounds(min,max,nbVerts,verts); + } + +/** +\brief Computes bounds of an array of vertices + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param bounds Computed bounds. +\param nbVerts Number of input vertices. +\param verts Array of vertices. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxBounds3 +*/ +NX_INLINE void NxComputeBounds(NxBounds3& bounds, NxU32 nbVerts, const NxVec3* verts) + { + NxVec3 min, max; + NxComputeBounds(min, max, nbVerts, verts); + bounds.set(min, max); + } + +/** +\brief Computes CRC of input buffer + +\warning #NxCreatePhysicsSDK() must be called before using this function. + +\param buffer Input buffer. +\param nbBytes Number of bytes in in the input buffer. +\return The computed CRC. + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +NX_INLINE NxU32 NxCrc32(const void* buffer, NxU32 nbBytes) + { + return NxGetUtilLib()->NxCrc32(buffer,nbBytes); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxExpression.h b/libraries/external/physx/Win32/include/PX/NxExpression.h new file mode 100755 index 0000000..9e52b7a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxExpression.h @@ -0,0 +1,110 @@ +#ifndef NX_PHYSICS_NXEXPRESSION +#define NX_PHYSICS_NXEXPRESSION + +#include + +#include "PX/NxHwParser.h" +#if NX_ENABLE_HW_PARSER + +namespace NxForceFieldInternals +{ + +class NxFloatExp; +class NxVecExp; + +class NxExp +{ + friend std::ostream& operator<<(std::ostream& stream, const NxExp& ); +public: + enum Type + { + BOOL, FLOAT, VECTOR + }; + Type mType; +protected: + NxExp(Type t): mType(t) {} +}; + +class NxBoolExp: public NxExp +{ + friend std::ostream& operator<<(std::ostream& stream, const NxBoolExp& ); + + NxHwParser::Op mOp; + union + { + bool mValue; + int mOffset; + int mId; + struct { NxFloatExp *mFloat1, *mFloat2; }; + struct { NxBoolExp *mBool1, *mBool2; }; + }; + +public: + NxBoolExp(bool val): NxExp(BOOL), mOp(NxHwParser::INLINECONSTANTBOOL), mValue(val) {} + NxBoolExp(NxHwParser::Op op, int offsetOrId): NxExp(BOOL), mOp(op), mOffset(offsetOrId) {} + NxBoolExp(NxHwParser::Op op, NxBoolExp *a1, NxBoolExp *a2): NxExp(BOOL), mOp(op), mBool1(a1), mBool2(a2) {} + NxBoolExp(NxHwParser::Op op, NxFloatExp *a1, NxFloatExp *a2): NxExp(BOOL), mOp(op), mFloat1(a1), mFloat2(a2) {} +}; + +class NxFloatExp: public NxExp +{ + friend std::ostream& operator<<(std::ostream& stream, const NxFloatExp& ); + + NxHwParser::Op mOp; + union + { + int mOffset; + int mId; + NxReal mValue; + struct { NxBoolExp *mBool; NxFloatExp *mFloat1, *mFloat2; }; + struct { NxVecExp *mVec1, *mVec2; }; + }; +public: + NxFloatExp(NxReal val): NxExp(FLOAT), mOp(NxHwParser::INLINECONSTANTFLOAT), mValue(val) {} + NxFloatExp(NxHwParser::Op op, int offsetOrId): NxExp(FLOAT), mOp(op), mOffset(offsetOrId) {} + NxFloatExp(NxHwParser::Op op, NxBoolExp *b, NxFloatExp *a1, NxFloatExp *a2): NxExp(FLOAT), mOp(op), mBool(b), mFloat1(a1), mFloat2(a2) {} + NxFloatExp(NxHwParser::Op op, NxFloatExp *a1, NxFloatExp *a2 = 0): NxExp(FLOAT), mOp(op), mFloat1(a1), mFloat2(a2) {} + NxFloatExp(NxHwParser::Op op, NxVecExp *a1, NxVecExp *a2 = 0): NxExp(FLOAT), mOp(op), mVec1(a1), mVec2(a2) {} +}; + +class NxVecExp: public NxExp +{ + friend std::ostream& operator<<(std::ostream& stream, const NxVecExp& ); + + NxHwParser::Op mOp; + union + { + int mOffset; + int mId; + struct { NxBoolExp *mBool; NxFloatExp *mFloat1; NxVecExp *mVec1, *mVec2; }; + }; +public: + + NxVecExp(NxHwParser::Op op, int offsetOrId): NxExp(VECTOR), mOp(op), mOffset(offsetOrId) {} + NxVecExp(NxHwParser::Op op, NxVecExp *a1, NxVecExp *a2 = 0): NxExp(VECTOR), mOp(op), mVec1(a1), mVec2(a2) {} + NxVecExp(NxHwParser::Op op, NxVecExp *a1, NxFloatExp *a2): mOp(op), NxExp(VECTOR), mVec1(a1), mFloat1(a2) {} + NxVecExp(NxHwParser::Op op, NxBoolExp *b, NxVecExp *a1, NxVecExp *a2): NxExp(VECTOR), mOp(op), mBool(b), mVec1(a1), mVec2(a2) {} + +}; + +class NxCmd +{ + friend std::ostream& operator<<(std::ostream& stream, const NxCmd& ); + + NxHwParser::CmdOp mOp; + int mVarId; + NxExp *mExp; +public: + NxCmd(NxHwParser::CmdOp op, NxBoolExp *e): mOp(op), mExp(e) {} + NxCmd(NxHwParser::CmdOp op, int v, NxExp *e): mOp(op), mVarId(v), mExp(e) {} +}; + +} // namespace +#endif +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxFixedJoint.h b/libraries/external/physx/Win32/include/PX/NxFixedJoint.h new file mode 100755 index 0000000..aabac3c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxFixedJoint.h @@ -0,0 +1,82 @@ +#ifndef NX_PHYSICS_NXFIXEDJOINT +#define NX_PHYSICS_NXFIXEDJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" + +class NxFixedJointDesc; + +/** + \brief A fixed joint permits no relative movement between two bodies. ie the bodies are glued together. + + \image html fixedJoint.png + +

Creation

+ + Example: + + \include NxFixedJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxFixedJointDesc NxScene.createJoint() +*/ +class NxFixedJoint: public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set this objects state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void loadFromDesc(const NxFixedJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve this objects state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void saveToDesc(NxFixedJointDesc& desc) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxFixedJointDesc.h b/libraries/external/physx/Win32/include/PX/NxFixedJointDesc.h new file mode 100755 index 0000000..154a57f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxFixedJointDesc.h @@ -0,0 +1,70 @@ +#ifndef NX_PHYSICS_NXFIXEDJOINTDESC +#define NX_PHYSICS_NXFIXEDJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +/** +\brief Desc class for fixed joint. + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxFixedJoint NxScene.createJoint() +*/ +class NxFixedJointDesc : public NxJointDesc + { + public: + /** + \brief Constructor sets to default. + */ + NX_INLINE NxFixedJointDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Return true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxFixedJointDesc::NxFixedJointDesc() : NxJointDesc(NX_JOINT_FIXED) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxFixedJointDesc::setToDefault() + { + NxJointDesc::setToDefault(); + } + +NX_INLINE bool NxFixedJointDesc::isValid() const + { + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxFluidUserNotify.h b/libraries/external/physx/Win32/include/PX/NxFluidUserNotify.h new file mode 100755 index 0000000..051534c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxFluidUserNotify.h @@ -0,0 +1,100 @@ +#ifndef NX_PHYSICS_NXFLUIDUSERNOTIFY +#define NX_PHYSICS_NXFLUIDUSERNOTIFY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics +@{ +*/ + + +#include "PX/Nxp.h" + +class NxFluidEmitter; +class NxFluid; + +/** +\brief Event types for fluid events. +@see NxFluidUserNotify::onEvent(NxFluid& fluid, NxFluidEventType eventType) +*/ +enum NxFluidEventType +{ + NX_FET_NO_PARTICLES_LEFT, //!< There are no particles left. +}; + + +/** +\brief Event types for emitter events. +@see NxUserNotify::onEmitterEvent(NxFluidEmitter& emitter, NxFluidEmitterEventType eventType) +*/ +enum NxFluidEmitterEventType +{ + NX_FEET_EMITTER_EMPTY, //!< The emitter has reached is emission limit NxEmitterDesc::maxParticles. +}; + + +/** +\brief An interface class that the user can implement in order to receive simulation events. + +Threading: It is not necessary to make this class thread safe as it will only be called in the context of the +user thread. + +See the NxUserNotify documentation for an example of how to use notifications. + +@see NxScene.setFluidUserNotify() NxScene.getFluidUserNotify() NxUserNotify +*/ +class NxFluidUserNotify +{ +public: + /** + \brief This is called during NxScene::fetchResults with fluid emitters that have events. + + \param[in] emitter - The emitter which had the event. + \param[in] eventType - The event type. + \return True to have the system release the emitter now. False to keep the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: No + + @see NxScene.setUserNotify() NxSceneDesc.userNotify + @see NxFluidEmitterEventType + */ + virtual bool onEmitterEvent(NxFluidEmitter& emitter, NxFluidEmitterEventType eventType) = 0; + + /** + \brief This is called during NxScene::fetchResults with fluids that have events. + + \param[in] fluid - The fluid which had the event. + \param[in] eventType - The event type. + \return True to have the system release the fluid now. False to keep the fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: No + + @see NxScene.setUserNotify() NxSceneDesc.userNotify + @see NxFluidEventType + */ + virtual bool onEvent(NxFluid& fluid, NxFluidEventType eventType) = 0; + +protected: + virtual ~NxFluidUserNotify(){}; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceField.h b/libraries/external/physx/Win32/include/PX/NxForceField.h new file mode 100755 index 0000000..7875270 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceField.h @@ -0,0 +1,536 @@ +#ifndef NX_PHYSICS_NXFORCEFIELD +#define NX_PHYSICS_NXFORCEFIELD +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxForceFieldDesc.h" +#include "PX/NxEffector.h" + +class NxEffector; +class NxForceFieldShape; +class NxForceFieldShapeDesc; + +/** + \brief A force field effector. + + Instances of this object automate the application of forces onto rigid bodies, fluid, soft bodies and cloth. + +Platform: +\li PC SW: Yes +\li PPU : Yes [SW fallback] +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldDesc, NxScene::createForceField() +*/ + +class NxForceField + { + protected: + NX_INLINE NxForceField() : userData(NULL) {} + virtual ~NxForceField() {} + + public: + /** + \brief Writes all of the effector's attributes to the description, as well + as setting the actor connection point. + + \param[out] desc The descriptor used to retrieve the state of the effector. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void saveToDesc(NxForceFieldDesc &desc) = 0; + + /** + \brief Retrieves the force field's transform. + + This transform is either from world space or from actor space, depending on whether the actor pointer is set. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setPose() getActor() NxForceFieldDesc::pose + */ + virtual NxMat34 getPose() const = 0; + + /** + \brief Sets the force field's transform. + + This transform is either from world space or from actor space, depending on whether the actor pointer is set. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getPose() getActor() NxForceFieldDesc::pose + */ + virtual void setPose(const NxMat34 & pose) = 0; + + /** + \brief Retrieves the actor pointer that this force field is attached to. + + Unattached force fields return NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setActor() NxForceFieldDesc::actor + */ + virtual NxActor * getActor() const = 0; + + /** + \brief Sets the actor pointer that this force field is attached to. + + Pass NULL for unattached force fields. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getActor() NxForceFieldDesc::actor + */ + virtual void setActor(NxActor * actor) = 0; + + /** + \brief Sets the kernel function which this field will be using + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setForceFieldKernel(NxForceFieldKernel * kernel) = 0; + + /** + \brief Retrieves the kernel function which this field is using + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldKernel* getForceFieldKernel() = 0; + + /** + \brief Retrieves the include shape group of this forcefield. Shapes in this group will move with the force field. + + \return NxForceFieldShapeGroup The includeGroup of this force field. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldShapeGroup& getIncludeShapeGroup() = 0; + + /** + \brief Adds a force field shape group to this force field to define its volume of activity. + + \param[in] group A force field shape group. See #NxForceFieldShapeGroup + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void addShapeGroup(NxForceFieldShapeGroup& group) = 0; + + /** + \brief Removes a force field shape group from this force field. + + \param[in] group A force field shape group. See #NxForceFieldShapeGroup + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void removeShapeGroup(NxForceFieldShapeGroup &) = 0; + + /** + \brief Returns the number of force field shape groups of this force field. (not counting the include group) + + \return The Number of force field shape groups. See #NxForceFieldShapeGroup + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbShapeGroups() const = 0; + + /** + \brief Restarts the force field shape groups iterator so that the next call to getNextShape() returns the first shape in the force field. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void resetShapeGroupsIterator() = 0; + + /** + \brief Retrieves the next FF shape group when iterating. + + \return NxForceFieldShapeGroup See #NxForceFieldShapeGroup + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldShapeGroup* getNextShapeGroup() = 0; + + /** + \brief Retrieves the value set with #setGroup(). + + NxCollisionGroup is an integer between 0 and 31. + + \return The collision group this shape belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setGroup() NxCollisionGroup + */ + virtual NxCollisionGroup getGroup() const = 0; + + /** + \brief Sets which collision group this shape is part of. + + Default group is 0. Maximum possible group is 31. + Collision groups are sets of shapes which may or may not be set + to collision detect with each other; this can be set using NxScene::setGroupCollisionFlag() + + \param[in] collisionGroup The collision group for this shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getGroup() NxCollisionGroup + */ + virtual void setGroup(NxCollisionGroup collisionGroup) = 0; + + /** + \brief Gets 128-bit mask used for collision filtering. See comments for ::NxGroupsMask + + \return The group mask for the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setGroupsMask() + */ + virtual NxGroupsMask getGroupsMask() const = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. See comments for ::NxGroupsMask + + \param[in] mask The group mask to set for the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getGroupsMask() + */ + virtual void setGroupsMask(NxGroupsMask mask) = 0; + + /** + \brief Gets the Coordinate space of the field. + + \return NxForceFieldCoordinates See #NxForceFieldCoordinates + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldCoordinates getCoordinates() const = 0; + + /** + \brief Sets the Coordinate space of the field. Transforms position and velocity of objects into this space prior to kernel evaluation. + + \param[in] coordinates The coordinate system. See #NxForceFieldCoordinates + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setCoordinates(NxForceFieldCoordinates coordinates) = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName (const char* name) = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The name string for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName () const = 0; + + /** + \brief Gets the force field scaling type for fluids + + \return NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldType getFluidType() const = 0; + + /** + \brief Sets the force field scaling type for fluids + + \param[in] t NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setFluidType(NxForceFieldType t) = 0; + + /** + \brief Gets the force field scaling type for cloths + + \return NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldType getClothType() const = 0; + + /** + \brief Sets the force field scaling type for cloths + + \param[in] t NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setClothType(NxForceFieldType t) = 0; + + /** + \brief Gets the force field scaling type for soft bodies + + \return NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldType getSoftBodyType() const = 0; + + /** + \brief Sets the force field scaling type for soft bodies + + \param[in] t NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setSoftBodyType(NxForceFieldType t) = 0; + + /** + \brief Gets the force field scaling type for rigid bodies + + \return NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldType getRigidBodyType() const = 0; + + /** + \brief Sets the force field scaling type for rigid bodies + + \param[in] t NxForceFieldType The force field scaling type for fluids. See #NxForceFieldType + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setRigidBodyType(NxForceFieldType t) = 0; + + /** + \brief Gets the force field flags @see NxForceFieldFlags + + \return NxForceFieldFlags The force field flags + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getFlags () const = 0; + + /** + \brief Sets the force field flags @see NxForceFieldFlags + + \param[in] f NxForceFieldFlags The force field flags + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setFlags(NxU32 f) = 0; + + /** + \brief Samples the force field. Incoming points & velocities must be in world space. The velocities pointer is optional and can be null. + + \param[in] numPoints Size of the buffers + \param[in] points Buffer of sample points + \param[in] velocities Buffer of velocities at the sample points + \param[out] outForces Buffer for the returned forces + \param[out] outTorques Buffer for the returned torques + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void samplePoints(NxU32 numPoints, const NxVec3* points, const NxVec3* velocities, NxVec3* outForces, NxVec3* outTorques) const = 0; + + /** + \brief Retrieves the scene which this force field belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + /** + \brief Retrieves the force field variety index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldVariety getForceFieldVariety() const = 0; + + /** + \brief Sets the force field variety index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setForceFieldVariety(NxForceFieldVariety) = 0; + + + //public variables: + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldDesc.h b/libraries/external/physx/Win32/include/PX/NxForceFieldDesc.h new file mode 100755 index 0000000..ad86c6c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldDesc.h @@ -0,0 +1,359 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDDESC +#define NX_PHYSICS_NXFORCEFIELDDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxArray.h" +#include "PX/NxForceFieldShapeDesc.h" + +class NxActor; +class NxForceFieldKernel; +class NxForceFieldShapeGroup; + +/** +\brief Type of force field coordinate space +*/ +enum NxForceFieldCoordinates { NX_FFC_CARTESIAN, NX_FFC_SPHERICAL, NX_FFC_CYLINDRICAL, NX_FFC_TOROIDAL }; + +enum NxForceFieldType + { + NX_FF_TYPE_DUMMY_0, // deprecated enum placeholder + NX_FF_TYPE_DUMMY_1, // deprecated enum placeholder + NX_FF_TYPE_GRAVITATIONAL, //!< scales the force by the mass of the particle or body + NX_FF_TYPE_OTHER, //!< does not scale the value from the force field + NX_FF_TYPE_NO_INTERACTION //!< used to disable force field interaction with a specific feature + }; + +enum NxForceFieldFlags + { + NX_FFF_DUMMY_0 = (1<<0), // deprecated flag placeholder + NX_FFF_DUMMY_1 = (1<<1), // deprecated flag placeholder + NX_FFF_DUMMY_2 = (1<<2), // deprecated flag placeholder + NX_FFF_DUMMY_3 = (1<<3), // deprecated flag placeholder + NX_FFF_VOLUMETRIC_SCALING_FLUID = (1<<5), //!< indicates whether the force is scaled by the amount of volume represented by the feature. + NX_FFF_VOLUMETRIC_SCALING_CLOTH = (1<<6), //!< indicates whether the force is scaled by the amount of volume represented by the feature. + NX_FFF_VOLUMETRIC_SCALING_SOFTBODY = (1<<7), //!< indicates whether the force is scaled by the amount of volume represented by the feature. + NX_FFF_VOLUMETRIC_SCALING_RIGIDBODY = (1<<8), //!< indicates whether the force is scaled by the amount of volume represented by the feature. + }; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + \brief Descriptor class for NxForceField class. + + +Platform: +\li PC SW: Yes +\li PPU : Yes [SW fallback] +\li PS3 : Yes +\li XB360: Yes + + @see NxForceField +*/ +class NxForceFieldDesc + { + public: + + /** + \brief Global or (if actor is set) actor relative transformation of the force field. + Detaching from the actor will cause the force field's pose to be relative to the world frame. + + Default: Identity + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxMat34 pose; + + /** + \brief The field's pose is relative to the actor's pose and relative to the world frame if field is null. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxActor* actor; + + /** + \brief Coordinate space of the field. + + Default: NX_FFC_CARTESIAN + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldCoordinates coordinates; + + /** + \brief Array of force field shapes descriptors which will be created inside the include group of this force field. This group moves with the force field and cannot be shared. + + Default: empty + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxArray + includeGroupShapes; + + /** + \brief a collection of NxForceFieldShapeGroup objects. @see NxForceFieldShapeGroup + + Default: empty + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxArray + shapeGroups; + /** + \brief Collision group used for collision filtering. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxCollisionGroup group; + + /** + \brief Groups mask used for collision filtering. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxGroupsMask groupsMask; + + /** + \brief kernel function of the force field. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldKernel* kernel; + + /** + \brief Force Field Variety Index, index != 0 has to be created. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldVariety forceFieldVariety; + + /** + \brief Force field type for fluids + + Default: NX_FF_TYPE_OTHER + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldType fluidType; + + /** + \brief Force field type for cloth + + Default: NX_FF_TYPE_OTHER + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldType clothType; + + /** + \brief Force field type for soft bodies + + Default: NX_FF_TYPE_OTHER + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldType softBodyType; + + /** + \brief Force field type for rigid bodies + + Default: NX_FF_TYPE_OTHER + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxForceFieldType rigidBodyType; + + /** + \brief Force field flags; @see NxForceFieldFlags + + Default: NX_FFF_VOLUMETRIC_SCALING_FLUID | NX_FFF_VOLUMETRIC_SCALING_CLOTH | NX_FFF_VOLUMETRIC_SCALING_SOFTBODY | NX_FFF_VOLUMETRIC_SCALING_RIGIDBODY + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 flags; //!< + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief Will be copied to NxForceField::userData + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxForceField.userData + */ + void* userData; + + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxForceFieldDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxForceFieldDesc::NxForceFieldDesc() + { + setToDefault(); + } + +NX_INLINE void NxForceFieldDesc::setToDefault() + { + pose.id(); + actor = NULL; + coordinates = NX_FFC_CARTESIAN; + + includeGroupShapes .clear(); + + group = 0; + groupsMask.bits0 = 0; + groupsMask.bits1 = 0; + groupsMask.bits2 = 0; + groupsMask.bits3 = 0; + + kernel = NULL; + + flags = NX_FFF_VOLUMETRIC_SCALING_FLUID | + NX_FFF_VOLUMETRIC_SCALING_CLOTH | + NX_FFF_VOLUMETRIC_SCALING_SOFTBODY | + NX_FFF_VOLUMETRIC_SCALING_RIGIDBODY; + + forceFieldVariety = 0; + + fluidType = NX_FF_TYPE_OTHER; + clothType = NX_FF_TYPE_OTHER; + softBodyType = NX_FF_TYPE_OTHER; + rigidBodyType = NX_FF_TYPE_OTHER; + + name = NULL; + userData = NULL; + } + +NX_INLINE bool NxForceFieldDesc::isValid() const + { + + for(NxU32 i = 0; i < includeGroupShapes.size(); i++) + { + if(!includeGroupShapes[i]->isValid()) + return false; + } + + if(group>=32) + return false; // We only support 32 different groups + + if(!kernel) + return false; + + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldKernel.h b/libraries/external/physx/Win32/include/PX/NxForceFieldKernel.h new file mode 100755 index 0000000..872949a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldKernel.h @@ -0,0 +1,42 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDKERNEL +#define NX_PHYSICS_NXFORCEFIELDKERNEL +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ +#include "PX/Nxp.h" + +enum NxForcFieldKernelType + { + NX_FFK_LINEAR_KERNEL, //!< The kernel type is linear kernel. For internal use only. + NX_FFK_CUSTOM_KERNEL //!< The kernel type is custom kernel. For internal use only. + }; + +class NxForceFieldKernel +{ +public: + virtual ~NxForceFieldKernel(){}; //!< For internal use only. + virtual void parse() const = 0; //!< For internal use only. + virtual bool evaluate(NxVec3 &force, NxVec3 &torque, const NxVec3 &position, const NxVec3 &velocity) const = 0; //!< For internal use only. + virtual NxU32 getType() const = 0; //!< For internal use only. + virtual NxForceFieldKernel* clone() const = 0; //!< For internal use only. + virtual void update(NxForceFieldKernel& in) const = 0; //!< For internal use only. + virtual void setEpsilon(NxReal eps) = 0; //!< For internal use only. + + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldKernelDefs.h b/libraries/external/physx/Win32/include/PX/NxForceFieldKernelDefs.h new file mode 100755 index 0000000..a3e24c2 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldKernelDefs.h @@ -0,0 +1,158 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDKERNELDEFS +#define NX_PHYSICS_NXFORCEFIELDKERNELDEFS + +#include "PX/Nxp.h" +#include "PX/NxTargets.h" + +#define NxBoolean typename NxTarget::BVarType +#define NxFloat typename NxTarget::FVarType +#define NxVector typename NxTarget::VVarType +#define NxFailIf(_x) if(NxTarget::testFailure(_x)) return false; +#define NxFinishIf(_x) if(NxTarget::testFinish(_x)) return true; +#define NxSelect(_x,_y,_z) typename NxTarget::BVarType(_x).select((_y),(_z)) + +#define NxFConst(name) \ +private: \ + typename NxTarget::FConstType name; \ +public: \ +NxReal get##name() { return NxForceFieldInternals::NxSw::getFloatVal(name); } \ +void set##name(NxReal x) { mUpdateCounter++; name = x; } \ + +#define NxVConst(name) \ +private: \ + typename NxTarget::VConstType name; \ +public: \ +NxVec3 get##name() { return NxForceFieldInternals::NxSw::getVecVal(name); } \ +void set##name(const NxVec3& x) { mUpdateCounter++; name = x; } \ + +#define NxBConst(name) \ +private: \ + typename NxTarget::BConstType name; \ +public: \ +NxVec3 get##name() { return NxForceFieldInternals::NxSw::getBoolVal(name); } \ +void set##name(bool x) { mUpdateCounter++; name = x; } \ + + +#define NX_START_FORCEFIELD(name) \ +template \ +class NxForceFieldKernelTemplate##name \ +{ \ + friend class NxForceFieldKernel##name; \ +protected: \ + NxU32 mUpdateCounter; \ + +#define NX_START_FUNCTION \ +protected: \ +bool eval(typename NxTarget::VVarType& force, \ + typename NxTarget::VVarType& torque, \ + const typename NxTarget::VConstType& Position, \ + const typename NxTarget::VConstType& Velocity) const \ +{ \ + +#define NX_END_FUNCTION \ + return true; \ +} \ + +#if NX_ENABLE_HW_PARSER + #define NX_END_FORCEFIELD(name) \ + }; \ + \ + class NxForceFieldKernel##name : \ + public NxForceFieldKernel, \ + public NxForceFieldKernelTemplate##name \ + { \ + public: \ + void parse() const \ + { \ + NxForceFieldInternals::NxHw::VVarType force, torque; \ + const NxForceFieldInternals::NxHw::VConstType position, velocity; \ + NxForceFieldKernelTemplate##name hwField;\ + hwField.eval(force, torque, position, velocity); \ + } \ + \ + bool evaluate( NxVec3& force, \ + NxVec3& torque, \ + const NxVec3& position, \ + const NxVec3& velocity) const \ + { \ + return eval((NxForceFieldInternals::NxSwVecVar&)force,(NxForceFieldInternals::NxSwVecVar&)torque, \ + position, velocity); \ + } \ + \ + NxU32 getType() const { return NX_FFK_CUSTOM_KERNEL; } \ + NxForceFieldKernel* clone() const { return NULL; } \ + void update(NxForceFieldKernel& in) const {} \ + void setEpsilon(NxReal eps) {} \ + \ + void* operator new(size_t size) \ + { \ + return NxGetPhysicsSDKAllocator()->malloc(size); \ + } \ + \ + void operator delete(void* p) \ + { \ + NxGetPhysicsSDKAllocator()->free(p); \ + } \ + }; +#else + #define NX_END_FORCEFIELD(name) \ + }; \ + \ + class NxForceFieldKernel##name : \ + public NxForceFieldKernel, \ + public NxForceFieldKernelTemplate##name \ + { \ + public: \ + void parse() const {} \ + bool evaluate( NxVec3& force, \ + NxVec3& torque, \ + const NxVec3& position, \ + const NxVec3& velocity) const \ + { \ + return eval((NxForceFieldInternals::NxSwVecVar&)force,(NxForceFieldInternals::NxSwVecVar&)torque, \ + position, velocity); \ + } \ + \ + NxU32 getType() const { return NX_FFK_CUSTOM_KERNEL; } \ + \ + NxForceFieldKernel* clone() const \ + { \ + NxForceFieldKernel##name* clone; \ + clone = new NxForceFieldKernel##name(); \ + *clone = *this; \ + return clone; \ + } \ + \ + void update(NxForceFieldKernel& in) const \ + { \ + NxForceFieldKernel##name* dest; \ + dest = static_cast(&in); \ + if(dest->mUpdateCounter == mUpdateCounter) return; \ + *dest = *this; \ + } \ + \ + void setEpsilon(NxReal eps) \ + { \ + NxForceFieldInternals::NxSwFloat::setEpsilon(eps); \ + } \ + \ + void* operator new(size_t size) \ + { \ + return NxGetPhysicsSDKAllocator()->malloc(size); \ + } \ + \ + void operator delete(void* p) \ + { \ + NxGetPhysicsSDKAllocator()->free(p); \ + } \ + }; +#endif + +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldLinearKernel.h b/libraries/external/physx/Win32/include/PX/NxForceFieldLinearKernel.h new file mode 100755 index 0000000..9eb8aca --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldLinearKernel.h @@ -0,0 +1,302 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDLINEARKERNEL +#define NX_PHYSICS_NXFORCEFIELDLINEARKERNEL +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ +#include "PX/Nxp.h" +#include "PX/NxForceFieldKernel.h" +#include "PX/NxForceFieldLinearKernelDesc.h" + + +class NxForceFieldLinearKernel : public NxForceFieldKernel +{ +protected: + NX_INLINE NxForceFieldLinearKernel() {} + virtual ~NxForceFieldLinearKernel() {} + +public: + + /** + \brief Gets the constant part of force field function. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxVec3 getConstant () const= 0; + + /** + \brief Sets the constant part of force field function. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setConstant (const NxVec3 &) = 0; + + /** + \brief Gets the coefficient of force field function position term. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxMat33 getPositionMultiplier () const = 0; + + /** + \brief Sets the coefficient of force field function position term. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setPositionMultiplier (const NxMat33 & ) = 0; + + /** + \brief Gets the coefficient of force field function velocity term. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxMat33 getVelocityMultiplier () const = 0; + + + /** + \brief Sets the coefficient of force field function velocity term. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setVelocityMultiplier (const NxMat33 & ) = 0; + + /** + \brief Gets the force field position target. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxVec3 getPositionTarget () const = 0; + + /** + \brief Sets the force field position target. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setPositionTarget (const NxVec3 & ) = 0; + + /** + \brief Gets the force field velocity target. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxVec3 getVelocityTarget () const = 0; + + /** + \brief Sets the force field velocity target. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setVelocityTarget (const NxVec3 & ) = 0; + + /** + \brief Sets the linear falloff term. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxVec3 getFalloffLinear() const = 0; + + /** + \brief Sets the linear falloff term. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setFalloffLinear(const NxVec3 &) = 0; + + /** + \brief Sets the quadratic falloff term. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxVec3 getFalloffQuadratic() const = 0; + + /** + \brief Sets the quadratic falloff term. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setFalloffQuadratic(const NxVec3 &) = 0; + + /** + \brief Gets the force field noise. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxVec3 getNoise () const = 0; + + /** + \brief Sets the force field noise. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setNoise (const NxVec3 & ) = 0; + + /** + \brief ets the toroidal radius. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxReal getTorusRadius () const = 0; + + /** + \brief ets the toroidal radius. + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void setTorusRadius(NxReal) = 0; + + /** + \brief Retrieves the scene which this kernel belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + /** + \brief Writes all of the kernel's attributes to the description, as well + as setting the actor connection point. + + \param[out] desc The descriptor used to retrieve the state of the kernel. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void saveToDesc(NxForceFieldLinearKernelDesc &desc) = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName (const char* name)= 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The name string for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName () const = 0; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldLinearKernelDesc.h b/libraries/external/physx/Win32/include/PX/NxForceFieldLinearKernelDesc.h new file mode 100755 index 0000000..035537d --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldLinearKernelDesc.h @@ -0,0 +1,229 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDLINEARKERNELDESC +#define NX_PHYSICS_NXFORCEFIELDLINEARKERNELDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ +#include "PX/Nxp.h" +#include "PX/NxForceFieldDesc.h" + +/** + \brief Descriptor class for NxForceFieldLinearKernel class. + +Platform: +\li PC SW: Yes +\li PPU : Yes [SW fallback] +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldLinearKernel +*/ + +class NxForceFieldLinearKernelDesc +{ + public: + + /** + \brief Constant part of force field function + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 constant; + + /** + \brief Coefficient of force field function position term + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxMat33 positionMultiplier; + + /** + \brief Force field position target. + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 positionTarget; + + /** + \brief Coefficient of force field function velocity term + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxMat33 velocityMultiplier; + + /** + \brief Force field velocity target + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 velocityTarget; + + /** + \brief Radius for NX_FFC_TOROIDAL type coordinates. + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxReal torusRadius; + + /** + \brief Linear term in magnitude falloff factor. Range (each component): [0, inf) + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 falloffLinear; + + /** + \brief Quadratic term in magnitude falloff factor. Range (each component): [0, inf) + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 falloffQuadratic; + + /** + \brief Noise scaling + + Default zero + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 noise; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief Will be copied to NxForceField::userData + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxForceField.userData + */ + void* userData; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxForceFieldLinearKernelDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + +}; + +NX_INLINE NxForceFieldLinearKernelDesc::NxForceFieldLinearKernelDesc() + { + setToDefault(); + } + +NX_INLINE void NxForceFieldLinearKernelDesc::setToDefault() + { + constant .zero(); + positionMultiplier .zero(); + positionTarget .zero(); + velocityMultiplier .zero(); + velocityTarget .zero(); + falloffLinear .zero(); + falloffQuadratic .zero(); + noise .zero(); + torusRadius = 1.0f; + name = NULL; + } + +NX_INLINE bool NxForceFieldLinearKernelDesc::isValid() const + { + if(torusRadius<0.0f) + return false; + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldShape.h b/libraries/external/physx/Win32/include/PX/NxForceFieldShape.h new file mode 100755 index 0000000..650717e --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldShape.h @@ -0,0 +1,367 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDSHAPE +#define NX_PHYSICS_NXFORCEFIELDSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxForceFieldShapeDesc.h" + +class NxSphereForceFieldShape; +class NxBoxForceFieldShape; +class NxCapsuleForceFieldShape; +class NxConvexForceFieldShape; + +/** + \brief A shape that represents a volume in which the force field acts on objects. + + +Platform: +\li PC SW: Yes +\li PPU : Yes [SW fallback] +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShapeDesc, NxForceField +*/ +class NxForceFieldShape + { + protected: + NX_INLINE NxForceFieldShape() : userData(NULL), appData(NULL) {} + virtual ~NxForceFieldShape() {} + public: + + /** + \brief Retrieves the force field shape's transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setPose() getFlags() NxForceFieldShapeDesc::pose + */ + virtual NxMat34 getPose() const = 0; + + /** + \brief Sets the force field shape's transform. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getPose() getFlags() NxForceFieldShapeDesc::pose + */ + virtual void setPose(const NxMat34 &) = 0; + + /** + \brief Returns the owning force field if this is a shape of an include group, else NULL will be returned + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxForceField + */ + virtual NxForceField * getForceField() const = 0; + + /** + \brief Returns the owning force field shape group. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxForceField + */ + virtual NxForceFieldShapeGroup & getShapeGroup() const = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName (const char *name)= 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The name string for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char * getName () const = 0; + + /** + \brief Retrieve the type of this force field shape. + \return The type of force field shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType + */ + virtual NxShapeType getType () const = 0; + + /** + \brief Type casting operator. The result may be cast to the desired subclass type. + + \param[in] type Used to query for a specific effector type. + \return NULL if the object if not of type(see #NxShapeType). Otherwise a pointer to this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType + */ + NX_INLINE void * is (NxShapeType type); + + /** + \brief Type casting operator. The result may be cast to the desired subclass type. + + \param[in] type Used to query for a specific effector type. + \return NULL if the object if not of type(see #NxShapeType). Otherwise a pointer to this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType + */ + NX_INLINE const void * is (NxShapeType type) const; + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxSphereForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxSphereForceFieldShape + */ + NX_INLINE NxSphereForceFieldShape * isSphere (); + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxSphereForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxSphereForceFieldShape() + */ + NX_INLINE const NxSphereForceFieldShape * isSphere () const; + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxBoxForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxForceFieldShape() + */ + NX_INLINE NxBoxForceFieldShape * isBox (); + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxBoxForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxBoxForceFieldShape + */ + NX_INLINE const NxBoxForceFieldShape * isBox () const; + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxCapsuleForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleForceFieldShape + */ + NX_INLINE NxCapsuleForceFieldShape * isCapsule (); + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxCapsuleForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsuleForceFieldShape + */ + NX_INLINE const NxCapsuleForceFieldShape * isCapsule () const; + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxConvexForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexForceFieldShape + */ + NX_INLINE NxConvexForceFieldShape * isConvex (); + + /** + \brief Attempts to perform a downcast to the type returned. + + Returns 0 if this object is not of the appropriate type. + + \return If this is a NxConvexForceFieldShape a pointer otherwise NULL. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxConvexForceFieldShape + */ + NX_INLINE const NxConvexForceFieldShape * isConvex () const; + + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + void* appData; //!< used internally, do not change. + }; + +NX_INLINE void * NxForceFieldShape::is (NxShapeType type) + { + return (type == getType()) ? (void*)this : NULL; + } + +NX_INLINE const void * NxForceFieldShape::is (NxShapeType type) const + { + return (type == getType()) ? (const void*)this : NULL; + } + +NX_INLINE NxSphereForceFieldShape * NxForceFieldShape::isSphere () + { + return (NxSphereForceFieldShape*)is(NX_SHAPE_SPHERE); + } + +NX_INLINE const NxSphereForceFieldShape * NxForceFieldShape::isSphere () const + { + return (const NxSphereForceFieldShape*)is(NX_SHAPE_SPHERE); + } + +NX_INLINE NxBoxForceFieldShape * NxForceFieldShape::isBox () + { + return (NxBoxForceFieldShape*)is(NX_SHAPE_BOX); + } + +NX_INLINE const NxBoxForceFieldShape * NxForceFieldShape::isBox () const + { + return (const NxBoxForceFieldShape*)is(NX_SHAPE_BOX); + } + +NX_INLINE NxCapsuleForceFieldShape * NxForceFieldShape::isCapsule () + { + return (NxCapsuleForceFieldShape*)is(NX_SHAPE_CAPSULE); + } + +NX_INLINE const NxCapsuleForceFieldShape * NxForceFieldShape::isCapsule () const + { + return (const NxCapsuleForceFieldShape*)is(NX_SHAPE_CAPSULE); + } + +NX_INLINE NxConvexForceFieldShape * NxForceFieldShape::isConvex () + { + return (NxConvexForceFieldShape*)is(NX_SHAPE_CONVEX); + } + +NX_INLINE const NxConvexForceFieldShape * NxForceFieldShape::isConvex () const + { + return (const NxConvexForceFieldShape*)is(NX_SHAPE_CONVEX); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxForceFieldShapeDesc.h new file mode 100755 index 0000000..859a072 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldShapeDesc.h @@ -0,0 +1,150 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDSHAPEDESC +#define NX_PHYSICS_NXFORCEFIELDSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** + \brief Descriptor class for NxForceFieldShape + + +Platform: +\li PC SW: Yes +\li PPU : Yes [SW fallback] +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShape, NxForceField +*/ +class NxForceFieldShapeDesc + { + protected: + /** + \brief The type of shape. This is set by the c'tor of the derived class. + */ + NxShapeType type; + + public: + + /** + \brief shape's pose + + Default: Identity + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + NxMat34 pose; + + + /** + \brief Will be copied to NxForceFieldShape::userData. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief Constructor sets to default. + */ + virtual NX_INLINE ~NxForceFieldShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + + /** + \brief Retrieves the shape type. + + \return The type of shape this descriptor describes. + + @see NxShapeType + */ + NX_INLINE NxShapeType getType() const; + + protected: + /** + \brief Constructor sets to default. + + \param type shape type + */ + NX_INLINE NxForceFieldShapeDesc(NxShapeType type); + }; + +NX_INLINE NxForceFieldShapeDesc::NxForceFieldShapeDesc(NxShapeType t) : type(t) + { + setToDefault(); + } + +NX_INLINE NxForceFieldShapeDesc::~NxForceFieldShapeDesc() + { + } + +NX_INLINE void NxForceFieldShapeDesc::setToDefault() + { + pose.id(); + + name = NULL; + userData = NULL; + } + +NX_INLINE bool NxForceFieldShapeDesc::isValid() const + { + return true; + } + +NX_INLINE NxShapeType NxForceFieldShapeDesc::getType() const + { + return type; + } + + + + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldShapeGroup.h b/libraries/external/physx/Win32/include/PX/NxForceFieldShapeGroup.h new file mode 100755 index 0000000..4692822 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldShapeGroup.h @@ -0,0 +1,208 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDSHAPEGROUP +#define NX_PHYSICS_NXFORCEFIELDSHAPEGROUP +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxScene; +class NxForceField; +class NxForceFieldShape; +class NxForceFieldShapeDesc; +class NxForceFieldShapeGroupDesc; + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +class NxForceFieldShapeGroup + { + protected: + NX_INLINE NxForceFieldShapeGroup() : userData(NULL) {} + virtual ~NxForceFieldShapeGroup() {} + + public: + + /** + \brief Creates a NxForceFieldShape and adds it to the group. + + The volume of activity of the force field is defined by the union of all of the force field's shapes' volumes created + here without the NX_FFS_EXCLUDE flag set, minus the union of all of the force field's shapes with the NX_FFS_EXCLUDE flag set. + + The shapes are owned by the force field and released if the force field is released. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see releaseShape() NxForceFieldShapeDesc + */ + virtual NxForceFieldShape* createShape(const NxForceFieldShapeDesc &) = 0; + + /** + \brief Releases the passed force field shape. + + The passed force field shape must previously have been created with this force field's createShape() call. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see createShape() NxForceFieldShapeDesc + */ + virtual void releaseShape(const NxForceFieldShape &) = 0; + + /** + \brief Returns the number of shapes in the force field group. + + \return The number of shapes in this group. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see createShape() NxForceFieldShapeDesc + */ + virtual NxU32 getNbShapes() const = 0; + + /** + \brief Restarts the shape iterator so that the next call to getNextShape() returns the first shape in the force field group. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void resetShapesIterator() = 0; + + /** + \brief Retrieves the next shape when iterating. + + \return NxForceFieldShape See #NxForceFieldShape + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxForceFieldShape* getNextShape() = 0; + + /** + \brief If this is an include group, getForceField() will return the force field of this group, else NULL will be returned. + + \return NxForceField See #NxForceField + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxForceField* getForceField() const = 0; + + /** + \brief Returns the force field shape group flags. @see NxForceFieldShapeGroupFlags + + \return NxForceFieldShapeGroupFlags See #NxForceFieldShapeGroupFlags + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxU32 getFlags() const = 0; + + /** + \brief Writes all of the shape groups's attributes to the description + + \param[out] desc The descriptor used to retrieve the state of the shape group. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void saveToDesc(NxForceFieldShapeGroupDesc &desc) = 0; + + /** + \brief Retrieves the scene which this force field group belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName (const char* name)= 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The name string for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName () const = 0; + + //public variables: + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxForceFieldShapeGroupDesc.h b/libraries/external/physx/Win32/include/PX/NxForceFieldShapeGroupDesc.h new file mode 100755 index 0000000..b839b55 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxForceFieldShapeGroupDesc.h @@ -0,0 +1,144 @@ +#ifndef NX_PHYSICS_NXFORCEFIELDSHAPEGROUPDESC +#define NX_PHYSICS_NXFORCEFIELDSHAPEGROUPDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxForceFieldShapeDesc.h" + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +enum NxForceFieldShapeGroupFlags + { + NX_FFSG_EXCLUDE_GROUP = (1 << 0), //!< Defines whether the shapes in this group will be include or exclude volumes + }; + +/** + \brief Descriptor class for NxForceFieldShapeGroup class. + +Platform: +\li PC SW: Yes +\li PPU : Yes [SW fallback] +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShapeGroup +*/ +class NxForceFieldShapeGroupDesc + { + public: + + /** + \brief Flags of the force field shape group. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceFieldShapeGroupFlags + */ + NxU32 flags; + + /** + \brief A list of force field shape descriptors which will be added to the group. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxArray shapes; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief Will be copied to NxForceFieldShapeGroupDesc::userData + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceFieldShapeGroupDesc.userData + */ + void* userData; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxForceFieldShapeGroupDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxForceFieldShapeGroupDesc::NxForceFieldShapeGroupDesc() + { + setToDefault(); + } + +NX_INLINE void NxForceFieldShapeGroupDesc::setToDefault() + { + flags = 0; + name = NULL; + userData = NULL; + shapes .clear(); + } + +NX_INLINE bool NxForceFieldShapeGroupDesc::isValid() const + { + for(NxU32 i = 0; i < shapes.size(); i++) + { + if(!shapes[i]->isValid()) + return false; + } + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxFoundation.h b/libraries/external/physx/Win32/include/PX/NxFoundation.h new file mode 100755 index 0000000..3516ee5 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxFoundation.h @@ -0,0 +1,44 @@ +#ifndef NX_FOUNDATION_ +#define NX_FOUNDATION_ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +/** +This is main user include of foundation SDK. It includes the most often +used headers of the foundation SDK at once. The user may also include +a subset of these separately instead. +*/ +#include "PX/Nx.h" +#include "PX/NxUserOutputStream.h" +#include "PX/NxUserAllocator.h" +#include "PX/NxFoundationSDK.h" +#include "PX/NxArray.h" +#include "PX/NxBitField.h" +#include "PX/NxBounds3.h" +#include "PX/NxBox.h" +#include "PX/NxCapsule.h" +#include "PX/NxPlane.h" +#include "PX/NxRay.h" +#include "PX/NxSegment.h" +#include "PX/NxSphere.h" +#include "PX/NxDebugRenderable.h" +#include "PX/NxSimpleTriangleMesh.h" +#include "PX/NxUtilities.h" +#include "PX/NxRemoteDebugger.h" + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxFoundationSDK.h b/libraries/external/physx/Win32/include/PX/NxFoundationSDK.h new file mode 100755 index 0000000..5ff6c8f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxFoundationSDK.h @@ -0,0 +1,112 @@ +#ifndef NX_FOUNDATION_NXFOUNDATIONSDK +#define NX_FOUNDATION_NXFOUNDATIONSDK +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nxf.h" +#include "PX/NxVersionNumber.h" + +class NxUserOutputStream; +class NxUserAllocator; +class NxProfilingZone; +class NxDebugRenderable; +class NxUserDebugRenderer; +class NxDebugRenderable; +class NxRemoteDebugger; + +/** +\brief Foundation SDK singleton class. + +You need to have an instance of this class to instance the higher level SDKs. +*/ +class NxFoundationSDK + { + public: + /** + Destroys the instance it is called on. + + Use this release method to destroy an instance of this class. Be sure + to not keep a reference to this object after calling release. + + Note: the foundation SDK instance used by the SDK should not be manually released, + please use the NxReleasePhysicsSDK() function to release the SDK and foundation SDK. + */ + virtual void release() = 0; + + /** + Sets an error stream provided by the user. + + After an error stream has been set, human readable error messages + will be inserted into it. + + \param stream Stream to report error on. + */ + virtual void setErrorStream(NxUserOutputStream* stream) = 0; + + /** + retrieves error stream + */ + virtual NxUserOutputStream* getErrorStream() = 0; + + /** + retrieves information about the last (most recent) error that has occurred, and then + resets both the last error code to NXE_NO_ERROR. + */ + virtual NxErrorCode getLastError() = 0; + + /** + retrieves information about the first error that has occurred since the last call to + getLastError() or getFirstError(), and then this error code to NXE_NO_ERROR. + */ + virtual NxErrorCode getFirstError() = 0; + + /** + retrieves the current allocator. + */ + virtual NxUserAllocator & getAllocator() = 0; + + /** + retrieves the current remote debugger. + */ + virtual NxRemoteDebugger* getRemoteDebugger() = 0; + + /* + creates a profiling zone. At the moment this is not needed by the user. + */ + //virtual NxProfilingZone* createProfilingZone(const char * x) = 0; + + /** + Sets the threshold for internal stack allocation. By default, stack allocations + are limited to half the default stack size for the platform or half the smallest + stack size of any thread created by the SDK. If called with threshold 0, this automatic + scheme is re-activated. + */ + virtual void setAllocaThreshold(NxU32 threshold) = 0; + + protected: + virtual ~NxFoundationSDK(){}; + }; + +/** +The constant NX_FOUNDATION_SDK_VERSION is used when creating the NxFoundationSDK object, +which is an internally created object. This is to ensure that the application is using +the same header version as the library was built with. +*/ +#define NX_FOUNDATION_SDK_VERSION (( NX_SDK_VERSION_MAJOR <<24)+(NX_SDK_VERSION_MINOR <<16)+(NX_SDK_VERSION_BUGFIX <<8) + 0) + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHeightField.h b/libraries/external/physx/Win32/include/PX/NxHeightField.h new file mode 100755 index 0000000..1545896 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHeightField.h @@ -0,0 +1,287 @@ +#ifndef NX_COLLISION_NXHEIGHTFIELD +#define NX_COLLISION_NXHEIGHTFIELD +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxHeightFieldDesc; + +/** +\brief A height field object. + +Height fields work in a similar way as triangle meshes specified to act as height fields, with some important differences: + +Triangle meshes can be made of nonuniform geometry, while height fields are regular, rectangular grids. +This means that with NxHeightField, you sacrifice flexibility in return for improved performance and decreased memory consumption. + +Like Convexes and TriangleMeshes, HeightFields are referenced by shape instances of type NxHeightFieldShape. + +To avoid duplicating data when you have several instances of a particular +height field differently, you do not use this class to represent a +height field object directly. Instead, you create an instance of this height field +via the NxHeightFieldShape class. + +

Creation

+ +To create an instance of this class call NxPhysicsSDK::createHeightField(), +and NxPhysicsSDK::releaseHeightField() to delete it. This is only possible +once you have released all of its NxHeightFiedShape instances. + +Example: + +\include NxHeightField_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_COLLISION_AABBS +\li #NX_VISUALIZE_COLLISION_SHAPES +\li #NX_VISUALIZE_COLLISION_AXES +\li #NX_VISUALIZE_COLLISION_VNORMALS +\li #NX_VISUALIZE_COLLISION_FNORMALS +\li #NX_VISUALIZE_COLLISION_EDGES +\li #NX_VISUALIZE_COLLISION_SPHERES + +@see NxHeightFieldDesc NxHeightFieldShape NxPhysicsSDK.createHeightField() +*/ + +class NxHeightField + { + public: + + /** + \brief Saves the HeightField descriptor. + + This does not save out the cells member of the desc because the user must provide destination memory for that. + Instead, use the saveCells method obtain the sample data. + + \param[out] desc The descriptor used to retrieve the state of the object. + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool saveToDesc(NxHeightFieldDesc& desc) const = 0; + + /** + \brief Load the height field from a description. + + \param[in] desc The descriptor to load the object from. + + \return True if the height field was successfully loaded. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc + */ + virtual bool loadFromDesc(const NxHeightFieldDesc& desc) = 0; + + /** + \brief Writes out the sample data array. + + The user provides destBufferSize bytes storage at destBuffer. + The data is formatted and arranged as NxHeightFieldDesc.samples. + + \param[out] destBuffer The destination buffer for the sample data. + \param[in] destBufferSize The size of the destination buffer. + \return The number of bytes written. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.samples + */ + virtual NxU32 saveCells(void * destBuffer, NxU32 destBufferSize) const = 0; + + /** + \brief Retrieves the number of sample rows in the samples array. + + \return The number of sample rows in the samples array. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.nbRows + */ + virtual NxU32 getNbRows() const = 0; + + /** + \brief Retrieves the number of sample columns in the samples array. + + \return The number of sample columns in the samples array. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.nbColumns + */ + virtual NxU32 getNbColumns() const = 0; + + /** + \brief Retrieves the format of the sample data. + + \return The format of the sample data. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.format NxHeightFieldFormat + */ + virtual NxHeightFieldFormat getFormat() const = 0; + + /** + \brief Retrieves the offset in bytes between consecutive samples in the array. + + \return The offset in bytes between consecutive samples in the array. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.sampleStride + */ + virtual NxU32 getSampleStride() const = 0; + + /** + \brief Deprecated: Retrieves the extent of the height volume in the vertical direction. + + \return The extent of the height volume in the vertical direction. + + Platform: + \li PC SW: Deprecated + \li PPU : Deprecated + \li PS3 : Deprecated + \li XB360: Deprecated + + @see NxHeightFieldDesc.verticalExtent + */ + virtual NxReal getVerticalExtent() const = 0; + + /** + \brief Retrieves the thickness of the height volume in the vertical direction. + + \return The thickness of the height volume in the vertical direction. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.thickness + */ + virtual NxReal getThickness() const = 0; + + /** + \brief Retrieves the convex edge threshold. + + \return The convex edge threshold. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.convexEdgeThreshold + */ + virtual NxReal getConvexEdgeThreshold() const = 0; + + /** + \brief Retrieves the flags bits, combined from values of the enum ::NxHeightFieldFlags. + + \return The flags bits, combined from values of the enum ::NxHeightFieldFlags. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.flags NxHeightFieldFlags + */ + virtual NxU32 getFlags() const = 0; + + /** + \brief Retrieves the height at the given coordinates in grid space. + \return The height at the given coordinates or 0 if the coordinates are out of range. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal getHeight(NxReal x, NxReal z) const = 0; + + /** + \brief Returns a read only pointer directly to the samples array. + The data format is identical to that in NxHeightFieldDesc.samples. + + \return A const void pointer to the samples array. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.samples + */ + virtual const void* getCells() const = 0; + + /** + \brief Returns the reference count for shared meshes. + + \return the current reference count, not used in any shapes if the count is 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getReferenceCount() = 0; + + + protected: + virtual ~NxHeightField(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHeightFieldDesc.h b/libraries/external/physx/Win32/include/PX/NxHeightFieldDesc.h new file mode 100755 index 0000000..64f84bc --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHeightFieldDesc.h @@ -0,0 +1,257 @@ +#ifndef NX_COLLISION_NXHEIGHTFIELDDESC +#define NX_COLLISION_NXHEIGHTFIELDDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** +\brief Descriptor class for #NxHeightField. + +The heightfield data is *copied* when a NxHeightField object is created from this descriptor. After the call the +user may discard the height data. + +@see NxHeightField NxHeightFieldShape NxPhysicsSDK.createHeightField() +*/ +class NxHeightFieldDesc + { + public: + + /** + \brief Number of sample rows in the height field samples array. + + Range: >1
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 nbRows; + + /** + \brief Number of sample columns in the height field samples array. + + Range: >1
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 nbColumns; + + /** + \brief Format of the sample data. + + Currently the only supported format is NX_HF_S16_TM: + + Default: NX_HF_S16_TM + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFormat NxHeightFieldDesc.samples + */ + NxHeightFieldFormat format; + + /** + \brief The offset in bytes between consecutive samples in the samples array. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 sampleStride; + + /** + \brief The samples array. + + It is copied to the SDK's storage at creation time. + + There are nbRows * nbColumn samples in the array, + which define nbRows * nbColumn vertices and cells, + of which (nbRows - 1) * (nbColumns - 1) cells are actually used. + + The array index of sample(row, column) = row * nbColumns + column. + The byte offset of sample(row, column) = sampleStride * (row * nbColumns + column). + The sample data follows at the offset and spans the number of bytes defined by the format. + Then there are zero or more unused bytes depending on sampleStride before the next sample. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFormat + */ + void * samples; + + /** + \brief Deprecated: Sets how far 'below ground' the height volume extends. + + In this way even objects which are under the surface of the height field but above + this cutoff are treated as colliding with the height field. To create a height field with the up axis being + the Y axis, you need to set the verticalAxis to Y and the verticalExtent to a large negative number. + + The verticalExtent has to be outside of the range of the scaled height values along the verticalAxis. + + You may set this to a positive value, in which case the extent will be cast along the opposite side of the height field. + + You may use a smaller finite value for the extent if you want to put some space under the height field, such as a cave. + + Range: (-inf,inf)
+ Default: 0 + + Platform: + \li PC SW: Deprecated + \li PPU : Deprecated + \li PS3 : Deprecated + \li XB360: Deprecated + */ + NxReal verticalExtent; + + /** + \brief Sets how thick the heightfield surface is. + + In this way even objects which are under the surface of the height field but above + this cutoff are treated as colliding with the height field. + + The difference between thickness and (the deprecated) verticalExtent is that thickness + is measured relative to the surface at the given point, while vertical extent was an absolute limit. + + You may set this to a positive value, in which case the extent will be cast along the opposite side of the height field. + + You may use a smaller finite value for the extent if you want to put some space under the height field, such as a cave. + + Range: (-inf,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + NxReal thickness; + + /** + This threshold is used by the collision detection to determine if a height field edge is convex + and can generate contact points. + Usually the convexity of an edge is determined from the angle (or cosine of the angle) between + the normals of the faces sharing that edge. + The height field allows a more efficient approach by comparing height values of neighbouring vertices. + This parameter offsets the comparison. Smaller changes than 0.5 will not alter the set of convex edges. + The rule of thumb is that larger values will result in fewer edge contacts. + + This parameter is ignored in contact generation with sphere and capsule primitives. + + Range: (0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + NxReal convexEdgeThreshold; + + /** + \brief Flags bits, combined from values of the enum ::NxHeightFieldFlags + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldFlags + */ + NxU32 flags; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxHeightFieldDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxHeightFieldDesc::NxHeightFieldDesc() //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxHeightFieldDesc::setToDefault() + { + nbColumns = 0; + nbRows = 0; + format = NX_HF_S16_TM; + sampleStride = 0; + samples = 0; + verticalExtent = 0; + thickness = 0; + convexEdgeThreshold = 0.0f; + flags = 0; + } + +NX_INLINE bool NxHeightFieldDesc::isValid() const + { + if (nbColumns < 2) return false; + if (nbRows < 2) return false; + switch (format) + { + case NX_HF_S16_TM: + if (sampleStride < 4) return false; + break; + default: + return false; + } + if (convexEdgeThreshold < 0) return false; + if ((flags & NX_HF_NO_BOUNDARY_EDGES) != flags) return false; + if (verticalExtent != 0 && thickness != 0) return false; + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHeightFieldSample.h b/libraries/external/physx/Win32/include/PX/NxHeightFieldSample.h new file mode 100755 index 0000000..814225f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHeightFieldSample.h @@ -0,0 +1,82 @@ +#ifndef NX_PHYSICS_NXHEIGHTFIELDSAMPLE +#define NX_PHYSICS_NXHEIGHTFIELDSAMPLE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** +\brief Heightfield sample format. + +This format corresponds to the #NxHeightFieldFormat member NX_HF_S16_TM. + +An array of heightfield samples are used when creating a NxHeightField to specify +the elevation of the heightfield points. In addition the material and tessellation of the adjacent +triangles are specified. + +@see NxHeightField NxHeightFieldDesc NxHeightFieldDesc.samples +*/ +struct NxHeightFieldSample + { + /** + \brief The height of the heightfield sample + + This value is scaled by NxHeightFieldShapeDesc::heightScale. + + @see NxHeightFieldShapeDesc + */ + NxI16 height : 16; + + /** + \brief The low 7 bits of a triangle material index. + + These low bits are concatenated with the high bits from NxHeightFieldShapeDesc::materialIndexHighBits, + to produce an index into the scene's material array. This index determines the material of the lower + of the quad's two triangles (i.e. the quad whose upper-left corner is this sample, see the Guide for illustrations). + + @see NxHeightFieldShapeDesc materialIndex1 + */ + NxU8 materialIndex0 : 7; + + /** + \brief Tessellation flag. + + This flag specifies which way the quad is split whose upper left corner is this sample. + If the flag is set, the diagonal of the quad will run from this sample to the opposite vertex; if not, + it will run between the other two vertices (see the Guide for illustrations). + */ + NxU8 tessFlag : 1; + + /** + \brief The low 7 bits of a triangle material index. + + These low bits are concatenated with the high bits from NxHeightFieldShapeDesc::materialIndexHighBits, + to produce an index into the scene's material array. This index determines the material of the upper + of the quad's two triangles (i.e. the quad whose upper-left corner is this sample, see the Guide for illustrations). + + @see NxHeightFieldShapeDesc materialIndex0 + */ + NxU8 materialIndex1 : 7; + + /** + \brief Reserved for future use. Should be set to zero. + */ + NxU8 unused : 1; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHeightFieldShape.h b/libraries/external/physx/Win32/include/PX/NxHeightFieldShape.h new file mode 100755 index 0000000..df7e18d --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHeightFieldShape.h @@ -0,0 +1,323 @@ +#ifndef NX_COLLISION_NXHEIGHTFIELDSHAPE +#define NX_COLLISION_NXHEIGHTFIELDSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" +#include "PX/NxUserEntityReport.h" + +class NxTriangle; +class NxHeightFieldShapeDesc; +class NxHeightField; + + +/** +\brief This class is a shape instance of a height field object of type NxHeightField. + +Each shape is owned by an actor that it is attached to. + +

Creation

+ +An instance can be created by calling the createShape() method of the NxActor object +that should own it, with a NxHeightFieldShapeDesc object as the parameter, or by adding the +shape descriptor into the NxActorDesc class before creating the actor. + +The shape is deleted by calling NxActor::releaseShape() on the owning actor. + +Example: + +\include NxHeightFieldShape_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_COLLISION_AABBS +\li #NX_VISUALIZE_COLLISION_SHAPES +\li #NX_VISUALIZE_COLLISION_AXES +\li #NX_VISUALIZE_COLLISION_VNORMALS +\li #NX_VISUALIZE_COLLISION_FNORMALS +\li #NX_VISUALIZE_COLLISION_EDGES +\li #NX_VISUALIZE_COLLISION_SPHERES + +@see NxHeightFieldShapeDesc NxHeightField +*/ + +class NxHeightFieldShape: public NxShape + { + public: + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc + */ + virtual void saveToDesc(NxHeightFieldShapeDesc& desc) const = 0; + + /** + \brief Retrieves the height field data associated with this instance. + + \return The height field associated with this shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField + */ + virtual NxHeightField& getHeightField() const = 0; + + /** + \brief Retrieves the multiplier to transform sample height values to shape space y coordinates. + + \return The multiplier to transform sample height values to shape space y coordinates. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.heightScale + */ + virtual NxReal getHeightScale() const = 0; + + /** + \brief Retrieves the multiplier to transform height field rows to shape space x coordinates. + + \return The multiplier to transform height field rows to shape space x coordinates. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.rowScale + */ + virtual NxReal getRowScale() const = 0; + + /** + \brief Retrieves the multiplier to transform height field columns to shape space z coordinates. + + \return The multiplier to transform height field columns to shape space z coordinates. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.columnScale + */ + virtual NxReal getColumnScale() const = 0; + + /** + \brief Sets the multiplier to transform sample height values to shape space y coordinates. + + \param scale The multiplier to transform sample height values to shape space y coordinates. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.heightScale + */ + virtual void setHeightScale(NxReal scale) = 0; + + /** + \brief Sets the multiplier to transform height field rows to shape space x coordinates. + + \param scale The multiplier to transform height field rows to shape space x coordinates. Range: (-inf,0), (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.rowScale + */ + virtual void setRowScale(NxReal scale) = 0; + + /** + \brief Sets the multiplier to transform height field columns to shape space z coordinates. + + \param scale The multiplier to transform height field columns to shape space z coordinates. Range: (-inf,0), (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.columnScale + */ + virtual void setColumnScale(NxReal scale) = 0; + + /** + \brief Retrieves triangle data from a triangle ID. + + \param[out] worldTri World space triangle points. + \param[out] edgeTri World space edge normals for triangle (NULL to not compute). + \param[out] flags Flags which show if an edge is convex. See #NxTriangleFlags + \param[in] triangleIndex The index of the triangle to retrieve. + \param[in] worldSpaceTranslation True if the triangle should be translated to world space. + \param[in] worldSpaceRotation True if the triangle should be rotated to world space. + + \return Zero if the triangle does not exist or has the hole material. Nonzero otherwise. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangle NxTriangleFlags NxTriangleID + */ + virtual NxU32 getTriangle(NxTriangle& worldTri, NxTriangle* edgeTri, NxU32* flags, NxTriangleID triangleIndex, bool worldSpaceTranslation=true, bool worldSpaceRotation=true) const = 0; + + /** + \brief Finds triangles touching the input bounds. + + \warning This method returns a pointer to an internal structure using the indices member. Hence the + user should use or copy the indices before calling any other API function. + + \warning This method is deprecated and overlapAABBTriangles(const NxBounds3 bounds, NxU32 flags, NxUserEntityReport* callback) should + be used in new code as it is more efficient and less error prone. + + The triangle indices returned by overlapAABBTriangles() can be used with #getTriangle() to retrieve the triangle properties. + + \param[in] bounds Bounds to test against. In object or world space depending on #NxQueryFlags. Range: See #NxBounds3 + \param[in] flags Controls if the bounds are in object or world space and if we return first contact only. See #NxQueryFlags. + \param[out] nb Retrieves the number of triangle indices touching the AABB. + \param[out] indices Returns an array of touching triangle indices. + \return True if there is an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxQueryFlags NxScene.overlapAABBShapes() getTriangle() + */ + NX_INLINE bool overlapAABBTriangles(const NxBounds3& bounds, NxU32 flags, NxU32& nb, const NxU32*& indices) const + { + return overlapAABBTrianglesDeprecated(bounds, flags, nb, indices); + } + + virtual bool overlapAABBTrianglesDeprecated(const NxBounds3& bounds, NxU32 flags, NxU32& nb, const NxU32*& indices) const = 0; + + /** + \brief Finds triangles touching the input bounds. + + The triangle indices returned by overlapAABBTriangles() can be used with #getTriangle() to retrieve the triangle properties. + + \param[in] bounds Bounds to test against. In object or world space depending on #NxQueryFlags. Range: See #NxBounds3 + \param[in] flags Controls if the bounds are in object or world space and if we return first contact only. See #NxQueryFlags. + \param[in] callback Used to return triangles which intersect the AABB + \return True if there is an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxQueryFlags NxScene.overlapAABBShapes() getTriangle() NxUserEntityReport + */ + virtual bool overlapAABBTriangles(const NxBounds3& bounds, NxU32 flags, NxUserEntityReport* callback) const = 0; + + /** + \brief Checks if the point in shape space projects onto the height field surface. + \return True if the point projects onto the height field surface, false otherwise. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool isShapePointOnHeightField(NxReal x, NxReal z) const = 0; + + /** + \brief Returns the interpolated height at the given point in shape space. + \return The interpolated height at the given point, or 0 if the point is out of range. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal getHeightAtShapePoint(NxReal x, NxReal z) const = 0; + + /** + \brief Returns the material index at the given point in shape space. + The return value is the 7 low order bits as set in the samples array. + The value may be compared directly with the hole material to determine + if the heightfield has a hole at the given point. + + \return The low bits material index, or 0xFFFF if the point is out of range. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldShapeDesc.holeMaterial + */ + virtual NxMaterialIndex getMaterialAtShapePoint(NxReal x, NxReal z) const = 0; + + /** + \brief Returns the normal of the heightfield surface at the given point in shape space. + \return The normal at the given point, or <0,0,0> if the point is out of range. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxVec3 getNormalAtShapePoint(NxReal x, NxReal z) const = 0; + + /** + \brief Returns the smoothed normal of the heightfield surface at the given point in shape space. + \return The smoothed normal at the given point, or <0,0,0> if the point is out of range. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxVec3 getSmoothNormalAtShapePoint(NxReal x, NxReal z) const = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHeightFieldShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxHeightFieldShapeDesc.h new file mode 100755 index 0000000..6198b50 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHeightFieldShapeDesc.h @@ -0,0 +1,207 @@ +#ifndef NX_COLLISION_NXHEIGHTFIELDSHAPEDESC +#define NX_COLLISION_NXHEIGHTFIELDSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShapeDesc.h" +#include "PX/NxHeightField.h" +#include "PX/NxHeightFieldShape.h" + +/** +\brief Descriptor class for #NxHeightFieldShape. + +@see NxHeightFieldShape +*/ +class NxHeightFieldShapeDesc : public NxShapeDesc + { + public: + + /** + \brief References the height field that we want to instance. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField + */ + NxHeightField * heightField; + + /** + \brief Multiplier to transform sample height values to shape space y coordinates. + + Range: (0,inf)
+ Default: 1.0f + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField NxHeightFieldDesc NxHeightFieldFormat + */ + NxReal heightScale; + + /** + \brief Multiplier to transform height field rows to shape space x coordinates. + + Range: (-inf,0), (0,inf)
+ Default: 1.0f + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField NxHeightFieldDesc + */ + NxReal rowScale; + + /** + \brief Multiplier to transform height field columns to shape space z coordinates. + + Range: (-inf,0), (0,inf)
+ Default: 1.0f + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField NxHeightFieldDesc + */ + NxReal columnScale; + + /** + \brief The high 9 bits of this number are used to complete the material indices in the samples. + + The remaining low 7 bits must be zero. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField NxHeightFieldDesc + */ + NxMaterialIndex materialIndexHighBits; + + /** + \brief The the material index that designates holes in the height field. + + This number is compared directly to sample materials. + Consequently the high 9 bits must be zero. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightField NxHeightFieldDesc + */ + NxMaterialIndex holeMaterial; + + /** + \brief Combination of ::NxMeshShapeFlag. + So far the only value permitted here is 0 or NX_MESH_SMOOTH_SPHERE_COLLISIONS. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshShapeFlag + */ + NxU32 meshFlags; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxHeightFieldShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + + NX_INLINE virtual void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid + */ + + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxHeightFieldShapeDesc::NxHeightFieldShapeDesc() : NxShapeDesc(NX_SHAPE_HEIGHTFIELD) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxHeightFieldShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + heightField = 0; + heightScale = 1.0f; + rowScale = 1.0f; + columnScale = 1.0f; + materialIndexHighBits = 0; + holeMaterial = 0; + meshFlags = 0; + } + +NX_INLINE bool NxHeightFieldShapeDesc::isValid() const + { + if (!heightField) return false; + + if (heightScale <= NX_EPS_REAL) return false; + if (NxMath::abs(rowScale) <= NX_EPS_REAL) return false; + if (NxMath::abs(columnScale) <= NX_EPS_REAL) return false; + + switch (heightField->getFormat()) + { + case NX_HF_S16_TM: + if (0x7f & materialIndexHighBits) return false; + if ((0x7f & holeMaterial) != holeMaterial) return false; + break; + default: + return false; + } + + + if (meshFlags & (~NX_MESH_SMOOTH_SPHERE_COLLISIONS)) return false; + + return NxShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHwParser.h b/libraries/external/physx/Win32/include/PX/NxHwParser.h new file mode 100755 index 0000000..5c6eb07 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHwParser.h @@ -0,0 +1,87 @@ +#ifndef NX_PHYSICS_NXHWPARSER +#define NX_PHYSICS_NXHWPARSER + +#include "PX/Nxp.h" +#if NX_ENABLE_HW_PARSER + +namespace NxForceFieldInternals +{ + +class NxBoolExp; +class NxFloatExp; +class NxVecExp; +class NxCmd; + +#define DllExport __declspec( dllexport ) +#else +#define DllExport +#endif + + +class DllExport NxHwParser +{ +public: + static void parseKernel(NxForceFieldKernel& kernel); + static void acquire(); // can also do locking + static void release(); + static void dump(); + + enum Op + { + INLINECONSTANTFLOAT, INLINECONSTANTBOOL, BOOLVAR, FLOATVAR, VECTORVAR, BOOLCONST, FLOATCONST, VECTORCONST, // leaf + RECIP, SQRT, RECIPSQRT, NEGATE, MAGNITUDE, VECTORX, VECTORY, VECTORZ, // unary + AND, OR, XOR, PLUS, MINUS, TIMES, LT, GT, LE, GE, EQ, NEQ, DOT, CROSS, // binary + SELECT // ternary + }; + + enum CmdOp + { + ASSIGN, PLUSASSIGN, MINUSASSIGN, TIMESASSIGN, FAILIF, FINISHIF, ASSIGNX, ASSIGNY, ASSIGNZ + }; + + static NxBoolExp * b(bool b); // NX_INLINE constant + static NxBoolExp * b(NxHwParser::Op op, int idOrOffset); // vars, constants + static NxBoolExp * b(NxHwParser::Op op, NxBoolExp *b1, NxBoolExp *b2 = 0); // boolean ops + static NxBoolExp * b(NxHwParser::Op op, NxFloatExp *b1, NxFloatExp *b2 = 0); // comparisons + + static NxFloatExp * f(NxReal f); // NX_INLINE constant + static NxFloatExp * f(NxHwParser::Op op, int idOrOffset); // vars, constants + static NxFloatExp * f(NxHwParser::Op, NxFloatExp *f1, NxFloatExp *f2 = 0); // float ops + static NxFloatExp * f(NxHwParser::Op, NxVecExp *f1, NxVecExp *f2 = 0); // dot product, magnitude + static NxFloatExp * f(NxHwParser::Op, NxBoolExp *, NxFloatExp *, NxFloatExp *); // select + + static NxVecExp * v(NxHwParser::Op, int offsetOrId); // vars, constants + static NxVecExp * v(NxHwParser::Op, NxVecExp *f1, NxVecExp *f2 = 0); // vec ops + static NxVecExp * v(NxHwParser::Op, NxVecExp *f1, NxFloatExp *f2); // scaling + static NxVecExp * v(NxHwParser::Op, NxBoolExp *, NxVecExp *, NxVecExp *); // select + + static void cmd(NxHwParser::CmdOp, NxBoolExp *); // failif, finishif + static void cmd(NxHwParser::CmdOp, int, NxBoolExp *); // bool assign + static void cmd(NxHwParser::CmdOp, int, NxFloatExp *); // float assign + static void cmd(NxHwParser::CmdOp, int, NxVecExp *); // vec assign + + static int getBoolVarIndex(); + static int getFloatVarIndex(); + static int getVectorVarIndex(); + static int getBoolConstOffset(); + static int getFloatConstOffset(); + static int getVecConstOffset(); +private: + static int sBoolVarIndex; + static int sFloatVarIndex; + static int sVectorVarIndex; + static int sBoolConstOffset; + static int sFloatConstOffset; + static int sVectorConstOffset; + static int sCmdCount; + static NxCmd *sCmd[1000]; +}; +} // namespace +#endif +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxHwTarget.h b/libraries/external/physx/Win32/include/PX/NxHwTarget.h new file mode 100755 index 0000000..afeddce --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxHwTarget.h @@ -0,0 +1,256 @@ +#ifndef NX_PHYSICS_NXHWTARGET +#define NX_PHYSICS_NXHWTARGET + +#include "PX/Nxp.h" +#if NX_ENABLE_HW_PARSER +#include "PX/NxForceFieldKernel.h" +#include "PX/NxExpression.h" +#include "PX/NxHwParser.h" + +namespace NxForceFieldInternals +{ + +class NxHwFloat; +class NxHwVec; + +class NxHwBool +{ + friend class NxHwBoolVar; + friend class NxHwVec; + friend class NxHwFloat; + friend NxHwBool operator<(const NxHwFloat &f1, const NxHwFloat &f2); + friend NxHwBool operator>(const NxHwFloat &f1, const NxHwFloat &f2); + friend NxHwBool operator==(const NxHwFloat &f1, const NxHwFloat &f2); + friend NxHwBool operator<=(const NxHwFloat &f1, const NxHwFloat &f2); + friend NxHwBool operator>=(const NxHwFloat &f1, const NxHwFloat &f2); + friend NxHwBool operator!=(const NxHwFloat &f1, const NxHwFloat &f2); + friend NxHwBool operator &(const NxHwBool &b1, const NxHwBool &b2); + friend NxHwBool operator |(const NxHwBool &b1, const NxHwBool &b2); + friend NxHwBool operator ^(const NxHwBool &b1, const NxHwBool &b2); + +private: + NxHwBool(NxBoolExp *exp): mExp(exp) {} +protected: + NxHwBool(): mExp(0) {} +public: + NxBoolExp *mExp; // FIXME + NxHwBool(bool b): mExp(NxHwParser::b(b)) { } + NxHwBool(int b): mExp(NxHwParser::b(!!b)) { } // For "Boolean b = true ^ true;" + NX_INLINE NxHwFloat select(NxHwFloat f0, NxHwFloat f1); + NX_INLINE NxHwVec select(NxHwVec& v0, NxHwVec& v1); +}; + +NX_INLINE NxHwBool operator &(const NxHwBool &b1, const NxHwBool &b2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::AND,b1.mExp,b2.mExp)); +} +NX_INLINE NxHwBool operator |(const NxHwBool &b1, const NxHwBool &b2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::OR,b1.mExp,b2.mExp)); +} +NX_INLINE NxHwBool operator ^(const NxHwBool &b1, const NxHwBool &b2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::XOR,b1.mExp,b2.mExp)); +} + + +class NxHwBoolVar: public NxHwBool +{ + int mId; +public: + NxHwBoolVar(const NxHwBool& b): mId(NxHwParser::getBoolVarIndex()) { NxHwParser::cmd(NxHwParser::ASSIGN, mId, b.mExp); + mExp = NxHwParser::b(NxHwParser::BOOLVAR, mId); + } + void operator=(const NxHwBool& b) { NxHwParser::cmd(NxHwParser::ASSIGN ,mId, b.mExp); } +}; + +class NxHwBoolConst: public NxHwBool +{ + int mOffset; +public: + NxHwBoolConst(): mOffset(NxHwParser::getBoolConstOffset()) { mExp = NxHwParser::b(NxHwParser::BOOLCONST, mOffset); } +}; + +// ------------------------------------------------- + +class NxHwFloat +{ +friend class NxHwVec; +friend class NxHw; +friend class NxHwFloatVar; +friend class NxHwBool; +friend NxHwFloat operator +(const NxHwFloat &f1, const NxHwFloat &f2); +friend NxHwFloat operator -(const NxHwFloat &f1, const NxHwFloat &f2); +friend NxHwFloat operator *(const NxHwFloat &f1, const NxHwFloat &f2); + +private: + NxHwFloat(NxFloatExp *exp): mExp(exp) {} + + static const NxHwFloat EPSILON; + +protected: + NxHwFloat(): mExp(0) {} + +public: + NxFloatExp *mExp; // FIXME + NxHwFloat(NxReal f): mExp(NxHwParser::f(f)) {} + + NxHwFloat operator -() const { return NxHwFloat(NxHwParser::f(NxHwParser::NEGATE, mExp)); } + NxHwFloat recip() const { return NxHwFloat(NxHwParser::f(NxHwParser::RECIP, mExp)); } + NxHwFloat recipSqrt() const { return NxHwFloat(NxHwParser::f(NxHwParser::RECIPSQRT, mExp)); } + NxHwFloat sqrt() const { return NxHwFloat(NxHwParser::f(NxHwParser::SQRT, mExp)); } +}; + +NX_INLINE NxHwFloat operator +(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwFloat(NxHwParser::f(NxHwParser::PLUS, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwFloat operator -(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwFloat(NxHwParser::f(NxHwParser::MINUS, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwFloat operator *(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwFloat(NxHwParser::f(NxHwParser::TIMES, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwBool operator<(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::LT, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwBool operator>(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::GT, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwBool operator==(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::EQ, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwBool operator<=(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::LE, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwBool operator>=(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::GE, f1.mExp, f2.mExp)); +} +NX_INLINE NxHwBool operator!=(const NxHwFloat &f1, const NxHwFloat &f2) +{ + return NxHwBool(NxHwParser::b(NxHwParser::NEQ, f1.mExp, f2.mExp)); +} + +class NxHwFloatVar: public NxHwFloat +{ + int mId; +public: + + NxHwFloatVar(NxReal f) { mExp = NxHwParser::f(f); } + NxHwFloatVar(const NxHwFloat& f): mId(NxHwParser::getFloatVarIndex()) { NxHwParser::cmd(NxHwParser::ASSIGN, mId, f.mExp); + mExp = NxHwParser::f(NxHwParser::FLOATVAR, mId); + } + void operator =(const NxHwFloat& f) { printf("=\n");NxHwParser::cmd(NxHwParser::ASSIGN, mId, f.mExp); } + void operator +=(const NxHwFloat& f) { NxHwParser::cmd(NxHwParser::PLUSASSIGN, mId, f.mExp); } + void operator -=(const NxHwFloat& f) { NxHwParser::cmd(NxHwParser::MINUSASSIGN, mId, f.mExp); } + void operator *=(const NxHwFloat& f) { NxHwParser::cmd(NxHwParser::TIMESASSIGN, mId, f.mExp); } +}; + +class NxHwFloatConst: public NxHwFloat +{ + int mOffset; +public: + NxHwFloatConst(): mOffset(NxHwParser::getFloatConstOffset()) { mExp = NxHwParser::f(NxHwParser::FLOATCONST, mOffset); } +}; + + +// ------------------------------------------------- + +class NxHwVec +{ + friend class NxHw; + friend class NxHwVecVar; + friend class NxHwVecConst; + friend class NxHwBool; + + NxHwVec(NxVecExp *exp): mExp(exp) {} + +protected: + NxHwVec(): mExp(0) {} + +public: + + NxVecExp *mExp; // FIXME + + NxHwFloat getX() { return NxHwFloat(NxHwParser::f(NxHwParser::VECTORX, mExp)); } + NxHwFloat getY() { return NxHwFloat(NxHwParser::f(NxHwParser::VECTORY, mExp)); } + NxHwFloat getZ() { return NxHwFloat(NxHwParser::f(NxHwParser::VECTORZ, mExp)); } + NxHwVec operator +(const NxHwVec& v) const { return NxHwVec(NxHwParser::v(NxHwParser::PLUS, mExp, v.mExp)); } + NxHwVec operator -(const NxHwVec& v) const { return NxHwVec(NxHwParser::v(NxHwParser::MINUS, mExp, v.mExp)); } + NxHwVec operator -() const { return NxHwVec(NxHwParser::v(NxHwParser::NEGATE, mExp)); } + NxHwVec operator *(const NxHwFloat& f) const { return NxHwVec(NxHwParser::v(NxHwParser::TIMES, mExp, f.mExp)); } + NxHwFloat dot(const NxHwVec& v) const { return NxHwFloat(NxHwParser::f(NxHwParser::DOT, mExp, v.mExp)); } + NxHwVec cross(const NxHwVec& v) const { return NxHwVec(NxHwParser::v(NxHwParser::CROSS, mExp, v.mExp)); } + NxHwFloat magnitude() const { return NxHwFloat(NxHwParser::f(NxHwParser::MAGNITUDE, mExp)); } + +}; + +class NxHwVecVar: public NxHwVec +{ + int mId; +public: + NxHwVecVar(): mId(NxHwParser::getVectorVarIndex()) { mExp = NxHwParser::v(NxHwParser::VECTORVAR, mId); } + NxHwVecVar(const NxHwVec& v): mId(NxHwParser::getVectorVarIndex()) { NxHwParser::cmd(NxHwParser::ASSIGN, mId, v.mExp); + mExp = NxHwParser::v(NxHwParser::VECTORVAR, mId); + } + void setX(const NxHwFloat &f) { NxHwParser::cmd(NxHwParser::ASSIGNX, mId, f.mExp); } + void setY(const NxHwFloat &f) { NxHwParser::cmd(NxHwParser::ASSIGNY, mId, f.mExp); } + void setZ(const NxHwFloat &f) { NxHwParser::cmd(NxHwParser::ASSIGNZ, mId, f.mExp); } + void operator =(const NxHwVec& v) { NxHwParser::cmd(NxHwParser::ASSIGN, mId, v.mExp); } + void operator +=(const NxHwVec& v) { NxHwParser::cmd(NxHwParser::PLUSASSIGN, mId, v.mExp); } + void operator -=(const NxHwVec& v) { NxHwParser::cmd(NxHwParser::MINUSASSIGN, mId, v.mExp); } +}; + +class NxHwVecConst: public NxHwVec +{ + int mOffset; +public: + NxHwVecConst(): mOffset(NxHwParser::getVecConstOffset()) { mExp = NxHwParser::v(NxHwParser::VECTORCONST, mOffset); } +}; + +class NxHw +{ +public: + + typedef NxHwBoolConst BConstType; + typedef NxHwBoolVar BVarType; + + typedef NxHwFloatConst FConstType; + typedef NxHwFloatVar FVarType; + + typedef NxHwVecConst VConstType; + typedef NxHwVecVar VVarType; + + static bool testFailure(NxHwBool cond) { NxHwParser::cmd(NxHwParser::FAILIF,cond.mExp); return false; } + static bool testFinish(NxHwBool cond) { NxHwParser::cmd(NxHwParser::FINISHIF,cond.mExp); return false; } +}; + +//void parseKernel(NxForceFieldKernel& kernel); + +NX_INLINE NxHwFloat NxHwBool::select(NxHwFloat f0, NxHwFloat f1) + { + NxFloatExp *f = NxHwParser::f(NxHwParser::SELECT, mExp,f0.mExp,f1.mExp); + return NxHwFloat(f); + } + +NX_INLINE NxHwVec NxHwBool::select(NxHwVec& v0, NxHwVec& v1) + { + return NxHwVec(NxHwParser::v(NxHwParser::SELECT, mExp,v0.mExp,v1.mExp)); + } + +} // namespace +#endif +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxI16Vec3.h b/libraries/external/physx/Win32/include/PX/NxI16Vec3.h new file mode 100755 index 0000000..8654182 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxI16Vec3.h @@ -0,0 +1,157 @@ +#ifndef NX_FOUNDATION_NXI16VEC3 +#define NX_FOUNDATION_NXI16VEC3 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ +//Exclude file from docs +/** \cond */ + +#include "PX/Nx.h" +#include "PX/NxVec3.h" + +class NxI16Vec3 +{ + +public: + + NxI16 x; + NxI16 y; + NxI16 z; + + NX_INLINE NxI16Vec3() + { + } + + NX_INLINE NxI16Vec3(const NxI16Vec3& v) + { + x = v.x; + y = v.y; + z = v.z; + } + + NX_INLINE NxI16Vec3(NxI16 _x, NxI16 _y, NxI16 _z) + { + x = _x; + y = _y; + z = _z; + } + + NX_INLINE bool operator==(const NxI16Vec3& v) const + { + return ((x == v.x) && (y == v.y) && (z == v.z)); + } + + NX_INLINE bool operator!=(const NxI16Vec3& v) const + { + return ((x != v.x) || (y != v.y) || (z != v.z)); + } + + NX_INLINE const NxI16Vec3 operator+(const NxI16Vec3& v) + { + NxI16Vec3 res; + res.x = x + v.x; + res.y = y + v.y; + res.z = z + v.z; + return res; + } + + NX_INLINE const NxI16Vec3& operator+=(const NxI16Vec3& v) + { + x += v.x; + y += v.y; + z += v.z; + return *this; + } + + NX_INLINE const NxI16Vec3& operator=(const NxI16Vec3& v) + { + x = v.x; + y = v.y; + z = v.z; + return *this; + } + + NX_INLINE const NxI16Vec3 operator << ( const NxU32 shift) const + { + NxI16Vec3 res; + res.x = x << shift; + res.y = y << shift; + res.z = z << shift; + return res; + } + + NX_INLINE const NxI16Vec3 operator >> ( const NxU32 shift) const + { + NxI16Vec3 res; + res.x = x >> shift; + res.y = y >> shift; + res.z = z >> shift; + return res; + } + + NX_INLINE const NxI16Vec3& operator <<= ( const NxU32 shift) + { + x <<= shift; + y <<= shift; + z <<= shift; + return *this; + } + + NX_INLINE const NxI16Vec3& operator >>= ( const NxU32 shift) + { + x >>= shift; + y >>= shift; + z >>= shift; + return *this; + } + + NX_INLINE void set( const NxVec3& realVec, NxReal scale) + { + x = static_cast(NxMath::floor(realVec.x * scale)); + y = static_cast(NxMath::floor(realVec.y * scale)); + z = static_cast(NxMath::floor(realVec.z * scale)); + } + + NX_INLINE void set( const NxVec3& realVec) + { + x = static_cast(NxMath::floor(realVec.x)); + y = static_cast(NxMath::floor(realVec.y)); + z = static_cast(NxMath::floor(realVec.z)); + } + + NX_INLINE void set( NxI16 _x, NxI16 _y, NxI16 _z) + { + x = _x; + y = _y; + z = _z; + } + + NX_INLINE void zero() + { + x = 0; + y = 0; + z = 0; + } + + NX_INLINE bool isZero() + { + return x == 0 && y == 0 && z == 0; + } +}; + +/** \endcond */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/NxInertiaTensor.h b/libraries/external/physx/Win32/include/PX/NxInertiaTensor.h new file mode 100755 index 0000000..7c478b9 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxInertiaTensor.h @@ -0,0 +1,291 @@ +#ifndef NX_PHYSICS_NXINERTIATENSOR +#define NX_PHYSICS_NXINERTIATENSOR +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/PhysXLoader.h" + + /** + \brief Computes mass of a homogeneous sphere according to sphere density. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] radius Radius of the sphere. Range: (0,inf) + \param[in] density Density of the sphere. Range: (0,inf) + + \return The mass of the sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeSphereMass (NxReal radius, NxReal density) + { + return NxGetUtilLib()->NxComputeSphereMass(radius,density); + } + + /** + \brief Computes density of a homogeneous sphere according to sphere mass. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] radius Radius of the sphere. Range: (0,inf) + \param[in] mass Mass of the sphere. Range: (0,inf) + + \return The density of the sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeSphereDensity (NxReal radius, NxReal mass) + { + return NxGetUtilLib()->NxComputeSphereDensity(radius,mass); + } + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous box according to box density. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] extents The extents/radii, that is the full side length along each axis, of the box. Range: direction vector + \param[in] density The density of the box. Range: (0,inf) + + \return The mass of the box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeBoxMass (const NxVec3& extents, NxReal density) + { + return NxGetUtilLib()->NxComputeBoxMass(extents,density); + } + + /** + \brief Computes density of a homogeneous box according to box mass. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] extents The extents/radii, that is the full side length along each axis, of the box. Range: direction vector + \param[in] mass The mass of the box. Range: (0,inf) + + \return The density of the box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeBoxDensity (const NxVec3& extents, NxReal mass) + { + return NxGetUtilLib()->NxComputeBoxDensity(extents,mass); + } + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous ellipsoid according to ellipsoid density. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] extents The extents/radii of the ellipsoid. Range: direction vector + \param[in] density The density of the ellipsoid. Range: (0,inf) + + \return The mass of the ellipsoid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeEllipsoidMass (const NxVec3& extents, NxReal density) + { + return NxGetUtilLib()->NxComputeEllipsoidMass(extents,density); + } + + /** + \brief Computes density of a homogeneous ellipsoid according to ellipsoid mass. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] extents The extents/radii of the ellipsoid. Range: direction vector + \param[in] mass The mass of the ellipsoid. Range: (0,inf) + + \return The density of the ellipsoid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeEllipsoidDensity (const NxVec3& extents, NxReal mass) + { + return NxGetUtilLib()->NxComputeEllipsoidDensity(extents,mass); + } + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous cylinder according to cylinder density. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] radius The radius of the cylinder. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] density The density. Range: (0,inf) + + \return The mass. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeCylinderMass (NxReal radius, NxReal length, NxReal density) + { + return NxGetUtilLib()->NxComputeCylinderMass(radius,length,density); + } + + /** + \brief Computes density of a homogeneous cylinder according to cylinder mass. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] radius The radius of the cylinder. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] mass The mass. Range: (0,inf) + + \return The density. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeCylinderDensity (NxReal radius, NxReal length, NxReal mass) + { + return NxGetUtilLib()->NxComputeCylinderDensity(radius,length,mass); + } + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous cone according to cone density. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] radius The radius of the cone. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] density The density. Range: (0,inf) + + \return The mass. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeConeMass (NxReal radius, NxReal length, NxReal density) + { + return NxGetUtilLib()->NxComputeConeMass(radius,length,density); + } + + /** + \brief Computes density of a homogeneous cone according to cone mass. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] radius The radius of the cone. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] mass The mass. Range: (0,inf) + + \return The density. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxReal NxComputeConeDensity (NxReal radius, NxReal length, NxReal mass) + { + return NxGetUtilLib()->NxComputeConeDensity(radius,length,mass); + } + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes diagonalized inertia tensor for a box. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[out] diagInertia The diagonalized inertia tensor. + \param[in] mass The mass of the box. Range: (0,inf) + \param[in] xlength The width of the box. Range: (-inf,inf) + \param[in] ylength The height. Range: (-inf,inf) + \param[in] zlength The depth. Range: (-inf,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE void NxComputeBoxInertiaTensor (NxVec3& diagInertia, NxReal mass, NxReal xlength, NxReal ylength, NxReal zlength) + { + NxGetUtilLib()->NxComputeBoxInertiaTensor(diagInertia,mass,xlength,ylength,zlength); + } + + /** + \brief Computes diagonalized inertia tensor for a sphere. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[out] diagInertia The diagonalized inertia tensor. + \param[in] mass The mass. Range: (0,inf) + \param[in] radius The radius. Range: (-inf,inf) + \param[in] hollow True to treat the sphere as a hollow shell. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE void NxComputeSphereInertiaTensor(NxVec3& diagInertia, NxReal mass, NxReal radius, bool hollow) + { + NxGetUtilLib()->NxComputeSphereInertiaTensor(diagInertia,mass,radius,hollow); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxInterface.h b/libraries/external/physx/Win32/include/PX/NxInterface.h new file mode 100755 index 0000000..7404f89 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxInterface.h @@ -0,0 +1,34 @@ +#ifndef NX_INTERFACE_H +#define NX_INTERFACE_H +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +enum NxInterfaceType +{ + NX_INTERFACE_STATS, + NX_INTERFACE_LAST +}; + + +class NxInterface +{ +public: + virtual int getVersionNumber(void) const = 0; + virtual NxInterfaceType getInterfaceType(void) const = 0; + +protected: + virtual ~NxInterface(){}; +}; + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxInterfaceStats.h b/libraries/external/physx/Win32/include/PX/NxInterfaceStats.h new file mode 100755 index 0000000..87b66a6 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxInterfaceStats.h @@ -0,0 +1,30 @@ +#ifndef NX_INTERFACE_STATS_H +#define NX_INTERFACE_STATS_H +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/NxInterface.h" + +#define NX_INTERFACE_STATS_VERSION 100 + +class NxInterfaceStats : public NxInterface +{ +public: + virtual int getVersionNumber(void) const { return NX_INTERFACE_STATS_VERSION; }; + virtual NxInterfaceType getInterfaceType(void) const { return NX_INTERFACE_STATS; }; + virtual bool getHeapSize(int &used,int &unused) = 0; + +}; + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionBoxBox.h b/libraries/external/physx/Win32/include/PX/NxIntersectionBoxBox.h new file mode 100755 index 0000000..952a551 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionBoxBox.h @@ -0,0 +1,157 @@ +#ifndef NX_INTERSECTION_BOX_BOX +#define NX_INTERSECTION_BOX_BOX +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxBox.h" +#include "PX/PhysXLoader.h" + + /** + \brief Boolean intersection test between two OBBs. + + Uses the separating axis theorem. Disabling 'full_test' only performs 6 axis tests out of 15. + + \param[in] extents0 Extents/radii of first box before transformation. Range: direction vector + \param[in] center0 Center of first box. Range: position vector + \param[in] rotation0 Rotation to apply to first box (before translation). Range: rotation matrix + \param[in] extents1 Extents/radii of second box before transformation Range: direction vector + \param[in] center1 Center of second box. Range: position vector + \param[in] rotation1 Rotation to apply to second box(before translation). Range: rotation matrix + \param[in] fullTest If false test only the first 6 axis. + + \return true on intersection + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxBoxBoxIntersect( const NxVec3& extents0, const NxVec3& center0, const NxMat33& rotation0, + const NxVec3& extents1, const NxVec3& center1, const NxMat33& rotation1, + bool fullTest) + { + return NxGetUtilLib()->NxBoxBoxIntersect(extents0,center0,rotation0,extents1,center1,rotation1,fullTest); + } + + /** + \brief Boolean intersection test between two OBBs. + + Uses the separating axis theorem. Disabling 'full_test' only performs 6 axis tests out of 15. + + \param[in] obb0 First Oriented Bounding Box. Range: See #NxBox + \param[in] obb1 Second Oriented Bounding Box. Range: See #NxBox + \param[in] fullTest If false test only the first 6 axis. + + \return true on intersection + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox + */ + NX_INLINE bool NxBoxBoxIntersect(const NxBox& obb0, const NxBox& obb1, bool fullTest=true) + { + return NxBoxBoxIntersect( + obb0.extents, obb0.center, obb0.rot, + obb1.extents, obb1.center, obb1.rot, + fullTest); + } + + /* + \brief Boolean intersection test between a triangle and an AABB. + + \param[in] vertex0 First vertex of triangle. Range: position vector + \param[in] vertex1 Second Vertex of triangle. Range: position vector + \param[in] vertex2 Third Vertex of triangle. Range: position vector + \param[in] center Center of Axis Aligned bounding box. Range: position vector + \param[in] extents Extents/radii of AABB. Range: direction vector + + \return true on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxTriBoxIntersect(const NxVec3 & vertex0, const NxVec3 & vertex1, const NxVec3 & vertex2, const NxVec3 & center, const NxVec3& extents) + { + return NxGetUtilLib()->NxTriBoxIntersect(vertex0,vertex1,vertex2,center,extents); + + } + + + /** + \brief Computes the separating axis between two OBBs. + + \param[in] extents0 Extents/radii of first box before transformation. Range: direction vector + \param[in] center0 Center of box first box. Range: position vector + \param[in] rotation0 Rotation to apply to first box (before translation). Range: rotation matrix + \param[in] extents1 Extents/radii of second box before transformation. Range: direction vector + \param[in] center1 Center of second box. Range: position vector + \param[in] rotation1 Rotation to apply to second box (before translation). Range: rotation matrix + \param[in] fullTest If false test only the first 6 axis. + + \return The separating axis or NX_SEP_AXIS_OVERLAP for an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSepAxis + */ + NX_INLINE NxSepAxis NxSeparatingAxis( const NxVec3& extents0, const NxVec3& center0, const NxMat33& rotation0, + const NxVec3& extents1, const NxVec3& center1, const NxMat33& rotation1, + bool fullTest=true) + { + return NxGetUtilLib()->NxSeparatingAxis(extents0,center0,rotation0,extents1,center1,rotation1,fullTest); + } + + /** + \brief Computes the separating axis between two OBBs. + + \param[in] obb0 First Oriented Bounding box. Range: See #NxBox + \param[in] obb1 Second Oriented Bounding box. Range: See #NxBox + \param[in] fullTest If false test only the first 6 axis. + + \return The separating axis. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSepAxis + */ + NX_INLINE NxSepAxis NxSeparatingAxis(const NxBox& obb0, const NxBox& obb1, bool fullTest=true) + { + return NxSeparatingAxis( + obb0.extents, obb0.center, obb0.rot, + obb1.extents, obb1.center, obb1.rot, + fullTest); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionPointTriangle.h b/libraries/external/physx/Win32/include/PX/NxIntersectionPointTriangle.h new file mode 100755 index 0000000..601e430 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionPointTriangle.h @@ -0,0 +1,119 @@ +#ifndef NX_INTERSECTION_POINT_TRIANGLE +#define NX_INTERSECTION_POINT_TRIANGLE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +//namespace NxCollision { + + /** + \brief Point-in-triangle test. + + We use the edges as parameters in case the user has access to edges directly + This is actually a "point-in-prism" test since it returns true as long as the point is bound by the edge planes. + + \param[in] p Point to test. Range: position vector + \param[in] p0 Triangle vertex. Range: position vector + \param[in] edge10 Triangle edge. Range: direction vector + \param[in] edge20 Second triangle edge. Range: direction vector + + \return True on intersection + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPointTriangleIntersect2D + */ + NX_INLINE NX_BOOL NxPointTriangleIntersect(const NxVec3& p, const NxVec3& p0, const NxVec3& edge10, const NxVec3& edge20) + { + NxReal a = edge10|edge10; + NxReal b = edge10|edge20; + NxReal c = edge20|edge20; + NxReal ac_bb = (a*c)-(b*b); + + NxVec3 vp = p - p0; + + NxReal d = vp|edge10; + NxReal e = vp|edge20; + + NxReal x = (d*c) - (e*b); + NxReal y = (e*a) - (d*b); + NxReal z = x + y - ac_bb; + + if ((x > 0.0f) && (y > 0.0f) && (z < 0.0f)) + return NX_TRUE; + else + return NX_FALSE; + } + + /** + \brief Dedicated 2D version of previous test + + \param[in] px Point to test, X + \param[in] pz Point to test, Z + \param[in] p0x Vertex of triangle to test, X + \param[in] p0z Vertex of triangle to test, Z + \param[in] e10x Edge of triangle to test, X + \param[in] e10z Edge of triangle to test, Y + \param[in] e20x Second edge of triangle to test, X + \param[in] e20z Second edge of triangle to test, Y + + \return True on intersection + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPointTriangleIntersect + */ + NX_INLINE NX_BOOL NxPointTriangleIntersect2D( + NxReal px, NxReal pz, + NxReal p0x, NxReal p0z, + NxReal e10x, NxReal e10z, + NxReal e20x, NxReal e20z) + { + NxReal a = e10x*e10x + e10z*e10z; + NxReal b = e10x*e20x + e10z*e20z; + NxReal c = e20x*e20x + e20z*e20z; + NxReal ac_bb = (a*c)-(b*b); + + NxReal vpx = px - p0x; + NxReal vpz = pz - p0z; + + NxReal d = vpx*e10x + vpz*e10z; + NxReal e = vpx*e20x + vpz*e20z; + + NxReal x = (d*c) - (e*b); + NxReal y = (e*a) - (d*b); + NxReal z = x + y - ac_bb; + + if ((x > 0.0f) && (y > 0.0f) && (z < 0.0f)) + return NX_TRUE; + else + return NX_FALSE; + } + +//} + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionRayPlane.h b/libraries/external/physx/Win32/include/PX/NxIntersectionRayPlane.h new file mode 100755 index 0000000..6914107 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionRayPlane.h @@ -0,0 +1,77 @@ +#ifndef NX_INTERSECTION_RAY_PLANE +#define NX_INTERSECTION_RAY_PLANE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/PhysXLoader.h" +class NxRay; +class NxPlane; + + /** + \brief Segment-plane intersection test. + + Returns distance between v1 and impact point, as well as impact point on plane. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] v1 First vertex of segment. Range: position vector + \param[in] v2 Second vertex of segment. Range: position vector + \param[in] plane Plane to test against. Range: See #NxPlane + \param[out] dist Distance from v1 to impact point (so pointOnPlane=Normalize(v2-v1)*dist). + \param[out] pointOnPlane Imapct point on plane. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxSegmentPlaneIntersect(const NxVec3& v1, const NxVec3& v2, + const NxPlane& plane, NxReal& dist, NxVec3& pointOnPlane) + { + return NxGetUtilLib()->NxSegmentPlaneIntersect(v1,v2,plane,dist,pointOnPlane); + } + + /** + \brief Ray-plane intersection test. + + Returns distance between ray origin and impact point, as well as impact point on plane. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] ray Ray to test against plane. Range: See #NxRay + \param[in] plane Plane to test. Range: See #NxPlane + \param[out] dist Distance along ray to impact point (so pointOnPlane=Normalize(v2-v1)*dist). + \param[out] pointOnPlane Impact point on the plane. + + \return True on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxRayPlaneIntersect(const NxRay& ray, const NxPlane& plane, + NxReal& dist, NxVec3& pointOnPlane) + { + return NxGetUtilLib()->NxRayPlaneIntersect(ray,plane,dist,pointOnPlane); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionRaySphere.h b/libraries/external/physx/Win32/include/PX/NxIntersectionRaySphere.h new file mode 100755 index 0000000..f25fef2 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionRaySphere.h @@ -0,0 +1,55 @@ +#ifndef NX_INTERSECTION_RAY_SPHERE +#define NX_INTERSECTION_RAY_SPHERE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/PhysXLoader.h" + +//namespace NxCollision +//{ + /** + \brief Ray-sphere intersection test. + + Returns true if the ray intersects the sphere, and the impact point if needed. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] origin Origin of the ray. Range: position vector + \param[in] dir Direction of the ray. Range: direction vector + \param[in] length Length of the ray. Range: (0,inf) + \param[in] center Center of the sphere. Range: position vector + \param[in] radius Sphere radius. Range: (0,inf) + \param[out] hit_time Distance of intersection between ray and sphere. + \param[out] hit_pos Point of intersection between ray and sphere. + + \return True on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxRaySphereIntersect(const NxVec3& origin, const NxVec3& dir, NxReal length, const NxVec3& center, NxReal radius, NxReal& hit_time, NxVec3& hit_pos) + { + return NxGetUtilLib()->NxRaySphereIntersect(origin, dir, length, center, radius, hit_time, hit_pos); + } +//} + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionRayTriangle.h b/libraries/external/physx/Win32/include/PX/NxIntersectionRayTriangle.h new file mode 100755 index 0000000..02c212d --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionRayTriangle.h @@ -0,0 +1,57 @@ +#ifndef NX_INTERSECTION_RAY_TRIANGLE +#define NX_INTERSECTION_RAY_TRIANGLE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/PhysXLoader.h" + +//namespace NxCollision +//{ + /** + \brief Ray-triangle intersection test. + + Returns impact distance (t) as well as barycentric coordinates (u,v) of impact point. + Use NxComputeBarycentricPoint() in Foundation to compute the impact point from the barycentric coordinates. + The test performs back face culling or not according to 'cull'. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] orig Origin of the ray. Range: position vector + \param[in] dir Direction of the ray. Range: direction vector + \param[in] vert0 First vertex of triangle. Range: position vector + \param[in] vert1 Second vertex of triangle. Range: position vector + \param[in] vert2 Third vertex of triangle. Range: position vector + \param[out] t Distance along the ray from the origin to the impact point. + \param[out] u Barycentric coordinate. + \param[out] v Barycentric coordinate. + \param[in] cull Cull backfaces. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxRayTriIntersect(const NxVec3& orig, const NxVec3& dir, const NxVec3& vert0, const NxVec3& vert1, const NxVec3& vert2, float& t, float& u, float& v, bool cull) + { + return NxGetUtilLib()->NxRayTriIntersect(orig,dir,vert0,vert1,vert2,t,u,v,cull); + } +//} + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionSegmentBox.h b/libraries/external/physx/Win32/include/PX/NxIntersectionSegmentBox.h new file mode 100755 index 0000000..fbc9a6f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionSegmentBox.h @@ -0,0 +1,191 @@ +#ifndef NX_INTERSECTION_SEGMENT_BOX +#define NX_INTERSECTION_SEGMENT_BOX +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxBox.h" +#include "PX/PhysXLoader.h" + +class NxRay; + +//namespace NxCollision +//{ + /** + \brief Segment-AABB intersection test. + + Also computes intersection point. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] p1 First point of line segment. Range: position vector + \param[in] p2 Second point of line segment. Range: position vector + \param[in] bbox_min Minimum extent of AABB. Range: position vector + \param[in] bbox_max Max extent of AABB. Range: position vector + \param[out] intercept Intersection point between segment and box. + + \return True if the segment and AABB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxSegmentBoxIntersect(const NxVec3& p1, const NxVec3& p2, + const NxVec3& bbox_min,const NxVec3& bbox_max, NxVec3& intercept) + { + return NxGetUtilLib()->NxSegmentBoxIntersect(p1,p2,bbox_min,bbox_max,intercept); + } + + /** + \brief Ray-AABB intersection test. + + Also computes intersection point. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] min Minimum extent of AABB. Range: position vector + \param[in] max Maximum extent of AABB. Range: position vector + \param[in] origin Origin of ray. Range: position vector + \param[in] dir Direction of ray. Range: direction vector + \param[out] coord Intersection point. + + \return True if the ray and AABB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxRayAABBIntersect(const NxVec3& min, const NxVec3& max, + const NxVec3& origin, const NxVec3& dir, NxVec3& coord) + { + return NxGetUtilLib()->NxRayAABBIntersect(min,max,origin,dir,coord); + } + + /** + \brief Extended Ray-AABB intersection test. + + Also computes intersection point, and parameter and returns contacted box axis index+1. Rays starting from inside the box are ignored. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] min Minimum extent of AABB. Range: position vector + \param[in] max Maximum extent of AABB. Range: position vector + \param[in] origin Origin of ray. Range: position vector + \param[in] dir Direction of ray. Range: direction vector + \param[out] coord Intersection point. + \param[out] t Ray parameter corresponding to contact point. + + \return Box axis index. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxU32 NxRayAABBIntersect2(const NxVec3& min, const NxVec3& max, + const NxVec3& origin, const NxVec3& dir, NxVec3& coord, NxReal & t) + { + return NxGetUtilLib()->NxRayAABBIntersect2(min,max,origin,dir,coord,t); + } + + /** + \brief Boolean segment-OBB intersection test. + + Based on separating axis theorem. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] p0 First point of line segment. Range: position vector + \param[in] p1 Second point of line segment. Range: position vector + \param[in] center Center point of OBB. Range: position vector + \param[in] extents Extent/Radii of the OBB. Range: direction vector + \param[in] rot Rotation of the OBB(applied before translation). Range: rotation matrix + + \return true if the segment and OBB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxSegmentOBBIntersect(const NxVec3& p0, const NxVec3& p1, + const NxVec3& center, const NxVec3& extents, const NxMat33& rot) + { + return NxGetUtilLib()->NxSegmentOBBIntersect(p0,p1,center,extents,rot); + } + + /** + \brief Boolean segment-AABB intersection test. + + Based on separating axis theorem. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] p0 First point of line segment. Range: position vector + \param[in] p1 Second point of line segment. Range: position vector + \param[in] min Minimum extent of AABB. Range: position vector + \param[in] max Maximum extent of AABB. Range: position vector + + \return True if the segment and AABB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxSegmentAABBIntersect(const NxVec3& p0, const NxVec3& p1, + const NxVec3& min, const NxVec3& max) + { + return NxGetUtilLib()->NxSegmentAABBIntersect(p0,p1,min,max); + } + + /** + \brief Boolean ray-OBB intersection test. + + Based on separating axis theorem. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] ray Ray to test against OBB. Range: See #NxRay + \param[in] center Center point of OBB. Range: position vector + \param[in] extents Extent/Radii of the OBB. Range: direction vector + \param[in] rot Rotation of the OBB(applied before translation). Range: rotation matrix + + \return True on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NxRayOBBIntersect(const NxRay& ray, const NxVec3& center, + const NxVec3& extents, const NxMat33& rot) + { + return NxGetUtilLib()->NxRayOBBIntersect(ray,center,extents,rot); + } +//} + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionSegmentCapsule.h b/libraries/external/physx/Win32/include/PX/NxIntersectionSegmentCapsule.h new file mode 100755 index 0000000..1539b7e --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionSegmentCapsule.h @@ -0,0 +1,92 @@ +#ifndef NX_INTERSECTION_SEGMENT_CAPSULE +#define NX_INTERSECTION_SEGMENT_CAPSULE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxCapsule.h" +#include "PX/NxSegment.h" +#include "PX/PhysXLoader.h" + +//namespace NxCollision { + + /** + \brief Ray-capsule intersection test. + + Returns number of intersection points (0,1 or 2) and corresponding parameters along the ray. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] origin Origin of ray. Range: position vector + \param[in] dir Direction of ray. Range: direction vector + \param[in] capsule Capsule to test. Range: see #NxCapsule + \param[out] t Parameter of intersection on the ray. + + \return Number of intersection points. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxRay NxCapsule + */ + NX_INLINE NxU32 NxRayCapsuleIntersect(const NxVec3& origin, const NxVec3& dir, + const NxCapsule& capsule, NxReal t[2]) + { + return NxGetUtilLib()->NxRayCapsuleIntersect(origin,dir,capsule,t); + } + + /** + \brief Segment-capsule intersection test. + + Returns number of intersection points (0,1 or 2) and corresponding parameters along the ray. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] segment Line segment. Range: See #NxSegment + \param[in] capsule Capsule to test. Range: See #NxCapsule + \param[out] nbImpacts Number of intersection point (0, 1 or 2) + \param[out] t Parameter of intersection on the ray. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSegement NxCapsule + */ + NX_INLINE void NxSegmentCapsuleIntersect(const NxSegment& segment, const NxCapsule& capsule, NxU32* nbImpacts, + NxReal t[2]) + { + NxReal s[2]; + NxU32 numISec = NxRayCapsuleIntersect(segment.p0, segment.computeDirection(), capsule,s); + + NxU32 numClip = 0; + for(NxU32 i = 0; i < numISec; i++) + { + if ( 0.0f <= s[i] && s[i] <= 1.0f ) t[numClip++] = s[i]; + } + + *nbImpacts = numClip; + } +//} + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxIntersectionSweptSpheres.h b/libraries/external/physx/Win32/include/PX/NxIntersectionSweptSpheres.h new file mode 100755 index 0000000..0daa5ae --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxIntersectionSweptSpheres.h @@ -0,0 +1,55 @@ +#ifndef NX_INTERSECTION_SWEPT_SPHERES +#define NX_INTERSECTION_SWEPT_SPHERES +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxSphere.h" +#include "PX/PhysXLoader.h" + + /** + \brief Sphere-sphere sweep test. + + Returns true if spheres intersect during their linear motion along provided velocity vectors. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] sphere0 First sphere to test. Range: See #NxSphere + \param[in] velocity0 Velocity of the first sphere(ie the vector to sweep the sphere along). Range: velocity/direction vector + \param[in] sphere1 Second sphere to test Range: See #NxSphere + \param[in] velocity1 Velocity of the second sphere(ie the vector to sweep the sphere along). Range: velocity/direction vector + + \return True if spheres intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere + */ + NX_INLINE bool NxSweptSpheresIntersect( const NxSphere& sphere0, const NxVec3& velocity0, + const NxSphere& sphere1, const NxVec3& velocity1) + { + return NxGetUtilLib()->NxSweptSpheresIntersect(sphere0, velocity0,sphere1,velocity1); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + + diff --git a/libraries/external/physx/Win32/include/PX/NxJoint.h b/libraries/external/physx/Win32/include/PX/NxJoint.h new file mode 100755 index 0000000..da0b26b --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxJoint.h @@ -0,0 +1,715 @@ +#ifndef NX_PHYSICS_NXJOINT +#define NX_PHYSICS_NXJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxActor; +class NxScene; +class NxRevoluteJoint; +class NxPointInPlaneJoint; +class NxPointOnLineJoint; +class NxPrismaticJoint; +class NxCylindricalJoint; +class NxSphericalJoint; +class NxFixedJoint; +class NxDistanceJoint; +class NxPulleyJoint; +class NxD6Joint; + +/** + \brief Abstract base class for the different types of joints. + + All joints are used to connect two dynamic actors, or an actor and the environment. + + A NULL actor represents the environment. Whenever the below comments mention two actors, + one of them may always be the environment (NULL). + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + +Platform: +\li PC SW: Yes +\li PPU : Yes (Up to 64k per scene) +\li PS3 : Yes +\li XB360: Yes + + @see NxJointDesc NxScene.createJoint() + @see NxCylindricalJoint NxD6Joint NxDistanceJoint NxFixedJoint NxPointInPlaneJoint +NxPointOnLineJoint NxPrismaticJoint NxPulleyJoint NxRevoluteJointDesc NxSphericalJoint +*/ +class NxJoint + { + protected: + NX_INLINE NxJoint() : userData(NULL), appData(NULL) + {} + virtual ~NxJoint() {} + + public: + + /** + \brief Retrieves the Actors involved. + + \param[out] actor1 First actor associated with joint. + \param[out] actor2 Second actor associated with joint. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.actors NxActor + */ + virtual void getActors(NxActor** actor1, NxActor** actor2) = 0; + + /** + \brief Sets the point where the two actors are attached, specified in global coordinates. + + Set this after setting the actors of the joint. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] vec Point the actors are attached at, specified in the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.setGlobalAnchor() getGlobalAnchor() + */ + virtual void setGlobalAnchor(const NxVec3 &vec) = 0; + + /** + \brief Sets the direction of the joint's primary axis, specified in global coordinates. + + The direction vector should be normalized to unit length. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] vec Direction of primary axis in the global frame. Range: direction vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.setGlobalAxis() getGlobalAxis() + */ + virtual void setGlobalAxis(const NxVec3 &vec) = 0; + + /** + \brief Retrieves the joint anchor. + + \return The joints anchor point in the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalAnchor() getGlobalAxis() + */ + virtual NxVec3 getGlobalAnchor() const = 0; + + /** + \brief Retrieves the joint axis. + + \return The joints axis in the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalAxis() getGlobalAnchor() + */ + virtual NxVec3 getGlobalAxis() const = 0; + + /** + \brief Returns the state of the joint. + + Joints are created in the NX_JS_UNBOUND state. Making certain changes to the simulation or the joint + can also make joints become unbound. + Unbound joints are automatically bound the next time Scene::run() is called, and this changes their + state to NX_JS_SIMULATING. NX_JS_BROKEN means that a breakable joint has broken due to a large force + or one of its actors has been deleted. In either case the joint was removed from the simulation, + so it should be released by the user to free up its memory. + + \return The state of the joint. See #NxJointState. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointState setBreakable() + */ + virtual NxJointState getState() = 0; + + /** + \brief Sets the maximum force magnitude that the joint is able to withstand without breaking. + + If the joint force rises above this threshold, the joint breaks, and becomes disabled. Additionally, + the jointBreakNotify() method of the scene's user notify callback will be called. + (You can set this with NxScene::setUserNotify()). + + There are two values, one for linear forces, and one for angular forces. Both values are used directly + as a value for the maximum impulse tolerated by the joint constraints. + + Both force values are NX_MAX_REAL by default. This setting makes the joint unbreakable. + The values should always be nonnegative. + + The distinction between maxForce and maxTorque is dependent on how the joint is implemented internally, + which may not be obvious. For example what appears to be an angular degree of freedom may be constrained + indirectly by a linear constraint. + + So in most practical applications the user should set both maxTorque and maxForce to low values. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] maxForce Maximum force the joint can withstand without breaking. Range: (0,inf] + \param[in] maxTorque Maximum torque the joint can withstand without breaking. Range: (0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.maxForce NxJointDesc.maxTorque getState() getBreakable() + */ + virtual void setBreakable(NxReal maxForce, NxReal maxTorque) = 0; + + /** + \brief Retrieves the max forces of a breakable joint. See #setBreakable(). + + \param[out] maxForce Retrieves the maximum force the joint can withstand without breaking. + \param[out] maxTorque Retrieves the maximum torque the joint can withstand without breaking. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setBreakable NxJointDesc.maxForce NxJointDesc.maxTorque getState() + */ + virtual void getBreakable(NxReal & maxForce, NxReal & maxTorque) = 0; + + /** + \brief Sets the solver extrapolation factor. + + \param[in] solverExtrapolationFactor The solver extrapolation factor. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.solverExtrapolationFactor + */ + + virtual void setSolverExtrapolationFactor(NxReal solverExtrapolationFactor) = 0; + + /** + \brief Retrieves the solver extrapolation factor. + + \return The solver extrapolation factor. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.solverExtrapolationFactor + */ + virtual NxReal getSolverExtrapolationFactor() const = 0; + + /** + \brief Switch between acceleration and force based spring. + + \param[in] b {true: use acceleration spring, false: use force spring}. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.useAccelerationSpring + */ + virtual void setUseAccelerationSpring(bool b) = 0; + + /** + \brief Checks whether acceleration spring is used. + + \return True if acceleration spring is used else false. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.useAccelerationSpring + */ + virtual bool getUseAccelerationSpring() const = 0; + +/************************************************************************************************/ + +/** @name Limits +*/ +//@{ + + /** + \brief Sets the limit point. + + The point is specified in the global coordinate frame. + + All types of joints may be limited with the same system: + You may elect a point attached to one of the two actors to act as the limit point. + You may also specify several planes attached to the other actor. + + The points and planes move together with the actor they are attached to. + + The simulation then makes certain that the pair of actors only move relative to each other + so that the limit point stays on the positive side of all limit planes. + + the default limit point is (0,0,0) in the local frame of actor2. + Calling this deletes all existing limit planes. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] point The limit reference point defined in the global frame. Range: position vector + \param[in] pointIsOnActor2 if true the point is attached to the second actor. Otherwise it is attached to the first. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLimitPoint() addLimitPlane() + */ + + virtual void setLimitPoint(const NxVec3 & point, bool pointIsOnActor2 = true) = 0; + + /** + \brief Retrieves the global space limit point. + + Returns true if the point is fixed on actor2. + + \param[out] worldLimitPoint Used to store the global frame limit point. + \return True if the point is fixed to actor 2 otherwise the point is fixed to actor 1. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLimitPoint() addLimitPlane() + */ + virtual bool getLimitPoint(NxVec3 & worldLimitPoint) = 0; + + /** + \brief Adds a limit plane. + + Both of the parameters are given in global coordinates. see setLimitPoint() for the meaning of limit planes. + + The plane is affixed to the actor that does not have the limit point. + + The normal of the plane points toward the positive side of the plane, and thus toward the + limit point. If the normal points away from the limit point at the time of this call, the + method returns false and the limit plane is ignored. + + \note This function always returns true and adds the limit plane unlike earlier versions. This behavior + was changed to allow the joint to be serialized easily. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] normal Normal for the limit plane in global coordinates. Range: direction vector + \param[in] pointInPlane Point in the limit plane in global coordinates. Range: position vector + \param[in] restitution Restitution of the limit plane. + Range: [0.0, 1.0] + Default: 0.0 + \return Always true. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLimitPoint() purgeLimitPlanes() getNextLimitPlane() + */ + virtual bool addLimitPlane(const NxVec3 & normal, const NxVec3 & pointInPlane, NxReal restitution = 0.0f) = 0; + + /** + \brief deletes all limit planes added to the joint. + + Invalidates limit plane iterator. + + Sleeping: Does NOT wake the associated actor up automatically. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see addLimitPlane() getNextLimitPlane() + */ + virtual void purgeLimitPlanes() = 0; + + /** + \brief Restarts the limit plane iteration. + + Call before starting to iterate. This method may be used together with + the below two methods to enumerate the limit planes. + This iterator becomes invalid when planes + are added or removed, or the plane iterator mechanism is + invoked on another joint. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see hasMoreLimitPlanes() getNextLimitPlane() + */ + virtual void resetLimitPlaneIterator() = 0; + + /** + \brief Returns true until the iterator reaches the end of the set of limit planes. + + Adding or removing elements does not reset the iterator. + + \return True if the iterator has not reached the end of the sequence of limit planes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see resetLimitPlaneIterator() getNextLimitPlane() + */ + virtual bool hasMoreLimitPlanes() = 0; + + /** + \brief Returns the next element pointed to by the limit plane iterator, and increments the iterator. + + Places the global frame plane equation (consisting of normal and d, the 4th + element) coefficients in the argument references. The plane equation is of the form: + + dot(n,p) + d == 0 (n = normal, p = a point on the plane) + + \note This convention for the plane equation differs from the convention used by #NxPlaneShape + + \param[out] planeNormal Used to store the plane normal. + \param[out] planeD Used to store the plane 'D'. + \param[out] restitution Optional, used to store restitution of the limit plane. + \return Returns true if the limit plane is satisfied. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see resetLimitPlaneIterator() hasMoreLimitPlanes() + */ + virtual bool getNextLimitPlane(NxVec3 & planeNormal, NxReal & planeD, NxReal * restitution = NULL) = 0; +//@} +/************************************************************************************************/ + + /** + \brief Retrieve the type of this joint. + \return The type of joint. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Only D6 joints are supported in hardware) + \li PS3 : Yes + \li XB360: Yes + + @see NxJointType + */ + virtual NxJointType getType() const = 0; + +/************************************************************************************************/ + +/** @name Is... Joint Type +*/ +//@{ + + /** + \brief Type casting operator. The result may be cast to the desired subclass type. + + \param[in] type Used to query for a specific joint type. + \return NULL if the object if not of type(see #NxJointType). Otherwise a pointer to this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointType + */ + virtual void* is(NxJointType type) = 0; + + /** + \brief Attempts to perform a cast to a #NxRevoluteJoint. + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxRevoluteJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxRevoluteJoint + */ + NX_INLINE NxRevoluteJoint* isRevoluteJoint() { return (NxRevoluteJoint*)is(NX_JOINT_REVOLUTE);} + + /** + \brief Attempts to perform a cast to a #NxPointInPlaneJoint. + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxPointInPlaneJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxPointInPlaneJoint + */ + NX_INLINE NxPointInPlaneJoint* isPointInPlaneJoint() { return (NxPointInPlaneJoint*)is(NX_JOINT_POINT_IN_PLANE);} + + /** + \brief Attempts to perform a cast to a #NxPointOnLineJoint. + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxPointOnLineJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxPointOnLineJoint + */ + NX_INLINE NxPointOnLineJoint* isPointOnLineJoint() { return (NxPointOnLineJoint*)is(NX_JOINT_POINT_ON_LINE);} + + /** + \brief Attempts to perform a cast to a #NxD6Joint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxD6Joint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxD6Joint + */ + NX_INLINE NxD6Joint* isD6Joint() { return (NxD6Joint*)is(NX_JOINT_D6);} + + /** + \brief Attempts to perform a cast to a #NxPrismaticJoint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxPrismaticJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxPrismaticJoint + */ + NX_INLINE NxPrismaticJoint* isPrismaticJoint() { return (NxPrismaticJoint*)is(NX_JOINT_PRISMATIC);} + + /** + \brief Attempts to perform a cast to a #NxCylindricalJoint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxCylindricalJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxCylindricalJoint + */ + NX_INLINE NxCylindricalJoint* isCylindricalJoint() { return (NxCylindricalJoint*)is(NX_JOINT_CYLINDRICAL);} + + /** + \brief Attempts to perform a cast to a #NxSphericalJoint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxSphericalJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxSphericalJoint + */ + NX_INLINE NxSphericalJoint* isSphericalJoint() { return (NxSphericalJoint*)is(NX_JOINT_SPHERICAL);} + + /** + \brief Attempts to perform a cast to a #NxFixedJoint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxFixedJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxFixedJoint + */ + NX_INLINE NxFixedJoint* isFixedJoint() { return (NxFixedJoint*)is(NX_JOINT_FIXED);} + + /** + \brief Attempts to perform a cast to a #NxDistanceJoint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxDistanceJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxDistanceJoint + */ + NX_INLINE NxDistanceJoint* isDistanceJoint() { return (NxDistanceJoint*)is(NX_JOINT_DISTANCE);} + + /** + \brief Attempts to perform a cast to a #NxPulleyJoint + + Returns NULL if this object is not of the appropriate type. + + \return NULL if this object is not a #NxPulleyJoint. Otherwise a pointer to this. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see is NxPulleyJoint + */ + NX_INLINE NxPulleyJoint* isPulleyJoint() { return (NxPulleyJoint*)is(NX_JOINT_PULLEY);} +//@} +/************************************************************************************************/ + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName(const char* name) = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The name string for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName() const = 0; + + /** + \brief Retrieves owner scene. + + \return The scene which owns this joint. + + Platform: + + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + void* appData; //!< used internally, do not change. + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxJointDesc.h b/libraries/external/physx/Win32/include/PX/NxJointDesc.h new file mode 100755 index 0000000..6ff9a51 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxJointDesc.h @@ -0,0 +1,376 @@ +#ifndef NX_PHYSICS_NXJOINTDESC +#define NX_PHYSICS_NXJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" +#include "PX/NxActor.h" +#include "PX/PhysXLoader.h" +#include "PX/NxUtilLib.h" + +/** +\brief Descriptor class for the #NxJoint class. + +Joint descriptors for all the different joint types are derived from this class. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxJoint NxScene.createJoint() +@see NxCylindricalJointDesc NxD6JointDesc NxDistanceJointDesc NxFixedJointDesc NxPointInPlaneJointDesc +NxPointOnLineJointDesc NxPrismaticJointDesc NxPulleyJointDesc NxRevoluteJointDesc NxSphericalJointDesc +*/ +class NxJointDesc + { + protected: + + /** + \brief The type of joint. This is set by the c'tor of the derived class. + */ + NxJointType type; + public: + + /** + \brief The two actors connected by the joint. + + The actors must be in the same scene as this joint. + + At least one of the two pointers must be a dynamic actor. + + One of the two may be NULL to indicate the world frame. Neither may be a static actor! + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor + */ + NxActor * actor[2]; + + /** + \brief X axis of joint space, in actor[i]'s space, orthogonal to localAxis[i] + + #localAxis and localNormal should be unit length and at right angles to each other, i.e. + dot(localNormal[0],localAxis[0])==0 and dot(localNormal[1],localAxis[1])==0. + + Range: direction vector
+ Default: [0] 1.0f,0.0f,0.0f
+ Default: [1] 1.0f,0.0f,0.0f + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see localAxis setGlobalAxis() + */ + NxVec3 localNormal[2]; + + /** + \brief Z axis of joint space, in actor[i]'s space. This is the primary axis of the joint. + + localAxis and #localNormal should be unit length and at right angles to each other, i.e. + dot(localNormal[0],localAxis[0])==0 and dot(localNormal[1],localAxis[1])==0. + + Range: direction vector
+ Default: [0] 0.0f,0.0f,1.0f
+ Default: [1] 0.0f,0.0f,1.0f + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see localNormal setGlobalAxis() + */ + NxVec3 localAxis[2]; + + /** + \brief Attachment point of joint in actor[i]'s space + + Range: position vector
+ Default: [0] Zero
+ Default: [1] Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalAnchor() + */ + NxVec3 localAnchor[2]; + + /** + Maximum linear force that the joint can withstand before breaking, must be positive. + + Range: (0,inf]
+ Default: NX_MAX_REAL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint.setBreakable() NxUserNotify.onJointBreak() + */ + NxReal maxForce; + + /** + \brief Maximum angular force (torque) that the joint can withstand before breaking, must be positive. + + Range: (0,inf]
+ Default: NX_MAX_REAL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint.setBreakable() NxUserNotify.onJointBreak() + */ + NxReal maxTorque; + + /** + \brief Extrapolation factor for solving joint constraints. + + This parameter can be used to build stronger joints and increase the solver convergence. Higher values + lead to stronger joints. + + \note Setting the value too high can decrease the joint stability. + + \note Currently, this feature is supported for D6, Revolute and Spherical Joints only. + + Range: [0.5,2]
+ Default: 1 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint.setSolverExtrapolationFactor(), NxJoint.getSolverExtrapolationFactor() + */ + NxReal solverExtrapolationFactor; + + /** + \brief Switch to acceleration based spring. + + This parameter can be used to switch between acceleration and force based spring. Acceleration + based springs do not take the mass of the attached objects into account, i.e., the spring/damping + behaviour will be independent of the load. + + \note Currently, this feature is supported for D6, Revolute and Spherical Joints only. + + Range: {0: use force spring, 1: use acceleration spring}
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint.setUseAccelerationSpring(), NxJoint.getUseAccelerationSpring() + */ + NxU32 useAccelerationSpring; + + /** + \brief Will be copied to NxJoint::userData. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief This is a combination of the bits defined by ::NxJointFlag . + + Default: NX_JF_VISUALIZATION + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 jointFlags; + + + NX_INLINE virtual ~NxJointDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + + + /** + \brief Set the localAnchor[] members using a world space point. + + sets the members localAnchor[0,1] by transforming the passed world space + vector into actor1 resp. actor2's local space. The actor pointers must already be set! + + \param[in] wsAnchor Global frame anchor point. Range: position vector + + @see setGlobalAxis() localAxis + */ + NX_INLINE void setGlobalAnchor(const NxVec3 & wsAnchor); + + /** + \brief Set the local axis/normal using a world space axis. + + sets the members localAxis[0,1] by transforming the passed world space + vector into actor1 resp. actor2's local space, and finding arbitrary orthogonals for localNormal[0,1]. + The actor pointers must already be set! + + \param[in] wsAxis Global frame axis. Range: direction vector + + @see setGlobalAnchor() localAnchor + */ + NX_INLINE void setGlobalAxis(const NxVec3 & wsAxis); + + /** + \brief Retrieves the joint type. + + \return The type of joint this descriptor describes. See #NxJointType. + + @see NxJointType + */ + NX_INLINE NxJointType getType() const { return type; } + protected: + /** + \brief Constructor sets to default. + + \param t Joint type + */ + NX_INLINE NxJointDesc(NxJointType t); + }; + + +NX_INLINE NxJointDesc::NxJointDesc(NxJointType t) : type(t) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE NxJointDesc::~NxJointDesc() + { + } + +NX_INLINE void NxJointDesc::setToDefault() + { + for (int i=0; i<2; i++) + { + actor[i] = 0; + localAxis[i].set(0,0,1); + localNormal[i].set(1,0,0); + localAnchor[i].zero(); + } + + maxForce = NX_MAX_REAL; + maxTorque = NX_MAX_REAL; + solverExtrapolationFactor = 1.0f; + useAccelerationSpring = 0; + userData = NULL; + name = NULL; + jointFlags = NX_JF_VISUALIZATION; + } + +NX_INLINE bool NxJointDesc::isValid() const + { + if (actor[0] == actor[1]) + return false; + if (!(actor[0] || actor[1])) + return false; + //non-null pointers must be dynamic: + if (actor[0] && ! actor[0]->isDynamic()) + return false; + if (actor[1] && ! actor[1]->isDynamic()) + return false; + + if (type >= NX_JOINT_COUNT) + return false; + for (int i=0; i<2; i++) + { + if (fabsf(localAxis[i].magnitudeSquared() - 1.0f) > 0.1f) return false; + if (fabsf(localNormal[i].magnitudeSquared() - 1.0f) > 0.1f) return false; + //check orthogonal pairs + if (fabsf(localAxis[i].dot(localNormal[i])) > 0.1f) return false; + } + if (maxForce <= 0) + return false; + if (maxTorque <= 0) + return false; + if ((solverExtrapolationFactor < 0.5f) || (solverExtrapolationFactor > 2.0f)) + return false; + if (useAccelerationSpring > 1) + return false; + + return true; + } + +NX_INLINE void NxJointDesc::setGlobalAnchor(const NxVec3 & wsAnchor) + { + NxGetUtilLib()->NxJointDesc_SetGlobalAnchor(*this, wsAnchor); + } + +NX_INLINE void NxJointDesc::setGlobalAxis(const NxVec3 & wsAxis) + { + NxGetUtilLib()->NxJointDesc_SetGlobalAxis(*this, wsAxis); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxJointLimitDesc.h b/libraries/external/physx/Win32/include/PX/NxJointLimitDesc.h new file mode 100755 index 0000000..023077d --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxJointLimitDesc.h @@ -0,0 +1,102 @@ +#ifndef NX_PHYSICS_NXJOINTLIMITDESC +#define NX_PHYSICS_NXJOINTLIMITDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +/** +\brief Describes a joint limit. + +

Example

+ +\include NxSpringDesc_NxJointLimitDesc_Example.cpp + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxRevoluteJoint NxSphericalJoint NxJointLimitPairDesc +*/ +class NxJointLimitDesc + { + public: + /** + \brief The angle / position beyond which the limit is active. + + Which side the limit restricts depends on whether this is a high or low limit. + + Unit: Angular: Radians + Range: Angular: (-PI,PI)
+ Range: Positional: (-inf,inf)
+ Default: 0.0 + */ + NxReal value; + + /** + \brief limit bounce + + Range: [0,1]
+ Default: 0.0 + */ + NxReal restitution; + + /** + \brief [not yet implemented!] limit can be made softer by setting this to less than 1. + + Range: [0,1]
+ Default: 1.0 + */ + NxReal hardness; + + /** + \brief Constructor, sets members to default values. + */ + NX_INLINE NxJointLimitDesc(); + + /** + \brief Sets members to default values. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxJointLimitDesc::NxJointLimitDesc() + { + setToDefault(); + } + +NX_INLINE void NxJointLimitDesc::setToDefault() + { + value = 0; + restitution = 0; + hardness = 1; + } + +NX_INLINE bool NxJointLimitDesc::isValid() const + { + return (restitution >= 0 && restitution <= 1 && hardness >= 0 && hardness <= 1); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxJointLimitPairDesc.h b/libraries/external/physx/Win32/include/PX/NxJointLimitPairDesc.h new file mode 100755 index 0000000..9fba6f7 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxJointLimitPairDesc.h @@ -0,0 +1,95 @@ +#ifndef NX_PHYSICS_NXJOINTLIMITPAIRDESC +#define NX_PHYSICS_NXJOINTLIMITPAIRDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxJointLimitDesc.h" + +/** +\brief Describes a pair of joint limits + +

Example

+ +\include NxSpringDesc_NxJointLimitDesc_Example.cpp + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxRevoluteJoint NxSphericalJoint NxJointLimitDesc +*/ +class NxJointLimitPairDesc + { + public: + + /** + \brief The low limit (smaller value) + + Range: See #NxJointLimitDesc
+ Default: See #NxJointLimitDesc + + @see NxJointLimitDesc + */ + NxJointLimitDesc low; + + /** + \brief the high limit (larger value) + + Range: See #NxJointLimitDesc
+ Default: See #NxJointLimitDesc + + @see NxJointLimitDesc + */ + NxJointLimitDesc high; + + /** + \brief Constructor, sets members to default values. + */ + NX_INLINE NxJointLimitPairDesc(); + + /** + \brief Sets members to default values. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxJointLimitPairDesc::NxJointLimitPairDesc() + { + setToDefault(); + } + +NX_INLINE void NxJointLimitPairDesc::setToDefault() + { + //nothing + } + +NX_INLINE bool NxJointLimitPairDesc::isValid() const + { + return (low.isValid() && high.isValid() && low.value <= high.value); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxJointLimitSoftDesc.h b/libraries/external/physx/Win32/include/PX/NxJointLimitSoftDesc.h new file mode 100755 index 0000000..91dcfc4 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxJointLimitSoftDesc.h @@ -0,0 +1,121 @@ +#ifndef NX_PHYSICS_NXJOINTLIMITSOFTDESC +#define NX_PHYSICS_NXJOINTLIMITSOFTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +/** +\brief Describes a joint limit. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxD6Joint NxD6JointDesc NxJointSoftLimitPairDesc +*/ +class NxJointLimitSoftDesc + { + public: + /** + \brief the angle / position beyond which the limit is active. + + Which side the limit restricts depends on whether this is a high or low limit. + + Unit: Angular: Radians + Range: Angular: (-PI,PI)
+ Range: Positional: [0.0,inf)
+ Default: 0.0 + */ + NxReal value; + + /** + \brief Controls the amount of bounce when the joint hits a limit. + + A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit. + A value of zero causes the joint to stop dead. + + In situations where the joint has many locked DOFs (e.g. 5) the restitution may not be applied + correctly. This is due to a limitation in the solver which causes the restitution velocity to become zero + as the solver enforces constraints on the other DOFs. + + This limitation applies to both angular and linear limits, however it is generally most apparent with limited + angular DOFs. + + Disabling joint projection and increasing the solver iteration count may improve this behavior to some extent. + + Also, combining soft joint limits with joint motors driving against those limits may affect stability. + + Range: [0,1]
+ Default: 0.0 + */ + NxReal restitution; + + /** + \brief if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit + + Range: [0,inf)
+ Default: 0.0 + */ + NxReal spring; + + /** + \brief if spring is greater than zero, this is the damping of the spring + + Range: [0,inf)
+ Default: 0.0 + */ + NxReal damping; + + /** + \brief Constructor, sets members to default values. + */ + NX_INLINE NxJointLimitSoftDesc(); + + /** + \brief Sets members to default values. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxJointLimitSoftDesc::NxJointLimitSoftDesc() + { + setToDefault(); + } + +NX_INLINE void NxJointLimitSoftDesc::setToDefault() + { + value = 0; + restitution = 0; + spring = 0; + damping = 0; + } + +NX_INLINE bool NxJointLimitSoftDesc::isValid() const + { + return (restitution >= 0 && restitution <= 1); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxJointLimitSoftPairDesc.h b/libraries/external/physx/Win32/include/PX/NxJointLimitSoftPairDesc.h new file mode 100755 index 0000000..59a8e48 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxJointLimitSoftPairDesc.h @@ -0,0 +1,91 @@ +#ifndef NX_PHYSICS_NXJOINTLIMITSOFTPAIRDESC +#define NX_PHYSICS_NXJOINTLIMITSOFTPAIRDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxJointLimitSoftDesc.h" + +/** +\brief Describes a pair of joint limits + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxD6Joint NxD6JointDesc +*/ +class NxJointLimitSoftPairDesc + { + public: + + /** + \brief The low limit (smaller value) + + Range: See #NxJointLimitSoftDesc
+ Default: See #NxJointLimitSoftDesc + + @see NxJointLimitSoftDesc + */ + NxJointLimitSoftDesc low; + + /** + \brief the high limit (larger value) + + Range: See #NxJointLimitSoftDesc
+ Default: See #NxJointLimitSoftDesc + + @see NxJointLimitSoftDesc + */ + NxJointLimitSoftDesc high; + + /** + \brief Constructor, sets members to default values. + */ + NX_INLINE NxJointLimitSoftPairDesc(); + + /** + \brief Sets members to default values. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxJointLimitSoftPairDesc::NxJointLimitSoftPairDesc() + { + setToDefault(); + } + +NX_INLINE void NxJointLimitSoftPairDesc::setToDefault() + { + //nothing + } + +NX_INLINE bool NxJointLimitSoftPairDesc::isValid() const + { + return (low.isValid() && high.isValid() && low.value <= high.value); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMat33.h b/libraries/external/physx/Win32/include/PX/NxMat33.h new file mode 100755 index 0000000..a85b19b --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMat33.h @@ -0,0 +1,1784 @@ +#ifndef NX_FOUNDATION_NxMat33T +#define NX_FOUNDATION_NxMat33T +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/NxVec3.h" +#include "PX/NxQuat.h" + + +/** +\brief Identifies a special matrix. Can be passed to the #NxMat33 constructor. +*/ +enum NxMatrixType + { + /** + \brief Matrix of all zeros. + */ + NX_ZERO_MATRIX, + + /** + \brief Identity matrix. + */ + NX_IDENTITY_MATRIX + }; + +#include "Nx9F32.h" //change this if changing type below, to Nx9F32, Nx12F32, Nx16F32 + +typedef Nx9Real Mat33DataType; //takes Nx9Real, Nx12Real, Nx16Real + +/** +\brief 3x3 Matrix Class. + + The idea of the matrix/vector classes is to partition them into two parts: + One is the data structure which may have different formatting (3x3, 3x4, 4x4), + row or column major. The other is a template class which has all the operators + but is storage format independent. + + This way it should be easier to change formats depending on what is faster/slower + on a particular platform. + + Design issue: We use nameless struct/unions here. + Design issue: this used to be implemented with a template. This had no benefit + but it added syntactic complexity. Currently we just use a typedef and a preprocessor switch + to change between different memory layouts. + + The matrix math in this class is storage format (row/col major) independent as far + as the user is concerned. + When the user wants to get/set raw data, he needs to specify what order the data is + coming in. + +*/ +class NxMat33 + { + public: + NX_INLINE NxMat33(); + + /** + \param type Special matrix type to initialize with. + + @see NxMatrixType + */ + NX_INLINE NxMat33(NxMatrixType type); + NX_INLINE NxMat33(const NxVec3 &row0, const NxVec3 &row1, const NxVec3 &row2); + + NX_INLINE NxMat33(const NxMat33&m); + NX_INLINE NxMat33(const NxQuat &m); + NX_INLINE ~NxMat33(); + NX_INLINE const NxMat33& operator=(const NxMat33 &src); + + // Access elements + + //low level data access, single or double precision, with eventual translation: + //for dense 9 element data + NX_INLINE void setRowMajor(const NxF32 *); + NX_INLINE void setRowMajor(const NxF32 d[][3]); + NX_INLINE void setColumnMajor(const NxF32 *); + NX_INLINE void setColumnMajor(const NxF32 d[][3]); + NX_INLINE void getRowMajor(NxF32 *) const; + NX_INLINE void getRowMajor(NxF32 d[][3]) const; + NX_INLINE void getColumnMajor(NxF32 *) const; + NX_INLINE void getColumnMajor(NxF32 d[][3]) const; + + NX_INLINE void setRowMajor(const NxF64 *); + NX_INLINE void setRowMajor(const NxF64 d[][3]); + NX_INLINE void setColumnMajor(const NxF64 *); + NX_INLINE void setColumnMajor(const NxF64 d[][3]); + NX_INLINE void getRowMajor(NxF64 *) const; + NX_INLINE void getRowMajor(NxF64 d[][3]) const; + NX_INLINE void getColumnMajor(NxF64 *) const; + NX_INLINE void getColumnMajor(NxF64 d[][3]) const; + + + //for loose 4-padded data. + NX_INLINE void setRowMajorStride4(const NxF32 *); + NX_INLINE void setRowMajorStride4(const NxF32 d[][4]); + NX_INLINE void setColumnMajorStride4(const NxF32 *); + NX_INLINE void setColumnMajorStride4(const NxF32 d[][4]); + NX_INLINE void getRowMajorStride4(NxF32 *) const; + NX_INLINE void getRowMajorStride4(NxF32 d[][4]) const; + NX_INLINE void getColumnMajorStride4(NxF32 *) const; + NX_INLINE void getColumnMajorStride4(NxF32 d[][4]) const; + + NX_INLINE void setRowMajorStride4(const NxF64 *); + NX_INLINE void setRowMajorStride4(const NxF64 d[][4]); + NX_INLINE void setColumnMajorStride4(const NxF64 *); + NX_INLINE void setColumnMajorStride4(const NxF64 d[][4]); + NX_INLINE void getRowMajorStride4(NxF64 *) const; + NX_INLINE void getRowMajorStride4(NxF64 d[][4]) const; + NX_INLINE void getColumnMajorStride4(NxF64 *) const; + NX_INLINE void getColumnMajorStride4(NxF64 d[][4]) const; + + + NX_INLINE void setRow(int row, const NxVec3 &); + NX_INLINE void setColumn(int col, const NxVec3 &); + NX_INLINE void getRow(int row, NxVec3 &) const; + NX_INLINE void getColumn(int col, NxVec3 &) const; + + NX_INLINE NxVec3 getRow(int row) const; + NX_INLINE NxVec3 getColumn(int col) const; + + + //element access: + NX_INLINE NxReal & operator()(int row, int col); + NX_INLINE const NxReal & operator() (int row, int col) const; + + /** + \brief returns true for identity matrix + */ + NX_INLINE bool isIdentity() const; + + /** + \brief returns true for zero matrix + */ + NX_INLINE bool isZero() const; + + /** + \brief returns true if all elems are finite (not NAN or INF, etc.) + */ + NX_INLINE bool isFinite() const; + + //create special matrices: + + /** + \brief sets this matrix to the zero matrix. + */ + NX_INLINE void zero(); + + /** + \brief sets this matrix to the identity matrix. + */ + NX_INLINE void id(); + + /** + \brief this = -this + */ + NX_INLINE void setNegative(); + + /** + \brief sets this matrix to the diagonal matrix. + */ + NX_INLINE void diagonal(const NxVec3 &vec); + + /** + \brief Sets this matrix to the Star(Skew Symetric) matrix. + + So that star(v) * x = v.cross(x) . + */ + NX_INLINE void star(const NxVec3 &vec); + + + NX_INLINE void fromQuat(const NxQuat &); + NX_INLINE void toQuat(NxQuat &) const; + + //modifications: + + NX_INLINE const NxMat33 &operator +=(const NxMat33 &s); + NX_INLINE const NxMat33 &operator -=(const NxMat33 &s); + NX_INLINE const NxMat33 &operator *=(NxReal s); + NX_INLINE const NxMat33 &operator /=(NxReal s); + + /* + Gram-Schmidt orthogonalization to correct numerical drift, plus column normalization + Caution: I believe the current implementation does not work right! + */ +// NX_INLINE void orthonormalize(); + + + /** + \brief returns determinant + */ + NX_INLINE NxReal determinant() const; + + /** + \brief assigns inverse to dest. + + Returns false if singular (i.e. if no inverse exists), setting dest to identity. + */ + NX_INLINE bool getInverse(NxMat33& dest) const; + + /** + \brief this = transpose(other) + + this == other is OK. + */ + NX_INLINE void setTransposed(const NxMat33& other); + + /** + \brief this = transpose(this) + */ + NX_INLINE void setTransposed(); + + /** + \brief this = this * [ d.x 0 0; 0 d.y 0; 0 0 d.z]; + */ + NX_INLINE void multiplyDiagonal(const NxVec3 &d); + + /** + \brief this = transpose(this) * [ d.x 0 0; 0 d.y 0; 0 0 d.z]; + */ + NX_INLINE void multiplyDiagonalTranspose(const NxVec3 &d); + + /** + \brief dst = this * [ d.x 0 0; 0 d.y 0; 0 0 d.z]; + */ + NX_INLINE void multiplyDiagonal(const NxVec3 &d, NxMat33 &dst) const; + + /** + \brief dst = transpose(this) * [ d.x 0 0; 0 d.y 0; 0 0 d.z]; + */ + NX_INLINE void multiplyDiagonalTranspose(const NxVec3 &d, NxMat33 &dst) const; + + /** + \brief dst = this * src + */ + NX_INLINE void multiply(const NxVec3 &src, NxVec3 &dst) const; + /** + \brief dst = transpose(this) * src + */ + NX_INLINE void multiplyByTranspose(const NxVec3 &src, NxVec3 &dst) const; + + /** + \brief this = a + b + */ + NX_INLINE void add(const NxMat33 & a, const NxMat33 & b); + /*** + \brief this = a - b + */ + NX_INLINE void subtract(const NxMat33 &a, const NxMat33 &b); + /** + \brief this = s * a; + */ + NX_INLINE void multiply(NxReal s, const NxMat33 & a); + /** + \brief this = left * right + */ + NX_INLINE void multiply(const NxMat33& left, const NxMat33& right); + /** + \brief this = transpose(left) * right + + \note #multiplyByTranspose() is faster. + */ + NX_INLINE void multiplyTransposeLeft(const NxMat33& left, const NxMat33& right); + /** + \brief this = left * transpose(right) + + \note faster than #multiplyByTranspose(). + */ + NX_INLINE void multiplyTransposeRight(const NxMat33& left, const NxMat33& right); + + /** + \brief this = left * transpose(right) + */ + NX_INLINE void multiplyTransposeRight(const NxVec3 &left, const NxVec3 &right); + + /** + \brief this = rotation matrix around X axis + + Unit: Radians + */ + NX_INLINE void rotX(NxReal angle); + + /** + \brief this = rotation matrix around Y axis + + Unit: Radians + */ + NX_INLINE void rotY(NxReal angle); + + /** + \brief this = rotation matrix around Z axis + + Unit: Radians + */ + NX_INLINE void rotZ(NxReal angle); + + + //overloaded multiply, and transposed-multiply ops: + + /** + \brief returns transpose(this)*src + */ + NX_INLINE NxVec3 operator% (const NxVec3 & src) const; + /** + \brief matrix vector product + */ + NX_INLINE NxVec3 operator* (const NxVec3 & src) const; + /** + \brief matrix product + */ + NX_INLINE NxMat33& operator*= (const NxMat33& mat); + /** + \brief matrix difference + */ + NX_INLINE NxMat33 operator- (const NxMat33& mat) const; + /** + \brief matrix addition + */ + NX_INLINE NxMat33 operator+ (const NxMat33& mat) const; + /** + \brief matrix product + */ + NX_INLINE NxMat33 operator* (const NxMat33& mat) const; + /** + \brief matrix scalar product + */ + NX_INLINE NxMat33 operator* (float s) const; + + private: + Mat33DataType data; + }; + + +NX_INLINE NxMat33::NxMat33() + { + } + + +NX_INLINE NxMat33::NxMat33(NxMatrixType type) + { + switch(type) + { + case NX_ZERO_MATRIX: zero(); break; + case NX_IDENTITY_MATRIX: id(); break; + } + } + + +NX_INLINE NxMat33::NxMat33(const NxMat33& a) + { + data = a.data; + } + + +NX_INLINE NxMat33::NxMat33(const NxQuat &q) + { + fromQuat(q); + } + +NX_INLINE NxMat33::NxMat33(const NxVec3 &row0, const NxVec3 &row1, const NxVec3 &row2) +{ + data.s._11 = row0.x; data.s._12 = row0.y; data.s._13 = row0.z; + data.s._21 = row1.x; data.s._22 = row1.y; data.s._23 = row1.z; + data.s._31 = row2.x; data.s._32 = row2.y; data.s._33 = row2.z; +} + + +NX_INLINE NxMat33::~NxMat33() + { + //nothing + } + + +NX_INLINE const NxMat33& NxMat33::operator=(const NxMat33 &a) + { + data = a.data; + return *this; + } + + +NX_INLINE void NxMat33::setRowMajor(const NxF32* d) + { + //we are also row major, so this is a direct copy + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[1]; + data.s._13 = (NxReal)d[2]; + + data.s._21 = (NxReal)d[3]; + data.s._22 = (NxReal)d[4]; + data.s._23 = (NxReal)d[5]; + + data.s._31 = (NxReal)d[6]; + data.s._32 = (NxReal)d[7]; + data.s._33 = (NxReal)d[8]; + } + + +NX_INLINE void NxMat33::setRowMajor(const NxF32 d[][3]) + { + //we are also row major, so this is a direct copy + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[0][1]; + data.s._13 = (NxReal)d[0][2]; + + data.s._21 = (NxReal)d[1][0]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[1][2]; + + data.s._31 = (NxReal)d[2][0]; + data.s._32 = (NxReal)d[2][1]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::setColumnMajor(const NxF32* d) + { + //we are column major, so copy transposed. + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[3]; + data.s._13 = (NxReal)d[6]; + + data.s._21 = (NxReal)d[1]; + data.s._22 = (NxReal)d[4]; + data.s._23 = (NxReal)d[7]; + + data.s._31 = (NxReal)d[2]; + data.s._32 = (NxReal)d[5]; + data.s._33 = (NxReal)d[8]; + } + + +NX_INLINE void NxMat33::setColumnMajor(const NxF32 d[][3]) + { + //we are column major, so copy transposed. + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[1][0]; + data.s._13 = (NxReal)d[2][0]; + + data.s._21 = (NxReal)d[0][1]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[2][1]; + + data.s._31 = (NxReal)d[0][2]; + data.s._32 = (NxReal)d[1][2]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::getRowMajor(NxF32* d) const + { + //we are also row major, so this is a direct copy + d[0] = (NxF32)data.s._11; + d[1] = (NxF32)data.s._12; + d[2] = (NxF32)data.s._13; + + d[3] = (NxF32)data.s._21; + d[4] = (NxF32)data.s._22; + d[5] = (NxF32)data.s._23; + + d[6] = (NxF32)data.s._31; + d[7] = (NxF32)data.s._32; + d[8] = (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::getRowMajor(NxF32 d[][3]) const + { + //we are also row major, so this is a direct copy + d[0][0] = (NxF32)data.s._11; + d[0][1] = (NxF32)data.s._12; + d[0][2] = (NxF32)data.s._13; + + d[1][0] = (NxF32)data.s._21; + d[1][1] = (NxF32)data.s._22; + d[1][2] = (NxF32)data.s._23; + + d[2][0] = (NxF32)data.s._31; + d[2][1] = (NxF32)data.s._32; + d[2][2] = (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajor(NxF32* d) const + { + //we are column major, so copy transposed. + d[0] = (NxF32)data.s._11; + d[3] = (NxF32)data.s._12; + d[6] = (NxF32)data.s._13; + + d[1] = (NxF32)data.s._21; + d[4] = (NxF32)data.s._22; + d[7] = (NxF32)data.s._23; + + d[2] = (NxF32)data.s._31; + d[5] = (NxF32)data.s._32; + d[8] = (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajor(NxF32 d[][3]) const + { + //we are column major, so copy transposed. + d[0][0] = (NxF32)data.s._11; + d[1][0] = (NxF32)data.s._12; + d[2][0] = (NxF32)data.s._13; + + d[0][1] = (NxF32)data.s._21; + d[1][1] = (NxF32)data.s._22; + d[2][1] = (NxF32)data.s._23; + + d[0][2] = (NxF32)data.s._31; + d[1][2] = (NxF32)data.s._32; + d[2][2] = (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::setRowMajorStride4(const NxF32* d) + { + //we are also row major, so this is a direct copy + //however we've got to skip every 4th element. + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[1]; + data.s._13 = (NxReal)d[2]; + + data.s._21 = (NxReal)d[4]; + data.s._22 = (NxReal)d[5]; + data.s._23 = (NxReal)d[6]; + + data.s._31 = (NxReal)d[8]; + data.s._32 = (NxReal)d[9]; + data.s._33 = (NxReal)d[10]; + } + + +NX_INLINE void NxMat33::setRowMajorStride4(const NxF32 d[][4]) + { + //we are also row major, so this is a direct copy + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[0][1]; + data.s._13 = (NxReal)d[0][2]; + + data.s._21 = (NxReal)d[1][0]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[1][2]; + + data.s._31 = (NxReal)d[2][0]; + data.s._32 = (NxReal)d[2][1]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::setColumnMajorStride4(const NxF32* d) + { + //we are column major, so copy transposed. + //however we've got to skip every 4th element. + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[4]; + data.s._13 = (NxReal)d[8]; + + data.s._21 = (NxReal)d[1]; + data.s._22 = (NxReal)d[5]; + data.s._23 = (NxReal)d[9]; + + data.s._31 = (NxReal)d[2]; + data.s._32 = (NxReal)d[6]; + data.s._33 = (NxReal)d[10]; + } + + +NX_INLINE void NxMat33::setColumnMajorStride4(const NxF32 d[][4]) + { + //we are column major, so copy transposed. + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[1][0]; + data.s._13 = (NxReal)d[2][0]; + + data.s._21 = (NxReal)d[0][1]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[2][1]; + + data.s._31 = (NxReal)d[0][2]; + data.s._32 = (NxReal)d[1][2]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::getRowMajorStride4(NxF32* d) const + { + //we are also row major, so this is a direct copy + //however we've got to skip every 4th element. + d[0] = (NxF32)data.s._11; + d[1] = (NxF32)data.s._12; + d[2] = (NxF32)data.s._13; + + d[4] = (NxF32)data.s._21; + d[5] = (NxF32)data.s._22; + d[6] = (NxF32)data.s._23; + + d[8] = (NxF32)data.s._31; + d[9] = (NxF32)data.s._32; + d[10]= (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::getRowMajorStride4(NxF32 d[][4]) const + { + //we are also row major, so this is a direct copy + d[0][0] = (NxF32)data.s._11; + d[0][1] = (NxF32)data.s._12; + d[0][2] = (NxF32)data.s._13; + + d[1][0] = (NxF32)data.s._21; + d[1][1] = (NxF32)data.s._22; + d[1][2] = (NxF32)data.s._23; + + d[2][0] = (NxF32)data.s._31; + d[2][1] = (NxF32)data.s._32; + d[2][2] = (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajorStride4(NxF32* d) const + { + //we are column major, so copy transposed. + //however we've got to skip every 4th element. + d[0] = (NxF32)data.s._11; + d[4] = (NxF32)data.s._12; + d[8] = (NxF32)data.s._13; + + d[1] = (NxF32)data.s._21; + d[5] = (NxF32)data.s._22; + d[9] = (NxF32)data.s._23; + + d[2] = (NxF32)data.s._31; + d[6] = (NxF32)data.s._32; + d[10]= (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajorStride4(NxF32 d[][4]) const + { + //we are column major, so copy transposed. + d[0][0] = (NxF32)data.s._11; + d[1][0] = (NxF32)data.s._12; + d[2][0] = (NxF32)data.s._13; + + d[0][1] = (NxF32)data.s._21; + d[1][1] = (NxF32)data.s._22; + d[2][1] = (NxF32)data.s._23; + + d[0][2] = (NxF32)data.s._31; + d[1][2] = (NxF32)data.s._32; + d[2][2] = (NxF32)data.s._33; + } + + +NX_INLINE void NxMat33::setRowMajor(const NxF64*d) + { + //we are also row major, so this is a direct copy + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[1]; + data.s._13 = (NxReal)d[2]; + + data.s._21 = (NxReal)d[3]; + data.s._22 = (NxReal)d[4]; + data.s._23 = (NxReal)d[5]; + + data.s._31 = (NxReal)d[6]; + data.s._32 = (NxReal)d[7]; + data.s._33 = (NxReal)d[8]; + } + + +NX_INLINE void NxMat33::setRowMajor(const NxF64 d[][3]) + { + //we are also row major, so this is a direct copy + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[0][1]; + data.s._13 = (NxReal)d[0][2]; + + data.s._21 = (NxReal)d[1][0]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[1][2]; + + data.s._31 = (NxReal)d[2][0]; + data.s._32 = (NxReal)d[2][1]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::setColumnMajor(const NxF64*d) + { + //we are column major, so copy transposed. + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[3]; + data.s._13 = (NxReal)d[6]; + + data.s._21 = (NxReal)d[1]; + data.s._22 = (NxReal)d[4]; + data.s._23 = (NxReal)d[7]; + + data.s._31 = (NxReal)d[2]; + data.s._32 = (NxReal)d[5]; + data.s._33 = (NxReal)d[8]; + } + + +NX_INLINE void NxMat33::setColumnMajor(const NxF64 d[][3]) + { + //we are column major, so copy transposed. + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[1][0]; + data.s._13 = (NxReal)d[2][0]; + + data.s._21 = (NxReal)d[0][1]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[2][1]; + + data.s._31 = (NxReal)d[0][2]; + data.s._32 = (NxReal)d[1][2]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::getRowMajor(NxF64*d) const + { + //we are also row major, so this is a direct copy + d[0] = (NxF64)data.s._11; + d[1] = (NxF64)data.s._12; + d[2] = (NxF64)data.s._13; + + d[3] = (NxF64)data.s._21; + d[4] = (NxF64)data.s._22; + d[5] = (NxF64)data.s._23; + + d[6] = (NxF64)data.s._31; + d[7] = (NxF64)data.s._32; + d[8] = (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::getRowMajor(NxF64 d[][3]) const + { + //we are also row major, so this is a direct copy + d[0][0] = (NxF64)data.s._11; + d[0][1] = (NxF64)data.s._12; + d[0][2] = (NxF64)data.s._13; + + d[1][0] = (NxF64)data.s._21; + d[1][1] = (NxF64)data.s._22; + d[1][2] = (NxF64)data.s._23; + + d[2][0] = (NxF64)data.s._31; + d[2][1] = (NxF64)data.s._32; + d[2][2] = (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajor(NxF64*d) const + { + //we are column major, so copy transposed. + d[0] = (NxF64)data.s._11; + d[3] = (NxF64)data.s._12; + d[6] = (NxF64)data.s._13; + + d[1] = (NxF64)data.s._21; + d[4] = (NxF64)data.s._22; + d[7] = (NxF64)data.s._23; + + d[2] = (NxF64)data.s._31; + d[5] = (NxF64)data.s._32; + d[8] = (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajor(NxF64 d[][3]) const + { + //we are column major, so copy transposed. + d[0][0] = (NxF64)data.s._11; + d[1][0] = (NxF64)data.s._12; + d[2][0] = (NxF64)data.s._13; + + d[0][1] = (NxF64)data.s._21; + d[1][1] = (NxF64)data.s._22; + d[2][1] = (NxF64)data.s._23; + + d[0][2] = (NxF64)data.s._31; + d[1][2] = (NxF64)data.s._32; + d[2][2] = (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::setRowMajorStride4(const NxF64*d) + { + //we are also row major, so this is a direct copy + //however we've got to skip every 4th element. + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[1]; + data.s._13 = (NxReal)d[2]; + + data.s._21 = (NxReal)d[4]; + data.s._22 = (NxReal)d[5]; + data.s._23 = (NxReal)d[6]; + + data.s._31 = (NxReal)d[8]; + data.s._32 = (NxReal)d[9]; + data.s._33 = (NxReal)d[10]; + } + + +NX_INLINE void NxMat33::setRowMajorStride4(const NxF64 d[][4]) + { + //we are also row major, so this is a direct copy + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[0][1]; + data.s._13 = (NxReal)d[0][2]; + + data.s._21 = (NxReal)d[1][0]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[1][2]; + + data.s._31 = (NxReal)d[2][0]; + data.s._32 = (NxReal)d[2][1]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::setColumnMajorStride4(const NxF64*d) + { + //we are column major, so copy transposed. + //however we've got to skip every 4th element. + data.s._11 = (NxReal)d[0]; + data.s._12 = (NxReal)d[4]; + data.s._13 = (NxReal)d[8]; + + data.s._21 = (NxReal)d[1]; + data.s._22 = (NxReal)d[5]; + data.s._23 = (NxReal)d[9]; + + data.s._31 = (NxReal)d[2]; + data.s._32 = (NxReal)d[6]; + data.s._33 = (NxReal)d[10]; + } + + +NX_INLINE void NxMat33::setColumnMajorStride4(const NxF64 d[][4]) + { + //we are column major, so copy transposed. + data.s._11 = (NxReal)d[0][0]; + data.s._12 = (NxReal)d[1][0]; + data.s._13 = (NxReal)d[2][0]; + + data.s._21 = (NxReal)d[0][1]; + data.s._22 = (NxReal)d[1][1]; + data.s._23 = (NxReal)d[2][1]; + + data.s._31 = (NxReal)d[0][2]; + data.s._32 = (NxReal)d[1][2]; + data.s._33 = (NxReal)d[2][2]; + } + + +NX_INLINE void NxMat33::getRowMajorStride4(NxF64*d) const + { + //we are also row major, so this is a direct copy + //however we've got to skip every 4th element. + d[0] = (NxF64)data.s._11; + d[1] = (NxF64)data.s._12; + d[2] = (NxF64)data.s._13; + + d[4] = (NxF64)data.s._21; + d[5] = (NxF64)data.s._22; + d[6] = (NxF64)data.s._23; + + d[8] = (NxF64)data.s._31; + d[9] = (NxF64)data.s._32; + d[10]= (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::getRowMajorStride4(NxF64 d[][4]) const + { + //we are also row major, so this is a direct copy + d[0][0] = (NxF64)data.s._11; + d[0][1] = (NxF64)data.s._12; + d[0][2] = (NxF64)data.s._13; + + d[1][0] = (NxF64)data.s._21; + d[1][1] = (NxF64)data.s._22; + d[1][2] = (NxF64)data.s._23; + + d[2][0] = (NxF64)data.s._31; + d[2][1] = (NxF64)data.s._32; + d[2][2] = (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajorStride4(NxF64*d) const + + { + //we are column major, so copy transposed. + //however we've got to skip every 4th element. + d[0] = (NxF64)data.s._11; + d[4] = (NxF64)data.s._12; + d[8] = (NxF64)data.s._13; + + d[1] = (NxF64)data.s._21; + d[5] = (NxF64)data.s._22; + d[9] = (NxF64)data.s._23; + + d[2] = (NxF64)data.s._31; + d[6] = (NxF64)data.s._32; + d[10]= (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::getColumnMajorStride4(NxF64 d[][4]) const + { + //we are column major, so copy transposed. + d[0][0] = (NxF64)data.s._11; + d[1][0] = (NxF64)data.s._12; + d[2][0] = (NxF64)data.s._13; + + d[0][1] = (NxF64)data.s._21; + d[1][1] = (NxF64)data.s._22; + d[2][1] = (NxF64)data.s._23; + + d[0][2] = (NxF64)data.s._31; + d[1][2] = (NxF64)data.s._32; + d[2][2] = (NxF64)data.s._33; + } + + +NX_INLINE void NxMat33::setRow(int row, const NxVec3 & v) + { +#ifndef TRANSPOSED_MAT33 + data.m[row][0] = v.x; + data.m[row][1] = v.y; + data.m[row][2] = v.z; +#else + data.m[0][row] = v.x; + data.m[1][row] = v.y; + data.m[2][row] = v.z; +#endif + } + + +NX_INLINE void NxMat33::setColumn(int col, const NxVec3 & v) + { +#ifndef TRANSPOSED_MAT33 + data.m[0][col] = v.x; + data.m[1][col] = v.y; + data.m[2][col] = v.z; +#else + data.m[col][0] = v.x; + data.m[col][1] = v.y; + data.m[col][2] = v.z; +#endif + } + + +NX_INLINE void NxMat33::getRow(int row, NxVec3 & v) const + { +#ifndef TRANSPOSED_MAT33 + v.x = data.m[row][0]; + v.y = data.m[row][1]; + v.z = data.m[row][2]; +#else + v.x = data.m[0][row]; + v.y = data.m[1][row]; + v.z = data.m[2][row]; +#endif + } + + +NX_INLINE void NxMat33::getColumn(int col, NxVec3 & v) const + { +#ifndef TRANSPOSED_MAT33 + v.x = data.m[0][col]; + v.y = data.m[1][col]; + v.z = data.m[2][col]; +#else + v.x = data.m[col][0]; + v.y = data.m[col][1]; + v.z = data.m[col][2]; +#endif + } + + +NX_INLINE NxVec3 NxMat33::getRow(int row) const +{ +#ifndef TRANSPOSED_MAT33 + return NxVec3(data.m[row][0],data.m[row][1],data.m[row][2]); +#else + return NxVec3(data.m[0][row],data.m[1][row],data.m[2][row]); +#endif +} + +NX_INLINE NxVec3 NxMat33::getColumn(int col) const +{ +#ifndef TRANSPOSED_MAT33 + return NxVec3(data.m[0][col],data.m[1][col],data.m[2][col]); +#else + return NxVec3(data.m[col][0],data.m[col][1],data.m[col][2]); +#endif +} + +NX_INLINE NxReal & NxMat33::operator()(int row, int col) + { +#ifndef TRANSPOSED_MAT33 + return data.m[row][col]; +#else + return data.m[col][row]; +#endif + } + + +NX_INLINE const NxReal & NxMat33::operator() (int row, int col) const + { +#ifndef TRANSPOSED_MAT33 + return data.m[row][col]; +#else + return data.m[col][row]; +#endif + } + +//const methods + + +NX_INLINE bool NxMat33::isIdentity() const + { + if(data.s._11 != 1.0f) return false; + if(data.s._12 != 0.0f) return false; + if(data.s._13 != 0.0f) return false; + + if(data.s._21 != 0.0f) return false; + if(data.s._22 != 1.0f) return false; + if(data.s._23 != 0.0f) return false; + + if(data.s._31 != 0.0f) return false; + if(data.s._32 != 0.0f) return false; + if(data.s._33 != 1.0f) return false; + + return true; + } + + +NX_INLINE bool NxMat33::isZero() const + { + if(data.s._11 != 0.0f) return false; + if(data.s._12 != 0.0f) return false; + if(data.s._13 != 0.0f) return false; + + if(data.s._21 != 0.0f) return false; + if(data.s._22 != 0.0f) return false; + if(data.s._23 != 0.0f) return false; + + if(data.s._31 != 0.0f) return false; + if(data.s._32 != 0.0f) return false; + if(data.s._33 != 0.0f) return false; + + return true; + } + + +NX_INLINE bool NxMat33::isFinite() const + { + return NxMath::isFinite(data.s._11) + && NxMath::isFinite(data.s._12) + && NxMath::isFinite(data.s._13) + + && NxMath::isFinite(data.s._21) + && NxMath::isFinite(data.s._22) + && NxMath::isFinite(data.s._23) + + && NxMath::isFinite(data.s._31) + && NxMath::isFinite(data.s._32) + && NxMath::isFinite(data.s._33); + } + + + +NX_INLINE void NxMat33::zero() + { + data.s._11 = NxReal(0.0); + data.s._12 = NxReal(0.0); + data.s._13 = NxReal(0.0); + + data.s._21 = NxReal(0.0); + data.s._22 = NxReal(0.0); + data.s._23 = NxReal(0.0); + + data.s._31 = NxReal(0.0); + data.s._32 = NxReal(0.0); + data.s._33 = NxReal(0.0); + } + + +NX_INLINE void NxMat33::id() + { + data.s._11 = NxReal(1.0); + data.s._12 = NxReal(0.0); + data.s._13 = NxReal(0.0); + + data.s._21 = NxReal(0.0); + data.s._22 = NxReal(1.0); + data.s._23 = NxReal(0.0); + + data.s._31 = NxReal(0.0); + data.s._32 = NxReal(0.0); + data.s._33 = NxReal(1.0); + } + + +NX_INLINE void NxMat33::setNegative() + { + data.s._11 = -data.s._11; + data.s._12 = -data.s._12; + data.s._13 = -data.s._13; + + data.s._21 = -data.s._21; + data.s._22 = -data.s._22; + data.s._23 = -data.s._23; + + data.s._31 = -data.s._31; + data.s._32 = -data.s._32; + data.s._33 = -data.s._33; + } + + +NX_INLINE void NxMat33::diagonal(const NxVec3 &v) + { + data.s._11 = v.x; + data.s._12 = NxReal(0.0); + data.s._13 = NxReal(0.0); + + data.s._21 = NxReal(0.0); + data.s._22 = v.y; + data.s._23 = NxReal(0.0); + + data.s._31 = NxReal(0.0); + data.s._32 = NxReal(0.0); + data.s._33 = v.z; + } + + +NX_INLINE void NxMat33::star(const NxVec3 &v) + { + data.s._11 = NxReal(0.0); data.s._12 =-v.z; data.s._13 = v.y; + data.s._21 = v.z; data.s._22 = NxReal(0.0); data.s._23 =-v.x; + data.s._31 =-v.y; data.s._32 = v.x; data.s._33 = NxReal(0.0); + } + + +NX_INLINE void NxMat33::fromQuat(const NxQuat & q) + { + const NxReal w = q.w; + const NxReal x = q.x; + const NxReal y = q.y; + const NxReal z = q.z; + + data.s._11 = NxReal(1.0) - y*y*NxReal(2.0) - z*z*NxReal(2.0); + data.s._12 = x*y*NxReal(2.0) - w*z*NxReal(2.0); + data.s._13 = x*z*NxReal(2.0) + w*y*NxReal(2.0); + + data.s._21 = x*y*NxReal(2.0) + w*z*NxReal(2.0); + data.s._22 = NxReal(1.0) - x*x*NxReal(2.0) - z*z*NxReal(2.0); + data.s._23 = y*z*NxReal(2.0) - w*x*NxReal(2.0); + + data.s._31 = x*z*NxReal(2.0) - w*y*NxReal(2.0); + data.s._32 = y*z*NxReal(2.0) + w*x*NxReal(2.0); + data.s._33 = NxReal(1.0) - x*x*NxReal(2.0) - y*y*NxReal(2.0); + } + + +NX_INLINE void NxMat33::toQuat(NxQuat & q) const // set the NxQuat from a rotation matrix + { + NxReal tr, s; + tr = data.s._11 + data.s._22 + data.s._33; + if(tr >= 0) + { + s = (NxReal)NxMath::sqrt(tr +1); + q.w = NxReal(0.5) * s; + s = NxReal(0.5) / s; + q.x = ((*this)(2,1) - (*this)(1,2)) * s; + q.y = ((*this)(0,2) - (*this)(2,0)) * s; + q.z = ((*this)(1,0) - (*this)(0,1)) * s; + } + else + { + int i = 0; + if (data.s._22 > data.s._11) + i = 1; + if(data.s._33 > (*this)(i,i)) + i=2; + switch (i) + { + case 0: + s = (NxReal)NxMath::sqrt((data.s._11 - (data.s._22 + data.s._33)) + 1); + q.x = NxReal(0.5) * s; + s = NxReal(0.5) / s; + q.y = ((*this)(0,1) + (*this)(1,0)) * s; + q.z = ((*this)(2,0) + (*this)(0,2)) * s; + q.w = ((*this)(2,1) - (*this)(1,2)) * s; + break; + case 1: + s = (NxReal)NxMath::sqrt((data.s._22 - (data.s._33 + data.s._11)) + 1); + q.y = NxReal(0.5) * s; + s = NxReal(0.5) / s; + q.z = ((*this)(1,2) + (*this)(2,1)) * s; + q.x = ((*this)(0,1) + (*this)(1,0)) * s; + q.w = ((*this)(0,2) - (*this)(2,0)) * s; + break; + case 2: + s = (NxReal)NxMath::sqrt((data.s._33 - (data.s._11 + data.s._22)) + 1); + q.z = NxReal(0.5) * s; + s = NxReal(0.5) / s; + q.x = ((*this)(2,0) + (*this)(0,2)) * s; + q.y = ((*this)(1,2) + (*this)(2,1)) * s; + q.w = ((*this)(1,0) - (*this)(0,1)) * s; + } + } + } +/* + +NX_INLINE void NxMat33::orthonormalize() //Gram-Schmidt orthogonalization to correct numerical drift, plus column normalization + { + //TODO: This is buggy! + NxVec3 w,t1,t2,t3; + NxReal norm_sq; + + const NxReal m=3; //m := linalg[rowdim](A); + const NxReal n=3; //n := linalg[coldim](A); + int i, j, k = 0; //k := 0; + + + Mat33d v = *this; //v := linalg[col](A, 1 .. n); -- 3 column vectors indexable + NxVec3 norm_u_sq; + //# orthogonalize v[i] + for (i=0; igetColumn(j,t1); + this->getColumn(j,t2); + v.getColumn(i,t3); + NxVec3 temp = (t2 * (NxReal(1.0)/norm_u_sq[j])); + NxVec3 temp2 = temp * t3.dot( t1 ); + w -= temp; + } + // # compute norm of orthogonalized v[i] + norm_sq = w.Dot(w); + + if (norm_sq != NxReal(0.0)) + { // # linearly independent new orthogonal vector + // # add to list of u and norm_u_sq + this->SetColumn(i,w); //u = [op(u), evalm(w)]; + norm_u_sq[i] = norm_sq; //norm_u_sq = [op(norm_u_sq), norm_sq]; + k ++; + } + } + + + NxVec3 temp; //may want to do this in-place -- dunno if optimizer does this for me + for (i=0; i<3; i++) + { + getColumn(i,temp); + temp.normalize(); + setColumn(i,temp); + } + } + */ + + +NX_INLINE void NxMat33::setTransposed(const NxMat33& other) + { + //gotta special case in-place case + if (this != &other) + { + data.s._11 = other.data.s._11; + data.s._12 = other.data.s._21; + data.s._13 = other.data.s._31; + + data.s._21 = other.data.s._12; + data.s._22 = other.data.s._22; + data.s._23 = other.data.s._32; + + data.s._31 = other.data.s._13; + data.s._32 = other.data.s._23; + data.s._33 = other.data.s._33; + } + else + { + NxReal tx, ty, tz; + tx = data.s._21; data.s._21 = other.data.s._12; data.s._12 = tx; + ty = data.s._31; data.s._31 = other.data.s._13; data.s._13 = ty; + tz = data.s._32; data.s._32 = other.data.s._23; data.s._23 = tz; + } + } + + +NX_INLINE void NxMat33::setTransposed() + { + NX_Swap(data.s._12, data.s._21); + NX_Swap(data.s._23, data.s._32); + NX_Swap(data.s._13, data.s._31); + } + + +NX_INLINE void NxMat33::multiplyDiagonal(const NxVec3 &d) + { + data.s._11 *= d.x; + data.s._12 *= d.y; + data.s._13 *= d.z; + + data.s._21 *= d.x; + data.s._22 *= d.y; + data.s._23 *= d.z; + + data.s._31 *= d.x; + data.s._32 *= d.y; + data.s._33 *= d.z; + } + + +NX_INLINE void NxMat33::multiplyDiagonalTranspose(const NxVec3 &d) + { + NxReal temp; + data.s._11 = data.s._11 * d.x; + data.s._22 = data.s._22 * d.y; + data.s._33 = data.s._33 * d.z; + + temp = data.s._21 * d.y; + data.s._21 = data.s._12 * d.x; + data.s._12 = temp; + + temp = data.s._31 * d.z; + data.s._31 = data.s._13 * d.x; + data.s._13 = temp; + + temp = data.s._32 * d.z; + data.s._32 = data.s._23 * d.y; + data.s._23 = temp; + } + + +NX_INLINE void NxMat33::multiplyDiagonal(const NxVec3 &d, NxMat33& dst) const + { + dst.data.s._11 = data.s._11 * d.x; + dst.data.s._12 = data.s._12 * d.y; + dst.data.s._13 = data.s._13 * d.z; + + dst.data.s._21 = data.s._21 * d.x; + dst.data.s._22 = data.s._22 * d.y; + dst.data.s._23 = data.s._23 * d.z; + + dst.data.s._31 = data.s._31 * d.x; + dst.data.s._32 = data.s._32 * d.y; + dst.data.s._33 = data.s._33 * d.z; + } + + +NX_INLINE void NxMat33::multiplyDiagonalTranspose(const NxVec3 &d, NxMat33& dst) const + { + dst.data.s._11 = data.s._11 * d.x; + dst.data.s._12 = data.s._21 * d.y; + dst.data.s._13 = data.s._31 * d.z; + + dst.data.s._21 = data.s._12 * d.x; + dst.data.s._22 = data.s._22 * d.y; + dst.data.s._23 = data.s._32 * d.z; + + dst.data.s._31 = data.s._13 * d.x; + dst.data.s._32 = data.s._23 * d.y; + dst.data.s._33 = data.s._33 * d.z; + } + + +NX_INLINE void NxMat33::multiply(const NxVec3 &src, NxVec3 &dst) const + { + NxReal x,y,z; //so it works if src == dst + x = data.s._11 * src.x + data.s._12 * src.y + data.s._13 * src.z; + y = data.s._21 * src.x + data.s._22 * src.y + data.s._23 * src.z; + z = data.s._31 * src.x + data.s._32 * src.y + data.s._33 * src.z; + + dst.x = x; + dst.y = y; + dst.z = z; + } + + +NX_INLINE void NxMat33::multiplyByTranspose(const NxVec3 &src, NxVec3 &dst) const + { + NxReal x,y,z; //so it works if src == dst + x = data.s._11 * src.x + data.s._21 * src.y + data.s._31 * src.z; + y = data.s._12 * src.x + data.s._22 * src.y + data.s._32 * src.z; + z = data.s._13 * src.x + data.s._23 * src.y + data.s._33 * src.z; + + dst.x = x; + dst.y = y; + dst.z = z; + } + + +NX_INLINE void NxMat33::add(const NxMat33 & a, const NxMat33 & b) + { + data.s._11 = a.data.s._11 + b.data.s._11; + data.s._12 = a.data.s._12 + b.data.s._12; + data.s._13 = a.data.s._13 + b.data.s._13; + + data.s._21 = a.data.s._21 + b.data.s._21; + data.s._22 = a.data.s._22 + b.data.s._22; + data.s._23 = a.data.s._23 + b.data.s._23; + + data.s._31 = a.data.s._31 + b.data.s._31; + data.s._32 = a.data.s._32 + b.data.s._32; + data.s._33 = a.data.s._33 + b.data.s._33; + } + + +NX_INLINE void NxMat33::subtract(const NxMat33 &a, const NxMat33 &b) + { + data.s._11 = a.data.s._11 - b.data.s._11; + data.s._12 = a.data.s._12 - b.data.s._12; + data.s._13 = a.data.s._13 - b.data.s._13; + + data.s._21 = a.data.s._21 - b.data.s._21; + data.s._22 = a.data.s._22 - b.data.s._22; + data.s._23 = a.data.s._23 - b.data.s._23; + + data.s._31 = a.data.s._31 - b.data.s._31; + data.s._32 = a.data.s._32 - b.data.s._32; + data.s._33 = a.data.s._33 - b.data.s._33; + } + + +NX_INLINE void NxMat33::multiply(NxReal d, const NxMat33 & a) + { + data.s._11 = a.data.s._11 * d; + data.s._12 = a.data.s._12 * d; + data.s._13 = a.data.s._13 * d; + + data.s._21 = a.data.s._21 * d; + data.s._22 = a.data.s._22 * d; + data.s._23 = a.data.s._23 * d; + + data.s._31 = a.data.s._31 * d; + data.s._32 = a.data.s._32 * d; + data.s._33 = a.data.s._33 * d; + } + + +NX_INLINE void NxMat33::multiply(const NxMat33& left, const NxMat33& right) + { + NxReal a,b,c, d,e,f, g,h,i; + //note: temps needed so that x.multiply(x,y) works OK. + a =left.data.s._11 * right.data.s._11 +left.data.s._12 * right.data.s._21 +left.data.s._13 * right.data.s._31; + b =left.data.s._11 * right.data.s._12 +left.data.s._12 * right.data.s._22 +left.data.s._13 * right.data.s._32; + c =left.data.s._11 * right.data.s._13 +left.data.s._12 * right.data.s._23 +left.data.s._13 * right.data.s._33; + + d =left.data.s._21 * right.data.s._11 +left.data.s._22 * right.data.s._21 +left.data.s._23 * right.data.s._31; + e =left.data.s._21 * right.data.s._12 +left.data.s._22 * right.data.s._22 +left.data.s._23 * right.data.s._32; + f =left.data.s._21 * right.data.s._13 +left.data.s._22 * right.data.s._23 +left.data.s._23 * right.data.s._33; + + g =left.data.s._31 * right.data.s._11 +left.data.s._32 * right.data.s._21 +left.data.s._33 * right.data.s._31; + h =left.data.s._31 * right.data.s._12 +left.data.s._32 * right.data.s._22 +left.data.s._33 * right.data.s._32; + i =left.data.s._31 * right.data.s._13 +left.data.s._32 * right.data.s._23 +left.data.s._33 * right.data.s._33; + + + data.s._11 = a; + data.s._12 = b; + data.s._13 = c; + + data.s._21 = d; + data.s._22 = e; + data.s._23 = f; + + data.s._31 = g; + data.s._32 = h; + data.s._33 = i; + } + + +NX_INLINE void NxMat33::multiplyTransposeLeft(const NxMat33& left, const NxMat33& right) + { + NxReal a,b,c, d,e,f, g,h,i; + //note: temps needed so that x.multiply(x,y) works OK. + a =left.data.s._11 * right.data.s._11 +left.data.s._21 * right.data.s._21 +left.data.s._31 * right.data.s._31; + b =left.data.s._11 * right.data.s._12 +left.data.s._21 * right.data.s._22 +left.data.s._31 * right.data.s._32; + c =left.data.s._11 * right.data.s._13 +left.data.s._21 * right.data.s._23 +left.data.s._31 * right.data.s._33; + + d =left.data.s._12 * right.data.s._11 +left.data.s._22 * right.data.s._21 +left.data.s._32 * right.data.s._31; + e =left.data.s._12 * right.data.s._12 +left.data.s._22 * right.data.s._22 +left.data.s._32 * right.data.s._32; + f =left.data.s._12 * right.data.s._13 +left.data.s._22 * right.data.s._23 +left.data.s._32 * right.data.s._33; + + g =left.data.s._13 * right.data.s._11 +left.data.s._23 * right.data.s._21 +left.data.s._33 * right.data.s._31; + h =left.data.s._13 * right.data.s._12 +left.data.s._23 * right.data.s._22 +left.data.s._33 * right.data.s._32; + i =left.data.s._13 * right.data.s._13 +left.data.s._23 * right.data.s._23 +left.data.s._33 * right.data.s._33; + + data.s._11 = a; + data.s._12 = b; + data.s._13 = c; + + data.s._21 = d; + data.s._22 = e; + data.s._23 = f; + + data.s._31 = g; + data.s._32 = h; + data.s._33 = i; + } + + +NX_INLINE void NxMat33::multiplyTransposeRight(const NxMat33& left, const NxMat33& right) + { + NxReal a,b,c, d,e,f, g,h,i; + //note: temps needed so that x.multiply(x,y) works OK. + a =left.data.s._11 * right.data.s._11 +left.data.s._12 * right.data.s._12 +left.data.s._13 * right.data.s._13; + b =left.data.s._11 * right.data.s._21 +left.data.s._12 * right.data.s._22 +left.data.s._13 * right.data.s._23; + c =left.data.s._11 * right.data.s._31 +left.data.s._12 * right.data.s._32 +left.data.s._13 * right.data.s._33; + + d =left.data.s._21 * right.data.s._11 +left.data.s._22 * right.data.s._12 +left.data.s._23 * right.data.s._13; + e =left.data.s._21 * right.data.s._21 +left.data.s._22 * right.data.s._22 +left.data.s._23 * right.data.s._23; + f =left.data.s._21 * right.data.s._31 +left.data.s._22 * right.data.s._32 +left.data.s._23 * right.data.s._33; + + g =left.data.s._31 * right.data.s._11 +left.data.s._32 * right.data.s._12 +left.data.s._33 * right.data.s._13; + h =left.data.s._31 * right.data.s._21 +left.data.s._32 * right.data.s._22 +left.data.s._33 * right.data.s._23; + i =left.data.s._31 * right.data.s._31 +left.data.s._32 * right.data.s._32 +left.data.s._33 * right.data.s._33; + + data.s._11 = a; + data.s._12 = b; + data.s._13 = c; + + data.s._21 = d; + data.s._22 = e; + data.s._23 = f; + + data.s._31 = g; + data.s._32 = h; + data.s._33 = i; + } + + +NX_INLINE void NxMat33::multiplyTransposeRight(const NxVec3 &left, const NxVec3 &right) + { + data.s._11 = left.x * right.x; + data.s._12 = left.x * right.y; + data.s._13 = left.x * right.z; + + data.s._21 = left.y * right.x; + data.s._22 = left.y * right.y; + data.s._23 = left.y * right.z; + + data.s._31 = left.z * right.x; + data.s._32 = left.z * right.y; + data.s._33 = left.z * right.z; + } + +NX_INLINE void NxMat33::rotX(NxReal angle) + { + NxReal Cos = cosf(angle); + NxReal Sin = sinf(angle); + id(); + data.m[1][1] = data.m[2][2] = Cos; + data.m[1][2] = -Sin; + data.m[2][1] = Sin; + } + +NX_INLINE void NxMat33::rotY(NxReal angle) + { + NxReal Cos = cosf(angle); + NxReal Sin = sinf(angle); + id(); + data.m[0][0] = data.m[2][2] = Cos; + data.m[0][2] = Sin; + data.m[2][0] = -Sin; + } + +NX_INLINE void NxMat33::rotZ(NxReal angle) + { + NxReal Cos = cosf(angle); + NxReal Sin = sinf(angle); + id(); + data.m[0][0] = data.m[1][1] = Cos; + data.m[0][1] = -Sin; + data.m[1][0] = Sin; + } + +NX_INLINE NxVec3 NxMat33::operator%(const NxVec3 & src) const + { + NxVec3 dest; + this->multiplyByTranspose(src, dest); + return dest; + } + + +NX_INLINE NxVec3 NxMat33::operator*(const NxVec3 & src) const + { + NxVec3 dest; + this->multiply(src, dest); + return dest; + } + + +NX_INLINE const NxMat33 &NxMat33::operator +=(const NxMat33 &d) + { + data.s._11 += d.data.s._11; + data.s._12 += d.data.s._12; + data.s._13 += d.data.s._13; + + data.s._21 += d.data.s._21; + data.s._22 += d.data.s._22; + data.s._23 += d.data.s._23; + + data.s._31 += d.data.s._31; + data.s._32 += d.data.s._32; + data.s._33 += d.data.s._33; + return *this; + } + + +NX_INLINE const NxMat33 &NxMat33::operator -=(const NxMat33 &d) + { + data.s._11 -= d.data.s._11; + data.s._12 -= d.data.s._12; + data.s._13 -= d.data.s._13; + + data.s._21 -= d.data.s._21; + data.s._22 -= d.data.s._22; + data.s._23 -= d.data.s._23; + + data.s._31 -= d.data.s._31; + data.s._32 -= d.data.s._32; + data.s._33 -= d.data.s._33; + return *this; + } + + +NX_INLINE const NxMat33 &NxMat33::operator *=(NxReal f) + { + data.s._11 *= f; + data.s._12 *= f; + data.s._13 *= f; + + data.s._21 *= f; + data.s._22 *= f; + data.s._23 *= f; + + data.s._31 *= f; + data.s._32 *= f; + data.s._33 *= f; + return *this; + } + + +NX_INLINE const NxMat33 &NxMat33::operator /=(NxReal x) + { + NxReal f = NxReal(1.0) / x; + data.s._11 *= f; + data.s._12 *= f; + data.s._13 *= f; + + data.s._21 *= f; + data.s._22 *= f; + data.s._23 *= f; + + data.s._31 *= f; + data.s._32 *= f; + data.s._33 *= f; + return *this; + } + + +NX_INLINE NxReal NxMat33::determinant() const + { + return data.s._11*data.s._22*data.s._33 + data.s._12*data.s._23*data.s._31 + data.s._13*data.s._21*data.s._32 + - data.s._13*data.s._22*data.s._31 - data.s._12*data.s._21*data.s._33 - data.s._11*data.s._23*data.s._32; + } + + +bool NxMat33::getInverse(NxMat33& dest) const + { + NxReal b00,b01,b02,b10,b11,b12,b20,b21,b22; + + b00 = data.s._22*data.s._33-data.s._23*data.s._32; b01 = data.s._13*data.s._32-data.s._12*data.s._33; b02 = data.s._12*data.s._23-data.s._13*data.s._22; + b10 = data.s._23*data.s._31-data.s._21*data.s._33; b11 = data.s._11*data.s._33-data.s._13*data.s._31; b12 = data.s._13*data.s._21-data.s._11*data.s._23; + b20 = data.s._21*data.s._32-data.s._22*data.s._31; b21 = data.s._12*data.s._31-data.s._11*data.s._32; b22 = data.s._11*data.s._22-data.s._12*data.s._21; + + + + /* + compute determinant: + NxReal d = a00*a11*a22 + a01*a12*a20 + a02*a10*a21 - a02*a11*a20 - a01*a10*a22 - a00*a12*a21; + 0 1 2 3 4 5 + + this is a subset of the multiplies done above: + + NxReal d = b00*a00 + b01*a10 + b02 * a20; + NxReal d = (a11*a22-a12*a21)*a00 + (a02*a21-a01*a22)*a10 + (a01*a12-a02*a11) * a20; + + NxReal d = a11*a22*a00-a12*a21*a00 + a02*a21*a10-a01*a22*a10 + a01*a12*a20-a02*a11*a20; + 0 5 2 4 1 3 + */ + + NxReal d = b00*data.s._11 + b01*data.s._21 + b02 * data.s._31; + + if (d == NxReal(0.0)) //singular? + { + dest.id(); + return false; + } + + d = NxReal(1.0)/d; + + //only do assignment at the end, in case dest == this: + + + dest.data.s._11 = b00*d; dest.data.s._12 = b01*d; dest.data.s._13 = b02*d; + dest.data.s._21 = b10*d; dest.data.s._22 = b11*d; dest.data.s._23 = b12*d; + dest.data.s._31 = b20*d; dest.data.s._32 = b21*d; dest.data.s._33 = b22*d; + + return true; + } + + +NX_INLINE NxMat33& NxMat33::operator*= (const NxMat33& mat) + { + this->multiply(*this, mat); + return *this; + } + + +NX_INLINE NxMat33 NxMat33::operator- (const NxMat33& mat) const + { + NxMat33 temp; + temp.subtract(*this, mat); + return temp; + } + + +NX_INLINE NxMat33 NxMat33::operator+ (const NxMat33& mat) const + { + NxMat33 temp; + temp.add(*this, mat); + return temp; + } + + +NX_INLINE NxMat33 NxMat33::operator* (const NxMat33& mat) const + { + NxMat33 temp; + temp.multiply(*this, mat); + return temp; + } + + +NX_INLINE NxMat33 NxMat33::operator* (float s) const + { + NxMat33 temp; + temp.multiply(s, *this); + return temp; + } + +NX_INLINE NxQuat::NxQuat(const class NxMat33 &m) +{ + m.toQuat(*this); +} + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMat34.h b/libraries/external/physx/Win32/include/PX/NxMat34.h new file mode 100755 index 0000000..eb6bfb0 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMat34.h @@ -0,0 +1,314 @@ +#ifndef NX_FOUNDATION_NxMat34T +#define NX_FOUNDATION_NxMat34T +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/NxMat33.h" + +/** +\brief Combination of a 3x3 rotation matrix and a translation vector. + +homogenous transform class composed of a matrix and a vector. +*/ + +class NxMat34 + { + public: + /** + \brief [ M t ] + */ + NxMat33 M; + NxVec3 t; + + /** + \brief by default M is inited and t isn't. Use this ctor to either init or not init in full. + */ + NX_INLINE explicit NxMat34(bool init = true); + + NX_INLINE NxMat34(const NxMat33& rot, const NxVec3& trans) : M(rot), t(trans) + { + } + + NX_INLINE void zero(); + + NX_INLINE void id(); + + /** + \brief returns true for identity matrix + */ + NX_INLINE bool isIdentity() const; + + /** + \brief returns true if all elems are finite (not NAN or INF, etc.) + */ + NX_INLINE bool isFinite() const; + + /** + \brief assigns inverse to dest. + + Returns false if singular (i.e. if no inverse exists), setting dest to identity. dest may equal this. + */ + NX_INLINE bool getInverse(NxMat34& dest) const; + + /** + \brief same as #getInverse(), but assumes that M is orthonormal + */ + NX_INLINE bool getInverseRT(NxMat34& dest) const; + + /** + \brief dst = this * src + */ + NX_INLINE void multiply(const NxVec3 &src, NxVec3 &dst) const; + + /** + \brief operator wrapper for multiply + */ + NX_INLINE NxVec3 operator* (const NxVec3 & src) const { NxVec3 dest; multiply(src, dest); return dest; } + /** + \brief dst = inverse(this) * src -- assumes M is rotation matrix!!! + */ + NX_INLINE void multiplyByInverseRT(const NxVec3 &src, NxVec3 &dst) const; + + /** + \brief operator wrapper for multiplyByInverseRT + */ + NX_INLINE NxVec3 operator% (const NxVec3 & src) const { NxVec3 dest; multiplyByInverseRT(src, dest); return dest; } + + /** + \brief this = left * right + */ + NX_INLINE void multiply(const NxMat34& left, const NxMat34& right); + + /** + \brief this = inverse(left) * right -- assumes M is rotation matrix!!! + */ + NX_INLINE void multiplyInverseRTLeft(const NxMat34& left, const NxMat34& right); + + /** + \brief this = left * inverse(right) -- assumes M is rotation matrix!!! + */ + NX_INLINE void multiplyInverseRTRight(const NxMat34& left, const NxMat34& right); + + /** + \brief operator wrapper for multiply + */ + NX_INLINE NxMat34 operator* (const NxMat34 & right) const { NxMat34 dest(false); dest.multiply(*this, right); return dest; } + + /** + \brief convert from a matrix format appropriate for rendering + */ + NX_INLINE void setColumnMajor44(const NxF32 *); + /** + \brief convert from a matrix format appropriate for rendering + */ + NX_INLINE void setColumnMajor44(const NxF32 d[4][4]); + /** + \brief convert to a matrix format appropriate for rendering + */ + NX_INLINE void getColumnMajor44(NxF32 *) const; + /** + \brief convert to a matrix format appropriate for rendering + */ + NX_INLINE void getColumnMajor44(NxF32 d[4][4]) const; + /** + \brief set the matrix given a row major matrix. + */ + NX_INLINE void setRowMajor44(const NxF32 *); + /** + \brief set the matrix given a row major matrix. + */ + NX_INLINE void setRowMajor44(const NxF32 d[4][4]); + /** + \brief retrieve the matrix in a row major format. + */ + NX_INLINE void getRowMajor44(NxF32 *) const; + /** + \brief retrieve the matrix in a row major format. + */ + NX_INLINE void getRowMajor44(NxF32 d[4][4]) const; + }; + + +NX_INLINE NxMat34::NxMat34(bool init) + { + if (init) + { + t.zero(); + M.id(); + } + } + + +NX_INLINE void NxMat34::zero() + { + M.zero(); + t.zero(); + } + + +NX_INLINE void NxMat34::id() + { + M.id(); + t.zero(); + } + + +NX_INLINE bool NxMat34::isIdentity() const + { + if(!M.isIdentity()) return false; + if(!t.isZero()) return false; + return true; + } + + +NX_INLINE bool NxMat34::isFinite() const + { + if(!M.isFinite()) return false; + if(!t.isFinite()) return false; + return true; + } + + +NX_INLINE bool NxMat34::getInverse(NxMat34& dest) const + { + // inv(this) = [ inv(M) , inv(M) * -t ] + bool status = M.getInverse(dest.M); + dest.M.multiply(t * -1.0f, dest.t); + return status; + } + + +NX_INLINE bool NxMat34::getInverseRT(NxMat34& dest) const + { + // inv(this) = [ M' , M' * -t ] + dest.M.setTransposed(M); + dest.M.multiply(t * -1.0f, dest.t); + return true; + } + + + +NX_INLINE void NxMat34::multiply(const NxVec3 &src, NxVec3 &dst) const + { + dst = M * src + t; + } + + +NX_INLINE void NxMat34::multiplyByInverseRT(const NxVec3 &src, NxVec3 &dst) const + { + //dst = M' * src - M' * t = M' * (src - t) + M.multiplyByTranspose(src - t, dst); + } + + +NX_INLINE void NxMat34::multiply(const NxMat34& left, const NxMat34& right) + { + //[aR at] * [bR bt] = [aR * bR aR * bt + at] NOTE: order of operations important so it works when this ?= left ?= right. + t = left.M * right.t + left.t; + M.multiply(left.M, right.M); + } + + +NX_INLINE void NxMat34::multiplyInverseRTLeft(const NxMat34& left, const NxMat34& right) + { + //[aR' -aR'*at] * [bR bt] = [aR' * bR aR' * bt - aR'*at] //aR' ( bt - at ) NOTE: order of operations important so it works when this ?= left ?= right. + t = left.M % (right.t - left.t); + M.multiplyTransposeLeft(left.M, right.M); + } + + +NX_INLINE void NxMat34::multiplyInverseRTRight(const NxMat34& left, const NxMat34& right) + { + //[aR at] * [bR' -bR'*bt] = [aR * bR' -aR * bR' * bt + at] NOTE: order of operations important so it works when this ?= left ?= right. + M.multiplyTransposeRight(left.M, right.M); + t = left.t - M * right.t; + } + +NX_INLINE void NxMat34::setColumnMajor44(const NxF32 * d) + { + M.setColumnMajorStride4(d); + t.x = d[12]; + t.y = d[13]; + t.z = d[14]; + } + +NX_INLINE void NxMat34::setColumnMajor44(const NxF32 d[4][4]) + { + M.setColumnMajorStride4(d); + t.x = d[3][0]; + t.y = d[3][1]; + t.z = d[3][2]; + } + +NX_INLINE void NxMat34::getColumnMajor44(NxF32 * d) const + { + M.getColumnMajorStride4(d); + d[12] = t.x; + d[13] = t.y; + d[14] = t.z; + d[3] = d[7] = d[11] = 0.0f; + d[15] = 1.0f; + } + +NX_INLINE void NxMat34::getColumnMajor44(NxF32 d[4][4]) const + { + M.getColumnMajorStride4(d); + d[3][0] = t.x; + d[3][1] = t.y; + d[3][2] = t.z; + d[0][3] = d[1][3] = d[2][3] = 0.0f; + d[3][3] = 1.0f; + } + +NX_INLINE void NxMat34::setRowMajor44(const NxF32 * d) + { + M.setRowMajorStride4(d); + t.x = d[3]; + t.y = d[7]; + t.z = d[11]; + } + +NX_INLINE void NxMat34::setRowMajor44(const NxF32 d[4][4]) + { + M.setRowMajorStride4(d); + t.x = d[0][3]; + t.y = d[1][3]; + t.z = d[2][3]; + } + +NX_INLINE void NxMat34::getRowMajor44(NxF32 * d) const + { + M.getRowMajorStride4(d); + d[3] = t.x; + d[7] = t.y; + d[11] = t.z; + d[12] = d[13] = d[14] = 0.0f; + d[15] = 1.0f; + } + +NX_INLINE void NxMat34::getRowMajor44(NxF32 d[4][4]) const + { + M.getRowMajorStride4(d); + d[0][3] = t.x; + d[1][3] = t.y; + d[2][3] = t.z; + d[3][0] = d[3][1] = d[3][2] = 0.0f; + d[3][3] = 1.0f; + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMaterial.h b/libraries/external/physx/Win32/include/PX/NxMaterial.h new file mode 100755 index 0000000..26db7fc --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMaterial.h @@ -0,0 +1,456 @@ +#ifndef NX_PHYSICS_NXMATERIAL +#define NX_PHYSICS_NXMATERIAL +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxMaterialDesc.h" + +class NxScene; + +/** +\brief Class for describing a shape's surface properties. + +

Creation

+ +Example material creation: +\include NxMaterial_Create.cpp + +You can create a material which has different friction coefficients depending on the direction that +a body in contact is trying to move in. This is called anisotropic friction. + +

Anisotropic Friction

+ +Anisotropic friction is useful for modeling things like sledges, skis etc + +When you create an anisotropic material you specify the default friction parameters and also friction parameters for the V axis. +The friction parameters for the V axis are applied to motion along the direction of anisotropy (dirOfAnisotropy). + +Anisotropic Material Example: +\include NxMaterial_Aniso.cpp + +

Default Material

+ +You can change the properties of the default material by querying for material index 0. + +Default Material Example: +\include NxMaterial_ChangeDefault.cpp + +

Visualizations:

+\li #NX_VISUALIZE_CONTACT_POINT +\li #NX_VISUALIZE_CONTACT_NORMAL +\li #NX_VISUALIZE_CONTACT_ERROR +\li #NX_VISUALIZE_CONTACT_FORCE + +@see NxMaterialDesc NxScene.createMaterial +*/ +class NxMaterial + { + protected: + NX_INLINE NxMaterial() : userData(NULL) {} + virtual ~NxMaterial() {} + + public: + /** + \brief The ID of the material can be retrieved using this function. + + Materials are associated with mesh faces and shapes using 16 bit identifiers of type NxMaterialIndex rather + than pointers. + + If you release a material while its material ID is still in use by shapes or meshes, the material usage + of these objects becomes undefined as the material index gets recycled. + + \return The material index for this material. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterialIndex NxTriangleMeshDesc.materialIndices NxShapeDesc.materialIndex NxShape.setMaterial() + */ + virtual NxMaterialIndex getMaterialIndex() = 0; + + /** + \brief Loads the entire state of the material from a descriptor with a single call. + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] desc The descriptor used to set this objects state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc NxMaterialDesc + */ + virtual void loadFromDesc(const NxMaterialDesc& desc) = 0; + + /** + \brief Saves the state of the material into a descriptor. + + \param[out] desc The descriptor used to retrieve this objects state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc NxMaterialDesc + */ + virtual void saveToDesc(NxMaterialDesc& desc) const = 0; + + /** + \brief retrieves owner scene + + \return The scene which this material belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + /** + \brief Sets the coefficient of dynamic friction. + + The coefficient of dynamic friction should be in [0, +inf]. If set to greater than staticFriction, the effective value of staticFriction will be increased to match. + If the flag NX_MF_ANISOTROPIC is set, then this value is used for the primary direction of anisotropy (U axis) + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] coef Coefficient of dynamic friction. Range: [0, +inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterialDesc.dynamicFriction getDynamicFriction() + */ + virtual void setDynamicFriction(NxReal coef) = 0; + + /** + \brief Retrieves the DynamicFriction value. + + \return The coefficient of dynamic friction. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDynamicFriction NxMaterialDesc.dynamicFriction + */ + virtual NxReal getDynamicFriction() const = 0; + + /** + \brief Sets the coefficient of static friction + + The coefficient of static friction should be in the range [0, +inf] + if flags & NX_MF_ANISOTROPIC is set, then this value is used for the primary direction of anisotropy (U axis) + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] coef Coefficient of static friction. Range: [0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getStaticFriction() NxMaterialDesc.staticFriction + */ + virtual void setStaticFriction(NxReal coef) = 0; + + /** + \brief Retrieves the coefficient of static friction. + \return The coefficient of static friction. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setStaticFriction NxMaterialDesc.staticFriction + */ + virtual NxReal getStaticFriction() const = 0; + + /** + \brief Sets the coefficient of restitution + + A coefficient of 0 makes the object bounce as little as possible, higher values up to 1.0 result in more bounce. + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] rest Coefficient of restitution. Range: [0,1] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getRestitution() NxMaterialDesc.restitution + */ + virtual void setRestitution(NxReal rest) = 0; + + /** + \brief Retrieves the coefficient of restitution. + + See #setRestitution. + + \return The coefficient of restitution. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setRestitution() NxMaterialDesc.restitution + */ + virtual NxReal getRestitution() const = 0; + + /** + \brief Sets the dynamic friction coefficient along the secondary (V) axis. + + This is used when anisotropic friction is being applied. I.e. the NX_MF_ANISOTROPIC flag is set. + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] coef Coefficient of dynamic friction in the V axis. Range: [0, +inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getDynamicFrictionV() NxMaterialDesc.dynamicFrictionV setFlags() + */ + virtual void setDynamicFrictionV(NxReal coef) = 0; + + /** + \brief Retrieves the dynamic friction coefficient for the V direction. + + See #setDynamicFrictionV. + + \return The coefficient if dynamic friction in the V direction. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDynamicFrictionV() NxMaterialDesc.dynamicFrictionV + */ + virtual NxReal getDynamicFrictionV() const = 0; + + /** + \brief Sets the static friction coefficient along the secondary (V) axis. + + This is used when anisotropic friction is being applied. I.e. the NX_MF_ANISOTROPIC flag is set. + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] coef Coefficient of static friction in the V axis. Range: [0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getStaticFrictionV() NxMaterialDesc.staticFrictionV setFlags() + */ + virtual void setStaticFrictionV(NxReal coef) = 0; + + /** + \brief Retrieves the static friction coefficient for the V direction. + + \return The coefficient of static friction in the V direction. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setStaticFrictionV() NxMaterialDesc.staticFrictionV + */ + virtual NxReal getStaticFrictionV() const = 0; + + /** + \brief Sets the shape space direction (unit vector) of anisotropy. + + This is used when anisotropic friction is being applied. I.e. the NX_MF_ANISOTROPIC flag is set. + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] vec Shape space direction of anisotropy. Range: direction vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getDirOfAnisotropy() NxMaterialDesc.dirOfAnisotropy setFlags() + */ + virtual void setDirOfAnisotropy(const NxVec3 &vec) = 0; + + /** + \brief Retrieves the direction of anisotropy value. + + \return The direction of anisotropy. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setDirOfAnisotropy() NxMaterialDesc.dirOfAnisotropy setFlags() + */ + virtual NxVec3 getDirOfAnisotropy() const = 0; + + /** + \brief Sets the flags, a combination of the bits defined by the enum ::NxMaterialFlag . + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] flags #NxMaterialFlag combination. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getFlags() NxMaterialFlag + */ + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief Retrieves the flags. See #NxMaterialFlag. + + \return The material flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterialFlag setFlags() + */ + virtual NxU32 getFlags() const = 0; + + /** + \brief Sets the friction combine mode. + + See the enum ::NxCombineMode . + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] combMode Friction combine mode to set for this material. See #NxCombineMode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCombineMode getFrictionCombineMode setStaticFriction() setDynamicFriction() + */ + virtual void setFrictionCombineMode(NxCombineMode combMode) = 0; + + /** + \brief Retrieves the friction combine mode. + + See #setFrictionCombineMode. + + \return The friction combine mode for this material. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCombineMode setFrictionCombineMode() + */ + virtual NxCombineMode getFrictionCombineMode() const = 0; + + /** + \brief Sets the restitution combine mode. + + See the enum ::NxCombineMode . + + Sleeping: Does NOT wake any actors which may be affected. + + \param[in] combMode Restitution combine mode for this material. See #NxCombineMode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCombineMode getRestitutionCombineMode() setRestitution() + */ + virtual void setRestitutionCombineMode(NxCombineMode combMode) = 0; + + /** + \brief Retrieves the restitution combine mode. + + See #setRestitutionCombineMode. + + \return The coefficient of restitution combine mode for this material. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCombineMode setRestitutionCombineMode getRestitution() + */ + virtual NxCombineMode getRestitutionCombineMode() const = 0; + + //public variables: + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + }; + + +//typedef NxMaterial * NxMaterialIndex; //legacy support (problematic because the size used to be 2 bytes) + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMaterialDesc.h b/libraries/external/physx/Win32/include/PX/NxMaterialDesc.h new file mode 100755 index 0000000..50b68ce --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMaterialDesc.h @@ -0,0 +1,377 @@ +#ifndef NX_PHYSICS_NXMATERIALDESC +#define NX_PHYSICS_NXMATERIALDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxSpringDesc.h" + +/** +\brief Flags which control the behavior of a material. + +@see NxMaterial NxMaterialDesc +*/ +enum NxMaterialFlag + { + /** + \brief Flag to enable anisotropic friction computation. + + For a pair of actors, anisotropic friction is used only if at least one of the two actors' materials are anisotropic. + The anisotropic friction parameters for the pair are taken from the material which is more anisotropic (i.e. the difference + between its two dynamic friction coefficients is greater). + + The anisotropy direction of the chosen material is transformed to world space: + + dirOfAnisotropyWS = shape2world * dirOfAnisotropy + + Next, the directions of anisotropy in one or more contact planes (i.e. orthogonal to the contact normal) have to be determined. + The two directions are: + + uAxis = (dirOfAnisotropyWS ^ contactNormal).normalize() + vAxis = contactNormal ^ uAxis + + This way [uAxis, contactNormal, vAxis] forms a basis. + + It may happen, however, that (dirOfAnisotropyWS | contactNormal).magnitude() == 1 + and then (dirOfAnisotropyWS ^ contactNormal) has zero length. This happens when + the contactNormal is coincident to the direction of anisotropy. In this case we perform isotropic friction. + + Platform: + \li PC SW: Yes + \li PPU : Yes (SW fall-back) + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterialDesc.dirOfAnisotropy + */ + NX_MF_ANISOTROPIC = 1 << 0, + + /** + If this flag is set, friction computations are always skipped between shapes with this material and any other shape. + It may be a good idea to use this when all friction is to be performed using the tire friction model (see ::NxWheelShape). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxWheelShape + */ + NX_MF_DISABLE_FRICTION = 1 << 4, + + /** + The difference between "normal" and "strong" friction is that the strong friction feature + remembers the "friction error" between simulation steps. The friction is a force trying to + hold objects in place (or slow them down) and this is handled in the solver. But since the + solver is only an approximation, the result of the friction calculation can include a small + "error" - e.g. a box resting on a slope should not move at all if the static friction is in + action, but could slowly glide down the slope because of a small friction error in each + simulation step. The strong friction counter-acts this by remembering the small error and + taking it to account during the next simulation step. + + However, in some cases the strong friction could cause problems, and this is why it is + possible to disable the strong friction feature by setting this flag. One example is + raycast vehicles, that are sliding fast across the surface, but still need a precise + steering behavior. It may be a good idea to reenable the strong friction when objects + are coming to a rest, to prevent them from slowly creeping down inclines. + + Note: This flag only has an effect if the NX_MF_DISABLE_FRICTION bit is 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxWheelShape + */ + NX_MF_DISABLE_STRONG_FRICTION = 1 << 5, + + //Note: Bits 16-31 are reserved for internal use! + }; + +/** +Flag that determines the combine mode. When two actors come in contact with each other, they each have +materials with various coefficients, but we only need a single set of coefficients for the pair. + +Physics doesn't have any inherent combinations because the coefficients are determined empirically on a case by case +basis. However, simulating this with a pairwise lookup table is often impractical. + +For this reason the following combine behaviors are available: + +NX_CM_AVERAGE +NX_CM_MIN +NX_CM_MULTIPLY +NX_CM_MAX + +The effective combine mode for the pair is max(material0.combineMode, material1.combineMode). + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxMaterial NxMaterialDesc NxMaterialDesc.frictionCombineMode NxMaterialDesc.restitutionCombineMode +*/ +enum NxCombineMode + { + NX_CM_AVERAGE = 0, //!< Average: (a + b)/2 + NX_CM_MIN = 1, //!< Minimum: min(a,b) + NX_CM_MULTIPLY = 2, //!< Multiply: a*b + NX_CM_MAX = 3, //!< Maximum: max(a,b) + NX_CM_N_VALUES = 4, //!< This is not a valid combine mode, it is a sentinel to denote the number of possible values. We assert that the variable's value is smaller than this. + NX_CM_PAD_32 = 0xffffffff //!< This is not a valid combine mode, it is to assure that the size of the enum type is big enough. + }; + + +/** +\brief Descriptor of #NxMaterial. + +@see NxMaterial NxScene.createMaterial() +*/ +class NxMaterialDesc + { + public: + /** + coefficient of dynamic friction -- should be in [0, +inf]. If set to greater than staticFriction, the effective value of staticFriction will be increased to match. + if flags & NX_MF_ANISOTROPIC is set, then this value is used for the primary direction of anisotropy (U axis) + + Range: [0,inf]
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags frictionCombineMode + */ + NxReal dynamicFriction; + + /** + coefficient of static friction -- should be in [0, +inf] + if flags & NX_MF_ANISOTROPIC is set, then this value is used for the primary direction of anisotropy (U axis) + + Range: [0,inf]
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags frictionCombineMode + */ + NxReal staticFriction; + + /** + coefficient of restitution -- 0 makes the object bounce as little as possible, higher values up to 1.0 result in more bounce. + Note that values close to or above 1 may cause stability problems and/or increasing energy. + Range: [0,1]
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags restitutionCombineMode + */ + NxReal restitution; + + /** + anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy. + This is only used if flags & NX_MF_ANISOTROPIC is set. + + Range: [0,inf]
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags dynamicFriction + */ + NxReal dynamicFrictionV; + + /** + anisotropic static friction coefficient for along the secondary (V) axis of anisotropy. + This is only used if flags & NX_MF_ANISOTROPIC is set. + + Range: [0,inf]
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags staticFriction + */ + NxReal staticFrictionV; + + /** + shape space direction (unit vector) of anisotropy. + This is only used if flags & NX_MF_ANISOTROPIC is set. + + Range: direction vector
+ Default: 1.0f,0.0f,0.0f + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flags staticFrictionV dynamicFrictionV + */ + NxVec3 dirOfAnisotropy; + + /** + Flags, a combination of the bits defined by the enum ::NxMaterialFlag . + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterialFlag + */ + NxU32 flags; + + /** + Friction combine mode. See the enum ::NxCombineMode . + + Default: NX_CM_AVERAGE + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCombineMode staticFriction dynamicFriction + */ + NxCombineMode frictionCombineMode; + + /** + Restitution combine mode. See the enum ::NxCombineMode . + + Default: NX_CM_AVERAGE + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCombineMode restitution + */ + NxCombineMode restitutionCombineMode; + + /** + Not used. + */ + NxSpringDesc * spring; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxMaterialDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxMaterialDesc::NxMaterialDesc() + { + setToDefault(); + } + +NX_INLINE void NxMaterialDesc::setToDefault() + { + dynamicFriction = 0.0f; + staticFriction = 0.0f; + restitution = 0.0f; + + + dynamicFrictionV= 0.0f; + staticFrictionV = 0.0f; + + dirOfAnisotropy.set(1,0,0); + flags = 0; + frictionCombineMode = NX_CM_AVERAGE; + restitutionCombineMode = NX_CM_AVERAGE; + spring = 0; + } + +NX_INLINE bool NxMaterialDesc::isValid() const + { + if(dynamicFriction < 0.0f) + return false; + if(staticFriction < 0.0f) + return false; + if(restitution < 0.0f || restitution > 1.0f) + return false; + + + if (flags & NX_MF_ANISOTROPIC) + { + NxReal ad = dirOfAnisotropy.magnitudeSquared(); + if (ad < 0.98f || ad > 1.03f) + return false; + if(dynamicFrictionV < 0.0f) + return false; + if(staticFrictionV < 0.0f) + return false; + } + /* + if (flags & NX_MF_MOVING_SURFACE) + { + NxReal md = dirOfMotion.magnitudeSquared(); + if (md < 0.98f || md > 1.03f) + return false; + } + */ + if (frictionCombineMode >= NX_CM_N_VALUES) + return false; + if (restitutionCombineMode >= NX_CM_N_VALUES) + return false; + + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMath.h b/libraries/external/physx/Win32/include/PX/NxMath.h new file mode 100755 index 0000000..14a5469 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMath.h @@ -0,0 +1,969 @@ +#ifndef NX_FOUNDATION_NXMATH +#define NX_FOUNDATION_NXMATH +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include +#include +#include //for rand() + +#ifdef _XBOX +#include //for fpmin,fpmax, sqrt etc +#endif + +#include "PX/Nx.h" + +#ifdef log2 +#undef log2 +#endif + +//constants +static const NxF64 NxPiF64 = 3.141592653589793; +static const NxF64 NxHalfPiF64 = 1.57079632679489661923; +static const NxF64 NxTwoPiF64 = 6.28318530717958647692; +static const NxF64 NxInvPiF64 = 0.31830988618379067154; +//we can get bad range checks if we use double prec consts to check single prec results. +static const NxF32 NxPiF32 = 3.141592653589793f; +static const NxF32 NxHalfPiF32 = 1.57079632679489661923f; +static const NxF32 NxTwoPiF32 = 6.28318530717958647692f; +static const NxF32 NxInvPiF32 = 0.31830988618379067154f; + + +#if defined(min) || defined(max) +#error Error: min or max is #defined, probably in . Put #define NOMINMAX before including windows.h to suppress windows global min,max macros. +#endif + +/** +\brief Static class with stateless scalar math routines. +*/ +class NxMath + { + public: + +// Type conversion and rounding + /** + \brief Returns true if the two numbers are within eps of each other. + */ + NX_INLINE static bool equals(NxF32,NxF32,NxF32 eps); + + /** + \brief Returns true if the two numbers are within eps of each other. + */ + NX_INLINE static bool equals(NxF64,NxF64,NxF64 eps); + /** + \brief The floor function returns a floating-point value representing the largest integer that is less than or equal to x. + */ + NX_INLINE static NxF32 floor(NxF32); + /** + \brief The floor function returns a floating-point value representing the largest integer that is less than or equal to x. + */ + NX_INLINE static NxF64 floor(NxF64); + + + /** + \brief The ceil function returns a single value representing the smallest integer that is greater than or equal to x. + */ + NX_INLINE static NxF32 ceil(NxF32); + /** + \brief The ceil function returns a double value representing the smallest integer that is greater than or equal to x. + */ + NX_INLINE static NxF64 ceil(NxF64); + + /** + \brief Truncates the float to an integer. + */ + NX_INLINE static NxI32 trunc(NxF32); + /** + \brief Truncates the double precision float to an integer. + */ + NX_INLINE static NxI32 trunc(NxF64); + + + /** + \brief abs returns the absolute value of its argument. + */ + NX_INLINE static NxF32 abs(NxF32); + /** + \brief abs returns the absolute value of its argument. + */ + NX_INLINE static NxF64 abs(NxF64); + /** + \brief abs returns the absolute value of its argument. + */ + NX_INLINE static NxI32 abs(NxI32); + + + /** + \brief sign returns the sign of its argument. The sign of zero is undefined. + */ + NX_INLINE static NxF32 sign(NxF32); + /** + \brief sign returns the sign of its argument. The sign of zero is undefined. + */ + NX_INLINE static NxF64 sign(NxF64); + /** + \brief sign returns the sign of its argument. The sign of zero is undefined. + */ + NX_INLINE static NxI32 sign(NxI32); + + + /** + \brief The return value is the greater of the two specified values. + */ + NX_INLINE static NxF32 max(NxF32,NxF32); + /** + \brief The return value is the greater of the two specified values. + */ + NX_INLINE static NxF64 max(NxF64,NxF64); + /** + \brief The return value is the greater of the two specified values. + */ + NX_INLINE static NxI32 max(NxI32,NxI32); + /** + \brief The return value is the greater of the two specified values. + */ + NX_INLINE static NxU32 max(NxU32,NxU32); + /** + \brief The return value is the greater of the two specified values. + */ + NX_INLINE static NxU16 max(NxU16,NxU16); + + + /** + \brief The return value is the lesser of the two specified values. + */ + NX_INLINE static NxF32 min(NxF32,NxF32); + /** + \brief The return value is the lesser of the two specified values. + */ + NX_INLINE static NxF64 min(NxF64,NxF64); + /** + \brief The return value is the lesser of the two specified values. + */ + NX_INLINE static NxI32 min(NxI32,NxI32); + /** + \brief The return value is the lesser of the two specified values. + */ + NX_INLINE static NxU32 min(NxU32,NxU32); + /** + \brief The return value is the lesser of the two specified values. + */ + NX_INLINE static NxU16 min(NxU16,NxU16); + + /** + \brief mod returns the floating-point remainder of x / y. + + If the value of y is 0.0, mod returns a quiet NaN. + */ + NX_INLINE static NxF32 mod(NxF32 x, NxF32 y); + /** + \brief mod returns the floating-point remainder of x / y. + + If the value of y is 0.0, mod returns a quiet NaN. + */ + NX_INLINE static NxF64 mod(NxF64 x, NxF64 y); + + /** + \brief Clamps v to the range [hi,lo] + */ + NX_INLINE static NxF32 clamp(NxF32 v, NxF32 hi, NxF32 low); + /** + \brief Clamps v to the range [hi,lo] + */ + NX_INLINE static NxF64 clamp(NxF64 v, NxF64 hi, NxF64 low); + /** + \brief Clamps v to the range [hi,lo] + */ + NX_INLINE static NxU32 clamp(NxU32 v, NxU32 hi, NxU32 low); + /** + \brief Clamps v to the range [hi,lo] + */ + NX_INLINE static NxI32 clamp(NxI32 v, NxI32 hi, NxI32 low); + + //!powers + /** + \brief Square root. + */ + NX_INLINE static NxF32 sqrt(NxF32); + /** + \brief Square root. + */ + NX_INLINE static NxF64 sqrt(NxF64); + + /** + \brief reciprocal square root. + */ + NX_INLINE static NxF32 recipSqrt(NxF32); + /** + \brief reciprocal square root. + */ + NX_INLINE static NxF64 recipSqrt(NxF64); + + /** + \brief Calculates x raised to the power of y. + */ + NX_INLINE static NxF32 pow(NxF32 x, NxF32 y); + /** + \brief Calculates x raised to the power of y. + */ + NX_INLINE static NxF64 pow(NxF64 x, NxF64 y); + + + /** + \brief Calculates e^n + */ + NX_INLINE static NxF32 exp(NxF32); + /** + \brief Calculates e^n + */ + NX_INLINE static NxF64 exp(NxF64); + + /** + \brief Calculates logarithms. + */ + NX_INLINE static NxF32 logE(NxF32); + /** + \brief Calculates logarithms. + */ + NX_INLINE static NxF64 logE(NxF64); + /** + \brief Calculates logarithms. + */ + NX_INLINE static NxF32 log2(NxF32); + /** + \brief Calculates logarithms. + */ + NX_INLINE static NxF64 log2(NxF64); + /** + \brief Calculates logarithms. + */ + NX_INLINE static NxF32 log10(NxF32); + /** + \brief Calculates logarithms. + */ + NX_INLINE static NxF64 log10(NxF64); + + //!trigonometry -- all angles are in radians. + + /** + \brief Converts degrees to radians. + */ + NX_INLINE static NxF32 degToRad(NxF32); + /** + \brief Converts degrees to radians. + */ + NX_INLINE static NxF64 degToRad(NxF64); + + /** + \brief Converts radians to degrees. + */ + NX_INLINE static NxF32 radToDeg(NxF32); + /** + \brief Converts radians to degrees. + */ + NX_INLINE static NxF64 radToDeg(NxF64); + + /** + \brief Sine of an angle. + + Unit: Radians + */ + NX_INLINE static NxF32 sin(NxF32); + /** + \brief Sine of an angle. + + Unit: Radians + */ + NX_INLINE static NxF64 sin(NxF64); + + /** + \brief Cosine of an angle. + + Unit: Radians + */ + NX_INLINE static NxF32 cos(NxF32); + /** + \brief Cosine of an angle. + + Unit: Radians + */ + NX_INLINE static NxF64 cos(NxF64); + + /** + \brief Computes both the sin and cos. + + Unit: Radians + */ + NX_INLINE static void sinCos(NxF32, NxF32 & sin, NxF32 & cos); + + /** + \brief Computes both the sin and cos. + + Unit: Radians + */ + NX_INLINE static void sinCos(NxF64, NxF64 & sin, NxF64 & cos); + + + /** + \brief Tangent of an angle. + + Unit: Radians + */ + NX_INLINE static NxF32 tan(NxF32); + /** + \brief Tangent of an angle. + + Unit: Radians + */ + NX_INLINE static NxF64 tan(NxF64); + + /** + \brief Arcsine. + + Returns angle between -PI/2 and PI/2 in radians + + Unit: Radians + */ + NX_INLINE static NxF32 asin(NxF32); + /** + \brief Arcsine. + + Returns angle between -PI/2 and PI/2 in radians + + Unit: Radians + */ + NX_INLINE static NxF64 asin(NxF64); + + /** + \brief Arccosine. + + Returns angle between 0 and PI in radians + + Unit: Radians + */ + NX_INLINE static NxF32 acos(NxF32); + + /** + \brief Arccosine. + + Returns angle between 0 and PI in radians + + Unit: Radians + */ + NX_INLINE static NxF64 acos(NxF64); + + /** + \brief ArcTangent. + + Returns angle between -PI/2 and PI/2 in radians + + Unit: Radians + */ + NX_INLINE static NxF32 atan(NxF32); + /** + \brief ArcTangent. + + Returns angle between -PI/2 and PI/2 in radians + + Unit: Radians + */ + NX_INLINE static NxF64 atan(NxF64); + + /** + \brief Arctangent of (x/y) with correct sign. + + Returns angle between -PI and PI in radians + + Unit: Radians + */ + NX_INLINE static NxF32 atan2(NxF32 x, NxF32 y); + /** + \brief Arctangent of (x/y) with correct sign. + + Returns angle between -PI and PI in radians + + Unit: Radians + */ + NX_INLINE static NxF64 atan2(NxF64 x, NxF64 y); + + //random numbers + + /** + \brief uniform random number in [a,b] + */ + NX_INLINE static NxF32 rand(NxF32 a,NxF32 b); + + /** + \brief uniform random number in [a,b] + */ + NX_INLINE static NxI32 rand(NxI32 a,NxI32 b); + + /** + \brief hashing: hashes an array of n 32 bit values to a 32 bit value. + + Because the output bits are uniformly distributed, the caller may mask + off some of the bits to index into a hash table smaller than 2^32. + */ + NX_INLINE static NxU32 hash(const NxU32 * array, NxU32 n); + + /** + \brief hash32 + */ + NX_INLINE static int hash32(int); + + /** + \brief returns true if the passed number is a finite floating point number as opposed to INF, NAN, etc. + */ + NX_INLINE static bool isFinite(NxF32 x); + + /** + \brief returns true if the passed number is a finite floating point number as opposed to INF, NAN, etc. + */ + NX_INLINE static bool isFinite(NxF64 x); + }; + +/* +Many of these are just implemented as NX_INLINE calls to the C lib right now, +but later we could replace some of them with some approximations or more +clever stuff. +*/ +NX_INLINE bool NxMath::equals(NxF32 a,NxF32 b,NxF32 eps) + { + const NxF32 diff = NxMath::abs(a - b); + return (diff < eps); + } + +NX_INLINE bool NxMath::equals(NxF64 a,NxF64 b,NxF64 eps) + { + const NxF64 diff = NxMath::abs(a - b); + return (diff < eps); + } + +NX_INLINE NxF32 NxMath::floor(NxF32 a) + { + return ::floorf(a); + } + +NX_INLINE NxF64 NxMath::floor(NxF64 a) + { + return ::floor(a); + } + +NX_INLINE NxF32 NxMath::ceil(NxF32 a) + { + return ::ceilf(a); + } + +NX_INLINE NxF64 NxMath::ceil(NxF64 a) + { + return ::ceil(a); + } + +NX_INLINE NxI32 NxMath::trunc(NxF32 a) + { + return (NxI32) a; // ### PT: this actually depends on FPU settings + } + +NX_INLINE NxI32 NxMath::trunc(NxF64 a) + { + return (NxI32) a; // ### PT: this actually depends on FPU settings + } + +NX_INLINE NxF32 NxMath::abs(NxF32 a) + { + return ::fabsf(a); + } + +NX_INLINE NxF64 NxMath::abs(NxF64 a) + { + return ::fabs(a); + } + +NX_INLINE NxI32 NxMath::abs(NxI32 a) + { + return ::abs(a); + } + +NX_INLINE NxF32 NxMath::sign(NxF32 a) + { + return (a >= 0.0f) ? 1.0f : -1.0f; + } + +NX_INLINE NxF64 NxMath::sign(NxF64 a) + { + return (a >= 0.0) ? 1.0 : -1.0; + } + +NX_INLINE NxI32 NxMath::sign(NxI32 a) + { + return (a >= 0) ? 1 : -1; + } + +NX_INLINE NxF32 NxMath::max(NxF32 a,NxF32 b) + { +#ifdef _XBOX + return (NxF32)fpmax(a, b); +#else + return (a < b) ? b : a; +#endif + } + +NX_INLINE NxF64 NxMath::max(NxF64 a,NxF64 b) + { +#ifdef _XBOX + return (NxF64)fpmax(a, b); +#else + return (a < b) ? b : a; +#endif + } + +NX_INLINE NxI32 NxMath::max(NxI32 a,NxI32 b) + { + return (a < b) ? b : a; + } + +NX_INLINE NxU32 NxMath::max(NxU32 a,NxU32 b) + { + return (a < b) ? b : a; + } + +NX_INLINE NxU16 NxMath::max(NxU16 a,NxU16 b) + { + return (a < b) ? b : a; + } + +NX_INLINE NxF32 NxMath::min(NxF32 a,NxF32 b) + { +#ifdef _XBOX + return (NxF32)fpmin(a, b); +#else + return (a < b) ? a : b; +#endif + } + +NX_INLINE NxF64 NxMath::min(NxF64 a,NxF64 b) + { +#ifdef _XBOX + return (NxF64)fpmin(a, b); +#else + return (a < b) ? a : b; +#endif + } + +NX_INLINE NxI32 NxMath::min(NxI32 a,NxI32 b) + { + return (a < b) ? a : b; + } + +NX_INLINE NxU32 NxMath::min(NxU32 a,NxU32 b) + { + return (a < b) ? a : b; + } + +NX_INLINE NxU16 NxMath::min(NxU16 a,NxU16 b) + { + return (a < b) ? a : b; + } + +NX_INLINE NxF32 NxMath::mod(NxF32 x, NxF32 y) + { + return (NxF32)::fmod(x,y); + } + +NX_INLINE NxF64 NxMath::mod(NxF64 x, NxF64 y) + { + return ::fmod(x,y); + } + +NX_INLINE NxF32 NxMath::clamp(NxF32 v, NxF32 hi, NxF32 low) + { + if (v > hi) + return hi; + else if (v < low) + return low; + else + return v; + } + +NX_INLINE NxF64 NxMath::clamp(NxF64 v, NxF64 hi, NxF64 low) + { + if (v > hi) + return hi; + else if (v < low) + return low; + else + return v; + } + +NX_INLINE NxU32 NxMath::clamp(NxU32 v, NxU32 hi, NxU32 low) + { + if (v > hi) + return hi; + else if (v < low) + return low; + else + return v; + } + +NX_INLINE NxI32 NxMath::clamp(NxI32 v, NxI32 hi, NxI32 low) + { + if (v > hi) + return hi; + else if (v < low) + return low; + else + return v; + } + +NX_INLINE NxF32 NxMath::sqrt(NxF32 a) + { + return ::sqrtf(a); + } + +NX_INLINE NxF64 NxMath::sqrt(NxF64 a) + { + return ::sqrt(a); + } + +NX_INLINE NxF32 NxMath::recipSqrt(NxF32 a) + { + return 1.0f/::sqrtf(a); + } + +NX_INLINE NxF64 NxMath::recipSqrt(NxF64 a) + { + return 1.0/::sqrt(a); + } + +NX_INLINE NxF32 NxMath::pow(NxF32 x, NxF32 y) + { + return ::powf(x,y); + } + +NX_INLINE NxF64 NxMath::pow(NxF64 x, NxF64 y) + { + return ::pow(x,y); + } + +NX_INLINE NxF32 NxMath::exp(NxF32 a) + { + return ::expf(a); + } + +NX_INLINE NxF64 NxMath::exp(NxF64 a) + { + return ::exp(a); + } + +NX_INLINE NxF32 NxMath::logE(NxF32 a) + { + return ::logf(a); + } + +NX_INLINE NxF64 NxMath::logE(NxF64 a) + { + return ::log(a); + } + +NX_INLINE NxF32 NxMath::log2(NxF32 a) + { + const NxF32 ln2 = (NxF32)0.693147180559945309417; + return ::logf(a) / ln2; + } + +NX_INLINE NxF64 NxMath::log2(NxF64 a) + { + const NxF64 ln2 = (NxF64)0.693147180559945309417; + return ::log(a) / ln2; + } + +NX_INLINE NxF32 NxMath::log10(NxF32 a) + { + return (NxF32)::log10(a); + } + +NX_INLINE NxF64 NxMath::log10(NxF64 a) + { + return ::log10(a); + } + +NX_INLINE NxF32 NxMath::degToRad(NxF32 a) + { + return (NxF32)0.01745329251994329547 * a; + } + +NX_INLINE NxF64 NxMath::degToRad(NxF64 a) + { + return (NxF64)0.01745329251994329547 * a; + } + +NX_INLINE NxF32 NxMath::radToDeg(NxF32 a) + { + return (NxF32)57.29577951308232286465 * a; + } + +NX_INLINE NxF64 NxMath::radToDeg(NxF64 a) + { + return (NxF64)57.29577951308232286465 * a; + } + +NX_INLINE NxF32 NxMath::sin(NxF32 a) + { + return ::sinf(a); + } + +NX_INLINE NxF64 NxMath::sin(NxF64 a) + { + return ::sin(a); + } + +NX_INLINE NxF32 NxMath::cos(NxF32 a) + { + return ::cosf(a); + } + +NX_INLINE NxF64 NxMath::cos(NxF64 a) + { + return ::cos(a); + } + +// Calling fsincos instead of fsin+fcos +NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c) + { +#ifdef WIN32 + NxF32 localCos, localSin; + NxF32 local = f; + _asm fld local + _asm fsincos + _asm fstp localCos + _asm fstp localSin + c = localCos; + s = localSin; +#else + c = cosf(f); + s = sinf(f); +#endif + } + +NX_INLINE void NxMath::sinCos(NxF64 a, NxF64 & s, NxF64 & c) + { + s = ::sin(a); + c = ::cos(a); + } + +NX_INLINE NxF32 NxMath::tan(NxF32 a) + { + return ::tanf(a); + } + +NX_INLINE NxF64 NxMath::tan(NxF64 a) + { + return ::tan(a); + } + +NX_INLINE NxF32 NxMath::asin(NxF32 f) + { + // Take care of FPU inaccuracies + if(f>=1.0f) return (NxF32)NxHalfPiF32; + if(f<=-1.0f)return -(NxF32)NxHalfPiF32; + return ::asinf(f); + } + +NX_INLINE NxF64 NxMath::asin(NxF64 f) + { + // Take care of FPU inaccuracies + if(f>=1.0) return (NxF32)NxHalfPiF64; + if(f<=-1.0) return -(NxF32)NxHalfPiF64; + return ::asin(f); + } + +NX_INLINE NxF32 NxMath::acos(NxF32 f) + { + // Take care of FPU inaccuracies + if(f>=1.0f) return 0.0f; + if(f<=-1.0f)return (NxF32)NxPiF32; + return ::acosf(f); + } + +NX_INLINE NxF64 NxMath::acos(NxF64 f) + { + // Take care of FPU inaccuracies + if(f>=1.0) return 0.0; + if(f<=-1.0) return (NxF64)NxPiF64; + return ::acos(f); + } + +NX_INLINE NxF32 NxMath::atan(NxF32 a) + { + return ::atanf(a); + } + +NX_INLINE NxF64 NxMath::atan(NxF64 a) + { + return ::atan(a); + } + +NX_INLINE NxF32 NxMath::atan2(NxF32 x, NxF32 y) + { + return ::atan2f(x,y); + } + +NX_INLINE NxF64 NxMath::atan2(NxF64 x, NxF64 y) + { + return ::atan2(x,y); + } + +NX_INLINE NxF32 NxMath::rand(NxF32 a,NxF32 b) + { + const NxF32 r = (NxF32)::rand()/((NxF32)RAND_MAX+1); + return r*(b-a) + a; + } + +NX_INLINE NxI32 NxMath::rand(NxI32 a,NxI32 b) + { + return a + (NxI32)(::rand()%(b-a)); + } + +/* +-------------------------------------------------------------------- +lookup2.c, by Bob Jenkins, December 1996, Public Domain. +hash(), hash2(), hash3, and mix() are externally useful functions. +Routines to test the hash are included if SELF_TEST is defined. +You can use this free for any purpose. It has no warranty. +-------------------------------------------------------------------- +-------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. +For every delta with one or two bit set, and the deltas of all three + high bits or all three low bits, whether the original value of a,b,c + is almost all zero or is uniformly distributed, +* If mix() is run forward or backward, at least 32 bits in a,b,c + have at least 1/4 probability of changing. +* If mix() is run forward, every bit of c will change between 1/3 and + 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) +mix() was built out of 36 single-cycle latency instructions in a + structure that could supported 2x parallelism, like so: + a -= b; + a -= c; x = (c>>13); + b -= c; a ^= x; + b -= a; x = (a<<8); + c -= a; b ^= x; + c -= b; x = (b>>13); + ... + Unfortunately, superscalar Pentiums and Sparcs can't take advantage + of that parallelism. They've also turned some of those single-cycle + latency instructions into multi-cycle latency instructions. Still, + this is the fastest good hash I could find. There were about 2^^68 + to choose from. I only looked at a billion or so. +-------------------------------------------------------------------- +*/ +#define NX_HASH_MIX(a,b,c) \ +{ \ + a -= b; a -= c; a ^= (c>>13); \ + b -= c; b -= a; b ^= (a<<8); \ + c -= a; c -= b; c ^= (b>>13); \ + a -= b; a -= c; a ^= (c>>12); \ + b -= c; b -= a; b ^= (a<<16); \ + c -= a; c -= b; c ^= (b>>5); \ + a -= b; a -= c; a ^= (c>>3); \ + b -= c; b -= a; b ^= (a<<10); \ + c -= a; c -= b; c ^= (b>>15); \ +} + +/* +-------------------------------------------------------------------- + This works on all machines. hash2() is identical to hash() on + little-endian machines, except that the length has to be measured + in ub4s instead of bytes. It is much faster than hash(). It + requires + -- that the key be an array of ub4's, and + -- that all your machines have the same endianness, and + -- that the length be the number of ub4's in the key +-------------------------------------------------------------------- +*/ +NX_INLINE NxU32 NxMath::hash(const NxU32 *k, NxU32 length) +//register ub4 *k; /* the key */ +//register ub4 length; /* the length of the key, in ub4s */ + { + NxU32 a,b,c,len; + + /* Set up the internal state */ + len = length; + a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ + c = 0; /* the previous hash value */ + + /*---------------------------------------- handle most of the key */ + while (len >= 3) + { + a += k[0]; + b += k[1]; + c += k[2]; + NX_HASH_MIX(a,b,c); + k += 3; len -= 3; + } + + /*-------------------------------------- handle the last 2 ub4's */ + c += length; + switch(len) /* all the case statements fall through */ + { + /* c is reserved for the length */ + case 2 : b+=k[1]; + case 1 : a+=k[0]; + /* case 0: nothing left to add */ + } + NX_HASH_MIX(a,b,c); + /*-------------------------------------------- report the result */ + return c; + } +#undef NX_HASH_MIX + +NX_INLINE int NxMath::hash32(int key) + { + key += ~(key << 15); + key ^= (key >> 10); + key += (key << 3); + key ^= (key >> 6); + key += ~(key << 11); + key ^= (key >> 16); + return key; + } + + +NX_INLINE bool NxMath::isFinite(NxF32 f) + { + #if defined(_MSC_VER) + return (0 == ((_FPCLASS_SNAN | _FPCLASS_QNAN | _FPCLASS_NINF | _FPCLASS_PINF) & _fpclass(f) )); + #elif defined(__CELLOS_LV2__) + return (!(isnan(f)||isinf(f))); + #else + return true; + #endif + + } + +NX_INLINE bool NxMath::isFinite(NxF64 f) + { + #if defined(_MSC_VER) + return (0 == ((_FPCLASS_SNAN | _FPCLASS_QNAN | _FPCLASS_NINF | _FPCLASS_PINF) & _fpclass(f) )); + #elif defined(__CELLOS_LV2__) + return (!(isnan(f)||isinf(f))); + #else + return true; + #endif + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMeshData.h b/libraries/external/physx/Win32/include/PX/NxMeshData.h new file mode 100755 index 0000000..bcffc1c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMeshData.h @@ -0,0 +1,250 @@ +#ifndef NX_PHYSICS_NX_MESHDATA +#define NX_PHYSICS_NX_MESHDATA +/** \addtogroup cloth + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** +\brief Very similar to #NxMeshFlags used for the #NxSimpleTriangleMesh type. +*/ +enum NxMeshDataFlags + { + /** + \brief Denotes the use of 16-bit vertex indices. + */ + NX_MDF_16_BIT_INDICES = 1 << 0, + }; + +/** +\brief Enum with flag values to be used in NxMeshData::dirtyBufferFlagsPtr. +*/ +enum NxMeshDataDirtyBufferFlags + { + /** + \brief Denotes a change in the vertex position buffer. + */ + NX_MDF_VERTICES_POS_DIRTY = 1 << 0, + /** + \brief Denotes a change in the vertex normal buffer. + */ + NX_MDF_VERTICES_NORMAL_DIRTY = 1 << 1, + /** + \brief Denotes a change in the index buffer. + */ + NX_MDF_INDICES_DIRTY = 1 << 2, + /** + \brief Denotes a change in the parent index buffer. + */ + NX_MDF_PARENT_INDICES_DIRTY = 1 << 3, + }; + +/** +\brief Descriptor-like user-side class for describing mesh data. + +This data type is used for specifying how the SDK is supposed to pass generated mesh data. This is used +to pass simulated cloth meshes back to the user. + +This class is very similar to NxSimpleTriangleMesh, with the difference that this user buffer +wrapper is used to let the SDK write to user buffers instead of reading from them. +*/ +class NxMeshData + { + public: + + /** + \brief The pointer to the user specified buffer for vertex positions. + + A vertex position consists of three consecutive 32 bit floats. + If the pointer is not initialized (NULL), no data is returned. + */ + void* verticesPosBegin; + + /** + \brief The pointer to the user specified buffer for vertex normals. + + A vertex normal consists of three consecutive 32 bit floats. + If the pointer is not initialized (NULL), no data is returned. + */ + void* verticesNormalBegin; + + /** + \brief Specifies the distance of two vertex position start addresses in bytes. + */ + NxI32 verticesPosByteStride; + + /** + \brief Specifies the distance of two vertex normal start addresses in bytes. + */ + NxI32 verticesNormalByteStride; + + /** + \brief The maximal number of vertices which can be stored in the user vertex buffers. + */ + NxU32 maxVertices; + + /** + \brief Must point to the user allocated memory holding the number of vertices stored in the user vertex + buffers. + + If the SDK writes to a given vertex buffer, it also sets the numbers of elements written. + */ + NxU32* numVerticesPtr; + + /** + \brief The pointer to the user specified buffer for vertex indices. + + An index consist of one 32 or 16 bit integers, depending on whether NX_MDF_16_BIT_INDICES has been set. + + If the pointer is not initialized (NULL), no data is returned. + */ + void* indicesBegin; + + /** + \brief Specifies the distance of two vertex indices start addresses in bytes. + */ + NxI32 indicesByteStride; + + /** + \brief The maximal number of indices which can be stored in the user index buffer. + */ + NxU32 maxIndices; + + /** + \brief Must point to the user allocated memory holding the number of vertex triplets used to define + triangles. + + If the SDK writes to a given triangle index buffer, it also sets the number of + triangles written. + */ + NxU32* numIndicesPtr; + + /** + \brief The pointer to the user specified buffer for vertex parent indices. + + An index consist of one 32 or 16 bit integers, depending on whether NX_MDF_16_BIT_INDICES has been set. + + Parent indices are provided when vertices are duplicated by the SDK (e.g. cloth tearing). + The parent index of an original vertex is its position in the verticesPos buffer. The + parent index of a vertex generated by duplication is the index of the vertex it was copied from. + + If the pointer is not initialized (NULL), no data is returned. + */ + void* parentIndicesBegin; + + /** + \brief Specifies the distance of two vertex parent indices start addresses in bytes. + */ + NxI32 parentIndicesByteStride; + + /** + \brief The maximal number of parent indices which can be stored in the user parent index buffer. + */ + NxU32 maxParentIndices; + + /** + \brief Must point to the user allocated memory holding the number of vertex parent indices + + If the SDK writes to a given vertex parent index buffer, it also sets the number of + parent indices written. + */ + NxU32* numParentIndicesPtr; + + /** + \brief Must point to the user allocated memory holding the dirty buffer flags + + If the SDK changes the content of a given buffer, it also sets the corresponding flag of + type #NxMeshDataDirtyBufferFlags. This functionality is only supported in conjunction with + cloth yet. The returned value for other features is undefined. + */ + NxU32* dirtyBufferFlagsPtr; + + /** + \brief Flags of type #NxMeshDataFlags + */ + NxU32 flags; + + const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + NX_INLINE ~NxMeshData(); + + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxMeshData(); + }; + +NX_INLINE NxMeshData::NxMeshData() + { + setToDefault(); + } + +NX_INLINE NxMeshData::~NxMeshData() + { + } + +NX_INLINE void NxMeshData::setToDefault() + { + verticesPosBegin = NULL; + verticesNormalBegin = NULL; + verticesPosByteStride = 0; + verticesNormalByteStride = 0; + maxVertices = 0; + numVerticesPtr = NULL; + indicesBegin = NULL; + indicesByteStride = 0; + maxIndices = 0; + numIndicesPtr = NULL; + parentIndicesBegin = NULL; + parentIndicesByteStride = 0; + maxParentIndices = 0; + numParentIndicesPtr = NULL; + dirtyBufferFlagsPtr = NULL; + flags = 0; + name = NULL; + } + +NX_INLINE bool NxMeshData::isValid() const + { + if (numVerticesPtr && !(verticesPosBegin || verticesNormalBegin)) return false; + if (!numVerticesPtr && (verticesPosBegin || verticesNormalBegin)) return false; + + if (!numIndicesPtr && indicesBegin) return false; + if (numIndicesPtr && !indicesBegin) return false; + + if (!numParentIndicesPtr && parentIndicesBegin) return false; + if (numParentIndicesPtr && !parentIndicesBegin) return false; + + if (verticesPosBegin && !verticesPosByteStride) return false; + if (verticesNormalBegin && !verticesNormalByteStride) return false; + if (indicesBegin && !indicesByteStride) return false; + if (parentIndicesBegin && !parentIndicesByteStride) return false; + + return true; + } + +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxMotorDesc.h b/libraries/external/physx/Win32/include/PX/NxMotorDesc.h new file mode 100755 index 0000000..ee8005a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxMotorDesc.h @@ -0,0 +1,200 @@ +#ifndef NX_PHYSICS_NXMOTORDESC +#define NX_PHYSICS_NXMOTORDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxBitField.h" //just for NxJointDriveDesc's drive type, to be removed. +/** +\brief Describes a joint motor. + +Some joints can be motorized, this allows them to apply a force to cause attached actors to move. + +Joints which can be motorized: + +
    +
  • #NxPulleyJoint
  • +
  • #NxRevoluteJoint
  • +
+ +#NxJointDriveDesc is used for a similar purpose with #NxD6Joint. + + Example (for a revolute joint): + + \include NxRevoluteJoint_Motor.cpp + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxPulleyJoint NxRevoluteJoint +*/ +class NxMotorDesc + { + public: + /** + \brief The relative velocity the motor is trying to achieve. + + The motor will only be able to reach this velocity if the maxForce is sufficiently large. + If the joint is spinning faster than this velocity, the motor will actually try to brake(see #freeSpin). + + If you set this to infinity then the motor will keep speeding up, unless there is some sort + of resistance on the attached bodies. The sign of this variable determines the rotation direction, + with positive values going the same way as positive joint angles. + + Default is infinity. + + Range: [0,inf]
+ Default: NX_MAX_REAL + + @see freeSpin + */ + NxReal velTarget; //target velocity of motor + + /** + \brief The maximum force (or torque) the motor can exert. + + Zero disables the motor. + Default is 0, should be >= 0. Setting this to a very large value if velTarget is also + very large may cause unexpected results. + + Range: [0,inf)
+ Default: 0.0 + */ + NxReal maxForce; //maximum motor force/torque + + /** + \brief If true, motor will not brake when it spins faster than velTarget + + Default: false + */ + NX_BOOL freeSpin; + + /** + \brief Constructor, sets members to default values. + */ + NX_INLINE NxMotorDesc(); + + /** + \brief Constructor, sets members to specified values. + + \param[in] velTarget target velocity of motor. Range: [0,inf] + \param[in] maxForce maximum motor force/torque. Range: [0,inf) + \param[in] freeSpin If true, motor will not brake when it spins faster than velTarget. + */ + NX_INLINE NxMotorDesc(NxReal velTarget, NxReal maxForce = 0, NX_BOOL freeSpin = 0); + + /** + \brief Sets members to default values. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxMotorDesc::NxMotorDesc() + { + setToDefault(); + } + +NX_INLINE NxMotorDesc::NxMotorDesc(NxReal v, NxReal m, NX_BOOL f) + { + velTarget = v; + maxForce = m; + freeSpin = f; + } + +NX_INLINE void NxMotorDesc::setToDefault() + { + velTarget = NX_MAX_REAL; + maxForce = 0; + freeSpin = 0; + } + +NX_INLINE bool NxMotorDesc::isValid() const + { + return (maxForce >= 0); + } + +//TODO: the below class is very similar to the above and NxSpringDesc, so it should be merged... +/** + \brief Class used to describe drive properties for a #NxD6Joint + +

Default Values

+ + \li #driveType - 0 + \li #spring - 0 + \li #damping - 0 + \li #forceLimit - FLT_MAX + + Platform: + \li PC SW: Yes + \li PPU : Yes (Only D6 joint orientation) + \li PS3 : Yes + \li XB360: Yes +*/ +class NxJointDriveDesc + { + public: + /** + Type of drive to apply. See #NxD6JointDriveType. + + Default: 0 + */ + NxBitField32 driveType; + + /** + \brief spring coefficient + + Default: 0 + Range: (-inf,inf) + */ + NxReal spring; + + /** + \brief damper coefficient + + Default: 0 + Range: [0,inf) + */ + NxReal damping; + + /** + \brief The maximum force (or torque) the drive can exert. + + Default: NX_MAX_REAL + Range: [0,inf) + */ + NxReal forceLimit; + + NxJointDriveDesc() + { + spring = 0; + damping = 0; + forceLimit = FLT_MAX; + driveType = 0; + } + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPMap.h b/libraries/external/physx/Win32/include/PX/NxPMap.h new file mode 100755 index 0000000..ff0046e --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPMap.h @@ -0,0 +1,102 @@ +#ifndef NX_COLLISION_NXPMAP +#define NX_COLLISION_NXPMAP +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +/** +\brief PMap data structure for mesh collision detection. + +\warning Legacy class + +Used by the functions NxCreatePMap and NxReleasePMap. + +This structure can be assigned to NxTriangleMeshDesc::pmap or passed to NxTriangleMesh::loadPMap(). + +

Creation

+ +Example: + +\include NxPMap_Create.cpp + +Platform: +\li PC SW: Yes +\li PPU : Yes (Software fallback) +\li PS3 : Yes +\li XB360: Yes + +@see NxTriangleMesh.loadPMap() NxConvexShape.loadPMap() +*/ +class NxPMap + { + public: + NxU32 dataSize; //!< size of data buffer in bytes + void* data; //!< data buffer that stores the PMap information. + }; + +//#ifdef NX_COOKING + /** + \brief Creates a PMap from a triangle mesh. + + \warning Legacy function + + A PMap is an optional data structure which makes mesh-mesh collision + detection more robust at the cost of higher memory consumption. + + This structure can then be assigned to NxTriangleMeshDesc::pmap or passed to NxTriangleMesh::loadPMap(). + + You may wish to store the PMap on disk (just write the above data block to a file of your choice) after + computing it because the creation process can be quite expensive. Then you won't have to create it the next time + you need it. + + \param[out] pmap Used to store details of the created PMap. + \param[in] mesh Mesh to create PMap from. + \param[in] density The density(resolution) of the PMap. + \param[in] outputStream User supplied interface for reporting errors and displaying messages(see #NxUserOutputStream) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxPMap NxTriangleMesh.loadPMap() NxConvexShape.loadPMap() NxReleasePMap + */ + NX_C_EXPORT NXP_DLL_EXPORT bool NX_CALL_CONV NxCreatePMap(NxPMap& pmap, const NxTriangleMesh& mesh, NxU32 density, NxUserOutputStream* outputStream = NULL); + + /** + \brief Releases PMap previously created with NxCreatePMap. + + \warning Legacy function + + You should not call this on PMap data you have loaded from + disc yourself. Don't release a PMap while it is being used by a NxTriangleMesh object. + + \param[in] pmap Pmap to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxPMap NxTriangleMesh.loadPMap() NxConvexShape.loadPMap() NxCreatePMap + */ + NX_C_EXPORT NXP_DLL_EXPORT bool NX_CALL_CONV NxReleasePMap(NxPMap& pmap); +//#endif + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPhysics.h b/libraries/external/physx/Win32/include/PX/NxPhysics.h new file mode 100755 index 0000000..11a08e2 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPhysics.h @@ -0,0 +1,201 @@ +#ifndef NX_PHYSICS_NXPHYSICS +#define NX_PHYSICS_NXPHYSICS +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +/** +This is the main include header for the Physics SDK, for users who +want to use a single #include file. + +Alternatively, one can instead directly #include a subset of the below files. +*/ + +#include "PX/NxFoundation.h" //include the all of the foundation SDK + + +//////////////general: + +#include "PX/NxScene.h" +#include "PX/NxSceneDesc.h" + +#include "PX/NxCompartment.h" + +#include "PX/NxActor.h" +#include "PX/NxActorDesc.h" + +#include "PX/NxMaterial.h" +#include "PX/NxMaterialDesc.h" + +#include "PX/NxContactStreamIterator.h" + +#include "PX/NxUserContactReport.h" +#include "PX/NxUserNotify.h" +#include "PX/NxFluidUserNotify.h" +#include "PX/NxClothUserNotify.h" +#include "PX/NxSoftBodyUserNotify.h" +#include "PX/NxUserRaycastReport.h" +#include "PX/NxUserEntityReport.h" + +#include "PX/NxBodyDesc.h" + +#include "PX/NxEffector.h" +#include "PX/NxEffectorDesc.h" + +#include "PX/NxSpringAndDamperEffector.h" +#include "PX/NxSpringAndDamperEffectorDesc.h" + +#include "PX/NxForceField.h" +#include "PX/NxForceFieldDesc.h" +#include "PX/NxForceFieldShapeGroup.h" +#include "PX/NxForceFieldShapeGroupDesc.h" +#include "PX/NxForceFieldKernel.h" +#include "PX/NxForceFieldLinearKernel.h" +#include "PX/NxForceFieldLinearKernelDesc.h" + +#include "PX/NxForceFieldShape.h" +#include "PX/NxForceFieldShapeDesc.h" + +#include "PX/NxBoxForceFieldShape.h" +#include "PX/NxBoxForceFieldShapeDesc.h" +#include "PX/NxSphereForceFieldShape.h" +#include "PX/NxSphereForceFieldShapeDesc.h" +#include "PX/NxCapsuleForceFieldShape.h" +#include "PX/NxCapsuleForceFieldShapeDesc.h" +#include "PX/NxConvexForceFieldShape.h" +#include "PX/NxConvexForceFieldShapeDesc.h" + +#include "PX/NxScheduler.h" + +#if NX_USE_FLUID_API +#include "PX/fluids/NxFluid.h" +#include "PX/fluids/NxFluidDesc.h" +#include "PX/fluids/NxFluidEmitter.h" +#include "PX/fluids/NxFluidEmitterDesc.h" +#endif + +#if NX_USE_CLOTH_API +#include "PX/cloth/NxCloth.h" +#include "PX/cloth/NxClothDesc.h" +#endif + +#if NX_USE_SOFTBODY_API +#include "PX/softbody/NxSoftBody.h" +#include "PX/softbody/NxSoftBodyDesc.h" +#endif + +#include "PX/NxCCDSkeleton.h" +#include "PX/NxTriangle.h" +#include "PX/NxScheduler.h" +#include "PX/NxSceneStats.h" +#include "PX/NxSceneStats2.h" +/////////////joints: + +#include "PX/NxJoint.h" + +#include "PX/NxJointLimitDesc.h" +#include "PX/NxJointLimitPairDesc.h" +#include "PX/NxMotorDesc.h" +#include "PX/NxSpringDesc.h" + +#include "PX/NxPointInPlaneJoint.h" +#include "PX/NxPointInPlaneJointDesc.h" + +#include "PX/NxPointOnLineJoint.h" +#include "PX/NxPointOnLineJointDesc.h" + +#include "PX/NxRevoluteJoint.h" +#include "PX/NxRevoluteJointDesc.h" + +#include "PX/NxPrismaticJoint.h" +#include "PX/NxPrismaticJointDesc.h" + +#include "PX/NxCylindricalJoint.h" +#include "PX/NxCylindricalJointDesc.h" + +#include "PX/NxSphericalJoint.h" +#include "PX/NxSphericalJointDesc.h" + +#include "PX/NxFixedJoint.h" +#include "PX/NxFixedJointDesc.h" + +#include "PX/NxDistanceJoint.h" +#include "PX/NxDistanceJointDesc.h" + +#include "PX/NxPulleyJoint.h" +#include "PX/NxPulleyJointDesc.h" + +#include "PX/NxD6Joint.h" +#include "PX/NxD6JointDesc.h" + +//////////////shapes: + +#include "PX/NxShape.h" +#include "PX/NxShapeDesc.h" + +#include "PX/NxBoxShape.h" +#include "PX/NxBoxShapeDesc.h" + +#include "PX/NxCapsuleShape.h" +#include "PX/NxCapsuleShapeDesc.h" + +#include "PX/NxPlaneShape.h" +#include "PX/NxPlaneShapeDesc.h" + +#include "PX/NxSphereShape.h" +#include "PX/NxSphereShapeDesc.h" + +#include "PX/NxTriangleMesh.h" +#include "PX/NxTriangleMeshDesc.h" + +#include "PX/NxTriangleMeshShape.h" +#include "PX/NxTriangleMeshShapeDesc.h" + +#include "PX/NxConvexMesh.h" +#include "PX/NxConvexMeshDesc.h" + +#include "PX/NxConvexShape.h" +#include "PX/NxConvexShapeDesc.h" + +#include "PX/NxHeightField.h" +#include "PX/NxHeightFieldDesc.h" + +#include "PX/NxHeightFieldShape.h" +#include "PX/NxHeightFieldShapeDesc.h" +#include "PX/NxHeightFieldSample.h" + +#include "PX/NxWheelShape.h" +#include "PX/NxWheelShapeDesc.h" +//////////////utils: + +#include "PX/NxInertiaTensor.h" +#include "PX/NxIntersectionBoxBox.h" +#include "PX/NxIntersectionPointTriangle.h" +#include "PX/NxIntersectionRayPlane.h" +#include "PX/NxIntersectionRaySphere.h" +#include "PX/NxIntersectionRayTriangle.h" +#include "PX/NxIntersectionSegmentBox.h" +#include "PX/NxIntersectionSegmentCapsule.h" +#include "PX/NxIntersectionSweptSpheres.h" +#include "PX/NxPMap.h" +#include "PX/NxSmoothNormals.h" +#include "PX/NxAllocateable.h" +#include "PX/NxExportedUtils.h" + +#include "PX/PhysXLoader.h" + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPhysicsSDK.h b/libraries/external/physx/Win32/include/PX/NxPhysicsSDK.h new file mode 100755 index 0000000..7436d11 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPhysicsSDK.h @@ -0,0 +1,663 @@ +#ifndef NX_PHYSICS_NX_PHYSICS_SDK +#define NX_PHYSICS_NX_PHYSICS_SDK +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxInterface.h" +#include "PX/NxUserAllocator.h" + +class NxScene; +class NxSceneDesc; +class NxUserDebugRenderer; +class NxTriangleMesh; +class NxTriangleMeshDesc; +class NxConvexMesh; +class NxConvexMeshDesc; +class NxUserOutputStream; +class NxUserAllocator; +class NxActor; +class NxJoint; +class NxStream; +class NxFoundationSDK; +class NxCCDSkeleton; //this class doesn't actually exist. +class NxSimpleTriangleMesh; +class NxHeightField; +class NxHeightFieldDesc; +#if NX_USE_CLOTH_API +class NxClothMesh; +#endif +#if NX_USE_SOFTBODY_API +class NxSoftBodyMesh; +#endif + +enum NxCookingValue + { + /** + Version numbers follow this format: + + Version = 16bit|16bit + + The high part is increased each time the format changes so much that + pre-cooked files become incompatible with the system (and hence must + be re-cooked) + + The low part is increased each time the format changes but the code + can still read old files. You don't need to re-cook the data in that + case, unless you want to make sure cooked files are optimal. + */ + NX_COOKING_CONVEX_VERSION_PC, + NX_COOKING_MESH_VERSION_PC, + NX_COOKING_CONVEX_VERSION_XENON, + NX_COOKING_MESH_VERSION_XENON, + NX_COOKING_CONVEX_VERSION_PLAYSTATION3, + NX_COOKING_MESH_VERSION_PLAYSTATION3, + }; + +/** +\brief SDK creation flags +*/ +enum NxSDKCreationFlag +{ + /** + \brief Disallows the use of the hardware for the application. + + A good example of when this flag is useful is when a client and server app must be run on the same + machine. Under normal circumstances the SDK will lock the use of the hardware to the first application + which attempts to use it. In the case of a client and server it is desirable to have the server run in + software mode and allow the client to use the hardware. + + Platform: + \li PC SW: No + \li PPU : Yes + \li PS3 : No + \li XB360: No + + @see NxPhysicsSDKDesc + */ + NX_SDKF_NO_HARDWARE = (1<<0), +}; + +/** +\brief Reads an internal value (cooking format version). + +\param[in] cookValue See #NxCookingValue +*/ +NX_C_EXPORT NXP_DLL_EXPORT NxU32 NX_CALL_CONV NxGetValue(NxCookingValue cookValue); + +/** +\brief Descriptor class for NxPhysicsSDK, primarily used for defining PhysX hardware limits + for data shared between scenes. +*/ +class NxPhysicsSDKDesc + { + public: + NxU32 hwPageSize; //!< size of hardware mesh pages. Currently only the value 65536 is supported. + NxU32 hwPageMax; //!< maximum number of hardware pages supported concurrently on hardware. The valid value must be power of 2. + NxU32 hwConvexMax; //!< maximum number of convex meshes which will be resident on hardware. The valid value must be power of 2. + NxU32 cookerThreadMask; //!< Thread affinity mask for the background cooker thread. Defaults to 0 which means the SDK determines the affinity. + + /** + \brief SDK creation flags. + + @see NxSDKCreationFlag + */ + NxU32 flags; + + /** + \brief (re)sets the structure to the default. + */ + + NX_INLINE void setToDefault() + { + hwPageSize = 65536; + hwConvexMax = 2048; + hwPageMax = 256; + flags = 0; + cookerThreadMask = 0; + } + + /** + \brief Returns true if the descriptor is valid. + + \return return true if the current settings are valid + */ + + NX_INLINE bool isValid() const + { + if (hwPageSize != 65536) return false; + if ( hwConvexMax & (hwConvexMax - 1) ) return false; //check if power of two + if ( hwPageMax & (hwPageMax - 1) ) return false; //check if power of two + return true; + } + + NxPhysicsSDKDesc() + { + setToDefault(); + } + }; + + +/** + \brief Abstract singleton factory class used for instancing objects in the Physics SDK. + + In addition you can use NxPhysicsSDK to set global parameters which will effect all scenes, + create triangle meshes and CCD skeletons. + + You can get an instance of this class by calling NxCreatePhysicsSDK(). + + @see NxCreatePhysicsSDK() NxScene NxParameter NxTriangleMesh NxConvexMesh NxPhysicsSDK.createCCDSkeleton() +*/ +class NxPhysicsSDK + { + protected: + NxPhysicsSDK() {} + virtual ~NxPhysicsSDK() {} + + public: + + /** + \brief Destroys the instance it is called on. + + Use this release method to destroy an instance of this class. Be sure + to not keep a reference to this object after calling release. + Avoid release calls while a scene is simulating (in between simulate() and fetchResults() calls). + + Releasing an SDK will also release any scenes, triangle meshes, convex meshes, heightfields, CCD skeletons, and cloth + meshes created through it, provided the user hasn't already done so. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCreatePhysicsSDK() + */ + virtual void release() = 0; + + /** + \brief Function that lets you set global simulation parameters. + + Returns false if the value passed is out of range for usage specified by the enum. + + Sleeping: Does NOT wake any actors which may be affected. + + See #NxParameter for a description of parameters support by hardware. + + \param[in] paramEnum Parameter to set. See #NxParameter + \param[in] paramValue The value to set, see #NxParameter for allowable values. + \return False if the parameter is out of range. + + Platform: + \li PC SW: Yes + \li PPU : Partial + \li PS3 : Yes + \li XB360: Yes + + @see NxParameter getParameter + */ + virtual bool setParameter(NxParameter paramEnum, NxReal paramValue) = 0; + + /** + \brief Function that lets you query global simulation parameters. + + See #NxParameter for a description of parameters support by hardware. + + \param[in] paramEnum The Parameter to retrieve. + \return The value of the parameter. + + Platform: + \li PC SW: Yes + \li PPU : Partial + \li PS3 : Yes + \li XB360: Yes + + @see setParameter NxParameter + */ + virtual NxReal getParameter(NxParameter paramEnum) const = 0; + + /** + \brief Creates a scene. + + The scene can then create its contained entities. + + See #NxSceneDesc::simType to choose if to create a hardware or software scene. + + \param[in] sceneDesc Scene descriptor. See #NxSceneDesc + \return The new scene object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Limitations: + + The number of scenes that can be created is limited by the amount of memory available, and since this + amount varies dynamically as memory is allocated and deallocated by the PhysX SDK and by other software + components there is in general no way to statically determine the maximum number of scenes which can be + created at a given point in the simulation. + + However, scenes are built from lower-level objects called contexts. There is a limit of 64 contexts; a scene will + take 1 or 2 contexts depending on flags upon creation. A software scene (NX_SIMULATION_SW) will always take 1 context, + a hardware scene will take 1 context if NX_SF_RESTRICTED_SCENE is set, otherwise 2 contexts. This places an + absolute limit on the maximum number of scenes regardless of the memory available. + + @see NxScene NxSceneDesc releaseScene() + */ + virtual NxScene* createScene(const NxSceneDesc& sceneDesc) = 0; + + /** + \brief Deletes the instance passed. + + Also releases any actors, sweep caches, fluids, fluid surfaces, cloths, joints, effectors and materials created in this scene + (if the user hasn't already done so), but not meshes or other items created via the SDK itself. + + Be sure to not keep a reference to this object after calling release. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + Make sure to call #NxScene::shutdownWorkerThreads before releasing the scene, if you have user + threads that poll for work (see #NxScene::pollForWork). + + \param[in] scene The scene to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene createScene() shutdownWorkerThreads() + */ + virtual void releaseScene(NxScene& scene) = 0; + + /** + \brief Gets number of created scenes. + + \return The number of scenes created. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getScene() + */ + virtual NxU32 getNbScenes() const = 0; + + /** + \brief Retrieves pointer to created scenes. + + \param[in] i The index for the scene. + \return The scene at index i. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbScenes() NxScene + */ + virtual NxScene* getScene(NxU32 i) = 0; + + /** + \brief Creates a triangle mesh object. + + This can then be instanced into #NxTriangleMeshShape objects. + + \param[in] stream The triangle mesh stream. + \return The new triangle mesh. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh NxStream releaseTriangleMesh() createConvexMesh() + */ + virtual NxTriangleMesh* createTriangleMesh(const NxStream& stream) = 0; + + /** + \brief Destroys the instance passed. + + Be sure to not keep a reference to this object after calling release. + Do not release the triangle mesh before all its instances are released first! + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] mesh Triangle mesh to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createTriangleMesh NxTriangleMesh + */ + virtual void releaseTriangleMesh(NxTriangleMesh& mesh) = 0; + + /** + \brief Number of triangle meshes. + + \return the number of triangle meshes. + */ + virtual NxU32 getNbTriangleMeshes() const = 0; + + /** + \brief Creates a NxHeightField object. + + This can then be instanced into #NxHeightFieldShape objects. + + \param[in] desc The descriptor to load the object from. + \return The new height field object. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see releaseHeightField() NxHeightField NxHeightFieldDesc NxHeightFieldShape + */ + virtual NxHeightField* createHeightField(const NxHeightFieldDesc& desc) = 0; + + /** + \brief Destroys the instance passed. + + Be sure to not keep a reference to this object after calling release. + Do not release the height field before all its shape instances are released first! + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] heightField The height field to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see createHeightField() NxHeightField NxHeightFieldDesc NxHeightFieldShape + */ + virtual void releaseHeightField(NxHeightField& heightField) = 0; + + /** + \brief Number of heightfields. + + \return the number of heightfields. + */ + virtual NxU32 getNbHeightFields() const = 0; + + /** + \brief Creates a CCD Skeleton mesh object. + + CCD is performed with a skeleton(mesh) embedded within the object, this can be simpler than the geometry + used for discrete collision detection. + + NxShape::setCCDSkeleton() should be used to associate a CCD skeleton with shapes. + + \note that stray vertices are permitted (in other words, vertices not referenced by any triangles), + but degenerate triangles (triangles that have a triangle index 2 or 3 times) are not. Stray vertices + are supported so that you can use a single vertex to do a raycast style CCD test. + + \note The CCD skeleton should be scaled so that it is smaller than the geometry it is embedded within. + This allows regular discrete collision detection to handle resting contact. Making the CCD skeleton too + large in comparison to the shape it is embedded within can cause erratic behavior. + + \note CCDSkeletons currently must contain at most 64 vertices! + + Limitations +

+ \li 64 vertex limit on CCD Skeletons (restriction probably lifted in a future version) + \li Doesn't work when the static shape is a NxSphereShape, NxCapsuleShape, NxPlaneShape,NxBoxShape. +

+ +

Visualizations:

+ \li #NX_VISUALIZE_COLLISION_CCD + \li #NX_VISUALIZE_COLLISION_SKELETONS + + \param[in] mesh The triangle mesh from which to create the CCD skeleton. + \return The new CCD skeleton. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSimpleTriangleMesh releaseCCDSkeleton() NxShape.setCCDSkeleton() + */ + virtual NxCCDSkeleton* createCCDSkeleton(const NxSimpleTriangleMesh& mesh) = 0; + + + /** + \brief Creates a CCD Skeleton mesh object. + + Same as createCCDSkeleton(NxSimpleTriangleMesh), but it creates from a memory buffer that was previously created + with NxCCDSkeleton::save(). + + + \param[in] memoryBuffer the buffer to read from. + \param[in] bufferSize size of the buffer. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createCCDSkeleton() + */ + virtual NxCCDSkeleton* createCCDSkeleton(const void* memoryBuffer, NxU32 bufferSize) = 0; + + /** + \brief Destroys the instance passed. + + Be sure to not keep a reference to this object after calling release. + Do not release the object before all its users are released first! + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] skel The CCD Skeleton to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createCCDSkeleton() NxShape.setCCDSkeleton() + */ + virtual void releaseCCDSkeleton(NxCCDSkeleton& skel) = 0; + + /** + \brief Number of CCD skeletons. + + \return the number of CCD skeletons. + */ + virtual NxU32 getNbCCDSkeletons() const = 0; + + /** + \brief Creates a convex mesh object. + + This can then be instanced into #NxConvexShape objects. + + \param[in] mesh The stream to load the convex mesh from. + \return The new convex mesh. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback for > 32 vertices or faces) + \li PS3 : Yes + \li XB360: Yes + + @see releaseConvexMesh() NxConvexMesh NxStream createTriangleMesh() NxConvexShape + */ + virtual NxConvexMesh* createConvexMesh(const NxStream& mesh) = 0; + + /** + \brief Destroys the instance passed. + + Be sure to not keep a reference to this object after calling release. + Do not release the convex mesh before all its instances are released first! + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] mesh The convex mesh to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createConvexMesh() NxConvexMesh NxConvexShape + */ + virtual void releaseConvexMesh(NxConvexMesh& mesh) = 0; + + /** + \brief Number of convex meshes. + + \return the number of convex meshes. + */ + virtual NxU32 getNbConvexMeshes() const = 0; + +#if NX_USE_CLOTH_API + + /** + \brief Creates a cloth mesh from a cooked cloth mesh stored in a stream. + + Stream has to be created with NxCookClothMesh(). + + \return The new cloth mesh. + */ + virtual NxClothMesh* createClothMesh(NxStream& stream) = 0; + + /** + \brief Deletes the specified cloth mesh. The cloth mesh must be in this scene. + + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param cloth Cloth to release. + */ + virtual void releaseClothMesh(NxClothMesh& cloth) = 0; + + /** + \brief Number of cloth meshes. + + \return the number of cloth meshes. + */ + virtual NxU32 getNbClothMeshes() const = 0; + + /** + \brief Retrieve an array of cloth meshes. + + \return an array of cloth mesh pointers with size getNbClothMeshes(). + */ + virtual NxClothMesh** getClothMeshes() = 0; + +#endif + +#if NX_USE_SOFTBODY_API + + /** + \brief Creates a soft body mesh from a cooked soft body mesh stored in a stream. + + Stream has to be created with NxCookSoftBodyMesh(). + + \return The new soft body mesh. + */ + virtual NxSoftBodyMesh* createSoftBodyMesh(NxStream& stream) = 0; + + /** + \brief Deletes the specified soft body mesh. The soft body mesh must be in this scene. + + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param softBodyMesh Soft body mesh to release. + */ + virtual void releaseSoftBodyMesh(NxSoftBodyMesh& softBodyMesh) = 0; + + /** + \brief Number of soft body meshes. + + \return the number of soft body meshes. + */ + virtual NxU32 getNbSoftBodyMeshes() const = 0; + + /** + \brief Retrieve an array of soft body meshes. + + \return an array of soft body mesh pointers with size getNbSoftBodyMeshes(). + */ + virtual NxSoftBodyMesh** getSoftBodyMeshes() = 0; + +#endif + + /** + \brief Reports the internal API version number of the SDK + + \return The internal API version information. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + */ + virtual NxU32 getInternalVersion(NxU32& apiRev, NxU32& descRev, NxU32& branchId) const = 0; + virtual NxInterface* getInterface(NxInterfaceType type, int versionNumber) = 0; + + /** + \brief Reports the available revision of the PhysX Hardware + + \return 0 if there is no hardware present in the machine, 1 for the PhysX Athena revision 1.0 card. + */ + + virtual NxHWVersion getHWVersion() const = 0; + + /** + \brief Reports the number of PPUs installed in the host system + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbPPUs() const = 0; + + /** + \brief Retrieves the FoundationSDK instance. + \return A reference to the Foundation SDK object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxFoundationSDK& getFoundationSDK() const = 0; + + }; + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright ?2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPlane.h b/libraries/external/physx/Win32/include/PX/NxPlane.h new file mode 100755 index 0000000..b3ee32c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPlane.h @@ -0,0 +1,202 @@ +#ifndef NX_FOUNDATION_NXPLANE +#define NX_FOUNDATION_NXPLANE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nxf.h" +#include "PX/NxVec3.h" +#include "PX/NxMat34.h" + +/** +\brief Representation of a plane. + + Plane equation used: a*x + b*y + c*z + d = 0 +*/ +class NxPlane + { + public: + /** + \brief Constructor + */ + NX_INLINE NxPlane() + { + } + + /** + \brief Constructor from a normal and a distance + */ + NX_INLINE NxPlane(NxF32 nx, NxF32 ny, NxF32 nz, NxF32 _d) + { + set(nx, ny, nz, _d); + } + + /** + \brief Constructor from a point on the plane and a normal + */ + NX_INLINE NxPlane(const NxVec3& p, const NxVec3& n) + { + set(p, n); + } + + /** + \brief Constructor from three points + */ + NX_INLINE NxPlane(const NxVec3& p0, const NxVec3& p1, const NxVec3& p2) + { + set(p0, p1, p2); + } + + /** + \brief Constructor from a normal and a distance + */ + NX_INLINE NxPlane(const NxVec3& _n, NxF32 _d) : normal(_n), d(_d) + { + } + + /** + \brief Copy constructor + */ + NX_INLINE NxPlane(const NxPlane& plane) : normal(plane.normal), d(plane.d) + { + } + + /** + \brief Destructor + */ + NX_INLINE ~NxPlane() + { + } + + /** + \brief Sets plane to zero. + */ + NX_INLINE NxPlane& zero() + { + normal.zero(); + d = 0.0f; + return *this; + } + + NX_INLINE NxPlane& set(NxF32 nx, NxF32 ny, NxF32 nz, NxF32 _d) + { + normal.set(nx, ny, nz); + d = _d; + return *this; + } + + NX_INLINE NxPlane& set(const NxVec3& _normal, NxF32 _d) + { + normal = _normal; + d = _d; + return *this; + } + + NX_INLINE NxPlane& set(const NxVec3& p, const NxVec3& _n) + { + normal = _n; + // Plane equation: a*x + b*y + c*z + d = 0 + // p belongs to plane so: + // a*p.x + b*p.y + c*p.z + d = 0 + // <=> (n|p) + d = 0 + // <=> d = - (n|p) + d = - p.dot(_n); + return *this; + } + + /** + \brief Computes the plane equation from 3 points. + */ + NxPlane& set(const NxVec3& p0, const NxVec3& p1, const NxVec3& p2) + { + NxVec3 Edge0 = p1 - p0; + NxVec3 Edge1 = p2 - p0; + + normal = Edge0.cross(Edge1); + normal.normalize(); + + // See comments in set() for computation of d + d = -p0.dot(normal); + + return *this; + } + + NX_INLINE NxF32 distance(const NxVec3& p) const + { + // Valid for plane equation a*x + b*y + c*z + d = 0 + return p.dot(normal) + d; + } + + NX_INLINE bool belongs(const NxVec3& p) const + { + return fabsf(distance(p)) < (1.0e-7f); + } + + /** + \brief projects p into the plane + */ + NX_INLINE NxVec3 project(const NxVec3 & p) const + { + // Pretend p is on positive side of plane, i.e. plane.distance(p)>0. + // To project the point we have to go in a direction opposed to plane's normal, i.e.: + return p - normal * distance(p); +// return p + normal * distance(p); + } + + /** + \brief find an arbitrary point in the plane + */ + NX_INLINE NxVec3 pointInPlane() const + { + // Project origin (0,0,0) to plane: + // (0) - normal * distance(0) = - normal * ((p|(0)) + d) = -normal*d + return - normal * d; +// return normal * d; + } + + NX_INLINE void normalize() + { + NxF32 Denom = 1.0f / normal.magnitude(); + normal.x *= Denom; + normal.y *= Denom; + normal.z *= Denom; + d *= Denom; + } + + NX_INLINE operator NxVec3() const + { + return normal; + } + + NX_INLINE void transform(const NxMat34 & transform, NxPlane & transformed) const + { + transformed.normal = transform.M * normal; + transformed.d = d - (transform.t | transformed.normal); + } + + NX_INLINE void inverseTransform(const NxMat34 & transform, NxPlane & transformed) const + { + transformed.normal = transform.M % normal; + NxVec3 it = transform.M % transform.t; + transformed.d = d + (it | transformed.normal); + } + + NxVec3 normal; //!< The normal to the plane + NxF32 d; //!< The distance from the origin + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPlaneShape.h b/libraries/external/physx/Win32/include/PX/NxPlaneShape.h new file mode 100755 index 0000000..1b67f20 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPlaneShape.h @@ -0,0 +1,154 @@ +#ifndef NX_COLLISION_NXPLANESHAPE +#define NX_COLLISION_NXPLANESHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" + +class NxPlane; +class NxPlaneShapeDesc; + +/** +\brief A plane collision detection primitive. + +By default it is configured to be the y == 0 plane. You can then set a normal and a d to specify +an arbitrary plane. d is the distance of the plane from the origin along the normal, assuming +the normal is normalized. Thus the plane equation is: +normal.x * X + normal.y * Y + normal.z * Z = d + +Note: The plane equation defines the plane in world space. Any other transformations, +like actor global pose and shape local pose are ignored by the plane shape. + +Note: the plane does not represent an infinitely thin object, but rather a completely solid negative +half space (all points p for which normal.dot(p) - d < 0 are inside the solid region.) + + +Each shape is owned by an actor that it is attached to. + + +

Creation

+ +An instance can be created by calling the createShape() method of the NxActor object +that should own it, with a NxPlaneShapeDesc object as the parameter, or by adding the +shape descriptor into the NxActorDesc class before creating the actor. + +The shape is deleted by calling NxActor::releaseShape() on the owning actor. + +Example: + +\include NxPlaneShape_Create.cpp + +

Visualizations

+\li NX_VISUALIZE_COLLISION_AABBS +\li NX_VISUALIZE_COLLISION_SHAPES +\li NX_VISUALIZE_COLLISION_AXES + +Platform: +\li PC SW: Yes +\li PPU : Yes (Hardware rigid body only) +\li PS3 : Yes +\li XB360: Yes + + +@see NxActor.createShape() NxPlaneShapeDesc NxShape NxPlane +*/ + +class NxPlaneShape: public NxShape + { + public: + + /** + \brief sets the plane equation. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] normal Normal for the plane, in the global frame. Range: direction vector + \param[in] d 'd' coefficient of the plane equation. Range: (-inf,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Hardware rigid body only) + \li PS3 : Yes + \li XB360: Yes + + @see getPlane() NxPlane + */ + virtual void setPlane(const NxVec3 & normal, NxReal d) = 0; + + /* + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save this objects state to. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Hardware rigid body only) + \li PS3 : Yes + \li XB360: Yes + + @see NxPlaneShapeDesc + */ + virtual void saveToDesc(NxPlaneShapeDesc& desc) const = 0; + + /** + \brief retrieves the plane + + Note: + There is an inconsistency between the definition of a plane in the + NxPlane class and the NxPlaneShape and NxPlaneShapeDesc classes. + The NxPlane class defines a point (X, Y, Z) in the plane when: + normal.x*X + normal.y*Y + normal.z*Z + d = 0 + The NxPlaneShapeDesc and NxPlaneShape::setPlane() use the following definition: + normal.x*X + normal.y*Y + normal.z*Z - d = 0 + Although the data is the same, the interpretation is different: + + NxPlane plane; + NxPlaneShape *planeShape; + ... + planeShape->setPlane(plane.normal, plane.d); + // At this point plane == planeShape->getPlane() will be true. + // But plane.pointInPlane() will not return a point in 'planeShape' + ... + // To use the plane methods the following conversions are required: + ... + // Assignment NxPlane -> NxPlaneShape + planeShape->setPlane(plane.normal, -plane.d); + // 'planeShape' now represents the same plane as 'plane' + ... + // Assignment NxPlaneShape -> NxPlane + plane = planeShape->getPlane(); + plane.d *= -plane.d; + // 'plane' now represents the same plane as 'planeShape' + + + \return The description of this plane. See #NxPlane. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Hardware rigid body only) + \li PS3 : Yes + \li XB360: Yes + + @see setPlane NxPlane + */ + virtual NxPlane getPlane() const = 0; + + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPlaneShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxPlaneShapeDesc.h new file mode 100755 index 0000000..56f5667 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPlaneShapeDesc.h @@ -0,0 +1,103 @@ +#ifndef NX_COLLISION_NXPLANESHAPEDESC +#define NX_COLLISION_NXPLANESHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShapeDesc.h" + +/** +\brief Descriptor class for #NxPlaneShape. + +See also the #NxPlane. + +Platform: +\li PC SW: Yes +\li PPU : Yes (Hardware rigid body only) +\li PS3 : Yes +\li XB360: Yes + +@see NxPlane NxPlaneShape NxShapeDesc NxActor.createShape() +*/ +class NxPlaneShapeDesc : public NxShapeDesc + { + public: + + /** + \brief Plane normal. (unit length!) + + The plane equation takes the form: normal.x * X + normal.y * Y + normal.z * Z = d + + Note: The plane equation defines the plane in world space. Any other transformations, + like actor global pose and shape local pose are ignored by the plane shape. + + Range: direction vector
+ Default: 0.0, 1.0, 0.0 + + @see NxPlaneShape + */ + NxVec3 normal; + + /** + \brief The distance from the origin. + + The plane equation takes the form: normal.x * X + normal.y * Y + normal.z * Z = d + + Range: (-inf,inf)
+ Default: 0.0 + + @see NxPlaneShape + */ + NxReal d; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxPlaneShapeDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return return true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxPlaneShapeDesc::NxPlaneShapeDesc() : NxShapeDesc(NX_SHAPE_PLANE) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxPlaneShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + // default ground plane + normal.set(NxReal(0.0),NxReal(1.0),NxReal(0.0)); + d=NxReal(0.0); + } + +NX_INLINE bool NxPlaneShapeDesc::isValid() const + { + if(!normal.isFinite()) return false; + if(!NxMath::isFinite(d)) return false; + return NxShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPointInPlaneJoint.h b/libraries/external/physx/Win32/include/PX/NxPointInPlaneJoint.h new file mode 100755 index 0000000..9a1b275 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPointInPlaneJoint.h @@ -0,0 +1,88 @@ +#ifndef NX_PHYSICS_NXPOINTINPLANEJOINT +#define NX_PHYSICS_NXPOINTINPLANEJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" + +class NxPointInPlaneJointDesc; + +/** + \brief A point in plane joint constrains a point on one body to only move inside + a plane attached to another body. + + The starting point of the point is defined as the anchor point. The plane + through this point is specified by its normal which is the joint axis vector. + + \image html pointInPlaneJoint.png + +

Creation

+ + \include NxPointInPlaneJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxPointInPlaneJointDesc NxJoint NxScene.createJoint +*/ +class NxPointInPlaneJoint : public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc NxPointInPlaneJointDesc + */ + virtual void loadFromDesc(const NxPointInPlaneJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct. + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc NxPointInPlaneJointDesc + */ + virtual void saveToDesc(NxPointInPlaneJointDesc& desc) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPointInPlaneJointDesc.h b/libraries/external/physx/Win32/include/PX/NxPointInPlaneJointDesc.h new file mode 100755 index 0000000..dfcf131 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPointInPlaneJointDesc.h @@ -0,0 +1,69 @@ +#ifndef NX_PHYSICS_NXPOINTINPLANEJOINTDESC +#define NX_PHYSICS_NXPOINTINPLANEJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +/** +\brief Desc class for point-in-plane joint. See #NxPointInPlaneJoint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxPointInPlaneJoint NxJointDesc NxScene.createJoint +*/ +class NxPointInPlaneJointDesc : public NxJointDesc + { + public: + /** + \brief Constructor sets to default. + */ + NX_INLINE NxPointInPlaneJointDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxPointInPlaneJointDesc::NxPointInPlaneJointDesc() : NxJointDesc(NX_JOINT_POINT_IN_PLANE) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxPointInPlaneJointDesc::setToDefault() + { + NxJointDesc::setToDefault(); + } + +NX_INLINE bool NxPointInPlaneJointDesc::isValid() const + { + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPointOnLineJoint.h b/libraries/external/physx/Win32/include/PX/NxPointOnLineJoint.h new file mode 100755 index 0000000..8e089bb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPointOnLineJoint.h @@ -0,0 +1,88 @@ +#ifndef NX_PHYSICS_NXPOINTONLINEJOINT +#define NX_PHYSICS_NXPOINTONLINEJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +#include "PX/NxJoint.h" +class NxPointOnLineJointDesc; + +/** + \brief A point on line joint constrains a point on one body to only move along + a line attached to another body. + + The starting point of the joint is defined as the anchor point. The line + through this point is specified by its direction (axis) vector. + + \image html pointOnLineJoint.png + +

Creation

+ + \include NxPointOnLineJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxPointOnLineJointDesc NxScene.createJoint() NxJoint +*/ +class NxPointOnLineJoint: public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc() NxPointOnLineJointDesc + */ + virtual void loadFromDesc(const NxPointOnLineJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc() NxPointOnLineJointDesc + */ + virtual void saveToDesc(NxPointOnLineJointDesc& desc) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPointOnLineJointDesc.h b/libraries/external/physx/Win32/include/PX/NxPointOnLineJointDesc.h new file mode 100755 index 0000000..aa5a6d7 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPointOnLineJointDesc.h @@ -0,0 +1,71 @@ +#ifndef NX_PHYSICS_NXPOINTONLINEJOINTDESC +#define NX_PHYSICS_NXPOINTONLINEJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +/** +\brief Desc class for point-on-line joint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxPointOnLineJoint NxScene.createJoint() NxJointDesc +*/ +class NxPointOnLineJointDesc : public NxJointDesc + { + public: + /** + \brief Constructor sets to default. + */ + NX_INLINE NxPointOnLineJointDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxPointOnLineJointDesc::NxPointOnLineJointDesc() : NxJointDesc(NX_JOINT_POINT_ON_LINE) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxPointOnLineJointDesc::setToDefault() + { + NxJointDesc::setToDefault(); + } + +NX_INLINE bool NxPointOnLineJointDesc::isValid() const + { + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPool.h b/libraries/external/physx/Win32/include/PX/NxPool.h new file mode 100755 index 0000000..17f877d --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPool.h @@ -0,0 +1,136 @@ +#ifndef NXPOOL_H +#define NXPOOL_H +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/NxArray.h" + +/** +\brief Class which stores a pool of objects for fast allocation. +*/ +template +class NxPool +{ + typedef NxArraySDK ElementPtrArray; + +public: + + /** + \param initial Initial size of the pool. + \param increment Size to increase pool by when we need more memory. + */ + NxPool(NxU32 initial, NxU32 increment = 0) + { + mIncrement = increment; + mCount = 0; + mCapacity = 0; + allocSlab(initial); + } + + ~NxPool() + { + for(NxU32 i=0;ifree(mSlabArray[i]); + } + + + Element *get() + { + Element *element = 0; + + if(mCount==mCapacity && mIncrement) + allocSlab(mIncrement); + + if(mCount < mCapacity) + { + element = mContents[mCount]; + mIDToContents[element->hwid] = mCount++; + } +// printf("Acquired %lp\n",element); + + return element; + } + + /** + \param element Element to put back into the pool. + */ + void put(Element *element) + { +// printf("Releasing %lp\n",element); + if(mIDToContents[element->hwid]!=0xffffffff) + { + NxU32 elementPos = mIDToContents[element->hwid]; + /* swap the released element with the last element & decrement content counter */ + Element *replacement = mContents[--mCount]; + mContents[mCount] = element; + mContents[elementPos] = replacement; + + /* update the ID to contents arrays */ + mIDToContents[replacement->hwid] = elementPos; + mIDToContents[element->hwid] = 0xffffffff; + } + } + + const NxArray contents() + { + return mContents; + } + + NxU32 count() + { + return mCount; + } + +private: + void allocSlab(NxU32 count) + { + char *mem = (char *) + nxFoundationSDKAllocator->malloc(count * ElementSize); + if(!mem) + return; + + mSlabArray.pushBack(mem); + mContents.reserve(mCapacity+count); + mIDToContents.reserve(mCapacity+count); + + for(NxU32 i=0;ihwid = mCapacity+i; + mIDToContents.pushBack(0xffffffff); + mContents.pushBack(e); + } + + mCapacity+=count; + } + + NxU32 mIncrement; /* resize quantum */ + NxU32 mCapacity; /* current size */ + NxU32 mCount; /* current number of elements */ + + NxArraySDK mSlabArray; /* array of allocated slabs */ + + ElementPtrArray mContents; /* array of elements. The first mCount are in use, + the rest are free for allocation */ + + NxArraySDK mIDToContents; /* maps IDs to the mContents array in order to get O(1) removal. + Only required for things actually allocated, so use 0xffffffff + for 'not allocated' and thereby catch double-deletion. */ +}; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPrismaticJoint.h b/libraries/external/physx/Win32/include/PX/NxPrismaticJoint.h new file mode 100755 index 0000000..3053784 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPrismaticJoint.h @@ -0,0 +1,85 @@ +#ifndef NX_PHYSICS_NXPRISMATICJOINT +#define NX_PHYSICS_NXPRISMATICJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" + +class NxPrismaticJointDesc; + +/** + \brief A prismatic joint permits relative translational movement between two bodies along + an axis, but no relative rotational movement. + + \image html prismJoint.png + +

Creation

+ + \include NxPrismaticJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxPrismaticJointDesc NxJoint NxScene.createJoint() +*/ +class NxPrismaticJoint: public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc NxPrismaticJointDesc + */ + virtual void loadFromDesc(const NxPrismaticJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc NxPrismaticJointDesc + */ + virtual void saveToDesc(NxPrismaticJointDesc& desc) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPrismaticJointDesc.h b/libraries/external/physx/Win32/include/PX/NxPrismaticJointDesc.h new file mode 100755 index 0000000..16bdf11 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPrismaticJointDesc.h @@ -0,0 +1,70 @@ +#ifndef NX_PHYSICS_NXPRISMATICJOINTDESC +#define NX_PHYSICS_NXPRISMATICJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +/** +\brief Desc class for #NxPrismaticJoint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxJointDesc NxPrismaticJoint NxScene.createJoint +*/ +class NxPrismaticJointDesc : public NxJointDesc + { + public: + /** + \brief Constructor sets to default. + */ + NX_INLINE NxPrismaticJointDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxPrismaticJointDesc::NxPrismaticJointDesc() : NxJointDesc(NX_JOINT_PRISMATIC) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxPrismaticJointDesc::setToDefault() + { + NxJointDesc::setToDefault(); + } + +NX_INLINE bool NxPrismaticJointDesc::isValid() const + { + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxProfiler.h b/libraries/external/physx/Win32/include/PX/NxProfiler.h new file mode 100755 index 0000000..10d4a16 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxProfiler.h @@ -0,0 +1,59 @@ +#ifndef NX_FOUNDATION_NXPROFILER +#define NX_FOUNDATION_NXPROFILER +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +//#define NX_ENABLE_PROFILER //!< Switch indicating if profiler is active. Customer requested that this define be exposed so that user code can be conditionally compiled. +//#define NX_ENABLE_PROFILER_COUNTER //!< Enable an additional performance counter(eg L2 cache misses) + +/** +\brief A profiling zone. + +A profiling zone is a named piece of code whose performance characteristics have been measured. +*/ +class NxProfileZone + { + public: + const char * name; //!< Name of the zone. + NxU32 callCount; //!< The number of times this zone was executed over the last profiling run (since readProfileData(true) was called.) + NxU32 hierTime; //!< Time in micro seconds that it took to execute the total of the calls to this zone. + NxU32 selfTime; //!< Time in micro seconds that it took to execute the total of the calls to this zone, minus the time it took to execute the zones called from this zone. + NxU32 recursionLevel; //!< The number of parent zones this zone has, each of which called the next until this zone was called. Can be used to indent a tree display of the zones. Sometimes a zone could have multiple rec. levels as it was called from different places. In this case the first encountered rec level is displayed. + NxReal percent; //!< The percentage time this zone took of its parent zone's time. If this zone has multiple parents (the code was called from multiple places), this is zero. + +#ifdef NX_ENABLE_PROFILER_COUNTER + NxU32 counter; +#endif + }; + + +/** +\brief Array of profiling data. + + profileZones points to an array of numZones profile zones. Zones are sorted such that the parent zones always come before their children. + Some zones have multiple parents (code called from multiple places) in which case only the relationship to the first parent is displayed. + returned by NxScene::readProfileData(). +*/ +class NxProfilerData + { + public: + NxU32 numZones; + NxProfileZone * profileZones; + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPulleyJoint.h b/libraries/external/physx/Win32/include/PX/NxPulleyJoint.h new file mode 100755 index 0000000..c5dc6ca --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPulleyJoint.h @@ -0,0 +1,170 @@ +#ifndef NX_PHYSICS_NXPULLEYJOINT +#define NX_PHYSICS_NXPULLEYJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJoint.h" + +class NxPulleyJointDesc; +class NxMotorDesc; + +/** + \brief A pulley joint simulates a rope between two objects passing over 2 pulleys. + + \image html pulleyJoint.png +

Creation

+ + Example: + + \include NxPulleyJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxJoint NxPulleyJointDesc NxScene.createJoint() +*/ +class NxPulleyJoint: public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc NxPulleyJointDesc + */ + virtual void loadFromDesc(const NxPulleyJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct. + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc() NxPulleyJointDesc + */ + virtual void saveToDesc(NxPulleyJointDesc& desc) = 0; + + /** + \brief Sets motor parameters for the joint. + + For a positive velTarget, the motor pulls the first body towards its pulley, + for a negative velTarget, the motor pulls the second body towards its pulley. + +
    +
  • velTarget - the relative velocity the motor is trying to achieve. The motor will only be able + to reach this velocity if the maxForce is sufficiently large. If the joint is + moving faster than this velocity, the motor will actually try to brake. If you set this + to infinity then the motor will keep speeding up, unless there is some sort of resistance + on the attached bodies.
  • +
  • maxForce - the maximum force the motor can exert. Zero disables the motor. + Default is 0, should be >= 0. Setting this to a very large value if velTarget is also + very large may not be a good idea.
  • +
  • freeSpin - if this flag is set, and if the joint is moving faster than velTarget, then neither + braking nor additional acceleration will result. + default: false.
  • +
+ This automatically enables the motor. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] motorDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMotorDesc getMotor() + */ + virtual void setMotor(const NxMotorDesc &motorDesc) = 0; + + /** + \brief Reads back the motor parameters. Returns true if it is enabled. + + \param[out] motorDesc Used to retrieve the settings for this joint. + \return True if the motor is enabled. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setMotor NxMotorDesc + */ + virtual bool getMotor(NxMotorDesc &motorDesc) = 0; + + /** + \brief Sets the flags. This is a combination of the ::NxPulleyJointFlag bits. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] flags New set of flags for this joint. See #NxPulleyJointFlag + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPulleyJointFlag getFlags() + */ + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief returns the current flag settings. see #NxPulleyJointFlag + + \return The flag settings for this object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFlags() NxPulleyJointFlag + */ + virtual NxU32 getFlags() = 0; + + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxPulleyJointDesc.h b/libraries/external/physx/Win32/include/PX/NxPulleyJointDesc.h new file mode 100755 index 0000000..3e81b64 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxPulleyJointDesc.h @@ -0,0 +1,139 @@ +#ifndef NX_PHYSICS_NXPULLEYJOINTDESC +#define NX_PHYSICS_NXPULLEYJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +#include "PX/NxMotorDesc.h" + +/** +\brief Desc class for #NxPulleyJoint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxPulleyJoint NxJointDesc +*/ +class NxPulleyJointDesc : public NxJointDesc + { + public: + /** + \brief suspension points of two bodies in world space. + + Range: position vector
+ Default: [0]Zero
+ Default: [1]Zero + */ + NxVec3 pulley[2]; + + /** + \brief the rest length of the rope connecting the two objects. + + The distance is computed as ||(pulley0 - anchor0)|| + ||(pulley1 - anchor1)|| * ratio. + + Range: [0,inf)
+ Default: 0.0 + */ + NxReal distance; + + /** + \brief how stiff the constraint is, between 0 and 1 (stiffest) + + Range: [0,1]
+ Default: 1.0 + */ + NxReal stiffness; + + /** + \brief transmission ratio + + Range: (0,inf)
+ Default: 1.0 + */ + NxReal ratio; + + /** + \brief This is a combination of the bits defined by ::NxPulleyJointFlag. + + Default: 0 + + @see NxPulleyJointFlag. + */ + NxU32 flags; + + /** + \brief Optional joint motor. + + Range: See #NxMotorDesc
+ Default: See #NxMotorDesc + + @see NxMotorDesc + */ + NxMotorDesc motor; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxPulleyJointDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxPulleyJointDesc::NxPulleyJointDesc() : NxJointDesc(NX_JOINT_PULLEY) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxPulleyJointDesc::setToDefault() + { + pulley[0].zero(); + pulley[1].zero(); + + distance = 0.0f; + stiffness = 1.0f; + ratio = 1.0f; + flags = 0; + + motor.setToDefault(); + + NxJointDesc::setToDefault(); + } + +NX_INLINE bool NxPulleyJointDesc::isValid() const + { + if (distance < 0) return false; + if (stiffness < 0 || stiffness > 1) return false; + if (ratio < 0) return false; + if (!motor.isValid()) return false; + + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxQuat.h b/libraries/external/physx/Win32/include/PX/NxQuat.h new file mode 100755 index 0000000..7770a93 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxQuat.h @@ -0,0 +1,805 @@ +#ifndef NX_FOUNDATION_NxQuatT +#define NX_FOUNDATION_NxQuatT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nxf.h" +#include "PX/NxVec3.h" + +/** +\brief This is a quaternion class. For more information on quaternion mathematics +consult a mathematics source on complex numbers. + +*/ + +class NxQuat + { + public: + /** + \brief Default constructor, does not do any initialization. + */ + NX_INLINE NxQuat(); + + /** + \brief Copy constructor. + */ + NX_INLINE NxQuat(const NxQuat&); + + /** + \brief copies xyz elements from v, and scalar from w (defaults to 0). + */ + NX_INLINE NxQuat(const NxVec3& v, NxReal w = 0); + + /** + \brief creates from angle-axis representation. + + note that if Angle > 360 the resulting rotation is Angle mod 360. + + Unit: Degrees + */ + NX_INLINE NxQuat(const NxReal angle, const NxVec3 & axis); + + /** + \brief Creates from orientation matrix. + + \param[in] m Rotation matrix to extract quaternion from. + */ + NX_INLINE NxQuat(const class NxMat33 &m); /* defined in NxMat33.h */ + + + /** + \brief Set the quaternion to the identity rotation. + */ + NX_INLINE void id(); + + /** + \brief Test if the quaternion is the identity rotation. + */ + NX_INLINE bool isIdentityRotation() const; + + //setting: + + /** + \brief Set the members of the quaternion, in order WXYZ + */ + NX_INLINE void setWXYZ(NxReal w, NxReal x, NxReal y, NxReal z); + + /** + \brief Set the members of the quaternion, in order XYZW + */ + NX_INLINE void setXYZW(NxReal x, NxReal y, NxReal z, NxReal w); + + /** + \brief Set the members of the quaternion, in order WXYZ + */ + NX_INLINE void setWXYZ(const NxReal *); + + /** + \brief Set the members of the quaternion, in order XYZW + */ + NX_INLINE void setXYZW(const NxReal *); + + NX_INLINE NxQuat& operator= (const NxQuat&); + + /** + \brief Implicitly extends vector by a 0 w element. + */ + NX_INLINE NxQuat& operator= (const NxVec3&); + + NX_INLINE void setx(const NxReal& d); + NX_INLINE void sety(const NxReal& d); + NX_INLINE void setz(const NxReal& d); + NX_INLINE void setw(const NxReal& d); + + NX_INLINE void getWXYZ(NxF32 *) const; + NX_INLINE void getXYZW(NxF32 *) const; + + NX_INLINE void getWXYZ(NxF64 *) const; + NX_INLINE void getXYZW(NxF64 *) const; + + /** + \brief returns true if all elements are finite (not NAN or INF, etc.) + */ + NX_INLINE bool isFinite() const; + + /** + \brief sets to the quat [0,0,0,1] + */ + NX_INLINE void zero(); + + /** + \brief creates a random unit quaternion. + */ + NX_INLINE void random(); + /** + \brief creates from angle-axis representation. + + Note that if Angle > 360 the resulting rotation is Angle mod 360. + + Unit: Degrees + */ + NX_INLINE void fromAngleAxis(NxReal angle, const NxVec3 & axis); + + /** + \brief Creates from angle-axis representation. + + Axis must be normalized! + + Unit: Radians + */ + NX_INLINE void fromAngleAxisFast(NxReal AngleRadians, const NxVec3 & axis); + + /** + \brief Sets this to the opposite rotation of this. + */ + NX_INLINE void invert(); + + /** + \brief Fetches the Angle/axis given by the NxQuat. + + Unit: Degrees + */ + NX_INLINE void getAngleAxis(NxReal& Angle, NxVec3 & axis) const; + + /** + \brief Gets the angle between this quat and the identity quaternion. + + Unit: Degrees + */ + NX_INLINE NxReal getAngle() const; + + /** + \brief Gets the angle between this quat and the argument + + Unit: Degrees + */ + NX_INLINE NxReal getAngle(const NxQuat &) const; + + /** + \brief This is the squared 4D vector length, should be 1 for unit quaternions. + */ + NX_INLINE NxReal magnitudeSquared() const; + + /** + \brief returns the scalar product of this and other. + */ + NX_INLINE NxReal dot(const NxQuat &other) const; + + //modifiers: + /** + \brief maps to the closest unit quaternion. + */ + NX_INLINE void normalize(); + + /* + \brief assigns its own conjugate to itself. + + \note for unit quaternions, this is the inverse. + */ + NX_INLINE void conjugate(); + + /** + this = a * b + */ + NX_INLINE void multiply(const NxQuat& a, const NxQuat& b); + + /** + this = a * v + v is interpreted as quat [xyz0] + */ + NX_INLINE void multiply(const NxQuat& a, const NxVec3& v); + + /** + this = slerp(t, a, b) + */ + NX_INLINE void slerp(const NxReal t, const NxQuat& a, const NxQuat& b); + + /** + rotates passed vec by rot expressed by unit quaternion. overwrites arg with the result. + */ + NX_INLINE void rotate(NxVec3 &) const; + + /** + rotates passed vec by this (assumed unitary) + */ + NX_INLINE const NxVec3 rot(const NxVec3 &) const; + + /** + inverse rotates passed vec by this (assumed unitary) + */ + NX_INLINE const NxVec3 invRot(const NxVec3 &) const; + + /** + transform passed vec by this rotation (assumed unitary) and translation p + */ + NX_INLINE const NxVec3 transform(const NxVec3 &v, const NxVec3 &p) const; + + /** + inverse rotates passed vec by this (assumed unitary) + */ + NX_INLINE const NxVec3 invTransform(const NxVec3 &v, const NxVec3 &p) const; + + + /** + rotates passed vec by opposite of rot expressed by unit quaternion. overwrites arg with the result. + */ + NX_INLINE void inverseRotate(NxVec3 &) const; + + + + /** + negates all the elements of the quat. q and -q represent the same rotation. + */ + NX_INLINE void negate(); + NX_INLINE NxQuat operator -() const; + + NX_INLINE NxQuat& operator*= (const NxQuat&); + NX_INLINE NxQuat& operator+= (const NxQuat&); + NX_INLINE NxQuat& operator-= (const NxQuat&); + NX_INLINE NxQuat& operator*= (const NxReal s); + + /** the quaternion elements */ + NxReal x,y,z,w; + + /** quaternion multiplication */ + NX_INLINE NxQuat operator *(const NxQuat &) const; + + /** quaternion addition */ + NX_INLINE NxQuat operator +(const NxQuat &) const; + + /** quaternion subtraction */ + NX_INLINE NxQuat operator -(const NxQuat &) const; + + /** quaternion conjugate */ + NX_INLINE NxQuat operator !() const; + + /* + ops we decided not to implement: + bool operator== (const NxQuat&) const; + NxVec3 operator^ (const NxQuat& r_h_s) const;//same as normal quat rot, but casts itself into a vector. (doesn't compute w term) + NxQuat operator* (const NxVec3& v) const;//implicitly extends vector by a 0 w element. + NxQuat operator* (const NxReal Scale) const; + */ + + friend class NxMat33; + private: + NX_INLINE NxQuat(NxReal ix, NxReal iy, NxReal iz, NxReal iw); + }; + + + + +NX_INLINE NxQuat::NxQuat() + { + //nothing + } + + +NX_INLINE NxQuat::NxQuat(const NxQuat& q) : x(q.x), y(q.y), z(q.z), w(q.w) + { + } + + +NX_INLINE NxQuat::NxQuat(const NxVec3& v, NxReal s) // copy constructor, assumes w=0 + { + x = v.x; + y = v.y; + z = v.z; + w = s; + } + + +NX_INLINE NxQuat::NxQuat(const NxReal angle, const NxVec3 & axis) // creates a NxQuat from an Angle axis -- note that if Angle > 360 the resulting rotation is Angle mod 360 + { + fromAngleAxis(angle,axis); + } + + +NX_INLINE void NxQuat::id() + { + x = NxReal(0); + y = NxReal(0); + z = NxReal(0); + w = NxReal(1); + } + +NX_INLINE bool NxQuat::isIdentityRotation() const +{ + return x==0 && y==0 && z==0 && fabsf(w)==1; +} + + +NX_INLINE void NxQuat::setWXYZ(NxReal sw, NxReal sx, NxReal sy, NxReal sz) + { + x = sx; + y = sy; + z = sz; + w = sw; + } + + +NX_INLINE void NxQuat::setXYZW(NxReal sx, NxReal sy, NxReal sz, NxReal sw) + { + x = sx; + y = sy; + z = sz; + w = sw; + } + + +NX_INLINE void NxQuat::setWXYZ(const NxReal * d) + { + x = d[1]; + y = d[2]; + z = d[3]; + w = d[0]; + } + + +NX_INLINE void NxQuat::setXYZW(const NxReal * d) + { + x = d[0]; + y = d[1]; + z = d[2]; + w = d[3]; + } + + +NX_INLINE void NxQuat::getWXYZ(NxF32 *d) const + { + d[1] = (NxF32)x; + d[2] = (NxF32)y; + d[3] = (NxF32)z; + d[0] = (NxF32)w; + } + + +NX_INLINE void NxQuat::getXYZW(NxF32 *d) const + { + d[0] = (NxF32)x; + d[1] = (NxF32)y; + d[2] = (NxF32)z; + d[3] = (NxF32)w; + } + + +NX_INLINE void NxQuat::getWXYZ(NxF64 *d) const + { + d[1] = (NxF64)x; + d[2] = (NxF64)y; + d[3] = (NxF64)z; + d[0] = (NxF64)w; + } + + +NX_INLINE void NxQuat::getXYZW(NxF64 *d) const + { + d[0] = (NxF64)x; + d[1] = (NxF64)y; + d[2] = (NxF64)z; + d[3] = (NxF64)w; + } + +//const methods + +NX_INLINE bool NxQuat::isFinite() const + { + return NxMath::isFinite(x) + && NxMath::isFinite(y) + && NxMath::isFinite(z) + && NxMath::isFinite(w); + } + + + +NX_INLINE void NxQuat::zero() + { + x = NxReal(0.0); + y = NxReal(0.0); + z = NxReal(0.0); + w = NxReal(1.0); + } + + +NX_INLINE void NxQuat::negate() + { + x = -x; + y = -y; + z = -z; + w = -w; + } + +NX_INLINE NxQuat NxQuat::operator-() const + { + return NxQuat(-x,-y,-z,-w); + } + + +NX_INLINE void NxQuat::random() + { + x = NxMath::rand(NxReal(0.0),NxReal(1.0)); + y = NxMath::rand(NxReal(0.0),NxReal(1.0)); + z = NxMath::rand(NxReal(0.0),NxReal(1.0)); + w = NxMath::rand(NxReal(0.0),NxReal(1.0)); + normalize(); + } + + +NX_INLINE void NxQuat::fromAngleAxis(NxReal Angle, const NxVec3 & axis) // set the NxQuat by Angle-axis (see AA constructor) + { + x = axis.x; + y = axis.y; + z = axis.z; + + // required: Normalize the axis + + const NxReal i_length = NxReal(1.0) / NxMath::sqrt( x*x + y*y + z*z ); + + x = x * i_length; + y = y * i_length; + z = z * i_length; + + // now make a clQuaternionernion out of it + NxReal Half = NxMath::degToRad(Angle * NxReal(0.5)); + + w = NxMath::cos(Half);//this used to be w/o deg to rad. + const NxReal sin_theta_over_two = NxMath::sin(Half ); + x = x * sin_theta_over_two; + y = y * sin_theta_over_two; + z = z * sin_theta_over_two; + } + +NX_INLINE void NxQuat::fromAngleAxisFast(NxReal AngleRadians, const NxVec3 & axis) + { + NxReal s; + NxMath::sinCos(AngleRadians * 0.5f, s, w); + x = axis.x * s; + y = axis.y * s; + z = axis.z * s; + } + +NX_INLINE void NxQuat::invert() + { + x = -x; + y = -y; + z = -z; + } + +NX_INLINE void NxQuat::setx(const NxReal& d) + { + x = d; + } + + +NX_INLINE void NxQuat::sety(const NxReal& d) + { + y = d; + } + + +NX_INLINE void NxQuat::setz(const NxReal& d) + { + z = d; + } + + +NX_INLINE void NxQuat::setw(const NxReal& d) + { + w = d; + } + + +NX_INLINE void NxQuat::getAngleAxis(NxReal& angle, NxVec3 & axis) const + { + //return axis and angle of rotation of quaternion + angle = NxMath::acos(w) * NxReal(2.0); //this is getAngle() + NxReal sa = NxMath::sqrt(NxReal(1.0) - w*w); + if (sa) + { + axis.set(x/sa,y/sa,z/sa); + angle = NxMath::radToDeg(angle); + } + else + axis.set(NxReal(1.0),NxReal(0.0),NxReal(0.0)); + + } + + + +NX_INLINE NxReal NxQuat::getAngle() const + { + return NxMath::acos(w) * NxReal(2.0); + } + + + +NX_INLINE NxReal NxQuat::getAngle(const NxQuat & q) const + { + return NxMath::acos(dot(q)) * NxReal(2.0); + } + + +NX_INLINE NxReal NxQuat::magnitudeSquared() const + +//modifiers: + { + return x*x + y*y + z*z + w*w; + } + + +NX_INLINE NxReal NxQuat::dot(const NxQuat &v) const + { + return x * v.x + y * v.y + z * v.z + w * v.w; + } + + +NX_INLINE void NxQuat::normalize() // convert this NxQuat to a unit clQuaternionernion + { + const NxReal mag = NxMath::sqrt(magnitudeSquared()); + if (mag) + { + const NxReal imag = NxReal(1.0) / mag; + + x *= imag; + y *= imag; + z *= imag; + w *= imag; + } + } + + +NX_INLINE void NxQuat::conjugate() // convert this NxQuat to a unit clQuaternionernion + { + x = -x; + y = -y; + z = -z; + } + + +NX_INLINE void NxQuat::multiply(const NxQuat& left, const NxQuat& right) // this = a * b + { + NxReal a,b,c,d; + + a =left.w*right.w - left.x*right.x - left.y*right.y - left.z*right.z; + b =left.w*right.x + right.w*left.x + left.y*right.z - right.y*left.z; + c =left.w*right.y + right.w*left.y + left.z*right.x - right.z*left.x; + d =left.w*right.z + right.w*left.z + left.x*right.y - right.x*left.y; + + w = a; + x = b; + y = c; + z = d; + } + + +NX_INLINE void NxQuat::multiply(const NxQuat& left, const NxVec3& right) // this = a * b + { + NxReal a,b,c,d; + + a = - left.x*right.x - left.y*right.y - left.z *right.z; + b = left.w*right.x + left.y*right.z - right.y*left.z; + c = left.w*right.y + left.z*right.x - right.z*left.x; + d = left.w*right.z + left.x*right.y - right.x*left.y; + + w = a; + x = b; + y = c; + z = d; + } + +NX_INLINE void NxQuat::slerp(const NxReal t, const NxQuat& left, const NxQuat& right) // this = slerp(t, a, b) + { + const NxReal quatEpsilon = (NxReal(1.0e-8f)); + + *this = left; + + NxReal cosine = + x * right.x + + y * right.y + + z * right.z + + w * right.w; //this is left.dot(right) + + NxReal sign = NxReal(1); + if (cosine < 0) + { + cosine = - cosine; + sign = NxReal(-1); + } + + NxReal Sin = NxReal(1) - cosine*cosine; + + if(Sin>=quatEpsilon*quatEpsilon) + { + Sin = NxMath::sqrt(Sin); + const NxReal angle = NxMath::atan2(Sin, cosine); + const NxReal i_sin_angle = NxReal(1) / Sin; + + + + NxReal lower_weight = NxMath::sin(angle*(NxReal(1)-t)) * i_sin_angle; + NxReal upper_weight = NxMath::sin(angle * t) * i_sin_angle * sign; + + w = (w * (lower_weight)) + (right.w * (upper_weight)); + x = (x * (lower_weight)) + (right.x * (upper_weight)); + y = (y * (lower_weight)) + (right.y * (upper_weight)); + z = (z * (lower_weight)) + (right.z * (upper_weight)); + } + } + + +NX_INLINE void NxQuat::rotate(NxVec3 & v) const //rotates passed vec by rot expressed by quaternion. overwrites arg ith the result. + { + //NxReal msq = NxReal(1.0)/magnitudeSquared(); //assume unit quat! + NxQuat myInverse; + myInverse.x = -x;//*msq; + myInverse.y = -y;//*msq; + myInverse.z = -z;//*msq; + myInverse.w = w;//*msq; + + //v = ((*this) * v) ^ myInverse; + + NxQuat left; + left.multiply(*this,v); + v.x =left.w*myInverse.x + myInverse.w*left.x + left.y*myInverse.z - myInverse.y*left.z; + v.y =left.w*myInverse.y + myInverse.w*left.y + left.z*myInverse.x - myInverse.z*left.x; + v.z =left.w*myInverse.z + myInverse.w*left.z + left.x*myInverse.y - myInverse.x*left.y; + } + + +NX_INLINE void NxQuat::inverseRotate(NxVec3 & v) const //rotates passed vec by opposite of rot expressed by quaternion. overwrites arg ith the result. + { + //NxReal msq = NxReal(1.0)/magnitudeSquared(); //assume unit quat! + NxQuat myInverse; + myInverse.x = -x;//*msq; + myInverse.y = -y;//*msq; + myInverse.z = -z;//*msq; + myInverse.w = w;//*msq; + + //v = (myInverse * v) ^ (*this); + NxQuat left; + left.multiply(myInverse,v); + v.x =left.w*x + w*left.x + left.y*z - y*left.z; + v.y =left.w*y + w*left.y + left.z*x - z*left.x; + v.z =left.w*z + w*left.z + left.x*y - x*left.y; + } + + +NX_INLINE NxQuat& NxQuat::operator= (const NxQuat& q) + { + x = q.x; + y = q.y; + z = q.z; + w = q.w; + return *this; + } + +#if 0 +NX_INLINE NxQuat& NxQuat::operator= (const NxVec3& v) //implicitly extends vector by a 0 w element. + { + x = v.x; + y = v.y; + z = v.z; + w = NxReal(1.0); + return *this; + } +#endif + +NX_INLINE NxQuat& NxQuat::operator*= (const NxQuat& q) + { + NxReal xx[4]; //working Quaternion + xx[0] = w*q.w - q.x*x - y*q.y - q.z*z; + xx[1] = w*q.x + q.w*x + y*q.z - q.y*z; + xx[2] = w*q.y + q.w*y + z*q.x - q.z*x; + z=w*q.z + q.w*z + x*q.y - q.x*y; + + w = xx[0]; + x = xx[1]; + y = xx[2]; + return *this; + } + + +NX_INLINE NxQuat& NxQuat::operator+= (const NxQuat& q) + { + x+=q.x; + y+=q.y; + z+=q.z; + w+=q.w; + return *this; + } + + +NX_INLINE NxQuat& NxQuat::operator-= (const NxQuat& q) + { + x-=q.x; + y-=q.y; + z-=q.z; + w-=q.w; + return *this; + } + + +NX_INLINE NxQuat& NxQuat::operator*= (const NxReal s) + { + x*=s; + y*=s; + z*=s; + w*=s; + return *this; + } + +NX_INLINE NxQuat::NxQuat(NxReal ix, NxReal iy, NxReal iz, NxReal iw) +{ + x = ix; + y = iy; + z = iz; + w = iw; +} + +NX_INLINE NxQuat NxQuat::operator*(const NxQuat &q) const +{ + return NxQuat(w*q.x + q.w*x + y*q.z - q.y*z, + w*q.y + q.w*y + z*q.x - q.z*x, + w*q.z + q.w*z + x*q.y - q.x*y, + w*q.w - x*q.x - y*q.y - z*q.z); +} + +NX_INLINE NxQuat NxQuat::operator+(const NxQuat &q) const +{ + return NxQuat(x+q.x,y+q.y,z+q.z,w+q.w); +} + +NX_INLINE NxQuat NxQuat::operator-(const NxQuat &q) const +{ + return NxQuat(x-q.x,y-q.y,z-q.z,w-q.w); +} + +NX_INLINE NxQuat NxQuat::operator!() const +{ + return NxQuat(-x,-y,-z,w); +} + + + +NX_INLINE const NxVec3 NxQuat::rot(const NxVec3 &v) const + { + NxVec3 qv(x,y,z); + + return (v*(w*w-0.5f) + (qv^v)*w + qv*(qv|v))*2; + } + +NX_INLINE const NxVec3 NxQuat::invRot(const NxVec3 &v) const + { + NxVec3 qv(x,y,z); + + return (v*(w*w-0.5f) - (qv^v)*w + qv*(qv|v))*2; + } + + + +NX_INLINE const NxVec3 NxQuat::transform(const NxVec3 &v, const NxVec3 &p) const + { + return rot(v)+p; + } + +NX_INLINE const NxVec3 NxQuat::invTransform(const NxVec3 &v, const NxVec3 &p) const + { + return invRot(v-p); + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxQuickSort.h b/libraries/external/physx/Win32/include/PX/NxQuickSort.h new file mode 100755 index 0000000..98d4c52 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxQuickSort.h @@ -0,0 +1,115 @@ +#ifndef NX_FOUNDATION_NXQUICKSORT +#define NX_FOUNDATION_NXQUICKSORT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +/** +\brief Sorts an array of Sortables or an array of pointers to Sortables. + +(the second tends to be much faster) +In the first case Predicate is simply: + +class SortableCompareDirect + { + public: + inline bool operator () (const Sortable &a, const Sortable & b) + { + return a < b; + } + }; +In the second case it should include the dereference: + +class SortableComparePtr + { + public: + inline bool operator () (const Sortable *a, const Sortable * b) + { + return (*a) < (*b); + } + }; + +Where it is assumed that Sortable implements the compare operator: + +class SortElem + { + public: + int sortKey; + + .... + + inline bool operator <(const SortElem & e) const + { + return sortKey < e.sortKey; + } + }; + +This is not used by the below code directly, only the example +predicates above. + +Called like this: +std::vector sortVector; +NxQuickSort(&sortVector[0], &sortVector[sortVector.size()-1]); + +//faster if SortElem is a large object, otherwise its about the same: +std::vector sortPtrVector; +NxQuickSort(&sortPtrVector[0], &sortPtrVector[sortPtrVector.size()-1]); +*/ +template +inline void NxQuickSort(Sortable * start, Sortable * end) + { + static Predicate p; + Sortable * i; + Sortable * j; + Sortable m; + + do + { + i = start; + j = end; + m = *(i + ((j - i) >> 2)); + + while (i <= j) + { + while(p(*i,m)) + i++; + while(p(m,*j)) + j--; + if (i <= j) + { + if (i != j) + { + Sortable k = *i; + *i = *j; + *j = k; + } + i++; + j--; + } + } + if (start < j) + NxQuickSort(start, j); + + start = i; + } + while (i < end); //we do this instead of recursing: + +// if (i < end) +// NxQuickSortIterate(i, end); + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxRay.h b/libraries/external/physx/Win32/include/PX/NxRay.h new file mode 100755 index 0000000..9694ef9 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxRay.h @@ -0,0 +1,98 @@ +#ifndef NX_FOUNDATION_NXRAY +#define NX_FOUNDATION_NXRAY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxVec3.h" + +class NxRay; + +/** +\brief Represents an infinite ray as an origin and direction. + +The direction should be normalized. +*/ +class NxRay + { + public: + /** + Constructor + */ + NX_INLINE NxRay() + { + } + + /** + Constructor + */ + NX_INLINE NxRay(const NxVec3& _orig, const NxVec3& _dir) : orig(_orig), dir(_dir) + { + } + + /** + Destructor + */ + NX_INLINE ~NxRay() + { + } +#ifdef FOUNDATION_EXPORTS + + NX_INLINE NxF32 distanceSquared(const NxVec3& point, NxF32* t=NULL) const + { + return NxComputeDistanceSquared(*this, point, t); + } + + NX_INLINE NxF32 distance(const NxVec3& point, NxF32* t=NULL) const + { + return sqrtf(distanceSquared(point, t)); + } +#endif + + NxVec3 orig; //!< Ray origin + NxVec3 dir; //!< Normalized direction + }; + + NX_INLINE void ComputeReflexionVector(NxVec3& reflected, const NxVec3& incoming_dir, const NxVec3& outward_normal) + { + reflected = incoming_dir - outward_normal * 2.0f * incoming_dir.dot(outward_normal); + } + + NX_INLINE void ComputeReflexionVector(NxVec3& reflected, const NxVec3& source, const NxVec3& impact, const NxVec3& normal) + { + NxVec3 V = impact - source; + reflected = V - normal * 2.0f * V.dot(normal); + } + + NX_INLINE void ComputeNormalCompo(NxVec3& normal_compo, const NxVec3& outward_dir, const NxVec3& outward_normal) + { + normal_compo = outward_normal * outward_dir.dot(outward_normal); + } + + NX_INLINE void ComputeTangentCompo(NxVec3& outward_dir, const NxVec3& outward_normal) + { + outward_dir -= outward_normal * outward_dir.dot(outward_normal); + } + + NX_INLINE void DecomposeVector(NxVec3& normal_compo, NxVec3& tangent_compo, const NxVec3& outward_dir, const NxVec3& outward_normal) + { + normal_compo = outward_normal * outward_dir.dot(outward_normal); + tangent_compo = outward_dir - normal_compo; + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxRemoteDebugger.h b/libraries/external/physx/Win32/include/PX/NxRemoteDebugger.h new file mode 100755 index 0000000..aa4d5b8 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxRemoteDebugger.h @@ -0,0 +1,419 @@ +#ifndef NX_FOUNDATION_NXREMOTEDEBUGGER +#define NX_FOUNDATION_NXREMOTEDEBUGGER +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** \addtogroup foundation +@{ +*/ + + +// ---- Groups - Use these when calling NX_DBG macros ---- +// Basic object +#define NX_DBG_EVENTGROUP_BASIC_OBJECTS 0x00000001 +#define NX_DBG_EVENTGROUP_BASIC_OBJECTS_DYNAMIC_DATA 0x00000002 +#define NX_DBG_EVENTGROUP_BASIC_OBJECTS_STATIC_DATA 0x00000004 + +// Joints +#define NX_DBG_EVENTGROUP_JOINTS 0x00000008 +#define NX_DBG_EVENTGROUP_JOINTS_DATA 0x00000010 + +// Contacts +#define NX_DBG_EVENTGROUP_CONTACTS 0x00000020 +#define NX_DBG_EVENTGROUP_CONTACTS_DATA 0x00000040 + +// Triggers +#define NX_DBG_EVENTGROUP_TRIGGERS 0x00000080 + +// Profiling +#define NX_DBG_EVENTGROUP_PROFILING 0x00000100 + +// Cloth +#define NX_DBG_EVENTGROUP_CLOTH 0x00000200 +#define NX_DBG_EVENTGROUP_CLOTH_DYNAMIC_DATA 0x00000400 +#define NX_DBG_EVENTGROUP_CLOTH_STATIC_DATA 0x00000800 + +// Soft body +#define NX_DBG_EVENTGROUP_SOFTBODY 0x00001000 +#define NX_DBG_EVENTGROUP_SOFTBODY_DYNAMIC_DATA 0x00002000 +#define NX_DBG_EVENTGROUP_SOFTBODY_STATIC_DATA 0x00004000 + +// Fluid +#define NX_DBG_EVENTGROUP_FLUID 0x00008000 +#define NX_DBG_EVENTGROUP_FLUID_DYNAMIC_DATA 0x00010000 +#define NX_DBG_EVENTGROUP_FLUID_STATIC_DATA 0x00020000 + +// ---- Masks - Use these when calling connect +#define NX_DBG_EVENTMASK_EVERYTHING 0xFFFFFFFF + +// Basic object +#define NX_DBG_EVENTMASK_BASIC_OBJECTS (NX_DBG_EVENTGROUP_BASIC_OBJECTS) +#define NX_DBG_EVENTMASK_BASIC_OBJECTS_DYNAMIC_DATA (NX_DBG_EVENTGROUP_BASIC_OBJECTS | NX_DBG_EVENTGROUP_BASIC_OBJECTS_DYNAMIC_DATA) +#define NX_DBG_EVENTMASK_BASIC_OBJECTS_STATIC_DATA (NX_DBG_EVENTGROUP_BASIC_OBJECTS | NX_DBG_EVENTGROUP_BASIC_OBJECTS_STATIC_DATA) +#define NX_DBG_EVENTMASK_BASIC_OBJECTS_ALL_DATA (NX_DBG_EVENTMASK_BASIC_OBJECTS_DYNAMIC_DATA | NX_DBG_EVENTMASK_BASIC_OBJECTS_STATIC_DATA) + +// Joints +#define NX_DBG_EVENTMASK_JOINTS (NX_DBG_EVENTGROUP_JOINTS | NX_DBG_EVENTMASK_BASIC_OBJECTS) +#define NX_DBG_EVENTMASK_JOINTS_DATA (NX_DBG_EVENTGROUP_JOINTS | NX_DBG_EVENTGROUP_JOINTS_DATA |NX_DBG_EVENTMASK_BASIC_OBJECTS) + +// Contacts +#define NX_DBG_EVENTMASK_CONTACTS (NX_DBG_EVENTGROUP_CONTACTS | NX_DBG_EVENTMASK_BASIC_OBJECTS) +#define NX_DBG_EVENTMASK_CONTACTS_DATA (NX_DBG_EVENTGROUP_CONTACTS | NX_DBG_EVENTGROUP_CONTACTS_DATA | NX_DBG_EVENTMASK_BASIC_OBJECTS) + +// Triggers +#define NX_DBG_EVENTMASK_TRIGGERS (NX_DBG_EVENTGROUP_TRIGGERS) + +// Profiling +#define NX_DBG_EVENTMASK_PROFILING (NX_DBG_EVENTGROUP_PROFILING) + +// Cloth +#define NX_DBG_EVENTMASK_CLOTH (NX_DBG_EVENTGROUP_CLOTH) +#define NX_DBG_EVENTMASK_CLOTH_DYNAMIC_DATA (NX_DBG_EVENTGROUP_CLOTH | NX_DBG_EVENTGROUP_CLOTH_DYNAMIC_DATA) +#define NX_DBG_EVENTMASK_CLOTH_STATIC_DATA (NX_DBG_EVENTGROUP_CLOTH | NX_DBG_EVENTGROUP_CLOTH_STATIC_DATA) +#define NX_DBG_EVENTMASK_CLOTH_ALL_DATA (NX_DBG_EVENTMASK_CLOTH_DYNAMIC_DATA | NX_DBG_EVENTMASK_CLOTH_STATIC_DATA) + +// Fluid +#define NX_DBG_EVENTMASK_FLUID (NX_DBG_EVENTGROUP_FLUID) +#define NX_DBG_EVENTMASK_FLUID_DYNAMIC_DATA (NX_DBG_EVENTGROUP_FLUID | NX_DBG_EVENTGROUP_FLUID_DYNAMIC_DATA) +#define NX_DBG_EVENTMASK_FLUID_STATIC_DATA (NX_DBG_EVENTGROUP_FLUID | NX_DBG_EVENTGROUP_FLUID_STATIC_DATA) +#define NX_DBG_EVENTMASK_FLUID_ALL_DATA (NX_DBG_EVENTMASK_FLUID_DYNAMIC_DATA | NX_DBG_EVENTMASK_FLUID_STATIC_DATA) + +#define NX_DBG_DEFAULT_PORT 5425 + +enum NxRemoteDebuggerObjectType +{ + NX_DBG_OBJECTTYPE_GENERIC = 0, + NX_DBG_OBJECTTYPE_ACTOR = 1, + NX_DBG_OBJECTTYPE_PLANE = 2, + NX_DBG_OBJECTTYPE_BOX = 3, + NX_DBG_OBJECTTYPE_SPHERE = 4, + NX_DBG_OBJECTTYPE_CAPSULE = 5, + NX_DBG_OBJECTTYPE_CYLINDER = 6, + NX_DBG_OBJECTTYPE_CONVEX = 7, + NX_DBG_OBJECTTYPE_MESH = 8, + NX_DBG_OBJECTTYPE_WHEEL = 9, + NX_DBG_OBJECTTYPE_JOINT = 10, + NX_DBG_OBJECTTYPE_CONTACT = 11, + NX_DBG_OBJECTTYPE_BOUNDINGBOX = 12, + NX_DBG_OBJECTTYPE_VECTOR = 13, + NX_DBG_OBJECTTYPE_CAMERA = 14, + NX_DBG_OBJECTTYPE_CLOTH = 15, + NX_DBG_OBJECTTYPE_SOFTBODY = 16, + NX_DBG_OBJECTTYPE_FLUID = 17, +}; + +//#define NX_DISABLE_REMOTE_DEBUG + +#ifndef NX_DISABLE_REMOTE_DEBUG + +#include "PX/NxSimpleTypes.h" +#include "PX/NxPlane.h" +#include "PX/NxVec3.h" + +#ifdef CORELIB + +#define NX_DBG_IS_CONNECTED() (NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->isConnected()) +#define NX_DBG_FRAME_BREAK() NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->frameBreak(); +#define NX_DBG_CREATE_OBJECT(object, type, className, mask) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->createObject(object, type, className, mask); +#define NX_DBG_REMOVE_OBJECT(object, mask) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->removeObject(object, mask); +#define NX_DBG_ADD_CHILD(object, child, mask) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->addChild(object, child, mask); +#define NX_DBG_REMOVE_CHILD(object, child, mask) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->removeChild(object, child, mask); +#define NX_DBG_CREATE_PARAMETER(parameter, object, name, mask) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->writeParameter(parameter, object, true, name, mask); +#define NX_DBG_SET_PARAMETER(parameter, object, name, mask) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->writeParameter(parameter, object, false, name, mask); +#define NX_DBG_CREATE_SET_PARAMETER(parameter, object, name, mask, create) NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->writeParameter(parameter, object, create, name, mask); +#define NX_DBG_EVENTMASK() (NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->getMask()) +#define NX_DBG_FLUSH() NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->flush(); + +#else +#define NX_DBG_IS_CONNECTED() (NxGetFoundationSDK()->getRemoteDebugger()->isConnected()) +#define NX_DBG_FRAME_BREAK() NxGetFoundationSDK()->getRemoteDebugger()->frameBreak(); +#define NX_DBG_CREATE_OBJECT(object, type, className, mask) NxGetFoundationSDK()->getRemoteDebugger()->createObject(object, type, className, mask); +#define NX_DBG_REMOVE_OBJECT(object, mask) NxGetFoundationSDK()->getRemoteDebugger()->removeObject(object, mask); +#define NX_DBG_ADD_CHILD(object, child, mask) NxGetFoundationSDK()->getRemoteDebugger()->addChild(object, child, mask); +#define NX_DBG_REMOVE_CHILD(object, child, mask) NxGetFoundationSDK()->getRemoteDebugger()->removeChild(object, child, mask); +#define NX_DBG_CREATE_PARAMETER(parameter, object, name, mask) NxGetFoundationSDK()->getRemoteDebugger()->writeParameter(parameter, object, true, name, mask); +#define NX_DBG_SET_PARAMETER(parameter, object, name, mask) NxGetFoundationSDK()->getRemoteDebugger()->writeParameter(parameter, object, false, name, mask); +#define NX_DBG_CREATE_SET_PARAMETER(parameter, object, name, mask, create) NxGetFoundationSDK()->getRemoteDebugger()->writeParameter(parameter, object, create, name, mask); +#define NX_DBG_EVENTMASK() (NxGetFoundationSDK()->getRemoteDebugger()->getMask()) +#define NX_DBG_FLUSH() NxGetFoundationSDK()->getRemoteDebugger()->flush(); +#endif + +/** +An event listener that can be registered to listen to Visual Remote Debugger events. +*/ +class NxRemoteDebuggerEventListener +{ +public: + /** + This is called right after the SDK is connected to the Visual Remote Debugger application. + */ + virtual void onConnect() {}; + /** + This is called right before the SDK is disconnected from the Visual Remote Debugger application. + */ + virtual void onDisconnect() {}; + /** + This is called right before the event mask is changed. + */ + virtual void beforeMaskChange(NxU32 oldMask, NxU32 newMask) {}; + /** + This is called right after the event mask is changed. + */ + virtual void afterMaskChange(NxU32 oldMask, NxU32 newMask) {}; + +protected: + virtual ~NxRemoteDebuggerEventListener(){}; +}; + +/** +\brief Singleton class used to communicate with the Visual Remote Debugger. +Generally this class is only accessed through the NX_DBG_X macros. +*/ +class NxRemoteDebugger +{ +public: + /** + Connects the SDK to the Visual Remote Debugger application + + \param host The host name of the computer running the VRD, e.g. "localhost". + \param port The port that the VRD is listening to. + \param eventMask 32 bit mask used to filter information sent to the debugger, constructed from NX_DBG_EVENTMASK_X macros. + */ + virtual void connect(const char* host, unsigned int port = NX_DBG_DEFAULT_PORT, NxU32 eventMask = NX_DBG_EVENTMASK_EVERYTHING) = 0; + + /** + Disconnects the SDK from the Visual Remote Debugger application. + */ + virtual void disconnect() = 0; + + /** + Flushes the output stream, i.e. forces it to write/send any queued data. + */ + virtual void flush() = 0; + + /** + Returns whether the debugger is connected or not. + */ + virtual bool isConnected() = 0; + + /** + Write a frame break to the output stream. + */ + virtual void frameBreak() = 0; + + /** + Create an object in the output stream. + + \param object Object identifier, usually a pointer. + \param type Type of object to create. + \param className Class name of the object, e.g. "NxBox" or "PulseRifleBolt". + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void createObject(void *object, NxRemoteDebuggerObjectType type, const char *className, NxU32 mask) = 0; + + /** + Remove an object in the output stream. + + \param object Object identifier of the object to remove. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void removeObject(void *object, NxU32 mask) = 0; + + /** + Add an object as child to another object. + + \param object Object identifier of the parent. + \param child Object identifier of the child. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void addChild(void *object, void *child, NxU32 mask) = 0; + + /** + Remove a child object from another object. + + \param object Object identifier of the parent. + \param child Object identifier of the child. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void removeChild(void *object, void *child, NxU32 mask) = 0; + + /** + Write a real parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxReal ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write a NxU32 parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxU32 ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write a Vector parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxVec3 ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write a Plane parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxPlane ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write an NxMat34 parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxMat34 ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write an NxMat33 parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxMat33 ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write an NxU32 parameter to output stream. + + \param parameter Pointer to a binary chunk of data to write. The first 4 bytes + must be an NxU32 containing the data size, including those 4 size + bytes. The data is assumed to be of the same endianness as the output + stream. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const NxU8 *parameter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write a string parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const char *parameter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write a boolean parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const bool ¶meter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Write an object ID parameter to output stream. + + \param parameter The value to write. + \param object The object to write a parameter to. + \param create Must be true at parameter creation, and should be false for all consecutive writes of the same parameter for optimal stream size. + \param name Name of the parameter. + \param mask Event group mask that this event is contained in, e.g. NX_DBG_EVENTGROUP_JOINTS. + */ + virtual void writeParameter(const void *parameter, void *object, bool create, const char *name, NxU32 mask) = 0; + + /** + Sets the mask which is used to filter out events from the Visual Remote Debugger stream. + */ + virtual void setMask(NxU32 mask) = 0; + + /** + Returns the mask the Visual Remote Debugger stream is filtered with. + */ + virtual NxU32 getMask() = 0; + + /** + Returns the object that is currently picked by the debugger + */ + virtual void *getPickedObject() = 0; + + /** + Returns the current picking point in the debugger + */ + virtual NxVec3 getPickPoint() = 0; + + /** + Registers an event listener that will be notified of Visual Remote Debugger events (i.e. connect and disconnect events). + + \param eventListener The event listener to register. + */ + virtual void registerEventListener(NxRemoteDebuggerEventListener* eventListener) = 0; + + /** + Unregisters an event listener. + + \param eventListener The event listener to unregister. + */ + virtual void unregisterEventListener(NxRemoteDebuggerEventListener* eventListener) = 0; + +protected: + virtual ~NxRemoteDebugger(){}; +}; + +#else + +#define NX_DBG_FRAME_BREAK(mask) ((void) 0); +#define NX_DBG_CREATE_OBJECT(object, type, name, mask) ((void) 0); +#define NX_DBG_REMOVE_OBJECT(object, mask) ((void) 0); +#define NX_DBG_ADD_CHILD(object, child, mask) ((void) 0); +#define NX_DBG_REMOVE_CHILD(object, child, mask) ((void) 0); +#define NX_DBG_CREATE_PARAMETER(parameter, object, name, mask) ((void) 0); +#define NX_DBG_SET_PARAMETER(parameter, object, name, mask) ((void) 0); +#define NX_DBG_CREATE_SET_PARAMETER(parameter, object, name, mask, create) ((void) 0); +#define NX_DBG_IS_CONNECTED() (false) +#define NX_DBG_EVENTMASK() (0) +#define NX_DBG_FLUSH() ((void) 0); + +#endif // NX_DISABLE_REMOTE_DEBUG + +/** @} */ +#endif // NX_FOUNDATION_NXREMOTEDEBUGGER +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxRevoluteJoint.h b/libraries/external/physx/Win32/include/PX/NxRevoluteJoint.h new file mode 100755 index 0000000..65d1d9a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxRevoluteJoint.h @@ -0,0 +1,359 @@ +#ifndef NX_PHYSICS_NXHINGEJOINT +#define NX_PHYSICS_NXHINGEJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +#include "PX/NxJoint.h" +#include "PX/NxRevoluteJointDesc.h" + +static const NxReal NX_NO_LOW_LIMIT = -16; +static const NxReal NX_NO_HIGH_LIMIT = 16; + + +/** + +\brief A joint which behaves in a similar way to a hinge or axel. + + A hinge joint removes all but a single rotational degree of freedom from two objects. + The axis along which the two bodies may rotate is specified with a point and a direction + vector. + + \image html revoluteJoint.png + +

Creation

+ + Example: + + \include NxRevoluteJoint_Create.cpp + + A revolute joint can be given a motor, so that it can apply a force to rotate the attached actors. + + Example: + + \include NxRevoluteJoint_Motor.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxRevoluteJointDesc NxScene.createJoint() NxJoint +*/ +class NxRevoluteJoint : public NxJoint + { + public: + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveToDesc() NxRevoluteJointDesc + */ + virtual void loadFromDesc(const NxRevoluteJointDesc& desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct . + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadFromDesc() NxRevoluteJointDesc + */ + virtual void saveToDesc(NxRevoluteJointDesc& desc) = 0; + + /** + \brief Sets angular joint limits. + + If either of these limits are set, any planar limits in NxJoint are ignored. + The limits are angles defined the same way as the values getAngle() returns. + + The following has to hold: + - Pi < lowAngle < highAngle < Pi + Both limits are disabled by default. + + Also sets coefficients of restitutions for the low and high angular limits. + These settings are only used if valid limits are set using setLimits(). + These restitution coefficients work the same way as for contacts. + + The coefficient of restitution determines whether a collision with the joint limit is + completely elastic (like pool balls, restitution = 1, no energy is lost in the collision), + completely inelastic (like putty, restitution = 0, no rebound after collision) or + somewhere in between. The default is 0 for both. + + This automatically enables the limit. + + \param[in] pair The new joint limit settings. Range: See #NxJointLimitPairDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitDesc NxJointLimitPairDesc getLimits() + */ + virtual void setLimits(const NxJointLimitPairDesc & pair) = 0; + + /** + \brief Retrieves the joint limits. + + Returns true if it is enabled. + + Also returns the limit restitutions. + + \param[in] pair Used to retrieve the joint limit settings. + \return True if the limit is enabled. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLimits() NxJointLimitPairDesc NxJointLimitDesc + */ + virtual bool getLimits(NxJointLimitPairDesc & pair) = 0; + + /** + \brief Sets motor parameters for the joint. + + The motor rotates the bodies relative to each other along the hinge axis. The motor has these parameters: + +
    +
  • velTarget - the relative velocity the motor is trying to achieve. The motor will only be able + to reach this velocity if the maxForce is sufficiently large. If the joint is + spinning faster than this velocity, the motor will actually try to brake. If you set this + to infinity then the motor will keep speeding up, unless there is some sort of resistance + on the attached bodies. The sign of this variable determines the rotation direction, + with positive values going the same way as positive joint angles. + Default is infinity.
  • +
  • maxForce - the maximum force (torque in this case) the motor can exert. Zero disables the motor. + Default is 0, should be >= 0. Setting this to a very large value if velTarget is also + very large may not be a good idea.
  • +
  • freeSpin - if this flag is set, and if the joint is spinning faster than velTarget, then neither + braking nor additional acceleration will result. + default: false.
  • +
+ + This automatically enables the motor. + + \param[in] motorDesc The new motor parameters for the joint. Range: See #NxMotorDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMotorDesc getMotor() + */ + virtual void setMotor(const NxMotorDesc &motorDesc) = 0; + + /** + \brief Reads back the motor parameters. + + Returns true if it is enabled. + + \param[out] motorDesc Used to store the motor parameters of the joint. See #NxMotorDesc + \return True if the motor is enabled. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setMotor() NxMotorDesc + */ + virtual bool getMotor(NxMotorDesc &motorDesc) = 0; + + /** + \brief Sets spring parameters. + + The spring is implicitly integrated so no instability should result for arbitrary + spring and damping constants. Using these settings together with a motor is not possible -- the motor will have + priority and the spring settings are ignored. + If you would like to simulate your motor's internal friction, do this by altering the motor parameters directly. + + spring - The rotational spring acts along the hinge axis and tries to force + the joint angle to zero. A setting of zero disables the spring. Default is 0, should be >= 0. + damper - Damping coefficient; acts against the hinge's angular velocity. A setting of zero disables + the damping. The default is 0, should be >= 0. + targetValue - The angle at which the spring is relaxed. In [-Pi,Pi]. Default is 0. + + This automatically enables the spring. + + \param[in] springDesc The new spring parameters for the joint. Range: See #NxSpringDesc. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSpring() NxSpringDesc + */ + virtual void setSpring(const NxSpringDesc &springDesc) = 0; + + /** + \brief Retrieves spring settings. + + Returns true if it is enabled. + + @see setSpring + + \param[out] springDesc Used to retrieve the spring parameters for the joint. See #NxSpringDesc. + \return True if the spring is enabled. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringDesc setSpring() + */ + virtual bool getSpring(NxSpringDesc &springDesc) = 0; + + /** + \brief Retrieves the current revolute joint angle. + + The relative orientation of the bodies is stored when the joint is created, or when setAxis() + or setAnchor() is called. + This initial orientation returns an angle of zero, and joint angles are measured + relative to this pose. + The angle is in the range [-Pi, Pi], with positive angles CCW around the axis, measured + from body2 to body1. + + Unit: Radians + Range: [-PI,PI] + + \return The current hinge angle. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getVelocity() + */ + virtual NxReal getAngle() = 0; + + /** + \brief Retrieves the revolute joint angle's rate of change (angular velocity). + + It is the angular velocity of body1 minus body2 projected along the axis. + + \return The hinge velocity. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getAngle() + */ + virtual NxReal getVelocity() = 0; + + /** + \brief Sets the flags to enable/disable the spring/motor/limit. + + This is a combination of the ::NxRevoluteJointFlag bits. + + \param[in] flags A combination of NxRevoluteJointFlag flags to set for this joint + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxRevoluteJointFlag getFlags() + */ + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief Retrieve the revolute joints flags. + + \return the current flag settings. See #NxRevoluteJointFlag + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFlags() NxRevoluteJointFlag + */ + virtual NxU32 getFlags() = 0; + + /** + \brief Sets the joint projection mode. + + \param[in] projectionMode The new projection mode. See #NxJointProjectionMode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getProjectionMode() NxJointProjectionMode NxRevoluteJointDesc.projectionMode + */ + virtual void setProjectionMode(NxJointProjectionMode projectionMode) = 0; + + /** + \brief Retrieves the joints projection mode. + + \return the current flag settings. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setProjectionMode() NxJointProjectionMode NxRevoluteJointDesc.projectionMode + */ + virtual NxJointProjectionMode getProjectionMode() = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxRevoluteJointDesc.h b/libraries/external/physx/Win32/include/PX/NxRevoluteJointDesc.h new file mode 100755 index 0000000..bafd1f3 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxRevoluteJointDesc.h @@ -0,0 +1,173 @@ +#ifndef NX_PHYSICS_NXHINGEJOINTDESC +#define NX_PHYSICS_NXHINGEJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointDesc.h" +#include "PX/NxJointLimitPairDesc.h" +#include "PX/NxSpringDesc.h" +#include "PX/NxMotorDesc.h" + +/** +\brief Desc class for #NxRevoluteJoint. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxRevoluteJoint +*/ +class NxRevoluteJointDesc : public NxJointDesc + { + public: + /** + \brief Optional limits for the angular motion of the joint. + + Range: See #NxJointLimitPairDesc
+ Default: See #NxJointLimitPairDesc + + @see NxJointLimitPairDesc NxJointLimitDesc NxRevoluteJointFlag + */ + NxJointLimitPairDesc limit; + + /** + \brief Optional motor. + + Range: See #NxMotorDesc
+ Default: See #NxMotorDesc + + @see NxMotorDesc NxRevoluteJointFlag + */ + NxMotorDesc motor; + + /** + \brief Optional spring. + + Range: See #NxSpringDesc
+ Default: See #NxSpringDesc + + @see NxSpringDesc NxRevoluteJointFlag + */ + NxSpringDesc spring; + + /** + \brief The distance beyond which the joint is projected. + + projectionMode is NX_JPM_POINT_MINDIST, the joint gets artificially projected together when it drifts more than this distance. Sometimes it is not possible to project (for example when the joints form a cycle) + Should be nonnegative. However, it may be a bad idea to always project to a very small or zero distance because the solver *needs* some error in order to produce correct motion. + + Range: [0,inf)
+ Default: 1.0 + + @see projectionMode projectionAngle + */ + NxReal projectionDistance; + + /** + \brief The angle beyond which the joint is projected. + + This similar to #projectionDistance, except this is an angle (in radians) to which angular drift is + projected. + + Unit: Radians + Range: (0.2,PI)
+ Default: 0.0872 (about 5 degrees in radians) + + @see projectionDistance projectionMode + */ + NxReal projectionAngle; + + /** + \brief This is a combination of the bits defined by ::NxRevoluteJointFlag. + + Default: 0 + + @see NxRevoluteJointFlag + */ + NxU32 flags; + + /** + \brief use this to enable joint projection + + Default: NX_JPM_NONE + + @see NxJointProjectionMode projectionDistance projectionAngle NxRevoluteJoint.setProjectionMode() + */ + NxJointProjectionMode projectionMode; + + /** + \brief constructor sets to default. + */ + + NX_INLINE NxRevoluteJointDesc(); + /** + \brief (re)sets the structure to the default. + + \param[in] fromCtor Avoid redundant work if called from constructor. + */ + NX_INLINE void setToDefault(bool fromCtor = false); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + }; + +NX_INLINE NxRevoluteJointDesc::NxRevoluteJointDesc() : NxJointDesc(NX_JOINT_REVOLUTE) //constructor sets to default + { + setToDefault(true); + } + +NX_INLINE void NxRevoluteJointDesc::setToDefault(bool fromCtor) + { + NxJointDesc::setToDefault(); + projectionDistance = 1.0f; + projectionAngle = 0.0872f; //about 5 degrees in radians. + + if (!fromCtor) + { + limit.setToDefault(); + motor.setToDefault(); + spring.setToDefault(); + } + + flags = 0; + projectionMode = NX_JPM_NONE; + } + +NX_INLINE bool NxRevoluteJointDesc::isValid() const + { + if (projectionDistance < 0.0f) return false; + if (projectionAngle < 0.02f) return false; //if its smaller then current algo gets too close to a singularity. + + + if (!limit.isValid()) return false; + if (!motor.isValid()) return false; + if (!spring.isValid()) return false; + + + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxScene.h b/libraries/external/physx/Win32/include/PX/NxScene.h new file mode 100755 index 0000000..4861d31 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxScene.h @@ -0,0 +1,3381 @@ +#ifndef NX_PHYSICS_NX_SCENE +#define NX_PHYSICS_NX_SCENE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxUserRaycastReport.h" +#include "PX/NxUserEntityReport.h" +#include "PX/NxSceneQuery.h" +#include "PX/NxSceneDesc.h" +#include "PX/NxSceneStats.h" +#include "PX/NxSceneStats2.h" +#include "PX/NxArray.h" +#include "PX/NxProfiler.h" +#if NX_USE_FLUID_API +#include "PX/fluids/NxFluid.h" +class NxUserFluidContactReport; +#endif + +#if NX_USE_CLOTH_API +#include "PX/cloth/NxCloth.h" +#include "PX/cloth/NxClothMesh.h" +#endif + +#if NX_USE_SOFTBODY_API +#include "PX/softbody/NxSoftBody.h" +#include "PX/softbody/NxSoftBodyMesh.h" +#endif + +class NxActor; +class NxActorDescBase; +class NxJoint; +class NxJointDesc; +class NxEffector; +class NxEffectorDesc; +class NxSpringAndDamperEffector; +class NxSpringAndDamperEffectorDesc; +class NxMaterialDesc; +class NxMaterial; +class NxUserNotify; +class NxUserTriggerReport; +class NxUserContactReport; +class NxThread; +class NxTriangle; +class NxDebugRenderable; +class NxCompartment; +class NxCompartmentDesc; +class NxPhysicsSDK; + +class NxForceField; +class NxForceFieldDesc; +class NxForceFieldLinearKernel; +class NxForceFieldLinearKernelDesc; +class NxForceFieldShapeGroup; +class NxForceFieldShapeGroupDesc; + +/** +\brief Struct used by NxScene::getPairFlagArray(). + +The high bit of each 32 bit flag field denotes whether a pair is a shape or an actor pair. +The flags are defined by the enum NxContactPairFlag. + +@see NxScene.getPairFlagArray +*/ +class NxPairFlag + { + public: + void* objects[2]; + NxU32 flags; + + NX_INLINE NxU32 isActorPair() const { return flags & 0x80000000; } + }; + + +/** +\brief Enum describing synchronization conditions. +*/ +enum NxStandardFences + { + NX_FENCE_RUN_FINISHED, + /*NX_SYNC_RAYCAST_FINISHED,*/ + NX_NUM_STANDARD_FENCES, + }; + +/** + enum to check if a certain part of the SDK has finished. + used in: + bool checkResults(NxSimulationStatus, bool block = false) + bool fetchResults(NxSimulationStatus, bool block = false) + + @see NxScene.checkResults() NxScene.fetchResults() +*/ +enum NxSimulationStatus + { + /** + \brief Refers to the primary scene and all compartments having finished, the new results being readable, and everything being writeable. + */ + NX_RIGID_BODY_FINISHED = (1<<0), + NX_ALL_FINISHED = (1<<0), //an alias as the above is misnomer + /** + \brief Refers to the primary scene having finished. The scene will still be locked for writing until you call fetchResults(NX_RIGID_BODY_FINISHED). + */ + NX_PRIMARY_FINISHED = (1<<1), + }; + +/** +\brief Polling result for SDK managed threading. + +@see NxScene.pollForWork() +*/ +enum NxThreadPollResult + { + /** + \brief There is no work to execute at the time the function was called. + */ + NX_THREAD_NOWORK = 0, + + /** + \brief There may be more work waiting for execution. + */ + NX_THREAD_MOREWORK = 1, + + /** + \brief The function returned because the simulation tick finished. + */ + NX_THREAD_SIMULATION_END = 2, + + /** + \brief The function returned because the user call shutdownWorkerThreads() + + When the user calls NxScene.shutdownWorkerThreads() the SDK releases all blocked threads. + Threads which are released return NX_THREAD_SHUTDOWN. + */ + NX_THREAD_SHUTDOWN = 3, + + NX_THREAD_FORCE_DWORD = 0x7fffffff, + }; + +enum NxThreadWait + { + /** + \brief The poll function will return immediately if there is no work available. + + Valid for pollForWork() and pollForBackgroundWork() + + @see NxScene.pollForWork() NxScene.pollForBackgroundWork() + */ + NX_WAIT_NONE = 0, + + /** + \brief The poll function will wait until the end of the simulation tick for work. + + Valid for pollForWork() + + @see NxScene.pollForWork() + */ + NX_WAIT_SIMULATION_END = 1, + + /** + \brief Wait until NxScene.shutdownWorkerThreads() is called. + + @see NxScene.shutdownWorkerThreads + */ + NX_WAIT_SHUTDOWN = 2, + + NX_WAIT_FORCE_DWORD = 0x7fffffff, + }; + +#if NX_SUPPORT_SWEEP_API +enum NxSweepFlags + { + NX_SF_STATICS = (1<<0), //!< Sweep vs static objects + NX_SF_DYNAMICS = (1<<1), //!< Sweep vs dynamic objects + NX_SF_ASYNC = (1<<2), //!< Asynchronous sweeps (else synchronous) (Note: Currently disabled) + NX_SF_ALL_HITS = (1<<3), //!< Reports all hits rather than just closest hit + + NX_SF_DEBUG_SM = (1<<5), //!< DEBUG - temp - don't use + NX_SF_DEBUG_ET = (1<<6), //!< DEBUG - temp - don't use + }; + +/** + \brief Struct used with the Sweep API. + Related methods: NxScene::linearOBBSweep(), NxScene::linearCapsuleSweep(), + NxActor::linearSweep(). + + @see NxScene, NxActor + */ +struct NxSweepQueryHit + { + NxF32 t; //!< Distance to hit expressed as a percentage of the source motion vector ([0,1] coeff) + NxShape* hitShape; //!< Hit shape + NxShape* sweepShape; //!< Only nonzero when using NxActor::linearSweep. Shape from NxActor that hits the hitShape. + void* userData; //!< User-defined data + NxU32 internalFaceID; //!< ID of touched triangle (internal) + NxU32 faceID; //!< ID of touched triangle (external) + NxVec3 point; //!< World-space impact point + NxVec3 normal; //!< World-space impact normal + }; + + class NxSweepCache; +#endif + + +/** + \brief Data struct for use with Active Transform Notification. + Used with NxScene::getActiveTransforms(). + + @see NxScene +*/ +struct NxActiveTransform +{ + NxActor* actor; //!< Affected actor + void* userData; //!< User data of the actor + NxMat34 actor2World; //!< Actor-to-world transform of the actor +}; + + +/** +\brief Names for a number of profile zones that should always be available. Can be used with NxProfileData::getNamedZone() + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: No +*/ +enum NxProfileZoneName + { + NX_PZ_CLIENT_FRAME, //!< Clock start is in client thread, just before scene thread was kicked off; clock end is when client calls fetchResults(). + NX_PZ_CPU_SIMULATE, //!< Maximum time of simulation thread ((Nf)Scene::simulate(NxU32)), over all CPU scenes inside the NxScene. + NX_PZ_PPU0_SIMULATE, //!< Maximum time of simulation thread over all PPU# scenes inside the NxScene. + NX_PZ_PPU1_SIMULATE, + NX_PZ_PPU2_SIMULATE, + NX_PZ_PPU3_SIMULATE, + NX_PZ_TOTAL_SIMULATION = 0x10, //!< Clock start is in client thread, just before scene thread was kicked off; clock end is in simulation thread when it finishes. + }; + + +/** +\brief Array of profiling data. + + profileZones points to an array of numZones profile zones. Zones are sorted such that the parent zones always come before their children. + Some zones have multiple parents (code called from multiple places) in which case only the relationship to the first parent is displayed. + returned by NxScene::readProfileData(). +*/ +class NxProfileData : public NxProfilerData + { + protected: + NX_INLINE NxProfileData() {} + virtual ~NxProfileData(){} + + public: + /** + \brief Returns some named profile zones. + + Note: though copies of these named zones do appear in the above array, this function may + return pointers to objects not included above. May return NULL if the zone is not available. + */ + virtual const NxProfileZone * getNamedZone(NxProfileZoneName) const = 0; + }; + +/** + \brief A scene is a collection of bodies, constraints, and effectors which can interact. + + The scene simulates the behavior of these objects over time. Several scenes may exist + at the same time, but each body, constraint, or effector object is specific to a scene + -- they may not be shared. + + For example, attempting to create a joint in one scene and then using it to attach + bodies from a different scene results in undefined behavior. + +

Creation

+ + Example: + + \include NxScene_Create.cpp + + @see NxSceneDesc NxPhysicsSDK.createScene() NxPhysicsSDK.releaseScene() +*/ +class NxScene + { + protected: + NxScene(): userData(0), extLink(0) {} + virtual ~NxScene() {} + + public: + + + /** + \brief Saves the Scene descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneDesc + */ + virtual bool saveToDesc(NxSceneDesc& desc) const = 0; + + /** + \brief Get the scene flags. + + \return The scene flags. See #NxSceneFlags + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneFlags + */ + virtual NxU32 getFlags() const = 0; + + /** + \brief Get the simulation type. + + \return The simulation type. See #NxSimulationType + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: No + + @see NxSceneDesc.simType + */ + virtual NxSimulationType getSimType() const = 0; + + + /** + \brief Gets a private interface to an internal debug object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void * getInternal(void) = 0; + + /** + \brief Sets a constant gravity for the entire scene. + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] vec A new gravity vector(e.g. NxVec3(0.0f,-9.8f,0.0f) ) Range: force vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneDesc.gravity getGravity() + */ + virtual void setGravity(const NxVec3& vec) = 0; + + /** + \brief Retrieves the current gravity setting. + + \param[out] vec Used to retrieve the current gravity for the scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGravity() NxSceneDesc.gravity + */ + virtual void getGravity(NxVec3& vec) = 0; + +/************************************************************************************************/ + +/** @name Create/Release Objects +*/ +//@{ + + /** + \brief Creates an actor in this scene. + + NxActorDesc::isValid() must return true. + + Sleeping: This call wakes the actors if they are sleeping. + + \param[in] desc Descriptor for actor to create. See #NxActorDescBase + \return The new actor. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Limits on numbers and types of actors) + \li PS3 : Yes + \li XB360: Yes + + @see NxActor NxActorDesc NxActorDescBase releaseActor() + */ + virtual NxActor* createActor(const NxActorDescBase& desc) = 0; + + /** + \brief Deletes the specified actor. + + Also releases any body and/or shapes associated with the actor. + + The actor must be in this scene. + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + Note: deleting a static actor will not wake up any sleeping objects that were + sitting on it. Use a kinematic actor instead to get this behavior. + + Releasing an actor will affect any joints that are connected to the actor. + Such joints will be moved to a list of "dead joints" and automatically deleted upon + scene deletion, or explicitly by the user by calling NxScene::releaseJoint(). It is + recommended to always remove all joints that reference actors before the actors + themselves are removed. It is not possible to retrieve the list of dead joints. + + Sleeping: This call will awaken any sleeping actors contacting the deleted actor (directly or indirectly). + + \param[in] actor The actor to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createActor() NxActor + */ + virtual void releaseActor(NxActor& actor) = 0; + + /** + \brief Creates a joint. + + The joint type depends on the type of joint desc passed in. + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] jointDesc The descriptor for the joint to create. E.g. #NxSphericalJointDesc,#NxRevoluteJointDesc etc + \return The new joint. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Up to 64k per scene) + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint NxJointDesc releaseJoint() NxJoint + @see NxRevoluteJoint NxSphericalJoint NxPrismaticJoint NxCylindricalJoint NxD6Joint NxDistanceJoint + NxFixedJoint NxPointInPlaneJoint NxPointOnLineJoint + */ + virtual NxJoint * createJoint(const NxJointDesc &jointDesc) = 0; + + /** + \brief Deletes the specified joint. + + The joint must be in this scene. + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + Sleeping: This call wakes the actor(s) if they are sleeping. + + \param[in] joint The joint to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void releaseJoint(NxJoint &joint) = 0; + + /** + \brief Deprecated. Use createEffector() instead. + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] springDesc The descriptor for the spring and damper effector to create. See #NxSpringAndDamperEffectorDesc. + \return The new spring and damper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffectorDesc NxSpringAndDamperEffector releaseEffector() + */ + virtual NxSpringAndDamperEffector* createSpringAndDamperEffector(const NxSpringAndDamperEffectorDesc& springDesc) = 0; + + /** + \brief Creates an effector. + + \param[in] desc The descriptor for the effector to create. See #NxEffectorDesc. + \return The new effector. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffectorDesc NxSpringAndDamperEffector releaseEffector() + */ + virtual NxEffector* createEffector(const NxEffectorDesc& desc) = 0; + + /** + \brief Deletes the effector passed. + + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + Sleeping: Does NOT wake the actor up automatically. + + \param[in] effector The effector to delete. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createSpringAndDamperEffector NxSpringAndDamperEffector + */ + virtual void releaseEffector(NxEffector& effector) = 0; + + /** + \brief Creates a force field. + + \param[in] forceFieldDesc The descriptor for the force field to create. See #NxForceFieldDesc. + \return The new force field. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see releaseForceField NxForceField NxForceFieldDesc + */ + virtual NxForceField* createForceField(const NxForceFieldDesc& forceFieldDesc) = 0; + + /** + \brief Deletes the force field passed. + + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] forceField The effector to delete. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + + @see createForceField NxForceField + */ + virtual void releaseForceField(NxForceField& forceField) = 0; + + /** + \brief Gets the number of force fields in the scene. + + \return The force field count. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbForceFields() const = 0; + + /** + \brief Gets the force fields in the scene. + + \return Array of pointers to NxForceField objects. Use #getNbForceFields to find the size of the array. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceField** getForceFields() = 0; + + /** + \brief creates a forcefield kernel which uses the same linear function as pre 2.8 force fields + + \param[in] kernelDesc The linear kernel desc to use to create a linear kernel for force fields. See #NxForceFieldLinearKernelDesc. + \return NxForceFieldLinearKernel. See #NxForceFieldLinearKernel + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldLinearKernel* createForceFieldLinearKernel(const NxForceFieldLinearKernelDesc& kernelDesc) = 0; + + /** + \brief releases a linear force field kernel + \param[in] kernel to be released. + \return NxForceFieldLinearKernel. See #NxForceFieldLinearKernel + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void releaseForceFieldLinearKernel(NxForceFieldLinearKernel& kernel) = 0; + + /** + \brief Returns the number of linear kernels in the scene. + + \return number of linear kernels in the scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbForceFieldLinearKernels() const = 0; + + /** + \brief Restarts the linear kernels iterator so that the next call to getNextForceFieldLinearKernel(). + + \return The first shape group in the force scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void resetForceFieldLinearKernelsIterator() = 0; + + /** + \brief Retrieves the next linear kernel when iterating. + + \return NxForceFieldLinearKernel + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldLinearKernel* getNextForceFieldLinearKernel() = 0; + + /** + \brief Creates a new force field shape group. + + \param[in] desc The force field group descriptor. See #NxForceFieldShapeGroupDesc. + \return NxForceFieldShapeGroup. See #NxForceFieldShapeGroup + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldShapeGroup* createForceFieldShapeGroup(const NxForceFieldShapeGroupDesc& desc) = 0; + + /** + \brief Releases a force field shape group. + + \param[in] group The group which is to be relased. See #NxForceFieldShapeGroup. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void releaseForceFieldShapeGroup(NxForceFieldShapeGroup& group) = 0; + + /** + \brief Returns the number of shape groups in the scene. + + \return The number of shape groups in the scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbForceFieldShapeGroups() const = 0; + + /** + \brief Restarts the shape groups iterator so that the next call to getNextForceFieldShapeGroup() returns the first shape group in the force scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void resetForceFieldShapeGroupsIterator() = 0; + + /** + \brief Retrieves the next shape group when iterating. + \return NxForceFieldShapeGroup. See #NxForceFieldShapeGroup + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldShapeGroup* getNextForceFieldShapeGroup() = 0; + + /** + \brief Creates a new variety index for force fields to access the scaling table, creates a new row in the scaling table. + \return NxForceFieldVariety. See #NxForceFieldVariety & #setForceFieldScale + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldVariety createForceFieldVariety() = 0; + + /** + \brief Returns the highest allocated force field variety. + \return Highest variety index See #NxForceFieldVariety + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldVariety getHighestForceFieldVariety() const = 0; + + /** + \brief Releases a forcefield variety index and the related row in the scaling table. + \param[in] mat The variery index to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void releaseForceFieldVariety(NxForceFieldVariety var) = 0; + + /** + \brief Creates a new index for objects(actor, fluid, cloth, softbody) to access the scaling table, creates a new column in the scaling table. + \return NxForceFieldMaterial See #NxForceFieldMaterial + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldMaterial createForceFieldMaterial() = 0; + + /** + \brief Returns the highest allocated force field material. + \return The highest allocated force field material. See #NxForceFieldMaterial + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldMaterial getHighestForceFieldMaterial() const = 0; + + /** + \brief Releases a forcefield material index and the related column in the scaling table. + \param[in] mat The material index to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void releaseForceFieldMaterial(NxForceFieldMaterial mat) = 0; + + /** + \brief Get the scaling value for a given variety/material pair. + \return The scaling value for a given variety/material pair. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal getForceFieldScale(NxForceFieldVariety var, NxForceFieldMaterial mat) = 0; + + /** + \brief Set the scaling value for a given variety/material pair. + \param[in] var A Variety index. + \param[in] mat A Material index. + \param[in] val The value to set at the variety/material coordinate in the table. Setting the value to big or to low may cause invalid floats in the kernel output. + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setForceFieldScale(NxForceFieldVariety var, NxForceFieldMaterial mat, NxReal val) = 0; + + /** + \brief Creates a new NxMaterial. + + The material library consists of an array of material objects. Each + material has a well defined index that can be used to refer to it. + If an object (shape or triangle) references an undefined material, + the default material with index 0 is used instead. + + \param[in] matDesc The material desc to use to create a material. See #NxMaterialDesc. + \return The new material. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterial NxMaterialDesc releaseMaterial() + */ + virtual NxMaterial * createMaterial(const NxMaterialDesc &matDesc) = 0; + + /** + \brief Deletes the specified material. + + The material must be in this scene. + Do not keep a reference to the deleted instance. + If you release a material while shapes or meshes are referencing its material index, + the material assignment of these objects becomes undefined. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] material The material to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createMaterial() NxMaterial + */ + virtual void releaseMaterial(NxMaterial &material) = 0; + + + /** + \brief Creates a scene compartment. + + A scene compartment is a portion of the scene that can + be simulated on a different hardware device than other parts of the scene. + See also the User's Guide on Compartments. + + \param[in] compDesc The NxCompartment descriptor to use to create a compartment. + \return the new compartment. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartment + */ + virtual NxCompartment * createCompartment(const NxCompartmentDesc &compDesc) = 0; + + /** + \brief Returns the number of compartments created in the scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartment, getCompartmentArray() + */ + virtual NxU32 getNbCompartments() const = 0; + + /** + \brief Writes the scene's array of NxCompartment pointers to a user buffer. + + bufferSize is the number of pointers (not bytes) that the buffer can hold. + usersIterator is an iterator that the user should initialize to 0 to start copying the array from the beginning. + Once the first call succeeds, the SDK will have changed the value of the iterator (in some data structure specific way) such that the + next get*Array() call will return the next batch of values. This way a large internal array can be read out with several calls into + a smaller user side buffer. + + Returns the number of pointers written, this should be less or equal to bufferSize. + + The ordering of the compartments in the array is not specified. + + \param[out] userBuffer The buffer to receive compartment pointers. + \param[in] bufferSize The number of compartment pointers which can be stored in the buffer. + \param[in,out] usersIterator Cookie used to continue iteration from the last position. + \return The number of compartment pointers written to userBuffer. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbCompartments() NxCompartment + */ + virtual NxU32 getCompartmentArray(NxCompartment ** userBuffer, NxU32 bufferSize, NxU32 & usersIterator) const = 0; +//@} +/************************************************************************************************/ + +/** @name Collision Filtering and Grouping +*/ +//@{ + + /** + \brief Sets the pair flags for the given pair of actors. + + The pair flags are a combination of bits + defined by ::NxContactPairFlag. Calling this on an actor that has no shape(s) has no effect. + The two actor references must not reference the same actor. + + It is important to note that the SDK stores pair flags per shape, even for actor pair flags. + This means that shapes should be created before actor pair flags are set, otherwise the pair + flags will be ignored. + + Sleeping: Does NOT wake the actors up automatically. + + \param[in] actorA Actor A + \param[in] actorB Actor B + \param[in] nxContactPairFlag New set of contact pair flags. See #NxContactPairFlag + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getActorPairFlags() NxContactPairFlag + */ + virtual void setActorPairFlags(NxActor& actorA, NxActor& actorB, NxU32 nxContactPairFlag) = 0; + + /** + \brief Retrieves the pair flags for the given pair of actors. + + The pair flags are a combination of bits + defined by ::NxContactPairFlag. If no pair record is found, zero is returned. + The two actor references must not reference the same actor. + + \param[in] actorA Actor A + \param[in] actorB Actor B + \return The actor pair flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setActorPairFlags() NxContactPairFlag + */ + virtual NxU32 getActorPairFlags(NxActor& actorA, NxActor& actorB) const = 0; + + /** + \brief Similar to #setActorPairFlags(), but for a pair of shapes. + + NX_IGNORE_PAIR is the only thing allowed + as a shape pair flag. All of the NX_NOTIFY flags should be used at the actor level. + The two shape references must not reference the same shape. + + Sleeping: Does NOT wake the associated actors up automatically. + + \param[in] shapeA Shape A + \param[in] shapeB Shape B + \param[in] nxContactPairFlag New set of shape contact pair flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getShapePairFlags() NxContactPairFlag + */ + virtual void setShapePairFlags(NxShape& shapeA, NxShape& shapeB, NxU32 nxContactPairFlag) = 0; + + /** + \brief Similar to #getActorPairFlags(), but for a pair of shapes. + + The two shape references must not reference the same shape. + + \param[in] shapeA Shape A + \param[in] shapeB SHape B + \return The shape pair flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setShapePairFlags() NxContactPairFlag + */ + virtual NxU32 getShapePairFlags(NxShape& shapeA, NxShape& shapeB) const = 0; + + /** + \brief Returns the number of pairs for which pairFlags are defined. + Note that this includes compartments. + + This includes actor and shape pairs. + + \return The number of pairs. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxContactPairFlag setShapePairFlags() setActorPairFlags() getPairFlagArray() + */ + virtual NxU32 getNbPairs() const = 0; + + /** + \brief Retrieves the pair flag data. + + The high bit of each 32 bit flag field denotes whether a pair is a shape or + an actor pair. numPairs is the number of pairs the buffer can hold. The user is responsible for + allocating and deallocating the buffer. Call ::getNbPairs() to check what the number of pairs should be. + + + \param[out] userArray Pointer to user array to receive pair flags. should be at least sizeof(NxPairFlag)*numPairs in size. + \param[in] numPairs Number of pairs the user buffer can hold. + \return The number of pairs written to userArray. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxContactPairFlag setShapePairFlags() setActorPairFlags() getNbPairs() + */ + virtual NxU32 getPairFlagArray(NxPairFlag* userArray, NxU32 numPairs) const = 0; + + /** + \brief Specifies if collision should be performed by a pair of shape groups. + + It is possible to assign each shape to a collision groups using #NxShape::setGroup(). + With this method one can set whether collisions should be detected between shapes + belonging to a given pair of groups. Initially all pairs are enabled. + + Collision detection between two shapes a and b occurs if: + getGroupCollisionFlag(a->getGroup(), b->getGroup()) && isEnabledPair(a,b) is true. + + Fluids can be assigned to collision groups as well. + + NxCollisionGroup is an integer between 0 and 31. + + Sleeping: Does NOT wake the associated actors up automatically. + + \param[in] group1 First group. + \param[in] group2 Second group. + \param[in] enable True to enable collision between the groups. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup getGroupCollisionFlag() NxShape.setGroup() NxShape.getGroup() + */ + virtual void setGroupCollisionFlag(NxCollisionGroup group1, NxCollisionGroup group2, bool enable) = 0; + + /** + \brief Determines if collision detection is performed between a pair of groups. + + NxCollisionGroup is an integer between 0 and 31. + + \param[in] group1 First Group. + \param[in] group2 Second Group. + \return True if the groups could collide. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGroupCollisionFlag() NxCollisionGroup NxShape.setGroup() NxShape.getGroup() + */ + virtual bool getGroupCollisionFlag(NxCollisionGroup group1, NxCollisionGroup group2) const = 0; + + /** + \brief Specifies the dominance behavior of constraints between two actors with two certain dominance groups. + + It is possible to assign each actor to a dominance groups using #NxActor::setDominanceGroup(). + + With dominance groups one can have all constraints (contacts and joints) created + between actors act in one direction only. This is useful if you want to make sure that the movement of the rider + of a vehicle or the pony tail of a character doesn't influence the object it is attached to, while keeping the motion of + both inherently physical. + + Whenever a constraint (i.e. joint or contact) between two actors (a0, a1) needs to be solved, the groups (g0, g1) of both + actors are retrieved. Then the NxConstraintDominance setting for this group pair is retrieved with getDominanceGroupPair(g0, g1). + + In the constraint, NxConstraintDominance::dominance0 becomes the dominance setting for a0, and + NxConstraintDominance::dominance1 becomes the dominance setting for a1. A dominanceN setting of 1.0f, the default, + will permit aN to be pushed or pulled by a(1-N) through the constraint. A dominanceN setting of 0.0f, will however + prevent aN to be pushed or pulled by a(1-N) through the constraint. Thus, a NxConstraintDominance of (1.0f, 0.0f) makes + the interaction one-way. + + + The matrix sampled by getDominanceGroupPair(g1, g2) is initialised by default such that: + + if g1 == g2, then (1.0f, 1.0f) is returned + if g1 < g2, then (0.0f, 1.0f) is returned + if g1 > g2, then (1.0f, 0.0f) is returned + + In other words, we permit actors in higher groups to be pushed around by actors in lower groups by default. + + These settings should cover most applications, and in fact not overriding these settings may likely result in higher performance. + + It is not possible to make the matrix asymetric, or to change the diagonal. In other words: + + * it is not possible to change (g1, g2) if (g1==g2) + * if you set + + (g1, g2) to X, then (g2, g1) will implicitly and automatically be set to ~X, where: + + ~(1.0f, 1.0f) is (1.0f, 1.0f) + ~(0.0f, 1.0f) is (1.0f, 0.0f) + ~(1.0f, 0.0f) is (0.0f, 1.0f) + + These two restrictions are to make sure that constraints between two actors will always evaluate to the same dominance + setting, regardless of which order the actors are passed to the constraint. + + Dominance settings are currently specified as floats 0.0f or 1.0f because in the future we may permit arbitrary + fractional settings to express 'partly-one-way' interactions. + + Sleeping: Does NOT wake actors up automatically. + + @see getDominanceGroupPair() NxDominanceGroup NxConstraintDominance NxActor::setDominanceGroup() NxActor::getDominanceGroup() + */ + virtual void setDominanceGroupPair(NxDominanceGroup group1, NxDominanceGroup group2, NxConstraintDominance & dominance) = 0; + + /** + \brief Samples the dominance matrix. + + @see setDominanceGroupPair() NxDominanceGroup NxConstraintDominance NxActor::setDominanceGroup() NxActor::getDominanceGroup() + */ + virtual NxConstraintDominance getDominanceGroupPair(NxDominanceGroup group1, NxDominanceGroup group2) const = 0; + + /** + \brief With this method one can set contact reporting flags between actors belonging to a pair of groups. + + It is possible to assign each actor to a group using NxActor::setGroup(). This is a different + set of groups from the shape groups despite the similar name. Here up to 0xffff different groups are permitted, + With this method one can set contact reporting flags between actors belonging to a pair of groups. + + The following flags are permitted: + + NX_NOTIFY_ON_START_TOUCH + NX_NOTIFY_ON_END_TOUCH + NX_NOTIFY_ON_TOUCH + NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD + NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD + NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD + NX_NOTIFY_ON_IMPACT + NX_NOTIFY_ON_ROLL + NX_NOTIFY_ON_SLIDE + + See ::NxContactPairFlag. + + Note that finer grain control of pairwise flags is possible using the functions + NxScene::setShapePairFlags() and NxScene::setActorPairFlags(). + + Sleeping: Does NOT wake the actors up automatically. + + \param[in] group1 First group. + \param[in] group2 Second group + \param[in] flags Flags to control contact reporting. See #NxContactPairFlag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getActorGroupPairFlags() NxActorGroup NxActor.getGroup() NxActor.setGroup() + */ + virtual void setActorGroupPairFlags(NxActorGroup group1, NxActorGroup group2, NxU32 flags) = 0; + + /** + \brief This reads the value set with #setActorGroupPairFlags. + + \param[in] group1 First Group + \param[in] group2 Second Group + \return The contact reporting flags associated with this actor pair. See #setActorGroupPairFlags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setActorPairFlags() NxActorGroup NxActor.getGroup() NxActor.setGroup() + */ + virtual NxU32 getActorGroupPairFlags(NxActorGroup group1, NxActorGroup group2) const = 0; + + /** + \brief Gets the number of actor group flags (as set by setActorGroupPairFlags). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxActorGroupPair, getActorGroupPairFlags(), getActorGroupPairArray() + */ + virtual NxU32 getNbActorGroupPairs() const = 0; + + /** + \brief Writes the scene's array of actor group flags (as set by setActorGroupPairFlags) to a user buffer. + + bufferSize is the number of NxActorGroupPairs (not bytes) that the buffer can hold. + usersIterator is an iterator that the user should initialize to 0 to start copying the array from the beginning. + Once the first call succeeds, the SDK will have changed the value of the iterator (in some data structure specific way) such that the + next get*Array() call will return the next batch of values. This way a large internal array can be read out with several calls into + a smaller user side buffer. + + \return the number of pairs written, this should be less or equal to bufferSize. + + The ordering of the elements in the array is not specified. + + \param[out] userBuffer The buffer to receive NxActorGroupPairs. + \param[in] bufferSize The number of NxActorGroupPairs which can be stored in the buffer. + \param[in,out] userIterator Cookie used to continue iteration from the last position. + \return The number of pairs written to userBuffer. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbActorGroupPairs() NxActorGroupPair + */ + virtual NxU32 getActorGroupPairArray(NxActorGroupPair * userBuffer, NxU32 bufferSize, NxU32 & userIterator) const = 0; + + + /** + \brief Setups filtering operations. See comments for ::NxGroupsMask + + Sleeping: Does NOT wake the actors up automatically. + + \param[in] op0 Filter op 0. + \param[in] op1 Filter op 1. + \param[in] op2 Filter op 2. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterBool() setFilterConstant0() setFilterConstant1() + */ + virtual void setFilterOps(NxFilterOp op0, NxFilterOp op1, NxFilterOp op2) = 0; + + /** + \brief Setups filtering's boolean value. See comments for ::NxGroupsMask + + Sleeping: Does NOT wake the actors up automatically. + + \param[in] flag Boolean value for filter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterOps() setFilterConstant0() setFilterConstant1() + */ + virtual void setFilterBool(bool flag) = 0; + + /** + \brief Setups filtering's K0 value. See comments for ::NxGroupsMask + + Sleeping: Does NOT wake the actors up automatically. + + \param[in] mask The new group mask. See #NxGroupsMask. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterOps() setFilterBool() setFilterConstant1() + */ + virtual void setFilterConstant0(const NxGroupsMask& mask) = 0; + + /** + \brief Setups filtering's K1 value. See comments for ::NxGroupsMask + + Sleeping: Does NOT wake the actors up automatically. + + \param[in] mask The new group mask. See #NxGroupsMask. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterOps() setFilterBool() setFilterConstant0() + */ + virtual void setFilterConstant1(const NxGroupsMask& mask) = 0; + + /** + \brief Retrieves filtering operation. See comments for ::NxGroupsMask + + \param[out] op0 First filter operator. + \param[out] op1 Second filter operator. + \param[out] op2 Third filter operator. + + See the user guide page "Contact Filtering" for more details. + + \return the filter operation requested + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterOps() setFilterBool() setFilterConstant0() setFilterConstant1() + */ + virtual void getFilterOps(NxFilterOp& op0, NxFilterOp& op1, NxFilterOp& op2)const = 0; + + /** + \brief Retrieves filtering's boolean value. See comments for ::NxGroupsMask + + \return flag Boolean value for filter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterBool() setFilterConstant0() setFilterConstant1() + */ + virtual bool getFilterBool() const = 0; + + /** + \brief Gets filtering constant K0. See comments for ::NxGroupsMask + + \return the filtering constant, as a mask. See #NxGroupsMask. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterOps() setFilterBool() setFilterConstant0() setFilterConstant1() getFilterConstant1() + */ + virtual NxGroupsMask getFilterConstant0() const = 0; + + /** + \brief Gets filtering constant K1. See comments for ::NxGroupsMask + + \return the filtering constant, as a mask. See #NxGroupsMask. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setFilterOps() setFilterBool() setFilterConstant0() setFilterConstant1() getFilterConstant0() + */ + virtual NxGroupsMask getFilterConstant1() const = 0; + +//@} +/************************************************************************************************/ + +/** @name Enumeration +*/ +//@{ + + /** + \brief Retrieve the number of actors in the scene. + \return the number of actors. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getActors() + */ + virtual NxU32 getNbActors() const = 0; + + /** + \brief Retrieve an array of all the actors in the scene. + + \return an array of actor pointers with size getNbActors(). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbActors() + */ + virtual NxActor** getActors() = 0; + + /** + \brief Queries the NxScene for a list of the NxActors whose transforms have been + updated during the previous simulation step + + Note: NX_SF_ENABLE_ACTIVETRANSFORMS must be set. + + \param[out] nbTransformsOut The number of transforms returned. + + \return A pointer to the list of NxActiveTransforms generated during the last call to fetchResults(). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActiveTransform + */ + + virtual NxActiveTransform* getActiveTransforms(NxU32 &nbTransformsOut) = 0; + + /** + \brief Returns the number of static shapes in the scene. + Note that this includes compartments and mirrored shapes in compartments. + + \return The number of static shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbDynamicShapes(); + @see getTotalNbShapes() + */ + virtual NxU32 getNbStaticShapes() const = 0; + + /** + \brief Returns the number of dynamic shapes in the scene. + Note that this includes compartments and mirrored shapes in compartments. + + \return the number of dynamic shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbStaticShapes() + @see getTotalNbShapes() + */ + virtual NxU32 getNbDynamicShapes() const = 0; + + /** + \brief Returns the total number of shapes in the scene, including compounds' sub-shapes. + Note that this also includes compartments and mirrored shapes in compartments. + + \return the total number of shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbStaticShapes() + @see getNbDynamicShapes() + */ + virtual NxU32 getTotalNbShapes() const = 0; + + /** + \brief Returns the number of joints in the scene (excluding "dead" joints). + Note that this includes compartments. + + \return the number of joints in this scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNextJoint() + */ + virtual NxU32 getNbJoints() const = 0; + + /** + + \brief Restarts the joint iterator so that the next call to ::getNextJoint() returns the first joint in the scene. + + Creating or deleting joints resets the joint iterator. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see resetJointIterator() getNbJoints() + */ + virtual void resetJointIterator() = 0; + + /** + \brief Retrieves the next joint when iterating. + + First call resetJointIterator(), then call this method repeatedly until it returns + zero. After a call to resetJointIterator(), repeated calls to getNextJoint() should return a sequence of getNbJoints() + joint pointers. The getNbJoints()+1th call will return 0. + Creating or deleting joints resets the joint iterator. + + @see resetJointIterator. + + \return The next joint in the iteration sequence. Or NULL when the end of the list of joints is reached. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see resetJointIterator() getNbJoints() + */ + virtual NxJoint * getNextJoint() = 0; + + /** + \brief Returns the number of effectors in the scene. + + \return the number of effectors in this scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNextEffector() + */ + virtual NxU32 getNbEffectors() const = 0; + + /** + \brief Restarts the effector iterator so that the next call to ::getNextEffector() returns the first effector in the scene. + + Creating or deleting effectors resets the joint iterator. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNextEffector() getNbEffectors() + */ + virtual void resetEffectorIterator() = 0; + + /** + \brief Retrieves the next effector when iterating through the effectors in the scene. + + First call resetEffectorIterator(), then call this method repeatedly until it returns + zero. After a call to resetEffectorIterator(), repeated calls to getNextEffector() should return a sequence of getNbEffectors() + effector pointers. The getNbEffectors()+1th call will return 0. + Creating or deleting effectors resets the joint iterator. + + @see resetEffectorIterator. + + \return The next effector in the iteration sequence. Or NULL when the end of the list of joints is reached. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see resetEffectorIterator() getNbEffectors() + */ + virtual NxEffector * getNextEffector() = 0; + + + /** + \brief Returns an upper bound for the number of actors in the collision island of a certain actor + + A collision island is a group of objects that are connected through bounds overlaps or joint constraints. + + \param[in] actor The actor for which to return island information + + \return The maximum size of the internal actor array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getIslandArrayFromActor() + */ + virtual NxU32 getBoundForIslandSize(NxActor& actor) = 0; + + /** + \brief Writes pointers to the actors making up the collision island of a certain actor to a user buffer + + A collision island is a group of objects that are connected through bounds overlaps or joint constraints. + + bufferSize is the number of pointers (not bytes) that the buffer can hold. + usersIterator is an iterator that the user should initialize to 0 to start copying the array from the beginning. + Once the first call succeeds, the SDK will have changed the value of the iterator (in some data structure specific way) such that the + next get*Array() call will return the next batch of values. This way a large internal array can be read out with several calls into + a smaller user side buffer. + + Returns the number of pointers written, this should be less or equal to bufferSize. This will include the specified actor. + + The ordering of the actors in the array is not specified. + Note that this call is invalid while the scene is simulating (in between simulate() and fetchResults() calls). + Also, the island is based on the state just before the last simulation step, which means the islands may be somewhat inaccurate, especially for fast moving objects. + + Usage example: + \code + NxActor * ptrs[3]; + NxU32 iterator = 0; + NxU32 actorCount; + while (actorCount = s->getIslandArrayFromActor(actor, ptrs, 3, iterator)) + while(actorCount--) processActor(ptrs[actorCount]); + + \endcode + + \param[in] actor The actor for which to return island information + \param[out] userBuffer The buffer to receive actor pointers. + \param[in] bufferSize The number of actor pointers which can be stored in the buffer. + \param[in,out] userIterator Cookie used to continue iteration from the last position. + \return The number of actor pointers written to userBuffer. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getBoundForIslandSize() NxActor + */ + virtual NxU32 getIslandArrayFromActor(NxActor& actor, NxActor** userBuffer, NxU32 bufferSize, NxU32& userIterator) = 0; + +//@} +/************************************************************************************************/ + +/** @name Materials +*/ +//@{ + + /** + \brief Return the number of materials in the scene. + + Note that the returned value is not related to material indices (NxMaterialIndex). + Those may not be allocated continuously, and its values may be higher than getNbMaterials(). + This will also include the default material which exists without having to be created. + + \return The size of the internal material array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getMaterialArray() + */ + virtual NxU32 getNbMaterials() const = 0; + + /** + \brief Writes the scene's array of material pointers to a user buffer. + + bufferSize is the number of pointers (not bytes) that the buffer can hold. + usersIterator is an iterator that the user should initialize to 0 to start copying the array from the beginning. + Once the first call succeeds, the SDK will have changed the value of the iterator (in some data structure specific way) such that the + next get*Array() call will return the next batch of values. This way a large internal array can be read out with several calls into + a smaller user side buffer. + + Returns the number of pointers written, this should be less or equal to bufferSize. This will also return the default material which exists without having to be created. + + The ordering of the materials in the array is not specified. + + Usage example: + \code + NxMaterial * ptrs[3]; + NxU32 iterator = 0; + NxU32 materialCount; + while (materialCount = s->getMaterialArray(ptrs, 3, iterator)) + while(materialCount--) processMaterial(ptrs[materialCount]); + + \endcode + + \param[out] userBuffer The buffer to receive material pointers. + \param[in] bufferSize The number of material pointers which can be stored in the buffer. + \param[in,out] usersIterator Cookie used to continue iteration from the last position. + \return The number of material pointers written to userBuffer. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbMaterials() NxMaterial + */ + virtual NxU32 getMaterialArray(NxMaterial ** userBuffer, NxU32 bufferSize, NxU32 & usersIterator) = 0; + + /** + \brief Returns current highest valid material index. + + Note that not all indices below this are valid if some of them belong to meshes that + have been freed. + + \return The highest material index. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterial NxMaterialIndex NxScene.createMaterial() + */ + + virtual NxMaterialIndex getHighestMaterialIndex() const = 0; + + /** + \brief Retrieves the material with the given material index. + + There is always at least one material in the Scene, the default material (index 0). If the + specified material index is out of range (larger than getHighestMaterialIndex) or belongs + to a material that has been released, then the default material is returned, but no error + is reported. + + You can always get a pointer to the default material by specifying index 0. You can change + the properties of the default material by changing the properties directly on the material. + It is not possible to release the default material, calling releaseMaterial(defaultMaterial) + has no effect. + + \param[in] matIndex Material index to retrieve. + \return The associated material. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterial NxMaterialIndex NxScene.createMaterial() getHighestMaterialIndex() + */ + virtual NxMaterial * getMaterialFromIndex(NxMaterialIndex matIndex) = 0; + +//@} +/************************************************************************************************/ + + /** + \brief Flush the scene's command queue for processing. + + Flushes any buffered commands so that they get executed. + Ensures that commands buffered in the system will continue to make forward progress until completion. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setTiming() simulate() fetchResults() checkResults() + */ + virtual void flushStream() = 0; + + /** + \brief Sets simulation timing parameters used in simulate(elapsedTime). + + If method is NX_TIMESTEP_FIXED, elapsedTime(simulate() parameter) is internally subdivided into up to + maxIter substeps no larger than maxTimestep. + + If elapsedTime is not a multiple of maxTimestep then any remaining time is accumulated + to be added onto the elapsedTime for the next time step. + + If more sub steps than maxIter are needed to advance the simulation by elapsed time, then + the remaining time is also accumulated for the next call to simulate(). + + The timestep method of TIMESTEP_FIXED is strongly preferred for stable, reproducible simulation. + + Alternatively NX_TIMESTEP_VARIABLE can be used, in this case the first two parameters + are not used. See also ::NxTimeStepMethod. + + \param[in] maxTimestep Maximum size of a substep. Range: (0,inf) + \param[in] maxIter Maximum number of iterations to divide a timestep into. + \param[in] method Method to use for timestep (either variable time step or fixed). See #NxTimeStepMethod. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see flushStream() simulate() fetchResults() checkResults() + */ + virtual void setTiming(NxReal maxTimestep=1.0f/60.0f, NxU32 maxIter=8, NxTimeStepMethod method=NX_TIMESTEP_FIXED) = 0; + + /** + \brief Retrieves simulation timing parameters. + + \param[in] maxTimestep Maximum size to divide a substep into. Range: (0,inf) + \param[in] maxIter Maximum number of iterations to divide a timestep into. + \param[in] method Method to use for timestep (either variable time step or fixed). See #NxTimeStepMethod. + \param[in] numSubSteps The number of sub steps the time step will be divided into. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setTiming() + */ + virtual void getTiming(NxReal& maxTimestep, NxU32& maxIter, NxTimeStepMethod& method, NxU32* numSubSteps=NULL) const = 0; + + /** + \brief Retrieves the debug renderable. + + This will contain the results of any active visualization for this scene. + \return The debug renderable. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxDebugRenderable + */ + virtual const NxDebugRenderable * getDebugRenderable() = 0; + + /** + \brief Call this method to retrieve the Physics SDK. + + \return The physics SDK this scene is associated with. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPhysicsSDK + */ + virtual NxPhysicsSDK& getPhysicsSDK() = 0; + + /** + \brief Call this method to retrieve statistics about the current scene. + + \param[out] stats Used to retrieve statistics for the scene. See #NxSceneStats. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneStats getLimits() + */ + virtual void getStats(NxSceneStats& stats) const = 0; +#ifdef NX_ENABLE_SCENE_STATS2 + /** + \brief Call this method to retrieve extended statistics about the current scene. + + \return Used to retrieve statistics for the scene. See #NxSceneStats2. + Note that this is a pointer to data that changes with each simulation call; + the relevant data must be copied in order to save it. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual const NxSceneStats2 * getStats2() const = 0; +#endif + + /** + \brief Call to retrieve the expected object count limits set in the scene descriptor. + + \param[out] limits Used to retrieve the limits for the scene(e.g. maximum number of actors). See #NxSceneLimits. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneLimits getStats() NxSceneStats + */ + virtual void getLimits(NxSceneLimits& limits) const = 0; + + + /** + \brief Not yet implemented! + + Call to set the maximum CPU for use when load-balancing. + + The SDK may choose to balance physics load by simulating assets on the CPU which could + otherwise be simulated on the PPU. Use this function to allocate a portion of the CPU + for this purpose. Note that the SDK only load-balances assets created in compartments + with the attribute NX_DC_PPU_AUTO_ASSIGN, and that the default CPU allocated is zero. + + \param[in] cpuFraction The maximum fraction of the total host CPU to use - for example + 0.2 would equate to 20% of a single core or might use 10% of each core or 20% of one + core on a dual-core CPU. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxDeviceCode getMaxCPUForLoadBalancing() + */ + virtual void setMaxCPUForLoadBalancing(NxReal cpuFraction) = 0; + + /** + \brief Call to get the maximum CPU for use when load-balancing. + + @see setMaxCPUForLoadBalancing() + */ + virtual NxReal getMaxCPUForLoadBalancing() = 0; + + +/************************************************************************************************/ + +/** @name Callbacks +*/ +//@{ + + /** + \brief Sets a user notify object which receives special simulation events when they occur. + + \param[in] callback User notification callback. See #NxUserNotify. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserNotify getUserNotify + */ + virtual void setUserNotify(NxUserNotify* callback) = 0; + + /** + \brief Retrieves the userNotify pointer set with setUserNotify(). + + \return The current user notify pointer. See #NxUserNotify. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserNotify setUserNotify() + */ + virtual NxUserNotify* getUserNotify() const = 0; + +#if NX_USE_FLUID_API + /** + \brief Sets a user notify object which receives special simulation events when they occur. + + \param[in] callback User fluid notification callback. See #NxFluidUserNotify. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxFluidUserNotify getFluidUserNotify + */ + virtual void setFluidUserNotify(NxFluidUserNotify* callback) = 0; + + + /** + \brief Retrieves the NxFluidUserNotify pointer set with setfluidUserNotify(). + + \return The current user fluid notify pointer. See #NxFluidUserNotify. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxFluidUserNotify setFluidUserNotify() + */ + virtual NxFluidUserNotify* getFluidUserNotify() const = 0; + +#endif //NX_USE_FLUID_API + +#if NX_USE_CLOTH_API + /** + \brief Sets a user notify object which receives special simulation events when they occur. + + \param[in] callback User cloth notification callback. See #NxClothUserNotify. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxClothUserNotify getClothUserNotify + */ + virtual void setClothUserNotify(NxClothUserNotify* callback) = 0; + + + /** + \brief Retrieves the NxClothUserNotify pointer set with setClothUserNotify(). + + \return The current user cloth notify pointer. See #NxClothUserNotify. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxClothUserNotify setClothUserNotify() + */ + virtual NxClothUserNotify* getClothUserNotify() const = 0; +#endif //NX_USE_CLOTH_API + +#if NX_USE_SOFTBODY_API + /** + \brief Sets a user notify object which receives special simulation events when they occur. + + \param[in] callback User softbody notification callback. See #NxSoftBodyUserNotify. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxSoftBodyUserNotify getSoftBodyUserNotify + */ + virtual void setSoftBodyUserNotify(NxSoftBodyUserNotify* callback) = 0; + + + /** + \brief Retrieves the NxSoftBodyUserNotify pointer set with setSoftBodyUserNotify(). + + \return The current user softbody notify pointer. See #NxSoftBodyUserNotify. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxSoftBodyUserNotify setSoftBodyUserNotify() + */ + virtual NxSoftBodyUserNotify* getSoftBodyUserNotify() const = 0; +#endif //NX_USE_SOFTBODY_API + + /** + \brief Sets a user callback object, which receives callbacks on all contacts generated for specified actors. + + \param[in] callback Asynchronous user contact modification callback. See #NxUserContactModify. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setUserContactModify(NxUserContactModify* callback) = 0; + + /** + \brief Retrieves the NxUserContactModify pointer set with setUserContactModify(). + + \return The current user contact modify callback pointer. See #NxUserContactModify. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserContactModify setUserContactModify() + */ + virtual NxUserContactModify* getUserContactModify() const = 0; + + /** + \brief Sets a trigger report object which receives collision trigger events. + + \param[in] callback User trigger callback. See #NxUserTriggerReport. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserTriggerReport getUserTriggerReport() + */ + virtual void setUserTriggerReport(NxUserTriggerReport* callback) = 0; + + /** + \brief Retrieves the callback pointer set with setUserTriggerReport(). + + \return The current user trigger pointer. See #NxUserTriggerReport. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserTriggerReport setUserTriggerReport() + */ + virtual NxUserTriggerReport* getUserTriggerReport() const = 0; + + /** + \brief Sets a contact report object which receives collision contact events. + + \param[in] callback User contact callback. See #NxUserContactReport. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserContactReport getUserContactReport() + */ + virtual void setUserContactReport(NxUserContactReport* callback) = 0; + + /** + \brief Retrieves the callback pointer set with setUserContactReport(). + + \return The current user contact reporter. See #NxUserContactReport. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserContactReport setUserContactReport() + */ + virtual NxUserContactReport* getUserContactReport() const = 0; + + /** + \brief Sets the custom actor pair filtering to use for this scene. + + \param callback Filtering class that defines the callback to use for custom pair filtering. + + @see NxUserActorPairFiltering getUserActorPairFiltering NxActor::resetUserActorPairFiltering + */ + virtual void setUserActorPairFiltering(NxUserActorPairFiltering* callback) = 0; + + /** + \brief Gets the custom actor pair filtering in use for this scene. + + \return Filtering class that defines the callback used for custom pair filtering. + + @see NxUserActorPairFiltering setUserActorPairFiltering NxActor::resetUserActorPairFiltering + */ + virtual NxUserActorPairFiltering* getUserActorPairFiltering() const = 0; + +//@} +/************************************************************************************************/ + +/** @name Raycasting +*/ +//@{ + + /** + \brief Returns true if any axis aligned bounding box enclosing a shape of type shapeType is intersected by the ray. + + \note Make certain that the direction vector of NxRay is normalized. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldRay The ray to cast in the global frame. Range: See #NxRay + \param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType. + \param[in] groups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] maxDist Max distance to check along the ray for intersecting bounds. Range: (0,inf) + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return true if any axis aligned bounding box enclosing a shape of type shapeType is intersected by the ray + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapesType NxRay NxShape.setGroup() raycastAnyShape() + */ + virtual bool raycastAnyBounds (const NxRay& worldRay, NxShapesType shapesType, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, const NxGroupsMask* groupsMask=NULL) const = 0; + + /** + \brief Returns true if any shape of type ShapeType is intersected by the ray. + + \note Make certain that the direction vector of NxRay is normalized. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldRay The ray to cast in the global frame. Range: See #NxRay + \param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType. + \param[in] groups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + \param[in] cache Possible cache for persistent raycasts, filled out by the SDK. + + \return Returns true if any shape of type ShapeType is intersected by the ray. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapesType NxRay NxShape.setGroup() raycastAnyBounds() + */ + virtual bool raycastAnyShape (const NxRay& worldRay, NxShapesType shapesType, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, const NxGroupsMask* groupsMask=NULL, NxShape** cache=NULL) const = 0; + + /** + \brief Calls the report's hitCallback() method for all the axis aligned bounding boxes enclosing shapes of type ShapeType intersected by the ray. + + The point of impact is provided as a parameter to hitCallback(). + hintFlags is a combination of ::NxRaycastBit flags. + Returns the number of shapes hit. + + \note Make certain that the direction vector of NxRay is normalized. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldRay The ray to cast in the global frame. Range: See #NxRay + \param[in] report User callback, to be called when an intersection is encountered. + \param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType. + \param[in] groups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) + \param[in] hintFlags Allows the user to specify which field of #NxRaycastHit they are interested in. + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return the number of shapes hit. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see raycastAnyBounds() raycastAllShapes() NxRay NxUserRaycastReport NxShapesType NxShape.setGroup() NxRaycastHit + */ + virtual NxU32 raycastAllBounds (const NxRay& worldRay, NxUserRaycastReport& report, NxShapesType shapesType, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, NxU32 hintFlags=0xffffffff, const NxGroupsMask* groupsMask=NULL) const = 0; + + /** + \brief Calls the report's hitCallback() method for all the shapes of type ShapeType intersected by the ray. + + hintFlags is a combination of ::NxRaycastBit flags. + Returns the number of shapes hit. The point of impact is provided as a parameter to hitCallback(). + + \note Make certain that the direction vector of NxRay is normalized. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + +

Example

+ + \include NxUserRaycastReport_Usage.cpp + + + \param[in] worldRay The ray to cast in the global frame. Range: See #NxRay + \param[in] report User callback, to be called when an intersection is encountered. + \param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType. + \param[in] groups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) + \param[in] hintFlags Allows the user to specify which field of #NxRaycastHit they are interested in. See #NxRaycastBit + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return the number of shapes hit + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see raycastAnyShape() raycastAllBounds() NxRay NxUserRaycastReport NxShapesType NxShape.setGroup() NxRaycastHit + */ + virtual NxU32 raycastAllShapes (const NxRay& worldRay, NxUserRaycastReport& report, NxShapesType shapesType, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, NxU32 hintFlags=0xffffffff, const NxGroupsMask* groupsMask=NULL) const = 0; + + /** + \brief Returns the first axis aligned bounding box enclosing a shape of type shapeType that is hit along the ray. + + The world space intersection point, and the distance along the ray are also provided. + hintFlags is a combination of ::NxRaycastBit flags. + + \note Make certain that the direction vector of NxRay is normalized. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldRay The ray to cast in the global frame. Range: See #NxRay + \param[in] shapeType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType. + \param[out] hit Description of the intersection. See #NxRaycastHit. + \param[in] groups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) + \param[in] hintFlags Allows the user to specify which field of #NxRaycastHit they are interested in. See #NxRaycastBit + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return The shape which is hit. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see raycastAllBounds() NxRay NxShapesType NxRaycastHit NxShape.setGroup() NxRaycastBit + */ + virtual NxShape* raycastClosestBounds (const NxRay& worldRay, NxShapesType shapeType, NxRaycastHit& hit, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, NxU32 hintFlags=0xffffffff, const NxGroupsMask* groupsMask=NULL) const = 0; + + /** + \brief Returns the first shape of type shapeType that is hit along the ray. + + The world space intersection point, and the distance along the ray are also provided. + hintFlags is a combination of ::NxRaycastBit flags. + + \note Make certain that the direction vector of NxRay is normalized. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldRay The ray to cast in the global frame. Range: See #NxRay + \param[in] shapeType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType. + \param[out] hit Description of the intersection. See #NxRaycastHit. + \param[in] groups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) + \param[in] hintFlags Allows the user to specify which field of #NxRaycastHit they are interested in. See #NxRaycastBit + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + \param[in] cache Possible cache for persistent raycasts, filled out by the SDK. + + \return The shape which is hit. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see raycastAllShapes() NxRay NxShapesType NxRaycastHit NxShape.setGroup() NxRaycastBit + */ + virtual NxShape* raycastClosestShape (const NxRay& worldRay, NxShapesType shapeType, NxRaycastHit& hit, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, NxU32 hintFlags=0xffffffff, const NxGroupsMask* groupsMask=NULL, NxShape** cache=NULL) const = 0; + +//@} +/************************************************************************************************/ + +/** @name Overlap Testing +*/ +//@{ + + /** + \brief Returns the set of shapes overlapped by the world-space sphere. + + You can test against static and/or dynamic objects by adjusting 'shapeType'. + Shapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'. + An alternative is to use the ::NxUserEntityReport callback mechanism. + + The function returns the total number of collided shapes. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldSphere Sphere description in world space. Range: See #NxSphere + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] nbShapes Number of shapes that the buffer shapes can hold. + \param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes. + \param[in] callback Alternative method to retrieve overlapping shapes. Is called with sets of overlapping shapes. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + \param[in] accurateCollision True to test the sphere against the actual shapes, false to test against the AABBs only. + + \return the total number of collided shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere NxShapesType overlapAABBShapes NxUserEntityReport NxShape.checkOverlapSphere() + */ + virtual NxU32 overlapSphereShapes (const NxSphere& worldSphere, NxShapesType shapeType, NxU32 nbShapes, NxShape** shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, bool accurateCollision=false) = 0; + + /** + \brief Returns the set of shapes overlapped by the world-space AABB. + + You can test against static and/or dynamic objects by adjusting 'shapeType'. + Shapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'. + An alternative is to use the ::NxUserEntityReport callback mechanism. + + The function returns the total number of collided shapes. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldBounds Axis Aligned Bounding Box in world space. Range: See #NxBounds3 + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] nbShapes Number of shapes that the buffer shapes can hold. + \param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes. + \param[in] callback Alternative method to retrieve overlapping shapes. Is called with sets of overlapping shapes. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + \param[in] accurateCollision True to test the AABB against the actual shapes, false to test against the AABBs only. + + \return the total number of collided shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxShapesType overlapAABBShapes NxUserEntityReport NxShape.checkOverlapAABB() + */ + virtual NxU32 overlapAABBShapes (const NxBounds3& worldBounds, NxShapesType shapeType, NxU32 nbShapes, NxShape** shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, bool accurateCollision=false) = 0; + + /** + \brief Returns the set of shapes overlapped by the world-space OBB. + + You can test against static and/or dynamic objects by adjusting 'shapeType'. + Shapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'. + An alternative is to use the ::NxUserEntityReport callback mechanism. + + The function returns the total number of collided shapes. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldBox Oriented Bounding Box in world space. Range: See #NxBox + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] nbShapes Number of shapes that the buffer shapes can hold. + \param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes. + \param[in] callback Alternative method to retrieve overlapping shapes. Is called with sets of overlapping shapes. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + \param[in] accurateCollision True to test the OBB against the actual shapes, false to test against the AABBs only. + + \return the total number of collided shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxShapesType overlapOBBShapes NxUserEntityReport NxShape.checkOverlapOBB() + */ + virtual NxU32 overlapOBBShapes (const NxBox& worldBox, NxShapesType shapeType, NxU32 nbShapes, NxShape** shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, bool accurateCollision=false) = 0; + + /** + \brief Returns the set of shapes overlapped by the world-space capsule. + + You can test against static and/or dynamic objects by adjusting 'shapeType'. + Shapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'. + An alternative is to use the ::NxUserEntityReport callback mechanism. + + The function returns the total number of collided shapes. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldCapsule capsule in world space. Range: See #NxCapsule + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] nbShapes Number of shapes that the buffer shapes can hold. + \param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes. + \param[in] callback Alternative method to retrieve overlapping shapes. Is called with sets of overlapping shapes. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + \param[in] accurateCollision True to test the capsule against the actual shapes, false to test against the AABBs only. + + \return the total number of collided shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxShapesType overlapCapsuleShapes NxUserEntityReport NxShape.checkOverlapCapsule() + */ + virtual NxU32 overlapCapsuleShapes (const NxCapsule& worldCapsule, NxShapesType shapeType, NxU32 nbShapes, NxShape** shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, bool accurateCollision=false) = 0; + +#if NX_SUPPORT_SWEEP_API + /** + \brief Creates a sweep cache, for use with NxActor::linearSweep(). See the Guide, "Sweep API" section for + more information. + @see NxActor + */ + virtual NxSweepCache* createSweepCache() = 0; + /** + \brief Deletes a sweep cache. See the Guide, "Sweep API" section, for more + information on sweep caches. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + @see NxActor + */ + virtual void releaseSweepCache(NxSweepCache* cache) = 0; + + /** + \brief Performs a linear sweep through space with an oriented box. + + The function sweeps an oriented box through space and reports any shapes in the scene + which it intersects. Apart from the number of shapes intersected in this way, and the shapes + intersected, information on the closest intersection is put in an #NxSweepQueryHit structure which + can be processed in the callback function if provided. + Which shapes in the scene are regarded is specified through the flags parameter. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldBox The oriented box (#NxBox object) that is to be swept + \param[in] motion Length and direction of the sweep + \param[in] flags Flags controlling the mode of the sweep + \param[in] userData User data to impart to the returned data struct + \param[in] nbShapes Maximum number of shapes to report Range: [1,NX_MAX_U32] + \param[out] shapes Pointer to buffer for reported shapes + \param[in] callback Callback function invoked on the closest hit (if any) + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return The number of hits reported. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox NxShape NxSweepQueryHit NxSweepFlags NxUserEntityReport NxScene + */ + virtual NxU32 linearOBBSweep (const NxBox& worldBox, const NxVec3& motion, NxU32 flags, void* userData, NxU32 nbShapes, NxSweepQueryHit* shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; + /** + \brief Performs a linear sweep through space with an oriented capsule. + + The function a capsule through space and reports any shapes in the scene + which it intersects. Apart from the number of shapes intersected in this way, and the shapes + intersected, information on the closest intersection is put in an #NxSweepQueryHit structure which + can be processed in the callback function if provided. + Which shapes in the scene are regarded is specified through the flags parameter. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldCapsule The oriented capsule (#NxCapsule object) that is to be swept + \param[in] motion Length and direction of the sweep + \param[in] flags Flags controlling the mode of the sweep + \param[in] userData User data to impart to the returned data struct + \param[in] nbShapes Maximum number of shapes to report Range: [1,NX_MAX_U32] + \param[out] shapes Pointer to buffer for reported shapes + \param[in] callback Callback function invoked on the closest hit (if any) + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return The number of hits reported. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsule NxShape NxSweepQueryHit NxSweepFlags NxUserEntityReport NxScene + */ + virtual NxU32 linearCapsuleSweep (const NxCapsule& worldCapsule, const NxVec3& motion, NxU32 flags, void* userData, NxU32 nbShapes, NxSweepQueryHit* shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; +#endif + + /** + \brief Returns the set of shapes which are in the negative half space of a number of planes. + + This function returns the set of shapes whose axis aligned bounding volumes are in the negative + half space(side the normal points away from) of all the planes passed in. + + However the set of shapes returned is not conservative, ie additional shapes may be returned which + do not actually intersect the union of the planes negative half space. + + You can test against static and/or dynamic objects by adjusting 'shapeType'. + Shapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'. + An alternative is to use the ::NxUserEntityReport callback mechanism. + + The function returns the total number of collided shapes. + + This function can be used for view-frustum culling by passing the 6 camera planes to the function. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \warning Passing more than 32 planes to this function is unsupported and may result in undefined behavior. + + \param[in] nbPlanes Number of planes to test. (worldPlanes should contain this many planes) + \param[in] worldPlanes Set of planes to test. Range: See #NxPlane + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] nbShapes Number of shapes that the buffer shapes can hold. + \param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes. + \param[in] callback Alternative method to retrieve overlapping shapes. Is called with sets of overlapping shapes. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return the total number of collided shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPlane overlapAABBShapes() overlapSphereShapes() NxShapesType NxUserEntityReport NxShape.setGroup() + */ + + virtual NxU32 cullShapes (NxU32 nbPlanes, const NxPlane* worldPlanes, NxShapesType shapeType, NxU32 nbShapes, NxShape** shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; + + /** + \brief Checks whether a world-space sphere overlaps a shape or not. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldSphere Sphere description in world space. Range: See #NxSphere + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return True if the sphere overlaps a shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere NxShapesType overlapSphereShapes NxShape.checkOverlapSphere() + */ + virtual bool checkOverlapSphere (const NxSphere& worldSphere, NxShapesType shapeType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; + + /** + \brief Checks whether a world-space AABB overlaps a shape or not. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldBounds Axis Aligned Bounding Box in world space. Range: See #NxBounds3 + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return True if the AABB overlaps a shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxShapesType overlapAABBShapes NxShape.checkOverlapAABB() + */ + virtual bool checkOverlapAABB (const NxBounds3& worldBounds, NxShapesType shapeType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; + + /** + \brief Checks whether a world-space OBB overlaps a shape or not. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldBox Oriented Bounding Box in world space. Range: See #NxBounds3 + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return True if the OBB overlaps a shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxShapesType overlapOBBShapes NxShape.checkOverlapOBB() + */ + virtual bool checkOverlapOBB (const NxBox& worldBox, NxShapesType shapeType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; + + /** + \brief Checks whether a world-space capsule overlaps something or not. + + \note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is + taken. For example the result of setting the global pose is not immediatly visible. + + \param[in] worldCapsule Capsule description in world space. Range: See #NxCapsule + \param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType. + \param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup + \param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask + + \return True if the capsule overlaps a shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCapsule NxShapesType NxShape.setGroup NxShape.setGroupsMask + */ + virtual bool checkOverlapCapsule (const NxCapsule& worldCapsule, NxShapesType shapeType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL) = 0; + + //virtual NxU32 overlapAABBTriangles (const NxBounds3& worldBounds, NxArraySDK& worldTriangles) = 0; +//@} +/************************************************************************************************/ + + + + + + + +/** @name Fluids +*/ +//@{ + +#if NX_USE_FLUID_API + + /** + \brief Creates a fluid in this scene. + + NxFluidDesc::isValid() must return true. + + \param[in] fluidDesc Description of the fluid object to create. See #NxFluidDesc. + \return The new fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see releaseFluid() + */ + virtual NxFluid* createFluid(const NxFluidDescBase& fluidDesc) = 0; + + /** + \brief Deletes the specified fluid. The fluid must be in this scene. + + Also releases any screen surface meshes created from the fluid. + + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param[in] fluid Fluid to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see createFluid() + */ + virtual void releaseFluid(NxFluid& fluid) = 0; + + /** + \brief Get the number of fluids belonging to the scene. + + \return the number of fluids. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getFluids() + */ + virtual NxU32 getNbFluids() const = 0; + + /** + \brief Get an array of fluids belonging to the scene. + + \return an array of fluid pointers with size getNbFluids(). + + \return An array of fluid objects belonging to this scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbFluids() + */ + virtual NxFluid** getFluids() = 0; + + + /** + \brief Pre-cooks all triangles from static NxTriangleMeshShapes of the scene which are intersecting with the given bounds. + + The pre-cooking will only be valid for Fluids which share the specified parameters (see NxFluidDesc) + + \param[in] bounds The volume whose contents should be pre-cooked + \param[in] packetSizeMultiplier + \param[in] restParticlesPerMeter + \param[in] kernelRadiusMultiplier + \param[in] motionLimitMultiplier + \param[in] collisionDistanceMultiplier + \param[in] compartment The specific compartment to perform the pre-cooking for. + \param[in] forceStrictCookingFormat Forces specified cooking parameters. Otherwise they might internaly be reinterpreted depending on created fluids. Not implemented yet. + + \return Operation succeeded. + @see NxFluidDesc + */ + virtual bool cookFluidMeshHotspot(const NxBounds3& bounds, NxU32 packetSizeMultiplier, NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxReal collisionDistanceMultiplier, NxCompartment* compartment = NULL, bool forceStrictCookingFormat = false) = 0; + +#endif +//@} +/************************************************************************************************/ + +//@} +/************************************************************************************************/ +/** @name Cloth +*/ +//@{ + +#if NX_USE_CLOTH_API + + /** + Creates a cloth in this scene. NxClothDesc::isValid() must return true. + + \param clothDesc Description of the cloth object to create. See #NxClothDesc. + \return The new cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc NxCloth + */ + virtual NxCloth* createCloth(const NxClothDesc& clothDesc) = 0; + + /** + Deletes the specified cloth. The cloth must be in this scene. + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param cloth Cloth to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCloth + */ + virtual void releaseCloth(NxCloth& cloth) = 0; + + /** + \return the number of cloths. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCloths() + */ + virtual NxU32 getNbCloths() const = 0; + + /** + \brief Returns an array of cloth objects. + + \return an array of cloth pointers with size getNbCloths(). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbCloths() + */ + virtual NxCloth** getCloths() = 0; + +#endif +//@} + +/************************************************************************************************/ +/** @name SoftBody +*/ +//@{ + +#if NX_USE_SOFTBODY_API + + /** + Creates a soft body in this scene. NxSoftBodyDesc::isValid() must return true. + + \param softBodyDesc Description of the soft body object to create. See #NxSoftBodyDesc. + \return The new soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc NxSoftBody + */ + virtual NxSoftBody* createSoftBody(const NxSoftBodyDesc& softBodyDesc) = 0; + + /** + Deletes the specified soft body. The soft body must be in this scene. + Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param softBody Soft body to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBody + */ + virtual void releaseSoftBody(NxSoftBody& softBody) = 0; + + /** + \return the number of soft bodies. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSoftBodies() + */ + virtual NxU32 getNbSoftBodies() const = 0; + + /** + \brief Returns an array of soft body objects. + + \return an array of soft body pointers with size getNbSoftBodies(). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNbSoftBodies() + */ + virtual NxSoftBody** getSoftBodies() = 0; + +#endif +//@} + +/************************************************************************************************/ + + /** + \brief This is a query to see if the scene is in a state that allows the application to update scene state. + + \return True if the scene can be written by the application. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool isWritable() = 0; + + /** + \brief Advances the simulation by an elapsedTime time. + + If elapsedTime is large, it is internally subdivided according to parameters provided with the + #setTiming() method. See #setTiming() for a more detailed discussion of the elapsedTime parameter + and time stepping behavior. + + Calls to simulate() should pair with calls to fetchResults(): + Each fetchResults() invocation corresponds to exactly one simulate() + invocation; calling simulate() twice without an intervening fetchResults() + or fetchResults() twice without an intervening simulate() causes an error + condition. + + scene->simulate(); + ...do some processing until physics is computed... + scene->fetchResults(); + ...now results of run may be retrieved. + + Applications should not modify physics objects between calls to + simulate() and fetchResults(); + + This method replaces startRun(). + + + \param[in] elapsedTime Amount of time to advance simulation by. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see fetchResults() checkResults() + */ + virtual void simulate(NxReal elapsedTime) = 0; + + /** + \brief This checks to see if the part of the simulation run whose results you are interested in has completed. + + This does not cause the data available for reading to be updated with the results of the simulation, it is simply a status check. + The bool will allow it to either return immediately or block waiting for the condition to be met so that it can return true + + This method replaces wait() + + \param[in] status The part of the simulation to check (eg NX_RIGID_BODY_FINISHED). See #NxSimulationStatus. + \param[in] block When set to true will block until the condition is met. + \return True if the results are available. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see simulate() fetchResults() + */ + virtual bool checkResults(NxSimulationStatus status, bool block = false) = 0; + + /** + This is the big brother to checkResults() it basically does the following: + + \code + if ( checkResults(enum, block) ) + { + fire appropriate callbacks + swap buffers + if (CheckResults(all_enums, false)) + make IsWritable() true + return true + } + else + return false + + \endcode + + \param[in] status The part of the simulation to fetch results for (eg NX_RIGID_BODY_FINISHED). See #NxSimulationStatus. + \param[in] block When set to true will block until the condition is met. + \param[out] errorState Used to retrieve hardware error codes. A non zero value indicates an error. + \return True if the results have been fetched. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see simulate() checkResults() + */ + virtual bool fetchResults(NxSimulationStatus status, bool block = false, NxU32 *errorState = 0) = 0; + + /** + Flush internal caches. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void flushCaches() = 0; + + /** + Accesses internal profiler. If clearData is true, the profile counters are reset. You will most likely want to call readProfileData(true) + right after calling fetchResults(). If that is not the time you want to read out the data, just call readProfileData(false) at some other place + in your code. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual const NxProfileData * readProfileData(bool clearData) = 0; + + /** + \brief Poll for work to execute on the current thread. + + Returns NX_THREAD_SIMULATION_END if the simulation step ended, + NX_THREAD_NOWORK if no work is available, NX_THREAD_MOREWORK if + there may be work remaining to execute. + + The function waits for work to execute according the the waitType argument. + + The function will continue to return NX_THREAD_SIMULATION_END until the + #resetPollForWork() method is called. + + \param[in] waitType Specifies how long the function should wait for work. + \return Informs the user about the reason for returning. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see resetPollForWork() NxThreadWait NxThreadPollResult + */ + virtual NxThreadPollResult pollForWork(NxThreadWait waitType)=0; + + /** + \brief Reset parallel simulation + + Resets parallel simulation so that threads calling pollForWork do not + return NX_THREAD_SIMULATION_END, but instead wait for a new simulation + step to start. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + + @see pollForWork() NxThreadPollResult NxThreadWait + */ + + virtual void resetPollForWork()=0; + + /** + \brief Polls for background work. + + Returns NX_THREAD_NOWORK if no work is available, NX_THREAD_MOREWORK if + there may be work remaining to execute or NX_THREAD_SHUTDOWN if + the thread was released by shutdownWorkerThreads(). + + The function waits for work to execute according the the waitType argument. + + The NX_WAIT_SIMULATION_END does not make sense for background tasks, as they are not + associated with a particular simulation step. + + \param[in] waitType Specifies how long the function should wait for work. + \return Informs the user about the reason for returning. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see resetPollForWork() NxThreadWait NxThreadPollResult + */ + virtual NxThreadPollResult pollForBackgroundWork(NxThreadWait waitType)=0; + + /** + \brief Release threads which are blocking to allow the SDK to be destroyed safely. + + Note: This also applies to SDK managed threads. So calling shutdownWorkerThreads will release + all threads which are waiting using NX_WAIT_SHUTDOWN, which includes internal SDK threads. + + When internal threads are released by shutdownWorkerThreads() they will exit. + + In a typical application, the user should call shutdownWorkerThreads prior to destroying the + scene. Then they will block until all user owned threads have left the API. It is then + safe to release the scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see pollForBackgroundWork() + */ + virtual void shutdownWorkerThreads()=0; + + /** + \brief Blocks all parallel raycast/overlap queries. + + This method should be used to lock raycasts from other threads while the SDK state is being updated in a way + which will affect raycasting/overlap queries. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see unlockQueries() + */ + virtual void lockQueries()=0; + + /** + \brief Unlock parallel raycast/overlap queries. + + See #lockQueries() for more details. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see lockQueries() + */ + virtual void unlockQueries()=0; + + // BATCHED_RAYCASTS + + /** + \brief Create a batched query object. + + \param[in] desc Descriptor used to modify the created query object. + \return A new query object. + + Platform: + \li PC SW: Yes + \li PPU : Yes (software) + \li PS3 : Yes + \li XB360: Yes + + @see releaseSceneQuery() NxSceneQueryDesc NxSceneQuery + */ + virtual NxSceneQuery* createSceneQuery(const NxSceneQueryDesc& desc) = 0; + + /** + + \brief Release a scene query object. + + \param[in] query The query object to release. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes (software) + \li PS3 : Yes + \li XB360: Yes + + @see createSceneQuery() NxSceneQuery + */ + virtual bool releaseSceneQuery(NxSceneQuery& query) = 0; + //~ BATCHED_RAYCASTS + + /** + \brief Sets the rebuild rate of the dynamic tree pruning structure. + + \param[in] dynamicTreeRebuildRateHint Rebuild rate of the dynamic tree pruning structure. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneDesc.dynamicTreeRebuildRateHint getDynamicTreeRebuildRateHint() + */ + virtual void setDynamicTreeRebuildRateHint(NxU32 dynamicTreeRebuildRateHint) = 0; + + /** + \brief Retrieves the rebuild rate of the dynamic tree pruning structure. + + \return The rebuild rate of the dyamic tree pruning structure. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint() + */ + virtual NxU32 getDynamicTreeRebuildRateHint() const = 0; + + /** + \brief Sets the number of actors required to spawn a separate rigid body solver thread. + + \note If internal multi threading is disabled (see #NX_SF_ENABLE_MULTITHREAD) this call will + have no effect. + + \param[in] solverBatchSize Number of actors required to spawn a separate rigid body solver thread. + + Platform: + \li PC SW: Yes + \li PPU : Not applicable + \li PS3 : Not applicable + \li XB360: Yes + + @see NxSceneDesc.solverBatchSize getSolverBatchSize() + */ + virtual void setSolverBatchSize(NxU32 solverBatchSize) = 0; + + /** + \brief Retrieves the number of actors required to spawn a separate rigid body solver thread. + + \return Current number of actors required to spawn a separate rigid body solver thread. + + Platform: + \li PC SW: Yes + \li PPU : Not applicable + \li PS3 : Not applicable + \li XB360: Yes + + @see NxSceneDesc.solverBatchSize setSolverBatchSize() + */ + virtual NxU32 getSolverBatchSize() const = 0; + + + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + void* extLink; //!< reserved for linkage with other Ageia components. Applications and SDK should not modify + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSceneDesc.h b/libraries/external/physx/Win32/include/PX/NxSceneDesc.h new file mode 100755 index 0000000..2a9157f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSceneDesc.h @@ -0,0 +1,1109 @@ +#ifndef NX_PHYSICS_NXSCENEDESC +#define NX_PHYSICS_NXSCENEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +/** +\brief Used to specify the timestepping behavior. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxSceneDesc +*/ +enum NxTimeStepMethod + { + NX_TIMESTEP_FIXED, //!< The simulation automatically subdivides the passed elapsed time into maxTimeStep-sized substeps. + NX_TIMESTEP_VARIABLE, //!< The simulation uses the elapsed time that the user passes as-is, substeps (maxTimeStep, maxIter) are not used. + NX_TIMESTEP_INHERIT, //!< Inherit timing settings from primary scene. Only valid for compartments. + NX_NUM_TIMESTEP_METHODS, + + NX_TSM_FORCE_DWORD = 0x7fffffff //!< Just to make sure sizeof(enum) == 4, not a valid value. + }; + +/** +\brief Used to choose between a hardware and software master scene. + +This enum is used with the NxSceneDesc::simType member. + +\note The master scene is a rigid body scene (which can also contain cloth); compartments are used for fluid. +Compartments can run in hardware even if the master scene is a software scene. + +@see NxSceneDesc +*/ +enum NxSimulationType + { + NX_SIMULATION_SW = 0, //!< Create a software master scene. + NX_SIMULATION_HW = 1, //!< Create a hardware master scene. + + NX_STY_FORCE_DWORD = 0x7fffffff //!< Just to make sure sizeof(enum) == 4, not a valid value. + }; + +/** +\brief Pruning structure used to accelerate scene queries (raycast, sweep tests, etc) + + NX_PRUNING_NONE can be used without defining extra parameters. It typically doesn't provide + fast scene queries, but on the other hand it doesn't consume much memory. It is useful when + you don't use the SDK's scene queries at all. + + NX_PRUNING_OCTREE usually provides fast queries and cheap per-object updates. You need + to define "maxBounds" and "subdivisionLevel" to use this structure. + + NX_PRUNING_QUADTREE is the 2D version of NX_PRUNING_OCTREE. It is usually a better choice + when your world is mostly flat. It is sometimes a better choice for non-flat worlds as well. + You need to define "maxBounds", "subdivisionLevel" and "upAxis" to use this structure. + + NX_PRUNING_DYNAMIC_AABB_TREE usually provides the fastest queries. However there is a + constant per-frame management cost associated with this structure. You have the option to + give a hint on how much work should be done per frame by setting the parameter + #NxSceneDesc::dynamicTreeRebuildRateHint. + + NX_PRUNING_STATIC_AABB_TREE is typically used for static objects. It is the same as the + dynamic AABB tree, without the per-frame overhead. This is the default choice for static + objects. However, if you are streaming parts of the world in and out, you may want to use + the dynamic version even for static objects. +*/ +enum NxPruningStructure + { + NX_PRUNING_NONE, //!< No structure, using a linear list of objects + NX_PRUNING_OCTREE, //!< Using a preallocated loose octree + NX_PRUNING_QUADTREE, //!< Using a preallocated loose quadtree + NX_PRUNING_DYNAMIC_AABB_TREE, //!< Using a dynamic AABB tree + NX_PRUNING_STATIC_AABB_TREE, //!< Using a static AABB tree + }; + +/** +\brief Selects a broadphase type. +*/ +enum NxBroadPhaseType +{ + /** + \brief A sweep-and-prune (SAP) algorithm to find pairs of potentially colliding shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_BP_TYPE_SAP_SINGLE, + + /** + \brief A multi sweep-and-prune algorithm to find pairs of potentially colliding shapes. + + Uses a configurable 2D grid to divide the scene space into cells. The potentially overlapping + shape pairs are detected in each cell and the information is merged together. This approach + is usually faster than NX_BP_TYPE_SAP_SINGLE in scenarios with many shapes and a high creation/deletion + rate of shapes. However, the amount of memory required is considerably higher depending on the + number of grid cells used. + + \note The following extra parameters need to be defined: + \li NxSceneDesc.maxBounds + \li NxSceneDesc.upAxis + \li NxSceneDesc.nbGridCellsX + \li NxSceneDesc.nbGridCellsY + + \n + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : No + \li XB360: Yes + + @see NxSceneDesc.bpType + */ + NX_BP_TYPE_SAP_MULTI, +}; + +enum NxSceneFlags + { + /** + \brief Used to disable use of SSE in the solver. + + SSE is detected at runtime(on appropriate platforms) and used if present by default. + + However use of SSE can be disabled, even if present, using this flag. + + Platform: + \li PC SW: Yes + \li PPU : N/A + \li PS3 : N/A + \li XB360: N/A + */ + NX_SF_DISABLE_SSE =0x1, + + /** + \brief Disable all collisions in a scene. Use the flags NX_AF_DISABLE_COLLISION and NX_SF_DISABLE_COLLISION for disabling collisions between specific actors and shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NX_AF_DISABLE_COLLISION, NX_SF_DISABLE_COLLISION + */ + NX_SF_DISABLE_COLLISIONS =0x2, + + /** + \brief Perform the simulation in a separate thread. + + By default the SDK runs the physics on a separate thread to the user thread(i.e. the thread which + calls the API). + + However if this flag is disabled, then the simulation is run in the thread which calls #NxScene::simulate() + + Default: True + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.simulate() + */ + NX_SF_SIMULATE_SEPARATE_THREAD =0x4, + + /** + \brief Enable internal multi threading. + + This flag enables the multi threading code within the SDK which allows the simulation to + be divided into tasks for execution on an arbitrary number of threads. + + This is an orthogonal feature to running the simulation in a separate thread, see #NX_SF_SIMULATE_SEPARATE_THREAD. + + \note There may be a small performance penalty for enabling the multi threading code, hence this flag should + only be enabled if the application intends to use the feature. + + Default: False + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxSceneDesc NX_SF_SIMULATE_SEPARATE_THREAD + */ + NX_SF_ENABLE_MULTITHREAD =0x8, + + /** + \brief Enable Active Transform Notification. + + This flag enables the the Active Transform Notification feature for a scene. This + feature defaults to disabled. When disabled, the function + NxScene::getActiveTransforms() will always return a NULL list. + + \note There may be a performance penalty for enabling the Active Transform Notification, hence this flag should + only be enabled if the application intends to use the feature. + + Default: False + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SF_ENABLE_ACTIVETRANSFORMS =0x10, + + /** + \brief Enable Restricted Scene. + + \note Only applies to hardware scenes. + + This flag creates a restricted scene, running the broadphase collision detection on hardware, + while limiting the number of actors (see "AGEIA PhysX Hardware Scenes" in the Guide). + + Default: False + + Platform: + \li PC SW: No + \li PPU : Yes + \li PS3 : No + \li XB360: No + */ + NX_SF_RESTRICTED_SCENE =0x20, + + /** + \brief Disable the mutex which serializes scene execution + + Under normal circumstances scene execution is serialized by a mutex. This flag + can be used to disable this serialization. + + \warning This flag is _experimental_ and in future versions is likely be removed. In favour of + completely removing the mutex. + + If this flag is used the recommended scenario is for use with a software scene and hardware fluid/cloth scene. + + Default: True (change from earlier beta versions) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SF_DISABLE_SCENE_MUTEX =0x40, + + + /** + \brief Force the friction model to cone friction + + This ensures that all contacts in the scene will use cone friction, rather than the default + simplified scheme. This will however have a negative impact on performance in software scenes. Use this + flag if sliding objects show an affinity for moving along the world axes. + + \note Only applies to software scenes; hardware scenes always force cone friction. + + Cone friction may also be activated on an actor-by-actor basis using the NX_AF_FORCE_CONE_FRICTION flag, see #NxActorFlag. + + Default: False + + Platform: + \li PC SW: Yes + \li PPU : Yes (always active) + \li PS3 : Yes + \li XB360: Yes + */ + NX_SF_FORCE_CONE_FRICTION =0x80, + + + /** + \brief When set to 1, the compartments are all executed before the primary scene is executed. This may lower performance + but it improves interaction quality between compartments and the primary scene. + + Default: False + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: No + */ + NX_SF_SEQUENTIAL_PRIMARY =0x80*2, + + /** + \brief Enables faster but less accurate fluid collision with static geometry. + + If the flag is set static geometry is considered one simulation step late, which + can cause particles to leak through static geometry. In order to prevent this, + NxFluidDesc.collisionDistanceMultiplier can be increased. + + Default: False + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SF_FLUID_PERFORMANCE_HINT =0x80*4, + + }; + +class NxUserNotify; +class NxFluidUserNotify; +class NxClothUserNotify; +class NxSoftBodyUserNotify; +class NxUserContactModify; +class NxUserTriggerReport; +class NxUserContactReport; +class NxUserActorPairFiltering; +class NxBounds3; +class NxUserScheduler; + +/** +\brief Class used to retrieve limits(e.g. max number of bodies) for a scene. The limits +are used as a hint to the size of the scene, not as a hard limit (i.e. it will be possible +to create more objects than specified in the scene limits). + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes +*/ +class NxSceneLimits + { + public: + NxU32 maxNbActors; //!< Expected max number of actors + NxU32 maxNbBodies; //!< Expected max number of bodies + NxU32 maxNbStaticShapes; //!< Expected max number of static shapes + NxU32 maxNbDynamicShapes; //!< Expected max number of dynamic shapes + NxU32 maxNbJoints; //!< Expected max number of joints + + NX_INLINE NxSceneLimits(); + }; + +NX_INLINE NxSceneLimits::NxSceneLimits() //constructor sets to default + { + maxNbActors = 0; + maxNbBodies = 0; + maxNbStaticShapes = 0; + maxNbDynamicShapes = 0; + maxNbJoints = 0; + } + +/** +\brief Descriptor class for scenes. See #NxScene. + +@see NxScene NxPhysicsSDK.createScene maxBounds +*/ + +class NxSceneDesc + { + public: + + /** + \brief Gravity vector + + Range: force vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.setGravity() + */ + NxVec3 gravity; + + /** + \brief Possible notification callback + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserNotify NxScene.setUserNotify() NxScene.getUserNotify() + */ + NxUserNotify* userNotify; + + /** + \brief Possible notification callback for fluids + + Default: NULL + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxFluidUserNotify NxScene.setFluidUserNotify() NxScene.getFluidUserNotify() + */ + NxFluidUserNotify* fluidUserNotify; + + /** + \brief Possible notification callback for cloths + + Default: NULL + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxClothUserNotify NxScene.setClothUserNotify() NxScene.getClothUserNotify() + */ + NxClothUserNotify* clothUserNotify; + + /** + \brief Possible notification callback for softBodys + + Default: NULL + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxSoftBodyUserNotify NxScene.setSoftBodyUserNotify() NxScene.getSoftBodyUserNotify() + */ + NxSoftBodyUserNotify* softBodyUserNotify; + + /** + \brief Possible asynchronous callback for contact modification + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserContactModify NxScene.setUserContactModify() NxScene.getUserContactModify() + */ + NxUserContactModify* userContactModify; + + /** + \brief Possible trigger callback + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserTriggerReport NxScene.setUserTriggerReport() NxScene.getUserTriggerReport() + */ + NxUserTriggerReport* userTriggerReport; + + /** + \brief Possible contact callback + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxUserContactReport NxScene.setUserContactReport() NxScene.getUserContactReport() + */ + NxUserContactReport* userContactReport; + + /** + \brief Internal. Do not use! + */ + NxUserActorPairFiltering* userActorPairFiltering; + + /** + \brief Maximum substep size. + + Range: (0,inf)
+ Default: 1.0/60.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.setTiming() maxIter + */ + NxReal maxTimestep; + + /** + \brief Maximum number of substeps to take + + Default: 8 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.setTiming() maxTimestep + */ + NxU32 maxIter; + + /** + \brief Integration method. + + Default: NX_TIMESTEP_FIXED + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTimeStepMethod NxScene.setTiming() maxTimestep maxIter + */ + NxTimeStepMethod timeStepMethod; + + /** + \brief Max scene bounds. + + If scene bounds are provided (maxBounds in the descriptor), the SDK takes advantage of this information + to accelerate scene-level collision queries (e.g. raycasting). When using maxBounds, you have to make + sure created objects stay within the scene bounds. In particular, the position of dynamic shapes should + stay within the provided bounds. Otherwise the shapes outside the bounds will not be taken into account + by all scene queries (raycasting, sweep tests, overlap tests, etc). They will nonetheless still work + correctly for the main physics simulation. + + Range: See #NxBounds3
+ Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxBounds3* maxBounds; + + /** + \brief Expected scene limits (or NULL) + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSceneLimits + */ + NxSceneLimits* limits; + + /** + \brief Used to specify if the scene is a master hardware or software scene. + + Default: NX_SIMULATION_SW + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSimulationType + */ + NxSimulationType simType; + + /** + \brief Enable/disable default ground plane + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Default: false + */ + NX_BOOL groundPlane; + + /** + \brief Enable/disable 6 planes around maxBounds (if available) + + Default: false + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see maxBounds + */ + NX_BOOL boundsPlanes; + + /** + \brief Flags used to select scene options. + + Default: NX_SF_SIMULATE_SEPARATE_THREAD | NX_SF_DISABLE_SCENE_MUTEX + + Platform: + \li PC SW: Yes + \li PPU : Partial + \li PS3 : Yes (however, default value is NX_SF_SIMULATE_SEPARATE_THREAD) + \li XB360: Yes + + @see NxSceneFlags + */ + NxU32 flags; + + /** + \brief Defines a custom scheduler. + + The application can define a custom scheduler to completely take over the allocation of work items among threads. + + An alternative is for the application to use the built in scheduler. See #internalThreadCount + + Default: NULL (disabled) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxScheduler NX_SF_ENABLE_MULTITHREAD internalThreadCount + */ + NxUserScheduler* customScheduler; + + /** + \brief Allows the user to specify the stack size for the main simulation thread. + + The value is specified in bytes and rounded to an appropriate size by the operating system. + + NOTE: If you increase the stack size for all threads that call the SDK, you may want to call + #NxFoundationSDK::setAllocaThreshold to prevent unnecessary heap allocations. + + Specifying a value of zero will cause the SDK to choose a platform specific default value: + + \li PC SW - OS default + \li PPU - OS default + \li PS3 - 256k + \li XBox 360 - OS default + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 simThreadStackSize; + + /** + \brief Sets the thread priority of the main simulation thread. + + The default is normal priority. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: No + */ + NxThreadPriority simThreadPriority; + + /** + \brief Allows the user to specify which (logical) processor to allocate the simulation thread to. + + The sim thread will be allocated to processors corresponding to bits which are set. Starting from + the least significant bit. + + This flag is ignored for platforms which do not associate threads exclusively to specific processors. + + \note The XBox 360 associates threads with specific processors. + \note The special value of 0 lets the SDK determine the thread affinity. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + */ + NxU32 simThreadMask; + + /** + \brief Sets the number of SDK managed worker threads used when running the simulation in parallel. + + When internal multi threading is enabled(see #NX_SF_ENABLE_MULTITHREAD) the SDK creates a number of + threads to run the simulation. This member controls the number of threads. + + This member is ignored if the application takes over control of the work allocation with a custom scheduler. + + \note This is poorly named; should be renamed workerThreadCount for consistency. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see customScheduler + */ + NxU32 internalThreadCount; + + /** + \brief Allows the user to specify the stack size for the worker threads created by the SDK. + + The value is specified in bytes and rounded to an appropriate size by the operating system. + + NOTE: If you increase the stack size for all threads that call the SDK, you may want to call + #NxFoundationSDK::setAllocaThreshold to prevent unnecessary heap allocations. + + Specifying a value of zero will cause the SDK to choose a platform specific default value. + + + \li PC SW - OS default + \li PPU - OS default + \li XBox 360 - OS default + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + */ + NxU32 workerThreadStackSize; + + /** + \brief Sets the thread priority of the SDK created worker threads + + The default is normal priority. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: No + */ + NxThreadPriority workerThreadPriority; + + /** + \brief Allows the user to specify which (logical) processor to allocate SDK internal worker threads to. + + The SDK Will allocate internal threads to processors corresponding to bits which are set. Starting from + the least significant bit. + + This flag is ignored for platforms which do not associate threads exclusively to specific processors. + + \note The XBox 360 associates threads with specific processors. + \note This is poorly named; should be renamed workerThreadMask for consistency. + \note The special value of 0 lets the SDK determine the thread affinity. + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + */ + NxU32 threadMask; + + /** + \brief Sets the number of SDK managed threads which will be processing background tasks. + + For example scene queries can run on these threads or the SDK may need to preprocess data to be sent to the + PhysX card. + + This member must be set to 0 if the application takes over control of the work allocation with a custom scheduler. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see customScheduler + */ + NxU32 backgroundThreadCount; + + /** + \brief Sets the thread priority of the SDK created background threads + + The default is normal priority. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: No + */ + NxThreadPriority backgroundThreadPriority; + + /** + \brief Allows the user to specify which (logical) processor to allocate SDK background threads. + + The SDK Will allocate internal threads to processors corresponding to bits which are set. Starting from + the least significant bit. + + This flag is ignored for platforms which do not associate threads exclusively to specific processors. + + \note The XBox 360 associates threads with specific processors. + \note The special value of 0 lets the SDK determine the thread affinity. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + */ + NxU32 backgroundThreadMask; + + + + /** + \brief Defines the up axis for your world. This is used to accelerate scene queries like + raycasting or sweep tests. Internally, a 2D structure is used instead of a 3D one whenever + an up axis is defined. This saves memory and is usually faster. + + Use 1 for Y = up, 2 for Z = up, or 0 to disable this feature. + It is not possible to use X = up. + + \note WARNING: this is only used when maxBounds are defined. + */ + NxU32 upAxis; + + /** + \brief Defines the subdivision level for acceleration structures used for scene queries. + + \note WARNING: this is only used when maxBounds are defined. + */ + NxU32 subdivisionLevel; + + /** + \brief Defines the structure used to store static objects. + + \note Only NX_PRUNING_STATIC_AABB_TREE and NX_PRUNING_DYNAMIC_AABB_TREE are allowed here. + */ + NxPruningStructure staticStructure; + + /** + \brief Defines the structure used to store dynamic objects. + */ + NxPruningStructure dynamicStructure; + + /** + \brief Hint for how much work should be done per simulation frame to rebuild the pruning structure. + + This parameter gives a hint on the distribution of the workload for rebuilding the dynamic AABB tree + pruning structure #NX_PRUNING_DYNAMIC_AABB_TREE. It specifies the desired number of simulation frames + the rebuild process should take. Higher values will decrease the workload per frame but the pruning + structure will get more and more outdated the longer the rebuild takes (which can make + scene queries less efficient). + + \note Only used for #NX_PRUNING_DYNAMIC_AABB_TREE pruning structure. + + \note This parameter gives only a hint. The rebuild process might still take more or less time depending on the + number of objects involved. + + Range: [5, inf]
+ Default: 100 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxU32 dynamicTreeRebuildRateHint; + + /** + \brief Will be copied to NxScene::userData + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + void* userData; + + /** + \brief Defines which type of broadphase to use. + + Default: NX_BP_TYPE_SAP_SINGLE + + @see NxBroadPhaseType + */ + NxBroadPhaseType bpType; + + /** + \brief Defines the number of broadphase cells along the grid x-axis. + + \note Must be power of two. Max is 8 at the moment. The broadphase type must be set to NX_BP_TYPE_SAP_MULTI + for this parameter to have an effect. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : No + \li XB360: Yes + + @see NxSceneDesc.bpType + */ + NxU32 nbGridCellsX; + + /** + \brief Defines the number of broadphase cells along the grid y-axis. + + \note Must be power of two. Max is 8 at the moment. The broadphase type must be set to NX_BP_TYPE_SAP_MULTI + for this parameter to have an effect. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : No + \li XB360: Yes + + @see NxSceneDesc.bpType + */ + NxU32 nbGridCellsY; + + /** + \brief Defines the number of actors required to spawn a separate rigid body solver thread. + + \note Internal multi threading must be enabled (see #NX_SF_ENABLE_MULTITHREAD) for this member to have + any effect. + + Default: 32 + + Platform: + \li PC SW: Yes + \li PPU : Not applicable + \li PS3 : Not applicable + \li XB360: Yes + + @see NxScene.setSolverBatchSize() NxScene.getSolverBatchSize() + */ + NxU32 solverBatchSize; + + /** + \brief constructor sets to default (no gravity, no ground plane, collision detection on). + */ + NX_INLINE NxSceneDesc(); + + /** + \brief (re)sets the structure to the default (no gravity, no ground plane, collision detection on). + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid (returns always true). + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxSceneDesc::NxSceneDesc() //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxSceneDesc::setToDefault() + { + gravity.zero(); + userNotify = NULL; + fluidUserNotify = NULL; + clothUserNotify = NULL; + softBodyUserNotify = NULL; + userTriggerReport = NULL; + userContactReport = NULL; + userContactModify = NULL; + userActorPairFiltering = NULL; + + maxTimestep = 1.0f/60.0f; + maxIter = 8; + timeStepMethod = NX_TIMESTEP_FIXED; + + maxBounds = NULL; + limits = NULL; + simType = NX_SIMULATION_SW; + groundPlane = false; + boundsPlanes = false; + userData = NULL; +#ifdef __CELLOS_LV2__ + flags = NX_SF_SIMULATE_SEPARATE_THREAD | NX_SF_SEQUENTIAL_PRIMARY; +#else + flags = NX_SF_SIMULATE_SEPARATE_THREAD | NX_SF_DISABLE_SCENE_MUTEX; +#endif + upAxis = 0; + subdivisionLevel = 5; + staticStructure = NX_PRUNING_STATIC_AABB_TREE; + dynamicStructure = NX_PRUNING_NONE; + dynamicTreeRebuildRateHint = 100; + + internalThreadCount = 0; + backgroundThreadCount = 0; + customScheduler = NULL; + + simThreadStackSize = 0; + simThreadPriority = NX_TP_NORMAL; + + workerThreadStackSize = 0; + workerThreadPriority = NX_TP_NORMAL; + backgroundThreadPriority= NX_TP_NORMAL; + + simThreadMask = 0; + threadMask = 0; + backgroundThreadMask = 0; + + bpType = NX_BP_TYPE_SAP_SINGLE; + nbGridCellsX = 0; + nbGridCellsY = 0; + + solverBatchSize = 32; + } + +NX_INLINE bool NxIsPowerOfTwo(NxU32 n) { return ((n&(n-1))==0); } + +NX_INLINE bool NxSceneDesc::isValid() const + { + if(bpType==NX_BP_TYPE_SAP_MULTI) + { + if(!nbGridCellsX || !NxIsPowerOfTwo(nbGridCellsX) || nbGridCellsX>8) + return false; + if(!nbGridCellsY || !NxIsPowerOfTwo(nbGridCellsY) || nbGridCellsY>8) + return false; + if(!maxBounds) + return false; + } + + if(maxTimestep <= 0 || maxIter < 1 || timeStepMethod > NX_NUM_TIMESTEP_METHODS) + return false; + if(boundsPlanes && !maxBounds) + return false; + + if(staticStructure!=NX_PRUNING_STATIC_AABB_TREE && staticStructure!=NX_PRUNING_DYNAMIC_AABB_TREE) + return false; + + if(dynamicStructure==NX_PRUNING_OCTREE || dynamicStructure==NX_PRUNING_QUADTREE) + { + if(!maxBounds) + return false; + if(dynamicStructure==NX_PRUNING_QUADTREE) + { + if(upAxis!=1 && upAxis!=2) + return false; + } + } + + if (dynamicTreeRebuildRateHint < 5) + return false; + + if((customScheduler!=NULL)&&(internalThreadCount>0)) + return false; + + if((customScheduler!=NULL)&&(backgroundThreadCount>0)) + return false; + + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSceneQuery.h b/libraries/external/physx/Win32/include/PX/NxSceneQuery.h new file mode 100755 index 0000000..7b615b3 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSceneQuery.h @@ -0,0 +1,377 @@ +#ifndef NX_PHYSICS_NX_SCENEQUERY +#define NX_PHYSICS_NX_SCENEQUERY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxUserRaycastReport.h" + +struct NxSweepQueryHit; +class NxRay; +class NxSphere; +class NxBounds3; +class NxBox; +class NxCapsule; +class NxPlane; +enum NxShapesType; + +/** +\brief Specifies the nature of the query object. + +In synchronous mode, a call to NxSceneQuery::execute() will block and batched queries are executed +immediately. + +In asynchronous mode, a call to NxSceneQuery::execute() will not block and batched queries are executed +at any point between calling NxSceneQuery::execute() and NxSceneQuery::finish() returning true. + +Note: This is a new feature in 2.7.0, and there are still some issues that will be fixed in a future version: +* cullShapes() does not work in asynchronous mode +* the return value from overlapXShapes() might not be correct in synchronous mode +* linearOBBSweep() and linearCapsuleSweep() always returns 0 when NX_SF_ALL_HITS is used. + +@see NxSceneQueryDesc NxSceneQuery +*/ +enum NxSceneQueryExecuteMode + { + NX_SQE_SYNCHRONOUS, //!< Execute queries in synchronous mode. + NX_SQE_ASYNCHRONOUS, //!< Execute queries in asynchronous mode. WARNING: NxSceneDesc::backgroundThreadCount must be at least 1 for this to work. + + NX_SQE_FORCE_DWORD = 0x7fffffff + }; + +/** +\brief Specifies the behaviour after a query result. + +@see NxSceneQueryReport NxSceneQuery +*/ +enum NxQueryReportResult + { + NX_SQR_CONTINUE, //!< Continue reporting more results + NX_SQR_ABORT_QUERY, //!< Stop reporting results for current query + NX_SQR_ABORT_ALL_QUERIES, //!< Stop reporting results for all queries + + NX_SQR_FORCE_DWORD = 0x7fffffff + }; + +/** +\brief User-defined object needed to get back query results from NxSceneQuery objects. + +@see NxSceneQuery NxQueryReportResult +*/ +class NxSceneQueryReport + { + public: + + /** + \brief Callback function used to return boolean query results. + + This function reports results from the following functions: + + \li #NxSceneQuery::raycastAnyShape() + \li #NxSceneQuery::checkOverlapSphere() + \li #NxSceneQuery::checkOverlapAABB() + \li #NxSceneQuery::checkOverlapOBB() + \li #NxSceneQuery::checkOverlapCapsule() + + \param[in] userData User data pointer passed to the query function. + \param[in] result True if there is an intersection/overlap + \return Specifies the action the SDK should take, eg continue or abort the query. + + @see NxQueryReportResult + */ + virtual NxQueryReportResult onBooleanQuery(void* userData, bool result) = 0; + + /** + \brief Callback function used to return raycast query results. + + This function reports results from the following functions: + + \li #NxSceneQuery::raycastClosestShape() + \li #NxSceneQuery::raycastAllShapes() + + \param[in] userData User data pointer passed to the query function. + \param[in] nbHits Number of hit shapes + \param[in] hits Array of hit descriptors (size nbHits) + \return Specifies the action the SDK should take, eg continue or abort the query. + + @see NxQueryReportResult + */ + virtual NxQueryReportResult onRaycastQuery(void* userData, NxU32 nbHits, const NxRaycastHit* hits) = 0; + + /** + \brief Callback function used to return shape query results. + + This function reports results from the following functions: + + \li #NxSceneQuery::overlapSphereShapes() + \li #NxSceneQuery::overlapAABBShapes() + \li #NxSceneQuery::overlapOBBShapes() + \li #NxSceneQuery::overlapCapsuleShapes() + \li #NxSceneQuery::cullShapes() + + \param[in] userData User data pointer passed to the query function. + \param[in] nbHits Number of hits returned. + \param[in] hits Array of shape pointers. + \return Specifies the action the SDK should take, e.g. continue or abort the query. + + @see NxQueryReportResult + */ + virtual NxQueryReportResult onShapeQuery(void* userData, NxU32 nbHits, NxShape** hits) = 0; + + /** + \brief Callback function used to return sweep query results. + + This function reports results from the following functions: + + \li #NxSceneQuery::linearOBBSweep() + \li #NxSceneQuery::linearCapsuleSweep() + + \param[in] userData User data pointer passed to the query function. + \param[in] nbHits Number of sweep hits. + \param[in] hits Array of sweep hits (size nbHits) + \return Specifies the action the SDK should take, eg continue or abort the query. + + @see NxQueryReportResult + */ + virtual NxQueryReportResult onSweepQuery(void* userData, NxU32 nbHits, NxSweepQueryHit* hits) = 0; + + protected: + virtual ~NxSceneQueryReport(){}; + }; + +/** +\brief Descriptor class for #NxSceneQuery. + +@see NxSceneQuery NxSceneQueryReport NxSceneQueryExecuteMode +*/ +class NxSceneQueryDesc + { + public: + /** + \brief The callback class used to return results from the batched queries. + + @see NxSceneQueryReport NxSceneQuery + */ + NxSceneQueryReport* report; + + /** + \brief The method used to execute the queries. ie synchronous or asynchronous. + + WARNING: NxSceneDesc::backgroundThreadCount must be at least 1 for the asynchronous mode to work, + else the queries will be processed in synchronous mode. + + @see NxSceneQueryExecuteMode NxSceneQuery + */ + NxSceneQueryExecuteMode executeMode; + + NxSceneQueryDesc() { setToDefault(); } + + void setToDefault() { report = NULL; executeMode = NX_SQE_SYNCHRONOUS; } + bool isValid() const { return report && executeMode < 2; } + }; + +/** +\brief Batched queries object. This is used to perform several queries at the same time. The queries are the same as the +previously available scene queries in #NxScene. + +@see NxSceneQueryReport NxSceneQueryExecuteMode +*/ +class NxSceneQuery + { + public: + + /** + \brief Gets report object + + \return The query report callback associated with this object. + + @see NxSceneQueryReport + */ + virtual NxSceneQueryReport* getQueryReport() = 0; + + + /** + \brief Gets the execution mode + + \return The execution mode for this query object. + + @see NxSceneQueryExecuteMode + */ + virtual NxSceneQueryExecuteMode getExecuteMode() = 0; + + /** + \brief Executes batched queries. + + In the synchronous mode the batched queries are executed immediately. In the asynchronous mode + they can be executed at any point between calling execute() and finish() returning true. + + WARNING: NxSceneDesc::backgroundThreadCount must be at least 1 for the asynchronous mode to work, + else the queries will be processed in synchronous mode. + + @see finish() + */ + virtual void execute() = 0; + + /** + \brief Used to determine if an execute call has completed. + + You should not call this without calling the execute function. + + When calling this method with the block parameter set to true, the method will not return until + all batched queries have been executed. + + \param[in] block Specifies if this function should wait until queries are complete. + \return true when all queries have executed. + + @see execute() + */ + virtual bool finish(bool block=false) = 0; + + /** + \brief Check if a ray intersects any shape. + + This function returns false and calls the query report callback when the batched queries are executed. + + See #NxScene::raycastAnyShape() for more details. + */ + virtual bool raycastAnyShape (const NxRay& worldRay, NxShapesType shapesType, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, const NxGroupsMask* groupsMask=NULL, NxShape** cache=NULL, void* userData=NULL) const = 0; + + /** + \brief Check if a sphere overlaps shapes. + + This function returns false and calls the query report callback when the batched queries are executed. + + See #NxScene::checkOverlapSphere() for more details. + */ + virtual bool checkOverlapSphere (const NxSphere& worldSphere, NxShapesType shapesType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Check if a AABB overlaps shapes. + + This function returns false and calls the query report callback when the batched queries are executed. + + See #NxScene::checkOverlapAABB() for more details. + */ + virtual bool checkOverlapAABB (const NxBounds3& worldBounds, NxShapesType shapesType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Check if an OBB overlaps shapes. + + This function returns false and calls the query report callback when the batched queries are executed. + + See #NxScene::checkOverlapOBB() for more details. + */ + virtual bool checkOverlapOBB (const NxBox& worldBox, NxShapesType shapesType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Check if a capsule overlaps shapes. + + This function returns false and calls the query report callback when the batched queries are executed. + + See #NxScene::checkOverlapCapsule() for more details. + */ + virtual bool checkOverlapCapsule (const NxCapsule& worldCapsule, NxShapesType shapesType=NX_ALL_SHAPES, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Find the closest ray/shape intersection. + + This function returns NULL and calls the query report callback when the batched queries are executed. + + See #NxScene::raycastClosestShape() for more details. + */ + virtual NxShape* raycastClosestShape (const NxRay& worldRay, NxShapesType shapesType, NxRaycastHit& hit, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, NxU32 hintFlags=0xffffffff, const NxGroupsMask* groupsMask=NULL, NxShape** cache=NULL, void* userData=NULL) const = 0; + + /** + \brief Find all the shapes which a ray intersects. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::raycastAllShapes() for more details. + */ + virtual NxU32 raycastAllShapes (const NxRay& worldRay, NxShapesType shapesType, NxU32 groups=0xffffffff, NxReal maxDist=NX_MAX_F32, NxU32 hintFlags=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Find all shapes which overlap a sphere. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::overlapSphereShapes() for more details. + */ + virtual NxU32 overlapSphereShapes (const NxSphere& worldSphere, NxShapesType shapesType, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Find all shapes which overlap an AABB. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::overlapAABBShapes() for more details. + */ + virtual NxU32 overlapAABBShapes (const NxBounds3& worldBounds, NxShapesType shapesType, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Find all shapes which overlap an OBB. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + + See #NxScene::overlapOBBShapes() for more details. + */ + virtual NxU32 overlapOBBShapes (const NxBox& worldBox, NxShapesType shapesType, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Find all shapes which overlap a capsule. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::overlapCapsuleShapes() for more details. + */ + virtual NxU32 overlapCapsuleShapes (const NxCapsule& worldCapsule, NxShapesType shapesType, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Find the set of shapes which are in the negative half space of a number of planes. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::cullShapes() for more details. + */ + virtual NxU32 cullShapes (NxU32 nbPlanes, const NxPlane* worldPlanes, NxShapesType shapesType, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + + /** + \brief Perform a linear OBB sweep. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::linearOBBSweep() for more details. + */ + virtual NxU32 linearOBBSweep (const NxBox& worldBox, const NxVec3& motion, NxU32 flags, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + /** + \brief Perform a linear capsule sweep. + + This function returns 0 and calls the query report callback when the batched queries are executed. + + See #NxScene::linearCapsuleSweep() for more details. + */ + virtual NxU32 linearCapsuleSweep (const NxCapsule& worldCapsule, const NxVec3& motion, NxU32 flags, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, void* userData=NULL) const = 0; + + protected: + virtual ~NxSceneQuery(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2006 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSceneStats.h b/libraries/external/physx/Win32/include/PX/NxSceneStats.h new file mode 100755 index 0000000..3827f32 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSceneStats.h @@ -0,0 +1,157 @@ +#ifndef NX_SCENE_STATS +#define NX_SCENE_STATS +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** +\brief Class used to retrieve statistics for a scene. + +Platform: +\li PC SW: Yes +\li PPU : Partial (Actors, dynamic actors, joints) +\li PS3 : Yes +\li XB360: Yes + +@see NxScene::getStats() +*/ +class NxSceneStats + { + public: +//collisions: + /** + \brief Number of contacts present in the scene for the current simulation step. Not supported in 2.6. + */ + NxU32 numContacts; + /** + \brief Maximum number of contacts present in the scene since the scene was created. Not supported in 2.6. + */ + NxU32 maxContacts; + /** + \brief Number of shape pairs present in the scene for the current simulation step. + */ + NxU32 numPairs; + /** + \brief Maximum number of shape pairs present in the scene since the scene was created. + */ + NxU32 maxPairs; +//sleep: + /** + \brief Number of dynamic actors which are not part of a sleeping group(island) + */ + NxU32 numDynamicActorsInAwakeGroups; + /** + \brief Maximum number of actors which have been present in a non sleeping island since the scene was created. + */ + NxU32 maxDynamicActorsInAwakeGroups; +//solver: + /** + \brief The number of constraints(joints+contact) present in the current simulation step. Not supported in 2.6. + */ + NxU32 numAxisConstraints; + /** + \brief The maximum number of constraints(joints+contacts) present in the scene since creation. Not supported in 2.6. + */ + NxU32 maxAxisConstraints; + /** + \brief Number of solver bodies present in the current step(i.e. the number of bodies subject to constraints). Not supported in 2.6. + */ + NxU32 numSolverBodies; + /** + \brief Max number of solver bodies present in the scene since creation. Not supported in 2.6. + */ + NxU32 maxSolverBodies; +//scene: + /** + \brief Number of actors(static+dynamic) present in the scene for the current simulation step. + */ + NxU32 numActors; + /** + \brief Max number of actors(static+dynamic) present in the scene since the scene was created. + */ + NxU32 maxActors; + /** + \brief Number of dynamic actors present in the scene for the current simulation step. + */ + NxU32 numDynamicActors; + /** + \brief Max number of dynamic actors present in the scene since it was created. + */ + NxU32 maxDynamicActors; + /** + \brief Number of static shapes present in the scene. + */ + NxU32 numStaticShapes; + /** + \brief Max number of static shapes present in the scene since it was created. + */ + NxU32 maxStaticShapes; + /** + \brief Number of dynamic shapes present in the scene for the current simulation step. + */ + NxU32 numDynamicShapes; + /** + \brief Max number of dynamic actors present in the scene, since it was created. + */ + NxU32 maxDynamicShapes; + /** + \brief Number of joints in the scene. Note that this number also includes all "dead joints" + in the scene (see NxScene.releaseActor). + */ + NxU32 numJoints; + /** + \brief Max number of joints in the scene since it was created. + */ + NxU32 maxJoints; + + + NxSceneStats() + { + reset(); + } + + /** + \brief Zeros all members. + */ + void reset() + { + numContacts = 0; + maxContacts = 0; + numPairs = 0; + maxPairs = 0; + numDynamicActorsInAwakeGroups = 0; + maxDynamicActorsInAwakeGroups = 0; + numAxisConstraints = 0; + maxAxisConstraints = 0; + numSolverBodies = 0; + maxSolverBodies = 0; + numActors = 0; + maxActors = 0; + numDynamicActors = 0; + maxDynamicActors = 0; + numStaticShapes = 0; + maxStaticShapes = 0; + numDynamicShapes = 0; + maxDynamicShapes = 0; + numJoints = 0; + maxJoints = 0; + } + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSceneStats2.h b/libraries/external/physx/Win32/include/PX/NxSceneStats2.h new file mode 100755 index 0000000..826b0db --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSceneStats2.h @@ -0,0 +1,68 @@ +#ifndef NX_SCENE_STATS2 +#define NX_SCENE_STATS2 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxArray.h" +#include "PX/NxFoundationSDK.h" +#include "PX/Nxp.h" + +#define NX_ENABLE_SCENE_STATS2 +/** +\brief Scene statistic counters +*/ + +struct NxSceneStatistic +{ + /** \brief Current value of the statistic + */ + NxI32 curValue; + /** \brief Maximum value of the statistic over the entire lifetime of the scene + */ + NxI32 maxValue; + /** \brief Pointer to the name of the statistic + */ + const char *name; + /** \brief The index into the array of NxSceneStatistics (see #NxSceneStats2) of the parent of the statistic; if no parent exists, the value is 0xFFFFFFFF). + */ + NxU32 parent; +}; + +/** +\brief Class used to retrieve statistics for a scene. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + +@see NxScene::getStats2() +*/ +class NxSceneStats2 +{ + public: + /**\brief The number of #NxSceneStatistic structures stored. + */ + NxU32 numStats; + /**\brief Array of #NxSceneStatistic structures. + */ + NxSceneStatistic *stats; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxScheduler.h b/libraries/external/physx/Win32/include/PX/NxScheduler.h new file mode 100755 index 0000000..492ee7b --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxScheduler.h @@ -0,0 +1,134 @@ +#ifndef NX_PHYSICS_NX_SCHEDULER +#define NX_PHYSICS_NX_SCHEDULER +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** +\brief Interface to an SDK task. + +The SDK submits NxTasks to users custom scheduler for execution on an appropriate thread. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : No +\li XB360: Yes + +@see NxScheduler NxTask.execute() +*/ +class NxTask + { + protected: + + virtual ~NxTask() {} + + public: + + /** + \brief Execute the task supplied by the SDK + + This method can be called from an arbitary thread. Note however that each additional thread + calling this function will incur a memory overhead for thread specific data. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxScheduler + */ + virtual void execute() = 0; + }; + +/** +\brief A user defined callback class to allow arbitary scheduling of work between threads. + +The user can supply a pointer to a derived class when creating a scene. Subsequently the SDK will +call methods of this class with tasks(#NxTask) which the application should execute on an appropriate thread. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : No +\li XB360: Yes + +@see NxSceneDesc.customScheduler NX_SF_ENABLE_MULTITHREAD NxTask +*/ +class NxUserScheduler + { + public: + /** + \brief The SDK calls this method to add a task to the applications work queue + + When a task has been added to the work queue the application should execute the task as soon as possible, + from an arbitary thread context. + + \param[in] task for the application to execute + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxTask + */ + virtual void addTask(NxTask *task) = 0; + + /** + \brief The SDK calls this method to add a background task to the applications work queue + + The timing of background tasks is not as critical as other tasks. The application + is also not required to execute background tasks when waitTasksComplete() is called. + + \note At present background tasks are not dispatched on any platform(this may change in the future). + + \param[in] task for the application to execute + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxTask + */ + virtual void addBackgroundTask(NxTask *task)=0; + + /** + \brief The SDK thread calls this function to suspend. + + When the SDK calls this method the user should block until all the tasks which have previously been submitted + with addTask() are complete. + + A typical implementation of this method begins executing tasks in the work queue. Then when the queue is complete, + it blocks until all other threads have finished executing their tasks. + + Note: Tasks submitted by addBackgroundTask() need not be completed before this method returns. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxTask + */ + virtual void waitTasksComplete() = 0; + + protected: + virtual ~NxUserScheduler(){}; + }; +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSegment.h b/libraries/external/physx/Win32/include/PX/NxSegment.h new file mode 100755 index 0000000..a30f263 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSegment.h @@ -0,0 +1,120 @@ +#ifndef NX_FOUNDATION_NXSEGMENT +#define NX_FOUNDATION_NXSEGMENT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nxf.h" +#include "PX/NxVec3.h" + + +class NxSegment; + +/** +\brief Represents a line segment. + +*/ +class NxSegment + { + public: + /** + \brief Constructor + */ + NX_INLINE NxSegment() + { + } + + /** + \brief Constructor + */ + NX_INLINE NxSegment(const NxVec3& _p0, const NxVec3& _p1) : p0(_p0), p1(_p1) + { + } + + /** + \brief Copy constructor + */ + NX_INLINE NxSegment(const NxSegment& seg) : p0(seg.p0), p1(seg.p1) + { + } + + /** + \brief Destructor + */ + NX_INLINE ~NxSegment() + { + } + + NX_INLINE const NxVec3& getOrigin() const + { + return p0; + } + + NX_INLINE NxVec3 computeDirection() const + { + return p1 - p0; + } + + NX_INLINE void computeDirection(NxVec3& dir) const + { + dir = p1 - p0; + } + + NX_INLINE NxF32 computeLength() const + { + return p1.distance(p0); + } + + NX_INLINE NxF32 computeSquareLength() const + { + return p1.distanceSquared(p0); + } + + NX_INLINE void setOriginDirection(const NxVec3& origin, const NxVec3& direction) + { + p0 = p1 = origin; + p1 += direction; + } + + /** + \brief Computes a point on the segment + + \param[out] pt point on segment + \param[in] t point's parameter [t=0 => pt = mP0, t=1 => pt = mP1] + */ + NX_INLINE void computePoint(NxVec3& pt, NxF32 t) const + { + pt = p0 + t * (p1 - p0); + } +#ifdef FOUNDATION_EXPORTS + + NX_INLINE NxF32 squareDistance(const NxVec3& point, NxF32* t=NULL) const + { + return NxComputeSquareDistance(*this, point, t); + } + + NX_INLINE NxF32 distance(const NxVec3& point, NxF32* t=NULL) const + { + return sqrtf(squareDistance(point, t)); + } +#endif + + NxVec3 p0; //!< Start of segment + NxVec3 p1; //!< End of segment + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxShape.h b/libraries/external/physx/Win32/include/PX/NxShape.h new file mode 100755 index 0000000..90bef8a --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxShape.h @@ -0,0 +1,888 @@ +#ifndef NX_COLLISION_NXSHAPE +#define NX_COLLISION_NXSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxPhysicsSDK.h" + +class NxBounds3; +class NxBoxShape; +class NxBoxShapeOffCenter; +class NxPlaneShape; +class NxSphereShape; +class NxCapsuleShape; +class NxCollisionSpace; +class NxConvexShape; +class NxTriangleMeshShape; +class NxHeightFieldShape; +class NxActor; +class NxRay; +class NxSphere; +class NxBox; +class NxCapsule; +class NxWheelShape; +struct NxRaycastHit; + +/** +\brief Abstract base class for the various collision shapes. + +An instance of a subclass can be created by calling the createShape() method of the NxActor class, +or by adding the shape descriptors into the NxActorDesc class before creating the actor. + +Note: in order to avoid a naming conflict, downcast operators are isTYPE(), while up casts are getTYPE(). + +

Visualizations

+\li NX_VISUALIZE_COLLISION_AABBS +\li NX_VISUALIZE_COLLISION_SHAPES +\li NX_VISUALIZE_COLLISION_AXES + +The AGEIA PhysX SDK users guide describes which shapes that can collide with each other (direct link:
users guide) + +@see NxActor.createShape() NxSphereShape NxPlaneShape NxConvexShape NxTriangleMeshShape NxCapsuleShape NxBoxShape +*/ +class NxShape + { + protected: + NX_INLINE NxShape() : userData(NULL), appData(NULL) + {} + virtual ~NxShape() {} + + public: + + /** + \brief Retrieves the actor which this shape is associated with. + + \return The actor this shape is associated with. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor + */ + virtual NxActor& getActor() const = 0; + + /** + \brief Sets which collision group this shape is part of. + + Default group is 0. Maximum possible group is 31. + Collision groups are sets of shapes which may or may not be set + to collision detect with each other; this can be set using NxScene::setGroupCollisionFlag() + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] collisionGroup The collision group for this shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGroup() NxCollisionGroup + */ + virtual void setGroup(NxCollisionGroup collisionGroup) = 0; + + /** + \brief Retrieves the value set with #setGroup(). + + NxCollisionGroup is an integer between 0 and 31. + + \return The collision group this shape belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGroup() NxCollisionGroup + */ + virtual NxCollisionGroup getGroup() const = 0; + + /** + \brief Returns a world space AABB enclosing this shape. + + \param[out] dest Retrieves the world space bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 + */ + virtual void getWorldBounds(NxBounds3& dest) const = 0; + + /** + \brief Sets shape flags + + The shape may be turned into a trigger by setting one or more of the + above TriggerFlag-s to true. A trigger shape will not collide + with other shapes. Instead, if a shape enters the trigger's volume, + a trigger event will be sent to the user via the NxUserTriggerReport::onTrigger method. + You can set a NxUserTriggerReport object with NxScene::setUserTriggerReport(). + + Since version 2.1.1 this is also used to setup generic (non-trigger) flags. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] flag The new shape flags to set for this shape. See #NxShapeFlag. + \param[in] value True to set the flags. False to clear the flags specified in flag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeFlag getFlag() + */ + virtual void setFlag(NxShapeFlag flag, bool value) = 0; + + /** + \brief Retrieves shape flags. + + \param[in] flag The flag to retrieve. + \return The value of the flag specified. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeFlag setFlag() + */ + virtual NX_BOOL getFlag(NxShapeFlag flag) const = 0; + +/************************************************************************************************/ + +/** @name Pose Manipulation +*/ +//@{ + + /** + \brief The setLocal*() methods set the pose of the shape in actor space, i.e. relative to the actor they are owned by. + + This transformation is identity by default. + + Sleeping: Does NOT wake the associated actor up automatically. + + Note: Does not automatically update the inertia properties of the owning actor (if applicable); use NxActor::updateMassFromShapes() to do this. + \param[in] mat The new transform from the actor frame to the shape frame. Range: rigid body transform + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLocalPose() NxShapeDesc.localPose() + */ + virtual void setLocalPose(const NxMat34& mat) = 0; + + /** + \brief The setLocal*() methods set the pose of the shape in actor space, i.e. relative to the actor they are owned by. + + This transformation is identity by default. + + Sleeping: Does NOT wake the associated actor up automatically. + + Note: Does not automatically update the inertia properties of the owning actor (if applicable); use NxActor::updateMassFromShapes() to do this. + \param[in] vec The new position of the shape relative to the actor frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPose() NxShapeDesc.localPose getLocalPosition() + */ + virtual void setLocalPosition(const NxVec3& vec) = 0; + + /** + \brief The setLocal*() methods set the pose of the shape in actor space, i.e. relative to the actor they are owned by. + + This transformation is identity by default. + + Sleeping: Does NOT wake the associated actor up automatically. + + Note: Does not automatically update the inertia properties of the owning actor (if applicable); use NxActor::updateMassFromShapes() to do this. + \param[in] mat The new orientation relative to the actor frame. Range: rotation matrix + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPose() NxShapeDesc.localPose getLocalOrientation() + */ + virtual void setLocalOrientation(const NxMat33& mat) = 0; + + /** + \brief The getLocal*() methods retrieve the pose of the shape in actor space, i.e. relative to the actor they are owned by. + This transformation is identity by default. + + \return Pose of shape relative to the actors frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPose() NxShapeDesc.localPose + */ + virtual NxMat34 getLocalPose() const = 0; + + /** + \brief The getLocal*() methods retrieve the pose of the shape in actor space, i.e. relative to the actor they are owned by. + + This transformation is identity by default. + + \return Position of shape relative to actors frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPosition() getLocalPose() NxShapeDesc.localPose + */ + virtual NxVec3 getLocalPosition() const = 0; + + /** + \brief The getLocal*() methods retrieve the pose of the shape in actor space, i.e. relative to the actor they are owned by. + This transformation is identity by default. + + \return Orientation of shape relative to actors frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalOrientation() getLocalPose() NxShapeDesc.localPose + */ + virtual NxMat33 getLocalOrientation() const = 0; + + /** + \brief The setGlobal() calls are convenience methods which transform the passed parameter + into the current local space of the actor and then call setLocalPose(). + + Sleeping: Does NOT wake the associated actor up automatically. + + Note: Does not automatically update the inertia properties of the owning actor (if applicable); use NxActor::updateMassFromShapes() to do this. + \param[in] mat The new shape pose, relative to the global frame. Range: rigid body transform + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPose() getGlobalPose() setGlobalPosition() setGlobalOrientation() + */ + virtual void setGlobalPose(const NxMat34& mat) = 0; + + /** + \brief The setGlobal() calls are convenience methods which transform the passed parameter + into the current local space of the actor and then call setLocalPose(). + + Sleeping: Does NOT wake the associated actor up automatically. + + Note: Does not automatically update the inertia properties of the owning actor (if applicable); use NxActor::updateMassFromShapes() to do this. + \param[in] vec The new shape position, relative to the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPose() getGlobalPosition() setGlobalPosition() setGlobalOrientation() + */ + virtual void setGlobalPosition(const NxVec3& vec) = 0; + + /** + \brief The setGlobal() calls are convenience methods which transform the passed parameter + into the current local space of the actor and then call setLocalPose(). + + Sleeping: Does NOT wake the associated actor up automatically. + + Note: Does not automatically update the inertia properties of the owning actor (if applicable); use NxActor::updateMassFromShapes() to do this. + \param[in] mat The new shape orientation relative to the global frame. Range: orientation matrix + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setLocalPose() getGlobalOrientation() setGlobalPosition() setGlobalOrientation() + */ + virtual void setGlobalOrientation(const NxMat33& mat) = 0; + + /** + \brief The getGlobal*() methods retrieve the shape's current world space pose. This is + the local pose multiplied by the actor's current global pose. + + \return Pose of shape relative to the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalPose() getGlobalPosition() getGlobalOrientation() + */ + virtual NxMat34 getGlobalPose() const = 0; + + /** + \brief The getGlobal*() methods retrieve the shape's current world space pose. This is + the local pose multiplied by the actor's current global pose. + + \return Position of the shape relative to the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalPosition() getGlobalPose() getGlobalOrientation() + */ + virtual NxVec3 getGlobalPosition() const = 0; + + /** + \brief The getGlobal*() methods retrieve the shape's current world space pose. This is + the local pose multiplied by the actor's current global pose. + + \return Orientation of the shape realative to the global frame. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGlobalOrientation() getGlobalPose() getGlobalPosition() + */ + virtual NxMat33 getGlobalOrientation() const = 0; +//@} +/************************************************************************************************/ + + /** + \brief Assigns a material index to the shape. + + The material index can be retrieved by calling NxMaterial::getMaterialIndex(). + If the material index is invalid, it will still be recorded, but + the default material (at index 0) will effectively be used for simulation. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] matIndex The material index to assign to the shape. See #NxMaterial + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.createMaterial() getMaterial() NxMaterialIndex NxMaterial.getMaterialIndex() + */ + virtual void setMaterial(NxMaterialIndex matIndex) = 0; + + /** + \brief Retrieves the material index currently assigned to the shape. + + \return The material index of the material associated with the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setMaterial() NxMaterialIndex + */ + virtual NxMaterialIndex getMaterial() const = 0; + + /** + \brief Sets the skin width. See #NxShapeDesc::skinWidth. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] skinWidth The new skin width. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSkinWidth + @see NxParameter + */ + virtual void setSkinWidth(NxReal skinWidth) = 0; + /** + \brief Retrieves the skin width. See #NxShapeDesc::skinWidth. + + \return The skin width of the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSkinWidth() NxParameter + */ + virtual NxReal getSkinWidth() const = 0; + + /** + \brief returns the type of shape. + + \return The shape type of the shape. See #NxShapeType. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType + */ + virtual NxShapeType getType() const = 0; + + /** + \brief Assigns a CCD Skeleton mesh. + + Note how CCDSkeletons can be shared between shapes. + +

Visualizations:

+ \li #NX_VISUALIZE_COLLISION_CCD + \li #NX_VISUALIZE_COLLISION_SKELETONS + + \param[in] ccdSkel The CCDSkeleton to assign to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeDesc.ccdSkeleton NxPhysicsSDK.createCCDSkeleton() getCCDSkeleton() + */ + virtual void setCCDSkeleton(NxCCDSkeleton *ccdSkel) = 0; + + /** + \brief Retrieves the CCDSkeleton for this shape. + + \return The CCD skeleton associated with this shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeDesc.ccdSkeleton NxPhysicsSDK.createCCDSkeleton() setCCDSkeleton() + */ + virtual NxCCDSkeleton * getCCDSkeleton() const = 0; + +/************************************************************************************************/ + +/** @name Is... Shape Type +*/ +//@{ + /** + \brief Type casting operator. The result may be cast to the desired subclass type. + + \param[in] type The type of shape to attempt a cast to. + \return NULL if the shape is not type. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType + */ + virtual void* is(NxShapeType type) = 0; + virtual const void* is(NxShapeType type) const = 0; + + /** + \brief Attempts to cast to an #NxPlaneShape. + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxPlaneShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxPlaneShape + */ + NX_INLINE NxPlaneShape* isPlane() { return (NxPlaneShape*) is(NX_SHAPE_PLANE); } + NX_INLINE const NxPlaneShape* isPlane() const { return (const NxPlaneShape*) is(NX_SHAPE_PLANE); } + + /** + \brief Attempts to cast to an #NxSphereShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxSphereShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxSphereShape + */ + NX_INLINE NxSphereShape* isSphere() { return (NxSphereShape*) is(NX_SHAPE_SPHERE); } + NX_INLINE const NxSphereShape* isSphere() const { return (const NxSphereShape*) is(NX_SHAPE_SPHERE); } + + /** + \brief Attempts to cast to an #NxBoxShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxBoxShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxBoxShape + */ + NX_INLINE NxBoxShape* isBox() { return (NxBoxShape*) is(NX_SHAPE_BOX); } + NX_INLINE const NxBoxShape* isBox() const { return (const NxBoxShape*) is(NX_SHAPE_BOX); } + + /** + \brief Attempts to cast to an #NxCapsuleShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxCapsuleShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxCapsuleShape + */ + NX_INLINE NxCapsuleShape* isCapsule() { return (NxCapsuleShape*) is(NX_SHAPE_CAPSULE); } + NX_INLINE const NxCapsuleShape* isCapsule() const { return (const NxCapsuleShape*)is(NX_SHAPE_CAPSULE); } + + /** + \brief Attempts to cast to an #NxWheelShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxWheelShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxWheelShape + */ + NX_INLINE NxWheelShape* isWheel() { return (NxWheelShape*) is(NX_SHAPE_WHEEL); } + NX_INLINE const NxWheelShape* isWheel() const { return (const NxWheelShape*) is(NX_SHAPE_WHEEL); } + + /** + \brief Attempts to cast to an #NxConvexShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxConvexShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxConvexShape + */ + NX_INLINE NxConvexShape* isConvexMesh() { return (NxConvexShape*) is(NX_SHAPE_CONVEX); } + NX_INLINE const NxConvexShape* isConvexMesh() const{ return (const NxConvexShape*) is(NX_SHAPE_CONVEX); } + + /** + \brief Attempts to cast to an #NxTriangleMeshShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxTriangleMeshShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxTriangleMeshShape + */ + NX_INLINE NxTriangleMeshShape* isTriangleMesh() { return (NxTriangleMeshShape*) is(NX_SHAPE_MESH); } + NX_INLINE const NxTriangleMeshShape* isTriangleMesh() const { return (const NxTriangleMeshShape*) is(NX_SHAPE_MESH); } + + /** + \brief Attempts to cast to an #NxHeightFieldShape + + Returns NULL if this object is not of the appropriate type. + + \return NULL if the shape is not an #NxHeightFieldShape. Otherwise a pointer to the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeType NxHeightFieldShape + */ + NX_INLINE NxHeightFieldShape* isHeightField() { return (NxHeightFieldShape*) is(NX_SHAPE_HEIGHTFIELD); } + NX_INLINE const NxHeightFieldShape* isHeightField() const { return (const NxHeightFieldShape*)is(NX_SHAPE_HEIGHTFIELD); } +//@} +/************************************************************************************************/ + + /** + \brief Sets a name string for the object that can be retrieved with #getName(). + + This is for debugging and is not used by the SDK. + The string is not copied by the SDK, only the pointer is stored. + + \param[in] name The name string to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName(const char* name) = 0; + + /** + \brief retrieves the name string set with setName(). + \return The name associated with the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName() const = 0; + +/************************************************************************************************/ + +/** @name Raycasting and Overlap Testing +*/ +//@{ + + /** + \brief casts a world-space ray against the shape. + + maxDist is the maximum allowed distance for the ray. You can use this for segment queries. + hintFlags is a combination of ::NxRaycastBit flags. + firstHit is a hint saying you're only interested in a boolean answer. + + Note: Make certain that the direction vector of NxRay is normalized. + + \param[in] worldRay The ray to intersect against the shape in the global frame. Range See #NxRay + \param[in] maxDist The maximum distance to check along the ray. Range: (0,inf) + \param[in] hintFlags a combination of ::NxRaycastBit flags. Specifies which members of NxRaycastHit the user is interested in(eg normal, material etc) + \param[out] hit Retrieves the information computed from a ray intersection + \param[in] firstHit is a hint saying you're only interested in a boolean answer. + \return True if the ray intersects the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.raycastAnyShape() NxScene.raycastAnyBounds() + */ + virtual bool raycast(const NxRay& worldRay, NxReal maxDist, NxU32 hintFlags, NxRaycastHit& hit, bool firstHit) const = 0; + + /** + \brief Checks whether the shape overlaps a world-space sphere or not. + + \param[in] worldSphere The sphere description in the global frame to test against. Range: See #NxSphere + \return True if the sphere overlaps the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.overlapSphereShapes() + */ + virtual bool checkOverlapSphere(const NxSphere& worldSphere) const = 0; + + /** + \brief Checks whether the shape overlaps a world-space OBB or not. + + \param[in] worldBox The world space oriented box to check against. Range: See #NxBox + \return True if the Oriented Bounding Box overlaps the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.overlapOBBShapes() + */ + virtual bool checkOverlapOBB(const NxBox& worldBox) const = 0; + + /** + \brief Checks whether the shape overlaps a world-space AABB or not. + + \param[in] worldBounds The world space axis aligned box to check against. Range: See #NxBounds3 + \return True if the Axis Aligned Bounding Box overlaps the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.overlapAABBShapes() + */ + virtual bool checkOverlapAABB(const NxBounds3& worldBounds) const = 0; + + /** + \brief Checks whether the shape overlaps a world-space capsule or not. + + \param[in] worldCapsule The world space capsule to check against. Range: See #NxCapsule + \return True if the capsule overlaps the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.overlapCapsuleShapes() + */ + virtual bool checkOverlapCapsule(const NxCapsule& worldCapsule) const = 0; +//@} +/************************************************************************************************/ + + /** + \brief Sets 128-bit mask used for collision filtering. See comments for ::NxGroupsMask + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] mask The group mask to set for the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGroupsMask() + */ + virtual void setGroupsMask(const NxGroupsMask& mask) = 0; + + /** + \brief Gets 128-bit mask used for collision filtering. See comments for ::NxGroupsMask + + \return The group mask for the shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGroupsMask() + */ + virtual const NxGroupsMask getGroupsMask() const = 0; + + /** + \brief Returns which compartment types the shape should not interact with. + + \return A combination of ::NxShapeCompartmentType values. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see setNonInteractingCompartmentTypes() NxShapeCompartmentType + */ + virtual NxU32 getNonInteractingCompartmentTypes() const = 0; + + /** + \brief Sets which compartment types the shape should not interact with. + + The shape will not interact with objects that belong to a compartment of the specified types. + + \note See #NxShapeDesc::nonInteractingCompartmentTypes for limitations. + + \param[in] compartmentTypes A combination of ::NxShapeCompartmentType values. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see getNonInteractingCompartmentTypes() NxShapeCompartmentType + */ + virtual void setNonInteractingCompartmentTypes(NxU32 compartmentTypes) = 0; + + + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + void* appData; //!< used internally, do not change. + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxShapeDesc.h new file mode 100755 index 0000000..707d7b1 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxShapeDesc.h @@ -0,0 +1,342 @@ +#ifndef NX_COLLISION_NXSHAPEDESC +#define NX_COLLISION_NXSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShape.h" + + +/** +\brief Describes the compartment types a rigid body shape might interact with +*/ +enum NxShapeCompartmentType + { + NX_COMPARTMENT_SW_RIGIDBODY = (1<<0), //!< Software rigid body compartment + NX_COMPARTMENT_HW_RIGIDBODY = (1<<1), //!< Hardware rigid body compartment + NX_COMPARTMENT_SW_FLUID = (1<<2), //!< Software fluid compartment + NX_COMPARTMENT_HW_FLUID = (1<<3), //!< Hardware fluid compartment + NX_COMPARTMENT_SW_CLOTH = (1<<4), //!< Software cloth compartment + NX_COMPARTMENT_HW_CLOTH = (1<<5), //!< Hardware cloth compartment + NX_COMPARTMENT_SW_SOFTBODY = (1<<6), //!< Software softbody compartment + NX_COMPARTMENT_HW_SOFTBODY = (1<<7), //!< Hardware softbody compartment + }; + + +/** +\brief Descriptor for #NxShape class. + +Used for saving and loading the shape state. + +See the derived classes for the different shape types. + +@see NxActor.createShape() NxSphereShapeDesc NxPlaneShapeDesc NxConvexShapeDesc NxTriangleMeshShapeDesc +NxCapsuleShapeDesc NxBoxShapeDesc +*/ +class NxShapeDesc + { + protected: + + /** + \brief The type of the shape (see NxShape.h). + + This gets set by the derived class' ctor, the user should not have to change it. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + const NxShapeType type; + public: + + /** + \brief The pose of the shape in the coordinate frame of the owning actor. + + Range: rigid body transform
+ Default: Identity + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape.setLocalPose + */ + NxMat34 localPose; + + /** + \brief A combination of ::NxShapeFlag values. + + Default: NX_SF_VISUALIZATION + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape.setFlag() NxShapeFlag + */ + NxU32 shapeFlags; + + /** + \brief See the documentation for NxShape::setGroup(). + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape.setGroup() + */ + NxCollisionGroup group; + + /** + \brief The material index of the shape. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.createMaterial() NxShape.setMaterial() + */ + NxMaterialIndex materialIndex; + + /** + \brief CCD Skeleton + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape.setCCDSkeleton() NxPhysicsSDK.createCCDSkeleton() + */ + NxCCDSkeleton* ccdSkeleton; + + /** + \brief density of this individual shape when computing mass inertial properties for a rigidbody (unless a valid mass >0.0 is provided). + Note that this will only be used if the body has a zero inertia tensor, or if you call #NxActor::updateMassFromShapes explicitly. + + See #NxActorDesc for a description of how the density is applied. + + Range: (0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal density; + + /** + \brief mass of this individual shape when computing mass inertial properties for a rigidbody. When mass<=0.0 then density and volume determine the mass. + Note that this will only be used if the body has a zero inertia tensor, or if you call #NxActor::updateMassFromShapes explicitly. + + Range: (0,inf)
+ Default: -1.0 (I.e. calculate mass from density) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal mass; + + /** + \brief Specifies by how much shapes can interpenetrate + + Two shapes will interpenetrate by the sum of their skin widths. This means that their graphical representations should be adjusted + so that they just touch when the shapes are interpenetrating. + + The default skin width is the NX_SKIN_WIDTH SDK parameter. + This is used if the skinWidth member is set to -1(which is the default). + + A skin width sum of zero for two bodies is not permitted because it will lead to an unstable simulation. + + If your simulation jitters because resting bodies occasionally lose contact, increasing the size of your collision volumes + and the skin width may improve things. + + Units: distance. + + Range: (0,inf)
+ Default: -1.0 (use the default specified with NX_SKIN_WIDTH) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParameter + */ + NxReal skinWidth; + + + /** + \brief Will be copied to NxShape::userData. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + const char* name; + + /** + \brief Groups bit mask for collision filtering + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxGroupsMask groupsMask; + + /** + \brief A combination of ::NxShapeCompartmentType values. + + Defines which compartment types the shape should not interact with. + + \note This member is ignored in the following cases: + + \li Explicitly adding the shape, i.e., its actor, to a rigid body compartment. + \li Attaching the shape to a fluid emitter. + \li Attaching the shape to a cloth. + \li Attaching the shape to a soft body. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : No + \li XB360: Yes + + @see NxShape.setNonInteractingCompartmentTypes() NxShapeCompartmentType + */ + NxU32 nonInteractingCompartmentTypes; + + NX_INLINE virtual ~NxShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + + /** + \brief Retrieves the shape type. + + \return The type of the shape. See #NxShapeType. + */ + NX_INLINE NxShapeType getType() const { return type; } + + protected: + /** + constructor sets to default. + + \param[in] shapeType The type of shape this desc is created for. + */ + NX_INLINE NxShapeDesc(NxShapeType shapeType); + }; + +NX_INLINE NxShapeDesc::NxShapeDesc(NxShapeType t) : type(t) + { + setToDefault(); + } + +NX_INLINE NxShapeDesc::~NxShapeDesc() + { + } + +NX_INLINE void NxShapeDesc::setToDefault() + { + localPose.id(); + shapeFlags = NX_SF_VISUALIZATION | NX_SF_CLOTH_TWOWAY | NX_SF_SOFTBODY_TWOWAY; + group = 0; + materialIndex = 0; + ccdSkeleton = NULL; + skinWidth = -1.0f; + density = 1.0f; + mass = -1.0f; // by default we let the mass be determined by its density. + userData = NULL; + name = NULL; + groupsMask.bits0 = 0; + groupsMask.bits1 = 0; + groupsMask.bits2 = 0; + groupsMask.bits3 = 0; + nonInteractingCompartmentTypes = 0; + } + +NX_INLINE bool NxShapeDesc::isValid() const + { + if(!localPose.isFinite()) + return false; + if(group>=32) + return false; // We only support 32 different groups + if(type >= NX_SHAPE_COUNT) + return false; + if(materialIndex==0xffff) + return false; // 0xffff is reserved for internal usage + if (skinWidth != -1 && skinWidth < 0) + return false; + return true; + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSimpleTriangleMesh.h b/libraries/external/physx/Win32/include/PX/NxSimpleTriangleMesh.h new file mode 100755 index 0000000..4a2ea59 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSimpleTriangleMesh.h @@ -0,0 +1,148 @@ +#ifndef NX_FOUNDATION_NXSIMPLETRIANGLEMESH +#define NX_FOUNDATION_NXSIMPLETRIANGLEMESH +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/NxVec3.h" + +/** +\brief Enum with flag values to be used in NxSimpleTriangleMesh::flags. +*/ +enum NxMeshFlags + { + /** + \brief Specifies if the SDK should flip normals. + + The Nx libraries assume that the face normal of a triangle with vertices [a,b,c] can be computed as: + edge1 = b-a + edge2 = c-a + face_normal = edge1 x edge2. + + Note: This is the same as a counterclockwise winding in a right handed coordinate system or + alternatively a clockwise winding order in a left handed coordinate system. + + If this does not match the winding order for your triangles, raise the below flag. + */ + NX_MF_FLIPNORMALS = (1<<0), + NX_MF_16_BIT_INDICES = (1<<1), // 0xffff && flags & NX_MF_16_BIT_INDICES) + return false; + if(!points) + return false; + if(pointStrideBytes < sizeof(NxPoint)) //should be at least one point's worth of data + return false; + + // Check topology + // The triangles pointer is not mandatory + if(triangles) + { + // Indexed mesh + if(flags & NX_MF_16_BIT_INDICES) + { + if((triangleStrideBytes < sizeof(NxU16)*3)) + return false; + } + else + { + if((triangleStrideBytes < sizeof(NxU32)*3)) + return false; + } + } + return true; + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSimpleTypes.h b/libraries/external/physx/Win32/include/PX/NxSimpleTypes.h new file mode 100755 index 0000000..df66bfb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSimpleTypes.h @@ -0,0 +1,157 @@ +#ifndef NX_FOUNDATION_NXSIMPLETYPES +#define NX_FOUNDATION_NXSIMPLETYPES +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +// Platform specific types: +//Design note: Its OK to use int for general loop variables and temps. + +#ifdef WIN32 + typedef __int64 NxI64; + typedef signed int NxI32; + typedef signed short NxI16; + typedef signed char NxI8; + + typedef unsigned __int64 NxU64; + typedef unsigned int NxU32; + typedef unsigned short NxU16; + typedef unsigned char NxU8; + + typedef float NxF32; + typedef double NxF64; + +#elif LINUX + typedef long long NxI64; + typedef signed int NxI32; + typedef signed short NxI16; + typedef signed char NxI8; + + typedef unsigned long long NxU64; + typedef unsigned int NxU32; + typedef unsigned short NxU16; + typedef unsigned char NxU8; + + typedef float NxF32; + typedef double NxF64; + +#elif __APPLE__ + typedef long long NxI64; + typedef signed int NxI32; + typedef signed short NxI16; + typedef signed char NxI8; + + typedef unsigned long long NxU64; + typedef unsigned int NxU32; + typedef unsigned short NxU16; + typedef unsigned char NxU8; + + typedef float NxF32; + typedef double NxF64; + +#elif __CELLOS_LV2__ + typedef long long NxI64; + typedef signed int NxI32; + typedef signed short NxI16; + typedef signed char NxI8; + + typedef unsigned long long NxU64; + typedef unsigned int NxU32; + typedef unsigned short NxU16; + typedef unsigned char NxU8; + + typedef float NxF32; + typedef double NxF64; + +#elif _XBOX + typedef __int64 NxI64; + typedef signed int NxI32; + typedef signed short NxI16; + typedef signed char NxI8; + + typedef unsigned __int64 NxU64; + typedef unsigned int NxU32; + typedef unsigned short NxU16; + typedef unsigned char NxU8; + + typedef float NxF32; + typedef double NxF64; + +#else + #error Unknown platform! +#endif + +union NxU32F32 +{ + NxU32 u; + NxF32 f; +}; + +#if __APPLE__ + NX_COMPILE_TIME_ASSERT(sizeof(bool)==4); // PPC has 4 byte bools +#else + NX_COMPILE_TIME_ASSERT(sizeof(bool)==1); // ...otherwise things might fail with VC++ 4.2 ! +#endif + NX_COMPILE_TIME_ASSERT(sizeof(NxI8)==1); + NX_COMPILE_TIME_ASSERT(sizeof(NxU8)==1); + NX_COMPILE_TIME_ASSERT(sizeof(NxI16)==2); + NX_COMPILE_TIME_ASSERT(sizeof(NxU16)==2); + NX_COMPILE_TIME_ASSERT(sizeof(NxI32)==4); + NX_COMPILE_TIME_ASSERT(sizeof(NxU32)==4); + NX_COMPILE_TIME_ASSERT(sizeof(NxI64)==8); + NX_COMPILE_TIME_ASSERT(sizeof(NxU64)==8); +#if defined(NX64) + NX_COMPILE_TIME_ASSERT(sizeof(void*)==8); +#else + NX_COMPILE_TIME_ASSERT(sizeof(void*)==4); +#endif + + // Type ranges + #define NX_MAX_I8 0x7f //max possible sbyte value + #define NX_MIN_I8 0x80 //min possible sbyte value + #define NX_MAX_U8 0xff //max possible ubyte value + #define NX_MIN_U8 0x00 //min possible ubyte value + #define NX_MAX_I16 0x7fff //max possible sword value + #define NX_MIN_I16 0x8000 //min possible sword value + #define NX_MAX_U16 0xffff //max possible uword value + #define NX_MIN_U16 0x0000 //min possible uword value + #define NX_MAX_I32 0x7fffffff //max possible sdword value + #define NX_MIN_I32 0x80000000 //min possible sdword value + #define NX_MAX_U32 0xffffffff //max possible udword value + #define NX_MIN_U32 0x00000000 //min possible udword value + #define NX_MAX_F32 FLT_MAX //max possible float value + #define NX_MIN_F32 (-FLT_MAX) //min possible float value + #define NX_MAX_F64 DBL_MAX //max possible double value + #define NX_MIN_F64 (-DBL_MAX) //min possible double value + + #define NX_EPS_F32 FLT_EPSILON //smallest number not zero + #define NX_EPS_F64 DBL_EPSILON //smallest number not zero + + #define NX_IEEE_1_0 0x3f800000 //integer representation of 1.0 + #define NX_IEEE_255_0 0x437f0000 //integer representation of 255.0 + #define NX_IEEE_MAX_F32 0x7f7fffff //integer representation of MAX_NXFLOAT + #define NX_IEEE_MIN_F32 0xff7fffff //integer representation of MIN_NXFLOAT + + typedef int NX_BOOL; + #define NX_FALSE 0 + #define NX_TRUE 1 + + #define NX_MIN(a, b) ((a) < (b) ? (a) : (b)) //Returns the min value between a and b + #define NX_MAX(a, b) ((a) > (b) ? (a) : (b)) //Returns the max value between a and b + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSmoothNormals.h b/libraries/external/physx/Win32/include/PX/NxSmoothNormals.h new file mode 100755 index 0000000..ff48a3f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSmoothNormals.h @@ -0,0 +1,64 @@ +#ifndef NX_COLLISION_NXSMOOTHNORMALS +#define NX_COLLISION_NXSMOOTHNORMALS +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/PhysXLoader.h" + + /** + \brief Builds smooth vertex normals over a mesh. + + - "smooth" because smoothing groups are not supported here + - takes angles into account for correct cube normals computation + + To use 32bit indices pass a pointer in dFaces and set wFaces to zero. Alternatively pass a pointer to + wFaces and set dFaces to zero. + + \warning #NxCreatePhysicsSDK() must be called before using this function. + + \param[in] nbTris Number of triangles + \param[in] nbVerts Number of vertices + \param[in] verts Array of vertices + \param[in] dFaces Array of dword triangle indices, or null + \param[in] wFaces Array of word triangle indices, or null + \param[out] normals Array of computed normals (assumes nbVerts vectors) + \param[in] flip Flips the normals or not + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool NX_CALL_CONV NxBuildSmoothNormals( + NxU32 nbTris, + NxU32 nbVerts, + const NxVec3* verts, + const NxU32* dFaces, + const NxU16* wFaces, + NxVec3* normals, + bool flip=false + ) + { + return NxGetUtilLib()->NxBuildSmoothNormals(nbTris,nbVerts,verts,dFaces,wFaces,normals,flip); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSoftBodyUserNotify.h b/libraries/external/physx/Win32/include/PX/NxSoftBodyUserNotify.h new file mode 100755 index 0000000..0322278 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSoftBodyUserNotify.h @@ -0,0 +1,41 @@ +#ifndef NX_PHYSICS_NXSOFTBODYUSERNOTIFY +#define NX_PHYSICS_NXSOFTBODYUSERNOTIFY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics +@{ +*/ + + +#include "PX/Nxp.h" + +class NxSoftBody; + +/** +\brief An interface class that the user can implement in order to receive simulation events. + +Threading: It is not necessary to make this class thread safe as it will only be called in the context of the +user thread. + +See the NxSoftBodyNotify documentation for an example of how to use notifications. + +@see NxScene.setSoftBodyUserNotify() NxScene.getSoftBodyUserNotify() NxUserNotify +*/ +class NxSoftBodyUserNotify +{ + virtual ~NxSoftBodyUserNotify(){}; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphere.h b/libraries/external/physx/Win32/include/PX/NxSphere.h new file mode 100755 index 0000000..c02b00e --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphere.h @@ -0,0 +1,176 @@ +#ifndef NX_FOUNDATION_NXSPHERE +#define NX_FOUNDATION_NXSPHERE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" +#include "PX/NxVec3.h" + +/** +\brief Enum to control the sphere generation method from a set of points. +*/ +enum NxBSphereMethod + { + NX_BS_NONE, + NX_BS_GEMS, + NX_BS_MINIBALL, + + NX_BS_FORCE_DWORD = 0x7fffffff + }; + +/** +\brief Represents a sphere defined by its center point and radius. +*/ +class NxSphere + { + public: + /** + \brief Constructor + */ + NX_INLINE NxSphere() + { + } + + /** + \brief Constructor + */ + NX_INLINE NxSphere(const NxVec3& _center, NxF32 _radius) : center(_center), radius(_radius) + { + } +#ifdef FOUNDATION_EXPORTS + /** + \brief Constructor + */ + NX_INLINE NxSphere(unsigned nb_verts, const NxVec3* verts) + { + NxComputeSphere(*this, nb_verts, verts); + } +#endif + /** + \brief Copy constructor + */ + NX_INLINE NxSphere(const NxSphere& sphere) : center(sphere.center), radius(sphere.radius) + { + } +#ifdef FOUNDATION_EXPORTS + + /** + \brief Union of spheres + */ + NX_INLINE NxSphere(const NxSphere& sphere0, const NxSphere& sphere1) + { + NxMergeSpheres(*this, sphere0, sphere1); + } +#endif + /** + \brief Destructor + */ + NX_INLINE ~NxSphere() + { + } +#ifdef FOUNDATION_EXPORTS + + NX_INLINE NxBSphereMethod compute(unsigned nb_verts, const NxVec3* verts) + { + return NxComputeSphere(*this, nb_verts, verts); + } + + NX_INLINE bool fastCompute(unsigned nb_verts, const NxVec3* verts) + { + return NxFastComputeSphere(*this, nb_verts, verts); + } +#endif + /** + \brief Checks the sphere is valid. + + \return true if the sphere is valid + */ + NX_INLINE bool IsValid() const + { + // Consistency condition for spheres: Radius >= 0.0f + return radius >= 0.0f; + } + + /** + \brief Tests if a point is contained within the sphere. + + \param[in] p the point to test + \return true if inside the sphere + */ + NX_INLINE bool Contains(const NxVec3& p) const + { + return center.distanceSquared(p) <= radius*radius; + } + + /** + \brief Tests if a sphere is contained within the sphere. + + \param sphere [in] the sphere to test + \return true if inside the sphere + */ + NX_INLINE bool Contains(const NxSphere& sphere) const + { + // If our radius is the smallest, we can't possibly contain the other sphere + if(radius < sphere.radius) return false; + // So r is always positive or null now + float r = radius - sphere.radius; + return center.distanceSquared(sphere.center) <= r*r; + } + + /** + \brief Tests if a box is contained within the sphere. + + \param min [in] min value of the box + \param max [in] max value of the box + \return true if inside the sphere + */ + NX_INLINE bool Contains(const NxVec3& min, const NxVec3& max) const + { + // I assume if all 8 box vertices are inside the sphere, so does the whole box. + // Sounds ok but maybe there's a better way? + NxF32 R2 = radius * radius; + NxVec3 p; + p.x=max.x; p.y=max.y; p.z=max.z; if(center.distanceSquared(p)>=R2) return false; + p.x=min.x; if(center.distanceSquared(p)>=R2) return false; + p.x=max.x; p.y=min.y; if(center.distanceSquared(p)>=R2) return false; + p.x=min.x; if(center.distanceSquared(p)>=R2) return false; + p.x=max.x; p.y=max.y; p.z=min.z; if(center.distanceSquared(p)>=R2) return false; + p.x=min.x; if(center.distanceSquared(p)>=R2) return false; + p.x=max.x; p.y=min.y; if(center.distanceSquared(p)>=R2) return false; + p.x=min.x; if(center.distanceSquared(p)>=R2) return false; + + return true; + } + + /** + \brief Tests if the sphere intersects another sphere + + \param sphere [in] the other sphere + \return true if spheres overlap + */ + NX_INLINE bool Intersect(const NxSphere& sphere) const + { + NxF32 r = radius + sphere.radius; + return center.distanceSquared(sphere.center) <= r*r; + } + + NxVec3 center; //!< Sphere's center + NxF32 radius; //!< Sphere's radius + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphereForceFieldShape.h b/libraries/external/physx/Win32/include/PX/NxSphereForceFieldShape.h new file mode 100755 index 0000000..50888b9 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphereForceFieldShape.h @@ -0,0 +1,86 @@ +#ifndef NX_PHYSICS_NXSPHEREFORCEFIELDSHAPE +#define NX_PHYSICS_NXSPHEREFORCEFIELDSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxForceFieldShape.h" + +class NxSphereForceFieldShapeDesc; + +/** + \brief A spherical force field shape + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShape +*/ +class NxSphereForceFieldShape : public NxForceFieldShape +{ + public: + /** + \brief Sets the sphere radius. + + Call this to initialize or alter the sphere. + + \param[in] radius The new radius for the sphere. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setRadius(NxReal radius) = 0; + + /** + \brief Retrieves the radius of the sphere. + + \return The radius of the sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + + virtual NxReal getRadius() const = 0; + + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to save to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphereForceFieldShapeDesc + */ + virtual void saveToDesc(NxSphereForceFieldShapeDesc& desc) const=0; +}; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphereForceFieldShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxSphereForceFieldShapeDesc.h new file mode 100755 index 0000000..1735c7e --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphereForceFieldShapeDesc.h @@ -0,0 +1,76 @@ +#ifndef NX_PHYSICS_NXSPHEREFORCEFIELDSHAPEDESC +#define NX_PHYSICS_NXSPHEREFORCEFIELDSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxForceFieldShapeDesc.h" +/** + \brief A descriptor for NxSphereForceFieldShape + + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : Yes +\li XB360: Yes + + @see NxForceFieldShapeDesc, NxForceFieldShape, NxForceField +*/ +class NxSphereForceFieldShapeDesc : public NxForceFieldShapeDesc + { + public: + NxReal radius; //!< radius of the sphere. + + /** + \brief constructor sets to default. + */ + NX_INLINE NxSphereForceFieldShapeDesc (); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + }; + +NX_INLINE NxSphereForceFieldShapeDesc::NxSphereForceFieldShapeDesc () : NxForceFieldShapeDesc(NX_SHAPE_SPHERE) + { + setToDefault(); + } + +NX_INLINE void NxSphereForceFieldShapeDesc::setToDefault() + { + NxForceFieldShapeDesc::setToDefault(); + radius = 1.0f; + } +NX_INLINE bool NxSphereForceFieldShapeDesc::isValid() const + { + if(!NxMath::isFinite(radius)) return false; + if(radius<=0.0f) return false; + + return NxForceFieldShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphereShape.h b/libraries/external/physx/Win32/include/PX/NxSphereShape.h new file mode 100755 index 0000000..7585c30 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphereShape.h @@ -0,0 +1,117 @@ +#ifndef NX_COLLISION_NXSPHERESHAPE +#define NX_COLLISION_NXSPHERESHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" + +class NxSphereShapeDesc; + +/** +\brief A sphere shaped collision detection primitive. + +Each shape is owned by an actor that it is attached to. + +

Creation

+ +An instance can be created by calling the createShape() method of the NxActor object +that should own it, with a NxSphereShapeDesc object as the parameter, or by adding the +shape descriptor into the NxActorDesc class before creating the actor. + +The shape is deleted by calling NxActor::releaseShape() on the owning actor. + +Example: + +\include NxSphereShape_Create.cpp + +

Visualizations

+\li NX_VISUALIZE_COLLISION_AABBS +\li NX_VISUALIZE_COLLISION_SHAPES +\li NX_VISUALIZE_COLLISION_AXES + +@see NxSphereShapeDesc NxShape +*/ + +class NxSphereShape : public NxShape + { + public: + /** + \brief Sets the sphere radius. + + Call this to initialize or alter the sphere. If this is not called, + then the default settings create a unit sphere at the origin. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] radius The new radius for the sphere. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setRadius(NxReal radius) = 0; + + /** + \brief Retrieves the radius of the sphere. + + \return The radius of the sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + + virtual NxReal getRadius() const = 0; + + /** + \brief Gets the sphere data in world space. + + \param[out] worldSphere Retrieves the description of the sphere in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere + */ + virtual void getWorldSphere(NxSphere& worldSphere) const = 0; + + /* + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphereShapeDesc + */ + virtual void saveToDesc(NxSphereShapeDesc& desc) const = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphereShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxSphereShapeDesc.h new file mode 100755 index 0000000..ddf3105 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphereShapeDesc.h @@ -0,0 +1,81 @@ +#ifndef NX_COLLISION_NXSPHERESHAPEDESC +#define NX_COLLISION_NXSPHERESHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShapeDesc.h" + +/** +\brief Descriptor class for #NxSphereShape. + +@see NxSphereShape NxShapeDesc + +*/ +class NxSphereShapeDesc : public NxShapeDesc + { + public: + /** + \brief radius of shape. Must be positive. + + Range: (0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal radius; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxSphereShapeDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxSphereShapeDesc::NxSphereShapeDesc() : NxShapeDesc(NX_SHAPE_SPHERE) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxSphereShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + radius = 1.0f; + } + +NX_INLINE bool NxSphereShapeDesc::isValid() const + { + if(!NxMath::isFinite(radius)) return false; + if(radius<=0.0f) return false; + return NxShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphericalJoint.h b/libraries/external/physx/Win32/include/PX/NxSphericalJoint.h new file mode 100755 index 0000000..d86008b --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphericalJoint.h @@ -0,0 +1,152 @@ +#ifndef NX_PHYSICS_NXSPHERICALJOINT +#define NX_PHYSICS_NXSPHERICALJOINT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxSphericalJointDesc.h" + +#include "PX/NxJoint.h" + +/** + \brief A sphere joint constrains two points on two bodies to coincide. + + This point, specified in world space (this guarantees that the points coincide + to start with) is the only parameter that has to be specified. + + \image html sphericalJoint.png + +

Creation

+ + Example: + + \include NxSphericalJoint_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_JOINT_LOCAL_AXES +\li #NX_VISUALIZE_JOINT_WORLD_AXES +\li #NX_VISUALIZE_JOINT_LIMITS + + @see NxSphericalJointDesc NxScene.createJoint() NxJoint +*/ + +class NxSphericalJoint: public NxJoint + { + public: + + /** + \brief Use this for changing a significant number of joint parameters at once. + + Use the set() methods for changing only a single property at once. + + Please note that you can not change the actor pointers using this function, if you do so the joint will be marked as broken and will stop working. + + Calling the loadFromDesc() method on a broken joint will result in an error message. + + Sleeping: This call wakes the actor if it is sleeping. + + \param[in] desc The descriptor used to set the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphericalJointDesc saveToDesc() + */ + virtual void loadFromDesc(const NxSphericalJointDesc &desc) = 0; + + /** + \brief Writes all of the object's attributes to the desc struct + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphericalJointDesc loadFromDesc() + */ + virtual void saveToDesc(NxSphericalJointDesc &desc) = 0; + + /** + \brief Sets the flags to enable/disable the spring/motor/limit. + + This is a combination of the bits defined by ::NxSphericalJointFlag. + + \param[in] flags The new value for the joint flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphericalJointFlag getFlags() + */ + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief Returns the current flag settings. + + \return The flags associated with the joint. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getFlags() NxSphericalJointFlag + */ + virtual NxU32 getFlags() = 0; + + /** + \brief Sets the joint projection mode. + + \param[in] projectionMode The new projection mode for the joint. See #NxJointProjectionMode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getProjectionMode() NxJointProjectionMode + */ + virtual void setProjectionMode(NxJointProjectionMode projectionMode) = 0; + + /** + \brief Returns the current flag settings. + + \return The joints projection mode. See #NxJointProjectionMode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setProjectionMode() NxJointProjectionMode + */ + virtual NxJointProjectionMode getProjectionMode() = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSphericalJointDesc.h b/libraries/external/physx/Win32/include/PX/NxSphericalJointDesc.h new file mode 100755 index 0000000..747ece3 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSphericalJointDesc.h @@ -0,0 +1,248 @@ +#ifndef NX_PHYSICS_NXSPHEREJOINTDESC +#define NX_PHYSICS_NXSPHEREJOINTDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxJointLimitPairDesc.h" +#include "PX/NxSpringDesc.h" +#include "PX/NxJointDesc.h" + +class NxActor; + + +/** +\brief Desc class for an #NxSphericalJoint. + +@see NxSphericalJoint NxScene.createJoint() +*/ +class NxSphericalJointDesc : public NxJointDesc + { + public: + /** + \brief swing limit axis defined in the joint space of actor 0. + + ([localNormal[0], localAxis[0]^localNormal[0],localAxis[0]]) + + Range: direction vector
+ Default: 0.0, 0.0, 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxVec3 swingAxis; + + + /** + \brief Distance above which to project joint. + + If flags.projectionMode is 1, the joint gets artificially projected together when it drifts more than this distance. + + Sometimes it is not possible to project (for example when the joints form a cycle). + + Should be nonnegative. + + However, it may be a bad idea to always project to a very small or zero distance because the solver *needs* some error in order to produce correct motion. + + Range: [0,inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see projectionMode NxJointProjectionMode + */ + NxReal projectionDistance; + + +//limits: + + /** + \brief limits rotation around twist axis + + Range: See #NxJointLimitPairDesc
+ Default: See #NxJointLimitPairDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitPairDesc swingLimit + */ + NxJointLimitPairDesc twistLimit; + + /** + \brief limits swing of twist axis + + Range: See #NxJointLimitDesc
+ Default: See #NxJointLimitDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointLimitDesc twistLimit + */ + NxJointLimitDesc swingLimit; + + +//spring + damper: + + /** + \brief spring that works against twisting + + Range: See #NxSpringDesc
+ Default: See #NxSpringDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringDesc + */ + NxSpringDesc twistSpring; + + /** + \brief spring that works against swinging + + Range: See #NxSpringDesc
+ Default: See #NxSpringDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringDesc + */ + NxSpringDesc swingSpring; + + /** + \brief spring that lets the joint get pulled apart + + Range: See #NxSpringDesc
+ Default: See #NxSpringDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringDesc + */ + NxSpringDesc jointSpring; + + /** + \brief This is a combination of the bits defined by ::NxSphericalJointFlag . + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphericalJointFlag + */ + NxU32 flags; + + /** + \brief use this to enable joint projection + + Default: NX_JPM_NONE + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see projectionDistance NxJointProjectionMode + */ + NxJointProjectionMode projectionMode; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxSphericalJointDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxSphericalJointDesc::NxSphericalJointDesc() : NxJointDesc(NX_JOINT_SPHERICAL) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxSphericalJointDesc::setToDefault() + { + NxJointDesc::setToDefault(); + + swingAxis.set(0,0,1); + + twistLimit.setToDefault(); + swingLimit.setToDefault(); + twistSpring.setToDefault(); + swingSpring.setToDefault(); + jointSpring.setToDefault(); + + projectionDistance = 1.0f; + + flags = 0; + projectionMode = NX_JPM_NONE; + } + +NX_INLINE bool NxSphericalJointDesc::isValid() const + { + //check unit vectors + if (swingAxis.magnitudeSquared() < 0.9f) return false; + if (projectionDistance < 0.0f) return false; + + if (!twistLimit.isValid()) return false; + if (!swingLimit.isValid()) return false; + if (!swingSpring.isValid()) return false; + if (!twistSpring.isValid()) return false; + if (!jointSpring.isValid()) return false; + + return NxJointDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSpringAndDamperEffector.h b/libraries/external/physx/Win32/include/PX/NxSpringAndDamperEffector.h new file mode 100755 index 0000000..f95fa89 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSpringAndDamperEffector.h @@ -0,0 +1,198 @@ +#ifndef NX_PHYSICS_NXSPRINGANDDAMPEREFFECTOR +#define NX_PHYSICS_NXSPRINGANDDAMPEREFFECTOR +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxEffector.h" + +class NxActor; +class NxEffector; +class NxSpringAndDamperEffectorDesc; + +/** +\brief Represents a spring and damper element, which exerts a force between two bodies, + proportional to the relative positions and the relative velocities of the bodies. + +\note The spring and damper element is deprecated and the distance joint should be used in its place, for the following reasons: + +\li Spring and Damper elements are not as numerically stable as genuine joints. +\li Joints have proper sleep behavior, bodies fall asleep and wake up at appropriate times with regard to forces being transfered across the joints spring. + + +

Creation

+ + Example: + + \include NxSpringAndDamperEffector_Create.cpp + + @see NxScene.createSpringAndDamperEffector() NxScene.releaseEffector() +*/ +class NxSpringAndDamperEffector: public NxEffector + { + public: + /** + \brief Writes all of the effector's spring attributes to the description, as well + as setting the 2 actor connection points. + + \param[out] desc The descriptor used to retrieve the state of the effector. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void saveToDesc(NxSpringAndDamperEffectorDesc &desc) = 0; + + /** + \brief Sets the two bodies which are connected by the element. + + You may set one of the bodies to NULL to signify that the effect is between a body and the static + environment. + + Setting both of the bodies to NULL is invalid. + + Each body parameter is followed by a point defined in the global coordinate frame, which will + move with the respective body. This is the point where the respective end of the spring and damper + element is attached to the body. + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] body1 First Body. + \param[in] global1 Attachment point for spring in the global frame. Range: position vector + \param[in] body2 Second Body + \param[in] global2 Attachment point for spring in the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setBodies(NxActor* body1, const NxVec3 & global1, NxActor* body2, const NxVec3 & global2) = 0; + + /** + \brief Sets the properties of the linear spring. + + Sleeping: Does NOT wake the associated actor up automatically. + + The first three parameters are stretch distances between the end points: + + The following has to hold: 0 <= distCompressSaturate <= distRelaxed <= distStretchSaturate and + 0 <= maxCompressForce, 0 <= maxStretchForce. + + The last two parameters are maximal force magnitudes. Set maxCompressForce to zero to disable the + compress phase. Set maxStretchForce to zero to disable the stretch phase. + + + \param[in] distCompressSaturate is the distance at which the repulsive spring force magnitude no + longer increases, but stays constant. Range: [0,springDistRelaxed] + + \param[in] distRelaxed is the distance at which the spring is relaxed, and there is no spring force + applied. Range: [springDistCompressSaturate,springDistStretchSaturate] + + \param[in] distStretchSaturate is the distance at which the attractive spring force magnitude no + longer increases, but stays constant. Range: [springDistCompressSaturate,inf) + + \param[in] maxCompressForce is the force applied when distCompressSaturate is reached. The force + ramps up linearly until this value, starting at zero at distRelaxed. Range: [0,inf) + + \param[in] maxStretchForce is the force applied when distStretchSaturate is reached. The force + ramps up linearly until this value, starting at zero at distRelaxed. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setLinearSpring(NxReal distCompressSaturate, NxReal distRelaxed, NxReal distStretchSaturate, NxReal maxCompressForce, NxReal maxStretchForce) = 0; + + /** + \brief Retrieves the spring properties. See #setLinearSpring. + + \param[out] distCompressSaturate is the distance at which the repulsive spring force magnitude no longer increases, but stays constant. + \param[out] distRelaxed is the distance at which the spring is relaxed, and there is no spring force applied. + \param[out] distStretchSaturate is the distance at which the attractive spring force magnitude no longer increases, but stays constant. + + \param[out] maxCompressForce is the force applied when distCompressSaturate is reached. The force ramps up linearly until this value, starting at zero at distRelaxed. + \param[out] maxStretchForce is the force applied when distStretchSaturate is reached. The force ramps up linearly until this value, starting at zero at distRelaxed. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void getLinearSpring(NxReal & distCompressSaturate, NxReal & distRelaxed, NxReal & distStretchSaturate, NxReal & maxCompressForce, NxReal & maxStretchForce) = 0; + + /** + \brief Sets the properties of the linear damper. + + The first two parameters are relative body velocities and the last two parameters are maximal force + magnitudes. + + The following has to hold: velCompressSaturate <= 0 <= velStretchSaturate and 0 <= maxCompressForce; 0 <= maxStretchForce + + Sleeping: Does NOT wake the associated actor up automatically. + + \param[in] velCompressSaturate is the negative (compression direction) velocity where the damping + force magnitude no longer increases, but stays constant. Range: (-inf,0] + + \param[in] velStretchSaturate is the positive (stretch direction) velocity where the the damping + force magnitude no longer increases, but stays constant. Range: [0,inf) + + \param[in] maxCompressForce is the force applied when velCompressSaturate is reached. The force + ramps up linearly until this value, starting at zero at vrel == 0. Range: [0,inf) + + \param[in] maxStretchForce is the force applied when velStretchSaturate is reached. The force + ramps up linearly until this value, starting at zero at vrel == 0. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setLinearDamper(NxReal velCompressSaturate, NxReal velStretchSaturate, NxReal maxCompressForce, NxReal maxStretchForce) = 0; + + /** + \brief Retrieves the damper properties. + + Retrieves the damper properties. See #setLinearDamper. + + \param[out] velCompressSaturate is the negative (compression direction) velocity where the damping force magnitude no longer increases, but stays constant. + \param[out] velStretchSaturate is the positive (stretch direction) velocity where the the damping force magnitude no longer increases, but stays constant. + + \param[out] maxCompressForce is the force applied when velCompressSaturate is reached. The force ramps up linearly until this value, starting at zero at vrel == 0. + \param[out] maxStretchForce is the force applied when velStretchSaturate is reached. The force ramps up linearly until this value, starting at zero at vrel == 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void getLinearDamper(NxReal & velCompressSaturate, NxReal & velStretchSaturate, NxReal & maxCompressForce, NxReal & maxStretchForce) = 0; + + protected: + virtual ~NxSpringAndDamperEffector(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSpringAndDamperEffectorDesc.h b/libraries/external/physx/Win32/include/PX/NxSpringAndDamperEffectorDesc.h new file mode 100755 index 0000000..d960ad1 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSpringAndDamperEffectorDesc.h @@ -0,0 +1,300 @@ +#ifndef NX_PHYSICS_NXSPRINGANDDAMPEREFFECTORDESC +#define NX_PHYSICS_NXSPRINGANDDAMPEREFFECTORDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxEffectorDesc.h" + +class NxActor; + +/* TODO: This is not yet/anymore used for anything useful!! */ + +/** +\brief Desc class for NxSpringAndDamperEffector. + +

Example

+ +\include NxSpringAndDamperEffector_Create.cpp + +@see NxSpringAndDamperEffector +*/ +class NxSpringAndDamperEffectorDesc : public NxEffectorDesc + { + public: + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxSpringAndDamperEffectorDesc(); + + /** + \brief (re)sets the structure to the default. + */ + virtual NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + virtual NX_INLINE bool isValid() const; + + /** + \brief First attached body. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setBodies() + */ + NxActor* body1; + + /** + \brief Second attached body. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setBodies() + */ + NxActor* body2; + + /** + \brief First attachment point. + + Range: position vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setBodies() + */ + NxVec3 pos1; + + /** + \brief Second attachment point. + + Range: position vector
+ Default: Zero + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setBodies() + */ + NxVec3 pos2; + +//linear spring parameters: + /** + \brief The distance at which the maximum repulsive force is attained (at shorter distances it remains the same). + + Range: [0,springDistRelaxed]
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearSpring() NxSpringAndDampererEffector.getLinearSpring() + */ + NxReal springDistCompressSaturate; + + /** + \brief The distance at which the spring force is zero. + + Range: [springDistCompressSaturate,springDistStretchSaturate]
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearSpring() NxSpringAndDampererEffector.getLinearSpring() + */ + NxReal springDistRelaxed; + + /** + \brief The distance at which the attractive spring force attains its maximum (farther away it remains the same). + + Range: [springDistCompressSaturate,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearSpring() NxSpringAndDampererEffector.getLinearSpring() + */ + NxReal springDistStretchSaturate; + + /** + \brief The maximum repulsive spring force, attained at distance springDistCompressSaturate. + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearSpring() NxSpringAndDampererEffector.getLinearSpring() + */ + NxReal springMaxCompressForce; + + /** + \brief The maximum attractive spring force, attained at distance springDistStretchSaturate. + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearSpring() NxSpringAndDampererEffector.getLinearSpring() + */ + NxReal springMaxStretchForce; + +//linear damper parameters: + + /** + \brief The relative velocity (negative) at which the repulsive damping force attains its maximum. + + Range: (-inf,0]
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearDamper() NxSpringAndDampererEffector.getLinearDamper() + */ + NxReal damperVelCompressSaturate; + + /** + \brief The relative velocity at which the attractive damping force attains its maximum. + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearDamper() NxSpringAndDampererEffector.getLinearDamper() + */ + NxReal damperVelStretchSaturate; + + /** + \brief The maximum repulsive damping force, attained at relative velocity damperVelCompressSaturate + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearDamper() NxSpringAndDampererEffector.getLinearDamper() + */ + NxReal damperMaxCompressForce; + + /** + \brief The maximum attractive damping force, attained at relative velocity damperVelStretchSaturate + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSpringAndDamperEffector.setLinearDamper() NxSpringAndDampererEffector.getLinearDamper() + */ + NxReal damperMaxStretchForce; + }; + +NX_INLINE NxSpringAndDamperEffectorDesc::NxSpringAndDamperEffectorDesc() : NxEffectorDesc(NX_EFFECTOR_SPRING_AND_DAMPER) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxSpringAndDamperEffectorDesc::setToDefault() + { + NxEffectorDesc::setToDefault(); + + body1 = NULL; + body2 = NULL; + + pos1.zero(); + pos2.zero(); + + springDistCompressSaturate = 0; + springDistRelaxed = 0; + springDistStretchSaturate = 0; + springMaxCompressForce = 0; + springMaxStretchForce = 0; + + damperVelCompressSaturate = 0; + damperVelStretchSaturate = 0; + damperMaxCompressForce = 0; + damperMaxStretchForce = 0; + } + +NX_INLINE bool NxSpringAndDamperEffectorDesc::isValid() const + { + return NxEffectorDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSpringDesc.h b/libraries/external/physx/Win32/include/PX/NxSpringDesc.h new file mode 100755 index 0000000..7dd84d8 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSpringDesc.h @@ -0,0 +1,138 @@ +#ifndef NX_PHYSICS_NXSPRINGDESC +#define NX_PHYSICS_NXSPRINGDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +/** +\brief Describes a joint spring. + +The spring is implicitly integrated, so even high spring and damper coefficients should be robust. + +

Example

+ +\include NxSpringDesc_NxJointLimitDesc_Example.cpp + +@see NxDistanceJoint NxRevoluteJoint NxSphericalJoint NxWheelShape NxMaterial NxMaterialDesc +*/ +class NxSpringDesc + { + public: + + /** + \brief spring coefficient + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal spring; + + /** + \brief damper coefficient + + Range: [0,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal damper; + + /** + \brief target value (angle/position) of spring where the spring force is zero. + + Range: Angular: (-PI,PI]
+ Range: Positional: (-inf,inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal targetValue; + + /** + \brief Initializes the NxSpringDesc with default parameters. + */ + NX_INLINE NxSpringDesc(); + + /** + \brief Initializes a NxSpringDesc with the given parameters. + + \param[in] spring Spring Coefficient. Range: (-inf,inf) + \param[in] damper Damper Coefficient. Range: [0,inf) + \param[in] targetValue Target value (angle/position) of spring where the spring force is zero. + Range: Angular: (-PI,PI] Positional: (-inf,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxSpringDesc(NxReal spring, NxReal damper = 0, NxReal targetValue = 0); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + + \return True if the current settings are valid. + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxSpringDesc::NxSpringDesc() + { + setToDefault(); + } + +NX_INLINE NxSpringDesc::NxSpringDesc(NxReal s, NxReal d, NxReal t) + { + spring = s; + damper = d; + targetValue = t; + } + +NX_INLINE void NxSpringDesc::setToDefault() + { + spring = 0; + damper = 0; + targetValue = 0; + } + +NX_INLINE bool NxSpringDesc::isValid() const + { + return (spring >= 0 && damper >= 0); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxStream.h b/libraries/external/physx/Win32/include/PX/NxStream.h new file mode 100755 index 0000000..eac49c6 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxStream.h @@ -0,0 +1,174 @@ +#ifndef NX_FOUNDATION_NXSTREAM +#define NX_FOUNDATION_NXSTREAM +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +/** +\brief Callback class for data serialization. + +The user needs to supply an NxStream implementation to a number of methods to allow the SDK to read or write +chunks of binary data. This allows flexibility for the source/destination of the data. For example the NxStream +could store data in a file, memory buffer or custom file format. + +\note It is the users resposibility to ensure that the data is written to the appropriate offset. NxStream does not +expose any seeking functionality. + +

Example

+ +\include NxStream_Example.cpp + +@see NxPhysicsSDK.createTriangleMesh() NxPhysicsSDK.createConvexMesh() NxTriangleMesh.load() + +*/ +class NxStream + { + public: + /** + \brief Empty constructor. + */ + + NxStream() {} + /** + \brief Virtual destructor. + */ + + virtual ~NxStream() {} + + // Loading API + + /** + \brief Called to read a single unsigned byte(8 bits) + + \return Byte read. + */ + virtual NxU8 readByte() const = 0; + + /** + \brief Called to read a single unsigned word(16 bits) + + \return Word read. + */ + virtual NxU16 readWord() const = 0; + + /** + \brief Called to read a single unsigned dword(32 bits) + + \return DWord read. + */ + virtual NxU32 readDword() const = 0; + + /** + \brief Called to read a single precision floating point value(32 bits) + + \return Floating point value read. + */ + virtual NxF32 readFloat() const = 0; + + /** + \brief Called to read a double precision floating point value(64 bits) + + \return Floating point value read. + */ + virtual NxF64 readDouble() const = 0; + + /** + \brief Called to read a number of bytes. + + \param[out] buffer Buffer to read bytes into, must be at least size bytes in size. + \param[in] size The size of the buffer in bytes. + */ + virtual void readBuffer(void* buffer, NxU32 size) const = 0; + + // Saving API + + /** + \brief Called to write a single unsigned byte to the stream(8 bits). + + \param b Byte to store. + \return Reference to the current NxStream object. + */ + virtual NxStream& storeByte(NxU8 b) = 0; + + /** + \brief Called to write a single unsigned word to the stream(16 bits). + + \param w World to store. + \return Reference to the current NxStream object. + */ + virtual NxStream& storeWord(NxU16 w) = 0; + + /** + \brief Called to write a single unsigned dword to the stream(32 bits). + + \param d DWord to store. + \return Reference to the current NxStream object. + */ + virtual NxStream& storeDword(NxU32 d) = 0; + + /** + \brief Called to write a single precision floating point value to the stream(32 bits). + + \param f floating point value to store. + \return Reference to the current NxStream object. + */ + virtual NxStream& storeFloat(NxF32 f) = 0; + + /** + \brief Called to write a double precision floating point value to the stream(64 bits). + + \param f floating point value to store. + \return Reference to the current NxStream object. + */ + virtual NxStream& storeDouble(NxF64 f) = 0; + + /** + \brief Called to write an array of bytes to the stream. + + \param[in] buffer Array of bytes, size bytes in size. + \param[in] size Size, in bytes of buffer. + \return Reference to the current NxStream object. + */ + virtual NxStream& storeBuffer(const void* buffer, NxU32 size) = 0; + + + /** + \brief Store a signed byte(wrapper for the unsigned version). + + \param b Byte to store. + \return Reference to the current NxStream object. + */ + NX_INLINE NxStream& storeByte(NxI8 b) { return storeByte(NxU8(b)); } + + /** + \brief Store a signed word(wrapper for the unsigned version). + + \param w Word to store. + \return Reference to the current NxStream object. + */ + NX_INLINE NxStream& storeWord(NxI16 w) { return storeWord(NxU16(w)); } + + /** + \brief Store a signed dword(wrapper for the unsigned version). + + \param d DWord to store. + \return Reference to the current NxStream object. + */ + NX_INLINE NxStream& storeDword(NxI32 d) { return storeDword(NxU32(d)); } + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxSwTarget.h b/libraries/external/physx/Win32/include/PX/NxSwTarget.h new file mode 100755 index 0000000..18d0924 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxSwTarget.h @@ -0,0 +1,213 @@ +#ifndef NX_PHYSICS_NXSWTARGET +#define NX_PHYSICS_NXSWTARGET + +#include "PX/Nxp.h" + +namespace NxForceFieldInternals +{ + +class NxSwFloat; +class NxSwVec; + +template +struct NxForceFieldEpsHolder +{ + static float epsilon; +}; + +template float NxForceFieldEpsHolder::epsilon = 1e-3f; + +class NxSwBool +{ + friend class NxSw; + friend class NxSwBoolVar; + friend class NxSwVec; + friend NxSwBool operator &(const NxSwBool &b1, const NxSwBool &b2); + friend NxSwBool operator |(const NxSwBool &b1, const NxSwBool &b2); + friend NxSwBool operator ^(const NxSwBool &b1, const NxSwBool &b2); +private: +protected: + bool val; +public: + NX_INLINE NxSwBool() {} + NX_INLINE NxSwBool(bool t) { val = t; } + NX_INLINE NxSwBool(int t) { val = !!t; } // For "Boolean b = true ^ true;" + + NX_INLINE NxSwFloat select(NxSwFloat f0, NxSwFloat f1); + NX_INLINE NxSwVec select(NxSwVec& v0, NxSwVec& v1); +}; + +NX_INLINE NxSwBool operator &(const NxSwBool &b1, const NxSwBool &b2) +{ + return NxSwBool(b1.val && b2.val); +} +NX_INLINE NxSwBool operator |(const NxSwBool &b1, const NxSwBool &b2) +{ + return NxSwBool(b1.val || b2.val); +} +NX_INLINE NxSwBool operator ^(const NxSwBool &b1, const NxSwBool &b2) +{ + return NxSwBool(!b1.val && b2.val||b1.val && !b2.val); +} + +class NxSwBoolVar: public NxSwBool +{ +public: + NX_INLINE NxSwBoolVar(const NxSwBool& b) { val = b.val; } + NX_INLINE void operator=(const NxSwBool& b) { val = b.val; } +}; + +class NxSwFloat +{ + friend class NxSw; + friend class NxSwVec; + friend class NxSwFloatVar; + friend class NxSwVecVar; + friend NxSwFloat operator +(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwFloat operator -(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwFloat operator *(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwBool operator<(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwBool operator>(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwBool operator==(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwBool operator<=(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwBool operator>=(const NxSwFloat &t1, const NxSwFloat &t2); + friend NxSwBool operator!=(const NxSwFloat &t1, const NxSwFloat &t2); + +protected: + NxReal val; +public: + NX_INLINE NxSwFloat() {} + NX_INLINE NxSwFloat(NxReal v): val(v) {} + + NX_INLINE NxSwFloat operator -() const { return NxSwFloat(-val); } + NX_INLINE NxSwFloat recip() { return fabsf(val) < NxForceFieldEpsHolder<>::epsilon ? 0 : NxSwFloat(1.0f/val); } + NX_INLINE NxSwFloat recipSqrt() { return fabsf(val) < NxForceFieldEpsHolder<>::epsilon ? 0 : NxSwFloat(1.0f/sqrtf(val)); } + NX_INLINE NxSwFloat sqrt() { return NxSwFloat(sqrtf(val)); } + NX_INLINE static void setEpsilon(NxReal eps) { NxForceFieldEpsHolder<>::epsilon = eps; } + +}; + +NX_INLINE NxSwFloat operator +(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwFloat(t1.val+t2.val); +} +NX_INLINE NxSwFloat operator -(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwFloat(t1.val-t2.val); +} +NX_INLINE NxSwFloat operator *(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwFloat(t1.val*t2.val); +} +NX_INLINE NxSwBool operator<(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwBool(t1.val(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwBool(t1.val>t2.val); +} +NX_INLINE NxSwBool operator==(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwBool(t1.val==t2.val); +} +NX_INLINE NxSwBool operator<=(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwBool(t1.val<=t2.val); +} +NX_INLINE NxSwBool operator>=(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwBool(t1.val>=t2.val); +} +NX_INLINE NxSwBool operator!=(const NxSwFloat &t1, const NxSwFloat &t2) +{ + return NxSwBool(t1.val!=t2.val); +} + +class NxSwFloatVar: public NxSwFloat +{ +public: + NX_INLINE NxSwFloatVar(NxReal v) { val = v; } + NX_INLINE NxSwFloatVar(const NxSwFloat& t) { val = t.val; } + NX_INLINE void operator =(const NxSwFloat& t) { val = t.val; } + NX_INLINE void operator +=(const NxSwFloat& t) { val += t.val; } + NX_INLINE void operator -=(const NxSwFloat& t) { val -= t.val; } + NX_INLINE void operator *=(const NxSwFloat& t) { val *= t.val; } +}; + +class NxSwVec +{ + friend class NxSw; + friend class NxSwVecVar; + +private: + NxVec3 val; + NX_INLINE NxSwVec(NxReal mx, NxReal my, NxReal mz): val(mx,my,mz) {} +public: + NX_INLINE NxSwVec() {} + NX_INLINE NxSwVec(const NxVec3& t): val(t) {} + + NX_INLINE NxSwFloat getX() const { return NxSwFloat(val.x); } + NX_INLINE NxSwFloat getY() const { return NxSwFloat(val.y); } + NX_INLINE NxSwFloat getZ() const { return NxSwFloat(val.z); } + NX_INLINE NxSwVec operator +(const NxSwVec& t) const { return NxSwVec(val + t); } + NX_INLINE NxSwVec operator -(const NxSwVec& t) const { return NxSwVec(val - t); } + NX_INLINE NxSwVec operator -() const { return NxSwVec( -val); } + NX_INLINE NxSwVec operator *(NxSwFloat f) const { return NxSwVec(val * f.val); } + NX_INLINE NxSwFloat dot(const NxSwVec& t) const { return NxSwFloat(val.dot(t.val)); } + NX_INLINE NxSwVec cross(const NxSwVec& t) const { return NxSwVec(val.cross(t.val)); } + NX_INLINE operator NxVec3() const { return val; } + NX_INLINE NxSwFloat magnitude() const { return val.magnitude(); } +}; + +class NxSwVecVar: public NxSwVec +{ +public: + NX_INLINE NxSwVecVar():NxSwVec(0,0,0) {} + NX_INLINE NxSwVecVar(const NxSwVec& t) { val = t.val;} + NX_INLINE void setX(const NxSwFloat &f) { val.x=f.val; } + NX_INLINE void setY(const NxSwFloat &f) { val.y=f.val; } + NX_INLINE void setZ(const NxSwFloat &f) { val.z=f.val; } + NX_INLINE void operator=(const NxSwVec& t) { val = t; } + NX_INLINE void operator +=(const NxSwVec& t) { val += t; } + NX_INLINE void operator -=(const NxSwVec& t) { val -= t; } +}; + +class NxSw +{ +public: + typedef NxSwFloat FConstType; + typedef NxSwFloatVar FVarType; + + typedef NxSwVec VConstType; + typedef NxSwVecVar VVarType; + + typedef NxSwBool BConstType; + typedef NxSwBoolVar BVarType; + + static NX_INLINE bool testFailure(NxSwBool condition) { return condition.val; } + static NX_INLINE bool testFinish(NxSwBool condition) { return condition.val; } + + static NX_INLINE bool getBoolVal(const NxSwBool& b) { return b.val; } + static NX_INLINE NxReal getFloatVal(const NxSwFloat& f) { return f.val; } + static NX_INLINE NxVec3 getVecVal(const NxSwVec& v) { return v.val; } +}; + +NX_INLINE NxSwFloat NxSwBool::select(NxSwFloat f0, NxSwFloat f1) + { + return NxSwFloat(val ? f0 : f1); + } + +NX_INLINE NxSwVec NxSwBool::select(NxSwVec& v0, NxSwVec& v1) + { + return NxSwVec(val ? v0 : v1); + } + +} // namespace +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxTargets.h b/libraries/external/physx/Win32/include/PX/NxTargets.h new file mode 100755 index 0000000..985cebf --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxTargets.h @@ -0,0 +1,15 @@ +#ifndef NX_PHYSICS_NXTARGETS +#define NX_PHYSICS_NXTARGETS + +#include "PX/NxSwTarget.h" +#if NX_ENABLE_HW_PARSER +#include "PX/NxHwTarget.h" +#endif + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2007 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxTriangle.h b/libraries/external/physx/Win32/include/PX/NxTriangle.h new file mode 100755 index 0000000..270ac72 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxTriangle.h @@ -0,0 +1,122 @@ +#ifndef NX_COLLISION_NXTRIANGLE +#define NX_COLLISION_NXTRIANGLE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + + #define NX_INV3 0.33333333333333333333f //!< 1/3 + +/** +\brief Triangle class. + +@see NxTriangleMesh NxTriangleMeshDesc +*/ + class NxTriangle + { + public: + /** + \brief Constructor + */ + NX_INLINE NxTriangle() + { + } + /** + \brief Constructor + + \param[in] p0 Point 0 + \param[in] p1 Point 1 + \param[in] p2 Point 2 + */ + NX_INLINE NxTriangle(const NxVec3& p0, const NxVec3& p1, const NxVec3& p2) + { + verts[0] = p0; + verts[1] = p1; + verts[2] = p2; + } + /** + \brief Copy constructor + + \param[in] triangle Tri to copy + */ + NX_INLINE NxTriangle(const NxTriangle& triangle) + { + verts[0] = triangle.verts[0]; + verts[1] = triangle.verts[1]; + verts[2] = triangle.verts[2]; + } + /** + \brief Destructor + */ + NX_INLINE ~NxTriangle() + { + } + + /** + \brief Array of Vertices. + */ + NxVec3 verts[3]; + + /** + \brief Compute the center of the NxTriangle. + + \param[out] center Retrieve center (average) point of triangle. + */ + NX_INLINE void center(NxVec3& center) const + { + center = (verts[0] + verts[1] + verts[2])*NX_INV3; + } + + /** + \brief Compute the normal of the NxTriangle. + + \param[out] _normal Triangle normal. + */ + NX_INLINE void normal(NxVec3& _normal) const + { + _normal = (verts[1]-verts[0])^(verts[2]-verts[0]); + _normal.normalize(); + } + + /** + \brief Makes a fat triangle + + \param[in] fatCoeff Amount to inflate triangle by. + \param[in] constantBorder True - Add same width independent of triangle size. False - Add bigger borders to biggers triangles. + */ + NX_INLINE void inflate(float fatCoeff, bool constantBorder) + { + // Compute triangle center + NxVec3 triangleCenter; + center(triangleCenter); + + // Don't normalize? + // Normalize => add a constant border, regardless of triangle size + // Don't => add more to big triangles + for(unsigned i=0;i<3;i++) + { + NxVec3 v = verts[i] - triangleCenter; + + if(constantBorder) v.normalize(); + + verts[i] += v * fatCoeff; + } + } + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxTriangleMesh.h b/libraries/external/physx/Win32/include/PX/NxTriangleMesh.h new file mode 100755 index 0000000..c20ab52 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxTriangleMesh.h @@ -0,0 +1,356 @@ +#ifndef NX_COLLISION_NXTRIANGLEMESH +#define NX_COLLISION_NXTRIANGLEMESH +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxVec3.h" +#include "PX/NxBounds3.h" + +class NxTriangleMeshShape; +class NxSimpleTriangleMesh; +class NxTriangleMeshDesc; +class NxTriangleMeshShapeDesc; +class NxPMap; +class NxStream; + + +/** + +\brief A triangle mesh, also called a 'polygon soup'. + +It is represented as an indexed triangle list. There are no restrictions on the +triangle data. + +To avoid duplicating data when you have several instances of a particular +mesh positioned differently, you do not use this class to represent a +mesh object directly. Instead, you create an instance of this mesh via +the NxTriangleMeshShape class. + +

Creation

+ +To create an instance of this class call NxPhysicsSDK::createTriangleMesh(), +and NxPhysicsSDK::releaseTriangleMesh() to delete it. This is only possible +once you have released all of its NxTriangleMeshShape instances. + + +Example: + +\include NxTriangleMesh_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_COLLISION_AABBS +\li #NX_VISUALIZE_COLLISION_SHAPES +\li #NX_VISUALIZE_COLLISION_AXES +\li #NX_VISUALIZE_COLLISION_VNORMALS +\li #NX_VISUALIZE_COLLISION_FNORMALS +\li #NX_VISUALIZE_COLLISION_EDGES +\li #NX_VISUALIZE_COLLISION_SPHERES + +@see NxTriangleMeshDesc NxTriangleMeshShape NxPhysicsSDK.createTriangleMesh() +*/ + +class NxTriangleMesh + { + public: + /** + \brief Saves the Mesh descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool saveToDesc(NxTriangleMeshDesc& desc) const = 0; + + /** + \brief Not used. + */ + virtual NxU32 getSubmeshCount() const = 0; + + /** + \brief Retrieves the number of elements of a given internal array. + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array size to retrieve(e.g. triangles, points etc). See #NxInternalArray. + \return The number of elements in the internal array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getFormat() getStride() getBase() + */ + virtual NxU32 getCount(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the format of a given internal array. + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array format to retrieve(e.g. triangles, points etc). See #NxInternalArray. + \return The format of the internal array. See #NxInternalFormat + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCount() getStride() getBase() + */ + virtual NxInternalFormat getFormat(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the base pointer of a given internal array. + + Example: + + \include NxTriangleMesh_getBase.cpp + + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array pointer to retrieve(e.g. triangles, points etc). See #NxInternalArray. + \return A pointer to the first element of the internal array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCount() getFormat() getStride() + */ + virtual const void* getBase(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the stride value of a given internal array. + + The stride value is always a number of bytes. You have to skip this number of bytes + to go from one element to the other in an array, starting from the base. + + \param[in] submeshIndex Reserved for future use, must be 0. + \param[in] intArray The internal array stride to retrieve(e.g. triangles, points etc). See #NxInternalArray. + \return The stride(number of bytes from one element to the next) for the internal array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getCount() getFormat() getBase() + */ + virtual NxU32 getStride(NxSubmeshIndex submeshIndex, NxInternalArray intArray) const = 0; + + /** + \brief Retrieves the number of PhysX processor pages into which a mesh is divided. + + Meshes used for PhysX processor collision are divided into a number of fixed-size pages. This + returns the number of such pages for this mesh. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getPageCount() const = 0; + + /** + \brief Retrieves the bounding box of a PhysX processor mesh page in the local space of the mesh + + \param pageIndex The index of the mesh page. Pages are indexed sequentially starting from 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + + virtual NxBounds3 getPageBBox(NxU32 pageIndex) const = 0; + + /** + \brief This call lets you supply a pmap if you have not done so at creation time. + + \warning Legacy function + +

Example

+ + \include NxPMap_Create.cpp + + \param[in] pmap The PMap to apply. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMeshDesc.pmap NxPMap + */ + virtual bool loadPMap(const NxPMap& pmap) = 0; + + /** + \brief Checks the mesh has a pmap or not. + + \warning Legacy function + + \return True if the mesh has a PMap associated with it. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMeshDesc.pmap NxPMap loadPMap() + */ + virtual bool hasPMap() const = 0; + + /** + \brief Gets the size of the pmap. + + \warning Legacy function + + \return The size (in bytes) necessary to store the associated PMap. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMeshDesc.pmap NxPMap loadPMap() hasPMap() + */ + virtual NxU32 getPMapSize() const = 0; + + /** + \brief Gets pmap data. + + \warning Legacy function + + You must first query expected size with getPmapSize(), then allocate a buffer large + enough to contain that amount of bytes, then call this function to dump data in preallocated buffer. + The system checks that pmap.dataSize is equal to expected data size, so you must initialize that + member as well before the query. + + \param[out] pmap Descriptor for PMap to retrieve. + \return True if the PMap is successfully extracted. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMeshDesc.pmap NxPMap loadPMap() hasPMap() getPMapSize() + */ + virtual bool getPMapData(NxPMap& pmap) const = 0; + + /** + \brief Gets the density of the pmap. + + \warning Legacy function + + \return The density(resolution) of the PMap, on all axis. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMeshDesc.pmap NxPMap loadPMap() hasPMap() getPMapSize() hasPMap() + */ + virtual NxU32 getPMapDensity() const = 0; + + /** + \brief Load the triangle mesh from a stream. + + You can create an appropriate stream using the cooking library. + + \param[in] stream Stream to load triangle mesh from. + \return True if the triangle mesh was successfully loaded. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxStream + */ + virtual bool load(const NxStream& stream) = 0; + + /** + \brief Returns material index of given triangle + + This function takes a post cooking triangle index. + + \param[in] triangleIndex (internal) index of desired triangle + \return Material index, or 0xffff if no per-triangle materials are used + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxMaterialIndex getTriangleMaterial(NxTriangleID triangleIndex) const = 0; + + /** + \brief Returns the reference count for shared meshes. + + \return the current reference count, not used in any shapes if the count is 0. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getReferenceCount() = 0; + + /** + \brief Returns the mass properties of the mesh. + + \param[out] mass The mass of the mesh. + \param[out] localInertia The inertia tensor in mesh local space. + \param[out] localCenterOfMass Position of center of mass in mesh local space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void getMassInformation(NxReal& mass, NxMat33& localInertia, NxVec3& localCenterOfMass) const = 0; + + protected: + virtual ~NxTriangleMesh(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxTriangleMeshDesc.h b/libraries/external/physx/Win32/include/PX/NxTriangleMeshDesc.h new file mode 100755 index 0000000..e037154 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxTriangleMeshDesc.h @@ -0,0 +1,217 @@ +#ifndef NX_COLLISION_NXTRIANGLEMESHDESC +#define NX_COLLISION_NXTRIANGLEMESHDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxTriangleMesh.h" +#include "PX/NxSimpleTriangleMesh.h" + +/** +\brief Descriptor class for #NxTriangleMesh. + +Note that this class is derived from NxSimpleTriangleMesh which contains the members that describe the basic mesh. +The mesh data is *copied* when an NxTriangleMesh object is created from this descriptor. After the call the +user may discard the triangle data. + +@see NxTriangleMesh NxTriangleMeshShape +*/ +class NxTriangleMeshDesc : public NxSimpleTriangleMesh + { + public: + /** + If materialIndices is NULL (not used) then this should be zero. Otherwise this is the + offset between material indices in bytes. This is at least sizeof(NxMaterialIndex). + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fall-back) + \li PS3 : Yes + \li XB360: Yes + + @see materialIndices + */ + NxU32 materialIndexStride; + + /** + Optional pointer to first material index, or NULL. There are NxSimpleTriangleMesh::numTriangles indices in total. + Caller may add materialIndexStride bytes to the pointer to access the next triangle. + + When a triangle mesh collides with another object, a material is required at the collision point. + If materialIndices is NULL, then the material of the NxTriangleMeshShape instance (specified via NxShapeDesc::materialIndex) is used. + Otherwise, if the point of contact is on a triangle with index i, then the material index is determined as: + NxMaterialIndex index = *(NxMaterialIndex *)(((NxU8*)materialIndices) + materialIndexStride * i); + + If the contact point falls on a vertex or an edge, a triangle adjacent to the vertex or edge is selected, and its index + used to look up a material. The selection is arbitrary but consistent over time. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fall-back) + \li PS3 : Yes + \li XB360: Yes + + @see materialIndexStride + */ + const void* materialIndices; + + /** + \brief Deprecated + + \warning This member is deprecated and will no longer be supported. Use the specialized #NxHeightField + class instead. + + The mesh may represent either an arbitrary mesh or a height field. The advantage of a height field + is that it is assumed to be semi-infinite along one axis, and therefore it doesn't have the problem + of fast moving objects 'popping' through it due to temporal under sampling. + + However, height fields must be 'flat' in the sense that the projections of all triangles onto the + height field plane must be disjoint. (If the height field vertical axis is Y, the height field plane is spanned by X and Z.) + + To create a height field, set heightFieldVerticalAxis to NX_X, NX_Y or NX_Z, + or leave it set to NX_NOT_HEIGHTFIELD for an arbitrary mesh. + + Default: NX_NOT_HEIGHTFIELD + + Platform: + \li PC SW: Deprecated + \li PPU : Deprecated + \li PS3 : Deprecated + \li XB360: Deprecated + + @see NxHeightFieldAxis heightFieldVerticalExtent + */ + NxHeightFieldAxis heightFieldVerticalAxis; + + /** + \brief Deprecated + + \warning This member is deprecated and will no longer be supported. Use the specialized #NxHeightField + class instead. + + If this mesh is a height field, this sets how far 'below ground' the height volume extends. + + In this way even objects which are under the surface of the height field but above + this cutoff are treated as colliding with the height field. To create a height field with the up axis being + the Y axis, you need to set the heightFieldVerticalAxis to Y and the heightFieldVerticalExtent to a large negative number. + + The heightFieldVerticalExtent has to be outside of the vertex coordinate range of the mesh along the heightFieldVerticalAxis. + + You may set this to a positive value, in which case the extent will be cast along the opposite side of the height field. + + You may use a smaller finite value for the extent if you want to put some space under the height field, such as a cave. + + Range: (-inf,inf)
+ Default: 0 + + Platform: + \li PC SW: Deprecated + \li PPU : Deprecated + \li PS3 : Deprecated + \li XB360: Deprecated + + @see heightFieldVerticalAxis + */ + NxReal heightFieldVerticalExtent; + + /** + The pmap is an optional data structure which makes mesh-mesh collision detection more robust at the cost of higher + memory consumption. A pmap can be created with ::NxCreatePMap and released with ::NxReleasePMap. + You may also save the output of ::NxCreatePMap do disc to avoid this preprocessing step. + + \warning Legacy member + + The pmap data will not be copied. For this reason the caller does not need to keep it around for the lifetime of + the NxTriangleMesh object. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh.loadPMap + */ + NxPMap* pmap; + + /** + The SDK computes convex edges of a mesh and use them for collision detection. This parameter allows you to + setup a tolerance for the convex edge detector. + + Range: (0,inf)
+ Default: 0.001 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NxReal convexEdgeThreshold; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxTriangleMeshDesc(); + + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the descriptor is valid. + \return true if the current settings are valid + */ + NX_INLINE bool isValid() const; + }; + +NX_INLINE NxTriangleMeshDesc::NxTriangleMeshDesc() //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxTriangleMeshDesc::setToDefault() + { + NxSimpleTriangleMesh::setToDefault(); + materialIndexStride = 0; + materialIndices = 0; + heightFieldVerticalAxis = NX_NOT_HEIGHTFIELD; + heightFieldVerticalExtent = 0; + convexEdgeThreshold = 0.001f; + pmap = NULL; + } + +NX_INLINE bool NxTriangleMeshDesc::isValid() const + { + if(numVertices < 3) //at least 1 trig's worth of points + return false; + if ((!triangles) && (numVertices%3)) // Non-indexed mesh => we must ensure the geometry defines an implicit number of triangles // i.e. numVertices can't be divided by 3 + return false; + //add more validity checks here + if (materialIndices && materialIndexStride < sizeof(NxMaterialIndex)) + return false; + return NxSimpleTriangleMesh::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxTriangleMeshShape.h b/libraries/external/physx/Win32/include/PX/NxTriangleMeshShape.h new file mode 100755 index 0000000..be668a9 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxTriangleMeshShape.h @@ -0,0 +1,244 @@ +#ifndef NX_COLLISION_NXTRIANGLEMESHSHAPE +#define NX_COLLISION_NXTRIANGLEMESHSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" +#include "PX/NxUserEntityReport.h" + +class NxTriangle; +class NxTriangleMeshShapeDesc; +class NxTriangleMesh; + + +/** +\brief This class is a shape instance of a triangle mesh object of type NxTriangleMesh. + +Each shape is owned by an actor that it is attached to. + +

Creation

+ +An instance can be created by calling the createShape() method of the NxActor object +that should own it, with a NxTriangleMeshShapeDesc object as the parameter, or by adding the +shape descriptor into the NxActorDesc class before creating the actor. + +The shape is deleted by calling NxActor::releaseShape() on the owning actor. + +PPU: Collision detection will only be performed against mesh pages which have been mapped into +PPU memory using #mapPageInstance() + +Example: + +\include NxTriangleMeshShape_Create.cpp + +

Visualizations:

+\li #NX_VISUALIZE_COLLISION_AABBS +\li #NX_VISUALIZE_COLLISION_SHAPES +\li #NX_VISUALIZE_COLLISION_AXES +\li #NX_VISUALIZE_COLLISION_VNORMALS +\li #NX_VISUALIZE_COLLISION_FNORMALS +\li #NX_VISUALIZE_COLLISION_EDGES +\li #NX_VISUALIZE_COLLISION_SPHERES + +@see NxTriangleMeshShapeDesc NxTriangleMesh +*/ + +class NxTriangleMeshShape: public NxShape + { + public: + /* + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMeshShapeDesc + */ + virtual void saveToDesc(NxTriangleMeshShapeDesc& desc) const = 0; + + /** + \brief Retrieves the triangle mesh data associated with this instance. + + \return The triangle mesh associated with this shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh + */ + virtual NxTriangleMesh& getTriangleMesh() = 0; + virtual const NxTriangleMesh& getTriangleMesh() const = 0; + + /** + \brief Retrieves triangle data from a triangle ID. + + This function can be used together with #overlapAABBTriangles() to retrieve triangle properties. + + \param[out] triangle triangle points in local or world space. + \param[out] edgeTri World space edge normals for triangle (NULL to not compute). + \param[out] flags Flags which show if an edge is convex. See #NxTriangleFlags + \param[in] triangleIndex The index of the triangle to retrieve. + \param[in] worldSpaceTranslation true to return triangle's position in world space, else false for local space + \param[in] worldSpaceRotation true to return triangle's orientation in world space, else false for local space + \return Unused. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangle NxTriangleFlags NxTriangleID overlapAABBTriangles() + */ + virtual NxU32 getTriangle(NxTriangle& triangle, NxTriangle* edgeTri, NxU32* flags, NxTriangleID triangleIndex, bool worldSpaceTranslation=true, bool worldSpaceRotation=true) const = 0; + + /** + \brief Finds triangles touching the input bounds. + + \warning This method returns a pointer to an internal structure using the indices member. Hence the + user should use or copy the indices before calling any other API function. + + \warning This method is deprecated and overlapAABBTriangles(const NxBounds3 bounds, NxU32 flags, NxUserEntityReport* callback) should + be used in new code as it is more efficient and less error prone. + + The triangle indices returned by overlapAABBTriangles() can be used with #getTriangle() to retrieve the triangle properties. + + \param[in] bounds Bounds to test against. In object or world space depending on #NxQueryFlags. Range: See #NxBounds3 + \param[in] flags Controls if the bounds are in object or world space and if we return first contact only. See #NxQueryFlags. + \param[out] nb Retrieves the number of triangle indices touching the AABB. + \param[out] indices Returns an array of touching triangle indices. + \return True if there is an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxQueryFlags NxScene.overlapAABBShapes() getTriangle() + */ + NX_INLINE bool overlapAABBTriangles(const NxBounds3& bounds, NxU32 flags, NxU32& nb, const NxU32*& indices) const + { + return overlapAABBTrianglesDeprecated(bounds, flags, nb, indices); + } + + virtual bool overlapAABBTrianglesDeprecated(const NxBounds3& bounds, NxU32 flags, NxU32& nb, const NxU32*& indices) const = 0; + + /** + \brief Finds triangles touching the input bounds. + + The triangle indices returned by overlapAABBTriangles() can be used with #getTriangle() to retrieve the triangle properties. + + \param[in] bounds Bounds to test against. In object or world space depending on #NxQueryFlags. Range: See #NxBounds3 + \param[in] flags Controls if the bounds are in object or world space and if we return first contact only. See #NxQueryFlags. + \param[in] callback Used to return triangles which intersect the AABB + \return True if there is an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxQueryFlags NxScene.overlapAABBShapes() getTriangle() NxUserEntityReport + */ + virtual bool overlapAABBTriangles(const NxBounds3& bounds, NxU32 flags, NxUserEntityReport* callback) const = 0; + + /** + \brief Send a page to the PhysX processor. + + Ensure that a mesh instance corresponding to a mesh page is present on the PhysX processor. If the + page is not present on the processor, it is also sent. If the PhysX processor is not present, this call has + no effect and returns false. If the page instance is already on the processor, this call has no effect and + returns true. + + If the mesh is emulated in software then collision detection will still be performed, even if the pages + of the mesh are not mapped. Since the software versions of the collision detection routines do not require + the mesh to be mapped into hardware memory. + + Cases where a mesh will be emulated in software(for 2.5): + + \li Dynamic(movable) triangle meshes. + \li Triangle meshes with per triangle materials. + \li mesh-mesh collision (pmaps). + \li Heightfield triangle meshes. + + \param[in] pageIndex the index of the page to map. Pages are indexed sequentially starting from zero. + \return False if there are insufficient resources available on the processor to accommodate the page or page + instance. False is also returned when the mesh is being run in software. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see unmapPageInstance() isPageInstanceMapped() + */ + + virtual bool mapPageInstance(NxU32 pageIndex) = 0; + + /** + \brief Release a page instance from the PhysX processor. + + Release a page instance corresponding to a mesh page from the PhysX processor. no other page instances + reference the mesh page, the page is also released. If the PhysX card is not present, this call has no effect. + + \param[in] pageIndex the index of the page to unmap. Pages are indexed sequentially starting from zero. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isPageInstanceMapped() mapPageInstance() + */ + + virtual void unmapPageInstance(NxU32 pageIndex) = 0; + + /** + \brief Determine whether a page instance is present from the PhysX processor. + + \param[in] pageIndex the index of the page being queried. Pages are indexed sequentially starting from zero. + \return False if the page is not mapped or if the PhysX processor is not present. False is also returned + when the mesh is being emulated in software. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see mapPageInstance() unmapPageInstance() + */ + + virtual bool isPageInstanceMapped(NxU32 pageIndex) const = 0; + + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxTriangleMeshShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxTriangleMeshShapeDesc.h new file mode 100755 index 0000000..0b378bb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxTriangleMeshShapeDesc.h @@ -0,0 +1,121 @@ +#ifndef NX_COLLISION_NXTRIANGLEMESHSHAPEDESC +#define NX_COLLISION_NXTRIANGLEMESHSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/NxShapeDesc.h" +#include "PX/NxTriangleMeshShape.h" + +/** +\brief Descriptor class for #NxTriangleMeshShape. + +@see NxTriangleMeshShape +*/ +class NxTriangleMeshShapeDesc : public NxShapeDesc + { + public: + /** + \brief References the triangle mesh that we want to instance. + + Default: NULL + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh + */ + NxTriangleMesh* meshData; + + /** + \brief Combination of ::NxMeshShapeFlag. + + Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshShapeFlag + */ + NxU32 meshFlags; + + /** + \brief Mesh paging scheme. + + Default: NX_MESH_PAGING_MANUAL + + Platform: + \li PC SW: No + \li PPU : Yes + \li PS3 : No + \li XB360: No + + @see NxMeshPagingMode + */ + NxMeshPagingMode meshPagingMode; + +#ifdef NX_SUPPORT_MESH_SCALE + NxReal scale; +#endif + /** + \brief Constructor sets to default. + */ + NX_INLINE NxTriangleMeshShapeDesc(); + /** + \brief (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + /** + \brief Returns true if the descriptor is valid. + + \return true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + +NX_INLINE NxTriangleMeshShapeDesc::NxTriangleMeshShapeDesc() : NxShapeDesc(NX_SHAPE_MESH) //constructor sets to default + { + setToDefault(); + } + +NX_INLINE void NxTriangleMeshShapeDesc::setToDefault() + { + NxShapeDesc::setToDefault(); + meshData = NULL; + meshFlags = 0; + meshPagingMode = NX_MESH_PAGING_MANUAL; +#ifdef NX_SUPPORT_MESH_SCALE + scale = 1.0f; +#endif + } + +NX_INLINE bool NxTriangleMeshShapeDesc::isValid() const + { + if(!meshData) return false; +#ifdef NX_SUPPORT_MESH_SCALE + if(scale<=0.0f) return false; +#endif + return NxShapeDesc::isValid(); + } + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserAllocator.h b/libraries/external/physx/Win32/include/PX/NxUserAllocator.h new file mode 100755 index 0000000..df189cc --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserAllocator.h @@ -0,0 +1,562 @@ +#ifndef NX_FOUNDATION_NXUSERALLOCATOR +#define NX_FOUNDATION_NXUSERALLOCATOR +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" + +class NxUserAllocator; + +/** +\brief Enum tp identify memory allocations within the SDK. +*/ +enum NxMemoryType +{ + NX_MEMORY_PERSISTENT, + NX_MEMORY_TEMP, + NX_MEMORY_Articulation, + NX_MEMORY_ArticulationMaximal, + NX_MEMORY_AxisConstraint, + NX_MEMORY_Body, + NX_MEMORY_BoxShape, + NX_MEMORY_CapsuleShape, + NX_MEMORY_Cloth, + NX_MEMORY_ClothManager, + NX_MEMORY_ClothMesh, + NX_MEMORY_WheelShape, + NX_MEMORY_CollisionMap, + NX_MEMORY_ConvexMeshBuilder, + NX_MEMORY_ConvexMeshRuntime, + NX_MEMORY_ConvexShape, + NX_MEMORY_DebugRenderable, + NX_MEMORY_Edge, + NX_MEMORY_Fluid, + NX_MEMORY_FluidEmitter, + NX_MEMORY_FluidEmitterPressure, + NX_MEMORY_FluidEmitterRate, + NX_MEMORY_FluidPacketShape, + NX_MEMORY_FluidElementRbElementInteraction, + NX_MEMORY_FluidIdToIndexMap, + NX_MEMORY_FluidParticleQueue, + NX_MEMORY_FrictionPatch, + NX_MEMORY_ExtraTrigData, + NX_MEMORY_JointBreakEvent, + NX_MEMORY_KinematicTarget, + NX_MEMORY_LimitPlane, + NX_MEMORY_Material, + NX_MEMORY_NpActor, + NX_MEMORY_NpMaterial, + NX_MEMORY_NpCompartment, + NX_MEMORY_NvJointBreakEvent, + NX_MEMORY_SortedSet_NameBinding, + NX_MEMORY_FoundationSDK, + NX_MEMORY_NxMutex, + NX_MEMORY_PenetrationMap, + NX_MEMORY_PersistentPairData, + NX_MEMORY_PhysicsSDK, + NX_MEMORY_PlaneShape, + NX_MEMORY_Scene, + NX_MEMORY_SceneObjectPools, + NX_MEMORY_NPPoolManager, + NX_MEMORY_SphereShape, + NX_MEMORY_SpringAndDamperEffector, + NX_MEMORY_TriangleMesh, + NX_MEMORY_TriangleMeshBuilder, + NX_MEMORY_TriangleMeshShape, + NX_MEMORY_HeightField, + NX_MEMORY_HeightFieldShape, + NX_MEMORY_NpPlaneShape, + NX_MEMORY_NpSphereShape, + NX_MEMORY_NpBoxShape, + NX_MEMORY_NpCapsuleShape, + NX_MEMORY_NpConvexShape, + NX_MEMORY_NpTriangleMeshShape, + NX_MEMORY_NpHeightFieldShape, + NX_MEMORY_NpWheelShape, + NX_MEMORY_NpScene, + NX_MEMORY_NpTriangleMesh, + NX_MEMORY_NpConvexMesh, + NX_MEMORY_NpHeightField, + NX_MEMORY_NpPhysicsSDK, + NX_MEMORY_PhysicsThread, + NX_MEMORY_AsyncSceneThread, + NX_MEMORY_NpPrismaticJoint, + NX_MEMORY_AsyncScene, + NX_MEMORY_NpRevoluteJoint, + NX_MEMORY_NpCylindricalJoint, + NX_MEMORY_NpSphericalJoint, + NX_MEMORY_NpPointOnLineJoint, + NX_MEMORY_NpPointInPlaneJoint, + NX_MEMORY_NpFixedJoint, + NX_MEMORY_NpDistanceJoint, + NX_MEMORY_NpPulleyJoint, + NX_MEMORY_NpD6Joint, + NX_MEMORY_NpSpringAndDamperEffector, + NX_MEMORY_NpForceField, + NX_MEMORY_NpForceFieldLinearKernel, + NX_MEMORY_NpForceFieldShapeGroup, + NX_MEMORY_ForceFieldShapeGroups, + NX_MEMORY_NpFluid, + NX_MEMORY_PrismaticJoint, + NX_MEMORY_RevoluteJoint, + NX_MEMORY_CylindricalJoint, + NX_MEMORY_SphericalJoint, + NX_MEMORY_PointOnLineJoint, + NX_MEMORY_PointInPlaneJoint, + NX_MEMORY_DistanceJoint, + NX_MEMORY_PulleyJoint, + NX_MEMORY_FixedJoint, + NX_MEMORY_D6Joint, + NX_MEMORY_NpFluidEmitter, + NX_MEMORY_NpCloth, + NX_MEMORY_NpClothMesh, + NX_MEMORY_NpSoftBody, + NX_MEMORY_NpSoftBodyMesh, + NX_MEMORY_NpCCDSkeleton, + NX_MEMORY_SourceCCDSkeleton, + NX_MEMORY_CCDTest, + NX_MEMORY_Array, + NX_MEMORY_Profiler, + NX_MEMORY_ProfilerManager, + NX_MEMORY_NxTriangle, + NX_MEMORY_CachedMesh, + NX_MEMORY_BoundsMirror, + NX_MEMORY_MirroredActor, + NX_MEMORY_DynamicMirror, + NX_MEMORY_HashCell, + NX_MEMORY_RigidSceneZoner, + NX_MEMORY_MirroredForceFieldGroup, + + NX_MEMORY_SolverCoreGeneral, + NX_MEMORY_SolverCoreSSE, + NX_MEMORY_NPhaseCore, + NX_MEMORY_BroadPhase, + NX_MEMORY_GroupSolveCoreSingle, + + //Low level + NX_MEMORY_LowLevel, + NX_MEMORY_LowLevelDebug, + NX_MEMORY_LowLevelThreadingTask, + NX_MEMORY_LowLevelThreadingThunk, + + + NX_MEMORY_NPhaseContext, + NX_MEMORY_GroupSolveContext, + NX_MEMORY_NPhaseContextWithContainer, + NX_MEMORY_NxTask, + + NX_MEMORY_NpSchedulerItem, + NX_MEMORY_NpInternalThread, + + NX_MEMORY_RemoteDebugger, + NX_MEMORY_VRDProfiling, + NX_MEMORY_VRDContacts, + NX_MEMORY_VRDData, + + NX_MEMORY_PxScene, + NX_MEMORY_PxActor, + NX_MEMORY_PxInteraction, + NX_MEMORY_PxElement, + NX_MEMORY_StaticActor, + NX_MEMORY_InactiveActor, + NX_MEMORY_DynamicActor, + NX_MEMORY_JointInteraction, + NX_MEMORY_RawBoundsElement, + NX_MEMORY_RawBoundsInteraction, + NX_MEMORY_PageBoundsElement, + NX_MEMORY_PageBoundsInteraction, + + NX_MEMORY_SoftwareSceneGraphUpdatePCM, + NX_MEMORY_SoftwarePoseChangeNotifyPCM, + NX_MEMORY_SoftwareBroadPhasePCM, + NX_MEMORY_SoftwarePairCachePCM, + NX_MEMORY_SoftwareNarrowPhasePCM, + NX_MEMORY_SoftwareIslandDetectionPCM, + NX_MEMORY_SoftwareBodyPrepPCM, + NX_MEMORY_SoftwareConstraintPrepPCM, + NX_MEMORY_SoftwarePoseIntegratePCM, + NX_MEMORY_SoftwareConstraintSolvePCM, + NX_MEMORY_SoftwarePackPCM, + + /* FW DDI objects */ + NX_MEMORY_PPUDataStream, + NX_MEMORY_NfArticulation, + NX_MEMORY_NfArticulationMaximal, + NX_MEMORY_NfBody, + NX_MEMORY_NfConvexMapper, + NX_MEMORY_NfJoint, + NX_MEMORY_NfMaterial, + NX_MEMORY_NfPPUDebug, + NX_MEMORY_NfPage, + NX_MEMORY_NfPageHash, + NX_MEMORY_NfPageInstanceMapper, + NX_MEMORY_NfPageMapper, + NX_MEMORY_NfPhysicsSDK, + NX_MEMORY_NfProfileOutput, + NX_MEMORY_NfProjectionTree, + NX_MEMORY_NfRBFwPipeline, + NX_MEMORY_NfRBSwPipeline, + NX_MEMORY_NfRBDebugPipeline, + NX_MEMORY_NfScene, + NX_MEMORY_NfRBSceneImage, + NX_MEMORY_NfShape, + NX_MEMORY_NfSyncManager, + NX_MEMORY_NfProfile, + NX_MEMORY_NfVRDBint, + NX_MEMORY_NfRawTriangleMesh, + NX_MEMORY_FluidMeshPacketHash, + NX_MEMORY_NfFluidMeshCuisine, + NX_MEMORY_NfParticleQueue, + + /* Fw DDI mallocs */ + NX_MEMORY_NfShapePageTable, + NX_MEMORY_NfRBSwPipelinePCMTable, + NX_MEMORY_NfRBSwPipelineSendBuf, + NX_MEMORY_NfRBSwPipelineRecvBuf, + NX_MEMORY_NfSyncManagerMaterialBM, + NX_MEMORY_NfSyncManagerPrevAwakeBM, + NX_MEMORY_NfSyncManagerCurrAwakeBM, + NX_MEMORY_NfPageInstanceMapperInstancePool, + NX_MEMORY_NfConvexMapperConvexPool, + NX_MEMORY_NfRBDebugPipelinePCMTable, + NX_MEMORY_NFRBDebugPipelineComparatorTable, + NX_MEMORY_NvVRDContactBuffer, + + NX_MEMORY_NfRBDebugPipelineComparatorTable, + NX_MEMORY_NfConvexHash, + NX_MEMORY_FwConvex, + + /* Fluid-DDI objects*/ + NX_MEMORY_NvFluidEmitterEvent, + NX_MEMORY_NvFluidEvent, + NX_MEMORY_NfFluid, + NX_MEMORY_NfFluidTriangleMeshPPUInterfaceSw, + NX_MEMORY_NfFluidTriangleMeshPPUInterfaceHw, + NX_MEMORY_NfFluidPPUInterfaceSw, + NX_MEMORY_NfFluidPPUInterfaceHw, + NX_MEMORY_NfFluidPPUInterfaceSwRef, + NX_MEMORY_FluidCollisionSwRef, + NX_MEMORY_FluidDynamicsSwRef, + NX_MEMORY_FluidSwRef, + NX_MEMORY_NeighborSearchSwRef, + NX_MEMORY_ParticlePairStreamSwRef, + NX_MEMORY_SpatialHashSwRef, + NX_MEMORY_NfFluidEmitter, + NX_MEMORY_NfFluidEmitterPressure, + NX_MEMORY_NfFluidEmitterRate, + NX_MEMORY_ParticleArray, + NX_MEMORY_SiteData, + NX_MEMORY_NfFluidDataPrint, + NX_MEMORY_NfShapeList, + NX_MEMORY_NxShapeList, + NX_MEMORY_DebugPacketHash, + NX_MEMORY_FluidTriangle, + NX_MEMORY_FluidMeshPktNode, + NX_MEMORY_FluidMeshPktBucket, + NX_MEMORY_FluidMeshCellNode, + NX_MEMORY_FluidMeshCellBucket, + NX_MEMORY_NfMeshPacketManager, + NX_MEMORY_NfHeapManager, + NX_MEMORY_Heap, + NX_MEMORY_Buddy, + NX_MEMORY_BuddyList, + + /* Fluid DDI mallocs */ + NX_MEMORY_NfFluidControllerFW, + NX_MEMORY_NfFluidMeshPacketHashPPU, + NX_MEMORY_NfFluidMeshTriangleVector, + NX_MEMORY_NfCollisionTable, + NX_MEMORY_NfFluidParticleBuffer, + NX_MEMORY_NfFluidPacketTable, + NX_MEMORY_NfFluidVpePacketTable, + NX_MEMORY_NfFluidCellHashTable, + NX_MEMORY_NfFluidCellSumHashTable, + NX_MEMORY_NfFluidCellHashNode, + NX_MEMORY_NfFluidPacketHashNode, + NX_MEMORY_NfFluidUpdateBuffer, + NX_MEMORY_NfFluidMeshTriangleVectorElts, + NX_MEMORY_NfFluidMeshTriangleVectorElt, + NX_MEMORY_NfFluidMeshPktBucketVectorElts, + NX_MEMORY_NfFluidMeshPktNodeVectorElts, + NX_MEMORY_NfFluidPacketHashPackedData, + NX_MEMORY_NfFluidMemCategory, + NX_MEMORY_NfFluidTransientBufferSet, + NX_MEMORY_NfFluidShapes, + + NX_MEMORY_NfFluidTriangleList, + NX_MEMORY_NfTriangleList, + + /* Cloth-DDI objects*/ + NX_MEMORY_NvClothEvent, + NX_MEMORY_NfCloth, + NX_MEMORY_NfClothPPUInterfaceSw, + NX_MEMORY_NfClothPPUInterfaceHw, + + /* Cloth DDI mallocs */ + NX_MEMORY_NfClothDataBuffer, + NX_MEMORY_NfClothCookBuffer, + +// ** NX_ALLOC calls + NX_MEMORY_CCD_TEMP, + NX_MEMORY_CONVEX_TEMP, + NX_MEMORY_TriangleMesh_TEMP, + NX_MEMORY_MINIBALL_TEMP, + NX_MEMORY_SMOOTH_NORMALS_TEMP, + NX_MEMORY_NxTriangle32, + NX_MEMORY_CCD_BUFFER, + NX_MEMORY_CCD_edgeDegenMap, + NX_MEMORY_InternalTriangleMesh_NxPoint, + NX_MEMORY_InternalTriangleMesh_NxTriangle32, + NX_MEMORY_InternalTriangleMesh_NxMaterialIndex, + NX_MEMORY_InternalTriangleMesh_faceRemap, + NX_MEMORY_InternalTriangelMesh_Plane, + NX_MEMORY_InternalTriangleMesh_Normals, + NX_MEMORY_InternalTriangleMesh_NxU8, + NX_MEMORY_InternalTriangleMesh_NxU16, + NX_MEMORY_InternalTriangleMesh_NxU32, + NX_MEMORY_NxSpringDesc, + NX_MEMORY_Scene_vertexTagStamps, + NX_MEMORY_Scene_featureCache, + NX_MEMORY_Scene_featureCacheExternal, + NX_MEMORY_TriangleMesh_NxU16, + NX_MEMORY_TriangleMesh_NxU8, + NX_MEMORY_PMAP, + NX_MEMORY_GenericCache_NxU8, + NX_MEMORY_PairManager_NxU32, + NX_MEMORY_PairManager_userPair, + NX_MEMORY_Utilities_FaceNormals, + NX_MEMORY_NxMutexRep, + NX_MEMORY_Generic_Array_Container, + NX_MEMORY_ConvexMesh, + NX_MEMORY_RawBounds, + NX_MEMORY_ClothSolverPacket, + NX_MEMORY_PMapSample, +// ** Ice Calls! + ICE_MEMORY_PERSISTENT, + ICE_MEMORY_TEMP, + ICE_MEMORY_SweepAndPrune, + ICE_MEMORY_Valencies, + ICE_MEMORY_ValenciesBuilder, + ICE_MEMORY_IndexedTriangle16, + ICE_MEMORY_HullPolygon, + ICE_MEMORY_Edge, + ICE_MEMORY_EdgeDesc, + ICE_MEMORY_CollisionHull, + ICE_MEMORY_SupportVertexMap, + ICE_MEMORY_RaycastMap, + ICE_MEMORY_MeshModel, + ICE_MEMORY_EdgeTriangle, + ICE_MEMORY_AdjTriangle, + ICE_MEMORY_AdjacenciesBuilder, + ICE_MEMORY_EdgeListBuilder, + ICE_MEMORY_LinearLooseOctree, + ICE_MEMORY_OctreeCell, + ICE_MEMORY_FreePruner, + ICE_MEMORY_DynamicPruner, + ICE_MEMORY_StaticPruner, + ICE_MEMORY_DynamicPruner2, + ICE_MEMORY_AABBTree, + ICE_MEMORY_AABBNoLeafTree, + ICE_MEMORY_AABBTreeNode, + ICE_MEMORY_AABBQuantizedNoLeafTree, + ICE_MEMORY_AABBCollisionTree, + ICE_MEMORY_PRUNING_SORTER, + ICE_MEMORY_AABBCollisionNode, + ICE_MEMORY_AABBNoLeafNode, + ICE_MEMORY_AABBQuantizedNode, + ICE_MEMORY_SAP_Element, + ICE_MEMORY_SAP_Box, + ICE_MEMORY_SAP_EndPoint, + ICE_MEMORY_CustomCell, + ICE_MEMORY_HandleManager, + ICE_MEMORY_AABBQuantizedNoLeafNode, + ICE_MEMORY_LeafTriangles, + ICE_MEMORY_Pair, +// Ice discrete allocations + ICE_MEMORY_ConvexDecomposer_FlatTags, + ICE_MEMORY_ConvexDecomposer_ConvexTags, + ICE_MEMORY_CookingUtils_XRef, + ICE_MEMORY_CookingUtils_RVerts, + ICE_MEMORY_CookingUtils_FaceNormals, + ICE_MEMORY_CookingUtils_VertexNormals, + ICE_MEMORY_ConvexHull_HullVertices, + ICE_MEMORY_ConvexHull_HullNormals, + ICE_MEMORY_ConvexHull_VertexData, + ICE_MEMORY_ConvexHull_EdgeData, + ICE_MEMORY_ConvexHull_EdgeNormals, + ICE_MEMORY_ConvexHull_FacesByEdges, + ICE_MEMORY_EdgeList_FacesByEdges, + ICE_MEMORY_EdgeList_ActiveEdges, + ICE_MEMORY_IceHullGaussMaps_Samples, + ICE_MEMORY_Valency_Valencies, + ICE_MEMORY_Valency_Offsets, + ICE_MEMORY_Valency_AdjecentVerts, + ICE_MEMORY_IcePruningPool_WorldBoxes, + ICE_MEMORY_IcePruningPool_Objects, + ICE_MEMORY_OPC_AABBTree_Indices, + ICE_MEMORY_OPC_HybridModel_Indices, + ICE_MEMORY_OPC_SweepAndPrune_Array, + ICE_MEMORY_IceContainer_NewEntries, + ICE_MEMORY_IceCustomArray_CellAddy, + ICE_MEMORY_IceHandleManager_Objects, + ICE_MEMORY_IceHandleManager_OutToIn, + ICE_MEMORY_IceHandleManager_InToOut, + ICE_MEMORY_IceHandleManager_Stamps, + ICE_MEMORY_IceRevisedRadix_Histogram, + ICE_MEMORY_IceRevistedRadix_Offset, + ICE_MEMORY_IceRevistedRadix_Ranks, + ICE_MEMORY_IceRevistedRadix_Ranks2, + + NX_MEMORY_LAST +}; + +#if defined(_DEBUG) + #define NX_NEW_TMP(x) new((const char *)__FILE__, __LINE__, #x, NX_MEMORY_##x) x + #define NX_NEW(x) new((const char *)__FILE__, __LINE__, #x, NX_MEMORY_##x) x + #define NX_NEW_MEM(x,y) new((const char *)__FILE__, __LINE__, #x, NX_MEMORY_##y) x +#else + #define NX_NEW_TMP(x) new(NX_MEMORY_##x) x + #define NX_NEW(x) new(NX_MEMORY_##x) x + #define NX_NEW_MEM(x,y) new(NX_MEMORY_##y) x +#endif + +/** + \brief Abstract base class for an application defined memory allocator that can be used by the Nx library. + + \note The SDK state should not be modified from within any allocation/free function. + + Threading: All methods of this class should be thread safe as it can be called from the user thread or the physics processing thread(s). + +

Example

+ + \include NxUserAllocator_Example.cpp +*/ +class NxUserAllocator + { + public: + /** + \brief Allocates size bytes of memory. + + Same as simple #malloc below, but with extra debug info fields. + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + + \param size Number of bytes to allocate. + \param fileName File which is allocating the memory. + \param line Line which is allocating the memory. + \return The allocated block of memory. + */ + virtual void* mallocDEBUG(size_t size, const char* fileName, int line) = 0; + + /** + \brief Allocates size bytes of memory. + + Same as simple #malloc below, but with extra debug info fields. + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + + \param size Number of bytes to allocate. + \param fileName File which is allocating the memory. + \param line Line which is allocating the memory. + \param className Name of the class which is allocating the memory. + \param type A hint about what the memory will be used for. See #NxMemoryType. + \return The allocated block of memory. + */ + virtual void* mallocDEBUG(size_t size, const char* fileName, int line, const char* className, NxMemoryType type) + { + return mallocDEBUG(size, fileName, line); // Just so we don't break user code + } + + /** + \brief Allocates size bytes of memory. + + Compatible with the standard C malloc(), with the exception that + it should never return NULL. If you run out of memory, then + you should terminate the app or take some other appropriate action. + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + + \param size Number of bytes to allocate. + \return The allocated block of memory. + */ + virtual void* malloc(size_t size) = 0; + + /** + \brief Allocates size bytes of memory. + + Compatible with the standard C malloc(), with the exception that + it should never return NULL. If you run out of memory, then + you should terminate the app or take some other appropriate action. + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + + \param size Number of bytes to allocate. + \param type A hint about what the memory will be used for. See #NxMemoryType. + \return The allocated block of memory. + */ + virtual void* malloc(size_t size, NxMemoryType type) + { + return malloc(size); // Just so we don't break user code + } + + /** + \brief Resizes the memory block previously allocated with malloc() or + realloc() to be size() bytes, and returns the possibly moved memory. + + Compatible with the standard C realloc(), with the exception that + it should never return NULL. If you run out of memory, then + you should terminate the app or take some other appropriate action. + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + + \param memory Memory block to change the size of. + \param size New size for memory block. + \return New pointer to the block of memory. + */ + virtual void* realloc(void* memory, size_t size) = 0; + + /** + \brief Frees the memory previously allocated by malloc() or realloc(). + + Compatible with the standard C free(). + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + + \param memory Memory to free. + */ + virtual void free(void* memory) = 0; + + /** + \brief Verify heap. + + Threading: This function should be thread safe as it can be called in the context of the user thread + and physics processing thread(s). + */ + virtual void checkDEBUG(void) {}; + + virtual ~NxUserAllocator(){}; + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserAllocatorDefault.h b/libraries/external/physx/Win32/include/PX/NxUserAllocatorDefault.h new file mode 100755 index 0000000..c046281 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserAllocatorDefault.h @@ -0,0 +1,113 @@ +#ifndef NX_FOUNDATION_NXUSER_ALLOCATOR_DEFAULT +#define NX_FOUNDATION_NXUSER_ALLOCATOR_DEFAULT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/NxUserAllocator.h" +#include "PX/Nx.h" + +#include + +#if defined(WIN32) && NX_DEBUG_MALLOC + #include +#endif + +/** +\brief Default implementation of memory allocator using standard C malloc / free / realloc. + +See #NxUserAllocator +*/ +class NxUserAllocatorDefault : public NxUserAllocator + { + public: + /** + \brief Allocates size bytes of memory. + + Compatible with the standard C malloc(). + */ + void* malloc(size_t size, NxMemoryType type) + { + return ::malloc(size); + } + void* malloc(size_t size) + { + return ::malloc(size); + } + + /** + \brief Allocates size bytes of memory. + + Same as above, but with extra debug info fields. + */ + void* mallocDEBUG(size_t size, const char* fileName, int line, const char* className, NxMemoryType type) + { +#ifdef _DEBUG + #if defined(WIN32) && NX_DEBUG_MALLOC + return ::_malloc_dbg(size, _NORMAL_BLOCK, fileName, line); + #else + return ::malloc(size); + #endif +#else + NX_ASSERT(0);//Don't use debug malloc for release mode code! + return 0; +#endif + } + void* mallocDEBUG(size_t size, const char* fileName, int line) + { +#ifdef _DEBUG + #if defined(WIN32) && NX_DEBUG_MALLOC + return ::_malloc_dbg(size, _NORMAL_BLOCK, fileName, line); + #else + return ::malloc(size); + #endif +#else + NX_ASSERT(0);//Don't use debug malloc for release mode code! + return 0; +#endif + } + + /** + \brief Resizes the memory block previously allocated with malloc() or + realloc() to be size() bytes, and returns the possibly moved memory. + + Compatible with the standard C realloc(). + */ + void* realloc(void* memory, size_t size) + { + return ::realloc(memory,size); + } + + /** + \brief Frees the memory previously allocated by malloc() or realloc(). + + Compatible with the standard C free(). + */ + void free(void* memory) + { + ::free(memory); + } + + void check() + { +#if defined(WIN32) && defined(_DEBUG) + _CrtCheckMemory(); +#endif + } + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserContactReport.h b/libraries/external/physx/Win32/include/PX/NxUserContactReport.h new file mode 100755 index 0000000..8c323bb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserContactReport.h @@ -0,0 +1,461 @@ +#ifndef NX_COLLISION_NXUSERCONTACTREPORT +#define NX_COLLISION_NXUSERCONTACTREPORT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" +#include "PX/NxContactStreamIterator.h" + +class NxActor; +class NxShape; + + +/** +\brief Contact pair flags. + +@see NxUserContactReport.onContactNotify() NxActor::setContactReportThreshold +*/ +enum NxContactPairFlag + { + NX_IGNORE_PAIR = (1<<0), //!< Disable contact generation for this pair + + NX_NOTIFY_ON_START_TOUCH = (1<<1), //!< Pair callback will be called when the pair starts to be in contact + NX_NOTIFY_ON_END_TOUCH = (1<<2), //!< Pair callback will be called when the pair stops to be in contact + NX_NOTIFY_ON_TOUCH = (1<<3), //!< Pair callback will keep getting called while the pair is in contact + NX_NOTIFY_ON_IMPACT = (1<<4), //!< [Not yet implemented] pair callback will be called when it may be appropriate for the pair to play an impact sound + NX_NOTIFY_ON_ROLL = (1<<5), //!< [Not yet implemented] pair callback will be called when the pair is in contact and rolling. + NX_NOTIFY_ON_SLIDE = (1<<6), //!< [Not yet implemented] pair callback will be called when the pair is in contact and sliding (and not rolling). + NX_NOTIFY_FORCES = (1<<7), //!< The (summed total) friction force and normal force will be given in the NxContactPair variable in the contact report. + NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD = (1<<8), //!< Pair callback will be called when the contact force between two actors exceeds one of the actor-defined force thresholds + NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD = (1<<9), //!< Pair callback will be called when the contact force between two actors falls below the actor-defined force thresholds + NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD = (1<<10), //!< Pair callback will keep getting called while the contact force between two actors exceeds one of the actor-defined force thresholds + + NX_NOTIFY_CONTACT_MODIFICATION = (1<<16), //!< Generate a callback for all associated contact constraints, making it possible to edit the constraint. This flag is not included in NX_NOTIFY_ALL for performance reasons. \see NxUserContactModify + + NX_NOTIFY_ALL = (NX_NOTIFY_ON_START_TOUCH|NX_NOTIFY_ON_END_TOUCH|NX_NOTIFY_ON_TOUCH|NX_NOTIFY_ON_IMPACT|NX_NOTIFY_ON_ROLL|NX_NOTIFY_ON_SLIDE|NX_NOTIFY_FORCES| + NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD|NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD|NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD) + }; + +/** +\brief An instance of this class is passed to NxUserContactReport::onContactNotify(). +It contains a contact stream which may be parsed using the class NxContactStreamIterator. + +@see NxUserContactReport.onContactNotify() +*/ +class NxContactPair + { + public: + NX_INLINE NxContactPair() : stream(NULL) {} + + /** + \brief The two actors that make up the pair. + + \note The actor pointers might reference deleted actors. Check the #isDeletedActor member to see + whether that is the case. Do not dereference a pointer to a deleted actor. The pointer to a + deleted actor is only provided such that user data structures which might depend on the pointer + value can be updated. + + @see NxActor + */ + NxActor* actors[2]; + + /** + \brief Use this to create stream iter. See #NxContactStreamIterator. + + @see NxConstContactStream + */ + NxConstContactStream stream; + + /** + \brief The total contact normal force that was applied for this pair, to maintain nonpenetration constraints. You should set NX_NOTIFY_FORCES in order to receive this value. + */ + NxVec3 sumNormalForce; + + /** + \brief The total tangential force that was applied for this pair. You should set NX_NOTIFY_FORCES in order to receive this value. + */ + NxVec3 sumFrictionForce; + + /** + \brief Specifies for each actor of the pair if the actor has been deleted. + + Before dereferencing the actor pointers of the contact pair you might want to use this member + to check if the pointers reference deleted actors. This will be the case if an actor for which + NX_NOTIFY_ON_END_TOUCH or NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD events were requested gets deleted. + + @see actors + */ + bool isDeletedActor[2]; + }; + +/** +\brief The user needs to implement this interface class in order to be notified when +certain contact events occur. + +Once you pass an instance of this class to #NxScene::setUserContactReport(), +its #onContactNotify() method will be called for each pair of actors which comes into contact, +for which this behavior was enabled. + +You request which events are reported using NxScene::setActorPairFlags(), +#NxScene::setShapePairFlags(), #NxScene::setActorGroupPairFlags() or #NxActor::setContactReportFlags() + +Please note: Kinematic actors will not generate contact reports when in contact with other kinematic actors. + + Threading: It is not necessary to make this class thread safe as it will only be called in the context of the + user thread. + +

Example

+ +\include NxUserContactReport_Example.cpp + +

Visualizations:

+\li #NX_VISUALIZE_CONTACT_POINT +\li #NX_VISUALIZE_CONTACT_NORMAL +\li #NX_VISUALIZE_CONTACT_ERROR +\li #NX_VISUALIZE_CONTACT_FORCE + +@see NxScene.setUserContactReport() NxScene.getUserNotify() +*/ +class NxUserContactReport + { + public: + /** + Called for a pair in contact. The events parameter is a combination of: + +
    +
  • NX_NOTIFY_ON_START_TOUCH,
  • +
  • NX_NOTIFY_ON_END_TOUCH,
  • +
  • NX_NOTIFY_ON_TOUCH,
  • +
  • NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD,
  • +
  • NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD,
  • +
  • NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD,
  • +
  • NX_NOTIFY_ON_IMPACT, //unimplemented!
  • +
  • NX_NOTIFY_ON_ROLL, //unimplemented!
  • +
  • NX_NOTIFY_ON_SLIDE, //unimplemented!
  • +
+ + See the documentation of #NxContactPairFlag for an explanation of each. You request which events + are reported using #NxScene::setActorPairFlags(), #NxScene::setActorGroupPairFlags(), + #NxScene::setShapePairFlags() or #NxActor::setContactReportFlags(). Do not keep a reference to + the passed object, as it will be invalid after this function returns. + + \note SDK state should not be modified from within onContactNotify(). In particular objects should not + be created or destroyed. If state modification is needed then the changes should be stored to a buffer + and performed after the simulation step. + + \param[in] pair The contact pair we are being notified of. See #NxContactPair. + \param[in] events Flags raised due to the contact. See #NxContactPairFlag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxContactPair NxContactPairFlag + */ + virtual void onContactNotify(NxContactPair& pair, NxU32 events) = 0; + + protected: + virtual ~NxUserContactReport(){}; + }; + +/** +\brief The user needs to implement this interface class in order to be notified when trigger events +occur. + +Once you pass an instance of this class to #NxScene::setUserTriggerReport(), shapes +which have been marked as triggers using NxShape::setFlag(NX_TRIGGER_ENABLE,true) will call the +#onTrigger() method when their trigger status changes. + +Threading: It is not necessary to make this class thread safe as it will only be called in the context of the +user thread. + +Example: + +\include NxUserTriggerReport_Usage.cpp + +

Visualizations

+\li NX_VISUALIZE_COLLISION_SHAPES + +@see NxScene.setUserTriggerReport() NxScene.getUserTriggerReport() NxShapeFlag NxShape.setFlag() +*/ +class NxUserTriggerReport + { + public: + /** + \brief Called when a trigger shape reports a trigger event. + + \note SDK state should not be modified from within onTrigger(). In particular objects should not + be created or destroyed. If state modification is needed then the changes should be stored to a buffer + and performed after the simulation step. + + \param[in] triggerShape is the shape that has been marked as a trigger. + \param[in] otherShape is the shape causing the trigger event. + \param[in] status is the type of trigger event. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxTriggerFlag + */ + virtual void onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status) = 0; + + protected: + virtual ~NxUserTriggerReport(){}; + }; + +/** +\brief An interface class that the user can implement in order to modify contact constraints. + +Threading: It is necessary to make this class thread safe as it will be called in the context of the +simulation thread. It might also be necessary to make it reentrant, since some calls can be made by multi-threaded +parts of the physics engine. + +You can enable the use of this contact modification callback in two ways: +1. Raise the flag NX_AF_CONTACT_MODIFICATION on a per-actor basis. +or +2. Set the flag NX_NOTIFY_CONTACT_MODIFICATION on a per-actor-pair basis. + +Please note: ++ It is possible to raise the contact modification flags at any time. But the calls will not wake the actors up. ++ It is not possible to turn off the performance degradation by simply removing the callback from the scene, all flags need to be removed as well. ++ The contacts will only be reported as long as the actors are awake. There will be no callbacks while the actors are sleeping. + +@see NxScene.setUserContactModify() NxScene.getUserContactModify() +*/ +class NxUserContactModify +{ +public: + //enum to identify what changes have been made + /** + \brief This enum is used for marking changes made to contact constraints in the NxUserContactModify callback. OR the values together when making multiple changes on the same contact. + */ + enum NxContactConstraintChange { + NX_CCC_NONE = 0, //!< No changes made + + NX_CCC_MINIMPULSE = (1<<0), //!< Min impulse value changed + NX_CCC_MAXIMPULSE = (1<<1), //!< Max impulse value changed + NX_CCC_ERROR = (1<<2), //!< Error vector changed + NX_CCC_TARGET = (1<<3), //!< Target vector changed + + NX_CCC_LOCALPOSITION0 = (1<<4), //!< Local attachment position in shape 0 changed + NX_CCC_LOCALPOSITION1 = (1<<5), //!< Local attachment position in shape 1 changed + NX_CCC_LOCALORIENTATION0 = (1<<6), //!< Local orientation (normal, friction direction) in shape 0 changed + NX_CCC_LOCALORIENTATION1 = (1<<7), //!< Local orientation (normal, friction direction) in shape 1 changed + + NX_CCC_STATICFRICTION0 = (1<<8), //!< Static friction parameter 0 changed. (Note: 0 does not have anything to do with shape 0/1) + NX_CCC_STATICFRICTION1 = (1<<9), //!< Static friction parameter 1 changed. (Note: 1 does not have anything to do with shape 0/1) + NX_CCC_DYNAMICFRICTION0 = (1<<10), //!< Dynamic friction parameter 0 changed. (Note: 0 does not have anything to do with shape 0/1) + NX_CCC_DYNAMICFRICTION1 = (1<<11), //!< Dynamic friction parameter 1 changed. (Note: 1 does not have anything to do with shape 0/1) + NX_CCC_RESTITUTION = (1<<12), //!< Restitution value changed. + + NX_CCC_FORCE32 = (1<<31) //!< Not a valid flag value, used by the enum to force the size to 32 bits. + }; + + //The data that can be changed by the callback + struct NxContactCallbackData { + NxReal minImpulse; //!< Minimum impulse value that the solver can apply. Normally this should be 0, negative amount gives sticky contacts. + NxReal maxImpulse; //!< Maximum impulse value that the solver can apply. Normally this is FLT_MAX. If you set this to 0 (and the min impulse value is 0) then you will void contact effects of the constraint. + NxVec3 error; //!< Error vector. This is the current error that the solver should try to relax. + NxVec3 target; //!< Target velocity. This is the relative target velocity of the two bodies. + + /** + \brief Constraint attachment point for shape 0. + + If the shape belongs to a dynamic actor, then localpos0 is relative to the body frame of the actor. + Alternatively it is relative to the world frame for a static actor. + */ + NxVec3 localpos0; + + /** + \brief Constraint attachment point for shape 1. + + If the shape belongs to a dynamic actor, then localpos1 is relative to the body frame of the actor. + Alternatively it is relative to the world frame for a static actor. + */ + NxVec3 localpos1; + + /** + \brief Constraint orientation quaternion for shape 0 relative to shape 0s body frame for dynamic + actors and relative to the world frame for static actors. + + The constraint axis (normal) is along the x-axis of the quaternion. + The Y axis is the primary friction axis and the Z axis the secondary friction axis. + */ + NxQuat localorientation0; + + /** + \brief Constraint orientation quaternion for shape 1 relative to shape 1s body frame for dynamic + actors and relative to the world frame for static actors. + + The constraint axis (normal) is along the x-axis of the quaternion. + The Y axis is the primary friction axis and the Z axis the secondary friction axis. + */ + NxQuat localorientation1; + + /** + \brief Static friction parameter 0. + + \note 0 does not have anything to do with shape 0/1, but is related to anisotropic friction, + 0 is the primary friction axis. + */ + NxReal staticFriction0; + + /** + \brief Static friction parameter 1. + + \note 1 does not have anything to do with shape 0/1, but is related to anisotropic friction, + 0 is the primary friction axis. + */ + NxReal staticFriction1; + + /** + \brief Dynamic friction parameter 0. + + \note 0 does not have anything to do with shape 0/1, but is related to anisotropic friction, + 0 is the primary friction axis. + */ + NxReal dynamicFriction0; + + /** + \brief Dynamic friction parameter 1. + + \note 1 does not have anything to do with shape 0/1, but is related to anisotropic friction, + 0 is the primary friction axis. + */ + NxReal dynamicFriction1; + NxReal restitution; //!< Restitution value. + }; + + /** + \brief This is called when a contact constraint is generated. Modify the parameters in order to affect the generated contact constraint. + This callback needs to be both thread safe and reentrant. + + \param changeFlags when making changes to the contact point, you must mark in this flag what changes have been made, see NxContactConstraintChange. + \param shape0 one of the two shapes in contact + \param shape1 the other shape + \param featureIndex0 feature on the first shape, which is in contact with the other shape + \param featureIndex1 feature on the second shape, which is in contact with the other shape + \param data contact constraint properties, for the user to change. Changes in this also requires changes in the changeFlags parameter. + + \return true if the contact point should be kept, false if it should be discarded. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool onContactConstraint( + NxU32& changeFlags, + const NxShape* shape0, + const NxShape* shape1, + const NxU32 featureIndex0, + const NxU32 featureIndex1, + NxContactCallbackData& data) = 0; + +protected: + virtual ~NxUserContactModify(){}; +}; + +/** +\brief An interface class that the user can implement in order to modify the contact point on which the +WheelShape base its simulation constraints. + +Threading: It is necessary to make this class thread safe as it will be called in the context of the +simulation thread. It might also be necessary to make it reentrant, since some calls can be made by multi-threaded +parts of the physics engine. + +You enable the use of this callback by specifying a callback function in NxWheelShapeDesc.wheelContactModify +or by setting a callback function through NxWheelShape.setUserWheelContactModify(). + +Please note: ++ There will only be callbacks if the WheelShape finds a contact point. Increasing the suspensionTravel value +gives a longer raycast and increases the chance of finding a contact point (but also gives a potentially slower +simulation). + +@see NxWheelShapeDesc.wheelContactModify NxWheelShape.setUserWheelContactModify() NxWheelShape.getUserWheelContactModify() +*/ +class NxUserWheelContactModify { +public: + + /** + \brief This callback is called once for each wheel and sub step before the wheel constraints are setup + and fed to the SDK. The values passed in the parameters can be adjusted to affect the vehicle simulation. + The most interesting values are contactPosition, contactPoint, and contactNormal. The contactPosition value + specifies how far on the travel distance the contactPoint was found. If you want to simulate a bumpy road, + then this is the main parameter to change. It is also good to adjust the contactPoint variable, so that the + wheel forces are applied in the correct position. + + \param wheelShape The WheelShape that is being processed. + \param contactPoint The contact point (in world coordinates) that is being used for the wheel. + \param contactNormal The normal of the geometry at the contact point. + \param contactPosition The distance on the spring travel distance where the wheel would end up if it was resting on the contact point. + \param normalForce The normal force on the wheel from the last simulation step. + \param otherShape The shape with which the wheel is in contact. + \param otherShapeMaterialIndex The material on the other shape in the position where the wheel is in contact. Currently has no effect on the simulation. + \param otherShapeFeatureIndex The feature on the other shape in the position where the wheel is in contact. + + \return Return true to keep the contact (with the possibly edited values) or false to drop the contact. + */ + virtual bool onWheelContact(NxWheelShape* wheelShape, NxVec3& contactPoint, NxVec3& contactNormal, NxReal& contactPosition, NxReal& normalForce, NxShape* otherShape, NxMaterialIndex& otherShapeMaterialIndex, NxU32 otherShapeFeatureIndex) = 0; + +protected: + virtual ~NxUserWheelContactModify() {} +}; + + +/** +\brief An actor pair used by filtering. +*/ +class NxActorPairFilter + { + public: + NxActor* actor[2]; //!< Pair of actors that are candidates for contact generation + bool filtered; //!< Set to true in order to filter out this pair from contact generation + }; + +/** +\brief An interface class that the user can implement in order to apply custom contact filtering. +*/ +class NxUserActorPairFiltering + { + public: + /** + \brief Callback to allow the user to decide whether to filter a certain actor pair. + + Use the actor member of the NxActorPairFilter objects to decide whether to filter out the contact + between the pair. Set the filtered member to true to apply filtering. + + \param filterArray An array of actor pairs for which filtering is to be decided. + \param arraySize The number of elements in filterArray. + + @see NxActorPairFilter NxActor::resetUserActorPairFiltering NxScene::setUserActorPairFiltering + */ + virtual void onActorPairs(NxActorPairFilter* filterArray, NxU32 arraySize) = 0; + + protected: + virtual ~NxUserActorPairFiltering() {} + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserEntityReport.h b/libraries/external/physx/Win32/include/PX/NxUserEntityReport.h new file mode 100755 index 0000000..e5b3ceb --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserEntityReport.h @@ -0,0 +1,133 @@ +#ifndef NX_PHYSICS_NXUSERENTITYREPORT +#define NX_PHYSICS_NXUSERENTITYREPORT +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +/** + \brief The user needs to pass an instance of this class to several of the scene collision + routines in NxScene. + + There are usually two ways to report a variable set of entities + to the user: using a dynamic array (e.g. an STL vector) or using a callback (called + for each entity). The first way is fast, but can lead to dynamic allocations and/or + wasted memory when it would just be possible to handle each entity on-the-fly. The + second way provides this, but suffers from call overhead. This class combines best + of both worlds by reporting a small number of entities to the user at the same time, + via a callback (the onEvent function). This number of entities is user-defined, hence + it is possible to fallback to the usual array or callback behaviours by adjusting it. + (Please refer to the comments below for details). + + Returning true lets the SDK continue the collision query, returning false stops it. + + NxUserEntityReport usage: + + A typical collision function will look like this: + + NxU32 someCollisionFunc(NxU32 nbEntities, const Entity** entities, NxUserEntityReport* callback); + + You have multiple ways to use this: + + 1) Using a fixed-size array in your app. This can happen for example when you query + some entities, and you already have a buffer big enough to handle all of them. In + that case you don't have to worry about dynamic allocations or callbacks, just do: + + // maxEntities = size of entity buffer + // entityBuffer = a buffer large enough to contain all entities + NxU32 nbEntities = someCollisionFunc(maxEntities, entityBuffer, NULL); + + If the buffer is not large enough, the SDK will keep writing entities to the buffer + until it is full, and then return. You might miss some entities in this case. + + 2) Using a callback. This is the default way to use NxUserEntityReport. + + // First define your callback object + + class UserEntityReport : public NxUserEntityReport + { + public: + + virtual bool onEvent(NxU32 nbEntities, Entity** entities); + }; + + UserEntityReport myReport; + + // Then later, do the collision calls + + NxU32 nbEntities = someCollisionFunc(0, NULL, &myReport); + + In this case, the SDK will report a limited set of entities at the same time + (usually 64), through the onEvent() function. The memory used to store + those entities is internally allocated on the stack. + + 3) Using a callback and your own memory buffers. this is the same as the previous + version, except you can customize the query by specifying both a memory buffer + and a callback: + + NxU32 nbEntities = someCollisionFunc(maxEntities, myBuffer, &myReport); + + In this case, entities are reported through the onEvent() function as in case 2), + but those differences apply: + + - the number of entities reported at the same time ("nbEntities" parameter in + onEvent) is lesser or equal to "maxEntities". + + - the memory used to store the entities ("entities" parameter in onEvent) is the + same as the user's input buffer ("myBuffer"). + + This 3rd way to use NxUserEntityReport is only provided in sake of flexibility, + but should not be needed in most cases. + + Threading: It is not necessary to make this class thread safe as it will only be called in the context of the + user thread. + +*/ + +template +class NxUserEntityReport + { + public: + + /** + \brief This is called to report a number of entities to the user. + + 'nbEntities' is the number of returned entities, which are stored in the + 'entities' memory buffer. + + After processing the entities in your application, return true to continue + the query (in which case onEvent might get called again), or false to end it. + + \note SDK state should not be modified from within onEvent(). In particular objects should not + be created or destroyed. If state modification is needed then the changes should be stored to a buffer + and performed after the query. + + \param[in] nbEntities The number of returned entities, which are stored in the 'entities' memory buffer. + \param[in] entities Array of entities. + \return true to continue processing, false to end processing. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool onEvent(NxU32 nbEntities, T* entities) = 0; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserNotify.h b/libraries/external/physx/Win32/include/PX/NxUserNotify.h new file mode 100755 index 0000000..00951d2 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserNotify.h @@ -0,0 +1,108 @@ +#ifndef NX_PHYSICS_NXUSERNOTIFY +#define NX_PHYSICS_NXUSERNOTIFY +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" + +class NxActor; +class NxJoint; + +/** + \brief An interface class that the user can implement in order to receive simulation events. + + Threading: It is not necessary to make this class thread safe as it will only be called in the context of the + user thread. + +

Example

+ + \include NxUserNotify_Example.cpp + + @see NxScene.setUserNotify() NxScene.getUserNotify() +*/ +class NxUserNotify + { + public: + /** + \brief This is called when a breakable joint breaks. + + The user should not release the joint inside this call! + Instead, if the user would like to have the joint + released and no longer holds any referenced to it, he should return true. + In this case the joint will be released by the system. Otherwise the user should return false, and + release the joint manually to free the resources associated with it (otherwise it will be released + with the scene). + + \note SDK state should not be modified from within onJointBreak(). In particular objects should not + be created or destroyed. If state modification is needed then the changes should be stored to a buffer + and performed after the simulation step. + + \note The behavior of this callback changed in version 2.5. The breakingForce parameter now supplies the + impulse applied, clamped to the maximum break impulse. + + \param[in] breakingImpulse The impulse which caused the joint to break. + \param[in] brokenJoint The joint which has been broken. + \return True to have the system release the joint now. False to keep the joint. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint.setBreakable() NxJointDesc.maxForce NxJointDesc.maxTorque + */ + virtual bool onJointBreak(NxReal breakingImpulse, NxJoint& brokenJoint) = 0; + + /** + \brief This is called during NxScene::fetchResults with the actors which have just been woken up. + + \param[in] actors - The actors which just woke up. + \param[in] count - The number of actors + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.setUserNotify() NxSceneDesc.userNotify + */ + virtual void onWake(NxActor** actors, NxU32 count) = 0; + + /** + \brief This is called during NxScene::fetchResults with the actors which have just been put to sleep. + + \param[in] actors - The actors which have just been put to sleep. + \param[in] count - The number of actors + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene.setUserNotify() NxSceneDesc.userNotify + */ + virtual void onSleep(NxActor** actors, NxU32 count) = 0; + + protected: + virtual ~NxUserNotify(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserOutputStream.h b/libraries/external/physx/Win32/include/PX/NxUserOutputStream.h new file mode 100755 index 0000000..174b2f6 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserOutputStream.h @@ -0,0 +1,70 @@ +#ifndef NX_FOUNDATION_NXUSEROUTPUTSTREAM +#define NX_FOUNDATION_NXUSEROUTPUTSTREAM +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nx.h" + +enum NxAssertResponse + { + NX_AR_CONTINUE, //!continue execution + NX_AR_IGNORE, //!continue and don't report this assert from now on + NX_AR_BREAKPOINT //!trigger a breakpoint + }; + +/** + \brief User defined interface class. Used by the library to emit debug information. + + \note The SDK state should not be modified from within any error reporting functions. + + Threading: It is not necessary to make this class thread safe as it will only be called in the context of the + user thread. +*/ +class NxUserOutputStream + { + public: + + /** + \brief Reports an error code. + + \param code Error code, see #NxErrorCode + \param message Message to display. + \param file File error occured in. + \param line Line number error occured on. + */ + virtual void reportError(NxErrorCode code, const char * message, const char *file, int line) = 0; + /** + \brief Reports an assertion violation. The user should return + + \param message Message to display. + \param file File error occured in. + \param line Line number error occured on. + */ + virtual NxAssertResponse reportAssertViolation(const char * message, const char *file, int line) = 0; + /** + \brief Simply prints some debug text + + \param message Message to display. + */ + virtual void print(const char * message) = 0; + + protected: + virtual ~NxUserOutputStream(){}; + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUserRaycastReport.h b/libraries/external/physx/Win32/include/PX/NxUserRaycastReport.h new file mode 100755 index 0000000..33fbc35 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUserRaycastReport.h @@ -0,0 +1,204 @@ +#ifndef NX_PHYSICS_NXRAYCAST +#define NX_PHYSICS_NXRAYCAST +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** \addtogroup physics + @{ +*/ + +#include "PX/Nxp.h" +class NxShape; + + +/** +Used to specify which types(static or dynamic) of shape to test against when used with raycasting and +overlap test methods in #NxScene. + +@see NxScene NxScene.raycastAllBounds() NxScene.raycastAllShapes() NxScene.raycastClosestBounds() +NxScene.raycastClosestShape() NxScene.raycastAnyBounds() NxScene.raycastAnyShape() NxScene.overlapSphereShapes() +NxScene.overlapAABBShapes() +*/ +enum NxShapesType + { + NX_STATIC_SHAPES = (1<<0), //!< Hits static shapes + NX_DYNAMIC_SHAPES = (1<<1), //!< Hits dynamic shapes + NX_ALL_SHAPES = NX_STATIC_SHAPES|NX_DYNAMIC_SHAPES //!< Hits both static & dynamic shapes + }; + +/** + +Specifies which members of #NxRaycastHit which should be generated(when used as hint flags for raycasting methods) +or which members have been generated when checking the flags member of #NxRaycastHit. + +@see NxRaycastHit +*/ +enum NxRaycastBit + { + NX_RAYCAST_SHAPE = (1<<0), //!< "shape" member of #NxRaycastHit is valid + NX_RAYCAST_IMPACT = (1<<1), //!< "worldImpact" member of #NxRaycastHit is valid + NX_RAYCAST_NORMAL = (1<<2), //!< "worldNormal" member of #NxRaycastHit is valid + NX_RAYCAST_FACE_INDEX = (1<<3), //!< "faceID" member of #NxRaycastHit is valid + NX_RAYCAST_DISTANCE = (1<<4), //!< "distance" member of #NxRaycastHit is valid + NX_RAYCAST_UV = (1<<5), //!< "u" and "v" members of #NxRaycastHit are valid + NX_RAYCAST_FACE_NORMAL = (1<<6), //!< Same as NX_RAYCAST_NORMAL but computes a non-smoothed normal + NX_RAYCAST_MATERIAL = (1<<7), //!< "material" member of #NxRaycastHit is valid + }; + +/** +\brief This structure captures results for a single raycast query. + +All members of the NxRaycastHit structure are not always available. For example when the ray hits a sphere, +the faceID member is not computed. Also, when raycasting against bounds (AABBs) instead of actual shapes, +some members are not available either. + +Some members like barycentric coordinates are currently only computed for triangle meshes and convexes, but next versions +might provide them in other cases. The client code should check #flags to make sure returned values are +relevant. + +When used as hint flags in raycasting queries, those bits control what the user would like to see computed +in the NxRaycastHit structure. For example, you might tell the SDK to compute impact normals using the +NX_RAYCAST_NORMAL hint flag. It's usually faster to let the SDK do it, instead of fetching relevant data +again in the client app. However all users may not need this information. In this case, just omit this flag +and corresponding member of ::NxRaycastHit will not be computed internally - saving processing time. + +Note that NX_RAYCAST_NORMAL computes a smoothed normal, while NX_RAYCAST_FACE_NORMAL only returns the usual +normal of a triangle (i.e. the normalized cross product of two edges). + +See #NxScene and #NxShape for raycasting methods. + + Threading: It is not necessary to make this class thread safe as it will only be called in the context of the + user thread. + + +@see NxScene.raycastAllBounds +@see NxScene.raycastAllShapes +@see NxScene.raycastClosestBounds +@see NxScene.raycastClosestShape +*/ +struct NxRaycastHit + { + /** + Touched shape (associated flags: NX_RAYCAST_SHAPE) + + @see flags + */ + NxShape* shape; + + /** + Impact point in world space (associated flags: NX_RAYCAST_IMPACT) + + @see flags + */ + NxVec3 worldImpact; + + /** + Impact normal in world space (associated flags: NX_RAYCAST_NORMAL / NX_RAYCAST_FACE_NORMAL) + + For #NxConvexShape and #NxTriangleMeshShape NX_RAYCAST_NORMAL generates a smooth normal. If a true + face normal is required use NX_RAYCAST_FACE_NORMAL instead when specifying hint flags to a raycast method. + + @see flags + */ + NxVec3 worldNormal; + + /** + Index of touched face (associated flags: NX_RAYCAST_FACE_INDEX) + + The face index is for the mesh before cooking. During the cooking process faces are moved + around which changes there index. However the SDK stores a table which is used to map the index to the original + mesh before it is returned for a raycast hit. + + @see flags + */ + NxU32 faceID; + NxTriangleID internalFaceID; + + /** + Distance from ray start to impact point (associated flags: NX_RAYCAST_DISTANCE) + + @see flags + */ + NxReal distance; + + /** + Impact barycentric coordinates (associated flags: NX_RAYCAST_UV) + + @see flags + */ + NxReal u,v; + + /** + Index of touched material (associated flags: NX_RAYCAST_MATERIAL) + + @see flags + */ + NxMaterialIndex materialIndex; + + /** + Combination of ::NxRaycastBit, when a corresponding flag is set, then the member is valid. + + ::NxRaycastBit flags can be passed to raycasting functions, as an optimization, to cause the SDK to + only generate specific members of this structure. + */ + NxU32 flags; + }; + +/** +\brief The user needs to pass an instance of this class to several of the ray casting routines in +NxScene. + +Its onHit method will be called for each shape that the ray intersects. + +Example: + +\include NxUserRaycastReport_Usage.cpp + +@see NxScene.raycastAllBounds +@see NxScene.raycastAllShapes +*/ +class NxUserRaycastReport + { + public: + /** + \brief This method is called for each shape hit by the raycast. + + If onHit returns true, it may be called again with the next shape that was stabbed. + If it returns false, no further shapes are returned, and the raycast is concluded. + + \note SDK state should not be modified from within onHit(). In particular objects should not + be created or destroyed. If state modification is needed then the changes should be stored to a buffer + and performed after the raycast. + + \param[in] hits The data corresponding to the ray intersection. See #NxRaycastHit. + \return True to continue the raycast. False to abort. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + }{ + + @see NxScene.raycastAllBounds + @see NxScene.raycastAllShapes + */ + virtual bool onHit(const NxRaycastHit& hits) = 0; + + protected: + virtual ~NxUserRaycastReport(){}; + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUtilLib.h b/libraries/external/physx/Win32/include/PX/NxUtilLib.h new file mode 100755 index 0000000..dd731da --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUtilLib.h @@ -0,0 +1,1492 @@ +#ifndef NX_UTIL_LIB +#define NX_UTIL_LIB +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/NxFoundation.h" +#include "PX/Nxp.h" +class NxJointDesc; +class NxTriangle; + +// For NxSweepBoxTriangles and NxSweepCapsuleTriangles +enum NxTriangleCollisionFlag + { + // Must be the 3 first ones to be indexed by (flags & (1<Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox + */ + virtual bool NxBoxContainsPoint(const NxBox& box, const NxVec3& p)=0; + + /** + + \brief Create an oriented box from an axis aligned box and a transformation. + + \param[out] box Used to store the oriented box. + \param[in] aabb Axis aligned box. + \param[in] mat Transformation to apply to the axis aligned box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox NxBounds3 + */ + virtual void NxCreateBox(NxBox& box, const NxBounds3& aabb, const NxMat34& mat)=0; + + /** + + \brief Computes plane equation for each face of an oriented box. + + \param[in] box The oriented box. + \param[out] planes Array to receive the computed planes (should be large enough to hold 6 planes) + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox NxPlane + */ + virtual bool NxComputeBoxPlanes(const NxBox& box, NxPlane* planes)=0; + + /** + + \brief Compute the corner points of an oriented box. + + \param[in] box The oriented box. + \param[out] pts Array to receive the box point (should be large enough to hold 8 points) + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox + */ + virtual bool NxComputeBoxPoints(const NxBox& box, NxVec3* pts)=0; + + /** + + \brief Compute the vertex normals of an oriented box. These are smooth normals, i.e. averaged from the faces of the box. + + \param[in] box The oriented box. + \param[out] pts The normals for each vertex(should be large enough to hold 8 normals). + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox + */ + virtual bool NxComputeBoxVertexNormals(const NxBox& box, NxVec3* pts)=0; + + /** + \brief Return a list of edge indices. + + \return List of edge indices. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxComputeBoxPoints + */ + virtual const NxU32* NxGetBoxEdges()=0; + + /** + \brief Return a list of box edge axes. + + \return List of box edge axes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxComputeBoxPoints + */ + virtual const NxI32* NxGetBoxEdgesAxes()=0; + + /** + \brief Return a set of triangle indices suitable for use with #NxComputeBoxPoints. + + \return List of box triangles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxComputeBoxPoints + */ + virtual const NxU32* NxGetBoxTriangles()=0; + + /** + \brief Returns a list of local space edge normals. + + \return List of edge normals. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual const NxVec3* NxGetBoxLocalEdgeNormals()=0; + + /** + \brief Compute and edge normals for an oriented box. + + This is an averaged normal, from the two faces sharing the edge. + + The edge index should be from 0 to 11 (i.e. a box has 12 edges). + + Edge ordering: + + \image html boxEdgeDiagram.png + + \param[in] box The oriented box. + \param[in] edge_index The index of the edge to compute a normal for. + \param[out] world_normal The computed normal. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxComputeBoxWorldEdgeNormal(const NxBox& box, NxU32 edge_index, NxVec3& world_normal)=0; + + /** + + \brief Compute a capsule which encloses a box. + + \param box Box to generate capsule for. + \param capsule Stores the capsule which is generated. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox NxCapsule NxComputeBoxAroundCapsule + */ + virtual void NxComputeCapsuleAroundBox(const NxBox& box, NxCapsule& capsule)=0; + + /** + \brief Test if box A is inside another box B. + + \param a Box A + \param b Box B + + \return True if box A is inside box B. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBox + */ + virtual bool NxIsBoxAInsideBoxB(const NxBox& a, const NxBox& b)=0; + + /** + \brief Get a list of indices representing the box as quads. + + \return List of quad indices. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxComputeBoxPoints() + */ + virtual const NxU32* NxGetBoxQuads()=0; + + /** + \brief Returns a list of quad indices sharing the vertex index. + + \param vertexIndex Vertex Index. + \return List of quad indices sharing the vertex index. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxComputeBoxPoints() NxGetBoxQuads() + */ + virtual const NxU32* NxBoxVertexToQuad(NxU32 vertexIndex)=0; + + /** + \brief Compute a box which encloses a capsule. + + \param capsule Capsule to generate an enclosing box for. + \param box Generated box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxComputeCapsuleAroundBox + */ + virtual void NxComputeBoxAroundCapsule(const NxCapsule& capsule, NxBox& box)=0; + + /** + \brief Set FPU precision. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPUPrecision24()=0; + + /** + \brief Set FPU precision. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPUPrecision53()=0; + + /** + \brief Set FPU precision + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPUPrecision64()=0; + + /** + \brief Set FPU precision. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPURoundingChop()=0; + + /** + \brief Set FPU rounding mode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPURoundingUp()=0; + + /** + \brief Set FPU rounding mode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPURoundingDown()=0; + + /** + \brief Set FPU rounding mode. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPURoundingNear()=0; + + /** + \brief Enable/Disable FPU exception. + + \param b True to enable exception. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxSetFPUExceptions(bool b)=0; + + /** + \brief Convert a floating point number to an integer. + + \param f Floating point number. + + \return The result. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual int NxIntChop(const NxF32& f)=0; + + /** + \brief Convert a floating point number to an integer. + + \param f Floating point number. + + \return The result. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual int NxIntFloor(const NxF32& f)=0; + + /** + \brief Convert a floating point number to an integer. + + \param f Floating point number. + + \return The result. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual int NxIntCeil(const NxF32& f)=0; + + /** + \brief Compute the distance squared from a point to a ray. + + \param ray The ray. + \param point The point. + \param t Used to retrieve the closest parameter value on the ray. + + \return The squared distance. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxRay + */ + virtual NxF32 NxComputeDistanceSquared(const NxRay& ray, const NxVec3& point, NxF32* t)=0; + + /** + \brief Compute the distance squared from a point to a line segment. + + \param seg The line segment. + \param point The point. + \param t Used to retrieve the closest parameter value on the line segment. + + \return The squared distance. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSegment + */ + virtual NxF32 NxComputeSquareDistance(const NxSegment& seg, const NxVec3& point, NxF32* t)=0; + + /** + \brief Compute a bounding sphere for a point cloud. + + \param sphere The computed sphere. + \param nb_verts Number of points. + \param verts Array of points. + + \return The method used to compute the sphere, see #NxBSphereMethod. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere NxFastComputeSphere + */ + virtual NxBSphereMethod NxComputeSphere(NxSphere& sphere, unsigned nb_verts, const NxVec3* verts)=0; + /** + \brief Compute a bounding sphere for a point cloud. + + The sphere may not be as tight as #NxComputeSphere + + \param sphere The computed sphere. + \param nb_verts Number of points. + \param verts Array of points. + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere NxComputeSphere + */ + virtual bool NxFastComputeSphere(NxSphere& sphere, unsigned nb_verts, const NxVec3* verts)=0; + + /** + \brief Compute an overall bounding sphere for a pair of spheres. + + \param merged The computed sphere. + \param sphere0 First sphere. + \param sphere1 Second sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere NxComputeSphere + */ + virtual void NxMergeSpheres(NxSphere& merged, const NxSphere& sphere0, const NxSphere& sphere1)=0; + + /** + \brief Get the tangent vectors associated with a normal. + + \param n Normal vector + \param t1 First tangent + \param t2 Second tangent + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxNormalToTangents(const NxVec3 & n, NxVec3 & t1, NxVec3 & t2)=0; + + /** + \brief Rotates a 3x3 symmetric inertia tensor I into a space R where it can be represented with the diagonal matrix D. + + I = R * D * R' + + Returns false on failure. + + \param denseInertia The dense inertia tensor. + \param diagonalInertia The diagonalized inertia tensor. + \param rotation Rotation for the frame of the diagonalized inertia tensor. + + \return True if the inertia tensor can be diagonalized. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + + virtual bool NxDiagonalizeInertiaTensor(const NxMat33 & denseInertia, NxVec3 & diagonalInertia, NxMat33 & rotation)=0; + + /** + \brief Computes a rotation matrix. + + computes rotation matrix M so that: + + M * x = b + + x and b are unit vectors. + + \param x Vector. + \param b Vector. + \param M Computed rotation matrix. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxFindRotationMatrix(const NxVec3 & x, const NxVec3 & b, NxMat33 & M)=0; + + /** + \brief Computes bounds of an array of vertices + + \param min Computed minimum of the bounds. + \param max Maximum + \param nbVerts Number of input vertices. + \param verts Array of vertices. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 + */ + virtual void NxComputeBounds(NxVec3& min, NxVec3& max, NxU32 nbVerts, const NxVec3* verts)=0; + + + /** + \brief Computes CRC of input buffer + + \param buffer Input buffer. + \param nbBytes Number of bytes in in the input buffer. + \return The computed CRC. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 NxCrc32(const void* buffer, NxU32 nbBytes)=0; +/* +** From NxInertiaTensor.h +*/ +/***************************************************************************/ + /** + \brief Computes mass of a homogeneous sphere according to sphere density. + + \param[in] radius Radius of the sphere. Range: (0,inf) + \param[in] density Density of the sphere. Range: (0,inf) + + \return The mass of the sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeSphereMass (NxReal radius, NxReal density)=0; + + /** + \brief Computes density of a homogeneous sphere according to sphere mass. + + \param[in] radius Radius of the sphere. Range: (0,inf) + \param[in] mass Mass of the sphere. Range: (0,inf) + + \return The density of the sphere. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeSphereDensity (NxReal radius, NxReal mass)=0; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous box according to box density. + + \param[in] extents The extents/radii, that is the full side length along each axis, of the box. Range: direction vector + \param[in] density The density of the box. Range: (0,inf) + + \return The mass of the box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeBoxMass (const NxVec3& extents, NxReal density)=0; + + /** + \brief Computes density of a homogeneous box according to box mass. + + \param[in] extents The extents/radii, that is the full side length along each axis, of the box. Range: direction vector + \param[in] mass The mass of the box. Range: (0,inf) + + \return The density of the box. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeBoxDensity (const NxVec3& extents, NxReal mass)=0; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous ellipsoid according to ellipsoid density. + + \param[in] extents The extents/radii of the ellipsoid. Range: direction vector + \param[in] density The density of the ellipsoid. Range: (0,inf) + + \return The mass of the ellipsoid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeEllipsoidMass (const NxVec3& extents, NxReal density)=0; + + /** + \brief Computes density of a homogeneous ellipsoid according to ellipsoid mass. + + \param[in] extents The extents/radii of the ellipsoid. Range: direction vector + \param[in] mass The mass of the ellipsoid. Range: (0,inf) + + \return The density of the ellipsoid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeEllipsoidDensity (const NxVec3& extents, NxReal mass)=0; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous cylinder according to cylinder density. + + \param[in] radius The radius of the cylinder. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] density The density. Range: (0,inf) + + \return The mass. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeCylinderMass (NxReal radius, NxReal length, NxReal density)=0; + + /** + \brief Computes density of a homogeneous cylinder according to cylinder mass. + + \param[in] radius The radius of the cylinder. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] mass The mass. Range: (0,inf) + + \return The density. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeCylinderDensity (NxReal radius, NxReal length, NxReal mass)=0; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes mass of a homogeneous cone according to cone density. + + \param[in] radius The radius of the cone. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] density The density. Range: (0,inf) + + \return The mass. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeConeMass (NxReal radius, NxReal length, NxReal density)=0; + + /** + \brief Computes density of a homogeneous cone according to cone mass. + + \param[in] radius The radius of the cone. Range: (0,inf) + \param[in] length The length. Range: (0,inf) + \param[in] mass The mass. Range: (0,inf) + + \return The density. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal NxComputeConeDensity (NxReal radius, NxReal length, NxReal mass)=0; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + \brief Computes diagonalized inertia tensor for a box. + + \param[out] diagInertia The diagonalized inertia tensor. + \param[in] mass The mass of the box. Range: (0,inf) + \param[in] xlength The width of the box. Range: (-inf,inf) + \param[in] ylength The height. Range: (-inf,inf) + \param[in] zlength The depth. Range: (-inf,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxComputeBoxInertiaTensor (NxVec3& diagInertia, NxReal mass, NxReal xlength, NxReal ylength, NxReal zlength)=0; + + /** + \brief Computes diagonalized inertia tensor for a sphere. + + \param[out] diagInertia The diagonalized inertia tensor. + \param[in] mass The mass. Range: (0,inf) + \param[in] radius The radius. Range: (-inf,inf) + \param[in] hollow True to treat the sphere as a hollow shell. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void NxComputeSphereInertiaTensor(NxVec3& diagInertia, NxReal mass, NxReal radius, bool hollow)=0; + +/* +** From NxJointDesc.h +*/ +/*************************************************************/ + /** + \brief Set the local anchor stored in a #NxJointDesc from a global anchor point. + + \param dis Joint desc to update. + \param wsAnchor Anchor point in the global frame. Range: position vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.setGlobalAnchor() + */ + virtual void NxJointDesc_SetGlobalAnchor(NxJointDesc & dis, const NxVec3 & wsAnchor)=0; + + /** + \brief Set the local axis stored in a #NxJointDesc from a global axis. + + \param dis Joint desc to update. + \param wsAxis Axis in the global frame. Range: direction vector + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.setGlobalAxis() + */ + virtual void NxJointDesc_SetGlobalAxis(NxJointDesc & dis, const NxVec3 & wsAxis)=0; + + +/* +** From NxIntersectionBoxBox.h +*/ +/******************************************************************/ + + /** + \brief Boolean intersection test between two OBBs. + + Uses the separating axis theorem. Disabling 'full_test' only performs 6 axis tests out of 15. + + \param[in] extents0 Extents/radii of first box before transformation. Range: direction vector + \param[in] center0 Center of first box. Range: position vector + \param[in] rotation0 Rotation to apply to first box (before translation). Range: rotation matrix + \param[in] extents1 Extents/radii of second box before transformation Range: direction vector + \param[in] center1 Center of second box. Range: position vector + \param[in] rotation1 Rotation to apply to second box(before translation). Range: rotation matrix + \param[in] fullTest If false test only the first 6 axis. + + \return true on intersection + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxBoxBoxIntersect( const NxVec3& extents0, const NxVec3& center0, const NxMat33& rotation0, + const NxVec3& extents1, const NxVec3& center1, const NxMat33& rotation1, + bool fullTest)=0; + + + + /* + \brief Boolean intersection test between a triangle and an AABB. + + \param[in] vertex0 First vertex of triangle. Range: position vector + \param[in] vertex1 Second Vertex of triangle. Range: position vector + \param[in] vertex2 Third Vertex of triangle. Range: position vector + \param[in] center Center of Axis Aligned bounding box. Range: position vector + \param[in] extents Extents/radii of AABB. Range: direction vector + + \return true on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxTriBoxIntersect(const NxVec3 & vertex0, const NxVec3 & vertex1, const NxVec3 & vertex2, const NxVec3 & center, const NxVec3& extents)=0; + + /** + \brief Computes the separating axis between two OBBs. + + \param[in] extents0 Extents/radii of first box before transformation. Range: direction vector + \param[in] center0 Center of box first box. Range: position vector + \param[in] rotation0 Rotation to apply to first box (before translation). Range: rotation matrix + \param[in] extents1 Extents/radii of second box before transformation. Range: direction vector + \param[in] center1 Center of second box. Range: position vector + \param[in] rotation1 Rotation to apply to second box (before translation). Range: rotation matrix + \param[in] fullTest If false test only the first 6 axis. + + \return The separating axis or NX_SEP_AXIS_OVERLAP for an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSepAxis + */ + virtual NxSepAxis NxSeparatingAxis( const NxVec3& extents0, const NxVec3& center0, const NxMat33& rotation0, + const NxVec3& extents1, const NxVec3& center1, const NxMat33& rotation1, + bool fullTest=true)=0; + + /* + ** From NxIntersectionRayPlane.h + */ +/*************************************************************************/ + + /** + \brief Segment-plane intersection test. + + Returns distance between v1 and impact point, as well as impact point on plane. + + \param[in] v1 First vertex of segment. Range: position vector + \param[in] v2 Second vertex of segment. Range: position vector + \param[in] plane Plane to test against. Range: See #NxPlane + \param[out] dist Distance from v1 to impact point (so pointOnPlane=Normalize(v2-v1)*dist). + \param[out] pointOnPlane Imapact point on plane. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSegmentPlaneIntersect(const NxVec3& v1, const NxVec3& v2, + const NxPlane& plane, NxReal& dist, NxVec3& pointOnPlane)=0; + + /** + \brief Ray-plane intersection test. + + Returns distance between ray origin and impact point, as well as impact point on plane. + + \param[in] ray Ray to test against plane. Range: See #NxRay + \param[in] plane Plane to test. Range: See #NxPlane + \param[out] dist Distance along ray to impact point (so pointOnPlane=Normalize(v2-v1)*dist). + \param[out] pointOnPlane Impact point on the plane. + + \return True on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxRayPlaneIntersect(const NxRay& ray, const NxPlane& plane, + NxReal& dist, NxVec3& pointOnPlane)=0; + +/* +** From NxIntersectionRaySphere.h +*/ +/**************************************************************************/ + + /** + \brief Ray-sphere intersection test. + + Returns true if the ray intersects the sphere, and the impact point if needed. + + \param[in] origin Origin of the ray. Range: position vector + \param[in] dir Direction of the ray. Range: direction vector + \param[in] length Length of the ray. Range: (0,inf) + \param[in] center Center of the sphere. Range: position vector + \param[in] radius Sphere radius. Range: (0,inf) + \param[out] hit_time Distance of intersection between ray and sphere. + \param[out] hit_pos Point of intersection between ray and sphere. + + \return True on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxRaySphereIntersect(const NxVec3& origin, const NxVec3& dir, NxReal length, const NxVec3& center, NxReal radius, NxReal& hit_time, NxVec3& hit_pos) = 0; + +/* +** From NxIntersectionSegmentBox +*/ +/**************************************************************************/ + + /** + \brief Segment-AABB intersection test. + + Also computes intersection point. + + \param[in] p1 First point of line segment. Range: position vector + \param[in] p2 Second point of line segment. Range: position vector + \param[in] bbox_min Minimum extent of AABB. Range: position vector + \param[in] bbox_max Max extent of AABB. Range: position vector + \param[out] intercept Intersection point between segment and box. + + \return True if the segment and AABB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSegmentBoxIntersect(const NxVec3& p1, const NxVec3& p2, + const NxVec3& bbox_min,const NxVec3& bbox_max, NxVec3& intercept)=0; + + /** + \brief Ray-AABB intersection test. + + Also computes intersection point. + + \param[in] min Minimum extent of AABB. Range: position vector + \param[in] max Maximum extent of AABB. Range: position vector + \param[in] origin Origin of ray. Range: position vector + \param[in] dir Direction of ray. Range: direction vector + \param[out] coord Intersection point. + + \return True if the ray and AABB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxRayAABBIntersect(const NxVec3& min, const NxVec3& max, + const NxVec3& origin, const NxVec3& dir, NxVec3& coord)=0; + + /** + \brief Extended Ray-AABB intersection test. + + Also computes intersection point, and parameter and returns contacted box axis index+1. Rays starting from inside the box are ignored. + + + \param[in] min Minimum extent of AABB. Range: position vector + \param[in] max Maximum extent of AABB. Range: position vector + \param[in] origin Origin of ray. Range: position vector + \param[in] dir Direction of ray. Range: direction vector + \param[out] coord Intersection point. + \param[out] t Ray parameter corresponding to contact point. + + \return Box axis index. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 NxRayAABBIntersect2(const NxVec3& min, const NxVec3& max, + const NxVec3& origin, const NxVec3& dir, NxVec3& coord, NxReal & t)=0; + + /** + \brief Boolean segment-OBB intersection test. + + Based on separating axis theorem. + + \param[in] p0 First point of line segment. Range: position vector + \param[in] p1 Second point of line segment. Range: position vector + \param[in] center Center point of OBB. Range: position vector + \param[in] extents Extent/Radii of the OBB. Range: direction vector + \param[in] rot Rotation of the OBB(applied before translation). Range: rotation matrix + + \return true if the segment and OBB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSegmentOBBIntersect(const NxVec3& p0, const NxVec3& p1, + const NxVec3& center, const NxVec3& extents, const NxMat33& rot)=0; + + /** + \brief Boolean segment-AABB intersection test. + + Based on separating axis theorem. + + \param[in] p0 First point of line segment. Range: position vector + \param[in] p1 Second point of line segment. Range: position vector + \param[in] min Minimum extent of AABB. Range: position vector + \param[in] max Maximum extent of AABB. Range: position vector + + \return True if the segment and AABB intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSegmentAABBIntersect(const NxVec3& p0, const NxVec3& p1, + const NxVec3& min, const NxVec3& max)=0; + + /** + \brief Boolean ray-OBB intersection test. + + Based on separating axis theorem. + + \param[in] ray Ray to test against OBB. Range: See #NxRay + \param[in] center Center point of OBB. Range: position vector + \param[in] extents Extent/Radii of the OBB. Range: direction vector + \param[in] rot Rotation of the OBB(applied before translation). Range: rotation matrix + + \return True on intersection. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxRayOBBIntersect(const NxRay& ray, const NxVec3& center, + const NxVec3& extents, const NxMat33& rot)=0; + +/* +** From NxIntersectionSegmentCapsule.h +*/ +/*************************************************************************/ + + /** + \brief Ray-capsule intersection test. + + Returns number of intersection points (0,1 or 2) and corresponding parameters along the ray. + + \param[in] origin Origin of ray. Range: position vector + \param[in] dir Direction of ray. Range: direction vector + \param[in] capsule Capsule to test. Range: see #NxCapsule + \param[out] t Parameter of intersection on the ray. + + The actual impact point is given by: + impact[i] = origin + t[i] * dir; + + \return Number of intersection points. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxRay NxCapsule + */ + virtual NxU32 NxRayCapsuleIntersect(const NxVec3& origin, const NxVec3& dir, + const NxCapsule& capsule, NxReal t[2])=0; + +/* +** From NxIntersectionSweptSpheres.h +*/ +/***************************************************************************/ + + /** + \brief Sphere-sphere sweep test. + + Returns true if spheres intersect during their linear motion along provided velocity vectors. + + \param[in] sphere0 First sphere to test. Range: See #NxSphere + \param[in] velocity0 Velocity of the first sphere(i.e. the vector to sweep the sphere along). Range: velocity/direction vector + \param[in] sphere1 Second sphere to test Range: See #NxSphere + \param[in] velocity1 Velocity of the second sphere(i.e. the vector to sweep the sphere along). Range: velocity/direction vector + + \return True if spheres intersect. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSphere + */ + virtual bool NxSweptSpheresIntersect( const NxSphere& sphere0, const NxVec3& velocity0, + const NxSphere& sphere1, const NxVec3& velocity1)=0; + +/* +** From NxRayTryIntersect.h +*/ + + /** + \brief Ray-triangle intersection test. + + Returns impact distance (t) as well as barycentric coordinates (u,v) of impact point. + Use NxComputeBarycentricPoint() in Foundation to compute the impact point from the barycentric coordinates. + The test performs back face culling or not according to 'cull'. + + \param[in] orig Origin of the ray. Range: position vector + \param[in] dir Direction of the ray. Range: direction vector + \param[in] vert0 First vertex of triangle. Range: position vector + \param[in] vert1 Second vertex of triangle. Range: position vector + \param[in] vert2 Third vertex of triangle. Range: position vector + \param[out] t Distance along the ray from the origin to the impact point. + \param[out] u Barycentric coordinate. + \param[out] v Barycentric coordinate. + \param[in] cull Cull backfaces. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxRayTriIntersect(const NxVec3& orig, const NxVec3& dir, const NxVec3& vert0, const NxVec3& vert1, const NxVec3& vert2, float& t, float& u, float& v, bool cull)=0; + + /***************************************************************/ +/* +** From NxBuildSmoothNormals.h +*/ + /** + \brief Builds smooth vertex normals over a mesh. + + - "smooth" because smoothing groups are not supported here + - takes angles into account for correct cube normals computation + + To use 32bit indices pass a pointer in dFaces and set wFaces to zero. Alternatively pass a pointer to + wFaces and set dFaces to zero. + + \param[in] nbTris Number of triangles + \param[in] nbVerts Number of vertices + \param[in] verts Array of vertices + \param[in] dFaces Array of dword triangle indices, or null + \param[in] wFaces Array of word triangle indices, or null + \param[out] normals Array of computed normals (assumes nbVerts vectors) + \param[in] flip Flips the normals or not + + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxBuildSmoothNormals( + NxU32 nbTris, + NxU32 nbVerts, + const NxVec3* verts, + const NxU32* dFaces, + const NxU16* wFaces, + NxVec3* normals, + bool flip=false + )=0; + + + + + /** + \brief Box-vs-capsule sweep test. + + Sweeps a box against a capsule, returns true if box hit the capsule. Also returns contact information. + + \param[in] box Box (source of the sweep) + \param[in] lss Capsule + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] min_dist Impact distance + \param[out] normal Normal at impact point + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepBoxCapsule(const NxBox& box, const NxCapsule& lss, const NxVec3& dir, float length, float& min_dist, NxVec3& normal) = 0; + + /** + \brief Box-vs-sphere sweep test. + + Sweeps a box against a sphere, returns true if box hit the sphere. Also returns contact information. + + \param[in] box Box (source of the sweep) + \param[in] sphere Sphere + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] min_dist Impact distance + \param[out] normal Normal at impact point + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepBoxSphere(const NxBox& box, const NxSphere& sphere, const NxVec3& dir, float length, float& min_dist, NxVec3& normal) = 0; + + /** + \brief Capsule-vs-capsule sweep test. + + Sweeps a capsule against a capsule, returns true if capsule hit the other capsule. Also returns contact information. + + \param[in] lss0 Capsule (source of the sweep) + \param[in] lss1 Capsule + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] min_dist Impact distance + \param[out] ip Impact point + \param[out] normal Normal at impact point + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepCapsuleCapsule(const NxCapsule& lss0, const NxCapsule& lss1, const NxVec3& dir, float length, float& min_dist, NxVec3& ip, NxVec3& normal) = 0; + + /** + \brief Sphere-vs-capsule sweep test. + + Sweeps a sphere against a capsule, returns true if sphere hit the capsule. Also returns contact information. + + \param[in] sphere Sphere (source of the sweep) + \param[in] lss Capsule + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] min_dist Impact distance + \param[out] ip Impact point + \param[out] normal Normal at impact point + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepSphereCapsule(const NxSphere& sphere, const NxCapsule& lss, const NxVec3& dir, float length, float& min_dist, NxVec3& ip, NxVec3& normal) = 0; + + /** + \brief Box-vs-box sweep test. + + Sweeps a box against a box, returns true if box hit the other box. Also returns contact information. + + \param[in] box0 Box (source of the sweep) + \param[in] box1 Box + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] ip Impact point + \param[out] normal Normal at impact point + \param[out] min_dist Impact distance + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepBoxBox(const NxBox& box0, const NxBox& box1, const NxVec3& dir, float length, NxVec3& ip, NxVec3& normal, float& min_dist) = 0; + + /** + \brief Box-vs-triangles sweep test. + + Sweeps a box against a set of triangles, returns true if box hit any triangle. Also returns contact information. + + \param[in] nb_tris Number of triangles + \param[in] triangles Array of triangles + \param[in] edge_triangles Array of edge-triangles, whose "vertices" are the edge normals + \param[in] edge_flags Array of edge flags (NxTriangleCollisionFlag) + \param[in] box Box (source of the sweep) + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] hit Impact point + \param[out] normal Normal at impact point + \param[out] d Impact distance + \param[out] index Triangle index (closest hit triangle) + \param[in/out] cachedIndex Cached triangle index for subsequent calls. Cached triangle is tested first. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepBoxTriangles(NxU32 nb_tris, const NxTriangle* triangles, const NxTriangle* edge_triangles, const NxU32* edge_flags, + const NxBounds3& box, + const NxVec3& dir, float length, + NxVec3& hit, NxVec3& normal, float& d, NxU32& index, NxU32* cachedIndex=NULL) = 0; + + /** + \brief Capsule-vs-triangles sweep test. + + Sweeps a capsule against a set of triangles, returns true if capsule hit any triangle. Also returns contact information. + + \param[in] nb_tris Number of triangles + \param[in] triangles Array of triangles + \param[in] edge_flags Array of edge flags (NxTriangleCollisionFlag) + \param[in] center Center of capsule + \param[in] radius Capsule radius + \param[in] height Capsule height + \param[in] dir Unit-length sweep direction + \param[in] length Length of sweep (i.e. total motion vectoir is dir*length) + \param[out] hit Impact point + \param[out] normal Normal at impact point + \param[out] d Impact distance + \param[out] index Triangle index (closest hit triangle) + \param[in/out] cachedIndex Cached triangle index for subsequent calls. Cached triangle is tested first. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool NxSweepCapsuleTriangles(NxU32 up_direction, + NxU32 nb_tris, const NxTriangle* triangles, const NxU32* edge_flags, + const NxVec3& center, const float radius, const float height, + const NxVec3& dir, float length, + NxVec3& hit, NxVec3& normal, float& d, NxU32& index, NxU32* cachedIndex=NULL) = 0; + + /** + \brief Point-vs-OBB distance computation. + + Returns distance between a point and an OBB. + + \param[in] point The point + \param[in] center OBB center + \param[in] extents OBB extents + \param[in] rot OBB rotation + \param[out] params Closest point on the box, in box space + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual float NxPointOBBSqrDist(const NxVec3& point, const NxVec3& center, const NxVec3& extents, const NxMat33& rot, NxVec3* params) = 0; + + /** + \brief Segment-vs-OBB distance computation. + + Returns distance between a segment and an OBB. + + \param[in] segment The segment + \param[in] c0 OBB center + \param[in] e0 OBB extents + \param[in] r0 OBB rotation + \param[out] t Parameter in [0,1] describing the closest point on the segment. + \param[out] params Closest point on the box, in box space + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual float NxSegmentOBBSqrDist(const NxSegment& segment, const NxVec3& c0, const NxVec3& e0, const NxMat33& r0, float* t, NxVec3* p) = 0; + + protected: + virtual ~NxUtilLib(){}; + }; +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxUtilities.h b/libraries/external/physx/Win32/include/PX/NxUtilities.h new file mode 100755 index 0000000..12bf807 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxUtilities.h @@ -0,0 +1,151 @@ +#ifndef NX_FOUNDATION_NXUTILITIES +#define NX_FOUNDATION_NXUTILITIES +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + +#include "PX/Nxf.h" +#include +#include "PX/NxVec3.h" +#include "PX/NxBounds3.h" + +/** + \brief Utility calls that don't fit anywhere else. + + Gathers elements seperated by stride byes into source. + + \param src Source memory block. + \param dst Destination memory block. + \param nbElem Number of elements to copy. + \param elemSize Size of each element. + \param stride Number of bytes from one element to the next. +*/ + + NX_INLINE void NxFlexiCopy(const void* src, void* dst, NxU32 nbElem, NxU32 elemSize, NxU32 stride) + { + const NxU8* s = (const NxU8*)src; + NxU8* d = (NxU8*)dst; + while(nbElem--) + { + memcpy(d, s, elemSize); + d += elemSize; + s += stride; + } + } + + /* + Find next power of 2. + + */ + NX_INLINE NxU32 NxNextPowerOfTwo(NxU32 x) + { + x |= (x >> 1); + x |= (x >> 2); + x |= (x >> 4); + x |= (x >> 8); + x |= (x >> 16); + return x+1; + } + + /** + \brief Returns the angle between two (possibly un-normalized) vectors + \param v0 First Vector. + \param v1 Second Vector. + */ + NX_INLINE NxF32 NxAngle(const NxVec3& v0, const NxVec3& v1) + { + NxF32 cos = v0|v1; // |v0|*|v1|*Cos(Angle) + NxF32 sin = (v0^v1).magnitude(); // |v0|*|v1|*Sin(Angle) + return NxMath::atan2(sin, cos); + } + + /** + \brief Make an edge longer by a factor of its length. + + \param p0 First point of edge. + \param p1 Second point of edge. + \param fatCoeff Factor by which to make fatter by. + */ + NX_INLINE void NxMakeFatEdge(NxVec3& p0, NxVec3& p1, NxF32 fatCoeff) + { + NxVec3 delta = p1 - p0; + delta.setMagnitude(fatCoeff); + p0 -= delta; + p1 += delta; + } + + /** + + \param normalCompo + \param outwardDir + \param outwardNormal + */ + + NX_INLINE void NxComputeNormalCompo(NxVec3& normalCompo, const NxVec3& outwardDir, const NxVec3& outwardNormal) + { + normalCompo = outwardNormal * (outwardDir|outwardNormal); + } + + /** + + \param outwardDir + \param outwardNormal + */ + NX_INLINE void NxComputeTangentCompo(NxVec3& outwardDir, const NxVec3& outwardNormal) + { + outwardDir -= outwardNormal * (outwardDir|outwardNormal); + } + + /** + + \param normalCompo + \param tangentCompo + \param outwardDir + \param outwardNormal + */ + NX_INLINE void NxDecomposeVector(NxVec3& normalCompo, NxVec3& tangentCompo, const NxVec3& outwardDir, const NxVec3& outwardNormal) + { + normalCompo = outwardNormal * (outwardDir|outwardNormal); + tangentCompo = outwardDir - normalCompo; + } + + /** + \brief Computes a point on a triangle using barycentric coordinates. + + It's only been extracted as a function so that there's no confusion regarding the order in + which u and v should be used. + + pt = (1 - u - v) * p0 + u * p1 + v * p2 + + \param pt Contains the computed point. + \param p0 First point of triangle. + \param p1 Second. + \param p2 Third. + \param u U parameter. + \param v V parameter. + */ + NX_INLINE void NxComputeBarycentricPoint(NxVec3& pt, const NxVec3& p0, const NxVec3& p1, const NxVec3& p2, float u, float v) + { + // This seems to confuse the compiler... +// pt = (1.0f - u - v)*p0 + u*p1 + v*p2; + NxF32 w = 1.0f - u - v; + pt.x = w*p0.x + u*p1.x + v*p2.x; + pt.y = w*p0.y + u*p1.y + v*p2.y; + pt.z = w*p0.z + u*p1.z + v*p2.z; + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxVec3.h b/libraries/external/physx/Win32/include/PX/NxVec3.h new file mode 100755 index 0000000..0b0d0b0 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxVec3.h @@ -0,0 +1,874 @@ +#ifndef NX_FOUNDATION_NXVEC3 +#define NX_FOUNDATION_NXVEC3 +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** \addtogroup foundation + @{ +*/ + + + +#include "PX/Nxf.h" +#include "PX/NxMath.h" + +class NxMat33; + + +/** +\brief Enum to classify an axis. +*/ + enum NxAxisType + { + NX_AXIS_PLUS_X, + NX_AXIS_MINUS_X, + NX_AXIS_PLUS_Y, + NX_AXIS_MINUS_Y, + NX_AXIS_PLUS_Z, + NX_AXIS_MINUS_Z, + NX_AXIS_ARBITRARY + }; + + +class NxVec3; + +/** \cond Exclude from documentation */ +typedef struct _Nx3F32 +{ + NxReal x, y, z; + + NX_INLINE const _Nx3F32& operator=(const NxVec3& d); +} Nx3F32; +/** \endcond */ + +/** +\brief 3 Element vector class. + +This is a vector class with public data members. +This is not nice but it has become such a standard that hiding the xyz data members +makes it difficult to reuse external code that assumes that these are public in the library. +The vector class can be made to use float or double precision by appropriately defining NxReal. +This has been chosen as a cleaner alternative to a template class. +*/ +class NxVec3 + { + public: + //!Constructors + + /** + \brief default constructor leaves data uninitialized. + */ + NX_INLINE NxVec3(); + + /** + \brief Assigns scalar parameter to all elements. + + Useful to initialize to zero or one. + + \param[in] a Value to assign to elements. + */ + explicit NX_INLINE NxVec3(NxReal a); + + /** + \brief Initializes from 3 scalar parameters. + + \param[in] nx Value to initialize X component. + \param[in] ny Value to initialize Y component. + \param[in] nz Value to initialize Z component. + */ + NX_INLINE NxVec3(NxReal nx, NxReal ny, NxReal nz); + + /** + \brief Initializes from Nx3F32 data type. + + \param[in] a Value to initialize with. + */ + NX_INLINE NxVec3(const Nx3F32 &a); + + /** + \brief Initializes from an array of scalar parameters. + + \param[in] v Value to initialize with. + */ + NX_INLINE NxVec3(const NxReal v[]); + + /** + \brief Copy constructor. + */ + NX_INLINE NxVec3(const NxVec3& v); + + /** + \brief Assignment operator. + */ + NX_INLINE const NxVec3& operator=(const NxVec3&); + + /** + \brief Assignment operator. + */ + NX_INLINE const NxVec3& operator=(const Nx3F32&); + + /** + \brief Access the data as an array. + + \return Array of 3 floats. + */ + NX_INLINE const NxReal *get() const; + + /** + \brief Access the data as an array. + + \return Array of 3 floats. + */ + NX_INLINE NxReal* get(); + + /** + \brief writes out the 3 values to dest. + + \param[out] dest Array to write elements to. + */ + NX_INLINE void get(NxF32 * dest) const; + + /** + \brief writes out the 3 values to dest. + */ + NX_INLINE void get(NxF64 * dest) const; + + NX_INLINE NxReal& operator[](int index); + NX_INLINE NxReal operator[](int index) const; + + //Operators + /** + \brief true if all the members are smaller. + */ + NX_INLINE bool operator< (const NxVec3&) const; + /** + \brief returns true if the two vectors are exactly equal. + + use equal() to test with a tolerance. + */ + NX_INLINE bool operator==(const NxVec3&) const; + /** + \brief returns true if the two vectors are exactly unequal. + + use !equal() to test with a tolerance. + */ + NX_INLINE bool operator!=(const NxVec3&) const; + +/* NX_INLINE const NxVec3 &operator +=(const NxVec3 &); + NX_INLINE const NxVec3 &operator -=(const NxVec3 &); + NX_INLINE const NxVec3 &operator *=(NxReal); + NX_INLINE const NxVec3 &operator /=(NxReal); +*/ +//Methods + NX_INLINE void set(const NxVec3 &); + +//legacy methods: + NX_INLINE void setx(const NxReal & d); + NX_INLINE void sety(const NxReal & d); + NX_INLINE void setz(const NxReal & d); + + /** + \brief this = -a + */ + NX_INLINE void setNegative(const NxVec3 &a); + + /** + \brief this = -this + */ + NX_INLINE void setNegative(); + + /** + \brief reads 3 consecutive values from the ptr passed + */ + NX_INLINE void set(const NxF32 *); + + /** + \brief reads 3 consecutive values from the ptr passed + */ + NX_INLINE void set(const NxF64 *); + NX_INLINE void set(NxReal, NxReal, NxReal); + NX_INLINE void set(NxReal); + + NX_INLINE void zero(); + + /** + \brief tests for exact zero vector + */ + NX_INLINE NX_BOOL isZero() const + { + if((x != 0.0f) || (y != 0.0f) || (z != 0.0f)) return NX_FALSE; + return NX_TRUE; + } + + NX_INLINE void setPlusInfinity(); + NX_INLINE void setMinusInfinity(); + + /** + \brief this = element wise min(this,other) + */ + NX_INLINE void min(const NxVec3 &); + /** + \brief this = element wise max(this,other) + */ + NX_INLINE void max(const NxVec3 &); + + /** + \brief this = a + b + */ + NX_INLINE void add(const NxVec3 & a, const NxVec3 & b); + /** + \brief this = a - b + */ + NX_INLINE void subtract(const NxVec3 &a, const NxVec3 &b); + /** + \brief this = s * a; + */ + NX_INLINE void multiply(NxReal s, const NxVec3 & a); + + /** + \brief this[i] = a[i] * b[i], for all i. + */ + NX_INLINE void arrayMultiply(const NxVec3 &a, const NxVec3 &b); + + + /** + \brief this = s * a + b; + */ + NX_INLINE void multiplyAdd(NxReal s, const NxVec3 & a, const NxVec3 & b); + + /** + \brief normalizes the vector + */ + NX_INLINE NxReal normalize(); + + /** + \brief sets the vector's magnitude + */ + NX_INLINE void setMagnitude(NxReal); + + /** + \brief snaps to closest axis + */ + NX_INLINE NxU32 closestAxis() const; + + /** + \brief snaps to closest axis + */ + NX_INLINE NxAxisType snapToClosestAxis(); + +//const methods + /** + \brief returns true if all 3 elems of the vector are finite (not NAN or INF, etc.) + */ + NX_INLINE bool isFinite() const; + + /** + \brief returns the scalar product of this and other. + */ + NX_INLINE NxReal dot(const NxVec3 &other) const; + + /** + \brief compares orientations (more readable, user-friendly function) + */ + NX_INLINE bool sameDirection(const NxVec3 &) const; + + /** + \brief returns the magnitude + */ + NX_INLINE NxReal magnitude() const; + + /** + \brief returns the squared magnitude + + Avoids calling sqrt()! + */ + NX_INLINE NxReal magnitudeSquared() const; + + /** + \brief returns (this - other).magnitude(); + */ + NX_INLINE NxReal distance(const NxVec3 &) const; + + /** + \brief returns (this - other).magnitudeSquared(); + */ + NX_INLINE NxReal distanceSquared(const NxVec3 &v) const; + + /** + \brief this = left x right + */ + NX_INLINE void cross(const NxVec3 &left, const NxVec3 & right); + + /** + \brief Stuff magic values in the point, marking it as explicitly not used. + */ + NX_INLINE void setNotUsed(); + + /** + \brief Checks the point is marked as not used + */ + NX_BOOL isNotUsed() const; + + /** + \brief returns true if this and arg's elems are within epsilon of each other. + */ + NX_INLINE bool equals(const NxVec3 &, NxReal epsilon) const; + + /** + \brief negation + */ + NxVec3 operator -() const; + /** + \brief vector addition + */ + NxVec3 operator +(const NxVec3 & v) const; + /** + \brief vector difference + */ + NxVec3 operator -(const NxVec3 & v) const; + /** + \brief scalar post-multiplication + */ + NxVec3 operator *(NxReal f) const; + /** + \brief scalar division + */ + NxVec3 operator /(NxReal f) const; + /** + \brief vector addition + */ + NxVec3&operator +=(const NxVec3& v); + /** + \brief vector difference + */ + NxVec3&operator -=(const NxVec3& v); + /** + \brief scalar multiplication + */ + NxVec3&operator *=(NxReal f); + /** + \brief scalar division + */ + NxVec3&operator /=(NxReal f); + /** + \brief cross product + */ + NxVec3 cross(const NxVec3& v) const; + + /** + \brief cross product + */ + NxVec3 operator^(const NxVec3& v) const; + /** + \brief dot product + */ + NxReal operator|(const NxVec3& v) const; + + NxReal x,y,z; + }; + +/** \cond Exclude from documentation */ +NX_INLINE const _Nx3F32& Nx3F32::operator=(const NxVec3& d) + { + x=d.x; + y=d.y; + z=d.z; + return *this; + } +/** \endcond */ + +//NX_INLINE implementations: +NX_INLINE NxVec3::NxVec3(NxReal v) : x(v), y(v), z(v) + { + } + +NX_INLINE NxVec3::NxVec3(NxReal _x, NxReal _y, NxReal _z) : x(_x), y(_y), z(_z) + { + } + +NX_INLINE NxVec3::NxVec3(const Nx3F32 &d) : x(d.x), y(d.y), z(d.z) + { + } + +NX_INLINE NxVec3::NxVec3(const NxReal v[]) : x(v[0]), y(v[1]), z(v[2]) + { + } + + +NX_INLINE NxVec3::NxVec3(const NxVec3 &v) : x(v.x), y(v.y), z(v.z) + { + } + + +NX_INLINE NxVec3::NxVec3() + { + //default constructor leaves data uninitialized. + } + + +NX_INLINE const NxVec3& NxVec3::operator=(const NxVec3& v) + { + x = v.x; + y = v.y; + z = v.z; + return *this; + } + +NX_INLINE const NxVec3& NxVec3::operator=(const Nx3F32& d) + { + x = d.x; + y = d.y; + z = d.z; + return *this; + } + +// Access the data as an array. + +NX_INLINE const NxReal* NxVec3::get() const + { + return &x; + } + + +NX_INLINE NxReal* NxVec3::get() + { + return &x; + } + + +NX_INLINE void NxVec3::get(NxF32 * v) const + { + v[0] = (NxF32)x; + v[1] = (NxF32)y; + v[2] = (NxF32)z; + } + + +NX_INLINE void NxVec3::get(NxF64 * v) const + { + v[0] = (NxF64)x; + v[1] = (NxF64)y; + v[2] = (NxF64)z; + } + + +NX_INLINE NxReal& NxVec3::operator[](int index) + { + NX_ASSERT(index>=0 && index<=2); + return (&x)[index]; + } + + +NX_INLINE NxReal NxVec3::operator[](int index) const + { + NX_ASSERT(index>=0 && index<=2); + return (&x)[index]; + } + + +NX_INLINE void NxVec3::setx(const NxReal & d) + { + x = d; + } + + +NX_INLINE void NxVec3::sety(const NxReal & d) + { + y = d; + } + + +NX_INLINE void NxVec3::setz(const NxReal & d) + { + z = d; + } + +//Operators + +NX_INLINE bool NxVec3::operator< (const NxVec3&v) const + { + return ((x < v.x)&&(y < v.y)&&(z < v.z)); + } + + +NX_INLINE bool NxVec3::operator==(const NxVec3& v) const + { + return ((x == v.x)&&(y == v.y)&&(z == v.z)); + } + + +NX_INLINE bool NxVec3::operator!=(const NxVec3& v) const + { + return ((x != v.x)||(y != v.y)||(z != v.z)); + } + +//Methods + +NX_INLINE void NxVec3::set(const NxVec3 & v) + { + x = v.x; + y = v.y; + z = v.z; + } + + +NX_INLINE void NxVec3::setNegative(const NxVec3 & v) + { + x = -v.x; + y = -v.y; + z = -v.z; + } + + +NX_INLINE void NxVec3::setNegative() + { + x = -x; + y = -y; + z = -z; + } + + + +NX_INLINE void NxVec3::set(const NxF32 * v) + { + x = (NxReal)v[0]; + y = (NxReal)v[1]; + z = (NxReal)v[2]; + } + + +NX_INLINE void NxVec3::set(const NxF64 * v) + { + x = (NxReal)v[0]; + y = (NxReal)v[1]; + z = (NxReal)v[2]; + } + + + +NX_INLINE void NxVec3::set(NxReal _x, NxReal _y, NxReal _z) + { + this->x = _x; + this->y = _y; + this->z = _z; + } + + +NX_INLINE void NxVec3::set(NxReal v) + { + x = v; + y = v; + z = v; + } + + +NX_INLINE void NxVec3::zero() + { + x = y = z = 0.0; + } + + +NX_INLINE void NxVec3::setPlusInfinity() + { + x = y = z = NX_MAX_F32; //TODO: this may be double too, but here we can't tell! + } + + +NX_INLINE void NxVec3::setMinusInfinity() + { + x = y = z = NX_MIN_F32; //TODO: this may be double too, but here we can't tell! + } + + +NX_INLINE void NxVec3::max(const NxVec3 & v) + { + x = NxMath::max(x, v.x); + y = NxMath::max(y, v.y); + z = NxMath::max(z, v.z); + } + + +NX_INLINE void NxVec3::min(const NxVec3 & v) + { + x = NxMath::min(x, v.x); + y = NxMath::min(y, v.y); + z = NxMath::min(z, v.z); + } + + + + +NX_INLINE void NxVec3::add(const NxVec3 & a, const NxVec3 & b) + { + x = a.x + b.x; + y = a.y + b.y; + z = a.z + b.z; + } + + +NX_INLINE void NxVec3::subtract(const NxVec3 &a, const NxVec3 &b) + { + x = a.x - b.x; + y = a.y - b.y; + z = a.z - b.z; + } + + +NX_INLINE void NxVec3::arrayMultiply(const NxVec3 &a, const NxVec3 &b) + { + x = a.x * b.x; + y = a.y * b.y; + z = a.z * b.z; + } + + +NX_INLINE void NxVec3::multiply(NxReal s, const NxVec3 & a) + { + x = a.x * s; + y = a.y * s; + z = a.z * s; + } + + +NX_INLINE void NxVec3::multiplyAdd(NxReal s, const NxVec3 & a, const NxVec3 & b) + { + x = s * a.x + b.x; + y = s * a.y + b.y; + z = s * a.z + b.z; + } + + +NX_INLINE NxReal NxVec3::normalize() + { + NxReal m = magnitude(); + if (m) + { + const NxReal il = NxReal(1.0) / m; + x *= il; + y *= il; + z *= il; + } + return m; + } + + +NX_INLINE void NxVec3::setMagnitude(NxReal length) + { + NxReal m = magnitude(); + if(m) + { + NxReal newLength = length / m; + x *= newLength; + y *= newLength; + z *= newLength; + } + } + + +NX_INLINE NxAxisType NxVec3::snapToClosestAxis() + { + const NxReal almostOne = 0.999999f; + if(x >= almostOne) { set( 1.0f, 0.0f, 0.0f); return NX_AXIS_PLUS_X ; } + else if(x <= -almostOne) { set(-1.0f, 0.0f, 0.0f); return NX_AXIS_MINUS_X; } + else if(y >= almostOne) { set( 0.0f, 1.0f, 0.0f); return NX_AXIS_PLUS_Y ; } + else if(y <= -almostOne) { set( 0.0f, -1.0f, 0.0f); return NX_AXIS_MINUS_Y; } + else if(z >= almostOne) { set( 0.0f, 0.0f, 1.0f); return NX_AXIS_PLUS_Z ; } + else if(z <= -almostOne) { set( 0.0f, 0.0f, -1.0f); return NX_AXIS_MINUS_Z; } + else return NX_AXIS_ARBITRARY; + } + + +NX_INLINE NxU32 NxVec3::closestAxis() const + { + const NxF32* vals = &x; + NxU32 m = 0; + if(NxMath::abs(vals[1]) > NxMath::abs(vals[m])) m = 1; + if(NxMath::abs(vals[2]) > NxMath::abs(vals[m])) m = 2; + return m; + } + + +//const methods + +NX_INLINE bool NxVec3::isFinite() const + { + return NxMath::isFinite(x) && NxMath::isFinite(y) && NxMath::isFinite(z); + } + + +NX_INLINE NxReal NxVec3::dot(const NxVec3 &v) const + { + return x * v.x + y * v.y + z * v.z; + } + + +NX_INLINE bool NxVec3::sameDirection(const NxVec3 &v) const + { + return x*v.x + y*v.y + z*v.z >= 0.0f; + } + + +NX_INLINE NxReal NxVec3::magnitude() const + { + return NxMath::sqrt(x * x + y * y + z * z); + } + + +NX_INLINE NxReal NxVec3::magnitudeSquared() const + { + return x * x + y * y + z * z; + } + + +NX_INLINE NxReal NxVec3::distance(const NxVec3 & v) const + { + NxReal dx = x - v.x; + NxReal dy = y - v.y; + NxReal dz = z - v.z; + return NxMath::sqrt(dx * dx + dy * dy + dz * dz); + } + + +NX_INLINE NxReal NxVec3::distanceSquared(const NxVec3 &v) const + { + NxReal dx = x - v.x; + NxReal dy = y - v.y; + NxReal dz = z - v.z; + return dx * dx + dy * dy + dz * dz; + } + + +NX_INLINE void NxVec3::cross(const NxVec3 &left, const NxVec3 & right) //prefered version, w/o temp object. + { + // temps needed in case left or right is this. + NxReal a = (left.y * right.z) - (left.z * right.y); + NxReal b = (left.z * right.x) - (left.x * right.z); + NxReal c = (left.x * right.y) - (left.y * right.x); + + x = a; + y = b; + z = c; + } + + +NX_INLINE bool NxVec3::equals(const NxVec3 & v, NxReal epsilon) const + { + return + NxMath::equals(x, v.x, epsilon) && + NxMath::equals(y, v.y, epsilon) && + NxMath::equals(z, v.z, epsilon); + } + + + +NX_INLINE NxVec3 NxVec3::operator -() const + { + return NxVec3(-x, -y, -z); + } + + +NX_INLINE NxVec3 NxVec3::operator +(const NxVec3 & v) const + { + return NxVec3(x + v.x, y + v.y, z + v.z); // RVO version + } + + +NX_INLINE NxVec3 NxVec3::operator -(const NxVec3 & v) const + { + return NxVec3(x - v.x, y - v.y, z - v.z); // RVO version + } + + + +NX_INLINE NxVec3 NxVec3::operator *(NxReal f) const + { + return NxVec3(x * f, y * f, z * f); // RVO version + } + + +NX_INLINE NxVec3 NxVec3::operator /(NxReal f) const + { + f = NxReal(1.0) / f; return NxVec3(x * f, y * f, z * f); + } + + +NX_INLINE NxVec3& NxVec3::operator +=(const NxVec3& v) + { + x += v.x; + y += v.y; + z += v.z; + return *this; + } + + +NX_INLINE NxVec3& NxVec3::operator -=(const NxVec3& v) + { + x -= v.x; + y -= v.y; + z -= v.z; + return *this; + } + + +NX_INLINE NxVec3& NxVec3::operator *=(NxReal f) + { + x *= f; + y *= f; + z *= f; + return *this; + } + + +NX_INLINE NxVec3& NxVec3::operator /=(NxReal f) + { + f = 1.0f/f; + x *= f; + y *= f; + z *= f; + return *this; + } + + +NX_INLINE NxVec3 NxVec3::cross(const NxVec3& v) const + { + NxVec3 temp; + temp.cross(*this,v); + return temp; + } + + +NX_INLINE NxVec3 NxVec3::operator^(const NxVec3& v) const + { + NxVec3 temp; + temp.cross(*this,v); + return temp; + } + + +NX_INLINE NxReal NxVec3::operator|(const NxVec3& v) const + { + return x * v.x + y * v.y + z * v.z; + } + +/** +scalar pre-multiplication +*/ + +NX_INLINE NxVec3 operator *(NxReal f, const NxVec3& v) + { + return NxVec3(f * v.x, f * v.y, f * v.z); + } + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxVersionNumber.h b/libraries/external/physx/Win32/include/PX/NxVersionNumber.h new file mode 100755 index 0000000..be54cce --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxVersionNumber.h @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/* +VersionNumbers: The combination of these +numbers uniquely identifies the API, and should +be incremented when the SDK API changes. This may +include changes to file formats. + +This header is included in the main SDK header files +so that the entire SDK and everything that builds on it +is completely rebuilt when this file changes. Thus, +this file is not to include a frequently changing +build number. See BuildNumber.h for that. + +Each of these three values should stay below 255 because +sometimes they are stored in a byte. +*/ +/** \addtogroup foundation + @{ +*/ +#ifndef NX_VERSION_NUMBER_H + +#define NX_VERSION_NUMBER_H + +#define NX_SDK_VERSION_MAJOR 2 +#define NX_SDK_VERSION_MINOR 8 +#define NX_SDK_VERSION_BUGFIX 1 + +#define NX_SDK_VERSION_NUMBER 281 + +#define NX_SDK_API_REV 1 // bump this number *any* time a public interface changes in any way!!! +#define NX_SDK_DESC_REV 0 // bump this number *any* time the serialization data ever changes in any way, this includes NxParameters!! +#define NX_SDK_BRANCH 0 // no longer used. + +#define NXAPI_HAS_PHYSXLOADER 1 +#define NX_CHANGELIST_NUMBER 30725 +#endif + + /** @} */ +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxVolumeIntegration.h b/libraries/external/physx/Win32/include/PX/NxVolumeIntegration.h new file mode 100755 index 0000000..c67b0b0 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxVolumeIntegration.h @@ -0,0 +1,71 @@ +#ifndef NX_FOUNDATION_NXVOLUMEINTEGRATION +#define NX_FOUNDATION_NXVOLUMEINTEGRATION +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup foundation + @{ +*/ + + +#include "PX/Nx.h" +#include "PX/NxVec3.h" +#include "PX/NxMat33.h" + +class NxSimpleTriangleMesh; + +/** +\brief Data structure used to store mass properties. +*/ +struct NxIntegrals + { + NxVec3 COM; //!< Center of mass + NxF64 mass; //!< Total mass + NxF64 inertiaTensor[3][3]; //!< Inertia tensor (mass matrix) relative to the origin + NxF64 COMInertiaTensor[3][3]; //!< Inertia tensor (mass matrix) relative to the COM + + /** + \brief Retrieve the inertia tensor relative to the center of mass. + + \param inertia Inertia tensor. + */ + void getInertia(NxMat33& inertia) + { + for(NxU32 j=0;j<3;j++) + { + for(NxU32 i=0;i<3;i++) + { + inertia(i,j) = (NxF32)COMInertiaTensor[i][j]; + } + } + } + + /** + \brief Retrieve the inertia tensor relative to the origin. + + \param inertia Inertia tensor. + */ + void getOriginInertia(NxMat33& inertia) + { + for(NxU32 j=0;j<3;j++) + { + for(NxU32 i=0;i<3;i++) + { + inertia(i,j) = (NxF32)inertiaTensor[i][j]; + } + } + } + }; + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxWheelShape.h b/libraries/external/physx/Win32/include/PX/NxWheelShape.h new file mode 100755 index 0000000..501dd3f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxWheelShape.h @@ -0,0 +1,557 @@ +#ifndef NX_COLLISION_NXWHEELSHAPE +#define NX_COLLISION_NXWHEELSHAPE +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/NxShape.h" +#include "PX/NxSpringDesc.h" +#include "PX/NxWheelShapeDesc.h" + +class NxShape; +class NxWheelShapeDesc; + +/** +\brief Contact information used by NxWheelShape + +Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + +@see NxWheelShape NxWheelShape.getContact() +*/ +class NxWheelContactData + { + public: + /** + \brief The point of contact between the wheel shape and the ground. + + */ + NxVec3 contactPoint; + + /** + \brief The normal at the point of contact. + + */ + NxVec3 contactNormal; + + /** + \brief The direction the wheel is pointing in. + */ + NxVec3 longitudalDirection; + + /** + \brief The sideways direction for the wheel(at right angles to the longitudinal direction). + */ + NxVec3 lateralDirection; + + /** + \brief The magnitude of the force being applied for the contact. + */ + NxReal contactForce; + + /** + \brief What these exactly are depend on NX_WF_INPUT_LAT_SLIPVELOCITY and NX_WF_INPUT_LNG_SLIPVELOCITY flags for the wheel. + */ + NxReal longitudalSlip, lateralSlip; + + /** + \brief the clipped impulses applied at the wheel. + */ + NxReal longitudalImpulse, lateralImpulse; + + /** + \brief The material index of the shape in contact with the wheel. + + @see NxMaterial NxMaterialIndex + */ + NxMaterialIndex otherShapeMaterialIndex; + + /** + \brief The distance on the spring travel distance where the wheel would end up if it was resting on the contact point. + */ + NxReal contactPosition; + }; + +/** +\brief A special shape used for simulating a car wheel. + +The -Y axis should be directed toward the ground. A ray is cast from the shape's origin along the -Y axis. + +When the ray strikes something, and the distance is: + + \li less than wheelRadius from the shape origin: a hard contact is created + \li between wheelRadius and (suspensionTravel + wheelRadius): a soft suspension contact is created + \li greater than (suspensionTravel + wheelRadius): no contact is created. + +Thus at the point of greatest possible suspension compression the wheel axle will pass through at the shape's origin. +At the point greatest suspension extension the wheel axle will be a distance of suspensionTravel from the shape's origin. + +The suspension's targetValue is 0 for real cars, which means that the suspension tries to extend all the way. Otherwise one can specify values +[0,1] for suspensions which have a spring to pull the wheel up when it is extended too far. 0.5 will then fall halfway along suspensionTravel. + +The +Z axis is the 'forward' direction of travel for the wheel. -Z is backwards. +The wheel rolls forward when rotating around the positive direction around the X axis. + +A positive wheel steering angle corresponds to a positive rotation around the shape's Y axis. (Castor angles are not modeled.) + +The coordinate frame of the shape is rigidly fixed on the car. + +Platform: +\li PC SW: Yes +\li PPU : Yes (Software fallback for collision) +\li PS3 : Yes +\li XB360: Yes + +

Visualizations

+\li NX_VISUALIZE_COLLISION_AABBS +\li NX_VISUALIZE_COLLISION_SHAPES +\li NX_VISUALIZE_COLLISION_AXES + +@see NxShape NxWheelShapeDesc +*/ + +class NxWheelShape : public NxShape + { + public: + + /** + \brief Saves the state of the shape object to a descriptor. + + \param[out] desc Descriptor to retrieve shape properties. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxWheelShapeDesc + */ + virtual void saveToDesc(NxWheelShapeDesc& desc) const = 0; + +//accessors for all the stuff in the descriptor go here. +//geometrical constants: + + /** + \brief distance from wheel axle to a point on the contact surface. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] radius The new wheel radius. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getRadius() + */ + virtual void setRadius(NxReal radius) = 0; + + /** + \brief maximum extension distance of suspension along shape's -Y axis. The minimum extension is always 0. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] travel The suspension travel. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSuspensionTravel() + */ + virtual void setSuspensionTravel(NxReal travel) = 0; + + + /** + \brief distance from wheel axle to a point on the contact surface. + + \return The wheel radius. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setRadius() + */ + virtual NxReal getRadius() const = 0; + + /** + \brief maximum extension distance of suspension along shape's -Y axis. The minimum extension is always 0. + + \return The suspension travel. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setSuspensionTravel() + */ + virtual NxReal getSuspensionTravel() const = 0; + + //simulation constants: + /** + \brief data intended for car wheel suspension effects. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] spring Suspension spring properties. + Range: .spring [0,inf)
+ Range: .damper [0,inf)
+ Range: .targetValue [0,1]
+ + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSuspension() NxSpringDesc + */ + virtual void setSuspension(NxSpringDesc spring) = 0; + + /** + \brief cubic Hermite spline coefficients describing the longitudinal tire force curve. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] tireFunc Description of the longitudinal tire forces. Range: See #NxTireFunctionDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLongitudalTireForceFunction NxTireFunctionDesc + */ + virtual void setLongitudalTireForceFunction(NxTireFunctionDesc tireFunc) = 0; + + /** + \brief cubic Hermite spline coefficients describing the lateral tire force curve. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] tireFunc Description of the lateral tire forces. Range: See #NxTireFunctionDesc + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getLateralTireForceFunction() NxTireFunctionDesc + */ + virtual void setLateralTireForceFunction(NxTireFunctionDesc tireFunc) = 0; + + /** + \brief inverse mass of the wheel. Determines the wheel velocity that wheel torques can achieve. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] invMass The inverse wheel mass. Range: (0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getInverseWheelMass() + */ + virtual void setInverseWheelMass(NxReal invMass) = 0; + + /** + \brief flags from NxWheelShapeFlags + + \param[in] flags The new wheel flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxWheelShapeFlags getWheelFlags() + */ + virtual void setWheelFlags(NxU32 flags) = 0; + + /** + \brief data intended for car wheel suspension effects. + + \return Description of the suspension spring. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setSuspension() NxSpringDesc + */ + virtual NxSpringDesc getSuspension() const = 0; + + /** + \brief cubic Hermite spline coefficients describing the longitudinal tire force curve. + + \return Description of the longitudinal tire force. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTireFunctionDesc setLongitudalTireForceFunction() + */ + virtual NxTireFunctionDesc getLongitudalTireForceFunction() const = 0; + + /** + \brief cubic Hermite spline coefficients describing the lateral tire force curve. + + \return Description of the lateral tire force. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxTireFunctionDesc setLateralTireForceFunction() + */ + virtual NxTireFunctionDesc getLateralTireForceFunction() const = 0; + + /** + \brief inverse mass of the wheel. Determines the wheel velocity that wheel torques can achieve. + + \return Inverse wheel mass. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setInverseWheelMass() + */ + virtual NxReal getInverseWheelMass() const = 0; + + /** + \brief flags from NxWheelShapeFlags + + \return The wheel flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxWheelShapeFlags setWheelFlags() + */ + virtual NxU32 getWheelFlags() const = 0; + +//dynamic inputs: + /** + \brief Sum engine torque on the wheel axle. Positive or negative depending on direction. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] torque The motor torque to apply. Range: (-inf,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getMotorTorque() + */ + virtual void setMotorTorque(NxReal torque) = 0; + + /** + \brief Must be nonnegative. Very large values should lock wheel but should be stable. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] torque The brake torque to apply. Range: [0,inf) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getBrakeTorque() + */ + virtual void setBrakeTorque(NxReal torque) = 0; + + /** + \brief steering angle, around shape Y axis. + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] angle The new steering angle(in radians). Range: (-PI,PI) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getSteerAngle() + */ + virtual void setSteerAngle(NxReal angle) = 0; + + /** + \brief Sum engine torque on the wheel axle. Positive or negative depending on direction. + + \return The current motor torque. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setMotorTorque() + */ + virtual NxReal getMotorTorque() const = 0; + + /** + \brief Must be positive. Very large values should lock wheel but should be stable. + + \return The current brake torque. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setBrakeTorque() + */ + virtual NxReal getBrakeTorque() const = 0; + + /** + \brief steering angle, around shape Y axis. + + \return The current steering angle(in radians) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setSteerAngle() + */ + virtual NxReal getSteerAngle() const = 0; + + +//setting of internal state variables -- you normally don't want to do this! + + /** + \brief Current axle rotation speed NOTE: NX_WF_AXLE_SPEED_OVERRIDE flag must be raised for this to have effect! + + Sleeping: Does NOT wake any actors associated with the shape. + + \param[in] speed The new axle speed. Range: (-inf,inf) + + NOTE: NX_WF_AXLE_SPEED_OVERRIDE flag must be raised for this to have effect! + + An overridden axle speed of course renders the axle motor and brake torques ineffective. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getAxleSpeed() + */ + virtual void setAxleSpeed(NxReal speed) = 0; + +//readout of internal state variables: + + /** + \brief Current axle rotation speed + + \return The current axle speed. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setAxleSpeed() + */ + virtual NxReal getAxleSpeed() const = 0; + + /** + \brief Return contact information for the wheel. + + when getContact() returns nonzero the wheel is in contact with another shape. (if there are several objects, this is the closest one hit by the wheel.) + returns most recent contact normal and contact force for the wheel. + longitudalDirection and lateralDirection are tangential to the returned shape, and form a basis together with the contactNormal. + otherShapeMaterialIndex is the material of the returned shape at the point of contact. Because the tire model does not automatically respond to the material + of objects it is in contact with (because it is an inherently different kind of material simulation) any adaptation of the tire force curves must be done by the + user in response to the ground material returned here. + + \param[out] dest Description of the contact. (only valid if there is a contact) + \return Returns the shape the wheel is in contact with. Or NULL if there is no contact. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback for collision) + \li PS3 : Yes + \li XB360: Yes + + @see NxWheelContactData NxShape + */ + virtual NxShape * getContact(NxWheelContactData & dest) const = 0; + + /** + \brief Sets a callback function for wheel contact modification. NULL deactivates this functionality for the WheelShape. + + \param callback The callback function + + @see NxWheelShapeDesc.wheelContactModify NxUserWheelContactModify + */ + virtual void setUserWheelContactModify(NxUserWheelContactModify* callback) = 0; + + /** + \brief Returns the callback function used for wheel contact modification on the WheelShape. + + \return The current wheel contact modification callback. NULL if no contact modification is being used. + + @see NxWheelShapeDesc.wheelContactModify NxUserWheelContactModify + */ + virtual NxUserWheelContactModify* getUserWheelContactModify() = 0; + }; + + +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/NxWheelShapeDesc.h b/libraries/external/physx/Win32/include/PX/NxWheelShapeDesc.h new file mode 100755 index 0000000..aa7469c --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/NxWheelShapeDesc.h @@ -0,0 +1,504 @@ +#ifndef NX_COLLISION_NXWHEELSHAPEDESC +#define NX_COLLISION_NXWHEELSHAPEDESC +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + + +#include "PX/NxShapeDesc.h" +#include "PX/NxSpringDesc.h" +class NxUserWheelContactModify; + +/** +\brief Class used to describe tire properties for a #NxWheelShape + +A tire force function takes a measure for tire slip as input, (this is computed differently for lateral and longitudal directions) +and gives a measure of grip as output. + +The exact interpretation of the output value will depend on the model used. + +In the default model the frictional constraints are modeled as springs. +The output from the tire force function is interpreted as a normalized spring coefficient. +The actual spring coefficient is computed by scaling the output with the normal impulse +and the stiffness parameter. +Note that this implies that the material of the "ground" and the wheel do not affect the grip level. + +In the clamped friction model the output from the tire force function is interpreted as friction +coefficients. The maximum friction impulse available to maintain the constraint is computed +by scaling the output with the normal impulse. +Note that the stiffness parameter is ignored in this model. +Note that this implies that the material of the "ground" and the wheel do not affect the grip level. +See #NX_WF_CLAMPED_FRICTION. + +In the legacy friction model the output from the tire force functions is ignored. +The combined material properties of the wheel and the "ground" determine the traction budget. +See #NX_WF_EMULATE_LEGACY_WHEEL. + +The default model and the clamped friction model use a different mechanism for low speed friction. +The low speed friction model is activated if the contact point with the ground is within skinWidth +of its previous position. In this mode the wheel contacts are modeled as static friction contacts. +
The maximum friction force in each direction is: +
(friction force) = mu * (normal force). +
Where, +
mu = NxTireFunctionDesc::extremumValue * NxTireFunctionDesc::stiffness (for the default model) +
mu = NxTireFunctionDesc::extremumValue (for the clamped friction model) + +The curve is approximated by a two piece cubic Hermite spline. The first section goes from (0,0) to (extremumSlip, extremumValue), at which +point the curve's tangent is zero. + +The second section goes from (extremumSlip, extremumValue) to (asymptoteSlip, asymptoteValue), at which point the curve's tangent is again zero. + +\image html wheelGraph.png + + +Platform: +\li PC SW: Yes +\li PPU : Yes (Software fallback for collision) +\li PS3 : Yes +\li XB360: Yes + +See #NxWheelShape. +*/ + +/* +Force +^ extremum +| _*_ +| ~ \ asymptote +| / \~__*______________ +| / +|/ +---------------------------> Slip +*/ +class NxTireFunctionDesc + { + public: + + virtual ~NxTireFunctionDesc(){}; + + /** + \brief extremal point of curve. Both values must be positive. + + Range: (0,inf)
+ Default: 1.0 + */ + NxReal extremumSlip; + + /** + \brief extremal point of curve. Both values must be positive. + + Range: (0,inf)
+ Default: 0.02 + */ + NxReal extremumValue; + + /** + \brief point on curve at which for all x > minumumX, function equals minimumY. Both values must be positive. + + Range: (0,inf)
+ Default: 2.0 + */ + NxReal asymptoteSlip; + + /** + \brief point on curve at which for all x > minumumX, function equals minimumY. Both values must be positive. + + Range: (0,inf)
+ Default: 0.01 + */ + NxReal asymptoteValue; + + + /** + \brief Scaling factor for tire force. + + This is an additional overall positive scaling that gets applied to the tire forces before passing + them to the solver. Higher values make for better grip. If you raise the *Values above, you may + need to lower this. A setting of zero will disable all friction in this direction. + + Range: (0,inf)
+ Default: 1000000.0 (quite stiff by default) + */ + NxReal stiffnessFactor; + + + /** + \brief Scaling factor for tire force. + + This is an additional overall positive scaling that gets applied to the tire forces before passing + them to the solver. Higher values make for better grip. If you raise the *Values above, you may + need to lower this. A setting of zero will disable all friction in this direction. + + Range: (0,inf)
+ Default: 1000000.0 (quite stiff by default) + */ + //NxReal stiffnessFactor; + + + /** + constructor sets to default. + */ + NX_INLINE NxTireFunctionDesc(); + /** + (re)sets the structure to the default. + */ + NX_INLINE virtual void setToDefault(); + /** + returns true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + + /** + evaluates the Force(Slip) function + */ + NX_INLINE NxReal hermiteEval(NxReal t) const; + }; + +enum NxWheelShapeFlags + { + /** + \brief Determines whether the suspension axis or the ground contact normal is used for the suspension constraint. + + */ + NX_WF_WHEEL_AXIS_CONTACT_NORMAL = 1 << 0, + + /** + \brief If set, the laterial slip velocity is used as the input to the tire function, rather than the slip angle. + + */ + NX_WF_INPUT_LAT_SLIPVELOCITY = 1 << 1, + + /** + \brief If set, the longutudal slip velocity is used as the input to the tire function, rather than the slip ratio. + */ + NX_WF_INPUT_LNG_SLIPVELOCITY = 1 << 2, + + /** + \brief If set, does not factor out the suspension travel and wheel radius from the spring force computation. This is the legacy behavior from the raycast capsule approach. + */ + NX_WF_UNSCALED_SPRING_BEHAVIOR = 1 << 3, + + /** + \brief If set, the axle speed is not computed by the simulation but is rather expected to be provided by the user every simulation step via NxWheelShape::setAxleSpeed(). + */ + NX_WF_AXLE_SPEED_OVERRIDE = 1 << 4, + + /** + \brief If set, the NxWheelShape will emulate the legacy raycast capsule based wheel. + See #NxTireFunctionDesc + */ + NX_WF_EMULATE_LEGACY_WHEEL = 1 << 5, + + /** + \brief If set, the NxWheelShape will clamp the force in the friction constraints. + See #NxTireFunctionDesc + */ + NX_WF_CLAMPED_FRICTION = 1 << 6, + }; + + +/** + \brief Descriptor for an #NxWheelShape. + +Platform: +\li PC SW: Yes +\li PPU : Yes (Software fallback for collision) +\li PS3 : Yes +\li XB360: Yes + + @see NxWheelShape NxActor.createActor() +*/ +class NxWheelShapeDesc : public NxShapeDesc //TODO: this nor other desc classes can be assigned with = operator, we need to define copy ctors. + { + public: + + virtual ~NxWheelShapeDesc(){}; + +//geometrical constants: + + /** + \brief distance from wheel axle to a point on the contact surface. + + Range: (0,inf)
+ Default: 1.0 + + @see NxWheelShape.getRadius() NxWheelShape.setRadius() + */ + NxReal radius; + + /** + \brief maximum extension distance of suspension along shape's -Y axis. + + The minimum extension is always 0. + + Range: [0,inf)
+ Default: 1.0 + + @see NxWheelShape.setSuspensionTravel() NxWheelShape.getSuspensionTravel() + */ + NxReal suspensionTravel; + +//(In the old model the capsule height was the sum of the two members above.) +//^^^ this may be redundant together with suspension.targetValue, not sure yet. + +//simulation constants: + + /** + \brief data intended for car wheel suspension effects. + + targetValue must be in [0, 1], which is the rest length of the suspension along the suspensionTravel. + 0 is the default, which maps to the tip of the ray cast. + + Range: .spring [0,inf)
+ Range: .damper [0,inf)
+ Range: .targetValue [0,1]
+ Default: See #NxSpringDesc + + + @see NxSpringDesc NxWheelShape.setSuspension() NxWheelShape.getSuspension() + */ + NxSpringDesc suspension; + + /** + \brief cubic hermite spline coefficients describing the longitudal tire force curve. + + Range: See #NxTireFunctionDesc
+ Default: See #NxTireFunctionDesc + + @see NxWheelShape.getLongitudalTireForceFunction() NxWheelShape.setLongitudalTireForceFunction() + */ + NxTireFunctionDesc longitudalTireForceFunction; + + /** + \brief cubic hermite spline coefficients describing the lateral tire force curve. + + Range: See #NxTireFunctionDesc
+ Default: See #NxTireFunctionDesc + + @see NxWheelShape.getLateralTireForceFunction() NxWheelShape.setLateralTireForceFunction() + */ + NxTireFunctionDesc lateralTireForceFunction; + + /** + \brief inverse mass of the wheel. + + Determines the wheel velocity that wheel torques can achieve. + + Range: (0,inf)
+ Default: 1.0 + + @see NxWheelShape.setInverseWheelMass() NxWheelShape.getInverseWheelMass() + */ + NxReal inverseWheelMass; + + /** + \brief flags from NxWheelShapeFlags + + Default: 0 + + @see NxWheelShapeFlags NxWheelShape.getWheelFlags() NxWheelShape.setWheelFlags() + */ + NxU32 wheelFlags; + +//dynamic inputs: + + /** + \brief Sum engine torque on the wheel axle. + + Positive or negative depending on direction. + + Range: (-inf,inf)
+ Default: 0.0 + + @see NxWheelShape.setMotorTorque() NxWheelShape.getMotorTorque() brakeTorque + */ + NxReal motorTorque; + + /** + \brief The amount of torque applied for braking. + + Must be nonnegative. Very large values should lock wheel but should be stable. + + Range: [0,inf)
+ Default: 0.0 + + @see NxWheelShape.setBrakeTorque() NxWheelShape.getBrakeTorque() motorTorque + */ + NxReal brakeTorque; + + /** + \brief steering angle, around shape Y axis. + + Range: (-PI,PI)
+ Default: 0.0 + + @see NxWheelShape.setSteerAngle() NxWheelShape.getSteerAngle() + */ + NxReal steerAngle; + + /** + \brief callback used for modifying the wheel contact point before the wheel constraints are created. + + Default: NULL + + @see NxUserWheelContactModify + */ + NxUserWheelContactModify* wheelContactModify; + + /** + constructor sets to default. + */ + NX_INLINE NxWheelShapeDesc(); + /** + \brief (re)sets the structure to the default. + \param[in] fromCtor Avoid redundant work if called from constructor. + */ + NX_INLINE virtual void setToDefault(bool fromCtor = false); + /** + \brief returns true if the current settings are valid + */ + NX_INLINE virtual bool isValid() const; + }; + + +NX_INLINE NxTireFunctionDesc::NxTireFunctionDesc() + { + setToDefault(); + } + +NX_INLINE void NxTireFunctionDesc::setToDefault() + { + extremumSlip = 1.0f; + extremumValue = 0.02f; + asymptoteSlip = 2.0f; + asymptoteValue = 0.01f; + stiffnessFactor = 1000000.0f; //quite stiff by default. + } + +NX_INLINE bool NxTireFunctionDesc::isValid() const + { + if(!(0.0f < extremumSlip)) return false; + if(!(extremumSlip < asymptoteSlip)) return false; + if(!(0.0f < extremumValue)) return false; + if(!(0.0f < asymptoteValue)) return false; + if(!(0.0f <= stiffnessFactor)) return false; + + return true; + } + + +NX_INLINE NxReal NxTireFunctionDesc::hermiteEval(NxReal t) const + { + + // This fix for TTP 3429 & 3675 is from Sega. + // Assume blending functions (look these up in a graph): + // H0(t) = 2ttt - 3tt + 1 + // H1(t) = -2ttt + 3tt + // H2(t) = ttt - 2tt + t + // H3(t) = ttt - tt + + NxReal v = NxMath::abs(t); + NxReal s = (t>=0) ? 1.0f : -1.0f; + + NxReal F; + + if(v NxVec3; +//typedef NxQuatT NxQuat; +//typedef NxMat33T NxMat33; +//typedef NxMat34T NxMat34; + +#define NxPi NxPiF32 +#define NxHalfPi NxHalfPiF32 +#define NxTwoPi NxTwoPiF32 +#define NxInvPi NxInvPiF32 + +#define NX_MAX_REAL NX_MAX_F32 +#define NX_MIN_REAL NX_MIN_F32 +#define NX_EPS_REAL NX_EPS_F32 + +#else +//#include "Nx4F64.h" +//#include "Nx9F64.h" + +typedef NxF64 NxReal; +//typedef NxVec3T NxVec3; +//typedef NxQuatT NxQuat; +//typedef NxMat33T NxMat33; +//typedef NxMat34T NxMat34; + +#define NxPi NxPiF64 +#define NxHalfPi NxHalfPiF64 +#define NxTwoPi NxTwoPiF64 +#define NxInvPi NxInvPiF64 + +#define NX_MAX_REAL NX_MAX_F64 +#define NX_MIN_REAL NX_MIN_F64 +#define NX_EPS_REAL NX_EPS_F64 +#endif + +//#define NxfBounds3 NxBounds3 //legacy code support, may want to replace them all eventually. + + /** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/Nxp.h b/libraries/external/physx/Win32/include/PX/Nxp.h new file mode 100755 index 0000000..03af7d8 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/Nxp.h @@ -0,0 +1,2253 @@ +#ifndef NX_PHYSICS_NXP +#define NX_PHYSICS_NXP +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +/** \addtogroup physics + @{ +*/ + +//this header should be included first thing in all headers in physics/include +#ifndef NXP_DLL_EXPORT + #if defined NX_PHYSICS_DLL + #if defined(WIN32) + #define NXP_DLL_EXPORT __declspec(dllexport) + //new: default foundation to static lib: + #define NXF_DLL_EXPORT //__declspec(dllimport) + #elif defined(LINUX) && defined(NX_LINUX_USE_VISIBILITY) + #define NXP_DLL_EXPORT __attribute__ ((visibility ("default"))) + #define NXF_DLL_EXPORT + #else + #define NXP_DLL_EXPORT + #define NXF_DLL_EXPORT + #endif + #elif defined NX_PHYSICS_STATICLIB + #define NXP_DLL_EXPORT + #define NXF_DLL_EXPORT + #elif defined NX_USE_SDK_DLLS + #if defined(WIN32) + #define NXP_DLL_EXPORT __declspec(dllimport) + //new: default foundation to static lib: + #define NXF_DLL_EXPORT //__declspec(dllimport) + #elif defined(LINUX) && defined(NX_LINUX_USE_VISIBILITY) + #define NXP_DLL_EXPORT __attribute__ ((visibility ("default"))) + #define NXF_DLL_EXPORT + #else + #define NXP_DLL_EXPORT + #define NXF_DLL_EXPORT + #endif + #elif defined NX_USE_SDK_STATICLIBS + + #define NXP_DLL_EXPORT + #define NXF_DLL_EXPORT + + #else + + #if defined(WIN32) + //#error Please define either NX_USE_SDK_DLLS or NX_USE_SDK_STATICLIBS in your project settings depending on the kind of libraries you use! + //new: default foundation to static lib: + #define NXP_DLL_EXPORT __declspec(dllimport) + #define NXF_DLL_EXPORT //__declspec(dllimport) + #elif defined(LINUX) && defined(NX_LINUX_USE_VISIBILITY) + #define NXP_DLL_EXPORT __attribute__ ((visibility ("default"))) + #define NXF_DLL_EXPORT + #else + #define NXP_DLL_EXPORT + #define NXF_DLL_EXPORT + #endif + + #endif +#endif + +#include "PX/Nxf.h" +#include "PX/NxVec3.h" +#include "PX/NxQuat.h" +#include "PX/NxMat33.h" +#include "PX/NxMat34.h" + +#include "PX/NxVersionNumber.h" +/** +Pass the constant NX_PHYSICS_SDK_VERSION to the NxCreatePhysicsSDK function. +This is to ensure that the application is using the same header version as the +library was built with. +*/ + +#define NX_PHYSICS_SDK_VERSION (( NX_SDK_VERSION_MAJOR <<24)+(NX_SDK_VERSION_MINOR <<16)+(NX_SDK_VERSION_BUGFIX <<8) + 0) +//2.1.1 Automatic scheme via VersionNumber.h on July 9, 2004. +//2.1.0 (new scheme: major.minor.build.configCode) on May 12, 2004. ConfigCode can be i.e. 32 vs. 64 bit. +//2.3 on Friday April 2, 2004, starting ag. changes. +//2.2 on Friday Feb 13, 2004 +//2.1 on Jan 20, 2004 + +/* +Note: users can't change these defines as it would need the libraries to be recompiled! + +AM: PLEASE MAKE SURE TO HAVE AN 'NX_' PREFIX ON ALL NEW DEFINES YOU ADD HERE!!!!! + +*/ + +#define NX_FIX_TTP_1922 1 +#define NX_SUPPORT_SWEEP_API 1 +#define NX_HAS_CCD_SKELETONS +#define NX_ENABLE_HW_PARSER 0 +//#define SUPPORT_INTERNAL_RADIUS // For raycast CCD only +//#define NX_SUPPORT_MESH_SCALE // Experimental mesh scale support + +//#define NX_DISABLE_FLUIDS +//#define NX_DISABLE_CLOTH +//#define NX_DISABLE_SOFTBODY + +#ifdef NX_DISABLE_FLUIDS + #define NX_USE_FLUID_API 0 + //#define NX_USE_SDK_FLUIDS 0 +#else + // If we are exposing the Fluid API. + #define NX_USE_FLUID_API 1 + + // If we are compiling in support for Fluid. + // We check to see if this is already defined + // by the Project or Makefile. + //#ifndef NX_USE_SDK_FLUIDS + //#define NX_USE_SDK_FLUIDS 1 + //#endif + + #if (defined(__CELLOS_LV2__) || defined(_XBOX)) + #define NX_USE_LL_SW_FLUIDS 1 + #else + #define NX_USE_LL_SW_FLUIDS 0 + #endif + #if NX_USE_LL_SW_FLUIDS + // Experimental code path which allows to put fluids in the primary scene + //#define NX_FLUID_IN_PRIMARY_SCENE + #endif +#endif /* NX_DISABLE_FLUIDS */ + +// Exposing of the Cloth API +#ifdef NX_DISABLE_CLOTH + #define NX_USE_CLOTH_API 0 +#else + #define NX_USE_CLOTH_API 1 +#endif /* NX_DISABLE_CLOTH */ + +// Exposing of the SoftBody API +#ifdef NX_DISABLE_SOFTBODY + #define NX_USE_SOFTBODY_API 0 +#else + #define NX_USE_SOFTBODY_API 1 +#endif /* NX_DISABLE_SOFTBODY */ + +// a bunch of simple defines used in several places: + +typedef NxU16 NxActorGroup; +typedef NxU16 NxDominanceGroup; // Must be < 32, NxU16 to be symmetric with NxCollisionGroup, NxActorGroup. +typedef NxU16 NxCollisionGroup; // Must be < 32 +typedef NxU16 NxMaterialIndex; +typedef NxU16 NxForceFieldVariety; +typedef NxU16 NxForceFieldMaterial; + +typedef NxU32 NxTriangleID; + +////// moved enums here that are used in Core so we don't have to include headers such as NxBoxShape in core!! + +/** +\brief Identified a particular shape type. + +@see NxShape NxShapeDesc +*/ +enum NxShapeType + { + /** + \brief A physical plane + @see NxPlaneShape + */ + NX_SHAPE_PLANE, + + /** + \brief A physical sphere + @see NxSphereShape + */ + NX_SHAPE_SPHERE, + + /** + \brief A physical box (OBB) + @see NxBoxShape + */ + NX_SHAPE_BOX, + + /** + \brief A physical capsule (LSS) + @see NxCapsuleShape + */ + NX_SHAPE_CAPSULE, + + /** + \brief A wheel for raycast cars + @see NxWheelShape + */ + NX_SHAPE_WHEEL, + + /** + \brief A physical convex mesh + @see NxConvexShape NxConvexMesh + */ + NX_SHAPE_CONVEX, + + /** + \brief A physical mesh + @see NxTriangleMeshShape NxTriangleMesh + */ + NX_SHAPE_MESH, + + /** + \brief A physical height-field + @see NxHeightFieldShape NxHeightField + */ + NX_SHAPE_HEIGHTFIELD, + + /** + \brief internal use only! + + */ + NX_SHAPE_RAW_MESH, + + NX_SHAPE_COMPOUND, + + NX_SHAPE_COUNT, + + NX_SHAPE_FORCE_DWORD = 0x7fffffff + }; + +enum NxMeshShapeFlag + { + /** + \brief Select between "normal" or "smooth" sphere-mesh/raycastcapsule-mesh contact generation routines. + + The 'normal' algorithm assumes that the mesh is composed from flat triangles. + When a ball rolls or a raycast capsule slides along the mesh surface, it will experience small, + sudden changes in velocity as it rolls from one triangle to the next. The smooth algorithm, on + the other hand, assumes that the triangles are just an approximation of a surface that is smooth. + It uses the Gouraud algorithm to smooth the triangles' vertex normals (which in this + case are particularly important). This way the rolling sphere's/capsule's velocity will change + smoothly over time, instead of suddenly. We recommend this algorithm for simulating car wheels + on a terrain. + + @see NxSphereShape NxTriangleMeshShape NxHeightFieldShape + */ + NX_MESH_SMOOTH_SPHERE_COLLISIONS = (1<<0), + NX_MESH_DOUBLE_SIDED = (1<<1) //!< The mesh is double-sided. This is currently only used for raycasting. + }; + +/** +\brief Lets the user specify how to handle mesh paging to the PhysX card. + +It is always possible to manually upload mesh pages, also in the modes called "automatic". +Actually the "automatic" modes should preferrably be used in a half-automatic manner, +having the automaticy as a fallback if there are pages missing. + +Although it is possible to manually map pages, you can not override the automatic +page mapping by unmapping an automatically mapped page. The pages that are mapped +on the PhysX card have two reference counters; one for the user (manual mapping) and +one for the automatic mapping. Only when both references are removed is the page +removed. +*/ +enum NxMeshPagingMode + { + /** + \brief Manual mesh paging is the default, and it is up to the user to see to it that all + needed mesh pages are available on the PhysX card when they are needed. + + This mode should be the default choice, as it lets the developer prepare for scene + switches, by uploading new mesh data continously. + */ + NX_MESH_PAGING_MANUAL, + + /** + \brief [Experimental] An automatic fallback to SW collision testing when mesh pages are missing on the PhysX card. + + This mode uses SW collision methods when an interaction between a shape and a mesh shape is missing mesh pages. + The kind of constraints that are generated are both slower to generate, and takes more time to simulate. + + \warning This mesh paging method is still an experimental feature + */ + NX_MESH_PAGING_FALLBACK, + + /** + \brief [Experimental] Automatic paging of missing mesh pages. + + This mode checks which mesh pages are needed for each interaction between a mesh shape and another shape. + If the page is not available on the PhysX card, then it is uploaded. If it is not possible to upload the + mesh page (e.g. because the PhysX card is out of memory), then the SW fallback (see NX_MESH_PAGING_FALLBACK) + is used instead. + \warning This mesh paging method is still an experimental feature + */ + NX_MESH_PAGING_AUTO + }; + +enum NxCapsuleShapeFlag + { + /** + \brief If this flag is set, the capsule shape represents a moving sphere, + moving along the ray defined by the capsule's positive Y axis. + + Currently this behavior is only implemented for points (zero radius spheres). + + Note:Used only in conjunction with the old-style capsule based wheel shape (see + the Guide for more information). + */ + NX_SWEPT_SHAPE = (1<<0) + }; + +/** +\brief Parameter to addForce*() calls, determines the exact operation that is carried out. + +@see NxActor.addForce() NxActor.addTorque() +*/ +enum NxForceMode + { + NX_FORCE, //!< parameter has unit of mass * distance/ time^2, i.e. a force + NX_IMPULSE, //!< parameter has unit of mass * distance /time + NX_VELOCITY_CHANGE, //!< parameter has unit of distance / time, i.e. the effect is mass independent: a velocity change. + NX_SMOOTH_IMPULSE, //!< same as NX_IMPULSE but the effect is applied over all substeps. Use this for motion controllers that repeatedly apply an impulse. + NX_SMOOTH_VELOCITY_CHANGE, //!< same as NX_VELOCITY_CHANGE but the effect is applied over all substeps. Use this for motion controllers that repeatedly apply an impulse. + NX_ACCELERATION //!< parameter has unit of distance/ time^2, i.e. an acceleration. It gets treated just like a force except the mass is not divided out before integration. + }; + +#define NX_SLEEP_INTERVAL (20.0f*0.02f) // Corresponds to 20 frames for the standard time step. +//#define NX_SLEEP_INTERVAL (999999999.0f) + + +/** +\brief Collection of flags describing the behavior of a dynamic rigid body. + +@see NxBodyDesc NxActor NxActorDesc +*/ +enum NxBodyFlag + { + /** + \brief Set if gravity should not be applied on this body + + @see NxBodyDesc.flags NxScene.setGravity() + */ + NX_BF_DISABLE_GRAVITY = (1<<0), + + /** + \brief Enable/disable freezing for this body/actor. + + \note This is an EXPERIMENTAL feature which doesn't always work on in all situations, e.g. + for actors which have joints connected to them. + + To freeze an actor is a way to simulate that it is static. The actor is however still simulated + as if it was dynamic, it's position is just restored after the simulation has finished. A much + more stable way to make an actor temporarily static is to raise the NX_BF_KINEMATIC flag. + */ + NX_BF_FROZEN_POS_X = (1<<1), + NX_BF_FROZEN_POS_Y = (1<<2), + NX_BF_FROZEN_POS_Z = (1<<3), + NX_BF_FROZEN_ROT_X = (1<<4), + NX_BF_FROZEN_ROT_Y = (1<<5), + NX_BF_FROZEN_ROT_Z = (1<<6), + NX_BF_FROZEN_POS = NX_BF_FROZEN_POS_X|NX_BF_FROZEN_POS_Y|NX_BF_FROZEN_POS_Z, + NX_BF_FROZEN_ROT = NX_BF_FROZEN_ROT_X|NX_BF_FROZEN_ROT_Y|NX_BF_FROZEN_ROT_Z, + NX_BF_FROZEN = NX_BF_FROZEN_POS|NX_BF_FROZEN_ROT, + + + /** + \brief Enables kinematic mode for the actor. + + Kinematic actors are special dynamic actors that are not + influenced by forces (such as gravity), and have no momentum. They are considered to have infinite + mass and can be moved around the world using the moveGlobal*() methods. They will push + regular dynamic actors out of the way. Kinematics will not collide with static or other kinematic objects. + + Kinematic actors are great for moving platforms or characters, where direct motion control is desired. + + You can not connect Reduced joints to kinematic actors. Lagrange joints work ok if the platform + is moving with a relatively low, uniform velocity. + + @see NxActor NxActor.raiseActorFlag() + */ + NX_BF_KINEMATIC = (1<<7), //!< Enable kinematic mode for the body. + + /** + \brief Enable debug renderer for this body + + @see NxScene.getDebugRenderable() NxDebugRenderable NxParameter + */ + NX_BF_VISUALIZATION = (1<<8), + + NX_BF_DUMMY_0 = (1<<9), // deprecated flag placeholder + + /** + \brief Filter velocities used keep body awake. The filter reduces rapid oscillations and transient spikes. + @see NxActor.isSleeping() + */ + NX_BF_FILTER_SLEEP_VEL = (1<<10), + + /** + \brief Enables energy-based sleeping algorithm. + @see NxActor.isSleeping() NxBodyDesc.sleepEnergyThreshold + */ + NX_BF_ENERGY_SLEEP_TEST = (1<<11), + }; + + +/** +\brief Flags which affect the behavior of NxShapes. + +@see NxShape NxShapeDesc NxShape.setFlag() +*/ +enum NxShapeFlag + { + /** + \brief Trigger callback will be called when a shape enters the trigger volume. + + @see NxUserTriggerReport NxScene.setUserTriggerReport() + */ + NX_TRIGGER_ON_ENTER = (1<<0), + + /** + \brief Trigger callback will be called after a shape leaves the trigger volume. + + @see NxUserTriggerReport NxScene.setUserTriggerReport() + */ + NX_TRIGGER_ON_LEAVE = (1<<1), + + /** + \brief Trigger callback will be called while a shape is intersecting the trigger volume. + + @see NxUserTriggerReport NxScene.setUserTriggerReport() + */ + NX_TRIGGER_ON_STAY = (1<<2), + + /** + \brief Combination of all the other trigger enable flags. + + @see NxUserTriggerReport NxScene.setUserTriggerReport() + */ + NX_TRIGGER_ENABLE = NX_TRIGGER_ON_ENTER|NX_TRIGGER_ON_LEAVE|NX_TRIGGER_ON_STAY, + + /** + \brief Enable debug renderer for this shape + + @see NxScene.getDebugRenderable() NxDebugRenderable NxParameter + */ + NX_SF_VISUALIZATION = (1<<3), + + /** + \brief Disable collision detection for this shape (counterpart of NX_AF_DISABLE_COLLISION) + + \warning IMPORTANT: this is only used for compound objects! Use NX_AF_DISABLE_COLLISION otherwise. + */ + NX_SF_DISABLE_COLLISION = (1<<4), + + /** + \brief Enable feature indices in contact stream. + + @see NxUserContactReport NxContactStreamIterator NxContactStreamIterator.getFeatureIndex0() + */ + NX_SF_FEATURE_INDICES = (1<<5), + + /** + \brief Disable raycasting for this shape + */ + NX_SF_DISABLE_RAYCASTING = (1<<6), + + /** + \brief Enable contact force reporting per contact point in contact stream (otherwise we only report force per actor pair) + */ + NX_SF_POINT_CONTACT_FORCE = (1<<7), + + NX_SF_FLUID_DRAIN = (1<<8), //!< Sets the shape to be a fluid drain. + NX_SF_FLUID_DISABLE_COLLISION = (1<<10), //!< Disable collision with fluids. + NX_SF_FLUID_TWOWAY = (1<<11), //!< Enables the reaction of the shapes actor on fluid collision. + + /** + \brief Disable collision response for this shape (counterpart of NX_AF_DISABLE_RESPONSE) + + \warning not supported by cloth / soft bodies + */ + NX_SF_DISABLE_RESPONSE = (1<<12), + + /** + \brief Enable dynamic-dynamic CCD for this shape. Used only when CCD is globally enabled and shape have a CCD skeleton. + */ + NX_SF_DYNAMIC_DYNAMIC_CCD = (1<<13), + + /** + \brief Disable participation in ray casts, overlap tests and sweeps. + + NOTE: Setting this flag for static non-trigger shapes may cause incorrect behavior for + colliding fluid and cloth. + */ + NX_SF_DISABLE_SCENE_QUERIES = (1<<14), + + NX_SF_CLOTH_DRAIN = (1<<15), //!< Sets the shape to be a cloth drain. + NX_SF_CLOTH_DISABLE_COLLISION = (1<<16), //!< Disable collision with cloths. + + /** + \brief Enables the reaction of the shapes actor on cloth collision. + \warning Compound objects cannot use a different value for each constituent shape. + */ + NX_SF_CLOTH_TWOWAY = (1<<17), + + NX_SF_SOFTBODY_DRAIN = (1<<18), //!< Sets the shape to be a soft body drain. + NX_SF_SOFTBODY_DISABLE_COLLISION = (1<<19), //!< Disable collision with soft bodies. + + /** + \brief Enables the reaction of the shapes actor on soft body collision. + \warning Compound objects cannot use a different value for each constituent shape. + */ + NX_SF_SOFTBODY_TWOWAY = (1<<20), + }; + +/** +\brief For compatibility with previous SDK versions before 2.1.1 + +@see NxShapeFlag +*/ +typedef NxShapeFlag NxTriggerFlag; + + +/** +\brief Specifies which axis is the "up" direction for a heightfield. +*/ +enum NxHeightFieldAxis + { + NX_X = 0, //!< X Axis + NX_Y = 1, //!< Y Axis + NX_Z = 2, //!< Z Axis + NX_NOT_HEIGHTFIELD = 0xff //!< Not a heightfield + }; + +/** +\brief Compatability/readability typedef. + +@see NxVec3 +*/ +typedef NxVec3 NxPoint; + +/** +\brief Structure used to store indices for a triangles points. +*/ +struct NxTriangle32 + { + NX_INLINE NxTriangle32() {} + NX_INLINE NxTriangle32(NxU32 a, NxU32 b, NxU32 c) { v[0] = a; v[1] = b; v[2] = c; } + + NxU32 v[3]; //vertex indices + }; + +/** +\brief Structure used to store actor group pair flags. +*/ + +struct NxActorGroupPair + { + NxActorGroup group0; + NxActorGroup group1; + NxU32 flags; + }; + +/** +\brief Expresses the dominance relationship of a constraint. +For the time being only three settings are permitted: + +(1.0f, 1.0f), (0.0f, 1.0f), and (1.0f, 0.0f). +*/ + +struct NxConstraintDominance + { + NxConstraintDominance(NxReal a, NxReal b) : dominance0(a), dominance1(b) {} + NxReal dominance0; + NxReal dominance1; + }; + +/** +\brief Typedef for submesh indexing. +@see NxTriangleMesh NxConvexMesh +*/ +typedef NxU32 NxSubmeshIndex; + +/** +\brief Enum to access internal data structures for triangle meshes and convex meshes. + +@see NxTriangleMesh.getFormat() NxConvexMesh.getFormat() +*/ +enum NxInternalFormat + { + NX_FORMAT_NODATA, //!< No data available + NX_FORMAT_FLOAT, //!< Data is in floating-point format + NX_FORMAT_BYTE, //!< Data is in byte format (8 bit) + NX_FORMAT_SHORT, //!< Data is in short format (16 bit) + NX_FORMAT_INT, //!< Data is in int format (32 bit) + }; + +/** +\brief Enum to access internal data structures for triangle meshes and convex meshes. + +@see NxTriangleMesh.getBase() NxConvexMesh.getBase() +*/ +enum NxInternalArray + { + NX_ARRAY_TRIANGLES, //!< Array of triangles (index buffer). One triangle = 3 vertex references in returned format. + NX_ARRAY_VERTICES, //!< Array of vertices (vertex buffer). One vertex = 3 coordinates in returned format. + NX_ARRAY_NORMALS, //!< Array of vertex normals. One normal = 3 coordinates in returned format. + NX_ARRAY_HULL_VERTICES, //!< Array of hull vertices. One vertex = 3 coordinates in returned format. + NX_ARRAY_HULL_POLYGONS, //!< Array of hull polygons + NX_ARRAY_TRIANGLES_REMAP, //!< Array of triangle remap indices. One triangle index = 1 original triangle index in returned format. (NxTriangleMesh only). + }; + +/** +\brief Identifies each type of joint. + +@see NxJoint NxJointDesc NxScene.createJoint() +*/ +enum NxJointType + { + /** + \brief Permits a single translational degree of freedom. + + @see NxPrismaticJoint + */ + NX_JOINT_PRISMATIC, + + /** + \brief Also known as a hinge joint, permits one rotational degree of freedom. + + @see NxRevoluteJoint + */ + NX_JOINT_REVOLUTE, + + /** + \brief Formerly known as a sliding joint, permits one translational and one rotational degree of freedom. + + @see NxCylindricalJoint + */ + NX_JOINT_CYLINDRICAL, + + /** + \brief Also known as a ball or ball and socket joint. + + @see NxSphericalJoint + */ + NX_JOINT_SPHERICAL, + + /** + \brief A point on one actor is constrained to stay on a line on another. + + @see NxPointOnLineJoint + */ + NX_JOINT_POINT_ON_LINE, + + /** + \brief A point on one actor is constrained to stay on a plane on another. + + @see NxPointInPlaneJoint + */ + NX_JOINT_POINT_IN_PLANE, + + /** + \brief A point on one actor maintains a certain distance range to another point on another actor. + + @see NxDistanceJoint + */ + NX_JOINT_DISTANCE, + + /** + \brief A pulley joint. + + @see NxPulleyJoint + */ + NX_JOINT_PULLEY, + + /** + \brief A "fixed" connection. + + @see NxFixedJoint + */ + NX_JOINT_FIXED, + + /** + \brief A 6 degree of freedom joint + + @see NxD6Joint + */ + NX_JOINT_D6, + + NX_JOINT_COUNT, //!< Just to track the number of available enum values. Not a joint type. + NX_JOINT_FORCE_DWORD = 0x7fffffff + }; + +/** +\brief Describes the state of the joint. + +@see NxJoint +*/ +enum NxJointState + { + /** + \brief Not used. + */ + NX_JS_UNBOUND, + + /** + \brief The joint is being simulated under normal conditions. I.e. it is not broken or deleted. + */ + NX_JS_SIMULATING, + + /** + \brief Set when the joint has been broken or one of the actors connected to the joint has been remove. + @see NxUserNotify.onJointBreak() NxJoint.setBreakable() + */ + NX_JS_BROKEN + }; + +/** +\brief Joint flags. + +@see NxJoint NxJointDesc +*/ +enum NxJointFlag + { + /** + \brief Raised if collision detection should be enabled between the bodies attached to the joint. + + By default collision constraints are not generated between pairs of bodies which are connected by joints. + */ + NX_JF_COLLISION_ENABLED = (1<<0), + + /** + \brief Enable debug renderer for this joint + + @see NxScene.getDebugRenderable() NxDebugRenderable NxParameter + */ + NX_JF_VISUALIZATION = (1<<1), + }; + +/** +\brief Joint projection modes. + +Joint projection is a method for correcting large joint errors. + +It is also necessary to set the distance above which projection occurs. + +@see NxRevoluteJointDesc.projectionMode NxRevoluteJointDesc.projectionDistance NxRevoluteJointDesc.projectionAngle +@see NxSphericalJointDesc.projectionMode +@see NxD6JointDesc.projectionMode +*/ +enum NxJointProjectionMode + { + NX_JPM_NONE = 0, //!< don't project this joint + NX_JPM_POINT_MINDIST = 1, //!< linear and angular minimum distance projection + NX_JPM_LINEAR_MINDIST = 2, //!< linear only minimum distance projection + //there may be more modes later + }; + +/** +\brief Flags to control the behavior of revolute joints. + +@see NxRevoluteJoint NxRevoluteJointDesc +*/ +enum NxRevoluteJointFlag + { + /** + \brief true if limits is enabled + + @see NxRevoluteJointDesc.limit + */ + NX_RJF_LIMIT_ENABLED = 1 << 0, + + /** + \brief true if the motor is enabled + + @see NxRevoluteJoint.motor + */ + NX_RJF_MOTOR_ENABLED = 1 << 1, + + /** + \brief true if the spring is enabled. The spring will only take effect if the motor is disabled. + + @see NxRevoluteJoint.spring + */ + NX_RJF_SPRING_ENABLED = 1 << 2, + }; + +/** +\brief Flags to control the behavior of pulley joints. + +@see NxPulleyJoint NxPulleyJointDesc NxPulleyJoint.setFlags() +*/ +enum NxPulleyJointFlag + { + /** + \brief true if the joint also maintains a minimum distance, not just a maximum. + */ + NX_PJF_IS_RIGID = 1 << 0, + + /** + \brief true if the motor is enabled + + @see NxPulleyJointDesc.motor + */ + NX_PJF_MOTOR_ENABLED = 1 << 1 + }; + +/** +\brief Flags which control the behavior of distance joints. + +@see NxDistanceJoint NxDistanceJointDesc NxDistanceJointDesc.flags +*/ +enum NxDistanceJointFlag + { + /** + \brief true if the joint enforces the maximum separate distance. + */ + NX_DJF_MAX_DISTANCE_ENABLED = 1 << 0, + + /** + \brief true if the joint enforces the minimum separate distance. + */ + NX_DJF_MIN_DISTANCE_ENABLED = 1 << 1, + + /** + \brief true if the spring is enabled + + @see NxDistanceJointDesc.spring + */ + NX_DJF_SPRING_ENABLED = 1 << 2, + }; + +/** +\brief Used to specify the range of motions allowed for a DOF in a D6 joint. + +@see NxD6Joint NxD6JointDesc +@see NxD6Joint.xMotion NxD6Joint.swing1Motion +*/ +enum NxD6JointMotion + { + NX_D6JOINT_MOTION_LOCKED, //!< The DOF is locked, it does not allow relative motion. + NX_D6JOINT_MOTION_LIMITED, //!< The DOF is limited, it only allows motion within a specific range. + NX_D6JOINT_MOTION_FREE //!< The DOF is free and has its full range of motions. + }; + + +/** +\brief Used to specify a particular drive method. i.e. Having a position based goal or a velocity based goal. +*/ +enum NxD6JointDriveType + { + /** + \brief Used to set a position goal when driving. + + Note: the appropriate target positions/orientations should be set. + + @see NxD6JointDesc.xDrive NxD6Joint.swingDrive NxD6JointDesc.drivePosition + */ + NX_D6JOINT_DRIVE_POSITION = 1<<0, + + /** + \brief Used to set a velocity goal when driving. + + Note: the appropriate target velocities should beset. + + @see NxD6JointDesc.xDrive NxD6Joint.swingDrive NxD6JointDesc.driveLinearVelocity + */ + NX_D6JOINT_DRIVE_VELOCITY = 1<<1 + }; + +/** +\brief Flags which control the general behavior of D6 joints. + +@see NxD6Joint NxD6JointDesc NxD6JointDesc.flags +*/ +enum NxD6JointFlag + { + /** + \brief Drive along the shortest spherical arc. + + @see NxD6JointDesc.slerpDrive + */ + NX_D6JOINT_SLERP_DRIVE = 1<<0, + /** + \brief Apply gearing to the angular motion, e.g. body 2s angular motion is twice body 1s etc. + + @see NxD6JointDesc.gearRatio + */ + NX_D6JOINT_GEAR_ENABLED = 1<<1 + }; + +/** +\brief Flags which control the behavior of an actor. + +@see NxActor NxActorDesc NxActor.raiseBodyFlag() +*/ +enum NxActorFlag + { + /** + \brief Enable/disable collision detection + + Turn off collision detection, i.e. the actor will not collide with other objects. Please note that you might need to wake + the actor up if it is sleeping, this depends on the result you wish to get when using this flag. (If a body is asleep it + will not start to fall through objects unless you activate it). + + Note: Also excludes the actor from overlap tests! + */ + NX_AF_DISABLE_COLLISION = (1<<0), + + /** + \brief Enable/disable collision response (reports contacts but don't use them) + + @see NxUserContactReport + */ + NX_AF_DISABLE_RESPONSE = (1<<1), + + /** + \brief Disables COM update when computing inertial properties at creation time. + + When sdk computes inertial properties, by default the center of mass will be calculated too. However, if lockCOM is set to a non-zero (true) value then the center of mass will not be altered. + */ + NX_AF_LOCK_COM = (1<<2), + + /** + \brief Enable/disable collision with fluid. + */ + NX_AF_FLUID_DISABLE_COLLISION = (1<<3), + + /** + \brief Turn on contact modification callback for the actor. + + @see NxScene.setUserContactModify(), NX_NOTIFY_CONTACT_MODIFICATION + */ + NX_AF_CONTACT_MODIFICATION = (1<<4), + + + /** + \brief Force cone friction to be used for this actor. + + This ensures that all contacts involving the actor will use cone friction, rather than the default + simplified scheme. This will however have a negative impact on performance in software scenes. Use this + flag if sliding objects show an affinity for moving along the world axes. + + \note Only applies to software scenes. Hardware scenes always force cone friction. + + Cone friction may also be applied wholesale to a scene using the NX_SF_FORCE_CONE_FRICTION + flag, see #NxSceneFlags. + */ + NX_AF_FORCE_CONE_FRICTION = (1<<5), + + /** + \brief Enable/disable custom contact filtering. + + When enabled the user will be queried for contact filtering for all contacts involving this actor. + */ + NX_AF_USER_ACTOR_PAIR_FILTERING = (1<<6) + }; + +/** +\brief Flags which control the properties of a scene compartment. + +@see NxScene NxCompartmentDesc +*/ +enum NxCompartmentFlag + { + /** + \brief Enable/disable sleep event reporting + + If sleep notification is enabled for the compartment, onWake and onSleep will be called on the NxUserNotify associated with the master scene, if non-null. + Note that onWake and onSleep will be called one time for each compartment with sleep notification enabled, + i.e. not only once with all sleeping/awake bodies from all compartments. + + @see NxUserNotify + */ + NX_CF_SLEEP_NOTIFICATION = (1<<0), + + /** + \brief Enable/disable continuous collision detection on the compartment. + + @see NxPhysicsSDK.createCCDSkeleton() + */ + NX_CF_CONTINUOUS_CD = (1<<1), + + /** + \brief Enable Restricted Scene on the compartment. + + \note Only applies to hardware scenes. + \note This flag is immutable and can hence only be set at creation. + + @see NX_SF_RESTRICTED_SCENE + */ + NX_CF_RESTRICTED_SCENE = (1<<2), + + /** + \brief Inherit NX_CF_CONTINUOUS_CD and NX_CF_RESTRICTED_SCENE. + + Override the NX_CF_CONTINUOUS_CD and NX_CF_RESTRICTED_SCENE and inherit these settings from the SDK parameters and the + primary scene respectively (i.e. NX_CONTINUOUS_CD and NX_SF_RESTRICTED_SCENE). + */ + NX_CF_INHERIT_SETTINGS = (1<<3) + }; + +/** +\brief Flags which control the behavior of spherical joints. + +@see NxSphericalJoint NxSphericalJointDesc NxSphericalJointDesc.flags +*/ +enum NxSphericalJointFlag + { + /** + \brief true if the twist limit is enabled + + @see NxSphericalJointDesc.twistLimit + */ + NX_SJF_TWIST_LIMIT_ENABLED = 1 << 0, + + /** + \brief true if the swing limit is enabled + + @see NxSphericalJointDesc.swingLimit + */ + NX_SJF_SWING_LIMIT_ENABLED = 1 << 1, + + /** + \brief true if the twist spring is enabled + + @see NxSphericalJointDesc.twistSpring + */ + NX_SJF_TWIST_SPRING_ENABLED= 1 << 2, + + /** + \brief true if the swing spring is enabled + + @see NxSphericalJointDesc.swingSpring + */ + NX_SJF_SWING_SPRING_ENABLED= 1 << 3, + + /** + \brief true if the joint spring is enabled + + @see NxSphericalJointDesc.jointSpring + + */ + NX_SJF_JOINT_SPRING_ENABLED= 1 << 4, + + /** + \brief Add additional constraints to linear movement. + + Constrain movements along directions perpendicular to the distance vector defined by the two anchor points. + + \note Setting this flag can increase the stability of the joint but the computation will be more expensive. + */ + NX_SJF_PERPENDICULAR_DIR_CONSTRAINTS = 1 << 5, + }; + +/** +\brief Used to control contact queries. + +@see NxTriangleMeshShape.overlapAABBTriangles() +*/ +enum NxQueryFlags + { + NX_QUERY_WORLD_SPACE = (1<<0), //!< world-space parameter, else object space + NX_QUERY_FIRST_CONTACT = (1<<1), //!< returns first contact only, else returns all contacts + }; + +/** +\brief Flags which are set for convex edges. + +Must be the 3 first ones to be indexed by (flags & (1<Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_PENALTY_FORCE = 0, + + /** + \brief Default value for ::NxShapeDesc::skinWidth, see for more info. + + Range: [0, inf)
+ Default: 0.025
+ Unit: distance. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShapeDesc.skinWidth + */ + NX_SKIN_WIDTH = 1, + + + /** + \brief The default linear velocity, squared, below which objects start going to sleep. + Note: Only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. + + Range: [0, inf)
+ Default: (0.15*0.15) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Sleep behavior on hardware is different) + \li PS3 : Yes + \li XB360: Yes + */ + NX_DEFAULT_SLEEP_LIN_VEL_SQUARED = 2, + + /** + \brief The default angular velocity, squared, below which objects start going to sleep. + Note: Only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. + + Range: [0, inf)
+ Default: (0.14*0.14) + + Platform: + \li PC SW: Yes + \li PPU : Yes (Sleep behavior on hardware is different) + \li PS3 : Yes + \li XB360: Yes + */ + NX_DEFAULT_SLEEP_ANG_VEL_SQUARED = 3, + + + /** + \brief A contact with a relative velocity below this will not bounce. + + Range: (-inf, 0]
+ Default: -2 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterial + */ + NX_BOUNCE_THRESHOLD = 4, + + /** + \brief This lets the user scale the magnitude of the dynamic friction applied to all objects. + + Range: [0, inf)
+ Default: 1 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterial + */ + NX_DYN_FRICT_SCALING = 5, + + /** + \brief This lets the user scale the magnitude of the static friction applied to all objects. + + Range: [0, inf)
+ Default: 1 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMaterial + */ + NX_STA_FRICT_SCALING = 6, + + + /** + \brief See the comment for NxActor::setMaxAngularVelocity() for details. + + Range: [0, inf)
+ Default: 7 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc.setMaxAngularVelocity() + */ + NX_MAX_ANGULAR_VELOCITY = 7, + +/* Collision-related parameters: */ + + + /** + \brief Enable/disable continuous collision detection (0.0f to disable) + + Range: [0, inf)
+ Default: 0.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPhysicsSDK.createCCDSkeleton() + */ + NX_CONTINUOUS_CD = 8, + + /** + \brief This overall visualization scale gets multiplied with the individual scales. Setting to zero turns ignores all visualizations. Default is 0. + + The below settings permit the debug visualization of various simulation properties. + The setting is either zero, in which case the property is not drawn. Otherwise it is a scaling factor + that determines the size of the visualization widgets. + + Only bodies and joints for which visualization is turned on using setFlag(VISUALIZE) are visualized. + Contacts are visualized if they involve a body which is being visualized. + Default is 0. + + Notes: + - to see any visualization, you have to set NX_VISUALIZATION_SCALE to nonzero first. + - the scale factor has been introduced because it's difficult (if not impossible) to come up with a + good scale for 3D vectors. Normals are normalized and their length is always 1. But it doesn't mean + we should render a line of length 1. Depending on your objects/scene, this might be completely invisible + or extremely huge. That's why the scale factor is here, to let you tune the length until it's ok in + your scene. + - however, things like collision shapes aren't ambiguous. They are clearly defined for example by the + triangles & polygons themselves, and there's no point in scaling that. So the visualization widgets + are only scaled when it makes sense. + + Range: [0, inf)
+ Default: 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes (only a subset of visualizations are supported) + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZATION_SCALE = 9, + + + /** + \brief Visualize the world axes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_WORLD_AXES = 10, + +/* Body visualizations */ + + /** + \brief Visualize a bodies axes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor.globalPose NxActor + */ + NX_VISUALIZE_BODY_AXES = 11, + + /** + \brief Visualize a body's mass axes. + + This visualization is also useful for visualizing the sleep state of bodies. Sleeping bodies are drawn in + black, while awake bodies are drawn in white. If the body is sleeping and part of a sleeping group, it is + drawn in red. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc.massLocalPose NxActor + */ + NX_VISUALIZE_BODY_MASS_AXES = 12, + + /** + \brief Visualize the bodies linear velocity. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc.linearVelocity NxActor + */ + NX_VISUALIZE_BODY_LIN_VELOCITY = 13, + + /** + \brief Visualize the bodies angular velocity. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBodyDesc.angularVelocity NxActor + */ + NX_VISUALIZE_BODY_ANG_VELOCITY = 14, + +/* + Obsolete parameters + NX_VISUALIZE_BODY_LIN_MOMENTUM = 15, + NX_VISUALIZE_BODY_ANG_MOMENTUM = 16, + NX_VISUALIZE_BODY_LIN_ACCEL = 17, + NX_VISUALIZE_BODY_ANG_ACCEL = 18, + NX_VISUALIZE_BODY_LIN_FORCE = 19, + NX_VISUALIZE_BODY_ANG_FORCE = 20, + NX_VISUALIZE_BODY_REDUCED = 21, +*/ + + /** + \brief Visualize joint groups + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_BODY_JOINT_GROUPS = 22, + +/* Obsolete parameters + NX_VISUALIZE_BODY_CONTACT_LIST = 23, + NX_VISUALIZE_BODY_JOINT_LIST = 24, + NX_VISUALIZE_BODY_DAMPING = 25, + NX_VISUALIZE_BODY_SLEEP = 26, +*/ + +/* Joint visualisations */ + /** + \brief Visualize local joint axes (including drive targets, if any) + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJointDesc.localAxis NxJoint + */ + NX_VISUALIZE_JOINT_LOCAL_AXES = 27, + + /** + \brief Visualize joint world axes. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint + */ + NX_VISUALIZE_JOINT_WORLD_AXES = 28, + + /** + \brief Visualize joint limits. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxJoint + */ + NX_VISUALIZE_JOINT_LIMITS = 29, + +/* Obsolete parameters + NX_VISUALIZE_JOINT_ERROR = 30, + NX_VISUALIZE_JOINT_FORCE = 31, + NX_VISUALIZE_JOINT_REDUCED = 32, +*/ + +/* Contact visualisations */ + + /** + \brief Visualize contact points. Will enable contact information. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_CONTACT_POINT = 33, + + /** + \brief Visualize contact normals. Will enable contact information. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_CONTACT_NORMAL = 34, + + /** + \brief Visualize contact errors. Will enable contact information. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_CONTACT_ERROR = 35, + + /** + \brief Visualize Contact forces. Will enable contact information. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_CONTACT_FORCE = 36, + + + /** + \brief Visualize actor axes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxActor + */ + NX_VISUALIZE_ACTOR_AXES = 37, + + + /** + \brief Visualize bounds (AABBs in world space) + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_COLLISION_AABBS = 38, + + /** + \brief Shape visualization + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxShape + */ + NX_VISUALIZE_COLLISION_SHAPES = 39, + + /** + \brief Shape axis visualization + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxShape + */ + NX_VISUALIZE_COLLISION_AXES = 40, + + /** + \brief Compound visualization (compound AABBs in world space) + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_COLLISION_COMPOUNDS = 41, + + /** + \brief Mesh & convex vertex normals + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh NxConvexMesh + */ + NX_VISUALIZE_COLLISION_VNORMALS = 42, + + /** + \brief Mesh & convex face normals + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh NxConvexMesh + */ + NX_VISUALIZE_COLLISION_FNORMALS = 43, + + /** + \brief Active edges for meshes + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxTriangleMesh + */ + NX_VISUALIZE_COLLISION_EDGES = 44, + + /** + \brief Bounding spheres + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_COLLISION_SPHERES = 45, + +/* Obsolete parameter + NX_VISUALIZE_COLLISION_SAP = 46, +*/ + + /** + \brief Static pruning structures + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_COLLISION_STATIC = 47, + + /** + \brief Dynamic pruning structures + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_COLLISION_DYNAMIC = 48, + + /** + \brief "Free" pruning structures + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_COLLISION_FREE = 49, + + /** + \brief Visualize the CCD tests + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPhysicsSDK.createCCDSkeleton() + */ + NX_VISUALIZE_COLLISION_CCD = 50, + + /** + \brief Visualize CCD Skeletons + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxPhysicsSDK.createCCDSkeleton() + */ + NX_VISUALIZE_COLLISION_SKELETONS = 51, + +/* Fluid visualizations */ + /** + \brief Emitter visualization. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_FLUID_EMITTERS = 52, + + /** + \brief Particle position visualization. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_FLUID_POSITION = 53, + + /** + \brief Particle velocity visualization. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_FLUID_VELOCITY = 54, + + /** + \brief Particle kernel radius visualization. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_FLUID_KERNEL_RADIUS = 55, + + /** + \brief Fluid AABB visualization. + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_VISUALIZE_FLUID_BOUNDS = 56, + + /** + \brief Fluid Packet visualization. + */ + NX_VISUALIZE_FLUID_PACKETS = 57, + + /** + \brief Fluid motion limit visualization. + */ + NX_VISUALIZE_FLUID_MOTION_LIMIT = 58, + + /** + \brief Fluid dynamic collision visualization. + */ + NX_VISUALIZE_FLUID_DYN_COLLISION = 59, + + /** + \brief Fluid static collision visualization. + */ + NX_VISUALIZE_FLUID_STC_COLLISION = 60, + + /** + \brief Fluid available mesh packets visualization. + */ + NX_VISUALIZE_FLUID_MESH_PACKETS = 61, + + /** + \brief Fluid drain shape visualization. + */ + NX_VISUALIZE_FLUID_DRAINS = 62, + + /** + \brief Fluid Packet Data visualization. + */ + NX_VISUALIZE_FLUID_PACKET_DATA = 90, + +/* Cloth visualizations */ + /** + \brief Cloth mesh visualization. + */ + NX_VISUALIZE_CLOTH_MESH = 63, + + /** + \brief Cloth rigid body collision visualization. + */ + NX_VISUALIZE_CLOTH_COLLISIONS = 64, + + /** + \brief Cloth cloth collision visualization. + */ + NX_VISUALIZE_CLOTH_SELFCOLLISIONS = 65, + + /** + \brief Cloth clustering for the PPU simulation visualization. + */ + NX_VISUALIZE_CLOTH_WORKPACKETS = 66, + + /** + \brief Cloth overall sleeping visualization. + */ + NX_VISUALIZE_CLOTH_SLEEP = 67, + + /** + \brief Cloth per vertex sleeping visualization. + */ + NX_VISUALIZE_CLOTH_SLEEP_VERTEX = 94, + + /** + \brief Cloth tearable vertices visualization. + */ + NX_VISUALIZE_CLOTH_TEARABLE_VERTICES = 80, + + /** + \brief Cloth tearing visualization. + */ + NX_VISUALIZE_CLOTH_TEARING = 81, + + /** + \brief Cloth attachments visualization. + */ + NX_VISUALIZE_CLOTH_ATTACHMENT = 82, + + /** + \brief Cloth valid bounds visualization. + */ + NX_VISUALIZE_CLOTH_VALIDBOUNDS = 92, + +/* SoftBody visualizations */ + /** + \brief Soft body mesh visualization. + */ + NX_VISUALIZE_SOFTBODY_MESH = 83, + + /** + \brief Soft body rigid body collision visualization. + */ + NX_VISUALIZE_SOFTBODY_COLLISIONS = 84, + + /** + \brief Soft body clustering for the PPU simulation visualization. + */ + NX_VISUALIZE_SOFTBODY_WORKPACKETS = 85, + + /** + \brief Soft body overall sleeping visualization. + */ + NX_VISUALIZE_SOFTBODY_SLEEP = 86, + + /** + \brief Soft body per vertex sleeping visualization. + */ + NX_VISUALIZE_SOFTBODY_SLEEP_VERTEX = 95, + + /** + \brief Soft body tearable vertices visualization. + */ + NX_VISUALIZE_SOFTBODY_TEARABLE_VERTICES = 87, + + /** + \brief Soft body tearing visualization. + */ + NX_VISUALIZE_SOFTBODY_TEARING = 88, + + /** + \brief Soft body attachments visualization. + */ + NX_VISUALIZE_SOFTBODY_ATTACHMENT = 89, + + /** + \brief Soft body valid bounds visualization. + */ + NX_VISUALIZE_SOFTBODY_VALIDBOUNDS = 93, + +/* General parameters and new parameters */ + + /** + \brief Used to enable adaptive forces to accelerate convergence of the solver. + + Range: [0, inf)
+ Default: 1.0 + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + */ + NX_ADAPTIVE_FORCE = 68, + + /** + \brief Controls default filtering for jointed bodies. True means collision is disabled. + + Range: {true, false}
+ Default: true + + @see NX_JF_COLLISION_ENABLED + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_COLL_VETO_JOINTED = 69, + + /** + \brief Controls whether two touching triggers generate a callback or not. + + Range: {true, false}
+ Default: true + + Platform: + \li PC SW: Yes + \li PPU : No + \li PS3 : Yes + \li XB360: Yes + + @see NxUserTriggerReport + */ + NX_TRIGGER_TRIGGER_CALLBACK = 70, + + /** + \brief Internal, used for debugging and testing. Not to be used. + */ + NX_SELECT_HW_ALGO = 71, + + /** + \brief Internal, used for debugging and testing. Not to be used. + */ + NX_VISUALIZE_ACTIVE_VERTICES = 72, + + /** + \brief Distance epsilon for the CCD algorithm. + + Range: [0, inf)
+ Default: 0.01 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_CCD_EPSILON = 73, + + /** + \brief Used to accelerate solver. + + Range: [0, inf)
+ Default: 0 + + Platform: + \li PC SW: No + \li PPU : Yes + \li PS3 : No + \li XB360: No + */ + NX_SOLVER_CONVERGENCE_THRESHOLD = 74, + + /** + \brief Used to accelerate HW Broad Phase. + + Range: [0, inf)
+ Default: 0.001 + + Platform: + \li PC SW: No + \li PPU : Yes + \li PS3 : No + \li XB360: No + */ + NX_BBOX_NOISE_LEVEL = 75, + + /** + \brief Used to set the sweep cache size. + + Range: [0, inf)
+ Default: 5.0 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_IMPLICIT_SWEEP_CACHE_SIZE = 76, + + /** + \brief The default sleep energy threshold. Objects with an energy below this threshold are allowed + to go to sleep. + Note: Only used when the NX_BF_ENERGY_SLEEP_TEST flag is set. + + Range: [0, inf)
+ Default: 0.005 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_DEFAULT_SLEEP_ENERGY = 77, + + /** + \brief Constant for the maximum number of packets per fluid. Used to compute the fluid packet buffer size in NxFluidPacketData. + + Range: [925, 925]
+ Default: 925 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidPacketData + */ + NX_CONSTANT_FLUID_MAX_PACKETS = 78, + + /** + \brief Constant for the maximum number of new fluid particles per frame. + Range: [4096, 4096]
+ Default: 4096 + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_CONSTANT_FLUID_MAX_PARTICLES_PER_STEP = 79, + + /** + \brief Force field visualization. + */ + NX_VISUALIZE_FORCE_FIELDS = 91, + + /** + \brief [Experimental] Disables scene locks when creating/releasing meshes. + + Prevents the SDK from locking all scenes when creating and releasing triangle meshes, convex meshes, height field + meshes, softbody meshes and cloth meshes, which is the default behavior. Can be used to improve parallelism but beware + of possible side effects. + + \warning Experimental feature. + */ + NX_ASYNCHRONOUS_MESH_CREATION = 96, + + /** + \brief Epsilon for custom force field kernels. + + This epsilon is used in custom force field kernels (NxSwTarget). Methods like recip() + or recipSqrt() evaluate to zero if their input is smaller than this epsilon. + +
+ */ + NX_FORCE_FIELD_CUSTOM_KERNEL_EPSILON = 97, + + /** + \brief Enable/disable improved spring solver for joints and wheelshapes + + This parameter allows to enable/disable an improved version of the spring solver for joints and wheelshapes. + + \warning + The parameter is introduced for legacy purposes only and will be removed in future versions (such that + the improved spring solver will always be used). + + \note + Changing the parameter will only affect newly created scenes but not existing ones. + + Range: {0: disabled, 1: enabled}
+ Default: 1 + + Platform: + \li PC SW: Yes + \li PPU : No (disabled by default) + \li PS3 : Yes + \li XB360: Yes + */ + NX_IMPROVED_SPRING_SOLVER = 98, + + /** + \brief This is not a parameter, it just records the current number of parameters (as max(NxParameter)+1) for use in loops. + When a new parameter is added this number should be assigned to it and then incremented. + */ + NX_PARAMS_NUM_VALUES = 99, + + NX_PARAMS_FORCE_DWORD = 0x7fffffff + }; + + /** + \brief 128-bit mask used for collision filtering. + + The collision filtering equation for 2 shapes S0 and S1 is: + +
 (G0 op0 K0) op2 (G1 op1 K1) == b 
+ + with + +
    +
  • G0 = NxGroupsMask for shape S0. See ::setGroupsMask
  • +
  • G1 = NxGroupsMask for shape S1. See ::setGroupsMask
  • +
  • K0 = filtering constant 0. See ::setFilterConstant0
  • +
  • K1 = filtering constant 1. See ::setFilterConstant1
  • +
  • b = filtering boolean. See ::setFilterBool
  • +
  • op0, op1, op2 = filtering operations. See ::setFilterOps
  • +
+ + If the filtering equation is true, collision detection is enabled. + + @see NxScene::setFilterOps() + */ + class NxGroupsMask + { + public: + NX_INLINE NxGroupsMask() {} + NX_INLINE ~NxGroupsMask() {} + + NxU32 bits0, bits1, bits2, bits3; + }; + + /** + \brief Collision filtering operations. + + @see NxGroupsMask + */ + enum NxFilterOp + { + NX_FILTEROP_AND, + NX_FILTEROP_OR, + NX_FILTEROP_XOR, + NX_FILTEROP_NAND, + NX_FILTEROP_NOR, + NX_FILTEROP_NXOR, + //UBISOFT : FILTERING + NX_FILTEROP_SWAP_AND + }; + + /** + Identifies each possible seperating axis for a pair of oriented bounding boxes. + + @see NxSeparatingAxis() + */ + enum NxSepAxis + { + NX_SEP_AXIS_OVERLAP, + + NX_SEP_AXIS_A0, + NX_SEP_AXIS_A1, + NX_SEP_AXIS_A2, + + NX_SEP_AXIS_B0, + NX_SEP_AXIS_B1, + NX_SEP_AXIS_B2, + + NX_SEP_AXIS_A0_CROSS_B0, + NX_SEP_AXIS_A0_CROSS_B1, + NX_SEP_AXIS_A0_CROSS_B2, + + NX_SEP_AXIS_A1_CROSS_B0, + NX_SEP_AXIS_A1_CROSS_B1, + NX_SEP_AXIS_A1_CROSS_B2, + + NX_SEP_AXIS_A2_CROSS_B0, + NX_SEP_AXIS_A2_CROSS_B1, + NX_SEP_AXIS_A2_CROSS_B2, + + NX_SEP_AXIS_FORCE_DWORD = 0x7fffffff + }; + + /** + Identifies the version of hardware present in the machine. + */ + + enum NxHWVersion + { + NX_HW_VERSION_NONE = 0, + NX_HW_VERSION_ATHENA_1_0 = 1 + }; + + /** + \brief Describes the format of height field samples. + @see NxHeightFieldDesc.format NxHeightFieldDesc.samples + */ + enum NxHeightFieldFormat + { + /** + \brief Height field height data is 16 bit signed integers, followed by triangle materials. + + Each sample is 32 bits wide arranged as follows: + + \image html heightFieldFormat_S16_TM.png + + 1) First there is a 16 bit height value. + 2) Next, two one byte material indices, with the high bit of each byte reserved for special use. + (so the material index is only 7 bits). + The high bit of material0 is the tess-flag. + The high bit of material1 is reserved for future use. + + There are zero or more unused bytes before the next sample depending on NxHeightFieldDesc.sampleStride, + where the application may eventually keep its own data. + + This is the only format supported at the moment. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.format NxHeightFieldDesc.samples + */ + NX_HF_S16_TM = (1 << 0), + }; + + /** + \brief Determines the tessellation of height field cells. + @see NxHeightFieldDesc.format NxHeightFieldDesc.samples + */ + enum NxHeightFieldTessFlag + { + /** + \brief This flag determines which way each quad cell is subdivided. + + The flag lowered indicates subdivision like this: (the 0th vertex is referenced by only one triangle) + + \image html heightfieldTriMat2.PNG + +
+		+--+--+--+---> column
+		| /| /| /|
+		|/ |/ |/ |
+		+--+--+--+
+		| /| /| /|
+		|/ |/ |/ |
+		+--+--+--+
+		|
+		|
+		V row
+		
+ + The flag raised indicates subdivision like this: (the 0th vertex is shared by two triangles) + + \image html heightfieldTriMat1.PNG + +
+		+--+--+--+---> column
+		|\ |\ |\ |
+		| \| \| \|
+		+--+--+--+
+		|\ |\ |\ |
+		| \| \| \|
+		+--+--+--+
+		|
+		|
+		V row
+		
+ + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.format NxHeightFieldDesc.samples + */ + NX_HF_0TH_VERTEX_SHARED = (1 << 0) + }; + + /** + \brief Enum with flag values to be used in NxHeightFieldDesc.flags. + */ + enum NxHeightFieldFlags + { + /** + \brief Disable collisions with height field with boundary edges. + + Raise this flag if several terrain patches are going to be placed adjacent to each other, + to avoid a bump when sliding across. + + This flag is ignored in contact generation with sphere and capsule shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes (Software fallback) + \li PS3 : Yes + \li XB360: Yes + + @see NxHeightFieldDesc.flags + */ + NX_HF_NO_BOUNDARY_EDGES = (1 << 0), + }; + +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/PhysXLoader.h b/libraries/external/physx/Win32/include/PX/PhysXLoader.h new file mode 100755 index 0000000..ffa925f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/PhysXLoader.h @@ -0,0 +1,168 @@ +#ifndef PHYSX_LOADER_H +#define PHYSX_LOADER_H +/*----------------------------------------------------------------------------*\ +| +| Public Interface to AGEIA PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/NxPhysicsSDK.h" +#include "PX/NxUtilLib.h" + +#ifdef _USRDLL + #if defined(WIN32) + #define NXPHYSXLOADERDLL_API extern "C" __declspec(dllexport) + #elif defined(LINUX) + #if defined(NX_LINUX_USE_VISIBILITY) + #define NXPHYSXLOADERDLL_API extern "C" __attribute__ ((visibility ("default"))) + #else + #define NXPHYSXLOADERDLL_API extern "C" + #endif + #else + #define NXPHYSXLOADERDLL_API + #endif +#elif defined NX_USE_SDK_STATICLIBS + #define NXPHYSXLOADERDLL_API +#else + #if defined(WIN32) + #define NXPHYSXLOADERDLL_API extern "C" __declspec(dllimport) + #elif defined(LINUX) + #define NXPHYSXLOADERDLL_API extern "C" + #else + #define NXPHYSXLOADERDLL_API + #endif +#endif + + +/** \addtogroup PhysXLoader + @{ +*/ + +/** +\brief Creates an instance of the physics SDK. + +Creates an instance of this class. May not be a class member to avoid name mangling. +Pass the constant NX_PHYSICS_SDK_VERSION as the argument. +Because the class is a singleton class, multiple calls return the same object. However, each call must be +matched by a corresponding call to NxReleasePhysicsSDK, as the SDK uses a reference counter to the singleton. + +NOTE: Calls after the first will not change the allocator used in the SDK, but they will affect the output stream. + +\param sdkVersion Version number we are expecting(should be NX_PHYSICS_SDK_VERSION) +\param allocator User supplied interface for allocating memory(see #NxUserAllocator) +\param outputStream User supplied interface for reporting errors and displaying messages(see #NxUserOutputStream) +\param desc Optional descriptor used to define hardware allocation parameters +\param errorCode Optional error code output parameter +*/ +NXPHYSXLOADERDLL_API NxPhysicsSDK* NX_CALL_CONV NxCreatePhysicsSDK(NxU32 sdkVersion, NxUserAllocator* allocator = NULL, NxUserOutputStream* outputStream = NULL, const NxPhysicsSDKDesc& desc = NxPhysicsSDKDesc(), NxSDKCreateError* errorCode=NULL); + +/** +\brief Creates an instance of the physics SDK with an ID string for application identification. + +Creates an instance of this class. May not be a class member to avoid name mangling. +Pass the constant NX_PHYSICS_SDK_VERSION as the argument. +Because the class is a singleton class, multiple calls return the same object. However, each call must be +matched by a corresponding call to NxReleasePhysicsSDK, as the SDK uses a reference counter to the singleton. + +NOTE: Calls after the first will not change the allocator used in the SDK, but they will affect the output stream. + +\param sdkVersion Version number we are expecting(should be NX_PHYSICS_SDK_VERSION) +\param companyNameStr Character string for the game or application developer company name +\param appNameStr Character string for the game or application name +\param appVersionStr Character string for the game or application version +\param appUserDefinedStr Character string for additional, user defined data +\param allocator User supplied interface for allocating memory(see #NxUserAllocator) +\param outputStream User supplied interface for reporting errors and displaying messages(see #NxUserOutputStream) +\param desc Optional descriptor used to define hardware allocation parameters +\param errorCode Optional error code output parameter +*/ +NXPHYSXLOADERDLL_API NxPhysicsSDK* NX_CALL_CONV NxCreatePhysicsSDKWithID(NxU32 sdkVersion, + char *companyNameStr, + char *appNameStr, + char *appVersionStr, + char *appUserDefinedStr, + NxUserAllocator* allocator = NULL, + NxUserOutputStream* outputStream = NULL, + const NxPhysicsSDKDesc &desc = NxPhysicsSDKDesc(), + NxSDKCreateError* errorCode=NULL); + + +/** +\brief Release an instance of the PhysX SDK. + +Note that this must be called once for each prior call to NxCreatePhysicsSDK or NxCreatePhysicsSDKWithID, as +there is a reference counter. Also note that you mustn't destroy the allocator or the outputStream (if available) until after the +reference count reaches 0 and the SDK is actually removed. + +Releasing an SDK will also release any scenes, triangle meshes, convex meshes, heightfields, CCD skeletons, and cloth +meshes created through it, provided the user hasn't already done so. + +You should release all scenes created with the SDK prior to calling this method, or resources may not be released. +*/ +NXPHYSXLOADERDLL_API void NX_CALL_CONV NxReleasePhysicsSDK(NxPhysicsSDK* sdk); + +/** +\brief Retrieves the Physics SDK allocator. + +Used by NxAllocateable's inlines and other macros below. + +Before using this function the user must call #NxCreatePhysicsSDK(). If #NxCreatePhysicsSDK() +has not been called then NULL will be returned. +*/ +NXPHYSXLOADERDLL_API NxUserAllocator* NX_CALL_CONV NxGetPhysicsSDKAllocator(); + +/** +\brief Retrieves the Foundation SDK after it has been created. + +Before using this function the user must call #NxCreatePhysicsSDK(). If #NxCreatePhysicsSDK() +has not been called then NULL will be returned.. +*/ +NXPHYSXLOADERDLL_API NxFoundationSDK* NX_CALL_CONV NxGetFoundationSDK(); + +/** +\brief Retrieves the Physics SDK after it has been created. + +Before using this function the user must call #NxCreatePhysicsSDK(). If #NxCreatePhysicsSDK() +has not been called then NULL will be returned. +*/ +NXPHYSXLOADERDLL_API NxPhysicsSDK* NX_CALL_CONV NxGetPhysicsSDK(); + +/** +\brief Retrieves the Physics SDK Utility Library + +Before using this function the user must call #NxCreatePhysicsSDK(). If #NxCreatePhysicsSDK() +has not been called then NULL will be returned. +*/ + +NXPHYSXLOADERDLL_API NxUtilLib* NX_CALL_CONV NxGetUtilLib(); + +/** +\brief Retrieves the Physics SDK Cooking Library for a specific version of the SDK. + +\note Not supported on platforms where dynamic linking is not used (Xbox 360 and PS3). + +\param sdk_version_number the version of the PhysX SDK, in hexadecimal format (e.g. 0x02060000 for +2.6.0). You may also use the NX_PHYSICS_SDK_VERSION constant. +*/ +class NxCookingInterface; +NXPHYSXLOADERDLL_API NxCookingInterface * NX_CALL_CONV NxGetCookingLib(NxU32 sdk_version_number); +NXPHYSXLOADERDLL_API NxCookingInterface * NX_CALL_CONV NxGetCookingLibWithID(NxU32 sdk_version_number, + char *companyNameStr, + char *appNameStr, + char *appVersionStr, + char *appUserDefinedStr); + +/** @} */ + +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2006 AGEIA Technologies, Inc. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/Win32RegistryAccess.h b/libraries/external/physx/Win32/include/PX/Win32RegistryAccess.h new file mode 100755 index 0000000..27dfec7 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/Win32RegistryAccess.h @@ -0,0 +1,28 @@ +#ifndef __AG_WIN32_REGISTRY_ACCESS__ +#define __AG_WIN32_REGISTRY_ACCESS__ + +/* AgWin32RegistryAccess is not part of the API and should not be included in the documentation.*/ +/** \cond */ + +#include + +#define AG_BASE_KEY_NAME "Software\\AGEIA Technologies\\" +#define AG_LOCAL_DLL_SUBKEY_NAME "enableLocalPhysXCore" +#define AG_NO_NIC_MAC "AGEIA" + +class AgWin32RegistryAccess +{ +public: + static bool ReadRegKey(const char *inKey, const char *inSubKey, char *outData, unsigned int *length); + static bool WriteRegKey(const char *inKey, const char *inSubKey, const char *inData, unsigned int length, bool nonvolatile, unsigned int wordType=REG_SZ); + bool EnableLocalDllUsage(); + bool DisableLocalDllUsage(); + bool IsLocalDllUsageEnabled(); + +private: + bool getMACAddr(unsigned char addr[8]); +}; + +/** \endcond */ + +#endif diff --git a/libraries/external/physx/Win32/include/PX/cloth/NxCloth.h b/libraries/external/physx/Win32/include/PX/cloth/NxCloth.h new file mode 100755 index 0000000..581590b --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/cloth/NxCloth.h @@ -0,0 +1,1584 @@ +#ifndef NX_PHYSICS_NX_CLOTH +#define NX_PHYSICS_NX_CLOTH +/** \addtogroup cloth + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/cloth/NxClothDesc.h" + +class NxRay; +class NxScene; +class NxActor; +class NxShape; +class NxBounds3; +class NxStream; +class NxCompartment; + +class NxCloth +{ +protected: + NX_INLINE NxCloth() : userData(NULL) {} + virtual ~NxCloth() {} + +public: + /** + \brief Saves the cloth descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc + */ + virtual bool saveToDesc(NxClothDesc& desc) const = 0; + + /** + \brief Returns a pointer to the corresponding cloth mesh. + + \return The cloth mesh associated with this cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.clothMesh + */ + virtual NxClothMesh* getClothMesh() const = 0; + + /** + \brief Sets the cloth bending stiffness in the range from 0 to 1. + + \param[in] stiffness The stiffness of this cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.bendingStiffness getBendingStiffness() + */ + virtual void setBendingStiffness(NxReal stiffness) = 0; + + /** + \brief Retrieves the cloth bending stiffness. + + \return Bending stiffness of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.bendingStiffness setBendingStiffness() + */ + virtual NxReal getBendingStiffness() const = 0; + + /** + \brief Sets the cloth stretching stiffness in the range from 0 to 1. + + Note: The stretching stiffness must be larger than 0. + + \param[in] stiffness Stiffness of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.stretchingStiffness getStretchingStiffness() + */ + virtual void setStretchingStiffness(NxReal stiffness) = 0; + + /** + \brief Retrieves the cloth stretching stiffness. + + \return stretching stiffness of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.stretchingStiffness setStretchingStiffness() + */ + virtual NxReal getStretchingStiffness() const = 0; + + /** + \brief Sets the damping coefficient in the range from 0 to 1. + + \param[in] dampingCoefficient damping coefficient of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.dampingCoefficient getDampingCoefficient() + */ + virtual void setDampingCoefficient(NxReal dampingCoefficient) = 0; + + /** + \brief Retrieves the damping coefficient. + + \return damping coefficient of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.dampingCoefficient setDampingCoefficient() + */ + virtual NxReal getDampingCoefficient() const = 0; + + /** + \brief Sets the cloth friction coefficient in the range from 0 to 1. + + \param[in] friction The friction of the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.friction getFriction() + */ + virtual void setFriction(NxReal friction) = 0; + + /** + \brief Retrieves the cloth friction coefficient. + + \return Friction coefficient of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.friction setFriction() + */ + virtual NxReal getFriction() const = 0; + + /** + \brief Sets the cloth pressure coefficient (must be non negative). + + \param[in] pressure The pressure applied to the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.pressure getPressure() + */ + virtual void setPressure(NxReal pressure) = 0; + + /** + \brief Retrieves the cloth pressure coefficient. + + \return Pressure of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.pressure setPressure() + */ + virtual NxReal getPressure() const = 0; + + /** + \brief Sets the cloth tear factor (must be larger than one). + + \param[in] factor The tear factor for the cloth + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.tearFactor getTearFactor() + */ + virtual void setTearFactor(NxReal factor) = 0; + + /** + \brief Retrieves the cloth tear factor. + + \return tear factor of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.tearFactor setTearFactor() + */ + virtual NxReal getTearFactor() const = 0; + + /** + \brief Sets the cloth attachment tear factor (must be larger than one). + + \param[in] factor The attachment tear factor for the cloth + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.attachmentTearFactor getAttachmentTearFactor() + */ + virtual void setAttachmentTearFactor(NxReal factor) = 0; + + /** + \brief Retrieves the attachment cloth tear factor. + + \return tear attachment factor of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.attachmentTearFactor setAttachmentTearFactor() + */ + virtual NxReal getAttachmentTearFactor() const = 0; + + /** + \brief Sets the cloth thickness (must be positive). + + \param[in] thickness The thickness of the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.thickness getThickness() + */ + virtual void setThickness(NxReal thickness) = 0; + + /** + \brief Gets the cloth thickness. + + \return thickness of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.thickness setThickness() + */ + virtual NxReal getThickness() const = 0; + + /** + \brief Gets the cloth density. + + \return density of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.density + */ + virtual NxReal getDensity() const = 0; + + /** + \brief Gets the relative grid spacing for the broad phase. + The cloth is represented by a set of world aligned cubical cells in broad phase. + The size of these cells is determined by multiplying the length of the diagonal + of the AABB of the initial cloth size with this constant. + + \return relative grid spacing. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.relativeGridSpacing + */ + virtual NxReal getRelativeGridSpacing() const = 0; + + /** + \brief Retrieves the cloth solver iterations. + + \return solver iterations of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.solverIterations setSolverIterations() + */ + virtual NxU32 getSolverIterations() const = 0; + + /** + \brief Sets the cloth solver iterations. + + \param[in] iterations The new solver iteration count for the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.solverIterations getSolverIterations() + */ + virtual void setSolverIterations(NxU32 iterations) = 0; + + /** + \brief Returns a world space AABB enclosing all cloth points. + + \param[out] bounds Retrieves the world space bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 + */ + virtual void getWorldBounds(NxBounds3& bounds) const = 0; + + /** + \brief Attaches the cloth to a shape. All cloth points currently inside the shape are attached. + + \note This method only works with primitive and convex shapes. Since the inside of a general + triangle mesh is not clearly defined. + + \param[in] shape Shape to which the cloth should be attached to. + \param[in] attachmentFlags One or two way interaction, tearable or non-tearable + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothAttachmentFlag freeVertex() attachToCollidingShapes() + */ + virtual void attachToShape(const NxShape *shape, NxU32 attachmentFlags) = 0; + + /** + \brief Attaches the cloth to all shapes, currently colliding. + + \note This method only works with primitive and convex shapes. Since the inside of a general + triangle mesh is not clearly defined. + + \param[in] attachmentFlags One or two way interaction, tearable or non-tearable + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothAttachmentFlag NxClothDesc.attachmentTearFactor NxClothDesc.attachmentResponseCoefficient freeVertex() + */ + virtual void attachToCollidingShapes(NxU32 attachmentFlags) = 0; + + /** + \brief Detaches the cloth from a shape it has been attached to before. + + If the cloth has not been attached to the shape before, the call has no effect. + + \param[in] shape Shape from which the cloth should be detached. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothAttachmentFlag NxClothDesc.attachmentTearFactor NxClothDesc.attachmentResponseCoefficient freeVertex() attachToShape() + */ + virtual void detachFromShape(const NxShape *shape) = 0; + + /** + \brief Attaches a cloth vertex to a local position within a shape. + + \param[in] vertexId Index of the vertex to attach. + \param[in] shape Shape to attach the vertex to. + \param[in] localPos The position relative to the pose of the shape. + \param[in] attachmentFlags One or two way interaction, tearable or non-tearable + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape freeVertex() NxClothAttachmentFlag attachToShape() + */ + virtual void attachVertexToShape(NxU32 vertexId, const NxShape *shape, const NxVec3 &localPos, NxU32 attachmentFlags) = 0; + + /** + \brief Attaches a cloth vertex to a position in world space. + + \param[in] vertexId Index of the vertex to attach. + \param[in] pos The position in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothAttachmentFlag NxClothDesc.attachmentTearFactor NxClothDesc.attachmentResponseCoefficient freeVertex() attachToShape() + */ + virtual void attachVertexToGlobalPosition(const NxU32 vertexId, const NxVec3 &pos) = 0; + + /** + \brief Frees a previously attached cloth point. + + \param[in] vertexId Index of the vertex to free. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see attachVertexToGlobalPosition() attachVertexToShape() detachFromShape() + */ + virtual void freeVertex(const NxU32 vertexId) = 0; + + /** + \brief Changes the weight of a vertex in the cloth solver for a period of time. + + If this method is called for some vertex, the cloth solver will, during a time + period of length expirationTime, assign a different weight to the vertex + while internal cloth constraints (i.e. bending & stretching) are being resolved. + + With a high dominanceWeight, the modified vertex will force neighboring vertices + to strongly accommodate their positions while its own is kept fairly constant. + The reverse holds for smaller dominanceWeights. + + Using a dominanceWeight of +infinity has a similar effect as temporarily attaching + the vertex to a global position. However, unlike using attachments, the velocity + of the vertex is kept intact when using this method. + + \note The current implementation will not support the full range of dominanceWeights. + All dominanceWeights > 0.0 are treated equally as being +infinity. + + \note An expiration time of 0.0 is legal and will result in dominance being + applied throughout one substep before being discarded immediately. + + \note Having a large number of vertices dominant at once may result in a performance penalty. + + \param[in] vertexId Index of the vertex. + \param[in] expirationTime Time period where dominance will be active for this vertex. + \param[in] dominanceWeight Dominance weight for this vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see attachVertexToGlobalPosition() + */ + virtual void dominateVertex(NxU32 vertexId, NxReal expirationTime, NxReal dominanceWeight) = 0; + + /** + \brief Return the attachment status of the given vertex. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getVertexAttachmentShape() getVertexAttachmentPosition() + */ + virtual NxClothVertexAttachmentStatus getVertexAttachmentStatus(NxU32 vertexId) const = 0; + + /** + \brief Returns the pointer to an attached shape pointer of the given vertex. + + If the vertex is not attached or attached to a global position, NULL is returned. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getVertexAttachmentStatus() getVertexAttachmentPosition() + */ + virtual NxShape* getVertexAttachmentShape(NxU32 vertexId) const = 0; + + /** + \brief Returns the attachment position of the given vertex. + + If the vertex is attached to shape, the position local to the shape's pose is returned. + If the vertex is not attached, the return value is undefined. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getVertexAttachmentStatus() getVertexAttachmentShape() + */ + virtual NxVec3 getVertexAttachmentPosition(NxU32 vertexId) const = 0; + + /** + \brief Attaches the cloth to an actor. + + \note Call this function only once right after the cloth is created. + Turning cloth into metal and vice versa during the simulation is not recommended. + + \note This feature is well suited for volumetric objects like barrels. + It cannot handle two dimensional flat pieces well. + + After this call, the cloth is infinitely stiff between collisions and simply + moves with the actor. At impacts with an impact impulse greater than impulseThreshold, + the cloth is plastically deformed. Thus, a cloth with a core behaves like a piece of metal. + + The core actor's geometry is adjusted automatically. Its size also depends on the + cloth thickness. Thus, it is recommended to choose small values for the thickness. + At impacts, colliding objects are moved closer to the cloth by the value provided in + penetrationDepth which causes a more dramatic collision result. + + The core actor must have at least one shape, and currently supported shapes are + spheres, capsules, boxes and compounds of spheres. + It is recommended to specify the density rather than the mass of the core body. + This way the mass and inertia tensor are updated when the core deforms. + + The maximal deviation of cloth particles from their initial positions + (modulo the global rigid body transforms translation and rotation) can be + specified via the parameter maxDeformationDistance. Setting this parameter to + zero means that the deformation is not limited. + + \param actor The core actor to attach the cloth to. + \param impulseThreshold Threshold for when deformation is allowed. + \param penetrationDepth Amount by which colliding objects are brought closer to the cloth. + \param maxDeformationDistance Maximum deviation of cloth particles from initial position. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + */ + virtual void attachToCore(NxActor *actor, NxReal impulseThreshold, NxReal penetrationDepth = 0.0f, NxReal maxDeformationDistance = 0.0f) = 0; + + /** + \brief Tears the cloth at a given vertex. + + First the vertex is duplicated. The triangles on one side of the split plane keep + the original vertex. For all triangles on the opposite side the original vertex is + replaced by the new one. The split plane is defined by the world location of the + vertex and the normal provided by the user. + + Note: TearVertex performs a user defined vertex split in contrast to an automatic split + that is performed when the flag NX_CLF_TEARABLE is set. Therefore, tearVertex works + even if NX_CLF_TEARABLE is not set in NxClothDesc.flags. + + Note: For tearVertex to work, the clothMesh has to be cooked with the flag + NX_CLOTH_MESH_TEARABLE set in NxClothMeshDesc.flags. + + \param[in] vertexId Index of the vertex to tear. + \param[in] normal The normal of the split plane. + \return true if the split had an effect (i.e. there were triangles on both sides of the split plane) + + @see NxClothFlag, NxClothMeshFlags, NxClothDesc.flags NxSimpleTriangleMesh.flags + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool tearVertex(const NxU32 vertexId, const NxVec3 &normal) = 0; + + /** + \brief Executes a raycast against the cloth. + + \param[in] worldRay The ray in world space. + \param[out] hit The hit position. + \param[out] vertexId Index to the nearest vertex hit by the raycast. + + \return true if the ray hits the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool raycast(const NxRay& worldRay, NxVec3 &hit, NxU32 &vertexId) = 0; + + /** + \brief Sets which collision group this cloth is part of. + + \param[in] collisionGroup The collision group for this cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup + */ + virtual void setGroup(NxCollisionGroup collisionGroup) = 0; + + /** + \brief Retrieves the value set with #setGroup(). + + \return The collision group this cloth belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup + */ + virtual NxCollisionGroup getGroup() const = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. + + \param[in] groupsMask The group mask to set for the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGroupsMask() NxGroupsMask + */ + virtual void setGroupsMask(const NxGroupsMask& groupsMask) = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. + + \return The group mask for the cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGroupsMask() NxGroupsMask + */ + virtual const NxGroupsMask getGroupsMask() const = 0; + + /** + \brief Sets the user buffer wrapper for the cloth mesh. + + \param[in,out] meshData User buffer wrapper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshData NxClothDesc.meshData + */ + virtual void setMeshData(NxMeshData& meshData) = 0; + + /** + \brief Returns a copy of the user buffer wrapper for the cloth mesh. + + \return User buffer wrapper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshData setMeshData() NxClothDesc.meshData + */ + virtual NxMeshData getMeshData() = 0; + + /** + \brief Sets the valid bounds of the cloth in world space. + + If the flag NX_CLF_VALIDBOUNDS is set, these bounds defines the volume + outside of which cloth particle are automatically removed from the simulation. + + \param[in] validBounds The valid bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.validBounds getValidBounds() NxBounds3 + */ + virtual void setValidBounds(const NxBounds3& validBounds) = 0; + + /** + \brief Returns the valid bounds of the cloth in world space. + + \param[out] validBounds The valid bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.validBounds setValidBounds() NxBounds3 + */ + virtual void getValidBounds(NxBounds3& validBounds) const = 0; + + /** + \brief Sets the position of a particular vertex of the cloth. + + \param[in] position New position of the vertex. + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles() + */ + virtual void setPosition(const NxVec3& position, NxU32 vertexId) = 0; + + /** + \brief Sets the positions of the cloth. + + The user must supply a buffer containing all positions (i.e same number of elements as number of particles). + + \param[in] buffer The user supplied buffer containing all positions for the cloth. + \param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getPositions() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual void setPositions(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Gets the position of a particular vertex of the cloth. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles() + */ + virtual NxVec3 getPosition(NxU32 vertexId) const = 0; + + /** + \brief Gets the positions of the cloth. + + The user must supply a buffer large enough to hold all positions (i.e same number of elements as number of particles). + + \param[in] buffer The user supplied buffer to hold all positions of the cloth. + \param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPositions() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual void getPositions(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Sets the velocity of a particular vertex of the cloth. + + \param[in] position New velocity of the vertex. + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPosition() getPosition() getVelocity() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual void setVelocity(const NxVec3& velocity, NxU32 vertexId) = 0; + + /** + \brief Sets the velocities of the cloth. + + The user must supply a buffer containing all velocities (i.e same number of elements as number of particles). + + \param[in] buffer The user supplied buffer containing all velocities for the cloth. + \param[in] byteStride The stride in bytes between the velocity vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getVelocities() setPositions() getPositions() getNumberOfParticles() + */ + virtual void setVelocities(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Gets the velocity of a particular vertex of the cloth. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPosition() getPosition() setVelocity() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual NxVec3 getVelocity(NxU32 vertexId) const = 0; + + /** + \brief Gets the velocities of the cloth. + + The user must supply a buffer large enough to hold all velocities (i.e same number of elements as number of particles). + + \param[in] buffer The user supplied buffer to hold all velocities of the cloth. + \param[in] byteStride The stride in bytes between the velocity vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setVelocities() setPositions() getPositions() getNumberOfParticles() + */ + virtual void getVelocities(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Gets the number of cloth particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setVelocities() getVelocities() setPositions() getPositions() + */ + virtual NxU32 getNumberOfParticles() = 0; + + /** + \brief Queries the cloth for the currently interacting shapes. Must be called prior to saveStateToStream in order for attachments and collisons to be saved. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getShapePointers() setShapePointers() saveStateToStream() loadStateFromStream() + */ + virtual NxU32 queryShapePointers() = 0; + + /** + \brief Gets the byte size of the current cloth state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNumberOfParticles() + */ + virtual NxU32 getStateByteSize() = 0; + + /** + \brief Saves pointers to the currently interacting shapes to memory + + \param[in] shapePointers The user supplied array to hold the shape pointers. + \param[in] flags The optional user supplied array to hold the cloth attachment flags for each attached shape + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see queryShapePointers() setShapePointers() saveStateToStream() loadStateFromStream() + */ + virtual void getShapePointers(NxShape** shapePointers,NxU32 *flags=0) = 0; + + /** + \brief Loads pointers to the currently interacting shapes from memory. + + \param[in] shapePointers The user supplied array that holds the shape pointers. Must be in the exact same order as the shapes were retrieved by getShapePointers. + \param[in] numShapes The size of the supplied array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see queryShapePointers() getShapePointers() saveStateToStream() loadStateFromStream() + */ + virtual void setShapePointers(NxShape** shapePointers,unsigned int numShapes) = 0; + + /** + \brief Saves the current cloth state to a stream. + + queryShapePointers must be called prior to this function in order for attachments and collisions to be saved. + Tearable and metal cloths are currently not supported. + A saved state contains platform specific data and can thus only be loaded on back on the same platform. + + \param[in] stream The user supplied stream to hold the cloth state. + \param[in] permute If true, the order of the vertices output will correspond to that of the associated + NxClothMesh's saveToDesc mehod; if false (the default), it will correspond to the original NxClothMesh descriptor + used to create the mesh. These may differ due to cooking. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadStateFromStream() queryShapePointers() getShapePointers() setShapePointers() + */ + virtual void saveStateToStream(NxStream& stream, bool permute = false) = 0; + + /** + \brief Loads the current cloth state from a stream. + + setShapePointers must be called prior to this function if attachments and collisions are to be loaded. + Tearable and metal cloths are currently not supported. + A saved state contains platform specific data and can thus only be loaded on back on the same platform. + + \param[in] stream The user supplied stream that holds the cloth state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveStateToStream() queryShapePointers() getShapePointers() setShapePointers() + */ + virtual void loadStateFromStream(NxStream& stream) = 0; + + /** + \brief Sets the collision response coefficient. + + \param[in] coefficient The collision response coefficient (0 or greater). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.collisionResponseCoefficient getCollisionResponseCoefficient() + */ + virtual void setCollisionResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves the collision response coefficient. + + \return The collision response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.collisionResponseCoefficient setCollisionResponseCoefficient() + */ + virtual NxReal getCollisionResponseCoefficient() const = 0; + + /** + \brief Sets the attachment response coefficient + + \param[in] coefficient The attachment response coefficient in the range from 0 to 1. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.attachmentResponseCoefficient getAttachmentResponseCoefficient() + */ + virtual void setAttachmentResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves the attachment response coefficient + + \return The attachment response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.attachmentResponseCoefficient setAttachmentResponseCoefficient() + */ + virtual NxReal getAttachmentResponseCoefficient() const = 0; + + /** + \brief Sets the response coefficient for collisions from fluids to this cloth + + \param[in] coefficient The response coefficient + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.fromFluidResponseCoefficient getFromFluidResponseCoefficient() + */ + virtual void setFromFluidResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves response coefficient for collisions from fluids to this cloth + + \return The response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.fromFluidResponseCoefficient setFromFluidResponseCoefficient() + */ + virtual NxReal getFromFluidResponseCoefficient() const = 0; + + /** + \brief Sets the response coefficient for collisions from this cloth to fluids + + \param[in] coefficient The response coefficient + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.toFluidResponseCoefficient getToFluidResponseCoefficient() + */ + virtual void setToFluidResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves response coefficient for collisions from this cloth to fluids + + \return The response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.toFluidResponseCoefficient setToFluidResponseCoefficient() + */ + virtual NxReal getToFluidResponseCoefficient() const = 0; + + /** + \brief Sets an external acceleration which affects all non attached particles of the cloth + + \param[in] acceleration The acceleration vector (unit length / s^2) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.externalAcceleration getExternalAcceleration() + */ + virtual void setExternalAcceleration(NxVec3 acceleration) = 0; + + /** + \brief Retrieves the external acceleration which affects all non attached particles of the cloth + + \return The acceleration vector (unit length / s^2) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.externalAcceleration setExternalAcceleration() + */ + virtual NxVec3 getExternalAcceleration() const = 0; + + /** + \brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame + of the attached actor. + + This feature is useful when the cloth is attached to a fast moving character. + In that case the cloth adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + \param[in] velocity The minimal velocity for cloth to adhere (unit length / s) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.minAdhereVelocity getMinAdhereVelocity() + */ + virtual void setMinAdhereVelocity(NxReal velocity) = 0; + + /** + \brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame + of the attached actor. + + This feature is useful when the cloth is attached to a fast moving character. + In that case the cloth adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + \return Returns the minimal velocity for cloth to adhere (unit length / s) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.minAdhereVelocity setMinAdhereVelocity() + */ + virtual NxReal getMinAdhereVelocity() const = 0; + + /** + \brief Sets an acceleration acting normal to the cloth surface at each vertex. + + \param[in] acceleration The acceleration vector (unit length / s^2) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.windAcceleration getWindAcceleration() + */ + virtual void setWindAcceleration(NxVec3 acceleration) = 0; + + /** + \brief Retrieves the acceleration acting normal to the cloth surface at each vertex. + + \return The acceleration vector (unit length / s^2) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.windAcceleration setWindAcceleration() + */ + virtual NxVec3 getWindAcceleration() const = 0; + + /** + \brief Returns true if this cloth is sleeping. + + When a cloth does not move for a period of time, it is no longer simulated in order to save time. This state + is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object, + or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user. + + If a cloth is asleep after the call to NxScene::fetchResults() returns, it is guaranteed that the position of the cloth + vertices was not changed. You can use this information to avoid updating dependent objects. + + \return True if the cloth is sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() + */ + virtual bool isSleeping() const = 0; + + /** + \brief Returns the linear velocity below which a cloth may go to sleep. + + A cloth whose linear velocity is above this threshold will not be put to sleep. + + @see isSleeping + + \return The threshold linear velocity for sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() setSleepLinearVelocity() + */ + virtual NxReal getSleepLinearVelocity() const = 0; + + /** + \brief Sets the linear velocity below which a cloth may go to sleep. + + A cloth whose linear velocity is above this threshold will not be put to sleep. + + If the threshold value is negative, the velocity threshold is set using the NxPhysicsSDK's + NX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter. + + \param[in] threshold Linear velocity below which a cloth may sleep. Range: (0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() + */ + virtual void setSleepLinearVelocity(NxReal threshold) = 0; + + /** + \brief Wakes up the cloth if it is sleeping. + + The wakeCounterValue determines how long until the cloth is put to sleep, a value of zero means + that the cloth is sleeping. wakeUp(0) is equivalent to NxCloth::putToSleep(). + + \param[in] wakeCounterValue New sleep counter value. Range: [0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() putToSleep() + */ + virtual void wakeUp(NxReal wakeCounterValue = NX_SLEEP_INTERVAL) = 0; + + /** + \brief Forces the cloth to sleep. + + The cloth will fall asleep. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() + */ + virtual void putToSleep() = 0; + + /** + \brief Sets the flags, a combination of the bits defined by the enum ::NxClothFlag. + + \param[in] flags #NxClothFlag combination. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.flags NxClothFlag getFlags() + */ + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief Retrieves the flags. + + \return The cloth flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.flags NxClothFlag setFlags() + */ + virtual NxU32 getFlags() const = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by + the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName(const char* name) = 0; + + /** + \brief Applies a force (or impulse) defined in the global coordinate frame, to a particular + vertex of the cloth. + + Because forces are reset at the end of every timestep, + you can maintain a total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + \param[in] force Force/impulse to add, defined in the global frame. Range: force vector + \param[in] vertexId Number of the vertex to add the force at. Range: position vector + \param[in] mode The mode to use when applying the force/impulse + (see #NxForceMode, supported modes are NX_FORCE, NX_IMPULSE, NX_ACCELERATION, NX_VELOCITY_CHANGE) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + */ + virtual void addForceAtVertex(const NxVec3& force, NxU32 vertexId, NxForceMode mode = NX_FORCE) = 0; + + /** + \brief Applies a radial force (or impulse) at a particular position. All vertices + within radius will be affected with a quadratic drop-off. + + Because forces are reset at the end of every timestep, + you can maintain a total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + \param[in] position Position to apply force at. + \param[in] magnitude Magnitude of the force/impulse to apply. + \param[in] radius The sphere radius in which particles will be affected. Range: position vector + \param[in] mode The mode to use when applying the force/impulse + (see #NxForceMode, supported modes are NX_FORCE, NX_IMPULSE, NX_ACCELERATION, NX_VELOCITY_CHANGE). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + */ + virtual void addForceAtPos(const NxVec3& position, NxReal magnitude, NxReal radius, NxForceMode mode = NX_FORCE) = 0; + + /** + \brief Applies a directed force (or impulse) at a particular position. All vertices + within radius will be affected with a quadratic drop-off. + + Because forces are reset at the end of every timestep, + you can maintain a total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + \param[in] position Position to apply force at. + \param[in] force Force to apply. + \param[in] radius The sphere radius in which particles will be affected. Range: position vector + \param[in] mode The mode to use when applying the force/impulse + (see #NxForceMode, supported modes are NX_FORCE, NX_IMPULSE, NX_ACCELERATION, NX_VELOCITY_CHANGE). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + */ + virtual void addDirectedForceAtPos(const NxVec3& position, const NxVec3& force, NxReal radius, NxForceMode mode = NX_FORCE) = 0; + + /** + \brief Finds triangles touching the input bounds. + + \warning This method returns a pointer to an internal structure using the indices member. Hence the + user should use or copy the indices before calling any other API function. + + \param[in] bounds Bounds to test against in world space. Range: See #NxBounds3 + \param[out] nb Retrieves the number of triangle indices touching the AABB. + \param[out] indices Returns an array of touching triangle indices. + The triangle indices correspond to the triangles referenced to by NxClothDesc.meshdata (#NxMeshData). + Triangle i has the vertices 3i, 3i+1 and 3i+2 in the array NxMeshData.indicesBegin. + \return True if there is an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxClothDesc NxMeshData + */ + virtual bool overlapAABBTriangles(const NxBounds3& bounds, NxU32& nb, const NxU32*& indices) const = 0; + + /** + \brief Retrieves the scene which this cloth belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return Name string associated with object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName() const = 0; + + /** + \brief Retrieves the cloth's simulation compartment, as specified by the user at creation time. + \return NULL if the cloth is not simulated in a compartment or if it was specified to run in + the default cloth compartment, otherwise the simulation compartment. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartment + */ + virtual NxCompartment * getCompartment() const = 0; + + /** + \brief Get the PPU simulation time. + + This method returns the time taken to simulate the fluid on the PPU in units + which are proportional to time but whose units are otherwise unspecified. + + \return the simulation time + Platform: + \li PC SW: No + \li PPU : Yes + \li PS3 : No + \li XB360: No + + */ + virtual NxU32 getPPUTime() const = 0; + + /** + \brief Retrieves the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldMaterial getForceFieldMaterial() const = 0; + + /** + \brief Sets the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setForceFieldMaterial(NxForceFieldMaterial) = 0; + + //public variables: +public: + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. +}; +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/cloth/NxClothDesc.h b/libraries/external/physx/Win32/include/PX/cloth/NxClothDesc.h new file mode 100755 index 0000000..2f0c713 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/cloth/NxClothDesc.h @@ -0,0 +1,823 @@ +#ifndef NX_PHYSICS_NX_CLOTHDESC +#define NX_PHYSICS_NX_CLOTHDESC +/** \addtogroup cloth + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/NxBounds3.h" +#include "PX/NxMeshData.h" + +class NxClothMesh; +class NxCompartment; + +/** +\brief Collection of flags describing the behavior of a cloth object. + +@see NxCloth NxClothMesh NxClothMeshDesc +*/ +enum NxClothFlag +{ + /** + \brief Enable/disable pressure simulation. + Note: Pressure simulation only produces meaningful results for closed meshes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.pressure + */ + NX_CLF_PRESSURE = (1<<0), + + /** + \brief Makes the cloth static. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_CLF_STATIC = (1<<1), + + /** + \brief Disable collision handling with the rigid body scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.collisionResponseCoefficient + */ + NX_CLF_DISABLE_COLLISION = (1<<2), + + /** + \brief Enable/disable self-collision handling within a single piece of cloth. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NX_CLF_TRIANGLE_COLLISION + */ + NX_CLF_SELFCOLLISION = (1<<3), + + /** + \brief Enable/disable debug visualization. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_CLF_VISUALIZATION = (1<<4), + + /** + \brief Enable/disable gravity. If off, the cloth is not subject to the gravitational force + of the rigid body scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_CLF_GRAVITY = (1<<5), + + /** + \brief Enable/disable bending resistance. Select the bending resistance through + NxClothDesc.bendingStiffness. Two bending modes can be selected via the NX_CLF_BENDING_ORTHO flag. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.bendingStiffness NX_CLF_BENDING_ORTHO + */ + NX_CLF_BENDING = (1<<6), + + /** + \brief Enable/disable orthogonal bending resistance. This flag has an effect only if + NX_CLF_BENDING is set. If NX_CLF_BENDING_ORTHO is not set, bending is modeled via an + additional distance constraint. This mode is fast but not independent of stretching + resistance. If NX_CLF_BENDING_ORTHO is set, bending is modeled via an angular spring + between adjacent triangles. This mode is slower but independent of stretching resistance. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.bendingStiffness NX_CLF_BENDING + */ + NX_CLF_BENDING_ORTHO = (1<<7), + + /** + \brief Enable/disable damping of internal velocities. Use NxClothDesc.dampingCoefficient + to control damping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.dampingCoefficient + */ + NX_CLF_DAMPING = (1<<8), + + /** + \brief Enable/disable two way collision of cloth with the rigid body scene. + + In either case, cloth is influenced by colliding rigid bodies. + If NX_CLF_COLLISION_TWOWAY is not set, rigid bodies are not influenced by + colliding pieces of cloth. Use NxClothDesc.collisionResponseCoefficient to + control the strength of the feedback force on rigid bodies. + + When using two way interaction care should be taken when setting the density of the attached objects. + For example if an object with a very low or high density is attached to a cloth then the simulation + may behave poorly. This is because impulses are only transfered between the cloth and rigid body solver + outside the solvers. + + Two way interaction works best when NX_SF_SEQUENTIAL_PRIMARY is set in the primary scene. If not set, + collision and attachment artifacts may happen. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.collisionResponseCoefficient + */ + NX_CLF_COLLISION_TWOWAY = (1<<9), + + /** + Not supported in current release. + \brief Enable/disable collision detection of cloth triangles against the scene. + If NX_CLF_TRIANGLE_COLLISION is not set, only collisions of cloth particles are detected. + If NX_CLF_TRIANGLE_COLLISION is set, collisions of cloth triangles are detected as well. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + */ + NX_CLF_TRIANGLE_COLLISION = (1<<11), + + /** + \brief Defines whether the cloth is tearable. + + Note: Make sure meshData.maxVertices and the corresponding buffers + in meshData are substantially larger (e.g. 2x) then the number + of original vertices since tearing will generate new vertices. + When the buffer cannot hold the new vertices anymore, tearing stops. + + Note: For tearing, make sure you cook the mesh with the flag + NX_CLOTH_MESH_TEARABLE set in the NxClothMeshDesc.flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.tearFactor NxClothDesc.meshData NxClothMeshDesc.flags + */ + NX_CLF_TEARABLE = (1<<12), + + /** + \brief Defines whether this cloth is simulated on the PPU. + + To simulate a piece of cloth on the PPU + set this flag and create the cloth in a regular software scene. + Note: only use this flag during creation, do not change it using NxCloth.setFlags(). + */ + NX_CLF_HARDWARE = (1<<13), + + /** + \brief Enable/disable center of mass damping of internal velocities. + + This flag only has an effect if the flag NX_CLF_DAMPING is set. If set, + the global rigid body modes (translation and rotation) are extracted from damping. + This way, the cloth can freely move and rotate even under high damping. + Use NxClothDesc.dampingCoefficient to control damping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.dampingCoefficient + */ + NX_CLF_COMDAMPING = (1<<14), + + /** + \brief If the flag NX_CLF_VALIDBOUNDS is set, cloth particles outside the volume + defined by NxClothDesc.validBounds are automatically removed from the simulation. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.validBounds + */ + NX_CLF_VALIDBOUNDS = (1<<15), + + /** + \brief Enable/disable collision handling between this cloth and fluids. + + Note: With the current implementation, do not switch on fluid collision for + many cloths. Create scenes with a few large pieces because the memory usage + increases linearly with the number of cloths. + The performance of the collision detection is dependent on both, the thickness + and the particle radius of the fluid so tuning these parameters might improve + the performance significantly. + + Note: The current implementation does not obey the NxScene::setGroupCollisionFlag + settings. If NX_CLF_FLUID_COLLISION is set, collisions will take place even if + collisions between the groups that the corresponding cloth and fluid belong to are + disabled. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.toFluidResponseCoefficient NxClothDesc.fromFluidResponseCoefficient + */ + NX_CLF_FLUID_COLLISION = (1<<16), + + /** + \brief Disable continuous collision detection with dynamic actors. + Dynamic actors are handled as static ones. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_CLF_DISABLE_DYNAMIC_CCD = (1<<17), + + /** + \brief Moves cloth partially in the frame of the attached actor. + + This feature is useful when the cloth is attached to a fast moving character. + In that case the cloth adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothDesc.minAdhereVelocity + */ + NX_CLF_ADHERE = (1<<18), +}; + +/*----------------------------------------------------------------------------*/ + +/** +\brief Cloth attachment flags. + +@see NxCloth.attachToShape() NxCloth.attachToCollidingShapes() NxCloth.attachVertexToShape() +*/ + +enum NxClothAttachmentFlag +{ + /** + \brief The default is only object->cloth interaction (one way). + + With this flag set, cloth->object interaction is turned on as well. + */ + NX_CLOTH_ATTACHMENT_TWOWAY = (1<<0), + + /** + \brief When this flag is set, the attachment is tearable. + + \note If the cloth is attached to a dynamic shape using two way interaction + half way torn attachments can generate unexpected impluses on the shape. + To prevent this, only attach one row of cloth vertices to the shape. + @see NxClothDesc.attachmentTearFactor + */ + NX_CLOTH_ATTACHMENT_TEARABLE = (1<<1), +}; + +/*----------------------------------------------------------------------------*/ + +/** +\brief Set of attachment states a vertex can be in. +*/ + +enum NxClothVertexAttachmentStatus +{ + /** + \brief The vertex is not attached + */ + NX_CLOTH_VERTEX_ATTACHMENT_NONE, + + /** + \brief The vertex is attached to a global position + */ + NX_CLOTH_VERTEX_ATTACHMENT_GLOBAL, + + /** + \brief The vertex is attached to a shape + */ + NX_CLOTH_VERTEX_ATTACHMENT_SHAPE, +}; + +/*----------------------------------------------------------------------------*/ + +/** +\brief Descriptor class for #NxCloth. + +@see NxCloth NxCloth.saveToDesc() +*/ + +class NxClothDesc +{ +public: + /** + \brief The cooked cloth mesh. + + Default: NULL + + @see NxClothMesh NxClothMeshDesc NxCloth.getClothMesh() + */ + NxClothMesh *clothMesh; + + /** + \brief The global pose of the cloth in the world. + + Default: Identity Transform + */ + NxMat34 globalPose; + + /** + \brief Thickness of the cloth. + + The thickness is usually a fraction of the overall extent of the cloth and + should not be set to a value greater than that. A good value is the maximal + distance between two adjacent cloth particles in their rest pose. Visual + artifacts or collision problems may appear if the thickness is too small. + + Default: 0.01
+ Range: [0,inf) + + @see NxCloth.setThickness() + */ + NxReal thickness; + + /** + \brief Density of the cloth (mass per area). + + Default: 1.0
+ Range: (0,inf) + */ + NxReal density; + + /** + \brief Bending stiffness of the cloth in the range 0 to 1. + + Only has an effect if the flag NX_CLF_BENDING is set. + + Default: 1.0
+ Range: [0,1] + + @see NX_CLF_BENDING NxCloth.setBendingStiffness() + */ + NxReal bendingStiffness; + + /** + \brief Stretching stiffness of the cloth in the range 0 to 1. + + Note: stretching stiffness must be larger than 0. + + Default: 1.0
+ Range: (0,1] + + @see NxCloth.setStretchingStiffness() + */ + NxReal stretchingStiffness; + + /** + \brief Spring damping of the cloth in the range 0 to 1. + + Only has an effect if the flag NX_CLF_DAMPING is set. + + Default: 0.5
+ Range: [0,1] + + @see NX_CLF_DAMPING NxCloth.setDampingCoefficient() + */ + NxReal dampingCoefficient; + + /** + \brief Friction coefficient in the range 0 to 1. + + Defines the damping of the velocities of cloth particles that are in contact. + + Default: 0.5
+ Range: [0,1] + + @see NxCloth.setFriction() + */ + NxReal friction; + + /** + \brief If the flag NX_CLF_PRESSURE is set, this variable defines the volume + of air inside the mesh as volume = pressure * restVolume. + + For pressure < 1 the mesh contracts w.r.t. the rest shape + For pressure > 1 the mesh expands w.r.t. the rest shape + + Default: 1.0
+ Range: [0,inf) + + @see NX_CLF_PRESSURE NxCloth.setPressure() + */ + NxReal pressure; + + /** + \brief If the flag NX_CLF_TEARABLE is set, this variable defines the + elongation factor that causes the cloth to tear. + + Must be larger than 1. + Make sure meshData.maxVertices and the corresponding buffers + in meshData are substantially larger (e.g. 2x) than the number + of original vertices since tearing will generate new vertices. + + When the buffer cannot hold the new vertices anymore, tearing stops. + + Default: 1.5
+ Range: (1,inf) + + @see NxCloth.setTearFactor() + */ + NxReal tearFactor; + + /** + \brief Defines a factor for the impulse transfer from cloth to colliding rigid bodies. + + Only has an effect if NX_CLF_COLLISION_TWOWAY is set. + + Default: 0.2
+ Range: [0,inf) + + @see NX_CLF_COLLISION_TWOWAY NxCloth.setCollisionResponseCoefficient() + */ + NxReal collisionResponseCoefficient; + + /** + \brief Defines a factor for the impulse transfer from cloth to attached rigid bodies. + + Only has an effect if the mode of the attachment is set to NX_CLOTH_ATTACHMENT_TWOWAY. + + Default: 0.2
+ Range: [0,1] + + @see NxCloth.attachToShape NxCloth.attachToCollidingShapes NxCloth.attachVertexToShape NxCloth.setAttachmentResponseCoefficient() + */ + NxReal attachmentResponseCoefficient; + + /** + \brief If the flag NX_CLOTH_ATTACHMENT_TEARABLE is set in the attachment method of NxCloth, + this variable defines the elongation factor that causes the attachment to tear. + + Must be larger than 1. + + Default: 1.5
+ Range: (1,inf) + + @see NxCloth.setAttachmentTearFactor() NxCloth.attachToShape NxCloth.attachToCollidingShapes NxCloth.attachVertexToShape + + */ + NxReal attachmentTearFactor; + + /** + \brief Defines a factor for the impulse transfer from this cloth to colliding fluids. + + Only has an effect if the NX_CLF_FLUID_COLLISION flag is set. + + Default: 1.0
+ Range: [0,inf) + + Note: Large values can cause instabilities + + @see NxClothDesc.flags NxClothDesc.fromFluidResponseCoefficient + */ + NxReal toFluidResponseCoefficient; + + /** + \brief Defines a factor for the impulse transfer from colliding fluids to this cloth. + + Only has an effect if the NX_CLF_FLUID_COLLISION flag is set. + + Default: 1.0
+ Range: [0,inf) + + Note: Large values can cause instabilities + + @see NxClothDesc.flags NxClothDesc.toFluidResponseCoefficient + */ + NxReal fromFluidResponseCoefficient; + + /** + \brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame + of the attached actor. + + This feature is useful when the cloth is attached to a fast moving character. + In that case the cloth adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + Default: 1.0 + Range: [0,inf) + + @see NX_CLF_ADHERE + */ + + NxReal minAdhereVelocity; + + /** + \brief Number of solver iterations. + + Note: Small numbers make the simulation faster while the cloth gets less stiff. + + Default: 5 + Range: [1,inf) + + @see NxCloth.setSolverIterations() + */ + + NxU32 solverIterations; + + /** + \brief External acceleration which affects all non attached particles of the cloth. + + Default: (0,0,0) + + @see NxCloth.setExternalAcceleration() + */ + NxVec3 externalAcceleration; + + /** + \brief Acceleration which acts normal to the cloth surface at each vertex. + + Default: (0,0,0) + + @see NxCloth.setWindAcceleration() + */ + NxVec3 windAcceleration; + + /** + \brief The cloth wake up counter. + + Range: [0,inf)
+ Default: 20.0f*0.02f + + @see NxCloth.wakeUp() NxCloth.putToSleep() + */ + NxReal wakeUpCounter; + + /** + \brief Maximum linear velocity at which cloth can go to sleep. + + If negative, the global default will be used. + + Range: [0,inf)
+ Default: -1.0 + + @see NxCloth.setSleepLinearVelocity() NxCloth.getSleepLinearVelocity() + */ + NxReal sleepLinearVelocity; + + /** + \brief The buffers in meshData are used to communicate the dynamic data of the cloth back to the user. + + For example vertex positions, normals, connectivity (triangles) and parent index information. The internal order + of the contents of meshData's buffers will remain the same as that in the initial mesh data used to create the mesh. + + Default: See #NxMeshData + + @see NxMeshData NxCloth.setMeshData() + */ + NxMeshData meshData; + + /** + \brief Sets which collision group this cloth is part of. + + Range: [0, 31] + Default: 0 + + NxCloth.setCollisionGroup() + */ + NxCollisionGroup collisionGroup; + + /** + \brief Sets the 128-bit mask used for collision filtering. + + Default: 0 + + @see NxGroupsMask NxCloth.setGroupsMask() NxCloth.getGroupsMask() + */ + NxGroupsMask groupsMask; + + /** + \brief Force Field Material Index, index != 0 has to be created. + + Default: 0 + */ + NxU16 forceFieldMaterial; + + /** + \brief If the flag NX_CLF_VALIDBOUNDS is set, this variable defines the volume + outside of which cloth particle are automatically removed from the simulation. + + @see NX_CLF_VALIDBOUNDS NxCloth.setValidBounds() + */ + NxBounds3 validBounds; + + /** + \brief This parameter defines the size of grid cells for collision detection. + + The cloth is represented by a set of world aligned cubical cells in broad phase. + The size of these cells is determined by multiplying the length of the diagonal + of the AABB of the initial cloth size with this constant. + + Range: [0.01,inf)
+ Default: 0.25 + */ + NxReal relativeGridSpacing; + + /** + \brief Flag bits. + + Default: NX_CLF_GRAVITY + + @see NxClothFlag NxCloth.setFlags() + */ + NxU32 flags; + + /** + \brief Will be copied to NxCloth::userData + + Default: NULL + + @see NxCloth.userData + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default: NULL + + @see NxCloth.setName() NxCloth.getName() + */ + const char* name; + + /** + \brief The compartment to place the cloth in. Must be either a pointer to an NxCompartment of type NX_SCT_CLOTH, or NULL. + A NULL compartment means creating NX_CLF_HARDWARE cloth in the first available cloth compartment (a default cloth compartment is created if none exists). + Software cloth with a NULL compartment is created in the scene proper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Default: NULL + */ + NxCompartment * compartment; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxClothDesc(); + + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; +}; + +/*----------------------------------------------------------------------------*/ + +NX_INLINE NxClothDesc::NxClothDesc() +{ + setToDefault(); +} + +/*----------------------------------------------------------------------------*/ + +NX_INLINE void NxClothDesc::setToDefault() +{ + clothMesh = NULL; + globalPose.id(); + thickness = 0.01f; + density = 1.0f; + bendingStiffness = 1.0f; + stretchingStiffness = 1.0f; + dampingCoefficient = 0.5f; + friction = 0.5f; + pressure = 1.0f; + tearFactor = 1.5f; + attachmentTearFactor = 1.5f; + attachmentResponseCoefficient = 0.2f; + collisionResponseCoefficient = 0.2f; + toFluidResponseCoefficient = 1.0f; + fromFluidResponseCoefficient = 1.0f; + minAdhereVelocity = 1.0f; + flags = NX_CLF_GRAVITY; + solverIterations = 5; + wakeUpCounter = NX_SLEEP_INTERVAL; + sleepLinearVelocity = -1.0f; + collisionGroup = 0; + forceFieldMaterial = 0; + externalAcceleration.set(0.0f, 0.0f, 0.0f); + windAcceleration.set(0.0f, 0.0f, 0.0f); + groupsMask.bits0 = 0; + groupsMask.bits1 = 0; + groupsMask.bits2 = 0; + groupsMask.bits3 = 0; + validBounds.setEmpty(); + relativeGridSpacing = 0.25f; + meshData.setToDefault(); + userData = NULL; + name = NULL; + compartment = NULL; +} + +/*----------------------------------------------------------------------------*/ + +NX_INLINE bool NxClothDesc::isValid() const +{ +// if (flags & NX_CLF_SELFCOLLISION) return false; // not supported at the moment + + if(!clothMesh) return false; + if(!globalPose.isFinite()) return false; + if(thickness < 0.0f) return false; + if(density <= 0.0f) return false; + if(bendingStiffness < 0.0f || bendingStiffness > 1.0f) return false; + if(stretchingStiffness <= 0.0f || stretchingStiffness > 1.0f) return false; + if(pressure < 0.0f) return false; + if(tearFactor <= 1.0f) return false; + if(attachmentTearFactor <= 1.0f) return false; + if(solverIterations < 1) return false; + if(friction < 0.0f || friction > 1.0f) return false; + if(!meshData.isValid()) return false; + if(dampingCoefficient < 0.0f || dampingCoefficient > 1.0f) return false; + if(collisionResponseCoefficient < 0.0f) return false; + if(wakeUpCounter < 0.0f) return false; + if(attachmentResponseCoefficient < 0.0f || attachmentResponseCoefficient > 1.0f) return false; + if(toFluidResponseCoefficient < 0.0f) return false; + if(fromFluidResponseCoefficient < 0.0f) return false; + if(minAdhereVelocity < 0.0f) return false; + if(relativeGridSpacing < 0.01f) return false; + if(collisionGroup >= 32) return false; // We only support 32 different collision groups + return true; +} + +/*----------------------------------------------------------------------------*/ +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/cloth/NxClothMesh.h b/libraries/external/physx/Win32/include/PX/cloth/NxClothMesh.h new file mode 100755 index 0000000..6ba9896 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/cloth/NxClothMesh.h @@ -0,0 +1,68 @@ +#ifndef NX_PHYSICS_NX_CLOTHMESH +#define NX_PHYSICS_NX_CLOTHMESH +/** \addtogroup cloth + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/cloth/NxClothMeshDesc.h" + +class NxStream; + +class NxClothMesh +{ +protected: + NX_INLINE NxClothMesh() {} + virtual ~NxClothMesh() {} + +public: + /** + \brief Saves the cloth descriptor. + A cloth mesh is created via the cooker. The cooker potentially changes the + order of the arrays references by the pointers points and triangles. + Since saveToDesc returns the data of the cooked mesh, this data might + differ from the originally provided data. Note that this is in contrast to the meshData + member of NxClothDesc, which is guaranteed to provide data in the same order as + that used to create the mesh. + + \param desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxClothMeshDesc + */ + virtual bool saveToDesc(NxClothMeshDesc& desc) const = 0; + + /** + \brief Gets the number of cloth instances referencing this cloth mesh. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCloth + */ + virtual NxU32 getReferenceCount() const = 0; +}; +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/cloth/NxClothMeshDesc.h b/libraries/external/physx/Win32/include/PX/cloth/NxClothMeshDesc.h new file mode 100755 index 0000000..c9a81de --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/cloth/NxClothMeshDesc.h @@ -0,0 +1,166 @@ +#ifndef NX_PHYSICS_NX_CLOTHMESHDESC +#define NX_PHYSICS_NX_CLOTHMESHDESC +/** \addtogroup cloth + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/NxSimpleTriangleMesh.h" + +/** +\brief Cloth mesh flags. + +@see NxClothMeshDesc.flags +*/ + +enum NxClothMeshFlags + { + /** + \brief Specifies whether extra space is allocated for tearing. + If this flag is not set, less memory is needed but tearing is not possible. + These flags for clothMeshes extend the set of flags defined in NxMeshFlags. + */ + NX_CLOTH_MESH_TEARABLE = (1<<8), + /** + \brief Welds close vertices. + + If this flag is set, the cooker maps close vertices (i.e. vertices closer than + NxClothMeshDesc.weldingDistance) to a single internal vertex. + This is useful when more than one vertex at the same location is used for handling + multiple texture coordinates. With welding, the mesh does not fall apart when simulated. + + @see NxClothMeshDesc.weldingDistance + */ + NX_CLOTH_MESH_WELD_VERTICES = (1<<9), + }; + +/** +\brief Cloth vertex flags. + +@see NxClothMeshDesc.vertexFlags +*/ + +enum NxClothVertexFlags + { + /** + \brief Specifies whether a cloth vertex is attached to a global position. + */ + NX_CLOTH_VERTEX_ATTACHED = (1<<0), + + /** + \brief Specifies whether a cloth vertex can be torn. + */ + NX_CLOTH_VERTEX_TEARABLE = (1<<7), + + }; + +/*----------------------------------------------------------------------------*/ + +/** +\brief Descriptor class for #NxClothMesh. + +Note that this class is derived from NxSimpleTriangleMesh which contains the +members that describe the basic mesh. The mesh data is *copied* when an +NxClothMesh object is created from this descriptor. After the creation the +user may discard the basic mesh data. + +@see NxClothMesh NxSimpleTriangleMesh +*/ + +class NxClothMeshDesc : public NxSimpleTriangleMesh +{ +public: + NxU32 vertexMassStrideBytes; //!< Offset between vertex masses in bytes. + NxU32 vertexFlagStrideBytes; //!< Offset between vertex flags in bytes. + + /** + \brief Pointer to first vertex mass. + + Caller may add vertexMassStrideBytes bytes to the pointer to access the next vertex mass. + */ + const void* vertexMasses; + + /** + \brief Pointer to first vertex flag. Flags are of type #NxClothVertexFlags + + Caller may add vertexFlagStrideBytes bytes to the pointer to access the next vertex flag. + */ + const void* vertexFlags; + + /** + \brief For welding close vertices. + + If the NX_CLOTH_MESH_WELD_VERTICES flag is set, the cooker maps close vertices + (i.e. vertices closer than NxClothMeshDesc.weldingDistance) to a single internal vertex. + This is useful when more than one vertex at the same location is used for handling + multiple texture coordinates. With welding, the mesh does not fall apart when simulated. + + @see NxClothMeshFlags + */ + NxReal weldingDistance; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxClothMeshDesc(); + + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; +}; + +/*----------------------------------------------------------------------------*/ + +NX_INLINE NxClothMeshDesc::NxClothMeshDesc() +{ + setToDefault(); +} + +/*----------------------------------------------------------------------------*/ + +NX_INLINE void NxClothMeshDesc::setToDefault() +{ + NxSimpleTriangleMesh::setToDefault(); + vertexMassStrideBytes = sizeof(NxReal); + vertexFlagStrideBytes = sizeof(NxU32); + vertexMasses = NULL; + vertexFlags = NULL; + weldingDistance = 0.0f; +} + +/*----------------------------------------------------------------------------*/ + +NX_INLINE bool NxClothMeshDesc::isValid() const +{ + if(vertexMasses && (vertexMassStrideBytes < sizeof(NxReal))) + return false; + if(vertexFlags && (vertexFlagStrideBytes < sizeof(NxU32))) + return false; + if(weldingDistance < 0.0f) + return false; + + return NxSimpleTriangleMesh::isValid(); +} + +/*----------------------------------------------------------------------------*/ +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/cloth/vssver.scc b/libraries/external/physx/Win32/include/PX/cloth/vssver.scc new file mode 100755 index 0000000..52b614b Binary files /dev/null and b/libraries/external/physx/Win32/include/PX/cloth/vssver.scc differ diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxFluid.h b/libraries/external/physx/Win32/include/PX/fluids/NxFluid.h new file mode 100755 index 0000000..48ad38f --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxFluid.h @@ -0,0 +1,1309 @@ +#ifndef NX_PHYSICS_NX_FLUIDACTOR +#define NX_PHYSICS_NX_FLUIDACTOR +/** \addtogroup fluids + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +#include "PX/Nxp.h" +#include "PX/NxArray.h" +#include "PX/NxBounds3.h" +#include "PX/fluids/NxFluidDesc.h" +#include "PX/NxPhysicsSDK.h" + +class NxFluidEmitterDesc; +class NxFluidEmitter; +class NxCompartment; + +/** +\brief The fluid class represents the main module for the particle based fluid simulation. +SPH (Smoothed Particle Hydrodynamics) is used to animate the particles. + +There are two kinds of particle interaction forces which govern the behaviour of the fluid: +
    +
  1. + Pressure forces: These forces result from particle densities higher than the + "rest density" of the fluid. The rest density is given by specifying the inter-particle + distance at which the fluid is in its relaxed state. Particles which are closer than + the rest spacing are pushed away from each other. +
  2. + Viscosity forces: These forces act on neighboring particles depending on the difference + of their velocities. Particles drag other particles with them which is used to simulate the + viscous behaviour of the fluid. +
+The fluid class manages a set of particles. +Particles can be created in two ways: +
    +
  1. + Particles can be added by the user directly. +
  2. + The user can add emitters to the fluid and configure the parameters of the emission. + (See NxFluidEmitter) +
+Particles can be removed in two ways as well: +
    +
  1. + The user can specify a lifetime for the particles. When its lifetime expires, a particle is deleted. +
  2. + Shapes can be configured to act as drains. When a particle intersects with a drain, the particle is deleted. + (See NxShapeFlag) +
+Particles collide with static and dynamic shapes. Particles are also affected by the scene gravity and a user force, +as well as global velocity damping. In order to render a fluid, the user can supply the fluid instance with a +user buffer into which the particle state is written after each simuation step. + +For a good introduction to SPH fluid simulation, +see http://graphics.ethz.ch/~mattmuel/publications/sca03.pdf + +@see NxFluidDesc, NxFluidEmitter, NxFluidEmitterDesc, NxMeshData, NxParticleData, NxShapeFlag +*/ +class NxFluid + { + protected: + NX_INLINE NxFluid() : userData(NULL) {} + virtual ~NxFluid() {} + + public: + +/************************************************************************************************/ + +/** @name Emitters +*/ +//@{ + + /** + \brief Creates an emitter for this fluid. + + NxFluidEmitterDesc::isValid() must return true. + + \param desc The fluid emitter desciptor. See #NxFluidEmitterDesc. + \return The new fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitter + */ + virtual NxFluidEmitter* createEmitter(const NxFluidEmitterDesc& desc) = 0; + + /** + \brief Deletes the specified emitter. + + The emitter must belong to this fluid. Do not keep a reference to the deleted instance. + Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). + + \param emitter The emitter to release. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void releaseEmitter(NxFluidEmitter& emitter) = 0; + + /** + \brief Returns the number of emitters. + + \return The number of emitters. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbEmitters() const = 0; + + /** + \brief Returns an array of emitter pointers with size getNbEmitters(). + + \return An array of fluid emitter pointers. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxFluidEmitter** getEmitters() const = 0; +//@} + +/** @name Particle Manipulation +*/ +//@{ + + /** + \brief Adds particles to the simulation specified with the user buffer wrapper. + + The SDK only accesses the wrapped buffers until the function returns. + The limit for adding particles is 4096 new particles per timestep. + This method can be called several times. Each call writes particle ids to the + particle creation id buffer, if the user has registered one with either + NxFluidDesc::particleCreationIdWriteData or + NxFluid::setParticleCreationIdWriteData(const NxParticleIdData&). User particle and packet + buffers are also updated accordingly. By default particle ids get overwritten with each call. + Optionally the caller can choose to have the ids be appended instead. Note that the particle + creation id buffer gets always overwritten on NxScene::fetchResults(). + + \param pData Structure describing the particles to add. + \param appendIds selects particle appending or overwriting. + \return number of successfully created particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleData + */ + virtual NxU32 addParticles(const NxParticleData& pData, bool appendIds = false) = 0; + + /** + \brief Removes all particles from the simulation. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void removeAllParticles() = 0; + + /** + \brief Sets the wrapper for user buffers, which configure where particle data is written to. + + \param pData The descriptor for the buffers to write the particle data to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleData + */ + virtual void setParticlesWriteData(const NxParticleData& pData) = 0; + + /** + \brief Returns a copy of the wrapper which was set by setParticlesWriteData(). + + \return The particle write data. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleData The descriptor for the buffers to write the particle data to. + */ + virtual NxParticleData getParticlesWriteData() const = 0; + + /** + \brief Sets the wrapper for user ID buffers, which configure where IDs of deleted particles are written to. + + \param iData The descriptor for the buffers to write the particle IDs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleIdData + */ + virtual void setParticleDeletionIdWriteData(const NxParticleIdData& iData) = 0; + + /** + \brief Returns a copy of the wrapper which was set by setParticleDeletionIdWriteData(). + + \return The particle ID write data. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleIdData The descriptor for the buffers to write the particle IDs to. + */ + virtual NxParticleIdData getParticleDeletionIdWriteData() const = 0; + + /** + \brief Sets the wrapper for user ID buffers, which configure where IDs of created particles are written to. + + \param iData The descriptor for the buffers to write the particle IDs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleIdData + */ + virtual void setParticleCreationIdWriteData(const NxParticleIdData& iData) = 0; + + /** + \brief Returns a copy of the wrapper which was set by setParticleCreationIdWriteData(). + + \return The particle ID write data. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxParticleIdData The descriptor for the buffers to write the particle IDs to. + */ + virtual NxParticleIdData getParticleCreationIdWriteData() const = 0; + + /** + \brief Gets the number of particles which are reserved for creation at runtime. + + @see NxFluidDesc.numReserveParticles + */ + virtual NxU32 getNumReserveParticles() const = 0; + + /** + \brief Sets the number of particles which are reserved for creation at runtime. + + @see NxFluidDesc.numReserveParticles + */ + virtual void setNumReserveParticles(NxU32) = 0; + + + /** + \brief Gets the bound on the maximum number of particles currently allowed in the fluid. + + @see setCurrentParticleLimit + */ + virtual NxU32 getCurrentParticleLimit() const = 0; + + /** + \brief Sets a bound on the maximum number of particles in the fluid. + + The value defaults to maxParticles, which is its maximum legal value. If it is lowered below + the number of particles currently in the fluid, the oldest particles will be deleted to bring down + the number. This attribute is only effective if the NX_FF_PRIORITY_MODE flag is set on the fluid. + + */ + virtual void setCurrentParticleLimit(NxU32) = 0; + + + + /** + \brief Updates particles for one simulation frame. + + @see NxParticleUpdateData + */ + virtual void updateParticles(const NxParticleUpdateData&) = 0; + + /** + \brief Sets the wrapper for user buffers, which configure where fluid packet data is written to. + + \param pData The descriptor for the buffers to write the fluid packet data to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidPacketData + */ + virtual void setFluidPacketData(const NxFluidPacketData& pData) = 0; + + /** + \brief Returns a copy of the wrapper which was set by setFluidPacketData(). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidPacketData + */ + virtual NxFluidPacketData getFluidPacketData() const = 0; + +//@} +/************************************************************************************************/ + +/** @name Fluid Parameters +*/ +//@{ + + /** + \brief Returns the simulation method of the fluid. + + + \return The simulation method. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidSimulationMethod + */ + virtual NxU32 getSimulationMethod() const = 0; + + /** + \brief Sets the simulation method of the fluid. + + Can either be set to NX_F_SPH, NX_F_NO_PARTICLE_INTERACTION or NX_F_MIXED_MODE. + Note that depending on the spatial arrangement of the particles, switching from + NX_F_NO_PARTICLE_INTERACTION or NX_F_MIXED_MODE to NX_F_SPH might lead to an + unstable simulation state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidSimulationMethod + */ + virtual void setSimulationMethod(NxU32 simMethod) = 0; + + /** + \brief Returns the fluid stiffness. + + \return The fluid stiffness. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.stiffness + */ + virtual NxReal getStiffness() const = 0; + + /** + \brief Sets the fluid stiffness (must be positive). + + \param stiff The new fluid stiffness. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.stiffness + */ + virtual void setStiffness(NxReal stiff) = 0; + + /** + \brief Returns the fluid viscosity. + + \return The viscosity of the fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.viscosity + */ + virtual NxReal getViscosity() const = 0; + + /** + \brief Sets the fluid viscosity (must be positive). + + \param visc The new viscosity of the fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.viscosity + */ + virtual void setViscosity(NxReal visc) = 0; + + /** + \brief Returns the fluid surfaceTension. + + \return The surfaceTension of the fluid. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxFluidDesc.surfaceTension + */ + virtual NxReal getSurfaceTension() const = 0; + + /** + \brief Sets the fluid surfaceTension (must be nonnegative). + + \param surfaceTension The new surfaceTension of the fluid. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + @see NxFluidDesc.surfaceTension + */ + virtual void setSurfaceTension(NxReal surfaceTension) = 0; + + /** + \brief Returns the fluid damping. + + \return The fluid damping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.damping + */ + virtual NxReal getDamping() const = 0; + + /** + \brief Sets the fluid damping (must be nonnegative). + + \param damp The new fluid damping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.damping + */ + virtual void setDamping(NxReal damp) = 0; + + /** + \brief Returns the fluid fadeInTime. + + \return The fluid fadeInTime. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + Experimental feature. + + @see NxFluidDesc.fadeInTime + */ + virtual NxReal getFadeInTime() const = 0; + + /** + \brief Sets the fluid fadeInTime (must be nonnegative). + + \param fadeIn The new fadeInTime. + + Platform: + \li PC SW: No + \li PPU : No + \li PS3 : No + \li XB360: No + + Experimental feature. + + @see NxFluidDesc.fadeInTime + */ + virtual void setFadeInTime(NxReal fadeIn) = 0; + + /** + \brief Returns the external acceleration applied to each particle at each time step. + + \return The external acceleration applied to particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.externalAcceleration + */ + virtual NxVec3 getExternalAcceleration() const = 0; + + /** + \brief Sets the external acceleration applied to each particle at each time step. + + \param acceleration External acceleration to apply to particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.externalAcceleration getExternalAcceleration() + */ + virtual void setExternalAcceleration(const NxVec3&acceleration) = 0; + + /** + \brief Returns the plane the fluid particles are projected to. + + \return The particle projection plane. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NX_FF_PROJECT_TO_PLANE NxFluidDesc.projectionPlane + */ + virtual NxPlane getProjectionPlane() const = 0; + + /** + \brief Sets the plane the fluid particles are projected to. + + \param plane Particle projection plane. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NX_FF_PROJECT_TO_PLANE NxFluidDesc.projectionPlane + */ + virtual void setProjectionPlane(const NxPlane& plane) = 0; +//@} +/************************************************************************************************/ + +/** @name Collisions +*/ +//@{ + + /** + \brief Returns the collision method of the fluid. + + \return The collision method. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidCollisionMethod + */ + virtual NxU32 getCollisionMethod() const = 0; + + /** + \brief Sets the collision method of the fluid. + + Can be set to a combination of NX_F_STATIC and NX_F_DYNAMIC. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidCollisionMethod + */ + virtual void setCollisionMethod(NxU32 collMethod) = 0; + + /** + \brief Returns the restitution used for collision with static shapes. + + \return The static collision restitution. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.restitutionForStaticShapes + */ + virtual NxReal getRestitutionForStaticShapes() const = 0; + + /** + \brief Sets the restitution used for collision with static shapes. + + Must be between 0 and 1. + + \param rest The new restitution for static shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.restitutionForStaticShapes + */ + virtual void setRestitutionForStaticShapes(NxReal rest) = 0; + + /** + \brief Returns the dynamic friction used for collision with static shapes. + + \return The dynamic friction used for static shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.dynamicFrictionForStaticShapes + */ + virtual NxReal getDynamicFrictionForStaticShapes() const = 0; + + /** + \brief Sets the dynamic friction used for collision with static actors. + + Must be between 0 and 1. + + \param adhesion The new dynamic friction used for static shapes + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.dynamicFrictionForStaticShapes + */ + virtual void setDynamicFrictionForStaticShapes(NxReal friction) = 0; + + /** + \brief Returns the static friction used for collision with static shapes. + + This feature is currently unimplemented! + + */ + virtual NxReal getStaticFrictionForStaticShapes() const = 0; + + /** + \brief Sets the static friction used for collision with static actors. + + This feature is currently unimplemented! + + */ + virtual void setStaticFrictionForStaticShapes(NxReal friction) = 0; + + /** + \brief Returns the attraction used for collision with static actors. + + This feature is currently unimplemented! + + */ + virtual NxReal getAttractionForStaticShapes() const = 0; + + /** + \brief Sets the attraction used for collision with static actors. + + This feature is currently unimplemented! + + */ + virtual void setAttractionForStaticShapes(NxReal attraction) = 0; + + /** + \brief Returns the restitution used for collision with dynamic actors. + + \return The collision resitution for dynamic shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.restitutionForDynamicShapes + */ + virtual NxReal getRestitutionForDynamicShapes() const = 0; + + /** + \brief Sets the restitution used for collision with dynamic actors. + + Must be between 0 and 1. + + \param rest The new collision restitution for dynamic shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.restitutionForDynamicShapes + */ + virtual void setRestitutionForDynamicShapes(NxReal rest) = 0; + + /** + \brief Returns the dynamic friction used for collision with dynamic shapes. + + \return The dynamic friction used for dynamic shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.dynamicFrictionForDynamicShapes + */ + virtual NxReal getDynamicFrictionForDynamicShapes() const = 0; + + /** + \brief Sets the dynamic friction used for collision with dynamic shapes. + + Must be between 0 and 1. + + \param friction The new dynamic friciton used for dynamic shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.dynamicFrictionForDynamicShapes + */ + virtual void setDynamicFrictionForDynamicShapes(NxReal friction) = 0; + + /** + \brief Returns the static friction used for collision with dynamic shapes. + + This feature is currently unimplemented! + + */ + virtual NxReal getStaticFrictionForDynamicShapes() const = 0; + + /** + \brief Sets the static friction used for collision with dynamic shapes. + + This feature is currently unimplemented! + + */ + virtual void setStaticFrictionForDynamicShapes(NxReal friction) = 0; + + /** + \brief Returns the attraction used for collision with dynamic actors. + + This feature is currently unimplemented! + + */ + virtual NxReal getAttractionForDynamicShapes() const = 0; + + /** + \brief Sets the attraction used for collision with dynamic actors. + + This feature is currently unimplemented! + + */ + virtual void setAttractionForDynamicShapes(NxReal attraction) = 0; + + /** + \brief Sets the collision response coefficient. + + \param[in] coefficient The collision response coefficient (0 or greater). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.collisionResponseCoefficient getCollisionResponseCoefficient() + */ + virtual void setCollisionResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves the collision response coefficient. + + \return The collision response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.collisionResponseCoefficient setCollisionResponseCoefficient() + */ + virtual NxReal getCollisionResponseCoefficient() const = 0; + + +//@} +/************************************************************************************************/ + + + /** + \brief Sets actor flags. + + \param flag Member of #NxFluidFlag. + \param val New flag value. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.flags + */ + virtual void setFlag(NxFluidFlag flag, bool val) = 0; + + /** + \brief Returns actor flags. + + \param flag Member of #NxFluidFlag. + \return The current flag value. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.flags + */ + virtual NX_BOOL getFlag(NxFluidFlag flag) const = 0; + + /** + \brief Retrieves the scene which this fluid belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: No + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + +/************************************************************************************************/ + +/** @name Fluid Property Read Back +*/ +//@{ + + /** + \brief Returns the maximum number of particles for this fluid. + + \return Max number of particles for this fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.maxParticles + */ + virtual NxU32 getMaxParticles() const = 0; + + /** + \brief Returns the kernel radius multiplier (the particle interact within a radius of + getRestParticleDistance() * getKernelRadiusMultiplier() ). + + \return The kernel radius multiplier. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.kernelRadiusMultiplier + */ + virtual NxReal getKernelRadiusMultiplier() const = 0; + + /** + \brief Returns the motion limit multiplier (the particle can move the maximal distance of + getRestParticleDistance() * getMotionLimitMultiplier() during one timestep). + + \return motion limit multiplier. + + @see getRestParticleDistance() + */ + virtual NxReal getMotionLimitMultiplier() const = 0; + + /** + \brief Returns the distance between particles and collision geometry, which is maintained during simulation. + + ( distance = getCollisionDistanceMultiplier()/getRestParticlesPerMeter() ). + + \return collision distance multiplier. + @see getRestParticleDistance() + */ + virtual NxReal getCollisionDistanceMultiplier() const = 0; + + /** + \brief Returns the fluid packet size used for parallelization of the fluid computations. + + \return The packet size multiplier. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getPacketSizeMultiplier() const = 0; + + /** + \brief Returns the number of particles per meter in the relaxed state of the fluid. + + \return Rest particles per meter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.restParticlesPerMeter + */ + virtual NxReal getRestParticlesPerMeter() const = 0; + + /** + \brief Returns the density in the relaxed state of the fluid. + + \return Rest density. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.restDensity + */ + virtual NxReal getRestDensity() const = 0; + + /** + \brief Returns the inter-particle distance in the relaxed state of the fluid. + + This is the reciprocal of the value given by getRestParticlesPerMeter() + + \return Rest particle distance. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxReal getRestParticleDistance() const = 0; + + /** + \brief Returns the mass of a particle. This value is dependent on the rest inter-particle + distance and the rest density of the fluid. + + \return Particle mass. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getRestParticleDistance() + @see getRestDensity() + */ + virtual NxReal getParticleMass() const = 0; + + /** + \brief Sets which collision group this fluid is part of. + + \param[in] collisionGroup The collision group for this fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup + */ + virtual void setGroup(NxCollisionGroup collisionGroup) = 0; + + /** + \brief Retrieves the value set with #setGroup(). + + \return The collision group this fluid belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup + */ + virtual NxCollisionGroup getGroup() const = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. + + \param[in] groupsMask The group mask to set for the fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGroupsMask() NxGroupsMask + */ + virtual void setGroupsMask(const NxGroupsMask& groupsMask) = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. + + \return The group mask for the fluid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGroupsMask() NxGroupsMask + */ + virtual const NxGroupsMask getGroupsMask() const = 0; + + /** + \brief Returns the minimal (exact) world space axis aligned bounding box (AABB) + including all simulated particles. + + \param dest Used to store the world bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void getWorldBounds(NxBounds3& dest) const = 0; +//@} +/************************************************************************************************/ + + +/** @name Fluid Descriptor Operations +*/ +//@{ + + /** + \brief Loads the fluid descriptor. + + \param[in] desc The descriptor used to restore the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc + */ + virtual bool loadFromDesc(const NxFluidDescBase& desc) = 0; + + /** + \brief Saves the fluid descriptor. + + This method does not save out any emitters to the emitter array of the fluid desctriptor, + nor does it store particle data or any other user pointer. You can use NxFluid::saveEmittersToFluidDesc(NxFluidDesc &) + to store the emitters of a fluid to a fluid descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc + @see saveEmittersToDesc + */ + virtual bool saveToDesc(NxFluidDescBase &desc) const = 0; + + /** + \brief Get the PPU simulation time. + + This method returns the time taken to simulate the fluid on the PPU in units + which are proportional to time but whose units are otherwise unspecified. + + \return the simulation time + Platform: + \li SW : No + \li PPU : Yes + \li PS3 : No + \li XB360: No + + */ + + virtual NxU32 getPPUTime() const = 0; + +//@} +/************************************************************************************************/ + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the + SDK, only the pointer is stored. + + \param name The new name. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setName(const char* name) = 0; + + /** + \brief Returns the name string set with setName(). + + \return The current name. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual const char* getName() const = 0; + + + /** + \brief Retrieves the fluid's simulation compartment, as specified by the user at creation time. + \return NULL if the fluid is not simulated in a compartment or if it was specified to run in + the default fluid compartment, otherwise the simulation compartment. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartment + */ + virtual NxCompartment * getCompartment() const = 0; + + +/************************************************************************************************/ + + /** + \brief Retrieves the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldMaterial getForceFieldMaterial() const = 0; + + /** + \brief Sets the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setForceFieldMaterial(NxForceFieldMaterial) = 0; + +/************************************************************************************************/ + + /** + \brief Helper function to save fluidEmitters to a fluidDescriptor. + + \param[out] desc Descriptor to save to. + \return True if the resulting fluid descriptor is valid. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE bool saveEmittersToFluidDesc(NxFluidDesc &desc); + + template + NX_INLINE bool saveEmittersToFluidDesc_Template(NxFluidDesc_Template &desc); + +/************************************************************************************************/ + + + //public variables: + void* userData; //!< The user can set this to anything, usually to create a 1:1 relationship with a user object. + }; + +NX_INLINE bool NxFluid::saveEmittersToFluidDesc(NxFluidDesc &desc) + { + NxU32 numEmitters = getNbEmitters(); + NxFluidEmitter** emitter = getEmitters(); + for(NxU32 i = 0; i < numEmitters; i++) + { + NxFluidEmitterDesc emitterDesc; + emitter[i]->saveToDesc(emitterDesc); + desc.emitters.pushBack(emitterDesc); + } + return desc.isValid(); + } + +template +NX_INLINE bool NxFluid::saveEmittersToFluidDesc_Template(NxFluidDesc_Template &desc) + { + NxU32 numEmitters = getNbEmitters(); + NxFluidEmitter** emitter = getEmitters(); + for(NxU32 i = 0; i < numEmitters; i++) + { + NxFluidEmitterDesc emitterDesc; + emitter[i]->saveToDesc(emitterDesc); + desc.emitters.pushBack(emitterDesc); + } + return desc.isValid(); + } + +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxFluidDesc.h b/libraries/external/physx/Win32/include/PX/fluids/NxFluidDesc.h new file mode 100755 index 0000000..70d296b --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxFluidDesc.h @@ -0,0 +1,814 @@ +#ifndef NX_FLUIDS_NXFLUIDACTORDESC +#define NX_FLUIDS_NXFLUIDACTORDESC +/** \addtogroup fluids + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/NxMeshData.h" +#include "PX/fluids/NxParticleData.h" +#include "PX/fluids/NxParticleIdData.h" +#include "PX/fluids/NxParticleUpdateData.h" +#include "PX/fluids/NxFluidPacketData.h" +#include "PX/fluids/NxFluidEmitterDesc.h" + +#include "PX/NxSceneDesc.h" + +#include "PX/NxArray.h" +#include "PX/NxPlane.h" + +class NxCompartment; + +enum NxFluidDescType +{ + NX_FDT_DEFAULT, + NX_FDT_ALLOCATOR +}; + +/** +\brief Describes the particle simulation method + +Particles can be treated in two ways: either they are simulated considering +interparticular forces (SPH), or they are simulated independently. +In the latter case (with the simulation method set to NX_F_NO_PARTICLE_INTERACTION), +you still get collision between particles and static/dynamic shapes, damping, +acceleration due to gravity, and the user force. +*/ +enum NxFluidSimulationMethod + { + /** + \brief Enable simulation of inter particle forces. + */ + NX_F_SPH = (1<<0), + + /** + \brief Do not simulate inter particle forces. + */ + NX_F_NO_PARTICLE_INTERACTION = (1<<1), + + /** + \brief Alternate between SPH and simple particles + */ + NX_F_MIXED_MODE = (1<<2), + }; + +/** +\brief The fluid collision method + +The NxFluid instance can be selected for collision with both static and dynamic shapes. + +Platform: +\li PC SW: Yes +\li PPU : Yes +\li PS3 : No +\li XB360: No +*/ +enum NxFluidCollisionMethod + { + NX_F_STATIC = (1<<0), + NX_F_DYNAMIC = (1<<1), + }; + +/** +\brief Fluid flags +*/ +enum NxFluidFlag + { + /** + \brief Enables debug visualization for the NxFluid. + */ + NX_FF_VISUALIZATION = (1<<0), + + /** + \brief Disables scene gravity for the NxFluid. + */ + NX_FF_DISABLE_GRAVITY = (1<<1), + + /** + \brief Enable/disable two way collision of fluid with the rigid body scene. + In either case, fluid is influenced by colliding rigid bodies. + If NX_FF_COLLISION_TWOWAY is not set, rigid bodies are not influenced by + colliding pieces of fluid. Use NxFluidDesc.collisionResponseCoefficient to + control the strength of the feedback force on rigid bodies. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluieDesc.collisionResponseCoefficient + */ + NX_FF_COLLISION_TWOWAY = (1<<2), + + + /** + \brief Enable/disable execution of fluid simulation. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_FF_ENABLED = (1<<3), + + /** + \brief Defines whether this fluid is simulated on the PPU. + */ + NX_FF_HARDWARE = (1<<4), + + /** + \brief Enable/disable particle priority mode. + If enabled, the oldest particles are deleted to keep a certain budget for + new particles. Note that particles which have equal lifetime can get deleted + at the same time. In order to avoid this, the particle lifetimes + can be varied randomly. + + @see NxFluidDesc.numReserveParticles + */ + NX_FF_PRIORITY_MODE = (1<<5), + + /** + \brief Defines whether the particles of this fluid should be projected to a plane. + This can be used to build 2D fluid applications, for instance. The projection + plane is defined by the parameter NxFluidDesc.projectionPlane. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidDesc.projectionPlane + */ + NX_FF_PROJECT_TO_PLANE = (1<<6), + + /** + \brief Forces fluid static mesh cooking format to parameters given by the fluid descriptor. + + Currently not implemented! + */ + NX_FF_FORCE_STRICT_COOKING_FORMAT = (1<<7), + + }; + +/** +\brief Describes an NxFluid. +*/ +class NxFluidDescBase + { + public: + + /** + \brief Describes the particles which are added to the fluid initially. + + The pointers to the buffers are invalidated after the initial particles are generated. + + @see NxParticleData + */ + NxParticleData initialParticleData; + + /** + \brief Sets the maximal number of particles for the fluid used in the simulation. + + If more particles are added directly, or more particles are emitted into the + fluid after this limit is reached, they are simply ignored. + + */ + NxU32 maxParticles; + + /** + \brief Defines the number of particles which are reserved for creation at runtime. + + If NxFluidDesc.flags.NX_FF_PRIORITY_MODE is set the oldest particles are removed until + there are no more than (maxParticles - numReserveParticles) particles left. This removal + is carried out for each simulation step, on particles which have a finite life time + (i.e. > 0.0). The deletion guarantees a reserve of numReserveParticles particles which + can be added for each simulaiton step. Note that particles which have equal lifetime can + get deleted at the same time. In order to avoid this, the particle lifetimes + can be varied randomly. + + This parameter must be smaller than NxFluidDesc.maxParticles. + */ + NxU32 numReserveParticles; + + /** + \brief The particle resolution given as particles per linear meter measured when the fluid is + in its rest state (relaxed). + + Even if the particle system is simulated without particle interactions, this parameter defines the + emission density of the emitters. + + */ + NxReal restParticlesPerMeter; + + /** + \brief Target density for the fluid (water is about 1000). + + Even if the particle system is simulated without particle interactions, this parameter defines + indirectly in combination with restParticlesPerMeter the mass of one particle + ( mass = restDensity/(restParticlesPerMeter^3) ). + + The particle mass has an impact on the repulsion effect on emitters and actors. + + */ + NxReal restDensity; + + /** + \brief Radius of sphere of influence for particle interaction. + + This parameter is relative to the rest spacing of the particles, which is defined by the parameter + restParticlesPerMeter + + ( radius = kernelRadiusMultiplier/restParticlesPerMeter ). + + This parameter should be set around 2.0 and definitely below 2.5 for optimal performance and simulation quality. + + @see restParticlesPerMeter + */ + NxReal kernelRadiusMultiplier; + + /** + \brief Maximal distance a particle is allowed to travel within one timestep. + + This parameter is relative to the rest spacing of the particles, which is defined by the parameter + restParticlesPerMeter: + + ( maximal travel distance = motionLimitMultiplier/restParticlesPerMeter ). + + Default value is 3.6 (i.e., 3.0 * kernelRadiusMultiplier). + + The value must not be higher than the product of packetSizeMultiplier and kernelRadiusMultiplier. + + @see restParticlesPerMeter + */ + NxReal motionLimitMultiplier; + + /** + \brief Defines the distance between particles and collision geometry, which is maintained during simulation. + + For the actual distance, this parameter is divided by the rest spacing of the particles, which is defined by the parameter + restParticlesPerMeter: + + ( distance = collisionDistanceMultiplier/restParticlesPerMeter ). + + It has to be positive and not higher than packetSizeMultiplier*kernelRadiusMultiplier. + Default value is 0.12 (i.e., 0.1 * kernelRadiusMultiplier). + + @see restParticlesPerMeter, kernelRadiusMultiplier + */ + NxReal collisionDistanceMultiplier; + + /** + \brief This parameter controls the parallelization of the fluid. + + The spatial domain is divided into so called packets, equal sized cubes, aligned in a grid. + + The parameter given defines the edge length of such a packet. This parameter is relative to the interaction + radius of the particles, given as kernelRadiusMultiplier/restParticlesPerMeter. + + It has to be a power of two, no less than 4. + + */ + NxU32 packetSizeMultiplier; + + /** + \brief The stiffness of the particle interaction related to the pressure. + + This factor linearly scales the force which acts on particles which are closer to each other than + the rest spacing. + + Setting this parameter appropriately is crucial for the simulation. The right value depends on many factors + such as viscosity, damping, and kernelRadiusMultiplier. Values which are too high will result in an + unstable simulation, whereas too low values will make the fluid appear "springy" (the fluid + acts more compressible). + + Must be positive. + + */ + NxReal stiffness; + + /** + \brief The viscosity of the fluid defines its viscous behavior. + + Higher values will result in a honey-like behavior. Viscosity is an effect which depends on the + relative velocity of neighboring particles; it reduces the magnitude of the relative velocity. + + Must be positive. + + */ + NxReal viscosity; + + /** + \brief The surfaceTension of the fluid defines an attractive force between particles + + Higher values will result in smoother surfaces. + Must be nonnegative. + + */ + NxReal surfaceTension; + + /** + \brief Velocity damping constant, which is globally applied to each particle. + + It generally reduces the velocity of the particles. Setting the damping to 0 will leave the + particles unaffected. + + Must be nonnegative. + + */ + NxReal damping; + + /** + \brief Defines a timespan for the particle "fade-in". + + This feature is experimental. When a particle is created it has no influence on the simulation. + It takes fadeInTime until the particle has full influence. If set to zero, the particle has full + influence on the simulation from start. + + Default: 0.0
+ Range: [0,inf) + */ + NxReal fadeInTime; + + /** + \brief Acceleration (m/s^2) applied to all particles at all time steps. + + Useful to simulate smoke or fire. + This acceleration is additive to the scene gravity. The scene gravity can be turned off + for the fluid, using the flag NX_FF_DISABLE_GRAVITY. + + @see NxFluid.getExternalAcceleration() NxFluid.setExternalAcceleration() + */ + NxVec3 externalAcceleration; + + /** + \brief Defines the plane the fluid particles are projected to. This parameter is only used if + NX_FF_PROJECT_TO_PLANE is set. + + Default: XY plane + + @see NX_FF_PROJECT_TO_PLANE NxFluid.getProjectionPlane() NxFluid.setProjectionPlane() + */ + NxPlane projectionPlane; + + /** + \brief Defines the restitution coefficient used for collisions of the fluid particles with static shapes. + + Must be between 0 and 1. + + A value of 0 causes the colliding particle to get a zero velocity component in the + direction of the surface normal of the static shape at the collision location; i.e. + it will not bounce. + + A value of 1 causes a particle's velocity component in the direction of the surface normal to invert; + i.e. the particle bounces off the surface with the same velocity magnitude as it had before collision. + (Caution: values near 1 may have a negative impact on stability) + + */ + NxReal restitutionForStaticShapes; + + /** + \brief Defines the dynamic friction of the fluid regarding the surface of a static shape. + + Must be between 0 and 1. + + A value of 1 will cause the particle to lose its velocity tangential to + the surface normal of the shape at the collision location; i.e. it will not slide + along the surface. + + A value of 0 will preserve the particle's velocity in the tangential surface + direction; i.e. it will slide without resistance on the surface. + + */ + NxReal dynamicFrictionForStaticShapes; + + /** + \brief Defines the static friction of the fluid regarding the surface of a static shape. + + This feature is currently unimplemented! + + */ + NxReal staticFrictionForStaticShapes; + + /** + \brief Defines the strength of attraction between the particles and static rigid bodies on collision. + + This feature is currently unimplemented! + + */ + NxReal attractionForStaticShapes; + + /** + \brief Defines the restitution coefficient used for collisions of the fluid particles with dynamic shapes. + + Must be between 0 and 1. + + (Caution: values near 1 may have a negative impact on stability) + + @see restitutionForStaticShapes + */ + NxReal restitutionForDynamicShapes; + + /** + \brief Defines the dynamic friction of the fluid regarding the surface of a dynamic shape. + + Must be between 0 and 1. + + @see dynamicFrictionForStaticShapes + */ + NxReal dynamicFrictionForDynamicShapes; + + /** + \brief Defines the static friction of the fluid regarding the surface of a dynamic shape. + + This feature is currently unimplemented! + + */ + NxReal staticFrictionForDynamicShapes; + + /** + \brief Defines the strength of attraction between the particles and the dynamic rigid bodies on collision. + + This feature is currently unimplemented! + + */ + NxReal attractionForDynamicShapes; + + /** + \brief Defines a factor for the impulse transfer from fluid to colliding rigid bodies. + + Only has an effect if NX_FF_COLLISION_TWOWAY is set. + + Default: 0.2
+ Range: [0,inf) + + @see NX_FF_COLLISION_TWOWAY NxFluid.setCollisionResponseCoefficient() + */ + NxReal collisionResponseCoefficient; + + /** + \brief NxFluidSimulationMethod flags. Defines whether or not particle interactions are considered + in the simulation. + + @see NxFluidSimulationMethod + */ + NxU32 simulationMethod; + + /** + \brief NxFluidCollisionMethod flags. Selects whether static collision and/or dynamic collision + with the environment is performed. + + @see NxFluidCollisionMethod + */ + NxU32 collisionMethod; + + /** + \brief Sets which collision group this fluid is part of. + + Default: 0 + + NxFluid.setCollisionGroup() + */ + NxCollisionGroup collisionGroup; + + + /** + \brief Sets the 128-bit mask used for collision filtering. + + Default: 0 + + @see NxGroupsMask NxFluid.setGroupsMask() NxFluid.getGroupsMask() + */ + NxGroupsMask groupsMask; + + /** + \brief Force Field Material Index, index != 0 has to be created. + + Default: 0 + */ + NxForceFieldMaterial forceFieldMaterial; + + /** + \brief Defines the user data buffers which are used to store particle data, which can be used for rendering. + + @see NxParticleData + */ + NxParticleData particlesWriteData; + + /** + \brief Defines the user data buffer which is used to store IDs of deleted particles. + + @see NxParticleIdData + */ + NxParticleIdData particleDeletionIdWriteData; + + /** + \brief Defines the user data buffer which is used to store IDs of created particles. + + @see NxParticleIdData + */ + NxParticleIdData particleCreationIdWriteData; + + /** + \brief Defines the user data buffer which is used to store fluid packets. + + @see NxFluidPacketData + */ + NxFluidPacketData fluidPacketData; + + /** + \brief Flags defining certain properties of the fluid. + + @see NxFluidFlag + */ + NxU32 flags; + + void* userData; //!< Will be copied to NxFluid::userData + const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + /** + \brief The compartment to place the fluid in. Must be either a pointer to an NxCompartment of type NX_SCT_FLUID, or NULL. + A NULL compartment means creating the fluid in the first available fluid compartment (a default fluid compartment is created if none exists). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Default: NULL + */ + NxCompartment * compartment; + + /** + \brief Constructor sets to default. + + */ + NX_INLINE NxFluidDescBase(); + /** + \brief (Re)sets the structure to the default. + + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + + */ + NX_INLINE bool isValid() const; + + + /** + \brief Retrieve the fluid desc type. + + \return The fluid desc type. See #NxFluidDescType + */ + NX_INLINE NxFluidDescType getType() const; + + protected: + + NxFluidDescType type; + + }; + +/** +\brief Fluid Descriptor. This structure is used to save and load the state of #NxFluid objects. + +Legacy implementation that works with existing code but does not permit the user +to supply his own allocator for NxArray emitters. +*/ +class NxFluidDesc : public NxFluidDescBase + { + public: + + /** + \brief Array of emitter descriptors that describe emitters which emit fluid into this + fluid actor. + + A fluid actor can have any number of emitters. + + @see NxFluidEmitter + */ + NxArray emitters; + + /** + \brief constructor sets to default. + */ + NX_INLINE NxFluidDesc(); + + /** + \brief (Re)sets the structure to the default. + + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + + */ + NX_INLINE bool isValid() const; + }; + +/** +\brief Implementation of an actor descriptor that permits the user to supply his own allocator +*/ +template class NxFluidDesc_Template : public NxFluidDescBase + { + public: + /** + \brief Array of emitter descriptors that describe emitters which emit fluid into this + fluid actor. + + A fluid actor can have any number of emitters. + + @see NxFluidEmitter + */ + NxArray emitters; + + NX_INLINE NxFluidDesc_Template() + { + setToDefault(); + type = NX_FDT_ALLOCATOR; + } + + NX_INLINE void setToDefault() + { + NxFluidDescBase::setToDefault(); + emitters.clear(); + } + + NX_INLINE bool isValid() const + { + if (!NxFluidDescBase::isValid()) + return false; + + if (emitters.size() > 0xffff) return false; + + for (unsigned i = 0; i < emitters.size(); i++) + if (!emitters[i].isValid()) return false; + + return true; + } + + }; + + +NX_INLINE NxFluidDescBase::NxFluidDescBase() + { + //nothing! Don't call setToDefault() here! + } + +NX_INLINE void NxFluidDescBase::setToDefault() + { + maxParticles = 32767; + numReserveParticles = 0; + restParticlesPerMeter = 50.0f; + restDensity = 1000.0f; + kernelRadiusMultiplier = 1.2f; + motionLimitMultiplier = 3.0f * kernelRadiusMultiplier; + collisionDistanceMultiplier = 0.1f * kernelRadiusMultiplier; + packetSizeMultiplier = 16; + stiffness = 20.0f; + viscosity = 6.0f; + surfaceTension = 0.0f; + damping = 0.0f; + fadeInTime = 0.0f; + externalAcceleration.zero(); + projectionPlane.set(NxVec3(0.0f, 0.0f, 1.0f), 0.0f); + restitutionForStaticShapes = 0.5f; + dynamicFrictionForStaticShapes = 0.05f; + staticFrictionForStaticShapes = 0.05f; + attractionForStaticShapes = 0.0f; + restitutionForDynamicShapes = 0.5f; + dynamicFrictionForDynamicShapes = 0.5f; + staticFrictionForDynamicShapes = 0.5f; + attractionForDynamicShapes = 0.0f; + collisionResponseCoefficient = 0.2f; + + simulationMethod = NX_F_SPH; + collisionMethod = NX_F_STATIC|NX_F_DYNAMIC; + collisionGroup = 0; + forceFieldMaterial = 0; + groupsMask.bits0 = 0; + groupsMask.bits1 = 0; + groupsMask.bits2 = 0; + groupsMask.bits3 = 0; + + particlesWriteData .setToDefault(); + particleDeletionIdWriteData .setToDefault(); + particleCreationIdWriteData .setToDefault(); + fluidPacketData .setToDefault(); + + flags = NX_FF_VISUALIZATION|NX_FF_ENABLED|NX_FF_HARDWARE; + + userData = NULL; + name = NULL; + compartment = NULL; + } + +NX_INLINE bool NxFluidDescBase::isValid() const + { + if (kernelRadiusMultiplier < 1.0f) return false; + if (restDensity <= 0.0f) return false; + if (restParticlesPerMeter <= 0.0f) return false; + + if (packetSizeMultiplier < 4) return false; + if (packetSizeMultiplier & ( packetSizeMultiplier - 1 ) ) return false; + + if (motionLimitMultiplier <= 0.0f) return false; + if (motionLimitMultiplier > packetSizeMultiplier*kernelRadiusMultiplier) return false; + + if (collisionDistanceMultiplier <= 0.0f) return false; + if (collisionDistanceMultiplier > packetSizeMultiplier*kernelRadiusMultiplier) return false; + + if (stiffness <= 0.0f) return false; + if (viscosity <= 0.0f) return false; + if (surfaceTension < 0.0f) return false; + + bool isNoInteraction = (simulationMethod & NX_F_NO_PARTICLE_INTERACTION) > 0; + bool isSPH = (simulationMethod & NX_F_SPH) > 0; + bool isMixed = (simulationMethod & NX_F_MIXED_MODE) > 0; + if (!(isNoInteraction || isSPH || isMixed)) return false; + if (isNoInteraction && (isSPH || isMixed)) return false; + if (isSPH && (isNoInteraction || isMixed)) return false; + if (isMixed && (isNoInteraction || isSPH)) return false; + + if (damping < 0.0f) return false; + if (fadeInTime < 0.0f) return false; + + if (projectionPlane.normal.isZero()) return false; + + if (dynamicFrictionForDynamicShapes < 0.0f || dynamicFrictionForDynamicShapes > 1.0f) return false; + if (staticFrictionForDynamicShapes < 0.0f || staticFrictionForDynamicShapes > 1.0f) return false; + if (restitutionForDynamicShapes < 0.0f || restitutionForDynamicShapes > 1.0f) return false; + if (attractionForDynamicShapes < 0.0f) return false; + if (dynamicFrictionForStaticShapes < 0.0f || dynamicFrictionForStaticShapes > 1.0f) return false; + if (staticFrictionForStaticShapes < 0.0f || staticFrictionForStaticShapes > 1.0f) return false; + if (restitutionForStaticShapes < 0.0f || restitutionForStaticShapes > 1.0f) return false; + if (attractionForStaticShapes < 0.0f) return false; + if (collisionResponseCoefficient < 0.0f) return false; + + if (!initialParticleData.isValid()) return false; + if (!particlesWriteData.isValid()) return false; + if (!particleDeletionIdWriteData.isValid()) return false; + if (!particleCreationIdWriteData.isValid()) return false; + if (!fluidPacketData.isValid()) return false; + + if (maxParticles > 32767) return false; + if (maxParticles < 1) return false; + + if (numReserveParticles >= maxParticles) return false; + + if(collisionGroup >= 32) return false; // We only support 32 different collision groups + + return true; + } + +NX_INLINE NxFluidDescType NxFluidDescBase::getType() const + { + return type; + } + +NX_INLINE NxFluidDesc::NxFluidDesc() + { + memset(this,0,sizeof(NxFluidDesc)); + setToDefault(); + type = NX_FDT_DEFAULT; + } + +NX_INLINE void NxFluidDesc::setToDefault() + { + NxFluidDescBase::setToDefault(); + emitters .clear(); + } + +NX_INLINE bool NxFluidDesc::isValid() const + { + if (!NxFluidDescBase::isValid()) + return false; + + if (emitters.size() > 0xffff) return false; + + for (unsigned i = 0; i < emitters.size(); i++) + if (!emitters[i].isValid()) return false; + + return true; + } +/** @} */ + +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxFluidEmitter.h b/libraries/external/physx/Win32/include/PX/fluids/NxFluidEmitter.h new file mode 100755 index 0000000..c8daf55 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxFluidEmitter.h @@ -0,0 +1,736 @@ +#ifndef NX_FLUIDS_NXFLUIDEMITTER +#define NX_FLUIDS_NXFLUIDEMITTER +/** \addtogroup fluids + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ +#include "PX/Nxp.h" +#include "PX/NxPhysicsSDK.h" +#include "PX/fluids/NxFluidEmitterDesc.h" + +class NxFluid; +class NxFluidEmitterDesc; +class NxShape; + + + +/** +\brief The fluid emitter class. It represents an emitter (fluid source) which is associated with one fluid. + +The emitter is an alternative to adding particles to the fluid via the NxFluid::addParticles() method. + +Emission always takes place in a plane given by the orientation and position of the emitter. The +shape of the area of emission is either a rectangle or an ellipse. The direction of emission is usually +perpendicular to the emission plane. However, this can be randomly modulated using the setRandomAngle() +method. An emitter can have two types of operation: +
    +
  1. + Constant pressure. + In this case the state of the surrounding fluid is taken into account. The emitter tries + to match the rest spacing of the particles. Nice rays of water can be generated this way. +
  2. + Constant flow rate. + In this case the emitter keeps emitting the same number of particles each frame. The rate can + be adjusted dynamically. +
+The emitter's pose can be animated directly or attached to a shape which belongs to a +dynamic actor. This shape is called the frame shape. When attaching an emitter to a shape, one +has the option of enabling impulse transfer from the emitter to the body of the shape. +The impulse generated is dependent on the rate, density, +and velocity of the emitted particles. + +*/ +class NxFluidEmitter + { + protected: + NX_INLINE NxFluidEmitter() : userData(NULL) {} + virtual ~NxFluidEmitter() {} + + public: + + /** + \brief Returns the owner fluid. + + \return The fluid this emitter is associated with. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxFluid & getFluid() const = 0; + + /** + \brief Sets the pose of the emitter in world space. + + \param[in] mat New pose of the emitter in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setGlobalPose(const NxMat34& mat) = 0; + + /** + \brief Sets the position of the emitter in world space. + + \param[in] vec New positon in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setGlobalPosition(const NxVec3& vec) = 0; + + /** + \brief Sets the orientation of the emitter in world space. + + \param[in] mat New orientation in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setGlobalOrientation(const NxMat33& mat) = 0; + +//exclude from documentation +/** \cond */ + + /** + \brief The get*Val() methods work just like the get*() methods, except they return the + desired values instead of copying them to destination variables. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxMat34 getGlobalPoseVal() const = 0; + virtual NxVec3 getGlobalPositionVal() const = 0; + virtual NxMat33 getGlobalOrientationVal() const = 0; +/** \endcond */ + + /** + \brief Returns the pose of the emitter in world space. + + \return The global pose. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxMat34 getGlobalPose() const { return getGlobalPoseVal(); } + + /** + \brief Returns the position of the emitter in world space. + + \return The world space position. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxVec3 getGlobalPosition() const { return getGlobalPositionVal(); } + + /** + \brief Returns the orientation of the emitter in world space. + + \return The world space orientation. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_INLINE NxMat33 getGlobalOrientation() const { return getGlobalOrientationVal(); } + + /** + \brief Sets the pose of the emitter relative to the frameShape. + + The pose is set relative to the shape frame. + + If the frameShape is NULL, world space is used. + + \param[in] mat The new local pose of the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.relPose + */ + virtual void setLocalPose(const NxMat34& mat) = 0; + + /** + \brief Sets the position of the emitter relative to the frameShape. + + The pose is relative to the shape frame. + + If the frameShape is NULL, world space is used. + + \param[in] vec The new local position of the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.relPose + */ + virtual void setLocalPosition(const NxVec3& vec) = 0; + + /** + \brief Sets the orientation of the emitter relative to the frameShape. + + The pose is relative to the shape frame. + + If the frameShape is NULL, world space is used. + + \param[in] mat The new local orientation of the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.relPose + */ + virtual void setLocalOrientation(const NxMat33& mat) = 0; + +//exclude from documentation +/** \cond */ + + /** + \brief The get*Val() methods work just like the get*() methods, except they return the + desired values instead of copying them to the destination variables. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxMat34 getLocalPoseVal() const = 0; + virtual NxVec3 getLocalPositionVal() const = 0; + virtual NxMat33 getLocalOrientationVal() const = 0; +/** \endcond */ + + + /** + \brief Returns the pose of the emitter relative to the frameShape. + + The pose is relative to the shape frame. + + If the frameShape is NULL, world space is used. + + \return The local pose of the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.relPose + */ + NX_INLINE NxMat34 getLocalPose() const { return getLocalPoseVal(); } + + /** + \brief Returns the position of the emitter relative to the frameShape. + + The pose is relative to the shape frame. + + If the frameShape is NULL, world space is used. + + \return The local position of the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.relPose + */ + + NX_INLINE NxVec3 getLocalPosition() const { return getLocalPositionVal(); } + + /** + \brief Returns the orientation of the emitter relative to the frameShape. + + The pose is relative to the shape frame. + + If the frameShape is NULL, world space is used. + + \return The local orientation of the emitter. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.relPose + */ + NX_INLINE NxMat33 getLocalOrientation() const { return getLocalOrientationVal(); } + + /** + \brief Sets the frame shape. Can be set to NULL. + + \param[in] shape The frame shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.frameShape + */ + virtual void setFrameShape(NxShape* shape) = 0; + + /** + \brief Returns the frame shape. May be NULL. + + \return The frame shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.frameShape + */ + virtual NxShape * getFrameShape() const = 0; + + /** + \brief Returns the radius of the emitter along the x axis. + + \return Radius of emitter along the X axis. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.dimensionX + */ + virtual NxReal getDimensionX() const = 0; + + /** + \brief Returns the radius of the emitter along the y axis. + + \return Radius of emitter along the Y axis. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.dimensionY + */ + virtual NxReal getDimensionY() const = 0; + + /** + \brief Sets the maximal random displacement in every dimension. + + \param[in] disp The maximal random displacment of particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.randomPos + */ + virtual void setRandomPos(NxVec3 disp) = 0; + + /** + \brief Returns the maximal random displacement in every dimension. + + \return The maximal random displacment of particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.randomPos + */ + virtual NxVec3 getRandomPos() const = 0; + + /** + \brief Sets the maximal random angle offset (in radians). + + Unit: Radians + + \param[in] angle Maximum random angle for emitted particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.randomAngle + */ + virtual void setRandomAngle(NxReal angle) = 0; + + /** + \brief Returns the maximal random angle offset (in radians). + + Unit: Radians + + \return Maximum random angle for emitted particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.randomAngle + */ + virtual NxReal getRandomAngle() const = 0; + + /** + \brief Sets the velocity magnitude of the emitted particles. + + \param[in] vel New velocity magnitude of emitted particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.fluidVelocityMagnitude + */ + virtual void setFluidVelocityMagnitude(NxReal vel) = 0; + + /** + \brief Returns the velocity magnitude of the emitted particles. + + \return Velocity magnitude of emitted particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.fluidVelocityMagnitude + */ + virtual NxReal getFluidVelocityMagnitude() const = 0; + + /** + \brief Sets the emission rate (particles/second). + + Only used if the NxEmitterType is NX_FE_CONSTANT_FLOW_RATE. + + \param[in] rate New emission rate. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.rate + */ + virtual void setRate(NxReal rate) = 0; + + /** + \brief Returns the emission rate. + + \return Emission rate. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.rate + */ + virtual NxReal getRate() const = 0; + + /** + \brief Sets the particle lifetime. + + \param[in] life Lifetime of emitted particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.particleLifetime + */ + virtual void setParticleLifetime(NxReal life) = 0; + + /** + \brief Returns the particle lifetime. + + \return Lifetime of emitted particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.particleLifetime + */ + virtual NxReal getParticleLifetime() const = 0; + + /** + \brief Sets the repulsion coefficient. + + \param[in] coefficient The repulsion coefficient in the range from 0 to inf. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.repulsionCoefficient getRepulsionCoefficient() + */ + virtual void setRepulsionCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves the repulsion coefficient. + + \return The repulsion coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.repulsionCoefficient setRepulsionCoefficient() + */ + virtual NxReal getRepulsionCoefficient() const = 0; + + /** + \brief Resets the particle reservoir. + + \param[in] new maxParticles value. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.maxParticles + */ + virtual void resetEmission(NxU32 maxParticles) = 0; + + /** + \brief Returns the maximal particle number to be emitted. + + \return max particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.maxParticles + */ + virtual NxU32 getMaxParticles() const = 0; + + /** + \brief Returns the number of particles that have been emitted already. + + \return number of particles already emitted. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxU32 getNbParticlesEmitted() const = 0; + + /** + \brief Sets the emitter flags. + + \param[in] flag Member of #NxFluidEmitterFlag. + \param[in] val New flag value. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterFlag + */ + virtual void setFlag(NxFluidEmitterFlag flag, bool val) = 0; + + /** + \brief Returns the emitter flags. + + \param[in] flag Member of #NxFluidEmitterFlag. + \return The current flag value. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterFlag + */ + virtual NX_BOOL getFlag(NxFluidEmitterFlag flag) const = 0; + + /** + \brief Get the emitter shape. + + \param[in] shape Member of #NxEmitterShape. + \return True if it is of type shape. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc.shape + */ + virtual NX_BOOL getShape(NxEmitterShape shape) const = 0; + + /** + \brief Get the emitter type. + + \param[in] type Member of #NxEmitterType + \return True if it is of type type. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxEmitterType + */ + virtual NX_BOOL getType(NxEmitterType type) const = 0; + +/************************************************************************************************/ + +/** @name FluidEmitter Descriptor Operations +*/ +//@{ + + /** + \brief Loads the FluidEmitter descriptor. + + \param[in] desc The descriptor used to restore the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc + */ + virtual bool loadFromDesc(const NxFluidEmitterDesc& desc) = 0; + + /** + \brief Saves the FluidEmitter descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxFluidEmitterDesc + */ + virtual bool saveToDesc(NxFluidEmitterDesc &desc) const = 0; + +//@} +/************************************************************************************************/ + + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by the SDK; + only the pointer is stored. + + \param[in] name The new name. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setName(const char* name) = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return The current name. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual const char* getName() const = 0; + + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. + }; +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxFluidEmitterDesc.h b/libraries/external/physx/Win32/include/PX/fluids/NxFluidEmitterDesc.h new file mode 100755 index 0000000..70b8370 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxFluidEmitterDesc.h @@ -0,0 +1,279 @@ +#ifndef NX_FLUIDS_NXFLUIDEMITTERDESC +#define NX_FLUIDS_NXFLUIDEMITTERDESC +/** \addtogroup fluids + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** +\brief Flags which control the behavior of fluid emitters. + +@see NxFluidEmitter +*/ +enum NxFluidEmitterFlag + { + /** + \brief Flags whether the emitter should be visualized for debugging or not. + */ + NX_FEF_VISUALIZATION = (1<<0), + + /** + \brief This flag specifies whether the emission should cause a force on + the shapes body that the emitter is attached to. + */ + NX_FEF_FORCE_ON_BODY = (1<<2), + + /** + \brief If set, the velocity of the shapes body is added to the emitted particle velocity. + + This is the default behaviour. + */ + NX_FEF_ADD_BODY_VELOCITY = (1<<3), + + /** + \brief Flag to start and stop the emission. On default the emission is enabled. + */ + NX_FEF_ENABLED = (1<<4), + }; + +/** +\brief Flags to specify the shape of the area of emission. + +Exactly one flag should be set at any time. + +*/ +enum NxEmitterShape + { + NX_FE_RECTANGULAR = (1<<0), + NX_FE_ELLIPSE = (1<<1) + }; + +/** +\brief Flags to specify the emitter's type of operation. +Exactly one flag should be set at any time. + +@see NxFluidEmitter +*/ +enum NxEmitterType + { + NX_FE_CONSTANT_PRESSURE = (1<<0), + NX_FE_CONSTANT_FLOW_RATE = (1<<1) + }; + +#include "PX/fluids/NxFluidEmitter.h" + +/** +\brief Descriptor for NxFluidEmitter class. Used for saving and loading the emitter state. +*/ +class NxFluidEmitterDesc + { + public: + + /** + \brief The emitter's pose relative to the frameShape. + + relPose is relative to the shape's frame. If frameShape is NULL then relPose is relative to the world frame. + + The direction of the flow is the direction of the third (z) axis of the emitter frame. + */ + NxMat34 relPose; + + /** + \brief A pointer to the NxShape to which the emitter is attached to. + + If this pointer is set to NULL, the emitter is attached to the world frame. The shape + must be in the same scene as the emitter. + */ + NxShape* frameShape; + + /** + \brief The emitter's mode of operation. + + Either the simulation enforces constant pressure or constant flow rate at the emission site, + given the velocity of emitted particles. + + @see NxEmitterType + */ + NxU32 type; + + /** + \brief The maximum number of particles which are emitted from this emitter. + + If the total number of particles in the fluid already hit the maxParticles parameter of the fluid, + this maximal values can't be reached. + + If set to 0, the number of emitted particles is unrestricted. + */ + NxU32 maxParticles; + + /** + \brief The emitter's shape can either be rectangular or elliptical. + + @see NxEmitterShape + */ + NxU32 shape; + + /** + \brief The sizes of the emitter in the directions of the first and the second axis of its orientation + frame (relPose). + + The dimensions are actually the radii of the size. + + */ + NxReal dimensionX; + NxReal dimensionY; + + /** + \brief Random vector with values for each axis direction of the emitter orientation. + + The values have to be positive and describe the maximal random particle displacement in each dimension. + + The z value describes the randomization in emission direction. The emission direction + is specified by the third orientation axis of relPose. + + */ + NxVec3 randomPos; + + /** + \brief Random angle deviation from emission direction. + + The emission direction is specified by the third orientation axis of relPose. + + Unit: Radians + + */ + NxReal randomAngle; + + /** + \brief The velocity magnitude of the emitted fluid particles. + + */ + NxReal fluidVelocityMagnitude; + + /** + \brief The rate specifies how many particles are emitted per second. + + The rate is only considered in the simulation if the type is set to NX_FE_CONSTANT_FLOW_RATE. + + @see NxEmitterType + */ + NxReal rate; + + /** + \brief This specifies the time in seconds an emitted particle lives. + + If set to 0, each particle will live until it collides with a drain. + */ + NxReal particleLifetime; + + /** + \brief Defines a factor for the impulse transfer from attached emitter to body. + + Only has an effect if NX_FEF_FORCE_ON_BODY is set. + + Default: 1.0
+ Range: [0,inf) + + @see NX_FEF_FORCE_ON_BODY NxFluidEmitter.setRepulsionCoefficient() + */ + NxReal repulsionCoefficient; + + /** + \brief A combination of NxFluidEmitterFlags. + + @see NxFluidEmitterFlag + */ + NxU32 flags; + + void* userData; //!< Will be copied to NxShape::userData. + const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + NX_INLINE ~NxFluidEmitterDesc(); + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxFluidEmitterDesc(); + }; + + +NX_INLINE NxFluidEmitterDesc::NxFluidEmitterDesc() + { + setToDefault(); + } + +NX_INLINE NxFluidEmitterDesc::~NxFluidEmitterDesc() + { + } + +NX_INLINE void NxFluidEmitterDesc::setToDefault() + { + relPose .id(); + frameShape = NULL; + type = NX_FE_CONSTANT_PRESSURE; + maxParticles = 0; + shape = NX_FE_RECTANGULAR; + dimensionX = 0.25f; + dimensionY = 0.25f; + randomPos .zero(); + randomAngle = 0.0f; + fluidVelocityMagnitude = 1.0f; + rate = 100.0f; + particleLifetime = 0.0f; + repulsionCoefficient = 1.0f; + flags = NX_FEF_ENABLED|NX_FEF_VISUALIZATION|NX_FEF_ADD_BODY_VELOCITY; + + userData = NULL; + name = NULL; + } + +NX_INLINE bool NxFluidEmitterDesc::isValid() const + { + if (!relPose.isFinite()) return false; + + if (dimensionX < 0.0f) return false; + if (dimensionY < 0.0f) return false; + + if (randomPos.x < 0.0f) return false; + if (randomPos.y < 0.0f) return false; + if (randomPos.z < 0.0f) return false; + if (!randomPos.isFinite()) return false; + + if (randomAngle < 0.0f) return false; + + if (!(((shape & NX_FE_ELLIPSE) > 0) ^ ((shape & NX_FE_RECTANGULAR) > 0))) return false; + if (!(((type & NX_FE_CONSTANT_FLOW_RATE) > 0) ^ ((type & NX_FE_CONSTANT_PRESSURE) > 0))) return false; + + if (rate < 0.0f) return false; + if (fluidVelocityMagnitude < 0.0f) return false; + if (particleLifetime < 0.0f) return false; + if (repulsionCoefficient < 0.0f) return false; + + return true; + } + +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxFluidPacketData.h b/libraries/external/physx/Win32/include/PX/fluids/NxFluidPacketData.h new file mode 100755 index 0000000..229fe60 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxFluidPacketData.h @@ -0,0 +1,114 @@ +#ifndef NX_FLUIDS_NXFLUIDPACKETDATA +#define NX_FLUIDS_NXFLUIDPACKETDATA +/** \addtogroup fluids + @{ +*/ + +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" + + +/** +\brief Data structure to represent a bounding box and its associated particle data of a fluid packet. +*/ +struct NxFluidPacket + { + /** + \brief AABB of all particles which are inside the same packet. + */ + NxBounds3 aabb; + + /** + \brief Index of first particle for a given packet. This index can be used to index into each of the buffers in NxParticleData. + + @see NxParticleData + */ + NxU32 firstParticleIndex; + + /** + \brief Number of particles inside the packet. + */ + NxU32 numParticles; + + /** + \brief The packet's Identifier. + */ + NxU32 packetID; + }; + +/** +\brief Data structure to receive AABBs per fluid packet. + +Important: The array lengths need to be equivalent to the maxPacket parameter of the NxFluid +this is applied to. + +*/ +class NxFluidPacketData + { + public: + + /** + \brief The pointer to the user-allocated buffer for fluid packets. + */ + NxFluidPacket* bufferFluidPackets; + + /** + \brief Points to the user-allocated memory holding the number of packets stored in the buffers. + */ + NxU32* numFluidPacketsPtr; + + NX_INLINE ~NxFluidPacketData(); + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxFluidPacketData(); + }; + +NX_INLINE NxFluidPacketData::NxFluidPacketData() + { + setToDefault(); + } + +NX_INLINE NxFluidPacketData::~NxFluidPacketData() + { + } + +NX_INLINE void NxFluidPacketData::setToDefault() + { + bufferFluidPackets = NULL; + numFluidPacketsPtr = NULL; + } + +NX_INLINE bool NxFluidPacketData::isValid() const + { + if (numFluidPacketsPtr && !bufferFluidPackets) return false; + return true; + } + +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxParticleData.h b/libraries/external/physx/Win32/include/PX/fluids/NxParticleData.h new file mode 100755 index 0000000..cdc19ee --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxParticleData.h @@ -0,0 +1,245 @@ +#ifndef NX_FLUIDS_NXPARTICLEDATA +#define NX_FLUIDS_NXPARTICLEDATA +/** \addtogroup fluids + @{ +*/ + +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** +Particle flags are used to give some additional information about the particles. +*/ +enum NxParticleFlag +{ + NX_FP_COLLISION_WITH_STATIC = (1<<0), + NX_FP_COLLISION_WITH_DYNAMIC = (1<<1), + NX_FP_SEPARATED = (1<<2), + NX_FP_MOTION_LIMIT_REACHED = (1<<3), +}; + +/** +\brief Descriptor-like user-side class describing a set of fluid particles. + +NxParticleData is used to submit particles to the simulation and +to retrieve information about particles in the simulation. + +Each particle is described by its position, velocity, lifetime, density, and a set of (NxParticleFlag) flags. +The memory for the particle data is allocated by the application, +making this class a "user buffer wrapper". +*/ +class NxParticleData + { + public: + + /** + \brief Points to the user-allocated memory holding the number of elements stored in the buffers. + + If the SDK writes to a given particle buffer, it also sets the numbers of elements written. If + numParticlesPtr is set to NULL, the SDK can't write to the given buffer. + When passing particles to the SDK, the number stored at the location is used to determine + how many particles need to be read from the buffer. Therefore it is critical to set the value + numParticlesPtr is pointing to, to the correct number of particles which are prepared to be added + to the simulation. Otherwise erroneous data gets processed which has undefined results. + */ + NxU32* numParticlesPtr; + + /** + \brief The pointer to the user-allocated buffer for particle positions. + + A position consists of three consecutive 32-bit floats. If set to NULL, positions are not read or written to. + */ + NxF32* bufferPos; + + /** + \brief The pointer to the user-allocated buffer for particle velocities. + + A velocity consists of three consecutive 32-bit + floats. If set to NULL, velocities are not read or written to. + */ + NxF32* bufferVel; + + /** + \brief The pointer to the user-allocated buffer for particle lifetimes. + + A particle lifetime consists of one 32-bit + float. If set to NULL, lifetimes are not read or written to. + */ + NxF32* bufferLife; + + /** + \brief The pointer to the user-allocated buffer for particle densities. + + A particle density consists of one 32-bit float. If set to NULL, densities are not written to. + Densities are never read from the user, they are always defined by the fluid simulation. + */ + NxF32* bufferDensity; + + /** + \brief The pointer to the user-allocated buffer for particle IDs. + + A particle id is represented as a 32-bit unsigned integer. If set to NULL, IDs are not written to. + IDs are never read from the user, they are always defined by the SDK. + */ + NxU32* bufferId; + + /** + \brief The pointer to the user-allocated buffer for particle flags. + + A particle flags are represented as a 32-bit unsigned integer. If set to NULL, flags are not written to. + Flags are never read from the user, they are always defined by the SDK. + Use NxParticleFlag to interpret this data. + */ + NxU32* bufferFlag; + + /** + \brief The pointer to the user-allocated buffer for particle collision normals. + + A collision normal consists of three consecutive 32-bit + floats. If set to NULL, normals are not read or written to. + + Limitation: Collision normals can only be received if + NxFluidDesc.flags.NX_FF_COLLISION_TWOWAY is NOT set. + */ + NxF32* bufferCollisionNormal; + + /** + \brief The separation (in bytes) between consecutive particle positions. + + The position of the first particle is found at location bufferPos; + the second is at bufferPos + bufferPosByteStride; + and so on. + */ + NxU32 bufferPosByteStride; + + /** + \brief The separation (in bytes) between consecutive particle velocities. + + The velocity of the first particle is found at location bufferVel; + the second is at bufferVel + bufferVelByteStride; + and so on. + */ + NxU32 bufferVelByteStride; + + /** + \brief The separation (in bytes) between consecutive particle lifetimes. + + The lifetime of the first particle is found at location bufferLife; + the second is at bufferLife + bufferLifeByteStride; + and so on. + */ + NxU32 bufferLifeByteStride; + + /** + \brief The separation (in bytes) between consecutive particle densities. + + The density of the first particle is found at location bufferDensity; + the second is at bufferDensity + bufferDensityByteStride; + and so on. + */ + NxU32 bufferDensityByteStride; + + /** + \brief The separation (in bytes) between consecutive particle IDs. + + The ID of the first particle is found at location bufferId; + the second is at bufferId + bufferIdByteStride; + and so on. + */ + NxU32 bufferIdByteStride; + + /** + \brief The separation (in bytes) between consecutive particle flags. + + The flags of the first particle is found at location bufferFlag; + the second is at bufferFlag + bufferFlagByteStride; + and so on. + */ + NxU32 bufferFlagByteStride; + + /** + \brief The separation (in bytes) between consecutive particle collision normals. + + The normal of the first particle is found at location bufferCollisionNormal; + the second is at bufferCollisionNormal + bufferCollisionNormalByteStride; + and so on. + */ + NxU32 bufferCollisionNormalByteStride; + + const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + NX_INLINE ~NxParticleData(); + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxParticleData(); + }; + +NX_INLINE NxParticleData::NxParticleData() + { + setToDefault(); + } + +NX_INLINE NxParticleData::~NxParticleData() + { + } + +NX_INLINE void NxParticleData::setToDefault() + { + numParticlesPtr = NULL; + bufferPos = NULL; + bufferVel = NULL; + bufferLife = NULL; + bufferDensity = NULL; + bufferId = NULL; + bufferFlag = NULL; + bufferCollisionNormal = NULL; + bufferPosByteStride = 0; + bufferVelByteStride = 0; + bufferLifeByteStride = 0; + bufferDensityByteStride = 0; + bufferIdByteStride = 0; + bufferFlagByteStride = 0; + bufferCollisionNormalByteStride = 0; + name = NULL; + } + +NX_INLINE bool NxParticleData::isValid() const + { + if (numParticlesPtr && !(bufferPos || bufferVel || bufferLife || bufferDensity || bufferId || bufferCollisionNormal)) return false; + if ((bufferPos || bufferVel || bufferLife || bufferDensity || bufferId || bufferCollisionNormal) && !numParticlesPtr) return false; + if (bufferPos && !bufferPosByteStride) return false; + if (bufferVel && !bufferVelByteStride) return false; + if (bufferLife && !bufferLifeByteStride) return false; + if (bufferDensity && !bufferDensityByteStride) return false; + if (bufferId && !bufferIdByteStride) return false; + if (bufferFlag && !bufferFlagByteStride) return false; + if (bufferCollisionNormal && !bufferCollisionNormalByteStride) return false; + return true; + } + +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxParticleIdData.h b/libraries/external/physx/Win32/include/PX/fluids/NxParticleIdData.h new file mode 100755 index 0000000..54d2228 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxParticleIdData.h @@ -0,0 +1,106 @@ +#ifndef NX_FLUIDS_NXPARTICLEIDDATA +#define NX_FLUIDS_NXPARTICLEIDDATA +/** \addtogroup fluids + @{ +*/ + +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** +\brief Descriptor-like user-side class describing a set of fluid particle IDs. + +NxParticleIdData is used to retrieve information about a selection of particles in the simulation. + +Each particle is created with an ID. This ID is unique within the current set of particles. Also, each ID +is guaranteed to be in the interval [0,NxFluidDesc::maxParticles). The user can use the particle IDs to +manage per particle user data. + +*/ +class NxParticleIdData + { + public: + + /** + \brief Points to the user-allocated memory holding the number of IDs stored in the buffer. + + If the SDK writes to a given ID buffer, it also sets the numbers of IDs written. If + this is set to NULL, the SDK can't write to the ID buffer. + */ + NxU32* numIdsPtr; + + /** + \brief The pointer to the user-allocated buffer for particle IDs. + + A particle ID is represented with a 32-bit unsigned integer. If set to NULL, IDs are not written to. + */ + NxU32* bufferId; + + /** + \brief The separation (in bytes) between consecutive particle IDs. + + The ID of the first particle is found at location bufferId; + the second is at bufferId + bufferIdByteStride; + and so on. + */ + NxU32 bufferIdByteStride; + + const char* name; //!< Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + NX_INLINE ~NxParticleIdData(); + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxParticleIdData(); + }; + +NX_INLINE NxParticleIdData::NxParticleIdData() + { + setToDefault(); + } + +NX_INLINE NxParticleIdData::~NxParticleIdData() + { + } + +NX_INLINE void NxParticleIdData::setToDefault() + { + numIdsPtr = NULL; + bufferId = NULL; + bufferIdByteStride = 0; + name = NULL; + } + +NX_INLINE bool NxParticleIdData::isValid() const + { + if (numIdsPtr && !(bufferId)) return false; + if (bufferId && !numIdsPtr) return false; + if (bufferId && !bufferIdByteStride) return false; + return true; + } + +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/NxParticleUpdateData.h b/libraries/external/physx/Win32/include/PX/fluids/NxParticleUpdateData.h new file mode 100755 index 0000000..2adb769 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fluids/NxParticleUpdateData.h @@ -0,0 +1,174 @@ +#ifndef NX_FLUIDS_NXPARTICLEUPDATEDATA +#define NX_FLUIDS_NXPARTICLEUPDATEDATA +/** \addtogroup fluids + @{ +*/ + +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" + +/** +Particle update flags are used specify flags which can be updated on the particles. +*/ +enum NxParticleDataFlag +{ + NX_FP_DELETE = (1<<0), +}; + +/** +\brief Data structure to define particle update data. + +There are two different types of updates, id based updates and particle order based updates. +Id based updates may contain an arbitrary number of elements, each paired with a particle id. +Particle order based updates always need to have the elements matching the particles as received +with the previous call to NxScene::fetchResults(). + +The id based update can be specified by passing particle ids per update element with +NxParticleUpdateData::bufferId, NxParticleUpdateData::bufferIdByteStride and NxParticleUpdateData::numUpdates + +The particle order based update is specified with setting NxParticleUpdateData::bufferId to NULL. +NxParticleUpdateData::numUpdates is ignored in this case. + +@see NxFluid::updateParticles(const NxParticleUpdateData&) +*/ +class NxParticleUpdateData + { + public: + + /** + \brief Defines how the "force" buffer is interpreted. + + Supported: + NX_FORCE, + NX_IMPULSE, + NX_VELOCITY_CHANGE, + NX_ACCELERATION + + @see NxForceMode + */ + NxForceMode forceMode; + + /** + \brief Number of elements stored in the update buffers. + + When passing id based updates to the SDK, the number is used to determine + how many ids and update forces or flags need to be read from the buffers. If passing particle order based + updates this parameter is ignored. + */ + NxU32 numUpdates; + + /** + \brief The pointer to the user-allocated buffer for particle forces. + + A force consists of three consecutive 32-bit floats. If set to NULL, forces are not read. + */ + NxF32* bufferForce; + + /** + \brief The pointer to the user-allocated buffer for particle update flags. + + Particle update flags are represented as a 32-bit unsigned integer. If set the NULL, flags are not read from. + Use NxParticleDataFlag to set the information. + */ + NxU32* bufferFlag; + + /** + \brief The pointer to the user-allocated buffer for id based updates. + + Particle ids are represented as a 32-bit unsigned integer. If set the NULL, NxFluid::updateParticles(...) + will assume an index based update on all particles. + */ + NxU32* bufferId; + + /** + \brief The separation (in bytes) between consecutive particle forces. + + The force of the first particle is found at location bufferForce; + the second is at bufferForce + bufferForceByteStride; + and so on. + */ + NxU32 bufferForceByteStride; + + /** + \brief The separation (in bytes) between consecutive particle update flags. + + The update flags of the first particle is found at location bufferFlag; + the second is at bufferFlag + bufferFlagByteStride; + and so on. + */ + NxU32 bufferFlagByteStride; + + /** + \brief The separation (in bytes) between consecutive particle ids. + + The id of the first particle is found at location bufferId; + the second is at bufferId + bufferIdByteStride; + and so on. + */ + NxU32 bufferIdByteStride; + + NX_INLINE ~NxParticleUpdateData(); + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxParticleUpdateData(); + }; + +NX_INLINE NxParticleUpdateData::NxParticleUpdateData() + { + setToDefault(); + } + +NX_INLINE NxParticleUpdateData::~NxParticleUpdateData() + { + } + +NX_INLINE void NxParticleUpdateData::setToDefault() + { + forceMode = NX_FORCE; + numUpdates = 0; + bufferForce = NULL; + bufferFlag = NULL; + bufferId = NULL; + bufferForceByteStride = 0; + bufferFlagByteStride = 0; + bufferIdByteStride = 0; + } + +NX_INLINE bool NxParticleUpdateData::isValid() const + { + if (!(bufferForce || bufferFlag)) return false; + if (bufferForce && !bufferForceByteStride) return false; + if (bufferFlag && !bufferFlagByteStride) return false; + if (bufferId && !bufferIdByteStride) return false; + if (bufferId && !numUpdates) return false; + return true; + } + +/** @} */ +#endif + + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2005 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND + diff --git a/libraries/external/physx/Win32/include/PX/fluids/vssver.scc b/libraries/external/physx/Win32/include/PX/fluids/vssver.scc new file mode 100755 index 0000000..5183161 Binary files /dev/null and b/libraries/external/physx/Win32/include/PX/fluids/vssver.scc differ diff --git a/libraries/external/physx/Win32/include/PX/fw-convex-cooker.h b/libraries/external/physx/Win32/include/PX/fw-convex-cooker.h new file mode 100755 index 0000000..8e261dd --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/fw-convex-cooker.h @@ -0,0 +1,184 @@ +/*---------------------------------------------------------------------- + This Software and Related Documentation are Proprietary to Ageia + Technologies, Inc. + + Copyright 2005 Ageia Technologies, Inc. St. Louis, MO + Unpublished - + All Rights Reserved Under the Copyright Laws of the United States. + + Restricted Rights Legend: Use, Duplication, or Disclosure by + the Government is Subject to Restrictions as Set Forth in + Paragraph (c)(1)(ii) of the Rights in Technical Data and + Computer Software Clause at DFARS 252.227-7013. Ageia + Technologies Inc. +-----------------------------------------------------------------------*/ + +#ifndef FW_MESH_COOKER_H +#define FW_MESH_COOKER_H 1 + +#include "PX/NxPhysics.h" + +class ConvexMesh; +void makeFwConvex(NxU8 *addr, const ConvexMesh *mesh); + +#ifdef DEFINE_CONVEX_COOKER +//#include "PhysicsSDK.h" +#include "PX/Physics.h" +#include "PX/TriangleMesh.h" +#include "PX/TriangleMeshShape.h" +#include "PX/ConvexMesh.h" +#include "PX/ConvexShape.h" +#include "PX/Scene.h" +// #include "Stream.h" +#include "PX/ConvexHull.h" +#include "PX/ConvexMesh.h" +#include "PX/fw-mesh-utils.h" +#include "PX/fw-convex.h" + + +// convex is required to be at least MAX_FWCONVEX_SIZE + +void makeFwConvex(NxU8 *convex, const ConvexMesh *mesh) +{ + NxU32 i,j; + + NxU32 nVerts = ((ConvexMeshRuntime *)mesh)->GetNbVerts(); + NxU32 nFaces = ((ConvexMeshRuntime *)mesh)->GetNbPolygons(); + NxU32 nEdges = nVerts + nFaces - 2; + + ASSERT(nVerts <= FW_MAX_CONVEX_VERT); + ASSERT(nFaces <= FW_MAX_CONVEX_FACE); + + // Allocate memory + + fw_convex_shape *shape = (fw_convex_shape *) convex; + shape->numVerts = nVerts; + shape->numFaces = nFaces; + + shape->centroid = FwV3(0,0,0); + FwV3 bbMin = FwV3(FLT_MAX,FLT_MAX,FLT_MAX); + FwV3 bbMax = FwV3(-FLT_MAX,-FLT_MAX,-FLT_MAX); + + // Copy verts + + FwV3 *verts = getConvexVerts(convex); + for (i = 0; i < nVerts; i++) + { + verts[i] = *(FwV3 *)&(((ConvexMeshRuntime *)mesh)->GetVerts()[i]); + shape->centroid += verts[i]; + bbMin = bbMin.min(verts[i]); + bbMax = bbMax.max(verts[i]); + } + + shape->centroid /= (NxReal)nVerts; + shape->bbCentre = (bbMin + bbMax)/2; + shape->bbRadius = (bbMax - bbMin)/2; + + fw_convex_face *faces = getConvexFaces(convex); + fw_convex_loop *loops = getConvexLoops(convex); + + // Copy faces + + NxU32 loopIndex = 0; + for (i = 0; i < nFaces; i++) + { + const PxHullPolygonData & Poly = ((ConvexMeshRuntime *)mesh)->GetPolygon(i); + + faces[i].plane.n = *(FwV3 *)&Poly.mPlane[0]; + faces[i].plane.d = Poly.mPlane[3]; + faces[i].loopIndex = loopIndex; + faces[i].numVerts = Poly.mNbVerts; + + FwV3 fn = (verts[Poly.mVRef8[1]]-verts[Poly.mVRef8[0]]).cross(verts[Poly.mVRef8[2]]-verts[Poly.mVRef8[1]]); + + + // Copy loops such that cross product of successive faces is always outward facing + + if(fn.dot(faces[i].plane.n)>0) + { + for (j = 0; j < Poly.mNbVerts; j++) + { + loops[loopIndex].vIndex = Poly.mVRef8[j]; + loops[loopIndex].eIndex = static_cast (Poly.mERef16[j]); // TODO: cull parallel edges + loopIndex++; + } + } + else + { + for (j = 0; j < Poly.mNbVerts; j++) + { + loops[loopIndex].vIndex = Poly.mVRef8[Poly.mNbVerts-1-j]; + loops[loopIndex].eIndex = static_cast (Poly.mERef16[Poly.mNbVerts-1-j]); // TODO: cull parallel edges + loopIndex++; + } + } + } + + NxReal normErr = 0; + for(i=0;inormErr) + normErr = k; + } + } + +// printf("********** Normal error %f\n",normErr); + + + /* fill in per-edge face info - somewhat clunky */ + + NxU8 *edgeTable = (NxU8 *) _alloca(nEdges * 2 * 3); + NxU8 *edgePtr = edgeTable; + + for(i=0;iofsLoops = static_cast ((sizeof(fw_convex_shape) + sizeof(fw_convex_face) * nFaces) >> 2); + shape->ofsVerts = shape->ofsLoops + + static_cast ((sizeof(fw_convex_loop) * nEdges * 2) >> 2); + shape->cSize = shape->ofsVerts + ((12 * shape->numVerts) >> 2); + shape->cSize = (shape->cSize + 7) & ~7; + } +} + +#endif +#endif diff --git a/libraries/external/physx/Win32/include/PX/softbody/NxSoftBody.h b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBody.h new file mode 100755 index 0000000..89ff656 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBody.h @@ -0,0 +1,1392 @@ +#ifndef NX_PHYSICS_NX_SOFTBODY +#define NX_PHYSICS_NX_SOFTBODY +/** \addtogroup softbody + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/softbody/NxSoftBodyDesc.h" + +class NxRay; +class NxScene; +class NxActor; +class NxShape; +class NxBounds3; +class NxStream; +class NxCompartment; + +class NxSoftBody +{ +protected: + NX_INLINE NxSoftBody() : userData(NULL) {} + virtual ~NxSoftBody() {} + +public: + /** + \brief Saves the soft body descriptor. + + \param[out] desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc + */ + virtual bool saveToDesc(NxSoftBodyDesc& desc) const = 0; + + /** + \brief Returns a pointer to the corresponding soft body mesh. + + \return The soft body mesh associated with this soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.softBodyMesh + */ + virtual NxSoftBodyMesh* getSoftBodyMesh() const = 0; + + /** + \brief Sets the soft body volume stiffness in the range from 0 to 1. + + \param[in] stiffness The volume stiffness of this soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.volumeStiffness getVolumeStiffness() + */ + virtual void setVolumeStiffness(NxReal stiffness) = 0; + + /** + \brief Retrieves the soft body volume stiffness. + + \return Volume stiffness of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.volumeStiffness setVolumeStiffness() + */ + virtual NxReal getVolumeStiffness() const = 0; + + /** + \brief Sets the soft body stretching stiffness in the range from 0 to 1. + + Note: The stretching stiffness must be larger than 0. + + \param[in] stiffness Stiffness of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.stretchingStiffness getStretchingStiffness() + */ + virtual void setStretchingStiffness(NxReal stiffness) = 0; + + /** + \brief Retrieves the soft body stretching stiffness. + + \return stretching stiffness of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.stretchingStiffness setStretchingStiffness() + */ + virtual NxReal getStretchingStiffness() const = 0; + + /** + \brief Sets the damping coefficient in the range from 0 to 1. + + \param[in] dampingCoefficient damping coefficient of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.dampingCoefficient getDampingCoefficient() + */ + virtual void setDampingCoefficient(NxReal dampingCoefficient) = 0; + + /** + \brief Retrieves the damping coefficient. + + \return damping coefficient of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.dampingCoefficient setDampingCoefficient() + */ + virtual NxReal getDampingCoefficient() const = 0; + + /** + \brief Sets the soft body friction coefficient in the range from 0 to 1. + + \param[in] friction The friction of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.friction getFriction() + */ + virtual void setFriction(NxReal friction) = 0; + + /** + \brief Retrieves the soft body friction coefficient. + + \return Friction coefficient of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.friction setFriction() + */ + virtual NxReal getFriction() const = 0; + + /** + \brief Sets the soft body tear factor (must be larger than one). + + \param[in] factor The tear factor for the soft body + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.tearFactor getTearFactor() + */ + virtual void setTearFactor(NxReal factor) = 0; + + /** + \brief Retrieves the soft body tear factor. + + \return tear factor of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.tearFactor setTearFactor() + */ + virtual NxReal getTearFactor() const = 0; + + /** + \brief Sets the soft body attachment tear factor (must be larger than one). + + \param[in] factor The attachment tear factor for the soft body + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.attachmentTearFactor getAttachmentTearFactor() + */ + virtual void setAttachmentTearFactor(NxReal factor) = 0; + + /** + \brief Retrieves the attachment soft body tear factor. + + \return tear attachment factor of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.attachmentTearFactor setAttachmentTearFactor() + */ + virtual NxReal getAttachmentTearFactor() const = 0; + + /** + \brief Sets the soft body particle radius (must be positive). + + \param[in] particleRadius The particle radius of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.particleRadius getParticleRadius() + */ + virtual void setParticleRadius(NxReal particleRadius) = 0; + + /** + \brief Gets the soft body particle radius. + + \return particle radius of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.particleRadius setParticleRadius() + */ + virtual NxReal getParticleRadius() const = 0; + + /** + \brief Gets the soft body density. + + \return density of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.density + */ + virtual NxReal getDensity() const = 0; + + /** + \brief Gets the relative grid spacing for the broad phase. + The soft body is represented by a set of world aligned cubical cells in broad phase. + The size of these cells is determined by multiplying the length of the diagonal + of the AABB of the initial soft body size with this constant. + + \return relative grid spacing. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.relativeGridSpacing + */ + virtual NxReal getRelativeGridSpacing() const = 0; + + /** + \brief Retrieves the soft body solver iterations. + + \return solver iterations of the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.solverIterations setSolverIterations() + */ + virtual NxU32 getSolverIterations() const = 0; + + /** + \brief Sets the soft body solver iterations. + + \param[in] iterations The new solver iteration count for the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.solverIterations getSolverIterations() + */ + virtual void setSolverIterations(NxU32 iterations) = 0; + + /** + \brief Returns a world space AABB enclosing all soft body particles. + + \param[out] bounds Retrieves the world space bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 + */ + virtual void getWorldBounds(NxBounds3& bounds) const = 0; + + /** + \brief Attaches the soft body to a shape. All soft body vertices currently inside the shape are attached. + + \note This method only works with primitive and convex shapes. Since the inside of a general + triangle mesh is not clearly defined. + \note Collisions with attached shapes are automatically switched off to increase the stability. + + \param[in] shape Shape to which the soft body should be attached to. + \param[in] attachmentFlags One or two way interaction, tearable or non-tearable + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyAttachmentFlag freeVertex() attachToCollidingShapes() + */ + virtual void attachToShape(const NxShape *shape, NxU32 attachmentFlags) = 0; + + /** + \brief Attaches the soft body to all shapes, currently colliding. + + \note This method only works with primitive and convex shapes. Since the inside of a general + triangle mesh is not clearly defined. + \note Collisions with attached shapes are automatically switched off to increase the stability. + + \param[in] attachmentFlags One or two way interaction, tearable or non-tearable + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyAttachmentFlag NxSoftBodyDesc.attachmentTearFactor NxSoftBodyDesc.attachmentResponseCoefficient freeVertex() + */ + virtual void attachToCollidingShapes(NxU32 attachmentFlags) = 0; + + /** + \brief Detaches the soft body from a shape it has been attached to before. + + If the soft body has not been attached to the shape before, the call has no effect. + + \param[in] shape Shape from which the soft body should be detached. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyAttachmentFlag NxSoftBodyDesc.attachmentTearFactor NxSoftBodyDesc.attachmentResponseCoefficient freeVertex() attachToShape() + */ + virtual void detachFromShape(const NxShape *shape) = 0; + + /** + \brief Attaches a soft body vertex to a local position within a shape. + + \param[in] vertexId Index of the vertex to attach. + \param[in] shape Shape to attach the vertex to. + \param[in] localPos The position relative to the pose of the shape. + \param[in] attachmentFlags One or two way interaction, tearable or non-tearable + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxShape freeVertex() NxSoftBodyAttachmentFlag attachToShape() + */ + virtual void attachVertexToShape(NxU32 vertexId, const NxShape *shape, const NxVec3 &localPos, NxU32 attachmentFlags) = 0; + + /** + \brief Attaches a soft body vertex to a position in world space. + + \param[in] vertexId Index of the vertex to attach. + \param[in] pos The position in world space. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyAttachmentFlag NxSoftBodyDesc.attachmentTearFactor NxSoftBodyDesc.attachmentResponseCoefficient freeVertex() attachToShape() + */ + virtual void attachVertexToGlobalPosition(const NxU32 vertexId, const NxVec3 &pos) = 0; + + /** + \brief Frees a previously attached soft body vertex. + + \param[in] vertexId Index of the vertex to free. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see attachVertexToGlobalPosition() attachVertexToShape() detachFromShape() + */ + virtual void freeVertex(const NxU32 vertexId) = 0; + + /** + \note Experimental feature, not yet fully supported. + + \brief [Experimental] Tears the soft body at a given vertex. + + First the vertex is duplicated. The tetrahedra on one side of the split plane keep + the original vertex. For all tetrahedra on the opposite side the original vertex is + replaced by the new one. The split plane is defined by the world location of the + vertex and the normal provided by the user. + + Note: TearVertex performs a user defined vertex split in contrast to an automatic split + that is performed when the flag NX_SBF_TEARABLE is set. Therefore, tearVertex works + even if NX_SBF_TEARABLE is not set in NxSoftBodyDesc.flags. + + Note: For tearVertex to work in hardware mode, the softBodyMesh has to be cooked with the + flag NX_SOFTBODY_MESH_TEARABLE set in NxSoftBodyMeshDesc.flags. + + \param[in] vertexId Index of the vertex to tear. + \param[in] normal The normal of the split plane. + \return true if the split had an effect (i.e. there were tetrahedra on both sides of the split plane) + + @see NxSoftBodyFlag, NxSoftBodyMeshFlags, NxSoftBodyDesc.flags + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool tearVertex(const NxU32 vertexId, const NxVec3 &normal) = 0; + + /** + \brief Executes a raycast against the soft body. + + \param[in] worldRay The ray in world space. + \param[out] hit The hit position. + \param[out] vertexId Index to the nearest vertex hit by the raycast. + + \return true if the ray hits the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + virtual bool raycast(const NxRay& worldRay, NxVec3 &hit, NxU32 &vertexId) = 0; + + /** + \brief Sets which collision group this soft body is part of. + + \param[in] collisionGroup The collision group for this soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup + */ + virtual void setGroup(NxCollisionGroup collisionGroup) = 0; + + /** + \brief Retrieves the value set with #setGroup(). + + \return The collision group this soft body belongs to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCollisionGroup + */ + virtual NxCollisionGroup getGroup() const = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. + + \param[in] groupsMask The group mask to set for the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getGroupsMask() NxGroupsMask + */ + virtual void setGroupsMask(const NxGroupsMask& groupsMask) = 0; + + /** + \brief Sets 128-bit mask used for collision filtering. + + \return The group mask for the soft body. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setGroupsMask() NxGroupsMask + */ + virtual const NxGroupsMask getGroupsMask() const = 0; + + /** + \brief Sets the user buffer wrapper for the soft body mesh. + + \param[in,out] meshData User buffer wrapper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshData NxSoftBodyDesc.meshData + */ + virtual void setMeshData(NxMeshData& meshData) = 0; + + /** + \brief Returns a copy of the user buffer wrapper for the soft body mesh. + + \return User buffer wrapper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxMeshData setMeshData() NxSoftBodyDesc.meshData + */ + virtual NxMeshData getMeshData() = 0; + + /** + \brief Sets the user buffer wrapper for the soft body split pairs. + + \param[in,out] splitPairData User buffer wrapper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodySplitPairData NxSoftBodyDesc.splitPairData + */ + virtual void setSplitPairData(NxSoftBodySplitPairData& splitPairData) = 0; + + /** + \brief Returns a copy of the user buffer wrapper for the soft body split pairs. + + \return User buffer wrapper. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodySplitPairData setSplitPairData() NxSoftBodyDesc.splitPairData + */ + virtual NxSoftBodySplitPairData getSplitPairData() = 0; + + /** + Note: Valid bounds do not have an effect on soft bodies in the current version. + + \brief Sets the valid bounds of the soft body in world space. + + If the flag NX_SBF_VALIDBOUNDS is set, these bounds defines the volume + outside of which soft body particles are automatically removed from the simulation. + + \param[in] validBounds The valid bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.validBounds getValidBounds() NxBounds3 + */ + virtual void setValidBounds(const NxBounds3& validBounds) = 0; + + /** + Note: Valid bounds do not have an effect on soft bodies in the current version. + + \brief Returns the valid bounds of the soft body in world space. + + \param[out] validBounds The valid bounds. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.validBounds setValidBounds() NxBounds3 + */ + virtual void getValidBounds(NxBounds3& validBounds) const = 0; + + /** + \brief Sets the position of a particular vertex of the soft body. + + \param[in] position New position of the vertex. + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles() + */ + virtual void setPosition(const NxVec3& position, NxU32 vertexId) = 0; + + /** + \brief Sets the positions of the soft body. + + The user must supply a buffer containing all positions (i.e same number of elements as number of vertices). + + \param[in] buffer The user supplied buffer containing all positions for the soft body. + \param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getPositions() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual void setPositions(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Gets the position of a particular vertex of the soft body. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles() + */ + virtual NxVec3 getPosition(NxU32 vertexId) const = 0; + + /** + \brief Gets the positions of the soft body. + + The user must supply a buffer large enough to hold all positions (i.e same number of elements as number of particles). + + \param[in] buffer The user supplied buffer to hold all positions of the soft body. + \param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPositions() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual void getPositions(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Sets the velocity of a particular vertex of the soft body. + + \param[in] position New velocity of the vertex. + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPosition() getPosition() getVelocity() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual void setVelocity(const NxVec3& velocity, NxU32 vertexId) = 0; + + /** + \brief Sets the velocities of the soft body. + + The user must supply a buffer containing all velocities (i.e same number of elements as number of vertices). + + \param[in] buffer The user supplied buffer containing all velocities for the soft body. + \param[in] byteStride The stride in bytes between the velocity vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getVelocities() setPositions() getPositions() getNumberOfParticles() + */ + virtual void setVelocities(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Gets the velocity of a particular vertex of the soft body. + + \param[in] vertexId Index of the vertex. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setPosition() getPosition() setVelocity() setVelocities() getVelocities() getNumberOfParticles() + */ + virtual NxVec3 getVelocity(NxU32 vertexId) const = 0; + + /** + \brief Gets the velocities of the soft body. + + The user must supply a buffer large enough to hold all velocities (i.e same number of elements as number of vertices). + + \param[in] buffer The user supplied buffer to hold all velocities of the soft body. + \param[in] byteStride The stride in bytes between the velocity vectors in the buffer. Default is size of NxVec3. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setVelocities() setPositions() getPositions() getNumberOfParticles() + */ + virtual void getVelocities(void* buffer, NxU32 byteStride = sizeof(NxVec3)) = 0; + + /** + \brief Gets the number of soft body particles. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setVelocities() getVelocities() setPositions() getPositions() + */ + virtual NxU32 getNumberOfParticles() = 0; + + /** + \brief Queries the soft body for the currently interacting shapes. Must be called prior to saveStateToStream in order for attachments and collisons to be saved. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getShapePointers() setShapePointers() saveStateToStream() loadStateFromStream() + */ + virtual NxU32 queryShapePointers() = 0; + + /** + \brief Gets the byte size of the current soft body state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getNumberOfParticles() + */ + virtual NxU32 getStateByteSize() = 0; + + /** + \brief Saves pointers to the currently interacting shapes to memory + + \param[in] shapePointers The user supplied array to hold the shape pointers. + \param[in] flags The optional user supplied array to hold the attachment shape flags for the various shapes. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see queryShapePointers() setShapePointers() saveStateToStream() loadStateFromStream() + */ + virtual void getShapePointers(NxShape** shapePointers,NxU32 *flags) = 0; + + /** + \brief Loads pointers to the currently interacting shapes from memory. + + \param[in] shapePointers The user supplied array that holds the shape pointers. Must be in the exact same order as the shapes were retrieved by getShapePointers. + \param[in] numShapes The size of the supplied array. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see queryShapePointers() getShapePointers() saveStateToStream() loadStateFromStream() + */ + virtual void setShapePointers(NxShape** shapePointers,unsigned int numShapes) = 0; + + /** + \brief Saves the current soft body state to a stream. + + queryShapePointers must be called prior to this function in order for attachments and collisions to be saved. + Tearable soft bodies are currently not supported. + A saved state contains platform specific data and can thus only be loaded on back on the same platform. + + \param[in] stream The user supplied stream to hold the soft body state. + \param[in] permute If true, the order of the vertices output will correspond to that of the associated + NxSoftBodyMesh's saveToDesc mehod; if false (the default), it will correspond to the original NxSoftBodyMesh descriptor + used to create the mesh. These may differ due to cooking. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see loadStateFromStream() queryShapePointers() getShapePointers() setShapePointers() + */ + virtual void saveStateToStream(NxStream& stream, bool permute = false) = 0; + + /** + \brief Loads the current soft body state from a stream. + + setShapePointers must be called prior to this function if attachments and collisions are to be loaded. + Tearable soft bodies are currently not supported. + A saved state contains platform specific data and can thus only be loaded on back on the same platform. + + \param[in] stream The user supplied stream that holds the soft body state. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see saveStateToStream() queryShapePointers() getShapePointers() setShapePointers() + */ + virtual void loadStateFromStream(NxStream& stream) = 0; + + /** + \brief Sets the collision response coefficient. + + \param[in] coefficient The collision response coefficient (0 or greater). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.collisionResponseCoefficient getCollisionResponseCoefficient() + */ + virtual void setCollisionResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves the collision response coefficient. + + \return The collision response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.collisionResponseCoefficient setCollisionResponseCoefficient() + */ + virtual NxReal getCollisionResponseCoefficient() const = 0; + + /** + \brief Sets the attachment response coefficient + + \param[in] coefficient The attachment response coefficient in the range from 0 to 1. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.attachmentResponseCoefficient getAttachmentResponseCoefficient() + */ + virtual void setAttachmentResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves the attachment response coefficient + + \return The attachment response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.attachmentResponseCoefficient setAttachmentResponseCoefficient() + */ + virtual NxReal getAttachmentResponseCoefficient() const = 0; + + /** + \brief Sets the response coefficient for collisions from fluids to this soft body + + \param[in] coefficient The response coefficient + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.fromFluidResponseCoefficient getFromFluidResponseCoefficient() + */ + virtual void setFromFluidResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves response coefficient for collisions from fluids to this soft body + + \return The response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.fromFluidResponseCoefficient setFromFluidResponseCoefficient() + */ + virtual NxReal getFromFluidResponseCoefficient() const = 0; + + /** + \brief Sets the response coefficient for collisions from this soft body to fluids + + \param[in] coefficient The response coefficient + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.toFluidResponseCoefficient getToFluidResponseCoefficient() + */ + virtual void setToFluidResponseCoefficient(NxReal coefficient) = 0; + + /** + \brief Retrieves response coefficient for collisions from this soft body to fluids + + \return The response coefficient. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.toFluidResponseCoefficient setToFluidResponseCoefficient() + */ + virtual NxReal getToFluidResponseCoefficient() const = 0; + + /** + \brief Sets an external acceleration which affects all non attached particles of the soft body + + \param[in] acceleration The acceleration vector (unit length / s^2) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.externalAcceleration getExternalAcceleration() + */ + virtual void setExternalAcceleration(NxVec3 acceleration) = 0; + + /** + \brief Retrieves the external acceleration which affects all non attached particles of the soft body + + \return The acceleration vector (unit length / s^2) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.externalAcceleration setExternalAcceleration() + */ + virtual NxVec3 getExternalAcceleration() const = 0; + + /** + \brief If the NX_SBF_ADHERE flag is set the soft body moves partially in the frame + of the attached actor. + + This feature is useful when the soft body is attached to a fast moving shape. + In that case the soft body adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + \param[in] velocity The minimal velocity for the soft body to adhere (unit length / s) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.minAdhereVelocity getMinAdhereVelocity() + */ + virtual void setMinAdhereVelocity(NxReal velocity) = 0; + + /** + \brief If the NX_SBF_ADHERE flag is set the soft body moves partially in the frame + of the attached actor. + + This feature is useful when the soft body is attached to a fast moving shape. + In that case the soft body adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + \return Returns the minimal velocity for the soft body to adhere (unit length / s) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.minAdhereVelocity setMinAdhereVelocity() + */ + virtual NxReal getMinAdhereVelocity() const = 0; + + /** + \brief Returns true if this soft body is sleeping. + + When a soft body does not move for a period of time, it is no longer simulated in order to save time. This state + is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object, + or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user. + + If a soft body is asleep after the call to NxScene::fetchResults() returns, it is guaranteed that the position of the soft body + vertices was not changed. You can use this information to avoid updating dependent objects. + + \return True if the soft body is sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() + */ + virtual bool isSleeping() const = 0; + + /** + \brief Returns the linear velocity below which a soft body may go to sleep. + + A soft body whose linear velocity is above this threshold will not be put to sleep. + + @see isSleeping + + \return The threshold linear velocity for sleeping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() setSleepLinearVelocity() + */ + virtual NxReal getSleepLinearVelocity() const = 0; + + /** + \brief Sets the linear velocity below which a soft body may go to sleep. + + A soft body whose linear velocity is above this threshold will not be put to sleep. + + If the threshold value is negative, the velocity threshold is set using the NxPhysicsSDK's + NX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter. + + \param[in] threshold Linear velocity below which a soft body may sleep. Range: (0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() + */ + virtual void setSleepLinearVelocity(NxReal threshold) = 0; + + /** + \brief Wakes up the soft body if it is sleeping. + + The wakeCounterValue determines how long until the soft body is put to sleep, a value of zero means + that the soft body is sleeping. wakeUp(0) is equivalent to NxSoftBody::putToSleep(). + + \param[in] wakeCounterValue New sleep counter value. Range: [0,inf] + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() putToSleep() + */ + virtual void wakeUp(NxReal wakeCounterValue = NX_SLEEP_INTERVAL) = 0; + + /** + \brief Forces the soft body to sleep. + + The soft body will fall asleep. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see isSleeping() getSleepLinearVelocity() wakeUp() + */ + virtual void putToSleep() = 0; + + /** + \brief Sets the flags, a combination of the bits defined by the enum ::NxSoftBodyFlag. + + \param[in] flags #NxSoftBodyFlag combination. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.flags NxSoftBodyFlag getFlags() + */ + virtual void setFlags(NxU32 flags) = 0; + + /** + \brief Retrieves the flags. + + \return The soft body flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.flags NxSoftBodyFlag setFlags() + */ + virtual NxU32 getFlags() const = 0; + + /** + \brief Sets a name string for the object that can be retrieved with getName(). + + This is for debugging and is not used by the SDK. The string is not copied by + the SDK, only the pointer is stored. + + \param[in] name String to set the objects name to. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see getName() + */ + virtual void setName(const char* name) = 0; + + /** + \brief Applies a force (or impulse) defined in the global coordinate frame, to a particular + vertex of the soft body. + + Because forces are reset at the end of every timestep, + you can maintain a total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + \param[in] force Force/impulse to add, defined in the global frame. Range: force vector + \param[in] vertexId Number of the vertex to add the force at. Range: position vector + \param[in] mode The mode to use when applying the force/impulse + (see #NxForceMode, supported modes are NX_FORCE, NX_IMPULSE, NX_ACCELERATION, NX_VELOCITY_CHANGE) + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + */ + virtual void addForceAtVertex(const NxVec3& force, NxU32 vertexId, NxForceMode mode = NX_FORCE) = 0; + + /** + \brief Applies a radial force (or impulse) at a particular position. All vertices + within radius will be affected with a quadratic drop-off. + + Because forces are reset at the end of every timestep, + you can maintain a total external force on an object by calling this once every frame. + + ::NxForceMode determines if the force is to be conventional or impulsive. + + \param[in] position Position to apply force at. + \param[in] magnitude Magnitude of the force/impulse to apply. + \param[in] radius The sphere radius in which particles will be affected. Range: position vector + \param[in] mode The mode to use when applying the force/impulse + (see #NxForceMode, supported modes are NX_FORCE, NX_IMPULSE, NX_ACCELERATION, NX_VELOCITY_CHANGE). + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxForceMode + */ + virtual void addForceAtPos(const NxVec3& position, NxReal magnitude, NxReal radius, NxForceMode mode = NX_FORCE) = 0; + + /** + \brief Finds tetrahedra touching the input bounds. + + \warning This method returns a pointer to an internal structure using the indices member. Hence the + user should use or copy the indices before calling any other API function. + + \param[in] bounds Bounds to test against in world space. Range: See #NxBounds3 + \param[out] nb Retrieves the number of tetrahedral indices touching the AABB. + \param[out] indices Returns an array of touching tetrahedra indices. + The tetrahedral indices correspond to the tetrahedra referenced to by NxSoftBodyDesc.meshdata (#NxMeshData). + Tetrahedron i has the vertices 4i, 4i+1, 4i+2 and 4i+3 in the array NxMeshData.indicesBegin. + \return True if there is an overlap. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxBounds3 NxSoftBodyDesc NxMeshData + */ + virtual bool overlapAABBTetrahedra(const NxBounds3& bounds, NxU32& nb, const NxU32*& indices) const = 0; + + /** + \brief Retrieves the scene which this soft body belongs to. + + \return Owner Scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxScene + */ + virtual NxScene& getScene() const = 0; + + /** + \brief Retrieves the name string set with setName(). + + \return Name string associated with object. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see setName() + */ + virtual const char* getName() const = 0; + + /** + \brief Retrieves the soft body's simulation compartment, as specified by the user at creation time. + \return NULL if the soft body is not simulated in a compartment or if it was specified to run in + the default soft body compartment, otherwise the simulation compartment. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxCompartment + */ + virtual NxCompartment * getCompartment() const = 0; + + /** + \brief Retrieves the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual NxForceFieldMaterial getForceFieldMaterial() const = 0; + + /** + \brief Sets the actor's force field material index, default index is 0 + + Platform: + \li PC SW: Yes + \li PPU : Yes [SW fallback] + \li PS3 : Yes + \li XB360: Yes + */ + virtual void setForceFieldMaterial(NxForceFieldMaterial) = 0; + + //public variables: +public: + void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. +}; +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2006 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyDesc.h b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyDesc.h new file mode 100755 index 0000000..efb9180 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyDesc.h @@ -0,0 +1,855 @@ +#ifndef NX_PHYSICS_NX_SOFTBODYDESC +#define NX_PHYSICS_NX_SOFTBODYDESC +/** \addtogroup softbody + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/NxBounds3.h" +#include "PX/NxMeshData.h" + +class NxSoftBodyMesh; +class NxCompartment; + +/** +\brief Collection of flags describing the behavior of a soft body. + +@see NxSoftBody NxSoftBodyMesh NxSoftBodyMeshDesc +*/ +enum NxSoftBodyFlag +{ + /** + \brief Makes the soft body static. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SBF_STATIC = (1<<1), + + /** + \brief Disable collision handling with the rigid body scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.collisionResponseCoefficient + */ + NX_SBF_DISABLE_COLLISION = (1<<2), + + /** + \brief Enable/disable self-collision handling within a single soft body. + + Note: self-collisions are only handled inbetween the soft body's particles, i.e., + particles do not collide against the tetrahedra of the soft body. + The user should therefore specify a large enough particleRadius to avoid + most interpenetrations. See NxSoftBodyDesc.particleRadius. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SBF_SELFCOLLISION = (1<<3), + + /** + \brief Enable/disable debug visualization. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SBF_VISUALIZATION = (1<<4), + + /** + \brief Enable/disable gravity. If off, the soft body is not subject to the gravitational force + of the rigid body scene. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SBF_GRAVITY = (1<<5), + + /** + \brief Enable/disable volume conservation. Select volume conservation through + NxSoftBodyDesc.volumeStiffness. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.volumeStiffness + */ + NX_SBF_VOLUME_CONSERVATION = (1<<6), + + /** + \brief Enable/disable damping of internal velocities. Use NxSoftBodyDesc.dampingCoefficient + to control damping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.dampingCoefficient + */ + NX_SBF_DAMPING = (1<<7), + + /** + \brief Enable/disable two way collision of the soft body with the rigid body scene. + + In either case, the soft body is influenced by colliding rigid bodies. + If NX_SBF_COLLISION_TWOWAY is not set, rigid bodies are not influenced by + colliding with the soft body. Use NxSoftBodyDesc.collisionResponseCoefficient to + control the strength of the feedback force on rigid bodies. + + When using two way interaction care should be taken when setting the density of the attached objects. + For example if an object with a very low or high density is attached to a soft body then the simulation + may behave poorly. This is because impulses are only transfered between the soft body and rigid body solver + outside the solvers. + + Two way interaction works best when NX_SF_SEQUENTIAL_PRIMARY is set in the primary scene. If not set, + collision and attachment artifacts may happen. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.collisionResponseCoefficient + */ + NX_SBF_COLLISION_TWOWAY = (1<<8), + + /** + \brief Defines whether the soft body is tearable. + + Make sure meshData.maxVertices and the corresponding buffers + in meshData are substantially larger (e.g. 2x) than the number + of original vertices since tearing will generate new vertices. + When the buffer cannot hold the new vertices anymore, tearing stops. + If this buffer is chosen big enough, the entire mesh can be + torn into all constituent tetrahedral elements. + (The theoretical maximum needed is 12 times the original number of vertices. + For reasonable mesh topologies, this should never be reached though.) + + If the soft body is simulated on the hardware, additional buffer + limitations that cannot be controlled by the user exist. Therefore, soft + bodies might cease to tear apart further, even though not all space in + the user buffer is used up. + + Note: For tearing in hardware, make sure you cook the mesh with + the flag NX_SOFTBODY_MESH_TEARABLE set in the NxSoftBodyMeshDesc.flags. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.tearFactor NxSoftBodyDesc.meshData NxSoftBodyMeshDesc.flags + */ + NX_SBF_TEARABLE = (1<<9), + + /** + \brief Defines whether this soft body is simulated on the PPU. + + To simulate a soft body on the PPU + set this flag and create the soft body in a regular software scene. + Note: only use this flag during creation, do not change it using NxSoftBody.setFlags(). + */ + NX_SBF_HARDWARE = (1<<10), + + /** + \brief Enable/disable center of mass damping of internal velocities. + + This flag only has an effect if the flag NX_SBF_DAMPING is set. If set, + the global rigid body modes (translation and rotation) are extracted from damping. + This way, the soft body can freely move and rotate even under high damping. + Use NxSoftBodyDesc.dampingCoefficient to control damping. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.dampingCoefficient + */ + NX_SBF_COMDAMPING = (1<<11), + + /** + \brief If the flag NX_SBF_VALIDBOUNDS is set, soft body particles outside the volume + defined by NxSoftBodyDesc.validBounds are automatically removed from the simulation. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.validBounds + */ + NX_SBF_VALIDBOUNDS = (1<<12), + + /** + \brief Enable/disable collision handling between this soft body and fluids. + + Note: With the current implementation, do not switch on fluid collision for + many soft bodies. Create scenes with a few bodies because the memory usage + increases linearly with the number of soft bodies. + The performance of the collision detection is dependent on both the particle + radius of the soft body and the particle radius of the fluid, so tuning + these parameters might improve the performance significantly. + + Note: The current implementation does not obey the NxScene::setGroupCollisionFlag + settings. If NX_SBF_FLUID_COLLISION is set, collisions will take place even if + collisions between the groups that the corresponding soft body and fluid belong to are + disabled. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.fluidCollisionResponseCoefficient + */ + NX_SBF_FLUID_COLLISION = (1<<13), + + /** + \brief Disable continuous collision detection with dynamic actors. + Dynamic actors are handled as static ones. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + */ + NX_SBF_DISABLE_DYNAMIC_CCD = (1<<14), + + /** + \brief Moves soft body partially in the frame of the attached actor. + + This feature is useful when the soft body is attached to a fast moving shape. + In that case the soft body adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyDesc.minAdhereVelocity + */ + NX_SBF_ADHERE = (1<<15), + +}; + +/*----------------------------------------------------------------------------*/ + +/** +\brief Soft body attachment flags. + +@see NxSoftBody.attachToShape() NxSoftBody.attachToCollidingShapes() NxSoftBody.attachVertexToShape() +*/ +enum NxSoftBodyAttachmentFlag +{ + /** + \brief The default is only object->soft body interaction (one way). + + With this flag set, soft body->object interaction is turned on as well. + + Care should be taken if objects with small masses (either through low + density or small volume) are attached, as the simulation may easily become unstable. + The NxSoftBodyDesc.attachmentResponseCoefficient field should be used to lower + the magnitude of the impulse transfer from the soft body to the attached rigid body. + */ + NX_SOFTBODY_ATTACHMENT_TWOWAY = (1<<0), + + /** + \brief When this flag is set, the attachment is tearable. + + @see NxSoftBodyDesc.attachmentTearFactor + */ + NX_SOFTBODY_ATTACHMENT_TEARABLE = (1<<1), +}; + +/*----------------------------------------------------------------------------*/ + +/** +\brief User-side class specifying a tetrahedron split generated from a torn soft body. +*/ +class NxSoftBodySplitPair +{ +public: + NxU32 tetrahedronIndex0; + NxU32 tetrahedronIndex1; + NxU8 faceIndex0; + NxU8 faceIndex1; +}; + +/** +\brief User-side class for receiving tetrahedron split events for torn softbodies. + +The user can optionally receive tetrahedron split event data if a soft body gets torn. +One split is represented by a pair of tetrahedron indices and a pair of face indices. +The tetrahedra indices can be used to locate the vertex index quadruple belonging to +the two mesh tetrahedra involved in split. + +Each pair is garantueed to be reported only once. +*/ +class NxSoftBodySplitPairData +{ +public: + /** + \brief Specifies the maximal number of splits the buffer can hold. + + If there are more splits in one time step than the buffer can hold, some will go unreported. + */ + NxU32 maxSplitPairs; + + /** + \brief Points to the user-allocated memory holding the number of splits stored in the buffer. + + If the SDK writes to a given split buffer, it also sets the numbers of entries written. + If this is set to NULL, the SDK can't write to the buffer. + */ + NxU32* numSplitPairsPtr; + + /** + \brief The pointer to the user-allocated buffer of split pairs. + + If set to NULL, split pairs are not written. + */ + NxSoftBodySplitPair* splitPairsBegin; + + /** + \brief The separation (in bytes) between consecutive split pairs. + + The first split pair is found at location splitPairsBegin; + the second is at splitPairsBegin + splitPairsByteStride; + and so on. + */ + NxU32 splitPairsByteStride; + + NX_INLINE ~NxSoftBodySplitPairData(); + + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxSoftBodySplitPairData(); +}; + +NX_INLINE NxSoftBodySplitPairData::NxSoftBodySplitPairData() + { + setToDefault(); + } + +NX_INLINE NxSoftBodySplitPairData::~NxSoftBodySplitPairData() + { + } + +NX_INLINE void NxSoftBodySplitPairData::setToDefault() + { + maxSplitPairs = 0; + numSplitPairsPtr = NULL; + splitPairsBegin = NULL; + splitPairsByteStride = 0; + } + +NX_INLINE bool NxSoftBodySplitPairData::isValid() const + { + if (numSplitPairsPtr && !splitPairsBegin) return false; + if (!numSplitPairsPtr && splitPairsBegin) return false; + if (splitPairsBegin && !splitPairsByteStride) return false; + return true; + } + +/*----------------------------------------------------------------------------*/ + +/** +\brief Descriptor class for #NxSoftBody. + +@see NxSoftBody NxSoftBody.saveToDesc() +*/ +class NxSoftBodyDesc +{ +public: + /** + \brief The cooked soft body mesh. + + Default: NULL + + @see NxSoftBodyMesh NxSoftBodyMeshDesc NxSoftBody.getSoftBodyMesh() + */ + NxSoftBodyMesh *softBodyMesh; + + /** + \brief The global pose of the soft body in the world. + + Default: Identity Transform + */ + NxMat34 globalPose; + + /** + \brief Size of the particles used for collision detection. + + The particle radius is usually a fraction of the overall extent of the soft body and + should not be set to a value greater than that. A good value is the maximal + distance between two adjacent soft body particles in their rest pose. Visual + artifacts or collision problems may appear if the particle radius is too small. + + Default: 0.1
+ Range: [0,inf) + + @see NxSoftBody.setParticleRadius() + */ + NxReal particleRadius; + + /** + \brief Density of the soft body (mass per volume). + + Default: 1.0
+ Range: (0,inf) + */ + NxReal density; + + /** + \brief Volume stiffness of the soft body in the range 0 to 1. + + Defines how strongly the soft body counteracts deviations from the rest volume. + Only has an effect if the flag NX_SBF_VOLUME_CONSERVATION is set. + + Default: 1.0
+ Range: [0,1] + + @see NX_SBF_VOLUME_CONSERVATION NxSoftBody.setVolumeStiffness() + */ + NxReal volumeStiffness; + + /** + \brief Stretching stiffness of the soft body in the range 0 to 1. + + Defines how strongly the soft body counteracts deviations from the rest lengths of edges. + + Note: stretching stiffness must be larger than 0. Even if the stretching stiffness is set very low, + tetrahedra edges will cease to stretch further if their length exceeds a certain internal limit. + This is done to prevent heavily degenerated tetrahedral elements which could occur otherwise. + + Default: 1.0
+ Range: (0,1] + + @see NxSoftBody.setStretchingStiffness() + */ + NxReal stretchingStiffness; + + /** + \brief Spring damping of the soft body in the range 0 to 1. + + Only has an effect if the flag NX_SBF_DAMPING is set. + + Default: 0.5
+ Range: [0,1] + + @see NX_SBF_DAMPING NxSoftBody.setDampingCoefficient() + */ + NxReal dampingCoefficient; + + /** + \brief Friction coefficient in the range 0 to 1. + + Defines the damping of the velocities of soft body particles that are in contact. + + Default: 0.5
+ Range: [0,1] + + @see NxSoftBody.setFriction() + */ + NxReal friction; + + /** + \note Experimental feature. + + \brief If the flag NX_SBF_TEARABLE is set, this variable defines the + elongation factor that causes the soft body to tear. + + Must be larger than 1. + Make sure meshData.maxVertices and the corresponding buffers + in meshData are substantially larger (e.g. 2x) then the number + of original vertices since tearing will generate new vertices. + + When the buffer cannot hold the new vertices anymore, tearing stops. + + Default: 1.5
+ Range: (1,inf) + + @see NxSoftBody.setTearFactor() + */ + NxReal tearFactor; + + /** + \brief Defines a factor for the impulse transfer from the soft body to colliding rigid bodies. + + Only has an effect if NX_SBF_COLLISION_TWOWAY is set. + + Default: 0.2
+ Range: [0,inf) + + @see NX_SBF_COLLISION_TWOWAY NxSoftBody.setCollisionResponseCoefficient() + */ + NxReal collisionResponseCoefficient; + + /** + \brief Defines a factor for the impulse transfer from the soft body to attached rigid bodies. + + Only has an effect if the mode of the attachment is set to NX_SOFTBODY_ATTACHMENT_TWOWAY. + + Default: 0.2
+ Range: [0,1] + + @see NxSoftBody.attachToShape NxSoftBody.attachToCollidingShapes NxSoftBody.attachVertexToShape NxSoftBody.setAttachmentResponseCoefficient() + */ + NxReal attachmentResponseCoefficient; + + /** + \brief If the flag NX_SOFTBODY_ATTACHMENT_TEARABLE is set in the attachment method of NxSoftBody, + this variable defines the elongation factor that causes the attachment to tear. + + Must be larger than 1. + + Default: 1.5
+ Range: (1,inf) + + @see NxSoftBody.setAttachmentTearFactor() NxSoftBody.attachToShape NxSoftBody.attachToCollidingShapes NxSoftBody.attachVertexToShape + */ + NxReal attachmentTearFactor; + + /** + \brief Defines a factor for the impulse transfer from this soft body to colliding fluids. + + Only has an effect if the NX_SBF_FLUID_COLLISION flag is set. + + Default: 1.0
+ Range: [0,inf) + + Note: Large values can cause instabilities + + @see NxSoftBodyDesc.flags NxSoftBodyDesc.fromFluidResponseCoefficient + */ + NxReal toFluidResponseCoefficient; + + /** + \brief Defines a factor for the impulse transfer from colliding fluids to this soft body. + + Only has an effect if the NX_SBF_FLUID_COLLISION flag is set. + + Default: 1.0
+ Range: [0,inf) + + Note: Large values can cause instabilities + + @see NxSoftBodyDesc.flags NxSoftBodyDesc.toFluidResponseCoefficient + */ + NxReal fromFluidResponseCoefficient; + + /** + \brief If the NX_SBF_ADHERE flag is set the soft body moves partially in the frame + of the attached actor. + + This feature is useful when the soft body is attached to a fast moving shape. + In that case the soft body adheres to the shape it is attached to while only + velocities below the parameter minAdhereVelocity are used for secondary effects. + + Default: 1.0 + Range: [0,inf) + + @see NX_SBF_ADHERE + */ + + NxReal minAdhereVelocity; + + /** + \brief Number of solver iterations. + + Note: Small numbers make the simulation faster while the soft body gets less stiff. + + Default: 5 + Range: [1,inf) + + @see NxSoftBody.setSolverIterations() + */ + NxU32 solverIterations; + + /** + \brief External acceleration which affects all non attached particles of the soft body. + + Default: (0,0,0) + + @see NxSoftBody.setExternalAcceleration() + */ + NxVec3 externalAcceleration; + + /** + \brief The soft body wake up counter. + + Range: [0,inf)
+ Default: 20.0f*0.02f + + @see NxSoftBody.wakeUp() NxSoftBody.putToSleep() + */ + NxReal wakeUpCounter; + + /** + \brief Maximum linear velocity at which the soft body can go to sleep. + + If negative, the global default will be used. + + Range: [0,inf)
+ Default: -1.0 + + @see NxSoftBody.setSleepLinearVelocity() NxSoftBody.getSleepLinearVelocity() + */ + NxReal sleepLinearVelocity; + + /** + \brief The buffers in meshData are used to communicate the dynamic data of the soft body back to the user. + + For example vertex positions and connectivity (tetrahedra). The internal order + of the contents of meshData's buffers will remain the same as that in the initial mesh data used to create the mesh. + + Default: See #NxMeshData + + @see NxMeshData NxSoftBody.setMeshData() + */ + NxMeshData meshData; + + /** + \brief The buffers in splitPairData are used to communicate the split tetrahedra data of the soft body back to the user. + + @see NxSoftBodySplitPairData + */ + NxSoftBodySplitPairData splitPairData; + + /** + \brief Sets which collision group this soft body is part of. + + Range: [0, 31] + Default: 0 + + NxSoftBody.setCollisionGroup() + */ + NxCollisionGroup collisionGroup; + + /** + \brief Sets the 128-bit mask used for collision filtering. + + Default: 0 + + @see NxGroupsMask NxSoftBody.setGroupsMask() NxSoftBody.getGroupsMask() + */ + NxGroupsMask groupsMask; + + /** + \brief Force Field Material Index, index != 0 has to be created. + + Default: 0 + */ + NxU16 forceFieldMaterial; + + /** + \brief If the flag NX_SBF_VALIDBOUNDS is set, this variable defines the volume + outside of which soft body particles are automatically removed from the simulation. + + @see NX_SBF_VALIDBOUNDS NxSoftBody.setValidBounds() + */ + NxBounds3 validBounds; + + /** + \brief This parameter defines the size of grid cells for collision detection. + + The soft body is represented by a set of world aligned cubical cells in broad phase. + The size of these cells is determined by multiplying the length of the diagonal + of the AABB of the initial soft body size with this constant. + + Range: [0.01,inf)
+ Default: 0.25 + */ + NxReal relativeGridSpacing; + + /** + \brief Flag bits. + + Default: NX_SBF_GRAVITY | NX_SBF_VOLUME_CONSERVATION + + @see NxSoftBodyFlag NxSoftBody.setFlags() + */ + NxU32 flags; + + /** + \brief Will be copied to NxSoftBody::userData + + Default: NULL + + @see NxSoftBody.userData + */ + void* userData; + + /** + \brief Possible debug name. The string is not copied by the SDK, only the pointer is stored. + + Default: NULL + + @see NxSoftBody.setName() NxSoftBody.getName() + */ + const char* name; + + /** + \brief The compartment to place the soft body in. The soft body feature currently uses the cloth + simulation, so this must be either a pointer to an NxCompartment of type NX_SCT_SOFTBODY + (or NX_SCT_CLOTH, since cloth and softbody currently use the same compartments), or NULL. + A NULL compartment means creating the soft body in the first available cloth compartment + (a default cloth compartment is created if none exists). A software soft body with a NULL + compartment is created in the scene on which createSoftBody() is called. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + Default: NULL + */ + NxCompartment * compartment; + + /** + \brief Constructor sets to default. + */ + NX_INLINE NxSoftBodyDesc(); + + /** + \brief (Re)sets the structure to the default. + */ + NX_INLINE void setToDefault(); + + /** + \brief Returns true if the current settings are valid + */ + NX_INLINE bool isValid() const; +}; + +/*----------------------------------------------------------------------------*/ + +NX_INLINE NxSoftBodyDesc::NxSoftBodyDesc() +{ + setToDefault(); +} + +/*----------------------------------------------------------------------------*/ + +NX_INLINE void NxSoftBodyDesc::setToDefault() +{ + softBodyMesh = NULL; + globalPose.id(); + particleRadius = 0.1f; + density = 1.0f; + volumeStiffness = 1.0f; + stretchingStiffness = 1.0f; + dampingCoefficient = 0.5f; + friction = 0.5f; + tearFactor = 1.5f; + attachmentTearFactor = 1.5f; + attachmentResponseCoefficient = 0.2f; + collisionResponseCoefficient = 0.2f; + toFluidResponseCoefficient = 1.0f; + fromFluidResponseCoefficient = 1.0f; + minAdhereVelocity = 1.0f; + flags = NX_SBF_GRAVITY | NX_SBF_VOLUME_CONSERVATION; + solverIterations = 5; + wakeUpCounter = NX_SLEEP_INTERVAL; + sleepLinearVelocity = -1.0f; + collisionGroup = 0; + externalAcceleration.set(0.0f, 0.0f, 0.0f); + groupsMask.bits0 = 0; + groupsMask.bits1 = 0; + groupsMask.bits2 = 0; + groupsMask.bits3 = 0; + validBounds.setEmpty(); + relativeGridSpacing = 0.25f; + meshData.setToDefault(); + userData = NULL; + name = NULL; + compartment = NULL; + forceFieldMaterial = 0; +} + +/*----------------------------------------------------------------------------*/ + +NX_INLINE bool NxSoftBodyDesc::isValid() const +{ + if(!softBodyMesh) return false; + if(!globalPose.isFinite()) return false; + if(particleRadius < 0.0f) return false; + if(density <= 0.0f) return false; + if(volumeStiffness < 0.0f || volumeStiffness > 1.0f) return false; + if(stretchingStiffness <= 0.0f || stretchingStiffness > 1.0f) return false; + if(tearFactor <= 1.0f) return false; + if(attachmentTearFactor <= 1.0f) return false; + if(solverIterations < 1) return false; + if(friction < 0.0f || friction > 1.0f) return false; + if(!meshData.isValid()) return false; + if(dampingCoefficient < 0.0f || dampingCoefficient > 1.0f) return false; + if(collisionResponseCoefficient < 0.0f) return false; + if(wakeUpCounter < 0.0f) return false; + if(attachmentResponseCoefficient < 0.0f || attachmentResponseCoefficient > 1.0f) return false; + if(toFluidResponseCoefficient < 0.0f) return false; + if(fromFluidResponseCoefficient < 0.0f) return false; + if(minAdhereVelocity < 0.0f) return false; + if(relativeGridSpacing < 0.01f) return false; + if(collisionGroup >= 32) return false; // We only support 32 different collision groups + return true; +} + +/*----------------------------------------------------------------------------*/ +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2006 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyMesh.h b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyMesh.h new file mode 100755 index 0000000..1852ecc --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyMesh.h @@ -0,0 +1,68 @@ +#ifndef NX_PHYSICS_NX_SOFTBODYMESH +#define NX_PHYSICS_NX_SOFTBODYMESH +/** \addtogroup softbody + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +#include "PX/Nxp.h" +#include "PX/softbody/NxSoftBodyMeshDesc.h" + +class NxStream; + +class NxSoftBodyMesh +{ +protected: + NX_INLINE NxSoftBodyMesh() {} + virtual ~NxSoftBodyMesh() {} + +public: + /** + \brief Saves the soft body mesh descriptor. + A soft body mesh is created via the cooker. The cooker potentially changes the + order of the arrays references by the pointers vertices and triangles. + Since saveToDesc returns the data of the cooked mesh, this data might + differ from the originally provided data. Note that this is in contrast to the meshData + member of NxSoftBodyDesc, which is guaranteed to provide data in the same order as + that used to create the mesh. + + \param desc The descriptor used to retrieve the state of the object. + \return True on success. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBodyMeshDesc + */ + virtual bool saveToDesc(NxSoftBodyMeshDesc& desc) const = 0; + + /** + \brief Gets the number of soft body instances referencing this soft body mesh. + + Platform: + \li PC SW: Yes + \li PPU : Yes + \li PS3 : Yes + \li XB360: Yes + + @see NxSoftBody + */ + virtual NxU32 getReferenceCount() const = 0; +}; +/** @} */ +#endif +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2006 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyMeshDesc.h b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyMeshDesc.h new file mode 100755 index 0000000..3814908 --- /dev/null +++ b/libraries/external/physx/Win32/include/PX/softbody/NxSoftBodyMeshDesc.h @@ -0,0 +1,194 @@ +#ifndef NX_PHYSICS_NX_SOFTBODYMESHDESC +#define NX_PHYSICS_NX_SOFTBODYMESHDESC +/** \addtogroup softbody + @{ +*/ +/*----------------------------------------------------------------------------*\ +| +| Public Interface to Ageia PhysX Technology +| +| www.ageia.com +| +\*----------------------------------------------------------------------------*/ + +/** +\brief Soft body mesh flags. + +@see NxSoftBodyMeshDesc.flags +*/ +enum NxSoftBodyMeshFlags + { + NX_SOFTBODY_MESH_16_BIT_INDICES = (1<<1), // 0xffff && flags & NX_SOFTBODY_MESH_16_BIT_INDICES) + return false; + if(!vertices) + return false; + if(vertexStrideBytes < sizeof(NxPoint)) //should be at least one point's worth of data + return false; + + if(!tetrahedra) + return false; + + if(flags & NX_SOFTBODY_MESH_16_BIT_INDICES) + { + if((tetrahedronStrideBytes < sizeof(NxU16)*3)) + return false; + } + else + { + if((tetrahedronStrideBytes < sizeof(NxU32)*3)) + return false; + } + + if(vertexMasses && (vertexMassStrideBytes < sizeof(NxReal))) + return false; + if(vertexFlags && (vertexFlagStrideBytes < sizeof(NxU32))) + return false; + + return true; +} + +/*----------------------------------------------------------------------------*/ +/** @} */ +#endif + +//AGCOPYRIGHTBEGIN +/////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2006 AGEIA Technologies. +// All rights reserved. www.ageia.com +/////////////////////////////////////////////////////////////////////////// +//AGCOPYRIGHTEND diff --git a/libraries/external/physx/Win32/include/PX/softbody/vssver.scc b/libraries/external/physx/Win32/include/PX/softbody/vssver.scc new file mode 100755 index 0000000..5104b43 Binary files /dev/null and b/libraries/external/physx/Win32/include/PX/softbody/vssver.scc differ diff --git a/libraries/external/physx/Win32/include/PX/vssver.scc b/libraries/external/physx/Win32/include/PX/vssver.scc new file mode 100755 index 0000000..ee0dedd Binary files /dev/null and b/libraries/external/physx/Win32/include/PX/vssver.scc differ diff --git a/libraries/external/physx/Win32/lib/NxCharacter.lib b/libraries/external/physx/Win32/lib/NxCharacter.lib new file mode 100755 index 0000000..d412c49 Binary files /dev/null and b/libraries/external/physx/Win32/lib/NxCharacter.lib differ diff --git a/libraries/external/physx/Win32/lib/NxCooking.lib b/libraries/external/physx/Win32/lib/NxCooking.lib new file mode 100755 index 0000000..cab3159 Binary files /dev/null and b/libraries/external/physx/Win32/lib/NxCooking.lib differ diff --git a/libraries/external/physx/Win32/lib/PhysXLoader.lib b/libraries/external/physx/Win32/lib/PhysXLoader.lib new file mode 100755 index 0000000..77206bf Binary files /dev/null and b/libraries/external/physx/Win32/lib/PhysXLoader.lib differ diff --git a/libraries/external/physx/Win32/lib/vssver.scc b/libraries/external/physx/Win32/lib/vssver.scc new file mode 100755 index 0000000..afe8223 Binary files /dev/null and b/libraries/external/physx/Win32/lib/vssver.scc differ diff --git a/libraries/external/physx/vssver.scc b/libraries/external/physx/vssver.scc new file mode 100755 index 0000000..73b1d80 Binary files /dev/null and b/libraries/external/physx/vssver.scc differ diff --git a/libraries/external/rockey/Driver-Rockey4-1.4.0-ubuntu5.10.x86.tar.gz b/libraries/external/rockey/Driver-Rockey4-1.4.0-ubuntu5.10.x86.tar.gz new file mode 100755 index 0000000..5be6f54 --- /dev/null +++ b/libraries/external/rockey/Driver-Rockey4-1.4.0-ubuntu5.10.x86.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b0a1aa0a0735c9a5a0585ae80350787b50440dd5b48e0d19c5ce11c11d32451b +size 605804 diff --git a/libraries/external/rockey/Driver-Rockey4-linux-2.6.24.2.tar.gz b/libraries/external/rockey/Driver-Rockey4-linux-2.6.24.2.tar.gz new file mode 100755 index 0000000..8c8a73f --- /dev/null +++ b/libraries/external/rockey/Driver-Rockey4-linux-2.6.24.2.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe87498a7256fc7ce6bd0077b7d31e7c9895beced889bfe6c07f9a3d508e0d75 +size 547855 diff --git a/libraries/external/rockey/makefile b/libraries/external/rockey/makefile new file mode 100755 index 0000000..5d5d572 --- /dev/null +++ b/libraries/external/rockey/makefile @@ -0,0 +1,27 @@ +# Makefile rockey + +# Right now this makefile only copies an existing library and header file into \g3\lib +# If we ever compile the library ourselves it this would be the makefile +# MTM 19JAN07 + +TARGETLIB = librockeyapi.a +LINUX24DIR = rockey_linux-2.6.12 +LINUX26DIR = rockey_linux-2.6.20 +LINUX2624DIR = rockey_linux-2.6.24.2 + +all: linux2.6.20 +#all: linux2.6.24.2 + +linux2.6.12: $(LINUX24DIR)/$(TARGETLIB) $(LINUX24DIR)/rockey.h makefile + cp $(LINUX24DIR)/$(TARGETLIB) /g3/lib + cp $(LINUX24DIR)/rockey.h /g3/include + +linux2.6.20: $(LINUX26DIR)/$(TARGETLIB) $(LINUX26DIR)/rockey.h makefile + cp $(LINUX26DIR)/$(TARGETLIB) /g3/lib + cp $(LINUX26DIR)/rockey.h /g3/include + +linux2.6.24.2: $(LINUX2624DIR)/$(TARGETLIB) $(LINUX2624DIR)/rockey.h makefile + cp $(LINUX2624DIR)/$(TARGETLIB) /g3/lib + cp $(LINUX2624DIR)/rockey.h /g3/include + + diff --git a/libraries/external/rockey/mssccprj.scc b/libraries/external/rockey/mssccprj.scc new file mode 100755 index 0000000..9194d59 --- /dev/null +++ b/libraries/external/rockey/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[rockey.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/external/rockey", NTOAAAAA diff --git a/libraries/external/rockey/readme.txt b/libraries/external/rockey/readme.txt new file mode 100755 index 0000000..f5d724c --- /dev/null +++ b/libraries/external/rockey/readme.txt @@ -0,0 +1,6 @@ +Right now, this workspace/project only copies rockey.h into c:\g3\lib +If we ever rebuild librockeyapi.lib, this would be the place. + +//the copy is under Project:Settings:Custom Build + +MTM 19JAN07 \ No newline at end of file diff --git a/libraries/external/rockey/rockey.dsp b/libraries/external/rockey/rockey.dsp new file mode 100755 index 0000000..90ec145 --- /dev/null +++ b/libraries/external/rockey/rockey.dsp @@ -0,0 +1,104 @@ +# Microsoft Developer Studio Project File - Name="rockey" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=rockey - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "rockey.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "rockey.mak" CFG="rockey - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "rockey - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "rockey - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "rockey - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "rockey - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Custom Build +InputPath=.\Debug\rockey.lib +SOURCE="$(InputPath)" + +"output.txt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy rockey.h c:\g3\lib + +# End Custom Build + +!ENDIF + +# Begin Target + +# Name "rockey - Win32 Release" +# Name "rockey - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Source File + +SOURCE=.\readme.txt +# End Source File +# End Target +# End Project diff --git a/libraries/external/rockey/rockey.dsw b/libraries/external/rockey/rockey.dsw new file mode 100755 index 0000000..c4537cc --- /dev/null +++ b/libraries/external/rockey/rockey.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "rockey"=.\rockey.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/external/rockey/rockey_linux-2.6.12/librockeyapi.a b/libraries/external/rockey/rockey_linux-2.6.12/librockeyapi.a new file mode 100755 index 0000000..7c6ae62 Binary files /dev/null and b/libraries/external/rockey/rockey_linux-2.6.12/librockeyapi.a differ diff --git a/libraries/external/rockey/rockey_linux-2.6.12/rockey.h b/libraries/external/rockey/rockey_linux-2.6.12/rockey.h new file mode 100755 index 0000000..45489ed --- /dev/null +++ b/libraries/external/rockey/rockey_linux-2.6.12/rockey.h @@ -0,0 +1,59 @@ +#ifndef __ROCKEY__H +#define __ROCKEY__H +#define RY_FIND 1 +#define RY_FIND_NEXT 2 +#define RY_OPEN 3 +#define RY_CLOSE 4 +#define RY_READ 5 +#define RY_WRITE 6 +#define RY_RANDOM 7 +#define RY_SEED 8 +#define RY_WRITE_USERID 9 +#define RY_READ_USERID 10 +#define RY_SET_MODULE 11 +#define RY_CHECK_MODULE 12 +#define RY_WRITE_ARITHMETIC 13 +#define RY_CALCULATE1 14 +#define RY_CALCULATE2 15 +#define RY_CALCULATE3 16 +#define RY_DECREASE 17 + +/*return code*/ +#define ERR_SUCCESS 0 +#define ERR_NO_PARALLEL_PORT 1 +#define ERR_NO_DRIVER -1 +#define ERR_NO_ROCKEY 3 +#define ERR_INVALID_PASSWORD 4 +#define ERR_INVALID_PASSWORD_OR_ID 5 +#define ERR_SETID 6 +#define ERR_INVALID_ADDR_OR_SIZE 7 +#define ERR_UNKNOWN_COMMAND 8 +#define ERR_NOTBELEVEL3 9 +#define ERR_READ 10 +#define ERR_WRITE 11 +#define ERR_RANDOM 12 +#define ERR_SEED 13 +#define ERR_CALCULATE 14 +#define ERR_NO_OPEN 15 +#define ERR_NOMORE 17 +#define ERR_NEED_FIND 18 +#define ERR_DECREASE 19 +#define ERR_AR_BADCOMMAND 20 +#define ERR_AR_UNKNOWN_OPCODE 21 +#define ERR_AR_WRONGBEGIN 22 +#define ERR_AR_WRONG_END 23 +#define ERR_AR_VALUEOVERFLOW 24 +#define ERR_UNKNOWN 0xffff +#define ERR_RECEIVE_NULL 0x100 +#define ERR_PRNPORT_BUSY 0x101 + +#ifdef __cplusplus +extern "C" { +#endif + +short rockey(short function,short *handle,long *lp1,long *lp2,short *p1,short *p2,short *p3,short *p4,unsigned char *buffer); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/rockey/rockey_linux-2.6.12/vssver.scc b/libraries/external/rockey/rockey_linux-2.6.12/vssver.scc new file mode 100755 index 0000000..fb21908 Binary files /dev/null and b/libraries/external/rockey/rockey_linux-2.6.12/vssver.scc differ diff --git a/libraries/external/rockey/rockey_linux-2.6.20/librockeyapi.a b/libraries/external/rockey/rockey_linux-2.6.20/librockeyapi.a new file mode 100755 index 0000000..f2afd84 Binary files /dev/null and b/libraries/external/rockey/rockey_linux-2.6.20/librockeyapi.a differ diff --git a/libraries/external/rockey/rockey_linux-2.6.20/rockey.h b/libraries/external/rockey/rockey_linux-2.6.20/rockey.h new file mode 100755 index 0000000..ab80356 --- /dev/null +++ b/libraries/external/rockey/rockey_linux-2.6.20/rockey.h @@ -0,0 +1,59 @@ +#ifndef __ROCKEY__H +#define __ROCKEY__H +#define RY_FIND 1 +#define RY_FIND_NEXT 2 +#define RY_OPEN 3 +#define RY_CLOSE 4 +#define RY_READ 5 +#define RY_WRITE 6 +#define RY_RANDOM 7 +#define RY_SEED 8 +#define RY_WRITE_USERID 9 +#define RY_READ_USERID 10 +#define RY_SET_MODULE 11 +#define RY_CHECK_MODULE 12 +#define RY_WRITE_ARITHMETIC 13 +#define RY_CALCULATE1 14 +#define RY_CALCULATE2 15 +#define RY_CALCULATE3 16 +#define RY_DECREASE 17 + +/*return code*/ +#define ERR_SUCCESS 0 +#define ERR_NO_PARALLEL_PORT 1 +#define ERR_NO_DRIVER -1 +#define ERR_NO_ROCKEY 3 +#define ERR_INVALID_PASSWORD 4 +#define ERR_INVALID_PASSWORD_OR_ID 5 +#define ERR_SETID 6 +#define ERR_INVALID_ADDR_OR_SIZE 7 +#define ERR_UNKNOWN_COMMAND 8 +#define ERR_NOTBELEVEL3 9 +#define ERR_READ 10 +#define ERR_WRITE 11 +#define ERR_RANDOM 12 +#define ERR_SEED 13 +#define ERR_CALCULATE 14 +#define ERR_NO_OPEN 15 +#define ERR_NOMORE 17 +#define ERR_NEED_FIND 18 +#define ERR_DECREASE 19 +#define ERR_AR_BADCOMMAND 20 +#define ERR_AR_UNKNOWN_OPCODE 21 +#define ERR_AR_WRONGBEGIN 22 +#define ERR_AR_WRONG_END 23 +#define ERR_AR_VALUEOVERFLOW 24 +#define ERR_UNKNOWN 0xffff +#define ERR_RECEIVE_NULL 0x100 +#define ERR_PRNPORT_BUSY 0x101 + +#ifdef __cplusplus +extern "C" { +#endif + +short rockey(unsigned short function,unsigned short *handle,unsigned long *lp1,unsigned long *lp2,unsigned short *p1,unsigned short *p2,unsigned short *p3,unsigned short *p4,unsigned char *buffer); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/rockey/rockey_linux-2.6.20/vssver.scc b/libraries/external/rockey/rockey_linux-2.6.20/vssver.scc new file mode 100755 index 0000000..2b7373c Binary files /dev/null and b/libraries/external/rockey/rockey_linux-2.6.20/vssver.scc differ diff --git a/libraries/external/rockey/rockey_linux-2.6.24.2/librockeyapi.a b/libraries/external/rockey/rockey_linux-2.6.24.2/librockeyapi.a new file mode 100755 index 0000000..7c6ae62 Binary files /dev/null and b/libraries/external/rockey/rockey_linux-2.6.24.2/librockeyapi.a differ diff --git a/libraries/external/rockey/rockey_linux-2.6.24.2/rockey.h b/libraries/external/rockey/rockey_linux-2.6.24.2/rockey.h new file mode 100755 index 0000000..45489ed --- /dev/null +++ b/libraries/external/rockey/rockey_linux-2.6.24.2/rockey.h @@ -0,0 +1,59 @@ +#ifndef __ROCKEY__H +#define __ROCKEY__H +#define RY_FIND 1 +#define RY_FIND_NEXT 2 +#define RY_OPEN 3 +#define RY_CLOSE 4 +#define RY_READ 5 +#define RY_WRITE 6 +#define RY_RANDOM 7 +#define RY_SEED 8 +#define RY_WRITE_USERID 9 +#define RY_READ_USERID 10 +#define RY_SET_MODULE 11 +#define RY_CHECK_MODULE 12 +#define RY_WRITE_ARITHMETIC 13 +#define RY_CALCULATE1 14 +#define RY_CALCULATE2 15 +#define RY_CALCULATE3 16 +#define RY_DECREASE 17 + +/*return code*/ +#define ERR_SUCCESS 0 +#define ERR_NO_PARALLEL_PORT 1 +#define ERR_NO_DRIVER -1 +#define ERR_NO_ROCKEY 3 +#define ERR_INVALID_PASSWORD 4 +#define ERR_INVALID_PASSWORD_OR_ID 5 +#define ERR_SETID 6 +#define ERR_INVALID_ADDR_OR_SIZE 7 +#define ERR_UNKNOWN_COMMAND 8 +#define ERR_NOTBELEVEL3 9 +#define ERR_READ 10 +#define ERR_WRITE 11 +#define ERR_RANDOM 12 +#define ERR_SEED 13 +#define ERR_CALCULATE 14 +#define ERR_NO_OPEN 15 +#define ERR_NOMORE 17 +#define ERR_NEED_FIND 18 +#define ERR_DECREASE 19 +#define ERR_AR_BADCOMMAND 20 +#define ERR_AR_UNKNOWN_OPCODE 21 +#define ERR_AR_WRONGBEGIN 22 +#define ERR_AR_WRONG_END 23 +#define ERR_AR_VALUEOVERFLOW 24 +#define ERR_UNKNOWN 0xffff +#define ERR_RECEIVE_NULL 0x100 +#define ERR_PRNPORT_BUSY 0x101 + +#ifdef __cplusplus +extern "C" { +#endif + +short rockey(short function,short *handle,long *lp1,long *lp2,short *p1,short *p2,short *p3,short *p4,unsigned char *buffer); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libraries/external/rockey/rockey_linux-2.6.24.2/vssver.scc b/libraries/external/rockey/rockey_linux-2.6.24.2/vssver.scc new file mode 100755 index 0000000..8ec3164 Binary files /dev/null and b/libraries/external/rockey/rockey_linux-2.6.24.2/vssver.scc differ diff --git a/libraries/external/rockey/vssver.scc b/libraries/external/rockey/vssver.scc new file mode 100755 index 0000000..4de371b Binary files /dev/null and b/libraries/external/rockey/vssver.scc differ diff --git a/libraries/external/xiph/include/ogg/config_types.h b/libraries/external/xiph/include/ogg/config_types.h new file mode 100755 index 0000000..880914e --- /dev/null +++ b/libraries/external/xiph/include/ogg/config_types.h @@ -0,0 +1,11 @@ +#ifndef __CONFIG_TYPES_H__ +#define __CONFIG_TYPES_H__ + +/* these are filled in by configure */ +typedef int16_t ogg_int16_t; +typedef u_int16_t ogg_uint16_t; +typedef int32_t ogg_int32_t; +typedef u_int32_t ogg_uint32_t; +typedef int64_t ogg_int64_t; + +#endif diff --git a/libraries/external/xiph/include/ogg/ogg.h b/libraries/external/xiph/include/ogg/ogg.h new file mode 100755 index 0000000..a3040dc --- /dev/null +++ b/libraries/external/xiph/include/ogg/ogg.h @@ -0,0 +1,202 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: toplevel libogg include + last mod: $Id: ogg.h 7188 2004-07-20 07:26:04Z xiphmont $ + + ********************************************************************/ +#ifndef _OGG_H +#define _OGG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct { + long endbyte; + int endbit; + + unsigned char *buffer; + unsigned char *ptr; + long storage; +} oggpack_buffer; + +/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ + +typedef struct { + unsigned char *header; + long header_len; + unsigned char *body; + long body_len; +} ogg_page; + +/* ogg_stream_state contains the current encode/decode state of a logical + Ogg bitstream **********************************************************/ + +typedef struct { + unsigned char *body_data; /* bytes from packet bodies */ + long body_storage; /* storage elements allocated */ + long body_fill; /* elements stored; fill mark */ + long body_returned; /* elements of fill returned */ + + + int *lacing_vals; /* The values that will go to the segment table */ + ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact + this way, but it is simple coupled to the + lacing fifo */ + long lacing_storage; + long lacing_fill; + long lacing_packet; + long lacing_returned; + + unsigned char header[282]; /* working space for header encode */ + int header_fill; + + int e_o_s; /* set when we have buffered the last packet in the + logical bitstream */ + int b_o_s; /* set after we've written the initial page + of a logical bitstream */ + long serialno; + long pageno; + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ + ogg_int64_t granulepos; + +} ogg_stream_state; + +/* ogg_packet is used to encapsulate the data and metadata belonging + to a single raw Ogg/Vorbis packet *************************************/ + +typedef struct { + unsigned char *packet; + long bytes; + long b_o_s; + long e_o_s; + + ogg_int64_t granulepos; + + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ +} ogg_packet; + +typedef struct { + unsigned char *data; + int storage; + int fill; + int returned; + + int unsynced; + int headerbytes; + int bodybytes; +} ogg_sync_state; + +/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ + +extern void oggpack_writeinit(oggpack_buffer *b); +extern void oggpack_writetrunc(oggpack_buffer *b,long bits); +extern void oggpack_writealign(oggpack_buffer *b); +extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpack_reset(oggpack_buffer *b); +extern void oggpack_writeclear(oggpack_buffer *b); +extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpack_look(oggpack_buffer *b,int bits); +extern long oggpack_look1(oggpack_buffer *b); +extern void oggpack_adv(oggpack_buffer *b,int bits); +extern void oggpack_adv1(oggpack_buffer *b); +extern long oggpack_read(oggpack_buffer *b,int bits); +extern long oggpack_read1(oggpack_buffer *b); +extern long oggpack_bytes(oggpack_buffer *b); +extern long oggpack_bits(oggpack_buffer *b); +extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); + +extern void oggpackB_writeinit(oggpack_buffer *b); +extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); +extern void oggpackB_writealign(oggpack_buffer *b); +extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpackB_reset(oggpack_buffer *b); +extern void oggpackB_writeclear(oggpack_buffer *b); +extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpackB_look(oggpack_buffer *b,int bits); +extern long oggpackB_look1(oggpack_buffer *b); +extern void oggpackB_adv(oggpack_buffer *b,int bits); +extern void oggpackB_adv1(oggpack_buffer *b); +extern long oggpackB_read(oggpack_buffer *b,int bits); +extern long oggpackB_read1(oggpack_buffer *b); +extern long oggpackB_bytes(oggpack_buffer *b); +extern long oggpackB_bits(oggpack_buffer *b); +extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); + +/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ + +extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); +extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); +extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); + +/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ + +extern int ogg_sync_init(ogg_sync_state *oy); +extern int ogg_sync_clear(ogg_sync_state *oy); +extern int ogg_sync_reset(ogg_sync_state *oy); +extern int ogg_sync_destroy(ogg_sync_state *oy); + +extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); +extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); +extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); +extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); +extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); +extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); +extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); + +/* Ogg BITSTREAM PRIMITIVES: general ***************************/ + +extern int ogg_stream_init(ogg_stream_state *os,int serialno); +extern int ogg_stream_clear(ogg_stream_state *os); +extern int ogg_stream_reset(ogg_stream_state *os); +extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); +extern int ogg_stream_destroy(ogg_stream_state *os); +extern int ogg_stream_eos(ogg_stream_state *os); + +extern void ogg_page_checksum_set(ogg_page *og); + +extern int ogg_page_version(ogg_page *og); +extern int ogg_page_continued(ogg_page *og); +extern int ogg_page_bos(ogg_page *og); +extern int ogg_page_eos(ogg_page *og); +extern ogg_int64_t ogg_page_granulepos(ogg_page *og); +extern int ogg_page_serialno(ogg_page *og); +extern long ogg_page_pageno(ogg_page *og); +extern int ogg_page_packets(ogg_page *og); + +extern void ogg_packet_clear(ogg_packet *op); + + +#ifdef __cplusplus +} +#endif + +#endif /* _OGG_H */ + + + + + + diff --git a/libraries/external/xiph/include/ogg/os_types.h b/libraries/external/xiph/include/ogg/os_types.h new file mode 100755 index 0000000..0aeae34 --- /dev/null +++ b/libraries/external/xiph/include/ogg/os_types.h @@ -0,0 +1,127 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $ + + ********************************************************************/ +#ifndef _OS_TYPES_H +#define _OS_TYPES_H + +/* make it easy on the folks that want to compile the libs with a + different malloc than stdlib */ +#define _ogg_malloc malloc +#define _ogg_calloc calloc +#define _ogg_realloc realloc +#define _ogg_free free + +#if defined(_WIN32) + +# if defined(__CYGWIN__) +# include <_G_config.h> + typedef _G_int64_t ogg_int64_t; + typedef _G_int32_t ogg_int32_t; + typedef _G_uint32_t ogg_uint32_t; + typedef _G_int16_t ogg_int16_t; + typedef _G_uint16_t ogg_uint16_t; +# elif defined(__MINGW32__) + typedef short ogg_int16_t; + typedef unsigned short ogg_uint16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + typedef unsigned long long ogg_uint64_t; +# elif defined(__MWERKS__) + typedef long long ogg_int64_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef short ogg_int16_t; + typedef unsigned short ogg_uint16_t; +# else + /* MSVC/Borland */ + typedef __int64 ogg_int64_t; + typedef __int32 ogg_int32_t; + typedef unsigned __int32 ogg_uint32_t; + typedef __int16 ogg_int16_t; + typedef unsigned __int16 ogg_uint16_t; +# endif + +#elif defined(__MACOS__) + +# include + typedef SInt16 ogg_int16_t; + typedef UInt16 ogg_uint16_t; + typedef SInt32 ogg_int32_t; + typedef UInt32 ogg_uint32_t; + typedef SInt64 ogg_int64_t; + +#elif defined(__MACOSX__) /* MacOS X Framework build */ + +# include + typedef int16_t ogg_int16_t; + typedef u_int16_t ogg_uint16_t; + typedef int32_t ogg_int32_t; + typedef u_int32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + +#elif defined(__BEOS__) + + /* Be */ +# include + typedef int16_t ogg_int16_t; + typedef u_int16_t ogg_uint16_t; + typedef int32_t ogg_int32_t; + typedef u_int32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef short ogg_int16_t; + typedef unsigned short ogg_uint16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + +#elif defined (DJGPP) + + /* DJGPP */ + typedef short ogg_int16_t; + typedef int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long ogg_int64_t; + +#elif defined(R5900) + + /* PS2 EE */ + typedef long ogg_int64_t; + typedef int ogg_int32_t; + typedef unsigned ogg_uint32_t; + typedef short ogg_int16_t; + +#elif defined(__SYMBIAN32__) + + /* Symbian GCC */ + typedef signed short ogg_int16_t; + typedef unsigned short ogg_uint16_t; + typedef signed int ogg_int32_t; + typedef unsigned int ogg_uint32_t; + typedef long long int ogg_int64_t; + +#else + +# include +# include + +#endif + +#endif /* _OS_TYPES_H */ diff --git a/libraries/external/xiph/include/ogg/vssver.scc b/libraries/external/xiph/include/ogg/vssver.scc new file mode 100755 index 0000000..8eeac4f Binary files /dev/null and b/libraries/external/xiph/include/ogg/vssver.scc differ diff --git a/libraries/external/xiph/include/theora/theora.h b/libraries/external/xiph/include/theora/theora.h new file mode 100755 index 0000000..20849db --- /dev/null +++ b/libraries/external/xiph/include/theora/theora.h @@ -0,0 +1,474 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: + last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $ + + ********************************************************************/ + +#ifndef _O_THEORA_H_ +#define _O_THEORA_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifndef LIBOGG2 +#include +#else +#include +/* This is temporary until libogg2 is more complete */ +ogg_buffer_state *ogg_buffer_create(void); +#endif + +/** \mainpage + * + * \section intro Introduction + * + * This is the documentation for the libtheora C API. + * libtheora is the reference implementation for + * Theora, a free video codec. + * Theora is derived from On2's VP3 codec with improved integration for + * Ogg multimedia formats by Xiph.Org. + */ + +/** \file + * The libtheora C API. + */ + +/** + * A YUV buffer for passing uncompressed frames to and from the codec. + * This holds a Y'CbCr frame in planar format. The CbCr planes can be + * subsampled and have their own separate dimensions and row stride + * offsets. Note that the strides may be negative in some + * configurations. For theora the width and height of the largest plane + * must be a multiple of 16. The actual meaningful picture size and + * offset are stored in the theora_info structure; frames returned by + * the decoder may need to be cropped for display. + * All samples are 8 bits. + */ +typedef struct { + int y_width; /**< width of the Y' luminance plane */ + int y_height; /**< height of the luminance plane */ + int y_stride; /**< offset in bytes between successive rows */ + + int uv_width; /**< height of the Cb and Cr chroma planes */ + int uv_height; /**< width of the chroma planes */ + int uv_stride; /**< offset between successive chroma rows */ + unsigned char *y; /**< pointer to start of luminance data */ + unsigned char *u; /**< pointer to start of Cb data */ + unsigned char *v; /**< pointer to start of Cr data */ + +} yuv_buffer; + +/** + * A Colorspace. + */ +typedef enum { + OC_CS_UNSPECIFIED, /**< the colorspace is unknown or unspecified */ + OC_CS_ITU_REC_470M, /**< best option for 'NTSC' content */ + OC_CS_ITU_REC_470BG, /**< best option for 'PAL' content */ + OC_CS_NSPACES /* mark the end of the defined colorspaces */ +} theora_colorspace; + +/** + * A Chroma subsampling + * + * These enumerate the available chroma subsampling options supported + * by the theora format. See Section 4.4 of the specification for + * exact definitions. + */ +typedef enum { + OC_PF_420, /**< Chroma subsampling by 2 in each direction (4:2:0) */ + OC_PF_RSVD, /**< reserved value */ + OC_PF_422, /**< Horizonatal chroma subsampling by 2 (4:2:2) */ + OC_PF_444, /**< No chroma subsampling at all (4:4:4) */ +} theora_pixelformat; + +/** + * Theora bitstream info. + * Contains the basic playback parameters for a stream, + * corresponds to the initial 'info' header packet. + * + * Encoded theora frames must be a multiple of 16 is size; + * this is what the width and height members represent. To + * handle other sizes, a crop rectangle is specified in + * frame_height and frame_width, offset_x and offset_y. The + * offset and size should still be a power of 2 to avoid + * chroma sampling shifts. + * + * Frame rate, in frames per second is stored as a rational + * fraction. So is the aspect ratio. Note that this refers + * to the aspect ratio of the frame pixels, not of the + * overall frame itself. + * + * see the example code for use of the other parameters and + * good default settings for the encoder parameters. + */ +typedef struct { + ogg_uint32_t width; + ogg_uint32_t height; + ogg_uint32_t frame_width; + ogg_uint32_t frame_height; + ogg_uint32_t offset_x; + ogg_uint32_t offset_y; + ogg_uint32_t fps_numerator; + ogg_uint32_t fps_denominator; + ogg_uint32_t aspect_numerator; + ogg_uint32_t aspect_denominator; + theora_colorspace colorspace; + int target_bitrate; + int quality; /**< nominal quality setting, 0-63 */ + int quick_p; /**< quick encode/decode */ + + /* decode only */ + unsigned char version_major; + unsigned char version_minor; + unsigned char version_subminor; + + void *codec_setup; + + /* encode only */ + int dropframes_p; + int keyframe_auto_p; + ogg_uint32_t keyframe_frequency; + ogg_uint32_t keyframe_frequency_force; /* also used for decode init to + get granpos shift correct */ + ogg_uint32_t keyframe_data_target_bitrate; + ogg_int32_t keyframe_auto_threshold; + ogg_uint32_t keyframe_mindistance; + ogg_int32_t noise_sensitivity; + ogg_int32_t sharpness; + + theora_pixelformat pixelformat; + +} theora_info; + +/** Codec internal state and context. + */ +typedef struct{ + theora_info *i; + ogg_int64_t granulepos; + + void *internal_encode; + void *internal_decode; + +} theora_state; + +/** + * Comment header metadata. + * + * This structure holds the in-stream metadata corresponding to + * the 'comment' header packet. + * + * Meta data is stored as a series of (tag, value) pairs, in + * length-encoded string vectors. The first occurence of the + * '=' character delimits the tag and value. A particular tag + * may occur more than once. The character set encoding for + * the strings is always utf-8, but the tag names are limited + * to case-insensitive ascii. See the spec for details. + * + * In filling in this structure, theora_decode_header() will + * null-terminate the user_comment strings for safety. However, + * the bitstream format itself treats them as 8-bit clean, + * and so the length array should be treated as authoritative + * for their length. + */ +typedef struct theora_comment{ + char **user_comments; /**< an array of comment string vectors */ + int *comment_lengths; /**< an array of corresponding string vector lengths in bytes */ + int comments; /**< the total number of comment string vectors */ + char *vendor; /**< the vendor string identifying the encoder, null terminated */ + +} theora_comment; + +#define OC_FAULT -1 /**< general failure */ +#define OC_EINVAL -10 /**< library encountered invalid internal data */ +#define OC_DISABLED -11 /**< requested action is disabled */ +#define OC_BADHEADER -20 /**< header packet was corrupt/invalid */ +#define OC_NOTFORMAT -21 /**< packet is not a theora packet */ +#define OC_VERSION -22 /**< bitstream version is not handled */ +#define OC_IMPL -23 /**< feature or action not implemented */ +#define OC_BADPACKET -24 /**< packet is corrupt */ +#define OC_NEWPACKET -25 /**< packet is an (ignorable) unhandled extension */ + +/** + * Retrieve a human-readable string to identify the encoder vendor and version. + * \returns a version string. + */ +extern const char *theora_version_string(void); + +/** + * Retrieve a 32-bit version number. + * This number is composed of a 16-bit major version, 8-bit minor version + * and 8 bit sub-version, composed as follows: +
+   (VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)
+
+* \returns the version number. +*/ +extern ogg_uint32_t theora_version_number(void); + +/** + * Initialize the theora encoder. + * \param th The theora_state handle to initialize for encoding. + * \param ti A theora_info struct filled with the desired encoding parameters. + * \returns 0 Success + */ +extern int theora_encode_init(theora_state *th, theora_info *c); + +/** + * Submit a YUV buffer to the theora encoder. + * \param t A theora_state handle previously initialized for encoding. + * \param yuv A buffer of YUV data to encode. + * \retval OC_EINVAL Encoder is not ready, or is finished. + * \retval -1 The size of the given frame differs from those previously input + * \retval 0 Success + */ +extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv); + +/** + * Request the next packet of encoded video. + * The encoded data is placed in a user-provided ogg_packet structure. + * \param t A theora_state handle previously initialized for encoding. + * \param last_p whether this is the last packet the encoder should produce. + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to encoded + * data. The memory for the encoded data is owned by libtheora. + * \retval 0 No internal storage exists OR no packet is ready + * \retval -1 The encoding process has completed + * \retval 1 Success + */ +extern int theora_encode_packetout( theora_state *t, int last_p, + ogg_packet *op); + +/** + * Request a packet containing the initial header. + * A pointer to the header data is placed in a user-provided ogg_packet + * structure. + * \param t A theora_state handle previously initialized for encoding. + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to the header + * data. The memory for the header data is owned by libtheora. + * \retval 0 Success + */ +extern int theora_encode_header(theora_state *t, ogg_packet *op); + +/** + * Request a comment header packet from provided metadata. + * A pointer to the comment data is placed in a user-provided ogg_packet + * structure. + * \param tc A theora_comment structure filled with the desired metadata + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to the encoded + * comment data. The memory for the comment data is owned by + * libtheora. + * \retval 0 Success + */ +extern int theora_encode_comment(theora_comment *tc, ogg_packet *op); + +/** + * Request a packet containing the codebook tables for the stream. + * A pointer to the codebook data is placed in a user-provided ogg_packet + * structure. + * \param t A theora_state handle previously initialized for encoding. + * \param op An ogg_packet structure to fill. libtheora will set all + * elements of this structure, including a pointer to the codebook + * data. The memory for the header data is owned by libtheora. + * \retval 0 Success + */ +extern int theora_encode_tables(theora_state *t, ogg_packet *op); + +/** + * Decode an Ogg packet, with the expectation that the packet contains + * an initial header, comment data or codebook tables. + * + * \param ci A theora_info structure to fill. This must have been previously + * initialized with theora_info_init(). If \a op contains an initial + * header, theora_decode_header() will fill \a ci with the + * parsed header values. If \a op contains codebook tables, + * theora_decode_header() will parse these and attach an internal + * representation to \a ci->codec_setup. + * \param cc A theora_comment structure to fill. If \a op contains comment + * data, theora_decode_header() will fill \a cc with the parsed + * comments. + * \param op An ogg_packet structure which you expect contains an initial + * header, comment data or codebook tables. + * + * \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet + * has the signature of an initial packet, but op is + * not a b_o_s packet; OR this packet has the signature + * of an initial header packet, but an initial header + * packet has already been seen; OR this packet has the + * signature of a comment packet, but the initial header + * has not yet been seen; OR this packet has the signature + * of a comment packet, but contains invalid data; OR + * this packet has the signature of codebook tables, + * but the initial header or comments have not yet + * been seen; OR this packet has the signature of codebook + * tables, but contains invalid data; + * OR the stream being decoded has a compatible version + * but this packet does not have the signature of a + * theora initial header, comments, or codebook packet + * \retval OC_VERSION The packet data of \a op is an initial header with + * a version which is incompatible with this version of + * libtheora. + * \retval OC_NEWPACKET the stream being decoded has an incompatible (future) + * version and contains an unknown signature. + * \retval 0 Success + * + * \note The normal usage is that theora_decode_header() be called on the + * first three packets of a theora logical bitstream in succession. + */ +extern int theora_decode_header(theora_info *ci, theora_comment *cc, + ogg_packet *op); + +/** + * Initialize a theora_state handle for decoding. + * \param th The theora_state handle to initialize. + * \param c A theora_info struct filled with the desired decoding parameters. + * This is of course usually obtained from a previous call to + * theora_decode_header(). + * \returns 0 Success + */ +extern int theora_decode_init(theora_state *th, theora_info *c); + +/** + * Input a packet containing encoded data into the theora decoder. + * \param th A theora_state handle previously initialized for decoding. + * \param op An ogg_packet containing encoded theora data. + * \retval OC_BADPACKET \a op does not contain encoded video data + */ +extern int theora_decode_packetin(theora_state *th,ogg_packet *op); + +/** + * Output the next available frame of decoded YUV data. + * \param th A theora_state handle previously initialized for decoding. + * \param yuv A yuv_buffer in which libtheora should place the decoded data. + * \retval 0 Success + */ +extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv); + +/** + * Report whether a theora packet is a header or not + * This function does no verification beyond checking the header + * flag bit so it should not be used for bitstream identification; + * use theora_decode_header() for that. + * + * \param op An ogg_packet containing encoded theora data. + * \retval 1 The packet is a header packet + * \retval 0 The packet is not a header packet (and so contains frame data) + * + * Thus function was added in the 1.0alpha4 release. + */ +extern int theora_packet_isheader(ogg_packet *op); + +/** + * Report whether a theora packet is a keyframe or not + * + * \param op An ogg_packet containing encoded theora data. + * \retval 1 The packet contains a keyframe image + * \retval 0 The packet is contains an interframe delta + * \retval -1 the packet is not an image data packet at all + * + * Thus function was added in the 1.0alpha4 release. + */ +extern int theora_packet_iskeyframe(ogg_packet *op); + +/** + * Convert a granulepos to an absolute frame number. The granulepos is + * interpreted in the context of a given theora_state handle. + * + * \param th A previously initialized theora_state handle (encode or decode) + * \param granulepos The granulepos to convert. + * \returns The frame number corresponding to \a granulepos. + * \retval -1 The given granulepos is invalid (ie. negative) + * + * Thus function was added in the 1.0alpha4 release. + */ +extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos); + +/** + * Convert a granulepos to absolute time in seconds. The granulepos is + * interpreted in the context of a given theora_state handle. + * \param th A previously initialized theora_state handle (encode or decode) + * \param granulepos The granulepos to convert. + * \returns The absolute time in seconds corresponding to \a granulepos. + * \retval -1 The given granulepos is invalid (ie. negative) + */ +extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos); + +/** + * Initialize a theora_info structure. All values within the given theora_info + * structure are initialized, and space is allocated within libtheora for + * internal codec setup data. + * \param c A theora_info struct to initialize. + */ +extern void theora_info_init(theora_info *c); + +/** + * Clear a theora_info structure. All values within the given theora_info + * structure are cleared, and associated internal codec setup data is freed. + * \param c A theora_info struct to initialize. + */ +extern void theora_info_clear(theora_info *c); + +/** + * Free all internal data associated with a theora_state handle. + * \param t A theora_state handle. + */ +extern void theora_clear(theora_state *t); + +/** Initialize an allocated theora_comment structure */ +extern void theora_comment_init(theora_comment *tc); +/** Add a comment to an initialized theora_comment structure + \param comment must be a null-terminated string encoding + the comment in "TAG=the value" form */ +extern void theora_comment_add(theora_comment *tc, char *comment); +/** Add a comment to an initialized theora_comment structure + \param tag a null-terminated string containing the tag + associated with the comment. + \param value the corresponding value as a null-terminated string + Neither theora_comment_add() nor theora_comment_add_tag() support + comments containing null values, although the bitstream format + supports this. To add such comments you will need to manipulate + the theora_comment structure directly */ +extern void theora_comment_add_tag(theora_comment *tc, + char *tag, char *value); +/** look up a comment value by tag + \param tc an initialized theora_comment structure + \param tag the tag to look up + \param count the instance of the tag. The same tag can appear + multiple times, each with a distinct and ordered value, so + an index is required to retrieve them all. + Use theora_comment_query_count() to get the legal range for the + count parameter + \returns a pointer to the queried tag's value + \retval NULL if no matching tag is found */ +extern char *theora_comment_query(theora_comment *tc, char *tag, int count); +/** look up the number of instances of a tag + \param tc an initialized theora_comment structure + \param tag the tag to look up + \returns the number on instances of a particular tag. + Call this first when querying for a specific tag and then interate + over the number of instances with separate calls to + theora_comment_query() to retrieve all instances in order. */ +extern int theora_comment_query_count(theora_comment *tc, char *tag); +/** clears an allocated theora_comment struct so that it can be freed. */ +extern void theora_comment_clear(theora_comment *tc); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _O_THEORA_H_ */ diff --git a/libraries/external/xiph/include/theora/vssver.scc b/libraries/external/xiph/include/theora/vssver.scc new file mode 100755 index 0000000..12d18d6 Binary files /dev/null and b/libraries/external/xiph/include/theora/vssver.scc differ diff --git a/libraries/external/xiph/include/vorbis/codec.h b/libraries/external/xiph/include/vorbis/codec.h new file mode 100755 index 0000000..14f44b0 --- /dev/null +++ b/libraries/external/xiph/include/vorbis/codec.h @@ -0,0 +1,240 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + + ******************************************************************** + + function: libvorbis codec headers + last mod: $Id: codec.h 7485 2004-08-05 14:54:23Z thomasvs $ + + ********************************************************************/ + +#ifndef _vorbis_codec_h_ +#define _vorbis_codec_h_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include + +typedef struct vorbis_info{ + int version; + int channels; + long rate; + + /* The below bitrate declarations are *hints*. + Combinations of the three values carry the following implications: + + all three set to the same value: + implies a fixed rate bitstream + only nominal set: + implies a VBR stream that averages the nominal bitrate. No hard + upper/lower limit + upper and or lower set: + implies a VBR bitstream that obeys the bitrate limits. nominal + may also be set to give a nominal rate. + none set: + the coder does not care to speculate. + */ + + long bitrate_upper; + long bitrate_nominal; + long bitrate_lower; + long bitrate_window; + + void *codec_setup; +} vorbis_info; + +/* vorbis_dsp_state buffers the current vorbis audio + analysis/synthesis state. The DSP state belongs to a specific + logical bitstream ****************************************************/ +typedef struct vorbis_dsp_state{ + int analysisp; + vorbis_info *vi; + + float **pcm; + float **pcmret; + int pcm_storage; + int pcm_current; + int pcm_returned; + + int preextrapolate; + int eofflag; + + long lW; + long W; + long nW; + long centerW; + + ogg_int64_t granulepos; + ogg_int64_t sequence; + + ogg_int64_t glue_bits; + ogg_int64_t time_bits; + ogg_int64_t floor_bits; + ogg_int64_t res_bits; + + void *backend_state; +} vorbis_dsp_state; + +typedef struct vorbis_block{ + /* necessary stream state for linking to the framing abstraction */ + float **pcm; /* this is a pointer into local storage */ + oggpack_buffer opb; + + long lW; + long W; + long nW; + int pcmend; + int mode; + + int eofflag; + ogg_int64_t granulepos; + ogg_int64_t sequence; + vorbis_dsp_state *vd; /* For read-only access of configuration */ + + /* local storage to avoid remallocing; it's up to the mapping to + structure it */ + void *localstore; + long localtop; + long localalloc; + long totaluse; + struct alloc_chain *reap; + + /* bitmetrics for the frame */ + long glue_bits; + long time_bits; + long floor_bits; + long res_bits; + + void *internal; + +} vorbis_block; + +/* vorbis_block is a single block of data to be processed as part of +the analysis/synthesis stream; it belongs to a specific logical +bitstream, but is independant from other vorbis_blocks belonging to +that logical bitstream. *************************************************/ + +struct alloc_chain{ + void *ptr; + struct alloc_chain *next; +}; + +/* vorbis_info contains all the setup information specific to the + specific compression/decompression mode in progress (eg, + psychoacoustic settings, channel setup, options, codebook + etc). vorbis_info and substructures are in backends.h. +*********************************************************************/ + +/* the comments are not part of vorbis_info so that vorbis_info can be + static storage */ +typedef struct vorbis_comment{ + /* unlimited user comment fields. libvorbis writes 'libvorbis' + whatever vendor is set to in encode */ + char **user_comments; + int *comment_lengths; + int comments; + char *vendor; + +} vorbis_comment; + + +/* libvorbis encodes in two abstraction layers; first we perform DSP + and produce a packet (see docs/analysis.txt). The packet is then + coded into a framed OggSquish bitstream by the second layer (see + docs/framing.txt). Decode is the reverse process; we sync/frame + the bitstream and extract individual packets, then decode the + packet back into PCM audio. + + The extra framing/packetizing is used in streaming formats, such as + files. Over the net (such as with UDP), the framing and + packetization aren't necessary as they're provided by the transport + and the streaming layer is not used */ + +/* Vorbis PRIMITIVES: general ***************************************/ + +extern void vorbis_info_init(vorbis_info *vi); +extern void vorbis_info_clear(vorbis_info *vi); +extern int vorbis_info_blocksize(vorbis_info *vi,int zo); +extern void vorbis_comment_init(vorbis_comment *vc); +extern void vorbis_comment_add(vorbis_comment *vc, char *comment); +extern void vorbis_comment_add_tag(vorbis_comment *vc, + char *tag, char *contents); +extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); +extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); +extern void vorbis_comment_clear(vorbis_comment *vc); + +extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); +extern int vorbis_block_clear(vorbis_block *vb); +extern void vorbis_dsp_clear(vorbis_dsp_state *v); +extern double vorbis_granule_time(vorbis_dsp_state *v, + ogg_int64_t granulepos); + +/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ + +extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); +extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); +extern int vorbis_analysis_headerout(vorbis_dsp_state *v, + vorbis_comment *vc, + ogg_packet *op, + ogg_packet *op_comm, + ogg_packet *op_code); +extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); +extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); +extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); +extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); + +extern int vorbis_bitrate_addblock(vorbis_block *vb); +extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, + ogg_packet *op); + +/* Vorbis PRIMITIVES: synthesis layer *******************************/ +extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, + ogg_packet *op); + +extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); +extern int vorbis_synthesis_restart(vorbis_dsp_state *v); +extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); +extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); +extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); +extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); +extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); +extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); +extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); + +extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); +extern int vorbis_synthesis_halfrate_p(vorbis_info *v); + +/* Vorbis ERRORS and return codes ***********************************/ + +#define OV_FALSE -1 +#define OV_EOF -2 +#define OV_HOLE -3 + +#define OV_EREAD -128 +#define OV_EFAULT -129 +#define OV_EIMPL -130 +#define OV_EINVAL -131 +#define OV_ENOTVORBIS -132 +#define OV_EBADHEADER -133 +#define OV_EVERSION -134 +#define OV_ENOTAUDIO -135 +#define OV_EBADPACKET -136 +#define OV_EBADLINK -137 +#define OV_ENOSEEK -138 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/libraries/external/xiph/include/vorbis/vorbisenc.h b/libraries/external/xiph/include/vorbis/vorbisenc.h new file mode 100755 index 0000000..0c78a3b --- /dev/null +++ b/libraries/external/xiph/include/vorbis/vorbisenc.h @@ -0,0 +1,112 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: vorbis encode-engine setup + last mod: $Id: vorbisenc.h 7485 2004-08-05 14:54:23Z thomasvs $ + + ********************************************************************/ + +#ifndef _OV_ENC_H_ +#define _OV_ENC_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "codec.h" + +extern int vorbis_encode_init(vorbis_info *vi, + long channels, + long rate, + + long max_bitrate, + long nominal_bitrate, + long min_bitrate); + +extern int vorbis_encode_setup_managed(vorbis_info *vi, + long channels, + long rate, + + long max_bitrate, + long nominal_bitrate, + long min_bitrate); + +extern int vorbis_encode_setup_vbr(vorbis_info *vi, + long channels, + long rate, + + float quality /* quality level from 0. (lo) to 1. (hi) */ + ); + +extern int vorbis_encode_init_vbr(vorbis_info *vi, + long channels, + long rate, + + float base_quality /* quality level from 0. (lo) to 1. (hi) */ + ); + +extern int vorbis_encode_setup_init(vorbis_info *vi); + +extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); + + /* deprecated rate management supported only for compatability */ +#define OV_ECTL_RATEMANAGE_GET 0x10 +#define OV_ECTL_RATEMANAGE_SET 0x11 +#define OV_ECTL_RATEMANAGE_AVG 0x12 +#define OV_ECTL_RATEMANAGE_HARD 0x13 + +struct ovectl_ratemanage_arg { + int management_active; + + long bitrate_hard_min; + long bitrate_hard_max; + double bitrate_hard_window; + + long bitrate_av_lo; + long bitrate_av_hi; + double bitrate_av_window; + double bitrate_av_window_center; +}; + + + /* new rate setup */ +#define OV_ECTL_RATEMANAGE2_GET 0x14 +#define OV_ECTL_RATEMANAGE2_SET 0x15 + +struct ovectl_ratemanage2_arg { + int management_active; + + long bitrate_limit_min_kbps; + long bitrate_limit_max_kbps; + long bitrate_limit_reservoir_bits; + double bitrate_limit_reservoir_bias; + + long bitrate_average_kbps; + double bitrate_average_damping; +}; + + + +#define OV_ECTL_LOWPASS_GET 0x20 +#define OV_ECTL_LOWPASS_SET 0x21 + +#define OV_ECTL_IBLOCK_GET 0x30 +#define OV_ECTL_IBLOCK_SET 0x31 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + + diff --git a/libraries/external/xiph/include/vorbis/vorbisfile.h b/libraries/external/xiph/include/vorbis/vorbisfile.h new file mode 100755 index 0000000..6481eb4 --- /dev/null +++ b/libraries/external/xiph/include/vorbis/vorbisfile.h @@ -0,0 +1,143 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + last mod: $Id: vorbisfile.h 7485 2004-08-05 14:54:23Z thomasvs $ + + ********************************************************************/ + +#ifndef _OV_FILE_H_ +#define _OV_FILE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include +#include "codec.h" + +/* The function prototypes for the callbacks are basically the same as for + * the stdio functions fread, fseek, fclose, ftell. + * The one difference is that the FILE * arguments have been replaced with + * a void * - this is to be used as a pointer to whatever internal data these + * functions might need. In the stdio case, it's just a FILE * cast to a void * + * + * If you use other functions, check the docs for these functions and return + * the right values. For seek_func(), you *MUST* return -1 if the stream is + * unseekable + */ +typedef struct { + size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); + int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); + int (*close_func) (void *datasource); + long (*tell_func) (void *datasource); +} ov_callbacks; + +#define NOTOPEN 0 +#define PARTOPEN 1 +#define OPENED 2 +#define STREAMSET 3 +#define INITSET 4 + +typedef struct OggVorbis_File { + void *datasource; /* Pointer to a FILE *, etc. */ + int seekable; + ogg_int64_t offset; + ogg_int64_t end; + ogg_sync_state oy; + + /* If the FILE handle isn't seekable (eg, a pipe), only the current + stream appears */ + int links; + ogg_int64_t *offsets; + ogg_int64_t *dataoffsets; + long *serialnos; + ogg_int64_t *pcmlengths; /* overloaded to maintain binary + compatability; x2 size, stores both + beginning and end values */ + vorbis_info *vi; + vorbis_comment *vc; + + /* Decoding working state local storage */ + ogg_int64_t pcm_offset; + int ready_state; + long current_serialno; + int current_link; + + double bittrack; + double samptrack; + + ogg_stream_state os; /* take physical pages, weld into a logical + stream of packets */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ + + ov_callbacks callbacks; + +} OggVorbis_File; + +extern int ov_clear(OggVorbis_File *vf); +extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); + +extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); +extern int ov_test_open(OggVorbis_File *vf); + +extern long ov_bitrate(OggVorbis_File *vf,int i); +extern long ov_bitrate_instant(OggVorbis_File *vf); +extern long ov_streams(OggVorbis_File *vf); +extern long ov_seekable(OggVorbis_File *vf); +extern long ov_serialnumber(OggVorbis_File *vf,int i); + +extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); +extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); +extern double ov_time_total(OggVorbis_File *vf,int i); + +extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek(OggVorbis_File *vf,double pos); +extern int ov_time_seek_page(OggVorbis_File *vf,double pos); + +extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); +extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); + +extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); +extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); +extern double ov_time_tell(OggVorbis_File *vf); + +extern vorbis_info *ov_info(OggVorbis_File *vf,int link); +extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); + +extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, + int *bitstream); +extern long ov_read(OggVorbis_File *vf,char *buffer,int length, + int bigendianp,int word,int sgned,int *bitstream); +extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); + +extern int ov_halfrate(OggVorbis_File *vf,int flag); +extern int ov_halfrate_p(OggVorbis_File *vf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + + diff --git a/libraries/external/xiph/include/vorbis/vssver.scc b/libraries/external/xiph/include/vorbis/vssver.scc new file mode 100755 index 0000000..efef2e4 Binary files /dev/null and b/libraries/external/xiph/include/vorbis/vssver.scc differ diff --git a/libraries/external/xiph/lib/libogg.so.0.5.2 b/libraries/external/xiph/lib/libogg.so.0.5.2 new file mode 100755 index 0000000..7370d93 Binary files /dev/null and b/libraries/external/xiph/lib/libogg.so.0.5.2 differ diff --git a/libraries/external/xiph/lib/libtheora.so.0.1.0 b/libraries/external/xiph/lib/libtheora.so.0.1.0 new file mode 100755 index 0000000..b93263a Binary files /dev/null and b/libraries/external/xiph/lib/libtheora.so.0.1.0 differ diff --git a/libraries/external/xiph/lib/ogg_static.lib b/libraries/external/xiph/lib/ogg_static.lib new file mode 100755 index 0000000..5d1aa60 Binary files /dev/null and b/libraries/external/xiph/lib/ogg_static.lib differ diff --git a/libraries/external/xiph/lib/theora_static.lib b/libraries/external/xiph/lib/theora_static.lib new file mode 100755 index 0000000..ae4ec37 Binary files /dev/null and b/libraries/external/xiph/lib/theora_static.lib differ diff --git a/libraries/external/xiph/lib/vssver.scc b/libraries/external/xiph/lib/vssver.scc new file mode 100755 index 0000000..ef8a06e Binary files /dev/null and b/libraries/external/xiph/lib/vssver.scc differ diff --git a/libraries/external/xiph/libogg-1.1.3.tar.gz b/libraries/external/xiph/libogg-1.1.3.tar.gz new file mode 100755 index 0000000..7637a82 --- /dev/null +++ b/libraries/external/xiph/libogg-1.1.3.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bae29e79fbc50bbedf1235852094b71c8c910a1ef0cd42fe4163b7b545630b65 +size 403467 diff --git a/libraries/external/xiph/libtheora-1.0alpha7.tar.gz b/libraries/external/xiph/libtheora-1.0alpha7.tar.gz new file mode 100755 index 0000000..681bd44 --- /dev/null +++ b/libraries/external/xiph/libtheora-1.0alpha7.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5c7730ded0273a8615b12b46a32b800bbcb9e861e3a18aa92b1c062981a2fef +size 2002542 diff --git a/libraries/external/xiph/libvorbis-1.1.2.tar.gz b/libraries/external/xiph/libvorbis-1.1.2.tar.gz new file mode 100755 index 0000000..37ced84 --- /dev/null +++ b/libraries/external/xiph/libvorbis-1.1.2.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f7135ccbda589c251017912f5f5ec9da626c976d2376bcfda19ad6b9c4a6050 +size 1316434 diff --git a/libraries/external/xiph/makefile b/libraries/external/xiph/makefile new file mode 100755 index 0000000..e4c6a2b --- /dev/null +++ b/libraries/external/xiph/makefile @@ -0,0 +1,5 @@ +# makefile for xiph libraries + +all: + cp libogg.so.0.5.2 ../../../lib/libogg.so.0 + cp libtheora.so.0.1.0 ../../../lib/libtheora.so.0 diff --git a/libraries/external/xiph/readme.txt b/libraries/external/xiph/readme.txt new file mode 100755 index 0000000..ba1e4f9 --- /dev/null +++ b/libraries/external/xiph/readme.txt @@ -0,0 +1,44 @@ + + +This folder contains the library files used for the ogg vorbis/theora codecs. +These codecs are used for the playback and encoding of video files, and are +part of the xiph.org framework. They are open-source and work great! + +Just look at the Deal Or No Deal earnings reports if you don't believe me! + +HOW TO USE: +----------- + +* On both PC and Linux, the "xiph" folder should be placed in the + "g3/lib" folder. + +* On Linux, run the makefile to copy the necessary files to the linux + shared libraries folder. If they are not there, your program will not run. + +* On Linux, make these additions to the makefile: + + In the CLFLAGS section, add: + + -I $(H1)/lib/xiph/include + + In the LIBS section, add: + + $(H1)/lib/xiph/libtheora.so.0.1.0 + $(H1)/lib/xiph/libogg.so.0.5.2 + +* On the PC, make the following additions to the project files: + + In both "core" and "game", in the "C/C++" tab, category "Preprocessor", + add "\g3\lib\xiph\include" to the list of "Additional + include directories". Do this for all configurations. + + In "game", in the "Link" tab, category "Input", + add "\g3\lib\xiph" to the list of "Additional library paths". + Do this for all configurations. + + In "game", in the "Link" tab, category "Input", + add "ogg_static.lib" and "theora_static.lib" to the list + of "Object/library modules". Do this for all configurations. + + +(mnajera@playmechanix.com) diff --git a/libraries/external/xiph/vssver.scc b/libraries/external/xiph/vssver.scc new file mode 100755 index 0000000..de8eaec Binary files /dev/null and b/libraries/external/xiph/vssver.scc differ diff --git a/libraries/external/zlib/Readme.txt b/libraries/external/zlib/Readme.txt new file mode 100755 index 0000000..9090b8e --- /dev/null +++ b/libraries/external/zlib/Readme.txt @@ -0,0 +1,26 @@ +Zlib - compression library + + +Windows headers and binaries taken from zlib-1.2.3.tar.gz + + +LINUX BUILD INSTRUCTIONS: + +1) gunzip and untar the zlib source tar ball + +2) run ./configure --prefix=/g3/zlib/linux + +3) run make and make install + +IF you are also building openssl, then you also will want to follow these steps: + +1) run ./configure + +2) run make and make install + +Basically, openssl will only compile itself against /usr/lib/libz.a +(it has configure flags to tell it to use another location for zlib files, + but as far as I could tell they did actually work) +So to build openssl correctly, you need do a 'normal' zlib build and install. +this will replace the rusty old copy of zlib sitting in /usr/lib (zlib 1.1.4 +which has known, exploitable buffer overflow vunerabilities). \ No newline at end of file diff --git a/libraries/external/zlib/linux/include/vssver.scc b/libraries/external/zlib/linux/include/vssver.scc new file mode 100755 index 0000000..bf8d5d5 Binary files /dev/null and b/libraries/external/zlib/linux/include/vssver.scc differ diff --git a/libraries/external/zlib/linux/include/zconf.h b/libraries/external/zlib/linux/include/zconf.h new file mode 100755 index 0000000..4919b35 --- /dev/null +++ b/libraries/external/zlib/linux/include/zconf.h @@ -0,0 +1,332 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/libraries/external/zlib/linux/include/zlib.h b/libraries/external/zlib/linux/include/zlib.h new file mode 100755 index 0000000..62d0e46 --- /dev/null +++ b/libraries/external/zlib/linux/include/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/libraries/external/zlib/linux/lib/libz.a b/libraries/external/zlib/linux/lib/libz.a new file mode 100755 index 0000000..1fd5364 Binary files /dev/null and b/libraries/external/zlib/linux/lib/libz.a differ diff --git a/libraries/external/zlib/linux/lib/vssver.scc b/libraries/external/zlib/linux/lib/vssver.scc new file mode 100755 index 0000000..01b752d Binary files /dev/null and b/libraries/external/zlib/linux/lib/vssver.scc differ diff --git a/libraries/external/zlib/pc/bin/vssver.scc b/libraries/external/zlib/pc/bin/vssver.scc new file mode 100755 index 0000000..1fe96b9 Binary files /dev/null and b/libraries/external/zlib/pc/bin/vssver.scc differ diff --git a/libraries/external/zlib/pc/bin/zlib1.dll b/libraries/external/zlib/pc/bin/zlib1.dll new file mode 100755 index 0000000..1cf8a47 Binary files /dev/null and b/libraries/external/zlib/pc/bin/zlib1.dll differ diff --git a/libraries/external/zlib/pc/include/vssver.scc b/libraries/external/zlib/pc/include/vssver.scc new file mode 100755 index 0000000..7bcb3be Binary files /dev/null and b/libraries/external/zlib/pc/include/vssver.scc differ diff --git a/libraries/external/zlib/pc/include/zconf.h b/libraries/external/zlib/pc/include/zconf.h new file mode 100755 index 0000000..e3b0c96 --- /dev/null +++ b/libraries/external/zlib/pc/include/zconf.h @@ -0,0 +1,332 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/libraries/external/zlib/pc/include/zlib.h b/libraries/external/zlib/pc/include/zlib.h new file mode 100755 index 0000000..62d0e46 --- /dev/null +++ b/libraries/external/zlib/pc/include/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/libraries/external/zlib/pc/lib/vssver.scc b/libraries/external/zlib/pc/lib/vssver.scc new file mode 100755 index 0000000..c66aacf Binary files /dev/null and b/libraries/external/zlib/pc/lib/vssver.scc differ diff --git a/libraries/external/zlib/pc/lib/zdll.exp b/libraries/external/zlib/pc/lib/zdll.exp new file mode 100755 index 0000000..2ca08c5 Binary files /dev/null and b/libraries/external/zlib/pc/lib/zdll.exp differ diff --git a/libraries/external/zlib/pc/lib/zdll.lib b/libraries/external/zlib/pc/lib/zdll.lib new file mode 100755 index 0000000..01f4e10 Binary files /dev/null and b/libraries/external/zlib/pc/lib/zdll.lib differ diff --git a/libraries/external/zlib/pc/lib/zlib.def b/libraries/external/zlib/pc/lib/zlib.def new file mode 100755 index 0000000..03bcf1c --- /dev/null +++ b/libraries/external/zlib/pc/lib/zlib.def @@ -0,0 +1,60 @@ +LIBRARY +; zlib data compression library + +EXPORTS +; basic functions + zlibVersion + deflate + deflateEnd + inflate + inflateEnd +; advanced functions + deflateSetDictionary + deflateCopy + deflateReset + deflateParams + deflateBound + deflatePrime + inflateSetDictionary + inflateSync + inflateCopy + inflateReset + inflateBack + inflateBackEnd + zlibCompileFlags +; utility functions + compress + compress2 + compressBound + uncompress + gzopen + gzdopen + gzsetparams + gzread + gzwrite + gzprintf + gzputs + gzgets + gzputc + gzgetc + gzungetc + gzflush + gzseek + gzrewind + gztell + gzeof + gzclose + gzerror + gzclearerr +; checksum functions + adler32 + crc32 +; various hacks, don't look :) + deflateInit_ + deflateInit2_ + inflateInit_ + inflateInit2_ + inflateBackInit_ + inflateSyncPoint + get_crc_table + zError diff --git a/libraries/external/zlib/vssver.scc b/libraries/external/zlib/vssver.scc new file mode 100755 index 0000000..16fd4cf Binary files /dev/null and b/libraries/external/zlib/vssver.scc differ diff --git a/libraries/external/zlib/zlib-1.2.3.tar.gz b/libraries/external/zlib/zlib-1.2.3.tar.gz new file mode 100755 index 0000000..bddcec2 --- /dev/null +++ b/libraries/external/zlib/zlib-1.2.3.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1795c7d067a43174113fdf03447532f373e1c6c57c08d61d9e4e9be5e244b05e +size 496597 diff --git a/libraries/external/zlib/zlib123-dll.zip b/libraries/external/zlib/zlib123-dll.zip new file mode 100755 index 0000000..30adabc Binary files /dev/null and b/libraries/external/zlib/zlib123-dll.zip differ diff --git a/libraries/external_libs.dsp b/libraries/external_libs.dsp new file mode 100755 index 0000000..55ff06b --- /dev/null +++ b/libraries/external_libs.dsp @@ -0,0 +1,97 @@ +# Microsoft Developer Studio Project File - Name="external_libs" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=external_libs - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "external_libs.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "external_libs.mak" CFG="external_libs - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "external_libs - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "external_libs - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries", VROAAAAA" +# PROP Scc_LocalPath "." + +!IF "$(CFG)" == "external_libs - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f external_libs.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "external_libs.exe" +# PROP BASE Bsc_Name "external_libs.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "nmake /f "external_libs.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "external_libs.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "external_libs - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f external_libs.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "external_libs.exe" +# PROP BASE Bsc_Name "external_libs.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "nmake /f "external_libs.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "external_libs.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "external_libs - Win32 Release" +# Name "external_libs - Win32 Debug" + +!IF "$(CFG)" == "external_libs - Win32 Release" + +!ELSEIF "$(CFG)" == "external_libs - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/libraries/external_libs.mak b/libraries/external_libs.mak new file mode 100755 index 0000000..bc54689 --- /dev/null +++ b/libraries/external_libs.mak @@ -0,0 +1,3 @@ +all: + c:\g3\libraries\remove-libs-w32.bat + c:\g3\libraries\install-external-libs-w32.bat diff --git a/libraries/external_libs.plg b/libraries/external_libs.plg new file mode 100755 index 0000000..f3d9455 --- /dev/null +++ b/libraries/external_libs.plg @@ -0,0 +1,62 @@ + + +
+

Build Log

+

+--------------------Configuration: external_libs - Win32 Debug-------------------- +

+ + +Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 +Copyright (C) Microsoft Corp 1988-1998. All rights reserved. + + c:\g3\libraries\remove-libs-w32.bat +Deleting contents of c:/g3/lib... +Deleting contents of c:/g3/include... + c:\g3\libraries\install-external-libs-w32.bat +Installing external libraries and headers... +Installing freeglut... +2 File(s) copied +2 File(s) copied +4 File(s) copied +Installing glew... +2 File(s) copied +2 File(s) copied +2 File(s) copied +Installing glut... +2 File(s) copied +2 File(s) copied +2 File(s) copied +Installing glext... +3 File(s) copied +Installing libxml... +6 File(s) copied +3 File(s) copied +48 File(s) copied +Installing openssl... +4 File(s) copied +3 File(s) copied +70 File(s) copied +Installing Xiph libs... +5 File(s) copied +10 File(s) copied +Installing zlib... +2 File(s) copied +4 File(s) copied +3 File(s) copied +Installing dsound... +2 File(s) copied +Installing iconv... +11 File(s) copied +4 File(s) copied +Installing icmp... +2 File(s) copied +5 File(s) copied + + + +

Results

+external_libs.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/install-external-libs-linux.sh b/libraries/install-external-libs-linux.sh new file mode 100755 index 0000000..913d14b --- /dev/null +++ b/libraries/install-external-libs-linux.sh @@ -0,0 +1,67 @@ +#! /bin/sh + +echo Installing external libraries and headers... + +START_DIR=`pwd` + +mkdir -p /g3/lib +mkdir -p /g3/include + + +echo Installing libxml... +cp -fr /g3/libraries/external/libxml/linux/lib/* /g3/lib +cp -fr /g3/libraries/external/libxml/linux/include/* /g3/include + + +echo Installing openssl... +cp -fr /g3/libraries/external/openssl/linux/lib/* /g3/lib +cp -fr /g3/libraries/external/openssl/linux/include/* /g3/include + +echo Installing glew... +cp -fr /g3/libraries/external/glew/linux/lib/* /g3/lib +cp -fr /g3/libraries/external/glew/linux/include/* /g3/include + + +echo Installing Xiph libs... +cp -fr /g3/libraries/external/xiph/lib/libogg.so.0.5.2 /usr/lib +cp -fr /g3/libraries/external/xiph/lib/libtheora.so.0.1.0 /usr/lib +cp -fr /g3/libraries/external/xiph/include/* /g3/include + + +echo Installing zlib... +cp -fr /g3/libraries/external/zlib/linux/lib/* /g3/lib +cp -fr /g3/libraries/external/zlib/linux/include/* /g3/include + +echo Installing libusb... +cp -fr /g3/libraries/external/libusb/lib/* /g3/lib +cp -fr /g3/libraries/external/libusb/include/* /g3/include + +echo Installing libhid... +cp -fr /g3/libraries/external/libhid/lib/* /g3/lib +cp -fr /g3/libraries/external/libhid/include/* /g3/include + + +echo Installing lungif +cd /g3/libraries/external/lungif +make clean +make + +echo Installing jpeglib +cd /g3/libraries/external/jpeglib +make clean +make + +echo Installing rockey +cd /g3/libraries/external/rockey +make + +echo Installing hasp +cp -fr /g3/libraries/external/hasp/linux/lib/* /g3/lib + +echo Installing OpenCV +mkdir /g3/include/opencv +cp -fr /g3/libraries/external/opencv/linux/include/*.h /g3/include/opencv +cp -fr /g3/libraries/external/opencv/linux/libs/*.a /g3/lib + +cd "$START_DIR" + diff --git a/libraries/install-external-libs-w32.bat b/libraries/install-external-libs-w32.bat new file mode 100755 index 0000000..881e53b --- /dev/null +++ b/libraries/install-external-libs-w32.bat @@ -0,0 +1,69 @@ +@ECHO off + +echo Installing external libraries and headers... + +@\cygwin\bin\mkdir -p c:/g3/lib +@\cygwin\bin\mkdir -p c:/g3/include + + +echo Installing freeglut... +xcopy c:\g3\libraries\external\freeglut\pc\bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\freeglut\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\freeglut\pc\include\* c:\g3\include /s /e /r /h /y /q + + +echo Installing glew... +xcopy c:\g3\libraries\external\glew\pc\bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\glew\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\glew\pc\include\* c:\g3\include /s /e /r /h /y /q + + +echo Installing glut... +xcopy c:\g3\libraries\external\glut\pc\bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\glut\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\glut\pc\include\* c:\g3\include /s /e /r /h /y /q + +echo Installing glext... +xcopy c:\g3\libraries\external\glext\pc\include\* c:\g3\include /s /e /r /h /y /q + + +echo Installing libxml... +xcopy c:\g3\libraries\external\libxml\pc\bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\libxml\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\libxml\pc\include\* c:\g3\include /s /e /r /h /y /q + + +echo Installing openssl... +xcopy c:\g3\libraries\external\openssl\pc\bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\openssl\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\openssl\pc\include\* c:\g3\include /s /e /r /h /y /q + + +echo Installing Xiph libs... +xcopy c:\g3\libraries\external\xiph\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\xiph\include\* c:\g3\include /s /e /r /h /y /q + + +echo Installing zlib... +xcopy c:\g3\libraries\external\zlib\pc\bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\zlib\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\zlib\pc\include\* c:\g3\include /s /e /r /h /y /q + +echo Installing dsound... +xcopy c:\g3\libraries\external\dsound\lib\* c:\g3\lib /s /e /r /h /y /q + +echo Installing iconv... +xcopy c:\g3\libraries\external\libiconv\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\libiconv\pc\include\* c:\g3\include /s /e /r /h /y /q + +echo Installing icmp... +xcopy c:\g3\libraries\external\icmp\pc\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\icmp\pc\include\* c:\g3\include /s /e /r /h /y /q + +echo Installing hasp... +xcopy c:\g3\libraries\external\hasp\pc\lib\* c:\g3\lib /s /e /r /h /y /q + +echo Installing PhysX... +xcopy c:\g3\libraries\external\physx\Win32\Bin\* c:\windows\system32 /s /e /r /h /y /q +xcopy c:\g3\libraries\external\physx\Win32\lib\* c:\g3\lib /s /e /r /h /y /q +xcopy c:\g3\libraries\external\physx\Win32\include\* c:\g3\include /s /e /r /h /y /q diff --git a/libraries/install-pmrt-libs-linux.sh b/libraries/install-pmrt-libs-linux.sh new file mode 100755 index 0000000..932b1e2 --- /dev/null +++ b/libraries/install-pmrt-libs-linux.sh @@ -0,0 +1,78 @@ +#! /bin/sh + +echo Installing pmrt libraries and headers... + +START_DIR=`pwd` + +mkdir /g3/lib +mkdir /g3/include + + +echo Installing card lib +cd /g3/libraries/pmrt/card +make clean +make + +echo Installing jamma lib +cd /g3/libraries/pmrt/jamma +make clean +make + +echo Installing jpsnd lib +cd /g3/libraries/pmrt/jpsnd +make clean +make + +echo Installing pmrt_utils lib +cd /g3/libraries/pmrt/pmrt_utils +make clean +make + +echo Installing pmrt_ssl lib +cd /g3/libraries/pmrt/pmrt_ssl +make clean +make + +echo Installing pmrt_compression lib +cd /g3/libraries/pmrt/pmrt_compression +make clean +make + +echo Installing pmrt_messages lib +cd /g3/libraries/pmrt/pmrt_messages +make clean +make + +echo Installing xmlWrapper lib +cd /g3/libraries/pmrt/xmlWrapper +make clean +make + +echo Installing telemetry lib +cd /g3/libraries/pmrt/telemetry +make clean +make + +echo Installing modem lib +cd /g3/libraries/pmrt/modem +make clean +make + +echo Installing dongle lib +cd /g3/libraries/pmrt/dongle +make clean +make + +echo Installing irtrack lib +cd /g3/libraries/pmrt/irtrack +make clean +make + +echo Installing psm_engine lib +cd /g3/libraries/pmrt/psm_engine +make clean +make + + +cd "$START_DIR" + diff --git a/libraries/libraries.dsp b/libraries/libraries.dsp new file mode 100755 index 0000000..bd51bf3 --- /dev/null +++ b/libraries/libraries.dsp @@ -0,0 +1,97 @@ +# Microsoft Developer Studio Project File - Name="libraries" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=libraries - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libraries.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libraries.mak" CFG="libraries - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libraries - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "libraries - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries", VROAAAAA" +# PROP Scc_LocalPath "." + +!IF "$(CFG)" == "libraries - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f libraries.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "libraries.exe" +# PROP BASE Bsc_Name "libraries.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "NMAKE /f libraries.mak" +# PROP Rebuild_Opt "/a" +# PROP Target_File "libraries.exe" +# PROP Bsc_Name "libraries.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "libraries - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "libraries___Win32_Debug" +# PROP BASE Intermediate_Dir "libraries___Win32_Debug" +# PROP BASE Cmd_Line "NMAKE /f libraries.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "libraries.exe" +# PROP BASE Bsc_Name "libraries.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "libraries___Win32_Debug" +# PROP Intermediate_Dir "libraries___Win32_Debug" +# PROP Cmd_Line "nmake /f "libraries.mak"" +# PROP Rebuild_Opt "/a" +# PROP Target_File "libraries.exe" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "libraries - Win32 Release" +# Name "libraries - Win32 Debug" + +!IF "$(CFG)" == "libraries - Win32 Release" + +!ELSEIF "$(CFG)" == "libraries - Win32 Debug" + +!ENDIF + +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/libraries/libraries.dsw b/libraries/libraries.dsw new file mode 100755 index 0000000..93a71cd --- /dev/null +++ b/libraries/libraries.dsw @@ -0,0 +1,370 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Modem"=.\pmrt\Modem\Modem.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "card"=.\pmrt\card\card.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name external_libs + End Project Dependency +}}} + +############################################################################### + +Project: "dongle"=.\pmrt\dongle\dongle.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pmrt_ssl + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_utils + End Project Dependency +}}} + +############################################################################### + +Project: "external_libs"=.\external_libs.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jammalib"=.\pmrt\jamma\jammalib.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpeglib"=.\external\jpeglib\jpeglib.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpslib"=.\pmrt\jpsnd\jpslib.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name external_libs + End Project Dependency +}}} + +############################################################################### + +Project: "libraries"=.\libraries.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name card + End Project Dependency + Begin Project Dependency + Project_Dep_Name external_libs + End Project Dependency + Begin Project Dependency + Project_Dep_Name jammalib + End Project Dependency + Begin Project Dependency + Project_Dep_Name jpeglib + End Project Dependency + Begin Project Dependency + Project_Dep_Name jpslib + End Project Dependency + Begin Project Dependency + Project_Dep_Name lungif + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_messages + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_ssl + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_utils + End Project Dependency + Begin Project Dependency + Project_Dep_Name telemetry + End Project Dependency + Begin Project Dependency + Project_Dep_Name xml + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_compression + End Project Dependency + Begin Project Dependency + Project_Dep_Name Modem + End Project Dependency + Begin Project Dependency + Project_Dep_Name dongle + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_llm + End Project Dependency + Begin Project Dependency + Project_Dep_Name psm_engine + End Project Dependency +}}} + +############################################################################### + +Project: "lungif"=.\external\lungif\lungif.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "pmrt_compression"=.\pmrt\pmrt_compression\pmrt_compression.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "pmrt_llm"=.\pmrt\pmrt_llm\pmrt_llm.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pmrt_utils + End Project Dependency +}}} + +############################################################################### + +Project: "pmrt_messages"=.\pmrt\pmrt_messages\pmrt_messages.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pmrt_utils + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_ssl + End Project Dependency + Begin Project Dependency + Project_Dep_Name pmrt_compression + End Project Dependency +}}} + +############################################################################### + +Project: "pmrt_ssl"=.\pmrt\pmrt_ssl\pmrt_ssl.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pmrt_utils + End Project Dependency +}}} + +############################################################################### + +Project: "pmrt_utils"=.\pmrt\pmrt_utils\pmrt_utils.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "psm_engine"=.\pmrt\psm_engine\psm_engine.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pmrt_utils + End Project Dependency +}}} + +############################################################################### + +Project: "telemetry"=.\pmrt\telemetry\telemetry.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name xml + End Project Dependency +}}} + +############################################################################### + +Project: "xml"=.\pmrt\xmlWrapper\xml.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries", SLBAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/libraries.mak b/libraries/libraries.mak new file mode 100755 index 0000000..a42db40 --- /dev/null +++ b/libraries/libraries.mak @@ -0,0 +1,2 @@ +all: + echo ALL DONE! \ No newline at end of file diff --git a/libraries/libraries.ncb b/libraries/libraries.ncb new file mode 100755 index 0000000..8f673cd Binary files /dev/null and b/libraries/libraries.ncb differ diff --git a/libraries/libraries.opt b/libraries/libraries.opt new file mode 100755 index 0000000..8dd1a29 Binary files /dev/null and b/libraries/libraries.opt differ diff --git a/libraries/libraries.plg b/libraries/libraries.plg new file mode 100755 index 0000000..62365ef --- /dev/null +++ b/libraries/libraries.plg @@ -0,0 +1,28 @@ + + +
+

Build Log

+

+--------------------Configuration: external_libs - Win32 Debug-------------------- +

+ + +Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 +Copyright (C) Microsoft Corp 1988-1998. All rights reserved. + + c:\g3\libraries\remove-libs-w32.bat +Deleting contents of c:/g3/lib... +Deleting contents of c:/g3/include... +/usr/bin/rm: cannot remove directory `c:/g3/include': Directory not empty +/usr/bin/mkdir: cannot create directory `c:/g3/include': File exists +NMAKE : fatal error U1077: 'c:\g3\libraries\remove-libs-w32.bat' : return code '0x1' +Stop. +Error executing nmake. + + + +

Results

+libraries.exe - 1 error(s), 0 warning(s) +
+ + diff --git a/libraries/makefile b/libraries/makefile new file mode 100755 index 0000000..5a04125 --- /dev/null +++ b/libraries/makefile @@ -0,0 +1,11 @@ +# Libraries Makefile +# +# this makefile builds and installs all the pmrt developed and external libs +# needed for big buck hunter and other games + +all: + /bin/sh /g3/libraries/remove-libs-linux.sh + /bin/sh /g3/libraries/install-external-libs-linux.sh + /bin/sh /g3/libraries/install-pmrt-libs-linux.sh + + diff --git a/libraries/mssccprj.scc b/libraries/mssccprj.scc new file mode 100755 index 0000000..1091f92 --- /dev/null +++ b/libraries/mssccprj.scc @@ -0,0 +1,17 @@ +SCC = This is a Source Code Control file + +[external_libs.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries", VROAAAAA + +[external_libs.mak] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries", VROAAAAA + +[libraries.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries", VROAAAAA + +[libraries.mak] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries", VROAAAAA diff --git a/libraries/pmrt/card/.map b/libraries/pmrt/card/.map new file mode 100644 index 0000000..fa8f5ff --- /dev/null +++ b/libraries/pmrt/card/.map @@ -0,0 +1,800 @@ +Archive member included because of file (symbol) + +libcard.a(card.o) cardtest.o (CardInit) +libcard.a(card_lin.o) libcard.a(card.o) (cardDrvrInit) +/g3/lib/libhid.a(hid_initialisation.o) + libcard.a(card_lin.o) (hid_new_HIDInterface) +/g3/lib/libhid.a(hid_opening.o) + libcard.a(card_lin.o) (hid_close) +/g3/lib/libhid.a(hid_parsing.o) + /g3/lib/libhid.a(hid_opening.o) (hid_reset_parser) +/g3/lib/libhid.a(hid_exchange.o) + libcard.a(card_lin.o) (hid_set_feature_report) +/g3/lib/libhid.a(debug.o) /g3/lib/libhid.a(hid_initialisation.o) (hid_debug_level) +/g3/lib/libhid.a(hidparser.o) + /g3/lib/libhid.a(hid_parsing.o) (ResetParser) +/g3/lib/libhid.a(linux.o) /g3/lib/libhid.a(hid_opening.o) (hid_os_force_claim) +/g3/lib/libhid.a(hid_preparation.o) + /g3/lib/libhid.a(hid_opening.o) (hid_prepare_interface) +/g3/lib/libusb.a(usb.o) /g3/lib/libhid.a(hid_initialisation.o) (usb_find_busses) +/g3/lib/libusb.a(error.o) /g3/lib/libhid.a(hid_exchange.o) (usb_strerror) +/g3/lib/libusb.a(descriptors.o) + /g3/lib/libusb.a(usb.o) (usb_destroy_configuration) +/g3/lib/libusb.a(linux.o) /g3/lib/libusb.a(usb.o) (usb_os_open) +/usr/lib/libc_nonshared.a(elf-init.oS) + /usr/lib/crt1.o (__libc_csu_init) + +Allocating common symbols +Common symbol size file + +asciibuf 0x80 cardtest.o +cardData 0x74 libcard.a(card.o) +cardMem 0x710 libcard.a(card.o) +rawtio 0x3c cardtest.o +savetio 0x3c cardtest.o +cardDev 0x4 libcard.a(card.o) + +Memory Configuration + +Name Origin Length Attributes +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD /usr/lib/crt1.o +LOAD /usr/lib/crti.o +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o +LOAD cardtest.o +LOAD libcard.a +LOAD /g3/lib/libhid.a +LOAD /g3/lib/libusb.a +LOAD /usr/lib/librt.so +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_eh.a +LOAD /usr/lib/libc.so +START GROUP +LOAD /lib/libc.so.6 +LOAD /usr/lib/libc_nonshared.a +END GROUP +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_eh.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o +LOAD /usr/lib/crtn.o + 0x0000000008048114 . = (0x8048000 + SIZEOF_HEADERS) + +.interp 0x0000000008048114 0x13 + *(.interp) + .interp 0x0000000008048114 0x13 /usr/lib/crt1.o + +.note.ABI-tag 0x0000000008048128 0x20 + .note.ABI-tag 0x0000000008048128 0x20 /usr/lib/crt1.o + +.hash 0x0000000008048148 0x170 + *(.hash) + .hash 0x0000000008048148 0x170 /usr/lib/crt1.o + +.dynsym 0x00000000080482b8 0x350 + *(.dynsym) + .dynsym 0x00000000080482b8 0x350 /usr/lib/crt1.o + +.dynstr 0x0000000008048608 0x247 + *(.dynstr) + .dynstr 0x0000000008048608 0x247 /usr/lib/crt1.o + +.gnu.version 0x0000000008048850 0x6a + *(.gnu.version) + .gnu.version 0x0000000008048850 0x6a /usr/lib/crt1.o + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r 0x00000000080488bc 0x60 + *(.gnu.version_r) + .gnu.version_r + 0x00000000080488bc 0x60 /usr/lib/crt1.o + +.rel.dyn 0x000000000804891c 0x28 + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + .rel.got 0x000000000804891c 0x20 /usr/lib/crt1.o + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + .rel.bss 0x000000000804893c 0x8 /usr/lib/crt1.o + +.rela.dyn + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + +.rel.plt 0x0000000008048944 0x168 + *(.rel.plt) + .rel.plt 0x0000000008048944 0x168 /usr/lib/crt1.o + +.rela.plt + *(.rela.plt) + +.init 0x0000000008048aac 0x17 + *(.init) + .init 0x0000000008048aac 0xb /usr/lib/crti.o + 0x0000000008048aac _init + .init 0x0000000008048ab7 0x5 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .init 0x0000000008048abc 0x5 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + .init 0x0000000008048ac1 0x2 /usr/lib/crtn.o + +.plt 0x0000000008048ac4 0x2e0 + *(.plt) + .plt 0x0000000008048ac4 0x2e0 /usr/lib/crt1.o + 0x0000000008048ad4 pthread_attr_init@@GLIBC_2.1 + 0x0000000008048ae4 usleep@@GLIBC_2.0 + 0x0000000008048af4 pthread_attr_setdetachstate@@GLIBC_2.0 + 0x0000000008048b04 strchr@@GLIBC_2.0 + 0x0000000008048b14 write@@GLIBC_2.0 + 0x0000000008048b24 strcmp@@GLIBC_2.0 + 0x0000000008048b34 close@@GLIBC_2.0 + 0x0000000008048b44 fprintf@@GLIBC_2.0 + 0x0000000008048b54 getenv@@GLIBC_2.0 + 0x0000000008048b64 pthread_create@@GLIBC_2.1 + 0x0000000008048b74 select@@GLIBC_2.0 + 0x0000000008048b84 strerror@@GLIBC_2.0 + 0x0000000008048b94 pthread_cancel@@GLIBC_2.0 + 0x0000000008048ba4 tcsetattr@@GLIBC_2.0 + 0x0000000008048bb4 __errno_location@@GLIBC_2.0 + 0x0000000008048bc4 malloc@@GLIBC_2.0 + 0x0000000008048bd4 pthread_testcancel@@GLIBC_2.0 + 0x0000000008048be4 strlen@@GLIBC_2.0 + 0x0000000008048bf4 __strtol_internal@@GLIBC_2.0 + 0x0000000008048c04 strncmp@@GLIBC_2.0 + 0x0000000008048c14 memcmp@@GLIBC_2.0 + 0x0000000008048c24 __libc_start_main@@GLIBC_2.0 + 0x0000000008048c34 realloc@@GLIBC_2.0 + 0x0000000008048c44 strcat@@GLIBC_2.0 + 0x0000000008048c54 pthread_attr_destroy@@GLIBC_2.0 + 0x0000000008048c64 printf@@GLIBC_2.0 + 0x0000000008048c74 memcpy@@GLIBC_2.0 + 0x0000000008048c84 closedir@@GLIBC_2.0 + 0x0000000008048c94 gettimeofday@@GLIBC_2.0 + 0x0000000008048ca4 opendir@@GLIBC_2.0 + 0x0000000008048cb4 snprintf@@GLIBC_2.0 + 0x0000000008048cc4 open@@GLIBC_2.0 + 0x0000000008048cd4 tcflush@@GLIBC_2.0 + 0x0000000008048ce4 sscanf@@GLIBC_2.0 + 0x0000000008048cf4 free@@GLIBC_2.0 + 0x0000000008048d04 ioctl@@GLIBC_2.0 + 0x0000000008048d14 memset@@GLIBC_2.0 + 0x0000000008048d24 strncpy@@GLIBC_2.0 + 0x0000000008048d34 vprintf@@GLIBC_2.0 + 0x0000000008048d44 sprintf@@GLIBC_2.0 + 0x0000000008048d54 fwrite@@GLIBC_2.0 + 0x0000000008048d64 readdir@@GLIBC_2.0 + 0x0000000008048d74 tcgetattr@@GLIBC_2.0 + 0x0000000008048d84 read@@GLIBC_2.0 + 0x0000000008048d94 strcpy@@GLIBC_2.0 + +.text 0x0000000008048db0 0xd990 + *(.text .stub .text.* .gnu.linkonce.t.*) + .text 0x0000000008048db0 0x24 /usr/lib/crt1.o + 0x0000000008048db0 _start + .text 0x0000000008048dd4 0x22 /usr/lib/crti.o + *fill* 0x0000000008048df6 0xa 90909090 + .text 0x0000000008048e00 0x74 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .text 0x0000000008048e74 0x60b cardtest.o + 0x0000000008048eef ConKeyRead + 0x000000000804917a card_callback + 0x000000000804945f card_apphook_msg + 0x0000000008049439 card_apphook_malloc + 0x0000000008048eea conFinal + 0x0000000008048fc1 main + 0x0000000008048f5b cardtesthelp + 0x000000000804944c card_apphook_free + 0x0000000008048e74 conInit + *fill* 0x000000000804947f 0x1 90909090 + .text 0x0000000008049480 0xca2 libcard.a(card.o) + 0x0000000008049545 CardFinal + 0x000000000804a092 CardFlushIO + 0x0000000008049608 CardChangePortSettings + 0x000000000804994a cardPullNumbers + 0x000000000804a0c8 CardSelectMag + 0x000000000804958d CardBegin + 0x0000000008049ad7 CardLoop + 0x00000000080495ea CardEnd + 0x0000000008049480 CardInit + 0x000000000804976a luhnsub + 0x000000000804971f cardClearPlayerData + 0x00000000080496ed CardSetCallback + 0x0000000008049839 cardLUHNCheck + 0x0000000008049672 CardGetVersionString + 0x000000000804a0fe cardGetDevice + *fill* 0x000000000804a122 0x2 90909090 + .text 0x000000000804a124 0x322d libcard.a(card_lin.o) + 0x000000000804ae18 SCRGetT2Len + 0x000000000804ceaf xicoCardThread + 0x000000000804b58a SCRGetT3Data + 0x000000000804a361 cardDrvrIsRunning + 0x000000000804a6a1 SCRGrnLedOff + 0x000000000804b7af ctCommand + 0x000000000804c31a xicoIsBufMsgReady + 0x000000000804b8ef SCRcardThread + 0x000000000804bfa8 xicoOpenPort + 0x000000000804ab21 SCRClearMagBuff + 0x000000000804c3cb xicoReadLoop + 0x000000000804a388 SCROpenPort + 0x000000000804a129 cardDrvrInit + 0x000000000804aa01 SCRSelMagMode + 0x000000000804a7c1 SCRRedLedOn + 0x000000000804a581 SCRGrnLedOn + 0x000000000804c0d3 xicoClosePort + 0x000000000804afac SCRGetT3Len + 0x000000000804c645 xicoPoll + 0x000000000804b365 SCRGetT2Data + 0x000000000804a8e1 SCRRedLedOff + 0x000000000804a305 cardDrvrClose + 0x000000000804b140 SCRGetT1Data + 0x000000000804a15f cardDrvrFinal + 0x000000000804a172 cardDrvrOpen + 0x000000000804c11f xicoSend + 0x000000000804ac84 SCRGetT1Len + 0x000000000804a525 SCRClosePort + *fill* 0x000000000804d351 0xf 90909090 + .text 0x000000000804d360 0x5fb /g3/lib/libhid.a(hid_initialisation.o) + 0x000000000804d440 hid_delete_HIDInterface + 0x000000000804d4e0 hid_reset_HIDInterface + 0x000000000804d940 hid_is_initialised + 0x000000000804d360 hid_new_HIDInterface + 0x000000000804d580 hid_init + 0x000000000804d870 hid_cleanup + *fill* 0x000000000804d95b 0x5 90909090 + .text 0x000000000804d960 0x16fa /g3/lib/libhid.a(hid_opening.o) + 0x000000000804e540 hid_open + 0x000000000804efd0 hid_is_opened + 0x000000000804e8e0 hid_force_open + 0x000000000804ec90 hid_close + *fill* 0x000000000804f05a 0x6 90909090 + .text 0x000000000804f060 0x129f /g3/lib/libhid.a(hid_parsing.o) + 0x000000000804fa20 hid_reset_parser + 0x000000000804fd90 hid_extract_value + 0x000000000804f640 hid_prepare_parser + 0x000000000804f230 hid_init_parser + 0x0000000008050190 hid_format_path + 0x000000000804fb60 hid_find_object + 0x000000000804ffe0 hid_get_report_size + *fill* 0x00000000080502ff 0x1 90909090 + .text 0x0000000008050300 0x1c5d /g3/lib/libhid.a(hid_exchange.o) + 0x0000000008051e00 hid_set_idle + 0x0000000008051a60 hid_interrupt_write + 0x00000000080515e0 hid_get_item_string + 0x00000000080506d0 hid_set_output_report + 0x00000000080516c0 hid_interrupt_read + 0x0000000008051240 hid_get_item_value + 0x0000000008050300 hid_get_input_report + 0x0000000008051650 hid_set_item_value + 0x0000000008050e70 hid_set_feature_report + 0x0000000008050aa0 hid_get_feature_report + *fill* 0x0000000008051f5d 0x3 90909090 + .text 0x0000000008051f60 0x46f /g3/lib/libhid.a(debug.o) + 0x0000000008051f80 hid_set_debug_stream + 0x0000000008051fa0 hid_set_usb_debug + 0x0000000008052060 trace_usb_device + 0x0000000008051f60 hid_set_debug + 0x00000000080522b0 trace_usb_config_descriptor + 0x0000000008051fd0 trace_usb_bus + 0x00000000080523a0 trace_usb_dev_handle + 0x0000000008052130 trace_usb_device_descriptor + *fill* 0x00000000080523cf 0x1 90909090 + .text 0x00000000080523d0 0xa05 /g3/lib/libhid.a(hidparser.o) + 0x00000000080523d0 ResetParser + 0x0000000008052550 FormatValue + 0x0000000008052c80 GetValue + 0x0000000008052590 HIDParse + 0x0000000008052d20 SetValue + 0x0000000008052490 GetReportOffset + 0x0000000008052bc0 FindObject + *fill* 0x0000000008052dd5 0xb 90909090 + .text 0x0000000008052de0 0x301 /g3/lib/libhid.a(linux.o) + 0x0000000008052de0 hid_os_force_claim + *fill* 0x00000000080530e1 0xf 90909090 + .text 0x00000000080530f0 0x810 /g3/lib/libhid.a(hid_preparation.o) + 0x0000000008053810 hid_prepare_interface + .text 0x0000000008053900 0x659 /g3/lib/libusb.a(usb.o) + 0x0000000008053c90 usb_set_debug + 0x0000000008053f00 usb_device + 0x0000000008053900 usb_find_busses + 0x0000000008053ce0 usb_init + 0x0000000008053a90 usb_find_devices + 0x0000000008053d30 usb_open + 0x0000000008053f40 usb_get_busses + 0x0000000008053f50 usb_free_bus + 0x0000000008053f10 usb_free_dev + 0x0000000008053de0 usb_get_string_simple + 0x0000000008053da0 usb_get_string + 0x0000000008053ed0 usb_close + *fill* 0x0000000008053f59 0x7 90909090 + .text 0x0000000008053f60 0x47 /g3/lib/libusb.a(error.o) + 0x0000000008053f60 usb_strerror + *fill* 0x0000000008053fa7 0x9 90909090 + .text 0x0000000008053fb0 0xe47 /g3/lib/libusb.a(descriptors.o) + 0x0000000008054710 usb_parse_configuration + 0x0000000008054070 usb_parse_descriptor + 0x0000000008053fb0 usb_get_descriptor_by_endpoint + 0x0000000008054b50 usb_fetch_and_parse_descriptors + 0x0000000008054010 usb_get_descriptor + 0x00000000080549a0 usb_destroy_configuration + *fill* 0x0000000008054df7 0x9 90909090 + .text 0x0000000008054e00 0x1893 /g3/lib/libusb.a(linux.o) + 0x0000000008055800 usb_os_find_busses + 0x0000000008054ed0 usb_os_open + 0x0000000008056340 usb_resetep + 0x0000000008055740 usb_bulk_write + 0x0000000008054ef0 usb_os_close + 0x00000000080563e0 usb_clear_halt + 0x0000000008056480 usb_reset + 0x0000000008055290 usb_control_msg + 0x00000000080561e0 usb_os_init + 0x0000000008056520 usb_get_driver_np + 0x0000000008055110 usb_release_interface + 0x00000000080559c0 usb_os_find_devices + 0x00000000080565f0 usb_detach_kernel_driver_np + 0x00000000080557a0 usb_interrupt_write + 0x0000000008054f80 usb_set_configuration + 0x00000000080557d0 usb_interrupt_read + 0x0000000008055770 usb_bulk_read + 0x0000000008055f20 usb_os_determine_children + 0x0000000008055030 usb_claim_interface + 0x00000000080551c0 usb_set_altinterface + *fill* 0x0000000008056693 0xd 90909090 + .text 0x00000000080566a0 0x68 /usr/lib/libc_nonshared.a(elf-init.oS) + 0x00000000080566d0 __libc_csu_fini + 0x00000000080566a0 __libc_csu_init + *fill* 0x0000000008056708 0x8 90909090 + .text 0x0000000008056710 0x30 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + *(.gnu.warning) + +.fini 0x0000000008056740 0x1b + *(.fini) + .fini 0x0000000008056740 0x11 /usr/lib/crti.o + 0x0000000008056740 _fini + .fini 0x0000000008056751 0x5 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .fini 0x0000000008056756 0x5 /usr/lib/crtn.o + 0x000000000805675b PROVIDE (__etext, .) + 0x000000000805675b PROVIDE (_etext, .) + 0x000000000805675b PROVIDE (etext, .) + +.rodata 0x0000000008056760 0x3ff5 + *(.rodata .rodata.* .gnu.linkonce.r.*) + .rodata 0x0000000008056760 0x8 /usr/lib/crt1.o + 0x0000000008056760 _fp_hw + 0x0000000008056764 _IO_stdin_used + *fill* 0x0000000008056768 0x18 00 + .rodata 0x0000000008056780 0x350 cardtest.o + .rodata 0x0000000008056ad0 0x1d libcard.a(card.o) + *fill* 0x0000000008056aed 0x13 00 + .rodata 0x0000000008056b00 0x9f8 libcard.a(card_lin.o) + 0x0000000008056bad brSelMagMode + 0x0000000008056bc5 brGetT2Len + 0x0000000008056ba4 brRedLedOff + 0x0000000008056bb5 brClearMagBuff + 0x0000000008056b9b brRedLedOn + 0x0000000008056b92 brGrnLedOff + 0x00000000080570b4 PATH_OUT + 0x0000000008056bd5 brGetT1Data + 0x0000000008056bde brGetT2Data + 0x0000000008056bcd brGetT3Len + 0x0000000008056b89 brGrnLedOn + 0x0000000008056bbd brGetT1Len + 0x0000000008056be7 brGetT3Data + 0x0000000008056b83 brACK + .rodata.str1.1 + 0x00000000080574f8 0xb5 /g3/lib/libhid.a(hid_initialisation.o) + *fill* 0x00000000080575ad 0x13 00 + .rodata.str1.32 + 0x00000000080575c0 0x289 /g3/lib/libhid.a(hid_initialisation.o) + .rodata.str1.1 + 0x0000000008057849 0x1f3 /g3/lib/libhid.a(hid_opening.o) + 0x216 (size before relaxing) + *fill* 0x0000000008057a3c 0x4 00 + .rodata.str1.32 + 0x0000000008057a40 0x6b4 /g3/lib/libhid.a(hid_opening.o) + .rodata.str1.1 + 0x00000000080580f4 0x128 /g3/lib/libhid.a(hid_parsing.o) + 0x18e (size before relaxing) + *fill* 0x000000000805821c 0x4 00 + .rodata.str1.32 + 0x0000000008058220 0x6c6 /g3/lib/libhid.a(hid_parsing.o) + 0x706 (size before relaxing) + .rodata.str1.1 + 0x00000000080588e6 0x130 /g3/lib/libhid.a(hid_exchange.o) + 0x168 (size before relaxing) + *fill* 0x0000000008058a16 0xa 00 + .rodata.str1.32 + 0x0000000008058a20 0x62a /g3/lib/libhid.a(hid_exchange.o) + 0x66a (size before relaxing) + .rodata.str1.1 + 0x000000000805904a 0x173 /g3/lib/libhid.a(debug.o) + *fill* 0x00000000080591bd 0x3 00 + .rodata.str1.32 + 0x00000000080591c0 0x56a /g3/lib/libhid.a(debug.o) + .rodata 0x000000000805972a 0x4 /g3/lib/libhid.a(hidparser.o) + 0x000000000805972a ItemSize + .rodata.str1.1 + 0x000000000805972e 0x13 /g3/lib/libhid.a(linux.o) + 0x36 (size before relaxing) + *fill* 0x0000000008059741 0x1f 00 + .rodata.str1.32 + 0x0000000008059760 0x13a /g3/lib/libhid.a(linux.o) + 0x1a0 (size before relaxing) + .rodata.str1.1 + 0x000000000805989a 0x78 /g3/lib/libhid.a(hid_preparation.o) + 0xca (size before relaxing) + *fill* 0x0000000008059912 0xe 00 + .rodata.str1.32 + 0x0000000008059920 0x367 /g3/lib/libhid.a(hid_preparation.o) + 0x3a7 (size before relaxing) + .rodata.str1.1 + 0x0000000008059c87 0x11 /g3/lib/libusb.a(usb.o) + *fill* 0x0000000008059c98 0x8 00 + .rodata.str1.32 + 0x0000000008059ca0 0x33 /g3/lib/libusb.a(usb.o) + .rodata.str1.1 + 0x0000000008059cd3 0x17 /g3/lib/libusb.a(error.o) + .rodata.str1.1 + 0x0000000008059cea 0xb2 /g3/lib/libusb.a(descriptors.o) + 0xb5 (size before relaxing) + *fill* 0x0000000008059d9c 0x4 00 + .rodata.str1.32 + 0x0000000008059da0 0x3d1 /g3/lib/libusb.a(descriptors.o) + .rodata.str1.1 + 0x000000000805a171 0x159 /g3/lib/libusb.a(linux.o) + 0x19c (size before relaxing) + *fill* 0x000000000805a2ca 0x16 00 + .rodata.str1.32 + 0x000000000805a2e0 0x475 /g3/lib/libusb.a(linux.o) + 0x515 (size before relaxing) + +.rodata1 + *(.rodata1) + +.eh_frame_hdr + *(.eh_frame_hdr) + 0x000000000805a755 . = (ALIGN (0x1000) - ((0x1000 - .) & 0xfff)) + 0x000000000805b000 . = (0x1000 DATA_SEGMENT_ALIGN 0x1000) + 0x000000000805b000 . = ALIGN (0x4) + 0x000000000805b000 PROVIDE (__preinit_array_start, .) + +.preinit_array + *(.preinit_array) + 0x000000000805b000 PROVIDE (__preinit_array_end, .) + 0x000000000805b000 PROVIDE (__init_array_start, .) + +.init_array + *(.init_array) + 0x000000000805b000 PROVIDE (__init_array_end, .) + 0x000000000805b000 PROVIDE (__fini_array_start, .) + +.fini_array + *(.fini_array) + 0x000000000805b000 PROVIDE (__fini_array_end, .) + +.data 0x000000000805b000 0x1484 + *(.data .data.* .gnu.linkonce.d.*) + .data 0x000000000805b000 0x4 /usr/lib/crt1.o + 0x000000000805b000 data_start + 0x000000000805b000 __data_start + .data 0x000000000805b004 0x8 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + 0x000000000805b004 __dso_handle + .data 0x000000000805b00c 0x28 libcard.a(card_lin.o) + 0x000000000805b030 xico_tracks1and2 + 0x000000000805b010 xico_led_on + 0x000000000805b02c xico_track2only + 0x000000000805b01c xico_version + 0x000000000805b028 xico_track1only + 0x000000000805b00c xico_led_off + 0x000000000805b014 xico_led_auto + 0x000000000805b024 xico_headeron + 0x000000000805b020 xico_headeroff + 0x000000000805b018 xico_watchdog + .data 0x000000000805b034 0x1 /g3/lib/libhid.a(hid_initialisation.o) + *fill* 0x000000000805b035 0x3 00 + .data 0x000000000805b038 0x8 /g3/lib/libhid.a(debug.o) + 0x000000000805b03c hid_debug_stream + 0x000000000805b038 hid_debug_level + .data 0x000000000805b040 0x8 /g3/lib/libusb.a(usb.o) + 0x000000000805b040 usb_debug + 0x000000000805b044 usb_busses + *fill* 0x000000000805b048 0x18 00 + .data 0x000000000805b060 0x408 /g3/lib/libusb.a(error.o) + 0x000000000805b060 usb_error_str + 0x000000000805b464 usb_error_type + 0x000000000805b460 usb_error_errno + *fill* 0x000000000805b468 0x18 00 + .data 0x000000000805b480 0x1001 /g3/lib/libusb.a(linux.o) + *fill* 0x000000000805c481 0x3 00 + +.data1 + *(.data1) + +.tdata + *(.tdata .tdata.* .gnu.linkonce.td.*) + +.tbss + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + +.eh_frame 0x000000000805c484 0x4 + *(.eh_frame) + .eh_frame 0x000000000805c484 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.gcc_except_table + *(.gcc_except_table) + +.dynamic 0x000000000805c488 0xd8 + *(.dynamic) + .dynamic 0x000000000805c488 0xd8 /usr/lib/crt1.o + 0x000000000805c488 _DYNAMIC + +.ctors 0x000000000805c560 0x8 + *crtbegin*.o(.ctors) + *(EXCLUDE_FILE(*crtend*.o) .ctors) + .ctors 0x000000000805c560 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + *(SORT(.ctors.*)) + *(.ctors) + .ctors 0x000000000805c564 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.dtors 0x000000000805c568 0x8 + *crtbegin*.o(.dtors) + *(EXCLUDE_FILE(*crtend*.o) .dtors) + .dtors 0x000000000805c568 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + *(SORT(.dtors.*)) + *(.dtors) + .dtors 0x000000000805c56c 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.jcr 0x000000000805c570 0x4 + *(.jcr) + .jcr 0x000000000805c570 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.got 0x000000000805c574 0xd0 + *(.got.plt) + .got.plt 0x000000000805c574 0xc0 /usr/lib/crt1.o + 0x000000000805c574 _GLOBAL_OFFSET_TABLE_ + *(.got) + .got 0x000000000805c634 0x10 /usr/lib/crt1.o + 0x000000000805c644 _edata = . + 0x000000000805c644 PROVIDE (edata, .) + 0x000000000805c644 __bss_start = . + +.bss 0x000000000805c660 0x8b4 + *(.dynbss) + .dynbss 0x000000000805c660 0x4 /usr/lib/crt1.o + 0x000000000805c660 stderr@@GLIBC_2.0 + *(.bss .bss.* .gnu.linkonce.b.*) + .bss 0x000000000805c664 0x1 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + *fill* 0x000000000805c665 0x3 00 + .bss 0x000000000805c668 0x10 cardtest.o + 0x000000000805c66c numsuccesst1 + 0x000000000805c670 numsuccesst2 + 0x000000000805c674 numfails + 0x000000000805c668 numswipes + .bss 0x000000000805c678 0x4 libcard.a(card.o) + 0x000000000805c678 cardReady + .bss 0x000000000805c67c 0x4 libcard.a(card_lin.o) + *(COMMON) + COMMON 0x000000000805c680 0xfc cardtest.o + 0x0 (size before relaxing) + 0x000000000805c680 asciibuf + 0x000000000805c700 rawtio + 0x000000000805c740 savetio + *fill* 0x000000000805c77c 0x4 00 + COMMON 0x000000000805c780 0x794 libcard.a(card.o) + 0x0 (size before relaxing) + 0x000000000805c780 cardData + 0x000000000805c800 cardMem + 0x000000000805cf10 cardDev + 0x000000000805cf14 . = ALIGN (0x4) + 0x000000000805cf14 . = ALIGN (0x4) + 0x000000000805cf14 _end = . + 0x000000000805cf14 PROVIDE (end, .) + 0x000000000805cf14 . = DATA_SEGMENT_END (.) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x17a + *(.comment) + .comment 0x0000000000000000 0x12 /usr/lib/crt1.o + .comment 0x0000000000000012 0x12 /usr/lib/crti.o + .comment 0x0000000000000024 0x12 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .comment 0x0000000000000036 0x12 cardtest.o + .comment 0x0000000000000048 0x12 libcard.a(card.o) + .comment 0x000000000000005a 0x12 libcard.a(card_lin.o) + .comment 0x000000000000006c 0x12 /g3/lib/libhid.a(hid_initialisation.o) + .comment 0x000000000000007e 0x12 /g3/lib/libhid.a(hid_opening.o) + .comment 0x0000000000000090 0x12 /g3/lib/libhid.a(hid_parsing.o) + .comment 0x00000000000000a2 0x12 /g3/lib/libhid.a(hid_exchange.o) + .comment 0x00000000000000b4 0x12 /g3/lib/libhid.a(debug.o) + .comment 0x00000000000000c6 0x12 /g3/lib/libhid.a(hidparser.o) + .comment 0x00000000000000d8 0x12 /g3/lib/libhid.a(linux.o) + .comment 0x00000000000000ea 0x12 /g3/lib/libhid.a(hid_preparation.o) + .comment 0x00000000000000fc 0x12 /g3/lib/libusb.a(usb.o) + .comment 0x000000000000010e 0x12 /g3/lib/libusb.a(error.o) + .comment 0x0000000000000120 0x12 /g3/lib/libusb.a(descriptors.o) + .comment 0x0000000000000132 0x12 /g3/lib/libusb.a(linux.o) + .comment 0x0000000000000144 0x12 /usr/lib/libc_nonshared.a(elf-init.oS) + .comment 0x0000000000000156 0x12 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + .comment 0x0000000000000168 0x12 /usr/lib/crtn.o + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges 0x0000000000000000 0x138 + *(.debug_aranges) + .debug_aranges + 0x0000000000000000 0x30 /usr/lib/crti.o + .debug_aranges + 0x0000000000000030 0x20 cardtest.o + .debug_aranges + 0x0000000000000050 0x20 libcard.a(card.o) + .debug_aranges + 0x0000000000000070 0x20 libcard.a(card_lin.o) + .debug_aranges + 0x0000000000000090 0x20 /g3/lib/libusb.a(usb.o) + .debug_aranges + 0x00000000000000b0 0x20 /g3/lib/libusb.a(error.o) + .debug_aranges + 0x00000000000000d0 0x20 /g3/lib/libusb.a(descriptors.o) + .debug_aranges + 0x00000000000000f0 0x20 /g3/lib/libusb.a(linux.o) + .debug_aranges + 0x0000000000000110 0x28 /usr/lib/crtn.o + +.debug_pubnames + 0x0000000000000000 0x9e1 + *(.debug_pubnames) + .debug_pubnames + 0x0000000000000000 0x25 /usr/lib/crt1.o + .debug_pubnames + 0x0000000000000025 0x10a cardtest.o + .debug_pubnames + 0x000000000000012f 0x14d libcard.a(card.o) + .debug_pubnames + 0x000000000000027c 0x37f libcard.a(card_lin.o) + .debug_pubnames + 0x00000000000005fb 0x103 /g3/lib/libusb.a(usb.o) + .debug_pubnames + 0x00000000000006fe 0x5c /g3/lib/libusb.a(error.o) + .debug_pubnames + 0x000000000000075a 0xc3 /g3/lib/libusb.a(descriptors.o) + .debug_pubnames + 0x000000000000081d 0x1c4 /g3/lib/libusb.a(linux.o) + +.debug_info 0x0000000000000000 0x1194d + *(.debug_info .gnu.linkonce.wi.*) + .debug_info 0x0000000000000000 0x89c /usr/lib/crt1.o + .debug_info 0x000000000000089c 0x68 /usr/lib/crti.o + .debug_info 0x0000000000000904 0x1d5e cardtest.o + .debug_info 0x0000000000002662 0x2e09 libcard.a(card.o) + .debug_info 0x000000000000546b 0x386b libcard.a(card_lin.o) + .debug_info 0x0000000000008cd6 0x2366 /g3/lib/libusb.a(usb.o) + .debug_info 0x000000000000b03c 0x15e4 /g3/lib/libusb.a(error.o) + .debug_info 0x000000000000c620 0x247d /g3/lib/libusb.a(descriptors.o) + .debug_info 0x000000000000ea9d 0x2e48 /g3/lib/libusb.a(linux.o) + .debug_info 0x00000000000118e5 0x68 /usr/lib/crtn.o + +.debug_abbrev 0x0000000000000000 0x12d2 + *(.debug_abbrev) + .debug_abbrev 0x0000000000000000 0x104 /usr/lib/crt1.o + .debug_abbrev 0x0000000000000104 0x10 /usr/lib/crti.o + .debug_abbrev 0x0000000000000114 0x285 cardtest.o + .debug_abbrev 0x0000000000000399 0x2af libcard.a(card.o) + .debug_abbrev 0x0000000000000648 0x2bc libcard.a(card_lin.o) + .debug_abbrev 0x0000000000000904 0x2df /g3/lib/libusb.a(usb.o) + .debug_abbrev 0x0000000000000be3 0x166 /g3/lib/libusb.a(error.o) + .debug_abbrev 0x0000000000000d49 0x2b2 /g3/lib/libusb.a(descriptors.o) + .debug_abbrev 0x0000000000000ffb 0x2c7 /g3/lib/libusb.a(linux.o) + .debug_abbrev 0x00000000000012c2 0x10 /usr/lib/crtn.o + +.debug_line 0x0000000000000000 0x1aa2 + *(.debug_line) + .debug_line 0x0000000000000000 0xce /usr/lib/crt1.o + .debug_line 0x00000000000000ce 0x8e /usr/lib/crti.o + .debug_line 0x000000000000015c 0x250 cardtest.o + .debug_line 0x00000000000003ac 0x338 libcard.a(card.o) + .debug_line 0x00000000000006e4 0x6d4 libcard.a(card_lin.o) + .debug_line 0x0000000000000db8 0x2b6 /g3/lib/libusb.a(usb.o) + .debug_line 0x000000000000106e 0x160 /g3/lib/libusb.a(error.o) + .debug_line 0x00000000000011ce 0x3e8 /g3/lib/libusb.a(descriptors.o) + .debug_line 0x00000000000015b6 0x480 /g3/lib/libusb.a(linux.o) + .debug_line 0x0000000000001a36 0x6c /usr/lib/crtn.o + +.debug_frame 0x0000000000000000 0xc24 + *(.debug_frame) + .debug_frame 0x0000000000000000 0x14 /usr/lib/crt1.o + .debug_frame 0x0000000000000014 0xf4 cardtest.o + .debug_frame 0x0000000000000108 0x180 libcard.a(card.o) + .debug_frame 0x0000000000000288 0x2d8 libcard.a(card_lin.o) + .debug_frame 0x0000000000000560 0x190 /g3/lib/libusb.a(usb.o) + .debug_frame 0x00000000000006f0 0x30 /g3/lib/libusb.a(error.o) + .debug_frame 0x0000000000000720 0x14c /g3/lib/libusb.a(descriptors.o) + .debug_frame 0x000000000000086c 0x3b8 /g3/lib/libusb.a(linux.o) + +.debug_str 0x0000000000000000 0x3914 + *(.debug_str) + .debug_str 0x0000000000000000 0x674 /usr/lib/crt1.o + 0x6b4 (size before relaxing) + .debug_str 0x0000000000000674 0x1a0c cardtest.o + 0x21f1 (size before relaxing) + .debug_str 0x0000000000002080 0xc87 libcard.a(card.o) + 0x2e08 (size before relaxing) + .debug_str 0x0000000000002d07 0x4a7 libcard.a(card_lin.o) + 0x31c1 (size before relaxing) + .debug_str 0x00000000000031ae 0x1ae /g3/lib/libusb.a(usb.o) + 0x24a3 (size before relaxing) + .debug_str 0x000000000000335c 0x42 /g3/lib/libusb.a(error.o) + 0x1d92 (size before relaxing) + .debug_str 0x000000000000339e 0x195 /g3/lib/libusb.a(descriptors.o) + 0x25b9 (size before relaxing) + .debug_str 0x0000000000003533 0x3e1 /g3/lib/libusb.a(linux.o) + 0x2931 (size before relaxing) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +/DISCARD/ + *(.note.GNU-stack) +OUTPUT(cardtest elf32-i386) + +.debug_ranges 0x0000000000000000 0x278 + .debug_ranges 0x0000000000000000 0xf8 /g3/lib/libusb.a(usb.o) + .debug_ranges 0x00000000000000f8 0xd8 /g3/lib/libusb.a(descriptors.o) + .debug_ranges 0x00000000000001d0 0xa8 /g3/lib/libusb.a(linux.o) diff --git a/libraries/pmrt/card/Debug/card.lib b/libraries/pmrt/card/Debug/card.lib new file mode 100755 index 0000000..5ca37b4 Binary files /dev/null and b/libraries/pmrt/card/Debug/card.lib differ diff --git a/libraries/pmrt/card/Debug/card.obj b/libraries/pmrt/card/Debug/card.obj new file mode 100755 index 0000000..e26a214 Binary files /dev/null and b/libraries/pmrt/card/Debug/card.obj differ diff --git a/libraries/pmrt/card/Debug/card.pch b/libraries/pmrt/card/Debug/card.pch new file mode 100755 index 0000000..f379aea Binary files /dev/null and b/libraries/pmrt/card/Debug/card.pch differ diff --git a/libraries/pmrt/card/Debug/card_lin.obj b/libraries/pmrt/card/Debug/card_lin.obj new file mode 100755 index 0000000..1595a8d Binary files /dev/null and b/libraries/pmrt/card/Debug/card_lin.obj differ diff --git a/libraries/pmrt/card/Debug/card_pc.obj b/libraries/pmrt/card/Debug/card_pc.obj new file mode 100755 index 0000000..f680c1a Binary files /dev/null and b/libraries/pmrt/card/Debug/card_pc.obj differ diff --git a/libraries/pmrt/card/Debug/vc60.idb b/libraries/pmrt/card/Debug/vc60.idb new file mode 100755 index 0000000..dd68df6 Binary files /dev/null and b/libraries/pmrt/card/Debug/vc60.idb differ diff --git a/libraries/pmrt/card/Debug/vc60.pdb b/libraries/pmrt/card/Debug/vc60.pdb new file mode 100755 index 0000000..37e7bf3 Binary files /dev/null and b/libraries/pmrt/card/Debug/vc60.pdb differ diff --git a/libraries/pmrt/card/Magnetic Card Data Format.doc b/libraries/pmrt/card/Magnetic Card Data Format.doc new file mode 100755 index 0000000..3428d45 Binary files /dev/null and b/libraries/pmrt/card/Magnetic Card Data Format.doc differ diff --git a/libraries/pmrt/card/Release/card.lib b/libraries/pmrt/card/Release/card.lib new file mode 100755 index 0000000..feb7bff Binary files /dev/null and b/libraries/pmrt/card/Release/card.lib differ diff --git a/libraries/pmrt/card/Release/card.obj b/libraries/pmrt/card/Release/card.obj new file mode 100755 index 0000000..d9d560f Binary files /dev/null and b/libraries/pmrt/card/Release/card.obj differ diff --git a/libraries/pmrt/card/Release/card.pch b/libraries/pmrt/card/Release/card.pch new file mode 100755 index 0000000..093d1aa Binary files /dev/null and b/libraries/pmrt/card/Release/card.pch differ diff --git a/libraries/pmrt/card/Release/card_lin.obj b/libraries/pmrt/card/Release/card_lin.obj new file mode 100755 index 0000000..acbe834 Binary files /dev/null and b/libraries/pmrt/card/Release/card_lin.obj differ diff --git a/libraries/pmrt/card/Release/card_pc.obj b/libraries/pmrt/card/Release/card_pc.obj new file mode 100755 index 0000000..4bac5de Binary files /dev/null and b/libraries/pmrt/card/Release/card_pc.obj differ diff --git a/libraries/pmrt/card/Release/vc60.idb b/libraries/pmrt/card/Release/vc60.idb new file mode 100755 index 0000000..31b5062 Binary files /dev/null and b/libraries/pmrt/card/Release/vc60.idb differ diff --git a/libraries/pmrt/card/card.c b/libraries/pmrt/card/card.c new file mode 100755 index 0000000..d35a3c0 --- /dev/null +++ b/libraries/pmrt/card/card.c @@ -0,0 +1,620 @@ +// +// card.c +// card reader library +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// GNP 24 Jul 07; XICO support +// + +// include files +#include "card.h" +#include "cardpriv.h" +#include +#include +#include +#include + +// local definitions + +// global data +int cardReady=0; +sCardDev cardMem,*cardDev; +sCardData cardData; + +// define check +#if (CARD_TRACK_NAME_LENGTH > CARD_NAME_LENGTH) +#error must increase size of CARD_NAME_LENGTH +#endif + +// local data + +// global functions + +// forward + +// +// CardInit +// called once at system start +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int CardInit(void) +{ + int ec=0; + + cardDev=NULL; + cardReady=0; + memset(&cardMem,0,sizeof(cardMem)); + memset(&cardData,0,sizeof(cardData)); + + if((ec=cardDrvrInit(&cardMem))<0) + goto BAIL; + + cardMem.bufsize=4096; + if(!(cardMem.buf=card_apphook_malloc(cardMem.bufsize))) + { + ec=ERR_CARD_MEM; + goto BAIL; + } + + cardDev=&cardMem; + cardDev->iComPort = CARD_IOPORT_DEFAULT; // Open COM Port # + cardDev->iBaudRate = CARD_BAUD_DEFAULT; // baudrate + +//DONE("CardInit") +BAIL: + return(ec); +} // CardInit + +// +// CardFinal +// called once at system shutdown +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +void CardFinal(void) +{ + if(cardDev) + cardDrvrFinal(cardDev); + + // free alloc'd memory + if(cardMem.buf) + card_apphook_free(cardMem.buf); + cardMem.buf=NULL; + + cardDev=NULL; +//DONE("CardFinal") +} // CardFinal + +// +// CardBegin +// start the card reader +// +// in: +// out: +// global: +// +// GNP 19 Feb 07 +// +int CardBegin(int readerType) +{ + int ec=0; + if(cardDev && (readerType < NUM_CARDREADERS)) + { + cardDev->flags = 0; + cardDev->errorf = 0; + cardDev->readerType = readerType; + ec=cardDrvrOpen(cardDev); + } + else + ec=-1; +//DONE("CardBegin") + return(ec); +} // CardBegin + +// +// CardEnd +// +// +// in: +// out: +// global: +// +// GNP 19 Feb 07 +// +void CardEnd(void) +{ + if(cardDev) + cardDrvrClose(cardDev); +//DONE("CardEnd") +} // CardEnd + +// +// CardChangePortSettings +// change the port settings for the card reader +// +// in: +// port = com port # +// baud = baud rate +// out: +// global: +// +// GNP 19 Feb 07 +// +int CardChangePortSettings(unsigned int port, unsigned long baud) +{ + int ec=0; + + if (cardDev) + { + cardDev->iComPort = port; // Open COM Port # + cardDev->iBaudRate = baud; // baudrate + if (cardDrvrIsRunning(cardDev)) + { + // close and open with new baud + cardDrvrClose(cardDev); + ec=cardDrvrOpen(cardDev); + } + } + else + ec = -1; +//DONE("CardChangePortSettings") + return(ec); +} // CardChangePortSettings + +// +// CardGetVersionString +// get version string of card driver +// +// in: +// buf = ptr to return buffer +// bufSize = size of return buffer +// out: +// global: +// +// GNP 19 Feb 07 +// +void CardGetVersionString(char *buf, int bufSize) +{ + int i; + char *s1; + + i=bufSize-1; + s1=CARD_VER_STRING; + while(i>0 && *s1) + *buf++=*s1++,i--; + s1=CARDPRIV_VER_STRING; + while(i>0 && *s1) + *buf++=*s1++,i--; + *buf=0; +//DONE("CardGetVersionString") +} // CardGetVersionString + +// +// CardSetCallback +// set the callback function for card stuff +// +// in: +// out: +// global: +// +// GNP 28 Feb 07 +// +int CardSetCallback(void *callback) +{ + sCardDev *cdev; + + if(!(cdev=cardGetDevice())) + return(ERR_CARD_DEVICE_NOTAVAILABLE); + + cdev->callback = callback; +//DONE("CardSetCallback") + return(0); +} // CardSetCallback + +// +// cardClearPlayerData +// clear the deciphered card data +// +// in: +// out: +// global: +// +// GNP 26 Feb 07 +// +void cardClearPlayerData(sCardData *cData) +{ + cData->bOperator = 0; + cData->id = 0; + cData->gameNumber = 0; + cData->countryCode = 0; + cData->cardId = 0; + cData->firstName[0] = 0; + cData->middleName[0] = 0; + cData->lastName[0] = 0; +//DONE("cardClearPlayerData") +} // cardClearPlayerData + +void luhnsub(unsigned long n,int ns,int *pbt,int *acc) +{ + int i,j,k,bytwo=*pbt; + + for (i=0;icardId; + + acc=0; + luhnsub(cData->cardId,CARD_TRACK_CID_LENGTH,&bytwo,&acc); + luhnsub(cData->countryCode ,CARD_TRACK_COUNTRY_LENGTH,&bytwo,&acc); + luhnsub(cData->gameNumber ,CARD_TRACK_GAME_LENGTH,&bytwo,&acc); + luhnsub(cData->id ,CARD_TRACK_ID_LENGTH,&bytwo,&acc); + luhnsub(CARD_TRACK_PAN_INT ,CARD_TRACK_PAN_LENGTH,&bytwo,&acc); + + acc += chkDig; + + if(acc%10) + { +// printf("luhn fail\n"); + return(-1); + } + else + { +// printf("luhn success\n"); + return(0); + } +} //cardLUHNCheck +// +// cardPullNumbers +// pull the id numbers from the card format +// +// in: +// cData = card data struct +// numBuf = ptr to number string +// out: +// 0 = success, <0 fail +// global: +// +// GNP 27 Feb 07 +// +int cardPullNumbers(sCardData *cData, char *numBuf) +{ + char *buf,tmpNums[CARD_TRACK_ID_LENGTH+CARD_TRACK_GAME_LENGTH+CARD_TRACK_COUNTRY_LENGTH+CARD_TRACK_CID_LENGTH+CARD_TRACK_CHKDIG_LENGTH+8]; + int i; + unsigned long chkDig; + + buf = tmpNums; + for (i=0;iid),&(cData->gameNumber),&(cData->countryCode),&(cData->cardId),&chkDig); + + // put LUHN check here + + if (i==5) + { + return(cardLUHNCheck(cData,chkDig)); + } + else + return(-1); +//DONE("cardPullNumbers") +} // cardPullNumbers + +// +// CardLoop +// +// +// in: +// out: +// global: +// +// GNP 26 Feb 07 +// +int CardLoop(void) +{ + sCardDev *cdev; + int dataFail; + sTrack1Data *buft1; + sTrack2Data *buft2; + char *buf1,*buf2; + int i; + sCardData *cData = &cardData; + + if(!(cdev=cardGetDevice())) + return(ERR_CARD_DEVICE_NOTAVAILABLE); + + dataFail=0; + + // check for card inserted + if ((cdev->intFlags & M_CARD_INTFLAGS_CARDIN) + && !(cdev->flags & M_CARD_FLAGS_CARDIN_PROCESSED)) + { + cdev->flags |= M_CARD_FLAGS_CARDIN_PROCESSED; + cdev->flags &= ~(M_CARD_FLAGS_DATA1_PROCESSED|M_CARD_FLAGS_DATA2_PROCESSED|M_CARD_FLAGS_DATA3_PROCESSED|M_CARD_FLAGS_DATA_EXPECTED|M_CARD_FLAGS_NODATA_PROCESSED); + if(cdev->callback) + (*cdev->callback)(CARDCALLBACK_CARDIN); + } + // check for card pulled out + else if (!(cdev->intFlags & M_CARD_INTFLAGS_CARDIN) + && (cdev->flags & M_CARD_FLAGS_CARDIN_PROCESSED)) + { + cdev->flags &= ~M_CARD_FLAGS_CARDIN_PROCESSED; + cdev->flags |= M_CARD_FLAGS_DATA_EXPECTED; // we now expect to see card data + if(cdev->callback) + (*cdev->callback)(CARDCALLBACK_CARDOUT); + } + // look for card data on track 1 + if (cdev->intFlags & M_CARD_INTFLAGS_DATA1) + { + // data is here + if (!(cdev->flags & M_CARD_FLAGS_DATA1_PROCESSED) && (cdev->flags & M_CARD_FLAGS_DATA_EXPECTED)) + { + // not processed, let's do it + dataFail=-1; // default to fail + cardClearPlayerData(cData); + buft1 = (sTrack1Data*)(cdev->TrackData[0]); + if ((cdev->TrackLen[0] == sizeof(sTrack1Data)) + && (buft1->fc == CARD_TRACK1_FC) + && (strncmp(CARD_TRACK_PAN,buft1->pan,CARD_TRACK_PAN_LENGTH) ==0) + && ((buft1->fs1 == CARD_TRACK_FS_PLAYER) + || (buft1->fs1 == CARD_TRACK_FS_OPERATOR)) + ) + { + // card data appears valid for PMRT + if(buft1->fs1 == CARD_TRACK_FS_OPERATOR) + cData->bOperator=1; // indicate operator card + + // pull name + buf1 = buft1->name; + buf2 = NULL; + for (i=0;ifirstName; + for (;imiddleName; + for (;iname; + buf2 = cData->lastName; + for (i=0;iname; + buf2 = cData->firstName; + for (i=0;iid) >= 0) + { + // we have pulled the info from track 1, so no need to process track 2 + // clearing this flag will make code ignore track 2 + cdev->flags &= ~M_CARD_FLAGS_DATA_EXPECTED; + dataFail=0; + if(cdev->callback) + (*cdev->callback)(CARDCALLBACK_TRACK1DATA,cData); + } + } + cdev->flags |= M_CARD_FLAGS_DATA1_PROCESSED; + } + + } + else + cdev->flags &= ~M_CARD_FLAGS_DATA1_PROCESSED; + + // look for card data on track 2 + if (cdev->intFlags & M_CARD_INTFLAGS_DATA2) + { + // data is here + if (!(cdev->flags & M_CARD_FLAGS_DATA2_PROCESSED) && (cdev->flags & M_CARD_FLAGS_DATA_EXPECTED)) + { + // not processed, let's do it + dataFail=-1; // default to fail + cardClearPlayerData(cData); + buft2 = (sTrack2Data*)(cdev->TrackData[1]); + if ((cdev->TrackLen[1] == sizeof(sTrack2Data)) + && (strncmp(CARD_TRACK_PAN,buft2->pan,CARD_TRACK_PAN_LENGTH) ==0) + && ((buft2->fs1 == CARD_TRACK_FS_PLAYER) + || (buft2->fs1 == CARD_TRACK_FS_OPERATOR)) + ) + { + // card data appears valid for PMRT + if(buft2->fs1 == CARD_TRACK_FS_OPERATOR) + cData->bOperator=1; // indicate operator card + + if(cardPullNumbers(cData,buft2->id)>=0) + { + cdev->flags &= ~M_CARD_FLAGS_DATA_EXPECTED; + if(cdev->callback) + (*cdev->callback)(CARDCALLBACK_TRACK2DATA,cData); + dataFail=0; + } + } + cdev->flags |= M_CARD_FLAGS_DATA2_PROCESSED; + } + } + else + cdev->flags &= ~M_CARD_FLAGS_DATA2_PROCESSED; + + // look for no data on card swipe + if (cdev->intFlags & M_CARD_INTFLAGS_NODATA) + { + // data is here + if (!(cdev->flags & M_CARD_FLAGS_NODATA_PROCESSED) && (cdev->flags & M_CARD_FLAGS_DATA_EXPECTED)) + { + // not processed, let's do it + if(cdev->callback) + (*cdev->callback)(CARDCALLBACK_NODATA,cData); + cdev->flags |= M_CARD_FLAGS_NODATA_PROCESSED; + } + } + else + cdev->flags &= ~M_CARD_FLAGS_NODATA_PROCESSED; + + + // clear any requests that have been acknowledged + if (cdev->flags & M_CARD_FLAGS_FLUSHIO + && cdev->intFlags & M_CARD_INTFLAGS_FLUSHIO_ACK) + cdev->flags &= ~M_CARD_FLAGS_FLUSHIO; + + if (cdev->flags & M_CARD_FLAGS_SELECTMAG + && cdev->intFlags & M_CARD_INTFLAGS_SELECTMAG_ACK) + cdev->flags &= ~M_CARD_FLAGS_SELECTMAG; + + if (dataFail<0) + { + if(cdev->callback) + (*cdev->callback)(CARDCALLBACK_DATAERROR); + } +//DONE("CardLoop") + return(0); +} // CardLoop + +int CardFlushIO(void) +{ + sCardDev *cdev; + + if(!(cdev=cardGetDevice())) + return(ERR_CARD_DEVICE_NOTAVAILABLE); + + cdev->flags |= M_CARD_FLAGS_FLUSHIO; + return(0); +} //CardFlushIO + +int CardSelectMag(void) +{ + sCardDev *cdev; + + if(!(cdev=cardGetDevice())) + return(ERR_CARD_DEVICE_NOTAVAILABLE); + + cdev->flags |= M_CARD_FLAGS_SELECTMAG; + return(0); +} //CardSelectMag + +// +// cardGetDevice +// returns the device ptr for the card reader +// +// in: +// out: +// ptr to device, NULL if no device +// global: +// +// GNP 21 Feb 07 +// +sCardDev *cardGetDevice(void) +{ + if(cardDev) + return(&cardMem); + else + return(NULL); +//DONE("cardGetDevice") +} // cardGetDevice + +// EOF diff --git a/libraries/pmrt/card/card.dsp b/libraries/pmrt/card/card.dsp new file mode 100755 index 0000000..15502a5 --- /dev/null +++ b/libraries/pmrt/card/card.dsp @@ -0,0 +1,122 @@ +# Microsoft Developer Studio Project File - Name="card" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=card - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "card.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "card.mak" CFG="card - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "card - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "card - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/card", KJMAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "card - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copying card files +PostBuild_Cmds=copy Release\card.lib c:\g3\lib copy card.h c:\g3\include +# End Special Build Tool + +!ELSEIF "$(CFG)" == "card - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "SYS_PC" /D "WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Copying card files +PostBuild_Cmds=copy Debug\card.lib c:\g3\lib copy card.h c:\g3\include +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "card - Win32 Release" +# Name "card - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\card.c +# End Source File +# Begin Source File + +SOURCE=.\card_lin.c +# End Source File +# Begin Source File + +SOURCE=.\card_pc.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\card.h +# End Source File +# Begin Source File + +SOURCE=.\cardpriv.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/card/card.dsw b/libraries/pmrt/card/card.dsw new file mode 100755 index 0000000..fed4a84 --- /dev/null +++ b/libraries/pmrt/card/card.dsw @@ -0,0 +1,44 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "card"=.\card.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "cardtest"=.\cardtest.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name card + End Project Dependency +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/card/card.h b/libraries/pmrt/card/card.h new file mode 100755 index 0000000..5bba76e --- /dev/null +++ b/libraries/pmrt/card/card.h @@ -0,0 +1,94 @@ +// +// card.h +// card reader header +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// +#ifndef CARD_H +#define CARD_H + +#define CARD_VER_STRING "3" + +#define CARD_NAME_LENGTH 32 + +// +// sCardData +// card data after it has been deciphered +// +typedef struct { + unsigned int bOperator; + unsigned long id; + unsigned long gameNumber; + unsigned long countryCode; + unsigned long cardId; + char firstName[CARD_NAME_LENGTH]; + char lastName[CARD_NAME_LENGTH]; + char middleName[CARD_NAME_LENGTH]; +} sCardData; + +// +// CARDCALLBACK_ +// callback reasons +// +enum { + CARDCALLBACK_TRACK1DATA=1, // track 1 data received + CARDCALLBACK_TRACK2DATA, // track 2 data received + CARDCALLBACK_DATAERROR, // data not formatted correctly + CARDCALLBACK_CARDIN, // card has been inserted + CARDCALLBACK_CARDOUT, // card has been pulled out + CARDCALLBACK_NODATA, // no data retrieved from card +}; + +// +// CARDREADER_ +// card reader type enumerations +// +enum { + CARDREADER_SINGULAR, // Singular Tech + CARDREADER_XICO, // XICO + NUM_CARDREADERS +}; + +/////////////////////////////////////////////////////////////////////////////// +// ERROR CODES +/////////////////////////////////////////////////////////////////////////////// +// +// ERRORS & EXTENDED RETURN CODES +// +// -1.....-8999 user +// -9000..-9099 system +// +enum // int16 +{ + // system + ERR_CARD_SYS_LAST=-9099, + ERR_CARD_DEVICE_NOTAVAILABLE, + ERR_CARD_MEM, + ERR_CARD_SYS_FIRST=-9000, + +}; // ERR_ + +extern int CardInit(void); +extern int CardBegin(int readerType); +extern void CardEnd(void); +extern void CardFinal(void); +extern int CardChangePortSettings(unsigned int port, unsigned long baud); +extern void CardGetVersionString(char *buf, int bufSize); +extern int CardSetCallback(void *callback); +extern int CardLoop(void); +extern int CardFlushIO(void); +extern int CardSelectMag(void); + +#define msg card_apphook_msg + +// apphook +extern void* card_apphook_malloc(int size); +extern void card_apphook_free(void *m); +extern void card_apphook_msg(char *fmt,...); + +#endif // ndef CARD_H +// EOF diff --git a/libraries/pmrt/card/card.o b/libraries/pmrt/card/card.o new file mode 100644 index 0000000..f9216f6 Binary files /dev/null and b/libraries/pmrt/card/card.o differ diff --git a/libraries/pmrt/card/card.plg b/libraries/pmrt/card/card.plg new file mode 100755 index 0000000..3b2d120 --- /dev/null +++ b/libraries/pmrt/card/card.plg @@ -0,0 +1,41 @@ + + +
+

Build Log

+

+--------------------Configuration: card - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3B6.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "SYS_PC" /D "WIN32" /D "_MBCS" /D "_LIB" /Fp"Debug/card.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\card\card.c" +"C:\g3\libraries\pmrt\card\card_lin.c" +"C:\g3\libraries\pmrt\card\card_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3B6.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\card.lib" .\Debug\card.obj .\Debug\card_lin.obj .\Debug\card_pc.obj " +

Output Window

+Compiling... +card.c +card_lin.c +card_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3B7.bat" with contents +[ +@echo off +copy Debug\card.lib c:\g3\lib +copy card.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3B7.bat" +Copying card files + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+card.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/card/card_lin.c b/libraries/pmrt/card/card_lin.c new file mode 100755 index 0000000..390f3e9 --- /dev/null +++ b/libraries/pmrt/card/card_lin.c @@ -0,0 +1,1837 @@ +// +// card_lin.c +// card reader linux low-level +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// +#if SYS_BB + + +// include files +#include "card.h" +#include "cardpriv.h" +#include +#include +#include +#include +#include +#include +#include + +// local definitions + +// +// DMSG_ +// debug messaging level +// +enum +{ + DMSG_OFF, + DMSG_1, + DMSG_2, + DMSG_3, + DMSG_MAX, +}; + +// global data + +// local data +static int debugMessageLevel; // current debug messaging level + +// global functions + +// forward +int SCROpenPort (sCardDev *cdev); +void *SCRcardThread(void *targ); +int SCRClosePort (sCardDev *cdev); +int xicoOpenPort (sCardDev *cdev); +int xicoClosePort (sCardDev *cdev); +void *xicoCardThread(void *targ); + +// +// dprintf +// debug printf to console +// +static void dprintf(int msgLevel, char *fmt,...) +{ +#ifdef DEBUG + char buf[2048]; + va_list args; + if (msgLevel <= debugMessageLevel) + { + va_start(args,fmt); + vsprintf(buf,fmt,args); + printf("%s",buf); + va_end(args); + } +#endif //DEBUG +} // dmsg() + +// +// cardDrvrInit +// called once by CardInit() at system startup +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int cardDrvrInit(sCardDev *cdev) +{ + int ec=0; + + cdev->thread=(pthread_t)NULL; + cdev->iPd = -1; //invalidate port + +#if DEBUG + debugMessageLevel=DMSG_OFF; +#else + debugMessageLevel=DMSG_OFF; +#endif + +//DONE("cardDrvrInit") + return(ec); +} // cardDrvrInit + +// +// cardDrvrFinal +// called once by CardFinal() at system shutdown +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +void cardDrvrFinal(sCardDev *cdev) +{ + // just in case + cardDrvrClose(cdev); +//DONE("cardDrvrFinal") +} // cardDrvrFinal + +// +// cardDrvrOpen +// called to open port connected to card reader +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int cardDrvrOpen(sCardDev *cdev) +{ + int ec=0; + pthread_attr_t attr; + + cdev->intErrorf=0; + cdev->intFlags=0; + + if(cdev->readerType == CARDREADER_SINGULAR) + { + if(SCROpenPort(cdev)==FALSE) + { + ec=-1; + goto BAIL; + } + } + else if(cdev->readerType == CARDREADER_XICO) + { + if(xicoOpenPort(cdev)<0) + { + ec=-1; + goto BAIL; + } + } + else + { + ec=-2; + goto BAIL; + } + + cdev->bufn=cdev->bufw=cdev->bufr=0; // clear read buffer + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); + + // create the card watch thread + if(cdev->readerType == CARDREADER_SINGULAR) + { + if(pthread_create(&(cdev->thread),&attr,SCRcardThread,&cdev)) + { + msg( "cardDrvrOpen(): Error creating thread: SCRcardThread\n"); + pthread_attr_destroy(&attr); + SCRClosePort(cdev); // no thread, no card + ec=-1; + goto BAIL; + } + else + { + pthread_attr_destroy(&attr); + } + } + else if(cdev->readerType == CARDREADER_XICO) + { + if(pthread_create(&(cdev->thread),&attr,xicoCardThread,&cdev)) + { + msg( "cardDrvrOpen(): Error creating thread: xicoCardThread\n"); + pthread_attr_destroy(&attr); + xicoClosePort(cdev); // no thread, no card + ec=-1; + goto BAIL; + } + else + { + pthread_attr_destroy(&attr); + } + } + +//DONE("cardDrvrOpen") +BAIL: + return(ec); +} // cardDrvrOpen + +// +// cardDrvrClose +// close port connected to card reader +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void cardDrvrClose(sCardDev *cdev) +{ + if(cdev->readerType == CARDREADER_SINGULAR) + { + SCRClosePort (cdev); + } + else if(cdev->readerType == CARDREADER_XICO) + { + xicoClosePort (cdev); + } + + if(cdev->thread) + pthread_cancel(cdev->thread); + + cdev->thread=(pthread_t)NULL; +//DONE("cardDrvrClose") +} // cardDrvrClose + +// +// cardDrvrIsRunning +// returns TRUE if the card driver is currently running (open) +// +// in: +// out: +// global: +// +// GNP 19 Feb 07 +// +int cardDrvrIsRunning(sCardDev *cdev) +{ + if (cdev->thread) + return(1); + else + return(0); +//DONE("cardDrvrIsRunning") +} // cardDrvrIsRunning + +//------------------------------------------------------ +// Singular card reader specific +//------------------------------------------------------ +// Open and initiate the com port +int SCROpenPort (sCardDev *cdev) +{ +/* + Open modem device for reading and writing and not as controlling tty + because we don't want to get killed if linenoise sends CTRL-C. +*/ + char portname[12]; + + sprintf(portname, "/dev/ttyS%u", cdev->iComPort-1); + cdev->iPd = open(portname, O_RDWR | O_NOCTTY ); + if (cdev->iPd <0) + return(-1); + + tcgetattr(cdev->iPd,&(cdev->oldtio)); // save current serial port settings + memset(&(cdev->newtio), 0, sizeof(cdev->newtio)); // clear struct for new port settings + + /* + BAUDRATE: Set bps rate. You could also use cfsetispeed and cfsetospeed. + CRTSCTS : output hardware flow control (only used if the cable has + all necessary lines. See sect.) + CS8 : 8n1 (8bit,no parity,1 stopbit) + CLOCAL : local connection, no modem contol + CREAD : enable receiving characters + IGNPAR : ignore bytes with parity errors + ICRNL : map CR to NL (otherwise a CR input on the other computer + will not terminate input) + otherwise make device raw (no other input processing) + */ + + // baudrate settings are defined in , which is included by + switch (cdev->iBaudRate) + { + case 9600: + cdev->newtio.c_cflag = B9600; + break; + case 19200: + cdev->newtio.c_cflag = B19200; + break; + case 115200: + default: + cdev->newtio.c_cflag = B115200; + break; + } + + cdev->newtio.c_cflag |= (CS8 | CLOCAL | CREAD); // don't use hardware control + cdev->newtio.c_iflag |= IGNPAR; + cdev->newtio.c_oflag = 0; // Raw output + cdev->newtio.c_lflag = 0; +// cdev->newtio.c_cc[VMIN] = 1; // blocking read until 1 char received +// cdev->newtio.c_cc[VTIME] = 0; // inter-character timer unused + cdev->newtio.c_cc[VMIN] = 0; // no waiting on characters, just VTIME + cdev->newtio.c_cc[VTIME] = 5; // timeout on read is 0.5 seconds + + + // now clean the modem line and activate the settings for the port + tcflush(cdev->iPd, TCIFLUSH); + tcsetattr(cdev->iPd,TCSANOW,&(cdev->newtio)); + usleep(250000); // Sleep 250 ms to ignore PnP procedure. + + return TRUE; +} + +// +// SCRClosePort +// close the port previously opened +int SCRClosePort (sCardDev *cdev) +{ + if (cdev->iPd >= 0) + { + tcsetattr(cdev->iPd,TCSANOW,&(cdev->oldtio)); + close(cdev->iPd); + } + cdev->iPd=-1; + return(0); +} //SCRClosePort + +// Command list: +const unsigned char brACK[6] = {0x24, 0, 0x02, 0x90, 0x00, 0xB6}; +const unsigned char brGrnLedOn[9] = {0x42, 0, 0x06, 0x1B, 0x30, 0, 0, 1, 0}; +const unsigned char brGrnLedOff[9] = {0x42, 0, 0x06, 0x1B, 0x30, 0, 0, 1, 1}; +const unsigned char brRedLedOn[9] = {0x42, 0, 0x06, 0x1B, 0x30, 0, 1, 1, 0}; +const unsigned char brRedLedOff[9] = {0x42, 0, 0x06, 0x1B, 0x30, 0, 1, 1, 1}; + +// commands for magnetic card +const unsigned char brSelMagMode[8] = {0x42, 0, 0x05, 0x1B, 0xC0, 0, 0x30, 0}; +const unsigned char brClearMagBuff[8] = {0x42, 0, 0x05, 0x1A, 0x12, 0, 0, 0}; +const unsigned char brGetT1Len[8] = {0x42, 0, 0x05, 0x1A, 0x13, 0, 0x01, 0}; +const unsigned char brGetT2Len[8] = {0x42, 0, 0x05, 0x1A, 0x13, 0, 0x02, 0}; +const unsigned char brGetT3Len[8] = {0x42, 0, 0x05, 0x1A, 0x13, 0, 0x03, 0}; +const unsigned char brGetT1Data[9] = {0x42, 0, 0x06, 0x1A, 0x14, 0, 0x01, 0, 0x80}; +const unsigned char brGetT2Data[9] = {0x42, 0, 0x06, 0x1A, 0x14, 0, 0x02, 0, 0x80}; +const unsigned char brGetT3Data[9] = {0x42, 0, 0x06, 0x1A, 0x14, 0, 0x03, 0, 0x80}; + +// +// SCRGrnLedOn +// turn Green LED on +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGrnLedOn(sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brGrnLedOn, 9); + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + res = write(cdev->iPd, cdev->cmd, 10); + res = read(cdev->iPd, cdev->rsp, 6); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + return CARD_OK; + else + return CARD_ERR_INVALID; +//DONE("SCRGrnLedOn") +} // SCRGrnLedOn + +// +// SCRGrnLedOff +// turn Green LED off +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGrnLedOff(sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brGrnLedOff, 9); + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + res = write(cdev->iPd, cdev->cmd, 10); + res = read(cdev->iPd, cdev->rsp, 6); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + return CARD_OK; + else + return CARD_ERR_INVALID; +//DONE("SCRGrnLedOff") +} // SCRGrnLedOff + +// +// SCRRedLedOn +// turn red LED on +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRRedLedOn (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brRedLedOn, 9); + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + res = write(cdev->iPd, cdev->cmd, 10); + res = read(cdev->iPd, cdev->rsp, 6); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + return CARD_OK; + else + return CARD_ERR_INVALID; +//DONE("SCRRedLedOn") +} // SCRRedLedOn + +// +// SCRRedLedOff +// turn red LED off +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRRedLedOff (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brRedLedOff, 9); + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + res = write(cdev->iPd, cdev->cmd, 10); + res = read(cdev->iPd, cdev->rsp, 6); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + return CARD_OK; + else + return CARD_ERR_INVALID; +//DONE("SCRRedLedOff") +} // SCRRedLedOff + +// +// SCRSelMagMode +// select magnetic stripe mode +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRSelMagMode (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brSelMagMode, 8); + edc = 0; + for (i=0; i<8; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[8]=edc; + tcflush(cdev->iPd, TCIFLUSH); + res = write(cdev->iPd, cdev->cmd, 9); + res = read(cdev->iPd, cdev->rsp, 6); + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + return CARD_OK; + else + return CARD_ERR_INVALID; +//DONE("SCRSelMagMode") +} // SCRSelMagMode + +// +// SCRClearMagBuff +// clear magnetic strip buffer +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRClearMagBuff (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brClearMagBuff, 8); + edc = 0; + for (i=0; i<8; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[8]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRClearMagBuff, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 9); + dprintf(DMSG_3,"----- SCRClearMagBuff, read\r\n"); + res = read(cdev->iPd, cdev->rsp, 6); + dprintf(DMSG_3,"----- SCRClearMagBuff, read = %d\r\n",res); + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + return CARD_OK; + else + return CARD_ERR_INVALID; +//DONE("SCRClearMagBuff") +} // SCRClearMagBuff + +// +// SCRGetT1Len +// get magnetic card track 1 length +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGetT1Len (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brGetT1Len, 8); + edc = 0; + for (i=0; i<8; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[8]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRGetT1Len, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 9); + usleep(100000); // Sleep 100ms + dprintf(DMSG_3,"----- SCRGetT1Len, read\r\n"); + res = read(cdev->iPd, cdev->rsp, 12); + dprintf(DMSG_3,"----- SCRGetT1Len, read=%d\r\n",res); + if ( res && memcmp(cdev->rsp, brACK, 6)==0 && cdev->rsp[9]==0x9f) + { + cdev->TrackLen[0] = cdev->rsp[10]; + return cdev->rsp[10]; + } + else + return CARD_ERR_INVALID; +//DONE("SCRGetT1Len") +} // SCRGetT1Len + +// +// SCRGetT2Len +// get magnetic card track 2 length +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGetT2Len (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, 16); + memcpy(cdev->cmd, brGetT2Len, 8); + edc = 0; + for (i=0; i<8; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[8]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRGetT2Len, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 9); + usleep(100000); // Sleep 100ms + dprintf(DMSG_3,"----- SCRGetT2Len, read\r\n"); + res = read(cdev->iPd, cdev->rsp, 12); + dprintf(DMSG_3,"----- SCRGetT2Len, read=%d\r\n",res); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 && cdev->rsp[9]==0x9f ) + { + cdev->TrackLen[1] = cdev->rsp[10]; + return cdev->rsp[10]; + } + else + return CARD_ERR_INVALID; +//DONE("SCRGetT2Len") +} // SCRGetT2Len + +// +// SCRGetT3Len +// get magnetic card track 3 length +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGetT3Len (sCardDev *cdev) +{ + unsigned char edc; + int i, res; + + memset(cdev->rsp, 0, sizeof(cdev->rsp)); + memcpy(cdev->cmd, brGetT3Len, 8); + edc = 0; + for (i=0; i<8; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[8]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRGetT3Len, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 9); + usleep(100000); // Sleep 100ms + dprintf(DMSG_3,"----- SCRGetT3Len, read\r\n"); + res = read(cdev->iPd, cdev->rsp, 12); + dprintf(DMSG_3,"----- SCRGetT3Len, read=%d\r\n",res); + if ( res && memcmp(cdev->rsp, brACK, 6)==0 && cdev->rsp[9]==0x9f ) + { + cdev->TrackLen[2] = cdev->rsp[10]; + return cdev->rsp[10]; + } + else + return CARD_ERR_INVALID; +//DONE("SCRGetT3Len") +} // SCRGetT3Len + +// +// SCRGetT1Data +// get magnetic card track 1 data +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGetT1Data (sCardDev *cdev) +{ + unsigned char edc; + int i, res, len; + + memset( cdev->rsp, 0, sizeof(cdev->rsp) ); + memset( cdev->TrackData[0], 0, sizeof(cdev->TrackData[0]) ); + memcpy(cdev->cmd, brGetT1Data, 9); + cdev->cmd[8] = cdev->TrackLen[0]; + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRGetT1Data, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 10); + usleep(100000); // Sleep 100ms + + i = 0; + len = 12+cdev->TrackLen[0]; + dprintf(DMSG_3,"----- SCRGetT1Data, read\r\n"); + while((res = read(cdev->iPd, cdev->rsp+i, 32))) + { + if(!res) + break; + + i = i + res; + dprintf(DMSG_2,"----- SCRGetT1Data, read=%d, tot=%d, len=%d\r\n",res,i,len); + //printf("res = %d\n", res); + if (i>=len) + break; + } + + dprintf(DMSG_3,"----- SCRGetT1Data, read done\r\n"); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + { + memcpy(cdev->TrackData[0], cdev->rsp+9, cdev->TrackLen[0]); // T1 start sentinel '%' and end sentinel '?'. + return CARD_OK; + } + else + return CARD_ERR_INVALID; +//DONE("SCRGetT1Data") +} // SCRGetT1Data + +// +// SCRGetT2Data +// get magnetic card track 2 data +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGetT2Data (sCardDev *cdev) +{ + unsigned char edc; + int i, res, len; + + memset( cdev->rsp, 0, sizeof(cdev->rsp) ); + memset( cdev->TrackData[1], 0, sizeof(cdev->TrackData[1]) ); + + memcpy(cdev->cmd, brGetT2Data, 9); + cdev->cmd[8] = cdev->TrackLen[1]; + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRGetT2Data, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 10); + usleep(100000); // Sleep 100ms + + i = 0; + len = 12+cdev->TrackLen[1]; + dprintf(DMSG_3,"----- SCRGetT2Data, read\r\n"); + while((res = read(cdev->iPd, cdev->rsp+i, 32))) + { + if(!res) + break; + + i = i + res; + dprintf(DMSG_2,"----- SCRGetT2Data, read=%d, tot=%d, len=%d\r\n",res,i,len); + //printf("res = %d\n", res); + if (i>=len) + break; + } + + dprintf(DMSG_3,"----- SCRGetT2Data, read done\r\n"); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + { + memcpy(cdev->TrackData[1], cdev->rsp+9, cdev->TrackLen[1]); // T2 start sentinel ';' and end sentinel '?'. + return CARD_OK; + } + else + return CARD_ERR_INVALID; +//DONE("SCRGetT2Data") +} // SCRGetT2Data + +// +// SCRGetT3Data +// get magnetic card track 3 data +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int SCRGetT3Data (sCardDev *cdev) +{ + unsigned char edc; + int i, res, len; + + memset( cdev->rsp, 0, sizeof(cdev->rsp) ); + memset( cdev->TrackData[2], 0, sizeof(cdev->TrackData[2]) ); + + memcpy(cdev->cmd, brGetT3Data, 9); + cdev->cmd[8] = cdev->TrackLen[2]; + edc = 0; + for (i=0; i<9; i++) + edc ^= cdev->cmd[i]; + + cdev->cmd[9]=edc; + tcflush(cdev->iPd, TCIFLUSH); + dprintf(DMSG_3,"----- SCRGetT3Data, write\r\n"); + res = write(cdev->iPd, cdev->cmd, 10); + usleep(100000); // Sleep 100ms + + i = 0; + len = 12+cdev->TrackLen[2]; + dprintf(DMSG_3,"----- SCRGetT3Data, read\r\n"); + while((res = read(cdev->iPd, cdev->rsp+i, 32))) + { + if(!res) + break; + + i = i + res; + dprintf(DMSG_2,"----- SCRGetT3Data, read=%d, tot=%d, len=%d\r\n",res,i,len); + //printf("res = %d\n", res); + if (i>=len) + break; + } + + dprintf(DMSG_3,"----- SCRGetT3Data, read done\r\n"); + + if ( res && memcmp(cdev->rsp, brACK, 6)==0 ) + { + memcpy(cdev->TrackData[2], cdev->rsp+9, cdev->TrackLen[2]); // T3 start sentinel ';' and end sentinel '?'. + return CARD_OK; + } + else + return CARD_ERR_INVALID; +//DONE("SCRGetT3Data") +} // SCRGetT3Data + +enum +{ + CTCOM_NONE, + CTCOM_GREENLEDON, + CTCOM_GREENLEDOFF, + CTCOM_REDLEDON, + CTCOM_REDLEDOFF, + CTCOM_SELECTMAGMODE, +}; + +void ctCommand(int command,sCardDev *cdev) +{ + switch(command) + { + case CTCOM_GREENLEDON: + if (SCRGrnLedOn(cdev)==CARD_OK) + cdev->intErrorf &= ~M_CARD_INTERROR_GREENLED; + else + cdev->intErrorf |= M_CARD_INTERROR_GREENLED; + break; + case CTCOM_GREENLEDOFF: + if (SCRGrnLedOff(cdev)==CARD_OK) + cdev->intErrorf &= ~M_CARD_INTERROR_GREENLED; + else + cdev->intErrorf |= M_CARD_INTERROR_GREENLED; + break; + break; + case CTCOM_REDLEDON: + if (SCRRedLedOn(cdev)==CARD_OK) + cdev->intErrorf &= ~M_CARD_INTERROR_REDLED; + else + cdev->intErrorf |= M_CARD_INTERROR_REDLED; + break; + case CTCOM_REDLEDOFF: + if (SCRRedLedOff(cdev)==CARD_OK) + cdev->intErrorf &= ~M_CARD_INTERROR_REDLED; + else + cdev->intErrorf |= M_CARD_INTERROR_REDLED; + break; + case CTCOM_SELECTMAGMODE: + if (SCRSelMagMode(cdev)==CARD_OK) + cdev->intErrorf &= ~M_CARD_INTERROR_MAGMODE; + else + cdev->intErrorf |= M_CARD_INTERROR_MAGMODE; + break; + } +} //ctCommand + +// +// SCRcardThread +// thread to watch card reader and grab data +// Singular Tech specific +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void *SCRcardThread(void *targ) +{ + int res = 0; + int err; + int bDebugDot, bIndicateError; + int errorTimer, errorFlashCount; + + sCardDev *cdev = *(sCardDev**)targ; + + cdev = cardGetDevice(); + + // Make SCR reader green led on + ctCommand(CTCOM_GREENLEDON,cdev); + + usleep(200000); // Sleep 0.2 second + + // Make SCR reader red led on + ctCommand(CTCOM_REDLEDON,cdev); + + usleep(500000); // Sleep 0.5 second + pthread_testcancel(); + ctCommand(CTCOM_REDLEDOFF,cdev); + + ctCommand(CTCOM_SELECTMAGMODE,cdev); + + bDebugDot=bIndicateError=errorTimer=errorFlashCount=0; + + while(1) + { +// dprintf(DMSG_2,"----- SCRcardThread, read, flags = %08X\r\n",cdev->intFlags); + if (cdev->intErrorf & M_CARD_INTERROR_PHASE) + { + dprintf(DMSG_1,"SCRcardThread, Phasing error\r\n"); + tcflush(cdev->iPd, TCIFLUSH); + cdev->intErrorf &= ~M_CARD_INTERROR_PHASE; + } + res = read(cdev->iPd, cdev->rsp, 6); + pthread_testcancel(); + if(!res) + { + bDebugDot=1; +#if DEBUG + dprintf(DMSG_3,"."); + fflush(stdout); +#endif + + if(cdev->flags & M_CARD_FLAGS_FLUSHIO) + { + if(!(cdev->intFlags & M_CARD_INTFLAGS_FLUSHIO_ACK)) + { + tcflush(cdev->iPd, TCIFLUSH); + tcflush(cdev->iPd, TCOFLUSH); + cdev->bufn=cdev->bufw=cdev->bufr=0; // clear read buffer + cdev->intFlags |= M_CARD_INTFLAGS_FLUSHIO_ACK; + } + } + else + cdev->intFlags &= ~M_CARD_INTFLAGS_FLUSHIO_ACK; + + if(cdev->flags & M_CARD_FLAGS_SELECTMAG) + { + if(!(cdev->intFlags & M_CARD_INTFLAGS_SELECTMAG_ACK)) + { + if (SCRSelMagMode(cdev)==CARD_OK) + cdev->intErrorf &= ~M_CARD_INTERROR_MAGMODE; + else + cdev->intErrorf |= M_CARD_INTERROR_MAGMODE; + cdev->intFlags |= M_CARD_INTFLAGS_SELECTMAG_ACK; + } + } + else + cdev->intFlags &= ~M_CARD_INTFLAGS_SELECTMAG_ACK; + + if(bIndicateError) + { + ctCommand(CTCOM_GREENLEDOFF,cdev); + ctCommand(CTCOM_REDLEDOFF,cdev); + bIndicateError=0; + errorTimer=0; + errorFlashCount=3; + } + else if (errorFlashCount > 0) + { + errorFlashCount--; + if(errorFlashCount & 1) + ctCommand(CTCOM_REDLEDOFF,cdev); + else + ctCommand(CTCOM_REDLEDON,cdev); + + if(!errorFlashCount) + errorTimer=1; + + } + else if (errorTimer > 0) + { + errorTimer--; + if(errorTimer <= 0) + { + ctCommand(CTCOM_GREENLEDON,cdev); + ctCommand(CTCOM_REDLEDOFF,cdev); + errorTimer=0; + } + } + continue; + } + else if(res<0) + { + //I/O error + if (errno == EBADF || errno == EISDIR || errno == EIO) + goto BAIL; + else + usleep(500000); // Sleep 0.5 second + } + + if(bDebugDot) + { + dprintf(DMSG_3,"\r\n"); + bDebugDot=0; + } + + dprintf(DMSG_2,"----- SCRcardThread, read=%d\r\n",res); + err=-1; // default to error, will be cleared by good read + + if ( cdev->rsp[3]==0x64 && cdev->rsp[4]==0xA0 ) + { + dprintf(DMSG_1,"Info: User inserts a card!\r\n"); + cdev->intFlags |= M_CARD_INTFLAGS_CARDIN; + cdev->intFlags &= ~(M_CARD_INTFLAGS_DATA1|M_CARD_INTFLAGS_DATA2|M_CARD_INTFLAGS_DATA3|M_CARD_INTFLAGS_NODATA); + // indicate we are processing + ctCommand(CTCOM_GREENLEDOFF,cdev); + ctCommand(CTCOM_REDLEDON,cdev); + // ready mag buffer + SCRClearMagBuff(cdev); + } + else if( cdev->rsp[3]==0x64 && cdev->rsp[4]==0xA1 ) + { + dprintf(DMSG_1,"Info: User removes a card!\r\n"); + + if (!(cdev->intFlags & M_CARD_INTFLAGS_CARDIN)) + { + // error card in/out is out of phase + cdev->intErrorf |= M_CARD_INTERROR_PHASE; + bIndicateError=1; + continue; //skip info read cycle + } + + cdev->intFlags &= ~M_CARD_INTFLAGS_CARDIN; + + // pause and read track 1 + usleep(200000); // Sleep 0.2 second + pthread_testcancel(); + if (SCRGetT1Len(cdev)>0) + { + dprintf(DMSG_1,"T1 Length = %d\r\n", cdev->TrackLen[0]); + if(SCRGetT1Data(cdev) != CARD_ERR_INVALID) + { + cdev->intFlags |= M_CARD_INTFLAGS_DATA1; + dprintf(DMSG_1,"T1 data = %s\r\n", cdev->TrackData[0]); + err=0; + } + else + { + cdev->intFlags &= ~M_CARD_INTFLAGS_DATA1; + dprintf(DMSG_1,"T1 data = ERROR\r\n"); + } + } + else + { + cdev->intFlags &= ~M_CARD_INTFLAGS_DATA1; + dprintf(DMSG_1,"T1 data = EMPTY or ERROR!\r\n"); + } + + // pause and read track 2 + usleep(200000); // Sleep 0.2 second + pthread_testcancel(); + if (SCRGetT2Len(cdev)>0) + { + dprintf(DMSG_1,"T2 Length = %d\r\n", cdev->TrackLen[1]); + if(SCRGetT2Data(cdev)!=CARD_ERR_INVALID) + { + cdev->intFlags |= M_CARD_INTFLAGS_DATA2; + dprintf(DMSG_1,"T2 data = %s\r\n", cdev->TrackData[1]); + err=0; + } + else + { + cdev->intFlags &= ~M_CARD_INTFLAGS_DATA2; + dprintf(DMSG_1,"T2 data = ERROR\r\n"); + } + } + else + { + cdev->intFlags &= ~M_CARD_INTFLAGS_DATA2; + dprintf(DMSG_1,"T2 data = EMPTY or ERROR!\r\n"); + } +// we do not use track 3 +#if 0 + // pause and read track 3 + usleep(200000); // Sleep 0.2 second + if (SCRGetT3Len(cdev)>0) + { + dprintf(DMSG_1,"T3 Length = %d\r\n", cdev->TrackLen[2]); + if(SCRGetT3Data(cdev)!=CARD_ERR_INVALID) + { + cdev->intFlags |= M_CARD_INTFLAGS_DATA3; + dprintf(DMSG_1,"T3 data = %s\r\n", cdev->TrackData[2]); + err=0; + } + else + { + cdev->intFlags &= ~M_CARD_INTFLAGS_DATA3; + dprintf(DMSG_1,"T3 data = ERROR\r\n"); + } + } + else + { + cdev->intFlags &= ~M_CARD_INTFLAGS_DATA3; + dprintf(DMSG_1,"T3 data = EMPTY or ERROR!\r\n"); + } +#endif + + if (err<0) + { + dprintf(DMSG_3,"----- SCRcardThread, error\r\n"); + cdev->intFlags |= M_CARD_INTFLAGS_NODATA; + bIndicateError=1; + } + else + { + ctCommand(CTCOM_GREENLEDON,cdev); + ctCommand(CTCOM_REDLEDOFF,cdev); + } + + } + } //While + +//DONE("SCRcardThread") +BAIL: + cdev->thread=(pthread_t)NULL; + return(0); +} // SCRcardThread + + +//------------------------------------------------------ +// XICO card reader specific +//------------------------------------------------------ +#define PATHLEN 2 +int const PATH_OUT[PATHLEN] = { 0xff000001, 0xff000003 }; // this means report 2, strangely enough + +// Command list: +unsigned char xico_led_off[4] = {'L', '0', '\r', '\0'}; +unsigned char xico_led_on[4] = {'L', '1', '\r', '\0'}; +unsigned char xico_led_auto[4] = {'L', '2', '\r', '\0'}; +unsigned char xico_watchdog[4] = {'W', 'D', '\r', '\0'}; +unsigned char xico_version[4] = {'I', 'D', '\r', '\0'}; +unsigned char xico_headeroff[4] = {'H', '0', '\r', '\0'}; +unsigned char xico_headeron[4] = {'H', '1', '\r', '\0'}; +unsigned char xico_track1only[4] = {'E', '1', '\r', '\0'}; +unsigned char xico_track2only[4] = {'E', '2', '\r', '\0'}; +unsigned char xico_tracks1and2[4] = {'E', '3', '\r', '\0'}; + +// +// xicoOpenPort +// open the XICO hid device +// +// 23JUL07 +// +int xicoOpenPort (sCardDev *cdev) +{ + // here's where you give it the VID:PID for the XICO device + HIDInterfaceMatcher matcher = { 0x0c04, 0x01c0, NULL, NULL, 0 }; + hid_return ret; + +#ifdef DEBUG + /* see include/debug.h for possible values */ + //hid_set_debug(HID_DEBUG_ALL); + hid_set_debug(HID_DEBUG_ERRORS); + hid_set_debug_stream(stderr); + /* passed directly to libusb */ + hid_set_usb_debug(0); +#else + hid_set_debug(HID_DEBUG_NONE); + /* passed directly to libusb */ + hid_set_usb_debug(0); +#endif + + // initialize hid library + ret = hid_init(); + if (ret != HID_RET_SUCCESS) + { + dprintf(DMSG_1, "hid_init failed with return code %d\n", ret); + return(CARD_ERR_HID); + } + + cdev->hid = hid_new_HIDInterface(); + if (cdev->hid == 0) + { + hid_cleanup(); + dprintf(DMSG_1,"hid_new_HIDInterface() failed, out of memory?\n"); + return(CARD_ERR_HID); + } + + /* How to detach a device from the kernel HID driver: + * + * The hid.o or usbhid.ko kernel modules claim a HID device on insertion, + * usually. To be able to use it with libhid, you need to blacklist the + * device (which requires a kernel recompilation), or simply tell libhid to + * detach it for you. hid_open just opens the device, hid_force_open will + * try n times to detach the device before failing. + * In the following, n == 3. + * + * To open the HID, you need permission to the file in the /proc usbfs + * (which must be mounted -- most distros do that by default): + * mount -t usbfs none /proc/bus/usb + * You can use hotplug to automatically give permissions to the device on + * connection. Please see + * http://cvs.ailab.ch/cgi-bin/viewcvs.cgi/external/libphidgets/hotplug/ + * for an example. Try NOT to work as root! + */ + + ret = hid_force_open(cdev->hid, 0, &matcher, 3); + if (ret != HID_RET_SUCCESS) + { + hid_delete_HIDInterface(&(cdev->hid)); + hid_cleanup(); + dprintf(DMSG_1, "hid_force_open failed with return code %d\n", ret); + return(CARD_ERR_HID); + } + + return(CARD_OK); +} //xicoOpenPort + + +// +// xicoClosePort +// close the XICO hid device +// +// 23JUL07 +// +int xicoClosePort (sCardDev *cdev) +{ + if (cdev->hid != 0) + { + hid_close(cdev->hid); + hid_delete_HIDInterface(&(cdev->hid)); + hid_cleanup(); + } + cdev->hid=0; + return(0); +} //xicoClosePort + + +// +// xicoSend +// send given data to XICO card reader +// +// GNP 20 jul 07 +// +int xicoSend(sCardDev *cdev, unsigned char *send_data) +{ + int i; + int ret = 0, ec=CARD_OK; + int len = strlen(send_data); + memset(cdev->sendBuf, 0, XICO_SEND_PACKET_LEN); + cdev->sendBuf[0] = 0x02; // report ID == 2 for SENDS + cdev->sendBuf[1] = len; // length of send_data + memcpy(&(cdev->sendBuf[2]), send_data, len); + + if (debugMessageLevel >= DMSG_2) + { + dprintf(DMSG_2,"sending %d bytes: ", len); + for(i=0;i<(len);i++) + dprintf(DMSG_2,"0x%02X ", cdev->sendBuf[i+2]); + + for(i=0; i<(7-len); i++) + dprintf(DMSG_2," "); + + for(i=0;i<(len);i++) + { + if((cdev->sendBuf[i+2] >= 0x20) && (cdev->sendBuf[i+2] < 0x7f)) + dprintf(DMSG_2,"%c", cdev->sendBuf[i+2]); + else + dprintf(DMSG_2,"."); + } + + dprintf(DMSG_2,"\r\n"); + } + ret = hid_set_feature_report(cdev->hid, PATH_OUT, PATHLEN, cdev->sendBuf, XICO_SEND_PACKET_LEN); + if (ret != HID_RET_SUCCESS) + { + dprintf(DMSG_1, "hid_set_feature_report failed with return code %d\n", ret); + ec=CARD_ERR_HID; + } + return(ec); +} //xicoSend + +// +// xicoIsBufMsgReady +// determine if there is a XICO message ready +// in the read buffer +// +int xicoIsBufMsgReady(sCardDev *cdev) +{ + int i,j,bCR=0; + + if(!cdev->bufsize) + return(0); + + for(i=0,j=cdev->bufr;ibufn;i++,j++) + { + // check wrap on read ptr + if(j>=cdev->bufsize) + j=0; + + if(cdev->buf[j] == 0x0d) + bCR=1; + if((cdev->buf[j] == 0x0A) && bCR) + return(1); + } + return(0); +} //xicoIsBufMsgReady + +#define RECV_PACKET_LEN 8 + +// +// xicoReadLoop +// read information from the card reader +// data will be buffered and routine will return +// on empty read or receipt of CRLF, whichever comes first +// +// GNP 25JUL07 +// +int xicoReadLoop(sCardDev *cdev) +{ + int i,len; + hid_return ret; + char packet[RECV_PACKET_LEN]; + + if(xicoIsBufMsgReady(cdev)) + { + dprintf(DMSG_2,"xicoReadLoop(): Previously stored message ready in buffer (%d)(%d)\r\n",cdev->bufn,cdev->bufw); + return(CARD_MESSAGE_READY); + } + + while(1) + { + ret = hid_interrupt_read(cdev->hid, 0x81, packet, RECV_PACKET_LEN, 10000); + + if (ret != HID_RET_SUCCESS) + { + // nothing to read, could be done or could be error +// dprintf(DMSG_1, "hid_interrupt_read failed with return code %d %s\n", ret, (ret==20)?"(TIMEOUT)":""); + return(CARD_ERR_NODATA); + } + else + { + if(debugMessageLevel>=DMSG_2) + { + dprintf(DMSG_2,"xicoReadLoop(): received %d bytes: ", packet[1]); + for(i=0;ibufsize) + { + dprintf(DMSG_1,"xicoReadLoop(): ERROR, no read buffer available\r\n"); + } + else + { + len = packet[1]; + // check for buffer overflow + if((cdev->bufn+=len)>cdev->bufsize) + { + len=cdev->bufsize-cdev->bufn; + cdev->bufn=cdev->bufsize; + cdev->intErrorf|=M_CARD_INTERROR_ROVERFLOW; + } + + } + + // copy data to read buffer + for(i=0;ibufw>=cdev->bufsize) + cdev->bufw=0; + cdev->buf[cdev->bufw++]=packet[i+2]; + } + + if(xicoIsBufMsgReady(cdev)) + { + dprintf(DMSG_2,"xicoReadLoop(): Message ready in buffer (%d)(%d)\r\n",cdev->bufn,cdev->bufw); + return(CARD_MESSAGE_READY); + } + } + } //while +} //xicoReadLoop + +// pssst... try the parsed output - it's fun, and safe! +#define PARSED_OUTPUT 0 + +enum +{ + XRCV_NONE, + XRCV_T1, + XRCV_T2, + XRCV_ACK, + XRCV_RESET, + XRCV_NORESET, + XRCV_TEXT, + XRCV_UNKNOWN, + +}; + +#define M_XRCV_T1 0x0001 +#define M_XRCV_T2 0x0002 +#define M_XRCV_ACK 0x0004 +#define M_XRCV_RESET 0x0008 +#define M_XRCV_NORESET 0x0010 +#define M_XRCV_TEXT 0x0020 +#define M_XRCV_UNKNOWN 0x0040 + +// +// xicoPoll +// check if data from card reader is available +// +int xicoPoll(sCardDev *cdev) +{ + int idx=0,ec=CARD_OK, tInd; + int received=0,eParsing=XRCV_NONE,bCR=0; + char c; + int ret; + + cdev->intFlags &= ~M_CARD_INTFLAGS_HIDDATA; + + while(1) + { + ret = xicoReadLoop(cdev); + + if (ret == CARD_MESSAGE_READY) + { + // data is ready to read + if(!(cdev->intFlags & M_CARD_INTFLAGS_HIDDATA)) + { + cdev->intFlags |= M_CARD_INTFLAGS_HIDDATA; + cdev->intFlags &= ~M_CARD_INTFLAGS_ACK; + } + + dprintf(DMSG_2,"xicoPoll(): Processing buffered data (%d)(%d)\r\n",cdev->bufn,cdev->bufr); + while(cdev->bufn) + { + if(cdev->bufr>=cdev->bufsize) + cdev->bufr=0; + c=cdev->buf[cdev->bufr++];cdev->bufn--; + + if (eParsing==XRCV_NONE) + { + dprintf(DMSG_2,"%c", c); + idx=0; // index for capturing text strings + bCR=0; // flag for catching CR/LF + tInd=0; // track leader indicator + switch(c) + { + case '!': + eParsing=XRCV_T1; + cdev->intTrackData[0][idx++]=CARD_TRACK1_SS; + cdev->intTrackFlags[0]=0; + break; + case '&': + eParsing=XRCV_T2; + cdev->intTrackData[1][idx++]=CARD_TRACK2_SS; + cdev->intTrackFlags[1]=0; + break; + case '#': + eParsing=XRCV_RESET; + break; + case '^': + eParsing=XRCV_ACK; + break; + case 0x00: + eParsing=XRCV_NORESET; + break; + default: + if((c >= 0x20) && (c < 0x7f)) + { + eParsing=XRCV_TEXT; + cdev->readerVersion[idx++]=c; + } + else + eParsing=XRCV_UNKNOWN; + break; + } //switch + } //if + else + { + if((c >= 0x20) && (c < 0x7f)) + { + dprintf(DMSG_2,"%c", c); + switch(eParsing) + { + case XRCV_T1: + if(!tInd) + { + if(c == 'T') + tInd=1; + } + else if(tInd==1) + { + if(c == ' ') + tInd=2; + } + else if(tInd==2) + cdev->intTrackData[0][idx++]=c; + break; + case XRCV_T2: + if(!tInd) + { + if(c == 'T') + tInd=1; + } + else if(tInd==1) + { + if(c == ' ') + tInd=2; + } + else if(tInd==2) + cdev->intTrackData[1][idx++]=c; + break; + case XRCV_TEXT: + cdev->readerVersion[idx++]=c; + break; + } + } + else + { + dprintf(DMSG_2,"."); + if(c == 0x0D) + bCR=1; + if((c == 0x0A) && bCR) + { + // we've actually received something, let's indicate + switch(eParsing) + { + case XRCV_T1: + cdev->intTrackData[0][idx++]=CARD_TRACK_ES; + cdev->intTrackLen[0]=idx; + cdev->intTrackData[0][idx]=0; + received|=M_XRCV_T1; + break; + case XRCV_T2: + cdev->intTrackData[1][idx++]=CARD_TRACK_ES; + cdev->intTrackLen[1]=idx; + cdev->intTrackData[1][idx]=0; + received|=M_XRCV_T2; + break; + case XRCV_TEXT: + cdev->readerVersion[idx]=0; + received|=M_XRCV_TEXT; + break; + case XRCV_RESET: + received|=M_XRCV_RESET; + break; + case XRCV_NORESET: + received|=M_XRCV_NORESET; + break; + case XRCV_ACK: + received|=M_XRCV_ACK; + break; + case XRCV_UNKNOWN: + received|=M_XRCV_UNKNOWN; + break; + } + eParsing=XRCV_NONE; + break; + } + } + } + } // while + dprintf(DMSG_2,"\r\n"); + dprintf(DMSG_2,"xicoPoll(): Read message from buffer (%d)(%d)\r\n",cdev->bufn,cdev->bufr); + break; + } + else + { + break; // no data ready + } + } // while + + + if(received) + { + if(received&M_XRCV_T1) + { + cdev->intTrackFlags[0] |= M_TRACKFLAGS_DATAREAD; + idx=cdev->intTrackLen[0]; + if(cdev->intTrackData[0][idx-3] == '?') + { + cdev->intTrackFlags[0] |= M_TRACKFLAGS_ERROR; + switch(cdev->intTrackData[0][idx-2]) + { + case 'B': + cdev->intTrackFlags[0] |= M_TRACKFLAGS_BLANK; + break; + case 'Z': + cdev->intTrackFlags[0] |= M_TRACKFLAGS_ALLCLOCK; + break; + case 'S': + cdev->intTrackFlags[0] |= M_TRACKFLAGS_NOSS; + break; + case 'E': + cdev->intTrackFlags[0] |= M_TRACKFLAGS_NOES; + break; + case 'L': + cdev->intTrackFlags[0] |= M_TRACKFLAGS_BADLRC; + break; + case 'P': + cdev->intTrackFlags[0] |= M_TRACKFLAGS_PARITY; + break; + } + } + dprintf(DMSG_2," Length = %d %s %s\r\n",idx,cdev->intTrackData[0],(cdev->intTrackFlags[0] & M_TRACKFLAGS_ERROR)?"ERROR":""); + } + if(received&M_XRCV_T2) + { + cdev->intTrackFlags[1] |= M_TRACKFLAGS_DATAREAD; + idx=cdev->intTrackLen[1]; + if(cdev->intTrackData[1][idx-3] == '?') + { + cdev->intTrackFlags[1] |= M_TRACKFLAGS_ERROR; + switch(cdev->intTrackData[1][idx-2]) + { + case 'B': + cdev->intTrackFlags[1] |= M_TRACKFLAGS_BLANK; + break; + case 'Z': + cdev->intTrackFlags[1] |= M_TRACKFLAGS_ALLCLOCK; + break; + case 'S': + cdev->intTrackFlags[1] |= M_TRACKFLAGS_NOSS; + break; + case 'E': + cdev->intTrackFlags[1] |= M_TRACKFLAGS_NOES; + break; + case 'L': + cdev->intTrackFlags[1] |= M_TRACKFLAGS_BADLRC; + break; + case 'P': + cdev->intTrackFlags[1] |= M_TRACKFLAGS_PARITY; + break; + } + } + dprintf(DMSG_2," Length = %d %s %s\r\n",idx,cdev->intTrackData[1],(cdev->intTrackFlags[1] & M_TRACKFLAGS_ERROR)?"ERROR":""); + } + if(received&M_XRCV_TEXT) + { + cdev->intFlags |= M_CARD_INTFLAGS_READERVERSION; + dprintf(DMSG_2," Length = %d %s\r\n",idx,cdev->readerVersion); + } + if(received&M_XRCV_RESET) + { + cdev->intFlags |= M_CARD_INTFLAGS_RESET; + dprintf(DMSG_2,"\r\n"); + } + if(received&M_XRCV_NORESET) + { + cdev->intFlags &= ~M_CARD_INTFLAGS_RESET; + dprintf(DMSG_2,"\r\n"); + } + if(received&M_XRCV_ACK) + { + cdev->intFlags |= M_CARD_INTFLAGS_ACK; + dprintf(DMSG_2,"\r\n"); + } + if(received&M_XRCV_UNKNOWN) + { + dprintf(DMSG_2,"\r\n"); + } + } + return(ec); +} //xicoPoll + +// +// xicoCardThread +// thread to watch card reader and grab data +// XICO specific +// +// in: +// out: +// global: +// +// GNP 23 Jul 07 +// +void *xicoCardThread(void *targ) +{ + int err,i; + int bDebugDot, bIndicateError; + int errorTimer, errorFlashCount; + + sCardDev *cdev = *(sCardDev**)targ; + + cdev = cardGetDevice(); + + // + // clear appropriate flags + // + for(i=0;i<3;i++) + cdev->intTrackFlags[i]=0; + + xicoSend(cdev,xico_led_off); + xicoPoll(cdev); + usleep(100000); + + xicoSend(cdev,xico_led_on); + xicoPoll(cdev); + usleep(100000); + + xicoSend(cdev,xico_led_off); + xicoPoll(cdev); + usleep(100000); + + xicoSend(cdev,xico_led_auto); + xicoPoll(cdev); + usleep(1000); + + xicoSend(cdev,xico_version); + xicoPoll(cdev); + usleep(1000); + + xicoSend(cdev,xico_watchdog); + xicoPoll(cdev); + usleep(1000); + + bDebugDot=bIndicateError=errorTimer=errorFlashCount=0; + + while(1) + { + err=xicoPoll(cdev); + pthread_testcancel(); + + // Singular legacy + if(cdev->flags & M_CARD_FLAGS_FLUSHIO) + { + if(!(cdev->intFlags & M_CARD_INTFLAGS_FLUSHIO_ACK)) + { + cdev->bufn=cdev->bufw=cdev->bufr=0; // clear read buffer + cdev->intFlags |= M_CARD_INTFLAGS_FLUSHIO_ACK; + } + } + else + cdev->intFlags &= ~M_CARD_INTFLAGS_FLUSHIO_ACK; + + if(cdev->flags & M_CARD_FLAGS_SELECTMAG) + { + if(!(cdev->intFlags & M_CARD_INTFLAGS_SELECTMAG_ACK)) + { + cdev->intFlags |= M_CARD_INTFLAGS_SELECTMAG_ACK; + } + } + else + cdev->intFlags &= ~M_CARD_INTFLAGS_SELECTMAG_ACK; + + // + // see if we have read track data + // if so, we will tell the tell the upper layer + // that a card is in so it prepares to receive data + // + if(((cdev->intTrackFlags[0] & M_TRACKFLAGS_DATAREAD) || (cdev->intTrackFlags[1] & M_TRACKFLAGS_DATAREAD)) + && !(cdev->intFlags & M_CARD_INTFLAGS_WAITINGFORCARDINACK) + ) + { + cdev->intFlags |= (M_CARD_INTFLAGS_CARDIN|M_CARD_INTFLAGS_WAITINGFORCARDINACK); +// dprintf(DMSG_2,"xicoCardThread(): Sending Card In\r\n"); + } + + // + // if upper layer is ready, then we'll send up some data + // if we have any + if((cdev->intFlags & M_CARD_INTFLAGS_WAITINGFORCARDINACK) + && (cdev->flags & M_CARD_FLAGS_CARDIN_PROCESSED) + ) + { + cdev->intFlags &= ~(M_CARD_INTFLAGS_DATA1|M_CARD_INTFLAGS_DATA2|M_CARD_INTFLAGS_DATA3|M_CARD_INTFLAGS_CARDIN|M_CARD_INTFLAGS_WAITINGFORCARDINACK); + cdev->intFlags |= M_CARD_INTFLAGS_NODATA; + +// dprintf(DMSG_2,"xicoCardThread(): Card In Acknowledged\r\n"); + + // Check Track 1 + if(cdev->intTrackFlags[0] & M_TRACKFLAGS_DATAREAD) + { + // copy Track 1 data + strcpy(cdev->TrackData[0],cdev->intTrackData[0]); + cdev->TrackLen[0] = cdev->intTrackLen[0]; + cdev->intTrackFlags[0] &= ~M_TRACKFLAGS_DATAREAD; + if(!(cdev->intTrackFlags[0] & M_TRACKFLAGS_ERROR)) + { + cdev->intFlags |= M_CARD_INTFLAGS_DATA1; + cdev->intFlags &= ~M_CARD_INTFLAGS_NODATA; + dprintf(DMSG_1,"T1 Length = %d\r\n", cdev->TrackLen[0]); + dprintf(DMSG_1,"T1 data = %s\r\n", cdev->TrackData[0]); + } + else + { + if(cdev->intTrackFlags[0] & M_TRACKFLAGS_BLANK) + dprintf(DMSG_1,"T1 data = EMPTY\r\n"); + else + dprintf(DMSG_1,"T1 data = ERROR\r\n"); + } + } + + // Check Track 2 + if(cdev->intTrackFlags[1] & M_TRACKFLAGS_DATAREAD) + { + // copy Track 2 data + strcpy(cdev->TrackData[1],cdev->intTrackData[1]); + cdev->TrackLen[1] = cdev->intTrackLen[1]; + cdev->intTrackFlags[1] &= ~M_TRACKFLAGS_DATAREAD; + if(!(cdev->intTrackFlags[1] & M_TRACKFLAGS_ERROR)) + { + cdev->intFlags |= M_CARD_INTFLAGS_DATA1; + cdev->intFlags &= ~M_CARD_INTFLAGS_NODATA; + dprintf(DMSG_1,"T2 Length = %d\r\n", cdev->TrackLen[1]); + dprintf(DMSG_1,"T2 data = %s\r\n", cdev->TrackData[1]); + } + else + { + if(cdev->intTrackFlags[1] & M_TRACKFLAGS_BLANK) + dprintf(DMSG_1,"T2 data = EMPTY\r\n"); + else + dprintf(DMSG_1,"T2 data = ERROR\r\n"); + } + } + } + } //while + +//DONE("xicoCardThread") +//BAIL: + cdev->thread=(pthread_t)NULL; + return(0); +} // xicoCardThread + + +#endif //SYS_BB +//EOF diff --git a/libraries/pmrt/card/card_lin.o b/libraries/pmrt/card/card_lin.o new file mode 100644 index 0000000..dd46f1f Binary files /dev/null and b/libraries/pmrt/card/card_lin.o differ diff --git a/libraries/pmrt/card/card_pc.c b/libraries/pmrt/card/card_pc.c new file mode 100755 index 0000000..aa53115 --- /dev/null +++ b/libraries/pmrt/card/card_pc.c @@ -0,0 +1,108 @@ +// +// card_lin.c +// card reader linux low-level +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// +#if SYS_PC +// include files +#include "card.h" +#include "cardpriv.h" +// local definitions + +// global data + +// local data + +// global functions + +// forward + + +// +// cardDrvrInit +// called once by CardInit() at system startup +// +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int cardDrvrInit(sCardDev *cdev) +{ + int ec=0; +//DONE("cardDrvrInit") + return(ec); +} // cardDrvrInit + +// +// cardDrvrFinal +// called once by CardFinal() at system shutdown +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void cardDrvrFinal(sCardDev *cdev) +{ +//DONE("cardDrvrFinal") +} // cardDrvrFinal + +// +// cardDrvrOpen +// called to open port connected to card reader +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int cardDrvrOpen(sCardDev *cdev) +{ + int ec=0; +//DONE("cardDrvrOpen") + return(ec); +} // cardDrvrOpen + +// +// cardDrvrClose +// close port connected to card reader +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void cardDrvrClose(sCardDev *cdev) +{ +//DONE("cardDrvrClose") +} // cardDrvrClose + +// +// cardDrvrIsRunning +// returns TRUE if the card driver is currently running (open) +// +// in: +// out: +// global: +// +// GNP 19 Feb 07 +// +int cardDrvrIsRunning(sCardDev *cdev) +{ + return(0); +//DONE("cardDrvrIsRunning") +} // cardDrvrIsRunning + +#endif //SYS_PC +//EOF diff --git a/libraries/pmrt/card/cardpriv.h b/libraries/pmrt/card/cardpriv.h new file mode 100755 index 0000000..3757832 --- /dev/null +++ b/libraries/pmrt/card/cardpriv.h @@ -0,0 +1,231 @@ +// +// cardpriv.h +// card reader header, internal +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// +#ifndef CARDPRIV_H +#define CARDPRIV_H + +#define CARDPRIV_VER_STRING "c" + +#define CARD_IOPORT_DEFAULT 3 +#define CARD_BAUD_DEFAULT 9600 + +// +// M_CARD_FLAGS_ +// flags set/cleared by card mid-level routines +// +#define M_CARD_FLAGS_FLUSHIO 0x00000001 +#define M_CARD_FLAGS_SELECTMAG 0x00000002 +#define M_CARD_FLAGS_FLUSHMAG 0x00000004 +#define M_CARD_FLAGS_GREENLEDON 0x00000008 +#define M_CARD_FLAGS_GREENLEDOFF 0x00000010 +#define M_CARD_FLAGS_REDLEDON 0x00000020 +#define M_CARD_FLAGS_REDLEDOFF 0x00000040 +#define M_CARD_FLAGS_CARDIN_PROCESSED 0x00100000 +#define M_CARD_FLAGS_DATA1_PROCESSED 0x00200000 +#define M_CARD_FLAGS_DATA2_PROCESSED 0x00400000 +#define M_CARD_FLAGS_DATA3_PROCESSED 0x00800000 +#define M_CARD_FLAGS_NODATA_PROCESSED 0x01000000 +#define M_CARD_FLAGS_DATA_EXPECTED 0x02000000 + +// +// M_CARD_INTFLAGS_ +// flags set/cleared only by card reader thread +// +#define M_CARD_INTFLAGS_FLUSHIO_ACK 0x00000001 +#define M_CARD_INTFLAGS_SELECTMAG_ACK 0x00000002 +#define M_CARD_INTFLAGS_RESET 0x00000004 // card reader reset +#define M_CARD_INTFLAGS_ACK 0x00000008 +#define M_CARD_INTFLAGS_READERVERSION 0x00000010 +#define M_CARD_INTFLAGS_WAITINGFORCARDINACK 0x00000020 +#define M_CARD_INTFLAGS_HIDDATA 0x00000040 +#define M_CARD_INTFLAGS_CARDIN 0x00010000 +#define M_CARD_INTFLAGS_DATA1 0x00020000 +#define M_CARD_INTFLAGS_DATA2 0x00040000 +#define M_CARD_INTFLAGS_DATA3 0x00080000 +#define M_CARD_INTFLAGS_NODATA 0x00100000 + +// +// M_CARD_INTERROR_ +// error flags set only by card reader thread +// +#define M_CARD_INTERROR_ROVERFLOW 0x00000001 +#define M_CARD_INTERROR_GREENLED 0x00010000 +#define M_CARD_INTERROR_REDLED 0x00020000 +#define M_CARD_INTERROR_MAGMODE 0x00040000 +#define M_CARD_INTERROR_PHASE 0x00080000 + +// +// M_TRACKFLAGS_ +// +#define M_TRACKFLAGS_DATAREAD 0x00000001 +#define M_TRACKFLAGS_ERROR 0x00000002 +#define M_TRACKFLAGS_BLANK 0x00000004 +#define M_TRACKFLAGS_ALLCLOCK 0x00000008 +#define M_TRACKFLAGS_NOSS 0x00000010 +#define M_TRACKFLAGS_NOES 0x00000020 +#define M_TRACKFLAGS_BADLRC 0x00000040 +#define M_TRACKFLAGS_PARITY 0x00000080 + +#define CARD_OK 0 // Success +#define CARD_MESSAGE_READY 1 // Message ready in buffer +#define CARD_ERR_INVALID -1 // Invalid Data +#define CARD_ERR_HID -2 // HID command error +#define CARD_ERR_NODATA -3 // No card reader data available +#define CARD_ERR_NOMEM -4 // No read buffer available + +#define XICO_SEND_PACKET_LEN 47 + +#if SYS_PC +#include +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + int avail; // packets available + int (*callback)(int op,...); + unsigned int iComPort; // Open Com Port number + unsigned long iBaudRate; + int readerType; + + // intFlags, intErrorf and card track data (only written by xxxcardThread, read all you want) + unsigned intFlags; + unsigned intErrorf; // error flags + unsigned char cmd[264]; + unsigned char rsp[264]; + unsigned char TrackLen[3]; // public data + char TrackData[3][128]; // public data + char readerVersion[256]; // public data + unsigned long intTrackFlags[3]; // interrupt only data + unsigned char intTrackLen[3]; // interrupt only data + char intTrackData[3][128]; // interrupt only data + + + // implementation specific + HANDLE thread; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + +} sCardDev; +#elif SYS_BB +#include +#define _POSIX_SOURCE 1 // POSIX compliant source +#define FALSE 0 +#define TRUE 1 +#define _XOPEN_SOURCE 500 // makes usleep() get defined properly? +#include +#include +#include +#include //posix threads +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + int avail; // packets available + int (*callback)(int op,...); + unsigned int iComPort; // Open Com Port number + unsigned long iBaudRate; + int readerType; + + // intFlags, intErrorf and card track data (only written by xxxcardThread, read all you want) + unsigned intFlags; + unsigned intErrorf; // error flags + unsigned char cmd[264]; + unsigned char rsp[264]; + unsigned char TrackLen[3]; // public data + char TrackData[3][128]; // public data + char readerVersion[256]; + unsigned long intTrackFlags[3]; // interrupt only data + unsigned char intTrackLen[3]; // interrupt only data + char intTrackData[3][128]; // interrupt only data + + // implementation specific + pthread_t thread; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + + int iPd; // port file descriptor + struct termios newtio; + struct termios oldtio; + + HIDInterface *hid; + char sendBuf[XICO_SEND_PACKET_LEN]; +} sCardDev; +#else +#error Must define SYS_ in pre-processor +#endif + +#define CARD_TRACK1_SS '%' // track 1 start sentinel +#define CARD_TRACK2_SS ';' // track 2 start sentinel +#define CARD_TRACK_ES '?' // track end sentinel (same for all tracks) +#define CARD_TRACK1_FC 'P' // track 1 format code +#define CARD_TRACK_PAN_LENGTH 4 //track 1 character length of primary account # +#define CARD_TRACK_PAN "1995" // track primary account # (always same for PM) +#define CARD_TRACK_PAN_INT 1995 //integer version of PAN +#define CARD_TRACK_FS '^' // track trailing field separator +#define CARD_TRACK_FS_OPERATOR ':' //track leading field separator indicating operator card +#define CARD_TRACK_FS_PLAYER '<' //track leading field separator indicating player card +#define CARD_TRACK1_NS '/' //track 1 name separator +#define CARD_TRACK1_NAME_LENGTH 26 //character length of NAME field +#define CARD_TRACK_ID_LENGTH 9 //character length of ID field +#define CARD_TRACK_GAME_LENGTH 3 //character length of GAME field +#define CARD_TRACK_COUNTRY_LENGTH 3 //character length of COUNTRY field +#define CARD_TRACK_CID_LENGTH 3 //character length of CARD ID field +#define CARD_TRACK_CHKDIG_LENGTH 1 //character length of Check Digit field + +// +// sTrack1Data +// card data as it appears on track 1 of the card +// +typedef struct { + char ss; + char fc; + char pan[CARD_TRACK_PAN_LENGTH]; + char fs1; + char name[CARD_TRACK1_NAME_LENGTH]; + char fs; + char id[CARD_TRACK_ID_LENGTH]; + char game[CARD_TRACK_GAME_LENGTH]; + char country[CARD_TRACK_COUNTRY_LENGTH]; + char cid[CARD_TRACK_CID_LENGTH]; + char chkdig; + char es; +} sTrack1Data; + +// +// sTrack2Data +// card data as it appears on track 2 of the card +// +typedef struct { + char ss; + char pan[CARD_TRACK_PAN_LENGTH]; + char fs1; + char id[CARD_TRACK_ID_LENGTH]; + char game[CARD_TRACK_GAME_LENGTH]; + char country[CARD_TRACK_COUNTRY_LENGTH]; + char cid[CARD_TRACK_CID_LENGTH]; + char chkdig; + char es; +} sTrack2Data; + +extern int cardDrvrInit(sCardDev *cdev); +extern void cardDrvrFinal(sCardDev *cdev); +extern int cardDrvrOpen(sCardDev *cdev); +extern void cardDrvrClose(sCardDev *cdev); +extern int cardDrvrIsRunning(sCardDev *cdev); +extern sCardDev *cardGetDevice(void); + +#endif // ndef CARDPRIV_H +// EOF diff --git a/libraries/pmrt/card/cardtest b/libraries/pmrt/card/cardtest new file mode 100755 index 0000000..c3fe302 Binary files /dev/null and b/libraries/pmrt/card/cardtest differ diff --git a/libraries/pmrt/card/cardtest.c b/libraries/pmrt/card/cardtest.c new file mode 100755 index 0000000..5769710 --- /dev/null +++ b/libraries/pmrt/card/cardtest.c @@ -0,0 +1,298 @@ +// cardtest.c +// GNP 20 Feb 07 + +#define CARDTEST_VERS "A" + +#include +#include +#include +#include "card.h" + +int card_callback(int op,...); + + + +#if SYS_PC +#include +int ConKeyRead(char *buf,int bufsize) +{ + HANDLE h=INVALID_HANDLE_VALUE; + DWORD dw,save=-1,i; + INPUT_RECORD ir[256]; + int len=0; + + // Get the standard input handle. + h=GetStdHandle(STD_INPUT_HANDLE); + if(h == INVALID_HANDLE_VALUE) + goto BAIL; + + // save + if (!GetConsoleMode(h, &save) ) + goto BAIL; + + // enable + dw=ENABLE_WINDOW_INPUT; + if(!SetConsoleMode(h, dw) ) + goto BAIL; + + // check for input -- don't block if there is none ready + if(!GetNumberOfConsoleInputEvents(h,&dw)) + goto BAIL; + if(!dw) + goto BAIL; + + if(!ReadConsoleInput(h,ir,sizeof(ir)/sizeof(ir[0]),&dw)) + goto BAIL; + + for(i=0;i +#include +#include +#include +#include +#include +struct termios rawtio; +struct termios savetio; +int conInit(void) +{ + tcgetattr(STDIN_FILENO,&savetio); + rawtio=savetio; + rawtio.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + rawtio.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + rawtio.c_cflag &= ~(CSIZE | PARENB); + rawtio.c_cflag |= CS8; + rawtio.c_oflag &= ~(OPOST); + rawtio.c_cc[VMIN]=0; + rawtio.c_cc[VTIME]=0; + return 0; +} +void conFinal(void) +{ + // tcsetattr(STDIN_FILENO,TCSANOW,&savetio); +} +int ConKeyRead(char *buf,int bufsize) +{ + int i; + tcsetattr(STDIN_FILENO,TCSANOW,&rawtio); + usleep(100); + i=read(STDIN_FILENO,buf,bufsize); + tcsetattr(STDIN_FILENO,TCSANOW,&savetio); + return i; +} // ConKeyRead() +#endif // SYS_BB + +char asciibuf[128]; + + + +void cardtesthelp(void) +{ + char buf[64]; + + CardGetVersionString(buf,sizeof(buf)); + + printf("Play Mechanix, Inc. - Card Test (vers %s%s)\n",CARDTEST_VERS,buf); + printf("Copyright(c)2007, All Rights Resvd.\n"); + printf("-------------------------------------\n"); + printf(" =exit h=help r=reset\n"); + printf(" f=flush i/o m=select magmode\n"); +} // cardtesthelp() + +// JFL 05 May 05 +int main(int argc,char *argv[]) +{ + int ec,i,ii,rType; + char buf[256]; + char c; + + + conInit(); + cardtesthelp(); + + if((ec=CardInit())<0) + { + printf("CardInit failed\n"); + goto BAIL; + } + + if((ec=CardSetCallback(card_callback))<0) + { + printf("CardSetCallback failed\n"); + goto BAIL; + } + + printf("card opened successfully\n"); + rType=CARDREADER_XICO; + CardBegin(rType); + + for(;;) + { + if((ii=ConKeyRead(buf,sizeof(buf)))>0) + { + for(i=0;ibOperator?"Operator":"Player"); + printf("Name: %s %s %s\n",cData->firstName,cData->middleName,cData->lastName); + printf("ID: %09lu\n",cData->id); + printf("Game: %03lu\n",cData->gameNumber); + printf("Country: %03lu\n",cData->countryCode); + printf("Card ID: %03lu\n",cData->cardId); +// increment total number of swipes and number of successful reads from Track 1 then display + numswipes++; + numsuccesst1++; + printf("Swipes= %d :: Track 1 Successes= %d :: Track 2 Successes= %d :: Failures= %d\n", numswipes, numsuccesst1, numsuccesst2, numfails); + break; + + case CARDCALLBACK_TRACK2DATA: + cData = va_arg(args,void*); + printf("Card data received on Track 2:\n"); + printf("%s card\n",cData->bOperator?"Operator":"Player"); + printf("ID: %09lu\n",cData->id); + printf("Game: %03lu\n",cData->gameNumber); + printf("Country: %03lu\n",cData->countryCode); + printf("Card ID: %03lu\n",cData->cardId); +// increment total number of swipes and number of successful reads from Track 2 then display + numswipes++; + numsuccesst2++; + printf("Swipes= %d :: Track 1 Successes= %d :: Track 2 Successes= %d :: Failures= %d\n", numswipes, numsuccesst1, numsuccesst2, numfails); + break; + + + case CARDCALLBACK_DATAERROR: + printf("Card data received and not recognized.\n"); +// increment total number of swipes and number of failures then display + numswipes++; + numfails++; + printf("Swipes= %d :: Track 1 Successes= %d :: Track 2 Successes= %d :: Failures= %d\n", numswipes, numsuccesst1, numsuccesst2, numfails); + break; + + case CARDCALLBACK_NODATA: + printf("Card data not present.\n"); +// increment total number of swipes and number of failures then display + numswipes++; + numfails++; + printf("Swipes= %d :: Track 1 Successes= %d :: Track 2 Successes= %d :: Failures= %d\n", numswipes, numsuccesst1, numsuccesst2, numfails); + break; + + case CARDCALLBACK_CARDIN: + printf("Card IN\n"); + break; + case CARDCALLBACK_CARDOUT: + printf("Card OUT\n"); + break; + } + + va_end(args); + return 0; +} // card_callback() + +void* card_apphook_malloc(int size) +{ + return malloc(size); +} // card_apphook_malloc() + +void card_apphook_free(void *m) +{ + free(m); +} // card_apphook_free() + +void card_apphook_msg(char *fmt,...) +{ + va_list args; + + va_start(args,fmt); + vprintf(fmt,args); + va_end(args); +} // card_apphook_msg() + +// EOF diff --git a/libraries/pmrt/card/cardtest.dsp b/libraries/pmrt/card/cardtest.dsp new file mode 100755 index 0000000..34021c7 --- /dev/null +++ b/libraries/pmrt/card/cardtest.dsp @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="cardtest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=cardtest - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "cardtest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "cardtest.mak" CFG="cardtest - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cardtest - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "cardtest - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/card", KJMAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "cardtest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SYS_PC" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib card.lib /nologo /subsystem:console /machine:I386 /libpath:".\release" + +!ELSEIF "$(CFG)" == "cardtest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "cardtest___Win32_Debug" +# PROP BASE Intermediate_Dir "cardtest___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "cardtest___Win32_Debug" +# PROP Intermediate_Dir "cardtest___Win32_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SYS_PC" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib card.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:".\debug" + +!ENDIF + +# Begin Target + +# Name "cardtest - Win32 Release" +# Name "cardtest - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cardtest.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/card/cardtest.o b/libraries/pmrt/card/cardtest.o new file mode 100644 index 0000000..366afff Binary files /dev/null and b/libraries/pmrt/card/cardtest.o differ diff --git a/libraries/pmrt/card/libcard.a b/libraries/pmrt/card/libcard.a new file mode 100644 index 0000000..fb2fd74 Binary files /dev/null and b/libraries/pmrt/card/libcard.a differ diff --git a/libraries/pmrt/card/luhn.xls b/libraries/pmrt/card/luhn.xls new file mode 100755 index 0000000..c0f30b4 Binary files /dev/null and b/libraries/pmrt/card/luhn.xls differ diff --git a/libraries/pmrt/card/makedeplib b/libraries/pmrt/card/makedeplib new file mode 100644 index 0000000..360acca --- /dev/null +++ b/libraries/pmrt/card/makedeplib @@ -0,0 +1,64 @@ +card.o: card.c card.h cardpriv.h /g3/include/hid.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /g3/include/usb.h /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/hidparser.h \ + /g3/include/hidtypes.h /usr/include/termios.h \ + /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /usr/include/string.h +card_lin.o: card_lin.c card.h cardpriv.h /g3/include/hid.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /g3/include/usb.h /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/hidparser.h \ + /g3/include/hidtypes.h /usr/include/termios.h \ + /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \ + /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h \ + /usr/include/bits/ioctl-types.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/string.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h diff --git a/libraries/pmrt/card/makedeptest b/libraries/pmrt/card/makedeptest new file mode 100644 index 0000000..651f455 --- /dev/null +++ b/libraries/pmrt/card/makedeptest @@ -0,0 +1,22 @@ +cardtest.o: cardtest.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h card.h \ + /usr/include/termios.h /usr/include/bits/termios.h \ + /usr/include/sys/ttydefaults.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/sys/ioctl.h \ + /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h \ + /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h \ + /usr/include/fcntl.h /usr/include/bits/fcntl.h /usr/include/string.h diff --git a/libraries/pmrt/card/makefile b/libraries/pmrt/card/makefile new file mode 100755 index 0000000..e790e09 --- /dev/null +++ b/libraries/pmrt/card/makefile @@ -0,0 +1,50 @@ +# make driver +# make install (as root) +# +.CTESTFILES = cardtest.c +.CLIBFILES = card.c card_lin.c + +.OTESTFILES = $(.CTESTFILES:.c=.o) +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETTEST = cardtest +TARGETLIB = libcard.a + +LIBTEST= libcard.a /g3/lib/libhid.a /g3/lib/libusb.a -lrt +#LIBS = /usr/local/lib/libusb.a /usr/local/lib/libhid.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map + +all: $(TARGETLIB) $(TARGETTEST) + +$(TARGETTEST) : $(.OTESTFILES) $(LIBTEST) $(DEPENDTESTFILE) makefile + $(CC) $(LINKFLAGS) -o $(TARGETTEST) $(.OTESTFILES) $(LIBTEST) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) + cp $(TARGETLIB) /g3/lib + cp card.h /g3/include + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDTESTFILE): + $(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDTESTFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/card/mssccprj.scc b/libraries/pmrt/card/mssccprj.scc new file mode 100755 index 0000000..662cdf3 --- /dev/null +++ b/libraries/pmrt/card/mssccprj.scc @@ -0,0 +1,9 @@ +SCC = This is a Source Code Control file + +[card.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/card", KJMAAAAA + +[cardtest.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/card", KJMAAAAA diff --git a/libraries/pmrt/card/vssver.scc b/libraries/pmrt/card/vssver.scc new file mode 100755 index 0000000..8f33164 Binary files /dev/null and b/libraries/pmrt/card/vssver.scc differ diff --git a/libraries/pmrt/dongle/dongle.c b/libraries/pmrt/dongle/dongle.c new file mode 100755 index 0000000..bbcfa96 --- /dev/null +++ b/libraries/pmrt/dongle/dongle.c @@ -0,0 +1,794 @@ +#if SYS_PC +#define WIN32_LEAN_AND_MEAN +#include +#include "ryvc32.h" +#include "getopt.h" +#define ROCKEY_FUNC Rockey +#else +#include +#include +#define ROCKEY_FUNC rockey +#endif + +#include "dongle.h" +#include +#include +#include +#include +#include + +//***globals*** +static hasp_handle_t alHandle = 0; +static unsigned long retCode = 0; +static unsigned char ftBuffer[1024]; // Rockey Variable +//***end globals*** + +/*! + \brief Initialize a dongle. Currently supports FeiTian and Aladdin + \author RA + \date 2007/11/09 + \param handle will point to a valid handle if function suceeds + \param type Pass in DONGLE_TYPE_UNKNOWN to try all dongles, else pass in specific one + \param key dongle password. + \param key_len lenght of the password in bytes + \return int DONGLE_OK on sucess. +*/ +int DongleInit(DongleHandle *handle, DongleType type, unsigned char *key, unsigned int key_len) +{ + int success = 0; + + if(!handle) + return DONGLE_ERR_INVALIDHANDLE; + + handle->type = (type == DONGLE_TYPE_UNKNOWN) ? DONGLE_TYPE_FEITIAN : type; + handle->opened = 0; + handle->data = NULL; + handle->initData = NULL; + handle->data = malloc(sizeof(FeiTianData)); + + //if it succeeds opening, it is a FEITIAN dongle + if(handle->type == DONGLE_TYPE_FEITIAN) + { + unsigned short *pkey = (unsigned short*)key; + FeiTianData *ftData = handle->data; + + ftData->p1 = pkey[0]; + ftData->p2 = pkey[1]; + + if ( key_len >= 8 ) // write passwords also passed in + { + ftData->p3 = pkey[2]; + ftData->p4 = pkey[3]; + } + else + { + ftData->p3 = 0; + ftData->p4 = 0; + } + + if(DongleOpen(handle, key) == DONGLE_OK) + success = 1; + + //erase the key + ftData->p1 = ftData->p2 = ftData->p3 = ftData->p4 = 0; + } + + if(handle->type == DONGLE_TYPE_FEITIAN && type == DONGLE_TYPE_FEITIAN && !success) + return DONGLE_ERR_OPENFAILED; + + //try aladdin dongle if feitian fails + if(!success) + { + AladdinInitData *aladdinOpenData = malloc(sizeof(AladdinInitData)); + int retVal = 0; + + handle->type = DONGLE_TYPE_ALADDIN; + + free(handle->data); + handle->data = malloc(sizeof(AladdinData)); + + aladdinOpenData->vendorCode = malloc(key_len); + memcpy(aladdinOpenData->vendorCode, key, key_len ); + + #ifdef DEBUG + printf("Using vc: %s \n", aladdinOpenData->vendorCode); + #endif + + handle->initData = aladdinOpenData; + retVal = DongleOpen(handle, NULL); + if(retVal != DONGLE_OK) + { + #ifdef DEBUG + printf("Error opening aladdin dongle: %d \n", retVal); + #endif + return DONGLE_ERR_OPENFAILED; + } + + //erase key + memset(aladdinOpenData->vendorCode, 0, key_len); + free(aladdinOpenData->vendorCode); + aladdinOpenData->vendorCode = NULL; + } + + return DONGLE_OK; +} + +/*! + \brief Will perform some operation using the dongle. If the operation succeeds, then the function returns + true. + -Feitian dongles will try generating a random number + -Aladdin dongles will try encrypted 32 bytes of garbage data + \author RA + \date 2007/11/09 + \param handle handle to an open dongle + \return int DONGLE_OK on sucess +*/ +int DongleIsPresent(DongleHandle *handle) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleIsPresent: invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->opened) + { + #ifdef DEBUG + printf("DongleIsPresent: not open \n"); + #endif + + return DONGLE_ERR_NOTOPEN; + } + + switch(handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + unsigned long retCode = 0; + FeiTianData *ftData = handle->data; + short ryOut = 0; + + retCode = ROCKEY_FUNC(RY_RANDOM, &ftData->handle, &ftData->lp1, &ftData->lp2, &ryOut, &ftData->p2, &ftData->p3, &ftData->p4, ftBuffer ); + if(retCode != 0) + { + #ifdef DEBUG + printf("DongleIsPresent: Failed to find feitian dongle: %d\n", (int)retCode ); + #endif + + handle->api_err_code = retCode; + return DONGLE_ERR_FINDFAILED; + } + + }break; + + case DONGLE_TYPE_ALADDIN: + { + char buffer[32]; + int retVal = 0; + + if( (retVal = DongleEncrypt(handle, buffer, sizeof(buffer)) != DONGLE_OK) ) + { + #ifdef DEBUG + printf("DongleIsPresent: Aladdin dongle not found: %d \n", retVal); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_READFAILED; + } + + handle->opened = 1; + }break; + + default: + { + #ifdef DEBUG + printf("DongleIsPresent: Invalid dongle type \n"); + #endif + + }break; + } + +// dprintf("DongleIsPresent: true \n"); + return DONGLE_OK; +} + +int DongleOpen(DongleHandle *handle, unsigned char *key) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleOpen: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(handle->opened) + { + #ifdef DEBUG + printf("DongleOpen: Dongle already open \n"); + #endif + return DONGLE_ERR_ALREADYOPEN; + } + + switch(handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + unsigned long retCode = 0; + FeiTianData *ftData = handle->data; + handle->data = ftData; + ftData->lp1 = 0; + ftData->lp2 = 0; + + retCode = ROCKEY_FUNC(RY_FIND, &ftData->handle, &ftData->lp1, &ftData->lp2, &ftData->p1, + &ftData->p2, &ftData->p3, &ftData->p4, ftBuffer); + if(retCode != 0) + { + #ifdef DEBUG + printf("DongleOpen: Failed to find feitian dongle: %d \n", (int)retCode ); + #endif + handle->api_err_code = retCode; + return DONGLE_ERR_FINDFAILED; + } + + retCode = ROCKEY_FUNC(RY_OPEN, &ftData->handle, &ftData->lp1, &ftData->lp2, &ftData->p1, + &ftData->p2, &ftData->p3, &ftData->p4, ftBuffer); + + if(retCode != 0) + { + #ifdef DEBUG + printf("DongleOpen: Failed to open feitian dongle.\n" ); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_OPENFAILED; + } + + handle->opened = 1; + + // store id as it lp1 maybe overwritten by subsequent calls + ftData->id = (unsigned int)ftData->lp1; + + #ifdef DEBUG + printf("DongleOpen: Found feitian dongle %u.\n", ftData->id); + #endif + + }break; + + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + AladdinInitData *initData = handle->initData; + if(!initData || !initData->vendorCode) + return -1; + + alHandle = hasp_login(HASP_PROGNUM_DEFAULT_FID, (hasp_vendor_code_t*)initData->vendorCode, &alData->handle); + if(alHandle != HASP_STATUS_OK) + { + #ifdef DEBUG + printf("DongleOpen: Unable to login to aladdin dongle. HE: %u \n", alHandle); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_FINDFAILED; + } + + handle->opened = 1; + }break; + + default: + break; + } + + return DONGLE_OK; +} + +int DongleRead(DongleHandle *handle, int startByte, int bytes, char *dest) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleRead: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->opened) + { + #ifdef DEBUG + printf("DongleRead: Dongle is not open \n"); + #endif + + return DONGLE_ERR_NOTOPEN; + } + + switch (handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + FeiTianData *ftData = handle->data; + ftData->p1 = startByte; + ftData->p2 = bytes; + retCode = ROCKEY_FUNC(RY_READ, &ftData->handle, &ftData->lp1, &ftData->lp2, &ftData->p1, &ftData->p2, &ftData->p3, &ftData->p4, dest); + if(retCode != 0) + { + #ifdef DEBUG + printf("DongleRead: Failed to read from feitian dongle: %d \n", (int)retCode ); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_READFAILED; + } + + }break; + + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + + alHandle = hasp_read(alData->handle, + HASP_FILEID_MAIN, + startByte, /* offset */ + bytes, /* length */ + dest); + + if(alHandle != HASP_STATUS_OK) + { + #ifdef DEBUG + printf("DongleRead: failed reading from aladdin dongle. HE: %u \n", alHandle); + #endif + handle->api_err_code = retCode; + return DONGLE_ERR_READFAILED; + } + + }break; + } + + return DONGLE_OK; +} + +int DongleWrite(DongleHandle *handle, int startByte, int bytes, char *src) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleWrite: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->data) + { + #ifdef DEBUG + printf("DongleWrite: No data founbd in handle \n"); + #endif + return DONGLE_ERR_NODATA; + } + + switch(handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + FeiTianData *ftData = handle->data; + + ftData->p1 = startByte; + ftData->p2 = bytes; + + retCode = ROCKEY_FUNC(RY_WRITE, &ftData->handle, &ftData->lp1, &ftData->lp2, &ftData->p1, &ftData->p2, &ftData->p3, &ftData->p4, src); + + if(retCode != 0) + { + #ifdef DEBUG + printf("DongleWrite: Failed to write to feitian dongle: %d \n", (int)retCode); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_WRITEFAILED; + } + + }break; + + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + + alHandle = hasp_write(alData->handle, + HASP_FILEID_MAIN, + startByte, /* offset */ + bytes, /* length */ + src); + + + if(alHandle != HASP_STATUS_OK) + { + #ifdef DEBUG + printf("DongleWrite: Failed writing to aladdin dongle. HE: %u \n", alHandle); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_WRITEFAILED; + } + }break; + } + + return DONGLE_OK; +} + +int DongleClose(DongleHandle *handle) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleClose: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->opened) + { + #ifdef DEBUG + printf("DongleClose: Dongle is not open \n"); + #endif + return DONGLE_ERR_NOTOPEN; + } + + switch(handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + FeiTianData *ftData = handle->data; + + retCode = ROCKEY_FUNC(RY_CLOSE, &ftData->handle, &ftData->lp1, &ftData->lp2, &ftData->p1, &ftData->p2, &ftData->p3, + &ftData->p4, ftBuffer); + + if(retCode != 0) + { + #ifdef DEBUG + printf("DongleClose: Failed to close feitian handle: %d \n", (int)retCode); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_CLOSEFAILED; + } + handle->opened = 0; + }break; + + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + + alHandle = hasp_logout(alData->handle); + + handle->opened = 0; + if(alHandle != HASP_STATUS_OK) + { + #ifdef DEBUG + printf("DongleClose: failed closing aladdin dongle (ec = %d)\n", %d); + #endif + handle->api_err_code = retCode; + + } + + if(handle->initData) + { + AladdinInitData *initData = handle->initData; + if(initData) + { + if(initData->vendorCode) + { + free(initData->vendorCode); + initData->vendorCode = NULL; + } + free(initData); + } + handle->initData = NULL; + } + }break; + } + + free(handle->data); + + return DONGLE_OK; +} + +/*! + \brief Get the unique hardware id on the dongle. + \author RA + \date 2007/11/09 + \param handle handle to an open dongle + \param outId will be filled in with the id if the function suceeds + \return int DONGLE_OK on sucess +*/ +int DongleGetID(DongleHandle *handle, unsigned int *outId) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleGetID: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->data) + { + #ifdef DEBUG + printf("DongleGetID: No data in handle \n"); + #endif + return DONGLE_ERR_NODATA; + } + + switch(handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + FeiTianData *ftData = handle->data; + + *outId = ftData->id; + }break; + + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + char *info = NULL; + char *idBeg = NULL; + char *idEnd = NULL; + char id[255]; + + memset(id, 0, sizeof(char)*255); + + alHandle = hasp_get_sessioninfo(alData->handle, HASP_KEYINFO, &info); + + if(alHandle != HASP_STATUS_OK) + { + #ifdef DEBUG + printf("DongleGetID: Error getting session for aladdin. HE: %u \n", alHandle); + #endif + handle->api_err_code = retCode; + + return DONGLE_ERR_SESSION; + } + + //the output is in xml format, so search for beginning and end of tags + idBeg = strstr(info, ""); + idEnd = strstr(info, ""); + + if(!idBeg || !idEnd) + { + #ifdef DEBUG + printf("DongleGetID: Error parsing aladdin xml \n"); + #endif + + return DONGLE_ERR_BADPARSE; + } + + //get beginning and end of tag + idBeg += strlen(""); + idEnd = (info + (idEnd - info)); + if(idEnd < idBeg || idEnd - idBeg >= 255) + { + #ifdef DEBUG + printf("DongleGetID: Invalid aladdin parsing data \n"); + #endif + return DONGLE_ERR_BADPARSE; + } + + //copy data between tags, should be the id + memcpy( id, idBeg, sizeof(char)*(idEnd - idBeg) ); + + *outId = atol(id); + + }break; + + }//end switch + + return DONGLE_OK; +} + +/*! + \brief Generate a random number using the dongle. + Supported dongles: Feitian + \author RA + \date 2007/11/09 + \param handle handle to an open dongle + \param buffer will be filled in with random number if function suceeds + \param numBytes number of bytes to generate + \return int DONGLE_OK on sucess +*/ +int DongleGetRand(DongleHandle *handle, unsigned char *buffer, int numBytes ) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleGetRand: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->data) + { + #ifdef DEBUG + printf("DongleGetRand: No data in handle \n"); + #endif + return DONGLE_ERR_NODATA; + } + + switch(handle->type) + { + case DONGLE_TYPE_FEITIAN: + { + // fetian dribs out randomness 2 bytes at a time + int retCode = 0; + int i = 0; + short ryOut = 0; + unsigned char *bytes; + FeiTianData *ftData = handle->data; + + for( i = 0; i < numBytes; i+=2 ) + { + retCode = ROCKEY_FUNC(RY_RANDOM, &ftData->handle, &ftData->lp1, &ftData->lp2, &ryOut, &ftData->p2, &ftData->p3, &ftData->p4, ftBuffer); + if( retCode != 0) + { + handle->api_err_code = retCode; + #ifdef DEBUG + printf("DongleGetRand: Error getting random number from feitian \n"); + #endif + + return DONGLE_ERR_RANDFAILED; + } + bytes = (unsigned char*) &ryOut; + + buffer[i]= bytes[0]; + if ( i + 1 < numBytes ) + buffer[i+1]= bytes[1]; + + } + }break; + + case DONGLE_TYPE_ALADDIN: + { + // Aladdin dongle does not have a random number generator + // routine, so just return 0 + //unsigned char buf[16]; + //memset(buf, 0, sizeof(char)*16); + //memcpy(num, buf, sizeof(short)); + #ifdef DEBUG + printf("DongleGetRand: Feature not supported in Aladdin \n"); + #endif + + return DONGLE_ERR_FEATURE_UNSUPPORTED; + + }break; + + }//end switch + + return DONGLE_OK; +} + +/*! + \brief Encrypte data through the dongle. + Supported dongles: Aladdin + \author RA + \date 2007/11/09 + \param handle handle to an open dongle + \param inOutData data to encrypt. will be modified to hold encrypted data on sucess + \param size size of the data in bytes + \return int DONGLE_OK on sucess +*/ +int DongleEncrypt(DongleHandle *handle, char *inOutData, unsigned int size) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleEncrypt: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->opened) + { + #ifdef DEBUG + printf("DongleEncrypt: Not open \n"); + #endif + return DONGLE_ERR_NOTOPEN; + } + if(!handle->data) + { + #ifdef DEBUG + printf("DongleEncrypt: No data in handle \n"); + #endif + return DONGLE_ERR_NODATA; + } + + switch(handle->type) + { + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + + if( (alHandle = hasp_encrypt(alData->handle, (unsigned char*)inOutData, size)) != HASP_STATUS_OK) + { + handle->api_err_code = alHandle; + #ifdef DEBUG + printf("DongleEncrypt: Error encrypting with aladdin. HE: %u \n", alHandle); + #endif + + return DONGLE_ERR_ENCRYPTFAILED; + } + }break; + + default: + { + #ifdef DEBUG + printf("DongleEncrypt: Feature not supported \n"); + #endif + + return DONGLE_ERR_FEATURE_UNSUPPORTED; + } + } + + return DONGLE_OK; +} + +/*! + \brief Decrypt data through the dongle + Supported dongles: Aladdin + \author RA + \date 2007/11/09 + \param handle handle to an open dongle + \param inOutData data to decrypt. will be modified to hold decrypted data on sucess + \param size size of the data in bytes + \return int DONGLE_OK on sucess +*/ +int DongleDecrypt(DongleHandle *handle, char *inOutData, unsigned int size) +{ + if(!handle) + { + #ifdef DEBUG + printf("DongleDecrypt: Invalid handle \n"); + #endif + return DONGLE_ERR_INVALIDHANDLE; + } + if(!handle->opened) + { + #ifdef DEBUG + printf("DongleDecrypt: Not open \n"); + #endif + return DONGLE_ERR_NOTOPEN; + } + if(!handle->initData) + { + #ifdef DEBUG + printf("DongleDecrypt: No data in handle \n"); + #endif + return DONGLE_ERR_NODATA; + } + + switch(handle->type) + { + case DONGLE_TYPE_ALADDIN: + { + AladdinData *alData = handle->data; + + if( (alHandle = hasp_decrypt(alData->handle, (unsigned char*)inOutData, size)) != HASP_STATUS_OK) + { + handle->api_err_code = alHandle; + #ifdef DEBUG + printf("DongleDecrypt: Error decrypting with aladdin. HE: %u \n", alHandle); + #endif + + return DONGLE_ERR_DECRYPTFAILED; + } + }break; + + default: + { + #ifdef DEBUG + printf("DongleDecrypt: Feature not supported \n"); + #endif + + return DONGLE_ERR_FEATURE_UNSUPPORTED; + } + } + + return DONGLE_OK; +} + +//EOF + + + + diff --git a/libraries/pmrt/dongle/dongle.dsp b/libraries/pmrt/dongle/dongle.dsp new file mode 100755 index 0000000..3196e49 --- /dev/null +++ b/libraries/pmrt/dongle/dongle.dsp @@ -0,0 +1,112 @@ +# Microsoft Developer Studio Project File - Name="dongle" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=dongle - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "dongle.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "dongle.mak" CFG="dongle - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "dongle - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "dongle - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries/pmrt/dongle", PBRAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "dongle - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "c:\g3\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\dongle copy Release\dongle.lib c:\g3\lib copy *.h c:\g3\include\dongle copy ryvc32.obj c:\g3\lib +# End Special Build Tool + +!ELSEIF "$(CFG)" == "dongle - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\dongle copy Debug\dongle.lib c:\g3\lib copy *.h c:\g3\include\dongle copy ryvc32.obj c:\g3\lib +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "dongle - Win32 Release" +# Name "dongle - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\dongle.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\dongle.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ryvc32.obj +# End Source File +# End Target +# End Project diff --git a/libraries/pmrt/dongle/dongle.h b/libraries/pmrt/dongle/dongle.h new file mode 100755 index 0000000..7e85655 --- /dev/null +++ b/libraries/pmrt/dongle/dongle.h @@ -0,0 +1,242 @@ +#ifndef PMRT_DONGLE +#define PMRT_DONGLE + +#include "hasp_hl.h" + +#define ROCKEY_MAX_STORAGE_BYTES 24 +#define ALADDIN_MAX_STORAGE_BYTES 26 + +typedef enum _DongleType +{ + DONGLE_TYPE_FEITIAN, DONGLE_TYPE_ALADDIN, DONGLE_TYPE_UNKNOWN +}DongleType; + +typedef enum _DongleError +{ + DONGLE_OK, // 0 + DONGLE_ERR_ALREADYOPEN, + DONGLE_ERR_OPENFAILED, + DONGLE_ERR_INVALIDHANDLE, + DONGLE_ERR_FINDFAILED, + DONGLE_ERR_LOGINFAILED, // 5 + DONGLE_ERR_VENDOR, + DONGLE_ERR_VENDORSEEK, + DONGLE_ERR_NOTOPEN, + DONGLE_ERR_READFAILED, + DONGLE_ERR_WRITEFAILED, // 10 + DONGLE_ERR_NODATA, + DONGLE_ERR_CLOSEFAILED, + DONGLE_ERR_SESSION, + DONGLE_ERR_BADPARSE, + DONGLE_ERR_RANDFAILED, // 15 + DONGLE_ERR_INVALIDDONGLE, + DONGLE_ERR_ENCRYPTFAILED, + DONGLE_ERR_DECRYPTFAILED, + DONGLE_ERR_FEATURE_UNSUPPORTED, + +}DongleError; + +typedef struct _FeiTianData +{ + // unsigned char rockeyData[ROCKEY_MAX_STORAGE_BYTES]; + unsigned short p1, p2, p3, p4; // Rockey Variable + short handle; + long lp1, lp2; // Rockey Variable + // unsigned char uc; + unsigned int id; +}FeiTianData; + +typedef struct _AladdinData +{ + // unsigned char buffer[ALADDIN_MAX_STORAGE_BYTES]; + unsigned int options; + hasp_handle_t handle; +}AladdinData; + +typedef struct _AladdinInitData +{ + unsigned char *vendorCode; +}AladdinInitData; + +typedef struct _DongleHandle +{ + int type; + int opened; + void *data; + void *initData; + int api_err_code; // error code from underlying api (HASP, Rockey, etc) +}DongleHandle; + + +#ifdef __cplusplus +extern "C" { +#endif +int DongleInit(DongleHandle *handle, DongleType type, unsigned char *key, unsigned int key_len); +int DongleOpen(DongleHandle *handle, unsigned char *key); +int DongleRead(DongleHandle *handle, int startByte, int bytes, char *dest); +int DongleWrite(DongleHandle *handle, int startByte, int bytes, char *src); +int DongleClose(DongleHandle *handle); +int DongleClose(DongleHandle *handle); +int DongleGetRand(DongleHandle *handle, unsigned char *buffer, int numBytes ); +int DongleIsPresent(DongleHandle *handle); +int DongleGetID(DongleHandle *handle, unsigned int *outNum); +int DongleEncrypt(DongleHandle *handle, char *inOutData, unsigned int size); +int DongleDecrypt(DongleHandle *handle, char *inOutData, unsigned int size); + +#ifdef __cplusplus +} +#endif + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleEncrypt(DongleHandle handle, char *inOutData, unsigned int size, int retVal) +//************************************************* +#define DongleEncryptInline(dongle, inOutData, size, retVal) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + \ + if( (retCode = hasp_encrypt(alData->handle, (unsigned char*)inOutData, size)) != HASP_STATUS_OK) \ + retVal = retCode; \ + }break; \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } + +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleDecrypt(DongleHandle handle, char *inOutData, unsigned int size, int retVal) +//************************************************* +#define DongleDecryptInline(dongle, inOutData, size, retVal) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + \ + if( (retCode = hasp_decrypt(alData->handle, (unsigned char*)inOutData, size)) != HASP_STATUS_OK) \ + retVal = retCode; \ + }break; \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } + +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +#endif + + + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleEncryptWithNoiseInline(DongleHandle handle, char *inOutData, unsigned int size, int retVal, int (*RandFunc)( unsigned char *buffer, int numBytes) ) +//************************************************* +/* does not work +#define DongleEncryptWithNoiseInline(dongle, inOutData, size, retVal, RandFunc) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + void *Noise; \ + Noise = malloc(size*2); \ + RandFunc((unsigned char*)Noise, size*2 ); \ + memcpy( &(((unsigned char*)Noise)[size/2]), inOutData, size ); \ + if( (retCode = hasp_encrypt(alData->handle, (unsigned char*)Noise, size * 2)) != HASP_STATUS_OK) \ + retVal = retCode; \ + memcpy( inOutData, &(((unsigned char*)Noise)[size/2]), size ); \ + free(Noise); \ + }break; \ + \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } +*/ +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +//************************************************* +//*****Ugly macro to force inlining >_> *********** +//DongleDecryptWithNoise(DongleHandle handle, char *inOutData, unsigned int size, int retVal, int (*RandFunc)( unsigned char *buffer, int numBytes)) +//************************************************* +/* +#define DongleDecryptWithNoiseInline(dongle, inOutData, size, retVal, RandFunc) \ + retVal = DONGLE_OK; \ + if(!dongle->opened) \ + retVal = DONGLE_ERR_NOTOPEN; \ + else if(!dongle->data) \ + retVal = DONGLE_ERR_NODATA; \ + \ + if(retVal == DONGLE_OK) \ + { \ + switch(dongle->type) \ + { \ + case DONGLE_TYPE_ALADDIN: \ + { \ + AladdinData *alData = dongle->data; \ + hasp_handle_t retCode; \ + void *Noise; \ + Noise = malloc(size*2); \ + RandFunc((unsigned char*)Noise, size*2 ); \ + memcpy( &(((unsigned char*)Noise)[size/2]), inOutData, size ); \ + if( (retCode = hasp_decrypt(alData->handle, (unsigned char*)Noise, size * 2)) != HASP_STATUS_OK) \ + retVal = retCode; \ + memcpy( inOutData, &(((unsigned char*)Noise)[size/2]), size ); \ + free(Noise); \ + }break; \ + \ + default: \ + retVal = DONGLE_ERR_INVALIDDONGLE; \ + } \ + } +*/ +//************************************************* +//*************End of Encyrpt _0_ ***************** +//************************************************* + +//EOF + + + diff --git a/libraries/pmrt/dongle/dongle.plg b/libraries/pmrt/dongle/dongle.plg new file mode 100755 index 0000000..35cbf8a --- /dev/null +++ b/libraries/pmrt/dongle/dongle.plg @@ -0,0 +1,46 @@ + + +
+

Build Log

+

+--------------------Configuration: dongle - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSPC04.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/dongle.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\G3\libraries\pmrt\dongle\dongle.c" +] +Creating command line "cl.exe @C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSPC04.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\dongle.lib" .\Debug\dongle.obj " +

Output Window

+Compiling... +dongle.c +Creating library... +Creating temporary file "C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSPC05.bat" with contents +[ +@echo off +mkdir c:\g3\include\dongle +copy Debug\dongle.lib c:\g3\lib +copy *.h c:\g3\include\dongle +copy libs\libhasp.lib c:\g3\lib +] +Creating command line "C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSPC05.bat" + +A subdirectory or file c:\g3\include\dongle already exists. + 1 file(s) copied. +dongle.h +getopt.h +hasp_hl.h +hasp_vcode.h +ryvc32.h + 5 file(s) copied. + 1 file(s) copied. + + + +

Results

+dongle.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/dongle/getopt.h b/libraries/pmrt/dongle/getopt.h new file mode 100755 index 0000000..bae04bf --- /dev/null +++ b/libraries/pmrt/dongle/getopt.h @@ -0,0 +1,191 @@ + + +/* getopt.h */ +/* Declarations for getopt. + Copyright (C) 1989-1994, 1996-1999, 2001 Free Software + Foundation, Inc. This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute + it and/or modify it under the terms of the GNU Lesser + General Public License as published by the Free Software + Foundation; either version 2.1 of the License, or + (at your option) any later version. + + The GNU C Library 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with the GNU C Library; if not, write + to the Free Software Foundation, Inc., 59 Temple Place, + Suite 330, Boston, MA 02111-1307 USA. */ + + + + + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if (defined __STDC__ && __STDC__) || defined __cplusplus +# ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ +extern int getopt (); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif +#else /* not __STDC__ */ +extern int getopt (); +# ifndef __need_getopt +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +# endif +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ + diff --git a/libraries/pmrt/dongle/hasp_hl.h b/libraries/pmrt/dongle/hasp_hl.h new file mode 100755 index 0000000..8e6a85d --- /dev/null +++ b/libraries/pmrt/dongle/hasp_hl.h @@ -0,0 +1,956 @@ +/*! \file hasp_hl.h HASP HL API declarations + * + */ + +/*! + * \mainpage HASP HL High Level API + * Copyright Aladdin Knowledge Systems Ltd. + * + * $Id: hasp_hl.h,v 1.3 2004/05/17 08:52:10 gerhard Exp $ + */ + + +#ifndef __HASP_HL_H__ +#define __HASP_HL_H__ + +#ifndef WITH_AKSTYPES +#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) +typedef unsigned __int64 hasp_u64_t; +typedef signed __int64 hasp_s64_t; +#else +typedef unsigned long long hasp_u64_t; +typedef signed long long hasp_s64_t; +#endif +#if defined(_MSC_VER) +typedef unsigned long hasp_u32_t; +typedef signed long hasp_s32_t; +#else +typedef unsigned int hasp_u32_t; +typedef signed int hasp_s32_t; +#endif +typedef unsigned short hasp_u16_t; +typedef signed short hasp_s16_t; +typedef unsigned char hasp_u8_t; +typedef signed char hasp_s8_t; +#endif + +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) +#define HASP_CALLCONV __stdcall +#else +#define HASP_CALLCONV +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @defgroup hasp_general General declarations + * + * @{ + */ + +typedef hasp_u32_t hasp_status_t; /*!< raw error code */ +typedef hasp_u32_t hasp_size_t; /*!< length */ +typedef hasp_u32_t hasp_handle_t; /*!< connection handle */ +typedef hasp_u32_t hasp_feature_t; /*!< feature id */ +typedef hasp_u32_t hasp_fileid_t; /*!< memory file id */ +typedef hasp_u64_t hasp_time_t; /*!< time, representing seconds since Jan-01-1970 0:00:00 GMT */ + +typedef void *hasp_vendor_code_t; /*!< contains the vendor code */ + +#define HASP_UPDATEINFO "" /*!< hasp_get_sessioninfo() format to get update info (C2V) */ +#define HASP_SESSIONINFO "" /*!< hasp_get_sessioninfo() format to get session info */ +#define HASP_KEYINFO "" /*!< hasp_get_sessioninfo() format to get key/hardware info */ + +/*! @} + */ + + +/*! @defgroup hasp_feature_ids Feature ID defines + * + * See also \ref hasp_features + * + * @{ + */ + +/*! \brief "Featuretype" mask + * + * AND-mask used to identify feature type + */ +#define HASP_FEATURETYPE_MASK 0xffff0000 + + +/*! \brief "PROGRAM NUMBER FEATURE" type + * + * After AND-ing with HASP_FEATURETYPE_MASK feature type contain this value. + */ +#define HASP_PROGNUM_FEATURETYPE 0xffff0000 + + +/*! \brief program number mask + * + * AND-mask used to extract program number from feature id if program number feature. + */ +#define HASP_PROGNUM_MASK 0x000000ff + + +/*! \brief prognum options mask + * + * AND-mask used to identify prognum options: + * - HASP_PROGNUM_OPT_NO_LOCAL + * - HASP_PROGNUM_OPT_NO_REMOTE + * - HASP_PROGNUM_OPT_PROCESS + * - HASP_PROGNUM_OPT_CLASSIC + * - HASP_PROGNUM_OPT_TS + * + * 3 bits of the mask are reserved for future extensions and currently unused. + * Initialize them to zero. + */ +#define HASP_PROGNUM_OPT_MASK 0x0000ff00 + + +/*! \brief "Prognum" option + * + * Disable local license search + */ +#define HASP_PROGNUM_OPT_NO_LOCAL 0x00008000 + + +/*! \brief "Prognum" option + * + * Disable network license search + */ +#define HASP_PROGNUM_OPT_NO_REMOTE 0x00004000 + + +/*! \brief "Prognum" option + * + * Sets session count of network licenses to per-process + */ +#define HASP_PROGNUM_OPT_PROCESS 0x00002000 + + +/*! \brief "Prognum" option + * + * Enables the API to access "classic" (HASP4 or earlier) keys + */ +#define HASP_PROGNUM_OPT_CLASSIC 0x00001000 + + +/*! \brief "Prognum" option + * + * Presence of Terminal Services gets ignored + */ +#define HASP_PROGNUM_OPT_TS 0x00000800 + + +/*! \brief HASP default feature id + * + * Present in every hardware key. + */ +#define HASP_DEFAULT_FID 0 + + +/*! \brief "Prognum" default feature id + * + * Present in every hardware HASP key. + */ +#define HASP_PROGNUM_DEFAULT_FID (HASP_DEFAULT_FID | HASP_PROGNUM_FEATURETYPE) + + +/*! @} + */ + +/*! \brief Minimal block size for hasp_encrypt() and hasp_decrypt() functions. + */ +#define HASP_MIN_BLOCK_SIZE 16 + +/*! \brief Minimal block size for legacy functions hasp_legacy_encrypt() + * and hasp_legacy_decrypt(). + */ +#define HASP_MIN_BLOCK_SIZE_LEGACY 8 + +/*! @defgroup hasp_file_ids Memory file id defines + * + * @{ + */ + +/*! \brief HASP4 memory file + * + * File id for HASP4 compatible memory contents w/o FAS + */ +#define HASP_FILEID_MAIN 0xfff0 + +/*! \brief HASP4 FAS memory file + * + * (Dummy) file id for license data area of memory contents + */ +#define HASP_FILEID_LICENSE 0xfff2 + + +/*! @} + */ + +/*! @defgroup hasp_error_codes Error code defines + * + * @{ + */ + +enum hasp_error_codes +{ + HASP_STATUS_OK = 0, /*!< no error occurred */ + HASP_MEM_RANGE = 1, /*!< invalid memory address */ + HASP_INV_PROGNUM_OPT = 2, /*!< unknown/invalid feature id option */ + HASP_INSUF_MEM = 3, /*!< memory allocation failed */ + HASP_TMOF = 4, /*!< too many open features */ + HASP_ACCESS_DENIED = 5, /*!< feature access denied */ + HASP_INCOMPAT_FEATURE = 6, /*!< incompatible feature */ + HASP_CONTAINER_NOT_FOUND = 7, /*!< license container not found */ + HASP_TOO_SHORT = 8, /*!< en-/decryption length too short */ + HASP_INV_HND = 9, /*!< invalid handle */ + HASP_INV_FILEID = 10, /*!< invalid file id / memory descriptor */ + HASP_OLD_DRIVER = 11, /*!< driver or support daemon version too old */ + HASP_NO_TIME = 12, /*!< real time support not available */ + HASP_SYS_ERR = 13, /*!< generic error from host system call */ + HASP_NO_DRIVER = 14, /*!< hardware key driver not found */ + HASP_INV_FORMAT = 15, /*!< unrecognized info format */ + HASP_REQ_NOT_SUPP = 16, /*!< request not supported */ + HASP_INV_UPDATE_OBJ = 17, /*!< invalid update object */ + HASP_KEYID_NOT_FOUND = 18, /*!< key with requested id was not found */ + HASP_INV_UPDATE_DATA = 19, /*!< update data consistency check failed */ + HASP_INV_UPDATE_NOTSUPP = 20, /*!< update not supported by this key */ + HASP_INV_UPDATE_CNTR = 21, /*!< update counter mismatch */ + HASP_INV_VCODE = 22, /*!< invalid vendor code */ + HASP_ENC_NOT_SUPP = 23, /*!< requested encryption algorithm not supported */ + HASP_INV_TIME = 24, /*!< invalid date / time */ + HASP_NO_BATTERY_POWER = 25, /*!< clock has no power */ + HASP_NO_ACK_SPACE = 26, /*!< update requested acknowledgement, but no area to return it */ + HASP_TS_DETECTED = 27, /*!< terminal services (remote terminal) detected */ + HASP_FEATURE_TYPE_NOT_IMPL = 28, /*!< feature type not implemented */ + HASP_UNKNOWN_ALG = 29, /*!< unknown algorithm */ + HASP_INV_SIG = 30, /*!< signature check failed */ + HASP_FEATURE_NOT_FOUND = 31, /*!< feature not found */ + HASP_NO_LOG = 32, /*!< trace log is not enabled */ + + /* c++ use */ + HASP_INVALID_OBJECT = 500, + HASP_INVALID_PARAMETER, + HASP_ALREADY_LOGGED_IN, + HASP_ALREADY_LOGGED_OUT, + + /* .net use */ + HASP_OPERATION_FAILED = 525, + + /* inside-api use */ + HASP_NO_EXTBLOCK = 600, /*!< no classic memory extension block available */ + /* internal use */ + HASP_INV_PORT_TYPE = 650, /*!< invalid port type */ + HASP_INV_PORT = 651, /*!< invalid port value */ + /* catch-all */ + HASP_NOT_IMPL = 698, /*!< capability isn't available */ + HASP_INT_ERR = 699 /*!< internal API error */ +}; + +/*! @} + */ + + +/*! @defgroup hasp_basic The Basic API + * + * @{ + */ + +/* --------------------------------------------------------------------- */ +/*! \brief Login into a feature. + * + * This function establishes a context (logs into a feature). + * + * \param feature_id - Unique identifier of the feature\n + * With "prognum" features (see \ref HASP_FEATURETYPE_MASK), + * 8 bits are reserved for legacy options (see \ref HASP_PROGNUM_OPT_MASK, + * currently 5 bits are used): + * - only local + * - only remote + * - login is counted per process ID + * - disable terminal server check + * - enable access to old (HASP3/HASP4) keys + * \param vendor_code - pointer to the vendor code + * \param handle - pointer to the resulting session handle + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_FEATURE_NOT_FOUND + * - the requested feature isn't available + * - HASP_CONTAINER_NOT_FOUND + * - no possible feature container found + * - HASP_FEATURE_TYPE_NOT_IMPL + * - the type of feature isn't implemented + * - HASP_INV_PROGNUM_OPT + * - unknown prognum option requested (\ref HASP_PROGNUM_OPT_MASK) + * - HASP_TMOF + * - too many open handles + * - HASP_INSUF_MEM + * - out of memory + * - HASP_INV_VCODE + * - invalid vendor code + * - HASP_NO_DRIVER + * - driver not installed + * - HASP_OLD_DRIVER + * - old driver installed + * - HASP_TS_DETECTED + * - program runs on a remote screen on Terminal Server + * + * \sa hasp_logout() + * + * \remark + * + * For local prognum features, concurrency is not handled and each login performs a decrement + * if it is a counting license. + * + * Network prognum features just use the old HASPLM login logic with all drawbacks. + * There is only support for concurrent usage of \b one server (global server address). + * + */ +hasp_status_t HASP_CALLCONV hasp_login(hasp_feature_t feature_id, + hasp_vendor_code_t vendor_code, + hasp_handle_t *handle); + + +/* --------------------------------------------------------------------- */ +/*! \brief Logout. + * + * Logs out from a session and frees all allocated resources for the session. + * + * \param handle - handle of session to log out from + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * + * \sa hasp_login() + */ +hasp_status_t HASP_CALLCONV hasp_logout(hasp_handle_t handle); + + +/* --------------------------------------------------------------------- */ +/*! \brief Encrypt a buffer. + * + * This function encrypts a buffer. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be encrypted + * \param length - size in bytes of the buffer to be encrypted (16 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be encrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \sa hasp_decrypt() + * + * \remark + * If the encryption fails (e.g. key removed in-between) the data pointed to by buffer is unmodified. + */ +hasp_status_t HASP_CALLCONV hasp_encrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Decrypt a buffer. + * + * This function decrypts a buffer. This is the reverse operation of the + * hasp_encrypt() function. See \ref hasp_encrypt() for more information. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be decrypted + * \param length - size in bytes of the buffer to be decrypted (16 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be decrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \sa hasp_encrypt() + * + * \remark + * If the decryption fails (e.g. key removed in-between) the data pointed to by buffer is unmodified. + */ +hasp_status_t HASP_CALLCONV hasp_decrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Read from key memory. + * + * This function is used to read from the key memory. + * + * \param handle - session handle + * \param fileid - id of the file to read (memory descriptor) + * \param offset - position in the file + * \param length - number of bytes to read + * \param buffer - result of the read operation + * + * \return status code. + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FILEID + * - unknown fileid + * - HASP_MEM_RANGE + * - attempt to read beyond eom + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \remark + * Valid fileids are \ref HASP_FILEID_LICENSE and \ref HASP_FILEID_MAIN. + * + * \sa hasp_write(), hasp_get_size() + */ +hasp_status_t HASP_CALLCONV hasp_read(hasp_handle_t handle, hasp_fileid_t fileid, hasp_size_t offset, hasp_size_t length, void *buffer); + + +/* --------------------------------------------------------------------- */ +/*! \brief Write to key memory. + * + * This function is used to write to the key memory. Depending on the provided + * session handle (either logged into the default feature or any other feature), + * write access to the FAS memory (\ref HASP_FILEID_LICENSE) is not permitted. + * + * \param handle - session handle + * \param fileid - id of the file to write + * \param offset - position in the file + * \param length - number of bytes to write + * \param buffer - what to write + * + * \return status code. + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FILEID + * - unknown fileid + * - HASP_MEM_RANGE + * - attempt to read beyond eom + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \remark + * Valid fileids are \ref HASP_FILEID_LICENSE and \ref HASP_FILEID_MAIN. + * + * \sa hasp_read(), hasp_get_size() + */ +hasp_status_t HASP_CALLCONV hasp_write(hasp_handle_t handle, hasp_fileid_t fileid, hasp_size_t offset, hasp_size_t length, void *buffer); + + +/* --------------------------------------------------------------------- */ +/*! \brief Get memory size. + * + * This function is used to determine the memory size. + * + * \param handle - session handle + * \param fileid - id of the file to query + * \param size - pointer to the resulting file size + * + * \result status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FILEID + * - unknown fileid + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \remark + * Valid fileids are \ref HASP_FILEID_LICENSE and \ref HASP_FILEID_MAIN. + * + * \sa hasp_read(), hasp_write() + */ +hasp_status_t HASP_CALLCONV hasp_get_size(hasp_handle_t handle, hasp_fileid_t fileid, hasp_size_t *size); + + +/* --------------------------------------------------------------------- */ +/*! \brief Read current time from a time key. + * + * This function reads the current time from a time key. + * The time will be returned in seconds since Jan-01-1970 0:00:00 GMT. + * + * \remark The general purpose of this function is not related to + * licensing, but to get reliable timestamps which are independent + * from the system clock. + * \remark This request is only supported on locally accessed keys. Trying to + * get the time from a remotely accessed key will return HASP_NO_TIME. + * + * \param handle - session handle + * \param time - pointer to the actual time + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_NO_TIME + * - RTC not available or remote access + * - HASP_NO_BATTERY_POWER + * - RTC consistency check failed, battery probably dead + * + * \sa hasp_datetime_to_hasptime(), hasp_hasptime_to_datetime() + */ +hasp_status_t HASP_CALLCONV hasp_get_rtc(hasp_handle_t handle, hasp_time_t *time); + + +/* --------------------------------------------------------------------- */ +/*! @} + */ + + +/* --------------------------------------------------------------------- */ +/*! @defgroup hasp_classic Legacy HASP functionality for backward compatibility + * + * @{ + */ + +/*! \brief Legacy HASP4 compatible encryption function. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be encrypted + * \param length - size in bytes of the buffer (8 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be encrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + * + * \sa hasp_legacy_decrypt(), hasp_encrypt(), hasp_decrypt() + * + * \remark + * If the encryption fails (e.g. key removed in-between) the data pointed to by buffer is undefined. + */ +hasp_status_t HASP_CALLCONV hasp_legacy_encrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Legacy HASP4 compatible decryption function. + * + * \param handle - session handle + * \param buffer - pointer to the buffer to be decrypted + * \param length - size in bytes of the buffer (8 bytes minimum) + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_TOO_SHORT + * - the length of the data to be decrypted is too short + * - HASP_ENC_NOT_SUPP + * - encryption type not supported by the hardware + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + * + * \sa hasp_legacy_encrypt(), hasp_decrypt(), hasp_encrypt() + * + * \remark + * If the decryption fails (e.g. key removed in-between) the data pointed to by buffer is undefined. + */ +hasp_status_t HASP_CALLCONV hasp_legacy_decrypt(hasp_handle_t handle, void *buffer, hasp_size_t length); + + +/* --------------------------------------------------------------------- */ +/*! \brief Write to HASP4 compatible real time clock + * + * \param handle - session handle + * \param new_time - time value to be set + * + * \remark This request is only supported on locally accessed keys. Trying to + * set the time on a remotely accessed key will return HASP_NO_TIME. + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_NO_TIME + * - RTC not available or access remote + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + * + * \sa hasp_get_rtc(), hasp_datetime_to_hasptime(), hasp_hasptime_to_datetime() + */ +hasp_status_t HASP_CALLCONV hasp_legacy_set_rtc(hasp_handle_t handle, hasp_time_t new_time); + + +/* --------------------------------------------------------------------- */ +/*! \brief Set the LM idle time. + * + * \param handle - session handle + * \param idle_time - the idle time in minutes + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_HND + * - invalid session handle + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_REQ_NOT_SUPP + * - attempt to set the idle time for a local license + * + * \note The handle must have been obtained by calling \ref hasp_login() with + * a prognum feature id. + */ +hasp_status_t HASP_CALLCONV hasp_legacy_set_idletime(hasp_handle_t handle, hasp_u16_t idle_time); + +/*! @} + */ + + +/*! @defgroup hasp_extended Extended HASP HL API + * + * The extended API consists of functions which provide extended functionality. This + * advanced functionality is sometimes necessary, and addresses the "advanced" user. + * + * @{ + */ + +/*! \brief Get information in a session context. + * + * Memory for the information is allocated by this function and has to be freed by the + * \ref hasp_free() function. + * + * \param handle - session handle + * \param format - XML definition of the output data structure + * \param info - pointer to the returned information (XML list) + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_CONTAINER_NOT_FOUND + * - the feature container isn't available anymore + * - HASP_INV_HND + * - invalid session handle + * - HASP_INV_FORMAT + * - unrecognized format + * - HASP_INSUF_MEM + * - out of memory + * + * \sa hasp_free() + * \sa HASP_UPDATEINFO, HASP_SESSIONINFO, HASP_KEYINFO + * \sa \ref hasp_query_page + */ +hasp_status_t HASP_CALLCONV hasp_get_sessioninfo (hasp_handle_t handle, const char *format, char **info); + + +/*! \brief Free resources allocated by hasp_get_sessioninfo + * + * This function must be called to free the resources allocated by hasp_get_sessioninfo() + * or to free the acknowledge data optionally returned from hasp_update(). + * + * \param info - pointer to the resources to be freed + * + * \sa hasp_get_sessioninfo(), hasp_update() + */ +void HASP_CALLCONV hasp_free (char *info); + + +/*! \brief Write an update. + * + * This function writes update information. The update blob contains all necessary data + * to perform the update: Where to write (in which "container", e.g. dongle), the necessary + * access data (vendor code) and of course the update itself. + * If the update blob requested it, the function returns in an acknowledge blob, + * which is signed/encrypted by the updated instance and contains a proof that this update + * was successfully installed. Memory for the acknowledge blob is allocated by the API and has to be + * freed by the programmer (see \ref hasp_free()). + * + * \param update_data - pointer to the complete update data. + * \param ack_data - pointer to a buffer to get the acknowledge data. + * + * \return status code + * - HASP_INV_UPDATE_DATA + * - required XML tags not found + * - contents in binary data missing or invalid + * - HASP_INV_UPDATE_OBJ + * - binary data doesn't contain an update blob + * - HASP_NO_ACK_SPACE + * - acknowledge data requested by the update, but ack_data input parameter is NULL + * - HASP_KEYID_NOT_FOUND + * - key to be updated not found + * - HASP_INV_UPDATE_NOTSUPP + * - update not supported by the key + * - HASP_INV_UPDATE_CNTR + * - update counter at the wrong position + * - HASP_INV_SIG + * - signature verification failed + * + * \sa hasp_free() + * + * \remark Update via LM is not supported. + */ +hasp_status_t HASP_CALLCONV hasp_update(char *update_data, char **ack_data); + +/*! @} + */ + + +/* --------------------------------------------------------------------- */ +/*! @defgroup hasp_util Utility functions + * + * @{ + */ + +/* --------------------------------------------------------------------- */ +/*! \brief Convert broken up time into a time type + * + * \param day - input day + * \param month - input month + * \param year - input year + * \param hour - input hour + * \param minute - input minute + * \param second - input second + * \param time - pointer to put result + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_TIME + * - time outside of the supported range + * + * \remark Times are in UTC. + * + * \sa hasp_hasptime_to_datetime() + */ +hasp_status_t HASP_CALLCONV hasp_datetime_to_hasptime(unsigned int day, + unsigned int month, + unsigned int year, + unsigned int hour, + unsigned int minute, + unsigned int second, + hasp_time_t *time); + + +/* --------------------------------------------------------------------- */ +/*! \brief Convert time type into broken up time + * + * \param time - pointer to put result + * \param day - pointer to day + * \param month - pointer to month + * \param year - pointer to year + * \param hour - pointer to hour + * \param minute - pointer to minute + * \param second - pointer to second + * + * \return status code + * - HASP_STATUS_OK + * - the request completed successfully + * - HASP_INV_TIME + * - time outside of the supported range + * + * \remark Times are in UTC. + * + * \sa hasp_datetime_to_hasptime() + */ +hasp_status_t HASP_CALLCONV hasp_hasptime_to_datetime(hasp_time_t time, + unsigned int *day, + unsigned int *month, + unsigned int *year, + unsigned int *hour, + unsigned int *minute, + unsigned int *second); + + +/*! @} + */ + + +/*! \page hasp_features Feature ID convention + +\section FeatIntr Feature ID introduction + +Feature ids are 32bits wide. If the upper 16 bit contain the value indicated by \ref HASP_PROGNUM_FEATURETYPE, +the feature defines a prognum feature.\n +For prognum features there are some options encoded in the feature id. These include + - \ref HASP_PROGNUM_OPT_NO_LOCAL\n + Don't search for a license locally. "Remote-only"\n\n + - \ref HASP_PROGNUM_OPT_NO_REMOTE\n + Don't search for a license on the network. "Local-only"\n\n + - \ref HASP_PROGNUM_OPT_PROCESS\n + In case, a license is found in the network, count license usage per process + instead of per workstation.\n\n + - \ref HASP_PROGNUM_OPT_TS\n + Don't detect whether the program is running on a remote screen on a terminal server.\n\n + - \ref HASP_PROGNUM_OPT_CLASSIC\n + The API by default only searches for HASPHL keys. When this option is set, it also + searches for HASP3/HASP4 keys.\n\n +*/ + + +/*! \page hasp_query_page hasp_get_sessioninfo format and info + +\section QueryPage hasp_get_sessioninfo format and info + +Calling hasp_get_sessioninfo() with \ref HASP_UPDATEINFO format will return something like this: + +\verbatim + + + + YYIBlIADY3R2oQaABEAwulCiCYABaoEBBIIBAKOBxoABAIGBwD2sfFj8UKuDvNWH9 + LhfRKDzUbLCAi6E9mN8ea7EclwOl9VeLMDuLvfsEvkor2igmwxg/wWs6HCuypEFi6 + V/FkI4EUmQNmcKSIY302s9CzHP7aCrG7QKvzArVq25Nc7UxIQJ4kZJm1oWiw3zZJq + UY+G0EleETkPZ8n2uDfMauBpdWhW0R35rHlRM4wiYCZzaelpRtDX36HDh1caqfpaL + mUnwWXRz0+tLs+Dvd+kLmvcQ6jWJJb4r2rxywG2IW1WTjIWBsI+h0/UgaIhG1J+9R + EQ1SrMx3YQ2bpdlK3FluZVDayW9okv7idxKJS4zGG+4UOccpKT4aWJi9cR0vdm4s/ + J6fUNbhK522x/gdvR51a6ll46GpVn2HjD0ZpAgCeu6xAIwHJ7Kc6tjeRfxYX9YksE + aB9JoV/uaPTHnbu2AgQmd0r09p0zmXgD4Kuk8EtTs1GoBbY7WF3qHJsj1Iz1ZeAdA + rdNOYKsOgA/q1tuLLR7O0dag + + +\endverbatim + + +Calling hasp_get_sessioninfo() with \ref HASP_SESSIONINFO format will return something like this: + +\verbatim + + + 4294905856 + 5 + 1 + unlimited + + +\endverbatim + +In case of a expiring license on a time enabled key (prognum <= 8), +instead of the remaining activations the expiration date will be +returned: + +\verbatim + + + 4294905857 + 1052919239 + + +\endverbatim + +For locally accessed keys there is no \p maxlogins and \p currentlogins field. + + +Calling hasp_get_sessioninfo() with \ref HASP_KEYINFO format will return something like +this for a locally accessed key: + +\verbatim + + + + + + + + + + 12345 + 0 + + "Main" + 65520 + 48 + + + "FAS" + 65522 + 80 + + + + "USB" +
1
+
+
+
+\endverbatim + + +Calling hasp_get_sessioninfo() with \ref HASP_KEYINFO format will return something like +this for a remotely accessed key: + +\verbatim + + + + + + + + 782062012 + 5 + + "Main" + 65520 + 432 + + + "FAS" + 65522 + 448 + + + + "IP" +
"10.20.3.10"
+
+
+
+\endverbatim + +\p keycaps flags: + - hasp4 + - support HASP4 compatible encryption + - aes + - support AES encryption + - rtc + - key has real time clock chip + - newintf + - supports new access interface + +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef __HASP_HL_H__ */ diff --git a/libraries/pmrt/dongle/hasp_vcode.h b/libraries/pmrt/dongle/hasp_vcode.h new file mode 100755 index 0000000..dcfeb0c --- /dev/null +++ b/libraries/pmrt/dongle/hasp_vcode.h @@ -0,0 +1,12 @@ +unsigned char vendor_code[] = +"p0AosKZcgvIqHRZwMAK6MqljLvA8fjsYK92+Z4QMib0WKbM/3ljp/RAHjtNwN4wfy1W8oFXWujb" +"bnEppgxd0vulb/ZTuqIvG5hiAuyjLoDYl49KmvXGoXL1yWEwFBIDoVYEbMy1x1Q9k0XxcRioqIG" +"Ks8Q/xX8ZqjvQlQyZi2p27biH4GxKvZew2ctfKKxEK87gHBxEC3Pz40bqUnPUEl5KnjfXwTX674" +"ZG0d8HVNnccAOqdblCHHQN6P5LdRpTOQI6B1W4+cLWOv30i1rsjCv8yWfiqV7k909pVuE8s2YMH" +"GBb14jKOjE4lm1FBQ2j8yr7S/jLFBBy1wbDSpThnwT06uzjGgXRhANPVji7lUYdNNebK/v5daWp" +"ZGN/e1x0H5QhnSOiclsxNRKAS9f4fVv3iLNHYZHi41W5S87teNkEDG/jkMQchv/Ub/VJTgW03ne" +"H44ZzbaAs2Ox+44ZkxdKtDXQM/e0g2qpafrtfPyu07XaEWifw+IBDq2hCoiyB02OZcHVZXAyPO5" +"sk/5pFXr0J2rNT5tf09rqHuemgZnSbEO1XkhrKTo/XS3i9Jw9ST/UgbpSaO5aeiCsWeQ8X5RJ3C" +"IWVDTKC1G2dpadJftEMR2rFS6N9ixxP/1R7pdT1df79/H/dPTVvzuy76dcpxj0UP7/mF/X6GO8O" +"qUOxKG8DoEPGMiZxHHm3ZgLib6uljbQ2ewZYKFp69QSVVMAHumT+wCgWPKg=="; + diff --git a/libraries/pmrt/dongle/makedeplib b/libraries/pmrt/dongle/makedeplib new file mode 100644 index 0000000..47db46c Binary files /dev/null and b/libraries/pmrt/dongle/makedeplib differ diff --git a/libraries/pmrt/dongle/makefile b/libraries/pmrt/dongle/makefile new file mode 100755 index 0000000..3d7ee14 --- /dev/null +++ b/libraries/pmrt/dongle/makefile @@ -0,0 +1,38 @@ +# make driver +# make install (as root) +# +.CLIBFILES = dongle.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libDongle.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +LIBS = /g3/lib/librockeyapi.a /g3/lib/libpmrt_utils.a /g3/lib/libpmrt_ssl.a /g3/lib/libcrypto.a /usr/lib/libdl.a + +#CFLAGS = -Wall -O2 -DSYS_BB -I/g3/include +CFLAGS = -Wall -Wno-implicit -O2 -g -DSYS_BB -DPRODUCTION -I/g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) + -mkdir /g3/include/dongle + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/dongle + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/dongle/ryvc32.h b/libraries/pmrt/dongle/ryvc32.h new file mode 100755 index 0000000..94189e5 --- /dev/null +++ b/libraries/pmrt/dongle/ryvc32.h @@ -0,0 +1,250 @@ +// Function Code +#define RY_FIND 1 // Find Dongle +#define RY_FIND_NEXT 2 // Find Next Dongle +#define RY_OPEN 3 // Open Dongle +#define RY_CLOSE 4 // Close Dongle +#define RY_READ 5 // Read Dongle +#define RY_WRITE 6 // Write Dongle +#define RY_RANDOM 7 // Generate Random Number +#define RY_SEED 8 // Generate Seed Code +#define RY_WRITE_USERID 9 // Write User ID +#define RY_READ_USERID 10 // Read User ID +#define RY_SET_MOUDLE 11 // Set Module +#define RY_CHECK_MOUDLE 12 // Check Module +#define RY_WRITE_ARITHMETIC 13 // Write Arithmetic +#define RY_CALCULATE1 14 // Calculate 1 +#define RY_CALCULATE2 15 // Calculate 2 +#define RY_CALCULATE3 16 // Calculate 3 +#define RY_DECREASE 17 // Decrease Module Unit + +// Error Code +#define ERR_SUCCESS 0 // Success +#define ERR_NO_PARALLEL_PORT 1 // No parallel port on the computer +#define ERR_NO_DRIVER 2 // No install drivers +#define ERR_NO_ROCKEY 3 // No rockey dongle +#define ERR_INVALID_PASSWORD 4 // Found rockey dongle, but base password is wrong +#define ERR_INVALID_PASSWORD_OR_ID 5 // Wrong password or rockey HID +#define ERR_SETID 6 // Set rockey HID wrong +#define ERR_INVALID_ADDR_OR_SIZE 7 // Read/Write address is wrong +#define ERR_UNKNOWN_COMMAND 8 // No such command +#define ERR_NOTBELEVEL3 9 // Inside error +#define ERR_READ 10 // Read error +#define ERR_WRITE 11 // Write error +#define ERR_RANDOM 12 // Random error +#define ERR_SEED 13 // Seed Code error +#define ERR_CALCULATE 14 // Calculate error +#define ERR_NO_OPEN 15 // No open dongle before operate dongle +#define ERR_OPEN_OVERFLOW 16 // Too more open dongle(>16) +#define ERR_NOMORE 17 // No more dongle +#define ERR_NEED_FIND 18 // No Find before FindNext +#define ERR_DECREASE 19 // Decrease error + +#define ERR_AR_BADCOMMAND 20 // Arithmetic instruction error +#define ERR_AR_UNKNOWN_OPCODE 21 // Arithmetic operator error +#define ERR_AR_WRONGBEGIN 22 // Const number can't use on first arithmetic instruction +#define ERR_AR_WRONG_END 23 // Const number can't use on last arithmetic instruction +#define ERR_AR_VALUEOVERFLOW 24 // Const number > 63 +#define ERR_UNKNOWN 0xffff // Unknown error + +#define ERR_RECEIVE_NULL 0x100 // Receive null +#define ERR_PRNPORT_BUSY 0x101 // Parallel busy +#define ERR_UNKNOWN_SYSTEM 0x102 // Unknown operate system + +/* Interface: +(1) Find Dongle + Input: + function = 0 + *p1 = pass1 + *p2 = pass2 + *p3 = pass3 + *p4 = pass4 + Return: + *lp1 = Rockey HID + return 0 = Success, else is error code + +(2) Find Next Dongle + Input: + function = 1 + *p1 = pass1 + *p2 = pass2 + *p3 = pass3 + *p4 = pass4 + Return: + *lp1 = Rockey HID + return 0 = Success, else is error code + +(3) Open Dongle + Input: + function = 2 + *p1 = pass1 + *p2 = pass2 + *p3 = pass3 + *p4 = pass4 + *lp1 = Rockey HID + Return: + *handle = Opened dongle handle + return 0 = Success, else is error code + +(4) Cloase Dongle + Input: + function = 3 + *handle = dongle handle + Return: + return 0 = Success, else is error code + +(5) Read Dongle + Input: + function = 4 + *handle = dongle handle + *p1 = pos + *p2 = length + buffer = pointer of buffer + Return: + Fill buffer with read contents + return 0 = Success, else is error code + +(6) Write Dongle + Input: + function = 5 + *handle = dongle handle + *p1 = pos + *p2 = length + buffer = pointer of buffer + Return: + return 0 = Success, else is error code + +(7) Generate Random Number + Input: + function = 6 + *handle = dongle handle + Return: + *p1 = random number + return 0 = Success, else is error code + +(8) Generate Seed Code + Input: + function = 7 + *handle = dongle handle + *lp2 = seed code + Return: + *p1 = seed return code 1 + *p2 = seed return code 2 + *p3 = seed return code 3 + *p4 = seed return code 4 + return 0 = Success, else is error code + +(9) Write User ID [*] + Input: + function = 8 + *handle = dongle handle + *lp1 = User ID + Return: + return 0 = Success, else is error code + +(10) Read User ID + Input: + function = 9 + *handle = dongle handle + Return: + *lp1 = User ID + return 0 = Success, else is error code + +(11) Set Module [*] + Input: + function = 10 + *handle = dongle handle + *p1 = module number + *p2 = module content + *p3 = set whether allow decrease (1 = allow, 0 = no allow) + Return: + return 0 = Success, else is error code + +(12) Check Module + Input: + function = 11 + *handle = dongle handle + *p1 = module number + Return: + *p2 = 1 means the module is valid, 0 means the module is invalid + *p3 = 1 means the module can't decrease, 0 means the module can decrease + return 0 = Success, else is error code + +(13) Write Arithmetic [*] + Input: + function = 12 + *handle = dongle handle + *p1 = pos + buffer = arithmetic instruction string + Return: + return 0 = Success, else is error code + +(14) Calculate 1 (Hide Unit Init Content = HID high 16bit, HID low 16bit, module content, random number) + Input: + function = 13 + *handle = dongle handle + *lp1 = calculate begin pos + *lp2 = module number + *p1 = input value 1 + *p2 = input value 2 + *p3 = input value 3 + *p4 = input value 4 + Return: + *p1 = return code 1 + *p2 = return code 2 + *p3 = return code 3 + *p4 = return code 4 + return 0 = Success, else is error code + +(15) Calculate 2 (Hide Unit Init Content = seed return code 1, seed return code 2, seed return code 3, seed return code 4) + Input: + function = 14 + *handle = dongle handle + *lp1 = calculate begin pos + *lp2 = seed code + *p1 = input value 1 + *p2 = input value 2 + *p3 = input value 3 + *p4 = input value 4 + Return: + *p1 = return code 1 + *p2 = return code 2 + *p3 = return code 3 + *p4 = return code 4 + return 0 = Success, else is error code + +(16) Calculate 3 (Hide Unit Init Content = module content, module+1 content, module+2 content, module+3 content) + Input: + function = 15 + *handle = dongle handle + *lp1 = calculate begin pos + *lp2 = module begin pos + *p1 = input value 1 + *p2 = input value 2 + *p3 = input value 3 + *p4 = input value 4 + Return: + *p1 = return code 1 + *p2 = return code 2 + *p3 = return code 3 + *p4 = return code 4 + return 0 = Success, else is error code + +(17) Decrease Module Unit + Input: + function = 16 + *handle = dongle handle + *p1 = module number + Return: + return 0 = Success, else is error code +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +WORD Rockey(WORD function, WORD* handle, DWORD* lp1, DWORD* lp2, WORD* p1, WORD* p2, WORD* p3, WORD* p4, BYTE* buffer); + +#ifdef __cplusplus +} +#endif diff --git a/libraries/pmrt/dongle/ryvc32.obj b/libraries/pmrt/dongle/ryvc32.obj new file mode 100755 index 0000000..1e137bb Binary files /dev/null and b/libraries/pmrt/dongle/ryvc32.obj differ diff --git a/libraries/pmrt/irtrack/cycle.h b/libraries/pmrt/irtrack/cycle.h new file mode 100755 index 0000000..4d714ba --- /dev/null +++ b/libraries/pmrt/irtrack/cycle.h @@ -0,0 +1,514 @@ +/* + * Copyright (c) 2003, 2007 Matteo Frigo + * Copyright (c) 2003, 2007 Massachusetts Institute of Technology + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + + +/* machine-dependent cycle counters code. Needs to be inlined. */ + +/***************************************************************************/ +/* To use the cycle counters in your code, simply #include "cycle.h" (this + file), and then use the functions/macros: + + ticks getticks(void); + + ticks is an opaque typedef defined below, representing the current time. + You extract the elapsed time between two calls to gettick() via: + + double elapsed(ticks t1, ticks t0); + + which returns a double-precision variable in arbitrary units. You + are not expected to convert this into human units like seconds; it + is intended only for *comparisons* of time intervals. + + (In order to use some of the OS-dependent timer routines like + Solaris' gethrtime, you need to paste the autoconf snippet below + into your configure.ac file and #include "config.h" before cycle.h, + or define the relevant macros manually if you are not using autoconf.) +*/ + +/***************************************************************************/ +/* This file uses macros like HAVE_GETHRTIME that are assumed to be + defined according to whether the corresponding function/type/header + is available on your system. The necessary macros are most + conveniently defined if you are using GNU autoconf, via the tests: + + dnl --------------------------------------------------------------------- + + AC_C_INLINE + AC_HEADER_TIME + AC_CHECK_HEADERS([sys/time.h c_asm.h intrinsics.h mach/mach_time.h]) + + AC_CHECK_TYPE([hrtime_t],[AC_DEFINE(HAVE_HRTIME_T, 1, [Define to 1 if hrtime_t is defined in ])],,[#if HAVE_SYS_TIME_H +#include +#endif]) + + AC_CHECK_FUNCS([gethrtime read_real_time time_base_to_time clock_gettime mach_absolute_time]) + + dnl Cray UNICOS _rtc() (real-time clock) intrinsic + AC_MSG_CHECKING([for _rtc intrinsic]) + rtc_ok=yes + AC_TRY_LINK([#ifdef HAVE_INTRINSICS_H +#include +#endif], [_rtc()], [AC_DEFINE(HAVE__RTC,1,[Define if you have the UNICOS _rtc() intrinsic.])], [rtc_ok=no]) + AC_MSG_RESULT($rtc_ok) + + dnl --------------------------------------------------------------------- +*/ + +/***************************************************************************/ + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \ +{ \ + return (double)t1 - (double)t0; \ +} + +/*----------------------------------------------------------------*/ +/* Solaris */ +#if defined(HAVE_GETHRTIME) && defined(HAVE_HRTIME_T) && !defined(HAVE_TICK_COUNTER) +typedef hrtime_t ticks; + +#define getticks gethrtime + +INLINE_ELAPSED(inline) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* AIX v. 4+ routines to read the real-time clock or time-base register */ +#if defined(HAVE_READ_REAL_TIME) && defined(HAVE_TIME_BASE_TO_TIME) && !defined(HAVE_TICK_COUNTER) +typedef timebasestruct_t ticks; + +static __inline ticks getticks(void) +{ + ticks t; + read_real_time(&t, TIMEBASE_SZ); + return t; +} + +static __inline double elapsed(ticks t1, ticks t0) /* time in nanoseconds */ +{ + time_base_to_time(&t1, TIMEBASE_SZ); + time_base_to_time(&t0, TIMEBASE_SZ); + return (((double)t1.tb_high - (double)t0.tb_high) * 1.0e9 + + ((double)t1.tb_low - (double)t0.tb_low)); +} + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* + * PowerPC ``cycle'' counter using the time base register. + */ +#if ((((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || (defined(__MWERKS__) && defined(macintosh)))) || (defined(__IBM_GCC_ASM) && (defined(__powerpc__) || defined(__ppc__)))) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long long ticks; + +static __inline__ ticks getticks(void) +{ + unsigned int tbl, tbu0, tbu1; + + do { + __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0)); + __asm__ __volatile__ ("mftb %0" : "=r"(tbl)); + __asm__ __volatile__ ("mftbu %0" : "=r"(tbu1)); + } while (tbu0 != tbu1); + + return (((unsigned long long)tbu0) << 32) | tbl; +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif + +/* MacOS/Mach (Darwin) time-base register interface (unlike UpTime, + from Carbon, requires no additional libraries to be linked). */ +#if defined(HAVE_MACH_ABSOLUTE_TIME) && defined(HAVE_MACH_MACH_TIME_H) && !defined(HAVE_TICK_COUNTER) +#include +typedef uint64_t ticks; +#define getticks mach_absolute_time +INLINE_ELAPSED(__inline__) +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* + * Pentium cycle counter + */ +#if (defined(__GNUC__) || defined(__ICC)) && defined(__i386__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long long ticks; + +static __inline__ ticks getticks(void) +{ + ticks ret; + + __asm__ __volatile__("rdtsc": "=A" (ret)); + /* no input, nothing else clobbered */ + return ret; +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#define TIME_MIN 5000.0 /* unreliable pentium IV cycle counter */ +#endif + +/* Visual C++ -- thanks to Morten Nissov for his help with this */ +#if _MSC_VER >= 1200 && _M_IX86 >= 500 && !defined(HAVE_TICK_COUNTER) +#include +typedef LARGE_INTEGER ticks; +#define RDTSC __asm __emit 0fh __asm __emit 031h /* hack for VC++ 5.0 */ + +static __inline ticks getticks(void) +{ + ticks retval; + + __asm { + RDTSC + mov retval.HighPart, edx + mov retval.LowPart, eax + } + return retval; +} + +static __inline double elapsed(ticks t1, ticks t0) +{ + return (double)t1.QuadPart - (double)t0.QuadPart; +} + +#define HAVE_TICK_COUNTER +#define TIME_MIN 5000.0 /* unreliable pentium IV cycle counter */ +#endif + +/*----------------------------------------------------------------*/ +/* + * X86-64 cycle counter + */ +#if (defined(__GNUC__) || defined(__ICC) || defined(__SUNPRO_C)) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long long ticks; + +static __inline__ ticks getticks(void) +{ + unsigned a, d; + asm volatile("rdtsc" : "=a" (a), "=d" (d)); + return ((ticks)a) | (((ticks)d) << 32); +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif + +/* PGI compiler, courtesy Cristiano Calonaci, Andrea Tarsi, & Roberto Gori. + NOTE: this code will fail to link unless you use the -Masmkeyword compiler + option (grrr). */ +#if defined(__PGI) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long long ticks; +static ticks getticks(void) +{ + asm(" rdtsc; shl $0x20,%rdx; mov %eax,%eax; or %rdx,%rax; "); +} +INLINE_ELAPSED(__inline__) +#define HAVE_TICK_COUNTER +#endif + +/* Visual C++, courtesy of Dirk Michaelis */ +#if _MSC_VER >= 1400 && (defined(_M_AMD64) || defined(_M_X64)) && !defined(HAVE_TICK_COUNTER) + +#include +#pragma intrinsic(__rdtsc) +typedef unsigned __int64 ticks; +#define getticks __rdtsc +INLINE_ELAPSED(__inline) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* + * IA64 cycle counter + */ + +/* intel's icc/ecc compiler */ +#if (defined(__EDG_VERSION) || defined(__ECC)) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long ticks; +#include + +static __inline__ ticks getticks(void) +{ + return __getReg(_IA64_REG_AR_ITC); +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif + +/* gcc */ +#if defined(__GNUC__) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long ticks; + +static __inline__ ticks getticks(void) +{ + ticks ret; + + __asm__ __volatile__ ("mov %0=ar.itc" : "=r"(ret)); + return ret; +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif + +/* HP/UX IA64 compiler, courtesy Teresa L. Johnson: */ +#if defined(__hpux) && defined(__ia64) && !defined(HAVE_TICK_COUNTER) +#include +typedef unsigned long ticks; + +static inline ticks getticks(void) +{ + ticks ret; + + ret = _Asm_mov_from_ar (_AREG_ITC); + return ret; +} + +INLINE_ELAPSED(inline) + +#define HAVE_TICK_COUNTER +#endif + +/* Microsoft Visual C++ */ +#if defined(_MSC_VER) && defined(_M_IA64) && !defined(HAVE_TICK_COUNTER) +typedef unsigned __int64 ticks; + +# ifdef __cplusplus +extern "C" +# endif +ticks __getReg(int whichReg); +#pragma intrinsic(__getReg) + +static __inline ticks getticks(void) +{ + volatile ticks temp; + temp = __getReg(3116); + return temp; +} + +INLINE_ELAPSED(inline) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* + * PA-RISC cycle counter + */ +#if defined(__hppa__) || defined(__hppa) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long ticks; + +# ifdef __GNUC__ +static __inline__ ticks getticks(void) +{ + ticks ret; + + __asm__ __volatile__("mfctl 16, %0": "=r" (ret)); + /* no input, nothing else clobbered */ + return ret; +} +# else +# include +static inline unsigned long getticks(void) +{ + register ticks ret; + _MFCTL(16, ret); + return ret; +} +# endif + +INLINE_ELAPSED(inline) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* S390, courtesy of James Treacy */ +#if defined(__GNUC__) && defined(__s390__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long long ticks; + +static __inline__ ticks getticks(void) +{ + ticks cycles; + __asm__("stck 0(%0)" : : "a" (&(cycles)) : "memory", "cc"); + return cycles; +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif +/*----------------------------------------------------------------*/ +#if defined(__GNUC__) && defined(__alpha__) && !defined(HAVE_TICK_COUNTER) +/* + * The 32-bit cycle counter on alpha overflows pretty quickly, + * unfortunately. A 1GHz machine overflows in 4 seconds. + */ +typedef unsigned int ticks; + +static __inline__ ticks getticks(void) +{ + unsigned long cc; + __asm__ __volatile__ ("rpcc %0" : "=r"(cc)); + return (cc & 0xFFFFFFFF); +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +#if defined(__GNUC__) && defined(__sparc_v9__) && !defined(HAVE_TICK_COUNTER) +typedef unsigned long ticks; + +static __inline__ ticks getticks(void) +{ + ticks ret; + __asm__ __volatile__("rd %%tick, %0" : "=r" (ret)); + return ret; +} + +INLINE_ELAPSED(__inline__) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +#if (defined(__DECC) || defined(__DECCXX)) && defined(__alpha) && defined(HAVE_C_ASM_H) && !defined(HAVE_TICK_COUNTER) +# include +typedef unsigned int ticks; + +static __inline ticks getticks(void) +{ + unsigned long cc; + cc = asm("rpcc %v0"); + return (cc & 0xFFFFFFFF); +} + +INLINE_ELAPSED(__inline) + +#define HAVE_TICK_COUNTER +#endif +/*----------------------------------------------------------------*/ +/* SGI/Irix */ +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER) +typedef struct timespec ticks; + +static inline ticks getticks(void) +{ + struct timespec t; + clock_gettime(CLOCK_SGI_CYCLE, &t); + return t; +} + +static inline double elapsed(ticks t1, ticks t0) +{ + return ((double)t1.tv_sec - (double)t0.tv_sec) * 1.0E9 + + ((double)t1.tv_nsec - (double)t0.tv_nsec); +} +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* Cray UNICOS _rtc() intrinsic function */ +#if defined(HAVE__RTC) && !defined(HAVE_TICK_COUNTER) +#ifdef HAVE_INTRINSICS_H +# include +#endif + +typedef long long ticks; + +#define getticks _rtc + +INLINE_ELAPSED(inline) + +#define HAVE_TICK_COUNTER +#endif + +/*----------------------------------------------------------------*/ +/* MIPS ZBus */ +#if HAVE_MIPS_ZBUS_TIMER +#if defined(__mips__) && !defined(HAVE_TICK_COUNTER) +#include +#include +#include + +typedef uint64_t ticks; + +static inline ticks getticks(void) +{ + static uint64_t* addr = 0; + + if (addr == 0) + { + uint32_t rq_addr = 0x10030000; + int fd; + int pgsize; + + pgsize = getpagesize(); + fd = open ("/dev/mem", O_RDONLY | O_SYNC, 0); + if (fd < 0) { + perror("open"); + return NULL; + } + addr = mmap(0, pgsize, PROT_READ, MAP_SHARED, fd, rq_addr); + close(fd); + if (addr == (uint64_t *)-1) { + perror("mmap"); + return NULL; + } + } + + return *addr; +} + +INLINE_ELAPSED(inline) + +#define HAVE_TICK_COUNTER +#endif +#endif /* HAVE_MIPS_ZBUS_TIMER */ + diff --git a/libraries/pmrt/irtrack/irtrack.a b/libraries/pmrt/irtrack/irtrack.a new file mode 100644 index 0000000..da0f93b Binary files /dev/null and b/libraries/pmrt/irtrack/irtrack.a differ diff --git a/libraries/pmrt/irtrack/irtrack.c b/libraries/pmrt/irtrack/irtrack.c new file mode 100755 index 0000000..ed46bba --- /dev/null +++ b/libraries/pmrt/irtrack/irtrack.c @@ -0,0 +1,4442 @@ +// ------------------------------------------------------------------- +// irtrack.c + +#include +#include +#include +#include +#include +#include + +#include +#define _POSIX_SOURCE 1 + +#include "cv.h" + +#include "irtrack.h" +#include "serial.h" + +#include "physWrapper.h" + +// 1 means use rs232, 0 means GWB +#define G_RS232 1 + +// ------------------------------------------------------------------- + +// TODO: we need to make the system compatible with multiple guns, +// which means that we have to store multiple copies of each varaible. +// This includes the point and group lists, previous homography matrix, +// group table, raw led data, debug data, gun coordinates, switches +// and calibration values. +// +// We can leave the space open for 4 guns. The only memory wasted for +// an unused gun slot is the raw led data array. If a gun has no data, +// nothing will be calculated or allocated. +// +// We should definetly make the system compatible for N guns. You +// never know, right? + +IrPointType *irt_pointList[SERIAL_MAX_PLAYERS]; +IrPointGroupType *irt_groupList[SERIAL_MAX_PLAYERS]; +IrPointGroupType *prevGroupList[SERIAL_MAX_PLAYERS]; + +IrCalibType *irt_calibList[SERIAL_MAX_PLAYERS]; +int irt_calibListSize[SERIAL_MAX_PLAYERS]; +int irt_calibListIndex[SERIAL_MAX_PLAYERS]; + +int irt_numPoints[SERIAL_MAX_PLAYERS]; +int irt_numGroups[SERIAL_MAX_PLAYERS]; +int irt_numPrevGroups[SERIAL_MAX_PLAYERS]; +float irt_avgDist; + +int irt_sampleCount[SERIAL_MAX_PLAYERS]; + +// - mark the fact that the current gun data has been read by the game + +char irt_dirtyFlag[SERIAL_MAX_PLAYERS]; + +// - check to see if we are off screen for any reason (bad read, null data, ect.) + +char int_offscreenFlag[SERIAL_MAX_PLAYERS]; + +// - by keeping track of which of the ten led boards that +// are visible to each players gun, we can show technicians +// servicing the machine if a certain board is never seen, and +// probably needs to be repaired. + +int irt_visibleGroups[SERIAL_MAX_PLAYERS][10]; + +int irt_currCalibXY[SERIAL_MAX_PLAYERS * 2]; +int irt_currCalibLeftXY[SERIAL_MAX_PLAYERS * 2]; +int irt_currCalibRightXY[SERIAL_MAX_PLAYERS * 2]; + +static CvMat cv_prev[SERIAL_MAX_PLAYERS]; +static CvMat cv_prevInv[SERIAL_MAX_PLAYERS]; + +// - the players orientation to the screen is continously being +// estimated as the game is played. this is done to provide a +// constant calibration for the player + +float irt_playerAngle[SERIAL_MAX_PLAYERS]; +float irt_playerDistance[SERIAL_MAX_PLAYERS]; +int irt_playerInCenter[SERIAL_MAX_PLAYERS]; + +float irt_depthTable[4] = { 150, 200, 250, 300 }; +float irt_angleTable[9] = { 0.80, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20 }; + +IrGroupTableType groupTable[SERIAL_MAX_PLAYERS][IR_HIST_TABLE_SIZE]; + +LedPointType ldata[SERIAL_MAX_PLAYERS][MAX_LEDS]; + +// - keep track of the last 4 gun coordinate entries + +IrGunCoordType irt_gunCoord[SERIAL_MAX_PLAYERS][4]; + +IrGunCoordType irt_xminusCoord[SERIAL_MAX_PLAYERS][4]; +IrGunCoordType irt_xplusCoord[SERIAL_MAX_PLAYERS][4]; + +// - the gun calibration is simply a pixel offset from the center +// of the screen + +int irt_gunCalibXY[SERIAL_MAX_PLAYERS][2]; +int irt_gunCalibLeftXY[SERIAL_MAX_PLAYERS][2]; +int irt_gunCalibRightXY[SERIAL_MAX_PLAYERS][2]; + +float irt_dbgPoints[SERIAL_MAX_PLAYERS][2 * MAX_LEDS]; +float irt_dbgGroups[SERIAL_MAX_PLAYERS][2 * MAX_LEDS]; +int irt_dbgNumGroups[SERIAL_MAX_PLAYERS]; + +float irt_y0[SERIAL_MAX_PLAYERS]; +float irt_y1[SERIAL_MAX_PLAYERS]; + +// - the two "history lines" are lines that describe the two rows +// of leds on the cabinet + +IrHistLineType hLine[2][SERIAL_MAX_PLAYERS]; + +// - keep track of when each player is using interpolated data to +// generate the gun coordinate + +int irt_usingInterpolation[SERIAL_MAX_PLAYERS]; +float irt_interpolationEntry[SERIAL_MAX_PLAYERS][2]; + +// - by default, the system will spawn a thread to handle the +// processing of the led data as soon as it becomes available + +static int irt_enableThread = 1; + +// - GWB firmware versions + +int irt_gwbVersion[4] = {0, 0, 0, 0}; + +int irt_gunVersion[SERIAL_MAX_PLAYERS]; +int irt_gunActive[SERIAL_MAX_PLAYERS]; + +float irt_avgFriendDist[SERIAL_MAX_PLAYERS]; + +char irt_systemCamRegisters[4]; +int irt_gunCamRegisterState[SERIAL_MAX_PLAYERS]; + +#define IRT_OS_GRID_RES 100 +#define IRT_OS_GRID_SIZE IRT_OS_GRID_RES * IRT_OS_GRID_RES + +IrOSGridPointType irt_osGrid[IRT_OS_GRID_SIZE][SERIAL_MAX_PLAYERS]; + +slog_callback *irt_sysLog = NULL; + +// - this flag signals that we are in the process of reversing player input + +int irt_reverse_in_progress = 0; + +// ------------------------------------------------------------------- + +pthread_t loop_thread; +pthread_attr_t loop_attr; +int irt_loop_exit = 0; + +// ------------------------------------------------------------------- + +inline void irt_point_transform(CvMat hmat, double *p_in, double *p_out); +inline float irt_getDistance(IrCoordType c1, IrCoordType c2); + +// ------------------------------------------------------------------- + +// - these coordinates were generated by a photograph of the test +// location cabinet + +#define SHOFF_UP 250.0 +#define SHOFF_DN 250.0 + +double irt_grp_rxy[2 * 20] = +{ + -29.7, -441.2, // 0 + 182.8, -441.2, // 1 + -24.9, -109.7, // 2 + 184.7, -109.7, // 3 + 396.2, -441.2, // 4 + 392.3, -109.7, // 5 + 606.7, -441.2, // 6 + 600.0, -109.7, // 7 + 815.3, -441.2, // 8 + 804.8, -109.7, // 9 + + -29.7, -441.2 - SHOFF_UP, // 10 SHADOW + 182.8, -441.2 - SHOFF_UP, // 11 SHADOW + 396.2, -441.2 - SHOFF_UP, // 12 SHADOW + 606.7, -441.2 - SHOFF_UP, // 13 SHADOW + 815.3, -441.2 - SHOFF_UP, // 14 SHADOW + + -24.9, -109.7 + SHOFF_DN, // 15 SHADOW + 184.7, -109.7 + SHOFF_DN, // 16 SHADOW + 392.3, -109.7 + SHOFF_DN, // 17 SHADOW + 600.0, -109.7 + SHOFF_DN, // 18 SHADOW + 804.8, -109.7 + SHOFF_DN, // 19 SHADOW +}; + +// ------------------------------------------------------------------- +// 0 1 4 6 8 +// 2 3 5 7 9 +/* +int goRelationTable[30] = { + // - group #0 + 2, 3, 1, + // - group #1 + 3, 4, 5, + // - group #2 + 0, 1, 3, + // - group #3 + 1, 4, 5, + // - group #4 + 5, 7, 6, + // - group #5 + 7, 4, 6, + // - group #6 + 8, 7, 9, + // - group #7 + 9, 6, 8, + // - group #8 + 7, 9, 6, + // - group #9 + 6, 8, 7, +}; +*/ + +/* +int goRelationTable[30] = { + // - group #0 + 2, 3, -1, + // - group #1 + 2, 3, 5, + // - group #2 + 0, 1, -1, + // - group #3 + 0, 1, 4, + // - group #4 + 3, 5, 7, + // - group #5 + 1, 4, 6, + // - group #6 + 5, 7, 9, + // - group #7 + 4, 6, 8, + // - group #8 + 7, 9, -1, + // - group #9 + 6, 8, -1, +}; +*/ + +int goRelationTable[30] = { + // - group #0 + 2, -1, -1, + // - group #1 + -1, 3, -1, + // - group #2 + 0, -1, -1, + // - group #3 + -1, 1, -1, + // - group #4 + -1, 5, -1, + // - group #5 + -1, 4, -1, + // - group #6 + -1, 7, -1, + // - group #7 + -1, 6, -1, + // - group #8 + -1, 9, -1, + // - group #9 + -1, 8, -1, +}; + +static IrGroupOffsetType goTable[30][SERIAL_MAX_PLAYERS]; + +// ------------------------------------------------------------------- + +void _irt_getOffsetTableData(int gindex, int index, float *x, float *y, float *minMax) +{ + int i; + + for (i = 0; i < 3; i++) + { + if (goTable[(index * 3) + i][gindex].targetId != -1) + { + *x = goTable[(index * 3) + i][gindex].x; + *y = goTable[(index * 3) + i][gindex].y; + minMax[0] = goTable[(index * 3) + i][gindex].min_x; + minMax[1] = goTable[(index * 3) + i][gindex].min_y; + minMax[2] = goTable[(index * 3) + i][gindex].max_x; + minMax[3] = goTable[(index * 3) + i][gindex].max_y; + return; + } + } + + *x = 0.0; + *y = 0.0; + for (i = 0; i < 4; i++) + minMax[i] = 0.0; +} + +// ------------------------------------------------------------------- + +void _irt_insertOffsetTableData(int gindex, int gid, int target, float x, float y) +{ + int i; + + for (i = 0; i < 3; i++) + { + if (goTable[(gid * 3) + i][gindex].targetId != -1) + { + goTable[(gid * 3) + i][gindex].x = x; + //goTable[(gid * 3) + i][gindex].x /= 2; + goTable[(gid * 3) + i][gindex].y = y; + //goTable[(gid * 3) + i][gindex].y /= 2; + //printf("goTable[%i][0] -> %2.2f, %2.2f\n", (gid * 3) + i, x, y); + return; + } + } +} + +// ------------------------------------------------------------------- + +int irt_systemGetGunActive(int gindex) +{ + return irt_gunActive[gindex]; +} + +// ------------------------------------------------------------------- + +int irt_systemGetSerialErrStatus(void) +{ + return serial_get_err_status(); +} + +// ------------------------------------------------------------------- + +void irt_loop_thread(void *ptr) +{ + int sample, curr_sample = -1; + int thread_index; + int loopCount = 0; + + thread_index = *((int*)ptr); + + //irt_systemSLog("irt_loop_thread[%i]: spawned\n", thread_index); + + while (!irt_loop_exit) + { + sample = serial_getSampleNum(thread_index); + + if (sample != curr_sample) + { + curr_sample = sample; + irt_systemLoop(thread_index); + loopCount = 0; + + if (!irt_gunActive[thread_index]) + { + //irt_systemSLog("irt_loop_thread[%i]: player #%i gun active\n", thread_index, thread_index + 1); + irt_gunActive[thread_index] = 1; + sleep(1); + serial_sendmsg(SERIAL_TX_RESET_CAMERA, NULL, thread_index); + } + } + + usleep(1000); + + if (loopCount == 1000) + { + //irt_systemSLog("irt_looop_thread[%i]: player #%i gun inactive!\n", thread_index, thread_index + 1); + loopCount++; + irt_gunActive[thread_index] = 0; + irt_gunCamRegisterState[thread_index] = 0; + } + else + loopCount++; + } + + //irt_systemSLog("irt_loop_thread[%i]: exited\n", thread_index); +} + +// ------------------------------------------------------------------- +// - this thread is responsible for monitoring the connection to the +// gwb, and it will attempt to close and re-open the connection if +// it ever goes down + +void irt_restart_thread(void *ptr) +{ + static int request_restart = 0; + int i, res; + + irt_systemSLog("irt_restart_thread: begun\n"); + + while (!irt_loop_exit) + { + if (serial_shouldRestart() && !request_restart) + { + request_restart = 1; + irt_systemSLog("irt_restart_thread: requesting connection shutdown\n"); + + // CHANGE THIS TO SOMETHING TO DO WITH THE SERIAL PORT - 7-30-08 KTU + //usb_quit(); + serial_close(); + + // - if they haven't been done so already, flag the guns as being + // inactive. + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + irt_gunActive[i] = 0; + irt_gunCamRegisterState[i] = 0; + } + + // - also clear out the firmware version. we will recieve a new + // one once the system is up and running again. + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + irt_systemSetFirmware(0, i); + } + + // - give the system at least five seconds before we attempt + // to reconnect + + sleep(5); + } + + // - if we have previously requested a restart, and we can + // detect the presence of the gwb on the usb bus, we will + // attempt to start the connection again. + + if (request_restart) + { + irt_systemSLog("irt_restart_thread: gwb detected, attempting to reconnect... "); + serial_init(); + request_restart = 0; + } + /* + if (request_restart && serial_detectGWB()) + { + irt_systemSLog("irt_restart_thread: gwb detected, attempting to reconnect... "); + + if (usb_gwb_init() < 0) + { + irt_systemSLog("failed.\n"); + sleep(1); + } + else + { + irt_systemSLog("success!\n"); + request_restart = 0; + + // - request the firmware version again + + //usb_gwb_sendmsg(GWB_MSG_GETFIRMWARE, NULL); + } + } + */ + sleep(1); + } + + irt_systemSLog("irt_restart_thread: exited\n"); +} + +// ------------------------------------------------------------------- + +int irt_systemDetectGWB(void) +{ + return serial_detectGWB(); +} + +// ------------------------------------------------------------------- +// +// +// ***************** THIS FUNCTION IS NOT NEEDED !!!! ***************** +// +/* +void irt_systemRequestFirmware(void) +{ + usb_gwb_sendmsg(GWB_MSG_GETFIRMWARE, NULL); +} +*/ + +// ------------------------------------------------------------------- +// - initialize the tracking system + +int irt_systemInit(void) +{ + static int idx[SERIAL_MAX_PLAYERS]; + int i, j, k; + + // - we just need these numbers to pass to the individual loop threads + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + idx[i] = i; + + //irt_systemSLog("serial version actually compiled!\n"); + + // - begin the serial port read thread + // use ttyUSB0 and ttyUSB1 for debug + if (serial_init() == -1) //"/dev/ttyUSB0", "/dev/ttyUSB1") == -1) + return -1; + + + // - clear the gun coordinate data for all of the guns + + for (i = 0; i < 4; i++) + { + for (j = 0; j < SERIAL_MAX_PLAYERS; j++) + { + irt_gunCoord[j][i].x = irt_gunCoord[j][i].y = irt_gunCoord[j][i].angle = 0; + } + + // - clear the xoffset calibration points + + irt_y0[i] = 0.0; + irt_y1[i] = 600.0; + } + + // - these calibration values were set on the playmechanix + // test rig + + irt_y0[0] = -28.03; + irt_y1[0] = 27.68; + irt_y0[1] = -11.43; + irt_y1[1] = 60.93; + + // - start with an initial gun calibration + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + irt_systemSetGunCalib(i, 490, -20); + irt_pointList[i] = NULL; + irt_groupList[i] = NULL; + prevGroupList[i] = NULL; + + irt_calibList[i] = NULL; + irt_calibListSize[i] = 0; + irt_calibListIndex[i] = -1; + + irt_playerInCenter[i] = 0; + + irt_sampleCount[i] = 0; + irt_currCalibXY[(i * 2) + 0] = 0; + irt_currCalibXY[(i * 2) + 1] = 0; + + irt_currCalibLeftXY[(i * 2) + 0] = 0; + irt_currCalibLeftXY[(i * 2) + 1] = 0; + + irt_currCalibRightXY[(i * 2) + 0] = 0; + irt_currCalibRightXY[(i * 2) + 1] = 0; + + irt_dirtyFlag[i] = 0; + + int_offscreenFlag[i] = 1; + + irt_avgFriendDist[i] = 0.0; + + irt_gunCamRegisterState[i] = 0; + + hLine[0][i].active = 0; + hLine[1][i].active = 0; + + irt_gunActive[i] = 1; + + for (j = 0; j < 30; j++) + { + goTable[j][i].targetId = goRelationTable[j]; + goTable[j][i].x = goTable[j][i].y = 0.0; + goTable[j][i].min_x = goTable[j][i].min_y = 999.9; + goTable[j][i].max_x = goTable[j][i].max_y = -999.9; + } + + irt_usingInterpolation[i] = 0; + irt_interpolationEntry[i][0] = 0.0; + irt_interpolationEntry[i][1] = 0.0; + + for (j = 0; j < IRT_OS_GRID_RES; j++) + for (k = 0; k < IRT_OS_GRID_RES; k++) + { + irt_osGrid[(j * IRT_OS_GRID_RES) + k][i].x = (800.0 / IRT_OS_GRID_RES) * k; + irt_osGrid[(j * IRT_OS_GRID_RES) + k][i].y = (600.0 / IRT_OS_GRID_RES) * k; + irt_osGrid[j][i].ox = irt_osGrid[j][i].oy = 0; + } + } + + sleep(2); + //irt_systemSetMarqueeState(1); + + // - spawn a thread to calculate the point data as soon as it has + // been recived from the serial port. + + irt_loop_exit = 0; + + if (irt_enableThread) + { + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + pthread_attr_init(&loop_attr); + pthread_attr_setdetachstate(&loop_attr, PTHREAD_CREATE_DETACHED); + pthread_create(&loop_thread, &loop_attr, (void*)irt_loop_thread, &idx[i]); + pthread_attr_destroy(&loop_attr); + } + // - spawn a thread to monitor the connection to the gwb + +#if (G_RS232==0) + pthread_attr_init(&loop_attr); + pthread_attr_setdetachstate(&loop_attr, PTHREAD_CREATE_DETACHED); + pthread_create(&loop_thread, &loop_attr, (void*)irt_restart_thread, NULL); + pthread_attr_destroy(&loop_attr); +#endif + } + + return 1; +} + +// ------------------------------------------------------------------- + +// +// 7-29-2008 KTU +// Use this call to reset the cameras back to a known state. +// +void irt_systemSendUpdateMSG(void) +{ + int i; + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + // No data input (NULL) + serial_sendmsg(SERIAL_TX_RESET_CAMERA, NULL, i); + } +} + + +// ------------------------------------------------------------------- +/* +void irt_systemSetFirmware(int mcuL, int mcuH, int fpgaL, int fpgaH) +{ + irt_gwbVersion[0] = mcuL; + irt_gwbVersion[1] = mcuH; + irt_gwbVersion[2] = fpgaL; + irt_gwbVersion[3] = fpgaH; + + //irt_systemSLog("Firmware Set: MCU %x.%x FPGA %x.%x\n", mcuH, mcuL, fpgaH, fpgaL); +} +*/ +void irt_systemSetFirmware(int fpga, int player) +{ + irt_gunVersion[player] = fpga; +} + + +// ------------------------------------------------------------------- +/* +void irt_systemGetFirmware(int *mcuL, int *mcuH, int *fpgaL, int *fpgaH) +{ + *mcuL = irt_gwbVersion[0]; + *mcuH = irt_gwbVersion[1]; + *fpgaL = irt_gwbVersion[2]; + *fpgaH = irt_gwbVersion[3]; +}*/ +void irt_systemGetFirmware(int *fpga, int player) +{ + *fpga = irt_gunVersion[player]; +} + + +// ------------------------------------------------------------------- +/* +void irt_systemSetRegisterStatus(char *buf) +{ + int i, gindex, allgood; + + gindex = buf[1] - 1; + + allgood = 1; + for (i = 0; i < 4; i++) + if (buf[4 + i] != irt_systemCamRegisters[0 + i]) + allgood = 0; + + irt_gunCamRegisterState[gindex] = allgood; + + // irt_systemSLog("gun %i, allgood = %i\n", gindex, allgood); +}*/ +void irt_systemSetRegisterStatus(unsigned char *reg_fpga, unsigned char *reg_cam, int player) +{ + int i, allgood; + + allgood = 1; + + for (i = 0; i < 30; i++){ + if (reg_fpga[i] != reg_cam[i]) + allgood = 0; + } + + irt_gunCamRegisterState[player] = allgood; + + // irt_systemSLog("gun %i, allgood = %i\n", gindex, allgood); +} + + +// ------------------------------------------------------------------- +// - enable or disable the use of threading to process led data. it +// should be turned off if we are trying to do some exotic debugging. +// +// NOTE: this option needs to be set before irt_systemInit is called. + +void irt_systemSetThreadEnable(int state) +{ + irt_enableThread = state; +} + +// ------------------------------------------------------------------- + +void irt_systemReverseInput(void) +{ + irt_reverse_in_progress = 1; + serial_reverseInput(); + irt_reverse_in_progress = 0; +} + +// ------------------------------------------------------------------- + +int irt_systemReverseInputStatus(void) +{ + return irt_reverse_in_progress; +} + +// ------------------------------------------------------------------- +// - close out the tracking system and free any used resources + +void irt_systemClose(void) +{ + int i; + + //irt_systemSetMarqueeState(0); + + // - shut down the system loop thread + + irt_loop_exit = 1; + + // - wait a bit for the threads to shut down + + sleep(2); + + // - shut down the serial port connections and read threads + // (this call will block until it is done) + + serial_close(); + + // - free the memory used up by the point and group lists + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + irt_destroyPointList(i); + irt_destroyGroupList(i); + + if (irt_calibListSize[i]) + free(irt_calibList[i]); + } +} + +// ------------------------------------------------------------------- +// - read in the latest point data and produce a new gun coordinate + +void irt_systemLoop(int gindex) +{ + float angle, angleYOffset, dist; + int i, j, scanResult, cx, cy; + float x, y, ftable[128]; + int psearch[4], pid[4]; + IrPointGroupType *g; + IrCoordType c1, c2; + float minmax[4]; + int index; + int res[2]; + + // - using the latest serial data, generate a list of coordinates + // and groups + + test_createCoordsFromLeds(gindex); + + // - save the xy data for each of the points in an array + + memset(irt_dbgPoints[gindex], 0, sizeof(float) * 2 * MAX_LEDS); + + + if (irt_numPoints[gindex] && irt_pointList[gindex]) + { + for (i = 0; i < irt_numPoints[gindex]; i++) + { + irt_dbgPoints[gindex][(i * 2) + 0] = irt_pointList[gindex][i].crd.x; + irt_dbgPoints[gindex][(i * 2) + 1] = irt_pointList[gindex][i].crd.y; + } + } + + // - before we start scanning for patterns we might consider simply + // comparing the data to the history table, and assign points that + // are "close enough" + + // - we might have a problem if everything is "grandfathered" into + // null data, and the pattern scanner refuses to re-assign anyone! + + // irt_groupHistoryAssign(0); + + // **** 01.07.08 **** + // - if two cabinets are side-by-side in an arcade, it is possible for + // the lights on one cabinet to interferre with the gun tracking + // on the other. the first step in detecting this sort of interferrence + // is to identify the 3-1-3-1 pattern, which appears only between two + // identical cabinets. + + psearch[0] = 3; psearch[1] = 1; psearch[2] = 3; psearch[3] = 1; + pid[0] = 108; pid[1] = 109; pid[2] = 100; pid[3] = 101; + if (irt_scanPattern(gindex, psearch, pid, 1)) + { + // - check to see if we have scan group #4 + + psearch[0] = 3; psearch[1] = 3; psearch[2] = 1; psearch[3] = 3; + pid[0] = 6; pid[1] = 108; pid[2] = 7; pid[3] = 109; + res[0] = irt_scanPattern(gindex, psearch, pid, 1); + + // - check for scan group #1 + + psearch[0] = 1; psearch[1] = 1; psearch[2] = 1; psearch[3] = 2; + pid[0] = 100; pid[1] = 101; pid[2] = 2; pid[3] = 3; + res[1] = irt_scanPattern(gindex, psearch, pid, 1); + + if (res[0] && !res[1]) + { + // - 108 and 109 become 8 and 9. + + irt_groupAssign(gindex, 108, 8); + irt_groupAssign(gindex, 109, 9); + } + else if (!res[0] && res[1]) + { + // - 100 and 101 become 0 and 1 + + irt_groupAssign(gindex, 100, 0); + irt_groupAssign(gindex, 101, 1); + } + else if (res[0] && res[1]) + { + // - repeat the process with groups 3 and 2. + // group #3... + + psearch[0] = 2; psearch[1] = 3; psearch[2] = 3; psearch[3] = 1; + pid[0] = 4; pid[1] = 6; pid[2] = 5; pid[3] = 7; + res[0] = irt_scanPattern(gindex, psearch, pid, 1); + + // - group #2 + + psearch[0] = 1; psearch[1] = 2; psearch[2] = 2; psearch[3] = 3; + pid[0] = 1; pid[1] = 4; pid[2] = 3; pid[3] = 5; + res[1] = irt_scanPattern(gindex, psearch, pid, 1); + + if (res[0] && !res[1]) + { + // - 108 and 109 become 8 and 9. + + irt_groupAssign(gindex, 108, 8); + irt_groupAssign(gindex, 109, 9); + } + else if (!res[0] && res[1]) + { + // - 100 and 101 become 0 and 1 + + irt_groupAssign(gindex, 100, 0); + irt_groupAssign(gindex, 101, 1); + } + } + } + + // **** /01.07.08 **** + + // - scan the coordinate data for the identities of specific groups. + + scanResult = 0; + + // - SCAN GROUP #1 + + psearch[0] = 1; psearch[1] = 1; psearch[2] = 1; psearch[3] = 2; + pid[0] = 0; pid[1] = 1; pid[2] = 2; pid[3] = 3; + scanResult += irt_scanPattern(gindex, psearch, pid, 1); + + // - SCAN GROUP #2 + + psearch[0] = 1; psearch[1] = 2; psearch[2] = 2; psearch[3] = 3; + pid[0] = 1; pid[1] = 4; pid[2] = 3; pid[3] = 5; + scanResult += irt_scanPattern(gindex, psearch, pid, 1); + + // - SCAN GROUP #3 + + psearch[0] = 2; psearch[1] = 3; psearch[2] = 3; psearch[3] = 1; + pid[0] = 4; pid[1] = 6; pid[2] = 5; pid[3] = 7; + scanResult += irt_scanPattern(gindex, psearch, pid, 1); + + // - SCAN GROUP #4 + + psearch[0] = 3; psearch[1] = 3; psearch[2] = 1; psearch[3] = 3; + pid[0] = 6; pid[1] = 8; pid[2] = 7; pid[3] = 9; + scanResult += irt_scanPattern(gindex, psearch, pid, 1); + + // - do a couple 3 scans, not counting them as full 4 scans. + + psearch[0] = 1; psearch[1] = 1; psearch[2] = 2; + pid[0] = 0; pid[1] = 1; pid[2] = 4; + irt_scan3Pattern(gindex, psearch, pid); + + psearch[0] = 2; psearch[1] = 3; psearch[2] = 3; + pid[0] = 4; pid[1] = 6; pid[2] = 8; + irt_scan3Pattern(gindex, psearch, pid); + + // - after we have identified whatever groups we could, try to + // identify the remaining groups based on the history + + if (!scanResult) + { + irt_groupHistoryAssign(gindex, 0); + //irt_groupInterpolateBlanks(gindex); + } + + irt_enforceGroupOffsetTable(gindex); + irt_updateGroupOffsetTable(gindex); + + // - save the xy data for each of the groups in an array + + irt_dbgNumGroups[gindex] = irt_numGroups[gindex]; + memset(irt_dbgGroups[gindex], 0, sizeof(float) * 2 * MAX_LEDS); + + if (irt_numGroups[gindex] && irt_groupList[gindex]) + { + for (i = 0; i < irt_numGroups[gindex]; i++) + { + irt_dbgGroups[gindex][(i * 2) + 0] = irt_groupList[gindex][i].x; + irt_dbgGroups[gindex][(i * 2) + 1] = irt_groupList[gindex][i].y; + } + } + + memset(irt_visibleGroups[gindex], 0, sizeof(int) * 10); + + for (i = 0; i < 10; i++) + { + if (g = irt_getGroupById(gindex, i)) + { + if (!g->faked) + irt_visibleGroups[gindex][i] = 1; + } + } + + // - lets attempt to do an estimate of the distance based on the + + + // - find the 4 groups that create the largest possible box and + // perform a planar homography calculation to produce a + // gun coordinate. + + if (!irt_calcBiggestBox(gindex, 400 + irt_gunCalibXY[gindex][0], 300 + irt_gunCalibXY[gindex][1], &x, &y, 0)) + irt_calcBiggestBox(gindex, 400 + irt_gunCalibXY[gindex][0], 300 + irt_gunCalibXY[gindex][1], &x, &y, 1); + + // - ALTERNATIVE METHOD: use the weighted average of all of the available + // homography rectangles. + // + // NOTE: we still need to run irt_calcBiggestBox at least once to generate + // the calibration data, as irt_calc_all_boxes doesn't do this yet. + + if (1) + { + //irt_systemGetPositionCal(gindex, &cx, &cy); + //if (gindex == 0) printf("(%i, %i)\n", cx, cy); + //irt_calc_all_boxes(gindex, 400 + cx, 300 + cy, ftable); + + // - calculate the gun coordinate using the standard calibration point + + irt_calc_all_boxes(gindex, 400 + irt_gunCalibXY[gindex][0], 300 + irt_gunCalibXY[gindex][1], ftable); + x = ftable[100]; + y = ftable[101]; + + /* + // - check the angle that the player is holding the gun at. if the angle is too + // severe, we will apply a bit of correction to the calibration point and we will + // calculate the coordinate again. + + angle = irt_systemGetXPMAngle(gindex); + //printf("angle = %2.2f\n", angle); + + // - note: these angle thresholds and correction values are tuned for the + // test cabinet. + + if (((angle <= 0.90) || (angle >= 1.10)) + && ((angle > -1.5) && (angle < 1.5))) + { + angleYOffset = (1.0 - angle) * 50.0;//173.3; + + //if (gindex == 0) + //printf("angleYOffset = %2.2f\n", angleYOffset); + irt_calc_all_boxes(gindex, 400 + irt_gunCalibXY[gindex][0], 300 + irt_gunCalibXY[gindex][1] + angleYOffset, ftable); + x = ftable[100]; + y = ftable[101]; + } + */ + } + + if ((x != irt_gunCoord[gindex][0].x) + && (y != irt_gunCoord[gindex][0].y)) + if (!(!x && !y)) + { + // - we store the last 4 gun coordinates so we can give an averaged + // result + + irt_gunCoord[gindex][3] = irt_gunCoord[gindex][2]; + irt_gunCoord[gindex][2] = irt_gunCoord[gindex][1]; + irt_gunCoord[gindex][1] = irt_gunCoord[gindex][0]; + + irt_gunCoord[gindex][0].x = x; + irt_gunCoord[gindex][0].y = y; + irt_gunCoord[gindex][0].angle = 0; + irt_gunCoord[gindex][0].timestamp = clock(); + + // - this is a nice, new piece of gun data! + + irt_dirtyFlag[gindex] = 0; + int_offscreenFlag[gindex] = 0; + } + else + { + int_offscreenFlag[gindex] = 1; + irt_dirtyFlag[gindex] = 1; + } + + irt_estimatePlayerPosition(gindex); + + // - free the point and group lists. we'll be creating new ones + // from scratch later + + irt_destroyPointList(gindex); + irt_destroyGroupList(gindex); + + // - advance the age of each of the points in the group history + // table + + irt_groupTableTick(); + + irt_sampleCount[gindex]++; +} + +// ------------------------------------------------------------------- +// - note: vgroup should be an int[10] + +void irt_systemGetVisibleGroups(int gindex, int *vgroup) +{ + int i; + + for (i = 0; i < 10; i++) + vgroup[i] = irt_visibleGroups[gindex][i]; +} + +// ------------------------------------------------------------------- + +clock_t irt_systemGetTimeStamp(int gindex) +{ + return irt_gunCoord[gindex][0].timestamp; +} + +// ------------------------------------------------------------------- + +clock_t irt_systemGetTimeStampDiff(int gindex) +{ + return irt_gunCoord[gindex][0].timestamp - irt_gunCoord[gindex][1].timestamp; +} + +// ------------------------------------------------------------------- +// - get the latest gun coordinates available from the system +// +// note that the returned coordinate is a weighted average of the last +// four. this is because the cursor in the irtrack demo is used +// similar to a mouse pointer or a wand, and not a gun. we should +// simply return the most recently calculated coordinate. + +void irt_systemGetCoords(int gindex, float *x, float *y) +{ + float avgx, avgy, f, ft; + int i; + + *x = irt_gunCoord[gindex][0].x; + *y = irt_gunCoord[gindex][0].y; +} + +// ------------------------------------------------------------------- +// - wait until the latest gun data is available, then return it! + +void irt_systemGetLatestCoords(int gindex, float *x, float *y) +{ + int currIndex, spins; + + // - we keep track of the current sample count... + + currIndex = irt_sampleCount[gindex]; + + // - ... and spin until we get a new one + + spins = 0; + while ((currIndex == irt_sampleCount[gindex]) + && (spins < 100)) + { + usleep(1000); + spins++; + } + + // - these coordinates are as new as can be! + + *x = irt_gunCoord[gindex][0].x; + *y = irt_gunCoord[gindex][0].y; +} + +// ------------------------------------------------------------------- + +void irt_systemScaleCoords(int gindex, float x, float y, float *sx, float *sy) +{ + float ys0, ys1; + + ys0 = (300.0 - irt_y0[gindex]) / 300.0; + ys1 = (300.0 + (irt_y1[gindex] - 600.0)) / 300.0; + + if (y < 300) + { + y = 300.0 - ((300.0 - y) / ys0); + } + + if (y > 300) + { + y = 300.0 - ((y - 300) * ys1); + } + + *sx = x; + *sy = y; +} + +// ------------------------------------------------------------------- + +void irt_systemGetScaledCoords(int gindex, float *x, float *y) +{ + float ys0, ys1; + + *x = irt_gunCoord[gindex][0].x; + *y = irt_gunCoord[gindex][0].y; + + ys0 = (300.0 - irt_y0[gindex]) / 300.0; + ys1 = (300.0 + (irt_y1[gindex] - 600.0)) / 300.0; + + if (*y < 300) + { + *y = 300.0 - ((300.0 - *y) / ys0); + } + + if (*y > 300) + { + *y = 300.0 - ((*y - 300) * ys1); + } +} + +// ------------------------------------------------------------------- + +float irt_systemGetXPMAngle(int gindex) +{ + return (irt_xminusCoord[gindex][0].x - irt_gunCoord[gindex][0].x) + / (irt_gunCoord[gindex][0].x - irt_xplusCoord[gindex][0].x); +} + +// ------------------------------------------------------------------- + +float irt_systemGetXPMDist(int gindex) +{ + return (irt_xminusCoord[gindex][0].x - irt_gunCoord[gindex][0].x) + + (irt_gunCoord[gindex][0].x - irt_xplusCoord[gindex][0].x); +} + +// ------------------------------------------------------------------- + +void irt_systemGetXPM(int gindex, int pindex, float *x, float *y) +{ + switch (pindex) + { + case 0: + *x = irt_xminusCoord[gindex][0].x; + *y = irt_xminusCoord[gindex][0].y; + break; + + case 1: + *x = irt_xplusCoord[gindex][0].x; + *y = irt_xplusCoord[gindex][0].y; + break; + } + + //irt_systemScaleCoords(gindex, localx, localy, x, y); +} + +// ------------------------------------------------------------------- + +int irt_systemIsPlayerOffscreen(int gindex) +{ + return int_offscreenFlag[gindex]; +} + +// ------------------------------------------------------------------- + +void irt_systemGetProjectedCoords(int gindex, float *x, float *y, int markDirty) +{ + float adiff[2], dist[3], vel[2]; + float avel, accel; + float localx, localy, xv, yv; + IrCoordType c1, c2; + int i; + + // - if this gun data has been given out to the game previously, we + // will return null (-1, -1) data. + + if (irt_dirtyFlag[gindex]) + { + *x = *y = -1; + return; + } + + adiff[0] = pw_angle_between(irt_gunCoord[gindex][3].x, irt_gunCoord[gindex][3].y + , irt_gunCoord[gindex][2].x, irt_gunCoord[gindex][2].y + , irt_gunCoord[gindex][1].x, irt_gunCoord[gindex][1].y); + + adiff[1] = pw_angle_between(irt_gunCoord[gindex][2].x, irt_gunCoord[gindex][2].y + , irt_gunCoord[gindex][1].x, irt_gunCoord[gindex][1].y + , irt_gunCoord[gindex][0].x, irt_gunCoord[gindex][0].y); + + avel = adiff[1] - adiff[0]; + + c1.x = irt_gunCoord[gindex][3].x; c1.y = irt_gunCoord[gindex][3].y; + c2.x = irt_gunCoord[gindex][2].x; c2.y = irt_gunCoord[gindex][2].y; + dist[0] = irt_getDistance(c1, c2); + + c1.x = irt_gunCoord[gindex][2].x; c1.y = irt_gunCoord[gindex][2].y; + c2.x = irt_gunCoord[gindex][1].x; c2.y = irt_gunCoord[gindex][1].y; + dist[1] = irt_getDistance(c1, c2); + + c1.x = irt_gunCoord[gindex][1].x; c1.y = irt_gunCoord[gindex][1].y; + c2.x = irt_gunCoord[gindex][0].x; c2.y = irt_gunCoord[gindex][0].y; + dist[2] = irt_getDistance(c1, c2); + + vel[0] = dist[1] - dist[0]; + vel[1] = dist[2] - dist[1]; + + accel = vel[1] - vel[0]; + + xv = irt_gunCoord[gindex][0].x - irt_gunCoord[gindex][3].x; + yv = irt_gunCoord[gindex][0].y - irt_gunCoord[gindex][3].y; + + xv *= 0.5; + yv *= 0.5; + + if (accel < 0) + { + xv *= 0.5; + yv *= 0.5; + } + + if (avel > 10.0) + { + xv = yv = 0.0; + } + + localx = irt_gunCoord[gindex][0].x + xv; + localy = irt_gunCoord[gindex][0].y + yv; + + // - if this projected coordinate is off the screen, we will go with + // the unprojected version! + + if ((localx < 0) || (localx > 800) || (localy < 0) || (localy > 600)) + { + *x = irt_gunCoord[gindex][0].x; + *y = irt_gunCoord[gindex][0].y; + } + else + { + *x = localx; + *y = localy; + } + + // - if we were asked to do so, mark this gun data as being + // used. + + if (markDirty) + irt_dirtyFlag[gindex] = 1; + + //irt_systemScaleCoords(gindex, localx, localy, x, y); +} + +// ------------------------------------------------------------------- +// - manually set the sceen calibration for the tracking system + +void irt_systemSetGunCalib(int pnum, int xoffset, int yoffset) +{ + irt_gunCalibXY[pnum][0] = xoffset; + irt_gunCalibXY[pnum][1] = yoffset; + + irt_gunCalibLeftXY[pnum][0] = irt_currCalibLeftXY[(pnum * 2) + 0]; + irt_gunCalibLeftXY[pnum][1] = irt_currCalibLeftXY[(pnum * 2) + 1]; + + irt_gunCalibRightXY[pnum][0] = irt_currCalibRightXY[(pnum * 2) + 0]; + irt_gunCalibRightXY[pnum][1] = irt_currCalibRightXY[(pnum * 2) + 1]; +} + +// ------------------------------------------------------------------- + +void irt_systemGetGunCalib(int pnum, int *xoffset, int *yoffset) +{ + *xoffset = irt_gunCalibXY[pnum][0]; + *yoffset = irt_gunCalibXY[pnum][1]; +} + +// ------------------------------------------------------------------- +// - perform a calibration using the latest available homography data + +void irt_systemGunCalib(int gindex) +{ + int i, xoffset, yoffset; + IrCalibType *cal, *c; + float angle, dist, adiff, distdiff; + + irt_cal_gun(gindex, &xoffset, &yoffset); + + irt_systemSetGunCalib(gindex, xoffset, yoffset); + + return; // <- no position-based calibration for now! + + irt_systemGetPlayerPosition(gindex, &angle, &dist); + + // - check to see if there is a matching calibration entry that + // is very close to this one. if there is, we will overwrite + // that entry + + cal = NULL; + for (i = 0; i < irt_calibListSize[gindex]; i++) + { + c = &irt_calibList[gindex][i]; + + adiff = c->angle - angle; + if (adiff < 0) adiff = -adiff; + + distdiff = c->dist - dist; + if (distdiff < 0) distdiff = -distdiff; + + if ((adiff <= 0.01) && (distdiff < 10.0)) + { + //printf("SAME:"); + cal = c; + break; + } + } + + // - if there is no closely matching calibration entry, add a new + // one. + + if (!cal) + { + // - add this calibration point to the list + + if (!irt_calibListSize[gindex]) + irt_calibList[gindex] = + (IrCalibType*)malloc(sizeof(IrCalibType) * (irt_calibListSize[gindex] + 1)); + else + irt_calibList[gindex] = + (IrCalibType*)realloc(irt_calibList[gindex], sizeof(IrCalibType) * (irt_calibListSize[gindex] + 1)); + + cal = &irt_calibList[gindex][irt_calibListSize[gindex]]; + + irt_calibListSize[gindex]++; + + //printf("NEW:"); + } + + cal->cx = xoffset; + cal->cy = yoffset; + cal->angle = angle; + cal->dist = dist; + + //printf("(%i, %i, %2.2f, %2.2f)\n" + // , cal->cx, cal->cy, cal->angle, cal->dist); + + //printf("(%i, %i)\n", irt_gunCalibXY[gindex][0], irt_gunCalibXY[gindex][1]); +} + +// ------------------------------------------------------------------- + +void irt_systemSaveCalibration(int gindex, char *filename) +{ + FILE *cfile; + int i; + + irt_systemSLog("irt_systemSaveCalibration\n"); + + if (!(cfile = fopen(filename, "wb"))) + { + irt_systemSLog("irt_systemSaveCalibration error: could not open %s\n", filename); + return; + } + + // - first, the number of entries... + + fwrite(&irt_calibListSize[gindex], sizeof(int), 1, cfile); + + // - followed by the entries + + for (i = 0; i < irt_calibListSize[gindex]; i++) + fwrite(&irt_calibList[gindex][i], sizeof(IrCalibType), 1, cfile); + + // - done! + + fclose(cfile); +} + +// ------------------------------------------------------------------- + +void irt_systemLoadCalibration(int gindex, char *filename) +{ + FILE *cfile; + int i, entries; + + if (!(cfile = fopen(filename, "rb"))) + { + irt_systemSLog("irt_systemLoadCalibration error: could not open %s\n", filename); + return; + } + + // - clear out the current calibration data + + if (irt_calibList[gindex]) + { + free(irt_calibList[gindex]); + irt_calibList[gindex] = NULL; + irt_calibListSize[gindex] = 0; + } + + // - read the number of entries + + fread(&entries, sizeof(int), 1, cfile); + + if (entries) + { + irt_calibListSize[gindex] = entries; + irt_calibList[gindex] = (IrCalibType*)malloc(sizeof(IrCalibType) * entries); + } + + for (i = 0; i < entries; i++) + { + fread(&irt_calibList[gindex][i], sizeof(IrCalibType), 1, cfile); + } + + fclose(cfile); +} + +// ------------------------------------------------------------------- + +void irt_systemClearCalibration(int gindex) +{ + if (irt_calibList[gindex]) + { + free(irt_calibList[gindex]); + irt_calibList[gindex] = NULL; + irt_calibListSize[gindex] = 0; + } +} + +// ------------------------------------------------------------------- + +void irt_systemGetPositionCal(int gindex, int *xoffset, int *yoffset) +{ + IrCalibType *cal; + float angle, dist, angleDiff, distDiff, ad, dd; + int i, nearIndex; + + // - get the player's estimated position + + irt_systemGetPlayerPosition(gindex, &angle, &dist); + + // - if we are currently using a calibration, make sure that + // we have moved far enough away to justify the use if a new + // calibration entry + + /* + if (irt_calibListIndex[gindex] != -1) + { + cal = &irt_calibList[gindex][irt_calibListIndex[gindex]]; + angleDiff = cal->angle - angle; + if (angleDiff < 0) angleDiff = -angleDiff; + + distDiff = cal->dist - dist; + if (distDiff < 0) distDiff = -distDiff; + + if ((angleDiff <= 0.01) && (distDiff <= 10.0)) + { + *xoffset = cal->cx; + *yoffset = cal->cy; + printf("using original (%i, %i)\n", cal->cx, cal->cy); + return; + } + } + */ + + // - search for the nearest calibration entry + + nearIndex = -1; + angleDiff = distDiff = 9999; + for (i = 0; i < irt_calibListSize[gindex]; i++) + { + cal = &irt_calibList[gindex][i]; + + ad = cal->angle - angle; + if (ad < 0) ad = -ad; + + dd = cal->dist - dist; + if (dd < 0) dd = -dd; + + if ((ad <= angleDiff) && (dd <= distDiff)) + { + angleDiff = ad; + distDiff = dd; + nearIndex = i; + } + } + + if (nearIndex == -1) + { + *xoffset = irt_gunCalibXY[gindex][0]; + *yoffset = irt_gunCalibXY[gindex][1]; + return; + } + + cal = &irt_calibList[gindex][nearIndex]; + *xoffset = cal->cx; + *yoffset = cal->cy; + + //printf("using new (%i, %i)\n", cal->cx, cal->cy); + // - store the list index of our current calibration entry + + irt_calibListIndex[gindex] = nearIndex; +} + +// ------------------------------------------------------------------- +// - set the x offset calibration. this calibration is used to scale +// the x values according to how the offset is at the top and the +// bottom of the screen + +void irt_systemSetYOffset(int gindex, int pindex) +{ + switch (pindex) + { + case 0: + irt_y0[gindex] = irt_gunCoord[gindex][0].y - 0; + break; + + case 1: + irt_y1[gindex] = irt_gunCoord[gindex][0].y - 600; + break; + } +} + +// ------------------------------------------------------------------- + +void irt_systemSetYOffsetVal(int gindex, int pindex, float val) +{ + switch (pindex) + { + case 0: + irt_y0[gindex] = val; + break; + + case 1: + irt_y1[gindex] = val; + break; + } +} + +// ------------------------------------------------------------------- + +float irt_systemGetYOffset(int gindex, int pindex) +{ + switch (pindex) + { + case 0: + return irt_y0[gindex]; + break; + + case 1: + return irt_y1[gindex]; + break; + } +} + +// ------------------------------------------------------------------- + +int irt_systemGetTrigger(int gindex) +{ + return serial_getSwitchCount(gindex, 0); +} + +//------------------------------------------------------------------------- +int irt_systemGetTriggerState(int gindex) +{ + return serial_getSwitchState(gindex, 0); +} + +// ------------------------------------------------------------------- + +int irt_systemGetPump(int gindex) +{ + return serial_getSwitchCount(gindex, 1); +} + +// ------------------------------------------------------------------- + +int irt_systemGetPumpRelease(int gindex) +{ + return serial_getSwitchCount(gindex, 2); +} + +// ------------------------------------------------------------------- + +void irt_systemGetGunStatus(int gindex, IrGunStatus *gun_stat) +{ + *gun_stat = serial_getGunStatus(gindex); +} + +// ------------------------------------------------------------------- + +void irt_systemClearGunStatus(int gindex) +{ + serial_clearGunStatus(gindex); +} + +// ------------------------------------------------------------------- + +int irt_dbgGetPointList(int gindex, float *fptr) +{ + memcpy(fptr, irt_dbgPoints[gindex], sizeof(float) * 2 * MAX_LEDS); + return irt_numPoints[gindex]; +} + +// ------------------------------------------------------------------- + +int irt_dbgGetGroupList(int gindex, float *fptr) +{ + memcpy(fptr, irt_dbgGroups[gindex], sizeof(float) * 2 * MAX_LEDS); + return irt_dbgNumGroups[gindex]; +} + +// ------------------------------------------------------------------- + +char *irt_systemGetVer(void) +{ + static char verStr[64]; + sprintf(verStr, "%02i.%02i.%02i" + , IRT_VERSION_MAJOR + , IRT_VERSION_MINOR + , IRT_VERSION_SUB ); + return verStr; +} + +// ------------------------------------------------------------------- + +float irt_getAverageDist(void) +{ + return irt_avgDist; +} + +// ------------------------------------------------------------------- + +int irt_getNumPoints(int gindex) +{ + return irt_numPoints[gindex]; +} + +// ------------------------------------------------------------------- + +IrPointType *irt_getPointNum(int gindex, int pnum) +{ + if ((pnum >= irt_numPoints[gindex]) || (pnum < 0)) + return NULL; + + return &irt_pointList[gindex][pnum]; +} + +// ------------------------------------------------------------------- + +void irt_getPointsFromCoords(int numCoords, IrCoordType *crdPtr, IrPointType *ptPtr, int gindex) +{ + int i, j, x, y, nIndex, nDist, newFriend, isNew, fIdx; + float dist, avgDist, minDist; + float avgFriendDist; + int avgFriendDistCount; + + // - initialize each point entry + + for (i = 0; i < numCoords; i++) + { + ptPtr[i].crd = crdPtr[i]; + ptPtr[i].neighbors = numCoords - 1; + + ptPtr[i].nDist = (float*)malloc(sizeof(float) * (numCoords - 1)); + memset(ptPtr[i].nDist, 0, sizeof(float) * (numCoords - 1)); + + ptPtr[i].nPtr = (int*)malloc(sizeof(int*) * (numCoords - 1)); + memset(ptPtr[i].nPtr, 0, sizeof(int*) * (numCoords - 1)); + } + + // - fill in the neighbor and neighbor distance data for each point + + avgDist = 0; + nDist = 0; + + for (i = 0; i < numCoords; i++) + { + nIndex = 0; + + for (j = 0; j < numCoords; j++) + { + if (i == j) + continue; + + // - TODO: store a table of distances, so we are not calculating redundant distances + + ptPtr[i].nPtr[nIndex] = j; + ptPtr[i].nDist[nIndex] = irt_getDistance(ptPtr[i].crd, ptPtr[j].crd); + + // - start out with no friends + + ptPtr[i].friends = 0; + ptPtr[i].fPtr = NULL; + ptPtr[i].groupNum = 0; + ptPtr[i].isNoise = 0; + ptPtr[i].dp[0] = 0.0; + ptPtr[i].dp[1] = 0.0; + + // - keep track of the average distance between points + + avgDist += ptPtr[i].nDist[nIndex]; + nDist++; + + nIndex++; + } + } + + avgDist /= nDist; + irt_avgDist = avgDist; + + avgFriendDist = 0; + avgFriendDistCount = 0; + + // - determine how many "friends" each of points have + + for (i = 0; i < numCoords; i++) + { + // - we will only consider distances that are a certain + // fraction of the overall average distance + + minDist = 60;//avgDist * IRT_AVG_DIST_THRESHOLD; + + // - check to see what the minimum distance is + + for (j = 0; j < numCoords; j++) + { + if (i == j) + continue; + + dist = irt_getDistance(ptPtr[i].crd, ptPtr[j].crd); + if (dist < minDist) + { + minDist = dist; + if (minDist < IRT_MIN_DIST_LOWEST) + minDist = IRT_MIN_DIST_LOWEST; + } + } + + // - count the number of "friend" points that are within + // a certain threshold of our minimum distance. + + for (j = 0; j < numCoords; j++) + { + if (i == j) + continue; + + dist = irt_getDistance(ptPtr[i].crd, ptPtr[j].crd); + + if (dist <= (minDist * IRT_MIN_DIST_THRESHOLD)) + { + ptPtr[i].friends++; + + if (!ptPtr[i].fPtr) + ptPtr[i].fPtr = (int*)malloc(sizeof(int) * ptPtr[i].friends); + else + ptPtr[i].fPtr = (int*)realloc(ptPtr[i].fPtr, sizeof(int) * ptPtr[i].friends); + + ptPtr[i].fPtr[ptPtr[i].friends - 1] = j; + + avgFriendDist += dist; + avgFriendDistCount++; + } + } + } + + avgFriendDist /= avgFriendDistCount; + if (irt_avgFriendDist[gindex] == -1) + irt_avgFriendDist[gindex] = 0; + else + irt_avgFriendDist[gindex] = avgFriendDist; + + // - for each point, make sure he is friends with all his friends friends + + for (i = 0; i < numCoords; i++) + { + // - for each friend.. + + for (j = 0; j < ptPtr[i].friends; j++) + { + fIdx = ptPtr[i].fPtr[j]; + + // - for each friend's friend... + + for (x = 0; x < ptPtr[fIdx].friends; x++) + { + // - grab an index... + + newFriend = ptPtr[fIdx].fPtr[x]; + + if (newFriend == i) + continue; + + // - check to see if the point lists this guy as a friend... + + isNew = 1; + for (y = 0; y < ptPtr[i].friends; y++) + { + if (ptPtr[i].fPtr[y] == newFriend) + isNew = 0; + } + + // - if this is a new friend, let's add him to our list + + if (isNew) + { + ptPtr[i].fPtr = (int*)realloc(ptPtr[i].fPtr, sizeof(int) * (ptPtr[i].friends + 1)); + ptPtr[i].fPtr[ptPtr[i].friends] = newFriend; + ptPtr[i].friends++; + } + } + } + } + + // TODO: there needs to be a dedicated friends-assignment function + /* + for (i = 0; i < numCoords; i++) + { + // - for each friend.. + + for (j = 0; j < irt_pointList[i].friends; j++) + { + fIdx = irt_pointList[i].fPtr[j]; + + // - for each friend's friend... + + for (x = 0; x < irt_pointList[fIdx].friends; x++) + { + // - grab an index... + + newFriend = irt_pointList[fIdx].fPtr[x]; + + if (newFriend == i) + continue; + + // - check to see if the point lists this guy as a friend... + + isNew = 1; + for (y = 0; y < irt_pointList[i].friends; y++) + { + if (irt_pointList[i].fPtr[y] == newFriend) + isNew = 0; + } + + // - if this is a new friend, let's add him to our list + + if (isNew) + { + irt_pointList[i].fPtr = (int*)realloc(irt_pointList[i].fPtr, sizeof(int) * (irt_pointList[i].friends + 1)); + irt_pointList[i].fPtr[irt_pointList[i].friends] = newFriend; + irt_pointList[i].friends++; + } + } + } + } + */ + return; +} + +// ------------------------------------------------------------------- + +void irt_destroyPointList(int gindex) +{ + int numCoords, i; + + if (!irt_pointList[gindex]) + return; + + // - get the total number of points from the reading of how many neighbors the + // first point has + + numCoords = irt_pointList[gindex][0].neighbors + 1; + + // - free up the alloc'd neighbor and neighbor distance lists + + for (i = 0; i < numCoords; i++) + { + free(irt_pointList[gindex][i].nDist); + free(irt_pointList[gindex][i].nPtr); + free(irt_pointList[gindex][i].fPtr); + } + + // - finally, free the alloc'd points list + + free(irt_pointList[gindex]); + irt_pointList[gindex] = NULL; +} + +// ------------------------------------------------------------------- + +void irt_discriminateFriends(int gindex) +{ + IrPointType *p, *p2; + IrCoordType c1, c2; + int i, j, k, fidx, curGroup; + float *groupDistMinMax = NULL; + float dist; + + if (!irt_numGroups[gindex] || !irt_numPoints[gindex]) + return; + + groupDistMinMax = (float*)malloc(sizeof(float) * 2 * irt_numGroups[gindex]); + + for (i = 0; i < irt_numGroups[gindex]; i++) + { + groupDistMinMax[(i * 2) + 0] = 999.0; // min + groupDistMinMax[(i * 2) + 1] = 0.0; // max + } + + // - look through each point in the list, storing the min and max + // distances for each group id that is encountered + + p = irt_pointList[gindex]; + for (i = 0; i < irt_numPoints[gindex]; i++) + { + curGroup = p->groupNum; + + c1.x = p->crd.x; + c1.y = p->crd.y; + + for (j = 0; j < p->friends; j++) + { + fidx = p->fPtr[j]; + p2 = &((IrPointType*)irt_pointList[gindex])[fidx]; + + c2.x = p2->crd.x; + c2.y = p2->crd.y; + dist = irt_getDistance(c1, c2); + + // - min distance + + if (dist < groupDistMinMax[(curGroup * 2) + 0]) + groupDistMinMax[(curGroup * 2) + 0] = dist; + + // - max distance + + if (dist > groupDistMinMax[(curGroup * 2) + 1]) + groupDistMinMax[(curGroup * 2) + 1] = dist; + } + + p++; + } + + // - look through each point in the list again, breaking any + // friendships that occur over a certain distance threshold + + p = irt_pointList[gindex]; + for (i = 0; i < irt_numPoints[gindex]; i++) + { + curGroup = p->groupNum; + + // - does this group have a big differerence between min/max + // friendship distances? if not, move on to the next point. + + if (!((groupDistMinMax[(curGroup * 2) + 0] * 2) + < groupDistMinMax[(curGroup * 2) + 1])) + continue; + + c1.x = p->crd.x; + c1.y = p->crd.y; + + for (j = 0; j < p->friends; j++) + { + fidx = p->fPtr[j]; + p2 = &((IrPointType*)irt_pointList[gindex])[fidx]; + + c2.x = p2->crd.x; + c2.y = p2->crd.y; + dist = irt_getDistance(c1, c2); + + // - if this friendship occurs over too great a distance, + // we will break it. a -1 friend index entry means + // "DELETE THIS FRIEND!" + + if (dist > (groupDistMinMax[(curGroup * 2) + 0] * 2)) + { + // - "remove" the friendship by placing a -1 index + // where the friend was in both points + + p->fPtr[j] = -1; + + for (k = 0; k < p2->friends; k++) + if (p2->fPtr[k] == i) + p2->fPtr[k] = -1; + + // - remove the -1 index entry in the first point... + + for (k = 0; k < (p->friends - 1); k++) + { + if (p->fPtr[k] == -1) + { + p->fPtr[k] = p->fPtr[k + 1]; + p->fPtr[k + 1] = -1; + } + } + + p->friends--; + + // - ... and remove the -1 entry in the second point + + for (k = 0; k < (p2->friends -1); k++) + { + if (p2->fPtr[k] == -1) + { + p2->fPtr[k] = p2->fPtr[k + 1]; + p2->fPtr[k + 1] = -1; + } + } + + p2->friends--; + + // - start from scratch while processing this + // point's friends list + + j = 0; + } + } + + p++; + } + + + free(groupDistMinMax); + + // MANNY +} + +/* +IrPointType *irt_pointList[SERIAL_MAX_PLAYERS]; +IrPointGroupType *irt_groupList[SERIAL_MAX_PLAYERS]; +IrPointGroupType *prevGroupList[SERIAL_MAX_PLAYERS]; + +IrCalibType *irt_calibList[SERIAL_MAX_PLAYERS]; +int irt_calibListSize[SERIAL_MAX_PLAYERS]; +int irt_calibListIndex[SERIAL_MAX_PLAYERS]; + +int irt_numPoints[SERIAL_MAX_PLAYERS]; +*/ + +// ------------------------------------------------------------------- + +void irt_getGroupsFromPoints(int gun_index) +{ + int i, j, gIndex, fIdx, lowestGroup; + + // - start with a clean group list + + if (irt_groupList[gun_index]) + free(irt_groupList[gun_index]); + + irt_numGroups[gun_index] = 0; + + gIndex = 0; + + for (i = 0; i < irt_numPoints[gun_index]; i++) + { + // - if this point doesn't belong to a group, and it has no + // friends, assign it to a new group + + if (!irt_pointList[gun_index][i].groupNum && !irt_pointList[gun_index][i].friends) + { + gIndex++; + irt_pointList[gun_index][i].groupNum = gIndex; + } + else + { + // - if the point is unassigned, and we have a friend, we + // will join that friend's group + + fIdx = irt_pointList[gun_index][i].fPtr[0]; + irt_pointList[gun_index][i].groupNum = irt_pointList[gun_index][fIdx].groupNum; + + if (!irt_pointList[gun_index][i].groupNum) + { + gIndex++; + irt_pointList[gun_index][i].groupNum = gIndex; + } + } + } + + for (i = 0; i < irt_numPoints[gun_index]; i++) + { + lowestGroup = 999; + for (j = 0; j < irt_pointList[gun_index][i].friends; j++) + { + fIdx = irt_pointList[gun_index][i].fPtr[j]; + if (irt_pointList[gun_index][fIdx].groupNum < lowestGroup) + lowestGroup = irt_pointList[gun_index][fIdx].groupNum; + } + + // - make sure that all of this point's friends are + // assigned to his group + + for (j = 0; j < irt_pointList[gun_index][i].friends; j++) + { + fIdx = irt_pointList[gun_index][i].fPtr[j]; + irt_pointList[gun_index][fIdx].groupNum = irt_pointList[gun_index][i].groupNum; + } + } + + irt_numGroups[gun_index] = gIndex + 1; + irt_groupList[gun_index] = (IrPointGroupType*)malloc(sizeof(IrPointGroupType) * irt_numGroups[gun_index]); + + for (i = 0; i < irt_numGroups[gun_index]; i++) + { + // - an id is assigned to a group once it has been positively + // identified + + irt_groupList[gun_index][i].id = -1;//i; + //irt_groupList[i].fPtr = NULL; + + // - count the number of friends in this group. check each point + // to see if it belongs to our group. + + irt_groupList[gun_index][i].friends = 0; + irt_groupList[gun_index][i].x = 0; + irt_groupList[gun_index][i].y = 0; + + for (j = 0; j < irt_numPoints[gun_index]; j++) + { + if (irt_pointList[gun_index][j].groupNum == i) + { + irt_groupList[gun_index][i].friends++; + irt_groupList[gun_index][i].x += irt_pointList[gun_index][j].crd.x; + irt_groupList[gun_index][i].y += irt_pointList[gun_index][j].crd.y; + } + } + + // - average out the accumulated x/y value + + irt_groupList[gun_index][i].x /= irt_groupList[gun_index][i].friends; + irt_groupList[gun_index][i].y /= irt_groupList[gun_index][i].friends; + + if ((irt_groupList[gun_index][i].x < IR_GROUP_LEFT_EDGE) + || (irt_groupList[gun_index][i].x > IR_GROUP_RIGHT_EDGE) + || (irt_groupList[gun_index][i].y < IR_GROUP_TOP_EDGE) + || (irt_groupList[gun_index][i].y > IR_GROUP_BOTTOM_EDGE)) + irt_groupList[gun_index][i].near_edge = 1; + else + irt_groupList[gun_index][i].near_edge = 0; + + irt_groupList[gun_index][i].rule = -1; + } +} + +// ------------------------------------------------------------------- + +int irt_getNumGroups(int gindex) +{ + return irt_numGroups[gindex]; +} + +// ------------------------------------------------------------------- + +IrPointGroupType* irt_getGroupNum(int gindex, int gnum) +{ + if ((gnum < 0) || (gnum >= irt_numGroups[gindex])) + return NULL; + + return &irt_groupList[gindex][gnum]; +} + +// ------------------------------------------------------------------- + +IrPointGroupType *irt_getGroupById(int gindex, int idnum) +{ + int i; + + for (i = 0; i < irt_numGroups[gindex]; i++) + { + if (irt_groupList[gindex][i].id == idnum) + return &irt_groupList[gindex][i]; + } + + return NULL; +} + +// ------------------------------------------------------------------- + +int irt_groupAssign(int gindex, int oldnum, int newnum) +{ + int i; + + for (i = 0; i < irt_numGroups[gindex]; i++) + { + if (irt_groupList[gindex][i].id == oldnum) + { + irt_groupList[gindex][i].id = newnum; + return 1; + } + } + + return 0; +} + +// ------------------------------------------------------------------- + +void irt_destroyGroupList(int gindex) +{ + int i; + + if (!irt_groupList[gindex]) + return; + + // - before we delete our current group list, we want to save + // a copy of it + + if (prevGroupList[gindex]) + { + free(prevGroupList[gindex]); + prevGroupList[gindex] = NULL; + } + + prevGroupList[gindex] = (IrPointGroupType*)malloc(sizeof(IrPointGroupType) * irt_numGroups[gindex]); + memset(prevGroupList[gindex], 0, sizeof(IrPointGroupType) * irt_numGroups[gindex]); + + for (i = 0; i < irt_numGroups[gindex]; i++) + { + prevGroupList[gindex][i].id = irt_groupList[gindex][i].id; + prevGroupList[gindex][i].friends = irt_groupList[gindex][i].friends; + prevGroupList[gindex][i].x = irt_groupList[gindex][i].x; + prevGroupList[gindex][i].y = irt_groupList[gindex][i].y; + } + + irt_numPrevGroups[gindex] = irt_numGroups[gindex]; + + // - now we can delete our current group list + + free(irt_groupList[gindex]); + irt_groupList[gindex] = NULL; + + irt_numGroups[gindex] = 0; +} + +// ------------------------------------------------------------------- +// - update the table entry for a given group + +void irt_groupTableUpdate(int gindex, IrPointGroupType *g) +{ + int i; + + if (!g) + return; + + for (i = 0; i < IR_HIST_TABLE_SIZE; i++) + { + if (g->id == i) + { + groupTable[gindex][i].x = g->x; + groupTable[gindex][i].y = g->y; + groupTable[gindex][i].age = 0; + groupTable[gindex][i].friends = g->friends; + } + } +} + +// ------------------------------------------------------------------- +// - advance the age of each entry in the group table + +void irt_groupTableTick(void) +{ + int i, j; + + for (i = 0; i < IR_HIST_TABLE_SIZE; i++) + { + for (j = 0; j < SERIAL_MAX_PLAYERS; j++) + { + groupTable[j][i].age++; + } + } +} + +/* +// ------------------------------------------------------------------- +// - if there is a group that has been previously been identified in +// the previous frame, but there is a complete absence of any +// group in the current frame, copy the history data into the +// current frame + +void irt_historyAdd(int gindex) +{ + float x, y; + int i, j; + + for (i = 0; i < 10; i++) + { + // - if there is no group of this id in the current frame, + // but this value was positively identified in the previous + // frame, we will add it. + + if ((!irt_getGroupById(gindex, i)) && (groupTable[gindex][i].age >= 2)) + { + x = groupTable[gindex][i].x; + y = groupTable[gindex][i].y; + + if ((x >= IR_GROUP_LEFT_EDGE) && (x <= IR_GROUP_RIGHT_EDGE) + && (y >= IR_GROUP_TOP_EDGE) && (y <= IR_GROUP_BOTTOM_EDGE)) + { + for (j = 0; j < irt_numGroups[gindex]; j++) + { + if (irt_groupList[gindex][j].id != -1) + continue; + } + } + } + } +} +*/ + +// ------------------------------------------------------------------- +// - reconcile the current group list with the previous group list +// +// if the markFakes flag is set, groups identified in this process +// will be flagged as being "fake" which will direct the system to +// not use those groups for calculating gun data + +void irt_groupHistoryAssign(int gindex, int markFakes) +{ + float dist, minDist; + IrCoordType c1, c2; + int i, j; + int minIndex; + + // - the algorithm needs to work like this: for each element in the + // history table, check the distance between each current group. + // the group that is the nearest (within a certain threshold value) + // will be awarded the id. + /* + for (i = 0; i < IR_HIST_TABLE_SIZE; i++) + { + c1.x = groupTable[i].x; + c1.y = groupTable[i].y; + + minDist = 999.0; + minIndex = -1; + + for (j = 0; j < irt_numGroups; j++) + { + c2.x = irt_groupList[j].x; + c2.y = irt_groupList[j].y; + + dist = irt_getDistance(c1, c2); + + if ((dist < minDist) + && (irt_groupList[i].friends == groupTable[j].friends) + ) + { + minDist = dist; + minIndex = j; + } + } + + if ((minIndex != -1) && (minDist < 5.0)) + { + irt_groupList[minIndex].id = i; + irt_groupList[minIndex].friends = groupTable[i].friends; + + if (markFakes) + irt_groupList[minIndex].faked = 1; + + irt_groupTableUpdate(gindex, &irt_groupList[minIndex]); + } + } + */ + + for (i = 0; i < irt_numGroups[gindex]; i++) + { + // - we are only interested in unassigned groups + + if (irt_groupList[gindex][i].id != -1) + continue; + + // - don't assign groups that are too close to the edge + + if (irt_groupList[gindex][i].near_edge) + continue; + + c1.x = irt_groupList[gindex][i].x; + c1.y = irt_groupList[gindex][i].y; + + minDist = 999.0; + minIndex = -1; + for (j = 0; j < IR_HIST_TABLE_SIZE; j++) + { + c2.x = groupTable[gindex][j].x; + c2.y = groupTable[gindex][j].y; + + dist = irt_getDistance(c1, c2); + + // TODO: there needs to be a better way to balance the + // desire to match a group by distance, and the desire + // to avoid a group that is too old. + + //dist *= 1.0 + (0.01 * groupTable[gindex][j].age); + dist *= 1.0 + (0.1 * groupTable[gindex][j].age); + + if ((dist < minDist) + && (irt_groupList[gindex][i].friends == groupTable[gindex][j].friends)) + { + minDist = dist; + minIndex = j; + } + } + + // TODO: we need to wait until all of the groups have had a + // chance to measure distances before we do any assignments! + + if ((minIndex != -1) && (minDist < 50.0))//100.0)) + { + if (!irt_getGroupById(gindex, minIndex)) + { + //printf("%i : %2.2f (%2.2f, %2.2f) (%2.2f, %2.2f)\n" + //, minIndex, dist, c1.x, c1.y, c2.x, c2.y); + irt_groupList[gindex][i].id = minIndex; + irt_groupList[gindex][i].friends = groupTable[gindex][minIndex].friends; + + if (markFakes) + irt_groupList[gindex][i].faked = 1; + + irt_groupTableUpdate(gindex, &irt_groupList[gindex][i]); + } + } + } +} + +// ------------------------------------------------------------------- + +void irt_groupHistoryCompensate(int gindex) +{ + float dist, minDist; + IrCoordType c1, c2; + int i, j, minIndex; + + for (i = 0; i < irt_numGroups[gindex]; i++) + { + // - don't assign groups that are too close to the edge + + if (irt_groupList[gindex][i].near_edge) + continue; + + c1.x = irt_groupList[gindex][i].x; + c1.y = irt_groupList[gindex][i].y; + + minDist = 999.9; + minIndex = -1; + for (j = 0; j < IR_HIST_TABLE_SIZE; j++) + { + //if (groupTable[gindex][j].friends != 3) + // continue; + + //if (groupTable[gindex][j].age > 1) + // continue; + + c2.x = groupTable[gindex][j].x; + c2.y = groupTable[gindex][j].y; + + dist = irt_getDistance(c1, c2); + + if (dist < minDist) + { + minDist = dist; + minIndex = j; + } + } + + //printf("%i : %2.2f\n", minIndex, minDist); + /* + if ((minIndex != -1) && (minDist < 10.0)) + { + //printf("corrected: %i from %i\n", i, minIndex); + irt_groupList[gindex][i].friends = groupTable[gindex][minIndex].friends; + irt_groupList[gindex][i].id = minIndex; + } + */ + + if ((minIndex != -1) && (minDist < 5.0)) + if (groupTable[gindex][minIndex].friends > irt_groupList[gindex][i].friends) + { + irt_groupList[gindex][i].friends = groupTable[gindex][minIndex].friends; + irt_groupList[gindex][i].id = minIndex; + irt_groupTableUpdate(gindex, &irt_groupList[gindex][i]); + } + } +} + +// ------------------------------------------------------------------- +// - try to fill in for any missing groups by interpolating existing +// data +// +// note: we are currently trying to fill our AAAB pattern data +// +// 0 1 +// +// 2 3 + +void irt_groupInterpolateBlanks(int gindex) +{ + #define IB_ITABLE_SIZE 16//25 + #define IB_NUM_GROUPS 20//12 + + IrPointGroupType *glist[IB_NUM_GROUPS]; + int i, numg, count[IB_NUM_GROUPS], rule[IB_NUM_GROUPS]; + float x, y, xacc[IB_NUM_GROUPS], yacc[IB_NUM_GROUPS]; + float angle, dist, aoffset; + + // - need, have1, have2, angle + // + // rotate 'have1' 'angle' degrees by 'have2' to get 'need' + + int itable[4 * IB_ITABLE_SIZE] = { + // - SHADOW GROUP #5 + 10, 1, 0, -90, + 11, 0, 1, 90, + // - SHADOW GROUP #6 + 11, 4, 1, -90, + 12, 1, 4, 90, + // - SHADOW GROUP #7 + 12, 6, 4, -90, + 13, 4, 6, 90, + // - SHADOW GROUP #8 + 13, 8, 6, -90, + 14, 6, 8, 90, + // - SHADOW GROUP #9 + 15, 3, 2, 90, + 16, 2, 3, -90, + // - SHADOW GROUP #10 + 16, 5, 3, 90, + 17, 3, 5, -90, + // - SHADOW GROUP #11 + 17, 7, 5, 90, + 18, 5, 7, -90, + // - SHADOW GROUP #12 + 18, 9, 7, 90, + 19, 7, 9, -90, + }; + + numg = 0; + for (i = 0; i < IB_NUM_GROUPS; i++) + { + if (glist[i] = irt_getGroupById(gindex, i)) + numg++; + + count[i] = 0; + rule[i] = -1; + xacc[i] = 0; + yacc[i] = 0; + } + + //irt_systemGetPlayerPosition(gindex, &angle, &dist); + //angle = irt_systemGetXPMAngle(gindex); + //aoffset = (1.0 - angle) * -10.0; + + //if (gindex == 0) + // printf("aoffset = %2.2f\n", aoffset); + aoffset = 0.0; + + // - loop through every element of the interpolation table + + for (i = 0; i < IB_ITABLE_SIZE; i++) + { + // - if we don't have this element... + + if (!glist[itable[(i * 4) + 0]]) + { + // - check to see if we have the two required elements to perform + // the interpolation + + if (glist[itable[(i * 4) + 1]] && glist[itable[(i * 4) + 2]]) + { + pw_rotatePoint(glist[itable[(i * 4) + 1]]->x, glist[itable[(i * 4) + 1]]->y + , glist[itable[(i * 4) + 2]]->x, glist[itable[(i * 4) + 2]]->y, itable[(i * 4) + 3] + aoffset, &x, &y); + + xacc[itable[(i * 4) + 0]] += x; + yacc[itable[(i * 4) + 0]] += y; + count[itable[(i * 4) + 0]]++; + rule[itable[(i * 4) + 0]] = i; + } + } + } + + // - for each of the 4 points in the pattern, if we interpolated + // a point, add the group to the list. + + for (i = 0; i < IB_NUM_GROUPS; i++) + { + if (count[i]) + { + xacc[i] /= count[i]; + yacc[i] /= count[i]; + + // - add this imaginary group to our list + + // TODO: we need a dedicated "add group" function + + irt_numGroups[gindex]++; + irt_groupList[gindex] + = (IrPointGroupType*)realloc(irt_groupList[gindex], sizeof(IrPointGroupType) * irt_numGroups[gindex]); + irt_groupList[gindex][irt_numGroups[gindex] - 1].x = xacc[i]; + irt_groupList[gindex][irt_numGroups[gindex] - 1].y = yacc[i]; + irt_groupList[gindex][irt_numGroups[gindex] - 1].id = i; + irt_groupList[gindex][irt_numGroups[gindex] - 1].friends = 1; + irt_groupList[gindex][irt_numGroups[gindex] - 1].faked = 1; + irt_groupList[gindex][irt_numGroups[gindex] - 1].rule = rule[i]; + } + } +} + +// ------------------------------------------------------------------- +// - return the average x/y value for all of the points in a +// specific group + +int irt_getGroupData(int gindex, int group, float *x, float *y) +{ + int i, numPoints; + + *x = 0; + *y = 0; + + numPoints = 0; + + if (irt_numGroups[gindex] == 0) + return 0; + + for (i = 0; i < irt_numPoints[gindex]; i++) + { + if (irt_pointList[gindex][i].groupNum == group) + { + *x += irt_pointList[gindex][i].crd.x; + *y += irt_pointList[gindex][i].crd.y; + numPoints++; + } + } + + if (numPoints == 0) + return 0; + + *x /= numPoints; + *y /= numPoints; + + return numPoints; +} + +// ------------------------------------------------------------------- + +inline float irt_getDistance(IrCoordType c1, IrCoordType c2) +{ + return sqrt(pow(c1.x - c2.x, 2) + pow(c1.y - c2.y, 2)); +} + +// ------------------------------------------------------------------- + +void test_createCoordsFromLeds(int gindex) +{ + IrCoordType *crdPtr = NULL; + unsigned char buf[64]; + int i, nCoords; + int acc_x, acc_y, s; + + // - read in the latest led data set + + nCoords = serial_get_led_data(gindex, ldata[gindex]); + + // - if there were no reported leds, do nothing + + if (!nCoords) + { + irt_numPoints[gindex] = 0; + irt_avgFriendDist[gindex] = 0; + return; + } + + // - alternately, if there are less than three points on screen, + // we will also signal that we are indeed not pointing at the + // screen (this means: set irt_avgFriendDist = -1 to suppress the + // "too close" message) + + if (nCoords < 3) + irt_avgFriendDist[gindex] = -1; + + // - allocate space for our coordinate set + + crdPtr = (IrCoordType*)malloc(sizeof(IrCoordType) * nCoords); + + // - read in the coordinate data from each of the leds + + for (i = 0; i < nCoords; i++) + { + // - scale the point data from 640x480 to 800x600 + + crdPtr[i].x = ldata[gindex][i].x * (800.0 / 640.0); + crdPtr[i].y = ldata[gindex][i].y * (600.0 / 480.0); + crdPtr[i].s = ldata[gindex][i].s; + } + + irt_pointList[gindex] = (IrPointType*)malloc(sizeof(IrPointType) * nCoords); + memset(irt_pointList[gindex], 0, sizeof(IrPointType) * nCoords); + + irt_numPoints[gindex] = nCoords; + + // - generate the point list from the coordnates + + irt_getPointsFromCoords(nCoords, crdPtr, irt_pointList[gindex], gindex); + + // - break up "friendships" between points based on distance + + // irt_discriminatePoints(gindex); + // irt_discriminateFriends(gindex); + + // - create a list of groups from the point list + + irt_getGroupsFromPoints(gindex); + + // - use history to "correct" the number of points that each group + // has + + //irt_groupHistoryCompensate(gindex); + + // - get rid of the coordinate and point list data + + free(crdPtr); +} + +// ------------------------------------------------------------------- +// - scan for a specific linear pattern of groups +// +// 0 1 2 + +int irt_scan3Pattern(int gindex, int *psearch, int *pid) +{ + int i[3], j; + int ismatch; + int numGroups, numleds[3]; + float x[3], y[3]; + IrPointGroupType *g, *glist[3]; + IrCoordType crd[3], midpoint; + float dev, totalDev, avgDist; + IrCoordType c; + IrSPCType spc[IRT_MAX_SP_CANDIDATES]; + int numSPC = 0, bestSPC; + float bestScore; + + // - make sure we have at least three groups to scan + + numGroups = irt_getNumGroups(gindex); + if (numGroups < 3) + return 0; + + for (i[0] = 0; i[0] < numGroups; i[0]++) + { + if (irt_getGroupData(gindex, i[0], &x[0], &y[0]) != psearch[0]) + continue; + + for (i[1] = 0; i[1] < numGroups; i[1]++) + { + if (irt_getGroupData(gindex, i[1], &x[0], &y[0]) != psearch[1]) + continue; + + for (i[2] = 0; i[2] < numGroups; i[2]++) + { + if (irt_getGroupData(gindex, i[2], &x[0], &y[0]) != psearch[2]) + continue; + + // - make sure there are no duplicates + + if ((i[0] == i[1]) || (i[0] == i[2]) || (i[1] == i[2])) + continue; + + // - read the number of leds in each group + + for (j = 0; j < 3; j++) + { + numleds[j] = irt_getGroupData(gindex, i[j], &x[j], &y[j]); + glist[j] = irt_getGroupNum(gindex, i[j]); + crd[j].x = x[j]; + crd[j].y = y[j]; + crd[j].s = 0; + } + + // - check to see if the number of leds match those in + // our pattern + + ismatch = 1; + for (j = 0; j < 3; j++) + if (numleds[j] != psearch[j]) + ismatch = 0; + + if (!ismatch) + continue; + + // - check to see if any of the groups have been positively + // identified as a group other than what we are testing them + // against. (for example, if a particular group is #7, and we + // are testing to see if it might be #3) + + ismatch = 1; + for (j = 0; j < 3; j++) + { + g = irt_getGroupNum(gindex, i[j]); + + // - if the group has been assigned, and it is not what + // we're testing for + + if ((g->id != -1) && (g->id != pid[j])) + ismatch = 0; + } + + if (!ismatch) + continue; + + totalDev = 0; + + // - find the midpoint between groups 0 and 2 + + midpoint.x = crd[0].x + ((crd[2].x - crd[0].x) / 2); + midpoint.y = crd[0].y + ((crd[2].y - crd[0].y) / 2); + + // - mark the deviation between the calculated midpoint + // and what is supposed to be our midpoint. + + totalDev += irt_getDistance(midpoint, crd[1]); + + if (totalDev > 10)//5) + continue; + + if (numSPC >= IRT_MAX_SP_CANDIDATES) + continue; + + totalDev = 0; + for (j = 0; j < 3; j++) + { + // - if the group in question has not been seen on camera + // for more than five frames, we won't consider it + + if (groupTable[gindex][pid[j]].age > 5) + continue; + + c.x = groupTable[gindex][pid[j]].x; + c.y = groupTable[gindex][pid[j]].y; + totalDev += irt_getDistance(crd[j], c); + } + + if (totalDev > 100) + continue; + + // - mark the deviation of the pattern from an equidistant + // line of three. + + avgDist = (irt_getDistance(crd[0], crd[1]) + + irt_getDistance(crd[1], crd[2])) / 2; + + dev = avgDist - irt_getDistance(crd[0], crd[1]); + if (dev < 0) dev = -dev; + totalDev += dev; + + dev = avgDist - irt_getDistance(crd[1], crd[2]); + if (dev < 0) dev = -dev; + totalDev += dev; + + // - the "score" in this case is the total deviation from + // the ideal pattern. the lowest score will be the best + + spc[numSPC].score = totalDev; + + // - store the ids of this candidate + + for (j = 0; j < 3; j++) + spc[numSPC].id[j] = i[j]; + + numSPC++; + + } // i[2] + } // i[1] + } // i[0] + + if (!numSPC) + return 0; + + // - now, see which of our candidates had the lowest score + + bestSPC = -1; + bestScore = 999; + for (j = 0; j < numSPC; j++) + { + if (spc[j].score < bestScore) + { + bestScore = spc[j].score; + bestSPC = j; + } + } + + if (bestSPC != -1) + { + for (j = 0; j < 3; j++) + { + g = irt_getGroupNum(gindex, spc[bestSPC].id[j]); + g->id = pid[j]; + g->faked = 0; + g->rule = -1; + + irt_groupTableUpdate(gindex, g); + } + + // - report that we've found our group! + + return 1; + } + + // - hang our heads in shame and report faliure. we couldn't find what + // we were looking for + + return 0; +} + +// ------------------------------------------------------------------- +// - scan for a specific square group pattern. +// +// the first input is an array of the group population that we are +// searching for. the second input is an array of the group ids to +// label once we have found a square pattern. In order, the pattern +// we are looking for is arranged in this format: +// +// 0 1 +// +// 2 3 +// +// example input: +// +// psearch[4] = { 1, 1, 1, 2 } +// pid[4] = { 0, 1, 2, 3 } + +int irt_scanPattern(int gindex, int *psearch, int *pid, int distcheck) +{ + int ptable[4]; + int i[4], j; // - loop indicies + int numGroups, numleds[4]; + int ismatch; + float x[4], y[4]; + float dist, avgDist, totalDev, totalLen, distDiff, minDist; + + float angle[4], adev[4], adevMin, adevMax; + + IrPointGroupType *g, *glist[4]; + IrCoordType crd[4], c; + + IrCoordType mid_13, mid_02; + + IrSPCType spc[IRT_MAX_SP_CANDIDATES]; + int numSPC = 0, bestSPC; + float sdist[4], sdev[4], bestScore; + + memset(&spc, 0, sizeof(IrSPCType) * IRT_MAX_SP_CANDIDATES); + + numGroups = irt_getNumGroups(gindex); + + // - we need at least four groups + + if (numGroups < 4) + return 0; + + // TODO: if we wanted to be really aggressive, we could try to + // identify groups based on history before we started scanning. + // If we did that, we would have to check here to see if this + // particular scan group has already been identified. + + // - note: only do this check if we've enabled aggressive + // history scanning. this scenario does not occur otherwise. + + ismatch = 0; + for (j = 0; j < 4; j++) + { + if (irt_getGroupById(gindex, pid[j])) + ismatch++; + } + + if (ismatch == 4) + return 1; + + ptable[0] = ptable[1] = ptable[2] = ptable[3] = -1; + + for (i[0] = 0; i[0] < numGroups; i[0]++) + { + if (irt_getGroupData(gindex, i[0], &x[0], &y[0]) != psearch[0]) + continue; + + for (i[1] = 0; i[1] < numGroups; i[1]++) + { + if (irt_getGroupData(gindex, i[1], &x[0], &y[0]) != psearch[1]) + continue; + + for (i[2] = 0; i[2] < numGroups; i[2]++) + { + if (irt_getGroupData(gindex, i[2], &x[0], &y[0]) != psearch[2]) + continue; + + for (i[3] = 0; i[3] < numGroups; i[3]++) + { + if (irt_getGroupData(gindex, i[3], &x[0], &y[0]) != psearch[3]) + continue; + + // - make sure there are no duplicates + + if ((i[0] == i[1]) || (i[0] == i[2]) || (i[0] == i[3]) + || (i[1] == i[2]) || (i[1] == i[3]) || (i[2] == i[3])) + continue; + + // - read the number of leds in each group + + for (j = 0; j < 4; j++) + { + numleds[j] = irt_getGroupData(gindex, i[j], &x[j], &y[j]); + glist[j] = irt_getGroupNum(gindex, i[j]); + crd[j].x = x[j]; + crd[j].y = y[j]; + crd[j].s = 0; + } + + // - check to see if the number of leds match those in + // our pattern + + ismatch = 1; + for (j = 0; j < 4; j++) + if (numleds[j] != psearch[j]) + ismatch = 0; + + if (!ismatch) + continue; + + // - check to see if any of the groups have been positively + // identified as a group other than what we are testing them + // against. (for example, if a particular group is #7, and we + // are testing to see if it might be #3) + + ismatch = 1; + for (j = 0; j < 4; j++) + { + g = irt_getGroupNum(gindex, i[j]); + + // - if the group has been assigned, and it is not what + // we're testing for + + if ((g->id != -1) && (g->id != pid[j])) + ismatch = 0; + } + + if (!ismatch) + continue; + + // - use the line-to-line collision between specific points to + // determine if this is the correct pattern + + // *** BA1, A2A3 -> [3,0], [1,2] == 0 *** + + if (checkCol(x[3], y[3], x[0], y[0], x[1], y[1], x[2], y[2]) != 0) + continue; + + // *** BA1, A3A2 -> [3,0], [2,1] == 1 *** + + if (checkCol(x[3], y[3], x[0], y[0], x[2], y[2], x[1], y[1]) != 1) + continue; + + // - superfluous tests + + if (checkCol(x[0], y[0], x[2], y[2], x[1], y[1], x[3], y[3]) != 0) + continue; + + if (checkCol(x[0], y[0], x[1], y[1], x[2], y[2], x[3], y[3]) != 0) + continue; + + // *** if we are here, that means that we've passed the collision tests! + + // - make sure that each of these groups isn't too close to the edge! + // a group that is too close to the edge might include points that + // are just out of view of the camera, so the groups population + // information might not be accurate! + + ismatch = 1; + for (j = 0; j < 4; j++) + { + if (glist[j]->near_edge) + ismatch = 0; + } + + if (!ismatch) + continue; + + // - basic orientation test: because the guns are almost always + // held the "correct" way (held upright, not upside down or sideways) + // because we are using pump shotguns and not handguns, we can + // safely assume that the points have the following orientation: + // + // 1 3 + // + // 0 2 + // + // ... which means that the midpoint of 13 should always be somewhat + // above the midpoint of 02. + + mid_13.x = crd[1].x + ((crd[3].x - crd[1].x) / 2); + mid_13.y = crd[1].y + ((crd[3].y - crd[1].y) / 2); + + mid_02.x = crd[0].x + ((crd[2].x - crd[0].x) / 2); + mid_02.y = crd[0].y + ((crd[2].y - crd[0].y) / 2); + + // - if the midpoint of 13 is not above the midpoint of 02, ignore this + // potential pattern + + if (mid_13.y > mid_02.y) + continue; + + // - trapezoid discrimination: measure the angle at each of the + // four corners, and calculate the deviation between each angle + // and the ideal 90 degrees. if the difference between the max + // and min deviation is greater than a certain threshold, this + // group is too much of a trapezoid. + + angle[0] = pw_angle_between(crd[0].x, crd[0].y, crd[1].x, crd[1].y, crd[2].x, crd[2].y); + angle[1] = pw_angle_between(crd[1].x, crd[1].y, crd[0].x, crd[0].y, crd[3].x, crd[3].y); + angle[2] = pw_angle_between(crd[2].x, crd[2].y, crd[0].x, crd[0].y, crd[3].x, crd[3].y); + angle[3] = pw_angle_between(crd[3].x, crd[3].y, crd[2].x, crd[2].y, crd[1].x, crd[1].y); + + // - calculate the deviation of each angle from 90 degrees + + for (j = 0; j < 4; j++) + adev[j] = (angle[j] > 90) ? (angle[j] - 90) : (90 - angle[j]); + + // - find out the min and max deviation + + adevMin = 360.0; + adevMax = 0.0; + for (j = 0; j < 4; j++) + { + if (adev[j] < adevMin) + adevMin = adev[j]; + + if (adev[j] > adevMax) + adevMax = adev[j]; + } + + // - an unevenly skewed trapzeoid will have a high min-max difference, + // while a evenly skewed trapezoid (as seen by a camera at a severe + // angle) will have a very low (near zero) min-max difference. + + if ((adevMax - adevMin) > 20.0) + continue; + + // - if we've stored away our maximum number of candidates, don't + // store any more. + + if (numSPC >= IRT_MAX_SP_CANDIDATES) + continue; + + // - now, we will determine how much of a square this group + // makes. read the length of every side... + + sdist[0] = irt_getDistance(crd[0], crd[1]); + sdist[1] = irt_getDistance(crd[1], crd[3]); + sdist[2] = irt_getDistance(crd[3], crd[2]); + sdist[3] = irt_getDistance(crd[2], crd[0]); + + // - get the total length and average length... + + totalLen = sdist[0] + sdist[1] + sdist[2] + sdist[3]; + avgDist = totalLen / 4; + + // - measure each side's deviation from the average length + // and mark the total overall deviation... + + totalDev = 0; + for (j = 0; j < 4; j++) + { + sdev[j] = avgDist - sdist[j]; if (sdev[j] < 0) sdev[j] = -sdev[j]; + totalDev += sdev[j]; + } + + // - this candidate is scored according to how little each side + // deviates from the average. note that a perfect square would + // score 100%. + + if ((totalLen == 0.0) || (totalDev == 0.0)) + spc[numSPC].score = 1.0; + else + spc[numSPC].score = 1.0 - (totalDev / totalLen); + + // - add points for how well this group matches with history + + totalDev = 0; + for (j = 0; j < 4; j++) + { + // - if the group in question has not been seen on camera + // for more than five frames, we won't consider it + + if (groupTable[gindex][pid[j]].age > 5) + continue; + + c.x = groupTable[gindex][pid[j]].x; + c.y = groupTable[gindex][pid[j]].y; + totalDev += irt_getDistance(crd[j], c); + } + + // - keep track of the history deviation for debugging purposes + + spc[numSPC].totalDev = totalDev; + + spc[numSPC].minmax = adevMax - adevMin; + + // - if the total history deviation is less than 100 units, add + // up to 0.2 to the score based on how small the deviation is. + // + // in this way, a square that scores 90% will now score 110% if + // it completely matches the history data. + + if ((totalDev <= 100.0) && (spc[numSPC].score >= 0.85)) + { + spc[numSPC].score += 0.20 * ((100.0 - totalDev) / 100.0); + } + + // - store the group ids for this candidate + + for (j = 0; j < 4; j++) + spc[numSPC].id[j] = i[j]; + + // - increase the candidate count + + numSPC++; + } // i[3] + } // i[2] + } // i[1] + } // i[0] + + // - no candidates? report faliure! + + if (!numSPC) + return 0; + + // - now, see which of our candidates had the highest score + + bestSPC = -1; + bestScore = -999; + for (j = 0; j < numSPC; j++) + { + if (spc[j].score > bestScore) + { + bestScore = spc[j].score; + bestSPC = j; + } + } + + // - if we have a "best" candidate, and the score is higher + // than 85%, then we will assign this group. a group that + // very much resembles a square will recieve a score of + // 90% or higher. a terribly skewed parallelogram would + // score about 60%. 85% is fairly generous + + if ((bestSPC != -1) && (bestScore >= 0.85)) + { + for (j = 0; j < 4; j++) + { + g = irt_getGroupNum(gindex, spc[bestSPC].id[j]); + g->id = pid[j]; + g->faked = 0; + g->rule = -1; + + irt_groupTableUpdate(gindex, g); + } + + // - report that we've found our group! + + return 1; + } + + // - hang our heads in shame and report faliure. we couldn't find what + // we were looking for + + return 0; +} + +// ------------------------------------------------------------------- + +inline void irt_point_transform(CvMat hmat, double *p_in, double *p_out) +{ + int i; + + for (i = 0; i < 3; i++) + { + p_out[i] = p_in[0] * cvmGet(&hmat, i, 0) + + p_in[1] * cvmGet(&hmat, i, 1) + 1 * cvmGet(&hmat, i, 2); + } +} + +// ------------------------------------------------------------------- +// +// LOW <-------> HIGH +// +// C0 C1 C2 C3 C4 +// +// ROW 0: 10 11 12 13 14 +// +// ROW 1: 00 01 04 06 08 +// +// ROW 2: 02 03 05 07 09 +// +// Find both the lowest and highest groups available for each row. +// +// -test data- +// +// 0 1 2 3 4 +// --------- +// 0: 0 1 1 1 1 +// 1: 1 1 1 0 1 +// 2: 0 1 1 1 0 +// +// lowCol = 1; +// highCol = 4; +// +// or: ennumerate each group configuration and check each one! +// +// row,col +// +// ROW #0 TO ROW #1 +// +// 0,0 -> 1,1 +// 0,0 -> 1,2 +// 0,0 -> 1,3 +// 0,0 -> 1,4 +// +// 0,1 -> 1,2 +// 0,1 -> 1,3 +// 0,1 -> 1,4 +// +// 0,2 -> 1,3 +// 0,2 -> 1,4 +// +// ROW #1 TO ROW #2 +// +// 1,0 -> 2,1 +// 1,0 -> 2,2 +// 1,0 -> 2,3 +// 1,0 -> 2,4 +// +// 1,1 -> 2,2 +// 1,1 -> 2,3 +// 1,1 -> 2,4 +// +// 1,2 -> 2,3 +// 1,2 -> 2,4 +// +// ROW #0 TO ROW #2 +// +// 0,0 -> 2,1 +// 0,0 -> 2,2 +// 0,0 -> 2,3 +// 0,0 -> 2,4 +// +// 0,1 -> 2,2 +// 0,1 -> 2,3 +// 0,1 -> 2,4 +// +// 0,2 -> 2,3 +// 0,2 -> 2,4 + +int irt_calcBiggestBox2(int gun_index, float cx, float cy, float *x, float *y) +{ + double grp_pts[8], pts[8], h[9], pin[3], pout[3]; + IrPointGroupType *gptr, *g[4]; + CvMat cmat_a, cmat_b, cmat_h; + int gids[4 * 9 * 3] = { + 0,0, 1,1, 0,0, 1,2, 0,0, 1,3, 0,0, 1,4, + 0,1, 1,2, 0,1, 1,3, 0,1, 1,4, + 0,2, 1,3, 0,2, 1,4, + 1,0, 2,1, 1,0, 2,2, 1,0, 2,3, 1,0, 2,4, + 1,1, 2,2, 1,1, 2,3, 1,1, 2,4, + 1,2, 2,3, 1,2, 2,4, + 0,0, 2,1, 0,0, 2,2, 0,0, 2,3, 0,0, 2,4, + 0,1, 2,2, 0,1, 2,3, 0,1, 2,4, + 0,2, 2,3, 0,2, 2,4, + }; + int i, j, area, largestArea, largestIndex, allThere; + int gindex[4]; + + // - check to see which is the largest available box + + largestArea = -1; + largestIndex = -1; + for (i = 0; i < 27; i++) + { + allThere = 1; + + for (j = 0; j < 4; j++) + { + gptr = irt_getGroupById(gun_index, gids[(i * 4) + j]); + if (!gptr) + allThere = 0; + } + + if (allThere) + { + area = (gids[(i * 4) + 2] - gids[(i * 4) + 0]) + * (gids[(i * 4) + 3] - gids[(i * 4) + 1]); + + if (area > largestArea) + { + largestArea = area; + largestIndex = i; + } + } + } + + if (largestIndex == -1) + return 0; + + for (i = 0; i < 4; i++) + { + gindex[i] = gids[(largestIndex * 4) + i]; + g[i] = irt_getGroupById(gun_index, gindex[i]); + printf("%i ", gindex[i]); + grp_pts[(i * 2) + 0] = g[i]->x; + grp_pts[(i * 2) + 1] = g[i]->y; + + pts[(i * 2) + 0] = irt_grp_rxy[(gindex[i] * 2) + 0]; + pts[(i * 2) + 1] = irt_grp_rxy[(gindex[i] * 2) + 1]; + } + printf("\n"); + + cmat_a = cvMat(4, 2, CV_64F, grp_pts); + cmat_b = cvMat(4, 2, CV_64F, pts); + cmat_h = cvMat(3, 3, CV_64F, h); + + cvFindHomography(&cmat_a, &cmat_b, &cmat_h); + + cv_prev[gun_index] = *cvCloneMat(&cmat_h); + //cvInvert(cv_prev[gun_index], cv_prevInv[gun_index]); + + pin[0] = cx; + pin[1] = cy; + pin[2] = 1; + + irt_point_transform(cmat_h, pin, pout); + + // - if our scale factor is non-zero, we have a good homography + + *x = *y = 0; + + if (pout[2] != 0) + { + *x = pout[0] / pout[2]; + *y = pout[1] / pout[2]; + return 1; + } + + return 0; +} + +// ------------------------------------------------------------------- + +int irt_calcBiggestBox(int gun_index, float cx, float cy, float *x, float *y, int useFake) +{ + double grp_pts[8], pts[8], h[9], pin[3], pout[3]; + CvMat cmat_a, cmat_b, cmat_h; + IrPointGroupType *g[4]; + int gids[10] ={ + 0, 2, + 1, 3, + 4, 5, + 6, 7, + 8, 9 }; + int gindex[4], gcount; + int i; + + *x = *y = 0; + + gcount = 0; + for (i = 0; i < 5; i++) + { + gindex[0] = gids[(i * 2) + 0]; + gindex[1] = gids[(i * 2) + 1]; + g[0] = irt_getGroupById(gun_index, gindex[0]); + g[1] = irt_getGroupById(gun_index, gindex[1]); + if (g[0] && g[1]) + { + if ((g[0]->faked || g[1]->faked) && !useFake) + continue; + + gcount++; + break; + } + } + + for (i = 4; i >= 0; i--) + { + gindex[2] = gids[(i * 2) + 0]; + gindex[3] = gids[(i * 2) + 1]; + + g[2] = irt_getGroupById(gun_index, gindex[2]); + g[3] = irt_getGroupById(gun_index, gindex[3]); + if (g[2] && g[3]) + { + if ((g[2]->faked || g[3]->faked) && !useFake) + continue; + + gcount++; + break; + } + } + + if (gcount != 2) + return 0; + + for (i = 0; i < 4; i++) + { + grp_pts[(i * 2) + 0] = g[i]->x; + grp_pts[(i * 2) + 1] = g[i]->y; + + pts[(i * 2) + 0] = irt_grp_rxy[(gindex[i] * 2) + 0]; + pts[(i * 2) + 1] = irt_grp_rxy[(gindex[i] * 2) + 1]; + } + + cmat_a = cvMat(4, 2, CV_64F, grp_pts); + cmat_b = cvMat(4, 2, CV_64F, pts); + cmat_h = cvMat(3, 3, CV_64F, h); + + cvFindHomography(&cmat_a, &cmat_b, &cmat_h); + + cv_prev[gun_index] = *cvCloneMat(&cmat_h); + cv_prevInv[gun_index] = *cvCloneMat(&cmat_h); + cvInvert(&cmat_h, &cv_prevInv[gun_index], CV_SVD); + + // - project the point from the center of the camera to see how it compares + // to the center of the screen (800x600) + + pin[0] = 400; + pin[1] = 300; + pin[2] = 1; + + irt_point_transform(cv_prevInv[gun_index], pin, pout); + if (pout[2] != 0) + { + irt_currCalibXY[(gun_index * 2) + 0] = (pout[0] / pout[2]) - 400; + irt_currCalibXY[(gun_index * 2) + 1] = (pout[1] / pout[2]) - 300; + } + + pin[0] = 0; + pin[1] = 300; + pin[2] = 1; + + irt_point_transform(cv_prevInv[gun_index], pin, pout); + if (pout[2] != 0) + { + irt_currCalibLeftXY[(gun_index * 2) + 0] = (pout[0] / pout[2]);// - 0; + irt_currCalibLeftXY[(gun_index * 2) + 1] = (pout[1] / pout[2]);// - 300; + } + + pin[0] = 800; + pin[1] = 300; + pin[2] = 1; + + irt_point_transform(cv_prevInv[gun_index], pin, pout); + if (pout[2] != 0) + { + irt_currCalibRightXY[(gun_index * 2) + 0] = (pout[0] / pout[2]);// - 800; + irt_currCalibRightXY[(gun_index * 2) + 1] = (pout[1] / pout[2]);// - 300; + } + + // - next, project our actual point using the calibrated camera center + + pin[0] = cx; + pin[1] = cy; + pin[2] = 1; + + irt_point_transform(cmat_h, pin, pout); + + // - if our scale factor is non-zero, we have a good homography + + if (pout[2] != 0) + { + *x = pout[0] / pout[2]; + *y = pout[1] / pout[2]; + return 1; + } + + return 0; +} + + + +// ------------------------------------------------------------------- +// note: ftable should be allocated to (sizeof(float) * (20 + 1)) + +void irt_calc_all_boxes(int gindex, int cx, int cy, float *ftable) +{ + double grp_pts[8], pts[8], h[9], pin[3], pout[3]; + CvMat cmat_a, cmat_b, cmat_h; + IrPointGroupType *g[4]; + int i, j, allthere, notFake, useFakes, gidx[4]; + float avgx, avgy, f, ft; + float xplusTable[128], xminusTable[128]; + float xplusAvg[2], xminusAvg[2], xpft, xmft; + float angle; + int grpid[21][4] = + { + // - size 1 boxes + { 0, 1, 2, 3 }, + { 1, 4, 3, 5 }, + { 4, 6, 5, 7 }, + { 6, 8, 7, 9 }, + + // - upper shadow group boxes + + { 10, 11, 0, 1 }, + { 11, 12, 1, 4 }, + { 12, 13, 4, 6 }, + { 13, 14, 6, 8 }, + + // - lower shadow group boxes + + { 2, 3, 15, 16 }, + { 3, 5, 16, 17 }, + { 5, 7, 17, 18 }, + { 7, 9, 18, 19 }, + + // - size 2 boxes + + { 0, 4, 2, 5 }, + { 1, 6, 3, 7 }, + { 4, 8, 5, 9 }, + + { 12, 14, 4, 8 }, + { 11, 13, 1, 6 }, + { 10, 12, 0, 4 }, + + // - size 3 boxes + { 0, 6, 2, 7 }, + { 1, 8, 3, 9 }, + // - size 4 boxes + { 0, 8, 2, 9 }, + }; + + // - this table describes how much weight each group is given in the + // final average. the size 4 box is given 100%, while the size 1 + // boxes are given only 20%. + + float ttable[21] = { + // size 1 boxes + 0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1, + 0.1, 0.1, 0.1, 0.1, + // size 2 boxes + 0.25, 0.25, 0.25, + 0.1, 0.1, 0.1, + // size 3 boxes + 0.5, 0.5, + // size 4 boxes + 1.0 + }; + + avgx = avgy = 0.0; + ft = 0; + + xplusAvg[0] = xplusAvg[1] = 0.0; + xminusAvg[0] = xminusAvg[1] = 0.0; + xpft = xmft = 0.0; + + // - first, check to see if we have groups that are not faked + + useFakes = 1; + for (i = 0; i < 21; i++) + { + allthere = 1; + notFake = 1; + for (j = 0; j < 4; j++) + { + gidx[j] = grpid[i][j]; + g[j] = irt_getGroupById(gindex, grpid[i][j]); + if (!g[j]) + allthere = 0; + + if (g[j]) + if (g[j]->faked) + notFake = 0; + } + + if (allthere && notFake) + useFakes = 0; + } + + for (i = 0; i < 21; i++) + { + allthere = 1; + for (j = 0; j < 4; j++) + { + gidx[j] = grpid[i][j]; + g[j] = irt_getGroupById(gindex, grpid[i][j]); + if (!g[j]) + allthere = 0; + + if (g[j]) + if (g[j]->faked && !useFakes) + allthere = 0; + } + + if (!allthere) + { + ftable[(i * 2) + 0] = 0.0; + ftable[(i * 2) + 1] = 0.0; + + xplusTable[(i * 2) + 0] = 0.0; + xplusTable[(i * 2) + 1] = 0.0; + + xminusTable[(i * 2) + 0] = 0.0; + xminusTable[(i * 2) + 1] = 0.0; + } + else + { + for (j = 0; j < 4; j++) + { + grp_pts[(j * 2) + 0] = g[j]->x; + grp_pts[(j * 2) + 1] = g[j]->y; + + pts[(j * 2) + 0] = irt_grp_rxy[(gidx[j] * 2) + 0]; + pts[(j * 2) + 1] = irt_grp_rxy[(gidx[j] * 2) + 1]; + } + + cmat_a = cvMat(4, 2, CV_64F, grp_pts); + cmat_b = cvMat(4, 2, CV_64F, pts); + cmat_h = cvMat(3, 3, CV_64F, h); + + cvFindHomography(&cmat_a, &cmat_b, &cmat_h); + + // - calculate the center-point + + pin[0] = cx; + pin[1] = cy; + pin[2] = 1; + + irt_point_transform(cmat_h, pin, pout); + + if (pout[2] != 0) + { + ftable[(i * 2) + 0] = pout[0] / pout[2]; + ftable[(i * 2) + 1] = pout[1] / pout[2]; + + f = ttable[i]; + avgx += ftable[(i * 2) + 0] * f; + avgy += ftable[(i * 2) + 1] * f; + ft += f; + } + else + { + ftable[(i * 2) + 0] = 0.0; + ftable[(i * 2) + 1] = 0.0; + } + + // - calculate the x-minus point + + /* + pin[0] = irt_gunCalibXY[gindex][0]; + pin[1] = irt_gunCalibXY[gindex][1] - 100; + pin[2] = 1; + */ + + pin[0] = cx; + pin[1] = cy - 100; + pin[2] = 1; + + irt_point_transform(cmat_h, pin, pout); + + if (pout[2] != 0) + { + xminusTable[(i * 2) + 0] = pout[0] / pout[2]; + xminusTable[(i * 2) + 1] = pout[1] / pout[2]; + + f = ttable[i]; + xminusAvg[0] += xminusTable[(i * 2) + 0] * f; + xminusAvg[1] += xminusTable[(i * 2) + 1] * f; + xmft += f; + } + else + { + xminusTable[(i * 2) + 0] = 0.0; + xminusTable[(i * 2) + 1] = 0.0; + } + + // - calculate the x-plus point + + /* + pin[0] = irt_gunCalibXY[gindex][0]; + pin[1] = irt_gunCalibXY[gindex][1] + 100; + pin[2] = 1; + */ + + pin[0] = cx; + pin[1] = cy + 100; + pin[2] = 1; + + irt_point_transform(cmat_h, pin, pout); + + if (pout[2] != 0) + { + xplusTable[(i * 2) + 0] = pout[0] / pout[2]; + xplusTable[(i * 2) + 1] = pout[1] / pout[2]; + + f = ttable[i]; + xplusAvg[0] += xplusTable[(i * 2) + 0] * f; + xplusAvg[1] += xplusTable[(i * 2) + 1] * f; + xpft += f; + } + else + { + xplusTable[(i * 2) + 0] = 0.0; + xplusTable[(i * 2) + 1] = 0.0; + } + + } + } + + if (ft > 0.0) + { + avgx /= ft; + avgy /= ft; + + xminusAvg[0] /= xmft; + xminusAvg[1] /= xmft; + + xplusAvg[0] /= xpft; + xplusAvg[1] /= xpft; + } + + // - the 100th and 101st entries are the averaged result of all available + // data + + ftable[100] = avgx; + ftable[101] = avgy; + + if (useFakes && !irt_usingInterpolation[gindex]) + { + irt_interpolationEntry[gindex][0] = avgx; + irt_interpolationEntry[gindex][1] = avgy; + irt_usingInterpolation[gindex] = 1; + } + else if (useFakes) + { + // - provide a bit of correction to the x coordinate + // ftable[100] = irt_interpolationEntry[gindex][0] + ((avgx - irt_interpolationEntry[gindex][0]) * 1.15); + } + else if (!useFakes) + { + irt_usingInterpolation[gindex] = 0; + } + + // - todo: save history? + + irt_xminusCoord[gindex][0].x = xminusAvg[0]; + irt_xminusCoord[gindex][0].y = xminusAvg[1]; + + irt_xplusCoord[gindex][0].x = xplusAvg[0]; + irt_xplusCoord[gindex][0].y = xplusAvg[1]; + + angle = (irt_xminusCoord[gindex][0].x - irt_gunCoord[gindex][0].x) + / (irt_gunCoord[gindex][0].x - irt_xplusCoord[gindex][0].x); +} + +// ------------------------------------------------------------------- + +void irt_cal_gun(int gindex, int *ox, int *oy) +{ + *ox = irt_currCalibXY[(gindex * 2) + 0]; + *oy = irt_currCalibXY[(gindex * 2) + 1]; + + // printf("irt_cal_gun: (%i, %i)\n", *ox, *oy); +} + +// ------------------------------------------------------------------- + +void irt_cal_gundisp(int gindex, int type) +{ + switch (type) + { + case 0: // - left (0, 300) + + printf("LEFT : (%i, %i) (%i, %i) (%i, %i)\n" + , irt_currCalibLeftXY[(gindex * 2) + 0] + , irt_currCalibLeftXY[(gindex * 2) + 1] + , irt_gunCalibLeftXY[gindex][0] + , irt_gunCalibLeftXY[gindex][1] + , irt_currCalibLeftXY[(gindex * 2) + 0] - irt_gunCalibLeftXY[gindex][0] + , irt_currCalibLeftXY[(gindex * 2) + 1] - irt_gunCalibLeftXY[gindex][1] + ); + + break; + + case 1: // - right (800, 300) + + printf("RIGHT: (%i, %i) (%i, %i) (%i, %i)\n" + , irt_currCalibRightXY[(gindex * 2) + 0] + , irt_currCalibRightXY[(gindex * 2) + 1] + , irt_gunCalibRightXY[gindex][0] + , irt_gunCalibRightXY[gindex][1] + , irt_currCalibRightXY[(gindex * 2) + 0] - irt_gunCalibRightXY[gindex][0] + , irt_currCalibRightXY[(gindex * 2) + 1] - irt_gunCalibRightXY[gindex][1] + ); + + break; + } + /* + printf("(%i, %i), (%i, %i), (%i, %i)\n" + , irt_currCalibXY[(gindex * 2) + 0] + , irt_currCalibXY[(gindex * 2) + 1] + , x, y + , irt_gunCalibXY[gindex][0] - irt_currCalibXY[(gindex * 2) + 0] + , irt_gunCalibXY[gindex][1] - irt_currCalibXY[(gindex * 2) + 1]); + */ +} + +// ------------------------------------------------------------------- +// - this function attempts to estimate where the player is standing +// in relation to the screen, in the hopes of providing accurate +// calibration as the player moves around. + +void irt_estimatePlayerPosition(int gindex) +{ + float x, y; + + // - see where we are currently pointing + + irt_systemGetScaledCoords(gindex, &x, &y); + + // - if the player is pointing near the center, we will assign + // the current angle and distance + + // - for the purposes of our "stand back" message, we will try to + // read the position in a greater range from the center. + + if ((irt_gunCoord[gindex][0].x < 0) || (irt_gunCoord[gindex][0].x > 800) + || (irt_gunCoord[gindex][0].y < 0) || (irt_gunCoord[gindex][0].y > 600)) + return; + + irt_playerAngle[gindex] = irt_systemGetXPMAngle(gindex); + irt_playerDistance[gindex] = irt_systemGetXPMDist(gindex); + + return; + + if ((x >= (400 - 10)) && (x <= (400 + 10))) + { + if (!irt_playerInCenter[gindex]) + { + irt_playerAngle[gindex] = irt_systemGetXPMAngle(gindex); + irt_playerDistance[gindex] = irt_systemGetXPMDist(gindex); + irt_playerInCenter[gindex] = 1; + } + } + else + { + irt_playerInCenter[gindex] = 0; + } +} + +// ------------------------------------------------------------------- + +void irt_systemGetPlayerPosition(int gindex, float *angle, float *dist) +{ + *angle = irt_playerAngle[gindex]; + *dist = irt_playerDistance[gindex]; +} + +// ------------------------------------------------------------------- + +void irt_assignHistoryLines(int gindex) +{ + IrPointGroupType *g; + int line0[5] = { 0, 1, 4, 6, 8 }; + int line1[5] = { 2, 3, 5, 7, 9 }; + int line0Low, line0High; + int line1Low, line1High; + int i; + int numId, numFaked; + + hLine[0][gindex].active = 0; + hLine[1][gindex].active = 0; + + numId = numFaked = 0; + for (i = 0; i < irt_numGroups[gindex]; i++) + { + g = irt_getGroupNum(gindex, i); + if (g) + if (g->id != -1) + numId++; + + if (g) + //if (g->faked) + numFaked++; + } + + //if (numId == numFaked) + // return; + + //printf("%i, %i\n", numId, numFaked); + + // - determine the "highest" and "lowest" groups for each row, in + // an effort to have the longest possible history line + + line0Low = line1Low = 99; + line0High = line1High = -1; + + for (i = 0; i < 5; i++) + { + if (g = irt_getGroupById(gindex, line0[i])) + { + if (!g->faked) + { + if (line0[i] < line0Low) line0Low = line0[i]; + if (line0[i] > line0High) line0High = line0[i]; + } + } + + if (g = irt_getGroupById(gindex, line1[i])) + { + if (!g->faked) + { + if (line1[i] < line1Low) line1Low = line1[i]; + if (line1[i] > line1High) line1High = line1[i]; + } + } + } + + //printf("(%i, %i)\n", line0Low, line0High); + + if ((line0Low != 99) && (line0High != -1) + && (line0Low != line0High)) + { + hLine[0][gindex].active = 1; + + g = irt_getGroupById(gindex, line0Low); + + if (g) + { + hLine[0][gindex].A.x = g->x; + hLine[0][gindex].A.y = g->y; + } + + g = irt_getGroupById(gindex, line0High); + + if (g) + { + hLine[0][gindex].B.x = g->x; + hLine[0][gindex].B.y = g->y; + } + } + else + { + hLine[0][gindex].active = 0; + } + + if ((line1Low != 99) && (line1High != -1) + && (line1Low != line1High)) + { + hLine[1][gindex].active = 1; + + g = irt_getGroupById(gindex, line1Low); + + if (g) + { + hLine[1][gindex].A.x = g->x; + hLine[1][gindex].A.y = g->y; + } + + g = irt_getGroupById(gindex, line1High); + + if (g) + { + hLine[1][gindex].B.x = g->x; + hLine[1][gindex].B.y = g->y; + } + } + else + { + hLine[1][gindex].active = 0; + } +} + +// ------------------------------------------------------------------- +// - here, we compare each of the points against any active "history +// lines". points that aren't close enough to either line are +// considered to be noise, and are flagged as such + +void irt_discriminatePoints(int gindex) +{ + IrPointType *p; + float px, py, bx, by, dp; + int i, j, numBad, numActive; + + // - if we don't have active history line data for both + // our lines, don't bother doing anything + + //if (!hLine[0][gindex].active && !hLine[1][gindex].active) + // return; + + p = irt_pointList[gindex]; + for (i = 0; i < irt_numPoints[gindex]; i++) + { + numBad = 0; + numActive = 0; + + for (j = 0; j < 2; j++) + if (hLine[j][gindex].active) + { + numActive++; + + px = p->crd.x - hLine[j][gindex].A.x; + py = p->crd.y - hLine[j][gindex].A.y; + bx = hLine[j][gindex].B.x - hLine[j][gindex].A.x; + by = hLine[j][gindex].B.y - hLine[j][gindex].A.y; + + dp = pw_dot_product(bx, by, px, py); + + p->dp[j] = dp; + + if (dp < 0.0) dp = -dp; + + if (!( (dp == 0) || (dp == 1) || (dp >= 0.999) )) + numBad++; + + //if (dp < 0.5) + // numBad++; + } + else + { + p->dp[j] = 0.0; + } + + if ((numBad == numActive) + && (numBad)) + p->isNoise = 1; + + p++; + } + +} + +// ------------------------------------------------------------------- + +void irt_getHistoryLineData(int gindex, int lindex, int *ax, int *ay, int *bx, int *by) +{ + *ax = hLine[lindex][gindex].A.x; + *ay = hLine[lindex][gindex].A.y; + *bx = hLine[lindex][gindex].B.x; + *by = hLine[lindex][gindex].B.y; +} + +// ------------------------------------------------------------------- +// - calculate the group offset table data. this table simply stores +// the offsets between each of the groups that are visible on camera +// in an effort to use this data later when a group is no longer +// visible (but we want to extrapolate its likely position). + +void irt_updateGroupOffsetTable(int gindex) +{ + IrPointGroupType *g, *currG; + IrCoordType c1, c2; + int i, j, index, curGroup; + float dist; + double len; + + for (i = 0; i < 30; i++) + { + curGroup = (i / 3); + + if (goTable[i][gindex].targetId == -1) + continue; + + g = irt_getGroupById(gindex, goTable[i][gindex].targetId); + if (!g) + continue; + + currG = irt_getGroupById(gindex, curGroup); + if (!currG) + continue; + + goTable[i][gindex].x = g->x - currG->x; + goTable[i][gindex].y = g->y - currG->y; + + if (!irt_enableThread) + if (g->faked || currG->faked) + continue; + + // - note... this code below should not be run here! + + // - if the group that we are targeting is not clearly seen, we will + // use an offset value that has been stored away somewhere in the + // offset group field + + if (g->faked) + { + continue; + + // - only do this if we are currently one of the top row groups + + if (!((currG->id == 0) || (currG->id == 1) || (currG->id == 4) + || (currG->id == 6) || (currG->id == 8))) + continue; + + c1.x = currG->x; + c1.y = currG->y; + + dist = 999.9; + index = -1; + for (j = 0; j < IRT_OS_GRID_SIZE; j++) + { + c2.x = irt_osGrid[j][gindex].x + irt_osGrid[j][gindex].ox; + c2.y = irt_osGrid[j][gindex].y + irt_osGrid[j][gindex].oy; + + if (dist > irt_getDistance(c1, c2)) + { + dist = irt_getDistance(c1, c2); + index = j; + } + } + + if (index != -1) + { + /* + glBegin(GL_LINES); + glColor3f(0, 1, 0); + glVertex2i(c1.x, c1.y); + glVertex2i(c1.x - osGrid[index].ox, c1.y - osGrid[index].oy); + glEnd(); + */ + + //goTable[i][gindex].x = -irt_osGrid[index][gindex].ox; + //goTable[i][gindex].y = -irt_osGrid[index][gindex].oy; + + _irt_insertOffsetTableData(gindex, g->id, 69, -irt_osGrid[index][gindex].ox, -irt_osGrid[index][gindex].oy); + } + } + + + + if ((irt_gunCoord[gindex][0].x < -32) || + (irt_gunCoord[gindex][0].x > 632)) + continue; + + if ((irt_gunCoord[gindex][0].y < -32) || + (irt_gunCoord[gindex][0].y > 832)) + continue; + + if (goTable[i][gindex].x < goTable[i][gindex].min_x) + goTable[i][gindex].min_x = goTable[i][gindex].x; + + if (goTable[i][gindex].y < goTable[i][gindex].min_y) + goTable[i][gindex].min_y = goTable[i][gindex].y; + + if (goTable[i][gindex].x > goTable[i][gindex].max_x) + goTable[i][gindex].max_x = goTable[i][gindex].x; + + if (goTable[i][gindex].y > goTable[i][gindex].max_y) + goTable[i][gindex].max_y = goTable[i][gindex].y; + + /* + if (gindex == 0) + if ((curGroup == 0) && (goTable[i][gindex].targetId == 2)) + { + len = sqrt(pow(g->x - currG->x, 2) + pow(g->y - currG->y, 2)); + printf("len = %2.2f\n", len); + } + */ + } +} + +// ------------------------------------------------------------------- + +void irt_enforceGroupOffsetTable(int gindex) +{ + IrPointGroupType *g, *currG; + int i, j, curGroup; + float x[10], y[10]; + int hits[10]; + + for (i = 0; i < 10; i++) + { + x[i] = y[i] = 0.0; + hits[i] = 0; + } + + for (i = 0; i < 30; i++) + { + curGroup = (i / 3); + + if (goTable[i][gindex].targetId == -1) + continue; + + currG = irt_getGroupById(gindex, curGroup); + if (!currG) + continue; + + if (currG->faked) + continue; + + j = goTable[i][gindex].targetId; + + g = irt_getGroupById(gindex, j); + + if (g) + continue; + + if ((goTable[i][gindex].x == 0) && (goTable[i][gindex].y == 0)) + continue; + + hits[j]++; + x[j] += currG->x + goTable[i][gindex].x; + y[j] += currG->y + goTable[i][gindex].y; + } + + for (i = 0; i < 10; i++) + { + if (!hits[i]) + continue; + + x[i] /= hits[i]; + y[i] /= hits[i]; + + irt_numGroups[gindex]++; + irt_groupList[gindex] + = (IrPointGroupType*)realloc(irt_groupList[gindex], sizeof(IrPointGroupType) * irt_numGroups[gindex]); + irt_groupList[gindex][irt_numGroups[gindex] - 1].x = x[i]; + irt_groupList[gindex][irt_numGroups[gindex] - 1].y = y[i]; + irt_groupList[gindex][irt_numGroups[gindex] - 1].id = i; + irt_groupList[gindex][irt_numGroups[gindex] - 1].friends = 1; + irt_groupList[gindex][irt_numGroups[gindex] - 1].faked = 1; + irt_groupList[gindex][irt_numGroups[gindex] - 1].rule = i; + } +} + +// ------------------------------------------------------------------- +// - set the function pointer to the main system's system log function +// (printf, ect.) + +void irt_systemSetSLogCB(slog_callback *func) +{ + irt_sysLog = func; +} + +// ------------------------------------------------------------------- + +void irt_systemSLog(char *fmt,...) +{ + char buf[1024]; + va_list ap; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + + if (irt_sysLog) + irt_sysLog(buf); + + va_end(ap); + +} + +// ------------------------------------------------------------------- + +int irt_systemShouldRestart(void) +{ + return serial_shouldRestart(); +} + +// ------------------------------------------------------------------- + +void irt_systemSetSentCamRegisters(char *buf) +{ + memcpy(irt_systemCamRegisters, buf, sizeof(char) * 4); +} + +// ------------------------------------------------------------------- + +int irt_systemGetCamRegisterState(int gindex) +{ + return irt_gunCamRegisterState[gindex]; +} + +// ------------------------------------------------------------------- + +float irt_systemGetAvgFriendDistance(int gindex) +{ + return irt_avgFriendDist[gindex]; +} + +// ------------------------------------------------------------------- + +int irt_systemGetConnectionStatus(int gindex) +{ + return serial_is_open(gindex); +} + +// ------------------------------------------------------------------- + +// ****** OPENCV FIX FOR OLDER GCC VERSIONS ****** + +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MAJOR__ * 100 + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION < 30300 + void __stack_chk_fail_local(void) { return; } +#endif + +// ****** + diff --git a/libraries/pmrt/irtrack/irtrack.h b/libraries/pmrt/irtrack/irtrack.h new file mode 100755 index 0000000..9e130fe --- /dev/null +++ b/libraries/pmrt/irtrack/irtrack.h @@ -0,0 +1,364 @@ +// ------------------------------------------------------------------- +// irtrack.h +// +// 01.07.09 - (07/02/08) +// +// * removed non-essential messages from the system log +// +// * greater detail displayed for crc errors +// +// 01.07.08 - (06/30/08) +// +// * added code to discriminate between leds from different cabinets. +// +// 01.07.07 - (05/22/08) +// +// * the "danger zone" has been reset to the value before v01.07.05. +// +// * the amount of messages that are written to the system log have +// been reduced. +// +// 01.07.06 - (05/20/08) +// +// * there needs to be a minimum of three points in the camera's view +// for the system to generate a "too close" message. the previous +// limit was one. +// +// 01.07.05 - (05/14/08) +// +// * the "danger zone" has been reduced to zero. +// +// 01.07.03 - (04/28/08) +// +// * a new test has been added to the patternScan function which +// throws out groups that are not oriented in the way that we +// would expect if the gun is held upright. orientations that can +// occur only if the gun is held upside down are ignored. this is +// done to filter out potentially "bad" groups that are created when +// noise is present in the image. +// +// 01.07.02 - (04/23/08) +// +// * the "danger zone" around the edges of the camera's vision have +// been extended back to the previous level, making the system more +// "cautious" about what it looks at. +// +// * in the patternScan function, extra points for history matching +// are only assigned if a group has already scored a minimum of 0.85. +// this is to prevent very skewed trapezoids from passing the test +// if a few points happen to match history. +// +// 01.07.01 - (04/18/08) +// +// * irt_calc_all_boxes no longer includes any interpolated data if +// there is at least one full group of four that consists entirely +// of "real" data. this is done to keep bad interpolation from +// adding noise to an otherwise good gun coordinate +// +// * irt_calc_all_boxes keeps track of the coordinate where the player +// enters interpolated mode, and applies a 115% correction to the +// x coordinate to compensate for the "lag" that occurs when the +// player sweeps across the screen in interpolated mode. +// +// * the anti-lag projection system will now default back to the +// regular un-projected gun coordinate if the projected coordinate +// lands somewhere off-screen. +// +// ------------------------------------------------------------------- + +#ifndef _IRTRACK_H_ +#define _IRTRACK_H_ + +// ------------------------------------------------------------------- + +#define IRT_VERSION_MAJOR 1 +#define IRT_VERSION_MINOR 7 +#define IRT_VERSION_SUB 9 + +#define SERIAL_MAX_PLAYERS 8 + +// ------------------------------------------------------------------- + +#include + +// ------------------------------------------------------------------- + +typedef struct { + + float x, y, s; // x/y coordinates and point size + +} IrCoordType; + +typedef struct { + + IrCoordType crd; + int neighbors; // number of neighbor points + int *nPtr; // index list of each neighbor (index) + float *nDist; // distance to each neighbor + + int friends; // how many friends (close neighbor points) we have + int *fPtr; // index list of each friend + int groupNum; // what group are we in? + + int isNoise; // did this point fail the "history line" test? + float dp[2]; +} IrPointType; + +typedef struct { + + int id; // group id + int friends; // number of friends in the group + //int *fPtr; // index list to each friend + float x, y; // center point for this group + + float id_rx, id_ry; // real-world coordinates for this group + + int faked; // has this group been faked by interpolation? + int near_edge; // is this group near the edge of the screen? + + int rule; // what "rule" were we interpolated by? + +} IrPointGroupType; + +typedef struct { + float x, y; // screen coordinates + int age; // age in frames + int friends; // how many points in this group +} IrGroupTableType; + +typedef struct { + float x, y; + float angle; + clock_t timestamp; +} IrGunCoordType; + +typedef struct { + int id[4]; + float score; + float totalDev; + float minmax; +} IrSPCType; + +typedef struct { + int cx, cy; + float angle; + float dist; +} IrCalibType; + +typedef struct { + IrCoordType A, B; // endpoints of the line + int active; +} IrHistLineType; + +typedef struct { + int targetId; // what group id we are targeting + float x, y; // the offset between us and the target group + float max_x, max_y; + float min_x, min_y; +} IrGroupOffsetType; + +typedef struct { + float x, y; // screen coordinates + float ox, oy; // offset to partner group +} IrOSGridPointType; + +typedef int (slog_callback)(char *fmt, ...); + +// added 7-30-2008 KTU +typedef struct{ + int frames; + int glitches; + int pBlaze_wd; + int pBlaze_pc; + unsigned char stuckbits; + unsigned char version; +} IrGunStatus; + +// ------------------------------------------------------------------- + +#define IR_HIST_TABLE_SIZE 15 + +#define IR_GROUP_LEFT_EDGE 20 +#define IR_GROUP_RIGHT_EDGE 780 +#define IR_GROUP_TOP_EDGE 20 +#define IR_GROUP_BOTTOM_EDGE 580 + +#define IRT_AVG_DIST_THRESHOLD 0.15 +#define IRT_MIN_DIST_THRESHOLD 1.10 +#define IRT_MIN_DIST_LOWEST 20.0 + +// - how many candidates to consider in each run of the pattern +// scan function + +#define IRT_MAX_SP_CANDIDATES 8 + +enum { + IRT_GUN_0 = 0, + IRT_GUN_1, + IRT_GUN_2, + IRT_GUN_3, +}; + +// ------------------------------------------------------------------- +// - these calls should be all that you need to use to get gun data +// into your game + +int irt_systemInit(void); +void irt_systemClose(void); +void irt_systemSetThreadEnable(int state); +void irt_systemLoop(int gindex); +void irt_systemGetCoords(int gindex, float *x, float *y); +void irt_systemGetLatestCoords(int gindex, float *x, float *y); + +void irt_systemGetScaledCoords(int gindex, float *x, float *y); + +//void irt_systemGetProjectedCoords(int gindex, float *x, float *y); +void irt_systemGetProjectedCoords(int gindex, float *x, float *y, int markDirty); + +clock_t irt_systemGetTimeStamp(int gindex); +clock_t irt_systemGetTimeStampDiff(int gindex); + +void irt_systemSetGunCalib(int pnum, int xoffset, int yoffset); +void irt_systemGetGunCalib(int pnum, int *xoffset, int *yoffset); +void irt_systemGunCalib(int gindex); + +void irt_systemSaveCalibration(int gindex, char *filename); +void irt_systemLoadCalibration(int gindex, char *filename); +void irt_systemClearCalibration(int gindex); + +void irt_systemSetYOffset(int gindex, int pindex); +void irt_systemSetYOffsetVal(int gindex, int pindex, float val); +float irt_systemGetYOffset(int gindex, int pindex); + +void irt_systemGetXPM(int gindex, int pindex, float *x, float *y); +float irt_systemGetXPMAngle(int gindex); +float irt_systemGetXPMDist(int gindex); + +// MODIFIED 7-29-2008 KTU +//void irt_systemSetFirmware(int mcuL, int mcuH, int fpgaL, int fpgaH); +//void irt_systemGetFirmware(int *mcuL, int *mcuH, int *fpgaL, int *fpgaH); +void irt_systemSetFirmware(int fpga, int player); +void irt_systemGetFirmware(int *fpga, int player); +void irt_systemGetGunStatus(int gindex, IrGunStatus *gun_stat); +void irt_systemClearGunStatus(int gindex); + +void irt_systemSendUpdateMSG(void); + +void irt_systemSetMarqueeState(int state); + +void irt_systemGetVisibleGroups(int gindex, int *vgroup); + +void irt_systemGetPlayerPosition(int gindex, float *angle, float *dist); + +void irt_systemGetPositionCal(int gindex, int *xoffset, int *yoffset); + +int irt_systemGetTrigger(int gindex); +int irt_systemGetTriggerState(int gindex); +int irt_systemGetPump(int gindex); +int irt_systemGetPumpRelease(int gindex); + +char *irt_systemGetVer(void); + +int irt_dbgGetPointList(int gindex, float *fptr); +int irt_dbgGetGroupList(int gindex, float *fptr); + +void irt_cal_gundisp(int gindex, int type); + +void irt_systemSetSLogCB(slog_callback *func); +void irt_systemSLog(char *fmt,...); + +void _irt_getOffsetTableData(int gindex, int index, float *x, float *y, float *minMax); +void _irt_insertOffsetTableData(int gindex, int gid, int target, float x, float y); + +int irt_systemShouldRestart(void); + +void irt_systemSetRegisterStatus(unsigned char *reg_fpga, unsigned char *reg_cam, int player); + +int irt_systemDetectGWB(void); + +int irt_systemGetGunActive(int gindex); + +//void irt_systemRequestFirmware(void); -- depricated 7-29-2008 KTU + +void irt_systemSetSentCamRegisters(char *buf); +int irt_systemGetCamRegisterState(int gindex); + +float irt_systemGetAvgFriendDistance(int gindex); + +void irt_systemReverseInput(void); + +int irt_systemGetConnectionStatus(int gindex); + +int irt_systemGetSerialErrStatus(void); + +int irt_systemIsPlayerOffscreen(int gindex); + +// ------------------------------------------------------------------- + +void irt_genCoords(int *numCoords, IrCoordType *crdPtr); + +void irt_getPointsFromCoords(int numCoords, IrCoordType *crdPtr, IrPointType *ptPtr, int gindex); + +void irt_destroyPointList(int gindex); + +void irt_getGroupsFromPoints(int gun_index); + +float irt_getDistance(IrCoordType c1, IrCoordType c2); + +int irt_getGroupData(int gindex, int group, float *x, float *y); + +IrPointGroupType *irt_getGroupById(int gindex, int idnum); + +int irt_getNumGroups(int gindex); + +IrPointGroupType* irt_getGroupNum(int gindex, int gnum); + +int irt_groupAssign(int gindex, int oldnum, int newnum); + +void irt_destroyGroupList(int gindex); + +void irt_groupHistoryAssign(int gindex, int markFakes); +void irt_groupHistoryCompensate(int gindex); +void irt_groupTableUpdate(int gindex, IrPointGroupType *g); +void irt_groupTableTick(void); +void irt_groupInterpolateBlanks(int gindex); + +void irt_genCoordsFromImg(int w, int h, int bpp, void *pixels); + +float irt_getAverageDist(void); + +int irt_getNumPoints(int gindex); + +IrPointType *irt_getPointNum(int gindex, int pnum); + +void test_createCoordsFromLeds(int gindex); + +int irt_scanPattern(int gindex, int *psearch, int *pid, int distcheck); +int irt_scan3Pattern(int gindex, int *psearch, int *pid); + +int irt_calcBiggestBox(int gun_index, float cx, float cy, float *x, float *y, int useFake); +int irt_calcBiggestBox2(int gindex, float cx, float cy, float *x, float *y); + +void irt_estimatePlayerPosition(int gindex); + +void irt_cal_gun(int gindex, int *ox, int *oy); + +//void irt_point_transform(CvMat hmat, double *p_in, double *p_out); + +void irt_loop_thread(void *ptr); + +void irt_calc_all_boxes(int gindex, int cx, int cy, float *ftable); + +void irt_discriminateFriends(int gindex); + +void irt_assignHistoryLines(int gindex); +void irt_getHistoryLineData(int gindex, int lindex, int *ax, int *ay, int *bx, int *by); +void irt_discriminatePoints(int gindex); + +void irt_updateGroupOffsetTable(int gindex); +void irt_enforceGroupOffsetTable(int gindex); + +// ------------------------------------------------------------------- + +#endif + diff --git a/libraries/pmrt/irtrack/irtrack.o b/libraries/pmrt/irtrack/irtrack.o new file mode 100644 index 0000000..e35766a Binary files /dev/null and b/libraries/pmrt/irtrack/irtrack.o differ diff --git a/libraries/pmrt/irtrack/makedeplib b/libraries/pmrt/irtrack/makedeplib new file mode 100644 index 0000000..948f562 --- /dev/null +++ b/libraries/pmrt/irtrack/makedeplib @@ -0,0 +1,59 @@ +irtrack.o: irtrack.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/include/bits/mathinline.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/opencv/cv.h \ + /g3/include/opencv/cxcore.h /g3/include/opencv/cxtypes.h \ + /usr/include/assert.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/float.h \ + /g3/include/opencv/cxerror.h /g3/include/opencv/cvver.h \ + /g3/include/opencv/cvtypes.h /g3/include/opencv/cvcompat.h irtrack.h \ + serial.h physWrapper.h +serial.o: serial.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/termios.h /usr/include/bits/termios.h \ + /usr/include/sys/ttydefaults.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h irtrack.h serial.h \ + /usr/local/include/usb.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h diff --git a/libraries/pmrt/irtrack/makefile b/libraries/pmrt/irtrack/makefile new file mode 100755 index 0000000..878f1c1 --- /dev/null +++ b/libraries/pmrt/irtrack/makefile @@ -0,0 +1,32 @@ +# irtrack - makefile + +.CLIBFILES = irtrack.c serial.c +.OLIBFILES = $(.CLIBFILES:.c=.o) + +.CCLIBFILES = physWrapper.cpp +.OOLIBFILES = $(.CCLIBFILES:.cpp=.o) + +TARGETLIB = irtrack.a + +DEPENDLIBFILE = makedeplib + +CFLAGS = -O3 +CFLAGS += -I /g3/include/opencv + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(.OOLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(.OOLIBFILES) + -cp $(TARGETLIB) /g3/lib + -cp irtrack.h /g3/include + +clean: + -rm $(.OLIBFILES) $(.OOLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/irtrack/physLine.h b/libraries/pmrt/irtrack/physLine.h new file mode 100755 index 0000000..a834270 --- /dev/null +++ b/libraries/pmrt/irtrack/physLine.h @@ -0,0 +1,41 @@ +// ------------------------------------------------------------------- +// physLine.h - manny najera (1.17.04) +// ------------------------------------------------------------------- + +#ifndef _PHYSLINE_H_ +#define _PHYSLINE_H_ + +// ------------------------------------------------------------------- + +//#include "physPoint.h" +#include "physVector.h" + +// ------------------------------------------------------------------- + +class Line { + + public: + Point a, b; // <- start point, end point + + Line(void); + Line(Point ai, Point bi); +}; + +// ------------------------------------------------------------------- + +Line::Line(void) +{ + a.x = a.y = a.z = 0; + b.x = b.y = b.z = 0; +} + +Line::Line(Point ai, Point bi) +{ + a = ai; + b = bi; +} + +// ------------------------------------------------------------------- + +#endif + diff --git a/libraries/pmrt/irtrack/physVector.h b/libraries/pmrt/irtrack/physVector.h new file mode 100755 index 0000000..0789419 --- /dev/null +++ b/libraries/pmrt/irtrack/physVector.h @@ -0,0 +1,334 @@ +// ------------------------------------------------------------------- +// physVector.h - manny najera (1.17.04) +// ------------------------------------------------------------------- + +#ifndef _PHYSVECTOR_H_ +#define _PHYSVECTOR_H_ + +// ------------------------------------------------------------------- + +#include + +// ------------------------------------------------------------------- + +#define PI 3.14159265 + +// ------------------------------------------------------------------- + +class Vector { + + public: + double x, y, z; + + Vector(void); + Vector(double xi, double yi, double zi); + + double Magnitude(void); + void Normalize(void); + void Reverse(void); + + void set(double xi, double yi, double zi); + + Vector& operator+=(Vector u); + Vector& operator-=(Vector u); + Vector& operator*=(double s); + Vector& operator/=(double s); + + Vector operator-(void); + + void rotate2d(double a, Vector u); + void rotate2dS(double a, double s, Vector u); + +}; + +typedef Vector Point; + +// ------------------------------------------------------------------- + +void Vector::set(double xi, double yi, double zi) +{ + x = xi; + y = yi; + z = zi; +} + +// ------------------------------------------------------------------- + +inline Vector::Vector(void) +{ + x = 0; + y = 0; + z = 0; +} + +// ------------------------------------------------------------------- + +inline Vector::Vector(double xi, double yi, double zi) +{ + x = xi; + y = yi; + z = zi; +} + +// ------------------------------------------------------------------- + +inline double Vector::Magnitude(void) +{ + return (double) sqrt(x*x + y*y + z*z); +} + +// ------------------------------------------------------------------- + +inline void Vector::Normalize(void) +{ + double const tol = 0.0001f; + double m = (double) sqrt(x*x + y*y + z*z); + + if (m <= tol) + m = 1; + + x /= m; + y /= m; + z /= m; + + if (fabs(x) < tol) x = 0.0; + if (fabs(y) < tol) y = 0.0; + if (fabs(z) < tol) z = 0.0; +} + +// ------------------------------------------------------------------- + +inline void Vector::Reverse(void) +{ + x = -x; + y = -y; + z = -z; +} + +// ------------------------------------------------------------------- + +inline Vector& Vector::operator+=(Vector u) +{ + x += u.x; + y += u.y; + z += u.z; + return *this; +} + +// ------------------------------------------------------------------- + +inline Vector& Vector::operator-=(Vector u) +{ + x -= u.x; + y -= u.y; + z -= u.z; + return *this; +} + +// ------------------------------------------------------------------- + +inline Vector& Vector::operator*=(double s) +{ + x *= s; + y *= s; + z *= s; + return *this; +} + +// ------------------------------------------------------------------- + +inline Vector& Vector::operator/=(double s) +{ + x /= s; + y /= s; + z /= s; + return *this; +} + +// ------------------------------------------------------------------- + +inline Vector Vector::operator-(void) +{ + return Vector(-x, -y, -z); +} + +// ------------------------------------------------------------------- + +inline Vector operator+(Vector u, Vector v) +{ + return Vector(u.x + v.x, u.y + v.y, u.z + v.z); +} + +// ------------------------------------------------------------------- + +inline Vector operator-(Vector u, Vector v) +{ + return Vector(u.x - v.x, u.y - v.y, u.z - v.z); +} + +// ------------------------------------------------------------------- + +inline Vector operator^(Vector u, Vector v) +{ + return Vector ( u.y * v.z - u.z * v.y, + -u.x * v.z + u.z * v.x, + u.x * v.y - u.y * v.x); +} + +// ------------------------------------------------------------------- + +inline double operator*(Vector u, Vector v) +{ + return (u.x * v.x + u.y * v.y + u.z * v.z); +} + +// ------------------------------------------------------------------- + +inline Vector operator*(double s, Vector u) +{ + return Vector(u.x * s, u.y * s, u.z * s); +} + +// ------------------------------------------------------------------- + +inline Vector operator*(Vector u, double s) +{ + return Vector(u.x * s, u.y * s, u.z * s); +} + +// ------------------------------------------------------------------- + +inline Vector operator/(Vector u, double s) +{ + return Vector(u.x/s, u.y/s, u.z/s); +} + +// ------------------------------------------------------------------- + +void Vector::rotate2d(double a, Vector u) +{ + Vector intoScreen(0, 0, 1); + Vector up(0, -1, 0); + Vector vn, vtemp; + double currAngle, rotAngle, scale; + + // - get the current orientation vector + + vn.set(x - u.x, y - u.y, z - u.z); + + // - remember how far away we are from the pivot point + + scale = vn.Magnitude(); + + // - we are only interested in the general direction now + + vn.Normalize(); + + // - get the current rotation angle between vn and the up vector + + currAngle = acos(vn * up) * (180 / PI); + + // - check to see if this is supposed to be a positive or negative + // angle based on the polarity of the cross product between vn + // and the "up" vector + + vtemp = vn ^ up; + if (vtemp.z > 0.001f) + currAngle = -currAngle; + + // - add our input angle to the total rotation + + rotAngle = currAngle + a; + + // - create a new vector with the correct rotation + + vtemp.x = cos((rotAngle) * PI/180); + vtemp.y = sin((rotAngle) * PI/180); + vtemp.Normalize(); + + // - this new vector is perpendicular to our result + + vtemp = vtemp ^ intoScreen; + vtemp.Normalize(); + + // - make sure that we stay the same distance away from the + // pivot point + + vtemp *= scale; + + // - adding the pivot point to our vector gives us the correct + // result + + vtemp += u; + + x = vtemp.x; + y = vtemp.y; + z = vtemp.z; +} + +// ------------------------------------------------------------------- + +void Vector::rotate2dS(double a, double s, Vector u) +{ + Vector intoScreen(0, 0, 1); + Vector up(0, -1, 0); + Vector vn, vtemp; + double currAngle, rotAngle, scale; + + // - get the current orientation vector + + vn.set(x - u.x, y - u.y, z - u.z); + + // - remember how far away we are from the pivot point + + scale = vn.Magnitude(); + + // - we are only interested in the general direction now + + vn.Normalize(); + + // - get the current rotation angle between vn and the up vector + + currAngle = acos(vn * up) * (180 / PI); + + // - check to see if this is supposed to be a positive or negative + // angle based on the polarity of the cross product between vn + // and the "up" vector + + vtemp = vn ^ up; + if (vtemp.z > 0.001f) + currAngle = -currAngle; + + // - add our input angle to the total rotation + + rotAngle = currAngle + a; + + // - create a new vector with the correct rotation + + vtemp.x = cos((rotAngle) * PI/180); + vtemp.y = sin((rotAngle) * PI/180); + vtemp.Normalize(); + + // - this new vector is perpendicular to our result + + vtemp = vtemp ^ intoScreen; + vtemp.Normalize(); + + // - make sure that we stay the same distance away from the + // pivot point + + vtemp *= scale; + vtemp *= s; + + // - adding the pivot point to our vector gives us the correct + // result + + vtemp += u; + + x = vtemp.x; + y = vtemp.y; + z = vtemp.z; +} + +#endif + diff --git a/libraries/pmrt/irtrack/physWrapper.cpp b/libraries/pmrt/irtrack/physWrapper.cpp new file mode 100755 index 0000000..ffba343 --- /dev/null +++ b/libraries/pmrt/irtrack/physWrapper.cpp @@ -0,0 +1,364 @@ +// ------------------------------------------------------------------- +// physWrapper.cpp + +#include +#include "physVector.h" +#include "physLine.h" + +// ------------------------------------------------------------------- + +int checkCollision(Line l1, Line l2, double &d, Vector &r, Vector &n, Vector &rf, double &nd); +extern "C" int checkCol(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); extern "C" void pw_rotatePoint(float x0, float y0, float x1, float y1, double a, float *rx, float *ry); +extern "C" void pw_rotatePointScale(float x0, float y0, float x1, float y1, double a, float s, float *rx, float *ry); +extern "C" void pw_projectSkirt(float ax, float ay + , float lx0, float ly0, float lx1, float ly1 + , float *px0, float *py0, float *px1, float *py1); + +extern "C" float pw_dot_product(float x0, float y0, float x1, float y1); + +extern "C" float pw_angle_between(float x0, float y0, float x1, float y1, float x2, float y2); + +void projectSkirt(Vector a, Line l, Line *lproj); + +// ------------------------------------------------------------------- + +int checkCol(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) +{ + Vector p0((double)x0, (double)y0, 0); + Vector p1((double)x1, (double)y1, 0); + Vector p2((double)x2, (double)y2, 0); + Vector p3((double)x3, (double)y3, 0); + Vector r, n, rf; + double d; + + p0.x = x0; + p0.y = y0; + p1.x = x1; + p1.y = y1; + p2.x = x2; + p2.y = y2; + p3.x = x3; + p3.y = y3; + + //printf("%2.2f, %2.2f, %2.2f, %2.2f, %2.2f, %2.2f, %2.2f, %2.2f \n", + // x0, y0, x1, y1, x2, y2, x3, y3); + + //printf("(%2.2f, %2.2f) -> (%2.2f, %2.2f) : (%2.2f, %2.2f) -> (%2.2f, %2.2f)\n" + // , p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y); + + return checkCollision(Line(p0, p1), Line(p2, p3), d, r, n, rf, d); +} + +// ------------------------------------------------------------------- + +float pw_dot_product(float x0, float y0, float x1, float y1) +{ + double d, a; + Vector v0((double)x0, (double)y0, 0); + Vector v1((double)x1, (double)y1, 0); + + v0.Normalize(); + v1.Normalize(); + + d = (float)(v0 * v1); + //a = acos(v0 * v1) * (180 / PI); + + //printf("%2.2f, %2.2f, %2.2f, %2.2f\n", x0, y0, x1, y1); + + return d;///(float)a; +} + +// ------------------------------------------------------------------- + +float pw_angle_between(float x0, float y0, float x1, float y1, float x2, float y2) +{ + Vector v0((double)(x1 - x0), (double)(y1 - y0), 0); + Vector v1((double)(x2 - x0), (double)(y2 - y0), 0); + double angle; + + v0.Normalize(); + v1.Normalize(); + + angle = acos(v0 * v1) * (180 / PI); + + return (float)angle; +} + +// ------------------------------------------------------------------- +// - rotate point (x0,y0) a degrees around point (x1, y1), and return +// the result as (rx, ry) + +void pw_rotatePoint(float x0, float y0, float x1, float y1, double a, float *rx, float *ry) +{ + Vector v1(x0, y0, 0); + Vector v2(x1, y1, 0); + + v1.rotate2d(a, v2); + + *rx = v1.x; + *ry = v1.y; +} + +void pw_rotatePointScale(float x0, float y0, float x1, float y1, double a, float s, float *rx, float *ry) +{ + Vector v1(x0, y0, 0); + Vector v2(x1, y1, 0); + + v1.rotate2dS(a, s, v2); + + *rx = v1.x; + *ry = v1.y; +} + +// ------------------------------------------------------------------- + +void pw_projectSkirt(float ax, float ay + , float lx0, float ly0, float lx1, float ly1 + , float *px0, float *py0, float *px1, float *py1) +{ + Vector a(ax, ay, 0); + Line l(Vector(lx0, ly0, 0), Vector(lx1, ly1, 0)); + Line lproj; + + projectSkirt(a, l, &lproj); + + *px0 = lproj.a.x; + *py0 = lproj.a.y; + *px1 = lproj.b.x; + *py1 = lproj.b.y; +} + +// ------------------------------------------------------------------- + +void projectSkirt(Vector a, Line l, Line *lproj) +{ + lproj->a = (l.a - a) * 2; + lproj->b = (l.b - a) * 2; +} + +// ------------------------------------------------------------------- +// checkCollision +// +// - this computes the intersection (if any) between line segments +// l1 and l2. +// +// d : collision distance +// r : collision point +// n : collision normal +// rf : reflection vector + +int checkCollision(Line l1, Line l2, double &d, Vector &r, Vector &n, Vector &rf, double &nd) +{ + double dist; // - collision distance along l1's plane + Vector v1, v2; // - vectors corresponding to the two lines + Vector v1n; // - v1's normal vector + Vector intoScreen(0, 0, 1); + Vector vUp(0, -1, 0); + Vector v2Extend; + Vector v1Extend; + Vector vtemp; + Vector result; + double rAngle, nAngle; + + // - create vectors v1 and v2 + + v1 = l1.b - l1.a; + v2 = l2.b - l2.a; + + // /////////////////////////////////////////////////////////////// + + Point v1A, v1B, v2A, v2B; + int numPoints = 0; + + // - this optimization assumes that the first, static line is larger + // than the line that is in motion against it + + if (0)//userBoundsCheck) + { + // - create a bounding box for each of the two lines + + v1A.x = l1.a.x; + v1B.x = l1.b.x; + if (l1.b.x < v1A.x) + { + v1A.x = l1.b.x; + v1B.x = l1.a.x; + } + + v1A.y = l1.a.y; + v1B.y = l1.b.y; + if (l1.b.y < v1A.y) + { + v1A.y = l1.b.y; + v1B.y = l1.a.y; + } + + v2A.x = l2.a.x; + v2B.x = l2.b.x; + if (l2.b.x < v2A.x) + { + v2A.x = l2.b.x; + v2B.x = l2.a.x; + } + + v2A.y = l2.a.y; + v2B.y = l2.b.y; + if (l2.b.y < v2A.y) + { + v2A.y = l2.b.y; + v2B.y = l2.a.y; + } + + // - determine if these two boxes intersect each other + + if ((v2A.x >= v1A.x) && (v2A.x <= v1B.x) && (v2A.y >= v1A.y) && (v2A.y <= v1B.y)) + numPoints++; + + if ((v2B.x >= v1A.x) && (v2B.x <= v1B.x) && (v2B.y >= v1A.y) && (v2B.y <= v1B.y)) + numPoints++; + + // - if v1 happens to be flat, we should give a point just to be sure + + if (v1A.y == v1B.y) + numPoints++; + + // - least one endpoint of the smaller line must fit inside the bounding + // box described by the first, larger line + + if (numPoints == 0) + return 0; + } + + // /////////////////////////////////////////////////////////////// + + // - determine if the two lines are parallel + + if (((v1 * v2) < 0) && ((v1 * v2) > -0)) + { + return 0; + } + + // - create v1's normal vector by calculating the cross-product + // between v1 and a vector pointing into the screen + + v1n = v1 ^ intoScreen; + v1n.Normalize(); + + // - if the angle between v2 and -v1n is greater than 90, that means that we cannot + // have a collision + + rAngle = acos(v2 * -v1n) * (180 / PI); + if (rAngle > 90) + return 0; + + // - calculate the collision distance + + dist = (v1n * (l1.a - l2.a)) / (v1n * v2); + + // - if this distance is negative, there was no collision + + if (dist < 0) + return 0; + + // - alternatively, if the distance is greater than 1 + // we are too far ahead for a collision + + if (dist > 1) + return 0; + + // - it looks like we have an intersection. + // extend v2 by dist to find the collision point + + v2Extend = v2 * dist; + result = l2.a + v2Extend; + + // - calculate how far v1 has to extend to reach + // the collision point + + v1Extend = result - l1.a; + + // - if v1 has to extend farther than its length, that + // means that this is an invalid collision + + if (v1Extend.Magnitude() > v1.Magnitude()) + return 0; + + // - there is still a chance that v1 extends less than its + // length, but in the opposite direction. if the normalized + // versions of v1 and v1Extend add up to zero, we know that + // we are facing the wrong way. + + v1Extend.Normalize(); + v1.Normalize(); + vtemp = v1Extend + v1; + + if (vtemp.Magnitude() < 0.001f) + return 0; + + // - report the collision results + + r = result; + d = dist; + + // - report the surface normal + + n = v1n; + + // - calculate the angle between the v2 and v1's normal, + // as well as the angle between v1's normal and the "up" vector + + v2.Normalize(); + // vUp.Normalize(); <- already normalized by definition + + // - calculating the dot products on the "outside" as doubles eliminates + // an error in which the value, calculated as a float, becomes undefined + // as it approaches 1.0. + + //tVal = (v1n * -v2); + rAngle = acos(v1n * -v2) * (180 / PI); + + //tVal = (v1n * vUp); + nAngle = acos(v1n * vUp) * (180 / PI); + + // - check the winding of the angle between v2 and v1n. + // if it results in negative cross product (one that goes into + // the screen), the angle should be negative + + vtemp = v1n ^ -v2; + if (vtemp.z < 0.001f) + rAngle = -rAngle; + + // - also check the winding (in the opposite direction) of v1n and the + // "up" vector. we have the size of the angle, but not the correct + // polarity. + + vtemp = v1n ^ vUp; + if (vtemp.z > 0.001f) + nAngle = -nAngle; + + // - now we create a rotated vector using the calculated angle + + nAngle -= rAngle; + + vtemp.x = cos((nAngle) * PI/180); + vtemp.y = sin((nAngle) * PI/180); + vtemp.Normalize(); + + // - that rotated vector is perpendicular to our reflection + // vector, so we calculate this perpendicular result and return + // it as our reflection vector + + rf = vtemp ^ intoScreen; + rf.Normalize(); + + // - if the angle between the reflection vector and v1n is greater + // than 90 degrees, we know that this is not a well-defined + // collision + + rAngle = acos(rf * v1n) * (180 / PI); + //printf("rAngle = %2.2f\n", rAngle); + if (rAngle > 90) + return 0; + + return 1; +} diff --git a/libraries/pmrt/irtrack/physWrapper.h b/libraries/pmrt/irtrack/physWrapper.h new file mode 100755 index 0000000..9a9283f --- /dev/null +++ b/libraries/pmrt/irtrack/physWrapper.h @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------- +// physWrapper.h + +#ifndef _PHYSWRAPPER_H_ +#define _PHYSWRAPPER_H_ + +// ------------------------------------------------------------------- + +extern int checkCol(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); +extern void pw_rotatePoint(float x0, float y0, float x1, float y1, double a, float *rx, float *ry); +extern void pw_rotatePointScale(float x0, float y0, float x1, float y1, double a, float s, float *rx, float *ry); +extern void pw_projectSkirt(float ax, float ay + , float lx0, float ly0, float lx1, float ly1 + , float *px0, float *py0, float *px1, float *py1); + +extern float pw_dot_product(float x0, float y0, float x1, float y1); + +extern float pw_angle_between(float x0, float y0, float x1, float y1, float x2, float y2); + +// ------------------------------------------------------------------- + +#endif diff --git a/libraries/pmrt/irtrack/physWrapper.o b/libraries/pmrt/irtrack/physWrapper.o new file mode 100644 index 0000000..4c3f679 Binary files /dev/null and b/libraries/pmrt/irtrack/physWrapper.o differ diff --git a/libraries/pmrt/irtrack/serial.c b/libraries/pmrt/irtrack/serial.c new file mode 100755 index 0000000..63ca3c4 --- /dev/null +++ b/libraries/pmrt/irtrack/serial.c @@ -0,0 +1,1412 @@ +// ------------------------------------------------------------------- +// serial.c + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "irtrack.h" +#include "serial.h" +// interface to libusb +#include "usb.h" + +#define _POSIX_SOURCE 1 + +// ------------------------------------------------------------------- + +void usb_read_thread(void *ptr); +void serial_read_thread_led(void *ptr); +int readNBytes(int fd, int bytes, unsigned char *buf, int offset); +void serial_parse_rx(unsigned char *buf, int length, int thread_index); + +unsigned char crc_buffer(unsigned char *buf, int length); + +// ------------------------------------------------------------------- + +int fd[SERIAL_MAX_PLAYERS]; +char ftdi_ser[SERIAL_MAX_PLAYERS][16]; // holds the uart-bridge serial numbers +char gun_tty[SERIAL_MAX_PLAYERS][16]; // holds the uart-bridge serial numbers + +int fd_thread_active[SERIAL_MAX_PLAYERS]; + +pthread_t read_thread[SERIAL_MAX_PLAYERS]; +pthread_attr_t read_attr; +int read_thread_exit = 0; +int read_thread_restart = 0; +int read_thread_done = 1; + +int usb_quitting = 0; + +int usb_serial_error = 0; + +int serial_usb_init = 0; + +LedPointType led_dat[SERIAL_MAX_PLAYERS][MAX_LEDS]; +IrGunStatus gun_status[SERIAL_MAX_PLAYERS]; + +int num_leds[SERIAL_MAX_PLAYERS]; +int sample_num[SERIAL_MAX_PLAYERS]; +int switch_count[SERIAL_MAX_PLAYERS][3]; +int switch_state[SERIAL_MAX_PLAYERS][3]; + +char cam_reg_data[SERIAL_MAX_PLAYERS][4]; + +int serial_err_status = 0; + +// common, internal fxns +int openpipe(void); + +SerialConnectionType sconn[2]; + +/********* LIB USB GLOBALS *******/ +usb_dev_handle *dev = NULL; + +// unique Raw Thrills USBWD vid:pid +#define MY_VID 0x0C70 +#define MY_PID 0x0775 + +#define EP_IN 0x81 +#define EP_OUT 0x02 + +#define EP_GUN_IN 0x81 +#define EP_MSG_OUT 0x02 +#define EP_MSG_IN 0x81 // 0x83 -- can't get ep3 to work + +#define MAX_RE_REQUESTS 2 + +#define BULK_DATA_LEN 64 +#define NUM_BYTES 64 + +unsigned char bulkdata[BULK_DATA_LEN]; +unsigned char bulkrd[BULK_DATA_LEN]; +unsigned char usb_ctrl_buf[BULK_DATA_LEN]; +unsigned char usb_stat_buf[BULK_DATA_LEN]; +unsigned char crc_in_err[256]; //counter for each type of recevied message + +unsigned char G_MCU_VERSION_L; +unsigned char G_MCU_VERSION_H; +unsigned char G_FPGA_VERSION_L; +unsigned char G_FPGA_VERSION_H; + +unsigned char lock_ctrl_buf; + +#define MAX_GWB_BUFFERED_MSGS 32 +int gwbBufMessageNum = 0; +GwbMsgType gwbBufMessage[MAX_GWB_BUFFERED_MSGS]; + +char *filename_guntable = { "/bbsuser/ftdi_gun.txt" }; +char *filename_ttytable = { "/bbsuser/ftdi_tty.txt" }; +char *filename_gunscript = { "/rawsrc/dipsw/gunslink.sh" }; + +/********* END GLOBALS *******/ + +int send_ctrl_packet = 0; +int send_ctrl_packet_retry = 0; + +// ------------------------------------------------------------------- +// - add a pc->gwb message to a buffer so it can be sent later + +int gwb_buffer_message(int type, unsigned char *data) +{ + // - don't buffer two identical messages in a row! + + if (gwbBufMessageNum) + if (gwbBufMessage[gwbBufMessageNum - 1].type == type) + return 0; + + if (gwbBufMessageNum >= (MAX_GWB_BUFFERED_MSGS - 1)) + { + irt_systemSLog("gwb_buffer_message error: too many stored messages\n"); + return 0; + } + + gwbBufMessage[gwbBufMessageNum].type = type; + + if (data) + memcpy(gwbBufMessage[gwbBufMessageNum].buf, data, sizeof(unsigned char) * 16); + else + memset(gwbBufMessage[gwbBufMessageNum].buf, 0, sizeof(unsigned char) * 16); + + gwbBufMessageNum++; + + return 1; +} + +// ------------------------------------------------------------------- +// - if there is at least one pc->gwb message in the buffer, + +int gwb_buffer_message_read(GwbMsgType *msg) +{ + int i; + + if (!gwbBufMessageNum) + return 0; + + // - copy the first message in the list + + msg->type = gwbBufMessage[0].type; + memcpy(msg->buf, gwbBufMessage[0].buf, sizeof(unsigned char) * 16); + + for (i = 0; i < (gwbBufMessageNum - 1); i++) + { + gwbBufMessage[i].type = gwbBufMessage[i + 1].type; + memcpy(gwbBufMessage[i].buf, gwbBufMessage[i + 1].buf, sizeof(unsigned char) * 16); + } + + gwbBufMessageNum--; + + return 1; +} + +// ------------------------------------------------------------------- +// - check to see if the serial connection at the specified index is +// valid. + +int serial_is_open(int index) +{ + return sconn[index].active; + + //if (fd[index] == -1) + // return 0; + // + //return 1; +} + +//-------------------------------------------------------------------- + +int serial_sendmsg(int type, unsigned char *data, int player) +{ + unsigned char buf[128], tmp[16]; + unsigned char crc_calc; + int bytes; + + bytes = 0; + buf[0] = 'W'; + + switch(type){ + case SERIAL_TX_RESET_CAMERA: + buf[1] = '1'; + buf[2] = 'z'; //EOM + crc_calc = crc_buffer(buf, 3); + sprintf(tmp, "%02x", (0xff&crc_calc)); + buf[3]=tmp[0]; + buf[4]=tmp[1]; + bytes = 5; + break; + + case SERIAL_TX_SET_REGISTER: + buf[1] = '2'; + buf[2] = data[0]; + buf[3] = data[1]; + buf[4] = data[2]; + buf[5] = data[3]; + buf[6] = 'z'; //EOM + crc_calc = crc_buffer(buf, 7); + sprintf(tmp, "%02x", (0xff&crc_calc)); + buf[7]=tmp[0]; + buf[8]=tmp[1]; + bytes = 9; + break; + + case SERIAL_TX_DEFAULT_REGISTERS: + buf[1] = '3'; + buf[2] = 'z'; //EOM + crc_calc = crc_buffer(buf, 3); + sprintf(tmp, "%02x", (0xff&crc_calc)); + buf[3]=tmp[0]; + buf[4]=tmp[1]; + bytes = 5; + break; + + default: + return 0; + break; + } + + // finally, send off the message + write(fd[player], &buf, bytes); +} + + +//-------------------------------------------------------------------- + +int usb_gwb_handle_in_err(unsigned char msg_type) +{ + switch(msg_type) + { + // switch message error, ask for another + case 0x03: + usb_ctrl_buf[0] = 0x03; + usb_ctrl_buf[1] = SWITCH_AUTO_INTERVAL; + break; + + default: + return 0; + } + + // 8-bit CRC our output buffer + usb_ctrl_buf[63] = crc_buffer(usb_ctrl_buf, 63); // CRC first 63 bytes (not last one #64) + send_ctrl_packet = 1; + send_ctrl_packet_retry = 0; + + return 1; +} + +// ------------------------------------------------------------------- +// - open the USB connection to the GWB, launch an endpoint thread for +// USB transactions + +int usb_gwb_init(void) +{ + int ret, i; + static ReadThreadDataType rd[2]; + + // open the usb interface (libusb) + + ret = openpipe(); + if(ret < 0) + { + irt_systemSLog("usb_gwb_init: error USB pipe: %i\n", ret); + return -1; // error + } + + // pass vars to thread + + rd[0].index = 0; + rd[1].index = 1; + + rd[0].ep = 0x81; + rd[1].ep = 0x82; + + // - spawn a thread to monitor the usb connections + + read_thread_exit = 0; + + pthread_attr_init(&read_attr); + pthread_attr_setdetachstate(&read_attr, PTHREAD_CREATE_DETACHED); + //pthread_create(&read_thread, &read_attr, (void *)usb_read_thread, &rd[0]); + + pthread_attr_destroy(&read_attr); + + read_thread_restart = 0; + + return 1; +} + +// -------------------------------------------------------------------------------------------------------------------------------------- +// +// +// ***** SERIAL READ THREAD ********* +// +// +// -------------------------------------------------------------------------------------------------------------------------------------- +void serial_read_thread_led(void *ptr) +{ + char chSerial[SERIAL_MAX_PLAYERS][32]; + int thread_fd, thread_index; + unsigned char buf[256+64]; + unsigned char crc_buf[64]; + char *name, chBuf[128]; + int i, j, k, nth, ledIndex; + int swCount[3]; + int x, y, s; + clock_t start, stop; + unsigned char crc_calc; + unsigned char crc_rcvd; + int buf_index; + int msg_progress; + int close_thread, err_code, reconnect, found, match; + FILE *fp; + + thread_fd = ((ReadThreadDataType*)ptr)->fd; + thread_index = ((ReadThreadDataType*)ptr)->index; + name = ((ReadThreadDataType*)ptr)->name; + + printf("serial_read_thread_led: spawned. thread_fd = %i, thread_index = %i, name = %s\n", thread_fd, thread_index, name); + + // - signal that this thread is active + + fd_thread_active[thread_index] = 1; + close_thread = 0; + + // - until we get the signal to exit, read in data + + while (!read_thread_exit && !close_thread) + { + err_code = 0; + err_code = readNBytes(thread_fd, 1, buf,0); + + // - if the byte isn't the header, this thread will keep reading + // individual bytes until the header is found. + // + + // Header of Gun to PC messages is 'X', 'Y' or 'Z' (all uppercase) + if((buf[0] == 'X') || (buf[0] == 'Y') || (buf[0] == 'Z')) + { + buf_index=1; + msg_progress=SERIAL_MESSAGE_IN_PROGRESS; + + // + // keep reading bytes (one at a time) until we get to the end of the message + // if a header shows up, start reading message again...glitch in transmission + // + while(msg_progress==SERIAL_MESSAGE_IN_PROGRESS) + { + err_code = readNBytes(thread_fd, 1, buf, buf_index); + + if((buf[buf_index] == 'X') || (buf[buf_index] == 'Y') || (buf[buf_index] == 'Z')){ + msg_progress = SERIAL_MESSAGE_ERROR; + }else if(buf[buf_index] == 'z'){ // End of Message Body + buf_index++; + + // read in the two ASCII byte CRC8 (8 binary bits) + err_code = readNBytes(thread_fd, 2, crc_buf,0); + crc_rcvd = hex2int(crc_buf, 2); + + // calculate the CRC8 of the buffer + crc_calc = crc_buffer(buf, buf_index); + + // check that the two CRC8's match + if((0xff&crc_rcvd) == (0xff&crc_calc)){ + msg_progress = SERIAL_MESSAGE_COMPLETE; + }else{ + msg_progress = SERIAL_MESSAGE_CRC_ERROR; + } + }else{ + // increase the buf index and read another byte! + if(buf_index++ >= 256){ + msg_progress = SERIAL_MESSAGE_ERROR; + } + } + } + + + // + // check up on the completed message's status + // + switch(msg_progress){ + case SERIAL_MESSAGE_COMPLETE: + serial_parse_rx(buf, buf_index, thread_index); + break; + case SERIAL_MESSAGE_ERROR: + //what should we do?????? + break; + case SERIAL_MESSAGE_CRC_ERROR: + //what should we do????? + break; + default: + break; + } + } + + if (err_code) + { + irt_systemSLog("[%s, %i] GUN CONNECTION ERROR.\n" + , sconn[thread_index].name, thread_index); + //close_thread = 1; + + // TODO: reopen the next available gun at the current thread_fd and current thread_index + + close(thread_fd); + sconn[thread_index].active = 0; + + reconnect = 0; + while (!reconnect) + { + // - cheap hack to make sure that the script isn't spammed + + sleep(5 + thread_index); + + printf("[%s, %i] running gun link script, searching for unconnected gun...\n" + , sconn[thread_index].name, thread_index); + + sprintf(chBuf, "%s > %s", filename_gunscript, filename_ttytable); + system(chBuf); + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + memset(chSerial[i], 0, 32); + + + if (fp = fopen(filename_ttytable, "rt")) + { + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + fscanf(fp, "%s", chSerial[i]); + + fclose(fp); + } + + // - try to reconnect in two steps: looking for an inactive + // connection of the same name, then any connection + + reconnect = 0; + for (j = 0; j < 2; j++) + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + if (!strcmp(chSerial[i], "-1")) + continue; + + if (j == 0) + match = !strcmp(chSerial[i], sconn[thread_index].name); + else + match = (serial_is_name_active(chSerial[i]) == -1); + + if (match) + { + printf("match on j = %i\n", j); + + // - the port number is the nth valid entry of the + // gun table file that our serial number matches with + + nth = 0; + for (k = 0; k < i; k++) + { + if (!strcmp(chSerial[k], "-1")) + continue; + + nth++; + } + + sprintf(chBuf, "/dev/irgun%i", nth);//i); + printf("[%s, %i] trying port %s\n" + , sconn[thread_index].name, thread_index, chBuf); + + thread_fd = open(chBuf, O_RDWR | O_NOCTTY); + + if (!serial_set_options(thread_fd)) + { + printf("could not open port %s\n", chBuf); + } + else + { + // TODO: we should probably do this, since if we connect + // on a j == 1 match (a new connection with a new name), this + // name must be assigned. + + sprintf(sconn[thread_index].name, chSerial[i]); + sconn[thread_index].active = 1; + reconnect = 1; + } + } + } + + if (reconnect) + { + irt_systemSLog("[%s, %i] GUN CONNECTION RE-ESTABLISHED.\n", sconn[thread_index].name, thread_index); + } + else + { + printf("[%s, %i] fail, waiting for retry.\n", sconn[thread_index].name, thread_index); + } + } + } + } + + // - close out the connection + + close(thread_fd); + + // - signal that this thread is no longer running + + fd_thread_active[thread_index] = 0; + + printf("serial_read_thread_led: exited. thread_fd = %i, thread_index = %i, name = %s\n", thread_fd, thread_index, name); +} + +// ------------------------------------------------------------------- + +int serial_is_name_active(char *name) +{ + int i; + + for (i = 0; i < 2; i++) + { + if (strcmp(sconn[i].name, name)) + continue; + + if (sconn[i].active) + { + return 1; + } + else + return 0; + } + + // - name not found + + return -1; +} + +// ------------------------------------------------------------------- + +void serial_parse_rx(unsigned char *buf, int length, int thread_index) +{ + unsigned char tmp_buf[16]; + int i, ledIndex; + int swCount[3]; + int x, y, s; + int offset; + int temp; + unsigned char reg_buf_fpga[32]; + unsigned char reg_buf_cam[32]; + + if (buf[0] == SERIAL_HEADER_POINT_DATA) + { + offset = 1; + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + + num_leds[thread_index] = hex2int(tmp_buf, 2); + + // check if appropriate # of leds was sent + if(num_leds[thread_index] > MAX_LEDS) + { + //error has occurred, now what? + return; + } + + ledIndex = 0; + for (i = 0; i < num_leds[thread_index]; i++) + { + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + tmp_buf[2]=buf[offset++]; + y = hex2int(tmp_buf, 3); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + tmp_buf[2]=buf[offset++]; + x = hex2int(tmp_buf, 3); + + + // - don't fill in values if we are over our max number + if (ledIndex < MAX_LEDS) + { + led_dat[thread_index][ledIndex].x = (float)x; + led_dat[thread_index][ledIndex].y = (float)y; + led_dat[thread_index][ledIndex].s = 30.0f; + } + + ledIndex++; + } + + // + // - there is 1 hex value for each switch count + // + tmp_buf[0]=buf[offset++]; + swCount[0] = hex2int(tmp_buf, 1); + + tmp_buf[0]=buf[offset++]; + swCount[1] = hex2int(tmp_buf, 1); + + tmp_buf[0]=buf[offset++]; + swCount[2] = hex2int(tmp_buf, 1); + + // ------ + switch_count[thread_index][0] = swCount[0]/2; + switch_count[thread_index][1] = swCount[1]/2; + switch_count[thread_index][2] = swCount[2]/2; + + switch_state[thread_index][0] = 0x01 & swCount[0]; + switch_state[thread_index][1] = 0x01 & swCount[1]; + switch_state[thread_index][2] = 0x01 & swCount[2]; + + // - clear out the remaining space + num_leds[thread_index] = ledIndex; + + if (num_leds[thread_index] < MAX_LEDS) + { + for (i = num_leds[thread_index]; i < MAX_LEDS; i++) + { + led_dat[thread_index][i].x = 0; + led_dat[thread_index][i].y = 0; + led_dat[thread_index][i].s = 0; + } + } + + if (num_leds[thread_index] > MAX_LEDS) + num_leds[thread_index] = MAX_LEDS; + + // - increment the sample number + sample_num[thread_index]++; + } + else if(buf[0] == SERIAL_HEADER_STATUS) + { + // ****************** FINISH ME!!! ******************** + //printf("PLAYER%d - got SERIAL_HEADER_STATUS message!\n", thread_index); + + offset = 1; + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + tmp_buf[2]=buf[offset++]; + tmp_buf[3]=buf[offset++]; + temp = hex2int(tmp_buf, 4); + gun_status[thread_index].frames = temp; + //printf("%8d : Good Camera Frames\n", temp); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + tmp_buf[2]=buf[offset++]; + tmp_buf[3]=buf[offset++]; + temp = hex2int(tmp_buf, 4); + gun_status[thread_index].glitches = temp; + //printf("%8d : HYSNC & VSYNC Glitch Count\n", temp); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + tmp_buf[2]=buf[offset++]; + tmp_buf[3]=buf[offset++]; + temp = hex2int(tmp_buf, 4); + gun_status[thread_index].pBlaze_wd = temp; + //printf("%8d : pBlaze WD's since power-on\n", temp); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + tmp_buf[2]=buf[offset++]; + tmp_buf[3]=buf[offset++]; + temp = hex2int(tmp_buf, 4); + gun_status[thread_index].pBlaze_pc = (0xffff & temp); + //printf("%8x : PC @ last pBlaze WD\n", (0xffff & temp)); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + temp = hex2int(tmp_buf, 2); + gun_status[thread_index].stuckbits = (0xff & temp); + //printf("%8x : Stuck Bits\n", (0xff & temp)); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + temp = hex2int(tmp_buf, 2); + gun_status[thread_index].version = (0xff & temp); + //printf("%8x : Version #\n", (0xff & temp)); + + G_FPGA_VERSION_L = temp; + + irt_systemSetFirmware(G_FPGA_VERSION_L, thread_index); + } + else if (buf[0] == SERIAL_HEADER_REG_DATA) + { + // ****************** FINISH ME!!! ******************** + //printf("PLAYER%d - got gun SERIAL_HEADER_REG_DATA message!\n", thread_index); + offset = 1; + + for(i=0; i < 16; i++) + { + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + reg_buf_fpga[i*2] = hex2int(tmp_buf, 2); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + reg_buf_fpga[i*2+1] = hex2int(tmp_buf, 2); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + reg_buf_cam[i*2] = hex2int(tmp_buf, 2); + + tmp_buf[0]=buf[offset++]; + tmp_buf[1]=buf[offset++]; + reg_buf_cam[i*2+1] = hex2int(tmp_buf, 2); + } + + irt_systemSetRegisterStatus(reg_buf_fpga, reg_buf_cam, thread_index); + } +} + +// ------------------------------------------------------------------- + +int serial_set_options(int desc) +{ + struct termios options; + + tcgetattr(desc, &options); + + cfsetispeed(&options, SERIAL_BAUD_RATE); + cfsetospeed(&options, SERIAL_BAUD_RATE); + + options.c_iflag = 0; + options.c_oflag = 0; + options.c_cflag &= ~PARENB; + options.c_cflag &= ~CSTOPB; + options.c_cflag &= ~CSIZE; + options.c_cflag |= CS8; + options.c_cflag &= ~CRTSCTS; + options.c_lflag &= ~(ICANON | ECHO | ISIG); + + tcflush(desc,TCIOFLUSH); + + if (tcsetattr(desc, TCSANOW, &options) != 0) + return 0; + + return 1; +} + +// ------------------------------------------------------------------- + +int serial_close(void) +{ + int i; + + // - signal for the read thread to close + + read_thread_exit = 1; + + // - one full second should be long enough for the serial read + // threads to finish up. (am i wrong?) + + sleep(1); + + // - close the serial port connections + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + if (fd[i] != -1) + { + close(fd[i]); + fd[i] = -1; + } + } +} + +// ------------------------------------------------------------------- +// - check the gun serial number table to make sure that there is a +// match for each serial number in the tty table + +int serial_guntable_check(void) +{ + char chSerial[SERIAL_MAX_PLAYERS][32]; + char chTTY[SERIAL_MAX_PLAYERS][32]; + char chBuf[128]; + FILE *fp; + int i, j, numguns, matches, ttyguns; + + // - open the gun serial number file. if there is no file, create + // a new one. note that this new file will have the guns in a + // random order. + + if (!(fp = fopen(filename_guntable, "rt"))) + { + printf("serial_guntable_check: no gun table file. creating new one\n"); + sprintf(chBuf, "%s > %s", filename_gunscript, filename_guntable); + system(chBuf); + return -1; + } + + // - if there was a file, read in each of the serial numbers + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + memset(chSerial[i], 0, 32); + memset(chTTY[i], 0, 32); + } + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + fscanf(fp, "%s", chSerial[i]); + + fclose(fp); + + // - read in the table of serial numbers that are currently attached + // to each serial port. this file is always generated by the + // script that boots the game. + + if (!(fp = fopen(filename_ttytable, "rt"))) + { + printf("unable to open tty table file\n"); + return -2; + } + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + fscanf(fp, "%s", chTTY[i]); + + fclose(fp); + + // - count the number of gun serial numbers in the table. this is + // the number of guns that are connected to the system. + // TODO: there needs to be a way to distinguish between an IR gun + // and another device that shows up on a /dev/ttyUSB node! + + numguns = 0; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + if (strcmp(chSerial[i], "-1")) + { + numguns++; + } + } + + ttyguns = 0; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + if (strcmp(chTTY[i], "-1")) + { + ttyguns++; + } + } + + // - for each of the serial numbers in the gun table, make + // sure that there is a match in the tty table + + matches = 0; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + for (j = 0; j < SERIAL_MAX_PLAYERS; j++) + { + if (!strcmp(chSerial[i], chTTY[j]) && strcmp(chSerial[i], "-1")) + matches++; + } + } + + // - if we do not have a match for all of the guns, we are going + // to need a new gun serial numbers table. this may occur if + // one of the guns has been replaced. + + if ((numguns != matches) || (numguns != ttyguns)) + { + printf("numguns %i != matches %i, or != ttyguns = %i\n", numguns, matches, ttyguns); + sprintf(chBuf, "%s > %s", filename_gunscript, filename_guntable); + system(chBuf); + return -2; + } +} + +// ------------------------------------------------------------------- + +int serial_get_err_status(void) +{ + return serial_err_status; +} + +// ------------------------------------------------------------------- +// - open a serial port connection for one or more ports, and spawn +// a read thread + +int serial_init(void) +{ + static ReadThreadDataType rd[SERIAL_MAX_PLAYERS]; + static ReadThreadDataType rd_extra; + //char *pname[SERIAL_MAX_PLAYERS]; + char pname[SERIAL_MAX_PLAYERS][32]; + int pname_thread_index[SERIAL_MAX_PLAYERS]; // for the given port, what player number is it? + int portnum[SERIAL_MAX_PLAYERS]; + char ftdi_tty[SERIAL_MAX_PLAYERS][16]; // holds the uart-bridge serial numbers + int i,j,c,v; + int lowest; + FILE *fp; + + for (i = 0; i < 2; i++) + { + sprintf(sconn[i].name, "(null)"); + sconn[i].active = 0; + } + + read_thread_restart = 0; + + // - monitor the guntable check error code. if the code is negative, + // the game will prompt the operator to re-calibrate the guns + + serial_err_status = serial_guntable_check(); + + // + // KTU 7-28-2008 + // Use a File to Store the serial number + // of the gun associated with player 1, player 2, etc. + // + + fp = fopen(filename_guntable, "r"); + if (fp == NULL) + { + printf("%s init file not found\n", filename_guntable); + return -1; + } + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + fscanf(fp, "%s", ftdi_ser[i]); + printf("ftdi_ser: |%s|\n", ftdi_ser[i]); + } + fclose(fp); + + fp = fopen(filename_ttytable, "r"); + if (fp == NULL) + { + printf("%s init file not found\n", filename_ttytable); + return -1; + } + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + fscanf(fp, "%s", gun_tty[i]); + printf("gun_tty: |%s|\n", gun_tty[i]); + } + fclose(fp); + + + // + // Now, Match up the serial numbers + // + + for(i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + *pname[i] = 0; + } + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + portnum[i] = -1; + + for (j = 0; j < SERIAL_MAX_PLAYERS; j++) + { + if (!strcmp(ftdi_ser[i], "-1")) + continue; + + if (strcmp(ftdi_ser[i], gun_tty[j]) == 0) + { + portnum[i] = j; + break; + } + } + } + + lowest = 999; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + if (portnum[i] == -1) + continue; + + if (portnum[i] < lowest) + lowest = portnum[i]; + } + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + if (portnum[i] != -1) + portnum[i] -= lowest; + + c = 0; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + for (j = 0; j < SERIAL_MAX_PLAYERS; j++) + { + if (!strcmp(ftdi_ser[i], "-1")) + continue; + + if (strcmp(ftdi_ser[i], gun_tty[j]) == 0) + { + sprintf(pname[i], "/dev/irgun%d", portnum[i]);//j);//c); + pname_thread_index[i] = i; + c++; + break; + } + } + } + + c = 0; + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + sample_num[i] = 0; + switch_count[i][0] = 0; + switch_count[i][1] = 0; + switch_count[i][2] = 0; + + fd[i] = -1; + if (*pname[i] != 0) + fd[i] = open(pname[i], O_RDWR | O_NOCTTY); + + if (pname[i] && (fd[i] == -1)) + { + printf("serial_init: error opening port %s\n", pname[i]); + } + else if (pname[i]) + { + fcntl(fd[i], F_SETFL, 0); + + printf("serial_init: %s opened as descriptor %i\n", pname[i], fd[i]); + + if (!serial_set_options(fd[i])) + { + printf("serial_init: could not set port options for %s\n", pname[i]); + close(fd[i]); + fd[i] = -1; + } + else + { + rd[i].fd = fd[i]; + rd[i].index = c; + sprintf(rd[i].name, ftdi_ser[i]); + + sconn[c].active = 1; + sprintf(sconn[c].name, rd[i].name); + + c++; + + // - for the "extra" read thread that may be created in the + // case that only one gun is active, it's thread index will + // be assigned to whatever this read connection ISN'T + + rd_extra.index = !rd[i].index; + } + } + } + + // - for each port that has been successfully opened, spawn a thread + // to continuously read and update LED data + + read_thread_exit = 0; + + c = 0; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + // clear the status of each gun + serial_clearGunStatus(i); + + if (fd[i] != -1) + { + pthread_attr_init(&read_attr); + pthread_attr_setdetachstate(&read_attr, PTHREAD_CREATE_DETACHED); + pthread_create(&read_thread[i], &read_attr, (void*)serial_read_thread_led, &rd[i]); + pthread_attr_destroy(&read_attr); + c++; + } + } + + /* + if (c == 1) + { + printf("booting with a single gun, spawning extra read thread\n"); + rd_extra.fd = -1; + sconn[rd_extra.index].active = 0; + sprintf(sconn[rd_extra.index].name, "(null)"); + pthread_attr_init(&read_attr); + pthread_attr_setdetachstate(&read_attr, PTHREAD_CREATE_DETACHED); + pthread_create(&read_thread[c], &read_attr, (void*)serial_read_thread_led, &rd_extra); + pthread_attr_destroy(&read_attr); + } + */ + + return 1; +} + + +// ------------------------------------------------------------------- + +int serial_get_led_data(int index, LedPointType *ldata) +{ + memcpy(ldata, led_dat[index], sizeof(LedPointType) * MAX_LEDS); + + if (num_leds[index] > MAX_LEDS) + return MAX_LEDS; + else + return num_leds[index]; +} + +// ------------------------------------------------------------------- + +int serial_getSampleNum(int gindex) +{ + return sample_num[gindex]; +} + +// ------------------------------------------------------------------- + +int readNBytes(int fd, int bytes, unsigned char *buf, int offset) +{ + int bytesRead, tries; + + bytesRead = 0; + tries = 0; + + // - it is possible that we are attempting to read a null file + // descriptor. if the system boots up with only one gun, a null + // read thread is initiated which searches for the second gun. + + if (fd == -1) + return -1; + + while (bytes) + { + bytesRead = read(fd, &buf[offset], bytes); + offset += bytesRead; + + if (bytesRead < 0) + bytesRead = 0; + + bytes -= bytesRead; + + // - the reads should be blocking, so if we attempt a lot + // of reads and we get a certain error value, we can + // assume that the connection is bad, and that we should + // try to restore it + + tries++; + if (tries == 100000) + { + tries = 0; + if (errno == 84) + return -1; + } + } + + return 0; +} + +// ------------------------------------------------------------------- + +int hex2int(unsigned char *text, int len) +{ + unsigned char buf[64]; + int res; + sprintf(buf, text); + buf[len] = '\0'; + res = (int)strtol(buf, NULL, 16); + return res; +} + +// ------------------------------------------------------------------- + +int serial_getSwitchCount(int gindex, int swnum) +{ + return switch_count[gindex][swnum]; +} + +// ------------------------------------------------------------------- + +int serial_getSwitchState(int gindex, int swnum) +{ + return switch_state[gindex][swnum]; +} + +// ------------------------------------------------------------------ + +IrGunStatus serial_getGunStatus(int gindex) +{ + return gun_status[gindex]; +} + +// ------------------------------------------------------------------ + +void serial_clearGunStatus(int gindex) +{ + gun_status[gindex].frames = 0; + gun_status[gindex].glitches = 0; + gun_status[gindex].pBlaze_wd = 0; + gun_status[gindex].pBlaze_pc = 0; + gun_status[gindex].stuckbits = 0; + gun_status[gindex].version = 0; +} + +// ------------------------------------------------------------------- + +int serial_shouldRestart(void) +{ + return read_thread_restart; +} + +// ------------------------------------------------------------------- +// Used by openpipe() to init the usb device + +usb_dev_handle *open_dev(void) +{ + struct usb_bus *bus; + struct usb_device *dev; + + for(bus = usb_get_busses(); bus; bus = bus->next) + { + for(dev = bus->devices; dev; dev = dev->next) + { + if ((dev->descriptor.idVendor == MY_VID) + && (dev->descriptor.idProduct == MY_PID)) + { + return usb_open(dev); + } + } + } + + return NULL; +} + +// ------------------------------------------------------------------ +// - detects the presence of the gun widget board by polling the usb +// bus for the specific vendor and product id + +int serial_detectGWB(void) +{ + struct usb_bus *bus; + struct usb_device *dev; + + if (!serial_usb_init) + { + usb_init(); + serial_usb_init = 1; + } + + usb_find_busses(); + usb_find_devices(); + + for (bus = usb_get_busses(); bus; bus = bus->next) + { + for (dev = bus->devices; dev; dev = dev->next) + { + if ((dev->descriptor.idVendor == MY_VID) + && (dev->descriptor.idProduct == MY_PID)) + return 1; + } + } + + return 0; +} + +// ------------------------------------------------------------------ +// +// Opens libusb interface to our device +// +// returns: 0 on success, -1 on error + +int openpipe(void) +{ + int ret = 0; + + if (!serial_usb_init) + { + usb_init(); + serial_usb_init = 1; + } + + usb_find_busses(); + usb_find_devices(); + + if (!(dev = open_dev())) + { + //irt_systemSLog("libusb: device not found!\n"); + return -1; + } + else + { + //irt_systemSLog("device found!\n"); + } + + ret = usb_set_configuration(dev, 1); + + if (ret < 0) + { + //irt_systemSLog("libusb: setting config 1 failed with %d\n", ret); + return -1; + } + //else + //irt_systemSLog("libusb: setting config 1 succeeded\n"); + + + ret = usb_claim_interface(dev, 0); + + if (ret < 0) + { + //irt_systemSLog("libusb: usb_claim_interface failed with %d\n", ret); + return -1; + } + //else + // irt_systemSLog("libusb: usb_claim_interface succeeded\n"); + + return 0; + +} + +// ------------------------------------------------------------------- + +unsigned char crc_buffer(unsigned char *buf, int length) +{ + unsigned char crc; + int i; + + crc = 0; + + for (i = 0; i < length; i++) + { + crc += buf[i]; + } + + return crc; +} + +// ------------------------------------------------------------------- +// serial_reverseInput +// +// - this function is called when it has been confirmed that the +// player 1 and player 2 guns have been inverted by the system. +// +// TODO: 1. reverse player 1 and player 2's entries in ftdi_gun.txt +// 2. close the serial port connections +// 3. reopen the serial port connections + +void serial_reverseInput(void) +{ + char chSerial[SERIAL_MAX_PLAYERS][16]; + char chBuf[16]; + FILE *fp; + int i, c, c2; + + irt_systemSLog("GUN ORDER REVERSED IN CALIBRATION\n"); + + // - read in the current player gun order + + if (!(fp = fopen(filename_guntable, "r"))) + { + printf("%s init file not found\n", filename_guntable); + return; + } + + c = 0; + c2 = 0; + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + { + fscanf(fp, "%s", chSerial[i]); + if (strcmp(chSerial[i], "-1") && !c) + { + c = i; + continue; + } + + if (c && strcmp(chSerial[i], "-1") && !c2) + { + c2 = i; + continue; + } + } + + fclose(fp); + + printf("reversing %s and %s\n", chSerial[c], chSerial[c2]); + + // - reverse the entires for player 1 and player 2 + + memcpy(chBuf, chSerial[c], 16); + memcpy(chSerial[c], chSerial[c2], 16); + memcpy(chSerial[c2], chBuf, 16); + + // - write out the new player gun order + + if (!(fp = fopen(filename_guntable, "wt"))) + { + printf("could not output to %s\n", filename_guntable); + return; + } + + for (i = 0; i < SERIAL_MAX_PLAYERS; i++) + fprintf(fp, "%s\n", chSerial[i]); + + fclose(fp); + + // - close out the gun system, which also closes the serial + // port connections + + irt_systemClose(); + + // - restart the system! + + irt_systemInit(); +} + +// EOF diff --git a/libraries/pmrt/irtrack/serial.h b/libraries/pmrt/irtrack/serial.h new file mode 100755 index 0000000..b812c10 --- /dev/null +++ b/libraries/pmrt/irtrack/serial.h @@ -0,0 +1,88 @@ +// ------------------------------------------------------------------- +// serial.h + +#ifndef _SERIAL_H_ +#define _SERIAL_H_ + +// ------------------------------------------------------------------- + +#define MAX_LEDS 100 +#define SERIAL_BAUD_RATE B230400//B460800 +#define SWITCH_AUTO_INTERVAL 5 + +#define SERIAL_MESSAGE_IN_PROGRESS 0 +#define SERIAL_MESSAGE_COMPLETE 1 +#define SERIAL_MESSAGE_ERROR 2 +#define SERIAL_MESSAGE_CRC_ERROR 3 + +#define SERIAL_TX_RESET_CAMERA 1 +#define SERIAL_TX_SET_REGISTER 2 +#define SERIAL_TX_DEFAULT_REGISTERS 3 + +#define SERIAL_HEADER_POINT_DATA 'X' +#define SERIAL_HEADER_STATUS 'Y' +#define SERIAL_HEADER_REG_DATA 'Z' + +// ------------------------------------------------------------------- + +typedef struct { + float x, y, s; +} LedPointType; + +typedef struct { + int fd, index, ep; + char name[32]; +} ReadThreadDataType; + +typedef struct { + int type; + char buf[16]; +} GwbMsgType; + +typedef struct { + char name[32]; // gun serial number + int active; // is the connection active? +} SerialConnectionType; + +// ------------------------------------------------------------------- + +enum { + GWB_MSG_CONFIG = 0, + GWB_MSG_GETFIRMWARE, + GWB_MSG_DEVICECTL, + GWB_MSG_GETSWITCH, + GWB_MSG_CAMERACTL, +}; + +// ------------------------------------------------------------------- + +int serial_init(void); +int serial_close(void); +void serial_get_data(int *sdata[]); +int serial_is_open(int index); +int serial_sendmsg(int type, unsigned char *data, int player); +int serial_get_err_status(void); + +//int usb_gwb_test_send(unsigned char); +//int usb_gwb_sendmsg(int type, unsigned char *data); + +int serial_get_led_data(int index, LedPointType *ldata); + +int hex2int(unsigned char *text, int len); + +int serial_getSampleNum(int gindex); +IrGunStatus serial_getGunStatus(int gindex); +void serial_clearGunStatus(int gindex); +int serial_getSwitchCount(int gindex, int swnum); +int serial_getSwitchState(int gindex, int swnum); + +int serial_shouldRestart(void); +int serial_detectGWB(void); + +int serial_is_name_active(char *name); + +void serial_reverseInput(void); + +// ------------------------------------------------------------------- + +#endif diff --git a/libraries/pmrt/irtrack/serial.o b/libraries/pmrt/irtrack/serial.o new file mode 100644 index 0000000..a29e6a5 Binary files /dev/null and b/libraries/pmrt/irtrack/serial.o differ diff --git a/libraries/pmrt/irtrack/vssver.scc b/libraries/pmrt/irtrack/vssver.scc new file mode 100755 index 0000000..9686a2a Binary files /dev/null and b/libraries/pmrt/irtrack/vssver.scc differ diff --git a/libraries/pmrt/jamma/.map b/libraries/pmrt/jamma/.map new file mode 100644 index 0000000..e57c593 --- /dev/null +++ b/libraries/pmrt/jamma/.map @@ -0,0 +1,483 @@ +Archive member included because of file (symbol) + +libjamma.a(jamma.o) jammatest.o (JammaInit) +libjamma.a(jamma_lin.o) libjamma.a(jamma.o) (jamma_init) +/usr/lib/libc_nonshared.a(elf-init.oS) + /usr/lib/crt1.o (__libc_csu_init) + +Allocating common symbols +Common symbol size file + +asciibuf 0x80 jammatest.o +inittime 0x8 libjamma.a(jamma_lin.o) +gunSampleDebugUsed 0x204 libjamma.a(jamma.o) +rawtio 0x3c jammatest.o +savetio 0x3c jammatest.o +jammaemumem 0x1 jammatest.o +jammamem 0x1ec libjamma.a(jamma.o) +jammaG 0x4 libjamma.a(jamma.o) +gunSampleDebugRaw 0x204 libjamma.a(jamma.o) +jamma_jdev 0x4 libjamma.a(jamma.o) + +Memory Configuration + +Name Origin Length Attributes +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD /usr/lib/crt1.o +LOAD /usr/lib/crti.o +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o +LOAD jammatest.o +LOAD libjamma.a +LOAD /usr/lib/librt.so +LOAD /g3/lib/libusb.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_eh.a +LOAD /usr/lib/libc.so +START GROUP +LOAD /lib/libc.so.6 +LOAD /usr/lib/libc_nonshared.a +END GROUP +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_eh.a +LOAD /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o +LOAD /usr/lib/crtn.o + 0x0000000008048114 . = (0x8048000 + SIZEOF_HEADERS) + +.interp 0x0000000008048114 0x13 + *(.interp) + .interp 0x0000000008048114 0x13 /usr/lib/crt1.o + +.note.ABI-tag 0x0000000008048128 0x20 + .note.ABI-tag 0x0000000008048128 0x20 /usr/lib/crt1.o + +.hash 0x0000000008048148 0xc0 + *(.hash) + .hash 0x0000000008048148 0xc0 /usr/lib/crt1.o + +.dynsym 0x0000000008048208 0x1d0 + *(.dynsym) + .dynsym 0x0000000008048208 0x1d0 /usr/lib/crt1.o + +.dynstr 0x00000000080483d8 0x116 + *(.dynstr) + .dynstr 0x00000000080483d8 0x116 /usr/lib/crt1.o + +.gnu.version 0x00000000080484ee 0x3a + *(.gnu.version) + .gnu.version 0x00000000080484ee 0x3a /usr/lib/crt1.o + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r 0x0000000008048528 0x20 + *(.gnu.version_r) + .gnu.version_r + 0x0000000008048528 0x20 /usr/lib/crt1.o + +.rel.dyn 0x0000000008048548 0x10 + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + .rel.got 0x0000000008048548 0x8 /usr/lib/crt1.o + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + .rel.bss 0x0000000008048550 0x8 /usr/lib/crt1.o + +.rela.dyn + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + +.rel.plt 0x0000000008048558 0xc0 + *(.rel.plt) + .rel.plt 0x0000000008048558 0xc0 /usr/lib/crt1.o + +.rela.plt + *(.rela.plt) + +.init 0x0000000008048618 0x17 + *(.init) + .init 0x0000000008048618 0xb /usr/lib/crti.o + 0x0000000008048618 _init + .init 0x0000000008048623 0x5 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .init 0x0000000008048628 0x5 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + .init 0x000000000804862d 0x2 /usr/lib/crtn.o + +.plt 0x0000000008048630 0x190 + *(.plt) + .plt 0x0000000008048630 0x190 /usr/lib/crt1.o + 0x0000000008048640 usleep@@GLIBC_2.0 + 0x0000000008048650 write@@GLIBC_2.0 + 0x0000000008048660 close@@GLIBC_2.0 + 0x0000000008048670 cfsetospeed@@GLIBC_2.0 + 0x0000000008048680 tcsetattr@@GLIBC_2.0 + 0x0000000008048690 __errno_location@@GLIBC_2.0 + 0x00000000080486a0 ftime@@GLIBC_2.0 + 0x00000000080486b0 malloc@@GLIBC_2.0 + 0x00000000080486c0 fgets@@GLIBC_2.0 + 0x00000000080486d0 strlen@@GLIBC_2.0 + 0x00000000080486e0 __libc_start_main@@GLIBC_2.0 + 0x00000000080486f0 printf@@GLIBC_2.0 + 0x0000000008048700 fcntl@@GLIBC_2.0 + 0x0000000008048710 open@@GLIBC_2.0 + 0x0000000008048720 tcflush@@GLIBC_2.0 + 0x0000000008048730 sscanf@@GLIBC_2.0 + 0x0000000008048740 cfsetispeed@@GLIBC_2.0 + 0x0000000008048750 free@@GLIBC_2.0 + 0x0000000008048760 memset@@GLIBC_2.0 + 0x0000000008048770 vprintf@@GLIBC_2.0 + 0x0000000008048780 sprintf@@GLIBC_2.0 + 0x0000000008048790 tcgetattr@@GLIBC_2.0 + 0x00000000080487a0 read@@GLIBC_2.0 + 0x00000000080487b0 strcpy@@GLIBC_2.0 + +.text 0x00000000080487c0 0x5dc0 + *(.text .stub .text.* .gnu.linkonce.t.*) + .text 0x00000000080487c0 0x24 /usr/lib/crt1.o + 0x00000000080487c0 _start + .text 0x00000000080487e4 0x22 /usr/lib/crti.o + *fill* 0x0000000008048806 0xa 90909090 + .text 0x0000000008048810 0x74 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .text 0x0000000008048884 0x15f7 jammatest.o + 0x00000000080488ff ConKeyRead + 0x000000000804897f jammatesthelp + 0x0000000008048975 fullScreen + 0x0000000008049e05 jamma_apphook_malloc + 0x0000000008049e4b jamma_apphook_sysmillisec + 0x00000000080488fa conFinal + 0x0000000008049a2d jamma_callback + 0x0000000008048a31 main + 0x0000000008049e2b jamma_apphook_msg + 0x000000000804896b closeScreen + 0x0000000008048884 conInit + 0x0000000008049e18 jamma_apphook_free + *fill* 0x0000000008049e7b 0x1 90909090 + .text 0x0000000008049e7c 0x3da8 libjamma.a(jamma.o) + 0x000000000804a1b4 jamma_pktget + 0x000000000804a3e9 jamma_msg + 0x000000000804d61e gunPreProcessSamples + 0x000000000804d7dd gunProcessSamples + 0x0000000008049e81 JammaInit + 0x000000000804d5e2 MemFill + 0x000000000804aaff JammaOp + 0x000000000804a09e ch2b + 0x000000000804a027 JammaFinal + 0x000000000804c139 JammaLoop + 0x000000000804a159 b2ch + .text 0x000000000804dc24 0x8bb libjamma.a(jamma_lin.o) + 0x000000000804dec6 jamma_send + 0x000000000804dc46 jamma_final + 0x000000000804df61 jamma_getsn + 0x000000000804e160 jamma_readloop + 0x000000000804dc29 jamma_init + 0x000000000804e4da jamma_mutex_release + 0x000000000804dd3d jamma_sendloop + 0x000000000804de9a jamma_sendloop_now + 0x000000000804dd19 jamma_tick + 0x000000000804e4d5 jamma_mutex_wait + 0x000000000804df6b jamma_open + 0x000000000804dc4b jamma_reset + 0x000000000804e0dd jamma_close + *fill* 0x000000000804e4df 0x1 90909090 + .text 0x000000000804e4e0 0x68 /usr/lib/libc_nonshared.a(elf-init.oS) + 0x000000000804e510 __libc_csu_fini + 0x000000000804e4e0 __libc_csu_init + *fill* 0x000000000804e548 0x8 90909090 + .text 0x000000000804e550 0x30 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + *(.gnu.warning) + +.fini 0x000000000804e580 0x1b + *(.fini) + .fini 0x000000000804e580 0x11 /usr/lib/crti.o + 0x000000000804e580 _fini + .fini 0x000000000804e591 0x5 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .fini 0x000000000804e596 0x5 /usr/lib/crtn.o + 0x000000000804e59b PROVIDE (__etext, .) + 0x000000000804e59b PROVIDE (_etext, .) + 0x000000000804e59b PROVIDE (etext, .) + +.rodata 0x000000000804e5a0 0xfb7 + *(.rodata .rodata.* .gnu.linkonce.r.*) + .rodata 0x000000000804e5a0 0x8 /usr/lib/crt1.o + 0x000000000804e5a0 _fp_hw + 0x000000000804e5a4 _IO_stdin_used + *fill* 0x000000000804e5a8 0x18 00 + .rodata 0x000000000804e5c0 0xb5c jammatest.o + *fill* 0x000000000804f11c 0x4 00 + .rodata 0x000000000804f120 0x42c libjamma.a(jamma.o) + .rodata 0x000000000804f54c 0xb libjamma.a(jamma_lin.o) + +.rodata1 + *(.rodata1) + +.eh_frame_hdr + *(.eh_frame_hdr) + 0x000000000804f557 . = (ALIGN (0x1000) - ((0x1000 - .) & 0xfff)) + 0x0000000008050000 . = (0x1000 DATA_SEGMENT_ALIGN 0x1000) + 0x0000000008050000 . = ALIGN (0x4) + 0x0000000008050000 PROVIDE (__preinit_array_start, .) + +.preinit_array + *(.preinit_array) + 0x0000000008050000 PROVIDE (__preinit_array_end, .) + 0x0000000008050000 PROVIDE (__init_array_start, .) + +.init_array + *(.init_array) + 0x0000000008050000 PROVIDE (__init_array_end, .) + 0x0000000008050000 PROVIDE (__fini_array_start, .) + +.fini_array + *(.fini_array) + 0x0000000008050000 PROVIDE (__fini_array_end, .) + +.data 0x0000000008050000 0x3c0 + *(.data .data.* .gnu.linkonce.d.*) + .data 0x0000000008050000 0x4 /usr/lib/crt1.o + 0x0000000008050000 data_start + 0x0000000008050000 __data_start + .data 0x0000000008050004 0x8 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + 0x0000000008050004 __dso_handle + *fill* 0x000000000805000c 0x14 00 + .data 0x0000000008050020 0x40 jammatest.o + 0x0000000008050020 iomodenames + .data 0x0000000008050060 0x360 libjamma.a(jamma.o) + 0x0000000008050240 jammamap_pkt_sbb + 0x0000000008050060 jammamap_pkt_bbh + +.data1 + *(.data1) + +.tdata + *(.tdata .tdata.* .gnu.linkonce.td.*) + +.tbss + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + +.eh_frame 0x00000000080503c0 0x4 + *(.eh_frame) + .eh_frame 0x00000000080503c0 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.gcc_except_table + *(.gcc_except_table) + +.dynamic 0x00000000080503c4 0xd0 + *(.dynamic) + .dynamic 0x00000000080503c4 0xd0 /usr/lib/crt1.o + 0x00000000080503c4 _DYNAMIC + +.ctors 0x0000000008050494 0x8 + *crtbegin*.o(.ctors) + *(EXCLUDE_FILE(*crtend*.o) .ctors) + .ctors 0x0000000008050494 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + *(SORT(.ctors.*)) + *(.ctors) + .ctors 0x0000000008050498 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.dtors 0x000000000805049c 0x8 + *crtbegin*.o(.dtors) + *(EXCLUDE_FILE(*crtend*.o) .dtors) + .dtors 0x000000000805049c 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + *(SORT(.dtors.*)) + *(.dtors) + .dtors 0x00000000080504a0 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.jcr 0x00000000080504a4 0x4 + *(.jcr) + .jcr 0x00000000080504a4 0x4 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + +.got 0x00000000080504a8 0x70 + *(.got.plt) + .got.plt 0x00000000080504a8 0x6c /usr/lib/crt1.o + 0x00000000080504a8 _GLOBAL_OFFSET_TABLE_ + *(.got) + .got 0x0000000008050514 0x4 /usr/lib/crt1.o + 0x0000000008050518 _edata = . + 0x0000000008050518 PROVIDE (edata, .) + 0x0000000008050518 __bss_start = . + +.bss 0x0000000008050520 0x750 + *(.dynbss) + .dynbss 0x0000000008050520 0x4 /usr/lib/crt1.o + 0x0000000008050520 stdin@@GLIBC_2.0 + *(.bss .bss.* .gnu.linkonce.b.*) + .bss 0x0000000008050524 0x1 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + *fill* 0x0000000008050525 0x3 00 + .bss 0x0000000008050528 0x4 libjamma.a(jamma.o) + 0x0000000008050528 jamma_ready + *(COMMON) + *fill* 0x000000000805052c 0x14 00 + COMMON 0x0000000008050540 0xfd jammatest.o + 0x0 (size before relaxing) + 0x0000000008050540 asciibuf + 0x00000000080505c0 rawtio + 0x0000000008050600 savetio + 0x000000000805063c jammaemumem + *fill* 0x000000000805063d 0x3 00 + COMMON 0x0000000008050640 0x628 libjamma.a(jamma.o) + 0x0 (size before relaxing) + 0x0000000008050640 gunSampleDebugUsed + 0x0000000008050860 jammamem + 0x0000000008050a4c jammaG + 0x0000000008050a60 gunSampleDebugRaw + 0x0000000008050c64 jamma_jdev + COMMON 0x0000000008050c68 0x8 libjamma.a(jamma_lin.o) + 0x0 (size before relaxing) + 0x0000000008050c68 inittime + 0x0000000008050c70 . = ALIGN (0x4) + 0x0000000008050c70 . = ALIGN (0x4) + 0x0000000008050c70 _end = . + 0x0000000008050c70 PROVIDE (end, .) + 0x0000000008050c70 . = DATA_SEGMENT_END (.) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0xa2 + *(.comment) + .comment 0x0000000000000000 0x12 /usr/lib/crt1.o + .comment 0x0000000000000012 0x12 /usr/lib/crti.o + .comment 0x0000000000000024 0x12 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o + .comment 0x0000000000000036 0x12 jammatest.o + .comment 0x0000000000000048 0x12 libjamma.a(jamma.o) + .comment 0x000000000000005a 0x12 libjamma.a(jamma_lin.o) + .comment 0x000000000000006c 0x12 /usr/lib/libc_nonshared.a(elf-init.oS) + .comment 0x000000000000007e 0x12 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o + .comment 0x0000000000000090 0x12 /usr/lib/crtn.o + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges 0x0000000000000000 0xb8 + *(.debug_aranges) + .debug_aranges + 0x0000000000000000 0x30 /usr/lib/crti.o + .debug_aranges + 0x0000000000000030 0x20 jammatest.o + .debug_aranges + 0x0000000000000050 0x20 libjamma.a(jamma.o) + .debug_aranges + 0x0000000000000070 0x20 libjamma.a(jamma_lin.o) + .debug_aranges + 0x0000000000000090 0x28 /usr/lib/crtn.o + +.debug_pubnames + 0x0000000000000000 0x39c + *(.debug_pubnames) + .debug_pubnames + 0x0000000000000000 0x25 /usr/lib/crt1.o + .debug_pubnames + 0x0000000000000025 0x12f jammatest.o + .debug_pubnames + 0x0000000000000154 0x143 libjamma.a(jamma.o) + .debug_pubnames + 0x0000000000000297 0x105 libjamma.a(jamma_lin.o) + +.debug_info 0x0000000000000000 0x7d4f + *(.debug_info .gnu.linkonce.wi.*) + .debug_info 0x0000000000000000 0x89c /usr/lib/crt1.o + .debug_info 0x000000000000089c 0x68 /usr/lib/crti.o + .debug_info 0x0000000000000904 0x22ce jammatest.o + .debug_info 0x0000000000002bd2 0x243d libjamma.a(jamma.o) + .debug_info 0x000000000000500f 0x2cd8 libjamma.a(jamma_lin.o) + .debug_info 0x0000000000007ce7 0x68 /usr/lib/crtn.o + +.debug_abbrev 0x0000000000000000 0x97e + *(.debug_abbrev) + .debug_abbrev 0x0000000000000000 0x104 /usr/lib/crt1.o + .debug_abbrev 0x0000000000000104 0x10 /usr/lib/crti.o + .debug_abbrev 0x0000000000000114 0x2b2 jammatest.o + .debug_abbrev 0x00000000000003c6 0x2b7 libjamma.a(jamma.o) + .debug_abbrev 0x000000000000067d 0x2f1 libjamma.a(jamma_lin.o) + .debug_abbrev 0x000000000000096e 0x10 /usr/lib/crtn.o + +.debug_line 0x0000000000000000 0x1032 + *(.debug_line) + .debug_line 0x0000000000000000 0xce /usr/lib/crt1.o + .debug_line 0x00000000000000ce 0x8e /usr/lib/crti.o + .debug_line 0x000000000000015c 0x3c9 jammatest.o + .debug_line 0x0000000000000525 0x7b2 libjamma.a(jamma.o) + .debug_line 0x0000000000000cd7 0x2ef libjamma.a(jamma_lin.o) + .debug_line 0x0000000000000fc6 0x6c /usr/lib/crtn.o + +.debug_frame 0x0000000000000000 0x418 + *(.debug_frame) + .debug_frame 0x0000000000000000 0x14 /usr/lib/crt1.o + .debug_frame 0x0000000000000014 0x13c jammatest.o + .debug_frame 0x0000000000000150 0x150 libjamma.a(jamma.o) + .debug_frame 0x00000000000002a0 0x178 libjamma.a(jamma_lin.o) + +.debug_str 0x0000000000000000 0x3453 + *(.debug_str) + .debug_str 0x0000000000000000 0x674 /usr/lib/crt1.o + 0x6b4 (size before relaxing) + .debug_str 0x0000000000000674 0x224a jammatest.o + 0x2a3a (size before relaxing) + .debug_str 0x00000000000028be 0x56f libjamma.a(jamma.o) + 0x1b6d (size before relaxing) + .debug_str 0x0000000000002e2d 0x626 libjamma.a(jamma_lin.o) + 0x3134 (size before relaxing) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +/DISCARD/ + *(.note.GNU-stack) +OUTPUT(jammatest elf32-i386) diff --git a/libraries/pmrt/jamma/Debug/BuildLog.htm b/libraries/pmrt/jamma/Debug/BuildLog.htm new file mode 100755 index 0000000..3de7065 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/BuildLog.htm differ diff --git a/libraries/pmrt/jamma/Debug/jamma.obj b/libraries/pmrt/jamma/Debug/jamma.obj new file mode 100755 index 0000000..8bea45a Binary files /dev/null and b/libraries/pmrt/jamma/Debug/jamma.obj differ diff --git a/libraries/pmrt/jamma/Debug/jamma_lin.obj b/libraries/pmrt/jamma/Debug/jamma_lin.obj new file mode 100755 index 0000000..9ec19f8 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/jamma_lin.obj differ diff --git a/libraries/pmrt/jamma/Debug/jamma_pc.obj b/libraries/pmrt/jamma/Debug/jamma_pc.obj new file mode 100755 index 0000000..7334863 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/jamma_pc.obj differ diff --git a/libraries/pmrt/jamma/Debug/jammalib.lib b/libraries/pmrt/jamma/Debug/jammalib.lib new file mode 100755 index 0000000..bcaf6a3 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/jammalib.lib differ diff --git a/libraries/pmrt/jamma/Debug/jammalib.pch b/libraries/pmrt/jamma/Debug/jammalib.pch new file mode 100755 index 0000000..d04117b Binary files /dev/null and b/libraries/pmrt/jamma/Debug/jammalib.pch differ diff --git a/libraries/pmrt/jamma/Debug/vc60.idb b/libraries/pmrt/jamma/Debug/vc60.idb new file mode 100755 index 0000000..e99baeb Binary files /dev/null and b/libraries/pmrt/jamma/Debug/vc60.idb differ diff --git a/libraries/pmrt/jamma/Debug/vc60.pdb b/libraries/pmrt/jamma/Debug/vc60.pdb new file mode 100755 index 0000000..6cea773 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/vc60.pdb differ diff --git a/libraries/pmrt/jamma/Debug/vc90.idb b/libraries/pmrt/jamma/Debug/vc90.idb new file mode 100755 index 0000000..0f2fba6 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/vc90.idb differ diff --git a/libraries/pmrt/jamma/Debug/vc90.pdb b/libraries/pmrt/jamma/Debug/vc90.pdb new file mode 100755 index 0000000..c619020 Binary files /dev/null and b/libraries/pmrt/jamma/Debug/vc90.pdb differ diff --git a/libraries/pmrt/jamma/README_SpongebobProtocol.txt b/libraries/pmrt/jamma/README_SpongebobProtocol.txt new file mode 100755 index 0000000..3043436 --- /dev/null +++ b/libraries/pmrt/jamma/README_SpongebobProtocol.txt @@ -0,0 +1,40 @@ +Following are the modifications to the protocol for SpongeBob i/o: + + +Switch Change +------------- +'S' - sent immediately on switch change detected, may send up to 5 msgs per frame. Also sent every .5s by default (periodic switch sending is turned on in the config) + +SPONGE BOB: Trackball X- and Y-count values are both 0xFF after reset. The 16ms counter sent with every msg (16ms_cnt) can be used to assist with velocity calculations for the trackball. + +format: S<16ms_cnt> + +[1] 'S' +[2] - u=user bit in config mode; ffffff=6-bit, 16ms counter, $00-$3F (~1sec) +[3] - XXXXXXXX=8-bit trackball X-position count value +[4] - YYYYYYYY=8-bit trackball Y-position count value +[5] - ssss=SpongeBob ticket NOTCH; SSSS=SpongeBob START +[6] - cccc=coin1_cnt; CCCC=coin2_cnt +[7] - VVVV=volup_cnt; vvvv=voldn_cnt +[8] - TTTT=test_cnt; ssss=serv_cnt +[9] - tttt=tilt_cnt; BBBB=bill_cnt + + +Set Hi-current Outputs: +---------------------- +'H' - sets state of hi-current output lines - one bit per line, active LOW + +SPONGE BOB: The Ticket Drive output is negative logic. After reset the value defaults to 0xA0 i.e. Start lamp ON, Mars lamp OFF, and ticket Drive OFF + +[1] 'H' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to SpongeBob Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** wired to SpongeBob Ticket Drive*** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** wired to SpongeBob Mars lamp *** + A=AudioMute *** connected to Audio Mute *** + 0 *** RESERVED for PC RESET (unmodifiable) *** diff --git a/libraries/pmrt/jamma/README_SpongebobProtocol_SBv3.txt b/libraries/pmrt/jamma/README_SpongebobProtocol_SBv3.txt new file mode 100755 index 0000000..7bf8329 --- /dev/null +++ b/libraries/pmrt/jamma/README_SpongebobProtocol_SBv3.txt @@ -0,0 +1,115 @@ +Following are the modifications to the protocol for SpongeBob i/o: + +v2 - added ticket dispensing functionality +v3 - added notch sense polarity control + + +Switch Change +------------- +'S' - sent immediately on switch change detected, may send up to 5 msgs per frame. Also sent every .5s by default (periodic switch sending is turned on in the config) + +SPONGE BOB: Trackball X- and Y-count values are both 0xFF after reset. The 16ms counter sent with every msg (16ms_cnt) can be used to assist with velocity calculations for the trackball. + +format: S<16ms_cnt> + +[1] 'S' +[2] - u=user bit in config mode; ffffff=6-bit, 16ms counter, $00-$3F (~1sec) +[3] - XXXXXXXX=8-bit trackball X-position count value +[4] - YYYYYYYY=8-bit trackball Y-position count value +[5] <----SSSS> - ----=(was ticket notch) (P1); SSSS=SpongeBob START (P2) +[6] - cccc=coin1_cnt; CCCC=coin2_cnt +[7] - VVVV=volup_cnt; vvvv=voldn_cnt +[8] - TTTT=test_cnt; ssss=serv_cnt +[9] - tttt=tilt_cnt; BBBB=bill_cnt + + +Set Hi-current Outputs: +---------------------- +'H' - sets state of hi-current output lines - one bit per line, active LOW + +SPONGE BOB: The Ticket Drive output is negative logic. After reset the value defaults to 0xA0 i.e. Start lamp ON, Mars lamp OFF, and ticket Drive OFF + +[1] 'H' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to SpongeBob Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** RESERVED FOR SpongeBob Ticket Drive (unmodifiable) *** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** wired to SpongeBob Mars lamp *** + A=AudioMute *** connected to Audio Mute *** + 0 *** RESERVED for PC RESET (unmodifiable) *** + + +--------------------- ticket dispensing in SpongeBob v2 ------------------ + + +Ticket Status (received from i/o board) +-------------- +'t' - sent in response to "Ticket Status" msg, and: + - when a change is detected in the 'emtpy' status + - when a change is detected in the 'overflow' status + - after each ticket is dispensed + +NOTES: when the 'e' bit is set, the ticket count is non-zero but the drive has timed out. The status + will continue to report the same status AND count value UNTIL a new Ticket Dispense msg is rec'd. + A new Ticket Dispense msg is required to re-attempt the ticket drive. + + when the 'V' bit is set, a Ticket Dispense msg was received which, when added to the current ticket + down-count value, exceeded 1023 tickets. The count value reported is undefined. Only a Ticket + Dispense msg with the "S" bit set will allow ticket dispensing to continue. + + +format: t +e.g. msg: t0028 - 40 tickets left to be dispensed; dispensing currently active + msg: t03FF - 1023 tickets left to be dispensed; dispensing currently active + msg: t0000 - re-start ticket drive if empty & count!=0; if==0 just generate status msg + msg: t8030 - dispenser empty or jammed; dispensing stopped; 50 tickets left to be dispensed + msg: t4123 - ticket counter overflowed; dispensing stopped; ??? tickets to be dispensed + +[1] 'T' + +status +[2] - e=empty indicator (1=empty) + - V=overflow indicator (1=overflowed) + - p=notch polarity indicator (1=use hi->lo transition for count; 0=count ticket on lo->hi {default}) + - tt=msbits 9-8 of ticket down-counter + +count +[3] - tttttttt=lsbits 7-0 of ticket down-counter + + + +Ticket Dispense (sent to i/o board) +--------------- +'T' - always results in a Ticket Status response msg. + - short msg 'T' by itself generates response msg, but does not affect the count or 'e' or 'V' bits + - can be sent to start, stop, or retry ticktet dispensing + +NOTEs: any Ticket Dispense msg will clear the Empty 'e' status bit except the short 'T' msg + + only a msg with the 'S' bit set will clear the Overflow 'V' status bit. +BIG v3 NOTE: + only a msg with the 'S' bit set will set/clear the polarity bit!!! Otherwise it is ignored + + +format: T +e.g. msg: T0028 - add 40 more tickets to ticket counter + msg: T0108 - add 512 more tickets to ticket counter + msg: T0000 - re-start ticket drive if empty & count!=0; if==0 just generate status msg + msg: T8030 - clear overflow bit, clear notch polarity bit, set ticket counter to 50, and dispense tickets + msg: T8000 - clear overflow bit, clear notch polarity bit, set ticket counter to 0 (stop dispensing tickets) + msg: T9208 - clear overflow bit, set notch polarity bit, set ticket counter to 520, and dispense tickets + msg: T9000 - clear overflow bit, set notch polarity bit, set ticket counter to 0 (stop dispensing tickets) + +[1] 'T' + +cmd +[2] - S=Set/add ticket counter (1=set to absolute count value; 0=add value to counter) + - p=notch polarity (1=use hi->lo transition for count; 0=count ticket on lo->hi {default}) + - tt=msbits 9-8 of value + +value +[3] - tttttttt=lsbits 7-0 of value diff --git a/libraries/pmrt/jamma/README_bb3_gunmsgs_v4.txt b/libraries/pmrt/jamma/README_bb3_gunmsgs_v4.txt new file mode 100755 index 0000000..703609d --- /dev/null +++ b/libraries/pmrt/jamma/README_bb3_gunmsgs_v4.txt @@ -0,0 +1,98 @@ +README_BB3_GUNMSGS.txt +8/08/2005 +J. Green +Raw Thrills, Inc. + + +******************************** + +Messages received FROM the board + +******************************** + + +Verbose/Debug gun Info: +-------------------------------- +'d' - gunshot data for P1 +'D' - gunshot data for P2 + - msg is fixed length, 253bytes (d/D + 12bytes + 60x4bytes + 4bytes) + - max lines reported is 61 (1st position + 60) + - data after 0xC000 or 0xE000 can be ignored +format: d<0xFshot><0x1vbase><0x2hbase><*line2><*line3>..<*lineN> +format: D<0xFshot><0x1vbase><0x2hbase><*line2><*line3>..<*lineN> + +* = 0x3 (line info), 0xB (blank line), 0xE (vblank), or 0xC (end of data) + +e.g. msg: dF33610232105310130FF30FF30FE31043110B000B000B000B000B000...C000 + P1, white this frame, white from this gun, frame#54, vertical line#35, hposition#261, + hpos#255, hpos#255, hpos#254, hpos#260, hpos#272, blank lines, more blank lines... end of data + +[1] 'd' or 'D' + +0xFshot +[2] 111100wW - w=whiteflash this frame; W=this gun pulled trigger, caused whiteflash + +frame +[3] 00ffffff - ffffff=6-bit frame counter + +0x1vbase +[4] 000100VV - msbits (2) of 1st vertical line# + +vbase +[5] vvvvvvvv - lsbyte of 1st vertical line# + +0x2hbase +[6] 00100HHH - msbits (3) of 1st horizontal position + +hbase +[7] hhhhhhhh - lsbyte of 1st horizontal position +------------------------------------------------------- + *lineN, lineN + [8+n], [8+n+1] +00110HHH, HHHHHHHH - (0x3) HHHHHHHHHHH=11-bit horizontal line position +10110000, 00000000 - (0xB) blank line +11100000, 00000000 - (0xE) vblank (bottom of screen reached) +11000000, 00000000 - (0xC) end of data (60 lines max) + + + +Brief gun Info: +-------------------------------- +'g' - gunshot data for P1 +'G' - gunshot data for P2 + - msg is fixed length, min of 13 bytes (g/G + 12bytes + nX2 bytes) + - data only reported if 7 or more data points are captured + - vposition reported is THE vertical line# of the 7th data point + +format: g<0xFshot><0x1v7line><0x3h7line> +format: G<0xFshot><0x1v7line><0x3h7line> + +[1] 'g' or 'G' + +0xFshot +[2] 111100wW - w=whiteflash this frame; W=this gun pulled trigger, caused whiteflash + +frame +[3] 00ffffff - ffffff=6-bit frame counter + +0x1v7line +[4] 000100VV - msbits (2) of 7th vertical line# + +v7line +[5] vvvvvvvv - lsbyte of 7th vertical line# + +0x3h7line +[6] 00100HHH - msbits (3) of 7th horizontal position + +h7line +[7] hhhhhhhh - lsbyte of 7th horizontal position + + + + + + + + + + diff --git a/libraries/pmrt/jamma/README_bb3_serial_v2.txt b/libraries/pmrt/jamma/README_bb3_serial_v2.txt new file mode 100755 index 0000000..60a33ac --- /dev/null +++ b/libraries/pmrt/jamma/README_bb3_serial_v2.txt @@ -0,0 +1,305 @@ +README_BB3_SERIAL.txt +08/08/2005 +J. Green +Raw Thrills, Inc. + + +NOTES: +1) for all in/out msgs, \n ($0a) is start delimiter, \r ($0d) is end +2) max msg length TO the board is 15 chars, NOT including \n & \r +3) every msg sent/received has single char identifier, followed by byte values (if any) +4) each byte value is sent/received as 2-char ascii, upper-case +5) all switches EXCEPT dipswitches are sampled 4ms, debounced 16ms +6) debounced trigger inputs are used for flash ckt, data collection +7) Dipswitch settings: + 8- "on"=disable watchdog function + 7- unused + 6- unused + 5- unused + 4- "on"=debug trig mode (overrides "T" bit in config byte, for hwflash debug) + 3- unused + 2- "on"=echo on RJ uart + 1- "on"=echo on DB9 uart + + +******************************** +Messages sent TO the board +******************************** + +Set Configuration Msg: +---------------------- +'C' - sets configuration and mode bytes in HW + - short msg sets only config byte, leaves mode byte alone +format: C or C +[1] 'C' + +config +[2] HhAa-T-d +H - 1=flash screen white on P2 trig, collect data for that frame only (default) +h - 1= " " P1 +A - 1=autofire mode for P2 (always collects & returns data, regardless of flash or trig) +a - " " P1 +T - 0=normal trigger mode (default); 1=trig mode (debug only: holds white onscreen when either trig pulled) +d - 0=brief gun msg mode (default) returns 7th line position; 1=debug gun msg mode returns verbose/debug msgs for gun data + +mode +[3] u-----Ts +u - 0=user bit (default); gets reset to 0 when board is reset/powered-up +T - 0=use vsync input for timing (default); 1=use internal 16ms timer (debug) + NOTE: timer used for watchdog & periodic switch state sends +s - 0=no periodic switch states sent (default); 1=sends switch states every .5sec + + +Request Configuration: +---------------------- +'c' - causes board to return the Configuration Info msg + - ALSO clears "watchdogged" state bit (following returned msg) +format: c + +[1] 'c' + + +Request Version Info: +---------------------- +'v' - causes board to return the Version Info msg + - ALSO clears "watchdogged" state bit (following returned msg) +format: v + +[1] 'v' + + +Set Hi-current Outputs: +---------------------- +'H' - sets state of hi-current output lines - one bit per line, active LOW + - cannot manually change PC Reset line (only watchdog function can do this) +format: H +e.g. msg: H11 + +[1] 'H' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to P2 Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** wired to P1 Start Lamp *** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** UNUSED *** + A=AudioMute *** connected to Audio Mute *** + + +Request Hi-current Output state: +-------------------------------- +'h' - causes board to return the value in hi-current output register (see below) +format: h + +[1] 'h' + + +Request sync frequency info +-------------------------------- +'f' - causes board to return the values in the h- and v-sync counters (see below) +format: f + +[1] 'f' + + +Request Switch Count info +-------------------------------- +'S' - causes board to send back a Switch Change msg (below) +format: S + +[1] 'S' + + +Watchdog Bone: +-------------- +'W' - throws watchdog bones, in 4-sec increments + - min value 0 = 4seconds, max value 0xFF ~= 17minutes + - after watchdog reset occurs, value resets to 5 mins, + the "W" bit is set in the config byte (see Configuration Info byte below), + and the "*WDT*" msg is sent (see "alert messages", below) +format: W +e.g. msg: W0E - feeds 15 = 60 seconds +e.g. msg: W00 - feeds 1 = 4secs + +[1] 'W' + +value +[2] - 0x00=0xFF: immediately resets watchdog timer to 1+value + + +Set WhiteFlash Timing Registers +--------------------------------- +'F' - sets 2 horizontal and 2 vertical timing registers for the whiteflash function + basically permits defining the "white" rectangle size & position, ideally to fill + entire screen while respecting blanking times + - vertical registers are in "lines", vFront=lines before white (top), vBack=line when white stops (bottom) + - horizontal registers are in "time" + hFront=time before white (left), hBack=time when white ends (right) + - default values for VGA are: + vFront=33 lines; vBack=514 lines; hFront=1.75us; hBack=27.25us + - Rev A board clk is 24.0MHz, so horizontal register multiplier is 1/24MHz = 41.6666ns + +format: F +e.g. msg: F2102202A8E20 - set default values for VGA fullscreen whiteflash + vfront = 0x021, vback = 0x202, hfront = 0x02A, hback = 0x28E +e.g. msg: F2102202A5C10 - left half + vfront = 0x021, vback = 0x202, hfront = 0x02A, hback = 0x15C +e.g. msg: F1102212A8E20 - bottom half + vfront = 0x111, vback = 0x202, hfront = 0x02A, hback = 0x28E + +[1] 'F' + +vfront +[2] lsbyte of 10-bit vFront register (8bits) + +vback +[3] lsbyte of 10-bit vBack register (8bits) + +vb_vf +[4] 00VV00vv - VV=2msbits of vFront; vv=2msbits of vBack + +hfront +[5] lsbyte of 11-bit hFront register (8bits) + +hback +[6] lsbyte of 11-bit hBack register (8bits) + +hb_hf +[7] 0HHH0hhh - HHH=3msbits of hFront; hhh=3msbits of hBack + + + + +******************************** +Messages received FROM the board +******************************** + +"Alert" Messages +----------------- +- two "alert" messages currently defined: *RST* and *WDT* +- *RST* is sent on power-up or reset condition (on-board reset switch pressed) +- *WDT* is sent ~1 second before PC_RESET line is pulled after watchdog counter expires +- messages have normal start/stop delimiters /n, /r + + +Switch Change: +-------------- +'S' - sent immediately on switch change detected, may rec'v multiple per frame + - all counts regs are 4-bits; if cnt value is odd, switch is in active pos (low) + - can represent multiple switch state changes i.e. parse whole msg +format: S +e.g. msg: S1901000000000000 - frame#25; p2trig pulled + msg: S2202000000000000 - frame#34; p2trig released + +[1] 'S' +[2] <--ffffff> - ffffff=6-bit frame count, $00-$3F (~1sec) +[3] - pppp=p1trig_cnt; PPPP=p2trig_cnt +[4] - rrrr=p1reload_cnt; RRRR=p2reload_cnt +[5] - ssss=p1start_cnt; SSSS=p2start_cnt +[6] - cccc=coin1_cnt; CCCC=coin2_cnt +[7] - VVVV=volup_cnt; vvvv=voldn_cnt +[8] - TTTT=test_cnt; ssss=serv_cnt +[9] - tttt=tilt_cnt; BBBB=bill_cnt + + +Switch State: +------------- +'s' - sent periodically only if 's' bit is set in configuration mode byte + - one bit per switch, all switches active low +format: s +e.g. msg: s2A3FFFFFFF - frame#42; all switches 'off' + msg: s133EFFFFFF - frame#19: p2trig held down + +[1] 's' +[2] --ffffff - ffffff=6-bit frame count, $00-$3F (~1sec) +[3] 00rRsStT - r=p1reload, R=p2reload, s=p1spare, S=p2spare, t=p1trig, T=p2trig +[4] jtvlSCsc - j=csyncPolarityJumper, t=test, v=service, l=tilt, S=start2, C=coin2, s=start1, c=coin1 +[5] abVBcdve - a=P1BT1, b=P1BT2, V=vol_up, B=bill_in, c=P2BT1, d=P2BT2, v=vol_dn, e=P2BT4 +[6] dipswitches - active low (1='off', 0='on') + + +Configuration Info: +---------------------- +'c' - configuration state info, sent in response to request only + - ALSO clears "watchdogged" state bit (following returned msg) +format: c +[1] 'c' + +config +[2] HhAa-T-d + (same bits as in Set Configuration msg above) + +mode +[3] uW----Ts +u - user bit; 0=reset/power-up state +W - 0=no wdt event occurred (default); 1=watchdog event occurred since configuration was last read + NOTE: this bit is CLEARED after it is read +T - 0=using vsync input for timing (default); 1=using internal 16ms timer (debug) + NOTE: indicates which timer is being used for watchdog & periodic switch state sends +s - 0=not sending periodic switch states(default); 1=sending switch states every .5sec + + +Version Info: +---------------------- +'v' - version information, sent in response to request only +format: v +e.g. msg: v230A - PCB Rev 'A', build rev 2; fpga hdl ver '3'; pBlaze firmware verison 10 (pre-release) + +[1] 'v' + +hw_ver +[2] PPbbFFFF - pp=PCB version 0='A', 1='B', etc; bb=build rev; FFFF=fpga hdl version + +firm_ver +[3] picoblaze firmware version: 0x00-0x7F=pre-release; 0x80-0xFF=release + + +Hi-current Outputs Info: +---------------------- +'h' - indicates current state of hi-current output register + - all outputs active-low +format: h +e.g. msg: h11 + +[1] 'h' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to P2 Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** wired to P1 Start Lamp *** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** UNUSED *** + A=AudioMute *** connected to Audio Mute *** + + +Sync Frequency Info: +-------------------------------- +'f' - indicates detected h- and v-sync frequencies + - NOTE: if this is called multiple times in a frame, may return zeros or bogus data + it is best to obtain several values and range check, average, etc + - Rev A board clk is 24.0MHz, so counter multiplier is 1/24MHz = 41.6666ns + +format: f +e.g. msg: f061AEB02F9 - vsync=1/(0x061AEB x 41.66ns)=59.984Hz; hsync=1/(0x02F9 x 41.66ns)=31.537kHz + +[1] 'f' + +vsync1 +[2] msbits of 20-bit vsync freq count (4bits) + +vsync2 +[3] middle byte of 20-bit vsync freq count (8bits) + +vsync3 +[4] lsbyte of 20-bit vsync freq count (8bits) + +hsync1 +[5] msbits of 10-bit hsync freq count (2bits) + +hsync2 +[6] lsbyte of 10-bit hsync freq count (8bits) + diff --git a/libraries/pmrt/jamma/README_bb3_serial_v4.txt b/libraries/pmrt/jamma/README_bb3_serial_v4.txt new file mode 100755 index 0000000..1abc0a6 --- /dev/null +++ b/libraries/pmrt/jamma/README_bb3_serial_v4.txt @@ -0,0 +1,318 @@ +README_BB3_SERIAL.txt +08/08/2005 +J. Green +Raw Thrills, Inc. + + +NOTES: +1) for all in/out msgs, \n ($0a) is start delimiter, \r ($0d) is end +2) max msg length TO the board is 15 chars, NOT including \n & \r +3) every msg sent/received has single char identifier, followed by byte values (if any) +4) each byte value is sent/received as 2-char ascii, upper-case +5) all switches EXCEPT dipswitches are sampled 4ms, debounced 16ms +6) debounced trigger inputs are used for flash ckt, data collection +7) Dipswitch settings: + 8- "on"=disable watchdog function + 7- unused + 6- unused + 5- unused + 4- "on"=debug trig mode (overrides "T" bit in config byte, for hwflash debug) + 3- unused + 2- "on"=echo on RJ uart + 1- "on"=echo on DB9 uart + + +******************************** +Messages sent TO the board +******************************** + +Set Configuration Msg: +---------------------- +'C' - sets configuration and mode bytes in HW + - short msg sets only config byte, leaves mode byte alone +format: C or C +[1] 'C' + +config +[2] HhAa-T-d +H - 1=flash screen white on P2 trig, collect data for that frame only (default) +h - 1= " " P1 +A - 1=autofire mode for P2 (always collects & returns data, regardless of flash or trig) +a - " " P1 +T - 0=normal trigger mode (default); 1=trig mode (debug only: holds white onscreen when either trig pulled) +d - 0=brief gun msg mode (default) returns 7th line position; 1=debug gun msg mode returns verbose/debug msgs for gun data + +mode +[3] uW---xTs +u - 0=user bit (default); gets reset to 0 when board is reset/powered-up +W - 1=clear 'WATCHDOG EVENT OCCURRED', 0=leave alone +x - *** RESERVED FOR 'BONE RECEIVED' (ignored) *** +T - 0=use vsync input for timing (default); 1=use internal 16ms timer (debug) + NOTE: timer used for watchdog & periodic switch state sends +s - 0=no periodic switch states sent (default); 1=sends switch states every .5sec + + +Request Configuration: +---------------------- +'c' - causes board to return the Configuration Info msg + - ALSO clears "watchdogged" state bit (following returned msg) + **NOTE - (8/08/08) JAL** - George and I tried with all our might, but never could get the 'c' ot clear the "watchdogged" state bit. +format: c + +[1] 'c' + + +Request Version Info: +---------------------- +'v' - causes board to return the Version Info msg + - ALSO clears "watchdogged" state bit (following returned msg) +format: v + +[1] 'v' + + +Set Hi-current Outputs: +---------------------- +'H' - sets state of hi-current output lines - one bit per line, active LOW + - cannot manually change PC Reset line (only watchdog function can do this) +format: H +e.g. msg: H11 + +[1] 'H' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to P2 Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** wired to P1 Start Lamp *** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** UNUSED *** + A=AudioMute *** connected to Audio Mute *** + + +Request Hi-current Output state: +-------------------------------- +'h' - causes board to return the value in hi-current output register (see below) +format: h + +[1] 'h' + + +Request sync frequency info +-------------------------------- +'f' - causes board to return the values in the h- and v-sync counters (see below) +format: f + +[1] 'f' + + +Request Switch Count info +-------------------------------- +'S' - causes board to send back a Switch Change msg (below) +format: S + +[1] 'S' + + +Request Switch State info +-------------------------------- +'s' - causes board to send back a Switch State msg (below) +format: s + +[1] 's' + + +Watchdog Bone: +-------------- +'W' - throws watchdog bones, in 4-sec increments + - min value 0 = 4seconds, max value 0xFF ~= 17minutes + - after watchdog reset occurs, value resets to 5 mins, + the "W" bit is set in the config byte (see Configuration Info byte below), + and the "*WDT*" msg is sent (see "alert messages", below) +format: W +e.g. msg: W0E - feeds 15 = 60 seconds +e.g. msg: W00 - feeds 1 = 4secs + +[1] 'W' + +value +[2] - 0x00=0xFF: immediately resets watchdog timer to 1+value + + +Set WhiteFlash Timing Registers +--------------------------------- +'F' - sets 2 horizontal and 2 vertical timing registers for the whiteflash function + basically permits defining the "white" rectangle size & position, ideally to fill + entire screen while respecting blanking times + - vertical registers are in "lines", vFront=lines before white (top), vBack=line when white stops (bottom) + - horizontal registers are in "time" + hFront=time before white (left), hBack=time when white ends (right) + - default values for VGA are: + vFront=33 lines; vBack=514 lines; hFront=1.75us; hBack=27.25us + - Rev A board clk is 24.0MHz, so horizontal register multiplier is 1/24MHz = 41.6666ns + +format: F +e.g. msg: F2102202A8E20 - set default values for VGA fullscreen whiteflash + vfront = 0x021, vback = 0x202, hfront = 0x02A, hback = 0x28E +e.g. msg: F2102202A5C10 - left half + vfront = 0x021, vback = 0x202, hfront = 0x02A, hback = 0x15C +e.g. msg: F1102212A8E20 - bottom half + vfront = 0x111, vback = 0x202, hfront = 0x02A, hback = 0x28E + +[1] 'F' + +vfront +[2] lsbyte of 10-bit vFront register (8bits) + +vback +[3] lsbyte of 10-bit vBack register (8bits) + +vb_vf +[4] 00VV00vv - VV=2msbits of vFront; vv=2msbits of vBack + +hfront +[5] lsbyte of 11-bit hFront register (8bits) + +hback +[6] lsbyte of 11-bit hBack register (8bits) + +hb_hf +[7] 0HHH0hhh - HHH=3msbits of hFront; hhh=3msbits of hBack + + + + +******************************** +Messages received FROM the board +******************************** + +"Alert" Messages +----------------- +- two "alert" messages currently defined: *RST* and *WDT* +- *RST* is sent on power-up or reset condition (on-board reset switch pressed) +- *WDT* is sent ~1 second before PC_RESET line is pulled after watchdog counter expires +- messages have normal start/stop delimiters /n, /r + + +Switch Change: +-------------- +'S' - sent immediately on switch change detected, may rec'v multiple per frame + - all counts regs are 4-bits; if cnt value is odd, switch is in active pos (low) + - can represent multiple switch state changes i.e. parse whole msg +format: S +e.g. msg: S1901000000000000 - frame#25; p2trig pulled + msg: S2202000000000000 - frame#34; p2trig released + +[1] 'S' +[2] - u=user bit in config mode; ffffff=6-bit frame count, $00-$3F (~1sec) +[3] - pppp=p1trig_cnt; PPPP=p2trig_cnt +[4] - rrrr=p1reload_cnt; RRRR=p2reload_cnt +[5] - ssss=p1start_cnt; SSSS=p2start_cnt +[6] - cccc=coin1_cnt; CCCC=coin2_cnt +[7] - VVVV=volup_cnt; vvvv=voldn_cnt +[8] - TTTT=test_cnt; ssss=serv_cnt +[9] - tttt=tilt_cnt; BBBB=bill_cnt + + +Switch State: +------------- +'s' - sent periodically only if 's' bit is set in configuration mode byte + - one bit per switch, all switches active low +format: s +e.g. msg: s2A3FFFFFFF - frame#42; all switches 'off' + msg: s133EFFFFFF - frame#19: p2trig held down + +[1] 's' +[2] u-ffffff - u=user bit in config mode; ffffff=6-bit frame count, $00-$3F (~1sec) +[3] 00rRsStT - r=p1reload, R=p2reload, s=p1spare, S=p2spare, t=p1trig, T=p2trig +[4] jtvlSCsc - j=csyncPolarityJumper, t=test, v=service, l=tilt, S=start2, C=coin2, s=start1, c=coin1 +[5] abVBcdve - a=P1BT1, b=P1BT2, V=vol_up, B=bill_in, c=P2BT1, d=P2BT2, v=vol_dn, e=P2BT4 +[6] dipswitches - active low (1='off', 0='on') + + +Configuration Info: +---------------------- +'c' - configuration state info, sent in response to request only + - ALSO clears "watchdogged" state bit (following returned msg) +format: c +[1] 'c' + +config +[2] HhAa-T-d + (same bits as in Set Configuration msg above) + +mode +[3] uW---bTs +u - user bit; 0=reset/power-up state +W - 0=no wdt event occurred (default); 1=watchdog event occurred since configuration was last read + NOTE: this bit is CLEARED after it is read +b - 0=no watchdog bones received (default); 1=bone received, watchdog active + NOTE: this bit is CLEARED after each watchdog event +T - 0=using vsync input for timing (default); 1=using internal 16ms timer (debug) + NOTE: indicates which timer is being used for watchdog & periodic switch state sends +s - 0=not sending periodic switch states(default); 1=sending switch states every .5sec + + +Version Info: +---------------------- +'v' - version information, sent in response to request only +format: v +e.g. msg: v230A - PCB Rev 'A', build rev 2; fpga hdl ver '3'; pBlaze firmware verison 10 (pre-release) + +[1] 'v' + +hw_ver +[2] PPbbFFFF - pp=PCB version 0='A', 1='B', etc; bb=build rev; FFFF=fpga hdl version + +firm_ver +[3] picoblaze firmware version: 0x00-0x7F=pre-release; 0x80-0xFF=release + + +Hi-current Outputs Info: +---------------------- +'h' - indicates current state of hi-current output register + - all outputs active-low +format: h +e.g. msg: h11 + +[1] 'h' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to P2 Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** wired to P1 Start Lamp *** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** UNUSED *** + A=AudioMute *** connected to Audio Mute *** + + +Sync Frequency Info: +-------------------------------- +'f' - indicates detected h- and v-sync frequencies + - NOTE: if this is called multiple times in a frame, may return zeros or bogus data + it is best to obtain several values and range check, average, etc + - Rev A board clk is 24.0MHz, so counter multiplier is 1/24MHz = 41.6666ns + +format: f +e.g. msg: f061AEB02F9 - vsync=1/(0x061AEB x 41.66ns)=59.984Hz; hsync=1/(0x02F9 x 41.66ns)=31.537kHz + +[1] 'f' + +vsync1 +[2] msbits of 20-bit vsync freq count (4bits) + +vsync2 +[3] middle byte of 20-bit vsync freq count (8bits) + +vsync3 +[4] lsbyte of 20-bit vsync freq count (8bits) + +hsync1 +[5] msbits of 10-bit hsync freq count (2bits) + +hsync2 +[6] lsbyte of 10-bit hsync freq count (8bits) + diff --git a/libraries/pmrt/jamma/README_jamma.txt b/libraries/pmrt/jamma/README_jamma.txt new file mode 100755 index 0000000..218bb93 --- /dev/null +++ b/libraries/pmrt/jamma/README_jamma.txt @@ -0,0 +1,117 @@ +README_jamma.txt +Jason Green Raw Thrills +JFL 04 May 05 + +------------------------------------------------------------------------------- +there are a few projects in this directory + +- makefile bulids/updates/cleans all projects +- jammadrvr_lin + the linux jamma driver, a single file, built and then installed as a module + files: jammadrvr_lin.c + output: jammadrvr_lin.o (installed into linux as a module) +- jamma library + files: jamma.h jammapriv.h jamma.c jamma_lin.c + output: libjamma.a jamma.h +- jammatest -- links to the jamma library to test it + files: jammatest.c jamma-lib + output: jammatest.exe +- testlin -- a very simple linux app to test if the driver & jamma board + are working + +------------------------------------------------------------------------------- +building Windows jammausb.lib +(out of date) + +Goal is to build jammausb.lib and copy it into /g3/lib + +jammausb.lib +In MSVC select the 'jammausb files' project +menu Build>Set Active Configuration>Win32 Release +right click>Clean selection only, Build selection only + +jammatest +build jammausb.lib first +then build this + +------------------------------------------------------------------------------- +building linux jamma drivers + +build driver +make driver -- rebuilds the driver jammadrvr_lin.o +make install -- removes old & installs new +lsmod -- look for usbcore [jammadrvr_lin ..] + +build testlin +make + +in /dev/usb/ type + mknod jusb c 180 192 + chmod +666 jusb + +------------------------------------------------------------------------------- +setting up + +links +http://www.lvr.com/hidpage.htm + +hidsdi.h +http://www.microsoft.com/whdc/devtools/ddk/default.mspx + +------------------------------------------------------------------------------- +from RawThrill's linux README.txt +JFL 04 May 05; added + +README for linux JAMMAUSB module +================================ + +- The supplied jammausb.o kernel module was compiled w/GCC 3.2.3 for +kernel 2.4.26 + + +- To build the jammausb module, execute "make" as "./make" from w/in +this directory. Kernel sources must be installed. There is no regular makefile. + +- To communicate with the JAMMA USB board, there must be a "jusb" +node in the /dev/usb/ filesystem with proper permissions and +major/minor numbers. + in /dev/usb/ type "mknod jusb c 180 192", followed by "chmod +660 jusb" + +- Additionally, the jamma usb module must be "blacklisted". This can + modify the hid-core.c + cd /usr/src/linux/drivers/usb/ + --> add the following lines to hid-core.c: + #define USB_VENDOR_ID_JAMMAUSB 0x0483 + #define USB_DEVICE_ID_JAMMAUSB 0x0003 + --> add the following item to the hid_blacklist[] array + { USB_VENDOR_ID_JAMMAUSB, USB_DEVICE_ID_JAMMAUSB, HID_QUIRK_IGNORE } + --> re-build the kernel modules + cd /usr/src/linux + make modules + make modules_install + + http://www.charmed.com/txt/hiddev.txt + http://www.linux-usb.org/FAQ.html + +INTERFACING TO THE JAMMAUSB BOARD +================================= + +- the game-api fxns in jusb_gun.c use the driver interface in jammausb.c to talk to the kernel module jammausb_lin.o + +- only FAST REPORT (report 4) mode is used in the game. Report 5 mode is for debugging only, primarily b/c it is often slow. + +- both report modes can be tested with the supplied test program. Pass in an argument "4" or "5" to see the output from the board. + -- note the line "output_report1(fd, 0x0001);" in the test code which puts the board into FAST REPORT mode + -- in FAST REPORT mode, a change in board status (e.g. switch press, dipswitch value change, lightgun trigger) causes an appropriate report to be sent. + + +NOTES +===== + +In the "gun" version of the board, the following are ignored/unused: + +- Gas/Brake data +- Steering/Clutch data +- Wheel Output enable +- Wheel Position +- PWM output diff --git a/libraries/pmrt/jamma/README_program.txt b/libraries/pmrt/jamma/README_program.txt new file mode 100755 index 0000000..f238fc5 --- /dev/null +++ b/libraries/pmrt/jamma/README_program.txt @@ -0,0 +1,8 @@ +README_program.txt + +// linux serial programming +http://www.vanemery.com/Linux/Serial/serial-console.html +http://www.tldp.org/HOWTO/Serial-HOWTO.html +http://www.ibiblio.org/pub/Linux/docs/HOWTO/ +http://www.easysw.com/~mike/serial/ + diff --git a/libraries/pmrt/jamma/README_serial.txt b/libraries/pmrt/jamma/README_serial.txt new file mode 100755 index 0000000..5d3c86b --- /dev/null +++ b/libraries/pmrt/jamma/README_serial.txt @@ -0,0 +1,162 @@ +README_serial.txt + +new modes + watchdog feed & set time to 5 or 2 minutes + guns independently + autocollectsend gun0 gun1 + triggerflashcollectsend gun0 gun1 + toggle coinmeter 0 1 + misc report + +config +[0] --dw Mm00 + m=toggle coin meter 0 + M=toggle coin meter 1 + w=clear watchdog flag + d=force misc data report + +[1] FfAa--Mr + F=flashgun2 + f=flashgun1 + A=autofiregun2 + a=autofiregun1 + M=mute + r=report4mode +hardware flash gun2 -- 1=CPLD will flash only when gun-trigger down +hardware flash gun1 -- only on next whole redraw +autofire gun2 -- 1=regardless of trigger/flash, send coords if sensed +autofire gun1 -- 0=rely on trigger pull +mute -- 1=mute audio amp +report 4 mode -- 1=get report 4s + +if(hflash&&!autofire) gun and flash must occur simultaneously to get data +if(!hflash) must draw own white screen +if(hflash) screen must be flashing b/c it was triggered +triggering is only through CPLD + +look into improving/testing debouncing -- +right now switches are sampled once per VBL + +The ST7 runs in a loop as fast as it can. + +{R04 .. } + switches are sampled & sent non-debounced when they change + and periodically always + look at Sept 1 2003 Jamma Programming + +/////////////////////////////////////////////////////////////////////////////// +// REPORT 4 PROCESSING +// +// JFL 06 May 05; from JAMMAUSB Board Programming Guide +// Andy Eloff, Raw Thrills, Sept 1, 2003 +// JFL 14 Jun 05; with Jason Green +// +// +// [0] -- report id (part of HID) +// 4 -- report 4 +// [1] nnnxxxxx -- first data byte +// n=0 gun0 data +// n=2 gun1 data +// n=4 general switch data +// n=5 gas/brake data +// n=6 steering/clutch data +// n=7 misc data +// +// player gun data +// [1] 0p0--yxx -- p=player x=xposhi y=yposhi +// [2] xxxxxxxx -- low bits of x +// [3] yyyyyyyy -- low bits of y +// +// general switch data +// [1] 100RrwGg -- R=gun2reload r=gun1reload w=watchdog G=gun2trig g=gun1trig +// [2] b?vtSCsc -- b=bill v=service t=test S=start2 C=coin2 s=start1 c=coin1 +// [3] ---uvV-- -- -=notused u=usbpower v=voldown V=volup (ignore for now) +// +// gas/brake +// not on the gun board +// +// steer/clutch +// not on the gun board +// +// misc data +// [1] 111----w -- -=notused w=watchdogack (? not implemented) +// [2] dipswtch -- dip switch bits +// [3] ? other dipswitch if stuffed +// +// gas/brake +// not on the gun board +// +// steer/clutch +// not on the gun board +// +// misc data +// [1] 111----w -- -=notused w=watchdogack (? not implemented) +// [2] dipswtch -- dip switch bits +// [3] ? other dipswitch if stuffed + +// examples +// {R040140F0} -- gun0 x=320 y=240 +// {R044680E0} -- gun1 x=640 y=480 + +watchdog enabled by default on powerup, must send report 1 (keep alive) +or after 5 minutes (watchdog will reset) + + +Raw Thrills Dipswitch Settings +7 disable watchdog +6 +5 +4 vsync polarity +3 hsync polarity +2 cut horizontal rate in half (CGA) +1 monitor res +0 monitor res + +h & v sync polarities affect not only the monitor, but also the gun triggering + +send +{c } -- reply with current configuration +{R0100C1} -- hardware flash only for both guns +{R0100F1} -- hflash & autoscan + + +-- new modes pending next update of ST7 -- + +Change mode: +--------------- +'A' - Autofire on both guns +'B' - Autofire on gun 1, HW flash on gun2 +'C' - HW flash on gun 1, Autofire on gun 2 +'D' - HW flash on both guns + +Keepalives: +----------- +'E' - keepalive for 2mins +'F' - keepalive for 5mins + +Requests: +---------- +'M' -> coin meter 1 output hi +'N' -> coin meter 1 output lo +'O' -> coin meter 2 output hi +'P' -> coin meter 2 output lo +'Q' -> request Misc Data (dipswitch report) + +**** sending data to the baord will require only 1 byte, no delimiter. +Audio will come up unmuted, w/no means of muting. You will STILL need +to limit the characters down to the board to < 2-per-frame, though that +should pose less of a problem now. +**** data received from the board will begin with one 'type' character +('0' thru '9', for now only '4' for Report 4) followed by ascii encoded +data as previously documented, followed by a . There will be no +start delimiter. + +**** the board will power up in 'fast' mode, and never enter debug mode +(Report 5). Watchdog countdown starts when the board powers up or is +reset, and defaults to 5minutes. If a watchdog timeout occurs, a string + gets sent to the PC like "***WATCHDOG RESET***", a negative pulse +occurs on the COINLOCK1 output on the JAMMA for ~100ms, and THE BOARD +REMAINS IN THE PRE-WATCHDOG STATE (we can change this for the new board) + +I am starting these changes right now, so let me know if you want +changes to the ch ch ch ch cha-anges.... diff --git a/libraries/pmrt/jamma/Release/jamma.obj b/libraries/pmrt/jamma/Release/jamma.obj new file mode 100755 index 0000000..31d2ed1 Binary files /dev/null and b/libraries/pmrt/jamma/Release/jamma.obj differ diff --git a/libraries/pmrt/jamma/Release/jamma_lin.obj b/libraries/pmrt/jamma/Release/jamma_lin.obj new file mode 100755 index 0000000..f9cb179 Binary files /dev/null and b/libraries/pmrt/jamma/Release/jamma_lin.obj differ diff --git a/libraries/pmrt/jamma/Release/jamma_pc.obj b/libraries/pmrt/jamma/Release/jamma_pc.obj new file mode 100755 index 0000000..3079125 Binary files /dev/null and b/libraries/pmrt/jamma/Release/jamma_pc.obj differ diff --git a/libraries/pmrt/jamma/Release/jammalib.lib b/libraries/pmrt/jamma/Release/jammalib.lib new file mode 100755 index 0000000..f57cb90 Binary files /dev/null and b/libraries/pmrt/jamma/Release/jammalib.lib differ diff --git a/libraries/pmrt/jamma/Release/jammalib.pch b/libraries/pmrt/jamma/Release/jammalib.pch new file mode 100755 index 0000000..640a8cc Binary files /dev/null and b/libraries/pmrt/jamma/Release/jammalib.pch differ diff --git a/libraries/pmrt/jamma/Release/vc60.idb b/libraries/pmrt/jamma/Release/vc60.idb new file mode 100755 index 0000000..6fb08ad Binary files /dev/null and b/libraries/pmrt/jamma/Release/vc60.idb differ diff --git a/libraries/pmrt/jamma/SpongebobProtocol_SBv9.txt b/libraries/pmrt/jamma/SpongebobProtocol_SBv9.txt new file mode 100755 index 0000000..b127a43 --- /dev/null +++ b/libraries/pmrt/jamma/SpongebobProtocol_SBv9.txt @@ -0,0 +1,123 @@ +Following are the modifications to the protocol for SpongeBob i/o: + +v2 - added ticket dispensing functionality +v3 - added notch sense polarity control +-- +v5 - added composite sync generation back in (fpga change only) +v6 - disable vcsync signal if cga or ega detected until 1st msg rec'd from game (no protocol change) +v7 - limit switch msgs to 1 per 16ms (no protocol change) +v8 - flush uart input on watchdog (prevent immediate csync re-activation - no protocol change) +-- +v9 - re-enable ticket drive when notch activity is detected _AND_ dispenser is 'empty' (no protocol change) + also removed gun report code to make room for more SpongeBob ticket dispensing logic + + +Switch Change +------------- +'S' - sent immediately on switch change detected, may send up to 5 msgs per frame. Also sent every .5s by default (periodic switch sending is turned on in the config) + +SPONGE BOB: Trackball X- and Y-count values are both 0xFF after reset. The 16ms counter sent with every msg (16ms_cnt) can be used to assist with velocity calculations for the trackball. + +format: S<16ms_cnt> + +[1] 'S' +[2] - u=user bit in config mode; ffffff=6-bit, 16ms counter, $00-$3F (~1sec) +[3] - XXXXXXXX=8-bit trackball X-position count value +[4] - YYYYYYYY=8-bit trackball Y-position count value +[5] <----SSSS> - ----=(was ticket notch) (P1); SSSS=SpongeBob START (P2) +[6] - cccc=coin1_cnt; CCCC=coin2_cnt +[7] - VVVV=volup_cnt; vvvv=voldn_cnt +[8] - TTTT=test_cnt; ssss=serv_cnt +[9] - tttt=tilt_cnt; BBBB=bill_cnt + + +Set Hi-current Outputs: +---------------------- +'H' - sets state of hi-current output lines - one bit per line, active LOW + +SPONGE BOB: The Ticket Drive output is negative logic. After reset the value defaults to 0xA0 i.e. Start lamp ON, Mars lamp OFF, and ticket Drive OFF + +[1] 'H' + +output +[2] CcMmHhA0 + C=CoinLock2 *** wired to SpongeBob Start Lamp *** + c=Coinlock1 *** UNUSED *** + M=CoinMeter2 *** RESERVED FOR SpongeBob Ticket Drive (unmodifiable) *** + m=CoinMeter1 *** wired to coin meter *** + H=Hi-Cout2 *** UNUSED *** + h=Hi-Cout1 *** wired to SpongeBob Mars lamp *** + A=AudioMute *** connected to Audio Mute *** + 0 *** RESERVED for PC RESET (unmodifiable) *** + + +--------------------- ticket dispensing in SpongeBob v2 ------------------ + + +Ticket Status (received from i/o board) +-------------- +'t' - sent in response to "Ticket Status" msg, and: + - when a change is detected in the 'emtpy' status + - when a change is detected in the 'overflow' status + - after each ticket is dispensed + +NOTES: when the 'e' bit is set, the ticket count is non-zero but the drive has timed out. The status + will continue to report the same status AND count value UNTIL a new Ticket Dispense msg is rec'd. + A new Ticket Dispense msg is required to re-attempt the ticket drive. + + when the 'V' bit is set, a Ticket Dispense msg was received which, when added to the current ticket + down-count value, exceeded 1023 tickets. The count value reported is undefined. Only a Ticket + Dispense msg with the "S" bit set will allow ticket dispensing to continue. + + +format: t +e.g. msg: t0028 - 40 tickets left to be dispensed; dispensing currently active + msg: t03FF - 1023 tickets left to be dispensed; dispensing currently active + msg: t0000 - re-start ticket drive if empty & count!=0; if==0 just generate status msg + msg: t8030 - dispenser empty or jammed; dispensing stopped; 50 tickets left to be dispensed + msg: t4123 - ticket counter overflowed; dispensing stopped; ??? tickets to be dispensed + +[1] 'T' + +status +[2] - e=empty indicator (1=empty) + - V=overflow indicator (1=overflowed) + - p=notch polarity indicator (1=use hi->lo transition for count; 0=count ticket on lo->hi {default}) + - tt=msbits 9-8 of ticket down-counter + +count +[3] - tttttttt=lsbits 7-0 of ticket down-counter + + + +Ticket Dispense (sent to i/o board) +--------------- +'T' - always results in a Ticket Status response msg. + - short msg 'T' by itself generates response msg, but does not affect the count or 'e' or 'V' bits + - can be sent to start, stop, or retry ticktet dispensing + +NOTEs: any Ticket Dispense msg will clear the Empty 'e' status bit except the short 'T' msg + + only a msg with the 'S' bit set will clear the Overflow 'V' status bit. +BIG v3 NOTE: + only a msg with the 'S' bit set will set/clear the polarity bit!!! Otherwise it is ignored + + +format: T +e.g. msg: T0028 - add 40 more tickets to ticket counter + msg: T0108 - add 512 more tickets to ticket counter + msg: T0000 - re-start ticket drive if empty & count!=0; if==0 just generate status msg + msg: T8030 - clear overflow bit, clear notch polarity bit, set ticket counter to 50, and dispense tickets + msg: T8000 - clear overflow bit, clear notch polarity bit, set ticket counter to 0 (stop dispensing tickets) + msg: T9208 - clear overflow bit, set notch polarity bit, set ticket counter to 520, and dispense tickets + msg: T9000 - clear overflow bit, set notch polarity bit, set ticket counter to 0 (stop dispensing tickets) + +[1] 'T' + +cmd +[2] - S=Set/add ticket counter (1=set to absolute count value; 0=add value to counter) + - p=notch polarity (1=use hi->lo transition for count; 0=count ticket on lo->hi {default}) + - tt=msbits 9-8 of value + +value +[3] - tttttttt=lsbits 7-0 of value diff --git a/libraries/pmrt/jamma/jamma.c b/libraries/pmrt/jamma/jamma.c new file mode 100755 index 0000000..27511e6 --- /dev/null +++ b/libraries/pmrt/jamma/jamma.c @@ -0,0 +1,2695 @@ +// jamma.c +// Jason Green Raw Thrills +// JFL 06 May 05; restructured and re-written +// JFL 18 Jun 05; re-written +// JFL 29 Jun 05 +// JFL 19 Jul 05; coin meters +// JFL 04 Aug 05; protocol 2 +// JFL 14 Aug 05 +// JFL 11 Sep 05; watchdog hit, cleared +// GNP 13 Mar 06; JAMMAOP_GETSWCOUNT added ability to request switch counts when not changed +// GNP 21 Mar 06; when receiving 'c' config byte is checked against library, config re-sent if different +// GNP 17 May 06; added processing for redemption bowling +// GNP 05 Sep 06; added ability to use verbose gun data and associated processing +// GNP 17 Oct 06; cleaned up signal processing, fixed calibration bug with second gun +// GNP 28 Nov 06; added trackball processing and auto setting of iomode based on firmware version +// GNP 02 May 07; for PC version only, added mutex for serial port read thread and jamma_pktget +// GNP 27 Jun 07; fixed problems with ticket dispenser overflow and erroneous reporting of player 1 start button +// GNP 28 Jun 07; added USB Watchdog support for linux, PC is stubbed +// GNP 28 Feb 08; v23q added error checking on Linux serial I/O due to Dell hardware chopping off data + +#include "jamma.h" +#include "jammapriv.h" // include after jamma.h +#include +#include +#include +#include + +typedef unsigned char uns8; +typedef unsigned int uns32; + +int jamma_ready=0; +jamma_dev jammamem,*jamma_jdev; + +typedef struct { + int dummy; +} jammaGlobals; + +jammaGlobals jammaG; + +#define JAMMA_WAIT_SEROUT 0 // 16 // milliseconds between serial out +#define JAMMA_WAIT_WDOG 5000 // milliseconds between watchdog bone +#define JAMMA_WAIT_METER 96 // milliseconds between meter increments +#define JAMMA_WAIT_PERIODIC 5000 // milliseconds between periodic +#define JAMMA_WAIT_TICKET_ERROR 10000 // milliseconds to wait on ticket error before trying to run dispenser again +#define JAMMA_WAIT_USB_RETRY 30000 // milliseconds to wait to retry connection to usb +#define MIN_GUN_SAMPLES 5 // min gun samples required to process array +// config output +#define M_JAMMA2_C2_P2TRIG 0x80 +#define M_JAMMA2_C2_P1TRIG 0x40 +#define M_JAMMA2_C2_P2AUTOFIRE 0x20 +#define M_JAMMA2_C2_P1AUTOFIRE 0x10 +#define M_JAMMA2_C2_DBGGUN 0x01 +#define M_JAMMA2_C3_PERIODICSW 0x01 +#define M_JAMMA2_C3_CLEARWDOGHIT 0x40 +#define M_JAMMA2_C3_USERBIT 0x80 + +// high current output bits +#define M_JAMMA2_H_LIGHT2 0x80 // player 2 start lamp +#define M_JAMMA2_H_METER2 0x40 // on current system, not wired, untested +#define M_JAMMA2_H_LIGHT1 0x20 // player 1 start lamp +#define M_JAMMA2_H_METER1 0x10 // coin meter 1 +#define M_JAMMA2_H_2 0x08 // hi current output 2 +#define M_JAMMA2_H_1 0x04 // hi current output 1 +#define M_JAMMA2_H_AUDIOMUTE 0x02 + +// M_JAMMA2_H_LOGIC_ defines which drive lines are active low, default is none +#define M_JAMMA2_H_LOGIC_DEFAULT 0x00 +#define M_JAMMA2_H_LOGIC_SBB M_JAMMA2_H_LOGIC_DEFAULT // ticket dispensers are active low + +// gun input message -- byte 2 +#define M_JAMMA2_G2_GUNCAUSE 0x01 // cause was a gun trigger +#define M_JAMMA2_G2_WHITEFLASH 0x02 // cause was a white flash only +#define M_JAMMA2_G2_ID 0xf0 // ID field of cause register + +// config input info +#define M_JAMMA2_G2_USER 0x80 +#define M_JAMMA2_G2_WATCHDOG 0x40 + +// switch bits received +#define M_JAMMA2_S1_USER 0x80 + +// config bits received +#define M_JAMMA2_C2_USER 0x80 + +int gunSampleDebugRaw[1+JAMMA_MAX_GUN_SAMPLES*2]; +int gunSampleDebugUsed[1+JAMMA_MAX_GUN_SAMPLES*2]; + +// forward +void gunPreProcessSamples(int*, int*, int*); +void gunProcessSamples(int *gunIntQ, int gunIntCnt, int *rX, int *rY, int *rFreq); + +// +// dprintf +// debug printf to console +// +static void dprintf(char *fmt,...) +{ +#ifdef DEBUG + va_list args; + va_start(args,fmt); + vprintf(fmt,args); + va_end(args); +#endif //DEBUG +} // dmsg() + +// JFL 05 May 05 +int JammaInit(void) +{ + int ec; + jamma_dev *jdev; + + // + // init + // + + jamma_jdev=NULL; + jamma_ready=0; + memset(&jammamem,0,sizeof(jammamem)); + memset(&jammaG,0,sizeof(jammaG)); + + // + // open + // + + if((ec=jamma_init())<0) + goto BAIL; + jdev=&jammamem; + + // + // usb watchdog + // +#ifdef USB_WATCHDOG + if(jamma_usbwd_open(jdev) >= 0) + { + jamma_usbwd_config(jdev,USBWD_CONFIG_REQUEST); + } + else + { + // if we can't find the USB watchdog board initially + // then we will act as if the 'original' configuration + // bits are valid to ensure that the watchdog reporting + // mechanism works OK + jdev->flags|=M_JAMMA_USB_ORG_VALID; + jdev->usbretrytime=JAMMA_WAIT_USB_RETRY+jamma_tick(); + } +#endif //USB_WATCHDOG + // + // com port config + // + + jdev->com|=M_JAMMACOM_BAUD_115200; + + if((ec=jamma_open(jdev))<0) + goto BAIL; + + jammamem.bufsize=4096; + if(!(jammamem.buf=jamma_apphook_malloc(jammamem.bufsize))) + err(ERR_JAMMA_MEM); + + jammamem.sndsize=256; + if(!(jammamem.snd=jamma_apphook_malloc(jammamem.sndsize))) + err(ERR_JAMMA_MEM); + + jamma_jdev=jdev; + jdev->sndwait=JAMMA_WAIT_SEROUT; // milliseconds between serial output + jdev->wdogwait=JAMMA_WAIT_WDOG; // milliseconds between watchdog bones + jdev->wdogboneclicks=5*JAMMAWATCHDOG_CLICKS_PER_MINUTE; // 5 minute + jdev->iomode = JAMMAIOMODE_BBH; + jdev->highcurrentlogic = M_JAMMA2_H_LOGIC_DEFAULT; + + // + // open & setup, now send config info to board + // + + jamma_msg(jamma_jdev,JAMMAMSG_GETCONFIG); + jamma_msg(jamma_jdev,JAMMAMSG_CONFIG); + jamma_msg(jamma_jdev,JAMMAMSG_GETVERSION); + jamma_msg(jamma_jdev,JAMMAMSG_GETSWCOUNTS); + + jamma_ready=1; + + ec=0; +BAIL: + return ec; +} // JammaInit() + +// JFL 05 May 05 +void JammaFinal(void) +{ + jamma_ready=0; + + if(jammamem.buf) + jamma_apphook_free(jammamem.buf); + jammamem.buf=NULL; + + if(jammamem.snd) + jamma_apphook_free(jammamem.snd); + jammamem.snd=NULL; + + if(jamma_jdev) + { +#ifdef USB_WATCHDOG + jamma_usbwd_close(jamma_jdev); +#endif //USB_WATCHDOG + jamma_close(jamma_jdev); + } + jamma_jdev=NULL; + + jamma_final(); + +} // JammaFinal() + +// JFL 18 Jun 05 +unsigned ch2b(char a,char b) +{ + unsigned x; + + if(a>='0' && a<='9') + x=(a-'0')<<4; + else if(a>='a' && a<='z') + x=(a-'a'+10)<<4; + else if(a>='A' && a<='Z') + x=(a-'A'+10)<<4; + else + x=0; + + if(b>='0' && b<='9') + x|=(b-'0'); + else if(b>='a' && b<='z') + x|=(b-'a'+10); + else if(b>='A' && b<='Z') + x|=(b-'A'+10); + + return x; +} // ch2b() + +// JFL 21 Jun 05 +void b2ch(unsigned x,char *ch) +{ + unsigned a; + + a=(x>>4)&0xf; + if((a>=0) && (a<=9)) + ch[0]='0'+a; + else +// ch[0]='A'+a-10; + ch[0]='a'+a-10; + + a=x&0xf; + if((a>=0) && (a<=9)) + ch[1]='0'+a; + else +// ch[1]='A'+a-10; + ch[1]='a'+a-10; + +} // b2ch() + + +enum { + JAMMAPKTMODE_NONE, + JAMMAPKTMODE_HEX1, + JAMMAPKTMODE_HEX2, + JAMMAPKTMODE_MSG, + JAMMAPKTMODE_ERR, +}; + +#ifdef DEBUG +#define JPRINT_BINBUF_SIZE 40 +void jamma_print_bin_buf(unsigned char *inBuf, unsigned int size) +{ + char buf[JPRINT_BINBUF_SIZE]; + unsigned i,j; + unsigned char d; + + i=0,j=0; + + while(j < size) + { + + if (i>=JPRINT_BINBUF_SIZE-3) + { + buf[i]=0; + jamma_apphook_msg("%s\n",buf); + i=0; + } + + d=inBuf[j++]; + b2ch(d,&buf[i]); + i+=2; + } + + if(i!=0) + { + buf[i]=0; + jamma_apphook_msg("%s\n",buf); + } + +} //jamma_print_bin_buf +#endif //DEBUG + +// JFL 18 Jun 05 +int jamma_pktget(jamma_dev *jdev,unsigned char *buf,int bufsize) +{ + int ec; + char c,c1; + unsigned char m; + int i; +#ifdef DEBUG + unsigned bufsave,charerr; +#endif //DEBUG + + i=0; // count + m=JAMMAPKTMODE_NONE; // mode + c1='0'; //makes optimizer happy + + // make sure no-one is using buf + jamma_mutex_wait(jdev); + +#ifdef DEBUG + bufsave=jdev->bufr; + charerr=0; +#endif //DEBUG + + // -- not yet -- c1='0'; // first digit is implied '0' in normal packet + while(jdev->bufn) + { + if(jdev->bufr>=jdev->bufsize) + jdev->bufr=0; + c=jdev->buf[jdev->bufr++];jdev->bufn--; + + if((jdev->flags&M_JAMMA_RCVASCII) + &&(jdev->asciibufiasciibufsize)) + jdev->asciibuf[jdev->asciibufi++]=c; + + // there are 3 types of packets + // 1- letter packets that start with a character and end with CR + // and are followed by a string of 2 ascii-hex-digit bytes + // 2- message packets that end with a CR + // these start with a '*' + // 3- in CHARPKT mode, every char is its own packet + // -- note: w/protocol 2, packets are sent with a leading LF + // this is stripped in the lower level + + // check for end of packet + if(c=='\r') + { + jdev->avail--; + err(i); + } + else if(jdev->flags&M_JAMMA_CHARPKT) + { + if(i>bufsize) + err(-1); + buf[i++]=c; + jdev->avail--; + err(i); + } + else if(m==JAMMAPKTMODE_ERR) + { + // skip till pkt end + continue; + } + else if(!i) + { + if(c=='*') + m=JAMMAPKTMODE_MSG; // message mode + else + { + // start a 'normal' pkt + // this first char should be a character pkt type + if(c<0x20) + { + // BS character received + m=JAMMAPKTMODE_ERR; + } + else + { + buf[i++]=c; + m=JAMMAPKTMODE_HEX1; + } + continue; + } + } + + // in message mode, copy till pkt end + if(m==JAMMAPKTMODE_MSG) + { + if(i>bufsize) + err(-1); + buf[i++]=c; + continue; + } // message mode + + // + // normal packet + // + + // starts with a single hex digit packet type + // followed by any number of two hex digit bytes + // terminated by a CR + + // inside normal packet, ignore unrecognized chars + if((c>='0' && c<='9') + ||(c>='a' && c<='f') + ||(c>='A' && c<='F')) + ; /* OK */ + else + { +#ifdef DEBUG + jamma_apphook_msg("jamma_pktget(): deleting illegal character %x\n",(unsigned char)c); + charerr=1; +#endif //DEBUG + continue; /* ignore */ + } + + // first digit in 2 hex-digit cycle + if(m==JAMMAPKTMODE_HEX1) + { + c1=c; + m=JAMMAPKTMODE_HEX2; + continue; + } + + // second digit in 2 hex-digit cycle + if(m==JAMMAPKTMODE_HEX2) + { + m=JAMMAPKTMODE_HEX1; // restart + if(i>bufsize) + err(-1); + buf[i++]=(unsigned char)ch2b(c1,c); + continue; + } + } // while + + ec=0; + +BAIL: + +#ifdef DEBUG + if(i && charerr) + { + jamma_apphook_msg("jamma_pktget(): packet after removing illegal chars, size=%d\n",ec); + jamma_print_bin_buf(buf, i); + } +#endif //DEBUG + + jamma_mutex_release(jdev); + return ec; +} // jamma_pktget() + +// JFL 20 Jun 05 +// JFL 29 Jun 05 +// JFL 04 Aug 05 +int jamma_msg(jamma_dev *jdev,unsigned msg) +{ + int ec; + int len; + unsigned x,y; + char buf[32]; + unsigned w=0; // for turning lights on/off w/guns + + buf[0]='\n'; // all start + + switch(msg&M_JAMMAMSG) + { + case JAMMAMSG_CONFIG: + buf[1]='C'; + + x=0; + if(jdev->flags&M_JAMMA_VERBOSEGUN) + x|=M_JAMMA2_C2_DBGGUN; // long debug gun messages w/lots of xy data + if(jdev->flags&M_JAMMA_GUN1) + x|=M_JAMMA2_C2_P1TRIG; + if(jdev->flags&M_JAMMA_GUN2) + x|=M_JAMMA2_C2_P2TRIG; + if(jdev->flags&M_JAMMA_GUNAUTO1) + x|=M_JAMMA2_C2_P1AUTOFIRE; + if(jdev->flags&M_JAMMA_GUNAUTO2) + x|=M_JAMMA2_C2_P2AUTOFIRE; + + b2ch(x,&buf[2]); + w=x; // to watch -- used to turn start button lights on/off for debug + + x=M_JAMMA2_C3_USERBIT; // always set user bit w/config + if(!(jdev->flags&M_JAMMA_PERIODICSW)) + x|=M_JAMMA2_C3_PERIODICSW; + if(jdev->flags&M_JAMMA_CLEARWDOGHIT) + x|=M_JAMMA2_C3_CLEARWDOGHIT; + + b2ch(x,&buf[4]); + len=6; + break; + + case JAMMAMSG_WATCHDOG: + x=jdev->wdogboneclicks; // use JAMMAWATCHDOG_CLICKS_PER_MINUTE +#ifdef USB_WATCHDOG + if(jdev->usbwd_dev) + { + // add 4 seconds to bone because USBwd asserts the watchdog + // that much earlier do to 'reset' switch behavior of PC + if(jamma_usbwd_throwwatchdogbone(jdev,x*4+4)<0) + jdev->errorf |= M_JAMMA_ERRORF_USBWD; + } +#endif //USB_WATCHDOG + buf[1]='W'; + b2ch(x,&buf[2]); + len=4; + break; + + case JAMMAMSG_METER1: + x=M_JAMMA2_H_METER1; + goto highcurrent; + case JAMMAMSG_METER2: + // + // special case for redemption games + // ticket meter is driven through hi-current 1 + // + if(jdev->iomode == JAMMAIOMODE_SBB) + x=M_JAMMA2_H_1; + else + x=M_JAMMA2_H_METER2; + + goto highcurrent; + case JAMMAMSG_METER2A: + // special case for ticket games that do not use + // hi-current 1 for the ticket meter + x=M_JAMMA2_H_LIGHT2; + goto highcurrent; + case JAMMAMSG_LIGHT1: + x=M_JAMMA2_H_LIGHT1; + goto highcurrent; + case JAMMAMSG_LIGHT2: + x=M_JAMMA2_H_LIGHT2; + goto highcurrent; + case JAMMAMSG_HICURRENT1: + x=M_JAMMA2_H_1; + goto highcurrent; + case JAMMAMSG_HICURRENT2: + x=M_JAMMA2_H_2; +highcurrent: + // keep track of highcurrent state (active high here) + if(msg&M_JAMMAMSG_ON) + jdev->highcurrent|=x; // go high (on) + else + jdev->highcurrent&=~x; // go low (off) + + // set physical drive logic correctly + x=jdev->highcurrent^jdev->highcurrentlogic; + + buf[1]='H'; + b2ch(x,&buf[2]); + len=4; + break; + case JAMMAMSG_GETSWCOUNTS: + buf[1]='S'; + len=2; + break; + case JAMMAMSG_GETSWSTATES: + buf[1]='s'; + len=2; + break; + case JAMMAMSG_GETCONFIG: + buf[1]='c'; + len=2; + break; + case JAMMAMSG_GETVERSION: + buf[1]='v'; + len=2; + break; + case JAMMAMSG_WHITEFLASH: + len=1; + buf[len++]='F'; + x=jdev->whiteflash[0]&0xff; // vfont + b2ch(x,&buf[len]);len+=2; + x=jdev->whiteflash[1]&0xff; // vback + b2ch(x,&buf[len]);len+=2; + x =(jdev->whiteflash[1]&0x300)>>(8-4); // vfont + x|=(jdev->whiteflash[0]&0x300)>>8; + b2ch(x,&buf[len]);len+=2; // vb_vf -- misnamed? + + x=jdev->whiteflash[2]&0xff; // hfont + b2ch(x,&buf[len]);len+=2; + x=jdev->whiteflash[3]&0xff; // hback + b2ch(x,&buf[len]);len+=2; + x =(jdev->whiteflash[3]&0x700)>>(8-4); // hfont + x|=(jdev->whiteflash[2]&0x700)>>8; + b2ch(x,&buf[len]);len+=2; // hb_hf -- misnamed? + + break; + case JAMMAMSG_TICKET1ADD: + buf[1]='T'; + x=y=0; + + // check for overflow before we start, just in case + if (jdev->ticketiocur[0] > JAMMAIO_MAX_TICKETS) + { + dprintf("jamma_msg(): JAMMAMSG_TICKET1ADD current ticket count maxed (%d).\n",JAMMAIO_MAX_TICKETS - jdev->ticketiocur[0]); + // shove overflowed tickets back on global ticket counter + jdev->ticketcnt[0] += JAMMAIO_MAX_TICKETS - jdev->ticketiocur[0]; + jdev->ticketcnt[0] += jdev->ticketioadd[0]; + jdev->ticketioadd[0]=0; + } + + // add amount of tickets + jdev->ticketiocur[0] += jdev->ticketioadd[0]; + + // check for overflow after we added, just in case + if (jdev->ticketiocur[0] > JAMMAIO_MAX_TICKETS) + { + dprintf("jamma_msg(): JAMMAMSG_TICKET1ADD current ticket count overflowed by %d tickets.\n",JAMMAIO_MAX_TICKETS - jdev->ticketiocur[0]); + jdev->ticketcnt[0] += (JAMMAIO_MAX_TICKETS - jdev->ticketiocur[0]); + jdev->ticketioadd[0] -= (JAMMAIO_MAX_TICKETS - jdev->ticketiocur[0]); + } + + if (jdev->flags & M_JAMMA_TICKET1) + { + // ticket dispenser currently running + // sanity check the add + if (jdev->ticketioadd[0] < 0) + jdev->ticketioadd[0]=0; + + x = (jdev->ticketioadd[0] >> 8) & 0x3; // hi bits of count + y = jdev->ticketioadd[0] & 0xff; // lo bits of count + } + else + { + // ticket dispenser not running + x = (jdev->ticketiocur[0] >> 8) & 0x3; // hi bits of count + y = jdev->ticketiocur[0] & 0xff; // lo bits of count + x |= 0x80; //hard set + if(jdev->flags & M_JAMMA_TICKET_POLARITY) + x |= 0x10; // set polarity correctly + jdev->flags |= M_JAMMA_TICKET1; + } + jdev->flags &= ~M_JAMMA_TICKET_ERROR; // clear error + jdev->ticketioadd[0]=0; + b2ch(x,&buf[2]); + b2ch(y,&buf[4]); + len=6; + break; + case JAMMAMSG_TICKET1STOP: + buf[1]='T'; + x=0x80; + if(jdev->flags & M_JAMMA_TICKET_POLARITY) + x |= 0x10; // set polarity correctly + b2ch(x,&buf[2]); + x=0x00; + b2ch(x,&buf[4]); + len=6; + break; + default: + err(-1); + } // switch + + // finish off + buf[len++]='\r'; // all end + + // send + if((ec=jamma_send(jdev,1 /* block */,buf,len))<0) + goto BAIL; + + // set lights based on guns + if((jdev->flags&M_JAMMA_WATCHLIGHTS) + && ((msg&M_JAMMAMSG)==JAMMAMSG_CONFIG)) + { + x=jdev->highcurrent; + x&=~(M_JAMMA2_H_LIGHT1|M_JAMMA2_H_LIGHT2); // both off + if(w&M_JAMMA2_C2_P1TRIG) + x|=M_JAMMA2_H_LIGHT1; + if(w&M_JAMMA2_C2_P2TRIG) + x|=M_JAMMA2_H_LIGHT2; + x^=jdev->highcurrentlogic; + buf[1]='H'; + b2ch(x,&buf[2]); + len=4; + buf[len++]='\r'; // all end + if((ec=jamma_send(jdev,1 /* block */,buf,len))<0) + goto BAIL; + } // set lights based on guns -- jjj + + ec=0; +BAIL: + if(ec<0) + jamma_apphook_msg("jamma_msg() %d\n",ec); + + return ec; +} // jamma_msg() + +// JFL 10 May 05 +// JFL 18 Aug 05 +int JammaOp(unsigned int op,...) +{ + int ec; + va_list args; + unsigned char *buf; + int i,j; + unsigned u; + float f1,f2; + char *s1; + float dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2; + JammaInpRec **jirp; + + va_start(args,op); + + //printf("JammaOp: %i\n", op); + + switch(op&M_JAMMAOP) + { + case JAMMAOP_GETDIPSWITCHES: // unsigned int dipswitch register M_JAMMADIP_ + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=jamma_jdev->ir.dipstate; +#ifdef USB_WATCHDOG + if(jamma_jdev->flags& (M_JAMMA_ORG_VALID|M_JAMMA_USB_ORG_VALID)) // make sure both are reporting back +#else + if(jamma_jdev->flags&M_JAMMA_ORG_VALID) +#endif //USB_WATCHDOG + { + i|=M_JAMMADIP_SPECIAL_VALID; + if(jamma_jdev->flags&M_JAMMA_ORG_WATCHDOG) + i|=M_JAMMADIP_SPECIAL_WATCHDOG; + if(jamma_jdev->flags&M_JAMMA_ORG_USER) + i|=M_JAMMADIP_SPECIAL_USER; +#ifdef USB_WATCHDOG + if(jamma_jdev->flags&M_JAMMA_USB_WATCHDOG) + i|=M_JAMMADIP_SPECIAL_WATCHDOG; +#endif //USB_WATCHDOG + } + err(i); // return i + break; + case JAMMAOP_GETINPREC: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jirp=va_arg(args,JammaInpRec**); + *jirp=&jamma_jdev->ir; +#ifdef USB_WATCHDOG + if(jamma_jdev->flags& (M_JAMMA_ORG_VALID|M_JAMMA_USB_ORG_VALID)) // make sure both are reporting back +#else + if(jamma_jdev->flags&M_JAMMA_ORG_VALID) +#endif //USB_WATCHDOG + if(jamma_jdev->flags&M_JAMMA_ORG_VALID) + { + (*jirp)->dipstate|=M_JAMMADIP_SPECIAL_VALID; + if(jamma_jdev->flags&M_JAMMA_ORG_WATCHDOG) + (*jirp)->dipstate|=M_JAMMADIP_SPECIAL_WATCHDOG; + if(jamma_jdev->flags&M_JAMMA_ORG_USER) + (*jirp)->dipstate|=M_JAMMADIP_SPECIAL_USER; +#ifdef USB_WATCHDOG + if(jamma_jdev->flags&M_JAMMA_USB_WATCHDOG) + (*jirp)->dipstate|=M_JAMMADIP_SPECIAL_WATCHDOG; +#endif //USB_WATCHDOG + } + break; + + case JAMMAOP_RCVBIN: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); + if(!ec) + jamma_jdev->flags&=~M_JAMMA_RCVBIN; + else if(ec==1) + jamma_jdev->flags|=M_JAMMA_RCVBIN; + else + jamma_jdev->flags^=M_JAMMA_RCVBIN; + break; + case JAMMAOP_RCVASCII: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); + if(!ec) + jamma_jdev->flags&=~M_JAMMA_RCVASCII; + else if(ec==1) + { + jamma_jdev->flags|=M_JAMMA_RCVASCII; + if((s1=va_arg(args,char*))) + { + jamma_jdev->asciibuf=s1; + jamma_jdev->asciibufsize=va_arg(args,int); + } + jamma_jdev->asciibufi=0; + } + else + jamma_jdev->flags^=M_JAMMA_RCVASCII; + + break; + case JAMMAOP_SETCALLBACK: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jamma_jdev->callback=va_arg(args,void*); + break; + case JAMMAOP_RESET: + if(!jamma_jdev) + { + JammaFinal(); + JammaInit(); + } + + if(!jamma_jdev) + err(-100); + + jamma_reset(jamma_jdev,0); + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_CONFIG))<0) + goto BAIL; + + break; + + case JAMMAOP_RECONFIG: + + // this resets error flags & send config info down again + + if(!jamma_jdev) + { + JammaFinal(); + JammaInit(); + } + + if(!jamma_jdev) + err(-100); + + jamma_reset(jamma_jdev,M_JAMMARESET_ERROR|M_JAMMARESET_HDW); + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_CONFIG))<0) + goto BAIL; + + break; + + case JAMMAOP_SENDBUF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + buf=va_arg(args,char*); + i=va_arg(args,int); + if((ec=jamma_send(jamma_jdev,0,buf,i))<0) + goto BAIL; + break; + + case JAMMAOP_GETVERSTRING: + buf=va_arg(args,char*); + i=va_arg(args,int)-1; + s1=JAMMA_VER_STRING; + while(i>0 && *s1) + *buf++=*s1++,i--; + s1=JAMMAPRIV_VER_STRING; + while(i>0 && *s1) + *buf++=*s1++,i--; + if(i>0) + *buf++='.',i--; + if(jamma_jdev && (i>3)) + { + *buf++='H',i--; + b2ch(jamma_jdev->versHW,buf); + i-=2,buf+=2; + } + if(i>0) + *buf++='.',i--; + if(jamma_jdev && (i>3)) + { + *buf++='F',i--; + b2ch(jamma_jdev->versFW,buf); + i-=2,buf+=2; + } +#ifdef USB_WATCHDOG + if(i>0) + *buf++='.',i--; + if(jamma_jdev && (i>3)) + { + *buf++='U',i--; + b2ch(jamma_jdev->versUSB,buf); + i-=2,buf+=2; + } +#endif //USB_WATCHDOG + // space + if(i>0) + *buf++=' ',i--; + +#ifdef DEBUG + // 'D' for debug + if(i>0) + *buf++='D',i--; +#else + // 'R' for release + if(i>0) + *buf++='R',i--; +#endif + *buf=0; + break; + case JAMMAOP_GETTICK: + buf=va_arg(args,char*); + *((unsigned long*)buf)=jamma_tick(); + break; + case JAMMAOP_SETSCRWH: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jamma_jdev->calibwh[0]=(float)va_arg(args,int); + jamma_jdev->calibwh[1]=(float)va_arg(args,int); + break; + case JAMMAOP_SETCALIBLTRB: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jamma_jdev->calibxy[0]=(float)va_arg(args,int); + jamma_jdev->calibxy[1]=(float)va_arg(args,int); + f1=(float)va_arg(args,int); + f1-=jamma_jdev->calibxy[0]; // right-left + f2=(float)va_arg(args,int); + f2-=jamma_jdev->calibxy[1]; // bottom-top + f1=jamma_jdev->calibwh[0]/f1; + f2=jamma_jdev->calibwh[1]/f2; + jamma_jdev->calibmul[0]=f1; + jamma_jdev->calibmul[1]=f2; + break; + case JAMMAOP_SETCALIBGLTRB: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); + if((i<0)||(i>=JAMMA_GUNS)) + i=0; + jamma_jdev->calibflags[i]=1; // signal gun has been calibrated + i*=2; + jamma_jdev->calibxy[0+i]=(float)va_arg(args,int); + jamma_jdev->calibxy[1+i]=(float)va_arg(args,int); + f1=(float)va_arg(args,int); + f1-=jamma_jdev->calibxy[0+i]; // right-left + f2=(float)va_arg(args,int); + f2-=jamma_jdev->calibxy[1+i]; // bottom-top + f1=jamma_jdev->calibwh[0]/f1; + f2=jamma_jdev->calibwh[1]/f2; + jamma_jdev->calibmul[0+i]=f1; + jamma_jdev->calibmul[1+i]=f2; + break; + case JAMMAOP_SETCALIBGSXYXYDXYXY: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + + // get gun number + i=va_arg(args,int); + if((i<0)||(i>=JAMMA_GUNS)) + i=0; + jamma_jdev->calibflags[i]=1; // signal gun has been calibrated + i*=2; + + // get sampled points + sx1=(float)va_arg(args,int); + sy1=(float)va_arg(args,int); + sx2=(float)va_arg(args,int); + sy2=(float)va_arg(args,int); + + // get drawn points + dx1=(float)va_arg(args,int); + dy1=(float)va_arg(args,int); + dx2=(float)va_arg(args,int); + dy2=(float)va_arg(args,int); + +#if 0 + // find sample -> draw multiplier + f1=dx2-dx1; // drawn width + f2=sx2-sx1; // sampled width + if(f2==0) + jamma_jdev->calibmul[0+i]=f1; // draw/sample + else + jamma_jdev->calibmul[0+i]=f1/f2; // draw/sample + + f1=dy2-dy1; // drawn height + f2=sy2-sy1; // sampled height + if(f2==0) + jamma_jdev->calibmul[1+i]=f1; + else + jamma_jdev->calibmul[1+i]=f1/f2; + + // project to find sampling 0,0 + jamma_jdev->calibxy[0+i]=sx1-(dx1/jamma_jdev->calibmul[0+i]); + jamma_jdev->calibxy[1+i]=sy1-(dy1/jamma_jdev->calibmul[1+i]); +#endif + // find sample -> draw multiplier +// printf("setting calibration for gun %d\n",i/2); +// printf("shot TL = %f,%f, LR = %f,%f\n",sx1,sy1,sx2,sy2); +// printf("point TL = %f,%f, LR = %f,%f\n",dx1,dy1,dx2,dy2); + f2=dx2-dx1; // drawn width + f1=sx2-sx1; // sampled width + if(f2!=0) + f1 = f1/f2; + if(f1==0) + f1=0.001f; + jamma_jdev->calibmul[0+i]=f1; // sample/draw + + f2=dy2-dy1; // drawn height + f1=sy2-sy1; // sampled height + if(f2!=0) + f1 = f1/f2; + if(f1==0) + f1=0.001f; + jamma_jdev->calibmul[1+i]=f1; + + // project to find sampling 0,0 + jamma_jdev->calibxy[0+i]=sx1-(dx1*jamma_jdev->calibmul[0+i]); + jamma_jdev->calibxy[1+i]=sy1-(dy1*jamma_jdev->calibmul[1+i]); + +// printf("mX = %f, bX = %f\n",jamma_jdev->calibmul[0+i],jamma_jdev->calibxy[0+i]); +// printf("mY = %f, bY = %f\n",jamma_jdev->calibmul[1+i],jamma_jdev->calibxy[1+i]); + + + break; + case JAMMAOP_SETCALIBMODE: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); // mode + for(ec=0;eccalibmode[ec]=i; + break; + case JAMMAOP_SETCALIBGMODE: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); // gun + i=va_arg(args,int); // mode + if(ec<0 || ec>=JAMMA_GUNS) + ec=0; + jamma_jdev->calibmode[ec]=i; + break; + + case JAMMAOP_SETCHARPKTMODE: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + if(va_arg(args,int)) + jamma_jdev->flags|=M_JAMMA_CHARPKT; + else + jamma_jdev->flags&=~M_JAMMA_CHARPKT; + break; + + case JAMMAOP_WATCHDOGBONE: + // this sends a bone + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_WATCHDOG))<0) + goto BAIL; + break; + case JAMMAOP_WATCHDOGBONE_SETCLICKPERIOD: + // this sets the size of the bone + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jamma_jdev->wdogboneclicks=va_arg(args,unsigned); // in clicks + break; + case JAMMAOP_WATCHDOGBONE_SETSENDMILLISECONDS: + // this sets how often the bone is sent + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jamma_jdev->wdogwait=va_arg(args,unsigned); // in milliseconds + break; + + // turn gun on/off - collects data on trigger pull and with white flash + case JAMMAOP_GUNONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); // gun1, gun2 + if(!i) + u=M_JAMMA_GUN1; + else if(i==1) + u=M_JAMMA_GUN2; + else + break; + + ec=va_arg(args,int); // on/off + if(!ec) // off + jamma_jdev->flags&=~u; + else // on + jamma_jdev->flags|=u; + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_CONFIG))<0) + goto BAIL; + break; + + // turn gun on/off - collects data all the time + case JAMMAOP_GUNAUTOONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); // gun1, gun2 + if(!i) + u=M_JAMMA_GUNAUTO1; + else if(i==1) + u=M_JAMMA_GUNAUTO2; + else + break; + + ec=va_arg(args,int); // on/off + if(!ec) // off + jamma_jdev->flags&=~u; + else // on + jamma_jdev->flags|=u; + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_CONFIG))<0) + goto BAIL; + break; + + case JAMMAOP_GUNVERBOSEONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + u=M_JAMMA_VERBOSEGUN; + ec=va_arg(args,int); // on/off + if(!ec) // off + jamma_jdev->flags&=~u; + else // on + jamma_jdev->flags|=u; + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_CONFIG))<0) + goto BAIL; + break; + + case JAMMAOP_STARTLIGHTONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); // start light # + if(!i) + u=M_JAMMA_SLIGHT1,j=JAMMAMSG_LIGHT1; + else if(i==1) + u=M_JAMMA_SLIGHT2,j=JAMMAMSG_LIGHT2; + else + break; + // u = M_JAMMA_ + // j = JAMMAMSG_ +output_onoff: + ec=va_arg(args,int); // on/off + if(!ec) // off + jamma_jdev->flags&=~u; + else // on + jamma_jdev->flags|=u,j|=M_JAMMAMSG_ON; + + if((ec=jamma_msg(jamma_jdev,j))<0) + goto BAIL; + break; + + case JAMMAOP_GETSWCOUNT: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + if(op&M_JAMMAOP_IGNORECHANGED) + { + if(!(jamma_jdev->flags&M_JAMMA_USERBIT)) + err(ERR_JAMMA_SWITCHDATA_NOTVALID); // switch data is not yet valid + } + else + { + if(!(jamma_jdev->flags&M_JAMMA_SWRCV)) + err(ERR_JAMMA_SWITCHDATA_UNCHANGED); // no switch changes + } + s1=va_arg(args,char*); + if(s1) + *((unsigned*)s1)=jamma_jdev->swchanged; + if(op&M_JAMMAOP_CLEAR) + jamma_jdev->swchanged=0; + s1=va_arg(args,char*); + if(s1) + *((unsigned**)s1)=jamma_jdev->ir.swcount; + break; + + case JAMMAOP_GETSWSTATES: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_GETSWSTATES))<0) + goto BAIL; + break; + + case JAMMAOP_DONTSENDBONE: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + if(va_arg(args,int)) + { + // if we are switching states, then clear watchdog message flag + if(!(jamma_jdev->flags & M_JAMMA_DONTSENDBONE)) + jamma_jdev->flags &= ~M_JAMMA_WATCHDOG_MSG; + + jamma_jdev->flags|=M_JAMMA_DONTSENDBONE; + } + else + { + // if we are switching states, then clear watchdog message flag + if(jamma_jdev->flags & M_JAMMA_DONTSENDBONE) + jamma_jdev->flags &= ~M_JAMMA_WATCHDOG_MSG; + + jamma_jdev->flags&=~M_JAMMA_DONTSENDBONE; + } + break; + + case JAMMAOP_COINMETERINC: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); // coin meter (0 or 1) + i=va_arg(args,int); // number of clicks + i*=2; // for high & low + + switch (ec) + { + case 0: + jamma_jdev->meter1+=i; + break; + + case 1: + jamma_jdev->meter2+=i; + break; + + case 2: + jamma_jdev->meter3+=i; + break; + } + + // always bump up meter time + jamma_jdev->metertick=JAMMA_WAIT_METER+jamma_tick(); + break; + + case JAMMAOP_GETSN: + i=va_arg(args,int); + err(jamma_getsn(i)); + break; + + case JAMMAOP_REQUESTCOUNTS: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_GETSWCOUNTS))<0) + goto BAIL; + break; + + case JAMMAOP_REQUESTCONFIG: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); +#ifdef USB_WATCHDOG + if (jamma_jdev->usbwd_dev) + jamma_usbwd_config(jamma_jdev,USBWD_CONFIG_REQUEST); +#endif //USB_WATCHDOG + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_GETCONFIG))<0) + goto BAIL; + break; + + case JAMMAOP_REQUESTVERSION: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); +#ifdef USB_WATCHDOG + if (jamma_jdev->usbwd_dev) + jamma_usbwd_config(jamma_jdev,USBWD_VERSION_REQUEST); +#endif //USB_WATCHDOG + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_GETVERSION))<0) + goto BAIL; + break; + + case JAMMAOP_WATCHLIGHTSONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); + if(i) + jamma_jdev->flags|=M_JAMMA_WATCHLIGHTS; + else + jamma_jdev->flags&=~M_JAMMA_WATCHLIGHTS; + break; + + case JAMMAOP_WHITEFLASH_VFB_HFB: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + jamma_jdev->whiteflash[0]=va_arg(args,int); + jamma_jdev->whiteflash[1]=va_arg(args,int); + jamma_jdev->whiteflash[2]=va_arg(args,int); + jamma_jdev->whiteflash[3]=va_arg(args,int); + + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_WHITEFLASH))<0) + goto BAIL; + + break; + + case JAMMAOP_GETSTARTLIGHTSTATES: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + // returns bits set in variable point by argument + // bit 0 = start light 1 is on + // bit 1 = start light 2 is on + buf=va_arg(args,char*); + *buf=0; + if(jamma_jdev->flags & M_JAMMA_SLIGHT1) + *buf |= 1; + if(jamma_jdev->flags & M_JAMMA_SLIGHT2) + *buf |= 2; + break; + + case JAMMAOP_SETIOMODE: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + u=va_arg(args,unsigned); + if (uiomode=u; + if(u==JAMMAIOMODE_SBB) + jamma_jdev->highcurrentlogic = M_JAMMA2_H_LOGIC_SBB; + else + jamma_jdev->highcurrentlogic = M_JAMMA2_H_LOGIC_DEFAULT; + } + break; + + case JAMMAOP_TICKETINC: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); // ticket dispenser number (0 or 1) + i=va_arg(args,int); // number of tickets + if (ec >= JAMMA_TICKETS) + err(-2); // ticket dispenser number too high + jamma_jdev->ticketcnt[ec]+=i; + break; + + case JAMMAOP_TICKETSET: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); // ticket dispenser number (0 or 1) + i=va_arg(args,int); // number of tickets + if (ec >= JAMMA_TICKETS) + err(-2); // ticket dispenser number too high + jamma_jdev->ticketcnt[ec]=i; + break; + + case JAMMAOP_HICURRENTONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + i=va_arg(args,int); // hi current output # + if(!i) + u=M_JAMMA_HICURRENT1,j=JAMMAMSG_HICURRENT1; + else if(i==1) + u=M_JAMMA_HICURRENT2,j=JAMMAMSG_HICURRENT2; + else + break; + goto output_onoff; + + case JAMMAOP_GETHWVERNUM: + if(!jamma_jdev) + err(0); + err(jamma_jdev->versHW); + break; + + case JAMMAOP_GETFWVERNUM: + if(!jamma_jdev) + err(0); + err(jamma_jdev->versFW); + break; + + case JAMMAOP_SETTICKETPOLARITY: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + u=va_arg(args,unsigned); + if (u) + jamma_jdev->flags |= M_JAMMA_TICKET_POLARITY; // hi/lo logic + else + jamma_jdev->flags &= ~M_JAMMA_TICKET_POLARITY; // lo/hi logic + break; + + case JAMMAOP_TICKETCLEAR: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + ec=va_arg(args,int); // ticket dispenser number (0 or 1) + if (ec >= JAMMA_TICKETS) + err(-2); // ticket dispenser number too high + jamma_jdev->ticketcnt[ec]=0; + jamma_jdev->ticketiocur[ec]=0; + jamma_jdev->ticketioadd[ec]=0; + if(!ec) + { + if((ec=jamma_msg(jamma_jdev,JAMMAMSG_TICKET1STOP))<0) + goto BAIL; + } + break; + + case JAMMAOP_SWBITCALLBACKONOFF: + if(!jamma_jdev) + err(ERR_JAMMA_DEVICE_NOTAVAILABLE); + u=M_JAMMA_CALLBACK_SWBIT; + ec=va_arg(args,int); // on/off + if(!ec) // off + jamma_jdev->flags&=~u; + else // on + jamma_jdev->flags|=u; + break; + + case JAMMAOP_GETERRORF: + if(!jamma_jdev) + err(0); + err(jamma_jdev->errorf); + break; + + case JAMMAOP_GETUSBWDVERNUM: + if(!jamma_jdev) + err(0); + err(jamma_jdev->versUSB); + break; + + case JAMMAOP_ISUSBWDPRESENT: + if(!jamma_jdev) + {err(0);} + if(jamma_jdev->usbwd_dev) + {err(1);} //yes + else + {err(0);} //no + break; + // tell if I/O board firmware is current for hardware type + case JAMMAOP_ISFIRMWAREUPTODATE: + if(!jamma_jdev) + {err(0);} + if(jamma_jdev->errorf & M_JAMMA_ERRORF_OLDFIRMWARE) + {err(0);} // no + else + {err(1);} // yes + break; + + default: + err(ERR_JAMMA_OP_NOTRECOGNIZED); + } // switch + + ec=0; +BAIL: + va_end(args); + return ec; +} // JammaOp() + +typedef struct _jpmr { + unsigned pktbyte; // byte of message + unsigned pktshift; // shift to get count bits to right + unsigned pktmask; // mask for count bits + unsigned flags; // flags + char *name; + unsigned inpcount; + unsigned inpmask; + void (*swfunc)(jamma_dev *jdev,struct _jpmr *pmr); +} jammaPktMapRec; + +void jammaswfunc(jamma_dev *jdev,struct _jpmr *pmr); + +// +// +// our offsets are one less than doc b/c leading \n is skipped + +#define M_JSWPKT_FLAG_TRACKBALL 0x1 // trackball allows up and down count + + +// incoming switch message for bbh +// [0] 'S' +// [1] frame count +// [2] p p1trig P p2trig +// [3] r p1pump R p2pump +// [4] s p1start S p2start +// [5] c coin1 C coin2 +// [6] V volup v voldn +// [7] T test s service +// [8] t tilt B bill +// [9] \r + +jammaPktMapRec jammamap_pkt_bbh[] = +{ + {2,4,0xf,0,"g1a",JAMMASW_GUN1_TRIG1,M_JAMMASW_GUN1_TRIG1,NULL}, + {2,0,0xf,0,"g2a",JAMMASW_GUN2_TRIG1,M_JAMMASW_GUN2_TRIG1,NULL}, + {3,4,0xf,0,"g1b",JAMMASW_GUN1_TRIG2,M_JAMMASW_GUN1_TRIG2,NULL}, + {3,0,0xf,0,"g2b",JAMMASW_GUN2_TRIG2,M_JAMMASW_GUN2_TRIG2,NULL}, + {4,4,0xf,0,"p1s",JAMMASW_P1_START,M_JAMMASW_P1_START,NULL}, + {4,0,0xf,0,"p2s",JAMMASW_P2_START,M_JAMMASW_P2_START,NULL}, + {5,4,0xf,0,"c1 ",JAMMASW_COIN1,M_JAMMASW_COIN1,NULL}, + {5,0,0xf,0,"c2 ",JAMMASW_COIN2,M_JAMMASW_COIN2,NULL}, + {6,4,0xf,0,"vlu",JAMMASW_VOLUP,M_JAMMASW_VOLUP,NULL}, + {6,0,0xf,0,"vld",JAMMASW_VOLDOWN,M_JAMMASW_VOLDOWN,NULL}, + {7,4,0xf,0,"tst",JAMMASW_TEST,M_JAMMASW_TEST,NULL}, + {7,0,0xf,0,"srv",JAMMASW_SERVICE,M_JAMMASW_SERVICE,NULL}, + {8,0,0xf,0,"bil",JAMMASW_BILL,M_JAMMASW_BILL,NULL}, + {8,4,0xf,0,"tlt",JAMMASW_TILT,M_JAMMASW_TILT,NULL}, + {0,} // term +}; + +// incoming switch message for spongebob +// [0] 'S' +// [1] frame count +// [2] X trackball X +// [3] Y trackball Y +// [4] <----SSSS> - unused S p2start +// [5] c coin1 C coin2 +// [6] V volup v voldn +// [7] T test s service +// [8] t tilt B bill +// [9] \r + +jammaPktMapRec jammamap_pkt_sbb[] = +{ + {2,0,0xff,M_JSWPKT_FLAG_TRACKBALL,"tbX",JAMMASW_TBALL_X,M_JAMMASW_TBALL_X,NULL}, + {3,0,0xff,M_JSWPKT_FLAG_TRACKBALL,"tbY",JAMMASW_TBALL_Y,M_JAMMASW_TBALL_Y,NULL}, +// {4,4,0xf,0,"p1s",JAMMASW_P1_START,M_JAMMASW_P1_START,NULL}, + {4,0,0xf,0,"p2s",JAMMASW_P2_START,M_JAMMASW_P2_START,NULL}, + {5,4,0xf,0,"c1 ",JAMMASW_COIN1,M_JAMMASW_COIN1,NULL}, + {5,0,0xf,0,"c2 ",JAMMASW_COIN2,M_JAMMASW_COIN2,NULL}, + {6,4,0xf,0,"vlu",JAMMASW_VOLUP,M_JAMMASW_VOLUP,NULL}, + {6,0,0xf,0,"vld",JAMMASW_VOLDOWN,M_JAMMASW_VOLDOWN,NULL}, + {7,4,0xf,0,"tst",JAMMASW_TEST,M_JAMMASW_TEST,NULL}, + {7,0,0xf,0,"srv",JAMMASW_SERVICE,M_JAMMASW_SERVICE,NULL}, + {8,0,0xf,0,"bil",JAMMASW_BILL,M_JAMMASW_BILL,NULL}, + {8,4,0xf,0,"tlt",JAMMASW_TILT,M_JAMMASW_TILT,NULL}, + {0,} // term +}; + + +// JFL 10 May 05 +// JFL 27 Jul 05 +// JFL 04 Aug 05; protocol2 +int JammaLoop(void) +{ + int ec,ja; + unsigned j; + jamma_dev *jdev; + int n,x,y,xx,yy,len,nn; + uns8 buf[512]; + int gunXYBuf[JAMMA_MAX_GUN_SAMPLES*2],numSamp,bNoTrigger,freq; + jammaPktMapRec *pmr; + float f1,f2,f3; + unsigned long tickTemp; + + if(!(jdev=jamma_jdev)) + return ERR_JAMMA_DEVICE_NOTAVAILABLE; + + // check usb watchdog device +#ifdef USB_WATCHDOG + if (!jdev->usbwd_dev && (jdev->usbretrytime <= jamma_tick())) + { + // device is not open, and retry timer is expired + if(jamma_usbwd_open(jdev) >= 0) + { + jamma_usbwd_config(jdev,USBWD_CONFIG_REQUEST); + } + else + { + jdev->usbretrytime=JAMMA_WAIT_USB_RETRY+jamma_tick(); + } + } + else if (jdev->errorf & M_JAMMA_ERRORF_USBWD) + { + // device had errors on last operation, close and retry later + if(jdev->usbwd_dev) + jamma_usbwd_close(jdev); + + jdev->usbretrytime=jamma_tick(); + jdev->errorf &= ~M_JAMMA_ERRORF_USBWD; + } + else if (jdev->usbwd_dev) + jamma_usbwd_readloop(jdev); +#endif //USB_WATCHDOG + + ja=jdev->avail; + + jamma_sendloop(jdev); + jamma_readloop(jdev); + + + // send watchdog bone + + if(jdev->wdogtick<=(tickTemp=jamma_tick())) + { + if(tickTemp - jdev->wdogtick > jdev->wdogwait) + dprintf("Uh Oh! Watchdog took a little too long to be fed, curtime: %08X nextime: %08X waitime: %08X\n",tickTemp,jdev->wdogtick,jdev->wdogwait); + + // wdogtime determines how often we send a bone + // the 'bone' message to the IO board contains the length of time + // before the watchdog resets the PC + jdev->wdogtick=jdev->wdogwait+tickTemp; + if(!(jdev->flags&M_JAMMA_DONTSENDBONE)) + { + JammaOp(JAMMAOP_WATCHDOGBONE); + if(!(jamma_jdev->flags & M_JAMMA_WATCHDOG_MSG)) + { + jamma_jdev->flags |= M_JAMMA_WATCHDOG_MSG; + dprintf("Watchdog is ENABLED\n"); + } + + } + else if(!(jamma_jdev->flags & M_JAMMA_WATCHDOG_MSG)) + { + jamma_jdev->flags |= M_JAMMA_WATCHDOG_MSG; + dprintf("Watchdog is DISABLED\n"); + } + } // watchdog bone + + // click coin meters + if(jdev->metertick<=jamma_tick()) + { + // next time + jdev->metertick=JAMMA_WAIT_METER+jamma_tick(); + + if(jdev->meter1) + { + // 2 1 0 + jdev->meter1--; + if(1&jdev->meter1) + j=JAMMAMSG_METER1|M_JAMMAMSG_ON; // high (on) + else + j=JAMMAMSG_METER1; // low (off) + jamma_msg(jdev,j); + } // meter1 + + if(jdev->meter2) + { + // 2 1 0 + jdev->meter2--; + if(1&jdev->meter2) + j=JAMMAMSG_METER2|M_JAMMAMSG_ON; // high (on) + else + j=JAMMAMSG_METER2; // low (off) + jamma_msg(jdev,j); + } // meter2 + + if(jdev->meter3) + { + // 2 1 0 + jdev->meter3--; + if(1&jdev->meter3) + j=JAMMAMSG_METER2A|M_JAMMAMSG_ON; // high (on) + else + j=JAMMAMSG_METER2A; // low (off) + jamma_msg(jdev,j); + } // meter3 + + } // coin meters + + // request dipswitches (and others) every so often + if(jdev->periodictime<=jamma_tick()) + { + jdev->periodictime=JAMMA_WAIT_PERIODIC+jamma_tick(); + jamma_msg(jdev,JAMMAMSG_GETSWSTATES); + } // periodic + + while(jdev->avail) + { + if((len=jamma_pktget(jdev,buf,sizeof(buf)-1))<0) + break; + if(len<1) + continue; + + if((jdev->flags&M_JAMMA_RCVASCII)&&jdev->callback&&jdev->asciibuf) + { + if(jdev->asciibufi>=jdev->asciibufsize) + jdev->asciibufi=jdev->asciibufsize-1; + jdev->asciibuf[jdev->asciibufi]=0; + (*jdev->callback)(JAMMACALLBACK_RCVASCII, + jdev->asciibuf,jdev->asciibufi); + jdev->asciibufi=0; + } + + if((jdev->flags&M_JAMMA_RCVBIN)&&jdev->callback) + (*jdev->callback)(JAMMACALLBACK_RCVBIN,buf,len); + + // in char packet mode, don't process here in the loop + // caller must handle with the RCVASCII or RCVBIN + if(jdev->flags&M_JAMMA_CHARPKT) + { + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_RCVCHARPKT,buf,len); + continue; + } + + switch(buf[0]) + { + case '*': // msg + + // message + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_MESSAGE,&buf[0],len-1); + + if(len<2) + break; + + switch(buf[1]) + { + case 'R': // RST + // reset + + // reset the userbit -- force synchronization + jdev->flags&=~M_JAMMA_USERBIT; + if(jdev->callback) // let app know userbit has been cleared + (*jdev->callback)(JAMMACALLBACK_USERBIT,0); + + // send config -- board is lost + jamma_msg(jdev,JAMMAMSG_CONFIG); + jamma_msg(jdev,JAMMAMSG_GETSWCOUNTS); + + dprintf("RESET received from Jamma I/O\n"); + + break; + case 'W': // WDT + // watchdog will reset the PC very soon + // this is our one warning and if we are here that means + // the program is still running and shouldn't be watchdogging + + if(!(jdev->flags&M_JAMMA_DONTSENDBONE)) + JammaOp(JAMMAOP_WATCHDOGBONE); + + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_WATCHDOGCOMING,0); + + break; + } // switch + break; // msg + case 'S': // switch change + + if(len<2) + break; + + // check for valid length + if(len!=9) + { +#ifdef DEBUG + jamma_apphook_msg("JammaLoop(): invalid length %c %d\n",buf[0],len); +#endif //DEBUG + break; + } + + // + // handle user bit + // + + // keep track of user bit + if(buf[1]&M_JAMMA2_S1_USER) + { // user bit set + + // if it's not set in our flags we need to + // synchronize the switch counts the board has sent + // with our copy of the switch counts + if(!(jdev->flags&M_JAMMA_USERBIT)) + { + jdev->flags|=M_JAMMA_USERBIT; + + // let app know user bit has been set + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_USERBIT,1); + + // make our counts match jamma board counts + + if(jdev->iomode == JAMMAIOMODE_SBB) + pmr=jammamap_pkt_sbb; + else + pmr=jammamap_pkt_bbh; + + // run through all the packet mappings + for(;pmr->pktbyte;pmr++) + { + // if this switch has a switch count & byte valid + if(pmr->inpcount && (pmr->pktbyte<(unsigned)len)) + { + x=buf[pmr->pktbyte]; // count bits sent + x>>=pmr->pktshift; // shift down to bits + x&=pmr->pktmask; // mask to keep low bits + jdev->ir.swoff[pmr->inpcount]= + (jdev->ir.swcount[pmr->inpcount] -x) + & pmr->pktmask; // keep our base for counting + jdev->ir.swlast[pmr->inpcount] = x; // keep last to check direction + } + } // for + break; // don't do any more processing + } // transition from no user bit to user bit set + } // user bit set + else + { // user bit not set + + // if board doesn't have it bit set, that means it doesn't + // have a valid configuration (since we set the bit every time + // we send a new config) or the board reset somehow and has not + // yet received a valid config + jdev->flags&=~M_JAMMA_USERBIT; + + // let app know user bit has been cleared + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_USERBIT,0); + + // send config -- board is lost + jamma_msg(jdev,JAMMAMSG_CONFIG); + jamma_msg(jdev,JAMMAMSG_GETSWCOUNTS); + + break; // doesn't have our config, ignore this packet + } // user bit not set + + // + // process & pass switch counts to game + // + + if(jdev->iomode == JAMMAIOMODE_SBB) + pmr=jammamap_pkt_sbb; + else + pmr=jammamap_pkt_bbh; + + // run through all the packet mappings + for(;pmr->pktbyte;pmr++) + { + // if this switch has a switch count & the pkt byte is valid + if(pmr->inpcount && (pmr->pktbyte<(unsigned)len)) + { + x=buf[pmr->pktbyte]; // count bits sent from board + x>>=pmr->pktshift; // shift down to bits for this switch + xx=x; // keep raw + x+=jdev->ir.swoff[pmr->inpcount]; // offset + x&=pmr->pktmask; // mask to keep only low bits + yy=jdev->ir.swlast[pmr->inpcount]; // pull last raw switch count (already masked) + jdev->ir.swlast[pmr->inpcount]=xx; // save new raw count as last + + // process switch count + if(pmr->flags & M_JSWPKT_FLAG_TRACKBALL) + { + // trackball counter + // reverse count allowed, we need to do more + if(xxpktmask + 1)) - yy)) + nn=1; // went backward + else + nn=0; // wrapped going forward + } + else + { + // counter going forward or wrapped while going backward + // whatever way is closer wins + if((unsigned)(xx-yy) < (unsigned)((yy + (pmr->pktmask + 1)) - xx)) + nn=0; // went forward + else + nn=1; // wrapped going backward + } + + // do actual incrementing/decrementing of switch counter + if(nn==1) + { + // decrement our local switch count to next match + for(n=0;;yy--) + { + yy&=pmr->pktmask; // mask to keep only low bits + if(xx==yy) + break; // nothing to do / don't dec anymore + jdev->ir.swcount[pmr->inpcount]--; + n++; // keep track of increments + } // for + } + else + { + // increment our local switch count to next match + for(n=0;;yy++) + { + yy&=pmr->pktmask; // mask to keep only low bits + if(xx==yy) + break; // nothing to do / don't inc anymore + jdev->ir.swcount[pmr->inpcount]++; + n++; // keep track of increments + } // for + } + } + else + { + // normal switch count processing + // counter only allowed to move forward + // increment our local switch count to next match + for(n=0;;) + { + y=jdev->ir.swcount[pmr->inpcount]; // current local counter + y&=pmr->pktmask; // mask to keep only low bits + + if(x==y) + break; // nothing to do / don't inc anymore + + jdev->ir.swcount[pmr->inpcount]++; + n++; // keep track of increments + } // for + + } + + if(n) // incremented (i.e. we received a change) + { + jdev->flags|=M_JAMMA_SWRCV; // valid switch data + jdev->swchanged|=pmr->inpmask; + + // call func + if(pmr->swfunc) + (*pmr->swfunc)(jdev,pmr); + } // if increments + } // inpcount + } // for + + break; // switch change + + case 'd': // gun1 position -- debug msg + case 'g': // gun1 position + n=0; // gun number + goto gunpos; + case 'D': // gun2 position -- debug msg + case 'G': // gun2 position + n=1; // gun number +gunpos: + if(len<7) + break; + + ec=buf[2]&0x3f; // frame number + + if((buf[1]&M_JAMMA2_G2_ID) != 0xf0) + { +#ifdef DEBUG + jamma_apphook_msg("JammaLoop(): gun message malformed cause ID %x\n",buf[1]); +#endif //DEBUG + break; + } + +#if 0 //old Joe method, ignores input without trigger or whiteflash + // only if the trigger caused & it was from a whiteflash + if(!(buf[1]&M_JAMMA2_G2_GUNCAUSE)) + break; + if(!(buf[1]&M_JAMMA2_G2_WHITEFLASH)) + break; +#endif + + //new method recognizes auto-fire mode with no + //trigger pull and sends data back via a new + //callback code if no trigger was pulled + + // check if input was caused by + // a trigger or whiteflash. + // if not, check if gun is in autofire + // mode. if not then do not respond to input. + // autofire mode always accepts input + if(!(buf[1]&M_JAMMA2_G2_GUNCAUSE) + || !(buf[1]&M_JAMMA2_G2_WHITEFLASH)) + { + bNoTrigger=1; + // break if gun was not in auto-fire mode + if((n==0 && !(jdev->flags & M_JAMMA_GUNAUTO1)) + || (n==1 && !(jdev->flags & M_JAMMA_GUNAUTO2))) + break; + + } + else + { + bNoTrigger=0; + } + + y=buf[3]&3; + y<<=8; + y|=buf[4]; + + x=buf[5]&7; + x<<=8; + x|=buf[6]; + + numSamp=0; + gunXYBuf[numSamp++]=x; + gunXYBuf[numSamp++]=y; + + yy=y; + nn=0; + for(j=7;(j+2)<=(unsigned)len;j+=2) + { + // code only comes here when the extended data is present + switch(buf[j]&0xf0) + { + case 0xb0: // blank + yy++; + xx=-1; + goto gundsave; + case 0xc0: // end of data + goto gund; + case 0xe0: // blank bottom of screen reached + goto gund; + case 0x30: // next line, next hpos + yy++; + xx=buf[j]&0x7; + xx<<=8; + xx|=buf[j+1]; +gundsave: + x=xx; + y=yy; + + gunXYBuf[numSamp++]=x; + gunXYBuf[numSamp++]=y; + + // grab & use x,y w/o any processing +// if(++nn>=6) +// goto gund; + break; + } + } // for +gund: + freq=0; + + gunSampleDebugRaw[0]=0; //set counts to 0 + gunSampleDebugUsed[0]=0; + + if(numSamp > 2) + { + gunPreProcessSamples(gunXYBuf,&numSamp, &y); + gunProcessSamples(gunXYBuf, numSamp, &x, &yy, &freq); + } + + // no valid data + if(x==-1) + break; + + switch(jdev->calibmode[n]) + { + case 1: // all guns use gun1 + j=0; + goto calib1; + case 2: + if(n>=JAMMA_GUNS) + j=0; + else if(!jdev->calibflags[n]) + j=0; + else + j=2*n; +calib1: + f1=(float)x; + f2=(float)y; + +// printf("Translating samples for gun %d\n",j/2); +// printf("Raw X,Y = %f,%f\n",f1,f2); + f1-=jdev->calibxy[0+j]; + if((f3=jdev->calibmul[0+j]) == 0) + f3=0.001f; + f1/=f3; + + if(f1<0) f1=0; + else if(f1>=jdev->calibwh[0]) f1=jdev->calibwh[0]-1; + + f2-=jdev->calibxy[1+j]; + if((f3=jdev->calibmul[1+j]) == 0) + f3=0.001f; + f2/=f3; + + if(f2<0) f2=0; + else if(f2>=jdev->calibwh[1]) f2=jdev->calibwh[1]-1; +// printf("Translated X,Y = %f,%f\n",f1,f2); + + x=(int)f1; + y=(int)f2; + break; // mode 1, mode 2 + + } // switch + + // set current gun position + jdev->ir.xy[0+n*2]=x; + jdev->ir.xy[1+n*2]=y; + jdev->ir.snr[0+n*2]=numSamp>>1; + jdev->ir.snr[1+n*2]=freq; + + // call handler + if(jdev->callback) + { + if(bNoTrigger) + { + ec=JAMMACALLBACK_GUNXYNOTRIGGER; + if(n) + ec|=(1&M_JAMMACALLBACK_PL)<callback)(ec,x,y,numSamp>>1,freq,(uns32)gunSampleDebugRaw,(uns32)gunSampleDebugUsed); + } + else + { + ec=JAMMACALLBACK_GUNXY; + if(n) + ec|=(1&M_JAMMACALLBACK_PL)<callback)(ec,x,y,numSamp>>1,freq,(uns32)gunSampleDebugRaw,(uns32)gunSampleDebugUsed); + } + } // gun position handler + break; // gun position + + case 's': // switch state -- periodic or requested + if(len<6) + break; + if(len != 6) + { +#ifdef DEBUG + jamma_apphook_msg("JammaLoop(): invalid length %c %d\n",buf[0],len); +#endif //DEBUG + break; + } + + jdev->ir.dipstate=buf[5]^0xff; // dip switch values (set if on) + jdev->ir.dipstate|=M_JAMMADIP_VALID; + jdev->ir.swprev = jdev->ir.swstate; + n = buf[2]; + n |= (int)((uns8)buf[3]<<8); + n |= (int)((uns8)buf[4]<<16); + n ^= 0xffff3f; + jdev->ir.swstate = n | M_JAMMASWBIT_VALID; + // if we want to callback, and there is one + if((jdev->flags & M_JAMMA_CALLBACK_SWBIT) && (jdev->callback)) + (*jdev->callback)(JAMMACALLBACK_SWBIT,jdev->ir.swstate,jdev->ir.dipstate); + break; + + case 'c': // mode info + // [1] mode-info + if(len<3) + break; + + // check for valid length + if(len!=3) + { +#ifdef DEBUG + jamma_apphook_msg("JammaLoop(): invalid length %c %d\n",buf[0],len); +#endif //DEBUG + break; + } + + // original config bits tell whether watchdog hit or user bit is set + if(!(jdev->flags&M_JAMMA_ORG_VALID)) + { + jdev->flags|=M_JAMMA_ORG_VALID; + jdev->flags&=~(M_JAMMA_ORG_USER|M_JAMMA_ORG_WATCHDOG); + if(buf[2]&M_JAMMA2_G2_USER) + jdev->flags|=M_JAMMA_ORG_USER; + if(buf[2]&M_JAMMA2_G2_WATCHDOG) + { + // watchdog hit bit is set, record this + // and request IO board to clear the bit (next config sent) + jdev->flags|=M_JAMMA_ORG_WATCHDOG|M_JAMMA_CLEARWDOGHIT; + } + } // org valid + + // if we get a watchdog-hit and have already recorded + // that the watchdog-hit, stop asking the board to clear it + else if((buf[2]&M_JAMMA2_G2_WATCHDOG) + &&(jdev->flags&M_JAMMA_CLEARWDOGHIT)) + { + jdev->flags&=~M_JAMMA_CLEARWDOGHIT; + } + + if (buf[2]&M_JAMMA2_G2_WATCHDOG) + { + dprintf("I/O Watchdog occured.\n"); + } + + // check current configuration against what we expect + // if it is not the same, then re-send configuration + x=buf[1] & (M_JAMMA2_C2_P1TRIG|M_JAMMA2_C2_P2TRIG|M_JAMMA2_C2_P1AUTOFIRE|M_JAMMA2_C2_P2AUTOFIRE|M_JAMMA2_C2_DBGGUN); + y=0; + if(jdev->flags&M_JAMMA_VERBOSEGUN) + y|=M_JAMMA2_C2_DBGGUN; + if(jdev->flags&M_JAMMA_GUN1) + y|=M_JAMMA2_C2_P1TRIG; + if(jdev->flags&M_JAMMA_GUN2) + y|=M_JAMMA2_C2_P2TRIG; + if(jdev->flags&M_JAMMA_GUNAUTO1) + y|=M_JAMMA2_C2_P1AUTOFIRE; + if(jdev->flags&M_JAMMA_GUNAUTO2) + y|=M_JAMMA2_C2_P2AUTOFIRE; + + if (x!=y) + jamma_msg(jdev,JAMMAMSG_CONFIG); //re-send config to correct + + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_STATUS,&buf[1],len-1); + break; // mode info + + case 'v': // version info + if(len<3) + break; + + // check for valid length + if(len!=3) + { +#ifdef DEBUG + jamma_apphook_msg("JammaLoop(): invalid length %c %d\n",buf[0],len); +#endif //DEBUG + break; + } + + jdev->versHW=buf[1]; + jdev->versFW=buf[2]; + + nn=0; // warning flag + // set iomode correctly based on firmware version + if((jdev->versFW & M_JAMMAFWID) == JAMMAFWID_SBB) + { + n=JAMMAIOMODE_SBB; + if((jdev->versFW & M_JAMMAFWVER) < JAMMAFWVER_SBB) + nn=1; + } + else if((jdev->versFW & M_JAMMAFWID) == JAMMAFWID_BBH) + { + n=JAMMAIOMODE_BBH; + if((jdev->versFW & M_JAMMAFWVER) < JAMMAFWVER_BBH) + nn=1; + } + else + { + n=0; + } + if(nn) + // firmware version out of date + jdev->errorf |= M_JAMMA_ERRORF_OLDFIRMWARE; // old firmware detected + + JammaOp(JAMMAOP_SETIOMODE,n); + + break; + case 't': // ticket info + if(len<3) + break; + x = ((buf[1] & 0x3) << 8) + buf[2]; // current count on board + + // check overflow situation + // must send a sane ticket count to i/o board + if(buf[1] & 0x40) + { + x = jdev->ticketiocur[0]; + if(x>JAMMAIO_MAX_TICKETS) + jdev->ticketiocur[0]=x=JAMMAIO_MAX_TICKETS; + // re-start ticket dispenser with good value + jdev->ticketioadd[0]=0; + jdev->flags &= ~M_JAMMA_TICKET1; // no longer running + jamma_msg(jdev,JAMMAMSG_TICKET1ADD); // start running + } + else + { + y = jdev->ticketiocur[0] - x; // number of tickets dispensed + jdev->ticketiocur[0]=x; + if(buf[1] & 0x80) // error or overflow + { + x = JAMMATICKET_ERROR; + jdev->flags &= ~M_JAMMA_TICKET1; // no longer running + jdev->flags |= M_JAMMA_TICKET_ERROR; + jdev->ticketnexttry[0] = JAMMA_WAIT_TICKET_ERROR +jamma_tick(); + } + else if (!x) + { + x = JAMMATICKET_DONE; + jdev->flags &= ~M_JAMMA_TICKET1; // no longer running + } + else + { + x = JAMMATICKET_CONTINUING; + jdev->flags |= M_JAMMA_TICKET1; // indicate running, could have re-started by itself + } + + if ((y!=0) || (x!=JAMMATICKET_CONTINUING)) + { + // callback if there is something for program to know + if(jdev->callback) + (*jdev->callback)(JAMMACALLBACK_TICKET,x,y); + } + } + + break; + case 'h': // output driver status + break; + case 'f': // Sync frequency info + break; + default: +#ifdef DEBUG + jamma_apphook_msg("JammaLoop(): unrecognized message %x, length %d\n",(unsigned)buf[0],len); +#endif //DEBUG + break; + + + } // switch + } // while avail + + // check ticket dispensers + for (j=0;jticketcnt[j]) + { + // time to run ticket dispenser + // check if already running + // note: this code will only run one ticket dispenser + // need to add an 'else' to do more + if(j==0) + { + n = jdev->ticketiocur[j] + jdev->ticketcnt[j]; + if (n>JAMMAIO_MAX_TICKETS) + { + n=JAMMAIO_MAX_TICKETS - jdev->ticketiocur[j]; + if(n<=0) + continue; // cannot pile on anymore tickets, let dispenser breath + jdev->ticketioadd[j] = n; + jdev->ticketcnt[j]-=n; + } + else + { + jdev->ticketioadd[j] = jdev->ticketcnt[j]; + jdev->ticketcnt[j]=0; + } + + jamma_msg(jdev,JAMMAMSG_TICKET1ADD); + } + } + } // for + + + if(!ja && (jdev->bufn>(jdev->bufsize-8))) + ec=-2; // this does happen + else if(jdev->errorf) + ec=-3; + else + ec=ja; // provides some indication that jamma is out there & alive +// BAIL: + return ec; +} // JammaLoop() + +typedef struct _gunfreq +{ + int x; + int freq; + int idx; +} gunFreq; + +#define GUNFREQ_NULL -4096 + +//#define PRINT_GUN_INFO 1 + +// +// MemFill +// fill a block of memory with a 32 bit value +// +// in: +// mem = ptr to memory +// size = size in bytes +// out: +// ~ +// +// GNP 04 May 00 +// +void MemFill(void *mem, unsigned int size, unsigned int val) +{ + register uns32 *p; + + if ((size & ~3) == 0) + return; // size must be four or higher + size>>=2; + p = (uns32*)mem; + while(size-->0) + *p++ = val; +} // MemFill + +// +// gunPreProcessSamples +// pre-process gun data, looking for string of blank lines and truncating +// will modify gunIntCnt to reflect valid data. +// will also attempt to determine if data is trending away from focal point +// and truncate. attempting to alleviate "?" +// +// in: +// gunIntQ = ptr to data array +// pGunIntCnt = ptr number of samples in array (may be modified) +// out: +// global: +// +// GNP 05 Sep 06 +// +void gunPreProcessSamples(int *gunIntQ, int *pGunIntCnt, int *rY) +{ + int gunIntCnt = *pGunIntCnt; + int i,j,k,x,y; + int mingunx=0x7fffffff; + int maxgunx=0xffffffff; + int minguny=0x7fffffff; + int maxguny=0xffffffff; + int trendx; + uns32 bMin; + + k=0; + *rY=-1; + + if (gunIntCnt >= 2) + { + // first copy all data and check valid/min/max + for (i=0,j=0;i= 0) + { + // check min/max + if(x>maxgunx) + maxgunx=x; + if(x= 0) + { + // check min/max + if(y>maxguny) + maxguny=y; + if(y> 1; //average y + + // now look through valid to determine trend + for(i=0,j=0,trendx=mingunx,bMin=0;i trendx) + || (j!=0 && x>= trendx)) +// if(x > trendx) + { + if(++j > 2) + { + k=i+2; // mark end data + break; + } + } + else + j=0; + trendx=x; + } + else if(x==mingunx) + bMin=1; + } + + if(k!=0) + *pGunIntCnt=gunIntCnt=k; + + gunSampleDebugRaw[0]=k>>1; + } +//DONE("gunPreProcessSamples") +} // gunPreProcessSamples + +// +// gunProcessSamples +// process array of gun data +// +// in: +// gBuf = ptr to array +// numSamp = number of samples in buff +// rX = ptr to X result +// rY = ptr to Y result +// out: +// global: +// +// GNP 25 Aug 06 +// +void gunProcessSamples(int *gunIntQ, int gunIntCnt, int *rX, int *rY, int *rFreq) +{ + *rX=-1; + *rY=-1; + *rFreq=0; + if (gunIntCnt > MIN_GUN_SAMPLES * 2) + { + int i; + int gunx=0; + int guny=0; + int minguny=0x7fffffff; + int maxguny=0xffffffff; + int mingunx; +// int maxgunx=0xffffffff; + gunFreq gunFilterQ[JAMMA_MAX_GUN_SAMPLES+2]; // add a NULL entry at end of filter, used by 'for' loops + gunFreq *gfq,*gmfq; + int j,k,l,m,n; + int gunFilterCnt; + float fAvgX, fAvgY; + + +#if PRINT_GUN_INFO + // loop through and print the raw data first + for (i=0;i>1,gunIntQ[i], gunIntQ[i+1]); // print dot + } +#endif //PRINT_GUN_INFO + + if(0) + { + // Average method + + // get average value for X and Y + fAvgX=fAvgY=0; + + for (i=0;i>1); + fAvgY /= (float)(gunIntCnt>>1); + + gunx = (int)fAvgX; + guny = (int)fAvgY; + + // throw away samples that have an x too far from average + + fAvgX=0; + for (j=0,i=0,k=0;i>1; + + *rX=gunx; + *rY=guny; + *rFreq = gunFilterCnt; // return frequency + + } + } + else + { + //GUNSAMPLEMETHOD_FREQUENCY + // Method: + // X-value Frequency sample + // GNP 28 Jun 01 + MemFill(gunFilterQ,sizeof(gunFilterQ),(uns32)(GUNFREQ_NULL)); + + // 1. count the occurance of every value scanned + for (gunFilterCnt=0,i=0;ix!=GUNFREQ_NULL;gfq++) + { + if (gfq->x == gunIntQ[i]) + { + gfq->freq++; + break; + } + } + + if(gunIntQ[i] < 0) + continue; //-1 samples are no good + + if (gfq->x == GUNFREQ_NULL) + { + gfq->x=gunIntQ[i]; + gfq->freq=1; + gfq->idx=i; + gunFilterCnt++; + } + + } + + // 2. look for an x value that is clearly more prevalent + gfq=gmfq=gunFilterQ; + for (j=0,k=0;gfq->x!=GUNFREQ_NULL;gfq++) + { + if (gfq->freq > j) + { + j=gfq->freq; + gmfq=gfq; + k=0; // new max + } + else if(gfq->freq == j) + k++; + } + + // 3. if k==0 then we have a clear winner + // else we'll have to find the one closest to the middle + if (k!=0) + { + + mingunx=0x7fffffff; + + // grab minimum x, out of the most frequent x's + for(gfq=gmfq;gfq->x!=GUNFREQ_NULL;gfq++) + { + if (gfq->freq == j) + { + if (gfq->x < mingunx) + { + mingunx = gfq->x; + gmfq=gfq; + } + } + } + +#if 0 + int dist; + + k=JAMMA_MAX_GUN_SAMPLES*2; // initialize close distance to median + i = gunIntCnt >> 2; // median of samples + for(gfq=gmfq;gfq->x!=GUNFREQ_NULL;gfq++) + { + if (gfq->freq == j) + { + dist = abs(i-(gfq->idx>>1)); + + if (k > dist) + { + k=dist; + gmfq=gfq; + } + } + } +#endif + } + + *rFreq = gmfq->freq; // return frequency + gunx = gmfq->x; // this is the x value + + // Y-value + // to filter, find the longest consecutive + // string of Y-values + // calculate Y by mean value + // i loop + // j curlen + // k longest + // l cur start + // m longest start + for (i=0,j=1,k=0,l=0,m=0;ik) + { + k=j; + m=l; + } + } + else + { + l=i+2; + j=1; + } + } + if (k!=0) + { + k = (k<<1)+m; + for (i=m;i maxguny) + maxguny=guny; + } + + guny = (minguny + maxguny) >> 1; //average y + } + else + guny = gunIntQ[1]; + + // loop through and print x values we determined + // to be of greatest frequency and closest to the middle + for (i=0,k=0;i>1,gunIntQ[i], gunIntQ[i+1]); // print dot +#endif //PRINT_GUN_INFO + } + } + gunSampleDebugUsed[0]=k>>1; + *rX=gunx; + *rY=guny; + } + } +//DONE("gunProcessSamples") +} // gunProcessSamples + +// EOF diff --git a/libraries/pmrt/jamma/jamma.dsw b/libraries/pmrt/jamma/jamma.dsw new file mode 100755 index 0000000..a34e2ac --- /dev/null +++ b/libraries/pmrt/jamma/jamma.dsw @@ -0,0 +1,56 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "jammalib"=.\jammalib.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/jamma", CADAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jammatest"=.\jammatest.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/jamma", CADAAAAA + . + end source code control +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name jammalib + End Project Dependency +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/jamma", CADAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/jamma/jamma.h b/libraries/pmrt/jamma/jamma.h new file mode 100755 index 0000000..7b7fe59 --- /dev/null +++ b/libraries/pmrt/jamma/jamma.h @@ -0,0 +1,277 @@ +#ifndef JAMMA_H +#define JAMMA_H +// jamma.h + +#define JAMMA_VER_STRING "24" + +#define JAMMA_GUNS 2 // number of supported guns +#define JAMMA_TICKETS 1 // number of supported ticket dispensers + +#define M_JAMMASW_GUN1_TRIG1 0x00000001 // order must match JAMMASW_ +#define M_JAMMASW_GUN2_TRIG1 0x00000002 +#define M_JAMMASW_GUN1_TRIG2 0x00000004 +#define M_JAMMASW_GUN2_TRIG2 0x00000008 +#define M_JAMMASW_P1_START 0x00000010 +#define M_JAMMASW_P2_START 0x00000020 +#define M_JAMMASW_COIN1 0x00000040 +#define M_JAMMASW_COIN2 0x00000080 +#define M_JAMMASW_BILL 0x00000100 +#define M_JAMMASW_SERVICE 0x00000200 +#define M_JAMMASW_TEST 0x00000400 +#define M_JAMMASW_VOLUP 0x00000800 +#define M_JAMMASW_VOLDOWN 0x00001000 +#define M_JAMMASW_USBPOWER 0x00002000 +#define M_JAMMASW_TBALL_X 0x00004000 +#define M_JAMMASW_TBALL_Y 0x00008000 +#define M_JAMMASW_TILT 0x00010000 + +#define M_JAMMADIP_DIP 0x000000ff // dip switch data mask +#define M_JAMMADIP_VALID 0x00010000 // dip switch data valid +#define M_JAMMADIP_SPECIAL_VALID 0x00020000 // special bits are valid +#define M_JAMMADIP_SPECIAL_WATCHDOG 0x00040000 // watchdog detected +#define M_JAMMADIP_SPECIAL_USER 0x00080000 // user bit (jamma resets) + +// Raw switch bits from I/O board +#define M_JAMMASWBIT 0x00ffffff // switch bit data mask +#define M_JAMMASWBIT_GUN2_TRIG1 0x00000001 // gun 2, trigger 1 +#define M_JAMMASWBIT_GUN1_TRIG1 0x00000002 // gun 1, trigger 1 +#define M_JAMMASWBIT_GUN2_SPARE 0x00000004 // gun 2, spare +#define M_JAMMASWBIT_GUN1_SPARE 0x00000008 // gun 1, spare +#define M_JAMMASWBIT_GUN2_TRIG2 0x00000010 // gun 2, trigger 2 (reload) +#define M_JAMMASWBIT_GUN1_TRIG2 0x00000020 // gun 1, trigger 2 (reload) +#define M_JAMMASWBIT_UNUSED1 0x00000040 // currently unused +#define M_JAMMASWBIT_UNUSED2 0x00000080 // currently unused +#define M_JAMMASWBIT_COIN1 0x00000100 // coin switch 1 (left) +#define M_JAMMASWBIT_START1 0x00000200 // player 1 start button +#define M_JAMMASWBIT_COIN2 0x00000400 // coin switch 2 (right) +#define M_JAMMASWBIT_START2 0x00000800 // player 2 start button +#define M_JAMMASWBIT_TILT 0x00001000 // tilt switch +#define M_JAMMASWBIT_SERVICE 0x00002000 // service switch +#define M_JAMMASWBIT_TEST 0x00004000 // test switch +#define M_JAMMASWBIT_CSYNCPOL 0x00008000 // composite sync polarity +#define M_JAMMASWBIT_P2B4 0x00010000 // player 2, button 4 +#define M_JAMMASWBIT_VOLDN 0x00020000 // volume down +#define M_JAMMASWBIT_P2B2 0x00040000 // player 2, button 2 +#define M_JAMMASWBIT_P2B1 0x00080000 // player 2, button 1 +#define M_JAMMASWBIT_BILL 0x00100000 // bill acceptor input +#define M_JAMMASWBIT_VOLUP 0x00200000 // volume up +#define M_JAMMASWBIT_P1B2 0x00400000 // player 1, button 2 +#define M_JAMMASWBIT_P1B1 0x00800000 // player 1, button 1 +#define M_JAMMASWBIT_VALID 0x10000000 // flag, switch register data is valid + + +enum { + JAMMAEVENT_NONE, + JAMMAEVENT_SWITCHES, // unsigned int switches +}; + +#define M_JAMMAEVENT 0xff + +enum { + JAMMASW_NONE, + JAMMASW_GUN1_TRIG1, // order must match M_JAMMASW_ + JAMMASW_GUN2_TRIG1, // order assumed + JAMMASW_GUN1_TRIG2, // order assumed + JAMMASW_GUN2_TRIG2, // order assumed + JAMMASW_P1_START, + JAMMASW_P2_START, + JAMMASW_COIN1, + JAMMASW_COIN2, + JAMMASW_BILL, + JAMMASW_SERVICE, + JAMMASW_TEST, + JAMMASW_VOLUP, + JAMMASW_VOLDOWN, + JAMMASW_USBPOWER, + JAMMASW_TBALL_X, + JAMMASW_TBALL_Y, + JAMMASW_TILT, + // -- beyond physical switches + JAMMASW_GUN1XYTRIG, // order assumed + JAMMASW_GUN2XYTRIG, // order assumed + JAMMASW_NUM +}; + +typedef struct { + unsigned int dipstate; + unsigned int swprev; + unsigned int swstate; + unsigned int swcount[JAMMASW_NUM]; + unsigned char swoff[JAMMASW_NUM]; + unsigned char swlast[JAMMASW_NUM]; + int xy[2*JAMMA_GUNS]; + int snr[2*JAMMA_GUNS]; +} JammaInpRec; + +enum { + JAMMAOP_NONE, + JAMMAOP_GETDIPSWITCHES, // unsigned int dipswitch register M_JAMMADIP_ + JAMMAOP_GETINPREC, // void **jir + JAMMAOP_RESET, + JAMMAOP_RCVBIN, + JAMMAOP_RCVASCII, + JAMMAOP_SETCALLBACK, // int func(int op,...); + JAMMAOP_RECONFIG, + JAMMAOP_SENDBUF, + JAMMAOP_GETVERSTRING, // char *buf,int bufsize + JAMMAOP_GETTICK, // unsigned long *tickp + JAMMAOP_SETCALIBLTRB, // int,int,int,int + JAMMAOP_SETCALIBMODE, // int + JAMMAOP_SETSCRWH, // float,float + JAMMAOP_SETCHARPKTMODE, // int + JAMMAOP_WATCHDOGBONE, + JAMMAOP_GUNONOFF, // int gun,int onoff + JAMMAOP_STARTLIGHTONOFF, // int light, int onoff + JAMMAOP_GETSWCOUNT, // uns *changedmaskp,uns **swcountsp + JAMMAOP_GETSWSTATES, + JAMMAOP_DONTSENDBONE, // int + JAMMAOP_COINMETERINC, // int meter,int num + JAMMAOP_SETCALIBGSXYXYDXYXY, // // int, int,int,int,int, int,int, int,int + JAMMAOP_GETSN, + JAMMAOP_SETCALIBGLTRB, // int,int,int,int,int + JAMMAOP_SETCALIBGMODE, // int,int + JAMMAOP_REQUESTCOUNTS, + JAMMAOP_REQUESTCONFIG, + JAMMAOP_REQUESTVERSION, + JAMMAOP_WATCHLIGHTSONOFF, // int + JAMMAOP_WHITEFLASH_VFB_HFB, // int,int,int,int + JAMMAOP_WATCHDOGBONE_SETCLICKPERIOD, // unsigned -- use JAMMAWATCHDOG_CLICKS_PER_MINUTE + JAMMAOP_WATCHDOGBONE_SETSENDMILLISECONDS, // unsigned + JAMMAOP_GETSTARTLIGHTSTATES, // unsigned char *mask + JAMMAOP_SETIOMODE, // uns + JAMMAOP_TICKETINC, // int ticket dispenser, int count + JAMMAOP_HICURRENTONOFF, // int hi current, int onoff + JAMMAOP_TICKETONOFF, // int hi current, int onoff + JAMMAOP_GETHWVERNUM, // returns Hardware version number + JAMMAOP_GETFWVERNUM, // returns Firmware version number + JAMMAOP_SETTICKETPOLARITY, // uns (0 = lo/hi, !0 = hi/lo) + JAMMAOP_TICKETCLEAR, // clear out ticket logic for given dispenser + JAMMAOP_GUNVERBOSEONOFF, // int onoff, turn verbose data on or off + JAMMAOP_GUNAUTOONOFF, // int gun,int onoff + JAMMAOP_SWBITCALLBACKONOFF, // int + JAMMAOP_TICKETSET, // int ticket dispenser, int count + JAMMAOP_GETERRORF, // returns jdev error flags + JAMMAOP_GETUSBWDVERNUM, // returns USB Watchdog version number + JAMMAOP_ISUSBWDPRESENT, // returns FALSE = no, TRUE = yes + JAMMAOP_ISFIRMWAREUPTODATE, // returns FALSE = no, TRUE = yes +}; + +#define JAMMAWATCHDOG_CLICKS_PER_MINUTE 15 +#define JAMMAWATCHDOG_CLICKS_GAME_OPERATION 3 //clicks for safe game operation + +#define M_JAMMAOP 0xff +#define M_JAMMAOP_CLEAR 0x100 //used with JAMMAOP_GETSWCOUNT to clear swchanged status +#define M_JAMMAOP_IGNORECHANGED 0x200 //used with JAMMAOP_GETSWCOUNT ignore swchanged status + +// +// JAMMAIOMODE_ +// current mode for I/O operation +// +enum +{ + JAMMAIOMODE_BBH, // Big Buck Hunter (default) + JAMMAIOMODE_SBB, // Sponge Bob Bowling + NUM_JAMMAIOMODE +}; + +// ---- ---- cccc cccc +// tttt pppp cccc cccc +// c=callback op +// -- other bits can be overloaded -- +// p=player +// t=trigger +#define M_JAMMACALLBACK 0x00ff +#define M_JAMMACALLBACK_PL 0x0f +#define S_JAMMACALLBACK_PL 8 +#define M_JAMMACALLBACK_TR 0x0f +#define S_JAMMACALLBACK_TR 10 +enum { + JAMMACALLBACK_GUNXY=1, // int x,int y + JAMMACALLBACK_RCVBIN, // unsigned char *buf,int len + JAMMACALLBACK_RCVASCII,// unsigned char *buf,int len + JAMMACALLBACK_RCVCHARPKT,// unsigned char *buf,int len + JAMMACALLBACK_STATUS, // unsigned char *buf,int len + JAMMACALLBACK_MESSAGE, // char *buf, int len + JAMMACALLBACK_USERBIT, // int changedonoff + JAMMACALLBACK_TICKET, // int JAMMATICKET_, int arg + JAMMACALLBACK_GUNXYNOTRIGGER, // int x,int y,float snr + JAMMACALLBACK_SWBIT, // int M_JAMMASWBIT_, int M_JAMMADIP_ (must be enabled by JAMMAOP_SWBITCALLBACKONOFF) + JAMMACALLBACK_WATCHDOGCOMING, // +}; + +// +// JAMMATICKET_ +// passed with JAMMACALLBACK_TICKET +// +enum +{ + JAMMATICKET_DONE, + JAMMATICKET_CONTINUING, + JAMMATICKET_ERROR, +}; + +// +// JAMMAFWID_ +// jamma Firmware identifier +// +#define M_JAMMAFWID 0xf0 // mask for Firmware ID +#define JAMMAFWID_BBH 0x00 // Big Buck Hunter Pro +#define JAMMAFWID_SBB 0x50 // Spongebob Bowling + +// +// JAMMAFWVER_ +// current latest jamma Firmware version +// +#define M_JAMMAFWVER 0x0f // mask for Firmware ID +#define JAMMAFWVER_BBH 0x07 // Big Buck Hunter Pro +#define JAMMAFWVER_SBB 0x09 // Spongebob Bowling + +// +// use this when capturing sample data in app +// +#define JAMMA_MAX_GUN_SAMPLES 64 // max gun samples reported per message + +/////////////////////////////////////////////////////////////////////////////// +// ERROR CODES +/////////////////////////////////////////////////////////////////////////////// +// +// ERRORS & EXTENDED RETURN CODES +// +// -1.....-8999 user +// -9000..-9099 system +// +enum // int16 +{ + // system + ERR_JAMMA_SYS_LAST=-9099, + ERR_JAMMA_DEVICE_NOTAVAILABLE, + ERR_JAMMA_IOPORT_OPEN, + ERR_JAMMA_IOPORT_STATE, + ERR_JAMMA_IOPORT_SETTINGS, + ERR_JAMMA_IOPORT_TIMEOUTS, + ERR_JAMMA_IOPORT_THREAD, + ERR_JAMMA_IOPORT_OVERFLOW, + ERR_JAMMA_MEM, + ERR_JAMMA_SWITCHDATA_NOTVALID, + ERR_JAMMA_SWITCHDATA_UNCHANGED, + ERR_JAMMA_OP_NOTRECOGNIZED, + ERR_JAMMA_SYS_FIRST=-9000, + +}; // ERR_ + + +extern int JammaInit(void); +extern void JammaFinal(void); +extern int JammaLoop(void); +extern int JammaOp(unsigned int op,...); + +// apphook +extern void* jamma_apphook_malloc(int size); +extern void jamma_apphook_free(void *m); +extern void jamma_apphook_msg(char *fmt,...); + +/// FUNCTIONS + +#endif // ndef JAMMA_H + +// EOF diff --git a/libraries/pmrt/jamma/jamma.ncb b/libraries/pmrt/jamma/jamma.ncb new file mode 100755 index 0000000..476e1a9 Binary files /dev/null and b/libraries/pmrt/jamma/jamma.ncb differ diff --git a/libraries/pmrt/jamma/jamma.o b/libraries/pmrt/jamma/jamma.o new file mode 100644 index 0000000..539a151 Binary files /dev/null and b/libraries/pmrt/jamma/jamma.o differ diff --git a/libraries/pmrt/jamma/jamma.opt b/libraries/pmrt/jamma/jamma.opt new file mode 100755 index 0000000..01513fc Binary files /dev/null and b/libraries/pmrt/jamma/jamma.opt differ diff --git a/libraries/pmrt/jamma/jamma_lin.c b/libraries/pmrt/jamma/jamma_lin.c new file mode 100755 index 0000000..d883e08 --- /dev/null +++ b/libraries/pmrt/jamma/jamma_lin.c @@ -0,0 +1,1002 @@ +// jamma_lin.c +// JFL 09 May 05 +// JFL 10 May 05; reworked Raw Thrills PC code +// JFL 22 Jun 05; linux +// JFL 29 Jun 05 +// GNP 13 Jan 06; modified to call into app for millisecond timer +// GNP 17 Jan 06; modified jamma_readloop to account jdev->bufn correctly +// GNP 22 Feb 08; added a dump of send queue upon closing app + +#if SYS_BB +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "jamma.h" +#include "jammapriv.h" // include after jamma.h + +#define NUL ((void*)0) + +//struct timeb inittime; +unsigned long long inittime; +extern unsigned long long jamma_apphook_sysmillisec(void); + +// +// dprintf +// debug printf to console +// +static void dprintf(char *fmt,...) +{ +#ifdef DEBUG + va_list args; + va_start(args,fmt); + vprintf(fmt,args); + va_end(args); +#endif //DEBUG +} // dmsg() + + +// forward + +// +// +// + +void jamma_thread(jamma_dev *jdev); + +int jamma_init(void) +{ + // init +// ftime(&inittime); + inittime=jamma_apphook_sysmillisec(); + return 0; +} // jamma_init() + +void jamma_final(void) +{ +} // jamma_final() + +// JFL 17 Jun 05 +int jamma_reset(jamma_dev *jdev,int flags) +{ + if(!flags) + { + // reset all + jdev->errorf=0; + jdev->avail=jdev->mode=0; + jdev->bufn=jdev->bufw=jdev->bufr=0; // clear read buffer + // clear com errors & reset com + tcflush(jdev->fd,TCIOFLUSH); + } + else if(flags&M_JAMMARESET_ERROR) + { + jdev->errorf=0; + // clear com errors & reset com + tcflush(jdev->fd,TCIOFLUSH); + } + + if(!flags || (flags&M_JAMMARESET_HDW)) + { + // clear com errors & reset com + tcflush(jdev->fd,TCIOFLUSH); + } + + return 0; + +} // jamma_reset() + +// JFL 21 Jun 05 +unsigned long jamma_tick(void) +{ + unsigned long long now; + unsigned long t; + + now=jamma_apphook_sysmillisec(); + t = (unsigned long)(jamma_apphook_sysmillisec() - inittime); + +// struct timeb now; +// ftime(&now); +// if((t=now.time-inittime.time)) +// t*=1000; +// t+=now.millitm-inittime.millitm; + + return t; +} // jamma_tick() + +// +// jamma_sendloop +// send any queued data to the I/O board +// +// out +// 1 = no more data to send +// 2 = too soon to send +// 0 = data sent +// <0 = error sending +// +// JFL 20 Jun 05 +// +int jamma_sendloop(jamma_dev *jdev) +{ + int ec; + char *buf; + int bufsize; + + if(!jdev->sndn) + return 1; // nothing to send + if(jdev->sndtime>jamma_tick()) + return 2; // wait longer + + // + // no more easy exits + // + + +/* + // send one character + if(jdev->sndr>=jdev->sndsize) + jdev->sndr=0; + buf=&jdev->snd[jdev->sndr++]; + jdev->sndn--; + bufsize=1; + */ + + if(jdev->sndr>=jdev->sndsize) + jdev->sndr=0; + + // if send queue has wrapped, only send up to the end of queue + // (will wrap and send rest next loop) + if (jdev->sndr + jdev->sndn >= jdev->sndsize ) + bufsize = jdev->sndsize - jdev->sndr; + else + bufsize = jdev->sndn; + + buf=&jdev->snd[jdev->sndr]; + + + // write buf + ec=write(jdev->fd,buf,bufsize); + if(ec<0) + { + if(errno!=EAGAIN) // non-blocking -- still working + { + jdev->errorf|=0x40; + err(-99); + } // non-still-working + } + else + { + // sent ec bytes + jdev->sndr+=ec; + jdev->sndn-=ec; + } + + jdev->sndtime=jamma_tick()+jdev->sndwait; // in milliseconds + + ec=0; +BAIL: + return ec; +} // jamma_sendloop() + +// +// jamma_sendloop_now +// force an immediate send of buffered data, if any exists +// +// GNP 22 FEB 08 +// +int jamma_sendloop_now(jamma_dev *jdev) +{ + int ec; + jdev->sndtime = jamma_tick(); // set next send time to now. + ec=jamma_sendloop(jdev); + return(ec); +} // jamma_sendloop_now + +// JFL 10 May 05 +// JFL 14 May 05 +int jamma_send(jamma_dev *jdev,int flags,unsigned char *buf,int bufsize) +{ + int ec; + + if((jdev->sndn+bufsize)>jdev->sndsize) + err(-1); // overflow + for(;bufsize>0;bufsize--) + { + if(jdev->sndw>=jdev->sndsize) + jdev->sndw=0; + jdev->snd[jdev->sndw++]=*buf++; + jdev->sndn++; + } // for + + ec=0; +BAIL: + return ec; +} // jamma_send() + +// gnu/gclib/libc_toc.html + +// JFL 20 Jul 05 +int jamma_getsn(int x) +{ + return 0; +} // jamma_getsn() + +// JFL 05 May 05 +// JFL 14 May 05 +int jamma_open(jamma_dev *jdev) +{ + int ec; + char *portname; + struct termios tio; + //struct sigaction saio; + + portname="/dev/ttyS0"; + + // open serial port + // O_NOCTTY dont make this controlling terminal + // O_NONBLOCK dont block on reads/writes + if((jdev->fd=open(portname,O_RDWR|O_NOCTTY|O_NONBLOCK))<0) + err(ERR_JAMMA_IOPORT_OPEN); + + // setup signal handler + //bzero(&saio,sizeof(saio)); + //saio.sa_handler=siosignals; + //sigaction(SIGIO,&saio,NULL); + + // alloc proc to rcv SAIO + //fcntl(jdev->fd,F_SETOWN,getpid()); + //fcntl(jdev->fd,F_SETFL,FASYNC); // make asynchronus + + tcgetattr(jdev->fd,&jdev->oldtio); + +//--------- + + fcntl(jdev->fd, F_SETFL, FNDELAY); /* Configure port reading */ + + // try zero-ing? + memset(&tio, 0, sizeof(tio)); + tcgetattr(jdev->fd, &tio); + + tio.c_iflag = 0; // this is not POSIXly correct, but whatever... + tio.c_oflag = 0; + + cfsetispeed(&tio, B115200); /* Set the baud rates */ + cfsetospeed(&tio, B115200); + + /* Enable the receiver and set local mode */ + tio.c_cflag |= (CLOCAL | CREAD); + tio.c_cflag &= ~PARENB; /* Mask the character size to 8 bits, no parity */ + tio.c_cflag &= ~CSTOPB; + tio.c_cflag &= ~CSIZE; + tio.c_cflag |= CS8; /* Select 8 data bits */ + tio.c_cflag &= ~CRTSCTS; /* Disable hardware flow control */ + + /* Enable data to be processed as raw input */ + tio.c_lflag &= ~(ICANON | ECHO | ISIG); + + /* Set the new options for the port */ + tcsetattr(jdev->fd, TCSANOW, &tio); + + +//--------- + + tcflush(jdev->fd,TCIOFLUSH); + + ec=0; +BAIL: + if(ec<0) + jamma_close(jdev); + + return ec; +} // jamma_open() + +// JFL 05 May 05 +void jamma_close(jamma_dev *jdev) +{ + int i,ec; + + if(jdev->fd) + { + // let's send any queued up data + for (i=0;i<10;i++) + { + ec=jamma_sendloop_now(jdev); + if (ec == 1) + break; + } + tcsetattr(jdev->fd,TCSANOW,&jdev->oldtio); + close(jdev->fd); + } + jdev->fd=0; + +} // jamma_close() + +#ifdef DEBUG +#define JPRINT_BUF_SIZE 40 +void jamma_print_read_buf(jamma_dev *jdev, unsigned start, unsigned end) +{ + char buf[JPRINT_BUF_SIZE]; + unsigned i,endmark; + char c; + unsigned char d; + + i=0; + + if(end>=jdev->bufsize) + end=0; + + while(start != end) + { + endmark=0; + if(start>=jdev->bufsize) + start=0; + c=jdev->buf[start++]; + + if (c<0x20) + { + + if (i>=JPRINT_BUF_SIZE-5) + { + buf[i]=0; + jamma_apphook_msg("%s\n",buf); + i=0; + } + + buf[i++]='('; + if(c=='\r') + { + buf[i++]='r'; + endmark=1; + } + else if (c=='\n') + { + buf[i++]='n'; + } + else + { + d = (c & 0xf0) >> 8; + if (d < 10) + d += 0x30; + else + d += (0x41-10); + buf[i++]=d; + + d = (c & 0xf); + if (d < 10) + d += 0x30; + else + d += (0x41-10); + buf[i++]=d; + } + + buf[i++]=')'; + + if (endmark) + { + buf[i]=0; + jamma_apphook_msg("%s\n",buf); + i=0; + endmark=0; + } + + } + else + { + if (i>=JPRINT_BUF_SIZE-1) + { + buf[i]=0; + jamma_apphook_msg("%s\n",buf); + i=0; + } + + buf[i++]=c; + } + } + + if(i!=0) + { + buf[i]=0; + jamma_apphook_msg("%s\n",buf); + } + +} //jamma_print_read_buf +#endif //DEBUG + +// JFL 19 Jun 05 +// JFL 22 Jun 05 +// GNP 17 Jan 06; account jdev->bufn correctly +int jamma_readloop(jamma_dev *jdev) +{ + char buf[255]; + int i,len; + unsigned curbufsize; + char c; + + len=read(jdev->fd,buf,sizeof(buf)); + if(len<=0) + goto BAIL; + if(!jdev->bufsize) + goto BAIL; + + // check for overflow + if((jdev->bufn+=len)>jdev->bufsize) + { + len=jdev->bufsize-jdev->bufn; + jdev->bufn=jdev->bufsize; + jdev->errorf|=M_JAMMA_ERRORF_ROVERFLOW; + } + + // copy & check for packets + for(i=0;ibufw>=jdev->bufsize) + jdev->bufw=0; + c=buf[i]; + + // copy + if(!(jdev->flags&M_JAMMA_CHARPKT)) + { + // normal mode + // wait for a \n, save till \r + if(c=='\n') + { + if(jdev->lowstart) + { + // this is an error condition where the last message + // being sent was truncated. now it's time to backup + // to the start of the last message and write over it + // with the new. + + // first check to make sure that we won't underflow the buffer + // by backing up + + if (jdev->bufr > jdev->bufw) + curbufsize = (jdev->bufsize - jdev->bufr) + jdev->bufw; + else + curbufsize = jdev->bufw - jdev->bufr; + +#ifdef DEBUG + jamma_apphook_msg("jamma_readloop(): truncated message (%d) (%d) (%d) (%d)\n",jdev->bufr,jdev->bufw,curbufsize,jdev->bufw_last); + jamma_print_read_buf(jdev, jdev->bufr, jdev->bufw); +#endif //DEBUG + + if(jdev->bufw_start_char == 'd' + || jdev->bufw_start_char == 'D' + || jdev->bufw_start_char == 'g' + || jdev->bufw_start_char == 'G') + { + // keep this message, but add an end marker +#ifdef DEBUG + jamma_apphook_msg("jamma_readloop(): keeping truncated message, adding message terminator\n"); +#endif //DEBUG + jdev->buf[jdev->bufw++]='\r'; + jdev->bufn++; // increment buffer count, no error check necessary as count will be decremented below + jdev->avail++; + jdev->lowstart=0; + } + else + { + // delete this message +#ifdef DEBUG + jamma_apphook_msg("jamma_readloop(): deleting truncated message\n"); +#endif //DEBUG + if (jdev->cur_readlen > curbufsize) + { +#ifdef DEBUG + jamma_apphook_msg("jamma_readloop(): deleting truncated message resulted in underflow, resetting buffer\n"); +#endif //DEBUG + // for whatever reason the buffer is going to underflow + // let's just reset it + jdev->bufw = jdev->bufr= jdev->avail = 0; + jdev->bufn = len-i; + } + else + { + jdev->bufw = jdev->bufw_last; + jdev->bufn -= jdev->cur_readlen; + } + } +#ifdef DEBUG + jamma_apphook_msg("jamma_readloop(): after operation message appears (%d) (%d)\n",jdev->bufr,jdev->bufw); + jamma_print_read_buf(jdev, jdev->bufr, jdev->bufw); +#endif //DEBUG + } + jdev->lowstart=1; // starting new message + jdev->bufw_last=jdev->bufw; // save starting spot + jdev->cur_readlen=0; // reset read count + jdev->bufn--; // character not added to input buffer + } + else if(jdev->lowstart) + { + jdev->buf[jdev->bufw++]=c; + // if this is the first character after start, save + if(jdev->cur_readlen==0) + jdev->bufw_start_char=c; + jdev->cur_readlen++; + if(c=='\r') + { + jdev->lowstart=0; + jdev->avail++; + } + } + else + { +#ifdef DEBUG + jamma_apphook_msg("jamma_readloop(): character received outside of message %x\n",(unsigned)c); +#endif //DEBUG + jdev->bufn--; // character not added to input buffer + } + } // normal + else + { + // every char is a pkt + jdev->buf[jdev->bufw++]=c; + jdev->avail++; + } // char pkt mode +/* + // copy + jdev->buf[jdev->bufw++]=c; + if((c=='\r') || (jdev->flags&M_JAMMA_CHARPKT)) // packet avail + jdev->avail++; +*/ + } // for + +BAIL: + return 0; +} // jamma_readloop() + +// +// jamma_mutex_wait +// wait for mutex to be signaled +// +void jamma_mutex_wait(jamma_dev *jdev) +{ + // only used when read is done by seperate thread +} // jamma_mutex_wait() + +// +// jamma_mutex_release +// release ownership of a mutex +// +void jamma_mutex_release(jamma_dev *jdev) +{ + // only used when read is done by seperate thread +} //jamma_mutex_release() + +// +// USB watchdog support +// +#ifdef USB_WATCHDOG + +/************************************** +** from usbwd.c +** courtesy Jason Green +** +** Copyright 2007 RAW THRILLS INC +**************************************/ + +// common, internal fxns +int build_rx_msg(unsigned char byte); +int open_usbwd(jamma_dev *jdev); +int send_usbwd(jamma_dev *jdev,unsigned char *buf, unsigned long len); +int read_usbwd(jamma_dev *jdev,void *buf, unsigned long len); +int jamma_usbwd_getreport(jamma_dev *jdev, unsigned char *buf); + +// unique Raw Thrills USBWD vid:pid +#define MY_VID 0x0C70 +#define MY_PID 0x0774 + +#define EP_IN 0x81 +#define EP_OUT 0x02 + +// global crud for building messages +// this should be unglobalized in the future +unsigned char UsbRxBuf[2]; +unsigned char UsbRxState = 0; +#define USB_RX_BUF_RAW_SIZE 256 +unsigned char UsbRxBufRaw[USB_RX_BUF_RAW_SIZE]; + +unsigned char UsbRxRdIdx = 0; +unsigned char UsbRxWrIdx = 0; + +// GNP 22 Jun 07 +int jamma_usbwd_open(jamma_dev *jdev) +{ + int ec; + + jamma_usbwd_close(jdev); // just in case + + if(open_usbwd(jdev)>=0) + { + // zero transfer states, structs + UsbRxRdIdx = 0; + UsbRxWrIdx = 0; + UsbRxState = 0; + jdev->usbFlags=0; + ec=0; + } + else + ec=-1; + return ec; +} // jamma_usbwd_open() + +// GNP 22 Jun 07 +void jamma_usbwd_close(jamma_dev *jdev) +{ + if(jdev->usbwd_dev) + { + usb_release_interface(jdev->usbwd_dev, 0); + usb_close(jdev->usbwd_dev); + } + jdev->usbwd_dev=NULL; + +} // jamma_usbwd_close() + +// +// jamma_usbwd_readloop +// reads the USB watchdog interface to see if information is available. +// the usb library will block for 1 msec if no information is available, +// so now we will only read the board if we have requested information such +// as config and version. Also the minimum time between reads is 250 msec. +// It would be nice to find a routine that queries the readiness of data on the +// port without blocking. +// GNP 22 Jun 07 +// GNP 10 Oct 07; limited reads from the usb port +// +int jamma_usbwd_readloop(jamma_dev *jdev) +{ + int c; + unsigned char buf[16]; + + if (((jdev->usbFlags & M_USBFLAGS_CONFIGREQ_SENT) || (jdev->usbFlags & M_USBFLAGS_VERSIONREQ_SENT)) + && (jdev->usbReadTime <= jamma_tick())) + { + dprintf("jamma_usbwd_readloop: reading usb\n"); + + while(jamma_usbwd_getreport(jdev,(unsigned char*)buf) >= 0) + { + // parse msg + switch(buf[1]) + { + case USBWD_MSG_CONFIG: + dprintf("jamma_usbwd_readloop: 0x%02x 0x%02x (CONFIG)\n", buf[1], buf[0]); + c=0; + + // clear the check flag + jdev->usbFlags &= ~M_USBFLAGS_CONFIGREQ_SENT; + // original configuration used to set watchdog + // flag only once per start-up + if(!(jdev->flags&M_JAMMA_USB_ORG_VALID)) + { + jdev->flags|=M_JAMMA_USB_ORG_VALID; + jdev->flags&=~(M_JAMMA_USB_WATCHDOG); + if(buf[0] & USBWD_CONFIG_WDOGGED) + { + jdev->flags |= M_JAMMA_USB_WATCHDOG; + } + } // org valid + + if(buf[0] & USBWD_CONFIG_WDOGGED) + { + c |= USBWD_CONFIG_WDOG_CLEAR; + dprintf("USB Watchdog occured.\n"); + } + if (jdev->versUSB == 0) + c |= USBWD_VERSION_REQUEST; + if(c) + { + if(jamma_usbwd_config(jdev,c)<0) + jdev->errorf |= M_JAMMA_ERRORF_USBWD; + } + break; + + case USBWD_MSG_DEBUG: + if (buf[0] == 0x0D) // indicates watchdog about to be asserted + { + // we are about to be reset, let app know + if(jdev->callback) // let app know userbit has been cleared + (*jdev->callback)(JAMMACALLBACK_WATCHDOGCOMING,0); + } + // this message seems to show up when a watchdog actually occurs + // and blocks the config request so we'll send the request again + // if we haven't seen the config response yet + if(!(jdev->flags&M_JAMMA_USB_ORG_VALID)) + jamma_usbwd_config(jdev,USBWD_CONFIG_REQUEST); + + dprintf("jamma_usbwd_readloop: 0x%02X %02X (DEBUG)\n", buf[1], buf[0]); + break; + + case USBWD_MSG_VERSION: + dprintf("jamma_usbwd_readloop: 0x%02X %02X (VERSION)\n", buf[1], buf[0]); + // clear the check flag + jdev->usbFlags &= ~M_USBFLAGS_VERSIONREQ_SENT; + jdev->versUSB = buf[0]; + break; + } + + jdev->usbReadTime=JAMMA_WAIT_USB_READ+jamma_tick(); + } //while + } + + return 0; +} + +// GNP 22 Jun 07 +int jamma_usbwd_sendreport(jamma_dev *jdev, unsigned char *buf) +{ + unsigned char msgbuf[4]; + int ec = 0; + + msgbuf[0] = 0x10 | ((buf[1] & 0xF0) >> 4); + msgbuf[1] = 0x20 | ((buf[1] & 0x0F)); + msgbuf[2] = 0x30 | ((buf[0] & 0xF0) >> 4); + msgbuf[3] = 0x40 | ((buf[0] & 0x0F)); + + // all sync'd for now - need to keep state when polling + ec = send_usbwd(jdev,&msgbuf[0], 4); + +// dprintf("jamma_usbwd_sendreport: %02X %02X %02X %02X (%d) \n", msgbuf[0], msgbuf[1], msgbuf[2], msgbuf[3], ec); + + return ec; + +} + +// GNP 22 Jun 07 +int jamma_usbwd_throwwatchdogbone(jamma_dev *jdev, int secs) +{ + unsigned char buf[2]; + + buf[1] = USBWD_MSG_BONE; + buf[0] = secs; // # of seconds + + return(jamma_usbwd_sendreport(jdev,buf)); + +} + +// GNP 22 Jun 07 +int jamma_usbwd_config(jamma_dev *jdev, int flags) +{ + unsigned char buf[2]; + int ret; + + buf[1] = USBWD_MSG_CONFIG; + buf[0] = flags; + +// dprintf("jamma_usbwd_config: %02X %02X\n", buf[1], buf[0]); + + ret = jamma_usbwd_sendreport(jdev,buf); + if (ret >= 0) + { + // successful send, let's set some flags + if(flags & USBWD_CONFIG_REQUEST) + jdev->usbFlags |= M_USBFLAGS_CONFIGREQ_SENT; + if(flags & USBWD_VERSION_REQUEST) + jdev->usbFlags |= M_USBFLAGS_VERSIONREQ_SENT; + } + return(ret); +} + +// GNP 22 Jun 07 +usb_dev_handle *open_usbwd_dev(void) +{ + struct usb_bus *bus; + struct usb_device *dev; + + for(bus = usb_get_busses(); bus; bus = bus->next) + { + for(dev = bus->devices; dev; dev = dev->next) + { + if(dev->descriptor.idVendor == MY_VID + && dev->descriptor.idProduct == MY_PID) + { + return usb_open(dev); + } + } + } + return NULL; +} + +// GNP 22 Jun 07 +int open_usbwd(jamma_dev *jdev) +{ + int ec = 0; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + if(!(jdev->usbwd_dev = open_usbwd_dev())) + { + ec=-1; + goto BAIL; + } + + ec = usb_set_configuration(jdev->usbwd_dev, 1); + if(ec < 0) + { + usb_close(jdev->usbwd_dev); + jdev->usbwd_dev=NULL; + ec=-2; + goto BAIL; + } + + ec = usb_claim_interface(jdev->usbwd_dev, 0); + if(ec < 0) + { + usb_close(jdev->usbwd_dev); + jdev->usbwd_dev=NULL; + ec=-3; + goto BAIL; + } + +BAIL: + return(ec); +} + +// GNP 22 Jun 07 +int send_usbwd(jamma_dev *jdev,unsigned char *buf, unsigned long len) +{ + int ec = 0; + + ec = usb_interrupt_write(jdev->usbwd_dev, EP_OUT, (char*)buf, len, 5000); + + if(ec != len) + { +// printf("error: usb_interrupt_write write failed\n"); + ec = -1; + } + else + ec=0; + + return ec; +} + +// GNP 22 Jun 07 +int read_usbwd(jamma_dev *jdev,void *buf, unsigned long len) +{ + int ec; + + if((ec=usb_interrupt_read(jdev->usbwd_dev, EP_IN, (char*)buf, len, 0)) != len) + { +// dprintf("error: usb_interrupt_read read failed returned %d\n",ec); + + return -1; + } + + return 0; + +} + +// GNP 22 Jun 07 +int jamma_usbwd_getreport(jamma_dev *jdev, unsigned char *buf) +{ + unsigned char bytes[4]; + int ec = 0; + + // first, catch up with buffer + while(UsbRxWrIdx != UsbRxRdIdx) + { + if(build_rx_msg(UsbRxBufRaw[UsbRxRdIdx++])) + { + // complete 2-byte msg in UsbRxBuf! + memcpy(buf, UsbRxBuf, 2); + ec=0; + goto BAIL; + } + } + + // NOW service the actual driver buffer + //if(readpipe(&byte, 4) == 1) + ec=read_usbwd(jdev,&bytes, 4); + while(ec>=0) + { + unsigned char n = 0; + // we have rec'd 4 bytes - add them to buffer + + for(n=0;n<4;n++) + { + if((UsbRxWrIdx+1) != UsbRxRdIdx) + { + UsbRxBufRaw[UsbRxWrIdx++] = bytes[n]; + } + else + { + ec=-1; + goto BAIL; + } + } + + // we got more bytes, maybe another whole msg? + // catch up with the buffer again + while(UsbRxWrIdx != UsbRxRdIdx) + { + if(build_rx_msg(UsbRxBufRaw[UsbRxRdIdx++])) + { + // complete 2-byte msg in UsbRxBuf! + memcpy(buf, UsbRxBuf, 2); + ec=0; + goto BAIL; + } + } + ec=read_usbwd(jdev,&bytes, 4); + } +BAIL: + return(ec); +} + +/////////////////////////////////////////////////////////////// +// internal fxns +/////////////////////////////////////////////////////////////// +int build_rx_msg(unsigned char byte) +{ + // no matter WHAT state we're in, if we get the 1st byte we + // want to receive it + if((byte & 0xF0) == 0x10) + { + UsbRxState = 1; + UsbRxBuf[1] = ((byte & 0x0F) << 4); + } + else + { + // received byte! + switch(UsbRxState) { + case 0: + // waiting for 1st byte (MSB, MSN) + // NOTE: THIS CASE IS HANDLED ABOVE - CAN'T EXECUTE HERE!!! + if((byte & 0xF0) == 0x10) { + UsbRxState = 1; + UsbRxBuf[1] = ((byte & 0x0F) << 4); + } + break; + case 1: + // waiting for 2nd byte (MSB, LSN) + if((byte & 0xF0) == 0x20) { + UsbRxState = 2; + UsbRxBuf[1] |= byte & 0x0F; + } else + UsbRxState = 0; + break; + case 2: + // waiting for 3rd byte (LSB, MSN) + if((byte & 0xF0) == 0x30) { + UsbRxState = 3; + UsbRxBuf[0] = ((byte & 0x0F) << 4); + } else + UsbRxState = 0; + break; + case 3: + // waiting for 4th byte (LSB, LSN) + if((byte & 0xF0) == 0x40) { + UsbRxState = 4; + UsbRxBuf[0] |= byte & 0x0F; + } else + UsbRxState = 0; + break; + default: + // wtf? + UsbRxState = 0; + break; + } + } + + if(UsbRxState == 4) + { + UsbRxState = 0; + + return 1; + } + + return 0; +} +#endif //USB_WATCHDOG + +#endif // SYS_BB +// EOF + diff --git a/libraries/pmrt/jamma/jamma_lin.o b/libraries/pmrt/jamma/jamma_lin.o new file mode 100644 index 0000000..f2c923d Binary files /dev/null and b/libraries/pmrt/jamma/jamma_lin.o differ diff --git a/libraries/pmrt/jamma/jamma_pc.c b/libraries/pmrt/jamma/jamma_pc.c new file mode 100755 index 0000000..7c78b83 --- /dev/null +++ b/libraries/pmrt/jamma/jamma_pc.c @@ -0,0 +1,760 @@ +// jamma_pc.c +// JFL 09 May 05 +// JFL 10 May 05; reworked Raw Thrills PC code +// JFL 29 Jun 05 +// GNP 17 Jan 06; modified jamma_thread to account jdev->bufn correctly + +#if SYS_PC +#include +#include +#include +#include + +#include "jamma.h" +#include "jammapriv.h" // include after jamma.h + +// +// +// + +void jamma_handle_error(jamma_dev *jdev); +void jamma_thread(jamma_dev *jdev); + +int jamma_init(void) +{ + // init + return 0; +} // jamma_init() + +void jamma_final(void) +{ +} // jamma_final() + +// JFL 17 Jun 05 +int jamma_reset(jamma_dev *jdev,int flags) +{ + DWORD dw; + COMSTAT comstat; + + if(!flags) + { + // reset all + jdev->errorf=0; + jdev->avail=jdev->mode=0; + jdev->bufn=jdev->bufw=jdev->bufr=0; // clear read buffer + ClearCommError(jdev->port,&dw,&comstat); + } + else if(flags&M_JAMMARESET_ERROR) + { + jdev->errorf=0; + ClearCommError(jdev->port,&dw,&comstat); + } + + if(!flags || (flags&M_JAMMARESET_HDW)) + { + PurgeComm(jdev->port,PURGE_TXABORT|PURGE_RXABORT + |PURGE_TXCLEAR|PURGE_RXCLEAR); + } + + return 0; +} // jamma_reset() + +// JFL 21 Jun 05 +unsigned long jamma_tick(void) +{ + return GetTickCount(); +} // jamma_tick() + +// JFL 20 Jun 05 +int jamma_sendloop(jamma_dev *jdev) +{ + int ec; + DWORD dw; + OVERLAPPED ov; + COMSTAT comstat; + char *buf; + int bufsize; + + if(!jdev->sndn) + return 1; // nothing to send + if(jdev->sndtime>jamma_tick()) + return 2; // wait longer + + // + // no more easy exits + // + + memset(&ov,0,sizeof(ov)); + ov.hEvent = CreateEvent(0,1,0,0); + + + // send one character + /* + if (jdev->sndr >= jdev->sndsize) + jdev->sndr = 0; + + buf = &jdev->snd[jdev->sndr++]; + jdev->sndn--; + bufsize = 1; + */ + + if(jdev->sndr>=jdev->sndsize) + jdev->sndr=0; + + // if send queue has wrapped, only send up to the end of queue + // (will wrap and send rest next loop) + if (jdev->sndr + jdev->sndn >= jdev->sndsize ) + bufsize = jdev->sndsize - jdev->sndr; + else + bufsize = jdev->sndn; + + buf=&jdev->snd[jdev->sndr]; + + ec=WriteFile(jdev->port,buf,bufsize,&dw,&ov); + if(!ec) + { + if(GetLastError()==ERROR_IO_PENDING) + { + + // blocking + while(!GetOverlappedResult(jdev->port,&ov, &dw,1)) + { + dw = GetLastError(); + if(dw == ERROR_IO_INCOMPLETE) + continue; // not finished + ClearCommError(jdev->port,&dw,&comstat); + } // while + } + else + { + // other error + ClearCommError(jdev->port,&dw,&comstat); + err(-99); + } + } // !ec + + jdev->sndr += dw; + jdev->sndn -= dw; + + jdev->sndtime=jamma_tick()+jdev->sndwait; // in milliseconds + + ec=0; +BAIL: + if(ec<0) + jamma_apphook_msg("jamma_sendloop() %d\n",ec); + CloseHandle(ov.hEvent); + return ec; +} // jamma_sendloop() + +int jamma_readloop(jamma_dev *jdev) +{ + return 0; +} // jamma_readloop() + +// JFL 10 May 05 +// JFL 14 May 05 +int jamma_send(jamma_dev *jdev,int flags,unsigned char *buf,int bufsize) +{ + int ec; + + if((jdev->sndn+bufsize)>jdev->sndsize) + err(-10); // overflow + for(;bufsize>0;bufsize--) + { + if(jdev->sndw>=jdev->sndsize) + jdev->sndw=0; + jdev->snd[jdev->sndw++]=*buf++; + jdev->sndn++; + } // for + + ec=0; +BAIL: + return ec; +} // jamma_send() + +// JFL 05 May 05 +// JFL 14 May 05 +int jamma_get(jamma_dev *jdev,unsigned char *buf,int bufsize) +{ + int ec; + DWORD dw; + OVERLAPPED ov; + + memset(&ov,0,sizeof(ov)); + ov.hEvent = CreateEvent(0,1,0,0); + + ReadFile(jdev->port,buf,bufsize,&dw,&ov); + + ec=0; +//BAIL: + CloseHandle(ov.hEvent); + return ec; +} // jamma_get() + +// JFL 20 Jul 05 +int jamma_getsn(int x) +{ + DWORD dw; + char buf[32]; + + buf[0]='c'; + buf[1]=':'; + buf[2]='\\'; + buf[3]=0; + if(!GetVolumeInformation(buf,NULL,0,&dw,NULL,NULL,NULL,0)) + dw=0; + dw^=0xaaaaaaaa; + return dw^x; +} // jamma_getsn() + +// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_functions.asp + +// JFL 05 May 05 +// JFL 14 May 05 +int jamma_open(jamma_dev *jdev) +{ + int ec; + DCB dcb; + char *portname; + DWORD id; + COMMTIMEOUTS timeouts; + int retry; + + portname="COM1"; + + // jjj -- check opening/closing port -- having problems + // and there is extra code in here. + if(jdev->port) + jamma_apphook_msg("jdev->port already open!\n"); + + retry=0; +reopen: + // open serial port + jdev->port=CreateFile(portname, + GENERIC_READ|GENERIC_WRITE, + 0, // share + 0, // security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, + 0 // no template + ); + if(!jdev->port || (jdev->port==INVALID_HANDLE_VALUE)) + { + Sleep(100); + if(++retry<10) + goto reopen; + ec=GetLastError(); + jamma_apphook_msg("jamma_open() Couldn't open %s %d\n",portname,ec); + if(++retry<12) + goto reopen; + err(ERR_JAMMA_IOPORT_OPEN); + } + // change port settings -- 8 N 0 noflowctl + memset(&dcb,0,sizeof(dcb)); + dcb.DCBlength=sizeof(dcb); + if(!GetCommState(jdev->port,&dcb)) // set + err(ERR_JAMMA_IOPORT_STATE); + + switch(jdev->com&M_JAMMACOM_BAUD) + { + case M_JAMMACOM_BAUD_38400: + dcb.BaudRate=38400; // Jason's board speed is fixed for test + break; + case M_JAMMACOM_BAUD_115200: + default: + dcb.BaudRate=115200; + break; + } // switch + + dcb.ByteSize=8; + dcb.Parity=0; + dcb.StopBits=0; + dcb.fOutxDsrFlow = 0; + dcb.fDtrControl = 1; + dcb.fOutxCtsFlow = 0; + dcb.fRtsControl = 1; + dcb.fInX = dcb.fOutX = 0; + dcb.XonChar = 0x11; + dcb.XoffChar = 0x13; + dcb.XonLim = dcb.XoffLim = 100; + dcb.fBinary = 1; + dcb.fParity = 1; + if(!SetCommState(jdev->port,&dcb)) // set + err(ERR_JAMMA_IOPORT_SETTINGS); + + // setup + SetupComm(jdev->port, 256, 256); // recommend sizes for in & out queues + PurgeComm(jdev->port,PURGE_TXABORT|PURGE_RXABORT + |PURGE_TXCLEAR|PURGE_RXCLEAR); + + memset(&timeouts,0,sizeof(timeouts)); + timeouts.ReadIntervalTimeout = MAXDWORD; + if(!SetCommTimeouts(jdev->port, &timeouts)) + err(ERR_JAMMA_IOPORT_TIMEOUTS); + + // create thread + if(!(jdev->thread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)jamma_thread, + (LPVOID)jdev, 0, &id))) + err(ERR_JAMMA_IOPORT_THREAD); + + jdev->hMutex = CreateMutex(NULL,FALSE,NULL); + + ec=0; +BAIL: + if(ec<0) + { + if(jdev->port) + CloseHandle(jdev->port); + jdev->port=NULL; + jamma_apphook_msg("jamma_open() %d\n",ec); + } + if(ec<0) + jamma_close(jdev); + + return ec; +} // jamma_open() + +// JFL 05 May 05 +void jamma_close(jamma_dev *jdev) +{ + if(jdev->thread) + TerminateThread(jdev->thread,0); + jdev->thread=NULL; + + if(jdev->hMutex) + CloseHandle(jdev->hMutex); + jdev->hMutex=NULL; + + if(jdev->port) + { + SetCommMask(jdev->port,0); + CloseHandle(jdev->port); + } + jdev->port=NULL; + +} // jamma_close() + +// +// jamma_mutex_wait +// wait for mutex to be signaled +// +void jamma_mutex_wait(jamma_dev *jdev) +{ + if(jdev->hMutex) + WaitForSingleObject(jdev->hMutex,INFINITE); +} // jamma_mutex_wait() + +// +// jamma_mutex_release +// release ownership of a mutex +// +void jamma_mutex_release(jamma_dev *jdev) +{ + if(jdev->hMutex) + ReleaseMutex(jdev->hMutex); +} //jamma_mutex_release() + +// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_reference.asp + +// JFL 05 May 05 +// JFL 14 Jun 05 +// JFL 17 Jun 05 +// JFL 04 Aug 05 +// GNP 17 Jan 06; account jdev->bufn correctly +void jamma_thread(jamma_dev *jdev) +{ + OVERLAPPED ov; + char c,buf[4096]; + int i; + long dw,dm; + + if(!jdev) + return; + + // + // INIT + // + + // create event for overlapped IO + memset(&ov,0,sizeof(ov)); + ov.hEvent = CreateEvent(0,0,0,0); + if(INVALID_HANDLE_VALUE==ov.hEvent) + goto BAIL; + + // + // + // + + SetCommMask(jdev->port,EV_RXCHAR); + + for(;;) + { + Sleep(1); + if(jdev->errorf&M_JAMMA_ERRORF_LOW) + { + PurgeComm(jdev->port,PURGE_TXABORT|PURGE_RXABORT + |PURGE_TXCLEAR|PURGE_RXCLEAR); + jdev->errorf&=~M_JAMMA_ERRORF_LOW; + } + + dm=0; + if(!WaitCommEvent(jdev->port,&dm,&ov)) + { + if((i=GetLastError()) != ERROR_IO_PENDING) + {jdev->errorf|=0x01;continue;} + else if(!GetOverlappedResult(jdev->port,&ov,&dw,1)) + {jdev->errorf|=0x02;continue;} + } // !WaitCommEvent + + if(!(dm&EV_RXCHAR)) + continue; + + dw=0; + if(!ReadFile(jdev->port,buf,sizeof(buf),&dw,&ov)) + { + if((i=GetLastError()) != ERROR_IO_PENDING) + {jdev->errorf|=0x04;continue;} + else if(!GetOverlappedResult(jdev->port,&ov,&dw,1)) + {jdev->errorf|=0x08;continue;} + } // !ReadFile + + if(!jdev->bufsize) + continue; + if(dw<=0) + continue; + + // wait for mutex + jamma_mutex_wait(jdev); + + // check for overflow + if((jdev->bufn+=dw)>jdev->bufsize) + { + dw=jdev->bufsize-jdev->bufn; + jdev->bufn=jdev->bufsize; + jdev->errorf|=M_JAMMA_ERRORF_ROVERFLOW; + } + + // copy & check for packets + for(i=0;ibufw>=jdev->bufsize) + jdev->bufw=0; + c=buf[i]; + + // copy + if(!(jdev->flags&M_JAMMA_CHARPKT)) + { + // normal mode + // wait for a \n, save till \r + if(c=='\n') + { + jdev->lowstart=1; + jdev->bufn--; // character not added to input buffer + } + else if(jdev->lowstart) + { + jdev->buf[jdev->bufw++]=c; + if(c=='\r') + { + jdev->lowstart=0; + jdev->avail++; + } + } + } // normal + else + { + // every char is a pkt + jdev->buf[jdev->bufw++]=c; + jdev->avail++; + } // char pkt mode + + } // for + + jamma_mutex_release(jdev); + } // for + + // + // FINALIZE + // + +BAIL: + if(INVALID_HANDLE_VALUE!=ov.hEvent) + CloseHandle(ov.hEvent); +} // jamma_thread() + +// +// USB watchdog support +// +#ifdef USB_WATCHDOG + +/************************************** +** from usbwd.c +** courtesy Jason Green +** +** Copyright 2007 RAW THRILLS INC +**************************************/ + + +// common, internal fxns +int build_rx_msg(unsigned char byte); +int open_usbwd(jamma_dev *jdev); +int send_usbwd(jamma_dev *jdev,unsigned char *buf, unsigned long len); +int read_usbwd(jamma_dev *jdev,void *buf, unsigned long len); +int jamma_usbwd_getreport(jamma_dev *jdev, unsigned char *buf); + + +// unique Raw Thrills USBWD vid:pid +#define MY_VID 0x0C70 +#define MY_PID 0x0774 + +#define EP_IN 0x81 +#define EP_OUT 0x02 + +// JFL 05 May 05 +// JFL 14 May 05 +int jamma_usbwd_open(jamma_dev *jdev) +{ + int ec; + ec=-1; + return ec; +} // jamma_usbwd_open() + +// JFL 05 May 05 +void jamma_usbwd_close(jamma_dev *jdev) +{ + jdev->usbwd_dev=NULL; +} // jamma_usbwd_close() + +int jamma_usbwd_readloop(jamma_dev *jdev) +{ + return 0; +} + +int jamma_usbwd_sendreport(jamma_dev *jdev, unsigned char *buf) +{ + int ec = 0; + return ec; + +} + +int jamma_usbwd_throwwatchdogbone(jamma_dev *jdev, int secs) +{ + unsigned char buf[2]; + + buf[1] = USBWD_MSG_BONE; + buf[0] = secs; // # of seconds + + return jamma_usbwd_sendreport(jdev,buf); + +} + +int jamma_usbwd_config(jamma_dev *jdev, int flags) +{ + unsigned char buf[2]; + + buf[1] = USBWD_MSG_CONFIG; + buf[0] = flags; + + return jamma_usbwd_sendreport(jdev, buf); +} + +#if 0 +usb_dev_handle *open_usbwd_dev(void) +{ + struct usb_bus *bus; + struct usb_device *dev; + + for(bus = usb_get_busses(); bus; bus = bus->next) + { + for(dev = bus->devices; dev; dev = dev->next) + { + if(dev->descriptor.idVendor == MY_VID + && dev->descriptor.idProduct == MY_PID) + { + return usb_open(dev); + } + } + } + return NULL; +} + +int open_usbwd(jamma_dev *jdev) +{ + int ec = 0; + + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + if(!(jdev->usbwd_dev = open_usbwd_dev())) + { + ec=-1; + goto BAIL; + } + + ec = usb_set_configuration(jdev->usbwd_dev, 1); + if(ec < 0) + { + usb_close(jdev->usbwd_dev); + jdev->usbwd_dev=NULL; + ec=-2; + goto BAIL; + } + + ec = usb_claim_interface(jdev->usbwd_dev, 0); + if(ec < 0) + { + usb_close(jdev->usbwd_dev); + jdev->usbwd_dev=NULL; + ec=-3; + goto BAIL; + } + +BAIL: + return(ec); +} +#endif +int send_usbwd(jamma_dev *jdev,unsigned char *buf, unsigned long len) +{ + int ec = 0; + return ec; +} + +int read_usbwd(jamma_dev *jdev,void *buf, unsigned long len) +{ + return -1; +} + +unsigned char UsbRxBuf[2]; +unsigned char UsbRxState = 0; +#define USB_RX_BUF_RAW_SIZE 256 +unsigned char UsbRxBufRaw[USB_RX_BUF_RAW_SIZE]; + +unsigned char UsbRxRdIdx = 0; +unsigned char UsbRxWrIdx = 0; + +int jamma_usbwd_getreport(jamma_dev *jdev, unsigned char *buf) +{ + unsigned char bytes[4]; + int ec = 0; + + // first, catch up with buffer + while(UsbRxWrIdx != UsbRxRdIdx) + { + if(build_rx_msg(UsbRxBufRaw[UsbRxRdIdx++])) + { + // complete 2-byte msg in UsbRxBuf! + memcpy(buf, UsbRxBuf, 2); + ec=0; + goto BAIL; + } + } + + // NOW service the actual driver buffer + //if(readpipe(&byte, 4) == 1) + ec=read_usbwd(jdev,&bytes, 4); + while(ec>=0) + { + unsigned char n = 0; + // we have rec'd 4 bytes - add them to buffer + + for(n=0;n<4;n++) + { + if((UsbRxWrIdx+1) != UsbRxRdIdx) + { + UsbRxBufRaw[UsbRxWrIdx++] = bytes[n]; + } + else + { + ec=-1; + goto BAIL; + } + } + + // we got more bytes, maybe another whole msg? + // catch up with the buffer again + while(UsbRxWrIdx != UsbRxRdIdx) + { + if(build_rx_msg(UsbRxBufRaw[UsbRxRdIdx++])) + { + // complete 2-byte msg in UsbRxBuf! + memcpy(buf, UsbRxBuf, 2); + ec=0; + goto BAIL; + } + } + ec=read_usbwd(jdev,&bytes, 4); + } +BAIL: + return(ec); +} + +/////////////////////////////////////////////////////////////// +// internal fxns +/////////////////////////////////////////////////////////////// +int build_rx_msg(unsigned char byte) +{ + // no matter WHAT state we're in, if we get the 1st byte we + // want to receive it + if((byte & 0xF0) == 0x10) + { + UsbRxState = 1; + UsbRxBuf[1] = ((byte & 0x0F) << 4); + } + else + { + // received byte! + switch(UsbRxState) { + case 0: + // waiting for 1st byte (MSB, MSN) + // NOTE: THIS CASE IS HANDLED ABOVE - CAN'T EXECUTE HERE!!! + if((byte & 0xF0) == 0x10) { + UsbRxState = 1; + UsbRxBuf[1] = ((byte & 0x0F) << 4); + } + break; + case 1: + // waiting for 2nd byte (MSB, LSN) + if((byte & 0xF0) == 0x20) { + UsbRxState = 2; + UsbRxBuf[1] |= byte & 0x0F; + } else + UsbRxState = 0; + break; + case 2: + // waiting for 3rd byte (LSB, MSN) + if((byte & 0xF0) == 0x30) { + UsbRxState = 3; + UsbRxBuf[0] = ((byte & 0x0F) << 4); + } else + UsbRxState = 0; + break; + case 3: + // waiting for 4th byte (LSB, LSN) + if((byte & 0xF0) == 0x40) { + UsbRxState = 4; + UsbRxBuf[0] |= byte & 0x0F; + } else + UsbRxState = 0; + break; + default: + // wtf? + UsbRxState = 0; + break; + } + } + + if(UsbRxState == 4) + { + UsbRxState = 0; + + return 1; + } + + return 0; +} +#endif //USB_WATCHDOG + +#endif // SYS_PC +// EOF diff --git a/libraries/pmrt/jamma/jammalib.dsp b/libraries/pmrt/jamma/jammalib.dsp new file mode 100755 index 0000000..9b5d662 --- /dev/null +++ b/libraries/pmrt/jamma/jammalib.dsp @@ -0,0 +1,120 @@ +# Microsoft Developer Studio Project File - Name="jammalib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=jammalib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "jammalib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "jammalib.mak" CFG="jammalib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "jammalib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "jammalib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/jamma", CADAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "jammalib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /D "PRODUCTION" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=copy Release\jammalib.lib c:\g3\lib copy jamma.h c:\g3\include +# End Special Build Tool + +!ELSEIF "$(CFG)" == "jammalib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_LIB" /D "SYS_PC" /D "DEBUG" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=copy Debug\jammalib.lib c:\g3\lib copy jamma.h c:\g3\include +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "jammalib - Win32 Release" +# Name "jammalib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\jamma.c +# End Source File +# Begin Source File + +SOURCE=.\jamma_lin.c +# End Source File +# Begin Source File + +SOURCE=.\jamma_pc.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\jamma.h +# End Source File +# Begin Source File + +SOURCE=.\jammapriv.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/jamma/jammalib.plg b/libraries/pmrt/jamma/jammalib.plg new file mode 100755 index 0000000..d21b082 --- /dev/null +++ b/libraries/pmrt/jamma/jammalib.plg @@ -0,0 +1,3225 @@ + + +
+

Build Log

+

+--------------------Configuration: Modem - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP45E.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/Modem.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\Modem\modem.c" +"C:\g3\libraries\pmrt\Modem\modem_lin.c" +"C:\g3\libraries\pmrt\Modem\modem_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP45E.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\Modem.lib" .\Release\modem.obj .\Release\modem_lin.obj .\Release\modem_pc.obj " +

Output Window

+Compiling... +modem.c +C:\g3\libraries\pmrt\Modem\modempriv.h(129) : fatal error C1189: #error : Must define SYS_ in pre-processor +modem_lin.c +modem_pc.c +Error executing cl.exe. + + + +

Results

+Modem.lib - 1 error(s), 0 warning(s) +

+--------------------Configuration: Modem - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP45F.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/Modem.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\Modem\modem.c" +"C:\g3\libraries\pmrt\Modem\modem_lin.c" +"C:\g3\libraries\pmrt\Modem\modem_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP45F.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\Modem.lib" .\Debug\modem.obj .\Debug\modem_lin.obj .\Debug\modem_pc.obj " +

Output Window

+Compiling... +modem.c +modem_lin.c +modem_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP460.bat" with contents +[ +@echo off +mkdir c:\g3\include\modem +copy *.h c:\g3\include\modem\ +copy debug\modem.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP460.bat" + +modem.h +modempriv.h + 2 file(s) copied. + 1 file(s) copied. + + + +

Results

+Modem.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: external_libs - Win32 Release-------------------- +

+ + +Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 +Copyright (C) Microsoft Corp 1988-1998. All rights reserved. + + c:\g3\libraries\remove-libs-w32.bat +Deleting contents of c:/g3/lib... +Deleting contents of c:/g3/include... + c:\g3\libraries\install-external-libs-w32.bat +Installing external libraries and headers... +Installing freeglut... +2 File(s) copied +2 File(s) copied +4 File(s) copied +Installing glew... +2 File(s) copied +2 File(s) copied +2 File(s) copied +Installing glut... +2 File(s) copied +2 File(s) copied +2 File(s) copied +Installing glext... +3 File(s) copied +Installing libxml... +6 File(s) copied +3 File(s) copied +48 File(s) copied +Installing openssl... +4 File(s) copied +3 File(s) copied +70 File(s) copied +Installing Xiph libs... +5 File(s) copied +10 File(s) copied +Installing zlib... +2 File(s) copied +4 File(s) copied +3 File(s) copied +Installing dsound... +2 File(s) copied +Installing iconv... +11 File(s) copied +4 File(s) copied +Installing icmp... +2 File(s) copied +5 File(s) copied +Installing hasp... +2 File(s) copied +Installing PhysX... +3 File(s) copied +4 File(s) copied +188 File(s) copied +

+--------------------Configuration: card - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP462.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Release/card.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\card\card.c" +"C:\g3\libraries\pmrt\card\card_lin.c" +"C:\g3\libraries\pmrt\card\card_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP462.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\card.lib" .\Release\card.obj .\Release\card_lin.obj .\Release\card_pc.obj " +

Output Window

+Compiling... +card.c +card_lin.c +card_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP463.bat" with contents +[ +@echo off +copy Release\card.lib c:\g3\lib +copy card.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP463.bat" +Copying card files + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+card.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: external_libs - Win32 Debug-------------------- +

+ + +Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 +Copyright (C) Microsoft Corp 1988-1998. All rights reserved. + + c:\g3\libraries\remove-libs-w32.bat +Deleting contents of c:/g3/lib... +Deleting contents of c:/g3/include... + c:\g3\libraries\install-external-libs-w32.bat +Installing external libraries and headers... +Installing freeglut... +2 File(s) copied +2 File(s) copied +4 File(s) copied +Installing glew... +2 File(s) copied +2 File(s) copied +2 File(s) copied +Installing glut... +2 File(s) copied +2 File(s) copied +2 File(s) copied +Installing glext... +3 File(s) copied +Installing libxml... +6 File(s) copied +3 File(s) copied +48 File(s) copied +Installing openssl... +4 File(s) copied +3 File(s) copied +70 File(s) copied +Installing Xiph libs... +5 File(s) copied +10 File(s) copied +Installing zlib... +2 File(s) copied +4 File(s) copied +3 File(s) copied +Installing dsound... +2 File(s) copied +Installing iconv... +11 File(s) copied +4 File(s) copied +Installing icmp... +2 File(s) copied +5 File(s) copied +Installing hasp... +2 File(s) copied +Installing PhysX... +3 File(s) copied +4 File(s) copied +188 File(s) copied +

+--------------------Configuration: card - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP464.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "SYS_PC" /D "WIN32" /D "_MBCS" /D "_LIB" /Fp"Debug/card.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\card\card.c" +"C:\g3\libraries\pmrt\card\card_lin.c" +"C:\g3\libraries\pmrt\card\card_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP464.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\card.lib" .\Debug\card.obj .\Debug\card_lin.obj .\Debug\card_pc.obj " +

Output Window

+Compiling... +card.c +card_lin.c +card_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP465.bat" with contents +[ +@echo off +copy Debug\card.lib c:\g3\lib +copy card.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP465.bat" +Copying card files + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+card.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: pmrt_utils - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP466.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/pmrt_utils.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\pmrt_utils\audcrc.c" +"C:\g3\libraries\pmrt\pmrt_utils\cguardian.c" +"C:\g3\libraries\pmrt\pmrt_utils\containerCommon.c" +"C:\g3\libraries\pmrt\pmrt_utils\containers.c" +"C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c" +"C:\g3\libraries\pmrt\pmrt_utils\filesys.c" +"C:\g3\libraries\pmrt\pmrt_utils\icmpSock_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\icmpSock_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\memallochist.c" +"C:\g3\libraries\pmrt\pmrt_utils\microtime.c" +"C:\g3\libraries\pmrt\pmrt_utils\netclient.c" +"C:\g3\libraries\pmrt\pmrt_utils\netsock_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\netsock_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\node.c" +"C:\g3\libraries\pmrt\pmrt_utils\pmrt_strings.c" +"C:\g3\libraries\pmrt\pmrt_utils\rtdatatypes.c" +"C:\g3\libraries\pmrt\pmrt_utils\textfile.c" +"C:\g3\libraries\pmrt\pmrt_utils\thread_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\thread_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP466.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP467.tmp" with contents +[ +/nologo /out:"Release\pmrt_utils.lib" +.\Release\audcrc.obj +.\Release\cguardian.obj +.\Release\containerCommon.obj +.\Release\containers.obj +.\Release\dnslookup.obj +.\Release\filesys.obj +.\Release\icmpSock_bb.obj +.\Release\icmpSock_pc.obj +.\Release\interfaceInfo.obj +.\Release\interfaceInfo_bb.obj +.\Release\interfaceInfo_pc.obj +.\Release\memallochist.obj +.\Release\microtime.obj +.\Release\netclient.obj +.\Release\netsock_bb.obj +.\Release\netsock_pc.obj +.\Release\node.obj +.\Release\pmrt_strings.obj +.\Release\rtdatatypes.obj +.\Release\textfile.obj +.\Release\thread_bb.obj +.\Release\thread_pc.obj +.\Release\tsqueue.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP467.tmp" +

Output Window

+Compiling... +audcrc.c +cguardian.c +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2371: 'ThreadStartInfo' : redefinition; different basic types + C:\g3\libraries\pmrt\pmrt_utils\thread.h(25) : see declaration of 'ThreadStartInfo' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ';' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(45) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(45) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(45) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(46) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(46) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(46) : error C2059: syntax error : ')' +containerCommon.c +containers.c +dnslookup.c +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2371: 'ThreadStartInfo' : redefinition; different basic types + C:\g3\libraries\pmrt\pmrt_utils\thread.h(25) : see declaration of 'ThreadStartInfo' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ';' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(61) : warning C4013: 'gethostbyname' undefined; assuming extern returning int +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(61) : warning C4047: '=' : 'struct hostent *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(66) : error C2037: left of 'h_addr_list' specifies undefined struct/union 'hostent' +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(113) : error C2065: 'ThreadHandle' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(113) : error C2146: syntax error : missing ';' before identifier 'th' +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(113) : error C2065: 'th' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c(128) : warning C4013: 'StartThread' undefined; assuming extern returning int +filesys.c +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(44) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(45) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(45) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(45) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(46) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(46) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.h(46) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2371: 'ThreadStartInfo' : redefinition; different basic types + C:\g3\libraries\pmrt\pmrt_utils\thread.h(25) : see declaration of 'ThreadStartInfo' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ';' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(49) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(72) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(72) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(72) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(73) : error C2054: expected '(' to follow 'fdh' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(84) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(84) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(84) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(85) : error C2054: expected '(' to follow 'fdh' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(109) : error C2065: 'FsDH' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(109) : error C2146: syntax error : missing ';' before identifier 'dh' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(109) : error C2065: 'dh' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(110) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(111) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(112) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(113) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(114) : error C2275: 'FILE' : illegal use of this type as an expression + C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\stdio.h(156) : see declaration of 'FILE' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(114) : error C2065: 'fd' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(115) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(117) : error C2065: 'ec' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(117) : warning C4013: 'FsOpenDir' undefined; assuming extern returning int +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(121) : error C2065: 'file' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(121) : warning C4013: 'FsReadDir' undefined; assuming extern returning int +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(121) : warning C4047: '!=' : 'int ' differs in levels of indirection from 'void *' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(123) : error C2065: 'len' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(123) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(123) : warning C4024: 'strlen' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(125) : error C2109: subscript requires array or pointer type +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(127) : error C2109: subscript requires array or pointer type +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(127) : error C2109: subscript requires array or pointer type +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(131) : error C2065: 'buf' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(132) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(132) : warning C4024: 'sprintf' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(136) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(136) : warning C4024: 'fopen' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(136) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(142) : error C2065: 'size' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(142) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(142) : warning C4024: 'FsDirSize' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(146) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(146) : warning C4024: 'fseek' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(149) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(149) : warning C4024: 'fclose' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(153) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(153) : warning C4024: 'ftell' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(154) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(154) : warning C4024: 'fclose' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(157) : warning C4013: 'FsCloseDir' undefined; assuming extern returning int +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(165) : error C2146: syntax error : missing ';' before identifier 'dh' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(166) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(167) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(168) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(169) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(175) : warning C4047: '!=' : 'int ' differs in levels of indirection from 'void *' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(177) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(177) : warning C4024: 'strlen' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(179) : error C2109: subscript requires array or pointer type +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(181) : error C2109: subscript requires array or pointer type +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(181) : error C2109: subscript requires array or pointer type +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(186) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(186) : warning C4024: 'sprintf' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(191) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(191) : warning C4024: 'unlink' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(196) : warning C4047: 'function' : 'char *' differs in levels of indirection from 'int ' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(196) : warning C4024: 'FsRecursiveRmdir' : different types for formal and actual parameter 1 +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(207) : warning C4013: 'rmdir' undefined; assuming extern returning int +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(219) : error C2146: syntax error : missing ';' before identifier 'dh' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(220) : error C2143: syntax error : missing ';' before 'type' +C:\g3\libraries\pmrt\pmrt_utils\filesys.c(220) : fatal error C1003: error count exceeds 100; stopping compilation +icmpSock_bb.c +icmpSock_pc.c +interfaceInfo.c +interfaceInfo_bb.c +interfaceInfo_pc.c +memallochist.c +C:\g3\libraries\pmrt\pmrt_utils\memallochist.c(35) : warning C4013: 'prts_debug' undefined; assuming extern returning int +microtime.c +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2061: syntax error : identifier 'GetSysElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(29) : error C2061: syntax error : identifier 'uns64' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(30) : error C2061: syntax error : identifier 'accumulated_time' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(30) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(32) : error C2059: syntax error : '}' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2061: syntax error : identifier 'PMRT_Timer_GetElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(134) : error C2065: 'uns64' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(134) : error C2146: syntax error : missing ';' before identifier 'microsecs' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(134) : error C2065: 'microsecs' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(135) : error C2275: 'uns32' : illegal use of this type as an expression + C:\g3\libraries\pmrt\pmrt_utils\node.h(18) : see declaration of 'uns32' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(135) : error C2146: syntax error : missing ';' before identifier 'retval' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(135) : error C2065: 'retval' : undeclared identifier +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(136) : warning C4013: 'GetSysElapsedMicroseconds' undefined; assuming extern returning int +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(143) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(143) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(143) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(144) : error C2054: expected '(' to follow 'timer' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(155) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(155) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(155) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(156) : error C2054: expected '(' to follow 'timer' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(164) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(164) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(164) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(165) : error C2054: expected '(' to follow 'timer' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(174) : error C2061: syntax error : identifier 'PMRT_Timer_GetElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(174) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(174) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(174) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(174) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(175) : error C2054: expected '(' to follow 'timer' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(185) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(185) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(185) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.c(186) : error C2054: expected '(' to follow 'timer' +netclient.c +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2061: syntax error : identifier 'GetSysElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(29) : error C2061: syntax error : identifier 'uns64' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(30) : error C2061: syntax error : identifier 'accumulated_time' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(30) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(32) : error C2059: syntax error : '}' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2061: syntax error : identifier 'PMRT_Timer_GetElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(34) : error C2061: syntax error : identifier 'NetSockHandle' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(55) : error C2061: syntax error : identifier 'connect_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(55) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(56) : error C2061: syntax error : identifier 'connect_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(56) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(57) : error C2061: syntax error : identifier 'send_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(57) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(58) : error C2061: syntax error : identifier 'send_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(58) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(59) : error C2061: syntax error : identifier 'recv_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(59) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(60) : error C2061: syntax error : identifier 'recv_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(60) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(61) : error C2061: syntax error : identifier 'close_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(61) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(62) : error C2061: syntax error : identifier 'close_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(62) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(63) : error C2061: syntax error : identifier 'complete_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(63) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(65) : error C2059: syntax error : '}' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(97) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(97) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(98) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(110) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(110) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(110) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(112) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(112) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(112) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(117) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(117) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(117) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.c(16) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.c(16) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.c(17) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.c(17) : fatal error C1003: error count exceeds 100; stopping compilation +netsock_bb.c +netsock_pc.c +node.c +C:\g3\libraries\pmrt\pmrt_utils\node.c(134) : warning C4013: 'SYSBREAK' undefined; assuming extern returning int +pmrt_strings.c +rtdatatypes.c +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(48) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(53) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(56) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(59) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(61) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netsock.h(62) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2061: syntax error : identifier 'GetSysElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(22) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(29) : error C2061: syntax error : identifier 'uns64' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(30) : error C2061: syntax error : identifier 'accumulated_time' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(30) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(32) : error C2059: syntax error : '}' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(34) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(36) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2061: syntax error : identifier 'PMRT_Timer_GetElapsedMicroseconds' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(38) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\microtime.h(39) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(34) : error C2061: syntax error : identifier 'NetSockHandle' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(55) : error C2061: syntax error : identifier 'connect_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(55) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(56) : error C2061: syntax error : identifier 'connect_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(56) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(57) : error C2061: syntax error : identifier 'send_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(57) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(58) : error C2061: syntax error : identifier 'send_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(58) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(59) : error C2061: syntax error : identifier 'recv_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(59) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(60) : error C2061: syntax error : identifier 'recv_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(60) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(61) : error C2061: syntax error : identifier 'close_start_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(61) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(62) : error C2061: syntax error : identifier 'close_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(62) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(63) : error C2061: syntax error : identifier 'complete_time' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(63) : error C2059: syntax error : ';' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(65) : error C2059: syntax error : '}' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(97) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(97) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(98) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(110) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(110) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(110) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(112) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(112) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(112) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(114) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(115) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(117) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(117) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\netclient.h(117) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2371: 'ThreadStartInfo' : redefinition; different basic types + C:\g3\libraries\pmrt\pmrt_utils\thread.h(25) : see declaration of 'ThreadStartInfo' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : fatal error C1003: error count exceeds 100; stopping compilation +textfile.c +thread_bb.c +thread_pc.c +tsqueue.c +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2371: 'ThreadStartInfo' : redefinition; different basic types + C:\g3\libraries\pmrt\pmrt_utils\thread.h(25) : see declaration of 'ThreadStartInfo' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2143: syntax error : missing ';' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(35) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(49) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(50) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(51) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\thread.h(52) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(18) : error C2061: syntax error : identifier 'MutexHandle' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(24) : error C2059: syntax error : '}' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(42) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(42) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(42) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(43) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(43) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(43) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(43) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(44) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(44) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(44) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(44) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(45) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(45) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(45) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(46) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(46) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.h(46) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(19) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(19) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(19) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(64) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(64) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(64) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(64) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(108) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(108) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(108) : error C2059: syntax error : 'type' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(108) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(153) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(153) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(153) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(154) : error C2054: expected '(' to follow 'Queue' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(163) : error C2143: syntax error : missing ')' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(163) : error C2143: syntax error : missing '{' before '*' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(163) : error C2059: syntax error : ')' +C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c(164) : error C2054: expected '(' to follow 'Queue' +Error executing cl.exe. + + + +

Results

+dongle.lib - 529 error(s), 37 warning(s) +

+--------------------Configuration: pmrt_utils - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP468.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR"Debug/" /Fp"Debug/pmrt_utils.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_utils\audcrc.c" +"C:\g3\libraries\pmrt\pmrt_utils\cguardian.c" +"C:\g3\libraries\pmrt\pmrt_utils\containerCommon.c" +"C:\g3\libraries\pmrt\pmrt_utils\containers.c" +"C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c" +"C:\g3\libraries\pmrt\pmrt_utils\filesys.c" +"C:\g3\libraries\pmrt\pmrt_utils\icmpSock_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\icmpSock_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\memallochist.c" +"C:\g3\libraries\pmrt\pmrt_utils\microtime.c" +"C:\g3\libraries\pmrt\pmrt_utils\netclient.c" +"C:\g3\libraries\pmrt\pmrt_utils\netsock_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\netsock_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\node.c" +"C:\g3\libraries\pmrt\pmrt_utils\pmrt_strings.c" +"C:\g3\libraries\pmrt\pmrt_utils\rtdatatypes.c" +"C:\g3\libraries\pmrt\pmrt_utils\textfile.c" +"C:\g3\libraries\pmrt\pmrt_utils\thread_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\thread_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP468.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP469.tmp" with contents +[ +/nologo /out:"Debug\pmrt_utils.lib" +.\Debug\audcrc.obj +.\Debug\cguardian.obj +.\Debug\containerCommon.obj +.\Debug\containers.obj +.\Debug\dnslookup.obj +.\Debug\filesys.obj +.\Debug\icmpSock_bb.obj +.\Debug\icmpSock_pc.obj +.\Debug\interfaceInfo.obj +.\Debug\interfaceInfo_bb.obj +.\Debug\interfaceInfo_pc.obj +.\Debug\memallochist.obj +.\Debug\microtime.obj +.\Debug\netclient.obj +.\Debug\netsock_bb.obj +.\Debug\netsock_pc.obj +.\Debug\node.obj +.\Debug\pmrt_strings.obj +.\Debug\rtdatatypes.obj +.\Debug\textfile.obj +.\Debug\thread_bb.obj +.\Debug\thread_pc.obj +.\Debug\tsqueue.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP469.tmp" +

Output Window

+Compiling... +audcrc.c +cguardian.c +containerCommon.c +containers.c +dnslookup.c +filesys.c +icmpSock_bb.c +icmpSock_pc.c +interfaceInfo.c +c:\g3\libraries\pmrt\pmrt_utils\icmpsock_pc.c(53) : warning C4761: integral size mismatch in argument; conversion supplied +interfaceInfo_bb.c +interfaceInfo_pc.c +memallochist.c +microtime.c +c:\g3\libraries\pmrt\pmrt_utils\microtime.c(138) : warning C4244: '=' : conversion from 'unsigned __int64 ' to 'unsigned long ', possible loss of data +c:\g3\libraries\pmrt\pmrt_utils\microtime.c(195) : warning C4244: '=' : conversion from 'unsigned __int64 ' to 'unsigned long ', possible loss of data +netclient.c +netsock_bb.c +netsock_pc.c +node.c +pmrt_strings.c +rtdatatypes.c +textfile.c +thread_bb.c +thread_pc.c +tsqueue.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46A.bat" with contents +[ +@echo off +mkdir \g3\include\pmrt_utils +copy Debug\pmrt_utils.lib \g3\lib +copy *.h \g3\include\pmrt_utils +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46A.bat" + + 1 file(s) copied. +audcrc.h +cguardian.h +containerCommon.h +containers.h +dnslookup.h +filesys.h +icmpSock.h +icmpSock_bb.h +icmpSock_pc.h +interfaceInfo.h +interfaceInfo_bb.h +interfaceInfo_pc.h +memallochist.h +microtime.h +netclient.h +netsock.h +netsock_bb.h +netsock_pc.h +node.h +pmrt_strings.h +pmrt_utils.h +rtdatatypes.h +textfile.h +thread.h +thread_bb.h +thread_pc.h +tsqueue.h + 27 file(s) copied. +

+--------------------Configuration: pmrt_ssl - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46B.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_ssl\aescrypt.c" +"C:\g3\libraries\pmrt\pmrt_ssl\datadigest.c" +"C:\g3\libraries\pmrt\pmrt_ssl\filecrypto.c" +"C:\g3\libraries\pmrt\pmrt_ssl\keygenerate.c" +"C:\g3\libraries\pmrt\pmrt_ssl\memcrypto.c" +"C:\g3\libraries\pmrt\pmrt_ssl\netssl.c" +"C:\g3\libraries\pmrt\pmrt_ssl\randomnumbers.c" +"C:\g3\libraries\pmrt\pmrt_ssl\sslclient.c" +"C:\g3\libraries\pmrt\pmrt_ssl\sslhttpclient.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46B.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46C.tmp" with contents +[ +/nologo /out:"Debug\pmrt_ssl.lib" +.\Debug\aescrypt.obj +.\Debug\datadigest.obj +.\Debug\filecrypto.obj +.\Debug\keygenerate.obj +.\Debug\memcrypto.obj +.\Debug\netssl.obj +.\Debug\randomnumbers.obj +.\Debug\sslclient.obj +.\Debug\sslhttpclient.obj +\g3\libraries\pmrt\pmrt_utils\Debug\pmrt_utils.lib +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46C.tmp" +

Output Window

+Compiling... +aescrypt.c +datadigest.c +filecrypto.c +keygenerate.c +memcrypto.c +netssl.c +randomnumbers.c +sslclient.c +sslhttpclient.c +Generating Code... +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46D.bat" with contents +[ +@echo off +mkdir c:\g3\include\pmrt_ssl +copy Debug\pmrt_ssl.lib c:\g3\lib +copy *.h c:\g3\include\pmrt_ssl +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46D.bat" + + 1 file(s) copied. +aescrypt.h +datadigest.h +filecrypto.h +keygenerate.h +memcrypto.h +netssl.h +pmrt_ssl.h +randomnumbers.h +sslclient.h +sslhttpclient.h + 10 file(s) copied. +

+--------------------Configuration: dongle - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46E.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/dongle.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\dongle\dongle.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46E.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\dongle.lib" .\Debug\dongle.obj .\ryvc32.obj \g3\libraries\pmrt\pmrt_ssl\Debug\pmrt_ssl.lib \g3\libraries\pmrt\pmrt_utils\Debug\pmrt_utils.lib " +

Output Window

+Compiling... +dongle.c +Creating library... +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudInitRollingCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudAddToRollingCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudCalcRollingCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudCRC32File already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _CRC32Tab already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _PrintDebug already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _CheckForDebugger already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _ExitOnSig already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _StartDebugGuard already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _GetProcessStatus already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _CheckDebugGuard already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _DisableCoreDump already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _CheckSharedLibs already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _GetCodeEntryPoint already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _ContainersSetMemoryFuncs already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _CopyStrings already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _DebugOutput already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _StringConcat already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _CustomFree already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _CustomMalloc already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListCreate already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPushFront already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPushBack already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPopFront already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPopBack already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPop already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListInsertBefore already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListFree already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListRemove already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListFreeNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListWalk already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListSearch already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListGetNthNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListCopy already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _BinaryTreeCreate already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _BinaryTreeAddNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _BinaryTreeFindNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeCreate already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeAddNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeGoUp already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeGoDown already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeDeleteNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeFree already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _GetHostByName already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _DNSLookupThread already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _DNSLookup already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _gQueryTimeout already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _gQueryErr already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _gQueryStatus already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsFileSize already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsOpenDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsCloseDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsReadDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsDirSize already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsRecursiveRmdir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsDirWalk already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _CountFiles already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsDirCountFiles already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsMkDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsLoadFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsSaveFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsCheckIfFileExists already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsSaveInt already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsLoadInt already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _UtilGetFileSize already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _UtilReadFromFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsFileCopy already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsFileMove already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_SimpleThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_OpenThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_ReadThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_WriteThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_OpenSimple already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Open already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Read already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Write already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckReadWriteBytes already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckStatus already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckError already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckErrorno already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_GetData already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_GetDataLen already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Close already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_OpenFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_SetData already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_GetData already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_Update already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_Close already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(icmpSock_pc.obj) : warning LNK4006: _IcmpPing already defined in pmrt_ssl.lib(icmpSock_pc.obj); second definition ignored +pmrt_utils.lib(interfaceInfo.obj) : warning LNK4006: _NetGetHostName already defined in pmrt_ssl.lib(interfaceInfo.obj); second definition ignored +pmrt_utils.lib(interfaceInfo.obj) : warning LNK4006: _GetDefaultGateway already defined in pmrt_ssl.lib(interfaceInfo.obj); second definition ignored +pmrt_utils.lib(interfaceInfo.obj) : warning LNK4006: _GetRoute already defined in pmrt_ssl.lib(interfaceInfo.obj); second definition ignored +pmrt_utils.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetInterfaceIpAddress already defined in pmrt_ssl.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_utils.lib(interfaceInfo_pc.obj) : warning LNK4006: _EthToolCableStatus already defined in pmrt_ssl.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_utils.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetMacAddress already defined in pmrt_ssl.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _InitMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _AddToMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _DelFromMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _PrintMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMicroseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMilliseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Reset already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Start already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Stop already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_GetElapsedMicroseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_GetElapsedMilliseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _SysDateTime_Utils already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _SysCopytmToSysDate_Utils already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _DateChangesBetweenDates already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _InitClientStateStruct already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _SetClientStateStructRecvBuf already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _ResetClientStateStructRecvBuf already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _SetClientStateStructSendBuf already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _CloseClientConnection already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _UpdateClientState already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _StartWin32Sockets already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockCloseConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenClientTCPConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockCheckConnectionStatus already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutTCPConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromTCPConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenUDPSocket already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutUDPSocket already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromUDPSocket already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockSetBroadcast already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N1LinkTail already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N1LinkHead already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N1Unlink already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Head already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2DontLink already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LinkAfter already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LinkBefore already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Unlink already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Parent already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Count already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LevelSet already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LevelGet already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LevelCpy already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Search already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Walk already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2SearchAndOperate already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2PopNode already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2PopNext already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2PopPrev already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2AddDataNode already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _IncArgOnDataNodes already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2CountDataNodes already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringFill already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringChomp already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringInsertChar already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameIndexFromPath already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameFromPath already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPath already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPathIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringIndexOfNextChar already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilChar already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetWordEndIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringHexToDecimal already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _FindLineInTextStringByStartString already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringIsWhiteSpace already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringFindFirstNonWhiteSpaceIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringFindFirstWhiteSpaceIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilWhitespace already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringHash already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringNHash already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataSetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataGetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _ReadCStructMemberLine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataFindForm already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _ResetCDefines already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _LookupCDefine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _SetCDefine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _ParseCDefine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _CreateNewDataTypeFromCStruct already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GrowForms already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataType already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_Init already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_DeInit already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataTypeFromCStruct already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataTypesFromCDefFile already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetType already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SizeOf already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetMember already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SetMember already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalk already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncPrint already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncDeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeDeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_Tokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_DeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _gNumCDefines already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _gRTDT_BaseForms already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataSmallStringMember already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _ReadLineFromTextFile already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _FindLineInTextFileByStartString already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _FileGetNumLines already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _FileGetLinePositions already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _WriteStringToFile already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_malloc already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_free already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _ThreadSleep already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _ThreadWrapperFunc@4 already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _StartThread already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _InitMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _GetMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _FreeMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _DestroyMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueInit already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePush already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePop already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueDeInit already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueGetCurrSize already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46F.bat" with contents +[ +@echo off +mkdir c:\g3\include\dongle +copy Debug\dongle.lib c:\g3\lib +copy *.h c:\g3\include\dongle +copy ryvc32.obj c:\g3\lib +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP46F.bat" + + 1 file(s) copied. +dongle.h +getopt.h +hasp_hl.h +hasp_vcode.h +ryvc32.h + 5 file(s) copied. + 1 file(s) copied. + + + +

Results

+dongle.lib - 0 error(s), 220 warning(s) +

+--------------------Configuration: jammalib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP470.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /D "PRODUCTION" /Fp"Release/jammalib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\jamma\jamma.c" +"C:\g3\libraries\pmrt\jamma\jamma_lin.c" +"C:\g3\libraries\pmrt\jamma\jamma_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP470.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\jammalib.lib" .\Release\jamma.obj .\Release\jamma_lin.obj .\Release\jamma_pc.obj " +

Output Window

+Compiling... +jamma.c +jamma_lin.c +jamma_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP471.bat" with contents +[ +@echo off +copy Release\jammalib.lib c:\g3\lib +copy jamma.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP471.bat" + + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jammalib.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: jammalib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP472.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_LIB" /D "SYS_PC" /D "DEBUG" /Fp"Debug/jammalib.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\jamma\jamma.c" +"C:\g3\libraries\pmrt\jamma\jamma_lin.c" +"C:\g3\libraries\pmrt\jamma\jamma_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP472.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\jammalib.lib" .\Debug\jamma.obj .\Debug\jamma_lin.obj .\Debug\jamma_pc.obj " +

Output Window

+Compiling... +jamma.c +jamma_lin.c +jamma_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP473.bat" with contents +[ +@echo off +copy Debug\jammalib.lib c:\g3\lib +copy jamma.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP473.bat" + + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jammalib.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: jpeglib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP474.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/jpeglib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\external\jpeglib\jcapimin.c" +"C:\g3\libraries\external\jpeglib\jcapistd.c" +"C:\g3\libraries\external\jpeglib\jccoefct.c" +"C:\g3\libraries\external\jpeglib\jccolor.c" +"C:\g3\libraries\external\jpeglib\jcdctmgr.c" +"C:\g3\libraries\external\jpeglib\jchuff.c" +"C:\g3\libraries\external\jpeglib\jcinit.c" +"C:\g3\libraries\external\jpeglib\jcmainct.c" +"C:\g3\libraries\external\jpeglib\jcmarker.c" +"C:\g3\libraries\external\jpeglib\jcmaster.c" +"C:\g3\libraries\external\jpeglib\jcomapi.c" +"C:\g3\libraries\external\jpeglib\jcparam.c" +"C:\g3\libraries\external\jpeglib\jcphuff.c" +"C:\g3\libraries\external\jpeglib\jcprepct.c" +"C:\g3\libraries\external\jpeglib\jcsample.c" +"C:\g3\libraries\external\jpeglib\jctrans.c" +"C:\g3\libraries\external\jpeglib\jdapimin.c" +"C:\g3\libraries\external\jpeglib\jdapistd.c" +"C:\g3\libraries\external\jpeglib\jdatadst.c" +"C:\g3\libraries\external\jpeglib\jdatasrc.c" +"C:\g3\libraries\external\jpeglib\jdcoefct.c" +"C:\g3\libraries\external\jpeglib\jdcolor.c" +"C:\g3\libraries\external\jpeglib\jddctmgr.c" +"C:\g3\libraries\external\jpeglib\jdhuff.c" +"C:\g3\libraries\external\jpeglib\jdinput.c" +"C:\g3\libraries\external\jpeglib\jdmainct.c" +"C:\g3\libraries\external\jpeglib\jdmarker.c" +"C:\g3\libraries\external\jpeglib\jdmaster.c" +"C:\g3\libraries\external\jpeglib\jdmerge.c" +"C:\g3\libraries\external\jpeglib\jdphuff.c" +"C:\g3\libraries\external\jpeglib\jdpostct.c" +"C:\g3\libraries\external\jpeglib\jdsample.c" +"C:\g3\libraries\external\jpeglib\jdtrans.c" +"C:\g3\libraries\external\jpeglib\jerror.c" +"C:\g3\libraries\external\jpeglib\jfdctflt.c" +"C:\g3\libraries\external\jpeglib\jfdctfst.c" +"C:\g3\libraries\external\jpeglib\jfdctint.c" +"C:\g3\libraries\external\jpeglib\jidctflt.c" +"C:\g3\libraries\external\jpeglib\jidctfst.c" +"C:\g3\libraries\external\jpeglib\jidctint.c" +"C:\g3\libraries\external\jpeglib\jidctred.c" +"C:\g3\libraries\external\jpeglib\jmemansi.c" +"C:\g3\libraries\external\jpeglib\jmemmgr.c" +"C:\g3\libraries\external\jpeglib\jquant1.c" +"C:\g3\libraries\external\jpeglib\jquant2.c" +"C:\g3\libraries\external\jpeglib\jutils.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP474.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP475.tmp" with contents +[ +/nologo /out:"Release\jpeglib.lib" +.\Release\jcapimin.obj +.\Release\jcapistd.obj +.\Release\jccoefct.obj +.\Release\jccolor.obj +.\Release\jcdctmgr.obj +.\Release\jchuff.obj +.\Release\jcinit.obj +.\Release\jcmainct.obj +.\Release\jcmarker.obj +.\Release\jcmaster.obj +.\Release\jcomapi.obj +.\Release\jcparam.obj +.\Release\jcphuff.obj +.\Release\jcprepct.obj +.\Release\jcsample.obj +.\Release\jctrans.obj +.\Release\jdapimin.obj +.\Release\jdapistd.obj +.\Release\jdatadst.obj +.\Release\jdatasrc.obj +.\Release\jdcoefct.obj +.\Release\jdcolor.obj +.\Release\jddctmgr.obj +.\Release\jdhuff.obj +.\Release\jdinput.obj +.\Release\jdmainct.obj +.\Release\jdmarker.obj +.\Release\jdmaster.obj +.\Release\jdmerge.obj +.\Release\jdphuff.obj +.\Release\jdpostct.obj +.\Release\jdsample.obj +.\Release\jdtrans.obj +.\Release\jerror.obj +.\Release\jfdctflt.obj +.\Release\jfdctfst.obj +.\Release\jfdctint.obj +.\Release\jidctflt.obj +.\Release\jidctfst.obj +.\Release\jidctint.obj +.\Release\jidctred.obj +.\Release\jmemansi.obj +.\Release\jmemmgr.obj +.\Release\jquant1.obj +.\Release\jquant2.obj +.\Release\jutils.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP475.tmp" +

Output Window

+Compiling... +jcapimin.c +jcapistd.c +jccoefct.c +jccolor.c +jcdctmgr.c +jchuff.c +jcinit.c +jcmainct.c +jcmarker.c +jcmaster.c +jcomapi.c +jcparam.c +jcphuff.c +jcprepct.c +jcsample.c +jctrans.c +jdapimin.c +jdapistd.c +jdatadst.c +jdatasrc.c +jdcoefct.c +jdcolor.c +jddctmgr.c +jdhuff.c +jdinput.c +jdmainct.c +jdmarker.c +jdmaster.c +jdmerge.c +jdphuff.c +jdpostct.c +jdsample.c +jdtrans.c +jerror.c +jfdctflt.c +jfdctfst.c +jfdctint.c +jidctflt.c +jidctfst.c +jidctint.c +jidctred.c +jmemansi.c +jmemmgr.c +jquant1.c +jquant2.c +jutils.c +Creating library... + + + +

Results

+jpeglib.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: jpeglib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP476.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"Debug/jpeglib.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\external\jpeglib\jcapimin.c" +"C:\g3\libraries\external\jpeglib\jcapistd.c" +"C:\g3\libraries\external\jpeglib\jccoefct.c" +"C:\g3\libraries\external\jpeglib\jccolor.c" +"C:\g3\libraries\external\jpeglib\jcdctmgr.c" +"C:\g3\libraries\external\jpeglib\jchuff.c" +"C:\g3\libraries\external\jpeglib\jcinit.c" +"C:\g3\libraries\external\jpeglib\jcmainct.c" +"C:\g3\libraries\external\jpeglib\jcmarker.c" +"C:\g3\libraries\external\jpeglib\jcmaster.c" +"C:\g3\libraries\external\jpeglib\jcomapi.c" +"C:\g3\libraries\external\jpeglib\jcparam.c" +"C:\g3\libraries\external\jpeglib\jcphuff.c" +"C:\g3\libraries\external\jpeglib\jcprepct.c" +"C:\g3\libraries\external\jpeglib\jcsample.c" +"C:\g3\libraries\external\jpeglib\jctrans.c" +"C:\g3\libraries\external\jpeglib\jdapimin.c" +"C:\g3\libraries\external\jpeglib\jdapistd.c" +"C:\g3\libraries\external\jpeglib\jdatadst.c" +"C:\g3\libraries\external\jpeglib\jdatasrc.c" +"C:\g3\libraries\external\jpeglib\jdcoefct.c" +"C:\g3\libraries\external\jpeglib\jdcolor.c" +"C:\g3\libraries\external\jpeglib\jddctmgr.c" +"C:\g3\libraries\external\jpeglib\jdhuff.c" +"C:\g3\libraries\external\jpeglib\jdinput.c" +"C:\g3\libraries\external\jpeglib\jdmainct.c" +"C:\g3\libraries\external\jpeglib\jdmarker.c" +"C:\g3\libraries\external\jpeglib\jdmaster.c" +"C:\g3\libraries\external\jpeglib\jdmerge.c" +"C:\g3\libraries\external\jpeglib\jdphuff.c" +"C:\g3\libraries\external\jpeglib\jdpostct.c" +"C:\g3\libraries\external\jpeglib\jdsample.c" +"C:\g3\libraries\external\jpeglib\jdtrans.c" +"C:\g3\libraries\external\jpeglib\jerror.c" +"C:\g3\libraries\external\jpeglib\jfdctflt.c" +"C:\g3\libraries\external\jpeglib\jfdctfst.c" +"C:\g3\libraries\external\jpeglib\jfdctint.c" +"C:\g3\libraries\external\jpeglib\jidctflt.c" +"C:\g3\libraries\external\jpeglib\jidctfst.c" +"C:\g3\libraries\external\jpeglib\jidctint.c" +"C:\g3\libraries\external\jpeglib\jidctred.c" +"C:\g3\libraries\external\jpeglib\jmemansi.c" +"C:\g3\libraries\external\jpeglib\jmemmgr.c" +"C:\g3\libraries\external\jpeglib\jquant1.c" +"C:\g3\libraries\external\jpeglib\jquant2.c" +"C:\g3\libraries\external\jpeglib\jutils.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP476.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP477.tmp" with contents +[ +/nologo /out:"Debug\jpeglib.lib" +.\Debug\jcapimin.obj +.\Debug\jcapistd.obj +.\Debug\jccoefct.obj +.\Debug\jccolor.obj +.\Debug\jcdctmgr.obj +.\Debug\jchuff.obj +.\Debug\jcinit.obj +.\Debug\jcmainct.obj +.\Debug\jcmarker.obj +.\Debug\jcmaster.obj +.\Debug\jcomapi.obj +.\Debug\jcparam.obj +.\Debug\jcphuff.obj +.\Debug\jcprepct.obj +.\Debug\jcsample.obj +.\Debug\jctrans.obj +.\Debug\jdapimin.obj +.\Debug\jdapistd.obj +.\Debug\jdatadst.obj +.\Debug\jdatasrc.obj +.\Debug\jdcoefct.obj +.\Debug\jdcolor.obj +.\Debug\jddctmgr.obj +.\Debug\jdhuff.obj +.\Debug\jdinput.obj +.\Debug\jdmainct.obj +.\Debug\jdmarker.obj +.\Debug\jdmaster.obj +.\Debug\jdmerge.obj +.\Debug\jdphuff.obj +.\Debug\jdpostct.obj +.\Debug\jdsample.obj +.\Debug\jdtrans.obj +.\Debug\jerror.obj +.\Debug\jfdctflt.obj +.\Debug\jfdctfst.obj +.\Debug\jfdctint.obj +.\Debug\jidctflt.obj +.\Debug\jidctfst.obj +.\Debug\jidctint.obj +.\Debug\jidctred.obj +.\Debug\jmemansi.obj +.\Debug\jmemmgr.obj +.\Debug\jquant1.obj +.\Debug\jquant2.obj +.\Debug\jutils.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP477.tmp" +

Output Window

+Compiling... +jcapimin.c +jcapistd.c +jccoefct.c +jccolor.c +jcdctmgr.c +jchuff.c +jcinit.c +jcmainct.c +jcmarker.c +jcmaster.c +jcomapi.c +jcparam.c +jcphuff.c +jcprepct.c +jcsample.c +jctrans.c +jdapimin.c +jdapistd.c +jdatadst.c +jdatasrc.c +jdcoefct.c +jdcolor.c +jddctmgr.c +jdhuff.c +jdinput.c +jdmainct.c +jdmarker.c +jdmaster.c +jdmerge.c +jdphuff.c +jdpostct.c +jdsample.c +jdtrans.c +jerror.c +jfdctflt.c +jfdctfst.c +jfdctint.c +jidctflt.c +jidctfst.c +jidctint.c +jidctred.c +jmemansi.c +jmemmgr.c +jquant1.c +jquant2.c +jutils.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP478.bat" with contents +[ +@echo off +copy Debug\jpeglib.lib c:\g3\lib +copy jpeglib.h c:\g3\include +copy jconfig.h c:\g3\include +copy jmorecfg.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP478.bat" +Copying libs & hdrs to lib directory + 1 file(s) copied. + 1 file(s) copied. + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jpeglib.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: jpslib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP479.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Release/jpslib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\jpsnd\jps.c" +"C:\g3\libraries\pmrt\jpsnd\jps_marsig.c" +"C:\g3\libraries\pmrt\jpsnd\jps_parse.c" +"C:\g3\libraries\pmrt\jpsnd\jps_pfuncs.c" +"C:\g3\libraries\pmrt\jpsnd\jps_player.c" +"C:\g3\libraries\pmrt\jpsnd\jps_snd.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_5500.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_dx.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_lin.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP479.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47A.tmp" with contents +[ +/nologo /out:"Release\jpslib.lib" +.\Release\jps.obj +.\Release\jps_marsig.obj +.\Release\jps_parse.obj +.\Release\jps_pfuncs.obj +.\Release\jps_player.obj +.\Release\jps_snd.obj +.\Release\jpsdrvr_5500.obj +.\Release\jpsdrvr_dx.obj +.\Release\jpsdrvr_lin.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47A.tmp" +

Output Window

+Compiling... +jps.c +jps_marsig.c +jps_parse.c +jps_pfuncs.c +jps_player.c +jps_snd.c +jpsdrvr_5500.c +jpsdrvr_dx.c +jpsdrvr_lin.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47B.bat" with contents +[ +@echo off +copy .\Release\jpslib.lib c:\G3\lib\ +copy .\jpsdefs.h c:\G3\include\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47B.bat" + + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jpslib.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: jpslib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47C.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "_WIN32" /D "_LIB" /D "SYS_PC" /Fr"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\jpsnd\jps.c" +"C:\g3\libraries\pmrt\jpsnd\jps_marsig.c" +"C:\g3\libraries\pmrt\jpsnd\jps_parse.c" +"C:\g3\libraries\pmrt\jpsnd\jps_pfuncs.c" +"C:\g3\libraries\pmrt\jpsnd\jps_player.c" +"C:\g3\libraries\pmrt\jpsnd\jps_snd.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_5500.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_dx.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_lin.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47C.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\jpslib.lib" .\Debug\jps.obj .\Debug\jps_marsig.obj .\Debug\jps_parse.obj .\Debug\jps_pfuncs.obj .\Debug\jps_player.obj .\Debug\jps_snd.obj .\Debug\jpsdrvr_5500.obj .\Debug\jpsdrvr_dx.obj .\Debug\jpsdrvr_lin.obj " +

Output Window

+Compiling... +jps.c +jps_marsig.c +jps_parse.c +jps_pfuncs.c +jps_player.c +jps_snd.c +jpsdrvr_5500.c +jpsdrvr_dx.c +jpsdrvr_lin.c +Generating Code... +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47D.bat" with contents +[ +@echo off +copy .\Debug\jpslib.lib c:\G3\lib\ +copy .\jpsdefs.h c:\G3\include\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47D.bat" + + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jpslib.lib - 0 error(s), 0 warning(s) +

+--------------------Configuration: card - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47E.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Release/card.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\card\card.c" +"C:\g3\libraries\pmrt\card\card_lin.c" +"C:\g3\libraries\pmrt\card\card_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47E.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\card.lib" .\Release\card.obj .\Release\card_lin.obj .\Release\card_pc.obj " +

Output Window

+Compiling... +card.c +card_lin.c +card_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47F.bat" with contents +[ +@echo off +copy Release\card.lib c:\g3\lib +copy card.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP47F.bat" +Copying card files + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: jammalib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP480.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /D "PRODUCTION" /Fp"Release/jammalib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\jamma\jamma.c" +"C:\g3\libraries\pmrt\jamma\jamma_lin.c" +"C:\g3\libraries\pmrt\jamma\jamma_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP480.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\jammalib.lib" .\Release\jamma.obj .\Release\jamma_lin.obj .\Release\jamma_pc.obj " +

Output Window

+Compiling... +jamma.c +jamma_lin.c +jamma_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP481.bat" with contents +[ +@echo off +copy Release\jammalib.lib c:\g3\lib +copy jamma.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP481.bat" + + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: jpeglib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP482.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/jpeglib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\external\jpeglib\jcapimin.c" +"C:\g3\libraries\external\jpeglib\jcapistd.c" +"C:\g3\libraries\external\jpeglib\jccoefct.c" +"C:\g3\libraries\external\jpeglib\jccolor.c" +"C:\g3\libraries\external\jpeglib\jcdctmgr.c" +"C:\g3\libraries\external\jpeglib\jchuff.c" +"C:\g3\libraries\external\jpeglib\jcinit.c" +"C:\g3\libraries\external\jpeglib\jcmainct.c" +"C:\g3\libraries\external\jpeglib\jcmarker.c" +"C:\g3\libraries\external\jpeglib\jcmaster.c" +"C:\g3\libraries\external\jpeglib\jcomapi.c" +"C:\g3\libraries\external\jpeglib\jcparam.c" +"C:\g3\libraries\external\jpeglib\jcphuff.c" +"C:\g3\libraries\external\jpeglib\jcprepct.c" +"C:\g3\libraries\external\jpeglib\jcsample.c" +"C:\g3\libraries\external\jpeglib\jctrans.c" +"C:\g3\libraries\external\jpeglib\jdapimin.c" +"C:\g3\libraries\external\jpeglib\jdapistd.c" +"C:\g3\libraries\external\jpeglib\jdatadst.c" +"C:\g3\libraries\external\jpeglib\jdatasrc.c" +"C:\g3\libraries\external\jpeglib\jdcoefct.c" +"C:\g3\libraries\external\jpeglib\jdcolor.c" +"C:\g3\libraries\external\jpeglib\jddctmgr.c" +"C:\g3\libraries\external\jpeglib\jdhuff.c" +"C:\g3\libraries\external\jpeglib\jdinput.c" +"C:\g3\libraries\external\jpeglib\jdmainct.c" +"C:\g3\libraries\external\jpeglib\jdmarker.c" +"C:\g3\libraries\external\jpeglib\jdmaster.c" +"C:\g3\libraries\external\jpeglib\jdmerge.c" +"C:\g3\libraries\external\jpeglib\jdphuff.c" +"C:\g3\libraries\external\jpeglib\jdpostct.c" +"C:\g3\libraries\external\jpeglib\jdsample.c" +"C:\g3\libraries\external\jpeglib\jdtrans.c" +"C:\g3\libraries\external\jpeglib\jerror.c" +"C:\g3\libraries\external\jpeglib\jfdctflt.c" +"C:\g3\libraries\external\jpeglib\jfdctfst.c" +"C:\g3\libraries\external\jpeglib\jfdctint.c" +"C:\g3\libraries\external\jpeglib\jidctflt.c" +"C:\g3\libraries\external\jpeglib\jidctfst.c" +"C:\g3\libraries\external\jpeglib\jidctint.c" +"C:\g3\libraries\external\jpeglib\jidctred.c" +"C:\g3\libraries\external\jpeglib\jmemansi.c" +"C:\g3\libraries\external\jpeglib\jmemmgr.c" +"C:\g3\libraries\external\jpeglib\jquant1.c" +"C:\g3\libraries\external\jpeglib\jquant2.c" +"C:\g3\libraries\external\jpeglib\jutils.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP482.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP483.tmp" with contents +[ +/nologo /out:"Release\jpeglib.lib" +.\Release\jcapimin.obj +.\Release\jcapistd.obj +.\Release\jccoefct.obj +.\Release\jccolor.obj +.\Release\jcdctmgr.obj +.\Release\jchuff.obj +.\Release\jcinit.obj +.\Release\jcmainct.obj +.\Release\jcmarker.obj +.\Release\jcmaster.obj +.\Release\jcomapi.obj +.\Release\jcparam.obj +.\Release\jcphuff.obj +.\Release\jcprepct.obj +.\Release\jcsample.obj +.\Release\jctrans.obj +.\Release\jdapimin.obj +.\Release\jdapistd.obj +.\Release\jdatadst.obj +.\Release\jdatasrc.obj +.\Release\jdcoefct.obj +.\Release\jdcolor.obj +.\Release\jddctmgr.obj +.\Release\jdhuff.obj +.\Release\jdinput.obj +.\Release\jdmainct.obj +.\Release\jdmarker.obj +.\Release\jdmaster.obj +.\Release\jdmerge.obj +.\Release\jdphuff.obj +.\Release\jdpostct.obj +.\Release\jdsample.obj +.\Release\jdtrans.obj +.\Release\jerror.obj +.\Release\jfdctflt.obj +.\Release\jfdctfst.obj +.\Release\jfdctint.obj +.\Release\jidctflt.obj +.\Release\jidctfst.obj +.\Release\jidctint.obj +.\Release\jidctred.obj +.\Release\jmemansi.obj +.\Release\jmemmgr.obj +.\Release\jquant1.obj +.\Release\jquant2.obj +.\Release\jutils.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP483.tmp" +

Output Window

+Compiling... +jcapimin.c +jcapistd.c +jccoefct.c +jccolor.c +jcdctmgr.c +jchuff.c +jcinit.c +jcmainct.c +jcmarker.c +jcmaster.c +jcomapi.c +jcparam.c +jcphuff.c +jcprepct.c +jcsample.c +jctrans.c +jdapimin.c +jdapistd.c +jdatadst.c +jdatasrc.c +jdcoefct.c +jdcolor.c +jddctmgr.c +jdhuff.c +jdinput.c +jdmainct.c +jdmarker.c +jdmaster.c +jdmerge.c +jdphuff.c +jdpostct.c +jdsample.c +jdtrans.c +jerror.c +jfdctflt.c +jfdctfst.c +jfdctint.c +jidctflt.c +jidctfst.c +jidctint.c +jidctred.c +jmemansi.c +jmemmgr.c +jquant1.c +jquant2.c +jutils.c +Creating library... +

+--------------------Configuration: jpslib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP484.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Release/jpslib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\jpsnd\jps.c" +"C:\g3\libraries\pmrt\jpsnd\jps_marsig.c" +"C:\g3\libraries\pmrt\jpsnd\jps_parse.c" +"C:\g3\libraries\pmrt\jpsnd\jps_pfuncs.c" +"C:\g3\libraries\pmrt\jpsnd\jps_player.c" +"C:\g3\libraries\pmrt\jpsnd\jps_snd.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_5500.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_dx.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_lin.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP484.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP485.tmp" with contents +[ +/nologo /out:"Release\jpslib.lib" +.\Release\jps.obj +.\Release\jps_marsig.obj +.\Release\jps_parse.obj +.\Release\jps_pfuncs.obj +.\Release\jps_player.obj +.\Release\jps_snd.obj +.\Release\jpsdrvr_5500.obj +.\Release\jpsdrvr_dx.obj +.\Release\jpsdrvr_lin.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP485.tmp" +

Output Window

+Compiling... +jps.c +jps_marsig.c +jps_parse.c +jps_pfuncs.c +jps_player.c +jps_snd.c +jpsdrvr_5500.c +jpsdrvr_dx.c +jpsdrvr_lin.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP486.bat" with contents +[ +@echo off +copy .\Release\jpslib.lib c:\G3\lib\ +copy .\jpsdefs.h c:\G3\include\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP486.bat" + + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: lungif - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP487.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/lungif.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\external\lungif\dgif_lib.c" +"C:\g3\libraries\external\lungif\egif_lib.c" +"C:\g3\libraries\external\lungif\gif_err.c" +"C:\g3\libraries\external\lungif\gifalloc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP487.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\lungif.lib" .\Release\dgif_lib.obj .\Release\egif_lib.obj .\Release\gif_err.obj .\Release\gifalloc.obj " +

Output Window

+Compiling... +dgif_lib.c +C:\g3\libraries\external\lungif\dgif_lib.c(115) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(116) : warning C4133: '=' : incompatible types - from 'struct _iobuf *' to 'int *' +C:\g3\libraries\external\lungif\dgif_lib.c(122) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(186) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(235) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(248) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(275) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(321) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(336) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(479) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(498) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(505) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(562) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(576) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(617) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(625) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(649) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(904) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(909) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +C:\g3\libraries\external\lungif\dgif_lib.c(934) : warning C4101: 'Error' : unreferenced local variable +C:\g3\libraries\external\lungif\dgif_lib.c(934) : warning C4101: 'i' : unreferenced local variable +C:\g3\libraries\external\lungif\dgif_lib.c(934) : warning C4101: 'j' : unreferenced local variable +egif_lib.c +C:\g3\libraries\external\lungif\egif_lib.c(226) : warning C4018: '!=' : signed/unsigned mismatch +C:\g3\libraries\external\lungif\egif_lib.c(580) : warning C4018: '!=' : signed/unsigned mismatch +C:\g3\libraries\external\lungif\egif_lib.c(705) : warning C4101: 'NewKey' : unreferenced local variable +C:\g3\libraries\external\lungif\egif_lib.c(704) : warning C4101: 'NewCode' : unreferenced local variable +C:\g3\libraries\external\lungif\egif_lib.c(809) : warning C4018: '!=' : signed/unsigned mismatch +C:\g3\libraries\external\lungif\egif_lib.c(825) : warning C4018: '!=' : signed/unsigned mismatch +gif_err.c +gifalloc.c +Creating library... +

+--------------------Configuration: pmrt_compression - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP488.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/pmrt_compression.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\pmrt_compression\pmrt_compression.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP488.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\pmrt_compression.lib" .\Release\pmrt_compression.obj " +

Output Window

+Compiling... +pmrt_compression.c +C:\g3\libraries\pmrt\pmrt_compression\pmrt_compression.h(8) : fatal error C1083: Cannot open include file: 'pmrt_utils/pmrt_utils.h': No such file or directory +Error executing cl.exe. + + + +

Results

+libraries.exe - 1 error(s), 28 warning(s) +

+--------------------Configuration: card - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP489.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "SYS_PC" /D "WIN32" /D "_MBCS" /D "_LIB" /Fp"Debug/card.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\card\card.c" +"C:\g3\libraries\pmrt\card\card_lin.c" +"C:\g3\libraries\pmrt\card\card_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP489.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\card.lib" .\Debug\card.obj .\Debug\card_lin.obj .\Debug\card_pc.obj " +

Output Window

+Compiling... +card.c +card_lin.c +card_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48A.bat" with contents +[ +@echo off +copy Debug\card.lib c:\g3\lib +copy card.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48A.bat" +Copying card files + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: jammalib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48B.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_LIB" /D "SYS_PC" /D "DEBUG" /Fp"Debug/jammalib.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\jamma\jamma.c" +"C:\g3\libraries\pmrt\jamma\jamma_lin.c" +"C:\g3\libraries\pmrt\jamma\jamma_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48B.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\jammalib.lib" .\Debug\jamma.obj .\Debug\jamma_lin.obj .\Debug\jamma_pc.obj " +

Output Window

+Compiling... +jamma.c +jamma_lin.c +jamma_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48C.bat" with contents +[ +@echo off +copy Debug\jammalib.lib c:\g3\lib +copy jamma.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48C.bat" + + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: jpeglib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48D.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"Debug/jpeglib.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\external\jpeglib\jcapimin.c" +"C:\g3\libraries\external\jpeglib\jcapistd.c" +"C:\g3\libraries\external\jpeglib\jccoefct.c" +"C:\g3\libraries\external\jpeglib\jccolor.c" +"C:\g3\libraries\external\jpeglib\jcdctmgr.c" +"C:\g3\libraries\external\jpeglib\jchuff.c" +"C:\g3\libraries\external\jpeglib\jcinit.c" +"C:\g3\libraries\external\jpeglib\jcmainct.c" +"C:\g3\libraries\external\jpeglib\jcmarker.c" +"C:\g3\libraries\external\jpeglib\jcmaster.c" +"C:\g3\libraries\external\jpeglib\jcomapi.c" +"C:\g3\libraries\external\jpeglib\jcparam.c" +"C:\g3\libraries\external\jpeglib\jcphuff.c" +"C:\g3\libraries\external\jpeglib\jcprepct.c" +"C:\g3\libraries\external\jpeglib\jcsample.c" +"C:\g3\libraries\external\jpeglib\jctrans.c" +"C:\g3\libraries\external\jpeglib\jdapimin.c" +"C:\g3\libraries\external\jpeglib\jdapistd.c" +"C:\g3\libraries\external\jpeglib\jdatadst.c" +"C:\g3\libraries\external\jpeglib\jdatasrc.c" +"C:\g3\libraries\external\jpeglib\jdcoefct.c" +"C:\g3\libraries\external\jpeglib\jdcolor.c" +"C:\g3\libraries\external\jpeglib\jddctmgr.c" +"C:\g3\libraries\external\jpeglib\jdhuff.c" +"C:\g3\libraries\external\jpeglib\jdinput.c" +"C:\g3\libraries\external\jpeglib\jdmainct.c" +"C:\g3\libraries\external\jpeglib\jdmarker.c" +"C:\g3\libraries\external\jpeglib\jdmaster.c" +"C:\g3\libraries\external\jpeglib\jdmerge.c" +"C:\g3\libraries\external\jpeglib\jdphuff.c" +"C:\g3\libraries\external\jpeglib\jdpostct.c" +"C:\g3\libraries\external\jpeglib\jdsample.c" +"C:\g3\libraries\external\jpeglib\jdtrans.c" +"C:\g3\libraries\external\jpeglib\jerror.c" +"C:\g3\libraries\external\jpeglib\jfdctflt.c" +"C:\g3\libraries\external\jpeglib\jfdctfst.c" +"C:\g3\libraries\external\jpeglib\jfdctint.c" +"C:\g3\libraries\external\jpeglib\jidctflt.c" +"C:\g3\libraries\external\jpeglib\jidctfst.c" +"C:\g3\libraries\external\jpeglib\jidctint.c" +"C:\g3\libraries\external\jpeglib\jidctred.c" +"C:\g3\libraries\external\jpeglib\jmemansi.c" +"C:\g3\libraries\external\jpeglib\jmemmgr.c" +"C:\g3\libraries\external\jpeglib\jquant1.c" +"C:\g3\libraries\external\jpeglib\jquant2.c" +"C:\g3\libraries\external\jpeglib\jutils.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48D.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48E.tmp" with contents +[ +/nologo /out:"Debug\jpeglib.lib" +.\Debug\jcapimin.obj +.\Debug\jcapistd.obj +.\Debug\jccoefct.obj +.\Debug\jccolor.obj +.\Debug\jcdctmgr.obj +.\Debug\jchuff.obj +.\Debug\jcinit.obj +.\Debug\jcmainct.obj +.\Debug\jcmarker.obj +.\Debug\jcmaster.obj +.\Debug\jcomapi.obj +.\Debug\jcparam.obj +.\Debug\jcphuff.obj +.\Debug\jcprepct.obj +.\Debug\jcsample.obj +.\Debug\jctrans.obj +.\Debug\jdapimin.obj +.\Debug\jdapistd.obj +.\Debug\jdatadst.obj +.\Debug\jdatasrc.obj +.\Debug\jdcoefct.obj +.\Debug\jdcolor.obj +.\Debug\jddctmgr.obj +.\Debug\jdhuff.obj +.\Debug\jdinput.obj +.\Debug\jdmainct.obj +.\Debug\jdmarker.obj +.\Debug\jdmaster.obj +.\Debug\jdmerge.obj +.\Debug\jdphuff.obj +.\Debug\jdpostct.obj +.\Debug\jdsample.obj +.\Debug\jdtrans.obj +.\Debug\jerror.obj +.\Debug\jfdctflt.obj +.\Debug\jfdctfst.obj +.\Debug\jfdctint.obj +.\Debug\jidctflt.obj +.\Debug\jidctfst.obj +.\Debug\jidctint.obj +.\Debug\jidctred.obj +.\Debug\jmemansi.obj +.\Debug\jmemmgr.obj +.\Debug\jquant1.obj +.\Debug\jquant2.obj +.\Debug\jutils.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48E.tmp" +

Output Window

+Compiling... +jcapimin.c +jcapistd.c +jccoefct.c +jccolor.c +jcdctmgr.c +jchuff.c +jcinit.c +jcmainct.c +jcmarker.c +jcmaster.c +jcomapi.c +jcparam.c +jcphuff.c +jcprepct.c +jcsample.c +jctrans.c +jdapimin.c +jdapistd.c +jdatadst.c +jdatasrc.c +jdcoefct.c +jdcolor.c +jddctmgr.c +jdhuff.c +jdinput.c +jdmainct.c +jdmarker.c +jdmaster.c +jdmerge.c +jdphuff.c +jdpostct.c +jdsample.c +jdtrans.c +jerror.c +jfdctflt.c +jfdctfst.c +jfdctint.c +jidctflt.c +jidctfst.c +jidctint.c +jidctred.c +jmemansi.c +jmemmgr.c +jquant1.c +jquant2.c +jutils.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48F.bat" with contents +[ +@echo off +copy Debug\jpeglib.lib c:\g3\lib +copy jpeglib.h c:\g3\include +copy jconfig.h c:\g3\include +copy jmorecfg.h c:\g3\include +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP48F.bat" +Copying libs & hdrs to lib directory + 1 file(s) copied. + 1 file(s) copied. + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: jpslib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP490.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "_WIN32" /D "_LIB" /D "SYS_PC" /Fr"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\jpsnd\jps.c" +"C:\g3\libraries\pmrt\jpsnd\jps_marsig.c" +"C:\g3\libraries\pmrt\jpsnd\jps_parse.c" +"C:\g3\libraries\pmrt\jpsnd\jps_pfuncs.c" +"C:\g3\libraries\pmrt\jpsnd\jps_player.c" +"C:\g3\libraries\pmrt\jpsnd\jps_snd.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_5500.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_dx.c" +"C:\g3\libraries\pmrt\jpsnd\jpsdrvr_lin.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP490.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\jpslib.lib" .\Debug\jps.obj .\Debug\jps_marsig.obj .\Debug\jps_parse.obj .\Debug\jps_pfuncs.obj .\Debug\jps_player.obj .\Debug\jps_snd.obj .\Debug\jpsdrvr_5500.obj .\Debug\jpsdrvr_dx.obj .\Debug\jpsdrvr_lin.obj " +

Output Window

+Compiling... +jps.c +jps_marsig.c +jps_parse.c +jps_pfuncs.c +jps_player.c +jps_snd.c +jpsdrvr_5500.c +jpsdrvr_dx.c +jpsdrvr_lin.c +Generating Code... +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP491.bat" with contents +[ +@echo off +copy .\Debug\jpslib.lib c:\G3\lib\ +copy .\jpsdefs.h c:\G3\include\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP491.bat" + + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: lungif - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP492.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"Debug/lungif.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\external\lungif\dgif_lib.c" +"C:\g3\libraries\external\lungif\egif_lib.c" +"C:\g3\libraries\external\lungif\gif_err.c" +"C:\g3\libraries\external\lungif\gifalloc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP492.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\lungif.lib" .\Debug\dgif_lib.obj .\Debug\egif_lib.obj .\Debug\gif_err.obj .\Debug\gifalloc.obj " +

Output Window

+Compiling... +dgif_lib.c +c:\g3\libraries\external\lungif\dgif_lib.c(115) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(116) : warning C4133: '=' : incompatible types - from 'struct _iobuf *' to 'int *' +c:\g3\libraries\external\lungif\dgif_lib.c(122) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(186) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(235) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(248) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(275) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(321) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(336) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(479) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(498) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(505) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(562) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(576) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(617) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(625) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(649) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(904) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(909) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _iobuf *' +c:\g3\libraries\external\lungif\dgif_lib.c(934) : warning C4101: 'Error' : unreferenced local variable +c:\g3\libraries\external\lungif\dgif_lib.c(934) : warning C4101: 'i' : unreferenced local variable +c:\g3\libraries\external\lungif\dgif_lib.c(934) : warning C4101: 'j' : unreferenced local variable +egif_lib.c +c:\g3\libraries\external\lungif\egif_lib.c(226) : warning C4018: '!=' : signed/unsigned mismatch +c:\g3\libraries\external\lungif\egif_lib.c(580) : warning C4018: '!=' : signed/unsigned mismatch +c:\g3\libraries\external\lungif\egif_lib.c(705) : warning C4101: 'NewKey' : unreferenced local variable +c:\g3\libraries\external\lungif\egif_lib.c(704) : warning C4101: 'NewCode' : unreferenced local variable +c:\g3\libraries\external\lungif\egif_lib.c(809) : warning C4018: '!=' : signed/unsigned mismatch +c:\g3\libraries\external\lungif\egif_lib.c(825) : warning C4018: '!=' : signed/unsigned mismatch +gif_err.c +gifalloc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP493.bat" with contents +[ +@echo off +copy .\Debug\lungif.lib c:\G3\lib\ +copy .\gif_lib.h c:\G3\include\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP493.bat" + + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: pmrt_compression - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP494.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/pmrt_compression.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_compression\pmrt_compression.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP494.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\pmrt_compression.lib" .\Debug\pmrt_compression.obj " +

Output Window

+Compiling... +pmrt_compression.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP495.bat" with contents +[ +@echo off +mkdir c:\g3\include\pmrt_compression +copy Debug\pmrt_compression.lib c:\g3\lib +copy *.h c:\g3\include\pmrt_compression +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP495.bat" + + 1 file(s) copied. +pmrt_compression.h + 1 file(s) copied. +

+--------------------Configuration: pmrt_messages - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP496.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/pmrt_messages.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_messages\dbquery.c" +"C:\g3\libraries\pmrt\pmrt_messages\filetransfer.c" +"C:\g3\libraries\pmrt\pmrt_messages\messages.c" +"C:\g3\libraries\pmrt\pmrt_messages\pmrt_messages.c" +"C:\g3\libraries\pmrt\pmrt_messages\tokens.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP496.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP497.tmp" with contents +[ +/nologo /out:"Debug\pmrt_messages.lib" +.\Debug\dbquery.obj +.\Debug\filetransfer.obj +.\Debug\messages.obj +.\Debug\pmrt_messages.obj +.\Debug\tokens.obj +\g3\libraries\pmrt\pmrt_utils\Debug\pmrt_utils.lib +\g3\libraries\pmrt\pmrt_ssl\Debug\pmrt_ssl.lib +\g3\libraries\pmrt\pmrt_compression\Debug\pmrt_compression.lib +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP497.tmp" +

Output Window

+Compiling... +dbquery.c +filetransfer.c +messages.c +pmrt_messages.c +tokens.c +Creating library... +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueInit already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePush already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePop already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueDeInit already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueGetCurrSize already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_malloc already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_free already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _ThreadSleep already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _ThreadWrapperFunc@4 already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _StartThread already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _InitMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _GetMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _FreeMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _DestroyMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _ReadLineFromTextFile already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _FindLineInTextFileByStartString already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _FileGetNumLines already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _FileGetLinePositions already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _WriteStringToFile already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataSetByString already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataGetByString already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _ReadCStructMemberLine already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataFindForm already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _ResetCDefines already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _LookupCDefine already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _SetCDefine already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _ParseCDefine already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _CreateNewDataTypeFromCStruct already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GrowForms already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataType already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_Init already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_DeInit already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataTypeFromCStruct already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataTypesFromCDefFile already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetType already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SizeOf already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetMember already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SetMember already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SetByString already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetByString already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalk already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncPrint already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncTokenize already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncDeTokenize already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeTokenize already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeDeTokenize already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_Tokenize already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_DeTokenize already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _gNumCDefines already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _gRTDT_BaseForms already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(rtdatatypes.obj) : warning LNK4006: _RTDataSmallStringMember already defined in pmrt_utils.lib(rtdatatypes.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringFill already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringChomp already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringInsertChar already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameIndexFromPath already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameFromPath already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPath already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPathIndex already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringIndexOfNextChar already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilChar already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetWordEndIndex already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringHexToDecimal already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _FindLineInTextStringByStartString already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringIsWhiteSpace already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringFindFirstNonWhiteSpaceIndex already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringFindFirstWhiteSpaceIndex already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilWhitespace already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringHash already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringNHash already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N1LinkTail already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N1LinkHead already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N1Unlink already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Head already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2DontLink already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LinkAfter already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LinkBefore already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Unlink already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Parent already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Count already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LevelSet already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LevelGet already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LevelCpy already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Search already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Walk already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2SearchAndOperate already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2PopNode already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2PopNext already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2PopPrev already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2AddDataNode already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _IncArgOnDataNodes already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2CountDataNodes already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _StartWin32Sockets already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockCloseConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenClientTCPConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockCheckConnectionStatus already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutTCPConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromTCPConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenUDPSocket already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutUDPSocket already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromUDPSocket already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockSetBroadcast already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _InitClientStateStruct already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _SetClientStateStructRecvBuf already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _ResetClientStateStructRecvBuf already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _SetClientStateStructSendBuf already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _CloseClientConnection already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _UpdateClientState already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMicroseconds already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMilliseconds already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Reset already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Start already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Stop already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_GetElapsedMicroseconds already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_GetElapsedMilliseconds already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _SysDateTime_Utils already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _SysCopytmToSysDate_Utils already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _DateChangesBetweenDates already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _InitMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _AddToMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _DelFromMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _PrintMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetInterfaceIpAddress already defined in pmrt_utils.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo_pc.obj) : warning LNK4006: _EthToolCableStatus already defined in pmrt_utils.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetMacAddress already defined in pmrt_utils.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo.obj) : warning LNK4006: _NetGetHostName already defined in pmrt_utils.lib(interfaceInfo.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo.obj) : warning LNK4006: _GetDefaultGateway already defined in pmrt_utils.lib(interfaceInfo.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo.obj) : warning LNK4006: _GetRoute already defined in pmrt_utils.lib(interfaceInfo.obj); second definition ignored +pmrt_ssl.lib(icmpSock_pc.obj) : warning LNK4006: _IcmpPing already defined in pmrt_utils.lib(icmpSock_pc.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsFileSize already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsOpenDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsCloseDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsReadDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsDirSize already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsRecursiveRmdir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsDirWalk already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _CountFiles already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsDirCountFiles already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsMkDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsLoadFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsSaveFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsCheckIfFileExists already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsSaveInt already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsLoadInt already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _UtilGetFileSize already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _UtilReadFromFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsFileCopy already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsFileMove already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_SimpleThread already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_OpenThread already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_ReadThread already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_WriteThread already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_OpenSimple already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Open already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Read already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Write already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckReadWriteBytes already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckStatus already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckError already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckErrorno already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_GetData already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_GetDataLen already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Close already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_OpenFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_SetData already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_GetData already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_Update already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_Close already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _GetHostByName already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _DNSLookupThread already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _DNSLookup already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _gQueryTimeout already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _gQueryErr already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _gQueryStatus already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListCreate already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPushFront already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPushBack already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPopFront already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPopBack already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPop already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListInsertBefore already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListFree already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListRemove already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListFreeNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListWalk already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListSearch already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListGetNthNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListCopy already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _BinaryTreeCreate already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _BinaryTreeAddNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _BinaryTreeFindNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeCreate already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeAddNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeGoUp already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeGoDown already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeDeleteNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeFree already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _ContainersSetMemoryFuncs already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _CopyStrings already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _DebugOutput already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _StringConcat already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _CustomFree already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _CustomMalloc already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _PrintDebug already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _CheckForDebugger already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _ExitOnSig already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _StartDebugGuard already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _GetProcessStatus already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _CheckDebugGuard already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _DisableCoreDump already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _CheckSharedLibs already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _GetCodeEntryPoint already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudInitRollingCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudAddToRollingCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudCalcRollingCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudCRC32File already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _CRC32Tab already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP498.bat" with contents +[ +@echo off +mkdir \g3\include\pmrt_messages +copy Debug\pmrt_messages.lib \g3\lib +copy *.h \g3\include\pmrt_messages +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP498.bat" + + 1 file(s) copied. +dbquery.h +filetransfer.h +messages.h +node.h +pmrt_messages.h +tokens.h + 6 file(s) copied. +

+--------------------Configuration: xml - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP499.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR"Debug/" /Fp"Debug/xml.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\xmlWrapper\xmlWrapper.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP499.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\xml.lib" .\Debug\xmlWrapper.obj " +

Output Window

+Compiling... +xmlWrapper.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49A.bat" with contents +[ +@echo off +mkdir c:\g3\include\xmlWrapper +copy *.h c:\g3\include\xmlWrapper\ +copy debug\xml.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49A.bat" + +xmlWrapper.h + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: telemetry - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49B.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR"Debug/" /Fp"Debug/telemetry.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\telemetry\bitbyte.c" +"C:\g3\libraries\pmrt\telemetry\telemetry.c" +"C:\g3\libraries\pmrt\telemetry\telemetry_bb.c" +"C:\g3\libraries\pmrt\telemetry\telemetry_pc.c" +"C:\g3\libraries\pmrt\telemetry\telemetryXml.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49B.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\telemetry.lib" .\Debug\bitbyte.obj .\Debug\telemetry.obj .\Debug\telemetry_bb.obj .\Debug\telemetry_pc.obj .\Debug\telemetryXml.obj \g3\libraries\pmrt\xmlWrapper\Debug\xml.lib " +

Output Window

+Compiling... +bitbyte.c +telemetry.c +telemetry_bb.c +telemetry_pc.c +telemetryXml.c +Creating library... +telemetry.obj : warning LNK4006: _TelemetryGetData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetrySetupQueries already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryInitialize already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryCollectData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryShutDown already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryUpdateNetTimers already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNumNetTimers already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNetData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryFillNetData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNextNetUpdate already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNetInterval already defined in telemetry_pc.obj; second definition ignored +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49C.bat" with contents +[ +@echo off +mkdir c:\g3\include\telemetry +copy *.h c:\g3\include\telemetry\ +copy debug\telemetry.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49C.bat" + +bitbyte.h +telemetry.h +telemetryXml.h + 3 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: Modem - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49D.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/Modem.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\Modem\modem.c" +"C:\g3\libraries\pmrt\Modem\modem_lin.c" +"C:\g3\libraries\pmrt\Modem\modem_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49D.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\Modem.lib" .\Debug\modem.obj .\Debug\modem_lin.obj .\Debug\modem_pc.obj " +

Output Window

+Compiling... +modem.c +modem_lin.c +modem_pc.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49E.bat" with contents +[ +@echo off +mkdir c:\g3\include\modem +copy *.h c:\g3\include\modem\ +copy debug\modem.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49E.bat" + +modem.h +modempriv.h + 2 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: dongle - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49F.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/dongle.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\dongle\dongle.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP49F.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\dongle.lib" .\Debug\dongle.obj .\ryvc32.obj \g3\libraries\pmrt\pmrt_ssl\Debug\pmrt_ssl.lib \g3\libraries\pmrt\pmrt_utils\Debug\pmrt_utils.lib " +

Output Window

+Compiling... +dongle.c +Creating library... +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudInitRollingCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudAddToRollingCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudCalcRollingCRC32 already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _AudCRC32File already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(audcrc.obj) : warning LNK4006: _CRC32Tab already defined in pmrt_ssl.lib(audcrc.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _PrintDebug already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _CheckForDebugger already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _ExitOnSig already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _StartDebugGuard already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _GetProcessStatus already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _CheckDebugGuard already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _DisableCoreDump already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _CheckSharedLibs already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(cguardian.obj) : warning LNK4006: _GetCodeEntryPoint already defined in pmrt_ssl.lib(cguardian.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _ContainersSetMemoryFuncs already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _CopyStrings already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _DebugOutput already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _StringConcat already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _CustomFree already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containerCommon.obj) : warning LNK4006: _CustomMalloc already defined in pmrt_ssl.lib(containerCommon.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListCreate already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPushFront already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPushBack already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPopFront already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPopBack already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListPop already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListInsertBefore already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListFree already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListRemove already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListFreeNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListWalk already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListSearch already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListGetNthNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _ListCopy already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _BinaryTreeCreate already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _BinaryTreeAddNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _BinaryTreeFindNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeCreate already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeAddNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeGoUp already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeGoDown already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeDeleteNode already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(containers.obj) : warning LNK4006: _TreeFree already defined in pmrt_ssl.lib(containers.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _GetHostByName already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _DNSLookupThread already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _DNSLookup already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _gQueryTimeout already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _gQueryErr already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(dnslookup.obj) : warning LNK4006: _gQueryStatus already defined in pmrt_ssl.lib(dnslookup.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsFileSize already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsOpenDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsCloseDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsReadDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsDirSize already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsRecursiveRmdir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsDirWalk already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _CountFiles already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsDirCountFiles already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsMkDir already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsLoadFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsSaveFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsCheckIfFileExists already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsSaveInt already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsLoadInt already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _UtilGetFileSize already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _UtilReadFromFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsFileCopy already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _FsFileMove already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_SimpleThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_OpenThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_ReadThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIO_WriteThread already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_OpenSimple already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Open already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Read already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Write already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckReadWriteBytes already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckStatus already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckError already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_CheckErrorno already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_GetData already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_GetDataLen already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOHandle_Close already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_OpenFile already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_SetData already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_GetData already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_Update already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(filesys.obj) : warning LNK4006: _NonBlockingIO_Close already defined in pmrt_ssl.lib(filesys.obj); second definition ignored +pmrt_utils.lib(icmpSock_pc.obj) : warning LNK4006: _IcmpPing already defined in pmrt_ssl.lib(icmpSock_pc.obj); second definition ignored +pmrt_utils.lib(interfaceInfo.obj) : warning LNK4006: _NetGetHostName already defined in pmrt_ssl.lib(interfaceInfo.obj); second definition ignored +pmrt_utils.lib(interfaceInfo.obj) : warning LNK4006: _GetDefaultGateway already defined in pmrt_ssl.lib(interfaceInfo.obj); second definition ignored +pmrt_utils.lib(interfaceInfo.obj) : warning LNK4006: _GetRoute already defined in pmrt_ssl.lib(interfaceInfo.obj); second definition ignored +pmrt_utils.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetInterfaceIpAddress already defined in pmrt_ssl.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_utils.lib(interfaceInfo_pc.obj) : warning LNK4006: _EthToolCableStatus already defined in pmrt_ssl.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_utils.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetMacAddress already defined in pmrt_ssl.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _InitMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _AddToMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _DelFromMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(memallochist.obj) : warning LNK4006: _PrintMemAllocHistory already defined in pmrt_ssl.lib(memallochist.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMicroseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMilliseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Reset already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Start already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_Stop already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_GetElapsedMicroseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _PMRT_Timer_GetElapsedMilliseconds already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _SysDateTime_Utils already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _SysCopytmToSysDate_Utils already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(microtime.obj) : warning LNK4006: _DateChangesBetweenDates already defined in pmrt_ssl.lib(microtime.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _InitClientStateStruct already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _SetClientStateStructRecvBuf already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _ResetClientStateStructRecvBuf already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _SetClientStateStructSendBuf already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _CloseClientConnection already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netclient.obj) : warning LNK4006: _UpdateClientState already defined in pmrt_ssl.lib(netclient.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _StartWin32Sockets already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockCloseConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenClientTCPConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockCheckConnectionStatus already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutTCPConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromTCPConnection already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenUDPSocket already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutUDPSocket already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromUDPSocket already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(netsock_pc.obj) : warning LNK4006: _NetSockSetBroadcast already defined in pmrt_ssl.lib(netsock_pc.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N1LinkTail already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N1LinkHead already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N1Unlink already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Head already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2DontLink already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LinkAfter already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LinkBefore already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Unlink already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Parent already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Count already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LevelSet already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LevelGet already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2LevelCpy already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Search already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2Walk already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2SearchAndOperate already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2PopNode already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2PopNext already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2PopPrev already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2AddDataNode already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _IncArgOnDataNodes already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(node.obj) : warning LNK4006: _N2CountDataNodes already defined in pmrt_ssl.lib(node.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringFill already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringChomp already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringInsertChar already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameIndexFromPath already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameFromPath already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPath already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPathIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringIndexOfNextChar already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilChar already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringGetWordEndIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringHexToDecimal already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _FindLineInTextStringByStartString already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringIsWhiteSpace already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringFindFirstNonWhiteSpaceIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringFindFirstWhiteSpaceIndex already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilWhitespace already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringHash already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(pmrt_strings.obj) : warning LNK4006: _StringNHash already defined in pmrt_ssl.lib(pmrt_strings.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataSetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataGetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _ReadCStructMemberLine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataFindForm already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _ResetCDefines already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _LookupCDefine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _SetCDefine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _ParseCDefine already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _CreateNewDataTypeFromCStruct already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GrowForms already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataType already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_Init already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_DeInit already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataTypeFromCStruct already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_AddNewDataTypesFromCDefFile already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetType already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SizeOf already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetMember already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SetMember already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_SetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_GetByString already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalk already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncPrint already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeWalkFuncDeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeDeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_Tokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataTypeParser_DeTokenize already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _gNumCDefines already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _gRTDT_BaseForms already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(rtdatatypes.obj) : warning LNK4006: _RTDataSmallStringMember already defined in pmrt_ssl.lib(rtdatatypes.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _ReadLineFromTextFile already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _FindLineInTextFileByStartString already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _FileGetNumLines already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _FileGetLinePositions already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(textfile.obj) : warning LNK4006: _WriteStringToFile already defined in pmrt_ssl.lib(textfile.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_malloc already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_free already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _ThreadSleep already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _ThreadWrapperFunc@4 already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _StartThread already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _InitMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _GetMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _FreeMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(thread_pc.obj) : warning LNK4006: _DestroyMutex already defined in pmrt_ssl.lib(thread_pc.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueInit already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePush already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePop already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueDeInit already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +pmrt_utils.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueGetCurrSize already defined in pmrt_ssl.lib(tsqueue.obj); second definition ignored +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP4A0.bat" with contents +[ +@echo off +mkdir c:\g3\include\dongle +copy Debug\dongle.lib c:\g3\lib +copy *.h c:\g3\include\dongle +copy ryvc32.obj c:\g3\lib +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP4A0.bat" + +A subdirectory or file c:\g3\include\dongle already exists. + 1 file(s) copied. +dongle.h +getopt.h +hasp_hl.h +hasp_vcode.h +ryvc32.h + 5 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: libraries - Win32 Debug-------------------- +

+ + +Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 +Copyright (C) Microsoft Corp 1988-1998. All rights reserved. + + echo ALL DONE! +ALL DONE! + + + +

Results

+libraries.exe - 0 error(s), 473 warning(s) +

+--------------------Configuration: xml - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP4A1.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"Release/xml.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\g3\libraries\pmrt\xmlWrapper\xmlWrapper.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP4A1.tmp" +Creating command line "link.exe -lib /nologo /out:"Release\xml.lib" .\Release\xmlWrapper.obj " +

Output Window

+Compiling... +xmlWrapper.c +C:\g3\libraries\pmrt\xmlWrapper\xmlWrapper.h(7) : fatal error C1083: Cannot open include file: 'libxml/xmlmemory.h': No such file or directory +Error executing cl.exe. + + + +

Results

+telemetry.lib - 1 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/jamma/jammalib.vcproj b/libraries/pmrt/jamma/jammalib.vcproj new file mode 100755 index 0000000..ac6ecdd --- /dev/null +++ b/libraries/pmrt/jamma/jammalib.vcproj @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/pmrt/jamma/jammalib.vcproj.NAJERA.mnajera.user b/libraries/pmrt/jamma/jammalib.vcproj.NAJERA.mnajera.user new file mode 100755 index 0000000..30f03c1 --- /dev/null +++ b/libraries/pmrt/jamma/jammalib.vcproj.NAJERA.mnajera.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/libraries/pmrt/jamma/jammapriv.h b/libraries/pmrt/jamma/jammapriv.h new file mode 100755 index 0000000..6db1ea6 --- /dev/null +++ b/libraries/pmrt/jamma/jammapriv.h @@ -0,0 +1,288 @@ +// jammapriv.h +// JFL 06 May 05 +// JFL 18 Jun 05 + +#define JAMMAPRIV_VER_STRING "q" +//#define USB_WATCHDOG // undefine to remove (removed until we fix USB probs GNP-28NOV07) + +// error flags +#define M_JAMMA_ERRORF_LOW 0x000ff // low level error flags +#define M_JAMMA_ERRORF_ROVERFLOW 0x01000 // read buffer overflow +#define M_JAMMA_ERRORF_RPKT 0x02000 // packet error +#define M_JAMMA_ERRORF_PKTSTAR 0x04000 // pkt received '*' signalling error +#define M_JAMMA_ERRORF_USBWD 0x08000 // error sending to USB watchdog +#define M_JAMMA_ERRORF_OLDFIRMWARE 0x10000 // firmware on board has been determined to be out of date + +// jamma state +#define M_JAMMA_RCVBIN 0x00000001 +#define M_JAMMA_RCVASCII 0x00000002 +#define M_JAMMA_CHARPKT 0x00000004 // packet avail for each char rcvd +#define M_JAMMA_DONTSENDBONE 0x00000008 // dont send watchdog bone +#define M_JAMMA_GUNAUTO1 0x00000010 // gun 1 autofire enabled +#define M_JAMMA_GUNAUTO2 0x00000020 // gun 2 autofire enabled +#define M_JAMMA_GUN1 0x00000100 // enabled +#define M_JAMMA_GUN2 0x00000200 // enabled +#define M_JAMMA_SLIGHT1 0x00000400 // enabled +#define M_JAMMA_SLIGHT2 0x00000800 // enabled +#define M_JAMMA_SWRCV 0x00001000 // valid switch data read +#define M_JAMMA_ORG_WATCHDOG 0x00002000 // original watchdog bit +#define M_JAMMA_ORG_USER 0x00004000 // original user bit +#define M_JAMMA_ORG_VALID 0x00008000 // original valid +#define M_JAMMA_PERIODICSW 0x00010000 // enabled +#define M_JAMMA_WATCHLIGHTS 0x00020000 // enabled +#define M_JAMMA_USERBIT 0x00040000 // user bit -- synchronize switch counts +#define M_JAMMA_VERBOSEGUN 0x00080000 // ask for verbose gun xy messages +#define M_JAMMA_CLEARWDOGHIT 0x00100000 // clear the watchdog hit bit +#define M_JAMMA_HICURRENT1 0x00200000 // enabled +#define M_JAMMA_HICURRENT2 0x00400000 // enabled +#define M_JAMMA_TICKET1 0x00800000 // enabled +#define M_JAMMA_TICKET_ERROR 0x01000000 // ticket dispenser is empty +#define M_JAMMA_TICKET_POLARITY 0x02000000 // invert the ticket polarity +#define M_JAMMA_USB_ORG_VALID 0x04000000 // original USB configuration is valid +#define M_JAMMA_CALLBACK_SWBIT 0x08000000 // enables callback when new swbit info comes in +#define M_JAMMA_WATCHDOG_MSG 0x10000000 // watchdog message has been printed +#define M_JAMMA_USB_WATCHDOG 0x20000000 // usb watchdog occured + +// communication flags +#define M_JAMMACOM_BAUD_115200 0x00 +#define M_JAMMACOM_BAUD_38400 0x01 +#define M_JAMMACOM_BAUD 0x0f + +#define JAMMAIO_MAX_TICKETS 1023 // maximum amount of tickets the jamma i/o card can handle at once + +// USB watchdog board flags +#define M_USBFLAGS_CONFIGREQ_SENT 0x00000001 // a config request was sent to the USB WD board, expect answer +#define M_USBFLAGS_VERSIONREQ_SENT 0x00000002 // a version request was sent to the USB WD board, expect answer + +#define JAMMA_WAIT_USB_READ 250 // milliseconds to wait to retry connection to usb + +#if SYS_PC +#include + +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + unsigned swchanged; + unsigned com; + int avail; // packets available + int (*callback)(int op,...); + JammaInpRec ir; + unsigned wdogboneclicks; // size of the bone + unsigned long wdogtick; // when to send next bone + unsigned long wdogwait; // how long to wait between sending bones + unsigned long metertick; // when to send next meter pulse + int meter1; + int meter2; + int meter3; + unsigned long periodictime; + unsigned asciibufsize; + unsigned asciibufi; + char *asciibuf; + int calibmode[JAMMA_GUNS]; + float calibwh[2]; // screen wh + int calibflags[JAMMA_GUNS]; // ready or not + float calibxy[2*JAMMA_GUNS]; // top left for gun + float calibmul[2*JAMMA_GUNS]; // 1/w 1/h + unsigned versHW; + unsigned versFW; + int whiteflash[4]; + unsigned iomode; // i/o board operation mode + int ticketcnt[JAMMA_TICKETS]; // current amount of tickets to dispense + int ticketiocur[JAMMA_TICKETS]; // current amount of tickets to dispense on the i/o card + int ticketioadd[JAMMA_TICKETS]; // current amount of tickets to add to i/o card + unsigned long ticketnexttry[JAMMA_TICKETS]; // next time to try dispenser on ticker error + void *usbwd_dev; + unsigned long usbretrytime; // when to retry establishing connection to usb when lost + unsigned versUSB; + unsigned usbFlags; + unsigned long usbReadTime; // time until next read of USB WD allowed + + // implementation specific + HANDLE port; + HANDLE thread; + int mode; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + int lowstart; + unsigned highcurrent; + unsigned highcurrentlogic; // xor'd with high current bits before sending + + char *snd; + unsigned sndwait; // in milliseconds + unsigned long sndtime; + unsigned sndsize; + unsigned sndn; // bytes in buf + unsigned sndw; // write index + unsigned sndr; // read index + + HANDLE hMutex; // synchronizes async writes to the read buffer + +} jamma_dev; + +typedef jamma_dev *jamma_HANDLE; +#endif // SYS_PC + +#if SYS_BB +#include +#ifdef USB_WATCHDOG +#include "usb.h" +#endif //USB_WATCHDOG +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + unsigned swchanged; + unsigned com; + int avail; // packets available + int (*callback)(int op,...); + JammaInpRec ir; + unsigned wdogboneclicks; // size of the bone + unsigned long wdogtick; // when to send next bone + unsigned long wdogwait; // how long to wait between sending bones + unsigned long metertick; // when to send next meter pulse +// unsigned long wdogtime; + int meter1; + int meter2; + int meter3; + unsigned long periodictime; + unsigned asciibufsize; + unsigned asciibufi; + char *asciibuf; +// int calibmethod; + int calibmode[JAMMA_GUNS]; + float calibwh[2]; // screen wh + int calibflags[JAMMA_GUNS]; // ready or not + float calibxy[2*JAMMA_GUNS]; // top left for gun + float calibmul[2*JAMMA_GUNS]; // 1/w 1/h + unsigned versHW; + unsigned versFW; + int whiteflash[4]; + unsigned iomode; // i/o board operation mode + int ticketcnt[JAMMA_TICKETS]; // current amount of tickets to dispense + int ticketiocur[JAMMA_TICKETS]; // current amount of tickets to dispense on the i/o card + int ticketioadd[JAMMA_TICKETS]; // current amount of tickets to add to i/o card + unsigned long ticketnexttry[JAMMA_TICKETS]; // next time to try dispenser on ticker error +#ifdef USB_WATCHDOG + usb_dev_handle *usbwd_dev; +#else + void *usbwd_dev; +#endif //USB_WATCHDOG + unsigned long usbretrytime; // when to retry establishing connection to usb when lost + unsigned versUSB; + unsigned usbFlags; + unsigned long usbReadTime; // time until next read of USB WD allowed + + // implementation specific + int fd; + struct termios oldtio; + int mode; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + int lowstart; + unsigned highcurrent; + unsigned highcurrentlogic; // xor'd with high current bits before sending + + char *snd; + unsigned sndwait; // in milliseconds + unsigned long sndtime; + unsigned sndsize; + unsigned sndn; // bytes in buf + unsigned sndw; // write index + unsigned sndr; // read index + + unsigned bufw_last; // write index at start of last message + unsigned cur_readlen; // current read length of incoming message + char bufw_start_char; // last message starting character +} jamma_dev; +#endif // SYS_BB + +#ifndef NULL +#define NULL ((void*)0) +#endif + +enum { + JAMMAMSG_CONFIG=1, + JAMMAMSG_WATCHDOG, + JAMMAMSG_METER1, + JAMMAMSG_METER2, + JAMMAMSG_METER2A, + JAMMAMSG_GETCONFIG, + JAMMAMSG_GETSWCOUNTS, + JAMMAMSG_GETSWSTATES, + JAMMAMSG_GETVERSION, + JAMMAMSG_LIGHT1, + JAMMAMSG_LIGHT2, + JAMMAMSG_WHITEFLASH, + JAMMAMSG_HICURRENT1, + JAMMAMSG_HICURRENT2, + JAMMAMSG_TICKET1ADD, + JAMMAMSG_TICKET1STOP, +}; +#define M_JAMMAMSG 0xff +#define M_JAMMAMSG_ON 0x100 + +#define err(x) {ec=x;goto BAIL;} + +extern jamma_dev *jamma_jdev; +extern int jamma_init(void); +extern void jamma_final(void); +#define M_JAMMARESET_HDW 0x01 +#define M_JAMMARESET_ERROR 0x02 +extern int jamma_reset(jamma_dev *jdev,int flags); +extern int jamma_open(jamma_dev *jdev); +extern int jamma_msg(jamma_dev *jdev,unsigned msg); +extern void jamma_close(jamma_dev *jdev); +extern int jamma_send(jamma_dev *jdev,int flags,unsigned char *buf,int bufsize); +extern int jamma_get(jamma_dev *jdev, unsigned char *buf,int bufsize); +extern int jamma_pktget(jamma_dev *jdev,unsigned char *buf,int bufsize); +extern int jamma_sendloop(jamma_dev *jdev); +extern int jamma_readloop(jamma_dev *jdev); +extern unsigned long jamma_tick(void); +extern int jamma_getsn(int x); +extern void jamma_mutex_wait(jamma_dev *jdev); +extern void jamma_mutex_release(jamma_dev *jdev); + +#ifdef USB_WATCHDOG +extern int jamma_usbwd_readloop(jamma_dev *jdev); +extern int jamma_usbwd_open(jamma_dev *jdev); +extern void jamma_usbwd_close(jamma_dev *jdev); +extern int jamma_usbwd_throwwatchdogbone(jamma_dev *jdev, int secs); +extern int jamma_usbwd_config(jamma_dev *jdev, int flags); + +#define USBWD_OK 0 +#define USBWD_ERROR 1 +#define USBWD_DISCONNECTED 2 + +#define USBWD_WRITEBUF_SIZE 4 +#define USBWD_READBUF_SIZE 4 + +// msg type fields +#define USBWD_MSG_BONE 0xB0 +#define USBWD_MSG_CONFIG 0xC0 +#define USBWD_MSG_DEBUG 0xD0 +#define USBWD_MSG_VERSION 0xF0 + +// config bitmask - sending +#define USBWD_CONFIG_REQUEST 0x80 +#define USBWD_VERSION_REQUEST 0x40 +#define USBWD_ENABLE_AUTOSEND 0x20 +#define USBWD_CONFIG_BROWNOUT_CLEAR 0x08 +#define USBWD_CONFIG_WDOG_CLEAR 0x01 + +// config bitmask - receiving +#define USBWD_CONFIG_WDOGGED 0x01 +#define USBWD_CONFIG_WATCHING 0x02 +#define USBWD_CONFIG_AUTOWATCH 0x04 +#define USBWD_CONFIG_BROWNEDOUT 0x08 +#define USBWD_AUTOSEND_ENABLED 0x20 + +#endif //USB_WATCHDOG + +// EOF diff --git a/libraries/pmrt/jamma/jammatest b/libraries/pmrt/jamma/jammatest new file mode 100755 index 0000000..51b3521 Binary files /dev/null and b/libraries/pmrt/jamma/jammatest differ diff --git a/libraries/pmrt/jamma/jammatest.c b/libraries/pmrt/jamma/jammatest.c new file mode 100755 index 0000000..c128f8d --- /dev/null +++ b/libraries/pmrt/jamma/jammatest.c @@ -0,0 +1,772 @@ +// jammatest.c +// JFL 05 May 05 +// JFL 22 Jun 05; linux version +// JFL 11 Sep 05; Jason's ec loop fix +// JAL 04 Apr 07; Added Hi-Current output tests - Joe LeVeque + +#define JAMMATEST_VERS "D" + +#include +#include +#include +#include "jamma.h" + +int jamma_callback(int op,...); + +typedef struct { + char mode; +} JammaEmu; + +JammaEmu jammaemumem; + +#if SYS_PC +#include +int ConKeyRead(char *buf,int bufsize) +{ + HANDLE h=INVALID_HANDLE_VALUE; + DWORD dw,save=-1,i; + INPUT_RECORD ir[256]; + int len=0; + + // Get the standard input handle. + h=GetStdHandle(STD_INPUT_HANDLE); + if(h == INVALID_HANDLE_VALUE) + goto BAIL; + + // save + if (!GetConsoleMode(h, &save) ) + goto BAIL; + + // enable + dw=ENABLE_WINDOW_INPUT; + if(!SetConsoleMode(h, dw) ) + goto BAIL; + + // check for input -- don't block if there is none ready + if(!GetNumberOfConsoleInputEvents(h,&dw)) + goto BAIL; + if(!dw) + goto BAIL; + + if(!ReadConsoleInput(h,ir,sizeof(ir)/sizeof(ir[0]),&dw)) + goto BAIL; + + for(i=0;i +#include +#include +#include +#include +#include +struct termios rawtio; +struct termios savetio; +int conInit(void) +{ + tcgetattr(STDIN_FILENO,&savetio); + rawtio=savetio; + rawtio.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + rawtio.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + rawtio.c_cflag &= ~(CSIZE | PARENB); + rawtio.c_cflag |= CS8; + rawtio.c_oflag &= ~(OPOST); + rawtio.c_cc[VMIN]=0; + rawtio.c_cc[VTIME]=0; + return 0; +} +void conFinal(void) +{ + // tcsetattr(STDIN_FILENO,TCSANOW,&savetio); +} +int ConKeyRead(char *buf,int bufsize) +{ + int i; + tcsetattr(STDIN_FILENO,TCSANOW,&rawtio); + usleep(100); + i=read(STDIN_FILENO,buf,bufsize); + tcsetattr(STDIN_FILENO,TCSANOW,&savetio); + return i; +} // ConKeyRead() +int closeScreen(void) +{ + return 0; +} +int fullScreen(unsigned w,unsigned h) +{ + return 0; +} +#endif // SYS_BB + +char asciibuf[128]; + +void jammatesthelp(void) +{ + char buf[64]; + + if(JammaOp(JAMMAOP_GETVERSTRING,buf,sizeof(buf))<0) + buf[0]=0; + + printf("Play Mechanix, Inc. - Jamma Test (vers %s%s)\n",JAMMATEST_VERS,buf); + printf("Copyright(c)2004-7, All Rights Resvd.\n"); + printf("-------------------------------------\n"); + printf(" =exit h=help =pause s=fullscreen a=asciiwatch\n"); + printf(" b=binwatch r=reset&reconfig c=requestconfig v=getversion\n"); + printf(" 1=gun1 2=gun2 d=dumpswcounts A=sendchars\n"); + printf(" m=meter1 n=meter2 S=requestswcount\n"); + printf(" 5=light1 6=light2 7=hicurrent1 8=hicurrent2 l=watchlights\n"); + printf(" i=iomode cycle p=ticket 1 dispense P=toggle ticket notch polarity\n"); + printf(" t=get switch states w=whiteflashparameters\n"); +} // jammatesthelp() + +char iomodenames[NUM_JAMMAIOMODE][32]= +{ + "Big Buck Hunter", + "SpongeBob Bowling", +}; + +// JFL 05 May 05 +int main(int argc,char *argv[]) +{ + int ec,i,box[4],ii; + unsigned char fs=0,pause=0,gun1=0,gun2=0,gverbose=0; + unsigned char dump=0,jammaemu=0,asciidump=0,bindump=0; + unsigned char light1=0,light2=0,watchlights=0,iomode=0,bWarn; + unsigned char hicurrent1=0, hicurrent2=0; + unsigned char ticketPolarity=0; + unsigned initVersHW=0; + unsigned initVersFW=0,hw,fw,vers_usbwd; + unsigned initVersUSBWD=0; + unsigned initWD=0; + char buf[256]; + char c; + unsigned long t,tdump; + JammaInpRec *jir; + + conInit(); + jammatesthelp(); + memset(&jammaemumem,0,sizeof(jammaemumem)); + + if((ec=JammaInit())<0) + { + printf("JammaInit failed\n"); + goto BAIL; + } + + if((ec=JammaOp(JAMMAOP_SETCALLBACK,jamma_callback))<0) + goto BAIL; + + printf("jamma opened successfully\n"); + JammaOp(JAMMAOP_RCVASCII,1,asciibuf,sizeof(asciibuf)); + JammaOp(JAMMAOP_RCVASCII,0); + JammaOp(JAMMAOP_REQUESTVERSION); // get the version from the board + + JammaOp(JAMMAOP_WATCHDOGBONE_SETSENDMILLISECONDS,5000); + if(JammaOp(JAMMAOP_ISUSBWDPRESENT)) + printf("USB watchdog is present\n"); + for(;;) + { +readlp: + if((ii=ConKeyRead(buf,sizeof(buf)))>0) + { + // + // JAMMA EMU KEY MODE + // + + for(i=0;i=NUM_JAMMAIOMODE) + iomode=0; + JammaOp(JAMMAOP_SETIOMODE,iomode); + printf("-- iomode = %s\n",iomodenames[iomode]); + break; + case 'l': + watchlights=watchlights?0:1; + JammaOp(JAMMAOP_WATCHLIGHTSONOFF,watchlights); // rcvbin + printf("-- watchlights %d\n",watchlights); + break; + case 'm': + printf("-- coin meter1\n"); + JammaOp(JAMMAOP_COINMETERINC,0,1); + break; + case 'n': + printf("-- coin meter2\n"); + JammaOp(JAMMAOP_COINMETERINC,1,1); + break; + case 'p': + printf("-- enter number of tickets to dispense (0=clear counts/stop dispenser)\n"); + fgets(buf,sizeof(buf),stdin); + if(sscanf(buf,"%d",&box[0]) == 1) + { + if(box[0]==0) + { + printf("-- ticket 1 - clearing internal counter\n"); + JammaOp(JAMMAOP_TICKETCLEAR,0); + } + else + { + printf("-- ticket 1 - dispense %d\n",box[0]); + JammaOp(JAMMAOP_TICKETINC,0,box[0]); + } + } + else + printf(" error on input.\n"); + break; + case 'P': + ticketPolarity = ticketPolarity?0:1; + JammaOp(JAMMAOP_SETTICKETPOLARITY,ticketPolarity); + printf("-- ticket polarity %d\n",ticketPolarity); + break; + case 'r': + printf("-- reconfig sent\n"); + JammaOp(JAMMAOP_RECONFIG); + break; + case 's': + if(!fs) + { + if(fullScreen(640,480)>=0) + fs=1; + } + else + { + closeScreen(); + fs=0; + } + break; + + case 'S': + printf("-- requesting switch counts\n"); + JammaOp(JAMMAOP_REQUESTCOUNTS); + break; + case 't': + printf("-- requesting switch states\n"); + JammaOp(JAMMAOP_GETSWSTATES); + JammaOp(JAMMAOP_SWBITCALLBACKONOFF,1); // turn callback on + break; + case 'w': + printf("-- enter:vfront vback hfront hback\n"); + fgets(buf,sizeof(buf),stdin); + sscanf(buf,"%d %d %d %d",&box[0],&box[1],&box[2],&box[3]); + JammaOp(JAMMAOP_WHITEFLASH_VFB_HFB,box[0],box[1],box[2],box[3]); + break; + case 'v': + if(JammaOp(JAMMAOP_GETVERSTRING,buf,sizeof(buf))<0) + break; + printf("-- version string %s\n",buf); + + ec=JammaOp(JAMMAOP_GETSN,0); + if(ec) ec^=0xaaaaaaaa; + + printf("-- system sn %X\n",ec); + + break; + case 'V': + gverbose^=1; + JammaOp(JAMMAOP_GUNVERBOSEONOFF,gverbose); // toggle gun verbose mode + printf("-- gun verbose mode = %d\n",gverbose); + break; + + } // switch + } // default key mode + } // for + } // keys avail + + if(pause) + continue; + + JammaLoop(); + + if(!initWD) + { + i=JammaOp(JAMMAOP_GETDIPSWITCHES); + if(i&M_JAMMADIP_SPECIAL_VALID) + { + initWD=1; + if(i&M_JAMMADIP_SPECIAL_WATCHDOG) + printf("Watchdog has been reported\n"); + } + } + hw=JammaOp(JAMMAOP_GETHWVERNUM); + fw=JammaOp(JAMMAOP_GETFWVERNUM); + vers_usbwd=JammaOp(JAMMAOP_GETUSBWDVERNUM); + if((initVersHW != hw) || (initVersFW != fw) || (initVersUSBWD != vers_usbwd)) + { + initVersHW=hw; + initVersFW=fw; + initVersUSBWD = vers_usbwd; + bWarn=0; + if(JammaOp(JAMMAOP_GETVERSTRING,buf,sizeof(buf))>=0) + printf("-- version string %s\n",buf); + if((fw&M_JAMMAFWID) == JAMMAFWID_SBB) + { + printf("i/o card configured for Spongebob Bowling\n"); + iomode=JAMMAIOMODE_SBB; + if((fw&M_JAMMAFWVER) < JAMMAFWVER_SBB) + bWarn=1; + } + else if((fw&M_JAMMAFWID) == JAMMAFWID_BBH) + { + printf("i/o card configured for Big Buck Hunter\n"); + iomode=JAMMAIOMODE_BBH; + if((fw&M_JAMMAFWVER) < JAMMAFWVER_BBH) + bWarn=1; + } + else + { + printf("i/o card configuration unknown\n"); + iomode=0; + } + if(bWarn) + printf("Warning: Firmware is not latest version, please update.\n"); + JammaOp(JAMMAOP_SETIOMODE,iomode); + printf("setting iomode appropriately.\n"); + } + + if(dump && (JammaOp(JAMMAOP_GETINPREC,&jir)>=0)) + { + if(dump==1) + { + dump=2; + if(iomode==JAMMAIOMODE_SBB) + printf("\n st1 st2 cn1 cn2 bil srv tst vup vdn tlt dip swreg tbX tbY\n"); + else + printf("\n g11 g21 g12 g22 st1 st2 cn1 cn2 bil srv tst vup vdn tlt dip swreg \n"); + + JammaOp(JAMMAOP_GETTICK,&tdump); + JammaOp(JAMMAOP_GETSWSTATES); + } + + if(!(jir->dipstate&M_JAMMADIP_VALID)) + i=0xfff; // not valid + else + { + i=jir->dipstate; + i&=~(M_JAMMADIP_VALID|M_JAMMADIP_SPECIAL_VALID); + } + + i&=M_JAMMADIP_DIP; + + ii=jir->swstate & M_JAMMASWBIT; + +// printf(" %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03X %07d %07d\r", + if(iomode==JAMMAIOMODE_SBB) + { + printf(" %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03X %06X %09d %09d\r", + jir->swcount[JAMMASW_P1_START],jir->swcount[JAMMASW_P2_START], + jir->swcount[JAMMASW_COIN1],jir->swcount[JAMMASW_COIN2], + jir->swcount[JAMMASW_BILL],jir->swcount[JAMMASW_SERVICE], + jir->swcount[JAMMASW_TEST],jir->swcount[JAMMASW_VOLUP], + jir->swcount[JAMMASW_VOLDOWN],jir->swcount[JAMMASW_TILT],i,ii, + jir->swcount[JAMMASW_TBALL_X],jir->swcount[JAMMASW_TBALL_Y]); + } + else + { + printf(" %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03X %06X\r", + jir->swcount[JAMMASW_GUN1_TRIG1],jir->swcount[JAMMASW_GUN2_TRIG1], + jir->swcount[JAMMASW_GUN1_TRIG2],jir->swcount[JAMMASW_GUN2_TRIG2], + jir->swcount[JAMMASW_P1_START],jir->swcount[JAMMASW_P2_START], + jir->swcount[JAMMASW_COIN1],jir->swcount[JAMMASW_COIN2], + jir->swcount[JAMMASW_BILL],jir->swcount[JAMMASW_SERVICE], + jir->swcount[JAMMASW_TEST],jir->swcount[JAMMASW_VOLUP], + jir->swcount[JAMMASW_VOLDOWN],jir->swcount[JAMMASW_TILT],i,ii); + } + + JammaOp(JAMMAOP_GETTICK,&t); + if(t-tdump > 100) + { + // get switches every 16 msec + tdump=t; + JammaOp(JAMMAOP_GETSWSTATES); + } + } + JammaOp(JAMMAOP_GETTICK,&t); + printf("%s\r",t&0x100?".":":"); + } // for + + + ec=0; +BAIL: + conFinal(); + if(fs) + closeScreen(); + JammaFinal(); + return ec; +} // main() + + +// JFL 18 Jun 05 + +int jamma_callback(int op,...) + +{ + va_list args; + int pl,x,y,i; + unsigned char *s1; + unsigned char buf[32]; + JammaEmu *je; + unsigned char c; + + va_start(args,op); + + switch(op&M_JAMMACALLBACK) + { + case JAMMACALLBACK_GUNXY: + x=va_arg(args,int); + y=va_arg(args,int); + pl=(op>>S_JAMMACALLBACK_PL)&M_JAMMACALLBACK_PL; + printf("gun %d %d,%d\n",pl,x,y); + break; + case JAMMACALLBACK_RCVBIN: + s1=va_arg(args,char*); + x=va_arg(args,int); // len + if(x<=0) + break; + while(x-->0) + printf("%02X",*s1++); + printf("\n"); + break; + case JAMMACALLBACK_RCVASCII: + s1=va_arg(args,char*); + x=va_arg(args,int); // len + if(x<=0) + break; + printf("%s\n",s1); + break; + case JAMMACALLBACK_RCVCHARPKT: + je=&jammaemumem; + s1=va_arg(args,char*); + x=va_arg(args,int); // len + if(x<=0) + break; + printf("Jamma Emu (%c) rcv: ",je->mode); + while(x-->0) + { + c=*s1++; + printf("%c",c); + switch(c) + { + case 'A': + case 'B': + case 'C': + case 'D': + je->mode=c; + break; + case 'c': + printf("(reply 5%02X)",je->mode); + sprintf(buf,"05%02X\r",je->mode); // mode + i=strlen(buf);JammaOp(JAMMAOP_SENDBUF,buf,i); + break; + } // switch + } // while + printf("\n"); + break; + case JAMMACALLBACK_STATUS: + s1=va_arg(args,char*); + x=va_arg(args,int); // len + printf("status:"); + while(x-->0) + printf("%02X",*s1++); + printf("\n"); + break; + case JAMMACALLBACK_MESSAGE: + s1=va_arg(args,char*); + x=va_arg(args,int); // len + printf("message:"); + while(x-->0) + printf("%c",*s1++); + printf("\n"); + break; + case JAMMACALLBACK_USERBIT: + i=va_arg(args,int); + printf("userbit: %d\n",i); + break; + case JAMMACALLBACK_TICKET: + x=va_arg(args,int); + y=va_arg(args,int); + printf("dispensed %d ticket(s)\n",y); + if(x==JAMMATICKET_DONE) + printf(" done\n"); + else if (x==JAMMATICKET_CONTINUING) + printf(" continuing\n"); + else if (x==JAMMATICKET_ERROR) + printf(" error\n"); + break; + case JAMMACALLBACK_SWBIT: + x=va_arg(args,int) & M_JAMMASWBIT; + y=va_arg(args,int) & M_JAMMADIP_DIP; + printf("switches: %06X dips: %02X\n",x,y); + JammaOp(JAMMAOP_SWBITCALLBACKONOFF,0); // turn callback off + break; + + } // switch + va_end(args); + return 0; +} // jamma_callback() + +void* jamma_apphook_malloc(int size) +{ + return malloc(size); +} // jamma_apphook_malloc() + +void jamma_apphook_free(void *m) +{ + free(m); +} // jamma_apphook_free() + +void jamma_apphook_msg(char *fmt,...) +{ + va_list args; + + va_start(args,fmt); + vprintf(fmt,args); + va_end(args); +} // jamma_apphook_msg() + +#if SYS_BB +#include +#include +// +// jamma_apphook_sysmillisec +// return the current system millisecond timer +// +// in: +// out: +// global: +// +// GNP 13 Jan 06 +// +unsigned long long jamma_apphook_sysmillisec(void) +{ + unsigned long t; + struct timeb now; + ftime(&now); + + t = now.time * 1000 + now.millitm; + + return(t); +//DONE("jamma_apphook_sysmillisec") +} // jamma_apphook_sysmillisec +#endif //SYS_BB + +// EOF diff --git a/libraries/pmrt/jamma/jammatest.dsp b/libraries/pmrt/jamma/jammatest.dsp new file mode 100755 index 0000000..54c3e69 --- /dev/null +++ b/libraries/pmrt/jamma/jammatest.dsp @@ -0,0 +1,93 @@ +# Microsoft Developer Studio Project File - Name="jammatest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=jammatest - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "jammatest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "jammatest.mak" CFG="jammatest - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "jammatest - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "jammatest - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/jamma", CADAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "jammatest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "SYS_PC" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "jammatest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_CONSOLE" /D "SYS_PC" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib jammalib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"/g3/lib" + +!ENDIF + +# Begin Target + +# Name "jammatest - Win32 Release" +# Name "jammatest - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\jammatest.c +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/jamma/jammatest.o b/libraries/pmrt/jamma/jammatest.o new file mode 100644 index 0000000..9da49bd Binary files /dev/null and b/libraries/pmrt/jamma/jammatest.o differ diff --git a/libraries/pmrt/jamma/libjamma.a b/libraries/pmrt/jamma/libjamma.a new file mode 100644 index 0000000..e8c06fc Binary files /dev/null and b/libraries/pmrt/jamma/libjamma.a differ diff --git a/libraries/pmrt/jamma/makedeplib b/libraries/pmrt/jamma/makedeplib new file mode 100644 index 0000000..fd1da61 --- /dev/null +++ b/libraries/pmrt/jamma/makedeplib @@ -0,0 +1,43 @@ +jamma.o: jamma.c jamma.h jammapriv.h /usr/include/termios.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/bits/termios.h \ + /usr/include/sys/ttydefaults.h /usr/include/stdio.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h +jamma_lin.o: jamma_lin.c /usr/include/termios.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h \ + /usr/include/stdio.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/signal.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + /usr/include/sys/timeb.h /usr/include/string.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h jamma.h jammapriv.h diff --git a/libraries/pmrt/jamma/makedeptest b/libraries/pmrt/jamma/makedeptest new file mode 100644 index 0000000..ee05c1a --- /dev/null +++ b/libraries/pmrt/jamma/makedeptest @@ -0,0 +1,23 @@ +jammatest.o: jammatest.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h jamma.h \ + /usr/include/termios.h /usr/include/bits/termios.h \ + /usr/include/sys/ttydefaults.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/sys/ioctl.h \ + /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h \ + /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h \ + /usr/include/fcntl.h /usr/include/bits/fcntl.h /usr/include/string.h \ + /usr/include/sys/timeb.h diff --git a/libraries/pmrt/jamma/makefile b/libraries/pmrt/jamma/makefile new file mode 100755 index 0000000..8abf5be --- /dev/null +++ b/libraries/pmrt/jamma/makefile @@ -0,0 +1,50 @@ +# make driver +# make install (as root) +# +.CTESTFILES = jammatest.c +.CLIBFILES = jamma.c jamma_lin.c + +.OTESTFILES = $(.CTESTFILES:.c=.o) +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETTEST = jammatest +TARGETLIB = libjamma.a + +LIBTEST=libjamma.a -lrt + +LIBS = /g3/lib/libusb.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map + +all: $(TARGETLIB) $(TARGETTEST) + +$(TARGETTEST) : $(.OTESTFILES) $(LIBTEST) $(DEPENDTESTFILE) $(LIBS) makefile + $(CC) $(LINKFLAGS) -o $(TARGETTEST) $(.OTESTFILES) $(LIBTEST) $(LIBS) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) + cp $(TARGETLIB) /g3/lib + cp jamma.h /g3/include + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDTESTFILE): + $(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDTESTFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/jamma/mssccprj.scc b/libraries/pmrt/jamma/mssccprj.scc new file mode 100755 index 0000000..66d86f0 --- /dev/null +++ b/libraries/pmrt/jamma/mssccprj.scc @@ -0,0 +1,9 @@ +SCC = This is a Source Code Control file + +[jammalib.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/jamma", CADAAAAA + +[jammatest.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/jamma", CADAAAAA diff --git a/libraries/pmrt/jamma/vssver.scc b/libraries/pmrt/jamma/vssver.scc new file mode 100755 index 0000000..31ec875 Binary files /dev/null and b/libraries/pmrt/jamma/vssver.scc differ diff --git a/libraries/pmrt/jpsnd/.gdbinit b/libraries/pmrt/jpsnd/.gdbinit new file mode 100755 index 0000000..f054af4 --- /dev/null +++ b/libraries/pmrt/jpsnd/.gdbinit @@ -0,0 +1,5 @@ +set output-radix 16 +handle SIG32 nostop noprint +file jpst +b jps_bank_load +r diff --git a/libraries/pmrt/jpsnd/Debug/jps.obj b/libraries/pmrt/jpsnd/Debug/jps.obj new file mode 100755 index 0000000..e635dd8 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jps.sbr b/libraries/pmrt/jpsnd/Debug/jps.sbr new file mode 100755 index 0000000..b2e3e09 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_marsig.obj b/libraries/pmrt/jpsnd/Debug/jps_marsig.obj new file mode 100755 index 0000000..aeda918 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_marsig.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_marsig.sbr b/libraries/pmrt/jpsnd/Debug/jps_marsig.sbr new file mode 100755 index 0000000..f5e7dc1 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_marsig.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_parse.obj b/libraries/pmrt/jpsnd/Debug/jps_parse.obj new file mode 100755 index 0000000..adc9016 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_parse.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_parse.sbr b/libraries/pmrt/jpsnd/Debug/jps_parse.sbr new file mode 100755 index 0000000..68b9bdb Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_parse.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_pfuncs.obj b/libraries/pmrt/jpsnd/Debug/jps_pfuncs.obj new file mode 100755 index 0000000..8f4498d Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_pfuncs.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_pfuncs.sbr b/libraries/pmrt/jpsnd/Debug/jps_pfuncs.sbr new file mode 100755 index 0000000..01daebd Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_pfuncs.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_player.obj b/libraries/pmrt/jpsnd/Debug/jps_player.obj new file mode 100755 index 0000000..9a40030 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_player.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_player.sbr b/libraries/pmrt/jpsnd/Debug/jps_player.sbr new file mode 100755 index 0000000..128d774 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_player.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_snd.obj b/libraries/pmrt/jpsnd/Debug/jps_snd.obj new file mode 100755 index 0000000..08c9d64 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_snd.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jps_snd.sbr b/libraries/pmrt/jpsnd/Debug/jps_snd.sbr new file mode 100755 index 0000000..ea15a82 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jps_snd.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jpsdrvr_5500.obj b/libraries/pmrt/jpsnd/Debug/jpsdrvr_5500.obj new file mode 100755 index 0000000..a5c550f Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpsdrvr_5500.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jpsdrvr_5500.sbr b/libraries/pmrt/jpsnd/Debug/jpsdrvr_5500.sbr new file mode 100755 index 0000000..e65e00f Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpsdrvr_5500.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jpsdrvr_dx.obj b/libraries/pmrt/jpsnd/Debug/jpsdrvr_dx.obj new file mode 100755 index 0000000..41b8159 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpsdrvr_dx.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jpsdrvr_dx.sbr b/libraries/pmrt/jpsnd/Debug/jpsdrvr_dx.sbr new file mode 100755 index 0000000..6142456 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpsdrvr_dx.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jpsdrvr_lin.obj b/libraries/pmrt/jpsnd/Debug/jpsdrvr_lin.obj new file mode 100755 index 0000000..7acc0a2 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpsdrvr_lin.obj differ diff --git a/libraries/pmrt/jpsnd/Debug/jpsdrvr_lin.sbr b/libraries/pmrt/jpsnd/Debug/jpsdrvr_lin.sbr new file mode 100755 index 0000000..edd66ca Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpsdrvr_lin.sbr differ diff --git a/libraries/pmrt/jpsnd/Debug/jpslib.lib b/libraries/pmrt/jpsnd/Debug/jpslib.lib new file mode 100755 index 0000000..882a58e Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/jpslib.lib differ diff --git a/libraries/pmrt/jpsnd/Debug/vc60.idb b/libraries/pmrt/jpsnd/Debug/vc60.idb new file mode 100755 index 0000000..7cf6119 Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/vc60.idb differ diff --git a/libraries/pmrt/jpsnd/Debug/vc60.pdb b/libraries/pmrt/jpsnd/Debug/vc60.pdb new file mode 100755 index 0000000..9d3d99b Binary files /dev/null and b/libraries/pmrt/jpsnd/Debug/vc60.pdb differ diff --git a/libraries/pmrt/jpsnd/ac97.h b/libraries/pmrt/jpsnd/ac97.h new file mode 100755 index 0000000..fb89079 --- /dev/null +++ b/libraries/pmrt/jpsnd/ac97.h @@ -0,0 +1,39 @@ +/************************************** +** +** ac97.h +** +** Register values for AC '97 Codecs +** +** Andrew Eloff +** Raw Thrills +** +**************************************/ + +#define AC97_RESET 0x00 +#define AC97_MASTER_VOL 0x02 +#define AC97_ALTERNATE_VOL 0x04 +#define AC97_MONO_VOL 0x06 +#define AC97_PC_BEEP_VOL 0x0A +#define AC97_PHONE_VOL 0x0C +#define AC97_MIC_VOL 0x0E +#define AC97_LINE_IN_VOL 0x10 +#define AC97_CD_VOL 0x12 +#define AC97_VIDEO_VOL 0x14 +#define AC97_AUX_VOL 0x16 +#define AC97_PCM_OUT_VOL 0x18 +#define AC97_RECORD_SELECT 0x1A +#define AC97_RECORD_GAIN 0x1C +#define AC97_GENERAL_PURPOSE 0x20 +#define AC97_3D_CONTROL 0x22 +#define AC97_POWERDOWN_CTRL 0x26 +#define AC97_EXTENDED_ID 0x28 +#define AC97_PCM_FRONT_RATE 0x2C +#define AC97_PCM_LR_RATE 0x32 + +#define CIRRUS_AC_MODE_CTRL 0x5E +#define CIRRUS_MISC_CTRL 0x60 +#define CIRRUS_SPDIF_CTRL 0x68 +#define CIRRUS_VENDOR_ID1 0x7C +#define CIRRUS_VENDOR_ID2 0x7E + + diff --git a/libraries/pmrt/jpsnd/dsp_info.c b/libraries/pmrt/jpsnd/dsp_info.c new file mode 100755 index 0000000..a23d930 --- /dev/null +++ b/libraries/pmrt/jpsnd/dsp_info.c @@ -0,0 +1,195 @@ +/* + * dsp_info.c + * Example program to display sound device capabilities + */ + +#include +#include +#include +#include +#include +#include +#include + +/* utility function for displaying boolean status */ +static char *yes_no(int condition) +{ + if (condition) return "yes"; else return "no"; +} + +/* + * Set sound device parameters to given values. Return -1 if + * values not valid. Sampling rate is returned. + */ +static int set_dsp_params(int fd, int channels, int bits, int *rate) { + int status, val = channels; + + status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &val); + if (status == -1) + perror("SOUND_PCM_WRITE_CHANNELS ioctl failed"); + if (val != channels) /* not valid, so return */ + return -1; + val = bits; + status = ioctl(fd, SOUND_PCM_WRITE_BITS, &val); + if (status == -1) + perror("SOUND_PCM_WRITE_BITS ioctl failed"); + if (val != bits) + return -1; + status = ioctl(fd, SOUND_PCM_WRITE_RATE, rate); + if (status == -1) + perror("SOUND_PCM_WRITE_RATE ioctl failed"); + return 0; +} + +int main(int argc, char *argv[]) +{ + int rate; + int channels; /* number of channels */ + int bits; /* sample size */ + int blocksize; /* block size */ + int formats; /* data formats */ + int caps; /* capabilities */ + int deffmt; /* default format */ + int min_rate, max_rate; /* min and max sampling rates */ + char *device; /* name of device to report on */ + int fd; /* file descriptor for device */ + int status; /* return value from ioctl */ + + /* get device name from command line or use default */ + if (argc == 2) + device = argv[1]; + else + device = "/dev/dsp"; + + /* try to open device */ + fd = open(device, O_RDWR); + if (fd == -1) { + fprintf(stderr, "%s: unable to open `%s', ", argv[0], device); + perror(""); + return 1; + } + + status = ioctl(fd, SOUND_PCM_READ_RATE, &rate); + if (status == -1) + perror("SOUND_PCM_READ_RATE ioctl failed"); + status = ioctl(fd, SOUND_PCM_READ_CHANNELS, &channels); + if (status == -1) + perror("SOUND_PCM_READ_CHANNELS ioctl failed"); + status = ioctl(fd, SOUND_PCM_READ_BITS, &bits); + if (status == -1) + perror("SOUND_PCM_READ_BITS ioctl failed"); + status = ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blocksize); + if (status == -1) + perror("SNFCTL_DSP_GETBLKSIZE ioctl failed"); + + printf( + "Information on %s:\n\n" + "Defaults:\n" + " sampling rate: %d Hz\n" + " channels: %d\n" + " sample size: %d bits\n" + " block size: %d bytes\n", + device, rate, channels, bits, blocksize + ); + +/* this requires a more recent version of the sound driver */ +#if SOUND_VERSION >= 301 + printf("\nSupported Formats:\n"); + deffmt = AFMT_QUERY; + status = ioctl(fd, SOUND_PCM_SETFMT, &deffmt); + if (status == -1) + perror("SOUND_PCM_SETFMT ioctl failed"); + status = ioctl(fd, SOUND_PCM_GETFMTS, &formats); + if (status == -1) + perror("SOUND_PCM_GETFMTS ioctl failed"); + if (formats & AFMT_MU_LAW) { + printf(" mu-law"); + (deffmt == AFMT_MU_LAW) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_A_LAW) { + printf(" A-law"); + (deffmt == AFMT_A_LAW) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_IMA_ADPCM) { + printf(" IMA ADPCM"); + (deffmt == AFMT_IMA_ADPCM) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_U8) { + printf(" unsigned 8-bit"); + (deffmt == AFMT_U8) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_S16_LE) { + printf(" signed 16-bit little-endian"); + (deffmt == AFMT_S16_LE) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_S16_BE) { + printf(" signed 16-bit big-endian"); + (deffmt == AFMT_S16_BE) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_S8) { + printf(" signed 8-bit"); + (deffmt == AFMT_S8) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_U16_LE) { + printf(" unsigned 16-bit little-endian"); + (deffmt == AFMT_U16_LE) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_U16_BE) { + printf(" unsigned 16-bit big-endian"); + (deffmt == AFMT_U16_BE) ? printf(" (default)\n") : printf("\n"); + } + if (formats & AFMT_MPEG) { + printf(" MPEG 2"); + (deffmt == AFMT_MPEG) ? printf(" (default)\n") : printf("\n"); + } + + printf("\nCapabilities:\n"); + status = ioctl(fd, SNDCTL_DSP_GETCAPS, &caps); + if (status == -1) + perror("SNDCTL_DSP_GETCAPS ioctl failed"); + printf( + " revision: %d\n" + " full duplex: %s\n" + " real-time: %s\n" + " batch: %s\n" + " coprocessor: %s\n" + " trigger: %s\n" + " mmap: %s\n", + caps & DSP_CAP_REVISION, + yes_no(caps & DSP_CAP_DUPLEX), + yes_no(caps & DSP_CAP_REALTIME), + yes_no(caps & DSP_CAP_BATCH), + yes_no(caps & DSP_CAP_COPROC), + yes_no(caps & DSP_CAP_TRIGGER), + yes_no(caps & DSP_CAP_MMAP)); + +#endif /* SOUND_VERSION >= 301 */ + + /* display table heading */ + printf( + "\nModes and Limits:\n" + "Device Sample Minimum Maximum\n" + "Channels Size Rate Rate\n" + "-------- -------- -------- --------\n" + ); + + /* do mono and stereo */ + for (channels = 1; channels <= 2 ; channels++) { + /* do 8 and 16 bits */ + for (bits = 8; bits <= 16 ; bits += 8) { + /* To find the minimum and maximum sampling rates we rely on + the fact that the kernel sound driver will round them to + the closest legal value. */ + min_rate = 1; + if (set_dsp_params(fd, channels, bits, &min_rate) == -1) +continue; + max_rate = 100000; + if (set_dsp_params(fd, channels, bits, &max_rate) == -1) +continue; + /* display the results */ + printf("%8d %8d %8d %8d\n", channels, bits, min_rate, max_rate); + } + } + close(fd); + return 0; +} diff --git a/libraries/pmrt/jpsnd/int_5500.h b/libraries/pmrt/jpsnd/int_5500.h new file mode 100755 index 0000000..fc37c7f --- /dev/null +++ b/libraries/pmrt/jpsnd/int_5500.h @@ -0,0 +1,15 @@ +#ifndef __INT_H +#define __INT_H +#else + +extern unsigned long get_sr_reg( void ); +extern void set_sr_reg( unsigned long foo ); +extern unsigned long get_cause_reg( void ); +extern unsigned long get_count_reg( void ); +extern unsigned long get_compare_reg( void ); +extern void set_compare_reg( unsigned long foo ); +extern unsigned long get_config_reg( void ); +extern void set_config_reg( unsigned long foo ); + +#endif + diff --git a/libraries/pmrt/jpsnd/jcomm.h b/libraries/pmrt/jpsnd/jcomm.h new file mode 100755 index 0000000..083210f --- /dev/null +++ b/libraries/pmrt/jpsnd/jcomm.h @@ -0,0 +1 @@ +int jcomm(int argc, char ** argv); diff --git a/libraries/pmrt/jpsnd/jcomm_keymap.c b/libraries/pmrt/jpsnd/jcomm_keymap.c new file mode 100755 index 0000000..4efcc26 --- /dev/null +++ b/libraries/pmrt/jpsnd/jcomm_keymap.c @@ -0,0 +1,114 @@ +#include +#include +#include "jps.h" +#include +#include "jcomm_keymap.h" + +#define MAX_NUM_KEYMAPS 255 + +typedef struct keymap_s { + char key; + int scall; + int vol; + int trackmask; + int priority; +}keymap; + +keymap keymaps[MAX_NUM_KEYMAPS]; +void keymap_load() { +/************************************** +** +**************************************/ + FILE *fp = NULL; + int ii=0; + memset(keymaps, 0x00, sizeof(keymaps)); + fp = fopen ("keymap.txt","r"); + if (fp == NULL) { + printf("couldn't open keymap file!!\n"); + return; + } + while (!feof(fp)) { + fscanf(fp,"%c %i %i\n", + &keymaps[ii].key, + &keymaps[ii].scall, + &keymaps[ii].vol); + ii++; + } + fclose(fp); +} + +void keymap_save() { +/************************************** +** +**************************************/ + FILE *fp = NULL; + int ii=0; + fp = fopen ("keymap.txt","w"); + if (fp == NULL) { + printf("couldn't open keymap file!!\n"); + return; + } + while (keymaps[ii].key != 0) { + fprintf(fp,"%c %i %i %i %i\n", + keymaps[ii].key, + keymaps[ii].scall, + keymaps[ii].vol); + ii++; + } + fclose(fp); +} + +void keymap_add(char cc, int *args) { +/************************************** +** +**************************************/ + // does the keymap exist? if so, replace + int ii=0; + while (keymaps[ii].key != 0) { + if (keymaps[ii].key == cc) { + // keymap exists, replace + goto addexit; + } + ii++; + } +addexit: + keymaps[ii].key = cc; + keymaps[ii].scall = args[0]; + keymaps[ii].vol = args[1]; +} + +int keymap_parse(char cc, int *args) { +/************************************** +** given a key, return the arguments +**************************************/ + // does the keymap exist? if so, replace + int ii=0; + while (keymaps[ii].key != 0) { + if (keymaps[ii].key == cc) { + // keymap exists, replace + args[0] = keymaps[ii].scall; + args[1] = keymaps[ii].vol; + return TRUE; + } + ii++; + } + return FALSE; +} + +void keymap_program() { +/************************************** +** +**************************************/ + char cc; + int args[4]; + printf("\nKEYMAP PROGRAM\n"); + cprintf("enter key-> "); + cc = getch(); + cprintf("%c\n",cc); + cprintf("\nscall: "); + scanf("%i",&args[0]); + cprintf("\nvolume: "); + scanf("%i",&args[1]); + cprintf("\n"); + keymap_add(cc,args); +} \ No newline at end of file diff --git a/libraries/pmrt/jpsnd/jcomm_keymap.h b/libraries/pmrt/jpsnd/jcomm_keymap.h new file mode 100755 index 0000000..e19975c --- /dev/null +++ b/libraries/pmrt/jpsnd/jcomm_keymap.h @@ -0,0 +1,5 @@ +void keymap_load(); +void keymap_save(); +void keymap_add(char cc, int *args); +int keymap_parse(char cc, int *args); +void keymap_program(); diff --git a/libraries/pmrt/jpsnd/jcomm_main.c b/libraries/pmrt/jpsnd/jcomm_main.c new file mode 100755 index 0000000..7c76cf6 --- /dev/null +++ b/libraries/pmrt/jpsnd/jcomm_main.c @@ -0,0 +1,299 @@ +/************************************** +** jcomm_main.c +** +** super-basic sound call previewer +** +** TODO: +** - backspace support (ESC too?) +** +**************************************/ + +// dsound.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib + +#include +#include + +#if _WIN32 +#include +#include +#else +#define HANDLE void* +#endif + +#include "jps.h" +#include "jps_parse.h" +#include "jcomm_keymap.h" + +int jcomm(int argc, char ** argv); + +//#define bank_filename "sounds\\smallpls.txt" +char bank_filename[255]= ""; + +HANDLE stdhandle = NULL; + +#define HELP_STRING "\n\ +*******************************************************************************\n\ + * \n\ + h - display this help * m - send a marker\n\ + l - load bank * q - quit\n\ + r - reload existing bank * {} \n\ + s - stop all sounds and playlists * - play soundcall at volume \n\ + b - show track busy mask * level \n\ + - repeat last sound * \n\ + . - increment and play playlist * \n\ + , - decrement and play playlist * k - enter keymap mode (ESC exits)\n\ + p - program a key * \n\ +*******************************************************************************\n\n\ +" + +void GoToXY(int x, int y) { +/************************************** +** +**************************************/ +COORD c; +c.X = x; +c.Y = y; +SetConsoleCursorPosition(stdhandle, c); +} + +void show_help() { +/************************************** +** +**************************************/ + uint32 MaVer,MiVer,SMiVer; + + jps_version(&MaVer,&MiVer,&SMiVer); + printf("\njcomm - jps sound system player Version %d.%d.%d\n",MaVer,MiVer,SMiVer); + printf(HELP_STRING); +} + +#define MAX_NUM_ARGS 4 + +void draw_busy_mask() { +/************************************** +** +**************************************/ + int dd; +#if _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + SetConsoleTextAttribute(stdhandle,FOREGROUND_RED|FOREGROUND_GREEN); + GetConsoleScreenBufferInfo(stdhandle,&csbi); + GoToXY(61,csbi.srWindow.Top); +#endif + for (dd = JPS_NUM_CHANNELS-1 ;dd>=0; dd--) { + if (jps_channel_data[dd].owner) + cprintf(" %i",dd); + else cprintf(" -"); + } + + cprintf(" "); +#if _WIN32 + SetConsoleTextAttribute(stdhandle,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); + GoToXY(csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y); +#endif +} + +#if _WIN32 +int main(int argc, char **argv) { + jcomm(argc, argv); +} +#endif +int jcomm(int argc, char ** argv) { +/************************************** +** +**************************************/ + char cc; + int keymap_mode = FALSE; + int done = FALSE; + int curr_scall = 0; + int draw_prompt = TRUE; + int play_sound = FALSE; + int args[MAX_NUM_ARGS]; + int curr_arg = -1; + jps_bank * bank = NULL; + +#if _WIN32 + stdhandle = GetStdHandle(STD_OUTPUT_HANDLE); +#endif + jps_init(); + keymap_load(); + if (argc > 1) { + strcpy(bank_filename, argv[1]); + bank = jps_bank_load(bank_filename); + } + show_help(); + while (!done) { + if (draw_prompt) { + + if (strlen(bank_filename) == 0) { + cprintf(""); + } else { + cprintf("%s",bank_filename); + } + if (keymap_mode) { + cprintf(":keymap mode >",curr_scall); + } else { + cprintf(":%i >",curr_scall); + } + draw_prompt = FALSE; + } + while (!kbhit()) { + uint16 signal; + if (jps_signal_get(&signal) == JPS_OK) { + cprintf("\n\rSIGNAL %i\n\r",signal); + } + draw_busy_mask(); + Sleep(1); + } + cc = getch(); + if (keymap_mode) { + if (cc == 27) { + cprintf("\n\r"); + keymap_mode = FALSE; + draw_prompt = TRUE; + } else if (cc == 32) { + jps_stopall_players(); + } else { + if (keymap_parse(cc,args)) { + cprintf(" '%c' -> %03i %03i \n",cc,args[0],args[1]); + play_sound = TRUE; + draw_prompt = TRUE; + curr_arg = 2; + } + } + } else { + switch(cc) { + case 'r': // reload bank + jps_bank_unload(bank_filename); + if (strlen(bank_filename) == 0) { + printf("must specify bank name first!\n"); + draw_prompt = TRUE; + break; + } + bank = jps_bank_load (bank_filename); + draw_prompt = TRUE; + break; + case 'h': + show_help(); + draw_prompt = TRUE; + break; + case 'm': + cprintf("marker\n\r"); + jps_marker_add(15); + draw_prompt = TRUE; + break; + case 'q': + done = TRUE; + break; + case 's': + printf("stop all\n\r"); + jps_stopall_players(); + draw_prompt = TRUE; + break; + case '1':case '2': case '3': case '4': case '5': + case '6':case '7': case '8': case '9': case '0': + switch (curr_arg) { + case -1: // nothing written yet + curr_arg = 0; + args[curr_arg] = 0; + // NOTE NO break; PASS THRU + case 0: case 1: + args[curr_arg] = cc-'0'+args[curr_arg]*10; + cprintf("%c",cc); + break; + case 2: // track mask - do it in binary! + if (cc == '0' || cc == '1') { + args[curr_arg] = cc-'0'+args[curr_arg]*2; + cprintf("%c",cc); + } + break; + + } + break; + case 8: // backspace + cprintf("\b \b"); + break; + case ' ': + cprintf(" "); + if (curr_arg != -1) { + curr_arg++; + args[curr_arg] = 0; + } + break; + case 13: // enter + if (curr_arg == -1) { + curr_arg = 0; + args[0] = curr_scall; + cprintf("%i\n\r",args[0]); + } else { + cprintf("\n\r"); + } + play_sound = TRUE; + break; + case '+': + case '.': + curr_arg = 0; + args[0] = curr_scall+1; + cprintf("%i\n\r",args[0]); + play_sound = TRUE; + break; + case '-': + case ',': + if (curr_scall >0) { + args[0] = curr_scall-1; + } + cprintf("%i\n\r",args[0]); + play_sound = TRUE; + break; + case 'b': + { + int32 dd; + cprintf("\n\r"); + for (dd = JPS_NUM_CHANNELS-1 ;dd>=0; dd--) { + if (jps_channel_data[dd].owner) + cprintf(" %i",dd); + else cprintf(" -"); + } + } + draw_prompt = TRUE; + break; + case 'l': + cprintf("\nbank filename:"); + scanf("%s",bank_filename); + bank = jps_bank_load(bank_filename); + draw_prompt = TRUE; + break; + case 'k': + cprintf("\n\r\n\r*** PRESS ESC TO EXIT KEYMAP MODE, SPACE TO STOP CALLS! ***\n\r"); + keymap_mode = TRUE; + draw_prompt = TRUE; + break; + case 'p': + keymap_program(); +// keymap_save(); + draw_prompt = TRUE; + break; + default: + // printf("%i\n",cc); + // cprintf("%c",cc); + break; + } + } + if (play_sound) { + if (curr_arg < 2) + args[2] = 0xFFFFFFFF; + if (curr_arg < 1) + args[1] = 0xFF; + jps_bank_play_vol(bank_filename, args[0], (uint8)args[1]); + draw_busy_mask(); + play_sound = FALSE; + curr_scall = args[0]; + curr_arg = -1; + draw_prompt = TRUE; + } + } + keymap_save(); + jps_bank_free(bank); + jps_shutdown(); + exit(0); +} \ No newline at end of file diff --git a/libraries/pmrt/jpsnd/jpdrvr_snd.h b/libraries/pmrt/jpsnd/jpdrvr_snd.h new file mode 100755 index 0000000..cc773b3 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpdrvr_snd.h @@ -0,0 +1,6 @@ +#ifndef __JPSDRVR_SND_H +#define __JPSDRVR_SND_H 1 + +int free_buffers(jps_sndbuf * buffer_to_kill); + +#endif \ No newline at end of file diff --git a/libraries/pmrt/jpsnd/jps Sound System.doc b/libraries/pmrt/jpsnd/jps Sound System.doc new file mode 100755 index 0000000..75208ac Binary files /dev/null and b/libraries/pmrt/jpsnd/jps Sound System.doc differ diff --git a/libraries/pmrt/jpsnd/jps.c b/libraries/pmrt/jpsnd/jps.c new file mode 100755 index 0000000..00b7708 --- /dev/null +++ b/libraries/pmrt/jpsnd/jps.c @@ -0,0 +1,127 @@ +/************************************************ +** jps.c +** +** JFL 26 Apr 05 + +TODO: +- looping should be a function of the instance + of playing rather than the sndbuf +- make sure that if a soundcall was bounced + the bounced soundcall's owner is no longer + manipulating the channel!!! +- make sure event_handles_owner is cleaned up + by sound_stop!!! +- sometimes channel_busy() doesn't report correctly + for looped scalls! +- SYNTAX ERROR CHECKING REPORTING +- JCOMM - BACKSPACE - FINISH +? SETPRI OPCODE - allow composer to reduce priority +? Immediately unduck any playlists that are canceled while ducking +- seamless transitions for DX(requires all-streaming) +- PLAYLIST REQUIRES EOL AT END OF PLAYLIST FILE +- 12kHz? +- SUPPORT 8bit per channel (affects waitfor() code!!!) +- Make sound_play, sound_stop, transition_thread shared across DX/5500 +- Remove unnecessary memalign()'s - they screw up deallocations! + +TODO CRITICAL: +- JPS/5500: stream end needs to stop stream! +- tighten transitions - use transition info! + +DONE: +x JPS/5500: Fix memalign() to return pointer to raw buffer loc for subsequent free() op's +x JPS/5500: sound_play() for streams doesn't work right +x JPS/5500: update_all doesn't work right, verify clock +x remove #channel_buffers# variable +x HANDLE MONO +x JPS/5500: can't handle [+x.xx] offsets! +x JPS: (NTF) sound_play MUST take a volume argument - easier to debug + less globals +x jps/5500: crackling sound, but multi-channels play +x JPS: convert parse functions to return OK or ERROR, if error, have them spew + the error data. +x (JPS/5500) 24kHz sample rate support: will take 4 days from start time (Andy Dyer) +x JPS Streaming!!! +x jps/5500: some soundcalls (15) don't play +x jps/5500: PLAYGROUP doesn't work +x Support BWF format +x FLUSH CONSTANT TABLE AFTER BANKLOAD +x test multi-track sound call allocation +x when loading file, change dir too +x JPS_NOTACOMMAND should be part of the JPS_OPCODE_ enum! +x JCOMM - FIX KEYCUT STUFF (no need for vol, pri, trackmask) +x support for regexp, variables in playlist +x verify shutdown unloading +x be sure to clean up transition events!!! +x still leaking secondary buffers - no release of notification = no release of buffers +x verify hashing works!!! +x directory support needs to be better +x channel_busy() needs a critical section -CRASHES +x channel busy status (in upper-right corner) too hard to read +x Add priority / track mask control to playlist +x Add randomization functionality to playlist +x Fix bug: Duck on channel with no sound call playing crashes +x Sound play by name (rather than number) +x comma with no whitespace works +x support randomization history + +************************************************/ +//#include "ussio.h" // george says this should work... +#include +#include + +#if SYS_PC +#include +#endif // SYS_PC + +#include "jps.h" +#include "jps_marsig.h" + +jps_channel jps_channel_data[JPS_NUM_CHANNELS]; +jps_player jps_players[JPS_NUM_PLAYERS]; +jps_bank *jps_banks[JPS_MAX_BANKS]; + +CRITICAL_SECTION jps_player_update_lock; +CRITICAL_SECTION channel_startstop; + +int jps_init() +{ +/************************************** +** initialize important structs +**************************************/ + memset(jps_players,0, sizeof(jps_players)); + memset(jps_channel_data,0x00,sizeof(jps_channel_data)); + + InitializeCriticalSection(&jps_player_update_lock); + InitializeCriticalSection(&channel_startstop); + + memset(jps_banks, 0, sizeof(jps_banks)); + // init the sound system... + if (jpsdrvr_init() != JPS_OK) { + msg("jps_init(): ERROR! Could not init sound hardware!\n"); + return JPS_ERROR; + } + + jps_marsig_init(); + jps_master_volume(255); + return JPS_OK; +} + +int jps_shutdown() +{ + jpsdrvr_shutdown(); + + return 0; +} + +// +// jps_version +// return the version number of the current sound library +// +void jps_version(uint32 *pMajor, uint32 *pMinor, uint32 *pSubMinor) +{ + *pMajor = MAJOR_VERSION; + *pMinor = MINOR_VERSION; + *pSubMinor = SUBMINOR_VERSION; +} + +// EOF diff --git a/libraries/pmrt/jpsnd/jps.dsw b/libraries/pmrt/jpsnd/jps.dsw new file mode 100755 index 0000000..96742a0 --- /dev/null +++ b/libraries/pmrt/jpsnd/jps.dsw @@ -0,0 +1,48 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "jpslib"=.\jpslib.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/jpsnd", POCAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpstst"=.\jpstst\jpstst.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name jpslib + End Project Dependency +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/jpsnd/jps.h b/libraries/pmrt/jpsnd/jps.h new file mode 100755 index 0000000..b56b067 --- /dev/null +++ b/libraries/pmrt/jpsnd/jps.h @@ -0,0 +1,120 @@ +#ifndef JPS_H_ +#define JPS_H_ + +#ifdef _WIN32 +#define SYS_PC 1 +#endif // def _WIN32 + +#if !(SYS_PC|SYS_BB|SYS_5500) +#error -- define SYS_ type! +#endif + +// defs.h +#define TRUE 1 +#define FALSE 0 +#define CODELDR_OK 0 +#define CODELDR_ERROR -1 +#define SOCKET_OK 0 + +#ifndef _JPS_TYPEDEFS +#define _JPS_TYPEDEFS +typedef unsigned int uint32; +typedef int int32; +typedef unsigned short uint16; +typedef short int16; +typedef unsigned char uint8; +typedef char int8; +#if SYS_PC +typedef __int64 int64; +typedef unsigned __int64 uint64; +#else // !SYS_PC +typedef long long int64; +typedef unsigned long long uint64; +#endif // !SYS_PC + +#if SYS_PC +#pragma warning(disable:4244) // conversion from 'double ' to 'float ' +#endif // SYS_PC + +// for compatibility with G3 +#define uns8 uint8 +#define uns16 uint16 +#define uns32 uint32 +#define uns64 uint64 + +#define COUNT(x) (sizeof(x)/sizeof((x)[0])) +#endif // !_JPS_TYPEDEFS + +// +// version information +// + +#define MAJOR_VERSION 1 +//#define MINOR_VERSION 5 -- in jpsdrvr.h +//#define SUBMINOR_VERSION 0 -- in jpsdrvr.h + +#if SYS_PC +#include +#include +#include +#include +#define BP() __asm{int 3} +#elif SYS_BB +#define BP() __asm__ ("int $3") +#else // !SYS_PC || !SYS_BB +#define BP() +#endif // !SYS_PC + +#include + +#define msg jps_apphook_msg + +#define JPS_FILE FILE +#define jps_fopen fopen +#define jps_fclose fclose +#define jps_feof feof +#define jps_fseek fseek +#define jps_fscanf fscanf +#define jps_fread fread +#define jps_fwrite fwrite +#define jps_fprintf fprintf +#define jps_ftell ftell +#define jps_fgets fgets +#define jps_clock_sec jps_apphook_clock_sec + +extern void* jps_apphook_malloc(unsigned long size); +extern void jps_apphook_free(void*); +extern void jps_apphook_memadd(void *p); +extern void jps_apphook_memdel(void *p); +extern unsigned long jps_apphook_clock_sec(void); +extern void jps_apphook_msg(char *fmt,...); + +// +// mutex type & functions +// +#if SYS_PC +// PC uses Windows(R) methods +#elif SYS_BB +// linux uses posix threads +#define CRITICAL_SECTION pthread_mutex_t +#else // !SYS_PC !SYS_BB +#define CRITICAL_SECTION (unsigned long) +#endif // !SYS_PC !SYS_BB + +#if !SYS_PC +void InitializeCriticalSection(CRITICAL_SECTION *CritSec); +void DestroyCriticalSection(CRITICAL_SECTION *CritSec); +void EnterCriticalSection(CRITICAL_SECTION *CritSec); +void LeaveCriticalSection(CRITICAL_SECTION *CritSec); +#endif // !SYS_PC + +extern CRITICAL_SECTION jps_player_update_lock; +extern CRITICAL_SECTION channel_startstop; + +#include "jpsdefs.h" +#include "jps_snd.h" +#include "jps_marsig.h" +#include "jps_parse.h" +#include "jpsdrvr.h" +#include "jps_player.h" +#endif // !_JPS_H_ diff --git a/libraries/pmrt/jpsnd/jps.ncb b/libraries/pmrt/jpsnd/jps.ncb new file mode 100755 index 0000000..1227527 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps.ncb differ diff --git a/libraries/pmrt/jpsnd/jps.o b/libraries/pmrt/jpsnd/jps.o new file mode 100644 index 0000000..b8cc51b Binary files /dev/null and b/libraries/pmrt/jpsnd/jps.o differ diff --git a/libraries/pmrt/jpsnd/jps.opt b/libraries/pmrt/jpsnd/jps.opt new file mode 100755 index 0000000..7c35085 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps.opt differ diff --git a/libraries/pmrt/jpsnd/jps_marsig.c b/libraries/pmrt/jpsnd/jps_marsig.c new file mode 100755 index 0000000..04a7f2f --- /dev/null +++ b/libraries/pmrt/jpsnd/jps_marsig.c @@ -0,0 +1,71 @@ +/************************************** +** +** jps_marsig.c +** +** marker and signal handling +** +**************************************/ + +#include +#include +#include "jps.h" + +#define JPS_MARKER_MAX 0x10000 + +uint32 jps_markers[JPS_MARKER_MAX/32]; + +#define JPS_SIGNAL_MAX 1024 +uint16 jps_signals[JPS_SIGNAL_MAX]; +uint16 jps_signals_head; +uint16 jps_signals_tail; + +void jps_marsig_init() { +/************************************** +** +**************************************/ + memset(jps_markers, 0x00, sizeof(jps_markers)); + memset(jps_signals, 0x00, sizeof(jps_signals)); + jps_signals_head = jps_signals_tail = 0; +} + +void jps_marker_add(uint16 marker) { +/************************************** +** +**************************************/ + jps_markers[marker/32] |= (0x1 << (marker%32)); +} + +uint8 jps_marker_test(uint16 marker) { +/************************************** +** +**************************************/ + uint8 marker_out; + marker_out = 0x1 & (jps_markers[marker/32]>>(marker%32)); + jps_markers[marker/32] &= ~(0x1 << (marker%32)); + return marker_out; +} + + +void jps_signal_add(uint16 signal) { +/************************************** +** called by the sound system playlister +**************************************/ + jps_signals[jps_signals_head] = signal; + jps_signals_head = (jps_signals_head+1)%JPS_SIGNAL_MAX; + if (jps_signals_head == jps_signals_tail) { + // oops, we've overflowed, knock off the oldest signal + jps_signals_tail = (jps_signals_tail+1)%JPS_SIGNAL_MAX; + } +} + +int32 jps_signal_get(uint16 *signal) { +/************************************** +** +**************************************/ + if (jps_signals_head == jps_signals_tail) + return JPS_ERROR; + + *signal = jps_signals[jps_signals_tail]; + jps_signals_tail = (jps_signals_tail+1)%JPS_SIGNAL_MAX; + return JPS_OK; +} diff --git a/libraries/pmrt/jpsnd/jps_marsig.h b/libraries/pmrt/jpsnd/jps_marsig.h new file mode 100755 index 0000000..416431f --- /dev/null +++ b/libraries/pmrt/jpsnd/jps_marsig.h @@ -0,0 +1,15 @@ +/************************************** +** +** jps_marsig.h +** +**************************************/ +#ifndef JPS_MARSIG_H_ +#define JPS_MARSIG_H_ + +void jps_marsig_init(); +void jps_marker_add(uint16 marker); +uint8 jps_marker_test(uint16 marker); +void jps_signal_add(uint16 signal); +int32 jps_signal_get(uint16 *signal); + +#endif diff --git a/libraries/pmrt/jpsnd/jps_marsig.o b/libraries/pmrt/jpsnd/jps_marsig.o new file mode 100644 index 0000000..06a7818 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps_marsig.o differ diff --git a/libraries/pmrt/jpsnd/jps_parse.c b/libraries/pmrt/jpsnd/jps_parse.c new file mode 100755 index 0000000..5839c33 --- /dev/null +++ b/libraries/pmrt/jpsnd/jps_parse.c @@ -0,0 +1,698 @@ + +/************************************************ +** jps_parse.c +** +** top-level parsing stuff + helper functions +** +************************************************/ + +#include +#include +#include + +#include "jps.h" +#include "jps_snd.h" +#include "jps_marsig.h" +#include "jps_parse.h" +#include "jpsdrvr.h" +#include "jps_player.h" +#include "jps_parse.h" + +// the absolute path here is changed when a bank is loaded - it's used to +// set the path offset for the soundcalls from a given bank. +char g_abspath[255] = ""; +char command_ws[] = " \t\r\n"; +char arg_ws[] = ","; + +// Globals... needed for parse error output +int g_jps_linenumber = 0; +char g_jps_filename[255]; +char g_jps_errstr[512]; +jps_parse_table jps_parser[] = { + "PLAYLIST", JPS_NOTACOMMAND, jps_parse_func_playlist, + "GROUP", JPS_NOTACOMMAND, jps_parse_func_group, + "CONSTANT", JPS_NOTACOMMAND, jps_parse_func_constant, + "VOL_ATTEN",JPS_NOTACOMMAND, jps_parse_func_vol_atten, + "VOL_GAIN", JPS_NOTACOMMAND, jps_parse_func_vol_gain, + "",0,NULL, +}; + +#define HASH_MAX_SIZE (256) + +// JFL 18 Jul 04; re-wrote to use only first 32 bits +void HashFileName(jps_name name, int32 idx, char *fname) +{ + uint32 h[2]; + int32 ii; + uint32 a,b,c; + int shift; + + if(!fname) + { + h[0]=h[1]=0; + } + else + { + shift=0; + h[0]=h[1]=0; + for(ii=0;;ii++) + { + if(!(a=fname[ii])) + break; + b=a<<24; + c=a*0x1010101; + shift+=(1+a&7)*3; + while(shift>23) + shift-=24; + b>>=shift; + a<<=shift; + h[0]^=a; + h[0]+=b; + h[0]^=c; + } // for + } + if (name) { + memcpy(name,h,sizeof(jps_name)); + } + //SystemLog("HashFileName:%08X '%s'\n",h[0],fname); +} // HashFileName() + +int32 jps_parse_quote_string(jps_name name, char *fp, char *out) { +/************************************** +** get a quote delimited string +** minus the quotes but including +** whitespace +**************************************/ + int ii = 0; + int offset = 0; + char cc = 0; + char charout[HASH_MAX_SIZE]; + int len = strlen(fp); +#if SYS_PC|SYS_BB +#define OPENQUOTE -111 +#define CLOSEQUOTE -110 +#endif +#if SYS_5500 +#define OPENQUOTE 138 +#define CLOSEQUOTE 139 +#endif + + for (ii=0;ii= strlen(data)-1) + return NULL; + if (data[offset] == ';') + return NULL; + return &data[offset]; +} + +char *jps_parse_skipdata (char *data, char *whitespace) { +/************************************** +** skip over data and whitespace until +** reaching next separator, then token +**************************************/ + unsigned int datalen; + unsigned int offset2; + unsigned int offset; + + offset = strcspn(data,whitespace); + datalen =strlen(data); + if (offset >= datalen-1) + return NULL; + offset2 = strspn(&data[offset],whitespace); + if (offset+offset2 > datalen-1) + return NULL; + if (data[offset+offset2] == ';') + return NULL; + return &data[offset+offset2]; +} + +void jps_parse_get_stats(JPS_FILE *fp, uint32 *num_commands, uint32 *num_playlists, uint32 *num_soundfiles, + uint32 *num_groups, uint32 *num_groupsounds) { +/************************************** +** Pre-scans the bank file to find out +** how many playlists, sounds and +** commands are needed +**************************************/ + char line[HASH_MAX_SIZE]; + char *currdata; + jps_name *soundfilenames = NULL; + void *rawSoundfilenames; + *num_commands = 0; + *num_playlists = 0; + *num_soundfiles = 0; + *num_groups = 0; + *num_groupsounds = 0; + + #define SOUNDFILENAMES_MAX 256 + soundfilenames = jps_memalloc(&rawSoundfilenames, 0,sizeof(jps_name)*SOUNDFILENAMES_MAX); + if (soundfilenames == NULL) { + msg("jps_parse_get_stats(): ERROR! Couldn't alloc array, exiting\n"); + return; + } + + while (!jps_feof(fp)) { + jps_fgets(line,255, fp); + if (jps_feof(fp)) goto exit; + + // skip comments... + currdata = jps_parse_nextdata(line,command_ws); + if (currdata == NULL) + continue; + + if (strstr(line,"PLAYLIST") != NULL) + (*num_playlists)++; + else if (strstr(line,"PLAY") != NULL || strstr(line,"SOUND") != NULL) { + uint32 ii; + char dummy[HASH_MAX_SIZE]; + // we have a play command. find and add the string name + if (jps_parse_quote_string(soundfilenames[*num_soundfiles],line,dummy)!= JPS_OK) { + msg("bad quote string\n"); + } + for (ii=0;ii<*num_soundfiles;ii++) { + if (soundfilenames[ii] == soundfilenames[*num_soundfiles]) { + // already in, don't increment + break; + } + } + if (ii == *num_soundfiles) { + // didn't find a match, increment! + (*num_soundfiles)++; + } + } else if (strstr(line,"GROUP") != NULL) { + (*num_groups)++; + } + if (strstr(line,"SOUND") != NULL) { + (*num_groupsounds)++; + } + + // regardless of PLAYLIST or not, it's a command... + (*num_commands)++; + } +exit: + jps_memfree(rawSoundfilenames); +// msg("prescan: %i commands, %i playlists, %i soundfiles\n",*num_commands, *num_playlists, *num_soundfiles); +// msg("prescan: %i groups, %i groupsounds\n",*num_groups, *num_groupsounds); + jps_fseek(fp,0,SEEK_SET); +} + +jps_bank * jps_bank_alloc(int num_commands, int num_playlists, int num_sounds, int num_groups, int num_groupsounds) { +/************************************** +** create a bank struct +**************************************/ + jps_bank *bank = NULL; + void *rawPtr; + int ii; + + // first alloc the bank structure + bank = jps_memalloc(&rawPtr,8,sizeof(jps_bank)); + if (bank==NULL) { + msg("jps_bank_alloc(): ERROR! Couldn't alloc mem for bank\n"); + goto errorexit; + } + memset(bank, 0, sizeof(jps_bank)); + bank->rawBank=rawPtr; + + bank->commands = jps_memalloc(&rawPtr,8,num_commands * sizeof(jps_command)); + if (bank->commands == NULL) { + msg("jps_bank_alloc(): ERROR! Couldn't mem for command data\n"); + goto errorexit; + } + bank->max_commands = num_commands; + bank->rawCommands = rawPtr; + + bank->playlists = jps_memalloc(&rawPtr,8,num_playlists * sizeof(jps_playlist)); + if (bank->playlists == NULL) { + msg("jps_bank_alloc(): ERROR! Couldn't alloc mem for bank playlists\n"); + goto errorexit; + } + memset(bank->playlists,0xFF, num_playlists*sizeof(jps_playlist)); + bank->max_playlists = num_playlists; + bank->rawPlaylists = rawPtr; + + for (ii=0;iiplaylists[ii].commands = NULL; + } + + bank->sndbufs = jps_memalloc(&rawPtr,8,num_sounds * sizeof(jps_sndbuf)); + if (bank->sndbufs == NULL) { + msg("jps_bank_alloc(): ERROR! Couldn't alloc mem for bank sound buffers\n"); + goto errorexit; + } + bank->max_sndbufs = num_sounds; + bank->rawSndbufs = rawPtr; + + bank->groups = jps_memalloc(&rawPtr,8,num_groups * sizeof(jps_group)); + if (bank->groups == NULL) { + msg("jps_bank_alloc(): ERROR! Couldn't alloc mem for bank group data\n"); + goto errorexit; + } + bank->max_groups = num_groups; + bank->rawGroups = rawPtr; + + bank->groupsounds = jps_memalloc(&rawPtr,8,num_groupsounds * sizeof(jps_group)); + if (bank->groupsounds == NULL) { + msg("jps_bank_alloc(): ERROR! Couldn't alloc mem for bank group sound data\n"); + goto errorexit; + } + bank->max_groupsounds = num_groupsounds; + bank->rawGroupsounds = rawPtr; + + return bank; +errorexit: + if (bank->groups) jps_memfree(bank->rawGroups); + if (bank->sndbufs) jps_memfree(bank->rawSndbufs); + if (bank->commands) jps_memfree(bank->rawCommands); + if (bank->playlists) jps_memfree(bank->rawPlaylists); + if (bank) jps_memfree(bank->rawBank); + return NULL; +} // jps_bank_alloc() + +void jps_bank_free(jps_bank *bank) { +/************************************** +** deallocate all arrays, free all +** sound buffers +**************************************/ + uint32 ii; + if (bank == NULL) return; + + //jps_stopall(); + jps_stop_bank(bank); + EnterCriticalSection(&channel_startstop); + + for (ii=0;iinum_sndbufs;ii++) + free_buffers(&bank->sndbufs[ii]); + if (bank->sndbufs) jps_memfree(bank->rawSndbufs); + if (bank->commands) jps_memfree(bank->rawCommands); + if (bank->playlists) jps_memfree(bank->rawPlaylists); + if (bank->groups) jps_memfree(bank->rawGroups); + if (bank->groupsounds) jps_memfree(bank->rawGroupsounds); + if (bank) jps_memfree(bank->rawBank); + + LeaveCriticalSection(&channel_startstop); +} // jps_bank_free() + +int jps_parse_time(float *curr_time, float last_time, char *currdata) { +/************************************** +** get the time from within [] brackets +**************************************/ + int relative = 0; + int result; + + if (currdata[0] != '[') { + // no time info given... equivalent to [+0.00] + *curr_time = last_time; + return FALSE; + } + + // skip the bracket + currdata++; + + // get next data + currdata = jps_parse_nextdata(currdata, command_ws); + if (currdata == NULL) { + jps_parse_error("Syntax error after '['",g_jps_filename, g_jps_linenumber); + return JPS_ERROR; + } + + // relativetime? + if (*currdata == '+') { + relative = 1; + currdata++; + currdata = jps_parse_nextdata(currdata, command_ws); + if (currdata == NULL) { + jps_parse_error("Syntax error after '['",g_jps_filename, g_jps_linenumber); + return JPS_ERROR; + } + } + + result = sscanf(currdata,"%f",curr_time); + if (result == 0) { + jps_parse_error("invalid time value, ignoring command",g_jps_filename, g_jps_linenumber); + return JPS_ERROR; + } + + currdata = strchr(currdata,']')+1; + if (currdata == NULL) { + jps_parse_error("missing closing ']' after time, ignoring command",g_jps_filename, g_jps_linenumber); + return JPS_ERROR; + } + if (!relative && *curr_time < last_time) { + jps_parse_error("time is less than previous command, ignoring command",g_jps_filename, g_jps_linenumber); + return JPS_ERROR; + } + *curr_time = *curr_time + relative*last_time; + + return TRUE; +} +void jps_parse_remove_lf(char *string) { + uint32 ii; + if (string == NULL) return; + for (ii=0;iinum_commands >= data->max_commands ) { + msg("ERROR! Too many commands\n"); + return; + } + command = &(data->commands[data->num_commands]); + command->opcode = funcs[func_idx].opcode; + command->time = curr_time; + command->flags = cond; + last_time = curr_time; + result = func(fp, currdata, data, command, &last_time); + if (result != JPS_OK) { + // syntax error! let's show it and ignore... + jps_parse_error(g_jps_errstr,g_jps_filename, g_jps_linenumber); + // ... and don't allow the command to register + } else { + if (funcs[func_idx].opcode != JPS_NOTACOMMAND) { + data->num_commands++; + data->playlists[data->num_playlists-1].num_commands++; + } + } + if (strcmp(token,"END")==0) + break; + } + + if(retry) + break; + } // while + + // check last command + result = data->playlists[data->num_playlists-1].num_commands-1; + if (!retry + && data->playlists[data->num_playlists-1].commands[result].opcode != JPS_OPCODE_END) { + jps_parse_error("missing END token in playlist -- added",g_jps_filename, g_jps_linenumber); + retry++; + currdata="END "; + goto retry_lp; + } // !gotend + + return; +} // jps_parse_opcodes() + +// JFL 26 Apr 05; either slash +void jps_setpath(char *filenamein) { +/************************************** +** set the path for a base as an offset +** for +**************************************/ + int pathlength = 0; + + if(!(pathlength = (uint32)strrchr(filenamein,'\\'))) + pathlength = (uint32)strrchr(filenamein,'/'); + + if (pathlength == 0) { + // no leading directory path + g_abspath[0] = '\0'; + return; + } + pathlength -= (uint32)filenamein; + while ((filenamein[pathlength] == '\\') + || (filenamein[pathlength] == '/')) { + pathlength++; + } + strncpy (g_abspath, filenamein, pathlength); +} + +jps_bank * jps_bank_load(char *filename) { +/************************************** +** parse a .jps into appropriate +** structures +**************************************/ +#define MAX_LINESIZE 255 +#define PLAYLIST_COMMENT ';' + uint32 num_commands; + uint32 num_playlists; + uint32 num_sounds; + uint32 num_groups; + uint32 num_groupsounds; + JPS_FILE *fp = NULL; + jps_bank *bank; + uint32 ii; + jps_name hash; + + // see if this bank is already loaded + HashFileName(hash, 0,filename); + for (ii=0;iiname,hash,sizeof(jps_name))==0) + { + // bank already loaded + msg("jps_bank_load(): Warning! trying to re-load bank %s\n",filename); + return(jps_banks[ii]); + } + } + + // see if there is an open spot + for (ii=0;iiname, 0,filename); + jps_parse_init(); + jps_parse_opcodes(fp,bank,jps_parser); + jps_fclose(fp); + + // store the bank value into the master array for access + for (ii=0;iiname,hash,sizeof(jps_name))==0) + break; + } + if (bank == JPS_MAX_BANKS) { + // msg("jps_bank_unload() couldn't find bank %s\n",filename); + return; + } + +// not necessary as jps_bank_free does it also, jps_stopall(); + jps_bank_free(jps_banks[bank]); + jps_banks[bank] = NULL; +// msg("jps_bank_unload(): Warning! Not yet implemented!!!\n"); +} + +// JFL 17 Jul 04 +void jps_bank_unloadall(void) { +/************************************** +** get rid of all banks +**************************************/ + uint32 bank; + for (bank=0;bank +#include +#include "jps.h" +#include "jps_parse.h" + +#define JPS_STREAMING 1 + +typedef struct symbol_table_s { + char name[50]; + int value; +} symbol_table; + +#define JPS_SYMBOL_TABLE_NUM 20 +symbol_table jps_symbol_table[JPS_SYMBOL_TABLE_NUM]; + +jps_parse_table jps_playlist_parser[] = { + "STOP", JPS_OPCODE_STOP, jps_parse_func_stop, + "PLAY", JPS_OPCODE_PLAY, jps_parse_func_play, + "PLAYS", JPS_OPCODE_PLAY, jps_parse_func_plays, + "SETVOL", JPS_OPCODE_SETVOL, jps_parse_func_setvol, + "LOOPSTART", JPS_OPCODE_LOOPSTART, jps_parse_func_loopstart, + "LOOPEND", JPS_OPCODE_LOOPEND, jps_parse_func_loopend, + "UNDUCK", JPS_OPCODE_UNDUCK, jps_parse_func_unduck, + "DUCK", JPS_OPCODE_DUCK, jps_parse_func_duck, + "END", JPS_OPCODE_END, jps_parse_func_end, + "WAITFOR", JPS_OPCODE_WAITFOR, jps_parse_func_waitfor, + "SETPAN", JPS_OPCODE_SETPAN, jps_parse_func_setpan, + "SETFREQ", JPS_OPCODE_SETFREQ, jps_parse_func_setfreq, + "GOTO", JPS_OPCODE_GOTO, jps_parse_func_goto, + "LABEL", JPS_OPCODE_LABEL, jps_parse_func_label, + "SIGNAL", JPS_OPCODE_SIGNAL, jps_parse_func_signal, + "MARKER", JPS_OPCODE_MARKER, jps_parse_func_marker, + "PLAYGROUP", JPS_OPCODE_PLAYGROUP, jps_parse_func_playgroup, + "", 0xFFFFFFFF, NULL, +}; + +jps_parse_table jps_group_parser[] = { + "SOUND", JPS_NOTACOMMAND, jps_parse_func_group_sound, + "END", JPS_NOTACOMMAND, jps_parse_func_group_end, +}; +void jps_parse_init() { +/************************************** +** initialization required before +** starting to parse a playlist file +**************************************/ + memset(jps_symbol_table, 0x00,sizeof(jps_symbol_table)); +} + +int jps_parse_symbolic(char *currdata, int *result) { +/************************************** +** +**************************************/ + char symbolic_ws[] = " \t"; + int sum = 0; + int curr = 0; + int sign = 1; + + if (currdata == NULL) + return JPS_ERROR; + + // eliminate leading blanks if they exist + while (currdata[0] == ' ' || currdata[0] == '\t') { + currdata++; + if (currdata[0] == '\0') { + //ERROR! + return JPS_ERROR; + } + } + while (currdata) { + if (currdata[0] >= '0' && currdata[0] <= '9') { + curr = jps_parse_hex(currdata); + sum += curr * sign; + } else { + char str[30]; + int ii; + // it's a symbol this time + sscanf(currdata,"%s",str); + str[strcspn(str,"+-")] = '\0'; + // remove any trailing commas, if they exist + if (str[strlen(str)-1] == ',') { + str[strlen(str)-1] = '\0'; + } + for (ii=0;ii 'F') cc -= 'a'-'A'; + cc -= 'A'-'0'; + if (cc>='0' && cc<='5') { + output = output*base+(cc-'0'+10); + continue; + } + } + if (in[ii] >='0' && in[ii]<='9') { + output = (output*base)+in[ii]-'0'; + } else if (in[ii] == ' ' || in[ii] == '\t' || in[ii] == ','){ + break; + } + } + return output; +} + +// JFL 18 Jul 04 +jps_sndbuf *jps_parse_addsound(char *soundname, jps_bank *bank, uint8 stream) { +/************************************** +** add a sound to the list of sounds +** to load... +**************************************/ + uint32 ii; + jps_sndbuf *sndbuf = NULL; + jps_name name; + JPS_FILE *fp = NULL; + wavinfo wavhdr; + char fullsoundname[255]; + int i; + + HashFileName(name,0,soundname); + + // is it already in the list? + for (ii=0;iinum_sndbufs;ii++) { + if (memcmp(name, bank->sndbufs[ii].name,sizeof(jps_name))==0) { + // got a match! + return &bank->sndbufs[ii]; + } + } // for + + // + // NO MORE EASY EXITS + // + + // no match, do we have room to load?... + if (bank->num_sndbufs == bank->max_sndbufs) { + msg("jps_parse_addsound() Already alloc'ed max # of sounds\n"); + goto errorexit; + } + + // get the file handle + sprintf(fullsoundname, "%s%s",g_abspath, soundname); + if(!(fp=jps_fopen(fullsoundname, "rb"))) + { + msg("Couldn't open sound file %s\n", fullsoundname); + goto errorexit; + } + + sndbuf = &bank->sndbufs[bank->num_sndbufs]; + memset(sndbuf,0,sizeof(jps_sndbuf)); + memcpy(sndbuf->name,name,sizeof(jps_name)); + sndbuf->file_pointer=fp; + + i=strlen(fullsoundname); + if(i>sizeof(sndbuf->file_path)-1) + i=sizeof(sndbuf->file_path)-1; + memcpy(sndbuf->file_path,fullsoundname,i); + sndbuf->file_path[i]=0; + + + // load the wav header + if(read_wav_header(&wavhdr,fp,&(sndbuf->file_hdrpos))) + { + msg("couldn't read_wav_header sound file %s\n", fullsoundname); + goto errorexit; + } + + // find end of data + sndbuf->file_endpos=sndbuf->file_hdrpos+sndbuf->numbytes; + + // fix sample rate information according to supported sample + // rates! +#if SYS_PC|SYS_BB + sndbuf->nSamplesPerSec = wavhdr.num_samples_per_sec; +#endif // SYS_PC|SYS_BB +#if SYS_5500 + if (wavhdr.num_samples_per_sec < 30000) + sndbuf->nSamplesPerSec = 24000; + else + sndbuf->nSamplesPerSec = 48000; +#endif + sndbuf->nChannels = wavhdr.num_channels; + + // determine streaming... + switch (stream) + { + case JPS_STREAM_YES: + sndbuf->streaming = TRUE; + break; + case JPS_STREAM_NO: + sndbuf->streaming = FALSE; + break; + //case JPS_STREAM_AUTO: + default: + sndbuf->streaming = FALSE; + if (wavhdr.Size3 > STREAM_SIZE_THRESHOLD) + sndbuf->streaming = TRUE; + break; + } // switch + + // msg("jps_parse_addsound() opened %08X streaming=%d\n",sndbuf->name[0],sndbuf->streaming); + + // create buffer, load it with the file data + if(create_and_preload_buffer(&wavhdr, sndbuf) != JPS_OK) + goto errorexit; + + // + // + // + + // close file if not streaming + if(!sndbuf->streaming) + { + // msg("jps_parse_addsound() closing %08X streaming=%d\n",sndbuf->name[0],sndbuf->streaming); + jps_fclose(fp); + fp=sndbuf->file_pointer=NULL; + } + + bank->num_sndbufs++; // only 'allocs' sndbuf if successful + return sndbuf; + +errorexit: + + if(fp) + { + // msg("jps_parse_addsound() closing %08X streaming=%d errorexit\n",sndbuf->name[0],sndbuf->streaming); + jps_fclose(fp); + } + + if(sndbuf) + memset(sndbuf,0,sizeof(jps_sndbuf)); + + msg("jps_parse_addsound() Couldn't load %s\n",soundname); + return NULL; +} // jps_parse_addsound() + +int32 jps_parse_func_playfunc(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time, uint8 stream) { +/************************************** +** start a sound playing on a channel +**************************************/ + char *currdata = NULL; + char soundname[255]; + jps_args_play *play_args = (jps_args_play *)cmd->args; + if (args == NULL) { + sprintf(g_jps_errstr,"PLAY requires arguments\n"); + return JPS_ERROR; + } + + // first arg: channel number + sscanf(args,"%i",&play_args->track); + + currdata = jps_parse_skipdata(args,arg_ws); + play_args->group = NULL; + + if (currdata == NULL) { + sprintf(g_jps_errstr,"Too few arguments to PLAY\n"); + return JPS_ERROR; + } + if (play_args->track > JPS_NUM_CHANNELS) { + sprintf(g_jps_errstr,"Track number too high! Must be less than %i\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + // second arg: sound name + if (jps_parse_quote_string(NULL, currdata,soundname) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + // throw 'er into the list of sounds to load + play_args->sndbuf = jps_parse_addsound(soundname, bank, stream); + if (play_args->sndbuf == NULL) { + sprintf(g_jps_errstr,"couldn't open sound file '%s'",soundname); + return JPS_ERROR; + } + if (currdata == NULL) { + sprintf(g_jps_errstr,"Too few arguments to PLAY\n"); + return JPS_ERROR; + } + // third arg: loop frequency + currdata = jps_parse_skipdata(currdata, arg_ws); + sscanf(currdata,"%i",&play_args->num_loops); + if (play_args->num_loops < 0) { + sprintf(g_jps_errstr,"loop frequency must be greater than zero\n"); + return JPS_ERROR; + } + if (bank->num_playlists <= 0) { + sprintf(g_jps_errstr,"INTERNAL ERROR E12345\n"); + return JPS_ERROR; + } + // now adjust the playlist track allocation information + if (bank->playlists[bank->num_playlists-1].num_tracks < (uint32)play_args->track+1) + bank->playlists[bank->num_playlists-1].num_tracks = play_args->track+1; + + return JPS_OK; +} // jps_parse_func_playfunc() + +int32 jps_parse_func_play(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** force no streaming +**************************************/ +#if JPS_AUTOSTREAM + if(jpsdrvr_stream_ok()) + return jps_parse_func_playfunc(fp,args,bank,cmd,curr_time,JPS_STREAM_AUTO); + else + return jps_parse_func_playfunc(fp,args,bank,cmd,curr_time,JPS_STREAM_NO); +#else + return jps_parse_func_playfunc(fp,args,bank,cmd,curr_time,JPS_STREAM_NO); +#endif +} + +int32 jps_parse_func_plays(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** force a stream play +**************************************/ + if(jpsdrvr_stream_ok()) +#if JPS_AUTOSTREAM + return jps_parse_func_playfunc(fp,args,bank,cmd,curr_time,JPS_STREAM_AUTO); +#else + return jps_parse_func_playfunc(fp,args,bank,cmd,curr_time,JPS_STREAM_YES); +#endif + else + return jps_parse_func_playfunc(fp,args,bank,cmd,curr_time,JPS_STREAM_NO); +} + +int32 jps_parse_func_playgroup(JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** select a sound at random and play +** it +**************************************/ + char *currdata = NULL; + char soundname[255]; + jps_name name; + uint32 ii; + jps_args_play *play_args = (jps_args_play *)cmd->args; + if (args == NULL) { + sprintf(g_jps_errstr,"Too few arguments to PLAYGROUP\n"); + return JPS_ERROR; + } + + // first arg: channel number + sscanf(args,"%i",&play_args->track); + currdata = jps_parse_skipdata(args,arg_ws); + + if (currdata == NULL) { + sprintf(g_jps_errstr,"Too few arguments to PLAYGROUP\n"); + return JPS_ERROR; + } + if (play_args->track > JPS_NUM_CHANNELS) { + sprintf(g_jps_errstr,"Track number too high! Must be less than %i\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + // second arg: group name + if (jps_parse_quote_string(name, currdata,soundname) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + for (ii=0;iinum_groups;ii++) { + if (memcmp(bank->groups[ii].name, name,sizeof(jps_name))==0) { + play_args->group = &bank->groups[ii]; + break; + } + } + if (ii==bank->num_groups) { + sprintf(g_jps_errstr,"PLAYGROUP: invalid group name '%s'\n",soundname); + return JPS_ERROR; + } + play_args->sndbuf = NULL; + + if (currdata == NULL) { + sprintf(g_jps_errstr,"Too few arguments to PLAYGROUP\n"); + return JPS_ERROR; + } + // third arg: loop frequency + currdata = jps_parse_skipdata(currdata, arg_ws); + sscanf(currdata,"%i",&play_args->num_loops); + + // now adjust the playlist track allocation information + if (bank->playlists[bank->num_playlists-1].num_tracks < (uint32)play_args->track+1) + bank->playlists[bank->num_playlists-1].num_tracks = play_args->track+1; + + return JPS_OK; +} + +int32 jps_parse_func_stop(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** stop a channel from playing +**************************************/ + jps_args_stop *stop_args = (jps_args_stop *)cmd->args; + if (args == NULL) { + sprintf(g_jps_errstr,"Too few arguments to STOP\n"); + return JPS_ERROR; + } + + // first arg: track number + sscanf(args,"%i",&stop_args->track); + if (stop_args->track > JPS_NUM_CHANNELS) { + sprintf(g_jps_errstr,"Track number too high! Must be less than %i\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + return JPS_OK; +} + +int32 jps_parse_func_waitfor(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** wait for the previous time-based +** command to finish... +**************************************/ + int ii; + jps_playlist *curr_playlist = NULL; + jps_args_waitfor *waitfor_args = (jps_args_waitfor*)cmd->args; + jps_command *curr_cmd = NULL; + float delay = 0; + + // first arg: track number + sscanf(args,"%i",&waitfor_args->track); + if (waitfor_args->track > JPS_NUM_CHANNELS) { + sprintf(g_jps_errstr,"Track number too high! Must be less than %i\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + // now go backwards through the command list, looking for a play with that track + curr_playlist = &bank->playlists[bank->num_playlists-1]; + + for (ii=curr_playlist->num_commands-1;ii>=0;ii--) { + curr_cmd = &curr_playlist->commands[ii]; + switch (curr_cmd->opcode) { + case JPS_OPCODE_PLAY: + { + jps_args_play *play_args; + play_args = (jps_args_play *)curr_cmd->args; + if (play_args->track != waitfor_args->track) break; + // found it! Now determine the length of the soundcall to play... + if (play_args->sndbuf == NULL) { + msg("jps_parse_func_waitfor(): Warning! Sound buffer not loaded\n"); + delay = 0; + } else { + delay=play_args->sndbuf->numbytes/ + ((float)play_args->sndbuf->nSamplesPerSec*2*play_args->sndbuf->nChannels); +// msg("waitfor delay=%f\n",delay); + } + goto exit; + } +// break; + case JPS_OPCODE_SETVOL: + { + jps_args_setvol *setvol_args; + setvol_args = (jps_args_setvol *)curr_cmd->args; + if (setvol_args->track != waitfor_args->track) break; + // found it! Now determine the length of the soundcall to play... + delay = setvol_args->ramp_time; + goto exit; + } +// break; + case JPS_OPCODE_DUCK: + { + jps_args_duck *duck_args; + duck_args = (jps_args_duck *)curr_cmd->args; + if (duck_args->channel != waitfor_args->track) break; + // found it! Now determine the length of the soundcall to play... + delay = duck_args->ramp_time; + goto exit; + } +// break; + case JPS_OPCODE_UNDUCK: + { + jps_args_unduck *unduck_args; + unduck_args = (jps_args_unduck *)curr_cmd->args; + if (unduck_args->channel != waitfor_args->track) break; + // found it! Now determine the length of the soundcall to play... + delay = unduck_args->ramp_time; + goto exit; + } +// break; + } + } + if (ii<0) { + sprintf(g_jps_errstr,"'WAITFOR' without 'PLAY'\n"); + return JPS_ERROR; + } + +exit: + *curr_time = delay + curr_cmd->time; + return JPS_OK; +} + +int32 jps_parse_func_loopstart(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** start of a loop +**************************************/ + jps_args_loopstart *loopstart_args = (jps_args_loopstart *)cmd->args; + if (args == NULL) { + sprintf(g_jps_errstr,"No arguments!\n"); + return JPS_ERROR; + } + // first arg: + sscanf(args,"%i",&loopstart_args->remaining); + if (loopstart_args->remaining == 0) { + loopstart_args->remaining = 0xFFFFFFFF; // this REALLY indicates forever + } + return JPS_OK; +} + +int32 jps_parse_func_loopend(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** end of a loop +**************************************/ + return JPS_OK; +} + + + +int32 jps_parse_func_constant(JPS_FILE *fp, char * args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + int ii; + char *currdata; + + // find a free constant value... + for (ii=0;iiargs; + uint32 volume; + float ramp_time; + + if (args == NULL) { + sprintf(g_jps_errstr,"No arguments!\n"); + return JPS_ERROR; + } + // first arg: track number + sscanf(args,"%i",&setvol_args->track); + currdata = jps_parse_skipdata(args,arg_ws); + + if (currdata == NULL) { + sprintf(g_jps_errstr,"Not enough arguments!\n"); + return JPS_ERROR; + } + + // second arg: volume + jps_parse_symbolic(currdata, &volume); + if (volume >255) { + sprintf(g_jps_errstr,"Volume must be in the range 0-255\n"); + return JPS_ERROR; + } + setvol_args->volume = volume; + + currdata = jps_parse_skipdata(currdata,arg_ws); + + if (currdata == NULL) { + sprintf(g_jps_errstr,"Not enough arguments!\n"); + return JPS_ERROR; + } + // third arg: ramp time + sscanf(currdata, "%f", &ramp_time); + if (ramp_time <0) { + sprintf(g_jps_errstr,"Ramp time must be positive\n"); + return JPS_ERROR; + } + setvol_args->ramp_time = ramp_time; + + return JPS_OK; +} + +int32 jps_parse_func_setpan (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata = NULL; + jps_args_setpan *setpan_args = (jps_args_setpan *)cmd->args; + + if (args == NULL) return JPS_ERROR; + // first arg: track number + sscanf(args,"%i",&setpan_args->track); + currdata = jps_parse_skipdata(args,arg_ws); + + // second arg: pan + sscanf(currdata, "%i", &setpan_args->pan); + currdata = jps_parse_skipdata(currdata,arg_ws); + + // third arg: ramp time + sscanf(currdata, "%f", &setpan_args->ramp_time); + if (setpan_args->ramp_time <0) { + sprintf(g_jps_errstr,"Ramp time must be positive\n"); + return JPS_ERROR; + } + + return JPS_OK; +} + +int32 jps_parse_func_goto (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + jps_args_goto *goto_args = (jps_args_goto *)cmd->args; + + if (args == NULL) return JPS_ERROR; + + // first arg: name + if (jps_parse_quote_string(goto_args->name, args, NULL) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + return JPS_OK; +} + +int32 jps_parse_func_label (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + jps_args_label *label_args = (jps_args_label *)cmd->args; + + if (args == NULL) return JPS_ERROR; + + // first arg: name + if (jps_parse_quote_string(label_args->name, args, NULL) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + return JPS_OK; +} + +int32 jps_parse_func_signal (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + jps_args_signal *signal_args = (jps_args_signal *)cmd->args; + + if (args == NULL) return JPS_ERROR; + + // first arg: name + sscanf(args, "%i", &(signal_args->num)); + + return JPS_OK; +} + +int32 jps_parse_func_marker (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + jps_args_marker *marker_args = (jps_args_marker *)cmd->args; + + if (args == NULL) return JPS_ERROR; + + // first arg: name + sscanf(args, "%i", &(marker_args->num)); + + return JPS_OK; +} + +int32 jps_parse_func_vol_atten (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + bank->flags |= JPS_BANK_FLAG_VOL_ATTEN; + return JPS_OK; +} + +int32 jps_parse_func_vol_gain (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + bank->flags &= ~JPS_BANK_FLAG_VOL_ATTEN; + return JPS_OK; +} + +int32 jps_parse_func_setfreq (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata = NULL; + jps_args_setfreq *setfreq_args = (jps_args_setfreq *)cmd->args; + + if (args == NULL) return JPS_ERROR; + // first arg: track number + sscanf(args,"%i",&setfreq_args->track); + currdata = jps_parse_skipdata(args,arg_ws); + + // second arg: frequency + sscanf(currdata, "%i", &setfreq_args->freq); + currdata = jps_parse_skipdata(currdata,arg_ws); + + // third arg: ramp time + sscanf(currdata, "%f", &setfreq_args->ramp_time); + if (setfreq_args->ramp_time <0) { + sprintf(g_jps_errstr,"Ramp time must be positive\n"); + return JPS_ERROR; + } + + return JPS_OK; +} + +int32 jps_parse_func_duck (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata = NULL; + jps_args_duck *duck_args = (jps_args_duck *)cmd->args; + uint32 volume; + uint32 channel; + + if (args == NULL) return JPS_ERROR; + + // first arg: channel + sscanf(args,"%i", &channel); + duck_args->channel = channel; + currdata = jps_parse_skipdata(args,arg_ws); + + // second arg: volume + sscanf(currdata, "%i", &volume); + if (volume <0 || volume >255) { + sprintf(g_jps_errstr,"Volume must be in the range 0-255\n"); + return JPS_ERROR; + } + duck_args->volume = volume; + + currdata = jps_parse_skipdata(currdata,arg_ws); + + // third arg: ramp time + sscanf(currdata, "%f", &duck_args->ramp_time); + if (duck_args->ramp_time <0) { + sprintf(g_jps_errstr,"Ramp time must be positive\n"); + return JPS_ERROR; + } + + return JPS_OK; +} + +int32 jps_parse_func_unduck (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata = NULL; + jps_args_unduck *unduck_args = (jps_args_unduck *)cmd->args; + uint32 channel; + float ramp_time; + + if (args == NULL) { + sprintf(g_jps_errstr,"NOT ENOUGH ARGUMENTS\n"); + return JPS_ERROR; + } + + // first arg: channel + sscanf(args,"%i", &channel); + unduck_args->channel = channel; + currdata = jps_parse_skipdata(args,arg_ws); + + // second arg: ramp time + sscanf(currdata, "%f", &ramp_time); + if (ramp_time <0) { + sprintf(g_jps_errstr,"Ramp time must be positive\n"); + return JPS_ERROR; + } + unduck_args->ramp_time = ramp_time; + + return JPS_OK; +} + +int32 jps_parse_func_end (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + // no args, just the opcode is ok. + return JPS_OK; +} + +int32 jps_parse_func_group (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata = args; + + bank->groups[bank->num_groups].groupsounds = &bank->groupsounds[bank->num_groupsounds]; + bank->groups[bank->num_groups].num = 0; + + // first arg is name... + if (jps_parse_quote_string(bank->groups[bank->num_groups].name, currdata,NULL) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + + // second arg is buf size... + currdata = jps_parse_skipdata(currdata, arg_ws); + if (currdata == NULL) { + sprintf(g_jps_errstr, "ERROR! Couldn't get repeat number\n"); + return JPS_ERROR; + } + sscanf(currdata, "%i", &bank->groups[bank->num_groups].buffer_size); + + + // now parse playlist opcodes until the playlist is done... + jps_parse_opcodes(fp,bank,jps_group_parser); + + // now convert the weights + { + uint32 ii; + float weightsum = 0; + for (ii=0;iigroups[bank->num_groups].num;ii++) { + weightsum += bank->groups[bank->num_groups].groupsounds[ii].prob; + } + for (ii=0;iigroups[bank->num_groups].num;ii++) { + bank->groups[bank->num_groups].groupsounds[ii].prob /= weightsum; + } + } + // handle the case where our group history buffer is greater than or equal to the + // number of sound calls + if (bank->groups[bank->num_groups].num <= bank->groups[bank->num_groups].buffer_size) + bank->groups[bank->num_groups].buffer_size = bank->groups[bank->num_groups].num-1; + bank->num_groups++; + + return JPS_OK; +} + +int32 jps_parse_func_group_sound (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata = args; + jps_name name; + char filename[255]; + jps_groupsound *groupsounds = bank->groups[bank->num_groups].groupsounds; + uint32 ii; + uint32 prob; + + // first arg is name... + if (jps_parse_quote_string(name, currdata, filename) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n",JPS_NUM_CHANNELS); + return JPS_ERROR; + } + if (jps_parse_addsound(filename,bank,JPS_STREAM_NO) == NULL) { + sprintf(g_jps_errstr,"couldn't open sound file '%s'",filename); + return JPS_ERROR; + } + for (ii=0;iinum_sndbufs;ii++) { + if (memcmp(bank->sndbufs[ii].name,name,sizeof(jps_name))==0) { + groupsounds[bank->groups[bank->num_groups].num].buf = &bank->sndbufs[ii]; + break; + } + } + + if (ii == bank->num_sndbufs) { + sprintf(g_jps_errstr, "jps_parse_func_group_sound(): ERROR! Couldn't find sound\n"); + return JPS_ERROR; + } + + // second arg is weight... + currdata = jps_parse_skipdata(currdata, arg_ws); + sscanf(currdata, "%i", &prob); + groupsounds[bank->groups[bank->num_groups].num].prob = (float)prob; + + bank->groups[bank->num_groups].num++; + bank->num_groupsounds++; + return JPS_OK; +} + +int32 jps_parse_func_group_end (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + return 0; +} + +int32 jps_parse_func_playlist (JPS_FILE *fp, char *args, jps_bank *bank, jps_command *cmd, float *curr_time) { +/************************************** +** +**************************************/ + char *currdata; + uint32 playlist_num; + uint32 priority; + uint32 trackmask; + if (args == NULL) return JPS_ERROR; + if (bank->num_playlists == bank->max_playlists) { + sprintf(g_jps_errstr,"ERROR! too many playlists\n"); + return JPS_ERROR; + } + if (*curr_time != 0.0f) { + // odd. there shouldn't be a time before a PLAYLIST command by definition + sprintf(g_jps_errstr,"nonzero time before playlist call!\n"); + return JPS_ERROR; + } + + // next argument is playlist number... + currdata = jps_parse_nextdata(args, arg_ws); + if (currdata == NULL) { + sprintf(g_jps_errstr,"ERROR! not enough args to PLAYLIST\n"); + return JPS_ERROR; + } + + sscanf(currdata,"%i",&playlist_num); + currdata = jps_parse_skipdata(currdata, arg_ws); + if (currdata == NULL) return JPS_ERROR; + + { + uint32 ii; + for (ii=0;iinum_playlists;ii++){ + if (bank->playlists[ii].num == playlist_num) { + sprintf(g_jps_errstr,"ERROR! duplicate playlist number, ignoring\n"); + return JPS_ERROR; + } + } + } + + bank->playlists[bank->num_playlists].num = playlist_num; + bank->playlists[bank->num_playlists].commands = &(bank->commands[bank->num_commands]); + bank->playlists[bank->num_playlists].num_commands = 0; + bank->playlists[bank->num_playlists].num_tracks = 0; + + // now get the name... + if (jps_parse_quote_string(bank->playlists[bank->num_playlists].name,currdata,NULL) != JPS_OK) { + sprintf(g_jps_errstr,"Syntax error: string must surrounded by single quotes\n"); + return JPS_ERROR; + } + + // get the priority + currdata = jps_parse_skipdata(currdata, arg_ws); + if (currdata == NULL || strlen(currdata)==0) { + // no more data... fill it in + msg("ERROR! no priority arg\n"); + bank->playlists[bank->num_playlists].priority = 128; + bank->playlists[bank->num_playlists].trackmask = 0xFF; + goto finish; + } +// sscanf(currdata,"%i",&priority); + jps_parse_symbolic(currdata, &priority); + if (priority > 255) { + sprintf(g_jps_errstr,"priority must be in the range 0-255\n"); + return JPS_ERROR; + } + + bank->playlists[bank->num_playlists].priority = priority; + + // get the trackmask + currdata = jps_parse_skipdata(currdata, arg_ws); + if (currdata == NULL) { + msg("ERROR! no trackmask arg\n"); + bank->playlists[bank->num_playlists].trackmask = 0xFF; + goto finish; + } +// sscanf(currdata,"%i",&trackmask); + jps_parse_symbolic(currdata, &trackmask); + if (trackmask == 0) { + sprintf(g_jps_errstr,"trackmask must be non-zero\n"); + return JPS_ERROR; + } + + bank->playlists[bank->num_playlists].trackmask = trackmask; +// bank->playlists[bank->num_playlists].trackmask = jps_parse_hex(currdata); + +finish: + bank->num_playlists++; + // now parse playlist opcodes until the playlist is done... + jps_parse_opcodes(fp,bank,jps_playlist_parser); + + // verify that the last playlist command was "END" + { + int last_command = bank->playlists[bank->num_playlists-1].num_commands-1; + if (bank->playlists[bank->num_playlists-1].commands[last_command].opcode != JPS_OPCODE_END) { + sprintf(g_jps_errstr,"ERROR! Last command must be 'END' and must end with EOL\n"); + return JPS_ERROR; + } + } + return JPS_OK; +} diff --git a/libraries/pmrt/jpsnd/jps_pfuncs.o b/libraries/pmrt/jpsnd/jps_pfuncs.o new file mode 100644 index 0000000..b538dd9 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps_pfuncs.o differ diff --git a/libraries/pmrt/jpsnd/jps_player.c b/libraries/pmrt/jpsnd/jps_player.c new file mode 100755 index 0000000..b9b2535 --- /dev/null +++ b/libraries/pmrt/jpsnd/jps_player.c @@ -0,0 +1,1174 @@ +/************************************************ +** jps_player.c +** +** playlist execution +** +************************************************/ +#include +#include +#include +#include "jps.h" +#include "jps_parse.h" + +#define DBG_WATCH_SOUNDS 0 //0 +#define CHANNEL_DUCKED 2 +#define CHANNEL_UNDUCK_REQUEST 1 +#define CHANNEL_UNDUCKED 0 + +jps_opcode_table jps_funcs[] = { + JPS_OPCODE_PLAY, jps_opcode_func_play, + JPS_OPCODE_STOP, jps_opcode_func_stop, + JPS_OPCODE_END, jps_opcode_func_end, + JPS_OPCODE_SETVOL, jps_opcode_func_setvol, + JPS_OPCODE_LOOPSTART, jps_opcode_func_loopstart, + JPS_OPCODE_LOOPEND, jps_opcode_func_loopend, + JPS_OPCODE_DUCK, jps_opcode_func_duck, + JPS_OPCODE_UNDUCK, jps_opcode_func_unduck, + JPS_OPCODE_WAITFOR, jps_opcode_func_waitfor, + JPS_OPCODE_LABEL, jps_opcode_func_label, + JPS_OPCODE_GOTO, jps_opcode_func_goto, + JPS_OPCODE_SIGNAL, jps_opcode_func_signal, + JPS_OPCODE_MARKER, jps_opcode_func_marker, + JPS_OPCODE_PLAYGROUP, jps_opcode_func_playgroup, + 0xFFFFFFFF, NULL, +}; + +#if DBG_WATCH_SOUNDS +struct { + char s[16]; +} jps_infochannel[JPS_NUM_CHANNELS]; +struct { + char s[16]; +} jps_infoplayer[JPS_NUM_PLAYERS]; +#endif // DBG_WATCH_SOUNDS + +void jps_update_all(jps_player *player) +{ +/************************************** +** update all currently-executing +** playlists +**************************************/ + int ii; + float curr_time; + #if DBG_WATCH_SOUNDS + uint32 name; + char c; + #endif // DBG_WATCH_SOUNDS + + EnterCriticalSection(&jps_player_update_lock); + curr_time = (float)jps_clock_sec(); + for (ii=0;iiname[0]; + c=(name>>24)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infoplayer[ii].s[1]=c; + + c=(name>>24)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infoplayer[ii].s[2]=c; + + c=(name>>16)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infoplayer[ii].s[3]=c; + + c=(name>>16)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infoplayer[ii].s[4]=c; + #endif // DBG_WATCH_SOUNDS + + jps_player_update(&jps_players[ii],curr_time-jps_players[ii].start_time); + } + } + LeaveCriticalSection(&jps_player_update_lock); +} // jps_update_all() + +int32 jps_player_exec(jps_command *command, jps_player *player, float *curr_time) { +/************************************** +** execute a playlist function +**************************************/ + uint32 ii; + int32 result; + // did we meet the conditional, if any? + if (!jps_player_conditional_met(command, player)) { + player->curr_command++; + return JPS_OK; + } + for (ii=0;jps_funcs[ii].func != NULL;ii++) { + if (jps_funcs[ii].opcode == command->opcode) { + // found the function! execute it + result = jps_funcs[ii].func(command, player, curr_time, NULL); + player->curr_command++; + return result; + } + } + msg("jps_player_exec(): ERROR! Invalid opcode '0x%0x'\n'",command->opcode); + player->curr_command++; + return JPS_ERROR; +} + +void jps_player_ramp_update( jps_player *player, float curr_time) +{ +/************************************** +** update any ramps a player is running +**************************************/ + int ii; + + for (ii=0;iiramps[ii].opcode) + { + case JPS_RAMP_OPCODE_NONE: + break; + case JPS_RAMP_OPCODE_REG: + { + // normal ramp here + int32 amount; + float donefrac; + jps_ramp_args *ramp_args = NULL; + + ramp_args = (jps_ramp_args*) &player->ramps[ii].args; + donefrac = (curr_time - ramp_args->start_time)/(ramp_args->finish_time - ramp_args->start_time); + if (donefrac >1.0f) + donefrac = 1.0f; + + amount = (int32)((ramp_args->final_amount-ramp_args->start_amount)*donefrac + ramp_args->start_amount); + switch (player->ramps[ii].obj) + { + case JPS_RAMP_OBJ_VOLUME: + channel_set_volume(ramp_args->channel,amount); + break; + default: + msg("jps_player_ramp_update(): Warning! obj yet supported\n"); + break; + } + + if (donefrac >= 1.0f) + { + player->ramps[ii].opcode = JPS_RAMP_OPCODE_NONE; // all done! + + if(jps_channel_data[ramp_args->channel].ducked == CHANNEL_UNDUCK_REQUEST) + jps_channel_data[ramp_args->channel].ducked = CHANNEL_UNDUCKED; + } + + } + break; + default: + msg("jps_player_ramp_update(): Warning! Opcode not supported\n"); + } + } +} + +void jps_player_update(jps_player *player, float curr_time) +{ +/************************************** +** update a playlist, executing all +** commands necessary +**************************************/ + jps_command *command = NULL; + + if (player->playlist == NULL) + goto exit; + + jps_player_ramp_update(player, curr_time); + + if (player->curr_command >= player->playlist->num_commands) + { + msg("jps_player_update(): ERROR! Exceeded end of list\n"); + jps_stop(player); + goto exit; + } + command = &(player->playlist->commands[player->curr_command]); + while (command->time <= curr_time) + { +// msg("x:%f\n",curr_time); + + // execute command + jps_player_exec(command, player, &curr_time); + if (player->playlist == NULL) { + // a command stopped us, get out! + goto exit; + } + if (player->playlist->commands[player->curr_command].opcode == JPS_OPCODE_END) { + // special case... we reached an end command but we're not + // yet finished... so leave for now, so we don't get stuck + // in an infinite loop + goto exit; + } + if (player->curr_command >= player->playlist->num_commands) { + msg("jps_player_update(): ERROR! Premature end of playlist encountered\n"); + jps_stop(player); + goto exit; + } + command = &(player->playlist->commands[player->curr_command]); + } // while + +exit: + return; +} // jps_player_update() + +void jps_stop(jps_player *player) { + uint32 ii; + + // first stop the playlister + player->playlist = NULL; + player->curr_command = 0; + + // stop any sounds that are playing + for (ii=0;iitracks[ii] >= 0) { + sound_stop(player->tracks[ii]); + + // free track ownership... + jps_channel_data[player->tracks[ii]].owner = NULL; + } + } // for +} // jps_stop() + +void jps_stopchannel(uint32 channel) { +/************************************** +** stop a playlist by channel +**************************************/ + if (jps_channel_data[channel].owner) + jps_stop(jps_channel_data[channel].owner); +} + +void jps_stopmask(uint32 trackmask) { +/************************************** +**************************************/ + int ii; + for (ii=0;iitracks[ii] != JPS_TRACK_NOT_ASSIGNED) { + // track assigned, increment count + num_channels_assigned++; + } + } + + // try to locate the channel + for (ii=0;iitracks[ii] == channel) { + // was this the only channel alloc'ed? If so, kill the whole playlist + if (num_channels_assigned == 1) { + jps_stop(player); + } else { + // just deassign that track + player->tracks[ii] = JPS_TRACK_NOT_ASSIGNED; + } + return JPS_OK; + } + } + return JPS_ERROR; +} + +uint8 jps_verify_channel_ownership(jps_player *player, uint16 channel) { +/************************************** +** make sure we haven't gotten bounced +** from this channel +**************************************/ + return TRUE; +} + +// +// jps_playlist_in_bank +// determine if given playlist exists in the given bank +// +// in: +// playlist = playlist to search for +// bank = bank to search +// out: +// 0 = not in bank +// global: +// +// GNP 14 May 04 +// +int jps_playlist_in_bank(jps_playlist *playlist, jps_bank *bank) +{ + int ii; + + for (ii=0;ii<(int)(bank->num_playlists);ii++) + { + if (playlist == &(bank->playlists[ii])) + { + return(1); + } + } + +//DONE("jps_playlist_in_bank") + return(0); +} // jps_playlist_in_bank + +// +// jps_stop_bank +// stop all players associated with this bank of sounds +// +// in: +// bank = ptr to sound bank +// out: +// global: +// +// GNP 14 May 04 +// +void jps_stop_bank(jps_bank *bank) +{ + uint32 ii; + + EnterCriticalSection(&jps_player_update_lock); + for (ii=0;iinum_playlists;ii++) + { + if (playlist_num == bank->playlists[ii].num) + { + playlist = &(bank->playlists[ii]); + goto bankd; + } + } // for + } // for + } // !bank +bankd: + + if (!bank) { + msg("jps_play(): invalid bank for sound %d\n",playlist_num); + goto exit; + } + + if(bank && !playlist) + { + // first, find the playlist + for (ii=0;iinum_playlists;ii++) { + if (playlist_num == bank->playlists[ii].num) { + playlist = &(bank->playlists[ii]); + break; + } + } // for + } // !playlist + + if (!playlist) { + msg("jps_play(): ERROR! invalid playlist number %d\n",playlist_num); + goto exit; + } + + // assign a free playlister member... + for (ii=0;iitracks[ii] = -1; + curr_player->playlist = playlist; + curr_player->volume = volume; + curr_player->curr_command = 0; + curr_player->priority = curr_player->playlist->priority; + curr_player->start_time = (float)jps_clock_sec(); + trackmask = jps_assign_channels(curr_player, curr_player->priority, curr_player->playlist->trackmask); + + if (trackmask == 0 && curr_player->playlist->num_tracks != 0) { + jps_stop(curr_player); + goto exit; + } + +#ifdef JPS_START_PLAYLISTER_MANUALLY + jps_player_update(curr_player, 0.0f); +#endif + +exit: + LeaveCriticalSection(&jps_player_update_lock); + return trackmask; // no tracks assigned +} // jps_play() + +uint32 jps_bank_play_vol(char *filename, uint32 playlist_num, int volume) +{ +/************************************** +** play a sound from a bank, using the +** attenuation level passed by the +** user +**************************************/ + uint32 ii,result; + jps_name hash; + jps_bank *bank = NULL; + + if(!playlist_num) + { + jps_stopall_players(); + result=0; + goto BAIL; + } + + + HashFileName(hash, 0,filename); + for (ii=0;iiname,sizeof(jps_name))==0) { + bank = jps_banks[ii]; + break; + } + } + if (bank == NULL) { + msg("jps_bank_play(): ERROR! Bank '%s' not loaded\n",filename); + return 0; + } + result = jps_play(bank, playlist_num, volume); + +BAIL: + return result; +} + +uint32 jps_bank_play(char *filename,uint32 playlist_num) +{ +/************************************** +** play a sound from a bank with +** no attenuation +**************************************/ + return jps_bank_play_vol(filename, playlist_num,JPS_VOL_MAX); +} + +uint32 jps_bank_play_name_vol(char *filename, char *scallname, uint8 atten) { +/************************************** +** we're through!! stop and clean up +**************************************/ + uint32 ii = 0; + jps_name hash= {0}; + jps_bank *bank = NULL; + uint32 scall = 0; + + HashFileName(hash,0,filename); + for (ii=0;iiname,sizeof(jps_name))==0) { + bank = jps_banks[ii]; + break; + } + } + if (bank == NULL) { + msg("jps_bank_play_name(): ERROR! Bank '%s' not loaded\n",filename); + return 0 ; + } + + HashFileName(hash, 0,scallname); + for (ii=0;iinum_playlists;ii++) { + if (memcmp(bank->playlists[ii].name, hash,sizeof(jps_name))==0) { + scall = bank->playlists[ii].num; + break; + } + } + if (ii==bank->num_playlists) { +// msg("jps_bank_play_name(): ERROR! Couldn't find scall named '%s'\n",scallname); + return 0; + } + + return jps_play(bank, scall, atten); +} +uint32 jps_bank_play_name(char *filename, char *scallname) { +/************************************** +** +**************************************/ + return jps_bank_play_name_vol(filename, scallname, JPS_VOL_MAX); +} + +uint32 jps_play_name(char *scallname) { +/************************************** +** +**************************************/ + uint32 ii = 0; + uns32 jj = 0; + int trackmask = 0; + jps_name hash = {0}; + jps_bank *bank = NULL; + uint32 scall = 0; + + HashFileName(hash, 0,scallname); + + for (jj=0;jjnum_playlists;ii++) { + if (memcmp(bank->playlists[ii].name, hash,sizeof(jps_name))==0) { + scall = bank->playlists[ii].num; + break; + } + } + if (ii==bank->num_playlists) { +// msg("jps_bank_play_name(): ERROR! Couldn't find scall named '%s'\n",scallname); + continue; + } + + trackmask = jps_play(bank,scall,JPS_VOL_MAX); + if (trackmask != 0) { + return trackmask; + } + } + return 0; +} + +int32 jps_opcode_func_end (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) { +/************************************** +** we're through!! stop and clean up +**************************************/ + int ii; + // we should only stop and clean up when every channel has stopped playing + for (ii=0;iitracks[ii] != 0xFFFFFFFF) { + if (channel_busy(player->tracks[ii])) { + // something still playing... let's make sure to keep executing + // this command until we're ready + player->curr_command--; + return JPS_OK; + } + } + } + jps_stop(player); + return JPS_OK; +} + +int32 jps_opcode_func_play (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank){ +/************************************** +** play a sound! +**************************************/ + int channel; + jps_args_play *args = (jps_args_play *)command->args; + + if (args->sndbuf == NULL) return JPS_ERROR; + + if (args->num_loops != 1) { + args->sndbuf->looping = TRUE; + } else { + args->sndbuf->looping = FALSE; + } + channel = player->tracks[args->track]; + + if (channel_busy(channel)) { + // if we're a streaming buffer, we don't actually want to STOP + // the playing sound to start the other, we just want to + // shift the stream source + if (jps_channel_data[channel].curr_buf) { + if (!jps_channel_data[channel].curr_buf->streaming) + sound_stop(channel); + } + } + sound_play(args->sndbuf,(uint8)channel); + + return JPS_OK; +} // jps_opcode_func_play() + +jps_sndbuf * jps_group_getsound(jps_group *grp) { +/************************************** +** play a sound at random from a group +**************************************/ + float cdf = 0; // cumulative probability + float prob = rand() / (float) RAND_MAX; + uint32 ii = 0; + uint32 jj = 0; + uint32 kk = 0; + uint32 scall = 0; + + if (grp == NULL) + { + return NULL; + } + + // second step: roll the random number and see where it lands + // the probabilities of occurence for each sound are stored + // as a pdf, so we need to sum the pdf's as we go along to + // find out which sound to select + for (ii=0;iinum;ii++) { + cdf += grp->groupsounds[ii].prob; + if (prob <= cdf) { + // matched probability! + break; + } + } + + if (ii==grp->num) + // probabilities didn't sum up... odd! + return NULL; + + // now test against history buffer + // simplest case, keep adding 1 to the selected + // soundcall until one is found that's not in + // the history buffer + for (jj=0;jjnum;jj++) { + scall = (ii+jj)%grp->num; + for (kk=0;kkbuffer_size;kk++) { + if (scall == grp->buffer[kk]) + // we have run this sound recently, keep trying! + break; + } + if (kk==grp->buffer_size) + // we haven't run THIS sound, this is the one! + break; + } + if (jj==grp->num) + return NULL; + + // add this one to the buffer. note, because the buffer size is + // so small, we're not implementing a circular buffer, we're + // just going to do it the brute-force way + memcpy(&grp->buffer[1],&grp->buffer[0],sizeof(grp->buffer)-sizeof(uint32)); + grp->buffer[0] = scall; + +// printf("snd:%i\n",scall); + return grp->groupsounds[scall].buf; +} + +int32 jps_opcode_func_playgroup (jps_command *command, jps_player *player, + float *curr_time, jps_bank *bank) +{ +/************************************** +** play a sound at random from a group +**************************************/ + jps_args_play *args = (jps_args_play *)command->args; + jps_sndbuf *buf = args->sndbuf; + + if (command->opcode == JPS_OPCODE_PLAYGROUP) { + // select a sound from the specified group at random + // and store the resulting buffer in sndbuf + buf = jps_group_getsound(args->group); + } + + if (!buf) + return JPS_ERROR; + + if (args->num_loops != 1) { + buf->looping = TRUE; + } else { + buf->looping = FALSE; + } + if (channel_busy(player->tracks[args->track])) { +// msg("jps_opcode_func_play(): Warning! Have to stop channel\n"); + sound_stop(player->tracks[args->track]); + } + + sound_play(buf,(uint8)(player->tracks[args->track])); + + return JPS_OK; +} + +int32 jps_opcode_func_waitfor(jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) { +/************************************** +** wait for the end of a sound. +** essentially a nop +**************************************/ + return JPS_OK; +} + +int32 jps_opcode_func_label(jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) { +/************************************** +** this one doesn't really do anything; +** however, the command's arguments +** are used by jump commands, etc. +**************************************/ + return JPS_OK; +} + +int32 jps_opcode_func_signal(jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) { +/************************************** +** wait for the end of a sound. +** essentially a nop +**************************************/ + jps_args_signal *args = (jps_args_signal *)command->args; + + jps_signal_add(args->num); + + return JPS_OK; +} + +int32 jps_opcode_func_marker(jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) { +/************************************** +** wait for the end of a sound. +** essentially a nop +**************************************/ + jps_args_marker *args = (jps_args_marker *)command->args; + + jps_marker_add(args->num); + + return JPS_OK; +} + +int32 jps_opcode_func_goto(jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) { +/************************************** +** this one doesn't really do anything; +** however, the command's arguments +** are used by jump commands, etc. +**************************************/ + uint32 ii; + jps_args_label *label_args = NULL; + jps_args_goto *args = (jps_args_goto *)command->args; + + // look for the companion duck command... + for (ii=0;iiplaylist->num_commands;ii++) { + if (player->playlist->commands[ii].opcode != JPS_OPCODE_LABEL) + continue; + label_args = (jps_args_label *)&player->playlist->commands[ii].args; + if (memcmp(args->name, label_args->name,sizeof(jps_name))==0) { + float diff_time; + // matching loop struct! loopback and bail + diff_time = player->playlist->commands[player->curr_command].time - player->playlist->commands[ii].time; + player->start_time += diff_time; + *curr_time = *curr_time - diff_time; + player->curr_command = ii; + return JPS_OK; + } + } + return JPS_OK; +} + +int32 jps_opcode_func_loopstart (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank){ +/************************************** +** show the beginning of a sound loop +**************************************/ + jps_args_loopstart *args = (jps_args_loopstart *)command->args; + int ii; + + for (ii=0;iiloops[ii].remaining == 0) { + player->loops[ii].remaining = args->remaining; + player->loops[ii].start_command = player->curr_command; + return JPS_OK; + } + } + msg("jps_opcode_func_loopstart(): ERROR! Loop overflow\n"); + return JPS_ERROR; +} + +int32 jps_opcode_func_loopend (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank){ +/************************************** +** seek backwards to matching +** loopstart and set command +**************************************/ + int loopcount = 0; + int32 ii; + int jj; + // look for next loopstart where loopcount == 0 + for (ii=player->curr_command-1;ii>=0;ii--) { + switch (player->playlist->commands[ii].opcode) { + + case JPS_OPCODE_LOOPSTART: + if (loopcount == 0) { + // we have our matching loop! Now find out how many more loops to do + for (jj=0;jjloops[jj].remaining != 0 && player->loops[jj].start_command == (uint32)ii) { + float diff_time; + // matching loop struct! loopback and bail + diff_time = player->playlist->commands[player->curr_command].time - player->playlist->commands[ii].time; + player->start_time += diff_time; + *curr_time = *curr_time - diff_time; + player->curr_command = ii; + player->loops[jj].remaining--; + return JPS_OK; + } + } + msg("ERROR! Couldn't find matching loop struct\n"); + return JPS_ERROR; + } + loopcount--; + break; + + case JPS_OPCODE_LOOPEND: + loopcount++; + break; + } + if (loopcount <0) { + msg("jps_opcode_func_loopend(): ERROR! non-matching loops, ignoring\n"); + } + } + msg("jps_opcode_func_loopend(): ERROR! LOOPEND without matching LOOPSTART... ignoring\n"); + return JPS_ERROR; +} + +int32 jps_alloc_ramp(jps_command *command, jps_player *player, uint16 volume, float ramp_time, uint16 channel) { +/************************************** +** find a free ramp and set 'er up +**************************************/ + int ii; + + for (ii = 0; ii < JPS_NUM_RAMPS; ii++) + { + if (player->ramps[ii].opcode == JPS_RAMP_OPCODE_NONE) + { + jps_ramp_args * ramp_args = (jps_ramp_args*)&player->ramps[ii].args; + + // here's a free one, allocate it + player->ramps[ii].opcode = JPS_RAMP_OPCODE_REG; + player->ramps[ii].obj = JPS_RAMP_OBJ_VOLUME; + ramp_args->start_time = command->time; + ramp_args->finish_time = ramp_time + command->time; + ramp_args->start_amount = jps_channel_data[channel].index; + ramp_args->final_amount = volume; + + if (ramp_args->final_amount > JPS_VOL_MAX) + { + msg("jsp_alloc_ramp: final ramp amount overflow %d\n",ramp_args->final_amount); + ramp_args->final_amount = JPS_VOL_MAX; + } + if (ramp_args->start_amount > JPS_VOL_MAX) + { + msg("jsp_alloc_ramp: start ramp amount overflow %d\n",ramp_args->start_amount); + ramp_args->start_amount = JPS_VOL_MAX; + } + + ramp_args->channel = channel; + return JPS_OK; + } + } + return JPS_ERROR; +} + +int32 jps_opcode_func_setvol (jps_command *command, jps_player *player, + float *curr_time,jps_bank *bank) +{ +/************************************** +** set volume on a track +**************************************/ + int final_volume; + jps_args_setvol *args = (jps_args_setvol *)command->args; + final_volume = (args->volume*player->volume) / JPS_VOL_MAX; + + if (player->tracks[args->track] == JPS_TRACK_NOT_ASSIGNED) + return JPS_ERROR; + + if (args->ramp_time > 0.0f) + { + uint32 result; + result = jps_alloc_ramp(command, player, (uint16)final_volume, args->ramp_time, (uint16)(player->tracks[args->track])); + if (result == JPS_OK) + return JPS_OK; + } + + if(final_volume >= 255) + final_volume = final_volume; + + channel_set_volume(player->tracks[args->track],final_volume); + return JPS_OK; +} + +// +// GNP 12 Apr 04; re-structured to duck track immediately if ramp time = 0 +// +int32 jps_opcode_func_duck (jps_command *command, jps_player *player, + float *curr_time, jps_bank *bank) +{ +/************************************** +** set volume on any track containing +** a specific channel label +**************************************/ + int16 new_volume; + jps_args_duck *args = (jps_args_duck *)command->args; + + new_volume = (jps_channel_data[args->channel].index > args->volume) ? jps_channel_data[args->channel].index - args->volume : 0; + + if (jps_channel_data[args->channel].owner == NULL) + { + // no channel playing... ignore duck command + return JPS_OK; + } + + // MAN 29 JAN 08 + + if(jps_channel_data[args->channel].ducked == CHANNEL_DUCKED) + return JPS_OK; + + // - if we are trying to duck a channel that is currently un-ducking, + // the volume change needs to be calculated from where the channel will be + // when the un-ducking is complete. otherwise, the volume will be + // artificially lower. + + if (jps_channel_data[args->channel].ducked == CHANNEL_UNDUCK_REQUEST) + new_volume = (jps_channel_data[args->channel].duckIndex > args->volume) ? jps_channel_data[args->channel].duckIndex - args->volume : 0; + else + jps_channel_data[args->channel].duckIndex = jps_channel_data[args->channel].index; + + if (args->ramp_time > 0.0f) + jps_alloc_ramp(command, player, new_volume, args->ramp_time, args->channel); + else + channel_set_volume(args->channel,new_volume); + + jps_channel_data[args->channel].ducked = CHANNEL_DUCKED; + + return JPS_OK; +} + +int32 jps_opcode_func_unduck (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) +{ +/************************************** +** restore volumes from a duck command +**************************************/ + jps_args_unduck *args = (jps_args_unduck *)command->args; + jps_args_duck *duck_args = NULL; + uint16 new_volume = 0; + int ii = 0; + + if(jps_channel_data[args->channel].ducked == CHANNEL_UNDUCKED) + return JPS_OK; + + // look for the companion duck command... + for (ii=player->curr_command-1; ii >= 0; ii--) + { + if (player->playlist->commands[ii].opcode != JPS_OPCODE_DUCK) + continue; + + duck_args = (jps_args_duck *)&player->playlist->commands[ii].args; + if(!duck_args) + { + msg("jps_opcode_func_unduck(): ERROR! Couldn't find duck args\n"); + return JPS_ERROR; + } + if (args->channel == duck_args->channel) + { + // found it... + break; + } + } + + if (ii < 0) + { + msg("jps_opcode_func_unduck(): ERROR! Couldn't find matching duck call\n"); + return JPS_ERROR; + } + + new_volume = jps_channel_data[args->channel].duckIndex;// + duck_args->volume; + if (new_volume > JPS_VOL_MAX) + new_volume = JPS_VOL_MAX; + + if (args->ramp_time > 0.0f) + { + //put up a request for unducking, when the ramp is done, it will clear the duck flag + jps_channel_data[args->channel].ducked = CHANNEL_UNDUCK_REQUEST; + jps_alloc_ramp(command, player, new_volume, args->ramp_time, args->channel); + } + else + { + jps_channel_data[args->channel].ducked = CHANNEL_UNDUCKED; + channel_set_volume(args->channel,new_volume); + } + + return JPS_OK; +} + +int32 jps_opcode_func_stop (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) +{ +/************************************** +** stop sound +**************************************/ + jps_args_stop *args = (jps_args_stop *)command->args; + + sound_stop(player->tracks[args->track]); + + return JPS_OK; +} + +int32 jps_assign_channels(jps_player *player, uint16 priority, uint32 track_mask) { +/************************************** +** find some free, contiguous channels +** for our playlister. +**************************************/ + uint32 ii; + uint32 jj; + uint32 trackmask = 0; + int oldest = -1; + + // look for a free set of tracks first... + for (ii=0;iiplaylist->num_tracks+1;ii++) { + if ((track_mask &(1<playlist->num_tracks;jj++) { + if (jps_channel_data[jj+ii].owner != NULL) { + break; + } + } + if (jj == player->playlist->num_tracks) { + goto assignexit; + } + } + + // todo: less priority + for (ii=0;iiplaylist->num_tracks+1;ii++) { + if ((track_mask &(1<playlist->num_tracks;jj++) { + if (jps_channel_data[jj+ii].priority >= player->priority) { + break; + } + } + if (jj == player->playlist->num_tracks) { + goto assignexit; + } + } + + // todo: oldest equal priority + for (ii=0;iiplaylist->num_tracks+1;ii++) { + if ((track_mask &(1<playlist->num_tracks;jj++) { + if (jps_channel_data[jj+ii].priority > player->priority) { + break; + } + } + if (jj == player->playlist->num_tracks) { + if (oldest == -1) { + oldest = ii; + } else if (jps_channel_data[oldest].owner->start_time>jps_channel_data[ii].owner->start_time) { + oldest = ii; + } + } + } + if (oldest == -1) { + goto errorexit; + } else { + ii = oldest; + goto assignexit; + } + +assignexit: +// msg("%i\n",ii); + for (jj=0;jjplaylist->num_tracks;jj++) { + jps_unassign_channel(jps_channel_data[jj+ii].owner, (uint16)(ii+jj)); + jps_channel_data[jj+ii].owner = player; + jps_channel_data[jj+ii].priority = priority; + player->tracks[jj] = jj+ii; + trackmask |= 1<<(jj+ii); + } + return trackmask; +errorexit: +// msg("jps_opcode_func_assign(): ERROR! Couldn't assign channel!!\n"); + for (jj=0;jjplaylist->num_tracks;jj++) { + player->tracks[ii+jj] = JPS_TRACK_NOT_ASSIGNED; + } + + return 0; + +} + +uint8 jps_player_conditional_met(jps_command *command, jps_player *player) { +/************************************** +** +**************************************/ + if (command->flags == 0) + return TRUE; + + if (command->flags&JPS_COMMAND_FLAG_ONMARKER) { + // did we receive a marker? + if (jps_marker_test((uint16)(command->flags>>16))) { + return TRUE; + } + } + return FALSE; +} + +// JFL 20 Jul 04 +int jps_streamfix(void) +{ + int i,j; + jps_bank *bank; + jps_sndbuf *buf; + int fixed=0; + + for (i=0;isndbufs)) + continue; + for(j=0;j<(int)(bank->num_sndbufs);j++,buf++) + { + // only care about open files + if(!buf->file_pointer) + continue; + + // extern PCFM_BUFFER pcfm_buf[]; + // flags & (PBF_HOLD|PBF_UNUSABLE) + // this clears the (possible) hold on the sector buffer's + // caused by reading/writing an open file and leaving it open + jps_fseek(buf->file_pointer,0,SEEK_CUR); + fixed++; + + } // for + } // for + + return fixed; +} // jps_streamfix() + +// EOF \ No newline at end of file diff --git a/libraries/pmrt/jpsnd/jps_player.h b/libraries/pmrt/jpsnd/jps_player.h new file mode 100755 index 0000000..470b691 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps_player.h differ diff --git a/libraries/pmrt/jpsnd/jps_player.o b/libraries/pmrt/jpsnd/jps_player.o new file mode 100644 index 0000000..5e23ba9 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps_player.o differ diff --git a/libraries/pmrt/jpsnd/jps_snd.o b/libraries/pmrt/jpsnd/jps_snd.o new file mode 100644 index 0000000..84fae48 Binary files /dev/null and b/libraries/pmrt/jpsnd/jps_snd.o differ diff --git a/libraries/pmrt/jpsnd/jpsdefs.h b/libraries/pmrt/jpsnd/jpsdefs.h new file mode 100755 index 0000000..b4db27f --- /dev/null +++ b/libraries/pmrt/jpsnd/jpsdefs.h @@ -0,0 +1,439 @@ +#ifndef JPSDEFS_H_ +#define JPSDEFS_H_ +/************************************************ +** jpsdefs.h +** +** inteface to the +** +************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef JPS_FILE +// when used in the outside world, this is a void* +#define JPS_FILE void +#endif // ndef JPS_FILE + +#define JPS_NUM_CHANNELS (8) +#define NUM_CHANNELS JPS_NUM_CHANNELS +#define JPS_OK 0 +#define JPS_ERROR -1 +#define JPS_NUM_PLAYERS (JPS_NUM_CHANNELS * 2) +#define ALWAYS_STREAM 0 +#define JPS_MAX_BANKS (32) +#define JPS_TRACK_NOT_ASSIGNED (-1) +#define JPS_TRACK_DYNAMIC (-1) +#define JPS_BUFFER_BYTE_ALIGN 16 // alignment for UDMA usage + +#define JPS_COMMAND_FLAG_ONMARKER 0x0001 + +// for some reason, dlytsk() doesn't wake my procs back up. +// sooo... do this, which might cause deadlock issues + // should the update_thread decide to wake back up +#define JPS_START_PLAYLISTER_MANUALLY 1 + +#define TRACK_0 0 +#define TRACK_1 1 +#define TRACK_2 2 +#define TRACK_3 3 +#define TRACK_4 4 +#define TRACK_5 5 +#define TRACK_6 6 +#define TRACK_7 7 +#define TRACK_8 8 +#define TRACK_9 9 +#define TRACK_10 10 +#define TRACK_11 11 +#define TRACK_12 12 +#define TRACK_13 13 +#define TRACK_14 14 +#define TRACK_15 15 + +#define JPS_VOL_MAX 255 +#define JPS_VOL_MIN 0 + +#if SYS_PC|SYS_BB +#define JPS_AUTOSTREAM 1 +#define STREAM_UPDATE_MIN_SIZE (0x0) +#define STREAM_BUFFER_SIZE (0x10000) +#define STREAM_SIZE_THRESHOLD (0x200000) +#endif +#if SYS_5500 +#define STREAM_UPDATE_MIN_SIZE (0x1000) +#define STREAM_BUFFER_SIZE (0x40000) // must be power of 2 +#define STREAM_SIZE_THRESHOLD (0x40000) +#define JPS_SIMULATE_MONO 0 +#endif + +#define JPS_STREAM_YES 1 +#define JPS_STREAM_NO 0 +#define JPS_STREAM_AUTO 2 + +typedef uns32 jps_name[2]; + +typedef struct transition_s +{ + void *event; + struct jps_sndbuf_s *next_buf; + unsigned long next_buf_position; + void *transition_graph; + struct transition_s *next_trans; +} transition; + +// audio files are parsed into this structure. +typedef struct jps_sndbuf_s +{ + jps_name name; // sound buffer file name + uns32 numbytes; // size IN BYTES of sample data + uns8 looping; // looping + uns8 streaming; // streaming + uns8 playflags; // flags -- cleared each time sound is started + uns8 allocated; // buffer was allocated & needs to be freed + uns16 channel_num; // where are we playing? + uns8 nChannels; // format + uns32 nSamplesPerSec; // format + uns32 nAvgBytesPerSec; // format + uns8 nBlockAlign; // format + uns8 nBitsPerSample;// format + void *data; // actual sample data + + // streaming info + char file_path[256]; + uns32 databufsize; // guaranteed power of 2 if streaming + uns32 dest_offset; // where we last put data in the hdw buf + uns32 finishzeros; // how many zeros have been copied + JPS_FILE *file_pointer; // file pointer (if streaming) + uns32 file_curpos; // where we are in the audio file + uns32 file_hdrpos; // offset in file to where the audio begins + uns32 file_endpos; // one past end of data +} jps_sndbuf; + +#define M_SNDBUF_PLAYING 0x01 // sound buffer is playing +#define M_SNDBUF_HITDATAEND 0x02 // end of buffer +#define M_SNDBUF_FINISHSTOP 0x04 // dont load any more +#define M_SNDBUF_ERR 0x80 // sound buffer is in some kind of error state -- don't play anymore, kill + +// data for the actual audio hardware channels - +// what they should be playing, at what volume, +// the label. +typedef struct jps_channel_s { + jps_name label; // channel label for reference by playlists + jps_sndbuf *curr_buf; // currently-playing buffer + jps_sndbuf *next_buf; // next buffer to play (for seamless transitions) MAY NOT USE + struct jps_player_s *owner; // are we 0WN3D (allocated?) + int volume; // stored as db in linux, index in dx + uns16 pan; + uns16 priority; + uns16 index; // 0-255 + uns16 ducked; + uns16 duckIndex; //original index before duckingzz + uns16 reserved; +} jps_channel; + +#define JPS_ARGS_MAX (64) + +// the commands to be executed by the playlister; +// for example, PLAY, STOP, LOOPSTART +typedef struct jps_command_s { + uns32 opcode; // used to identify command and index into array of fxn ptrs + float time; // the time at which the playlister should execute this command + uns32 flags; // conditional/random/etc modifiers to opcode + uns8 args[JPS_ARGS_MAX]; // plenty of scratch space for arguments +} jps_command; + +// a playlist is a collection of commands to be +// executed by the playlister +typedef struct jps_playlist_s { + jps_name name; + uns32 num; + jps_command *commands; // location of the start of the playlist commands + uns32 num_commands; + uns32 num_tracks; // how many tracks does this playlist require? + uns16 trackmask; // what possible tracks should this playlist land on? + uns16 priority; // what priority level should every sound on this playlist have? +} jps_playlist; + +typedef struct jps_groupsound_s { + jps_sndbuf *buf; + float prob; // probability that it will be selected +} jps_groupsound; + +#define JPS_MAX_HISTORY 10 + +typedef struct jps_group_s { + jps_name name; // the name of the group + jps_groupsound *groupsounds; // pointer to location in the groupsounds array + uns32 num; + uns32 buffer_size; + uns32 buffer[JPS_MAX_HISTORY]; +} jps_group; + +#define JPS_BANK_FLAG_VOL_ATTEN 0x1 +// bank information, parsed from the bank file. +// contains everything necessary to play sounds: +// banks, and playlists consisting of commands +typedef struct jps_bank_s { + jps_name name; // bank file name + char nameStr[32]; // string name + uns32 flags; // any sorts of playlist conventions + jps_sndbuf *sndbufs; // pointer to array of sound buffer information for this bank + void *rawSndbufs; // raw version of above + uns32 num_sndbufs; // number of loaded sound buffers + uns32 max_sndbufs; // maximum number of sound buffer data allocated + jps_playlist *playlists; // pointer to array of playlist information + void *rawPlaylists; // raw version of above + uns32 num_playlists; // number of playlists loaded + uns32 max_playlists; // max number of playlists allocated + jps_command *commands; // pointer to command data for all playlists + void *rawCommands; // raw version of above + uns32 num_commands; // number of commands loaded + uns32 max_commands; // max number of commands loaded + jps_group *groups; + void *rawGroups; // raw version of above + uns32 num_groups; + uns32 max_groups; + jps_groupsound *groupsounds; + void *rawGroupsounds; // raw version of above + uns32 num_groupsounds; + uns32 max_groupsounds; + void *rawBank; // raw ptr to this bank +} jps_bank; + +#define JPS_NUM_RAMPS (10) +#define JPS_RAMP_ARGS_MAX (32) + +typedef enum { + JPS_RAMP_OPCODE_NONE, + JPS_RAMP_OPCODE_REG, +} jps_ramp_opcode; + +typedef enum { + JPS_RAMP_OBJ_VOLUME, + JPS_RAMP_OBJ_PAN, +} jps_ramp_obj; + +typedef struct jps_ramp_args_s { + float start_time; + float finish_time; + int32 start_amount; + int32 final_amount; + uns16 channel; // NOTE: NOT track + uns16 filler; +} jps_ramp_args; + +typedef struct jps_ramp_s { + jps_ramp_opcode opcode; // what type of ramp are we doing? + jps_ramp_obj obj; // what type of obj are we ramping? + uns32 num; // which of those objs are we ramping? + uns8 args[JPS_RAMP_ARGS_MAX]; // plenty of scratch space for arguments +} jps_ramp; + +// this is the max number of loops supported within a playlist. +// 16 should be WAY more than enough +#define JPS_NUM_LOOPS (16) + +typedef struct jps_loop_s { + uns32 start_command; // location of loopstart opcode + uns32 remaining; // how many loops remain? +} jps_loop; + +// the jps_player is used for each instance +// a playlist is played +typedef struct jps_player_s { + jps_playlist *playlist; // currently playing playlist + float start_time; // when did we start? +// float last_time; // we need to HOW MANY commands to execute next + uns32 curr_command; // where are we? + int32 tracks[JPS_NUM_CHANNELS]; // track->channel mapping (-1 if not alloc'ed) + uns16 priority; // how important is this player? + jps_ramp ramps[JPS_NUM_RAMPS]; // different ramp modifiers for playlist channels + jps_loop loops[JPS_NUM_LOOPS]; // loop counters + uns32 track_mask; // what are acceptable values for a start track? + uns32 volume; // what's our default vol? +} jps_player; + +// the opcode-parsing function needs to be able to reference +// the player struct to see on which channel to place +// a sound for playing. it needs the bank stuct so it can +// see where the sound buffers are +#define JPS_OPCODE_FUNC(x) int32 (x) (jps_command *command, jps_player *player, float *curr_time, jps_bank *bank) +typedef JPS_OPCODE_FUNC(*jps_opcode_func); +JPS_OPCODE_FUNC(jps_opcode_func_assign); +JPS_OPCODE_FUNC(jps_opcode_func_play); +JPS_OPCODE_FUNC(jps_opcode_func_stop); +JPS_OPCODE_FUNC(jps_opcode_func_end); +JPS_OPCODE_FUNC(jps_opcode_func_setvol); +JPS_OPCODE_FUNC(jps_opcode_func_loopstart); +JPS_OPCODE_FUNC(jps_opcode_func_loopend); +JPS_OPCODE_FUNC(jps_opcode_func_duck); +JPS_OPCODE_FUNC(jps_opcode_func_unduck); +JPS_OPCODE_FUNC(jps_opcode_func_waitfor); +JPS_OPCODE_FUNC(jps_opcode_func_setpan); +JPS_OPCODE_FUNC(jps_opcode_func_setfreq); +JPS_OPCODE_FUNC(jps_opcode_func_signal); +JPS_OPCODE_FUNC(jps_opcode_func_goto); +JPS_OPCODE_FUNC(jps_opcode_func_gosub); +JPS_OPCODE_FUNC(jps_opcode_func_label); +JPS_OPCODE_FUNC(jps_opcode_func_marker); +JPS_OPCODE_FUNC(jps_opcode_func_playgroup); +typedef struct jps_opcode_table_s { + uns32 opcode; + jps_opcode_func func; +} jps_opcode_table; + + +#define JPS_PARSE_FUNC(x) int32 (x) (JPS_FILE *fp, char *currdata, jps_bank *bank, jps_command *cmd, float *time) +typedef JPS_PARSE_FUNC(*jps_parse_func); +JPS_PARSE_FUNC(jps_parse_func_playlist); +JPS_PARSE_FUNC(jps_parse_func_group); +JPS_PARSE_FUNC(jps_parse_func_group_sound); +JPS_PARSE_FUNC(jps_parse_func_group_end); +JPS_PARSE_FUNC(jps_parse_func_end); +JPS_PARSE_FUNC(jps_parse_func_assign); +JPS_PARSE_FUNC(jps_parse_func_play); +JPS_PARSE_FUNC(jps_parse_func_plays); +JPS_PARSE_FUNC(jps_parse_func_stop); +JPS_PARSE_FUNC(jps_parse_func_setvol); +JPS_PARSE_FUNC(jps_parse_func_loopstart); +JPS_PARSE_FUNC(jps_parse_func_loopend); +JPS_PARSE_FUNC(jps_parse_func_duck); +JPS_PARSE_FUNC(jps_parse_func_unduck); +JPS_PARSE_FUNC(jps_parse_func_waitfor); +JPS_PARSE_FUNC(jps_parse_func_setpan); +JPS_PARSE_FUNC(jps_parse_func_setfreq); +JPS_PARSE_FUNC(jps_parse_func_signal); +JPS_PARSE_FUNC(jps_parse_func_goto); +JPS_PARSE_FUNC(jps_parse_func_gosub); +JPS_PARSE_FUNC(jps_parse_func_label); +JPS_PARSE_FUNC(jps_parse_func_marker); +JPS_PARSE_FUNC(jps_parse_func_playgroup); +JPS_PARSE_FUNC(jps_parse_func_vol_atten); +JPS_PARSE_FUNC(jps_parse_func_vol_gain); +JPS_PARSE_FUNC(jps_parse_func_constant); + +typedef struct jps_parse_table_s{ + char command[20]; + uns32 opcode; + jps_parse_func func; +} jps_parse_table; + +// these opcodes need to be synchronized with the list of function pointers +typedef enum jps_opcodes_e { + JPS_NOTACOMMAND=0, + JPS_OPCODE_END, + JPS_OPCODE_PLAY, + JPS_OPCODE_STOP, + JPS_OPCODE_SETVOL, + JPS_OPCODE_LOOPSTART, + JPS_OPCODE_LOOPEND, + JPS_OPCODE_DUCK, + JPS_OPCODE_UNDUCK, + JPS_OPCODE_WAITFOR, + JPS_OPCODE_SETPAN, + JPS_OPCODE_SETFREQ, + JPS_OPCODE_SIGNAL, + JPS_OPCODE_GOTO, + JPS_OPCODE_GOSUB, + JPS_OPCODE_LABEL, + JPS_OPCODE_MARKER, + JPS_OPCODE_PLAYGROUP, +} jps_opcodes; + +extern jps_opcode_table jps_funcs[]; + +typedef struct jps_args_play_s { + jps_group* group; // for groupplay opcode + jps_sndbuf* sndbuf; // for play opcode + uns8 track; + uns32 num_loops; +} jps_args_play; + +typedef struct jps_args_stop_s { + uns8 track; +} jps_args_stop; + +typedef struct jps_args_setvol_s { + uns8 track; + uns16 volume; + float ramp_time; +} jps_args_setvol; + +typedef struct jps_args_setpan_s { + uns8 track; + uns16 pan; + float ramp_time; +} jps_args_setpan; + +typedef struct jps_args_setfreq_s { + uns8 track; + uns16 freq; + float ramp_time; +} jps_args_setfreq; + +typedef struct jps_args_loopstart_s { + uns32 remaining; +} jps_args_loopstart; + +typedef struct jps_args_duck_s { + uns16 channel; + uns16 volume; + float ramp_time; +} jps_args_duck; + +typedef struct jps_args_unduck_s { + uns16 channel; + float ramp_time; +} jps_args_unduck; + +typedef struct jps_args_waitfor_s { + uns8 track; +} jps_args_waitfor; + +typedef struct jps_args_goto_s { + jps_name name; +} jps_args_goto; + +typedef struct jps_args_label_s { + jps_name name; +} jps_args_label; + +typedef struct jps_args_signal_s { + uns16 num; +} jps_args_signal; + +typedef struct jps_args_marker_s { + uns16 num; +} jps_args_marker; + +extern int jps_init(); +extern void jps_master_volume(int volume); +extern uns32 jps_play(jps_bank *bank, uns32 playlist_num, int volume); +extern uns32 jps_bank_play(char *filename, uns32 playlist_num); +extern uns32 jps_bank_play_name(char *filename, char *scallname); +extern uns32 jps_bank_play_vol(char *filename, uns32 playlist_num, int volume); +extern uns32 jps_play_name(char *scallname); +extern void jps_version(uns32 *pMajor, uns32 *pMinor, uns32 *pSubMinor); +extern void jps_update_all(jps_player *player); +extern void jps_player_update(jps_player *player, float curr_time); +extern void *jps_memalloc(void **raw_ptr, uns32 alignbound, uns32 size); +extern void jps_memfree(void *raw_ptr); +extern jps_bank * jps_bank_load(char *filename); + +extern jps_channel jps_channel_data[JPS_NUM_CHANNELS]; +extern jps_player jps_players[JPS_NUM_PLAYERS]; +extern void jps_stop(jps_player *player); +extern jps_bank *jps_banks[JPS_MAX_BANKS]; +extern void jps_parse_channels(char *filename, jps_channel *data); +extern void jps_bank_free(jps_bank *bank); +extern int jps_shutdown(void); +extern void jps_stopall_players(); + +extern int jps_sndmem_alloc_count; +extern int jps_sndmem_alloc_size; + +#ifdef __cplusplus +} +#endif + +#endif // !JPSDEFS_H_ diff --git a/libraries/pmrt/jpsnd/jpsdrvr.h b/libraries/pmrt/jpsnd/jpsdrvr.h new file mode 100755 index 0000000..af01eb0 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpsdrvr.h @@ -0,0 +1,64 @@ +/************************************************ +** jpsdrvr.h +** +************************************************/ + +#ifndef __JPSDRVR_H +#define __JPSDRVR_H 1 + +#if __cplusplus +extern "C" { +#endif + +#define MINOR_VERSION 9 // reflects both drivers + +#if SYS_PC +#define SUBMINOR_VERSION 2 +#endif // SYS_PC +#if SYS_BB +#define SUBMINOR_VERSION 2 +#endif // SYS_BB + +#define MAX_JPS_SNDBUFS (128) + +int sound_play(jps_sndbuf *,uint16 ii); +int jpsdrvr_init(); +void jpsdrvr_shutdown(); +int sound_transition(jps_sndbuf *next_buf, int channel_num); +int sound_transition_instant(jps_sndbuf *next_buf, int channel_num); +int sound_stop (int channel_num); +int sound_stopbuf(jps_sndbuf *sbuf); +int sound_start (jps_sndbuf *sbuf); +int channel_set_volume (int channel_num, int volume); +int free_buffers(jps_sndbuf * buffer_to_kill); + +// THIS SHOULD BE UNIFIED AND PUT IN JPS_SND +int copy_to_dsbuf(jps_sndbuf *buf,int size,int *copiedp); +int channel_set_freq (int channel_num, int detune); +int channel_busy (int channel_num); +jps_sndbuf * jps_sndbuf_malloc(void); +extern int create_and_preload_buffer(wavinfo *wavhdr, jps_sndbuf * new_buf); +extern int jpsdrvr_stream_ok(void); + +int jpsdrvr_GetCurrentPosition(jps_sndbuf *this_buf,uint32 *play_position); +int jpsdrvr_Unlock(jps_sndbuf *buf,void *buf_ptr1, uint32 buf_len1, + void *buf_ptr2, uint32 buf_len2); +int jpsdrvr_Lock(jps_sndbuf *snd_buf, uint32 dest_offset, + uint32 bytes_to_copy,void **buf_ptr1, uint32 *buf_len1, + void **buf_ptr2, uint32 *buf_len2); + +#if SYS_PC +extern void jps_update_thread(void *dummy); +#endif // SYS_PC +#if SYS_BB +#endif // SYS_BB +#if SYS_5500 +extern TASKFUNCTION jps_update_thread(void); +extern TASKFUNCTION jps_stream_update_thread(void); +#endif // SYS_5500 + +#if __cplusplus +} +#endif + +#endif diff --git a/libraries/pmrt/jpsnd/jpsdrvr_5500.c b/libraries/pmrt/jpsnd/jpsdrvr_5500.c new file mode 100755 index 0000000..f608ca6 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpsdrvr_5500.c @@ -0,0 +1,1080 @@ +#if SYS_5500 + +// warning -- changes have been made to keep this file close to the other +// driverss, but since this file hasn't been built and tested, there will +// need to be some time spent getting this working again + +/************************************** +** +** jpsdrvr_5500.c +** +** system specific sound routines +** +** Andrew Eloff; RAW THRILLS / PLAY MECHANIX +** JFL 20 Jul 04 +** +**************************************/ + +#include +#include +#include +#include +#include +#include +#include "vp100.h" +#include "jp5500.h" +#include "jps.h" +#include "jpsdrvr_5500.h" +#include "ac97.h" +#include "onintr_5500.h" +#include "int_5500.h" +#include "jps_volume.h" +#define SND_INT_INTERRUPT_BIT (8+MIPS_INT_SOUNDDMA) +#define SND_INT_INTERRUPT_MASK (1 << SND_INT_INTERRUPT_BIT) + +#define HARDWARE_LOOPING 1 + +#if VOLUME_16BIT +#define LOOP_FLAG 0x10000 +#define HALF_RATE_FLAG 0x20000 +#else +#define LOOP_FLAG 0x100 +#endif + +uint32 dma_adr[JPS_NUM_CHANNELS]; +volatile uint32 dma_len[JPS_NUM_CHANNELS]; +volatile uint32 dma_flg[JPS_NUM_CHANNELS]; +uint32 dma_max[JPS_NUM_CHANNELS]; +uint8 dma_per[JPS_NUM_CHANNELS]; + +// +// jpsdrvr_stream_ok +// determine if hardware streaming is allowed +// +// in: +// out: +// global: +// +// GNP 30 Oct 03 +// +int jpsdrvr_stream_ok(void) +{ + if(GetGfxRev() >= VP100_REV_AUDIOSTREAM) + return(1); + else + return(0); +//DONE("jpsdrvr_stream_ok") +} // jpsdrvr_stream_ok + +TASKFUNCTION jps_update_thread(void) +{ + while (1) { + jps_update_all(jps_players); + dlytsk(cur_task,DLY_TICKS,1); + } +} + +TASKFUNCTION jps_stream_update_thread(void) { +/************************************** +** +**************************************/ + while(1) { + jps_update_streams(); + dlytsk(cur_task, DLY_TICKS,1); + } +} + +//#define DBG_DISPLAY_TIME 1 +time_t jps_clock() +{ +/************************************** +** simulate ANSI clock() function +** note: this function has a big +** caveat - since it depends on a +** counter that overflows every 20s or +** so, this clock function needs to be +** accessed within this time to avoid +** time aliasing +**************************************/ +#if DBG_DISPLAY_TIME +#define DISPLAY_TIME_INCR 1.0f + static float last_displayed_time = 0.00f; +#endif + static time_t jps_clock_time = 0; + static uint32 last_pClock = 0; + uint32 curr_pClock = (uint32)getCount(); + curr_pClock = curr_pClock / pClock2uSec; + + // unwrap wrapped #pClock# if necessary + if (curr_pClock < last_pClock) + { +#if 0 + // AWE DEBUG: THESE WRAPS ARE USUALLY SPURIOUS - IGNORE + jps_clock_time += 0xFFFFFFFF-(curr_pClock-last_pClock); +#endif + } else + { + jps_clock_time += (curr_pClock-last_pClock); + } + last_pClock = curr_pClock; + +#if DBG_DISPLAY_TIME + if (jps_clock_time/(float)JPS_CLOCKS_PER_SEC - last_displayed_time >=DISPLAY_TIME_INCR) { + msg("t%f\n",jps_clock_time/(float)JPS_CLOCKS_PER_SEC); + last_displayed_time = jps_clock_time/(float)JPS_CLOCKS_PER_SEC; + } +#endif + return(jps_clock_time); +} + +int snd_ac97_write(uint16 addr, uint16 data) { +/************************************** +** write data to a register on the +** AC97 chip +**************************************/ + *JP_AC97_LINKADDR = addr; + *JP_AC97_LINKSTART = 0x0; + *JP_AC97_LINKWR = data; + + // wait for return status; + { + int start_time = jps_clock(); + while((*JP_AC97_LINKSTART)) { + if (jps_clock()-start_time > JPS_CLOCKS_PER_SEC*1) { + msg("snd_init(): ERROR! timeout waiting for ok\n"); + return -1; + } + } + } + + return 0; +} + +int snd_ac97_read(uint16 addr, uint16 *data) { +/************************************** +** read data from a register on the +** AC97 chip +**************************************/ + + *JP_AC97_LINKADDR = addr|JP_AC97_LINKADDR_RD; + *JP_AC97_LINKSTART = 0x0; // start state machine + + // wait for return status; + { + int start_time = jps_clock(); + while((*JP_AC97_LINKSTART)) { + if (jps_clock()-start_time > JPS_CLOCKS_PER_SEC*1) { + msg("snd_init(): ERROR! timeout waiting for ok\n"); + return -1; + } + } + } + *data = *JP_AC97_LINKRD; + return 0; +} + +void snd_wait(float sec) +{ + uint32 start_time = jps_clock(); + uint32 curr_time = start_time; + while (curr_time-start_time < JPS_CLOCKS_PER_SEC*sec){ + curr_time = jps_clock(); + } +} // snd_wait() + +void snd_ac97_regdump() { +/************************************** +** dump out register values +**************************************/ + uint16 data; + uint16 ii; + + for (ii=0;ii<0x32;ii+=2) { + snd_ac97_read(ii,&data); + msg("[0x%02x]:0x%08x\n",ii,data); + } + ii = 0x5E; + snd_ac97_read(ii,&data); + msg("[0x%02x]:0x%08x\n",ii,data); + ii = 0x60; + snd_ac97_read(ii,&data); + msg("[0x%02x]:0x%08x\n",ii,data); + ii = 0x68; + snd_ac97_read(ii,&data); + msg("[0x%02x]:0x%08x\n",ii,data); +} + +// JFL 18 Jul 04; cleanup +int jpsdrvr_GetCurrentPosition(jps_sndbuf *this_buf,uint32 *play_position) +{ + jps_snddata *data = this_buf->data; + uint32 dma,buf; + + *play_position = 0; + + if (!this_buf->data) + return JPS_OK; + + // get the current address the DMA is playing at, then the offset + dma = (uint32)*SNDDMA_ADDR(this_buf->channel_num) & 0x1fffffff; + buf = (uint32)data->buf & 0x1fffffff; + + // allow dma to be a sample below the buffer in case we catch it + // during the restarting of the loop + if(dma=buf) + *play_position=0; + else + *play_position=dma-buf; + + // make sure DMA is playing in our buffer + if (*play_position >= this_buf->databufsize) + { + // quick stop + *SNDDMA_INT_MASK &= ~(0x1<<(this_buf->channel_num)); + *SNDDMA_ENABLE &= ~(0x01<<(this_buf->channel_num)); + msg("jpsdrvr_GetCurrentPosition() (dma=%08X buf=%08X)\n",dma,data->buf); + *play_position=0; + return JPS_ERROR; + } // in the buffer + + return JPS_OK; +} // jpsdrvr_GetCurrentPosition() + +// JFL 18 Jul 04; stream buffers are powers of 2 +int create_and_preload_buffer(wavinfo *wavhdr, jps_sndbuf *new_buf) { +/************************************** +** create a sound buffer +**************************************/ + uint32 dsbuf_size; + jps_snddata *data = NULL; + + new_buf->looping = FALSE; + new_buf->clone = FALSE; + new_buf->trans.event = NULL; + + if (new_buf->streaming) + { + new_buf->numbytes = wavhdr->Size3; // start with size of sound + dsbuf_size = 256; // smallest buffer we'll alloc (power of 2) + + // find smallest power of 2 buffer size + while(dsbuf_sizenumbytes) + dsbuf_size<<=1; + + // limit buffer + if(dsbuf_size>databufsize) + dsbuf_size=databufsize; + + new_buf->databufsize = dsbuf_size; + } + else + { + dsbuf_size = wavhdr->Size3; +#if JPS_SIMULATE_MONO + // we need to create a stereo file, so + // we need to double the reported size in bytes + // of the wav file. + // be sure to indicate that we're only single channel + // until we've finished loading the sound data + if (new_buf->num_channels == 1) { + dsbuf_size *= 2; + } +#endif + new_buf->numbytes = dsbuf_size; + } + if (snd_buffer_create(new_buf, dsbuf_size) == NULL) { + return JPS_ERROR; + } + + data = new_buf->data; + + // reset the file pointer so it's pointing to the beginning of the file + new_buf->file_curpos = new_buf->file_hdrpos; + new_buf->file_endpos = new_buf->file_hdrpos+new_buf->numbytes; + + if(jps_fseek((new_buf)->file_pointer,(new_buf)->file_curpos,SEEK_SET)) + { + msg("create_and_preload_buffer() jps_fseek err\n"); + goto errexit; + } + + // handle not streaming + if(!(new_buf->streaming)) + { +#if JPS_SIMULATE_MONO + // if we're mono, we're going to write 2x the data read until we fill it + if (new_buf->num_channels == 1) { + int ii; + uint16 *buf16 = (uint16 *)data->buf; + jps_fread(buf16,dsbuf_size/2,1,new_buf->file_pointer); + #error -- check this.. + for (ii=(dsbuf_size/2/2)-1;ii>=0;ii--) { + buf16[ii*2] = buf16[ii*2+1] = buf16[ii]; + } + // we're a 2-channel buffer now! + new_buf->num_channels = 2; + } else +#endif // JPS_SIMULATE_MONO + if(1!=jps_fread(data->buf,dsbuf_size,1,new_buf->file_pointer)) + { + msg("create_and_preload_buffer() jps_fread err\n"); + goto errexit; + } + } // !streaming + + return JPS_OK; +errexit: + return JPS_ERROR; +} // create_and_preload_buffer() + +jps_sndbuf * snd_buffer_create(jps_sndbuf *snd_buf, uint32 size) { +/************************************** +** create a sound buffer +**************************************/ + jps_snddata *dsBuf=NULL; + + if (snd_buf == NULL) { + msg("snd_buffer_create(): ERROR! Must pass non-null jps_sndbuf*\n"); + return NULL; + } + + snd_buf->data = jps_memalloc(NULL,0,sizeof(jps_snddata)); + if (snd_buf->data == NULL) { + msg("snd_buffer_create(): ERROR! Couldn't alloc sound buffer data\n"); + return NULL; + } + dsBuf = (jps_snddata*)snd_buf->data; + + dsBuf->buf = jps_memalloc(&dsBuf->buf_raw,128,size); + if (dsBuf->buf_raw == NULL) { + msg("snd_buffer_create(): ERROR! Couldn't alloc sound buffer\n"); + jps_memfree(dsBuf); + return NULL; + } + + // make uncached + dsBuf->buf = (uint32 *)((uint32)dsBuf->buf|0x20000000); + + return snd_buf; +} +void jpsdrvr_shutdown() { +/************************************** +** shut down sound system +**************************************/ + +} + +int jpsdrvr_init() { +/************************************** +** start up the sound system +**************************************/ + uint16 data; + uint16 ii; + + msg("snd_init(): begin - VP100\n"); + + for(ii=0;ii JPS_CLOCKS_PER_SEC*1) { + msg("snd_init(): ERROR! timeout waiting for ok\n"); + return -1; + } + } + } +#define AC97_VENDOR_STRING 0x4352 + // get the ID string + if (snd_ac97_read(CIRRUS_VENDOR_ID1,&data) == -1) { + msg("snd_init(): ERROR! Timeout waiting for ID from codec\n"); + return -1; + } + if (data != AC97_VENDOR_STRING) { + msg("snd_init(): ERROR! Invalid response from codec\n"); + msg("snd_init(): .. expected 0x%x, got 0x%x\n",AC97_VENDOR_STRING, data); + return -1; + } + + // wait for powerdown status... + { + int start_time = jps_clock(); + snd_ac97_read(AC97_POWERDOWN_CTRL,&data ); + while ((data&0xE)!= 0xE) { + if (jps_clock() - start_time > JPS_CLOCKS_PER_SEC*1) { + msg("snd_init(): ERROR! timeout waiting for powerdown ctrl\n"); + return -1; + } + snd_ac97_read(AC97_POWERDOWN_CTRL,&data); + } + } + + // set the master volume, mute = 0x8000, 0x00 = 0dB attenuation, 0x0505=no distortion 0x2020 = shh + snd_ac97_write(AC97_MASTER_VOL, 0x0505); + // the aux output is the "line out" for the VP board, unmute it w/no atten + snd_ac97_write(AC97_ALTERNATE_VOL,0x0505); + + snd_ac97_write(AC97_PCM_OUT_VOL, 0x0808); + snd_ac97_write(CIRRUS_SPDIF_CTRL,0x8000); + + for (ii=0;ii255) volume=255; + + jp_volume = (255-volume)/255.0f*64; + jp_volume &= 0x3F; + snd_ac97_write(AC97_MASTER_VOL, (jp_volume<<8)|jp_volume); + snd_ac97_write(AC97_ALTERNATE_VOL, (jp_volume<<8)|jp_volume); +} + +jps_sndbuf *snd_makesine(uint32 freq, float amplitude, uint32 num_periods, uint8 channels) { +/************************************** +** make a sinewave of the given freq +** and number of periods +**************************************/ +#if JPS_STEREO +#define SINE_BYTES_PER_SAMPLE 4 +#else +#define SINE_BYTES_PER_SAMPLE 2 +#endif + +#define DAC_RATE (48000) +#define MAX_AMPLITUDE 0x7F00 + jps_sndbuf *snd_buf = NULL; + jps_snddata *snd_data = NULL; + uint16 amp_int; + uint32 dma_bufsize = DAC_RATE/freq*num_periods; + amp_int = (uint16)(amplitude * MAX_AMPLITUDE); + // set up DMA channel 0 + snd_buf = jps_memalloc(NULL,0,sizeof(jps_sndbuf)); + snd_buffer_create(snd_buf, dma_bufsize*SINE_BYTES_PER_SAMPLE); + + snd_data = snd_buf->data; +// msg("snd_makesine(): sound buffer alloc'ed %i at 0x%08x\n",dma_bufsize*SINE_BYTES_PER_SAMPLE,snd_data->buf); + snd_buf->rate = DAC_RATE; + snd_buf->num_channels = 1; + snd_buf->databufsize = snd_buf->numbytes = dma_bufsize*SINE_BYTES_PER_SAMPLE; + +#if JPS_STEREO + // fill the buf with data + { + int ii = 0; + int16 out; + for (ii=0;iibuf[ii] = out; + } + if (channels&0x2) { + snd_data->buf[ii] |= (out<<16); + } + } + } +#else + // fill the buf with data + { + int ii = 0; + int16 out; + for (ii=0;iibuf; + out = amp_int*sin((float)ii*freq*(2*3.14157f/DAC_RATE)); + curr_sample[ii] = out; + } + } +#endif + + return snd_buf; +} + +jps_sndbuf *snd_makezero(uint32 dma_bufsize) { +/************************************** +** make a sinewave of the given freq +** and number of periods +**************************************/ + jps_sndbuf *snd_buf = NULL; + + snd_buf = jps_memalloc(NULL,0,sizeof(jps_sndbuf)); + snd_buffer_create(snd_buf, dma_bufsize*4); + msg("snd_makezero(): sound buffer alloc'ed %i at 0x%08x\n",dma_bufsize*4,((jps_snddata*)(snd_buf->data))->buf); + + // fill the buf with data + { + int ii = 0; + for (ii=0;iidata))->buf[ii] = 0; + } + } + return snd_buf; +} + +// JFL 18 Jul 04 +int sound_playbuf(jps_sndbuf *snd_buf,uint16 channel) +{ +/************************************** +** set up the dma registers for a sound buffer +**************************************/ + jps_snddata *snd_data = (jps_snddata*)snd_buf->data; + uint32 len; + + if (!snd_buf) + goto errorexit; + if (!snd_buf->data) + goto errorexit; + if (channel >= JPS_NUM_CHANNELS) + goto errorexit; + if (!snd_buf->streaming && channel_busy(channel)) + goto errorexit; + + snd_buf->channel_num = channel; + jps_channel_data[channel].curr_buf = snd_buf; + snd_buf->playflags=0; // only place these are cleared + + // figure bytes per sample -- and turn it into a left-shift value + if(snd_buf->num_channels==2) + dma_per[channel]=2; // 4 bytes-per-sample, left shift=2 + else + dma_per[channel]=1; // 2 bytes-per-sample, left shift=1 + + // setup for streaming + if(snd_buf->streaming) + { + snd_buf->dest_offset = 0; + snd_buf->file_curpos = snd_buf->file_hdrpos; + + // copy preload data into the buffer + if(JPS_OK==copy_to_dsbuf(snd_buf,snd_buf->databufsize,&len)) + { + // check if we can make this a static buffer + if(snd_buf->numbytes <= len) // snd_buf->databufsize) + { + // we're static now! + if (snd_buf->file_pointer) + { + // msg("sound_playbuf() closing %08X streaming=%d\n",snd_buf->name[0],snd_buf->streaming); + jps_fclose(snd_buf->file_pointer); + snd_buf->file_pointer=NULL; + } + snd_buf->streaming = FALSE; + } // copied + } // small enough + } // if streaming + + // this routine kicks off the DMA for the first time through the buffer + // after that, the dma_adr[] tables are the only contact with the DMA. + // At the end-of-buffer interrupt the sound will loop by itself if the + // DMA-loop flag is set or it will stop and go quiet if the loop flag isn't set. + // If dma_flg[] is zero, nothing will be done (meaning the DMA-loop flag controls). + // If dma_flg[] is nonzero, then dma_len[] is the total byte size of the sound and + // dma_max[] is the total byte size of the buffer and dma_adr[] is the start of the + // buffer. The interrupt routine will keep the DMA running through buffers until + // all it has run through all the data for that sound. + // The DMA-loop flag can't be set if you want an end of buffer interrupt. + + dma_adr[channel] = (uint32)snd_data->buf; + dma_len[channel] = snd_buf->numbytes; + + if(snd_buf->streaming) + dma_max[channel] = snd_buf->databufsize; + else + dma_max[channel] = snd_buf->numbytes; + + // figure len of first DMA + len=dma_len[channel]; + if(len>dma_max[channel]) + len=dma_max[channel]; + dma_len[channel]-=len; + + dma_flg[channel]=0; // will be overridden if streaming a large sound + + // pick sample rate + if (snd_buf->rate > 30000) { + *SNDDMA_CTRL(channel) &= ~HALF_RATE_FLAG; + } else { + *SNDDMA_CTRL(channel) |= HALF_RATE_FLAG; + } + + if (snd_buf->looping) { + *SNDDMA_CTRL(channel) |= LOOP_FLAG; + } else { + *SNDDMA_CTRL(channel) &= ~LOOP_FLAG; + if(snd_buf->streaming && dma_len[channel]) + dma_flg[channel]=1; // channel isn't looping, but dma needs to + } + + *SNDDMA_ADDR(channel) = dma_adr[channel]&0x1FFFFFFF; + *SNDDMA_COUNT(channel) = 0x1000000-(len>>dma_per[channel])+1; // number of samples first time through + *SNDDMA_LOOP(channel) = (uint32)(dma_adr[channel]-2)&0x1FFFFFFF; // - bytes_per_sample + *SNDDMA_LCOUNT(channel)= 0x1000000-(len>>dma_per[channel])+1; // number of samples in loop + + // enable sound dma + *SNDDMA_INT_MASK |= 0x1<playflags=0; + EnterCriticalSection(&channel_startstop); + sound_playbuf(sbuf, channel); + LeaveCriticalSection(&channel_startstop); + return JPS_OK; +} + +int channel_stop(uint16 channel) { + EnterCriticalSection(&channel_startstop); + *SNDDMA_ENABLE &= ~(0x01<file_pointer) + { + // msg("free_buffers() closing %X streaming=%d\n",buffer_to_kill->name[0],buffer_to_kill->streaming); + jps_fclose(buffer_to_kill->file_pointer); + buffer_to_kill->file_pointer=NULL; + } + jps_memfree(((jps_snddata*)buffer_to_kill->data)->buf_raw); + jps_memfree(buffer_to_kill->data); +// jps_memfree(buffer_to_kill); + LeaveCriticalSection(&channel_startstop); + return JPS_OK; + +//DONE("free_buffers") +} // free_buffers + +int channel_set_volume(int channel_num, int volume) { +/*************************************** +** set the volume of a given channel +**************************************/ + uint32 volout; + uint16 jpvolume; + // set the VP100 volume... currently the volume is set up as 8-bit + // linear... #vol_to_db# uses 8-bit log as input and converts it to + // a 16-bit linear value. + + if (volume>JPS_VOL_MAX) + volume=JPS_VOL_MAX; + + jpvolume = vol_to_db[volume]; +#if VOLUME_16BIT + volout = *SNDDMA_CTRL(channel_num)&0xFFFF0000; + *SNDDMA_CTRL(channel_num) = volout | (jpvolume &0xFFFF); +#else + volout = *SNDDMA_CTRL(channel_num)&0xFFFFFF00; + *SNDDMA_CTRL(channel_num) = volout | ((jpvolume &0xFF00)>>8); +#endif + jps_channel_data[channel_num].volume = volume; + jps_channel_data[channel_num].index = volume; + return JPS_OK; +} + +// JFL 20 Jul 04 +int channel_busy(int channel) { + if (!(*SNDDMA_ENABLE&(0x01<> 2), &snd_int_data_block ); + + /* Enable the clock interrupt */ +// set_sr_reg( get_sr_reg( ) | SR_IE | SND_INT_INTERRUPT_MASK ); +} + +static int snd_int_hdlr_wrapper(void) { +/************************************** +** +**************************************/ +// if ( (get_cause_reg( ) & SND_INT_INTERRUPT_MASK) == 0 ) + if ( (getCause( ) & SND_INT_INTERRUPT_MASK) == 0 ) + return ( FALSE ); + snd_int_hdlr(); + return TRUE; +} + +void snd_int_hdlr_pseudo() { +/************************************** +** NO WAITING - calls interrupt +** handler if and interrupt should be +** pending +*************************************/ + if (*SNDDMA_INT_CLR) + snd_int_hdlr(); +} + +void snd_verify_buffer(uint8 channel) { +/************************************** +** +*************************************/ + int ii; + for (ii=0;ii<128;ii++) { + if ((SNDDMA_DEBUG(channel))[ii]!=0) { +// printf("ERROR! BUFFER is 0x%4x at %i\n",(SNDDMA_DEBUG(channel))[ii],ii); + } + } +} + +// JFL 18 Jul 04 +static int snd_int_hdlr( void ) +/************************************** +** +*************************************/ +{ + uint32 cause = getCause(); + uint32 channel_mask = 0; + uint32 channel; + uint32 serviced=0; + uint32 loops=0; + uint32 len; + + if ((*JP_AC97_CONFIG&JP_AC97_CONFIG_READY)==0) + msg("AC97 NOT READY\n"); + + // let's find out what channel caused it... + // this part should be abstracted + while (*SNDDMA_INT_CLR && ++loops<10000) + { + for (channel=0;channeldma_max[channel]) + len=dma_max[channel]; + dma_len[channel]-=len; + if(!dma_len[channel]) + dma_flg[channel]=0; + + if(len) + { + // the dma_flg is only set for channels that stream and loop + *SNDDMA_ADDR(channel) = dma_adr[channel]&0x1FFFFFFF; // adr of start of buffer + *SNDDMA_COUNT(channel) = 0x1000000-(len>>dma_per[channel])+1; // samples + *SNDDMA_INT_MASK |= 0x1<data; + + if(dest_offset+bytes_to_copy>snd_buf->databufsize) + { + // + // SPLIT BUFFERS + // + + // |= 0x20000000 write-through cache + + // how far till end of buffer + *buf_ptr1 = &((uint8*)data->buf)[dest_offset]; + *((uint32*)buf_ptr1) |= 0x20000000; // where we left off + *buf_len1 = snd_buf->databufsize - dest_offset; // till end of buffer + *buf_ptr2 = data->buf; + *((uint32*)buf_ptr2) |= 0x20000000; // start of buffer + *buf_len2 = bytes_to_copy - *buf_len1; // till end of data + } + else + { + // + // SINGLE BUFFER + // + + // simple case, one buffer + *buf_ptr1 = &((uint8*)data->buf)[dest_offset]; + *((uint32*)buf_ptr1) |= 0x20000000; // where we left off + *buf_len1 = bytes_to_copy; + *buf_ptr2 = NULL; + *buf_len2 = 0; + } + + return JPS_OK; +} // jpsdrvr_Lock() + +int jpsdrvr_Unlock(jps_sndbuf *buf, + void *buf_ptr1, uint32 buf_len1, + void *buf_ptr2, uint32 buf_len2) { +/************************************** +** emulate the directsound lock() +** function +**************************************/ + // don't do anything. + return JPS_OK; +} + +unsigned long num_critical_sections = 0; + +void InitializeCriticalSection(CRITICAL_SECTION *CritSec) { +/************************************** +** assign a resource ID to a critical +** section handle for further use +**************************************/ + // note, we're not using 0 as a valid resource ID + num_critical_sections++; + *CritSec = num_critical_sections; +} + +void EnterCriticalSection(CRITICAL_SECTION *CritSec) { +/************************************** +** hold off execution until there are +** no holds on the given critical +** section +**************************************/ + getres(*CritSec,0); +} + +void LeaveCriticalSection(CRITICAL_SECTION *CritSec) { +/************************************** +** free up a critical section for +** others to use +**************************************/ + relres(*CritSec); +} + +// JFL 29 Apr 05 +void DestroyCriticalSection(CRITICAL_SECTION *CritSec) +{ +} // DestroyCriticalSection() + +// JFL 18 Jul 04 +void jps_update_streams() +{ +/************************************** +** top off any half-full buffers +**************************************/ +#if !FILL_IN_ISR + int ii; + #if DBG_WATCH_SOUNDS + uint32 name; + char c; + #endif // DBG_WATCH_SOUNDS + + jps_sndbuf *this_buf = NULL; + EnterCriticalSection(&channel_startstop); + for (ii=0;iiname[0]; + c=(name>>24)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[1]=c; + + c=(name>>24)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[2]=c; + + c=(name>>16)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[3]=c; + + c=(name>>16)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[4]=c; + #endif // DBG_WATCH_SOUNDS + + #if DBG_WATCH_SOUNDS + if(this_buf->playflags&M_SNDBUF_ERR) + { + jps_infochannel[ii].s[0]='E'; + } + #endif // DBG_WATCH_SOUNDS + + if (this_buf->streaming) + { + #if DBG_WATCH_SOUNDS + if (this_buf->streaming) + jps_infochannel[ii].s[0]='s'; + if(this_buf->looping) + jps_infochannel[ii].s[0]='S'; + #endif // DBG_WATCH_SOUNDS + + // + // HANDLE STOPPING / LOOPING + // + + // if the sound is suppose to stop and the interrupt has hit, stop sound + if(JPS_OK!=fill_buffer(this_buf)) + { + msg("stopping sound %08X b/c fill_buffer err\n",this_buf->name[0]); + sound_stopbuf(ii); + } + } + else + { + #if DBG_WATCH_SOUNDS + jps_infochannel[ii].s[0]='n'; + if(this_buf->looping) + jps_infochannel[ii].s[0]='N'; + #endif DBG_WATCH_SOUNDS + } + } // for + LeaveCriticalSection(&channel_startstop); +#endif +} // jps_update_streams() + +void *jps_memalloc (void **raw_ptr, uint32 alignbound, uint32 size) { +/************************************** +** +**************************************/ + void *pTemp = NULL; + uint32 uTemp; + + // initialize ptr for return + if (raw_ptr) + *raw_ptr = NULL; + + pTemp = jps_apphook_malloc(size + alignbound); + if (pTemp == NULL) return NULL; + + jps_sndmem_alloc_count++; + + uTemp = (uint32)pTemp; + if(alignbound) + { + uTemp += alignbound - 1; + uTemp &= ~(alignbound - 1); + } + + if (raw_ptr) + *raw_ptr = pTemp; + + return (void *)uTemp; +} + +void jps_memfree(void *raw_ptr) +{ + jps_apphook_free(raw_ptr); + jps_sndmem_alloc_count--; +} // jps_memfree() + +#endif // SYS_5500 +// EOF diff --git a/libraries/pmrt/jpsnd/jpsdrvr_dx.c b/libraries/pmrt/jpsnd/jpsdrvr_dx.c new file mode 100755 index 0000000..0a15ef7 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpsdrvr_dx.c @@ -0,0 +1,1167 @@ +#if SYS_PC +/************************************************ +** jpsdrvr_dx.c +** +** hardware/OS abstraction for DirectSound/Win +** +** Andrew Eloff +** (c) RAW THRILLS 2001 +** +** TODO: +** - comments, better code flow +** - make transition points work for +** streaming buffers (hint, you can't add +** them once the buffer's playing, so you +** have to mod (%) them into the buffer size +** and then make sure the div (/)'s are +** equal to know if it's a valid transition) +** - the only way to get no popping from +** playlisted combinations of .wav files is +** to stream them... load the wav's into main +** memory and then stream them into a secondary +** buffer. +** - for streaming buffers, the buffer should +** really correspond to the CHANNEL rather than +** the sound! +************************************************/ + +// JFL 26 Apr 05 +// JFL 27 Apr 05 +// JFL 03 May 05; partial inits & shutdowns +// JFL 13 Jun 05 +// JFL 18 Jul 05 +// JFL 27 Jul 05; volumes + +// Kept getting link err: IID_IDirectSoundNotify undefined +// defining INITGUID brings in the definition +#define INITGUID + +#include +#include +#include +#include "jps.h" + +#define DSOUND_ENUMERATE_DEVICES 0 +#define RTSOUND_TRANSITION_EVENT_PREFIX "rtsound_trans_event" + +// This is the parent window for DirectSound (it needs a window, +// see jpsdrvr_init() below +static HWND dsound_dsWin; + +// this is the main handle for all of DirectSound... +LPDIRECTSOUND dsound_dsi = NULL; +static GUID dsound_GUID; + +// MAX_NUM_TRANSITION_POINTS refers to the maximum number of +// events that can be set up in the system at any given time, +// meaning all events for all voices currently buffered. +#define MAX_NUM_TRANSITION_POINTS (16) +static HANDLE event_handles[MAX_NUM_TRANSITION_POINTS]; + +// this is the pointer to the allocated array of jps_sndbufs +static jps_sndbuf *jps_sndbuf_list; +static int num_jps_sndbufs = MAX_JPS_SNDBUFS; +static float jps_master_volume_mul; + +DSBPOSITIONNOTIFY jps_notify_buffers[NUM_CHANNELS]; + +#if DSOUND_ENUMERATE_DEVICES +GUID *pguID = NULL; +#endif // DSOUND_ENUMERATE_DEVICES + +HANDLE hThread; +DWORD lpThreadID; + +extern int sound_init = 0; + +// the streaming buffers are allocated by channel +// rather than sound (as the static ones are) +LPDIRECTSOUNDBUFFER stream_buffers[NUM_CHANNELS]; + +#define FMT_TAG 1 +#define FMT_SAMPLES_PER_SEC 24000 +#define FMT_BITS_PER_SAMPLE 16 +#define FMT_AVG_BYTES_PER_SEC 2*FMT_SAMPLES_PER_SEC +#define FMT_NUMCHANNELS 1 +#define FMT_BLOCKALIGN 2 + +// forwards +int stream_buffer_init(); +int sound_playbuf(jps_sndbuf *sbuf,uint16 channel); + +// JFL 27 Jul 05; built volume to direct sound decibel attenuation table +int voltbl[256]= +{ + // this table is generated from jpstest.c + -10000,-9844,-9689,-9537,-9387,-9238,-9091,-8946, + -8802,-8661,-8521,-8382,-8246,-8111,-7978,-7846, + -7716,-7588,-7461,-7336,-7212,-7090,-6970,-6851, + -6734,-6618,-6504,-6391,-6279,-6169,-6061,-5954, + -5848,-5744,-5641,-5540,-5440,-5341,-5244,-5148, + -5053,-4960,-4868,-4777,-4687,-4599,-4512,-4426, + -4342,-4259,-4176,-4096,-4016,-3937,-3860,-3784, + -3708,-3634,-3562,-3490,-3419,-3350,-3281,-3213, + -3147,-3082,-3017,-2954,-2892,-2830,-2770,-2710, + -2652,-2594,-2538,-2482,-2428,-2374,-2321,-2269, + -2218,-2167,-2118,-2069,-2022,-1975,-1929,-1883, + -1839,-1795,-1752,-1710,-1669,-1628,-1589,-1549, + -1511,-1473,-1436,-1400,-1365,-1330,-1296,-1262, + -1229,-1197,-1165,-1134,-1104,-1074,-1045,-1016, + -988,-961,-934,-908,-882,-857,-833,-809, + -785,-762,-740,-718,-696,-675,-654,-634, + -615,-596,-577,-559,-541,-523,-506,-490, + -474,-458,-443,-428,-413,-399,-385,-372, + -359,-346,-333,-321,-310,-298,-287,-276, + -266,-256,-246,-236,-227,-218,-209,-200, + -192,-184,-176,-169,-162,-155,-148,-141, + -135,-129,-123,-117,-112,-106,-101,-96, + -92,-87,-83,-78,-74,-70,-67,-63, + -60,-56,-53,-50,-47,-44,-42,-39, + -37,-34,-32,-30,-28,-26,-24,-23, + -21,-20,-18,-17,-16,-14,-13,-12, + -11,-10,-9,-8,-8,-7,-6,-6, + -5,-4,-4,-3,-3,-3,-2,-2, + -2,-1,-1,-1,-1,-1,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0 +}; + +// JFL 27 Jul 05 +int vol2ds(int invol) +{ + int outvol; + + invol = (int) (((float)invol)*jps_master_volume_mul); + + if(invol<1) + outvol=DSBVOLUME_MIN; // silence + else if(invol>254) + outvol=DSBVOLUME_MAX; // no attenuation + else + outvol=voltbl[invol]; + + // msg("in %d out %d mul %f\n",invol,outvol,jps_master_volume_mul); + return outvol; +} // vol2ds() + +int jpsdrvr_Lock(jps_sndbuf *sbuf, + uint32 dest_offset, uint32 bytes_to_copy, + void **buf_ptr1, uint32 *buf_len1, + void **buf_ptr2, uint32 *buf_len2) +{ + int status=0; + + status = IDirectSoundBuffer_Lock((LPDIRECTSOUNDBUFFER)sbuf->data, + dest_offset,bytes_to_copy,buf_ptr1,buf_len1,buf_ptr2,buf_len2,0); + + if(status==DS_OK) + return JPS_OK; + + return JPS_ERROR; +} // jpsdrvr_Lock() + +int jpsdrvr_Unlock(jps_sndbuf *sbuf, + void *buf_ptr1, uint32 buf_len1,void *buf_ptr2, uint32 buf_len2) +{ + int status; + + status=IDirectSoundBuffer_Unlock((LPDIRECTSOUNDBUFFER)sbuf->data, + buf_ptr1, buf_len1, buf_ptr2, buf_len2); + + if(status==DS_OK) + return JPS_OK; + + return JPS_ERROR; +} // jpsdrvr_Unlock() + +int jpsdrvr_GetCurrentPosition(jps_sndbuf *sbuf,uint32 *playp) +{ + /************************************** + ** locate the current play position + **************************************/ + DWORD write_position; + + if (JPS_OK==IDirectSoundBuffer_GetCurrentPosition( + (LPDIRECTSOUNDBUFFER)sbuf->data, + (DWORD *)playp, &write_position)) + + return JPS_OK; + return JPS_ERROR; +} // jpsdrvr_GetCurrentPosition() + +// JFL 29 Apr 05 +void DestroyCriticalSection(CRITICAL_SECTION *CritSec) +{ +} // DestroyCriticalSection() + +#if DSOUND_ENUMERATE_DEVICES +BOOL CALLBACK cb(LPGUID lpGuid, LPSTR lpstrDescription, LPCSTR lpstrModule, LPVOID lpContext) { +/************************************** +** silly callback function for +** enumeration of Dsound devices +**************************************/ + if(lpGuid) { + dsound_GUID = *lpGuid; + return 0; + } + + return 1; +} +#endif + +// JFL 29 Apr 05 +int jpsdrvr_init() +{ +/************************************** +** DirectSound SPECIFIC initialization +** of the system. +** We don't HAVE to make a dummy window +** like we do below. It just helps +** with setting the DirectSound +** cooperative level without having +** to pass the hWnd through as an init +** parameter. +**************************************/ + //unsigned long threadID; + //char name[255]; + int count; + int ii; + HRESULT result; + WNDCLASSEX winClass; + ATOM classAtom; + HINSTANCE hInstance; + + // + // zero all resource handles before we can fail + // to allow for partial init & shutdown + // + + sound_init=0; + + #if DSOUND_ENUMERATE_DEVICES + pguID = NULL; + #endif + + // initialize vars getting set in this routine... + dsound_dsi = NULL; + dsound_dsWin = NULL; + for(count = 0;count < MAX_NUM_TRANSITION_POINTS;count++) + event_handles[count] = NULL; + + for (ii=0;iiSize3); + if (*buffer == NULL) { + msg("load_wav() Can't alloc data for sound\n"); + return JPS_ERROR; + } + + status = fread(*buffer,1,wavhdr->Size3,in_file); + // make sure that we read in the correct amount of information from the wav file + if (status != wavhdr->Size3) { + msg("load_wav() problem reading wav data\n"); + jps_memfree(*buffer); + return JPS_ERROR; + } + + return JPS_OK; +} // load_wav() + +// JFL 14 Jun 05 +int create_soundbuffer(jps_sndbuf *sbuf,LPDIRECTSOUNDBUFFER *dsbp) +{ + int ec; + DWORD ii; + DSBUFFERDESC desc; + WAVEFORMATEX format; + LPDIRECTSOUNDBUFFER dsb; + + // + // create streaming sound buffer + // + + *dsbp=NULL; + + memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(DSBUFFERDESC); + desc.dwFlags = DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPOSITIONNOTIFY; + desc.dwFlags |= DSBCAPS_GLOBALFOCUS; + desc.dwFlags |= DSBCAPS_CTRLFREQUENCY; + desc.dwFlags |= DSBCAPS_LOCSOFTWARE; // 20ms hardware, 100ms software + desc.dwBufferBytes = sbuf->databufsize; // size of buffer + desc.lpwfxFormat = &format; + desc.dwReserved = 0; + + // fill out the format... + memset(&format,0,sizeof(format)); + format.wFormatTag = 1; + format.nChannels = sbuf->nChannels; + format.nSamplesPerSec = sbuf->nSamplesPerSec; + format.nAvgBytesPerSec = sbuf->nAvgBytesPerSec; + format.nBlockAlign = sbuf->nBlockAlign; + format.wBitsPerSample = sbuf->nBitsPerSample; + format.cbSize = sizeof(format); + + // Create the secondary buffer... + ii = IDirectSound_CreateSoundBuffer(dsound_dsi, &desc, + (LPDIRECTSOUNDBUFFER *) &dsb, NULL); + if(ii!=DS_OK) + {ec=-1;goto BAIL;} + + jps_apphook_memadd(dsb); + *dsbp=dsb; + + ec=0; +BAIL: + return ec; +} // create_soundbuffer() + +// JFL 28 Apr 05 +int create_and_preload_buffer(wavinfo *wavhdr,jps_sndbuf *sbuf) +{ + LPDIRECTSOUNDBUFFER dsb; + int ec,i; + + if (!sound_init) + return JPS_ERROR; + + sbuf->looping=0; + sbuf->data=NULL; + sbuf->allocated=0; + + // copy the sound size to the jps_sndbuf struct (this info isn't kept by DS) + sbuf->nSamplesPerSec = wavhdr->num_samples_per_sec; + sbuf->nChannels = wavhdr->num_channels; + + // jjj -- need to modify _lin implementation to match + // this is called when the .pls file is loaded + // streaming sounds dont do anything + // non-streaming sounds get a buffer allocated and they get loaded + +#if 0 +printf("preload - tag %d nch %d nsps %d avgbps %d ba %d bps %d\n", + wavhdr->format_tag, + wavhdr->num_channels, + wavhdr->num_samples_per_sec, + wavhdr->avg_bps, + wavhdr->block_align, + wavhdr->bits_per_sample); +#endif + + // + // + // + + // copy format info -- need to create buffer when sound is played + sbuf->nChannels = wavhdr->num_channels; + sbuf->nSamplesPerSec = wavhdr->num_samples_per_sec; + sbuf->nAvgBytesPerSec = wavhdr->avg_bps; + sbuf->nBlockAlign = wavhdr->block_align; + sbuf->nBitsPerSample = wavhdr->bits_per_sample; + + if(sbuf->streaming) + { + sbuf->numbytes = wavhdr->Size3; // size of whole sound + sbuf->databufsize = STREAM_BUFFER_SIZE; + } // streaming + else + { + sbuf->numbytes = wavhdr->Size3; + sbuf->databufsize = wavhdr->Size3; + } + + // reset the file pointer so it's pointing to the beginning of the file + sbuf->file_curpos = sbuf->file_hdrpos; + sbuf->file_endpos = sbuf->file_hdrpos+sbuf->numbytes; + + // + // + // + + if(!sbuf->streaming) + { + if(create_soundbuffer(sbuf,&dsb)<0) + goto errorexit; + sbuf->data=dsb; + sbuf->allocated=1; + + ec = copy_to_dsbuf(sbuf,sbuf->numbytes,&i); + jps_fclose(sbuf->file_pointer); + sbuf->file_pointer=NULL; + if(ec!=JPS_OK) + { + msg("create_and_preload_buffer() jps_fread err\n"); + goto errorexit; + } + + } // !streaming + + return JPS_OK; +errorexit: + return JPS_ERROR; +} // create_and_preload_buffer() + +// JFL 14 Jun 05 +int match_sbufformat_dsb(jps_sndbuf *sbuf,LPDIRECTSOUNDBUFFER dsb) +{ + WAVEFORMATEX format; + DWORD ii,dw; + + // fill out the format... + memset(&format, 0, sizeof(format)); + format.cbSize = sizeof(format); + + ii=IDirectSoundBuffer_GetFormat((LPDIRECTSOUNDBUFFER)dsb, + &format,sizeof(format),&dw); + if(ii!=DS_OK) + return -1; // error -- no match + + if( (format.nChannels != sbuf->nChannels) + ||(format.nSamplesPerSec != sbuf->nSamplesPerSec) + ||(format.wBitsPerSample != sbuf->nBitsPerSample) + ) + return 1; // no match + + return 0; +} // match_sbufformat_dsb() + +// JFL 27 Apr 05 +int sound_playbuf(jps_sndbuf *sbuf,uint16 channel) +{ + HRESULT result; + int ds_volume; + uint32 len; + LPDIRECTSOUNDBUFFER dsb; + int streaming; + + if(!sound_init || !sbuf || (channel >= JPS_NUM_CHANNELS)) + return JPS_ERROR; + + streaming=sbuf->streaming; + sbuf->playflags=0; // only place this is cleared + sbuf->finishzeros=0; + + // update record to keep track of which channel sbuf is on + if(sbuf->channel_num!=channel) + { + if(jps_channel_data[sbuf->channel_num].curr_buf==sbuf) + jps_channel_data[sbuf->channel_num].curr_buf=NULL; + } // zero old curr_buf + + sbuf->channel_num = channel; // set new channel + jps_channel_data[channel].curr_buf = sbuf; // set curr_buf + + if(sbuf->streaming) + { + sbuf->data=NULL; + sbuf->databufsize = STREAM_BUFFER_SIZE; // streaming buffers + + // free old streaming buffer + if((dsb=stream_buffers[channel])) + { + // check if streaming buffer we have currently allocated + // is compatible with the one we want to create + if(!match_sbufformat_dsb(sbuf,dsb)) + goto created; + + // free current stream buffer's dsb + stream_buffers[channel]=NULL; + IDirectSoundBuffer_Stop((LPDIRECTSOUNDBUFFER)dsb); + IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER)dsb); + jps_apphook_memdel(dsb); + } + + // create stream buffer dsb + if(create_soundbuffer(sbuf,&dsb)<0) + goto errorexit; + stream_buffers[channel]=dsb; + +created: + sbuf->data=dsb; + if(sbuf->allocated) + msg("sound_playbuf() alloc streaming\n"); // should never allocate streaming sbufs! + } + if(!sbuf->data) + goto errorexit; + + // stop already playing buffers + IDirectSoundBuffer_Stop((LPDIRECTSOUNDBUFFER)sbuf->data); + + // + // load streaming buffers + // + + // if streaming, load + if(sbuf->streaming) + { + // reset offsets + sbuf->dest_offset = 0; + sbuf->file_curpos = sbuf->file_hdrpos; + + if(!sbuf->file_pointer) + { + // re-open if closed + if(!(sbuf->file_pointer=jps_fopen(sbuf->file_path,"rb"))) + goto errorexit; + } // re-open + + // copy preload data into the buffer + if(JPS_OK==copy_to_dsbuf(sbuf,sbuf->databufsize,&len)) + { + // check if we can make this a static buffer + if(sbuf->numbytes <= len) + { + // we're static now! + jps_fclose(sbuf->file_pointer); + sbuf->file_pointer=NULL; + sbuf->playflags|=M_SNDBUF_FINISHSTOP; + } // copied + } // small enough + } // streaming + + // set the initial volume... + ds_volume=vol2ds((uint8)jps_channel_data[channel].volume); + result=IDirectSoundBuffer_SetVolume( + (LPDIRECTSOUNDBUFFER)sbuf->data,ds_volume); + if (result != DS_OK) + msg("sound_play() Couldn't set volume\n"); + + sound_start(sbuf); + + return JPS_OK; +errorexit: + return JPS_ERROR; +} // sound_playbuf() + +// JFL 11 Jun 05 +int sound_start(jps_sndbuf *sbuf) +{ + int result; + + if (!sound_init || !sbuf || !sbuf->data) + return JPS_ERROR; + + IDirectSoundBuffer_Stop((LPDIRECTSOUNDBUFFER)(sbuf->data)); + IDirectSoundBuffer_SetCurrentPosition((LPDIRECTSOUNDBUFFER)(sbuf->data),0); + + // start playing the sound buffer + if (sbuf->looping||sbuf->streaming) + result=IDirectSoundBuffer_Play( (LPDIRECTSOUNDBUFFER)(sbuf->data), + 0,0,DSBPLAY_LOOPING); + else + result=IDirectSoundBuffer_Play( (LPDIRECTSOUNDBUFFER)(sbuf->data), + 0,0,0); + + sbuf->playflags|=M_SNDBUF_PLAYING; // only place this flag is set + + return JPS_OK; +} // sound_start() + +// JFL 18 Jul 04 +// JFL 29 Apr 05 +void jpsdrvr_update_streams() +{ +/************************************** +** top off any half-full buffers +**************************************/ + int ii; + DWORD dw; + #if DBG_WATCH_SOUNDS + uint32 name; + char c; + #endif // DBG_WATCH_SOUNDS + + jps_sndbuf *sbuf = NULL; + EnterCriticalSection(&channel_startstop); + for (ii=0;iidata),&dw) + ||!(dw&DSBSTATUS_PLAYING)) + { + continue; + } + + #if DBG_WATCH_SOUNDS + name=sbuf->name[0]; + c=(name>>24)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[1]=c; + + c=(name>>24)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[2]=c; + + c=(name>>16)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[3]=c; + + c=(name>>16)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[4]=c; + #endif // DBG_WATCH_SOUNDS + + #if DBG_WATCH_SOUNDS + if(sbuf->playflags&M_SNDBUF_ERR) + { + jps_infochannel[ii].s[0]='E'; + } + #endif // DBG_WATCH_SOUNDS + + if((sbuf->playflags&M_SNDBUF_PLAYING) + && sbuf->streaming + && sbuf->data) + { + #if DBG_WATCH_SOUNDS + if (sbuf->streaming) + jps_infochannel[ii].s[0]='s'; + if(sbuf->looping) + jps_infochannel[ii].s[0]='S'; + #endif // DBG_WATCH_SOUNDS + + // + // FILL BUFFER + // + + // if the sound is suppose to stop and the interrupt has hit, stop sound + if(JPS_OK!=fill_buffer(sbuf)) + { + sound_stopbuf(sbuf); + msg("jpsdrvr_update_streams() stopped sound %08X b/c fill_buffer err\n",sbuf->name[0]); + } + } + else + { + #if DBG_WATCH_SOUNDS + jps_infochannel[ii].s[0]='n'; + if(sbuf->looping) + jps_infochannel[ii].s[0]='N'; + #endif DBG_WATCH_SOUNDS + } + } // for + LeaveCriticalSection(&channel_startstop); +} // jpsdrvr_update_streams() + +// JFL 12 Jun 05; handle updating streams +void jps_update_thread(void *dummy) +{ + DWORD dw=0; + + while(1) + { + Sleep(12); + + // non-blocking (hopefully) wait + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecoreos5/html/wce50conwaitfunctions.asp + //dw=MsgWaitForMultipleObjects (MAX_NUM_TRANSITION_POINTS,event_handles, + // FALSE, INFINITE, QS_ALLINPUT); + //if((dw>=WAIT_OBJECT_0) && (dw<(WAIT_OBJECT_0+MAX_NUM_TRANSITION_POINTS))) + //{ + // dw-=WAIT_OBJECT_0; + //} + + jpsdrvr_update_streams(); + jps_update_all(jps_players); + + } // while +} // jps_update_thread() + +int sound_stopbuf(jps_sndbuf *sbuf) +{ + unsigned channel; + + if(!sbuf || !sbuf->data || ((channel=sbuf->channel_num)>=JPS_NUM_CHANNELS)) + return -1; + + if(sbuf==jps_channel_data[channel].curr_buf) + jps_channel_data[channel].curr_buf=NULL; // signal not-playing-o + else if(jps_channel_data[channel].curr_buf) + msg("sound_stopbuf() curr_buf\n"); + + sbuf->playflags&=~M_SNDBUF_PLAYING; // only place this flag is cleared + + EnterCriticalSection(&channel_startstop); + IDirectSoundBuffer_Stop((LPDIRECTSOUNDBUFFER)(sbuf->data)); + LeaveCriticalSection(&channel_startstop); + + if(sbuf->file_pointer) + { + jps_fclose(sbuf->file_pointer); + sbuf->file_pointer=NULL; + } + + return 0; +} // sound_stopbuf() + +int sound_stop(int channel) +{ + /************** + ** stop sound + **************/ + // int result; + jps_sndbuf *sbuf; + //int ii; + + if (!sound_init) + return JPS_ERROR; + if (channel <0 || channel >= JPS_NUM_CHANNELS) + return JPS_ERROR; + + sbuf=jps_channel_data[channel].curr_buf; + jps_channel_data[channel].curr_buf=NULL; // signal not-playing-o + + sound_stopbuf(sbuf); + return JPS_OK; +} // sound_stop() + +// JFL 28 Jul 05 +void jps_master_volume(int volume) +{ + int ch; + + if(volume<0) volume=0; + else if(volume>JPS_VOL_MAX) volume=JPS_VOL_MAX; + + jps_master_volume_mul = ((float)volume/(float)JPS_VOL_MAX); + + for(ch=0;chdata),ds_volume); + if (result!=DS_OK) + msg("channel_set_volume() Couldn't set volume %d\n",result); + } + + return JPS_OK; +} // channel_set_volume() + +int channel_set_freq (int channel_num, int detune) { +/************************************************* +** change the freq of a sound that is currently +** playing +*************************************************/ + int status; + int ds_volume; + if (jps_channel_data[channel_num].curr_buf == NULL) { + return JPS_OK; + } + if (!sound_init) { + return JPS_ERROR; + } + + // awe HACK!!! todo grab sample rate from + // jps_channel_data[channel_num] + ds_volume = (int)(jps_channel_data[channel_num].curr_buf->nSamplesPerSec + detune); // for now... probably should do proportional + + status = IDirectSoundBuffer_SetFrequency( + (LPDIRECTSOUNDBUFFER)(jps_channel_data[channel_num].curr_buf->data), + ds_volume + ); + + return JPS_OK; +} + // note from AWE + // does directsound think it's stopped playing? BIG-TIME note here - + // the creative sound driver prematurely thinks that a sound has finished + // so this will potentially clip the end of a scall. Irritating. + +int channel_busy(int channel_num) +{ + /************************************** + ** returns 1 if a sound is playing + **************************************/ + int playing; + + if (!sound_init) + return 0; + if((channel_num<0)||(channel_num>=JPS_NUM_CHANNELS)) + return 0; + + playing=0; + EnterCriticalSection(&channel_startstop); + if (jps_channel_data[channel_num].curr_buf) + playing=1; + LeaveCriticalSection(&channel_startstop); + return playing; +} // channel_busy() + +#define FREE_RETRY 1000 + +// JFL 13 Jun 05 +int free_buffers(jps_sndbuf * sbuf) +{ + // streaming buffers are free'd on final + uint32 ii; + + if (!sound_init) + return JPS_ERROR; + + EnterCriticalSection(&channel_startstop); + + if(sbuf->data && sbuf->allocated) + { + sbuf->allocated=0; + ii=FREE_RETRY; + while(ii-->1) + { + if(!IDirectSoundBuffer_Release((LPDIRECTSOUNDNOTIFY)sbuf->data)) + break; + LeaveCriticalSection(&channel_startstop); + EnterCriticalSection(&channel_startstop); + } // while + jps_apphook_memdel(sbuf->data); + sbuf->data=NULL; + } // sbuf->data + + // close file if there is one + if (sbuf->file_pointer) + { + jps_fclose(sbuf->file_pointer); + sbuf->file_pointer=NULL; + } + + // clear any event info + //for (ii=0;ii +#include +#include "jps.h" +#include "jpsdrvr.h" +// device control +#include +#include +#include +// for memory mappings +#include +#include +// posix threads +#include + +#define DEV_MIXER "/dev/mixer" +#define DEV_DSP "/dev/dsp" + +void jpsdrvr_thread(void * dummy); +void jpsdrvr_update_streams(); +void setMixer(int val, int pcmval); + +// note -- reset all static initializations in _init() +// b/c the module may be shutdown/restarted w/o reloading + +// memory-map vars for the DMA +int mmbufsize = 0; +unsigned char *mmbuf = NULL; +int16 *dsbuf = 0; // output buffer +int dsbufsize = 0; +int streambufsize = 0; // in bytes +int dsp_fd = -1; +int dsp_format = 0; +volatile int dsp_init = 0; // used to signal thread +int master_volume = 0; +float master_volume_inv = 0; +struct audio_buf_info dsp_info; +float channel_volume_inv[JPS_NUM_CHANNELS]; +uns32 vol_to_db[]; +pthread_t dsp_thread; + +// software 'dma' +volatile uns8* dma_adr[JPS_NUM_CHANNELS]; // current +volatile uns8* dma_adr0[JPS_NUM_CHANNELS]; // first in buffer +volatile uns8* dma_adrx[JPS_NUM_CHANNELS]; // one past last valid +volatile uns32 dma_len[JPS_NUM_CHANNELS]; // size of valid data +volatile uns8 dma_stereo[JPS_NUM_CHANNELS]; // size of valid data +volatile uns8 dma_looping[JPS_NUM_CHANNELS]; // channel is looping +volatile uns32 dma_buflen[JPS_NUM_CHANNELS]; // total size of buffered data + + +// notes: +// call SNDCTL_DSP_POST when your program is going to pause +// continuous output of audio data for relatively long time. +// You can use SNDCTL_DSP_RESET when playback should be stopped +// (cancelled) immediately. +// Call SNDCTL_DSP_SYNC when you want to wait until all data has +// been played. +// SNDCTL_DSP_RESET or SNDCTL_DSP_SYNC should be called when the +// application wants to change sampling parameters (speed, number +// of channels or number of bits). +// http://www.4front-tech.com/pguide/audio.html + +// threads +// http://www.llnl.gov/computing/tutorials/workshops/workshop/pthreads/MAIN.html#ConVarSignal + +// JFL 28 Apr 05; re-implemented +int jpsdrvr_init() +{ + int ec; + int caps; + int fmt,fmtbytes; + int bits,speed; + // char *p; + + // + // zero all resource pointers + // + + dsp_init=0; + dsp_fd=-1; + dsbuf=NULL; + mmbuf=NULL; + dsp_thread=NULL; + + // reset all 'dma' buffers + for(ec=0;ec=0) + close(dsp_fd); + dsp_fd=-1; + + if(dsbuf) + jps_memfree(dsbuf); + dsbuf=NULL; + + dsp_init=0; // also has effect of killing thread +} // jpsdrvr_shutdown() + +// JFL 27 Apr 05 +int jpsdrvr_Lock(jps_sndbuf *sbuf, + uint32 dest_offset, uint32 bytes_to_copy, + void **buf_ptr1, uint32 *buf_len1, + void **buf_ptr2, uint32 *buf_len2) +{ + if(!dsp_init) + return JPS_ERROR; + + if(dest_offset+bytes_to_copy>sbuf->databufsize) + { + // + // SPLIT BUFFERS + // + + // how far till end of buffer + *buf_ptr1 = &((uint8*)sbuf->data)[dest_offset]; + *buf_len1 = sbuf->databufsize - dest_offset; // till end of buffer + *buf_ptr2 = sbuf->data; + *buf_len2 = bytes_to_copy - *buf_len1; // till end of data + } + else + { + // + // SINGLE BUFFER + // + + // simple case, one buffer + *buf_ptr1 = &((uint8*)sbuf->data)[dest_offset]; + *buf_len1 = bytes_to_copy; + *buf_ptr2 = NULL; + *buf_len2 = 0; + } + + return JPS_OK; +} // jpsdrvr_Lock() + +// JFL 29 Apr 05 +int jpsdrvr_Unlock(jps_sndbuf *sbuf, + void *buf_ptr1, uint32 buf_len1, + void *buf_ptr2, uint32 buf_len2) +{ + int channel=sbuf->channel_num; + + if(!dsp_init) + return JPS_ERROR; + if((channel<0)||(channel>=JPS_NUM_CHANNELS)) + return JPS_ERROR; + + if(dma_adr[channel]) + { + dma_len[channel]+=buf_len1+buf_len2; + dma_buflen[channel]=dma_len[channel]; + } + + return JPS_OK; +} // jpsdrvr_Unlock() + +int jpsdrvr_GetCurrentPosition(jps_sndbuf *sbuf, + uint32 *play_position) +{ + int channel=sbuf->channel_num; + uns8 *dma; + + *play_position = 0; + + if(!dsp_init) + return JPS_ERROR; + if (!sbuf->data) + return JPS_OK; + if((channel<0)||(channel>=JPS_NUM_CHANNELS)) + return JPS_ERROR; + + // where our buf starts & where dma is currently playing + dma = dma_adr[channel]; + if((dma=dma_adrx[channel])) + { + // quick stop + dma_adr[channel]=NULL; + *play_position=0; + return JPS_ERROR; + } + + *play_position=dma-dma_adr0[channel]; + return JPS_OK; +} // jpsdrvr_GetCurrentPosition() + +// +// jpsdrvr_stream_ok +// determine if streaming is ok on this hardware +// +int jpsdrvr_stream_ok(void) +{ + return(1); +} + +#define MAX_SNDDAT 32767 +#define MIN_SNDDAT -32767 + +// JFL 29 Apr 05 +void jpsdrvr_thread(void * dummy) +{ + audio_buf_info info; + int i = 0; + int j = 0; + int len = 0; + int size = 0; + int16 *src = 0; + int16 *dst = 0; + int32 *dst32 = 0; + float f1 = 0; + float f2 = 0; + float level = 0; + float i1 = 0; + + while(1) + { + usleep(4000); // sleep -- review this + + jps_update_all(jps_players); + jpsdrvr_update_streams(); + + // + // play the 'dma' + // + + // find how many bytes we can send w/o blocking + if(ioctl(dsp_fd, SNDCTL_DSP_GETOSPACE, &info) == -1) + continue; + + // MN 21NOV07 : setting the size to info.bytes can result in output lengths + // that are smaller than our 384 byte limit! + // (24000 Hz, 16bit stereo = 96000 bytes/second, 96000 / 4ms loop = 384 bytes / loop) + // hardcoding to our sound buffer size (4k) keeps the output lengths much higher + + size = dsbufsize; + + if(size<=0) + continue; + + // clear output buffer + if (size&0x3) + { + // buffer on half-word boundry + dst=(void*)dsbuf; + len=size>>1; + for(i=0;i>2; + for(i=0;i>=1; // we send 2x samples w/mono sound + } + if(dma_looping[i]) + { + // looping sounds never stop so wrap their counter + if(len > j) + { + // more buffer remains + dma_len[i] -= j; + } + else + { + // loop buffer and set remainder correctly + dma_len[i] = dma_buflen[i] - (j-len); + } + len = j; + } + else + { + // clamp non-looping sound size to size of buffer, if necessary + if(len > j) // clamp len to dst buffer size in bytes + len = j; + dma_len[i] = (dma_len[i] > len) ? dma_len[i] - len : 0; + } + + len >>= 1; // len in words + + // due to a noticeably low output volume for Big Buck Hunter Pro + // rather than re-mixing all playlists, we are going to multipy + // the output level by a factor to bump up the overall output volume. + // GNP 30JAN06 + level = master_volume_inv*channel_volume_inv[i]*10.0; + if(!dma_stereo[i]) + { + // mono + for(j=0;jstereo mixing + f1=*src++; + if(src>=dma_adrx[i]) src=dma_adr0[i]; // wrap dma buffer + f1*=level; + f2=f1; + f1+=*dst; + if((i1=f1)MAX_SNDDAT) + i1=MAX_SNDDAT; + *dst++=i1; + f2+=*dst; + if((i1=f2)MAX_SNDDAT) + i1=MAX_SNDDAT; + *dst++=i1; + } // for + } // mono + else + { + // stereo + for(j=0;j=dma_adrx[i]) src=dma_adr0[i]; // wrap dma buffer + f1*=level; + f1+=*dst; + if((i1=f1)MAX_SNDDAT) + i1=MAX_SNDDAT; + *dst++=i1; + } // for + } // stereo + + dma_adr[i]=(void*)src; + } // for + + // send the combined output buffer + write(dsp_fd,dsbuf,size); + + } // while +} // jpsdrvr_thread() + +// JFL 18 Jul 04 +// JFL 29 Apr 05 +// GNP 05 Jan 06; added handling of non-streaming sounds +void jpsdrvr_update_streams() +{ +/************************************** +** top off any half-full buffers +**************************************/ + int ii; + #if DBG_WATCH_SOUNDS + uint32 name; + char c; + #endif // DBG_WATCH_SOUNDS + + jps_sndbuf *sbuf = NULL; + EnterCriticalSection(&channel_startstop); + for (ii=0;iiname[0]; + c=(name>>24)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[1]=c; + + c=(name>>24)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[2]=c; + + c=(name>>16)&0xff;c>>=4;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[3]=c; + + c=(name>>16)&0xff;c&=0xf;if(c>9) c+='A'-10; else c+='0'; + jps_infochannel[ii].s[4]=c; + #endif // DBG_WATCH_SOUNDS + + #if DBG_WATCH_SOUNDS + if(sbuf->playflags&M_SNDBUF_ERR) + { + jps_infochannel[ii].s[0]='E'; + } + #endif // DBG_WATCH_SOUNDS + + if (sbuf->streaming) + { + #if DBG_WATCH_SOUNDS + if (sbuf->streaming) + jps_infochannel[ii].s[0]='s'; + if(sbuf->looping) + jps_infochannel[ii].s[0]='S'; + #endif // DBG_WATCH_SOUNDS + + // + // HANDLE STOPPING / LOOPING + // + + // if the sound is suppose to stop and the interrupt has hit, stop sound + if(JPS_OK!=fill_buffer(sbuf)) + { + msg("stopping sound %08X b/c fill_buffer err\n",sbuf->name[0]); + sound_stop(ii); + } + } + else + { + #if DBG_WATCH_SOUNDS + jps_infochannel[ii].s[0]='n'; + if(sbuf->looping) + jps_infochannel[ii].s[0]='N'; + #endif DBG_WATCH_SOUNDS + if (!dma_len[ii]) + { + // buffer is exhausted + // if looping, then loop + // else stop + if(sbuf->looping) + { + dma_adr[ii]=dma_adr0[ii]; + dma_len[ii]=dma_buflen[ii]=sbuf->databufsize; + } + else + { + sound_stop(ii); + } + } + } + } // for + LeaveCriticalSection(&channel_startstop); +} // jpsdrvr_update_streams() + +// JFL 28 Apr 05 +int create_and_preload_buffer(wavinfo *wavhdr, jps_sndbuf *sbuf) +{ + int ec; + int dsbuf_size; + + if (!dsp_init) + return JPS_ERROR; + + sbuf->looping = 0; + + // copy the sound size to the jps_sndbuf struct + // (this info isn't kept by DS) + sbuf->nSamplesPerSec = wavhdr->num_samples_per_sec; + sbuf->nChannels = wavhdr->num_channels; // mono/stereo + + if (sbuf->streaming) + { + sbuf->numbytes = wavhdr->Size3; // size of whole sound + + if(sbuf->numbytesnumbytes) + dsbuf_size<<=1; + } + + if(dsbuf_size>streambufsize) + dsbuf_size=streambufsize; + + } // streaming + else + { + dsbuf_size = wavhdr->Size3; +#if JPS_SIMULATE_MONO + // we need to create a stereo file, so + // we need to double the reported size in bytes + // of the wav file. + // be sure to indicate that we're only single channel + // until we've finished loading the sound data + if (sbuf->nChannels == 1) + dsbuf_size *= 2; +#endif + sbuf->numbytes = dsbuf_size; + } // not-streaming + + sbuf->databufsize = dsbuf_size; + if(!(sbuf->data=jps_memalloc(NULL,0,dsbuf_size))) + goto BAIL; + + // reset the file pointer so it's pointing to the beginning of the file + sbuf->file_curpos = sbuf->file_hdrpos; + sbuf->file_endpos = sbuf->file_hdrpos+sbuf->numbytes; + + if(jps_fseek((sbuf)->file_pointer,(sbuf)->file_curpos,SEEK_SET)) + { + msg("create_and_preload_buffer() jps_fseek err\n"); + goto BAIL; + } + + // reset 'dma' for this channel + dma_len[sbuf->channel_num]=dma_buflen[sbuf->channel_num]=0; + dma_adr[sbuf->channel_num] = NULL; + + // handle not streaming + if(!(sbuf->streaming)) + { +#if JPS_SIMULATE_MONO + // if we're mono, we're going to write 2x the data read until we fill it + if (sbuf->nChannels == 1) { + int ii; + uint16 *buf16 = (uint16 *)sbuf->data; + jps_fread(buf16,dsbuf_size/2,1,sbuf->file_pointer); + #error -- check this.. + for (ii=(dsbuf_size/2/2)-1;ii>=0;ii--) + { + buf16[ii*2] = buf16[ii*2+1] = buf16[ii]; + } + // we're a 2-channel buffer now! + sbuf->nChannels = 2; + } else +#endif // JPS_SIMULATE_MONO + if(JPS_OK!=copy_to_dsbuf(sbuf,dsbuf_size,&ec)) + { + msg("create_and_preload_buffer() jps_fread err\n"); + goto BAIL; + } + } // !streaming + + ec=JPS_OK; + if(0) + { +BAIL: + ec=JPS_ERROR; + } + return ec; +} // create_and_preload_buffer() + +// JFL 18 Jul 04 +// JFL 29 Apr 05 +int sound_playbuf(jps_sndbuf *sbuf,uns16 channel) +{ + uint32 len; + + if (!sbuf) + goto errorexit; + if (!sbuf->data) + goto errorexit; + if (channel >= JPS_NUM_CHANNELS) + goto errorexit; + if (!sbuf->streaming && channel_busy(channel)) + goto errorexit; + + sbuf->channel_num = channel; + jps_channel_data[channel].curr_buf = sbuf; + sbuf->playflags=0; // only place these are cleared + + // setup dma + // adr is current, adr0 is first, adrx is one-past-last-valid + dma_len[channel]=dma_buflen[channel]=0; + dma_adr[channel] = dma_adr0[channel] = dma_adrx[channel] = sbuf->data; + dma_adrx[channel] += sbuf->databufsize; + + if(sbuf->nChannels==1) + dma_stereo[sbuf->channel_num]=0; + else + dma_stereo[sbuf->channel_num]=1; + + if(sbuf->looping) + dma_looping[sbuf->channel_num]=1; + else + dma_looping[sbuf->channel_num]=0; + + + // setup for streaming + if(sbuf->streaming) + { + sbuf->dest_offset = 0; + sbuf->file_curpos = sbuf->file_hdrpos; + + // copy data into the buffer + if(JPS_OK==copy_to_dsbuf(sbuf,sbuf->databufsize,&len)) + { + // check if we can make this a static buffer + if(sbuf->numbytes <= len) + { + // we're static now! + if (sbuf->file_pointer) + { + // err("sound_playbuf() closing %08X streaming=%d\n",sbuf->name[0],sbuf->streaming); + jps_fclose(sbuf->file_pointer); + sbuf->file_pointer=NULL; + } + sbuf->streaming = 0; + } // copied + } // small enough + } // if streaming + else + { + // buffer is wholly pre-loaded, kick it off + dma_len[channel]=dma_buflen[channel]=sbuf->databufsize; + } + +errorexit: + return JPS_OK; +} // sound_playbuf() + +int sound_play(jps_sndbuf *sbuf,uint16 channel) +{ + int ec; + sbuf->playflags=0; + EnterCriticalSection(&channel_startstop); + ec=sound_playbuf(sbuf, channel); + LeaveCriticalSection(&channel_startstop); + return ec; +} // sound_play() + +int sound_stopbuf(jps_sndbuf *sbuf) +{ + unsigned channel; + + if(!sbuf || !sbuf->data || ((channel=sbuf->channel_num)>=JPS_NUM_CHANNELS)) + return -1; + + if(sbuf==jps_channel_data[channel].curr_buf) + jps_channel_data[channel].curr_buf=NULL; // signal not-playing-o + else if(jps_channel_data[channel].curr_buf) + msg("sound_stopbuf"); + + sbuf->playflags&=~M_SNDBUF_PLAYING; // only place this flag is cleared + + dma_adr[channel]=NULL; + + return 0; +} // sound_stopbuf() + +// JFL 29 Apr 05 +int sound_stop(int channel) +{ + if((channel<0)||(channel>JPS_NUM_CHANNELS)) + return JPS_ERROR; + + dma_adr[channel]=NULL; + jps_channel_data[channel].curr_buf = NULL; + return JPS_OK; +} + +//#error -- make sure static buffers close file handles on load + +// JFL 28 Apr 05 +int free_buffers(jps_sndbuf *sbuf) +{ + if (!dsp_init) + return JPS_ERROR; + + // free buffer + if (sbuf->data) + { + jps_memfree(sbuf->data); + sbuf->data=NULL; + } + + // close file + if (sbuf->file_pointer) + { + jps_fclose (sbuf->file_pointer); + sbuf->file_pointer=NULL; + } + + return JPS_OK; +} // free_buffers() + +uint32 vol_to_db[256] = +{ +4, +4, +4, +4, +4, +4, +5, +5, +5, +5, +5, +6, +6, +6, +6, +7, +7, +7, +7, +8, +8, +8, +9, +9, +9, +10, +10, +10, +11, +11, +12, +12, +13, +13, +14, +14, +15, +15, +16, +16, +17, +18, +18, +19, +20, +21, +22, +22, +23, +24, +25, +26, +27, +28, +29, +30, +32, +33, +34, +35, +37, +38, +40, +41, +43, +45, +46, +48, +50, +52, +54, +56, +58, +61, +63, +66, +68, +71, +74, +76, +79, +83, +86, +89, +93, +96, +100, +104, +108, +112, +117, +121, +126, +131, +136, +141, +147, +152, +158, +165, +171, +178, +185, +192, +199, +207, +215, +224, +233, +242, +251, +261, +271, +282, +293, +304, +316, +328, +341, +355, +369, +383, +398, +414, +430, +446, +464, +482, +501, +521, +541, +562, +584, +607, +631, +655, +681, +708, +735, +764, +794, +825, +857, +891, +926, +962, +1000, +1039, +1079, +1122, +1165, +1211, +1258, +1308, +1359, +1412, +1467, +1525, +1584, +1646, +1711, +1778, +1847, +1919, +1994, +2072, +2154, +2238, +2325, +2416, +2511, +2609, +2711, +2817, +2927, +3042, +3161, +3285, +3413, +3547, +3685, +3830, +3979, +4135, +4297, +4465, +4640, +4821, +5010, +5206, +5409, +5621, +5841, +6069, +6307, +6554, +6810, +7076, +7353, +7641, +7940, +8250, +8573, +8909, +9257, +9619, +9996, +10387, +10793, +11215, +11654, +12110, +12584, +13076, +13588, +14119, +14672, +15246, +15842, +16462, +17106, +17775, +18471, +19193, +19944, +20724, +21535, +22378, +23253, +24163, +25108, +26090, +27111, +28172, +29274, +30419, +31609, +32846, +34131, +35466, +36854, +38295, +39794, +41350, +42968, +44649, +46396, +48211, +50097, +52057, +54094, +56210, +58409, +60694, +63069, +65535, +}; + +int channel_set_volume(int channel_num, int volume) +{ + if(volume<0) + volume=0; + else if(volume>255) + volume=255; + + if(channel_num >= JPS_NUM_CHANNELS) + return JPS_ERROR; + + jps_channel_data[channel_num].volume = vol_to_db[volume]; + channel_volume_inv[channel_num] = (float)jps_channel_data[channel_num].volume/65535.0f; + jps_channel_data[channel_num].index = volume; + + return JPS_OK; +} + +// JFL 28 Apr 05 +void jps_master_volume(int volume) +{ + if (!dsp_init) + return; + + if (volume < 0) volume=0; + else if(volume>255) volume=255; + + master_volume=volume; + master_volume_inv=(float)volume/255.0f; +} // jps_master_volume() + +// JFL 28 Apr 05 +int channel_busy(int channel) +{ + if (!dsp_init) + return JPS_ERROR; + if((channel<0)||(channel>=JPS_NUM_CHANNELS)) + return JPS_ERROR; + + if(dma_adr[channel]) + return 1; + + return 0; +} // channel_busy() + +// JFL 29 Apr 05 +void InitializeCriticalSection(CRITICAL_SECTION *lockp) +{ + pthread_mutex_init(lockp, NULL); +} // InitializeCriticalSection() + +// JFL 29 Apr 05 +void DestroyCriticalSection(CRITICAL_SECTION *lockp) +{ + pthread_mutex_destroy(lockp); +} // DestroyCriticalSection() + +// JFL 29 Apr 05 +void EnterCriticalSection(CRITICAL_SECTION *lockp) +{ +/************************************** +** hold off execution until there are +** no holds on the given critical +** section +**************************************/ + pthread_mutex_lock(lockp); +} // EnterCriticalSection() + +// JFL 29 Apr 05 +void LeaveCriticalSection(CRITICAL_SECTION *lockp) +{ +/************************************** +** free up a critical section for +** others to use +**************************************/ + pthread_mutex_unlock(lockp); +} // LeaveCriticalSection() + +void *jps_memalloc (void **raw_ptr, uint32 alignbound, uint32 size) { +/************************************** +** +**************************************/ + void *pTemp; + // no need to align memory in windoze + pTemp=jps_apphook_malloc(size); + if (raw_ptr) + *raw_ptr = pTemp; + return(pTemp); +} // jps_memalloc() + +void jps_memfree(void *raw_ptr) +{ + jps_apphook_free(raw_ptr); +} // jps_memfree() + +// +// setMixer +// set the output mixer values +// +// in: +// out: +// global: +// +// GNP 07 Nov 05 +// +void setMixer(int val, int pcmval) +{ + //int mixerfd; + int ctrl, arg, left, right; + + if ( dsp_fd < 0 ) + return; + + for (ctrl = 0; ctrl < SOUND_MIXER_NRDEVICES; ctrl++) + { + if ( ctrl == SOUND_MIXER_PCM ) + { + left = pcmval; + right = pcmval; + } + else + { + left = val; + right = val; + } + + arg = left | (right << 8); + + if (ioctl(dsp_fd, MIXER_WRITE(ctrl), &arg) == -1) + { + } + } + +//DONE("setMixer") +} // setMixer + +#endif // SYS_BB +// EOF diff --git a/libraries/pmrt/jpsnd/jpsdrvr_lin.o b/libraries/pmrt/jpsnd/jpsdrvr_lin.o new file mode 100644 index 0000000..89e07a2 Binary files /dev/null and b/libraries/pmrt/jpsnd/jpsdrvr_lin.o differ diff --git a/libraries/pmrt/jpsnd/jpslib.dsp b/libraries/pmrt/jpsnd/jpslib.dsp new file mode 100755 index 0000000..bdbec47 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpslib.dsp @@ -0,0 +1,173 @@ +# Microsoft Developer Studio Project File - Name="jpslib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=jpslib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "jpslib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "jpslib.mak" CFG="jpslib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "jpslib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "jpslib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/jpsnd", POCAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "jpslib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=copy .\Release\jpslib.lib c:\G3\lib\ copy .\jpsdefs.h c:\G3\include\ +# End Special Build Tool + +!ELSEIF "$(CFG)" == "jpslib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "jpslib___Win32_Debug" +# PROP BASE Intermediate_Dir "jpslib___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_WIN32" /D "_LIB" /D "SYS_PC" /Fr /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=copy .\Debug\jpslib.lib c:\G3\lib\ copy .\jpsdefs.h c:\G3\include\ +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "jpslib - Win32 Release" +# Name "jpslib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\jps.c +# End Source File +# Begin Source File + +SOURCE=.\jps_marsig.c +# End Source File +# Begin Source File + +SOURCE=.\jps_parse.c +# End Source File +# Begin Source File + +SOURCE=.\jps_pfuncs.c +# End Source File +# Begin Source File + +SOURCE=.\jps_player.c +# End Source File +# Begin Source File + +SOURCE=.\jps_snd.c +# End Source File +# Begin Source File + +SOURCE=.\jpsdrvr_5500.c +# End Source File +# Begin Source File + +SOURCE=.\jpsdrvr_dx.c +# End Source File +# Begin Source File + +SOURCE=.\jpsdrvr_lin.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\jpdrvr_snd.h +# End Source File +# Begin Source File + +SOURCE=.\jps.h +# End Source File +# Begin Source File + +SOURCE=.\jps_marsig.h +# End Source File +# Begin Source File + +SOURCE=.\jps_parse.h +# End Source File +# Begin Source File + +SOURCE=.\jps_player.h +# End Source File +# Begin Source File + +SOURCE=.\jps_snd.h +# End Source File +# Begin Source File + +SOURCE=.\jps_volume.h +# End Source File +# Begin Source File + +SOURCE=.\jpsdefs.h +# End Source File +# Begin Source File + +SOURCE=.\jpsdrvr.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/jpsnd/jpslib.plg b/libraries/pmrt/jpsnd/jpslib.plg new file mode 100755 index 0000000..68d2d44 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpslib.plg @@ -0,0 +1,66 @@ + + +
+

Build Log

+

+--------------------Configuration: jpslib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\Joe\LOCALS~1\Temp\RSP314.tmp" with contents +[ +/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Release/jpslib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"C:\G3\jpsnd\jps.c" +"C:\G3\jpsnd\jps_marsig.c" +"C:\G3\jpsnd\jps_parse.c" +"C:\G3\jpsnd\jps_pfuncs.c" +"C:\G3\jpsnd\jps_player.c" +"C:\G3\jpsnd\jps_snd.c" +"C:\G3\jpsnd\jpsdrvr_5500.c" +"C:\G3\jpsnd\jpsdrvr_dx.c" +"C:\G3\jpsnd\jpsdrvr_lin.c" +] +Creating command line "cl.exe @C:\DOCUME~1\Joe\LOCALS~1\Temp\RSP314.tmp" +Creating temporary file "C:\DOCUME~1\Joe\LOCALS~1\Temp\RSP315.tmp" with contents +[ +/nologo /out:"Release\jpslib.lib" +.\Release\jps.obj +.\Release\jps_marsig.obj +.\Release\jps_parse.obj +.\Release\jps_pfuncs.obj +.\Release\jps_player.obj +.\Release\jps_snd.obj +.\Release\jpsdrvr_5500.obj +.\Release\jpsdrvr_dx.obj +.\Release\jpsdrvr_lin.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\Joe\LOCALS~1\Temp\RSP315.tmp" +

Output Window

+Compiling... +jps.c +jps_marsig.c +jps_parse.c +jps_pfuncs.c +jps_player.c +jps_snd.c +jpsdrvr_5500.c +jpsdrvr_dx.c +jpsdrvr_lin.c +Creating library... +Creating temporary file "C:\DOCUME~1\Joe\LOCALS~1\Temp\RSP316.bat" with contents +[ +@echo off +copy .\Release\jpslib.lib c:\G3\lib\ +copy .\jpsdefs.h c:\G3\lib\ +] +Creating command line "C:\DOCUME~1\Joe\LOCALS~1\Temp\RSP316.bat" + + 1 file(s) copied. + 1 file(s) copied. + + + +

Results

+jpslib.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/jpsnd/jpstest.c b/libraries/pmrt/jpsnd/jpstest.c new file mode 100755 index 0000000..cdda506 --- /dev/null +++ b/libraries/pmrt/jpsnd/jpstest.c @@ -0,0 +1,364 @@ +// jpstest.c +// simpler test-bed for jps +// +// JFL 27 Apr 05 + +#include +#include +#include +#include +#include +#include + +// for Windows +// preprocessor defines: _CONSOLE,SYS_PC +// libs: kernel32.lib user32.lib jpslib.lib dsound.lib +// libpath: Debug + +// types jps needs defined +typedef unsigned int uns32; +typedef int int32; +typedef unsigned short uns16; +typedef short int16; +typedef unsigned char uns8; +typedef char int8; +#if SYS_PC +typedef __int64 int64; +typedef unsigned __int64 uns64; +#else // !SYS_PC +typedef long long int64; +typedef unsigned long long uns64; +#endif // !SYS_PC + +//#define BANKFILE "/g3/bbh3data/snd/plstest.txt" +//#define SOUND 35 +//#define BANKFILE "/home/g3/bbh3data/snd/plstest1.txt" +//#define SOUND 1556 + +#if SYS_PC +//#define BANKFILE "/g3/bbh3data/snd/plsperm.txt" +//#define SOUND 2 +#define BANKFILE "../bbh3data/snd/plstest.txt" +#define SOUND 3 +#endif + +#if SYS_BB +//#define BANKFILE "../bbh3data/snd/plstest.txt" +//#define SOUND 35 +#define BANKFILE "../bbh3data/snd/plsperm.txt" +#define SOUND 1 +#endif + +#include "jpsdefs.h" + +#define COUNT(x) (sizeof(x)/sizeof((x)[0])) + +void* jps_memdebug_ptr[2048]; + +void jpstestFile(char *fpath) +{ + char buf[1024],*s1; + char line[1024]; + int n; + FILE *ftmp=NULL; + + ftmp=fopen(fpath,"rb"); + if(!ftmp) + goto BAIL; + + for(;;) + { + if(!fgets(buf,sizeof(buf)-1,ftmp)) + break; + buf[sizeof(buf)-1]=0; + + printf("%s\n",buf); + if(!strncmp("SndPlay",buf,6)) + + { + s1=&buf[6]; + s1=strchr(s1,'('); + if(!s1) + continue; + s1++; + sscanf(s1,"%d",&n); + + fgets(line,sizeof(line)-1,stdin); + + if(line[0]=='q') + break; + if(line[0]=='\n') + { + jps_play(NULL, n, 255); + } + } + } // for + +BAIL: + if(ftmp) + fclose(ftmp); +} // jpstestFile() + +// JFL 27 Jul 05 +void jpsVolTable(void) +{ + int i,j,k; + double a; + // direct sound works in decibels of attenuation + // -10,000 = 100dB attenuation = silent + // 0 = no attenuation = loudest + // map 0 (silent) .. 255 (loudest) to these units + + // + // + // + + // build mapping table + k=0; + for(i=0;i<=255;i++) + { + a=255-i; // 0=loudest 255=silent + + #if 1 // x^4 + a=a*a*a*a; + a/=(255.0*255.0*255.0*255.0); + a*=-10000.0f; + #endif // x^4 + + j=(int)a; + printf("%d,",j); + if(++k>7) + { + printf("\n"); + k=0; + } + } // for +} // jpsVolTable() + +int main(int argc,char *argv[]) +{ + int ec; + char c,line[512],last[512],*playstr; + jps_bank * bank = NULL; + char *bankfilename=BANKFILE; + int snd=-1; + unsigned char vol=255,vv; + int i; + + if(argc>1) + { + playstr=argv[1]; + if(playstr[0]=='-' && playstr[1]=='v' && playstr[2]=='t') + { + jpsVolTable(); + goto BAIL; + } + } + for(ec=0;ec -- set sound number v -- set vol\n"); + printf("s -- stop all\n"); + if((ec=jps_init())) + { + printf("* ERROR * jps_init()=%d\n",ec); + } + jps_master_volume(255); + + last[0]=0; + for(;;) + { + playstr=NULL; + fgets(line,sizeof(line)-1,stdin); + + if(line[0]=='\n' && last[0]) + playstr=last; + else + strncpy(last,line,sizeof(last)); + + switch((c=line[0])) + { + case 'q': + case 'Q': + goto done; + + case 'v': + vol=(unsigned char)strtoul(line+1,NULL,0); + printf("vol %d\n",vol); + continue; + + case 'V': + vv=(unsigned char)strtoul(line+1,NULL,0); + printf("Master volume %d\n",vv); + jps_master_volume(vv); + continue; + + case 's': + printf("jps_stopall_players\n"); + jps_stopall_players(); + continue; + + case 'f': + for(ec=2;ec='0')&&(c<='9')) + playstr=line; + + } // switch + + + if(!bank) + { + bankfilename="/g3/bbh3data/snd/plsperm.txt"; + if(!(bank=jps_bank_load(bankfilename))) + printf("couldn't load %s\n",bankfilename); + + bankfilename="/g3/bbh3data/snd/plsdeer.txt"; + if(!(bank=jps_bank_load(bankfilename))) + printf("couldn't load %s\n",bankfilename); + + bankfilename="/g3/bbh3data/snd/plsspeech.txt"; + if(!(bank=jps_bank_load(bankfilename))) + printf("couldn't load %s\n",bankfilename); + + //if(!(bank=jps_bank_load(bankfilename))) + // printf("couldn't load %s\n",bankfilename); + } // !bank + if(!bank) + continue; + + while(1) + { + if(playstr && *playstr!='\n') + { + + snd=strtol(playstr,&playstr,0); + if(playstr) + { + while(*playstr && (*playstr<'0'||*playstr>'9')) + playstr++; + } + } + if(snd<0) + break; + + printf("%s %d vol=%d\n",bankfilename,snd,vol); + jps_play(NULL, snd, vol); + + if(!playstr || !*playstr) + break; + + } // while + + } // for +done: + jps_shutdown(); + + ec=0; + for(i=0;i +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=jpstst - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "jpstst.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "jpstst.mak" CFG="jpstst - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "jpstst - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "jpstst - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "jpstst - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "_CONSOLE" /D "SYS_PC" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib dsound.lib jpslib.lib /nologo /subsystem:console /machine:I386 /libpath:"Release" + +!ELSEIF "$(CFG)" == "jpstst - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /D "_CONSOLE" /D "SYS_PC" /FR /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib dsound.lib jpslib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"Debug" +# SUBTRACT LINK32 /nodefaultlib + +!ENDIF + +# Begin Target + +# Name "jpstst - Win32 Release" +# Name "jpstst - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\jpstest.c +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/jpsnd/libjps.a b/libraries/pmrt/jpsnd/libjps.a new file mode 100644 index 0000000..cc45f59 Binary files /dev/null and b/libraries/pmrt/jpsnd/libjps.a differ diff --git a/libraries/pmrt/jpsnd/makedepend b/libraries/pmrt/jpsnd/makedepend new file mode 100644 index 0000000..24b2f23 --- /dev/null +++ b/libraries/pmrt/jpsnd/makedepend @@ -0,0 +1,121 @@ +jpsdrvr_lin.o: jpsdrvr_lin.c /usr/include/stdlib.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h jps.h \ + jpsdefs.h jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h jps_player.h \ + /usr/include/fcntl.h /usr/include/bits/fcntl.h /usr/include/sys/ioctl.h \ + /usr/include/bits/ioctls.h /usr/include/asm/ioctls.h \ + /usr/include/asm/ioctl.h /usr/include/bits/ioctl-types.h \ + /usr/include/sys/ttydefaults.h /usr/include/sys/soundcard.h \ + /usr/include/linux/soundcard.h /usr/include/linux/ioctl.h \ + /usr/include/sys/mman.h /usr/include/bits/mman.h /usr/include/sys/shm.h \ + /usr/include/sys/ipc.h /usr/include/bits/ipctypes.h \ + /usr/include/bits/ipc.h /usr/include/bits/shm.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h +jps.o: jps.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h jps.h \ + jpsdefs.h jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h jps_player.h +jps_snd.o: jps_snd.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h jps.h \ + jpsdefs.h jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h jps_player.h +jps_parse.o: jps_parse.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + jps.h jpsdefs.h jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h \ + jps_player.h +jps_marsig.o: jps_marsig.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h jps.h jpsdefs.h \ + jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h jps_player.h +jps_pfuncs.o: jps_pfuncs.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h jps.h jpsdefs.h \ + jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h jps_player.h +jps_player.o: jps_player.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h jps.h jpsdefs.h \ + jps_snd.h jps_marsig.h jps_parse.h jpsdrvr.h jps_player.h diff --git a/libraries/pmrt/modem/Debug/Modem.lib b/libraries/pmrt/modem/Debug/Modem.lib new file mode 100755 index 0000000..a39b597 Binary files /dev/null and b/libraries/pmrt/modem/Debug/Modem.lib differ diff --git a/libraries/pmrt/modem/Debug/Modem.pch b/libraries/pmrt/modem/Debug/Modem.pch new file mode 100755 index 0000000..4301fa9 Binary files /dev/null and b/libraries/pmrt/modem/Debug/Modem.pch differ diff --git a/libraries/pmrt/modem/Debug/modem.obj b/libraries/pmrt/modem/Debug/modem.obj new file mode 100755 index 0000000..60191f5 Binary files /dev/null and b/libraries/pmrt/modem/Debug/modem.obj differ diff --git a/libraries/pmrt/modem/Debug/modem_lin.obj b/libraries/pmrt/modem/Debug/modem_lin.obj new file mode 100755 index 0000000..a45945c Binary files /dev/null and b/libraries/pmrt/modem/Debug/modem_lin.obj differ diff --git a/libraries/pmrt/modem/Debug/modem_pc.obj b/libraries/pmrt/modem/Debug/modem_pc.obj new file mode 100755 index 0000000..9875074 Binary files /dev/null and b/libraries/pmrt/modem/Debug/modem_pc.obj differ diff --git a/libraries/pmrt/modem/Debug/vc60.idb b/libraries/pmrt/modem/Debug/vc60.idb new file mode 100755 index 0000000..1ff72bc Binary files /dev/null and b/libraries/pmrt/modem/Debug/vc60.idb differ diff --git a/libraries/pmrt/modem/Debug/vc60.pdb b/libraries/pmrt/modem/Debug/vc60.pdb new file mode 100755 index 0000000..a18a1da Binary files /dev/null and b/libraries/pmrt/modem/Debug/vc60.pdb differ diff --git a/libraries/pmrt/modem/Modem.dsp b/libraries/pmrt/modem/Modem.dsp new file mode 100755 index 0000000..ec06571 --- /dev/null +++ b/libraries/pmrt/modem/Modem.dsp @@ -0,0 +1,116 @@ +# Microsoft Developer Studio Project File - Name="Modem" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=Modem - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Modem.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Modem.mak" CFG="Modem - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Modem - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "Modem - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries/pmrt/modem", DTQAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Modem - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "Modem - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\modem copy *.h c:\g3\include\modem\ copy debug\modem.lib c:\g3\lib\ +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "Modem - Win32 Release" +# Name "Modem - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\modem.c +# End Source File +# Begin Source File + +SOURCE=.\modem_lin.c +# End Source File +# Begin Source File + +SOURCE=.\modem_pc.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\modem.h +# End Source File +# Begin Source File + +SOURCE=.\modempriv.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/modem/Modem.dsw b/libraries/pmrt/modem/Modem.dsw new file mode 100755 index 0000000..b2db8e3 --- /dev/null +++ b/libraries/pmrt/modem/Modem.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Modem"=.\Modem.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/modem/Modem.ncb b/libraries/pmrt/modem/Modem.ncb new file mode 100755 index 0000000..d2bd8d9 Binary files /dev/null and b/libraries/pmrt/modem/Modem.ncb differ diff --git a/libraries/pmrt/modem/Modem.plg b/libraries/pmrt/modem/Modem.plg new file mode 100755 index 0000000..8f8ac27 --- /dev/null +++ b/libraries/pmrt/modem/Modem.plg @@ -0,0 +1,47 @@ + + +
+

Build Log

+

+--------------------Configuration: Modem - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSP1B1.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/Modem.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\G3\libraries\pmrt\Modem\modem.c" +"C:\G3\libraries\pmrt\Modem\modem_lin.c" +"C:\G3\libraries\pmrt\Modem\modem_pc.c" +] +Creating command line "cl.exe @C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSP1B1.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\Modem.lib" .\Debug\modem.obj .\Debug\modem_lin.obj .\Debug\modem_pc.obj " +

Output Window

+Compiling... +modem.c +modem_lin.c +modem_pc.c +c:\g3\libraries\pmrt\modem\modem.h(81) : warning C4005: 'msg' : macro redefinition + c:\g3\libraries\pmrt\card\card.h(86) : see previous definition of 'msg' +Creating library... +Creating temporary file "C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSP1B2.bat" with contents +[ +@echo off +mkdir c:\g3\include\modem +copy *.h c:\g3\include\modem\ +copy debug\modem.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\rahmed\LOCALS~1\Temp\RSP1B2.bat" + +A subdirectory or file c:\g3\include\modem already exists. +modem.h +modempriv.h + 2 file(s) copied. + 1 file(s) copied. + + + +

Results

+Modem.lib - 0 error(s), 1 warning(s) +
+ + diff --git a/libraries/pmrt/modem/Release/Modem.pch b/libraries/pmrt/modem/Release/Modem.pch new file mode 100755 index 0000000..0e99f93 Binary files /dev/null and b/libraries/pmrt/modem/Release/Modem.pch differ diff --git a/libraries/pmrt/modem/Release/modem_lin.obj b/libraries/pmrt/modem/Release/modem_lin.obj new file mode 100755 index 0000000..d007a18 Binary files /dev/null and b/libraries/pmrt/modem/Release/modem_lin.obj differ diff --git a/libraries/pmrt/modem/Release/modem_pc.obj b/libraries/pmrt/modem/Release/modem_pc.obj new file mode 100755 index 0000000..67f6bd8 Binary files /dev/null and b/libraries/pmrt/modem/Release/modem_pc.obj differ diff --git a/libraries/pmrt/modem/Release/vc60.idb b/libraries/pmrt/modem/Release/vc60.idb new file mode 100755 index 0000000..e6dcf64 Binary files /dev/null and b/libraries/pmrt/modem/Release/vc60.idb differ diff --git a/libraries/pmrt/modem/libModem.a b/libraries/pmrt/modem/libModem.a new file mode 100644 index 0000000..ee0874d Binary files /dev/null and b/libraries/pmrt/modem/libModem.a differ diff --git a/libraries/pmrt/modem/makedeplib b/libraries/pmrt/modem/makedeplib new file mode 100644 index 0000000..8fd47f0 --- /dev/null +++ b/libraries/pmrt/modem/makedeplib @@ -0,0 +1,64 @@ +modem.o: modem.c modem.h modempriv.h /g3/include/hid.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /g3/include/usb.h /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/hidparser.h \ + /g3/include/hidtypes.h /usr/include/termios.h \ + /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /usr/include/string.h +modem_lin.o: modem_lin.c modem.h modempriv.h /g3/include/hid.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /g3/include/usb.h /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/hidparser.h \ + /g3/include/hidtypes.h /usr/include/termios.h \ + /usr/include/bits/termios.h /usr/include/sys/ttydefaults.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \ + /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h \ + /usr/include/bits/ioctl-types.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/string.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/error.h diff --git a/libraries/pmrt/modem/makefile b/libraries/pmrt/modem/makefile new file mode 100755 index 0000000..f4d5752 --- /dev/null +++ b/libraries/pmrt/modem/makefile @@ -0,0 +1,38 @@ +# make driver +# make install (as root) +# +.CLIBFILES = modem.c modem_lin.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libModem.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -Wno-format -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /g3/lib/libpmrt_utils.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/modem + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/modem + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/modem/modem.c b/libraries/pmrt/modem/modem.c new file mode 100755 index 0000000..8a38956 --- /dev/null +++ b/libraries/pmrt/modem/modem.c @@ -0,0 +1,389 @@ +// +// modem.c +// modem library +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Aug 07 +// + +// include files +#include "modem.h" +#include "modempriv.h" +#include +#include +#include +#include + +// local definitions +#define msg modem_apphook_msg + +// global data +int modemReady=0; +sModemDev modemMem,*modemDev; + +// local data + +// global functions + +// forward + +// +// ModemInit +// called once at system start +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int ModemInit(void) +{ + int ec=0; + + modemDev=NULL; + modemReady=0; + memset(&modemMem,0,sizeof(modemMem)); + + if((ec=modemDrvrInit(&modemMem))<0) + goto BAIL; + + modemMem.bufsize=RECEIVE_BUFFER_SIZE; + if(!(modemMem.buf=modem_apphook_malloc(modemMem.bufsize))) + { + ec=ERR_MODEM_MEM; + goto BAIL; + } + + modemMem.sndsize=SEND_BUFFER_SIZE; + if(!(modemMem.snd=modem_apphook_malloc(modemMem.sndsize))) + { + // free what we had + if(modemMem.buf) + modem_apphook_free(modemMem.buf); + modemMem.buf=NULL; + ec=ERR_MODEM_MEM; + goto BAIL; + } + + modemDev=&modemMem; + + modemDev->iComPort[0] = MODEM_AT_IOPORT_DEFAULT; // Open COM Port # + modemDev->iComPort[1] = MODEM_DM_IOPORT_DEFAULT; // Open COM Port # + modemDev->iPd[0] = -1; + modemDev->iPd[1] = -1; + modemDev->iBaudRate = MODEM_BAUD_DEFAULT; // baudrate + modemDev->modemType = MODEM_AIRCARD875U; + +//DONE("ModemInit") +BAIL: + return(ec); +} // ModemInit + +// +// ModemFinal +// called once at system shutdown +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +void ModemFinal(void) +{ + if(modemDev) + modemDrvrFinal(modemDev); + + // free alloc'd memory + if(modemMem.buf) + modem_apphook_free(modemMem.buf); + modemMem.buf=NULL; + + if(modemMem.snd) + modem_apphook_free(modemMem.snd); + modemMem.snd=NULL; + + modemDev=NULL; +//DONE("ModemFinal") +} // ModemFinal + +// +// ModemBegin +// start the modem driver +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int ModemBegin(void) +{ + int ec=0; + if(modemDev) + { + modemDev->flags = 0; + modemDev->errorf = 0; +#if DEBUG +// modemDev->flags |= M_MODEM_FLAGS_DM_PRINT; +#endif + ec=modemDrvrOpen(modemDev); + } + else + ec=-1; +//DONE("ModemBegin") + return(ec); +} // ModemBegin + +// +// ModemEnd +// +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +void ModemEnd(void) +{ + if(modemDev) + modemDrvrClose(modemDev); +//DONE("ModemEnd") +} // ModemEnd + +// +// ModemChangePortSettings +// change the port settings for the modem +// +// in: +// port = com port # +// baud = baud rate +// out: +// global: +// +// GNP 16 Aug 07 +// +int ModemChangePortSettings(unsigned int port, unsigned long baud) +{ + int ec=0; + + if (modemDev) + { + modemDev->iComPort[0] = port; // Open COM Port # + modemDev->iBaudRate = baud; // baudrate + if (modemDrvrIsPresent(modemDev)) + { + // close and open with new baud + modemDrvrClose(modemDev); + ec=modemDrvrOpen(modemDev); + } + } + else + ec = -1; +//DONE("ModemChangePortSettings") + return(ec); +} // ModemChangePortSettings + +// +// ModemLoop +// +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int ModemLoop(void) +{ + sModemDev *mdev; + int i; + + if(!(mdev=modemGetDevice())) + return(ERR_MODEM_DEVICE_NOTAVAILABLE); + + modemSendLoop(mdev); + modemReadLoop(mdev); + + if(mdev->avail) + { + i=0; + while (mdev->bufn) + { + if(mdev->bufr>=mdev->bufsize) + mdev->bufr=0; + if(itransferBuf[i++] = mdev->buf[mdev->bufr++]; + else + mdev->bufr++; + mdev->bufn--; + } //while + + mdev->transferBuf[i]=0; + mdev->avail=0; + + if(strstr(mdev->transferBuf,"OK") != NULL) + { + if(mdev->callback) + (*mdev->callback)(MODEMCALLBACK_OK,mdev->transferBuf,i); + } + else if (strstr(mdev->transferBuf,"ERROR") != NULL) + { + if(mdev->callback) + (*mdev->callback)(MODEMCALLBACK_ERROR,mdev->transferBuf,i); + } + else + { + if(mdev->callback) + (*mdev->callback)(MODEMCALLBACK_UNKNOWN,mdev->transferBuf,i); + } + + printf("%s \n", mdev->transferBuf); + } + +//DONE("ModemLoop") + return(0); +} // ModemLoop + +// +// ModemOp +// +// +// in: +// out: +// global: +// +// GNP 27 Aug 07 +// +int ModemOp(unsigned int op,...) +{ + int ec; + va_list args; + unsigned char *buf; + int i; + char *s1; + + va_start(args,op); + + switch(op&M_MODEMOP) + { + + case MODEMOP_GETVERSTRING: + // prts_debug("MODEM: getverstring \n"); + + buf=va_arg(args,char*); + i=va_arg(args,int)-1; + s1=MODEM_VER_STRING; + while(i>0 && *s1) + *buf++=*s1++,i--; + s1=MODEMPRIV_VER_STRING; + while(i>0 && *s1) + *buf++=*s1++,i--; + // space + if(i>0) + *buf++=' ',i--; +#ifdef DEBUG + // 'D' for debug + if(i>0) + *buf++='D',i--; +#else + // 'R' for release + if(i>0) + *buf++='R',i--; +#endif + *buf=0; + break; + + case MODEMOP_SETCALLBACK: + // prts_debug("MODEM: setting callback \n"); + if(!modemDev) + { + // prts_debug("MODEM: error setting callback \n"); + ec=ERR_MODEM_DEVICE_NOTAVAILABLE; + goto BAIL; + } + modemDev->callback=va_arg(args,void*); + break; + + case MODEMOP_SENDBUF: + if(!modemDev) + { + ec=ERR_MODEM_DEVICE_NOTAVAILABLE; + // prts_debug("MODEM: error sending buf \n"); + goto BAIL; + } + buf=va_arg(args,char*); + i=va_arg(args,int); + + // prts_debug("MODEM: sending %s \n", buf); + if((ec=modemSend(modemDev,0,buf,i))<0) + goto BAIL; + break; + + case MODEMOP_ISMODEMPRESENT: + // prts_debug("MODEM: ismodepresent \n"); + + if(!modemDev) + { + ec=ERR_MODEM_DEVICE_NOTAVAILABLE; + goto BAIL; + } + else if(!modemDrvrIsPresent(modemDev)) + { + ec=ERR_MODEM_PORT_NOTOPEN; + goto BAIL; + } + break; + default: + // prts_debug("MODEM: op not recognized \n"); + ec=ERR_MODEM_OP_NOTRECOGNIZED; + goto BAIL; + } //switch + + ec=0; +//DONE("ModemOp") +BAIL: + va_end(args); + return ec; +} // ModemOp + + +int ModemFlushIO(void) +{ + sModemDev *mdev; + + if(!(mdev=modemGetDevice())) + return(ERR_MODEM_DEVICE_NOTAVAILABLE); + + mdev->flags |= M_MODEM_FLAGS_FLUSHIO; + return(0); +} //ModemFlushIO + +// +// modemGetDevice +// returns the device ptr for the modem +// +// in: +// out: +// ptr to device, NULL if no device +// global: +// +// GNP 16 Aug 07 +// +sModemDev *modemGetDevice(void) +{ + if(modemDev) + return(&modemMem); + else + return(NULL); +//DONE("modemGetDevice") +} // modemGetDevice + + + +// EOF diff --git a/libraries/pmrt/modem/modem.h b/libraries/pmrt/modem/modem.h new file mode 100755 index 0000000..2048004 --- /dev/null +++ b/libraries/pmrt/modem/modem.h @@ -0,0 +1,89 @@ +// +// modem.h +// modem header +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 16 Aug 07 +// +#ifndef MODEM_H +#define MODEM_H + +#define MODEM_VER_STRING "1" + +// +// MODEMOP_ +// modem operations +// +enum { + MODEMOP_GETVERSTRING=0, + MODEMOP_SETCALLBACK, + MODEMOP_SENDBUF, + MODEMOP_ISMODEMPRESENT, + MODEMOP_RESET, +}; + +#define M_MODEMOP 0xff + +// +// MODEMCALLBACK_ +// callback reasons +// +enum { + MODEMCALLBACK_ERROR=1, // received ERROR + MODEMCALLBACK_OK, // received OK + MODEMCALLBACK_UNKNOWN, // received but don't recognize string +}; + +// +// MODEM_ +// modem type enumerations +// +enum { + MODEM_AIRCARD875U, // Sierra Wireless Aircard + NUM_MODEMS +}; + +/////////////////////////////////////////////////////////////////////////////// +// ERROR CODES +/////////////////////////////////////////////////////////////////////////////// +// +// ERRORS & EXTENDED RETURN CODES +// +// -1.....-8999 user +// -9000..-9099 system +// +enum // int16 +{ + // system + ERR_MODEM_SYS_LAST=-9099, + ERR_MODEM_DEVICE_NOTAVAILABLE, + ERR_MODEM_MEM, + ERR_MODEM_SENDBUFFER_FULL, + ERR_MODEM_PORT_NOTOPEN, + ERR_MODEM_OP_NOTRECOGNIZED, + ERR_MODEM_SYS_FIRST=-9000, + +}; // ERR_ + +extern int ModemInit(void); +extern void ModemFinal(void); +extern int ModemBegin(void); +extern void ModemEnd(void); +extern int ModemChangePortSettings(unsigned int port, unsigned long baud); +extern void ModemGetVersionString(char *buf, int bufSize); +extern int ModemLoop(void); +extern int ModemOp(unsigned int op,...); +extern int ModemFlushIO(void); + + +// apphook +extern void* modem_apphook_malloc(int size); +extern void modem_apphook_free(void *m); +extern void modem_apphook_msg(char *fmt,...); + +#endif // ndef MODEM_H +// EOF + diff --git a/libraries/pmrt/modem/modem.o b/libraries/pmrt/modem/modem.o new file mode 100644 index 0000000..530597a Binary files /dev/null and b/libraries/pmrt/modem/modem.o differ diff --git a/libraries/pmrt/modem/modem_lin.c b/libraries/pmrt/modem/modem_lin.c new file mode 100755 index 0000000..72b59f6 --- /dev/null +++ b/libraries/pmrt/modem/modem_lin.c @@ -0,0 +1,660 @@ +// +// modem_lin.c +// modem linux low-level +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Aug 07 +// +#if SYS_BB + +// include files +#include "modem.h" +#include "modempriv.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// local definitions + +// +// DMSG_ +// debug messaging level +// +enum +{ + DMSG_OFF, + DMSG_1, + DMSG_2, + DMSG_3, + DMSG_MAX, +}; + +// global data + +// local data +static int debugMessageLevel; // current debug messaging level + +char *ioPortDevs[NUM_MODEMS][NUM_MODEM_IOPORTS]= +{ + // Sierra Aircard 875U (usb) + { + "/dev/ttyUSB0", //port 0 - Data + "/dev/ttyUSB1", //port 1 - device mgmt + "/dev/ttyUSB2", //port 2 - AT command port + }, + +}; + +// global functions + +// forward +int ModemOpenPort (sModemDev *mdev); +void *modemThread(void *targ); +int ModemClosePort (sModemDev *mdev); + +// +// dprintf +// debug printf to console +// +static void dprintf(int msgLevel, char *fmt,...) +{ +#ifdef DEBUG + va_list args; + if (msgLevel <= debugMessageLevel) + { + va_start(args,fmt); + vprintf(fmt,args); + va_end(args); + } +#endif //DEBUG +} // dmsg() + +// +// modemDrvrInit +// called once by ModemInit() at system startup +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int modemDrvrInit(sModemDev *mdev) +{ + int ec=0; + + mdev->thread=(pthread_t)NULL; + mdev->iPd[0] = -1; //invalidate port + mdev->iPd[1] = -1; //invalidate port + +#if DEBUG + debugMessageLevel=DMSG_OFF; +#else + debugMessageLevel=DMSG_OFF; +#endif + +//DONE("modemDrvrInit") + return(ec); +} // modemDrvrInit + +// +// modemDrvrFinal +// called once by ModemFinal() at system shutdown +// +// in: +// out: +// global: +// +// GNP 14 Aug 07 +// +void modemDrvrFinal(sModemDev *mdev) +{ + // just in case + modemDrvrClose(mdev); +//DONE("modemDrvrFinal") +} // modemDrvrFinal + +// +// modemDrvrOpen +// called to open port connected to modem +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int modemDrvrOpen(sModemDev *mdev) +{ + int ec=0; +// pthread_attr_t attr; + + mdev->intErrorf=0; + mdev->intFlags=0; + + if(ModemOpenPort(mdev)==FALSE) + { + ModemClosePort(mdev); + ec=-1; + goto BAIL; + } + + mdev->bufn=mdev->bufw=mdev->bufr=0; // clear read buffer + mdev->sndn=mdev->sndw=mdev->sndr=0; + mdev->avail=0; +#if 0 + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); + + // create the watch thread + if(pthread_create(&(mdev->thread),&attr,modemThread,&mdev)) + { + msg( "modemDrvrOpen(): Error creating thread: modemThread\n"); + pthread_attr_destroy(&attr); + ModemClosePort(mdev); // no thread + ec=-1; + goto BAIL; + } + else + { + pthread_attr_destroy(&attr); + } +#endif //0 + +//DONE("modemDrvrOpen") +BAIL: + return(ec); +} // modemDrvrOpen + +// +// modemDrvrClose +// close port connected to modem +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void modemDrvrClose(sModemDev *mdev) +{ + if(mdev->modemType == MODEM_AIRCARD875U) + { + ModemClosePort (mdev); + } + + if(mdev->thread) + pthread_cancel(mdev->thread); + + mdev->thread=(pthread_t)NULL; +//DONE("modemDrvrClose") +} // modemDrvrClose + +// +// modemDrvrIsPresent +// returns TRUE if the modem is present +// +// in: +// out: +// global: +// +// GNP 23 Aug 07 +// +int modemDrvrIsPresent(sModemDev *mdev) +{ + if (mdev->iPd[0]>=0) + return(1); + else + return(0); +//DONE("modemDrvrIsPresent") +} // modemDrvrIsPresent + + + + + +// +// modemSendloop +// send any buffered data out the i/o port +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int modemSendLoop(sModemDev *mdev) +{ + int ec; + char *buf; + int bufsize; +#if DEBUG + int i; +#endif + + if(!mdev->sndn) + return 1; // nothing to send + + dprintf(DMSG_1,"modemSendLoop(): Sending %d bytes\n",mdev->sndn); + + if(mdev->sndr>=mdev->sndsize) + mdev->sndr=0; + + // if send queue has wrapped, only send up to the end of queue + // (will wrap and send rest next loop) + if (mdev->sndr + mdev->sndn >= mdev->sndsize ) + bufsize = mdev->sndsize - mdev->sndr; + else + bufsize = mdev->sndn; + + if(mdev->iPd[0]<0) + return(ERR_MODEM_PORT_NOTOPEN); + + buf=&mdev->snd[mdev->sndr]; + +#if DEBUG + // write buf + dprintf(DMSG_1,"Writing %d bytes to port 0\n",bufsize); + for(i=0;iiPd[0],buf,bufsize); + if(ec<0) + { + if(errno!=EAGAIN) // non-blocking -- still working + { + mdev->errorf|=0x40; + ec=-99; + goto BAIL; + } // non-still-working + } + else + { + // sent ec bytes + mdev->sndr+=ec; + mdev->sndn-=ec; + } + + ec=0; +BAIL: + return ec; +//DONE("modemSendloop") +} // modemSendloop + +// +// modemSend +// buffer data to send to modem +// +// in: +// *mdev = device structure +// flags = +// *buf = ptr to buffer +// bufsize = size of data in buffer +// out: +// global: +// +// GNP 16 Aug 07 +// +int modemSend(sModemDev *mdev,int flags,unsigned char *buf,int bufsize) +{ + int ec; + + if((mdev->sndn+bufsize)>mdev->sndsize) + { + ec=ERR_MODEM_SENDBUFFER_FULL; + goto BAIL; + } + for(;bufsize>0;bufsize--) + { + if(mdev->sndw>=mdev->sndsize) + mdev->sndw=0; + mdev->snd[mdev->sndw++]=*buf++; + mdev->sndn++; + } // for + + ec=0; +BAIL: + return ec; +//DONE("modemSend") +} // modemSend + +// +// modemReadLoop +// read data received from the modem +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int modemReadLoop(sModemDev *mdev) +{ + char buf[255]; + int i,len,bCR,bLF; + char c; + static int backoff = 0; + + if ( backoff > 0 ) + { + //if ( backoff % 60 == 0 ) + // dprintf(DMSG_1, "BACKING OFF (%d)\n", backoff ); + backoff--; + return(ERR_MODEM_PORT_NOTOPEN); + } + + if(mdev->iPd[0]<0) + { + //dprintf(DMSG_1, "TRYING TO OPEN MODEM PORT\n" ); + // try to open port + if ( ModemOpenPort(mdev) != TRUE ) + { + ModemClosePort(mdev); // close to be safe + backoff = 2400; // wait a good bit before trying another open + return(ERR_MODEM_PORT_NOTOPEN); + } + //dprintf(DMSG_1,"SUCCESS TRYING TO OPEN MODEM PORT\n" ); + } + + + if((len=read(mdev->iPd[0],buf,sizeof(buf))) > 0) + { + dprintf(DMSG_1,"Received %d bytes from port 0\n",len); + if(mdev->bufsize) + { + if((mdev->bufn+=len)>mdev->bufsize) + { + len=mdev->bufsize-mdev->bufn; + mdev->bufn=mdev->bufsize; + mdev->intErrorf|=M_MODEM_INTERROR_ROVERFLOW; + } + + // copy everything to the receive buffer + for(i=0;ibufw>=mdev->bufsize) + mdev->bufw=0; + c=buf[i]; +#ifdef DEBUG + if (c<0x20 && c!=0x0a && c !=0x0d) +// dprintf(DMSG_1,"(0x%02X)",c); + dprintf(DMSG_1,".",c); + else + dprintf(DMSG_1,"%c",c); +#endif //DEBUG + // every char is a pkt + mdev->buf[mdev->bufw++]=c; + } // for + + // let's look at what we just received to find: + // <0x0d><0x0a>OK + // or + // <0x0d><0x0a>ERROR + for(bCR=0,bLF=0,i=0;iavail++; + break; + } + else if(strncmp(&buf[i],"ERROR",5) == 0) + { + mdev->avail++; + break; + } + } + else if(buf[i] == 0x0d) + bCR=1; + else if (bCR && buf[i] == 0x0a) + bLF=1; + else + bCR=bLF=0; + } + } + } + else + { + // printf("ERR READING FROM MODEM, ec = %d, errno = %d\n", len, errno ); + // only valid error is EAGAIN (try again) indicating that there is nothing to be read + // any other err (even return of 0) means modem got screwy + // so close port (will try to re-open after backoff timer expires) + if ( len == 0 || errno != EAGAIN ) + { + //printf( "BAD READ, CLOSING MODEM PORT\n" ); + // ModemClosePort(mdev); + // wait a good while before trying to re-open + // found that if you tried to re-open the port too quickly + // after closing it, the open() would succeed even + // though the modem was disconnected! + backoff = 2400; + ModemClosePort(mdev); + } + } + +#ifdef DEBUG + if((mdev->iPd[1]>=0) && ((len=read(mdev->iPd[1],buf,sizeof(buf)))>0)) + { + dprintf(DMSG_1,"Received %d bytes from port 1\n",len); + // spew forth info + for(i=0;imodemType >= NUM_MODEMS) || (mdev->iComPort[0] >= NUM_MODEM_IOPORTS)) + { + dprintf(DMSG_1,"modemOpenPort(): ERROR port 0 definitions invalid\n"); + return(FALSE); + } + + portname = ioPortDevs[mdev->modemType][mdev->iComPort[0]]; + // open serial port 0 + // O_NOCTTY dont make this controlling terminal + // O_NONBLOCK dont block on reads/writes + if((mdev->iPd[0]=open(portname,O_RDWR|O_NOCTTY|O_NONBLOCK))<0) + { + dprintf(DMSG_1,"modemOpenPort(): ERROR opening port %s\n",portname); + return(FALSE); + } + + dprintf(DMSG_1,"modemOpenPort(): successfully opened port %s\n",portname); + + tcgetattr(mdev->iPd[0],&(mdev->oldtio[0])); + + fcntl(mdev->iPd[0], F_SETFL, FNDELAY); /* Configure port reading */ + + // try zero-ing? + memset(&(newtio), 0, sizeof(newtio)); // clear struct for new port settings + tcgetattr(mdev->iPd[0], &(newtio)); + + newtio.c_iflag = 0; // Raw output + newtio.c_oflag = 0; + + cfsetispeed(&(newtio), B115200); /* Set the baud rates */ + cfsetospeed(&(newtio), B115200); + + /* Enable the receiver and set local mode */ + newtio.c_cflag |= (CLOCAL | CREAD); + newtio.c_cflag &= ~PARENB; /* Mask the character size to 8 bits, no parity */ + newtio.c_cflag &= ~CSTOPB; + newtio.c_cflag &= ~CSIZE; + newtio.c_cflag |= CS8; /* Select 8 data bits */ + newtio.c_cflag &= ~CRTSCTS; /* Disable hardware flow control */ + newtio.c_cflag &= ~HUPCL; /* Disable hang-up on close (hanging up on modem ctrl ports causes hangup on ppp connection!) */ + + + /* Enable data to be processed as raw input */ + newtio.c_lflag &= ~(ICANON | ECHO | ISIG); + + /* Set the new options for the port */ + tcsetattr(mdev->iPd[0],TCSANOW,&(newtio)); + tcflush(mdev->iPd[0],TCIOFLUSH); + +#ifdef DEBUG + // port 1 is optional for debugging purposes + // it will just spew info at the console + if((mdev->flags & M_MODEM_FLAGS_DM_PRINT) + && (mdev->iComPort[1] < NUM_MODEM_IOPORTS)) + { + // open serial port 1 + portname = ioPortDevs[mdev->modemType][mdev->iComPort[1]]; + + // O_NOCTTY dont make this controlling terminal + // O_NONBLOCK dont block on reads/writes + if((mdev->iPd[1]=open(portname,O_RDWR|O_NOCTTY|O_NONBLOCK))>=0) + { + dprintf(DMSG_1,"modemOpenPort(): successfully opened port %s\n",portname); + + tcgetattr(mdev->iPd[1],&(mdev->oldtio[1])); + + + fcntl(mdev->iPd[1], F_SETFL, FNDELAY); /* Configure port reading */ + + // try zero-ing? + memset(&(newtio), 0, sizeof(newtio)); // clear struct for new port settings + tcgetattr(mdev->iPd[1], &(newtio)); + + newtio.c_iflag = 0; // Raw output + newtio.c_oflag = 0; + + cfsetispeed(&(newtio), B115200); /* Set the baud rates */ + cfsetospeed(&(newtio), B115200); + + /* Enable the receiver and set local mode */ + newtio.c_cflag |= (CLOCAL | CREAD); + newtio.c_cflag &= ~PARENB; /* Mask the character size to 8 bits, no parity */ + newtio.c_cflag &= ~CSTOPB; + newtio.c_cflag &= ~CSIZE; + newtio.c_cflag |= CS8; /* Select 8 data bits */ + newtio.c_cflag &= ~CRTSCTS; /* Disable hardware flow control */ + newtio.c_cflag &= ~HUPCL; /* Disable hang-up on close (hanging up on modem ctrl ports causes hangup on ppp connection!) */ + + /* Enable data to be processed as raw input */ + newtio.c_lflag &= ~(ICANON | ECHO | ISIG); + + /* Set the new options for the port */ + tcsetattr(mdev->iPd[1],TCSANOW,&(newtio)); + tcflush(mdev->iPd[1],TCIOFLUSH); + } + else + dprintf(DMSG_1,"modemOpenPort(): ERROR opening port %s\n",portname); + } + else + dprintf(DMSG_1,"modemOpenPort(): debug port 1 not opened\n"); +#endif //DEBUG + return TRUE; +} + +// +// ModemClosePort +// close the port previously opened +int ModemClosePort (sModemDev *mdev) +{ + // since we restore the original settings before closing the device, + // we disable HUPCL even on the 'restored' settings + // otherwise a HUP will get sent on close, causing ppp connection to reset + if (mdev->iPd[0] >= 0) + { + mdev->oldtio[0].c_cflag &= ~HUPCL; /* Disable hang-up on close (hanging up on modem ctrl ports causes hangup on ppp connection!) */ + tcsetattr(mdev->iPd[0],TCSANOW,&(mdev->oldtio[0])); + close(mdev->iPd[0]); + } + mdev->iPd[0]=-1; + + if (mdev->iPd[1] >= 0) + { + mdev->oldtio[1].c_cflag &= ~HUPCL; /* Disable hang-up on close (hanging up on modem ctrl ports causes hangup on ppp connection!) */ + tcsetattr(mdev->iPd[1],TCSANOW,&(mdev->oldtio[1])); + close(mdev->iPd[1]); + } + mdev->iPd[1]=-1; + + return(0); +} //ModemClosePort + +#if 0 +// +// modemThread +// thread to watch modem and grab data +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +void *modemThread(void *targ) +{ + int res = 0; + int err; + int bDebugDot, bIndicateError; + int errorTimer, errorFlashCount; + + sModemDev *mdev = *(sModemDev**)targ; + + mdev = modemGetDevice(); + + bDebugDot=bIndicateError=errorTimer=errorFlashCount=0; + + while(1) + { + sleep(1000); + pthread_testcancel(); + + + } //While + +//DONE("modemThread") +BAIL: + mdev->thread=(pthread_t)NULL; + return(0); +} // modemThread +#endif //0 +#endif //SYS_BB +//EOF diff --git a/libraries/pmrt/modem/modem_lin.o b/libraries/pmrt/modem/modem_lin.o new file mode 100644 index 0000000..cf52e21 Binary files /dev/null and b/libraries/pmrt/modem/modem_lin.o differ diff --git a/libraries/pmrt/modem/modem_pc.c b/libraries/pmrt/modem/modem_pc.c new file mode 100755 index 0000000..822860a --- /dev/null +++ b/libraries/pmrt/modem/modem_pc.c @@ -0,0 +1,302 @@ +// +// card_lin.c +// card reader linux low-level +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Feb 07 +// +#if SYS_PC +// include files +//#include "..\card\card.h" +//#include "..\card\cardpriv.h" +#include "modempriv.h" +#include "modem.h" + +// local definitions + +// +// DMSG_ +// debug messaging level +// +enum +{ + DMSG_OFF, + DMSG_1, + DMSG_2, + DMSG_3, + DMSG_MAX, +}; + +// global data + +// local data +static int debugMessageLevel; // current debug messaging level + +char *ioPortDevs[NUM_MODEMS][NUM_MODEM_IOPORTS]= +{ + // Sierra Aircard 875U (usb) + { + "/dev/ttyUSB0", //port 0 - Data + "/dev/ttyUSB1", //port 1 - device mgmt + "/dev/ttyUSB2", //port 2 - AT command port + }, + +}; + +// global functions + +// forward +int ModemOpenPort (sModemDev *mdev); +void *modemThread(void *targ); +int ModemClosePort (sModemDev *mdev); + +// +// dprintf +// debug printf to console +// +static void dprintf(int msgLevel, char *fmt,...) +{ +#ifdef DEBUG + va_list args; + if (msgLevel <= debugMessageLevel) + { + va_start(args,fmt); + vprintf(fmt,args); + va_end(args); + } +#endif //DEBUG +} // dmsg() + +// +// modemDrvrInit +// called once by ModemInit() at system startup +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int modemDrvrInit(sModemDev *mdev) +{ + return 0; +} // modemDrvrInit + +// +// modemDrvrFinal +// called once by ModemFinal() at system shutdown +// +// in: +// out: +// global: +// +// GNP 14 Aug 07 +// +void modemDrvrFinal(sModemDev *mdev) +{ +} // modemDrvrFinal + +// +// modemDrvrOpen +// called to open port connected to modem +// +// in: +// out: +// global: +// +// GNP 14 Feb 07 +// +int modemDrvrOpen(sModemDev *mdev) +{ + return 0; +} // modemDrvrOpen + +// +// modemDrvrClose +// close port connected to modem +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void modemDrvrClose(sModemDev *mdev) +{ + return; +} // modemDrvrClose + +// +// modemDrvrIsPresent +// returns TRUE if the modem is present +// +// in: +// out: +// global: +// +// GNP 23 Aug 07 +// +int modemDrvrIsPresent(sModemDev *mdev) +{ + return 0; +} // modemDrvrIsPresent + + + +// +// modemSendloop +// send any buffered data out the i/o port +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int modemSendLoop(sModemDev *mdev) +{ + return 0; +//DONE("modemSendloop") +} // modemSendloop + +// +// modemSend +// buffer data to send to modem +// +// in: +// *mdev = device structure +// flags = +// *buf = ptr to buffer +// bufsize = size of data in buffer +// out: +// global: +// +// GNP 16 Aug 07 +// +int modemSend(sModemDev *mdev,int flags,unsigned char *buf,int bufsize) +{ + return 0; +} // modemSend + +// +// modemReadLoop +// read data received from the modem +// +// in: +// out: +// global: +// +// GNP 16 Aug 07 +// +int modemReadLoop(sModemDev *mdev) +{ + return 0; +} // modemReadLoop + + +// Open and initiate the com port +int ModemOpenPort (sModemDev *mdev) +{ + return TRUE; +} + +// +// ModemClosePort +// close the port previously opened +int ModemClosePort (sModemDev *mdev) +{ + return(0); +} + +#endif //SYS_PC + + +/* +// +// cardDrvrInit +// called once by CardInit() at system startup +// +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +#ifndef CARD_H +int cardDrvrInit(sCardDev *cdev) +{ + int ec=0; +//DONE("cardDrvrInit") + return(ec); +} // cardDrvrInit + +// +// cardDrvrFinal +// called once by CardFinal() at system shutdown +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void cardDrvrFinal(sCardDev *cdev) +{ +//DONE("cardDrvrFinal") +} // cardDrvrFinal + +// +// cardDrvrOpen +// called to open port connected to card reader +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +int cardDrvrOpen(sCardDev *cdev) +{ + int ec=0; +//DONE("cardDrvrOpen") + return(ec); +} // cardDrvrOpen + +// +// cardDrvrClose +// close port connected to card reader +// +// in: +// out: +// global: +// +// GNP 16 Feb 07 +// +void cardDrvrClose(sCardDev *cdev) +{ +//DONE("cardDrvrClose") +} // cardDrvrClose + +// +// cardDrvrIsRunning +// returns TRUE if the card driver is currently running (open) +// +// in: +// out: +// global: +// +// GNP 19 Feb 07 +// +int cardDrvrIsRunning(sCardDev *cdev) +{ + return(0); +} // cardDrvrIsRunning +#endif //CARD_H + +*/ + +//EOF diff --git a/libraries/pmrt/modem/modempriv.h b/libraries/pmrt/modem/modempriv.h new file mode 100755 index 0000000..34a5a88 --- /dev/null +++ b/libraries/pmrt/modem/modempriv.h @@ -0,0 +1,143 @@ +// +// modempriv.h +// modem header, internal +// +// Play Mechanix - Video Game System +// +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 14 Aug 07 +// +#ifndef MODEMPRIV_H +#define MODEMPRIV_H + +#define MODEMPRIV_VER_STRING "a" + +#define MODEM_AT_IOPORT_DEFAULT 2 +#define MODEM_DM_IOPORT_DEFAULT 1 +#define MODEM_BAUD_DEFAULT 115200 + +#define NUM_MODEM_IOPORTS 3 + +#define SEND_BUFFER_SIZE 256 +#define RECEIVE_BUFFER_SIZE 4096 + +// +// M_MODEM_FLAGS_ +// flags set/cleared by modem mid-level routines +// +#define M_MODEM_FLAGS_FLUSHIO 0x00000001 +#define M_MODEM_FLAGS_NODATA_PROCESSED 0x01000000 +#define M_MODEM_FLAGS_DATA_EXPECTED 0x02000000 +#define M_MODEM_FLAGS_DM_PRINT 0x04000000 + +// +// M_MODEM_INTFLAGS_ +// flags set/cleared only by modem reader thread +// +#define M_MODEM_INTFLAGS_FLUSHIO_ACK 0x00000001 +#define M_MODEM_INTFLAGS_RESET 0x00000004 +#define M_MODEM_INTFLAGS_ACK 0x00000008 +#define M_MODEM_INTFLAGS_NODATA 0x00100000 + +// +// M_MODEM_INTERROR_ +// error flags set only by modem reader thread +// +#define M_MODEM_INTERROR_ROVERFLOW 0x00000001 + +#if SYS_PC +#include +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + int avail; // packets available + int (*callback)(int op,...); + unsigned int iComPort[2]; // Open Com Port number + unsigned long iBaudRate; + unsigned int modemType; + + // intFlags, intErrorf and card track data (only written by xxxcardThread, read all you want) + unsigned intFlags; + unsigned intErrorf; // error flags + + char transferBuf[RECEIVE_BUFFER_SIZE+1]; + + // implementation specific + HANDLE thread; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + + char *snd; + unsigned sndsize; + unsigned sndn; // bytes in buf + unsigned sndw; // write index + unsigned sndr; // read index + + int iPd[2]; // port file descriptor + +} sModemDev; +#elif SYS_BB +#include +#define _POSIX_SOURCE 1 // POSIX compliant source +#define FALSE 0 +#define TRUE 1 +#define _XOPEN_SOURCE 500 // makes usleep() get defined properly? +#include +#include +#include +#include //posix threads +typedef struct { + // common + unsigned flags; + unsigned errorf; // error flags + int avail; // packets available + int (*callback)(int op,...); + unsigned int iComPort[2]; // Open Com Port number + unsigned long iBaudRate; + unsigned int modemType; + + // intFlags, intErrorf and card track data (only written by xxxcardThread, read all you want) + unsigned intFlags; + unsigned intErrorf; // error flags + + char transferBuf[RECEIVE_BUFFER_SIZE+1]; + + // implementation specific + pthread_t thread; + char *buf; + unsigned bufsize; + unsigned bufn; // bytes in buf + unsigned bufw; // write index + unsigned bufr; // read index + + char *snd; + unsigned sndsize; + unsigned sndn; // bytes in buf + unsigned sndw; // write index + unsigned sndr; // read index + + int iPd[2]; // port file descriptor + struct termios oldtio[2]; + +} sModemDev; +#else +#error Must define SYS_ in pre-processor +#endif + +extern int modemDrvrInit(sModemDev *mdev); +extern void modemDrvrFinal(sModemDev *mdev); +extern int modemDrvrOpen(sModemDev *mdev); +extern void modemDrvrClose(sModemDev *mdev); +extern int modemDrvrIsPresent(sModemDev *mdev); +extern sModemDev *modemGetDevice(void); +int modemSendLoop(sModemDev *mdev); +int modemSend(sModemDev *mdev,int flags,unsigned char *buf,int bufsize); +int modemReadLoop(sModemDev *mdev); + +#endif // ndef MODEMPRIV_H +// EOF diff --git a/libraries/pmrt/modem/modemtest.c b/libraries/pmrt/modem/modemtest.c new file mode 100755 index 0000000..d9ea095 --- /dev/null +++ b/libraries/pmrt/modem/modemtest.c @@ -0,0 +1,248 @@ +// modemtest.c +// GNP 16 Aug 07 + +#define MODEMTEST_VERS "A" + +#include +#include +#include +#include "modem.h" + +int modem_callback(int op,...); + +#if SYS_PC +#include +int ConKeyRead(char *buf,int bufsize) +{ + HANDLE h=INVALID_HANDLE_VALUE; + DWORD dw,save=-1,i; + INPUT_RECORD ir[256]; + int len=0; + + // Get the standard input handle. + h=GetStdHandle(STD_INPUT_HANDLE); + if(h == INVALID_HANDLE_VALUE) + goto BAIL; + + // save + if (!GetConsoleMode(h, &save) ) + goto BAIL; + + // enable + dw=ENABLE_WINDOW_INPUT; + if(!SetConsoleMode(h, dw) ) + goto BAIL; + + // check for input -- don't block if there is none ready + if(!GetNumberOfConsoleInputEvents(h,&dw)) + goto BAIL; + if(!dw) + goto BAIL; + + if(!ReadConsoleInput(h,ir,sizeof(ir)/sizeof(ir[0]),&dw)) + goto BAIL; + + for(i=0;i +#include +#include +#include +#include +#include +struct termios rawtio; +struct termios savetio; +int conInit(void) +{ + tcgetattr(STDIN_FILENO,&savetio); + rawtio=savetio; + rawtio.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + rawtio.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + rawtio.c_cflag &= ~(CSIZE | PARENB); + rawtio.c_cflag |= CS8; + rawtio.c_oflag &= ~(OPOST); + rawtio.c_cc[VMIN]=0; + rawtio.c_cc[VTIME]=0; + return 0; +} +void conFinal(void) +{ + // tcsetattr(STDIN_FILENO,TCSANOW,&savetio); +} +int ConKeyRead(char *buf,int bufsize) +{ + int i; + tcsetattr(STDIN_FILENO,TCSANOW,&rawtio); + usleep(100); + i=read(STDIN_FILENO,buf,bufsize); + tcsetattr(STDIN_FILENO,TCSANOW,&savetio); + return i; +} // ConKeyRead() +#endif // SYS_BB + +char asciibuf[128]; + +void modemtesthelp(void) +{ + char buf[64]; + + ModemOp(MODEMOP_GETVERSTRING,buf,sizeof(buf)); + + printf("Play Mechanix, Inc. - Modem Test (vers %s%s)\n",MODEMTEST_VERS,buf); + printf("Copyright(c)2007, All Rights Resvd.\n"); + printf("-------------------------------------\n"); + printf(" =exit, type string to send to modem followed by \n"); +} // modemtesthelp() + +// JFL 05 May 05 +int main(int argc,char *argv[]) +{ + int ec,i,ii,si; + char buf[256]; + char sendbuf[1024]; + char c; + + conInit(); + modemtesthelp(); + + if((ec=ModemInit())<0) + { + printf("ModemInit failed\n"); + goto BAIL; + } + + if((ec=ModemOp(MODEMOP_SETCALLBACK,modem_callback))<0) + { + printf("ModemSetCallback failed\n"); + goto BAIL; + } + + if((ec=ModemBegin())<0) + { + printf("ModemBegin failed\n"); + goto BAIL; + } + printf("modem opened successfully\n"); + si=0; + + for(;;) + { + if((ii=ConKeyRead(buf,sizeof(buf)))>0) + { + for(i=0;i= 0x20) + { + if (si >= sizeof(sendbuf)) + { + printf("Sending partial string: %s\n",sendbuf); + if((ec=ModemOp(MODEMOP_SENDBUF,sendbuf,sizeof(sendbuf)))<0) + printf("Send failed %d\n",ec); + si=0; + sendbuf[0]=0; + } + + sendbuf[si++]=c; + } + } // switch all modes + } // for + } // keys avail + + ModemLoop(); + } // for + + ec=0; +BAIL: + conFinal(); + ModemFinal(); + return ec; +} // main() + + +// GNP 20 Feb 07 +int modem_callback(int op,...) + +{ + va_list args; + char *buf; + int size; + + va_start(args,op); + buf=va_arg(args,char *); + size=va_arg(args, int); + + switch(op) + { + case MODEMCALLBACK_ERROR: + printf("Received ERROR from modem\n"); + printf("%s\n",buf); + break; + case MODEMCALLBACK_OK: + printf("Received OK from modem\n"); + printf("%s\n",buf); + break; + case MODEMCALLBACK_UNKNOWN: + printf("Received unknown string from modem\n"); + printf("%s\n",buf); + break; + } + + va_end(args); + return 0; +} // modem_callback() + + + +// EOF diff --git a/libraries/pmrt/modem/mssccprj.scc b/libraries/pmrt/modem/mssccprj.scc new file mode 100755 index 0000000..020f786 --- /dev/null +++ b/libraries/pmrt/modem/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[Modem.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/modem", DTQAAAAA diff --git a/libraries/pmrt/modem/vssver.scc b/libraries/pmrt/modem/vssver.scc new file mode 100755 index 0000000..18f4f40 Binary files /dev/null and b/libraries/pmrt/modem/vssver.scc differ diff --git a/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.lib b/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.lib new file mode 100755 index 0000000..528eeb5 Binary files /dev/null and b/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.lib differ diff --git a/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.obj b/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.obj new file mode 100755 index 0000000..5b0e0c3 Binary files /dev/null and b/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.obj differ diff --git a/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.pch b/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.pch new file mode 100755 index 0000000..04a8d27 Binary files /dev/null and b/libraries/pmrt/pmrt_compression/Debug/pmrt_compression.pch differ diff --git a/libraries/pmrt/pmrt_compression/Debug/vc60.idb b/libraries/pmrt/pmrt_compression/Debug/vc60.idb new file mode 100755 index 0000000..2514b84 Binary files /dev/null and b/libraries/pmrt/pmrt_compression/Debug/vc60.idb differ diff --git a/libraries/pmrt/pmrt_compression/Debug/vc60.pdb b/libraries/pmrt/pmrt_compression/Debug/vc60.pdb new file mode 100755 index 0000000..4558be1 Binary files /dev/null and b/libraries/pmrt/pmrt_compression/Debug/vc60.pdb differ diff --git a/libraries/pmrt/pmrt_compression/Release/vc60.idb b/libraries/pmrt/pmrt_compression/Release/vc60.idb new file mode 100755 index 0000000..8b7ef6c Binary files /dev/null and b/libraries/pmrt/pmrt_compression/Release/vc60.idb differ diff --git a/libraries/pmrt/pmrt_compression/compress_test.c b/libraries/pmrt/pmrt_compression/compress_test.c new file mode 100755 index 0000000..8a32030 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/compress_test.c @@ -0,0 +1,23 @@ +// compress_test.cpp : Defines the entry point for the console application. +// + +#include +#include + +int main(int argc, char* argv[]) +{ + int ec; + if ( argc > 1 ) + { + printf("gunzipping %s to %s\n", argv[1], argv[2] ); + ec = gunzipfile( argv[1], argv[2] ); + printf( "got back ec = %d\n" ); + + printf("zipping %s to out.gz\n", argv[2] ); + ec = gzipfile( argv[2], "out.pdf.gz" ); + printf( "got back ec = %d\n" ); + + } + return 0; +} + diff --git a/libraries/pmrt/pmrt_compression/compression_test.dsp b/libraries/pmrt/pmrt_compression/compression_test.dsp new file mode 100755 index 0000000..a987aba --- /dev/null +++ b/libraries/pmrt/pmrt_compression/compression_test.dsp @@ -0,0 +1,101 @@ +# Microsoft Developer Studio Project File - Name="compression_test" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=compression_test - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "compression_test.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "compression_test.mak" CFG="compression_test - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "compression_test - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "compression_test - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "compression_test - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "compression_test - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "compression_test___Win32_Debug" +# PROP BASE Intermediate_Dir "compression_test___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "compression_test___Win32_Debug" +# PROP Intermediate_Dir "compression_test___Win32_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pmrt_compression.lib zdll.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"c:\g3\lib" + +!ENDIF + +# Begin Target + +# Name "compression_test - Win32 Release" +# Name "compression_test - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\compress_test.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/pmrt_compression/libpmrt_compression.a b/libraries/pmrt/pmrt_compression/libpmrt_compression.a new file mode 100644 index 0000000..5329bae Binary files /dev/null and b/libraries/pmrt/pmrt_compression/libpmrt_compression.a differ diff --git a/libraries/pmrt/pmrt_compression/makedeplib b/libraries/pmrt/pmrt_compression/makedeplib new file mode 100644 index 0000000..16fe018 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/makedeplib @@ -0,0 +1,55 @@ +pmrt_compression.o: pmrt_compression.c pmrt_compression.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/zlib.h \ + /g3/include/zconf.h diff --git a/libraries/pmrt/pmrt_compression/makefile b/libraries/pmrt/pmrt_compression/makefile new file mode 100755 index 0000000..81d501c --- /dev/null +++ b/libraries/pmrt/pmrt_compression/makefile @@ -0,0 +1,39 @@ +# make driver +# make install (as root) +# +# +.CLIBFILES = pmrt_compression.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libpmrt_compression.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /g3/lib/libpmrt_utils.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/pmrt_compression + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/pmrt_compression + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/pmrt_compression/mssccprj.scc b/libraries/pmrt/pmrt_compression/mssccprj.scc new file mode 100755 index 0000000..1659a16 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/mssccprj.scc @@ -0,0 +1,9 @@ +SCC = This is a Source Code Control file + +[compression_test.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/pmrt_compression", ROQAAAAA + +[pmrt_compression.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/pmrt_compression", ROQAAAAA diff --git a/libraries/pmrt/pmrt_compression/pmrt_compression.c b/libraries/pmrt/pmrt_compression/pmrt_compression.c new file mode 100755 index 0000000..b2bcd6c --- /dev/null +++ b/libraries/pmrt/pmrt_compression/pmrt_compression.c @@ -0,0 +1,256 @@ +// pmrt_compression.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "pmrt_compression.h" + +#include +#include +#include + +int gunzipfile( char *srcfile, char *destfile ) +{ + gzFile *src; + FILE *dest; + char buf[4096]; + int read,wrote; + + src = gzopen( srcfile, "rb" ); + if ( src == NULL ) + return GZ_FAILED_TO_OPEN_SRCFILE; + + dest = fopen( destfile, "wb" ); + if ( dest == NULL ) + return GZ_FAILED_TO_OPEN_DESTFILE; + + while(!gzeof(src)) + { + read = gzread(src,buf,sizeof(buf)); + if ( read < 0 ) + { + fclose(dest); + gzclose(src); + return GZ_READ_FAILED; + } + else if ( read > 0 ) + { + wrote = fwrite(buf,1,read,dest); + if ( wrote != read ) + { + fclose(dest); + gzclose(src); + return GZ_WRITE_FAILED; + } + } + } + + fclose(dest); + gzclose(src); + + return GZ_SUCCESS; +} + +int gzipfile( char *srcfile, char *destfile ) +{ + gzFile *dest; + FILE *src; + char buf[4096]; + int read,wrote; + + src = fopen( srcfile, "rb" ); + if ( src == NULL ) + return GZ_FAILED_TO_OPEN_SRCFILE; + + dest = gzopen( destfile, "wb" ); + if ( dest == NULL ) + return GZ_FAILED_TO_OPEN_DESTFILE; + + while(!feof(src)) + { + read = fread( buf, 1, sizeof(buf), src ); + if ( read < 0 ) + { + fclose(src); + gzclose(dest); + return GZ_READ_FAILED; + } + else if ( read > 0 ) + { + wrote = gzwrite( dest, buf, read ); + if ( wrote != read ) + { + fclose(src); + gzclose(dest); + return GZ_WRITE_FAILED; + } + } + } + + fclose(src); + gzclose(dest); + + return GZ_SUCCESS; + + return 0; +} + +/*! + \brief will uncompress a file that was compressed using the compress function in zlib + outBuffer will be filled in. Buffer size will be filled in with the size of the buffer + //NOTE: User is expected to free the buffer after use! + + \param fileName name of input file + \param outBuffer will have uncompressed data if the function succeeds + \param bufferSize will contain size of buffer if the function succeeds + \return int -1 for fail, 0 for success +*/ +int UncompressFile(const char *fileName, char *outBuffer, unsigned int *bufferSize) +{ + FILE *inFile = NULL; + unsigned int fileSize = 0; + char *buffer = NULL; + + if(!outBuffer || !bufferSize) + return -1; + + *bufferSize = 0; + + //***read in data from file*** + inFile = fopen(fileName, "rb"); + if(!inFile) + return -1; + + fileSize = UtilGetFileSize(inFile); + if(!fileSize) + goto fail; + + buffer = (char*)CustomMalloc( sizeof(char)*fileSize) ; + if(fread(outBuffer, 1, fileSize, inFile) != fileSize) + goto fail; + + fclose(inFile); + //***done reading from file*** + + if(uncompress(outBuffer, bufferSize, buffer, fileSize) != Z_OK) + goto fail; + + if(inFile) + fclose(inFile); + + if(buffer) + free(buffer); + + return 0; + +fail: + if(inFile) + fclose(inFile); + + if(outBuffer) + free(outBuffer); + + if(buffer) + free(buffer); + + return -1; +} + + +/* these funcs moved to pmrt_ssl lib, consider implementing sans crypto here +int ZStreamCryptoInit(ZStreamHandle *handle, ZEnum type, const char *fileName, const char *fileKey, + int keySize, const char *iv, int ivSize, char *inBuffer, int inSize) +{ + memset(handle, 0, sizeof(ZStreamHandle)); + handle->stream.zalloc = Z_NULL; + handle->stream.zfree = Z_NULL; + handle->stream.opaque = Z_NULL; + + if(type == ZENUM_READ) + { + if(OpenCryptoFile(&handle->crypFile, fileName, "rb", CRYPTO_DECRYPT, CRYPTO_AES256_OFB, fileKey, + keySize, iv, ivSize) + != CRYPTOFILE_RESULT_SUCCESS) + return -1; + + if(inflateInit(&handle->stream) != Z_OK) + return -1; + } + + handle->inBuffer = inBuffer; + handle->stream.next_in = inBuffer; + handle->origBuffer = inBuffer; + handle->inBufSize = inSize; + + return 0; +} + +int ZStreamRead(ZStreamHandle *zhandle, void *outData, unsigned int outSize) +{ + int ret = 0; + + zhandle->stream.avail_out = outSize; + zhandle->stream.next_out = outData; + + do + { + //if there are bytes available in the stream, then leave them alone. Otherwise we need moar bytes + int len = (zhandle->stream.avail_in == 0) ? zhandle->inBufSize - zhandle->stream.total_out : zhandle->stream.avail_in; + + //if we don't have any available bytes left, read in more + if(!zhandle->stream.avail_in) + { + //reset the length and buffer pointer to original values + len = zhandle->inBufSize; + zhandle->inBuffer = zhandle->origBuffer; + + //decrypt + ret = ReadFromCryptoFile(&zhandle->crypFile, zhandle->inBuffer, &len); + + zhandle->stream.total_out = 0; + + if(ret != CRYPTOFILE_RESULT_SUCCESS) + return -1; + } + + zhandle->stream.avail_in = len; + + zhandle->stream.next_in = zhandle->inBuffer; + + //decompress + ret = inflate(&zhandle->stream, Z_NO_FLUSH); + if(ret == Z_STREAM_ERROR) // state not clobbered + return ret; + + switch (ret) + { + case Z_NEED_DICT: + ret = Z_DATA_ERROR; // and fall through + + case Z_DATA_ERROR: + case Z_MEM_ERROR: + { + (void)inflateEnd(&zhandle->stream); + return ret; + } + } + + } while(zhandle->stream.avail_out > 0); + + //save the position the stream is at + zhandle->inBuffer = zhandle->stream.next_in; + + return 0; +} + +void ZStreamClose(ZStreamHandle *zhandle) +{ + CloseCryptoFile(&zhandle->crypFile); + + inflateEnd(&zhandle->stream); +} + +*/ + +//EOF + diff --git a/libraries/pmrt/pmrt_compression/pmrt_compression.dsp b/libraries/pmrt/pmrt_compression/pmrt_compression.dsp new file mode 100755 index 0000000..7444c86 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/pmrt_compression.dsp @@ -0,0 +1,104 @@ +# Microsoft Developer Studio Project File - Name="pmrt_compression" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pmrt_compression - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pmrt_compression.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pmrt_compression.mak" CFG="pmrt_compression - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pmrt_compression - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pmrt_compression - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries/pmrt/pmrt_compression", ROQAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pmrt_compression - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "pmrt_compression - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\pmrt_compression copy Debug\pmrt_compression.lib c:\g3\lib copy *.h c:\g3\include\pmrt_compression +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pmrt_compression - Win32 Release" +# Name "pmrt_compression - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pmrt_compression.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pmrt_compression.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/pmrt_compression/pmrt_compression.dsw b/libraries/pmrt/pmrt_compression/pmrt_compression.dsw new file mode 100755 index 0000000..eb993c7 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/pmrt_compression.dsw @@ -0,0 +1,52 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "compression_test"=.\compression_test.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pmrt_compression + End Project Dependency +}}} + +############################################################################### + +Project: "pmrt_compression"=.\pmrt_compression.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/pmrt_compression", ROQAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/pmrt_compression", ROQAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/pmrt_compression/pmrt_compression.h b/libraries/pmrt/pmrt_compression/pmrt_compression.h new file mode 100755 index 0000000..ea54446 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/pmrt_compression.h @@ -0,0 +1,59 @@ +// pmrt_compression.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_COMPRESSION_H +#define PMRT_COMPRESSION_H + +#include + +#include + +enum GZERRS +{ + GZ_FAILED_TO_OPEN_SRCFILE = -99, + GZ_FAILED_TO_OPEN_DESTFILE, + GZ_WRITE_FAILED, + GZ_READ_FAILED, + + GZ_SUCCESS = 0, +}; + + + + +int gunzipfile( char *srcfile, char *destfile ); +int gzipfile( char *srcfile, char *destfile ); + +//will uncompress a file that was compressed using the compress function in zlib +//outBuffer will be filled in. Buffer size will be filled in with the size of the buffer +//NOTE: User is expected to free the buffer after use! +int UncompressFile(const char *fileName, char *outBuffer, unsigned int *bufferSize); + + +/* these funcs moved to pmrt_ssl lib, consider implementing sans crypto here +typedef enum _ZEnum +{ + ZENUM_READ, ZENUM_UNKNOWN +}ZEnum; + +typedef struct _ZStreamHandle +{ + z_stream stream; + CryptoFileHandle crypFile; + char *inBuffer; + char *origBuffer; + int inBufSize; +}ZStreamHandle; + + +int ZStreamCryptoInit(ZStreamHandle *handle, ZEnum type, const char *fileName, const char *fileKey, + int keySize, const char *iv, int ivSize, char *inBuffer, int inSize); +int ZStreamRead(ZStreamHandle *zhandle, void *outData, unsigned int outSize); +void ZStreamClose(ZStreamHandle *zhandle); + +*/ + +#endif +//EOF + diff --git a/libraries/pmrt/pmrt_compression/pmrt_compression.o b/libraries/pmrt/pmrt_compression/pmrt_compression.o new file mode 100644 index 0000000..44df271 Binary files /dev/null and b/libraries/pmrt/pmrt_compression/pmrt_compression.o differ diff --git a/libraries/pmrt/pmrt_compression/pmrt_compression.plg b/libraries/pmrt/pmrt_compression/pmrt_compression.plg new file mode 100755 index 0000000..fac5691 --- /dev/null +++ b/libraries/pmrt/pmrt_compression/pmrt_compression.plg @@ -0,0 +1,39 @@ + + +
+

Build Log

+

+--------------------Configuration: pmrt_compression - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F6.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/pmrt_compression.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_compression\pmrt_compression.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F6.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\pmrt_compression.lib" .\Debug\pmrt_compression.obj " +

Output Window

+Compiling... +pmrt_compression.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F7.bat" with contents +[ +@echo off +mkdir c:\g3\include\pmrt_compression +copy Debug\pmrt_compression.lib c:\g3\lib +copy *.h c:\g3\include\pmrt_compression +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F7.bat" + + 1 file(s) copied. +pmrt_compression.h + 1 file(s) copied. + + + +

Results

+pmrt_compression.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/pmrt_compression/test.pdf.gz b/libraries/pmrt/pmrt_compression/test.pdf.gz new file mode 100755 index 0000000..68b8dbc Binary files /dev/null and b/libraries/pmrt/pmrt_compression/test.pdf.gz differ diff --git a/libraries/pmrt/pmrt_compression/vssver.scc b/libraries/pmrt/pmrt_compression/vssver.scc new file mode 100755 index 0000000..af8ed8c Binary files /dev/null and b/libraries/pmrt/pmrt_compression/vssver.scc differ diff --git a/libraries/pmrt/pmrt_llm/Debug/pmrt_llm.lib b/libraries/pmrt/pmrt_llm/Debug/pmrt_llm.lib new file mode 100755 index 0000000..a609a52 Binary files /dev/null and b/libraries/pmrt/pmrt_llm/Debug/pmrt_llm.lib differ diff --git a/libraries/pmrt/pmrt_llm/Debug/pmrt_llm.obj b/libraries/pmrt/pmrt_llm/Debug/pmrt_llm.obj new file mode 100755 index 0000000..35571df Binary files /dev/null and b/libraries/pmrt/pmrt_llm/Debug/pmrt_llm.obj differ diff --git a/libraries/pmrt/pmrt_llm/Debug/vc60.idb b/libraries/pmrt/pmrt_llm/Debug/vc60.idb new file mode 100755 index 0000000..ddaad85 Binary files /dev/null and b/libraries/pmrt/pmrt_llm/Debug/vc60.idb differ diff --git a/libraries/pmrt/pmrt_llm/Debug/vc60.pdb b/libraries/pmrt/pmrt_llm/Debug/vc60.pdb new file mode 100755 index 0000000..1bff9d6 Binary files /dev/null and b/libraries/pmrt/pmrt_llm/Debug/vc60.pdb differ diff --git a/libraries/pmrt/pmrt_llm/makefile b/libraries/pmrt/pmrt_llm/makefile new file mode 100755 index 0000000..94ad608 --- /dev/null +++ b/libraries/pmrt/pmrt_llm/makefile @@ -0,0 +1,39 @@ +# make driver +# make install (as root) +# +.CLIBFILES = pmrt_llm.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libpmrt_llm.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -Wno-implicit -O0 -g -DSYS_BB -DPRODUCTION -I/g3/include +# use this next line if building on Fedora Linux +#CFLAGS += -DUSE_INTERNAL_RDTSC -DUSE_FEDORA + +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) + -mkdir /g3/include/pmrt_llm + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/pmrt_llm + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/pmrt_llm/mssccprj.scc b/libraries/pmrt/pmrt_llm/mssccprj.scc new file mode 100755 index 0000000..f06d28f --- /dev/null +++ b/libraries/pmrt/pmrt_llm/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[pmrt_llm.dsp] +SCC_Aux_Path = "\\vss-nas-1\PM_Utilities\" +SCC_Project_Name = "$/libraries/pmrt/pmrt_llm", MXCAAAAA diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.c b/libraries/pmrt/pmrt_llm/pmrt_llm.c new file mode 100755 index 0000000..404382b --- /dev/null +++ b/libraries/pmrt/pmrt_llm/pmrt_llm.c @@ -0,0 +1,169 @@ + +#include "pmrt_llm.h" + + +void (*gUnknownMsgCallback)(LLM_Msg *msg); + +void (*gMsgCallbacks[LLM_MSG_TYPES])(LLM_Msg *msg); + +uns32 gLocalID; + +int gRecvPort; +int gSendPort; + +NetSockHandle gRecvNSH; +NetSockHandle gSendNSH; + +void DfltUnkownMsgCallback(LLM_Msg *msg) +{ + return; +} + +int LLM_Init(int SendPort, int RecvPort ) +{ + int ec; + memset(&gMsgCallbacks,0,sizeof(gMsgCallbacks)); + gUnknownMsgCallback = DfltUnkownMsgCallback; + gLocalID = 0; + memset(&gRecvNSH,0,sizeof(gRecvNSH)); + memset(&gSendNSH,0,sizeof(gSendNSH)); + + gSendPort = SendPort; + gRecvPort = RecvPort; + + ec = NetSockOpenUDPSocket( &gRecvNSH, NULL, gRecvPort ); + if ( ec != NETSOCK_RESULT_SUCCESS ) + { + return -1; + } + ec = NetSockSetBroadcast(&gRecvNSH,1); + if ( ec != NETSOCK_RESULT_SUCCESS ) + { + return -2; + } + + ec = NetSockOpenUDPSocket( &gSendNSH, NULL, 0 ); + if ( ec != NETSOCK_RESULT_SUCCESS ) + { + return -3; + } + ec = NetSockSetBroadcast(&gSendNSH,1); + if ( ec != NETSOCK_RESULT_SUCCESS ) + { + return -4; + } + + return 0; +} + +int LLM_DeInit() +{ + NetSockCloseConnection(&gRecvNSH); + NetSockCloseConnection(&gSendNSH); + + return 0; +} + + +int LLM_SetLocalID(uns32 id) +{ + gLocalID = id; + return 0; +} + +int LLM_SetMsgTypeCallback(int type, void (*callback)(LLM_Msg *msg) ) +{ + if ( type == LLM_MSG_TYPE_UNKNOWN ) + { + gUnknownMsgCallback = callback; + return 0; + } + + if ( type < 0 || type >= LLM_MSG_TYPES ) + { + return -1; + } + + gMsgCallbacks[type]=callback; + return 0; +} + +int LLM_SendMsg( int type, uns32 dest_id, void *data, int size ) +{ + int ec; + char buf[LLM_MAX_MSG_SIZE]; + int len; + LLM_Msg *msg; + + memset(buf,0,sizeof(buf)); + + if( sizeof(LLM_Msg) + size > LLM_MAX_MSG_SIZE ) + return -1; // message too long + + msg = (LLM_Msg*)buf; + + msg->type = type; + msg->src_id = gLocalID; + msg->dest_id = dest_id; + msg->size = size; + msg->data = NULL; + + if ( size > 0 ) + memcpy( &buf[sizeof(LLM_Msg)],data,size); + + len = sizeof(LLM_Msg) + size; + + ec = NetSockSendOutUDPSocket( &gSendNSH, msg, &len, NULL, gSendPort ); + if ( ec == NETSOCK_RESULT_SUCCESS ) + return 1; // message sent, enjoy! + + if ( ec == NETSOCK_RESULT_SOCKET_NOT_READY ) + return 0; // message not sent, try again + + + return -1; // message not sent, do not try again (some other error) + +} + + + +int LLM_RecvMsg() +{ + int ec; + char buf[LLM_MAX_MSG_SIZE]; + int size; + char remote_ip[64]; + int remote_port; + LLM_Msg *msg; + + memset(buf,0,sizeof(buf)); + + size = sizeof(buf); + + ec = NetSockRecvFromUDPSocket( &gRecvNSH, buf, &size, remote_ip, &remote_port ); + if ( ec == NETSOCK_RESULT_SOCKET_NOT_READY ) + { + return 0; + } + if ( ec != NETSOCK_RESULT_SUCCESS ) + { + return -1; + } + + msg = (LLM_Msg*)buf; + msg->data = NULL; + if (msg->size>0) + { + // data is always located just after the header + msg->data = &buf[sizeof(LLM_Msg)]; + } + + if ( msg->type < 0 || msg->type >= LLM_MSG_TYPES || gMsgCallbacks[msg->type]==NULL ) + gUnknownMsgCallback(msg); + else + gMsgCallbacks[msg->type](msg); + + + return 1; +} + diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.dsp b/libraries/pmrt/pmrt_llm/pmrt_llm.dsp new file mode 100755 index 0000000..a2236e4 --- /dev/null +++ b/libraries/pmrt/pmrt_llm/pmrt_llm.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="pmrt_llm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pmrt_llm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pmrt_llm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pmrt_llm.mak" CFG="pmrt_llm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pmrt_llm - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pmrt_llm - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries", SLBAAAAA" +# PROP Scc_LocalPath "..\.." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pmrt_llm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "pmrt_llm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir \g3\include\pmrt_llm copy Debug\pmrt_llm.lib \g3\lib copy *.h \g3\include\pmrt_llm +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pmrt_llm - Win32 Release" +# Name "pmrt_llm - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pmrt_llm.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pmrt_llm.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.dsw b/libraries/pmrt/pmrt_llm/pmrt_llm.dsw new file mode 100755 index 0000000..f707ba2 --- /dev/null +++ b/libraries/pmrt/pmrt_llm/pmrt_llm.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "pmrt_llm"=.\pmrt_llm.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.h b/libraries/pmrt/pmrt_llm/pmrt_llm.h new file mode 100755 index 0000000..4244440 --- /dev/null +++ b/libraries/pmrt/pmrt_llm/pmrt_llm.h @@ -0,0 +1,38 @@ +#ifndef PMRTLLM_H +#define PMRTLLM_H + +#include + +#define LLM_MAX_MSG_SIZE 1400 // set below 1500 to prevent packet fragmentation + +enum +{ + LLM_MSG_TYPE_UNKNOWN = -1, + LLM_MSG_TYPES=128, // max +}; + +typedef struct +{ + int type; + uns32 src_id; + uns32 dest_id; + int size; + void *data; +} LLM_Msg; + + +int LLM_Init(int SendPort, int RecvPort ); +int LLM_DeInit(); + + +int LLM_SetLocalID(uns32 id); + +int LLM_SetMsgTypeCallback(int type, void (*callback)(LLM_Msg *msg) ); + +int LLM_SendMsg( int type, uns32 dest_id, void *data, int size ); +int LLM_RecvMsg(); // will pull first message off udp buffer if buffer not empty + + + +#endif + diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.ncb b/libraries/pmrt/pmrt_llm/pmrt_llm.ncb new file mode 100755 index 0000000..320e0af Binary files /dev/null and b/libraries/pmrt/pmrt_llm/pmrt_llm.ncb differ diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.opt b/libraries/pmrt/pmrt_llm/pmrt_llm.opt new file mode 100755 index 0000000..1bb4aa3 Binary files /dev/null and b/libraries/pmrt/pmrt_llm/pmrt_llm.opt differ diff --git a/libraries/pmrt/pmrt_llm/pmrt_llm.plg b/libraries/pmrt/pmrt_llm/pmrt_llm.plg new file mode 100755 index 0000000..e69de29 diff --git a/libraries/pmrt/pmrt_llm/vssver.scc b/libraries/pmrt/pmrt_llm/vssver.scc new file mode 100755 index 0000000..a848a61 Binary files /dev/null and b/libraries/pmrt/pmrt_llm/vssver.scc differ diff --git a/libraries/pmrt/pmrt_messages/Debug/dbquery.obj b/libraries/pmrt/pmrt_messages/Debug/dbquery.obj new file mode 100755 index 0000000..41e4f45 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/dbquery.obj differ diff --git a/libraries/pmrt/pmrt_messages/Debug/filetransfer.obj b/libraries/pmrt/pmrt_messages/Debug/filetransfer.obj new file mode 100755 index 0000000..bb17513 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/filetransfer.obj differ diff --git a/libraries/pmrt/pmrt_messages/Debug/messages.obj b/libraries/pmrt/pmrt_messages/Debug/messages.obj new file mode 100755 index 0000000..f595990 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/messages.obj differ diff --git a/libraries/pmrt/pmrt_messages/Debug/node.obj b/libraries/pmrt/pmrt_messages/Debug/node.obj new file mode 100755 index 0000000..55cd399 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/node.obj differ diff --git a/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.lib b/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.lib new file mode 100755 index 0000000..487a555 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.lib differ diff --git a/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.obj b/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.obj new file mode 100755 index 0000000..50ddc4e Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.obj differ diff --git a/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.pch b/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.pch new file mode 100755 index 0000000..e48e366 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/pmrt_messages.pch differ diff --git a/libraries/pmrt/pmrt_messages/Debug/tokens.obj b/libraries/pmrt/pmrt_messages/Debug/tokens.obj new file mode 100755 index 0000000..8ab7774 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/tokens.obj differ diff --git a/libraries/pmrt/pmrt_messages/Debug/vc60.idb b/libraries/pmrt/pmrt_messages/Debug/vc60.idb new file mode 100755 index 0000000..8a54f77 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/vc60.idb differ diff --git a/libraries/pmrt/pmrt_messages/Debug/vc60.pdb b/libraries/pmrt/pmrt_messages/Debug/vc60.pdb new file mode 100755 index 0000000..6ad80a3 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/Debug/vc60.pdb differ diff --git a/libraries/pmrt/pmrt_messages/dbquery.c b/libraries/pmrt/pmrt_messages/dbquery.c new file mode 100755 index 0000000..46e86ca --- /dev/null +++ b/libraries/pmrt/pmrt_messages/dbquery.c @@ -0,0 +1,3547 @@ +// dbquery.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +// #include "node.h" +// #include + + +#include "dbquery.h" +#include "tokens.h" + +#include +#include +#include +#include +#include +#ifdef SYS_BB +#include +#endif +#ifdef SYS_PC +#include +#endif + +#include + +// #define SERVERCERT "/g3/bbh3data/ssl/queryserver.cert" +#define SSL_CIPHER "AES256-SHA" + +KeyGenHandle gKeyGenHandle; +// unsigned char gCryptoSeed[] = "0123456789abcdefghij"; +unsigned char gCryptoKey[32]; // AES key +unsigned char gCryptoIV[CRYPTO_IV_LEN]; // AES Initial Vector (this will get munged w/ filename to produce different IV for every file) + +#define DBSERVER_OLD_ERROR_STRING "ERROR " // how error messages from old server used to start (they looks like: "ERROR 1503: blah blah") +#define DBSERVER_ERROR_STRING "Error Code :" // how errors from new server begin +#define DBSERVER_ERROR_CANT_CONTACT_DBASE "ERROR 2003: Can't connect to MySQL server" // how connection errors from either server look + + +// Fill in info about basic DBQuery Types here, +// should match enumeration of DBQueryTypes in dbquery.h +// use AddNewDBQueryTypes() to add additional query types from game code +DBQueryTypeInfoStruct DBQueryTypeInfo[MAX_NUM_DBQUERY_TYPES] = +{ + // Query Type, Query Struct, Result Struct, Stored Proc Name + { DBQUERY_TYPE_PLAIN_TEXT,VOID_FORM,VOID_FORM, ""}, +// administrative queries (not actual queries, instead instruct DBQuery Thread to do something) + { DBQUERY_TYPE_PURGE_CACHE, VOID_FORM, VOID_FORM, "" }, + { DBQUERY_TYPE_RESET_BACKEDOFF_CLIENTS, VOID_FORM, VOID_FORM, "" }, + +}; + +// table of callbacks for orphan messages +DBQueryOrphanCallbackStruct DBQueryOrphanCallbacks[MAX_DBQUERY_ORPHAN_CALLBACKS] = +{ + { DBQUERY_TYPE_PLAIN_TEXT, NULL }, + { DBQUERY_TYPE_PURGE_CACHE, NULL }, + { DBQUERY_TYPE_RESET_BACKEDOFF_CLIENTS, NULL }, + +} ; + + +#define DBQUERY_LOOP_SLEEP_TIME 2 // how many msecs to sleep btwn each iteration of main loop + +#define DBQUERY_QUEUE_DEPTH 1024 + + +#define DBQUERY_MAX_NEW_MSGS_FROM_GAME_PER_LOOP 20 + +#define DBQUERY_MAX_MEM_CACHE_SIZE_NODES 2000 +#define DBQUERY_MAX_MEM_CACHE_SIZE_BYTES 5000000 // 5 megs +#define MAX_DBQUERY_CACHE_SAVES_PER_LOOP 10 + +#define DBQUERY_MAX_DISK_CACHE_SIZE_BYTES 50000000 // 50 megs + +/* +#if SYS_PC +#define DBQUERY_CACHE_DIR "/g3/bbh3tuser/querycache" +#endif +#if SYS_BB +#define DBQUERY_CACHE_DIR "/bbh3Tuser/querycache" +#endif +#define DBQUERY_SERVER "75.11.71.30" +#define DBQUERY_PORT 7788 +*/ + + +char gDBQueryCacheDir[128]; +char gDBQueryAuditsDir[128]; +char gDBQueryStatsAuditFile[128]; +char gDBQueryServerIP[128]; +char gDBQueryServerCertFile[128]; +int gDBQueryServerPort; + +int (*gpCheckIfOKToUseDiskFunc)(); + +int gNumDBQueryTypes; +int gNumDBQueryOrphanCallbacks; + + +N2 gDBQueryMessageList; +N2 gDBQueryResultCache; + +ThreadSafeQueue gDBQueryInQue; +ThreadSafeQueue gDBQueryOutQue; + +ThreadHandle gDBQueryThreadHandle; + +// how long to pause for after a failed connection/transmit err +// always a multiple of DBQUERY_BASE_BACKOFF_TIMEOUT +// never more than DBQUERY_MAX_BACKOFF_TIMEOUT +// doubles w/ every failed connect, reset w/ each successful connect +int gDBQueryBackOffTime; + +#define DBQUERY_MAX_TCP_MSG_SIZE 1024*1024 // 262144 + +// DBQUERY_MAX_CLIENT_SESSIONS +// if 2 or more then first session is always reserved for persistent messages +// each session gets a buffer of size DBQUERY_MAX_TCP_MSG_SIZE +// so don't got too ape with the number of them +#define DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS 1 + +// struct for tracking state on our client sessions +// each client session gets it's own copy of the DBQuery +// it's trying to answer, that way the client session can +// still continue even if the message that spawned it disappears +// (that way we don't have to kill an active client session when a message expires) +typedef struct +{ + SSLClientStateStruct state; + int expirey_time; + + char send_buf[DBQUERY_MAX_TCP_MSG_SIZE]; + char recv_buf[DBQUERY_MAX_TCP_MSG_SIZE]; + DBQuery query; + unsigned int MsgID; +} DBQueryClientSession; + +DBQueryClientSession gClientSessions[DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS]; + +// gClientSessionBufs[][] +// recv buffer for each client session +//char gClientSessionRecvBufs[DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS][DBQUERY_MAX_TCP_MSG_SIZE]; + +// gClientSessionQueries +// used to track what query was assigned to each client sessions +//DBQuery gClientSessionQueries[DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS]; + +struct DBQueryUpdateLoopVarStruct +{ + unsigned int loop_number; + int new_msgs_from_game_this_loop; + int new_results_from_client_this_loop; +}; + + + +int UpdateDBQueryResultCache( DBQueryResult *newresult ); + +// helpfer func borrowed from messages.c +extern int MatchMsgByID( void *arg, void *obj ); + + +// struct ClientStateStruct gClientState; + + +// malloc and free wrappers for tracking memory used +// by dbquery subsystem +void* dbquery_apphook_malloc(size_t size) +{ + void *ptr; + ptr = malloc(size); + AddToMemAllocHistory(ptr, size ); + return ptr; +} // dbquery_apphook_malloc() + +void dbquery_apphook_free(void *m) +{ +// prts_debug( "DBQuery System Free:\n" ); + DelFromMemAllocHistory(m); + free(m); +// prts_debug("Successfully free'd mem at %p\n", m ); +} // dbquery_apphook_free() + +int AddNewDBQueryTypes(int count, DBQueryTypeInfoStruct *NewQueryTypeInfo) +{ + int c,a; + if ( NewQueryTypeInfo == NULL ) + return -1; + + a = 0; + for ( c = 0; c < count; c++ ) + { + if ( gNumDBQueryTypes < MAX_NUM_DBQUERY_TYPES ) + { + memcpy(&DBQueryTypeInfo[gNumDBQueryTypes],&NewQueryTypeInfo[c], sizeof(DBQueryTypeInfoStruct) ); + gNumDBQueryTypes++; + a++; + } + else + break; + } + + return a; +} + +int AddNewDBQueryOrphanCallbacks( int count, DBQueryOrphanCallbackStruct *NewOrphanCallbacks ) +{ + int c,a; + if ( NewOrphanCallbacks == NULL ) + return -1; + + a = 0; + for ( c = 0; c < count; c++ ) + { + if ( gNumDBQueryOrphanCallbacks < MAX_DBQUERY_ORPHAN_CALLBACKS ) + { + memcpy(&DBQueryOrphanCallbacks[gNumDBQueryOrphanCallbacks],&NewOrphanCallbacks[c], sizeof(DBQueryOrphanCallbackStruct) ); + gNumDBQueryOrphanCallbacks++; + a++; + } + else + break; + } + + return a; +} + + +void FreeDBQuery( DBQuery *query, int free_query_data ) +{ + if ( query == NULL ) + return; + if ( free_query_data && query->query_data != NULL ) + dbquery_apphook_free(query->query_data); + dbquery_apphook_free(query); +} + +void FreeDBQueryResult( DBQueryResult *result, int free_query_data, int free_result_data ) +{ + if ( result == NULL ) + return; + + if ( free_query_data && result->query.query_data != NULL ) + dbquery_apphook_free(result->query.query_data); + if ( free_result_data && result->result_data != NULL ) + dbquery_apphook_free(result->result_data); + + dbquery_apphook_free(result); +} + + +int CreateDBQuery( DBQuery **ppQuery, int type, int maxage, int max_result_rows, int query_data_size, void *query_data, int copy_query_data ) +{ + DBQuery *query; + + if ( ppQuery == NULL ) + return -1; + + *ppQuery = dbquery_apphook_malloc(sizeof(DBQuery)); + if ( *ppQuery == NULL ) + return -2; + + query=*ppQuery; + + query->type = type; + query->max_result_rows = max_result_rows; + query->maxage = maxage; + query->query_data_size = query_data_size; + if ( ! copy_query_data || query_data == NULL ) + query->query_data = query_data; + else + { + query->query_data = dbquery_apphook_malloc(query_data_size); + if ( query->query_data == NULL ) + { + dbquery_apphook_free(query); + return -3; + } + memcpy( query->query_data, query_data, query_data_size ); + } + if ( query->query_data != NULL ) + query->query_data_crc = AudCRC32( (uns8*)query->query_data, query->query_data_size ); + else + query->query_data_crc = 0; + return 0; +} + + +int CloneDBQuery( DBQuery **ppDst, DBQuery *Src, int copy_query_data ) +{ + DBQuery *query = Src; + + if ( Src == NULL || ppDst == NULL ) + return -1; + + return CreateDBQuery( ppDst, query->type, query->maxage, query->max_result_rows, query->query_data_size, query->query_data, copy_query_data ); +} + + +int CopyDBQuery( DBQuery *src, DBQuery *dst, int copy_query_data ) +{ + + if ( src == NULL || dst == NULL ) + return -1; + + dst->type = src->type; + dst->max_result_rows = src->max_result_rows; + dst->maxage = src->maxage; + dst->query_data_size = src->query_data_size; + if ( ! copy_query_data || src->query_data == NULL ) + dst->query_data = src->query_data; + else + { + dst->query_data = dbquery_apphook_malloc(src->query_data_size); + if ( dst->query_data == NULL ) + return -2; + memcpy( dst->query_data, src->query_data, src->query_data_size ); + } + dst->query_data_crc = src->query_data_crc; + + return 0; +} + + +int CreateDBQueryResult( DBQueryResult **ppQueryResult, DBQuery *Query, int copy_query_data, int timestamp, int error_code, int result_row_size, int result_rows, void *result_data, int copy_result_data ) +{ + int ec; + DBQueryResult *result; + + if ( ppQueryResult == NULL ) + return -1; + + *ppQueryResult = dbquery_apphook_malloc(sizeof(DBQueryResult)); + if ( *ppQueryResult == NULL ) + return -2; + + result=*ppQueryResult; + + if ( Query != NULL ) + { + // use Copy instead of Clone here b/c result struct contains a full query + // rather than just a pointer to one + ec = CopyDBQuery( Query, &result->query, copy_query_data ); + if ( ec < 0 ) + { + dbquery_apphook_free(result); + return -3; + } + } + + result->timestamp = timestamp; + result->error_code = error_code; + result->result_row_size = result_row_size; + result->result_rows = result_rows; + result->saved = 0; + + if ( ! copy_result_data || result_data == NULL ) + result->result_data = result_data; + else + { + result->result_data = dbquery_apphook_malloc(result_row_size * result_rows); + if ( result->result_data == NULL ) + return -4; + memcpy( result->result_data, result_data, result_row_size * result_rows ); + } + if ( result->result_data != NULL ) + result->result_data_crc = AudCRC32( (uns8*)result->result_data, result->result_row_size * result->result_rows ); + else + result->result_data_crc = 0; + + return 0; +} + +int CloneDBQueryResult(DBQueryResult **ppDst, DBQueryResult *Src, int copy_query_data, int copy_result_data ) +{ + int ec; + DBQueryResult *result = Src; + ec = CreateDBQueryResult( ppDst, &result->query, copy_query_data, result->timestamp, result->error_code, result->result_row_size, result->result_rows, result->result_data, copy_result_data ); + if ( ec == 0 ) // create always sets saved to 0 + (*ppDst)->saved = Src->saved; + return ec; +} + +void PrintDBQuery( DBQuery *query, char *lead ) +{ + if ( query == NULL ) + return; + + prts_debug( "%s DBquery:\n", lead ); + prts_debug( "%s type: %d\n", lead, query->type ); + prts_debug( "%s maxage: %d\n", lead, query->maxage ); + prts_debug( "%s max_result_rows: %d\n", lead, query->max_result_rows ); + prts_debug( "%s query_data_size: %d\n", lead, query->query_data_size ); + prts_debug( "%s query_data: addr = %p\n", lead, query->query_data ); + + if ( query->type == DBQUERY_TYPE_PLAIN_TEXT && query->query_data != NULL ) + prts_debug( "%s query_data: %s\n", lead, query->query_data ); + else + prts_debug( "%s query_data: (binary)\n", lead ); + + prts_debug( "%s query_data_crc: = %u\n", lead, query->query_data_crc ); + +} + +void PrintDBQueryResult( DBQueryResult *result, char *lead ) +{ + char buf[256]; + DBQuery *query; + if ( result == NULL ) + return; + + strncpy( buf, lead, 200 ); + strncat( buf, " ", 56 ); + query = &result->query; + prts_debug( "%s DBquery Result:\n", lead ); + PrintDBQuery( query, buf ); + prts_debug( "%s timestamp: %d\n", lead, result->timestamp ); + prts_debug( "%s error_code: %d\n", lead, result->error_code ); + prts_debug( "%s result_row_size: %d\n", lead, result->result_row_size ); + prts_debug( "%s result_rows: %d\n", lead, result->result_rows ); + + prts_debug( "%s result_data: addr = %p\n", lead, result->result_data ); + if ( query->type == DBQUERY_TYPE_PLAIN_TEXT && result->result_data != NULL ) + prts_debug( "%s result_data: %s\n", lead, result->result_data ); + else + prts_debug( "%s result_data: (binary)\n", lead ); + + prts_debug( "%s result_data_crc: = %u\n", lead, result->result_data_crc ); + +} + + +// walks message list looking for message with passed id +Message *FindDBQueryMessageByID(unsigned int id) +{ + ObjData *obj; + obj = N2Search(gDBQueryMessageList.next,&id,MatchMsgByID); + if (obj != NULL) + { + return (Message *)obj->data; + } + return NULL; +} + +// same as above but returns node ptr instead of msg ptr +ObjData *FindDBQueryMessageNodeByID(unsigned int id) +{ + return N2Search(gDBQueryMessageList.next,&id,MatchMsgByID); +} + + +// write passed data to passed crypto file handle +// appending CRC after data +int WriteDataWithCRCToCryptoFile( void *data, int len, int count, CryptoFileHandle *cfh ) +{ + int ec; + int items_written; + uns32 crc; + + crc = AudCRC32( (uns8*)data, len * count ); + + items_written = len * count; + ec = WriteToCryptoFile( cfh, data, &items_written ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return ec; + if( items_written != len * count ) + return -1; + + items_written = sizeof(crc); + ec = WriteToCryptoFile( cfh, &crc, &items_written ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return ec; + if( items_written != sizeof(crc) ) + return -2; + + return CRYPTOFILE_RESULT_SUCCESS; +} + +// reads data from file handle into passed buffer +// then reads next 32 bytes from filehandle, +// assumes it is a CRC for the data +// (as would be the case if data was written with WriteDataWithCRCToFile()) +// and compares it to the calc'd CRC for the loaded data +int ReadDataWithCRCFromCryptoFile( void *data, int len, int count, CryptoFileHandle *cfh ) +{ + int ec; + int items_read; + uns32 data_crc,disk_crc; + + items_read = len * count; + ec = ReadFromCryptoFile( cfh, data, &items_read ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return ec; + if( items_read != len * count ) + return -1; + + items_read = sizeof(disk_crc); + ec = ReadFromCryptoFile( cfh, &disk_crc, &items_read ); + if( ec != CRYPTOFILE_RESULT_SUCCESS ) + return ec; + if (items_read != sizeof(disk_crc) ) + return -2; + + data_crc = AudCRC32((uns8*)data, len * count); + + if ( data_crc != disk_crc ) + return -3; + + return 0; + +} + + + + +int WriteDBQueryToCryptoFile( CryptoFileHandle *cfh, DBQuery *query ) +{ + int ec; + DBQuery tmpquery; + + if ( query == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( cfh == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + // copy bits from query into tmp var + tmpquery = *query; + tmpquery.query_data = NULL; // void out data ptr in tmp var + + + ec = WriteDataWithCRCToCryptoFile( &tmpquery, sizeof(tmpquery), 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + + if ( query->query_data_size > 0 && query->query_data != NULL ) + { + ec = WriteDataWithCRCToCryptoFile( query->query_data, query->query_data_size, 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + return DBQUERY_FILE_RESULT_SUCCESS; +} + +int WriteDBQueryResultToCryptoFile( CryptoFileHandle *cfh, DBQueryResult *result ) +{ + int ec; + DBQueryResult tmpresult; + DBQuery *query; + + if ( result == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( cfh == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + // copy bits to tmp result + tmpresult = *result; + // void out data ptrs in tmp var + tmpresult.query.query_data = NULL; + tmpresult.result_data = NULL; + + ec = WriteDataWithCRCToCryptoFile( &tmpresult, sizeof(tmpresult), 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + // write out query data + query = &result->query; + if ( query->query_data_size > 0 && query->query_data != NULL ) + { + ec = WriteDataWithCRCToCryptoFile( query->query_data, query->query_data_size, 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + // write out reply data + if ( result->result_row_size * result->result_rows > 0 && result->result_data != NULL ) + { + ec = WriteDataWithCRCToCryptoFile( result->result_data, result->result_row_size * result->result_rows, 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + return DBQUERY_FILE_RESULT_SUCCESS; + +} + +int LoadDBQueryFromCryptoFile( CryptoFileHandle *cfh, DBQuery *query ) +{ + int ec; + + if ( query == NULL || query->query_data != NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( cfh == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + ec = ReadDataWithCRCFromCryptoFile( query, sizeof(DBQuery), 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS) + { + query->query_data = NULL; + if ( ec == CRYPTOFILE_RESULT_EOF ) + return DBQUERY_FILE_RESULT_EOF; + + return DBQUERY_FILE_RESULT_READ_ERR; + } + + + if ( query->query_data_size < 1 ) + { + query->query_data = NULL; + } + else + { + // make space for query data + query->query_data = dbquery_apphook_malloc( query->query_data_size ); + if ( query->query_data == NULL ) + { + return DBQUERY_FILE_RESULT_MALLOC_ERR; + } + + ec = ReadDataWithCRCFromCryptoFile( query->query_data, query->query_data_size, 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + // free the memory we just allocated + dbquery_apphook_free(query->query_data); + query->query_data = NULL; + if ( ec == CRYPTOFILE_RESULT_EOF ) + return DBQUERY_FILE_RESULT_EOF; + + return DBQUERY_FILE_RESULT_READ_ERR; + } + } + + return DBQUERY_FILE_RESULT_SUCCESS; +} + + + +int LoadDBQueryResultFromCryptoFile( CryptoFileHandle *cfh, DBQueryResult *result ) +{ + + int ec; + DBQuery *query; + + if ( result == NULL || result->result_data != NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( cfh == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + + ec = ReadDataWithCRCFromCryptoFile( result, sizeof(DBQueryResult), 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + // null out pointers before bailing, just to be safe + result->query.query_data = NULL; + result->result_data = NULL; + + if ( ec == CRYPTOFILE_RESULT_EOF ) + return DBQUERY_FILE_RESULT_EOF; + + return DBQUERY_FILE_RESULT_READ_ERR; + } + + + query = &result->query; + + if ( query->query_data_size < 1 ) + { + query->query_data = NULL; + } + else + { + // make space for query data + query->query_data = dbquery_apphook_malloc( query->query_data_size ); + if ( query->query_data == NULL ) + { + return DBQUERY_FILE_RESULT_MALLOC_ERR; + } + + ec = ReadDataWithCRCFromCryptoFile( query->query_data, query->query_data_size, 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + // free the memory we just allocated + dbquery_apphook_free(query->query_data); + + // null out pointers before bailing, just to be safe + result->result_data = NULL; + query->query_data = NULL; + + if ( ec == CRYPTOFILE_RESULT_EOF ) + return DBQUERY_FILE_RESULT_EOF; + + return DBQUERY_FILE_RESULT_READ_ERR; + } + } + + if ( result->result_row_size * result->result_rows < 1 ) + { + result->result_data = NULL; + } + else + { + // make room for results + result->result_data = dbquery_apphook_malloc( result->result_row_size * result->result_rows ); + if ( result->result_data == NULL ) + { + // free any mem we've alloc'd here + if ( query->query_data != NULL ) + dbquery_apphook_free(query->query_data); + // null out pointers before bailing, just to be safe + result->result_data = NULL; + query->query_data = NULL; + + return DBQUERY_FILE_RESULT_MALLOC_ERR; + } + + ec = ReadDataWithCRCFromCryptoFile( result->result_data, result->result_row_size * result->result_rows, 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + // free any mem we've alloc'd here + if ( query->query_data != NULL ) + dbquery_apphook_free(query->query_data); + dbquery_apphook_free(result->result_data); + + query->query_data = NULL; + result->result_data = NULL; + + if ( ec == CRYPTOFILE_RESULT_EOF ) + return DBQUERY_FILE_RESULT_EOF; + + return DBQUERY_FILE_RESULT_READ_ERR; + } + } + + return DBQUERY_FILE_RESULT_SUCCESS; + +} + + +// write passed data to passed file handle +// appending CRC after data +int WriteDataWithCRCToFile( void *data, int len, int count, FILE *fd ) +{ + int items_written; + uns32 crc; + + crc = AudCRC32( (uns8*)data, len * count ); + + items_written = fwrite( data, len, count, fd ); + if( items_written != count) + return -1; + + items_written = fwrite( &crc, sizeof(crc), 1, fd ); + if( items_written != 1) + return -2; + + + return 0; +} + +// reads data from file handle into passed buffer +// then reads next 32 bytes from filehandle, +// assumes it is a CRC for the data +// (as would be the case if data was written with WriteDataWithCRCToFile()) +// and compares it to the calc'd CRC for the loaded data +int ReadDataWithCRCFromFile( void *data, int len, int count, FILE *fd ) +{ + int items_read; + uns32 data_crc,disk_crc; + + items_read = fread( data, len, count, fd ); + if( items_read != count ) + return -1; + + items_read = fread( &disk_crc, sizeof(uns32), 1, fd ); + if( items_read != 1) + return -2; + + data_crc = AudCRC32((uns8*)data, len * count); + + if ( data_crc != disk_crc ) + return -3; + + return 0; + +} + + + +int LoadDataWithCRC( void *data, int size, char *filename ) +{ + int ec; + FILE *fd; + fd = fopen(filename, "rb"); + if ( fd == NULL ) + return -1; + ec = ReadDataWithCRCFromFile( data, 1, size, fd ); + fclose(fd); + return ec; + +} + +int SaveDataWithCRC( void *data, int size, char *filename ) +{ + int ec; + FILE *fd; + fd = fopen(filename, "wb"); + if ( fd == NULL ) + return -1; + ec = WriteDataWithCRCToFile( data, 1, size, fd ); + fclose(fd); + return ec; +} + + + +int WriteDBQueryToFile( FILE *fd, DBQuery *query ) +{ + int ec; + DBQuery tmpquery; + + if ( query == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( fd == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + // copy bits from query into tmp var + tmpquery = *query; + tmpquery.query_data = NULL; // void out data ptr in tmp var + + + ec = WriteDataWithCRCToFile( &tmpquery, sizeof(tmpquery), 1, fd ); + if ( ec < 0 ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + + if ( query->query_data_size > 0 && query->query_data != NULL ) + { + ec = WriteDataWithCRCToFile( query->query_data, query->query_data_size, 1, fd ); + if ( ec < 0 ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + + return DBQUERY_FILE_RESULT_SUCCESS; +} + +int WriteDBQueryResultToFile( FILE *fd, DBQueryResult *result ) +{ + int ec; + DBQueryResult tmpresult; + DBQuery *query; + + if ( result == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( fd == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + // copy bits to tmp result + tmpresult = *result; + // void out data ptrs in tmp var + tmpresult.query.query_data = NULL; + tmpresult.result_data = NULL; + + ec = WriteDataWithCRCToFile( &tmpresult, sizeof(tmpresult), 1, fd ); + if ( ec < 0 ) + { + + } + + // write out query data + query = &result->query; + if ( query->query_data_size > 0 && query->query_data != NULL ) + { + ec = WriteDataWithCRCToFile( query->query_data, query->query_data_size, 1, fd ); + if ( ec < 0 ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + // write out reply data + if ( result->result_row_size * result->result_rows > 0 && result->result_data != NULL ) + { + ec = WriteDataWithCRCToFile( result->result_data, result->result_row_size * result->result_rows, 1, fd ); + if ( ec < 0 ) + return DBQUERY_FILE_RESULT_WRITE_ERR; + } + + return DBQUERY_FILE_RESULT_SUCCESS; + +} + +int LoadDBQueryFromFile( FILE *fd, DBQuery *query ) +{ + int ec; + + if ( query == NULL || query->query_data != NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( fd == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + ec = ReadDataWithCRCFromFile( query, sizeof(DBQuery), 1, fd ); + if ( ec < 0 ) + { + query->query_data = NULL; + return DBQUERY_FILE_RESULT_READ_ERR; + } + + + if ( query->query_data_size < 1 ) + { + query->query_data = NULL; + } + else + { + // make space for query data + query->query_data = dbquery_apphook_malloc( query->query_data_size ); + if ( query->query_data == NULL ) + { + return DBQUERY_FILE_RESULT_MALLOC_ERR; + } + + ec = ReadDataWithCRCFromFile( query->query_data, query->query_data_size, 1, fd ); + if ( ec < 0 ) + { + // free the memory we just allocated + dbquery_apphook_free(query->query_data); + query->query_data = NULL; + return DBQUERY_FILE_RESULT_READ_ERR; + } + } + + return DBQUERY_FILE_RESULT_SUCCESS; +} + + + +int LoadDBQueryResultFromFile( FILE *fd, DBQueryResult *result ) +{ + + int ec; + DBQuery *query; + + if ( result == NULL || result->result_data != NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( fd == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + + ec = ReadDataWithCRCFromFile( result, sizeof(DBQueryResult), 1, fd ); + if ( ec < 0 ) + { + // null out pointers before bailing, just to be safe + result->query.query_data = NULL; + result->result_data = NULL; + return DBQUERY_FILE_RESULT_READ_ERR; + } + + + query = &result->query; + + if ( query->query_data_size < 1 ) + { + query->query_data = NULL; + } + else + { + // make space for query data + query->query_data = dbquery_apphook_malloc( query->query_data_size ); + if ( query->query_data == NULL ) + { + return DBQUERY_FILE_RESULT_MALLOC_ERR; + } + + ec = ReadDataWithCRCFromFile( query->query_data, query->query_data_size, 1, fd ); + if ( ec < 0 ) + { + // free the memory we just allocated + dbquery_apphook_free(query->query_data); + + // null out pointers before bailing, just to be safe + result->result_data = NULL; + query->query_data = NULL; + return DBQUERY_FILE_RESULT_READ_ERR; + } + } + + if ( result->result_row_size * result->result_rows < 1 ) + { + result->result_data = NULL; + } + else + { + // make room for results + result->result_data = dbquery_apphook_malloc( result->result_row_size * result->result_rows ); + if ( result->result_data == NULL ) + { + // free any mem we've alloc'd here + if ( query->query_data != NULL ) + dbquery_apphook_free(query->query_data); + // null out pointers before bailing, just to be safe + result->result_data = NULL; + query->query_data = NULL; + + return DBQUERY_FILE_RESULT_MALLOC_ERR; + } + + ec = ReadDataWithCRCFromFile( result->result_data, result->result_row_size * result->result_rows, 1, fd ); + if ( ec < 0 ) + { + // free any mem we've alloc'd here + if ( query->query_data != NULL ) + dbquery_apphook_free(query->query_data); + dbquery_apphook_free(result->result_data); + + query->query_data = NULL; + result->result_data = NULL; + + return DBQUERY_FILE_RESULT_READ_ERR; + } + } + + return DBQUERY_FILE_RESULT_SUCCESS; + +} + + +int GenerateFileIV( char *filename, unsigned char *iv, int iv_len ) +{ + int i,len; + int ec = 0; + + // Want to avoid using the same IV twice + // as this has the potential to leak information + // see (http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation) + // But IV does not have to be secret and we need to be able to + // recover the encryption IV for later decryption + // so... + // Generate a pseudo random number based on our filename + // and use that for the IV + // our filenames are guarenteed unique + // (will use the same IV for the same filename, but that's ok b/c that means we are overwriting the file) + // and include a fair amount of random noise (timestamps, data CRCs, etc) + // so this should work reasonably well + //ec = GenerateCryptoKey( (unsigned char *)filename, strlen(filename), iv, iv_len ); + //if ( ec != KEYGEN_RESULT_SUCCESS ) + //{ + // memset( iv, 0, iv_len ); + // return -1; + //} + + /* GenerateCryptoKey is now thread safe! + // GenerateCryptoKey is not thread safe! :( + // just copy the filename in there for now + memset( iv, 0, iv_len ); + len = strlen(filename); + for ( i = 0; i < iv_len; i++ ) + { + iv[i] = filename[i % len]; + } + */ + + // GenerateCryptoKey() can take a while so... + // finally for quickness, settled on this + // munge filename with a global secret + memset( iv, 0, iv_len ); + len = strlen(filename); + for ( i = 0; i < iv_len; i++ ) + { + iv[i] = filename[i % len] ^ gCryptoIV[ i & sizeof(gCryptoIV) ]; + } + + return 0; + +} + + +int SaveDBQuery( char *filename, DBQuery *query ) +{ + CryptoFileHandle cfh; + int ec; + unsigned char FileIV[CRYPTO_IV_LEN]; + GenerateFileIV( filename, FileIV, sizeof(FileIV) ); + + if ( query == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( filename == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + ec = OpenCryptoFile( &cfh, filename, "wb", CRYPTO_ENCRYPT, CRYPTO_AES256, gCryptoKey, sizeof(gCryptoKey), FileIV, sizeof(FileIV) ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FOPEN_ERR; + ec = WriteDBQueryToCryptoFile(&cfh,query); + if( CloseCryptoFile(&cfh) != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FCLOSE_ERR; + + return ec; + +} + +int LoadDBQuery( char *filename, DBQuery *query ) +{ + CryptoFileHandle cfh; + + int ec; + + unsigned char FileIV[CRYPTO_IV_LEN]; + GenerateFileIV( filename, FileIV, sizeof(FileIV) ); + + if ( query == NULL || query->query_data != NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( filename == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + ec = OpenCryptoFile( &cfh, filename, "rb", CRYPTO_DECRYPT, CRYPTO_AES256, gCryptoKey, sizeof(gCryptoKey), FileIV, sizeof(FileIV) ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FOPEN_ERR; + ec = LoadDBQueryFromCryptoFile(&cfh,query); + if( CloseCryptoFile(&cfh) != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FCLOSE_ERR; + + return ec; + +} + + +int SaveDBQueryResult( char *filename, DBQueryResult *result ) +{ + CryptoFileHandle cfh; + int ec; + unsigned char FileIV[CRYPTO_IV_LEN]; + GenerateFileIV( filename, FileIV, sizeof(FileIV) ); + + + if ( result == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( filename == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + ec = OpenCryptoFile( &cfh, filename, "wb", CRYPTO_ENCRYPT, CRYPTO_AES256, gCryptoKey, sizeof(gCryptoKey), FileIV, sizeof(FileIV) ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FOPEN_ERR; + ec = WriteDBQueryResultToCryptoFile(&cfh,result); + if( CloseCryptoFile(&cfh) != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FCLOSE_ERR; + + return ec; + +} + +int LoadDBQueryResult( char *filename, DBQueryResult *result ) +{ + CryptoFileHandle cfh; + + int ec; + unsigned char FileIV[CRYPTO_IV_LEN]; + GenerateFileIV( filename, FileIV, sizeof(FileIV) ); + + if ( result == NULL || result->result_data != NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + if ( filename == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + ec = OpenCryptoFile( &cfh, filename, "rb", CRYPTO_DECRYPT, CRYPTO_AES256, gCryptoKey, sizeof(gCryptoKey), FileIV, sizeof(FileIV) ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FOPEN_ERR; + ec = LoadDBQueryResultFromCryptoFile(&cfh,result); + if( CloseCryptoFile(&cfh) != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FCLOSE_ERR; + + + return ec; + +} + + +// pass in a query and he'll return a pointer to a copy of the disk cache'd result +// for that query or NULL if no result exists in disk cache +DBQueryResult *SearchDBQueryResultCacheFiles( DBQuery *query ) +{ + int ec; + char dirname[512]; + char buf[512]; + DBQueryResult result; + DBQueryResult *newresult; + int found; + FsDH fdh; + char *filename; + + if ( query == NULL ) + return NULL; + + // walk directory for this query type and data, + // loading each file and seeing + // if it is a match for our query + sprintf(dirname, "%s/%04d/%08X",gDBQueryCacheDir,query->type,(unsigned int)query->query_data_crc ); + + found = 0; + result.query.query_data = NULL; + result.result_data = NULL; + + // prts_debug( "LOOKING FOR DIR '%s'\n", dirname ); + + // walk files in dir + if ( FsOpenDir(&fdh, dirname) < 0 ) // failed to open dir + return NULL; + + // prts_debug( "OPENED DIR '%s'\n", dirname ); + while( (filename = FsReadDir(&fdh)) != NULL ) + { + if (filename[0] == '.' ) { continue; } // skip '.' and '..' + // prts_debug( "LOOKING AT FILE '%s'\n", filename ); + + sprintf(buf, "%s/%04d/%08X/%s",gDBQueryCacheDir,query->type,(unsigned int)query->query_data_crc,filename); + // load up result + ec = LoadDBQueryResult( buf, &result ); + if ( ec == DBQUERY_FILE_RESULT_SUCCESS ) + { + // PrintDBQueryResult( &result, "LOADED RESULT: " ); + // check if result matches our query + if ( DBQueryCompare( query, &result.query ) == 0) + { + found = 1; + break; + } + } + // free any data in result before moving to next pass in loop + if ( result.query.query_data != NULL ) + dbquery_apphook_free(result.query.query_data); + if ( result.result_data != NULL ) + dbquery_apphook_free(result.result_data); + // reset data pointers + result.query.query_data = NULL; + result.result_data = NULL; + + } + FsCloseDir(&fdh); + + if (found == 1 ) + { + // note that we only copy ptrs to data + // this works b/c we have already malloc'd for space for the + // data and the local 'result' struct won't use + // it's ptrs to the space after func exits + ec = CloneDBQueryResult( &newresult, &result, 0, 0 ); + if ( ec == 0 ) + { + // success + return newresult; + } + } + + + // free any data in local copy of result + if ( result.query.query_data != NULL ) + dbquery_apphook_free(result.query.query_data); + if ( result.result_data != NULL ) + dbquery_apphook_free(result.result_data); + + return NULL; + + + + +} + + +void ConstructDBQueryResultFilename( DBQueryResult *result, char *dest, int len ) +{ +// char filename[512]; + + if ( result == NULL || dest == NULL ) + { + if ( dest != NULL ) + dest[0] = '\0'; + return; + } + + // name is compound of "query type/query crc/result_crc.result_timestamp" + // this should be pretty unique + // allows us to quickly search for matching files + // by filtering on query type query crc + // directory structure is done this way to allow quick searches + // filename is also formatted w/ fixed widths for easy comparing + + sprintf(dest, "%s/%04d/%08X/%08X.%d.dat", gDBQueryCacheDir, + result->query.type, + (unsigned int)result->query.query_data_crc, + (unsigned int)result->result_data_crc, + result->timestamp ); + + + +} + + +int SaveDBQueryResultCacheFile( DBQueryResult *result ) +{ + int ec; + char buf[512]; + char filename[512]; + + if ( result == NULL ) + return DBQUERY_FILE_RESULT_INVALID_PARAMS; + + // create directory structure for file + sprintf(buf, "%s/%04d", gDBQueryCacheDir, result->query.type ); + ec = FsMkDir(buf, 1); + if( ec != 0 ) + { + return DBQUERY_FILE_RESULT_MKDIR_ERR; + } + + sprintf(buf, "%s/%04d/%08X", gDBQueryCacheDir,result->query.type,(unsigned int)result->query.query_data_crc ); + ec = FsMkDir(buf, 1); + if( ec != 0 ) + { + return DBQUERY_FILE_RESULT_MKDIR_ERR; + } + + ConstructDBQueryResultFilename( result, filename, sizeof(filename) ); + return SaveDBQueryResult( filename, result ); +} + +int DelDBQueryResultCacheFile( DBQueryResult *result ) +{ + char filename[512]; + ConstructDBQueryResultFilename( result, filename, sizeof(filename) ); + return unlink(filename); +} + +// find and delete all files which hold answers for the passed query +int DelAllDBQueryResultCacheFilesForQuery( DBQuery *query ) +{ + int count; + DBQueryResult *result; + while( (result=SearchDBQueryResultCacheFiles(query)) != NULL ) + { + DelDBQueryResultCacheFile(result); + FreeDBQueryResult(result,1,1); + count++; + } + return count; +} + + +// this function walks the query cache on disk +// deleting either files or dirs or both as it goes +// dirs will fail to delete if they have files in them +// so this function can be called w/ just RmDirs set to +// safely 'clean up' query cache dir structure (delete unused dirs) +int PurgeDBQueryDiskCache(int RmFiles, int RmDirs) +{ + int count = 0; + FsDH cache_fdh; + FsDH type_fdh; + FsDH query_fdh; + + char *type,*query,*result; + + char buf[256]; + + + if ( FsOpenDir( &cache_fdh, gDBQueryCacheDir ) < 0 ) + { + prts_debug( "Failed to open '%s' while pruning query cache\n", gDBQueryCacheDir ); + return count; + } + + while( (type = FsReadDir(&cache_fdh)) != NULL) + { + if ( type[0] == '.' ) { continue; } // skip . and .. + sprintf(buf, "%s/%s", gDBQueryCacheDir, type ); + if (FsOpenDir( &type_fdh, buf ) < 0 ) + { + prts_debug( "Failed to open '%s' while pruning query cache\n", buf ); + continue; + } + while ( (query = FsReadDir(&type_fdh)) != NULL ) + { + if ( query[0] == '.' ) { continue; } // skip . and .. + sprintf(buf, "%s/%s/%s", gDBQueryCacheDir, type, query ); + if ( FsOpenDir( &query_fdh, buf ) < 0 ) + { + prts_debug( "Failed to open '%s' while pruning query cache\n", buf ); + continue; + } + + while ( (result = FsReadDir(&query_fdh)) != NULL ) + { + if ( result[0] == '.' ) { continue; } // skip . and .. + if ( RmFiles ) + { + count++; + sprintf(buf, "%s/%s/%s/%s", gDBQueryCacheDir, type, query, result ); + prts_debug( "CACHE PURGE: unlinking file '%s'\n", buf ); + unlink(buf); + } + } + FsCloseDir(&query_fdh); + if ( RmDirs ) + { + sprintf(buf, "%s/%s/%s", gDBQueryCacheDir, type, query ); + rmdir(buf); + } + } + FsCloseDir(&type_fdh); + if ( RmDirs ) + { + sprintf(buf, "%s/%s", gDBQueryCacheDir, type ); + rmdir(buf); + } + } + FsCloseDir(&cache_fdh); + return count; +} + +int PurgeDBQueryMemCache() +{ + int c; + ObjData *Obj; + DBQueryResult *result; + // Unlink cache entry and free the attached result + while( (Obj = (ObjData*)N2PopNode(gDBQueryResultCache.next)) != NULL ) + { + result = (DBQueryResult*)Obj->data; + if ( result != NULL ) + prts_debug( "CACHE PURGE: unlinking results from mem cache (qtype=%d,datacrc=%d)\n", result->query.type, result->query.query_data_crc ); + else + prts_debug( "CACHE PURGE: unlinking results from mem cache\n" ); + + FreeDBQueryResult(result, 1, 1 ); + dbquery_apphook_free(Obj); + c++; + } + return c; +} + +int PurgeDBQueryCache() +{ + int c; + prts_debug( "CACHE PURGE: starting\n" ); + c = PurgeDBQueryMemCache(); + prts_debug( "CACHE PURGE: purged %d record from mem cache\n",c ); + c = PurgeDBQueryDiskCache(1,1); + prts_debug( "CACHE PURGE: purged %d record from disk cache\n",c ); + return c; +} + +void AttachResultToMessage( DBQueryResult *result, Message *msg ) +{ + int ec; + DBQueryResult *oldresult,*newresult; + + if ( result == NULL || msg == NULL ) + return; + + // prts_debug( "DB Query Thread: Matched db query results to msg %d\n", msg->id ); + + // first check if this message already has an answer (maybe a tenative one or a server err result?) + oldresult = (DBQueryResult *)msg->reply_data; + if ( oldresult != NULL && oldresult->timestamp > result->timestamp) + { + // prts_debug( "DB Query Thread: existing result is newer, leaving alone\n" ); + return; // don't replace a newer answer + } + + // prts_debug( "DB Query Thread: (msg id = %d) creating copy of results (%p)\n", msg->id, result ); + + // make a copy of the result to attach to message + ec = CloneDBQueryResult( &newresult, result, 1, 1 ); + if ( ec < 0 ) + { + prts_debug( "DB Query Thread: failed to copy db query result\n" ); + return; + } + + // prts_debug( "DB Query Thread: attaching copy of results (%p) to message (msg id = %d)\n", newresult, msg->id ); + // PrintDBQueryResult( result, "DBQuery Thread: Orig Result: " ); + // PrintDBQueryResult( newresult, "DBQuery Thread: Result: " ); + + msg->reply_data = newresult; + + // check error code of result + // only give back definitive answers for successful queries + // otherwise mark answer as tenative (a copy will be sent back to game and then query will be retried) + // note that we don't retry non-persistent messages if the server give us back an error message + // but we will retry persistent messages if this happens, see below + if ( newresult->error_code == DBQUERY_RESULT_SUCCESS + || + ( (!msg->persist) && + (newresult->error_code == DBQUERY_RESULT_SERVER_RETURNED_ERR + || newresult->error_code == DBQUERY_RESULT_ERROR_PARSING_RESULTS ) ) + ) + msg->waitstatus = MESSAGE_ANSWERED; + else + msg->waitstatus = MESSAGE_ANSWERED_TENTATIVE; + + // + // little trick here, if we got back an error from the server + // we bump the priority of the message down + // this has the effect of moving it to the end of line + // note that persitent queries are processed in a head-of-line-blocking fashion + // so this allows us to process other messages that (hopefully) don't have errors + // but still retry the errored message + // an error like this typically means a stored proc on the + // server got screwed up, retrying the messages like this is gives us + // a chance to fix the stored proc w/o losing the message and w/o blocking all + // other messages, just have to hope that later messages are not dependent on this one (like player create followed by player records...) + if( msg->persist + && (newresult->error_code == DBQUERY_RESULT_SERVER_RETURNED_ERR + || newresult->error_code == DBQUERY_RESULT_ERROR_PARSING_RESULTS ) + ) + { + if ( msg->priority < 100000 ) // just bogus to keep the int from rolling over + msg->priority++; + + // here's another bogus trick, for persistent messages we overload the waittime + // with the time that we should next try the message + // this allows us to backoff on trying 'errored' persistent messages + // w/o backing off on all queries + msg->waittime = time(NULL) + (60*60); // try again in an hour + + if ( msg->waittime > msg->timestamp + (14*24*60*60) ) // 14 days + { + // if the message is too old, then give up on it + // that's 14 days that a message will kick around + // before we finally give up on it, + // should give us time to fix whatever the DB problem was + // or if it was a client-side problem then we do eventually + // purge the message + msg->waitstatus = MESSAGE_ANSWERED; + } + } + + + if ( oldresult != NULL ) // free old result + { + // prts_debug( "DB Query Thread: freeing old msg reply data\n"); + FreeDBQueryResult( oldresult, 1, 1 ); + } + +} + + +int DBQueryCompare( DBQuery *q1, DBQuery *q2 ) +{ + + if ( q1 == NULL || q2 == NULL ) + return -1; + + if ( q1->type != q2->type ) + return -1; + + // prts_debug( "Comparing queries: '%s' to '%s'\n",q1->query_data,q2->query_data); + + switch(q1->type) + { + case DBQUERY_TYPE_PLAIN_TEXT: + return strcmp(q1->query_data,q2->query_data); + break; + default: + return StructCmp(DBQueryTypeInfo[q1->type].query_struct_type,q1->query_data,q2->query_data); + break; + } + + + // they match!! + return 0; + +} + + +int MatchDBQueryResult( void *arg, void *obj ) +{ +// int ec; + ObjData *DataObj = (ObjData *)obj; + Message *msg; + DBQuery *q1; + DBQuery *q2; + DBQueryResult *result; // ,*oldresult,*newresult; + + result = (DBQueryResult *) arg; + if ( result == NULL ) + return 0; + q1 = &result->query; + + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return 0; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return 0; + + q2 = (DBQuery *) msg->msg_data; + + if ( DBQueryCompare( q1, q2 ) != 0 ) // they don't match + return 0; + + // they match! + + AttachResultToMessage(result, msg); + + // success! + // return 0 so N2Walk keeps going, want to compare new result to every + // outstanding message, so if we have two msgs w/ the same query then + // we answer them both + return 0; +} + + +int MatchDBQueryToDBQueryResultCacheObj( void *arg, void *obj ) +{ + DBQuery *query = (DBQuery*)arg; + DBQueryResult *result; + ObjData *cacheobj = (ObjData *)obj; + + // prts_debug( "MATCH DBQUERY TO DBQUERY RESULT CACHE CALLED:\n" ); + + if ( query == NULL || cacheobj == NULL + || cacheobj->lnk.type != N2TYPE_OBJ + || cacheobj->lnk.sub != OBJSUB_DATA + || cacheobj->data == NULL ) + return -1; + + result = (DBQueryResult*)cacheobj->data; + + /* + prts_debug( "Arg Query:\n" ); + PrintDBQuery( query, " " ); + prts_debug( "Cache Query:\n" ); + PrintDBQuery( &result->query , " " ); + */ + + return DBQueryCompare( query, &result->query ); + + +} + +int MatchDBQueryResultToDBQueryResultCacheObj( void *result, void *obj ) +{ + DBQueryResult *newresult = (DBQueryResult*)result; + DBQueryResult *oldresult; + ObjData *cacheobj = (ObjData *)obj; + + if ( newresult == NULL || cacheobj == NULL + || cacheobj->lnk.type != N2TYPE_OBJ + || cacheobj->lnk.sub != OBJSUB_DATA + || cacheobj->data == NULL ) + return -1; + + oldresult = (DBQueryResult*)cacheobj->data; + + return DBQueryCompare( &newresult->query, &oldresult->query ); + + +} + +// pass in a new result and he'll either add it to the cache +// or update the existing cache entry for the result +int UpdateDBQueryResultCache( DBQueryResult *newresult ) +{ + int ec; + ObjData *Obj; + DBQueryResult *oldresult; + + if ( newresult == NULL ) + return -1; + + // prts_debug( "Updating results cache\n" ); + + + if ( newresult->error_code != DBQUERY_RESULT_SUCCESS ) + { + prts_debug( "Refusing to cache err'd results!\n" ); + FreeDBQueryResult(newresult, 1, 1 ); + return 0; // do not return err as this is normal behavior + } + + if ( newresult->query.maxage <= 0 ) + { + // prts_debug( "Refusing to cache results for a query with maxage <= 0!\n" ); + FreeDBQueryResult(newresult, 1, 1 ); + return 0; // do not return err as this is normal behavior + } + + Obj = N2Search( gDBQueryResultCache.next, newresult, MatchDBQueryResultToDBQueryResultCacheObj ); + if ( Obj == NULL ) // no existing result, make a new one + { + // prts_debug( "Adding cache node for new results\n" ); + + ec = N2AddDataNode( &gDBQueryResultCache, dbquery_apphook_malloc, newresult, 0 ); + if ( ec < 0 ) + { + prts_debug( "failed when Adding cache node for new results\n" ); + + // could not add node to cache for some reason :( + // give up and free result data + FreeDBQueryResult(newresult, 1, 1 ); + return -1; + } + } + else // obj does exist, update it by pointing it at the new result + { + // prts_debug( "Updating cache node for new results\n" ); + + oldresult = (DBQueryResult*)Obj->data; + + // if out new result has a 0 or negative timestamp + // then copy the timestamp from oldresult + // this is done with cache updates + // so that the cache update does not end up with a newer + // timestamp than the original cache entry + // that way we can send down new cache updates + // and yet still have the cache entry age out + // otherwise a steady stream of cache updates from the game + // would prevent us from ever going back to the server + // to answer a query + if ( newresult->timestamp <= 0 ) + { + newresult->timestamp = oldresult->timestamp; + } + Obj->data = newresult; + // free old result now that we are done with it + FreeDBQueryResult(oldresult, 1, 1 ); + } + + + return 0; +} + + + + +int PurgeQueryFromDBQueryResultCache( DBQuery *query ) +{ + // int ec; + ObjData *Obj; + DBQueryResult *result; + int count = 0; + + Obj = N2Search( gDBQueryResultCache.next, query, MatchDBQueryToDBQueryResultCacheObj ); + if ( Obj == NULL ) + return 0; // cache miss + + result = (DBQueryResult*)Obj->data; + + if ( N2PopNode(Obj) != NULL ) + { + FreeDBQueryResult(result, 1, 1 ); + dbquery_apphook_free(Obj); + count++; + } + + return count; +} + + +// pass in a query and he'll return a pointer to a copy of the cache'd result +// for that query or NULL if no result exists in cache +DBQueryResult *SearchDBQueryResultCache( DBQuery *query ) +{ + int ec; + ObjData *Obj; + DBQueryResult *newresult; + + prts_debug( "searching results cache\n" ); + Obj = N2Search( gDBQueryResultCache.next, query, MatchDBQueryToDBQueryResultCacheObj ); + if ( Obj == NULL ) + return NULL; // cache miss + + ec = CloneDBQueryResult( &newresult, (DBQueryResult*) Obj->data, 1, 1 ); + if ( ec < 0 ) + { + // failed to create a copy of result for some reason + // bail :( + return NULL; + } + + return newresult; + +} + + + +int DBQueryCheckForEndOfRecvData(ClientStateStruct *clientstate) +{ + if ( clientstate == NULL ) + return -1; + + if ( clientstate->recv_count < 2 ) + return -1; + + // look for two newlines in a row as signal for end of query results + if ( clientstate->recv_buf[clientstate->recv_count-2] == 10 + && + clientstate->recv_buf[clientstate->recv_count-1] == 10 ) + { + // match! + return 0; + } + + return -1; +} + +int DBQuerySSLCheckForEndOfRecvData(SSLClientStateStruct *clientstate) +{ + if ( clientstate == NULL ) + return -1; + + if ( clientstate->recv_count < 2 ) + return -1; + + // look for two newlines in a row as signal for end of query results + if ( clientstate->recv_buf[clientstate->recv_count-2] == 10 + && + clientstate->recv_buf[clientstate->recv_count-1] == 10 ) + { + // match! + return 0; + } + + return -1; +} + + + +int DBQuerySystemInit(char *CacheDir, char *AuditsDir, + char *ServerIP, int ServerPort, char *ServerCertFile, + int (*pCheckIfOKToUseDiskFunc)(), + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize ) +{ + int ec; + int i; + ThreadStartInfo tsi; + char buf[256]; + + strcpy( gDBQueryCacheDir, CacheDir ); + strcpy( gDBQueryAuditsDir, AuditsDir ); + strcpy( gDBQueryServerIP, ServerIP ); + strcpy( gDBQueryServerCertFile, ServerCertFile ); + sprintf( gDBQueryStatsAuditFile, "%s/dbquerystats.000.aud", gDBQueryAuditsDir ); + + gDBQueryServerPort = ServerPort; + gpCheckIfOKToUseDiskFunc = pCheckIfOKToUseDiskFunc; + + + gNumDBQueryTypes = NUM_BASE_DBQUERY_TYPES; + gNumDBQueryOrphanCallbacks = NUM_BASE_DBQUERY_TYPES; + + gDBQueryBackOffTime = DBQUERY_BASE_BACKOFF_TIMEOUT; + + ec = ThreadSafeQueueInit( &gDBQueryInQue, DBQUERY_QUEUE_DEPTH, dbquery_apphook_malloc, dbquery_apphook_free ); + if ( ec != TSQ_RESULT_SUCCESS ) + return -1; + + ec = ThreadSafeQueueInit( &gDBQueryOutQue, DBQUERY_QUEUE_DEPTH, dbquery_apphook_malloc, dbquery_apphook_free ); + if ( ec != TSQ_RESULT_SUCCESS ) + return -2; + + + N2Head(&gDBQueryMessageList); + N2Head(&gDBQueryResultCache); + memset(&gDBQuerySystemStats,0,sizeof(gDBQuerySystemStats) ); + // load stats from file + ec = LoadDataWithCRC( &gDBQuerySystemStats,sizeof(gDBQuerySystemStats), gDBQueryStatsAuditFile); + if ( ec < 0 ) + { + memset(&gDBQuerySystemStats,0,sizeof(gDBQuerySystemStats) ); + gDBQuerySystemStats.start_timestamp = time(NULL); + } + + + + + for ( i = 0; i < DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; i++ ) + { + gClientSessions[i].state.state = CLIENT_STATE_AVAILABLE; + gClientSessions[i].query.query_data = NULL; + } + + + memset( gCryptoKey, 0, sizeof(gCryptoKey) ); + ec = GenerateCryptoKey( CryptoSeed, CryptoSeedSize, gCryptoKey, sizeof(gCryptoKey) ); + if( ec != KEYGEN_RESULT_SUCCESS ) + return -6; + + memset( gCryptoIV, 0, sizeof(gCryptoIV) ); + ec = GenerateCryptoKey( CryptoSeed, CryptoSeedSize, gCryptoIV, sizeof(gCryptoIV) ); + if( ec != KEYGEN_RESULT_SUCCESS ) + return -7; + + // init our ssl key and cert + sprintf( buf, "Play Mechanix (%s)", ClientID ); + ec = InitKeyHandleFromSeed( &gKeyGenHandle, CryptoSeed, CryptoSeedSize, buf ); + if( ec != KEYGEN_RESULT_SUCCESS ) + return -8; + +#if !PRODUCTION + // save public portion of key + ec = SaveKeyHandleCert(&gKeyGenHandle, "client.cert" ); +#endif + // save private portion of key + // ec = SaveKeyHandlePrivateKey(&kgh, "client.key" ); + + memset( gDBQueryPublicCert, 0, sizeof(gDBQueryPublicCert) ); + ec = ExportKeyHandleCert( &gKeyGenHandle, gDBQueryPublicCert, sizeof(gDBQueryPublicCert) ); + if ( ec != KEYGEN_RESULT_SUCCESS ) + { + strcpy( gDBQueryPublicCert, "N/A" ); + } + + // init our ssl client structs + memset( gClientSessions, 0, sizeof(gClientSessions) ); + for ( i = 0; i < DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; i++ ) + { + ec = InitSSLClientStateStruct(&gClientSessions[i].state, + gDBQueryServerIP , gDBQueryServerPort, // 7787, + &gKeyGenHandle, + NULL, NULL, + gDBQueryServerCertFile, SSL_CIPHER, + gClientSessions[i].send_buf, sizeof(gClientSessions[i].send_buf), + gClientSessions[i].recv_buf, sizeof(gClientSessions[i].recv_buf), + 1, + DBQuerySSLCheckForEndOfRecvData, DBQUERY_DISABLE_PERSISTENT_CONNECTIONS, + // NULL, 1, + DBQUERY_WAIT_CONNECT_TIMEOUT, + DBQUERY_SEND_TIMEOUT, + DBQUERY_RECV_TIMEOUT, + gDBQueryBackOffTime, + // 0, 0, // use dflt ssl session length values + 1024*1024*5, // renegotiate ssl session every 5mb of data transfered + 4*60*60, // or every 4 hours, notice these are way up from dflts in order to cut down on bandwidth use + 1 ); // ignore_dates_on_server_cert + // 100, 60 ); // use dflt ssl session length values + + if ( ec < 0 ) + { + if ( ec == -3 ) // returned if ssl setup returns NETSSL_RESULT_FAILED_TO_SET_SERVER_CERT_FILE + { + // ignore this error, ssl client won't work + // but we don't want game to fail just b/c the server cert is missing + } + else + { + return -9; + } + } + + gClientSessions[i].state.state = SSL_CLIENT_STATE_AVAILABLE; + gClientSessions[i].query.query_data = NULL; + } + + + // start DBQueryThread + tsi.Arg = 0; + tsi.Func = DBQueryThread; + ec = StartThread( &gDBQueryThreadHandle, &tsi ); + if (ec != THREAD_RESULT_SUCCESS ) + return -5; + + return 0; +} + +// use to change the server port after Init +// new server will be used for next new connection +void DBQuerySystemSetServer( char *ServerIP, int ServerPort ) +{ + int i; + if ( ServerPort < 0 || ServerIP == NULL ) + return; + for ( i = 0; i < DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; i++ ) + { + SetSSLClientStateStructServer( &gClientSessions[i].state, ServerIP, ServerPort ); + } +} + + +// resets backoff timer and makes available any client in backoff state +int ResetClientBackoffTimeouts(int persist) +{ + int i,s,e; + // int t; + // int wait; + // t= time(NULL); + + if ( DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS > 1 ) + { + // check either persistent or non-persistent client sessions + if ( persist == 1 ) + { + // only one persitent message queue + s = 0; + e = 1; + } + else + { + // non-persistent messages use any session starting with session 1 + s = 1; + e = DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; + } + } + else + { + // only have one session + s = 0; + e = 1; + } + + + for ( i = s; i < e; i++ ) + { + if ( gClientSessions[i].state.state == SSL_CLIENT_STATE_BACKOFF ) + { + // time we'll have to wait is client's back time minus + // how long it's already waited + gClientSessions[i].state.backoff_timeout = 0; + gClientSessions[i].state.state = SSL_CLIENT_STATE_AVAILABLE; + } + } + + return 0; +} + + +// counts how long it will be before the next client session becomes free +int FindWaitBeforeNextAvailableClientSession(int persist) +{ + int i,s,e; + int t,next; + int wait; + t= time(NULL); + + if ( DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS > 1 ) + { + + // check either persistent or non-persistent client sessions + if ( persist == 1 ) + { + // only one persitent message queue + s = 0; + e = 1; + } + else + { + // non-persistent messages use any session starting with session 1 + s = 1; + e = DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; + } + } + else + { + // only have one session + s = 0; + e = 1; + } + + // worst case scenario is that no client will be available for + // DBQUERY_MAX_BACKOFF_TIMEOUT seconds + next = DBQUERY_MAX_BACKOFF_TIMEOUT; + + for ( i = s; i < e; i++ ) + { + if ( gClientSessions[i].state.state == SSL_CLIENT_STATE_BACKOFF ) + { + // time we'll have to wait is client's back time minus + // how long it's already waited + wait = gClientSessions[i].state.backoff_timeout - (t-gClientSessions[i].state.curr_state_start); + if ( wait < next ) + next = wait; + } + else + { + // if client is in any other state, assume it will be free shortly + wait = 0; + break; + } + } + + return wait; +} + +void ProcessNewDBQueryMsg(Message *msg) +{ + int ec; + int checked_disk_cache; + DBQuery *query; + DBQueryResult *cacheresult,*newresult; + + if ( msg == NULL ) + return; + + if ( msg->type != MESSAGE_TYPE_DB_QUERY ) + { + // how did this get here? + // delete it + prts_debug( "DB Query Thread: found non-DB Query message, deleting it\n" ); + FreeMessage( msg, 1, 1 ); + return; + } + query = (DBQuery*)msg->msg_data; + if ( query == NULL ) + { + // how did this get here? + // delete it + prts_debug( "DB Query Thread: found empty query in DB Query message, deleting it\n" ); + FreeMessage( msg, 1, 1 ); + return; + } + + + // prts_debug( "DB Query Thread: Processing new DB Query msg id = %d\n", msg->id ); + + if ( query->type == DBQUERY_TYPE_PURGE_CACHE ) + { + prts_debug( "DB Query Thread: got a purge cache mesasge, purging cache (msg id = %d)\n", msg->id ); + PurgeDBQueryCache(); + msg->waitstatus = MESSAGE_ANSWERED; + return; + } + + if ( query->type == DBQUERY_TYPE_RESET_BACKEDOFF_CLIENTS ) + { + prts_debug( "DB Query Thread: got a reset backoff mesasge, resetting backoff time (msg id = %d)\n", msg->id ); + // gDBQueryBackOffTime = 0; + // Don't reset the global backoff timer, just + // free any clients that are in a backoff state + // yeah not very well named, what can I say? + ResetClientBackoffTimeouts(1); + ResetClientBackoffTimeouts(0); + msg->waitstatus = MESSAGE_ANSWERED; + return; + } + + // if maxage == -1, then the message is a telling us to + // delete all cache'd responses for the query + // this provides a way for the game to selectively purge the cache + if( query->maxage == -1 ) + { + // remove any mem cache entries + PurgeQueryFromDBQueryResultCache(query); + // remove any disk cache entries + DelAllDBQueryResultCacheFilesForQuery(query); + msg->waitstatus = MESSAGE_ANSWERED; + return; + } + + + // do not answer persitent queries from the cache + // these are queries that MUST reach the server (eg. DB updates) + // do not answer queries from cache if they have a 0 maxage + // (allows game to specify that it does not want a cache answer to a query) + if( msg->persist == 1 || query->maxage == 0 ) + { + msg->waitstatus = MESSAGE_QUEUE; + return; + } + + // check for a 'cache update' message + // signal for this is that the message alread has a reply attached to it + if ( msg->reply_data != NULL ) + { + // put copy of result in cache + newresult = NULL; + ec = CloneDBQueryResult( &newresult, (DBQueryResult *)msg->reply_data, 1, 1 ); + if ( ec < 0 ) + { + prts_debug( "DBQuery Thread: Failed to copy query results on cache update (msd id = %d)\n", msg->id ); + return; // bail + } + + // this func will handle freeing newresult if needed + UpdateDBQueryResultCache( newresult ); + + // mark message as answered (it'll get sent back to the game so MsgLoop can + // mark it answered and notify the game that the cache update was accepted) + // prts_debug( "DBQuery Thread: NEW MESSAGE (id = %d, qtype = %d) CACHE UPDATE added to cache and marked answerwed!\n", msg->id, query->type ); + msg->waitstatus = MESSAGE_ANSWERED; + return; + } + + // create and queue a tenative answer from the cache + // prts_debug( "DB Query Thread: Check Mem Cache DB Query msg id = %d\n", msg->id ); + checked_disk_cache = 0; + cacheresult = SearchDBQueryResultCache( query ); + if( cacheresult == NULL ) + { + // prts_debug( "DB Query Thread: Checking Disk Cache for DB Query msg id = %d\n", msg->id ); + // try using the disk cache + cacheresult = SearchDBQueryResultCacheFiles( query ); + checked_disk_cache = 1; + } + if ( cacheresult != NULL ) // cache hit + { + // prts_debug( "DBQuery Thread: NEW MESSAGE (id = %d) matching result found in cache!\n", msg->id ); + + + // if we got result from the disk, and there is room for it + // then put a copy of it into the in-memory cache + if ( checked_disk_cache == 1 + && + gDBQuerySystemStats.DBQueryMemCacheSize < DBQUERY_MAX_MEM_CACHE_SIZE_NODES + && + gDBQuerySystemStats.DBQueryMemCacheSizeBytes < DBQUERY_MAX_MEM_CACHE_SIZE_BYTES + ) + { + // prts_debug( "Copying query result from disk to mem cache (msd id = %d)\n", msg->id ); + + // put copy of result in cache + newresult = NULL; + ec = CloneDBQueryResult( &newresult, cacheresult, 1, 1 ); + if ( ec < 0 ) + { + prts_debug( "DBQuery Thread: Failed to copy query results on cache update from disk (msd id = %d)\n", msg->id ); + return; // bail + } + + // this func will handle freeing newresult if needed + UpdateDBQueryResultCache( newresult ); + } + + // cacheresult is a copy, so we can just use it + msg->reply_data = cacheresult; + // if cache result is new enough, mark it as answered + // and we are done! + if ( cacheresult->timestamp > time(NULL) - query->maxage ) + { + prts_debug( "DBQuery Thread: NEW MESSAGE (id = %d) answered from cache!\n", msg->id ); + msg->waitstatus = MESSAGE_ANSWERED; + return; + } + } + else // cache miss + { + // prts_debug( "DBQuery Thread: NEW MESSAGE (id = %d) cache miss!\n", msg->id ); + + ec = CreateDBQueryResult( &newresult, query, 1, time(NULL), DBQUERY_RESULT_CACHE_MISS, 0, 0, NULL, 0 ); + if ( ec < 0 ) + { + // failed to create a new result for some reason + // bail and try again next loop + return; + } + msg->reply_data = newresult; + } + + // for either a cache miss or a stale cache entry, + // mark msg answer as tenative and mail loop will send it back to game + msg->waitstatus = MESSAGE_ANSWERED_TENTATIVE; + + // additionally, if another client session will not become available + // before msg expires (are they all stuck in backoff?) + // then go ahead and just mark it as answered + if( msg->persist == 0 + && + FindWaitBeforeNextAvailableClientSession(0) > msg->waittime ) + { + prts_debug( "DBQuery Thread: Preemptively Answering msg (no clients availabe before msg expires) (msg id = %d)\n", msg->id ); + msg->waitstatus = MESSAGE_ANSWERED; + } + + return; +} + + +int UpdateDBQueryMessageDataObj( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *msg; + Message *newmsg; + ObjData *DataObj2; + unsigned int id; + + struct DBQueryUpdateLoopVarStruct *LoopVars; + int t; + int ec; + + + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return 0; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return 0; + + if ( arg == NULL ) + return 0; + + LoopVars = arg; + + t = time(NULL); + // check if message has been waiting too long + // never age out persitent messages + if ( msg->persist != 1 && t > msg->timestamp + msg->waittime ) + { + // if so, just delete it from our list + // ( game won't wait any longer for an answer anyway, so + // at this point it's too late to do anything with it) + // MsgLoop() will handle sending an answer back to game + prts_debug( "DBQuery Thread: Message closed (too old) (id = %d)\n", msg->id ); + // prts_debug( " Unlinking Msg\n" ); + // unlink it from our list + if ( N2PopNode(DataObj) != NUL ) + { + // prts_debug( " Freeing Msg Memory\n" ); + FreeMessage( msg, 1, 1); + // and free the memory for N2 headers + dbquery_apphook_free(DataObj); + } + return 0; + } + +/* + // check msg priority + // we process priority 1 every loop + // priority 2 ever other loop + // priority 3 every 3rd loop + // priority 4 every 4th loop + // etc. etc. + if ( msg->priority <= 0 ) + msg->priority = 1; // 1 is as low as priority goes + // priority does not apply to persitent messages + if ( msg->persist != 1 && LoopVars->loop_number % msg->priority != 0 ) + { + return 0; + } +*/ + + switch( msg->waitstatus ) + { + case MESSAGE_OPEN: + // means message has just come in + ProcessNewDBQueryMsg(msg); + // prts_debug( "DBQuery Thread: NEW MESSAGE (id = %d) (status = %d)\n", msg->id, msg->waitstatus ); +// PrintMessage( msg ); + break; + case MESSAGE_RETRY: // on a message that's being retried, jump straight to queuing it for the client + case MESSAGE_QUEUE: + // these messages just wait around to be queued + // check if another client session will even become available + // before msg expires + if( msg->persist == 0 + && + FindWaitBeforeNextAvailableClientSession(0) > msg->waittime ) + { + // if no client session will even become available (are they all stuck in backoff?) + // then just go ahead and mark the message answered + prts_debug( "DBQuery Thread: Preemptively Answering msg (no clients availabe before msg expires) (msg id = %d)\n", msg->id ); + msg->waitstatus = MESSAGE_ANSWERED; + } + break; + case MESSAGE_QUEUED: + // these messages just wait around to be answered + break; + case MESSAGE_ANSWERED_TENTATIVE: + // either got an err'd result from server + // or answered from stale cache record (or cache miss) + // send back a copy of the message to game, so game + // knows at least what's in the cache as soon as possible + // but then queue for retry + ec = CloneMessage( &newmsg, msg, 1, 1 ); + // prts_debug( "DBQuery Thread Sending tenative answer for msg %d to game\n", msg->id ); + if ( ec == 0 ) + { + ec = ThreadSafeQueuePush( &gDBQueryOutQue, (void *)newmsg ); + if ( ec == TSQ_RESULT_SUCCESS ) + { + // mark message so it will be queued for client next loop + msg->waitstatus = MESSAGE_QUEUE; + } + else + { + // failed to queue copy of msg + // delete copy and try again next loop + FreeMessage( newmsg, 1, 1 ); + } + } + break; + case MESSAGE_ANSWERED: + // try push msg on out queue + ec = ThreadSafeQueuePush( &gDBQueryOutQue, (void *)msg ); + if ( ec == TSQ_RESULT_SUCCESS ) + { + // now that we put message on out queue + // we can unlink it from our list + if ( N2PopNode(DataObj) != NUL ) + { + // and free the memory for N2 headers + // note that this doesn't free the space used by + // the msg (game will take care of that when it finishes with msg) + dbquery_apphook_free(DataObj); + } + } + break; + case MESSAGE_DROP: + // main thread is telling us to drop this message + // we need to check our list for any messages of the same ID + // and drop them + id = msg->id; + while( (DataObj2 = FindDBQueryMessageNodeByID(id)) != NULL ) + { + prts_debug( "DBQuery Thread: Dropping message %d\n", id ); + // free message memory + FreeMessage( (Message*) DataObj2->data, 1, 1 ); + DataObj2->data = NULL; + if ( N2PopNode(DataObj2) != NUL ) + { + // free the memory for N2 headers + dbquery_apphook_free(DataObj2); + } + } + break; + } + + // not safe to operate on DataObj or msg after this point + // (case statements above may have freed these ptrs) + + return 0; +} + + + +int CountDBQueryResultCacheObjBytes( void *count, void *obj ) +{ + int *c; + ObjData *cacheobj = (ObjData *)obj; + DBQueryResult *result; + + if ( count == NULL || cacheobj == NULL + || cacheobj->lnk.type != N2TYPE_OBJ + || cacheobj->lnk.sub != OBJSUB_DATA + || cacheobj->data == NULL ) + return 0; + + c = (int*)count; + result = (DBQueryResult*)cacheobj->data; + + // account for space used by our two static structs + *c += sizeof(ObjData); + *c += sizeof(DBQueryResult); + + // acount for query data + *c += result->query.query_data_size; + + // account for result data + *c += result->result_row_size * result->result_rows; + + return 0; + +} + +int CountDBQueryResultCacheBytes() +{ + int count = 0; + N2Walk(&gDBQueryResultCache, &count, CountDBQueryResultCacheObjBytes ); + return count; +} + + + + +int UnlinkDBQueryResultCacheObjByAge( void *timestamp, void *obj ) +{ + int t; + ObjData *cacheobj = (ObjData *)obj; + DBQueryResult *result; + + if ( timestamp == NULL || cacheobj == NULL + || cacheobj->lnk.type != N2TYPE_OBJ + || cacheobj->lnk.sub != OBJSUB_DATA + || cacheobj->data == NULL ) + return 0; + + t = *(int *)timestamp;; + + result = (DBQueryResult*)cacheobj->data; + + // check if result is older than passed timestamp + if ( result->timestamp > t ) + { + // result is younger! + // don't prune it + return 0; + } + + // Unlink cache entry and free the attached result + if ( N2PopNode(cacheobj) != NULL ) + { + FreeDBQueryResult(result, 1, 1 ); + dbquery_apphook_free(cacheobj); + } + + + return 0; + +} + + +void PruneDBQueryResultMemCache() +{ + int t; + int maxage,div; + ObjData *Obj; + int count; + + // start by pruning cache entries that are more than 56 days old (div=1) + // then if we are still not small enough, + // clear out records that are older than 28 days (div=2) + // then if we are still not small enough, + // clear out records that are older than 14 days + // then if we are still not small enough, + // clear out records that are older than 7 days + // then if we are still not small enough, + // clear out records that are older than 3.5 days + // then if we are still not small enough, + // clear out records that are older than 1.75 days + // then if we are still not small enough, + // clear out records that are older than 0.825 days (div=7) + // if we get this far bail + div = 1; + maxage = (60*60*24)*56; + while( (N2CountDataNodes(&gDBQueryResultCache) > DBQUERY_MAX_MEM_CACHE_SIZE_NODES + || + CountDBQueryResultCacheBytes() > DBQUERY_MAX_MEM_CACHE_SIZE_BYTES) + && div < 8 ) + { + t = time(NULL) - maxage; + prts_debug( "Pruning out cache entries that are older than %d (%d secs ago)\n", t, maxage ); + N2Walk(&gDBQueryResultCache, &t, UnlinkDBQueryResultCacheObjByAge ); + maxage /= 2; + div++; + } + + // if we got this far and we are still too big + // just start deleting records from the begining of the list + count = 0; + while ( (N2CountDataNodes(&gDBQueryResultCache) > DBQUERY_MAX_MEM_CACHE_SIZE_NODES + || + CountDBQueryResultCacheBytes() > DBQUERY_MAX_MEM_CACHE_SIZE_BYTES) + && count < 20 ) // bail no matter what after 20 passes, just so we never get stuck here + { + Obj = (ObjData*)N2PopNode(gDBQueryResultCache.next); + // Unlink cache entry and free the attached result + if ( Obj != NULL ) + { + prts_debug( "Pruning out cache entry from start of list\n", t, maxage ); + FreeDBQueryResult((DBQueryResult*)Obj->data, 1, 1 ); + dbquery_apphook_free(Obj); + } + else + { + // and just to be safe, bail out of loop if we ever fail to pop a node + // otherwise could be stuck forever trying to pop that node + break; + } + count++; + } + + + +} + +// this function deletes the passed file and returns -1 +// which will stop a FsDirWalk +int PruneFirstDBQueryResultCacheFile(char *file, void *data) +{ + if ( file == NULL ) + return 0; + + // too old delete it + prts_debug( "deleting old disk cache file '%s'\n", file ); + unlink(file); + + return -1; +} + +int PruneDBQueryResultCacheFileByAge(char *file, void *data) +{ + int timestamp; + int file_timestamp; + int len; + char *s; + if ( file == NULL || data == NULL ) + return 0; + + // check with game if it is ok to write to disk now + // if not, bail and try again next pass through + if ( gpCheckIfOKToUseDiskFunc != NULL && (! gpCheckIfOKToUseDiskFunc()) ) + return -1; // this will stop the FsDirWalk + + timestamp = *((int*)data); + + + len = strlen(file); + if ( len < 24 || len < 4 + || file[len-4] != '.' + || file[len-3] != 'd' + || file[len-2] != 'a' + || file[len-1] != 't' + ) + return 0; // not a valid cache file (filename not long enough,or not end w/ .dat) + s = &file[len-14]; // move back to timestamp in filename + + file_timestamp = atoi(s); + if ( file_timestamp < timestamp ) + { + // too old delete it + prts_debug( "deleting old disk cache file '%s'\n", file ); + unlink(file); + } + + return 0; +} + +void PruneDBQueryResultDiskCache() +{ + int ec,t; + int maxage,div,count; + + // check with game if it is ok to write to disk now + // if not, bail and try again next pass through + if ( gpCheckIfOKToUseDiskFunc != NULL && (! gpCheckIfOKToUseDiskFunc()) ) + return; + + // start by pruning cache entries that are more than 224 days old (div=1) + // then if we are still not small enough, + // clear out records that are older than 112 days (div=2) + // then if we are still not small enough, + // clear out records that are older than 56 days (div=3) + // then if we are still not small enough, + // clear out records that are older than 28 days + // then if we are still not small enough, + // clear out records that are older than 14 days + // then if we are still not small enough, + // clear out records that are older than 7 days + // then if we are still not small enough, + // clear out records that are older than 3.5 days + // then if we are still not small enough, + // clear out records that are older than 1.75 days + // then if we are still not small enough, + // clear out records that are older than 0.825 days (div=9) + // if we get this far bail + div = 1; + maxage = (60*60*24)*56; + while( FsDirSize(gDBQueryCacheDir, 1) > DBQUERY_MAX_DISK_CACHE_SIZE_BYTES + && div < 10 ) + { + + // check with game if it is ok to write to disk now + // if not, bail and try again next pass through + if ( gpCheckIfOKToUseDiskFunc != NULL && (! gpCheckIfOKToUseDiskFunc()) ) + return; + + t = time(NULL) - maxage; + prts_debug( "Pruning out disk cache entries that are older than %d (%d secs ago)\n", t, maxage ); + ec = FsDirWalk(gDBQueryCacheDir,1,0,PruneDBQueryResultCacheFileByAge, &t ); + if ( ec < 0 ) + return; // if FsDirWalk was interrupted (game said it wasn't ok to write to disk?) then bail + maxage /= 2; + div++; + } + + // if we got this far and we are still too big + // just start deleting records until we get under the required size + count = 0; + while( FsDirSize(gDBQueryCacheDir, 1) > DBQUERY_MAX_DISK_CACHE_SIZE_BYTES + && count < 20 ) // bail no matter what after 20 passes, just so we don't get stuck grinding away in here + { + // check with game if it is ok to write to disk now + // if not, bail and try again next pass through + if ( gpCheckIfOKToUseDiskFunc != NULL && (! gpCheckIfOKToUseDiskFunc()) ) + return; + + // this deletes the first file it finds and then bails w/ return code -1 + ec = FsDirWalk(gDBQueryCacheDir,1,0,PruneFirstDBQueryResultCacheFile, NULL ); + if ( ec >= 0 ) + break; // didn't find anything to delete! (returns -1 if found and deleted a file) + count++; + } + // before we leave, take a pass at cleaning-up the query cache dir structure + // ie deleting empty cache directories + PurgeDBQueryDiskCache(0,1); +} + +int SaveDBQueryResultCacheObj( void *count, void *obj ) +{ + int ec; + ObjData *cacheobj = (ObjData *)obj; + DBQueryResult *result; + + if ( count == NULL || cacheobj == NULL + || cacheobj->lnk.type != N2TYPE_OBJ + || cacheobj->lnk.sub != OBJSUB_DATA + || cacheobj->data == NULL ) + return 0; + + + result = (DBQueryResult*)cacheobj->data; + + // check if result has been saved + if ( result->saved != 0 ) + { + // already been saved, skip this one + return 0; + } + + + // check with game if it is ok to write to disk now + // if not, bail and try again next pass through + if ( gpCheckIfOKToUseDiskFunc != NULL && (! gpCheckIfOKToUseDiskFunc()) ) + { + // prts_debug( "Game says it's not ok to write right now, refusing to save query result cache obj\n" ); + return 0; + } + + // clear out any existing results on disk for this query + // bit heavy handed here, but idea is to keep cache clean + // by only keeping one copy of query answer around + DelAllDBQueryResultCacheFilesForQuery(&result->query); + // save out new result + ec = SaveDBQueryResultCacheFile(result); + if ( ec != DBQUERY_FILE_RESULT_SUCCESS ) + { + // bail, will try again next time through + prts_debug( "Error when saving cache node for dbquery result\n" ); + return 0; + } + + result->saved = 1; + *(int*)count += 1; + + if( *(int*)count >= MAX_DBQUERY_CACHE_SAVES_PER_LOOP ) + { + // prts_debug( "Already saved %d dbquery result cache files this loop, refusing to write more\n", *(int*)count ); + return -1; // signal N2walk to end + } + return 0; + +} + +void WriteOutDBQueryResultCache() +{ + int count; + count = 0; + N2Walk(&gDBQueryResultCache, &count, SaveDBQueryResultCacheObj ); + return; +} + +// send all new results from client here +// and he keeps track of err counts +void UpdateDBQueryErrCounts(DBQueryResult *result, DBQueryClientSession *session ) +{ + int t; + int query_type; + SSLClientStateStruct *state; + + if ( result == NULL || session == NULL ) + return; + + query_type = session->query.type; + + + + state = &session->state; + +/* + int DBClientNoConnectErrs; + int DBClientTransmitErrs; + int DBClientServerErrs; + int DBClientLastSuccessfulServerConnect; + int DBClientLastSuccessfulQuery; +*/ + // use timestamp from result to know + // when contact w/ server took place (or failed) + t = result->timestamp; + // every result represents another connection attempt + gDBQuerySystemStats.DBClientConnectAttemps++; + switch( result->error_code ) + { + case DBQUERY_RESULT_SUCCESS: + //gDBQuerySystemStats.DBClientSuccessfulConnections++; + //gDBQuerySystemStats.DBClientLastSuccessfulServerConnect = t; + + gDBQuerySystemStats.DBClientLastSuccessfulQuery = t; + + // micro timers + gDBQuerySystemStats.DBClientTotalConnectTime += state->connect_time; + gDBQuerySystemStats.DBClientTotalSendTime += state->send_time; + gDBQuerySystemStats.DBClientTotalRecvTime += state->recv_time; + gDBQuerySystemStats.DBClientTotalCloseTime += state->close_time; + gDBQuerySystemStats.DBClientTotalCompleteQueryTime += state->complete_time; + + // compute avgs + if ( gDBQuerySystemStats.DBClientSuccessfulConnections > 0 ) + { + gDBQuerySystemStats.DBClientAvgConnectTime = gDBQuerySystemStats.DBClientTotalConnectTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgSendTime = gDBQuerySystemStats.DBClientTotalSendTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgRecvTime = gDBQuerySystemStats.DBClientTotalRecvTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgCloseTime = gDBQuerySystemStats.DBClientTotalCloseTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgCompleteQueryTime = gDBQuerySystemStats.DBClientTotalCompleteQueryTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + } + // do per type stats + if ( query_type >= 0 ) + { + gDBQuerySystemStats.DBClientSuccessfulConnectionsByType[query_type]++; + gDBQuerySystemStats.DBClientTotalCompleteQueryTimeByType[query_type] += state->complete_time; + if ( gDBQuerySystemStats.DBClientSuccessfulConnectionsByType[query_type] > 0 ) + gDBQuerySystemStats.DBClientAvgCompleteQueryTimeByType[query_type] = gDBQuerySystemStats.DBClientTotalCompleteQueryTimeByType[query_type] / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnectionsByType[query_type]; + + } + + + break; + case DBQUERY_RESULT_SERVER_UNREACHABLE: + gDBQuerySystemStats.DBClientLastFailedServerConnect = t; + gDBQuerySystemStats.DBClientNoConnectErrs++; + break; + case DBQUERY_RESULT_TRANSMIT_ERR: + // gDBQuerySystemStats.DBClientLastSuccessfulServerConnect = t; + gDBQuerySystemStats.DBClientLastFailedQuery = t; + gDBQuerySystemStats.DBClientTransmitErrs++; + break; + case DBQUERY_RESULT_SERVER_RETURNED_ERR: + case DBQUERY_RESULT_SERVER_COULD_NOT_CONTACT_DATABASE: + case DBQUERY_RESULT_ERROR_PARSING_RESULTS: +// gDBQuerySystemStats.DBClientSuccessfulConnections++; +// gDBQuerySystemStats.DBClientLastSuccessfulServerConnect = t; + gDBQuerySystemStats.DBClientLastFailedQuery = t; + gDBQuerySystemStats.DBClientServerErrs++; + + // micro timers + gDBQuerySystemStats.DBClientTotalConnectTime += state->connect_time; + gDBQuerySystemStats.DBClientTotalSendTime += state->send_time; + gDBQuerySystemStats.DBClientTotalRecvTime += state->recv_time; + gDBQuerySystemStats.DBClientTotalCloseTime += state->close_time; + gDBQuerySystemStats.DBClientTotalCompleteQueryTime += state->complete_time; + + // compute avgs + gDBQuerySystemStats.DBClientAvgConnectTime = gDBQuerySystemStats.DBClientTotalConnectTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgSendTime = gDBQuerySystemStats.DBClientTotalSendTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgRecvTime = gDBQuerySystemStats.DBClientTotalRecvTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgCloseTime = gDBQuerySystemStats.DBClientTotalCloseTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + gDBQuerySystemStats.DBClientAvgCompleteQueryTime = gDBQuerySystemStats.DBClientTotalCompleteQueryTime / (uns64)gDBQuerySystemStats.DBClientSuccessfulConnections; + + break; + } + +} + + + + + + + +int AssignMessageToClientSession(Message *msg,int session_num) +{ + int ec; + DBQuery *query; + SSLClientStateStruct *session = NULL; + + char *recv_buf; + char *send_buf; + int send_buf_size; + int len; + + if (msg == NULL || msg->msg_data == NULL || + session_num < 0 || session_num >= DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS ) + return -1; + + session = &gClientSessions[session_num].state; + + query = &gClientSessions[session_num].query; + + recv_buf = gClientSessions[session_num].recv_buf; + + + // client session gets it's own copy of the DBQuery + // it's trying to answer, that way the client session can + // still continue even if the message that spawned it disappears + // (that way we don't have to kill an active client session when a message expires) + ec = CopyDBQuery( (DBQuery *)msg->msg_data, query, 1 ); + if ( ec < 0 ) // failed to malloc space for query data :( + return -3; + + // prepare send buffer (ie convert out query to plain text so the DB understands it) + send_buf = gClientSessions[session_num].send_buf; + send_buf_size = sizeof(gClientSessions[session_num].send_buf); + + switch(query->type) + { + case DBQUERY_TYPE_PLAIN_TEXT: + strncpy(send_buf,(char*)query->query_data,send_buf_size); + break; + default: + // sprintf(send_buf, "%ud\ncall ",gDBQueryClientID ); + sprintf(send_buf, "call " ); + len = strlen(send_buf); + strncat(send_buf,DBQueryTypeInfo[query->type].name,send_buf_size-len-1); // leave space at end for closing paren); + strcat( send_buf, "(" ); + len = strlen(send_buf); + UnParseStruct(DBQueryTypeInfo[query->type].query_struct_type,query->query_data,&send_buf[len],send_buf_size-len-1); // leave space at end for closing paren + // strcat( send_buf, ")" ); + strcat( send_buf, ");\n" ); + prts_debug( "SEND BUFFER = %s\n", send_buf ); + break; + } + + ResetSSLClientStateStruct(session); + ResetSSLClientStateStructRecvBuf(session); + SetSSLClientStateStructSendBuf(session,send_buf, strlen(send_buf)); // do not send null terminator + SetSSLClientStateStructTimeOuts( session, DBQUERY_WAIT_CONNECT_TIMEOUT, + DBQUERY_SEND_TIMEOUT, + DBQUERY_RECV_TIMEOUT, + gDBQueryBackOffTime ); + if( session->connected) + session->state = SSL_CLIENT_STATE_SEND_DATA; + else + session->state = SSL_CLIENT_STATE_OPEN_CONNECTION; + + + gClientSessions[session_num].MsgID = msg->id; + + prts_debug( "Assigned msg %d to client session %d\n", msg->id, session_num); + + return 0; +} + + + + + +// obj is ptr to DataObj (item on DBQueryMessageList) +// arg is ptr to ptr to msg +// checks obj and arg to see if +// arg should be pointed at msg attached to obj +// used by FindNextMessageByPriorityAndID +int MatchMessageOnPriorityAndID( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *objmsg; + Message **ppmsg; + + if ( arg == NULL || DataObj == NULL + || DataObj->lnk.type != N2TYPE_OBJ + || DataObj->lnk.sub != OBJSUB_DATA + || DataObj->data == NULL ) + return -1; + + ppmsg = (Message **)arg; + + objmsg = (Message *)DataObj->data; + + // skip persitent messages, and messages that have been answered or queued already + if ( objmsg->persist == 1 || objmsg->waitstatus == MESSAGE_ANSWERED + || objmsg->waitstatus == MESSAGE_ANSWERED_TENTATIVE + || objmsg->waitstatus == MESSAGE_QUEUED ) + return 0; + + // take first msg we find, + // after that take the one with the lowest priority number + // after that take the on with the lowest id number + if( *ppmsg == NULL || (*ppmsg)->priority > objmsg->priority || (*ppmsg)->id > objmsg->id ) + *ppmsg = objmsg; + return 0; +} + +// walks through message list searching for the (non-persitent) message +// with the the lowest priority and lowest id number and points passed ptr to the message, +// or NULL if no suitable messages are found +void FindNextMessageByPriorityAndID(Message **ppmsg) +{ + if ( ppmsg == NULL ) + return; + N2Walk(&gDBQueryMessageList, ppmsg, MatchMessageOnPriorityAndID ); +} + + +// obj is ptr to DataObj (item on DBQueryMessageList) +// arg is ptr to ptr to msg +// checks obj and arg to see if +// arg should be pointed at msg attached to obj +// used by FindNextPersistentMessage +int MatchNextPersistentMessage( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *objmsg; + Message **ppmsg; + + if ( arg == NULL || DataObj == NULL + || DataObj->lnk.type != N2TYPE_OBJ + || DataObj->lnk.sub != OBJSUB_DATA + || DataObj->data == NULL ) + return 0; + + ppmsg = (Message **)arg; + + objmsg = (Message *)DataObj->data; + + // skip non-persitent messages and persitent messages that have been answered already + if ( objmsg->persist != 1 || objmsg->waitstatus == MESSAGE_ANSWERED ) + return 0; + + // here's another bogus trick, for persistent messages we overload the waittime + // with the time that we should next try the message + // this allows us to backoff on trying 'errored' persistent messages + // w/o backing off on all queries + if ( time(NULL) < objmsg->waittime ) + return 0; + + // take first msg we find, + // after that take the one with the lowest priority number + // after that take the on with the lowest id number + if( *ppmsg == NULL || (*ppmsg)->priority > objmsg->priority || (*ppmsg)->id > objmsg->id ) + *ppmsg = objmsg; + + return 0; +} + +// walks through message list searching for the persistent message +// with the lowest id number, points passed ptr to the message, or NULL if +// no persitent messages are found +void FindNextPersistentMessage(Message **ppmsg) +{ + if ( ppmsg == NULL ) + return; + N2Walk(&gDBQueryMessageList, ppmsg, MatchNextPersistentMessage ); +} + + + +void AssignMessagesToClientSessions() +{ + int i; + int ec; + SSLClientStateStruct *session = NULL; + Message *msg = NULL; + static unsigned int count = 0; + Message *pmsg = NULL; + Message *npmsg = NULL; + + // if we have more than one client session + // then we dedicate one to persistent queries + // and the rest to non-persistents + if ( DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS > 1 ) + { + + // do persitent messages first + // handle them seperately b/c + // we want them to always process in linear order by msgid + // (this b/c certain database updates are order dependent) + // persitent messages can only use session 0 + session = &gClientSessions[0].state; + if ( session->state == SSL_CLIENT_STATE_AVAILABLE ) + { + msg = NULL; + FindNextPersistentMessage(&msg); + if ( msg != NULL ) + { + ec = AssignMessageToClientSession( msg, 0 ); + if ( ec == 0 ) + msg->waitstatus = MESSAGE_QUEUED; + } + } + + // non-persistent messages use any session starting with session 1 + for ( i = 1; i < DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; i++ ) + { + if ( gClientSessions[i].state.state == SSL_CLIENT_STATE_AVAILABLE ) + { + msg = NULL; + FindNextMessageByPriorityAndID(&msg); + if ( msg == NULL ) + break; // no suitable messages found! (don't even bother looking at rest of client sessions) + ec = AssignMessageToClientSession( msg, i ); + if ( ec == 0 ) + msg->waitstatus = MESSAGE_QUEUED; + } + } + } + else + { + // if only one client session, then + // we alternate between feeding it + // persistent and non-persistent messages + session = &gClientSessions[0].state; + if ( session->state == SSL_CLIENT_STATE_AVAILABLE ) + { + msg = NULL; + pmsg = NULL; + npmsg = NULL; + FindNextPersistentMessage(&pmsg); + FindNextMessageByPriorityAndID(&npmsg); + if ( pmsg != NULL || npmsg != NULL ) + { + count++; + if ( pmsg != NULL && ((count%2==0) || npmsg == NULL)) + msg = pmsg; + else + msg = npmsg; + ec = AssignMessageToClientSession( msg, 0 ); + if ( ec == 0 ) + msg->waitstatus = MESSAGE_QUEUED; + } + } + } + +} + + + +// returns 1 if string found, 0 if not found +int CheckForOldServerErrorString(char *str) +{ + char *c; + if ( strncmp( str, DBSERVER_OLD_ERROR_STRING,strlen(DBSERVER_OLD_ERROR_STRING))!=0 ) + return 0; + + if ( strstr( str, ":" ) == NULL ) + return 0; + + // format we are looking for is ERROR 1503: blah blah + // trick is we don't know how many digits in the number + c = str; + c += strlen(DBSERVER_OLD_ERROR_STRING); // skip past 'ERROR ' + + // walk until we hit a ':' or a non-numeric + while( *c != ':' ) + { + if ( *c < '0' || *c > '9' ) + return 0; // non-numeric means some other format + c++; + } + + + return 1; +} + +void ProcessClientSessionResults(int session_num) +{ + int ec; + int error; + SSLClientStateStruct *session = NULL; + DBQuery *query; + DBQueryResult *result; + Message *msg; + int struct_type; + int rows; + int row_size; + void *result_data; + int free_result_data = 0; + + if ( session_num < 0 || session_num >= DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS ) + return; + + session = &gClientSessions[session_num].state; + query = &gClientSessions[session_num].query; + + + if ( session->state != SSL_CLIENT_STATE_DONE || query == NULL ) + return; + + + + result = NULL; + result_data = NULL; + + prts_debug( "Recv Buff = '%s'\n", session->recv_buf ); + + // check for error with client session, or an error result from database + if ( session->error_code == SSL_CLIENT_ERR_NONE + && strncmp( session->recv_buf,DBSERVER_ERROR_STRING , strlen(DBSERVER_ERROR_STRING)) != 0 + && strncmp( session->recv_buf, DBSERVER_ERROR_CANT_CONTACT_DBASE,strlen(DBSERVER_ERROR_CANT_CONTACT_DBASE))!=0 + && CheckForOldServerErrorString(session->recv_buf) == 0 + ) + { + error = DBQUERY_RESULT_SUCCESS; + // parse database results + switch(query->type) + { + case DBQUERY_TYPE_PLAIN_TEXT: + // for plain text queries, we just pass recv buffer straight on + rows = 1; + row_size = session->recv_count + 1; // extra spot for the '\0' char + result_data = session->recv_buf; + free_result_data = 0; + break; + default: + // for messages w/ a struct form, use tokenizer to load DB response + // into struct of the correct form + struct_type = DBQueryTypeInfo[query->type].result_struct_type; + row_size = StructForms[struct_type][0]; + rows = query->max_result_rows; + result_data = NULL; + + prts_debug( "DBQueryParsing Result Data Into Struct\n"); + + // on success Pasrse Struch returns the number of rows actually parsed + rows = ParseStruct( struct_type, rows, &result_data, session->recv_buf ); + if ( rows < 0 ) + { + rows = 0; + error = DBQUERY_RESULT_ERROR_PARSING_RESULTS; + prts_debug( "DBQuery Error Parsing Result Data Into Struct (qtype = %d, stype = %d)\n", query->type, struct_type ); + result_data = NULL; + } + else + free_result_data = 1; // make a note that we need to free this data on exit + + break; + } + + prts_debug( "DB Client: Got succesful result for query\n" ); + // create our query result + ec = CreateDBQueryResult( &result, query, 1, + time(NULL), + error, + row_size, + rows, + result_data, + 1 ); + if (ec<0) + { + prts_debug( "DB Client: Failed to create dbquery result\n" ); + result = NULL; + } + } + else + { + switch(session->error_code) + { + case SSL_CLIENT_ERR_NONE: + // if there was no err w/ client session, means the server + // returned an error with query + // check if the error was that we could not contact the database + if ( strncmp( session->recv_buf, DBSERVER_ERROR_CANT_CONTACT_DBASE,strlen(DBSERVER_ERROR_CANT_CONTACT_DBASE))==0) + error = DBQUERY_RESULT_SERVER_COULD_NOT_CONTACT_DATABASE; + else + error = DBQUERY_RESULT_SERVER_RETURNED_ERR; + break; + case SSL_CLIENT_ERR_CONNECT_FAILED: + case SSL_CLIENT_ERR_CONNECT_TIMEDOUT: + error = DBQUERY_RESULT_SERVER_UNREACHABLE; + break; + default: + error = DBQUERY_RESULT_TRANSMIT_ERR; + } + + ec = CreateDBQueryResult( &result, query, 1, + time(NULL), + error, + 0, + 0, + NULL, + 0 ); + if (ec<0) + { + prts_debug( "DB Client: Failed to create dbquery result\n" ); + result = NULL; + } + + } + + + if ( result != NULL ) + { + // update accounting stats + UpdateDBQueryErrCounts(result, &gClientSessions[session_num]); + + // got a new query result from client, + // time to pair it with an outstanding message + if ( session_num == 0 ) // session 0 reserved for persistent queries only + { + // only match persistent queries to the message that originated them + msg = FindDBQueryMessageByID(gClientSessions[session_num].MsgID); + if ( msg != NULL ) + AttachResultToMessage(result,msg); + + } + else + { + // for normal queries go see if it + // matches /any/ of our outstanding messages + // (note that we intentionally check against all outstanding msgs + // and not just the msg associated w/ this client session) + N2Walk(&gDBQueryMessageList, (void*)result, MatchDBQueryResult ); + } + // put copy of result in cache (this will handle freeing result if needed) + UpdateDBQueryResultCache( result ); + } + + + // free space used by query data and null out pointer to it + if ( query->query_data != NULL ) + { + // prts_debug( "DB Client: freeing query data for client session %d\n", session_num ); + dbquery_apphook_free(query->query_data); + query->query_data = NULL; + } + + // if we malloc'd for space to store parsed result data, then be sure to + // free that memory now + if ( result_data != NULL && free_result_data == 1 ) + dbquery_apphook_free(result_data); + + + // update stats + // if connect failed then we send no data (expect TCP syn packets) + if ( session->error_code != SSL_CLIENT_ERR_CONNECT_FAILED + && session->error_code != SSL_CLIENT_ERR_CONNECT_TIMEDOUT ) + { + gDBQuerySystemStats.DBClientTotalBytesSent += session->send_buf_size; + gDBQuerySystemStats.DBClientTotalBytesRecieved += session->recv_count; + + if ( query != NULL ) + { + gDBQuerySystemStats.DBClientBytesSentByType[query->type] += session->send_buf_size; + gDBQuerySystemStats.DBClientBytesRecievedByType[query->type] += session->recv_count; + } + } + + + // mark session as ready for a new msg or tell it to back off on an err + if ( session->error_code == SSL_CLIENT_ERR_NONE + && + error != DBQUERY_RESULT_SERVER_COULD_NOT_CONTACT_DATABASE +// && +// error != DBQUERY_RESULT_SERVER_RETURNED_ERR +// && +// error != DBQUERY_RESULT_ERROR_PARSING_RESULTS + ) + { + session->state = SSL_CLIENT_STATE_AVAILABLE; + // reset backoff timer on success connection + gDBQueryBackOffTime = DBQUERY_BASE_BACKOFF_TIMEOUT; + gClientSessions[session_num].expirey_time = time(NULL) + DBQUERY_CONNECTION_PERSIST_TIME; + } + else + { + prts_debug( "DB Client: instructing client session %d to back off %d secs before trying a new connection\n", session_num, gDBQueryBackOffTime ); + session->state = SSL_CLIENT_STATE_BACKOFF; + // adv back off timer (this will take effect for next session we open) + gDBQueryBackOffTime *= 2; + if ( gDBQueryBackOffTime > DBQUERY_MAX_BACKOFF_TIMEOUT ) + gDBQueryBackOffTime = DBQUERY_MAX_BACKOFF_TIMEOUT; + } + // also reset sesion's timer values + session->start_time = 0; + session->curr_state_start = 0; + + +} + +// returns count of active client sessions +int UpdateClientSessions() +{ + int i; + int count = 0; + int t = time(NULL); + int was_connected; + + gDBQuerySystemStats.DBClientConnectionsOpen = 0; + + for ( i = 0; i < DBQUERY_MAX_ACTIVE_CLIENT_SESSIONS; i++ ) + { + was_connected = gClientSessions[i].state.connected; + + UpdateSSLClientState(&gClientSessions[i].state); + // check for completed client session + if ( gClientSessions[i].state.state == SSL_CLIENT_STATE_DONE ) + { + prts_debug( "DB Query Thread: got new result from client session %d\n", i ); + ProcessClientSessionResults(i); + } + + if ( gClientSessions[i].state.state == SSL_CLIENT_STATE_AVAILABLE + && + gClientSessions[i].state.connected ) + { + if ( gClientSessions[i].expirey_time < t ) + { + CloseSSLClientConnection(&gClientSessions[i].state); + // gClientSessions[i].state.state = SSL_CLIENT_STATE_CLOSE_CONNECTION; + // UpdateSSLClientState(&gClientSessions[i].state); + gClientSessions[i].state.state = SSL_CLIENT_STATE_AVAILABLE; + } + else + { + // if we are connected, verify that we still are + if ( gClientSessions[i].state.nsh.connected ) + { + int ec; + char buf; + int b = 1; + // try to read something + // we don't expect to be able to read anything right now + // we just want to see if the connection has been closed + ec = NetSSLRecvFromClientSession( &(gClientSessions[i].state.nsh), &buf, &b ); + if ( ec == NETSSL_RESULT_CONNECTION_CLOSED ) + { + gClientSessions[i].state.state = SSL_CLIENT_STATE_CLOSE_CONNECTION; + UpdateSSLClientState(&(gClientSessions[i].state)); + gClientSessions[i].state.state = SSL_CLIENT_STATE_AVAILABLE; + } + } + + // update again just to see if we are still connected + UpdateSSLClientState(&gClientSessions[i].state); + } + } + + if ( gClientSessions[i].state.connected ) + gDBQuerySystemStats.DBClientConnectionsOpen++; + + if ( (!was_connected) && gClientSessions[i].state.connected ) + { + gDBQuerySystemStats.DBClientConnectionsOpened++; + gDBQuerySystemStats.DBClientSuccessfulConnections++; + gDBQuerySystemStats.DBClientLastSuccessfulServerConnect = time(NULL); + } + + if ( was_connected && (!gClientSessions[i].state.connected) ) + gDBQuerySystemStats.DBClientConnectionsClosed++; + + if ( gClientSessions[i].state.state != SSL_CLIENT_STATE_AVAILABLE ) + { + count++; + } + } + + return count; +} + + +void DBQueryThread( int arg ) +{ + Message *msg; + + struct DBQueryUpdateLoopVarStruct DBQueryUpdateLoopVars; + + + DBQueryUpdateLoopVars.loop_number = 0; + DBQueryUpdateLoopVars.new_msgs_from_game_this_loop = 0; + + while( 1 ) + { + DBQueryUpdateLoopVars.new_msgs_from_game_this_loop = 0; + + // check for new messages from game + while( ThreadSafeQueuePop( &gDBQueryInQue, (void**)&msg ) == TSQ_RESULT_SUCCESS ) + { + // prts_debug( "DB Query Thread got new DB Query msg id = %d\n", msg->id ); + // got a new message, add it to our list + if ( N2AddDataNode( &gDBQueryMessageList, dbquery_apphook_malloc, msg, 0 ) != 0 ) + { + prts_debug( "DB Query Thread failed to add new DB Query msg\n" ); + // if failed to add it to the list + // then free the memory it is using (nothing else we can do :( + FreeMessage( msg, 1, 1 ); + } + DBQueryUpdateLoopVars.new_msgs_from_game_this_loop++; + // only take so many new messages from game per loop + // this keeps us from getting stuck + // servicing the new message queue all day! + if ( DBQueryUpdateLoopVars.new_msgs_from_game_this_loop >= DBQUERY_MAX_NEW_MSGS_FROM_GAME_PER_LOOP ) + { + // prts_debug( "DBQuery Thread: processed %d messages from game this loop already, refusing to process more\n", DBQueryUpdateLoopVars.new_msgs_from_game_this_loop ); + break; + } + + } + + // done checking for new messages + // walk message list and do stuff + N2Walk( &gDBQueryMessageList, &DBQueryUpdateLoopVars, UpdateDBQueryMessageDataObj ); + + + // look for free client sessions and assign messages to them + // in order by priority and msg id + AssignMessagesToClientSessions(); + + // update our client sessions + gDBQuerySystemStats.ActiveDBClientSessions = UpdateClientSessions(); + + // write cache to disk every 6 secs + if ( DBQueryUpdateLoopVars.loop_number % (6*1000/DBQUERY_LOOP_SLEEP_TIME) == 0 ) + WriteOutDBQueryResultCache(); + + // have a go at pruning the in memory cache every 10 secs + if( DBQueryUpdateLoopVars.loop_number % (10*1000/DBQUERY_LOOP_SLEEP_TIME) == 0 ) + PruneDBQueryResultMemCache(); + + // count = 0; + // prts_debug( "DB Query Thread Message List:\n" ); + // N2Walk( &DBQueryMessageList, &count, PrintMessageDataObj ); + + // make a note of current backoff time + gDBQuerySystemStats.DBQueryBackOffTime = gDBQueryBackOffTime; + + gDBQuerySystemStats.DBQueryNextFreeClient = FindWaitBeforeNextAvailableClientSession(0); + gDBQuerySystemStats.DBQueryNextFreePersistentClient = FindWaitBeforeNextAvailableClientSession(1); + + gDBQuerySystemStats.DBQueryMemCacheSize = N2CountDataNodes(&gDBQueryResultCache); + gDBQuerySystemStats.DBQueryMemCacheSizeBytes = CountDBQueryResultCacheBytes(); + + // every minute, check how big the disk cache has gotten + if ( DBQueryUpdateLoopVars.loop_number % (60*1000/DBQUERY_LOOP_SLEEP_TIME) == 0 ) + { + gDBQuerySystemStats.DBQueryDiskCacheSize = FsDirWalk(gDBQueryCacheDir,1,0, NULL, NULL); + gDBQuerySystemStats.DBQueryDiskCacheSizeBytes = FsDirSize(gDBQueryCacheDir,1); + PruneDBQueryResultDiskCache(); + } + // every 5 mins, save out our query stats + if ( DBQueryUpdateLoopVars.loop_number % (5*60*1000/DBQUERY_LOOP_SLEEP_TIME) == 0 ) + { + SaveDataWithCRC( &gDBQuerySystemStats,sizeof(gDBQuerySystemStats), gDBQueryStatsAuditFile); + } + + + DBQueryUpdateLoopVars.loop_number++; + ThreadSleep(DBQUERY_LOOP_SLEEP_TIME); + } +} + + +void DoDBQueryOrphanCallback(Message *msg) +{ + DBQuery *query; + int i; + if ( msg == NULL ) + return; + query = msg->msg_data; + if( query == NULL ) + return; + + for(i = 0; i < gNumDBQueryOrphanCallbacks; i++ ) + { + if ( DBQueryOrphanCallbacks[i].type == query->type + && DBQueryOrphanCallbacks[i].callback != NULL ) + { + // execute callback + DBQueryOrphanCallbacks[i].callback(msg); + return; + } + } + +} + diff --git a/libraries/pmrt/pmrt_messages/dbquery.h b/libraries/pmrt/pmrt_messages/dbquery.h new file mode 100755 index 0000000..dfc470f --- /dev/null +++ b/libraries/pmrt/pmrt_messages/dbquery.h @@ -0,0 +1,296 @@ +// dbquery.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef DBQUERY_H +#define DBQUERY_H + +#include "messages.h" + +//#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +//#include "node.h" +//#endif + +#include +#include + + + + +#include + + +#define MAX_NUM_DBQUERY_TYPES 512 +#define MAX_DBQUERY_ORPHAN_CALLBACKS MAX_NUM_DBQUERY_TYPES + +#define DBQUERY_WAIT_CONNECT_TIMEOUT 10 +#define DBQUERY_SEND_TIMEOUT 10 +#define DBQUERY_RECV_TIMEOUT 30 // DB queries can take some time to execute +#define DBQUERY_BASE_BACKOFF_TIMEOUT 2 +#define DBQUERY_MAX_BACKOFF_TIMEOUT 128 // don't ever back off for more than 2 minutes + +#define DBQUERY_DISABLE_PERSISTENT_CONNECTIONS 0 +#define DBQUERY_CONNECTION_PERSIST_TIME 900 // how long to hold connections open while waiting for new queries to queue + +// Enumerate basic dbquery types here +// should match DBQueryTypeInfo defined in dbquery.c +// use AddNewDBQueryTypes() to add additional query types form game code +enum +{ + DBQUERY_TYPE_PLAIN_TEXT = 0, +// administrative queries (not actual queries, instead instruct DBQuery Thread to do something) + DBQUERY_TYPE_PURGE_CACHE, + DBQUERY_TYPE_RESET_BACKEDOFF_CLIENTS, + NUM_BASE_DBQUERY_TYPES, +}; + + +// used by open/load routines +#define CRYPTO_IV_LEN 16 + + + +typedef struct DBQueryTypeInfoStruct +{ + int query_type; + int query_struct_type; + int result_struct_type; + char name[256]; + +} DBQueryTypeInfoStruct; + +extern DBQueryTypeInfoStruct DBQueryTypeInfo[MAX_NUM_DBQUERY_TYPES]; + +typedef struct +{ + int type; + void (*callback)(struct Message*); +} DBQueryOrphanCallbackStruct; + +extern DBQueryOrphanCallbackStruct DBQueryOrphanCallbacks[MAX_DBQUERY_ORPHAN_CALLBACKS]; + +enum DBQueryResultErrorCodes +{ + DBQUERY_RESULT_SUCCESS, + DBQUERY_RESULT_CACHE_MISS, + DBQUERY_RESULT_SERVER_UNREACHABLE, + DBQUERY_RESULT_TRANSMIT_ERR, + DBQUERY_RESULT_SERVER_RETURNED_ERR, + DBQUERY_RESULT_SERVER_COULD_NOT_CONTACT_DATABASE, + DBQUERY_RESULT_ERROR_PARSING_RESULTS, +}; + + + +enum DBQueryFileOperationErrorCodes +{ + DBQUERY_FILE_RESULT_SUCCESS, + DBQUERY_FILE_RESULT_INVALID_PARAMS, + DBQUERY_FILE_RESULT_INVALID_FD, + DBQUERY_FILE_RESULT_WRITE_ERR, + DBQUERY_FILE_RESULT_READ_ERR, + DBQUERY_FILE_RESULT_MALLOC_ERR, + DBQUERY_FILE_RESULT_FOPEN_ERR, + DBQUERY_FILE_RESULT_FCLOSE_ERR, + DBQUERY_FILE_RESULT_MKDIR_ERR, + DBQUERY_FILE_RESULT_EOF, +}; + +typedef struct +{ + int type; + int maxage; + int max_result_rows; + int query_data_size; + uns32 query_data_crc; + void *query_data; + +} DBQuery; + +typedef struct +{ + DBQuery query; + int timestamp; + int error_code; + int result_rows; + int result_row_size; + int saved; + uns32 result_data_crc; + void *result_data; + +} DBQueryResult; + + +struct DBQuerySystemStats +{ + int start_timestamp; + int TotalMsgs; + int ActiveMsgs; + int ActiveMsgsByType[NUM_MESSAGE_TYPES]; + int ActivePersistentMsgs; + + int DBQueryInQueueSize; + int DBQueryOutQueueSize; + + int ActiveDBClientSessions; + + // err counts and timestamps + int DBClientConnectAttemps; + int DBClientNoConnectErrs; + int DBClientTransmitErrs; + int DBClientServerErrs; + int DBClientSuccessfulConnections; + int DBClientLastSuccessfulServerConnect; + int DBClientLastFailedServerConnect; + int DBClientLastSuccessfulQuery; + int DBClientLastFailedQuery; + int DBClientSuccessfulConnectionsByType[MAX_NUM_DBQUERY_TYPES]; + + + int DBClientConnectionsOpen; + int DBClientConnectionsOpened; + int DBClientConnectionsClosed; + + + // backoff stats + int DBQueryBackOffTime; + int DBQueryNextFreeClient; + int DBQueryNextFreePersistentClient; + + // byte counters + // (note these are raw bytes sent/recvd before SSL and/or encryption) + unsigned int DBClientTotalBytesSent; + unsigned int DBClientTotalBytesRecieved; + + unsigned int DBClientBytesSentByType[MAX_NUM_DBQUERY_TYPES]; + unsigned int DBClientBytesRecievedByType[MAX_NUM_DBQUERY_TYPES]; + + // cache stats + int DBQueryMemCacheSize; + int DBQueryMemCacheSizeBytes; + + int DBQueryDiskCacheSize; + int DBQueryDiskCacheSizeBytes; + + int DBQueryMemCacheHits; + int DBQueryDiskCacheHits; + + // microsecond timers + uns64 DBClientTotalConnectTime; + uns64 DBClientTotalSendTime; + uns64 DBClientTotalRecvTime; + uns64 DBClientTotalCloseTime; + uns64 DBClientTotalCompleteQueryTime; + + uns64 DBClientAvgConnectTime; + uns64 DBClientAvgSendTime; + uns64 DBClientAvgRecvTime; + uns64 DBClientAvgCloseTime; + uns64 DBClientAvgCompleteQueryTime; + + uns64 DBClientTotalCompleteQueryTimeByType[MAX_NUM_DBQUERY_TYPES]; + uns64 DBClientAvgCompleteQueryTimeByType[MAX_NUM_DBQUERY_TYPES]; + + // general stat tracking + // note these are all tracked on a 'by type' so the two + // queries of the same type but w/ different inputs are treated + // the same as far as these stats are concerned + // also as a note, all these stats are actually tracked in messages.c + // that's b/c only the message loop really knows what the final + // answer passed to the game is (dbquery only knows what it tried to send) + // but keep in mind, messages.c runs in a different thread than + // dbquery.c, so should never edit these fields in dbqeury.c + int DBQueryCountByType[MAX_NUM_DBQUERY_TYPES]; // raw count of queries answered + int DBQueryResultTimestampsByType[MAX_NUM_DBQUERY_TYPES]; // timestamp on must recent result given to game + int DBQueryTotalAgeTimesByType[MAX_NUM_DBQUERY_TYPES]; // // sum of age of results for each query answered + int DBQueryAvgAgeTimesByType[MAX_NUM_DBQUERY_TYPES]; // QueryTotalAgeTimes / QueryCounts; +}; + +struct DBQuerySystemStats gDBQuerySystemStats; + +char gDBQueryPublicCert[2048]; // text copy of public cert, good for displaying the public key + + + +void FreeDBQuery( DBQuery *query, int free_query_data ); +void FreeDBQueryResult( DBQueryResult *result, int free_query_data, int free_result_data ); + + +int CreateDBQuery( DBQuery **ppQuery, int type, int maxage, int max_result_rows, int query_data_size, void *query_data, int copy_query_data ); +int CloneDBQuery( DBQuery **ppDst, DBQuery *Src, int copy_query_data ); +int CopyDBQuery( DBQuery *src, DBQuery *dst, int copy_query_data ); +int CreateDBQueryResult( DBQueryResult **ppQueryResult, DBQuery *Query, int copy_query_data, int timestamp, int error_code, int result_row_size, int result_rows, void *result_data, int copy_result_data ); +int CloneDBQueryResult(DBQueryResult **ppDst, DBQueryResult *Src, int copy_query_data, int copy_result_data ); + + +DBQueryResult *SearchDBQueryResultCache( DBQuery *query ); +DBQueryResult *SearchDBQueryResultCacheFiles( DBQuery *query ); + +int DBQueryCompare( DBQuery *q1, DBQuery *q2 ); + + +void PrintDBQuery( DBQuery *query, char *lead ); +void PrintDBQueryResult( DBQueryResult *result, char *lead ); + +int WriteDBQueryToFile( FILE *fd, DBQuery *query ); +int WriteDBQueryResultToFile( FILE *fd, DBQueryResult *result ); +int LoadDBQueryFromFile( FILE *fd, DBQuery *query ); +int LoadDBQueryResultFromFile( FILE *fd, DBQueryResult *result ); + +int SaveDBQuery( char *filename, DBQuery *query ); +int LoadDBQuery( char *filename, DBQuery *query ); +int GenerateFileIV( char *filename, unsigned char *iv, int iv_len ); + +int SaveDBQueryResult( char *filename, DBQueryResult *result ); +int LoadDBQueryResult( char *filename, DBQueryResult *result ); + + +int DBQuerySystemInit(char *CacheDir, char *AuditsDir, + char *ServerIP, int ServerPort, char *ServerCertFile, + int (*pCheckIfOKToUseDiskFunc)(), + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize ); + +void DBQuerySystemSetServer( char *ServerIP, int ServerPort ); + +void DBQueryThread( int arg ); + +int AddNewDBQueryTypes(int count, DBQueryTypeInfoStruct *NewQueryTypeInfo); +int AddNewDBQueryOrphanCallbacks( int count, DBQueryOrphanCallbackStruct *NewOrphanCallbacks ); + +void DoDBQueryOrphanCallback(Message *msg); + + +int AssignMessageToClientSession(Message *msg,int session_num); +void ProcessClientSessionResults(int session_num); +int UpdateClientSessions(); + +// write passed data to passed file handle +// appending CRC after data +int WriteDataWithCRCToFile( void *data, int len, int count, FILE *fd ); + + +// reads data from file handle into passed buffer +// then reads next 32 bytes from filehandle, +// assumes it is a CRC for the data +// (as would be the case if data was written with WriteDataWithCRCToFile()) +// and compares it to the calc'd CRC for the loaded data +int ReadDataWithCRCFromFile( void *data, int len, int count, FILE *fd ); + + +int LoadDataWithCRC( void *data, int size, char *filename ); +int SaveDataWithCRC( void *data, int size, char *filename ); + + +// crypto versions of above read/write functions +int WriteDataWithCRCToCryptoFile( void *data, int len, int count, CryptoFileHandle *cfh ); +int ReadDataWithCRCFromCryptoFile( void *data, int len, int count, CryptoFileHandle *cfh ); +int WriteDBQueryToCryptoFile( CryptoFileHandle *cfh, DBQuery *query ); +int WriteDBQueryResultToCryptoFile( CryptoFileHandle *cfh, DBQueryResult *result ); +int LoadDBQueryFromCryptoFile( CryptoFileHandle *cfh, DBQuery *query ); +int LoadDBQueryResultFromCryptoFile( CryptoFileHandle *cfh, DBQueryResult *result ); + + +#endif + diff --git a/libraries/pmrt/pmrt_messages/dbquery.o b/libraries/pmrt/pmrt_messages/dbquery.o new file mode 100644 index 0000000..dc0b66a Binary files /dev/null and b/libraries/pmrt/pmrt_messages/dbquery.o differ diff --git a/libraries/pmrt/pmrt_messages/filetransfer.c b/libraries/pmrt/pmrt_messages/filetransfer.c new file mode 100755 index 0000000..2c062bf --- /dev/null +++ b/libraries/pmrt/pmrt_messages/filetransfer.c @@ -0,0 +1,1070 @@ +// filetransfer.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "filetransfer.h" +// #include "node.h" + +#include +#include + +#include + +#include "messages.h" +#include "dbquery.h" // needed for load data w/ crc + + +#include +#include +#include +#include +#include + +char gFileTransferAuditsDir[128]; +char gFileTransferStatsAuditFile[128]; +char gFileServerIP[128]; +char gFileServerCertFile[128]; +int gFileServerPort; + +// #define SERVERCERT "/g3/bbh3data/ssl/fileserver.cert" +#define SSL_CIPHER "AES256-SHA" +KeyGenHandle gKeyGenHandle; + +#define MANIFEST_RETRIES 5 +#define FILE_RETRIES 3 + + +// tells what dir names to use when looking for a file of given type +// order should match FileTransferRequestTypes in filetransfer.h +char RequestTypeDirs[][64] = +{ + "", // FILETRANSFER_TYPE_TEST_CONNECTION, + "trny_files", // FILETRANSFER_TYPE_TRNY_FILES, + "ad_files", // FILETRANSFER_TYPE_AD_FILES, +}; + +// similarly, this one maps games (BBHT,BBST, etc) to dirnames +char RequestGameDirs[][64] = +{ + "BBHT", // Big Buck Hunter Tourny, + "BBS", // safari, +}; + + +/* +#define FTP_COMMAND "/g3/bbh3/client/ftpget" +#define FTP_DOWNLOADS_PATH "/bbh3Tuser/downloads" +*/ +char gDownloadPath[128]; + +int (*gpCheckIfOKToUseDiskFunc)(); + + +#define FILETRANSFER_QUEUE_DEPTH 1024 + +N2 gFileTransferMessageList; + + +ThreadSafeQueue gFileTransferInQue; +ThreadSafeQueue gFileTransferOutQue; + +ThreadHandle gFileTransferThreadHandle; + +// malloc and free wrappers for tracking memory used +// by filetransfer subsystem +void* filetransfer_apphook_malloc(size_t size) +{ + void *ptr; + ptr = malloc(size); + AddToMemAllocHistory(ptr, size ); + return ptr; +} // dbquery_apphook_malloc() + +void filetransfer_apphook_free(void *m) +{ +// prts_debug( "DBQuery System Free:\n" ); + DelFromMemAllocHistory(m); + free(m); +// prts_debug("Successfully free'd mem at %p\n", m ); +} // filetransfer_apphook_free() + + +void FreeFileTransferRequest( FileTransferRequest_t *request ) +{ + if ( request == NULL ) + return; + filetransfer_apphook_free(request); +} + +void FreeFileTransferReply( int *reply ) +{ + if ( reply == NULL ) + return; + filetransfer_apphook_free(reply); +} + + +int CloneFileTransferRequest( FileTransferRequest_t **ppDst, FileTransferRequest_t *Src ) +{ + if ( Src == NULL || ppDst == NULL ) + return -1; + + *ppDst = NULL; + + // make a copy of the passed file info struct to put on msg + *ppDst = filetransfer_apphook_malloc(sizeof(FileTransferRequest_t)); + if ( *ppDst == NULL ) + { + return -2; + } + memcpy(*ppDst,Src,sizeof(FileTransferRequest_t)); + + return 0; +} + +int CloneFileTransferReply( int **ppDst, int *Src ) +{ + if ( Src == NULL || ppDst == NULL ) + return -1; + + *ppDst = NULL; + + // make a copy of the passed file info struct to put on msg + *ppDst = filetransfer_apphook_malloc(sizeof(int)); + if ( *ppDst == NULL ) + { + return -2; + } + memcpy(*ppDst,Src,sizeof(int)); + + return 0; +} + +int FileTransferSystemInit( char *ServerIP, int ServerPort, char *ServerCertFile, + char *DownloadPath, char *AuditsDir, + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize, + int (*pCheckIfOKToUseDiskFunc)()) +{ + char buf[1024]; + int ec; + ThreadStartInfo tsi; + + strcpy(gDownloadPath,DownloadPath); + + strcpy( gFileTransferAuditsDir, AuditsDir ); + sprintf( gFileTransferStatsAuditFile, "%s/filexfrstats.000.aud", gFileTransferAuditsDir ); + + strncpy( gFileServerIP, ServerIP, sizeof(gFileServerIP) ); + strcpy( gFileServerCertFile, ServerCertFile ); + gFileServerPort = ServerPort; + + gpCheckIfOKToUseDiskFunc = pCheckIfOKToUseDiskFunc; + + ec = ThreadSafeQueueInit( &gFileTransferInQue, FILETRANSFER_QUEUE_DEPTH, filetransfer_apphook_malloc, filetransfer_apphook_free ); + if ( ec != TSQ_RESULT_SUCCESS ) + return -1; + + ec = ThreadSafeQueueInit( &gFileTransferOutQue, FILETRANSFER_QUEUE_DEPTH, filetransfer_apphook_malloc, filetransfer_apphook_free ); + if ( ec != TSQ_RESULT_SUCCESS ) + return -2; + + + N2Head(&gFileTransferMessageList); + + // init our ssl key and cert + sprintf( buf, "Play Mechanix (%s)", ClientID ); + ec = InitKeyHandleFromSeed( &gKeyGenHandle, CryptoSeed, CryptoSeedSize, buf ); + if( ec != KEYGEN_RESULT_SUCCESS ) + return -8; + + // save public portion of key +#if !PRODUCTION + ec = SaveKeyHandleCert(&gKeyGenHandle, "client.filetransfer.cert" ); +#endif + + memset( gFileTransferPublicCert, 0, sizeof(gFileTransferPublicCert) ); + ec = ExportKeyHandleCert( &gKeyGenHandle, gFileTransferPublicCert, sizeof(gFileTransferPublicCert) ); + if ( ec != KEYGEN_RESULT_SUCCESS ) + { + strcpy( gFileTransferPublicCert, "N/A" ); + } + + memset( &gFileTransferSystemStats, 0, sizeof(gFileTransferSystemStats) ); + // load stats from file + ec = LoadDataWithCRC( &gFileTransferSystemStats,sizeof(gFileTransferSystemStats), gFileTransferStatsAuditFile); + if ( ec < 0 ) + { + memset(&gFileTransferSystemStats,0,sizeof(gFileTransferSystemStats) ); + gFileTransferSystemStats.start_timestamp = time(NULL); + } + + // start FileTransferThread + tsi.Arg = 0; + tsi.Func = FileTransferThread; + ec = StartThread( &gFileTransferThreadHandle, &tsi ); + if (ec != THREAD_RESULT_SUCCESS ) + return -5; + + return 0; +} + +// use to change server after Init +// new server will be used for next connection +void FileTransferSetServer( char *ServerIP, int ServerPort ) +{ + if ( ServerPort < 0 || ServerIP == NULL ) + return; + strncpy( gFileServerIP, ServerIP, sizeof(gFileServerIP) ); + gFileServerPort = ServerPort; +} + + +int FileTransferUnTarFile(char *filename) +{ + int ec=0; + int tar_ec=0; + int len; + char syscall[256]; + + + len = strlen(filename); + // check for .tgz file extension + if ( filename[len-4] != '.' + || + filename[len-3] != 't' + || + filename[len-2] != 'g' + || + filename[len-1] != 'z' + ) + { + prts_debug( "File '%s' not a tar archive, skipping untar\n", filename ); + ec = 1; // not a tar file + goto BAIL; + } + + + prts_debug( "File '%s' is a tar archive, proceeding with untar\n", filename ); + + while(gpCheckIfOKToUseDiskFunc != NULL && (!gpCheckIfOKToUseDiskFunc()) ) + { + prts_debug( "File Transfer Thread waiting for game to ok to use disk before executing untar.\n" ); + ThreadSleep(2000); + } + + + // sprintf( syscall, "/bin/tar zxf %s/%s -C /bbh3Tuser", gFTPDownloadPath, filename ); + + prts_debug( "Executing command: '%s'\n", syscall ); + +#if SYS_BB + tar_ec = system(syscall); + if ( tar_ec != 0 ) + { + prts_debug("Error untarring file '%s' (return code = %d)\n", filename, tar_ec ); + ec = -1; + goto BAIL; + } + else + { + prts_debug("File '%s' successfully untarred\n", filename); + } +#endif +BAIL: + return ec; +} + + + + +void PrintFileInfoStruct( FileInfoStruct_t *finfo ) +{ + if (finfo == NULL) + return; + + prts_debug( "Filename: %s\n", finfo->Filename ); + prts_debug( "SrcPath: %s\n", finfo->SrcPath ); + prts_debug( "DestPath: %s\n", finfo->DestPath ); + prts_debug( "FileSize: %u\n", finfo->Filesize ); + prts_debug( "FileCRC: %u\n", finfo->FileCRC ); + prts_debug( "FileDiget: %s\n", finfo->FileDigest ); + +} + +int GrabNextItem( char *src, int start_index, int src_len, char *dest, int dest_len ) +{ + int i; + int copy_len; + int item_len; + if ( src == NULL || src_len < 1 || dest == NULL || dest_len < 1 ) + { + return -1; + } + memset(dest,0,dest_len); + + + i = start_index; + while ( i < src_len ) + { + if ( src[i]==',' || src[i] == '\0' ) + { + break; + } + i++; + } + + item_len = i - start_index; + if ( item_len > 0 ) + { + copy_len = item_len; + if ( copy_len > dest_len ) + copy_len = dest_len; + memcpy(dest,&src[start_index],copy_len); + dest[dest_len-1] = '\0'; // null terminate dest + } + + return i + 1; + +} + +int ValidateFile( char *filename, int size, unsigned char *sha1_digest ) +{ + int ec; + int filesize; + unsigned char filedigest[DATADIGEST_MAX_DIGEST_LEN]; + unsigned int len; + + if ( filename == NULL || sha1_digest == NULL ) + return -1; + + // first check if the filesize matches + // if passed a size of 0 then skip size compare + // this allows us to call function w/ just a digest + if ( size > 0 ) + { + filesize = FsFileSize(filename); + if ( filesize != size ) + { + return -2; + } + } + + // compute digest and compare to to the passed value + memset( &filedigest, 0, sizeof(filedigest) ); + len = sizeof( filedigest ); + ec = DataDigestFile( DIGEST_SHA1, filename, filedigest, &len ); + if ( ec != DATADIGEST_RESULT_SUCCESS ) + { + prts_debug( "Error digesting file '%s'\n", filename ); + return -2; + } + + if ( DataDigestCmp( filedigest, sha1_digest, DIGEST_SHA1_LEN ) != 0 ) + { + prts_debug( "File '%s' doesn't match passed digest\n", filename ); + return -3; + } + + // the matches the passed params! + return 0; + +} + + +int FileTransferTestConnection() +{ + HTTPGetClientStruct gclient; + int ec; + int return_code = 0; + char index[64]; + char remotefile[] ="/index.html"; + + + ec = InitHTTPGetClientStruct(&gclient, + gFileServerIP, gFileServerPort, + &gKeyGenHandle, + NULL, NULL, + gFileServerCertFile, SSL_CIPHER, + remotefile, 0, + NULL, + index, sizeof(index), + 1, + 1, // 0, // 1 // close connection on exit? + 10, 60, 60, 60, + 1024*1024*5, // renegotiate ssl session every 5mb of data transfered + 4*60*60, // or every 4 hours, notice these are way up from dflts in order to cut down on bandwidth use + 1 ); // ignore_dates_on_server_cert + if ( ec < 0 ) + { + prts_debug( "Error when initng HTTP Client (ec = %d)\n", ec ); + return -2; + } + + gFileTransferSystemStats.ConnectAttemps++; + + while( gclient.state == HTTP_GET_CLIENT_STATE_NORMAL ) + { + UpdateHTTPGetClientStruct(&gclient); + ThreadSleep(1); + } + + // ignore HTTP errs as we expect this request to fail + // question here is can we connect + if ( gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + prts_debug( "Error when getting '%s'\n", remotefile ); + prts_debug( "client err = %d, parse err = %d, http err = %d\n", gclient.client_error, gclient.parser_error, gclient.http_error ); + gFileTransferSystemStats.ClientErrs++; + + if ( gclient.client_error == SSL_CLIENT_ERR_CONNECT_FAILED + || + gclient.client_error == SSL_CLIENT_ERR_CONNECT_TIMEDOUT ) + { + gFileTransferSystemStats.NoConnectErrs++; + gFileTransferSystemStats.LastFailedServerConnect = time(NULL); + } + return_code = -1; + } + else + { + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.SuccessfulConnections++; + } + + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + FreeHTTPGetClientStateStruct(&gclient); + + return return_code; + +} + + +int ProcessFileTransferRequest( FileTransferRequest_t *request ) +{ + char line[1024]; + char buf[1024]; + char *str; + FileInfoStruct_t fileinfo; + FILE *fd; + HTTPGetClientStruct gclient; + int ec; + int retries; + // int download; + // int valid; + int index; + + + char remotepath[MAX_FILEXFR_STRING_LENGTH]; + char localpath[MAX_FILEXFR_STRING_LENGTH]; + + char remotefile[MAX_FILEXFR_STRING_LENGTH]; + char localfile[MAX_FILEXFR_STRING_LENGTH]; + char manifestfile[MAX_FILEXFR_STRING_LENGTH]; + char destfile[MAX_FILEXFR_STRING_LENGTH]; + + char manifestdigest[DATADIGEST_MAX_DIGEST_LEN]; + char manifestdigest_string[3*DATADIGEST_MAX_DIGEST_LEN]; + + int localfilesize; + unsigned char remotefiledigest[DATADIGEST_MAX_DIGEST_LEN]; + // unsigned char localfiledigest[DATADIGEST_MAX_DIGEST_LEN]; + // char localfiledigest_string[3*DATADIGEST_MAX_DIGEST_LEN]; + // unsigned int len; + + int exit; + + if (request == NULL) + return -1; + + prts_debug( "Processing File Transfer request...\n" ); + + if ( request->type == FILETRANSFER_TYPE_TEST_CONNECTION ) + return FileTransferTestConnection(); + + sprintf(remotepath,"/%s/%s/%d", RequestGameDirs[request->game], RequestTypeDirs[request->type], request->id ); + sprintf(localpath, "%s%s", gDownloadPath, remotepath ); + sprintf(manifestfile,"%s/manifest", localpath ); + + ec = FsMkDir(localpath, 1 ); + if ( ec < 0 ) + { + prts_debug( "FAILED TO MAKE DIR '%s' when downloading files\n", localpath ); + return -1; + } + + + sprintf(remotefile,"%s/manifest.sha", remotepath ); + + ec = InitHTTPGetClientStruct(&gclient, + // "10.0.1.197", 7786, + // "72.16.164.10" + gFileServerIP, gFileServerPort, + &gKeyGenHandle, + NULL, NULL, + gFileServerCertFile, SSL_CIPHER, + remotefile, 0, + NULL, + manifestdigest_string, sizeof(manifestdigest_string), + 1, + 1, // 0, // 1 // close connection on exit? + 10, 60, 60, 60, + 0, 0, 1 ); + if ( ec < 0 ) + { + prts_debug( "Error when initng HTTP Client (ec = %d)\n", ec ); + return -2; + } + + retries = 0; + while ( retries < MANIFEST_RETRIES ) + { + int prev_state; + + prts_debug( "Downloading manifest digest...\n" ); + gFileTransferSystemStats.ConnectAttemps++; + + prev_state = gclient.clientstate.state; + while( gclient.state == HTTP_GET_CLIENT_STATE_NORMAL ) + { + UpdateHTTPGetClientStruct(&gclient); + ThreadSleep(1); + if( gclient.clientstate.state != prev_state ) + { + prts_debug( "client state: %d, parse state: %d\n", gclient.clientstate.state, gclient.parser.state ); + prev_state = gclient.clientstate.state; + } + } + + if ( gclient.parser_error != HTTP_GET_ERR_NONE + || + gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + prts_debug( "Error when getting '%s'\n", remotefile ); + prts_debug( "client err = %d, parse err = %d, http err = %d\n", gclient.client_error, gclient.parser_error, gclient.http_error ); + if ( gclient.http_error == 404 ) // HTTP FILE NOT FOUND ERR + { + gFileTransferSystemStats.FileNotFoundErrs++; + retries = MANIFEST_RETRIES; // quick bail if file not found + } + if ( gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + gFileTransferSystemStats.ClientErrs++; + + if ( gclient.client_error == SSL_CLIENT_ERR_CONNECT_FAILED + || + gclient.client_error == SSL_CLIENT_ERR_CONNECT_TIMEDOUT ) + { + gFileTransferSystemStats.NoConnectErrs++; + gFileTransferSystemStats.LastFailedServerConnect = time(NULL); + } + } + else + { + // must have been an http err + gFileTransferSystemStats.HTTPErrs++; + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.SuccessfulConnections++; + } + + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + ResetHTTPGetClientStruct( &gclient ); + retries++; + gFileTransferSystemStats.LastFailedXFR = time(NULL); + ThreadSleep(2000); // wait 2 sec before we try again + } + else + { + gFileTransferSystemStats.SuccessfulConnections++; + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.LastSuccessfulXFR = time(NULL); + break; + } + } + + if ( retries >= MANIFEST_RETRIES ) + { + FreeHTTPGetClientStateStruct(&gclient); + return -2; + } + + // close the connection while we parse the digest file + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + + // now we have a diget for our manifest + // convert the digest to binary + memset( &manifestdigest, 0, sizeof(manifestdigest) ); + ec = ConvertHexStringToDataDigest( manifestdigest_string, strlen(manifestdigest_string) + 1, manifestdigest, DIGEST_SHA1_LEN, 0 ); + if ( ec < 0 ) + { + prts_debug( "Error converting remote file digest string\n" ); + } + + if( ValidateFile( manifestfile, 0, manifestdigest ) != 0 ) + { + prts_debug( "manifest file on server is different from local copying, downloading new manifest file\n" ); + + sprintf(remotefile,"%s/manifest.gz", remotepath ); + sprintf(localfile,"%s/manifest.gz", localpath ); + + ResetHTTPGetClientStruct( &gclient ); + SetHTTPGetClientStructRequestDoc( &gclient, remotefile, 0 ); + SetHTTPGetClientStructDest( &gclient, localfile, NULL, 0 ); + + retries = 0; + while ( retries < MANIFEST_RETRIES ) + { + prts_debug( "Downloading new manifest...\n" ); + gFileTransferSystemStats.ConnectAttemps++; + + // delete any copy of manifest file that is lying around + // if we got to this point we know it is not correct + unlink(manifestfile); + unlink(localfile); // also delete any copy of gzip'd manifest + while( gclient.state == HTTP_GET_CLIENT_STATE_NORMAL ) + { + UpdateHTTPGetClientStruct(&gclient); + ThreadSleep(1); + } + + if ( gclient.parser_error != HTTP_GET_ERR_NONE + || + gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + prts_debug( "Error when getting '%s'\n", remotefile ); + prts_debug( "client err = %d, parse err = %d, http err = %d\n", gclient.client_error, gclient.parser_error, gclient.http_error ); + if ( gclient.http_error == 404 ) // HTTP FILE NOT FOUND ERR + { + gFileTransferSystemStats.FileNotFoundErrs++; + retries = MANIFEST_RETRIES; // quick bail if file not found + } + if ( gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + gFileTransferSystemStats.ClientErrs++; + + if ( gclient.client_error == SSL_CLIENT_ERR_CONNECT_FAILED + || + gclient.client_error == SSL_CLIENT_ERR_CONNECT_TIMEDOUT ) + { + gFileTransferSystemStats.NoConnectErrs++; + gFileTransferSystemStats.LastFailedServerConnect = time(NULL); + } + } + else + { + // must have been an http err + gFileTransferSystemStats.HTTPErrs++; + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.SuccessfulConnections++; + } + + + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + ResetHTTPGetClientStruct( &gclient ); + retries++; + gFileTransferSystemStats.LastFailedXFR = time(NULL); + ThreadSleep(2000); // wait 2 sec before we try again + } + else + { + gFileTransferSystemStats.SuccessfulConnections++; + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.LastSuccessfulXFR = time(NULL); + + // downloaded the file, now gunzip it + ec = gunzipfile( localfile, manifestfile ); + if ( ec != GZ_SUCCESS ) + { + prts_debug( "Error when gunzipping '%s' to '%s'\n", localfile, manifestfile ); + prts_debug( "gz err = %d\n", ec ); + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + ResetHTTPGetClientStruct( &gclient ); + retries++; + gFileTransferSystemStats.LastFailedGunzip = time(NULL); + gFileTransferSystemStats.FailedGunzips++; + } + else if( ValidateFile( manifestfile, 0, manifestdigest ) != 0 ) + { + prts_debug( "Downloaded manifest file has incorrect digest value!\n" ); + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + ResetHTTPGetClientStruct( &gclient ); + retries++; + gFileTransferSystemStats.LastFailedValidation = time(NULL); + gFileTransferSystemStats.FailedValidations++; + } + else + { + // success! + unlink(localfile); // delete gzip'd manifest + break; + } + } + } + + if ( retries >= MANIFEST_RETRIES ) + { + FreeHTTPGetClientStateStruct(&gclient); + // clean up files + unlink(manifestfile); + unlink(localfile); + return -2; + } + + // close the connection while we parse the digest file + gFileTransferSystemStats.TotalBytesRecieved += gclient.clientstate.recv_count; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + + } + + // now walk through the manifest file ... + fd = fopen(manifestfile, "rb" ); + if ( fd == NULL ) + { + prts_debug( "Error when opening '%s'\n", manifestfile ); + FreeHTTPGetClientStateStruct(&gclient); + return -4; + } + + + exit = 0; + while( ! exit ) + { + memset( &fileinfo, 0, sizeof(fileinfo) ); + + str = fgets( line, sizeof(line) , fd ); + if ( str == NULL ) + { + exit = 1; + break; + } + + // get rid of carriage return + if ( line[strlen(line) - 1] == '\n' ) + line[strlen(line) - 1] = '\0'; + + prts_debug( "Pulled line from manifest: '%s'\n", line ); + + index = 0; + index = GrabNextItem( line, index, strlen(line), buf, sizeof(buf) ); + strncpy(fileinfo.Filename, buf, sizeof(fileinfo.Filename) ); + index = GrabNextItem( line, index, strlen(line), buf, sizeof(buf) ); + strncpy(fileinfo.SrcPath, buf, sizeof(fileinfo.SrcPath) ); + index = GrabNextItem( line, index, strlen(line), buf, sizeof(buf) ); + strncpy(fileinfo.DestPath, buf, sizeof(fileinfo.DestPath) ); + index = GrabNextItem( line, index, strlen(line), buf, sizeof(buf) ); + fileinfo.Filesize = atol(buf); + index = GrabNextItem( line, index, strlen(line), buf, sizeof(buf) ); + fileinfo.FileCRC = atol(buf); + index = GrabNextItem( line, index, strlen(line), buf, sizeof(buf) ); + strncpy(fileinfo.FileDigest, buf, sizeof(fileinfo.FileDigest) ); + + + + prts_debug( "Pulled File from manifest:\n" ); + PrintFileInfoStruct( &fileinfo ); + + + // convert the digest to binary + memset( &remotefiledigest, 0, sizeof(remotefiledigest) ); + ec = ConvertHexStringToDataDigest( fileinfo.FileDigest, strlen(fileinfo.FileDigest) + 1, remotefiledigest, DIGEST_SHA1_LEN, 0 ); + if ( ec < 0 ) + { + prts_debug( "Error converting remote file digest string\n" ); + } + +#ifdef SYS_PC + sprintf(destfile,"/g3%s/%s", fileinfo.DestPath, fileinfo.Filename ); +#else + sprintf(destfile,"%s/%s", fileinfo.DestPath, fileinfo.Filename ); +#endif + + // check already have this file + if ( ValidateFile( destfile, fileinfo.Filesize, remotefiledigest ) == 0 ) + { + prts_debug( "Already have file '%s'\n", fileinfo.Filename ); + continue; + } + + + // don't have this file, or local file does not match server file + // so go get it + sprintf(remotefile,"%s/%s", fileinfo.SrcPath, fileinfo.Filename ); + sprintf(localfile,"%s/%s.%s", localpath, fileinfo.Filename, fileinfo.FileDigest ); + + ResetHTTPGetClientStruct( &gclient ); + SetHTTPGetClientStructRequestDoc( &gclient, remotefile, 0 ); + SetHTTPGetClientStructDest( &gclient, localfile, NULL, 0 ); + + + retries = 0; + while ( retries < FILE_RETRIES ) + { + gFileTransferSystemStats.ConnectAttemps++; + + while( gpCheckIfOKToUseDiskFunc != NULL && (!gpCheckIfOKToUseDiskFunc()) ) + { + prts_debug( "File Transfer Thread waiting for game to ok to use disk before starting new download\n" ); + ThreadSleep(2000); + } + + // check for an existing file in downloads area + // we tag the localfile name with the digest for + // the remote file, and we delete localfile + // on all fatal errs + // so if we find a file here w/ that name + // then assume it is from a partial download + // which we now want to resume + localfilesize = FsFileSize(localfile); + if ( localfilesize > 0 ) + { + if ( localfilesize < fileinfo.Filesize ) + { + // instruct http parser to resume download where it stopped + SetHTTPGetClientStructRequestDoc( &gclient, remotefile, localfilesize ); + } + else + { + // some other err has occured + // so just delete the file and we'll start again + unlink(localfile); + } + } + + while( gclient.state == HTTP_GET_CLIENT_STATE_NORMAL ) + { + UpdateHTTPGetClientStruct(&gclient); + ThreadSleep(1); + } + + if ( gclient.parser_error != HTTP_GET_ERR_NONE + || + gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + prts_debug( "Error when getting '%s'\n", remotefile ); + prts_debug( "client err = %d, parse err = %d, http err = %d\n", gclient.client_error, gclient.parser_error, gclient.http_error ); + if ( gclient.http_error == 404 ) // HTTP FILE NOT FOUND ERR + { + gFileTransferSystemStats.FileNotFoundErrs++; + retries = MANIFEST_RETRIES; // quick bail if file not found + } + if ( gclient.client_error != SSL_CLIENT_ERR_NONE ) + { + gFileTransferSystemStats.ClientErrs++; + + if ( gclient.client_error == SSL_CLIENT_ERR_CONNECT_FAILED + || + gclient.client_error == SSL_CLIENT_ERR_CONNECT_TIMEDOUT ) + { + gFileTransferSystemStats.NoConnectErrs++; + gFileTransferSystemStats.LastFailedServerConnect = time(NULL); + } + } + else + { + // must have been an http err + gFileTransferSystemStats.HTTPErrs++; + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.SuccessfulConnections++; + } + gFileTransferSystemStats.TotalBytesRecieved += gclient.parser.header_len + gclient.parser.data_len + gclient.parser.footer_len; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + ResetHTTPGetClientStruct( &gclient ); + retries++; + gFileTransferSystemStats.LastFailedXFR = time(NULL); + ThreadSleep(2000); // wait 2 sec before we try again + + } + else + { + gFileTransferSystemStats.TotalBytesRecieved += gclient.parser.header_len + gclient.parser.data_len + gclient.parser.footer_len; + gFileTransferSystemStats.TotalBytesSent += gclient.clientstate.send_count; + CloseHTTPGetClientConnection(&gclient); + + gFileTransferSystemStats.SuccessfulConnections++; + gFileTransferSystemStats.LastSuccessfulServerConnect = time(NULL); + gFileTransferSystemStats.LastSuccessfulXFR = time(NULL); + + // great we got the file, now we get to validate it + if( ValidateFile(localfile, fileinfo.Filesize,remotefiledigest) == 0 ) + { + prts_debug( "Success downloading '%s' to '%s'\n", remotefile, localfile ); + break; // all done! + } + else + { + prts_debug( "downloaded file invalid!\n" ); + unlink(localfile); // delete invalid file + ResetHTTPGetClientStruct( &gclient ); + retries++; + gFileTransferSystemStats.LastFailedValidation = time(NULL); + gFileTransferSystemStats.FailedValidations++; + } + + // break; + } + } + + if ( retries >= FILE_RETRIES ) + { + prts_debug( "Retries exceeded when getting '%s'\n", remotefile ); + continue; + } + + + +#ifdef SYS_PC + sprintf( buf, "/g3%s", fileinfo.DestPath ); + ec = FsMkDir( buf, 1 ); +#else + ec = FsMkDir( fileinfo.DestPath, 1 ); +#endif + if ( ec < 0 ) + { + prts_debug( "Error making dir '%s'\n", fileinfo.DestPath ); + } + + // delete any existing file, if we got this far we can safely say we don't want to use the old file + unlink(destfile); + ec = rename( localfile, destfile ); + if ( ec < 0 ) + { + prts_debug( "Error renaming '%s' to '%s' (errno = %d)\n", localfile, destfile, errno ); + gFileTransferSystemStats.LastFailedRename = time(NULL); + gFileTransferSystemStats.FailedRenames++; + unlink(localfile); + } + + // all done! + // move on to next file + + + } + + + fclose(fd); + CloseHTTPGetClientConnection(&gclient); + FreeHTTPGetClientStateStruct(&gclient); + + + return 0; +} + + + +void FileTransferThread( int arg ) +{ + int ec=0; + Message *msg; + FileTransferRequest_t *fileinfo; + // char buf[1024]; + int *reply; + + while(1) + { + while( ThreadSafeQueuePop( &gFileTransferInQue, (void**)&msg ) == TSQ_RESULT_SUCCESS ) + { + reply = NULL; + reply = filetransfer_apphook_malloc(sizeof(int)); + if ( reply == NULL ) + { + prts_debug( "File Transfer Thread failed to malloc for reply int. msg id = %u\n", msg->id ); + } + else + { + fileinfo = (FileTransferRequest_t *)msg->msg_data; + if ( fileinfo == NULL ) + { + prts_debug( "File Transfer Thread got empty file request. msg id = %u\n", msg->id ); + // just give back a success result, what does game expect? + *reply = FILETRANSFER_RESULT_SUCCESS; + if ( msg->reply_data != NULL ) + filetransfer_apphook_free(msg->reply_data); + msg->reply_data = reply; + } + else + { + prts_debug( "File Transfer Thread got new file request. msg id = %u, type = %d, file id = %u\n", msg->id, fileinfo->type, fileinfo->id ); + + while( gpCheckIfOKToUseDiskFunc != NULL && (!gpCheckIfOKToUseDiskFunc()) ) + { + prts_debug( "File Transfer Thread waiting for game to ok to use disk. msg id = %d\n", msg->id ); + ThreadSleep(2000); + } + + + gFileTransferSystemStats.TotalMsgs++; + gFileTransferSystemStats.ActiveMsgs = 1; + ec = ProcessFileTransferRequest( fileinfo ); + // save out updated audits after every transfer attempt + SaveDataWithCRC( &gFileTransferSystemStats,sizeof(gFileTransferSystemStats), gFileTransferStatsAuditFile); + prts_debug( "Done Processing File Transfer request (ec = %d)\n", ec ); + gFileTransferSystemStats.ActiveMsgs = 0; + +/* + // check if we already have that file + sprintf(buf,"%s/%s",gFTPDownloadPath,fileinfo->Filename); + if ( FsFileSize(buf) == (int)fileinfo->Filesize + && + (fileinfo->FileCRC == 0 || fileinfo->FileCRC == AudCRCFile(buf)) + ) + { + prts_debug( "File Transfer Thread found existing file '%s'\n", buf ); + } + else // got to ftp it + { + sprintf(buf,"%s %s %s/%s %s/%s", + gFTPCommand, + fileinfo->FTPaddress, + fileinfo->Filepath, + fileinfo->Filename, + gFTPDownloadPath, + fileinfo->Filename ); + + prts_debug( "File Transfer Thread executing ftp cmd '%s'\n", buf ); +#if SYS_BB + ec = system(buf); +#endif + } + // just assume it worked for now + FileTransferUnTarFile(fileinfo->Filename); +*/ + if ( ec >= 0 ) + *reply = FILETRANSFER_RESULT_SUCCESS; + else + *reply = FILETRANSFER_RESULT_FAILURE; + + if ( msg->reply_data != NULL ) + filetransfer_apphook_free(msg->reply_data); + msg->reply_data = reply; + + } + } + + // send message back to game + msg->waitstatus = MESSAGE_ANSWERED; + while(ThreadSafeQueuePush( &gFileTransferOutQue, msg ) != TSQ_RESULT_SUCCESS ) + { + prts_debug( "File Transfer Thread Failed to push message on out queue. msg id = %d\n", msg->id ); + ThreadSleep(1000); + } + + ThreadSleep(10); + } + ThreadSleep(1000); + } +} diff --git a/libraries/pmrt/pmrt_messages/filetransfer.h b/libraries/pmrt/pmrt_messages/filetransfer.h new file mode 100755 index 0000000..ffee926 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/filetransfer.h @@ -0,0 +1,146 @@ +// filetransfer.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef FILEXFR_H +#define FILEXFR_H + + + + +#include + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +// #include "node.h" +#endif + +#include +#include + + + +enum FileTranferErrCodes +{ + FILETRANSFER_RESULT_SUCCESS, + FILETRANSFER_RESULT_SERVER_UNREACHABLE, + FILETRANSFER_RESULT_SERVER_RETURNED_ERR, + FILETRANSFER_RESULT_FAILURE, +}; + + +#define MAX_FILEXFR_STRING_LENGTH 256 +// file transfer structs +typedef struct +{ + unsigned int id; + char Filepath[MAX_FILEXFR_STRING_LENGTH]; + char Filename[MAX_FILEXFR_STRING_LENGTH]; + unsigned int Filesize; + unsigned int FileCRC; + char Filetype[MAX_FILEXFR_STRING_LENGTH]; + char FTPaddress[MAX_FILEXFR_STRING_LENGTH]; +} FileTransferInfo_t; + +typedef struct +{ + unsigned int id; + char FileType[MAX_FILEXFR_STRING_LENGTH]; +} FileTransferGetByType_t; + + +typedef struct +{ + int game; + int type; + int id; +} FileTransferRequest_t; + +enum FileTransferRequestTypes +{ + FILETRANSFER_TYPE_TEST_CONNECTION, + FILETRANSFER_TYPE_TRNY_FILES, + FILETRANSFER_TYPE_AD_FILES, + NUM_FILETRANSFER_TYPES, +}; + +enum FileTransferGameTypes +{ + FILETRANSFER_GAME_BBHT, + FILETRANSFER_GAME_BBST, +}; + +char gFileTransferPublicCert[2048]; + +typedef struct +{ + char Filename[MAX_FILEXFR_STRING_LENGTH]; + char SrcPath[MAX_FILEXFR_STRING_LENGTH]; + char DestPath[MAX_FILEXFR_STRING_LENGTH]; + int Filesize; + unsigned int FileCRC; + char FileDigest[3*DATADIGEST_MAX_DIGEST_LEN]; + +} FileInfoStruct_t; + + +struct FileTransferSystemStats +{ + int start_timestamp; + int TotalMsgs; + int ActiveMsgs; + + // err counts and timestamps + unsigned int ConnectAttemps; + unsigned int NoConnectErrs; + unsigned int ClientErrs; + unsigned int HTTPErrs; + unsigned int FileNotFoundErrs; + unsigned int SuccessfulConnections; + + int LastSuccessfulServerConnect; + int LastFailedServerConnect; + int LastSuccessfulXFR; + int LastFailedXFR; + + unsigned int FailedValidations; + int LastFailedValidation; + + unsigned int FailedGunzips; + int LastFailedGunzip; + + unsigned int FailedRenames; + int LastFailedRename; + + // byte counters + // (note these are raw bytes sent/recvd before SSL and/or encryption) + unsigned int TotalBytesSent; + unsigned int TotalBytesRecieved; + + // unsigned int BytesSentByType[NUM_FILETRANSFER_TYPES]; + // unsigned int BytesRecievedByType[NUM_FILETRANSFER_TYPES]; + +}; + +struct FileTransferSystemStats gFileTransferSystemStats; + + +int FileTransferSystemInit( char *ServerIP, int ServerPort, char *ServerCertFile, + char *DownloadPath, char *AuditsDir, + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize, + int (*pCheckIfOKToUseDiskFunc)()); + +void FileTransferSetServer( char *ServerIP, int ServerPort ); + +void FileTransferThread( int arg ); + +void FreeFileTransferRequest( FileTransferRequest_t *request ); +void FreeFileTransferReply( int *reply ); +int CloneFileTransferRequest( FileTransferRequest_t **ppDst, FileTransferRequest_t *Src ); +int CloneFileTransferReply( int **ppDst, int *Src ); + +extern char RequestTypeDirs[][64]; +extern char RequestGameDirs[][64]; +#endif + diff --git a/libraries/pmrt/pmrt_messages/filetransfer.o b/libraries/pmrt/pmrt_messages/filetransfer.o new file mode 100644 index 0000000..3539757 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/filetransfer.o differ diff --git a/libraries/pmrt/pmrt_messages/libpmrt_messages.a b/libraries/pmrt/pmrt_messages/libpmrt_messages.a new file mode 100644 index 0000000..f2dfbdf Binary files /dev/null and b/libraries/pmrt/pmrt_messages/libpmrt_messages.a differ diff --git a/libraries/pmrt/pmrt_messages/makedeplib b/libraries/pmrt/pmrt_messages/makedeplib new file mode 100644 index 0000000..7c44fac --- /dev/null +++ b/libraries/pmrt/pmrt_messages/makedeplib @@ -0,0 +1,373 @@ +dbquery.o: dbquery.c dbquery.h messages.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + filetransfer.h /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /g3/include/pmrt_utils/memallochist.h \ + /g3/include/pmrt_utils/netsock.h /g3/include/pmrt_utils/netsock_bb.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/pmrt_ssl/pmrt_ssl.h \ + /g3/include/pmrt_ssl/keygenerate.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/openssl/rand.h \ + /g3/include/pmrt_ssl/datadigest.h /g3/include/pmrt_ssl/filecrypto.h \ + /g3/include/zlib.h /g3/include/zconf.h /g3/include/pmrt_ssl/netssl.h \ + /g3/include/pmrt_ssl/sslclient.h /g3/include/pmrt_ssl/sslhttpclient.h \ + /g3/include/pmrt_ssl/randomnumbers.h /g3/include/pmrt_ssl/memcrypto.h \ + /g3/include/pmrt_ssl/aescrypt.h tokens.h +filetransfer.o: filetransfer.c filetransfer.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/pmrt_ssl/pmrt_ssl.h \ + /g3/include/pmrt_ssl/keygenerate.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/openssl/rand.h \ + /g3/include/pmrt_ssl/datadigest.h /g3/include/pmrt_ssl/filecrypto.h \ + /g3/include/zlib.h /g3/include/zconf.h /g3/include/pmrt_ssl/netssl.h \ + /g3/include/pmrt_ssl/sslclient.h /g3/include/pmrt_ssl/sslhttpclient.h \ + /g3/include/pmrt_ssl/randomnumbers.h /g3/include/pmrt_ssl/memcrypto.h \ + /g3/include/pmrt_ssl/aescrypt.h \ + /g3/include/pmrt_compression/pmrt_compression.h messages.h dbquery.h +messages.o: messages.c messages.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + filetransfer.h /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /g3/include/pmrt_utils/memallochist.h \ + /g3/include/pmrt_utils/netsock.h /g3/include/pmrt_utils/netsock_bb.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/pmrt_ssl/pmrt_ssl.h \ + /g3/include/pmrt_ssl/keygenerate.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/openssl/rand.h \ + /g3/include/pmrt_ssl/datadigest.h /g3/include/pmrt_ssl/filecrypto.h \ + /g3/include/zlib.h /g3/include/zconf.h /g3/include/pmrt_ssl/netssl.h \ + /g3/include/pmrt_ssl/sslclient.h /g3/include/pmrt_ssl/sslhttpclient.h \ + /g3/include/pmrt_ssl/randomnumbers.h /g3/include/pmrt_ssl/memcrypto.h \ + /g3/include/pmrt_ssl/aescrypt.h dbquery.h +pmrt_messages.o: pmrt_messages.c pmrt_messages.h messages.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + filetransfer.h /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /g3/include/pmrt_utils/memallochist.h \ + /g3/include/pmrt_utils/netsock.h /g3/include/pmrt_utils/netsock_bb.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/pmrt_ssl/pmrt_ssl.h \ + /g3/include/pmrt_ssl/keygenerate.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/openssl/rand.h \ + /g3/include/pmrt_ssl/datadigest.h /g3/include/pmrt_ssl/filecrypto.h \ + /g3/include/zlib.h /g3/include/zconf.h /g3/include/pmrt_ssl/netssl.h \ + /g3/include/pmrt_ssl/sslclient.h /g3/include/pmrt_ssl/sslhttpclient.h \ + /g3/include/pmrt_ssl/randomnumbers.h /g3/include/pmrt_ssl/memcrypto.h \ + /g3/include/pmrt_ssl/aescrypt.h dbquery.h tokens.h +tokens.o: tokens.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h tokens.h /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h /g3/include/pmrt_utils/memallochist.h \ + /g3/include/pmrt_utils/netsock.h /g3/include/pmrt_utils/netsock_bb.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h diff --git a/libraries/pmrt/pmrt_messages/makefile b/libraries/pmrt/pmrt_messages/makefile new file mode 100755 index 0000000..80fb1fd --- /dev/null +++ b/libraries/pmrt/pmrt_messages/makefile @@ -0,0 +1,41 @@ +# make driver +# make install (as root) +# +.CLIBFILES = dbquery.c filetransfer.c messages.c pmrt_messages.c tokens.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libpmrt_messages.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /g3/lib/libpmrt_utils.a +# add ssl support +CFLAGS += -DUSE_SSL -I /g3/lib/pmrt_ssl +LIBS += /g3/lib/libpmrt_ssl.a /g3/lib/libssl.a /g3/lib/libcrypto.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/pmrt_messages + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/pmrt_messages + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/pmrt_messages/messages.c b/libraries/pmrt/pmrt_messages/messages.c new file mode 100755 index 0000000..43e014a --- /dev/null +++ b/libraries/pmrt/pmrt_messages/messages.c @@ -0,0 +1,2501 @@ +// messages.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +#include "messages.h" + +#include +#include +#include +#include +#include + +// #include "node.h" +#include + +#include + +unsigned char gCryptoKey[32]; // AES key +// unsigned char gCryptoIV[16]; // AES Initial Vector + +#include "dbquery.h" + + +/* +#if SYS_PC +#define MESSAGE_STORE_DIR "/g3/bbh3tuser/messages" +#endif +#if SYS_BB +#define MESSAGE_STORE_DIR "/bbh3Tuser/messages" +#endif +*/ +char gMessageStoreDir[128]; + +int (*gpCheckIfOKToUseDiskFunc)(); + + +#define MAX_MESSAGE_REPLIES_PER_LOOP 20 // do not process any more than this number of message replies per loop +#define MAX_MESSAGE_LIFETIME 4*3600 // don't let any message live more than 4 hours +#define MAX_ACTIVE_PERSISTENT_MESSAGES 256 // 100 // only this many persistent msgs in mem at one time (rest on disk) +#define MAX_ACTIVE_MESSAGES 1024 // stop accepting messages if we have more than this +#define MAX_STORED_MESSAGES 1000000 + +N2 gMessageList; +unsigned int gNextMessageID; + +extern ThreadSafeQueue gDBQueryInQue; +extern ThreadSafeQueue gDBQueryOutQue; + +extern ThreadSafeQueue gFileTransferInQue; +extern ThreadSafeQueue gFileTransferOutQue; + + + + + +// FUNCTION DECLARATIONS +// + +// malloc and free wrappers for tracking memory used +// by message subsystem +void* message_apphook_malloc(size_t size); +void message_apphook_free(void *m); + +// +// Init Function +// sets up global vars used by message system +// +int MessageSystemInit(char *MessageStoreDir, int (*pCheckIfOKToUseDiskFunc)(), unsigned char *CryptoSeed, int CryptoSeedSize); + +// +// Message Create/Delete/Copy/Clone Funtions +// 'nuff said +// +int CreateNewMessage( Message **ppMessage, + unsigned int id, + int type, + int timestamp, + int waittime, + int priority, + int persist, + int waitstatus, + int closed, + int saved, + int orphaned, + void *msg_data, + void *reply_data, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int CloneMessageData( Message *dst, Message *src ); +int CloneMessageReply( Message *dst, Message *src ); +int CloneMessage( Message **ppDst, Message *Src, int copy_msg_data, int copy_reply_data ); +void FreeMessageData( Message *message, int free_msg_data, int free_reply_data ); +void FreeMessage( Message *message, int free_msg_data, int free_reply_data ); + +// +// Message Send Funtions +// These create new messages and link them onto gMessageList +// +int SendNewMessage( unsigned int *id, int type, + int waittime, int priority, int persist, + void *msg_data, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int SendNewDBQueryMessage( unsigned int *id, + int query_type, int maxage, int max_result_rows, + int query_data_size, void *query_data, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int SendNewFileTransferMessage( unsigned int *id, + FileTransferRequest_t *FileInfo, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + + +// +// Message Storage Funtions +// These read/write messages to the disk, +// used for storing persitent messages so they can survive a game reboot +// also includes some funcs for examining pool of stored messages +// +int StoreMessage( Message *msg ); +int UnStoreMessage( Message *msg ); +int RestoreMessage( unsigned int id, int priority ); // priority is optional here +int CountStoredMessages(); +unsigned int FindNextSafeMessageID(); +unsigned int RestoreNextStoredMessage(); +int WriteMessageToFile( FILE *fd, Message *msg ); +int LoadMessageFromFile( FILE *fd, Message *msg ); +int SaveMessage( char *filename, Message *msg ); +int LoadMessage( char *filename, Message *msg ); + +// +// Message Search Funtion +// function to find messages by ID and it's helper func +// +int MatchMsgByID( void *arg, void *obj ); +Message *FindMessageByID( unsigned int id ); + + +ObjData *FindPersistentMessageNodeByHighestPriorityAndID(); + + + +// +// Message Introspection Funtions +// Wrapper functions for the game to use when +// interacting with messages (eg. closing them or pull information out of them) +// +int CheckMessageStatus( Message *message ); +int CloseOutMessage( Message *message ); +int CheckDBQueryMsgErrorCode( Message *message ); +int CheckDBQueryMsgResultCount( Message *message ); +int CopyDBQueryMsgResultsData( Message *message, void *dest, int size ); +void *GetDBQueryMsgResultsData( Message *message ); +void *GetDBQueryMsgQueryData( Message *message ); +int GetDBQueryMsgResultsTimestamp( Message *message ); + +int CheckMessageStatusByID( unsigned int id ); +int CloseOutMessageByID( unsigned int id ); +int CheckDBQueryMsgErrorCodeByID( unsigned int id ); +int CheckDBQueryMsgResultCountByID( unsigned int id ); +int CopyDBQueryMsgResultsDataByID( unsigned int id, void *dest, int size ); +void *GetDBQueryMsgResultsDataByID( unsigned int id ); +void *GetDBQueryMsgQueryDataByID( unsigned int id ); +int GetDBQueryMsgResultsTimestampByID( unsigned int id ); + +// +// Message Print Funtions +// use to print messages to stdout when debugging +// +int PrintMessageDataObj( void *arg, void *obj ); +int PrintMessage( Message *msg ); +void PrintMessageStats(); + +// +// Message Flush Funtions +// func to flush out current message list and its helper func +// +int FlushMessageDataObj( void *arg, void *obj ); // helper func +void FlushMessages(); + +// +// Message Loop Funtions +// MessageLoop() and helper functions used for processing/updating messages +// on the gMessageList +// +void ProcessNewMsg(Message *msg); +void AnswerDBQueryMsgFromDiskCache( Message *msg ); +void DoDBQueryOrphanCallback(Message *msg); +void DoOrphanCallback(Message *msg); +int UpdateMessageDataObj( void *arg, void *obj ); +int CheckIfMessageHasGoodReply( Message *msg ); +int MatchReplyWithMessageDataObj( void *arg, void *obj ); +int MessageLoop(); + +// test funcs +void TestOrphanCallbackFunc(Message *msg); + + +// END FUNCTION DECLARATIONS + + + +// malloc and free wrappers for tracking memory used +// by message subsystem +void* message_apphook_malloc(size_t size) +{ + void *ptr; + ptr = malloc(size); + AddToMemAllocHistory(ptr, size ); + return ptr; +} // message_apphook_malloc() + +void message_apphook_free(void *m) +{ +// prts_debug( "Msg System Free:\n" ); + DelFromMemAllocHistory(m); + free(m); +// prts_debug("Successfully free'd mem at %p\n", m ); +} // message_apphook_free() + +// +// Init Function +// sets up global vars used by message system +// +int MessageSystemInit(char *MessageStoreDir, int (*pCheckIfOKToUseDiskFunc)(), unsigned char *CryptoSeed, int CryptoSeedSize ) +{ + int ec = 0; + N2Head(&gMessageList); + + memset(&gMessageSystemStats, 0, sizeof(gMessageSystemStats)); + + strcpy(gMessageStoreDir,MessageStoreDir); + gpCheckIfOKToUseDiskFunc = pCheckIfOKToUseDiskFunc; + + // note that we do this after copying MessageStoreDir! + gNextMessageID = FindNextSafeMessageID(); + + gMessageSystemStats.StoredMsgs = CountStoredMessages(); + gMessageSystemStats.TotalMsgs += gMessageSystemStats.StoredMsgs; + + memset( gCryptoKey, 0, sizeof(gCryptoKey) ); + ec = GenerateCryptoKey( CryptoSeed, CryptoSeedSize, gCryptoKey, sizeof(gCryptoKey) ); + if( ec != KEYGEN_RESULT_SUCCESS ) + return -6; +/* + memset( gCryptoIV, 0, sizeof(gCryptoIV) ); + ec = GenerateCryptoKey( CryptoSeed, CryptoSeedSize, gCryptoIV, sizeof(gCryptoIV) ); + if( ec != KEYGEN_RESULT_SUCCESS ) + return -7; +*/ + return 0; +} + + +// +// Message Create/Delete/Copy/Clone Funtions +// 'nuff said +// +int CreateNewMessage( Message **ppMessage, + unsigned int id, + int type, + int timestamp, + int waittime, + int priority, + int persist, + int waitstatus, + int closed, + int saved, + int orphaned, + void *msg_data, + void *reply_data, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ) +{ + Message *NewMsg; + + if ( ppMessage == NULL ) + return -1; + + // create new message + NewMsg = message_apphook_malloc(sizeof(Message)); + if( NewMsg == NULL ) + return -2; + + // setup message + NewMsg->id = id; + NewMsg->timestamp = timestamp; + NewMsg->type = type; + NewMsg->waittime = waittime; + NewMsg->priority = priority; + NewMsg->persist = persist; + NewMsg->waitstatus = waitstatus; + NewMsg->closed = closed; + NewMsg->saved = saved; + NewMsg->orphaned = orphaned; + NewMsg->msg_data = msg_data; + NewMsg->replyCB = replyCB; + NewMsg->killCB = killCB; + + NewMsg->reply_data = reply_data; + *ppMessage = NewMsg; + + return 0; +} + +int CloneMessageData( Message *dst, Message *src ) +{ + int ec; + DBQuery *query,*newquery; + FileTransferRequest_t *filerequest,*newfilerequest; + + if ( src == NULL || dst == NULL ) + return -1; + + if ( src->msg_data == NULL ) + { + dst->msg_data = NULL; + return 0; + } + + switch( src->type ) + { + case MESSAGE_TYPE_DB_QUERY: + query = (DBQuery*) src->msg_data; + ec = CloneDBQuery( &newquery, query, 1 ); // CreateDBQuery( &newquery, query->type, query->maxage, query->max_result_rows, query->query_data_size, query->query_data, 1 ); + if ( ec < 0 ) + return -2; + dst->msg_data = newquery; + break; + case MESSAGE_TYPE_FILE_TRANSFER_REQUEST: + filerequest = (FileTransferRequest_t*) src->msg_data; + ec = CloneFileTransferRequest(&newfilerequest, filerequest); + if ( ec < 0 ) + return -2; + dst->msg_data = newfilerequest; + break; + case MESSAGE_TYPE_PLAIN_TEXT: + dst->msg_data = message_apphook_malloc(strlen(src->msg_data) + 1 ); + if ( dst->msg_data == NULL ) + return -2; + strcpy( dst->msg_data, src->msg_data ); + break; + } + + return 0; +} + +int CloneMessageReply( Message *dst, Message *src ) +{ + int ec; + DBQueryResult *result,*newresult; + int *filereply,*newfilereply; + if ( src == NULL || dst == NULL ) + return -1; + + if ( src->reply_data == NULL ) + { + dst->reply_data = NULL; + return 0; + } + + switch( src->type ) + { + case MESSAGE_TYPE_DB_QUERY: + result = (DBQueryResult*) src->reply_data; + ec = CloneDBQueryResult( &newresult, result, 1, 1 ); // CreateDBQueryResult( &newresult, &result->query, 1, result->timestamp, result->error_code, result->result_row_size, result->result_rows, result->result_data, 1 ); + if ( ec < 0 ) + return -2; + dst->reply_data = newresult; + break; + case MESSAGE_TYPE_FILE_TRANSFER_REQUEST: + filereply = (int*) src->msg_data; + ec = CloneFileTransferReply(&newfilereply, filereply); + if ( ec < 0 ) + return -2; + dst->msg_data = newfilereply; + break; + case MESSAGE_TYPE_PLAIN_TEXT: + dst->reply_data = message_apphook_malloc(strlen(src->reply_data) + 1 ); + if ( dst->reply_data == NULL ) + return -2; + strcpy( dst->reply_data, src->reply_data ); + break; + } + + return 0; +} + +int CloneMessage( Message **ppDst, Message *Src, int copy_msg_data, int copy_reply_data ) +{ + int ec; + + if ( ppDst == NULL || Src == NULL ) + return -1; + + ec = CreateNewMessage( ppDst, Src->id, Src->type, Src->timestamp, Src->waittime, Src->priority, Src->persist, Src->waitstatus, Src->closed, Src->saved, Src->orphaned, NULL, NULL, Src->replyCB, Src->killCB ); + if ( ec < 0 ) + return -2; + + if ( ! copy_msg_data ) + (*ppDst)->msg_data = Src->msg_data; + else + { + ec = CloneMessageData( *ppDst, Src ); + if ( ec < 0 ) + { + FreeMessage( *ppDst, 0, 0 ); + } + } + + if ( ! copy_reply_data ) + (*ppDst)->reply_data = Src->reply_data; + else + { + ec = CloneMessageReply( *ppDst, Src ); + if ( ec < 0 ) + { + FreeMessage( *ppDst, copy_msg_data, 0 ); + } + } + + + return 0; +} +void FreeMessageData( Message *message, int free_msg_data, int free_reply_data ) +{ + if ( message == NULL ) + return; + + // prts_debug( "Freeing msg data for msg at %p, (msg_data = %p), (reply_msg = %p)\n", message, message->msg_data, message->reply_data ); + // free any message specific memory + switch(message->type) + { + case MESSAGE_TYPE_DB_QUERY: + if ( free_msg_data && message->msg_data != NULL ) + FreeDBQuery( message->msg_data, 1 ); + if ( free_reply_data && message->reply_data != NULL ) + FreeDBQueryResult( message->reply_data, 1, 1 ); + break; + case MESSAGE_TYPE_FILE_TRANSFER_REQUEST: + if ( free_msg_data && message->msg_data != NULL ) + FreeFileTransferRequest( message->msg_data ); + if ( free_reply_data && message->reply_data != NULL ) + FreeFileTransferReply( message->reply_data ); + break; + + case MESSAGE_TYPE_PLAIN_TEXT: + // msg is just a pointer to a string + // calling free on msg_data will be enough + // falls through + default: + // free msg_data and reply_data + if ( free_msg_data && message->msg_data != NULL ) + message_apphook_free( message->msg_data ); + if ( free_reply_data && message->reply_data != NULL ) + message_apphook_free( message->reply_data ); + break; + } + + return; +} + +void FreeMessage( Message *message, int free_msg_data, int free_reply_data ) +{ + if ( message == NULL ) + return; + + // prts_debug( "Freeing msg (id = %d) at %p\n", message->id, message ); + + // free message data fields + FreeMessageData( message, free_msg_data, free_reply_data ); + + // free message + message_apphook_free(message); + + // PrintMemAllocHistory(); + +} + + + +// +// Message Send Funtions +// These create new messages and link them onto gMessageList +// +int SendNewMessage( unsigned int *id, int type, + int waittime, int priority, int persist, + void *msg_data, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ) +{ + int ec; + Message *NewMsg; + ObjData *NewObj; + + // zero out the passed id value, that way if we fail, caller is given msg id 0 + // which is alway invalid (gNextMessageID starts at 1) + if ( id != NULL ) + *id = 0; + + ec = CreateNewMessage( &NewMsg, gNextMessageID, type, time(NULL), waittime, priority, persist, MESSAGE_OPEN, 0, 0, 0, msg_data, NULL, replyCB, killCB ); + if ( ec < 0 ) + return -1; + + // inc message id + gNextMessageID++; + gMessageSystemStats.TotalMsgs++; + + // for persistent messages, write message out to disk first thing + if ( NewMsg->persist == 1 ) + { + ec = StoreMessage(NewMsg); + if ( ec != MESSAGE_FILE_RESULT_SUCCESS ) + prts_debug( "Failed to store Message (id = %d)!\n", NewMsg->id ); + // keep chugging, not much can do about this err + // main loop will try to save again + } + + // if given a persistent message and we already have + // too many active persistent messages, then don't + // make this one active, it will have to wait for MsgLoop + // to restore it before it activates + if ( (gMessageSystemStats.ActiveMsgs >= MAX_ACTIVE_MESSAGES) + || + (NewMsg->persist == 1 + && gMessageSystemStats.ActivePersistentMsgs >= MAX_ACTIVE_PERSISTENT_MESSAGES) ) + { + int made_room = 0; + ObjData *node; + // check if there is a lower priority message that we can + // retire to make room for this message + // only bother to do this w/ persist messages + if ( NewMsg->persist == 1 ) + { + node = FindPersistentMessageNodeByHighestPriorityAndID(); + if ( node != NULL ) + { + Message *omsg = (Message *)node->data; + if ( omsg->priority > NewMsg->priority ) + { + // drop the old message to make room for the new one + prts_debug( "Dropping active message (id = %d) in favor of new msg (id = %d)\n", omsg->id, NewMsg->id ); + + // flag old message for dropping + // message loop will handle getting rid of it + omsg->waitstatus = MESSAGE_DROP; + made_room = 1; + + /* + if ( N2PopNode(node) != NULL ) + { + // prts_debug( "Freeing message (id = %d)\n", msg->id ); + FreeMessage( omsg, 1, 1 ); + message_apphook_free(node); + made_room = 1; + } + */ + } + } + } + + if ( ! made_room ) + { + // free message but still return it's id + if ( id != NULL ) + *id = NewMsg->id; + FreeMessage(NewMsg,1,1); // better hope the StoreMessage() above succeeded + return SEND_MESSAGE_SUCCESS; // this is normal behavior so no err + } + } + + + // create new data obj on MessageList to hold new message + if ( N2AddDataNode( &gMessageList, message_apphook_malloc, (void *)NewMsg, 0 ) != 0 ) + { + message_apphook_free(NewMsg); + return SEND_MESSAGE_MALLOC_ERR; + } + // point data obj at new message + NewObj = (ObjData *)gMessageList.prev; + NewObj->data = NewMsg; + + + if ( id != NULL ) + *id = NewMsg->id; + + return 0; +} + +int SendNewDBQueryMessage( unsigned int *id, + int query_type, int maxage, int max_result_rows, + int query_data_size, void *query_data, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ) +{ + int ec; + DBQuery *query = NULL; + + // zero out the passed id value, that way if we fail, caller is given msg id 0 + // which is alway invalid (gNextMessageID starts at 1) + if ( id != NULL ) + *id = 0; + + // create a query + ec = CreateDBQuery( &query, query_type, maxage, max_result_rows, query_data_size, query_data, 1 ); + if ( ec < 0 ) + { + return SEND_MESSAGE_MALLOC_ERR; + } + + + // now send new message with query as the payload + ec = SendNewMessage( id, MESSAGE_TYPE_DB_QUERY, waittime, priority, persist, query, replyCB, killCB ); + if ( ec != SEND_MESSAGE_SUCCESS ) + { + FreeDBQuery( query, 1 ); + return ec; + } + return SEND_MESSAGE_SUCCESS; +} + + +int SendNewDBQueryCacheUpdateMessage( unsigned int *id, + int query_type, + int query_data_size, void *query_data, + int result_row_size, int result_rows, void *result_data, + int waittime, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ) +{ + int ec; + DBQuery *query = NULL; + DBQueryResult *result = NULL; + Message *msg; + unsigned int MsgID = 0; + + if ( id != NULL ) + *id = MsgID; + + // create a query + ec = CreateDBQuery( &query, query_type, 1, result_rows, query_data_size, query_data, 1 ); + if ( ec < 0 ) + { + return SEND_MESSAGE_MALLOC_ERR; + } + + // create result + ec = CreateDBQueryResult( &result, query, 1, 0, DBQUERY_RESULT_SUCCESS, result_row_size, result_rows, result_data, 1 ); + if ( ec < 0 ) + { + FreeDBQuery( query, 1 ); + return SEND_MESSAGE_MALLOC_ERR; + } + + + // now send new message with query as the payload + ec = SendNewMessage( &MsgID, MESSAGE_TYPE_DB_QUERY, waittime, 1, 0, query, replyCB, killCB ); + if ( ec != SEND_MESSAGE_SUCCESS ) + { + FreeDBQuery( query, 1 ); + FreeDBQueryResult( result, 1, 1 ); + return ec; + } + // attach results to message + // when DBQuery thread gets sees an incoming message + // with a reply already attached, it will know to process + // message as a cache update + msg = FindMessageByID(MsgID); + if ( msg != NULL ) + { + msg->reply_data = result; + } + + if ( id != NULL ) + *id = MsgID; + + return SEND_MESSAGE_SUCCESS; +} + + +int SendNewFileTransferMessage( unsigned int *id, + FileTransferRequest_t *FileInfo, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ) +{ + int ec; + FileTransferRequest_t *FileInfoCopy = NULL; + unsigned int MsgID = 0; + + if ( id != NULL ) + *id = MsgID; + + if ( FileInfo == NULL ) + return SEND_MESSAGE_INVALID_PARAMS; + + // make a copy of the passed file info struct to put on msg + ec = CloneFileTransferRequest(&FileInfoCopy, FileInfo); + if ( ec < 0 ) + { + return SEND_MESSAGE_MALLOC_ERR; + } + + // now send new message with fileinfo as the payload + ec = SendNewMessage( id, MESSAGE_TYPE_FILE_TRANSFER_REQUEST, waittime, priority, persist, FileInfoCopy, replyCB, killCB ); + if ( ec != SEND_MESSAGE_SUCCESS ) + { + message_apphook_free(FileInfoCopy); + return ec; + } + return SEND_MESSAGE_SUCCESS; +} + + +// +// Message Storage Funtions +// These read/write messages to the disk, +// used for storing persitent messages so they can survive a game reboot +// also includes some funcs for examining pool of stored messages +// + + +// this guy looks for the file corresponding to the passed msg id and +// copies it's name (with path) into the passed string buffer +// do this b/c messages are stored with a file name of the format +// MsgID.Priority.msg +// so if you don't know the priority (which you can't know before loading msg) +// the you have to grope around the dir for the correct file +// the upside is that having the priority on the filename +// allows us to restore messages in the correct order w/o +// having open each message to check it's priority +int FindStoredMessage( unsigned int id, char *dst, int dst_len ) +{ + FsDH fdh; + char *filename; + unsigned int tmp; + + if ( dst == NULL || dst_len <= 0 ) + return -1; // error + + memset(dst,0,sizeof(dst)); + + if ( FsOpenDir(&fdh,gMessageStoreDir) < 0 ) // failed to open dir + return -1; // error + + while( (filename = FsReadDir(&fdh)) != NULL ) + { + if(filename[0] == '.' ) { continue; } // skip . and .. + tmp = atol(filename); + if ( tmp == id ) + { + // strncpy(dst,filename,dst_len); + sprintf(dst,"%s/%s",gMessageStoreDir,filename); + // dst[dst_len-1] = 0; // just to be safe + break; + } + } + FsCloseDir(&fdh); + + if ( dst[0] == 0 ) + return 0; // not found + else + return 1; // found +} + + + +int StoreMessage( Message *msg ) +{ + int ec; + char filename[256]; + + if ( msg == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + sprintf(filename, "%s/%u.%d.msg", gMessageStoreDir, msg->id, msg->priority ); + + // if we go over our limit of stored messages, then we just + // pretend to save the message + if ( gMessageSystemStats.StoredMsgs < MAX_STORED_MESSAGES ) + { + ec = SaveMessage( filename, msg ); + if ( ec != MESSAGE_FILE_RESULT_SUCCESS ) + return ec; + gMessageSystemStats.StoredMsgs++; + } + + msg->saved = 1; + return ec; +} + +int UnStoreMessage( Message *msg ) +{ + int ec; + char filename[256]; + + if ( msg == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + sprintf(filename, "%s/%u.%d.msg", gMessageStoreDir, msg->id, msg->priority ); + ec = unlink(filename); + if ( ec < 0 ) + { + // maybe that filename was not right (priority changed since saved?), + // try looking for the right filename for this message + ec = FindStoredMessage( msg->id, filename, sizeof(filename) ); + if( ec > 0 ) + ec = unlink(filename); // not much you can do if unlink fails + } + msg->saved = 0; + gMessageSystemStats.StoredMsgs--; + return MESSAGE_FILE_RESULT_SUCCESS; +} + + +int RestoreMessage( unsigned int id, int priority ) +{ + int ec; + ObjData *NewObj; + char filename[256]; + Message tmpmsg; + Message *restored_msg; + + + tmpmsg.msg_data = NULL; + tmpmsg.reply_data = NULL; + + sprintf(filename, "%s/%u.%d.msg", gMessageStoreDir, id, priority ); + + ec = LoadMessage( filename, &tmpmsg ); + if ( ec != MESSAGE_FILE_RESULT_SUCCESS ) + { + // maybe that was not the right filename (priority changed since message was sent??) + ec = FindStoredMessage( id, filename, sizeof(filename) ); + if( ec <= 0 ) // msg not found + return -1; + + ec = LoadMessage( filename, &tmpmsg ); + if( ec < 0 ) + return -1; + } + + // clone the message we just loaded + // only copy a ptr to msg_data + // this works b/c we allocated space for msg_data when tmpmsg is loaded + // and tmpmsg won't live past this func + ec = CloneMessage( &restored_msg, &tmpmsg, 0, 0 ); + if ( ec < 0 ) + { + // free memory we used for msg_data in tmpmsg + FreeMessageData( &tmpmsg, 1, 1 ); + return -2; + } + + // try to link new msg back into msg list + // create new data obj on MessageList to hold restored message + if ( N2AddDataNode( &gMessageList, message_apphook_malloc, (void *)restored_msg, 0 ) != 0 ) + { + // clean up restored msg before bailing + FreeMessage( restored_msg, 1, 1 ); + return -3; + } + + // refresh msg's timestamp + restored_msg->timestamp = time(NULL); + restored_msg->waitstatus = MESSAGE_OPEN; + + // point data obj at new message + NewObj = (ObjData *)gMessageList.prev; + NewObj->data = restored_msg; + + + return 0; +} + +// this guy walks msg storage dir and returns +// the number of messages found there +int CountStoredMessages() +{ + int count = 0; + FsDH fdh; + char dirname[512]; + char *filename; + + // construct dir + sprintf(dirname, "%s",gMessageStoreDir ); + + // walk files in dir + if ( FsOpenDir(&fdh,dirname) < 0 ) // failed to open dir + return count; + + while( (filename = FsReadDir(&fdh)) != NULL ) + { + // check if msg id is higher than what we've seen so far + if(filename[0] == '.' ) { continue; } // skip . and .. + count++; + } + FsCloseDir(&fdh); + return count; +} + + +// this guy walks msg storage dir and returns +// highest msg id number found +// run this at start up to make sure +// new message id's don't overlap with any +// msgs in storage +unsigned int FindNextSafeMessageID() +{ + unsigned int next; + unsigned int tmp; + FsDH fdh; + + char dirname[512]; + char *filename; + + // we start counting at 1 so 0 is never a valid msg id + // do this so SendNewMessage can set message id = 0 on failure + // to create a new message + next = 1; + + // construct dir + sprintf(dirname, "%s",gMessageStoreDir ); + + if ( FsOpenDir(&fdh,dirname) < 0 ) // failed to open dir + return next; + + while( (filename = FsReadDir(&fdh)) != NULL ) + { + // check if msg id is higher than what we've seen so far + if(filename[0] == '.' ) { continue; } // skip . and .. + tmp = atol(filename); + if ( tmp >= next ) + next = tmp + 1; + } + FsCloseDir(&fdh); + + // construct dir + sprintf(dirname, "%s",gMessageStoreDir ); + + return next; +} + + + +// this guy walks msg storage dir and +// restores the msg with the lowest priority +// and lowest msg id that is not already on the active list +// this ensures that we restore our messages in the +// same order that they were stored +// meaning order dependent queries can be +// stored and restored safely +// (ex. an add player query, followed by a bunch of player stat queries) +// and respect their priority settings +unsigned int RestoreNextStoredMessage() +{ + static int retries = 0; + + int p; + int priority; + + unsigned int tmp; + unsigned int id; + int ec; + int found = 0; + Message *msg; + FsDH fdh; + char dirname[512]; + char *filename; + + tmp = 0; + // id = 0 - 1; // roll id over to highest possible value (anything we find should be less than this) + id = 0; + + // construct dir + sprintf(dirname, "%s",gMessageStoreDir ); + + // walk files in dir + if ( FsOpenDir(&fdh,dirname) < 0 ) // failed to open dir + return -1; + + while( (filename = FsReadDir(&fdh)) != NULL ) + { + if(filename[0] == '.' ) { continue; } // skip . and .. + // format of filename is 'MsgID.Priority.msg' + // first part of filename is msg id + tmp = atol(filename); + // check if msg is already on the active list + msg = FindMessageByID(tmp); + if ( msg != NULL ) + continue; + // step ahead in filename until we are past first '.' + while(filename[0] != '.' && filename[0] != '\0' ) + filename++; + if ( filename[0] == '.' ) + filename++; + + p = atoi(filename); + + if ( found == 0 ) + { + id = tmp; + priority = p; + } + found = 1; + + if ( p > priority ) + continue; + if ( p < priority ) + { + id = tmp; + priority = p; + } + else // p == priority + { + // check if msg id is smaller than anything we've seen so far w/ this priority + if ( tmp < id ) + { + id = tmp; + priority = p; + } + } + + } + FsCloseDir(&fdh); + + if ( found ) + { + ec = RestoreMessage( id, priority ); + if ( ec != 0 ) + { + retries++; + if ( retries >= 5 ) + { + // if the load failed 5 times in a row, + // then delete the message + // otherwise we can get stuck trying to restore + // the same broken message over and over again + // this works b/c we always try to restore the msgs in + // the same order everytime, so retries is the number of + // retries on this message (otherwise we'd need a list to track + // retries for each message file seperately) + sprintf(dirname, "%s/%u.msg",gMessageStoreDir, id ); + prts_debug( "Message Loop: deleting broken message file '%s'\n", dirname ); + unlink(dirname); + gMessageSystemStats.StoredMsgs--; + retries = 0; + return -3; + } + return -2; + } + else + { + retries = 0; + return 1; // worked + } + } + else + { + retries = 0; + return 0; // no messages to restore + } + +} + + +// writes a message to an open filehandle +int WriteMessageToFile( FILE *fd, Message *msg ) +{ + int ec; + Message tmpmsg; + + if ( msg == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + if ( fd == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + // note that not although all fields are saved out + // some things like 'id' and 'saved' are re-assigned + // at load time, better this than to read them out of a file + // also some items simply cannot be saved (ie callback funcs) + + + tmpmsg = *msg; + // tmpmsg.id = 0; + tmpmsg.msg_data = NULL; + tmpmsg.reply_data = NULL; + tmpmsg.replyCB = NULL; + tmpmsg.killCB = NULL; + + ec = WriteDataWithCRCToFile( &tmpmsg, sizeof(tmpmsg), 1, fd ); + if ( ec < 0 ) + return MESSAGE_FILE_RESULT_WRITE_ERR; + + // for now we only worry about saving msg_data, not reply_data + // also we only worry about saving data for DBQuery messages + // for now the the only messages that we'd write to the disk + // are DataBase updates which we want to post even if the game crashes + // or which we want to write to the disk while we wait for the game + // to come online so it can connect to the server and send the updates + if ( msg->msg_data != NULL ) + { + switch(msg->type) + { + case MESSAGE_TYPE_DB_QUERY: + ec = WriteDBQueryToFile( fd, msg->msg_data ); + if ( ec != DBQUERY_FILE_RESULT_SUCCESS ) + return ec; + break; + default: // no way to save other messages right now + break; + } + } + + return MESSAGE_FILE_RESULT_SUCCESS; + +} + +// reads message from open filehandle +int LoadMessageFromFile( FILE *fd, Message *msg ) +{ + + int ec; + + if ( msg == NULL || msg->msg_data != NULL || msg->reply_data != NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + if ( fd == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + // note that not all fields are used as loaded out + // better for things like 'id' and 'saved' to be assigned + // at load time, then to read them out of a file + // also some items simply cannot be saved (ie callback funcs) + + ec = ReadDataWithCRCFromFile( msg, sizeof(Message), 1, fd ); + if ( ec < 0 ) + return MESSAGE_FILE_RESULT_READ_ERR; + + // msg->id = gNextMessageID; // dynamically assign id, ensures we don't end with id conflict by loading id values from a previous game + msg->saved = 1; // if you loaded it from a file, then by def it has been saved + msg->orphaned = 1; // msgs loaded from file are also always orphaned (game has no ptrs or callbacks to them) + msg->closed = 0; // if message were closed, you would not have bothered to write it to disk + msg->killCB = NULL; // no way to save these two + msg->replyCB = NULL; + msg->msg_data = NULL; // init these as null just to be safe + msg->reply_data = NULL; + + // for now we only worry about loading/saving msg_data, not reply_data + // also we only worry about loading/saving data for DBQuery messages + // for now the the only messages that we'd write to the disk + // are DataBase updates which we want to post even if the game crashes + // or which we want to write to the disk while we wait for the game + // to come online so it can connect to the server and send the updates + switch(msg->type) + { + case MESSAGE_TYPE_DB_QUERY: + // make space for query + ec = CreateDBQuery( (DBQuery**)&msg->msg_data, 0, 0, 0, 0, NULL, 0 ); + if ( ec < 0 ) + return MESSAGE_FILE_RESULT_MALLOC_ERR; + ec = LoadDBQueryFromFile( fd, msg->msg_data ); + if ( ec != DBQUERY_FILE_RESULT_SUCCESS ) + { + // free query plus any data that got attached to it + FreeDBQuery( (DBQuery*)msg->msg_data, 1 ); + return ec; + } + break; + default: // no way to load/save other messages right now + break; + } + + // gNextMessageID++; + return MESSAGE_FILE_RESULT_SUCCESS; + +} + + +// writes a message to an open filehandle +int WriteMessageToCryptoFile( CryptoFileHandle *cfh, Message *msg ) +{ + int ec; + Message tmpmsg; + + if ( msg == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + if ( cfh == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + // note that not although all fields are saved out + // some things like 'id' and 'saved' are re-assigned + // at load time, better this than to read them out of a file + // also some items simply cannot be saved (ie callback funcs) + + + tmpmsg = *msg; + // tmpmsg.id = 0; + tmpmsg.msg_data = NULL; + tmpmsg.reply_data = NULL; + tmpmsg.replyCB = NULL; + tmpmsg.killCB = NULL; + + ec = WriteDataWithCRCToCryptoFile( &tmpmsg, sizeof(tmpmsg), 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return MESSAGE_FILE_RESULT_WRITE_ERR; + + // for now we only worry about saving msg_data, not reply_data + // also we only worry about saving data for DBQuery messages + // for now the the only messages that we'd write to the disk + // are DataBase updates which we want to post even if the game crashes + // or which we want to write to the disk while we wait for the game + // to come online so it can connect to the server and send the updates + if ( msg->msg_data != NULL ) + { + switch(msg->type) + { + case MESSAGE_TYPE_DB_QUERY: + ec = WriteDBQueryToCryptoFile( cfh, msg->msg_data ); + if ( ec != DBQUERY_FILE_RESULT_SUCCESS ) + return ec; + break; + default: // no way to save other messages right now + break; + } + } + + return MESSAGE_FILE_RESULT_SUCCESS; + +} + +// reads message from open filehandle +int LoadMessageFromCryptoFile( CryptoFileHandle *cfh, Message *msg ) +{ + + int ec; + + if ( msg == NULL || msg->msg_data != NULL || msg->reply_data != NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + if ( cfh == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + // note that not all fields are used as loaded out + // better for things like 'id' and 'saved' to be assigned + // at load time, then to read them out of a file + // also some items simply cannot be saved (ie callback funcs) + + ec = ReadDataWithCRCFromCryptoFile( msg, sizeof(Message), 1, cfh ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + if ( ec == CRYPTOFILE_RESULT_EOF ) + return MESSAGE_FILE_RESULT_EOF; + + return MESSAGE_FILE_RESULT_READ_ERR; + } + + msg->saved = 1; // if you loaded it from a file, then by def it has been saved + msg->orphaned = 1; // msgs loaded from file are also always orphaned (game has no ptrs or callbacks to them) + msg->closed = 0; // if message were closed, you would not have bothered to write it to disk + msg->killCB = NULL; // no way to save these two + msg->replyCB = NULL; + msg->msg_data = NULL; // init these as null just to be safe + msg->reply_data = NULL; + + // for now we only worry about loading/saving msg_data, not reply_data + // also we only worry about loading/saving data for DBQuery messages + // for now the the only messages that we'd write to the disk + // are DataBase updates which we want to post even if the game crashes + // or which we want to write to the disk while we wait for the game + // to come online so it can connect to the server and send the updates + switch(msg->type) + { + case MESSAGE_TYPE_DB_QUERY: + // make space for query + ec = CreateDBQuery( (DBQuery**)&msg->msg_data, 0, 0, 0, 0, NULL, 0 ); + if ( ec < 0 ) + return MESSAGE_FILE_RESULT_MALLOC_ERR; + ec = LoadDBQueryFromCryptoFile( cfh, msg->msg_data ); + if ( ec != DBQUERY_FILE_RESULT_SUCCESS ) + { + if ( ec == DBQUERY_FILE_RESULT_EOF ) + return MESSAGE_FILE_RESULT_EOF; + + // free query plus any data that got attached to it + FreeDBQuery( (DBQuery*)msg->msg_data, 1 ); + return MESSAGE_FILE_RESULT_READ_ERR; + } + break; + default: // no way to load/save other messages right now + break; + } + + // gNextMessageID++; + return MESSAGE_FILE_RESULT_SUCCESS; + +} + + +int SaveMessage( char *filename, Message *msg ) +{ + CryptoFileHandle cfh; + int ec; + unsigned char FileIV[CRYPTO_IV_LEN]; + GenerateFileIV( filename, FileIV, sizeof(FileIV) ); + + if ( msg == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + if ( filename == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + ec = OpenCryptoFile( &cfh, filename, "wb", CRYPTO_ENCRYPT, CRYPTO_AES256, gCryptoKey, sizeof(gCryptoKey), FileIV, sizeof(FileIV) ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FOPEN_ERR; + ec = WriteMessageToCryptoFile(&cfh,msg); + if( CloseCryptoFile(&cfh) != CRYPTOFILE_RESULT_SUCCESS ) + return DBQUERY_FILE_RESULT_FCLOSE_ERR; + + return ec; + +} + +int LoadMessage( char *filename, Message *msg ) +{ + CryptoFileHandle cfh; + int ec; + unsigned char FileIV[CRYPTO_IV_LEN]; + GenerateFileIV( filename, FileIV, sizeof(FileIV) ); + + if ( msg == NULL || msg->msg_data != NULL || msg->reply_data != NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + if ( filename == NULL ) + return MESSAGE_FILE_RESULT_INVALID_PARAMS; + + ec = OpenCryptoFile( &cfh, filename, "rb", CRYPTO_DECRYPT, CRYPTO_AES256, gCryptoKey, sizeof(gCryptoKey), FileIV, sizeof(FileIV) ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + return MESSAGE_FILE_RESULT_FOPEN_ERR; + ec = LoadMessageFromCryptoFile(&cfh,msg); + if( CloseCryptoFile(&cfh) != CRYPTOFILE_RESULT_SUCCESS ) + return MESSAGE_FILE_RESULT_FCLOSE_ERR; + + return ec; + +} + + + +// +// Message Search Funtion +// function to find messages by ID and it's helper func +// + +// helper func +int MatchMsgByID( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *msg; + unsigned int id; + + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return -1; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return -1; + + if ( arg == NULL ) + return -1; + + id = *(unsigned int*)arg; + + if ( id == msg->id ) + return 0; + return -1; +} + +Message *FindMessageByID( unsigned int id ) +{ + ObjData *Obj; + + Obj = (ObjData*)N2Search( gMessageList.next, &id, MatchMsgByID ); + if ( Obj == NULL ) + return NULL; + + return (Message *)Obj->data; +} + + + + +// obj is ptr to DataObj (item on MessageList) +// arg is ptr to ptr to ObjData node +// checks obj and arg to see if +// arg should be pointed to obj +// used by FindPersistentMessageNodeByHighestPriorityAndID +int MatchPersistentMessageOnHighPriorityAndID( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *objmsg; + ObjData **ppArgObj; + Message *argmsg; + + if ( arg == NULL || DataObj == NULL + || DataObj->lnk.type != N2TYPE_OBJ + || DataObj->lnk.sub != OBJSUB_DATA + || DataObj->data == NULL ) + return -1; + + ppArgObj = (ObjData **)arg; + + if ( ppArgObj == NULL ) + return -1; + + if ( *ppArgObj != NULL ) + { + argmsg = (Message*)(*ppArgObj)->data; + } + + objmsg = (Message *)DataObj->data; + + // skip non-persistent messages + if ( (!objmsg->persist) ) + return 0; + + // skip messages that have been answered already or are marked to be dropped + if ( objmsg->waitstatus == MESSAGE_ANSWERED + || objmsg->waitstatus == MESSAGE_DROP ) + // || objmsg->waitstatus == MESSAGE_ANSWERED_TENTATIVE + // || objmsg->waitstatus == MESSAGE_QUEUED ) + return 0; + + // take first msg we find, + // after that take the one with the highest priority number + // after that take the one with the highest id number + if( *ppArgObj == NULL + || argmsg->priority < objmsg->priority + || argmsg->id < objmsg->id ) + *ppArgObj = DataObj; + return 0; +} + +// walks through message list searching for the persistent message +// with the highest priority and highest id number, +// and returns pointer to that list node +// or NULL if no message is found +// used to check for a lower priority message +// when accepting a new message w/ too many active messages +ObjData *FindPersistentMessageNodeByHighestPriorityAndID() +{ + ObjData *node = NULL; + N2Walk(gMessageList.next, &node, MatchPersistentMessageOnHighPriorityAndID ); + + return node; +} + + + + +// +// Message Introspection Funtions +// Wrapper functions for the game to use when +// interacting with messages (eg. closing them or pull information out of them) +// +int CheckMessageStatus( Message *message ) +{ + // if passed a null ptr (as in case where CheckMessageByID() is called w/ bum msg id) + // just return a positive result + // otherwise game might get stuck spinning on a bugus/stored message id + // this is safe to do b/c all other instropection calls on the + // bogus message id will return err results, so game should + // interpret results as message was answered with an error + if ( message == NULL ) + return MESSAGE_ANSWERED; + + // also, if the message has been orphaned then + // return a postive result + // when a persistent message's waittime runs up it is marked as + // orphaned, but not answered (it sticks around until it is really answered) + // return answered here so the game will stop waiting on the message + // again, this is safe to to b/c introspection calls will return err results + if ( message->persist == 1 && message->orphaned == 1 ) + return MESSAGE_ANSWERED; + + return message->waitstatus; +} + +int CloseOutMessage( Message *message ) +{ + if (message == NULL ) + return -1; + + // don't let the game close out + // an orphaned message that has not been answered + // these messages stick around until they are answered + if ( message->persist == 1 + && message->orphaned == 1 + && message->waitstatus != MESSAGE_ANSWERED ) + { + prts_debug( "REFUSING TO CLOSE ORPHANED MESSAGE THAT IS NOT ANSWERED (msg id %d)\n", message->id ); + return 0; + } + message->closed = 1; + return 0; +} + +int CheckFileTransferMsgErrorCode( Message *message ) +{ + int *reply; + + if (message == NULL + || message->type != MESSAGE_TYPE_FILE_TRANSFER_REQUEST + || message->reply_data == NULL ) + return -1; + + reply = (int*)message->reply_data; + + return *reply; +} + +int CheckFileTransferMsgErrorCodeByID( unsigned int id ) +{ + return CheckFileTransferMsgErrorCode( FindMessageByID(id) ); +} + +int CheckDBQueryMsgErrorCode( Message *message ) +{ + DBQueryResult *result; + if (message == NULL + || message->type != MESSAGE_TYPE_DB_QUERY + || message->reply_data == NULL ) + return -1; + + result = (DBQueryResult*)message->reply_data; + + return result->error_code; +} + +int CheckDBQueryMsgResultCount( Message *message ) +{ + DBQueryResult *result; + if (message == NULL + || message->type != MESSAGE_TYPE_DB_QUERY + || message->reply_data == NULL ) + return -1; + + result = (DBQueryResult*)message->reply_data; + + return result->result_rows; +} + +void *GetDBQueryMsgResultsData( Message *message ) +{ + DBQueryResult *result; + + if ( message == NULL + || message->type != MESSAGE_TYPE_DB_QUERY + || message->reply_data == NULL ) + return NULL; + + result = (DBQueryResult*)message->reply_data; + + return result->result_data; + +} + + +int CopyDBQueryMsgResultsData( Message *message, void *dest, int size ) +{ + DBQueryResult *result; + int cpy_size; + int rslt_size; + + if (dest == NULL || message == NULL + || message->type != MESSAGE_TYPE_DB_QUERY + || message->reply_data == NULL ) + return -1; + + result = (DBQueryResult*)message->reply_data; + + rslt_size = result->result_row_size * result->result_rows; + + // check for no data to copy + if ( rslt_size == 0 || result->result_data == NULL ) + return 0; + + + // don't copy more data than is in result + // or more than user asked for + cpy_size = size; + if ( cpy_size > rslt_size ) + cpy_size = rslt_size; + + + // first null it all out + memset( dest, 0, size ); + memcpy( dest, result->result_data, cpy_size ); + + // return number of bytes copied + return cpy_size; +} + + +void *GetDBQueryMsgQueryData( Message *message ) +{ + DBQuery *query; + + if ( message == NULL + || message->type != MESSAGE_TYPE_DB_QUERY + || message->msg_data == NULL ) + return NULL; + + query = (DBQuery*)message->msg_data; + + return query->query_data; + +} + +int GetDBQueryMsgResultsTimestamp( Message *message ) +{ + DBQueryResult *result; + + if ( message == NULL + || message->type != MESSAGE_TYPE_DB_QUERY + || message->reply_data == NULL ) + return -1; + + result = (DBQueryResult*)message->reply_data; + + return result->timestamp; +} + + +int CheckMessageStatusByID( unsigned int id ) +{ + return CheckMessageStatus(FindMessageByID(id)); +} + +int CloseOutMessageByID( unsigned int id ) +{ + return CloseOutMessage(FindMessageByID(id)); +} +int CheckDBQueryMsgErrorCodeByID( unsigned int id ) +{ + return CheckDBQueryMsgErrorCode(FindMessageByID(id)); +} +int CheckDBQueryMsgResultCountByID( unsigned int id ) +{ + return CheckDBQueryMsgResultCount(FindMessageByID(id)); +} +int CopyDBQueryMsgResultsDataByID( unsigned int id, void *dest, int size ) +{ + return CopyDBQueryMsgResultsData( FindMessageByID(id), dest, size ); +} + +void *GetDBQueryMsgResultsDataByID( unsigned int id ) +{ + return GetDBQueryMsgResultsData( FindMessageByID(id) ); +} + +void *GetDBQueryMsgQueryDataByID( unsigned int id ) +{ + return GetDBQueryMsgQueryData( FindMessageByID(id) ); +} + +int GetDBQueryMsgResultsTimestampByID( unsigned int id ) +{ + return GetDBQueryMsgResultsTimestamp( FindMessageByID(id) ); +} + + + + + + + +// +// Message Print Funtions +// use to print messages to stdout when debugging +// +int PrintMessageDataObj( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *msg; + int *i; + + i = (int*)arg; + (*i)++; + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return 0; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return 0; + + prts_debug ("Message %d:\n", *i ); + PrintMessage( msg ); + + return 0; +} + +int PrintMessage( Message *msg ) +{ + if ( msg == NULL ) + return 0; + + prts_debug (" id: %d\n", msg->id ); + prts_debug (" timestamp: %d\n", msg->timestamp ); + prts_debug (" type: %d\n", msg->type ); + prts_debug (" waittime: %d\n", msg->waittime ); + prts_debug (" priority: %d\n", msg->priority ); + prts_debug (" waitstatus: %d\n", msg->waitstatus ); + prts_debug (" closed: %d\n", msg->closed ); + prts_debug (" persist: %d\n", msg->persist ); + prts_debug (" saved: %d\n", msg->saved ); + prts_debug (" orphaned: %d\n", msg->orphaned ); + + switch( msg->type) + { + case MESSAGE_TYPE_PLAIN_TEXT: + prts_debug(" msg_data: %s (%p)\n", (char*)msg->msg_data, msg->msg_data ); + break; + case MESSAGE_TYPE_DB_QUERY: + prts_debug(" msg_data: addr = %p\n", msg->msg_data ); + PrintDBQuery( msg->msg_data, " msg_data: " ); + prts_debug(" reply_data: addr = %p\n", msg->reply_data ); + PrintDBQueryResult( msg->reply_data, " reply_data: " ); + break; + } + + + return 0; +} + +void PrintMessageStats() +{ + char *buf; + prts_debug( "Message System Stats:\n" ); + prts_debug( " Messages Counts:\n" ); + prts_debug( " Total Messages: %d\n", gMessageSystemStats.TotalMsgs ); + prts_debug( " Active Messages: %d\n", gMessageSystemStats.ActiveMsgs ); + prts_debug( " Active Persistent Messages: %d\n", gMessageSystemStats.ActivePersistentMsgs ); + prts_debug( " Stored Messages: %d\n", gMessageSystemStats.StoredMsgs ); + prts_debug( " Active DBQueries: %d\n", gMessageSystemStats.ActiveMsgsByType[1] ); + prts_debug( " Active FTP Requests: %d\n", gMessageSystemStats.ActiveMsgsByType[2] ); + prts_debug( " Active Client Sessions: %d\n", gDBQuerySystemStats.ActiveDBClientSessions ); + + prts_debug( " Queue Sizes:\n" ); + prts_debug( " DBQueryInQueue: %d\n", gDBQuerySystemStats.DBQueryInQueueSize ); + prts_debug( " DBQueryInQueue: %d\n", gDBQuerySystemStats.DBQueryOutQueueSize ); +// prts_debug( " DBClientInQueue: %d\n", gMessageSystemStats.DBClientInQueueSize ); +// prts_debug( " DBClientOutQueue: %d\n", gMessageSystemStats.DBClientOutQueueSize ); + prts_debug( " Error Counts:\n" ); + prts_debug( " Failed Connect Attempts: %d\n", gDBQuerySystemStats.DBClientNoConnectErrs ); + prts_debug( " Transmit/Recv Errs: %d\n", gDBQuerySystemStats.DBClientTransmitErrs ); + prts_debug( " Server/Query Errs: %d\n", gDBQuerySystemStats.DBClientServerErrs ); + prts_debug( " Connection/Failure Times:\n" ); + buf = ctime(&gDBQuerySystemStats.DBClientLastSuccessfulServerConnect); + prts_debug( " Last Successful Connection: %s", buf ); + buf = ctime(&gDBQuerySystemStats.DBClientLastSuccessfulQuery); + prts_debug( " Last Successful Query: %s",buf ); + buf = ctime(&gDBQuerySystemStats.DBClientLastFailedServerConnect); + prts_debug( " Last Failed Connection: %s", buf ); + buf = ctime(&gDBQuerySystemStats.DBClientLastSuccessfulQuery); + prts_debug( " Last Failed Query: %s", buf ); + +} + +// +// Message Flush Funtions +// func to flush out current message list and its helper func +// + +// helper func +int FlushMessageDataObj( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *msg; + + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return 0; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return 0; + + // clear message callback pointers + msg->killCB = NULL; + msg->replyCB = NULL; + // do not flush persistant messages + if ( msg->persist == 1 ) + { + // but do mark them orphaned + msg->orphaned = 1; + return 0; + } + + prts_debug( "Flushing non-pesistent message (id = %d)\n", msg->id ); + if ( N2PopNode(obj) != NULL ) + { + // prts_debug( "Freeing message (id = %d)\n", msg->id ); + FreeMessage( msg, 1, 1 ); + message_apphook_free(obj); + } + return 0; +} + + +// Flush out any outstanding messages +// persistent messages are kept, but they're marked orphaned and their callbacks are NULL'd +void FlushMessages() +{ + N2Walk( &gMessageList, NULL, FlushMessageDataObj ); +} + + + + +// +// Message Loop Funtions +// MessageLoop() and helper functions used for processing/updating messages +// on the gMessageList +// + +void ProcessNewMsg(Message *msg) +{ + int ec; + Message *newmsg; + if ( msg == NULL ) + return; + switch(msg->type) + { + case MESSAGE_TYPE_PLAIN_TEXT: + // these are test messages, don't do anything with them + msg->waitstatus = MESSAGE_QUEUED; + break; + case MESSAGE_TYPE_DB_QUERY: + // prts_debug( "Processing new/retried DB Query msg\n" ); + // make a copy of message and put it in the InQue for + // our DBquery thread + ec = CloneMessage( &newmsg, msg, 1, 1 ); + if ( ec == 0 ) + { + ec = ThreadSafeQueuePush( &gDBQueryInQue, (void *)newmsg ); + if ( ec == TSQ_RESULT_SUCCESS ) + { + msg->waitstatus = MESSAGE_QUEUED; + } + else + { + prts_debug( "Failed to queue DB Query msg\n" ); + // failed to go on queue for some reason + // delete copied message and try again later + FreeMessage( newmsg, 1, 1 ); + } + } + else // else (failed to copy message, leave it on list and try again later) + prts_debug( "Failed to clone new DB Query msg\n" ); + break; + case MESSAGE_TYPE_FILE_TRANSFER_REQUEST: + // prts_debug( "Processing new/retried file transfer msg\n" ); + // make a copy of message and put it in the InQue for + // our DBquery thread + ec = CloneMessage( &newmsg, msg, 1, 1 ); + if ( ec == 0 ) + { + ec = ThreadSafeQueuePush( &gFileTransferInQue, (void *)newmsg ); + if ( ec == TSQ_RESULT_SUCCESS ) + msg->waitstatus = MESSAGE_QUEUED; + else + { + prts_debug( "Failed to queue file transfer msg\n" ); + // failed to go on queue for some reason + // delete copied message and try again later + FreeMessage( newmsg, 1, 1 ); + } + } + else // else (failed to copy message, leave it on list and try again later) + prts_debug( "Failed to clone new filetransfer msg\n" ); + break; + } +} + + +int ProcessDroppedMsg(Message *msg) +{ + int ec; + // Message *newmsg; + if ( msg == NULL ) + return 0; + switch(msg->type) + { + case MESSAGE_TYPE_PLAIN_TEXT: + // these are test messages, don't do anything with them + FreeMessage( msg, 1, 1 ); + break; + case MESSAGE_TYPE_DB_QUERY: + // prts_debug( "Processing dropped DB Query msg\n" ); + // put dropped msg in the InQue for + // our DBquery thread + ec = ThreadSafeQueuePush( &gDBQueryInQue, (void *)msg ); + if ( ec != TSQ_RESULT_SUCCESS ) + { + prts_debug( "Failed to queue DB Query msg\n" ); + return -1; + } + break; + case MESSAGE_TYPE_FILE_TRANSFER_REQUEST: + ec = ThreadSafeQueuePush( &gFileTransferInQue, (void *)msg ); + if ( ec != TSQ_RESULT_SUCCESS ) + { + prts_debug( "Failed to queue File XFR msg\n" ); + return -1; + } + break; + } + return 0; +} + + +void AnswerDBQueryMsgFromDiskCache( Message *msg ) +{ + int ec; + DBQuery *query; + if ( msg == NULL || msg->type != MESSAGE_TYPE_DB_QUERY || msg->msg_data == NULL ) + return; + + // if we got here it means the DB Query Thread did not even + // send back a tenative answer to our query + // since this is the first thing the DB Query Thread does when it + // gets a message, the DB Query thread is most likely broken :( + // so hit the disk cache directly to look for an answer + + query = (DBQuery*)msg->msg_data; + + // do not answer persitent messages or messages w/ a maxage of 0 or less + // from the cache + if ( msg->persist == 1 || query->maxage <= 0 ) + return; + + prts_debug( "Making last ditch effort to answer dbquery msg from disk cache\n" ); + + // search disk cache for a answer + msg->reply_data = SearchDBQueryResultCacheFiles(query); + if ( msg->reply_data == NULL ) // cache miss + { + prts_debug( "No answer dbquery msg found in disk cache\n" ); + // attempt to create a cache miss result for msg + ec = CreateDBQueryResult( (DBQueryResult**) &msg->reply_data, (DBQuery*)msg->msg_data, 1, time(NULL), DBQUERY_RESULT_CACHE_MISS, 0, 0, NULL, 0 ); + if ( ec < 0 ) + { + // failed to even create a cache miss result! + msg->reply_data = NULL; + } + } + else + { + prts_debug( "Answer dbquery msg found in disk cache\n" ); + } +} + + + + + +void DoOrphanCallback(Message *msg) +{ + if ( msg == NULL ) + return; + switch(msg->type) + { + case MESSAGE_TYPE_PLAIN_TEXT: + break; + case MESSAGE_TYPE_DB_QUERY: + DoDBQueryOrphanCallback(msg); + break; + case MESSAGE_TYPE_FILE_TRANSFER_REQUEST: + break; + } +} + +// some quick accounting we do whenever a message is closed +void DoMessageAccounting( Message *msg ) +{ + int t; + DBQuery *query; + DBQueryResult *result; + if ( msg == NULL ) + return; + + switch( msg->type ) + { + case MESSAGE_TYPE_DB_QUERY: + query = msg->msg_data; + result = msg->reply_data; + if ( query == NULL || result == NULL ) + return; + t = time(NULL); + gDBQuerySystemStats.DBQueryCountByType[query->type]++; + gDBQuerySystemStats.DBQueryResultTimestampsByType[query->type] = result->timestamp; + if ( t - (result->timestamp) > 0 ) + { + gDBQuerySystemStats.DBQueryTotalAgeTimesByType[query->type] += (t - (result->timestamp)); + if ( gDBQuerySystemStats.DBQueryCountByType[query->type] > 0 ) + gDBQuerySystemStats.DBQueryAvgAgeTimesByType[query->type] = gDBQuerySystemStats.DBQueryTotalAgeTimesByType[query->type] / gDBQuerySystemStats.DBQueryCountByType[query->type]; + } + break; + } + + return; +} + +int UpdateMessageDataObj( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message *msg; + int t; + + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return 0; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return 0; + + + t = time(NULL); + + // do some quick accounting + gMessageSystemStats.ActiveMsgs++; + gMessageSystemStats.ActiveMsgsByType[msg->type]++; + if( msg->persist == 1 ) + gMessageSystemStats.ActivePersistentMsgs++; + + // check if msg has been closed + if ( msg->closed == 1 ) + { + // prts_debug( "Message closed (id = %d)\n", msg->id ); + if ( msg->saved == 1 ) // if msg stored, delete it from storage + { + // prts_debug( "Unstoring msg (id = %d)\n", msg->id ); + UnStoreMessage(msg); + } + // some quick accounting + DoMessageAccounting(msg); + + // prts_debug( " Unlinking Msg\n" ); + if ( N2PopNode(obj) != NUL ) + { + // prts_debug( " Freeing Msg Memory\n" ); + FreeMessage(msg, 1, 1 ); + message_apphook_free(obj); + return 0; + } + } + + + // check if message has been around for just too darn long + // persistant msgs are not deleted until they are answered or game closes them + if( msg->persist != 1 && + t > msg->timestamp + MAX_MESSAGE_LIFETIME ) + { + // execute callback + if ( msg->killCB != NULL ) + { + msg->killCB(msg); + } + + prts_debug( "Message closed by MsgLoop (too old) (id = %d)\n", msg->id ); + // prts_debug( " Unlinking Msg\n" ); + if ( N2PopNode(obj) != NUL ) + { + // prts_debug( " Freeing Msg Memory\n" ); + FreeMessage(msg, 1, 1 ); + message_apphook_free(obj); + return 0; + } + } + + + // force an answer if message has been waiting too long + if ( msg->waitstatus != MESSAGE_ANSWERED ) + { + if ( t > msg->timestamp + msg->waittime ) + { + if ( msg->persist == 0 ) + { + // mark messsage as answered + // if no tenative answer + // to DBquery then game will have to check disk cache + // for an answer itself + if ( msg->waitstatus != MESSAGE_ANSWERED_TENTATIVE ) + { + // this is the part where MsgLoop() tries to + // answer a DB Query from the disk cache + switch(msg->type) + { + case MESSAGE_TYPE_DB_QUERY: + AnswerDBQueryMsgFromDiskCache(msg); + break; + } + } + + msg->waitstatus = MESSAGE_ANSWERED; + } + else + { + // treat persitent messages a little bit different + // first we mark the message as orphaned + // important to do this first so that CloseOutMessage() can + // prevent the game from closing an orphaned persistent message that is not answered + msg->orphaned = 1; + + // next we signal game that message has been answered + // by calling the reply callback + if ( msg->replyCB != NULL ) + { + // prts_debug( "Calling CB func for Message %d\n", msg->id ); + msg->replyCB(msg); + // null callback after we run it once + // so msg can sit on list waiting to be answered + // w/o callback executing again + msg->replyCB = NULL; + } + + // from here we will continue + // to retry the msg until an answer does come in + // when an answer does come, we look up + // the Orphan Callback for the msg type and call that + // so null out the game supplied callbacks + msg->replyCB = NULL; + msg->killCB = NULL; + msg->timestamp = t; // reset msg timer + // leave message state as QUEUED, DBQuery thread will handle retrying it + // msg->waitstatus = MESSAGE_RETRY; + } + } + } + + + // one more bit of business, if message is marked persist + // but has not been saved, try to save it + // we also try to save persitent messages + // right when they are first sent in SendNewMessage() + // but try again here just in case that attempt failed for + // some reason + // also don't bother saving message once it's been answered + if ( msg->persist == 1 && msg->saved == 0 + && msg->waitstatus != MESSAGE_ANSWERED ) + { + StoreMessage(msg); // this will set msg->saved = 1 on success + } + + + switch( msg->waitstatus ) + { + case MESSAGE_RETRY: // falls through (do the same thing for either QUEUE or RETRY or OPEN, queue query for subsystem) + case MESSAGE_QUEUE: + case MESSAGE_OPEN: + // means message has just come in + ProcessNewMsg(msg); + break; + case MESSAGE_QUEUED: + break; + case MESSAGE_ANSWERED_TENTATIVE: + break; + case MESSAGE_ANSWERED: + // prts_debug( "Message %d answered!\n", msg->id ); + // execute callback + if ( msg->replyCB != NULL ) + { + // prts_debug( "Calling CB func for Message %d\n", msg->id ); + msg->replyCB(msg); + // null callback after we run it once + // so msg can sit on list waiting to be closed + // w/o callback executing again + msg->replyCB = NULL; + } + // delete any copy of message that is sitting around + if ( msg->saved == 1 ) + { + UnStoreMessage(msg); // this will set msg->saved = 0 on success + } + if ( msg->persist == 1 ) + { + // handle persistent messages that have been orphaned slightly differently + // basically, need to assume that game has long since forgotten about these messages + // so we use our table of orphan callbacks to notify the game that message + // has been answered + // then we go ahead and mark the message closed ourselves instead of waiting + // for the game to do it + if( msg->orphaned == 1 ) + { + // issue orphan callback (if one exists) + DoOrphanCallback(msg); + + // close message + prts_debug( "Message closed by MsgLoop (orphan msg was finally answered) (id = %d)\n", msg->id ); + msg->closed = 1; + } + else + { + if ( t > msg->timestamp + MAX_MESSAGE_LIFETIME ) + { + // message abandoned :( + // execute kill callback + if ( msg->killCB != NULL ) + { + msg->killCB(msg); + } + // kill msg + msg->closed = 1; + } + } + } + break; + case MESSAGE_DROP: + // message has been marked for removal + // we forward it to subsystem so subsystem knows to drop it also + // and then remove it from our list + if ( ProcessDroppedMsg(msg) == 0 ) + { + DataObj->data = NULL; + if ( N2PopNode(DataObj) != NULL ) + { + message_apphook_free(DataObj); + } + } + break; + } + + + return 0; +} + + + +int CheckIfMessageHasGoodReply( Message *msg ) +{ + int ec; + + if ( msg == NULL ) + return 0; + + // no reply implies not a success + if ( msg->reply_data == NULL ) + return 0; + + switch(msg->type) + { + case MESSAGE_TYPE_PLAIN_TEXT: + // these are test messages, any reply is + // ok for them + return 1; + break; + case MESSAGE_TYPE_DB_QUERY: + ec = CheckDBQueryMsgErrorCode(msg); + if ( ec == DBQUERY_RESULT_SUCCESS ) + return 1; + else + return 0; + break; + } + return 0; +} + +// takes a pointer to a message pointer +// treats obj->data as a msg +// then compares the two msgs to see if they are the same +int MatchReplyWithMessageDataObj( void *arg, void *obj ) +{ + ObjData *DataObj = (ObjData *)obj; + Message **preply_msg; + Message *reply_msg; + Message *msg; + + if ( DataObj == NULL || DataObj->lnk.type != N2TYPE_OBJ || DataObj->lnk.sub != OBJSUB_DATA ) + return 0; + msg = (Message *)DataObj->data; + if ( msg == NULL ) + return 0; + + preply_msg = (Message **)arg; + reply_msg = (Message *)(*preply_msg); + + if ( preply_msg == NULL || reply_msg == NULL ) + return 0; + + if ( msg->id != reply_msg->id ) + return 0; + + // they match! + + // prts_debug( "Matched msg reply to msg (id = %d)\n", msg->id ); + + + // do not replace the answer on a message + // that is already marked ANSWERED + // if this happens it means either: + // a) two answers for the same message (err, should not happen (except for w/ tenative answers) + // b) answer came back too late (MsgLoop() already forced an answer on timeout) + // in either case it is important not to touch the existing answer + // as game maybe looking at it! + if ( msg->waitstatus == MESSAGE_ANSWERED ) + { + + // free reply_message and all it's data + FreeMessage(reply_msg, 1, 1 ); + + // signal back to caller that we have matched the message + // and have deleted it + // do this by NULL'ng out the value of the passed in pointer + *preply_msg = NULL; + + // signal N2Walk to stop walking message list + // important as we just free'd *arg + return -1; + } + + // if new reply is only a tenative answer and + // we have already have a tenative answer that's 'good' + // don't replace existing reply data + // this keeps us from replacing a 'good' tenative answer + // with an err'd answer + // do this b/c the DBQuery thread just + // keeps sending up every 'answer' it gets, + // 'good' (stale cache entry) or 'bad' (connection err) + // (stale cache entry is good in this as that's the one we'd want to + // give game on a timeout) + if ( reply_msg->waitstatus == MESSAGE_ANSWERED_TENTATIVE + && msg->waitstatus == MESSAGE_ANSWERED_TENTATIVE + && CheckIfMessageHasGoodReply(msg) ) + { + // prts_debug( "MsgLoop: Ignoring new tenative answer to msg %d (already have 'good' reply)\n", msg->id ); + // free reply_message and all it's data + FreeMessage(reply_msg, 1, 1 ); + } + else + { + // otherwise, replace msg reply data w/ new reply + + // update msg status + // we take new status from reply + // (allows subsystems to give back tenative answers) + msg->waitstatus = reply_msg->waitstatus; + + // free any existing reply data + if ( msg->reply_data != NULL ) + FreeMessageData( msg, 0, 1 ); + + // point msg at new reply data + msg->reply_data = reply_msg->reply_data; + + + // free reply_message and reply_msg's msg_data but not it's reply_data + FreeMessage(reply_msg, 1, 0 ); + + } + + + + // prts_debug( "Updated Message %d:\n", msg->id ); +// PrintMessage( msg ); + + + + // for DB Query messages + // take priority from reply_msg + // this allows dbquery subsystem to update the priority of a message + // consider doing this for all msg types + if ( msg->type == MESSAGE_TYPE_DB_QUERY + && + msg->priority != reply_msg->priority ) + { + // if the message is persistent then + // be sure to update the disk copy of it + if ( msg->persist ) + UnStoreMessage(msg); + + msg->priority = reply_msg->priority; + + if ( msg->persist ) + StoreMessage(msg); + + } + + + + // signal back to caller that we have matched the message + // and have deleted it + // do this by NULL'ng out the value of the passed in pointer + *preply_msg = NULL; + + // signal N2Walk to stop walking message list + // important as we just free'd *arg + return -1; + +} + + + + +int MessageLoop() +{ + int count; + int replies_this_loop; + Message *msg; + Message **pmsg; + +// prts_debug( "Entering MsgLoop\n" ); + + replies_this_loop = 0; + // Check new replies from DB Query thread + while( ThreadSafeQueuePop( &gDBQueryOutQue, (void**)&msg ) == TSQ_RESULT_SUCCESS ) + { + pmsg = &msg; + // prts_debug( "Got reply msg from DBQuery Thread (%p)\n", msg ); + + N2Walk( &gMessageList, pmsg, MatchReplyWithMessageDataObj ); + if ( *pmsg != NULL ) // we did not match this message to anything + { + prts_debug( "No msg matched reply (%p), freeing it\n", msg ); + FreeMessage(msg, 1, 1 ); + } + + // only process so many message replies per loop + // this prevents us from getting stuck or spending + // too much time servicing message replies + replies_this_loop++; + if ( replies_this_loop >= MAX_MESSAGE_REPLIES_PER_LOOP ) + { + prts_debug( "Processed %d replies this loop, refusing to process any more\n", replies_this_loop ); + break; + } + } + + // Check new replies from File Transfer thread + replies_this_loop = 0; + while( ThreadSafeQueuePop( &gFileTransferOutQue, (void**)&msg ) == TSQ_RESULT_SUCCESS ) + { + pmsg = &msg; + N2Walk( &gMessageList, pmsg, MatchReplyWithMessageDataObj ); + if ( *pmsg != NULL ) // we did not match this message to anything + { + // prts_debug( "No msg matched reply (%p), freeing it\n", msg ); + FreeMessage(msg, 1, 1 ); + } + + // only process so many message replies per loop + // this prevents us from getting stuck or spending + // too much time servicing message replies + replies_this_loop++; + if ( replies_this_loop >= MAX_MESSAGE_REPLIES_PER_LOOP ) + { + prts_debug( "Processed %d replies this loop, refusing to process any more\n", replies_this_loop ); + break; + } + } + + // clear active message counters so they can be refreshed as + // we walk the message list + gMessageSystemStats.ActiveMsgs = 0; + gMessageSystemStats.ActivePersistentMsgs = 0; + memset(gMessageSystemStats.ActiveMsgsByType,0, sizeof(gMessageSystemStats.ActiveMsgsByType) ); + N2Walk( &gMessageList, NULL, UpdateMessageDataObj ); + + gDBQuerySystemStats.DBQueryInQueueSize = ThreadSafeQueueGetCurrSize(&gDBQueryInQue); + gDBQuerySystemStats.DBQueryOutQueueSize = ThreadSafeQueueGetCurrSize(&gDBQueryOutQue); + + + // if disk activity is ok at this time + // and we are below our limit for active persistent messages + // and there are more messages in storage than are active + // (active messages also count as in storage (if they've been saved, then they have a copy in storage)) + // then load up a message from storage + if ( (gpCheckIfOKToUseDiskFunc == NULL || gpCheckIfOKToUseDiskFunc()) + && gMessageSystemStats.ActivePersistentMsgs < MAX_ACTIVE_PERSISTENT_MESSAGES + && gMessageSystemStats.ActivePersistentMsgs < gMessageSystemStats.StoredMsgs ) + { + RestoreNextStoredMessage(); + } + + count = 0; + // prts_debug( "Game Message List:\n" ); + // N2Walk( &gMessageList, &count, PrintMessageDataObj ); + +// prts_debug( "Exiting MsgLoop\n" ); + + return 0; +} + + + + +void TestOrphanCallbackFunc(Message *msg) +{ + prts_debug( "ORPHAN CALLBACK CALLED!\n" ); + PrintMessage(msg); + prts_debug( "ORPHAN CALLBACK DONE.\n" ); + return; +} + diff --git a/libraries/pmrt/pmrt_messages/messages.h b/libraries/pmrt/pmrt_messages/messages.h new file mode 100755 index 0000000..cfe3686 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/messages.h @@ -0,0 +1,198 @@ +#ifndef MESSAGES_H +#define MESSAGES_H + +// messages.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#include + +#include "filetransfer.h" + +enum MessageStatus +{ + MESSAGE_OPEN, // new + MESSAGE_QUEUE, // waiting to be queued + MESSAGE_QUEUED, // queued + MESSAGE_RETRY, // retrying + MESSAGE_ANSWERED_TENTATIVE, // answered w/ err or from old/stale data + MESSAGE_ANSWERED, // answered definitively + MESSAGE_DROP, // message has been marked for removal (can happen if we are at limit of active messages and msg gets bumped to let a higher priority msg in) +}; + +enum MessageTypes +{ + MESSAGE_TYPE_PLAIN_TEXT, + MESSAGE_TYPE_DB_QUERY, + MESSAGE_TYPE_FILE_TRANSFER_REQUEST, + NUM_MESSAGE_TYPES, +}; + +enum SendMessageErrorCodes +{ + SEND_MESSAGE_SUCCESS, + SEND_MESSAGE_INVALID_PARAMS, + SEND_MESSAGE_MALLOC_ERR, +}; + +enum MessageFileOperationErrorCodes +{ + MESSAGE_FILE_RESULT_SUCCESS, + MESSAGE_FILE_RESULT_INVALID_PARAMS, + MESSAGE_FILE_RESULT_INVALID_FD, + MESSAGE_FILE_RESULT_WRITE_ERR, + MESSAGE_FILE_RESULT_READ_ERR, + MESSAGE_FILE_RESULT_MALLOC_ERR, + MESSAGE_FILE_RESULT_FOPEN_ERR, + MESSAGE_FILE_RESULT_FCLOSE_ERR, + MESSAGE_FILE_RESULT_MKDIR_ERR, + MESSAGE_FILE_RESULT_EOF, +}; + + + + + +typedef struct Message +{ + unsigned int id; + int type; + int timestamp; + int waittime; + int priority; + int persist; + int waitstatus; + int closed; + int saved; + int orphaned; + void *msg_data; + void *reply_data; + void (*replyCB)(struct Message*); + void (*killCB)(struct Message*); +}Message; + + +struct MessageSystemStats +{ + int TotalMsgs; + int ActiveMsgs; + int ActiveMsgsByType[NUM_MESSAGE_TYPES]; + int ActivePersistentMsgs; + + int StoredMsgs; + +}; + +void TestOrphanCallbackFunc(Message *msg); + +struct MessageSystemStats gMessageSystemStats; + + + +// +// Public Message Functions +// (see messages.c for all message functions) +// +// + +// Message Init and Loop funcs +// +int MessageSystemInit(char *MessageStoreDir, int (*pCheckIfOKToUseDiskFunc)(), unsigned char *CryptoSeed, int CryptoSeedSize); +int MessageLoop(); + + +// +// Print Message funcs +// for debug printing of messages to stdout +// +int PrintMessage( Message *msg ); +void PrintMessageStats(); + +// +// Message Send Funtions +// These create new messages and link them onto the actice Message List +// +int SendNewMessage( unsigned int *id, int type, + int waittime, int priority, int persist, + void *msg_data, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + + +int SendNewDBQueryMessage( unsigned int *id, + int query_type, + int maxage, int max_result_rows, + int query_data_size, void *query_data, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int SendNewDBQueryCacheUpdateMessage( unsigned int *id, + int query_type, + int query_data_size, void *query_data, + int result_row_size, int result_rows, void *result_data, + int waittime, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + +int SendNewFileTransferMessage( unsigned int *id, + FileTransferRequest_t *FileInfo, + int waittime, int priority, int persist, + void (*replyCB)(struct Message*), + void (*killCB)(struct Message*) ); + + +// +// Message Create/Delete/Copy/Clone Funtions +// 'nuff said +// +int CloneMessage( Message **ppDst, Message *Src, int copy_msg_data, int copy_reply_data ); +void FreeMessageData( Message *message, int free_msg_data, int free_reply_data ); +void FreeMessage( Message *message, int free_msg_data, int free_reply_data ); + + +// +// Message Flush Funtions +// func to flush out current message list (call before entering Diag) +// +void FlushMessages(); + +// +// Message Search Funtion +// +Message *FindMessageByID( unsigned int id ); + +// +// Message Introspection Funtions +// Wrapper functions for the game to use when +// interacting with messages (eg. closing them or pull information out of them) +// +int CheckMessageStatus( Message *message ); +int CloseOutMessage( Message *message ); +int CheckDBQueryMsgErrorCode( Message *message ); +int CheckDBQueryMsgResultCount( Message *message ); +int CopyDBQueryMsgResultsData( Message *message, void *dest, int size ); +void *GetDBQueryMsgResultsData( Message *message ); +void *GetDBQueryMsgQueryData( Message *message ); +int GetDBQueryMsgResultsTimestamp( Message *message ); + + + +int CheckMessageStatusByID( unsigned int id ); +int CloseOutMessageByID( unsigned int id ); +int CheckDBQueryMsgErrorCodeByID( unsigned int id ); +int CheckDBQueryMsgResultCountByID( unsigned int id ); +int CopyDBQueryMsgResultsDataByID( unsigned int id, void *dest, int size ); +void *GetDBQueryMsgResultsDataByID( unsigned int id ); +void *GetDBQueryMsgQueryDataByID( unsigned int id ); +int GetDBQueryMsgResultsTimestampByID( unsigned int id ); + +int CheckFileTransferMsgErrorCode( Message *message ); +int CheckFileTransferMsgErrorCodeByID( unsigned int id ); + + + +#endif + + + diff --git a/libraries/pmrt/pmrt_messages/messages.o b/libraries/pmrt/pmrt_messages/messages.o new file mode 100644 index 0000000..7c15dba Binary files /dev/null and b/libraries/pmrt/pmrt_messages/messages.o differ diff --git a/libraries/pmrt/pmrt_messages/mssccprj.scc b/libraries/pmrt/pmrt_messages/mssccprj.scc new file mode 100755 index 0000000..dd0d839 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[pmrt_messages.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/pmrt_messages", OUNAAAAA diff --git a/libraries/pmrt/pmrt_messages/node.c b/libraries/pmrt/pmrt_messages/node.c new file mode 100755 index 0000000..db78029 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/node.c @@ -0,0 +1,1006 @@ +// sys.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 26 Aug 04 +// JFL 17 May 05 +#include "node.h" + +// #include "obj.h" + + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +// +// N1Link +// link given node into given list. +// node is linked on the end. +// +// in: +// headp = handle to head of list +// node = node to link +// out: +// global: +// +// GNP 09 Jun 00 +// JFL 06 Sep 04 +void N1LinkTail(void *headp,void *node) +{ + N1 *n; + + ((N1*)node)->next = (N1*)0; + + n = *((N1**)headp); + if(!n) + { + *((N1**)headp) = node; + } + else + { + while(n->next) + n = n->next; + n->next = node; + } + +//DONE("N1LinkTail") +} // N1LinkTail + +// +// N1LinkHead +// link given node into given list. +// node is linked on the head. +// +// in: +// headp = handle to head of list +// node = node to link +// out: +// global: +// +// GNP 09 Jun 00 +// +void N1LinkHead(void *headp,void *node) +{ + ((N1*)node)->next = *((void**)headp); + *((void**)headp) = node; +} // N1LinkHead + +// +// N1Unlink +// un-link node from given list +// +// in: +// headp = handle to head of list +// node = node to un-link +// out: +// <0 = fail +// global: +// +// GNP 09 Jun 00 +// JFL 04 Sep 04 +int N1Unlink(void *headp,void *node) +{ + N1 *n; + + n = *((N1**)headp); + if(!n) + return -1; + + if(n==node) + { + *((N1**)headp) = ((N1*)node)->next; + return 0; + } + else + { + while(n->next && n->next != node) + n = n->next; + + if(n->next == node) + { + n->next = ((N1*)node)->next; + return 0; + } + } + return -1; +} // N1Unlink + +// N2Head() +// JFL 10 Aug 04; from JoeCo +void N2Head(void *head) +{ + ((N2*)head)->next=((N2*)head)->prev=head; + ((N2*)head)->type=0; +} // N2Head() + +void N2DontLink(void *head) +{ + ((N2*)head)->next=((N2*)head)->prev=head; + ((N2*)head)->type=0; +} // N2Head() + +// N2LinkAfter() +// JFL 10 Aug 04; from JoeCo +void N2LinkAfter(void *head,void *node) +{ + N2 *n=node,*h=head; + n->next=h->next; + n->prev=head; + h->next=node; + ((N2*)(n->next))->prev=node; + + if(!n->type) + { + BP(BP_N2LINKAFTER); + n->type=1; + } +} // N2LinkAfter() + +// N2LinkBefore() +// JFL 10 Aug 04; from JoeCo +void N2LinkBefore(void *head,void *node) +{ + N2 *n=node,*h=head; + n->prev=h->prev; + n->next=head; + h->prev=node; + ((N2*)(n->prev))->next=node; + + if(!n->type) + { + BP(BP_N2LINKBEFORE); + n->type=1; + } +} // N2LinkBefore() + +// N2Unlink() +// JFL 10 Aug 04; from JoeCo +void N2Unlink(void *node) +{ + N2 *n=node; + + // unlink + ((N2*)n->next)->prev=n->prev; + ((N2*)n->prev)->next=n->next; + + // the following makes the node safe from multiple unlinking + n->next=n->prev=node; +} // N2Unlink() + +// JFL 12 Jan 05 +void* N2Parent(void *vn) +{ + N2 *n=vn; + while(n && n->type) + n=n->next; + if(n && !n->type) + { + n++; + if(n->next + && (((N2*)n->next)->prev==n) + && (((N2*)n->prev)->next==n)) + return n; + } + return NUL; +} // N2Parent() + + + +// JFL 11 Nov 04 +int N2Count(void *vn) +{ + N2 *k,*stack[N2_DEPTH_MAX]; + int depth,count; + N2 *n=vn; + + count=0; + stack[0]=n; + depth=1; + + while(depth-->0) + { + for(n=stack[depth];n->type;n=n->next) + { + count++; + if(depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) && k->type) + { + stack[depth++]=n->next; // push next in cur list + n=k->prev; // switch current to first kid + } + } // for + } // while + + return count; +} // N2Count() + +// JFL 18 Feb 05 +int N2LevelSet(N2 *n,int lev) +{ + int oldlev; + + oldlev=n->flags&M_N2_LEVEL; + oldlev>>=S_N2_LEVEL; + + lev = (M_N2_LEVEL & (lev<>S_N2_LEVEL; // complex clamp + n->flags&=~M_N2_LEVEL; + n->flags|=lev<flags&M_N2_LEVEL; + oldlev>>=S_N2_LEVEL; + + return oldlev; +} // N2LevelGet() + +// JFL 24 Feb 05 +int N2LevelCpy(N2 *dst,N2 *src) +{ + int oldlev,newlev; + + newlev=src->flags&M_N2_LEVEL; + + oldlev=dst->flags&M_N2_LEVEL; + dst->flags&=~M_N2_LEVEL; + dst->flags|=newlev; + oldlev>>=S_N2_LEVEL; + + return oldlev; +} // N2LevelCpy() + + +// Generic Search Function for N2 lists +void *N2Search( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *) ) +{ + void *result = NUL; + N2 *Node = (N2*)StartNode; + // quit if we get a NUL node, or we get to top of list + // note that this means you can not start a search at the list head + // this is required to make iterative calls to this function safe + // (if we always skipped passed head node, successive calls to this func might never end) + while ( Node != NUL && Node->type != 0) + { + if ( CompareFunc != NUL && (*CompareFunc)( CompareParam, (void *) Node ) == 0) + { + result = Node; + break; + } + Node = Node->next; + if ( Node == StartNode ) // quit if we get back to start node again + break; + } + + return result; +} // N2Search() + +// walk list and perform OperationFunc on each item +void N2Walk( void *StartNode, void *OperationParam, int (*OperationFunc)(void *, void *) ) +{ + int ec; + N2 *Node; + N2 *Next; + + if ( OperationFunc == NUL ) + return; + + // if starting at head of list, skip past head node + if ( StartNode != NUL && ((N2*)StartNode)->type == 0 ) + StartNode = ((N2*)StartNode)->next; + + Node = (N2*)StartNode; + while ( Node != NUL && Node->type != 0) // quit if we get a NUL node, or we get to top of list + { + // grab next before operating on node so we are safe if operation unlinks node + Next = Node->next; + ec = (*OperationFunc)( OperationParam, (void *) Node ); + if ( ec < 0 ) // stop if ever get a negative value from operation func + break; + + Node = Next; + if ( Node == StartNode ) // quit if we get back to start node again + break; + } +} + +// Combo of prev two functions, searches list for matching items and performs operation on them +void N2SearchAndOperate( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *), void *OperationParam, int (*OperationFunc)(void *, void *) ) +{ + int ec; + N2 *Node; + N2 *Next; + if ( OperationFunc == NUL ) + return; + + // if starting at head of list, skip past head node + if ( StartNode != NUL && ((N2*)StartNode)->type == 0 ) + StartNode = ((N2*)StartNode)->next; + + Node = N2Search( StartNode, CompareParam, CompareFunc ); + while ( Node != NUL && Node->type != 0) // quit if we get a NUL node, or we get to top of list + { + // grab next before operating on node so we are safe if operation unlinks node + Next = Node->next; + ec = (*OperationFunc)( OperationParam, (void *) Node ); + if ( ec < 0 ) // stop if ever get a negative value from operation func + break; + + Node = N2Search( Next, CompareParam, CompareFunc ); + if ( Node == StartNode ) // quit if we get back to start node again + break; + } +} + + +// Pop item off of list +void *N2PopNode( void *Node ) +{ + N2 *n = (N2 *)Node; + // check if node is nul + // check if node is a head marker (don't unlink head of list) + if ( n != NUL + && + n->type != 0 ) + { + N2Unlink(n); + return n; + } + // else return NUL ptr + return NUL; +} + +// Pop next item off of list +void *N2PopNext( void *Node ) +{ + // Check if node is nul + if ( Node != NUL ) + { + return N2PopNode(((N2*)Node)->next); + } + else // return NUL + { + return NUL; + } +} + +// Pop prev item off of list +void *N2PopPrev( void *Node ) +{ + // Check if node is nul + if ( Node != NUL ) + { + return N2PopNode(((N2*)Node)->prev); + } + else // return NUL + { + return NUL; + } +} + + +// adds a DataObj to an N2 list +// gets space for new obj by calling malloc_func +int N2AddDataNode( N2 *List, void *(*malloc_func)(size_t), void *data, int link_after ) +{ + ObjData *NewObj; + if ( List == NUL ) + return -1; + if ( malloc_func == NUL ) + return -2; + + NewObj = (ObjData *) malloc_func( sizeof(ObjData) ); + if (NewObj == NUL ) + return -3; + + NewObj->lnk.type = OBJSUB_DATA; + NewObj->data = data; + + if ( link_after == 1) + N2LinkAfter( List, NewObj ); + else + N2LinkBefore( List, NewObj ); + + + return 0; +} +/* Moved to DBquery on temp basis until GNP checks in sys.c +int IncArgOnDataNodes( void *arg, void *node ) +{ + N2 *n = (N2 *)node; + if ( node == NUL || arg == NUL ) + return 0; + + if ( n->type == OBJSUB_DATA ) + *(int*)arg += 1; + + return 0; +} + +int N2CountDataNodes( N2 *List ) +{ + int count=0; + N2Walk(List,&count,IncArgOnDataNodes); + return count; +} +*/ +#include +#include +#include +#include +#include +#include +void prts_debug(char* format,...) +{ + char buff[1024]; + va_list args; +#if !PRODUCTION + sprintf(buff,"%s",format); + va_start(args,format); + vprintf(buff,args); +#endif +} + + +/* +// CRC checksum calculation table +uns32 CRCTab[256] = +{ + 0x00000000,0x77073096,0xee0e612c,0x990951ba,0x076dc419, + 0x706af48f,0xe963a535,0x9e6495a3,0x0edb8832,0x79dcb8a4, + 0xe0d5e91e,0x97d2d988,0x09b64c2b,0x7eb17cbd,0xe7b82d07, + 0x90bf1d91,0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de, + 0x1adad47d,0x6ddde4eb,0xf4d4b551,0x83d385c7,0x136c9856, + 0x646ba8c0,0xfd62f97a,0x8a65c9ec,0x14015c4f,0x63066cd9, + 0xfa0f3d63,0x8d080df5,0x3b6e20c8,0x4c69105e,0xd56041e4, + 0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b, + 0x35b5a8fa,0x42b2986c,0xdbbbc9d6,0xacbcf940,0x32d86ce3, + 0x45df5c75,0xdcd60dcf,0xabd13d59,0x26d930ac,0x51de003a, + 0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599, + 0xb8bda50f,0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924, + 0x2f6f7c87,0x58684c11,0xc1611dab,0xb6662d3d,0x76dc4190, + 0x01db7106,0x98d220bc,0xefd5102a,0x71b18589,0x06b6b51f, + 0x9fbfe4a5,0xe8b8d433,0x7807c9a2,0x0f00f934,0x9609a88e, + 0xe10e9818,0x7f6a0dbb,0x086d3d2d,0x91646c97,0xe6635c01, + 0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,0x6c0695ed, + 0x1b01a57b,0x8208f4c1,0xf50fc457,0x65b0d9c6,0x12b7e950, + 0x8bbeb8ea,0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3, + 0xfbd44c65,0x4db26158,0x3ab551ce,0xa3bc0074,0xd4bb30e2, + 0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,0x4369e96a, + 0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5, + 0xaa0a4c5f,0xdd0d7cc9,0x5005713c,0x270241aa,0xbe0b1010, + 0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,0xce61e49f, + 0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17, + 0x2eb40d81,0xb7bd5c3b,0xc0ba6cad,0xedb88320,0x9abfb3b6, + 0x03b6e20c,0x74b1d29a,0xead54739,0x9dd277af,0x04db2615, + 0x73dc1683,0xe3630b12,0x94643b84,0x0d6d6a3e,0x7a6a5aa8, + 0xe40ecf0b,0x9309ff9d,0x0a00ae27,0x7d079eb1,0xf00f9344, + 0x8708a3d2,0x1e01f268,0x6906c2fe,0xf762575d,0x806567cb, + 0x196c3671,0x6e6b06e7,0xfed41b76,0x89d32be0,0x10da7a5a, + 0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5, + 0xd6d6a3e8,0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1, + 0xa6bc5767,0x3fb506dd,0x48b2364b,0xd80d2bda,0xaf0a1b4c, + 0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef, + 0x4669be79,0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236, + 0xcc0c7795,0xbb0b4703,0x220216b9,0x5505262f,0xc5ba3bbe, + 0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,0xb5d0cf31, + 0x2cd99e8b,0x5bdeae1d,0x9b64c2b0,0xec63f226,0x756aa39c, + 0x026d930a,0x9c0906a9,0xeb0e363f,0x72076785,0x05005713, + 0x95bf4a82,0xe2b87a14,0x7bb12bae,0x0cb61b38,0x92d28e9b, + 0xe5d5be0d,0x7cdcefb7,0x0bdbdf21,0x86d3d2d4,0xf1d4e242, + 0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1, + 0x18b74777,0x88085ae6,0xff0f6a70,0x66063bca,0x11010b5c, + 0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,0xa00ae278, + 0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7, + 0x4969474d,0x3e6e77db,0xaed16a4a,0xd9d65adc,0x40df0b66, + 0x37d83bf0,0xa9bcae53,0xdebb9ec5,0x47b2cf7f,0x30b5ffe9, + 0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605, + 0xcdd70693,0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8, + 0x5d681b02,0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b, + 0x2d02ef8d +}; + +// +// AudCRC +// generate a 32bit CRC checksum of an array of memory +// +// in: +// out: +// global: +// +// GNP 09 Oct 00 +// +uns32 AudCRC(uns8 *data, int len) +{ + register int i; + register uns32 crc; + + crc = 0xFFFFFFFF; + for(i = 0; i < len; i++) + { + crc = ((crc>>8) & 0x00FFFFFF) ^ CRCTab[ (crc^*data) & 0xFF ]; + data++; + } +//DONE("AudCRC") + return( crc^0xFFFFFFFF ); +} // AudCRC + + +int AudInitRollingCRC( RollingCRCHandle *rcrc ) +{ + if ( rcrc == NULL ) + return -1; + + rcrc->count = 0; + rcrc->crc = 0xFFFFFFFF; + return 0; +} + +int AudAddToRollingCRC( RollingCRCHandle *rcrc, uns8 *data, int len) +{ + int i; + for(i = 0; i < len; i++) + { + rcrc->crc = ((rcrc->crc>>8) & 0x00FFFFFF) ^ CRCTab[ (rcrc->crc^*data) & 0xFF ]; + data++; + rcrc->count++; + } + return 0; +} + + +uns32 AudCalcRollingCRC( RollingCRCHandle *rcrc ) +{ + if ( rcrc == NULL ) + return 0; + return ( rcrc->crc^0xFFFFFFFF ); +} + +uns32 AudCRCFile( char *filename ) +{ + FILE *fd; + int len; + uns8 data[64]; + RollingCRCHandle rcrc; + AudInitRollingCRC(&rcrc); + + + fd = fopen( filename, "rb" ); + if ( fd == NULL ) + return 0; + + while ( (len = fread(data, 1, 64, fd )) != 0 ) + { + AudAddToRollingCRC( &rcrc, data, len ); + } + fclose(fd); + + return AudCalcRollingCRC(&rcrc); + + +} +*/ + +#include +#ifdef SYS_PC +#include +#endif +#ifdef SYS_BB +#include +#endif + + +// +// FsDirCheck +// check if given directory exists, +// if not, create it +// +// in: +// dirName = full path to directory +// out: +// <0 = fail +// global: +// +// GNP 11 Oct 00 +// +int FsDirCheck(char* dirName) +{ + int ec=0,idx; + char tStr[1024], *ptr; + + #ifdef SYS_BB + FILE* dirFile; + #endif + + ptr = dirName; + idx=0; + + while((*ptr == '/') || (*ptr == '\\')) + { + // grab first slashes + tStr[idx++] = *ptr++; + } + + // + // UNIX file system + // + while(*ptr != '\0') + { + while ((*ptr != '\0') && (*ptr != '/') && (*ptr != '\\')) + tStr[idx++] = *ptr++; + tStr[idx]=0; + #ifdef SYS_BB + // check if operator adjustment directory exists + // if so, do nothing + // if not, create + dirFile = fopen(tStr, "d"); + if (dirFile == NULL) + { + if(mkdir(tStr,S_IRWXU|S_IRGRP|S_IXGRP) != 0) + { + if (errno != EEXIST) + { + ec=-1; // some other error occured besides directory already existing + break; + } + } + } + else + { + fclose(dirFile); + } + #endif + + #ifdef SYS_PC + + // attempt to create directory, if it does not already exist + if (_mkdir(tStr) < 0) + { + if (errno != EEXIST) + { + ec=-1; // some other error occured besides directory already existing + break; + } + } + #endif + + while ((*ptr == '/') || (*ptr == '\\')) + tStr[idx++] = *ptr++; + } //while + +//DONE("FsDirCheck") + return(ec); +} // FsDirCheck + + + + +// return 0 false if now is not a good time +// for subsystems to write stuff (dbquery cache entries, etc) +// to the disk +int CheckIfGameSubSystemsOkToUseDisk() +{ + return 1; +} + + + +// directory walking functions +int FsOpenDir(FsDH *fdh, char *dirname ) +{ +#ifdef SYS_PC + char buf[256]; +#endif + if ( fdh == NUL ) + return -1; +#ifdef SYS_PC + sprintf(buf,"%s/*", dirname); + fdh->hFile = _findfirst(buf, &fdh->file ); + if ( fdh->hFile == -1 ) // error w/ search (non-existent dir?) + return -2; + fdh->done = 0; + return 0; +#endif +#ifdef SYS_BB + fdh->dir = opendir(dirname); + if ( fdh->dir == NULL ) + return -2; + return 0; +#endif +} + +int FsCloseDir(FsDH *fdh) +{ + if ( fdh == NUL ) + return -1; +#ifdef SYS_PC + return _findclose(fdh->hFile); +#endif +#ifdef SYS_BB + return closedir(fdh->dir); +#endif +} + +char *FsReadDir(FsDH *fdh) +{ +#if SYS_PC + if ( fdh->done == 1 ) + return NULL; + strncpy(fdh->filename, fdh->file.name, FS_MAX_FILENAME_LEN); + // get next dir entry + if ( _findnext( fdh->hFile, &fdh->file ) != 0 ) + fdh->done = 1; + return &fdh->filename[0]; +#endif +#ifdef SYS_BB + fdh->ent = readdir(fdh->dir); + if ( fdh->ent == NULL ) + return NULL; + strncpy(fdh->filename, fdh->ent->d_name, FS_MAX_FILENAME_LEN); + return &fdh->filename[0]; +#endif +} + +int FsFileSize( char *filename ) +{ + FILE *fd; + int size; + int ec; + + + fd = fopen(filename,"rb"); + if ( fd <= 0 ) + { + // not a valid filename? + return -1; + } + + ec = fseek(fd,0,SEEK_END); + if ( ec < 0 ) + { + fclose(fd); + return 0; + } + + size=ftell(fd); + fclose(fd); + + return size; +} + + +int FsDirSize( char *dirname, int recurse ) +{ + FsDH dh; + int ec; + int len; + char *file; + char buf[256]; + FILE *fd; + int size = 0; + + ec = FsOpenDir(&dh, dirname ); + if ( ec < 0 ) + return 0; + + while ( (file = FsReadDir(&dh)) != NULL ) + { + len = strlen(file); + // skip "." and ".." + if ( ( len == 1 && file[0] == '.' ) + || + ( len == 2 && file[0] == '.' && file[1] == '.' ) + ) + continue; + + if ( strlen(dirname) + len < sizeof(buf) ) + sprintf(buf,"%s/%s",dirname,file); + else + continue; // file name too long, so just skip it + + fd = fopen(buf,"rb"); + if ( fd <= 0 ) + { + // could be a file we don't have perms to open + // or could be a directory, try to recurse it + if ( recurse ) + size += FsDirSize(buf, recurse ); + continue; + } + + ec = fseek(fd,0,SEEK_END); + if ( ec < 0 ) + { + fclose(fd); + continue; + } + + size+=ftell(fd); + fclose(fd); + } + + FsCloseDir(&dh); + return size; + +} + +int FsDirWalk( char *dirname, int recurse, int (*OperationFunc)(char *, void *), void *data) +{ + FsDH dh; + int ec; + int len; + char *file; + char buf[256]; + FILE *fd; + int count = 0; + + ec = FsOpenDir(&dh, dirname ); + if ( ec < 0 ) + return 0; + + while ( (file = FsReadDir(&dh)) != NULL ) + { + len = strlen(file); + // skip "." and ".." + if ( ( len == 1 && file[0] == '.' ) + || + ( len == 2 && file[0] == '.' && file[1] == '.' ) + ) + continue; + + if ( strlen(dirname) + len < sizeof(buf) ) + sprintf(buf,"%s/%s",dirname,file); + else + continue; // file name too long, so just skip it + + fd = fopen(buf,"rb"); + if ( fd <= 0 ) + { + // could be a file we don't have perms to open + // or could be a directory, try to recurse it + if ( recurse ) + { + ec = FsDirWalk(buf, recurse, OperationFunc, data ); + if ( ec < 0 ) + { + FsCloseDir(&dh); + return ec; + } + count += ec; + } + continue; + } + fclose(fd); + if ( OperationFunc != NULL ) + { + // call the operation func on the file + ec = OperationFunc(buf,data); + if ( ec < 0 ) + { + FsCloseDir(&dh); + return ec; + } + } + + } + + FsCloseDir(&dh); + + // if err'd then return the ec, otherwise return our count + return count; + + +} + +int FsMkDir( char *dirname, int make_parent_dirs ) +{ +// int ec; + int i; + char buf[512]; + int len; + +#if SYS_BB + FsDH dh; +#endif + if ( ! make_parent_dirs ) + { +#if SYS_BB + if(mkdir(dirname,S_IRWXU|S_IRGRP|S_IXGRP) == 0) + { + return 0; + } + else + { + if ( errno == EEXIST ) + { + // path exists, double check it is a dir + if ( FsOpenDir( &dh, dirname ) < 0 ) + { + return -1; + } + else + { + FsCloseDir(&dh); + return 0; + } + } + else + { + // some other error + return -1; + } + } +#endif +#if SYS_PC + if (_mkdir(dirname) < 0) + { + if (errno == EEXIST) + { + return 0; // dir already exists, that counts as success + } + else + { + // some other error occured besides directory already existing + return -1; + } + } + else + { + // _mkdir succeeded + return 0; + } +#endif + } + else + { + // we need to walk dirname and make each dir as we go + len = strlen(dirname); + if ( len > sizeof(buf) - 1 ) + return -1; // dirname too long! + i = 0; + + // check for some special cases + if ( dirname[0] == '/' ) // skip leading slash + { + i = 1; + } + else if ( len > 3 // skip leading drive letter (windows style c:/stuff) + && dirname[1] == ':' + && dirname[2] == '/' ) + { + i = 3; + } + + while ( i < len ) + { + if ( dirname[i] == '/' ) + { + // null out buf + memset( buf, 0, sizeof(buf) ); + // copy up to the slash into buffer + memcpy(buf,dirname,i); + // make the dir + if ( FsMkDir( buf, 0 ) < 0 ) + { + return -2; + } + } + i++; + } + // make final dir + if ( FsMkDir( dirname, 0 ) < 0 ) + { + return -2; + } + + // all done! + return 0; + } +} + +// EOF diff --git a/libraries/pmrt/pmrt_messages/node.h b/libraries/pmrt/pmrt_messages/node.h new file mode 100755 index 0000000..57f0730 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/node.h @@ -0,0 +1,286 @@ +#ifndef NODE_H +#define NODE_H +// node.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// + +//#include "" + +#include +#include + + +// Play Mechanix base types & system +typedef signed char int8; +typedef unsigned char uns8; +typedef signed short int16; +typedef unsigned short uns16; +typedef signed long int32; +typedef unsigned long uns32; + +#if SYS_PC +typedef __int64 int64; +typedef unsigned __int64 uns64; +#endif +#if SYS_BB +typedef long long int64; +typedef unsigned long long uns64; +#endif + +typedef int8 int2; +typedef uns8* ptr; +typedef float f32; +typedef unsigned int uns; +typedef uns sto; // unsigned, big enough for void*,float,int +typedef uns memu; +typedef int memi; + +#if SYS_PC +#define SYSBREAK() __asm {int 3} +#endif // SYS_PC + +#if SYS_BB +#define SYSBREAK() __asm__ ("int $3") +#endif // SYS_BB + + +#define BP(x) { SYSBREAK();} + + + +#define NUL ((void*)0) + +#define COUNT(array) (sizeof(array) / sizeof(array[0])) + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION TYPES + +enum { + FTYPE_NONE, + FTYPE_1, + FTYPE_2, + FTYPE_3, + FTYPE_4, + FTYPE_5, + FTYPE_6, + FTYPE_7, +}; + +typedef void (ftype1)(void); +typedef int (ftype2)(void*); +typedef int (ftype3)(void*,void*); +typedef int (ftype4)(int,void*,void*,void*); +typedef int (ftype5)(int); +typedef int (ftype6)(int,void*); +typedef int (ftype7)(void*,int); + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +typedef struct { + void *next; +} N1; + +enum { + N2TYPE_NONE, + N2TYPE_UNK, // valid node, but not typed yet + N2TYPE_RES, // resource type + N2TYPE_OBJ, // object type + N2TYPE_PROC, // proc type + N2TYPE_MSG, // msg type + N2TYPE_L2, // l2 link + N2TYPE_MAX +}; +#define M_N2TYPE 0x1f // flags will be in the top + +enum { + N2SUB_NONE, + N2SUB_KID=0xf2, // can be used to verify that this is a kid (not needed) +}; + +// keep this whole section up to date in DC + +#define M_N2_KIDLIST 0x0001 // has kid list +#define M_N2_KIDFIRST 0x0002 // process kid list first +#define M_N2_SKIP 0x0004 // don't process this node or any kids +#define M_N2_DEAD 0x0008 // node is dead (unlinked, aborted) +#define M_N2_LEVEL0 0x0010 // 0,1,2,3 +#define M_N2_LEVEL1 0x0020 // 0,1,2,3 +#define M_N2_LEVEL 0x0030 // 0,1,2,3 +#define S_N2_LEVEL 4 +#define M_N2_STRONG 0x0080 // strong node (don't normally kill) +#define M_N2_TYPE 0x0f00 // type can use 4 bits +#define M_N2_OPEN 0x1000 // node is open (for debugging) +#define M_N2_L2LINKED 0x2000 // linked into L2 list + + + +typedef struct { + // order is assumed by compiled (res_pc.c) and loaded data + void *next; + void *prev; + uns8 type; // type + uns8 sub; // subtype info + uns16 flags; // top 8 bits of flags are reserved for type +} N2; + + +#define N2KIDLIST(n) (((N2*)n)-1) +#define N2PARENT(n) (((N2*)n)+1) +#define N2L2(n) (((N2*)n)+1) // n2 to l2 +#define L2N2(n) (((N2*)n)-1) // l2 to n2 + +#define N2_DEPTH_MAX 8 +#define N2_DEPTH_DEFAULT 8 + + +void N1LinkTail(void *headp,void *node); +void N1LinkHead(void *headp,void *node); +int N1Unlink(void *headp,void *node); + +void N2Head(void *head); +void N2DontLink(void *node); +void N2LinkAfter(void *head,void *node); +void N2LinkBefore(void *head,void *node); +void N2Unlink(void *node); +int N2Count(void *node); +void* N2Parent(void *node); +char *N2Name(N2 *n,char **s2p); + +enum { + // return codes for the scan func + N2SCANFUNC_MATCH_AND_RETURN, + N2SCANFUNC_CONTINUE +}; + +typedef struct { + N2 *stack[8]; + int stacki; + N2 *wrapper; + ftype3 *func3; // int func(N2ScanRec *nsr,N2 *n) return N2SCANFUNC_ + memu fdata; // function data + char *s1; // match string s1 + char *s2; // match string s2 +} N2ScanRec; + +#define M_N2SCAN_VAL 0x0000ffff // used to pass values in +#define M_N2SCAN_SUB 0x00010000 // look for subtype +#define M_N2SCAN_FUNC 0x00020000 // function call +#define M_N2SCAN_NAME 0x00040000 // match the name +#define M_N2SCAN_PRIME 0x00100000 // find prime obj +#define M_N2SCAN_INIT 0x00200000 // this is the first call w/n2sr -- init +#define M_N2SCAN_DONTSCAN 0x00400000 // first and don't search (init only) +#define M_N2SCAN_NODEEPER 0x00800000 // dont scan deeper +#define M_N2SCAN_NOKIDS M_N2SCAN_NODEEPER // -- depricated +#define M_N2SCAN_WRAP 0x01000000 // wrap until start instead of till list end +#define M_N2SCAN_KIDSONLY 0x02000000 // kids only +void* N2Scan(N2ScanRec *n2sr,uns find,void *node); + +// generic search func for N2 list +void *N2Search( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *) ); +// generic operation func for N2 list +void N2Walk( void *StartNode, void *OperationParam, int (*OperationFunc)(void *, void *) ); +// Combo func, searches list for matching items and performs operation on them +void N2SearchAndOperate( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *), void *OperationParam, int (*OperationFunc)(void *, void *) ); + +// funcs for popping items off list +void *N2PopNode( void *Node ); +void *N2PopNext( void *Node ); +void *N2PopPrev( void *Node ); + + +int N2LevelSet(N2 *n,int lev); +int N2LevelGet(N2 *n); +int N2LevelCpy(N2 *dst,N2 *src); + +int N2AddDataNode( N2 *List , void *(*malloc_func)(size_t), void *data, int link_after); +int N2CountDataNodes( N2 *List ); + + +enum { + // must match resObjSubTable[], resObjSubSizes[] + OBJSUB_NONE, + OBJSUB_DATA, +}; + +typedef struct { + N2 lnk; + void *data; +} ObjData; + + +void prts_debug(char* format,...); + + +/* +uns32 AudCRC(uns8 *data, int len); + +typedef struct +{ + unsigned int count; + uns32 crc; +} RollingCRCHandle; + +int AudInitRollingCRC( RollingCRCHandle *rcrc ); +int AudAddToRollingCRC( RollingCRCHandle *rcrc, uns8 *data, int len); +uns32 AudCalcRollingCRC( RollingCRCHandle *rcrc ); + +uns32 AudCRCFile(char *filename ); +*/ + +int FsDirCheck(char* dirName); + + +#include + + + +// int CheckIfGameSubSystemsOkToUseDisk(); + + + +//----------------------------------------------------------------------------- +// Directory walking structures +#define FS_MAX_FILENAME_LEN 256 + +// SYS_PC +#if SYS_PC +#include +#include +typedef struct { + struct _finddata_t file; + long hFile; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir + int done; +} FsDH; +#endif // SYS_PC + +#if SYS_BB +#include +#include +#include +typedef struct { + DIR *dir; + struct dirent *ent; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir +} FsDH; +#endif // SYS_BB + +int FsOpenDir(FsDH *fdh, char *dirname ); +int FsCloseDir(FsDH *fdh); +char *FsReadDir(FsDH *fdh); +int FsMkDir( char *dirname, int make_parent_dirs ); + +int FsFileSize( char *filename ); + +int FsDirSize( char *dirname, int recurse ); +int FsDirWalk( char *dirname, int recurse, int (*OperationFunc)(char *, void *), void *data); + + +//----------------------------------------------------------------------------- + + +#endif // ndef NODE_H + + diff --git a/libraries/pmrt/pmrt_messages/pmrt_messages.c b/libraries/pmrt/pmrt_messages/pmrt_messages.c new file mode 100755 index 0000000..3b180f1 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/pmrt_messages.c @@ -0,0 +1,54 @@ +// pmrt_messages.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "pmrt_messages.h" + +#include + +// #include "node.h" + +int PMRT_MessagesSystemInit( char *MessageStoreDir, + char *DBQueryCacheDir, char *AuditsDir, + char *DBQueryServerIP, int DBQueryServerPort, char *DBQueryServerCertFile, + char *FileServerIP, int FileServerPort, char *FileServerCertFile, + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize, + char *FTPDownloadPath, + int (*pCheckIfOKToUseDiskFunc)(), + int NumGameQueryTypes, DBQueryTypeInfoStruct *GameDBQueryTypes, + int NumGameStructForms, int *GameStructForms, + int NumGameQueryOrphanCallbacks, DBQueryOrphanCallbackStruct *GameDBQueryOrphanCallbacks ) +{ + + int ec; + + ec = TokenSystemInit(); + if ( ec < 0 ) + return ec; + + AddTokenStructForms(NumGameStructForms, GameStructForms); + + ec = DBQuerySystemInit(DBQueryCacheDir,AuditsDir, DBQueryServerIP,DBQueryServerPort, DBQueryServerCertFile, + pCheckIfOKToUseDiskFunc,ClientID,CryptoSeed,CryptoSeedSize); + if ( ec < 0 ) + return ec; + + AddNewDBQueryTypes(NumGameQueryTypes, GameDBQueryTypes ); + AddNewDBQueryOrphanCallbacks( NumGameQueryOrphanCallbacks, GameDBQueryOrphanCallbacks ); + + ec = FileTransferSystemInit( FileServerIP, FileServerPort, FileServerCertFile, + FTPDownloadPath, AuditsDir, ClientID, + CryptoSeed, CryptoSeedSize, + pCheckIfOKToUseDiskFunc); + if ( ec < 0 ) + return ec; + + MessageSystemInit(MessageStoreDir, pCheckIfOKToUseDiskFunc,CryptoSeed,CryptoSeedSize); + if ( ec < 0 ) + return ec; + + return 0; +} + diff --git a/libraries/pmrt/pmrt_messages/pmrt_messages.dsp b/libraries/pmrt/pmrt_messages/pmrt_messages.dsp new file mode 100755 index 0000000..05a18fc --- /dev/null +++ b/libraries/pmrt/pmrt_messages/pmrt_messages.dsp @@ -0,0 +1,140 @@ +# Microsoft Developer Studio Project File - Name="pmrt_messages" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pmrt_messages - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pmrt_messages.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pmrt_messages.mak" CFG="pmrt_messages - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pmrt_messages - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pmrt_messages - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/pmrt_messages", OUNAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pmrt_messages - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\pmrt_messages copy Release\pmrt_messages.lib c:\g3\lib copy *.h c:\g3\include\pmrt_messages +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pmrt_messages - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir \g3\include\pmrt_messages copy Debug\pmrt_messages.lib \g3\lib copy *.h \g3\include\pmrt_messages +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pmrt_messages - Win32 Release" +# Name "pmrt_messages - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\dbquery.c +# End Source File +# Begin Source File + +SOURCE=.\filetransfer.c +# End Source File +# Begin Source File + +SOURCE=.\messages.c +# End Source File +# Begin Source File + +SOURCE=.\pmrt_messages.c +# End Source File +# Begin Source File + +SOURCE=.\tokens.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\dbquery.h +# End Source File +# Begin Source File + +SOURCE=.\filetransfer.h +# End Source File +# Begin Source File + +SOURCE=.\messages.h +# End Source File +# Begin Source File + +SOURCE=.\pmrt_messages.h +# End Source File +# Begin Source File + +SOURCE=.\tokens.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/pmrt_messages/pmrt_messages.dsw b/libraries/pmrt/pmrt_messages/pmrt_messages.dsw new file mode 100755 index 0000000..b65a560 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/pmrt_messages.dsw @@ -0,0 +1,37 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "pmrt_messages"=.\pmrt_messages.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/pmrt_messages", OUNAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/pmrt_messages", OUNAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/pmrt_messages/pmrt_messages.h b/libraries/pmrt/pmrt_messages/pmrt_messages.h new file mode 100755 index 0000000..f009bc9 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/pmrt_messages.h @@ -0,0 +1,32 @@ +// pmrt_messages.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_MESSAGES_H +#define PMRT_MESSAGES_H + + +#include "messages.h" +#include "dbquery.h" +#include "filetransfer.h" +#include "tokens.h" + +#define PMRT_MESSAGES_MAJOR_VERSION 1 +#define PMRT_MESSAGES_MINOR_VERSION 6 +#define PMRT_MESSAGES_SUB_MINOR_VERSION 0x01 + + +int PMRT_MessagesSystemInit( char *MessageStoreDir, + char *DBQueryCacheDir, char *AuditsDir, + char *DBQueryServerIP, int DBQueryServerPort, char *DBQueryServerCert, + char *FileServerIP, int FileServerPort, char *FileServerCert, + char *ClientID, + unsigned char *CryptoSeed, int CryptoSeedSize, + char *FTPDownloadPath, + int (*pCheckIfOKToUseDiskFunc)(), + int NumGameQueryTypes, DBQueryTypeInfoStruct *GameDBQueryTypes, + int NumGameStructForms, int *GameStructForms, + int NumGameQueryOrphanCallbacks, DBQueryOrphanCallbackStruct *GameDBQueryOrphanCallbacks ); + +#endif + diff --git a/libraries/pmrt/pmrt_messages/pmrt_messages.o b/libraries/pmrt/pmrt_messages/pmrt_messages.o new file mode 100644 index 0000000..b1a66a1 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/pmrt_messages.o differ diff --git a/libraries/pmrt/pmrt_messages/pmrt_messages.plg b/libraries/pmrt/pmrt_messages/pmrt_messages.plg new file mode 100755 index 0000000..4a920c5 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/pmrt_messages.plg @@ -0,0 +1,215 @@ + + +
+

Build Log

+

+--------------------Configuration: pmrt_messages - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F8.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fp"Debug/pmrt_messages.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_messages\dbquery.c" +"C:\g3\libraries\pmrt\pmrt_messages\filetransfer.c" +"C:\g3\libraries\pmrt\pmrt_messages\messages.c" +"C:\g3\libraries\pmrt\pmrt_messages\pmrt_messages.c" +"C:\g3\libraries\pmrt\pmrt_messages\tokens.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F8.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F9.tmp" with contents +[ +/nologo /out:"Debug\pmrt_messages.lib" +.\Debug\dbquery.obj +.\Debug\filetransfer.obj +.\Debug\messages.obj +.\Debug\pmrt_messages.obj +.\Debug\tokens.obj +\g3\libraries\pmrt\pmrt_utils\Debug\pmrt_utils.lib +\g3\libraries\pmrt\pmrt_ssl\Debug\pmrt_ssl.lib +\g3\libraries\pmrt\pmrt_compression\Debug\pmrt_compression.lib +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3F9.tmp" +

Output Window

+Compiling... +dbquery.c +filetransfer.c +messages.c +pmrt_messages.c +tokens.c +Creating library... +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueInit already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePush already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueuePop already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueDeInit already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(tsqueue.obj) : warning LNK4006: _ThreadSafeQueueGetCurrSize already defined in pmrt_utils.lib(tsqueue.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_malloc already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _thread_apphook_free already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _ThreadSleep already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _ThreadWrapperFunc@4 already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _StartThread already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _InitMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _GetMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _FreeMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(thread_pc.obj) : warning LNK4006: _DestroyMutex already defined in pmrt_utils.lib(thread_pc.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _ReadLineFromTextFile already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _FindLineInTextFileByStartString already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _FileGetNumLines already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _FileGetLinePositions already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(textfile.obj) : warning LNK4006: _WriteStringToFile already defined in pmrt_utils.lib(textfile.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringFill already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringChomp already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringInsertChar already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameIndexFromPath already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetNameFromPath already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPath already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetPathIndex already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringIndexOfNextChar already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringCopyUntilChar already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringGetWordEndIndex already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _StringHexToDecimal already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(pmrt_strings.obj) : warning LNK4006: _FindLineInTextStringByStartString already defined in pmrt_utils.lib(pmrt_strings.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N1LinkTail already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N1LinkHead already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N1Unlink already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Head already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2DontLink already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LinkAfter already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LinkBefore already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Unlink already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Parent already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Count already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LevelSet already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LevelGet already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2LevelCpy already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Search already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2Walk already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2SearchAndOperate already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2PopNode already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2PopNext already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2PopPrev already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2AddDataNode already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _IncArgOnDataNodes already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(node.obj) : warning LNK4006: _N2CountDataNodes already defined in pmrt_utils.lib(node.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _StartWin32Sockets already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockCloseConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockOpenClientTCPConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockCheckConnectionStatus already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockSendOutTCPConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netsock_pc.obj) : warning LNK4006: _NetSockRecvFromTCPConnection already defined in pmrt_utils.lib(netsock_pc.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _InitClientStateStruct already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _SetClientStateStructRecvBuf already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _ResetClientStateStructRecvBuf already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _SetClientStateStructSendBuf already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _CloseClientConnection already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(netclient.obj) : warning LNK4006: _UpdateClientState already defined in pmrt_utils.lib(netclient.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _GetSysElapsedMicroseconds already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _SysDateTime_Utils already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _SysCopytmToSysDate_Utils already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(microtime.obj) : warning LNK4006: _DateChangesBetweenDates already defined in pmrt_utils.lib(microtime.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _InitMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _AddToMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _DelFromMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(memallochist.obj) : warning LNK4006: _PrintMemAllocHistory already defined in pmrt_utils.lib(memallochist.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetInterfaceIpAddress already defined in pmrt_utils.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo_pc.obj) : warning LNK4006: _EthToolCableStatus already defined in pmrt_utils.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo_pc.obj) : warning LNK4006: _GetMacAddress already defined in pmrt_utils.lib(interfaceInfo_pc.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo.obj) : warning LNK4006: _NetGetHostName already defined in pmrt_utils.lib(interfaceInfo.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo.obj) : warning LNK4006: _GetDefaultGateway already defined in pmrt_utils.lib(interfaceInfo.obj); second definition ignored +pmrt_ssl.lib(interfaceInfo.obj) : warning LNK4006: _GetRoute already defined in pmrt_utils.lib(interfaceInfo.obj); second definition ignored +pmrt_ssl.lib(icmpSock_pc.obj) : warning LNK4006: _IcmpPing already defined in pmrt_utils.lib(icmpSock_pc.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsFileSize already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsOpenDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsCloseDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsReadDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsDirSize already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsRecursiveRmdir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsDirWalk already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _CountFiles already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsDirCountFiles already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsMkDir already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsLoadFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsSaveFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsCheckIfFileExists already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsSaveInt already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsLoadInt already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _UtilGetFileSize already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _UtilReadFromFile already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsFileCopy already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _FsFileMove already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _ThreadedFileIOThread already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _OpenThreadedFileIOHandle already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _CheckThreadedFileIOHandleStatus already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _CheckThreadedFileIOHandleError already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _GetThreadedFileIOHandleData already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _GetThreadedFileIOHandleDataLen already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(filesys.obj) : warning LNK4006: _CloseThreadedFileIOHandle already defined in pmrt_utils.lib(filesys.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _GetHostByName already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _DNSLookupThread already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _DNSLookup already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _gQueryTimeout already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _gQueryErr already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(dnslookup.obj) : warning LNK4006: _gQueryStatus already defined in pmrt_utils.lib(dnslookup.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListCreate already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPushFront already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPushBack already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPopFront already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPopBack already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListPop already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListInsertBefore already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListFree already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListRemove already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _ListFreeNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _BinaryTreeCreate already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _BinaryTreeAddNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _BinaryTreeFindNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeCreate already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeAddNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeGoUp already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeGoDown already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeDeleteNode already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containers.obj) : warning LNK4006: _TreeFree already defined in pmrt_utils.lib(containers.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _ContainersSetMemoryFuncs already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _CopyStrings already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _DebugOutput already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _StringConcat already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _CustomFree already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(containerCommon.obj) : warning LNK4006: _CustomMalloc already defined in pmrt_utils.lib(containerCommon.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _PrintDebug already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _CheckForDebugger already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _ExitOnSig already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _StartDebugGuard already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _CheckDebugGuard already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _DisableCoreDump already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _CheckSharedLibs already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(cguardian.obj) : warning LNK4006: _GetCodeEntryPoint already defined in pmrt_utils.lib(cguardian.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudInitRollingCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudAddToRollingCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudCalcRollingCRC32 already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _AudCRC32File already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +pmrt_ssl.lib(audcrc.obj) : warning LNK4006: _CRC32Tab already defined in pmrt_utils.lib(audcrc.obj); second definition ignored +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FA.bat" with contents +[ +@echo off +mkdir c:\g3\include\pmrt_messages +copy Debug\pmrt_messages.lib c:\g3\lib +copy *.h c:\g3\include\pmrt_messages +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FA.bat" + + 1 file(s) copied. +dbquery.h +filetransfer.h +messages.h +node.h +pmrt_messages.h +tokens.h + 6 file(s) copied. + + + +

Results

+pmrt_messages.lib - 0 error(s), 151 warning(s) +
+ + diff --git a/libraries/pmrt/pmrt_messages/tokens.c b/libraries/pmrt/pmrt_messages/tokens.c new file mode 100755 index 0000000..ffd6a5a --- /dev/null +++ b/libraries/pmrt/pmrt_messages/tokens.c @@ -0,0 +1,1054 @@ +// tokens.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include +#include +#include +#include + +#include "tokens.h" +#include + + +// StructForms +// metadata of structs +// Entries must match the order of e_StructForms. +// Struct members including primitives must use enumerations +// in e_StructForms +// +// All structure forms must pad out to multiples of 4 bytes +// +// Should match enumeration of e_BaseStructForms in tokens.h +// use AddTokenStructForms() to add additional structure forms from game code +int StructForms[MAX_STRUCT_FORMS][MAX_STRUCT_MEMBERS] = +{ + // primitives + {0,0,VOID_FORM,0}, + {sizeof(char),1,BYTE_PAD_FORM,1}, // padding is one byte + {sizeof(char),1,CHAR_FORM,1}, + {sizeof(short),1,SHORT_FORM,1}, + {sizeof(int),1,INT_FORM,1}, + {sizeof(unsigned int),1,UNSINT_FORM,1}, + {sizeof(long),1,LONG_FORM,1}, + {sizeof(float),1,FLOAT_FORM,1}, +}; +int gNumStructForms; + +// malloc and free wrappers for tracking memory used +// by message subsystem +void* tokens_apphook_malloc(size_t size) +{ + void *ptr; + ptr = malloc(size); + AddToMemAllocHistory(ptr, size ); + return ptr; +} // message_apphook_malloc() + +void token_apphook_free(void *m) +{ + prts_debug( "Token System Free:\n" ); + DelFromMemAllocHistory(m); + free(m); + prts_debug("Successfully free'd mem at %p\n", m ); +} // message_apphook_free() + +void TokensStartTokenizingMessage(token_data* td, char* msg) +{ + int i; + int fields_this_row; + td->rows=0; + td->fields=0; + td->max_fields = 0; + td->min_fields = 0; + td->current_token=0; + + + fields_this_row = 0; + // prts_debug("\\n = %d \\t = %d\n",'\n','\t'); + for(i=0;msg[i]!='\n' || msg[i+1]!='\n';i++) + { + // prts_debug("%d(%c) ",msg->data[i],msg->data[i]>=' '?msg->data[i]:'.'); + if( msg[i] == '\t' || msg[i] == '\n' ) + { + fields_this_row++; + + // if we're still in the first row, count fields + if(!(td->rows)) + { + td->fields++; + td->min_fields++; + td->max_fields++; + } + // if this is a \n then, count a row + if( msg[i] == '\n' ) + { + if ( fields_this_row > td->max_fields ) + td->max_fields = fields_this_row; + if ( fields_this_row < td->min_fields ) + td->min_fields = fields_this_row; + td->rows++; + fields_this_row = 0; + + } + // set this as null + msg[i] = (char)0; + } + } + // count the last row if it hasn't been counted already + if( td->rows==0 && i > 0 ) + { + td->fields++; + td->min_fields++; + td->max_fields++; + } + + if(msg[i]=='\n' && msg[i+1]=='\n') + { + msg[i] = (char)0; + msg[i+1] = (char)0; + // if there is at least 1 field, advance the row count at the end of the data set + if(td->fields) + td->rows++; + } +} + +// counts all the data fields required to +// fill out a given struct +int TokensCountTotalStructureFields(int type) +{ + int count; + int j; + int ec; + int numMembers,memberType,memberCount; + if(type >= gNumStructForms || type < VOID_FORM) + { + return -1; + } + + numMembers = StructForms[type][1]; + // check for invalid number of members + if(numMembers < 0) + { + return -2; + } + + + count = 0; + + j = 2; + while(j < 2+ (numMembers*2)) + { + memberType = StructForms[type][j]; + // check type against valid enums + if(memberType >= gNumStructForms || memberType < BYTE_PAD_FORM) + { + return -3; + } + + memberCount = StructForms[type][j+1]; + // check for invalid number of members + if(memberCount < 0) + { + prts_debug("Negative members field value (%d) in datatype %d table\n", + memberCount, type); + return -4; + } + + switch(memberType) + { + case BYTE_PAD_FORM: + break; + case CHAR_FORM: + count++; // one field for either a single char or a char array (string) + break; + case SHORT_FORM: + case INT_FORM: + case UNSINT_FORM: + case LONG_FORM: + case FLOAT_FORM: + count += memberCount; + break; + default: // struct + ec = TokensCountTotalStructureFields(memberType); + if ( ec >= 0 ) + count += ec; + else + return ec; + break; + } // switch + j+=2; + } // while + + return count; + +} + +char* TokensGetNextTokenAsString(token_data* td, char* msg) +{ + int index = td->current_token; + // check for end of input +// if( msg->data[index]==(char)0 && msg->data[index+1]==(char)0 ) +// return &(msg->data[index]); + // advance to the next token + for(;msg[td->current_token];td->current_token++); + td->current_token++; + // return the previous token + return &(msg[index]); +} + +// +// parseHelper +// Recursive helper function for parsing values from source[], +// populating a structure whose memory is at the location pointed +// to by the pointer that is pointed to by ppData + +// pre: +// ppData: pointer to a struct pointer whose memory has been allocated. +// source: array of strings formatted according to StructForms +// +// post: +// ppData: struct pointer is populated with data parsed from source +// +// return: +// count: +// the number of struct elements parsed, including elements +// from recursive calls to parseHelper +// error code +// -2: input error +// -4: StructForms table error: negative number +// +// 11Apr2007 +// GTR +// +int parseHelper(void **pData, char *source, + token_data *tokenData, int type) +{ + int i; // traverses source[] + int nestedTrav; // traverses element + int j; // traverses StructForms + int numMembers; // number of members inside the struct + char *cd; + short *sd; + int *id; + unsigned int *ud; + long *ld; + float *fd; + int temp; +// char tempString[COINUP_STR_LEN]; + int startLoc; + + int memberType; // enum of elements within a struct + int memberCount; // count of the elements, in case of an array + + void *walker; // for walking memory of the struct being populated + + // check type against valid enums + if(type >= gNumStructForms || type < VOID_FORM) + { + prts_debug("Invalid datatype: %d\n", type); + return -2; + } + + // number of members + numMembers = StructForms[type][1]; // tokenData->fields; + // check for invalid number of members + if(numMembers < 0) + { + prts_debug("Negative members field value (%d) in datatype %d table\n", + numMembers, type); + return -4; + } + + // Walk argument list and populate struct into next memory in data pointer + walker = *pData; + cd = (char*)walker; + sd = (short*)walker; + id = (int*)walker; + ud = (unsigned int*)walker; + ld = (long*)walker; + fd = (float*)walker; + + prts_debug( "STARTED PARSING NEW STRUCT\n", (char*)walker ); + + i = 0; + // Go to where in StructForms list has member type/count pairs. + // Skip 2 in StructForms for memory size and number of members. + j = 2; + + while(j < 2+ (numMembers*2)) + { + memberType = StructForms[type][j]; + // check type against valid enums + if(memberType >= gNumStructForms || memberType < BYTE_PAD_FORM) + { + prts_debug("Invalid member datatype: %d\n", memberType); + return -2; + } + memberCount = StructForms[type][j+1]; + // check for invalid number of members + if(memberCount < 0) + { + prts_debug("Negative members field value (%d) in datatype %d table\n", + numMembers, type); + return -4; + } + + switch(memberType) + { + case BYTE_PAD_FORM: + for(nestedTrav=0; nestedTrav 0) + { + i += temp; + } + else + { + return temp; + } + } + break; + } // switch + j+=2; + } // while + + *pData = walker; + return i; +} + +// +// ParseStruct +// Parses string source then allocates memory and puts data into struct +// pointed to by the pointer that is pointed to by ppData +// +// pre: +// dataType: data type, according to enum e_StructForms +// memberCount: number of that data type, in case of array +// ppData: pointer to a void pointer. Assumed NULL initially +// source: array of strings formatted according to StructForms +// +// post: +// ppData: pointer to a struct pointer +// +// return: +// count +// the number of struct elements parsed, including elements +// of nested structs +// error code +// -2: input error +// -3: memory allocation error +// -4: StructForms table error: negative number +// +// 10Apr2007 +// GTR +// +int ParseStruct(int dataType, int memberCount, void **ppData, char *source) +{ + int i; + int numMembers; + int rows_to_parse; + int size; + void *data; + void *walker; + int returnCode; + int requiredFields; + + token_data tokenData; + + ////////// Allocate memory to store data + + // check type against valid enums + + if(dataType >= gNumStructForms || dataType < VOID_FORM) + { + prts_debug("Invalid datatype: %d\n", dataType); + return -2; + } + + if(memberCount < 0) + { + prts_debug("Error: Negative array count when entering ParseStruct\n."); + return -2; + } + + // number of members in the struct + numMembers = StructForms[dataType][1]; + if( numMembers == 0 ) + { + // this is not an error, it handles the VOID_FORM case + // no members, so no work to do! + return 0; + } + + // check for improperly formed StructForms table + if(numMembers < 0) + { + prts_debug("Error: Negative members field value (%d) in datatype %d table\n", + numMembers, dataType); + return -4; + } + + if ( source == NULL ) + return -5; + + TokensStartTokenizingMessage(&tokenData, source); + + // determine how many rows we should parse out + // this also sets how many rows we will alloc space for + // if we were passed a ptr to NULL ptr + if( memberCount == 0 || memberCount > tokenData.rows ) + { + // either asked specifically to malloc for as many results + // as there were + // or got back fewer results than we asked for + rows_to_parse = tokenData.rows; + } + else + { + // got back as many or more results than we asked for + rows_to_parse = memberCount; + } + + + // If no rows to parse, do not malloc, do not continue, do not pass go + // just return 0 + if( rows_to_parse == 0) + { + return 0; + } + + // check for partial/incomplete records + // first check if there are the right number + // of coloumns for our struct, but because the struct can + // contain structs, this is non-trivial + // next, check if each row of data has the same number of coloumns + requiredFields = TokensCountTotalStructureFields(dataType); + if ( tokenData.fields != requiredFields + || + tokenData.max_fields != tokenData.min_fields ) + { + prts_debug("Error: Not enough fields for datatype %d (need %d, got min %d, max %d)\n", + dataType, requiredFields, tokenData.min_fields, tokenData.max_fields ); + + return -6; + } + + prts_debug("YEAA HAH! enough fields for datatype %d (need %d, got min %d, max %d)\n", + dataType, requiredFields, tokenData.min_fields, tokenData.max_fields ); + + + + // memory size + size = StructForms[dataType][0]; + if ( *ppData == NULL ) + { + + // if passed ptr to a NULL ptr, then make some space + // for the parsed structure + data = tokens_apphook_malloc(size * rows_to_parse); + if(data == NULL) + { + prts_debug("malloc failed (%d bytes requested)\n", size); + return -3; + } + memset(data,0,size * rows_to_parse); + } + else + { + data = *ppData; + // if passed a data block, zero out the whole thing + memset(data,0,size * memberCount); + + // If no rows to parse, return 0. + if( rows_to_parse == 0) + { + return 0; + } + } + // zero out dest memory + + walker = data; + + ////////// Parse source string, populating data + for(i=0; i= gNumStructForms || type < VOID_FORM) + { + prts_debug("Invalid datatype: %d\n", type); + return -2; + } + + // Walk argument list and populate struct into next memory in data pointer + walker = *ppData; + cd = (char*)walker; + sd = (short*)walker; + id = (int*)walker; + ud = (unsigned int*)walker; + ld = (long*)walker; + fd = (float*)walker; + + i = 0; + // Go to where in StructForms list has member type/count pairs. + // Skip 2 in StructForms for memory size and number of members. + numMembers = StructForms[type][1]; + + j = 2; + while(j < 2+ (numMembers*2)) + { + memberType = StructForms[type][j]; + // check type against valid enums + if(memberType >= gNumStructForms || memberType < BYTE_PAD_FORM) + { + prts_debug("Invalid member datatype: %d\n", memberType); + return -2; + } + memberCount = StructForms[type][j+1]; + // check for invalid number of members + if(memberCount < 0) + { + prts_debug("Negative members field value (%d) in datatype %d table\n", + numMembers, type); + return -4; + } + + switch(memberType) + { + case BYTE_PAD_FORM: + for(nestedTrav=0; nestedTrav 0) + { + i += temp; + } + else + { + return temp; + } + } + break; + } // switch + j+=2; + } // while + + *ppData = walker; + return i; +} + +int UnParseStruct(int dataType, void *pData, char *dest, int dest_size ) +{ + int numMembers; + void *walker; + int returnCode; + + + if(dataType >= gNumStructForms || dataType < VOID_FORM) + { + prts_debug("Invalid datatype: %d (min = %d, max = %d)\n", dataType, gNumStructForms, VOID_FORM); + return -2; + } + + // number of members in the struct + numMembers = StructForms[dataType][1]; + if( numMembers == 0 ) + { + // this is not an error, it handles the VOID_FORM case + // no members, so no work to do! + return 0; + } + + // check for improperly formed StructForms table + if(numMembers < 0) + { + prts_debug("Error: Negative members field value (%d) in datatype %d table\n", + numMembers, dataType); + return -4; + } + + // check for bogus data ptrs + if( pData == NULL || dest == NULL ) + return -1; + + + dest[0] = '\0'; // null terminate start of dest string so we can use strncat to append to it + walker = pData; + ////////// Parse source string, populating data + returnCode = unparseHelper(&walker, dest, dest_size, dataType); + // delete trailing ", " + if( strlen(dest) >= 2 ) + dest[strlen(dest)-2]='\0'; + prts_debug( "FINAL STRING: (%s)\n", dest ); + + return returnCode; +} // UnParseStruct + + + +int structcmpHelper(void **pData1, void **pData2, int type) +{ + int nestedTrav; // traverses element + int j; // traverses StructForms + int numMembers; // number of members inside the struct + + int temp; + + + int memberType; // enum of elements within a struct + int memberCount; // count of the elements, in case of an array + + void *walker1; // for walking memory of the struct being populated + char *cd1; + short *sd1; + int *id1; + unsigned int *ud1; + long *ld1; + float *fd1; + void *walker2; // for walking memory of the struct being populated + char *cd2; + short *sd2; + int *id2; + unsigned int *ud2; + long *ld2; + float *fd2; + + + if ( pData1 == NULL || *pData1 == NULL || + pData2 == NULL || *pData2 == NULL ) + return -1; + + // check type against valid enums + if(type >= gNumStructForms || type < VOID_FORM) + { + prts_debug("Invalid datatype: %d\n", type); + return -2; + } + + // Walk argument list and populate struct into next memory in data pointer + walker1 = *pData1; + cd1 = (char*)walker1; + sd1 = (short*)walker1; + id1 = (int*)walker1; + ud1 = (unsigned int*)walker1; + ld1 = (long*)walker1; + fd1 = (float*)walker1; + walker2 = *pData2; + cd2 = (char*)walker2; + sd2 = (short*)walker2; + id2 = (int*)walker2; + ud2 = (unsigned int*)walker2; + ld2 = (long*)walker2; + fd2 = (float*)walker2; + + // Go to where in StructForms list has member type/count pairs. + // Skip 2 in StructForms for memory size and number of members. + numMembers = StructForms[type][1]; + j = 2; + while(j < 2+ (numMembers*2)) + { + memberType = StructForms[type][j]; + // check type against valid enums + if(memberType >= gNumStructForms || memberType < BYTE_PAD_FORM) + { + prts_debug("Invalid member datatype: %d\n", memberType); + return -2; + } + memberCount = StructForms[type][j+1]; + // check for invalid number of members + if(memberCount < 0) + { + prts_debug("Negative members field value (%d) in datatype %d table\n", + numMembers, type); + return -4; + } + + switch(memberType) + { + case BYTE_PAD_FORM: + for(nestedTrav=0; nestedTrav= gNumStructForms || dataType < VOID_FORM) + { + prts_debug("Invalid datatype: %d\n", dataType); + return -2; + } + + // number of members in the struct + numMembers = StructForms[dataType][1]; + if ( numMembers == 0 ) + { + // this is not an error, it handles the VOID_FORM case + // no members, so no comparing to do, by def they are equal! + return 0; + } + // check for improperly formed StructForms table + if(numMembers < 0) + { + prts_debug("Error: Negative members field value (%d) in datatype %d table\n", + numMembers, dataType); + return -4; + } + + // make sure data ptrs are all good + if( pData1 == NULL || pData2 == NULL ) + return -1; + + + walker1 = pData1; + walker2 = pData2; + + ////////// Parse source string, populating data + returnCode = structcmpHelper(&walker1, &walker2, dataType); + + return returnCode; +} // StructCmp + + +int AddTokenStructForms(int count,int *NewForms) +{ + int i,c; + if( NewForms == NULL ) + return -1; + + + c = 0; + for ( i = 0; i < count; i++ ) + { + if ( gNumStructForms < MAX_STRUCT_FORMS ) + { + memcpy(&StructForms[gNumStructForms],&NewForms[i*MAX_STRUCT_MEMBERS],sizeof(int)*MAX_STRUCT_MEMBERS ); + gNumStructForms++; + c++; + } + else + break; + } + return c; + +} + +int TokenSystemInit() +{ + gNumStructForms = TOKENS_NUM_BASE_FORMS; + return 0; +} diff --git a/libraries/pmrt/pmrt_messages/tokens.h b/libraries/pmrt/pmrt_messages/tokens.h new file mode 100755 index 0000000..c3662c9 --- /dev/null +++ b/libraries/pmrt/pmrt_messages/tokens.h @@ -0,0 +1,62 @@ +// tokens.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef TOKENS_H +#define TOKENS_H + + +#define MAX_STRUCT_FORMS 256 +#define MAX_STRUCT_MEMBERS 256 + + +// Enumerate token primitives here +// should match definition of StructForms in tokens.h +// use AddTokenStructForms() to add additional structure forms from game code +typedef enum +{ + // primitives + VOID_FORM = 0, + BYTE_PAD_FORM, + CHAR_FORM, + SHORT_FORM, + INT_FORM, + UNSINT_FORM, + LONG_FORM, + FLOAT_FORM, + TOKENS_NUM_BASE_FORMS, +} e_BaseStructForms; + + +typedef struct +{ + int rows; + int fields; + int min_fields; // fields in the longest row + int max_fields; // fields in the shortest row + int current_token; +} token_data; + +// Parses string source and puts into struct pointed to by +// the pointer that is pointed to by pDest +int ParseStruct(int dataType, int memberCount, void **ppDest, char *source); +// reverse of ParseStruct +// converts structure of type dataType into a text string +// of space seperated values enclosed in single quotes +// (ie. "'val1' 'val2' ...") +// puts new string in dest +int UnParseStruct(int dataType, void *pData, char *dest, int dest_size ); +// Compares two structures of type dataType +// returns 0 if all members hold the same values +// returns 1 if any members hold different values +// returns -1 on error +int StructCmp(int dataType, void *pData1, void *pData2 ); + +extern int StructForms[MAX_STRUCT_FORMS][MAX_STRUCT_MEMBERS]; + +int AddTokenStructForms(int count,int *NewForms); + +int TokenSystemInit(); + +#endif + diff --git a/libraries/pmrt/pmrt_messages/tokens.o b/libraries/pmrt/pmrt_messages/tokens.o new file mode 100644 index 0000000..acb4c73 Binary files /dev/null and b/libraries/pmrt/pmrt_messages/tokens.o differ diff --git a/libraries/pmrt/pmrt_messages/vssver.scc b/libraries/pmrt/pmrt_messages/vssver.scc new file mode 100755 index 0000000..0fa9eab Binary files /dev/null and b/libraries/pmrt/pmrt_messages/vssver.scc differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/aescrypt.obj b/libraries/pmrt/pmrt_ssl/Debug/aescrypt.obj new file mode 100755 index 0000000..e9b2f48 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/aescrypt.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/datadigest.obj b/libraries/pmrt/pmrt_ssl/Debug/datadigest.obj new file mode 100755 index 0000000..3179958 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/datadigest.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/filecrypto.obj b/libraries/pmrt/pmrt_ssl/Debug/filecrypto.obj new file mode 100755 index 0000000..b41e0f0 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/filecrypto.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/keygenerate.obj b/libraries/pmrt/pmrt_ssl/Debug/keygenerate.obj new file mode 100755 index 0000000..c84c446 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/keygenerate.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/memcrypto.obj b/libraries/pmrt/pmrt_ssl/Debug/memcrypto.obj new file mode 100755 index 0000000..6f971a9 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/memcrypto.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/netssl.obj b/libraries/pmrt/pmrt_ssl/Debug/netssl.obj new file mode 100755 index 0000000..9eb30fb Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/netssl.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/pmrt_ssl.lib b/libraries/pmrt/pmrt_ssl/Debug/pmrt_ssl.lib new file mode 100755 index 0000000..41dd012 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/pmrt_ssl.lib differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/randomnumbers.obj b/libraries/pmrt/pmrt_ssl/Debug/randomnumbers.obj new file mode 100755 index 0000000..be6f9e9 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/randomnumbers.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/sslclient.obj b/libraries/pmrt/pmrt_ssl/Debug/sslclient.obj new file mode 100755 index 0000000..df361ce Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/sslclient.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/sslhttpclient.obj b/libraries/pmrt/pmrt_ssl/Debug/sslhttpclient.obj new file mode 100755 index 0000000..40c5af6 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/sslhttpclient.obj differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/vc60.idb b/libraries/pmrt/pmrt_ssl/Debug/vc60.idb new file mode 100755 index 0000000..734d43f Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/vc60.idb differ diff --git a/libraries/pmrt/pmrt_ssl/Debug/vc60.pdb b/libraries/pmrt/pmrt_ssl/Debug/vc60.pdb new file mode 100755 index 0000000..6886b1b Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/Debug/vc60.pdb differ diff --git a/libraries/pmrt/pmrt_ssl/aescrypt.c b/libraries/pmrt/pmrt_ssl/aescrypt.c new file mode 100755 index 0000000..27dfcf2 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/aescrypt.c @@ -0,0 +1,192 @@ +// aescrypt.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// wrapper functions for doing AES encryption + +#include "aescrypt.h" +#include + +int EncryptDataAES_OFB( unsigned char *key, unsigned char *iv, void *data, int data_len ) +{ + return CryptoMemOp( CRYPTO_ENCRYPT, CRYPTO_AES256_OFB, key, 32, iv, 16, + data, data_len, data, &data_len ); +} + +int DecryptDataAES_OFB( unsigned char *key, unsigned char *iv, void *data, int data_len ) +{ + return CryptoMemOp( CRYPTO_DECRYPT, CRYPTO_AES256_OFB, key, 32, iv, 16, + data, data_len, data, &data_len ); +} + + + +int EncryptFileAES_OFB( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ) +{ + return CryptoFileOp( srcfile, dstfile, CRYPTO_ENCRYPT, CRYPTO_AES256_OFB, key, 32, iv, 16 ); +} + +int DecryptFileAES_OFB( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ) +{ + return CryptoFileOp( srcfile, dstfile, CRYPTO_DECRYPT, CRYPTO_AES256_OFB, key, 32, iv, 16 ); +} + +int EncryptFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ) +{ + return CryptoFileOp( srcfile, dstfile, CRYPTO_ENCRYPT, CRYPTO_AES256_CBC, key, 32, iv, 16 ); +} + +int DecryptFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ) +{ + return CryptoFileOp( srcfile, dstfile, CRYPTO_DECRYPT, CRYPTO_AES256_CBC, key, 32, iv, 16 ); +} + +int DecryptFileAESIntoBuffer_OFB(unsigned char *key, unsigned char *iv, const char *srcfile, char **destBuffer, + unsigned int *outBufSize) +{ + FILE *inFile = NULL; + char *buffer = NULL; + int size = 0; + + if(!key || !iv || !srcfile || !destBuffer || !outBufSize) + return -1; + + inFile = fopen(srcfile, "rb"); + + size = UtilGetFileSize(inFile); + if(!size) + goto fail; + + buffer = (char*)malloc(sizeof(char)*size); + if(!buffer) + goto fail; + + if(fread(buffer, 1, size, inFile) != (size_t)size) + goto fail; + + fclose(inFile); + + if(DecryptDataAES_OFB(key, iv, buffer, size) != CRYPTOMEM_RESULT_SUCCESS) + goto fail; + + *destBuffer = buffer; + *outBufSize = size; + + return CRYPTOMEM_RESULT_SUCCESS; + +fail: + if(inFile) + fclose(inFile); + + if(buffer) + free(buffer); + + return -1; +} + + +int CompressEncryptFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile, int PrependUncompressedSize ) +{ + return CryptoZFileOp( srcfile, dstfile, CRYPTO_COMPRESS_ENCRYPT, CRYPTO_AES256_CBC, PrependUncompressedSize, key, 32, iv, 16 ); +} + +int DecryptDecompressFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile, int PrependUncompressedSize ) +{ + return CryptoZFileOp( srcfile, dstfile, CRYPTO_DECRYPT_DECOMPRESS, CRYPTO_AES256_CBC, PrependUncompressedSize, key, 32, iv, 16 ); +} + + +// assumes file was written with Prepend Size option set +int DecryptDecompressFileIntoBufferAES_CBC(unsigned char *key, unsigned char *iv, + const char *srcfile, int PrependUncompressedSize, + char **destBuffer, unsigned int *outBufSize, + void *(*malloc_func)(size_t), void (*free_func)(void *) ) +{ + int ec = 0; + int bytes = 0; + int fsize = 0; + int mallocd = 0; + CryptoZFileHandle cfh; + + if(!key || !iv || !srcfile || !destBuffer || !outBufSize) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + if ( *destBuffer != NULL && (outBufSize == NULL || *outBufSize == 0) ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + if( *destBuffer == NULL && ! PrependUncompressedSize ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + if ( malloc_func == NULL ) + malloc_func = malloc; + if (free_func == NULL ) + free_func = free; + + + ec = CryptoZFileInit( &cfh, CRYPTO_DECRYPT_DECOMPRESS, CRYPTO_AES256_CBC, srcfile, key, 32, iv, 16 ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + return ec; + } + + + mallocd = 0; + if ( *destBuffer == NULL ) + { + bytes = sizeof(int); + ec = CryptoZFileRead( &cfh, &fsize, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS || bytes != sizeof(int) ) + { + CryptoZFileClose(&cfh); + return ec; + } + *destBuffer = malloc_func(fsize); + if ( *destBuffer == NULL ) + { + CryptoZFileClose(&cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + if ( outBufSize != NULL ) + *outBufSize = fsize; + else + outBufSize = &fsize; + + mallocd = 1; + } + else if ( PrependUncompressedSize ) + { + bytes = sizeof(int); + ec = CryptoZFileRead( &cfh, &fsize, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS || bytes != sizeof(int) ) + { + CryptoZFileClose(&cfh); + return ec; + } + *outBufSize = fsize; + } + + + + bytes = *outBufSize; + + + ec = CryptoZFileRead( &cfh, *destBuffer, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) // || (PrependUncompressedSize && bytes != *outBufSize) ) + { + if ( mallocd ) + { + *outBufSize = 0; + free_func( *destBuffer ); + } + CryptoZFileClose(&cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + CryptoZFileClose( &cfh ); + + // note the number of bytes actually read out + *outBufSize = bytes; + + return CRYPTOFILE_RESULT_SUCCESS; + +} \ No newline at end of file diff --git a/libraries/pmrt/pmrt_ssl/aescrypt.h b/libraries/pmrt/pmrt_ssl/aescrypt.h new file mode 100755 index 0000000..3a71e4a --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/aescrypt.h @@ -0,0 +1,44 @@ +// aescrypt.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// wrapper functions for doing AES encryption + +#ifndef AESCRYPT_H +#define AESCRYPT_H + +#include "filecrypto.h" +#include "memcrypto.h" + + +// key size MUST be 32 +// iv size MUST be 16 +// these lengths are not checked so use with care +int EncryptDataAES_OFB( unsigned char *key, unsigned char *iv, void *data, int data_len ); +int DecryptDataAES_OFB( unsigned char *key, unsigned char *iv, void *data, int data_len ); + +int EncryptFileAES_OFB( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ); +int DecryptFileAES_OFB( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ); + +//buffer must be freed by user +int DecryptFileAESIntoBuffer_OFB(unsigned char *key, unsigned char *iv, const char *srcfile, char **destBuffer, + unsigned int *outBufSize); + +int EncryptFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ); +int DecryptFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile ); + + +int CompressEncryptFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile, int PrependUncompressedSize ); +int DecryptDecompressFileAES_CBC( unsigned char *key, unsigned char *iv, const char *srcfile, const char *dstfile, int PrependUncompressedSize ); + + +int DecryptDecompressFileIntoBufferAES_CBC(unsigned char *key, unsigned char *iv, + const char *srcfile, int PrependUncompressedSize, + char **destBuffer, unsigned int *outBufSize, + void *(*malloc_func)(size_t), void (*free_func)(void *) ); + + + + +#endif + diff --git a/libraries/pmrt/pmrt_ssl/aescrypt.o b/libraries/pmrt/pmrt_ssl/aescrypt.o new file mode 100644 index 0000000..c33d602 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/aescrypt.o differ diff --git a/libraries/pmrt/pmrt_ssl/datadigest.c b/libraries/pmrt/pmrt_ssl/datadigest.c new file mode 100755 index 0000000..204ebeb --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/datadigest.c @@ -0,0 +1,441 @@ +// datadigest.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "datadigest.h" +#if SYS_PC +#include +#endif + +#if SYS_BB +#include +#endif + +#include +#include +#include +#include +#include + +// to print err string: +// printf( "ERR: %s\n", ERR_error_string(ERR_get_error(),NULL) ); + + +void FreeDataDigestHandle(DataDigestHandle *ddh) +{ + if( ddh == NULL ) + return; + + if ( ddh->digest_bio != NULL ) + BIO_free(ddh->digest_bio); + + if ( ddh->null_bio != NULL ) + BIO_free(ddh->null_bio); + + ddh->digest_bio = NULL; + ddh->null_bio = NULL; + memset(ddh->digest,0,sizeof(ddh->digest)); + ddh->digest_len = 0; + +} + +int CloseDataDigest(DataDigestHandle *ddh ) +{ + FreeDataDigestHandle(ddh); + return 0; +} + +int ComputeDataDigest(DataDigestHandle *ddh ) +{ + int ec; + EVP_MD_CTX *mdcp; + if( ddh == NULL ) + return DATADIGEST_RESULT_INVALID_HANDLE; + mdcp = NULL; + ec = BIO_get_md_ctx(ddh->digest_bio, &mdcp ); + if ( ec < 0 || mdcp == NULL ) + { + FreeDataDigestHandle(ddh); + return DATADIGEST_RESULT_FAILURE; + } + + // clear out old digest + memset(ddh->digest,0,sizeof(ddh->digest)); + ddh->digest_len = 0; + + ec = EVP_DigestFinal( mdcp, ddh->digest, &ddh->digest_len ); + if ( ec < 0 ) + { + FreeDataDigestHandle(ddh); + return DATADIGEST_RESULT_FAILURE; + } + + + // reset digest, so we can use it digest some more/different data + BIO_set_md(ddh->digest_bio, ddh->digest_method); + + BIO_reset(ddh->digest_bio); + + + return DATADIGEST_RESULT_SUCCESS; +} + +int InitDataDigest(DataDigestHandle *ddh, int method ) +{ + // const EVP_MD *digest_method = NULL; + + if( ddh == NULL ) + return DATADIGEST_RESULT_INVALID_HANDLE; + + ddh->digest_bio = NULL; + + // setup to digest stream + ddh->digest_bio = BIO_new(BIO_f_md()); + if ( ddh->digest_bio == NULL ) + { + FreeDataDigestHandle(ddh); + return DATADIGEST_RESULT_FAILURE; + } + + + switch(method) + { + case DIGEST_MD5: + ddh->digest_method = EVP_md5(); + break; + case DIGEST_SHA1: + ddh->digest_method = EVP_sha1(); + break; + default: // no digest + ddh->digest_method = EVP_md_null(); + break; + } + + // set digest method + if( BIO_set_md(ddh->digest_bio, ddh->digest_method) < 0 ) + { + FreeDataDigestHandle(ddh); + return DATADIGEST_RESULT_FAILURE; + } + + + + // setup null stream + ddh->null_bio = BIO_new(BIO_s_null()); + if ( ddh->null_bio == NULL ) + { + FreeDataDigestHandle(ddh); + return DATADIGEST_RESULT_FAILURE; + } + + // chain the bios + if ( BIO_push(ddh->digest_bio,ddh->null_bio) < 0 ) + { + FreeDataDigestHandle(ddh); + return DATADIGEST_RESULT_FAILURE; + } + + + + return DATADIGEST_RESULT_SUCCESS; + +} + +int WriteToDataDigest( DataDigestHandle *ddh, void *data, int *size ) +{ + int ec; + if( ddh == NULL || ddh->digest_bio == NULL ) + return DATADIGEST_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return DATADIGEST_RESULT_INVALID_PARAMS; + + + + ec = BIO_write(ddh->digest_bio, data, *size ); + if ( ec <= 0 ) + return DATADIGEST_RESULT_FAILURE; + + + *size = ec; + + return DATADIGEST_RESULT_SUCCESS; +} + + +int DataDigestMem( int method, void *data, int size, unsigned char *digest, unsigned int *digest_len ) +{ + int ec,s; + DataDigestHandle ddh; + + if ( data == NULL || size <= 0 || digest == NULL || digest_len == NULL || *digest_len <= 0 ) + { + return DATADIGEST_RESULT_INVALID_PARAMS; + } + + ec = InitDataDigest( &ddh, method ); + if ( ec != DATADIGEST_RESULT_SUCCESS ) + return ec; + + s = size; + ec = WriteToDataDigest( &ddh, data, &s ); + if ( ec != DATADIGEST_RESULT_SUCCESS || s != size ) + { + CloseDataDigest(&ddh); + return DATADIGEST_RESULT_FAILURE; + } + + ec = ComputeDataDigest(&ddh); + if ( ec != DATADIGEST_RESULT_SUCCESS ) + { + CloseDataDigest(&ddh); + return ec; + } + + // didn't provide enough space for digest + if ( ddh.digest_len > *digest_len ) + { + CloseDataDigest(&ddh); + return DATADIGEST_RESULT_FAILURE; + } + + // zero out existing data + memset(digest,0,*digest_len); + // copy the digest and it's length + memcpy(digest,ddh.digest,ddh.digest_len); + *digest_len = ddh.digest_len; + + // all done! + CloseDataDigest(&ddh); + return DATADIGEST_RESULT_SUCCESS; + +} + +int DataDigestFile( int method, char *filename, unsigned char *digest, unsigned int *digest_len ) +{ + + int ec; + BIO *file_bio; + BIO *digest_bio; + char buf[1024]; + unsigned int len; + const EVP_MD *digest_method = NULL; + EVP_MD_CTX *mdcp = NULL; + + file_bio = NULL; + digest_bio = NULL; + + // set file bio + file_bio = BIO_new_file(filename,"rb"); + if ( file_bio == NULL ) + { + return DATADIGEST_RESULT_FAILURE; + } + + // setup to digest stream + digest_bio = BIO_new(BIO_f_md()); + if ( digest_bio == NULL ) + { + BIO_free(file_bio); + return DATADIGEST_RESULT_FAILURE; + } + + switch(method) + { + case DIGEST_MD5: + digest_method = EVP_md5(); + break; + case DIGEST_SHA1: + digest_method = EVP_sha1(); + break; + default: // no digest + digest_method = EVP_md_null(); + break; + } + + // set digest method + if( BIO_set_md(digest_bio, digest_method) < 0 ) + { + BIO_free(file_bio); + BIO_free(digest_bio); + return DATADIGEST_RESULT_FAILURE; + } + + + // chain the bios + if ( BIO_push(digest_bio,file_bio) < 0 ) + { + BIO_free(file_bio); + BIO_free(digest_bio); + return DATADIGEST_RESULT_FAILURE; + } + + + // read in data 1k at a time + ec = 0; + while ( ec >= 0 ) + { + ec = BIO_read(digest_bio, buf, sizeof(buf) ); + if ( ec == 0 && BIO_should_retry(digest_bio) == 0 ) // EOF + break; + if ( ec < 0 ) + break; + } + + // read failed :( + if ( ec < 0 ) + { + BIO_free(file_bio); + BIO_free(digest_bio); + return DATADIGEST_RESULT_FAILURE; + } + + // extract digest value + ec = BIO_get_md_ctx(digest_bio, &mdcp ); + if ( ec < 0 || mdcp == NULL ) + { + BIO_free(file_bio); + BIO_free(digest_bio); + return DATADIGEST_RESULT_FAILURE; + } + + + len = EVP_MD_CTX_size(mdcp); + // didn't provide enough space for digest! + if ( len > *digest_len ) + { + BIO_free(file_bio); + BIO_free(digest_bio); + return DATADIGEST_RESULT_FAILURE; + } + + // clear out any existing data + memset(digest,0,*digest_len); + + ec = EVP_DigestFinal( mdcp, digest, digest_len ); + if ( ec < 0 ) + { + BIO_free(file_bio); + BIO_free(digest_bio); + return DATADIGEST_RESULT_FAILURE; + } + + // all done! + BIO_free(file_bio); + BIO_free(digest_bio); + + return DATADIGEST_RESULT_SUCCESS; + +} + + +int ConvertDataDigestToHexString( unsigned char *digest, unsigned int digest_len, char *dest, unsigned int dest_len, char seperator ) +{ + unsigned int i; + char buf[4]; + if ( digest == NULL || dest == NULL ) + return -1; +// if ( dest_len < 3 * digest_len ) +// return -2; + + memset( dest, 0, dest_len ); + + if ( seperator > 0 ) + { + for ( i = 0; i < digest_len - 1; i++ ) + { + sprintf( buf, "%02x%c", digest[i], seperator ); + if ( dest_len > 3 ) // need room for new chars plus NULL terminator + { + strncat(dest, buf, 3 ); + dest_len -= 3; + } + } + // do last byte w/o a trailing seperator + sprintf( buf, "%02x", digest[digest_len-1] ); + if ( dest_len > 2 ) // need room for new chars plus NULL terminator + { + strncat(dest, buf, 2 ); + dest_len -= 2; + } + + } + else + { + // no seperator + for ( i = 0; i < digest_len ; i++ ) + { + sprintf( buf, "%02x", digest[i] ); + if ( dest_len > 2 ) // need room for new chars plus NULL terminator + { + strncat(dest, buf, 2 ); + dest_len -= 2; + } + } + } + + + + return 0; + +} + +int ConvertHexStringToDataDigest( char *src, unsigned int src_len, unsigned char *digest, unsigned int digest_len, char seperator ) +{ + unsigned int i,j; + int ec; + char buf[3]; + char *start; + if ( digest == NULL || src == NULL ) + return -1; + if (seperator > 0 && src_len < 3 * digest_len ) + return -2; + if (seperator <= 0 && src_len < 2 * digest_len ) + return -2; + + memset( digest, 0, digest_len ); + + j = 0; + start = src; + for ( i = 0; i < digest_len; i++ ) + { + memset( buf, 0, 3 ); + memcpy( buf, start, 2 ); + + sscanf(buf, "%02x", &ec ); + digest[i] = ec; + if ( seperator > 0 ) + { + start+=3; + j += 3; + } + else + { + start+=2; + j += 2; + } + if ( j > src_len ) + break; + } + + return 0; + +} + +int DataDigestCmp( unsigned char *digest1, unsigned char *digest2, unsigned int digest_len ) +{ + unsigned int i; + if ( digest1 == NULL || digest2 == NULL ) + return -1; + + for ( i = 0; i < digest_len; i++ ) + { + if ( digest1[i] != digest2[i] ) + return 1; + } + + return 0; +} + + diff --git a/libraries/pmrt/pmrt_ssl/datadigest.h b/libraries/pmrt/pmrt_ssl/datadigest.h new file mode 100755 index 0000000..d2ef571 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/datadigest.h @@ -0,0 +1,62 @@ +// datadigest.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + + +#ifndef DATADIGEST_H +#define DATADIGEST_H + + +#include +#include +#include +#include + +enum +{ + DATADIGEST_RESULT_SUCCESS, + DATADIGEST_RESULT_INVALID_HANDLE, + DATADIGEST_RESULT_INVALID_PARAMS, + DATADIGEST_RESULT_FAILURE, +}; + +enum +{ + DIGEST_MD5, + DIGEST_SHA1, +}; + +#define DATADIGEST_MAX_DIGEST_LEN EVP_MAX_MD_SIZE + +#define DIGEST_MD5_LEN 16 +#define DIGEST_SHA1_LEN 20 + +typedef struct +{ + BIO *digest_bio; + BIO *null_bio; + const EVP_MD *digest_method; + + unsigned char digest[EVP_MAX_MD_SIZE]; + unsigned int digest_len; +} DataDigestHandle; + + +int InitDataDigest(DataDigestHandle *ddh, int type ); +int CloseDataDigest(DataDigestHandle *ddh ); +int WriteToDataDigest(DataDigestHandle *ddh, void *data, int *size ); +int ComputeDataDigest(DataDigestHandle *ddh ); + +int DataDigestMem( int method, void *data, int size, unsigned char *digest, unsigned int *digest_len ); + +int DataDigestFile( int method, char *file, unsigned char *digest, unsigned int *digest_len ); + +int DataDigestCmp( unsigned char *digest1, unsigned char *digest2, unsigned int digest_len ); + +int ConvertDataDigestToHexString( unsigned char *digest, unsigned int digest_len, char *dest, unsigned int dest_len, char seperator ); +int ConvertHexStringToDataDigest( char *src, unsigned int src_len, unsigned char *digest, unsigned int digest_len, char seperator ); + +#endif + + diff --git a/libraries/pmrt/pmrt_ssl/datadigest.o b/libraries/pmrt/pmrt_ssl/datadigest.o new file mode 100644 index 0000000..634ca3a Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/datadigest.o differ diff --git a/libraries/pmrt/pmrt_ssl/filecrypto.c b/libraries/pmrt/pmrt_ssl/filecrypto.c new file mode 100755 index 0000000..bf54746 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/filecrypto.c @@ -0,0 +1,787 @@ +// filecrypto.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "filecrypto.h" +#if SYS_PC +#include +#endif + +#if SYS_BB +#include +#endif + +#include +#include +#include +#include +#include +#include + + +void FreeCryptoFileHandle(CryptoFileHandle *cfh) +{ + if( cfh == NULL ) + return; + + if ( cfh->crypto_bio != NULL ) + BIO_free(cfh->crypto_bio); + + if ( cfh->file_bio != NULL ) + BIO_free(cfh->file_bio); + + cfh->file_bio = NULL; + cfh->crypto_bio = NULL; + + return; +} + +int OpenCryptoFile( CryptoFileHandle *cfh, const char *filename, const char *mode, int CryptoMode, int CryptoAlg, + const unsigned char *key, int key_len, const unsigned char *iv, int iv_len ) +{ + EVP_CIPHER_CTX *cipher_ctx; + int enc_mode; + int min_iv_len; + + if( cfh == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + cfh->eof = 0; + cfh->file_bio = NULL; + cfh->crypto_bio = NULL; + + + //setup the file bio + + + cfh->file_bio = BIO_new_file(filename,mode); + if ( cfh->file_bio == NULL ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + + // keep track of wether we are opening this file for + // reading or writing (need to call BIO_flush on writing, but not on reading BIOs) + cfh->writing = 0; + + if ( mode[0] == 'w' || mode[0] == 'a' ) + cfh->writing = 1; + + + // setup the crypto stream + cfh->crypto_bio = BIO_new(BIO_f_cipher()); + if ( cfh->crypto_bio == NULL ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + cipher_ctx = NULL; + + if( CryptoMode == CRYPTO_ENCRYPT ) + enc_mode = 1; + else // decrypt + enc_mode = 0; + + switch( CryptoAlg ) + { + case CRYPTO_BLOWFISH: + // make sure initial vector is at least as long as required + min_iv_len = EVP_CIPHER_iv_length(EVP_bf_cbc()); + if ( iv_len < min_iv_len ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + BIO_set_cipher( cfh->crypto_bio, EVP_bf_cbc(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cfh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + // set the key length + if ( EVP_CIPHER_CTX_set_key_length(cipher_ctx,key_len) < 0 ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + break; + case CRYPTO_AES256_CBC: + min_iv_len = EVP_CIPHER_iv_length(EVP_aes_256_cbc()); + if ( iv_len < min_iv_len ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + if ( key_len < 32 ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + BIO_set_cipher( cfh->crypto_bio, EVP_aes_256_cbc(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cfh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + // key length is fixed at 256, so don't set + break; + case CRYPTO_AES256_OFB: + min_iv_len = EVP_CIPHER_iv_length(EVP_aes_256_ofb()); + if ( iv_len < min_iv_len ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + if ( key_len < 32 ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + BIO_set_cipher( cfh->crypto_bio, EVP_aes_256_ofb(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cfh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + // key length is fixed at 256, so don't set + break; + case CRYPTO_AES256_CFB: + min_iv_len = EVP_CIPHER_iv_length(EVP_aes_256_cfb()); + if ( iv_len < min_iv_len ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + if ( key_len < 32 ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + BIO_set_cipher( cfh->crypto_bio, EVP_aes_256_cfb(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cfh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + // key length is fixed at 256, so don't set + break; + default: + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + break; + } + + // chain the bios + if ( BIO_push(cfh->crypto_bio,cfh->file_bio) < 0 ) + { + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + // ta dah! now anything we read/write to the file will be + // either encrypted or unencrypted as it's read/written! + + + return CRYPTOFILE_RESULT_SUCCESS; + +} + + +int ReadFromCryptoFile( CryptoFileHandle *cfh, void *data, int *size ) +{ + + int ec; + if( cfh == NULL || cfh->crypto_bio == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + if ( cfh->eof ) + { + *size = 0; + return CRYPTOFILE_RESULT_EOF; + } + + ec = BIO_read(cfh->crypto_bio, data, *size ); + if ( ec < 0 ) + return CRYPTOFILE_RESULT_FAILURE; + + *size = ec; + + if ( ec == 0 ) + { + // this could indicate a decrypt err on last block or EOF + // from what I could tell, this does not check for decrypt + // w/ wrong key (no way to test that, except to verify CRC of decrypted data) + // rather it tests for a file w/o enough bits in last block for + // the cipher (ciphers always round up to blocks of a certain size) + if ( BIO_get_cipher_status(cfh->crypto_bio) == 0 ) + { + return CRYPTOFILE_RESULT_DECRYPT_FAILURE; + } + else if ( BIO_should_retry(cfh->crypto_bio) == 0 ) // EOF + { + // mark that the end of file has been reached + cfh->eof = 1; + return CRYPTOFILE_RESULT_EOF; + } + } + + return CRYPTOFILE_RESULT_SUCCESS; +} + +int WriteToCryptoFile( CryptoFileHandle *cfh, void *data, int *size ) +{ + int ec; + if( cfh == NULL || cfh->crypto_bio == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + + ec = BIO_write(cfh->crypto_bio, data, *size ); + if ( ec <= 0 ) + return CRYPTOFILE_RESULT_FAILURE; + + *size = ec; + + return CRYPTOFILE_RESULT_SUCCESS; +} + +int CloseCryptoFile( CryptoFileHandle *cfh ) +{ + if( cfh == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + if ( cfh->writing == 1 ) + BIO_flush(cfh->crypto_bio); + + FreeCryptoFileHandle(cfh); + return CRYPTOFILE_RESULT_SUCCESS; + +} + +int CheckCryptoFileEOF( CryptoFileHandle *cfh ) +{ + if( cfh == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + +// This stuff doesn't work b/c feof and BIO_eof only return EOF +// /after/ you have tried to read past EOF +/* + int ec; + FILE *fp; + + fp = cfh->file_bio->ptr; + ec = feof(fp); + + ec = BIO_ctrl(cfh->crypto_bio, BIO_CTRL_EOF, 0, NULL); + prts_debug( "BIO_eof returned %d\n", ec ); + // if ( BIO_ctrl(cfh->crypto_bio, BIO_CTRL_EOF, 0, NULL) ) + if ( ec ) + { + cfh->eof = 1; + } +*/ + return cfh->eof; +} + + +int CryptoFileOp( const char *srcfile, const char *dstfile, int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len ) +{ + int ec; + int bytes; + char buf[1024]; + + CryptoFileHandle cfh; + BIO *outfile; + + if( dstfile == NULL || srcfile == NULL ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + outfile = BIO_new_file(dstfile,"wb"); + if ( outfile == NULL ) + { + return CRYPTOFILE_RESULT_FAILURE; + } + + ec = OpenCryptoFile( &cfh, srcfile, "rb", CryptoMode, CryptoAlg, key, key_len, iv, iv_len ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + BIO_free(outfile); + return ec; + } + + while( ! CheckCryptoFileEOF( &cfh ) ) + { + bytes = sizeof(buf); + ec = ReadFromCryptoFile( &cfh, buf, &bytes ); + if ( ec == CRYPTOFILE_RESULT_EOF ) + { + break; + } + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + BIO_free(outfile); + CloseCryptoFile(&cfh); + return ec; + } + + ec = BIO_write(outfile, buf, bytes ); + if ( ec <= 0 ) + { + BIO_free(outfile); + CloseCryptoFile(&cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + } + + // all done! + BIO_free(outfile); + CloseCryptoFile(&cfh); + + return CRYPTOFILE_RESULT_SUCCESS; +} + + +/* +int CryptoZFileInit(CryptoZFileHandle *handle, CryptoZModes CryptoZMode, const char *fileName, const unsigned char *fileKey, + int keySize, const unsigned char *iv, int ivSize, void *inBuffer, int inSize); +int CrytpoZFileRead(CryptoZFileHandle *zhandle, void *outData, unsigned int outSize); +void CryptoZFileClose(CryptoZFileHandle *zhandle); +*/ + +int CryptoZFileInit(CryptoZFileHandle *handle, int CryptoZMode, int CryptoAlg, + const char *filename, const unsigned char *key, int key_len, + const unsigned char *iv, int iv_len ) +{ + int ec; + if ( handle == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + if ( filename == NULL || key == NULL || key_len < 0 || iv == NULL || iv_len < 0 ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + + memset(handle, 0, sizeof(CryptoZFileHandle)); + handle->stream.zalloc = Z_NULL; + handle->stream.zfree = Z_NULL; + handle->stream.opaque = Z_NULL; + handle->mode = CryptoZMode; + + if(handle->mode == CRYPTO_DECRYPT_DECOMPRESS) + { + + ec = OpenCryptoFile(&handle->crypFile, filename, "rb", CRYPTO_DECRYPT, CryptoAlg, + key, key_len, iv, iv_len); + if( ec != CRYPTOFILE_RESULT_SUCCESS) + return ec; + + ec = inflateInit(&handle->stream); + if( ec != Z_OK) + { + handle->zlib_err = ec; + return CRYPTOFILE_RESULT_ZLIB_ERR; + } + + handle->inBuffer = handle->origBuffer; + handle->inBufSize = sizeof(handle->origBuffer); + handle->stream.next_in = handle->inBuffer; + } + else if(handle->mode == CRYPTO_COMPRESS_ENCRYPT ) + { + ec = OpenCryptoFile(&handle->crypFile, filename, "wb", CRYPTO_ENCRYPT, CryptoAlg, + key, key_len, iv, iv_len); + if( ec != CRYPTOFILE_RESULT_SUCCESS) + return ec; + + ec = deflateInit(&handle->stream, 6 ); + if( ec != Z_OK) + { + handle->zlib_err = ec; + return CRYPTOFILE_RESULT_ZLIB_ERR; + } + + handle->outBuffer = handle->origBuffer; + handle->outBufSize = sizeof(handle->origBuffer); + handle->stream.next_out = handle->outBuffer; + + } + else + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + + + + return 0; +} + +int CryptoZFileRead(CryptoZFileHandle *zhandle, void *outData, unsigned int *outSize) +{ + int ret = 0; + + if ( zhandle == NULL || zhandle->mode != CRYPTO_DECRYPT_DECOMPRESS ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + + if ( outData == NULL || outSize == NULL || *outSize == 0 ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + zhandle->stream.avail_out = *outSize; + zhandle->stream.next_out = outData; + + do + { + //if there are bytes available in the stream, then leave them alone. Otherwise we need moar bytes + int len = (zhandle->stream.avail_in == 0) ? zhandle->inBufSize - zhandle->stream.total_out : zhandle->stream.avail_in; + + //if we don't have any available bytes left, read in more + if(!zhandle->stream.avail_in) + { + //reset the length and buffer pointer to original values + len = zhandle->inBufSize; + zhandle->inBuffer = zhandle->origBuffer; + + zhandle->stream.total_out = 0; + + //decrypt + ret = ReadFromCryptoFile(&zhandle->crypFile, zhandle->inBuffer, &len); + if ( ret == CRYPTOFILE_RESULT_EOF ) + { + // we have run out of bytes in our buffer and in our + // source file + // note that this error is only terminal when we get + // back 0 bytes read, otherwise it means we read some + // bytes and then hit EOF, in that case keep processing + // the data that was read out + if ( len == 0 ) + { + // set total bytes read out + *outSize = *outSize - zhandle->stream.avail_out; + zhandle->eof = 1; + return CRYPTOFILE_RESULT_EOF; + } + } + else if(ret != CRYPTOFILE_RESULT_SUCCESS) + return ret; + } + + zhandle->stream.avail_in = len; + + zhandle->stream.next_in = zhandle->inBuffer; + + //decompress + ret = inflate(&zhandle->stream, Z_NO_FLUSH); + if(ret == Z_STREAM_ERROR) /* state not clobbered */ + { + zhandle->zlib_err = ret; + *outSize = *outSize - zhandle->stream.avail_out; // set the number read out + return CRYPTOFILE_RESULT_ZLIB_ERR; + } + + switch (ret) + { + case Z_NEED_DICT: + ret = Z_DATA_ERROR; /* and fall through */ + + case Z_DATA_ERROR: + case Z_MEM_ERROR: + { + zhandle->zlib_err = ret; + *outSize = *outSize - zhandle->stream.avail_out; // set the number read out + CryptoZFileClose( zhandle ); + return CRYPTOFILE_RESULT_ZLIB_ERR; + } + } + + } while(zhandle->stream.avail_out > 0); + + //save the position the stream is at + zhandle->inBuffer = zhandle->stream.next_in; + + // if we got this far than we read *outSize bytes, so don't change that value + + return CRYPTOFILE_RESULT_SUCCESS; +} + + +int CryptoZFileWrite(CryptoZFileHandle *zhandle, void *inData, unsigned int *inSize) +{ + int ret = 0; + int have,wrote; + int zflush_state; + unsigned int z; + + if ( zhandle == NULL || zhandle->mode != CRYPTO_COMPRESS_ENCRYPT ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + + + zflush_state = Z_NO_FLUSH; + + if ( inData == NULL && inSize == NULL ) + { + // this is our signal to finish the compress + // and close the zstream + zflush_state = Z_FINISH; + // point our inSize ptr to a zero uns + z = 0; + inSize = &z; + } + else if ( inData == NULL || inSize == NULL || *inSize == 0 ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + + // point z stream to our input data + zhandle->stream.avail_in = *inSize; + zhandle->stream.next_in = inData; + + + // spin on deflate until it does not fill the output buffer + // writing output data to file as we go + do + { + + zhandle->stream.avail_out = zhandle->outBufSize; + zhandle->stream.next_out = zhandle->outBuffer; + + ret = deflate(&zhandle->stream, zflush_state); + if ( ret == Z_STREAM_ERROR ) + { + *inSize = *inSize - zhandle->stream.avail_in; // how many of our bytes got written + zhandle->zlib_err = ret; + zhandle->err = 1; // important to set this so CryptoZFileClose() does not try to 'finish' the compression stream + CryptoZFileClose(zhandle); + return CRYPTOFILE_RESULT_ZLIB_ERR; + // all other errs are non-fatal + } + + *inSize = *inSize - zhandle->stream.avail_in; // how many input bytes have been written so far + + // check how many bytes got put in the output buffer + have = zhandle->outBufSize - zhandle->stream.avail_out; + + // write new compressed bytes out to the disk + if ( have > 0 ) + { + wrote = have; + ret = WriteToCryptoFile(&zhandle->crypFile, zhandle->outBuffer, &wrote); + if ( ret != CRYPTOFILE_RESULT_SUCCESS ) + { + zhandle->err = 1; // important to set this so CryptoZFileClose() does not try to 'finish' the compression stream + CryptoZFileClose(zhandle); + return ret; + } + if ( wrote != have ) + { + zhandle->err = 1; // important to set this so CryptoZFileClose() does not try to 'finish' the compression stream + CryptoZFileClose(zhandle); + return CRYPTOFILE_RESULT_WRITE_FAILURE; + } + } + } while ( zhandle->stream.avail_out == 0 ); + + + return CRYPTOFILE_RESULT_SUCCESS; +} + + + +int CryptoZFileClose(CryptoZFileHandle *zhandle) +{ + + if ( zhandle == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + if ( zhandle->closed ) // handle already closed + return CRYPTOFILE_RESULT_SUCCESS; + + + if( zhandle->mode == CRYPTO_DECRYPT_DECOMPRESS ) + { + CloseCryptoFile(&zhandle->crypFile); + inflateEnd(&zhandle->stream); + zhandle->closed = 1; + } + + if ( zhandle->mode == CRYPTO_COMPRESS_ENCRYPT ) + { + if ( ! zhandle->err && ! zhandle->zlib_err ) + CryptoZFileWrite( zhandle, NULL, NULL ); + deflateEnd(&zhandle->stream); + zhandle->closed = 1; + CloseCryptoFile(&zhandle->crypFile); + } + return CRYPTOFILE_RESULT_SUCCESS; +} + +int CheckCryptoZFileEOF( CryptoZFileHandle *zhandle ) +{ + if ( zhandle == NULL ) + return CRYPTOFILE_RESULT_INVALID_HANDLE; + + return zhandle->eof; +} + + + +// big wrapper func +int CryptoZFileOp( const char *srcfile, const char *dstfile, + int CryptoZMode, int CryptoAlg, int PrependUncompressedSize, + const unsigned char *key, int key_len, const unsigned char *iv, int iv_len ) +{ + int fsize; + int ec; + unsigned int bytes; + char buf[128*128]; + + CryptoZFileHandle cfh; + BIO *file; + + if ( srcfile == NULL || dstfile == NULL || key == NULL || key_len < 0 || iv == NULL || iv_len == 0 ) + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + + if(CryptoZMode == CRYPTO_DECRYPT_DECOMPRESS) + { + file = BIO_new_file(dstfile,"wb"); + if ( file == NULL ) + { + return CRYPTOFILE_RESULT_FAILURE; + } + + ec = CryptoZFileInit( &cfh, CRYPTO_DECRYPT_DECOMPRESS, CryptoAlg, srcfile, key, key_len, iv, iv_len ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + BIO_free(file); + return ec; + } + + // indicates that the first 4-bytes of input will be the uncompressed file size + if ( PrependUncompressedSize ) + { + bytes = sizeof(int); + ec = CryptoZFileRead( &cfh, &fsize, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS && ec != CRYPTOFILE_RESULT_EOF ) + { + BIO_free(file); + CryptoZFileClose(&cfh); + return ec; + } + } + + while( ! CheckCryptoZFileEOF( &cfh ) ) + { + bytes = sizeof(buf); + ec = CryptoZFileRead( &cfh, buf, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS && ec != CRYPTOFILE_RESULT_EOF ) + { + BIO_free(file); + CryptoZFileClose(&cfh); + return ec; + } + + ec = BIO_write(file, buf, bytes ); + if ( ec <= 0 ) + { + BIO_free(file); + CryptoZFileClose(&cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + } + + // all done! + BIO_free(file); + CryptoZFileClose(&cfh); + + return CRYPTOFILE_RESULT_SUCCESS; + } + + if(CryptoZMode == CRYPTO_COMPRESS_ENCRYPT) + { + + + ec = CryptoZFileInit( &cfh, CRYPTO_COMPRESS_ENCRYPT, CryptoAlg, dstfile, key, key_len, iv, iv_len ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + return ec; + } + + // indicates that the first 4-bytes of output will be the uncompressed file size + // useful for knowing how many bytes to malloc if loading the compressed file all at once + if ( PrependUncompressedSize ) + { + fsize = FsFileSize( srcfile ); + if ( fsize < 0 ) + { + CryptoZFileClose(&cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + bytes = sizeof(int); + ec = CryptoZFileWrite( &cfh, &fsize, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS && ec != CRYPTOFILE_RESULT_EOF ) + { + CryptoZFileClose(&cfh); + return ec; + } + } + + + file = BIO_new_file(srcfile,"rb"); + if ( file == NULL ) + { + CryptoZFileClose(&cfh); + return CRYPTOFILE_RESULT_FAILURE; + } + + while( (ec = BIO_read(file, buf, sizeof(buf) ) ) >= 0 ) + { + bytes = ec; + if ( bytes == 0 ) + { + if ( BIO_should_retry(file) == 0 ) // EOF + { + break; + } + } + ec = CryptoZFileWrite( &cfh, buf, &bytes ); + if ( ec != CRYPTOFILE_RESULT_SUCCESS ) + { + BIO_free(file); + CryptoZFileClose(&cfh); + return ec; + } + } + + // all done! + BIO_free(file); + CryptoZFileClose(&cfh); + + if ( ec < 0 ) + return CRYPTOFILE_RESULT_FAILURE; + + return CRYPTOFILE_RESULT_SUCCESS; + + } + + return CRYPTOFILE_RESULT_INVALID_PARAMS; + + +} diff --git a/libraries/pmrt/pmrt_ssl/filecrypto.h b/libraries/pmrt/pmrt_ssl/filecrypto.h new file mode 100755 index 0000000..60ba2cb --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/filecrypto.h @@ -0,0 +1,114 @@ +// filecrypto.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef FILECRYPTO_H +#define FILECRYPTO_H + +#include + + +#include +#include +#include +#include + +#include + + +enum +{ + CRYPTOFILE_RESULT_SUCCESS, + CRYPTOFILE_RESULT_INVALID_HANDLE, + CRYPTOFILE_RESULT_INVALID_PARAMS, + CRYPTOFILE_RESULT_FAILURE, + CRYPTOFILE_RESULT_DECRYPT_FAILURE, + CRYPTOFILE_RESULT_EOF, + CRYPTOFILE_RESULT_ZLIB_ERR, + CRYPTOFILE_RESULT_WRITE_FAILURE, + +}; + +enum +{ + CRYPTO_BLOWFISH, + CRYPTO_AES256, + CRYPTO_AES256_CBC = CRYPTO_AES256, + CRYPTO_AES256_OFB, + CRYPTO_AES256_CFB, +} CryptoAlgs; + +enum +{ + CRYPTO_ENCRYPT, + CRYPTO_DECRYPT, +} CryptoModes; + + +typedef struct +{ + BIO *file_bio; + BIO *crypto_bio; + + int writing; + int eof; +} CryptoFileHandle; + + + +int OpenCryptoFile( CryptoFileHandle *cfh, const char *filename, const char *mode, int CryptoMode, int CryptoAlg, + const unsigned char *key, int key_len, const unsigned char *iv, int iv_len ); + +int ReadFromCryptoFile( CryptoFileHandle *cfh, void *data, int *size ); +int WriteToCryptoFile( CryptoFileHandle *cfh, void *data, int *size ); + +int CloseCryptoFile( CryptoFileHandle *cfh ); + +int CheckCryptoFileEOF( CryptoFileHandle *cfh ); + + +int CryptoFileOp( const char *srcfile, const char *dstfile, int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len ); + + + +// funcs for reading/writing files that are zlib compressed and then encrypted + +typedef struct _CryptoZFileHandle +{ + z_stream stream; + CryptoFileHandle crypFile; + char *inBuffer; + char *outBuffer; + char origBuffer[128*128]; + int inBufSize; + int outBufSize; + int err; + int zlib_err; + int mode; + int eof; + int closed; +} CryptoZFileHandle; + +enum +{ + CRYPTO_COMPRESS_ENCRYPT, + CRYPTO_DECRYPT_DECOMPRESS, +} CryptoZModes; + + + +int CryptoZFileInit(CryptoZFileHandle *handle, int CryptoZMode, int CryptoAlg, + const char *filename, const unsigned char *key, int key_len, + const unsigned char *iv, int iv_len ); +int CryptoZFileRead(CryptoZFileHandle *zhandle, void *outData, unsigned int *outSize); +int CryptoZFileWrite(CryptoZFileHandle *zhandle, void *inData, unsigned int *inSize); +int CryptoZFileClose(CryptoZFileHandle *zhandle); +int CheckCryptoZFileEOF( CryptoZFileHandle *zhandle ); + +int CryptoZFileOp( const char *srcfile, const char *dstfile, + int CryptoZMode, int CryptoAlg, int PrependUncompressedSize, + const unsigned char *key, int key_len, const unsigned char *iv, int iv_len ); + +#endif + diff --git a/libraries/pmrt/pmrt_ssl/filecrypto.o b/libraries/pmrt/pmrt_ssl/filecrypto.o new file mode 100644 index 0000000..a307998 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/filecrypto.o differ diff --git a/libraries/pmrt/pmrt_ssl/keygenerate.c b/libraries/pmrt/pmrt_ssl/keygenerate.c new file mode 100755 index 0000000..cf73ab8 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/keygenerate.c @@ -0,0 +1,788 @@ +// keygenerate.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "keygenerate.h" +#include "randomnumbers.h" + +#include +#include +#include +#include +#include + + +// 'New Rand' funcs, these replace the dflt OpenSSL random number generator +// which is used to generate RSA public/private key pairs +// we can't use the normal OpenSSL generator b/c it is too random! +// (calls /dev/random, etc. results not reproduceable) +// instead we use a replacement generator that mimics the dflt OpenSSL +// method but always produces the same results for a given seed +// here is the description of this method from the OpenSSL docs: +/* + +The RAND_SSLeay() method implements a PRNG based on a cryptographic hash function. + +The following description of its design is based on the SSLeay documentation: + +First up I will state the things I believe I need for a good RNG. + +1 A good hashing algorithm to mix things up and to convert the RNG 'state' to random numbers. +2 An initial source of random 'state'. +3 The state should be very large. If the RNG is being used to generate 4096 bit RSA keys, 2 2048 bit random strings are required (at a minimum). If your RNG state only has 128 bits, you are obviously limiting the search space to 128 bits, not 2048. I'm probably getting a little carried away on this last point but it does indicate that it may not be a bad idea to keep quite a lot of RNG state. It should be easier to break a cipher than guess the RNG seed data. +4 Any RNG seed data should influence all subsequent random numbers generated. This implies that any random seed data entered will have an influence on all subsequent random numbers generated. +5 When using data to seed the RNG state, the data used should not be extractable from the RNG state. I believe this should be a requirement because one possible source of 'secret' semi random data would be a private key or a password. This data must not be disclosed by either subsequent random numbers or a 'core' dump left by a program crash. +6 Given the same initial 'state', 2 systems should deviate in their RNG state (and hence the random numbers generated) over time if at all possible. +7 Given the random number output stream, it should not be possible to determine the RNG state or the next random number. + +The algorithm is as follows. + +There is global state made up of a 1023 byte buffer (the 'state'), +a working hash value ('md'), and a counter ('count'). + +Whenever seed data is added, it is inserted into the 'state' as follows. + +The input is chopped up into units of 20 bytes (or less for the last block). +Each of these blocks is run through the hash function as follows: +The data passed to the hash function is the current 'md', +the same number of bytes from the 'state' +(the location determined by in incremented looping index) as the current 'block', +the new key data 'block', and 'count' (which is incremented after each use). +The result of this is kept in 'md' and also xored into the 'state' at the same locations +that were used as input into the hash function. +I believe this system addresses points 1 (hash function; currently SHA-1), 3 (the 'state'), 4 (via the 'md'), 5 (by the use of a hash function and xor). + +When bytes are extracted from the RNG, the following process is used. +For each group of 10 bytes (or less), we do the following: + +Input into the hash function the local 'md' (which is initialized from the global +'md' before any bytes are generated), the bytes that are to be overwritten +by the random bytes, and bytes from the 'state' (incrementing looping index). +From this digest output (which is kept in 'md'), the top (up to) 10 bytes are +returned to the caller and the bottom 10 bytes are xored into the 'state'. + +Finally, after we have finished 'num' random bytes for the caller, 'count' +(which is incremented) and the local and global 'md' are fed into the hash function +and the results are kept in the global 'md'. + +I believe the above addressed points 1 (use of SHA-1), +6 (by hashing into the 'state' the 'old' data from the caller that is about +to be overwritten) and 7 (by not using the 10 bytes given to the caller to +update the 'state', but they are used to update 'md'). + +So of the points raised, only 2 is not addressed (but see RAND_add(3)). + + +*/ + +/* +There is global state made up of a 1023 byte buffer (the 'state'), +a working hash value ('md'), and a counter ('count'). +*/ + + +RandState gRandState; + +// need enough function to fill out this struct: +/* + typedef struct rand_meth_st + { + void (*seed)(const void *buf, int num); + int (*bytes)(unsigned char *buf, int num); + void (*cleanup)(void); + void (*add)(const void *buf, int num, double entropy); + int (*pseudorand)(unsigned char *buf, int num); + int (*status)(void); + } RAND_METHOD; + */ + +/* +The input is chopped up into units of 20 bytes (or less for the last block). +Each of these blocks is run through the hash function as follows: +The data passed to the hash function is the current 'md', +the same number of bytes from the 'state' +(the location determined by in incremented looping index) as the current 'block', +the new key data 'block', and 'count' (which is incremented after each use). +The result of this is kept in 'md' and also xored into the 'state' at the same locations +that were used as input into the hash function. +I believe this system addresses points 1 (hash function; currently SHA-1), 3 (the 'state'), 4 (via the 'md'), 5 (by the use of a hash function and xor). +*/ + +#define KEYGEN_SEED_BLOCK_SIZE 20 +#define KEYGEN_RAND_BLOCK_SIZE 20 + +void nr_init() +{ + + // setup hashing handle + InitDataDigest(&gRandState.ddh,DIGEST_SHA1); + // reset our random state + memset(&gRandState.md,0,sizeof(gRandState.md)); + memset(&gRandState.state,0,sizeof(gRandState.state)); + gRandState.count = 0; + gRandState.spot = 0; +} +void nr_deinit() +{ + // setup hashing handle + CloseDataDigest(&gRandState.ddh); + // clear random state + memset(&gRandState.md,0,sizeof(gRandState.md)); + memset(&gRandState.state,0,sizeof(gRandState.state)); + gRandState.count = 0; + gRandState.spot = 0; +} + + +int nr_psuedorand(unsigned char *buf, int num); + +void nr_seed(const void *buf, int num) +{ + int num_blocks; + int extra_bytes; + int block_size; + int i,j; + int n; + int s; + unsigned char *data; + unsigned char tmp[256]; + + data = (unsigned char *)buf; + +/* + printf( "nr_seed called (%d bytes)!\n", num ); + printf( "seed:\n", num ); + for ( i = 0; i < num; i++ ) + { + printf( "%02X:", data[i] ); + } + printf( "\n" ); + + printf( "start state:\n" ); + for ( i = 0; i < sizeof(gRandState.state); i++ ) + { + printf( "%02X:", gRandState.state[i] ); + } + printf( "\n" ); + + printf( "start md:\n", sizeof(gRandState.md) ); + for ( i = 0; i < sizeof(gRandState.md); i++ ) + { + printf( "%02X:", gRandState.md[i] ); + } + printf( "\n" ); +*/ + + num_blocks = num / KEYGEN_SEED_BLOCK_SIZE; + extra_bytes = num % KEYGEN_SEED_BLOCK_SIZE; + + n = num_blocks; + if ( extra_bytes != 0 ) // do one extra block if we have extra bytes to roll in + n++; + + for( i = 0; i < n; i++ ) + { + if ( i == num_blocks ) // if on that extra block, roll in just the extra bytes + block_size = extra_bytes; + else + block_size = KEYGEN_SEED_BLOCK_SIZE; + + gRandState.spot++; + if ( gRandState.spot >= sizeof(gRandState.state) - block_size ) + gRandState.spot = 0; + + + + s = sizeof(gRandState.md); + WriteToDataDigest(&gRandState.ddh,gRandState.md,&s); + + s = block_size; + WriteToDataDigest(&gRandState.ddh,&gRandState.state[gRandState.spot],&s); + + s = block_size; + WriteToDataDigest(&gRandState.ddh,&data[i*KEYGEN_SEED_BLOCK_SIZE],&s); + + s = sizeof(gRandState.count); + WriteToDataDigest(&gRandState.ddh,&gRandState.count,&s); + ComputeDataDigest(&gRandState.ddh); + + // copy out the md and then xor it into state + memcpy(gRandState.md,gRandState.ddh.digest,gRandState.ddh.digest_len); + for ( j = 0; j < block_size; j++ ) + { + gRandState.state[gRandState.spot + j] ^= gRandState.md[j]; + } + + gRandState.count++; + + + } + + // spin on it a little bit for good measure, not strictly neccessary but what the heck? + memset(tmp, 0, sizeof(tmp) ); + for ( i = 0; i < (int)sizeof(tmp) + num; i++ ) + { + nr_psuedorand(tmp, sizeof(tmp) ); + } + +/* + printf( "exit state:\n" ); + for ( i = 0; i < sizeof(gRandState.state); i++ ) + { + printf( "%02X:", gRandState.state[i] ); + } + printf( "\n" ); + + printf( "exit md:\n" ); + for ( i = 0; i < sizeof(gRandState.md); i++ ) + { + printf( "%02X:", gRandState.md[i] ); + } + printf( "\n" ); +*/ + return; +} +void nr_cleanup(void) +{ + return; +} + +void nr_add(const void *buf, int num, double entropy) +{ + return; +} + +/* +When bytes are extracted from the RNG, the following process is used. +For each group of 10 bytes (or less), we do the following: + +Input into the hash function the local 'md' (which is initialized from the global +'md' before any bytes are generated), the bytes that are to be overwritten +by the random bytes, and bytes from the 'state' (incrementing looping index). +From this digest output (which is kept in 'md'), the top (up to) 10 bytes are +returned to the caller and the bottom 10 bytes are xored into the 'state'. + +Finally, after we have finished 'num' random bytes for the caller, 'count' +(which is incremented) and the local and global 'md' are fed into the hash function +and the results are kept in the global 'md'. +*/ + +int nr_psuedorand(unsigned char *buf, int num) +{ + int num_blocks; + int extra_bytes; + int block_size; + int i,j; + int n; + int s; + unsigned char *data; + + unsigned char local_md[DATADIGEST_MAX_DIGEST_LEN]; + + data = (unsigned char *)buf; + +/* + printf( "nr_psuedorand called (%d bytes)!\n", num ); + + printf( "start state:\n" ); + for ( i = 0; i < sizeof(gRandState.state); i++ ) + { + printf( "%02X:", gRandState.state[i] ); + } + printf( "\n" ); + + printf( "start md:\n", sizeof(gRandState.md) ); + for ( i = 0; i < sizeof(gRandState.md); i++ ) + { + printf( "%02X:", gRandState.md[i] ); + } + printf( "\n" ); +*/ + + // copy global md to local md + memcpy(local_md,gRandState.md,sizeof(local_md)); + + num_blocks = num / KEYGEN_RAND_BLOCK_SIZE; + extra_bytes = num % KEYGEN_RAND_BLOCK_SIZE; + + n = num_blocks; + if ( extra_bytes != 0 ) // do one extra block if we have extra bytes to roll in + n++; + + for( i = 0; i < n; i++ ) + { + if ( i == num_blocks ) // if on that extra block, roll in just the extra bytes + block_size = extra_bytes; + else + block_size = KEYGEN_RAND_BLOCK_SIZE; + + + gRandState.spot++; + if ( gRandState.spot >= sizeof(gRandState.state) - block_size ) + gRandState.spot = 0; + + + s = sizeof(local_md); + WriteToDataDigest(&gRandState.ddh,local_md,&s); + + // don't use the passed in data, this could add random noise to + // the generator and we don't want that + //s = block_size; + //WriteToDataDigest(&gRandState.ddh,&data[i*KEYGEN_RAND_BLOCK_SIZE],&s); + + s = block_size; + WriteToDataDigest(&gRandState.ddh,&gRandState.state[gRandState.spot],&s); + + ComputeDataDigest(&gRandState.ddh); + + // copy out the md + memcpy(gRandState.md,gRandState.ddh.digest,gRandState.ddh.digest_len); + + // return top ten bytes to caller + for( j = 0; j < block_size; j++ ) + { + data[(i*KEYGEN_RAND_BLOCK_SIZE) + j] = gRandState.md[j]; + } + + // xor last ten bytes into state + for ( j = 0; j < block_size; j++ ) + { + gRandState.state[gRandState.spot + j] ^= gRandState.md[gRandState.ddh.digest_len - j - 1]; + } + + } + + gRandState.count++; + + s = sizeof(gRandState.count); + WriteToDataDigest(&gRandState.ddh,&gRandState.count,&s); + + s = sizeof(local_md); + WriteToDataDigest(&gRandState.ddh,local_md,&s); + + s = sizeof(gRandState.md); + WriteToDataDigest(&gRandState.ddh,gRandState.md,&s); + + ComputeDataDigest(&gRandState.ddh); + + // copy out the md + memcpy(gRandState.md,gRandState.ddh.digest,gRandState.ddh.digest_len); + +/* + printf( "nr_psuedorand returned:\n", num ); + for ( i = 0; i < num; i++ ) + { + printf( "%02X:", buf[i] ); + } + printf( "\n" ); + + printf( "end state:\n" ); + for ( i = 0; i < sizeof(gRandState.state); i++ ) + { + printf( "%02X:", gRandState.state[i] ); + } + printf( "\n" ); + + printf( "end md:\n", sizeof(gRandState.md) ); + for ( i = 0; i < sizeof(gRandState.md); i++ ) + { + printf( "%02X:", gRandState.md[i] ); + } + printf( "\n" ); +*/ + + return 1; +} +int nr_bytes(unsigned char *buf, int num) +{ + return nr_psuedorand(buf,num); +} + +int nr_status(void) +{ + return 1; +} + + +RSA *GenerateRSAKey( unsigned char *seed, int seed_len ) +{ + RSA *rsa = NULL; + + RAND_METHOD new_rand; + + if ( seed == NULL || seed_len <= 0 ) + return NULL; + + // set up our replacement pseudo random number generator + // see comments above for details + + new_rand.seed = &nr_seed; + new_rand.bytes = &nr_bytes; + new_rand.add = &nr_add; + new_rand.pseudorand = &nr_psuedorand; + new_rand.status = &nr_status; + + // intialize nr (sets up the data digest handle) + nr_init(); + // according to man pages, ENGINE system is preffered method + // changing the OpenSSL rand num generator, but I found this worked + // and was more straight forward + RAND_set_rand_method( &new_rand ); + + RAND_seed( seed, seed_len ); + + rsa = RSA_generate_key( KEYGEN_RSA_KEY_LEN, 65537, NULL, NULL ); + + // set back to dflt OpenSSL random num generator + RAND_set_rand_method( RAND_SSLeay() ); + + // de-intialize nr (frees the data digest handle) + nr_deinit(); + + return rsa; +} + + +int MakeSSLCert( X509 **ppX509Cert, EVP_PKEY **ppPrivateKey, RSA *rsa, char *text ) +{ + int ec; + time_t expire_time; + + X509_NAME *name=NULL; + // X509_NAME_ENTRY *name_entry=NULL; + // X509_EXTENSION *extension=NULL; + + if ( ppX509Cert == NULL || ppPrivateKey == NULL ) + return KEYGEN_RESULT_INVALID_PARAMS; + + + *ppPrivateKey = EVP_PKEY_new(); + if ( *ppPrivateKey == NULL ) + return KEYGEN_RESULT_FAILURE; + + *ppX509Cert = X509_new(); + if ( ppX509Cert == NULL ) + { + EVP_PKEY_free(*ppPrivateKey); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + + ec = EVP_PKEY_assign_RSA(*ppPrivateKey,rsa); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + + ec = X509_set_version(*ppX509Cert,3); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + // always use 0 as the serial number + ec = ASN1_INTEGER_set(X509_get_serialNumber(*ppX509Cert),0); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + + // time starts counting from 1970, so calc the number of + // seconds from 1970 to our desired expiration date + // as a note, important to keep all this time stuff strictly GMT + expire_time = (60*60*24)*365*(KEYGEN_KEY_EXPIRE_YEAR - 1970); + // prts_debug( "Generating certificate that will expire on %s", asctime(localtime(&expire_time)) ); + + + ASN1_UTCTIME_set(X509_get_notBefore(*ppX509Cert),0); + ASN1_UTCTIME_set(X509_get_notAfter(*ppX509Cert), expire_time); + + ec = X509_set_pubkey(*ppX509Cert,*ppPrivateKey); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + name = X509_get_subject_name(*ppX509Cert); + if( name == NULL ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + ec = X509_NAME_add_entry_by_txt(name,"C", MBSTRING_ASC, "US", -1, -1, 0); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + ec = X509_NAME_add_entry_by_txt(name,"CN", MBSTRING_ASC, text, -1, -1, 0); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + ec = X509_set_issuer_name(*ppX509Cert,name); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + + // sign the cert ourselves + ec = X509_sign(*ppX509Cert,*ppPrivateKey,EVP_md5()); + if ( ec <= 0 ) + { + EVP_PKEY_free(*ppPrivateKey); + X509_free(*ppX509Cert); + *ppPrivateKey = NULL; + *ppX509Cert = NULL; + return KEYGEN_RESULT_FAILURE; + } + + + + return KEYGEN_RESULT_SUCCESS; + +}; + + +int InitKeyHandleFromSeed( KeyGenHandle *kgh, unsigned char *seed, int seed_len, char *CertText ) +{ + int ec; + RSA *rsa; + + if( kgh == NULL ) + return KEYGEN_RESULT_INVALID_HANDLE; + if ( seed == NULL || seed_len <= 0 ) + return KEYGEN_RESULT_INVALID_PARAMS; + + rsa = GenerateRSAKey( seed, seed_len ); + if ( rsa == NULL ) + { + return KEYGEN_RESULT_FAILURE; + } + ec = MakeSSLCert( &kgh->cert, &kgh->key, rsa, CertText ); + if ( ec != KEYGEN_RESULT_SUCCESS ) + { + return KEYGEN_RESULT_FAILURE; + } + + return KEYGEN_RESULT_SUCCESS; +} + +int SaveKeyHandleCert( KeyGenHandle *kgh, char *filename ) +{ + BIO *fbio; + int ec; + + if( kgh == NULL || kgh->cert == NULL ) + return KEYGEN_RESULT_INVALID_HANDLE; + + fbio = BIO_new_file(filename,"wb"); + if ( fbio == NULL ) + return KEYGEN_RESULT_FAILURE; + + ec = PEM_write_bio_X509(fbio,kgh->cert); + if ( ec < 0 ) + { + BIO_free_all(fbio); + return KEYGEN_RESULT_FAILURE; + } + + BIO_free_all(fbio); + + return KEYGEN_RESULT_SUCCESS; + + +} + + +int SaveKeyHandlePrivateKey( KeyGenHandle *kgh, char *filename ) +{ + BIO *fbio; + int ec; + + if( kgh == NULL || kgh->key == NULL ) + return KEYGEN_RESULT_INVALID_HANDLE; + + fbio = BIO_new_file(filename,"wb"); + if ( fbio == NULL ) + return KEYGEN_RESULT_FAILURE; + + ec = PEM_write_bio_PrivateKey(fbio,kgh->key,NULL,NULL,0,NULL, NULL); + if ( ec < 0 ) + { + BIO_free_all(fbio); + return KEYGEN_RESULT_FAILURE; + } + + BIO_free_all(fbio); + + return KEYGEN_RESULT_SUCCESS; + +} + + +int ExportKeyHandleCert( KeyGenHandle *kgh, char *buf, int len ) +{ + BIO *mbio; + int ec; + int count; + // BUF_MEM *bm; + // int i; + + if ( buf == NULL || len <= 0 ) + return KEYGEN_RESULT_INVALID_PARAMS; + + if( kgh == NULL || kgh->cert == NULL ) + return KEYGEN_RESULT_INVALID_HANDLE; + + mbio = BIO_new(BIO_s_mem()); + + if ( mbio == NULL ) + return KEYGEN_RESULT_FAILURE; + + // ec = BIO_write(mbio, buf, len ); + + + // BIO_get_mem_ptr(mbio, &bm); + + + ec = PEM_write_bio_X509(mbio,kgh->cert); + if ( ec < 0 ) + { + BIO_free_all(mbio); + return KEYGEN_RESULT_FAILURE; + } + + // copy from mem bio to passed buffer + count = 0; + while( (!BIO_eof(mbio)) && count < len - 1 ) // leave space for null terminator + { + ec = BIO_read( mbio, &buf[count], len ); + if ( ec > 0 ) + count += ec; + } + // null terminate + buf[count] = '\0'; + /* + for ( i = 0; i < count; i++ ) + { + prts_debug( "%d = %d ('%c')\n", i, buf[i], buf[i] ); + } + */ + + BIO_free_all(mbio); + + return KEYGEN_RESULT_SUCCESS; + +} + +int CloseKeyHandle( KeyGenHandle *kgh ) +{ + if( kgh == NULL ) + return KEYGEN_RESULT_INVALID_HANDLE; + + if ( kgh->key != NULL ) + EVP_PKEY_free(kgh->key); + + if ( kgh->cert != NULL ) + X509_free(kgh->cert); + + return KEYGEN_RESULT_SUCCESS; +} + + +// function to go from an N length seed to an M length key +int GenerateCryptoKey( unsigned char *seed, int seed_len, + unsigned char *key, int key_len ) +{ + int i; + RandState rs; + + if ( seed == NULL || seed_len <= 0 || key == NULL || key_len <= 0 ) + return KEYGEN_RESULT_INVALID_PARAMS; + + // intialize nr (sets up the data digest handle) + RandStateInit( &rs ); + // nr_init(); + + + // nr_seed(seed,seed_len); + RandStateSeed(&rs, seed,seed_len); + // just generate a bunch of random numbers + // and give back the last one as the key + for ( i = 0; i < seed_len + key_len; i++ ) + { + RandStatePsuedoRand( &rs, key, key_len ); + } + // de-intialize nr (frees the data digest handle) + RandStateDeinit(&rs); + + return KEYGEN_RESULT_SUCCESS; +} + + +// using the PRNG can be somewhat slow, so here is an alternate +// func that is not as good but much faster +// this one just muxes the two passed seeds together in quasi random fashion +int GenerateCryptoKeyFast( const unsigned char *seed1, int seed1_len, + const unsigned char *seed2, int seed2_len, + unsigned char *key, int key_len ) +{ + int i; + unsigned int s1,s2; + + s1 = (seed2_len + key_len) % seed1_len; + s2 = (seed1_len + key_len) % seed2_len; + + for ( i = 0; i < key_len; i++ ) + { + key[i] = seed1[s1] ^ seed2[s2]; + s1 += seed2[s2] + i + key_len; + s1 = s1 % seed1_len; + s2 += seed1[s1] + i + key_len; + s2 = s2 % seed2_len; + } + + + return KEYGEN_RESULT_SUCCESS; + +} diff --git a/libraries/pmrt/pmrt_ssl/keygenerate.h b/libraries/pmrt/pmrt_ssl/keygenerate.h new file mode 100755 index 0000000..75c8693 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/keygenerate.h @@ -0,0 +1,76 @@ +// keygenerate.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef KEYGENERATE_H +#define KEYGENERATE_H + +#include + +#include +#include +#include +#include +#include +#include + +#include "datadigest.h" + +// how big to make the private/public keys, 2048 is considered safe for immediate future +// from the RSA folks: (http://www.rsa.com/rsalabs/node.asp?id=2218) +/* +RSA Laboratories currently recommends key sizes of 1024 bits for corporate use and +2048 bits for extremely valuable keys like the root key pair used by a certifying +authority (see Question 4.1.3.12). Several recent standards specify a 1024-bit minimum +for corporate use. +*/ +// found some articles recommending 2048 bit keys, so consider using them if speed allows +#define KEYGEN_RSA_KEY_LEN 1024 +// keys will expire on Jan 1 of this year +#define KEYGEN_KEY_EXPIRE_YEAR 2025 // <- due to 32 bit time counter, can't go higher than this! + +enum +{ + KEYGEN_RESULT_SUCCESS, + KEYGEN_RESULT_INVALID_HANDLE, + KEYGEN_RESULT_INVALID_PARAMS, + KEYGEN_RESULT_FAILURE, +}; + +typedef struct +{ + X509 *cert; + EVP_PKEY *key; +} KeyGenHandle; + +RSA *GenerateRSAKey( unsigned char *seed, int seed_len ); + + +#ifdef __cplusplus +extern "C" { +#endif + +int MakeSSLCert( X509 **ppX509Cert, EVP_PKEY **ppPrivateKey, RSA *rsa, char *text ); + +int InitKeyHandleFromSeed( KeyGenHandle *kgh, unsigned char *seed, int seed_len, char *CertText ); +int SaveKeyHandleCert( KeyGenHandle *kgh, char *filename ); +int SaveKeyHandlePrivateKey( KeyGenHandle *kgh, char *filename ); +int ExportKeyHandleCert( KeyGenHandle *kgh, char *buf, int len ); + +int CloseKeyHandle( KeyGenHandle *kgh ); + +int GenerateCryptoKey( unsigned char *seed, int seed_len, + unsigned char *key, int key_len ); + +int GenerateCryptoKeyFast( const unsigned char *seed1, int seed1_len, + const unsigned char *seed2, int seed2_len, + unsigned char *key, int key_len ); + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/libraries/pmrt/pmrt_ssl/keygenerate.o b/libraries/pmrt/pmrt_ssl/keygenerate.o new file mode 100644 index 0000000..7b69534 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/keygenerate.o differ diff --git a/libraries/pmrt/pmrt_ssl/libpmrt_ssl.a b/libraries/pmrt/pmrt_ssl/libpmrt_ssl.a new file mode 100644 index 0000000..62794f3 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/libpmrt_ssl.a differ diff --git a/libraries/pmrt/pmrt_ssl/makedeplib b/libraries/pmrt/pmrt_ssl/makedeplib new file mode 100644 index 0000000..399eff6 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/makedeplib @@ -0,0 +1,642 @@ +netssl.o: netssl.c /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h netssl.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h keygenerate.h /g3/include/openssl/rand.h \ + datadigest.h /usr/include/sys/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h +sslclient.o: sslclient.c sslclient.h /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h netssl.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h keygenerate.h /g3/include/openssl/rand.h \ + datadigest.h +filecrypto.o: filecrypto.c filecrypto.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/zlib.h /g3/include/zconf.h \ + /g3/include/openssl/rand.h +datadigest.o: datadigest.c datadigest.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /g3/include/openssl/crypto.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h +keygenerate.o: keygenerate.c keygenerate.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/openssl/rand.h datadigest.h \ + randomnumbers.h +sslhttpclient.o: sslhttpclient.c sslhttpclient.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h netssl.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h keygenerate.h /g3/include/openssl/rand.h \ + datadigest.h sslclient.h +randomnumbers.o: randomnumbers.c randomnumbers.h keygenerate.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/openssl/rand.h datadigest.h +memcrypto.o: memcrypto.c filecrypto.h /g3/include/pmrt_utils/pmrt_utils.h \ + /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/zlib.h /g3/include/zconf.h \ + memcrypto.h /g3/include/openssl/rand.h +aescrypt.o: aescrypt.c aescrypt.h filecrypto.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /g3/include/openssl/bio.h \ + /g3/include/openssl/e_os2.h /g3/include/openssl/opensslconf.h \ + /g3/include/openssl/crypto.h /g3/include/openssl/stack.h \ + /g3/include/openssl/safestack.h /g3/include/openssl/opensslv.h \ + /g3/include/openssl/ossl_typ.h /g3/include/openssl/symhacks.h \ + /g3/include/openssl/ssl.h /g3/include/openssl/comp.h \ + /g3/include/openssl/x509.h /g3/include/openssl/buffer.h \ + /g3/include/openssl/evp.h /g3/include/openssl/objects.h \ + /g3/include/openssl/obj_mac.h /g3/include/openssl/asn1.h \ + /g3/include/openssl/bn.h /g3/include/openssl/ec.h \ + /g3/include/openssl/ecdsa.h /g3/include/openssl/ecdh.h \ + /g3/include/openssl/rsa.h /g3/include/openssl/dsa.h \ + /g3/include/openssl/dh.h /g3/include/openssl/sha.h \ + /g3/include/openssl/x509_vfy.h /g3/include/openssl/lhash.h \ + /g3/include/openssl/pkcs7.h /g3/include/openssl/pem.h \ + /g3/include/openssl/pem2.h /g3/include/openssl/kssl.h \ + /g3/include/openssl/ssl2.h /g3/include/openssl/ssl3.h \ + /g3/include/openssl/pq_compat.h /g3/include/openssl/tls1.h \ + /g3/include/openssl/dtls1.h /g3/include/openssl/pqueue.h \ + /usr/include/string.h /g3/include/openssl/ssl23.h \ + /g3/include/openssl/err.h /g3/include/zlib.h /g3/include/zconf.h \ + memcrypto.h diff --git a/libraries/pmrt/pmrt_ssl/makefile b/libraries/pmrt/pmrt_ssl/makefile new file mode 100755 index 0000000..8cb4eac --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/makefile @@ -0,0 +1,38 @@ +# make driver +# make install (as root) +# +.CLIBFILES = netssl.c sslclient.c filecrypto.c datadigest.c keygenerate.c sslhttpclient.c randomnumbers.c memcrypto.c aescrypt.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libpmrt_ssl.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /g3/lib/libpmrt_utils.a /g3/lib/libssl.a /g3/lib/libcrypto.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/pmrt_ssl + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/pmrt_ssl + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/pmrt_ssl/memcrypto.c b/libraries/pmrt/pmrt_ssl/memcrypto.c new file mode 100755 index 0000000..a78ab1a --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/memcrypto.c @@ -0,0 +1,383 @@ +// memcrypto.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "filecrypto.h" +#include "memcrypto.h" + +#if SYS_PC +#include +#endif + +#if SYS_BB +#include +#endif + +#include +#include +#include +#include +#include +#include + + +void FreeCryptoMemHandle(CryptoMemHandle *cmh) +{ + if( cmh == NULL ) + return; + + if ( cmh->crypto_bio != NULL ) + BIO_free(cmh->crypto_bio); + + if ( cmh->mem_bio != NULL ) + BIO_free(cmh->mem_bio); + + cmh->mem_bio = NULL; + cmh->crypto_bio = NULL; + + return; +} + +int InitCryptoMemHandle( CryptoMemHandle *cmh, int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len ) +{ + EVP_CIPHER_CTX *cipher_ctx; + int enc_mode; + int min_iv_len; + + if( cmh == NULL ) + return CRYPTOMEM_RESULT_INVALID_HANDLE; + + cmh->mem_bio = NULL; + cmh->crypto_bio = NULL; + + + //setup the file bio + + + cmh->mem_bio = BIO_new(BIO_s_mem()); + if ( cmh->mem_bio == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + // setup the crypto stream + cmh->crypto_bio = BIO_new(BIO_f_cipher()); + if ( cmh->crypto_bio == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + cipher_ctx = NULL; + + if( CryptoMode == CRYPTO_ENCRYPT ) + enc_mode = 1; + else // decrypt + enc_mode = 0; + + switch( CryptoAlg ) + { + case CRYPTO_BLOWFISH: + // make sure initial vector is at least as long as required + min_iv_len = EVP_CIPHER_iv_length(EVP_bf_cbc()); + if ( iv_len < min_iv_len ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + BIO_set_cipher( cmh->crypto_bio, EVP_bf_cbc(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cmh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + // set the key length + if ( EVP_CIPHER_CTX_set_key_length(cipher_ctx,key_len) < 0 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + break; + case CRYPTO_AES256_CBC: + min_iv_len = EVP_CIPHER_iv_length(EVP_aes_256_cbc()); + if ( iv_len < min_iv_len ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + if ( key_len < 32 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + BIO_set_cipher( cmh->crypto_bio, EVP_aes_256_cbc(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cmh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + // key length is fixed at 256, so don't set + + break; + case CRYPTO_AES256_OFB: + min_iv_len = EVP_CIPHER_iv_length(EVP_aes_256_ofb()); + if ( iv_len < min_iv_len ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + if ( key_len < 32 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + BIO_set_cipher( cmh->crypto_bio, EVP_aes_256_ofb(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cmh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + // key length is fixed at 256, so don't set + break; + case CRYPTO_AES256_CFB: + min_iv_len = EVP_CIPHER_iv_length(EVP_aes_256_cfb()); + if ( iv_len < min_iv_len ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + if ( key_len < 32 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + BIO_set_cipher( cmh->crypto_bio, EVP_aes_256_cfb(), key, iv, enc_mode ); + BIO_get_cipher_ctx(cmh->crypto_bio,&cipher_ctx); + if ( cipher_ctx == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + // key length is fixed at 256, so don't set + break; + default: + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + break; + } + + // chain the bios + if ( BIO_push(cmh->crypto_bio,cmh->mem_bio) < 0 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + // ta dah! now anything we read/write to the file will be + // either encrypted or unencrypted as it's read/written! + + + return CRYPTOMEM_RESULT_SUCCESS; + +} + + +int ReadFromCryptoMemHandle( CryptoMemHandle *cmh, void *data, int *size ) +{ + + int ec; + int count; + + if( cmh == NULL || cmh->crypto_bio == NULL || cmh->mem_bio == NULL ) + return CRYPTOMEM_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return CRYPTOMEM_RESULT_INVALID_PARAMS; + + + // flush any data waiting to be encrypted + BIO_flush(cmh->crypto_bio); + + // copy from mem bio to passed buffer + count = 0; + while( (!BIO_eof(cmh->mem_bio)) && count < *size ) + { + ec = BIO_read( cmh->mem_bio, &((unsigned char *)data)[count], *size ); + if ( ec > 0 ) + count += ec; + } + + // mark the number of bits written out + *size = count; + + +/* + ec = BIO_read(cmh->crypto_bio, data, *size ); + if ( ec < 0 ) + return CRYPTOMEM_RESULT_FAILURE; + + *size = ec; +*/ + +/* + if ( ec == 0 ) + { + // this could indicate a decrypt err on last block or EOF + // from what I could tell, this does not check for decrypt + // w/ wrong key (no way to test that, except to verify CRC of decrypted data) + // rather it tests for a file w/o enough bits in last block for + // the cipher (ciphers always round up to blocks of a certain size) + if ( BIO_get_cipher_status(cmh->crypto_bio) == 0 ) + { + return CRYPTOMEM_RESULT_DECRYPT_FAILURE; + } + else if ( BIO_should_retry(cmh->crypto_bio) == 0 ) // EOF + { + // mark that the end of file has been reached + cmh->eof = 1; + return CRYPTOMEM_RESULT_EOF; + } + } +*/ + return CRYPTOMEM_RESULT_SUCCESS; +} + +int WriteToCryptoMemHandle( CryptoMemHandle *cmh, void *data, int *size ) +{ + int ec; + if( cmh == NULL || cmh->crypto_bio == NULL ) + return CRYPTOMEM_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return CRYPTOMEM_RESULT_INVALID_PARAMS; + + + ec = BIO_write(cmh->crypto_bio, data, *size ); + if ( ec <= 0 ) + return CRYPTOMEM_RESULT_FAILURE; + + *size = ec; + + return CRYPTOMEM_RESULT_SUCCESS; +} + +// flushes pending crypto operations +// and clears any data in mem bio +// effectively reseting handle so it can be +// used for a new crypto operation +int ResetCryptoMemHandle( CryptoMemHandle *cmh ) +{ +// int ec; +// unsigned char buf[256]; + + if( cmh == NULL || cmh->crypto_bio == NULL || cmh->mem_bio == NULL ) + return CRYPTOMEM_RESULT_INVALID_HANDLE; + + // flush any data waiting to be encrypted + BIO_flush(cmh->crypto_bio); + + // pop mem bio off the chain + if ( BIO_pop(cmh->mem_bio) < 0 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + // free mem bio + BIO_free(cmh->mem_bio); + + + // now spawn a new mem bio + cmh->mem_bio = BIO_new(BIO_s_mem()); + if ( cmh->mem_bio == NULL ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + + // chain the bios + if ( BIO_push(cmh->crypto_bio,cmh->mem_bio) < 0 ) + { + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_FAILURE; + } + +/* + // just read out every byte that's left + while( BIO_ctrl_pending(cmh->mem_bio) > 0 + && + !BIO_eof(cmh->mem_bio) ) + { + ec = BIO_read( cmh->mem_bio, buf, sizeof(buf) ); + } +*/ + return CRYPTOMEM_RESULT_SUCCESS; +} + +int CloseCryptoMemHandle( CryptoMemHandle *cmh ) +{ + if( cmh == NULL ) + return CRYPTOMEM_RESULT_INVALID_HANDLE; + + BIO_flush(cmh->crypto_bio); + + FreeCryptoMemHandle(cmh); + return CRYPTOMEM_RESULT_SUCCESS; + +} + + +int CryptoMemOp( int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len, + void *src, int src_len, void *dst, int *dst_len ) +{ + + int ec; + int bytes; + CryptoMemHandle cmh; + + ec = InitCryptoMemHandle( &cmh, CryptoMode, CryptoAlg, key, key_len, iv, iv_len ); + if ( ec != CRYPTOMEM_RESULT_SUCCESS ) + return ec; + + bytes = src_len; + ec = WriteToCryptoMemHandle( &cmh, src, &bytes ); + if ( ec != CRYPTOMEM_RESULT_SUCCESS ) + { + CloseCryptoMemHandle( &cmh ); + return ec; + } + + if ( bytes < src_len ) + { + CloseCryptoMemHandle( &cmh ); + return CRYPTOMEM_RESULT_FAILURE; + } + + bytes = *dst_len; + ec = ReadFromCryptoMemHandle( &cmh, dst, &bytes ); + if ( ec != CRYPTOMEM_RESULT_SUCCESS ) + { + CloseCryptoMemHandle( &cmh ); + return ec; + } + + // return the number of bytes in the encrypted block + // (useful for CBC and other modes where encrypted data is larger than src) + *dst_len = bytes; + + CloseCryptoMemHandle( &cmh ); + return CRYPTOMEM_RESULT_SUCCESS; + +} diff --git a/libraries/pmrt/pmrt_ssl/memcrypto.h b/libraries/pmrt/pmrt_ssl/memcrypto.h new file mode 100755 index 0000000..c314ec5 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/memcrypto.h @@ -0,0 +1,53 @@ +// memcrypto.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef MEMCRYPTO_H +#define MEMCRYPTO_H + +#include "filecrypto.h" + +#include +#include +#include +#include + +enum +{ + CRYPTOMEM_RESULT_SUCCESS, + CRYPTOMEM_RESULT_INVALID_HANDLE, + CRYPTOMEM_RESULT_INVALID_PARAMS, + CRYPTOMEM_RESULT_FAILURE, + CRYPTOMEM_RESULT_DECRYPT_FAILURE, + CRYPTOMEM_RESULT_EOF, + +}; + + + +typedef struct +{ + BIO *mem_bio; + BIO *crypto_bio; + +} CryptoMemHandle; + + + +int InitCryptoMemHandle( CryptoMemHandle *cmh, int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len ); + +int ReadFromCryptoMemHandle( CryptoMemHandle *cmh, void *data, int *size ); +int WriteToCryptoMemHandle( CryptoMemHandle *cmh, void *data, int *size ); + +int ResetCryptoMemHandle( CryptoMemHandle *cfh ); + +int CloseCryptoMemHandle( CryptoMemHandle *cfh ); + + +int CryptoMemOp( int CryptoMode, int CryptoAlg, unsigned char *key, int key_len, unsigned char *iv, int iv_len, + void *src, int src_len, void *dst, int *dst_len ); + + +#endif + diff --git a/libraries/pmrt/pmrt_ssl/memcrypto.o b/libraries/pmrt/pmrt_ssl/memcrypto.o new file mode 100644 index 0000000..084d75e Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/memcrypto.o differ diff --git a/libraries/pmrt/pmrt_ssl/mssccprj.scc b/libraries/pmrt/pmrt_ssl/mssccprj.scc new file mode 100755 index 0000000..6ef5139 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[pmrt_ssl.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/pmrt_ssl", FCOAAAAA diff --git a/libraries/pmrt/pmrt_ssl/netssl.c b/libraries/pmrt/pmrt_ssl/netssl.c new file mode 100755 index 0000000..f386a13 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/netssl.c @@ -0,0 +1,558 @@ +// netssl.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include + +#include "netssl.h" + +#include +#include +#include +#include +#include + +#if SYS_BB +#include +#endif + +void SSL_Init() +{ + static int SSL_Started = 0; + + if(!SSL_Started) + { + SSL_load_error_strings(); + ERR_load_BIO_strings(); + OpenSSL_add_all_algorithms(); + SSL_library_init(); + // add compression support + // from openssl docs (http://www.openssl.org/docs/ssl/SSL_COMP_add_compression_method.html) + /* + The TLS standard (or SSLv3) allows the integration of compression methods + into the communication. The TLS RFC does however not specify compression methods + or their corresponding identifiers, so there is currently no compatible way to + integrate compression with unknown peers. + It is therefore currently not recommended to integrate compression into + applications. Applications for non-public use may agree on certain compression + methods. Using different compression methods with the same identifier will lead + to connection failure. + + An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1) + will unconditionally send the list of all compression methods enabled with + SSL_COMP_add_compression_method() to the server during the handshake. + Unlike the mechanisms to set a cipher list, there is no method available to + restrict the list of compression method on a per connection basis. + + An OpenSSL server will match the identifiers listed by a client against its + own compression methods and will unconditionally activate compression when a + matching identifier is found. There is no way to restrict the list of compression + methods supported on a per connection basis. + + The OpenSSL library has the compression methods COMP_rle() and + (when especially enabled during compilation) COMP_zlib() available. + */ + // basically I read this to mean 'don't use this if you want your to work + // correctly w/ non-OpenSSL applications', but since we are using + // OpenSSL on both sides of our connections, it should be fine to use + // + // id values taken from stunnel + SSL_COMP_add_compression_method(0xe0,COMP_zlib()); + SSL_COMP_add_compression_method(0xe1,COMP_rle()); + SSL_Started = 1; +#if SYS_BB + // on unix we'll get a SIGPIPE if we write to a + // closed ssl connection w/ BIO_write + // this causes the program to crash so + // instead we ignore the signal and use + // BIO_should_retry() after the write fails + // to detect a closed connection + signal(SIGPIPE, SIG_IGN); /* Ignore SIGPIPE */ +#endif + } +} + +// this function will be called once for every error that +// is found during server cert verification +// this allows us to log specific errors as they occur +int log_errors_verify_callback(int preverify_ok, X509_STORE_CTX *ctx) +{ + int err; + + // if verify went ok, then return true + if ( preverify_ok ) + return 1; + + err = X509_STORE_CTX_get_error(ctx); + + prts_debug("SSL verify error:num=%d:%s\n", err, X509_verify_cert_error_string(err)); + + return preverify_ok; + +} + + +// this function will be called once for every error that +// is found during server cert verification +// this allows us to ignore specific errors as they occur +// in this case we ignore errors pertaining to the date +// on the server's certificate, do this just in case the client's +// date gets out of whack (client must connect to the server to correct it's date) +int ignore_dates_verify_callback(int preverify_ok, X509_STORE_CTX *ctx) +{ + int err; + + // if verify went ok, then return true + if ( preverify_ok ) + return 1; + + err = X509_STORE_CTX_get_error(ctx); + + prts_debug("SSL verify error:num=%d:%s\n", err, X509_verify_cert_error_string(err)); + + // ignore cert expiration errors + switch(err) + { + case X509_V_ERR_CERT_NOT_YET_VALID: + case X509_V_ERR_CERT_HAS_EXPIRED: + prts_debug( "SSL veirfy server cert date error ignored.\n" ); + return 1; + default: + return 0; + } +} + + + +void ResetNetSSLHandle( NetSSLHandle *handle ) +{ + if ( handle == NULL ) + return; + handle->bio = NULL; + handle->ctx = NULL; + handle->ssl = NULL; + handle->ssl_method = NULL; + handle->ssl_session = NULL; + handle->type = 0; + handle->connected = 0; + handle->port = 0; + handle->ignore_dates_on_server_cert = 0; + memset(handle->ip,0,NETSSL_MAX_IP_LEN); +} + + +int NetSSLInitClientSession( NetSSLHandle *handle, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, + char *cipherlist, + int session_renegotiate_bytes, int session_renegotiate_time, + int ignore_dates_on_server_cert ) +{ + + SSL_METHOD *ssl_method; + if ( handle == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + if ( server_certfile == NULL ) + return NETSSL_RESULT_INVALID_PARAMS; + + // init openssl systems + SSL_Init(); + + // null out all our pointers + ResetNetSSLHandle(handle); + + handle->session_renegotiate_bytes = session_renegotiate_bytes; + handle->session_renegotiate_time = session_renegotiate_time; + handle->ignore_dates_on_server_cert = ignore_dates_on_server_cert; + + ssl_method = SSLv3_client_method(); + + handle->ctx = SSL_CTX_new(ssl_method); + if(handle->ctx == NULL) + { + return NETSSL_RESULT_FAILED_TO_INIT_SSL_CONTEXT; + } + + + // if provided, load client cert and key + if ( client_kgh != NULL && client_kgh->cert != NULL && client_kgh->key != NULL ) + { + if ( ! SSL_CTX_use_certificate(handle->ctx, client_kgh->cert) ) + return NETSSL_RESULT_FAILED_TO_SET_CLIENT_CERT; + + if ( ! SSL_CTX_use_PrivateKey(handle->ctx, client_kgh->key) ) + return NETSSL_RESULT_FAILED_TO_SET_CLIENT_KEY; + + if ( ! SSL_CTX_check_private_key(handle->ctx) ) + return NETSSL_RESULT_CLIENT_CERT_NO_MATCH_KEY; + } + else if ( client_certfile != NULL && client_keyfile != NULL ) + { + if ( ! SSL_CTX_use_certificate_chain_file(handle->ctx, client_certfile) ) + return NETSSL_RESULT_FAILED_TO_SET_CLIENT_CERT; + + if ( ! SSL_CTX_use_PrivateKey_file(handle->ctx, client_keyfile, SSL_FILETYPE_PEM ) ) + return NETSSL_RESULT_FAILED_TO_SET_CLIENT_KEY; + + if ( ! SSL_CTX_check_private_key(handle->ctx) ) + return NETSSL_RESULT_CLIENT_CERT_NO_MATCH_KEY; + } + + + if(! SSL_CTX_load_verify_locations(handle->ctx, server_certfile, NULL)) + { + SSL_CTX_free(handle->ctx); + handle->ctx = NULL; + return NETSSL_RESULT_FAILED_TO_SET_SERVER_CERT_FILE; + } + + if ( handle->ignore_dates_on_server_cert ) + { + SSL_CTX_set_verify(handle->ctx, SSL_VERIFY_PEER, ignore_dates_verify_callback); + } + else + { + SSL_CTX_set_verify(handle->ctx, SSL_VERIFY_PEER, log_errors_verify_callback); + } + + if ( cipherlist != NULL ) + { + if( SSL_CTX_set_cipher_list(handle->ctx,cipherlist) == 0 ) + { + SSL_CTX_free(handle->ctx); + handle->ctx = NULL; + return NETSSL_RESULT_FAILED_TO_SET_CIPHER_LIST; + } + } + + return NETSSL_RESULT_SUCCESS; +} + + +int NetSSLOpenClientSession( NetSSLHandle *handle, char *remote_ip, int remote_port ) +{ + + int ec; + char buf[128]; + + if ( handle == NULL || handle->ctx == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + if ( remote_ip == NULL || remote_port < 1 ) + return NETSSL_RESULT_INVALID_PARAMS; + + + + handle->bio = BIO_new_ssl_connect(handle->ctx); + if(handle->bio == NULL) + { + return NETSSL_RESULT_FAILED_TO_INIT_BIO_OBJECT; + } + + // get our ssl handle + BIO_get_ssl(handle->bio, &handle->ssl); + // this tells ssl to handle session renegotiation for us + // reads/writes will fail with 'should retry' while the + // renegotiation happens + SSL_set_mode(handle->ssl, SSL_MODE_AUTO_RETRY); + + // set how often we want session renegotiation (repeat full handshake, change symmetric key) to happen + if ( handle->session_renegotiate_bytes >= 512 ) // 512 bytes is the min value openssl allows + BIO_set_ssl_renegotiate_bytes(handle->bio,handle->session_renegotiate_bytes); + + if ( handle->session_renegotiate_time > 0 ) + BIO_set_ssl_renegotiate_timeout(handle->bio,handle->session_renegotiate_time); + + + if ( handle->ssl_session != NULL ) + { + // if we are connecting to the same host again, + // then try to reuse our session, otherwise free it and NULL out our pointer + if ( strcmp(handle->ip, remote_ip) == 0 && handle->port == remote_port ) + { + SSL_set_session(handle->ssl,handle->ssl_session); + } + else + { + SSL_SESSION_free(handle->ssl_session); + handle->ssl_session = NULL; + } + } + + // do this /after/ the above compare + // (this allows NetSSLRestoreClientSession() to pass in + // the handle's own ip and port in order to restore a session) + strncpy(handle->ip,remote_ip,NETSSL_MAX_IP_LEN); + handle->port = remote_port; + + + // bio wants a string like "10.0.1.61:7071" +#if SYS_PC // vis c++ does not have native snprintf call (l@m3r) + _snprintf( buf,sizeof(buf), "%s:%d",handle->ip, handle->port ); +#else + snprintf( buf,sizeof(buf), "%s:%d",handle->ip, handle->port ); +#endif + BIO_set_conn_hostname(handle->bio, buf); + + if ( BIO_set_nbio(handle->bio,1) < 0 ) + { + BIO_free_all(handle->bio); + handle->bio = NULL; + return NETSSL_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION; + } + + // checking the client status will kick off the connect process + ec = NetSSLCheckClientSessionStatus(handle); + if ( ec == NETSSL_STATUS_READY_SEND_AND_RECV + || + ec == NETSSL_STATUS_CONNECT_PENDING ) + { + return NETSSL_RESULT_SUCCESS; + } + else + { + return NETSSL_RESULT_CONNECT_FAILED; + } + +} + +int NetSSLCheckClientSessionStatus(NetSSLHandle *handle) +{ + int ec; + + if ( handle == NULL || handle->ctx == NULL || handle->bio == NULL ) + return NETSSL_STATUS_INVALID_HANDLE; + + // not yet connected, then + if ( handle->connected == 0 ) + { + ec = BIO_do_connect(handle->bio); + if ( ec == 1 ) + { + handle->connected = 1; + handle->session_reused = SSL_session_reused(handle->ssl); + return NETSSL_STATUS_READY_SEND_AND_RECV; + } + else + { + if ( BIO_should_retry(handle->bio) ) + { + return NETSSL_STATUS_CONNECT_PENDING; + } + else + { + // sometimes on Win32 systems, BIO_should_retry() + // fails while connection is still pending even though + // everything is all good + // so for win32, we go to the trouble of digging + // up the socket and using select to see if connection + // has really failed or is just pending +#ifdef SYS_PC + SOCKET sd; + struct timeval waittime; + fd_set writeset; + fd_set exceptset; + + sd = BIO_get_fd(handle->bio, NULL); + waittime.tv_sec = 0; + waittime.tv_usec = 0; + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + FD_SET(sd, &writeset); + FD_SET(sd, &exceptset); + + ec = select( sd + 1, NULL, &writeset, &exceptset, &waittime ); + if ( ec >= 0 ) + { + // select succeeded (if it failed, let normal err happen) + if ( ! FD_ISSET( sd, &exceptset ) ) + { + // if except bit was set, then connect failed, let normal err occur + if (! FD_ISSET( sd, &writeset ) ) + { + // if write bit is not set then connection is still pending + return NETSSL_STATUS_CONNECT_PENDING; + // else some other err occured, let normal err occur + } + } + } +#endif + } + } + // if connected but failed to verify cert + // or should_retry is false, then the connection failed + prts_debug( "SSL CONNECT FAILED!\n" ); + prts_debug( "ERR: %s\n", ERR_error_string(ERR_get_error(),NULL) ); + + // if connection fails, then invalidate our session + // not strictly necessary (session can/should work + // if/when we can connect again) but have had issues + // where session re-use caused connect failures + if ( handle->ssl_session != NULL ) + { + SSL_SESSION_free(handle->ssl_session); + handle->ssl_session = NULL; + } + + BIO_free_all(handle->bio); + handle->bio = NULL; + return NETSSL_STATUS_CONNECT_FAILED; + } + + // if connected then assume ready to send/recv, + // our send/recv functions will handle detecting connection closed + return NETSSL_STATUS_READY_SEND_AND_RECV; +} + + +int NetSSLCloseClientSession( NetSSLHandle *handle ) +{ + if ( handle == NULL || handle->ctx == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + + + if ( handle->bio == NULL ) // already closed? + return NETSSL_RESULT_SUCCESS; + + // go grap client's ssl session before we close the connection + handle->ssl_session = SSL_get1_session(handle->ssl); + BIO_free_all(handle->bio); + + handle->bio = NULL; + handle->connected = 0; + + return NETSSL_RESULT_SUCCESS; + +} + +int NetSSLFreeClientSession( NetSSLHandle *handle ) +{ + if ( handle == NULL || handle->ctx == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + + // close connection if still open + if ( handle->bio != NULL ) + NetSSLCloseClientSession(handle); + + // free session if still open + if ( handle->ssl_session != NULL ) + SSL_SESSION_free(handle->ssl_session); + + // free ssl context + SSL_CTX_free(handle->ctx); + + // null out all our pointers + ResetNetSSLHandle(handle); + + return NETSSL_RESULT_SUCCESS; +} + + +int NetSSLRestoreClientSession( NetSSLHandle *handle ) +{ + if ( handle == NULL || handle->ctx == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + + return NetSSLOpenClientSession( handle, handle->ip, handle->port ); +} + + + +int NetSSLSendOutClientSession( NetSSLHandle *handle, void *data, int *size ) +{ + int ec; + int req_size; + + if ( handle == NULL || handle->ctx == NULL || handle->bio == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL ) + return NETSSL_RESULT_INVALID_PARAMS; + + // record how much data the user wanted to send + req_size = *size; + + ec = NetSSLCheckClientSessionStatus(handle); + if ( ec != NETSSL_STATUS_READY_SEND + && ec != NETSSL_STATUS_READY_SEND_AND_RECV ) + { + return NETSSL_RESULT_CONNECTION_NOT_READY; + } + + *size = BIO_write(handle->bio, data, req_size ); + if(*size <= 0) + { + // this is how bio tells us that the write would have blocked + if(BIO_should_retry(handle->bio)) + return NETSSL_RESULT_CONNECTION_NOT_READY; + else + { + if ( *size == 0 ) // this implies connection closed + return NETSSL_RESULT_CONNECTION_CLOSED; + else // some other error has occured + return NETSSL_RESULT_FAILURE; + } + } + + return NETSSL_RESULT_SUCCESS; + +} + + + +int NetSSLRecvFromClientSession( NetSSLHandle *handle, void *data, int *size ) +{ + int ec; + + if ( handle == NULL || handle->ctx == NULL || handle->bio == NULL ) + return NETSSL_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL ) + return NETSSL_RESULT_INVALID_PARAMS; + + + ec = NetSSLCheckClientSessionStatus(handle); + if ( ec != NETSSL_STATUS_READY_RECV + && ec != NETSSL_STATUS_READY_SEND_AND_RECV ) + { + return NETSSL_RESULT_CONNECTION_NOT_READY; + } + + + *size = BIO_read(handle->bio, data, *size); + + if ( *size <= 0 ) + { + // this is how bio tells us that the read would have blocked + if(BIO_should_retry(handle->bio)) + return NETSSL_RESULT_CONNECTION_NOT_READY; + else + { + if ( *size == 0 ) // this implies connection closed + return NETSSL_RESULT_CONNECTION_CLOSED; + else // some other error has occured + return NETSSL_RESULT_FAILURE; + } + } + else + return NETSSL_RESULT_SUCCESS; + + +} + + + + + +char *NetSSLCheckClientSessionError(NetSSLHandle *handle) +{ + if ( handle == NULL ) + return NULL; + + ERR_error_string_n(ERR_get_error(), handle->error,NETSSL_MAX_ERR_LEN); + return handle->error; +} + + + diff --git a/libraries/pmrt/pmrt_ssl/netssl.h b/libraries/pmrt/pmrt_ssl/netssl.h new file mode 100755 index 0000000..8461bdf --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/netssl.h @@ -0,0 +1,98 @@ +// netssl.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + + +#ifndef NETSSL_H +#define NETSSL_H + +#include +#include +#include + +#include "keygenerate.h" + +enum +{ + NETSSL_RESULT_SUCCESS, + NETSSL_RESULT_PENDING, + NETSSL_RESULT_INVALID_HANDLE, + NETSSL_RESULT_INVALID_PARAMS, + NETSSL_RESULT_FAILED_TO_INIT_SSL_CONTEXT, + NETSSL_RESULT_FAILED_TO_SET_CLIENT_CERT, + NETSSL_RESULT_FAILED_TO_SET_CLIENT_KEY, + NETSSL_RESULT_CLIENT_CERT_NO_MATCH_KEY, + + NETSSL_RESULT_FAILED_TO_SET_SERVER_CERT_FILE, + NETSSL_RESULT_FAILED_TO_SET_VERIFY_CALLBACK, + NETSSL_RESULT_FAILED_TO_SET_CIPHER_LIST, + NETSSL_RESULT_FAILED_TO_INIT_BIO_OBJECT, + NETSSL_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION, + NETSSL_RESULT_CONNECT_FAILED, + NETSSL_RESULT_CONNECTION_NOT_READY, + NETSSL_RESULT_CONNECTION_CLOSED, + NETSSL_RESULT_FAILURE, +}; + +enum +{ + NETSSL_STATUS_READY_SEND, + NETSSL_STATUS_READY_RECV, + NETSSL_STATUS_READY_SEND_AND_RECV, + NETSSL_STATUS_NOT_READY, + NETSSL_STATUS_CONNECT_PENDING, + NETSSL_STATUS_HANDSHAKE_PENDING, + NETSSL_STATUS_INVALID_HANDLE, + NETSSL_STATUS_SELECT_FAILED, + NETSSL_STATUS_CONNECT_FAILED, + NETSSL_STATUS_CLOSED, +}; + + +#define NETSSL_MAX_IP_LEN 64 +#define NETSSL_MAX_ERR_LEN 256 + +typedef struct +{ + int type; + BIO *bio; + SSL_CTX *ctx; + SSL_METHOD *ssl_method; + SSL *ssl; + SSL_SESSION *ssl_session; + char ip[NETSSL_MAX_IP_LEN]; + int port; + char error[NETSSL_MAX_ERR_LEN]; + int connected; + int session_reused; + int session_renegotiate_bytes; + int session_renegotiate_time; + int ignore_dates_on_server_cert; + +} NetSSLHandle; + + +int NetSSLInitClientSession( NetSSLHandle *handle, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + int session_renegotiate_bytes, int session_renegotiate_time, + int ignore_dates_on_server_cert ); +int NetSSLOpenClientSession( NetSSLHandle *handle, char *remote_ip, int remote_port ); +int NetSSLCheckClientSessionStatus(NetSSLHandle *handle); +int NetSSLCloseClientSession( NetSSLHandle *handle ); +int NetSSLSendOutClientSession( NetSSLHandle *handle, void *data, int *size ); +int NetSSLRecvFromClientSession( NetSSLHandle *handle, void *data, int *size ); +int NetSSLRestoreClientSession( NetSSLHandle *handle ); +int NetSSLFreeClientSession( NetSSLHandle *handle ); +char *NetSSLCheckClientSessionError(NetSSLHandle *handle); + + + + + + +#endif + + diff --git a/libraries/pmrt/pmrt_ssl/netssl.o b/libraries/pmrt/pmrt_ssl/netssl.o new file mode 100644 index 0000000..8c91bc1 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/netssl.o differ diff --git a/libraries/pmrt/pmrt_ssl/pmrt_ssl.dsp b/libraries/pmrt/pmrt_ssl/pmrt_ssl.dsp new file mode 100755 index 0000000..22fd9cb --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/pmrt_ssl.dsp @@ -0,0 +1,177 @@ +# Microsoft Developer Studio Project File - Name="pmrt_ssl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pmrt_ssl - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pmrt_ssl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pmrt_ssl.mak" CFG="pmrt_ssl - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pmrt_ssl - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pmrt_ssl - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/pmrt_ssl", FCOAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pmrt_ssl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\pmrt_ssl copy Release\pmrt_ssl.lib c:\g3\lib copy *.h c:\g3\include +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pmrt_ssl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\pmrt_ssl copy Debug\pmrt_ssl.lib c:\g3\lib copy *.h c:\g3\include\pmrt_ssl +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pmrt_ssl - Win32 Release" +# Name "pmrt_ssl - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\aescrypt.c +# End Source File +# Begin Source File + +SOURCE=.\datadigest.c +# End Source File +# Begin Source File + +SOURCE=.\filecrypto.c +# End Source File +# Begin Source File + +SOURCE=.\keygenerate.c +# End Source File +# Begin Source File + +SOURCE=.\memcrypto.c +# End Source File +# Begin Source File + +SOURCE=.\netssl.c +# End Source File +# Begin Source File + +SOURCE=.\randomnumbers.c +# End Source File +# Begin Source File + +SOURCE=.\sslclient.c +# End Source File +# Begin Source File + +SOURCE=.\sslhttpclient.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\aescrypt.h +# End Source File +# Begin Source File + +SOURCE=.\datadigest.h +# End Source File +# Begin Source File + +SOURCE=.\filecrypto.h +# End Source File +# Begin Source File + +SOURCE=.\keygenerate.h +# End Source File +# Begin Source File + +SOURCE=.\memcrypto.h +# End Source File +# Begin Source File + +SOURCE=.\netssl.h +# End Source File +# Begin Source File + +SOURCE=.\pmrt_ssl.h +# End Source File +# Begin Source File + +SOURCE=.\randomnumbers.h +# End Source File +# Begin Source File + +SOURCE=.\sslclient.h +# End Source File +# Begin Source File + +SOURCE=.\sslhttpclient.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/pmrt_ssl/pmrt_ssl.dsw b/libraries/pmrt/pmrt_ssl/pmrt_ssl.dsw new file mode 100755 index 0000000..97f5f8b --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/pmrt_ssl.dsw @@ -0,0 +1,37 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "pmrt_ssl"=.\pmrt_ssl.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/pmrt_ssl", FCOAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/pmrt_ssl", FCOAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/pmrt_ssl/pmrt_ssl.h b/libraries/pmrt/pmrt_ssl/pmrt_ssl.h new file mode 100755 index 0000000..a387b5b --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/pmrt_ssl.h @@ -0,0 +1,31 @@ +// filecrypto.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef PMRTSSL_H +#define PMRTSSL_H + +// openssl includes windows.h so for PC systems, +// need to go lean and mean, otherwise run afowl of a whole lot of stuff +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include "keygenerate.h" +#include "datadigest.h" +#include "filecrypto.h" +#include "netssl.h" +#include "sslclient.h" +#include "sslhttpclient.h" +#include "randomnumbers.h" +#include "memcrypto.h" +#include "aescrypt.h" + +#define PMRT_SSL_MAJOR_VERSION 1 +#define PMRT_SSL_MINOR_VERSION 1 +#define PMRT_SSL_SUB_MINOR_VERSION 0x01 + + +#endif + diff --git a/libraries/pmrt/pmrt_ssl/pmrt_ssl.plg b/libraries/pmrt/pmrt_ssl/pmrt_ssl.plg new file mode 100755 index 0000000..dcdd54d --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/pmrt_ssl.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: pmrt_ssl - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+pmrt_ssl.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/pmrt_ssl/randomnumbers.c b/libraries/pmrt/pmrt_ssl/randomnumbers.c new file mode 100755 index 0000000..9474438 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/randomnumbers.c @@ -0,0 +1,253 @@ +// randomnumbers.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// funcs for generating random numbers + +#include "randomnumbers.h" +#include "keygenerate.h" + +#include +#include +#include +#include +#include + +#define RANDNUM_SEED_BLOCK_SIZE 20 +#define RANDNUM_RAND_BLOCK_SIZE 20 + +// generate random number using OpenSSL's random number generator +// uses /dev/rand, system uptime, passed in bytes, etc. etc. +// to try to be really random +int SSLRand(unsigned char *buffer, int numBytes) +{ +#ifdef SYS_PC + // dump contents of screen grab into PRNG + // have do this as windows does not provide + // a /dev/rand + RAND_screen(); +#endif + return RAND_bytes(buffer, numBytes); +} + + +// functions for generating deterministic series of random numbers +int RandStateInit( RandState *rs ) +{ + if ( rs == NULL ) + return RANDNUM_INVALID_PARAMS; + + // clear out our state + memset(rs,0,sizeof(RandState)); + + // setup hashing handle + InitDataDigest(&rs->ddh,DIGEST_SHA1); + // reset our random state + memset(&rs->md,0,sizeof(rs->md)); + memset(&rs->state,0,sizeof(rs->state)); + rs->count = 0; + rs->spot = 0; + + return RANDNUM_SUCCESS; +} + +int RandStateDeinit( RandState *rs ) +{ + if ( rs == NULL ) + return RANDNUM_INVALID_PARAMS; + + // setup hashing handle + CloseDataDigest(&rs->ddh); + // clear random state + memset(&rs->md,0,sizeof(rs->md)); + memset(&rs->state,0,sizeof(rs->state)); + rs->count = 0; + rs->spot = 0; + + return RANDNUM_SUCCESS; +} + + +int RandStatePsuedoRand( RandState *rs, unsigned char *buf, int num); + +int RandStateSeed( RandState *rs, const void *buf, int num) +{ + + int num_blocks; + int extra_bytes; + int block_size; + int i,j; + int n; + int s; + unsigned char *data; + unsigned char tmp[256]; + + if ( rs == NULL ) + return RANDNUM_INVALID_PARAMS; + + data = (unsigned char *)buf; + + num_blocks = num / RANDNUM_SEED_BLOCK_SIZE; + extra_bytes = num % RANDNUM_SEED_BLOCK_SIZE; + + n = num_blocks; + if ( extra_bytes != 0 ) // do one extra block if we have extra bytes to roll in + n++; + + for( i = 0; i < n; i++ ) + { + if ( i == num_blocks ) // if on that extra block, roll in just the extra bytes + block_size = extra_bytes; + else + block_size = RANDNUM_SEED_BLOCK_SIZE; + + rs->spot++; + if ( rs->spot >= sizeof(rs->state) - block_size ) + rs->spot = 0; + + + + s = sizeof(rs->md); + WriteToDataDigest(&rs->ddh,rs->md,&s); + + s = block_size; + WriteToDataDigest(&rs->ddh,&rs->state[rs->spot],&s); + + s = block_size; + WriteToDataDigest(&rs->ddh,&data[i*RANDNUM_SEED_BLOCK_SIZE],&s); + + s = sizeof(rs->count); + WriteToDataDigest(&rs->ddh,&rs->count,&s); + ComputeDataDigest(&rs->ddh); + + // copy out the md and then xor it into state + memcpy(rs->md,rs->ddh.digest,rs->ddh.digest_len); + for ( j = 0; j < block_size; j++ ) + { + rs->state[rs->spot + j] ^= rs->md[j]; + } + + rs->count++; + + + } + + // spin on it a little bit for good measure, not strictly neccessary but what the heck? + memset(tmp, 0, sizeof(tmp) ); + for ( i = 0; i < (int)sizeof(tmp) + num; i++ ) + { + RandStatePsuedoRand( rs, tmp, sizeof(tmp) ); + } + + return RANDNUM_SUCCESS; +} + +/* +When bytes are extracted from the RNG, the following process is used. +For each group of 10 bytes (or less), we do the following: + +Input into the hash function the local 'md' (which is initialized from the global +'md' before any bytes are generated), the bytes that are to be overwritten +by the random bytes, and bytes from the 'state' (incrementing looping index). +From this digest output (which is kept in 'md'), the top (up to) 10 bytes are +returned to the caller and the bottom 10 bytes are xored into the 'state'. + +Finally, after we have finished 'num' random bytes for the caller, 'count' +(which is incremented) and the local and global 'md' are fed into the hash function +and the results are kept in the global 'md'. +*/ + +int RandStatePsuedoRand(RandState *rs, unsigned char *buf, int num) +{ + + int num_blocks; + int extra_bytes; + int block_size; + int i,j; + int n; + int s; + unsigned char *data; + + unsigned char local_md[DATADIGEST_MAX_DIGEST_LEN]; + + if ( rs == NULL ) + return RANDNUM_INVALID_PARAMS; + + data = (unsigned char *)buf; + + + // copy global md to local md + memcpy(local_md,rs->md,sizeof(local_md)); + + num_blocks = num / RANDNUM_RAND_BLOCK_SIZE; + extra_bytes = num % RANDNUM_RAND_BLOCK_SIZE; + + n = num_blocks; + if ( extra_bytes != 0 ) // do one extra block if we have extra bytes to roll in + n++; + + for( i = 0; i < n; i++ ) + { + if ( i == num_blocks ) // if on that extra block, roll in just the extra bytes + block_size = extra_bytes; + else + block_size = RANDNUM_RAND_BLOCK_SIZE; + + + rs->spot++; + if ( rs->spot >= sizeof(rs->state) - block_size ) + rs->spot = 0; + + + s = sizeof(local_md); + WriteToDataDigest(&rs->ddh,local_md,&s); + + // don't use the passed in data, this could add random noise to + // the generator and we don't want that + //s = block_size; + //WriteToDataDigest(&rs->ddh,&data[i*KEYGEN_RAND_BLOCK_SIZE],&s); + + s = block_size; + WriteToDataDigest(&rs->ddh,&rs->state[rs->spot],&s); + + ComputeDataDigest(&rs->ddh); + + // copy out the md + memcpy(rs->md,rs->ddh.digest,rs->ddh.digest_len); + + // return top ten bytes to caller + for( j = 0; j < block_size; j++ ) + { + data[(i*RANDNUM_RAND_BLOCK_SIZE) + j] = rs->md[j]; + } + + // xor last ten bytes into state + for ( j = 0; j < block_size; j++ ) + { + rs->state[rs->spot + j] ^= rs->md[rs->ddh.digest_len - j - 1]; + } + + } + + rs->count++; + + s = sizeof(rs->count); + WriteToDataDigest(&rs->ddh,&rs->count,&s); + + s = sizeof(local_md); + WriteToDataDigest(&rs->ddh,local_md,&s); + + s = sizeof(rs->md); + WriteToDataDigest(&rs->ddh,rs->md,&s); + + ComputeDataDigest(&rs->ddh); + + // copy out the md + memcpy(rs->md,rs->ddh.digest,rs->ddh.digest_len); + + return RANDNUM_SUCCESS; +} + +//EOF + + diff --git a/libraries/pmrt/pmrt_ssl/randomnumbers.h b/libraries/pmrt/pmrt_ssl/randomnumbers.h new file mode 100755 index 0000000..da810e7 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/randomnumbers.h @@ -0,0 +1,42 @@ +// randomnumbers.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// funcs for generating random numbers + +#ifndef RANDOMNUMBERS_H +#define RANDOMNUMBERS_H + +#include "keygenerate.h" + + +typedef struct +{ + unsigned char state[1023]; + unsigned char md[DATADIGEST_MAX_DIGEST_LEN]; + unsigned int count; + unsigned int spot; + DataDigestHandle ddh; +} RandState; + +enum { + RANDNUM_SUCCESS, + RANDNUM_INVALID_PARAMS, + +} RandomNumbersErrCodes; + +// generate random number using OpenSSL's random number generator +// uses /dev/rand, system uptime, passed in bytes, etc. etc. +// to try to be really random +int SSLRand(unsigned char *buffer, int numBytes); + +// functions for generating deterministic series of random numbers +int RandStateInit( RandState *rs ); +int RandStateDeinit( RandState *rs ); +int RandStatePsuedoRand( RandState *rs, unsigned char *buf, int num); +int RandStateSeed( RandState *rs, const void *buf, int num); + + + +#endif + diff --git a/libraries/pmrt/pmrt_ssl/randomnumbers.o b/libraries/pmrt/pmrt_ssl/randomnumbers.o new file mode 100644 index 0000000..f41c62e Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/randomnumbers.o differ diff --git a/libraries/pmrt/pmrt_ssl/sslclient.c b/libraries/pmrt/pmrt_ssl/sslclient.c new file mode 100755 index 0000000..c531bd8 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/sslclient.c @@ -0,0 +1,383 @@ +// sslclient.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +#include "sslclient.h" + + +#include +#include +#include +#include +#include + + +int InitSSLClientStateStruct(SSLClientStateStruct *clientstate, + char *server_ip, int server_port, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + char *send_buf, int send_buf_size, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int (*eod_check)(struct SSLClientStateStruct*), + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout, + int ssl_renegotiate_bytes, int ssl_renegotiate_seconds, + int ignore_dates_on_server_cert ) +{ + int ec; + if ( clientstate == NULL ) + return -1; + + memset( clientstate,0, sizeof(SSLClientStateStruct) ); + + strcpy(clientstate->server_ip, server_ip); + clientstate->server_port = server_port; + + clientstate->state = SSL_CLIENT_STATE_OPEN_CONNECTION; + clientstate->error_code = SSL_CLIENT_ERR_NONE; + clientstate->send_buf = send_buf; + clientstate->send_buf_size = send_buf_size; + clientstate->recv_buf = recv_buf; + clientstate->recv_buf_size = recv_buf_size; + + clientstate->eod_check = eod_check; + clientstate->null_terminate_recv_data = null_terminate_recvd_data; + if ( clientstate->eod_check == NULL ) + clientstate->close_connection_after_recv_data = 1; + else + clientstate->close_connection_after_recv_data = close_connection_after_recv_data; + + // clear out recv buffer (just in case there was something else in there) + memset( clientstate->recv_buf, 0, clientstate->recv_buf_size ); + + + + clientstate->backoff_timeout = backoff_timeout; + clientstate->connect_timeout = connect_timeout; + clientstate->send_timeout = send_timeout; + clientstate->recv_timeout = recv_timeout; + + + ec = NetSSLInitClientSession(&clientstate->nsh, client_kgh, client_certfile, client_keyfile, server_certfile,cipherlist,ssl_renegotiate_bytes, ssl_renegotiate_seconds, ignore_dates_on_server_cert); + if ( ec != NETSSL_RESULT_SUCCESS ) + { + if ( ec == NETSSL_RESULT_FAILED_TO_SET_SERVER_CERT_FILE ) + return -3; // call this one out special b/c we might like to ignore it + else + return -2; + } + + return 0; +} + +int ResetSSLClientStateStruct(SSLClientStateStruct *clientstate ) +{ + if ( clientstate == NULL ) + return -1; + + clientstate->error_code = SSL_CLIENT_ERR_NONE; + + clientstate->retries = 0; + clientstate->start_time = 0; + clientstate->curr_state_start = 0; + + clientstate->recv_count = 0; + clientstate->send_count = 0; + + clientstate->send_start_time = 0; + clientstate->send_time = 0; + clientstate->recv_start_time = 0; + clientstate->recv_time = 0; + + + if ( clientstate->connected ) + clientstate->state = SSL_CLIENT_STATE_SEND_DATA; + else + { + clientstate->state = SSL_CLIENT_STATE_OPEN_CONNECTION; + clientstate->connect_start_time = 0; + clientstate->connect_time = 0; + clientstate->close_start_time = 0; + clientstate->close_time = 0; + clientstate->complete_time = 0; + } + + return 0; +} + + +int SetSSLClientStateStructRecvBuf(SSLClientStateStruct *clientstate, char *recv_buf, int recv_buf_size ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->recv_buf = recv_buf; + clientstate->recv_buf_size = recv_buf_size; + clientstate->recv_count = 0; + // clear out recv buffer (just in case there was something else in there) + memset( clientstate->recv_buf, 0, clientstate->recv_buf_size ); + return 0; +} + +int ResetSSLClientStateStructRecvBuf(SSLClientStateStruct *clientstate ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->recv_count = 0; + // clear out recv buffer (just in case there was something else in there) + memset( clientstate->recv_buf, 0, clientstate->recv_buf_size ); + return 0; +} + + +int SetSSLClientStateStructSendBuf(SSLClientStateStruct *clientstate, char *send_buf, int send_buf_size ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->send_buf = send_buf; + clientstate->send_buf_size = send_buf_size; + clientstate->send_count = 0; + return 0; +} + +int SetSSLClientStateStructTimeOuts(SSLClientStateStruct *clientstate, int connect_timeout, int send_timeout, + int recv_timeout, int backoff_timeout ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->backoff_timeout = backoff_timeout; + clientstate->connect_timeout = connect_timeout; + clientstate->send_timeout = send_timeout; + clientstate->recv_timeout = recv_timeout; + return 0; +} + + +int FreeSSLClientStateStruct(SSLClientStateStruct *clientstate) +{ + if ( clientstate == NULL ) + return -1; + clientstate->state = SSL_CLIENT_STATE_FREE_SESSION; + return UpdateSSLClientState(clientstate); +} + + +int CloseSSLClientConnection(SSLClientStateStruct *clientstate) +{ + if ( clientstate == NULL ) + return -1; + clientstate->state = SSL_CLIENT_STATE_CLOSE_CONNECTION; + return UpdateSSLClientState(clientstate); +} + + +// use to change the server's ip and port after Init +// new server will be use next time connection is closed and re-opened again +int SetSSLClientStateStructServer(SSLClientStateStruct *clientstate, char *server_ip, int server_port ) +{ + if ( clientstate == NULL ) + return -1; + strcpy(clientstate->server_ip, server_ip); + clientstate->server_port = server_port; + return 0; +} + + +int UpdateSSLClientState(SSLClientStateStruct *clientstate) +{ + int ec; + int t; + int recvd_bytes; + int sent_bytes; + if ( clientstate == NULL ) + return -1; + + t = time(NULL); + if( clientstate->start_time == 0 ) + clientstate->start_time = t; + if ( clientstate->curr_state_start == 0 ) + clientstate->curr_state_start = t; + + switch(clientstate->state) + { + case SSL_CLIENT_STATE_AVAILABLE: + break; + case SSL_CLIENT_STATE_OPEN_CONNECTION: + clientstate->connect_start_time = GetSysElapsedMicroseconds(); + clientstate->connected = 0; + ec = NetSSLOpenClientSession( &clientstate->nsh, clientstate->server_ip, clientstate->server_port ); + if ( ec == NETSSL_RESULT_SUCCESS ) + { + clientstate->state = SSL_CLIENT_STATE_WAIT_FOR_CONNECTION; + clientstate->curr_state_start = t; + } + else + { + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_CONNECT_FAILED; + } + break; + case SSL_CLIENT_STATE_WAIT_FOR_CONNECTION: + ec = NetSSLCheckClientSessionStatus(&clientstate->nsh); + if ( ec == NETSSL_STATUS_READY_SEND || ec == NETSSL_STATUS_READY_SEND_AND_RECV ) + { + clientstate->state = SSL_CLIENT_STATE_SEND_DATA; + clientstate->curr_state_start = t; + clientstate->connected = 1; + clientstate->connect_time = GetSysElapsedMicroseconds() - clientstate->connect_start_time; + } + else if ( ec == NETSSL_STATUS_CONNECT_FAILED ) + { + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_CONNECT_FAILED; + } + else if ( t > clientstate->curr_state_start + clientstate->connect_timeout ) + { + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_CONNECT_TIMEDOUT; + } + break; + case SSL_CLIENT_STATE_SEND_DATA: + if ( clientstate->send_start_time == 0 ) + clientstate->send_start_time = GetSysElapsedMicroseconds(); + sent_bytes = clientstate->send_buf_size - clientstate->send_count; + ec = NetSSLSendOutClientSession( &clientstate->nsh, &clientstate->send_buf[clientstate->send_count], &sent_bytes ); + prts_debug("client Sending '%s'\n", clientstate->send_buf ); + if( ec == NETSSL_RESULT_SUCCESS ) + { + clientstate->send_count += sent_bytes; + if ( clientstate->send_count >= clientstate->send_buf_size ) + { + clientstate->state = SSL_CLIENT_STATE_RECV_DATA; + clientstate->curr_state_start = t; + clientstate->last_recv_time = t; + clientstate->send_time += GetSysElapsedMicroseconds() - clientstate->send_start_time; + clientstate->recv_start_time = GetSysElapsedMicroseconds(); + } + } + else if ( ec == NETSSL_RESULT_FAILURE ) + { + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_SEND_FAILED; + } + else if ( t > clientstate->curr_state_start + clientstate->send_timeout ) + { + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_SEND_TIMEDOUT; + } + // retry send next pass through + break; + case SSL_CLIENT_STATE_RECV_DATA: + if ( clientstate->recv_start_time == 0 ) + { + clientstate->recv_start_time = GetSysElapsedMicroseconds(); + clientstate->last_recv_time = t; + } + // set max bytes to recv (so we don't overrun recv buffer) + if( clientstate->null_terminate_recv_data == 1 ) + recvd_bytes = clientstate->recv_buf_size - clientstate->recv_count -1 ; // leave an extra space in recv buffer for null terminator + else + recvd_bytes = clientstate->recv_buf_size - clientstate->recv_count; + if ( recvd_bytes <= 0 ) + { + // out of buffer space + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_RECV_BUFFER_FULL; + break; + } + ec = NetSSLRecvFromClientSession( &clientstate->nsh, &clientstate->recv_buf[clientstate->recv_count], &recvd_bytes ); + //if ( recvd_bytes > 0 ) + // prts_debug("Recvd %d bytes, %d total '%s'\n", recvd_bytes, clientstate->recv_count, clientstate->recv_buf ); + if( ec == NETSSL_RESULT_SUCCESS ) + { + clientstate->recv_count += recvd_bytes; + if ( clientstate->null_terminate_recv_data == 1 ) + clientstate->recv_buf[clientstate->recv_count] = '\0'; // null terminate string + + // check for end of data + if ( clientstate->eod_check != NULL && + clientstate->eod_check(clientstate) == 0 ) + { + clientstate->state = SSL_CLIENT_STATE_RECV_COMPLETE; + clientstate->curr_state_start = t; + clientstate->recv_time += GetSysElapsedMicroseconds() - clientstate->recv_start_time; + } + clientstate->last_recv_time = t; + } + else if ( ec == NETSSL_RESULT_CONNECTION_NOT_READY ) + { + if ( t > clientstate->last_recv_time + clientstate->recv_timeout ) + { + prts_debug("CLIENT RECV TIMEOUT\n"); + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_RECV_TIMEDOUT; + } + } + else if ( ec == NETSSL_RESULT_CONNECTION_CLOSED + && clientstate->eod_check == NULL ) + { + // if no eod func is specificied, then we rely on server closing the + // connection as our signal to stop recv'ng + clientstate->state = SSL_CLIENT_STATE_RECV_COMPLETE; + clientstate->curr_state_start = t; + clientstate->recv_time += GetSysElapsedMicroseconds() - clientstate->recv_start_time; + } + else // some other error occurred while sending! + { + prts_debug("CLIENT RECV ERROR (ec = %d)\n", ec); + clientstate->state = SSL_CLIENT_STATE_ERROR; + clientstate->error_code = SSL_CLIENT_ERR_RECV_FAILED; + } + break; + case SSL_CLIENT_STATE_RECV_COMPLETE: + if ( clientstate->close_connection_after_recv_data == 1 ) + { + clientstate->state = SSL_CLIENT_STATE_CLOSE_CONNECTION; + clientstate->curr_state_start = t; + } + else // otherwise jump right to done + { + clientstate->state = SSL_CLIENT_STATE_DONE; + } + break; + case SSL_CLIENT_STATE_CLOSE_CONNECTION: + clientstate->close_start_time = GetSysElapsedMicroseconds(); + NetSSLCloseClientSession(&clientstate->nsh); + clientstate->close_time = GetSysElapsedMicroseconds() - clientstate->close_start_time; + clientstate->complete_time = GetSysElapsedMicroseconds() - clientstate->connect_start_time; + clientstate->state = SSL_CLIENT_STATE_DONE; + clientstate->curr_state_start = t; + clientstate->connected = 0; + break; + case SSL_CLIENT_STATE_DONE: + break; + case SSL_CLIENT_STATE_ERROR: + break; + case SSL_CLIENT_STATE_BACKOFF: // put this client in this state to have him spin for a bit (like after he reports a failed connection attempt) + if ( t > clientstate->curr_state_start + clientstate->backoff_timeout ) + { + clientstate->state = SSL_CLIENT_STATE_AVAILABLE; + } + break; + case SSL_CLIENT_STATE_FREE_SESSION: + NetSSLCloseClientSession(&clientstate->nsh); + NetSSLFreeClientSession(&clientstate->nsh); + clientstate->state = SSL_CLIENT_STATE_DONE; + clientstate->curr_state_start = t; + clientstate->connected = 0; + break; + } + + // rather than wait another loop to notice an err, check for one right away + if ( clientstate->state == SSL_CLIENT_STATE_ERROR ) + { + clientstate->state = SSL_CLIENT_STATE_CLOSE_CONNECTION; + clientstate->curr_state_start = t; + } + + return 0; +} + diff --git a/libraries/pmrt/pmrt_ssl/sslclient.h b/libraries/pmrt/pmrt_ssl/sslclient.h new file mode 100755 index 0000000..3391297 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/sslclient.h @@ -0,0 +1,127 @@ +// sslclient.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#ifndef SSLCLIENT_H +#define SSLCLIENT_H + +#include +#include "netssl.h" +#include "keygenerate.h" + +typedef struct SSLClientStateStruct +{ + char server_ip[32]; + int server_port; + int state; + int start_time; + int curr_state_start; + int retries; + int curr_state_retries; + int connected; + int error_code; + + NetSSLHandle nsh; + + int (*eod_check)(struct SSLClientStateStruct*); + + char *send_buf; + int send_buf_size; + int send_count; + char *recv_buf; + int recv_buf_size; + int recv_count; + int last_recv_time; + + int null_terminate_recv_data; + int close_connection_after_recv_data; + + int connect_timeout; + int send_timeout; + int recv_timeout; + int backoff_timeout; + + uns64 connect_start_time; + uns64 connect_time; + uns64 send_start_time; + uns64 send_time; + uns64 recv_start_time; + uns64 recv_time; + uns64 close_start_time; + uns64 close_time; + uns64 complete_time; + +} SSLClientStateStruct; + +enum SSLClientStates +{ + SSL_CLIENT_STATE_AVAILABLE, + SSL_CLIENT_STATE_OPEN_CONNECTION, + SSL_CLIENT_STATE_WAIT_FOR_CONNECTION, + SSL_CLIENT_STATE_SEND_DATA, + SSL_CLIENT_STATE_RECV_DATA, + SSL_CLIENT_STATE_RECV_COMPLETE, + SSL_CLIENT_STATE_CLOSE_CONNECTION, + SSL_CLIENT_STATE_FREE_SESSION, + SSL_CLIENT_STATE_DONE, + SSL_CLIENT_STATE_ERROR, + SSL_CLIENT_STATE_BACKOFF, + +}; + + +enum SSLClientStateErrorCodes +{ + SSL_CLIENT_ERR_NONE, + SSL_CLIENT_ERR_CONNECT_FAILED, + SSL_CLIENT_ERR_SEND_FAILED, + SSL_CLIENT_ERR_RECV_FAILED, + SSL_CLIENT_ERR_CONNECT_TIMEDOUT, + SSL_CLIENT_ERR_SEND_TIMEDOUT, + SSL_CLIENT_ERR_RECV_TIMEDOUT, + SSL_CLIENT_ERR_RECV_BUFFER_FULL, +}; + + + + +int InitSSLClientStateStruct(SSLClientStateStruct *clientstate, + char *server_ip, int server_port, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + char *send_buf, int send_buf_size, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int (*eod_check)(struct SSLClientStateStruct*), + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout, + int ssl_renegotiate_bytes, int ssl_renegotiate_seconds, + int ignore_dates_on_server_cert ); + + +int UpdateSSLClientState(SSLClientStateStruct *clientstate); + +int ResetSSLClientStateStruct(SSLClientStateStruct *clientstate ); + +int ResetSSLClientStateStructRecvBuf(SSLClientStateStruct *clientstate ); + +int SetSSLClientStateStructSendBuf(SSLClientStateStruct *clientstate, char *send_buf, int send_buf_size ); +int SetSSLClientStateStructRecvBuf(SSLClientStateStruct *clientstate, char *recv_buf, int recv_buf_size ); + +int SetSSLClientStateStructTimeOuts(SSLClientStateStruct *clientstate, int connect_timeout, int send_timeout, + int recv_timeout, int backoff_timeout ); + +int SetSSLClientStateStructServer(SSLClientStateStruct *clientstate, char *server_ip, int server_port ); + +int FreeSSLClientStateStruct(SSLClientStateStruct *clientstate); + +int CloseSSLClientConnection(SSLClientStateStruct *clientstate); + +#endif + + diff --git a/libraries/pmrt/pmrt_ssl/sslclient.o b/libraries/pmrt/pmrt_ssl/sslclient.o new file mode 100644 index 0000000..9d9317b Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/sslclient.o differ diff --git a/libraries/pmrt/pmrt_ssl/sslhttpclient.c b/libraries/pmrt/pmrt_ssl/sslhttpclient.c new file mode 100755 index 0000000..2b335b0 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/sslhttpclient.c @@ -0,0 +1,929 @@ +// sslhttpclient.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +#include "sslhttpclient.h" + + +#include +#include +#include +#include +#include + + +#define HTTP_REPLY_START "HTTP/1.1" +#define HTTP_REQUEST_OK 200 // "HTTP/1.1 200 OK" +#define HTTP_PARTIAL_REQUEST_OK 206 // "HTTP/1.1 206 Partial Content" +#define HTTP_CONT_REPLY 100 // "HTTP/1.1 100 Continue" +#define CONTENT_LENGTH_HEADER "Content-Length:" +#define TRANFER_ENCODING_HEADER "Transfer-Encoding:" + + +int HTTPGetParserInit( HTTPGetParserStruct *parser, + char *server_ip, int server_port, + char *request_document, int request_start_byte, + char *dest_filename, + char *dest_buf, int dest_buf_size, + int null_terminate_data, + int close_connection_after_recv_data + ) +{ + if ( parser == NULL ) + return -1; + if ( dest_filename == NULL && dest_buf == NULL ) + return -2; + if ( request_document == NULL || request_start_byte < 0 ) + return -3; + + + // reset entire parser + memset( parser,0, sizeof(HTTPGetParserStruct) ); + + strncpy(parser->server_ip, server_ip, sizeof(parser->server_ip)); + parser->server_port = server_port; + strncpy(parser->request_document, request_document, sizeof(parser->request_document) ); + parser->request_start_byte = request_start_byte; + parser->close_connection_after_recv_data = close_connection_after_recv_data; + + if ( dest_filename != NULL ) // if given a filename, then assume we will write reply data into that file + { + strncpy(parser->data_file, dest_filename, sizeof(parser->data_file)); + parser->null_terminate_data = 0; + } + else // assume we will put reply data into dest_buf + { + parser->data_buf = dest_buf; + parser->data_buf_size = dest_buf_size; + parser->null_terminate_data = null_terminate_data; + } + + parser->state = HTTP_GET_STATE_START; + parser->error_code = HTTP_GET_ERR_NONE; + + // this generates our request string + HTTPGetParserGetRequestString( parser ); + + return 0; +} + +char *HTTPGetParserGetRequestString( HTTPGetParserStruct *parser ) +{ + if ( parser == NULL ) + return NULL; + + // clear our buffer just to be safe + memset( parser->request, 0, sizeof(parser->request) ); + + // construct our HTTP request, pretty simple + sprintf( parser->request, + "GET %s HTTP/1.1\r\nHost: %s:%d\nRange: bytes=%d-\r\n", + parser->request_document, parser->server_ip, parser->server_port, parser->request_start_byte ); + + if ( parser->close_connection_after_recv_data ) + strcat( parser->request, "Connection: close\r\n" ); + + // add closing new line + strcat( parser->request, "\r\n" ); + + return parser->request; +} + +int HTTPGetParserParseHeader( HTTPGetParserStruct *parser ) +{ + int ec; + int done; + int pos; + char *data; + char *line; + char *field; + char *value; + int line_num; + if ( parser == NULL ) + return -1; + + ec = HTTP_GET_ERR_NONE; + + //prts_debug( "HTTP Get Reply Header:\n" ); + //prts_debug( parser->header ); + //prts_debug( "\n" ); + + // walk header line by line + data = parser->header; + line_num = 0; + done = 0; + pos = 0; + while ( ! done && pos < parser->header_len ) + { + line = data; + while(data[0] != '\n' && pos < parser->header_len ) + { + if ( data[0] == '\r' ) // zap out any carriage returns (they are useless anyway) + data[0] = '\0'; + data++; + pos++; + } + data[0]='\0'; + + // adv data ptr one more time + data++; + pos++; + + line_num++; + + // first line is err code from server + if ( line_num == 1 ) + { + if ( strncmp( line, HTTP_REPLY_START, strlen(HTTP_REPLY_START) ) == 0 ) + { + value = line; + // step value pointer past the field text + while( value[0] != ' ' && value[0] != '\0' ) + value++; + while( value[0] == ' ' && value[0] != '\0' ) + { + value[0] = '\0'; + value++; + } + parser->http_error_code = atoi(value); + if ( parser->http_error_code == HTTP_REQUEST_OK + || + parser->http_error_code == HTTP_PARTIAL_REQUEST_OK ) + { + // all around success! + continue; + } + else if( parser->http_error_code == HTTP_CONT_REPLY ) + { + // means we got a continue message from server, + // this means we gotta wait more for the real header to + // comeback, so reset our header parsing status + parser->header_len = 0; + memset(parser->header, 0, sizeof(parser->header) ); + parser->state = HTTP_GET_STATE_PARSING_HEADER; + return HTTP_GET_ERR_NONE; + } + else + { + // got back some other http error code + // we keep parsing entire HTTP message + // as it usual contains an detailed err report + // as the message data + // prts_debug( "HTTP PARSER: GOT BACK ERR: %s %s\n", line, value ); + continue; + } + + + } + else + { + // got back garbage + prts_debug( "HTTP PARSER: GOT BACK GARBAGE: %s\n", line ); + ec = HTTP_GET_ERR_PARSE_ERR; + break; + } + } + + // other lines contain data about result + // we only care about certain things + + // format for header lines is: + // field: value + // eg: + // Content-Length: 100 + + field = line; + value = line; + // step value pointer past the field text + while( value[0] != ' ' && value[0] != '\0' ) + value++; + while( value[0] == ' ' && value[0] != '\0' ) + { + value[0] = '\0'; + value++; + } + + if( strcmp( field, CONTENT_LENGTH_HEADER ) == 0 ) + { + parser->content_len = atoi(value); + } + + if( strcmp( field, TRANFER_ENCODING_HEADER ) == 0 ) + { + if ( strncmp(value,"chunked", 5 ) == 0 ) + parser->chunk_encoded = 1; + } + + } + + + return ec; +} + + + +int HTTPGetParserParseRecvdData( HTTPGetParserStruct *parser, char *data, int len ) +{ + int ec; + int pos; + int found; + int copy_len; + + + if ( parser == NULL || data == NULL ) + return -1; + + if ( len == 0 ) + return HTTP_GET_ERR_NONE; + + switch(parser->state) + { + case HTTP_GET_STATE_START: + case HTTP_GET_STATE_PARSING_HEADER: + // we are looking for the end of the header + // this is signaled by CRLF,CRLF or by two new lines in succession (empty line) + // special case, end of header got split btwn this new data and data + // we already copied into the header buffer + if( parser->header_len > 0 + && + (data[0] == '\n' || data[0] == '\r') ) + { + // several ways for this to happen + // gotta check them all, probly would be worth + // busting out the regexes for this... + if ( data[0] == '\n' ) + { + // second new line in a '\n','\n' sequence + if ( parser->header[parser->header_len-1] == '\n' ) + { + pos = 0; + found = 1; + } + // second new line in a '\r','\n','\r','\n' sequence + if ( parser->header_len > 2 + && + parser->header[parser->header_len-3] == '\r' + && + parser->header[parser->header_len-2] == '\n' + && + parser->header[parser->header_len-1] == '\r' + ) + { + pos = 0; + found = 1; + } + // first new line in a '\r','\n','\r','\n' sequence + if ( len > 2 + && + parser->header[parser->header_len-1] == '\r' + && + data[1] == '\r' + && + data[2] == '\n' + ) + { + pos = 0; + found = 1; + } + } + else if ( data[0] == '\r') + { + // second cr in a '\r','\n','\r','\n' sequence + if ( parser->header_len > 1 && len > 1 + && + parser->header[parser->header_len-1] == '\r' + && + parser->header[parser->header_len-2] == '\n' + && + data[1] == '\n' + ) + { + pos = 0; + found = 1; + } + // first cr in a '\r','\n','\r','\n' sequence + // this case covered by normal search below + } + } + else // otherwise, normal case, look for end of header in new data + { + pos = 1; + found = 0; + while ( pos < len ) + { + if ( + // this is the standard, CRLF,CRLF + ( pos > 2 + && data[pos - 3] == '\r' && data[pos - 2] == '\n' + && data[pos - 1] == '\r' && data[pos] == '\n' ) + || // this one is useful for parsing http commands from text files + (data[pos - 1] == '\n' && data[pos] == '\n') + ) + { + found = 1; + break; + } + pos++; + } + } + + if ( found == 1 ) + copy_len = pos + 1; + else + copy_len = len; + + if ( parser->header_len + copy_len > sizeof(parser->header) - 1 ) // leave space for null terminator + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_HEADER_BUFFER_FULL; + return parser->error_code; + } + // copy header data into our header buffer + memcpy( &parser->header[parser->header_len], data, copy_len ); + parser->header_len += copy_len; + parser->header[parser->header_len] = '\0'; // null terminate header string + + // if we found the end of our header, then + // parse the header and start parsing any extra data in the passed block + if ( found == 1 ) + { + // important to do this first, as HTTPGetParserParseHeader could push + // us back to the parsing header state (in case of HTTP/1.1 continue) + parser->state = HTTP_GET_STATE_PARSING_DATA; + + ec = HTTPGetParserParseHeader( parser ); + if ( ec != HTTP_GET_ERR_NONE ) + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = ec; + return parser->error_code; + } + + // parse rest of the passed data block + if ( copy_len < len ) + return HTTPGetParserParseRecvdData( parser, &data[copy_len], len - copy_len ); + } + break; + case HTTP_GET_STATE_PARSING_DATA: + if ( parser->chunk_encoded ) // chunk'd data + { + // have we read in the chunk header yet? + if ( parser->chunk_len == 0 ) + { + // a CRLF is inserted after each chunk of data, + // so we skip a leading '\r' or '\n' if we see it + if ( parser->chunk_header_len == 0 && (data[0] == '\n' || data[0] == '\r') ) + { + return HTTPGetParserParseRecvdData( parser, &data[1], len - 1 ); + } + + // gotta read in the chunk header + // it's a single line with a hex number on it + // which tells us how long the upcoming chunk is + pos = 0; + found = 0; + while(pos 0 && data[pos - 1] == '\r' && data[pos] == '\n' ) + || // this one is useful for parsing http commands from text files + (data[pos] == '\n') + ) + { + found = 1; + break; + } + pos++; + } + if ( found == 1 ) + copy_len = pos + 1; + else + copy_len = len; + + if ( parser->chunk_header_len + copy_len > sizeof(parser->chunk_header) - 1 ) // leave space for null terminator + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_HEADER_BUFFER_FULL; + return parser->error_code; + } + + // copy header data into our header buffer + memcpy( &parser->chunk_header[parser->chunk_header_len], data, copy_len ); + parser->chunk_header_len += copy_len; + parser->chunk_header[parser->chunk_header_len - 1] = '\0'; // null terminate header string + + if ( found == 1 ) + { + parser->chunk_pos = 0; + + sscanf( parser->chunk_header, "%X", &parser->chunk_len ); + if ( parser->chunk_len == 0 ) + { + // this was the last chunk, we are all done + // though we may still have to read out a few footers + if ( parser->fd != NULL ) + { + fclose(parser->fd); + parser->fd = NULL; + } + parser->state = HTTP_GET_STATE_PARSE_FOOTER; + } + } + // parse rest of the passed data block + if ( copy_len < len ) + return HTTPGetParserParseRecvdData( parser, &data[copy_len], len - copy_len ); + + } + else // we got our chunk header and are now reading the chunk's data + { + if ( parser->data_buf != NULL ) // writing result to passed data buffer + { + copy_len = parser->chunk_len - parser->chunk_pos; + + if ( copy_len > len ) + copy_len = len; + + if ( parser->data_buf_size - 1 < (parser->data_len + copy_len) ) // leave space for null terminator + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_DATA_BUFFER_FULL; + return parser->error_code; + } + memcpy(&parser->data_buf[parser->data_len], data, copy_len ); + parser->data_len += copy_len; + parser->chunk_pos += copy_len; + if ( parser->null_terminate_data ) + { + parser->data_buf[parser->data_len] = '\0'; + } + if ( parser->chunk_pos >= parser->chunk_len ) + { + // copied in all our chunk data + parser->chunk_len = 0; + parser->chunk_pos = 0; + parser->chunk_header_len = 0; + memset(parser->chunk_header, 0, sizeof(parser->chunk_header)); + } + // parse rest of the passed data block + if ( copy_len < len ) + return HTTPGetParserParseRecvdData( parser, &data[copy_len], len - copy_len ); + } + else // writing result to a file + { + if ( parser->fd == NULL ) + { + // open file for writing or appending + // (assume resuming a file transfer if given a start_byte other than 0) + if ( parser->request_start_byte > 0 ) + parser->fd = fopen(parser->data_file, "ab" ); + else + parser->fd = fopen(parser->data_file, "wb" ); + + if ( parser->fd == NULL ) + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_DATA_FILE_OPEN_FAILED; + return parser->error_code; + } + } + + copy_len = parser->chunk_len - parser->chunk_pos; + + if ( copy_len > len ) + copy_len = len; + + ec = fwrite(data,1,copy_len,parser->fd); + if ( ec != copy_len ) + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_DATA_FILE_WRITE_FAILED; + fclose(parser->fd); + parser->fd = NULL; + return parser->error_code; + } + parser->data_len += copy_len; + parser->chunk_pos += copy_len; + if ( parser->chunk_pos >= parser->chunk_len ) + { + // copied in all our chunk data + parser->chunk_len = 0; + parser->chunk_pos = 0; + parser->chunk_header_len = 0; + memset(parser->chunk_header, 0, sizeof(parser->chunk_header)); + } + // parse rest of the passed data block + if ( copy_len < len ) + return HTTPGetParserParseRecvdData( parser, &data[copy_len], len - copy_len ); + } + } + } + else // data as one big blob + { + // this mode is much easier + if ( parser->data_buf != NULL ) // writing result to passed data buffer + { + copy_len = parser->content_len - parser->data_len; + + if ( copy_len > len ) + copy_len = len; + + if ( parser->data_buf_size - 1 < (parser->data_len + copy_len) ) // leave space for null terminator + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_DATA_BUFFER_FULL; + return parser->error_code; + } + memcpy(&parser->data_buf[parser->data_len], data, copy_len ); + parser->data_len += copy_len; + if ( parser->null_terminate_data ) + { + parser->data_buf[parser->data_len] = '\0'; + } + + if ( parser->data_len >= parser->content_len ) + { + parser->state = HTTP_GET_STATE_DONE; + // parser->state = HTTP_GET_STATE_PARSE_FOOTER; + } + } + else // writing result to a file + { + if ( parser->fd == NULL ) + { + // open file for writing or appending + // (assume resuming a file transfer if given a start_byte other than 0) + if ( parser->request_start_byte > 0 ) + parser->fd = fopen(parser->data_file, "ab" ); + else + parser->fd = fopen(parser->data_file, "wb" ); + + if ( parser->fd == NULL ) // || (parser->request_start_byte > 0 && fseek(parser->fd,SEEK_END,0) != 0) ) + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_DATA_FILE_OPEN_FAILED; + return parser->error_code; + } + } + + copy_len = parser->content_len - parser->data_len; + + if ( copy_len > len ) + copy_len = len; + + ec = fwrite(data,1,copy_len,parser->fd); + if ( ec != copy_len ) + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_DATA_FILE_WRITE_FAILED; + fclose(parser->fd); + parser->fd = NULL; + return parser->error_code; + } + parser->data_len += copy_len; + if ( parser->data_len >= parser->content_len ) + { + fclose(parser->fd); + parser->fd = NULL; + parser->state = HTTP_GET_STATE_DONE; + // parser->state = HTTP_GET_STATE_PARSE_FOOTER; + } + } + } + break; + case HTTP_GET_STATE_PARSE_FOOTER: + // since footer is the last possible thing, just copy everything + // there is into the buffer + copy_len = len; + if ( parser->footer_len + copy_len > sizeof(parser->footer) - 1 ) // leave space for null terminator + { + parser->state = HTTP_GET_STATE_ERR; + parser->error_code = HTTP_GET_ERR_FOOTER_BUFFER_FULL; + return parser->error_code; + } + // copy footer data into our footer buffer + memcpy( &parser->footer[parser->footer_len], data, copy_len ); + parser->footer_len += copy_len; + parser->footer[parser->footer_len] = '\0'; // null terminate footer string + + // now look for the end of the footer + if ( parser->footer_len > 1 ) + { + + // special check, single empty line at start of footer + // means no footer + if ( parser->footer[0] == '\r' && parser->footer[1] == '\n' ) + { + found = 1; + } + else if ( parser->footer_len > 3 ) + { + pos = 3; + while ( pos < parser->footer_len ) + { + if ( parser->footer[pos-3] == '\r' && parser->footer[pos-2] == '\n' + && + parser->footer[pos-1] == '\r' && parser->footer[pos] == '\n' ) + { + found = 1; + break; + } + pos++; + } + } + } + if ( found == 1 ) + { + // all done! + parser->state = HTTP_GET_STATE_DONE; + } + break; + default: + case HTTP_GET_STATE_ERR: + case HTTP_GET_STATE_DONE: + if ( parser->fd != NULL ) + { + fclose(parser->fd); + parser->fd = NULL; + } + return parser->error_code; + break; + } + return HTTP_GET_ERR_NONE; +} + +int ResetHTTPGetParser( HTTPGetParserStruct *parser ) +{ + if ( parser == NULL ) + return -1; + + parser->chunk_encoded = 0; + parser->chunk_header_len = 0; + parser->chunk_len = 0; + parser->chunk_pos = 0; + parser->content_len = 0; + parser->content_pos = 0; + + parser->data_len = 0; + parser->footer_len = 0; + parser->header_len = 0; + + parser->error_code = 0; + parser->http_error_code = 0; + + parser->state = HTTP_GET_STATE_START; + + memset( parser->header, 0, sizeof(parser->header) ); + memset( parser->footer, 0, sizeof(parser->footer) ); + memset( parser->chunk_header, 0, sizeof(parser->chunk_header) ); + + if ( parser->fd != NULL ) + { + fclose(parser->fd); + parser->fd = NULL; + } + + return 0; +} + + + +// quickie func, makes sure sslclient code never decides we've reached +// the end of our data, instead we use our HTTPGetParser to determine that +// we've reached the end of data +int HTTPGetClientEODCheck(SSLClientStateStruct *clientstate) +{ + return -1; +} + + +int InitHTTPGetClientStruct(HTTPGetClientStruct *client, + char *server_ip, int server_port, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + char *request_document, + int request_document_start_byte, + char *recv_filename, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout, + int ssl_renegotiate_bytes, int ssl_renegotiate_seconds, + int ignore_dates_on_server_cert ) +{ + int ec; + char *send_buf; + + if( client == NULL ) + return -1; + + memset(client,0,sizeof(HTTPGetClientStruct) ); + + ec = HTTPGetParserInit( &client->parser, server_ip, server_port, + request_document, request_document_start_byte, + recv_filename, recv_buf, recv_buf_size, + null_terminate_recvd_data, close_connection_after_recv_data ); + if ( ec < 0 ) + return ec; + + send_buf = HTTPGetParserGetRequestString(&client->parser); + + ec = InitSSLClientStateStruct( &client->clientstate, server_ip, server_port, + client_kgh, client_certfile, client_keyfile, + server_certfile, cipherlist, + send_buf, strlen(send_buf), + client->recv_buf, sizeof(client->recv_buf), + null_terminate_recvd_data, HTTPGetClientEODCheck, + close_connection_after_recv_data, + connect_timeout, send_timeout, recv_timeout, + backoff_timeout, ssl_renegotiate_bytes, ssl_renegotiate_seconds, ignore_dates_on_server_cert ); + if ( ec < 0 ) + return ec; + + return 0; +} + + +int UpdateHTTPGetClientStruct(HTTPGetClientStruct *client ) +{ + int ec; + if( client == NULL ) + return -1; + + ec = UpdateSSLClientState( &client->clientstate ); + if ( ec < 0 ) + return ec; + + if ( client->clientstate.state == SSL_CLIENT_STATE_RECV_DATA ) + { + if ( client->clientstate.recv_count > 0 ) + { + // recv'd some bytes + // put them through parser + // prts_debug( "'%s'\n", client->clientstate.recv_buf ); + ec = HTTPGetParserParseRecvdData(&client->parser,client->clientstate.recv_buf,client->clientstate.recv_count); + if ( ec != HTTP_GET_ERR_NONE || client->parser.state == HTTP_GET_STATE_ERR ) + { + CloseSSLClientConnection(&client->clientstate); + client->state = HTTP_GET_CLIENT_STATE_ERR; + client->client_error = client->clientstate.error_code; + client->parser_error = client->parser.error_code; + client->http_error = client->parser.http_error_code; + return client->state; + } + + // now reset recv buffer and recv counter + memset(client->recv_buf,0,sizeof(client->recv_buf)); + client->clientstate.recv_count = 0; + + // check for end of data, + if ( client->parser.state == HTTP_GET_STATE_DONE ) + { + client->clientstate.state = SSL_CLIENT_STATE_RECV_COMPLETE; + client->clientstate.curr_state_start = time(NULL); + client->clientstate.recv_time += GetSysElapsedMicroseconds() - client->clientstate.recv_start_time; + } + else if ( client->parser.state == HTTP_GET_STATE_ERR ) + { + CloseSSLClientConnection(&client->clientstate); + client->state = HTTP_GET_CLIENT_STATE_ERR; + client->client_error = client->clientstate.error_code; + client->parser_error = client->parser.error_code; + client->http_error = client->parser.http_error_code; + return client->state; + } + } + } + + if ( client->clientstate.state == SSL_CLIENT_STATE_DONE ) + { + client->state = HTTP_GET_CLIENT_STATE_DONE; + client->client_error = client->clientstate.error_code; + client->parser_error = client->parser.error_code; + client->http_error = client->parser.http_error_code; + } + return client->state; + +} + + +int ResetHTTPGetClientStruct(HTTPGetClientStruct *client ) +{ + client->http_error = 0; + client->client_error = 0; + client->parser_error = 0; + client->state = HTTP_GET_CLIENT_STATE_NORMAL; + + // now reset recv buffer and recv counter + memset(client->recv_buf,0,sizeof(client->recv_buf)); + + ResetSSLClientStateStruct(&client->clientstate); + ResetHTTPGetParser(&client->parser); + + + return 0; +} + +int ResetHTTPGetClientStructRecvBuf(HTTPGetClientStruct *client ) +{ + + if ( client== NULL ) + return -1; + + client->parser.data_len = 0; + if ( client->parser.data_buf != NULL ) + memset( client->parser.data_buf, 0, client->parser.data_buf_size ); + + + if ( client->parser.fd != NULL ) + { + fclose(client->parser.fd); + client->parser.fd = NULL; + } + + return 0; +} + +int SetHTTPGetClientStructRequestDoc(HTTPGetClientStruct *client, char *request_document, int request_start_byte ) +{ + HTTPGetParserStruct *parser; + char *send_buf; + + if ( client== NULL ) + return -1; + + if ( request_document == NULL || request_start_byte < 0 ) + return -2; + + parser = &client->parser; + + strncpy(parser->request_document, request_document, sizeof(parser->request_document) ); + parser->request_start_byte = request_start_byte; + + send_buf = HTTPGetParserGetRequestString(parser); + + SetSSLClientStateStructSendBuf( &client->clientstate, send_buf, strlen(send_buf) ); + + return 0; +} + +int SetHTTPGetClientStructDest(HTTPGetClientStruct *client, char *dest_filename, char *dest_buf, int dest_buf_size ) +{ + HTTPGetParserStruct *parser; + + if ( client== NULL ) + return -1; + + parser = &client->parser; + + if ( dest_filename != NULL ) // if given a filename, then assume we will write reply data into that file + { + strncpy(parser->data_file, dest_filename, sizeof(parser->data_file)); + parser->null_terminate_data = 0; + parser->data_buf = NULL; + parser->data_buf_size = 0; + } + else // assume we will put reply data into dest_buf + { + strncpy(parser->data_file, "", sizeof(parser->data_file)); + parser->data_buf = dest_buf; + parser->data_buf_size = dest_buf_size; + } + + return 0; +} + + +int SetHTTPGetClientStructTimeOuts(HTTPGetClientStruct *client, int connect_timeout, int send_timeout, int recv_timeout, int backoff_timeout ) +{ + if ( client== NULL ) + return -1; + + return SetSSLClientStateStructTimeOuts( &client->clientstate, connect_timeout, send_timeout, recv_timeout, backoff_timeout ); +} + +int FreeHTTPGetClientStateStruct(HTTPGetClientStruct *client) +{ + if ( client== NULL ) + return -1; + + if ( client->parser.fd != NULL ) + { + fclose(client->parser.fd); + client->parser.fd = NULL; + } + + return FreeSSLClientStateStruct(&client->clientstate); +} + +int CloseHTTPGetClientConnection(HTTPGetClientStruct *client) +{ + if ( client== NULL ) + return -1; + + return CloseSSLClientConnection(&client->clientstate); +} diff --git a/libraries/pmrt/pmrt_ssl/sslhttpclient.h b/libraries/pmrt/pmrt_ssl/sslhttpclient.h new file mode 100755 index 0000000..0bac3d7 --- /dev/null +++ b/libraries/pmrt/pmrt_ssl/sslhttpclient.h @@ -0,0 +1,171 @@ +// sslclient.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#ifndef SSLHTTPCLIENT_H +#define SSLHTTPCLIENT_H + +#include +#include + +#include +#include "netssl.h" +#include "sslclient.h" +#include "keygenerate.h" + +#define MAX_HTTP_REQUEST_LEN 1024 +#define MAX_HTTP_HEADER_LEN 2048 +#define MAX_HTTP_RECV_FILENAME_LEN 1024 + +// use a 256k buffer when reading http get data +// this buffer can go as large or small as you like +// smaller sizes maybe a little bit slower do to more +// frequent 'process data' calls +#define HTTP_GET_BUFFER_SIZE 256000 + +typedef struct HTTPGetParserStruct +{ + int state; + char server_ip[32]; + int server_port; + + char request_document[MAX_HTTP_REQUEST_LEN]; + int request_start_byte; + char request[MAX_HTTP_REQUEST_LEN]; + + char header[MAX_HTTP_HEADER_LEN]; + int header_len; + + char data_file[MAX_HTTP_RECV_FILENAME_LEN]; + FILE *fd; + char *data_buf; + int data_buf_size; + int data_len; + + int chunk_encoded; + char chunk_header[MAX_HTTP_HEADER_LEN]; + int chunk_header_len; + int chunk_len; + int chunk_pos; + + int content_len; + int content_pos; + + char footer[MAX_HTTP_HEADER_LEN]; + int footer_len; + + int close_connection_after_recv_data; + int null_terminate_data; + + int error_code; + int http_error_code; + +} HTTPGetParserStruct; + + +enum HTTPGetStates +{ + HTTP_GET_STATE_START, + HTTP_GET_STATE_PARSING_HEADER, + HTTP_GET_STATE_PARSING_DATA, + HTTP_GET_STATE_PARSE_FOOTER, + HTTP_GET_STATE_DONE, + HTTP_GET_STATE_ERR, +}; + +enum HTTPGetErrCodes +{ + HTTP_GET_ERR_NONE, + HTTP_GET_ERR_PARSE_ERR, + HTTP_GET_ERR_HTTP_ERR, + HTTP_GET_ERR_HEADER_BUFFER_FULL, + HTTP_GET_ERR_FOOTER_BUFFER_FULL, + HTTP_GET_ERR_DATA_BUFFER_FULL, + HTTP_GET_ERR_DATA_FILE_OPEN_FAILED, + HTTP_GET_ERR_DATA_FILE_WRITE_FAILED, +}; + + +int HTTPGetParserInit( HTTPGetParserStruct *parser, + char *server_ip, int server_port, + char *request_document, int request_start_byte, + char *dest_filename, + char *dest_buf, int dest_buf_size, + int close_connection_after_recv_data, + int null_terminate_data + ); + +char *HTTPGetParserGetRequestString( HTTPGetParserStruct *parser ); +int HTTPGetParserParseRecvdData( HTTPGetParserStruct *parser, char *data, int len ); + +int ResetHTTPGetParser( HTTPGetParserStruct *parser ); + + + +typedef struct HTTPGetClientStruct +{ + + SSLClientStateStruct clientstate; + HTTPGetParserStruct parser; + char recv_buf[HTTP_GET_BUFFER_SIZE]; + int state; + int parser_error; + int http_error; + int client_error; + +} HTTPGetClientStruct; + + +enum HTTPGetClientStates +{ + HTTP_GET_CLIENT_STATE_NORMAL, + HTTP_GET_CLIENT_STATE_DONE, + HTTP_GET_CLIENT_STATE_ERR, +}; + + +int InitHTTPGetClientStruct(HTTPGetClientStruct *client, + char *server_ip, int server_port, + KeyGenHandle *client_kgh, + char *client_certfile, char *client_keyfile, + char *server_certfile, char *cipherlist, + char *request_document, + int request_document_start_byte, + char *recv_filename, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout, + int ssl_renegotiate_bytes, int ssl_renegotiate_seconds, + int ignore_dates_on_server_cert ); + + +int UpdateHTTPGetClientStruct(HTTPGetClientStruct *client ); + +int ResetHTTPGetClientStruct(HTTPGetClientStruct *client ); + +int ResetHTTPGetClientStructRecvBuf(HTTPGetClientStruct *client ); + +int SetHTTPGetClientStructRequestDoc(HTTPGetClientStruct *client, char *request_document, int request_start_byte ); +int SetHTTPGetClientStructDest(HTTPGetClientStruct *client, char *dest_filename, char *dest_buf, int dest_buf_size ); + +int SetHTTPGetClientStructTimeOuts(HTTPGetClientStruct *client, int connect_timeout, int send_timeout, + int recv_timeout, int backoff_timeout ); + +int FreeHTTPGetClientStateStruct(HTTPGetClientStruct *client); + +int CloseHTTPGetClientConnection(HTTPGetClientStruct *client); + +/* +int FreeSSLhttpClientStateStruct(SSLhttpClientStateStruct *clientstate); + +int CloseSSLhttpClientConnection(SSLhttpClientStateStruct *clientstate); +*/ + +#endif + + diff --git a/libraries/pmrt/pmrt_ssl/sslhttpclient.o b/libraries/pmrt/pmrt_ssl/sslhttpclient.o new file mode 100644 index 0000000..a0c2358 Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/sslhttpclient.o differ diff --git a/libraries/pmrt/pmrt_ssl/vssver.scc b/libraries/pmrt/pmrt_ssl/vssver.scc new file mode 100755 index 0000000..344ab3e Binary files /dev/null and b/libraries/pmrt/pmrt_ssl/vssver.scc differ diff --git a/libraries/pmrt/pmrt_utils/Debug/audcrc.obj b/libraries/pmrt/pmrt_utils/Debug/audcrc.obj new file mode 100755 index 0000000..6505620 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/audcrc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/audcrc.sbr b/libraries/pmrt/pmrt_utils/Debug/audcrc.sbr new file mode 100755 index 0000000..4b4832b Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/audcrc.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/cguardian.obj b/libraries/pmrt/pmrt_utils/Debug/cguardian.obj new file mode 100755 index 0000000..fde4479 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/cguardian.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/cguardian.sbr b/libraries/pmrt/pmrt_utils/Debug/cguardian.sbr new file mode 100755 index 0000000..decd3f4 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/cguardian.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/containerCommon.obj b/libraries/pmrt/pmrt_utils/Debug/containerCommon.obj new file mode 100755 index 0000000..2655cce Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/containerCommon.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/containerCommon.sbr b/libraries/pmrt/pmrt_utils/Debug/containerCommon.sbr new file mode 100755 index 0000000..b1fd7cc Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/containerCommon.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/containers.obj b/libraries/pmrt/pmrt_utils/Debug/containers.obj new file mode 100755 index 0000000..275c70b Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/containers.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/containers.sbr b/libraries/pmrt/pmrt_utils/Debug/containers.sbr new file mode 100755 index 0000000..446b910 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/containers.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/dnslookup.obj b/libraries/pmrt/pmrt_utils/Debug/dnslookup.obj new file mode 100755 index 0000000..f30c086 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/dnslookup.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/dnslookup.sbr b/libraries/pmrt/pmrt_utils/Debug/dnslookup.sbr new file mode 100755 index 0000000..e15466d Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/dnslookup.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/filesys.obj b/libraries/pmrt/pmrt_utils/Debug/filesys.obj new file mode 100755 index 0000000..cc96114 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/filesys.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/filesys.sbr b/libraries/pmrt/pmrt_utils/Debug/filesys.sbr new file mode 100755 index 0000000..cc529bc Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/filesys.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/icmpSock_bb.obj b/libraries/pmrt/pmrt_utils/Debug/icmpSock_bb.obj new file mode 100755 index 0000000..2d680f2 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/icmpSock_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/icmpSock_bb.sbr b/libraries/pmrt/pmrt_utils/Debug/icmpSock_bb.sbr new file mode 100755 index 0000000..18f1bf6 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/icmpSock_bb.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/icmpSock_pc.obj b/libraries/pmrt/pmrt_utils/Debug/icmpSock_pc.obj new file mode 100755 index 0000000..b4c6f4e Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/icmpSock_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/icmpSock_pc.sbr b/libraries/pmrt/pmrt_utils/Debug/icmpSock_pc.sbr new file mode 100755 index 0000000..1cd7853 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/icmpSock_pc.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/interfaceInfo.obj b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo.obj new file mode 100755 index 0000000..99a75eb Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/interfaceInfo.sbr b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo.sbr new file mode 100755 index 0000000..db57238 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_bb.obj b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_bb.obj new file mode 100755 index 0000000..a658f11 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_bb.sbr b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_bb.sbr new file mode 100755 index 0000000..e4be7e0 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_bb.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_pc.obj b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_pc.obj new file mode 100755 index 0000000..0b23274 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_pc.sbr b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_pc.sbr new file mode 100755 index 0000000..62cf5c9 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/interfaceInfo_pc.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/memallochist.obj b/libraries/pmrt/pmrt_utils/Debug/memallochist.obj new file mode 100755 index 0000000..8d3941f Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/memallochist.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/memallochist.sbr b/libraries/pmrt/pmrt_utils/Debug/memallochist.sbr new file mode 100755 index 0000000..f7d0f93 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/memallochist.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/microtime.obj b/libraries/pmrt/pmrt_utils/Debug/microtime.obj new file mode 100755 index 0000000..84c81b8 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/microtime.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/microtime.sbr b/libraries/pmrt/pmrt_utils/Debug/microtime.sbr new file mode 100755 index 0000000..1650c98 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/microtime.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/netclient.obj b/libraries/pmrt/pmrt_utils/Debug/netclient.obj new file mode 100755 index 0000000..7a17170 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/netclient.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/netclient.sbr b/libraries/pmrt/pmrt_utils/Debug/netclient.sbr new file mode 100755 index 0000000..33ef731 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/netclient.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/netsock_bb.obj b/libraries/pmrt/pmrt_utils/Debug/netsock_bb.obj new file mode 100755 index 0000000..6dd00bc Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/netsock_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/netsock_bb.sbr b/libraries/pmrt/pmrt_utils/Debug/netsock_bb.sbr new file mode 100755 index 0000000..49d7743 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/netsock_bb.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/netsock_pc.obj b/libraries/pmrt/pmrt_utils/Debug/netsock_pc.obj new file mode 100755 index 0000000..a8fe688 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/netsock_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/netsock_pc.sbr b/libraries/pmrt/pmrt_utils/Debug/netsock_pc.sbr new file mode 100755 index 0000000..bdb9a0b Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/netsock_pc.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/node.obj b/libraries/pmrt/pmrt_utils/Debug/node.obj new file mode 100755 index 0000000..753f5ab Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/node.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/node.sbr b/libraries/pmrt/pmrt_utils/Debug/node.sbr new file mode 100755 index 0000000..e836a94 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/node.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/pmrt_strings.obj b/libraries/pmrt/pmrt_utils/Debug/pmrt_strings.obj new file mode 100755 index 0000000..5bc7511 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/pmrt_strings.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/pmrt_strings.sbr b/libraries/pmrt/pmrt_utils/Debug/pmrt_strings.sbr new file mode 100755 index 0000000..c0ddced Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/pmrt_strings.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/pmrt_utils.lib b/libraries/pmrt/pmrt_utils/Debug/pmrt_utils.lib new file mode 100755 index 0000000..fce28d1 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/pmrt_utils.lib differ diff --git a/libraries/pmrt/pmrt_utils/Debug/pmrt_utils.pch b/libraries/pmrt/pmrt_utils/Debug/pmrt_utils.pch new file mode 100755 index 0000000..f0ca546 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/pmrt_utils.pch differ diff --git a/libraries/pmrt/pmrt_utils/Debug/rtdatatypes.obj b/libraries/pmrt/pmrt_utils/Debug/rtdatatypes.obj new file mode 100755 index 0000000..2ef736c Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/rtdatatypes.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/rtdatatypes.sbr b/libraries/pmrt/pmrt_utils/Debug/rtdatatypes.sbr new file mode 100755 index 0000000..77ed890 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/rtdatatypes.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/textfile.obj b/libraries/pmrt/pmrt_utils/Debug/textfile.obj new file mode 100755 index 0000000..7d91bef Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/textfile.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/textfile.sbr b/libraries/pmrt/pmrt_utils/Debug/textfile.sbr new file mode 100755 index 0000000..d77bf97 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/textfile.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/textfiles.obj b/libraries/pmrt/pmrt_utils/Debug/textfiles.obj new file mode 100755 index 0000000..745965d Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/textfiles.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/thread_bb.obj b/libraries/pmrt/pmrt_utils/Debug/thread_bb.obj new file mode 100755 index 0000000..f043b2c Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/thread_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/thread_bb.sbr b/libraries/pmrt/pmrt_utils/Debug/thread_bb.sbr new file mode 100755 index 0000000..bdbbcb5 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/thread_bb.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/thread_pc.obj b/libraries/pmrt/pmrt_utils/Debug/thread_pc.obj new file mode 100755 index 0000000..435f3b7 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/thread_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/thread_pc.sbr b/libraries/pmrt/pmrt_utils/Debug/thread_pc.sbr new file mode 100755 index 0000000..52b582f Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/thread_pc.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/tsqueue.obj b/libraries/pmrt/pmrt_utils/Debug/tsqueue.obj new file mode 100755 index 0000000..8e5f29f Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/tsqueue.obj differ diff --git a/libraries/pmrt/pmrt_utils/Debug/tsqueue.sbr b/libraries/pmrt/pmrt_utils/Debug/tsqueue.sbr new file mode 100755 index 0000000..2e2cbf8 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/tsqueue.sbr differ diff --git a/libraries/pmrt/pmrt_utils/Debug/vc60.idb b/libraries/pmrt/pmrt_utils/Debug/vc60.idb new file mode 100755 index 0000000..d598bd1 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/vc60.idb differ diff --git a/libraries/pmrt/pmrt_utils/Debug/vc60.pdb b/libraries/pmrt/pmrt_utils/Debug/vc60.pdb new file mode 100755 index 0000000..a141274 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Debug/vc60.pdb differ diff --git a/libraries/pmrt/pmrt_utils/Release/audcrc.obj b/libraries/pmrt/pmrt_utils/Release/audcrc.obj new file mode 100755 index 0000000..63fc343 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/audcrc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/containerCommon.obj b/libraries/pmrt/pmrt_utils/Release/containerCommon.obj new file mode 100755 index 0000000..221c04f Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/containerCommon.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/containers.obj b/libraries/pmrt/pmrt_utils/Release/containers.obj new file mode 100755 index 0000000..4fa1589 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/containers.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/icmpSock_bb.obj b/libraries/pmrt/pmrt_utils/Release/icmpSock_bb.obj new file mode 100755 index 0000000..c99d446 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/icmpSock_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/icmpSock_pc.obj b/libraries/pmrt/pmrt_utils/Release/icmpSock_pc.obj new file mode 100755 index 0000000..efb7643 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/icmpSock_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/interfaceInfo.obj b/libraries/pmrt/pmrt_utils/Release/interfaceInfo.obj new file mode 100755 index 0000000..3118acf Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/interfaceInfo.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/interfaceInfo_bb.obj b/libraries/pmrt/pmrt_utils/Release/interfaceInfo_bb.obj new file mode 100755 index 0000000..9542bea Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/interfaceInfo_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/interfaceInfo_pc.obj b/libraries/pmrt/pmrt_utils/Release/interfaceInfo_pc.obj new file mode 100755 index 0000000..e17e682 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/interfaceInfo_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/memallochist.obj b/libraries/pmrt/pmrt_utils/Release/memallochist.obj new file mode 100755 index 0000000..07e9b1c Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/memallochist.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/netsock_bb.obj b/libraries/pmrt/pmrt_utils/Release/netsock_bb.obj new file mode 100755 index 0000000..b0f60c2 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/netsock_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/netsock_pc.obj b/libraries/pmrt/pmrt_utils/Release/netsock_pc.obj new file mode 100755 index 0000000..852ffc6 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/netsock_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/node.obj b/libraries/pmrt/pmrt_utils/Release/node.obj new file mode 100755 index 0000000..c0eb0d0 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/node.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/pmrt_strings.obj b/libraries/pmrt/pmrt_utils/Release/pmrt_strings.obj new file mode 100755 index 0000000..dd5aa9e Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/pmrt_strings.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/pmrt_utils.pch b/libraries/pmrt/pmrt_utils/Release/pmrt_utils.pch new file mode 100755 index 0000000..37c377f Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/pmrt_utils.pch differ diff --git a/libraries/pmrt/pmrt_utils/Release/textfile.obj b/libraries/pmrt/pmrt_utils/Release/textfile.obj new file mode 100755 index 0000000..794932e Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/textfile.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/thread_bb.obj b/libraries/pmrt/pmrt_utils/Release/thread_bb.obj new file mode 100755 index 0000000..5f7c85c Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/thread_bb.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/thread_pc.obj b/libraries/pmrt/pmrt_utils/Release/thread_pc.obj new file mode 100755 index 0000000..83096b6 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/thread_pc.obj differ diff --git a/libraries/pmrt/pmrt_utils/Release/vc60.idb b/libraries/pmrt/pmrt_utils/Release/vc60.idb new file mode 100755 index 0000000..628af5f Binary files /dev/null and b/libraries/pmrt/pmrt_utils/Release/vc60.idb differ diff --git a/libraries/pmrt/pmrt_utils/audcrc.c b/libraries/pmrt/pmrt_utils/audcrc.c new file mode 100755 index 0000000..e69dc7c --- /dev/null +++ b/libraries/pmrt/pmrt_utils/audcrc.c @@ -0,0 +1,167 @@ +// +// audcrc.c +// PM proprietary crc generator +// do not release this source code outside of Play Mechanix +// +// Play Mechanix - Video Game System +// +// Copyright (c) 1998-2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 21 Mar 07 +// + +// include files +#include "audcrc.h" +#include +#include +#include + +// CRC checksum calculation table +unsigned long CRC32Tab[256] = +{ + 0x00000000,0x77073096,0xee0e612c,0x990951ba,0x076dc419, + 0x706af48f,0xe963a535,0x9e6495a3,0x0edb8832,0x79dcb8a4, + 0xe0d5e91e,0x97d2d988,0x09b64c2b,0x7eb17cbd,0xe7b82d07, + 0x90bf1d91,0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de, + 0x1adad47d,0x6ddde4eb,0xf4d4b551,0x83d385c7,0x136c9856, + 0x646ba8c0,0xfd62f97a,0x8a65c9ec,0x14015c4f,0x63066cd9, + 0xfa0f3d63,0x8d080df5,0x3b6e20c8,0x4c69105e,0xd56041e4, + 0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b, + 0x35b5a8fa,0x42b2986c,0xdbbbc9d6,0xacbcf940,0x32d86ce3, + 0x45df5c75,0xdcd60dcf,0xabd13d59,0x26d930ac,0x51de003a, + 0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599, + 0xb8bda50f,0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924, + 0x2f6f7c87,0x58684c11,0xc1611dab,0xb6662d3d,0x76dc4190, + 0x01db7106,0x98d220bc,0xefd5102a,0x71b18589,0x06b6b51f, + 0x9fbfe4a5,0xe8b8d433,0x7807c9a2,0x0f00f934,0x9609a88e, + 0xe10e9818,0x7f6a0dbb,0x086d3d2d,0x91646c97,0xe6635c01, + 0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,0x6c0695ed, + 0x1b01a57b,0x8208f4c1,0xf50fc457,0x65b0d9c6,0x12b7e950, + 0x8bbeb8ea,0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3, + 0xfbd44c65,0x4db26158,0x3ab551ce,0xa3bc0074,0xd4bb30e2, + 0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,0x4369e96a, + 0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5, + 0xaa0a4c5f,0xdd0d7cc9,0x5005713c,0x270241aa,0xbe0b1010, + 0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,0xce61e49f, + 0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17, + 0x2eb40d81,0xb7bd5c3b,0xc0ba6cad,0xedb88320,0x9abfb3b6, + 0x03b6e20c,0x74b1d29a,0xead54739,0x9dd277af,0x04db2615, + 0x73dc1683,0xe3630b12,0x94643b84,0x0d6d6a3e,0x7a6a5aa8, + 0xe40ecf0b,0x9309ff9d,0x0a00ae27,0x7d079eb1,0xf00f9344, + 0x8708a3d2,0x1e01f268,0x6906c2fe,0xf762575d,0x806567cb, + 0x196c3671,0x6e6b06e7,0xfed41b76,0x89d32be0,0x10da7a5a, + 0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5, + 0xd6d6a3e8,0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1, + 0xa6bc5767,0x3fb506dd,0x48b2364b,0xd80d2bda,0xaf0a1b4c, + 0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef, + 0x4669be79,0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236, + 0xcc0c7795,0xbb0b4703,0x220216b9,0x5505262f,0xc5ba3bbe, + 0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,0xb5d0cf31, + 0x2cd99e8b,0x5bdeae1d,0x9b64c2b0,0xec63f226,0x756aa39c, + 0x026d930a,0x9c0906a9,0xeb0e363f,0x72076785,0x05005713, + 0x95bf4a82,0xe2b87a14,0x7bb12bae,0x0cb61b38,0x92d28e9b, + 0xe5d5be0d,0x7cdcefb7,0x0bdbdf21,0x86d3d2d4,0xf1d4e242, + 0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1, + 0x18b74777,0x88085ae6,0xff0f6a70,0x66063bca,0x11010b5c, + 0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,0xa00ae278, + 0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7, + 0x4969474d,0x3e6e77db,0xaed16a4a,0xd9d65adc,0x40df0b66, + 0x37d83bf0,0xa9bcae53,0xdebb9ec5,0x47b2cf7f,0x30b5ffe9, + 0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605, + 0xcdd70693,0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8, + 0x5d681b02,0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b, + 0x2d02ef8d +}; + +// +// AudCRC32 +// generate a 32bit CRC checksum of an array of memory +// +// in: +// out: +// global: +// +// GNP 09 Oct 00 +// +unsigned long AudCRC32(unsigned char *data, int len) +{ + register int i; + register unsigned long crc; + + crc = 0xFFFFFFFF; + for(i = 0; i < len; i++) + { + crc = ((crc>>8) & 0x00FFFFFF) ^ CRC32Tab[ (crc^*data) & 0xFF ]; + data++; + } +//DONE("AudCRC") + return( crc^0xFFFFFFFF ); +} // AudCRC + + + +// these functions operate on a RollingCRC32Handle +// general idea is mimic results of AudCRC but allow +// one to incrementally CRC data instead of having +// to CRC all the data at once, useful for calculating +// CRC of large files since you don't have to load the +// entire file int memory, instead you can just load n bytes at a time +// see AudCRCFile() for example of this... +int AudInitRollingCRC32( RollingCRC32Handle *rcrc ) +{ + if ( rcrc == NULL ) + return -1; + + rcrc->count = 0; + rcrc->crc = 0xFFFFFFFF; + return 0; +} + +int AudAddToRollingCRC32( RollingCRC32Handle *rcrc, unsigned char *data, int len) +{ + int i; + for(i = 0; i < len; i++) + { + rcrc->crc = ((rcrc->crc>>8) & 0x00FFFFFF) ^ CRC32Tab[ (rcrc->crc^*data) & 0xFF ]; + data++; + rcrc->count++; + } + return 0; +} + +// notice that this does not change the value stored in rcrc->crc +// so you can still add more data to the CRC you'll just need to call +// AudCalcRollingCRC32() again to get the new CRC +unsigned long AudCalcRollingCRC32( RollingCRC32Handle *rcrc ) +{ + if ( rcrc == NULL ) + return 0; + return ( rcrc->crc^0xFFFFFFFF ); +} + +// generates a 32 bit CRC for the passed file +unsigned long AudCRC32File( char *filename ) +{ + FILE *fd; + int len; + unsigned char data[256]; + RollingCRC32Handle rcrc; + AudInitRollingCRC32(&rcrc); + + + fd = fopen( filename, "rb" ); + if ( fd == NULL ) + return 0; + + while ( (len = fread(data, 1, sizeof(data), fd )) != 0 ) + { + AudAddToRollingCRC32( &rcrc, data, len ); + } + fclose(fd); + + return AudCalcRollingCRC32(&rcrc); + + +} + +// EOF diff --git a/libraries/pmrt/pmrt_utils/audcrc.h b/libraries/pmrt/pmrt_utils/audcrc.h new file mode 100755 index 0000000..b4499aa --- /dev/null +++ b/libraries/pmrt/pmrt_utils/audcrc.h @@ -0,0 +1,47 @@ +// +// audcrc.h +// PM crc generator header +// +// Play Mechanix - Video Game System +// +// Copyright (c) 1998-2007 Play Mechanix Inc. All Rights Reserved +// +// GNP 21 Mar 07 +// +#ifndef AUDCRC_H +#define AUDCRC_H + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned long AudCRC32(unsigned char *data, int len); + +#ifdef __cplusplus +} +#endif + +typedef struct +{ + unsigned int count; + unsigned long crc; +} RollingCRC32Handle; + +// these functions operate on a RollingCRCHandle +// general idea is mimic results of AudCRC but allow +// one to incrementally CRC data instead of having +// to CRC all the data at once, useful for calculating +// CRC of large files since you don't have to load the +// entire file int memory, instead you can just load n bytes at a time +// see AudCRCFile() for example of this... + +int AudInitRollingCRC32( RollingCRC32Handle *rcrc ); +int AudAddToRollingCRC32( RollingCRC32Handle *rcrc, unsigned char *data, int len); +unsigned long AudCalcRollingCRC32( RollingCRC32Handle *rcrc ); +unsigned long AudCRC32File(char *filename ); + + + +#endif // ndef AUDCRC_H +//EOF + diff --git a/libraries/pmrt/pmrt_utils/audcrc.o b/libraries/pmrt/pmrt_utils/audcrc.o new file mode 100644 index 0000000..956a388 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/audcrc.o differ diff --git a/libraries/pmrt/pmrt_utils/cguardian.c b/libraries/pmrt/pmrt_utils/cguardian.c new file mode 100755 index 0000000..b784687 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/cguardian.c @@ -0,0 +1,479 @@ +// cguardian.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for guarding code against attackers + +#include "cguardian.h" +#include "thread.h" +#include "filesys.h" + +#include +#include +#include +#include +#include + +#ifdef SYS_BB +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define _GNU_SOURCE +#define __USE_GNU +#include +#undef __USE_GNU +#undef _GNU_SOURCE +#endif + + + + +// note: USE prts_debug() instead of PrintDebug directly +// there is magic in header to make +// prts_debug hide strings in prod builds +void PrintDebug(char* format,...) +{ + va_list args; + va_start(args,format); + vprintf(format,args); +#if SYS_BB + // flush stdout buffer + fflush(stdout); +#endif // SYS_BB + +} + + +int gChildPid; +int gParentPid; + +// this function only works under Unix +// idea is this, ptrace is the mechanism debuggers use to +// hook into a running process, a program can only be 'ptraced' +// by one process at a time, so we spawn a child and have it try to +// ptrace to us, if that call fails we know someone else is +// already tracing us! +int CheckForDebugger() +{ +#ifdef SYS_BB + + int ec,status; + pid_t child_pid,parent_pid; + + parent_pid = getpid(); + + // printf("Attempting fork\n"); + + child_pid = 0; + child_pid = fork(); + if (! child_pid ) + { + // printf("Child Spawned\n"); + // CHILD + ec = ptrace(PT_ATTACH,parent_pid,0,0); + if ( ec != 0 ) + exit(1); // ptrace attach failed! someone else is ptracing us! + + // printf("Child attached to parent\n"); + + do + { + ec = waitpid(parent_pid,&status,0); + } while(ec == -1 && errno == EINTR ); + + // printf("Child detaching from parent\n"); + + ec = ptrace(PT_DETACH,parent_pid,(caddr_t)1,SIGCONT); + exit(0); + } + + + // Parent + if ( child_pid < 0 ) + return -1; // fork failed :( + + do + { + ec = waitpid(child_pid,&status,0); + } while(ec == -1 && errno == EINTR ); + + + status=WEXITSTATUS(status); + // printf("Parent got back child status of %d\n", status); + + // child found an active a ptrace! + if ( status == 1 ) + return 1; + +#endif + return 0; +} + + +// again only works under unix, this guy is variant of the above +// what he does it to start a child and attach to it +// child then continues to run the program while parent just +// hangs around, staying attached to child to prevent a debugger +// from attaching to child +// child kills itself on SIGHUP (parent died) +// parent kills itself on SIGCHLD (child died) +// parent otherwise forwards all signals to child +// child may verify that parent is still around with a call to CheckDebugGuard() +// this is important as the child will not get a SIGHUP +// when the parent dies if it is run with nohup +void ExitOnSig(int sig) +{ +#ifdef SYS_BB + exit(-1); +#endif +} + +int StartDebugGuard() +{ +#ifdef SYS_BB + int ec,status,quit; + + gParentPid = getpid(); + + prts_debug("Attempting fork\n"); + + gChildPid = 0; + gChildPid = fork(); + if (! gChildPid ) + { + // install exit on sig hup handler + signal(SIGHUP,ExitOnSig); + + // CHILD + ec = ptrace(PTRACE_TRACEME,gParentPid,0,0); + + prts_debug( "Child trace me returned %d\n", ec ); + + if ( ec != 0 ) + exit(-1); // ptrace failed! die and signal parent that things went wrongo + else + return 1; // return success and continue normal program execution as child + } + + + // Parent + if ( gChildPid < 0 ) + return -1; // fork failed :( + +#ifdef DEBUG + prts_debug( "Parent is %d, Child is %d\n", gParentPid, gChildPid ); +#endif + + quit = 0; + while(!quit) + { + + /* + // printf( "Parent looping on wait pid\n" ); + // wait for a signal to come in + do + { + ec = waitpid(gChildPid,&status,0); + if ( ec == -1 && errno == ECHILD ) + exit(-1); // child is dead or not ours, either way, die + } while(ec == -1 && errno == EINTR ); + */ + + ThreadSleep(10); + + // check to see if someone is running the debugger on parent + if ( CheckForDebugger() ) + { + // tell child to die + kill(gChildPid,SIGKILL); + // die ourselves + exit(-1); + } + // check for signal to come in + ec = waitpid(gChildPid,&status,WNOHANG); + if ( ec == -1 && errno == ECHILD ) + exit(-1); // child is dead or not ours, either way, die + + if ( ec > 0 ) + { + prts_debug( "Parent got %d from wait pid\n", status ); + + if ( WIFEXITED(status) ) // child exited + { + status=WEXITSTATUS(status); + prts_debug( "Parent got child exit with %d \n", status); + exit(status); // forward on child's exit code + } + + if ( WIFSIGNALED(status) ) // child died on failure to handle a signal + { + prts_debug( "Parent got child died from unhandled signal \n"); + exit(-1); // would use WTERMSIG(status) to get the offending signal if you are curious + } + + // check if child got a signal (this stop child, see ptrace man page) + if ( WIFSTOPPED(status) ) + { + // get the signal that was sent to the child + ec = WSTOPSIG(status); + + prts_debug( "Parent got sig %d for child\n", ec); + + // tell child to continue, forwarding signal along + ec = ptrace(PTRACE_CONT, gChildPid, 0, ec ); + prts_debug( "ptrace returned %d\n", ec); + continue; + } + + prts_debug( "Something else happened (ec = %d)\n", ec); + exit(-1); // something else happened, die to be safe + } + } + + +#endif + // printf( "Parent returning to main\n"); + + return 0; +} + + + + +// GetProcessStatus() +// linux only, copies the 'Status:' line of /proc/pid/status into dst +// returns 0 on success +// returns -1 if process is not found/running +int GetProcessStatus(int pid, char *dst, int dst_len) +{ +#ifdef SYS_PC + return -1; +#endif + +#ifdef SYS_BB + char buffer[64]; + + memset(dst,0,dst_len); + + // check if parent is still allive + if ( kill(pid,0) != 0 ) + { + //printf( "Parent pid (%d) not running!\n", gParentPid ); + return -1; + } + + snprintf(buffer, sizeof(buffer), "/proc/%u/status", gParentPid ); + + //check if the state is valid + return FindLineInTextFileByStartString(buffer, dst, dst_len, "State:", 1, 1); + // available states from src/linux/fs/proc/array.c +// "R (running)", /* 0 */ +// "S (sleeping)", /* 1 */ +// "D (disk sleep)", /* 2 */ +// "T (stopped)", /* 4 */ +// "T (tracing stop)", /* 8 */ +// "Z (zombie)", /* 16 */ +// "X (dead)" /* 32 */ + // stopped, zombie and dead are the bad ones for us + + +#endif + +} + +// child should run this function frequently after +// calling StartDebugGuard() to check if the guard is still active +// returns 1 if DebugGuard is still up and running, <0 otherwise (consider just dying) +int CheckDebugGuard() +{ +#ifdef SYS_BB + int pid; + char buffer[512]; + char outBuffer[128]; + + memset( buffer, 0, sizeof(buffer) ); + memset( outBuffer, 0, sizeof(outBuffer) ); + // check if parent is still allive + if ( kill(gParentPid,0) != 0 ) + { + //printf( "Parent pid (%d) not running!\n", gParentPid ); + return -1; + } + + snprintf(buffer, sizeof(buffer), "/proc/%u/status", gParentPid ); + + //check if the state is valid + FindLineInTextFileByStartString(buffer, outBuffer, sizeof(outBuffer), "State:", 1, 1); + + // available states from src/linux/fs/proc/array.c +// "R (running)", /* 0 */ +// "S (sleeping)", /* 1 */ +// "D (disk sleep)", /* 2 */ +// "T (stopped)", /* 4 */ +// "T (tracing stop)", /* 8 */ +// "Z (zombie)", /* 16 */ +// "X (dead)" /* 32 */ + // stopped, zombie and dead are the bad ones for us + + // printf( "Looking for Status: line in '%s', got '%s'\n", buffer, outBuffer ); + if( !strstr(outBuffer, "running") + && !strstr(outBuffer, "sleeping") + && !strstr(outBuffer, "tracing stop") + && !strstr(outBuffer, "disk sleep") + ) + { + //printf( "Looking for Status: line in '%s', got '%s'\n", buffer, outBuffer ); + + //printf( "parent pid not running or sleeping\n" ); + return -2; + } + + // check if it's still our parent + pid = getppid(); + if ( pid != gParentPid ) + { + //printf( "parent pid changed!\n" ); + return -3; + } + else + return 1; + +#endif + return 1; +} + +// another function that only works under Unix +// basically we just set the limit on the size of a core file to 0 +// this overrides value set by ulimit +int DisableCoreDump() +{ +#ifdef SYS_BB + struct rlimit r; + + r.rlim_cur = 0; + r.rlim_max = 0; + + setrlimit(RLIMIT_CORE, &r); +#endif + return 0; +} + + +// Yet another linux only function +// this one walks the shared libraries used +// by program and calls CheckCallback() on each one +// CheckCallback() should return 0 if lib is determined to be ok +// or -1 if lib fails check +// +static int dl_phdr_callback(struct dl_phdr_info *info, size_t size, void *data) +{ +#ifdef SYS_BB +// int j = 0; + int (*Callback)(char *); + Callback = (int (*)(char *)) data; + +/* + printf("name=%s (%d segments)\n", info->dlpi_name, + info->dlpi_phnum); + + for (j = 0; j < info->dlpi_phnum; j++) + printf("\t\t header %2d: address=%10p\n", j, + (void *) (info->dlpi_addr + info->dlpi_phdr[j].p_vaddr)); +*/ + return Callback( (char *)info->dlpi_name ); + +#endif + return 0; +} + +int CheckSharedLibs( int (*CheckCallback)(char *) ) +{ + int ec = 0; +#ifdef SYS_BB + ec = dl_iterate_phdr( dl_phdr_callback, (void *)CheckCallback ); +#endif + return ec; +} + + + +// Yet another linux only function +// this one returns the start of the code stack for a given +// executable, all static ptrs (like function ptrs) in executable +// can be found in file at entry point + address + +#if SYS_BB +// defines for where stuff is in the standard elf header +#define ELF_ENTRY_OFFSET 24 +#define ELF_PHOFF_OFFSET 28 +#define ELF_PHESZ_OFFSET 42 +#define ELF_PHNUM_OFFSET 44 +#define ELF_PH_OFFSET_OFF 4 +#define ELF_PH_VADDR_OFF 8 +#define ELF_PH_FILESZ_OFF 16 + +static unsigned long elf_get_entry(unsigned char *buf) +{ + unsigned long entry, p_vaddr, p_filesz, p_offset; + unsigned int i, phoff; + unsigned short phnum, phsz; + unsigned char *phdr; + + + entry = *(unsigned long *) &buf[ELF_ENTRY_OFFSET]; + phoff = *(unsigned int *) &buf[ELF_PHOFF_OFFSET]; + phnum = *(unsigned short *) &buf[ELF_PHNUM_OFFSET]; + phsz = *(unsigned short *) &buf[ELF_PHESZ_OFFSET]; + + phdr = &buf[phoff]; + + /* walk headers */ + for ( i = 0; i < phnum; i++, phdr += phsz ) + { + p_vaddr = *(unsigned long *)&phdr[ELF_PH_VADDR_OFF]; + p_filesz = *(unsigned long *)&phdr[ELF_PH_FILESZ_OFF]; + if ( entry >= p_vaddr && entry < p_vaddr + p_filesz ) + { + // calc offset + p_offset = *(unsigned long *)&phdr[ELF_PH_OFFSET_OFF]; + return p_offset + (entry - p_vaddr); + } + } + return 0; +} +#endif //SYS_BB + +void *GetCodeEntryPoint(char *filename) +{ +#if SYS_PC + return NULL; +#endif + +#ifdef SYS_BB + int ec; + char *buf; + int buf_size; + unsigned long EntryPoint; + + buf = NULL; + buf_size = 0; + ec = FsLoadFile( filename, (void*) &buf, &buf_size, malloc, free ); + if ( ec != FS_ERR_NONE ) + return NULL; + + EntryPoint = elf_get_entry( buf ); + // printf( "Entry Point is 0x%X\n", EntryPoint ); + free(buf); + return (void *)EntryPoint; +#endif +} + +//EOF + + diff --git a/libraries/pmrt/pmrt_utils/cguardian.h b/libraries/pmrt/pmrt_utils/cguardian.h new file mode 100755 index 0000000..264344a --- /dev/null +++ b/libraries/pmrt/pmrt_utils/cguardian.h @@ -0,0 +1,67 @@ +// cguardian.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for guarding code against attackers +#ifndef CGUARD_H +#define CGUARD_H + + +// this bit of magic removes dbg strings from production code +// if you call prts_debug() to print them +#if SYS_BB + #if PRODUCTION + // replace calls to prts_dbg with null op, eating string along the way + #define prts_debug(...) + #else + #define prts_debug PrintDebug + #endif // PRODUCTION +#endif // SYS_BB +#if SYS_PC // VisStudio < VisStudio 2005 does not support variodic macros + #define prts_debug PrintDebug +#endif +void PrintDebug(char* format,...); + + +// Debugger Guard + +int CheckForDebugger(); + +int StartDebugGuard(); +int CheckDebugGuard(); + + +int DisableCoreDump(); + + +int CheckSharedLibs( int (*CheckCallback)(char *) ); + + +#define CGUARD_DECLARE_CODE_BLOCK(label) extern void CG_Code_Block_##label(); extern void _CG_Code_Block_##label(); +#define CGUARD_START_CODE_BLOCK(label) void CG_Code_Block_##label() {} +#define CGUARD_END_CODE_BLOCK(label) void _CG_Code_Block_##label() {} +#define CGUARD_CODE_BLOCK_LEN(label) (int) _CG_Code_Block_##label - (int) CG_Code_Block_##label +#define CGUARD_CODE_BLOCK_ADDR(label) (unsigned char *) CG_Code_Block_##label +#define CGUARD_CODE_BLOCK_OFFSET(label) (long) CG_Code_Block_##label - (long)_start + +#define CGUARD_DATA_BLOCK_ADDR &__data_start +#define CGUARD_DATA_BLOCK_OFFSET (long) &__data_start - (long)_start +#define CGUARD_DATA_BLOCK_LEN (long)&__bss_start - (long) &__data_start + +#define CGUARD_GLOBAL_VAR_ADDR(global_variable) &##global_variable +#define CGUARD_GLOBAL_VAR_LEN(global_variable) sizeof(##global_variable) +#define CGUARD_GLOBAL_VAR_OFFSET(global_variable) (long) ##global_variable - (long)_start + + +extern void _start(void); // true starting point of program +extern unsigned char *__data_start; +extern unsigned char *__bss_start; +extern unsigned char *_end; + + +void *GetCodeEntryPoint(char *filename); + +#endif + + + diff --git a/libraries/pmrt/pmrt_utils/cguardian.o b/libraries/pmrt/pmrt_utils/cguardian.o new file mode 100644 index 0000000..358e960 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/cguardian.o differ diff --git a/libraries/pmrt/pmrt_utils/containerCommon.c b/libraries/pmrt/pmrt_utils/containerCommon.c new file mode 100755 index 0000000..42f53ee --- /dev/null +++ b/libraries/pmrt/pmrt_utils/containerCommon.c @@ -0,0 +1,75 @@ +// containerCommon.c +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +#include "containerCommon.h" +#include +#include +#include +#ifdef SYS_PC +#include +#endif + +void* (*CustomMalloc)(size_t) = &malloc; +void (*CustomFree) (void *) = &free; + +/*! + \brief Change the default allocation/deallocation functions. Default are malloc/free. + Malloc function should return NULL on failure + \author RA + \date 2007/11/21 + \param CustomMallocFunc Function used to allocate memory + \param CustomFreeFunc Function used to free memory +*/ +void ContainersSetMemoryFuncs( void* (*CustomMallocFunc)(size_t size), void (*CustomFreeFunc)(void *) ) +{ + CustomMalloc = CustomMallocFunc; + CustomFree = CustomFreeFunc; +} + +//assumes null terminated source +int CopyStrings(char **dest, const char *source) +{ + const size_t sourceLength = strlen(source); + *dest = (char*)CustomMalloc((sourceLength+1)*sizeof(char)); + if(!dest) + { + DebugOutput("Unable to allocate memory for string"); + return 0; + } + memset(*dest, 0, (sourceLength+1)*sizeof(char)); + memcpy(*dest, source, sourceLength*sizeof(char)); + + return 1; +} + +void DebugOutput(const char *string) +{ + if(!string || !strlen(string)) + return; + +#ifdef _DEBUG + #ifdef SYS_PC + OutputDebugString(string); + #else + printf("%s \n", string); + #endif +#endif +} + +//user is expected to free inDest +void StringConcat(char **inDest, const char *src1, const char *src2) +{ + unsigned int length1 = strlen(src1); + unsigned int length2 = strlen(src2); + + char *dest = CustomMalloc( sizeof(char)*(length1 + length2 + 1) ); + + memcpy(dest , src1, length1); + memcpy(dest + length1, src2, length2); + dest[length1 + length2] = 0; + + *inDest = dest; +} diff --git a/libraries/pmrt/pmrt_utils/containerCommon.h b/libraries/pmrt/pmrt_utils/containerCommon.h new file mode 100755 index 0000000..1c0593b --- /dev/null +++ b/libraries/pmrt/pmrt_utils/containerCommon.h @@ -0,0 +1,24 @@ +// containerCommon.h +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +#ifndef _COMMON +#define _COMMON + +int CopyStrings(char **dest, const char *source); +void DebugOutput(const char *string); + +//will enlarge the destination buffer and copy source over +void StringConcat(char **dest, const char *src1, const char *src2); + +extern void* (*CustomMalloc)(size_t); +extern void (*CustomFree) (void *); + +#endif + + + + + diff --git a/libraries/pmrt/pmrt_utils/containerCommon.o b/libraries/pmrt/pmrt_utils/containerCommon.o new file mode 100644 index 0000000..7326761 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/containerCommon.o differ diff --git a/libraries/pmrt/pmrt_utils/containers.c b/libraries/pmrt/pmrt_utils/containers.c new file mode 100755 index 0000000..8503644 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/containers.c @@ -0,0 +1,573 @@ +// containers.c +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +#include "containers.h" +#include "containerCommon.h" +#include +#include +#include "node.h" + + +//******************************************************************* +//**************************List Functions*************************** +//******************************************************************* +void ListCreate(List *list) +{ + list->head = list->tail = NULL; + list->numNodes = 0; +} + +ListNode *ListPushFront(List *list, void *data, size_t dataSize) +{ + ListNode *newNode = CustomMalloc(sizeof(ListNode)); + if(!newNode) + return NULL; + + newNode->next = newNode->prev = NULL; + newNode->dataSize = dataSize; + + if(dataSize) + { + newNode->data = CustomMalloc(dataSize); + if(!newNode->data) + { + CustomFree(newNode); + return NULL; + } + if ( data != NULL ) + memcpy(newNode->data, data, dataSize); + else + memset(newNode->data, 0, dataSize); + } + else + newNode->data = data; + + if(!list->head) + list->head = list->tail = newNode; + else + { + newNode->next = list->head; + list->head->prev = newNode; + list->head = newNode; + } + + list->numNodes++; + + return newNode; +} + +ListNode *ListPushBack(List *list, void *data, size_t dataSize) +{ + ListNode *newNode = CustomMalloc(sizeof(ListNode)); + if(!newNode) + return NULL; + + newNode->next = newNode->prev = NULL; + newNode->dataSize = dataSize; + + if(dataSize) + { + newNode->data = CustomMalloc(dataSize); + if(!newNode->data) + { + CustomFree(newNode); + return NULL; + } + if ( data != NULL ) + memcpy(newNode->data, data, dataSize); + else + memset(newNode->data, 0, dataSize); + } + else + newNode->data = data; + + if(!list->head) + list->head = list->tail = newNode; + else + { + list->tail->next = newNode; + newNode->prev = list->tail; + list->tail = newNode; + } + + list->numNodes++; + + return newNode; +} + +ListNode *ListPopFront(List *list) +{ + ListNode *popNode = list->head; + + if(!list->head) + return NULL; + + ListPop(list, popNode); + + return popNode; +} + +ListNode *ListPopBack(List *list) +{ + ListNode *popNode = list->tail; + + if(!list->tail) + return NULL; + + ListPop(list, popNode); + + return popNode; +} +void ListPop(List *list, ListNode *pop) +{ + if(!pop) + return; + + if(pop->prev) + pop->prev->next = pop->next; + if(pop->next) + pop->next->prev = pop->prev; + + if(list->head == pop) + list->head = pop->next; + if(list->tail == pop) + list->tail = pop->prev; + + if(list->numNodes) + list->numNodes--; +} + + +/*! + \brief Takes a node from the list and moves it before another node on the list + \author RA + \date 2007/11/07 + \param list list to be modified + \param node node to be moved + \param nextNode node the other node will be inserted before +*/ +void ListInsertBefore(List *list, ListNode *node, ListNode *nextNode) +{ + ListNode *tmpNode = NULL; + + if(!list || !node || !nextNode) + return; + + if(node->next == nextNode || node == nextNode) + return; + + if(list->head == node) + list->head = node->next; + if(list->tail == node) + list->tail = node->prev; + + if(node->prev) + node->prev->next = node->next; + if(node->next) + node->next->prev = node->prev; + + if(nextNode->prev) + nextNode->prev->next = node; + else + list->head = node; + + tmpNode = nextNode->prev; + nextNode->prev = node; + node->next = nextNode; + node->prev = tmpNode; + +} + +void ListFree(List *list) +{ + while(list->head) + { + ListNode *delNode = list->head; + list->head = list->head->next; + + if(delNode->dataSize) + CustomFree(delNode->data); + CustomFree(delNode); + } + + list->head = list->tail = NULL; + list->numNodes = 0; +} + +//remove a node by its data pointer +ListNode *ListRemove(List *list, void *data) +{ + ListNode *node = list->head; + while(node) + { + if(node->data == data) + { + ListPop(list, node); + return node; + } + node = node->next; + } + + return NULL; +} + +//free a single node +void ListFreeNode(ListNode *node) +{ + if(node->dataSize) + CustomFree(node->data); + CustomFree(node); +} + + +int ListWalk(List *list, int (*OpFunc)(ListNode *, void *), void *data ) +{ + int ec,count; + ListNode *node; + ListNode *next; + + if(!list || !OpFunc ) + return -1; + + count = 0; + node = list->head; + while(node) + { + next = node->next; + ec = OpFunc( node, data ); + if ( ec < 0 ) + break; + count++; + node = next; + } + + return count; +} + +ListNode *ListSearch(List *list, int (*SearchFunc)(ListNode *, void *), void *data, int match_number ) +{ + + int ec,count; + ListNode *node; + ListNode *next; + + if(!list || !SearchFunc ) + return NULL; + + count = 0; + node = list->head; + while(node) + { + next = node->next; + ec = SearchFunc( node, data ); + if ( ec ) + { + if ( count == match_number ) + return node; + count++; + } + node = next; + } + + return NULL; // no match found + +} + +ListNode *ListGetNthNode(List *list, int n ) +{ + int count; + ListNode *node; + + if(!list ) + return NULL; + + count = 0; + node = list->head; + while(node) + { + if ( count == n ) + return node; + count++; + node = node->next; + } + + return NULL; // no match found + +} + + +int ListCopy(List *src, List *dst) +{ + int count; + ListNode *node,*newnode; + if(!src || !dst ) + return -1; + + + count = 0; + node = src->head; + while(node) + { + newnode = ListPushBack(dst, node->data, node->dataSize); + if ( newnode == NULL ) // failed to create new node + return count; + count++; + node = node->next; + } + + + return count; + +} + + + +//******************************************************************* +//***********************End List Functions************************** +//******************************************************************* + + +//******************************************************************* +//**************************Binary Tree Functions******************** +//******************************************************************* +/* + \brief must be called before tree is used + \param tree address of a valid tree +*/ +void BinaryTreeCreate(BinaryTree *tree) +{ + tree->head = NULL; + tree->numNodes = 0; +} + +static void BinaryTreePushNode(BinaryTreeNode **head, BinaryTreeNode *node, unsigned int depth) +{ + if( !(*head) ) + { + node->depth = depth; + *head = node; + return; + } + + if(node->key < (*head)->key) + BinaryTreePushNode( &(*head)->left, node, ++depth); + else if(node->key > (*head)->key) + BinaryTreePushNode( &(*head)->right, node, ++depth); +} + +static BinaryTreeNode *BinaryTreeSearch(BinaryTreeNode *node, unsigned int key) +{ + if(!node) + return NULL; + + if(node->key == key) + return node; + else if(key < node->key) + return BinaryTreeSearch(node->left, key); + else if(key > node->key) + return BinaryTreeSearch(node->right, key); + + return NULL; +} + +/* + \brief push a node onto a tree + \param tree address of a valid tree + \param dataSize size of the data if the data is to be copied. If datasize is 0, then a pointer to it will be stored instead + \param data pointer to valid data + \param dataKey address of a variable of any 32bit type holding the key + \return pointer to the new node that was added +*/ +BinaryTreeNode *BinaryTreeAddNode(BinaryTree *tree, unsigned int dataSize, void *data, void *dataKey) +{ + BinaryTreeNode *newNode = NULL; + + if(!tree || !data || !dataKey) + return NULL; + + //**initialize new node** + newNode = CustomMalloc(sizeof(BinaryTreeNode*)); if(!newNode) return NULL; + newNode->dataSize = dataSize; + if(dataSize) + { + newNode->data = CustomMalloc(dataSize); if(!newNode->data) return NULL; + memcpy(newNode->data, data, dataSize); + } + else + newNode->data = data; + newNode->parent = newNode->left = newNode->right; + newNode->key = *( (unsigned int*)dataKey ); + //**done initializing new node** + + if(!tree->head) + tree->head = newNode; + else + BinaryTreePushNode(&tree->head, newNode, 0); + + return newNode; +} + +/* + \brief search for a node by its key + \param tree pointer to a valid tree + \param dataKey address of a variable of any 32bit type holding the key +*/ +BinaryTreeNode *BinaryTreeFindNode(BinaryTree *tree, void* dataKey) +{ + unsigned int key = *( (unsigned int*)dataKey ); + + return BinaryTreeSearch(tree->head, key); +} +//******************************************************************* +//**********************End Binary Tree Functions******************** +//******************************************************************* + + +//******************************************************************* +//**************************Tree Functions*************************** +//******************************************************************* + +/* + \brief must be called before tree is used + \param tree address of a valid tree +*/ +void TreeCreate(Tree *tree) +{ + tree->head = tree->currNode = NULL; + tree->numNodes = 0; +} + +/* + \brief adds a node to the tree. If behavior is set to ADD_NODE_AND_GO_DOWN, the next node added + will be a child of the node just added + \param tree address of a valid tree +*/ +TreeNode *TreeAddNode(Tree *tree, void *data, size_t dataSize, ContainerCommands behavior) +{ + TreeNode *newNode = CustomMalloc(sizeof(TreeNode)); + newNode->parent = NULL; + newNode->data = NULL; + newNode->depth = 0; + newNode->dataSize = dataSize; + ListCreate(&newNode->childList); + + if(dataSize) + { + newNode->data = CustomMalloc(dataSize); + if(!newNode->data) return NULL; + memcpy(newNode->data, data, dataSize); + } + else + newNode->data = data; + + tree->numNodes++; + + if(!tree->head) + tree->head = tree->currNode = newNode; + else + { + newNode->parent = tree->currNode; + newNode->depth = tree->currNode->depth + 1; + ListPushBack(&tree->currNode->childList, newNode, 0); + + if(behavior == TREE_ADD_NODE_AND_GO_DOWN) + tree->currNode = newNode; + } + + return newNode; +} + +/* + \brief the next node added will be a child of the parent of the current head + + \param tree address of a valid tree +*/ +TreeNode *TreeGoUp(Tree *tree) +{ + if(!tree->currNode) + return NULL; + + tree->currNode = tree->currNode->parent; + + return tree->currNode; +} + +/* + \brief the next node added will be a child of the child of the current head + + \param tree address of a valid tree +*/ +TreeNode *TreeGoDown(Tree *tree) +{ + if(!tree->currNode || !tree->currNode->childList.head) + return NULL; + + tree->currNode = tree->currNode->childList.head->data; + + return tree->currNode; +} + +/* +static void TreeFreeChildren(Tree *tree, TreeNode *node) +{ + ListNode *childNode = ListPopBack(&node->childList); + while(childNode) + { + TreeDeleteNode(tree, (TreeNode*)childNode->data); + + if(childNode->dataSize) + ContainerFree(childNode->data); + ContainerFree(childNode); + + childNode = ListPopBack(&node->childList); + } +}*/ + +/* + \brief frees the node and its subtree + \param tree address of a valid tree + \param removeNode node to remove +*/ +void TreeDeleteNode(Tree *tree, TreeNode *removeNode) +{ + if(!removeNode) + return; + + //remove children + while(removeNode->childList.head) + { + ListNode *childHead = ListPopFront(&removeNode->childList); + TreeDeleteNode(tree, childHead->data); + CustomFree(childHead); + } + + //remove the node + if(removeNode->dataSize) + CustomFree(removeNode->data); + CustomFree(removeNode); +} + +/* + \brief frees the whole tree + \param tree address of a valid tree +*/ +void TreeFree(Tree *tree) +{ + if(tree->head) + TreeDeleteNode(tree, tree->head); + +} + +//******************************************************************* +//**********************End List Functions*************************** +//******************************************************************* + + + + + + + diff --git a/libraries/pmrt/pmrt_utils/containers.h b/libraries/pmrt/pmrt_utils/containers.h new file mode 100755 index 0000000..5b3948a --- /dev/null +++ b/libraries/pmrt/pmrt_utils/containers.h @@ -0,0 +1,99 @@ +// containers.h +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +#ifndef _TREE +#define _TREE + +#include + +#define _NULL 0 + +typedef enum _ContainerCommands +{ + TREE_ADD_NODE, TREE_ADD_NODE_AND_GO_DOWN +}ContainerCommands; + +typedef struct _ListNode +{ + struct _ListNode *next; + struct _ListNode *prev; + void *data; + size_t dataSize; +}ListNode; + +typedef struct _List +{ + ListNode *head; + ListNode *tail; + size_t numNodes; +}List; + +typedef struct _TreeNode +{ + int depth; + size_t dataSize; + void *data; + List childList; + struct _TreeNode *parent; +}TreeNode; + +typedef struct _BinaryTreeNode +{ + int depth; + size_t dataSize; + unsigned int key; + void *data; + struct _BinaryTreeNode *parent; + struct _BinaryTreeNode *left; + struct _BinaryTreeNode *right; +}BinaryTreeNode; + +typedef struct _Tree +{ + TreeNode *head; + TreeNode *currNode; + int numNodes; +}Tree; + +typedef struct _BinaryTree +{ + BinaryTreeNode *head; + int numNodes; +}BinaryTree; + +void ContainersSetMemoryFuncs( void* (*CustomMallocFunc)(size_t size), void (*CustomFreeFunc)(void *) ); + +void ListCreate(List *list); +ListNode *ListPushBack(List *list, void *data, size_t dataSize); +ListNode *ListPushFront(List *list, void *data, size_t dataSize); +ListNode *ListPopFront(List *list); +ListNode *ListPopBack(List *list); +ListNode *ListRemove(List *list, void *data); +void ListInsertBefore(List *list, ListNode *node, ListNode *nextNode); +void ListPop(List *list, ListNode *node); +void ListFree(List *list); +void ListFreeNode(ListNode *node); +int ListWalk(List *list, int (*OpFunc)(ListNode *, void *), void *data ); +ListNode *ListSearch(List *list, int (*SearchFunc)(ListNode *, void *), void *data, int match_number ); +ListNode *ListGetNthNode(List *list, int n ); +int ListCopy(List *src, List *dst); + + +void TreeCreate(Tree *tree); +void TreeDeleteNode(Tree *tree, TreeNode *removeNode); +void TreeFree(Tree *tree); +TreeNode *TreeAddNode(Tree *tree, void *data, size_t size, ContainerCommands behavior); +TreeNode *TreeGoUp(Tree *tree); +TreeNode *TreeGoDown(Tree *tree); + +void BinaryTreeCreate(BinaryTree *tree); +BinaryTreeNode *BinaryTreeAddNode(BinaryTree *tree, unsigned int dataSize, void *data, void *dataKey); +BinaryTreeNode *BinaryTreeFindNode(BinaryTree *tree, void* dataKey); + +#endif + + + diff --git a/libraries/pmrt/pmrt_utils/containers.o b/libraries/pmrt/pmrt_utils/containers.o new file mode 100644 index 0000000..16f574a Binary files /dev/null and b/libraries/pmrt/pmrt_utils/containers.o differ diff --git a/libraries/pmrt/pmrt_utils/dnslookup.c b/libraries/pmrt/pmrt_utils/dnslookup.c new file mode 100755 index 0000000..be08080 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/dnslookup.c @@ -0,0 +1,188 @@ +// dnslookup.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#include "dnslookup.h" +#include "netsock.h" +#include "thread.h" + +#include +#include +#include + +#if SYS_PC +extern int StartWin32Sockets(); +#endif + +#include + +#define MAX_DNS_QUERY_TIME 120 + +#define MAX_DNS_QUERY_LEN 256 + + +enum +{ + + DNS_STATUS_AVAILABLE = 0, + DNS_STATUS_BUSY, + DNS_STATUS_COMPLETE, + + +}; + +char gQueryName[MAX_DNS_QUERY_LEN]; +char gQueryResult[MAX_DNS_QUERY_LEN]; +int gQueryStatus = DNS_STATUS_AVAILABLE; +int gQueryErr = 0; +int gQueryTimeout = 0; + + +// this call will block! +int GetHostByName( char *name, char *result, int len) +{ +// #if SYS_BB + struct hostent *h; + char *addr; + +#if SYS_PC + struct in_addr iaddr; + + StartWin32Sockets(); +#endif + + if ( name == NULL || result == NULL || len <= 0 ) + return -1; + + // zero result + memset( result, 0, len ); + + // blocking call! + h = gethostbyname(name); + if ( h == NULL ) + { + return -1; + } + if ( h->h_addr_list[0] == NULL ) + return -1; + +#if SYS_PC + iaddr.s_addr = *(u_long *) h->h_addr_list[0]; + addr = inet_ntoa( iaddr ); +#endif +#if SYS_BB + addr = inet_ntoa( *( struct in_addr*)( h->h_addr_list[0]) ); +#endif + strncpy( result, addr, len ); + return 0; + +} + + +void DNSLookupThread( int arg ) +{ + int ec; + int TimeOut; + char Result[MAX_DNS_QUERY_LEN]; + + // capture timeout on way in + TimeOut = gQueryTimeout; + + ec = GetHostByName( gQueryName, Result, sizeof(Result) ); + + + // finished in time + if ( gQueryStatus == DNS_STATUS_BUSY + && + time(NULL) <= TimeOut ) + { + strncpy( gQueryResult, Result, sizeof(gQueryResult) ); + gQueryStatus = DNS_STATUS_COMPLETE; + if ( ec < 0 ) + gQueryErr = -1; + } + + return; +} + + + +int DNSLookup(char *hostname, char *result, int result_len) +{ + ThreadStartInfo tsi; + ThreadHandle th; + if ( hostname == NULL || result == NULL || result_len <= 0 ) + { + return DNSLOOKUP_INVALID_PARAMS; + } + + switch( gQueryStatus ) + { + case DNS_STATUS_AVAILABLE: + tsi.Arg = 0; + tsi.Func = DNSLookupThread; + gQueryStatus = DNS_STATUS_BUSY; + gQueryTimeout = time(NULL) + MAX_DNS_QUERY_TIME; + gQueryErr = 0; + strncpy( gQueryName, hostname, sizeof(gQueryName) ); + if ( StartThread( &th, &tsi ) == THREAD_RESULT_SUCCESS ) + { + return DNSLOOKUP_BUSY; + } + else + { + gQueryStatus = DNS_STATUS_AVAILABLE; + gQueryTimeout = 0; + gQueryErr = 0; + return DNSLOOKUP_THREAD_ERROR; + } + break; + case DNS_STATUS_BUSY: + if ( time(NULL) > gQueryTimeout ) + { + // if it's been too long on any one query + // then reset query status + gQueryStatus = DNS_STATUS_AVAILABLE; + gQueryTimeout = 0; + gQueryErr = 0; + } + return DNSLOOKUP_BUSY; + break; + case DNS_STATUS_COMPLETE: + if ( strcmp( hostname, gQueryName) == 0 ) + { + // our query was answered! + // first reset query status + gQueryStatus = DNS_STATUS_AVAILABLE; + gQueryTimeout = 0; + gQueryErr = 0; + + // copy result and return + strncpy( result, gQueryResult, result_len ); + if ( gQueryErr != 0 ) + return DNSLOOKUP_DNS_ERROR; + else + return DNSLOOKUP_SUCCESS; + + } + else + { + if ( time(NULL) > gQueryTimeout ) + { + // waited too long for someone to claim this result + // reset our status and be done w/ it + gQueryStatus = DNS_STATUS_AVAILABLE; + gQueryTimeout = 0; + gQueryErr = 0; + + } + else + return DNSLOOKUP_BUSY; + } + break; + } + + return DNSLOOKUP_BUSY; +} + + diff --git a/libraries/pmrt/pmrt_utils/dnslookup.h b/libraries/pmrt/pmrt_utils/dnslookup.h new file mode 100755 index 0000000..ba3f8c2 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/dnslookup.h @@ -0,0 +1,18 @@ +// dnslookup.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + + +enum +{ + DNSLOOKUP_SUCCESS = 0, + DNSLOOKUP_INVALID_PARAMS, + DNSLOOKUP_BUSY, + DNSLOOKUP_DNS_ERROR, + DNSLOOKUP_THREAD_ERROR, + +} DNSQueryResults; + + +int DNSLookup(char *hostname, char *result, int result_len); diff --git a/libraries/pmrt/pmrt_utils/dnslookup.o b/libraries/pmrt/pmrt_utils/dnslookup.o new file mode 100644 index 0000000..f873d5d Binary files /dev/null and b/libraries/pmrt/pmrt_utils/dnslookup.o differ diff --git a/libraries/pmrt/pmrt_utils/filesys.c b/libraries/pmrt/pmrt_utils/filesys.c new file mode 100755 index 0000000..5d6a977 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/filesys.c @@ -0,0 +1,1350 @@ +// filesys.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#include "filesys.h" + +#include "thread.h" + + +#include +#include +#include +#include +#ifdef SYS_PC +#include +#endif +#ifdef SYS_BB +#include +#endif + + +// file info functions +int FsFileSize( const char *filename ) +{ + FILE *fd; + int size; + int ec; + fd = fopen(filename,"rb"); + if ( fd <= 0 ) + { + // not a valid filename? + return -1; + } + + ec = fseek(fd,0,SEEK_END); + if ( ec < 0 ) + { + fclose(fd); + return 0; + } + + size=ftell(fd); + fclose(fd); + + return size; +} + +// directory walking functions +int FsOpenDir(FsDH *fdh, char *dirname ) +{ +#ifdef SYS_PC + char buf[256]; +#endif + if ( fdh == NULL ) + return -1; +#ifdef SYS_PC + sprintf(buf,"%s/*", dirname); + fdh->hFile = _findfirst(buf, &fdh->file ); + if ( fdh->hFile == -1 ) // error w/ search (non-existent dir?) + return -2; + fdh->done = 0; + return 0; +#endif +#ifdef SYS_BB + fdh->dir = opendir(dirname); + if ( fdh->dir == NULL ) + return -2; + return 0; +#endif +} + +int FsCloseDir(FsDH *fdh) +{ + if ( fdh == NULL ) + return -1; +#ifdef SYS_PC + return _findclose(fdh->hFile); +#endif +#ifdef SYS_BB + return closedir(fdh->dir); +#endif +} + +char *FsReadDir(FsDH *fdh) +{ +#if SYS_PC + if ( fdh->done == 1 ) + return NULL; + strncpy(fdh->filename, fdh->file.name, FS_MAX_FILENAME_LEN); + // get next dir entry + if ( _findnext( fdh->hFile, &fdh->file ) != 0 ) + fdh->done = 1; + return &fdh->filename[0]; +#endif +#ifdef SYS_BB + fdh->ent = readdir(fdh->dir); + if ( fdh->ent == NULL ) + return NULL; + strncpy(fdh->filename, fdh->ent->d_name, FS_MAX_FILENAME_LEN); + return &fdh->filename[0]; +#endif +} + + + + +int FsDirSize( char *dirname, int recurse ) +{ + FsDH dh; + int ec; + int len; + char *file; + char buf[256]; + FILE *fd; + int size = 0; + + ec = FsOpenDir(&dh, dirname ); + if ( ec < 0 ) + return 0; + + while ( (file = FsReadDir(&dh)) != NULL ) + { + len = strlen(file); + // skip "." and ".." + if ( ( len == 1 && file[0] == '.' ) + || + ( len == 2 && file[0] == '.' && file[1] == '.' ) + ) + continue; + + if ( strlen(dirname) + len < sizeof(buf) ) + sprintf(buf,"%s/%s",dirname,file); + else + continue; // file name too long, so just skip it + + fd = fopen(buf,"rb"); + if ( fd <= 0 ) + { + // could be a file we don't have perms to open + // or could be a directory, try to recurse it + if ( recurse ) + size += FsDirSize(buf, recurse ); + continue; + } + + ec = fseek(fd,0,SEEK_END); + if ( ec < 0 ) + { + fclose(fd); + continue; + } + + size+=ftell(fd); + fclose(fd); + } + + FsCloseDir(&dh); + return size; + +} + +// Removes a directory and everything in it. +int FsRecursiveRmdir(char *dirname) +{ + FsDH dh; + int ec; + int len; + char *file; + char buf[256]; + + ec = FsOpenDir(&dh, dirname ); + if (ec < 0) + return -1; + + while ( (file = FsReadDir(&dh)) != NULL) + { + len = strlen(file); + // skip "." and ".." + if ( ( len == 1 && file[0] == '.' ) + || + ( len == 2 && file[0] == '.' && file[1] == '.' ) + ) + continue; + + if ( strlen(dirname) + len < sizeof(buf) ) + sprintf(buf,"%s/%s",dirname,file); + else + continue; // file name too long, so just skip it + + // delete any files encountered + ec = unlink(buf); + // Couldn't delete file because it's a directory + if ( ec == -1 && errno == EISDIR) + { + // delete any files inside the directory + ec = FsRecursiveRmdir(buf); + if ( ec < 0 ) + { + FsCloseDir(&dh); + return ec; + } + } + } + + FsCloseDir(&dh); + + ec = rmdir(dirname); + if ( ec < 0 ) + { + return ec; + } + + // if err'd then return the ec, otherwise return 0 + return 0; +} + +int FsDirWalk( char *dirname, int recurse, int actOnDirs, int (*OperationFunc)(char *, void *), void *data) +{ + FsDH dh; + int ec; + int len; + char *file; + char buf[256]; + FILE *fd; + int count = 0; + + ec = FsOpenDir(&dh, dirname ); + if ( ec < 0 ) + return 0; + + while ( (file = FsReadDir(&dh)) != NULL ) + { + len = strlen(file); + // skip "." and ".." + if ( ( len == 1 && file[0] == '.' ) + || + ( len == 2 && file[0] == '.' && file[1] == '.' ) + ) + continue; + + if ( strlen(dirname) + len < sizeof(buf) ) + sprintf(buf,"%s/%s",dirname,file); + else + continue; // file name too long, so just skip it + + fd = fopen(buf,"rb"); + if ( fd <= 0 ) + { + // could be a file we don't have perms to open + // or could be a directory, try to recurse it + if ( recurse ) + { + ec = FsDirWalk(buf, recurse, 0, OperationFunc, data ); + if ( ec < 0 ) + { + FsCloseDir(&dh); + return ec; + } + count += ec; + } + if (!actOnDirs) + continue; + } + else + { + fclose(fd); + } + + if ( OperationFunc != NULL ) + { + // call the operation func on the file + ec = OperationFunc(buf,data); + if ( ec < 0 ) + { + FsCloseDir(&dh); + return ec; + } + } + count++; + } + + FsCloseDir(&dh); + + // if err'd then return the ec, otherwise return our count + return count; + + +} + + +int CountFiles(char *filename, void *pCount) +{ + if ( filename == NULL || pCount == NULL ) + return 0; + *((int*)pCount) += 1; + return 0; +} + +int FsDirCountFiles(char *dirname, int recursive) +{ + int count = 0; + FsDirWalk( dirname, recursive, 0, CountFiles, &count ); + return count; +} + +int FsMkDir( char *dirname, int make_parent_dirs ) +{ +// int ec; + int i; + char buf[512]; + int len; + +#ifdef SYS_BB + FsDH dh; +#endif + if ( ! make_parent_dirs ) + { +#if SYS_BB + if(mkdir(dirname,S_IRWXU|S_IRGRP|S_IXGRP) == 0) + { + return 0; + } + else + { + if ( errno == EEXIST ) + { + // path exists, double check it is a dir + if ( FsOpenDir( &dh, dirname ) < 0 ) + { + return -1; + } + else + { + FsCloseDir(&dh); + return 0; + } + } + else + { + // some other error + return -1; + } + } +#endif +#if SYS_PC + if (_mkdir(dirname) < 0) + { + if (errno == EEXIST) + { + return 0; // dir already exists, that counts as success + } + else + { + // some other error occured besides directory already existing + return -1; + } + } + else + { + // _mkdir succeeded + return 0; + } +#endif + } + else + { + // we need to walk dirname and make each dir as we go + len = strlen(dirname); + if ( len > sizeof(buf) - 1 ) + return -1; // dirname too long! + i = 0; + + // check for some special cases + if ( dirname[0] == '/' ) // skip leading slash + { + i = 1; + } + else if ( len > 3 // skip leading drive letter (windows style c:/stuff) + && dirname[1] == ':' + && dirname[2] == '/' ) + { + i = 3; + } + + while ( i < len ) + { + if ( dirname[i] == '/' ) + { + // null out buf + memset( buf, 0, sizeof(buf) ); + // copy up to the slash into buffer + memcpy(buf,dirname,i); + // make the dir + if ( FsMkDir( buf, 0 ) < 0 ) + { + return -2; + } + } + i++; + } + // make final dir + if ( FsMkDir( dirname, 0 ) < 0 ) + { + return -2; + } + + // all done! + return 0; + } +} + +// wrappers for the usual fopen, fread/fwrite, fclose business +int FsLoadFile( char *filename, void **dest, int *dest_len, void *(*malloc_func)(size_t), void (*free_func)(void *) ) +{ + FILE *fd; + int mallocd; + int bytes; + + if ( filename == NULL + || dest == NULL + || dest_len == NULL + || (*dest != NULL && *dest_len < 0) + // || (*dest == NULL && (malloc_func == NULL || free_func == NULL)) + ) + return FS_ERR_INVALID_PARAMS; // invalid params + + mallocd = 0; + + if ( malloc_func == NULL ) + malloc_func = malloc; + if (free_func == NULL ) + free_func = free; + + if ( *dest == NULL ) + { + *dest_len = FsFileSize(filename); + if ( *dest_len <= 0 ) + { + return FS_ERR_INVALID_FILE; + } + + *dest = malloc_func(*dest_len); + if ( *dest == NULL ) + return FS_ERR_MALLOC_FAILED; + mallocd = 1; + } + + + fd = fopen(filename, "rb" ); + if (fd == NULL) + { + if (mallocd) + { + free_func(*dest); + *dest = NULL; + *dest_len = 0; + } + return FS_ERR_INVALID_FILE; + } + + bytes = fread( *dest, 1, *dest_len, fd ); + if ( bytes < 0 || bytes < *dest_len ) + { + if (mallocd) + { + free_func(*dest); + *dest = NULL; + *dest_len = 0; + fclose(fd); + } + return FS_ERR_READ_FAILED; + } + + // all done! + fclose(fd); + return FS_ERR_NONE; +} + +int FsSaveFile( char *filename, void *data, int data_len ) +{ + FILE *fd; + int bytes; + + if ( filename == NULL + || data == NULL + || data_len <= 0 + ) + return FS_ERR_INVALID_PARAMS; // invalid params + + fd = fopen(filename, "wb" ); + if (fd == NULL) + { + return FS_ERR_INVALID_FILE; + } + + bytes = fwrite( data, 1, data_len, fd ); + if ( bytes < 0 || bytes < data_len ) + { + return FS_ERR_WRITE_FAILED; + } + + // all done! + fclose(fd); + return FS_ERR_NONE; +} + + + +// returns true if file exists and is readable +int FsCheckIfFileExists( char *filename ) +{ + FILE *fd; + + if ( filename == NULL ) + return FS_ERR_INVALID_PARAMS; + + fd = fopen(filename,"r"); + if ( fd <= 0 ) + { + // not a valid filename? + return FS_ERR_INVALID_FILE; + } + fclose(fd); + + return FS_ERR_NONE; +} + + +int FsSaveInt( char *filename, int val ) +{ + // int FsSaveFile( char *filename, void *data, int data_len ); + if ( filename == NULL ) + return FS_ERR_INVALID_PARAMS; + + return FsSaveFile( filename, &val, sizeof(int) ); +} + + + +// int FsLoadFile( char *filename, void **dest, int *dest_len, void *(*malloc_func)(size_t), void (*free_func)(void *) ); +int FsLoadInt( char *filename, int *val ) +{ + int size; + size = 4; + if ( filename == NULL || val == NULL ) + return FS_ERR_INVALID_PARAMS; + + return FsLoadFile( filename, &val, &size, NULL, NULL ); +} + + + +/*! + \brief Gets the size of a file when passed a handle to an open file + \param openFile handle to a file already open + \return unsigned int size of the file +*/ +unsigned int UtilGetFileSize(FILE *openFile) +{ + unsigned int size = 0; + long start = 0; + + if(!openFile) + return 0; + + start = ftell(openFile); + + fseek(openFile, 0L, SEEK_END); + size = ftell(openFile); + + fseek(openFile, start, SEEK_SET); + + return (unsigned int)size; +} + +/*! + \brief Read the contents of a file into a buffer. File should not already be open. + \param fileName name of the file + \param fopenFlags fopen flags ("w", "r", ...) + \param buffer pointer to a buffer which will point to valid data if the function succeeds + \param bufferSize will contain the size of the buffer if the function succeeds + \return int 0 for sucess, -1 for fail +*/ +int UtilReadFromFile(const char *fileName, const char *fopenFlags, char **buffer, unsigned int *bufferSize) +{ + FILE *inFile = NULL; + unsigned int size = 0; + + if(!bufferSize || !fopenFlags || !fileName || !buffer) + return -1; + + inFile = fopen(fileName, fopenFlags); + if(!inFile) + goto fail; + + size = UtilGetFileSize(inFile); + + *buffer = calloc(1, size * sizeof(char)); + + size = fread(*buffer, 1, sizeof(char)*size, inFile); + + fclose(inFile); + + *bufferSize = size; + + return 0; +fail: + if(inFile) + fclose(inFile); + + return -1; +} + + +int FsFileCopy( char *srcfile, char *destfile ) +{ + FILE *src,*dst; + unsigned char buf[4096]; + int bytes_read; + int bytes_written; + + if ( srcfile == NULL || destfile == NULL ) + return -1; + + src = fopen( srcfile, "rb" ); + if ( src == NULL ) + return -2; + + dst = fopen( destfile, "wb" ); + if ( dst == NULL ) + { + fclose(src); + return -3; + } + + while ( ! feof(src) ) + { + bytes_read = fread( buf, 1, sizeof(buf), src ); + if ( bytes_read > 0 ) + { + bytes_written = fwrite(buf, 1, bytes_read, dst ); + if ( bytes_written != bytes_read ) + { + fclose(src); + fclose(dst); + unlink(destfile); + return -4; + } + } + else + { + // read error + fclose(src); + fclose(dst); + unlink(destfile); + return -5; + } + } + + fclose(src); + fclose(dst); + + return 0; + +} + +int FsFileMove( char *srcfile, char *destfile ) +{ + + int ec; + + if ( srcfile == NULL || destfile == NULL ) + return -1; + + // first try to rename the file, if that fails, then try a manual copy + ec = rename( srcfile, destfile ); + + if( ec < 0 && errno == EXDEV ) // 'oldpath and newpath are not on the same filesystem.' + { + // this means we have to do a manual copy + ec = FsFileCopy( srcfile, destfile ); + if ( ec == 0 ) // copy was a success + unlink(srcfile); + } + + return ec; +} + + +// Threaded IO Routines + +// Threaded IO support threads (do actual operations) +void ThreadedFileIO_SimpleThread( int arg ) +{ + ThreadedFileIOHandle *tfioh; + int ec; + + tfioh = (ThreadedFileIOHandle *) arg; + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + if ( tfioh->data_len < 0 || (tfioh->data_len > 0 && tfioh->data == NULL) || (tfioh->data_len == 0 && (tfioh->malloc_func == NULL || tfioh->free_func == NULL)) ) + { + tfioh->error = THREADEDIO_ERR_INVALID_PARAMS; + tfioh->status = THREADEDIO_STATUS_ERROR; + return; + } + + if ( tfioh->mode[0] == 'w' ) + tfioh->writing = 1; + else + tfioh->writing = 0; + + if ( tfioh->writing == 1 && tfioh->data_len == 0 ) + { + tfioh->error = THREADEDIO_ERR_INVALID_PARAMS; + tfioh->status = THREADEDIO_STATUS_ERROR; + return; + } + + if( tfioh->writing ) + { + ec = FsSaveFile( tfioh->filename, tfioh->data, tfioh->data_len ); + } + else + { + ec = FsLoadFile( tfioh->filename, &tfioh->data, &tfioh->data_len, tfioh->malloc_func, tfioh->free_func ); + } + + switch(ec) + { + case FS_ERR_NONE: + tfioh->error = THREADEDIO_ERR_NONE; + tfioh->status = THREADEDIO_STATUS_COMPLETE; + break; + case FS_ERR_INVALID_PARAMS: + tfioh->error = THREADEDIO_ERR_INVALID_PARAMS; + tfioh->status = THREADEDIO_STATUS_ERROR; + break; + case FS_ERR_INVALID_FILE: + tfioh->error = THREADEDIO_ERR_INVALID_FILE; + tfioh->status = THREADEDIO_STATUS_ERROR; + break; + case FS_ERR_MALLOC_FAILED: + tfioh->error = THREADEDIO_ERR_MALLOC_FAILED; + tfioh->status = THREADEDIO_STATUS_ERROR; + break; + case FS_ERR_READ_FAILED: + tfioh->error = THREADEDIO_ERR_READ_FAILED; + tfioh->status = THREADEDIO_STATUS_ERROR; + break; + case FS_ERR_WRITE_FAILED: + tfioh->error = THREADEDIO_ERR_WRITE_FAILED; + tfioh->status = THREADEDIO_STATUS_ERROR; + break; + default: // something else went wrongo + tfioh->error = THREADEDIO_ERR_UNKNOWN; + tfioh->status = THREADEDIO_STATUS_ERROR; + break; + } + + return; + + +} + + +void ThreadedFileIO_OpenThread( int arg ) +{ + ThreadedFileIOHandle *tfioh; + + tfioh = (ThreadedFileIOHandle *) arg; + + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + tfioh->fp = fopen( tfioh->filename, tfioh->mode ); + if ( tfioh->fp == NULL ) + { + tfioh->error = THREADEDIO_ERR_OPEN_FAILED; + tfioh->ERRNO = errno; // dubious thread saftey on this one... + tfioh->status = THREADEDIO_STATUS_ERROR; + return; + } + + tfioh->error = THREADEDIO_ERR_NONE; + tfioh->status = THREADEDIO_STATUS_COMPLETE; + + return; + + +} + + +void ThreadedFileIO_ReadThread( int arg ) +{ + ThreadedFileIOHandle *tfioh; + + tfioh = (ThreadedFileIOHandle *) arg; + + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + tfioh->bytes_readorwrote = fread( tfioh->data, 1, tfioh->data_len, tfioh->fp ); + if ( tfioh->bytes_readorwrote != tfioh->data_len ) + { + tfioh->error = THREADEDIO_ERR_READ_FAILED; + tfioh->ERRNO = errno; // dubious thread saftey on this one... + tfioh->status = THREADEDIO_STATUS_ERROR; + return; + } + + tfioh->error = THREADEDIO_ERR_NONE; + tfioh->status = THREADEDIO_STATUS_COMPLETE; + + return; + + +} + +void ThreadedFileIO_WriteThread( int arg ) +{ + ThreadedFileIOHandle *tfioh; + + tfioh = (ThreadedFileIOHandle *) arg; + + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + tfioh->bytes_readorwrote = fwrite( tfioh->data, 1, tfioh->data_len, tfioh->fp ); + if ( tfioh->bytes_readorwrote != tfioh->data_len ) + { + tfioh->error = THREADEDIO_ERR_WRITE_FAILED; + tfioh->ERRNO = errno; // dubious thread saftey on this one... + tfioh->status = THREADEDIO_STATUS_ERROR; + return; + } + + tfioh->error = THREADEDIO_ERR_NONE; + tfioh->status = THREADEDIO_STATUS_COMPLETE; + + return; + + +} + + +// an all in one function, will open file and read/write entire contents to/from the passed buffer +// alternately a malloc and free func can be passed and a buffer will be created for read data +// use ThreadedFileIOHandle_GetData() to get a ptr to resultant buffer +// caller is responsible for freeing data malloc'd this way (it is not freed by ThreadedFileIOHandle_Close) +int ThreadedFileIOHandle_OpenSimple( ThreadedFileIOHandle *tfioh, char *filename, char *mode, + void *data, int data_len, + void *(*malloc_func)(size_t), void (*free_func)(void *) ) +{ + ThreadStartInfo tsi; + ThreadHandle th; + ThreadedFileIOHandle *tfioh_ptr; + int tfioh_address; + + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + if ( filename == NULL || mode == NULL || data_len < 0 || (data_len > 0 && data == NULL) || (data_len == 0 && (malloc_func == NULL || free_func == NULL) ) ) + return THREADEDIO_ERR_INVALID_PARAMS; + + strncpy(tfioh->filename, filename, sizeof(tfioh->filename) ); + strncpy(tfioh->mode, mode, sizeof(tfioh->mode) ); + + tfioh->data = data; + tfioh->data_len = data_len; + tfioh->malloc_func = malloc_func; + tfioh->free_func = free_func; + tfioh->fp = NULL; + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + + //(ThreadedFileIOHandle *)tfioh_address = tfioh; + tfioh_ptr = (ThreadedFileIOHandle*)tfioh_address; + tfioh_ptr = tfioh; + + tsi.Arg = tfioh_address; + tsi.Func = ThreadedFileIO_SimpleThread; + + if ( StartThread( &th, &tsi ) != THREAD_RESULT_SUCCESS ) + { + tfioh->status = THREADEDIO_STATUS_ERROR; + tfioh->error = THREADEDIO_ERR_FAILED_TO_START_THREAD; + return THREADEDIO_ERR_FAILED_TO_START_THREAD; + } + + + return THREADEDIO_ERR_NONE; + +} + + +/* +int ThreadedFileIOHandle_OpenSimple( ThreadedFileIOHandle *tfioh, char *filename, char *mode, + void *data, int data_len, + void *(*malloc_func)(size_t), void (*free_func)(void *) ) +{ + ThreadStartInfo tsi; + ThreadHandle th; + + int tfioh_address; + + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + if ( filename == NULL || mode == NULL || data_len < 0 || (data_len > 0 && data == NULL) || (data_len == 0 && (malloc_func == NULL || free_func == NULL) ) ) + return THREADEDIO_ERR_INVALID_PARAMS; + + strncpy(tfioh->filename, filename, sizeof(tfioh->filename) ); + strncpy(tfioh->mode, mode, sizeof(tfioh->mode) ); + + tfioh->data = data; + tfioh->data_len = data_len; + tfioh->malloc_func = malloc_func; + tfioh->free_func = free_func; + tfioh->fp = NULL; + + + (ThreadedFileIOHandle *)tfioh_address = tfioh; + + tsi.Arg = tfioh_address; + tsi.Func = ThreadedFileIOHandle_SimpleThread; + + if ( StartThread( &th, &tsi ) != THREAD_RESULT_SUCCESS ) + { + tfioh->status = THREADEDIO_STATUS_ERROR; + tfioh->error = THREADEDIO_ERR_FAILED_TO_START_THREAD; + return THREADEDIO_ERR_FAILED_TO_START_THREAD; + } + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + return THREADEDIO_ERR_NONE; + +} +*/ + +// opens manual threaded io file handle +// use ThreadedFileIOHandle_Read(), ThreadedFileIOHandle_Write() and ThreadedFileIOHandle_Close() +// to perform read/write/close operations +// use ThreadedFileIOHandle_CheckStatus() to spin while waiting for an operation to complete +int ThreadedFileIOHandle_Open( ThreadedFileIOHandle *tfioh, char *filename, char *mode ) +{ + ThreadStartInfo tsi; + ThreadHandle th; + ThreadedFileIOHandle *tfioh_ptr; + int tfioh_address; + + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + if ( filename == NULL || mode == NULL ) + return THREADEDIO_ERR_INVALID_PARAMS; + + memset( tfioh, 0, sizeof(ThreadedFileIOHandle) ); + + strncpy(tfioh->filename, filename, sizeof(tfioh->filename) ); + strncpy(tfioh->mode, mode, sizeof(tfioh->mode) ); + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + + //(ThreadedFileIOHandle *)tfioh_address = tfioh; + tfioh_ptr = (ThreadedFileIOHandle*)tfioh_address; + tfioh_ptr = tfioh; + + tsi.Arg = tfioh_address; + tsi.Func = ThreadedFileIO_OpenThread; + + if ( StartThread( &th, &tsi ) != THREAD_RESULT_SUCCESS ) + { + tfioh->status = THREADEDIO_STATUS_ERROR; + tfioh->error = THREADEDIO_ERR_FAILED_TO_START_THREAD; + return THREADEDIO_ERR_FAILED_TO_START_THREAD; + } + + + return THREADEDIO_ERR_NONE; + +} + +// analogs for fread/fwrite +// use ThreadedFileIOHandle_CheckReadWriteBytes() to recover the actual number of +// bytes read/written from/to file (useful in event of an error) +int ThreadedFileIOHandle_Read( ThreadedFileIOHandle *tfioh, void *data, int len ) +{ + ThreadStartInfo tsi; + ThreadHandle th; + ThreadedFileIOHandle *tfioh_ptr; + int tfioh_address; + + if ( tfioh == NULL || tfioh->fp == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + if ( data == NULL || len <= 0 ) + return THREADEDIO_ERR_INVALID_PARAMS; + + tfioh->data = data; + tfioh->data_len = len; + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + +// (ThreadedFileIOHandle *)tfioh_address = tfioh; + tfioh_ptr = (ThreadedFileIOHandle*)tfioh_address; + tfioh_ptr = tfioh; + + + tsi.Arg = tfioh_address; + tsi.Func = ThreadedFileIO_ReadThread; + + if ( StartThread( &th, &tsi ) != THREAD_RESULT_SUCCESS ) + { + tfioh->status = THREADEDIO_STATUS_ERROR; + tfioh->error = THREADEDIO_ERR_FAILED_TO_START_THREAD; + return THREADEDIO_ERR_FAILED_TO_START_THREAD; + } + + + return THREADEDIO_ERR_NONE; + +} + +int ThreadedFileIOHandle_Write( ThreadedFileIOHandle *tfioh, void *data, int len ) +{ + ThreadStartInfo tsi; + ThreadHandle th; + ThreadedFileIOHandle *tfioh_ptr; + int tfioh_address; + + if ( tfioh == NULL || tfioh->fp == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + if ( data == NULL || len <= 0 ) + return THREADEDIO_ERR_INVALID_PARAMS; + + tfioh->data = data; + tfioh->data_len = len; + + tfioh->status = THREADEDIO_STATUS_BUSY; + tfioh->error = THREADEDIO_ERR_NONE; + + + //(ThreadedFileIOHandle *)tfioh_address = tfioh; + tfioh_ptr = (ThreadedFileIOHandle*)tfioh_address; + tfioh_ptr = tfioh; + + tsi.Arg = tfioh_address; + tsi.Func = ThreadedFileIO_ReadThread; + + if ( StartThread( &th, &tsi ) != THREAD_RESULT_SUCCESS ) + { + tfioh->status = THREADEDIO_STATUS_ERROR; + tfioh->error = THREADEDIO_ERR_FAILED_TO_START_THREAD; + return THREADEDIO_ERR_FAILED_TO_START_THREAD; + } + + + return THREADEDIO_ERR_NONE; + +} + +int ThreadedFileIOHandle_CheckReadWriteBytes( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + return tfioh->bytes_readorwrote; +} + + +int ThreadedFileIOHandle_CheckStatus( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + return tfioh->status; +} + +int ThreadedFileIOHandle_CheckError( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + + return tfioh->error; +} + +int ThreadedFileIOHandle_CheckErrorno( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + + return tfioh->ERRNO; +} + + +void *ThreadedFileIOHandle_GetData( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return NULL; + + return tfioh->data; +} + +int ThreadedFileIOHandle_GetDataLen( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + return tfioh->data_len; +} + +int ThreadedFileIOHandle_Close( ThreadedFileIOHandle *tfioh ) +{ + if ( tfioh == NULL ) + return THREADEDIO_ERR_INVALID_HANDLE; + + if ( tfioh->fp ) + fclose(tfioh->fp); + + tfioh->fp = NULL; + + return THREADEDIO_ERR_NONE; +} + + +// non blocking io stuff +// this uses open/read/write in nonblocking mode +// to read files, etc without blocking +// note that call may still block during a read/write +// just not before +// that is to say call will never wait for device to be 'ready' for reading/writing +// but may wait while actual data transfer takes place +int NonBlockingIO_OpenFile( NonBlockingIOHandle *nbioh, char *filename, char *mode ) +{ +#ifdef SYS_BB + int ec; + int flags; +#endif + + if ( nbioh == NULL || filename == NULL || mode == NULL ) + return NONBLOCKINGIO_ERR_INVALID_PARAMS; + + memset( nbioh, 0, sizeof(NonBlockingIOHandle) ); + + +#ifdef SYS_PC // not supported on PC yet + nbioh->ERRNO = errno; + nbioh->error = NONBLOCKINGIO_ERR_OPEN_FAILED; + return nbioh->error; +#else // SYS_BB + + strncpy(nbioh->filename, filename, sizeof(nbioh->filename) ); + strncpy(nbioh->mode, mode, sizeof(nbioh->mode) ); + + if ( nbioh->mode[0] == 'w' || nbioh->mode[0] == 'a' ) + nbioh->writing = 1; + + if (nbioh->writing) + flags = O_WRONLY; + else + flags = O_RDONLY; + + if ( nbioh->mode[0] == 'a' ) + flags |= O_APPEND; + + flags |= O_NONBLOCK; + + + ec = open( filename, flags ); + nbioh->fd = ec; + + if ( ec < 0 ) + { + nbioh->ERRNO = errno; + nbioh->error = NONBLOCKINGIO_ERR_OPEN_FAILED; + return nbioh->error; + } + + + return NONBLOCKINGIO_ERR_NONE; + +#endif // SYS_PC +} + +int NonBlockingIO_SetData( NonBlockingIOHandle *nbioh, void *data, int len ) +{ + if ( nbioh == NULL ) + return NONBLOCKINGIO_ERR_INVALID_HANDLE; + if ( data == NULL || len == 0 ) + return NONBLOCKINGIO_ERR_INVALID_PARAMS; + + nbioh->data = data; + nbioh->data_len = len; + nbioh->data_pos = 0; + + return NONBLOCKINGIO_ERR_NONE; + +} + +int NonBlockingIO_GetData( NonBlockingIOHandle *nbioh, void **data, int *len, int *pos ) +{ + if ( nbioh == NULL ) + return NONBLOCKINGIO_ERR_INVALID_HANDLE; + if ( data == NULL || len == 0 ) + return NONBLOCKINGIO_ERR_INVALID_PARAMS; + + if ( data != NULL ) + *data = nbioh->data; + if ( len != NULL ) + *len = nbioh->data_len; + if ( pos != NULL ) + *pos = nbioh->data_pos; + + + return NONBLOCKINGIO_ERR_NONE; + +} + +int NonBlockingIO_Update( NonBlockingIOHandle *nbioh ) +{ +#ifdef SYS_BB + int ec; + struct timeval waittime; + + fd_set writeset; + fd_set readset; + fd_set exceptset; +#endif + + if ( nbioh == NULL || nbioh->fd < 0 || nbioh->error != NONBLOCKINGIO_ERR_NONE ) + return NONBLOCKINGIO_STATUS_ERROR; + + + if ( nbioh->data == NULL || nbioh->data_pos >= nbioh->data_len ) + return NONBLOCKINGIO_STATUS_COMPLETE; + +#ifdef SYS_PC // not supported on PC yet + nbioh->ERRNO = errno; + if (nbioh->writing) + nbioh->error = NONBLOCKINGIO_ERR_WRITE_FAILED; + else + nbioh->error = NONBLOCKINGIO_ERR_READ_FAILED; + return NONBLOCKINGIO_STATUS_ERROR; +#else // SYS_BB + + // use select to see if connection is read for reading or writing (or both) + // also check for pending connection or other errs + + waittime.tv_sec = 0; + waittime.tv_usec = 0; + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + + FD_SET(nbioh->fd, &readset); + FD_SET(nbioh->fd, &writeset); + FD_SET(nbioh->fd, &exceptset); + + // prts_debug( "Calling select\n" ); + + ec = select( nbioh->fd + 1, &readset, &writeset, &exceptset, &waittime ); + if ( ec < 0 ) + { + + nbioh->error = NONBLOCKINGIO_ERR_SELECT_FAILED; + nbioh->ERRNO = errno; + return NONBLOCKINGIO_STATUS_ERROR; + } + + + if ( nbioh->writing && (!FD_ISSET( nbioh->fd, &writeset ) ) ) + return NONBLOCKINGIO_STATUS_BUSY; + + if ( (!nbioh->writing) && (!FD_ISSET( nbioh->fd, &readset ) ) ) + return NONBLOCKINGIO_STATUS_BUSY; + + + if ( nbioh->writing ) + { + ec = write( nbioh->fd, &((char*)nbioh->data)[nbioh->data_pos], nbioh->data_len - nbioh->data_pos ); + } + else + { + ec = read( nbioh->fd, &((char*)nbioh->data)[nbioh->data_pos], nbioh->data_len - nbioh->data_pos ); + } + + if ( ec < 0 ) + { + if ( nbioh->writing ) + nbioh->error = NONBLOCKINGIO_ERR_WRITE_FAILED; + else + nbioh->error = NONBLOCKINGIO_ERR_READ_FAILED; + nbioh->ERRNO = errno; + return NONBLOCKINGIO_STATUS_ERROR; + } + + if ( ec == 0 && !nbioh->writing ) + { + nbioh->error = NONBLOCKINGIO_ERR_EOF; + return NONBLOCKINGIO_STATUS_ERROR; + } + + nbioh->data_pos += ec; + + if ( nbioh->data_pos >= nbioh->data_len ) + return NONBLOCKINGIO_STATUS_COMPLETE; + + return NONBLOCKINGIO_STATUS_BUSY; +#endif +} + +int NonBlockingIO_Close( NonBlockingIOHandle *nbioh ) +{ + int ec; + if ( nbioh == NULL ) + return NONBLOCKINGIO_ERR_INVALID_HANDLE; + + if ( nbioh->fd < 0 ) + return NONBLOCKINGIO_ERR_NONE; + + + ec = close(nbioh->fd); + if ( ec < 0 ) + { + nbioh->ERRNO = errno; + nbioh->error = NONBLOCKINGIO_ERR_CLOSE_FAILED; + return nbioh->error; + } + + nbioh->fd = -1; + return NONBLOCKINGIO_ERR_NONE; + +} diff --git a/libraries/pmrt/pmrt_utils/filesys.h b/libraries/pmrt/pmrt_utils/filesys.h new file mode 100755 index 0000000..fc20f4d --- /dev/null +++ b/libraries/pmrt/pmrt_utils/filesys.h @@ -0,0 +1,215 @@ +// filesys.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#ifndef FILESYS_H +#define FILESYS_H + +#include "netsock.h" // gives us select on the PC + +#include + +#include + +#if SYS_BB +#include +#include +#include +#endif + +#if SYS_PC +#include +#endif + +// Directory walking structures +#define FS_MAX_FILENAME_LEN 256 + +#if SYS_PC +typedef struct { + struct _finddata_t file; + long hFile; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir + int done; +} FsDH; +#endif // SYS_PC + +#if SYS_BB +typedef struct { + DIR *dir; + struct dirent *ent; + char filename[FS_MAX_FILENAME_LEN]; // place to store filenames while walking dir +} FsDH; +#endif // SYS_BB + +int FsOpenDir(FsDH *fdh, char *dirname ); +int FsCloseDir(FsDH *fdh); +char *FsReadDir(FsDH *fdh); + +int FsDirSize( char *dirname, int recurse ); +int FsDirWalk( char *dirname, int recurse, int actOnDirs, int (*OperationFunc)(char *, void *), void *data); + +int FsDirCountFiles(char *dirname, int recursive); // counts files in directory + +int FsMkDir( char *dirname, int make_parent_dirs ); +int FsRecursiveRmdir(char *dirname); + +// file info functions +int FsFileSize( const char *filename ); + + +unsigned int UtilGetFileSize(FILE *openFile); +int UtilReadFromFile(const char *fileName, const char *fopenFlags, char **buffer, unsigned int *bufferSize); + + +// wrappers for the usual fopen, fread/fwrite, fclose business +int FsLoadFile( char *filename, void **dest, int *dest_len, void *(*malloc_func)(size_t), void (*free_func)(void *) ); +int FsSaveFile( char *filename, void *data, int data_len ); + + +int FsFileCopy( char *srcfile, char *destfile ); +int FsFileMove( char *srcfile, char *destfile ); + + + +// returns FS_ERR_NONE if the file exists and is readable, FS_ERR_INVALID_FILE otherwise +int FsCheckIfFileExists( char *filename ); + +// wrappers for FsLoadFile/FsSaveFile that deal only with ints +// who knows that this is useful for but... +int FsSaveInt( char *filename, int val ); +int FsLoadInt( char *filename, int *val ); + + +enum { + FS_ERR_NONE, + FS_ERR_INVALID_PARAMS, + FS_ERR_INVALID_FILE, + FS_ERR_MALLOC_FAILED, + FS_ERR_WRITE_FAILED, + FS_ERR_READ_FAILED, + +} FS_ERR_CODES; + + + +// Threaded loading stuff +typedef struct { + int status; + char filename[FS_MAX_FILENAME_LEN]; + char mode[8]; + void *data; + int data_len; + void *(*malloc_func)(size_t); + void (*free_func)(void *); + int writing; + int mallocd; + int error; + FILE *fp; + int bytes_readorwrote; + int ERRNO; +} ThreadedFileIOHandle; + +enum { + THREADEDIO_STATUS_BUSY, + THREADEDIO_STATUS_COMPLETE, + THREADEDIO_STATUS_ERROR, +} ThreadedIO_Stati; + +enum { + THREADEDIO_ERR_NONE, + THREADEDIO_ERR_INVALID_PARAMS, + THREADEDIO_ERR_INVALID_HANDLE, + THREADEDIO_ERR_FAILED_TO_START_THREAD, + THREADEDIO_ERR_INVALID_FILE, + THREADEDIO_ERR_MALLOC_FAILED, + THREADEDIO_ERR_OPEN_FAILED, + THREADEDIO_ERR_READ_FAILED, + THREADEDIO_ERR_WRITE_FAILED, + THREADEDIO_ERR_UNKNOWN, + +} ThreadedIO_Error_Codes; + +// an all in one function, will open file and read/write entire contents to/from the passed buffer +// alternately a malloc and free func can be passed and a buffer will be created for read data +// use ThreadedFileIOHandle_GetData to get a ptr to resultant buffer +int ThreadedFileIOHandle_OpenSimple( ThreadedFileIOHandle *tfioh, char *filename, char *mode, + void *data, int data_len, + void *(*malloc_func)(size_t), void (*free_func)(void *) ); + +// opens manual threaded io file handle +// use ThreadedFileIOHandle_Read(), ThreadedFileIOHandle_Write() and ThreadedFileIOHandle_Close() +// to perform read/write/close operations +// use ThreadedFileIOHandle_CheckStatus() to spin while waiting for an operation to complete +int ThreadedFileIOHandle_Open( ThreadedFileIOHandle *tfioh, char *filename, char *mode ); + +// analogs for fread/fwrite +// use ThreadedFileIOHandle_CheckReadWriteBytes() to recover the actual number of +// bytes read/written from/to file (useful in event of an error) +int ThreadedFileIOHandle_Read( ThreadedFileIOHandle *tfioh, void *data, int len ); +int ThreadedFileIOHandle_Write( ThreadedFileIOHandle *tfioh, void *data, int len ); + +int ThreadedFileIOHandle_CheckReadWriteBytes( ThreadedFileIOHandle *tfioh ); + + +int ThreadedFileIOHandle_CheckStatus( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_CheckError( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_CheckErrorno( ThreadedFileIOHandle *tfioh ); + +void *ThreadedFileIOHandle_GetData( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_GetDataLen( ThreadedFileIOHandle *tfioh ); +int ThreadedFileIOHandle_Close( ThreadedFileIOHandle *tfioh ); + + + +// Non-blocking reading/writing +// note that reads/writes may block +// during the actual read/write +// just not before + +typedef struct { + int status; + char filename[FS_MAX_FILENAME_LEN]; + char mode[8]; + int fd; + + void *data; + int data_len; + int data_pos; + + //void *(*malloc_func)(size_t); + //void (*free_func)(void *); + int writing; + //int mallocd; + int error; + int ERRNO; +} NonBlockingIOHandle; + +enum { + NONBLOCKINGIO_STATUS_BUSY, + NONBLOCKINGIO_STATUS_COMPLETE, + NONBLOCKINGIO_STATUS_ERROR, +} NONBLOCKINGIO_Stati; + +enum { + NONBLOCKINGIO_ERR_NONE, + NONBLOCKINGIO_ERR_INVALID_PARAMS, + NONBLOCKINGIO_ERR_INVALID_HANDLE, + NONBLOCKINGIO_ERR_INVALID_FILE, + NONBLOCKINGIO_ERR_OPEN_FAILED, + NONBLOCKINGIO_ERR_SELECT_FAILED, + NONBLOCKINGIO_ERR_READ_FAILED, + NONBLOCKINGIO_ERR_WRITE_FAILED, + NONBLOCKINGIO_ERR_CLOSE_FAILED, + NONBLOCKINGIO_ERR_EOF, + NONBLOCKINGIO_ERR_UNKNOWN, + +} NONBLOCKINGIO_Error_Codes; + +int NonBlockingIO_OpenFile( NonBlockingIOHandle *nbioh, char *filename, char *mode ); +int NonBlockingIO_SetData( NonBlockingIOHandle *nbioh, void *data, int len ); +int NonBlockingIO_GetData( NonBlockingIOHandle *nbioh, void **data, int *len, int *pos ); +int NonBlockingIO_Update( NonBlockingIOHandle *nbioh ); +int NonBlockingIO_Close( NonBlockingIOHandle *nbioh ); + + +#endif diff --git a/libraries/pmrt/pmrt_utils/filesys.o b/libraries/pmrt/pmrt_utils/filesys.o new file mode 100644 index 0000000..d785564 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/filesys.o differ diff --git a/libraries/pmrt/pmrt_utils/icmpSock.h b/libraries/pmrt/pmrt_utils/icmpSock.h new file mode 100755 index 0000000..2f512b6 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/icmpSock.h @@ -0,0 +1,23 @@ +#ifndef PRTS_ICMP_H +#define PRTS_ICMP_H + +#define PING_COMPLETE 0 +#define PING_NOHOST -2 +#define PING_MALLOC_FAIL -3 +#define PING_SOCKET_FAIL -4 +#define PING_SEND_FAIL -5 +#define PING_INVALID_SELECT -6 +#define PING_INVALID_RESULT -7 +#define PING_RECV_FAIL -8 +#define PING_ACTIVE -9 +#define PING_THREAD_FAILED -10 + +#ifdef SYS_PC +#include "icmpSock_pc.h" +#endif +#ifdef SYS_BB +#include "icmpSock_bb.h" +#endif + +#endif + diff --git a/libraries/pmrt/pmrt_utils/icmpSock_bb.c b/libraries/pmrt/pmrt_utils/icmpSock_bb.c new file mode 100755 index 0000000..7a580bc --- /dev/null +++ b/libraries/pmrt/pmrt_utils/icmpSock_bb.c @@ -0,0 +1,167 @@ +#ifdef SYS_BB + +// icmpSock_bb.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "icmpSock.h" + +#include +#include +#include +#include +#include +#include + +//forward decl +unsigned short CheckSum(unsigned short *addr, unsigned len); + +int IcmpPingInitialize(IcmpData *outData, const char *target, unsigned int timeout) +{ + int counter = 0; + int retVal = 0; + + memset(outData, 0, sizeof(IcmpData)); + + outData->to.sin_family = AF_INET; + + //convert from string + outData->to.sin_addr.s_addr = inet_addr(target); + if (outData->to.sin_addr.s_addr != (u_int)-1) + strncpy(outData->hostName, target, 255); + else + { + outData->host = gethostbyname(target); + if (!outData->host) + return PING_NOHOST; + + outData->to.sin_family = outData->host->h_addrtype; + bcopy(outData->host->h_addr, (caddr_t)&outData->to.sin_addr, outData->host->h_length); + + strncpy(outData->hostNameBuf, outData->host->h_name, sizeof(outData->hostNameBuf) - 1); + strncpy(outData->hostName, outData->hostNameBuf, 255); + } + + outData->packLength = DEFDATALEN + MAXIPLEN + MAXICMPLEN; + outData->packet = (u_char *)malloc( (u_int)outData->packLength ); + if(outData->packet == NULL) + return PING_MALLOC_FAIL; + + outData->sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); + if(outData->sock < 0) + return PING_SOCKET_FAIL; + + outData->icp = (Icmp *)outData->outpack; + outData->icp->icmp_type = ICMP_ECHO; + outData->icp->icmp_code = 0; + outData->icp->icmp_cksum = 0; + outData->icp->icmp_seq = 12345; /* seq and id must be reflected */ + outData->icp->icmp_id = getpid(); + + counter = DEFDATALEN + ICMP_MINLEN; + outData->icp->icmp_cksum = CheckSum((unsigned short *)outData->icp, counter); + + gettimeofday(&outData->start, NULL); + + retVal = sendto(outData->sock, (char *)outData->outpack, counter, 0, + (struct sockaddr*)&outData->to, (socklen_t)sizeof(SockAddr_In)); + + if (retVal < 0 || retVal != counter) + { + if (retVal < 0) + return PING_SEND_FAIL; + } + + FD_ZERO(&outData->rfds); + FD_SET(outData->sock, &outData->rfds); + + //wait 100 milliseconds + outData->tv.tv_sec = 2; + outData->tv.tv_usec = 0; + + return 0; +}; + +int IcmpPing(IcmpData *icmpInfo) +{ + int retVal = 0; + int ret = 0; + int fromLength = 0; + int hLength = 0; + SockAddr_In from; + + retVal = select(icmpInfo->sock+1, &icmpInfo->rfds, NULL, NULL, &icmpInfo->tv); + if(retVal == -1) + return PING_INVALID_RESULT; + + if(retVal > 0) + { + fromLength = sizeof(SockAddr_In); + ret = recvfrom( icmpInfo->sock, (char *)icmpInfo->packet, icmpInfo->packLength, + MSG_PEEK,(struct sockaddr *)&from, (socklen_t*)&fromLength); + if (ret < 0) + return PING_RECV_FAIL; + + // check ip header + icmpInfo->ip = (Ip *)((char*)icmpInfo->packet); + hLength = sizeof(Ip); + if (ret < (hLength + ICMP_MINLEN)) + return PING_INVALID_RESULT; + + // check icmp + icmpInfo->icp = (Icmp*)(icmpInfo->packet + hLength); + if (icmpInfo->icp->icmp_type == ICMP_ECHOREPLY) + { + if (icmpInfo->icp->icmp_seq != 12345) + return PING_ACTIVE; + if (icmpInfo->icp->icmp_id != getpid()) + return PING_ACTIVE; + } + else + return PING_ACTIVE; + + gettimeofday(&icmpInfo->end, NULL); + + icmpInfo->time = 1000*(icmpInfo->end.tv_sec - icmpInfo->start.tv_sec) + (float)(icmpInfo->end.tv_usec - icmpInfo->start.tv_usec)/1000.f; + + return PING_COMPLETE; + } + + return PING_ACTIVE; +} + +//from linuxForums.org +unsigned short CheckSum(unsigned short *addr, unsigned len) +{ + unsigned short answer = 0; + + /* + * Our algorithm is simple, using a 32 bit accumulator (sum), we add + * sequential 16 bit words to it, and at the end, fold back all the + * carry bits from the top 16 bits into the lower 16 bits. + */ + unsigned int sum = 0; + while (len > 1) + { + sum += *addr++; + len -= 2; + } + + // mop up an odd byte, if necessary + if (len == 1) + { + *(unsigned char *)&answer = *(unsigned char *)addr ; + sum += answer; + } + + // add back carry outs from top 16 bits to low 16 bits + sum = (sum >> 16) + (sum & 0xffff); // add high 16 to low 16 + sum += (sum >> 16); // add carry + answer = ~sum; // truncate to 16 bits + return answer; +} + +#endif + + diff --git a/libraries/pmrt/pmrt_utils/icmpSock_bb.h b/libraries/pmrt/pmrt_utils/icmpSock_bb.h new file mode 100755 index 0000000..be05100 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/icmpSock_bb.h @@ -0,0 +1,54 @@ +// icmpSock_bb.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef ICMPSOCK_H +#define ICMPSOCK_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define DEFDATALEN (64-ICMP_MINLEN) // default data length */ +#define MAXPACKET (ICMP_MINLEN) // max packet size +#define MAXIPLEN 60 +#define MAXICMPLEN 76 + +typedef struct timeval TimeVal; +typedef struct ip Ip; +typedef struct icmp Icmp; +typedef struct sockaddr_in SockAddr_In; +typedef struct hostent HostEnt; + +typedef struct _IcmpData +{ + HostEnt *host; + SockAddr_In to; + Icmp *icp; + Ip *ip; + TimeVal tv, start, end; + fd_set rfds; + u_char *packet, outpack[MAXPACKET]; + char hostNameBuf[MAXHOSTNAMELEN], hostName[255]; + int fromLength, retVal, time, packLength; + int sock; + +}IcmpData; + +int IcmpPing(IcmpData *icmpData); +int IcmpPingInitialize(IcmpData *outData, const char *target, unsigned int timeout); + +int PingQueryTime(); + +#endif + + diff --git a/libraries/pmrt/pmrt_utils/icmpSock_bb.o b/libraries/pmrt/pmrt_utils/icmpSock_bb.o new file mode 100644 index 0000000..4bf757c Binary files /dev/null and b/libraries/pmrt/pmrt_utils/icmpSock_bb.o differ diff --git a/libraries/pmrt/pmrt_utils/icmpSock_pc.c b/libraries/pmrt/pmrt_utils/icmpSock_pc.c new file mode 100755 index 0000000..b6c1245 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/icmpSock_pc.c @@ -0,0 +1,58 @@ +#ifdef SYS_PC + +// icmpSock_bb.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +//need to be declared before includes +typedef struct _MIBICMPSTATS_EX +{ + unsigned long dwMsgs; + unsigned long dwErrors; + unsigned long rgdwTypeCount[256]; +} MIBICMPSTATS_EX, *PMIBICMPSTATS_EX; +typedef struct _MIB_ICMP_EX +{ + MIBICMPSTATS_EX icmpInStats; + MIBICMPSTATS_EX icmpOutStats; +} MIB_ICMP_EX,*PMIB_ICMP_EX; + +#include +#include +#include +#include "icmpSock.h" + +//forward decl +unsigned short CheckSum(unsigned short *addr, unsigned len); + +int IcmpPing(const char *target) +{ + HANDLE hIcmp; + char *sendData = "ICMP SEND DATA"; + LPVOID replyBuffer; + DWORD retVal; + DWORD buflen; + PICMP_ECHO_REPLY pIcmpEchoReply; + + hIcmp = IcmpCreateFile(); + + buflen = sizeof(ICMP_ECHO_REPLY) + strlen(sendData) + 1; + replyBuffer = (VOID*) malloc(buflen); + if (replyBuffer == 0) + return PING_INVALID_RESULT; + + memset(replyBuffer, 0, buflen); + pIcmpEchoReply = (PICMP_ECHO_REPLY)replyBuffer; + + retVal = IcmpSendEcho(hIcmp, + inet_addr(target), + sendData, strlen(sendData), + NULL, replyBuffer, + buflen, + 1000); + + return pIcmpEchoReply->RoundTripTime; +} + +#endif \ No newline at end of file diff --git a/libraries/pmrt/pmrt_utils/icmpSock_pc.h b/libraries/pmrt/pmrt_utils/icmpSock_pc.h new file mode 100755 index 0000000..7098617 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/icmpSock_pc.h @@ -0,0 +1,7 @@ +#ifndef ICMP_PC +#define ICMP_PC + +int IcmpPing(const char *target); +int PingQueryTime(); + +#endif \ No newline at end of file diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo.c b/libraries/pmrt/pmrt_utils/interfaceInfo.c new file mode 100755 index 0000000..5875403 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/interfaceInfo.c @@ -0,0 +1,194 @@ +// interfaceInfo_pc.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#include "interfaceInfo.h" + +#include +#include +#include "pmrt_strings.h" + + +#if SYS_BB +#endif + +#if (_MSC_VER >= 1200) +#pragma warning(push) +#pragma warning( disable : 4013 ) // 'blah' undfined; assuming extern returning int +#endif + + +int NetGetHostName(char *name,unsigned int size) +{ + int ec=0; + + if(gethostname(name,size) != 0) + { + if(size) + name[0]=0; + ec = -1; + } + return(ec); +} + + +#if (_MSC_VER >= 1200) +#pragma warning(pop) +#endif + + +int GetDefaultGateway(char *gw_addr, int gw_addr_len, char *interfaceName, int interfaceName_len ) +{ + int ec = 0; + FILE *fd; + int index; + char buf[256]; + char buf2[64]; + char ifname[32]; + char gw[32]; + //char destnet_s[32]; + //char destmask_s[32]; + //char gw_s[32]; + + int b1,b2,b3,b4; + + // return 0.0.0.0 if not found + strncpy( gw_addr, "0.0.0.0", gw_addr_len ); + memset( interfaceName, 0, interfaceName_len ); + +#if SYS_PC + fd = fopen( "proc_net_route", "rb" ); +#else + fd = fopen( "/proc/net/route", "rb" ); +#endif + if ( fd == NULL ) + return -1; + + + while( fgets(buf, sizeof(buf), fd ) != NULL ) + { + if ( strncmp( buf, "Iface", 5) == 0 ) + continue; + // format of file tab seperated colomns of form: + // eth0 0001000A 00000000 0001 0 0 0 00FFFFFF 0 0 0 + //buf[7] = '\0'; // terminate ifname + //buf[16] = '\0'; // terminate dest addr + //buf[32] = '\0'; // terminate gw addr + //buf[80] = '\0'; // terminate dest mask + //ifname = &buf[0]; + //destnet_s = &buf[8]; + //gw_s = &buf[24]; + //destmask_s = &buf[72]; + + index = 0; + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + strncpy(ifname,buf2,sizeof(ifname)); + + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + // sscanf(buf2, "%X", &destnet ); + sscanf(buf2, "%2X%2X%2X%2X", &b4, &b3, &b2, &b1 ); + if ( b4 != 0 || b3 != 0 || b2 != 0 || b1 != 0 ) + { + continue; + } + + // this is our gateway + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + sscanf(buf2, "%2X%2X%2X%2X", &b4, &b3, &b2, &b1 ); + sprintf( gw, "%d.%d.%d.%d", b1, b2, b3, b4 ); + // snprintf( gw, sizeof(gw), "%d.%d.%d.%d", b1, b2, b3, b4 ); + + + // skip next 4 fields + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + sscanf(buf2, "%2X%2X%2X%2X", &b4, &b3, &b2, &b1 ); + if ( b4 != 0 || b3 != 0 || b2 != 0 || b1 != 0 ) + { + continue; + } + + strncpy( gw_addr, gw, gw_addr_len ); + strncpy( interfaceName, ifname, interfaceName_len ); + + + + } + return 0; +} + +int GetRoute(unsigned int dest_ipaddr, unsigned int *gateway_address, unsigned int *network_address, unsigned int *netmask, char *interfaceName, int interfaceName_len ) +{ + int ec = 0; + FILE *fd; + int index; + char buf[256]; + char buf2[64]; + char ifname[32]; + //char destnet_s[32]; + //char destmask_s[32]; + //char gw_s[32]; + + int b1,b2,b3,b4; + + /* + unsigned int destnet; + unsigned int destmask; + unsigned int gw; + */ +#if SYS_PC + fd = fopen( "proc_net_route", "rb" ); +#else + fd = fopen( "/proc/net/route", "rb" ); +#endif + if ( fd == NULL ) + return -1; + + memset( interfaceName, 0, interfaceName_len ); + + while( fgets(buf, sizeof(buf), fd ) != NULL ) + { + if ( strncmp( buf, "Iface", 5) == 0 ) + continue; + // format of file tab seperated colomns of form: + // eth0 0001000A 00000000 0001 0 0 0 00FFFFFF 0 0 0 + //buf[7] = '\0'; // terminate ifname + //buf[16] = '\0'; // terminate dest addr + //buf[32] = '\0'; // terminate gw addr + //buf[80] = '\0'; // terminate dest mask + //ifname = &buf[0]; + //destnet_s = &buf[8]; + //gw_s = &buf[24]; + //destmask_s = &buf[72]; + + index = 0; + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + strncpy(ifname,buf2,sizeof(ifname)); + + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + // sscanf(buf2, "%X", &destnet ); + sscanf(buf2, "%2X%2X%2X%2X", &b4, &b3, &b2, &b1 ); + + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + sscanf(buf2, "%2X%2X%2X%2X", &b4, &b3, &b2, &b1 ); + + // skip next 4 fields + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + + index = StringCopyUntilChar( buf, index, strlen(buf), buf2, sizeof(buf2), '\t' ); + sscanf(buf2, "%2X%2X%2X%2X", &b4, &b3, &b2, &b1 ); + + + } + return ec; +} +//EOF + + diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo.h b/libraries/pmrt/pmrt_utils/interfaceInfo.h new file mode 100755 index 0000000..d63de1d --- /dev/null +++ b/libraries/pmrt/pmrt_utils/interfaceInfo.h @@ -0,0 +1,20 @@ +#ifndef PMRT_NET_INTERFACE +#define PMRT_NET_INTERFACE + + +int NetGetHostName(char *name,unsigned int size); +int EthToolCableStatus(const char *interfaceName); +int GetDefaultGateway(char *gw_addr, int gw_addr_len, char *interfaceName, int interfaceName_len ); +int GetMacAddress(const char *interfaceName, char *outMacAddress); + +#ifdef SYS_PC + #include "interfaceInfo_pc.h" +#endif + +#ifdef SYS_BB + #include "interfaceInfo_bb.h" +#endif + + +#endif //PRMT_NET_INTERFACE + diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo.o b/libraries/pmrt/pmrt_utils/interfaceInfo.o new file mode 100644 index 0000000..e14a368 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/interfaceInfo.o differ diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo_bb.c b/libraries/pmrt/pmrt_utils/interfaceInfo_bb.c new file mode 100755 index 0000000..66a59e6 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/interfaceInfo_bb.c @@ -0,0 +1,133 @@ +#ifdef SYS_BB + +// interfaceInfo_bb.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#include "interfaceInfo_bb.h" +#include "cguardian.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//needed by ethtool.h +#ifdef USE_FEDORA +#include +typedef __u64 u64; +typedef __u32 u32; +typedef __u16 u16; +typedef __u8 u8; +#else +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +#endif + +#include + +#include + +int GetInterfaceIpAddress(const char *interfaceName, unsigned int *ipaddr, unsigned int *netmask) +{ + int ec = 0, sock; + struct ifreq ifr; + + *ipaddr = 0; + *netmask = 0; + + if( (sock = socket(PF_INET, SOCK_DGRAM, 0) ) >= 0) + { + strcpy(ifr.ifr_name, interfaceName); + if(ioctl(sock,SIOCGIFADDR,&ifr)<0) + ec=-1; + else + memcpy(ipaddr,&(ifr.ifr_addr.sa_data[2]),4); + + if(ioctl(sock,SIOCGIFNETMASK,&ifr)>=0) + memcpy(netmask,&(ifr.ifr_netmask.sa_data[2]),4); + + close(sock); + } + else + ec = -1; + + return ec; +} + +int EthToolCableStatus(const char *interfaceName) +{ + struct ifreq ifReq; + struct ethtool_value eData; + int sock = 0; + + memset(&ifReq, 0, sizeof(ifReq)); + eData.cmd = ETHTOOL_GLINK; + + if( (sock = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) + { + prts_debug("ethtool: socket error \n"); + return -1; + } + + strncpy(ifReq.ifr_name, interfaceName, sizeof(ifReq.ifr_name)-1); + ifReq.ifr_data = (char *)&eData; + + if (ioctl(sock, SIOCETHTOOL, &ifReq) == -1) + { + prts_debug("ethtool: ioctl failed\n"); + close(sock); + return -1; + } + + close(sock); + return (eData.data ? 1 : 0); +} + +/*! + \author RA + \date 2007/12/05 + \param interfaceName eth0, eth1, .. + \param outMac must be large enough to hold mac address + \return int 0 on success, -1 on fail +*/ +int GetMacAddress(const char *interfaceName, char *outMac) +{ + int ec = 0, sock; + struct ifreq ifr; + + if( (sock = socket(PF_INET, SOCK_DGRAM, 0) ) >= 0) + { + strcpy(ifr.ifr_name, interfaceName); + + if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0) + ec=-1; + else + { + unsigned char *mac = (unsigned char*)&ifr.ifr_ifru.ifru_hwaddr.sa_data[0]; + + sprintf(outMac, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + } + close(sock); + } + else + ec = -1; + + return ec; +} + +#endif //SYS_BB + +//EOF + + diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo_bb.h b/libraries/pmrt/pmrt_utils/interfaceInfo_bb.h new file mode 100755 index 0000000..6c52536 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/interfaceInfo_bb.h @@ -0,0 +1,16 @@ +// interfaceInfo_bb.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef INTERFACE_INFO_H +#define INTERFACE_INFO_H + +#include + +int GetInterfaceIpAddress(const char *interfaceName, unsigned int *ipaddr, unsigned int *netmask); + +#endif + + + diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo_bb.o b/libraries/pmrt/pmrt_utils/interfaceInfo_bb.o new file mode 100644 index 0000000..15831f1 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/interfaceInfo_bb.o differ diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo_pc.c b/libraries/pmrt/pmrt_utils/interfaceInfo_pc.c new file mode 100755 index 0000000..1011a16 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/interfaceInfo_pc.c @@ -0,0 +1,124 @@ +#ifdef SYS_PC + +// interfaceInfo_pc.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include +#include +#include + +#include "interfaceInfo_pc.h" + +typedef struct _ASTAT_ +{ + ADAPTER_STATUS adapt; + NAME_BUFFER NameBuff [30]; +}ASTAT, * PASTAT; + +ASTAT Adapter; + +int GetInterfaceIpAddress(const char *name, unsigned int *ipaddr, unsigned int *netmask) +{ + char cn[512]; + int i,ec=0; + HOSTENT *he; + + *ipaddr=0; + *netmask=0; + + if(gethostname(cn,sizeof(cn)) == 0) + { + if((he=gethostbyname(cn)) != NULL) + { + for (i = 0; he->h_addr_list[i] != 0; ++i) + memcpy(ipaddr, he->h_addr_list[i], sizeof(struct in_addr)); + } + else + ec = -1; + + } + else + ec = -1; + + return ec; +} + +int EthToolCableStatus(const char *interfaceName) +{ + return 0; +} + +//Note: outMac should be large enough (35 bytes) to hold mac address +//taken from msdn +int GetMacAddress(const char *interfaceName, char *outMac) +{ + NCB Ncb; + unsigned char uRetCode; + LANA_ENUM lenum; + int i = 0; + + memset( &Ncb, 0, sizeof(Ncb) ); + Ncb.ncb_command = NCBENUM; + Ncb.ncb_buffer = (UCHAR *)&lenum; + Ncb.ncb_length = sizeof(lenum); + uRetCode = Netbios( &Ncb ); + + for(i=0; i < lenum.length ;i++) + { + memset( &Ncb, 0, sizeof(Ncb) ); + Ncb.ncb_command = NCBRESET; + Ncb.ncb_lana_num = lenum.lana[i]; + + uRetCode = Netbios( &Ncb ); + + memset( &Ncb, 0, sizeof (Ncb) ); + Ncb.ncb_command = NCBASTAT; + Ncb.ncb_lana_num = lenum.lana[i]; + + strcpy( Ncb.ncb_callname, "* " ); + Ncb.ncb_buffer = (char *)&Adapter; + Ncb.ncb_length = sizeof(Adapter); + + uRetCode = Netbios( &Ncb ); + if ( uRetCode == 0 ) + { + sprintf(outMac, "%02x:%02x:%02x:%02x:%02x:%02x", + Adapter.adapt.adapter_address[0], + Adapter.adapt.adapter_address[1], + Adapter.adapt.adapter_address[2], + Adapter.adapt.adapter_address[3], + Adapter.adapt.adapter_address[4], + Adapter.adapt.adapter_address[5] ); + + return 0; + } + } + + return -1; +} + +/* +int GetRoute(unsigned int dest_ipaddr, unsigned int *gateway_address, unsigned int *network_address, unsigned int *netmask, char *interfaceName, int interfaceName_len ) +{ + + if ( gateway_address != NULL ) + *gateway_address = 0; + if ( network_address != NULL ) + *network_address = 0; + if ( netmask != NULL ) + *netmask = 0; + + memset( interfaceName, 0, interfaceName_len ); + + return 0; +} +*/ +#endif//SYS_PC + diff --git a/libraries/pmrt/pmrt_utils/interfaceInfo_pc.h b/libraries/pmrt/pmrt_utils/interfaceInfo_pc.h new file mode 100755 index 0000000..cd54f8f --- /dev/null +++ b/libraries/pmrt/pmrt_utils/interfaceInfo_pc.h @@ -0,0 +1,14 @@ +// interfaceInfo_pc.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef INTERFACE_INFO_H +#define INTERFACE_INFO_H + +#include + +int GetInterfaceIpAddress(const char *interfaceName, unsigned int *ipaddr, unsigned int *netmask); + +#endif + diff --git a/libraries/pmrt/pmrt_utils/libpmrt_utils.a b/libraries/pmrt/pmrt_utils/libpmrt_utils.a new file mode 100644 index 0000000..6de64d3 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/libpmrt_utils.a differ diff --git a/libraries/pmrt/pmrt_utils/makedeplib b/libraries/pmrt/pmrt_utils/makedeplib new file mode 100644 index 0000000..b3cf3c6 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/makedeplib @@ -0,0 +1,452 @@ +memallochist.o: memallochist.c memallochist.h cguardian.h node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h +netsock_bb.o: netsock_bb.c netsock.h netsock_bb.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h cguardian.h node.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h +node.o: node.c node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h +thread_pc.o: thread_pc.c +netclient.o: netclient.c netclient.h netsock.h netsock_bb.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h microtime.h node.h cguardian.h \ + /usr/include/string.h +netsock_pc.o: netsock_pc.c +thread_bb.o: thread_bb.c thread.h thread_bb.h /usr/include/pthread.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/sched.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/bits/sched.h /usr/include/bits/time.h \ + /usr/include/signal.h /usr/include/bits/sigset.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h cguardian.h node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h memallochist.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h +tsqueue.o: tsqueue.c tsqueue.h thread.h thread_bb.h \ + /usr/include/pthread.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/sched.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/bits/sched.h /usr/include/bits/time.h \ + /usr/include/signal.h /usr/include/bits/sigset.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/string.h +cguardian.o: cguardian.c cguardian.h thread.h thread_bb.h \ + /usr/include/pthread.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/sched.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/bits/sched.h /usr/include/bits/time.h \ + /usr/include/signal.h /usr/include/bits/sigset.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h filesys.h netsock.h netsock_bb.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/string.h \ + /usr/include/sys/ptrace.h /usr/include/sys/wait.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/sys/mman.h /usr/include/bits/mman.h /usr/include/link.h \ + /usr/include/elf.h /usr/include/dlfcn.h /usr/include/bits/dlfcn.h \ + /usr/include/bits/elfclass.h +microtime.o: microtime.c microtime.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/sys/time.h /usr/include/asm/msr.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/linux/rtc.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/string.h +interfaceInfo.o: interfaceInfo.c interfaceInfo.h interfaceInfo_bb.h \ + /usr/include/unistd.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h pmrt_strings.h +interfaceInfo_bb.o: interfaceInfo_bb.c interfaceInfo_bb.h \ + /usr/include/unistd.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/confname.h \ + /usr/include/getopt.h cguardian.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/net/if.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \ + /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h \ + /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \ + /usr/include/linux/rtc.h /usr/include/sys/klog.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/stdlib.h /usr/include/alloca.h \ + /usr/include/string.h /usr/include/linux/ethtool.h \ + /usr/include/linux/sockios.h +icmpSock_bb.o: icmpSock_bb.c icmpSock.h icmpSock_bb.h \ + /usr/include/arpa/inet.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/wordsize.h \ + /usr/include/bits/types.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/sys/file.h \ + /usr/include/fcntl.h /usr/include/bits/fcntl.h /usr/include/sys/time.h \ + /usr/include/netinet/in_systm.h /usr/include/netinet/ip.h \ + /usr/include/netinet/ip_icmp.h /usr/include/netdb.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/ctype.h /usr/include/stdlib.h /usr/include/alloca.h +containers.o: containers.c containers.h /usr/include/stdlib.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h containerCommon.h \ + /usr/include/string.h node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h +containerCommon.o: containerCommon.c containerCommon.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +audcrc.o: audcrc.c audcrc.h /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +dnslookup.o: dnslookup.c dnslookup.h netsock.h netsock_bb.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h thread.h thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /usr/include/string.h +textfile.o: textfile.c textfile.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h +filesys.o: filesys.c filesys.h netsock.h netsock_bb.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h thread.h thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /usr/include/string.h +pmrt_strings.o: pmrt_strings.c pmrt_strings.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h +rtdatatypes.o: rtdatatypes.c rtdatatypes.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + pmrt_utils.h node.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h memallochist.h \ + netsock.h netsock_bb.h /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + netclient.h microtime.h thread.h thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h tsqueue.h cguardian.h containerCommon.h \ + containers.h audcrc.h icmpSock.h icmpSock_bb.h /usr/include/sys/param.h \ + /usr/include/linux/param.h /usr/include/asm/param.h \ + /usr/include/sys/file.h /usr/include/sys/time.h \ + /usr/include/netinet/in_systm.h /usr/include/netinet/ip.h \ + /usr/include/netinet/ip_icmp.h dnslookup.h interfaceInfo.h \ + interfaceInfo_bb.h textfile.h filesys.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h pmrt_strings.h diff --git a/libraries/pmrt/pmrt_utils/makefile b/libraries/pmrt/pmrt_utils/makefile new file mode 100755 index 0000000..57932c0 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/makefile @@ -0,0 +1,39 @@ +# make driver +# make install (as root) +# +.CLIBFILES = memallochist.c netsock_bb.c node.c thread_pc.c netclient.c netsock_pc.c thread_bb.c tsqueue.c cguardian.c microtime.c interfaceInfo.c interfaceInfo_bb.c icmpSock_bb.c containers.c containerCommon.c audcrc.c dnslookup.c textfile.c filesys.c pmrt_strings.c rtdatatypes.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libpmrt_utils.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -Wno-implicit -O0 -g -DSYS_BB -DPRODUCTION +# use this next line if building on Fedora Linux +#CFLAGS += -DUSE_INTERNAL_RDTSC -DUSE_FEDORA + +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) + -mkdir /g3/include/pmrt_utils + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/pmrt_utils + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/pmrt_utils/memallochist.c b/libraries/pmrt/pmrt_utils/memallochist.c new file mode 100755 index 0000000..1b5654f --- /dev/null +++ b/libraries/pmrt/pmrt_utils/memallochist.c @@ -0,0 +1,82 @@ +// memallochist.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// utility funcs for tracking memory that's being malloc'd and freed + +#include "memallochist.h" +#include "cguardian.h" +#include "node.h" +#include // for memset + + +int InitMemAllocHistory() +{ +#if !PRODUCTION + memset( gMemAllocHistory, 0, sizeof(gMemAllocHistory) ); +#endif + return 0; +} + +void AddToMemAllocHistory( void *addr, int size ) +{ +#if !PRODUCTION + int i; + for ( i = 0; i < MALLOC_HIST_SIZE; i++ ) + { + if ( gMemAllocHistory[i].size == 0 ) + { + gMemAllocHistory[i].addr = addr; + gMemAllocHistory[i].size = size; + // prts_debug( "Alloc'd %d bytes at %p\n", size, addr ); + return; + } + } + prts_debug( "NO ROOM FOR %p (size=%d)!\n", addr,size ); + +#endif +} + +void DelFromMemAllocHistory( void *addr ) +{ +#if !PRODUCTION + int i; + for ( i = 0; i < MALLOC_HIST_SIZE; i++ ) + { + if ( gMemAllocHistory[i].addr == addr ) + { +// prts_debug( "Free'd %d bytes at %p\n", gMemAllocHistory[i].size, addr ); + gMemAllocHistory[i].addr = 0; + gMemAllocHistory[i].size = 0; + return; + } + } + prts_debug( "INVALID FREE OF %p!\n", addr ); + +#endif +} + +void PrintMemAllocHistory() +{ +#if !PRODUCTION + void *addr; + int size; + int i; + int count=0; + prts_debug("Mem Alloc History:\n"); + for ( i = 0; i < MALLOC_HIST_SIZE; i++ ) + { + if ( gMemAllocHistory[i].size != 0 ) + { + addr = gMemAllocHistory[i].addr; + size = gMemAllocHistory[i].size; + prts_debug( " Alloc Table: %d bytes at %p\n", size, addr ); + count++; + } + } + prts_debug(" Total Entries: %d\n", count); + prts_debug("\n"); +#endif +} + + diff --git a/libraries/pmrt/pmrt_utils/memallochist.h b/libraries/pmrt/pmrt_utils/memallochist.h new file mode 100755 index 0000000..16c23d6 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/memallochist.h @@ -0,0 +1,29 @@ +#ifndef MEMALLOCHIST_H +#define MEMALLOCHIST_H +// memallochist.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + + +#define MALLOC_HIST_SIZE 8000 + +struct malloc_rec +{ + void *addr; + int size; +}; + + +struct malloc_rec gMemAllocHistory[MALLOC_HIST_SIZE]; + +int InitMemAllocHistory(); +void AddToMemAllocHistory( void *addr, int size ); +void DelFromMemAllocHistory( void *addr ); +void PrintMemAllocHistory(); + + +#endif + + + diff --git a/libraries/pmrt/pmrt_utils/memallochist.o b/libraries/pmrt/pmrt_utils/memallochist.o new file mode 100644 index 0000000..52119bd Binary files /dev/null and b/libraries/pmrt/pmrt_utils/memallochist.o differ diff --git a/libraries/pmrt/pmrt_utils/microtime.c b/libraries/pmrt/pmrt_utils/microtime.c new file mode 100755 index 0000000..9bbc268 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/microtime.c @@ -0,0 +1,320 @@ + // microtime.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for obtaining time in micro second + +#include "microtime.h" + +#if SYS_PC +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include + +// returns time since system boot in micro seconds +// borrowed straight from sys_pc.c +uns64 GetSysElapsedMicroseconds() +{ + static double os_us_freq_d = 0.0; + static LARGE_INTEGER os_us_freq; + LARGE_INTEGER li; + double d; + double s; + uns64 retval; + + + + // initialize + if ( os_us_freq_d == 0 ) + { + // get system clock speed + QueryPerformanceFrequency(&os_us_freq); + os_us_freq_d = (double)(os_us_freq.QuadPart); + os_us_freq_d /= 1000000.0f; // change to micro secs + } + + + QueryPerformanceCounter(&li); + d = (double)(li.QuadPart); + s = d/os_us_freq_d; + retval = (uns64)s; + return retval; + +} +#endif + +#if SYS_BB + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// forward declaration of required helper func +float MicroTimeGetPTimerResolution(void); + +// returns time since system boot in micro seconds +// borrowed straight from sys_bb.c + + +uns64 GetSysElapsedMicroseconds() +{ + static float sysPTimerResolution = 0.0f; // Performance timer millions of ticks per second + uns64 retval; + double fTime; + uns32 time_low, time_high; + + // initialize + if ( sysPTimerResolution == 0.0f ) + { + sysPTimerResolution = MicroTimeGetPTimerResolution(); + + } + + + rdtsc(time_low, time_high); + retval = ((uns64)time_high << 32) + (uns64)time_low; + + fTime = (double)retval; + fTime = fTime/(double)sysPTimerResolution; + retval = (uns64)fTime; + return(retval); + +} + + + + +// +// xSysGetPTimerResolution +// get system performance timer resolution +// in millions of ticks per second +float MicroTimeGetPTimerResolution(void) +{ + char path_to_procfile[32]; + char cpuinfo_buffer[256]; + int procfile = 0; + int index; + char *ptr = NULL; + float cpuspeed_inMhz = 0.0f; + + // read cpu speed from /proc/cpuinfo + sprintf(path_to_procfile, "/proc/cpuinfo"); + procfile = open(path_to_procfile, O_RDONLY); + index = read(procfile, cpuinfo_buffer, sizeof(cpuinfo_buffer)-1); + cpuinfo_buffer[index] = '\0'; + close(procfile); + ptr = strstr(cpuinfo_buffer, "MHz"); + ptr = strstr(ptr, ":"); + + // search for first non-whitespace character, or just... + ptr += 2; + + // got the cpuspeed! + sscanf(ptr, "%f", &cpuspeed_inMhz); + return(cpuspeed_inMhz); +} +#endif + + +uns32 GetSysElapsedMilliseconds() +{ + uns64 microsecs; + uns32 retval; + microsecs = GetSysElapsedMicroseconds(); + microsecs /= 1000; + retval = microsecs; + return retval; +} + + +void PMRT_Timer_Reset( PMRT_Timer *timer ) +{ + if ( timer == NULL ) + return; + + timer->accumulated_time = 0; + timer->start_time = 0; + timer->running = 0; + +} + + +void PMRT_Timer_Start( PMRT_Timer *timer ) +{ + if ( timer == NULL ) + return; + timer->start_time = GetSysElapsedMicroseconds(); + timer->running = 1; +} + + +void PMRT_Timer_Stop( PMRT_Timer *timer ) +{ + if ( timer == NULL ) + return; + timer->accumulated_time += PMRT_Timer_GetElapsedMicroseconds(timer); + timer->start_time = 0; + timer->running = 0; +} + + +uns64 PMRT_Timer_GetElapsedMicroseconds( PMRT_Timer *timer ) +{ + if ( timer == NULL ) + return 0; + + if ( ! timer->running ) + return timer->accumulated_time; + else + return (GetSysElapsedMicroseconds() - timer->start_time) + timer->accumulated_time; +} + +uns32 PMRT_Timer_GetElapsedMilliseconds( PMRT_Timer *timer ) +{ + uns32 retval; + uns64 micro; + + if ( timer == NULL ) + return 0; + + micro = PMRT_Timer_GetElapsedMicroseconds(timer); + micro /= 1000; + retval = micro; // cast down to 32 bits + return retval; +} + + +long SysDateTime_Utils(SysDate_Utils *dt,uns flags) +{ + time_t t; + struct tm *tm; + + if(!dt) + return -1; + if((t=time(NUL))<0) + return -1; + + if(!(flags&M_SYSTIMEDATE_GMT)) + tm=localtime(&t); + else + tm=gmtime(&t); + + if(!tm) + return -1; + + SysCopytmToSysDate_Utils(tm,dt); + + return(t); +} // SysDateTime() + + +// SysCopytmToSysDate +// copy the values from tm struct to the SysDate struct +// +// GNP 16APR07 +void SysCopytmToSysDate_Utils(void *tmv,SysDate_Utils *dt) +{ + struct tm *tms = tmv; + + dt->sec=tms->tm_sec; + dt->min=tms->tm_min; + dt->hour=tms->tm_hour; + dt->mday=tms->tm_mday; + dt->mon=tms->tm_mon; + dt->year=tms->tm_year; + dt->wday=tms->tm_wday; + dt->yday=tms->tm_yday; + dt->isdst=tms->tm_isdst; +} //SysCopytmToSysDate + + +// DateChangesBetweenDates: +// Returns how many times midnight passes between two dates +// in the form: firstTime - secondTime +// +// Unless noSign is set, results are positive if firstTime is +// later than secondTime and negative otherwise. +// +// param: firstTime and secondTime are valid time_t. +// noSign should be nonzero to always return positive results +// +// GTR 30Nov2007 +#define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400))) +#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365) +int DateChangesBetweenDates(time_t firstTime_t, time_t secondTime_t, int noSign) +{ + struct tm firstTime, secondTime; + struct tm *tmpTime; + int i; + int days = 0; + + tmpTime = localtime(&firstTime_t); + if (!tmpTime) + return 0; + memcpy(&firstTime, tmpTime, sizeof(struct tm)); + + tmpTime = localtime(&secondTime_t); + if (!tmpTime) + return 0; + memcpy(&secondTime, tmpTime, sizeof(struct tm)); + + // secondTime is in an earlier year than firstTime + if (firstTime.tm_year > secondTime.tm_year) + { + // what remains of secondTime's year + days += (YEARSIZE(secondTime.tm_year) - secondTime.tm_yday); + + // full years between (non-inclusive) + for(i = secondTime.tm_year + 1; i < firstTime.tm_year; i++) + { + days += (YEARSIZE(i)); + } + + // part of firstTime's year + days -= firstTime.tm_yday; + } + else if (firstTime.tm_year < secondTime.tm_year) + // firstTime is in an earlier year than secondTime + { + // what remains of firstTime's year + days -= (YEARSIZE(firstTime.tm_year) - firstTime.tm_yday); + + // full years between (non-inclusive) + for(i = firstTime.tm_year + 1; i < secondTime.tm_year; i++) + { + days -= (YEARSIZE(i)); + } + + // part of secondTime's year + days -= secondTime.tm_yday; + } + else // same year + { + // difference in days + days = firstTime.tm_yday - secondTime.tm_yday; + } + + if (noSign != 0 && days < 0) + days *= -1; + + return days; +} + + + + + + diff --git a/libraries/pmrt/pmrt_utils/microtime.h b/libraries/pmrt/pmrt_utils/microtime.h new file mode 100755 index 0000000..b3703ad --- /dev/null +++ b/libraries/pmrt/pmrt_utils/microtime.h @@ -0,0 +1,73 @@ +// microtime.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for obtaining time in micro second + +#ifndef MICROTIME_H +#define MICROTIME_H + +#include +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + + +#ifdef USE_INTERNAL_RDTSC +#define rdtsc(low,high) \ +__asm__ __volatile__(".byte 0x0f, 0x31" : "=a" (low), "=d" (high)) +#endif + +// returns time since system boot in micro seconds +uns64 GetSysElapsedMicroseconds(); + +// returns time since system boot in milli seconds +uns32 GetSysElapsedMilliseconds(); + +typedef struct PMRT_Timer +{ + uns64 start_time; + uns64 accumulated_time; + int running; +} PMRT_Timer; + +void PMRT_Timer_Start( PMRT_Timer *timer ); +void PMRT_Timer_Stop( PMRT_Timer *timer ); +void PMRT_Timer_Reset( PMRT_Timer *timer ); + +uns64 PMRT_Timer_GetElapsedMicroseconds( PMRT_Timer *timer ); +uns32 PMRT_Timer_GetElapsedMilliseconds( PMRT_Timer *timer ); + + + +int DateChangesBetweenDates(time_t firstTime_t, time_t secondTime_t, int noSign); + +#ifndef SYS_UTILS +#define SYS_UTILS +#define M_SYSTIMEDATE_GMT 0x0001 + +typedef struct { + int sec; // 0..61(?) + int min; // 0..59 + int hour; // 0..23 + int mday; // 1..31 + int mon; // 0..11 + int year; // eg 2005 + int wday; // 0..6 Sunday==0 + int yday; // since jan 1 0..365 + int isdst; // is daylight savings time +} SysDate_Utils; + +long SysDateTime_Utils(SysDate_Utils *dt,uns flags); +void SysCopytmToSysDate_Utils(void *tmv,SysDate_Utils *dt); + +#endif + + + + + + + +#endif // define MICROTIME_H + diff --git a/libraries/pmrt/pmrt_utils/microtime.o b/libraries/pmrt/pmrt_utils/microtime.o new file mode 100644 index 0000000..ea846d5 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/microtime.o differ diff --git a/libraries/pmrt/pmrt_utils/mssccprj.scc b/libraries/pmrt/pmrt_utils/mssccprj.scc new file mode 100755 index 0000000..18ce006 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[pmrt_utils.dsp] +SCC_Aux_Path = "\\vss-nas-1\PM_Utilities\" +SCC_Project_Name = "$/libraries/pmrt/pmrt_utils", LADAAAAA diff --git a/libraries/pmrt/pmrt_utils/netclient.c b/libraries/pmrt/pmrt_utils/netclient.c new file mode 100755 index 0000000..f9c9434 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netclient.c @@ -0,0 +1,282 @@ +// netclient.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +#include "netclient.h" + +#include "cguardian.h" + +#include "node.h" + +#include +#include +#include +#include + + +int InitClientStateStruct(ClientStateStruct *clientstate, + char *server_ip, int server_port, + char *send_buf, int send_buf_size, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int (*eod_check)(struct ClientStateStruct*), + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout ) +{ + if ( clientstate == NULL ) + return -1; + + memset( clientstate,0, sizeof(ClientStateStruct) ); + + strcpy(clientstate->server_ip, server_ip); + clientstate->server_port = server_port; + + clientstate->state = CLIENT_STATE_OPEN_CONNECTION; + clientstate->error_code = CLIENT_ERR_NONE; + clientstate->send_buf = send_buf; + clientstate->send_buf_size = send_buf_size; + clientstate->recv_buf = recv_buf; + clientstate->recv_buf_size = recv_buf_size; + + clientstate->eod_check = eod_check; + clientstate->null_terminate_recv_data = null_terminate_recvd_data; + if ( clientstate->eod_check == NULL ) + clientstate->close_connection_after_recv_data = 1; + else + clientstate->close_connection_after_recv_data = close_connection_after_recv_data; + + // clear out recv buffer (just in case there was something else in there) + memset( clientstate->recv_buf, 0, clientstate->recv_buf_size ); + + + + clientstate->backoff_timeout = backoff_timeout; + clientstate->connect_timeout = connect_timeout; + clientstate->send_timeout = send_timeout; + clientstate->recv_timeout = recv_timeout; + + return 0; +} + +int SetClientStateStructRecvBuf(ClientStateStruct *clientstate, char *recv_buf, int recv_buf_size ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->recv_buf = recv_buf; + clientstate->recv_buf_size = recv_buf_size; + clientstate->recv_count = 0; + // clear out recv buffer (just in case there was something else in there) + memset( clientstate->recv_buf, 0, clientstate->recv_buf_size ); + return 0; +} + +int ResetClientStateStructRecvBuf(ClientStateStruct *clientstate ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->recv_count = 0; + // clear out recv buffer (just in case there was something else in there) + memset( clientstate->recv_buf, 0, clientstate->recv_buf_size ); + return 0; +} + + +int SetClientStateStructSendBuf(ClientStateStruct *clientstate, char *send_buf, int send_buf_size ) +{ + if ( clientstate == NULL ) + return -1; + clientstate->send_buf = send_buf; + clientstate->send_buf_size = send_buf_size; + return 0; +} + +int CloseClientConnection(ClientStateStruct *clientstate) +{ + if ( clientstate == NULL ) + return -1; + clientstate->state = CLIENT_STATE_CLOSE_CONNECTION; + return UpdateClientState(clientstate); +} + +int UpdateClientState(ClientStateStruct *clientstate) +{ + int ec; + int t; + int recvd_bytes; + if ( clientstate == NULL ) + return -1; + + t = time(NULL); + if( clientstate->start_time == 0 ) + clientstate->start_time = t; + if ( clientstate->curr_state_start == 0 ) + clientstate->curr_state_start = t; + + switch(clientstate->state) + { + case CLIENT_STATE_AVAILABLE: + break; + case CLIENT_STATE_OPEN_CONNECTION: + clientstate->connected = 0; + clientstate->connect_start_time = GetSysElapsedMicroseconds(); + ec = NetSockOpenClientTCPConnection( &clientstate->nsh, clientstate->server_ip, clientstate->server_port ); + if ( ec == NETSOCK_RESULT_SUCCESS ) + { + clientstate->state = CLIENT_STATE_WAIT_FOR_CONNECTION; + clientstate->curr_state_start = t; + } + else + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_CONNECT_FAILED; + } + break; + case CLIENT_STATE_WAIT_FOR_CONNECTION: + ec = NetSockCheckConnectionStatus(&clientstate->nsh); + if ( ec == NETSOCK_STATUS_READY_SEND || ec == NETSOCK_STATUS_READY_SEND_AND_RECV ) + { + prts_debug( "Net Client: Socket Connected!\n" ); + clientstate->state = CLIENT_STATE_SEND_DATA; + clientstate->curr_state_start = t; + clientstate->connected = 1; + clientstate->connect_time = GetSysElapsedMicroseconds() - clientstate->connect_start_time; + } + else if ( ec == NETSOCK_STATUS_CONNECT_FAILED ) + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_CONNECT_FAILED; + prts_debug( "Net Client: Socket Connect Failed!\n" ); + } + else if ( t > clientstate->curr_state_start + clientstate->connect_timeout ) + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_CONNECT_TIMEDOUT; + } + break; + case CLIENT_STATE_SEND_DATA: + clientstate->send_start_time = GetSysElapsedMicroseconds(); + ec = NetSockSendOutTCPConnection( &clientstate->nsh, clientstate->send_buf, &clientstate->send_buf_size ); + if( ec == NETSOCK_RESULT_SUCCESS ) + { + prts_debug( "Net Client: Data sent!\n" ); + clientstate->state = CLIENT_STATE_RECV_DATA; + clientstate->curr_state_start = t; + clientstate->send_time += GetSysElapsedMicroseconds() - clientstate->send_start_time; + clientstate->recv_start_time = GetSysElapsedMicroseconds(); + } + else if ( ec == NETSOCK_RESULT_FAILURE ) + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_SEND_FAILED; + } + else if ( t > clientstate->curr_state_start + clientstate->send_timeout ) + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_SEND_TIMEDOUT; + } + // retry send next pass through + break; + case CLIENT_STATE_RECV_DATA: + if ( clientstate->recv_start_time == 0 ) + clientstate->recv_start_time = GetSysElapsedMicroseconds(); + // set max bytes to recv (so we don't overrun recv buffer) + if( clientstate->null_terminate_recv_data == 1 ) + recvd_bytes = clientstate->recv_buf_size - clientstate->recv_count -1 ; // leave an extra space in recv buffer for null terminator + else + recvd_bytes = clientstate->recv_buf_size - clientstate->recv_count; + if ( recvd_bytes <= 0 ) + { + // out of buffer space + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_RECV_BUFFER_FULL; + break; + } + ec = NetSockRecvFromTCPConnection( &clientstate->nsh, &clientstate->recv_buf[clientstate->recv_count], &recvd_bytes ); + if( ec == NETSOCK_RESULT_SUCCESS ) + { + prts_debug( "Net Client: Some Data Recvd!\n" ); + + clientstate->recv_count += recvd_bytes; + if ( clientstate->null_terminate_recv_data == 1 ) + clientstate->recv_buf[clientstate->recv_count] = '\0'; // null terminate string + + // check for end of data + if ( clientstate->eod_check != NULL && + clientstate->eod_check(clientstate) == 0 ) + { + prts_debug( "Net Client: All Data Recvd!\n" ); + clientstate->state = CLIENT_STATE_RECV_COMPLETE; + clientstate->curr_state_start = t; + clientstate->recv_time += GetSysElapsedMicroseconds() - clientstate->recv_start_time; + } + } + else if ( ec == NETSOCK_RESULT_SOCKET_NOT_READY ) + { + if ( t > clientstate->curr_state_start + clientstate->recv_timeout ) + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_RECV_TIMEDOUT; + } + } + else if ( ec == NETSOCK_RESULT_SOCKET_CLOSED + && clientstate->eod_check == NULL ) + { + // if no eod func is specificied, then we rely on server closing the + // connection as our signal to stop recv'ng + prts_debug( "Net Client: All Data Recvd!\n" ); + clientstate->state = CLIENT_STATE_RECV_COMPLETE; + clientstate->curr_state_start = t; + clientstate->recv_time += GetSysElapsedMicroseconds() - clientstate->recv_start_time; + } + else // some other error occurred while sending! + { + clientstate->state = CLIENT_STATE_ERROR; + clientstate->error_code = CLIENT_ERR_RECV_FAILED; + } + break; + case CLIENT_STATE_RECV_COMPLETE: + if ( clientstate->close_connection_after_recv_data == 1 ) + { + clientstate->state = CLIENT_STATE_CLOSE_CONNECTION; + clientstate->curr_state_start = t; + } + else // otherwise jump right to done + { + clientstate->state = CLIENT_STATE_DONE; + } + break; + case CLIENT_STATE_CLOSE_CONNECTION: + prts_debug( "Net Client: Closing connection!\n" ); + clientstate->close_start_time = GetSysElapsedMicroseconds(); + NetSockCloseConnection(&clientstate->nsh); + clientstate->close_time = GetSysElapsedMicroseconds() - clientstate->close_start_time; + clientstate->complete_time = GetSysElapsedMicroseconds() - clientstate->connect_start_time; + clientstate->state = CLIENT_STATE_DONE; + clientstate->curr_state_start = t; + clientstate->connected = 0; + break; + case CLIENT_STATE_DONE: + break; + case CLIENT_STATE_ERROR: + break; + case CLIENT_STATE_BACKOFF: // put this client in this state to have him spin for a bit (like after he reports a failed connection attempt) + if ( t > clientstate->curr_state_start + clientstate->backoff_timeout ) + { + clientstate->state = CLIENT_STATE_AVAILABLE; + } + break; + } + + // rather than wait another loop to notice an err, check for one right away + if ( clientstate->state == CLIENT_STATE_ERROR ) + { + prts_debug( "Net Client: ERROR! (ec = %d)\n", clientstate->error_code ); + clientstate->state = CLIENT_STATE_CLOSE_CONNECTION; + clientstate->curr_state_start = t; + } + + return 0; +} + diff --git a/libraries/pmrt/pmrt_utils/netclient.h b/libraries/pmrt/pmrt_utils/netclient.h new file mode 100755 index 0000000..1740739 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netclient.h @@ -0,0 +1,120 @@ +// netclient.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +#ifndef NETCLIENT_H +#define NETCLIENT_H + +#include "netsock.h" +#include "microtime.h" + + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + + +/* +#define CLIENT_WAIT_CONNECT_TIMEOUT 5 +#define CLIENT_SEND_TIMEOUT 5 +#define CLIENT_RECV_TIMEOUT 5 +// how long to pause for after a failed connection/transmit err +#define CLIENT_BACKOFF_TIMEOUT 3 +*/ + +typedef struct ClientStateStruct +{ + char server_ip[32]; + int server_port; + int state; + int start_time; + int curr_state_start; + int retries; + int curr_state_retries; + NetSockHandle nsh; + int connected; + int error_code; + + int (*eod_check)(struct ClientStateStruct*); + + char *send_buf; + int send_buf_size; + char *recv_buf; + int recv_buf_size; + int recv_count; + + int null_terminate_recv_data; + int close_connection_after_recv_data; + + int connect_timeout; + int send_timeout; + int recv_timeout; + int backoff_timeout; + + + uns64 connect_start_time; + uns64 connect_time; + uns64 send_start_time; + uns64 send_time; + uns64 recv_start_time; + uns64 recv_time; + uns64 close_start_time; + uns64 close_time; + uns64 complete_time; + +} ClientStateStruct; + +enum ClientStates +{ + CLIENT_STATE_AVAILABLE, + CLIENT_STATE_OPEN_CONNECTION, + CLIENT_STATE_WAIT_FOR_CONNECTION, + CLIENT_STATE_SEND_DATA, + CLIENT_STATE_RECV_DATA, + CLIENT_STATE_RECV_COMPLETE, + CLIENT_STATE_CLOSE_CONNECTION, + CLIENT_STATE_DONE, + CLIENT_STATE_ERROR, + CLIENT_STATE_BACKOFF, +}; + + +enum ClientStateErrorCodes +{ + CLIENT_ERR_NONE, + CLIENT_ERR_CONNECT_FAILED, + CLIENT_ERR_SEND_FAILED, + CLIENT_ERR_RECV_FAILED, + CLIENT_ERR_CONNECT_TIMEDOUT, + CLIENT_ERR_SEND_TIMEDOUT, + CLIENT_ERR_RECV_TIMEDOUT, + CLIENT_ERR_RECV_BUFFER_FULL, +}; + + + + +int InitClientStateStruct(ClientStateStruct *clientstate, + char *server_ip, int server_port, + char *send_buf, int send_buf_size, + char *recv_buf, int recv_buf_size, + int null_terminate_recvd_data, + int (*eod_check)(struct ClientStateStruct*), + int close_connection_after_recv_data, + int connect_timeout, + int send_timeout, + int recv_timeout, + int backoff_timeout ); + + +int UpdateClientState(ClientStateStruct *clientstate); + +int ResetClientStateStructRecvBuf(ClientStateStruct *clientstate ); + +int SetClientStateStructSendBuf(ClientStateStruct *clientstate, char *send_buf, int send_buf_size ); +int SetClientStateStructRecvBuf(ClientStateStruct *clientstate, char *recv_buf, int recv_buf_size ); + +int CloseClientConnection(ClientStateStruct *clientstate); + +#endif + diff --git a/libraries/pmrt/pmrt_utils/netclient.o b/libraries/pmrt/pmrt_utils/netclient.o new file mode 100644 index 0000000..7741199 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/netclient.o differ diff --git a/libraries/pmrt/pmrt_utils/netsock.h b/libraries/pmrt/pmrt_utils/netsock.h new file mode 100755 index 0000000..f195482 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netsock.h @@ -0,0 +1,65 @@ +#ifndef NETSOCK_H +#define NETSOCK_H + + +// these guy pull in system include files and define the NetSockHandle struct +#ifdef SYS_PC +#include "netsock_pc.h" +#endif +#ifdef SYS_BB +#include "netsock_bb.h" +#endif + + + +enum +{ + NETSOCK_RESULT_SUCCESS, + NETSOCK_RESULT_PENDING, + NETSOCK_RESULT_INVALID_HANDLE, + NETSOCK_RESULT_INVALID_PARAMS, + NETSOCK_RESULT_WIN32_SOCK_INIT_FAILED, + NETSOCK_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION, + NETSOCK_RESULT_BIND_FAILED, + NETSOCK_RESULT_CONNECT_FAILED, + NETSOCK_RESULT_SOCKET_NOT_READY, + NETSOCK_RESULT_SOCKET_CLOSED, + NETSOCK_RESULT_EAGAIN, + NETSOCK_RESULT_FAILURE, +}; + +enum +{ + NETSOCK_STATUS_READY_SEND, + NETSOCK_STATUS_READY_RECV, + NETSOCK_STATUS_READY_SEND_AND_RECV, + NETSOCK_STATUS_NOT_READY, + NETSOCK_STATUS_CONNECT_PENDING, + NETSOCK_STATUS_INVALID_HANDLE, + NETSOCK_STATUS_SELECT_FAILED, + NETSOCK_STATUS_CONNECT_FAILED, + NETSOCK_STATUS_CLOSED, + +}; + + + + +int NetSockCheckConnectionStatus(NetSockHandle *handle); +int NetSockCloseConnection( NetSockHandle *handle ); + +int NetSockOpenClientTCPConnection( NetSockHandle *handle, char *remote_ip, int remote_port ); +int NetSockSendOutTCPConnection( NetSockHandle *handle, void *data, int *size ); +int NetSockRecvFromTCPConnection( NetSockHandle *handle, void *data, int *size ); + + +int NetSockSetBroadcast( NetSockHandle *handle, int enable ); + + +int NetSockOpenUDPSocket( NetSockHandle *handle, char *local_ip, int local_port ); + +int NetSockSendOutUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int remote_port ); +int NetSockRecvFromUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int *remote_port ); + + +#endif diff --git a/libraries/pmrt/pmrt_utils/netsock_bb.c b/libraries/pmrt/pmrt_utils/netsock_bb.c new file mode 100755 index 0000000..61da639 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netsock_bb.c @@ -0,0 +1,456 @@ +#ifdef SYS_BB +// netsock.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "netsock.h" + +#include "cguardian.h" + +#include "node.h" + + + +#include // needed for return code definitions + + + +int NetSockCloseConnection( NetSockHandle *handle ) +{ + int ec; + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + ec = close(handle->sd); + // prts_debug("SOCKET HANDLE CLOSED\n" ); + + if ( ec < 0 ) + return NETSOCK_RESULT_FAILURE; + + handle->connected = 0; + handle->type = 0; + return NETSOCK_RESULT_SUCCESS; + +} + + +int NetSockOpenClientTCPConnection( NetSockHandle *handle, char *remote_ip, int remote_port ) +{ + int ec = 0; + + prts_debug( "opening tcp socket\n" ); + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if( remote_ip == NULL ) + return NETSOCK_RESULT_INVALID_PARAMS; + + if( remote_port < 0 || remote_port > 65535) + return NETSOCK_RESULT_INVALID_PARAMS; + + + handle->type = SOCK_STREAM; + + handle->sd = socket(AF_INET, SOCK_STREAM, 0); + if ( handle->sd < 0 ) + return NETSOCK_RESULT_FAILURE; + + // put socket in non-blocking mode + // all send/recv calls will be non-blocking + // so they will return right away if there is: + // no room in tcp buffers for send data + // no data in tcp buffers to recv + // do this so game is never stuck waiting + // on a tcp/ip operation to move forward + ec = fcntl(handle->sd, F_SETFL, O_NONBLOCK); + if ( ec < 0 ) + return NETSOCK_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION; + + // setup src and dst address structures + // use anything that's available for src address and port + handle->src_addr.sin_family = AF_INET; + handle->src_addr.sin_port = INADDR_ANY; + // unix and win32 use slightly different defines for 'use any ip address' + handle->src_addr.sin_addr.s_addr = htonl(INADDR_ANY); + // take destination address and port from args + handle->dst_addr.sin_family = AF_INET; + handle->dst_addr.sin_port = htons(remote_port); + handle->dst_addr.sin_addr.s_addr = inet_addr(remote_ip); + + // bind to local address and port + ec = bind( handle->sd, (struct sockaddr*)&handle->src_addr, sizeof(handle->src_addr) ); + if ( ec < 0 ) + { + // on linux you can just look at ec, but on win32, need to check last error + // do best to close out socket before bailing + NetSockCloseConnection(handle); + return NETSOCK_RESULT_BIND_FAILED; + } + + handle->connected = 0; + + prts_debug( "calling connect\n" ); + + // open TCP session + ec = connect( handle->sd, (struct sockaddr*)&handle->dst_addr, sizeof(handle->dst_addr) ); + // don't expect this to complete right away, as we are in non-blocking mode + // (use NetSockCheckConnectionStatus() to poll for when connection is ready) + // so we need to check our error codes carefully here + if ( ec == 0 ) // immediate success (connecting to localhost?) + { + prts_debug( "connect succeeded right away\n" ); + handle->connected = 1; + return NETSOCK_RESULT_SUCCESS; + } + // check if connection is in pending state + // unix and win32 use different error codes for this :( + // this is how unix indicates that the connection is pending + if ( ec == -1 && errno == EINPROGRESS ) + { + prts_debug( "connect returned in progress err\n" ); + return NETSOCK_RESULT_SUCCESS; + } + else + { + prts_debug( "connect failed w/ err %d, errno = %d\n", ec, errno ); + } + + + // otherwise, connection failed for some reason + // (invalid params, etc) + // do best to close out socket before bailing + NetSockCloseConnection(handle); + return NETSOCK_RESULT_CONNECT_FAILED; + +} + +int NetSockCheckConnectionStatus(NetSockHandle *handle) +{ + int ec,size; + struct timeval waittime; + fd_set writeset; + fd_set readset; + fd_set exceptset; + + // prts_debug( "Checking conneciton status\n" ); + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + // use select to see if connection is read for reading or writing (or both) + // also check for pending connection or other errs + + waittime.tv_sec = 0; + waittime.tv_usec = 0; + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + + FD_SET(handle->sd, &readset); + FD_SET(handle->sd, &writeset); + FD_SET(handle->sd, &exceptset); + + // prts_debug( "Calling select\n" ); + + ec = select( handle->sd + 1, &readset, &writeset, &exceptset, &waittime ); + if ( ec < 0 ) + { + prts_debug( "select failed\n" ); + return NETSOCK_STATUS_SELECT_FAILED; + } + + // check if connection is established + if ( handle->type == SOCK_STREAM && handle->connected != 1 ) + { + // prts_debug( "Unconnected tcp socket, checking connect status\n" ); + + // on an unconnected tcp connection, we + // use select to tell when connection is ready + + + // in unix we check for writeability + // then check for a connection error + if( ! FD_ISSET( handle->sd, &writeset ) ) + { + // prts_debug( "socket not yet writeable\n" ); + // connection is still pending + return NETSOCK_STATUS_CONNECT_PENDING; + } + else + { + // connection is writeable, check if there was a connection err + // prts_debug( "socket writeable checking for error\n" ); + + size = sizeof(ec); + getsockopt( handle->sd, SOL_SOCKET, SO_ERROR, &ec, &size ); + if ( ec != 0 ) + { + // prts_debug( "socket connect error found\n" ); + // there was an error when connecting + // connection failed + NetSockCloseConnection(handle); + return NETSOCK_STATUS_CONNECT_FAILED; + } + // prts_debug( "no socket connect err found\n" ); + + // no err so connected, mark it and let normal + // checks done below determine read/write status + handle->connected = 1; + } + } + + if ( FD_ISSET( handle->sd, &readset ) && FD_ISSET( handle->sd, &writeset ) ) + { + // prts_debug( "connection ready for send and recv\n" ); + return NETSOCK_STATUS_READY_SEND_AND_RECV; + } + else if ( FD_ISSET( handle->sd, &readset ) ) + { + // prts_debug( "connection ready for recv\n" ); + return NETSOCK_STATUS_READY_RECV; + } + else if ( FD_ISSET( handle->sd, &writeset ) ) + { + // prts_debug( "connection ready for send\n" ); + return NETSOCK_STATUS_READY_SEND; + } + else + { + // prts_debug( "connection not ready\n" ); + return NETSOCK_STATUS_NOT_READY; + } + + + +} + +int NetSockSendOutTCPConnection( NetSockHandle *handle, void *data, int *size ) +{ + int ec; + int req_size; + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + // check if socket is ready for sending + ec = NetSockCheckConnectionStatus(handle); + if ( ec != NETSOCK_STATUS_READY_SEND_AND_RECV + && ec != NETSOCK_STATUS_READY_SEND ) + return NETSOCK_RESULT_SOCKET_NOT_READY; + + // record how much data user intended to send + req_size = *size; + + // result of send is how many bytes were sent (or -1 for error) + // always do a non-blocking send + *size = send( handle->sd, data, req_size, MSG_DONTWAIT ); + // check if we sent the requested # of bytes + if ( *size == req_size ) + return NETSOCK_RESULT_SUCCESS; + + if ( *size < req_size ) // did not send all the data + return NETSOCK_RESULT_FAILURE; + + // some other error occured + return NETSOCK_RESULT_FAILURE; + +} + + +int NetSockRecvFromTCPConnection( NetSockHandle *handle, void *data, int *size ) +{ + int ec; + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + // check if socket is ready for recv'ng + ec = NetSockCheckConnectionStatus(handle); + if ( ec != NETSOCK_STATUS_READY_SEND_AND_RECV + && ec != NETSOCK_STATUS_READY_RECV ) + return NETSOCK_RESULT_SOCKET_NOT_READY; + + // recv returns number of bytes recieved or -1 for error + *size = recv( handle->sd, data, *size, 0 ); + + if ( *size > 0 ) + return NETSOCK_RESULT_SUCCESS; + + if ( *size < 0 ) // some error occurred + return NETSOCK_RESULT_FAILURE; + + // recv'd no data (typically this implies that connection is closed,get a negative value if no data in buffer) + return NETSOCK_RESULT_SOCKET_CLOSED; + +} + + + +int NetSockOpenUDPSocket( NetSockHandle *handle, char *local_ip, int local_port ) +{ + int ec; + int arg; + + prts_debug( "opening udp socket\n" ); + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + + if( local_port < 0 || local_port > 65535) + return NETSOCK_RESULT_INVALID_PARAMS; + + + handle->type = SOCK_DGRAM; + + handle->sd = socket(AF_INET, SOCK_DGRAM, 0); + if ( handle->sd < 0 ) + return NETSOCK_RESULT_FAILURE; + + // put socket in non-blocking mode + // all send/recv calls will be non-blocking + // so they will return right away if there is: + // no room in udp buffers for send data + // no data in udp buffers to recv + // do this so game is never stuck waiting + // on a udp/ip operation to move forward + arg = 1; + ec = fcntl(handle->sd, F_SETFL, O_NONBLOCK); + if ( ec < 0 ) + return NETSOCK_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION; + + + // setup src address structures + // use anything that's available for src address and use passed port + handle->src_addr.sin_family = AF_INET; + if ( local_port == 0 ) + { + handle->src_addr.sin_port = INADDR_ANY; + } + else + { + handle->src_addr.sin_port = htons(local_port); + } + if ( local_ip == NULL || (strcmp(local_ip,"") == 0)) + { + // unix and win32 use slightly different defines for 'use any ip address' + handle->src_addr.sin_addr.s_addr = htonl(INADDR_ANY); + } + else + { + handle->src_addr.sin_addr.s_addr = inet_addr(local_ip); + } + + // bind to local address and port + ec = bind( handle->sd, (struct sockaddr*)&handle->src_addr, sizeof(handle->src_addr) ); + if ( ec < 0 ) + { + // do best to close out socket before bailing + NetSockCloseConnection(handle); + return NETSOCK_RESULT_BIND_FAILED; + } + + handle->connected = 0; + return NETSOCK_RESULT_SUCCESS; + +} + +int NetSockSendOutUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int remote_port ) +{ + int ec; + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return NETSOCK_RESULT_INVALID_PARAMS; + + if( remote_port < 0 || remote_port > 65535) + return NETSOCK_RESULT_INVALID_PARAMS; + + + + + handle->dst_addr.sin_family = AF_INET; + handle->dst_addr.sin_port = htons(remote_port); + if ( remote_ip == NULL || (strcmp(remote_ip,"") == 0) ) + handle->dst_addr.sin_addr.s_addr = INADDR_BROADCAST; + else + handle->dst_addr.sin_addr.s_addr = inet_addr(remote_ip); + + ec = sendto(handle->sd, data, *size, 0, (struct sockaddr *) &handle->dst_addr, sizeof(handle->dst_addr) ); + if ( ec < 0 ) + { + if (errno==EAGAIN) + return NETSOCK_RESULT_SOCKET_NOT_READY; + + return NETSOCK_RESULT_FAILURE; + } + + *size = ec; // how many bytes actually got sent + + + return NETSOCK_RESULT_SUCCESS; + +} + +int NetSockRecvFromUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int *remote_port ) +{ + int ec; + int len; + struct sockaddr_in csockaddr; + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return NETSOCK_RESULT_INVALID_PARAMS; + + len = sizeof(csockaddr); + ec = recvfrom(handle->sd, data, *size, 0, (struct sockaddr *) &csockaddr, &len ); + if ( ec < 0 ) + { + if (errno==EAGAIN) + return NETSOCK_RESULT_SOCKET_NOT_READY; + + return NETSOCK_RESULT_FAILURE; + } + + *size = ec; + + if ( remote_port ) + *remote_port = ntohs(csockaddr.sin_port); + if ( remote_ip ) + sprintf(remote_ip,"%s",inet_ntoa(csockaddr.sin_addr) ); + + + + return NETSOCK_RESULT_SUCCESS; + + +} + + +int NetSockSetBroadcast( NetSockHandle *handle, int enable ) +{ + int ec; + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if ( enable != 0 && enable != 1 ) + return NETSOCK_RESULT_INVALID_PARAMS; + + + ec = setsockopt(handle->sd, SOL_SOCKET, SO_BROADCAST, (char *) &enable, sizeof(enable) ); + if ( ec < 0 ) + return NETSOCK_RESULT_FAILURE; + else + return NETSOCK_RESULT_SUCCESS; + +} + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/netsock_bb.h b/libraries/pmrt/pmrt_utils/netsock_bb.h new file mode 100755 index 0000000..f7033f9 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netsock_bb.h @@ -0,0 +1,45 @@ +#ifdef SYS_BB +// netsock.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef NETSOCKBB_H +#define NETSOCKBB_H + +// includes req for datatypes and err codes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +typedef struct +{ + int type; + int sd; + struct sockaddr_in src_addr; + struct sockaddr_in dst_addr; + int connected; + +} NetSockHandle; + + + + + +#endif + + +#endif + + diff --git a/libraries/pmrt/pmrt_utils/netsock_bb.o b/libraries/pmrt/pmrt_utils/netsock_bb.o new file mode 100644 index 0000000..2624206 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/netsock_bb.o differ diff --git a/libraries/pmrt/pmrt_utils/netsock_pc.c b/libraries/pmrt/pmrt_utils/netsock_pc.c new file mode 100755 index 0000000..45f760b --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netsock_pc.c @@ -0,0 +1,540 @@ +#ifdef SYS_PC +// netsock.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#include "netsock.h" + +#include "cguardian.h" + +#include "node.h" + + +int StartWin32Sockets() +{ + static int Win32SocketsStarted = 0; + + if(!Win32SocketsStarted) + { + WSADATA data; + if(WSAStartup(MAKEWORD(2, 2), &data) != 0) + { + return 0; + } + Win32SocketsStarted = 1; + } + return 1; +} + + +int NetSockCloseConnection( NetSockHandle *handle ) +{ + int ec; + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + ec = closesocket(handle->sd ); + + if ( ec < 0 ) + return NETSOCK_RESULT_FAILURE; + + handle->connected = 0; + handle->type = 0; + return NETSOCK_RESULT_SUCCESS; + +} + + +int NetSockOpenClientTCPConnection( NetSockHandle *handle, char *remote_ip, int remote_port ) +{ + int ec = 0; + int arg; + + prts_debug( "opening tcp socket\n" ); + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if( remote_ip == NULL ) + return NETSOCK_RESULT_INVALID_PARAMS; + + if( remote_port < 0 || remote_port > 65535) + return NETSOCK_RESULT_INVALID_PARAMS; + + if ( ! StartWin32Sockets() ) + return NETSOCK_RESULT_WIN32_SOCK_INIT_FAILED; + + + handle->type = SOCK_STREAM; + + handle->sd = socket(AF_INET, SOCK_STREAM, 0); + if ( handle->sd < 0 ) + return NETSOCK_RESULT_FAILURE; + + // put socket in non-blocking mode + // all send/recv calls will be non-blocking + // so they will return right away if there is: + // no room in tcp buffers for send data + // no data in tcp buffers to recv + // do this so game is never stuck waiting + // on a tcp/ip operation to move forward + arg = 1; + ec = ioctlsocket(handle->sd, FIONBIO, &arg); // non-blocking mode enabled + if ( ec < 0 ) + return NETSOCK_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION; + + // setup src and dst address structures + // use anything that's available for src address and port + handle->src_addr.sin_family = AF_INET; + handle->src_addr.sin_port = INADDR_ANY; + // unix and win32 use slightly different defines for 'use any ip address' + handle->src_addr.sin_addr.s_addr = ADDR_ANY; + // take destination address and port from args + handle->dst_addr.sin_family = AF_INET; + handle->dst_addr.sin_port = htons((u_short)remote_port); + handle->dst_addr.sin_addr.s_addr = inet_addr(remote_ip); + + // bind to local address and port + ec = bind( handle->sd, (struct sockaddr*)&handle->src_addr, sizeof(handle->src_addr) ); + if ( ec < 0 ) + { + // on linux you can just look at ec, but on win32, need to check last error + ec = WSAGetLastError(); + // check http://msdn2.microsoft.com/en-us/library/ms740668.aspx + // for the complete list + switch (ec) + { + case WSANOTINITIALISED: + break; + case WSAENETDOWN: + break; + case WSAEACCES: + break; + case WSAEADDRINUSE: + break; + case WSAEADDRNOTAVAIL: + break; + case WSAEFAULT: + break; + case WSAEINPROGRESS: + break; + case WSAEINVAL: + break; + case WSAENOBUFS: + break; + case WSAENOTSOCK: + break; + } + // do best to close out socket before bailing + NetSockCloseConnection(handle); + return NETSOCK_RESULT_BIND_FAILED; + } + + handle->connected = 0; + + prts_debug( "calling connect\n" ); + + // open TCP session + ec = connect( handle->sd, (struct sockaddr*)&handle->dst_addr, sizeof(handle->dst_addr) ); + // don't expect this to complete right away, as we are in non-blocking mode + // (use NetSockCheckConnectionStatus() to poll for when connection is ready) + // so we need to check our error codes carefully here + if ( ec == 0 ) // immediate success (connecting to localhost?) + { + prts_debug( "connect succeeded right away\n" ); + handle->connected = 1; + return NETSOCK_RESULT_SUCCESS; + } + // check if connection is in pending state + // unix and win32 use different error codes for this :( + // this is how windows indicates that the connection is pending + // see http://msdn2.microsoft.com/en-us/library/ms737625.aspx + if ( ec == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK ) + return NETSOCK_RESULT_SUCCESS; + + + // otherwise, connection failed for some reason + // (invalid params, etc) + // do best to close out socket before bailing + NetSockCloseConnection(handle); + return NETSOCK_RESULT_CONNECT_FAILED; + +} + +int NetSockCheckConnectionStatus(NetSockHandle *handle) +{ + int ec; + struct timeval waittime; + fd_set writeset; + fd_set readset; + fd_set exceptset; + + // prts_debug( "Checking conneciton status\n" ); + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + // use select to see if connection is read for reading or writing (or both) + // also check for pending connection or other errs + + waittime.tv_sec = 0; + waittime.tv_usec = 0; + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + + FD_SET(handle->sd, &readset); + FD_SET(handle->sd, &writeset); + FD_SET(handle->sd, &exceptset); + + // prts_debug( "Calling select\n" ); + + ec = select( handle->sd + 1, &readset, &writeset, &exceptset, &waittime ); + if ( ec < 0 ) + { + prts_debug( "select failed\n" ); + return NETSOCK_STATUS_SELECT_FAILED; + } + + // check if connection is established + if ( handle->type == SOCK_STREAM && handle->connected != 1 ) + { + // prts_debug( "Unconnected tcp socket, checking connect status\n" ); + + // on an unconnected tcp connection, we + // use select to tell when connection is ready + + // in win32 we can check the except status for this + if ( FD_ISSET( handle->sd, &exceptset ) ) + { + // connection failed + NetSockCloseConnection(handle); + return NETSOCK_STATUS_CONNECT_FAILED; + } + else if( ! FD_ISSET( handle->sd, &writeset ) ) + { + // connection is still pending + return NETSOCK_STATUS_CONNECT_PENDING; + } + else + { + // connection is open, mark it and let normal + // checks done below determine read/write status + handle->connected = 1; + } + } + + if ( FD_ISSET( handle->sd, &readset ) && FD_ISSET( handle->sd, &writeset ) ) + { + // prts_debug( "connection ready for send and recv\n" ); + return NETSOCK_STATUS_READY_SEND_AND_RECV; + } + else if ( FD_ISSET( handle->sd, &readset ) ) + { + // prts_debug( "connection ready for recv\n" ); + return NETSOCK_STATUS_READY_RECV; + } + else if ( FD_ISSET( handle->sd, &writeset ) ) + { + // prts_debug( "connection ready for send\n" ); + return NETSOCK_STATUS_READY_SEND; + } + else + { + // prts_debug( "connection not ready\n" ); + return NETSOCK_STATUS_NOT_READY; + } + + + +} + +int NetSockSendOutTCPConnection( NetSockHandle *handle, void *data, int *size ) +{ + int ec; + int req_size; + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + // check if socket is ready for sending + ec = NetSockCheckConnectionStatus(handle); + if ( ec != NETSOCK_STATUS_READY_SEND_AND_RECV + && ec != NETSOCK_STATUS_READY_SEND ) + return NETSOCK_RESULT_SOCKET_NOT_READY; + + // record how much data user intended to send + req_size = *size; + + // result of send is how many bytes were sent (or -1 for error) + // no option to do a non-blocking send on win32 + *size = send( handle->sd, data, req_size, 0 ); + + // check if we sent the requested # of bytes + if ( *size == req_size ) + return NETSOCK_RESULT_SUCCESS; + + if ( *size < req_size ) // did not send all the data + return NETSOCK_RESULT_FAILURE; + + // some other error occured + return NETSOCK_RESULT_FAILURE; + +} + + +int NetSockRecvFromTCPConnection( NetSockHandle *handle, void *data, int *size ) +{ + int ec; + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + // check if socket is ready for recv'ng + ec = NetSockCheckConnectionStatus(handle); + if ( ec != NETSOCK_STATUS_READY_SEND_AND_RECV + && ec != NETSOCK_STATUS_READY_RECV ) + return NETSOCK_RESULT_SOCKET_NOT_READY; + + // recv returns number of bytes recieved or -1 for error + *size = recv( handle->sd, data, *size, 0 ); + + if ( *size > 0 ) + return NETSOCK_RESULT_SUCCESS; + + if ( *size < 0 ) // some error occurred + return NETSOCK_RESULT_FAILURE; + + // recv'd no data (typically this implies that connection is closed,get a negative value if no data in buffer) + return NETSOCK_RESULT_SOCKET_CLOSED; + +} + + + +int NetSockOpenUDPSocket( NetSockHandle *handle, char *local_ip, int local_port ) +{ + int ec; + int arg; + + prts_debug( "opening udp socket\n" ); + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + + if( local_port < 0 || local_port > 65535) + return NETSOCK_RESULT_INVALID_PARAMS; + + if ( ! StartWin32Sockets() ) + return NETSOCK_RESULT_WIN32_SOCK_INIT_FAILED; + + + handle->type = SOCK_DGRAM; + + handle->sd = socket(AF_INET, SOCK_DGRAM, 0); + if ( handle->sd < 0 ) + return NETSOCK_RESULT_FAILURE; + + // put socket in non-blocking mode + // all send/recv calls will be non-blocking + // so they will return right away if there is: + // no room in udp buffers for send data + // no data in udp buffers to recv + // do this so game is never stuck waiting + // on a udp/ip operation to move forward + arg = 1; + ec = ioctlsocket(handle->sd, FIONBIO, &arg); // non-blocking mode enabled + if ( ec < 0 ) + return NETSOCK_RESULT_FAILED_TO_ENABLE_NONBLOCKING_OPERATION; + + // setup src address structures + // use anything that's available for src address and use passed port + handle->src_addr.sin_family = AF_INET; + if ( local_port == 0 ) + { + handle->src_addr.sin_port = INADDR_ANY; + } + else + { + handle->src_addr.sin_port = htons((u_short)local_port); + } + if ( local_ip == NULL || (strcmp(local_ip,"") == 0)) + { + // unix and win32 use slightly different defines for 'use any ip address' + handle->src_addr.sin_addr.s_addr = ADDR_ANY; + } + else + { + handle->src_addr.sin_addr.s_addr = inet_addr(local_ip); + } + + // bind to local address and port + ec = bind( handle->sd, (struct sockaddr*)&handle->src_addr, sizeof(handle->src_addr) ); + if ( ec < 0 ) + { + // on linux you can just look at ec, but on win32, need to check last error + ec = WSAGetLastError(); + // check http://msdn2.microsoft.com/en-us/library/ms740668.aspx + // for the complete list + switch (ec) + { + case WSANOTINITIALISED: + break; + case WSAENETDOWN: + break; + case WSAEACCES: + break; + case WSAEADDRINUSE: + break; + case WSAEADDRNOTAVAIL: + break; + case WSAEFAULT: + break; + case WSAEINPROGRESS: + break; + case WSAEINVAL: + break; + case WSAENOBUFS: + break; + case WSAENOTSOCK: + break; + } + // do best to close out socket before bailing + NetSockCloseConnection(handle); + return NETSOCK_RESULT_BIND_FAILED; + } + + handle->connected = 0; + return NETSOCK_RESULT_SUCCESS; + +} + +int NetSockSendOutUDPSocket( NetSockHandle *handle, void *data, int *size, char *remote_ip, int remote_port ) +{ + int ec; + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return NETSOCK_RESULT_INVALID_PARAMS; + + if( remote_port < 0 || remote_port > 65535) + return NETSOCK_RESULT_INVALID_PARAMS; + + handle->dst_addr.sin_family = AF_INET; + handle->dst_addr.sin_port = htons((u_short)remote_port); + if ( remote_ip == NULL || (strcmp(remote_ip,"") == 0) ) + handle->dst_addr.sin_addr.s_addr = INADDR_BROADCAST; + else + handle->dst_addr.sin_addr.s_addr = inet_addr(remote_ip); + + ec = sendto(handle->sd, data, *size, 0, (struct sockaddr *) &handle->dst_addr, sizeof(handle->dst_addr) ); + if ( ec < 0 ) + { + // on linux you can just look at ec, but on win32, need to check last error + ec = WSAGetLastError(); + // check http://msdn2.microsoft.com/en-us/library/ms740668.aspx + // for the complete list + switch (ec) + { + case WSAEWOULDBLOCK: // call would have blocked (no message ready right now) + return NETSOCK_RESULT_SOCKET_NOT_READY; + break; + } + } + + + *size = ec; // bytes actually sent + + return NETSOCK_RESULT_SUCCESS; + +} + +int NetSockRecvFromUDPSocket( NetSockHandle *handle, void *data, int *size , char *remote_ip, int *remote_port ) +{ + int ec; + int len; + struct sockaddr_in csockaddr; + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if ( data == NULL || size == NULL || *size <= 0 ) + return NETSOCK_RESULT_INVALID_PARAMS; + + len = sizeof(csockaddr); + ec = recvfrom(handle->sd, data, *size, 0, (struct sockaddr *) &csockaddr, &len ); + if ( ec < 0 ) + { + // on linux you can just look at ec, but on win32, need to check last error + ec = WSAGetLastError(); + // check http://msdn2.microsoft.com/en-us/library/ms740668.aspx + // for the complete list + switch (ec) + { + case WSAEWOULDBLOCK: // call would have blocked (no message ready right now) + return NETSOCK_RESULT_SOCKET_NOT_READY; + break; + case WSAEMSGSIZE: // message larger than buffer size (ignore this error for now) + break; + // other errors + case WSAENETDOWN: + break; + case WSAEACCES: + break; + case WSAEADDRINUSE: + break; + case WSAEADDRNOTAVAIL: + break; + case WSAEFAULT: + break; + case WSAEINPROGRESS: + break; + case WSAEINVAL: + break; + case WSAENOBUFS: + break; + case WSAENOTSOCK: + break; + } + } + + *size = ec; + + + if ( remote_port ) + *remote_port = ntohs(csockaddr.sin_port); + if ( remote_ip ) + sprintf(remote_ip,"%s",inet_ntoa(csockaddr.sin_addr) ); + + return NETSOCK_RESULT_SUCCESS; + + +} + + +int NetSockSetBroadcast( NetSockHandle *handle, int enable ) +{ + int ec; + + if ( handle == NULL ) + return NETSOCK_RESULT_INVALID_HANDLE; + + if ( enable != 0 && enable != 1 ) + return NETSOCK_RESULT_INVALID_PARAMS; + + + ec = setsockopt(handle->sd, SOL_SOCKET, SO_BROADCAST, (char *) &enable, sizeof(enable) ); + if ( ec < 0 ) + return NETSOCK_RESULT_FAILURE; + else + return NETSOCK_RESULT_SUCCESS; + +} + + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/netsock_pc.h b/libraries/pmrt/pmrt_utils/netsock_pc.h new file mode 100755 index 0000000..e5c2964 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/netsock_pc.h @@ -0,0 +1,39 @@ +#ifdef SYS_PC +// netsock.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef NETSOCKPC_H +#define NETSOCKPC_H + +// includes req for datatypes and err codes +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include + + + + +typedef struct +{ + int type; + SOCKET sd; + struct sockaddr_in src_addr; + struct sockaddr_in dst_addr; + int connected; +} NetSockHandle; + + + + +#endif + + +#endif + + diff --git a/libraries/pmrt/pmrt_utils/netsock_pc.o b/libraries/pmrt/pmrt_utils/netsock_pc.o new file mode 100644 index 0000000..d723c80 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/netsock_pc.o differ diff --git a/libraries/pmrt/pmrt_utils/node.c b/libraries/pmrt/pmrt_utils/node.c new file mode 100755 index 0000000..b7865a3 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/node.c @@ -0,0 +1,444 @@ +// sys.c +// Play Mechanix - Video Game System +// Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved +// +// JFL 26 Aug 04 +// JFL 17 May 05 +#include "node.h" + +// #include "obj.h" + + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +// +// N1Link +// link given node into given list. +// node is linked on the end. +// +// in: +// headp = handle to head of list +// node = node to link +// out: +// global: +// +// GNP 09 Jun 00 +// JFL 06 Sep 04 +void N1LinkTail(void *headp,void *node) +{ + N1 *n; + + ((N1*)node)->next = (N1*)0; + + n = *((N1**)headp); + if(!n) + { + *((N1**)headp) = node; + } + else + { + while(n->next) + n = n->next; + n->next = node; + } + +//DONE("N1LinkTail") +} // N1LinkTail + +// +// N1LinkHead +// link given node into given list. +// node is linked on the head. +// +// in: +// headp = handle to head of list +// node = node to link +// out: +// global: +// +// GNP 09 Jun 00 +// +void N1LinkHead(void *headp,void *node) +{ + ((N1*)node)->next = *((void**)headp); + *((void**)headp) = node; +} // N1LinkHead + +// +// N1Unlink +// un-link node from given list +// +// in: +// headp = handle to head of list +// node = node to un-link +// out: +// <0 = fail +// global: +// +// GNP 09 Jun 00 +// JFL 04 Sep 04 +int N1Unlink(void *headp,void *node) +{ + N1 *n; + + n = *((N1**)headp); + if(!n) + return -1; + + if(n==node) + { + *((N1**)headp) = ((N1*)node)->next; + return 0; + } + else + { + while(n->next && n->next != node) + n = n->next; + + if(n->next == node) + { + n->next = ((N1*)node)->next; + return 0; + } + } + return -1; +} // N1Unlink + +// N2Head() +// JFL 10 Aug 04; from JoeCo +void N2Head(void *head) +{ + ((N2*)head)->next=((N2*)head)->prev=head; + ((N2*)head)->type=0; +} // N2Head() + +void N2DontLink(void *head) +{ + ((N2*)head)->next=((N2*)head)->prev=head; + ((N2*)head)->type=0; +} // N2Head() + +// N2LinkAfter() +// JFL 10 Aug 04; from JoeCo +void N2LinkAfter(void *head,void *node) +{ + N2 *n=node,*h=head; + n->next=h->next; + n->prev=head; + h->next=node; + ((N2*)(n->next))->prev=node; + + if(!n->type) + { + BP(BP_N2LINKAFTER); + n->type=1; + } +} // N2LinkAfter() + +// N2LinkBefore() +// JFL 10 Aug 04; from JoeCo +void N2LinkBefore(void *head,void *node) +{ + N2 *n=node,*h=head; + n->prev=h->prev; + n->next=head; + h->prev=node; + ((N2*)(n->prev))->next=node; + + if(!n->type) + { + BP(BP_N2LINKBEFORE); + n->type=1; + } +} // N2LinkBefore() + +// N2Unlink() +// JFL 10 Aug 04; from JoeCo +void N2Unlink(void *node) +{ + N2 *n=node; + + // unlink + ((N2*)n->next)->prev=n->prev; + ((N2*)n->prev)->next=n->next; + + // the following makes the node safe from multiple unlinking + n->next=n->prev=node; +} // N2Unlink() + +// JFL 12 Jan 05 +void* N2Parent(void *vn) +{ + N2 *n=vn; + while(n && n->type) + n=n->next; + if(n && !n->type) + { + n++; + if(n->next + && (((N2*)n->next)->prev==n) + && (((N2*)n->prev)->next==n)) + return n; + } + return NUL; +} // N2Parent() + + + +// JFL 11 Nov 04 +int N2Count(void *vn) +{ + N2 *k,*stack[N2_DEPTH_MAX]; + int depth,count; + N2 *n=vn; + + count=0; + stack[0]=n; + depth=1; + + while(depth-->0) + { + for(n=stack[depth];n->type;n=n->next) + { + count++; + if(depthflags&M_N2_KIDLIST) + && (k=N2KIDLIST(n)->next) && k->type) + { + stack[depth++]=n->next; // push next in cur list + n=k->prev; // switch current to first kid + } + } // for + } // while + + return count; +} // N2Count() + +// JFL 18 Feb 05 +int N2LevelSet(N2 *n,int lev) +{ + int oldlev; + + oldlev=n->flags&M_N2_LEVEL; + oldlev>>=S_N2_LEVEL; + + lev = (M_N2_LEVEL & (lev<>S_N2_LEVEL; // complex clamp + n->flags&=~M_N2_LEVEL; + n->flags|=lev<flags&M_N2_LEVEL; + oldlev>>=S_N2_LEVEL; + + return oldlev; +} // N2LevelGet() + +// JFL 24 Feb 05 +int N2LevelCpy(N2 *dst,N2 *src) +{ + int oldlev,newlev; + + newlev=src->flags&M_N2_LEVEL; + + oldlev=dst->flags&M_N2_LEVEL; + dst->flags&=~M_N2_LEVEL; + dst->flags|=newlev; + oldlev>>=S_N2_LEVEL; + + return oldlev; +} // N2LevelCpy() + + +// Generic Search Function for N2 lists +void *N2Search( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *) ) +{ + void *result = NUL; + N2 *Node = (N2*)StartNode; + // quit if we get a NUL node, or we get to top of list + // note that this means you can not start a search at the list head + // this is required to make iterative calls to this function safe + // (if we always skipped passed head node, successive calls to this func might never end) + while ( Node != NUL && Node->type != 0) + { + if ( CompareFunc != NUL && (*CompareFunc)( CompareParam, (void *) Node ) == 0) + { + result = Node; + break; + } + Node = Node->next; + if ( Node == StartNode ) // quit if we get back to start node again + break; + } + + return result; +} // N2Search() + +// walk list and perform OperationFunc on each item +void N2Walk( void *StartNode, void *OperationParam, int (*OperationFunc)(void *, void *) ) +{ + int ec; + N2 *Node; + N2 *Next; + + if ( OperationFunc == NUL ) + return; + + // if starting at head of list, skip past head node + if ( StartNode != NUL && ((N2*)StartNode)->type == 0 ) + StartNode = ((N2*)StartNode)->next; + + Node = (N2*)StartNode; + while ( Node != NUL && Node->type != 0) // quit if we get a NUL node, or we get to top of list + { + // grab next before operating on node so we are safe if operation unlinks node + Next = Node->next; + ec = (*OperationFunc)( OperationParam, (void *) Node ); + if ( ec < 0 ) // stop if ever get a negative value from operation func + break; + + Node = Next; + if ( Node == StartNode ) // quit if we get back to start node again + break; + } +} + +// Combo of prev two functions, searches list for matching items and performs operation on them +void N2SearchAndOperate( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *), void *OperationParam, int (*OperationFunc)(void *, void *) ) +{ + int ec; + N2 *Node; + N2 *Next; + if ( OperationFunc == NUL ) + return; + + // if starting at head of list, skip past head node + if ( StartNode != NUL && ((N2*)StartNode)->type == 0 ) + StartNode = ((N2*)StartNode)->next; + + Node = N2Search( StartNode, CompareParam, CompareFunc ); + while ( Node != NUL && Node->type != 0) // quit if we get a NUL node, or we get to top of list + { + // grab next before operating on node so we are safe if operation unlinks node + Next = Node->next; + ec = (*OperationFunc)( OperationParam, (void *) Node ); + if ( ec < 0 ) // stop if ever get a negative value from operation func + break; + + Node = N2Search( Next, CompareParam, CompareFunc ); + if ( Node == StartNode ) // quit if we get back to start node again + break; + } +} + + +// Pop item off of list +void *N2PopNode( void *Node ) +{ + N2 *n = (N2 *)Node; + // check if node is nul + // check if node is a head marker (don't unlink head of list) + if ( n != NUL + && + n->type != 0 ) + { + N2Unlink(n); + return n; + } + // else return NUL ptr + return NUL; +} + +// Pop next item off of list +void *N2PopNext( void *Node ) +{ + // Check if node is nul + if ( Node != NUL ) + { + return N2PopNode(((N2*)Node)->next); + } + else // return NUL + { + return NUL; + } +} + +// Pop prev item off of list +void *N2PopPrev( void *Node ) +{ + // Check if node is nul + if ( Node != NUL ) + { + return N2PopNode(((N2*)Node)->prev); + } + else // return NUL + { + return NUL; + } +} + + +// adds a DataObj to an N2 list +// gets space for new obj by calling malloc_func +int N2AddDataNode( N2 *List, void *(*malloc_func)(size_t), void *data, int link_after ) +{ + ObjData *NewObj; + if ( List == NUL ) + return -1; + if ( malloc_func == NUL ) + return -2; + + NewObj = (ObjData *) malloc_func( sizeof(ObjData) ); + if (NewObj == NUL ) + return -3; + + NewObj->lnk.type = N2TYPE_OBJ; + NewObj->lnk.sub = OBJSUB_DATA; + NewObj->data = data; + + if ( link_after == 1) + N2LinkAfter( List, NewObj ); + else + N2LinkBefore( List, NewObj ); + + + return 0; +} + +int IncArgOnDataNodes( void *arg, void *node ) +{ + N2 *n = (N2 *)node; + if ( node == NUL || arg == NUL ) + return 0; + + if ( n->type == N2TYPE_OBJ && n->sub == OBJSUB_DATA ) + *(int*)arg += 1; + + return 0; +} + +int N2CountDataNodes( N2 *List ) +{ + int count=0; + N2Walk(List,&count,IncArgOnDataNodes); + return count; +} + + +#include +#include +#include +#include +#include +#include + + + + +// EOF diff --git a/libraries/pmrt/pmrt_utils/node.h b/libraries/pmrt/pmrt_utils/node.h new file mode 100755 index 0000000..092b398 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/node.h @@ -0,0 +1,220 @@ +#ifndef NODE_H +#define NODE_H +// node.h +// Copyright 1998-2004 Play Mechanix Inc. All Rights Reserved +// + +//#include "memallochist.h" + +#include +#include + +// Play Mechanix base types & system +typedef signed char int8; +typedef unsigned char uns8; +typedef signed short int16; +typedef unsigned short uns16; +typedef signed long int32; +typedef unsigned long uns32; + +#if SYS_PC +typedef __int64 int64; +typedef unsigned __int64 uns64; +#endif +#if SYS_BB +typedef long long int64; +typedef unsigned long long uns64; +#endif + +typedef int8 int2; +typedef uns8* ptr; +typedef float f32; +typedef unsigned int uns; +typedef uns sto; // unsigned, big enough for void*,float,int +typedef uns memu; +typedef int memi; + +#if SYS_PC +#define SYSBREAK() __asm {int 3} +#endif // SYS_PC + +#if SYS_BB +#define SYSBREAK() __asm__ ("int $3") +#endif // SYS_BB + + +#define BP(x) { SYSBREAK();} + + + +#define NUL ((void*)0) + +#define COUNT(array) (sizeof(array) / sizeof(array[0])) + + +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION TYPES + +enum { + FTYPE_NONE, + FTYPE_1, + FTYPE_2, + FTYPE_3, + FTYPE_4, + FTYPE_5, + FTYPE_6, + FTYPE_7, +}; + +typedef void (ftype1)(void); +typedef int (ftype2)(void*); +typedef int (ftype3)(void*,void*); +typedef int (ftype4)(int,void*,void*,void*); +typedef int (ftype5)(int); +typedef int (ftype6)(int,void*); +typedef int (ftype7)(void*,int); + +/////////////////////////////////////////////////////////////////////////////// +// NODES + +typedef struct { + void *next; +} N1; + +enum { + N2TYPE_NONE, + N2TYPE_UNK, // valid node, but not typed yet + N2TYPE_RES, // resource type + N2TYPE_OBJ, // object type + N2TYPE_PROC, // proc type + N2TYPE_MSG, // msg type + N2TYPE_L2, // l2 link + N2TYPE_MAX +}; +#define M_N2TYPE 0x1f // flags will be in the top + +enum { + N2SUB_NONE, + N2SUB_KID=0xf2, // can be used to verify that this is a kid (not needed) +}; + +// keep this whole section up to date in DC + +#define M_N2_KIDLIST 0x0001 // has kid list +#define M_N2_KIDFIRST 0x0002 // process kid list first +#define M_N2_SKIP 0x0004 // don't process this node or any kids +#define M_N2_DEAD 0x0008 // node is dead (unlinked, aborted) +#define M_N2_LEVEL0 0x0010 // 0,1,2,3 +#define M_N2_LEVEL1 0x0020 // 0,1,2,3 +#define M_N2_LEVEL 0x0030 // 0,1,2,3 +#define S_N2_LEVEL 4 +#define M_N2_STRONG 0x0080 // strong node (don't normally kill) +#define M_N2_TYPE 0x0f00 // type can use 4 bits +#define M_N2_OPEN 0x1000 // node is open (for debugging) +#define M_N2_L2LINKED 0x2000 // linked into L2 list + + + +typedef struct { + // order is assumed by compiled (res_pc.c) and loaded data + void *next; + void *prev; + uns8 type; // type + uns8 sub; // subtype info + uns16 flags; // top 8 bits of flags are reserved for type +} N2; + + +#define N2KIDLIST(n) (((N2*)n)-1) +#define N2PARENT(n) (((N2*)n)+1) +#define N2L2(n) (((N2*)n)+1) // n2 to l2 +#define L2N2(n) (((N2*)n)-1) // l2 to n2 + +#define N2_DEPTH_MAX 8 +#define N2_DEPTH_DEFAULT 8 + + +void N1LinkTail(void *headp,void *node); +void N1LinkHead(void *headp,void *node); +int N1Unlink(void *headp,void *node); + +void N2Head(void *head); +void N2DontLink(void *node); +void N2LinkAfter(void *head,void *node); +void N2LinkBefore(void *head,void *node); +void N2Unlink(void *node); +int N2Count(void *node); +void* N2Parent(void *node); +char *N2Name(N2 *n,char **s2p); + +enum { + // return codes for the scan func + N2SCANFUNC_MATCH_AND_RETURN, + N2SCANFUNC_CONTINUE +}; + +typedef struct { + N2 *stack[8]; + int stacki; + N2 *wrapper; + ftype3 *func3; // int func(N2ScanRec *nsr,N2 *n) return N2SCANFUNC_ + memu fdata; // function data + char *s1; // match string s1 + char *s2; // match string s2 +} N2ScanRec; + +#define M_N2SCAN_VAL 0x0000ffff // used to pass values in +#define M_N2SCAN_SUB 0x00010000 // look for subtype +#define M_N2SCAN_FUNC 0x00020000 // function call +#define M_N2SCAN_NAME 0x00040000 // match the name +#define M_N2SCAN_PRIME 0x00100000 // find prime obj +#define M_N2SCAN_INIT 0x00200000 // this is the first call w/n2sr -- init +#define M_N2SCAN_DONTSCAN 0x00400000 // first and don't search (init only) +#define M_N2SCAN_NODEEPER 0x00800000 // dont scan deeper +#define M_N2SCAN_NOKIDS M_N2SCAN_NODEEPER // -- depricated +#define M_N2SCAN_WRAP 0x01000000 // wrap until start instead of till list end +#define M_N2SCAN_KIDSONLY 0x02000000 // kids only +void* N2Scan(N2ScanRec *n2sr,uns find,void *node); + +// generic search func for N2 list +void *N2Search( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *) ); +// generic operation func for N2 list +void N2Walk( void *StartNode, void *OperationParam, int (*OperationFunc)(void *, void *) ); +// Combo func, searches list for matching items and performs operation on them +void N2SearchAndOperate( void *StartNode, void *CompareParam, int (*CompareFunc)(void *, void *), void *OperationParam, int (*OperationFunc)(void *, void *) ); + +// funcs for popping items off list +void *N2PopNode( void *Node ); +void *N2PopNext( void *Node ); +void *N2PopPrev( void *Node ); + + +int N2LevelSet(N2 *n,int lev); +int N2LevelGet(N2 *n); +int N2LevelCpy(N2 *dst,N2 *src); + +int N2AddDataNode( N2 *List , void *(*malloc_func)(size_t), void *data, int link_after); +int N2CountDataNodes( N2 *List ); + + +enum { + // must match resObjSubTable[], resObjSubSizes[] + OBJSUB_NONE, + OBJSUB_DATA, +}; + +// this one needs to match the same definition in core/obj.h +typedef struct { + N2 lnk; + uns32 oid; + void *data; +} ObjData; + +int N2CountDataNodes( N2 *List ); + + + +#endif // ndef NODE_H + + + diff --git a/libraries/pmrt/pmrt_utils/node.o b/libraries/pmrt/pmrt_utils/node.o new file mode 100644 index 0000000..344fdcb Binary files /dev/null and b/libraries/pmrt/pmrt_utils/node.o differ diff --git a/libraries/pmrt/pmrt_utils/pmrt_strings.c b/libraries/pmrt/pmrt_utils/pmrt_strings.c new file mode 100755 index 0000000..44e9401 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/pmrt_strings.c @@ -0,0 +1,581 @@ +#include "pmrt_strings.h" + +#include +#include + +/*! + \brief Fills in the destination string with the source string as many times as possible + \param destString destination string + \param sourceString source string + \param destLen string length of the destString + \param sourceLen string length of the source string +*/ +void StringFill(char *destString, const char *sourceString, unsigned int destLen, unsigned int sourceLen) +{ + unsigned int i = 0; + for (i = 0; i < destLen; i++ ) + destString[i] = sourceString[i % sourceLen]; +} + + +/*! + \brief strips new line and or carriage returns from string + \param string string to operate on (must be NULL terminated) +*/ +void StringChomp(char *string) +{ + int i; + for ( i = strlen(string); i >= 0; i-- ) + { + if ( string[i] == '\n' || string[i] == 13 ) // new line or carriage return + string[i] = '\0'; + } +} + +/*! + \brief inserts c into string every frequency chars (useful for adding commas to numbers, etc) + \param dst string to operate on (must be NULL terminated) + \param len size of dst in bytes (total bytes alloc'd for dst, /not/ strlen(dst)) + \param c char to insert + \param frequency insert c every frequency chars + \param origin 0 = begin inserting from start of string, 1 = begin inserting from end of string + \return number of times c was inserted, <0 on err +*/ +int StringInsertChar(char *dst, int len, char c, int frequency, int origin ) +{ + int i; + int j; + int size; + int count; + int inserts = 0; + + if ( dst == NULL || len <= 0 || frequency <= 0 ) + return -1; + + size = strlen(dst); + + count = size / frequency; + + if ( count + size + 1 > len ) + return -2; // not enough room for inserted chars + + // origin: + // 0 == start from front of string + // 1 == start from end of string + if ( origin == 0 ) + i = 0 + frequency; + else + i = size - frequency; + + while( i > 0 && i < (int)strlen(dst) ) + { + // slide every char down one + for ( j = strlen(dst) + 1; j > i; j-- ) + { + dst[j] = dst[j-1]; + } + dst[i] = c; + inserts++; + + if ( origin == 0 ) + i += frequency + 1; + else + i -= frequency; + } + + return inserts; + +} + +/*! + \brief Get the starting index of the file name from the path. Example c:\g3\main.c will return 6 + src is assumed to be null terminated + \author RA + \date 2007/11/08 + \param src source string + \param outLen length of the name will be filled in. Null terminator is not included in length. + If not needed, set to NULL + \return int starting index of the file name in the src string +*/ +int StringGetNameIndexFromPath(const char *src, int *outLen) +{ + const char *pSrc = src; + const int origLen = (src) ? (int)strlen(src) : 0; + int srcLen = origLen; + + if(!src) + return 0; + + if(outLen) + *outLen = origLen; + + pSrc += srcLen - 1; + + while(srcLen) + { + if(*pSrc == '\\' || *pSrc == '/') + { + if(outLen) + *outLen = origLen - srcLen; + return srcLen; + } + + --srcLen; + --pSrc; + } + + return 0; +} + +/*! + \brief Get the name of a file from the path. Example c:\g3\main.c will put main.c in dest + src is assumed to be null terminated + \author RA + \date 2007/11/08 + \param src source string + \param dest destination string + \param destLen size of the destination + \param outLen length of the name will be filled in. If not needed, set to NULL. + Null terminator is not included in length. +*/ +void StringGetNameFromPath(const char *src, char *dest, int destLen, int *outLen) +{ +// const char *pSrc = src; + int nameIndex = 0; + + if(!src || !dest || !destLen) + return; + + nameIndex = StringGetNameIndexFromPath(src, outLen); + + memcpy(dest, src + nameIndex, destLen); +} + +/*! + \brief Get the path from a path+fileName. Examplee c:\g3\main.c will put c:\g3\ into dest + \author RA + \date 2007/11/08 + \param src source string + \param dest dest string + \param destLen lenght of dest + \param outLen length of the path will be filled in. If not needed, set to NULL +*/ +void StringGetPath(const char *src, char *dest, int destLen, int *outLen) +{ + int pathIndex = 0; + int pathLen = 0; + int copyLen = 0; + + if(!src || !dest || !destLen) + return; + + pathIndex = StringGetPathIndex(src, &pathLen); + + if ( pathLen > 1 ) + pathLen--; // do not copy '/' unless it is the only character + + memset( dest, 0, destLen ); + copyLen = pathLen; + if ( copyLen > destLen - 1) + copyLen = destLen - 1; + memcpy(dest, src, copyLen); + + if ( outLen != NULL ) + *outLen = copyLen + 1;// add one for null terminator +} + +/*! + \brief get the ending index of the path. Example c:\g3\main.c will return 5 + \author RA + \date 2007/11/08 + \param src source string + \param outLen length of the name will be filled in. If not needed, set to NULL + \return int end index of the path +*/ +int StringGetPathIndex(const char *src, int *outLen) +{ + int nameIndex = 0; + int nameLen = 0; + if(!src) + return 0; + + nameIndex = StringGetNameIndexFromPath(src, &nameLen); + + if(outLen) + *outLen = strlen(src) - nameLen; + + return (nameIndex) ? nameIndex - 1 : 0; +} + + +/*! + \brief Finds the index of the next character in 'src' + \author RA + \date 2007/11/13 + \param src source string + \param startIndex where to start searching in the string + \param srcLen length of the 'src' string + \param c the character to search for + \return int -1 on fail, else the index +*/ +int StringIndexOfNextChar(const char *src, int startIndex, int srcLen, char c) +{ + const char *pSrc = src + startIndex; + int pos = startIndex; + + if(!src || !srcLen || startIndex > srcLen) + return -1; + + while(pos < srcLen) + { + if(*pSrc++ == c) + return pos; + + ++pos; + } + + return -1; +} + +/*! + \brief Copies text up to the first instance of 'c' from src to dest (useful for parsing comma seperated lists, etc) + \param src source string + \param start_index where in src to start copying from + \param src_len length in bytes of source string + \param dest dest buffer + \param dest_len length in bytes of dest buffer + \param c character to stop copying at +\return returns index of first char after 'c' in src (useful as start_index for next call) +*/ +int StringCopyUntilChar( const char *src, int start_index, int src_len, char *dest, int dest_len, char c ) +{ + int i; + int copy_len; + int item_len; + if ( src == NULL || src_len < 1 || dest == NULL || dest_len < 1 ) + { + return -1; + } + memset(dest,0,dest_len); + + + i = start_index; + while ( i < src_len ) + { + if ( src[i]==c || src[i] == '\0' ) + { + break; + } + i++; + } + + item_len = i - start_index; + if ( item_len > 0 ) + { + copy_len = item_len; + if ( copy_len > dest_len ) + copy_len = dest_len; + memcpy(dest,&src[start_index],copy_len); + dest[dest_len-1] = '\0'; // null terminate dest + } + + return i + 1; + +} + +/*! + \brief gets the end index of the next word in a string not including white space or newline + \author RA + \date 2007/12/06 + \param src pointer to source string + \param startIndex where to start looking in the src string + \param outEndIndex index of the end character in a word not including ' ' or '/n' + \return int 0 on success, -1 on fail +*/ +int StringGetWordEndIndex(const char * const src, int startIndex, int *outEndIndex) +{ + const char *pSrc = (src && (int)strlen(src) > startIndex) ? &src[startIndex] : 0; + + if(!pSrc|| !outEndIndex) + return -1; + + *outEndIndex = startIndex; + + while(*pSrc) + { + if(*pSrc == ' ' || *pSrc == '\n') + break; + + ++(*outEndIndex); + + ++pSrc; + } + + //discard ' ' or '\n' + if(*outEndIndex > startIndex && *pSrc) + *outEndIndex -= 1; + + return 0; +} + +static unsigned int GetHexValueFromCharacter(const char c) +{ + if(c >= '0' && c <= '9') + return c - '0'; + + if(c >= 'A' && c <= 'F') + return c - 'A' + 10; + + if(c >= 'a' && c <= 'f') + return c - 'a' + 10; + + return 0; +} + +/*! + \brief //convert a hexidecimal string into an integer. Ex: 0xffffffff returns 4294967295 as + does ffffffff + \author RA + \date 2007/12/21 + \param src hexidecimal string + \return unsigned int converted to decimal +*/ +unsigned int StringHexToDecimal(const char *const src) +{ + unsigned int length = (unsigned int)strlen(src); + unsigned int retValue = 0; + unsigned int power = 0; + int i = 0; + int end = (length == 10) ? 2 : 0; + + if(!length || (length == 10 && !(src[0]=='0' && src[1]=='x')) || (length > 8 && length != 10) ) + return 0; + + for(i = length - 1; i >= end; --i) + { + //get the value of the hex character + unsigned int charValue = GetHexValueFromCharacter(src[i]); + + //add the value to the return value + retValue += charValue * (unsigned int)( pow(16.f, (float)power) ); + + ++power; + } + + return retValue; +} + + +/*! + \brief usefule for reading strings of format "Name: value" + \author SM + \param string string to search + \param string_len length of string to search + \param dst destination buffer + \param dst_len length of the dst buffer + \param start_string where to start copying from + \param skip_start_string if 1, then copying starts after 'start_string' + \param skip_whitespace if 1, then any leading whitespace is skipped before copying to dst. whitespace == space or tab + \return int returns index of first char past matching line on success, -1 on invalid params, -3 on no match found +*/ +int FindLineInTextStringByStartString(const char *string, int string_len, int start_index, char *dst, int dst_len, const char *start_string, + int skip_start_string, int skip_whitespace ) +{ + int len; + size_t i; + char buf[256]; + char *start; + int found = 0; + int index; + + + if ( string == NULL || string_len <= 0 || dst == NULL || dst_len < 1 || start_string == NULL || start_index < 0 ) + { + // invalid params + return -1; + } + + index = start_index; + len = strlen(start_string); + + while( index < string_len - 1 ) + { + index = StringCopyUntilChar( string, index, string_len, buf, sizeof(buf), '\n' ); + StringChomp(buf); + if ( strncmp( buf, start_string, len ) == 0 ) + { + i = 0; + if ( skip_start_string == 1 ) + { + i = strlen(start_string); + } + if ( skip_start_string == 1 ) + { + while ( i < strlen(buf) && (buf[i] == ' ' || buf[i] == '\t' ) ) + { + i++; + } + } + start = &buf[i]; + found = 1; + strncpy( dst, start, dst_len ); + dst[dst_len-1] = '\0'; // always null terminate result to be safe + break; + } + } + + if ( found == 0 ) + return -3; + + return index; + +} + + +int StringIsWhiteSpace(char c ) +{ + if ( c =='\n' + || c == '\t' + || c == ' ' + || c == '\r' + ) + return 1; + + return 0; +} + +int StringFindFirstNonWhiteSpaceIndex(char *string ) +{ + int c = 0; + if ( string == NULL ) + return 0; + + while( string[c] != '\0' && StringIsWhiteSpace(string[c]) ) + c++; + + return c; +} + + +int StringFindFirstWhiteSpaceIndex(char *string ) +{ + int c = 0; + if ( string == NULL ) + return 0; + + while( string[c] != '\0' && (!StringIsWhiteSpace(string[c])) ) + c++; + + return c; +} + + + +/*! + \brief Copies text up to the first whitespace char from src to dest (useful for parsing comma seperated lists, etc) + \param src source string + \param start_index where in src to start copying from + \param src_len length in bytes of source string + \param dest dest buffer + \param dest_len length in bytes of dest buffer +\return returns index of first char after whitespace in src (useful as start_index for next call) +*/ +int StringCopyUntilWhitespace( const char *src, int start_index, int src_len, char *dest, int dest_len ) +{ + int i; + int copy_len; + int item_len; + if ( src == NULL || src_len < 1 || dest == NULL || dest_len < 1 ) + { + return -1; + } + memset(dest,0,dest_len); + + + i = start_index; + while ( i < src_len ) + { + if ( StringIsWhiteSpace(src[i]) || src[i] == '\0' ) + { + break; + } + i++; + } + + item_len = i - start_index; + if ( item_len > 0 ) + { + copy_len = item_len; + if ( copy_len > dest_len ) + copy_len = dest_len; + memcpy(dest,&src[start_index],copy_len); + dest[dest_len-1] = '\0'; // null terminate dest + } + + // skip past whitespace + while(src[i] != '\0' && StringIsWhiteSpace(src[i]) ) + i++; + + return i; + +} + + + +// taken from http://www.cse.yorku.ca/~oz/hash.html +unsigned int StringHash(char *string) +{ + unsigned char *str = (char*)string; + unsigned int hash = 0; + int c; + + while (c = *str++) + hash = c + (hash << 6) + (hash << 16) - hash; + + return hash; +} + +unsigned int StringNHash(char *string, int len ) +{ + unsigned char *str = (char*)string; + unsigned int hash = 0; + int c; + + while ( (c=*str++) && (len) ) + { + hash = c + (hash << 6) + (hash << 16) - hash; + len--; + } + + return hash; +} + +int StringChangeCase( char *src, char *dest, int upperOrLower ) +{ + char *pSrc; + char *pDest; + + pSrc = src; + pDest = dest; + + if( src == NULL || dest == NULL ) + return -1; + + while( *pSrc != '\0' ) + { + if( !upperOrLower ) + *pDest = tolower(*pSrc); + else + *pDest = toupper(*pSrc); + + pSrc++; + pDest++; + } + *pDest = '\0'; + + return 0; +} + + +//EOF + diff --git a/libraries/pmrt/pmrt_utils/pmrt_strings.h b/libraries/pmrt/pmrt_utils/pmrt_strings.h new file mode 100755 index 0000000..5325fcd --- /dev/null +++ b/libraries/pmrt/pmrt_utils/pmrt_strings.h @@ -0,0 +1,82 @@ +#ifndef PMRT_STRINGS +#define PMRT_STRINGS + + +#if SYS_PC // required to use snprintf on win32 (why MS? why?) +#define snprintf _snprintf +#endif + +//fill in destString with sourceString as many times as possible +void StringFill(char *destString, const char *sourceString, unsigned int destSize, unsigned int sourceSize); + +// strips new line and or carriage returns from string +void StringChomp(char *string); + +int StringInsertChar(char *dst, int len, char c, int frequency, int origin ); + +//get the name of a file from the path. Example c:\g3\main.c will put main.c in dest +//src is assumed to be null terminated +//outLen will be filled in with the length of the name. Set to NULL if not wanted +void StringGetNameFromPath(const char *src, char *dest, int destLen, int *outLen); + +//get the starting index of the file name from the path. Example c:\g3\main.c will return 6 +//src is assumed to be null terminated +//outLen will be filled in with the length of the name. Set to NULL if not wanted +int StringGetNameIndexFromPath(const char *src, int *outLen); + +//get the path from a path+fileName. Examplee c:\g3\main.c will put c:\g3\ into dest +//outLen will be filled in with the length of the path. Set to NULL if not wanted +void StringGetPath(const char *src, char *dest, int destLen, int *outLen); + +//get the ending index of the path. Example c:\g3\main.c will return 5 +//outLen will be filled in with the length of the path. Set to NULL if not wanted +int StringGetPathIndex(const char *src, int *outLen); + +// Copies text up to the first instance of 'c' from src to dest (useful for parsing comma seperated lists, etc) +int StringCopyUntilChar(const char *src, int start_index, int src_len, char *dest, int dest_len, char c ); + +// gets the index of the next instance of 'c' +int StringIndexOfNextChar(const char *src, int startIndex, int srcLen, char c); + +// gets the end index of the next word in a string not including white space or newline +// returns 0 on success, -1 on fail +int StringGetWordEndIndex(const char *const src, int startIndex, int *outEndIndex); + +//convert a hexidecimal string into an integer. Ex: 0xffffffff returns 4294967295 as does ffffffff +unsigned int StringHexToDecimal(const char *const src); + + +// similar to FindLineInTextFileByStartString but operates on passed string instead of a file +int FindLineInTextStringByStartString(const char *string, int string_len, int start_index, char *dst, int dst_len, const char *start_string, + int skip_start_string, int skip_whitespace ); + + +// returns 1 if c is whitespace (space, tab, newline, carriage return), 0 otherwise +int StringIsWhiteSpace(char c ); + +// returns index of first non-whitespace char in string +int StringFindFirstNonWhiteSpaceIndex(char *string ); + +// returns index of first whitespace char in string +int StringFindFirstWhiteSpaceIndex(char *string ); + + +// Copies text up to the first whitespace char from src to dest (useful for parsing comma seperated lists, etc) +int StringCopyUntilWhitespace( const char *src, int start_index, int src_len, char *dest, int dest_len ); + +unsigned int StringHash(char *string); + +unsigned int StringNHash(char *string, int len ); + + +// Changes the case of src and puts results in dest. +// - nonzero 'upperOrLower' is uppercase, 0 is lowercase. +// - src and dest may point to the same string. +// - returns 0 if no error, -1 if either pointer is null. +int StringChangeCase( char *src, char *dest, int upperOrLower ); + +#endif + +//EOF + + diff --git a/libraries/pmrt/pmrt_utils/pmrt_strings.o b/libraries/pmrt/pmrt_utils/pmrt_strings.o new file mode 100644 index 0000000..a641fd2 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/pmrt_strings.o differ diff --git a/libraries/pmrt/pmrt_utils/pmrt_utils.dsp b/libraries/pmrt/pmrt_utils/pmrt_utils.dsp new file mode 100755 index 0000000..39d6d64 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/pmrt_utils.dsp @@ -0,0 +1,300 @@ +# Microsoft Developer Studio Project File - Name="pmrt_utils" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pmrt_utils - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pmrt_utils.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pmrt_utils.mak" CFG="pmrt_utils - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pmrt_utils - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pmrt_utils - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/pmrt_utils", CVNAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pmrt_utils - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\pmrt_utils copy Release\pmrt_utils.lib c:\g3\lib copy *.h c:\g3\include\pmrt_utils +# End Special Build Tool + +!ELSEIF "$(CFG)" == "pmrt_utils - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "pmrt_utils___Win32_Debug" +# PROP BASE Intermediate_Dir "pmrt_utils___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir \g3\include\pmrt_utils copy Debug\pmrt_utils.lib \g3\lib copy *.h \g3\include\pmrt_utils +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "pmrt_utils - Win32 Release" +# Name "pmrt_utils - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\audcrc.c +# End Source File +# Begin Source File + +SOURCE=.\cguardian.c +# End Source File +# Begin Source File + +SOURCE=.\containerCommon.c +# End Source File +# Begin Source File + +SOURCE=.\containers.c +# End Source File +# Begin Source File + +SOURCE=.\dnslookup.c +# End Source File +# Begin Source File + +SOURCE=.\filesys.c +# End Source File +# Begin Source File + +SOURCE=.\icmpSock_bb.c +# End Source File +# Begin Source File + +SOURCE=.\icmpSock_pc.c +# End Source File +# Begin Source File + +SOURCE=.\interfaceInfo.c +# End Source File +# Begin Source File + +SOURCE=.\interfaceInfo_bb.c +# End Source File +# Begin Source File + +SOURCE=.\interfaceInfo_pc.c +# End Source File +# Begin Source File + +SOURCE=.\memallochist.c +# End Source File +# Begin Source File + +SOURCE=.\microtime.c +# End Source File +# Begin Source File + +SOURCE=.\netclient.c +# End Source File +# Begin Source File + +SOURCE=.\netsock_bb.c +# End Source File +# Begin Source File + +SOURCE=.\netsock_pc.c +# End Source File +# Begin Source File + +SOURCE=.\node.c +# End Source File +# Begin Source File + +SOURCE=.\pmrt_strings.c +# End Source File +# Begin Source File + +SOURCE=.\rtdatatypes.c +# End Source File +# Begin Source File + +SOURCE=.\textfile.c +# End Source File +# Begin Source File + +SOURCE=.\thread_bb.c +# End Source File +# Begin Source File + +SOURCE=.\thread_pc.c +# End Source File +# Begin Source File + +SOURCE=.\tsqueue.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\audcrc.h +# End Source File +# Begin Source File + +SOURCE=.\cguardian.h +# End Source File +# Begin Source File + +SOURCE=.\containerCommon.h +# End Source File +# Begin Source File + +SOURCE=.\containers.h +# End Source File +# Begin Source File + +SOURCE=.\dnslookup.h +# End Source File +# Begin Source File + +SOURCE=.\filesys.h +# End Source File +# Begin Source File + +SOURCE=.\icmpSock.h +# End Source File +# Begin Source File + +SOURCE=.\icmpSock_bb.h +# End Source File +# Begin Source File + +SOURCE=.\icmpSock_pc.h +# End Source File +# Begin Source File + +SOURCE=.\interfaceInfo.h +# End Source File +# Begin Source File + +SOURCE=.\interfaceInfo_bb.h +# End Source File +# Begin Source File + +SOURCE=.\interfaceInfo_pc.h +# End Source File +# Begin Source File + +SOURCE=.\memallochist.h +# End Source File +# Begin Source File + +SOURCE=.\microtime.h +# End Source File +# Begin Source File + +SOURCE=.\netclient.h +# End Source File +# Begin Source File + +SOURCE=.\netsock.h +# End Source File +# Begin Source File + +SOURCE=.\netsock_bb.h +# End Source File +# Begin Source File + +SOURCE=.\netsock_pc.h +# End Source File +# Begin Source File + +SOURCE=.\node.h +# End Source File +# Begin Source File + +SOURCE=.\pmrt_strings.h +# End Source File +# Begin Source File + +SOURCE=.\pmrt_utils.h +# End Source File +# Begin Source File + +SOURCE=.\rtdatatypes.h +# End Source File +# Begin Source File + +SOURCE=.\textfile.h +# End Source File +# Begin Source File + +SOURCE=.\thread.h +# End Source File +# Begin Source File + +SOURCE=.\thread_bb.h +# End Source File +# Begin Source File + +SOURCE=.\thread_pc.h +# End Source File +# Begin Source File + +SOURCE=.\tsqueue.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/pmrt_utils/pmrt_utils.dsw b/libraries/pmrt/pmrt_utils/pmrt_utils.dsw new file mode 100755 index 0000000..0e629e9 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/pmrt_utils.dsw @@ -0,0 +1,37 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "pmrt_utils"=.\pmrt_utils.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/pmrt_utils", CVNAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/pmrt_utils", CVNAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/pmrt_utils/pmrt_utils.h b/libraries/pmrt/pmrt_utils/pmrt_utils.h new file mode 100755 index 0000000..4e32945 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/pmrt_utils.h @@ -0,0 +1,38 @@ +// pmrt_utils.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// + +#ifndef PMRT_UTLILITIES_H +#define PMRT_UTLILITIES_H + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + +#include "memallochist.h" +#include "netsock.h" +#include "netclient.h" +#include "thread.h" +#include "tsqueue.h" +#include "cguardian.h" +#include "microtime.h" +#include "containerCommon.h" +#include "containers.h" +#include "audcrc.h" +#include "icmpSock.h" +#include "dnslookup.h" +#include "interfaceInfo.h" +#include "textfile.h" +#include "filesys.h" +#include "pmrt_strings.h" +#include "rtdatatypes.h" + + +#define PMRT_UTILS_MAJOR_VERSION 1 +#define PMRT_UTILS_MINOR_VERSION 4 +#define PMRT_UTILS_SUB_MINOR_VERSION 0x01 + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/pmrt_utils.ncb b/libraries/pmrt/pmrt_utils/pmrt_utils.ncb new file mode 100755 index 0000000..3ebcb37 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/pmrt_utils.ncb differ diff --git a/libraries/pmrt/pmrt_utils/pmrt_utils.opt b/libraries/pmrt/pmrt_utils/pmrt_utils.opt new file mode 100755 index 0000000..a75bc4d Binary files /dev/null and b/libraries/pmrt/pmrt_utils/pmrt_utils.opt differ diff --git a/libraries/pmrt/pmrt_utils/pmrt_utils.plg b/libraries/pmrt/pmrt_utils/pmrt_utils.plg new file mode 100755 index 0000000..8a73ab7 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/pmrt_utils.plg @@ -0,0 +1,93 @@ + + +
+

Build Log

+

+--------------------Configuration: pmrt_utils - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP304.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR"Debug/" /Fp"Debug/pmrt_utils.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_utils\containers.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP304.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP305.tmp" with contents +[ +/nologo /out:"Debug\pmrt_utils.lib" +.\Debug\audcrc.obj +.\Debug\cguardian.obj +.\Debug\containerCommon.obj +.\Debug\containers.obj +.\Debug\dnslookup.obj +.\Debug\filesys.obj +.\Debug\icmpSock_bb.obj +.\Debug\icmpSock_pc.obj +.\Debug\interfaceInfo.obj +.\Debug\interfaceInfo_bb.obj +.\Debug\interfaceInfo_pc.obj +.\Debug\memallochist.obj +.\Debug\microtime.obj +.\Debug\netclient.obj +.\Debug\netsock_bb.obj +.\Debug\netsock_pc.obj +.\Debug\node.obj +.\Debug\pmrt_strings.obj +.\Debug\rtdatatypes.obj +.\Debug\textfile.obj +.\Debug\thread_bb.obj +.\Debug\thread_pc.obj +.\Debug\tsqueue.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP305.tmp" +

Output Window

+Compiling... +containers.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP306.bat" with contents +[ +@echo off +mkdir \g3\include\pmrt_utils +copy Debug\pmrt_utils.lib \g3\lib +copy *.h \g3\include\pmrt_utils +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP306.bat" + +A subdirectory or file \g3\include\pmrt_utils already exists. + 1 file(s) copied. +audcrc.h +cguardian.h +containerCommon.h +containers.h +dnslookup.h +filesys.h +icmpSock.h +icmpSock_bb.h +icmpSock_pc.h +interfaceInfo.h +interfaceInfo_bb.h +interfaceInfo_pc.h +memallochist.h +microtime.h +netclient.h +netsock.h +netsock_bb.h +netsock_pc.h +node.h +pmrt_strings.h +pmrt_utils.h +rtdatatypes.h +textfile.h +thread.h +thread_bb.h +thread_pc.h +tsqueue.h + 27 file(s) copied. + + + +

Results

+pmrt_utils.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/pmrt_utils/rtdatatypes.c b/libraries/pmrt/pmrt_utils/rtdatatypes.c new file mode 100755 index 0000000..2f8cfde --- /dev/null +++ b/libraries/pmrt/pmrt_utils/rtdatatypes.c @@ -0,0 +1,1421 @@ +// rtdatatypes.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for parsing datatypes at runtime + +#include "rtdatatypes.h" +#include "pmrt_utils.h" + + +#define RTDT_PARSER_FORMS_BLOCK_SIZE 32 // number of forms to malloc for at one time + + + + +// RTDataSmallString +// example of a type defined at compile time +// see top of rtdatatypes.h for typedef +RTDataTypeMemberForm RTDataSmallStringMember = { "char", 0, "string", 0, RTDT_MAX_FORM_NAME_LEN, RTDT_MAX_FORM_NAME_LEN }; +RTDataTypeMemberForm RTDataTwoSmallStringsMember = { "RTDataSmallString", 0, "strings", 0, 2, 2*RTDT_MAX_FORM_NAME_LEN }; +RTDataTypeMemberForm RTDataLongStringMember = { "char", 0, "string", 0, 4*RTDT_MAX_FORM_NAME_LEN, 4*RTDT_MAX_FORM_NAME_LEN }; + + +RTDataTypeForm gRTDT_BaseForms[] = +{ + { "NULL", 0, 0, 0, NULL }, + + { "char", 0, sizeof(char), 0, NULL }, + { "unsigned char", 0, sizeof(unsigned char), 0, NULL }, + + { "float", 0, sizeof(float), 0, NULL }, + { "double", 0, sizeof(double), 0, NULL }, + + { "int", 0, sizeof(int), 0, NULL }, + { "unsigned int", 0, sizeof(unsigned int), 0, NULL }, + + { "void*", 0, sizeof(void*), 0, NULL }, + + { "short", 0, sizeof(short), 0, NULL }, + { "unsigned short", 0, sizeof(unsigned short), 0, NULL }, + + + // common macros used by g3 engine (pm.h) + { "uns8", 0, sizeof(uns8), 0, NULL }, + { "uns16", 0, sizeof(uns16), 0, NULL }, + { "uns32", 0, sizeof(uns32), 0, NULL }, + + + // example of a type defined at compile time + { "RTDataSmallString", 0, sizeof(RTDataSmallString), 1, &RTDataSmallStringMember }, + { "RTDataTwoSmallStrings", 0, sizeof(RTDataTwoSmallStrings), 1, &RTDataTwoSmallStringsMember }, + { "RTDataLongString", 0, sizeof(RTDataLongString), 1, &RTDataLongStringMember }, + + + +}; + + +int RTDataSetByString( RTDataTypeForm *tform, RTDataTypeMemberForm *mform, void *data, char *value ) +{ + if ( tform == NULL || data == NULL || value == NULL ) + return 0; + + // for now the base types are just hardcoded in here, consider some sort of callback system + if ( strcmp(tform->type,"char") == 0 ) + { + // special case, for an array of char, then string copy + if ( mform != NULL && mform->count > 0 ) + { + strncpy( data, value, mform->count ); + ((char*)data)[mform->count-1] = '\0'; // terminate to be safe + } + else + { + *(char*)data = atoi(value); + } + } + else if ( strcmp( tform->type, "unsigned char" ) == 0 || strcmp( tform->type, "uns8" ) == 0) + { + *(unsigned char*)data = atoi(value); + } + else if ( strcmp( tform->type, "float" ) == 0 ) + { + *(float*)data = (float)atof(value); + } + else if ( strcmp( tform->type, "double" ) == 0 ) + { + *(double*)data = atof(value); + } + else if ( strcmp( tform->type, "int" ) == 0 ) + { + *(int*)data = atoi(value); + } + else if ( strcmp( tform->type, "unsigned int" ) == 0 || strcmp( tform->type, "uns32" ) == 0) + { + *(unsigned int*)data = atol(value); + } + else if ( strcmp( tform->type, "short" ) == 0 ) + { + *(short*)data = atoi(value); + } + else if ( strcmp( tform->type, "unsigned short" ) == 0 || strcmp( tform->type, "uns16" ) == 0 ) + { + *(unsigned short*)data = atoi(value); + } + + return 0; + // memcpy( data, value, tform->size ); + +} + + +int RTDataGetByString( RTDataTypeForm *tform, RTDataTypeMemberForm *mform, void *data, char *value, int value_len ) +{ + if ( tform == NULL || data == NULL || value == NULL || value_len <= 0 ) + return 0; + + memset(value,0,value_len); // blank string + + // for now the base types are just hardcoded in here, consider some sort of callback system + if ( strcmp(tform->type,"char") == 0 ) + { + // special case, for an array of char, then string copy + if ( mform != NULL && mform->count > 0 ) + { + strncpy( value, data, value_len ); + ((char*)value)[value_len-1] = '\0'; // terminate to be safe + } + else + { + snprintf( value, value_len, "%c", *(char*)data ); + } + } + else if ( strcmp( tform->type, "unsigned char" ) == 0 ) + { + snprintf( value, value_len, "%uc", *(unsigned char*)data ); + } + else if ( strcmp( tform->type, "float" ) == 0 ) + { + snprintf( value, value_len, "%f", *(float*)data ); + } + else if ( strcmp( tform->type, "double" ) == 0 ) + { + snprintf( value, value_len, "%f", *(double*)data ); + } + else if ( strcmp( tform->type, "int" ) == 0 ) + { + snprintf( value, value_len, "%d", *(int*)data ); + } + else if ( strcmp( tform->type, "unsigned int" ) == 0 ) + { + snprintf( value, value_len, "%u", *(unsigned int*)data ); + } + + value[value_len-1]='\0'; // just to be sure + + return 1; + // memcpy( data, value, tform->size ); + +} + +int ReadCStructMemberLine( char *line, char *type, char *name, char *count ) +{ + char *l,*t,*n,*c; + + // skip white space + l = line; + while( StringIsWhiteSpace(*l) ) + l++; + + // read in type + t= type; + while( (!StringIsWhiteSpace(*l)) && *l != '\0' ) + { + *t = *l; + t++; + l++; + } + *t = '\0'; + if ( strcmp(type,"unsigned") == 0 ) // then read next word + { + *t = ' '; + t++; + // skip white space + while( StringIsWhiteSpace(*l) ) + l++; + + while( (!StringIsWhiteSpace(*l)) && *l != '\0' ) + { + *t = *l; + t++; + l++; + } + *t = '\0'; + + } + + // skip white space + while( StringIsWhiteSpace(*l) ) + l++; + + // deal with ptr flags + while ( *l == '*' ) + { + *t = '*'; + t++; + *t='\0'; + l++; + } + + + // read in name + n = name; + while( (!StringIsWhiteSpace(*l)) && *l != '[' && *l != '\0' ) + { + *n = *l; + l++; + n++; + } + *n = '\0'; + + count[0] = '1'; + count[1] = '\0'; + if ( *l == '[' ) + { + l++; + c = count; + while( (!StringIsWhiteSpace(*l)) && *l != ']' && *l != '\0' ) + { + *c = *l; + l++; + c++; + } + *c = '\0'; + } + + return (memu)l - (memu)line; +} + +RTDataTypeForm *RTDataFindForm( RTDataTypeForm **Forms, char *type ) +{ + unsigned int thash = 0; + RTDataTypeForm *Form = NULL; + + if (Forms == NULL || type == NULL ) + return NULL; + + thash = StringHash(type); + + while( (Form = Forms[0]) != NULL ) + { + if ( Form->type_hash == thash + && + (strcmp(Form->type,type)==0) ) + return Form; + Forms++; + } + return NULL; +} + + +// bogus stuff to handle simple #defines +struct CDefineMacro +{ + char name[32]; + int value; +}; + +struct CDefineMacro gCDefines[32]; +int gNumCDefines = 0; + +int ResetCDefines( ) +{ + gNumCDefines = 0; + memset(gCDefines,0,sizeof(gCDefines) ); + return 0; +} + +int LookupCDefine( char *string ) +{ + int i; + for ( i = 0; i < gNumCDefines; i++ ) + { + if ( strcmp( string, gCDefines[i].name )== 0 ) + return gCDefines[i].value; + } + + return 0; +} + +int SetCDefine( char *name, int value ) +{ + if ( gNumCDefines >= COUNT(gCDefines ) ) + return -1; + + memset( gCDefines[gNumCDefines].name, 0, sizeof(gCDefines[gNumCDefines].name) ); + strncpy( gCDefines[gNumCDefines].name , name, sizeof(gCDefines[gNumCDefines].name) - 1 ); + gCDefines[gNumCDefines].value = value; + gNumCDefines++; + return 0; +} + +// takes input of form "#define STRING value" +int ParseCDefine( char *src ) +{ + char name[32]; + int value; + int i,t = 0; + + + // skip leading whitespace + i = StringFindFirstNonWhiteSpaceIndex(src); + t+=i; + src=&src[i]; + + if ( strncmp( src, "#define", strlen("#define") ) != 0 ) + return t; // no good format + + // skip #define + i = StringFindFirstWhiteSpaceIndex(src); + t+=i; + src=&src[i]; + + // skip whitespace + i = StringFindFirstNonWhiteSpaceIndex(src); + t+=i; + src=&src[i]; + + // read in name + i = StringCopyUntilWhitespace( src, 0, strlen(src), name , sizeof(name) ); + t+=i; + src=&src[i]; // skip name and trailing whitespace + + // pull in value + value = atoi(src); + + // add to global list + SetCDefine(name,value); + + // skip value and trailing whitespace + i = StringFindFirstWhiteSpaceIndex(src); + t+=i; + src=&src[i]; + i = StringFindFirstNonWhiteSpaceIndex(src); + t+=i; + src=&src[i]; + + // return index after everyting that was read in + return t; + +} + + +int CreateNewDataTypeFromCStruct( RTDataTypeForm **Forms, RTDataTypeForm *NewForm, char *c_def, int byte_alignment ) +{ + char *src; + char *dst; + char *body; + char *end; + + // char *l; //,*t,*n,*c; + RTDataTypeForm *MemberForm; + RTDataTypeMemberForm *Member; + RTDataTypeMemberForm *prev_Member; + + + char head[128]; + char tail[128]; + char line[128]; + char type[128]; + char name[128]; + char count[128]; + + int size,i,pad; + + if ( Forms == NULL || NewForm == NULL || c_def == NULL ) + return -1; + + memset(NewForm, 0, sizeof( RTDataTypeForm ) ); + + // format we expect is a c struct + // so: + // [typedef] struct NAME { int c; float b[100]; } NAME; + // + + // read in header + src = c_def; + dst = head; + while( *src !='{' && *src != '\0' ) + { + *dst = *src; + src++; + dst++; + } + *dst = '\0'; + + if ( *src == '\0' ) + return -2; + + src++; // skip past curly brace + // mark start of body + body = src; + + // count elements + dst = line; + NewForm->member_count = 0; + while( *src !='}' && *src != '\0' ) + { + // skip C/C++ style comments + if ( src[0] == '/' && src[1] == '/' ) + { + src = strstr( src, "\n" ); // skip line + if ( src == NULL ) + return -3; // nothing after the comment + src++; // skip past the new line + continue; + } + if ( src[0] == '/' && src[1] == '*' ) + { + src++; + src++; + src = strstr( src, "*/" ); // skip to end of comment + if ( src == NULL ) + return -3; // comment not closed + // skip comment terminator + src+=2; + continue; + } + + + *dst = *src; + if ( *src == ';' ) + { + NewForm->member_count++; + *dst = '\0'; + dst = line; + } + else + dst++; + + src++; + } + + if ( *src == '\0' ) + return -3; + + // read in tail + src++; + dst = tail; + while( *src != '\0' && *src != ';' ) + { + *dst = *src; + src++; + dst++; + } + *dst = '\0'; + + // note the end of the definition + end = src; + + // try to pull name of new form out of tail or header + src = tail; + + // skip leading whitespace + i = StringFindFirstNonWhiteSpaceIndex(src); + src=&src[i]; + + // int StringCopyUntilWhitespace( const char *src, int start_index, int src_len, char *dest, int dest_len ); + name[0] = '\0'; + i = StringCopyUntilWhitespace( src, 0, RTDT_MAX_FORM_NAME_LEN, name, RTDT_MAX_FORM_NAME_LEN ); + + if ( name[0] == '\0' ) + { + src = head; + while(1) + { + // skip leading whitespace + i = StringFindFirstNonWhiteSpaceIndex(src); + src=&src[i]; + + // int StringCopyUntilWhitespace( const char *src, int start_index, int src_len, char *dest, int dest_len ); + name[0] = '\0'; + i = StringCopyUntilWhitespace( src, 0, RTDT_MAX_FORM_NAME_LEN, name, RTDT_MAX_FORM_NAME_LEN ); + src=&src[i]; + + if ( (strcmp( name, "struct" ) != 0) + && + (strcmp( name, "typedef" ) != 0) ) + break; + if (src == head + || src[0] == '\0' ) + break; + } + + if ( name[0] == '\0' ) + return -4; + + } + + strcpy( NewForm->type, name); + NewForm->type_hash = StringHash(NewForm->type); + + + size = sizeof(RTDataTypeMemberForm) * NewForm->member_count; + + NewForm->members = (RTDataTypeMemberForm *)malloc(size); + if ( NewForm->members == NULL ) + return -5; + + Member = NewForm->members; + prev_Member = Member; + memset( NewForm->members, 0, size ); + + // now we go back to the body and read in the elements + // mark start of body + src = body; + + // count elements + dst = line; + while( *src !='}' && *src != '\0' ) + { + // skip C/C++ style comments + if ( src[0] == '/' && src[1] == '/' ) + { + src = strstr( src, "\n" ); // skip line + if ( src == NULL ) + return -3; // nothing after the comment + src++; // skip past the new line + continue; + } + if ( src[0] == '/' && src[1] == '*' ) + { + src++; + src++; + src = strstr( src, "*/" ); // skip to end of comment + if ( src == NULL ) + return -3; // comment not closed + // skip comment terminator + src+=2; + continue; + } + + *dst = *src; + if ( *src == ';' ) + { + *dst = '\0'; + ReadCStructMemberLine( line, type, name, count ); + MemberForm = RTDataFindForm( Forms, type ); + if ( MemberForm != NULL ) + { + // fill out member struct + Member->count = atoi(count); + if ( Member->count == 0 ) // count is a string + Member->count = LookupCDefine( count ); // then check for a matching #define + strcpy( Member->type, MemberForm->type ); + Member->type_hash = MemberForm->type_hash; + strcpy( Member->name, name); + Member->name_hash = StringHash(Member->name); + + // inc size of total struct + size = (MemberForm->size * Member->count); + + // if needed pad prev member up to meet the byte alignment + // this happens at the border of byte aligned + // and non-aligned members + if ( ((size % byte_alignment)==0) + && ((NewForm->size % byte_alignment)!=0) ) + { + pad = byte_alignment - (NewForm->size % byte_alignment); + prev_Member->byte_aligned_size += pad; + NewForm->size += pad; + } + + // record the byte_aligned size for use when walking struct later + Member->byte_aligned_size = size; + + NewForm->size += Member->byte_aligned_size; + + prev_Member = Member; + + Member++; + + } + else + { + // big trouble + } + + dst = line; + } + else + dst++; + + src++; + } + + + // pad out tail + if ( ((NewForm->size % byte_alignment)!=0) ) + NewForm->size += byte_alignment - (NewForm->size % byte_alignment); + + return (memu)end - (memu)c_def; // index where we stopped + + +} + + + + + + +int RTDataTypeParser_GrowForms( RTDataTypeParser *prtdtp ) +{ + int i,count,size; + RTDataTypeForm **NewForms = NULL; + + if ( prtdtp == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + // add new ptrs in groups of RTDT_PARSER_FORMS_BLOCK_SIZE + count = prtdtp->max_form_count + RTDT_PARSER_FORMS_BLOCK_SIZE; + + // malloc space for form ptrs + size = count * sizeof(RTDataTypeForm*); + NewForms = (RTDataTypeForm**)malloc(size); + + if ( NewForms == NULL ) + return RTDT_RESULT_MALLOC_FAILED; + + // zero ptrs + memset(NewForms, 0, size ); + + // copy ptrs from old list + for( i = 0; i < prtdtp->max_form_count; i++ ) + NewForms[i] = prtdtp->Forms[i]; + + if ( prtdtp->Forms ) + free(prtdtp->Forms); // free old list + + // point to new list + prtdtp->Forms = NewForms; + // update size + prtdtp->max_form_count += RTDT_PARSER_FORMS_BLOCK_SIZE; + + return RTDT_RESULT_SUCCESS; + +} + + +int RTDataTypeParser_AddNewDataType( RTDataTypeParser *prtdtp, RTDataTypeForm *Form ) +{ + int ec,m; + + if ( prtdtp == NULL || Form == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + if ( prtdtp->form_count >= prtdtp->max_form_count - 1 ) // last form reserved for NULL ptr + { + ec = RTDataTypeParser_GrowForms( prtdtp ); + if ( ec != RTDT_RESULT_SUCCESS ) + return ec; + } + + prtdtp->Forms[prtdtp->form_count] = (RTDataTypeForm*)malloc(sizeof(RTDataTypeForm)); + if ( prtdtp->Forms[prtdtp->form_count] == NULL ) + return RTDT_RESULT_MALLOC_FAILED; + + memcpy( prtdtp->Forms[prtdtp->form_count], Form, sizeof(RTDataTypeForm) ); + + // set hash values (mainly used for compile time types, since it is hard to set these up ahead of time) + prtdtp->Forms[prtdtp->form_count]->type_hash = StringHash(prtdtp->Forms[prtdtp->form_count]->type); + + for ( m = 0; m < Form->member_count; m++ ) + { + Form->members[m].name_hash = StringHash(Form->members[m].name); + Form->members[m].type_hash = StringHash(Form->members[m].type); + } + + prtdtp->form_count++; + + return RTDT_RESULT_SUCCESS; + +} + + +int RTDataTypeParser_Init( RTDataTypeParser *prtdtp, int byte_alignment ) +{ + int i,ec; + if ( prtdtp == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + // clear out handle + memset( prtdtp, 0, sizeof(RTDataTypeParser) ); + + ec = RTDataTypeParser_GrowForms( prtdtp ); + if ( ec != RTDT_RESULT_SUCCESS ) + return ec; + + // load in compile time types (primatives) + for ( i = 0; i < COUNT(gRTDT_BaseForms); i++ ) + { + ec = RTDataTypeParser_AddNewDataType( prtdtp, &gRTDT_BaseForms[i] ); + if ( ec != RTDT_RESULT_SUCCESS ) + return ec; + } + + prtdtp->byte_alignment = byte_alignment; + return RTDT_RESULT_SUCCESS; + +} + + +int RTDataTypeParser_DeInit( RTDataTypeParser *prtdtp ) +{ + + int i; + + if ( prtdtp == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + + // free forms list + if ( prtdtp->Forms ) + { + for ( i = COUNT(gRTDT_BaseForms); i < prtdtp->max_form_count; i++ ) // do not free the built in forms + { + if ( prtdtp->Forms[i] != NULL ) + { + if ( prtdtp->Forms[i]->members ) + free(prtdtp->Forms[i]->members); + free(prtdtp->Forms[i]); + prtdtp->Forms[i] = NULL; + } + } + free(prtdtp->Forms); + } + + prtdtp->form_count = 0; + prtdtp->max_form_count = 0; + + return RTDT_RESULT_SUCCESS; + +} + +int RTDataTypeParser_AddNewDataTypeFromCStruct( RTDataTypeParser *prtdtp, char *c_def ) +{ + int ec; + RTDataTypeForm Form; + + if ( prtdtp == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + memset(&Form,0,sizeof(Form)); + + ec = CreateNewDataTypeFromCStruct(prtdtp->Forms, &Form, c_def, prtdtp->byte_alignment ); + if ( ec < 0 ) + return RTDT_RESULT_PARSE_FAILED; + + ec = RTDataTypeParser_AddNewDataType( prtdtp, &Form ); + + return ec; + +} + + +int RTDataTypeParser_AddNewDataTypesFromCDefFile( RTDataTypeParser *prtdtp, char *filename ) +{ + int ec; + RTDataTypeForm Form; + char *string; + int string_len; + int i,n; + + if ( prtdtp == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + string = NULL; + string_len = 0; + ec = FsLoadFile( filename, &string, &string_len, NULL, NULL ); + if ( ec != FS_ERR_NONE ) + return RTDT_RESULT_LOAD_FAILED; + + string[string_len-1] = '\0'; // note that this foresakes the last char of the file, but in our case that turns out to be safe to do (worst case it is a ';' at the end of typedef, but our parses stops at '\0' also) + + + ResetCDefines(); // clear global list of #defines + i = 0; + + while ( i < string_len - 2 ) // read up to the 2nd to last char + { + // skip whitespace + i += StringFindFirstNonWhiteSpaceIndex(&string[i]); + + // skip comments + while( i < string_len && string[i] == '/' && string[i+1] == '/' ) + { + n = StringIndexOfNextChar( &string[i], 0, string_len - i, '\n' ); + if ( n < 0 ) + i = string_len; // no end to comment + else + i += n; + + i += StringFindFirstNonWhiteSpaceIndex(&string[i]); + } + if ( string[i] == '/' && string[i+1] == '*' ) + { + while ( i < string_len - 1 ) + { + n = StringIndexOfNextChar( &string[i], 0, string_len - i, '*' ); + if ( n < 0 ) + i = string_len; // no end to comment + else + i += n + 1; //skip past char + + if ( i >= string_len - 1 ) + break; + if ( string[i+1] == '/' ) // end of comment + { + i+=2; // skip past '*/' + break; + } + } + } + // reached of string while skipping comments/whitespace + if ( i >= string_len - 1 ) + break; + + + // check if word is of interest... + if ( strncmp( &string[i], "typedef", strlen("typedef") ) == 0 ) + { + // found a typedef, read it in + + memset(&Form,0,sizeof(Form)); + + ec = CreateNewDataTypeFromCStruct(prtdtp->Forms, &Form, &string[i], prtdtp->byte_alignment ); + if ( ec < 0 ) + { + free(string); + return RTDT_RESULT_PARSE_FAILED; + } + // return code is index of end of typedef + i += ec; + + ec = RTDataTypeParser_AddNewDataType( prtdtp, &Form ); + if ( ec != RTDT_RESULT_SUCCESS ) + { + free(string); + return ec; + } + + // re-loop + continue; + } + else if ( strncmp( &string[i], "#define", strlen("#define") ) == 0 ) + { + i += ParseCDefine( &string[i] ); // should return index of first word after '#define STRING VALUE' statement + continue; + } + + i += StringFindFirstWhiteSpaceIndex( &string[i] ); // skip past word + + } + + free(string); + return RTDT_RESULT_SUCCESS; + +} + + + +RTDataTypeForm *RTDataTypeParser_GetType( RTDataTypeParser *prtdtp, char *type ) +{ + if ( prtdtp == NULL ) + return NULL; + + return RTDataFindForm( prtdtp->Forms,type ); + +} + +int RTDataTypeParser_SizeOf( RTDataTypeParser *prtdtp, char *type ) +{ + RTDataTypeForm *tform; + if ( prtdtp == NULL || type == NULL) + return 0; + + tform = RTDataTypeParser_GetType( prtdtp, type ); + if ( tform == NULL ) + { + if ( strstr(type,"*") != NULL) + return sizeof(void*); // all ptrs are the same size + return 0; + } + + return tform->size; + +} + + + +void *RTDataTypeParser_GetMember( RTDataTypeParser *prtdtp, char *type, char *member, void *data, RTDataTypeForm **type_form, RTDataTypeMemberForm **member_form ) +{ + RTDataTypeForm *tform; + + RTDataTypeForm *mtform; + + RTDataTypeMemberForm *mform; + int m; + unsigned int mhash; + int len; + int index; + + char *next_member; + char *array_index; + + char *ptr = (char *)data; + + if ( prtdtp == NULL || type == NULL || data == NULL ) + return NULL; // RTDT_RESULT_INVALID_PARAMS; + + + tform = RTDataFindForm( prtdtp->Forms, type ); + if ( tform == NULL ) + return NULL; // RTDT_RESULT_UNKNOWN_DATATYPE; + + // we are there + if ( tform->member_count == 0 || member == NULL ) + { + index = 0; + if ( member ) + { + // check for array ref, eg "johnny[100]" + array_index = strstr( member, "[" ); + // found an array index and that array_index is not on a nested member + if ( array_index != NULL ) + { + array_index++; + index = atoi(array_index); + } + } + ptr += (index * tform->size); + if ( type_form != NULL ) + *type_form = tform; + return ptr; + //memcpy( ptr, value, tform->size ); + //return RTDT_RESULT_SUCCESS; + } + + + // else need to walk type's members until we are there + + // check for nested setting, eg "johnny.x" + next_member = strstr( member, "." ); + if ( next_member != NULL ) + { + len = (memu)next_member - (memu)member; + next_member++; // skip past the . + } + else + len = strlen(member); + + + index = 0; + // check for array ref, eg "johnny[100]" + array_index = strstr( member, "[" ); + // found an array index and that array_index is not on a nested member + if ( array_index != NULL && + ( (next_member==NULL) || (memu)array_index < (memu)next_member) ) + { + // take array index chars off member name + len = ( (memu)array_index - (memu)member ); + array_index++; + index = atoi(array_index); + } + + mhash = StringNHash(member, len); + + for ( m = 0; m < tform->member_count; m++ ) + { + mform = &tform->members[m]; + + if ( mform->name_hash == mhash + && + (strncmp(mform->name,member,len)==0) ) + { + // if required, advance to correct element in array + if ( index != 0 ) + { + mtform = RTDataFindForm( prtdtp->Forms, mform->type ); + if ( mtform == NULL ) + return NULL; // unknown type + ptr += (mtform->size * index); + } + // return membership info (this comes one level up from the actual data) + if ( member_form != NULL ) + *member_form = mform; + return RTDataTypeParser_GetMember( prtdtp, mform->type , next_member, ptr, type_form, member_form ); + } + ptr+=mform->byte_aligned_size; + } + + // we got through all the members without a match! :( + return NULL; + +} + + +int RTDataTypeParser_SetMember( RTDataTypeParser *prtdtp, char *type, char *member, void *data, void *value ) +{ + RTDataTypeForm *tform = NULL; + + data = RTDataTypeParser_GetMember( prtdtp, type, member, data, &tform, NULL ); + if ( data == NULL || tform == NULL ) + return RTDT_RESULT_MEMBER_NOT_FOUND; + + if (tform->size) + memcpy( data, value, tform->size ); + + return RTDT_RESULT_SUCCESS; + + + +} + + + +int RTDataTypeParser_SetByString( RTDataTypeParser *prtdtp, char *type, char *member, void *data, char *value ) +{ + RTDataTypeForm *tform = NULL; + RTDataTypeMemberForm *mform = NULL; + + data = RTDataTypeParser_GetMember( prtdtp, type, member, data, &tform, &mform ); + if ( data == NULL || tform == NULL ) + return RTDT_RESULT_MEMBER_NOT_FOUND; + + + RTDataSetByString( tform, mform, data, value ); + + return RTDT_RESULT_SUCCESS; +} + + +int RTDataTypeParser_GetByString( RTDataTypeParser *prtdtp, char *type, char *member, void *data, char *value, int value_len ) +{ + RTDataTypeForm *tform = NULL; + RTDataTypeMemberForm *mform = NULL; + + data = RTDataTypeParser_GetMember( prtdtp, type, member, data, &tform, &mform ); + if ( data == NULL || tform == NULL ) + return RTDT_RESULT_MEMBER_NOT_FOUND; + + + RTDataGetByString( tform, mform, data, value, value_len ); + + return RTDT_RESULT_SUCCESS; + +} + + + + +int RTDataTypeWalk( RTDataTypeForm **Forms, RTDataTypeForm *tform, RTDataTypeMemberForm *mform, int array_index, void *data, int (*OpFunc)(RTDataTypeForm *, RTDataTypeMemberForm *, int, void *, void *), void *OpFuncData ) +{ + int ec,m,i,len; + RTDataTypeMemberForm *member = NULL; + RTDataTypeForm *mtform = NULL; + char *cd = (char*)data; + + if ( tform->member_count == 0 ) // primative type + { + ec = OpFunc( tform, mform, array_index, (void*)cd, OpFuncData ); + if ( ec < 0 ) // signal to stop walking + return ec; + } + + // else, walk members + for ( m = 0; m < tform->member_count; m++ ) + { + member = &tform->members[m]; + mtform = RTDataFindForm( Forms, member->type ); + if ( mtform == NULL ) + return -1; + for ( i = 0; i < member->count; i++ ) + { + ec = RTDataTypeWalk( Forms, mtform, member, i, (void*)cd, OpFunc, OpFuncData ); + if ( ec < 0 ) + return ec; + + // if data ptr was given, advance it + if ( (void*)cd ) + { + cd += mtform->size; + } + } + if ( data ) + { + // account for byte alignment + len = member->byte_aligned_size - (mtform->size * member->count); + if ( len > 0 ) + cd += len; + } + + } + + return 0; + +} + +int RTDataTypeWalkFuncPrint( RTDataTypeForm *tform, RTDataTypeMemberForm *mform, int array_index, void *data, void *opdata ) +{ + if ( mform != NULL ) + printf( "Member: %s, Type: %s, Index %d\n", mform->name, tform->type, array_index ); + else + printf( "Member: %s, Type: %s, Index %d\n", "NULL", tform->type, array_index ); + + return 0; +} + +struct RTDT_Tokenize_WalkData +{ + char *str; + int str_len; + + char *cur_str_pos; + int str_remaining; + + char *seperator; + char *wrapper; +}; + +/* +int RTDataTypeWalkFuncTokenize( RTDataTypeForm *tform, RTDataTypeMemberForm *mform, int array_index, void *data ) +{ + int len; + struct RTDT_Tokenize_WalkData *wdata; + + wdata = (struct RTDT_Tokenize_WalkData *)data; + + // char arrays are always treated like strings and copied on first array_index + if ( strcmp(tform->type,"char") == 0 && mform && array_index > 0 ) + { + // still need to advance data pointer + wdata->cur_data_pos += tform->size; + // are we on the last element of an array? + if ( mform->count - 1 == array_index ) + { + // then account for byte alignment + if ( len > 0 ) + wdata->cur_data_pos += len; + } + return 0; + } + + if ( wdata->str_remaining <= 0 ) + return 0; + + if ( wdata->wrapper ) + { + strncat( wdata->cur_str_pos, wdata->wrapper, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + } + + RTDataGetByString( tform, mform, wdata->cur_data_pos, wdata->cur_str_pos, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + + wdata->cur_data_pos += tform->size; + + if ( mform ) + { + // are we on the last element of an array? + if ( mform->count - 1 == array_index ) + { + // then account for byte alignment + len = mform->byte_aligned_size - (tform->size * mform->count); + if ( len > 0 ) + wdata->cur_data_pos += len; + } + } + + if ( wdata->wrapper ) + { + strncat( wdata->cur_str_pos, wdata->wrapper, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + } + + if ( wdata->seperator) + { + strncat( wdata->cur_str_pos, wdata->seperator, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + } + + return 1; + +} +*/ + +int RTDataTypeWalkFuncTokenize( RTDataTypeForm *tform, RTDataTypeMemberForm *mform, int array_index, void *data, void *opdata ) +{ + int len; + struct RTDT_Tokenize_WalkData *wdata; + + wdata = (struct RTDT_Tokenize_WalkData *)opdata; + + // char arrays are always treated like strings and copied on first array_index + if ( strcmp(tform->type,"char") == 0 && mform && array_index > 0 ) + return 0; + + if ( wdata->str_remaining <= 0 ) + return 0; + + if ( wdata->wrapper ) + { + strncat( wdata->cur_str_pos, wdata->wrapper, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + } + + RTDataGetByString( tform, mform, data, wdata->cur_str_pos, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + + + if ( wdata->wrapper ) + { + strncat( wdata->cur_str_pos, wdata->wrapper, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + } + + if ( wdata->seperator) + { + strncat( wdata->cur_str_pos, wdata->seperator, wdata->str_remaining ); + // advance past what we just pasted on + len = strlen(wdata->cur_str_pos); + wdata->cur_str_pos += len; + wdata->str_remaining -= len; + } + + return 1; + +} + + +int RTDataTypeWalkFuncDeTokenize( RTDataTypeForm *tform, RTDataTypeMemberForm *mform, int array_index, void *data, void *opdata ) +{ + char *c; + struct RTDT_Tokenize_WalkData *wdata; + + wdata = (struct RTDT_Tokenize_WalkData *)opdata; + + if ( wdata->cur_str_pos == NULL ) + return -1; + + // char arrays are always treated like strings and copied on first array_index + if ( strcmp(tform->type,"char") == 0 && mform && array_index > 0 ) + return 0; + + + if ( wdata->wrapper ) + { + // skip wrapper + wdata->cur_str_pos += strlen(wdata->wrapper); + } + + RTDataSetByString( tform, mform, data, wdata->cur_str_pos ); + + // for char array, the above will copy as much of the src string as will fit + // so get in there an terminate the string at the wrapper or seperator + if ( strcmp(tform->type,"char") == 0 && mform && mform->count > 1 ) + { + if ( wdata->wrapper ) + { + c = strstr((char*)data,wdata->wrapper); + if ( c != NULL ) + c[0] = '\0'; + } + else + { + c = strstr((char*)data,wdata->seperator); + if ( c != NULL ) + c[0] = '\0'; + } + } + + + // skip wrapper + if ( wdata->wrapper ) + { + wdata->cur_str_pos = strstr( wdata->cur_str_pos, wdata->wrapper ); + if ( wdata->cur_str_pos == NULL ) + return -1; + wdata->cur_str_pos += strlen( wdata->wrapper ); + } + + // skip seperator + wdata->cur_str_pos = strstr( wdata->cur_str_pos, wdata->seperator ); + if ( wdata->cur_str_pos == NULL ) + return -1; + wdata->cur_str_pos += strlen( wdata->seperator ); + + return 1; + +} + + + +int RTDataTypeTokenize( RTDataTypeForm **Forms, RTDataTypeForm *tform, void *data, char *dest, int dest_len, char *seperator, char *wrapper ) +{ + struct RTDT_Tokenize_WalkData wdata; + + if ( Forms == NULL || tform == NULL || data == NULL || dest == NULL || dest_len <= 0 || seperator == NULL ) + return -1; + + memset(&wdata,0,sizeof(wdata)); + + + wdata.str = dest; + wdata.str_len = dest_len; + wdata.str_remaining = dest_len; + wdata.cur_str_pos = dest; + + wdata.wrapper = wrapper; + wdata.seperator = seperator; + + // blank string before we start + memset(dest,0,dest_len); + + + return RTDataTypeWalk( Forms, tform, NULL, 0, data, RTDataTypeWalkFuncTokenize, &wdata ); +} + +int RTDataTypeDeTokenize( RTDataTypeForm **Forms, RTDataTypeForm *tform, void *data, char *src, char *seperator, char *wrapper ) +{ + struct RTDT_Tokenize_WalkData wdata; + + if ( Forms == NULL || tform == NULL || data == NULL || src == NULL || seperator == NULL ) + return -1; + + memset(&wdata,0,sizeof(wdata)); + + + wdata.str = src; + wdata.str_len = strlen(src); + wdata.str_remaining = wdata.str_len; + wdata.cur_str_pos = src; + + wdata.wrapper = wrapper; + wdata.seperator = seperator; + + // blank data before we start + memset(data,0,tform->size); + + + return RTDataTypeWalk( Forms, tform, NULL, 0, data, RTDataTypeWalkFuncDeTokenize, &wdata ); +} + + +int RTDataTypeParser_Tokenize( RTDataTypeParser *prtdtp, char *type, void *data, char *dest, int dest_len, char *seperator, char *wrapper ) +{ + int ec; + RTDataTypeForm *tform = NULL; + + if ( prtdtp == NULL || type == NULL || data == NULL || dest == NULL || dest_len <= 0 || seperator == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + + tform = RTDataFindForm( prtdtp->Forms, type ); + if ( tform == NULL ) + return RTDT_RESULT_UNKNOWN_DATATYPE; + + ec = RTDataTypeTokenize( prtdtp->Forms, tform, data, dest, dest_len, seperator, wrapper ); + if ( ec < 0 ) + return RTDT_RESULT_PARSE_FAILED; + + return RTDT_RESULT_SUCCESS; + + +} + + + +int RTDataTypeParser_DeTokenize( RTDataTypeParser *prtdtp, char *type, void *data, char *src, char *seperator, char *wrapper ) +{ + int ec; + RTDataTypeForm *tform = NULL; + + if ( prtdtp == NULL || type == NULL || data == NULL || src == NULL || seperator == NULL ) + return RTDT_RESULT_INVALID_PARAMS; + + + tform = RTDataFindForm( prtdtp->Forms, type ); + if ( tform == NULL ) + return RTDT_RESULT_UNKNOWN_DATATYPE; + + ec = RTDataTypeDeTokenize( prtdtp->Forms, tform, data, src, seperator, wrapper ); + if ( ec < 0 ) + return RTDT_RESULT_PARSE_FAILED; + + return RTDT_RESULT_SUCCESS; + + +} + diff --git a/libraries/pmrt/pmrt_utils/rtdatatypes.h b/libraries/pmrt/pmrt_utils/rtdatatypes.h new file mode 100755 index 0000000..5eadd41 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/rtdatatypes.h @@ -0,0 +1,110 @@ +// rtdatatypes.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for parsing datatypes at runtime + +#ifndef RTDATATYPES_H +#define RTDATATYPES_H + +#include + +#define RTDT_MAX_FORM_NAME_LEN 32 + + +enum +{ + RTDT_RESULT_SUCCESS, + RTDT_RESULT_INVALID_PARAMS, + RTDT_RESULT_MALLOC_FAILED, + RTDT_RESULT_PARSE_FAILED, + RTDT_RESULT_DATATYPE_CREATION_FAILED, + RTDT_RESULT_UNKNOWN_DATATYPE, + RTDT_RESULT_MEMBER_NOT_FOUND, + RTDT_RESULT_LOAD_FAILED, + +}; + +// RTDataSmallString +// example of a type defined at compile time +// see top of rtdatatypes.c for rest of example +typedef struct RTDataSmallString +{ + char string[RTDT_MAX_FORM_NAME_LEN]; +} RTDataSmallString; + +typedef struct RTDataTwoSmallStrings +{ + RTDataSmallString strings[2]; +} RTDataTwoSmallStrings; + +typedef struct RTDataLongString +{ + char string[4*RTDT_MAX_FORM_NAME_LEN]; +} RTDataLongString; + + + +typedef struct RTDataTypeMemberForm +{ + char type[RTDT_MAX_FORM_NAME_LEN]; + unsigned int type_hash; + + char name[RTDT_MAX_FORM_NAME_LEN]; + unsigned int name_hash; + + int count; + size_t byte_aligned_size; // useful for walking form (may differ from size of the type) + +} RTDataTypeMemberForm; + + +typedef struct RTDataTypeForm +{ + char type[RTDT_MAX_FORM_NAME_LEN]; + unsigned int type_hash; + + size_t size; + + int member_count; + + RTDataTypeMemberForm *members; + +} RTDataTypeForm; + + +typedef struct RTDataTypeParser +{ + RTDataTypeForm **Forms; + int form_count; + int max_form_count; + int byte_alignment; + +} RTDataTypeParser; + + + + + +int RTDataTypeParser_Init( RTDataTypeParser *prtdtp, int byte_alignment ); + +int RTDataTypeParser_AddNewDataType( RTDataTypeParser *prtdtp, RTDataTypeForm *Form ); + +int RTDataTypeParser_AddNewDataTypeFromCStruct( RTDataTypeParser *prtdtp, char *c_def ); +int RTDataTypeParser_AddNewDataTypesFromCDefFile( RTDataTypeParser *prtdtp, char *filename ); + +RTDataTypeForm *RTDataTypeParser_GetType( RTDataTypeParser *prtdtp, char *type ); + +int RTDataTypeParser_SizeOf( RTDataTypeParser *prtdtp, char *type ); + + +void *RTDataTypeParser_GetMember( RTDataTypeParser *prtdtp, char *type, char *member, void *data, RTDataTypeForm **type_form, RTDataTypeMemberForm **member_form ); +int RTDataTypeParser_SetMember( RTDataTypeParser *prtdtp, char *type, char *member, void *data, void *value ); +int RTDataTypeParser_SetByString( RTDataTypeParser *prtdtp, char *type, char *member, void *data, char *value ); +int RTDataTypeParser_GetByString( RTDataTypeParser *prtdtp, char *type, char *member, void *data, char *value, int value_len ); + +int RTDataTypeParser_Tokenize( RTDataTypeParser *prtdtp, char *type, void *data, char *dest, int dest_len, char *seperator, char *wrapper ); +int RTDataTypeParser_DeTokenize( RTDataTypeParser *prtdtp, char *type, void *data, char *src, char *seperator, char *wrapper ); + + +#endif diff --git a/libraries/pmrt/pmrt_utils/rtdatatypes.o b/libraries/pmrt/pmrt_utils/rtdatatypes.o new file mode 100644 index 0000000..3ec653d Binary files /dev/null and b/libraries/pmrt/pmrt_utils/rtdatatypes.o differ diff --git a/libraries/pmrt/pmrt_utils/textfile.c b/libraries/pmrt/pmrt_utils/textfile.c new file mode 100755 index 0000000..7484f63 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/textfile.c @@ -0,0 +1,289 @@ +// textfile.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for dealing with plain text files +#include "textfile.h" + +#include +#include +#include + + +/*! + \brief Read a line from a file + \author SM + \param filename name and path of the file top read from + \param dst destination buffer into which the data is copied + \param dst_len length of the buffer + \param line_number copies line number line_number in filename into dst. line numbers start counting from 1 + \param skip_whitespace if 1, then any leading whitespace is skipped before copying to dst (whitespace == space or tab) + \return int 0 on sucess, a negative value otherwise +*/ +int ReadLineFromTextFile(const char *filename, char *dst, int dst_len, int line_number, int skip_whitespace ) +{ + FILE *fd; + int curr_line_num; + size_t i; + char buf[256]; + char *start; + int found = 0; + + if ( filename == NULL || dst == NULL || dst_len < 1 ) + { + // invalid params + return -1; + } + + fd = fopen( filename, "r" ); + if ( fd == NULL ) + return -2; + + curr_line_num = 0; + while( fgets(buf, sizeof(buf), fd ) != NULL ) + { + curr_line_num++; + if ( curr_line_num == line_number ) + { + found = 1; + break; + } + } + fclose(fd); + + + if ( found == 1 ) + { + i = 0; + if ( skip_whitespace == 1 ) + { + while ( i < strlen(buf) && (buf[i] == ' ' || buf[i] == '\t' ) ) + { + i++; + } + } + start = &buf[i]; + found = 1; + strncpy( dst, start, dst_len ); + dst[dst_len-1] = '\0'; // always null terminate result to be safe + } + + if ( found == 0 ) + return -3; + + return 0; +} + + +/*! + \brief usefule for reading files for format "Name: value" + \author SM + \param filename name of the file + \param dst destination buffer + \param dst_len length of the dst buffer + \param start_string where to start copying from + \param skip_start_string if 1, then copying starts after 'start_string' + \param skip_whitespace if 1, then any leading whitespace is skipped before copying to dst. whitespace == space or tab + \return int 0 on success, a negative value otherwise +*/ +int FindLineInTextFileByStartString(const char *filename, char *dst, int dst_len, const char *start_string, + int skip_start_string, int skip_whitespace ) +{ + FILE *fd; + int len; + size_t i; + char buf[256]; + char *start; + int found = 0; + + + if ( filename == NULL || dst == NULL || dst_len < 1 || start_string == NULL ) + { + // invalid params + return -1; + } + + fd = fopen( filename, "r" ); + if ( fd == NULL ) + return -2; + + len = strlen(start_string); + + while( fgets(buf, sizeof(buf), fd ) != NULL ) + { + if ( strncmp( buf, start_string, len ) == 0 ) + { + i = 0; + if ( skip_start_string == 1 ) + { + i = strlen(start_string); + } + if ( skip_start_string == 1 ) + { + while ( i < strlen(buf) && (buf[i] == ' ' || buf[i] == '\t' ) ) + { + i++; + } + } + start = &buf[i]; + found = 1; + strncpy( dst, start, dst_len ); + dst[dst_len-1] = '\0'; // always null terminate result to be safe + break; + } + } + + fclose(fd); + + if ( found == 0 ) + return -3; + + return 0; + +} + + + + + + + +/*! + \brief Get the number of lines in a file. Can either pass in a handle to an open file handle, or the name + of the file to open. One one is needed, so set the other to NULL + \author RA + \date 2007/11/13 + \param inFile handle to an open file + \param fileName name of the file to open + \return int number of lines read in +*/ +int FileGetNumLines(FILE *inFile, const char *fileName) +{ + char buffer[256]= {0} ; + int lineCount = 0; + FILE *file = NULL; + + if( (!inFile || feof(inFile)) && !fileName) + return 0; + + if(fileName) + file = fopen(fileName, "r"); + else + file = inFile; + + if(file) + { + int inChar = 0; + long origPos = ftell(file); + + //start from the start + rewind(file); + + do + { + inChar = fgetc(file); + if(inChar == '\n') + ++lineCount; + + } while(inChar != EOF); + + //go back to the original position + fseek(file, origPos, SEEK_SET); + } + + if(file && fileName) + fclose(file); + + return lineCount; +} + +/*! + \brief Gets the starting positions of lines in a file. User can then use fseek(file, position, SEEK_SET) to + reach the starting points of the lines. If a file is passed in, its position will be unchanged + after the function returns. If a fileName is passed in, a file handle will be opened and closed. + \author RA + \date 2007/11/13 + \param inFile open file handle. Set to NULL if the name of the file is passed in + \param fileName name of the file to open. Set to NULL if a valid file handle is passed in + \param outBuffer buffer containing line positions + \param bufSize number of elements outBuffer can cold + \param lineSkipAmount number of lines to skip + \return int 0 on sucess, -1 on fail +*/ +int FileGetLinePositions(FILE *inFile, const char *fileName, int *outBuffer, int bufSize, int lineSkipAmount) +{ + char buffer[256]= {0}; + FILE *file = NULL; + + if( (!inFile || feof(inFile)) && !fileName || !outBuffer || bufSize == 0) + return -1; + + //open the file if need, else just use the one passed in by the user + if(fileName) + file = fopen(fileName, "r"); + else + file = inFile; + + if(file) + { + int inChar = 0; + int foundLine=0; + int currLine = 0; + long origPos = ftell(file); + + if(!lineSkipAmount) + outBuffer[currLine++] = ftell(file); + + do + { + inChar = fgetc(file); + if(inChar == '\n') + { + foundLine = 1; + } + else if(foundLine) + { + lineSkipAmount = lineSkipAmount ? lineSkipAmount - 1 : 0; + + if(!lineSkipAmount) + outBuffer[currLine++] = ftell(file) - 1; + + foundLine = 0; + } + + } while(inChar != EOF && currLine < bufSize); + + fseek(file, origPos, SEEK_SET); + } + + if(file && fileName) + fclose(file); + + return 0; +} + + +// Writes passed string to file (if append set, then will append to end of file) +int WriteStringToFile(char *filename,char *string, int append) +{ + + FILE *dest; + if ( append ) + dest = fopen( filename, "a" ); + else + dest = fopen( filename, "w" ); + + if ( dest == NULL ) + { + return -1; + } + + fputs( string, dest ); + // fputs( "\n", dest ); // append a new line + fclose( dest ); + + return 1; +} + +//EOF + diff --git a/libraries/pmrt/pmrt_utils/textfile.h b/libraries/pmrt/pmrt_utils/textfile.h new file mode 100755 index 0000000..af71f53 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/textfile.h @@ -0,0 +1,72 @@ +// textfile.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for dealing with plain text files + +#ifndef TEXTFILE_H +#define TEXTFILE_H +#include + +// ReadLineFromTextFile() +// copies line number line_number in filename into dst +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// usefule for reading a specfic line from a file +// line numbers start counting from 1 +int ReadLineFromTextFile(const char *filename, char *dst, int dst_len, int line_number, int skip_whitespace ); + + +// ReadLinesFromTextFile() +// copies lines from start_line to end_line (inclusive) from filename into dst +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// line numbers start counting from 1 +// returns number of lines copied (maybe less than end_line - start_line, if reach +// int ReadLinesFromTextFile( char *filename, char *dst, int dst_len, int start_line, int end_line, int skip_whitespace ); + + +// FindLineInTextFileByStartString() +// copies first line in filename that starts with the string 'start_string' int dst +// if skip_start_string == 1, then copying starts after 'start_string' +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// usefule for reading files for format "Name: value" +int FindLineInTextFileByStartString(const char *filename, char *dst, int dst_len, const char *start_string, int skip_start_string, int skip_whitespace ); + + + + +/*! + \brief Get the number of lines in a file. Can either pass in a handle to an open file handle, or the name + of the file to open. One one is needed, so set the other to NULL + \param inFile handle to an open file + \param fileName name of the file to open + \return int number of lines read in +*/ +int FileGetNumLines(FILE *inFile, const char *fileName); + + +/*! + \brief Gets the starting positions of lines in a file. User can then use fseek(file, position, SEEK_SET) to + reach the starting points of the lines. If a file is passed in, its position will be unchanged + after the function returns. If a fileName is passed in, a file handle will be opened and closed. + \param inFile open file handle. Set to NULL if the name of the file is passed in + \param fileName name of the file to open. Set to NULL if a valid file handle is passed in + \param outBuffer buffer containing line positions + \param bufSize number of elements outBuffer can cold + \param lineSkipAmount number of lines to skip + \return int 0 on sucess, -1 on fail +*/ +int FileGetLinePositions(FILE *inFile, const char *fileName, int *outBuffer, int bufSize, int lineSkipAmount); + + + +// Writes passed string to file (if append set, then will append to end of file) +int WriteStringToFile(char *filename,char *string, int append); + + +#endif + +//EOF + diff --git a/libraries/pmrt/pmrt_utils/textfile.o b/libraries/pmrt/pmrt_utils/textfile.o new file mode 100644 index 0000000..40f6dc0 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/textfile.o differ diff --git a/libraries/pmrt/pmrt_utils/textfiles.c b/libraries/pmrt/pmrt_utils/textfiles.c new file mode 100755 index 0000000..9bc65f1 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/textfiles.c @@ -0,0 +1,184 @@ +// textfile.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for dealing with plain text files +#include "textfile.h" + +#include +#include +#include + +// ReadLineFromTextFile() +// copies line number line_number in filename into dst +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// usefule for reading a specfic line from a file +// line numbers start counting from 1 +int ReadLineFromTextFile( char *filename, char *dst, int dst_len, int line_number, int skip_whitespace ) +{ + FILE *fd; + int curr_line_num; + size_t i; + char buf[256]; + char *start; + int found = 0; + + if ( filename == NULL || dst == NULL || dst_len < 1 ) + { + // invalid params + return -1; + } + + fd = fopen( filename, "r" ); + if ( fd == NULL ) + return -2; + + curr_line_num = 0; + while( fgets(buf, sizeof(buf), fd ) != NULL ) + { + curr_line_num++; + if ( curr_line_num == line_number ) + { + found = 1; + break; + } + } + + fclose(fd); + + + if ( found == 1 ) + { + i = 0; + if ( skip_whitespace == 1 ) + { + while ( i < strlen(buf) && (buf[i] == ' ' || buf[i] == '\t' ) ) + { + i++; + } + } + start = &buf[i]; + found = 1; + strncpy( dst, start, dst_len ); + dst[dst_len-1] = '\0'; // always null terminate result to be safe + } + + + if ( found == 0 ) + return -3; + + return 0; +} + + +// copies first line in filename that starts with the string 'start_string' int dst +// if skip_start_string == 1, then copying starts after 'start_string' +// if skip_whitespace == 1, then any leading whitespace is skipped before copying to dst +// whitespace == space or tab +// usefule for reading files for format "Name: value" +int FindLineInTextFileByStartString( char *filename, char *dst, int dst_len, char *start_string, int skip_start_string, int skip_whitespace ) +{ + FILE *fd; + int len; + size_t i; + char buf[256]; + char *start; + int found = 0; + + + if ( filename == NULL || dst == NULL || dst_len < 1 || start_string == NULL ) + { + // invalid params + return -1; + } + + fd = fopen( filename, "r" ); + if ( fd == NULL ) + return -2; + + len = strlen(start_string); + + while( fgets(buf, sizeof(buf), fd ) != NULL ) + { + if ( strncmp( buf, start_string, len ) == 0 ) + { + i = 0; + if ( skip_start_string == 1 ) + { + i = strlen(start_string); + } + if ( skip_start_string == 1 ) + { + while ( i < strlen(buf) && (buf[i] == ' ' || buf[i] == '\t' ) ) + { + i++; + } + } + start = &buf[i]; + found = 1; + strncpy( dst, start, dst_len ); + dst[dst_len-1] = '\0'; // always null terminate result to be safe + break; + } + } + + fclose(fd); + + if ( found == 0 ) + return -3; + + return 0; + +} + +unsigned int UtilGetFileSize(FILE *openFile) +{ + unsigned int size = 0; + long start = 0; + + if(!openFile) + return 0; + + start = ftell(openFile); + + fseek(openFile, 0L, SEEK_END); + size = ftell(openFile); + + fseek(openFile, start, SEEK_SET); + + return (unsigned int)size; +} + +int UtilReadFromFile(const char *fileName, const char *fopenFlags, char **buffer, unsigned int *bufferSize) +{ + FILE *inFile = NULL; + unsigned int size = 0; + + if(!bufferSize || !fopenFlags || !fileName || !buffer) + return -1; + + inFile = fopen(fileName, fopenFlags); + if(!inFile) + goto fail; + + size = UtilGetFileSize(inFile); + + *buffer = calloc(1, size * sizeof(char)); + + size = fread(*buffer, 1, sizeof(char)*size, inFile); + + fclose(inFile); + + *bufferSize = size; + + return 0; +fail: + if(inFile) + fclose(inFile); + + return -1; +} + +//EOF + diff --git a/libraries/pmrt/pmrt_utils/thread.h b/libraries/pmrt/pmrt_utils/thread.h new file mode 100755 index 0000000..9697a56 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/thread.h @@ -0,0 +1,56 @@ +// thread.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#ifndef THREAD_H +#define THREAD_H + +// system specific definitions +#ifdef SYS_PC +#include "thread_pc.h" +#endif +#ifdef SYS_BB +#include "thread_bb.h" +#endif + + +typedef void (*ThreadFunc)(int); + +typedef struct +{ + ThreadFunc Func; + int Arg; + +} ThreadStartInfo; + +enum +{ + THREAD_RESULT_SUCCESS, + THREAD_RESULT_INVALID_PARAMS, + THREAD_RESULT_MALLOC_FAILED, + THREAD_RESULT_THREAD_CREATION_FAILED, +}; + +int StartThread( ThreadHandle *handle, ThreadStartInfo *info); +void ThreadSleep( int millisec ); + + +enum { + MUTEX_RESULT_SUCCESS, + MUTEX_RESULT_UNKNOWN_ERROR, + MUTEX_RESULT_MUTEX_ALREADY_EXISTS, + MUTEX_RESULT_NO_SUCH_MUTEX, + MUTEX_RESULT_INVALID_HANDLE, + MUTEX_RESULT_MUTEX_ABANDONED, + MUTEX_RESULT_MUTEX_BUSY, +}; + +int InitMutex( MutexHandle *handle ); +int GetMutex( MutexHandle *handle ); +int FreeMutex( MutexHandle *handle ); +int DestroyMutex( MutexHandle *handle ); + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/thread_bb.c b/libraries/pmrt/pmrt_utils/thread_bb.c new file mode 100755 index 0000000..e0b1bdd --- /dev/null +++ b/libraries/pmrt/pmrt_utils/thread_bb.c @@ -0,0 +1,175 @@ +#ifdef SYS_BB +// thread.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#include "thread.h" + +#include "cguardian.h" +#include "node.h" +#include "memallochist.h" + + +#include +#include +#include +#include +#include +#include + + +// malloc and free wrappers for tracking memory used +// by thread subsystem +void* thread_apphook_malloc(size_t size) +{ + void *ptr; + ptr = malloc(size); + AddToMemAllocHistory(ptr, size ); + return ptr; +} // thread_apphook_malloc() + +void thread_apphook_free(void *m) +{ + prts_debug( "Thread System Free:\n" ); + DelFromMemAllocHistory(m); + free(m); + prts_debug("Successfully free'd mem at %p\n", m ); +} // thread_apphook_free() + +void ThreadSleep( int millisec ) +{ + usleep(millisec * 1000); +} + + + +#include +#include + + + + +// use a wrapper to actually launch desired routine +// b/c unix and windows both expect funcs w/ different formats +// when starting new threads +void* ThreadWrapperFunc( void *info ) +{ + ThreadStartInfo *ThreadInfo = (ThreadStartInfo *) info; + ThreadInfo->Func( ThreadInfo->Arg ); // call user supplied function + thread_apphook_free(info); // free memory used by our threadinfo struct (assume this was malloc'd by StartThread) + return NULL; +} + +int StartThread( ThreadHandle *handle, ThreadStartInfo *info) +{ + + int ec; + pthread_attr_t attr; + ThreadStartInfo *tinfo; + + if ( handle == NULL ) + return -1; + + // make a copy of the info struct the user passed us + // copy is then handed to ThreadWrapperFunc which + // will free it when thread is done + // this is required, otherwise calling app might + // change or delete contents of *info before ThreadWrapperFunc + // gets a chance to use them + // note that there is nothing we can do to protect thread from + // contents of info->*Arg changing, so be careful when passing + // args into a thread + tinfo = thread_apphook_malloc( sizeof(ThreadStartInfo) ); + if ( tinfo == NULL ) + return -2; + + tinfo->Func = info->Func; + tinfo->Arg = info->Arg; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); + + handle->threadp = 0; + + ec = pthread_create( &handle->threadp, &attr, ThreadWrapperFunc, tinfo ); + + pthread_attr_destroy(&attr); + + return ec; + +} + + +int InitMutex( MutexHandle *handle ) +{ + int ec; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + ec = pthread_mutex_init( &handle->lock, NULL ); + + + /* from the man pages: + RETURN VALUE + !pthread_mutex_init! always returns 0. The other mutex + functions return 0 on success and a non-zero error code on + error. + */ + return MUTEX_RESULT_SUCCESS; +} + +int GetMutex( MutexHandle *handle ) +{ + int ec; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + ec = pthread_mutex_trylock( &handle->lock ); + + if ( ec == 0 ) + return MUTEX_RESULT_SUCCESS; + + if ( ec == EBUSY ) + return MUTEX_RESULT_MUTEX_BUSY; + + if ( ec == EINVAL ) + return MUTEX_RESULT_INVALID_HANDLE; + + return MUTEX_RESULT_UNKNOWN_ERROR; + +} + +int FreeMutex( MutexHandle *handle ) +{ + int ec; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + ec = pthread_mutex_unlock( &handle->lock ); + + if ( ec != 0 ) + return MUTEX_RESULT_UNKNOWN_ERROR; + else + return MUTEX_RESULT_SUCCESS; + +} + +int DestroyMutex( MutexHandle *handle ) +{ + int ec; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + ec = pthread_mutex_destroy( &handle->lock ); + + if ( ec != 0 ) + return MUTEX_RESULT_UNKNOWN_ERROR; + else + return MUTEX_RESULT_SUCCESS; +} + + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/thread_bb.h b/libraries/pmrt/pmrt_utils/thread_bb.h new file mode 100755 index 0000000..cbd0c7c --- /dev/null +++ b/libraries/pmrt/pmrt_utils/thread_bb.h @@ -0,0 +1,29 @@ +#ifdef SYS_BB + +#ifndef THREADBB_H +#define THREADBB_H + +// thread.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + + +#include +typedef struct _ThreadHandle +{ + pthread_t threadp; +} ThreadHandle; + +typedef struct +{ + pthread_mutex_t lock; +} MutexHandle; + + + +#endif + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/thread_bb.o b/libraries/pmrt/pmrt_utils/thread_bb.o new file mode 100644 index 0000000..7fd716e Binary files /dev/null and b/libraries/pmrt/pmrt_utils/thread_bb.o differ diff --git a/libraries/pmrt/pmrt_utils/thread_pc.c b/libraries/pmrt/pmrt_utils/thread_pc.c new file mode 100755 index 0000000..a0c54e4 --- /dev/null +++ b/libraries/pmrt/pmrt_utils/thread_pc.c @@ -0,0 +1,231 @@ +#ifdef SYS_PC +// thread.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + +#include "thread.h" + +#include "cguardian.h" +#include "node.h" +#include "memallochist.h" + + +#include +#include +#include +#include +#include + + +// malloc and free wrappers for tracking memory used +// by thread subsystem +void* thread_apphook_malloc(size_t size) +{ + void *ptr; + ptr = malloc(size); + AddToMemAllocHistory(ptr, size ); + return ptr; +} // thread_apphook_malloc() + +void thread_apphook_free(void *m) +{ + //prts_debug( "Thread System Free:\n" ); + DelFromMemAllocHistory(m); + free(m); + //prts_debug("Successfully free'd mem at %p\n", m ); +} // thread_apphook_free() + +void ThreadSleep( int millisec ) +{ + Sleep(millisec); +} + + +// need WIN32_LEAN_AND_MEAN to prevent conflicts with winsock2.h +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include + +// use a wrapper to actually launch desired routine +// b/c unix and windows both expect funcs w/ different formats +// when starting new threads +unsigned _stdcall ThreadWrapperFunc( void *info ) +{ + ThreadStartInfo *ThreadInfo = (ThreadStartInfo *) info; + ThreadInfo->Func( ThreadInfo->Arg ); // call user supplied function + thread_apphook_free(info); // free memory used by our threadinfo struct (assume this was malloc'd by StartThread) + return 0; +} + +int StartThread( ThreadHandle *handle, ThreadStartInfo *info) +{ + ThreadStartInfo *tinfo; + + if ( handle == NULL ) + return THREAD_RESULT_INVALID_PARAMS; + if ( info == NULL ) + return THREAD_RESULT_INVALID_PARAMS; + if ( info->Func == NULL ) + return THREAD_RESULT_INVALID_PARAMS; + + + // make a copy of the info struct the user passed us + // copy is then handed to ThreadWrapperFunc which + // will free it when thread is done + // this is required, otherwise calling app might + // change or delete contents of *info before ThreadWrapperFunc + // gets a chance to use them + // this is also the reason we force Arg to be an int + // instead of allowing a void pointer + // if req'd ThreadStartInfo struct could be extended to + // accomodate passing args of other types + // just be sure to pass in a copy instead of a ptr to the data + + tinfo = thread_apphook_malloc( sizeof(ThreadStartInfo) ); + if ( tinfo == NULL ) + return THREAD_RESULT_MALLOC_FAILED; + + tinfo->Func = info->Func; + tinfo->Arg = info->Arg; + +/* + handle->handle = CreateThread( NULL, 0, + ThreadWrapperFunc, + (void*)tinfo, + 0, + &handle->id ); +*/ + +/* + Use _beginthreadex instead of CreateThread. + Note that this means you must compile with /MT (or /MTd for debug) + From MSDN: http://msdn2.microsoft.com/en-us/library/ms682453.aspx + A thread in an executable that calls the C run-time library (CRT) + should use the _beginthreadex and _endthreadex functions for thread + management rather than CreateThread and ExitThread; + this requires the use of the multi-threaded version of the CRT. + If a thread created using CreateThread calls the CRT, + the CRT may terminate the process in low-memory conditions. +*/ + + + handle->handle = (HANDLE) _beginthreadex( NULL, 0, + ThreadWrapperFunc, + (void*)tinfo, + 0, + &handle->id ); + + + if ( handle->handle == NULL ) + { + // check errno + // EAGAIN if there are too many threads + // EINVAL if the argument is invalid or the stack size is incorrect + // EACCES in the case of insufficient resources (such as memory). + return THREAD_RESULT_THREAD_CREATION_FAILED; + } + + return THREAD_RESULT_SUCCESS; + +} + + +int InitMutex( MutexHandle *handle ) +{ + DWORD Error; + + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + handle->handle = CreateMutex( NULL, FALSE, NULL ); + if ( handle->handle == NULL ) + { + // some err occured + Error = GetLastError(); + if ( Error == ERROR_ALREADY_EXISTS ) + return MUTEX_RESULT_MUTEX_ALREADY_EXISTS; + + // some other error occured, check win32 docs to find it + return MUTEX_RESULT_UNKNOWN_ERROR; + } + + return MUTEX_RESULT_SUCCESS; +} + +int GetMutex( MutexHandle *handle ) +{ + DWORD Error; + DWORD WaitResult; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + if ( handle->handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + // wait 1 millisecond for mutex to be available + // now way in Windows to poll w/o a wait :( + WaitResult = WaitForSingleObject( handle->handle, 1 ); + + if ( WaitResult == WAIT_OBJECT_0 ) + return MUTEX_RESULT_SUCCESS; + + // err'd states + if ( WaitResult == WAIT_TIMEOUT ) + return MUTEX_RESULT_MUTEX_BUSY; + + if ( WaitResult == WAIT_ABANDONED_0 ) + { + // if a mutex gets abandoned, then the + // next guy to ask for it, gets it + // so we return sucess here + // but throw a break + // as most likely, this is an error + // in the code logic (thread died w/o releasing all it's mutexes) + BP(MUTEX_RESULT_MUTEX_ABANDONED) + return MUTEX_RESULT_SUCCESS; + } + // some other error occured, check win32 docs to find it + Error = GetLastError(); + return MUTEX_RESULT_UNKNOWN_ERROR; + +} +int FreeMutex( MutexHandle *handle ) +{ + BOOL ec; + DWORD Error; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + if ( handle->handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + ec = ReleaseMutex( handle->handle ); + if ( ec == TRUE ) + return MUTEX_RESULT_SUCCESS; + // some other error occured, check win32 docs to find it + Error = GetLastError(); + return MUTEX_RESULT_UNKNOWN_ERROR; +} +int DestroyMutex( MutexHandle *handle ) +{ + BOOL ec; + DWORD Error; + if ( handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + if ( handle->handle == NULL ) + return MUTEX_RESULT_INVALID_HANDLE; + + ec = CloseHandle(handle->handle); + if ( ec == TRUE ) + return MUTEX_RESULT_SUCCESS; + // some other error occured, check win32 docs to find it + Error = GetLastError(); + return MUTEX_RESULT_UNKNOWN_ERROR; + return 0; +} + + +#endif diff --git a/libraries/pmrt/pmrt_utils/thread_pc.h b/libraries/pmrt/pmrt_utils/thread_pc.h new file mode 100755 index 0000000..b9f403b --- /dev/null +++ b/libraries/pmrt/pmrt_utils/thread_pc.h @@ -0,0 +1,35 @@ +#ifdef SYS_PC + +#ifndef THREADPC_H +#define THREADPC_H + +// thread.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + + + + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +typedef struct _ThreadHandle +{ + HANDLE handle; + DWORD id; +} ThreadHandle; + + +typedef struct +{ + HANDLE handle; +} MutexHandle; + + +#endif + + +#endif + + diff --git a/libraries/pmrt/pmrt_utils/thread_pc.o b/libraries/pmrt/pmrt_utils/thread_pc.o new file mode 100644 index 0000000..1dd29c9 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/thread_pc.o differ diff --git a/libraries/pmrt/pmrt_utils/tsqueue.c b/libraries/pmrt/pmrt_utils/tsqueue.c new file mode 100755 index 0000000..ccbb59f --- /dev/null +++ b/libraries/pmrt/pmrt_utils/tsqueue.c @@ -0,0 +1,170 @@ +// tsqueue.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// Thread Safe Queue Structs/Funcs + +#include "tsqueue.h" +#include "thread.h" + +#include "node.h" + + +#include +#include +#include +#include + + +int ThreadSafeQueueInit( ThreadSafeQueue *Queue, int max_size, void *(*malloc_func)(size_t), void (*free_func)(void *) ) +{ + int ec; + if ( Queue == NULL ) + return TSQ_RESULT_INVALID_QUEUE; + if ( malloc_func == NULL ) + return TSQ_RESULT_INVALID_MALLOC_FUNC; + if ( free_func == NULL ) + return TSQ_RESULT_INVALID_FREE_FUNC; + + + // create mutex + ec = InitMutex( &Queue->Mutex ); + if ( ec != MUTEX_RESULT_SUCCESS ) + { + return TSQ_RESULT_MUTEX_CREATION_FAILED; + } + + // acquire mutex + ec = GetMutex(&Queue->Mutex); + if ( ec == MUTEX_RESULT_MUTEX_BUSY ) + { + return TSQ_RESULT_QUEUE_BUSY; + } + else if ( ec != MUTEX_RESULT_SUCCESS ) + { + return TSQ_RESULT_MUTEX_GET_FAILED; + } + + // make N2 list head out of queue + N2Head(&Queue->Queue); + + // set pointers for free and malloc funcs + Queue->free_func = free_func; + Queue->malloc_func = malloc_func; + + Queue->max_size = max_size; + Queue->size = 0; + + // release mutex + FreeMutex(&Queue->Mutex); + + return TSQ_RESULT_SUCCESS; +} + +int ThreadSafeQueuePush( ThreadSafeQueue *Queue, void *data ) +{ + int ec; + ObjData *NewObj; + + if ( Queue == NULL ) + return TSQ_RESULT_INVALID_QUEUE; + if ( Queue->malloc_func == NULL ) + return TSQ_RESULT_INVALID_MALLOC_FUNC; + + if ( Queue->max_size && Queue->size >= Queue->max_size ) + return TSQ_RESULT_QUEUE_FULL; + + // acquire mutex + ec = GetMutex(&Queue->Mutex); + if ( ec == MUTEX_RESULT_MUTEX_BUSY ) + { + return TSQ_RESULT_QUEUE_BUSY; + } + else if ( ec != MUTEX_RESULT_SUCCESS ) + { + return TSQ_RESULT_MUTEX_GET_FAILED; + } + + NewObj = Queue->malloc_func( sizeof(ObjData) ); + if ( NewObj == NULL ) + { + // release mutex + FreeMutex(&Queue->Mutex); + return TSQ_RESULT_MALLOC_FAILED; + } + + NewObj->lnk.type = OBJSUB_DATA; + NewObj->data = data; + + N2LinkBefore(&Queue->Queue, NewObj ); + + Queue->size++; + // release mutex + FreeMutex(&Queue->Mutex); + + return TSQ_RESULT_SUCCESS; +} + +int ThreadSafeQueuePop( ThreadSafeQueue *Queue, void **ppdata ) +{ + int ec; + ObjData *Obj; + + if ( Queue == NULL ) + return TSQ_RESULT_INVALID_QUEUE; + if ( ppdata == NULL ) + return TSQ_RESULT_INVALID_PARAMS; + if ( Queue->free_func == NULL ) + return TSQ_RESULT_INVALID_FREE_FUNC; + + // acquire mutex + ec = GetMutex(&Queue->Mutex); + if ( ec == MUTEX_RESULT_MUTEX_BUSY ) + { + return TSQ_RESULT_QUEUE_BUSY; + } + else if ( ec != MUTEX_RESULT_SUCCESS ) + { + return TSQ_RESULT_MUTEX_GET_FAILED; + } + + + Obj = (ObjData *)N2PopNext(&Queue->Queue); + if ( Obj == NULL ) + { + *ppdata = NULL; + // release mutex + FreeMutex(&Queue->Mutex); + return TSQ_RESULT_QUEUE_EMPTY; + } + + *ppdata = Obj->data; + + Queue->free_func(Obj); + + Queue->size--; + + // release mutex + FreeMutex(&Queue->Mutex); + + return TSQ_RESULT_SUCCESS; +} + +int ThreadSafeQueueDeInit( ThreadSafeQueue *Queue ) +{ + if ( Queue == NULL ) + return TSQ_RESULT_INVALID_QUEUE; + + DestroyMutex(&Queue->Mutex); + return TSQ_RESULT_SUCCESS; +} + + +int ThreadSafeQueueGetCurrSize( ThreadSafeQueue *Queue ) +{ + if ( Queue == NULL ) + return TSQ_RESULT_INVALID_QUEUE; + // this is a pure read, no need to lock + return Queue->size; +} + diff --git a/libraries/pmrt/pmrt_utils/tsqueue.h b/libraries/pmrt/pmrt_utils/tsqueue.h new file mode 100755 index 0000000..a61011a --- /dev/null +++ b/libraries/pmrt/pmrt_utils/tsqueue.h @@ -0,0 +1,50 @@ +#ifndef TSQUEUE_H +#define TSQUEUE_H + +// tsqueue.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved + +// Thread Safe Queue Structs/Funcs +#include "thread.h" + +#ifndef PM_H // pm.h from game engine also defines all the N2 stuff, so skip node if we already have that +#include "node.h" +#endif + +typedef struct +{ + N2 Queue; + MutexHandle Mutex; + void *(*malloc_func)(size_t); + void (*free_func)(void *); + int size; + int max_size; // use 0 for infite size queue + +} ThreadSafeQueue; + + +enum +{ + TSQ_RESULT_SUCCESS, + TSQ_RESULT_INVALID_QUEUE, + TSQ_RESULT_INVALID_MALLOC_FUNC, + TSQ_RESULT_INVALID_FREE_FUNC, + TSQ_RESULT_INVALID_PARAMS, + TSQ_RESULT_MUTEX_CREATION_FAILED, + TSQ_RESULT_MUTEX_GET_FAILED, + TSQ_RESULT_QUEUE_BUSY, + TSQ_RESULT_QUEUE_EMPTY, + TSQ_RESULT_QUEUE_FULL, + TSQ_RESULT_MALLOC_FAILED, +}; + +int ThreadSafeQueueInit( ThreadSafeQueue *Queue, int max_size, void *(*malloc_func)(size_t), void (*free_func)(void *) ); +int ThreadSafeQueuePush( ThreadSafeQueue *Queue, void *data ); +int ThreadSafeQueuePop( ThreadSafeQueue *Queue, void **ppdata ); +int ThreadSafeQueueDeInit( ThreadSafeQueue *Queue ); +int ThreadSafeQueueGetCurrSize( ThreadSafeQueue *Queue ); + + +#endif + diff --git a/libraries/pmrt/pmrt_utils/tsqueue.o b/libraries/pmrt/pmrt_utils/tsqueue.o new file mode 100644 index 0000000..8e8d606 Binary files /dev/null and b/libraries/pmrt/pmrt_utils/tsqueue.o differ diff --git a/libraries/pmrt/pmrt_utils/vssver.scc b/libraries/pmrt/pmrt_utils/vssver.scc new file mode 100755 index 0000000..80f5a2d Binary files /dev/null and b/libraries/pmrt/pmrt_utils/vssver.scc differ diff --git a/libraries/pmrt/psm_engine/Debug/psm_engine.lib b/libraries/pmrt/psm_engine/Debug/psm_engine.lib new file mode 100755 index 0000000..a694191 Binary files /dev/null and b/libraries/pmrt/psm_engine/Debug/psm_engine.lib differ diff --git a/libraries/pmrt/psm_engine/Debug/psm_engine.obj b/libraries/pmrt/psm_engine/Debug/psm_engine.obj new file mode 100755 index 0000000..e257d4b Binary files /dev/null and b/libraries/pmrt/psm_engine/Debug/psm_engine.obj differ diff --git a/libraries/pmrt/psm_engine/Debug/vc60.idb b/libraries/pmrt/psm_engine/Debug/vc60.idb new file mode 100755 index 0000000..2c37f3c Binary files /dev/null and b/libraries/pmrt/psm_engine/Debug/vc60.idb differ diff --git a/libraries/pmrt/psm_engine/Debug/vc60.pdb b/libraries/pmrt/psm_engine/Debug/vc60.pdb new file mode 100755 index 0000000..a26e124 Binary files /dev/null and b/libraries/pmrt/psm_engine/Debug/vc60.pdb differ diff --git a/libraries/pmrt/psm_engine/libpsm_engine.a b/libraries/pmrt/psm_engine/libpsm_engine.a new file mode 100644 index 0000000..c29fb14 Binary files /dev/null and b/libraries/pmrt/psm_engine/libpsm_engine.a differ diff --git a/libraries/pmrt/psm_engine/makedeplib b/libraries/pmrt/psm_engine/makedeplib new file mode 100644 index 0000000..ac86ccb --- /dev/null +++ b/libraries/pmrt/psm_engine/makedeplib @@ -0,0 +1,54 @@ +psm_engine.o: psm_engine.c psm_engine.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/inttypes.h /usr/include/fcntl.h \ + /usr/include/bits/fcntl.h /g3/include/pmrt_utils/netclient.h \ + /g3/include/pmrt_utils/microtime.h /g3/include/pmrt_utils/thread.h \ + /g3/include/pmrt_utils/thread_bb.h /usr/include/pthread.h \ + /usr/include/sched.h /usr/include/signal.h /usr/include/bits/initspin.h \ + /usr/include/bits/sigthread.h /g3/include/pmrt_utils/tsqueue.h \ + /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h diff --git a/libraries/pmrt/psm_engine/makefile b/libraries/pmrt/psm_engine/makefile new file mode 100755 index 0000000..5e2aef8 --- /dev/null +++ b/libraries/pmrt/psm_engine/makefile @@ -0,0 +1,41 @@ +# make driver +# make install (as root) +# +.CLIBFILES = psm_engine.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libpsm_engine.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /g3/lib/libpmrt_utils.a +# add ssl support +CFLAGS += -DUSE_SSL -I /g3/lib/pmrt_ssl +LIBS += /g3/lib/libpmrt_ssl.a /g3/lib/libssl.a /g3/lib/libcrypto.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/psm_engine + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/psm_engine + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/psm_engine/mssccprj.scc b/libraries/pmrt/psm_engine/mssccprj.scc new file mode 100755 index 0000000..619b91f --- /dev/null +++ b/libraries/pmrt/psm_engine/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[psm_engine.dsp] +SCC_Aux_Path = "\\vss-nas-1\PM_Utilities\" +SCC_Project_Name = "$/libraries/pmrt/psm_engine", HTDAAAAA diff --git a/libraries/pmrt/psm_engine/psm_engine.c b/libraries/pmrt/psm_engine/psm_engine.c new file mode 100755 index 0000000..006794f --- /dev/null +++ b/libraries/pmrt/psm_engine/psm_engine.c @@ -0,0 +1,1742 @@ +// psm_engine.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for building/using programmable state machines + +#include "psm_engine.h" + + +#include "time.h" + +RTDataTypeParser gPSM_BuiltInRTDTParser; +RTDataTypeParser *gpPSM_RTDTParser = &gPSM_BuiltInRTDTParser; + + +PSM_State gPSM_BuiltInStates[] = +{ +// timing + { PSM_BUILTIN_STATE_MSLEEP, "MSLEEP", "unsigned int", 0, 0, PSM_BuiltInStateFunc_MSleep }, + { PSM_BUILTIN_STATE_SLOOP, "SLOOP", "unsigned int", 0, 0, PSM_BuiltInStateFunc_Sloop }, + +// flow control + { PSM_BUILTIN_STATE_LABEL, "LABEL", "RTDataSmallString", 0, 0, NULL }, + { PSM_BUILTIN_STATE_GOTO, "GOTO", "RTDataSmallString", 0, 0, PSM_BuiltInStateFunc_Goto }, + { PSM_BUILTIN_STATE_GOSUB, "GOSUB", "RTDataSmallString", 0, 0, PSM_BuiltInStateFunc_GoSub }, + { PSM_BUILTIN_STATE_RETURN, "RETURN", "NULL", 0, 0, PSM_BuiltInStateFunc_Return }, + { PSM_BUILTIN_STATE_INTERRUPT, "INTERRUPT", "RTDataSmallString", 0, 0, PSM_BuiltInStateFunc_Interrupt }, + { PSM_BUILTIN_STATE_EXIT, "EXIT", "NULL", 0, 0, PSM_BuiltInStateFunc_Exit }, + +// variables + { PSM_BUILTIN_STATE_SET_PARAM, "SET_PARAM", "RTDataTwoSmallStrings", 0, 0, PSM_BuiltInStateFunc_SetParam }, + + +// Debug + { PSM_BUILTIN_STATE_PRINT, "PRINT", "RTDataSmallString", 0, 0, PSM_BuiltInStateFunc_Print }, + { PSM_BUILTIN_STATE_SINGLECOMMENT, "//", "RTDataLongString", 0, 0, PSM_BuiltInStateFunc_SingleComment }, + { PSM_BUILTIN_STATE_STARTCOMMENT, "/*", "RTDataLongString", 0, 0, PSM_BuiltInStateFunc_StartComment }, + { PSM_BUILTIN_STATE_COMMENTLINE, "", "RTDataLongString", 0, 0, PSM_BuiltInStateFunc_SingleComment }, + { PSM_BUILTIN_STATE_ENDCOMMENT, "*/", "RTDataLongString", 0, 0, PSM_BuiltInStateFunc_EndComment }, + + +// { PSM_BUILTIN_STATE_GOTO_LABEL, "GOTO_LABEL", "RTDataSmallString", 0, 0, PSM_BuiltInStateFunc_GotoLabel }, +// { PSM_BUILTIN_STATE_GOSUB_LABEL, "GOSUB_LABEL", "RTDataSmallString", 0, 0, PSM_BuiltInStateFunc_GoSubLabel }, + + +}; + + + +int PSM_Engine_Init( RTDataTypeParser *prtdtp ) +{ + int ec; + + if ( prtdtp == NULL ) + { + ec = RTDataTypeParser_Init( &gPSM_BuiltInRTDTParser, 4 ); + if ( ec < 0 ) + return PSM_FAILURE; + gpPSM_RTDTParser = &gPSM_BuiltInRTDTParser; + } + else + { + gpPSM_RTDTParser = prtdtp; + } + + return PSM_SUCCESS; + +} + + +int PSM_State_Init( PSM_State *state, int number, char *name, char *params_type, int params_size, int (*StateFunc)(PSM_ExeContext *,void *,void *,uns32 *) ) +{ + if ( state == NULL ) + return PSM_INVALID_HANDLE; + + memset( state, 0, sizeof(PSM_State) ); + + state->number = number; + state->StateFunc = StateFunc; + + strncpy( state->name, name, PSM_MAX_NAME_LEN ); + state->name[PSM_MAX_NAME_LEN-1] = '\0'; // just to be safe + + strncpy( state->params_type, params_type, RTDT_MAX_FORM_NAME_LEN ); + state->params_type[RTDT_MAX_FORM_NAME_LEN-1] = '\0'; // just to be safe + state->params_size = params_size; + + return PSM_SUCCESS; + +} + + + +int PSM_StateMachine_Init( PSM_StateMachine *statemachine, char *name, char *params_type, RTDataTypeParser *prtdtp ) +{ + if ( statemachine == NULL ) + return PSM_INVALID_HANDLE; + + memset( statemachine, 0, sizeof(PSM_StateMachine) ); + + if ( prtdtp != NULL ) + statemachine->prtdtp = prtdtp; + else + statemachine->prtdtp = gpPSM_RTDTParser; + + strncpy( statemachine->name, name, PSM_MAX_NAME_LEN ); + statemachine->name[PSM_MAX_NAME_LEN-1] = '\0'; // just to be safe + + strncpy( statemachine->params_type, params_type, RTDT_MAX_FORM_NAME_LEN ); + statemachine->params_type[RTDT_MAX_FORM_NAME_LEN-1] = '\0'; // just to be safe + statemachine->params_size = RTDataTypeParser_SizeOf( statemachine->prtdtp, statemachine->params_type ); + + ListCreate(&statemachine->states); + + statemachine->prtdtp = gpPSM_RTDTParser; + + return PSM_SUCCESS; +} + + +int PSM_StateMachine_AddStates( PSM_StateMachine *statemachine, PSM_State *states, int count ) +{ + int i; + ListNode *node; + + if ( statemachine == NULL || states == NULL || count <= 0 ) + return PSM_INVALID_PARAMS; + + + + for( i = 0; i < count; i++ ) + { + // put a copy of the state on our states list + node = ListPushBack( &statemachine->states, &states[i], sizeof(PSM_State) ); + if ( node == NULL ) + return PSM_LIST_FAILURE; + + // if not given a size, get sizeof from our RTDataTypeParser + if ( ((PSM_State*) node->data)->params_size == 0 ) + ((PSM_State*) node->data)->params_size = RTDataTypeParser_SizeOf(statemachine->prtdtp, ((PSM_State*)node->data)->params_type ); + } + + return PSM_SUCCESS; +} + +int PSM_StateMachine_AddBuiltInStates( PSM_StateMachine *statemachine ) +{ + return PSM_StateMachine_AddStates( statemachine, gPSM_BuiltInStates, NUM_PSM_BUILTIN_STATES ); +} + +int CompareStateByNumber( ListNode *node, void *data ) +{ + PSM_State *state; + if ( node == NULL || data == NULL || node->data == NULL ) + return 0; + + state = (PSM_State*)node->data; + + if ( state->number == *(int*)data ) + return 1; + + return 0; +} + +int CompareStateByName( ListNode *node, void *data ) +{ + PSM_State *state; + if ( node == NULL || data == NULL || node->data == NULL ) + return 0; + + state = (PSM_State*)node->data; + + if ( strcmp(state->name, (char*)data) == 0 ) + return 1; + + return 0; +} + + +PSM_State *PSM_StateMachine_FindStateByNumber( PSM_StateMachine *statemachine, int number ) +{ + ListNode *node; + if ( statemachine == NULL ) + return NULL; + + node = ListSearch( &statemachine->states, CompareStateByNumber, &number, 0 ); + if ( node == NULL ) + return NULL; + + return (PSM_State*)node->data; +} + +PSM_State *PSM_StateMachine_FindStateByName( PSM_StateMachine *statemachine, char *name ) +{ + ListNode *node; + if ( statemachine == NULL || name == NULL ) + return NULL; + + node = ListSearch( &statemachine->states, CompareStateByName, name, 0 ); + if ( node == NULL ) + return NULL; + + return (PSM_State*)node->data; +} + +int CompareStateParamsSize( ListNode *node, void *data ) +{ + + if ( node == NULL || data == NULL || node->data == NULL ) + return 0; + + if ( *(int*)data < ((PSM_State*)node->data)->params_size ) + *(int*)data = ((PSM_State*)node->data)->params_size; + + return 0; +} + +int PSM_StateMachine_FindLargestParamSize( PSM_StateMachine *statemachine ) +{ + int size = 0; + if ( statemachine == NULL ) + return 0; + + ListWalk( &statemachine->states, CompareStateParamsSize, &size ); + + return size; +} + + +int PSM_StateMachine_DeInit( PSM_StateMachine *statemachine ) +{ + if ( statemachine == NULL ) + return PSM_INVALID_HANDLE; + + statemachine->name[0] = '\0'; + statemachine->params_type[0] = '\0'; + + ListFree( &statemachine->states ); + return PSM_SUCCESS; + +} + + +int PSM_StateMachine_Document( PSM_StateMachine *statemachine, char *filename, int show_types ) +{ + FILE *file; + ListNode *node; + PSM_State *state; + RTDataTypeForm *tform; + RTDataTypeMemberForm *mform; + int i; + char buf[1024]; + + if ( statemachine == NULL || filename == NULL ) + return PSM_INVALID_PARAMS; + + file = fopen( filename, "wb" ); + if ( file == NULL ) + return PSM_FILE_FAILURE; + + sprintf( buf, "STATE MACHINE: %s\r\n\r\nPARAMS:\r\n", statemachine->name ); + + fwrite( buf, 1, strlen(buf), file ); + + + tform = RTDataTypeParser_GetType( statemachine->prtdtp, statemachine->params_type ); + if ( tform != NULL ) + { + sprintf( buf, " Type: %s\r\n", tform->type ); + fwrite( buf, 1, strlen(buf), file ); + + sprintf( buf, " Members: %d\r\n", tform->member_count ); + fwrite( buf, 1, strlen(buf), file ); + + for( i = 0; i < tform->member_count; i++ ) + { + mform = &tform->members[i]; + sprintf( buf, " %-16s %s\r\n", mform->type, mform->name ); + fwrite( buf, 1, strlen(buf), file ); + } + } + + sprintf( buf, "\r\n" ); + fwrite( buf, 1, strlen(buf), file ); + + sprintf( buf, "STATES:\r\n" ); + fwrite( buf, 1, strlen(buf), file ); + + + node = statemachine->states.head; + while(node) + { + state = (PSM_State*)node->data; + node = node->next; + + sprintf( buf, "%-16s", state->name ); + fwrite( buf, 1, strlen(buf), file ); + + tform = RTDataTypeParser_GetType( statemachine->prtdtp, state->params_type ); + if ( ! tform ) + continue; + + if ( tform->member_count == 0 && (strcmp(tform->type,"NULL")!=0) ) + { + sprintf( buf, " %s", tform->type ); + fwrite( buf, 1, strlen(buf), file ); + } + for( i = 0; i < tform->member_count; i++ ) + { + mform = &tform->members[i]; + if ( show_types ) + { + if ( mform->count <= 1 || (strcmp(mform->type,"char")==0) ) + sprintf( buf, " %s %s,", mform->type, mform->name ); + else + sprintf( buf, " %s %s[%d],", mform->type, mform->name, mform->count ); + + fwrite( buf, 1, strlen(buf), file ); + } + else + { + if ( mform->count <= 1 || (strcmp(mform->type,"char")==0) ) + sprintf( buf, " %s,", mform->name ); + else + sprintf( buf, " %s[%d],", mform->name, mform->count ); + + fwrite( buf, 1, strlen(buf), file ); + } + } + + + sprintf( buf, "\r\n\r\n" ); + fwrite( buf, 1, strlen(buf), file ); + } + + + fclose(file); + return PSM_SUCCESS; + +} + + + + + +int PSM_Program_Init( PSM_Program *program, char *name, char *statemachine_name ) +{ + if ( program == NULL || name == NULL ) + return PSM_INVALID_PARAMS; + + memset( program, 0, sizeof(PSM_Program) ); + + strncpy( program->name, name, PSM_MAX_NAME_LEN ); + program->name[PSM_MAX_NAME_LEN-1] = '\0'; // just to be safe + + if ( statemachine_name ) + { + strncpy( program->statemachine_name, statemachine_name, PSM_MAX_NAME_LEN ); + program->name[PSM_MAX_NAME_LEN-1] = '\0'; // just to be safe + } + + ListCreate(&program->instructions); + + program->prtdtp = gpPSM_RTDTParser; + + return PSM_SUCCESS; + +} + +int PSM_Program_AddInstructions( PSM_Program *program, PSM_ProgramInstruction *instructions, int count, int start_pos ) +{ + ListNode *node,*before_node; + int i,size; + + PSM_ProgramInstruction *instruction; + + + if ( program == NULL || instructions == NULL || count <= 0 ) + return PSM_INVALID_PARAMS; + + before_node = ListGetNthNode( &program->instructions, start_pos ); + for ( i = 0; i < count; i++ ) + { + // new instruction plus params + size = sizeof(PSM_ProgramInstruction) + instructions[i].params_size; + + // create an blank node of the right size on back of the list + node = ListPushBack( &program->instructions, NULL, size ); + if ( node == NULL ) + return PSM_LIST_FAILURE; + + // move it before the requested node (if node was found) + if ( before_node != NULL ) + ListInsertBefore( &program->instructions, node, before_node ); + + // copy over the instruction + instruction = (PSM_ProgramInstruction*)node->data; + memcpy(instruction,&instructions[i],sizeof(PSM_ProgramInstruction)); + // params are stored right after the instruction + if ( instruction->params_size > 0 ) + { + instruction->params = &instruction[1]; + // copy params + if ( instruction->params ) + memcpy( instruction->params, instructions[i].params, instruction->params_size ); + + } + else + instruction->params = NULL; // just to be safe + } + + + return PSM_SUCCESS; + +} + +int PSM_Program_DropInstructions( PSM_Program *program, int count, int start_pos ) +{ + ListNode *node; + int i; + + if ( program == NULL || count <= 0 ) + return PSM_INVALID_PARAMS; + + + for ( i = 0; i < count; i++ ) + { + node = ListGetNthNode( &program->instructions, start_pos ); + if ( node == NULL ) + return PSM_INVALID_PARAMS; + + ListPop(&program->instructions,node); + ListFreeNode(node); + + } + + return PSM_SUCCESS; + + +} + + +PSM_ProgramInstruction *PSM_Program_GetInstruction( PSM_Program *program, int pos ) +{ + ListNode *node; + if ( program == NULL || pos < 0 ) + return NULL; + node = ListGetNthNode( &program->instructions, pos ); + if ( node == NULL ) + return NULL; + + return (PSM_ProgramInstruction*)node->data; +} + +int PSM_Program_AddEventActions( PSM_Program *program, PSM_ProgramEventAction *eventactions, int count ) +{ + PSM_ProgramEventAction *eaction; + ListNode *node; + int i,size; + + if ( program == NULL || eventactions == NULL || count <= 0 ) + return PSM_INVALID_PARAMS; + + for ( i = 0; i < count; i++ ) + { + // new event plus params + size = sizeof(PSM_ProgramEventAction) + eventactions[i].instruction.params_size; + + // create an blank node of the right size on back of the list + node = ListPushBack( &program->eventactions, NULL, size ); + if ( node == NULL ) + return PSM_LIST_FAILURE; + + // copy over the data + eaction = (PSM_ProgramEventAction*)node->data; + memcpy(eaction,&eventactions[i],sizeof(PSM_ProgramEventAction)); + // params are stored right after the instruction + if ( eaction->instruction.params_size > 0 ) + { + eaction->instruction.params = &eaction[1]; + // copy params + if ( eventactions[i].instruction.params ) + memcpy( eaction->instruction.params, eventactions[i].instruction.params, eaction->instruction.params_size ); + } + else + eaction->instruction.params = NULL; // just to be safe + + } + + return PSM_SUCCESS; +} + +int CompareEventActionByName( ListNode *node, void *data ) +{ + PSM_ProgramEventAction *eaction; + if ( node == NULL || data == NULL || node->data == NULL ) + return 0; + + eaction = (PSM_ProgramEventAction*)node->data; + + if ( strcmp(eaction->event_name, (char*)data) == 0 ) + return 1; + + return 0; +} + + + +int PSM_Program_DropEventAction( PSM_Program *program, char *event_name ) +{ + ListNode *node; + if ( program == NULL || event_name == NULL ) + return PSM_INVALID_PARAMS; + + node = ListSearch( &program->eventactions, CompareEventActionByName, event_name, 0 ); + if ( node == NULL ) + return PSM_SUCCESS; // already gone! + + ListPop(&program->eventactions,node); + ListFreeNode(node); + + return PSM_SUCCESS; + +} + +PSM_ProgramEventAction *PSM_Program_GetEventAction( PSM_Program *program, char *event_name ) +{ + ListNode *node; + if ( program == NULL || event_name == NULL ) + return NULL; + + node = ListSearch( &program->eventactions, CompareEventActionByName, event_name, 0 ); + if ( node == NULL ) + return NULL; + + return (PSM_ProgramEventAction*)node->data; +} + + + +int PSM_Program_AddStateMachineParams( PSM_Program *program, PSM_ProgramStateMachineParam *statemachineparams, int count ) +{ + ListNode *node; + int i; + + if ( program == NULL || statemachineparams == NULL || count <= 0 ) + return PSM_INVALID_PARAMS; + + for ( i = 0; i < count; i++ ) + { + + // put a copy on the back of the list + node = ListPushBack( &program->statemachineparams, &statemachineparams[i], sizeof(PSM_ProgramStateMachineParam) ); + if ( node == NULL ) + return PSM_LIST_FAILURE; + } + + return PSM_SUCCESS; + +} + +int CompareProgramStateMachineParamsByName( ListNode *node, void *data ) +{ + PSM_ProgramStateMachineParam *params; + if ( node == NULL || data == NULL || node->data == NULL ) + return 0; + + params = (PSM_ProgramStateMachineParam*)node->data; + + if ( strcmp(params->param_name, (char*)data) == 0 ) + return 1; + + return 0; +} + +int PSM_Program_DropStateMachineParam( PSM_Program *program, char *param_name ) +{ + ListNode *node; + if ( program == NULL || param_name == NULL ) + return PSM_INVALID_PARAMS; + + node = ListSearch( &program->statemachineparams, CompareProgramStateMachineParamsByName, param_name, 0 ); + if ( node == NULL ) + return PSM_SUCCESS; // already gone! + + + ListPop(&program->statemachineparams,node); + ListFreeNode(node); + + + return PSM_SUCCESS; // done! + +} + +PSM_ProgramStateMachineParam *PSM_Program_GetStateMachineParam( PSM_Program *program, char *param_name ) +{ + ListNode *node; + if ( program == NULL || param_name == NULL ) + return NULL; + + node = ListSearch( &program->statemachineparams, CompareProgramStateMachineParamsByName, param_name, 0 ); + if ( node == NULL ) + return NULL; + + return (PSM_ProgramStateMachineParam*)node->data; +} + +int PSM_Program_SetStateMachineParam( PSM_Program *program, char *param_name, char *value ) +{ + PSM_ProgramStateMachineParam *param,newparam; + if ( program == NULL || param_name == NULL ) + return PSM_INVALID_PARAMS; + + if( value == NULL ) + return PSM_Program_DropStateMachineParam( program, param_name ); + + param = PSM_Program_GetStateMachineParam( program, param_name ); + if ( param != NULL ) + { + // do a little trick to make sure it is always properly null terminated + memset( param->value, 0, sizeof(param->value) ); + strncpy(param->value, value, sizeof(param->value) - 1 ); + } + else + { + memset(&newparam,0,sizeof(newparam)); + strncpy( newparam.param_name, param_name, sizeof(newparam.param_name) - 1 ); + strncpy( newparam.value, value, sizeof(newparam.value) - 1 ); + return PSM_Program_AddStateMachineParams( program, &newparam, 1 ); + + } + + return PSM_SUCCESS; // done! + +} + +int PSM_Program_ApplyStateMachineParams( PSM_Program *program, char *statemachine_params_type, void *statemachine_params ) +{ + ListNode *node; + PSM_ProgramStateMachineParam *param; + RTDataTypeParser *prtdtp = program->prtdtp; + + if ( program == NULL || statemachine_params_type == NULL || statemachine_params == NULL ) + return PSM_INVALID_PARAMS; + + node = program->statemachineparams.head; + while(node) + { + param = (PSM_ProgramStateMachineParam *)node->data; + if ( param == NULL ) + continue; // bad node? + RTDataTypeParser_SetByString( prtdtp, statemachine_params_type, param->param_name, statemachine_params, param->value ); + node=node->next; + } + + + return PSM_SUCCESS; +} + +int PSM_Program_FindLabel( PSM_Program *program, char *label ) +{ + PSM_ProgramInstruction *instr; + ListNode *node; + int count = 0; + int i; + + if ( program == NULL || label == NULL ) + return -1; + + + node = program->instructions.head; + while(node) + { + if ( node->data != NULL ) + { + instr = (PSM_ProgramInstruction*)node->data; + if ( instr->params ) + { + if ( strcmp(instr->state_name, "LABEL") == 0 ) + { + // no spaces allowed in label names, but sometimes the sneak in there + i = StringFindFirstWhiteSpaceIndex( (char*)instr->params ); + ((char*)instr->params)[i] = '\0'; + if ( strcmp( (char*)instr->params, label ) == 0 ) + return count; + } + } + } + node=node->next; + count++; // instructions count from 0 + } + return -1; + +} + + +int PSM_Program_DeInit( PSM_Program *program ) +{ + if ( program == NULL ) + return PSM_INVALID_HANDLE; + + ListFree(&program->instructions); + ListFree(&program->eventactions); + ListFree(&program->statemachineparams); + + // also drop event actions and drop statemachine params + + return PSM_SUCCESS; + +} + +int PSM_Program_LoadFromPlainTextFile( PSM_Program *program, PSM_StateMachine *statemachine, char *filename ) +{ + int size,eact; + + RTDataTypeForm *tform; + PSM_ProgramInstruction *instruction,instruct; + PSM_ProgramEventAction eaction; + PSM_ProgramStateMachineParam param; + + PSM_State *state; + + char buf[1024]; + char param_buf[1024]; // no instruction param can be bigger than this + + FILE *fp; + int i; + int comment_started = 0; + char *str; + + RTDataTypeParser *prtdtp; + + if( program == NULL || statemachine == NULL ) + return PSM_INVALID_PARAMS; + + prtdtp = program->prtdtp; + + fp = fopen( filename, "rb" ); + if ( fp == NULL ) + return PSM_FILE_FAILURE; + + memset(buf,0,sizeof(buf)); + + while(fgets(buf,sizeof(buf),fp) != NULL ) + { + eact = 0; + instruction = NULL; + str = buf; + // clear newlines/carriage returns + StringChomp(str); + // skip leading whitespace + i = StringFindFirstNonWhiteSpaceIndex( str ); + str = &str[i]; + // if ( str[0] == '/' && str[1] == '/' ) { continue; } // skip c++ style comments + // if ( str[0] == '\0' ) { continue; } // empty lines + if ( str[0] == '#' ) { continue; } // skip sh/perl style comments, note that c style comments are now loaded into the program so that they can be preserved if saving the program back out) + + if ( strncmp( str, PSM_PLAINTEXT_STATEMACHINENAME, strlen(PSM_PLAINTEXT_STATEMACHINENAME) ) == 0 ) + { + // skip past EVENTACTION: + i = StringFindFirstWhiteSpaceIndex( str ); + str = &str[i]; + // skip whitespace + i = StringFindFirstNonWhiteSpaceIndex( str ); + str = &str[i]; + // copy in name + i = StringCopyUntilWhitespace( str, 0, strlen(str), program->statemachine_name, sizeof(program->statemachine_name) ); + str = &str[i]; // advance past statemachine name and following whitespace + + continue; + + } + else if ( strncmp( str, PSM_PLAINTEXT_STATEMACHINEPARAM, strlen(PSM_PLAINTEXT_STATEMACHINEPARAM) ) == 0 ) + { + memset(¶m,0,sizeof(PSM_ProgramStateMachineParam)); + + // skip past EVENTACTION: + i = StringFindFirstWhiteSpaceIndex( str ); + str = &str[i]; + // skip whitespace + i = StringFindFirstNonWhiteSpaceIndex( str ); + str = &str[i]; + // copy in param name + i = StringCopyUntilWhitespace( str, 0, strlen(str), param.param_name, sizeof(param.param_name) ); + str = &str[i]; // advance past state name and following whitespace + // copy in value + i = StringCopyUntilWhitespace( str, 0, strlen(str), param.value, sizeof(param.value) ); + str = &str[i]; // advance past state name and following whitespace + + PSM_Program_AddStateMachineParams( program, ¶m, 1 ); + continue; + } + else if ( strncmp( str, PSM_PLAINTEXT_EVENTACTION, strlen(PSM_PLAINTEXT_EVENTACTION) ) == 0 ) + { + memset(&eaction,0,sizeof(PSM_ProgramEventAction)); + instruction = &eaction.instruction; + + // skip past EVENTACTION: + i = StringFindFirstWhiteSpaceIndex( str ); + str = &str[i]; + // skip whitespace + i = StringFindFirstNonWhiteSpaceIndex( str ); + str = &str[i]; + // copy in event name + i = StringCopyUntilWhitespace( str, 0, strlen(str), eaction.event_name, sizeof(eaction.event_name) ); + str = &str[i]; // advance past state name and following whitespace + + eact = 1; + // fall through to parse instruction for the action + } + else // normal instruction + { + instruction = &instruct; + memset(instruction,0,sizeof(PSM_ProgramInstruction)); + } + + i = StringCopyUntilWhitespace( str, 0, strlen(str), instruction->state_name, sizeof(instruction->state_name) ); + + // some mild bogocity to deal with fact that comment markers are not always followed by a space + if( (instruction->state_name[0] == '/' && instruction->state_name[1] == '/') + || + (instruction->state_name[0] == '/' && instruction->state_name[1] == '*') + || + (instruction->state_name[0] == '*' && instruction->state_name[1] == '/') ) + { + str = &str[2]; // advance past comment markers + instruction->state_name[2] = '\0'; // terminate state name + } + else + str = &str[i]; // advance past state name and trailing white space + + state = PSM_StateMachine_FindStateByName( statemachine, instruction->state_name ); + if ( state == NULL ) + { + // if we are in a comment and we encounter an invalid instruction, + // then we load that line as a comment line + if ( comment_started ) + { + instruction->state_name[0] = '\0'; + state = PSM_StateMachine_FindStateByName( statemachine, instruction->state_name ); + str = buf; // reset string + } + } + if ( state != NULL ) + { + tform = RTDataTypeParser_GetType( prtdtp, state->params_type ); + if ( tform != NULL ) + { + size = tform->size; + memset(param_buf,0,sizeof(param_buf)); + instruction->params = param_buf; + if ( tform->size > sizeof(param_buf) ) + { + // params list too big!! + prts_debug( "Param list too long when loading statemachine program!\n" ); + continue; + } + instruction->params_size = size; + + // read in params + if ( state->number == PSM_BUILTIN_STATE_SINGLECOMMENT + || + state->number == PSM_BUILTIN_STATE_STARTCOMMENT + || + state->number == PSM_BUILTIN_STATE_ENDCOMMENT ) + { + // bogus but for comments we read in the whole line + RTDataTypeParser_DeTokenize( prtdtp, state->params_type, instruction->params, str, "\n", NULL ); + } + else + RTDataTypeParser_DeTokenize( prtdtp, state->params_type, instruction->params, str, ",", NULL ); + + if ( state->number == PSM_BUILTIN_STATE_STARTCOMMENT ) + comment_started = 1; + else if( state->number == PSM_BUILTIN_STATE_ENDCOMMENT ) + comment_started = 0; + } + } + + if ( eact != 0 ) + PSM_Program_AddEventActions( program, &eaction, 1 ); + else + PSM_Program_AddInstructions( program, instruction, 1, -1 ); + + } + + + fclose(fp); + + + + + return PSM_SUCCESS; +} + +int PSM_Program_SaveToPlainTextFile( PSM_Program *program, PSM_StateMachine *statemachine, char *filename ) +{ + + RTDataTypeForm *tform; + PSM_ProgramInstruction *instruction; + PSM_ProgramEventAction *eaction; + PSM_ProgramStateMachineParam *param; + RTDataTypeParser *prtdtp; + + PSM_State *state; + ListNode *node; + char buf[1024]; + FILE *fp; + + if ( program == NULL || statemachine == NULL ) + return PSM_INVALID_PARAMS; + + prtdtp = program->prtdtp; + + fp = fopen( filename, "wb" ); + if ( fp == NULL ) + return PSM_FILE_FAILURE; + + memset(buf,0,sizeof(buf)); + + + // save instructions + node = program->instructions.head; + + while(node) + { + instruction = (PSM_ProgramInstruction*)node->data; + if ( instruction == NULL ) + continue; // bad node?? + + // some bogus stuff for comments + if( (instruction->state_name[0] == '/' && instruction->state_name[1] == '/') + || + (instruction->state_name[0] == '/' && instruction->state_name[1] == '*') + || + (instruction->state_name[0] == '*' && instruction->state_name[1] == '/') + || + (instruction->state_name[0] == '\0') ) + snprintf( buf, sizeof(buf), "%s", instruction->state_name ); + else + snprintf( buf, sizeof(buf), "%-16s ", instruction->state_name ); + + // fwrite( instruction->state_name, strlen( instruction->state_name ), 1, fp ); + // fwrite( " ", 1, 1, fp ); + + fwrite( buf, strlen(buf), 1, fp ); + + if ( instruction->params ) + { + state = PSM_StateMachine_FindStateByName( statemachine, instruction->state_name ); + if ( state != NULL ) + { + tform = RTDataTypeParser_GetType( prtdtp, state->params_type ); + if ( tform != NULL ) + { + RTDataTypeParser_Tokenize( prtdtp, state->params_type, instruction->params, buf, sizeof(buf), ",", NULL ); + if ( strlen(buf) > 0 && buf[strlen(buf)-1] == ',' ) + buf[strlen(buf)-1] = '\0'; // hide trailing comma + + fwrite( buf, strlen(buf), 1, fp ); + } + } + } + + fwrite( "\r\n", 2, 1, fp ); // PC style + node = node->next; + + } + + fwrite( "#\r\n", 3, 1, fp ); // PC style + + // save event actions + node = program->eventactions.head; + while(node) + { + eaction = (PSM_ProgramEventAction*)node->data; + if ( eaction == NULL ) + continue; // bad node?? + + fwrite( PSM_PLAINTEXT_EVENTACTION, 1, strlen(PSM_PLAINTEXT_EVENTACTION), fp ); + + fwrite( " ", 1, 1, fp ); + fwrite( eaction->event_name, 1, strlen(eaction->event_name), fp ); + fwrite( " ", 1, 1, fp ); + instruction = &eaction->instruction; + + fwrite( instruction->state_name, strlen( instruction->state_name ), 1, fp ); + fwrite( " ", 1, 1, fp ); + + if ( instruction->params ) + { + state = PSM_StateMachine_FindStateByName( statemachine, instruction->state_name ); + if ( state != NULL ) + { + tform = RTDataTypeParser_GetType( prtdtp, state->params_type ); + if ( tform != NULL ) + { + RTDataTypeParser_Tokenize( prtdtp, state->params_type, instruction->params, buf, sizeof(buf), ",", NULL ); + if ( strlen(buf) > 0 && buf[strlen(buf)-1] == ',' ) + buf[strlen(buf)-1] = '\0'; // hide trailing comma + + fwrite( buf, strlen(buf), 1, fp ); + } + } + } + + + fwrite( "\r\n", 2, 1, fp ); // PC style + node = node->next; + + } + + // save event params + + fwrite( "#\r\n", 3, 1, fp ); // PC style + + // save statemachine params + node = program->statemachineparams.head; + while(node) + { + param = (PSM_ProgramStateMachineParam*)node->data; + if ( param == NULL ) + continue; // bad node?? + + fwrite( PSM_PLAINTEXT_STATEMACHINEPARAM, 1, strlen(PSM_PLAINTEXT_STATEMACHINEPARAM), fp ); + fwrite( " ", 1, 1, fp ); + fwrite( param->param_name, strlen(param->param_name), 1, fp ); + fwrite( " ", 1, 1, fp ); + fwrite( param->value, strlen(param->value), 1, fp ); + + fwrite( "\r\n", 2, 1, fp ); // PC style + + node = node->next; + + } + + + // at the very end we put our statemachine name + // this is really just a hint as the program could be run on + // any statemachine with the required states + fwrite( "#\r\n", 3, 1, fp ); // PC style + + fwrite( PSM_PLAINTEXT_STATEMACHINENAME, strlen(PSM_PLAINTEXT_STATEMACHINENAME), 1, fp ); + fwrite( " ", 1, 1, fp ); + fwrite( program->statemachine_name, strlen(program->statemachine_name), 1, fp ); + + fwrite( "\r\n", 2, 1, fp ); // PC style + // fwrite( "\r\n", 2, 1, fp ); // PC style + + + fclose(fp); + + + + return PSM_SUCCESS; +} + + +int CompileInstructionNodeForStatemachine( ListNode *node, void *data ) +{ + PSM_State *state; + PSM_StateMachine *statemachine; + PSM_ProgramInstruction *instruction; + if ( node == NULL || data == NULL || node->data == NULL ) + return 0; + + statemachine = (PSM_StateMachine*)data; + instruction = (PSM_ProgramInstruction*)node->data; + + state = PSM_StateMachine_FindStateByName( statemachine, instruction->state_name ); + if ( state != NULL ) + instruction->state_number = state->number; + + return 0; + +} + +int PSM_Program_CompileForStateMachine( PSM_Program *program, PSM_StateMachine *statemachine ) +{ + if ( program == NULL || statemachine == NULL ) + return PSM_INVALID_PARAMS; + + ListWalk( &program->instructions, CompileInstructionNodeForStatemachine, statemachine ); + + return PSM_SUCCESS; +} + + + +int PSM_ExeContext_Init( PSM_ExeContext *context, PSM_StateMachine *statemachine, void *statemachine_params, PSM_Program *program ) +{ + int ec; + int size; + ListNode *node; + + if ( context == NULL || statemachine == NULL ) + return PSM_INVALID_PARAMS; + + size = sizeof(PSM_ExeContext); + memset(context,0,size); + + ListCreate(&context->membufs); + ListCreate(&context->eventactions); + + + PMRT_Timer_Reset(&context->timer); + + + context->statemachine = statemachine; + + context->program = program; + + + context->curr_instruction_number = 0; + + PSM_Program_CompileForStateMachine( program, statemachine ); + + + size = PSM_StateMachine_FindLargestParamSize( statemachine ); + if ( size > 0 ) + { + node = ListPushBack( &context->membufs, NULL, size ); + if ( node == NULL ) + { + ListFree(&context->membufs); + return PSM_LIST_FAILURE; + } + context->state_params_buf = node->data; + + node = ListPushBack( &context->membufs, NULL, size ); + if ( node == NULL ) + { + ListFree(&context->membufs); + return PSM_LIST_FAILURE; + } + context->eaction_state_params_buf = node->data; + + } + + + + if ( program ) + { + ec = ListCopy( &program->eventactions, &context->eventactions ); + if ( ec < 0 ) + { + ListFree(&context->eventactions); + ListFree(&context->membufs); + return PSM_LIST_FAILURE; + } + } + + + // handle state machine params + // if given take + context->statemachine_params = statemachine_params; + if ( (! context->statemachine_params) && statemachine->params_size > 0 ) + { + // else malloc + size = statemachine->params_size; + node = ListPushBack( &context->membufs, NULL, size ); + if ( node == NULL ) + { + ListFree(&context->eventactions); + ListFree(&context->membufs); + return PSM_LIST_FAILURE; + } + context->statemachine_params = node->data; + memset(context->statemachine_params,0,size); + } + + // apply the state machine params + context->prtdtp = gpPSM_RTDTParser; + + if ( context->program && context->statemachine_params ) + { + PSM_Program_ApplyStateMachineParams( program, statemachine->params_type, context->statemachine_params ); + } + + + return PSM_SUCCESS; +} + + +int PSM_ExeContext_SetActiveInstruction( PSM_ExeContext *context, PSM_ProgramInstruction *instruction ) +{ + if ( context == NULL ) + return PSM_INVALID_HANDLE; + + if ( instruction != NULL ) + { + context->state_rec.state = PSM_StateMachine_FindStateByNumber( context->statemachine, instruction->state_number ); + if ( context->state_rec.state == NULL ) + context->state_rec.state = PSM_StateMachine_FindStateByName( context->statemachine, instruction->state_name ); + if ( instruction->params ) + { + memcpy( context->state_params_buf, instruction->params, instruction->params_size ); + context->state_rec.params = context->state_params_buf; + context->state_rec.params_size = instruction->params_size; + } + else + { + context->state_rec.params = NULL; + context->state_rec.params_size = 0; + } + + } + else + { + context->state_rec.state = NULL; + context->state_rec.params = NULL; + context->state_rec.params_size = 0; + + } + + context->state_rec.elapsed_time = 0; + context->state_rec.updates = 0; + + return PSM_SUCCESS; + +} + +int PSM_ExeContext_LoadCurrInstruction( PSM_ExeContext *context ) +{ + PSM_ProgramInstruction *instruction; + + instruction = PSM_Program_GetInstruction( context->program, context->curr_instruction_number ); + + return PSM_ExeContext_SetActiveInstruction(context, instruction ); + +} + + + +int PSM_ExeContext_Update( PSM_ExeContext *context, uns32 *pelapsed_time ) +{ + int ec; + uns32 elapsed_time; + PSM_State *prev_state; + + if ( context == NULL ) + return PSM_INVALID_HANDLE; + + // first call + if ( context->updates == 0 ) + { + PMRT_Timer_Reset(&context->timer); + PMRT_Timer_Start(&context->timer); + context->elapsed_time = 0; + + if ( context->state_rec.state == NULL ) + PSM_ExeContext_LoadCurrInstruction( context ); + } + + // if not given an elapsed time, then go get it from our internal timer + if ( pelapsed_time == NULL ) + { + elapsed_time = PMRT_Timer_GetElapsedMilliseconds( &context->timer) - context->elapsed_time; + pelapsed_time = &elapsed_time; + } + + + // we keep updating until all our time is eaten up + while (1) + { + if ( context->state_rec.state == NULL ) + { + if ( context->curr_instruction_number >= (int)context->program->instructions.numNodes ) + return PSM_PROGRAM_COMPLETED; // reached end of program + else + return PSM_PROGRAM_HALTED; // bad instruction? + } + + // inc global time counter + context->elapsed_time += *pelapsed_time; + + // inc how long we have been in this state + context->state_rec.elapsed_time += *pelapsed_time; + + + prev_state = context->state_rec.state; + if ( context->state_rec.state->StateFunc != NULL ) + ec = context->state_rec.state->StateFunc( context, context->statemachine_params, context->state_rec.params, pelapsed_time ); + else + ec = PSM_RETURN_NEXT_INSTRUCTION; + + + // do accounting + context->updates++; + // quick check to see if StateFunc changed our state (eg. loaded a new instruction) + // in this case assume we do not want state_rec.updates updated for the new state + if ( prev_state == context->state_rec.state ) + context->state_rec.updates++; + + if ( ec < 0 ) // err with instruction + ec = PSM_RETURN_NEXT_INSTRUCTION; // try to keep chooglin' + + // parse results from state func + switch(ec) + { + case PSM_RETURN_WAIT: // wait for next update cycle + *pelapsed_time = 0; // eat all the elapsed time + break; + + case PSM_RETURN_CONTINUE: // spin + break; + + case PSM_RETURN_NEXT_INSTRUCTION: + context->curr_instruction_number++; + PSM_ExeContext_LoadCurrInstruction( context ); + break; + case PSM_RETURN_QUIT: + context->curr_instruction_number = context->program->instructions.numNodes; + context->state_rec.state = NULL; + return PSM_PROGRAM_COMPLETED; + break; + + } + + if ( *pelapsed_time > 0 ) // state did not eat all of the elapsed time + { + + // take remaining time off elapsed counters + // it will be added back at the top of the loop + context->state_rec.elapsed_time -= *pelapsed_time; + context->elapsed_time -= *pelapsed_time; + + // update until all the time is spent + // return PSM_ExeContext_Update( context, pelapsed_time ); + continue; + } + else + break; + } + + return PSM_SUCCESS; + +} + + +int PSM_ExeContext_DeInit( PSM_ExeContext *context ) +{ + if ( context == NULL ) + return PSM_INVALID_PARAMS; + + ListFree(&context->eventactions); + ListFree(&context->membufs); + ListFree(&context->return_stack); + + memset(context,0,sizeof(PSM_ExeContext)); + + return PSM_SUCCESS; +} + +int PSM_ExeContext_AddEventActions( PSM_ExeContext *context, PSM_ProgramEventAction *eventactions, int count ) +{ + PSM_ProgramEventAction *eaction; + ListNode *node; + int i,size; + + if ( context == NULL || eventactions == NULL || count <= 0 ) + return PSM_INVALID_PARAMS; + + for ( i = 0; i < count; i++ ) + { + // new event plus params + size = sizeof(PSM_ProgramEventAction) + eventactions[i].instruction.params_size; + + // create an blank node of the right size on back of the list + node = ListPushBack( &context->eventactions, NULL, size ); + if ( node == NULL ) + return PSM_LIST_FAILURE; + + // copy over the data + eaction = (PSM_ProgramEventAction*)node->data; + memcpy(eaction,&eventactions[i],sizeof(PSM_ProgramEventAction)); + // params are stored right after the instruction + if ( eaction->instruction.params_size > 0 ) + { + eaction->instruction.params = &eaction[1]; + // copy params + if ( eventactions[i].instruction.params ) + memcpy( eaction->instruction.params, eventactions[i].instruction.params, eaction->instruction.params_size ); + } + else + eaction->instruction.params = NULL; // just to be safe + + } + + return PSM_SUCCESS; + +} + +int PSM_ExeContext_DropEventAction( PSM_ExeContext *context, char *event_name ) +{ + ListNode *node; + if ( context == NULL || event_name == NULL ) + return PSM_INVALID_PARAMS; + + node = ListSearch( &context->eventactions, CompareEventActionByName, event_name, 0 ); + if ( node == NULL ) + return PSM_SUCCESS; // already gone! + + ListPop(&context->eventactions, node); + ListFreeNode(node); + + return PSM_SUCCESS; + +} + + +PSM_ProgramEventAction *PSM_ExeContext_GetEventAction( PSM_ExeContext *context, char *event_name ) +{ + ListNode *node; + if ( context == NULL || event_name == NULL ) + return NULL; + + node = ListSearch( &context->eventactions, CompareEventActionByName, event_name, 0 ); + if ( node == NULL ) + return NULL; + + return (PSM_ProgramEventAction*)node->data; +} + + +int PSM_ExeContext_DoEvent( PSM_ExeContext *context, char *event_name, void *event_data ) +{ + int ec; + void *params; + PSM_State *state; + PSM_ProgramEventAction *eaction; + uns32 elapsed_time = 0; + if ( context == NULL || event_name == NULL ) + return PSM_INVALID_PARAMS; + + eaction = PSM_ExeContext_GetEventAction( context, event_name ); + if ( eaction == NULL ) + return PSM_SUCCESS; // no action for this event + + + + state = PSM_StateMachine_FindStateByName( context->statemachine, eaction->instruction.state_name ); + if ( state == NULL ) + return PSM_INVALID_STATE; + + if ( eaction->instruction.params ) + { + memcpy( context->eaction_state_params_buf, eaction->instruction.params, eaction->instruction.params_size ); + params = context->eaction_state_params_buf; + } + else + params = NULL; + + context->event_data = event_data; + + // execute the requested state one-time + if ( state->StateFunc != NULL ) + ec = state->StateFunc( context, context->statemachine_params, params, &elapsed_time ); + // for now just ignore return code + + + context->event_data = NULL; + + return PSM_SUCCESS; + +} + + + +// timing states + + +int PSM_BuiltInStateFunc_MSleep( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + unsigned int remaining_time; + if ( context == NULL || state_params == NULL ) + return -1; + + if ( (*(unsigned int*)state_params==0) || (context->state_rec.elapsed_time < *(unsigned int*)state_params) ) + return PSM_RETURN_WAIT; + else + { + // calc how many far over our desired sleep time we went + remaining_time = context->state_rec.elapsed_time - *(unsigned int*)state_params; + + if ( elapsed_time ) + *elapsed_time = remaining_time; + return PSM_RETURN_NEXT_INSTRUCTION; + } + + +} + +int PSM_BuiltInStateFunc_Sloop( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + if ( context == NULL || state_params == NULL ) + return -1; + + + if ( (*(unsigned int*)state_params==0) || (context->state_rec.updates < *(unsigned int*)state_params) ) + return PSM_RETURN_WAIT; + else + return PSM_RETURN_NEXT_INSTRUCTION; + +} + + +int PSM_BuiltInStateFunc_Print( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ +// time_t t; +// char *c; + if ( context == NULL || state_params == NULL ) + return -1; + + if ( context->state_rec.params ) + { + /* not thread safe! + t = time(NULL); + c = ctime(&t); + StringChomp(c); + printf( "%s: ", c ); + */ + printf( "%s\n", (char*)state_params ); + } + + return PSM_RETURN_NEXT_INSTRUCTION; + +} + + +int PSM_BuiltInStateFunc_SingleComment( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + // all we do for a comment is skip to the next instruction + return PSM_RETURN_NEXT_INSTRUCTION; +} + + + +int PSM_BuiltInStateFunc_StartComment( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + int ec; + if ( context == NULL ) + return -1; + + // keep skipping instructions until we get to the end comment + while( context->state_rec.state->number != PSM_BUILTIN_STATE_ENDCOMMENT ) + { + context->curr_instruction_number++; + ec = PSM_ExeContext_LoadCurrInstruction( context ); + if ( ec != PSM_SUCCESS || (context->state_rec.state == NULL) ) + return PSM_RETURN_QUIT; // either bad instruction or out of instructions + } + + return PSM_RETURN_NEXT_INSTRUCTION; +} + +int PSM_BuiltInStateFunc_EndComment( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + // if all goes well, end comment '*/' is eaten by start comment so if we ever get here + // there was probly an err, but not much we can do about it so just move on to the next instr + return PSM_RETURN_NEXT_INSTRUCTION; +} + + + +// flow control stuff + +int PSM_BuiltInStateFunc_Goto( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + char c; + int i; + if ( context == NULL || state_params == NULL ) + return -1; + + c = *(char*)state_params; + + if ( c >= '0' && c <= '9' ) // a number + { + i = atoi((char*)state_params); + context->curr_instruction_number = i - 1; // instruction list counts from 0, but goto counts from 1 + } + else // a text label + { + // no spaces allowed in label, but sometimes they sneak in there + i = StringFindFirstWhiteSpaceIndex( (char*)state_params ); + ((char*)state_params)[i] = '\0'; + + + i = PSM_Program_FindLabel( context->program, (char*)state_params ); + if ( i >= 0 ) + context->curr_instruction_number = i; + else + return -1; // label not found + } + + + PSM_ExeContext_LoadCurrInstruction( context ); + + return PSM_RETURN_CONTINUE; + +} + + +int PSM_BuiltInStateFunc_Return( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ) +{ + ListNode *node; + if ( context == NULL ) + return -1; + + + node = ListPopFront( &context->return_stack ); + if ( node != NULL ) + { + context->curr_instruction_number = (int)node->data; + PSM_ExeContext_LoadCurrInstruction( context ); + ListFreeNode(node); + + return PSM_RETURN_CONTINUE; + } + return PSM_RETURN_QUIT; // return w/o anywhere to go! + + +} + + + +int PSM_BuiltInStateFunc_GoSub( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ) +{ + char c; + int i; + if ( context == NULL || state_params == NULL ) + return -1; + + c = *(char*)state_params; + + if ( c >= '0' && c <= '9' ) // a number + { + i = atoi((char*)state_params); + // cheese but we just store the return instruction as the node->data ptr + ListPushFront( &context->return_stack, (void*) (context->curr_instruction_number+1), 0 ); + context->curr_instruction_number = i - 1; // instruction list counts from 0, but goto counts from 1 + } + else // a text label + { + // no spaces allowed in label, but sometimes they sneak in there + i = StringFindFirstWhiteSpaceIndex( (char*)state_params ); + ((char*)state_params)[i] = '\0'; + + + i = PSM_Program_FindLabel( context->program, (char*)state_params ); + if ( i >= 0 ) + { + // cheese but we just store the return instruction as the node->data ptr + ListPushFront( &context->return_stack, (void*) (context->curr_instruction_number+1), 0 ); + context->curr_instruction_number = i; + } + else + return -1; // label not found + } + + + + PSM_ExeContext_LoadCurrInstruction( context ); + + return PSM_RETURN_CONTINUE; + +} + + +// same thing as GoSub, but puts current instruciton on return stack, instead of next instr, meant to be called asynchronously +int PSM_BuiltInStateFunc_Interrupt( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ) +{ + char c; + int i; + if ( context == NULL || state_params == NULL ) + return -1; + + c = *(char*)state_params; + + if ( c >= 0 && c <= '9' ) // a number + { + i = atoi((char*)context->curr_instruction_number); + // cheese but we just store the return instruction as the node->data ptr + ListPushFront( &context->return_stack, (void*) (context->curr_instruction_number), 0 ); + context->curr_instruction_number = i - 1; // instruction list counts from 0, but goto counts from 1 + } + else // a text label + { + // no spaces allowed in label, but sometimes they sneak in there + i = StringFindFirstWhiteSpaceIndex( (char*)state_params ); + ((char*)state_params)[i] = '\0'; + + + i = PSM_Program_FindLabel( context->program, (char*)state_params ); + if ( i >= 0 ) + { + // cheese but we just store the return instruction as the node->data ptr + ListPushFront( &context->return_stack, (void*) (context->curr_instruction_number), 0 ); + context->curr_instruction_number = i; + } + else + return -1; // label not found + } + + + + PSM_ExeContext_LoadCurrInstruction( context ); + + return PSM_RETURN_CONTINUE; + +} + + +int PSM_BuiltInStateFunc_SetParam( PSM_ExeContext *context, void *statemachine_params, void *state_params, uns32 *elapsed_time ) +{ + RTDataTwoSmallStrings *params; + + char *name,*value; + if ( context == NULL || state_params == NULL ) + return -1; + + params = (RTDataTwoSmallStrings *)state_params; + + if ( params ) + { + name = params->strings[0].string; + value = params->strings[1].string; + + // use magic of RTDT Parser to set this value + RTDataTypeParser_SetByString( context->statemachine->prtdtp, context->statemachine->params_type, name, context->statemachine_params, value ); + + } + + return PSM_RETURN_NEXT_INSTRUCTION; + +} + +int PSM_BuiltInStateFunc_Exit( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ) +{ + return PSM_RETURN_QUIT; +} + diff --git a/libraries/pmrt/psm_engine/psm_engine.dsp b/libraries/pmrt/psm_engine/psm_engine.dsp new file mode 100755 index 0000000..6df65ab --- /dev/null +++ b/libraries/pmrt/psm_engine/psm_engine.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="psm_engine" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=psm_engine - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "psm_engine.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "psm_engine.mak" CFG="psm_engine - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "psm_engine - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "psm_engine - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries", SLBAAAAA" +# PROP Scc_LocalPath "..\.." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "psm_engine - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "psm_engine - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FD /I /g3/include" /I /g3/include" /I /g3/include" /I /g3/include" /GZ " " " " /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir \g3\include\psm_engine copy Debug\psm_engine.lib \g3\lib copy *.h \g3\include\psm_engine +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "psm_engine - Win32 Release" +# Name "psm_engine - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\psm_engine.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\psm_engine.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/psm_engine/psm_engine.dsw b/libraries/pmrt/psm_engine/psm_engine.dsw new file mode 100755 index 0000000..5ce060c --- /dev/null +++ b/libraries/pmrt/psm_engine/psm_engine.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "psm_engine"=.\psm_engine.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/psm_engine/psm_engine.h b/libraries/pmrt/psm_engine/psm_engine.h new file mode 100755 index 0000000..9d3cd07 --- /dev/null +++ b/libraries/pmrt/psm_engine/psm_engine.h @@ -0,0 +1,287 @@ +// psm_engine.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// routines for building/using programmable state machines + +#ifndef PSM_ENGINE_H +#define PSM_ENGINE_H + +#include + +#define PSM_MAX_NAME_LEN 32 + +#define PSM_PLAINTEXT_EVENTACTION "EVENTACTION" +#define PSM_PLAINTEXT_STATEMACHINEPARAM "SMPARAM" +#define PSM_PLAINTEXT_STATEMACHINENAME "STATEMACHINE" + + +struct PSM_ExeContext; // forward dec + +typedef struct PSM_State +{ + int number; + char name[PSM_MAX_NAME_LEN]; + char params_type[RTDT_MAX_FORM_NAME_LEN]; + int params_size; + + unsigned int flags; + int (*StateFunc)(struct PSM_ExeContext *, void *, void *, uns32 * ); + +} PSM_State; + + +typedef struct PSM_StateRecord +{ + uns32 elapsed_time; + + unsigned int updates; + + PSM_State *state; + void *params; + int params_size; + +} PSM_StateRecord; + + +typedef struct PSM_ProgramInstruction +{ + char state_name[PSM_MAX_NAME_LEN]; + int state_number; + void *params; + int params_size; +} PSM_ProgramInstruction; + + +typedef struct PSM_ProgramEventAction +{ + char event_name[PSM_MAX_NAME_LEN]; + PSM_ProgramInstruction instruction; + +} PSM_ProgramEventAction; + +typedef struct PSM_ProgramStateMachineParam +{ + char param_name[RTDT_MAX_FORM_NAME_LEN*4]; // give a little extra room to allow for array and sub-member setting + char value[PSM_MAX_NAME_LEN]; +} PSM_ProgramStateMachineParam; + +typedef struct PSM_Program +{ + char name[PSM_MAX_NAME_LEN]; + char statemachine_name[PSM_MAX_NAME_LEN]; + + List instructions; + + List eventactions; + + List statemachineparams; + + + RTDataTypeParser *prtdtp; + +} PSM_Program; + + + + + + +typedef struct PSM_StateMachine +{ + char name[PSM_MAX_NAME_LEN]; + char params_type[RTDT_MAX_FORM_NAME_LEN]; + int params_size; + + List states; + + RTDataTypeParser *prtdtp; + +} PSM_StateMachine; + + + + + +typedef struct PSM_ExeContext +{ + + + PSM_StateMachine *statemachine; + + void *statemachine_params; + + PSM_Program *program; + + int curr_instruction_number; + + + // StateFunc's are allowed to modify the passed in params and these changes are held over + // until the ExeContext advances to the next instruction + // hence we have two buffers that we copy the initial state params from our program into + // before executing each instruction + void *state_params_buf; // buffer into which we put a copy of the state params for each instruction before it's executed + void *eaction_state_params_buf; // same, but used when we are executing an event action + + + unsigned int elapsed_time; + +// unsigned int last_update; +// unsigned int update_elapsed_time; + + unsigned int updates; + + // data for most recent event + void *event_data; + + RTDataTypeParser *prtdtp; + + + + + // b/c the event actions may change + // as the program runs, we need to maintain + // a seperate list for each ExeContext + // list is copied from program on init + List eventactions; + + // put all the mem bufs we malloc for on a list + // makes it easier to clean up + List membufs; + + + // list of instruction numbers to return to + List return_stack; + + // current state data stored in here + PSM_StateRecord state_rec; + + // use this guy for keeping time if no time supplied + PMRT_Timer timer; + + +} PSM_ExeContext; + + +enum +{ + PSM_SUCCESS, + PSM_INVALID_HANDLE, + PSM_INVALID_PARAMS, + PSM_MALLOC_FAILURE, + PSM_LIST_FAILURE, + PSM_FILE_FAILURE, + PSM_FAILURE, + PSM_PROGRAM_HALTED, + PSM_PROGRAM_COMPLETED, + PSM_INVALID_STATE, + +} PSM_ERROR_CODES; + + +enum +{ +// timing + PSM_BUILTIN_STATE_MSLEEP, + PSM_BUILTIN_STATE_SLOOP, + +// flow control + PSM_BUILTIN_STATE_LABEL, + PSM_BUILTIN_STATE_GOTO, + PSM_BUILTIN_STATE_GOSUB, + PSM_BUILTIN_STATE_RETURN, + PSM_BUILTIN_STATE_INTERRUPT, + PSM_BUILTIN_STATE_EXIT, + +// variables + PSM_BUILTIN_STATE_SET_PARAM, + +// debug + PSM_BUILTIN_STATE_PRINT, + PSM_BUILTIN_STATE_SINGLECOMMENT, + PSM_BUILTIN_STATE_STARTCOMMENT, + PSM_BUILTIN_STATE_COMMENTLINE, + PSM_BUILTIN_STATE_ENDCOMMENT, + + NUM_PSM_BUILTIN_STATES, +} PSM_BUILTIN_STATES; + + +enum +{ + PSM_RETURN_WAIT, // wait for next update call + PSM_RETURN_CONTINUE, // continue w/o waiting for next update call + PSM_RETURN_NEXT_INSTRUCTION, // proceed to next instuction w/o waiting for next update call + PSM_RETURN_QUIT, // stop program execution +} PSM_STATE_RETURN_CODES; + + +int PSM_Engine_Init( RTDataTypeParser *prtdtp ); + + +int PSM_State_Init( PSM_State *state, int number, char *name, char *params_type, int params_size, int (*StateFunc)(PSM_ExeContext *,void *,void *, uns32 * ) ); + + +int PSM_StateMachine_Init( PSM_StateMachine *statemachine, char *name, char *params_type, RTDataTypeParser *prtdtp ); +int PSM_StateMachine_AddBuiltInStates( PSM_StateMachine *statemachine ); +int PSM_StateMachine_AddStates( PSM_StateMachine *statemachine, PSM_State *states, int count ); + +PSM_State *PSM_StateMachine_FindStateByName( PSM_StateMachine *statemachine, char *name ); +int PSM_StateMachine_FindLargestParamSize( PSM_StateMachine *statemachine ); + +int PSM_StateMachine_DeInit( PSM_StateMachine *statemachine ); +int PSM_StateMachine_Document( PSM_StateMachine *statemachine, char *filename, int show_types ); + +int PSM_Program_Init( PSM_Program *program, char *name, char *statemachine_name ); +int PSM_Program_AddInstructions( PSM_Program *program, PSM_ProgramInstruction *instructions, int count, int start_pos ); +int PSM_Program_DropInstructions( PSM_Program *program, int count, int start_pos ); +PSM_ProgramInstruction *PSM_Program_GetInstruction( PSM_Program *program, int pos ); +int PSM_Program_FindLabel( PSM_Program *program, char *label ); + + +int PSM_Program_AddEventActions( PSM_Program *program, PSM_ProgramEventAction *eventactions, int count ); +int PSM_Program_DropEventAction( PSM_Program *program, char *event_name ); +PSM_ProgramEventAction *PSM_Program_GetEventAction( PSM_Program *program, char *event_name ); + +int PSM_Program_AddStateMachineParams( PSM_Program *program, PSM_ProgramStateMachineParam *statemachineparams, int count ); +int PSM_Program_DropStateMachineParam( PSM_Program *program, char *param_name ); +int PSM_Program_SetStateMachineParam( PSM_Program *program, char *param_name, char *value ); +PSM_ProgramStateMachineParam *PSM_Program_GetStateMachineParam( PSM_Program *program, char *param_name ); + + +int PSM_Program_DeInit( PSM_Program *program ); + +int PSM_Program_LoadFromPlainTextFile( PSM_Program *program, PSM_StateMachine *statemachine, char *filename ); +int PSM_Program_SaveToPlainTextFile( PSM_Program *program, PSM_StateMachine *statemachine, char *filename ); + +int PSM_Program_CompileForStateMachine( PSM_Program *program, PSM_StateMachine *statemachine ); + + +int PSM_ExeContext_Init( PSM_ExeContext *context, PSM_StateMachine *statemachine, void *statemachine_params, PSM_Program *program ); +int PSM_ExeContext_Update( PSM_ExeContext *context, uns32 *elapsed_time ); +int PSM_ExeContext_DoEvent( PSM_ExeContext *context, char *event_name, void *event_data ); +int PSM_ExeContext_DeInit( PSM_ExeContext *context ); +int PSM_ExeContext_AddEventActions( PSM_ExeContext *context, PSM_ProgramEventAction *eventactions, int count ); +int PSM_ExeContext_DropEventAction( PSM_ExeContext *context, char *event_name ); +PSM_ProgramEventAction *PSM_ExeContext_GetEventAction( PSM_ExeContext *context, char *event_name ); +int PSM_ExeContext_SetActiveInstruction( PSM_ExeContext *context, PSM_ProgramInstruction *instruction ); + + +int PSM_BuiltInStateFunc_MSleep( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Sloop( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time); + +int PSM_BuiltInStateFunc_SingleComment( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_StartComment( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_EndComment( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Print( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); + +int PSM_BuiltInStateFunc_Goto( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_GoSub( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Return( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Interrupt( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_SetParam( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); +int PSM_BuiltInStateFunc_Exit( PSM_ExeContext *context, void *statemachine_params, void *state_params , uns32 *elapsed_time ); + + + +#endif // PSM_ENGINE_H diff --git a/libraries/pmrt/psm_engine/psm_engine.ncb b/libraries/pmrt/psm_engine/psm_engine.ncb new file mode 100755 index 0000000..0ed9c45 Binary files /dev/null and b/libraries/pmrt/psm_engine/psm_engine.ncb differ diff --git a/libraries/pmrt/psm_engine/psm_engine.o b/libraries/pmrt/psm_engine/psm_engine.o new file mode 100644 index 0000000..3a2b278 Binary files /dev/null and b/libraries/pmrt/psm_engine/psm_engine.o differ diff --git a/libraries/pmrt/psm_engine/psm_engine.opt b/libraries/pmrt/psm_engine/psm_engine.opt new file mode 100755 index 0000000..c7b16e0 Binary files /dev/null and b/libraries/pmrt/psm_engine/psm_engine.opt differ diff --git a/libraries/pmrt/psm_engine/psm_engine.plg b/libraries/pmrt/psm_engine/psm_engine.plg new file mode 100755 index 0000000..8b7f682 --- /dev/null +++ b/libraries/pmrt/psm_engine/psm_engine.plg @@ -0,0 +1,168 @@ + + +
+

Build Log

+

+--------------------Configuration: pmrt_utils - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP53.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR"Debug/" /Fp"Debug/pmrt_utils.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\pmrt_utils\audcrc.c" +"C:\g3\libraries\pmrt\pmrt_utils\cguardian.c" +"C:\g3\libraries\pmrt\pmrt_utils\containerCommon.c" +"C:\g3\libraries\pmrt\pmrt_utils\containers.c" +"C:\g3\libraries\pmrt\pmrt_utils\dnslookup.c" +"C:\g3\libraries\pmrt\pmrt_utils\filesys.c" +"C:\g3\libraries\pmrt\pmrt_utils\icmpSock_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\icmpSock_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\interfaceInfo_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\memallochist.c" +"C:\g3\libraries\pmrt\pmrt_utils\microtime.c" +"C:\g3\libraries\pmrt\pmrt_utils\netclient.c" +"C:\g3\libraries\pmrt\pmrt_utils\netsock_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\netsock_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\node.c" +"C:\g3\libraries\pmrt\pmrt_utils\pmrt_strings.c" +"C:\g3\libraries\pmrt\pmrt_utils\rtdatatypes.c" +"C:\g3\libraries\pmrt\pmrt_utils\textfile.c" +"C:\g3\libraries\pmrt\pmrt_utils\thread_bb.c" +"C:\g3\libraries\pmrt\pmrt_utils\thread_pc.c" +"C:\g3\libraries\pmrt\pmrt_utils\tsqueue.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP53.tmp" +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP54.tmp" with contents +[ +/nologo /out:"Debug\pmrt_utils.lib" +.\Debug\audcrc.obj +.\Debug\cguardian.obj +.\Debug\containerCommon.obj +.\Debug\containers.obj +.\Debug\dnslookup.obj +.\Debug\filesys.obj +.\Debug\icmpSock_bb.obj +.\Debug\icmpSock_pc.obj +.\Debug\interfaceInfo.obj +.\Debug\interfaceInfo_bb.obj +.\Debug\interfaceInfo_pc.obj +.\Debug\memallochist.obj +.\Debug\microtime.obj +.\Debug\netclient.obj +.\Debug\netsock_bb.obj +.\Debug\netsock_pc.obj +.\Debug\node.obj +.\Debug\pmrt_strings.obj +.\Debug\rtdatatypes.obj +.\Debug\textfile.obj +.\Debug\thread_bb.obj +.\Debug\thread_pc.obj +.\Debug\tsqueue.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP54.tmp" +

Output Window

+Compiling... +audcrc.c +cguardian.c +containerCommon.c +containers.c +dnslookup.c +filesys.c +icmpSock_bb.c +icmpSock_pc.c +interfaceInfo.c +c:\g3\libraries\pmrt\pmrt_utils\icmpsock_pc.c(53) : warning C4761: integral size mismatch in argument; conversion supplied +interfaceInfo_bb.c +interfaceInfo_pc.c +memallochist.c +microtime.c +c:\g3\libraries\pmrt\pmrt_utils\microtime.c(138) : warning C4244: '=' : conversion from 'unsigned __int64 ' to 'unsigned long ', possible loss of data +c:\g3\libraries\pmrt\pmrt_utils\microtime.c(195) : warning C4244: '=' : conversion from 'unsigned __int64 ' to 'unsigned long ', possible loss of data +netclient.c +netsock_bb.c +netsock_pc.c +node.c +pmrt_strings.c +rtdatatypes.c +textfile.c +thread_bb.c +thread_pc.c +tsqueue.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP55.bat" with contents +[ +@echo off +mkdir \g3\include\pmrt_utils +copy Debug\pmrt_utils.lib \g3\lib +copy *.h \g3\include\pmrt_utils +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP55.bat" + +A subdirectory or file \g3\include\pmrt_utils already exists. + 1 file(s) copied. +audcrc.h +cguardian.h +containerCommon.h +containers.h +dnslookup.h +filesys.h +icmpSock.h +icmpSock_bb.h +icmpSock_pc.h +interfaceInfo.h +interfaceInfo_bb.h +interfaceInfo_pc.h +memallochist.h +microtime.h +netclient.h +netsock.h +netsock_bb.h +netsock_pc.h +node.h +pmrt_strings.h +pmrt_utils.h +rtdatatypes.h +textfile.h +thread.h +thread_bb.h +thread_pc.h +tsqueue.h + 27 file(s) copied. +

+--------------------Configuration: psm_engine - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP56.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /Fo"Debug/" /Fd"Debug/" /FD /I /g3/include" /I /g3/include" /I /g3/include" /I /g3/include" /GZ " " " " /c +"C:\g3\libraries\pmrt\psm_engine\psm_engine.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP56.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\psm_engine.lib" .\Debug\psm_engine.obj \g3\libraries\pmrt\pmrt_utils\Debug\pmrt_utils.lib " +

Output Window

+Compiling... +psm_engine.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP57.bat" with contents +[ +@echo off +mkdir \g3\include\psm_engine +copy Debug\psm_engine.lib \g3\lib +copy *.h \g3\include\psm_engine +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP57.bat" + +A subdirectory or file \g3\include\psm_engine already exists. + 1 file(s) copied. +psm_engine.h + 1 file(s) copied. + + + +

Results

+psm_engine.lib - 0 error(s), 3 warning(s) +
+ + diff --git a/libraries/pmrt/psm_engine/vssver.scc b/libraries/pmrt/psm_engine/vssver.scc new file mode 100755 index 0000000..4461522 Binary files /dev/null and b/libraries/pmrt/psm_engine/vssver.scc differ diff --git a/libraries/pmrt/telemetry/Debug/bitbyte.obj b/libraries/pmrt/telemetry/Debug/bitbyte.obj new file mode 100755 index 0000000..283bfe9 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/bitbyte.obj differ diff --git a/libraries/pmrt/telemetry/Debug/bitbyte.sbr b/libraries/pmrt/telemetry/Debug/bitbyte.sbr new file mode 100755 index 0000000..dbc54f0 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/bitbyte.sbr differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry.lib b/libraries/pmrt/telemetry/Debug/telemetry.lib new file mode 100755 index 0000000..bd324f8 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry.lib differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry.obj b/libraries/pmrt/telemetry/Debug/telemetry.obj new file mode 100755 index 0000000..e7ab77d Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry.obj differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry.pch b/libraries/pmrt/telemetry/Debug/telemetry.pch new file mode 100755 index 0000000..db9bb40 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry.pch differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry.sbr b/libraries/pmrt/telemetry/Debug/telemetry.sbr new file mode 100755 index 0000000..facfc57 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry.sbr differ diff --git a/libraries/pmrt/telemetry/Debug/telemetryXml.obj b/libraries/pmrt/telemetry/Debug/telemetryXml.obj new file mode 100755 index 0000000..4e5b900 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetryXml.obj differ diff --git a/libraries/pmrt/telemetry/Debug/telemetryXml.sbr b/libraries/pmrt/telemetry/Debug/telemetryXml.sbr new file mode 100755 index 0000000..2af424e Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetryXml.sbr differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry_bb.obj b/libraries/pmrt/telemetry/Debug/telemetry_bb.obj new file mode 100755 index 0000000..fa3af02 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry_bb.obj differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry_bb.sbr b/libraries/pmrt/telemetry/Debug/telemetry_bb.sbr new file mode 100755 index 0000000..cba64fa Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry_bb.sbr differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry_pc.obj b/libraries/pmrt/telemetry/Debug/telemetry_pc.obj new file mode 100755 index 0000000..fa7f60b Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry_pc.obj differ diff --git a/libraries/pmrt/telemetry/Debug/telemetry_pc.sbr b/libraries/pmrt/telemetry/Debug/telemetry_pc.sbr new file mode 100755 index 0000000..30f016d Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/telemetry_pc.sbr differ diff --git a/libraries/pmrt/telemetry/Debug/vc60.idb b/libraries/pmrt/telemetry/Debug/vc60.idb new file mode 100755 index 0000000..9d7f077 Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/vc60.idb differ diff --git a/libraries/pmrt/telemetry/Debug/vc60.pdb b/libraries/pmrt/telemetry/Debug/vc60.pdb new file mode 100755 index 0000000..54bbbcd Binary files /dev/null and b/libraries/pmrt/telemetry/Debug/vc60.pdb differ diff --git a/libraries/pmrt/telemetry/bitbyte.c b/libraries/pmrt/telemetry/bitbyte.c new file mode 100755 index 0000000..671b33c --- /dev/null +++ b/libraries/pmrt/telemetry/bitbyte.c @@ -0,0 +1,707 @@ +/*////////////////////////////////////////////////////////////////////////// +diag.c +Play Mechanix - Video Game System +Copyright (c) 2004 Play Mechanix Inc. All Rights Reserved + +Description: Keep track of the amount of bytes sent and recieved on ppp + and eth interfaces. Different intervals can be specified + to be kept track of in telemLUT.xml. + All data is stored in one array for each interface type going + from oldest to newest data. If the array is full, then the + oldest data is removed by shifting all values to the left. +//////////////////////////////////////////////////////////////////////////*/ + +#include "bitbyte.h" +#include +#include +#include +#include + +#ifdef SYS_BB +#include +#include +#endif + +//gcc doesn't define min or max +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +BitByteInterfaces _bitByteInterfaces; + +//***********UTIL FUNCTIONS************* +static void PrintDebug(char* format,...) +{ + #ifdef DEBUG + char buff[1024] = {0}; + va_list args; + + sprintf(buff,"%s",format); + va_start(args,format); + vprintf(buff,args); + #endif +} + +/*! + \brief Reads out info from proc + \author RA + \date 2007/11/20 + \param name name of the interface wanting to be read + \param outData will be filled in with data on success + \return int 1 on success, 0 on fail +*/ +int UtilGetNetData(const char *name, BitBytePacket *outData) +{ + int ec = 0; +#ifdef SYS_BB + FILE *devFile = _NULL; + char buffer[1024]; + struct stat fileStat; + + if(!outData || !name) + return 0; + + outData->sent = 0; + outData->recv = 0; + + devFile = fopen("/proc/net/dev", "r"); + if(!devFile) + { + PrintDebug("UpdateNetData: Unable to open net.dev file \n"); + return 0; + } + + //**safety checks** + if(lstat("/proc/net/dev", &fileStat) != 0) + { + PrintDebug("UpdateNetData: Error in net.dev file \n"); + return 0; + } + if(S_ISLNK(fileStat.st_mode)) + { + PrintDebug("UpdateNetData: Error in net.dev file \n"); + return 0; + } + //**end safety checks** + + //read past header + if( !fgets(buffer, sizeof(buffer), devFile) ) + { + PrintDebug("UpdateNetData: Error in net.dev header \n"); + return 0; + } + if( !fgets(buffer, sizeof(buffer), devFile) ) + { + PrintDebug("UpdateNetData: Error in net.dev heard \n"); + return 0; + } + //done reading past header + + if( (strstr(buffer, "compressed")) == _NULL ) + { + PrintDebug("UpdateNetData: Header format not supported for net.dev \n"); + return 0; + } + + while( fgets(buffer, sizeof(buffer), devFile) ) + { + if( strstr(buffer, name) ) + { + uns64 recieved, sent; + + char *delim = strchr(buffer, ':'); + if( *( delim + 1 ) == ' ' ) + { + sscanf( buffer, "%*s %lu %*Lu %*lu %*lu %*lu %*lu %*lu %*lu %lu %*Lu %*lu %*lu %*lu %*lu %*lu %*lu", + &recieved, &sent ); + } + else + { + sscanf(delim+1, "%Lu %*lu %*lu %*lu %*lu %*lu %*lu %*lu %Lu", + &recieved, &sent ); + } + + outData->sent = (int)sent; + outData->recv = (int)recieved; + + ec = 1; + } + } + + fclose(devFile); + +#else //SYS_PC + outData->sent = outData->recv = 0; +#endif + + return ec; +} +//********END UTIL FUNCTIONS************ + + +//********BITBYTE UTIL FUNCTIONS************ +void BitByteUtilDiscardOld(time_t diff) +{ + int iDiff = (int)diff; + int i = 0; + + for(i = 0; i < _bitByteInterfaces.numInterfaces; ++i) + { + BitByteData *pData = &_bitByteInterfaces.bitByteData[i]; + + //discard old values if data is too old, or by shifting to the left by necessary amount + if(iDiff >= pData->info.size) + memset(&pData->info, 0, sizeof(pData->info)); + + else if(pData->info.count == pData->info.size) + { + //copy data into temp buffer + //clear old data + //copy latest data into the buffer + memcpy(_bitByteInterfaces.copyBuf, pData->data, sizeof(BitBytePacket)*pData->info.size); + memset(pData->data, 0, sizeof(BitBytePacket)*pData->info.size); + memcpy(pData->data, _bitByteInterfaces.copyBuf + iDiff, sizeof(BitBytePacket)*(pData->info.size-iDiff)); + + //do a sanity check before decrementing count + pData->info.count = (pData->info.count - iDiff > 0) ? pData->info.count - iDiff : 0; + } + } +} + +/*! + \brief Sums up the total bytes sent and recieved from interfaces and stores the results into + _bitByteData.ethCount and _bitByteData.pppCount + \author RA + \date 2007/11/19 + \param pData pointer to valid data + \param startIndex index in eth or ppp where summing will begin + \param endIndex index in eth or ppp where summing will end + \param outData pointer to a valid struct which will be filled on success. + \return void +*/ +void BitByteUtilTotal(const BitByteData *pData, int startIndex, int endIndex, BitBytePacket *outData) +{ + int i = 0; + + if(!pData || !outData || startIndex > endIndex || startIndex < 0 || endIndex >= pData->info.size) + return; + + //set counters to 0 + memset(outData, 0, sizeof(BitBytePacket)); + + //sum up eth data + for(i = startIndex; i < endIndex; ++i) + { + outData->sent += pData->data[i].sent; + outData->recv += pData->data[i].recv; + } +} + +/*! + \brief Returns a pointer to the bitByteData which has the same name + as the one passed in + \author RA + \date 2007/11/20 + \param name name of interface being searched + \return BitByteData pointer data, NULL if not found +*/ +BitByteData* BitByteUtilFindData(const char *name) +{ + int i = 0; + + for(i = 0; i < _bitByteInterfaces.numInterfaces; ++i) + { + if( !strcmp(_bitByteInterfaces.bitByteData[i].name, name) ) + return &_bitByteInterfaces.bitByteData[i]; + } + + return NULL; +} +//********END BITBYTE UTIL FUNCTIONS************ + +/*! + \brief Must be called before BitByte other functions are used + \author RA + \date 2007/11/16 + \param inXml pointer to xml residing in memory + \param xmlDataSize length in bytes of xml + \return int 0 on success, -1 on fail. Will fail if there was an error reading from the xml data +*/ +int BitByteInitialize(const char *inXml, int xmlDataSize) +{ + int ec = 0; + int i = 0; //counter + int maxTime = 0; + XmlFileTree fileTree; + List xmlData; + List subData; + ListNode *listNode = NULL; + XmlElement *element = NULL; + + ListCreate(&subData); + ListCreate(&xmlData); + + memset(&_bitByteInterfaces, 0, sizeof(_bitByteInterfaces)); + _bitByteInterfaces.interval = 1; + _bitByteInterfaces.prevCollectTime = time(NULL); + + //read out xml data into a tree structure + if(!XmlBuildFileTreeFromMem(inXml, xmlDataSize, &fileTree)) + return -1; + + //get the 'timers' subtree + if(!XmlFileTreeGetNodes(fileTree.tree.head, "timers", &xmlData)) + goto fail; + + //read out interval + if(!XmlFileTreeGetElement(xmlData.head->data, "interval", &element)) + PrintDebug("Unable to readout interval in BitByteInitialize \n"); + + _bitByteInterfaces.interval = atoi(element->value); + + //get requested interfaces + if(!XmlFileTreeGetElements(xmlData.head->data, "interface", &subData, TRUE)) + { + PrintDebug("Unable to find any interfaces \n"); + goto fail; + } + + //make sure 'interface's were found + if(!subData.numNodes || !subData.head || !subData.head->data) + { + PrintDebug("Unable to find any interfaces \n"); + goto fail; + } + + //allocate for interfaces + _bitByteInterfaces.numInterfaces = subData.numNodes; + _bitByteInterfaces.bitByteData = calloc(subData.numNodes, sizeof(BitByteData)); + if(!_bitByteInterfaces.bitByteData) + goto fail; + + //read out interface names + listNode = subData.head; + i = 0; + while(listNode) + { + XmlElement *elem = listNode->data; + + strncpy(_bitByteInterfaces.bitByteData[i].name, elem->value, sizeof(_bitByteInterfaces.bitByteData[i].name)); + + ++i; + listNode = listNode->next; + } + ListFree(&subData); + + //get all the 'timer's + if(!XmlFileTreeGetNodes(xmlData.head->data, "timer", &subData)) + { + PrintDebug("Unable to read timers in BitByteInitialize \n"); + goto fail; + } + + //make sure 'timer's were found + if(!subData.numNodes || !subData.head || !subData.head->data) + { + PrintDebug("No timers found in BitByteInitialize \n"); + goto fail; + } + + //make room for all the timers + _bitByteInterfaces.timers = calloc(subData.numNodes, sizeof(BitByteTimer)); + _bitByteInterfaces.numTimers = subData.numNodes; + if(!_bitByteInterfaces.timers) + { + PrintDebug("Unable to malloc memory of timers in BitBytInitialize \n"); + goto fail; + } + + //get and fill in timer data + listNode = subData.head; + i = 0; + while(listNode) + { + XmlElement *title = NULL; + XmlElement *days = NULL; + XmlElement *weeks = NULL; + XmlElement *months = NULL; + + XmlFileTreeGetElement(listNode->data, "title", &title); + XmlFileTreeGetElement(listNode->data, "days", &days); + XmlFileTreeGetElement(listNode->data, "weeks", &weeks); + XmlFileTreeGetElement(listNode->data, "months",&months); + + if(title->value) + memcpy(_bitByteInterfaces.timers[i].name, title->value, min( sizeof(_bitByteInterfaces.timers[i].name), strlen(title->value) ) ); + + //get total amount of days + if(days) + _bitByteInterfaces.timers[i].timeInterval = (days->value) ? atoi(days->value) : 0; + if(weeks) + _bitByteInterfaces.timers[i].timeInterval += (weeks->value) ? atoi(weeks->value)*7 : 0; + if(months) + _bitByteInterfaces.timers[i].timeInterval += (months->value)? atoi(months->value)*30 : 0; + + //convert from days to hours + _bitByteInterfaces.timers[i].timeInterval *= 24; + + //keep track of the largest timer + maxTime = (_bitByteInterfaces.timers[i].timeInterval > maxTime) ? _bitByteInterfaces.timers[i].timeInterval : maxTime; + + listNode = listNode->next; + ++i; + } + + //***allocate memory for interfaces and set data to 0*** + _bitByteInterfaces.copyBuf = calloc(maxTime, sizeof(BitBytePacket)); + if(!_bitByteInterfaces.copyBuf) + goto fail; + + //go through each interface and initialize it + for(i = 0; i < _bitByteInterfaces.numInterfaces; ++i) + { + BitByteData *pBitByteData = &_bitByteInterfaces.bitByteData[i]; + + pBitByteData->info.size = maxTime; + pBitByteData->data = calloc(maxTime, sizeof(BitBytePacket)); + UtilGetNetData(pBitByteData->name, &pBitByteData->prevCount); + + if(!_bitByteInterfaces.bitByteData[i].data) + goto fail; + } + //***done allocating memory for interfaces*** + + goto done; +fail: + ec = -1; + +done: + ListFree(&xmlData); + ListFree(&subData); + XmlFreeFileTree(&fileTree); + + return ec; +} + +/*! + \brief Load saved data + \author RA + \date 2007/11/20 + \param inData valid data + \return int 0 on success, -1 on fail +*/ +int BitByteFill(const BitByteSaveData *inData) +{ + time_t currTime = 0; + + //make sure there is some valid data + if( !inData) + return -1; + + //get the time data was previously collected + _bitByteInterfaces.prevCollectTime = inData->prevCollectTime; + currTime = time(NULL); + if(currTime < inData->prevCollectTime) + { + PrintDebug("BitByteFill: ERROR - Prev time passed in is greater than current time \n"); + return -1; + } + + else + { + BitByteData *pData = BitByteUtilFindData(inData->bitByteData.name); + const BitByteData *pInData = NULL; + int numElems = 0; + + if(!pData) + return -1; + + //get pointers to the current data + pInData = &inData->bitByteData; + + //get previous count + pData->prevCount = pInData->prevCount; + + //check for bounds + if(pInData->info.size > pData->info.size) + { + numElems = pData->info.size; + PrintDebug("BitByteFill: WARNING - More eth elements passed into fill than can be held \n"); + } + else + numElems = pInData->info.count; + + //reset data and copy over input data + memset(pData->data, 0, pData->info.size*sizeof(BitBytePacket)); + if(numElems) + memcpy(pData->data, pInData->data, numElems*sizeof(BitBytePacket)); + + pData->info.count = numElems; + } + + return 0; +} + +/*! + \brief Updates the data if the interval specified has passed + \author RA + \date 2007/11/19 + \return int 0 if data was updated, -1 otherwise +*/ +int BitByteUpdate(void) +{ + BitBytePacket currData; + time_t currTime = time(NULL); + time_t diff = (currTime - _bitByteInterfaces.prevCollectTime)/3600; + int i = 0; + int err = -1; + + //collect new data if it has been longer than the interval + if( currTime > _bitByteInterfaces.prevCollectTime && diff >= _bitByteInterfaces.interval ) + { + //if the array of data is full, then remove the last piece of data + //will decrement _bitByteData.xxxInfo.count if data is removed + BitByteUtilDiscardOld(diff); + + //update all interfaces + for(i = 0; i < _bitByteInterfaces.numInterfaces; ++i) + { + BitByteData *pData = &_bitByteInterfaces.bitByteData[i]; + int sent = 0; + int recieved = 0; + + //get current data + if(!UtilGetNetData(pData->name, &currData)) + continue; + + err = 0; + + //if the current data is less than previous data, use the current data, else use the difference between the two + recieved = (currData.recv >= pData->prevCount.recv) ? currData.recv - pData->prevCount.recv : currData.recv; + sent = (currData.sent >= pData->prevCount.sent) ? currData.sent - pData->prevCount.sent : currData.sent; + pData->data[pData->info.count].recv = recieved; + pData->data[pData->info.count].sent = sent; + + pData->info.count++; + + //save current data + memcpy(&pData->prevCount, &currData, sizeof(BitBytePacket)); + + }//end for + + _bitByteInterfaces.prevCollectTime = currTime; + }//end if + + return err; +} + +/*! + \brief Gets timer description and computes the total bytes sent/recieved for the timer + \author RA + \date 2007/11/19 + \param outTimer filled in with timer info if function succeeds. Set to NULL if not wanted + \param outData filled in with sum of data on success + \param timer index of the timer + \param name eth0, ppp0, ... + \return int 0 on success. -1 if timer index is invalid. -2 if the name was invalid +*/ +int BitByteGetTimerData(BitByteTimer *outTimer, BitBytePacket *outData, int timer, const char *name) +{ + int count = 0; + int startIndex = 0; + int endIndex = 0; + BitByteTimer *pTimer = NULL; + BitByteData *pData = BitByteUtilFindData(name); + BitBytePacket packet; + + //return if invalid index + if(timer >= _bitByteInterfaces.numTimers) + return -1; + + if(!pData) + return -2; + + //initialize all output to 0 + memset(outData, 0, sizeof(BitBytePacket)); + memset(outTimer, 0, sizeof(BitBytePacket)); + + pTimer = outTimer; + + //copy over timer + if(pTimer) + memcpy(pTimer, &_bitByteInterfaces.timers[timer], sizeof(BitByteTimer)); + else + pTimer = &_bitByteInterfaces.timers[timer]; + + count = pData->info.count; + + //data is stored in the array from oldest to newest + endIndex = count; + startIndex = (endIndex >= pTimer->timeInterval) ? endIndex - pTimer->timeInterval : 0; + + //get the summation of the bytes during the intervals + BitByteUtilTotal(pData, startIndex, endIndex, outData); + + //get current data from machine + if(UtilGetNetData(name, &packet)) + { + outData->recv += (packet.recv >= pData->prevCount.recv) ? packet.recv - pData->prevCount.recv : packet.recv; + outData->sent += (packet.sent >= pData->prevCount.sent) ? packet.sent - pData->prevCount.sent : packet.sent; + } + + return 0; +} + +int BitByteGetNumTimers(void) +{ + return _bitByteInterfaces.numTimers; +} + +/*! + \brief Gives the user a pointer to the interfaces. + \author RA + \date 2007/11/21 + \return const BitByteInterfaces * Pointer to interfaces +*/ +const BitByteInterfaces *BitByteGetInterfaces(void) +{ + return &_bitByteInterfaces; +} + +/*! + \brief Get interface data from machine + \author RA + \date 2007/11/21 + \param interfaceName name of the interface for which the data will be returned + \param outData pointer to a valid struct which will be filled in on success + \return int 0 on success, -1 on fail +*/ +int BitByteGetCurrData(const char *interfaceName, BitBytePacket *outData) +{ + if(!interfaceName || !outData) + return -1; + + memset(outData, 0, sizeof(BitBytePacket)); + + return (UtilGetNetData(interfaceName, outData)) ? 0 : -1; +} + +/*! + \brief Gets the total amount of intervals collected for a specific timer on a specific interface + \author RA + \date 2007/11/30 + \param interfaceName name of the interface + \param timer timer index + \return int amount of intervals collected so far, -1 on error +*/ +int BitByteGetNumValidIntervals(const char *interfaceName, int timer) +{ + BitByteData *pData = NULL; + BitByteTimer *pTimer = NULL; + + if(!interfaceName || timer >= _bitByteInterfaces.numTimers) + return -1; + + pData = BitByteUtilFindData(interfaceName); + if(!pData) + return -1; + + pTimer = &_bitByteInterfaces.timers[timer]; + + //count is the total count for the whole buffer, which is the size of the largest timer in the interface + //so if the count of the data is larger than the interval, return the timeInterval + return (pTimer->timeInterval < pData->info.count) ? pTimer->timeInterval : pData->info.count; +} + +/*! + \brief Gets all the intervals for a specific timer in a specific interface. outData is expected + to be large enough to hold output data. Can get number of valid interfaces using + BitByteGetNumValidIntervals + \author RA + \date 2007/11/30 + \param interfaceName name of the interface + \param timer index of the timer + \param outData a buffer expected to be large enough to hold the data + \return int 0 on success, -1 on fail +*/ +int BitByteGetAllData(const char *interfaceName, int timer, BitBytePacket *outData) +{ + BitByteData *pData = NULL; + BitByteTimer *pTimer = NULL; + int numIntervals = 0; + int i = 0; + int k = 0; + int startIndex = 0; + int endIndex = 0; + + if(!interfaceName || timer >= _bitByteInterfaces.numTimers) + return -1; + + pData = BitByteUtilFindData(interfaceName); + if(!pData) + return -1; + + pTimer = &_bitByteInterfaces.timers[timer]; + + //data is stored in the array from oldest to newest + endIndex = pData->info.count; + startIndex = (endIndex >= pTimer->timeInterval) ? endIndex - pTimer->timeInterval : 0; + + for(i = startIndex, k = 0; i < endIndex; ++i, ++k) + outData[k] = pData->data[i]; + + return 0; +} + +/*! + \brief Stores the maximums sent and recieved values in the outpacket of a specific timer in a + specifiv interface + \author RA + \date 2007/11/30 + \param interfaceName name of the interface + \param timer index of the timer + \param outPacket pointer to a valid BitBytePacket + \return int 0 on success, -1 on fail +*/ +int BitByteGetMaxValue(const char *interfaceName, int timer, BitBytePacket *outPacket) +{ + BitByteData *pData = NULL; + BitByteTimer *pTimer = NULL; + int startIndex = 0; + int endIndex = 0; + int i = 0; + + if(!interfaceName || timer >= _bitByteInterfaces.numTimers) + return -1; + + pData = BitByteUtilFindData(interfaceName); + if(!pData) + return -1; + + pTimer = &_bitByteInterfaces.timers[timer]; + + //data is stored in the array from oldest to newest + endIndex = pData->info.count; + startIndex = (endIndex >= pTimer->timeInterval) ? endIndex - pTimer->timeInterval : 0; + + memset(outPacket, 0, sizeof(BitBytePacket)); + + for(i = startIndex; i < endIndex; ++i) + { + outPacket->recv = (outPacket->recv < pData->data[i].recv) ? pData->data[i].recv : outPacket->recv; + outPacket->sent = (outPacket->sent < pData->data[i].sent) ? pData->data[i].sent : outPacket->sent; + } + + return 0; +} + +//EOF + diff --git a/libraries/pmrt/telemetry/bitbyte.h b/libraries/pmrt/telemetry/bitbyte.h new file mode 100755 index 0000000..ccb8586 --- /dev/null +++ b/libraries/pmrt/telemetry/bitbyte.h @@ -0,0 +1,63 @@ +#ifndef _BIT_BYTE_ +#define _BIT_BYTE_ +#include + +typedef struct _BitBytePacket +{ + unsigned int recv; + unsigned int sent; +}BitBytePacket; + +typedef struct _BitByteDataInfo //where interface is eth0, ppp, ... +{ + int size; //number of elements allocated + int count; //number of elements used +}BitByteDataInfo; + +typedef struct _BitByteTimer +{ + char name[80]; + int timeInterval; //time period in which the timer works in in hours (1 day, 7 days, 30 days...) +}BitByteTimer; + +typedef struct _BitByteData +{ + char name[20]; //name of the interface + BitBytePacket prevCount; //previous eth data read from machine + BitByteDataInfo info; + BitBytePacket *data; //collected data +}BitByteData; + +typedef struct _BitByteSaveData //used for saving/loading data +{ + BitByteData bitByteData; + time_t prevCollectTime; //time data was previously collected +}BitByteSaveData; + +typedef struct _BitByteInterface +{ + BitByteData *bitByteData; + BitByteTimer *timers; //timer data - same for all interfaces + BitBytePacket *copyBuf; //used for shifting interface data + time_t prevCollectTime; //time data was previously collected + int interval; //interval in hours which the data will be collected + int numTimers; //number of BitByteTimers + int numInterfaces; //number of elements in bitByteData +}BitByteInterfaces; + +int BitByteInitialize(const char *xmlData, int xmlDataSize); +int BitByteFill(const BitByteSaveData *inData); +int BitByteUpdate(void); +int BitByteGetTimerData(BitByteTimer *outTimer, BitBytePacket *outData, int timer, const char *interfaceName); +int BitByteGetNumTimers(void); +int BitByteGetCurrData(const char *interfaceName, BitBytePacket *outData); +int BitByteGetAllData(const char *interfaceName, int timer, BitBytePacket *outData); +int BitByteGetNumValidIntervals(const char *interfaceName, int timer); +int BitByteGetMaxValue(const char *interfaceName, int timer, BitBytePacket *outPacket); + +const BitByteInterfaces* BitByteGetInterfaces(void); + +#endif + +//EOF + diff --git a/libraries/pmrt/telemetry/bitbyte.o b/libraries/pmrt/telemetry/bitbyte.o new file mode 100644 index 0000000..36f7375 Binary files /dev/null and b/libraries/pmrt/telemetry/bitbyte.o differ diff --git a/libraries/pmrt/telemetry/driver/driver.dsp b/libraries/pmrt/telemetry/driver/driver.dsp new file mode 100755 index 0000000..c0e6522 --- /dev/null +++ b/libraries/pmrt/telemetry/driver/driver.dsp @@ -0,0 +1,101 @@ +# Microsoft Developer Studio Project File - Name="driver" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=driver - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "driver.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "driver.mak" CFG="driver - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "driver - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "driver - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries/pmrt/telemetry/driver", UPQAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "driver - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "driver - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib telemetry.lib xml.lib containers.lib libxml2.lib libiconv.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"c:\g3\lib" + +!ENDIF + +# Begin Target + +# Name "driver - Win32 Release" +# Name "driver - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\main.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/telemetry/driver/main.c b/libraries/pmrt/telemetry/driver/main.c new file mode 100755 index 0000000..4d27b76 --- /dev/null +++ b/libraries/pmrt/telemetry/driver/main.c @@ -0,0 +1,14 @@ +#include +#include + +void main() +{ + int i = 0; + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); +// _CrtSetBreakAlloc(431); + + TelemetryInitialize(); + TelemetryCollectData(); + + TelemetryShutDown(); +} \ No newline at end of file diff --git a/libraries/pmrt/telemetry/driver/mssccprj.scc b/libraries/pmrt/telemetry/driver/mssccprj.scc new file mode 100755 index 0000000..625dbfa --- /dev/null +++ b/libraries/pmrt/telemetry/driver/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[driver.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/telemetry/driver", UPQAAAAA diff --git a/libraries/pmrt/telemetry/driver/vssver.scc b/libraries/pmrt/telemetry/driver/vssver.scc new file mode 100755 index 0000000..8705979 Binary files /dev/null and b/libraries/pmrt/telemetry/driver/vssver.scc differ diff --git a/libraries/pmrt/telemetry/libTelemetry.a b/libraries/pmrt/telemetry/libTelemetry.a new file mode 100644 index 0000000..a7988a6 Binary files /dev/null and b/libraries/pmrt/telemetry/libTelemetry.a differ diff --git a/libraries/pmrt/telemetry/makedeplib b/libraries/pmrt/telemetry/makedeplib new file mode 100644 index 0000000..c064f31 --- /dev/null +++ b/libraries/pmrt/telemetry/makedeplib @@ -0,0 +1,159 @@ +telemetryXml.o: telemetryXml.c telemetryXml.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h \ + /g3/include/xmlWrapper/xmlWrapper.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /g3/include/libxml/xmlmemory.h /g3/include/libxml/xmlversion.h \ + /g3/include/libxml/xmlexports.h /g3/include/libxml/threads.h \ + /g3/include/libxml/globals.h /g3/include/libxml/parser.h \ + /g3/include/libxml/tree.h /g3/include/libxml/xmlstring.h \ + /g3/include/libxml/xmlregexp.h /g3/include/libxml/dict.h \ + /g3/include/libxml/hash.h /g3/include/libxml/valid.h \ + /g3/include/libxml/xmlerror.h /g3/include/libxml/list.h \ + /g3/include/libxml/xmlautomata.h /g3/include/libxml/entities.h \ + /g3/include/libxml/encoding.h /usr/include/iconv.h \ + /g3/include/libxml/xmlIO.h /g3/include/libxml/SAX.h \ + /g3/include/libxml/xlink.h /g3/include/libxml/SAX2.h \ + /g3/include/libxml/xmlreader.h /g3/include/libxml/relaxng.h +telemetry.o: telemetry.c telemetry_bb.c telemetry.h telemetryXml.h \ + /g3/include/pmrt_utils/pmrt_utils.h /g3/include/pmrt_utils/node.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/pmrt_utils/memallochist.h /g3/include/pmrt_utils/netsock.h \ + /g3/include/pmrt_utils/netsock_bb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h /usr/include/bits/stdio_lim.h \ + /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/inttypes.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /g3/include/pmrt_utils/netclient.h /g3/include/pmrt_utils/microtime.h \ + /g3/include/pmrt_utils/thread.h /g3/include/pmrt_utils/thread_bb.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /g3/include/pmrt_utils/tsqueue.h /g3/include/pmrt_utils/cguardian.h \ + /g3/include/pmrt_utils/containerCommon.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/audcrc.h \ + /g3/include/pmrt_utils/icmpSock.h /g3/include/pmrt_utils/icmpSock_bb.h \ + /usr/include/sys/param.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/sys/file.h \ + /usr/include/sys/time.h /usr/include/netinet/in_systm.h \ + /usr/include/netinet/ip.h /usr/include/netinet/ip_icmp.h \ + /g3/include/pmrt_utils/dnslookup.h \ + /g3/include/pmrt_utils/interfaceInfo.h \ + /g3/include/pmrt_utils/interfaceInfo_bb.h \ + /g3/include/pmrt_utils/textfile.h /g3/include/pmrt_utils/filesys.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /g3/include/pmrt_utils/pmrt_strings.h \ + /g3/include/pmrt_utils/rtdatatypes.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h /usr/include/bits/mathinline.h \ + /usr/include/linux/stat.h /usr/include/ctype.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h +bitbyte.o: bitbyte.c bitbyte.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /g3/include/xmlWrapper/xmlWrapper.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/string.h \ + /usr/include/bits/string.h /usr/include/bits/string2.h \ + /usr/include/endian.h /usr/include/bits/endian.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/libxml/xmlmemory.h /g3/include/libxml/xmlversion.h \ + /g3/include/libxml/xmlexports.h /g3/include/libxml/threads.h \ + /g3/include/libxml/globals.h /g3/include/libxml/parser.h \ + /g3/include/libxml/tree.h /g3/include/libxml/xmlstring.h \ + /g3/include/libxml/xmlregexp.h /g3/include/libxml/dict.h \ + /g3/include/libxml/hash.h /g3/include/libxml/valid.h \ + /g3/include/libxml/xmlerror.h /g3/include/libxml/list.h \ + /g3/include/libxml/xmlautomata.h /g3/include/libxml/entities.h \ + /g3/include/libxml/encoding.h /usr/include/iconv.h \ + /g3/include/libxml/xmlIO.h /g3/include/libxml/SAX.h \ + /g3/include/libxml/xlink.h /g3/include/libxml/SAX2.h \ + /g3/include/libxml/xmlreader.h /g3/include/libxml/relaxng.h \ + /g3/include/pmrt_utils/containers.h /g3/include/pmrt_utils/node.h \ + /usr/include/linux/stat.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h diff --git a/libraries/pmrt/telemetry/makefile b/libraries/pmrt/telemetry/makefile new file mode 100755 index 0000000..d0f57d8 --- /dev/null +++ b/libraries/pmrt/telemetry/makefile @@ -0,0 +1,38 @@ +# make driver +# make install (as root) +# +.CLIBFILES = telemetryXml.c telemetry.c bitbyte.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libTelemetry.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -Wno-format -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O3 -Wno-format -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /g3/lib/libpmrt_utils.a /usr/lib/libxml2.a /g3/lib/libXmlWrapper.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/telemetry + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/telemetry + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/telemetry/mssccprj.scc b/libraries/pmrt/telemetry/mssccprj.scc new file mode 100755 index 0000000..7dd7719 --- /dev/null +++ b/libraries/pmrt/telemetry/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[telemetry.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/telemetry", SPQAAAAA diff --git a/libraries/pmrt/telemetry/telemetry.c b/libraries/pmrt/telemetry/telemetry.c new file mode 100755 index 0000000..b99c15f --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry.c @@ -0,0 +1,14 @@ +#ifdef SYS_BB +#include "telemetry_bb.c" +#endif + +#ifdef SYS_PC +#include "telemetry_pc.c" +#endif + + + + + + + diff --git a/libraries/pmrt/telemetry/telemetry.dsp b/libraries/pmrt/telemetry/telemetry.dsp new file mode 100755 index 0000000..93e8d4c --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry.dsp @@ -0,0 +1,128 @@ +# Microsoft Developer Studio Project File - Name="telemetry" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=telemetry - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "telemetry.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "telemetry.mak" CFG="telemetry - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "telemetry - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "telemetry - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries/pmrt/telemetry", SPQAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "telemetry - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "telemetry - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\telemetry copy *.h c:\g3\include\telemetry\ copy debug\telemetry.lib c:\g3\lib\ +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "telemetry - Win32 Release" +# Name "telemetry - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\bitbyte.c +# End Source File +# Begin Source File + +SOURCE=.\telemetry.c +# End Source File +# Begin Source File + +SOURCE=.\telemetry_bb.c +# End Source File +# Begin Source File + +SOURCE=.\telemetry_pc.c +# End Source File +# Begin Source File + +SOURCE=.\telemetryXml.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\bitbyte.h +# End Source File +# Begin Source File + +SOURCE=.\telemetry.h +# End Source File +# Begin Source File + +SOURCE=.\telemetryXml.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/telemetry/telemetry.dsw b/libraries/pmrt/telemetry/telemetry.dsw new file mode 100755 index 0000000..01965df --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry.dsw @@ -0,0 +1,53 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "driver"=.\driver\driver.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/telemetry/driver", UPQAAAAA + .\driver + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "telemetry"=.\telemetry.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/telemetry", SPQAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/telemetry", SPQAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/telemetry/telemetry.h b/libraries/pmrt/telemetry/telemetry.h new file mode 100755 index 0000000..2d84b88 --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry.h @@ -0,0 +1,72 @@ + // telemetry.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_TELEMETRY +#define PMRT_TELEMETRY + +#include "telemetryXml.h" +#include +#include +#include + +typedef struct _QueryData +{ + int dataId; + float data; + char misc[256]; + char *postFix; + char *name; +}QueryData; + +typedef struct _NetByteData +{ + uns64 bytesSentEth0; + uns64 bytesRecievedEth0; + uns64 bytesSentPpp0; + uns64 bytesRecievedPpp0; +}NetByteData; + +typedef struct _SystemNetNode +{ + SysDate_Utils recordTime; //when it was recorded + uns32 dataCount; + uns32 dataSize; + uns32 timeInterval; + char *title; + NetByteData *data; + NetByteData *dataCopyBuf; + +}SystemNetNode; + +int TelemetryInitialize(const char *telemLookUpTable, const char *telemFields, int lutSize, int fieldSize); + +unsigned int TelemetryCollectData(); + +//need to call when game shut downs inorder to avoid memleaks +void TelemetryShutDown(); + +//needs to be called continuously +int TelemetryUpdateNetTimers(); + +int TelemetryGetNumNetTimers(); + +int TelemetryGetNetData(int timerIndex, NetByteData *outData); + +int TelemetryFillNetData(NetByteData *data, uns32 *dataCount, uns32 *dataSize, uns32 numTimers, time_t recordTime); + +int TelemetryGetNextNetUpdate(); + +int TelemetryGetNetInterval(int timer); //returns in days + +extern QueryData *telemetryData; +extern SystemNetNode *systemNetNodes; +extern NetByteData currNetData; + +#define MAX_NET_TIMERS 5 + +#endif + + + + diff --git a/libraries/pmrt/telemetry/telemetry.o b/libraries/pmrt/telemetry/telemetry.o new file mode 100644 index 0000000..f051628 Binary files /dev/null and b/libraries/pmrt/telemetry/telemetry.o differ diff --git a/libraries/pmrt/telemetry/telemetry.plg b/libraries/pmrt/telemetry/telemetry.plg new file mode 100755 index 0000000..b8b4200 --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry.plg @@ -0,0 +1,87 @@ + + +
+

Build Log

+

+--------------------Configuration: xml - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FB.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR"Debug/" /Fp"Debug/xml.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\xmlWrapper\xmlWrapper.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FB.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\xml.lib" .\Debug\xmlWrapper.obj " +

Output Window

+Compiling... +xmlWrapper.c +Creating library... +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FC.bat" with contents +[ +@echo off +mkdir c:\g3\include\xmlWrapper +copy *.h c:\g3\include\xmlWrapper\ +copy debug\xml.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FC.bat" + +xmlWrapper.h + 1 file(s) copied. + 1 file(s) copied. +

+--------------------Configuration: telemetry - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FD.tmp" with contents +[ +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "SYS_PC" /FR"Debug/" /Fp"Debug/telemetry.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\g3\libraries\pmrt\telemetry\bitbyte.c" +"C:\g3\libraries\pmrt\telemetry\telemetry.c" +"C:\g3\libraries\pmrt\telemetry\telemetry_bb.c" +"C:\g3\libraries\pmrt\telemetry\telemetry_pc.c" +"C:\g3\libraries\pmrt\telemetry\telemetryXml.c" +] +Creating command line "cl.exe @C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FD.tmp" +Creating command line "link.exe -lib /nologo /out:"Debug\telemetry.lib" .\Debug\bitbyte.obj .\Debug\telemetry.obj .\Debug\telemetry_bb.obj .\Debug\telemetry_pc.obj .\Debug\telemetryXml.obj \g3\libraries\pmrt\xmlWrapper\Debug\xml.lib " +

Output Window

+Compiling... +bitbyte.c +telemetry.c +telemetry_bb.c +telemetry_pc.c +telemetryXml.c +Creating library... +telemetry.obj : warning LNK4006: _TelemetryGetData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetrySetupQueries already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryInitialize already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryCollectData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryShutDown already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryUpdateNetTimers already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNumNetTimers already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNetData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryFillNetData already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNextNetUpdate already defined in telemetry_pc.obj; second definition ignored +telemetry.obj : warning LNK4006: _TelemetryGetNetInterval already defined in telemetry_pc.obj; second definition ignored +Creating temporary file "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FE.bat" with contents +[ +@echo off +mkdir c:\g3\include\telemetry +copy *.h c:\g3\include\telemetry\ +copy debug\telemetry.lib c:\g3\lib\ +] +Creating command line "C:\DOCUME~1\mnajera\LOCALS~1\Temp\RSP3FE.bat" + +bitbyte.h +telemetry.h +telemetryXml.h + 3 file(s) copied. + 1 file(s) copied. + + + +

Results

+telemetry.lib - 0 error(s), 11 warning(s) +
+ + diff --git a/libraries/pmrt/telemetry/telemetryXml.c b/libraries/pmrt/telemetry/telemetryXml.c new file mode 100755 index 0000000..e7202a2 --- /dev/null +++ b/libraries/pmrt/telemetry/telemetryXml.c @@ -0,0 +1,481 @@ +// telemetryXml.c +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +/*****Documentation of data format***** + +List + List //different queries for version X + Struct + List //elements + path + file + desc + .... + List //attributes + Struct + List //elements + path + file + desc + .... + List //attributes + + List //different queries for version X.1 + ... + ... + ... +****/ +// RA July 07 + +#include "telemetryXml.h" +#include +#include + +//****forward decls**** + +static TelemetryQuery *g_currQuery = _NULL; +static List g_queryPaths; //list //pathName pathValue +static List g_telemetryDefs; //list +static List *g_currQueryList; //list +static List *g_telemetryQueries; //list< list > +static List *g_telemetryFields; //list< string > a list of fields which need to be queried such as fanSpeed or cpuTemp +static List *g_netNodeList; //list +static float g_queryVersion; +static int g_queryOpen = 0; +static int g_netCollectionInterval; +static NetNodeTrigger currNetNode; + +static void LUTQueryAttribute(const xmlChar *inName, int inCount, XmlParser *inParser); +static void LUTQueryBeginElement(const xmlChar *inName, XmlParser *inParser); +static void LUTQueryEndElement(const xmlChar *inName, XmlParser *inParser); +static void LUTHandleTextValue(const xmlChar *inName, xmlChar *inValue, struct _XmlParser *inParser); + +static void TelemetryFieldEndElement(const xmlChar *inName, XmlParser *inParser); + +//****end forward decls**** + +//add path onto file name +void FixPaths(List *telemetryQuery) +{ + const int numQueries = telemetryQuery->numNodes; + ListNode *query = telemetryQuery->head; + int counter = 0; + + for(counter = 0; counter < numQueries; ++counter) + { + TelemetryQuery *queryData = query->data; + TelemetryQueryNode *qFileNode = TelemXMLFindQueryNode("file", &queryData->elements); + TelemetryQueryNode *qPathNode = TelemXMLFindQueryNode("path", &queryData->elements); + TelemetryQueryNode *pathNode = _NULL; + char *oldStr = _NULL; + + if(!qFileNode || !qPathNode) + { + DebugOutput("TlmXml: All nodes not found in query for fixing paths\n"); + continue; + } + + pathNode = TelemXMLFindQueryNode(qPathNode->value, &g_queryPaths); + if(!pathNode) + { + DebugOutput("TlmXml: Path not found \n"); + continue; + } + + oldStr = qFileNode->value; + StringConcat((char**)&qFileNode->value, pathNode->value, qFileNode->value); + + CustomFree(oldStr); + + query = query->next; + } +} + +List *TelemXMLFindQuery(List *telemQueries, const char *nodeName, const char *valueName) +{ + unsigned int counter = 0; + ListNode *version = telemQueries->head; + + for(counter = 0; counter < telemQueries->numNodes; ++counter, version = version->next) + { + List *queryList = _NULL; + ListNode *listNode = _NULL; + unsigned int counter2 = 0; + + if(!version || !version->data) + { + DebugOutput("Telem: Error finding query. Query list is corrupt \n"); + continue; + } + + queryList = version->data; + listNode = queryList->head; + + //go through each query + for(counter2 = 0; counter2 < queryList->numNodes; ++counter2, listNode = listNode->next) + { + TelemetryQuery *query = _NULL; + TelemetryQueryNode *queryNode = _NULL; + + if(!listNode || !listNode->data) + { + DebugOutput("Telem: Error finding query. Element list is corrupt \n"); + continue; + } + + query = listNode->data; + queryNode = TelemXMLFindQueryNode(nodeName, &query->elements); + if(!queryNode) + continue; + + if( strcmp(queryNode->value, valueName) == 0) + return &query->elements; + } + } + + return _NULL; +} + +void TelemXMLFreeTelemetryQueryList(List *list) +{ + ListNode *node = _NULL; + + if(!list) + return; + + node = list->head; + while(node) + { + TelemetryQueryNode *qNode = node->data; + + CustomFree(qNode->name); + CustomFree(qNode->value); + + if(!node->dataSize) + CustomFree(qNode); + + ListPop(list, node); + ListFreeNode(node); + + node = list->head; + } + + ListFree(list); +} + +int TelemXMLInitializeFromXML(const char *lutData, int lutSize, const char *fieldData, int fieldSize, + List *queryList, List *fieldList, List *netNodes, int *netCollectionInterval) +{ + XmlParser lutParser; + XmlParser fieldParser; + int error = TELEMETRY_SUCCESS; + + //****init**** + g_telemetryFields = fieldList; + g_telemetryQueries = queryList; + g_netNodeList = netNodes; + + ListCreate(&g_queryPaths); + ListCreate(queryList); + ListCreate(fieldList); + //**end init** + + if(!XmlCreateParserFromMem(&lutParser, lutData, lutSize, LUTQueryAttribute, LUTHandleTextValue, LUTQueryEndElement, LUTQueryBeginElement)) + return TELEMETRY_INVALID_FILE; + + if(!XmlCreateParserFromMem(&fieldParser, fieldData, fieldSize, _NULL, _NULL, TelemetryFieldEndElement, _NULL)) + { + XmlFreeParser(&lutParser); + return TELEMETRY_INVALID_FILE; + } + + XmlParseFile(&lutParser); + XmlParseFile(&fieldParser); + + *netCollectionInterval = g_netCollectionInterval; + + //****free allocs**** + XmlFreeParser(&lutParser); + XmlFreeParser(&fieldParser); + + TelemXMLFreeTelemetryQueryList(&g_queryPaths); + ListFree(&g_telemetryDefs); + //**end free allocs** + + return error; +} + +TelemetryQueryNode *TelemXMLFindQueryNode(const char *name, List *queryNodes) +{ + unsigned int counter = 0; + ListNode *node = _NULL; + + if(!queryNodes || !name) + return _NULL; + + node = queryNodes->head; + for(counter = 0; counter < queryNodes->numNodes && node; ++counter) + { + TelemetryQueryNode *query = node->data; + + if(strcmp(query->name, name) == 0) + return query; + + node = node->next; + } + + return _NULL; +} + +void TelemXMLFreeTelemetryQueries(List *queries) +{ + unsigned int counter = 0; + ListNode *listNode = _NULL; + + if(!queries) + return; + + listNode = queries->head; + for(counter = 0; counter < queries->numNodes; ++counter) + { + List *list = listNode->data; + ListNode *currList = list->head; + unsigned int counter2 = 0; + + for(counter2 = 0; counter2 < list->numNodes; ++counter2) + { + TelemetryQuery *query = currList->data; + TelemXMLFreeTelemetryQueryList(&query->elements); + TelemXMLFreeTelemetryQueryList(&query->attributes); + + //if memory is not managed by list, it must be freed + if(!currList->dataSize) + CustomFree(query); + + currList = currList->next; + } + + ListFree(list); + if(!listNode->dataSize) //if data is not managed by list, free it + CustomFree(list); + CustomFree(currList); + listNode = listNode->next; + } + + ListFree(queries); +} + +//********************************************************************* +//*****************Query Callback Functions for XML******************** +//********************************************************************* +TelemetryQueryDef *GetQueryDef(float versionNumber) +{ + ListNode *node = g_telemetryDefs.head; + + while(node) + { + TelemetryQueryDef *def = node->data; + if(def->version == versionNumber) + return def; + + node = node->next; + } + + return _NULL; +} + +void LUTQueryAttribute(const xmlChar *inName, int inCount, XmlParser *inParser) +{ + const xmlChar *elementName = XmlGetElementName(inParser->parsedData.tail); + + if(strcmp(elementName, "path") == 0) + { + xmlChar *pathName = _NULL; + TelemetryQueryNode *newData = _NULL; + + newData = (TelemetryQueryNode*)CustomMalloc(sizeof(TelemetryQueryNode)); + pathName = XmlGetAttributeByName(inParser->file, "name"); + + //copy over data + if(!CopyStrings((char**)&newData->name, pathName)) + DebugOutput("TlmXml: Unable to copy telemetry path attribute \n"); + + //free mem + XmlFreeString(pathName); + + ListPushBack(&g_queryPaths, newData, 0); + } + else if(strcmp(elementName, "queries") || strcmp(elementName, "querydef") == 0) + { + xmlChar *versionNum = _NULL; + + versionNum = XmlGetAttributeByName(inParser->file, "version"); + if(!versionNum) + { + DebugOutput("TlmXml: Error in xml file for telemetry, no version attribute found in queries/querydef \n"); + return; + } + + g_queryVersion = (float)atof(versionNum); + + //free mem + XmlFreeString(versionNum); + } +} + +void LUTQueryEndElement(const xmlChar *inName, XmlParser *inParser) +{ + if(strcmp(inName, "query") == 0) + { + ListPushBack(g_currQueryList, g_currQuery, _NULL); + g_queryOpen = 0; + } + + else if(strcmp(inName, "paths") == 0) + { + XmlTextNode *textNodeHead = _NULL; + XmlTextNode *textNode = _NULL; + int counter = 0; + ListNode *queryPathNode = g_queryPaths.head; + + //Get text + const int numNodesFound = XmlGetStringsInElementBlock(inParser->parsedData.tail, "path", "paths", &textNodeHead, XML_SEARCH_BACKWARDS); + + //sanity check + if(numNodesFound != (int)g_queryPaths.numNodes) + DebugOutput("Error in telemetryLUT file. Num paths != numPathNames \n"); + + //get all paths + textNode = textNodeHead; + for(counter = 0; counter < numNodesFound; ++counter) + { + TelemetryQueryNode *pathData = queryPathNode->data; + if(!pathData) + DebugOutput("TlmXml: Error parsing telemetry paths \n"); + + if(!CopyStrings((char**)&pathData->value, textNode->string)) + DebugOutput("TlmXml: Error parsing telemetry paths \n"); + + textNode = textNode->next; + queryPathNode = queryPathNode->next; + } + + XmlFreeTextNodes(textNodeHead); + }//end paths + + //get number of elements and number of attributes + else if(strcmp(inName, "querydef") == 0) + { + int numNodesFound = 0; + XmlTextNode *attribNode = _NULL; + XmlTextNode *elemNode = _NULL; + TelemetryQueryDef queryDef; + + numNodesFound += XmlGetStringsInElementBlock(inParser->parsedData.tail, "attributes", "querydef", &attribNode, XML_SEARCH_BACKWARDS); + numNodesFound += XmlGetStringsInElementBlock(inParser->parsedData.tail, "elements", "querydef", &elemNode, XML_SEARCH_BACKWARDS); + + if(!numNodesFound) + DebugOutput("TlmXml: Error in telemetryLUT xml file. No tags found in querydef \n"); + + queryDef.numAttributes = (attribNode && attribNode->string) ? atoi(attribNode->string) : 0; + queryDef.numElements = (elemNode && elemNode->string) ? atoi(elemNode->string) : 0; + queryDef.version = g_queryVersion; + + if(!queryDef.numElements) + DebugOutput("TlmXml: Error in telemetryLUT xml file. No element tags found"); + + XmlFreeTextNodes(attribNode); + XmlFreeTextNodes(elemNode); + + ListPushBack(&g_telemetryDefs, &queryDef, sizeof(TelemetryQueryDef)); + } + else if(strcmp(inName, "queries") == 0) + { + FixPaths(g_currQueryList); + ListPushBack(g_telemetryQueries, g_currQueryList, _NULL); + } + else if(strcmp(inName, "timer") == 0) + ListPushBack(g_netNodeList, &currNetNode, sizeof(currNetNode)); +} + +void LUTQueryBeginElement(const xmlChar *inName, XmlParser *inParser) +{ + if(strcmp(inName, "query") == 0) + { + g_currQuery = (TelemetryQuery *)CustomMalloc(sizeof(TelemetryQuery)); + ListCreate(&g_currQuery->attributes); + ListCreate(&g_currQuery->elements); + g_queryOpen = 1; + } + else if(strcmp(inName, "queries") == 0) + { + g_currQueryList = (List *)CustomMalloc(sizeof(List)); + + ListCreate(g_currQueryList); + } + else if(strcmp(inName, "timer") == 0) + memset(&currNetNode, 0, sizeof(currNetNode)); +} + +void LUTHandleTextValue(const xmlChar *inName, xmlChar *inValue, struct _XmlParser *inParser) +{ + if(g_queryOpen) + { + TelemetryQueryNode *node = (TelemetryQueryNode*)CustomMalloc(sizeof(TelemetryQueryNode)); + + if(!CopyStrings((char**)&node->name, inName)) + DebugOutput("TlmXml: Unable to copy telemetry query name \n"); + + if(!CopyStrings((char**)&node->value, inValue)) + DebugOutput("TlmXml: Unable to copy telemetry query value \n"); + + ListPushBack(&g_currQuery->elements, node, _NULL); + } + + else if(strcmp(inName, "months") == 0) + currNetNode.months = atoi(inValue); + else if(strcmp(inName, "weeks") == 0) + currNetNode.weeks = atoi(inValue); + else if(strcmp(inName, "days") == 0) + currNetNode.days = atoi(inValue); + else if(strcmp(inName, "interval") == 0) + g_netCollectionInterval = atoi(inValue); + else if(strcmp(inName, "title") == 0) + CopyStrings(&currNetNode.title, (char*)inValue); +} +//********************************************************************* +//***************End Query Callback Functions for XML****************** +//********************************************************************* + + +//********************************************************************* +//***************Telemetry Field Callback Functions for XML************ +//********************************************************************* +void TelemetryFieldEndElement(const xmlChar *inName, XmlParser *inParser) +{ + if(strcmp(inName, "queries") == 0) + { + int counter = 0; + XmlTextNode *queryNode = _NULL; + XmlTextNode *queryNodeHead = _NULL; + + const int numNodesFound = XmlGetStringsInElementBlock(inParser->parsedData.tail, "query", "queries", &queryNodeHead, XML_SEARCH_BACKWARDS); + + queryNode = queryNodeHead; + for(counter = 0; counter < numNodesFound; ++counter) + { + ListPushBack(g_telemetryFields, queryNode->string, sizeof(char)* (strlen(queryNode->string) + 1) ); + + queryNode = queryNode->next; + } + + XmlFreeTextNodes(queryNodeHead); + } +} + +//********************************************************************* +//***********End Telemetry Field Callback Functions for XML************ +//********************************************************************* + + diff --git a/libraries/pmrt/telemetry/telemetryXml.h b/libraries/pmrt/telemetry/telemetryXml.h new file mode 100755 index 0000000..2668b4e --- /dev/null +++ b/libraries/pmrt/telemetry/telemetryXml.h @@ -0,0 +1,58 @@ +// telemetryXml.h +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +#ifndef PMRT_TELEMETRY_XML +#define PMRT_TELEMETRY_XML +#include + +typedef enum _TelemetryEnum +{ + TELEMETRY_ERRUNKNOWN, + TELEMETRY_INVALID_FILE, + TELEMETRY_SUCCESS +}TelemetryEnum; + +typedef struct _TelemetryQueryDef +{ + float version; + unsigned int numAttributes; + unsigned int numElements; +}TelemetryQueryDef; + +typedef struct _TelemetryQueryNode +{ + unsigned char *name; + unsigned char *value; +}TelemetryQueryNode; + +typedef struct _TelemetryQuery +{ + List attributes; //list + List elements; //list +}TelemetryQuery; + +typedef struct _NetNodeTimeTrigger +{ + char *title; + uns32 days; + uns32 weeks; + uns32 months; +}NetNodeTrigger; + +int TelemXMLInitializeFromXML (const char *lutData, int lutSize, const char *fieldData, int fieldSize, + List *queryList, List *names, List *netNodes, + int *netCollectionInterval); + +List* TelemXMLFindQuery(List *telemQueries, const char *nodeName, const char *valueName); + +void TelemXMLFreeTelemetryQueries(List *queryList); +TelemetryQueryNode *TelemXMLFindQueryNode (const char *name, List *queryNodes); + +#endif + +//EOF + + + + diff --git a/libraries/pmrt/telemetry/telemetryXml.o b/libraries/pmrt/telemetry/telemetryXml.o new file mode 100644 index 0000000..7d60c0c Binary files /dev/null and b/libraries/pmrt/telemetry/telemetryXml.o differ diff --git a/libraries/pmrt/telemetry/telemetry_bb.c b/libraries/pmrt/telemetry/telemetry_bb.c new file mode 100755 index 0000000..aa372b4 --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry_bb.c @@ -0,0 +1,721 @@ + #ifdef SYS_BB +// telemetry.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// RA July 07 + +//NOTE: The NetByte stuff is no longer used. Use bitbyte.c instead. + +#include "telemetry.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// #include +#include +#include + +List g_telemQueries; +List g_telemFields; +List g_queryInfo; +QueryData *telemetryData; +SystemNetNode *systemNetNodes; +NetByteData currNetData; +static SysDate_Utils lastNetTime; +static NetByteData origNetData; +static unsigned int telemArraySize; +static int telemInitialized; +static int netDataInitialized; +static int g_netCollectionInterval; +static int g_collected; +static List g_netNodeTriggers; //list +static NetByteData g_prevData; + +typedef struct _QueryInfo +{ + char *filePath; + char *name; + char *format; + char *postFix; + char *operation; + int id; +}QueryInfo; + +//forward decls +static void UpdateNetData(NetByteData *byteData); +static void ElapsedTime(SysDate_Utils *out, SysDate_Utils *begin, SysDate_Utils *end); +//end forward decls + +/*! + \brief opens a file and reads in the data + \param path fullpath+fileName of the file + \param format optional. used when reading in string data, ex: %*s %s set to _NULL if not using + \param outData optional. a pointer to valid memory which is filled in with data. set to _NULL if not using + \param value read in from file, -num if error. 1 if success when reading in string data + \return error code +*/ +int TelemetryGetData(const char *path, const char *format, char *outData, float *value) +{ + FILE *file = _NULL; + *value = -1.f; + + file = fopen(path, "r"); + if(!file) + return -1; + + if(!format) + { + if(fscanf(file, "%f", value) == EOF) + return -2; + } + else + { + if(!outData) + return -3; + + if(fscanf(file, format, outData) == EOF) + return -4; + + fclose(file); + + return 1; + } + + fclose(file); + + return 1; +} + +/*! + \brief internal function used to initialize query data for system telemetry +*/ +void TelemetrySetupQueries() +{ + unsigned int counter = 0; + ListNode *fieldNode = g_telemFields.head; + + telemArraySize = g_telemFields.numNodes; + telemetryData = (QueryData*)CustomMalloc(sizeof(QueryData)*telemArraySize); + + for(counter = 0; counter < g_telemFields.numNodes; ++counter, fieldNode = fieldNode->next) + { + char *queryName = fieldNode->data; + List *queryList = _NULL; + TelemetryQueryNode *idNode = _NULL; + TelemetryQueryNode *fileNode = _NULL; + TelemetryQueryNode *formatNode = _NULL; + TelemetryQueryNode *postFixNode = _NULL; + TelemetryQueryNode *operNode = _NULL; //operation node (multiply, divide) + QueryInfo newInfo; + + queryList = TelemXMLFindQuery(&g_telemQueries, "name", queryName); + if(!queryList) + continue; + + idNode = TelemXMLFindQueryNode("id", queryList); + fileNode = TelemXMLFindQueryNode("file", queryList); + formatNode = TelemXMLFindQueryNode("format", queryList); + postFixNode = TelemXMLFindQueryNode("postfix", queryList); + operNode = TelemXMLFindQueryNode("operation", queryList); + + if(!(idNode && fileNode)) + continue; + + newInfo.filePath = fileNode->value; + newInfo.id = atoi(idNode->value); + newInfo.name = queryName; + newInfo.format = (formatNode) ? formatNode->value : _NULL; + newInfo.postFix = (postFixNode) ? postFixNode->value : _NULL; + newInfo.operation = (operNode) ? operNode->value : _NULL; + + ListPushBack(&g_queryInfo, &newInfo, sizeof(QueryInfo)); + } +} + +/*! + \brief internal function used to setup queries +*/ +void TelemetrySetupNetTimers() +{ + ListNode *currNode = _NULL; + unsigned int counter = 0; + + g_collected = 0; + + //g_netNodeTrigger data was filled in by reading xml file in TelemetryInitialize + systemNetNodes = (SystemNetNode *)CustomMalloc( g_netNodeTriggers.numNodes*sizeof(SystemNetNode)); + if(!systemNetNodes || g_netCollectionInterval <= 0) + return; + + memset(systemNetNodes, 0, sizeof(SystemNetNode)*g_netNodeTriggers.numNodes); + + currNode = g_netNodeTriggers.head; + + //allocate arrays for holding byte data + for(counter = 0; counter < g_netNodeTriggers.numNodes; ++counter, currNode = currNode->next) + { + unsigned int size = 0; + NetNodeTrigger *triggerData = currNode->data; + + size = (triggerData->months*30 + triggerData->weeks*7 + triggerData->days) * ceil(24/g_netCollectionInterval); + + systemNetNodes[counter].dataSize = size; + systemNetNodes[counter].dataCount = 0; + systemNetNodes[counter].data = (NetByteData*)CustomMalloc(size*sizeof(NetByteData)); + systemNetNodes[counter].dataCopyBuf = (NetByteData*)CustomMalloc((size-1)*sizeof(NetByteData)); + systemNetNodes[counter].title = triggerData->title; + systemNetNodes[counter].timeInterval = triggerData->months*30 + triggerData->weeks*7 + triggerData->days; + if(!systemNetNodes[counter].data || !systemNetNodes[counter].dataCopyBuf) + { + netDataInitialized = -1; + continue; + } + memset(systemNetNodes[counter].data, 0, size*sizeof(NetByteData)); + memset(systemNetNodes[counter].dataCopyBuf, 0, (size-1)*sizeof(NetByteData)); + } + + UpdateNetData(&origNetData); + UpdateNetData(&currNetData); + + SysDateTime_Utils(&lastNetTime, 0); + + if(netDataInitialized != -1) + { + netDataInitialized = 1; + DebugOutput("Telem: Failed to initialize netData \n"); + } +} + +int TelemetryInitialize(const char *telemLookUpTable, const char *telemFields, int lutSize, int fieldSize) +{ + + telemInitialized = 0; + + if(TelemXMLInitializeFromXML(telemLookUpTable, lutSize, telemFields, fieldSize, &g_telemQueries, + &g_telemFields, &g_netNodeTriggers, &g_netCollectionInterval) == TELEMETRY_SUCCESS) + telemInitialized = 1; + else + { + DebugOutput("Telemetry failed to initialize \n"); + return 0; + } + + //read out queries from xml + TelemetrySetupQueries(); + + //create timers for net data +// TelemetrySetupNetTimers(); + + telemInitialized = 1; + + return telemInitialized; +} + +/*! + \brief updates telemetry data and returns the amount of elements updated +*/ +unsigned int TelemetryCollectData() +{ + unsigned int counter = 0; + unsigned int read = 0; + ListNode *queryNode = _NULL; + char buffer[256]; + int index = 0; + + if(!telemInitialized) + return 0; + + queryNode = g_queryInfo.head; + for(counter = 0; counter < g_queryInfo.numNodes; ++counter) + { + QueryInfo *queryInfo = queryNode->data; + + float value; + int ec = TelemetryGetData(queryInfo->filePath, queryInfo->format, buffer, &value); + + //sanity if check + if(counter < telemArraySize) + { + telemetryData[counter].dataId = queryInfo->id; + telemetryData[counter].data = value; + telemetryData[counter].name = queryInfo->name; + telemetryData[counter].postFix = queryInfo->postFix; + + if(queryInfo->format && value >= 0.f) + strcpy(telemetryData[counter].misc, buffer); + else + telemetryData[counter].misc[0] = 0; + + if(queryInfo->operation) + { + value = 0; + char *operation = queryInfo->operation; + if(isalpha(*operation)) + { + value = atof(queryInfo->operation + 1); + if(ec > 0) + { + if(*operation == 'd') + { + telemetryData[counter].data /= value; + } + else if(*operation == 'm') + { + telemetryData[counter].data *= value; + } + else if(*operation == 'a') + { + telemetryData[counter].data += value; + } + else if(*operation == 's') + { + telemetryData[counter].data -= value; + } + else if(telemetryData[counter].misc[0] && strcmp(operation, "capitalize") == 0) + { + index = 0; + while(telemetryData[counter].misc[index]) + { + telemetryData[counter].misc[index] = toupper(telemetryData[counter].misc[index]); + ++index; + } + } + } + } + + } + + //On the Dell, CoreTemp1 falsely reports as -49.0 C + //catch here and set to N/A state + if(!strcmp(telemetryData[counter].name,"CoreTemp1") && telemetryData[counter].data==-49.0) + telemetryData[counter].data = -1.0f; + + ++read; + } + + queryNode = queryNode->next; + } + + return read; +} + +/*! + \brief needs to be called at the end of the game inorder to avoid memory leaks +*/ +void TelemetryShutDown() +{ + unsigned int counter = 0; + ListNode *listNode = _NULL; + + for(counter = 0; counter < g_netNodeTriggers.numNodes; ++counter) + { + CustomFree(systemNetNodes[counter].data); + CustomFree(systemNetNodes[counter].dataCopyBuf); + } + CustomFree(systemNetNodes); + + TelemXMLFreeTelemetryQueries(&g_telemQueries); + ListFree(&g_telemFields); + ListFree(&g_queryInfo); + CustomFree(telemetryData); + + listNode = g_netNodeTriggers.head; + while(listNode) + { + NetNodeTrigger *trigger = listNode->data; + + CustomFree(trigger); + listNode = listNode->next; + } + ListFree(&g_netNodeTriggers); + + telemArraySize = 0; +} + +/*! + \brief internal function. Gets newest value netByte data +*/ +void UpdateNetData(NetByteData *byteData) +{ + FILE *devFile = _NULL; + char buffer[1024]; + struct stat fileStat; + + devFile = fopen("/proc/net/dev", "r"); + if(!devFile) + { + DebugOutput("Unable to open net.dev file \n"); + return; + } + + //**safety checks** + if(lstat("/proc/net/dev", &fileStat) != 0) + { + DebugOutput("Error in net.dev file \n"); + return; + } + if(S_ISLNK(fileStat.st_mode)) + { + DebugOutput("Error in net.dev file \n"); + return; + } + //**end safety checks** + + //read past header + if( !fgets(buffer, sizeof(buffer), devFile) ) + { + DebugOutput("Telem: Error in net.dev header \n"); + return; + } + if( !fgets(buffer, sizeof(buffer), devFile) ) + { + DebugOutput("Telem: Error in net.dev heard \n"); + return; + } + //done reading past header + + if( (strstr(buffer, "compressed")) == _NULL ) + { + DebugOutput("Telem: Header format not supported for net.dev \n"); + return; + } + + while( fgets(buffer, sizeof(buffer), devFile) ) + { + if( (strstr(buffer, "ppp0") ) != _NULL || (strstr(buffer, "eth0") ) != _NULL ) + { + uns64 recieved, sent; + + char *delim = strchr(buffer, ':'); + if( *( delim + 1 ) == ' ' ) + { + sscanf( buffer, "%*s %lu %*Lu %*lu %*lu %*lu %*lu %*lu %*lu %lu %*Lu %*lu %*lu %*lu %*lu %*lu %*lu", + &recieved, &sent ); + } + else + { + sscanf(delim+1, "%Lu %*lu %*lu %*lu %*lu %*lu %*lu %*lu %Lu", + &recieved, &sent ); + } + + if(strstr(buffer, "ppp0") != _NULL) + { + byteData->bytesSentPpp0 = sent; + byteData->bytesRecievedPpp0 = recieved; + } + else + { + byteData->bytesSentEth0 = sent; + byteData->bytesRecievedEth0 = recieved; + } + } + } + + fclose(devFile); +} + +void ElapsedTime(SysDate_Utils *out, SysDate_Utils *begin, SysDate_Utils *end) +{ + out->yday = end->yday - begin->yday; + out->hour = out->yday*24 + end->hour - begin->hour; + out->min = out->hour*60 + end->min - begin->min; + out->sec = out->min*60 + end->sec - begin->sec; +} + +int ValidateNetData(const NetByteData *dataCurr, const NetByteData *dataOld) +{ + if( dataCurr->bytesRecievedEth0 < dataOld->bytesRecievedEth0 || + dataCurr->bytesRecievedPpp0 < dataOld->bytesRecievedPpp0 || + dataCurr->bytesSentEth0 < dataOld->bytesSentEth0 || + dataCurr->bytesSentPpp0 < dataOld->bytesSentPpp0) + return 0; + + return 1; +} + +void NetDataDifference(NetByteData *dataOut, const NetByteData *dataNew, const NetByteData *dataOld) +{ + dataOut->bytesRecievedEth0 = dataNew->bytesRecievedEth0 - dataOld->bytesRecievedEth0; + dataOut->bytesRecievedPpp0 = dataNew->bytesRecievedPpp0 - dataOld->bytesRecievedPpp0; + dataOut->bytesSentEth0 = dataNew->bytesSentEth0 - dataOld->bytesSentEth0; + dataOut->bytesSentPpp0 = dataNew->bytesSentPpp0 - dataOld->bytesSentPpp0; +} + +/*! + \brief samples byte data if the interval specified in xml file has gone by since last sample + \return 1 if a sample was take, 0 otherwise +*/ +int TelemetryUpdateNetTimers() +{ + unsigned int counter = 0; + SysDate_Utils currTime, elapsedTime; + + return; + + if(!netDataInitialized || !g_netNodeTriggers.head) + return 0; + + SysDateTime_Utils(&currTime, 0); + ElapsedTime(&elapsedTime, &lastNetTime, &currTime); + + SysDateTime_Utils(&lastNetTime, 0); + + UpdateNetData(&currNetData); + + if(!g_collected) + { + g_prevData = currNetData; + g_collected = 1; + } + + if(elapsedTime.hour < g_netCollectionInterval) + { + NetByteData diffNode; + int validated = 0; + + validated = ValidateNetData(&currNetData, &g_prevData); + if(validated) + { + NetDataDifference(&diffNode, &currNetData, &g_prevData); + + // update data for current interval + for(counter = 0; counter < g_netNodeTriggers.numNodes; ++counter) + { + SystemNetNode *netNode = &systemNetNodes[counter]; + if(netNode->dataCount == netNode->dataSize) + netNode->data[0] = diffNode; //set data + else + netNode->data[ netNode->dataSize - 1 - netNode->dataCount ] = diffNode; + } + } + + return 0; + } + + if(g_collected) + { + NetByteData diffNode; + int validated = 0; + + validated = ValidateNetData(&currNetData, &g_prevData); + if(validated) + { + NetDataDifference(&diffNode, &currNetData, &g_prevData); + g_prevData = currNetData; + } + else + { + g_prevData = currNetData; + return 0; + } + + // interval has passed, slide data intervals down one + for(counter = 0; counter < g_netNodeTriggers.numNodes; ++counter) + { + SystemNetNode *netNode = &systemNetNodes[counter]; + + if(netNode->dataCount == netNode->dataSize) + { + memcpy(netNode->dataCopyBuf, netNode->data, sizeof(NetByteData)*(netNode->dataSize-1)); + memcpy(netNode->data+1, netNode->dataCopyBuf, sizeof(NetByteData)*(netNode->dataSize-1)); + + netNode->data[0] = diffNode; + } + else + { + if( ValidateNetData(&currNetData, &g_prevData) ) + netNode->data[ netNode->dataSize - 1 - netNode->dataCount++ ] = diffNode; + } + + netNode->recordTime = currTime; + }//for + }//if g_collected + + return 1; +} + +/*! + \brief internal function called when bad net data is found +*/ +void TelemetryResetNetData() +{ + ListNode *currNode = _NULL; + unsigned int counter = 0; + + currNode = g_netNodeTriggers.head; + + //allocate arrays for holding byte data + for(counter = 0; counter < g_netNodeTriggers.numNodes; ++counter, currNode = currNode->next) + { + unsigned int size = 0; + + systemNetNodes[counter].dataSize = size; + systemNetNodes[counter].dataCount = 0; + memset(systemNetNodes[counter].data, 0, systemNetNodes[counter].dataSize*sizeof(NetByteData)); + memset(systemNetNodes[counter].dataCopyBuf, 0, (systemNetNodes[counter].dataSize-1)*sizeof(NetByteData)); + } +} + +/*! + \brief get the number of bytes transfered recorded in a timer + \param timerIndex index of the timer. Indices correspond to how the timers are laid out in the xml file + \param outData a pointer to valid memory which will be filled in with data + \return 0 if fail, 1 on success +*/ +int TelemetryGetNetData(int timerIndex, NetByteData *outData) +{ + SystemNetNode *netNode = &systemNetNodes[timerIndex]; + int counter = 0; + + if(netNode->dataCount == 0 || netNode->dataSize <= 0) + { + prts_debug("Telem: Unable to get net data \n"); + return 0; + } + + memset(outData, 0, sizeof(NetByteData)); + for(counter = netNode->dataSize - 1; counter >= 0; --counter) + { + outData->bytesRecievedEth0 += netNode->data[counter].bytesRecievedEth0; + outData->bytesRecievedPpp0 += netNode->data[counter].bytesRecievedPpp0; + outData->bytesSentEth0 += netNode->data[counter].bytesSentEth0; + outData->bytesSentPpp0 += netNode->data[counter].bytesSentPpp0; + } + + return 1; +} + +/*! + \brief call to load data into timers. + \param data array of byte structs for all timers + \param dataCount number of valid samples in the array + \param dataSize total size of the array + \param numTimers number of timers to load + \param recordTime when these timers were last updated + \return 1 on success, 0 on fail +*/ +int TelemetryFillNetData(NetByteData *data, uns32 *dataCount, uns32 *dataSize, uns32 numTimers, time_t recordTime) +{ + int counter = 0; + uns32 counter2 = 0; + uns32 offset = 0; + time_t secDiff; + uns32 daysDiff; + uns32 intervalDiff; + + time(&secDiff); + secDiff -= recordTime; + daysDiff = secDiff/(60*60*24); + intervalDiff = (secDiff/3600*g_netCollectionInterval); + +#ifdef DEBUG + printf("Telem: IntervalDiff %d \n", intervalDiff); +#endif + + for(counter = 0; counter < g_netNodeTriggers.numNodes; ++counter) + { + SystemNetNode *netNode = &systemNetNodes[counter]; + + if(daysDiff > netNode->timeInterval) + { + #ifdef DEBUG + printf("telem: skipping net fill. daysDiff: %u timeInterval: %u \n", daysDiff, netNode->timeInterval); + #endif + + continue; + } + + if(dataSize[counter] != netNode->dataSize || dataCount[counter] > netNode->dataSize) + { + #ifdef DEBUG + printf("telem: invalid input for fill of net data \n"); + #endif + + return 0; + } + + #ifdef DEBUG + printf("filling. size: %u count: %u \n", dataSize[counter], dataCount[counter]); + printf("&&&&&&&&&&&&&&&&&&&&&&&&&& %d\n", dataSize[counter]); + #endif + for(counter2 = 0; counter2 < dataSize[counter]; ++counter2) + { + netNode->data[counter2] = data[offset + counter2]; + + #ifdef DEBUG + printf("%lu ", data[offset + counter2]); + #endif + } + #ifdef DEBUG + printf("\n"); + #endif + + //fill in the missing hours with 0 + netNode->dataCount = dataCount[counter]; + for(counter2 = 0; counter2 < intervalDiff && counter2 + dataCount[counter] < netNode->dataSize; ++counter2) + { + memset(&netNode->data[netNode->dataSize - 1 - dataCount[counter] - counter2], 0, sizeof(NetByteData));//data[offset + dataSize[counter] - dataCount[counter]]; + netNode->dataCount++; + } + + //sanity check + if(netNode->dataCount > netNode->dataSize) + netNode->dataCount = netNode->dataSize; + + offset += dataSize[counter]; + } + + return 1; +} + +int TelemetryGetNumNetTimers() +{ + return g_netNodeTriggers.numNodes; +} + +int TelemetryGetNextNetUpdate() +{ + SysDate_Utils currTime, elapsedTime; + + if(!netDataInitialized) + return 0; + + SysDateTime_Utils(&currTime, 0); + ElapsedTime(&elapsedTime, &lastNetTime, &currTime); + + return g_netCollectionInterval*60 - elapsedTime.min; +} + +/*! + \brief returns interval of collection (1 day, 1 week, 1 month...) + \timer index for the timer + \return number of days +*/ +int TelemetryGetNetInterval(int timer) +{ + SystemNetNode *netNode = _NULL; + + if(timer >= g_netNodeTriggers.numNodes) + { + DebugOutput("Telem: invalid index to net interval \n"); + return 0; + } + + netNode = &systemNetNodes[timer]; + + return netNode->timeInterval; +} + +#endif + +//EOF + + + + diff --git a/libraries/pmrt/telemetry/telemetry_pc.c b/libraries/pmrt/telemetry/telemetry_pc.c new file mode 100755 index 0000000..86cf14d --- /dev/null +++ b/libraries/pmrt/telemetry/telemetry_pc.c @@ -0,0 +1,194 @@ +#ifdef SYS_PC +// telemetry.c +// Play Mechanix - Video Game System +// Copyright (c) 2007 Play Mechanix Inc. All Rights Reserved +// +// RA July 07 + +#include "telemetry.h" +#include +#include +#include +#include +#include + +// #include +#include +#include + +List g_telemQueries; +List g_telemFields; +List g_queryInfo; +QueryData *telemetryData; +SystemNetNode *systemNetNodes; +NetByteData currNetData; +static SysDate_Utils lastNetTime; +static unsigned int telemArraySize; +static int telemInitialized; +static int netDataInitialized; +static int g_netCollectionInterval; +static List g_netNodeTriggers; //list + +typedef struct _QueryInfo +{ + char *filePath; + char *name; + char *format; + char *postFix; + int id; +}QueryInfo; + +float TelemetryGetData(const char *path) +{ + FILE *file = _NULL; + float value = -1.f; + + file = fopen(path, "r"); + if(!file) + return -1.f; + + if(fscanf(file, "%f", &value) == EOF) + return -1.f; + + fclose(file); + + return value; +} + +void TelemetrySetupQueries() +{ + unsigned int counter = 0; + ListNode *fieldNode = g_telemFields.head; + + telemArraySize = g_telemFields.numNodes; + telemetryData = (QueryData*)CustomMalloc(sizeof(QueryData)*telemArraySize); + + for(counter = 0; counter < g_telemFields.numNodes; ++counter, fieldNode = fieldNode->next) + { + char *queryName = fieldNode->data; + List *queryList = _NULL; + TelemetryQueryNode *idNode = _NULL; + TelemetryQueryNode *fileNode = _NULL; + QueryInfo newInfo; + + queryList = TelemXMLFindQuery(&g_telemQueries, "name", queryName); + if(!queryList) + continue; + + idNode = TelemXMLFindQueryNode("id", queryList); + fileNode = TelemXMLFindQueryNode("file", queryList); + if(!(idNode && fileNode)) + continue; + + newInfo.filePath = fileNode->value; + newInfo.id = atoi(idNode->value); + newInfo.name = queryName; + + ListPushBack(&g_queryInfo, &newInfo, sizeof(QueryInfo)); + } +} + +int TelemetryInitialize(const char *telemLookUpTable, const char *telemFields, int lutSize, int fieldSize) +{ + + telemInitialized = 0; + + if(TelemXMLInitializeFromXML(telemLookUpTable, lutSize, telemFields, fieldSize, &g_telemQueries, + &g_telemFields, &g_netNodeTriggers, &g_netCollectionInterval) == TELEMETRY_SUCCESS) + telemInitialized = 1; + else + { + DebugOutput("Telemetry failed to initialize \n"); + return 0; + } + + //grab IDs from database + TelemetrySetupQueries(); + + telemInitialized = 1; + + return telemInitialized; +} + +/*! + \brief updates telemetry data and returns the amount of elements updated +*/ +unsigned int TelemetryCollectData() +{ + unsigned int counter = 0; + unsigned int read = 0; + ListNode *queryNode = _NULL; + + if(!telemInitialized) + return 0; + + queryNode = g_queryInfo.head; + for(counter = 0; counter < g_queryInfo.numNodes; ++counter) + { + QueryInfo *queryInfo = queryNode->data; + float value = TelemetryGetData(queryInfo->filePath); + + //sanity if check + if(counter < telemArraySize) + { + telemetryData[counter].dataId = queryInfo->id; + telemetryData[counter].data = value; + telemetryData[counter].name = queryInfo->name; + ++read; + } + + queryNode = queryNode->next; + } + + return read; +} + +/*! + \brief needs to be called at the end of the game inorder to avoid memory leaks +*/ +void TelemetryShutDown() +{ + TelemXMLFreeTelemetryQueries(&g_telemQueries); + ListFree(&g_telemFields); + ListFree(&g_queryInfo); + CustomFree(telemetryData); + + telemArraySize = 0; +} + +int TelemetryUpdateNetTimers() +{ + return 0; +} + +int TelemetryGetNumNetTimers() +{ + return 0; +} + +int TelemetryGetNetData(int timerIndex, NetByteData *outData) +{ + return 0; +} + +int TelemetryFillNetData(NetByteData *data, uns32 *dataCount, uns32 *dataSize, uns32 numTimers, time_t recordTime) +{ + return 1; +} + +int TelemetryGetNextNetUpdate() +{ + return 0; +} + +int TelemetryGetNetInterval(int timer) +{ + return 0; +} + +#endif + + + + + diff --git a/libraries/pmrt/telemetry/vssver.scc b/libraries/pmrt/telemetry/vssver.scc new file mode 100755 index 0000000..aaa11b8 Binary files /dev/null and b/libraries/pmrt/telemetry/vssver.scc differ diff --git a/libraries/pmrt/xmlWrapper/Debug/vc60.idb b/libraries/pmrt/xmlWrapper/Debug/vc60.idb new file mode 100755 index 0000000..a39c6e1 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/Debug/vc60.idb differ diff --git a/libraries/pmrt/xmlWrapper/Debug/vc60.pdb b/libraries/pmrt/xmlWrapper/Debug/vc60.pdb new file mode 100755 index 0000000..bfce5d1 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/Debug/vc60.pdb differ diff --git a/libraries/pmrt/xmlWrapper/Debug/xml.lib b/libraries/pmrt/xmlWrapper/Debug/xml.lib new file mode 100755 index 0000000..c9d276f Binary files /dev/null and b/libraries/pmrt/xmlWrapper/Debug/xml.lib differ diff --git a/libraries/pmrt/xmlWrapper/Debug/xml.pch b/libraries/pmrt/xmlWrapper/Debug/xml.pch new file mode 100755 index 0000000..cbd9f67 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/Debug/xml.pch differ diff --git a/libraries/pmrt/xmlWrapper/Debug/xmlWrapper.obj b/libraries/pmrt/xmlWrapper/Debug/xmlWrapper.obj new file mode 100755 index 0000000..70e0d88 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/Debug/xmlWrapper.obj differ diff --git a/libraries/pmrt/xmlWrapper/Debug/xmlWrapper.sbr b/libraries/pmrt/xmlWrapper/Debug/xmlWrapper.sbr new file mode 100755 index 0000000..162b1d2 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/Debug/xmlWrapper.sbr differ diff --git a/libraries/pmrt/xmlWrapper/libXmlWrapper.a b/libraries/pmrt/xmlWrapper/libXmlWrapper.a new file mode 100644 index 0000000..cd38069 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/libXmlWrapper.a differ diff --git a/libraries/pmrt/xmlWrapper/makedeplib b/libraries/pmrt/xmlWrapper/makedeplib new file mode 100644 index 0000000..9e7271f --- /dev/null +++ b/libraries/pmrt/xmlWrapper/makedeplib @@ -0,0 +1,30 @@ +xmlWrapper.o: xmlWrapper.c xmlWrapper.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /g3/include/libxml/xmlmemory.h /g3/include/libxml/xmlversion.h \ + /g3/include/libxml/xmlexports.h /g3/include/libxml/threads.h \ + /g3/include/libxml/globals.h /g3/include/libxml/parser.h \ + /g3/include/libxml/tree.h /g3/include/libxml/xmlstring.h \ + /g3/include/libxml/xmlregexp.h /g3/include/libxml/dict.h \ + /g3/include/libxml/hash.h /g3/include/libxml/valid.h \ + /g3/include/libxml/xmlerror.h /g3/include/libxml/list.h \ + /g3/include/libxml/xmlautomata.h /g3/include/libxml/entities.h \ + /g3/include/libxml/encoding.h /usr/include/iconv.h \ + /g3/include/libxml/xmlIO.h /g3/include/libxml/SAX.h \ + /g3/include/libxml/xlink.h /g3/include/libxml/SAX2.h \ + /g3/include/libxml/xmlreader.h /g3/include/libxml/relaxng.h \ + /g3/include/pmrt_utils/containers.h \ + /g3/include/pmrt_utils/containerCommon.h diff --git a/libraries/pmrt/xmlWrapper/makefile b/libraries/pmrt/xmlWrapper/makefile new file mode 100755 index 0000000..ddef634 --- /dev/null +++ b/libraries/pmrt/xmlWrapper/makefile @@ -0,0 +1,38 @@ +# make driver +# make install (as root) +# +.CLIBFILES = xmlWrapper.c + +.OLIBFILES = $(.CLIBFILES:.c=.o) + +TARGETLIB = libXmlWrapper.a + +DEPENDTESTFILE = makedeptest +DEPENDLIBFILE = makedeplib + +#CFLAGS = -Wall -O0 -ggdb -DSYS_BB -DDEBUG +CFLAGS = -Wall -O0 -g -DSYS_BB -DPRODUCTION +CFLAGS += -I /g3/include +LINKFLAGS = -Xlinker -Map -Xlinker $(TARGET).map +LIBS = /usr/lib/libxml2.a /g3/lib/libz.a /g3/lib/libpmrt_utils.a + +all: $(TARGETLIB) + +$(TARGETLIB) : $(.OLIBFILES) $(DEPENDLIBFILE) makefile + ar rs $(TARGETLIB) $(.OLIBFILES) $(LIBS) + -mkdir /g3/include/xmlWrapper + -cp $(TARGETLIB) /g3/lib + -cp *.h /g3/include/xmlWrapper + +clean: + -rm $(.OTESTFILES) $(DEPENDTESTFILE) $(TARGETTEST) + -rm $(.OLIBFILES) $(DEPENDLIBFILE) $(TARGETLIB) + +depend: + -$(CC) $(CFLAGS) -M $(.CTESTFILES) > $(DEPENDTESTFILE) + -$(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +$(DEPENDLIBFILE): + $(CC) $(CFLAGS) -M $(.CLIBFILES) > $(DEPENDLIBFILE) + +include $(DEPENDLIBFILE) diff --git a/libraries/pmrt/xmlWrapper/mssccprj.scc b/libraries/pmrt/xmlWrapper/mssccprj.scc new file mode 100755 index 0000000..f18a641 --- /dev/null +++ b/libraries/pmrt/xmlWrapper/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[xml.dsp] +SCC_Aux_Path = "\\Vss-nas-1\bbh3\" +SCC_Project_Name = "$/libraries/pmrt/xmlWrapper", NPQAAAAA diff --git a/libraries/pmrt/xmlWrapper/vssver.scc b/libraries/pmrt/xmlWrapper/vssver.scc new file mode 100755 index 0000000..1fc94a9 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/vssver.scc differ diff --git a/libraries/pmrt/xmlWrapper/xml.dsp b/libraries/pmrt/xmlWrapper/xml.dsp new file mode 100755 index 0000000..01ffa72 --- /dev/null +++ b/libraries/pmrt/xmlWrapper/xml.dsp @@ -0,0 +1,104 @@ +# Microsoft Developer Studio Project File - Name="xml" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=xml - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "xml.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "xml.mak" CFG="xml - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "xml - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "xml - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/libraries/pmrt/xmlWrapper", NPQAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "xml - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "xml - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\g3\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=mkdir c:\g3\include\xmlWrapper copy *.h c:\g3\include\xmlWrapper\ copy debug\xml.lib c:\g3\lib\ +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "xml - Win32 Release" +# Name "xml - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\xmlWrapper.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\xmlWrapper.h +# End Source File +# End Group +# End Target +# End Project diff --git a/libraries/pmrt/xmlWrapper/xml.dsw b/libraries/pmrt/xmlWrapper/xml.dsw new file mode 100755 index 0000000..b9504ea --- /dev/null +++ b/libraries/pmrt/xmlWrapper/xml.dsw @@ -0,0 +1,49 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "driver"=.\driver\driver.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "xml"=.\xml.dsp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/xmlWrapper", NPQAAAAA + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ + begin source code control + "$/libraries/pmrt/xmlWrapper", NPQAAAAA + . + end source code control +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/pmrt/xmlWrapper/xml.plg b/libraries/pmrt/xmlWrapper/xml.plg new file mode 100755 index 0000000..ead9fbd --- /dev/null +++ b/libraries/pmrt/xmlWrapper/xml.plg @@ -0,0 +1,16 @@ + + +
+

Build Log

+

+--------------------Configuration: xml - Win32 Debug-------------------- +

+

Command Lines

+ + + +

Results

+xml.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/libraries/pmrt/xmlWrapper/xmlWrapper.c b/libraries/pmrt/xmlWrapper/xmlWrapper.c new file mode 100755 index 0000000..de60be3 --- /dev/null +++ b/libraries/pmrt/xmlWrapper/xmlWrapper.c @@ -0,0 +1,748 @@ +// obj_gl.c +// Play Mechanix - Video Game System +// Copyright (c) 2006-2007 Play Mechanix Inc. All Rights Reserved +// +// RA June 07 + +//NOTE: Use the set of XmlFile functions for easy reading of xml files. +// XmlBuildFileTree will read in the file and create a tree out of all the nodes. You can then use +// XmlFileTreeGetNodes and XmlFileTreeGetElements to read out individual pieces. Refer to documentation +// of those functions for examples and further description. +// Otherwise you can use XmlCreateParser and provide it callbacks which you +// will have to implement yourself for custom reading. + +#include "xmlWrapper.h" +#include +#include + +//************XmlTextNode************ +/*! \brief This function builds a list of XmlTextNode + + \param head address of head of the list + \param string string needed to be added + +*/ +void XmlTextNodePushBack(XmlTextNode **head, xmlChar *string) +{ + XmlTextNode *newNode = (XmlTextNode*)(CustomMalloc(sizeof(XmlTextNode))); + if(!newNode) + return; + + newNode->next = NULL; + newNode->string = string; + if(!*head) + (*head) = newNode; + else + { + newNode->next = *head; + *head = newNode; + } +} + +/*! \brief Frees a list of XmlTextNodes + + \param head head of the list +*/ +void XmlFreeTextNodes(XmlTextNode *head) +{ + while(head) + { + XmlTextNode *delNode = head; + head = head->next; + CustomFree(delNode); + } +} +//**********End XmlTextNode********** + + +//*************XmlDataList************ +/*! \brief Add onto a list of XmlDataList + + \param list pointer to the list + \param string the text of the node + \param type what kind of node it is. Will be an enum of type xmlReaderTypes found in xmlreader.h +*/ +void XmlDataPushBack(XmlDataList *list, xmlChar *string, int type) +{ + XmlDataList *newNode = NULL; + newNode = (XmlDataList*)(CustomMalloc(sizeof(XmlDataList))); + if(!newNode) + return; + newNode->next = newNode->prev = NULL; + newNode->text = string; + newNode->type = type; + + if(!list->root) + list->root = list->tail = newNode; + else + { + newNode->prev = list->tail; + list->tail->next = newNode; + list->tail = newNode; + } +} +//***********End XmlDataList********** + +/*! \brief Processes a single xml node. Will figure out the type of node it is and call the associated callback + function if one is attached. + + \param list pointer to the list + \param string the text of the node + \param type what kind of node it is. Will be an enum of type xmlReaderTypes found in xmlreader.h +*/ +static void ProcessNode(XmlParser *parser) +{ + xmlChar *name; + int attribCount = 0; + int type = 0; + + name = xmlTextReaderName(parser->file); + if (name == NULL) + { + name = xmlStrdup(BAD_CAST "--"); + return; + } + + type = xmlTextReaderNodeType(parser->file); + + if(type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE) + return; + + //add to list + if(type != XML_READER_TYPE_TEXT) + XmlDataPushBack(&parser->parsedData, name, type); + + //get value and call callback function if there is one + else if(xmlTextReaderIsEmptyElement(parser->file) == 0) + { + //get value and put it into list + xmlChar *value = xmlTextReaderValue(parser->file); + XmlDataPushBack(&parser->parsedData, value, type); + + if(parser->HandleTextValue && type == XML_READER_TYPE_TEXT && parser->parsedData.root) + { + const xmlChar *elementName = XmlGetElementName(parser->parsedData.tail); + parser->HandleTextValue(elementName, value, parser); + } + } + + //if this is an end element, call the callback + if(type == XML_READER_TYPE_END_ELEMENT && parser->HandleEndElement) + parser->HandleEndElement(name, parser); + else if(type == XML_READER_TYPE_ELEMENT && parser->HandleBeginElement) + parser->HandleBeginElement(name, parser); + + //get number of attributes and call attribute callback + attribCount = xmlTextReaderAttributeCount(parser->file); + if(attribCount) + { + if(parser->HandleAttributes) + parser->HandleAttributes(name, attribCount, parser); + } +} + +/*! \brief Loop to parse an xml file + + \param list pointer to a valid parser +*/ +void XmlParseFile(XmlParser *parser) +{ + int ret = 0; + ret = xmlTextReaderRead(parser->file); + while (ret == 1) + { + ProcessNode(parser); + ret = xmlTextReaderRead(parser->file); + } + xmlFreeTextReader(parser->file); +} + +/*! \brief Opens an xml file and creates a parser. If a certain callback function isn't wanted, pass in 0. + + \param parser pointer to a valid parser struct + \param fileName name of the xml file to parse + \param HandleAttributes pointer to a user callback function which will be called when an attribute is found + \param HandlTextValue pointer to a user callback function which will be called when text is found + \param HandleEndElement pointer to a user callback function which will be called when an end element is found + \param HandleBeginElement pointer to a user callback function which will be called when a begin element is found + + \return 1 if success, 0 if failed. Fails if xml file can't be opened +*/ +int XmlCreateParser(XmlParser *parser, const char *fileName, void *HandleAttributes, void *HandleTextValue, + void *HandleEndElement, void *HandleBeginElement) +{ + parser->file = xmlNewTextReaderFilename(fileName); + parser->HandleAttributes = HandleAttributes; + parser->HandleTextValue = HandleTextValue; + parser->HandleEndElement = HandleEndElement; + parser->HandleBeginElement = HandleBeginElement; + parser->parsedData.next = NULL; + parser->parsedData.prev = NULL; + parser->parsedData.root = NULL; + parser->parsedData.tail = NULL; + + return (parser->file) ? 1 : 0; +} + +/*! \brief Reads from a buffer in memory to create a parser. If a certain callback function isn't wanted, pass in 0. + + \param parser pointer to a valid parser struct + \param buffer pointer to a buffer containing xml + \param size length of the buffer in bytes + \param HandleAttributes pointer to a user callback function which will be called when an attribute is found + \param HandlTextValue pointer to a user callback function which will be called when text is found + \param HandleEndElement pointer to a user callback function which will be called when an end element is found + \param HandleBeginElement pointer to a user callback function which will be called when a begin element is found + + \return 1 if success, 0 if failed. Fails if xml file can't be opened +*/ +int XmlCreateParserFromMem(XmlParser *parser, const char *buffer, int size, + void *HandleAttributes, void *HandleTextValue, void *HandleEndElement, + void *HandleBeginElement) +{ + parser->file = xmlReaderForMemory(buffer, size, NULL, NULL, 0); + parser->HandleAttributes = HandleAttributes; + parser->HandleTextValue = HandleTextValue; + parser->HandleEndElement = HandleEndElement; + parser->HandleBeginElement = HandleBeginElement; + parser->parsedData.next = NULL; + parser->parsedData.prev = NULL; + parser->parsedData.root = NULL; + parser->parsedData.tail = NULL; + + return (parser->file) ? 1 : 0; +} + +/* + \brief Frees memory allocated by parser + + \param parser pointer to a valid parser +*/ +void XmlFreeParser(XmlParser *parser) +{ + //free linked list + while(parser->parsedData.root) + { + XmlDataList *del = parser->parsedData.root; + xmlFree(parser->parsedData.root->text); + parser->parsedData.root = parser->parsedData.root->next; + CustomFree(del); + } + //xmlTextReaderClose(parser->file); +} + +/* + \brief get the number of attributes associated with tag assuming file reader is at a node with attribs + + \param file an open xml file pointer + \return number of attributes +*/ +int XmlGetNumAttributes(XmlFile file) +{ + return xmlTextReaderAttributeCount(file); +} + +/* + \brief get the attribute associated with tag assuming file reader is at a node with attribs + Note: User is expected to free the strings returned + + \param file an open xml file pointer + \param index index of the attribute + \param outAttribName name of the attribte, set to 0 if not needed + \return value of the attribute +*/ +xmlChar *XmlGetAttributeByIndex(XmlFile file, int index, xmlChar **outAttribName) +{ + if(outAttribName) + { + xmlTextReaderMoveToAttributeNo(file, index); + *outAttribName = xmlTextReaderLocalName(file); + + return xmlTextReaderValue(file); + } + else + return xmlTextReaderGetAttributeNo(file, index); +} + +/* + \brief get the attribute associated with tag assuming file reader is at a node with attribs + Note: User is expected to free the string returned + + \param file an open xml file pointer + \param name name of attribute + \return value of the attribute +*/ +xmlChar *XmlGetAttributeByName(XmlFile file, const char *name) +{ + return xmlTextReaderGetAttribute(file, name); +} + +/* + \brief deprecated, don't use. +*/ +const xmlChar *XmlGetElementValue(XmlParser *parser, const xmlChar *elementName) +{ + int elementFound = 0; + XmlDataList *node = parser->parsedData.root; + if(!node) + return NULL; + + while(node) + { + //another element started without the other ending + if(node->type == XML_READER_TYPE_ELEMENT && elementFound) + return NULL; + + //found element + if(node->type == XML_READER_TYPE_ELEMENT && node->text) + { + if(strcmp(elementName, node->text) == 0) + elementFound = 1; + } + + //found value associated with element + else if(node->type == XML_READER_TYPE_TEXT && node->text && elementFound) + return node->text; + + //element ended + else if(node->type == XML_READER_TYPE_END_ELEMENT && elementFound) + return NULL; + + node = node->next; + } + + return NULL; +} + +/* + \brief gets the name of the element to which this node belongs + example: + Warrior + XmlGetElementName( warriorNode) --returns-> "job" + + \param the current node in the XmlParser, should be the tail pointer in the parser + \return value of the attribute +*/ +const xmlChar *XmlGetElementName(XmlDataList *currNode) +{ + while(currNode) + { + if(currNode->type == XML_READER_TYPE_ELEMENT) + return currNode->text; + + //if the end of an element was found, it means the head element wasn't found + //:xml file has invalid syntax + else if(currNode->type == XML_READER_TYPE_END_ELEMENT) + return NULL; + currNode = currNode->prev; + } + + return NULL; +} + +/* +\brief search for the string value of tags within an element going forward or backwards, + -return the number of matching strings found + example: + + PlayMechanix + The boy jumped + over the fence + + + search for author within the book element + we will search forward, so the current node should be before + XmlTextNode foundList; + XmlGetStringInElementBlock( currNode, "sentence", "book", &foundList, XML_SEARCH_FORWARD ); + + \param currNode the current node in the XmlParser, should be the tail pointer in the parser + \param tagName name of the tag for which values are wanted + \param elementName name of the element to search within + \param head pointer to the head of a list of text nodes, this will be filled in and retured + \param direction search backwards or forward. +*/ +int XmlGetStringsInElementBlock(XmlDataList *currNode, const xmlChar *tagName, const xmlChar *elementName, + XmlTextNode **head, XmlEnum direction) +{ + XmlDataList *node = currNode; + int count = 0; + + if(direction == XML_SEARCH_BACKWARDS) + { + while(node) + { + if(node->type == XML_READER_TYPE_TEXT) + { + //if the tag name for this element is the one being searched for, + //store the text value of the node + const xmlChar *nodeElementName = XmlGetElementName(node); + if(nodeElementName && strcmp(tagName, nodeElementName) == 0) + { + XmlTextNodePushBack(head, node->text); + ++count; + } + } + + //if this is the start tag of the element being searched within, the tag being searched + //for was not found + if(node->type == XML_READER_TYPE_ELEMENT && strcmp(node->text, elementName) == 0) + return count; + + node = node->prev; + } + } + else + { + while(node) + { + if(node->type == XML_READER_TYPE_TEXT) + { + //if the tag name for this element is the one being searched for, + //store the text value of the node + const xmlChar *nodeElementName = XmlGetElementName(node); + if(nodeElementName && strcmp(tagName, nodeElementName) == 0) + { + XmlTextNodePushBack(head, node->text); + ++count; + } + } + + //if this is the end tag of the element being searched within, the tag being searched + //for was not found + if(node->type == XML_READER_TYPE_END_ELEMENT && strcmp(node->text, elementName) == 0) + return count; + + node = node->next; + } + } + + return count; +} + +/* + \brief Frees memory allocated when an xml function returns a pointer to a string. Only call this + if an Xml function is documented specifies the user to free memory of an xml string +*/ +void XmlFreeString(xmlChar *s) +{ + xmlFree(s); +} + +//************************************************************* +//*******************List Building Funcs*********************** +//************************************************************* +static Tree *g_tree; +static XmlFileTree *g_fileTree; +static void XmlHandleAttributes(const xmlChar *inName, int inCount, XmlParser *inParser) +{ + + XmlElement *currElement = NULL; + int i = 0; + + //create the attribute list for this element + currElement = (XmlElement*)(g_tree->currNode->data); + ListCreate( &currElement->attribs ); + + for(i = 0; i < inCount; ++i) + { + ListNode *newNode = NULL; + xmlChar *attribName = NULL; + xmlChar *value; + XmlAttrib *attrib; + + value = XmlGetAttributeByIndex(inParser->file, i, &attribName); + + attrib = CustomMalloc(sizeof(XmlAttrib)); + attrib->index = i; + CopyStrings((char**)&attrib->name, (char*)attribName); + CopyStrings((char**)&attrib->value, (char*)value); + + newNode = ListPushBack(&currElement->attribs, attrib, 0); + ListPushBack(&g_fileTree->delAttribs, newNode, 0); //save pointer to node to delete at end + + XmlFreeString(value); + XmlFreeString(attribName); + } +} +static void XmlHandleBeginElement(const xmlChar *inName, XmlParser *inParser) +{ + TreeNode *node; + XmlElement element, *pElement; + size_t elemSize; + size_t nameLength; + element.type = XML_READER_TYPE_ELEMENT; + element.value = NULL; + nameLength = strlen(inName); + if(!inName) + return; + + //~allocate a block of data so it can automatically be deleted by the tree when it is destroyed + elemSize = sizeof(XmlElement) + (nameLength+1)*sizeof(char); + node = TreeAddNode(g_tree, &element, elemSize, TREE_ADD_NODE_AND_GO_DOWN); + + //assign pointers and copy name + pElement = node->data; + pElement->name = ( ((char*)pElement) + sizeof(XmlElement) ); + memcpy(pElement->name, inName, sizeof(char)*nameLength); + pElement->name[nameLength] = 0; +} +static void XmlHandleTextValue(const xmlChar *inName, xmlChar *inValue, XmlParser *inParser) +{ + TreeNode *node; + XmlElement element, *pElement; + size_t valueLength; + size_t nameLength; + size_t elemSize; + + valueLength = strlen(inValue); + if(!valueLength) + return; + + nameLength = strlen(inName); + if(!inName) + return; + + element.name = NULL; + element.type = XML_READER_TYPE_TEXT; + + //~allocate a block of data so it can automatically be deleted by the tree when it is destroyed + elemSize = sizeof(XmlElement) + (valueLength+1)*sizeof(char) + (nameLength+1)*sizeof(char); + node = TreeAddNode(g_tree, &element, elemSize, TREE_ADD_NODE); + + //assign pointers and copy name + pElement = node->data; + pElement->value = ( ((char*)pElement) + sizeof(XmlElement) ); + pElement->name = pElement->value + sizeof(char)*(valueLength+1); + memcpy(pElement->value, inValue, sizeof(char)*(valueLength+1)); + memcpy(pElement->name, inName, sizeof(char)*(nameLength+1)); +} +static void XmlHandleEndElement(const xmlChar *inName, XmlParser *inParser) +{ + TreeGoUp(g_tree); +} + +/*! + \brief Build a tree of the xml file. Use the tree functions to find elements and element data. + \param xmlFile name of the file + \param fileTree pointer to a valid tree structure which will be filled in + \return int 0 on fail, 1 on success +*/ +int XmlBuildFileTree(const char *xmlFile, XmlFileTree *fileTree) //parse file into a big list +{ + XmlParser parser; + g_tree = &fileTree->tree; + g_fileTree = fileTree; + + ListCreate(&fileTree->delAttribs); + TreeCreate(g_tree); + + if(!XmlCreateParser(&parser, xmlFile, XmlHandleAttributes, XmlHandleTextValue, XmlHandleEndElement, XmlHandleBeginElement)) + return 0; + + XmlParseFile(&parser); + + XmlFreeParser(&parser); + + return 1; +} + +/*! + \brief Build a tree of the xml file. Use the tree functions to find elements and element data. + \param buffer buffer in memory + \param bufSize size of the buffer in bytes + \param fileTree pointer to a valid tree structure which will be filled in + \return int 0 on fail, 1 on success +*/ +int XmlBuildFileTreeFromMem(const char *buffer, int bufSize, XmlFileTree *fileTree) +{ + XmlParser parser; + g_tree = &fileTree->tree; + g_fileTree = fileTree; + + ListCreate(&fileTree->delAttribs); + TreeCreate(g_tree); + + if(!XmlCreateParserFromMem(&parser, buffer, bufSize, XmlHandleAttributes, XmlHandleTextValue, XmlHandleEndElement, XmlHandleBeginElement)) + return 0; + + XmlParseFile(&parser); + + XmlFreeParser(&parser); + + return 1; +} + +void XmlFreeFileTree(XmlFileTree *fileTree) +{ + ListNode *node = NULL; + + TreeFree(&fileTree->tree); + + node = fileTree->delAttribs.head; + while(node) + { + ListNode *delNode = node->data; + XmlAttrib *attrib = delNode->data; + CustomFree(attrib->name); + CustomFree(attrib->value); + CustomFree(attrib); + CustomFree(delNode); + node = node->next; + } + ListFree(&fileTree->delAttribs); +} + +int XmlTreeFindElements(const TreeNode *node, const char *name, List *addList, int valuesOnly) +{ + XmlElement *elem = NULL; + ListNode *childNode = NULL; + if(!node || !node->data) + return 0; + + elem = node->data; + if(valuesOnly) + { + if(elem->type == XML_READER_TYPE_TEXT && strcmp(elem->name, name)==0) + ListPushBack(addList, elem, 0); + } + else if(strcmp(elem->name, name)==0) + ListPushBack(addList, elem, 0); + + childNode = node->childList.head; + while(childNode) + { + XmlTreeFindElements(childNode->data, name, addList, valuesOnly); + childNode = childNode->next; + } + + return addList->numNodes; +} + +int XmlTreeFindNode(const TreeNode *node, const char *name, List *addList) +{ + XmlElement *elem = NULL; + ListNode *childNode = NULL; + if(!node || !node->data) + return 0; + + elem = node->data; + if(strcmp(elem->name, name)==0) + ListPushBack(addList, (void*)node, 0); + + childNode = node->childList.head; + while(childNode) + { + XmlTreeFindNode(childNode->data, name, addList); + childNode = childNode->next; + } + + return addList->numNodes; +} + +/* + \brief Fills in addList with XmlElement nodes. tree and addList must be initialized before calling + the function + \param tree pointer to an initialized tree containing the XmlFileTree info, pass in xmlFileTree.head to search the whole tree + \param name name of the elements being searched + \param addList pointer to an initialized list which will be filled in with XmlElementNode(s) when done + \param valuesOnly if 1, only elements of type XML_READER_TYPE_TEXT are returned + \return number of elements found +*/ +int XmlFileTreeGetElements(const TreeNode *tree, const char *name, List *addList, int valuesOnly) +{ + if(!tree || !name) + return 0; + + if(tree->childList.head) + XmlTreeFindElements(tree, name, addList, valuesOnly); + + return addList->numNodes; +} + +/*! + \brief Get a single element from an XmlFileTree + \author RA + \date 2007/11/16 + \param treeHead starting point of search in the tree + \param name name of element being searched + \param outElement pointer to a valid XmlElement pointer which will point to valid data if the function succeeds + \return int 1 on success, 0 on fail +*/ +int XmlFileTreeGetElement(const TreeNode *treeHead, const char *name, XmlElement **outElement) +{ + List data; + int ec = 1; + XmlElement *elem = NULL; + + if(!treeHead || !name || !outElement) + return 0; + + ListCreate(&data); + + if(!XmlFileTreeGetElements(treeHead, name, &data, 1)) + goto fail; + + if(!data.head || !data.head->data) + goto fail; + + *outElement = (XmlElement*)data.head->data; + + goto done; +fail: + ec = 0; + *outElement = NULL; + +done: + ListFree(&data); + + return ec; +} + +/* + \brief Fills in addList with TreeNodes. tree and addList must be initialized before calling the function + Use this to get subtree(s) of elements and then use XmlFileTreeGetElements to find child elements + within this subtree + example: + + + Past Day + 1 + + + + Past Week + 1 + + + XmlFileTreeGetNodes(tree, "timer", &addList) //will give you the two 'timer' subtrees. + ListNode *node = addList->head; + while(node) + { + XmlElement *title, *interval; + XmlFileTreeGetElement(node->data, "title", &title); + XmlFileTreeGetElement(node->data, "interval", &interval); + + if(!title || !interval) + //error + node = node->next; + } + + \param tree pointer to an initialized tree containing the XmlFileTree info, pass in xmlFileTree.head to + search the whole tree + \param name name of the elements being searched + \param addList pointer to an initialized list which will be filled in with TreeNode(s) when done + \return number of elements found +*/ +int XmlFileTreeGetNodes(const TreeNode *tree, const char *name, List *addList) +{ + if(!tree || !name) + return 0; + + if(tree->childList.head) + XmlTreeFindNode(tree, name, addList); + + return addList->numNodes; +} + +//EOF + diff --git a/libraries/pmrt/xmlWrapper/xmlWrapper.h b/libraries/pmrt/xmlWrapper/xmlWrapper.h new file mode 100755 index 0000000..8f31743 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/xmlWrapper.h differ diff --git a/libraries/pmrt/xmlWrapper/xmlWrapper.o b/libraries/pmrt/xmlWrapper/xmlWrapper.o new file mode 100644 index 0000000..0f0aaf5 Binary files /dev/null and b/libraries/pmrt/xmlWrapper/xmlWrapper.o differ diff --git a/libraries/remove-libs-linux.sh b/libraries/remove-libs-linux.sh new file mode 100755 index 0000000..8945c6d --- /dev/null +++ b/libraries/remove-libs-linux.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +# quickie script to delete any files in /g3/lib and /g3/include +# useful for clearing out old files before doing a new build +# of libraries + + +echo Deleting contents of c:/g3/lib... +rm -rf /g3/lib/* + +echo Deleting contents of c:/g3/include... +rm -rf /g3/include/* + diff --git a/libraries/remove-libs-w32.bat b/libraries/remove-libs-w32.bat new file mode 100755 index 0000000..485e90e --- /dev/null +++ b/libraries/remove-libs-w32.bat @@ -0,0 +1,15 @@ +@ECHO off + +rem quickie script to delete any files in /g3/lib and /g3/include +rem useful for clearing out old files before doing a new build +rem of libraries + + +echo Deleting contents of c:/g3/lib... +\cygwin\bin\rm.exe -rf 'c:/g3/lib' +\cygwin\bin\mkdir 'c:/g3/lib' + +echo Deleting contents of c:/g3/include... +\cygwin\bin\rm.exe -rf 'c:/g3/include' +\cygwin\bin\mkdir 'c:/g3/include' + diff --git a/libraries/vssver.scc b/libraries/vssver.scc new file mode 100755 index 0000000..5d247c0 Binary files /dev/null and b/libraries/vssver.scc differ diff --git a/linux/.nvidia-settings-rc b/linux/.nvidia-settings-rc new file mode 100755 index 0000000..2d0c18d --- /dev/null +++ b/linux/.nvidia-settings-rc @@ -0,0 +1,47 @@ +# +# /usr/local/demo1/.nvidia-settings-rc +# +# Configuration file for nvidia-settings - the NVIDIA X Server Settings utility +# Generated on Tue May 3 20:27:30 2005 +# + +# ConfigProperties: + +ToolTips = Yes +DisplayStatusBar = Yes +SliderTextEntries = Yes +IncludeDisplayNameInConfigFile = No +ShowQuitDialog = Yes + +# Attributes: + +0/DigitalVibrance[CRT-0]=0 +0/SyncToVBlank=1 +0/LogAniso=0 +0/FSAA=1 +0/TextureSharpen=1 +0/ForceGenericCpu=0 +0/CursorShadow=0 +0/CursorShadowXOffset=4 +0/CursorShadowYOffset=2 +0/CursorShadowAlpha=64 +0/CursorShadowRed=0 +0/CursorShadowGreen=0 +0/CursorShadowBlue=0 +0/FSAAAppControlled=0 +0/LogAnisoAppControlled=1 +0/RedBrightness=0.000000 +0/GreenBrightness=0.000000 +0/BlueBrightness=0.000000 +0/RedContrast=0.000000 +0/GreenContrast=0.000000 +0/BlueContrast=0.000000 +0/RedGamma=1.000000 +0/GreenGamma=1.000000 +0/BlueGamma=1.000000 +0/XVideoOverlaySaturation=4096 +0/XVideoOverlayContrast=4096 +0/XVideoOverlayBrightness=0 +0/XVideoOverlayHue=0 +0/XVideoTextureSyncToVBlank=1 +0/XVideoBlitterSyncToVBlank=0 diff --git a/linux/README_kernel.txt b/linux/README_kernel.txt new file mode 100755 index 0000000..3450c43 --- /dev/null +++ b/linux/README_kernel.txt @@ -0,0 +1,154 @@ +kreb by this guide + +This is a detailed guide to compiling a new kernel version 2.6.10 under a fresh install of Slackware 10.1. + +I enjoyed DaOne's little guide and am grateful for his contribution. However, as the total noob I am, in my first kernel compiling experiences I still missed some points I believe some other noobs as me may miss to successfully compiling their new kernel. I am therefore releasing this first 'acid guide' hoping to help out someone, as I was helped by DaOne and various posts' around here. Please do feel free to leave comments on any suggestions / mistakes that you have found in this guide. Forums are all made of this, sharing. + +General note: I try and keep this Post #1 updated all the time so that there's no need to go through all the inevitable posts with such a topic. However, feel free to read on and give your own feedbacks. + +Now for the guide part. For the purpose of this guide, I'll use version 2.6.10 which at the moment of this writing is the latest kernel release. + +Note: even though strictly not necessary, if you are doing a fresh install of Slackware I recommend updating the kernel prior doing anything else, on the first boot after installing Slack (i.e. even before you get the X server configured and running). This is useful since many compiles do rely on the current version of kernel and may need to be reinstalled when upgrading it (for instance, NVIDIA drivers need to be reinstalled after a kernel upgrade). + +The following are my recommended points to follow. Definitely not exhaustive. One last thing: this worked for me. It doesn't mean that it will work for you. Upgrading a kernel may result in the total mess up of your system (this sound scary: it is however a normal operation done by most linux users; it is here to ensure you are aware of what you are doing). + +Before you begin, download the necessary files and save them to /etc/src: + +1. Get the kernel 2.6.10 sources +Slackware 10.1 comes with kernel 2.4.29. You therefore need to download the full sources of the new kernel. You can get them here: linux-2.6.10.tar.bz2 (35MB). This is the .bz2 file format, which is more compressed than the tar.gz one. + +2. Get a valid kernel 2.6.10 configuration file +At a certain point you will have to configure your kernel. You may start off with a fresh configuration, however I recommend getting a good starting point by downloading Patrick's excellent configuration file: config-2.6.10. + +Now let's start the operations. Let's move into the /usr/src directory (where you have put the two files here above) and decompress the kernel 2.6.10 source code: +code: # cd /usr/src +/usr/src# tar xjvf linux-2.6.10.tar.bz2 + +The Kernel 2.6.10 source code will now be found into the directory /usr/src/linux-2.6.10. + +Note: as per Linus Tovalds, there's a philosophy that if it doesn't have to be done as root it shouldn't be, in order to reduce error / hacking risks. You may consider compiling the kernel on your local home directory and then su to root to move the compiled files. However, I somewhat tend to believe that having a symbolic link /usr/src/linux to /usr/src/kernel-2.6.10 might be needed by some applications / installs that look for the kernel source, and therefore the fastest / easiest way to proceed is as described here below. If you didn't understand a single word of this, you may just as well ignore this note. + +Now, delete the symbolic link 'linux' that is under /usr/src and which points to the old kernel source directory and recreate it to point to the new directory: +code: /usr/src# rm linux +/usr/src# ln -s linux-2.6.10 linux + +Now the symbolic link 'linux' points to the new kernel source directory. + +Move into the directory linux: +code: /usr/src# cd linux + +Prepare the compiling by removing all eventual precedent files (which you shouldn't have since this is your first compiling, isn't it?) :) +code: /usr/src/linux# make mrproper + +Now let's start configuring the kernel. There are several tools around, I prefer menuconfig. Start it up: +code: /usr/src/linux# make menuconfig + +You may now start configuring from scratch, however as I already explained I believe that it is better to load Patrick's configuration file and build on it. In the configuration window, choose the option 'Load an alternate file', an type /usr/src/config-2.6.10 in the box, then click 'ok'. You have now loaded a proper startup configuration file. + +Here things can get tricky, since the options that you set here must build the kernel according to the system you are running linux on. Read all available help and be sure to have the correct settings. + +Personally, I setup these three additional things: + +1. I have an AMD64 processor, therefore under the processors section I select 'AMD64' and leave 'PC-compatible' as architecture. + +2. I use SATA disks, therefore I must ensure that these disks are understood by the kernel at boot time or it will not be able to read from it and I would experience a 'Kernel panic' error. To enable SATA support, under Device drivers->SCSI device support I ensure that I have 'SCSI disk' and 'SCSI generic' selected <*> and not loaded in modules [M]. Also, under SCSI Low Level Drivers, I make sure that 'Serial ATA' is <*>, and I ensure that my chipset support is also enabled here (I enabled NVIDIA chipset support since I have a NFORCE one). This is all done since at boot time modules are not loaded yet, therefore I can't have this support on modules (or, as explained, I wouldn't be able to boot). + +3. Also, since I've formatted my disks using ReiserFS, I also want to be sure that at boot time the Kernel is able to read from them. To do so, under File systems I enable Reiserfs support <*>. + +Thank you db391 for these clues. + +4. I have a PS2 mouse, therefore i ensure that under Device Drivers I select all the necessary PS2 and serial port support otherwise my mouse will not work. + +5. Finally, I enable ALSA support to allow for my sound card configuration and I ensure to select the driver for my card (SoundBlaster). You may consider in setting this as module instead of compiled into the kernel <*>. + +If you do believe that you need to make additional changes, do so. Otherwise, quit and, when prompted, save the file leaving the .config name as it is by default. You have now configured your kernel. + +Now, it's time to build the compressed kernel image using the command: +code: /usr/src/linux# make -j5 bzImage + +You'll have to wait some time here depending on your machine's speed. + +After a certain time it will finish, and you will have the kernel image into the directory /usr/src/linux/arch/i386/boot/ (do not browse there for now, stay into the /usr/src/linux directory). + +Now let's proceed with compiling and the install of the modules by issuing these 2 commands: +code: /usr/src/linux# make -j5 modules +/usr/src/linux# make modules_install + +This will take longer, and the modules will be installed into /lib/modules/**kernel version here**. + +We will now create a new boot entry for LILO, so that you can boot in your new kernel but keeping the old kernel still available. + +First, we need to put the freshly generated System.map, .config and the compiled kernel image bzImage into the /boot/ directory. + +To do so: +code: /usr/src/linux# mv System.map /boot/System.map-2.6.10 +/usr/src/linux# mv .config /boot/config-2.6.10 +/usr/src/linux# mv /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.6.10 + +Now we need to rename the old kernel image (why we do this will become clear when we recreate the virtual links): +code: /usr/src/linux# mv /boot/vmlinuz /boot/vmlinuz-old + +Now let's create the new LILO entry, modifying its config file (lilo.conf). Open this file in pico, a very simple text editor: +code: /usr/src/linux# pico /etc/lilo.conf + +Note on pico: as per XavierP post here below, pico is only installed if PINE is installed. If you selected a full install of Slack, you will have it. If not, you may try using 'nano' instead of 'pico', or use any text editor you may be familiar with. + +You will see at the end of the lilo.conf file the Windows entry of your boot option, and then the Linux one. Do not touch the Windows entry. We will modify the existing Linux entry and add a new one so that the last two entries of this file look like this: +code: # Slack NEW begins +image = /boot/vmlinuz-2.6.10 +root = /dev/sdb5 +label = Slack_2.6.10 +read-only +# Slack NEW ends +# Slack OLD begins +image = /boot/vmlinuz-old +root = /dev/sdb5 +label = Slack_OLD +read-only +# Slack OLD ends + +Important note: please do use the appropriate root disk instead of the example /dev/sdb5 which is the partition that I use in my system. + +Quit pico by pressing Ctrl-X and say yes to save the file, leave default name unchanged (lilo.conf). + +Now, let's activate these changes by running lilo: +code: /usr/src/linux# lilo + + +------------------ Optional Step ------------------ + +If you wish, you may remove the existing symbolic links to the old kernel files: +code: /usr/src/linux# cd /boot +/boot# rm System.map +/boot# rm config +/boot# rm vmlinuz + +We can now add the links to the new files: +code: /boot# ln -s System.map-2.6.10 System.map +/boot# ln -s config-2.6.10 config +/boot# ln -s vmlinuz-2.6.10 vmlinuz + +Now these symlinks will point directly to the new compiled files. + +-------------- End of Optional Step ------------- + + +We're almost done. Since kernel version 2.6.xx, the file modules.conf is now substituted by the file modprobe.conf, which you normally shouldn't have already, or if you do, it might just as well be empty. + +to see if you have it or if it is empty, type: +code: /boot# pico /etc/modprobe.conf + +and see if the file contains something. Exit pico, typing Ctrl-X. If the file doesn't contain anything, delete it: +code: /boot# rm /etc/modprobe.conf + +(If you receive an error it is simply because you didn't have the file in the first place). + +Now let's create a good file from the new kernel: +code: /boot# generate-modprobe.conf /etc/modprobe.conf + +Final step, ensure that you have a /sys directory. If you do not have, create one with +code: mkdir /sys + +You may now reboot, and at boot select the Slack_2.6.10 option from LILO. + +Enjoy. diff --git a/linux/README_linux.txt b/linux/README_linux.txt new file mode 100755 index 0000000..a840df5 --- /dev/null +++ b/linux/README_linux.txt @@ -0,0 +1,280 @@ +README_linux.txt + +This directory contains misc linux files. + +------------------------------------------------------------------------------- +updating the game + +UPDATE THE MAKEFILE + +- make sure all the files in the project are in the linux/makefile + +UPDATE / COPY FROM PC to LINUX + +- build all data on the PC +- use WinSCP3 (sftp program) to transfer & setup + as root, ifconfig to find IP address if needed + prefs: binary, set permissions RWX for all, clear archive, no filename change +- data + create bbh3data directory + copy + bbh3data/hd_pc + bbh3data/cf + bbh3data/snd +- audits/adjustments + copy bbh3user +- game source + create bbh3 + probably easiest to clean all build data from the PC + copy bbh3/core bbh3/corebb bbh3/coregl bbh3/game + delete the Debug subdirectories full of Window's object code +- sound system + copy jpsnd +- jamma + copy jamma +- prep + create lib + copy linux + copy these files from linux on the PC to the home dir + stg stw xinitgame xinitrc .nvidia-settings-rc + chmod +x stg stw + +BUILDING on LINUX + +- ls -la to make sure you have the dirs & permissions + for example: + drwxr-xr-x lib + drwxr-xr-x bbh3 + drwxrwxrwx bbh3user + drwxr-xr-x bbh3data + chmod -R +rwx bbh3/* +- cd jpsnd & make + should build and then copy libjps.a & jpsdefs.h to ~/lib +- cd jamma & make + should build all and copy libjamma.a & jamma.h to ~/lib +- cd linux + create tmp + make + should build all + make 2>&1 | less + +RUNNING + +- test it + cd; game + +- full screen + exit, stg + +alsaconf +alsamixer +alsactl store + +TESTING THE SOUND SYSTEM + +cd jpsnd +make jpst +jpst + +- make sure all playlists have only lowercase file names +- make sure all slashes in the playlist are '/'!!! +- when copying, force all filenames to lowercase + +.gdbinit + set output-radix 16 + handle SIG32 nostop noprint + file jpst + b jpsdrvr_init + b jps_bank_load + b jps_parse_addsound + r + + best to d to delete all breakpoints, c to continue, and exit w/q + +------------------------------------------------------------------------------- +NFORCE2 setup +- NFORCE install, unified drivers +- NVIDIA install +- set root passwd +- netconfig & edit /etc/modules.conf +- reboot, ifconfig should show eth0 & inet adr +- groupadd dev; useradd joe -g dev -d /home/joe -m +- useradd g3 -g dev -d /usr/local/g3 -m -p bbh3 +- edit /etc/X11/xorg.conf + +/etc/xorg.conf + "vesa" <- "nvidia" + setup new screen and default depth (24) + +/etc/modules.conf + alias eth0 nvnet + alias sound-slot-0 nvsound + +insmod nvnet + date MMDDhhmmCCYY + +/usr/share/doc/nforce/ReleaseNotes.html +/etc/services.conf +/etc/inetd.conf + ftpaccess + +------------------------------------------------------------------------------- +NOTES +www.savagenews.com/drivers/drivers.php +fdisk /dev/hdb (2d ide) +cfdisk +hdb2 1024 M swap +hda3 linux -- 2048 inode size +setup +/etc/rc.d/rc.hotplug +/etc/hotplub/blacklist +/dev/tty24 +liloconfig +dd if=/dev/hdb3 bs=512 count=1 of=/c/bootsect.lnx +sh NVIDIA-..run --check +/etc/X11/xorg.conf /var/log/Xorg.O.log +not if rivafb is present /usr/share/doc/NVIDIA-GLX-1.0/REAMDE +driver "mouse" protocol "PS/2" device "/dev/psaux" +/etc/rc.d/rcmodules + +------------------------------------------------------------------------------- +ADMIN +useradd joe -g dev -d /home/joe -m +groupadd dev +passwd joe +chgrp -R dev . +chown -R joe . +Xorg -configure +X -config /root/xorg.conf +xorgconfig +find / -name XXX -print +xinit xvidtune +xtiming.sourceforge.net +/etc/lilo.conf + +COMMANDS +tar -cvvf doc.tar doc +chmod -R +cp -r /c/G3/bbh3 bbh3 +ls -lat | less +make 2>&1 | less + +NETWORK +ifconfig -- to find the IP address +sftp g3@ + +xinit -- -screen GameScreen +nvidia-settings +.xinit + nvidia-settings --loadconfig-only & + . /etc/X11/xinit/xinitrc + + +------------------------------------------------------------------------------- +build notes + +JFL 16 Jun 05 + +BUILDING SLACKWARE SYSTEM + +download +- download first 2 slackware isos & burn +- download from nVidia + Platform/nForce Drivers Unified Driver Linux + latest Version: 1.0-0301 Release Date: March 10, 2005 + Graphics Driver GeForce and TNT2 Linux IA32 + latest Version: 1.0-7664 Release Date: June 1, 2005 + +bios +- bios + is there a bios update? + AGP size (128 maybe 256) + +partitioning +- slackware CD & boot +- at boot prompt +- no root passwd here +- cfdisk /dev/hda + hda1 Boot Primary Linux 8192MB + hda2 Primary Linyx swap 1024MB + hda3 Primary Linux 8192MB + +slackware setup -- if you mess this up anywhere here, start this part over +- 'setup' + add swap + /dev/hda1 / format w/Reiser + /dev/hda3 /home +- install from cdrom + A AP D F K KDE L N X XAP (trim as we go) + full + skip -- use default kernel + skip -- dont make a bootdisk + nomodem + no -- don't enable hotplug + lilo + begin (no parameters) 640x480x256 MBR /dev/hda None + add linux partition /dev/hda1 linux + install + ps2 mouse + gpm cut & paste + configure network -- bigbuck playmechanix.com dhcp skip + rc.inetd rc.sendmail rc.syslog rc.sshd + don't try out custom fonts + no -- hardware clock is set to local time + us/central + xinitrc.xfce + yes -- set root passwd to bbh3 + +nforce setup +- login as root + mount /dev/cdrom + ls /mnt/cdrom + /mnt/dev/cdrom/NF + install both audio & network drivers + (builds kernel) + /mnt/dev/cdrom/NV + install graphics driver +- edit modules.conf + vi /etc/modules.conf + alias eth0 nvnet + alias sound-slot-0 nvsound +- reboot & test + ifconfig -- should see eth0 with an internet address +- copy xorg.conf from g3/linux to /etc/X11 + +add user +- add user + groupadd dev + useradd g3 -g dev -d /home/g3 -m + passwd g3 -- set to bbh3 + +setup FTP +- edit /etc/inetd.conf + uncomment the ftp line for vsftpd +- copy the vsftpd.conf to /etc/vsftpd.conf +- edit /etc/passwd + make sure any users that can log in via FTP have valid shells + i.e. to g3/../ add /bin/bash at end + +setup serial port +- chgrp dev /dev/ttyS0 + +copy .h files +- copy /g3/freeglut/include/GL/freeglut*.h to /usr/include/GL + +------------------------------------------------------------------------------- +SYSTEM HISTORY & BUILD NOTES + +JFL 21 Apr 05 +running kernal 2.4.10 +to reinstall, as root, remove /etc/modules.conf, reboot, lsmod +reinstalled/updated NFORCE-Linux-x86-1.0-0301-pkg1.run +edit /etc/modules.conf, add line 'alias eth0 nvnet', reboot +ifconfig should show eth0 w/inet addr +reinstalled/updated NVIDIA-Linux-x86-1.0-7174-pkg1.run +./NVIDIA-.. --uninstall +./NVIDIA-.. + + +EOF + diff --git a/linux/config-ide-2.4.26 b/linux/config-ide-2.4.26 new file mode 100755 index 0000000..ea5d634 --- /dev/null +++ b/linux/config-ide-2.4.26 @@ -0,0 +1,2020 @@ +# +# Automatically generated make config: don't edit +# +CONFIG_X86=y +# CONFIG_SBUS is not set +CONFIG_UID16=y + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y + +# +# Loadable module support +# +CONFIG_MODULES=y +# CONFIG_MODVERSIONS is not set +CONFIG_KMOD=y + +# +# Processor type and features +# +# CONFIG_M386 is not set +CONFIG_M486=y +# CONFIG_M586 is not set +# CONFIG_M586TSC is not set +# CONFIG_M586MMX is not set +# CONFIG_M686 is not set +# CONFIG_MPENTIUMIII is not set +# CONFIG_MPENTIUM4 is not set +# CONFIG_MK6 is not set +# CONFIG_MK7 is not set +# CONFIG_MK8 is not set +# CONFIG_MELAN is not set +# CONFIG_MCRUSOE is not set +# CONFIG_MWINCHIPC6 is not set +# CONFIG_MWINCHIP2 is not set +# CONFIG_MWINCHIP3D is not set +# CONFIG_MCYRIXIII is not set +# CONFIG_MVIAC3_2 is not set +CONFIG_X86_WP_WORKS_OK=y +CONFIG_X86_INVLPG=y +CONFIG_X86_CMPXCHG=y +CONFIG_X86_XADD=y +CONFIG_X86_BSWAP=y +CONFIG_X86_POPAD_OK=y +# CONFIG_RWSEM_GENERIC_SPINLOCK is not set +CONFIG_RWSEM_XCHGADD_ALGORITHM=y +CONFIG_X86_L1_CACHE_SHIFT=4 +CONFIG_X86_USE_STRING_486=y +CONFIG_X86_ALIGNMENT_16=y +CONFIG_X86_PPRO_FENCE=y +# CONFIG_X86_F00F_WORKS_OK is not set +# CONFIG_X86_MCE is not set +CONFIG_TOSHIBA=m +CONFIG_I8K=m +CONFIG_MICROCODE=m +CONFIG_X86_MSR=m +CONFIG_X86_CPUID=m +CONFIG_EDD=m +CONFIG_NOHIGHMEM=y +# CONFIG_HIGHMEM4G is not set +# CONFIG_HIGHMEM64G is not set +# CONFIG_HIGHMEM is not set +CONFIG_MATH_EMULATION=y +CONFIG_MTRR=y +# CONFIG_SMP is not set +# CONFIG_X86_UP_APIC is not set +# CONFIG_X86_UP_IOAPIC is not set +# CONFIG_X86_TSC_DISABLE is not set + +# +# General setup +# +CONFIG_NET=y +CONFIG_PCI=y +# CONFIG_PCI_GOBIOS is not set +# CONFIG_PCI_GODIRECT is not set +CONFIG_PCI_GOANY=y +CONFIG_PCI_BIOS=y +CONFIG_PCI_DIRECT=y +CONFIG_ISA=y +CONFIG_PCI_NAMES=y +# CONFIG_EISA is not set +# CONFIG_MCA is not set +CONFIG_HOTPLUG=y + +# +# PCMCIA/CardBus support +# +CONFIG_PCMCIA=m +CONFIG_CARDBUS=y +CONFIG_TCIC=y +CONFIG_I82092=y +CONFIG_I82365=y + +# +# PCI Hotplug Support +# +CONFIG_HOTPLUG_PCI=m +CONFIG_HOTPLUG_PCI_COMPAQ=m +# CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set +CONFIG_SYSVIPC=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_SYSCTL=y +CONFIG_KCORE_ELF=y +# CONFIG_KCORE_AOUT is not set +CONFIG_BINFMT_AOUT=m +CONFIG_BINFMT_ELF=y +CONFIG_BINFMT_MISC=m +# CONFIG_OOM_KILLER is not set +CONFIG_PM=y +CONFIG_APM=m +# CONFIG_APM_IGNORE_USER_SUSPEND is not set +# CONFIG_APM_DO_ENABLE is not set +# CONFIG_APM_CPU_IDLE is not set +# CONFIG_APM_DISPLAY_BLANK is not set +# CONFIG_APM_RTC_IS_GMT is not set +# CONFIG_APM_ALLOW_INTS is not set +# CONFIG_APM_REAL_MODE_POWER_OFF is not set + +# +# ACPI Support +# +# CONFIG_ACPI is not set + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Parallel port support +# +CONFIG_PARPORT=m +CONFIG_PARPORT_PC=m +CONFIG_PARPORT_PC_CML1=m +CONFIG_PARPORT_SERIAL=m +# CONFIG_PARPORT_PC_FIFO is not set +# CONFIG_PARPORT_PC_SUPERIO is not set +CONFIG_PARPORT_PC_PCMCIA=m +# CONFIG_PARPORT_AMIGA is not set +# CONFIG_PARPORT_MFC3 is not set +# CONFIG_PARPORT_ATARI is not set +# CONFIG_PARPORT_GSC is not set +# CONFIG_PARPORT_SUNBPP is not set +# CONFIG_PARPORT_IP22 is not set +# CONFIG_PARPORT_OTHER is not set +CONFIG_PARPORT_1284=y + +# +# Plug and Play configuration +# +CONFIG_PNP=m +CONFIG_ISAPNP=m + +# +# Block devices +# +CONFIG_BLK_DEV_FD=y +CONFIG_BLK_DEV_XD=m +CONFIG_PARIDE=m +CONFIG_PARIDE_PARPORT=m + +# +# Parallel IDE high-level drivers +# +CONFIG_PARIDE_PD=m +CONFIG_PARIDE_PCD=m +CONFIG_PARIDE_PF=m +CONFIG_PARIDE_PT=m +CONFIG_PARIDE_PG=m + +# +# Parallel IDE protocol modules +# +CONFIG_PARIDE_ATEN=m +CONFIG_PARIDE_BPCK=m +CONFIG_PARIDE_BPCK6=m +CONFIG_PARIDE_COMM=m +CONFIG_PARIDE_DSTR=m +CONFIG_PARIDE_FIT2=m +CONFIG_PARIDE_FIT3=m +CONFIG_PARIDE_EPAT=m +CONFIG_PARIDE_EPATC8=y +CONFIG_PARIDE_EPIA=m +CONFIG_PARIDE_FRIQ=m +CONFIG_PARIDE_FRPW=m +CONFIG_PARIDE_KBIC=m +CONFIG_PARIDE_KTTI=m +CONFIG_PARIDE_ON20=m +CONFIG_PARIDE_ON26=m +CONFIG_BLK_CPQ_DA=m +CONFIG_BLK_CPQ_CISS_DA=m +CONFIG_CISS_SCSI_TAPE=y +# CONFIG_CISS_MONITOR_THREAD is not set +CONFIG_BLK_DEV_DAC960=m +CONFIG_BLK_DEV_UMEM=m +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_NBD=m +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=7777 +CONFIG_BLK_DEV_INITRD=y +# CONFIG_BLK_STATS is not set + +# +# Multi-device support (RAID and LVM) +# +CONFIG_MD=y +CONFIG_BLK_DEV_MD=y +CONFIG_MD_LINEAR=y +CONFIG_MD_RAID0=y +CONFIG_MD_RAID1=y +CONFIG_MD_RAID5=y +CONFIG_MD_MULTIPATH=m +CONFIG_BLK_DEV_LVM=y + +# +# Networking options +# +CONFIG_PACKET=y +CONFIG_PACKET_MMAP=y +CONFIG_NETLINK_DEV=m +CONFIG_NETFILTER=y +# CONFIG_NETFILTER_DEBUG is not set +CONFIG_FILTER=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_FWMARK=y +CONFIG_IP_ROUTE_NAT=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_TOS=y +CONFIG_IP_ROUTE_VERBOSE=y +# CONFIG_IP_PNP is not set +CONFIG_NET_IPIP=m +CONFIG_NET_IPGRE=m +CONFIG_NET_IPGRE_BROADCAST=y +CONFIG_IP_MROUTE=y +CONFIG_IP_PIMSM_V1=y +# CONFIG_IP_PIMSM_V2 is not set +# CONFIG_ARPD is not set +# CONFIG_INET_ECN is not set +CONFIG_SYN_COOKIES=y + +# +# IP: Netfilter Configuration +# +CONFIG_IP_NF_CONNTRACK=m +CONFIG_IP_NF_FTP=m +CONFIG_IP_NF_AMANDA=m +CONFIG_IP_NF_TFTP=m +CONFIG_IP_NF_IRC=m +CONFIG_IP_NF_QUEUE=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_MATCH_LIMIT=m +CONFIG_IP_NF_MATCH_MAC=m +CONFIG_IP_NF_MATCH_PKTTYPE=m +CONFIG_IP_NF_MATCH_MARK=m +CONFIG_IP_NF_MATCH_MULTIPORT=m +CONFIG_IP_NF_MATCH_TOS=m +CONFIG_IP_NF_MATCH_RECENT=m +CONFIG_IP_NF_MATCH_ECN=m +CONFIG_IP_NF_MATCH_DSCP=m +CONFIG_IP_NF_MATCH_AH_ESP=m +CONFIG_IP_NF_MATCH_LENGTH=m +CONFIG_IP_NF_MATCH_TTL=m +CONFIG_IP_NF_MATCH_TCPMSS=m +CONFIG_IP_NF_MATCH_HELPER=m +CONFIG_IP_NF_MATCH_STATE=m +CONFIG_IP_NF_MATCH_CONNTRACK=m +CONFIG_IP_NF_MATCH_UNCLEAN=m +CONFIG_IP_NF_MATCH_OWNER=m +CONFIG_IP_NF_FILTER=m +CONFIG_IP_NF_TARGET_REJECT=m +CONFIG_IP_NF_TARGET_MIRROR=m +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_NAT_NEEDED=y +CONFIG_IP_NF_TARGET_MASQUERADE=m +CONFIG_IP_NF_TARGET_REDIRECT=m +CONFIG_IP_NF_NAT_AMANDA=m +# CONFIG_IP_NF_NAT_LOCAL is not set +CONFIG_IP_NF_NAT_SNMP_BASIC=m +CONFIG_IP_NF_NAT_IRC=m +CONFIG_IP_NF_NAT_FTP=m +CONFIG_IP_NF_NAT_TFTP=m +CONFIG_IP_NF_MANGLE=m +CONFIG_IP_NF_TARGET_TOS=m +CONFIG_IP_NF_TARGET_ECN=m +CONFIG_IP_NF_TARGET_DSCP=m +CONFIG_IP_NF_TARGET_MARK=m +CONFIG_IP_NF_TARGET_LOG=m +CONFIG_IP_NF_TARGET_ULOG=m +CONFIG_IP_NF_TARGET_TCPMSS=m +CONFIG_IP_NF_ARPTABLES=m +CONFIG_IP_NF_ARPFILTER=m +CONFIG_IP_NF_ARP_MANGLE=m +CONFIG_IP_NF_COMPAT_IPCHAINS=m +CONFIG_IP_NF_NAT_NEEDED=y +# CONFIG_IP_NF_COMPAT_IPFWADM is not set + +# +# IP: Virtual Server Configuration +# +CONFIG_IP_VS=m +# CONFIG_IP_VS_DEBUG is not set +CONFIG_IP_VS_TAB_BITS=12 + +# +# IPVS scheduler +# +CONFIG_IP_VS_RR=m +CONFIG_IP_VS_WRR=m +CONFIG_IP_VS_LC=m +CONFIG_IP_VS_WLC=m +CONFIG_IP_VS_LBLC=m +CONFIG_IP_VS_LBLCR=m +CONFIG_IP_VS_DH=m +CONFIG_IP_VS_SH=m +CONFIG_IP_VS_SED=m +CONFIG_IP_VS_NQ=m + +# +# IPVS application helper +# +CONFIG_IP_VS_FTP=m +CONFIG_IPV6=m + +# +# IPv6: Netfilter Configuration +# +# CONFIG_IP6_NF_QUEUE is not set +CONFIG_IP6_NF_IPTABLES=m +CONFIG_IP6_NF_MATCH_LIMIT=m +CONFIG_IP6_NF_MATCH_MAC=m +CONFIG_IP6_NF_MATCH_RT=m +CONFIG_IP6_NF_MATCH_OPTS=m +CONFIG_IP6_NF_MATCH_FRAG=m +CONFIG_IP6_NF_MATCH_HL=m +CONFIG_IP6_NF_MATCH_MULTIPORT=m +CONFIG_IP6_NF_MATCH_OWNER=m +CONFIG_IP6_NF_MATCH_MARK=m +CONFIG_IP6_NF_MATCH_IPV6HEADER=m +CONFIG_IP6_NF_MATCH_AHESP=m +CONFIG_IP6_NF_MATCH_LENGTH=m +CONFIG_IP6_NF_MATCH_EUI64=m +CONFIG_IP6_NF_FILTER=m +CONFIG_IP6_NF_TARGET_LOG=m +CONFIG_IP6_NF_MANGLE=m +CONFIG_IP6_NF_TARGET_MARK=m +CONFIG_KHTTPD=m + +# +# SCTP Configuration (EXPERIMENTAL) +# +CONFIG_IP_SCTP=m +# CONFIG_SCTP_DBG_MSG is not set +# CONFIG_SCTP_DBG_OBJCNT is not set +# CONFIG_SCTP_HMAC_NONE is not set +# CONFIG_SCTP_HMAC_SHA1 is not set +CONFIG_SCTP_HMAC_MD5=y +# CONFIG_ATM is not set +CONFIG_VLAN_8021Q=m + +# +# +# +CONFIG_IPX=m +# CONFIG_IPX_INTERN is not set +CONFIG_ATALK=m + +# +# Appletalk devices +# +# CONFIG_DEV_APPLETALK is not set +CONFIG_DECNET=m +# CONFIG_DECNET_SIOCGIFCONF is not set +# CONFIG_DECNET_ROUTER is not set +CONFIG_BRIDGE=m +CONFIG_X25=m +CONFIG_LAPB=m +# CONFIG_LLC is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=m +# CONFIG_NET_FASTROUTE is not set +# CONFIG_NET_HW_FLOWCONTROL is not set + +# +# QoS and/or fair queueing +# +CONFIG_NET_SCHED=y +CONFIG_NET_SCH_CBQ=m +CONFIG_NET_SCH_HTB=m +CONFIG_NET_SCH_CSZ=m +CONFIG_NET_SCH_HFSC=m +CONFIG_NET_SCH_PRIO=m +CONFIG_NET_SCH_RED=m +CONFIG_NET_SCH_SFQ=m +CONFIG_NET_SCH_TEQL=m +CONFIG_NET_SCH_TBF=m +CONFIG_NET_SCH_GRED=m +CONFIG_NET_SCH_DELAY=m +CONFIG_NET_SCH_DSMARK=m +CONFIG_NET_SCH_INGRESS=m +CONFIG_NET_QOS=y +CONFIG_NET_ESTIMATOR=y +CONFIG_NET_CLS=y +CONFIG_NET_CLS_TCINDEX=m +CONFIG_NET_CLS_ROUTE4=m +CONFIG_NET_CLS_ROUTE=y +CONFIG_NET_CLS_FW=m +CONFIG_NET_CLS_U32=m +CONFIG_NET_CLS_RSVP=m +CONFIG_NET_CLS_RSVP6=m +CONFIG_NET_CLS_POLICE=y + +# +# Network testing +# +CONFIG_NET_PKTGEN=m + +# +# Telephony Support +# +CONFIG_PHONE=m +CONFIG_PHONE_IXJ=m +CONFIG_PHONE_IXJ_PCMCIA=m + +# +# ATA/IDE/MFM/RLL support +# +CONFIG_IDE=y + +# +# IDE, ATA and ATAPI Block devices +# +CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# +# CONFIG_BLK_DEV_HD_IDE is not set +# CONFIG_BLK_DEV_HD is not set +CONFIG_BLK_DEV_IDEDISK=y +# CONFIG_IDEDISK_MULTI_MODE is not set +# CONFIG_IDEDISK_STROKE is not set +CONFIG_BLK_DEV_IDECS=m +CONFIG_BLK_DEV_IDECD=y +CONFIG_BLK_DEV_IDETAPE=m +CONFIG_BLK_DEV_IDEFLOPPY=y +CONFIG_BLK_DEV_IDESCSI=m +# CONFIG_IDE_TASK_IOCTL is not set + +# +# IDE chipset support/bugfixes +# +CONFIG_BLK_DEV_CMD640=y +# CONFIG_BLK_DEV_CMD640_ENHANCED is not set +# CONFIG_BLK_DEV_ISAPNP is not set +CONFIG_BLK_DEV_IDEPCI=y +CONFIG_BLK_DEV_GENERIC=y +CONFIG_IDEPCI_SHARE_IRQ=y +CONFIG_BLK_DEV_IDEDMA_PCI=y +# CONFIG_BLK_DEV_OFFBOARD is not set +# CONFIG_BLK_DEV_IDEDMA_FORCED is not set +CONFIG_IDEDMA_PCI_AUTO=y +# CONFIG_IDEDMA_ONLYDISK is not set +CONFIG_BLK_DEV_IDEDMA=y +# CONFIG_IDEDMA_PCI_WIP is not set +CONFIG_BLK_DEV_ADMA100=y +CONFIG_BLK_DEV_AEC62XX=y +CONFIG_BLK_DEV_ALI15X3=y +# CONFIG_WDC_ALI15X3 is not set +CONFIG_BLK_DEV_AMD74XX=y +# CONFIG_AMD74XX_OVERRIDE is not set +CONFIG_BLK_DEV_ATIIXP=y +CONFIG_BLK_DEV_CMD64X=y +CONFIG_BLK_DEV_TRIFLEX=y +# CONFIG_BLK_DEV_CY82C693 is not set +CONFIG_BLK_DEV_CS5530=y +CONFIG_BLK_DEV_HPT34X=y +# CONFIG_HPT34X_AUTODMA is not set +CONFIG_BLK_DEV_HPT366=y +CONFIG_BLK_DEV_PIIX=y +# CONFIG_BLK_DEV_NS87415 is not set +# CONFIG_BLK_DEV_OPTI621 is not set +CONFIG_BLK_DEV_PDC202XX_OLD=y +# CONFIG_PDC202XX_BURST is not set +CONFIG_BLK_DEV_PDC202XX_NEW=y +# CONFIG_PDC202XX_FORCE is not set +CONFIG_BLK_DEV_RZ1000=y +CONFIG_BLK_DEV_SC1200=y +CONFIG_BLK_DEV_SVWKS=y +CONFIG_BLK_DEV_SIIMAGE=y +CONFIG_BLK_DEV_SIS5513=y +CONFIG_BLK_DEV_SLC90E66=y +# CONFIG_BLK_DEV_TRM290 is not set +CONFIG_BLK_DEV_VIA82CXXX=y +CONFIG_IDE_CHIPSETS=y + +# +# Note: most of these also require special kernel boot parameters +# +CONFIG_BLK_DEV_4DRIVES=y +CONFIG_BLK_DEV_ALI14XX=y +CONFIG_BLK_DEV_DTC2278=y +CONFIG_BLK_DEV_HT6560B=y +CONFIG_BLK_DEV_PDC4030=y +CONFIG_BLK_DEV_QD65XX=y +CONFIG_BLK_DEV_UMC8672=y +CONFIG_IDEDMA_AUTO=y +# CONFIG_IDEDMA_IVB is not set +# CONFIG_DMA_NONPCI is not set +CONFIG_BLK_DEV_PDC202XX=y +CONFIG_BLK_DEV_ATARAID=m +CONFIG_BLK_DEV_ATARAID_PDC=m +CONFIG_BLK_DEV_ATARAID_HPT=m +CONFIG_BLK_DEV_ATARAID_MEDLEY=m +CONFIG_BLK_DEV_ATARAID_SII=m + +# +# SCSI support +# +CONFIG_SCSI=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +CONFIG_SD_EXTRA_DEVS=40 +CONFIG_CHR_DEV_ST=m +CONFIG_CHR_DEV_OSST=m +CONFIG_BLK_DEV_SR=y +# CONFIG_BLK_DEV_SR_VENDOR is not set +CONFIG_SR_EXTRA_DEVS=2 +CONFIG_CHR_DEV_SG=y + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +CONFIG_SCSI_DEBUG_QUEUES=y +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set + +# +# SCSI low-level drivers +# +CONFIG_BLK_DEV_3W_XXXX_RAID=m +CONFIG_SCSI_7000FASST=m +CONFIG_SCSI_ACARD=m +CONFIG_SCSI_AHA152X=m +CONFIG_SCSI_AHA1542=m +CONFIG_SCSI_AHA1740=m +CONFIG_SCSI_AACRAID=m +CONFIG_SCSI_AIC7XXX=m +CONFIG_AIC7XXX_CMDS_PER_DEVICE=8 +CONFIG_AIC7XXX_RESET_DELAY_MS=15000 +# CONFIG_AIC7XXX_PROBE_EISA_VL is not set +# CONFIG_AIC7XXX_BUILD_FIRMWARE is not set +# CONFIG_AIC7XXX_DEBUG_ENABLE is not set +CONFIG_AIC7XXX_DEBUG_MASK=0 +# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set +CONFIG_SCSI_AIC79XX=m +CONFIG_AIC79XX_CMDS_PER_DEVICE=32 +CONFIG_AIC79XX_RESET_DELAY_MS=15000 +# CONFIG_AIC79XX_BUILD_FIRMWARE is not set +# CONFIG_AIC79XX_ENABLE_RD_STRM is not set +# CONFIG_AIC79XX_DEBUG_ENABLE is not set +CONFIG_AIC79XX_DEBUG_MASK=0 +# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set +CONFIG_SCSI_AIC7XXX_OLD=m +# CONFIG_AIC7XXX_OLD_TCQ_ON_BY_DEFAULT is not set +CONFIG_AIC7XXX_OLD_CMDS_PER_DEVICE=8 +# CONFIG_AIC7XXX_OLD_PROC_STATS is not set +CONFIG_SCSI_DPT_I2O=m +CONFIG_SCSI_ADVANSYS=m +CONFIG_SCSI_IN2000=m +CONFIG_SCSI_AM53C974=m +CONFIG_SCSI_MEGARAID=m +CONFIG_SCSI_MEGARAID2=m +CONFIG_SCSI_BUSLOGIC=m +# CONFIG_SCSI_OMIT_FLASHPOINT is not set +CONFIG_SCSI_CPQFCTS=m +CONFIG_SCSI_DMX3191D=m +CONFIG_SCSI_DTC3280=m +CONFIG_SCSI_EATA=m +# CONFIG_SCSI_EATA_TAGGED_QUEUE is not set +# CONFIG_SCSI_EATA_LINKED_COMMANDS is not set +CONFIG_SCSI_EATA_MAX_TAGS=16 +CONFIG_SCSI_EATA_DMA=m +CONFIG_SCSI_EATA_PIO=m +CONFIG_SCSI_FUTURE_DOMAIN=m +CONFIG_SCSI_GDTH=m +CONFIG_SCSI_GENERIC_NCR5380=m +CONFIG_SCSI_GENERIC_NCR53C400=y +CONFIG_SCSI_G_NCR5380_PORT=y +# CONFIG_SCSI_G_NCR5380_MEM is not set +CONFIG_SCSI_IPS=m +CONFIG_SCSI_INITIO=m +CONFIG_SCSI_INIA100=m +CONFIG_SCSI_PPA=m +CONFIG_SCSI_IMM=m +CONFIG_SCSI_IZIP_EPP16=y +# CONFIG_SCSI_IZIP_SLOW_CTR is not set +CONFIG_SCSI_NCR53C406A=m +CONFIG_SCSI_NCR53C7xx=m +# CONFIG_SCSI_NCR53C7xx_sync is not set +# CONFIG_SCSI_NCR53C7xx_FAST is not set +# CONFIG_SCSI_NCR53C7xx_DISCONNECT is not set +CONFIG_SCSI_SYM53C8XX_2=m +CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1 +CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 +CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set +CONFIG_SCSI_NCR53C8XX=m +CONFIG_SCSI_SYM53C8XX=m +CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 +CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 +CONFIG_SCSI_NCR53C8XX_SYNC=20 +# CONFIG_SCSI_NCR53C8XX_PROFILE is not set +# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set +CONFIG_SCSI_NCR53C8XX_PQS_PDS=y +# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +CONFIG_SCSI_PAS16=m +CONFIG_SCSI_PCI2000=m +CONFIG_SCSI_PCI2220I=m +CONFIG_SCSI_PSI240I=m +CONFIG_SCSI_QLOGIC_FAS=m +CONFIG_SCSI_QLOGIC_ISP=m +CONFIG_SCSI_QLOGIC_FC=m +CONFIG_SCSI_QLOGIC_FC_FIRMWARE=y +CONFIG_SCSI_QLOGIC_1280=m +CONFIG_SCSI_SEAGATE=m +CONFIG_SCSI_SIM710=m +CONFIG_SCSI_SYM53C416=m +CONFIG_SCSI_DC390T=m +# CONFIG_SCSI_DC390T_NOGENSUPP is not set +CONFIG_SCSI_T128=m +CONFIG_SCSI_U14_34F=m +# CONFIG_SCSI_U14_34F_LINKED_COMMANDS is not set +CONFIG_SCSI_U14_34F_MAX_TAGS=8 +CONFIG_SCSI_ULTRASTOR=m +CONFIG_SCSI_NSP32=m +CONFIG_SCSI_DEBUG=m + +# +# PCMCIA SCSI adapter support +# +CONFIG_SCSI_PCMCIA=y +CONFIG_PCMCIA_AHA152X=m +CONFIG_PCMCIA_FDOMAIN=m +CONFIG_PCMCIA_NINJA_SCSI=m +CONFIG_PCMCIA_QLOGIC=m + +# +# Fusion MPT device support +# +CONFIG_FUSION=m +# CONFIG_FUSION_BOOT is not set +CONFIG_FUSION_MAX_SGE=40 +CONFIG_FUSION_ISENSE=m +CONFIG_FUSION_CTL=m +CONFIG_FUSION_LAN=m +CONFIG_NET_FC=y + +# +# IEEE 1394 (FireWire) support (EXPERIMENTAL) +# +CONFIG_IEEE1394=m + +# +# Device Drivers +# +CONFIG_IEEE1394_PCILYNX=m +CONFIG_IEEE1394_OHCI1394=m + +# +# Protocol Drivers +# +CONFIG_IEEE1394_VIDEO1394=m +CONFIG_IEEE1394_SBP2=m +# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set +CONFIG_IEEE1394_ETH1394=m +CONFIG_IEEE1394_DV1394=m +CONFIG_IEEE1394_RAWIO=m +CONFIG_IEEE1394_CMP=m +CONFIG_IEEE1394_AMDTP=m +# CONFIG_IEEE1394_VERBOSEDEBUG is not set +# CONFIG_IEEE1394_OUI_DB is not set + +# +# I2O device support +# +CONFIG_I2O=m +CONFIG_I2O_PCI=m +CONFIG_I2O_BLOCK=m +CONFIG_I2O_LAN=m +CONFIG_I2O_SCSI=m +CONFIG_I2O_PROC=m + +# +# Network device support +# +CONFIG_NETDEVICES=y + +# +# ARCnet devices +# +CONFIG_ARCNET=m +CONFIG_ARCNET_1201=m +CONFIG_ARCNET_1051=m +CONFIG_ARCNET_RAW=m +CONFIG_ARCNET_COM90xx=m +CONFIG_ARCNET_COM90xxIO=m +CONFIG_ARCNET_RIM_I=m +CONFIG_ARCNET_COM20020=m +CONFIG_ARCNET_COM20020_ISA=m +CONFIG_ARCNET_COM20020_PCI=m +CONFIG_DUMMY=m +CONFIG_BONDING=m +CONFIG_EQUALIZER=m +CONFIG_TUN=m +CONFIG_ETHERTAP=m +CONFIG_NET_SB1000=m + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +# CONFIG_SUNLANCE is not set +CONFIG_HAPPYMEAL=m +# CONFIG_SUNBMAC is not set +# CONFIG_SUNQE is not set +CONFIG_SUNGEM=m +CONFIG_NET_VENDOR_3COM=y +CONFIG_EL1=m +CONFIG_EL2=m +CONFIG_ELPLUS=m +CONFIG_EL16=m +CONFIG_EL3=m +CONFIG_3C515=m +# CONFIG_ELMC is not set +# CONFIG_ELMC_II is not set +CONFIG_VORTEX=m +CONFIG_TYPHOON=m +CONFIG_LANCE=m +CONFIG_NET_VENDOR_SMC=y +CONFIG_WD80x3=m +# CONFIG_ULTRAMCA is not set +CONFIG_ULTRA=m +# CONFIG_ULTRA32 is not set +CONFIG_SMC9194=m +CONFIG_NET_VENDOR_RACAL=y +CONFIG_NI5010=m +CONFIG_NI52=m +CONFIG_NI65=m +CONFIG_AT1700=m +CONFIG_DEPCA=m +CONFIG_HP100=m +CONFIG_NET_ISA=y +CONFIG_E2100=m +CONFIG_EWRK3=m +CONFIG_EEXPRESS=m +CONFIG_EEXPRESS_PRO=m +CONFIG_HPLAN_PLUS=m +CONFIG_HPLAN=m +CONFIG_LP486E=m +CONFIG_ETH16I=m +CONFIG_NE2000=m +CONFIG_NET_PCI=y +CONFIG_PCNET32=m +CONFIG_AMD8111_ETH=m +CONFIG_ADAPTEC_STARFIRE=m +CONFIG_AC3200=m +CONFIG_APRICOT=m +CONFIG_B44=m +CONFIG_CS89x0=m +CONFIG_TULIP=m +# CONFIG_TULIP_MWI is not set +# CONFIG_TULIP_MMIO is not set +CONFIG_DE4X5=m +CONFIG_DGRS=m +CONFIG_DM9102=m +CONFIG_EEPRO100=m +# CONFIG_EEPRO100_PIO is not set +CONFIG_E100=m +# CONFIG_LNE390 is not set +CONFIG_FEALNX=m +CONFIG_NATSEMI=m +CONFIG_NE2K_PCI=m +CONFIG_FORCEDETH=m +# CONFIG_NE3210 is not set +# CONFIG_ES3210 is not set +CONFIG_8139CP=m +CONFIG_8139TOO=m +# CONFIG_8139TOO_PIO is not set +CONFIG_8139TOO_TUNE_TWISTER=y +CONFIG_8139TOO_8129=y +# CONFIG_8139_OLD_RX_RESET is not set +CONFIG_SIS900=m +CONFIG_EPIC100=m +CONFIG_SUNDANCE=m +# CONFIG_SUNDANCE_MMIO is not set +CONFIG_TLAN=m +CONFIG_VIA_RHINE=m +# CONFIG_VIA_RHINE_MMIO is not set +CONFIG_WINBOND_840=m +CONFIG_NET_POCKET=y +CONFIG_ATP=m +CONFIG_DE600=m +CONFIG_DE620=m + +# +# Ethernet (1000 Mbit) +# +CONFIG_ACENIC=m +# CONFIG_ACENIC_OMIT_TIGON_I is not set +CONFIG_DL2K=m +CONFIG_E1000=m +# CONFIG_E1000_NAPI is not set +# CONFIG_MYRI_SBUS is not set +CONFIG_NS83820=m +CONFIG_HAMACHI=m +CONFIG_YELLOWFIN=m +CONFIG_R8169=m +CONFIG_SK98LIN=m +CONFIG_TIGON3=m +CONFIG_FDDI=y +CONFIG_DEFXX=m +CONFIG_SKFP=m +# CONFIG_HIPPI is not set +CONFIG_PLIP=m +CONFIG_PPP=m +CONFIG_PPP_MULTILINK=y +CONFIG_PPP_FILTER=y +CONFIG_PPP_ASYNC=m +CONFIG_PPP_SYNC_TTY=m +CONFIG_PPP_DEFLATE=m +CONFIG_PPP_BSDCOMP=m +CONFIG_PPPOE=m +CONFIG_SLIP=m +CONFIG_SLIP_COMPRESSED=y +CONFIG_SLIP_SMART=y +# CONFIG_SLIP_MODE_SLIP6 is not set + +# +# Wireless LAN (non-hamradio) +# +CONFIG_NET_RADIO=y +CONFIG_STRIP=m +CONFIG_WAVELAN=m +CONFIG_ARLAN=m +CONFIG_AIRONET4500=m +CONFIG_AIRONET4500_NONCS=m +CONFIG_AIRONET4500_PNP=y +CONFIG_AIRONET4500_PCI=y +# CONFIG_AIRONET4500_ISA is not set +# CONFIG_AIRONET4500_I365 is not set +CONFIG_AIRONET4500_PROC=m +CONFIG_AIRO=m +CONFIG_HERMES=m +CONFIG_PLX_HERMES=m +CONFIG_TMD_HERMES=m +CONFIG_PCI_HERMES=m + +# +# Wireless Pcmcia cards support +# +CONFIG_PCMCIA_HERMES=m +CONFIG_AIRO_CS=m +CONFIG_PCMCIA_ATMEL=m +CONFIG_NET_WIRELESS=y + +# +# Token Ring devices +# +CONFIG_TR=y +CONFIG_IBMTR=m +CONFIG_IBMOL=m +CONFIG_IBMLS=m +CONFIG_3C359=m +CONFIG_TMS380TR=m +CONFIG_TMSPCI=m +CONFIG_TMSISA=m +CONFIG_ABYSS=m +# CONFIG_MADGEMC is not set +CONFIG_SMCTR=m +CONFIG_NET_FC=y +CONFIG_IPHASE5526=m +CONFIG_RCPCI=m +CONFIG_SHAPER=m + +# +# Wan interfaces +# +CONFIG_WAN=y +CONFIG_HOSTESS_SV11=m +CONFIG_COSA=m +# CONFIG_COMX is not set +CONFIG_DSCC4=m +# CONFIG_DSCC4_PCISYNC is not set +# CONFIG_DSCC4_PCI_RST is not set +CONFIG_LANMEDIA=m +CONFIG_ATI_XX20=m +CONFIG_SEALEVEL_4021=m +CONFIG_SYNCLINK_SYNCPPP=m +CONFIG_HDLC=m +CONFIG_HDLC_RAW=y +CONFIG_HDLC_RAW_ETH=y +CONFIG_HDLC_CISCO=y +CONFIG_HDLC_FR=y +# CONFIG_HDLC_PPP is not set +# CONFIG_HDLC_X25 is not set +CONFIG_PCI200SYN=m +CONFIG_PC300=m + +# +# Cyclades-PC300 MLPPP support is disabled. +# + +# +# Refer to the file README.mlppp, provided by PC300 package. +# +CONFIG_FARSYNC=m +CONFIG_N2=m +CONFIG_C101=m +CONFIG_DLCI=m +CONFIG_DLCI_COUNT=24 +CONFIG_DLCI_MAX=8 +CONFIG_SDLA=m +CONFIG_WAN_ROUTER_DRIVERS=y +CONFIG_VENDOR_SANGOMA=m +CONFIG_WANPIPE_CHDLC=y +# CONFIG_WANPIPE_FR is not set +# CONFIG_WANPIPE_X25 is not set +CONFIG_WANPIPE_PPP=y +# CONFIG_WANPIPE_MULTPPP is not set +CONFIG_CYCLADES_SYNC=m +CONFIG_CYCLOMX_X25=y +CONFIG_LAPBETHER=m +CONFIG_X25_ASY=m +CONFIG_SBNI=m +# CONFIG_SBNI_MULTILINE is not set + +# +# PCMCIA network device support +# +CONFIG_NET_PCMCIA=y +CONFIG_PCMCIA_3C589=m +CONFIG_PCMCIA_3C574=m +CONFIG_PCMCIA_FMVJ18X=m +CONFIG_PCMCIA_PCNET=m +CONFIG_PCMCIA_AXNET=m +CONFIG_PCMCIA_NMCLAN=m +CONFIG_PCMCIA_SMC91C92=m +CONFIG_PCMCIA_XIRC2PS=m +CONFIG_ARCNET_COM20020_CS=m +CONFIG_PCMCIA_IBMTR=m +CONFIG_PCMCIA_XIRCOM=m +CONFIG_PCMCIA_XIRTULIP=m +CONFIG_NET_PCMCIA_RADIO=y +CONFIG_PCMCIA_RAYCS=m +CONFIG_PCMCIA_NETWAVE=m +CONFIG_PCMCIA_WAVELAN=m +CONFIG_AIRONET4500_CS=m + +# +# Amateur Radio support +# +CONFIG_HAMRADIO=y + +# +# Packet Radio protocols +# +CONFIG_AX25=m +CONFIG_AX25_DAMA_SLAVE=y +CONFIG_NETROM=m +CONFIG_ROSE=m + +# +# AX.25 network device drivers +# + +# +# AX.25 network device drivers +# +CONFIG_MKISS=m +CONFIG_6PACK=m +CONFIG_BPQETHER=m +CONFIG_DMASCC=m +CONFIG_SCC=m +CONFIG_SCC_DELAY=y +CONFIG_SCC_TRXECHO=y +CONFIG_BAYCOM_SER_FDX=m +CONFIG_BAYCOM_SER_HDX=m +CONFIG_BAYCOM_PAR=m +CONFIG_BAYCOM_EPP=m +CONFIG_SOUNDMODEM=m +CONFIG_SOUNDMODEM_SBC=y +CONFIG_SOUNDMODEM_WSS=y +CONFIG_SOUNDMODEM_AFSK1200=y +CONFIG_SOUNDMODEM_AFSK2400_7=y +CONFIG_SOUNDMODEM_AFSK2400_8=y +CONFIG_SOUNDMODEM_AFSK2666=y +CONFIG_SOUNDMODEM_HAPN4800=y +CONFIG_SOUNDMODEM_PSK4800=y +CONFIG_SOUNDMODEM_FSK9600=y +CONFIG_YAM=m + +# +# IrDA (infrared) support +# +CONFIG_IRDA=m + +# +# IrDA protocols +# +CONFIG_IRLAN=m +CONFIG_IRNET=m +CONFIG_IRCOMM=m +# CONFIG_IRDA_ULTRA is not set + +# +# IrDA options +# +CONFIG_IRDA_CACHE_LAST_LSAP=y +CONFIG_IRDA_FAST_RR=y +# CONFIG_IRDA_DEBUG is not set + +# +# Infrared-port device drivers +# + +# +# SIR device drivers +# +CONFIG_IRTTY_SIR=m +CONFIG_IRPORT_SIR=m + +# +# Dongle support +# +CONFIG_DONGLE=y +CONFIG_ESI_DONGLE=m +CONFIG_ACTISYS_DONGLE=m +CONFIG_TEKRAM_DONGLE=m +CONFIG_GIRBIL_DONGLE=m +CONFIG_LITELINK_DONGLE=m +CONFIG_MCP2120_DONGLE=m +CONFIG_OLD_BELKIN_DONGLE=m +CONFIG_ACT200L_DONGLE=m +CONFIG_MA600_DONGLE=m + +# +# FIR device drivers +# +CONFIG_USB_IRDA=m +CONFIG_NSC_FIR=m +CONFIG_WINBOND_FIR=m +CONFIG_TOSHIBA_OLD=m +CONFIG_TOSHIBA_FIR=m +CONFIG_SMC_IRCC_FIR=m +CONFIG_ALI_FIR=m +CONFIG_VLSI_FIR=m +CONFIG_VIA_IRCC_FIR=m + +# +# ISDN subsystem +# +CONFIG_ISDN=m +CONFIG_ISDN_BOOL=y +CONFIG_ISDN_PPP=y +CONFIG_IPPP_FILTER=y +CONFIG_ISDN_PPP_VJ=y +CONFIG_ISDN_MPP=y +CONFIG_ISDN_PPP_BSDCOMP=m +CONFIG_ISDN_AUDIO=y +# CONFIG_ISDN_TTY_FAX is not set +CONFIG_ISDN_X25=y + +# +# ISDN feature submodules +# +CONFIG_ISDN_DRV_LOOP=m +CONFIG_ISDN_DIVERSION=m + +# +# low-level hardware drivers +# + +# +# Passive ISDN cards +# +CONFIG_ISDN_DRV_HISAX=m +CONFIG_ISDN_HISAX=y + +# +# D-channel protocol features +# +CONFIG_HISAX_EURO=y +CONFIG_DE_AOC=y +# CONFIG_HISAX_NO_SENDCOMPLETE is not set +# CONFIG_HISAX_NO_LLC is not set +# CONFIG_HISAX_NO_KEYPAD is not set +CONFIG_HISAX_1TR6=y +# CONFIG_HISAX_NI1 is not set +CONFIG_HISAX_MAX_CARDS=8 + +# +# HiSax supported cards +# +CONFIG_HISAX_16_0=y +CONFIG_HISAX_16_3=y +CONFIG_HISAX_AVM_A1=y +CONFIG_HISAX_IX1MICROR2=y +CONFIG_HISAX_ASUSCOM=y +CONFIG_HISAX_TELEINT=y +CONFIG_HISAX_HFCS=y +CONFIG_HISAX_SPORTSTER=y +CONFIG_HISAX_MIC=y +CONFIG_HISAX_ISURF=y +CONFIG_HISAX_HSTSAPHIR=y +CONFIG_HISAX_TELESPCI=y +CONFIG_HISAX_S0BOX=y +CONFIG_HISAX_FRITZPCI=y +CONFIG_HISAX_AVM_A1_PCMCIA=y +CONFIG_HISAX_ELSA=y +CONFIG_HISAX_DIEHLDIVA=y +CONFIG_HISAX_SEDLBAUER=y +CONFIG_HISAX_NETJET=y +CONFIG_HISAX_NETJET_U=y +CONFIG_HISAX_NICCY=y +CONFIG_HISAX_BKM_A4T=y +CONFIG_HISAX_SCT_QUADRO=y +CONFIG_HISAX_GAZEL=y +CONFIG_HISAX_HFC_PCI=y +CONFIG_HISAX_W6692=y +CONFIG_HISAX_HFC_SX=y +CONFIG_HISAX_ENTERNOW_PCI=y +# CONFIG_HISAX_DEBUG is not set +CONFIG_HISAX_SEDLBAUER_CS=m +CONFIG_HISAX_ELSA_CS=m +CONFIG_HISAX_AVM_A1_CS=m +CONFIG_HISAX_ST5481=m +CONFIG_HISAX_FRITZ_PCIPNP=m +CONFIG_USB_AUERISDN=m + +# +# Active ISDN cards +# +CONFIG_ISDN_DRV_ICN=m +CONFIG_ISDN_DRV_PCBIT=m +CONFIG_ISDN_DRV_SC=m +CONFIG_ISDN_DRV_ACT2000=m +CONFIG_ISDN_DRV_EICON=y +CONFIG_ISDN_DRV_EICON_DIVAS=m +CONFIG_ISDN_DRV_EICON_OLD=m +CONFIG_ISDN_DRV_EICON_PCI=y +CONFIG_ISDN_DRV_EICON_ISA=y +CONFIG_ISDN_DRV_TPAM=m +CONFIG_ISDN_CAPI=m +CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y +# CONFIG_ISDN_CAPI_MIDDLEWARE is not set +CONFIG_ISDN_CAPI_CAPI20=m +CONFIG_ISDN_CAPI_CAPIDRV=m +CONFIG_ISDN_DRV_AVMB1_B1ISA=m +CONFIG_ISDN_DRV_AVMB1_B1PCI=m +CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y +CONFIG_ISDN_DRV_AVMB1_T1ISA=m +CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m +CONFIG_ISDN_DRV_AVMB1_AVM_CS=m +CONFIG_ISDN_DRV_AVMB1_T1PCI=m +CONFIG_ISDN_DRV_AVMB1_C4=m +CONFIG_HYSDN=m +# CONFIG_HYSDN_CAPI is not set + +# +# Old CD-ROM drivers (not SCSI, not IDE) +# +CONFIG_CD_NO_IDESCSI=y +CONFIG_AZTCD=m +CONFIG_GSCD=m +CONFIG_SBPCD=m +CONFIG_MCD=m +CONFIG_MCD_IRQ=11 +CONFIG_MCD_BASE=300 +CONFIG_MCDX=m +CONFIG_OPTCD=m +CONFIG_CM206=m +CONFIG_SJCD=m +CONFIG_ISP16_CDI=m +CONFIG_CDU31A=m +CONFIG_CDU535=m + +# +# Input core support +# +CONFIG_INPUT=m +CONFIG_INPUT_KEYBDEV=m +CONFIG_INPUT_MOUSEDEV=m +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +CONFIG_INPUT_JOYDEV=m +CONFIG_INPUT_EVDEV=m +CONFIG_INPUT_UINPUT=m + +# +# Character devices +# +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_SERIAL_CONSOLE=y +CONFIG_SERIAL_EXTENDED=y +CONFIG_SERIAL_MANY_PORTS=y +CONFIG_SERIAL_SHARE_IRQ=y +# CONFIG_SERIAL_DETECT_IRQ is not set +CONFIG_SERIAL_MULTIPORT=y +CONFIG_HUB6=y +CONFIG_SERIAL_NONSTANDARD=y +CONFIG_COMPUTONE=m +CONFIG_ROCKETPORT=m +CONFIG_CYCLADES=m +# CONFIG_CYZ_INTR is not set +CONFIG_DIGIEPCA=m +CONFIG_ESPSERIAL=m +CONFIG_MOXA_INTELLIO=m +CONFIG_MOXA_SMARTIO=m +CONFIG_ISI=m +CONFIG_SYNCLINK=m +CONFIG_SYNCLINKMP=m +CONFIG_N_HDLC=m +CONFIG_RISCOM8=m +CONFIG_SPECIALIX=m +# CONFIG_SPECIALIX_RTSCTS is not set +CONFIG_SX=m +CONFIG_RIO=m +# CONFIG_RIO_OLDPCI is not set +CONFIG_STALDRV=y +CONFIG_STALLION=m +CONFIG_ISTALLION=m +CONFIG_UNIX98_PTYS=y +CONFIG_UNIX98_PTY_COUNT=512 +CONFIG_PRINTER=m +# CONFIG_LP_CONSOLE is not set +CONFIG_PPDEV=m +CONFIG_TIPAR=m + +# +# I2C support +# +CONFIG_I2C=m +CONFIG_I2C_ALGOBIT=m +CONFIG_I2C_PHILIPSPAR=m +CONFIG_I2C_ELV=m +CONFIG_I2C_VELLEMAN=m +CONFIG_SCx200_I2C=m +CONFIG_SCx200_I2C_SCL=12 +CONFIG_SCx200_I2C_SDA=13 +CONFIG_SCx200_ACB=m +CONFIG_I2C_ALGOPCF=m +CONFIG_I2C_ELEKTOR=m +CONFIG_I2C_CHARDEV=m +CONFIG_I2C_PROC=m + +# +# Mice +# +CONFIG_BUSMOUSE=m +CONFIG_ATIXL_BUSMOUSE=m +CONFIG_LOGIBUSMOUSE=m +CONFIG_MS_BUSMOUSE=m +CONFIG_MOUSE=y +CONFIG_PSMOUSE=y +CONFIG_82C710_MOUSE=m +CONFIG_PC110_PAD=m +CONFIG_MK712_MOUSE=m + +# +# Joysticks +# +CONFIG_INPUT_GAMEPORT=m +CONFIG_INPUT_NS558=m +CONFIG_INPUT_LIGHTNING=m +CONFIG_INPUT_PCIGAME=m +CONFIG_INPUT_CS461X=m +CONFIG_INPUT_EMU10K1=m +CONFIG_INPUT_SERIO=m +CONFIG_INPUT_SERPORT=m + +# +# Joysticks +# +CONFIG_INPUT_ANALOG=m +CONFIG_INPUT_A3D=m +CONFIG_INPUT_ADI=m +CONFIG_INPUT_COBRA=m +CONFIG_INPUT_GF2K=m +CONFIG_INPUT_GRIP=m +CONFIG_INPUT_INTERACT=m +CONFIG_INPUT_TMDC=m +CONFIG_INPUT_SIDEWINDER=m +CONFIG_INPUT_IFORCE_USB=m +CONFIG_INPUT_IFORCE_232=m +CONFIG_INPUT_WARRIOR=m +CONFIG_INPUT_MAGELLAN=m +CONFIG_INPUT_SPACEORB=m +CONFIG_INPUT_SPACEBALL=m +CONFIG_INPUT_STINGER=m +CONFIG_INPUT_DB9=m +CONFIG_INPUT_GAMECON=m +CONFIG_INPUT_TURBOGRAFX=m +CONFIG_QIC02_TAPE=m +# CONFIG_QIC02_DYNCONF is not set + +# +# Edit configuration parameters in ./include/linux/tpqic02.h! +# +CONFIG_IPMI_HANDLER=m +# CONFIG_IPMI_PANIC_EVENT is not set +CONFIG_IPMI_DEVICE_INTERFACE=m +CONFIG_IPMI_KCS=m +CONFIG_IPMI_WATCHDOG=m + +# +# Watchdog Cards +# +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set +CONFIG_ACQUIRE_WDT=m +CONFIG_ADVANTECH_WDT=m +CONFIG_ALIM1535_WDT=m +CONFIG_ALIM7101_WDT=m +CONFIG_SC520_WDT=m +CONFIG_PCWATCHDOG=m +CONFIG_EUROTECH_WDT=m +CONFIG_IB700_WDT=m +CONFIG_WAFER_WDT=m +CONFIG_I810_TCO=m +CONFIG_MIXCOMWD=m +CONFIG_60XX_WDT=m +CONFIG_SC1200_WDT=m +CONFIG_SCx200_WDT=m +CONFIG_SOFT_WATCHDOG=m +CONFIG_W83877F_WDT=m +CONFIG_WDT=m +CONFIG_WDTPCI=m +CONFIG_WDT_501=y +CONFIG_WDT_501_FAN=y +CONFIG_MACHZ_WDT=m +CONFIG_AMD7XX_TCO=m +CONFIG_SCx200=m +CONFIG_SCx200_GPIO=m +CONFIG_AMD_RNG=m +CONFIG_INTEL_RNG=m +CONFIG_HW_RANDOM=m +CONFIG_AMD_PM768=m +CONFIG_NVRAM=m +CONFIG_RTC=y +CONFIG_DTLK=m +CONFIG_R3964=m +CONFIG_APPLICOM=m +CONFIG_SONYPI=m + +# +# Ftape, the floppy tape device driver +# +CONFIG_FTAPE=m +CONFIG_ZFTAPE=m +CONFIG_ZFT_DFLT_BLK_SZ=10240 + +# +# The compressor will be built as a module only! +# +CONFIG_ZFT_COMPRESSOR=m +CONFIG_FT_NR_BUFFERS=3 +# CONFIG_FT_PROC_FS is not set +CONFIG_FT_NORMAL_DEBUG=y +# CONFIG_FT_FULL_DEBUG is not set +# CONFIG_FT_NO_TRACE is not set +# CONFIG_FT_NO_TRACE_AT_ALL is not set + +# +# Hardware configuration +# +CONFIG_FT_STD_FDC=y +# CONFIG_FT_MACH2 is not set +# CONFIG_FT_PROBE_FC10 is not set +# CONFIG_FT_ALT_FDC is not set +CONFIG_FT_FDC_THR=8 +CONFIG_FT_FDC_MAX_RATE=2000 +CONFIG_FT_ALPHA_CLOCK=0 +CONFIG_AGP=m +CONFIG_AGP_INTEL=y +CONFIG_AGP_I810=y +CONFIG_AGP_VIA=y +CONFIG_AGP_AMD=y +CONFIG_AGP_AMD_K8=y +CONFIG_AGP_SIS=y +CONFIG_AGP_ALI=y +CONFIG_AGP_SWORKS=y +CONFIG_AGP_NVIDIA=y +CONFIG_AGP_ATI=y + +# +# Direct Rendering Manager (XFree86 DRI support) +# +CONFIG_DRM=y +# CONFIG_DRM_OLD is not set + +# +# DRM 4.1 drivers +# +CONFIG_DRM_NEW=y +CONFIG_DRM_TDFX=m +CONFIG_DRM_GAMMA=m +CONFIG_DRM_R128=m +CONFIG_DRM_RADEON=m +CONFIG_DRM_I810=m +# CONFIG_DRM_I810_XFREE_41 is not set +CONFIG_DRM_I830=m +CONFIG_DRM_MGA=m +CONFIG_DRM_SIS=m + +# +# PCMCIA character devices +# +CONFIG_PCMCIA_SERIAL_CS=m +CONFIG_SYNCLINK_CS=m +CONFIG_MWAVE=m +CONFIG_OBMOUSE=m + +# +# Multimedia devices +# +CONFIG_VIDEO_DEV=m + +# +# Video For Linux +# +CONFIG_VIDEO_PROC_FS=y +CONFIG_I2C_PARPORT=m + +# +# Video Adapters +# +CONFIG_VIDEO_BT848=m +CONFIG_VIDEO_PMS=m +CONFIG_VIDEO_BWQCAM=m +CONFIG_VIDEO_CQCAM=m +CONFIG_VIDEO_W9966=m +CONFIG_VIDEO_CPIA=m +CONFIG_VIDEO_CPIA_PP=m +CONFIG_VIDEO_CPIA_USB=m +CONFIG_VIDEO_SAA5249=m +CONFIG_TUNER_3036=m +CONFIG_VIDEO_STRADIS=m +CONFIG_VIDEO_ZORAN=m +CONFIG_VIDEO_ZORAN_BUZ=m +CONFIG_VIDEO_ZORAN_DC10=m +CONFIG_VIDEO_ZORAN_LML33=m +CONFIG_VIDEO_ZR36120=m +CONFIG_VIDEO_MEYE=m + +# +# Radio Adapters +# +CONFIG_RADIO_CADET=m +CONFIG_RADIO_RTRACK=m +CONFIG_RADIO_RTRACK2=m +CONFIG_RADIO_AZTECH=m +CONFIG_RADIO_GEMTEK=m +CONFIG_RADIO_GEMTEK_PCI=m +CONFIG_RADIO_MAXIRADIO=m +CONFIG_RADIO_MAESTRO=m +CONFIG_RADIO_MIROPCM20=m +CONFIG_RADIO_MIROPCM20_RDS=m +CONFIG_RADIO_SF16FMI=m +CONFIG_RADIO_SF16FMR2=m +CONFIG_RADIO_TERRATEC=m +CONFIG_RADIO_TRUST=m +CONFIG_RADIO_TYPHOON=m +CONFIG_RADIO_TYPHOON_PROC_FS=y +CONFIG_RADIO_ZOLTRIX=m + +# +# File systems +# +CONFIG_QUOTA=y +CONFIG_QFMT_V2=m +CONFIG_AUTOFS_FS=m +CONFIG_AUTOFS4_FS=m +CONFIG_REISERFS_FS=y +# CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_PROC_INFO is not set +# CONFIG_ADFS_FS is not set +# CONFIG_ADFS_FS_RW is not set +# CONFIG_AFFS_FS is not set +CONFIG_HFS_FS=m +CONFIG_HFSPLUS_FS=m +CONFIG_BEFS_FS=m +# CONFIG_BEFS_DEBUG is not set +# CONFIG_BFS_FS is not set +CONFIG_EXT3_FS=y +CONFIG_JBD=y +# CONFIG_JBD_DEBUG is not set +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_UMSDOS_FS=y +CONFIG_VFAT_FS=y +# CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set +# CONFIG_JFFS2_FS is not set +CONFIG_CRAMFS=m +CONFIG_TMPFS=y +CONFIG_RAMFS=y +CONFIG_ISO9660_FS=y +CONFIG_JOLIET=y +CONFIG_ZISOFS=y +CONFIG_JFS_FS=m +# CONFIG_JFS_DEBUG is not set +# CONFIG_JFS_STATISTICS is not set +CONFIG_MINIX_FS=m +CONFIG_VXFS_FS=m +CONFIG_NTFS_FS=m +# CONFIG_NTFS_RW is not set +CONFIG_HPFS_FS=m +CONFIG_PROC_FS=y +# CONFIG_DEVFS_FS is not set +# CONFIG_DEVFS_MOUNT is not set +# CONFIG_DEVFS_DEBUG is not set +CONFIG_DEVPTS_FS=y +CONFIG_QNX4FS_FS=m +# CONFIG_QNX4FS_RW is not set +# CONFIG_ROMFS_FS is not set +CONFIG_EXT2_FS=y +CONFIG_SYSV_FS=m +CONFIG_UDF_FS=m +# CONFIG_UDF_RW is not set +CONFIG_UFS_FS=m +CONFIG_UFS_FS_WRITE=y +CONFIG_XFS_FS=m +CONFIG_XFS_QUOTA=y +# CONFIG_XFS_RT is not set +# CONFIG_XFS_TRACE is not set +# CONFIG_XFS_DEBUG is not set + +# +# Network File Systems +# +CONFIG_CODA_FS=m +CONFIG_INTERMEZZO_FS=m +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +# CONFIG_NFS_DIRECTIO is not set +# CONFIG_ROOT_NFS is not set +CONFIG_NFSD=m +CONFIG_NFSD_V3=y +# CONFIG_NFSD_TCP is not set +CONFIG_SUNRPC=y +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_SMB_FS=m +# CONFIG_SMB_NLS_DEFAULT is not set +CONFIG_SMB_UNIX=y +CONFIG_NCP_FS=m +# CONFIG_NCPFS_PACKET_SIGNING is not set +# CONFIG_NCPFS_IOCTL_LOCKING is not set +CONFIG_NCPFS_STRONG=y +CONFIG_NCPFS_NFS_NS=y +CONFIG_NCPFS_OS2_NS=y +# CONFIG_NCPFS_SMALLDOS is not set +# CONFIG_NCPFS_NLS is not set +# CONFIG_NCPFS_EXTRAS is not set +CONFIG_ZISOFS_FS=y + +# +# Partition Types +# +CONFIG_PARTITION_ADVANCED=y +# CONFIG_ACORN_PARTITION is not set +# CONFIG_OSF_PARTITION is not set +# CONFIG_AMIGA_PARTITION is not set +# CONFIG_ATARI_PARTITION is not set +CONFIG_MAC_PARTITION=y +CONFIG_MSDOS_PARTITION=y +CONFIG_BSD_DISKLABEL=y +# CONFIG_MINIX_SUBPARTITION is not set +# CONFIG_SOLARIS_X86_PARTITION is not set +# CONFIG_UNIXWARE_DISKLABEL is not set +# CONFIG_LDM_PARTITION is not set +# CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set +# CONFIG_SUN_PARTITION is not set +# CONFIG_EFI_PARTITION is not set +CONFIG_SMB_NLS=y +CONFIG_NLS=y + +# +# Native Language Support +# +CONFIG_NLS_DEFAULT="cp437" +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_CODEPAGE_737=m +CONFIG_NLS_CODEPAGE_775=m +CONFIG_NLS_CODEPAGE_850=m +CONFIG_NLS_CODEPAGE_852=m +CONFIG_NLS_CODEPAGE_855=m +CONFIG_NLS_CODEPAGE_857=m +CONFIG_NLS_CODEPAGE_860=m +CONFIG_NLS_CODEPAGE_861=m +CONFIG_NLS_CODEPAGE_862=m +CONFIG_NLS_CODEPAGE_863=m +CONFIG_NLS_CODEPAGE_864=m +CONFIG_NLS_CODEPAGE_865=m +CONFIG_NLS_CODEPAGE_866=m +CONFIG_NLS_CODEPAGE_869=m +CONFIG_NLS_CODEPAGE_936=m +CONFIG_NLS_CODEPAGE_950=m +CONFIG_NLS_CODEPAGE_932=m +CONFIG_NLS_CODEPAGE_949=m +CONFIG_NLS_CODEPAGE_874=m +CONFIG_NLS_ISO8859_8=m +CONFIG_NLS_CODEPAGE_1250=m +CONFIG_NLS_CODEPAGE_1251=m +CONFIG_NLS_ISO8859_1=y +CONFIG_NLS_ISO8859_2=m +CONFIG_NLS_ISO8859_3=m +CONFIG_NLS_ISO8859_4=m +CONFIG_NLS_ISO8859_5=m +CONFIG_NLS_ISO8859_6=m +CONFIG_NLS_ISO8859_7=m +CONFIG_NLS_ISO8859_9=m +CONFIG_NLS_ISO8859_13=m +CONFIG_NLS_ISO8859_14=m +CONFIG_NLS_ISO8859_15=m +CONFIG_NLS_KOI8_R=m +CONFIG_NLS_KOI8_U=m +CONFIG_NLS_UTF8=m + +# +# Console drivers +# +CONFIG_VGA_CONSOLE=y +CONFIG_VIDEO_SELECT=y +# CONFIG_MDA_CONSOLE is not set + +# +# Frame-buffer support +# +CONFIG_FB=y +CONFIG_DUMMY_CONSOLE=y +CONFIG_FB_RIVA=m +CONFIG_FB_CLGEN=m +CONFIG_FB_PM2=m +# CONFIG_FB_PM2_FIFO_DISCONNECT is not set +CONFIG_FB_PM2_PCI=y +CONFIG_FB_PM3=m +CONFIG_FB_CYBER2000=m +CONFIG_FB_VESA=y +CONFIG_FB_VGA16=m +CONFIG_FB_HGA=m +CONFIG_VIDEO_SELECT=y +CONFIG_FB_MATROX=m +CONFIG_FB_MATROX_MILLENIUM=y +CONFIG_FB_MATROX_MYSTIQUE=y +CONFIG_FB_MATROX_G450=y +CONFIG_FB_MATROX_G100=y +CONFIG_FB_MATROX_I2C=m +CONFIG_FB_MATROX_MAVEN=m +CONFIG_FB_MATROX_PROC=m +CONFIG_FB_MATROX_MULTIHEAD=y +CONFIG_FB_ATY=m +CONFIG_FB_ATY_GX=y +CONFIG_FB_ATY_CT=y +CONFIG_FB_ATY_GENERIC_LCD=y +CONFIG_FB_RADEON=m +CONFIG_FB_ATY128=m +CONFIG_FB_INTEL=m +CONFIG_FB_SIS=m +CONFIG_FB_SIS_300=y +CONFIG_FB_SIS_315=y +CONFIG_FB_NEOMAGIC=m +CONFIG_FB_3DFX=m +CONFIG_FB_VOODOO1=m +CONFIG_FB_TRIDENT=m +CONFIG_FB_IT8181=m +# CONFIG_FB_VIRTUAL is not set +CONFIG_FBCON_ADVANCED=y +CONFIG_FBCON_MFB=m +CONFIG_FBCON_CFB2=m +CONFIG_FBCON_CFB4=m +CONFIG_FBCON_CFB8=y +CONFIG_FBCON_CFB16=y +CONFIG_FBCON_CFB24=y +CONFIG_FBCON_CFB32=y +# CONFIG_FBCON_AFB is not set +# CONFIG_FBCON_ILBM is not set +# CONFIG_FBCON_IPLAN2P2 is not set +# CONFIG_FBCON_IPLAN2P4 is not set +# CONFIG_FBCON_IPLAN2P8 is not set +# CONFIG_FBCON_MAC is not set +# CONFIG_FBCON_VGA_PLANES is not set +CONFIG_FBCON_VGA=y +CONFIG_FBCON_HGA=m +# CONFIG_FBCON_FONTWIDTH8_ONLY is not set +CONFIG_FBCON_FONTS=y +CONFIG_FONT_8x8=y +CONFIG_FONT_8x16=y +# CONFIG_FONT_SUN8x16 is not set +# CONFIG_FONT_SUN12x22 is not set +# CONFIG_FONT_6x11 is not set +# CONFIG_FONT_PEARL_8x8 is not set +# CONFIG_FONT_ACORN_8x8 is not set + +# +# Sound +# +CONFIG_SOUND=m +CONFIG_SOUND_ALI5455=m +CONFIG_SOUND_ALI5455_CODECSPDIFOUT_PCMOUTSHARE=y +CONFIG_SOUND_ALI5455_CODECSPDIFOUT_CODECINDEPENDENTDMA=y +CONFIG_SOUND_ALI5455_CONTROLLERSPDIFOUT_PCMOUTSHARE=y +CONFIG_SOUND_ALI5455_CONTROLLERSPDIFOUT_CONTROLLERINDEPENDENTDMA=y +CONFIG_SOUND_BT878=m +CONFIG_SOUND_CMPCI=m +# CONFIG_SOUND_CMPCI_FM is not set +# CONFIG_SOUND_CMPCI_MIDI is not set +CONFIG_SOUND_CMPCI_JOYSTICK=y +CONFIG_SOUND_CMPCI_CM8738=y +# CONFIG_SOUND_CMPCI_SPDIFINVERSE is not set +CONFIG_SOUND_CMPCI_SPDIFLOOP=y +CONFIG_SOUND_CMPCI_SPEAKERS=2 +CONFIG_SOUND_EMU10K1=m +CONFIG_MIDI_EMU10K1=y +CONFIG_SOUND_FUSION=m +CONFIG_SOUND_CS4281=m +CONFIG_SOUND_ES1370=m +CONFIG_SOUND_ES1371=m +CONFIG_SOUND_ESSSOLO1=m +CONFIG_SOUND_MAESTRO=m +CONFIG_SOUND_MAESTRO3=m +CONFIG_SOUND_FORTE=m +CONFIG_SOUND_ICH=m +CONFIG_SOUND_RME96XX=m +CONFIG_SOUND_SONICVIBES=m +CONFIG_SOUND_TRIDENT=m +CONFIG_SOUND_MSNDCLAS=m +# CONFIG_MSNDCLAS_HAVE_BOOT is not set +CONFIG_MSNDCLAS_INIT_FILE="/etc/sound/msndinit.bin" +CONFIG_MSNDCLAS_PERM_FILE="/etc/sound/msndperm.bin" +CONFIG_SOUND_MSNDPIN=m +# CONFIG_MSNDPIN_HAVE_BOOT is not set +CONFIG_MSNDPIN_INIT_FILE="/etc/sound/pndspini.bin" +CONFIG_MSNDPIN_PERM_FILE="/etc/sound/pndsperm.bin" +CONFIG_SOUND_VIA82CXXX=m +# CONFIG_MIDI_VIA82CXXX is not set +CONFIG_SOUND_OSS=m +# CONFIG_SOUND_TRACEINIT is not set +# CONFIG_SOUND_DMAP is not set +CONFIG_SOUND_AD1816=m +CONFIG_SOUND_AD1889=m +CONFIG_SOUND_SGALAXY=m +CONFIG_SOUND_ADLIB=m +CONFIG_SOUND_ACI_MIXER=m +CONFIG_SOUND_CS4232=m +CONFIG_SOUND_SSCAPE=m +CONFIG_SOUND_GUS=m +# CONFIG_SOUND_GUS16 is not set +# CONFIG_SOUND_GUSMAX is not set +CONFIG_SOUND_VMIDI=m +CONFIG_SOUND_TRIX=m +CONFIG_SOUND_MSS=m +CONFIG_SOUND_MPU401=m +CONFIG_SOUND_NM256=m +CONFIG_SOUND_MAD16=m +# CONFIG_MAD16_OLDCARD is not set +CONFIG_SOUND_PAS=m +# CONFIG_PAS_JOYSTICK is not set +CONFIG_SOUND_PSS=m +# CONFIG_PSS_MIXER is not set +# CONFIG_PSS_HAVE_BOOT is not set +CONFIG_SOUND_SB=m +CONFIG_SOUND_AWE32_SYNTH=m +CONFIG_SOUND_KAHLUA=m +CONFIG_SOUND_WAVEFRONT=m +CONFIG_SOUND_MAUI=m +CONFIG_SOUND_YM3812=m +CONFIG_SOUND_OPL3SA1=m +CONFIG_SOUND_OPL3SA2=m +CONFIG_SOUND_YMFPCI=m +# CONFIG_SOUND_YMFPCI_LEGACY is not set +CONFIG_SOUND_UART6850=m +CONFIG_SOUND_AEDSP16=m +CONFIG_SC6600=y +CONFIG_SC6600_JOY=y +CONFIG_SC6600_CDROM=4 +CONFIG_SC6600_CDROMBASE=0 +CONFIG_AEDSP16_SBPRO=y +CONFIG_AEDSP16_MPU401=y +CONFIG_SOUND_TVMIXER=m +CONFIG_SOUND_AD1980=m +CONFIG_SOUND_WM97XX=m + +# +# USB support +# +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +# CONFIG_USB_BANDWIDTH is not set + +# +# USB Host Controller Drivers +# +CONFIG_USB_EHCI_HCD=m +CONFIG_USB_UHCI=m +CONFIG_USB_UHCI_ALT=m +CONFIG_USB_OHCI=m +CONFIG_USB_SL811HS_ALT=m +CONFIG_USB_SL811HS=m + +# +# USB Device Class drivers +# +CONFIG_USB_AUDIO=m +CONFIG_USB_EMI26=m + +# +# USB Bluetooth can only be used with disabled Bluetooth subsystem +# +CONFIG_USB_MIDI=m +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +CONFIG_USB_STORAGE_DATAFAB=y +CONFIG_USB_STORAGE_FREECOM=y +CONFIG_USB_STORAGE_ISD200=y +CONFIG_USB_STORAGE_DPCM=y +CONFIG_USB_STORAGE_HP8200e=y +CONFIG_USB_STORAGE_SDDR09=y +CONFIG_USB_STORAGE_SDDR55=y +CONFIG_USB_STORAGE_JUMPSHOT=y +CONFIG_USB_ACM=m +CONFIG_USB_PRINTER=m + +# +# USB Human Interface Devices (HID) +# +CONFIG_USB_HID=m +CONFIG_USB_HIDINPUT=y +CONFIG_USB_HIDDEV=y +CONFIG_USB_KBD=m +CONFIG_USB_MOUSE=m +CONFIG_USB_AIPTEK=m +CONFIG_USB_WACOM=m +CONFIG_USB_KBTAB=m +CONFIG_USB_POWERMATE=m + +# +# USB Imaging devices +# +CONFIG_USB_DC2XX=m +CONFIG_USB_MDC800=m +CONFIG_USB_SCANNER=m +CONFIG_USB_MICROTEK=m +CONFIG_USB_HPUSBSCSI=m + +# +# USB Multimedia devices +# +CONFIG_USB_IBMCAM=m +CONFIG_USB_KONICAWC=m +CONFIG_USB_OV511=m +CONFIG_USB_PWC=m +CONFIG_USB_SE401=m +CONFIG_USB_STV680=m +CONFIG_USB_W9968CF=m +CONFIG_USB_VICAM=m +CONFIG_USB_DSBR=m +CONFIG_USB_DABUSB=m + +# +# USB Network adaptors +# +CONFIG_USB_PEGASUS=m +CONFIG_USB_RTL8150=m +CONFIG_USB_KAWETH=m +CONFIG_USB_CATC=m +CONFIG_USB_CDCETHER=m +CONFIG_USB_USBNET=m + +# +# USB port drivers +# +CONFIG_USB_USS720=m + +# +# USB Serial Converter support +# +CONFIG_USB_SERIAL=m +# CONFIG_USB_SERIAL_DEBUG is not set +CONFIG_USB_SERIAL_GENERIC=y +CONFIG_USB_SERIAL_BELKIN=m +CONFIG_USB_SERIAL_WHITEHEAT=m +CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m +CONFIG_USB_SERIAL_EMPEG=m +CONFIG_USB_SERIAL_FTDI_SIO=m +CONFIG_USB_SERIAL_VISOR=m +CONFIG_USB_SERIAL_IPAQ=m +CONFIG_USB_SERIAL_IR=m +CONFIG_USB_SERIAL_EDGEPORT=m +CONFIG_USB_SERIAL_EDGEPORT_TI=m +CONFIG_USB_SERIAL_KEYSPAN_PDA=m +CONFIG_USB_SERIAL_KEYSPAN=m +CONFIG_USB_SERIAL_KEYSPAN_USA28=y +CONFIG_USB_SERIAL_KEYSPAN_USA28X=y +CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y +CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y +CONFIG_USB_SERIAL_KEYSPAN_USA19=y +CONFIG_USB_SERIAL_KEYSPAN_USA18X=y +CONFIG_USB_SERIAL_KEYSPAN_USA19W=y +CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y +CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y +CONFIG_USB_SERIAL_KEYSPAN_MPR=y +CONFIG_USB_SERIAL_KEYSPAN_USA49W=y +CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y +CONFIG_USB_SERIAL_MCT_U232=m +CONFIG_USB_SERIAL_KLSI=m +CONFIG_USB_SERIAL_KOBIL_SCT=m +CONFIG_USB_SERIAL_PL2303=m +CONFIG_USB_SERIAL_CYBERJACK=m +CONFIG_USB_SERIAL_XIRCOM=m +CONFIG_USB_SERIAL_OMNINET=m + +# +# USB Miscellaneous drivers +# +CONFIG_USB_RIO500=m +CONFIG_USB_AUERSWALD=m +CONFIG_USB_TIGL=m +CONFIG_USB_BRLVGER=m +CONFIG_USB_LCD=m + +# +# Support for USB gadgets +# +# CONFIG_USB_GADGET is not set + +# +# Bluetooth support +# +CONFIG_BLUEZ=m +CONFIG_BLUEZ_L2CAP=m +CONFIG_BLUEZ_SCO=m +CONFIG_BLUEZ_RFCOMM=m +CONFIG_BLUEZ_RFCOMM_TTY=y +CONFIG_BLUEZ_BNEP=m +CONFIG_BLUEZ_BNEP_MC_FILTER=y +CONFIG_BLUEZ_BNEP_PROTO_FILTER=y +CONFIG_BLUEZ_CMTP=m + +# +# Bluetooth device drivers +# +CONFIG_BLUEZ_HCIUSB=m +CONFIG_BLUEZ_HCIUSB_SCO=y +CONFIG_BLUEZ_HCIUART=m +CONFIG_BLUEZ_HCIUART_H4=y +CONFIG_BLUEZ_HCIUART_BCSP=y +CONFIG_BLUEZ_HCIUART_BCSP_TXCRC=y +CONFIG_BLUEZ_HCIBFUSB=m +CONFIG_BLUEZ_HCIDTL1=m +CONFIG_BLUEZ_HCIBT3C=m +CONFIG_BLUEZ_HCIBLUECARD=m +CONFIG_BLUEZ_HCIBTUART=m +CONFIG_BLUEZ_HCIVHCI=m + +# +# Kernel hacking +# +# CONFIG_DEBUG_KERNEL is not set +CONFIG_LOG_BUF_SHIFT=0 + +# +# Cryptographic options +# +CONFIG_CRYPTO=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_NULL=m +CONFIG_CRYPTO_MD4=m +CONFIG_CRYPTO_MD5=m +CONFIG_CRYPTO_SHA1=m +CONFIG_CRYPTO_SHA256=m +CONFIG_CRYPTO_SHA512=m +CONFIG_CRYPTO_DES=m +CONFIG_CRYPTO_BLOWFISH=m +CONFIG_CRYPTO_TWOFISH=m +CONFIG_CRYPTO_SERPENT=m +CONFIG_CRYPTO_AES=m +CONFIG_CRYPTO_CAST5=m +CONFIG_CRYPTO_CAST6=m +CONFIG_CRYPTO_ARC4=m +CONFIG_CRYPTO_DEFLATE=m +CONFIG_CRYPTO_TEST=m + +# +# Library routines +# +CONFIG_CRC32=m +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=m +CONFIG_FW_LOADER=m diff --git a/linux/ddd-3.3.10.tar.gz b/linux/ddd-3.3.10.tar.gz new file mode 100755 index 0000000..dd32441 --- /dev/null +++ b/linux/ddd-3.3.10.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e1b986d4719c393eab6bc1366ee274608cc7432c0776c4b0c0e162f8175af7b +size 7620458 diff --git a/linux/lc b/linux/lc new file mode 100755 index 0000000..ea2f1c5 Binary files /dev/null and b/linux/lc differ diff --git a/linux/stg b/linux/stg new file mode 100755 index 0000000..40b16ea Binary files /dev/null and b/linux/stg differ diff --git a/linux/stw b/linux/stw new file mode 100755 index 0000000..889bb53 Binary files /dev/null and b/linux/stw differ diff --git a/linux/vssver.scc b/linux/vssver.scc new file mode 100755 index 0000000..e68ba30 Binary files /dev/null and b/linux/vssver.scc differ diff --git a/linux/xinitgame b/linux/xinitgame new file mode 100755 index 0000000..40ddf28 Binary files /dev/null and b/linux/xinitgame differ diff --git a/linux/xinitrc b/linux/xinitrc new file mode 100755 index 0000000..1dd1731 Binary files /dev/null and b/linux/xinitrc differ diff --git a/linux/xorg.conf b/linux/xorg.conf new file mode 100755 index 0000000..2fd0950 Binary files /dev/null and b/linux/xorg.conf differ diff --git a/makefile b/makefile new file mode 100755 index 0000000..d18ed30 --- /dev/null +++ b/makefile @@ -0,0 +1,81 @@ +# makefile -- gnu make +# MAN 28 Dec 06 + +# idea is to build from the PC directory structure into D1 + +H1=. +D1=./linux/tmp + +S1=./dond/core +OBJ1=$(D1)/cab.o $(D1)/cam.o $(D1)/fc.o $(D1)/fs.o $(D1)/ftp.o $(D1)/gun.o \ + $(D1)/inp.o $(D1)/mem.o $(D1)/mem_data.o $(D1)/obj.o $(D1)/proc.o \ + $(D1)/res.o $(D1)/snd.o $(D1)/str.o $(D1)/sys.o \ + $(D1)/theorafunc.o $(D1)/vec.o + +S2=./dond/corebb +OBJ2=$(D1)/int_bb.o $(D1)/main_bb.o $(D1)/sys_bb.o $(D1)/wnd_bb.o + +S3=./dond/coregl +OBJ3=$(D1)/diag_gl.o $(D1)/draw_gl.o $(D1)/fb_gl.o $(D1)/font_gl.o $(D1)/fs_gl.o \ + $(D1)/net_gl.o $(D1)/obj_gl.o $(D1)/res_gl.o $(D1)/vid_gl.o + +S4=./dond/game +OBJ4=$(D1)/at.o $(D1)/aud.o $(D1)/credits.o \ + $(D1)/currency.o $(D1)/diag.o $(D1)/dond.o \ + $(D1)/fcfunc.o $(D1)/game.o $(D1)/gcon.o $(D1)/m.o \ + $(D1)/text3d.o $(D1)/dond_lpt.o $(D1)/donglecheck.o + +# OBJ4B is a list of game files that should not be added to the game library +# as they are intended to be built by outside groups +OBJ4B=$(D1)/prts_interface.o $(D1)/prts_msg.o $(D1)/prts_utils.o +buildall=$(D1)/game + +#CFLAGS=-g -DSYS_BB -DSYS_GL -DDEBUG +#CFLAGS=-DSYS_BB -DSYS_GL -DDEBUG +CFLAGS=-DSYS_BB -DSYS_GL -DPRODUCTION +CFLAGS+=-O3 +CFLAGS+=-Wno-sign-compare -Wno-conversion -Wno-missing-prototypes +CFLAGS+=-I $(H1)/dond/core -I $(H1)/dond/game -I $(H1)/dond/game/ogginclude -I $(H1)/lib +CFLAGS+=-I /usr/X11/include -I /usr/local/include +CFLAGS+=-I /g3/include +CC=gcc + +LD=gcc --mode=link +LFLAGS=-L/usr/X11/lib -lGL -lGLU -lglut -lpthread -lrt +LIBS=$(H1)/lib/librockeyapi.a $(H1)/lib/libjps.a $(H1)/lib/libjamma.a \ + $(H1)/ogglibs/libtheora.so.0.1.0 $(H1)/ogglibs/libogg.so.0.5.2 +LIBS+=$(H1)/lib/libusb.a $(H1)/lib/libpmrt_utils.a + +# library name for game +TARGETLIB = $(D1)/libgame.a + +$(D1)/game: $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ4B) $(LIBS) + $(LD) $(LFLAGS) $^ -o $@ + cp $(D1)/game . + +$(D1)/%.o : $(S1)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(D1)/%.o : $(S2)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(D1)/%.o : $(S3)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +$(D1)/%.o : $(S4)/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +.PHONY: all clean + +all: $(buildall) + +clean: + rm $(D1)/*.o + + +# lib target makes the game objects an archive +lib: $(TARGETLIB) + +$(TARGETLIB) : $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) + ar rs $(TARGETLIB) $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) + cp $(TARGETLIB) ./lib diff --git a/ogglibs/libogg.so.0.5.2 b/ogglibs/libogg.so.0.5.2 new file mode 100755 index 0000000..7370d93 Binary files /dev/null and b/ogglibs/libogg.so.0.5.2 differ diff --git a/ogglibs/libtheora.so.0.1.0 b/ogglibs/libtheora.so.0.1.0 new file mode 100755 index 0000000..b93263a Binary files /dev/null and b/ogglibs/libtheora.so.0.1.0 differ diff --git a/ogglibs/libvorbis.so.0.3.0 b/ogglibs/libvorbis.so.0.3.0 new file mode 100755 index 0000000..548d717 Binary files /dev/null and b/ogglibs/libvorbis.so.0.3.0 differ diff --git a/ogglibs/libvorbisenc.so.2.0.0 b/ogglibs/libvorbisenc.so.2.0.0 new file mode 100755 index 0000000..808a7bb Binary files /dev/null and b/ogglibs/libvorbisenc.so.2.0.0 differ diff --git a/ogglibs/libvorbisfile.so.3.1.0 b/ogglibs/libvorbisfile.so.3.1.0 new file mode 100755 index 0000000..26bdc37 Binary files /dev/null and b/ogglibs/libvorbisfile.so.3.1.0 differ diff --git a/recovery.log b/recovery.log new file mode 100644 index 0000000..0fe1a43 --- /dev/null +++ b/recovery.log @@ -0,0 +1,3030 @@ +####### Pass 0 ####### +3874 directory entries were hashed with "r5" hash. +####### Pass 1 ####### +####### Pass 2 ####### +vpf-10260: The file we are inserting the new item (7277 10854 0x1 IND (1), len 52, location 4044 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5470 5995 0x1 IND (1), len 3936, location 160 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5470 5999 0x1 IND (1), len 2852, location 1244 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5470 6032 0x1 IND (1), len 2888, location 1208 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (25 855 0xde1 DRCT (2), len 272, location 3824 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (25 1854 0x79 DRCT (2), len 1512, location 2584 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (25 1858 0x1 DRCT (2), len 1968, location 2128 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5470 6063 0x1 IND (1), len 3568, location 528 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5470 6069 0x1 IND (1), len 3216, location 880 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (7349 7351 0x189 DRCT (2), len 3080, location 1016 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (11645 11686 0x1 DRCT (2), len 880, location 3216 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (2138 2401 0x559 DRCT (2), len 2048, location 2048 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (2204 3096 0x1 DRCT (2), len 1032, location 3064 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (3166 3176 0x8e9 DRCT (2), len 8, location 4088 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (2130 3346 0x289 DRCT (2), len 728, location 3368 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (7285 7296 0x479 DRCT (2), len 1424, location 2672 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (6240 7434 0x1b6001 IND (1), len 204, location 3892 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (7258 7288 0xb9 DRCT (2), len 3696, location 400 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (9816 9818 0x1af001 IND (1), len 3152, location 944 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (6472 6506 0x69 DRCT (2), len 1288, location 2808 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (4355 4562 0x1 IND (1), len 3080, location 1016 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (10289 10337 0x1 DRCT (2), len 2848, location 1248 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (6241 10774 0x211 DRCT (2), len 488, location 3608 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5860 5914 0x374001 IND (1), len 1588, location 2508 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5860 6022 0x1 IND (1), len 2944, location 1152 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (10220 10268 0x891 DRCT (2), len 608, location 3488 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5860 6077 0x1 IND (1), len 3512, location 584 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (5860 6086 0x1 IND (1), len 3224, location 872 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (9021 9023 0x1 IND (1), len 844, location 3252 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (9371 9380 0x1 DRCT (2), len 960, location 3136 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (10044 10046 0x2e1001 IND (1), len 1784, location 2312 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (10044 10050 0x2c2001 IND (1), len 336, location 3760 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (10044 10046 0x1 IND (1), len 2948, location 1148 entry count 0, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (7363 10765 0x1 DRCT (2), len 1152, location 2944 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +vpf-10260: The file we are inserting the new item (6182 6183 0x1e9 DRCT (2), len 1920, location 2176 entry count 65535, fsck need 0, format new) into has no StatData, insertion was skipped +####### Pass 3 ######### +rebuild_semantic_pass: The entry [6238 6240] ("libxml2.a") in directory [2 6238] points to nowhere - is removed +vpf-10650: The directory [2 6238] has the wrong size in the StatData (1384) - corrected to (1352) +vpf-10650: The directory [2 1226] has the wrong size in the StatData (48) - corrected to (104) +vpf-10680: The file [2 10212] has the wrong block count in the StatData (1824) - corrected to (0) +rebuild_semantic_pass: The entry [5889 5901] ("vssver.scc") in directory [2 5889] points to nowhere - is removed +vpf-10680: The file [5945 6074] has the wrong block count in the StatData (2056) - corrected to (1200) +vpf-10680: The file [10130 10841] has the wrong block count in the StatData (104) - corrected to (0) +vpf-10680: The file [10130 10849] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [10130 10818] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [10130 10843] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [10130 10850] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [10130 10820] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10130 10847] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [10130 10822] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [10130 10823] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10130 10825] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [10130 10827] has the wrong block count in the StatData (168) - corrected to (0) +vpf-10680: The file [10130 10832] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [10130 10833] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [10130 10835] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [10130 10839] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10130 10840] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10130 10853] has the wrong block count in the StatData (368) - corrected to (16) +vpf-10680: The file [10130 10838] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10130 10846] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [10130 10851] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10130 10834] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [10130 10837] has the wrong block count in the StatData (24) - corrected to (0) +rebuild_semantic_pass: The entry [6866 7378] ("makefile") in directory [6866 7343] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 7382] ("Release") in directory [6866 7343] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 7375] ("jps_snd.c") in directory [6866 7343] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 7376] ("jps_snd.h") in directory [6866 7343] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 7379] ("mssccprj.scc") in directory [6866 7343] points to nowhere - is removed +vpf-10680: The file [6866 7374] has the wrong block count in the StatData (8) - corrected to (0) +rebuild_semantic_pass: The entry [6866 7377] ("jps_volume.h") in directory [6866 7343] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 7381] ("vssver.scc") in directory [6866 7343] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 7380] ("volume convert.xls") in directory [6866 7343] points to nowhere - is removed +vpf-10650: The directory [6866 7343] has the wrong size in the StatData (1528) - corrected to (1280) +rebuild_semantic_pass: The entry [6866 6895] ("Release") in directory [6866 6886] points to nowhere - is removed +rebuild_semantic_pass: The entry [6866 6897] ("driver") in directory [6866 6886] points to nowhere - is removed +vpf-10650: The directory [6866 6886] has the wrong size in the StatData (440) - corrected to (392) +rebuild_semantic_pass: The entry [7430 10736] ("dongle.o") in directory [6866 7430] points to nowhere - is removed +rebuild_semantic_pass: The entry [7430 10738] ("libDongle.a") in directory [6866 7430] points to nowhere - is removed +vpf-10650: The directory [6866 7430] has the wrong size in the StatData (416) - corrected to (360) +vpf-10650: The directory [6866 6885] has the wrong size in the StatData (152) - corrected to (432) +vpf-10680: The file [10003 10016] has the wrong block count in the StatData (608) - corrected to (280) +vpf-10680: The file [10003 10007] has the wrong block count in the StatData (1032) - corrected to (0) +vpf-10680: The file [10003 10006] has the wrong block count in the StatData (704) - corrected to (0) +vpf-10680: The file [7591 7602] has the wrong block count in the StatData (87184) - corrected to (79640) +vpf-10680: The file [9497 9498] has the wrong block count in the StatData (856) - corrected to (0) +vpf-10680: The file [9449 9458] has the wrong block count in the StatData (176) - corrected to (168) +rebuild_semantic_pass: The entry [7472 9084] ("libxml") in directory [6866 7472] points to nowhere - is removed +vpf-10680: The file [9051 10222] has the wrong block count in the StatData (64) - corrected to (48) +rebuild_semantic_pass: The entry [7472 9075] ("Debug") in directory [7472 9051] points to nowhere - is removed +rebuild_semantic_pass: The entry [7472 9065] ("Release") in directory [7472 9051] points to nowhere - is removed +vpf-10680: The file [7472 9064] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10650: The directory [7472 9051] has the wrong size in the StatData (664) - corrected to (616) +vpf-10680: The file [7472 9024] has the wrong block count in the StatData (21776) - corrected to (20488) +vpf-10680: The file [9472 9473] has the wrong block count in the StatData (8656) - corrected to (8608) +vpf-10680: The directory [6866 7472] has the wrong block count in the StatData (2) - corrected to (1) +vpf-10650: The directory [6866 7472] has the wrong size in the StatData (528) - corrected to (504) +rebuild_semantic_pass: The entry [2 1226] (".reiserfs_priv") in directory [1 2] points to nowhere - is removed +rebuild_semantic_pass: The entry [10364 10414] ("tsqueue.h") in directory [6239 10364] points to nowhere - is removed +vpf-10680: The file [10364 10413] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10650: The directory [6239 10364] has the wrong size in the StatData (912) - corrected to (880) +rebuild_semantic_pass: The entry [10426 10462] ("aescrypt.h") in directory [6239 10426] points to nowhere - is removed +rebuild_semantic_pass: The entry [10426 10463] ("datadigest.h") in directory [6239 10426] points to nowhere - is removed +vpf-10650: The directory [6239 10426] has the wrong size in the StatData (360) - corrected to (296) +vpf-10650: The directory [2 4] has the wrong size in the StatData (48) - corrected to (72) +vpf-10650: The directory [1 2] has the wrong size in the StatData (216) - corrected to (360) +####### Pass 3a (lost+found pass) ######### +relocate_dir: Moving [2 6230 0x0 SD (0)] to [2 5 0x0 SD (0)] +relocate_dir: Moving [2 6230 0x1e9ce900 DIR (3)] to [2 5 0x1e9ce900 DIR (3)] +vpf-10680: The file [6230 6232] has the wrong block count in the StatData (248) - corrected to (0) +vpf-10680: The file [6230 6231] has the wrong block count in the StatData (32) - corrected to (0) +rebuild_semantic_pass: The entry [6230 6233] ("libvorbis.so.0.3.0") in directory [2 5] points to nowhere - is removed +rebuild_semantic_pass: The entry [6230 6234] ("libvorbisenc.so.2.0.0") in directory [2 5] points to nowhere - is removed +rebuild_semantic_pass: The entry [6230 6235] ("libvorbisfile.so.3.1.0") in directory [2 5] points to nowhere - is removed +vpf-10650: The directory [2 5] has the wrong size in the StatData (48) - corrected to (120) +get_next_directory_item: The entry ".." of the directory [3166 3229] pointes to [2 3166], instead of [2 4] - corrected +vpf-10680: The file [3166 3231] has the wrong block count in the StatData (72) - corrected to (64) +vpf-10680: The file [3166 3232] has the wrong block count in the StatData (24) - corrected to (16) +vpf-10680: The file [3166 3233] has the wrong block count in the StatData (48) - corrected to (24) +rewrite_file: 2 items of file [3166 3234] moved to [3166 6] +The entry [3166 3234] ("ui.h") in directory [3166 3229] updated to point to [3166 6] +rewrite_file: 2 items of file [3166 3235] moved to [3166 7] +The entry [3166 3235] ("crypto.h") in directory [3166 3229] updated to point to [3166 7] +rewrite_file: 2 items of file [3166 3236] moved to [3166 8] +The entry [3166 3236] ("txt_db.h") in directory [3166 3229] updated to point to [3166 8] +get_next_directory_item: The entry ".." of the directory [3166 3301] pointes to [2 3166], instead of [2 4] - corrected +vpf-10680: The file [3166 3302] has the wrong block count in the StatData (1040) - corrected to (1032) +get_next_directory_item: The entry ".." of the directory [3166 3304] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3309] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3312] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3444] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3477] pointes to [2 3166], instead of [2 4] - corrected +rewrite_file: 2 items of file [3166 3484] moved to [3166 9] +The entry [3166 3484] ("pmrt_ssl.h") in directory [3166 3477] updated to point to [3166 9] +rewrite_file: 2 items of file [3166 3483] moved to [3166 10] +The entry [3166 3483] ("netssl.h") in directory [3166 3477] updated to point to [3166 10] +rewrite_file: 2 items of file [3166 3485] moved to [3166 11] +The entry [3166 3485] ("sslclient.h") in directory [3166 3477] updated to point to [3166 11] +get_next_directory_item: The entry ".." of the directory [3166 3489] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3500] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3511] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3518] pointes to [2 3166], instead of [2 4] - corrected +get_next_directory_item: The entry ".." of the directory [3166 3526] pointes to [2 3166], instead of [2 4] - corrected +relocate_dir: Moving [3295 10737 0x0 SD (0)] to [3295 12 0x0 SD (0)] +relocate_dir: Moving [3295 10737 0x6d7bd300 DIR (3)] to [3295 12 0x6d7bd300 DIR (3)] +rebuild_semantic_pass: The entry [10737 10792] ("myisam.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10793] ("m_ctype.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10794] ("mysqld_ername.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10795] ("my_list.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [3295 7015] ("mysql_version.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10797] ("my_nosys.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10798] ("mysqld_error.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10799] ("base64.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [3295 6990] ("readline") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10802] ("t_ctype.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10803] ("myisampack.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10804] ("my_alarm.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10805] ("mysql_time.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10806] ("my_alloc.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10807] ("my_time.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10808] ("m_string.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10809] ("my_tree.h") in directory [3295 12] points to nowhere - is removed +rebuild_semantic_pass: The entry [10737 10810] ("my_user.h") in directory [3295 12] points to nowhere - is removed +relocate_dir: Moving [3295 10761 0x0 SD (0)] to [3295 13 0x0 SD (0)] +relocate_dir: Moving [3295 10761 0x1 DIR (3)] to [3295 13 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [3295 13] pointes to [2 3295], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [10761 11769] ("requests") in directory [3295 13] points to nowhere - is removed +rebuild_semantic_pass: The entry [10761 11771] ("output.0") in directory [3295 13] points to nowhere - is removed +rebuild_semantic_pass: The entry [10761 11772] ("traces.0") in directory [3295 13] points to nowhere - is removed +vpf-10650: The directory [3295 13] has the wrong size in the StatData (120) - corrected to (48) +relocate_dir: Moving [3295 10812 0x0 SD (0)] to [3295 14 0x0 SD (0)] +relocate_dir: Moving [3295 10812 0x1 DIR (3)] to [3295 14 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [3295 14] pointes to [2 3295], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [10812 10813] ("ha") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10825] ("os") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10843] ("ut") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10864] ("buf") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10882] ("btr") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10900] ("dyn") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10909] ("fil") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10918] ("fsp") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10927] ("fut") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10939] ("log") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10951] ("mem") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10964] ("mtr") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10976] ("rem") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10988] ("que") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 10997] ("row") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11033] ("srv") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11048] ("thr") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11057] ("trx") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11084] ("usr") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11093] ("data") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11105] ("dict") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11126] ("eval") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11138] ("ibuf") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11147] ("mach") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11156] ("lock") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11165] ("page") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11177] ("pars") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11199] ("read") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11208] ("sync") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11223] ("ib_config.h.in") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [3295 5512] ("Makefile") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11225] ("aclocal.m4") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11226] ("config.status") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11227] ("configure") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11228] ("libtool") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11229] ("CMakeLists.txt") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11230] ("configure.in") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11231] ("ib_config.h") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11232] ("config.log") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11233] ("Makefile.am") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11234] ("Makefile.in") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11235] ("stamp-h1") in directory [3295 14] points to nowhere - is removed +rebuild_semantic_pass: The entry [10812 11236] ("include") in directory [3295 14] points to nowhere - is removed +vpf-10680: The directory [3295 14] has the wrong block count in the StatData (3) - corrected to (1) +vpf-10650: The directory [3295 14] has the wrong size in the StatData (1160) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [3536 3537] pointes to [2 3536], instead of [2 4] - corrected +relocate_dir: Moving [3873 5860 0x0 SD (0)] to [3873 15 0x0 SD (0)] +relocate_dir: Moving [3873 5860 0x1 DIR (3)] to [3873 15 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [3873 15] pointes to [2 3873], instead of [2 4] - corrected +rewrite_file: 3 items of file [5860 6107] moved to [5860 16] +The entry [5860 6107] ("mr_11_select.g3") in directory [3873 15] updated to point to [5860 16] +rebuild_semantic_pass: The entry [5860 5864] ("collect.g3") in directory [3873 15] points to nowhere - is removed +rebuild_semantic_pass: The entry [5860 6147] ("mr_16_shappy.g3") in directory [3873 15] points to nowhere - is removed +rewrite_file: 1 items of file [5860 6076] moved to [5860 17] +vpf-10680: The file [5860 17] has the wrong block count in the StatData (5640) - corrected to (0) +The entry [5860 6076] ("mr_08_select.g3") in directory [3873 15] updated to point to [5860 17] +rebuild_semantic_pass: The entry [5860 5889] ("fnt_cont.g3") in directory [3873 15] points to nowhere - is removed +rebuild_semantic_pass: The entry [5860 5865] ("diag.g3") in directory [3873 15] points to nowhere - is removed +rewrite_file: 3 items of file [5860 6120] moved to [5860 18] +The entry [5860 6120] ("mr_12_shappy.g3") in directory [3873 15] updated to point to [5860 18] +rewrite_file: 2 items of file [5860 6030] moved to [5860 19] +The entry [5860 6030] ("mr_04_select.g3") in directory [3873 15] updated to point to [5860 19] +rebuild_semantic_pass: The entry [5860 5873] ("fntsans16.g3") in directory [3873 15] points to nowhere - is removed +rebuild_semantic_pass: The entry [5860 5874] ("fntsans20.g3") in directory [3873 15] points to nowhere - is removed +rebuild_semantic_pass: The entry [5860 5875] ("fntsans24.g3") in directory [3873 15] points to nowhere - is removed +rebuild_semantic_pass: The entry [5860 5888] ("fntsans36.g3") in directory [3873 15] points to nowhere - is removed +rebuild_semantic_pass: The entry [5860 5890] ("fnt_cred.g3") in directory [3873 15] points to nowhere - is removed +vpf-10680: The directory [3873 15] has the wrong block count in the StatData (14) - corrected to (1) +vpf-10650: The directory [3873 15] has the wrong size in the StatData (6888) - corrected to (176) +relocate_dir: Moving [6241 10779 0x0 SD (0)] to [6241 20 0x0 SD (0)] +relocate_dir: Moving [6241 10779 0x1 DIR (3)] to [6241 20 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 20] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10782] moved to [6241 21] +The entry [6241 10782] ("pmrt_compression.h") in directory [6241 20] updated to point to [6241 21] +relocate_dir: Moving [6241 10789 0x0 SD (0)] to [6241 22 0x0 SD (0)] +relocate_dir: Moving [6241 10789 0x1 DIR (3)] to [6241 22 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 22] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10794] moved to [6241 23] +vpf-10680: The file [6241 23] has the wrong block count in the StatData (16) - corrected to (0) +The entry [6241 10794] ("messages.h") in directory [6241 22] updated to point to [6241 23] +rewrite_file: 2 items of file [6241 10796] moved to [6241 24] +The entry [6241 10796] ("pmrt_messages.h") in directory [6241 22] updated to point to [6241 24] +rewrite_file: 2 items of file [6241 10793] moved to [6241 26] +The entry [6241 10793] ("filetransfer.h") in directory [6241 22] updated to point to [6241 26] +rewrite_file: 2 items of file [6241 10795] moved to [6241 27] +vpf-10680: The file [6241 27] has the wrong block count in the StatData (16) - corrected to (0) +The entry [6241 10795] ("node.h") in directory [6241 22] updated to point to [6241 27] +rewrite_file: 2 items of file [6241 10792] moved to [6241 28] +vpf-10680: The file [6241 28] has the wrong block count in the StatData (24) - corrected to (0) +The entry [6241 10792] ("dbquery.h") in directory [6241 22] updated to point to [6241 28] +rewrite_file: 2 items of file [6241 10797] moved to [6241 29] +The entry [6241 10797] ("tokens.h") in directory [6241 22] updated to point to [6241 29] +relocate_dir: Moving [6241 10800 0x0 SD (0)] to [6241 30 0x0 SD (0)] +relocate_dir: Moving [6241 10800 0x1 DIR (3)] to [6241 30 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 30] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10803] moved to [6241 31] +The entry [6241 10803] ("xmlWrapper.h") in directory [6241 30] updated to point to [6241 31] +relocate_dir: Moving [6241 10808 0x0 SD (0)] to [6241 32 0x0 SD (0)] +relocate_dir: Moving [6241 10808 0x1 DIR (3)] to [6241 32 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 32] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10812] moved to [6241 33] +The entry [6241 10812] ("telemetry.h") in directory [6241 32] updated to point to [6241 33] +rewrite_file: 2 items of file [6241 10813] moved to [6241 34] +The entry [6241 10813] ("telemetryXml.h") in directory [6241 32] updated to point to [6241 34] +rewrite_file: 2 items of file [6241 10811] moved to [6241 35] +The entry [6241 10811] ("bitbyte.h") in directory [6241 32] updated to point to [6241 35] +relocate_dir: Moving [6241 10817 0x0 SD (0)] to [6241 36 0x0 SD (0)] +relocate_dir: Moving [6241 10817 0x1 DIR (3)] to [6241 36 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 36] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10821] moved to [6241 37] +The entry [6241 10821] ("modempriv.h") in directory [6241 36] updated to point to [6241 37] +rewrite_file: 2 items of file [6241 10820] moved to [6241 38] +The entry [6241 10820] ("modem.h") in directory [6241 36] updated to point to [6241 38] +relocate_dir: Moving [6241 10824 0x0 SD (0)] to [6241 39 0x0 SD (0)] +relocate_dir: Moving [6241 10824 0x1 DIR (3)] to [6241 39 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 39] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10827] moved to [6241 40] +vpf-10680: The file [6241 40] has the wrong block count in the StatData (24) - corrected to (0) +The entry [6241 10827] ("dongle.h") in directory [6241 39] updated to point to [6241 40] +rewrite_file: 2 items of file [6241 10834] moved to [6241 41] +vpf-10680: The file [6241 41] has the wrong block count in the StatData (16) - corrected to (0) +The entry [6241 10834] ("ryvc32.h") in directory [6241 39] updated to point to [6241 41] +rewrite_file: 2 items of file [6241 10828] moved to [6241 42] +vpf-10680: The file [6241 42] has the wrong block count in the StatData (16) - corrected to (0) +The entry [6241 10828] ("getopt.h") in directory [6241 39] updated to point to [6241 42] +rewrite_file: 2 items of file [6241 10833] moved to [6241 43] +The entry [6241 10833] ("hasp_vcode.h") in directory [6241 39] updated to point to [6241 43] +rewrite_file: 2 items of file [6241 10832] moved to [6241 44] +vpf-10680: The file [6241 44] has the wrong block count in the StatData (72) - corrected to (0) +The entry [6241 10832] ("hasp_hl.h") in directory [6241 39] updated to point to [6241 44] +relocate_dir: Moving [6241 10844 0x0 SD (0)] to [6241 45 0x0 SD (0)] +relocate_dir: Moving [6241 10844 0x1 DIR (3)] to [6241 45 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [6241 45] pointes to [2 6241], instead of [2 4] - corrected +rewrite_file: 2 items of file [6241 10847] moved to [6241 46] +vpf-10680: The file [6241 46] has the wrong block count in the StatData (24) - corrected to (0) +The entry [6241 10847] ("psm_engine.h") in directory [6241 45] updated to point to [6241 46] +relocate_dir: Moving [7182 7221 0x0 SD (0)] to [7182 47 0x0 SD (0)] +relocate_dir: Moving [7182 7221 0x1 DIR (3)] to [7182 47 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7182 47] pointes to [6234 7182], instead of [2 4] - corrected +rewrite_file: 2 items of file [7221 7222] moved to [7221 48] +The entry [7221 7222] ("jps.obj") in directory [7182 47] updated to point to [7221 48] +rebuild_semantic_pass: The entry [7221 7231] ("jps_player.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7230] ("jps_pfuncs.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7232] ("jps_snd.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7224] ("jpsdrvr_dx.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7233] ("vc60.idb") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7223] ("jpsdrvr_5500.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7228] ("jps_marsig.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7229] ("jps_parse.obj") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7226] ("jpslib.lib") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7227] ("jpslib.pch") in directory [7182 47] points to nowhere - is removed +rebuild_semantic_pass: The entry [7221 7225] ("jpsdrvr_lin.obj") in directory [7182 47] points to nowhere - is removed +vpf-10650: The directory [7182 47] has the wrong size in the StatData (416) - corrected to (72) +relocate_dir: Moving [7182 7234 0x0 SD (0)] to [7182 49 0x0 SD (0)] +relocate_dir: Moving [7182 7234 0x1 DIR (3)] to [7182 49 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7182 49] pointes to [6234 7182], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [7234 7235] ("jps.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7236] ("jps.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7252] ("jps_player.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7253] ("jps_player.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7250] ("jps_pfuncs.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7251] ("jps_pfuncs.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7254] ("jps_snd.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7255] ("jps_snd.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7239] ("jpsdrvr_dx.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7240] ("jpsdrvr_dx.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7256] ("vc60.idb") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7257] ("vc60.pdb") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7237] ("jpsdrvr_5500.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7238] ("jpsdrvr_5500.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7246] ("jps_marsig.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7247] ("jps_marsig.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7248] ("jps_parse.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7249] ("jps_parse.sbr") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7245] ("jpslib.lib") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7243] ("jpsdrvr_lin.obj") in directory [7182 49] points to nowhere - is removed +rebuild_semantic_pass: The entry [7234 7244] ("jpsdrvr_lin.sbr") in directory [7182 49] points to nowhere - is removed +vpf-10680: The directory [7182 49] has the wrong block count in the StatData (2) - corrected to (1) +vpf-10650: The directory [7182 49] has the wrong size in the StatData (688) - corrected to (48) +relocate_dir: Moving [7258 7300 0x0 SD (0)] to [7258 50 0x0 SD (0)] +relocate_dir: Moving [7258 7300 0x1 DIR (3)] to [7258 50 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7258 50] pointes to [6234 7258], instead of [2 4] - corrected +rewrite_file: 2 items of file [7258 7302] moved to [7258 51] +vpf-10680: The file [7258 51] has the wrong block count in the StatData (72) - corrected to (0) +The entry [7258 7302] ("jammalib.lib") in directory [7258 50] updated to point to [7258 51] +rewrite_file: 2 items of file [7258 7303] moved to [7258 52] +vpf-10680: The file [7258 52] has the wrong block count in the StatData (5552) - corrected to (24) +The entry [7258 7303] ("jammalib.pch") in directory [7258 50] updated to point to [7258 52] +rewrite_file: 2 items of file [7258 7307] moved to [7258 53] +vpf-10680: The file [7258 53] has the wrong block count in the StatData (88) - corrected to (0) +The entry [7258 7307] ("vc60.idb") in directory [7258 50] updated to point to [7258 53] +rewrite_file: 2 items of file [7258 7306] moved to [7258 54] +vpf-10680: The file [7258 54] has the wrong block count in the StatData (16) - corrected to (0) +The entry [7258 7306] ("jamma_pc.obj") in directory [7258 50] updated to point to [7258 54] +rewrite_file: 2 items of file [7258 7301] moved to [7258 55] +vpf-10680: The file [7258 55] has the wrong block count in the StatData (48) - corrected to (0) +The entry [7258 7301] ("jamma.obj") in directory [7258 50] updated to point to [7258 55] +rewrite_file: 2 items of file [7258 7305] moved to [7258 56] +The entry [7258 7305] ("jamma_lin.obj") in directory [7258 50] updated to point to [7258 56] +relocate_dir: Moving [7258 7308 0x0 SD (0)] to [7258 57 0x0 SD (0)] +relocate_dir: Moving [7258 7308 0x1 DIR (3)] to [7258 57 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7258 57] pointes to [6234 7258], instead of [2 4] - corrected +rewrite_file: 2 items of file [7258 7314] moved to [7258 58] +vpf-10680: The file [7258 58] has the wrong block count in the StatData (184) - corrected to (0) +The entry [7258 7314] ("jammalib.lib") in directory [7258 57] updated to point to [7258 58] +rewrite_file: 2 items of file [7258 7315] moved to [7258 59] +vpf-10680: The file [7258 59] has the wrong block count in the StatData (5544) - corrected to (4208) +The entry [7258 7315] ("jammalib.pch") in directory [7258 57] updated to point to [7258 59] +rewrite_file: 2 items of file [7258 7322] moved to [7258 60] +The entry [7258 7322] ("vc60.idb") in directory [7258 57] updated to point to [7258 60] +rewrite_file: 2 items of file [7258 7323] moved to [7258 61] +The entry [7258 7323] ("vc60.pdb") in directory [7258 57] updated to point to [7258 61] +rewrite_file: 2 items of file [7258 7321] moved to [7258 62] +The entry [7258 7321] ("jamma_pc.obj") in directory [7258 57] updated to point to [7258 62] +rewrite_file: 2 items of file [7258 7310] moved to [7258 63] +vpf-10680: The file [7258 63] has the wrong block count in the StatData (128) - corrected to (0) +The entry [7258 7310] ("jamma.obj") in directory [7258 57] updated to point to [7258 63] +rewrite_file: 2 items of file [7258 7318] moved to [7258 64] +The entry [7258 7318] ("jamma_lin.obj") in directory [7258 57] updated to point to [7258 64] +relocate_dir: Moving [7349 7365 0x0 SD (0)] to [7349 65 0x0 SD (0)] +relocate_dir: Moving [7349 7365 0x1 DIR (3)] to [7349 65 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7349 65] pointes to [6234 7349], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [7365 7371] ("vc60.idb") in directory [7349 65] points to nowhere - is removed +rewrite_file: 2 items of file [7365 7369] moved to [7365 66] +The entry [7365 7369] ("card_lin.obj") in directory [7349 65] updated to point to [7365 66] +rewrite_file: 2 items of file [7365 7366] moved to [7365 67] +The entry [7365 7366] ("card.lib") in directory [7349 65] updated to point to [7365 67] +rewrite_file: 2 items of file [7365 7367] moved to [7365 68] +The entry [7365 7367] ("card.obj") in directory [7349 65] updated to point to [7365 68] +rewrite_file: 3 items of file [7365 7368] moved to [7365 69] +vpf-10680: The file [7365 69] has the wrong block count in the StatData (5504) - corrected to (5496) +The entry [7365 7368] ("card.pch") in directory [7349 65] updated to point to [7365 69] +rewrite_file: 1 items of file [7365 7370] moved to [7365 70] +vpf-10680: The file [7365 70] has the wrong block count in the StatData (8) - corrected to (0) +The entry [7365 7370] ("card_pc.obj") in directory [7349 65] updated to point to [7365 70] +vpf-10650: The directory [7349 65] has the wrong size in the StatData (208) - corrected to (184) +relocate_dir: Moving [7349 7372 0x0 SD (0)] to [7349 71 0x0 SD (0)] +relocate_dir: Moving [7349 7372 0x1 DIR (3)] to [7349 71 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7349 71] pointes to [6234 7349], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [7372 7378] ("vc60.idb") in directory [7349 71] points to nowhere - is removed +rebuild_semantic_pass: The entry [7372 7379] ("vc60.pdb") in directory [7349 71] points to nowhere - is removed +rebuild_semantic_pass: The entry [7372 7376] ("card_lin.obj") in directory [7349 71] points to nowhere - is removed +rebuild_semantic_pass: The entry [7372 7373] ("card.lib") in directory [7349 71] points to nowhere - is removed +rebuild_semantic_pass: The entry [7372 7374] ("card.obj") in directory [7349 71] points to nowhere - is removed +rebuild_semantic_pass: The entry [7372 7375] ("card.pch") in directory [7349 71] points to nowhere - is removed +rebuild_semantic_pass: The entry [7372 7377] ("card_pc.obj") in directory [7349 71] points to nowhere - is removed +vpf-10650: The directory [7349 71] has the wrong size in the StatData (232) - corrected to (48) +relocate_dir: Moving [7380 7717 0x0 SD (0)] to [7380 72 0x0 SD (0)] +relocate_dir: Moving [7380 7717 0x1 DIR (3)] to [7380 72 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 72] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [7717 8751] ("pc") in directory [7380 72] points to nowhere - is removed +rebuild_semantic_pass: The entry [7717 8508] ("nasm-0.98.39-win32.zip") in directory [7380 72] points to nowhere - is removed +rebuild_semantic_pass: The entry [7717 8849] ("linux") in directory [7380 72] points to nowhere - is removed +rebuild_semantic_pass: The entry [7717 8510] ("Readme.txt") in directory [7380 72] points to nowhere - is removed +rebuild_semantic_pass: The entry [7717 8509] ("openssl-0.9.8e.tar.gz") in directory [7380 72] points to nowhere - is removed +rewrite_file: 2 items of file [7717 7718] moved to [7717 73] +vpf-10680: The file [7717 73] has the wrong block count in the StatData (17368) - corrected to (0) +The entry [7717 7718] ("ActivePerl-5.6.1.638-MSWin32-x86.msi") in directory [7380 72] updated to point to [7717 73] +rebuild_semantic_pass: The entry [7717 8750] ("vssver.scc") in directory [7380 72] points to nowhere - is removed +vpf-10650: The directory [7380 72] has the wrong size in the StatData (48) - corrected to (104) +relocate_dir: Moving [7380 8931 0x0 SD (0)] to [7380 74 0x0 SD (0)] +relocate_dir: Moving [7380 8931 0x1 DIR (3)] to [7380 74 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 74] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [8931 8935] ("linux") in directory [7380 74] points to nowhere - is removed +rebuild_semantic_pass: The entry [8931 8933] ("README.txt") in directory [7380 74] points to nowhere - is removed +rebuild_semantic_pass: The entry [8931 8932] ("opencv-1.0.0.tar.gz") in directory [7380 74] points to nowhere - is removed +rebuild_semantic_pass: The entry [8931 8934] ("vssver.scc") in directory [7380 74] points to nowhere - is removed +vpf-10650: The directory [7380 74] has the wrong size in the StatData (176) - corrected to (48) +relocate_dir: Moving [7380 8959 0x0 SD (0)] to [7380 75 0x0 SD (0)] +relocate_dir: Moving [7380 8959 0x1 DIR (3)] to [7380 75 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 75] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [8959 8960] ("dgif_lib.c") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 10289] ("dgif_lib.o") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8981] ("Debug") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8961] ("egif_lib.c") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 10290] ("egif_lib.o") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8967] ("lungif.dsp") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8968] ("lungif.dsw") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8969] ("lungif.plg") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8970] ("makefile") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8973] ("Release") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8963] ("gifalloc.c") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 10292] ("gifalloc.o") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8971] ("mssccprj.scc") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8964] ("gif_err.c") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 10291] ("gif_err.o") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8965] ("gif_lib.h") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 10294] ("lungif.a") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8962] ("gif2tmap.txt") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8966] ("gif_lib_private.h") in directory [7380 75] points to nowhere - is removed +rebuild_semantic_pass: The entry [8959 8972] ("vssver.scc") in directory [7380 75] points to nowhere - is removed +vpf-10680: The directory [7380 75] has the wrong block count in the StatData (2) - corrected to (1) +vpf-10650: The directory [7380 75] has the wrong size in the StatData (664) - corrected to (48) +relocate_dir: Moving [7380 8990 0x0 SD (0)] to [7380 76 0x0 SD (0)] +relocate_dir: Moving [7380 8990 0x1 DIR (3)] to [7380 76 0x1 DIR (3)] +relocate_dir: Moving [7380 8990 0x39680 DIR (3)] to [7380 76 0x39680 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 76] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [8990 8995] ("pc") in directory [7380 76] points to nowhere - is removed +rebuild_semantic_pass: The entry [8990 8992] ("libxml2-2.6.13.win32.zip") in directory [7380 76] points to nowhere - is removed +rebuild_semantic_pass: The entry [8990 9057] ("linux") in directory [7380 76] points to nowhere - is removed +rebuild_semantic_pass: The entry [8990 8993] ("README.txt") in directory [7380 76] points to nowhere - is removed +rebuild_semantic_pass: The entry [8990 8991] ("libxml2-2.6.13.tar.gz") in directory [7380 76] points to nowhere - is removed +rebuild_semantic_pass: The entry [8990 8994] ("vssver.scc") in directory [7380 76] points to nowhere - is removed +vpf-10650: The directory [7380 76] has the wrong size in the StatData (240) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [7380 9120] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9120 9361] ("bin") in directory [7380 9120] points to nowhere - is removed +rebuild_semantic_pass: The entry [9120 9127] ("lib") in directory [7380 9120] points to nowhere - is removed +rebuild_semantic_pass: The entry [9120 9124] ("README.txt") in directory [7380 9120] points to nowhere - is removed +rebuild_semantic_pass: The entry [9120 9357] ("include") in directory [7380 9120] points to nowhere - is removed +rebuild_semantic_pass: The entry [9120 9122] ("libusb-0.1.12.tar.gz") in directory [7380 9120] points to nowhere - is removed +rebuild_semantic_pass: The entry [9120 9126] ("vssver.scc") in directory [7380 9120] points to nowhere - is removed +vpf-10650: The directory [7380 9120] has the wrong size in the StatData (224) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [7380 9365] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9365 9372] ("pc") in directory [7380 9365] points to nowhere - is removed +rebuild_semantic_pass: The entry [9365 9368] ("libiconv-1.9.2-1-lib.zip") in directory [7380 9365] points to nowhere - is removed +rebuild_semantic_pass: The entry [9365 9369] ("libiconv-1.9.2-1-src.zip") in directory [7380 9365] points to nowhere - is removed +rebuild_semantic_pass: The entry [9365 9366] ("libiconv-1.11.tar.gz") in directory [7380 9365] points to nowhere - is removed +rebuild_semantic_pass: The entry [9365 9370] ("README.txt") in directory [7380 9365] points to nowhere - is removed +rebuild_semantic_pass: The entry [9365 9367] ("libiconv-1.9.2-1-bin.zip") in directory [7380 9365] points to nowhere - is removed +rebuild_semantic_pass: The entry [9365 9371] ("vssver.scc") in directory [7380 9365] points to nowhere - is removed +vpf-10650: The directory [7380 9365] has the wrong size in the StatData (296) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [7380 9390] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9390 9394] ("lib") in directory [7380 9390] points to nowhere - is removed +vpf-10680: The file [9390 9391] has the wrong block count in the StatData (8656) - corrected to (0) +rebuild_semantic_pass: The entry [9390 9392] ("README.txt") in directory [7380 9390] points to nowhere - is removed +rebuild_semantic_pass: The entry [9390 9398] ("include") in directory [7380 9390] points to nowhere - is removed +rebuild_semantic_pass: The entry [9390 9393] ("vssver.scc") in directory [7380 9390] points to nowhere - is removed +vpf-10650: The directory [7380 9390] has the wrong size in the StatData (200) - corrected to (88) +get_next_directory_item: The entry ".." of the directory [7380 9403] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9403 9447] ("jdinput.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10320] ("jdinput.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10306] ("jccoefct.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9427] ("jcmainct.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10304] ("jcmainct.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10296] ("jcapimin.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10297] ("jcapistd.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9436] ("jctrans.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10298] ("jctrans.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9475] ("jpeglib.dsp") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9476] ("jpeglib.dsw") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9478] ("jpeglib.plg") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9439] ("jdatadst.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10300] ("jdatadst.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9538] ("Debug") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10311] ("jcdctmgr.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9440] ("jdatasrc.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10318] ("jdatasrc.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9428] ("jcmarker.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10303] ("jcmarker.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9442] ("jdcolor.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10338] ("jdcolor.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9429] ("jcmaster.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10302] ("jcmaster.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9430] ("jcomapi.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10348] ("jcomapi.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9456] ("jerror.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9457] ("jerror.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10350] ("jerror.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9432] ("jcparam.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10299] ("jcparam.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9431] ("jconfig.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9473] ("jmorecfg.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9454] ("jdsample.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10337] ("jdsample.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9434] ("jcprepct.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10305] ("jcprepct.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9433] ("jcphuff.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10310] ("jcphuff.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9485] ("makefile") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9465] ("jinclude.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9488] ("Release") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9481] ("jquant1.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10345] ("jquant1.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9482] ("jquant2.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10346] ("jquant2.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9479] ("jpegsrc.v6b.tar.gz") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9451] ("jdmerge.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10347] ("jdmerge.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9461] ("jidctflt.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10330] ("jidctflt.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9462] ("jidctfst.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10329] ("jidctfst.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9463] ("jidctint.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10331] ("jidctint.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9464] ("jidctred.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10336] ("jidctred.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9443] ("jdct.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9486] ("mssccprj.scc") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10307] ("jccolor.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9466] ("jmemansi.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9441] ("jdcoefct.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10325] ("jdcoefct.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9448] ("jdmainct.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10324] ("jdmainct.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9474] ("jpegint.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10359] ("jpeglib.a") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9477] ("jpeglib.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9483] ("jutils.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10349] ("jutils.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9437] ("jdapimin.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10315] ("jdapimin.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9438] ("jdapistd.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10316] ("jdapistd.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9455] ("jdtrans.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10317] ("jdtrans.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9444] ("jddctmgr.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10327] ("jddctmgr.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9453] ("jdpostct.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10326] ("jdpostct.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9449] ("jdmarker.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10321] ("jdmarker.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9470] ("jmemname.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9450] ("jdmaster.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10319] ("jdmaster.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9471] ("jmemnobs.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10352] ("jmemnobs.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9484] ("jversion.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9480] ("jpegtran.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9435] ("jcsample.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10308] ("jcsample.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9467] ("jmemdos.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9458] ("jfdctflt.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10313] ("jfdctflt.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9459] ("jfdctfst.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10312] ("jfdctfst.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9468] ("jmemmac.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9469] ("jmemmgr.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10351] ("jmemmgr.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9460] ("jfdctint.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10314] ("jfdctint.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9472] ("jmemsys.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10309] ("jchuff.o") in directory [7380 9403] points to nowhere - is removed +vpf-10680: The file [9403 9426] has the wrong block count in the StatData (8) - corrected to (0) +rebuild_semantic_pass: The entry [9403 10301] ("jcinit.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9452] ("jdphuff.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10323] ("jdphuff.o") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9487] ("vssver.scc") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9445] ("jdhuff.c") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 9446] ("jdhuff.h") in directory [7380 9403] points to nowhere - is removed +rebuild_semantic_pass: The entry [9403 10322] ("jdhuff.o") in directory [7380 9403] points to nowhere - is removed +vpf-10680: The directory [7380 9403] has the wrong block count in the StatData (8) - corrected to (1) +vpf-10650: The directory [7380 9403] has the wrong size in the StatData (3696) - corrected to (280) +relocate_dir: Moving [7380 9793 0x0 SD (0)] to [7380 77 0x0 SD (0)] +relocate_dir: Moving [7380 9793 0x1 DIR (3)] to [7380 77 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 77] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9793 9794] ("pc") in directory [7380 77] points to nowhere - is removed +vpf-10650: The directory [7380 77] has the wrong size in the StatData (72) - corrected to (48) +relocate_dir: Moving [7380 9807 0x0 SD (0)] to [7380 78 0x0 SD (0)] +relocate_dir: Moving [7380 9807 0x1 DIR (3)] to [7380 78 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 78] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9807 9808] ("pc") in directory [7380 78] points to nowhere - is removed +rebuild_semantic_pass: The entry [9807 9812] ("linux") in directory [7380 78] points to nowhere - is removed +vpf-10650: The directory [7380 78] has the wrong size in the StatData (96) - corrected to (48) +relocate_dir: Moving [7380 9816 0x0 SD (0)] to [7380 79 0x0 SD (0)] +relocate_dir: Moving [7380 9816 0x1 DIR (3)] to [7380 79 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 79] pointes to [6215 7380], instead of [2 4] - corrected +relocate_dir: Moving [9816 9820 0x0 SD (0)] to [9816 80 0x0 SD (0)] +relocate_dir: Moving [9816 9820 0x1 DIR (3)] to [9816 80 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9816 80] pointes to [7380 9816], instead of [7380 79] - corrected +relocate_dir: Moving [9816 9828 0x0 SD (0)] to [9816 81 0x0 SD (0)] +relocate_dir: Moving [9816 9828 0x1 DIR (3)] to [9816 81 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9816 81] pointes to [9816 9820], instead of [9816 80] - corrected +rewrite_file: 2 items of file [9816 9829] moved to [9816 82] +The entry [9816 9829] ("glut32.dll") in directory [9816 81] updated to point to [9816 82] +rewrite_file: 2 items of file [9816 9830] moved to [9816 83] +The entry [9816 9830] ("vssver.scc") in directory [9816 81] updated to point to [9816 83] +The entry [9816 81] ("bin") in directory [9816 80] updated to point to [9816 81] +relocate_dir: Moving [9816 9821 0x0 SD (0)] to [9816 84 0x0 SD (0)] +relocate_dir: Moving [9816 9821 0x1 DIR (3)] to [9816 84 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9816 84] pointes to [9816 9820], instead of [9816 80] - corrected +rewrite_file: 2 items of file [9816 9822] moved to [9816 85] +The entry [9816 9822] ("glut32.lib") in directory [9816 84] updated to point to [9816 85] +rewrite_file: 2 items of file [9816 9823] moved to [9816 86] +The entry [9816 9823] ("vssver.scc") in directory [9816 84] updated to point to [9816 86] +The entry [9816 84] ("lib") in directory [9816 80] updated to point to [9816 84] +relocate_dir: Moving [9816 9824 0x0 SD (0)] to [9816 87 0x0 SD (0)] +relocate_dir: Moving [9816 9824 0x1 DIR (3)] to [9816 87 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9816 87] pointes to [9816 9820], instead of [9816 80] - corrected +relocate_dir: Moving [9816 9825 0x0 SD (0)] to [9816 88 0x0 SD (0)] +relocate_dir: Moving [9816 9825 0x1 DIR (3)] to [9816 88 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9816 88] pointes to [9816 9824], instead of [9816 87] - corrected +rewrite_file: 2 items of file [9816 9826] moved to [9816 89] +The entry [9816 9826] ("glut.h") in directory [9816 88] updated to point to [9816 89] +rewrite_file: 2 items of file [9816 9827] moved to [9816 90] +The entry [9816 9827] ("vssver.scc") in directory [9816 88] updated to point to [9816 90] +The entry [9816 88] ("GL") in directory [9816 87] updated to point to [9816 88] +The entry [9816 87] ("include") in directory [9816 80] updated to point to [9816 87] +The entry [9816 80] ("pc") in directory [7380 79] updated to point to [9816 80] +rebuild_semantic_pass: The entry [9816 9818] ("glut-3.7.6-src.zip") in directory [7380 79] points to nowhere - is removed +rebuild_semantic_pass: The entry [9816 9817] ("glut-3.7.6-bin.zip") in directory [7380 79] points to nowhere - is removed +rewrite_file: 2 items of file [9816 9819] moved to [9816 91] +The entry [9816 9819] ("vssver.scc") in directory [7380 79] updated to point to [9816 91] +vpf-10650: The directory [7380 79] has the wrong size in the StatData (184) - corrected to (104) +relocate_dir: Moving [7380 9831 0x0 SD (0)] to [7380 92 0x0 SD (0)] +relocate_dir: Moving [7380 9831 0x1 DIR (3)] to [7380 92 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 92] pointes to [6215 7380], instead of [2 4] - corrected +relocate_dir: Moving [9831 9835 0x0 SD (0)] to [9831 93 0x0 SD (0)] +relocate_dir: Moving [9831 9835 0x1 DIR (3)] to [9831 93 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9831 93] pointes to [7380 9831], instead of [7380 92] - corrected +relocate_dir: Moving [9831 9836 0x0 SD (0)] to [9831 94 0x0 SD (0)] +relocate_dir: Moving [9831 9836 0x1 DIR (3)] to [9831 94 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9831 94] pointes to [9831 9835], instead of [9831 93] - corrected +relocate_dir: Moving [9831 9837 0x0 SD (0)] to [9831 95 0x0 SD (0)] +relocate_dir: Moving [9831 9837 0x1 DIR (3)] to [9831 95 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9831 95] pointes to [9831 9836], instead of [9831 94] - corrected +rewrite_file: 2 items of file [9831 9840] moved to [9831 96] +The entry [9831 9840] ("wglext.h") in directory [9831 95] updated to point to [9831 96] +rewrite_file: 2 items of file [9831 9838] moved to [9831 97] +The entry [9831 9838] ("glext.h") in directory [9831 95] updated to point to [9831 97] +rewrite_file: 2 items of file [9831 9839] moved to [9831 98] +The entry [9831 9839] ("vssver.scc") in directory [9831 95] updated to point to [9831 98] +The entry [9831 95] ("GL") in directory [9831 94] updated to point to [9831 95] +The entry [9831 94] ("include") in directory [9831 93] updated to point to [9831 94] +The entry [9831 93] ("pc") in directory [7380 92] updated to point to [9831 93] +rewrite_file: 2 items of file [9831 9832] moved to [9831 99] +The entry [9831 9832] ("OpenGL Nvidia.zip") in directory [7380 92] updated to point to [9831 99] +rewrite_file: 2 items of file [9831 9833] moved to [9831 100] +The entry [9831 9833] ("README.txt") in directory [7380 92] updated to point to [9831 100] +rewrite_file: 2 items of file [9831 9834] moved to [9831 101] +The entry [9831 9834] ("vssver.scc") in directory [7380 92] updated to point to [9831 101] +relocate_dir: Moving [7380 9841 0x0 SD (0)] to [7380 102 0x0 SD (0)] +relocate_dir: Moving [7380 9841 0x1 DIR (3)] to [7380 102 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 102] pointes to [6215 7380], instead of [2 4] - corrected +relocate_dir: Moving [9841 9845 0x0 SD (0)] to [9841 103 0x0 SD (0)] +relocate_dir: Moving [9841 9845 0x1 DIR (3)] to [9841 103 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 103] pointes to [7405 9841], instead of [7380 102] - corrected +relocate_dir: Moving [9841 9912 0x0 SD (0)] to [9841 104 0x0 SD (0)] +relocate_dir: Moving [9841 9912 0x1 DIR (3)] to [9841 104 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 104] pointes to [9841 9845], instead of [9841 103] - corrected +rewrite_file: 2 items of file [9841 9913] moved to [9841 105] +The entry [9841 9913] ("glew32.dll") in directory [9841 104] updated to point to [9841 105] +rebuild_semantic_pass: The entry [9841 9913] ("glut32.dll") in directory [9841 104] points to nowhere - is removed +rewrite_file: 2 items of file [9841 9914] moved to [9841 106] +The entry [9841 9914] ("vssver.scc") in directory [9841 104] updated to point to [9841 106] +The entry [9841 104] ("bin") in directory [9841 103] updated to point to [9841 104] +relocate_dir: Moving [9841 9846 0x0 SD (0)] to [9841 107 0x0 SD (0)] +relocate_dir: Moving [9841 9846 0x1 DIR (3)] to [9841 107 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 107] pointes to [9841 9845], instead of [9841 103] - corrected +rewrite_file: 2 items of file [9841 9847] moved to [9841 108] +vpf-10670: The file [9841 108] has the wrong size in the StatData (28728) - corrected to (311296) +vpf-10680: The file [9841 108] has the wrong block count in the StatData (64) - corrected to (608) +The entry [9841 9847] ("glew32.lib") in directory [9841 107] updated to point to [9841 108] +rebuild_semantic_pass: The entry [9841 9847] ("glut32.lib") in directory [9841 107] points to nowhere - is removed +rewrite_file: 2 items of file [9841 9848] moved to [9841 109] +The entry [9841 9848] ("vssver.scc") in directory [9841 107] updated to point to [9841 109] +The entry [9841 107] ("lib") in directory [9841 103] updated to point to [9841 107] +relocate_dir: Moving [9841 9873 0x0 SD (0)] to [9841 110 0x0 SD (0)] +relocate_dir: Moving [9841 9873 0x1 DIR (3)] to [9841 110 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 110] pointes to [9841 9845], instead of [9841 103] - corrected +relocate_dir: Moving [9841 9874 0x0 SD (0)] to [9841 111 0x0 SD (0)] +relocate_dir: Moving [9841 9874 0x1 DIR (3)] to [9841 111 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 111] pointes to [9841 9873], instead of [9841 110] - corrected +rewrite_file: 2 items of file [9841 9875] moved to [9841 112] +vpf-10670: The file [9841 112] has the wrong size in the StatData (27670) - corrected to (532480) +vpf-10680: The file [9841 112] has the wrong block count in the StatData (56) - corrected to (1040) +The entry [9841 9875] ("glew.h") in directory [9841 111] updated to point to [9841 112] +rebuild_semantic_pass: The entry [9841 9875] ("glut.h") in directory [9841 111] points to nowhere - is removed +rewrite_file: 2 items of file [9841 9911] moved to [9841 113] +The entry [9841 9911] ("vssver.scc") in directory [9841 111] updated to point to [9841 113] +The entry [9841 111] ("GL") in directory [9841 110] updated to point to [9841 111] +The entry [9841 110] ("include") in directory [9841 103] updated to point to [9841 110] +The entry [9841 103] ("pc") in directory [7380 102] updated to point to [9841 103] +rewrite_file: 3 items of file [9841 9843] moved to [9841 114] +vpf-10680: The file [9841 114] has the wrong block count in the StatData (9752) - corrected to (8792) +The entry [9841 9843] ("glew-1.4.0-win32.zip") in directory [7380 102] updated to point to [9841 114] +relocate_dir: Moving [9841 9915 0x0 SD (0)] to [9841 115 0x0 SD (0)] +relocate_dir: Moving [9841 9915 0x1 DIR (3)] to [9841 115 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 115] pointes to [7380 9841], instead of [7380 102] - corrected +relocate_dir: Moving [9841 9916 0x0 SD (0)] to [9841 116 0x0 SD (0)] +relocate_dir: Moving [9841 9916 0x1 DIR (3)] to [9841 116 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 116] pointes to [9841 9915], instead of [9841 115] - corrected +rewrite_file: 2 items of file [9841 9928] moved to [9841 117] +The entry [9841 9928] ("libGLEW.a") in directory [9841 116] updated to point to [9841 117] +rewrite_file: 2 items of file [9841 9929] moved to [9841 118] +The entry [9841 9929] ("vssver.scc") in directory [9841 116] updated to point to [9841 118] +The entry [9841 116] ("lib") in directory [9841 115] updated to point to [9841 116] +relocate_dir: Moving [9841 9930 0x0 SD (0)] to [9841 119 0x0 SD (0)] +relocate_dir: Moving [9841 9930 0x1 DIR (3)] to [9841 119 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 119] pointes to [9841 9915], instead of [9841 115] - corrected +relocate_dir: Moving [9841 9931 0x0 SD (0)] to [9841 120 0x0 SD (0)] +relocate_dir: Moving [9841 9931 0x1 DIR (3)] to [9841 120 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 120] pointes to [9841 9930], instead of [9841 119] - corrected +rewrite_file: 2 items of file [9841 9932] moved to [9841 121] +The entry [9841 9932] ("glew.h") in directory [9841 120] updated to point to [9841 121] +rewrite_file: 2 items of file [9841 9933] moved to [9841 122] +The entry [9841 9933] ("vssver.scc") in directory [9841 120] updated to point to [9841 122] +The entry [9841 120] ("GL") in directory [9841 119] updated to point to [9841 120] +The entry [9841 119] ("include") in directory [9841 115] updated to point to [9841 119] +The entry [9841 115] ("linux") in directory [7380 102] updated to point to [9841 115] +rewrite_file: 2 items of file [9841 9842] moved to [9841 123] +vpf-10670: The file [9841 123] has the wrong size in the StatData (119897) - corrected to (360448) +vpf-10680: The file [9841 123] has the wrong block count in the StatData (240) - corrected to (704) +The entry [9841 9842] ("glew-1.4.0-src.tgz") in directory [7380 102] updated to point to [9841 123] +rewrite_file: 2 items of file [9841 9844] moved to [9841 124] +The entry [9841 9844] ("vssver.scc") in directory [7380 102] updated to point to [9841 124] +relocate_dir: Moving [7380 9934 0x0 SD (0)] to [7380 125 0x0 SD (0)] +relocate_dir: Moving [7380 9934 0x1 DIR (3)] to [7380 125 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 125] pointes to [6215 7380], instead of [2 4] - corrected +relocate_dir: Moving [9934 9937 0x0 SD (0)] to [9934 126 0x0 SD (0)] +relocate_dir: Moving [9934 9937 0x1 DIR (3)] to [9934 126 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9934 126] pointes to [7380 9934], instead of [7380 125] - corrected +relocate_dir: Moving [9937 9947 0x0 SD (0)] to [9937 127 0x0 SD (0)] +relocate_dir: Moving [9937 9947 0x1 DIR (3)] to [9937 127 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9937 127] pointes to [9934 9937], instead of [9934 126] - corrected +rebuild_semantic_pass: The entry [9947 9948] ("freeglut.dll") in directory [9937 127] points to nowhere - is removed +rebuild_semantic_pass: The entry [9947 9949] ("vssver.scc") in directory [9937 127] points to nowhere - is removed +vpf-10650: The directory [9937 127] has the wrong size in the StatData (112) - corrected to (48) +The entry [9937 127] ("bin") in directory [9934 126] updated to point to [9937 127] +relocate_dir: Moving [9937 9938 0x0 SD (0)] to [9937 128 0x0 SD (0)] +relocate_dir: Moving [9937 9938 0x1 DIR (3)] to [9937 128 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9937 128] pointes to [9934 9937], instead of [9934 126] - corrected +rewrite_file: 2 items of file [9938 9939] moved to [9938 129] +The entry [9938 9939] ("freeglut.lib") in directory [9937 128] updated to point to [9938 129] +rewrite_file: 2 items of file [9938 9940] moved to [9938 130] +The entry [9938 9940] ("vssver.scc") in directory [9937 128] updated to point to [9938 130] +The entry [9937 128] ("lib") in directory [9934 126] updated to point to [9937 128] +relocate_dir: Moving [9937 9941 0x0 SD (0)] to [9937 131 0x0 SD (0)] +relocate_dir: Moving [9937 9941 0x1 DIR (3)] to [9937 131 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9937 131] pointes to [9934 9937], instead of [9934 126] - corrected +relocate_dir: Moving [9941 9942 0x0 SD (0)] to [9941 132 0x0 SD (0)] +relocate_dir: Moving [9941 9942 0x1 DIR (3)] to [9941 132 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9941 132] pointes to [9937 9941], instead of [9937 131] - corrected +rewrite_file: 2 items of file [9942 9943] moved to [9942 133] +The entry [9942 9943] ("freeglut.h") in directory [9941 132] updated to point to [9942 133] +rewrite_file: 2 items of file [9942 9944] moved to [9942 134] +The entry [9942 9944] ("freeglut_ext.h") in directory [9941 132] updated to point to [9942 134] +rewrite_file: 2 items of file [9942 9945] moved to [9942 135] +The entry [9942 9945] ("freeglut_std.h") in directory [9941 132] updated to point to [9942 135] +rebuild_semantic_pass: The entry [9942 9946] ("vssver.scc") in directory [9941 132] points to nowhere - is removed +vpf-10650: The directory [9941 132] has the wrong size in the StatData (176) - corrected to (144) +The entry [9941 132] ("GL") in directory [9937 131] updated to point to [9941 132] +The entry [9937 131] ("include") in directory [9934 126] updated to point to [9937 131] +The entry [9934 126] ("pc") in directory [7380 125] updated to point to [9934 126] +rewrite_file: 2 items of file [9934 9935] moved to [9934 136] +vpf-10680: The file [9934 136] has the wrong block count in the StatData (920) - corrected to (0) +The entry [9934 9935] ("freeglut-2.4.0.tar.gz") in directory [7380 125] updated to point to [9934 136] +rewrite_file: 2 items of file [9934 9936] moved to [9934 137] +The entry [9934 9936] ("vssver.scc") in directory [7380 125] updated to point to [9934 137] +relocate_dir: Moving [7380 9950 0x0 SD (0)] to [7380 138 0x0 SD (0)] +relocate_dir: Moving [7380 9950 0x1 DIR (3)] to [7380 138 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 138] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9950 9951] ("pc") in directory [7380 138] points to nowhere - is removed +vpf-10650: The directory [7380 138] has the wrong size in the StatData (72) - corrected to (48) +relocate_dir: Moving [7380 10013 0x0 SD (0)] to [7380 139 0x0 SD (0)] +relocate_dir: Moving [7380 10013 0x1 DIR (3)] to [7380 139 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7380 139] pointes to [6215 7380], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [10013 10016] ("lib") in directory [7380 139] points to nowhere - is removed +vpf-10650: The directory [7380 139] has the wrong size in the StatData (72) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [7381 7386] pointes to [7380 7381], instead of [2 4] - corrected +relocate_dir: Moving [7386 7396 0x0 SD (0)] to [7386 140 0x0 SD (0)] +relocate_dir: Moving [7386 7396 0x1 DIR (3)] to [7386 140 0x1 DIR (3)] +rewrite_file: 2 items of file [7396 7398] moved to [7396 141] +The entry [7396 7398] ("zlib1.dll") in directory [7386 140] updated to point to [7396 141] +rewrite_file: 2 items of file [7396 7397] moved to [7396 142] +The entry [7396 7397] ("vssver.scc") in directory [7386 140] updated to point to [7396 142] +The entry [7386 140] ("bin") in directory [7381 7386] updated to point to [7386 140] +rewrite_file: 2 items of file [7392 7395] moved to [7392 143] +The entry [7392 7395] ("zlib.h") in directory [7386 7392] updated to point to [7392 143] +relocate_dir: Moving [7381 7399 0x0 SD (0)] to [7381 144 0x0 SD (0)] +relocate_dir: Moving [7381 7399 0x1 DIR (3)] to [7381 144 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7381 144] pointes to [7380 7381], instead of [2 4] - corrected +relocate_dir: Moving [7399 7400 0x0 SD (0)] to [7399 145 0x0 SD (0)] +relocate_dir: Moving [7399 7400 0x1 DIR (3)] to [7399 145 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7399 145] pointes to [7381 7399], instead of [7381 144] - corrected +rewrite_file: 2 items of file [7400 7401] moved to [7400 146] +The entry [7400 7401] ("libz.a") in directory [7399 145] updated to point to [7400 146] +rewrite_file: 2 items of file [7400 7402] moved to [7400 147] +The entry [7400 7402] ("vssver.scc") in directory [7399 145] updated to point to [7400 147] +The entry [7399 145] ("lib") in directory [7381 144] updated to point to [7399 145] +relocate_dir: Moving [7399 7403 0x0 SD (0)] to [7399 148 0x0 SD (0)] +relocate_dir: Moving [7399 7403 0x1 DIR (3)] to [7399 148 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7399 148] pointes to [7381 7399], instead of [7381 144] - corrected +rewrite_file: 2 items of file [7403 7405] moved to [7403 149] +vpf-10680: The file [7403 149] has the wrong block count in the StatData (24) - corrected to (0) +The entry [7403 7405] ("zconf.h") in directory [7399 148] updated to point to [7403 149] +rewrite_file: 2 items of file [7403 7406] moved to [7403 150] +vpf-10680: The file [7403 150] has the wrong block count in the StatData (136) - corrected to (0) +The entry [7403 7406] ("zlib.h") in directory [7399 148] updated to point to [7403 150] +rewrite_file: 2 items of file [7403 7404] moved to [7403 151] +The entry [7403 7404] ("vssver.scc") in directory [7399 148] updated to point to [7403 151] +The entry [7399 148] ("include") in directory [7381 144] updated to point to [7399 148] +relocate_dir: Moving [7432 7439 0x0 SD (0)] to [7432 152 0x0 SD (0)] +relocate_dir: Moving [7432 7439 0x1 DIR (3)] to [7432 152 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7432 152] pointes to [6240 7432], instead of [2 4] - corrected +rewrite_file: 2 items of file [7439 7441] moved to [7439 153] +The entry [7439 7441] ("libtheora.so.0.1.0") in directory [7432 152] updated to point to [7439 153] +rewrite_file: 2 items of file [7439 7440] moved to [7439 154] +The entry [7439 7440] ("libogg.so.0.5.2") in directory [7432 152] updated to point to [7439 154] +rewrite_file: 2 items of file [7439 7443] moved to [7439 155] +The entry [7439 7443] ("theora_static.lib") in directory [7432 152] updated to point to [7439 155] +rewrite_file: 2 items of file [7439 7442] moved to [7439 156] +The entry [7439 7442] ("ogg_static.lib") in directory [7432 152] updated to point to [7439 156] +rewrite_file: 2 items of file [7439 7444] moved to [7439 157] +The entry [7439 7444] ("vssver.scc") in directory [7432 152] updated to point to [7439 157] +relocate_dir: Moving [7432 7445 0x0 SD (0)] to [7432 158 0x0 SD (0)] +relocate_dir: Moving [7432 7445 0x1 DIR (3)] to [7432 158 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7432 158] pointes to [6240 7432], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [7445 7454] ("ogg") in directory [7432 158] points to nowhere - is removed +rebuild_semantic_pass: The entry [7445 7451] ("theora") in directory [7432 158] points to nowhere - is removed +relocate_dir: Moving [7445 7446 0x0 SD (0)] to [7445 159 0x0 SD (0)] +relocate_dir: Moving [7445 7446 0x1 DIR (3)] to [7445 159 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7445 159] pointes to [7432 7445], instead of [7432 158] - corrected +rewrite_file: 2 items of file [7445 7447] moved to [7445 160] +vpf-10680: The file [7445 160] has the wrong block count in the StatData (24) - corrected to (0) +The entry [7445 7447] ("codec.h") in directory [7445 159] updated to point to [7445 160] +rebuild_semantic_pass: The entry [7445 7449] ("vorbisfile.h") in directory [7445 159] points to nowhere - is removed +rewrite_file: 2 items of file [7445 7448] moved to [7445 161] +The entry [7445 7448] ("vorbisenc.h") in directory [7445 159] updated to point to [7445 161] +rebuild_semantic_pass: The entry [7445 7450] ("vssver.scc") in directory [7445 159] points to nowhere - is removed +vpf-10650: The directory [7445 159] has the wrong size in the StatData (168) - corrected to (104) +The entry [7445 159] ("vorbis") in directory [7432 158] updated to point to [7445 159] +vpf-10650: The directory [7432 158] has the wrong size in the StatData (120) - corrected to (72) +relocate_dir: Moving [7460 7466 0x0 SD (0)] to [7460 162 0x0 SD (0)] +relocate_dir: Moving [7460 7466 0x1 DIR (3)] to [7460 162 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7460 162] pointes to [7455 7460], instead of [2 4] - corrected +relocate_dir: Moving [7460 7467 0x0 SD (0)] to [7460 163 0x0 SD (0)] +relocate_dir: Moving [7460 7467 0x1 DIR (3)] to [7460 163 0x1 DIR (3)] +relocate_dir: Moving [7460 7467 0x1a38e600 DIR (3)] to [7460 163 0x1a38e600 DIR (3)] +relocate_dir: Moving [7460 7467 0x710b2480 DIR (3)] to [7460 163 0x710b2480 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7460 163] pointes to [7460 7466], instead of [7460 162] - corrected +rewrite_file: 2 items of file [7460 7640] moved to [7460 164] +The entry [7460 7640] ("NxRevoluteJoint.h") in directory [7460 163] updated to point to [7460 164] +rewrite_file: 2 items of file [7460 7500] moved to [7460 165] +The entry [7460 7500] ("NxConvexForceFieldShapeDesc.h") in directory [7460 163] updated to point to [7460 165] +rewrite_file: 2 items of file [7460 7469] moved to [7460 166] +vpf-10680: The file [7460 166] has the wrong block count in the StatData (16) - corrected to (0) +The entry [7460 7469] ("Nx.h") in directory [7460 163] updated to point to [7460 166] +rewrite_file: 2 items of file [7460 7492] moved to [7460 167] +The entry [7460 7492] ("NxCapsuleShape.h") in directory [7460 163] updated to point to [7460 167] +rewrite_file: 2 items of file [7460 7545] moved to [7460 168] +The entry [7460 7545] ("NxInterfaceStats.h") in directory [7460 163] updated to point to [7460 168] +rewrite_file: 2 items of file [7460 7635] moved to [7460 169] +The entry [7460 7635] ("NxPulleyJointDesc.h") in directory [7460 163] updated to point to [7460 169] +rewrite_file: 2 items of file [7460 7615] moved to [7460 170] +The entry [7460 7615] ("NxMaterialDesc.h") in directory [7460 163] updated to point to [7460 170] +rewrite_file: 2 items of file [7460 7610] moved to [7460 171] +The entry [7460 7610] ("NxJointLimitSoftDesc.h") in directory [7460 163] updated to point to [7460 171] +relocate_dir: Moving [7460 7690 0x0 SD (0)] to [7460 172 0x0 SD (0)] +relocate_dir: Moving [7460 7690 0x1 DIR (3)] to [7460 172 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7460 172] pointes to [7460 7467], instead of [7460 163] - corrected +rewrite_file: 2 items of file [7460 7694] moved to [7460 173] +The entry [7460 7694] ("NxSoftBodyMeshDesc.h") in directory [7460 172] updated to point to [7460 173] +rewrite_file: 2 items of file [7460 7691] moved to [7460 174] +The entry [7460 7691] ("NxSoftBody.h") in directory [7460 172] updated to point to [7460 174] +rewrite_file: 2 items of file [7460 7692] moved to [7460 175] +The entry [7460 7692] ("NxSoftBodyDesc.h") in directory [7460 172] updated to point to [7460 175] +rewrite_file: 2 items of file [7460 7693] moved to [7460 176] +The entry [7460 7693] ("NxSoftBodyMesh.h") in directory [7460 172] updated to point to [7460 176] +rewrite_file: 2 items of file [7460 7695] moved to [7460 177] +The entry [7460 7695] ("vssver.scc") in directory [7460 172] updated to point to [7460 177] +The entry [7460 172] ("softbody") in directory [7460 163] updated to point to [7460 172] +rewrite_file: 2 items of file [7460 7641] moved to [7460 178] +The entry [7460 7641] ("NxRevoluteJointDesc.h") in directory [7460 163] updated to point to [7460 178] +rewrite_file: 2 items of file [7460 7482] moved to [7460 179] +The entry [7460 7482] ("NxBox.h") in directory [7460 163] updated to point to [7460 179] +rewrite_file: 2 items of file [7460 7671] moved to [7460 180] +The entry [7460 7671] ("NxTriangleMeshShape.h") in directory [7460 163] updated to point to [7460 180] +rewrite_file: 2 items of file [7460 7516] moved to [7460 181] +The entry [7460 7516] ("NxExportedUtils.h") in directory [7460 163] updated to point to [7460 181] +rewrite_file: 2 items of file [7460 7638] moved to [7460 182] +The entry [7460 7638] ("NxRay.h") in directory [7460 163] updated to point to [7460 182] +rewrite_file: 2 items of file [7460 7497] moved to [7460 183] +The entry [7460 7497] ("NxCompartmentDesc.h") in directory [7460 163] updated to point to [7460 183] +rewrite_file: 2 items of file [7460 7659] moved to [7460 184] +The entry [7460 7659] ("NxSphereShapeDesc.h") in directory [7460 163] updated to point to [7460 184] +rewrite_file: 2 items of file [7460 7514] moved to [7460 185] +The entry [7460 7514] ("NxEffectorDesc.h") in directory [7460 163] updated to point to [7460 185] +rewrite_file: 2 items of file [7460 7603] moved to [7460 186] +The entry [7460 7603] ("NxIntersectionSegmentBox.h") in directory [7460 163] updated to point to [7460 186] +rewrite_file: 2 items of file [7460 7644] moved to [7460 187] +The entry [7460 7644] ("NxSceneQuery.h") in directory [7460 163] updated to point to [7460 187] +rewrite_file: 2 items of file [7460 7525] moved to [7460 188] +The entry [7460 7525] ("NxForceFieldKernelDefs.h") in directory [7460 163] updated to point to [7460 188] +rewrite_file: 2 items of file [7460 7488] moved to [7460 189] +The entry [7460 7488] ("Nxc.h") in directory [7460 163] updated to point to [7460 189] +rewrite_file: 2 items of file [7460 7518] moved to [7460 190] +The entry [7460 7518] ("Nxf.h") in directory [7460 163] updated to point to [7460 190] +rewrite_file: 2 items of file [7460 7619] moved to [7460 191] +The entry [7460 7619] ("Nxp.h") in directory [7460 163] updated to point to [7460 191] +rewrite_file: 2 items of file [7460 7536] moved to [7460 192] +The entry [7460 7536] ("NxHeightFieldSample.h") in directory [7460 163] updated to point to [7460 192] +rewrite_file: 2 items of file [7460 7541] moved to [7460 193] +The entry [7460 7541] ("NxHwTarget.h") in directory [7460 163] updated to point to [7460 193] +rewrite_file: 2 items of file [7460 7605] moved to [7460 194] +The entry [7460 7605] ("NxIntersectionSweptSpheres.h") in directory [7460 163] updated to point to [7460 194] +rewrite_file: 2 items of file [7460 7654] moved to [7460 195] +The entry [7460 7654] ("NxSoftBodyUserNotify.h") in directory [7460 163] updated to point to [7460 195] +relocate_dir: Moving [7460 7706 0x0 SD (0)] to [7460 196 0x0 SD (0)] +relocate_dir: Moving [7460 7706 0x1 DIR (3)] to [7460 196 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7460 196] pointes to [7460 7467], instead of [7460 163] - corrected +rewrite_file: 2 items of file [7460 7707] moved to [7460 197] +The entry [7460 7707] ("NxCloth.h") in directory [7460 196] updated to point to [7460 197] +rewrite_file: 2 items of file [7460 7708] moved to [7460 198] +The entry [7460 7708] ("NxClothDesc.h") in directory [7460 196] updated to point to [7460 198] +rewrite_file: 2 items of file [7460 7709] moved to [7460 199] +The entry [7460 7709] ("NxClothMesh.h") in directory [7460 196] updated to point to [7460 199] +rewrite_file: 2 items of file [7460 7710] moved to [7460 200] +The entry [7460 7710] ("NxClothMeshDesc.h") in directory [7460 196] updated to point to [7460 200] +rewrite_file: 2 items of file [7460 7711] moved to [7460 201] +The entry [7460 7711] ("vssver.scc") in directory [7460 196] updated to point to [7460 201] +The entry [7460 196] ("cloth") in directory [7460 163] updated to point to [7460 196] +rewrite_file: 2 items of file [7460 7675] moved to [7460 202] +The entry [7460 7675] ("NxUserContactReport.h") in directory [7460 163] updated to point to [7460 202] +rewrite_file: 2 items of file [7460 7687] moved to [7460 203] +The entry [7460 7687] ("PhysXLoader.h") in directory [7460 163] updated to point to [7460 203] +rewrite_file: 2 items of file [7460 7617] moved to [7460 204] +The entry [7460 7617] ("NxMeshData.h") in directory [7460 163] updated to point to [7460 204] +rewrite_file: 2 items of file [7460 7533] moved to [7460 205] +The entry [7460 7533] ("NxFoundationSDK.h") in directory [7460 163] updated to point to [7460 205] +rewrite_file: 2 items of file [7460 7624] moved to [7460 206] +The entry [7460 7624] ("NxPlaneShapeDesc.h") in directory [7460 163] updated to point to [7460 206] +rewrite_file: 2 items of file [7460 7618] moved to [7460 207] +The entry [7460 7618] ("NxMotorDesc.h") in directory [7460 163] updated to point to [7460 207] +rewrite_file: 2 items of file [7460 7633] moved to [7460 208] +The entry [7460 7633] ("NxProfiler.h") in directory [7460 163] updated to point to [7460 208] +rewrite_file: 2 items of file [7460 7477] moved to [7460 209] +The entry [7460 7477] ("NxArray.h") in directory [7460 163] updated to point to [7460 209] +rewrite_file: 2 items of file [7460 7665] moved to [7460 210] +The entry [7460 7665] ("NxStream.h") in directory [7460 163] updated to point to [7460 210] +rewrite_file: 2 items of file [7460 7524] moved to [7460 211] +The entry [7460 7524] ("NxForceFieldKernel.h") in directory [7460 163] updated to point to [7460 211] +rewrite_file: 2 items of file [7460 7476] moved to [7460 212] +The entry [7460 7476] ("NxAllocatorDefault.h") in directory [7460 163] updated to point to [7460 212] +rewrite_file: 2 items of file [7460 7647] moved to [7460 213] +The entry [7460 7647] ("NxScheduler.h") in directory [7460 163] updated to point to [7460 213] +rewrite_file: 2 items of file [7460 7526] moved to [7460 214] +The entry [7460 7526] ("NxForceFieldLinearKernel.h") in directory [7460 163] updated to point to [7460 214] +rewrite_file: 2 items of file [7460 7478] moved to [7460 215] +The entry [7460 7478] ("NxAssert.h") in directory [7460 163] updated to point to [7460 215] +rewrite_file: 2 items of file [7460 7510] moved to [7460 216] +The entry [7460 7510] ("NxDebugRenderable.h") in directory [7460 163] updated to point to [7460 216] +rewrite_file: 2 items of file [7460 7515] moved to [7460 217] +The entry [7460 7515] ("NxException.h") in directory [7460 163] updated to point to [7460 217] +rewrite_file: 2 items of file [7460 7667] moved to [7460 218] +The entry [7460 7667] ("NxTargets.h") in directory [7460 163] updated to point to [7460 218] +rewrite_file: 2 items of file [7460 7684] moved to [7460 219] +The entry [7460 7684] ("NxVolumeIntegration.h") in directory [7460 163] updated to point to [7460 219] +rewrite_file: 2 items of file [7460 7679] moved to [7460 220] +The entry [7460 7679] ("NxUserRaycastReport.h") in directory [7460 163] updated to point to [7460 220] +rewrite_file: 2 items of file [7460 7637] moved to [7460 221] +The entry [7460 7637] ("NxQuickSort.h") in directory [7460 163] updated to point to [7460 221] +rewrite_file: 2 items of file [7460 7629] moved to [7460 222] +The entry [7460 7629] ("NxPointOnLineJointDesc.h") in directory [7460 163] updated to point to [7460 222] +rewrite_file: 2 items of file [7460 7661] moved to [7460 223] +The entry [7460 7661] ("NxSphericalJointDesc.h") in directory [7460 163] updated to point to [7460 223] +rewrite_file: 2 items of file [7460 7622] moved to [7460 224] +The entry [7460 7622] ("NxPlane.h") in directory [7460 163] updated to point to [7460 224] +rewrite_file: 2 items of file [7460 7472] moved to [7460 225] +The entry [7460 7472] ("Nx9F32.h") in directory [7460 163] updated to point to [7460 225] +rewrite_file: 2 items of file [7460 7620] moved to [7460 226] +The entry [7460 7620] ("NxPhysics.h") in directory [7460 163] updated to point to [7460 226] +rewrite_file: 2 items of file [7460 7607] moved to [7460 227] +The entry [7460 7607] ("NxJointDesc.h") in directory [7460 163] updated to point to [7460 227] +rewrite_file: 2 items of file [7460 7522] moved to [7460 228] +The entry [7460 7522] ("NxForceField.h") in directory [7460 163] updated to point to [7460 228] +rewrite_file: 2 items of file [7460 7634] moved to [7460 229] +The entry [7460 7634] ("NxPulleyJoint.h") in directory [7460 163] updated to point to [7460 229] +rewrite_file: 2 items of file [7460 7508] moved to [7460 230] +The entry [7460 7508] ("NxD6Joint.h") in directory [7460 163] updated to point to [7460 230] +rewrite_file: 2 items of file [7460 7474] moved to [7460 231] +The entry [7460 7474] ("NxActorDesc.h") in directory [7460 163] updated to point to [7460 231] +rewrite_file: 2 items of file [7460 7686] moved to [7460 232] +The entry [7460 7686] ("NxWheelShapeDesc.h") in directory [7460 163] updated to point to [7460 232] +rewrite_file: 2 items of file [7460 7491] moved to [7460 233] +The entry [7460 7491] ("NxCapsuleForceFieldShapeDesc.h") in directory [7460 163] updated to point to [7460 233] +rewrite_file: 2 items of file [7460 7475] moved to [7460 234] +The entry [7460 7475] ("NxAllocateable.h") in directory [7460 163] updated to point to [7460 234] +rewrite_file: 2 items of file [7460 7489] moved to [7460 235] +The entry [7460 7489] ("NxCapsule.h") in directory [7460 163] updated to point to [7460 235] +rewrite_file: 2 items of file [7460 7645] moved to [7460 236] +The entry [7460 7645] ("NxSceneStats.h") in directory [7460 163] updated to point to [7460 236] +rewrite_file: 2 items of file [7460 7643] moved to [7460 237] +The entry [7460 7643] ("NxSceneDesc.h") in directory [7460 163] updated to point to [7460 237] +rewrite_file: 2 items of file [7460 7673] moved to [7460 238] +The entry [7460 7673] ("NxUserAllocator.h") in directory [7460 163] updated to point to [7460 238] +rewrite_file: 2 items of file [7460 7621] moved to [7460 239] +The entry [7460 7621] ("NxPhysicsSDK.h") in directory [7460 163] updated to point to [7460 239] +rewrite_file: 2 items of file [7460 7602] moved to [7460 240] +The entry [7460 7602] ("NxIntersectionRayTriangle.h") in directory [7460 163] updated to point to [7460 240] +rewrite_file: 2 items of file [7460 7676] moved to [7460 241] +The entry [7460 7676] ("NxUserEntityReport.h") in directory [7460 163] updated to point to [7460 241] +rewrite_file: 2 items of file [7460 7627] moved to [7460 242] +The entry [7460 7627] ("NxPointInPlaneJointDesc.h") in directory [7460 163] updated to point to [7460 242] +rewrite_file: 2 items of file [7460 7656] moved to [7460 243] +The entry [7460 7656] ("NxSphereForceFieldShape.h") in directory [7460 163] updated to point to [7460 243] +rewrite_file: 2 items of file [7460 7685] moved to [7460 244] +The entry [7460 7685] ("NxWheelShape.h") in directory [7460 163] updated to point to [7460 244] +rewrite_file: 2 items of file [7460 7506] moved to [7460 245] +The entry [7460 7506] ("NxCylindricalJoint.h") in directory [7460 163] updated to point to [7460 245] +rewrite_file: 2 items of file [7460 7487] moved to [7460 246] +The entry [7460 7487] ("NxBuildNumber.h") in directory [7460 163] updated to point to [7460 246] +rewrite_file: 2 items of file [7460 7505] moved to [7460 247] +The entry [7460 7505] ("NxCooking.h") in directory [7460 163] updated to point to [7460 247] +rewrite_file: 2 items of file [7460 7631] moved to [7460 248] +The entry [7460 7631] ("NxPrismaticJoint.h") in directory [7460 163] updated to point to [7460 248] +rewrite_file: 2 items of file [7460 7663] moved to [7460 249] +The entry [7460 7663] ("NxSpringAndDamperEffectorDesc.h") in directory [7460 163] updated to point to [7460 249] +rewrite_file: 2 items of file [7460 7606] moved to [7460 250] +The entry [7460 7606] ("NxJoint.h") in directory [7460 163] updated to point to [7460 250] +rewrite_file: 2 items of file [7460 7680] moved to [7460 251] +The entry [7460 7680] ("NxUtilities.h") in directory [7460 163] updated to point to [7460 251] +rewrite_file: 2 items of file [7460 7626] moved to [7460 252] +The entry [7460 7626] ("NxPointInPlaneJoint.h") in directory [7460 163] updated to point to [7460 252] +rewrite_file: 2 items of file [7460 7544] moved to [7460 253] +The entry [7460 7544] ("NxInterface.h") in directory [7460 163] updated to point to [7460 253] +rewrite_file: 2 items of file [7460 7632] moved to [7460 254] +The entry [7460 7632] ("NxPrismaticJointDesc.h") in directory [7460 163] updated to point to [7460 254] +rewrite_file: 2 items of file [7460 7658] moved to [7460 255] +The entry [7460 7658] ("NxSphereShape.h") in directory [7460 163] updated to point to [7460 255] +rewrite_file: 2 items of file [7460 7689] moved to [7460 256] +The entry [7460 7689] ("Win32RegistryAccess.h") in directory [7460 163] updated to point to [7460 256] +rewrite_file: 2 items of file [7460 7655] moved to [7460 257] +The entry [7460 7655] ("NxSphere.h") in directory [7460 163] updated to point to [7460 257] +rewrite_file: 2 items of file [7460 7528] moved to [7460 258] +The entry [7460 7528] ("NxForceFieldShape.h") in directory [7460 163] updated to point to [7460 258] +rewrite_file: 2 items of file [7460 7639] moved to [7460 259] +The entry [7460 7639] ("NxRemoteDebugger.h") in directory [7460 163] updated to point to [7460 259] +relocate_dir: Moving [7460 7696 0x0 SD (0)] to [7460 260 0x0 SD (0)] +relocate_dir: Moving [7460 7696 0x1 DIR (3)] to [7460 260 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7460 260] pointes to [7460 7467], instead of [7460 163] - corrected +rewrite_file: 2 items of file [7460 7700] moved to [7460 261] +The entry [7460 7700] ("NxFluidEmitterDesc.h") in directory [7460 260] updated to point to [7460 261] +rewrite_file: 2 items of file [7460 7698] moved to [7460 262] +The entry [7460 7698] ("NxFluidDesc.h") in directory [7460 260] updated to point to [7460 262] +rewrite_file: 2 items of file [7460 7701] moved to [7460 263] +The entry [7460 7701] ("NxFluidPacketData.h") in directory [7460 260] updated to point to [7460 263] +rewrite_file: 2 items of file [7460 7702] moved to [7460 264] +The entry [7460 7702] ("NxParticleData.h") in directory [7460 260] updated to point to [7460 264] +rewrite_file: 2 items of file [7460 7704] moved to [7460 265] +The entry [7460 7704] ("NxParticleUpdateData.h") in directory [7460 260] updated to point to [7460 265] +rewrite_file: 2 items of file [7460 7699] moved to [7460 266] +The entry [7460 7699] ("NxFluidEmitter.h") in directory [7460 260] updated to point to [7460 266] +rewrite_file: 2 items of file [7460 7697] moved to [7460 267] +The entry [7460 7697] ("NxFluid.h") in directory [7460 260] updated to point to [7460 267] +rewrite_file: 2 items of file [7460 7703] moved to [7460 268] +The entry [7460 7703] ("NxParticleIdData.h") in directory [7460 260] updated to point to [7460 268] +rewrite_file: 2 items of file [7460 7705] moved to [7460 269] +The entry [7460 7705] ("vssver.scc") in directory [7460 260] updated to point to [7460 269] +The entry [7460 260] ("fluids") in directory [7460 163] updated to point to [7460 260] +rewrite_file: 2 items of file [7460 7485] moved to [7460 270] +The entry [7460 7485] ("NxBoxShape.h") in directory [7460 163] updated to point to [7460 270] +rewrite_file: 2 items of file [7460 7623] moved to [7460 271] +The entry [7460 7623] ("NxPlaneShape.h") in directory [7460 163] updated to point to [7460 271] +rewrite_file: 2 items of file [7460 7648] moved to [7460 272] +The entry [7460 7648] ("NxSegment.h") in directory [7460 163] updated to point to [7460 272] +rewrite_file: 2 items of file [7460 7483] moved to [7460 273] +The entry [7460 7483] ("NxBoxForceFieldShape.h") in directory [7460 163] updated to point to [7460 273] +rewrite_file: 2 items of file [7460 7480] moved to [7460 274] +The entry [7460 7480] ("NxBodyDesc.h") in directory [7460 163] updated to point to [7460 274] +rewrite_file: 2 items of file [7460 7517] moved to [7460 275] +The entry [7460 7517] ("NxExpression.h") in directory [7460 163] updated to point to [7460 275] +rewrite_file: 2 items of file [7460 7496] moved to [7460 276] +The entry [7460 7496] ("NxCompartment.h") in directory [7460 163] updated to point to [7460 276] +rewrite_file: 2 items of file [7460 7670] moved to [7460 277] +The entry [7460 7670] ("NxTriangleMeshDesc.h") in directory [7460 163] updated to point to [7460 277] +rewrite_file: 2 items of file [7460 7511] moved to [7460 278] +The entry [7460 7511] ("NxDistanceJoint.h") in directory [7460 163] updated to point to [7460 278] +rewrite_file: 2 items of file [7460 7683] moved to [7460 279] +The entry [7460 7683] ("NxVersionNumber.h") in directory [7460 163] updated to point to [7460 279] +rewrite_file: 2 items of file [7460 7484] moved to [7460 280] +The entry [7460 7484] ("NxBoxForceFieldShapeDesc.h") in directory [7460 163] updated to point to [7460 280] +rewrite_file: 2 items of file [7460 7611] moved to [7460 281] +The entry [7460 7611] ("NxJointLimitSoftPairDesc.h") in directory [7460 163] updated to point to [7460 281] +rewrite_file: 2 items of file [7460 7589] moved to [7460 282] +The entry [7460 7589] ("NxIntersectionBoxBox.h") in directory [7460 163] updated to point to [7460 282] +rewrite_file: 2 items of file [7460 7519] moved to [7460 283] +The entry [7460 7519] ("NxFixedJoint.h") in directory [7460 163] updated to point to [7460 283] +rewrite_file: 2 items of file [7460 7642] moved to [7460 284] +The entry [7460 7642] ("NxScene.h") in directory [7460 163] updated to point to [7460 284] +rewrite_file: 2 items of file [7460 7616] moved to [7460 285] +The entry [7460 7616] ("NxMath.h") in directory [7460 163] updated to point to [7460 285] +rewrite_file: 2 items of file [7460 7486] moved to [7460 286] +The entry [7460 7486] ("NxBoxShapeDesc.h") in directory [7460 163] updated to point to [7460 286] +rewrite_file: 2 items of file [7460 7652] moved to [7460 287] +The entry [7460 7652] ("NxSimpleTypes.h") in directory [7460 163] updated to point to [7460 287] +rewrite_file: 2 items of file [7460 7509] moved to [7460 288] +The entry [7460 7509] ("NxD6JointDesc.h") in directory [7460 163] updated to point to [7460 288] +rewrite_file: 2 items of file [7460 7625] moved to [7460 289] +The entry [7460 7625] ("NxPMap.h") in directory [7460 163] updated to point to [7460 289] +rewrite_file: 2 items of file [7460 7628] moved to [7460 290] +The entry [7460 7628] ("NxPointOnLineJoint.h") in directory [7460 163] updated to point to [7460 290] +rewrite_file: 2 items of file [7460 7650] moved to [7460 291] +The entry [7460 7650] ("NxShapeDesc.h") in directory [7460 163] updated to point to [7460 291] +rewrite_file: 2 items of file [7460 7502] moved to [7460 292] +The entry [7460 7502] ("NxConvexMeshDesc.h") in directory [7460 163] updated to point to [7460 292] +rewrite_file: 2 items of file [7460 7543] moved to [7460 293] +The entry [7460 7543] ("NxInertiaTensor.h") in directory [7460 163] updated to point to [7460 293] +rewrite_file: 2 items of file [7460 7614] moved to [7460 294] +The entry [7460 7614] ("NxMaterial.h") in directory [7460 163] updated to point to [7460 294] +rewrite_file: 2 items of file [7460 7649] moved to [7460 295] +The entry [7460 7649] ("NxShape.h") in directory [7460 163] updated to point to [7460 295] +rewrite_file: 2 items of file [7460 7630] moved to [7460 296] +The entry [7460 7630] ("NxPool.h") in directory [7460 163] updated to point to [7460 296] +rewrite_file: 2 items of file [7460 7507] moved to [7460 297] +The entry [7460 7507] ("NxCylindricalJointDesc.h") in directory [7460 163] updated to point to [7460 297] +rewrite_file: 2 items of file [7460 7678] moved to [7460 298] +The entry [7460 7678] ("NxUserOutputStream.h") in directory [7460 163] updated to point to [7460 298] +rewrite_file: 2 items of file [7460 7527] moved to [7460 299] +The entry [7460 7527] ("NxForceFieldLinearKernelDesc.h") in directory [7460 163] updated to point to [7460 299] +rewrite_file: 2 items of file [7460 7636] moved to [7460 300] +The entry [7460 7636] ("NxQuat.h") in directory [7460 163] updated to point to [7460 300] +rewrite_file: 2 items of file [7460 7512] moved to [7460 301] +The entry [7460 7512] ("NxDistanceJointDesc.h") in directory [7460 163] updated to point to [7460 301] +rewrite_file: 2 items of file [7460 7521] moved to [7460 302] +The entry [7460 7521] ("NxFluidUserNotify.h") in directory [7460 163] updated to point to [7460 302] +rewrite_file: 2 items of file [7460 7660] moved to [7460 303] +The entry [7460 7660] ("NxSphericalJoint.h") in directory [7460 163] updated to point to [7460 303] +rewrite_file: 2 items of file [7460 7612] moved to [7460 304] +The entry [7460 7612] ("NxMat33.h") in directory [7460 163] updated to point to [7460 304] +rewrite_file: 2 items of file [7460 7613] moved to [7460 305] +The entry [7460 7613] ("NxMat34.h") in directory [7460 163] updated to point to [7460 305] +rewrite_file: 2 items of file [7460 7531] moved to [7460 306] +The entry [7460 7531] ("NxForceFieldShapeGroupDesc.h") in directory [7460 163] updated to point to [7460 306] +rewrite_file: 2 items of file [7460 7501] moved to [7460 307] +The entry [7460 7501] ("NxConvexMesh.h") in directory [7460 163] updated to point to [7460 307] +rewrite_file: 2 items of file [7460 7674] moved to [7460 308] +The entry [7460 7674] ("NxUserAllocatorDefault.h") in directory [7460 163] updated to point to [7460 308] +rewrite_file: 2 items of file [7460 7503] moved to [7460 309] +The entry [7460 7503] ("NxConvexShape.h") in directory [7460 163] updated to point to [7460 309] +rewrite_file: 2 items of file [7460 7682] moved to [7460 310] +The entry [7460 7682] ("NxVec3.h") in directory [7460 163] updated to point to [7460 310] +rewrite_file: 2 items of file [7460 7672] moved to [7460 311] +The entry [7460 7672] ("NxTriangleMeshShapeDesc.h") in directory [7460 163] updated to point to [7460 311] +rewrite_file: 2 items of file [7460 7540] moved to [7460 312] +The entry [7460 7540] ("NxHwParser.h") in directory [7460 163] updated to point to [7460 312] +rewrite_file: 2 items of file [7460 7529] moved to [7460 313] +The entry [7460 7529] ("NxForceFieldShapeDesc.h") in directory [7460 163] updated to point to [7460 313] +rewrite_file: 2 items of file [7460 7677] moved to [7460 314] +The entry [7460 7677] ("NxUserNotify.h") in directory [7460 163] updated to point to [7460 314] +rewrite_file: 2 items of file [7460 7591] moved to [7460 315] +The entry [7460 7591] ("NxIntersectionRayPlane.h") in directory [7460 163] updated to point to [7460 315] +rewrite_file: 2 items of file [7460 7534] moved to [7460 316] +The entry [7460 7534] ("NxHeightField.h") in directory [7460 163] updated to point to [7460 316] +rewrite_file: 2 items of file [7460 7481] moved to [7460 317] +The entry [7460 7481] ("NxBounds3.h") in directory [7460 163] updated to point to [7460 317] +rewrite_file: 2 items of file [7460 7608] moved to [7460 318] +The entry [7460 7608] ("NxJointLimitDesc.h") in directory [7460 163] updated to point to [7460 318] +rewrite_file: 2 items of file [7460 7490] moved to [7460 319] +The entry [7460 7490] ("NxCapsuleForceFieldShape.h") in directory [7460 163] updated to point to [7460 319] +rewrite_file: 2 items of file [7460 7590] moved to [7460 320] +The entry [7460 7590] ("NxIntersectionPointTriangle.h") in directory [7460 163] updated to point to [7460 320] +rewrite_file: 2 items of file [7460 7653] moved to [7460 321] +The entry [7460 7653] ("NxSmoothNormals.h") in directory [7460 163] updated to point to [7460 321] +rewrite_file: 2 items of file [7460 7532] moved to [7460 322] +The entry [7460 7532] ("NxFoundation.h") in directory [7460 163] updated to point to [7460 322] +rewrite_file: 2 items of file [7460 7604] moved to [7460 323] +The entry [7460 7604] ("NxIntersectionSegmentCapsule.h") in directory [7460 163] updated to point to [7460 323] +rewrite_file: 2 items of file [7460 7530] moved to [7460 324] +The entry [7460 7530] ("NxForceFieldShapeGroup.h") in directory [7460 163] updated to point to [7460 324] +rewrite_file: 2 items of file [7460 7479] moved to [7460 325] +The entry [7460 7479] ("NxBitField.h") in directory [7460 163] updated to point to [7460 325] +rewrite_file: 2 items of file [7460 7609] moved to [7460 326] +The entry [7460 7609] ("NxJointLimitPairDesc.h") in directory [7460 163] updated to point to [7460 326] +rewrite_file: 2 items of file [7460 7657] moved to [7460 327] +The entry [7460 7657] ("NxSphereForceFieldShapeDesc.h") in directory [7460 163] updated to point to [7460 327] +rewrite_file: 2 items of file [7460 7523] moved to [7460 328] +The entry [7460 7523] ("NxForceFieldDesc.h") in directory [7460 163] updated to point to [7460 328] +rewrite_file: 2 items of file [7460 7493] moved to [7460 329] +The entry [7460 7493] ("NxCapsuleShapeDesc.h") in directory [7460 163] updated to point to [7460 329] +rewrite_file: 2 items of file [7460 7513] moved to [7460 330] +The entry [7460 7513] ("NxEffector.h") in directory [7460 163] updated to point to [7460 330] +rewrite_file: 2 items of file [7460 7499] moved to [7460 331] +The entry [7460 7499] ("NxConvexForceFieldShape.h") in directory [7460 163] updated to point to [7460 331] +rewrite_file: 2 items of file [7460 7494] moved to [7460 332] +The entry [7460 7494] ("NxCCDSkeleton.h") in directory [7460 163] updated to point to [7460 332] +rewrite_file: 2 items of file [7460 7504] moved to [7460 333] +The entry [7460 7504] ("NxConvexShapeDesc.h") in directory [7460 163] updated to point to [7460 333] +rewrite_file: 2 items of file [7460 7535] moved to [7460 334] +The entry [7460 7535] ("NxHeightFieldDesc.h") in directory [7460 163] updated to point to [7460 334] +rewrite_file: 2 items of file [7460 7468] moved to [7460 335] +vpf-10680: The file [7460 335] has the wrong block count in the StatData (16) - corrected to (0) +The entry [7460 7468] ("fw-convex-cooker.h") in directory [7460 163] updated to point to [7460 335] +rewrite_file: 2 items of file [7460 7662] moved to [7460 336] +The entry [7460 7662] ("NxSpringAndDamperEffector.h") in directory [7460 163] updated to point to [7460 336] +rewrite_file: 2 items of file [7460 7668] moved to [7460 337] +The entry [7460 7668] ("NxTriangle.h") in directory [7460 163] updated to point to [7460 337] +rewrite_file: 2 items of file [7460 7666] moved to [7460 338] +The entry [7460 7666] ("NxSwTarget.h") in directory [7460 163] updated to point to [7460 338] +rewrite_file: 2 items of file [7460 7542] moved to [7460 339] +The entry [7460 7542] ("NxI16Vec3.h") in directory [7460 163] updated to point to [7460 339] +rewrite_file: 2 items of file [7460 7539] moved to [7460 340] +The entry [7460 7539] ("NxHeightFieldShapeDesc.h") in directory [7460 163] updated to point to [7460 340] +rewrite_file: 2 items of file [7460 7664] moved to [7460 341] +The entry [7460 7664] ("NxSpringDesc.h") in directory [7460 163] updated to point to [7460 341] +rewrite_file: 2 items of file [7460 7601] moved to [7460 342] +The entry [7460 7601] ("NxIntersectionRaySphere.h") in directory [7460 163] updated to point to [7460 342] +rewrite_file: 2 items of file [7460 7470] moved to [7460 343] +The entry [7460 7470] ("Nx12F32.h") in directory [7460 163] updated to point to [7460 343] +rewrite_file: 2 items of file [7460 7681] moved to [7460 344] +The entry [7460 7681] ("NxUtilLib.h") in directory [7460 163] updated to point to [7460 344] +rewrite_file: 2 items of file [7460 7520] moved to [7460 345] +The entry [7460 7520] ("NxFixedJointDesc.h") in directory [7460 163] updated to point to [7460 345] +rewrite_file: 2 items of file [7460 7669] moved to [7460 346] +The entry [7460 7669] ("NxTriangleMesh.h") in directory [7460 163] updated to point to [7460 346] +rewrite_file: 2 items of file [7460 7688] moved to [7460 347] +The entry [7460 7688] ("vssver.scc") in directory [7460 163] updated to point to [7460 347] +rewrite_file: 2 items of file [7460 7646] moved to [7460 348] +The entry [7460 7646] ("NxSceneStats2.h") in directory [7460 163] updated to point to [7460 348] +rewrite_file: 2 items of file [7460 7651] moved to [7460 349] +The entry [7460 7651] ("NxSimpleTriangleMesh.h") in directory [7460 163] updated to point to [7460 349] +rewrite_file: 2 items of file [7460 7498] moved to [7460 350] +The entry [7460 7498] ("NxContactStreamIterator.h") in directory [7460 163] updated to point to [7460 350] +rewrite_file: 2 items of file [7460 7473] moved to [7460 351] +vpf-10680: The file [7460 351] has the wrong block count in the StatData (144) - corrected to (136) +The entry [7460 7473] ("NxActor.h") in directory [7460 163] updated to point to [7460 351] +rewrite_file: 2 items of file [7460 7495] moved to [7460 352] +The entry [7460 7495] ("NxClothUserNotify.h") in directory [7460 163] updated to point to [7460 352] +rewrite_file: 2 items of file [7460 7538] moved to [7460 353] +The entry [7460 7538] ("NxHeightFieldShape.h") in directory [7460 163] updated to point to [7460 353] +rewrite_file: 2 items of file [7460 7471] moved to [7460 354] +The entry [7460 7471] ("Nx16F32.h") in directory [7460 163] updated to point to [7460 354] +The entry [7460 163] ("PX") in directory [7460 162] updated to point to [7460 163] +relocate_dir: Moving [7460 7712 0x0 SD (0)] to [7460 355 0x0 SD (0)] +relocate_dir: Moving [7460 7712 0x1 DIR (3)] to [7460 355 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7460 355] pointes to [7455 7460], instead of [2 4] - corrected +rewrite_file: 2 items of file [7460 7714] moved to [7460 356] +The entry [7460 7714] ("PhysXLoader.dll") in directory [7460 355] updated to point to [7460 356] +rewrite_file: 2 items of file [7460 7713] moved to [7460 357] +The entry [7460 7713] ("NxCooking.dll") in directory [7460 355] updated to point to [7460 357] +rewrite_file: 2 items of file [7460 7715] moved to [7460 358] +The entry [7460 7715] ("vssver.scc") in directory [7460 355] updated to point to [7460 358] +get_next_directory_item: The entry ".." of the directory [7472 9089] pointes to [7472 9084], instead of [2 4] - corrected +rewrite_file: 2 items of file [7472 9120] moved to [7472 359] +The entry [7472 9120] ("SAX.h") in directory [7472 9095] updated to point to [7472 359] +rewrite_file: 2 items of file [7472 9365] moved to [7472 360] +The entry [7472 9365] ("xmlwin32version.h") in directory [7472 9095] updated to point to [7472 360] +get_next_directory_item: The entry ".." of the directory [7472 9377] pointes to [7472 9084], instead of [2 4] - corrected +vpf-10680: The file [9378 9382] has the wrong block count in the StatData (6320) - corrected to (176) +rewrite_file: 2 items of file [9386 9420] moved to [9386 361] +The entry [9386 9420] ("SAX.h") in directory [9386 9387] updated to point to [9386 361] +rewrite_file: 2 items of file [9386 9390] moved to [9386 362] +The entry [9386 9390] ("chvalid.h") in directory [9386 9387] updated to point to [9386 362] +rewrite_file: 2 items of file [9386 9423] moved to [9386 363] +The entry [9386 9423] ("SAX2.h") in directory [9386 9387] updated to point to [9386 363] +rewrite_file: 2 items of file [9386 9424] moved to [9386 364] +The entry [9386 9424] ("schemasInternals.h") in directory [9386 9387] updated to point to [9386 364] +rewrite_file: 2 items of file [9386 9425] moved to [9386 365] +The entry [9386 9425] ("threads.h") in directory [9386 9387] updated to point to [9386 365] +rewrite_file: 2 items of file [9386 9403] moved to [9386 366] +The entry [9386 9403] ("parser.h") in directory [9386 9387] updated to point to [9386 366] +rewrite_file: 2 items of file [9386 9406] moved to [9386 367] +The entry [9386 9406] ("pattern.h") in directory [9386 9387] updated to point to [9386 367] +rewrite_file: 2 items of file [9386 9419] moved to [9386 368] +The entry [9386 9419] ("relaxng.h") in directory [9386 9387] updated to point to [9386 368] +rewrite_file: 2 items of file [9386 9404] moved to [9386 369] +The entry [9386 9404] ("parserInternals.h") in directory [9386 9387] updated to point to [9386 369] +rewrite_file: 2 items of file [9386 9426] moved to [9386 370] +The entry [9386 9426] ("tree.h") in directory [9386 9387] updated to point to [9386 370] +rewrite_file: 2 items of file [9386 9391] moved to [9386 371] +The entry [9386 9391] ("debugXML.h") in directory [9386 9387] updated to point to [9386 371] +relocate_dir: Moving [7652 7653 0x0 SD (0)] to [7652 372 0x0 SD (0)] +relocate_dir: Moving [7652 7653 0x1 DIR (3)] to [7652 372 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [7652 372] pointes to [6990 7652], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [7652 7658] ("pc") in directory [7652 372] points to nowhere - is removed +rebuild_semantic_pass: The entry [7652 7671] ("linux") in directory [7652 372] points to nowhere - is removed +rewrite_file: 2 items of file [7652 7654] moved to [7652 373] +The entry [7652 7654] ("Readme.txt") in directory [7652 372] updated to point to [7652 373] +rebuild_semantic_pass: The entry [7652 7656] ("zlib-1.2.3.tar.gz") in directory [7652 372] points to nowhere - is removed +rebuild_semantic_pass: The entry [7652 7657] ("zlib123-dll.zip") in directory [7652 372] points to nowhere - is removed +rewrite_file: 1 items of file [7652 7655] moved to [7652 374] +vpf-10680: The file [7652 374] has the wrong block count in the StatData (8) - corrected to (0) +The entry [7652 7655] ("vssver.scc") in directory [7652 372] updated to point to [7652 374] +vpf-10650: The directory [7652 372] has the wrong size in the StatData (232) - corrected to (112) +get_next_directory_item: The entry ".." of the directory [9084 9085] pointes to [9015 9084], instead of [2 4] - corrected +vpf-10680: The file [9085 9086] has the wrong block count in the StatData (9464) - corrected to (0) +rebuild_semantic_pass: The entry [9085 9090] ("libxml2.so.2.6.13") in directory [9084 9085] points to nowhere - is removed +rebuild_semantic_pass: The entry [9085 9089] ("libxml2.so.2") in directory [9084 9085] points to nowhere - is removed +rebuild_semantic_pass: The entry [9085 9092] ("xml2Conf.sh") in directory [9084 9085] points to nowhere - is removed +rebuild_semantic_pass: The entry [9085 9087] ("libxml2.la") in directory [9084 9085] points to nowhere - is removed +rebuild_semantic_pass: The entry [9085 9088] ("libxml2.so") in directory [9084 9085] points to nowhere - is removed +rebuild_semantic_pass: The entry [9085 9091] ("vssver.scc") in directory [9084 9085] points to nowhere - is removed +vpf-10650: The directory [9084 9085] has the wrong size in the StatData (280) - corrected to (80) +relocate_dir: Moving [9084 9093 0x0 SD (0)] to [9084 375 0x0 SD (0)] +relocate_dir: Moving [9084 9093 0x1 DIR (3)] to [9084 375 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9084 375] pointes to [9015 9084], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9093 9094] ("libxml") in directory [9084 375] points to nowhere - is removed +vpf-10650: The directory [9084 375] has the wrong size in the StatData (72) - corrected to (48) +relocate_dir: Moving [9430 9434 0x0 SD (0)] to [9430 376 0x0 SD (0)] +relocate_dir: Moving [9430 9434 0x1 DIR (3)] to [9430 376 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9430 376] pointes to [7405 9430], instead of [2 4] - corrected +rewrite_file: 2 items of file [9434 9436] moved to [9434 377] +The entry [9434 9436] ("libhid.la") in directory [9430 376] updated to point to [9434 377] +rewrite_file: 2 items of file [9434 9435] moved to [9434 378] +vpf-10680: The file [9434 378] has the wrong block count in the StatData (152) - corrected to (0) +The entry [9434 9435] ("libhid.a") in directory [9430 376] updated to point to [9434 378] +rewrite_file: 2 items of file [9434 9437] moved to [9434 379] +The entry [9434 9437] ("vssver.scc") in directory [9430 376] updated to point to [9434 379] +relocate_dir: Moving [9430 9438 0x0 SD (0)] to [9430 380 0x0 SD (0)] +relocate_dir: Moving [9430 9438 0x1 DIR (3)] to [9430 380 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9430 380] pointes to [7405 9430], instead of [2 4] - corrected +rewrite_file: 2 items of file [9438 9439] moved to [9438 381] +The entry [9438 9439] ("hid.h") in directory [9430 380] updated to point to [9438 381] +rewrite_file: 3 items of file [9438 9440] moved to [9438 382] +The entry [9438 9440] ("hidparser.h") in directory [9430 380] updated to point to [9438 382] +rewrite_file: 2 items of file [9438 9441] moved to [9438 383] +The entry [9438 9441] ("hidtypes.h") in directory [9430 380] updated to point to [9438 383] +rewrite_file: 2 items of file [9438 9442] moved to [9438 384] +The entry [9438 9442] ("vssver.scc") in directory [9430 380] updated to point to [9438 384] +relocate_dir: Moving [9443 9513 0x0 SD (0)] to [9443 385 0x0 SD (0)] +relocate_dir: Moving [9443 9513 0x1 DIR (3)] to [9443 385 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9443 385] pointes to [7405 9443], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9513 9522] ("jcmarker.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9545] ("jdsample.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9636] ("jpeglib.lib") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9637] ("jpeglib.pch") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9621] ("jfdctint.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9536] ("jddctmgr.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9542] ("jdmerge.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9538] ("jdinput.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9543] ("jdphuff.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9530] ("jdapimin.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9531] ("jdapistd.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9638] ("jquant1.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9694] ("jquant2.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9528] ("jcsample.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9525] ("jcparam.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9624] ("jidctint.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9696] ("vc60.idb") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9544] ("jdpostct.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9518] ("jcdctmgr.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9527] ("jcprepct.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9537] ("jdhuff.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9517] ("jccolor.obj") in directory [9443 385] points to nowhere - is removed +rewrite_file: 2 items of file [9513 9514] moved to [9513 386] +The entry [9513 9514] ("jcapimin.obj") in directory [9443 385] updated to point to [9513 386] +rewrite_file: 1 items of file [9513 9515] moved to [9513 387] +vpf-10680: The file [9513 387] has the wrong block count in the StatData (8) - corrected to (0) +The entry [9513 9515] ("jcapistd.obj") in directory [9443 385] updated to point to [9513 387] +rebuild_semantic_pass: The entry [9513 9524] ("jcomapi.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9625] ("jidctred.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9520] ("jcinit.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9529] ("jctrans.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9634] ("jmemansi.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9532] ("jdatadst.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9534] ("jdcoefct.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9541] ("jdmaster.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9548] ("jfdctflt.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9539] ("jdmainct.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9533] ("jdatasrc.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9540] ("jdmarker.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9535] ("jdcolor.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9620] ("jfdctfst.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9546] ("jdtrans.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9547] ("jerror.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9695] ("jutils.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9516] ("jccoefct.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9622] ("jidctflt.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9519] ("jchuff.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9523] ("jcmaster.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9521] ("jcmainct.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9635] ("jmemmgr.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9526] ("jcphuff.obj") in directory [9443 385] points to nowhere - is removed +rebuild_semantic_pass: The entry [9513 9623] ("jidctfst.obj") in directory [9443 385] points to nowhere - is removed +vpf-10680: The directory [9443 385] has the wrong block count in the StatData (4) - corrected to (1) +vpf-10650: The directory [9443 385] has the wrong size in the StatData (1608) - corrected to (112) +relocate_dir: Moving [9443 9767 0x0 SD (0)] to [9443 388 0x0 SD (0)] +relocate_dir: Moving [9443 9767 0x1 DIR (3)] to [9443 388 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9443 388] pointes to [7405 9443], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [9767 9776] ("jcmarker.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9799] moved to [9767 389] +The entry [9767 9799] ("jdsample.obj") in directory [9443 388] updated to point to [9767 389] +rewrite_file: 2 items of file [9767 9811] moved to [9767 390] +The entry [9767 9811] ("jpeglib.lib") in directory [9443 388] updated to point to [9767 390] +rewrite_file: 2 items of file [9767 9812] moved to [9767 391] +The entry [9767 9812] ("jpeglib.pch") in directory [9443 388] updated to point to [9767 391] +rewrite_file: 2 items of file [9767 9804] moved to [9767 392] +The entry [9767 9804] ("jfdctint.obj") in directory [9443 388] updated to point to [9767 392] +rebuild_semantic_pass: The entry [9767 9790] ("jddctmgr.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9796] moved to [9767 393] +The entry [9767 9796] ("jdmerge.obj") in directory [9443 388] updated to point to [9767 393] +rebuild_semantic_pass: The entry [9767 9792] ("jdinput.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9797] moved to [9767 394] +The entry [9767 9797] ("jdphuff.obj") in directory [9443 388] updated to point to [9767 394] +rebuild_semantic_pass: The entry [9767 9784] ("jdapimin.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9785] ("jdapistd.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9813] moved to [9767 395] +The entry [9767 9813] ("jquant1.obj") in directory [9443 388] updated to point to [9767 395] +rewrite_file: 2 items of file [9767 9814] moved to [9767 396] +The entry [9767 9814] ("jquant2.obj") in directory [9443 388] updated to point to [9767 396] +rebuild_semantic_pass: The entry [9767 9782] ("jcsample.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9779] ("jcparam.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9807] moved to [9767 397] +The entry [9767 9807] ("jidctint.obj") in directory [9443 388] updated to point to [9767 397] +rewrite_file: 2 items of file [9767 9816] moved to [9767 398] +The entry [9767 9816] ("vc60.idb") in directory [9443 388] updated to point to [9767 398] +rewrite_file: 2 items of file [9767 9817] moved to [9767 399] +The entry [9767 9817] ("vc60.pdb") in directory [9443 388] updated to point to [9767 399] +rewrite_file: 2 items of file [9767 9798] moved to [9767 400] +The entry [9767 9798] ("jdpostct.obj") in directory [9443 388] updated to point to [9767 400] +rebuild_semantic_pass: The entry [9767 9772] ("jcdctmgr.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9781] ("jcprepct.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9791] ("jdhuff.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9771] ("jccolor.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9768] ("jcapimin.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9769] ("jcapistd.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9778] ("jcomapi.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9808] moved to [9767 401] +The entry [9767 9808] ("jidctred.obj") in directory [9443 388] updated to point to [9767 401] +rebuild_semantic_pass: The entry [9767 9774] ("jcinit.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9783] ("jctrans.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9809] moved to [9767 402] +The entry [9767 9809] ("jmemansi.obj") in directory [9443 388] updated to point to [9767 402] +rebuild_semantic_pass: The entry [9767 9786] ("jdatadst.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9788] ("jdcoefct.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9795] ("jdmaster.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9802] moved to [9767 403] +The entry [9767 9802] ("jfdctflt.obj") in directory [9443 388] updated to point to [9767 403] +rebuild_semantic_pass: The entry [9767 9793] ("jdmainct.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9787] ("jdatasrc.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9794] ("jdmarker.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9789] ("jdcolor.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9803] moved to [9767 404] +The entry [9767 9803] ("jfdctfst.obj") in directory [9443 388] updated to point to [9767 404] +rewrite_file: 2 items of file [9767 9800] moved to [9767 405] +The entry [9767 9800] ("jdtrans.obj") in directory [9443 388] updated to point to [9767 405] +rewrite_file: 2 items of file [9767 9801] moved to [9767 406] +The entry [9767 9801] ("jerror.obj") in directory [9443 388] updated to point to [9767 406] +rewrite_file: 2 items of file [9767 9815] moved to [9767 407] +The entry [9767 9815] ("jutils.obj") in directory [9443 388] updated to point to [9767 407] +rebuild_semantic_pass: The entry [9767 9770] ("jccoefct.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9805] moved to [9767 408] +The entry [9767 9805] ("jidctflt.obj") in directory [9443 388] updated to point to [9767 408] +rebuild_semantic_pass: The entry [9767 9773] ("jchuff.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9777] ("jcmaster.obj") in directory [9443 388] points to nowhere - is removed +rebuild_semantic_pass: The entry [9767 9775] ("jcmainct.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9810] moved to [9767 409] +The entry [9767 9810] ("jmemmgr.obj") in directory [9443 388] updated to point to [9767 409] +rebuild_semantic_pass: The entry [9767 9780] ("jcphuff.obj") in directory [9443 388] points to nowhere - is removed +rewrite_file: 2 items of file [9767 9806] moved to [9767 410] +The entry [9767 9806] ("jidctfst.obj") in directory [9443 388] updated to point to [9767 410] +vpf-10680: The directory [9443 388] has the wrong block count in the StatData (4) - corrected to (2) +vpf-10650: The directory [9443 388] has the wrong size in the StatData (1632) - corrected to (736) +relocate_dir: Moving [9818 9819 0x0 SD (0)] to [9818 411 0x0 SD (0)] +relocate_dir: Moving [9818 9819 0x1 DIR (3)] to [9818 411 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9818 411] pointes to [7405 9818], instead of [2 4] - corrected +relocate_dir: Moving [9819 9829 0x0 SD (0)] to [9819 412 0x0 SD (0)] +relocate_dir: Moving [9819 9829 0x1 DIR (3)] to [9819 412 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9819 412] pointes to [9818 9819], instead of [9818 411] - corrected +rewrite_file: 2 items of file [9829 9830] moved to [9829 413] +The entry [9829 9830] ("iphlpapi.dll") in directory [9819 412] updated to point to [9829 413] +rewrite_file: 2 items of file [9829 9831] moved to [9829 414] +The entry [9829 9831] ("vssver.scc") in directory [9819 412] updated to point to [9829 414] +The entry [9819 412] ("dll") in directory [9818 411] updated to point to [9819 412] +relocate_dir: Moving [9819 9820 0x0 SD (0)] to [9819 415 0x0 SD (0)] +relocate_dir: Moving [9819 9820 0x1 DIR (3)] to [9819 415 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9819 415] pointes to [9818 9819], instead of [9818 411] - corrected +rewrite_file: 2 items of file [9820 9821] moved to [9820 416] +vpf-10680: The file [9820 416] has the wrong block count in the StatData (80) - corrected to (0) +The entry [9820 9821] ("IPHlpApi.Lib") in directory [9819 415] updated to point to [9820 416] +rewrite_file: 2 items of file [9820 9822] moved to [9820 417] +The entry [9820 9822] ("vssver.scc") in directory [9819 415] updated to point to [9820 417] +The entry [9819 415] ("lib") in directory [9818 411] updated to point to [9819 415] +relocate_dir: Moving [9819 9823 0x0 SD (0)] to [9819 418 0x0 SD (0)] +relocate_dir: Moving [9819 9823 0x1 DIR (3)] to [9819 418 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9819 418] pointes to [9818 9819], instead of [9818 411] - corrected +rewrite_file: 2 items of file [9823 9824] moved to [9823 419] +vpf-10680: The file [9823 419] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9823 9824] ("IcmpAPI.h") in directory [9819 418] updated to point to [9823 419] +rewrite_file: 2 items of file [9823 9826] moved to [9823 420] +vpf-10680: The file [9823 420] has the wrong block count in the StatData (40) - corrected to (0) +The entry [9823 9826] ("IPHlpApi.h") in directory [9819 418] updated to point to [9823 420] +rewrite_file: 2 items of file [9823 9827] moved to [9823 421] +vpf-10680: The file [9823 421] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9823 9827] ("IPTypes.h") in directory [9819 418] updated to point to [9823 421] +rewrite_file: 2 items of file [9823 9825] moved to [9823 422] +vpf-10680: The file [9823 422] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9823 9825] ("IPExport.h") in directory [9819 418] updated to point to [9823 422] +rewrite_file: 2 items of file [9823 9828] moved to [9823 423] +The entry [9823 9828] ("vssver.scc") in directory [9819 418] updated to point to [9823 423] +The entry [9819 418] ("include") in directory [9818 411] updated to point to [9819 418] +relocate_dir: Moving [9832 9833 0x0 SD (0)] to [9832 424 0x0 SD (0)] +relocate_dir: Moving [9832 9833 0x1 DIR (3)] to [9832 424 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9832 424] pointes to [7405 9832], instead of [2 4] - corrected +relocate_dir: Moving [9832 9834 0x0 SD (0)] to [9832 425 0x0 SD (0)] +relocate_dir: Moving [9832 9834 0x1 DIR (3)] to [9832 425 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9832 425] pointes to [9832 9833], instead of [9832 424] - corrected +rewrite_file: 2 items of file [9832 9835] moved to [9832 426] +vpf-10680: The file [9832 426] has the wrong block count in the StatData (1712) - corrected to (0) +The entry [9832 9835] ("libhasp.lib") in directory [9832 425] updated to point to [9832 426] +rewrite_file: 2 items of file [9832 9836] moved to [9832 427] +The entry [9832 9836] ("vssver.scc") in directory [9832 425] updated to point to [9832 427] +The entry [9832 425] ("lib") in directory [9832 424] updated to point to [9832 425] +relocate_dir: Moving [9832 9837 0x0 SD (0)] to [9832 428 0x0 SD (0)] +relocate_dir: Moving [9832 9837 0x1 DIR (3)] to [9832 428 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9832 428] pointes to [7405 9832], instead of [2 4] - corrected +relocate_dir: Moving [9832 9838 0x0 SD (0)] to [9832 429 0x0 SD (0)] +relocate_dir: Moving [9832 9838 0x1 DIR (3)] to [9832 429 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9832 429] pointes to [9832 9837], instead of [9832 428] - corrected +rewrite_file: 2 items of file [9832 9839] moved to [9832 430] +vpf-10680: The file [9832 430] has the wrong block count in the StatData (1176) - corrected to (0) +The entry [9832 9839] ("libHASP.a") in directory [9832 429] updated to point to [9832 430] +rewrite_file: 2 items of file [9832 9840] moved to [9832 431] +The entry [9832 9840] ("vssver.scc") in directory [9832 429] updated to point to [9832 431] +The entry [9832 429] ("lib") in directory [9832 428] updated to point to [9832 429] +relocate_dir: Moving [9841 9981 0x0 SD (0)] to [9841 432 0x0 SD (0)] +relocate_dir: Moving [9841 9981 0x1 DIR (3)] to [9841 432 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 432] pointes to [7652 9841], instead of [2 4] - corrected +rewrite_file: 2 items of file [9841 9990] moved to [9841 433] +vpf-10680: The file [9841 433] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9990] ("jcmarker.obj") in directory [9841 432] updated to point to [9841 433] +rewrite_file: 2 items of file [9841 10020] moved to [9841 434] +vpf-10680: The file [9841 434] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10020] ("jdsample.obj") in directory [9841 432] updated to point to [9841 434] +rewrite_file: 2 items of file [9841 10032] moved to [9841 435] +vpf-10680: The file [9841 435] has the wrong block count in the StatData (456) - corrected to (0) +The entry [9841 10032] ("jpeglib.lib") in directory [9841 432] updated to point to [9841 435] +rewrite_file: 2 items of file [9841 10033] moved to [9841 436] +vpf-10680: The file [9841 436] has the wrong block count in the StatData (528) - corrected to (0) +The entry [9841 10033] ("jpeglib.pch") in directory [9841 432] updated to point to [9841 436] +rewrite_file: 2 items of file [9841 10025] moved to [9841 437] +The entry [9841 10025] ("jfdctint.obj") in directory [9841 432] updated to point to [9841 437] +rewrite_file: 2 items of file [9841 10006] moved to [9841 438] +The entry [9841 10006] ("jddctmgr.obj") in directory [9841 432] updated to point to [9841 438] +rewrite_file: 2 items of file [9841 10017] moved to [9841 439] +The entry [9841 10017] ("jdmerge.obj") in directory [9841 432] updated to point to [9841 439] +rewrite_file: 2 items of file [9841 10008] moved to [9841 440] +The entry [9841 10008] ("jdinput.obj") in directory [9841 432] updated to point to [9841 440] +rewrite_file: 2 items of file [9841 10018] moved to [9841 441] +vpf-10680: The file [9841 441] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10018] ("jdphuff.obj") in directory [9841 432] updated to point to [9841 441] +rewrite_file: 2 items of file [9841 9998] moved to [9841 442] +vpf-10680: The file [9841 442] has the wrong block count in the StatData (8) - corrected to (0) +The entry [9841 9998] ("jdapimin.obj") in directory [9841 432] updated to point to [9841 442] +rewrite_file: 2 items of file [9841 9999] moved to [9841 443] +The entry [9841 9999] ("jdapistd.obj") in directory [9841 432] updated to point to [9841 443] +rewrite_file: 2 items of file [9841 10034] moved to [9841 444] +vpf-10680: The file [9841 444] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10034] ("jquant1.obj") in directory [9841 432] updated to point to [9841 444] +rewrite_file: 2 items of file [9841 10035] moved to [9841 445] +vpf-10680: The file [9841 445] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10035] ("jquant2.obj") in directory [9841 432] updated to point to [9841 445] +rewrite_file: 2 items of file [9841 9996] moved to [9841 446] +vpf-10680: The file [9841 446] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9996] ("jcsample.obj") in directory [9841 432] updated to point to [9841 446] +rewrite_file: 2 items of file [9841 9993] moved to [9841 447] +vpf-10680: The file [9841 447] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9993] ("jcparam.obj") in directory [9841 432] updated to point to [9841 447] +rewrite_file: 2 items of file [9841 10028] moved to [9841 448] +The entry [9841 10028] ("jidctint.obj") in directory [9841 432] updated to point to [9841 448] +rewrite_file: 2 items of file [9841 10037] moved to [9841 449] +vpf-10680: The file [9841 449] has the wrong block count in the StatData (200) - corrected to (0) +The entry [9841 10037] ("vc60.idb") in directory [9841 432] updated to point to [9841 449] +rewrite_file: 2 items of file [9841 10019] moved to [9841 450] +The entry [9841 10019] ("jdpostct.obj") in directory [9841 432] updated to point to [9841 450] +rewrite_file: 2 items of file [9841 9986] moved to [9841 451] +The entry [9841 9986] ("jcdctmgr.obj") in directory [9841 432] updated to point to [9841 451] +rewrite_file: 2 items of file [9841 9995] moved to [9841 452] +The entry [9841 9995] ("jcprepct.obj") in directory [9841 432] updated to point to [9841 452] +rewrite_file: 2 items of file [9841 10007] moved to [9841 453] +vpf-10680: The file [9841 453] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10007] ("jdhuff.obj") in directory [9841 432] updated to point to [9841 453] +rewrite_file: 2 items of file [9841 9985] moved to [9841 454] +vpf-10680: The file [9841 454] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9985] ("jccolor.obj") in directory [9841 432] updated to point to [9841 454] +rewrite_file: 2 items of file [9841 9982] moved to [9841 455] +The entry [9841 9982] ("jcapimin.obj") in directory [9841 432] updated to point to [9841 455] +rewrite_file: 2 items of file [9841 9983] moved to [9841 456] +The entry [9841 9983] ("jcapistd.obj") in directory [9841 432] updated to point to [9841 456] +rewrite_file: 2 items of file [9841 9992] moved to [9841 457] +The entry [9841 9992] ("jcomapi.obj") in directory [9841 432] updated to point to [9841 457] +rewrite_file: 2 items of file [9841 10029] moved to [9841 458] +The entry [9841 10029] ("jidctred.obj") in directory [9841 432] updated to point to [9841 458] +rewrite_file: 2 items of file [9841 9988] moved to [9841 459] +The entry [9841 9988] ("jcinit.obj") in directory [9841 432] updated to point to [9841 459] +rewrite_file: 2 items of file [9841 9997] moved to [9841 460] +The entry [9841 9997] ("jctrans.obj") in directory [9841 432] updated to point to [9841 460] +rewrite_file: 2 items of file [9841 10030] moved to [9841 461] +The entry [9841 10030] ("jmemansi.obj") in directory [9841 432] updated to point to [9841 461] +rewrite_file: 2 items of file [9841 10000] moved to [9841 462] +The entry [9841 10000] ("jdatadst.obj") in directory [9841 432] updated to point to [9841 462] +rewrite_file: 2 items of file [9841 10002] moved to [9841 463] +vpf-10680: The file [9841 463] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10002] ("jdcoefct.obj") in directory [9841 432] updated to point to [9841 463] +rewrite_file: 2 items of file [9841 10016] moved to [9841 464] +vpf-10680: The file [9841 464] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10016] ("jdmaster.obj") in directory [9841 432] updated to point to [9841 464] +rewrite_file: 2 items of file [9841 10023] moved to [9841 465] +The entry [9841 10023] ("jfdctflt.obj") in directory [9841 432] updated to point to [9841 465] +rewrite_file: 2 items of file [9841 10009] moved to [9841 466] +vpf-10680: The file [9841 466] has the wrong block count in the StatData (8) - corrected to (0) +The entry [9841 10009] ("jdmainct.obj") in directory [9841 432] updated to point to [9841 466] +rewrite_file: 2 items of file [9841 10001] moved to [9841 467] +The entry [9841 10001] ("jdatasrc.obj") in directory [9841 432] updated to point to [9841 467] +rewrite_file: 2 items of file [9841 10013] moved to [9841 468] +vpf-10680: The file [9841 468] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10013] ("jdmarker.obj") in directory [9841 432] updated to point to [9841 468] +rewrite_file: 2 items of file [9841 10003] moved to [9841 469] +The entry [9841 10003] ("jdcolor.obj") in directory [9841 432] updated to point to [9841 469] +rewrite_file: 2 items of file [9841 10024] moved to [9841 470] +The entry [9841 10024] ("jfdctfst.obj") in directory [9841 432] updated to point to [9841 470] +rewrite_file: 2 items of file [9841 10021] moved to [9841 471] +The entry [9841 10021] ("jdtrans.obj") in directory [9841 432] updated to point to [9841 471] +rewrite_file: 2 items of file [9841 10022] moved to [9841 472] +vpf-10680: The file [9841 472] has the wrong block count in the StatData (56) - corrected to (0) +The entry [9841 10022] ("jerror.obj") in directory [9841 432] updated to point to [9841 472] +rewrite_file: 2 items of file [9841 10036] moved to [9841 473] +The entry [9841 10036] ("jutils.obj") in directory [9841 432] updated to point to [9841 473] +rewrite_file: 2 items of file [9841 9984] moved to [9841 474] +The entry [9841 9984] ("jccoefct.obj") in directory [9841 432] updated to point to [9841 474] +rewrite_file: 2 items of file [9841 10026] moved to [9841 475] +The entry [9841 10026] ("jidctflt.obj") in directory [9841 432] updated to point to [9841 475] +rewrite_file: 2 items of file [9841 9987] moved to [9841 476] +vpf-10680: The file [9841 476] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9987] ("jchuff.obj") in directory [9841 432] updated to point to [9841 476] +rewrite_file: 2 items of file [9841 9991] moved to [9841 477] +vpf-10680: The file [9841 477] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9991] ("jcmaster.obj") in directory [9841 432] updated to point to [9841 477] +rewrite_file: 2 items of file [9841 9989] moved to [9841 478] +The entry [9841 9989] ("jcmainct.obj") in directory [9841 432] updated to point to [9841 478] +rewrite_file: 2 items of file [9841 10031] moved to [9841 479] +vpf-10680: The file [9841 479] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10031] ("jmemmgr.obj") in directory [9841 432] updated to point to [9841 479] +rewrite_file: 2 items of file [9841 9994] moved to [9841 480] +vpf-10680: The file [9841 480] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 9994] ("jcphuff.obj") in directory [9841 432] updated to point to [9841 480] +rewrite_file: 2 items of file [9841 10027] moved to [9841 481] +The entry [9841 10027] ("jidctfst.obj") in directory [9841 432] updated to point to [9841 481] +vpf-10680: The directory [9841 432] has the wrong block count in the StatData (1) - corrected to (4) +vpf-10650: The directory [9841 432] has the wrong size in the StatData (48) - corrected to (1608) +relocate_dir: Moving [9841 10038 0x0 SD (0)] to [9841 482 0x0 SD (0)] +relocate_dir: Moving [9841 10038 0x1 DIR (3)] to [9841 482 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9841 482] pointes to [7652 9841], instead of [2 4] - corrected +rewrite_file: 2 items of file [9841 10047] moved to [9841 483] +vpf-10680: The file [9841 483] has the wrong block count in the StatData (40) - corrected to (0) +The entry [9841 10047] ("jcmarker.obj") in directory [9841 482] updated to point to [9841 483] +rewrite_file: 2 items of file [9841 10070] moved to [9841 484] +vpf-10680: The file [9841 484] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10070] ("jdsample.obj") in directory [9841 482] updated to point to [9841 484] +vpf-10680: The file [9841 10082] has the wrong block count in the StatData (1136) - corrected to (8) +vpf-10680: The file [9841 10083] has the wrong block count in the StatData (528) - corrected to (0) +rewrite_file: 2 items of file [9841 10075] moved to [9841 485] +vpf-10680: The file [9841 485] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10075] ("jfdctint.obj") in directory [9841 482] updated to point to [9841 485] +rewrite_file: 2 items of file [9841 10061] moved to [9841 486] +vpf-10680: The file [9841 486] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10061] ("jddctmgr.obj") in directory [9841 482] updated to point to [9841 486] +rewrite_file: 2 items of file [9841 10067] moved to [9841 487] +vpf-10680: The file [9841 487] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10067] ("jdmerge.obj") in directory [9841 482] updated to point to [9841 487] +rewrite_file: 2 items of file [9841 10063] moved to [9841 488] +vpf-10680: The file [9841 488] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10063] ("jdinput.obj") in directory [9841 482] updated to point to [9841 488] +rewrite_file: 2 items of file [9841 10068] moved to [9841 489] +vpf-10680: The file [9841 489] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10068] ("jdphuff.obj") in directory [9841 482] updated to point to [9841 489] +rewrite_file: 2 items of file [9841 10055] moved to [9841 490] +vpf-10680: The file [9841 490] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10055] ("jdapimin.obj") in directory [9841 482] updated to point to [9841 490] +rewrite_file: 2 items of file [9841 10056] moved to [9841 491] +vpf-10680: The file [9841 491] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10056] ("jdapistd.obj") in directory [9841 482] updated to point to [9841 491] +vpf-10680: The file [9841 10084] has the wrong block count in the StatData (48) - corrected to (0) +rewrite_file: 2 items of file [9841 10085] moved to [9841 492] +vpf-10680: The file [9841 492] has the wrong block count in the StatData (56) - corrected to (0) +The entry [9841 10085] ("jquant2.obj") in directory [9841 482] updated to point to [9841 492] +rewrite_file: 2 items of file [9841 10053] moved to [9841 493] +vpf-10680: The file [9841 493] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10053] ("jcsample.obj") in directory [9841 482] updated to point to [9841 493] +rewrite_file: 2 items of file [9841 10050] moved to [9841 494] +vpf-10680: The file [9841 494] has the wrong block count in the StatData (40) - corrected to (0) +The entry [9841 10050] ("jcparam.obj") in directory [9841 482] updated to point to [9841 494] +rewrite_file: 2 items of file [9841 10078] moved to [9841 495] +vpf-10680: The file [9841 495] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10078] ("jidctint.obj") in directory [9841 482] updated to point to [9841 495] +rewrite_file: 2 items of file [9841 10087] moved to [9841 496] +vpf-10680: The file [9841 496] has the wrong block count in the StatData (184) - corrected to (48) +The entry [9841 10087] ("vc60.idb") in directory [9841 482] updated to point to [9841 496] +rewrite_file: 2 items of file [9841 10088] moved to [9841 497] +The entry [9841 10088] ("vc60.pdb") in directory [9841 482] updated to point to [9841 497] +rewrite_file: 2 items of file [9841 10069] moved to [9841 498] +vpf-10680: The file [9841 498] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10069] ("jdpostct.obj") in directory [9841 482] updated to point to [9841 498] +rewrite_file: 2 items of file [9841 10043] moved to [9841 499] +vpf-10680: The file [9841 499] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10043] ("jcdctmgr.obj") in directory [9841 482] updated to point to [9841 499] +rewrite_file: 2 items of file [9841 10052] moved to [9841 500] +vpf-10680: The file [9841 500] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10052] ("jcprepct.obj") in directory [9841 482] updated to point to [9841 500] +rewrite_file: 2 items of file [9841 10062] moved to [9841 501] +vpf-10680: The file [9841 501] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10062] ("jdhuff.obj") in directory [9841 482] updated to point to [9841 501] +rewrite_file: 2 items of file [9841 10042] moved to [9841 502] +vpf-10680: The file [9841 502] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10042] ("jccolor.obj") in directory [9841 482] updated to point to [9841 502] +rewrite_file: 2 items of file [9841 10039] moved to [9841 503] +vpf-10680: The file [9841 503] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10039] ("jcapimin.obj") in directory [9841 482] updated to point to [9841 503] +rewrite_file: 2 items of file [9841 10040] moved to [9841 504] +vpf-10680: The file [9841 504] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10040] ("jcapistd.obj") in directory [9841 482] updated to point to [9841 504] +rewrite_file: 2 items of file [9841 10049] moved to [9841 505] +vpf-10680: The file [9841 505] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10049] ("jcomapi.obj") in directory [9841 482] updated to point to [9841 505] +rewrite_file: 2 items of file [9841 10079] moved to [9841 506] +vpf-10680: The file [9841 506] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10079] ("jidctred.obj") in directory [9841 482] updated to point to [9841 506] +rewrite_file: 2 items of file [9841 10045] moved to [9841 507] +vpf-10680: The file [9841 507] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10045] ("jcinit.obj") in directory [9841 482] updated to point to [9841 507] +rewrite_file: 2 items of file [9841 10054] moved to [9841 508] +vpf-10680: The file [9841 508] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10054] ("jctrans.obj") in directory [9841 482] updated to point to [9841 508] +vpf-10680: The file [9841 10080] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [9841 10057] moved to [9841 509] +vpf-10680: The file [9841 509] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10057] ("jdatadst.obj") in directory [9841 482] updated to point to [9841 509] +rewrite_file: 2 items of file [9841 10059] moved to [9841 510] +vpf-10680: The file [9841 510] has the wrong block count in the StatData (40) - corrected to (0) +The entry [9841 10059] ("jdcoefct.obj") in directory [9841 482] updated to point to [9841 510] +rewrite_file: 2 items of file [9841 10066] moved to [9841 511] +vpf-10680: The file [9841 511] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10066] ("jdmaster.obj") in directory [9841 482] updated to point to [9841 511] +rewrite_file: 2 items of file [9841 10073] moved to [9841 512] +vpf-10680: The file [9841 512] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10073] ("jfdctflt.obj") in directory [9841 482] updated to point to [9841 512] +rewrite_file: 2 items of file [9841 10064] moved to [9841 513] +vpf-10680: The file [9841 513] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10064] ("jdmainct.obj") in directory [9841 482] updated to point to [9841 513] +rewrite_file: 2 items of file [9841 10058] moved to [9841 514] +vpf-10680: The file [9841 514] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10058] ("jdatasrc.obj") in directory [9841 482] updated to point to [9841 514] +rewrite_file: 2 items of file [9841 10065] moved to [9841 515] +vpf-10680: The file [9841 515] has the wrong block count in the StatData (72) - corrected to (0) +The entry [9841 10065] ("jdmarker.obj") in directory [9841 482] updated to point to [9841 515] +rewrite_file: 2 items of file [9841 10060] moved to [9841 516] +vpf-10680: The file [9841 516] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10060] ("jdcolor.obj") in directory [9841 482] updated to point to [9841 516] +rewrite_file: 2 items of file [9841 10074] moved to [9841 517] +vpf-10680: The file [9841 517] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10074] ("jfdctfst.obj") in directory [9841 482] updated to point to [9841 517] +rewrite_file: 2 items of file [9841 10071] moved to [9841 518] +vpf-10680: The file [9841 518] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10071] ("jdtrans.obj") in directory [9841 482] updated to point to [9841 518] +rewrite_file: 2 items of file [9841 10072] moved to [9841 519] +vpf-10680: The file [9841 519] has the wrong block count in the StatData (72) - corrected to (0) +The entry [9841 10072] ("jerror.obj") in directory [9841 482] updated to point to [9841 519] +rewrite_file: 2 items of file [9841 10086] moved to [9841 520] +vpf-10680: The file [9841 520] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10086] ("jutils.obj") in directory [9841 482] updated to point to [9841 520] +rewrite_file: 2 items of file [9841 10041] moved to [9841 521] +vpf-10680: The file [9841 521] has the wrong block count in the StatData (24) - corrected to (0) +The entry [9841 10041] ("jccoefct.obj") in directory [9841 482] updated to point to [9841 521] +rewrite_file: 2 items of file [9841 10076] moved to [9841 522] +vpf-10680: The file [9841 522] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10076] ("jidctflt.obj") in directory [9841 482] updated to point to [9841 522] +rewrite_file: 2 items of file [9841 10044] moved to [9841 523] +vpf-10680: The file [9841 523] has the wrong block count in the StatData (40) - corrected to (0) +The entry [9841 10044] ("jchuff.obj") in directory [9841 482] updated to point to [9841 523] +rewrite_file: 2 items of file [9841 10048] moved to [9841 524] +vpf-10680: The file [9841 524] has the wrong block count in the StatData (32) - corrected to (0) +The entry [9841 10048] ("jcmaster.obj") in directory [9841 482] updated to point to [9841 524] +rewrite_file: 2 items of file [9841 10046] moved to [9841 525] +vpf-10680: The file [9841 525] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10046] ("jcmainct.obj") in directory [9841 482] updated to point to [9841 525] +vpf-10680: The file [9841 10081] has the wrong block count in the StatData (48) - corrected to (0) +rewrite_file: 2 items of file [9841 10051] moved to [9841 526] +vpf-10680: The file [9841 526] has the wrong block count in the StatData (40) - corrected to (0) +The entry [9841 10051] ("jcphuff.obj") in directory [9841 482] updated to point to [9841 526] +rewrite_file: 2 items of file [9841 10077] moved to [9841 527] +vpf-10680: The file [9841 527] has the wrong block count in the StatData (16) - corrected to (0) +The entry [9841 10077] ("jidctfst.obj") in directory [9841 482] updated to point to [9841 527] +relocate_dir: Moving [9915 9930 0x0 SD (0)] to [9915 528 0x0 SD (0)] +relocate_dir: Moving [9915 9930 0x1 DIR (3)] to [9915 528 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [9915 528] pointes to [7405 9915], instead of [2 4] - corrected +relocate_dir: Moving [9930 9931 0x0 SD (0)] to [9930 529 0x0 SD (0)] +vpf-10650: The directory [9930 529] has the wrong size in the StatData (72) - corrected to (48) +The entry [9930 529] ("include") in directory [9915 528] updated to point to [9930 529] +relocate_dir: Moving [10045 10053 0x0 SD (0)] to [10045 530 0x0 SD (0)] +relocate_dir: Moving [10045 10053 0x1 DIR (3)] to [10045 530 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10045 530] pointes to [2 10045], instead of [2 4] - corrected +rewrite_file: 2 items of file [10045 10054] moved to [10045 531] +vpf-10680: The file [10045 531] has the wrong block count in the StatData (16) - corrected to (0) +The entry [10045 10054] ("encoding.h") in directory [10045 530] updated to point to [10045 531] +rewrite_file: 2 items of file [10045 10055] moved to [10045 532] +The entry [10045 10055] ("xmlregexp.h") in directory [10045 530] updated to point to [10045 532] +rebuild_semantic_pass: The entry [10045 10056] ("xmlmemory.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10057] ("xlink.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10058] ("xmlIO.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10059] ("xpath.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10060] ("SAX.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10061] ("chvalid.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10062] ("uri.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10063] ("SAX2.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10064] ("nanoftp.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10065] ("schemasInternals.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10066] ("threads.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10067] ("parser.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10068] ("c14n.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10069] ("xmlerror.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10070] ("pattern.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10071] ("DOCBparser.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10072] ("dict.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10073] ("xmlautomata.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10074] ("xmlschemastypes.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10075] ("xpointer.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10076] ("hash.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10077] ("nanohttp.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10078] ("relaxng.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10079] ("xpathInternals.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10085] ("xmlversion.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10086] ("list.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10087] ("HTMLtree.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10088] ("parserInternals.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10089] ("entities.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10090] ("HTMLparser.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10091] ("valid.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10092] ("catalog.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10093] ("tree.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10094] ("globals.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10095] ("xmlunicode.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10096] ("xmlexports.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10097] ("xmlsave.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10098] ("xinclude.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10099] ("xmlreader.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10100] ("debugXML.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10101] ("xmlwriter.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10102] ("vssver.scc") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10103] ("xmlstring.h") in directory [10045 530] points to nowhere - is removed +rebuild_semantic_pass: The entry [10045 10104] ("xmlschemas.h") in directory [10045 530] points to nowhere - is removed +vpf-10680: The directory [10045 530] has the wrong block count in the StatData (3) - corrected to (1) +vpf-10650: The directory [10045 530] has the wrong size in the StatData (1440) - corrected to (112) +relocate_dir: Moving [10089 10090 0x0 SD (0)] to [10089 533 0x0 SD (0)] +relocate_dir: Moving [10089 10090 0x1 DIR (3)] to [10089 533 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10089 533] pointes to [7652 10089], instead of [2 4] - corrected +relocate_dir: Moving [10090 10100 0x0 SD (0)] to [10090 534 0x0 SD (0)] +relocate_dir: Moving [10090 10100 0x1 DIR (3)] to [10090 534 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10090 534] pointes to [10089 10090], instead of [10089 533] - corrected +rewrite_file: 2 items of file [10090 10101] moved to [10090 535] +vpf-10680: The file [10090 535] has the wrong block count in the StatData (168) - corrected to (0) +The entry [10090 10101] ("iphlpapi.dll") in directory [10090 534] updated to point to [10090 535] +rewrite_file: 2 items of file [10090 10102] moved to [10090 536] +The entry [10090 10102] ("vssver.scc") in directory [10090 534] updated to point to [10090 536] +The entry [10090 534] ("dll") in directory [10089 533] updated to point to [10090 534] +relocate_dir: Moving [10090 10091 0x0 SD (0)] to [10090 537 0x0 SD (0)] +relocate_dir: Moving [10090 10091 0x1 DIR (3)] to [10090 537 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10090 537] pointes to [10089 10090], instead of [10089 533] - corrected +rewrite_file: 2 items of file [10090 10092] moved to [10090 538] +vpf-10680: The file [10090 538] has the wrong block count in the StatData (80) - corrected to (24) +The entry [10090 10092] ("IPHlpApi.Lib") in directory [10090 537] updated to point to [10090 538] +rewrite_file: 2 items of file [10090 10093] moved to [10090 539] +The entry [10090 10093] ("vssver.scc") in directory [10090 537] updated to point to [10090 539] +The entry [10090 537] ("lib") in directory [10089 533] updated to point to [10090 537] +relocate_dir: Moving [10090 10094 0x0 SD (0)] to [10090 540 0x0 SD (0)] +relocate_dir: Moving [10090 10094 0x1 DIR (3)] to [10090 540 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10090 540] pointes to [10089 10090], instead of [10089 533] - corrected +rewrite_file: 2 items of file [10090 10095] moved to [10090 541] +The entry [10090 10095] ("IcmpAPI.h") in directory [10090 540] updated to point to [10090 541] +rewrite_file: 2 items of file [10090 10097] moved to [10090 542] +vpf-10680: The file [10090 542] has the wrong block count in the StatData (40) - corrected to (0) +The entry [10090 10097] ("IPHlpApi.h") in directory [10090 540] updated to point to [10090 542] +rewrite_file: 2 items of file [10090 10098] moved to [10090 543] +vpf-10680: The file [10090 543] has the wrong block count in the StatData (24) - corrected to (0) +The entry [10090 10098] ("IPTypes.h") in directory [10090 540] updated to point to [10090 543] +rewrite_file: 2 items of file [10090 10096] moved to [10090 544] +vpf-10680: The file [10090 544] has the wrong block count in the StatData (24) - corrected to (0) +The entry [10090 10096] ("IPExport.h") in directory [10090 540] updated to point to [10090 544] +rewrite_file: 2 items of file [10090 10099] moved to [10090 545] +The entry [10090 10099] ("vssver.scc") in directory [10090 540] updated to point to [10090 545] +The entry [10090 540] ("include") in directory [10089 533] updated to point to [10090 540] +relocate_dir: Moving [10103 10104 0x0 SD (0)] to [10103 546 0x0 SD (0)] +relocate_dir: Moving [10103 10104 0x1 DIR (3)] to [10103 546 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10103 546] pointes to [7652 10103], instead of [2 4] - corrected +relocate_dir: Moving [10104 10106 0x0 SD (0)] to [10104 547 0x0 SD (0)] +relocate_dir: Moving [10104 10106 0x1 DIR (3)] to [10104 547 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10104 547] pointes to [10103 10104], instead of [10103 546] - corrected +rewrite_file: 1 items of file [10104 10107] moved to [10104 548] +vpf-10680: The file [10104 548] has the wrong block count in the StatData (1712) - corrected to (0) +The entry [10104 10107] ("libhasp.lib") in directory [10104 547] updated to point to [10104 548] +rebuild_semantic_pass: The entry [10104 10108] ("vssver.scc") in directory [10104 547] points to nowhere - is removed +vpf-10650: The directory [10104 547] has the wrong size in the StatData (112) - corrected to (80) +The entry [10104 547] ("lib") in directory [10103 546] updated to point to [10104 547] +relocate_dir: Moving [10103 10109 0x0 SD (0)] to [10103 549 0x0 SD (0)] +relocate_dir: Moving [10103 10109 0x1 DIR (3)] to [10103 549 0x1 DIR (3)] +get_next_directory_item: The entry ".." of the directory [10103 549] pointes to [7652 10103], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [10109 10110] ("lib") in directory [10103 549] points to nowhere - is removed +vpf-10650: The directory [10103 549] has the wrong size in the StatData (72) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [10694 10695] pointes to [5270 10694], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [10694 10698] ("fault.c") in directory [10694 10695] points to nowhere - is removed +rebuild_semantic_pass: The entry [10694 10699] ("init.c") in directory [10694 10695] points to nowhere - is removed +rebuild_semantic_pass: The entry [10694 10700] ("kmap.c") in directory [10694 10695] points to nowhere - is removed +vpf-10650: The directory [10694 10695] has the wrong size in the StatData (176) - corrected to (104) +get_next_directory_item: The entry ".." of the directory [11292 11293] pointes to [11158 11292], instead of [2 4] - corrected +vpf-10680: The file [11292 11295] has the wrong block count in the StatData (16) - corrected to (0) +get_next_directory_item: The entry ".." of the directory [11292 11296] pointes to [11158 11292], instead of [2 4] - corrected +vpf-10680: The file [11292 11297] has the wrong block count in the StatData (24) - corrected to (0) +get_next_directory_item: The entry ".." of the directory [11292 11298] pointes to [11158 11292], instead of [2 4] - corrected +vpf-10680: The file [11292 11299] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [11292 11301] has the wrong block count in the StatData (40) - corrected to (0) +rebuild_semantic_pass: The entry [11292 11303] ("spu.c") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11304] ("interrupt.c") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11305] ("setup.c") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11306] ("exports.c") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11307] ("platform.h") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11308] ("hvcall.S") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11309] ("Kconfig") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11310] ("htab.c") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11311] ("time.c") in directory [11292 11298] points to nowhere - is removed +rebuild_semantic_pass: The entry [11292 11312] ("os-area.c") in directory [11292 11298] points to nowhere - is removed +vpf-10650: The directory [11292 11298] has the wrong size in the StatData (424) - corrected to (152) +get_next_directory_item: The entry ".." of the directory [13592 13594] pointes to [11808 13592], instead of [2 4] - corrected +rebuild_semantic_pass: The entry [13592 13595] ("Makefile") in directory [13592 13594] points to nowhere - is removed +rebuild_semantic_pass: The entry [13592 13596] (".snd-usb-usx2y.o.cmd") in directory [13592 13594] points to nowhere - is removed +rebuild_semantic_pass: The entry [13592 13597] (".snd-usb-usx2y.mod.o.cmd") in directory [13592 13594] points to nowhere - is removed +rebuild_semantic_pass: The entry [13592 13598] ("snd-usb-usx2y.ko") in directory [13592 13594] points to nowhere - is removed +vpf-10680: The directory [13592 13594] has the wrong block count in the StatData (2) - corrected to (1) +vpf-10650: The directory [13592 13594] has the wrong size in the StatData (896) - corrected to (48) +get_next_directory_item: The entry ".." of the directory [22745 22767] pointes to [14509 22745], instead of [2 4] - corrected +vpf-10680: The file [22745 22769] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [22745 22770] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22745 22771] has the wrong block count in the StatData (96) - corrected to (0) +vpf-10680: The file [22745 22772] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22745 22773] has the wrong block count in the StatData (304) - corrected to (0) +vpf-10680: The file [22745 22774] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22745 22775] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [22745 22776] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22745 22777] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [22745 22778] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22745 22780] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22745 22781] has the wrong block count in the StatData (112) - corrected to (0) +vpf-10680: The file [22745 22782] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22745 22783] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22745 22785] has the wrong block count in the StatData (200) - corrected to (0) +vpf-10680: The file [22745 22786] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22745 22789] has the wrong block count in the StatData (368) - corrected to (0) +vpf-10680: The file [22745 22790] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [22745 22791] has the wrong block count in the StatData (88) - corrected to (0) +vpf-10680: The file [22745 22792] has the wrong block count in the StatData (168) - corrected to (0) +vpf-10680: The file [22745 22793] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22745 22794] has the wrong block count in the StatData (96) - corrected to (0) +vpf-10680: The file [22745 22795] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22745 22796] has the wrong block count in the StatData (152) - corrected to (0) +vpf-10680: The file [22745 22797] has the wrong block count in the StatData (64) - corrected to (0) +rewrite_file: 2 items of file [2 10789] moved to [2 550] +vpf-10680: The file [2 550] has the wrong block count in the StatData (1272) - corrected to (0) +vpf-10680: The file [25 1856] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [25 1860] has the wrong block count in the StatData (8) - corrected to (0) +rewrite_file: 2 items of file [2130 3347] moved to [2130 551] +rewrite_file: 2 items of file [2130 3348] moved to [2130 552] +vpf-10680: The file [2130 552] has the wrong block count in the StatData (16) - corrected to (8) +rewrite_file: 2 items of file [2130 3349] moved to [2130 553] +rewrite_file: 2 items of file [2204 3106] moved to [2204 554] +rewrite_file: 2 items of file [2204 3107] moved to [2204 555] +rewrite_file: 2 items of file [2204 3108] moved to [2204 556] +rewrite_file: 2 items of file [2204 3109] moved to [2204 557] +vpf-10680: The file [2204 3519] has the wrong block count in the StatData (6496) - corrected to (872) +vpf-10680: The file [2205 3079] has the wrong block count in the StatData (184) - corrected to (0) +vpf-10680: The file [3165 3330] has the wrong block count in the StatData (480) - corrected to (0) +vpf-10680: The file [3165 3333] has the wrong block count in the StatData (152) - corrected to (0) +rewrite_file: 2 items of file [3165 3342] moved to [3165 558] +vpf-10680: The file [3165 558] has the wrong block count in the StatData (184) - corrected to (0) +vpf-10680: The file [3165 3391] has the wrong block count in the StatData (296) - corrected to (0) +rewrite_file: 2 items of file [3165 3396] moved to [3165 559] +vpf-10680: The file [3165 559] has the wrong block count in the StatData (200) - corrected to (0) +vpf-10680: The file [3165 3402] has the wrong block count in the StatData (208) - corrected to (0) +vpf-10680: The file [3165 3412] has the wrong block count in the StatData (224) - corrected to (0) +vpf-10680: The file [3165 3426] has the wrong block count in the StatData (480) - corrected to (0) +vpf-10680: The file [3165 3446] has the wrong block count in the StatData (584) - corrected to (0) +vpf-10680: The file [3166 3186] has the wrong block count in the StatData (48) - corrected to (40) +rewrite_file: 2 items of file [3166 3336] moved to [3166 560] +rewrite_file: 2 items of file [3166 3337] moved to [3166 561] +rewrite_file: 2 items of file [3166 3344] moved to [3166 562] +rewrite_file: 2 items of file [3166 3393] moved to [3166 563] +rewrite_file: 2 items of file [3166 3394] moved to [3166 564] +rewrite_file: 2 items of file [3166 3395] moved to [3166 565] +rewrite_file: 2 items of file [3166 3397] moved to [3166 566] +rewrite_file: 2 items of file [3295 10811] moved to [3295 567] +vpf-10680: The file [3295 567] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [4355 4573] has the wrong block count in the StatData (6128) - corrected to (0) +rewrite_file: 2 items of file [5470 5996] moved to [5470 568] +rewrite_file: 2 items of file [5470 5997] moved to [5470 569] +rewrite_file: 1 items of file [5470 5998] moved to [5470 570] +vpf-10680: The file [5470 570] has the wrong block count in the StatData (6128) - corrected to (0) +rewrite_file: 2 items of file [5470 6000] moved to [5470 571] +vpf-10680: The file [5470 571] has the wrong block count in the StatData (6336) - corrected to (4520) +rewrite_file: 1 items of file [5470 6001] moved to [5470 572] +vpf-10680: The file [5470 572] has the wrong block count in the StatData (5824) - corrected to (0) +rewrite_file: 2 items of file [5470 6044] moved to [5470 573] +rewrite_file: 2 items of file [5470 6045] moved to [5470 574] +rewrite_file: 2 items of file [5470 6046] moved to [5470 575] +rewrite_file: 3 items of file [5470 6047] moved to [5470 576] +rewrite_file: 3 items of file [5470 6061] moved to [5470 577] +rewrite_file: 1 items of file [5470 6062] moved to [5470 578] +vpf-10680: The file [5470 578] has the wrong block count in the StatData (6248) - corrected to (0) +rewrite_file: 3 items of file [5470 6064] moved to [5470 579] +vpf-10680: The file [5470 579] has the wrong block count in the StatData (6080) - corrected to (5896) +rewrite_file: 1 items of file [5470 6065] moved to [5470 580] +vpf-10680: The file [5470 580] has the wrong block count in the StatData (6800) - corrected to (0) +rewrite_file: 2 items of file [5470 6070] moved to [5470 581] +rewrite_file: 2 items of file [5470 6072] moved to [5470 582] +rewrite_file: 2 items of file [5470 6073] moved to [5470 583] +rewrite_file: 3 items of file [5470 6074] moved to [5470 584] +rewrite_file: 3 items of file [5470 6075] moved to [5470 585] +rewrite_file: 3 items of file [5470 6076] moved to [5470 586] +rewrite_file: 3 items of file [5470 6077] moved to [5470 587] +rewrite_file: 2 items of file [5470 6078] moved to [5470 588] +rewrite_file: 3 items of file [5470 6079] moved to [5470 589] +rewrite_file: 3 items of file [5470 6080] moved to [5470 590] +rewrite_file: 3 items of file [5470 6081] moved to [5470 591] +rewrite_file: 3 items of file [5470 6083] moved to [5470 592] +rewrite_file: 2 items of file [5470 6084] moved to [5470 593] +rewrite_file: 3 items of file [5470 6086] moved to [5470 594] +rewrite_file: 3 items of file [5470 6087] moved to [5470 595] +rewrite_file: 3 items of file [5470 6102] moved to [5470 596] +rewrite_file: 3 items of file [5470 6103] moved to [5470 597] +rewrite_file: 2 items of file [5470 6104] moved to [5470 598] +rewrite_file: 3 items of file [5470 6105] moved to [5470 599] +rewrite_file: 3 items of file [5470 6106] moved to [5470 600] +rewrite_file: 3 items of file [5470 6107] moved to [5470 601] +rewrite_file: 3 items of file [5470 6108] moved to [5470 602] +rewrite_file: 3 items of file [5470 6109] moved to [5470 603] +rewrite_file: 2 items of file [5470 6110] moved to [5470 604] +rewrite_file: 2 items of file [5470 6113] moved to [5470 605] +rewrite_file: 2 items of file [5470 6114] moved to [5470 606] +vpf-10680: The file [5470 606] has the wrong block count in the StatData (7936) - corrected to (5856) +rewrite_file: 3 items of file [5860 5915] moved to [5860 607] +rewrite_file: 2 items of file [5860 5916] moved to [5860 608] +rewrite_file: 2 items of file [5860 5917] moved to [5860 609] +rewrite_file: 2 items of file [5860 5919] moved to [5860 610] +rewrite_file: 2 items of file [5860 5920] moved to [5860 611] +rewrite_file: 3 items of file [5860 5921] moved to [5860 612] +rewrite_file: 2 items of file [5860 5922] moved to [5860 613] +rewrite_file: 2 items of file [5860 5923] moved to [5860 614] +rewrite_file: 2 items of file [5860 5925] moved to [5860 615] +rewrite_file: 2 items of file [5860 5926] moved to [5860 616] +rewrite_file: 2 items of file [5860 5930] moved to [5860 617] +rewrite_file: 3 items of file [5860 5931] moved to [5860 618] +rewrite_file: 2 items of file [5860 5933] moved to [5860 619] +rewrite_file: 2 items of file [5860 5934] moved to [5860 620] +rewrite_file: 2 items of file [5860 5945] moved to [5860 621] +rewrite_file: 2 items of file [5860 5946] moved to [5860 622] +rewrite_file: 3 items of file [5860 5947] moved to [5860 623] +rewrite_file: 2 items of file [5860 5948] moved to [5860 624] +rewrite_file: 2 items of file [5860 5949] moved to [5860 625] +rewrite_file: 3 items of file [5860 5950] moved to [5860 626] +rewrite_file: 2 items of file [5860 5952] moved to [5860 627] +rewrite_file: 2 items of file [5860 5953] moved to [5860 628] +rewrite_file: 2 items of file [5860 5954] moved to [5860 629] +rewrite_file: 2 items of file [5860 5955] moved to [5860 631] +rewrite_file: 2 items of file [5860 5956] moved to [5860 632] +rewrite_file: 2 items of file [5860 5958] moved to [5860 633] +rewrite_file: 3 items of file [5860 5959] moved to [5860 634] +rewrite_file: 2 items of file [5860 5960] moved to [5860 635] +rewrite_file: 2 items of file [5860 5961] moved to [5860 636] +rewrite_file: 2 items of file [5860 5962] moved to [5860 637] +rewrite_file: 2 items of file [5860 5963] moved to [5860 638] +rewrite_file: 2 items of file [5860 5964] moved to [5860 639] +rewrite_file: 2 items of file [5860 5966] moved to [5860 640] +rewrite_file: 3 items of file [5860 5967] moved to [5860 641] +rewrite_file: 2 items of file [5860 5968] moved to [5860 642] +rewrite_file: 2 items of file [5860 5969] moved to [5860 643] +rewrite_file: 2 items of file [5860 5970] moved to [5860 644] +rewrite_file: 3 items of file [5860 5971] moved to [5860 645] +rewrite_file: 2 items of file [5860 5972] moved to [5860 646] +rewrite_file: 2 items of file [5860 5973] moved to [5860 647] +rewrite_file: 3 items of file [5860 5974] moved to [5860 648] +rewrite_file: 2 items of file [5860 5975] moved to [5860 649] +rewrite_file: 2 items of file [5860 5976] moved to [5860 650] +vpf-10680: The file [5860 650] has the wrong block count in the StatData (2056) - corrected to (80) +rewrite_file: 2 items of file [5860 5977] moved to [5860 651] +vpf-10680: The file [5860 651] has the wrong block count in the StatData (2056) - corrected to (8) +rewrite_file: 2 items of file [5860 5978] moved to [5860 652] +vpf-10680: The file [5860 652] has the wrong block count in the StatData (2056) - corrected to (480) +rewrite_file: 2 items of file [5860 5979] moved to [5860 653] +rewrite_file: 2 items of file [5860 5980] moved to [5860 654] +rewrite_file: 3 items of file [5860 5981] moved to [5860 655] +rewrite_file: 2 items of file [5860 5982] moved to [5860 656] +rewrite_file: 2 items of file [5860 5983] moved to [5860 657] +rewrite_file: 2 items of file [5860 5984] moved to [5860 658] +rewrite_file: 3 items of file [5860 5985] moved to [5860 659] +rewrite_file: 2 items of file [5860 5986] moved to [5860 660] +rewrite_file: 2 items of file [5860 5987] moved to [5860 661] +rewrite_file: 3 items of file [5860 5988] moved to [5860 662] +rewrite_file: 2 items of file [5860 5989] moved to [5860 663] +rewrite_file: 2 items of file [5860 5990] moved to [5860 664] +rewrite_file: 2 items of file [5860 5991] moved to [5860 665] +rewrite_file: 2 items of file [5860 5992] moved to [5860 666] +rewrite_file: 2 items of file [5860 5993] moved to [5860 667] +rewrite_file: 2 items of file [5860 5994] moved to [5860 668] +rewrite_file: 3 items of file [5860 5995] moved to [5860 669] +rewrite_file: 2 items of file [5860 5996] moved to [5860 670] +rewrite_file: 2 items of file [5860 5997] moved to [5860 671] +rewrite_file: 2 items of file [5860 5998] moved to [5860 672] +rewrite_file: 3 items of file [5860 5999] moved to [5860 673] +rewrite_file: 2 items of file [5860 6000] moved to [5860 674] +rewrite_file: 2 items of file [5860 6001] moved to [5860 675] +rewrite_file: 3 items of file [5860 6002] moved to [5860 676] +rewrite_file: 2 items of file [5860 6003] moved to [5860 677] +rewrite_file: 2 items of file [5860 6004] moved to [5860 678] +rewrite_file: 2 items of file [5860 6005] moved to [5860 679] +rewrite_file: 2 items of file [5860 6006] moved to [5860 680] +rewrite_file: 2 items of file [5860 6007] moved to [5860 681] +rewrite_file: 2 items of file [5860 6008] moved to [5860 682] +rewrite_file: 3 items of file [5860 6009] moved to [5860 683] +rewrite_file: 2 items of file [5860 6010] moved to [5860 684] +rewrite_file: 12 items of file [5860 6011] moved to [5860 685] +vpf-10680: The file [5860 685] has the wrong block count in the StatData (79280) - corrected to (79192) +rewrite_file: 2 items of file [5860 6012] moved to [5860 686] +vpf-10680: The file [5860 686] has the wrong block count in the StatData (6160) - corrected to (4200) +rewrite_file: 2 items of file [5860 6013] moved to [5860 687] +vpf-10680: The file [5860 687] has the wrong block count in the StatData (6168) - corrected to (8) +rewrite_file: 1 items of file [5860 6015] moved to [5860 688] +vpf-10680: The file [5860 688] has the wrong block count in the StatData (5816) - corrected to (0) +rewrite_file: 2 items of file [5860 6023] moved to [5860 689] +rewrite_file: 2 items of file [5860 6024] moved to [5860 690] +rewrite_file: 2 items of file [5860 6025] moved to [5860 691] +rewrite_file: 2 items of file [5860 6026] moved to [5860 692] +rewrite_file: 2 items of file [5860 6027] moved to [5860 693] +rewrite_file: 2 items of file [5860 6028] moved to [5860 694] +rewrite_file: 2 items of file [5860 6029] moved to [5860 695] +rewrite_file: 2 items of file [5860 6031] moved to [5860 696] +rewrite_file: 2 items of file [5860 6032] moved to [5860 697] +rewrite_file: 2 items of file [5860 6044] moved to [5860 698] +rewrite_file: 2 items of file [5860 6045] moved to [5860 699] +rewrite_file: 2 items of file [5860 6046] moved to [5860 700] +rewrite_file: 2 items of file [5860 6047] moved to [5860 701] +rewrite_file: 2 items of file [5860 6061] moved to [5860 702] +rewrite_file: 3 items of file [5860 6062] moved to [5860 703] +rewrite_file: 3 items of file [5860 6063] moved to [5860 704] +rewrite_file: 2 items of file [5860 6064] moved to [5860 705] +rewrite_file: 2 items of file [5860 6065] moved to [5860 706] +rewrite_file: 3 items of file [5860 6066] moved to [5860 707] +rewrite_file: 3 items of file [5860 6067] moved to [5860 708] +rewrite_file: 3 items of file [5860 6069] moved to [5860 709] +rewrite_file: 2 items of file [5860 6070] moved to [5860 710] +rewrite_file: 3 items of file [5860 6072] moved to [5860 711] +rewrite_file: 3 items of file [5860 6073] moved to [5860 712] +rewrite_file: 3 items of file [5860 6074] moved to [5860 713] +rewrite_file: 2 items of file [5860 6075] moved to [5860 714] +rewrite_file: 2 items of file [5860 6078] moved to [5860 715] +vpf-10680: The file [5860 715] has the wrong block count in the StatData (5744) - corrected to (3688) +rewrite_file: 1 items of file [5860 6079] moved to [5860 716] +vpf-10680: The file [5860 716] has the wrong block count in the StatData (5936) - corrected to (0) +rewrite_file: 3 items of file [5860 6087] moved to [5860 717] +rewrite_file: 3 items of file [5860 6102] moved to [5860 718] +rewrite_file: 3 items of file [5860 6103] moved to [5860 719] +rewrite_file: 3 items of file [5860 6104] moved to [5860 720] +rewrite_file: 2 items of file [5860 6105] moved to [5860 721] +rewrite_file: 2 items of file [5860 6106] moved to [5860 722] +rewrite_file: 3 items of file [5860 6108] moved to [5860 723] +rewrite_file: 3 items of file [5860 6109] moved to [5860 724] +rewrite_file: 3 items of file [5860 6110] moved to [5860 725] +rewrite_file: 2 items of file [5860 6113] moved to [5860 726] +rewrite_file: 2 items of file [5860 6114] moved to [5860 727] +rewrite_file: 3 items of file [5860 6121] moved to [5860 728] +rewrite_file: 3 items of file [5860 6123] moved to [5860 729] +rewrite_file: 2 items of file [5860 6124] moved to [5860 730] +rewrite_file: 2 items of file [5860 6130] moved to [5860 731] +rewrite_file: 2 items of file [5860 6131] moved to [5860 732] +rewrite_file: 2 items of file [5860 6132] moved to [5860 733] +rewrite_file: 2 items of file [5860 6133] moved to [5860 734] +rewrite_file: 2 items of file [5860 6134] moved to [5860 735] +rewrite_file: 2 items of file [5860 6135] moved to [5860 736] +rewrite_file: 2 items of file [5860 6136] moved to [5860 737] +rewrite_file: 2 items of file [5860 6137] moved to [5860 738] +rewrite_file: 2 items of file [5860 6138] moved to [5860 739] +rewrite_file: 2 items of file [5860 6140] moved to [5860 740] +rewrite_file: 2 items of file [5860 6141] moved to [5860 741] +rewrite_file: 2 items of file [5860 6142] moved to [5860 742] +rewrite_file: 2 items of file [5860 6143] moved to [5860 743] +rewrite_file: 2 items of file [5860 6144] moved to [5860 744] +rewrite_file: 1 items of file [5860 6145] moved to [5860 745] +vpf-10680: The file [5860 745] has the wrong block count in the StatData (6320) - corrected to (0) +rewrite_file: 2 items of file [6182 6184] moved to [6182 746] +rewrite_file: 2 items of file [6182 6185] moved to [6182 747] +rewrite_file: 2 items of file [6182 6186] moved to [6182 748] +rewrite_file: 2 items of file [6182 6187] moved to [6182 749] +rewrite_file: 2 items of file [6182 6188] moved to [6182 750] +rewrite_file: 2 items of file [6182 6189] moved to [6182 751] +rewrite_file: 2 items of file [6182 6190] moved to [6182 752] +rewrite_file: 2 items of file [6182 6191] moved to [6182 753] +rewrite_file: 2 items of file [6182 6192] moved to [6182 754] +rewrite_file: 2 items of file [6182 6193] moved to [6182 755] +rewrite_file: 2 items of file [6182 6194] moved to [6182 756] +rewrite_file: 2 items of file [6182 6195] moved to [6182 757] +rewrite_file: 2 items of file [6182 6196] moved to [6182 758] +rewrite_file: 2 items of file [6182 6197] moved to [6182 759] +rewrite_file: 2 items of file [6182 6198] moved to [6182 760] +rewrite_file: 2 items of file [6182 6199] moved to [6182 761] +rewrite_file: 2 items of file [6182 6200] moved to [6182 762] +rewrite_file: 2 items of file [6182 6201] moved to [6182 763] +rewrite_file: 2 items of file [6182 6202] moved to [6182 764] +rewrite_file: 2 items of file [6182 6203] moved to [6182 765] +rewrite_file: 2 items of file [6182 6204] moved to [6182 766] +rewrite_file: 2 items of file [6182 6205] moved to [6182 767] +rewrite_file: 2 items of file [6182 6206] moved to [6182 768] +rewrite_file: 2 items of file [6182 6207] moved to [6182 769] +rewrite_file: 2 items of file [6182 6208] moved to [6182 770] +rewrite_file: 2 items of file [6182 6209] moved to [6182 771] +rewrite_file: 2 items of file [6182 6210] moved to [6182 772] +rewrite_file: 2 items of file [6182 6211] moved to [6182 773] +rewrite_file: 2 items of file [6182 6212] moved to [6182 774] +rewrite_file: 2 items of file [6182 6214] moved to [6182 775] +rewrite_file: 2 items of file [6182 6215] moved to [6182 776] +rewrite_file: 2 items of file [6182 6216] moved to [6182 777] +rewrite_file: 2 items of file [6182 6217] moved to [6182 778] +rewrite_file: 2 items of file [6182 6219] moved to [6182 779] +rewrite_file: 2 items of file [6182 6220] moved to [6182 780] +rewrite_file: 2 items of file [6182 6221] moved to [6182 781] +rewrite_file: 2 items of file [6182 6222] moved to [6182 782] +rewrite_file: 2 items of file [6182 6223] moved to [6182 783] +rewrite_file: 2 items of file [6182 6224] moved to [6182 784] +rewrite_file: 2 items of file [6182 6225] moved to [6182 785] +rewrite_file: 2 items of file [6182 6226] moved to [6182 786] +rewrite_file: 2 items of file [6182 6227] moved to [6182 787] +rewrite_file: 2 items of file [6182 6228] moved to [6182 788] +rewrite_file: 2 items of file [6182 6229] moved to [6182 789] +rewrite_file: 2 items of file [6182 10788] moved to [6182 790] +rewrite_file: 2 items of file [6241 10775] moved to [6241 791] +rewrite_file: 2 items of file [6241 10776] moved to [6241 792] +vpf-10680: The file [6241 792] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [6241 10841] moved to [6241 793] +vpf-10680: The file [6241 793] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 1 items of file [6245 6246] moved to [6245 794] +vpf-10680: The file [6245 794] has the wrong block count in the StatData (8) - corrected to (0) +rewrite_file: 2 items of file [6472 6507] moved to [6472 795] +rewrite_file: 2 items of file [6472 6508] moved to [6472 796] +vpf-10680: The file [6472 796] has the wrong block count in the StatData (40) - corrected to (0) +rewrite_file: 2 items of file [6472 6509] moved to [6472 797] +vpf-10680: The file [6472 797] has the wrong block count in the StatData (1024) - corrected to (0) +rewrite_file: 2 items of file [6472 6510] moved to [6472 798] +vpf-10680: The file [6472 798] has the wrong block count in the StatData (104) - corrected to (0) +rewrite_file: 2 items of file [6472 6511] moved to [6472 799] +vpf-10680: The file [6472 799] has the wrong block count in the StatData (136) - corrected to (0) +rewrite_file: 2 items of file [6472 10739] moved to [6472 800] +rewrite_file: 2 items of file [6472 10742] moved to [6472 801] +vpf-10680: The file [6472 801] has the wrong block count in the StatData (3832) - corrected to (3768) +rewrite_file: 2 items of file [6472 10782] moved to [6472 802] +vpf-10680: The file [6472 802] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [6472 10783] moved to [6472 803] +rewrite_file: 2 items of file [6472 10784] moved to [6472 804] +rewrite_file: 2 items of file [6472 10785] moved to [6472 805] +rewrite_file: 2 items of file [6472 10787] moved to [6472 806] +vpf-10680: The file [6472 806] has the wrong block count in the StatData (7888) - corrected to (1408) +rewrite_file: 2 items of file [6498 10746] moved to [6498 807] +rewrite_file: 2 items of file [6498 10747] moved to [6498 808] +rewrite_file: 2 items of file [6498 10748] moved to [6498 809] +rewrite_file: 2 items of file [6498 10749] moved to [6498 810] +rewrite_file: 3 items of file [6498 10751] moved to [6498 811] +rewrite_file: 2 items of file [6796 10782] moved to [6796 812] +rewrite_file: 2 items of file [6796 10783] moved to [6796 813] +vpf-10680: The file [6796 813] has the wrong block count in the StatData (168) - corrected to (0) +rewrite_file: 3 items of file [6796 10785] moved to [6796 814] +vpf-10680: The file [6796 814] has the wrong block count in the StatData (13584) - corrected to (0) +rewrite_file: 2 items of file [6849 10374] moved to [6849 815] +rewrite_file: 2 items of file [6849 10375] moved to [6849 816] +rewrite_file: 2 items of file [6849 10378] moved to [6849 817] +rewrite_file: 2 items of file [6849 10379] moved to [6849 818] +rewrite_file: 2 items of file [6849 10380] moved to [6849 819] +rewrite_file: 2 items of file [6849 10381] moved to [6849 820] +rewrite_file: 2 items of file [6849 10382] moved to [6849 821] +rewrite_file: 2 items of file [6849 10383] moved to [6849 822] +rewrite_file: 2 items of file [6849 10384] moved to [6849 823] +rewrite_file: 2 items of file [6849 10385] moved to [6849 824] +rewrite_file: 2 items of file [6849 10387] moved to [6849 825] +rewrite_file: 2 items of file [6849 10388] moved to [6849 826] +rewrite_file: 2 items of file [6849 10395] moved to [6849 827] +rewrite_file: 2 items of file [6849 10396] moved to [6849 828] +rewrite_file: 2 items of file [6849 10399] moved to [6849 829] +rewrite_file: 2 items of file [6849 10400] moved to [6849 830] +rewrite_file: 2 items of file [6849 10401] moved to [6849 831] +rewrite_file: 1 items of file [6849 10406] moved to [6849 832] +vpf-10680: The file [6849 832] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [6864 6898] has the wrong block count in the StatData (104) - corrected to (0) +vpf-10680: The file [6864 6899] has the wrong block count in the StatData (136) - corrected to (0) +rewrite_file: 2 items of file [6864 10804] moved to [6864 833] +vpf-10680: The file [6864 833] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [6864 10805] moved to [6864 834] +vpf-10680: The file [6864 834] has the wrong block count in the StatData (248) - corrected to (0) +rewrite_file: 2 items of file [6864 10806] moved to [6864 835] +vpf-10680: The file [6864 835] has the wrong block count in the StatData (136) - corrected to (0) +rewrite_file: 2 items of file [6864 10807] moved to [6864 836] +vpf-10680: The file [6864 836] has the wrong block count in the StatData (184) - corrected to (0) +rewrite_file: 3 items of file [6864 10809] moved to [6864 837] +vpf-10680: The file [6864 837] has the wrong block count in the StatData (7888) - corrected to (1544) +rewrite_file: 2 items of file [6866 7386] moved to [6866 838] +rewrite_file: 2 items of file [6866 7387] moved to [6866 839] +rewrite_file: 2 items of file [6866 7388] moved to [6866 840] +rewrite_file: 3 items of file [6866 7389] moved to [6866 841] +rewrite_file: 2 items of file [6866 7390] moved to [6866 842] +rewrite_file: 2 items of file [6866 7391] moved to [6866 843] +rewrite_file: 2 items of file [6866 7392] moved to [6866 844] +rewrite_file: 2 items of file [6866 7393] moved to [6866 845] +rewrite_file: 2 items of file [6866 7394] moved to [6866 846] +vpf-10680: The file [6913 11060] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [6913 11089] has the wrong block count in the StatData (248) - corrected to (0) +vpf-10680: The file [6913 11116] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [6913 11117] has the wrong block count in the StatData (184) - corrected to (0) +vpf-10680: The file [6913 11135] has the wrong block count in the StatData (7888) - corrected to (0) +rewrite_file: 2 items of file [7001 10794] moved to [7001 847] +vpf-10680: The file [7001 847] has the wrong block count in the StatData (112) - corrected to (0) +rewrite_file: 2 items of file [7001 10795] moved to [7001 848] +vpf-10680: The file [7001 848] has the wrong block count in the StatData (32) - corrected to (0) +rewrite_file: 2 items of file [7001 10796] moved to [7001 849] +vpf-10680: The file [7001 849] has the wrong block count in the StatData (144) - corrected to (16) +rewrite_file: 2 items of file [7001 10798] moved to [7001 850] +vpf-10680: The file [7001 850] has the wrong block count in the StatData (1136) - corrected to (72) +rewrite_file: 2 items of file [7086 10688] moved to [7086 851] +vpf-10680: The file [7086 851] has the wrong block count in the StatData (48) - corrected to (0) +rewrite_file: 2 items of file [7086 10689] moved to [7086 852] +vpf-10680: The file [7086 852] has the wrong block count in the StatData (600) - corrected to (0) +rewrite_file: 2 items of file [7086 10690] moved to [7086 853] +vpf-10680: The file [7086 853] has the wrong block count in the StatData (256) - corrected to (0) +rewrite_file: 2 items of file [7086 10691] moved to [7086 854] +vpf-10680: The file [7086 854] has the wrong block count in the StatData (288) - corrected to (0) +rewrite_file: 3 items of file [7086 10692] moved to [7086 856] +vpf-10680: The file [7086 856] has the wrong block count in the StatData (224) - corrected to (0) +rewrite_file: 2 items of file [7086 10693] moved to [7086 857] +vpf-10680: The file [7086 857] has the wrong block count in the StatData (632) - corrected to (0) +rewrite_file: 4 items of file [7086 10708] moved to [7086 858] +vpf-10680: The file [7086 858] has the wrong block count in the StatData (15400) - corrected to (0) +rewrite_file: 2 items of file [7160 10665] moved to [7160 859] +rewrite_file: 2 items of file [7160 10666] moved to [7160 860] +rewrite_file: 1 items of file [7160 10668] moved to [7160 861] +vpf-10680: The file [7160 861] has the wrong block count in the StatData (1240) - corrected to (0) +rewrite_file: 2 items of file [7182 7187] moved to [7182 862] +rewrite_file: 2 items of file [7182 7188] moved to [7182 863] +rewrite_file: 2 items of file [7182 7189] moved to [7182 864] +rewrite_file: 2 items of file [7182 7190] moved to [7182 865] +rewrite_file: 2 items of file [7182 7191] moved to [7182 866] +rewrite_file: 2 items of file [7182 7192] moved to [7182 867] +rewrite_file: 2 items of file [7182 7193] moved to [7182 868] +rewrite_file: 3 items of file [7182 7194] moved to [7182 869] +rewrite_file: 2 items of file [7182 7195] moved to [7182 870] +rewrite_file: 2 items of file [7182 7196] moved to [7182 871] +rewrite_file: 2 items of file [7182 7197] moved to [7182 872] +rewrite_file: 2 items of file [7182 7198] moved to [7182 873] +rewrite_file: 2 items of file [7182 7199] moved to [7182 874] +rewrite_file: 2 items of file [7182 7200] moved to [7182 875] +rewrite_file: 2 items of file [7182 7201] moved to [7182 876] +rewrite_file: 2 items of file [7182 7202] moved to [7182 877] +rewrite_file: 2 items of file [7182 7203] moved to [7182 878] +rewrite_file: 2 items of file [7182 7204] moved to [7182 879] +rewrite_file: 2 items of file [7182 7205] moved to [7182 880] +rewrite_file: 3 items of file [7182 7206] moved to [7182 881] +rewrite_file: 2 items of file [7182 7207] moved to [7182 882] +rewrite_file: 3 items of file [7182 7208] moved to [7182 883] +rewrite_file: 2 items of file [7182 7209] moved to [7182 884] +rewrite_file: 2 items of file [7182 7210] moved to [7182 885] +rewrite_file: 2 items of file [7182 7211] moved to [7182 886] +rewrite_file: 2 items of file [7182 7212] moved to [7182 887] +rewrite_file: 2 items of file [7182 7213] moved to [7182 888] +rewrite_file: 2 items of file [7182 7214] moved to [7182 889] +rewrite_file: 2 items of file [7182 7215] moved to [7182 890] +rewrite_file: 2 items of file [7182 7216] moved to [7182 891] +rewrite_file: 2 items of file [7182 7217] moved to [7182 892] +rewrite_file: 2 items of file [7182 7218] moved to [7182 893] +rewrite_file: 2 items of file [7182 7219] moved to [7182 894] +rewrite_file: 2 items of file [7182 7220] moved to [7182 895] +rewrite_file: 2 items of file [7182 10415] moved to [7182 896] +rewrite_file: 2 items of file [7182 10416] moved to [7182 897] +rewrite_file: 2 items of file [7182 10417] moved to [7182 898] +rewrite_file: 2 items of file [7182 10418] moved to [7182 899] +rewrite_file: 2 items of file [7182 10419] moved to [7182 900] +rewrite_file: 2 items of file [7182 10421] moved to [7182 901] +rewrite_file: 2 items of file [7182 10422] moved to [7182 902] +rewrite_file: 2 items of file [7182 10424] moved to [7182 903] +rewrite_file: 2 items of file [7187 10827] moved to [7187 904] +vpf-10680: The file [7187 904] has the wrong block count in the StatData (80) - corrected to (0) +rewrite_file: 2 items of file [7187 10828] moved to [7187 905] +vpf-10680: The file [7187 905] has the wrong block count in the StatData (208) - corrected to (0) +rewrite_file: 2 items of file [7187 10832] moved to [7187 906] +vpf-10680: The file [7187 906] has the wrong block count in the StatData (200) - corrected to (0) +rewrite_file: 2 items of file [7187 10833] moved to [7187 907] +vpf-10680: The file [7187 907] has the wrong block count in the StatData (208) - corrected to (0) +rewrite_file: 2 items of file [7187 10834] moved to [7187 908] +vpf-10680: The file [7187 908] has the wrong block count in the StatData (144) - corrected to (0) +rewrite_file: 2 items of file [7187 10835] moved to [7187 909] +vpf-10680: The file [7187 909] has the wrong block count in the StatData (208) - corrected to (0) +rewrite_file: 2 items of file [7187 10836] moved to [7187 910] +vpf-10680: The file [7187 910] has the wrong block count in the StatData (216) - corrected to (0) +rewrite_file: 2 items of file [7187 10837] moved to [7187 911] +vpf-10680: The file [7187 911] has the wrong block count in the StatData (192) - corrected to (0) +rewrite_file: 2 items of file [7187 10838] moved to [7187 912] +vpf-10680: The file [7187 912] has the wrong block count in the StatData (200) - corrected to (0) +rewrite_file: 2 items of file [7187 10839] moved to [7187 913] +vpf-10680: The file [7187 913] has the wrong block count in the StatData (200) - corrected to (0) +rewrite_file: 2 items of file [7187 10841] moved to [7187 914] +vpf-10680: The file [7187 914] has the wrong block count in the StatData (7584) - corrected to (0) +rewrite_file: 2 items of file [7258 7289] moved to [7258 915] +rewrite_file: 2 items of file [7258 7290] moved to [7258 916] +vpf-10680: The file [7258 916] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [7258 7293] moved to [7258 917] +rewrite_file: 2 items of file [7258 7294] moved to [7258 918] +vpf-10680: The file [7258 918] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [7258 7296] moved to [7258 919] +vpf-10680: The file [7258 919] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [7258 7299] moved to [7258 920] +rewrite_file: 2 items of file [7258 10411] moved to [7258 921] +vpf-10680: The file [7258 921] has the wrong block count in the StatData (88) - corrected to (0) +rewrite_file: 2 items of file [7258 10413] moved to [7258 922] +vpf-10680: The file [7258 922] has the wrong block count in the StatData (192) - corrected to (0) +rewrite_file: 2 items of file [7277 10856] moved to [7277 923] +rewrite_file: 2 items of file [7285 7303] moved to [7285 924] +rewrite_file: 2 items of file [7285 7307] moved to [7285 925] +rewrite_file: 2 items of file [7285 7310] moved to [7285 926] +rewrite_file: 2 items of file [7285 7318] moved to [7285 927] +rewrite_file: 2 items of file [7285 10351] moved to [7285 928] +rewrite_file: 2 items of file [7285 10352] moved to [7285 929] +rewrite_file: 2 items of file [7324 7326] moved to [7324 930] +vpf-10680: The file [7324 930] has the wrong block count in the StatData (32) - corrected to (0) +rewrite_file: 2 items of file [7324 7327] moved to [7324 931] +vpf-10680: The file [7324 931] has the wrong block count in the StatData (224) - corrected to (0) +rewrite_file: 2 items of file [7324 7329] moved to [7324 932] +vpf-10680: The file [7324 932] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [7324 7330] moved to [7324 933] +rewrite_file: 2 items of file [7324 7331] moved to [7324 934] +rewrite_file: 2 items of file [7324 7332] moved to [7324 935] +vpf-10680: The file [7324 935] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [7324 7333] moved to [7324 936] +vpf-10680: The file [7324 936] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [7324 7334] moved to [7324 937] +rewrite_file: 2 items of file [7324 7335] moved to [7324 938] +vpf-10680: The file [7324 938] has the wrong block count in the StatData (80) - corrected to (0) +rewrite_file: 2 items of file [7324 7336] moved to [7324 939] +rewrite_file: 2 items of file [7324 7337] moved to [7324 940] +rewrite_file: 2 items of file [7324 10810] moved to [7324 941] +rewrite_file: 2 items of file [7349 7352] moved to [7349 942] +rewrite_file: 2 items of file [7349 7353] moved to [7349 943] +rewrite_file: 2 items of file [7349 7354] moved to [7349 944] +rewrite_file: 2 items of file [7349 7355] moved to [7349 945] +rewrite_file: 2 items of file [7349 7356] moved to [7349 946] +rewrite_file: 2 items of file [7349 7357] moved to [7349 947] +rewrite_file: 2 items of file [7349 7358] moved to [7349 948] +rewrite_file: 2 items of file [7349 7359] moved to [7349 949] +rewrite_file: 2 items of file [7349 7360] moved to [7349 950] +rewrite_file: 2 items of file [7349 7361] moved to [7349 951] +rewrite_file: 2 items of file [7349 7362] moved to [7349 952] +rewrite_file: 2 items of file [7349 7363] moved to [7349 953] +rewrite_file: 2 items of file [7349 7364] moved to [7349 954] +rewrite_file: 2 items of file [7349 10395] moved to [7349 955] +rewrite_file: 2 items of file [7349 10396] moved to [7349 956] +rewrite_file: 2 items of file [7349 10399] moved to [7349 957] +rewrite_file: 2 items of file [7349 10400] moved to [7349 958] +rewrite_file: 2 items of file [7349 10406] moved to [7349 959] +rewrite_file: 2 items of file [7349 10408] moved to [7349 960] +rewrite_file: 2 items of file [7349 10409] moved to [7349 961] +rewrite_file: 2 items of file [7349 10410] moved to [7349 962] +rewrite_file: 2 items of file [7351 10775] moved to [7351 963] +rewrite_file: 2 items of file [7363 10766] moved to [7363 964] +rewrite_file: 2 items of file [7363 10768] moved to [7363 965] +rewrite_file: 2 items of file [7374 10331] moved to [7374 966] +rewrite_file: 2 items of file [7381 7384] moved to [7381 967] +rewrite_file: 2 items of file [7381 7385] moved to [7381 968] +rewrite_file: 2 items of file [7407 7408] moved to [7407 969] +rewrite_file: 2 items of file [7407 7409] moved to [7407 970] +rewrite_file: 2 items of file [7407 7410] moved to [7407 971] +vpf-10680: The file [7407 971] has the wrong block count in the StatData (2576) - corrected to (1120) +rewrite_file: 2 items of file [7432 7436] moved to [7432 972] +rewrite_file: 2 items of file [7432 7437] moved to [7432 973] +rewrite_file: 2 items of file [7432 7438] moved to [7432 974] +rewrite_file: 2 items of file [7460 7463] moved to [7460 975] +vpf-10680: The file [7460 975] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [7460 7464] moved to [7460 976] +rewrite_file: 2 items of file [7460 7465] moved to [7460 977] +rewrite_file: 3 items of file [7472 9086] moved to [7472 978] +rewrite_file: 2 items of file [7505 10350] moved to [7505 979] +rewrite_file: 2 items of file [7505 10351] moved to [7505 980] +rewrite_file: 2 items of file [7505 10352] moved to [7505 981] +rewrite_file: 2 items of file [7505 10358] moved to [7505 982] +rewrite_file: 2 items of file [7505 10359] moved to [7505 983] +rewrite_file: 2 items of file [7505 10360] moved to [7505 984] +rewrite_file: 2 items of file [7505 10361] moved to [7505 985] +vpf-10680: The file [8552 8555] has the wrong block count in the StatData (7160) - corrected to (0) +vpf-10680: The file [8552 8556] has the wrong block count in the StatData (8200) - corrected to (0) +vpf-10680: The file [8552 8557] has the wrong block count in the StatData (7432) - corrected to (0) +vpf-10680: The file [8552 8558] has the wrong block count in the StatData (520) - corrected to (0) +vpf-10680: The file [8552 8559] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8560] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8561] has the wrong block count in the StatData (4104) - corrected to (0) +vpf-10680: The file [8552 8562] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [8552 8563] has the wrong block count in the StatData (264) - corrected to (0) +vpf-10680: The file [8552 8564] has the wrong block count in the StatData (520) - corrected to (0) +vpf-10680: The file [8552 8565] has the wrong block count in the StatData (520) - corrected to (0) +vpf-10680: The file [8552 8566] has the wrong block count in the StatData (1032) - corrected to (0) +vpf-10680: The file [8552 8567] has the wrong block count in the StatData (1032) - corrected to (0) +vpf-10680: The file [8552 8568] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8569] has the wrong block count in the StatData (8200) - corrected to (0) +vpf-10680: The file [8552 8570] has the wrong block count in the StatData (8200) - corrected to (0) +vpf-10680: The file [8552 8571] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [8552 8572] has the wrong block count in the StatData (520) - corrected to (0) +vpf-10680: The file [8552 8573] has the wrong block count in the StatData (520) - corrected to (0) +vpf-10680: The file [8552 8574] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8575] has the wrong block count in the StatData (520) - corrected to (0) +vpf-10680: The file [8552 8576] has the wrong block count in the StatData (264) - corrected to (0) +vpf-10680: The file [8552 8577] has the wrong block count in the StatData (264) - corrected to (0) +vpf-10680: The file [8552 8578] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8579] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8580] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8581] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8582] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8583] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8584] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8585] has the wrong block count in the StatData (2056) - corrected to (0) +vpf-10680: The file [8552 8586] has the wrong block count in the StatData (2056) - corrected to (0) +rewrite_file: 2 items of file [9051 10424] moved to [9051 986] +vpf-10680: The file [9051 986] has the wrong block count in the StatData (64) - corrected to (0) +rewrite_file: 2 items of file [9051 10425] moved to [9051 987] +vpf-10680: The file [9051 987] has the wrong block count in the StatData (56) - corrected to (0) +rewrite_file: 2 items of file [9051 10426] moved to [9051 988] +vpf-10680: The file [9051 988] has the wrong block count in the StatData (32) - corrected to (0) +rewrite_file: 2 items of file [9051 10460] moved to [9051 989] +vpf-10680: The file [9051 989] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [9051 10462] has the wrong block count in the StatData (184) - corrected to (0) +vpf-10680: The file [9077 9079] has the wrong block count in the StatData (1584) - corrected to (8) +vpf-10680: The file [9077 9081] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [9077 9082] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [9077 9083] has the wrong block count in the StatData (112) - corrected to (8) +rewrite_file: 2 items of file [9371 9381] moved to [9371 990] +vpf-10680: The file [9371 990] has the wrong block count in the StatData (480) - corrected to (472) +rewrite_file: 2 items of file [9371 9382] moved to [9371 991] +rewrite_file: 2 items of file [9383 9384] moved to [9383 992] +vpf-10680: The file [9383 992] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [9383 9385] moved to [9383 993] +vpf-10680: The file [9383 993] has the wrong block count in the StatData (56) - corrected to (0) +rewrite_file: 2 items of file [9383 9386] moved to [9383 994] +rewrite_file: 2 items of file [9387 9388] moved to [9387 995] +rewrite_file: 2 items of file [9387 9389] moved to [9387 996] +rewrite_file: 2 items of file [9398 9401] moved to [9398 997] +vpf-10680: The file [9398 997] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9398 9402] moved to [9398 998] +rewrite_file: 2 items of file [9430 9433] moved to [9430 999] +rewrite_file: 2 items of file [9443 9444] moved to [9443 1000] +vpf-10680: The file [9443 1000] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [9443 9445] moved to [9443 1001] +vpf-10680: The file [9443 1001] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 9446] moved to [9443 1002] +vpf-10680: The file [9443 1002] has the wrong block count in the StatData (40) - corrected to (0) +rewrite_file: 2 items of file [9443 9447] moved to [9443 1003] +vpf-10680: The file [9443 1003] has the wrong block count in the StatData (32) - corrected to (0) +rewrite_file: 2 items of file [9443 9448] moved to [9443 1004] +vpf-10680: The file [9443 1004] has the wrong block count in the StatData (32) - corrected to (0) +rewrite_file: 2 items of file [9443 9449] moved to [9443 1005] +vpf-10680: The file [9443 1005] has the wrong block count in the StatData (64) - corrected to (0) +rewrite_file: 3 items of file [9443 9450] moved to [9443 1006] +rewrite_file: 1 items of file [9443 9451] moved to [9443 1007] +vpf-10680: The file [9443 1007] has the wrong block count in the StatData (8) - corrected to (0) +rewrite_file: 2 items of file [9443 9502] moved to [9443 1008] +vpf-10680: The file [9443 1008] has the wrong block count in the StatData (96) - corrected to (0) +rewrite_file: 2 items of file [9443 9503] moved to [9443 1009] +vpf-10680: The file [9443 1009] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 9504] moved to [9443 1010] +vpf-10680: The file [9443 1010] has the wrong block count in the StatData (1200) - corrected to (0) +rewrite_file: 2 items of file [9443 9505] moved to [9443 1011] +vpf-10680: The file [9443 1011] has the wrong block count in the StatData (40) - corrected to (0) +rewrite_file: 2 items of file [9443 9506] moved to [9443 1012] +vpf-10680: The file [9443 1012] has the wrong block count in the StatData (64) - corrected to (0) +rewrite_file: 2 items of file [9443 9507] moved to [9443 1013] +vpf-10680: The file [9443 1013] has the wrong block count in the StatData (104) - corrected to (0) +rewrite_file: 2 items of file [9443 9508] moved to [9443 1014] +vpf-10680: The file [9443 1014] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 9509] moved to [9443 1015] +rewrite_file: 2 items of file [9443 9510] moved to [9443 1016] +vpf-10680: The file [9443 1016] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 9511] moved to [9443 1017] +rewrite_file: 3 items of file [9443 9512] moved to [9443 1018] +rewrite_file: 2 items of file [9443 10261] moved to [9443 1019] +rewrite_file: 2 items of file [9443 10262] moved to [9443 1020] +rewrite_file: 2 items of file [9443 10263] moved to [9443 1021] +rewrite_file: 2 items of file [9443 10264] moved to [9443 1022] +vpf-10680: The file [9443 1022] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 10265] moved to [9443 1023] +rewrite_file: 2 items of file [9443 10271] moved to [9443 1024] +rewrite_file: 2 items of file [9443 10272] moved to [9443 1025] +rewrite_file: 2 items of file [9443 10273] moved to [9443 1026] +rewrite_file: 2 items of file [9443 10274] moved to [9443 1027] +vpf-10680: The file [9443 1027] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 10275] moved to [9443 1028] +vpf-10680: The file [9443 1028] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 3 items of file [9443 10276] moved to [9443 1029] +rewrite_file: 2 items of file [9443 10277] moved to [9443 1030] +rewrite_file: 2 items of file [9443 10278] moved to [9443 1031] +rewrite_file: 2 items of file [9443 10279] moved to [9443 1032] +rewrite_file: 3 items of file [9443 10280] moved to [9443 1033] +rewrite_file: 2 items of file [9443 10281] moved to [9443 1034] +rewrite_file: 2 items of file [9443 10282] moved to [9443 1035] +rewrite_file: 2 items of file [9443 10283] moved to [9443 1036] +rewrite_file: 3 items of file [9443 10284] moved to [9443 1037] +rewrite_file: 2 items of file [9443 10285] moved to [9443 1038] +rewrite_file: 2 items of file [9443 10286] moved to [9443 1039] +vpf-10680: The file [9443 1039] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [9443 10287] moved to [9443 1040] +vpf-10680: The file [9443 1040] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 10288] moved to [9443 1041] +vpf-10680: The file [9443 1041] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 3 items of file [9443 10289] moved to [9443 1042] +rewrite_file: 2 items of file [9443 10290] moved to [9443 1043] +vpf-10680: The file [9443 1043] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 3 items of file [9443 10291] moved to [9443 1044] +rewrite_file: 2 items of file [9443 10292] moved to [9443 1045] +rewrite_file: 3 items of file [9443 10293] moved to [9443 1046] +rewrite_file: 2 items of file [9443 10294] moved to [9443 1047] +rewrite_file: 3 items of file [9443 10295] moved to [9443 1048] +rewrite_file: 2 items of file [9443 10296] moved to [9443 1049] +rewrite_file: 2 items of file [9443 10297] moved to [9443 1050] +rewrite_file: 3 items of file [9443 10298] moved to [9443 1051] +rewrite_file: 2 items of file [9443 10299] moved to [9443 1052] +vpf-10680: The file [9443 1052] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [9443 10300] moved to [9443 1053] +vpf-10680: The file [9443 1053] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 3 items of file [9443 10301] moved to [9443 1054] +rewrite_file: 2 items of file [9443 10302] moved to [9443 1055] +rewrite_file: 2 items of file [9443 10303] moved to [9443 1056] +rewrite_file: 2 items of file [9443 10304] moved to [9443 1057] +vpf-10680: The file [9443 1057] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [9443 10305] moved to [9443 1058] +vpf-10680: The file [9443 1058] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 3 items of file [9443 10306] moved to [9443 1059] +rewrite_file: 2 items of file [9443 10308] moved to [9443 1060] +vpf-10680: The file [9443 1060] has the wrong block count in the StatData (304) - corrected to (0) +rewrite_file: 2 items of file [9915 9916] moved to [9915 1061] +rewrite_file: 2 items of file [9915 9928] moved to [9915 1062] +rewrite_file: 2 items of file [9915 9929] moved to [9915 1063] +rewrite_file: 2 items of file [10044 10047] moved to [10044 1064] +rewrite_file: 3 items of file [10044 10048] moved to [10044 1065] +vpf-10680: The file [10044 1065] has the wrong block count in the StatData (6320) - corrected to (6280) +rewrite_file: 3 items of file [10044 10049] moved to [10044 1066] +vpf-10680: The file [10044 1066] has the wrong block count in the StatData (6320) - corrected to (4056) +rewrite_file: 2 items of file [10044 10051] moved to [10044 1067] +rewrite_file: 2 items of file [10044 10052] moved to [10044 1068] +rewrite_file: 2 items of file [10044 10106] moved to [10044 1069] +rewrite_file: 2 items of file [10044 10107] moved to [10044 1070] +rewrite_file: 2 items of file [10044 10203] moved to [10044 1071] +rewrite_file: 2 items of file [10044 10227] moved to [10044 1072] +rewrite_file: 2 items of file [10044 10233] moved to [10044 1073] +rewrite_file: 2 items of file [10044 10234] moved to [10044 1074] +rewrite_file: 2 items of file [10044 10235] moved to [10044 1075] +rewrite_file: 2 items of file [10044 10236] moved to [10044 1076] +rewrite_file: 2 items of file [10044 10237] moved to [10044 1077] +rewrite_file: 2 items of file [10044 10238] moved to [10044 1078] +rewrite_file: 2 items of file [10044 10239] moved to [10044 1079] +rewrite_file: 2 items of file [10044 10243] moved to [10044 1080] +rewrite_file: 2 items of file [10044 10244] moved to [10044 1081] +rewrite_file: 2 items of file [10044 10245] moved to [10044 1082] +rewrite_file: 2 items of file [10044 10248] moved to [10044 1083] +rewrite_file: 2 items of file [10044 10249] moved to [10044 1084] +rewrite_file: 2 items of file [10044 10258] moved to [10044 1085] +rewrite_file: 2 items of file [10044 10307] moved to [10044 1086] +rewrite_file: 2 items of file [10044 10312] moved to [10044 1087] +rewrite_file: 2 items of file [10044 10314] moved to [10044 1088] +rewrite_file: 2 items of file [10044 10329] moved to [10044 1089] +rewrite_file: 2 items of file [10044 10330] moved to [10044 1090] +rewrite_file: 2 items of file [10044 10345] moved to [10044 1091] +rewrite_file: 2 items of file [10044 10366] moved to [10044 1092] +rewrite_file: 2 items of file [10044 10414] moved to [10044 1093] +rewrite_file: 3 items of file [10044 10577] moved to [10044 1094] +rewrite_file: 2 items of file [10044 10669] moved to [10044 1095] +rewrite_file: 4 items of file [10044 10709] moved to [10044 1096] +rewrite_file: 2 items of file [10044 10743] moved to [10044 1097] +rewrite_file: 3 items of file [10044 10752] moved to [10044 1098] +rewrite_file: 2 items of file [10044 10761] moved to [10044 1099] +rewrite_file: 2 items of file [10044 10769] moved to [10044 1100] +rewrite_file: 2 items of file [10044 10779] moved to [10044 1101] +rewrite_file: 3 items of file [10044 10786] moved to [10044 1102] +rewrite_file: 2 items of file [10045 7321] moved to [10045 1103] +vpf-10680: The file [10045 1103] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [10220 10221] moved to [10220 1104] +rewrite_file: 2 items of file [10220 10222] moved to [10220 1105] +rewrite_file: 2 items of file [10220 10269] moved to [10220 1106] +vpf-10680: The file [10220 1106] has the wrong block count in the StatData (24) - corrected to (0) +rewrite_file: 2 items of file [10220 10270] moved to [10220 1107] +vpf-10680: The file [10220 1107] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [10220 10271] moved to [10220 1108] +vpf-10680: The file [10220 1108] has the wrong block count in the StatData (48) - corrected to (0) +rewrite_file: 2 items of file [10220 10272] moved to [10220 1109] +rewrite_file: 2 items of file [10220 10273] moved to [10220 1110] +vpf-10680: The file [10220 1110] has the wrong block count in the StatData (16) - corrected to (0) +rewrite_file: 2 items of file [10220 10274] moved to [10220 1111] +vpf-10680: The file [10220 1111] has the wrong block count in the StatData (8) - corrected to (0) +rewrite_file: 2 items of file [10277 10278] moved to [10277 1112] +rewrite_file: 2 items of file [10289 10338] moved to [10289 1113] +rewrite_file: 2 items of file [10289 10345] moved to [10289 1114] +rewrite_file: 2 items of file [10289 10346] moved to [10289 1115] +rewrite_file: 2 items of file [10615 10687] moved to [10615 1116] +rewrite_file: 2 items of file [10690 10691] moved to [10690 1117] +rewrite_file: 2 items of file [10690 10692] moved to [10690 1118] +rewrite_file: 2 items of file [10690 10693] moved to [10690 1119] +rewrite_file: 2 items of file [10797 10808] moved to [10797 1120] +rewrite_file: 2 items of file [10797 10809] moved to [10797 1121] +rewrite_file: 2 items of file [10797 10810] moved to [10797 1122] +rewrite_file: 2 items of file [10797 10811] moved to [10797 1123] +rewrite_file: 2 items of file [10797 10812] moved to [10797 1124] +rewrite_file: 3 items of file [10797 10813] moved to [10797 1125] +rewrite_file: 2 items of file [10797 10814] moved to [10797 1126] +rewrite_file: 2 items of file [10797 10815] moved to [10797 1127] +rewrite_file: 2 items of file [10797 10816] moved to [10797 1128] +rewrite_file: 2 items of file [10797 10817] moved to [10797 1129] +rewrite_file: 2 items of file [10797 10818] moved to [10797 1130] +rewrite_file: 3 items of file [10797 10819] moved to [10797 1131] +rewrite_file: 2 items of file [10797 10820] moved to [10797 1132] +rewrite_file: 2 items of file [10797 10821] moved to [10797 1133] +rewrite_file: 3 items of file [10797 10822] moved to [10797 1134] +rewrite_file: 2 items of file [10797 10823] moved to [10797 1135] +rewrite_file: 2 items of file [10797 10824] moved to [10797 1136] +rewrite_file: 2 items of file [10797 10825] moved to [10797 1137] +rewrite_file: 2 items of file [10797 10826] moved to [10797 1138] +rewrite_file: 2 items of file [10840 10843] moved to [10840 1139] +rewrite_file: 1 items of file [10840 10844] moved to [10840 1140] +vpf-10680: The file [10840 1140] has the wrong block count in the StatData (8) - corrected to (0) +rewrite_file: 2 items of file [10855 10858] moved to [10855 1141] +vpf-10680: The file [10872 10931] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [10872 10950] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [10872 10967] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [11009 11055] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [11230 11233] has the wrong block count in the StatData (24) - corrected to (8) +vpf-10680: The file [11230 11234] has the wrong block count in the StatData (16) - corrected to (8) +vpf-10680: The file [11264 11267] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [11645 11674] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [11645 11675] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [11645 11677] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [11645 11679] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [11645 11681] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [11645 11684] has the wrong block count in the StatData (176) - corrected to (0) +vpf-10680: The file [11645 11685] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [11645 11687] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [11645 11688] has the wrong block count in the StatData (208) - corrected to (0) +vpf-10680: The file [11645 11689] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [11645 11690] has the wrong block count in the StatData (224) - corrected to (0) +vpf-10680: The file [11645 11696] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [11645 11698] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [11645 11701] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [11645 11702] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [11645 11704] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [11645 11706] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [11645 11708] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [11645 11711] has the wrong block count in the StatData (104) - corrected to (0) +vpf-10680: The file [11645 11717] has the wrong block count in the StatData (80) - corrected to (0) +vpf-10680: The file [11722 11723] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [11722 11724] has the wrong block count in the StatData (360) - corrected to (0) +vpf-10680: The file [11722 11725] has the wrong block count in the StatData (88) - corrected to (0) +vpf-10680: The file [11722 11726] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [11722 11727] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [11722 11728] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12557 12566] has the wrong block count in the StatData (144) - corrected to (112) +vpf-10680: The file [12557 12567] has the wrong block count in the StatData (608) - corrected to (0) +vpf-10680: The file [12557 12569] has the wrong block count in the StatData (144) - corrected to (0) +vpf-10680: The file [12557 12570] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12572 12573] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [12572 12575] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12572 12577] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [12572 12578] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [12572 12579] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [12572 12580] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12572 12581] has the wrong block count in the StatData (104) - corrected to (0) +vpf-10680: The file [12572 12583] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12572 12585] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12572 12587] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [12572 12588] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12572 12591] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12572 12592] has the wrong block count in the StatData (80) - corrected to (0) +vpf-10680: The file [12572 12593] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [12572 12594] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [12572 12595] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12572 12596] has the wrong block count in the StatData (96) - corrected to (0) +vpf-10680: The file [12602 12603] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12602 12605] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [12602 12607] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12616 12622] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12616 12624] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12616 12625] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12616 12629] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [12616 12630] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [12616 12631] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [12616 12632] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [12616 12633] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [12643 12648] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12643 12649] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12643 12650] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [12643 12653] has the wrong block count in the StatData (288) - corrected to (0) +vpf-10680: The file [12643 12654] has the wrong block count in the StatData (112) - corrected to (0) +vpf-10680: The file [12643 12655] has the wrong block count in the StatData (80) - corrected to (0) +vpf-10680: The file [12643 12656] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [12643 12657] has the wrong block count in the StatData (112) - corrected to (0) +vpf-10680: The file [12643 12659] has the wrong block count in the StatData (200) - corrected to (0) +vpf-10680: The file [12643 12660] has the wrong block count in the StatData (80) - corrected to (0) +vpf-10680: The file [12643 12662] has the wrong block count in the StatData (152) - corrected to (0) +vpf-10680: The file [12643 12663] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [12643 12664] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [13226 13237] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [13226 13239] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [13226 13240] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13226 13241] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [13226 13243] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [13226 13244] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13245] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13247] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13250] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13251] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13252] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [13226 13254] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13257] has the wrong block count in the StatData (168) - corrected to (0) +vpf-10680: The file [13226 13258] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13259] has the wrong block count in the StatData (80) - corrected to (0) +vpf-10680: The file [13226 13260] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [13226 13261] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [13226 13262] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [13226 13266] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13269] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13272] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13226 13274] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13277] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13278] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13226 13279] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13281] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13283] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13285] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13292] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [13226 13293] has the wrong block count in the StatData (144) - corrected to (0) +vpf-10680: The file [13226 13294] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13295] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13296] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [13226 13297] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13226 13298] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [13226 13300] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13226 13302] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [13226 13303] has the wrong block count in the StatData (152) - corrected to (0) +vpf-10680: The file [13226 13304] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13226 13306] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13307 13309] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [13307 13310] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13307 13311] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13307 13312] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13307 13315] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [13307 13316] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [13307 13318] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [13307 13319] has the wrong block count in the StatData (104) - corrected to (0) +vpf-10680: The file [13307 13320] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [13575 13587] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [13575 13588] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [13575 13590] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [13575 13591] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [16248 16254] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [16248 16255] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [16248 16256] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [16248 16257] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [16248 16258] has the wrong block count in the StatData (80) - corrected to (0) +vpf-10680: The file [16248 16259] has the wrong block count in the StatData (112) - corrected to (0) +vpf-10680: The file [16248 16260] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [16248 16262] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [16248 16263] has the wrong block count in the StatData (120) - corrected to (0) +vpf-10680: The file [16248 16264] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [16248 16265] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [16248 16266] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [16248 16267] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [16248 16268] has the wrong block count in the StatData (136) - corrected to (0) +vpf-10680: The file [16248 16269] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [16248 16270] has the wrong block count in the StatData (248) - corrected to (0) +vpf-10680: The file [17029 17036] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [17029 17037] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [17029 17038] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [17029 17039] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [17029 17040] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17041 17043] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [17041 17045] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [17212 17220] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [17221 17222] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17221 17223] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [17221 17229] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [17221 17231] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [17221 17233] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17221 17234] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17221 17235] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [17221 17238] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17221 17239] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [17221 17240] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [17241 17243] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17241 17244] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [17241 17245] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [17241 17254] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [18087 18091] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [18087 18092] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [18087 18093] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18094] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18095] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18096] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18099] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [18087 18101] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18102] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [18087 18103] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [18087 18104] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [18087 18105] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18107] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18109] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18110] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18111] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18087 18112] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [18087 18114] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [18126 18127] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [18126 18128] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [18126 18130] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [19326 19331] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [19326 19341] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [19326 19343] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22745 22749] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22745 22751] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [22745 22752] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [22745 22753] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22745 22755] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22745 22757] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22745 22759] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22745 22760] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22745 22761] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22745 22762] has the wrong block count in the StatData (112) - corrected to (0) +vpf-10680: The file [22745 22763] has the wrong block count in the StatData (48) - corrected to (0) +vpf-10680: The file [22745 22764] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22745 22765] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22800 22802] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22800 22803] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22800 22804] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22800 22805] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22800 22806] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [22861 22868] has the wrong block count in the StatData (56) - corrected to (0) +vpf-10680: The file [22861 22870] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22872] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22861 22873] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22861 22874] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22875] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22861 22877] has the wrong block count in the StatData (152) - corrected to (0) +vpf-10680: The file [22861 22878] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22861 22879] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22881] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22884] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22861 22885] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22886] has the wrong block count in the StatData (224) - corrected to (0) +vpf-10680: The file [22861 22887] has the wrong block count in the StatData (40) - corrected to (0) +vpf-10680: The file [22861 22888] has the wrong block count in the StatData (88) - corrected to (0) +vpf-10680: The file [22861 22889] has the wrong block count in the StatData (64) - corrected to (0) +vpf-10680: The file [22861 22891] has the wrong block count in the StatData (392) - corrected to (0) +vpf-10680: The file [22861 22892] has the wrong block count in the StatData (72) - corrected to (0) +vpf-10680: The file [22861 22893] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22894] has the wrong block count in the StatData (128) - corrected to (0) +vpf-10680: The file [22861 22895] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [22861 22897] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22898] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22899] has the wrong block count in the StatData (104) - corrected to (0) +vpf-10680: The file [22861 22900] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22901] has the wrong block count in the StatData (88) - corrected to (0) +vpf-10680: The file [22861 22903] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [22861 22905] has the wrong block count in the StatData (112) - corrected to (0) +vpf-10680: The file [22861 22906] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [22907 22909] has the wrong block count in the StatData (96) - corrected to (72) +vpf-10680: The file [22907 22910] has the wrong block count in the StatData (8) - corrected to (0) +vpf-10680: The file [23910 23912] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [23910 23913] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [23910 23917] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [23910 23918] has the wrong block count in the StatData (24) - corrected to (0) +vpf-10680: The file [23910 23919] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [23910 23920] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [23910 23921] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [23910 23922] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [23956 23957] has the wrong block count in the StatData (32) - corrected to (0) +vpf-10680: The file [23956 23958] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [23956 23962] has the wrong block count in the StatData (16) - corrected to (0) +vpf-10680: The file [23956 23963] has the wrong block count in the StatData (24) - corrected to (0) diff --git a/version.txt b/version.txt new file mode 100755 index 0000000..7be2b17 --- /dev/null +++ b/version.txt @@ -0,0 +1,4 @@ +01.07.03 D&B +EXE Version 01.07.03 D&B +Release Date: Tuesday, February 3rd, 2009 +9